Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

3 строки
9.6 KiB

  1. var e,r;e=this,r=function(e){"use strict";function r(e,r,n,t,o,i){var a,f,u,c,p;n&&(Array.isArray(o)?function(e,r,n,t,o,i){for(var a=Math.min(o.length,i.length),f=0;f<a;f++)if(e.assigned[f]&&o[f]!==i[f]){var u=r.concat(f);n.push({op:"replace",path:u,value:i[f]}),t.push({op:"replace",path:u,value:o[f]})}if(a<i.length){for(var c=a;c<i.length;c++){var p=r.concat(c);n.push({op:"add",path:p,value:i[c]})}t.push({op:"replace",path:r.concat("length"),value:o.length})}else if(a<o.length){n.push({op:"replace",path:r.concat("length"),value:i.length});for(var s=a;s<o.length;s++){var d=r.concat(s);t.push({op:"add",path:d,value:o[s]})}}}(e,r,n,t,o,i):(a=r,f=n,u=t,c=o,p=i,v(e.assigned,function(e,r){var n=c[e],t=p[e],o=r?e in c?"replace":"add":"remove";if(n!==c||"replace"!==o){var i=a.concat(e);f.push("remove"===o?{op:o,path:i}:{op:o,path:i,value:t}),u.push("add"===o?{op:"remove",path:i}:"remove"===o?{op:"add",path:i,value:n}:{op:"replace",path:i,value:n})}})))}var n,t,o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a="undefined"!=typeof Symbol?Symbol("immer-nothing"):(o=!0,(t="immer-nothing")in(n={})?Object.defineProperty(n,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[t]=o,n),f="undefined"!=typeof Symbol?Symbol("immer-proxy-state"):"__$immer_state",u="An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.";var c=!("undefined"!=typeof process&&"production"===process.env.NODE_ENV||"verifyMinified"!==function(){}.name),p="undefined"!=typeof Proxy;function s(e){return!!e&&!!e[f]}function d(e){if(!e)return!1;if("object"!==(void 0===e?"undefined":i(e)))return!1;if(Array.isArray(e))return!0;var r=Object.getPrototypeOf(e);return null===r||r===Object.prototype}function l(e){return c&&Object.freeze(e),e}var h=Object.assign||function(e,r){for(var n in r)g(r,n)&&(e[n]=r[n]);return e};function y(e){if(Array.isArray(e))return e.slice();var r=void 0===e.__proto__?Object.create(null):{};return h(r,e)}function v(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(n,e[n]);else for(var t in e)r(t,e[t])}function g(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function m(e,n,t,o){if(s(e)){var i=e[f];if(!0===i.modified){if(!0===i.finalized)return i.copy;i.finalized=!0;var a=(u=p?i.copy:i.copy=y(e),h=n,b=t,w=o,O=(c=i).base,v(u,function(e,r){if(r!==O[e]){var n=b&&!g(c.assigned,e);u[e]=m(r,n&&h.concat(e),n&&b,w)}}),l(u));return r(i,n,t,o,i.base,a),a}return i.base}var u,c,h,b,w,O;return function e(r){if(!d(r))return;if(Object.isFrozen(r))return;v(r,function(n,t){s(t)?r[n]=m(t):e(t)});l(r)}(e),e}function b(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var w=null,O={get:function(e,r){if(r===f)return e;if(e.modified){var n=e.copy[r];return n===e.base[r]&&d(n)?e.copy[r]=A(e,n):n}if(g(e.proxies,r))return e.proxies[r];var t=e.base[r];return!s(t)&&d(t)?e.proxies[r]=A(e,t):t},has:function(e,r){return r in x(e)},ownKeys:function(e){return Reflect.ownKeys(x(e))},set:function(e,r,n){if(e.assigned[r]=!0,!e.modified){if(r in e.base&&b(e.base[r],n)||g(e.proxies,r)&&e.proxies[r]===n)return!0;P(e)}return e.copy[r]=n,!0},deleteProperty:function(e,r){return e.assigned[r]=!1,P(e),delete e.copy[r],!0},getOwnPropertyDescriptor:function(e,r){var n=e.modified?e.copy:g(e.proxies,r)?e.proxies:e.base,t=Reflect.getOwnPropertyDescriptor(n,r);!t||Array.isArray(n)&&"length"===r||(t.configurable=!0);return t},defineProperty:function(){throw new Error("Immer does not support defining properties on draft objects.")},setPrototypeOf:function(){throw new Error("Immer does not support `setPrototypeOf()`.")}},j={};function x(e){return!0===e.modified?e.copy:e.base}function P(e){e.modified||(e.modified=!0,e.copy=y(e.base),Object.assign(e.copy,e.proxies),e.parent&&P(e.parent))}function A(e,r,n){if(s(r))throw new Error("Immer bug. Plz report.");var t={modified:!1,assigned:{},finalized:!1,parent:e,base:r,copy:void 0,proxies:{}},o=Array.isArray(r)?Proxy.revocable([t],j):Proxy.revocable(t,O);return w.push(o),o.proxy}v(O,function(e,r){j[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),j.deleteProperty=function(e,r){if(isNaN(parseInt(r)))throw new Error("Immer does not support deleting properties from arrays: "+r);return O.deleteProperty.call(this,e[0],r)},j.set=function(e,r,n){if("length"!==r&&isNaN(parseInt(r)))throw new Error("Immer does not support setting non-numeric properties on arrays: "+r);return O.set.call(this,e[0],r,n)};var E={},k=null;function z(e){return e.hasCopy?e.copy:e.base}function S(e){e.modified||(e.modified=!0,e.parent&&S(e.parent))}function _(e){e.hasCopy||(e.hasCopy=!0,e.copy=y(e.base))}function C(e,r){var n=y(r);v(r,function(e){var r;Object.defineProperty(n,""+e,E[r=""+e]||(E[r]={configurable:!0,enumerable:!0,get:function(){return function(e,r){I(e);var n=z(e)[r];return!e.finalizing&&n===e.base[r]&&d(n)?(_(e),e.copy[r]=C(e,n)):n}(this[f],r)},set:function(e){!function(e,r,n){if(I(e),e.assigned[r]=!0,!e.modified){if(b(z(e)[r],n))return;S(e),_(e)}e.copy[r]=n}(this[f],r,e)}}))});var t,o,i,a={modified:!1,assigned:{},hasCopy:!1,parent:e,base:r,proxy:n,copy:void 0,finished:!1,finalizing:!1,finalized:!1};return t=n,o=f,i=a,Object.defineProperty(t,o,{value:i,enumerable:!1,writable:!0}),k.push(a),n}function I(e){if(!0===e.finished)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(e.copy||e.base))}function N(e){if(e&&"object"===(void 0===e?"undefined":i(e))){var r=e[f];if(r){var n,t,o,a,u=r.proxy,c=r.base;if(Array.isArray(e)){if(D(r)){if(S(r),r.assigned.length=!0,u.length<c.length)for(var p=u.length;p<c.length;p++)r.assigned[p]=!1;else for(var s=c.length;s<u.length;s++)r.assigned[s]=!0;v(u,function(e,n){r.assigned[e]||N(n)})}}else{var d=(n=c,t=u,o=Object.keys(n),{added:(a=Object.keys(t)).filter(function(e){return-1===o.indexOf(e)}),removed:o.filter(function(e){return-1===a.indexOf(e)})}),l=d.added,h=d.removed;(l.length>0||h.length>0)&&S(r),v(l,function(e,n){r.assigned[n]=!0}),v(h,function(e,n){r.assigned[n]=!1}),v(u,function(e,n){r.assigned[e]||N(n)})}}}}function D(e){var r=e.proxy;if(r.length!==e.base.length)return!0;var n=Object.getOwnPropertyDescriptor(r,r.length-1);return!(!n||n.get)}function M(e,r,n){if(s(e)){var t=r.call(e,e);return void 0===t?e:t}var o=k;k=[];var a=n&&[],c=n&&[];try{var p=C(void 0,e),d=r.call(p,p);v(k,function(e,r){r.finalizing=!0});var l=void 0;if(void 0!==d&&d!==p){if(p[f].modified)throw new Error(u);l=m(d),a&&(a.push({op:"replace",path:[],value:l}),c.push({op:"replace",path:[],value:e}))}else n&&N(p),function(){for(var e=k.length-1;e>=0;e--){var r=k[e];!1===r.modified&&(Array.isArray(r.base)?D(r)&&S(r):(n=r,t=Object.keys(n.base),o=Object.keys(n.proxy),function(e,r){if(b(e,r))return!0;if("object"!==(void 0===e?"undefined":i(e))||null===e||"object"!==(void 0===r?"undefined":i(r))||null===r)return!1;var n=Object.keys(e),t=Object.keys(r);if(n.length!==t.length)return!1;for(var o=0;o<n.length;o++)if(!hasOwnProperty.call(r,n[o])||!b(e[n[o]],r[n[o]]))return!1;return!0}(t,o)||S(r)))}var n,t,o}(),l=m(p,[],a,c);return v(k,function(e,r){r.finished=!0}),n&&n(a,c),l}finally{k=o}}function R(e,r,n){if(arguments.length<1||arguments.length>3)throw new Error("produce expects 1 to 3 arguments, got "+arguments.length);if("function"==typeof e){if("function"==typeof r)throw new Error("if first argument is a function (curried invocation), the second argument to produce cannot be a function");var t=r,o=e;return function(){var e=arguments;return R(void 0===e[0]&&void 0!==t?t:e[0],function(r){return e[0]=r,o.apply(r,e)})}}if("function"!=typeof r)throw new Error("if first argument is not a function, the second argument to produce should be a function");if(void 0!==n&&"function"!=typeof n)throw new Error("the third argument of a producer should not be set or a function");if("object"!==(void 0===e?"undefined":i(e))||null===e){var a=r(e);return void 0===a?e:F(a)}if(!d(e))throw new Error("the first argument to an immer producer should be a primitive, plain object or array, got "+(void 0===e?"undefined":i(e))+': "'+e+'"');return F(p?function(e,r,n){if(s(e)){var t=r.call(e,e);return void 0===t?e:t}var o=w;w=[];var i=n&&[],a=n&&[];try{var c=A(void 0,e),p=r.call(c,c),d=void 0;if(void 0!==p&&p!==c){if(c[f].modified)throw new Error(u);d=m(p),i&&(i.push({op:"replace",path:[],value:d}),a.push({op:"replace",path:[],value:e}))}else d=m(c,[],i,a);return v(w,function(e,r){return r.revoke()}),n&&n(i,a),d}finally{w=o}}(e,r,n):M(e,r,n))}function F(e){return e===a?void 0:e}var K=R(function(e,r){for(var n=function(n){var t=r[n];if(0===t.path.length&&"replace"===t.op)e=t.value;else{var o=t.path.slice(),i=o.pop(),a=o.reduce(function(e,r){if(!e)throw new Error("Cannot apply patch, path doesn't resolve: "+t.path.join("/"));return e[r]},e);if(!a)throw new Error("Cannot apply patch, path doesn't resolve: "+t.path.join("/"));switch(t.op){case"replace":case"add":a[i]=t.value;break;case"remove":if(Array.isArray(a)){if(i!==a.length-1)throw new Error("Remove can only remove the last key of an array, index: "+i+", length: "+a.length);a.length-=1}else delete a[i];break;default:throw new Error("Unsupported patch operation: "+t.op)}}},t=0;t<r.length;t++)n(t);return e}),U=a;e.produce=R,e.default=R,e.applyPatches=K,e.nothing=U,e.setAutoFreeze=function(e){c=e},e.setUseProxies=function(e){p=e},e.original=function(e){if(e&&e[f])return e[f].base},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.immer={});
  2. //# sourceMappingURL=immer.umd.js.map