Comparing version 10.0.0-beta.4 to 10.0.0-beta.6
@@ -854,3 +854,3 @@ 'use strict'; | ||
// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft | ||
var draft = isMap(value) ? proxyMap(value, parent) : isSet(value) ? proxySet(value, parent) : createProxyProxy(value, parent); | ||
var draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent); | ||
var scope = parent ? parent.scope_ : getCurrentScope(); | ||
@@ -887,266 +887,2 @@ scope.drafts_.push(draft); | ||
var DraftMap = /*#__PURE__*/function (_Map, _Symbol$iterator) { | ||
_inheritsLoose(DraftMap, _Map); | ||
function DraftMap(target, parent) { | ||
var _this; | ||
_this = _Map.call(this) || this; | ||
_this[DRAFT_STATE] = { | ||
type_: 2 /* Map */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
assigned_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this), | ||
isManual_: false, | ||
revoked_: false | ||
}; | ||
return _this; | ||
} | ||
var _proto = DraftMap.prototype; | ||
_proto.has = function has(key) { | ||
return latest(this[DRAFT_STATE]).has(key); | ||
}; | ||
_proto.set = function set(key, value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!latest(state).has(key) || latest(state).get(key) !== value) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_.set(key, true); | ||
state.copy_.set(key, value); | ||
state.assigned_.set(key, true); | ||
} | ||
return this; | ||
}; | ||
_proto["delete"] = function _delete(key) { | ||
if (!this.has(key)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
if (state.base_.has(key)) { | ||
state.assigned_.set(key, false); | ||
} else { | ||
state.assigned_["delete"](key); | ||
} | ||
state.copy_["delete"](key); | ||
return true; | ||
}; | ||
_proto.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_ = new Map(); | ||
each(state.base_, function (key) { | ||
state.assigned_.set(key, false); | ||
}); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto.forEach = function forEach(cb, thisArg) { | ||
var _this2 = this; | ||
var state = this[DRAFT_STATE]; | ||
latest(state).forEach(function (_value, key, _map) { | ||
cb.call(thisArg, _this2.get(key), key, _this2); | ||
}); | ||
}; | ||
_proto.get = function get(key) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
var value = latest(state).get(key); | ||
if (state.finalized_ || !isDraftable(value)) { | ||
return value; | ||
} | ||
if (value !== state.base_.get(key)) { | ||
return value; // either already drafted or reassigned | ||
} | ||
// despite what it looks, this creates a draft only once, see above condition | ||
var draft = createProxy(value, state); | ||
prepareMapCopy(state); | ||
state.copy_.set(key, draft); | ||
return draft; | ||
}; | ||
_proto.keys = function keys() { | ||
return latest(this[DRAFT_STATE]).keys(); | ||
}; | ||
_proto.values = function values() { | ||
var _this3 = this, | ||
_ref; | ||
var iterator = this.keys(); | ||
return _ref = {}, _ref[Symbol.iterator] = function () { | ||
return _this3.values(); | ||
}, _ref.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this3.get(r.value); | ||
return { | ||
done: false, | ||
value: value | ||
}; | ||
}, _ref; | ||
}; | ||
_proto.entries = function entries() { | ||
var _this4 = this, | ||
_ref2; | ||
var iterator = this.keys(); | ||
return _ref2 = {}, _ref2[Symbol.iterator] = function () { | ||
return _this4.entries(); | ||
}, _ref2.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this4.get(r.value); | ||
return { | ||
done: false, | ||
value: [r.value, value] | ||
}; | ||
}, _ref2; | ||
}; | ||
_proto[_Symbol$iterator] = function () { | ||
return this.entries(); | ||
}; | ||
_createClass(DraftMap, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftMap; | ||
}( /*#__PURE__*/_wrapNativeSuper(Map), Symbol.iterator); | ||
function proxyMap(target, parent) { | ||
// @ts-ignore | ||
return new DraftMap(target, parent); | ||
} | ||
function prepareMapCopy(state) { | ||
if (!state.copy_) { | ||
state.assigned_ = new Map(); | ||
state.copy_ = new Map(state.base_); | ||
} | ||
} | ||
var DraftSet = /*#__PURE__*/function (_Set, _Symbol$iterator2) { | ||
_inheritsLoose(DraftSet, _Set); | ||
function DraftSet(target, parent) { | ||
var _this5; | ||
_this5 = _Set.call(this) || this; | ||
_this5[DRAFT_STATE] = { | ||
type_: 3 /* Set */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this5), | ||
drafts_: new Map(), | ||
revoked_: false, | ||
isManual_: false | ||
}; | ||
return _this5; | ||
} | ||
var _proto2 = DraftSet.prototype; | ||
_proto2.has = function has(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
// bit of trickery here, to be able to recognize both the value, and the draft of its value | ||
if (!state.copy_) { | ||
return state.base_.has(value); | ||
} | ||
if (state.copy_.has(value)) return true; | ||
if (state.drafts_.has(value) && state.copy_.has(state.drafts_.get(value))) return true; | ||
return false; | ||
}; | ||
_proto2.add = function add(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!this.has(value)) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.add(value); | ||
} | ||
return this; | ||
}; | ||
_proto2["delete"] = function _delete(value) { | ||
if (!this.has(value)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
return state.copy_["delete"](value) || (state.drafts_.has(value) ? state.copy_["delete"](state.drafts_.get(value)) : /* istanbul ignore next */false); | ||
}; | ||
_proto2.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto2.values = function values() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.values(); | ||
}; | ||
_proto2.entries = function entries() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.entries(); | ||
}; | ||
_proto2.keys = function keys() { | ||
return this.values(); | ||
}; | ||
_proto2[_Symbol$iterator2] = function () { | ||
return this.values(); | ||
}; | ||
_proto2.forEach = function forEach(cb, thisArg) { | ||
var iterator = this.values(); | ||
var result = iterator.next(); | ||
while (!result.done) { | ||
cb.call(thisArg, result.value, result.value, this); | ||
result = iterator.next(); | ||
} | ||
}; | ||
_createClass(DraftSet, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftSet; | ||
}( /*#__PURE__*/_wrapNativeSuper(Set), Symbol.iterator); | ||
function proxySet(target, parent) { | ||
// @ts-ignore | ||
return new DraftSet(target, parent); | ||
} | ||
function prepareSetCopy(state) { | ||
if (!state.copy_) { | ||
// create drafts for all entries to preserve insertion order | ||
state.copy_ = new Set(); | ||
state.base_.forEach(function (value) { | ||
if (isDraftable(value)) { | ||
var draft = createProxy(value, state); | ||
state.drafts_.set(value, draft); | ||
state.copy_.add(draft); | ||
} else { | ||
state.copy_.add(value); | ||
} | ||
}); | ||
} | ||
} | ||
function assertUnrevoked(state /*ES5State | MapState | SetState*/) { | ||
if (state.revoked_) die(3, JSON.stringify(latest(state))); | ||
} | ||
function enablePatches() { | ||
@@ -1396,2 +1132,272 @@ var errorOffset = 16; | ||
function enableMapSet() { | ||
var DraftMap = /*#__PURE__*/function (_Map, _Symbol$iterator) { | ||
_inheritsLoose(DraftMap, _Map); | ||
function DraftMap(target, parent) { | ||
var _this; | ||
_this = _Map.call(this) || this; | ||
_this[DRAFT_STATE] = { | ||
type_: 2 /* Map */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
assigned_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this), | ||
isManual_: false, | ||
revoked_: false | ||
}; | ||
return _this; | ||
} | ||
var _proto = DraftMap.prototype; | ||
_proto.has = function has(key) { | ||
return latest(this[DRAFT_STATE]).has(key); | ||
}; | ||
_proto.set = function set(key, value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!latest(state).has(key) || latest(state).get(key) !== value) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_.set(key, true); | ||
state.copy_.set(key, value); | ||
state.assigned_.set(key, true); | ||
} | ||
return this; | ||
}; | ||
_proto["delete"] = function _delete(key) { | ||
if (!this.has(key)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
if (state.base_.has(key)) { | ||
state.assigned_.set(key, false); | ||
} else { | ||
state.assigned_["delete"](key); | ||
} | ||
state.copy_["delete"](key); | ||
return true; | ||
}; | ||
_proto.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_ = new Map(); | ||
each(state.base_, function (key) { | ||
state.assigned_.set(key, false); | ||
}); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto.forEach = function forEach(cb, thisArg) { | ||
var _this2 = this; | ||
var state = this[DRAFT_STATE]; | ||
latest(state).forEach(function (_value, key, _map) { | ||
cb.call(thisArg, _this2.get(key), key, _this2); | ||
}); | ||
}; | ||
_proto.get = function get(key) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
var value = latest(state).get(key); | ||
if (state.finalized_ || !isDraftable(value)) { | ||
return value; | ||
} | ||
if (value !== state.base_.get(key)) { | ||
return value; // either already drafted or reassigned | ||
} | ||
// despite what it looks, this creates a draft only once, see above condition | ||
var draft = createProxy(value, state); | ||
prepareMapCopy(state); | ||
state.copy_.set(key, draft); | ||
return draft; | ||
}; | ||
_proto.keys = function keys() { | ||
return latest(this[DRAFT_STATE]).keys(); | ||
}; | ||
_proto.values = function values() { | ||
var _this3 = this, | ||
_ref; | ||
var iterator = this.keys(); | ||
return _ref = {}, _ref[Symbol.iterator] = function () { | ||
return _this3.values(); | ||
}, _ref.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this3.get(r.value); | ||
return { | ||
done: false, | ||
value: value | ||
}; | ||
}, _ref; | ||
}; | ||
_proto.entries = function entries() { | ||
var _this4 = this, | ||
_ref2; | ||
var iterator = this.keys(); | ||
return _ref2 = {}, _ref2[Symbol.iterator] = function () { | ||
return _this4.entries(); | ||
}, _ref2.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this4.get(r.value); | ||
return { | ||
done: false, | ||
value: [r.value, value] | ||
}; | ||
}, _ref2; | ||
}; | ||
_proto[_Symbol$iterator] = function () { | ||
return this.entries(); | ||
}; | ||
_createClass(DraftMap, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftMap; | ||
}( /*#__PURE__*/_wrapNativeSuper(Map), Symbol.iterator); | ||
function proxyMap_(target, parent) { | ||
// @ts-ignore | ||
return new DraftMap(target, parent); | ||
} | ||
function prepareMapCopy(state) { | ||
if (!state.copy_) { | ||
state.assigned_ = new Map(); | ||
state.copy_ = new Map(state.base_); | ||
} | ||
} | ||
var DraftSet = /*#__PURE__*/function (_Set, _Symbol$iterator2) { | ||
_inheritsLoose(DraftSet, _Set); | ||
function DraftSet(target, parent) { | ||
var _this5; | ||
_this5 = _Set.call(this) || this; | ||
_this5[DRAFT_STATE] = { | ||
type_: 3 /* Set */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this5), | ||
drafts_: new Map(), | ||
revoked_: false, | ||
isManual_: false | ||
}; | ||
return _this5; | ||
} | ||
var _proto2 = DraftSet.prototype; | ||
_proto2.has = function has(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
// bit of trickery here, to be able to recognize both the value, and the draft of its value | ||
if (!state.copy_) { | ||
return state.base_.has(value); | ||
} | ||
if (state.copy_.has(value)) return true; | ||
if (state.drafts_.has(value) && state.copy_.has(state.drafts_.get(value))) return true; | ||
return false; | ||
}; | ||
_proto2.add = function add(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!this.has(value)) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.add(value); | ||
} | ||
return this; | ||
}; | ||
_proto2["delete"] = function _delete(value) { | ||
if (!this.has(value)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
return state.copy_["delete"](value) || (state.drafts_.has(value) ? state.copy_["delete"](state.drafts_.get(value)) : /* istanbul ignore next */false); | ||
}; | ||
_proto2.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto2.values = function values() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.values(); | ||
}; | ||
_proto2.entries = function entries() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.entries(); | ||
}; | ||
_proto2.keys = function keys() { | ||
return this.values(); | ||
}; | ||
_proto2[_Symbol$iterator2] = function () { | ||
return this.values(); | ||
}; | ||
_proto2.forEach = function forEach(cb, thisArg) { | ||
var iterator = this.values(); | ||
var result = iterator.next(); | ||
while (!result.done) { | ||
cb.call(thisArg, result.value, result.value, this); | ||
result = iterator.next(); | ||
} | ||
}; | ||
_createClass(DraftSet, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftSet; | ||
}( /*#__PURE__*/_wrapNativeSuper(Set), Symbol.iterator); | ||
function proxySet_(target, parent) { | ||
// @ts-ignore | ||
return new DraftSet(target, parent); | ||
} | ||
function prepareSetCopy(state) { | ||
if (!state.copy_) { | ||
// create drafts for all entries to preserve insertion order | ||
state.copy_ = new Set(); | ||
state.base_.forEach(function (value) { | ||
if (isDraftable(value)) { | ||
var draft = createProxy(value, state); | ||
state.drafts_.set(value, draft); | ||
state.copy_.add(draft); | ||
} else { | ||
state.copy_.add(value); | ||
} | ||
}); | ||
} | ||
} | ||
function assertUnrevoked(state /*ES5State | MapState | SetState*/) { | ||
if (state.revoked_) die(3, JSON.stringify(latest(state))); | ||
} | ||
loadPlugin("MapSet", { | ||
proxyMap_: proxyMap_, | ||
proxySet_: proxySet_ | ||
}); | ||
} | ||
var immer = /*#__PURE__*/new Immer(); | ||
@@ -1479,2 +1485,3 @@ /** | ||
exports.current = current; | ||
exports.enableMapSet = enableMapSet; | ||
exports.enablePatches = enablePatches; | ||
@@ -1481,0 +1488,0 @@ exports.finishDraft = finishDraft; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=Symbol.for("immer-nothing"),t=Symbol.for("immer-draftable"),r=Symbol.for("immer-state");function n(e){throw new Error("[Immer] minified error nr: "+e+". Full error at: https://bit.ly/3cXEKWf")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=f()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){return!!e&&!!e[r]}function h(e){var r;return!!e&&(d(e)||Array.isArray(e)||!!e[t]||!(null==(r=e.constructor)||!r[t])||P(e)||S(e))}var y=Object.prototype.constructor.toString();function d(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===y}function b(e,t){0===g(e)?Object.entries(e).forEach((function(r){t(r[0],r[1],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function g(e){var t=e[r];return t?t.type_:Array.isArray(e)?1:P(e)?2:S(e)?3:0}function m(e,t){return 2===g(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function w(e,t){return 2===g(e)?e.get(t):e[t]}function O(e,t,r){var n=g(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function P(e){return e instanceof Map}function S(e){return e instanceof Set}function j(e){return e.copy_||e.base_}function z(e,t){if(P(e))return new Map(e);if(S(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&d(e)){if(!Object.getPrototypeOf(e)){var n=Object.create(null);return Object.assign(n,e)}return i({},e)}var o=Object.getOwnPropertyDescriptors(e);delete o[r];for(var a=Reflect.ownKeys(o),u=0;u<a.length;u++){var c=a[u],s=o[c];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(o[c]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[c]})}return Object.create(Object.getPrototypeOf(e),o)}function x(e,t){return void 0===t&&(t=!1),F(e)||v(e)||!h(e)||(g(e)>1&&(e.set=e.add=e.clear=e.delete=A),Object.freeze(e),t&&b(e,(function(e,t){return x(t,!0)}))),e}function A(){n(2)}function F(e){return Object.isFrozen(e)}var k,D={};function M(e){var t=D[e];return t||n(0),t}function E(){return k}function R(e,t){t&&(M("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function C(e){N(e),e.drafts_.forEach(K),e.drafts_=null}function N(e){e===k&&(k=e.parent_)}function W(e){return k={drafts_:[],parent_:k,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function K(e){var t=e[r];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function U(t,o){o.unfinalizedDrafts_=o.drafts_.length;var a=o.drafts_[0];return void 0!==t&&t!==a?(a[r].modified_&&(C(o),n(4)),h(t)&&(t=I(o,t),o.parent_||L(o,t)),o.patches_&&M("Patches").generateReplacementPatches_(a[r].base_,t,o.patches_,o.inversePatches_)):t=I(o,a,[]),C(o),o.patches_&&o.patchListener_(o.patches_,o.inversePatches_),t!==e?t:void 0}function I(e,t,n){if(F(t))return t;var o=t[r];if(!o)return b(t,(function(r,a){return B(e,o,t,r,a,n)})),t;if(o.scope_!==e)return t;if(!o.modified_)return L(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;var a=o.copy_,i=a,u=!1;3===o.type_&&(i=new Set(a),a.clear(),u=!0),b(i,(function(t,r){return B(e,o,a,t,r,n,u)})),L(e,a,!1),n&&e.patches_&&M("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function B(e,t,r,n,o,a,i){if(v(o)){var u=I(e,o,a&&t&&3!==t.type_&&!m(t.assigned_,n)?a.concat(n):void 0);if(O(r,n,u),!v(u))return;e.canAutoFreeze_=!1}else i&&r.add(o);if(h(o)&&!F(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;I(e,o),t&&t.scope_.parent_||L(e,o)}}function L(e,t,r){void 0===r&&(r=!1),!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&x(t,r)}var T={get:function(e,t){if(t===r)return e;var n=j(e);if(!m(n,t))return function(e,t,r){var n,o=q(t,r);return o?"value"in o?o.value:null==(n=o.get)?void 0:n.call(e.draft_):void 0}(e,n,t);var o=n[t];return e.finalized_||!h(o)?o:o===X(e.base_,t)?(H(e),e.copy_[t]=V(o,e)):o},has:function(e,t){return t in j(e)},ownKeys:function(e){return Reflect.ownKeys(j(e))},set:function(e,t,n){var o,a,i=q(j(e),t);if(null!=i&&i.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){var u=X(j(e),t),c=null==u?void 0:u[r];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((o=n)===(a=u)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==n||m(e.base_,t)))return!0;H(e),G(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:function(e,t){return void 0!==X(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,H(e),G(e)):delete e.assigned_[t],delete e.copy_[t],!0},getOwnPropertyDescriptor:function(e,t){var r=j(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){n(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base_)},setPrototypeOf:function(){n(12)}},J={};function X(e,t){var n=e[r];return(n?j(n):e)[t]}function q(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function G(e){e.modified_||(e.modified_=!0,e.parent_&&G(e.parent_))}function H(e){e.copy_||(e.copy_=z(e.base_,e.scope_.immer_.useStrictShallowCopy_))}b(T,(function(e,t){J[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),J.deleteProperty=function(e,t){return J.set.call(this,e,t,void 0)},J.set=function(e,t,r){return T.set.call(this,e[0],t,r,e[0])};var Q=function(){function t(t){var r=this;this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=function(t,o,a){if("function"==typeof t&&"function"!=typeof o){var i=o;o=t;var u=r;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return u.produce(e,(function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))}))}}var c;if("function"!=typeof o&&n(6),void 0!==a&&"function"!=typeof a&&n(7),h(t)){var s=W(r),f=V(t,void 0),p=!0;try{c=o(f),p=!1}finally{p?C(s):N(s)}return R(s,a),U(c,s)}if(!t||"object"!=typeof t){if(void 0===(c=o(t))&&(c=t),c===e&&(c=void 0),r.autoFreeze_&&x(c,!0),a){var l=[],_=[];M("Patches").generateReplacementPatches_(t,c,l,_),a(l,_)}return c}n(1)},this.produceWithPatches=function(e,t){return"function"==typeof e?function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return r.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(o))}))}:[r.produce(e,t,(function(e,t){n=e,o=t})),n,o];var n,o},"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof(null==t?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}var o=t.prototype;return o.createDraft=function(e){h(e)||n(8),v(e)&&(e=Y(e));var t=W(this),o=V(e,void 0);return o[r].isManual_=!0,N(t),o},o.finishDraft=function(e,t){var o=e&&e[r];o&&o.isManual_||n(9);var a=o.scope_;return R(a,t),U(void 0,a)},o.setAutoFreeze=function(e){this.autoFreeze_=e},o.setUseStrictShallowCopy=function(e){this.useStrictShallowCopy_=e},o.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var o=M("Patches").applyPatches_;return v(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},t}();function V(e,t){var r=P(e)?function(e,t){return new Z(e,t)}(e,t):S(e)?function(e,t){return new ee(e,t)}(e,t):function(e,t){var r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:E(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,a=T;r&&(o=[n],a=J);var i=Proxy.revocable(o,a),u=i.revoke,c=i.proxy;return n.draft_=c,n.revoke_=u,c}(e,t);return(t?t.scope_:E()).drafts_.push(r),r}function Y(e){return v(e)||n(10),function e(t){if(!h(t)||F(t))return t;var n,o=t[r];if(o){if(!o.modified_)return o.base_;o.finalized_=!0,n=z(t,o.scope_.immer_.useStrictShallowCopy_)}else n=z(t,!0);return b(n,(function(t,r){O(n,t,e(r))})),o&&(o.finalized_=!1),n}(e)}var Z=function(e,t){function n(t,n){var o;return(o=e.call(this)||this)[r]={type_:2,parent_:n,scope_:n?n.scope_:E(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:t,draft_:_(o),isManual_:!1,revoked_:!1},o}u(n,e);var o=n.prototype;return o.has=function(e){return j(this[r]).has(e)},o.set=function(e,t){var n=this[r];return re(n),j(n).has(e)&&j(n).get(e)===t||($(n),G(n),n.assigned_.set(e,!0),n.copy_.set(e,t),n.assigned_.set(e,!0)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[r];return re(t),$(t),G(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0},o.clear=function(){var e=this[r];re(e),j(e).size&&($(e),G(e),e.assigned_=new Map,b(e.base_,(function(t){e.assigned_.set(t,!1)})),e.copy_.clear())},o.forEach=function(e,t){var n=this;j(this[r]).forEach((function(r,o,a){e.call(t,n.get(o),o,n)}))},o.get=function(e){var t=this[r];re(t);var n=j(t).get(e);if(t.finalized_||!h(n))return n;if(n!==t.base_.get(e))return n;var o=V(n,t);return $(t),t.copy_.set(e,o),o},o.keys=function(){return j(this[r]).keys()},o.values=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},o.entries=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},o[t]=function(){return this.entries()},a(n,[{key:"size",get:function(){return j(this[r]).size}}]),n}(l(Map),Symbol.iterator);function $(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}var ee=function(e,t){function n(t,n){var o;return(o=e.call(this)||this)[r]={type_:3,parent_:n,scope_:n?n.scope_:E(),modified_:!1,finalized_:!1,copy_:void 0,base_:t,draft_:_(o),drafts_:new Map,revoked_:!1,isManual_:!1},o}u(n,e);var o=n.prototype;return o.has=function(e){var t=this[r];return re(t),t.copy_?!!t.copy_.has(e)||!(!t.drafts_.has(e)||!t.copy_.has(t.drafts_.get(e))):t.base_.has(e)},o.add=function(e){var t=this[r];return re(t),this.has(e)||(te(t),G(t),t.copy_.add(e)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[r];return re(t),te(t),G(t),t.copy_.delete(e)||!!t.drafts_.has(e)&&t.copy_.delete(t.drafts_.get(e))},o.clear=function(){var e=this[r];re(e),j(e).size&&(te(e),G(e),e.copy_.clear())},o.values=function(){var e=this[r];return re(e),te(e),e.copy_.values()},o.entries=function(){var e=this[r];return re(e),te(e),e.copy_.entries()},o.keys=function(){return this.values()},o[t]=function(){return this.values()},o.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},a(n,[{key:"size",get:function(){return j(this[r]).size}}]),n}(l(Set),Symbol.iterator);function te(e){e.copy_||(e.copy_=new Set,e.base_.forEach((function(t){if(h(t)){var r=V(t,e);e.drafts_.set(t,r),e.copy_.add(r)}else e.copy_.add(t)})))}function re(e){e.revoked_&&n(3,JSON.stringify(j(e)))}var ne=new Q,oe=ne.produce,ae=ne.produceWithPatches.bind(ne),ie=ne.setAutoFreeze.bind(ne),ue=ne.setUseStrictShallowCopy.bind(ne),ce=ne.applyPatches.bind(ne),se=ne.createDraft.bind(ne),fe=ne.finishDraft.bind(ne);exports.Immer=Q,exports.applyPatches=ce,exports.castDraft=function(e){return e},exports.castImmutable=function(e){return e},exports.createDraft=se,exports.current=Y,exports.enablePatches=function(){var r="add";function o(e){if(!h(e))return e;if(Array.isArray(e))return e.map(o);if(P(e))return new Map(Array.from(e.entries()).map((function(e){return[e[0],o(e[1])]})));if(S(e))return new Set(Array.from(e).map(o));var r=Object.create(Object.getPrototypeOf(e));for(var n in e)r[n]=o(e[n]);return m(e,t)&&(r[t]=e[t]),r}function a(e){return v(e)?o(e):e}D.Patches||(D.Patches={applyPatches_:function(e,t){return t.forEach((function(t){for(var a=t.path,i=t.op,u=e,c=0;c<a.length-1;c++){var s=g(u),f=a[c];"string"!=typeof f&&"number"!=typeof f&&(f=""+f),0!==s&&1!==s||"__proto__"!==f&&"constructor"!==f||n(19),"function"==typeof u&&"prototype"===f&&n(19),"object"!=typeof(u=w(u,f))&&n(18,a.join("/"))}var p=g(u),l=o(t.value),_=a[a.length-1];switch(i){case"replace":switch(p){case 2:return u.set(_,l);case 3:n(16);default:return u[_]=l}case r:switch(p){case 1:return"-"===_?u.push(l):u.splice(_,0,l);case 2:return u.set(_,l);case 3:return u.add(l);default:return u[_]=l}case"remove":switch(p){case 1:return u.splice(_,1);case 2:return u.delete(_);case 3:return u.delete(t.value);default:return delete u[_]}default:n(17)}})),e},generatePatches_:function(e,t,n,o){switch(e.type_){case 0:case 2:return function(e,t,n,o){var i=e.base_,u=e.copy_;b(e.assigned_,(function(e,c){var s=w(i,e),f=w(u,e),p=c?m(i,e)?"replace":r:"remove";if(s!==f||"replace"!==p){var l=t.concat(e);n.push("remove"===p?{op:p,path:l}:{op:p,path:l,value:f}),o.push(p===r?{op:"remove",path:l}:"remove"===p?{op:r,path:l,value:a(s)}:{op:"replace",path:l,value:a(s)})}}))}(e,t,n,o);case 1:return function(e,t,n,o){var i=e.base_,u=e.assigned_,c=e.copy_;if(c.length<i.length){var s=[c,i];i=s[0],c=s[1];var f=[o,n];n=f[0],o=f[1]}for(var p=0;p<i.length;p++)if(u[p]&&c[p]!==i[p]){var l=t.concat([p]);n.push({op:"replace",path:l,value:a(c[p])}),o.push({op:"replace",path:l,value:a(i[p])})}for(var _=i.length;_<c.length;_++){var v=t.concat([_]);n.push({op:r,path:v,value:a(c[_])})}for(var h=c.length-1;i.length<=h;--h){var y=t.concat([h]);o.push({op:"remove",path:y})}}(e,t,n,o);case 3:return function(e,t,n,o){var a=e.base_,i=e.copy_,u=0;a.forEach((function(e){if(!i.has(e)){var a=t.concat([u]);n.push({op:"remove",path:a,value:e}),o.unshift({op:r,path:a,value:e})}u++})),u=0,i.forEach((function(e){if(!a.has(e)){var i=t.concat([u]);n.push({op:r,path:i,value:e}),o.unshift({op:"remove",path:i,value:e})}u++}))}(e,t,n,o)}},generateReplacementPatches_:function(t,r,n,o){n.push({op:"replace",path:[],value:r===e?void 0:r}),o.push({op:"replace",path:[],value:t})}})},exports.finishDraft=fe,exports.freeze=x,exports.immerable=t,exports.isDraft=v,exports.isDraftable=h,exports.nothing=e,exports.original=function(e){return v(e)||n(15),e[r].base_},exports.produce=oe,exports.produceWithPatches=ae,exports.setAutoFreeze=ie,exports.setUseStrictShallowCopy=ue; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=Symbol.for("immer-nothing"),t=Symbol.for("immer-draftable"),r=Symbol.for("immer-state");function n(e){throw new Error("[Immer] minified error nr: "+e+". Full error at: https://bit.ly/3cXEKWf")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=f()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){return!!e&&!!e[r]}function h(e){var r;return!!e&&(d(e)||Array.isArray(e)||!!e[t]||!(null==(r=e.constructor)||!r[t])||P(e)||S(e))}var y=Object.prototype.constructor.toString();function d(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===y}function b(e,t){0===g(e)?Object.entries(e).forEach((function(r){t(r[0],r[1],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function g(e){var t=e[r];return t?t.type_:Array.isArray(e)?1:P(e)?2:S(e)?3:0}function m(e,t){return 2===g(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function w(e,t){return 2===g(e)?e.get(t):e[t]}function O(e,t,r){var n=g(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function P(e){return e instanceof Map}function S(e){return e instanceof Set}function j(e){return e.copy_||e.base_}function z(e,t){if(P(e))return new Map(e);if(S(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&d(e)){if(!Object.getPrototypeOf(e)){var n=Object.create(null);return Object.assign(n,e)}return i({},e)}var o=Object.getOwnPropertyDescriptors(e);delete o[r];for(var a=Reflect.ownKeys(o),u=0;u<a.length;u++){var c=a[u],s=o[c];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(o[c]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[c]})}return Object.create(Object.getPrototypeOf(e),o)}function x(e,t){return void 0===t&&(t=!1),M(e)||v(e)||!h(e)||(g(e)>1&&(e.set=e.add=e.clear=e.delete=A),Object.freeze(e),t&&b(e,(function(e,t){return x(t,!0)}))),e}function A(){n(2)}function M(e){return Object.isFrozen(e)}var F,k={};function D(e){var t=k[e];return t||n(0),t}function E(e,t){k[e]||(k[e]=t)}function R(){return F}function C(e,t){t&&(D("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function N(e){W(e),e.drafts_.forEach(U),e.drafts_=null}function W(e){e===F&&(F=e.parent_)}function K(e){return F={drafts_:[],parent_:F,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function U(e){var t=e[r];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function I(t,o){o.unfinalizedDrafts_=o.drafts_.length;var a=o.drafts_[0];return void 0!==t&&t!==a?(a[r].modified_&&(N(o),n(4)),h(t)&&(t=B(o,t),o.parent_||T(o,t)),o.patches_&&D("Patches").generateReplacementPatches_(a[r].base_,t,o.patches_,o.inversePatches_)):t=B(o,a,[]),N(o),o.patches_&&o.patchListener_(o.patches_,o.inversePatches_),t!==e?t:void 0}function B(e,t,n){if(M(t))return t;var o=t[r];if(!o)return b(t,(function(r,a){return L(e,o,t,r,a,n)})),t;if(o.scope_!==e)return t;if(!o.modified_)return T(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;var a=o.copy_,i=a,u=!1;3===o.type_&&(i=new Set(a),a.clear(),u=!0),b(i,(function(t,r){return L(e,o,a,t,r,n,u)})),T(e,a,!1),n&&e.patches_&&D("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function L(e,t,r,n,o,a,i){if(v(o)){var u=B(e,o,a&&t&&3!==t.type_&&!m(t.assigned_,n)?a.concat(n):void 0);if(O(r,n,u),!v(u))return;e.canAutoFreeze_=!1}else i&&r.add(o);if(h(o)&&!M(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;B(e,o),t&&t.scope_.parent_||T(e,o)}}function T(e,t,r){void 0===r&&(r=!1),!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&x(t,r)}var J={get:function(e,t){if(t===r)return e;var n=j(e);if(!m(n,t))return function(e,t,r){var n,o=G(t,r);return o?"value"in o?o.value:null==(n=o.get)?void 0:n.call(e.draft_):void 0}(e,n,t);var o=n[t];return e.finalized_||!h(o)?o:o===q(e.base_,t)?(Q(e),e.copy_[t]=Y(o,e)):o},has:function(e,t){return t in j(e)},ownKeys:function(e){return Reflect.ownKeys(j(e))},set:function(e,t,n){var o,a,i=G(j(e),t);if(null!=i&&i.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){var u=q(j(e),t),c=null==u?void 0:u[r];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((o=n)===(a=u)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==n||m(e.base_,t)))return!0;Q(e),H(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:function(e,t){return void 0!==q(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Q(e),H(e)):delete e.assigned_[t],delete e.copy_[t],!0},getOwnPropertyDescriptor:function(e,t){var r=j(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){n(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base_)},setPrototypeOf:function(){n(12)}},X={};function q(e,t){var n=e[r];return(n?j(n):e)[t]}function G(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function H(e){e.modified_||(e.modified_=!0,e.parent_&&H(e.parent_))}function Q(e){e.copy_||(e.copy_=z(e.base_,e.scope_.immer_.useStrictShallowCopy_))}b(J,(function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),X.deleteProperty=function(e,t){return X.set.call(this,e,t,void 0)},X.set=function(e,t,r){return J.set.call(this,e[0],t,r,e[0])};var V=function(){function t(t){var r=this;this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=function(t,o,a){if("function"==typeof t&&"function"!=typeof o){var i=o;o=t;var u=r;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return u.produce(e,(function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))}))}}var c;if("function"!=typeof o&&n(6),void 0!==a&&"function"!=typeof a&&n(7),h(t)){var s=K(r),f=Y(t,void 0),p=!0;try{c=o(f),p=!1}finally{p?N(s):W(s)}return C(s,a),I(c,s)}if(!t||"object"!=typeof t){if(void 0===(c=o(t))&&(c=t),c===e&&(c=void 0),r.autoFreeze_&&x(c,!0),a){var l=[],_=[];D("Patches").generateReplacementPatches_(t,c,l,_),a(l,_)}return c}n(1)},this.produceWithPatches=function(e,t){return"function"==typeof e?function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return r.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(o))}))}:[r.produce(e,t,(function(e,t){n=e,o=t})),n,o];var n,o},"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof(null==t?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}var o=t.prototype;return o.createDraft=function(e){h(e)||n(8),v(e)&&(e=Z(e));var t=K(this),o=Y(e,void 0);return o[r].isManual_=!0,W(t),o},o.finishDraft=function(e,t){var o=e&&e[r];o&&o.isManual_||n(9);var a=o.scope_;return C(a,t),I(void 0,a)},o.setAutoFreeze=function(e){this.autoFreeze_=e},o.setUseStrictShallowCopy=function(e){this.useStrictShallowCopy_=e},o.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var o=D("Patches").applyPatches_;return v(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},t}();function Y(e,t){var r=P(e)?D("MapSet").proxyMap_(e,t):S(e)?D("MapSet").proxySet_(e,t):function(e,t){var r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:R(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,a=J;r&&(o=[n],a=X);var i=Proxy.revocable(o,a),u=i.revoke,c=i.proxy;return n.draft_=c,n.revoke_=u,c}(e,t);return(t?t.scope_:R()).drafts_.push(r),r}function Z(e){return v(e)||n(10),function e(t){if(!h(t)||M(t))return t;var n,o=t[r];if(o){if(!o.modified_)return o.base_;o.finalized_=!0,n=z(t,o.scope_.immer_.useStrictShallowCopy_)}else n=z(t,!0);return b(n,(function(t,r){O(n,t,e(r))})),o&&(o.finalized_=!1),n}(e)}var $=new V,ee=$.produce,te=$.produceWithPatches.bind($),re=$.setAutoFreeze.bind($),ne=$.setUseStrictShallowCopy.bind($),oe=$.applyPatches.bind($),ae=$.createDraft.bind($),ie=$.finishDraft.bind($);exports.Immer=V,exports.applyPatches=oe,exports.castDraft=function(e){return e},exports.castImmutable=function(e){return e},exports.createDraft=ae,exports.current=Z,exports.enableMapSet=function(){var e=function(e,n){function o(t,n){var o;return(o=e.call(this)||this)[r]={type_:2,parent_:n,scope_:n?n.scope_:R(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:t,draft_:_(o),isManual_:!1,revoked_:!1},o}u(o,e);var i=o.prototype;return i.has=function(e){return j(this[r]).has(e)},i.set=function(e,n){var o=this[r];return c(o),j(o).has(e)&&j(o).get(e)===n||(t(o),H(o),o.assigned_.set(e,!0),o.copy_.set(e,n),o.assigned_.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var n=this[r];return c(n),t(n),H(n),n.base_.has(e)?n.assigned_.set(e,!1):n.assigned_.delete(e),n.copy_.delete(e),!0},i.clear=function(){var e=this[r];c(e),j(e).size&&(t(e),H(e),e.assigned_=new Map,b(e.base_,(function(t){e.assigned_.set(t,!1)})),e.copy_.clear())},i.forEach=function(e,t){var n=this;j(this[r]).forEach((function(r,o,a){e.call(t,n.get(o),o,n)}))},i.get=function(e){var n=this[r];c(n);var o=j(n).get(e);if(n.finalized_||!h(o))return o;if(o!==n.base_.get(e))return o;var a=Y(o,n);return t(n),n.copy_.set(e,a),a},i.keys=function(){return j(this[r]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[n]=function(){return this.entries()},a(o,[{key:"size",get:function(){return j(this[r]).size}}]),o}(l(Map),Symbol.iterator);function t(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}var o=function(e,t){function n(t,n){var o;return(o=e.call(this)||this)[r]={type_:3,parent_:n,scope_:n?n.scope_:R(),modified_:!1,finalized_:!1,copy_:void 0,base_:t,draft_:_(o),drafts_:new Map,revoked_:!1,isManual_:!1},o}u(n,e);var o=n.prototype;return o.has=function(e){var t=this[r];return c(t),t.copy_?!!t.copy_.has(e)||!(!t.drafts_.has(e)||!t.copy_.has(t.drafts_.get(e))):t.base_.has(e)},o.add=function(e){var t=this[r];return c(t),this.has(e)||(i(t),H(t),t.copy_.add(e)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[r];return c(t),i(t),H(t),t.copy_.delete(e)||!!t.drafts_.has(e)&&t.copy_.delete(t.drafts_.get(e))},o.clear=function(){var e=this[r];c(e),j(e).size&&(i(e),H(e),e.copy_.clear())},o.values=function(){var e=this[r];return c(e),i(e),e.copy_.values()},o.entries=function(){var e=this[r];return c(e),i(e),e.copy_.entries()},o.keys=function(){return this.values()},o[t]=function(){return this.values()},o.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},a(n,[{key:"size",get:function(){return j(this[r]).size}}]),n}(l(Set),Symbol.iterator);function i(e){e.copy_||(e.copy_=new Set,e.base_.forEach((function(t){if(h(t)){var r=Y(t,e);e.drafts_.set(t,r),e.copy_.add(r)}else e.copy_.add(t)})))}function c(e){e.revoked_&&n(3,JSON.stringify(j(e)))}E("MapSet",{proxyMap_:function(t,r){return new e(t,r)},proxySet_:function(e,t){return new o(e,t)}})},exports.enablePatches=function(){var r="add";function o(e){if(!h(e))return e;if(Array.isArray(e))return e.map(o);if(P(e))return new Map(Array.from(e.entries()).map((function(e){return[e[0],o(e[1])]})));if(S(e))return new Set(Array.from(e).map(o));var r=Object.create(Object.getPrototypeOf(e));for(var n in e)r[n]=o(e[n]);return m(e,t)&&(r[t]=e[t]),r}function a(e){return v(e)?o(e):e}E("Patches",{applyPatches_:function(e,t){return t.forEach((function(t){for(var a=t.path,i=t.op,u=e,c=0;c<a.length-1;c++){var s=g(u),f=a[c];"string"!=typeof f&&"number"!=typeof f&&(f=""+f),0!==s&&1!==s||"__proto__"!==f&&"constructor"!==f||n(19),"function"==typeof u&&"prototype"===f&&n(19),"object"!=typeof(u=w(u,f))&&n(18,a.join("/"))}var p=g(u),l=o(t.value),_=a[a.length-1];switch(i){case"replace":switch(p){case 2:return u.set(_,l);case 3:n(16);default:return u[_]=l}case r:switch(p){case 1:return"-"===_?u.push(l):u.splice(_,0,l);case 2:return u.set(_,l);case 3:return u.add(l);default:return u[_]=l}case"remove":switch(p){case 1:return u.splice(_,1);case 2:return u.delete(_);case 3:return u.delete(t.value);default:return delete u[_]}default:n(17)}})),e},generatePatches_:function(e,t,n,o){switch(e.type_){case 0:case 2:return function(e,t,n,o){var i=e.base_,u=e.copy_;b(e.assigned_,(function(e,c){var s=w(i,e),f=w(u,e),p=c?m(i,e)?"replace":r:"remove";if(s!==f||"replace"!==p){var l=t.concat(e);n.push("remove"===p?{op:p,path:l}:{op:p,path:l,value:f}),o.push(p===r?{op:"remove",path:l}:"remove"===p?{op:r,path:l,value:a(s)}:{op:"replace",path:l,value:a(s)})}}))}(e,t,n,o);case 1:return function(e,t,n,o){var i=e.base_,u=e.assigned_,c=e.copy_;if(c.length<i.length){var s=[c,i];i=s[0],c=s[1];var f=[o,n];n=f[0],o=f[1]}for(var p=0;p<i.length;p++)if(u[p]&&c[p]!==i[p]){var l=t.concat([p]);n.push({op:"replace",path:l,value:a(c[p])}),o.push({op:"replace",path:l,value:a(i[p])})}for(var _=i.length;_<c.length;_++){var v=t.concat([_]);n.push({op:r,path:v,value:a(c[_])})}for(var h=c.length-1;i.length<=h;--h){var y=t.concat([h]);o.push({op:"remove",path:y})}}(e,t,n,o);case 3:return function(e,t,n,o){var a=e.base_,i=e.copy_,u=0;a.forEach((function(e){if(!i.has(e)){var a=t.concat([u]);n.push({op:"remove",path:a,value:e}),o.unshift({op:r,path:a,value:e})}u++})),u=0,i.forEach((function(e){if(!a.has(e)){var i=t.concat([u]);n.push({op:r,path:i,value:e}),o.unshift({op:"remove",path:i,value:e})}u++}))}(e,t,n,o)}},generateReplacementPatches_:function(t,r,n,o){n.push({op:"replace",path:[],value:r===e?void 0:r}),o.push({op:"replace",path:[],value:t})}})},exports.finishDraft=ie,exports.freeze=x,exports.immerable=t,exports.isDraft=v,exports.isDraftable=h,exports.nothing=e,exports.original=function(e){return v(e)||n(15),e[r].base_},exports.produce=ee,exports.produceWithPatches=te,exports.setAutoFreeze=re,exports.setUseStrictShallowCopy=ne; | ||
//# sourceMappingURL=immer.cjs.production.min.js.map |
@@ -75,2 +75,3 @@ import { IProduce, IProduceWithPatches, Immer, Draft, Immutable } from "./internal"; | ||
export { enablePatches } from "./plugins/patches"; | ||
export { enableMapSet } from "./plugins/mapset"; | ||
//# sourceMappingURL=immer.d.ts.map |
@@ -856,3 +856,3 @@ (function (global, factory) { | ||
// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft | ||
var draft = isMap(value) ? proxyMap(value, parent) : isSet(value) ? proxySet(value, parent) : createProxyProxy(value, parent); | ||
var draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent); | ||
var scope = parent ? parent.scope_ : getCurrentScope(); | ||
@@ -889,266 +889,2 @@ scope.drafts_.push(draft); | ||
var DraftMap = /*#__PURE__*/function (_Map, _Symbol$iterator) { | ||
_inheritsLoose(DraftMap, _Map); | ||
function DraftMap(target, parent) { | ||
var _this; | ||
_this = _Map.call(this) || this; | ||
_this[DRAFT_STATE] = { | ||
type_: 2 /* Map */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
assigned_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this), | ||
isManual_: false, | ||
revoked_: false | ||
}; | ||
return _this; | ||
} | ||
var _proto = DraftMap.prototype; | ||
_proto.has = function has(key) { | ||
return latest(this[DRAFT_STATE]).has(key); | ||
}; | ||
_proto.set = function set(key, value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!latest(state).has(key) || latest(state).get(key) !== value) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_.set(key, true); | ||
state.copy_.set(key, value); | ||
state.assigned_.set(key, true); | ||
} | ||
return this; | ||
}; | ||
_proto["delete"] = function _delete(key) { | ||
if (!this.has(key)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
if (state.base_.has(key)) { | ||
state.assigned_.set(key, false); | ||
} else { | ||
state.assigned_["delete"](key); | ||
} | ||
state.copy_["delete"](key); | ||
return true; | ||
}; | ||
_proto.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_ = new Map(); | ||
each(state.base_, function (key) { | ||
state.assigned_.set(key, false); | ||
}); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto.forEach = function forEach(cb, thisArg) { | ||
var _this2 = this; | ||
var state = this[DRAFT_STATE]; | ||
latest(state).forEach(function (_value, key, _map) { | ||
cb.call(thisArg, _this2.get(key), key, _this2); | ||
}); | ||
}; | ||
_proto.get = function get(key) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
var value = latest(state).get(key); | ||
if (state.finalized_ || !isDraftable(value)) { | ||
return value; | ||
} | ||
if (value !== state.base_.get(key)) { | ||
return value; // either already drafted or reassigned | ||
} | ||
// despite what it looks, this creates a draft only once, see above condition | ||
var draft = createProxy(value, state); | ||
prepareMapCopy(state); | ||
state.copy_.set(key, draft); | ||
return draft; | ||
}; | ||
_proto.keys = function keys() { | ||
return latest(this[DRAFT_STATE]).keys(); | ||
}; | ||
_proto.values = function values() { | ||
var _this3 = this, | ||
_ref; | ||
var iterator = this.keys(); | ||
return _ref = {}, _ref[Symbol.iterator] = function () { | ||
return _this3.values(); | ||
}, _ref.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this3.get(r.value); | ||
return { | ||
done: false, | ||
value: value | ||
}; | ||
}, _ref; | ||
}; | ||
_proto.entries = function entries() { | ||
var _this4 = this, | ||
_ref2; | ||
var iterator = this.keys(); | ||
return _ref2 = {}, _ref2[Symbol.iterator] = function () { | ||
return _this4.entries(); | ||
}, _ref2.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this4.get(r.value); | ||
return { | ||
done: false, | ||
value: [r.value, value] | ||
}; | ||
}, _ref2; | ||
}; | ||
_proto[_Symbol$iterator] = function () { | ||
return this.entries(); | ||
}; | ||
_createClass(DraftMap, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftMap; | ||
}( /*#__PURE__*/_wrapNativeSuper(Map), Symbol.iterator); | ||
function proxyMap(target, parent) { | ||
// @ts-ignore | ||
return new DraftMap(target, parent); | ||
} | ||
function prepareMapCopy(state) { | ||
if (!state.copy_) { | ||
state.assigned_ = new Map(); | ||
state.copy_ = new Map(state.base_); | ||
} | ||
} | ||
var DraftSet = /*#__PURE__*/function (_Set, _Symbol$iterator2) { | ||
_inheritsLoose(DraftSet, _Set); | ||
function DraftSet(target, parent) { | ||
var _this5; | ||
_this5 = _Set.call(this) || this; | ||
_this5[DRAFT_STATE] = { | ||
type_: 3 /* Set */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this5), | ||
drafts_: new Map(), | ||
revoked_: false, | ||
isManual_: false | ||
}; | ||
return _this5; | ||
} | ||
var _proto2 = DraftSet.prototype; | ||
_proto2.has = function has(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
// bit of trickery here, to be able to recognize both the value, and the draft of its value | ||
if (!state.copy_) { | ||
return state.base_.has(value); | ||
} | ||
if (state.copy_.has(value)) return true; | ||
if (state.drafts_.has(value) && state.copy_.has(state.drafts_.get(value))) return true; | ||
return false; | ||
}; | ||
_proto2.add = function add(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!this.has(value)) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.add(value); | ||
} | ||
return this; | ||
}; | ||
_proto2["delete"] = function _delete(value) { | ||
if (!this.has(value)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
return state.copy_["delete"](value) || (state.drafts_.has(value) ? state.copy_["delete"](state.drafts_.get(value)) : /* istanbul ignore next */false); | ||
}; | ||
_proto2.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto2.values = function values() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.values(); | ||
}; | ||
_proto2.entries = function entries() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.entries(); | ||
}; | ||
_proto2.keys = function keys() { | ||
return this.values(); | ||
}; | ||
_proto2[_Symbol$iterator2] = function () { | ||
return this.values(); | ||
}; | ||
_proto2.forEach = function forEach(cb, thisArg) { | ||
var iterator = this.values(); | ||
var result = iterator.next(); | ||
while (!result.done) { | ||
cb.call(thisArg, result.value, result.value, this); | ||
result = iterator.next(); | ||
} | ||
}; | ||
_createClass(DraftSet, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftSet; | ||
}( /*#__PURE__*/_wrapNativeSuper(Set), Symbol.iterator); | ||
function proxySet(target, parent) { | ||
// @ts-ignore | ||
return new DraftSet(target, parent); | ||
} | ||
function prepareSetCopy(state) { | ||
if (!state.copy_) { | ||
// create drafts for all entries to preserve insertion order | ||
state.copy_ = new Set(); | ||
state.base_.forEach(function (value) { | ||
if (isDraftable(value)) { | ||
var draft = createProxy(value, state); | ||
state.drafts_.set(value, draft); | ||
state.copy_.add(draft); | ||
} else { | ||
state.copy_.add(value); | ||
} | ||
}); | ||
} | ||
} | ||
function assertUnrevoked(state /*ES5State | MapState | SetState*/) { | ||
if (state.revoked_) die(3, JSON.stringify(latest(state))); | ||
} | ||
function enablePatches() { | ||
@@ -1398,2 +1134,272 @@ var errorOffset = 16; | ||
function enableMapSet() { | ||
var DraftMap = /*#__PURE__*/function (_Map, _Symbol$iterator) { | ||
_inheritsLoose(DraftMap, _Map); | ||
function DraftMap(target, parent) { | ||
var _this; | ||
_this = _Map.call(this) || this; | ||
_this[DRAFT_STATE] = { | ||
type_: 2 /* Map */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
assigned_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this), | ||
isManual_: false, | ||
revoked_: false | ||
}; | ||
return _this; | ||
} | ||
var _proto = DraftMap.prototype; | ||
_proto.has = function has(key) { | ||
return latest(this[DRAFT_STATE]).has(key); | ||
}; | ||
_proto.set = function set(key, value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!latest(state).has(key) || latest(state).get(key) !== value) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_.set(key, true); | ||
state.copy_.set(key, value); | ||
state.assigned_.set(key, true); | ||
} | ||
return this; | ||
}; | ||
_proto["delete"] = function _delete(key) { | ||
if (!this.has(key)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
if (state.base_.has(key)) { | ||
state.assigned_.set(key, false); | ||
} else { | ||
state.assigned_["delete"](key); | ||
} | ||
state.copy_["delete"](key); | ||
return true; | ||
}; | ||
_proto.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareMapCopy(state); | ||
markChanged(state); | ||
state.assigned_ = new Map(); | ||
each(state.base_, function (key) { | ||
state.assigned_.set(key, false); | ||
}); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto.forEach = function forEach(cb, thisArg) { | ||
var _this2 = this; | ||
var state = this[DRAFT_STATE]; | ||
latest(state).forEach(function (_value, key, _map) { | ||
cb.call(thisArg, _this2.get(key), key, _this2); | ||
}); | ||
}; | ||
_proto.get = function get(key) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
var value = latest(state).get(key); | ||
if (state.finalized_ || !isDraftable(value)) { | ||
return value; | ||
} | ||
if (value !== state.base_.get(key)) { | ||
return value; // either already drafted or reassigned | ||
} | ||
// despite what it looks, this creates a draft only once, see above condition | ||
var draft = createProxy(value, state); | ||
prepareMapCopy(state); | ||
state.copy_.set(key, draft); | ||
return draft; | ||
}; | ||
_proto.keys = function keys() { | ||
return latest(this[DRAFT_STATE]).keys(); | ||
}; | ||
_proto.values = function values() { | ||
var _this3 = this, | ||
_ref; | ||
var iterator = this.keys(); | ||
return _ref = {}, _ref[Symbol.iterator] = function () { | ||
return _this3.values(); | ||
}, _ref.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this3.get(r.value); | ||
return { | ||
done: false, | ||
value: value | ||
}; | ||
}, _ref; | ||
}; | ||
_proto.entries = function entries() { | ||
var _this4 = this, | ||
_ref2; | ||
var iterator = this.keys(); | ||
return _ref2 = {}, _ref2[Symbol.iterator] = function () { | ||
return _this4.entries(); | ||
}, _ref2.next = function next() { | ||
var r = iterator.next(); | ||
/* istanbul ignore next */ | ||
if (r.done) return r; | ||
var value = _this4.get(r.value); | ||
return { | ||
done: false, | ||
value: [r.value, value] | ||
}; | ||
}, _ref2; | ||
}; | ||
_proto[_Symbol$iterator] = function () { | ||
return this.entries(); | ||
}; | ||
_createClass(DraftMap, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftMap; | ||
}( /*#__PURE__*/_wrapNativeSuper(Map), Symbol.iterator); | ||
function proxyMap_(target, parent) { | ||
// @ts-ignore | ||
return new DraftMap(target, parent); | ||
} | ||
function prepareMapCopy(state) { | ||
if (!state.copy_) { | ||
state.assigned_ = new Map(); | ||
state.copy_ = new Map(state.base_); | ||
} | ||
} | ||
var DraftSet = /*#__PURE__*/function (_Set, _Symbol$iterator2) { | ||
_inheritsLoose(DraftSet, _Set); | ||
function DraftSet(target, parent) { | ||
var _this5; | ||
_this5 = _Set.call(this) || this; | ||
_this5[DRAFT_STATE] = { | ||
type_: 3 /* Set */, | ||
parent_: parent, | ||
scope_: parent ? parent.scope_ : getCurrentScope(), | ||
modified_: false, | ||
finalized_: false, | ||
copy_: undefined, | ||
base_: target, | ||
draft_: _assertThisInitialized(_this5), | ||
drafts_: new Map(), | ||
revoked_: false, | ||
isManual_: false | ||
}; | ||
return _this5; | ||
} | ||
var _proto2 = DraftSet.prototype; | ||
_proto2.has = function has(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
// bit of trickery here, to be able to recognize both the value, and the draft of its value | ||
if (!state.copy_) { | ||
return state.base_.has(value); | ||
} | ||
if (state.copy_.has(value)) return true; | ||
if (state.drafts_.has(value) && state.copy_.has(state.drafts_.get(value))) return true; | ||
return false; | ||
}; | ||
_proto2.add = function add(value) { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (!this.has(value)) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.add(value); | ||
} | ||
return this; | ||
}; | ||
_proto2["delete"] = function _delete(value) { | ||
if (!this.has(value)) { | ||
return false; | ||
} | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
return state.copy_["delete"](value) || (state.drafts_.has(value) ? state.copy_["delete"](state.drafts_.get(value)) : /* istanbul ignore next */false); | ||
}; | ||
_proto2.clear = function clear() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
if (latest(state).size) { | ||
prepareSetCopy(state); | ||
markChanged(state); | ||
state.copy_.clear(); | ||
} | ||
}; | ||
_proto2.values = function values() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.values(); | ||
}; | ||
_proto2.entries = function entries() { | ||
var state = this[DRAFT_STATE]; | ||
assertUnrevoked(state); | ||
prepareSetCopy(state); | ||
return state.copy_.entries(); | ||
}; | ||
_proto2.keys = function keys() { | ||
return this.values(); | ||
}; | ||
_proto2[_Symbol$iterator2] = function () { | ||
return this.values(); | ||
}; | ||
_proto2.forEach = function forEach(cb, thisArg) { | ||
var iterator = this.values(); | ||
var result = iterator.next(); | ||
while (!result.done) { | ||
cb.call(thisArg, result.value, result.value, this); | ||
result = iterator.next(); | ||
} | ||
}; | ||
_createClass(DraftSet, [{ | ||
key: "size", | ||
get: function get() { | ||
return latest(this[DRAFT_STATE]).size; | ||
} | ||
}]); | ||
return DraftSet; | ||
}( /*#__PURE__*/_wrapNativeSuper(Set), Symbol.iterator); | ||
function proxySet_(target, parent) { | ||
// @ts-ignore | ||
return new DraftSet(target, parent); | ||
} | ||
function prepareSetCopy(state) { | ||
if (!state.copy_) { | ||
// create drafts for all entries to preserve insertion order | ||
state.copy_ = new Set(); | ||
state.base_.forEach(function (value) { | ||
if (isDraftable(value)) { | ||
var draft = createProxy(value, state); | ||
state.drafts_.set(value, draft); | ||
state.copy_.add(draft); | ||
} else { | ||
state.copy_.add(value); | ||
} | ||
}); | ||
} | ||
} | ||
function assertUnrevoked(state /*ES5State | MapState | SetState*/) { | ||
if (state.revoked_) die(3, JSON.stringify(latest(state))); | ||
} | ||
loadPlugin("MapSet", { | ||
proxyMap_: proxyMap_, | ||
proxySet_: proxySet_ | ||
}); | ||
} | ||
var immer = /*#__PURE__*/new Immer(); | ||
@@ -1481,2 +1487,3 @@ /** | ||
exports.current = current; | ||
exports.enableMapSet = enableMapSet; | ||
exports.enablePatches = enablePatches; | ||
@@ -1483,0 +1490,0 @@ exports.finishDraft = finishDraft; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).immer={})}(this,(function(e){"use strict";var t=Symbol.for("immer-nothing"),r=Symbol.for("immer-draftable"),n=Symbol.for("immer-state");function o(e){throw new Error("[Immer] minified error nr: "+e+". Full error at: https://bit.ly/3cXEKWf")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}function i(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,r){return(l=p()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function _(e){var t="function"==typeof Map?new Map:void 0;return(_=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return l(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){return!!e&&!!e[n]}function d(e){var t;return!!e&&(b(e)||Array.isArray(e)||!!e[r]||!(null==(t=e.constructor)||!t[r])||S(e)||j(e))}var y=Object.prototype.constructor.toString();function b(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===y}function g(e,t){0===m(e)?Object.entries(e).forEach((function(r){t(r[0],r[1],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function m(e){var t=e[n];return t?t.type_:Array.isArray(e)?1:S(e)?2:j(e)?3:0}function w(e,t){return 2===m(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function O(e,t){return 2===m(e)?e.get(t):e[t]}function P(e,t,r){var n=m(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function S(e){return e instanceof Map}function j(e){return e instanceof Set}function z(e){return e.copy_||e.base_}function A(e,t){if(S(e))return new Map(e);if(j(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&b(e)){if(!Object.getPrototypeOf(e)){var r=Object.create(null);return Object.assign(r,e)}return u({},e)}var o=Object.getOwnPropertyDescriptors(e);delete o[n];for(var a=Reflect.ownKeys(o),i=0;i<a.length;i++){var c=a[i],f=o[c];!1===f.writable&&(f.writable=!0,f.configurable=!0),(f.get||f.set)&&(o[c]={configurable:!0,writable:!0,enumerable:f.enumerable,value:e[c]})}return Object.create(Object.getPrototypeOf(e),o)}function F(e,t){return void 0===t&&(t=!1),D(e)||v(e)||!d(e)||(m(e)>1&&(e.set=e.add=e.clear=e.delete=k),Object.freeze(e),t&&g(e,(function(e,t){return F(t,!0)}))),e}function k(){o(2)}function D(e){return Object.isFrozen(e)}var M,E={};function x(e){var t=E[e];return t||o(0),t}function R(){return M}function C(e,t){t&&(x("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function N(e){W(e),e.drafts_.forEach(U),e.drafts_=null}function W(e){e===M&&(M=e.parent_)}function K(e){return M={drafts_:[],parent_:M,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function U(e){var t=e[n];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function I(e,r){r.unfinalizedDrafts_=r.drafts_.length;var a=r.drafts_[0];return void 0!==e&&e!==a?(a[n].modified_&&(N(r),o(4)),d(e)&&(e=B(r,e),r.parent_||T(r,e)),r.patches_&&x("Patches").generateReplacementPatches_(a[n].base_,e,r.patches_,r.inversePatches_)):e=B(r,a,[]),N(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==t?e:void 0}function B(e,t,r){if(D(t))return t;var o=t[n];if(!o)return g(t,(function(n,a){return L(e,o,t,n,a,r)})),t;if(o.scope_!==e)return t;if(!o.modified_)return T(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;var a=o.copy_,i=a,u=!1;3===o.type_&&(i=new Set(a),a.clear(),u=!0),g(i,(function(t,n){return L(e,o,a,t,n,r,u)})),T(e,a,!1),r&&e.patches_&&x("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function L(e,t,r,n,o,a,i){if(v(o)){var u=B(e,o,a&&t&&3!==t.type_&&!w(t.assigned_,n)?a.concat(n):void 0);if(P(r,n,u),!v(u))return;e.canAutoFreeze_=!1}else i&&r.add(o);if(d(o)&&!D(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;B(e,o),t&&t.scope_.parent_||T(e,o)}}function T(e,t,r){void 0===r&&(r=!1),!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&F(t,r)}var J={get:function(e,t){if(t===n)return e;var r=z(e);if(!w(r,t))return function(e,t,r){var n,o=G(t,r);return o?"value"in o?o.value:null==(n=o.get)?void 0:n.call(e.draft_):void 0}(e,r,t);var o=r[t];return e.finalized_||!d(o)?o:o===q(e.base_,t)?(Q(e),e.copy_[t]=Y(o,e)):o},has:function(e,t){return t in z(e)},ownKeys:function(e){return Reflect.ownKeys(z(e))},set:function(e,t,r){var o,a,i=G(z(e),t);if(null!=i&&i.set)return i.set.call(e.draft_,r),!0;if(!e.modified_){var u=q(z(e),t),c=null==u?void 0:u[n];if(c&&c.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(((o=r)===(a=u)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==r||w(e.base_,t)))return!0;Q(e),H(e)}return e.copy_[t]===r&&(void 0!==r||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty:function(e,t){return void 0!==q(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Q(e),H(e)):delete e.assigned_[t],delete e.copy_[t],!0},getOwnPropertyDescriptor:function(e,t){var r=z(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){o(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base_)},setPrototypeOf:function(){o(12)}},X={};function q(e,t){var r=e[n];return(r?z(r):e)[t]}function G(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function H(e){e.modified_||(e.modified_=!0,e.parent_&&H(e.parent_))}function Q(e){e.copy_||(e.copy_=A(e.base_,e.scope_.immer_.useStrictShallowCopy_))}g(J,(function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),X.deleteProperty=function(e,t){return X.set.call(this,e,t,void 0)},X.set=function(e,t,r){return J.set.call(this,e[0],t,r,e[0])};var V=function(){function e(e){var r=this;this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=function(e,n,a){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var u=r;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return u.produce(e,(function(e){var r;return(r=n).call.apply(r,[t,e].concat(o))}))}}var c;if("function"!=typeof n&&o(6),void 0!==a&&"function"!=typeof a&&o(7),d(e)){var f=K(r),s=Y(e,void 0),p=!0;try{c=n(s),p=!1}finally{p?N(f):W(f)}return C(f,a),I(c,f)}if(!e||"object"!=typeof e){if(void 0===(c=n(e))&&(c=e),c===t&&(c=void 0),r.autoFreeze_&&F(c,!0),a){var l=[],_=[];x("Patches").generateReplacementPatches_(e,c,l,_),a(l,_)}return c}o(1)},this.produceWithPatches=function(e,t){return"function"==typeof e?function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return r.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(o))}))}:[r.produce(e,t,(function(e,t){n=e,o=t})),n,o];var n,o},"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof(null==e?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}var r=e.prototype;return r.createDraft=function(e){d(e)||o(8),v(e)&&(e=Z(e));var t=K(this),r=Y(e,void 0);return r[n].isManual_=!0,W(t),r},r.finishDraft=function(e,t){var r=e&&e[n];r&&r.isManual_||o(9);var a=r.scope_;return C(a,t),I(void 0,a)},r.setAutoFreeze=function(e){this.autoFreeze_=e},r.setUseStrictShallowCopy=function(e){this.useStrictShallowCopy_=e},r.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var o=x("Patches").applyPatches_;return v(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},e}();function Y(e,t){var r=S(e)?function(e,t){return new $(e,t)}(e,t):j(e)?function(e,t){return new te(e,t)}(e,t):function(e,t){var r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:R(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,a=J;r&&(o=[n],a=X);var i=Proxy.revocable(o,a),u=i.revoke,c=i.proxy;return n.draft_=c,n.revoke_=u,c}(e,t);return(t?t.scope_:R()).drafts_.push(r),r}function Z(e){return v(e)||o(10),function e(t){if(!d(t)||D(t))return t;var r,o=t[n];if(o){if(!o.modified_)return o.base_;o.finalized_=!0,r=A(t,o.scope_.immer_.useStrictShallowCopy_)}else r=A(t,!0);return g(r,(function(t,n){P(r,t,e(n))})),o&&(o.finalized_=!1),r}(e)}var $=function(e,t){function r(t,r){var o;return(o=e.call(this)||this)[n]={type_:2,parent_:r,scope_:r?r.scope_:R(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:t,draft_:h(o),isManual_:!1,revoked_:!1},o}c(r,e);var o=r.prototype;return o.has=function(e){return z(this[n]).has(e)},o.set=function(e,t){var r=this[n];return ne(r),z(r).has(e)&&z(r).get(e)===t||(ee(r),H(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[n];return ne(t),ee(t),H(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0},o.clear=function(){var e=this[n];ne(e),z(e).size&&(ee(e),H(e),e.assigned_=new Map,g(e.base_,(function(t){e.assigned_.set(t,!1)})),e.copy_.clear())},o.forEach=function(e,t){var r=this;z(this[n]).forEach((function(n,o,a){e.call(t,r.get(o),o,r)}))},o.get=function(e){var t=this[n];ne(t);var r=z(t).get(e);if(t.finalized_||!d(r))return r;if(r!==t.base_.get(e))return r;var o=Y(r,t);return ee(t),t.copy_.set(e,o),o},o.keys=function(){return z(this[n]).keys()},o.values=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},o.entries=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},o[t]=function(){return this.entries()},i(r,[{key:"size",get:function(){return z(this[n]).size}}]),r}(_(Map),Symbol.iterator);function ee(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}var te=function(e,t){function r(t,r){var o;return(o=e.call(this)||this)[n]={type_:3,parent_:r,scope_:r?r.scope_:R(),modified_:!1,finalized_:!1,copy_:void 0,base_:t,draft_:h(o),drafts_:new Map,revoked_:!1,isManual_:!1},o}c(r,e);var o=r.prototype;return o.has=function(e){var t=this[n];return ne(t),t.copy_?!!t.copy_.has(e)||!(!t.drafts_.has(e)||!t.copy_.has(t.drafts_.get(e))):t.base_.has(e)},o.add=function(e){var t=this[n];return ne(t),this.has(e)||(re(t),H(t),t.copy_.add(e)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[n];return ne(t),re(t),H(t),t.copy_.delete(e)||!!t.drafts_.has(e)&&t.copy_.delete(t.drafts_.get(e))},o.clear=function(){var e=this[n];ne(e),z(e).size&&(re(e),H(e),e.copy_.clear())},o.values=function(){var e=this[n];return ne(e),re(e),e.copy_.values()},o.entries=function(){var e=this[n];return ne(e),re(e),e.copy_.entries()},o.keys=function(){return this.values()},o[t]=function(){return this.values()},o.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},i(r,[{key:"size",get:function(){return z(this[n]).size}}]),r}(_(Set),Symbol.iterator);function re(e){e.copy_||(e.copy_=new Set,e.base_.forEach((function(t){if(d(t)){var r=Y(t,e);e.drafts_.set(t,r),e.copy_.add(r)}else e.copy_.add(t)})))}function ne(e){e.revoked_&&o(3,JSON.stringify(z(e)))}var oe=new V,ae=oe.produce,ie=oe.produceWithPatches.bind(oe),ue=oe.setAutoFreeze.bind(oe),ce=oe.setUseStrictShallowCopy.bind(oe),fe=oe.applyPatches.bind(oe),se=oe.createDraft.bind(oe),pe=oe.finishDraft.bind(oe);e.Immer=V,e.applyPatches=fe,e.castDraft=function(e){return e},e.castImmutable=function(e){return e},e.createDraft=se,e.current=Z,e.enablePatches=function(){var e="add";function n(e){if(!d(e))return e;if(Array.isArray(e))return e.map(n);if(S(e))return new Map(Array.from(e.entries()).map((function(e){return[e[0],n(e[1])]})));if(j(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return w(e,r)&&(t[r]=e[r]),t}function a(e){return v(e)?n(e):e}E.Patches||(E.Patches={applyPatches_:function(t,r){return r.forEach((function(r){for(var a=r.path,i=r.op,u=t,c=0;c<a.length-1;c++){var f=m(u),s=a[c];"string"!=typeof s&&"number"!=typeof s&&(s=""+s),0!==f&&1!==f||"__proto__"!==s&&"constructor"!==s||o(19),"function"==typeof u&&"prototype"===s&&o(19),"object"!=typeof(u=O(u,s))&&o(18,a.join("/"))}var p=m(u),l=n(r.value),_=a[a.length-1];switch(i){case"replace":switch(p){case 2:return u.set(_,l);case 3:o(16);default:return u[_]=l}case e:switch(p){case 1:return"-"===_?u.push(l):u.splice(_,0,l);case 2:return u.set(_,l);case 3:return u.add(l);default:return u[_]=l}case"remove":switch(p){case 1:return u.splice(_,1);case 2:return u.delete(_);case 3:return u.delete(r.value);default:return delete u[_]}default:o(17)}})),t},generatePatches_:function(t,r,n,o){switch(t.type_){case 0:case 2:return function(t,r,n,o){var i=t.base_,u=t.copy_;g(t.assigned_,(function(t,c){var f=O(i,t),s=O(u,t),p=c?w(i,t)?"replace":e:"remove";if(f!==s||"replace"!==p){var l=r.concat(t);n.push("remove"===p?{op:p,path:l}:{op:p,path:l,value:s}),o.push(p===e?{op:"remove",path:l}:"remove"===p?{op:e,path:l,value:a(f)}:{op:"replace",path:l,value:a(f)})}}))}(t,r,n,o);case 1:return function(t,r,n,o){var i=t.base_,u=t.assigned_,c=t.copy_;if(c.length<i.length){var f=[c,i];i=f[0],c=f[1];var s=[o,n];n=s[0],o=s[1]}for(var p=0;p<i.length;p++)if(u[p]&&c[p]!==i[p]){var l=r.concat([p]);n.push({op:"replace",path:l,value:a(c[p])}),o.push({op:"replace",path:l,value:a(i[p])})}for(var _=i.length;_<c.length;_++){var h=r.concat([_]);n.push({op:e,path:h,value:a(c[_])})}for(var v=c.length-1;i.length<=v;--v){var d=r.concat([v]);o.push({op:"remove",path:d})}}(t,r,n,o);case 3:return function(t,r,n,o){var a=t.base_,i=t.copy_,u=0;a.forEach((function(t){if(!i.has(t)){var a=r.concat([u]);n.push({op:"remove",path:a,value:t}),o.unshift({op:e,path:a,value:t})}u++})),u=0,i.forEach((function(t){if(!a.has(t)){var i=r.concat([u]);n.push({op:e,path:i,value:t}),o.unshift({op:"remove",path:i,value:t})}u++}))}(t,r,n,o)}},generateReplacementPatches_:function(e,r,n,o){n.push({op:"replace",path:[],value:r===t?void 0:r}),o.push({op:"replace",path:[],value:e})}})},e.finishDraft=pe,e.freeze=F,e.immerable=r,e.isDraft=v,e.isDraftable=d,e.nothing=t,e.original=function(e){return v(e)||o(15),e[n].base_},e.produce=ae,e.produceWithPatches=ie,e.setAutoFreeze=ue,e.setUseStrictShallowCopy=ce,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).immer={})}(this,(function(e){"use strict";var t=Symbol.for("immer-nothing"),r=Symbol.for("immer-draftable"),n=Symbol.for("immer-state");function o(e){throw new Error("[Immer] minified error nr: "+e+". Full error at: https://bit.ly/3cXEKWf")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}function i(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,r){return(l=p()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function _(e){var t="function"==typeof Map?new Map:void 0;return(_=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return l(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return!!e&&!!e[n]}function y(e){var t;return!!e&&(b(e)||Array.isArray(e)||!!e[r]||!(null==(t=e.constructor)||!t[r])||S(e)||j(e))}var d=Object.prototype.constructor.toString();function b(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===d}function g(e,t){0===m(e)?Object.entries(e).forEach((function(r){t(r[0],r[1],e)})):e.forEach((function(r,n){return t(n,r,e)}))}function m(e){var t=e[n];return t?t.type_:Array.isArray(e)?1:S(e)?2:j(e)?3:0}function w(e,t){return 2===m(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function O(e,t){return 2===m(e)?e.get(t):e[t]}function P(e,t,r){var n=m(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function S(e){return e instanceof Map}function j(e){return e instanceof Set}function z(e){return e.copy_||e.base_}function A(e,t){if(S(e))return new Map(e);if(j(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&b(e)){if(!Object.getPrototypeOf(e)){var r=Object.create(null);return Object.assign(r,e)}return u({},e)}var o=Object.getOwnPropertyDescriptors(e);delete o[n];for(var a=Reflect.ownKeys(o),i=0;i<a.length;i++){var c=a[i],f=o[c];!1===f.writable&&(f.writable=!0,f.configurable=!0),(f.get||f.set)&&(o[c]={configurable:!0,writable:!0,enumerable:f.enumerable,value:e[c]})}return Object.create(Object.getPrototypeOf(e),o)}function M(e,t){return void 0===t&&(t=!1),x(e)||h(e)||!y(e)||(m(e)>1&&(e.set=e.add=e.clear=e.delete=F),Object.freeze(e),t&&g(e,(function(e,t){return M(t,!0)}))),e}function F(){o(2)}function x(e){return Object.isFrozen(e)}var k,D={};function E(e){var t=D[e];return t||o(0),t}function R(e,t){D[e]||(D[e]=t)}function C(){return k}function N(e,t){t&&(E("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function W(e){K(e),e.drafts_.forEach(I),e.drafts_=null}function K(e){e===k&&(k=e.parent_)}function U(e){return k={drafts_:[],parent_:k,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function I(e){var t=e[n];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function B(e,r){r.unfinalizedDrafts_=r.drafts_.length;var a=r.drafts_[0];return void 0!==e&&e!==a?(a[n].modified_&&(W(r),o(4)),y(e)&&(e=L(r,e),r.parent_||J(r,e)),r.patches_&&E("Patches").generateReplacementPatches_(a[n].base_,e,r.patches_,r.inversePatches_)):e=L(r,a,[]),W(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==t?e:void 0}function L(e,t,r){if(x(t))return t;var o=t[n];if(!o)return g(t,(function(n,a){return T(e,o,t,n,a,r)})),t;if(o.scope_!==e)return t;if(!o.modified_)return J(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;var a=o.copy_,i=a,u=!1;3===o.type_&&(i=new Set(a),a.clear(),u=!0),g(i,(function(t,n){return T(e,o,a,t,n,r,u)})),J(e,a,!1),r&&e.patches_&&E("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function T(e,t,r,n,o,a,i){if(h(o)){var u=L(e,o,a&&t&&3!==t.type_&&!w(t.assigned_,n)?a.concat(n):void 0);if(P(r,n,u),!h(u))return;e.canAutoFreeze_=!1}else i&&r.add(o);if(y(o)&&!x(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;L(e,o),t&&t.scope_.parent_||J(e,o)}}function J(e,t,r){void 0===r&&(r=!1),!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&M(t,r)}var X={get:function(e,t){if(t===n)return e;var r=z(e);if(!w(r,t))return function(e,t,r){var n,o=H(t,r);return o?"value"in o?o.value:null==(n=o.get)?void 0:n.call(e.draft_):void 0}(e,r,t);var o=r[t];return e.finalized_||!y(o)?o:o===G(e.base_,t)?(V(e),e.copy_[t]=Z(o,e)):o},has:function(e,t){return t in z(e)},ownKeys:function(e){return Reflect.ownKeys(z(e))},set:function(e,t,r){var o,a,i=H(z(e),t);if(null!=i&&i.set)return i.set.call(e.draft_,r),!0;if(!e.modified_){var u=G(z(e),t),c=null==u?void 0:u[n];if(c&&c.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(((o=r)===(a=u)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==r||w(e.base_,t)))return!0;V(e),Q(e)}return e.copy_[t]===r&&(void 0!==r||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty:function(e,t){return void 0!==G(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,V(e),Q(e)):delete e.assigned_[t],delete e.copy_[t],!0},getOwnPropertyDescriptor:function(e,t){var r=z(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){o(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base_)},setPrototypeOf:function(){o(12)}},q={};function G(e,t){var r=e[n];return(r?z(r):e)[t]}function H(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function Q(e){e.modified_||(e.modified_=!0,e.parent_&&Q(e.parent_))}function V(e){e.copy_||(e.copy_=A(e.base_,e.scope_.immer_.useStrictShallowCopy_))}g(X,(function(e,t){q[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),q.deleteProperty=function(e,t){return q.set.call(this,e,t,void 0)},q.set=function(e,t,r){return X.set.call(this,e[0],t,r,e[0])};var Y=function(){function e(e){var r=this;this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=function(e,n,a){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var u=r;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return u.produce(e,(function(e){var r;return(r=n).call.apply(r,[t,e].concat(o))}))}}var c;if("function"!=typeof n&&o(6),void 0!==a&&"function"!=typeof a&&o(7),y(e)){var f=U(r),s=Z(e,void 0),p=!0;try{c=n(s),p=!1}finally{p?W(f):K(f)}return N(f,a),B(c,f)}if(!e||"object"!=typeof e){if(void 0===(c=n(e))&&(c=e),c===t&&(c=void 0),r.autoFreeze_&&M(c,!0),a){var l=[],_=[];E("Patches").generateReplacementPatches_(e,c,l,_),a(l,_)}return c}o(1)},this.produceWithPatches=function(e,t){return"function"==typeof e?function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return r.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(o))}))}:[r.produce(e,t,(function(e,t){n=e,o=t})),n,o];var n,o},"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof(null==e?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}var r=e.prototype;return r.createDraft=function(e){y(e)||o(8),h(e)&&(e=$(e));var t=U(this),r=Z(e,void 0);return r[n].isManual_=!0,K(t),r},r.finishDraft=function(e,t){var r=e&&e[n];r&&r.isManual_||o(9);var a=r.scope_;return N(a,t),B(void 0,a)},r.setAutoFreeze=function(e){this.autoFreeze_=e},r.setUseStrictShallowCopy=function(e){this.useStrictShallowCopy_=e},r.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var o=E("Patches").applyPatches_;return h(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},e}();function Z(e,t){var r=S(e)?E("MapSet").proxyMap_(e,t):j(e)?E("MapSet").proxySet_(e,t):function(e,t){var r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:C(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,a=X;r&&(o=[n],a=q);var i=Proxy.revocable(o,a),u=i.revoke,c=i.proxy;return n.draft_=c,n.revoke_=u,c}(e,t);return(t?t.scope_:C()).drafts_.push(r),r}function $(e){return h(e)||o(10),function e(t){if(!y(t)||x(t))return t;var r,o=t[n];if(o){if(!o.modified_)return o.base_;o.finalized_=!0,r=A(t,o.scope_.immer_.useStrictShallowCopy_)}else r=A(t,!0);return g(r,(function(t,n){P(r,t,e(n))})),o&&(o.finalized_=!1),r}(e)}var ee=new Y,te=ee.produce,re=ee.produceWithPatches.bind(ee),ne=ee.setAutoFreeze.bind(ee),oe=ee.setUseStrictShallowCopy.bind(ee),ae=ee.applyPatches.bind(ee),ie=ee.createDraft.bind(ee),ue=ee.finishDraft.bind(ee);e.Immer=Y,e.applyPatches=ae,e.castDraft=function(e){return e},e.castImmutable=function(e){return e},e.createDraft=ie,e.current=$,e.enableMapSet=function(){var e=function(e,r){function o(t,r){var o;return(o=e.call(this)||this)[n]={type_:2,parent_:r,scope_:r?r.scope_:C(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:t,draft_:v(o),isManual_:!1,revoked_:!1},o}c(o,e);var a=o.prototype;return a.has=function(e){return z(this[n]).has(e)},a.set=function(e,r){var o=this[n];return u(o),z(o).has(e)&&z(o).get(e)===r||(t(o),Q(o),o.assigned_.set(e,!0),o.copy_.set(e,r),o.assigned_.set(e,!0)),this},a.delete=function(e){if(!this.has(e))return!1;var r=this[n];return u(r),t(r),Q(r),r.base_.has(e)?r.assigned_.set(e,!1):r.assigned_.delete(e),r.copy_.delete(e),!0},a.clear=function(){var e=this[n];u(e),z(e).size&&(t(e),Q(e),e.assigned_=new Map,g(e.base_,(function(t){e.assigned_.set(t,!1)})),e.copy_.clear())},a.forEach=function(e,t){var r=this;z(this[n]).forEach((function(n,o,a){e.call(t,r.get(o),o,r)}))},a.get=function(e){var r=this[n];u(r);var o=z(r).get(e);if(r.finalized_||!y(o))return o;if(o!==r.base_.get(e))return o;var a=Z(o,r);return t(r),r.copy_.set(e,a),a},a.keys=function(){return z(this[n]).keys()},a.values=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},a.entries=function(){var e,t=this,r=this.keys();return(e={})[Symbol.iterator]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},a[r]=function(){return this.entries()},i(o,[{key:"size",get:function(){return z(this[n]).size}}]),o}(_(Map),Symbol.iterator);function t(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}var r=function(e,t){function r(t,r){var o;return(o=e.call(this)||this)[n]={type_:3,parent_:r,scope_:r?r.scope_:C(),modified_:!1,finalized_:!1,copy_:void 0,base_:t,draft_:v(o),drafts_:new Map,revoked_:!1,isManual_:!1},o}c(r,e);var o=r.prototype;return o.has=function(e){var t=this[n];return u(t),t.copy_?!!t.copy_.has(e)||!(!t.drafts_.has(e)||!t.copy_.has(t.drafts_.get(e))):t.base_.has(e)},o.add=function(e){var t=this[n];return u(t),this.has(e)||(a(t),Q(t),t.copy_.add(e)),this},o.delete=function(e){if(!this.has(e))return!1;var t=this[n];return u(t),a(t),Q(t),t.copy_.delete(e)||!!t.drafts_.has(e)&&t.copy_.delete(t.drafts_.get(e))},o.clear=function(){var e=this[n];u(e),z(e).size&&(a(e),Q(e),e.copy_.clear())},o.values=function(){var e=this[n];return u(e),a(e),e.copy_.values()},o.entries=function(){var e=this[n];return u(e),a(e),e.copy_.entries()},o.keys=function(){return this.values()},o[t]=function(){return this.values()},o.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},i(r,[{key:"size",get:function(){return z(this[n]).size}}]),r}(_(Set),Symbol.iterator);function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach((function(t){if(y(t)){var r=Z(t,e);e.drafts_.set(t,r),e.copy_.add(r)}else e.copy_.add(t)})))}function u(e){e.revoked_&&o(3,JSON.stringify(z(e)))}R("MapSet",{proxyMap_:function(t,r){return new e(t,r)},proxySet_:function(e,t){return new r(e,t)}})},e.enablePatches=function(){var e="add";function n(e){if(!y(e))return e;if(Array.isArray(e))return e.map(n);if(S(e))return new Map(Array.from(e.entries()).map((function(e){return[e[0],n(e[1])]})));if(j(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return w(e,r)&&(t[r]=e[r]),t}function a(e){return h(e)?n(e):e}R("Patches",{applyPatches_:function(t,r){return r.forEach((function(r){for(var a=r.path,i=r.op,u=t,c=0;c<a.length-1;c++){var f=m(u),s=a[c];"string"!=typeof s&&"number"!=typeof s&&(s=""+s),0!==f&&1!==f||"__proto__"!==s&&"constructor"!==s||o(19),"function"==typeof u&&"prototype"===s&&o(19),"object"!=typeof(u=O(u,s))&&o(18,a.join("/"))}var p=m(u),l=n(r.value),_=a[a.length-1];switch(i){case"replace":switch(p){case 2:return u.set(_,l);case 3:o(16);default:return u[_]=l}case e:switch(p){case 1:return"-"===_?u.push(l):u.splice(_,0,l);case 2:return u.set(_,l);case 3:return u.add(l);default:return u[_]=l}case"remove":switch(p){case 1:return u.splice(_,1);case 2:return u.delete(_);case 3:return u.delete(r.value);default:return delete u[_]}default:o(17)}})),t},generatePatches_:function(t,r,n,o){switch(t.type_){case 0:case 2:return function(t,r,n,o){var i=t.base_,u=t.copy_;g(t.assigned_,(function(t,c){var f=O(i,t),s=O(u,t),p=c?w(i,t)?"replace":e:"remove";if(f!==s||"replace"!==p){var l=r.concat(t);n.push("remove"===p?{op:p,path:l}:{op:p,path:l,value:s}),o.push(p===e?{op:"remove",path:l}:"remove"===p?{op:e,path:l,value:a(f)}:{op:"replace",path:l,value:a(f)})}}))}(t,r,n,o);case 1:return function(t,r,n,o){var i=t.base_,u=t.assigned_,c=t.copy_;if(c.length<i.length){var f=[c,i];i=f[0],c=f[1];var s=[o,n];n=s[0],o=s[1]}for(var p=0;p<i.length;p++)if(u[p]&&c[p]!==i[p]){var l=r.concat([p]);n.push({op:"replace",path:l,value:a(c[p])}),o.push({op:"replace",path:l,value:a(i[p])})}for(var _=i.length;_<c.length;_++){var v=r.concat([_]);n.push({op:e,path:v,value:a(c[_])})}for(var h=c.length-1;i.length<=h;--h){var y=r.concat([h]);o.push({op:"remove",path:y})}}(t,r,n,o);case 3:return function(t,r,n,o){var a=t.base_,i=t.copy_,u=0;a.forEach((function(t){if(!i.has(t)){var a=r.concat([u]);n.push({op:"remove",path:a,value:t}),o.unshift({op:e,path:a,value:t})}u++})),u=0,i.forEach((function(t){if(!a.has(t)){var i=r.concat([u]);n.push({op:e,path:i,value:t}),o.unshift({op:"remove",path:i,value:t})}u++}))}(t,r,n,o)}},generateReplacementPatches_:function(e,r,n,o){n.push({op:"replace",path:[],value:r===t?void 0:r}),o.push({op:"replace",path:[],value:e})}})},e.finishDraft=ue,e.freeze=M,e.immerable=r,e.isDraft=h,e.isDraftable=y,e.nothing=t,e.original=function(e){return h(e)||o(15),e[n].base_},e.produce=te,e.produceWithPatches=re,e.setAutoFreeze=ne,e.setUseStrictShallowCopy=oe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=immer.umd.production.min.js.map |
@@ -12,3 +12,2 @@ export * from "./utils/env"; | ||
export * from "./core/current"; | ||
export * from "./core/mapset"; | ||
//# sourceMappingURL=internal.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { ImmerState, Patch } from "../internal"; | ||
import { ImmerState, Patch, Drafted, ImmerBaseState, AnyMap, AnySet, ArchType } from "../internal"; | ||
/** Plugin utilities */ | ||
@@ -9,2 +9,6 @@ declare const plugins: { | ||
}; | ||
MapSet?: { | ||
proxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T; | ||
proxySet_<T extends AnySet>(target: T, parent?: ImmerState): T; | ||
}; | ||
}; | ||
@@ -14,2 +18,19 @@ declare type Plugins = typeof plugins; | ||
export declare function loadPlugin<K extends keyof Plugins>(pluginKey: K, implementation: Plugins[K]): void; | ||
/** Map / Set plugin */ | ||
export interface MapState extends ImmerBaseState { | ||
type_: ArchType.Map; | ||
copy_: AnyMap | undefined; | ||
assigned_: Map<any, boolean> | undefined; | ||
base_: AnyMap; | ||
revoked_: boolean; | ||
draft_: Drafted<AnyMap, MapState>; | ||
} | ||
export interface SetState extends ImmerBaseState { | ||
type_: ArchType.Set; | ||
copy_: AnySet | undefined; | ||
base_: AnySet; | ||
drafts_: Map<any, Drafted>; | ||
revoked_: boolean; | ||
draft_: Drafted<AnySet, SetState>; | ||
} | ||
/** Patches plugin */ | ||
@@ -16,0 +37,0 @@ export declare type PatchPath = (string | number)[]; |
{ | ||
"name": "immer", | ||
"version": "10.0.0-beta.4", | ||
"version": "10.0.0-beta.6", | ||
"description": "Create your next immutable state by mutating the current one", | ||
@@ -24,5 +24,5 @@ "main": "dist/index.js", | ||
"test": "jest && yarn test:build && yarn test:flow", | ||
"test:perf": "cd __performance_tests__ && babel-node add-data.js && babel-node todo.js && babel-node incremental.js && babel-node large-obj.js", | ||
"test:perf": "cd __performance_tests__ && node add-data.mjs && node todo.mjs && node incremental.mjs && node large-obj.mjs", | ||
"test:flow": "yarn flow check __tests__/flow", | ||
"test:build": "yarn build && NODE_ENV='production' yarn jest --config jest.config.build.mjs", | ||
"test:build": "yarn build && NODE_ENV='production' yarn jest --config jest.config.build.js", | ||
"watch": "jest --watch", | ||
@@ -35,3 +35,3 @@ "coverage": "jest --coverage", | ||
"start": "cd website && yarn start", | ||
"test:size": "yarn build && yarn import-size --report . produce enablePatches", | ||
"test:size": "yarn build && yarn import-size --report . produce enableMapSet enablePatches", | ||
"test:sizequick": "tsdx build --name immer --format esm && yarn import-size . produce" | ||
@@ -70,3 +70,2 @@ }, | ||
"@babel/core": "^7.21.3", | ||
"@babel/node": "^7.20.7", | ||
"@types/jest": "^25.1.2", | ||
@@ -73,0 +72,0 @@ "coveralls": "^3.0.0", |
@@ -26,5 +26,3 @@ import { | ||
freeze, | ||
current, | ||
proxyMap, | ||
proxySet | ||
current | ||
} from "../internal" | ||
@@ -208,5 +206,5 @@ | ||
const draft: Drafted = isMap(value) | ||
? proxyMap(value, parent) | ||
? getPlugin("MapSet").proxyMap_(value, parent) | ||
: isSet(value) | ||
? proxySet(value, parent) | ||
? getPlugin("MapSet").proxySet_(value, parent) | ||
: createProxyProxy(value, parent) | ||
@@ -213,0 +211,0 @@ |
@@ -113,1 +113,2 @@ import { | ||
export {enablePatches} from "./plugins/patches" | ||
export {enableMapSet} from "./plugins/mapset" |
@@ -12,2 +12,1 @@ export * from "./utils/env" | ||
export * from "./core/current" | ||
export * from "./core/mapset" |
@@ -1,2 +0,11 @@ | ||
import {ImmerState, Patch, die} from "../internal" | ||
import { | ||
ImmerState, | ||
Patch, | ||
Drafted, | ||
ImmerBaseState, | ||
AnyMap, | ||
AnySet, | ||
ArchType, | ||
die | ||
} from "../internal" | ||
@@ -20,2 +29,6 @@ /** Plugin utilities */ | ||
} | ||
MapSet?: { | ||
proxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T | ||
proxySet_<T extends AnySet>(target: T, parent?: ImmerState): T | ||
} | ||
} = {} | ||
@@ -42,5 +55,24 @@ | ||
} | ||
/** Map / Set plugin */ | ||
export interface MapState extends ImmerBaseState { | ||
type_: ArchType.Map | ||
copy_: AnyMap | undefined | ||
assigned_: Map<any, boolean> | undefined | ||
base_: AnyMap | ||
revoked_: boolean | ||
draft_: Drafted<AnyMap, MapState> | ||
} | ||
export interface SetState extends ImmerBaseState { | ||
type_: ArchType.Set | ||
copy_: AnySet | undefined | ||
base_: AnySet | ||
drafts_: Map<any, Drafted> // maps the original value to the draft value in the new set | ||
revoked_: boolean | ||
draft_: Drafted<AnySet, SetState> | ||
} | ||
/** Patches plugin */ | ||
export type PatchPath = (string | number)[] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
743824
22
6927