@formily/reactive
Advanced tools
Comparing version 2.2.29 to 2.2.30
@@ -355,3 +355,3 @@ (function (global, factory) { | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -399,8 +399,17 @@ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
function __spreadArray(to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
} | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
var DataChange = /** @class */ (function () { | ||
@@ -735,5 +744,5 @@ function DataChange(operation, node) { | ||
} | ||
return cb.apply(void 0, __spreadArray([findObservable(target, key, value), key], __read(args))); | ||
return cb.apply(void 0, __spreadArray([findObservable(target, key, value), key], __read(args), false)); | ||
}; | ||
return (_a = proto.forEach).call.apply(_a, __spreadArray([target, wrappedCb], __read(args))); | ||
return (_a = proto.forEach).call.apply(_a, __spreadArray([target, wrappedCb], __read(args), false)); | ||
}, | ||
@@ -740,0 +749,0 @@ keys: function () { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("formily.reactive",["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).Formily=e.Formily||{},e.Formily.Reactive={}))}(this,(function(e){"use strict";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var t=Object.prototype.toString,r=function(e){return e&&e instanceof Map},n=function(e){return e&&e instanceof Set},a=function(e){return e&&e instanceof WeakMap},u=function(e){return e&&e instanceof WeakSet},o=function(e){return"function"==typeof e},i=Array.isArray,c=function(e){return"[object Object]"===t.call(e)},l=function(e){return r(e)||a(e)||n(e)||u(e)},f=function(e){return c(e)||i(e)},s=function(e){return Array.isArray(e)?e:null!=e?[e]:[]},v=function(){function e(e){void 0===e&&(e=[]),this.forEachIndex=0,this.value=e}return e.prototype.add=function(e){this.has(e)||this.value.push(e)},e.prototype.has=function(e){return this.value.indexOf(e)>-1},e.prototype.delete=function(e){var t=this.value.length;if(0!==t)if(1!==t||this.value[0]!==e){var r=this.value.indexOf(e);r>-1&&(this.value.splice(r,1),r<=this.forEachIndex&&(this.forEachIndex-=1))}else this.value=[]},e.prototype.forEach=function(e){if(0!==this.value.length)for(this.forEachIndex=0;this.forEachIndex<this.value.length;this.forEachIndex++)e(this.value[this.forEachIndex])},e.prototype.batchDelete=function(e){if(0!==this.value.length)for(this.forEachIndex=0;this.forEachIndex<this.value.length;this.forEachIndex++){var t=this.value[this.forEachIndex];this.value.splice(this.forEachIndex,1),this.forEachIndex--,e(t)}},e.prototype.clear=function(){this.value.length=0},e}(),y=new WeakMap,p=new WeakMap,d=new WeakMap,h=new WeakMap,g=new WeakMap,b=[],m={value:0},k={value:0},O={value:!1},_={value:!1},w=new v,P=new v,S=new v,E=new v,j=Symbol("MakeObModelSymbol"),x=Symbol("ObModelSymbol"),R=Symbol("ObModelNodeSymbol"),V=Symbol("iteration key"),M=function(e,t){var r=g.get(e),n=[];if(r){var a=r.get(t);a&&a.forEach((function(e){-1===n.indexOf(e)&&n.push(e)}))}return n},D=function(e,t){var r=M(e,t),n=k.value;k.value=0;for(var a=0,u=r.length;a<u;a++){var i=r[a];i._isComputed?i._scheduler(i):K()?P.add(i):B()?w.add(i):o(i._scheduler)?i._scheduler(i):i()}k.value=n},I=function(e){var t=e.key,r=e.type,n=e.target;"iterate"===r&&(t=V);var a=b.length;if(0!==a){var u=b[a-1];Y()||u&&(_.value=!0,function(e,t){var r=e._reactionsSet;r?r.add(t):e._reactionsSet=new v([t])}(u,function(e,t,r){var n=g.get(e);if(n){var a=n.get(t);return a?a.add(r):n.set(t,new v([r])),n}var u=new Map([[t,new v([r])]]);return g.set(e,u),u}(n,t,u)))}},q=function(e){var t=e.key,r=e.type,n=e.target,a=e.oldTarget;if(N(),function(e){E.forEach((function(t){return t(e)}))}(e),"clear"===r?a.forEach((function(e,t){D(n,t)})):D(n,t),"add"===r||"delete"===r||"clear"===r){var u=Array.isArray(n)?"length":V;D(n,u)}W()},A=function(e){var t;null===(t=e._reactionsSet)||void 0===t||t.forEach((function(t){t.forEach((function(t){t.delete(e)}))})),w.delete(e),P.delete(e),delete e._reactionsSet},T=function(e){e._disposed=!0,A(e),function(e){var t;null===(t=e._computesSet)||void 0===t||t.forEach((function(e){0===M(e._context,e._property).length&&(T(e),e._dirty=!0)}))}(e)},N=function(){m.value++},W=function(){if(m.value--,0===m.value){var e=k.value;k.value=0,$(),L(),k.value=e}},C=function(){O.value=!0},J=function(){var e=k.value;O.value=!1,k.value=0,P.batchDelete((function(e){o(e._scheduler)?e._scheduler(e):e()})),k.value=e},z=function(){k.value++},F=function(){k.value--},B=function(){return m.value>0},K=function(){return O.value},Y=function(){return k.value>0},$=function(){w.batchDelete((function(e){o(e._scheduler)?e._scheduler(e):e()}))},L=function(){S.batchDelete((function(e){e()}))},G=function(e,t){return e!==t&&(e.length!==t.length||!!e.some((function(e,r){return e!==t[r]})))},H=function(){return H=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},H.apply(this,arguments)};function Q(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,u=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=u.next()).done;)o.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=u.return)&&r.call(u)}finally{if(a)throw a.error}}return o}function U(e,t){for(var r=0,n=t.length,a=e.length;r<n;r++,a++)e[a]=t[r];return e}var X,Z=function(){function e(e,t){this.node=t,this.key=e.key,this.type=e.type,this.object=e.target,this.value=e.value,this.oldValue=e.oldValue}return Object.defineProperty(e.prototype,"path",{get:function(){return this.node.path.concat(this.key)},enumerable:!1,configurable:!0}),e}(),ee=function(){function e(e,t,r){this.target=e,this.key=t,this.value=r}return Object.defineProperty(e.prototype,"path",{get:function(){return this.parent?this.parent.path.concat(this.key):this.key?[this.key]:[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetRaw",{get:function(){return fe(this.target)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){if(this.target)return te(this.targetRaw)},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(e){return this.key?e.targetRaw===this.targetRaw&&e.key===this.key:e.value===this.value},e.prototype.contains=function(e){if(e===this)return!0;for(var t=e.parent;t;){if(this.isEqual(t))return!0;t=t.parent}return!1},e}(),te=function(e){return(null==e?void 0:e[R])?e[R]:h.get(e)},re=function(e,t){(null==e?void 0:e[x])?e[R]=t:h.set(e,t)},ne=function(e,t,r){var n=fe(r),a=te(n);if(a)return a;re(n,new ee(e,t,r))},ae=Symbol("RAW_TYPE"),ue=Symbol("OBSERVABLE_TYPE"),oe=Object.prototype.hasOwnProperty,ie=function(e){return y.has(e)||!!(null==e?void 0:e[x])},ce=function(e){return e&&!!e[j]},le=function(e){return null!=e&&(!!i(e)||(c(e)?!e[ae]&&(!!e[ue]||(!("$$typeof"in e)||!("_owner"in e))&&(!e._isAMomentObject&&(!e._isJSONSchemaObject&&(!o(e.toJS)&&!o(e.toJSON))))):!!(r(e)||a(e)||n(e)||u(e))))},fe=function(e){return(null==e?void 0:e[x])?e[x]:y.get(e)||e},se=new Set(Object.getOwnPropertyNames(Symbol).reduce((function(e,t){if("arguments"===t||"caller"===t)return e;var r=Symbol[t];return"symbol"==typeof r?e.concat(r):e}),[])),ve=Object.prototype.hasOwnProperty;function ye(e,t,r){var n=p.get(r);return n||(!ie(r)&&le(r)?ke(e,t,r):r)}function pe(e,t,r,n){var a=r.next;return r.next=function(){var u=a.call(r),o=u.done,i=u.value;return o||(n?i[1]=ye(e,t,i[1]):i=ye(e,t,i)),{done:o,value:i}},r}var de=(X={has:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this);return I({target:t,key:e,type:"has"}),r.has.apply(t,arguments)},get:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this);return I({target:t,key:e,type:"get"}),ye(t,e,r.get.apply(t,arguments))},add:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),a=r.add.apply(t,arguments);return n||q({target:t,key:e,value:e,type:"add"}),a},set:function(e,t){var r=y.get(this),n=Reflect.getPrototypeOf(this),a=n.has.call(r,e),u=n.get.call(r,e),o=n.set.apply(r,arguments);return a?t!==u&&q({target:r,key:e,value:t,oldValue:u,type:"set"}):q({target:r,key:e,value:t,type:"add"}),o},delete:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),a=r.get?r.get.call(t,e):void 0,u=r.delete.apply(t,arguments);return n&&q({target:t,key:e,oldValue:a,type:"delete"}),u},clear:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this),r=0!==e.size,n=e instanceof Map?new Map(e):new Set(e),a=t.clear.apply(e,arguments);return r&&q({target:e,oldTarget:n,type:"clear"}),a},forEach:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var a=y.get(this),u=Reflect.getPrototypeOf(this);I({target:a,type:"iterate"});var o=function(t,r){for(var n=[],u=2;u<arguments.length;u++)n[u-2]=arguments[u];return e.apply(void 0,U([ye(a,r,t),r],Q(n)))};return(t=u.forEach).call.apply(t,U([a,o],Q(r)))},keys:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);return I({target:e,type:"iterate"}),t.keys.apply(e,arguments)},values:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);I({target:e,type:"iterate"});var r=t.values.apply(e,arguments);return pe(e,"",r,!1)},entries:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);I({target:e,type:"iterate"});var r=t.entries.apply(e,arguments);return pe(e,"",r,!0)}},X[Symbol.iterator]=function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);I({target:e,type:"iterate"});var r=t[Symbol.iterator].apply(e,arguments);return pe(e,"",r,e instanceof Map)},Object.defineProperty(X,"size",{get:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);return I({target:e,type:"iterate"}),Reflect.get(t,"size",e)},enumerable:!1,configurable:!0}),X),he={get:function(e,t,r){return e=ve.call(de,t)?de:e,Reflect.get(e,t,r)}},ge={get:function(e,t,r){if(t){var n=e[t];if("symbol"==typeof t&&se.has(t))return n;I({target:e,key:t,receiver:r,type:"get"});var a=p.get(n);if(a)return a;if(!ie(n)&&le(n)){var u=Reflect.getOwnPropertyDescriptor(e,t);if(!u||!1!==u.writable||!1!==u.configurable)return ke(e,t,n)}return n}},has:function(e,t){var r=Reflect.has(e,t);return I({target:e,key:t,type:"has"}),r},ownKeys:function(e){var t=Reflect.ownKeys(e);return I({target:e,type:"iterate"}),t},set:function(e,t,r,n){var a=ve.call(e,t),u=ke(e,t,r),o=e[t];return e[t]=u,a?r!==o&&q({target:e,key:t,value:u,oldValue:o,receiver:n,type:"set"}):q({target:e,key:t,value:u,oldValue:o,receiver:n,type:"add"}),!0},deleteProperty:function(e,t){var r=e[t];return delete e[t],q({target:e,key:t,oldValue:r,type:"delete"}),!0}},be=function(e,t){var r=new Proxy(e,ge);return y.set(r,e),t?d.set(e,r):p.set(e,r),r},me=function(e,t){var r=new Proxy(e,he);return y.set(r,e),t?d.set(e,r):p.set(e,r),r},ke=function(e,t,r,n){if("object"!=typeof r)return r;var a=y.get(r);if(a){var u=te(a);return u.target||(u.target=e),u.key=t,r}if(!le(r))return r;if(e){var o=y.get(e)||e;if(d.get(o))return r}return ne(e,t,r),n?function(e){return f(e)?be(e,!0):l(e)?me(e,!0):e}(r):f(r)?be(r):l(r)?me(r):r},Oe=function(e){var t=function(t){return e({value:t})};return o(e)&&(t[j]=e),t},_e=function(e){if(e[j])return e[j][j]?_e(e[j]):e[j]},we=function(e,t){function r(r){var n;try{e(),o(r)&&(n=r())}finally{t()}return n}return r.bound=Pe(r),r},Pe=function(e){return function(t,r){return function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];return e((function(){return t.apply(r,n)}))}}},Se=function(e,t){var r=we(e,t),n=Oe((function(e){var t=e.target,n=e.key;return t[n]=r.bound(t[n],t),t}));return r[j]=n,r.bound[j]=n,r},Ee=Se(N,W);Ee.scope=Se(C,J),Ee.endpoint=function(e){o(e)&&(0===m.value?e():S.add(e))};var je=Se((function(){N(),z()}),(function(){F(),W()}));je.scope=Se((function(){C(),z()}),(function(){F(),J()}));var xe=we(z,F),Re=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:ke(t,r,t?t[r]:n)};return t?(Object.defineProperty(t,r,{set:function(e){var n=a.value;e=ke(t,r,e),a.value=e,n!==e&&q({target:t,key:r,type:"set",oldValue:n,value:e})},get:function(){return I({target:t,key:r,type:"get"}),a.value},enumerable:!0,configurable:!1}),t):a.value})),Ve=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:t?t[r]:n},u={set:function(e){var t=a.value;a.value=e,t!==e&&q({target:a,key:r,type:"set",oldValue:t,value:e})},get:function(){return I({target:a,key:r,type:"get"}),a.value}};return y.set(u,a),p.set(a,u),ne(t,r,a),t?(Object.defineProperty(t,r,{value:u,enumerable:!0,configurable:!1,writable:!1}),t):u})),Me=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:t?t[r]:n},u={},o=t||a,i=t?r:"value";function c(){return I({target:o,key:i,type:"get"}),a.value}function l(e){var t=a.value;a.value=e,t!==e&&q({target:o,key:i,type:"set",oldValue:t,value:e})}return t?(Object.defineProperty(t,r,{get:c,set:l,enumerable:!0}),t):(Object.defineProperty(u,"value",{set:l,get:c}),ne(t,r,a),u[x]=a,u)})),De=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:ke(t,r,t?t[r]:n,!0)};return t?(Object.defineProperty(t,r,{set:function(e){var n=a.value;e=ke(t,r,e,!0),a.value=e,n!==e&&q({target:t,key:r,type:"set",oldValue:n,value:e})},get:function(){return I({target:t,key:r,type:"get"}),a.value},enumerable:!0,configurable:!1}),t):a.value})),Ie=Object.getOwnPropertyDescriptor,qe=Object.getPrototypeOf,Ae=Symbol("ClassDescriptorSymbol");function Te(e,t){if(e)return Ie(e,t)||Te(qe(e),t)}function Ne(e,t,r){if(!e)return r?o(r)?{get:r}:r:{};var n=function(e,t){var r=e.constructor;if(r===Object||r===Array)return Te(e,t);var n=r[Ae]||{},a=n[t];if(a)return a;var u=Te(e,t);return r[Ae]=n,n[t]=u,u}(e,t);return n||{}}var We=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={},u={},i=t||a,c=t?r:"value",l=Ne(t,c,n);function f(){var e;a.value=null===(e=l.get)||void 0===e?void 0:e.call(i)}function s(){if(-1===b.indexOf(s)){A(s);try{b.push(s),f()}finally{b.pop()}}}function y(){return b.length>0&&function(e){if(o(e)){var t=b[b.length-1];if(t){var r=t._computesSet;r?r.add(e):t._computesSet=new v([e])}}}(s),Y()?f():s._dirty&&(s(),s._dirty=!1),I({target:i,key:c,type:"get"}),a.value}function p(e){var t;try{N(),null===(t=l.set)||void 0===t||t.call(i,e)}finally{W()}}return s._name="ComputedReaction",s._scheduler=function(){s._dirty=!0,q({target:i,key:c,value:a.value,type:"set"})},s._isComputed=!0,s._dirty=!0,s._context=i,s._property=c,t?(Object.defineProperty(t,r,{get:y,set:p,enumerable:!0}),t):(Object.defineProperty(u,"value",{set:p,get:y}),ne(t,r,a),u[x]=a,u)}));function Ce(e){return ke(null,null,e)}function Je(e,t){if(ie(e))return e;if(!le(e))return e;for(var r in e[x]=e,ne(void 0,void 0,e),t){var n=t[r];ce(n)&&_e(n)({target:e,key:r})}return e}Ce.box=Ve,Ce.ref=Me,Ce.deep=Re,Ce.shallow=De,Ce.computed=We,Ce[j]=Re;var ze=function(e,t){void 0===t&&(t="AutoRun");var r=function(){if(o(e)&&!(r._boundary>0)&&-1===b.indexOf(r)){A(r);try{N(),b.push(r),e()}finally{b.pop(),r._boundary++,W(),r._boundary=0,r._memos.cursor=0,r._effects.cursor=0}}},n=function(){r._memos={queue:[],cursor:0},r._effects={queue:[],cursor:0}};return r._boundary=0,r._name=t,n(),r(),function(){T(r),function(e){if(e._effects)try{N(),e._effects.queue.forEach((function(e){e&&e.dispose&&e.dispose()}))}finally{W()}}(r),n()}};ze.memo=function(e,t){if(o(e)){var r=b[b.length-1];if(!r||!r._memos)throw new Error("autorun.memo must used in autorun function body.");var n=s(t||[]),a=r._memos.cursor++,u=r._memos.queue[a];if(!u||G(n,u.deps)){var i=e();return r._memos.queue[a]={value:i,deps:n},i}return u.value}},ze.effect=function(e,t){if(o(e)){var r=b[b.length-1];if(!r||!r._effects)throw new Error("autorun.effect must used in autorun function body.");var n=r._effects,a=s(t||[{}]),u=n.cursor++,i=n.queue[u];i&&!G(a,i.deps)||(Promise.resolve(0).then((function(){if(!r._disposed){var t=e();o(t)&&(n.queue[u].dispose=t)}})),n.queue[u]={deps:a})}};var Fe=function(e,t){void 0===t&&(t="TrackerReaction");var r=this;this.track=function(e){if(!o(e))return r.results;if(!(r.track._boundary>0)){if(-1===b.indexOf(r.track)){A(r.track);try{N(),b.push(r.track),r.results=e()}finally{b.pop(),r.track._boundary++,W(),r.track._boundary=0}}return r.results}},this.dispose=function(){T(r.track)},this.track._scheduler=function(t){0===r.track._boundary&&r.dispose(),o(t)&&e(t)},this.track._name=t,this.track._boundary=0};e.DataChange=Z,e.DataNode=ee,e.Tracker=Fe,e.action=je,e.autorun=ze,e.batch=Ee,e.buildDataTree=ne,e.contains=function(e,t){var r=fe(e),n=fe(t);if(r===n)return!0;var a=te(r),u=te(n);return!!a&&(!!u&&a.contains(u))},e.define=Je,e.getDataNode=te,e.hasCollected=function(e){return _.value=!1,null==e||e(),_.value},e.isAnnotation=ce,e.isObservable=ie,e.isSupportObservable=le,e.markObservable=function(e){if(e)return o(e)?e.prototype[ue]=!0:e[ue]=!0,e},e.markRaw=function(e){if(e)return o(e)?e.prototype[ae]=!0:e[ae]=!0,e},e.model=function(e){var t=Object.keys(e||{}).reduce((function(t,r){var n=Object.getOwnPropertyDescriptor(e,r);return n&&n.get?t[r]=Ce.computed:o(e[r])?t[r]=je:t[r]=Ce,t}),{});return Je(e,t)},e.observable=Ce,e.observe=function(e,t,r){void 0===r&&(r=!0);if(e&&"object"!=typeof e)throw Error("Can not observe ".concat(typeof e," type."));return function(e){var n=fe(e),a=te(n),u=function(e){var n=fe(e.target),u=te(n);(r&&a.contains(u)||a===u||a.targetRaw===n&&a.key===e.key)&&t(new Z(e,u))};return a&&o(t)&&E.add(u),function(){E.delete(u)}}(e)},e.raw=fe,e.reaction=function(e,t,r){var n=H({name:"Reaction"},r),a={},u=function(){try{N(),o(t)&&t(a.currentValue,a.oldValue)}finally{W()}},i=function(){if(-1===b.indexOf(i)){A(i);try{b.push(i),a.currentValue=e()}finally{b.pop()}}};return i._scheduler=function(e){e(),(o(n.equals)?n.equals(a.oldValue,a.currentValue):a.oldValue===a.currentValue)||u(),a.oldValue=a.currentValue},i._name=n.name,i(),a.oldValue=a.currentValue,n.fireImmediately&&u(),function(){T(i)}},e.setDataNode=re,e.toJS=function(e){var t=new WeakSet,r=function(e){if(t.has(e))return e;if(e&&e[ae])return e;if(i(e)){if(ie(e)){t.add(e);var n=[];return e.forEach((function(e){n.push(r(e))})),t.delete(e),n}}else if(c(e)&&ie(e)){t.add(e);var a={};for(var u in e)oe.call(e,u)&&(a[u]=r(e[u]));return t.delete(e),a}return e};return r(e)},e.untracked=xe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("formily.reactive",["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).Formily=e.Formily||{},e.Formily.Reactive={}))}(this,(function(e){"use strict";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var t=Object.prototype.toString,r=function(e){return e&&e instanceof Map},n=function(e){return e&&e instanceof Set},a=function(e){return e&&e instanceof WeakMap},u=function(e){return e&&e instanceof WeakSet},o=function(e){return"function"==typeof e},i=Array.isArray,c=function(e){return"[object Object]"===t.call(e)},l=function(e){return r(e)||a(e)||n(e)||u(e)},f=function(e){return c(e)||i(e)},s=function(e){return Array.isArray(e)?e:null!=e?[e]:[]},v=function(){function e(e){void 0===e&&(e=[]),this.forEachIndex=0,this.value=e}return e.prototype.add=function(e){this.has(e)||this.value.push(e)},e.prototype.has=function(e){return this.value.indexOf(e)>-1},e.prototype.delete=function(e){var t=this.value.length;if(0!==t)if(1!==t||this.value[0]!==e){var r=this.value.indexOf(e);r>-1&&(this.value.splice(r,1),r<=this.forEachIndex&&(this.forEachIndex-=1))}else this.value=[]},e.prototype.forEach=function(e){if(0!==this.value.length)for(this.forEachIndex=0;this.forEachIndex<this.value.length;this.forEachIndex++)e(this.value[this.forEachIndex])},e.prototype.batchDelete=function(e){if(0!==this.value.length)for(this.forEachIndex=0;this.forEachIndex<this.value.length;this.forEachIndex++){var t=this.value[this.forEachIndex];this.value.splice(this.forEachIndex,1),this.forEachIndex--,e(t)}},e.prototype.clear=function(){this.value.length=0},e}(),y=new WeakMap,p=new WeakMap,d=new WeakMap,h=new WeakMap,g=new WeakMap,b=[],m={value:0},k={value:0},O={value:!1},_={value:!1},w=new v,P=new v,S=new v,E=new v,j=Symbol("MakeObModelSymbol"),x=Symbol("ObModelSymbol"),R=Symbol("ObModelNodeSymbol"),V=Symbol("iteration key"),M=function(e,t){var r=g.get(e),n=[];if(r){var a=r.get(t);a&&a.forEach((function(e){-1===n.indexOf(e)&&n.push(e)}))}return n},A=function(e,t){var r=M(e,t),n=k.value;k.value=0;for(var a=0,u=r.length;a<u;a++){var i=r[a];i._isComputed?i._scheduler(i):K()?P.add(i):B()?w.add(i):o(i._scheduler)?i._scheduler(i):i()}k.value=n},D=function(e){var t=e.key,r=e.type,n=e.target;"iterate"===r&&(t=V);var a=b.length;if(0!==a){var u=b[a-1];Y()||u&&(_.value=!0,function(e,t){var r=e._reactionsSet;r?r.add(t):e._reactionsSet=new v([t])}(u,function(e,t,r){var n=g.get(e);if(n){var a=n.get(t);return a?a.add(r):n.set(t,new v([r])),n}var u=new Map([[t,new v([r])]]);return g.set(e,u),u}(n,t,u)))}},I=function(e){var t=e.key,r=e.type,n=e.target,a=e.oldTarget;if(N(),function(e){E.forEach((function(t){return t(e)}))}(e),"clear"===r?a.forEach((function(e,t){A(n,t)})):A(n,t),"add"===r||"delete"===r||"clear"===r){var u=Array.isArray(n)?"length":V;A(n,u)}W()},q=function(e){var t;null===(t=e._reactionsSet)||void 0===t||t.forEach((function(t){t.forEach((function(t){t.delete(e)}))})),w.delete(e),P.delete(e),delete e._reactionsSet},T=function(e){e._disposed=!0,q(e),function(e){var t;null===(t=e._computesSet)||void 0===t||t.forEach((function(e){0===M(e._context,e._property).length&&(T(e),e._dirty=!0)}))}(e)},N=function(){m.value++},W=function(){if(m.value--,0===m.value){var e=k.value;k.value=0,$(),L(),k.value=e}},C=function(){O.value=!0},J=function(){var e=k.value;O.value=!1,k.value=0,P.batchDelete((function(e){o(e._scheduler)?e._scheduler(e):e()})),k.value=e},z=function(){k.value++},F=function(){k.value--},B=function(){return m.value>0},K=function(){return O.value},Y=function(){return k.value>0},$=function(){w.batchDelete((function(e){o(e._scheduler)?e._scheduler(e):e()}))},L=function(){S.batchDelete((function(e){e()}))},G=function(e,t){return e!==t&&(e.length!==t.length||!!e.some((function(e,r){return e!==t[r]})))},H=function(){return H=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},H.apply(this,arguments)};function Q(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,u=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=u.next()).done;)o.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=u.return)&&r.call(u)}finally{if(a)throw a.error}}return o}function U(e,t,r){if(r||2===arguments.length)for(var n,a=0,u=t.length;a<u;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var X,Z=function(){function e(e,t){this.node=t,this.key=e.key,this.type=e.type,this.object=e.target,this.value=e.value,this.oldValue=e.oldValue}return Object.defineProperty(e.prototype,"path",{get:function(){return this.node.path.concat(this.key)},enumerable:!1,configurable:!0}),e}(),ee=function(){function e(e,t,r){this.target=e,this.key=t,this.value=r}return Object.defineProperty(e.prototype,"path",{get:function(){return this.parent?this.parent.path.concat(this.key):this.key?[this.key]:[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetRaw",{get:function(){return fe(this.target)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){if(this.target)return te(this.targetRaw)},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(e){return this.key?e.targetRaw===this.targetRaw&&e.key===this.key:e.value===this.value},e.prototype.contains=function(e){if(e===this)return!0;for(var t=e.parent;t;){if(this.isEqual(t))return!0;t=t.parent}return!1},e}(),te=function(e){return(null==e?void 0:e[R])?e[R]:h.get(e)},re=function(e,t){(null==e?void 0:e[x])?e[R]=t:h.set(e,t)},ne=function(e,t,r){var n=fe(r),a=te(n);if(a)return a;re(n,new ee(e,t,r))},ae=Symbol("RAW_TYPE"),ue=Symbol("OBSERVABLE_TYPE"),oe=Object.prototype.hasOwnProperty,ie=function(e){return y.has(e)||!!(null==e?void 0:e[x])},ce=function(e){return e&&!!e[j]},le=function(e){return null!=e&&(!!i(e)||(c(e)?!e[ae]&&(!!e[ue]||(!("$$typeof"in e)||!("_owner"in e))&&(!e._isAMomentObject&&(!e._isJSONSchemaObject&&(!o(e.toJS)&&!o(e.toJSON))))):!!(r(e)||a(e)||n(e)||u(e))))},fe=function(e){return(null==e?void 0:e[x])?e[x]:y.get(e)||e},se=new Set(Object.getOwnPropertyNames(Symbol).reduce((function(e,t){if("arguments"===t||"caller"===t)return e;var r=Symbol[t];return"symbol"==typeof r?e.concat(r):e}),[])),ve=Object.prototype.hasOwnProperty;function ye(e,t,r){var n=p.get(r);return n||(!ie(r)&&le(r)?ke(e,t,r):r)}function pe(e,t,r,n){var a=r.next;return r.next=function(){var u=a.call(r),o=u.done,i=u.value;return o||(n?i[1]=ye(e,t,i[1]):i=ye(e,t,i)),{done:o,value:i}},r}var de=(X={has:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this);return D({target:t,key:e,type:"has"}),r.has.apply(t,arguments)},get:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this);return D({target:t,key:e,type:"get"}),ye(t,e,r.get.apply(t,arguments))},add:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),a=r.add.apply(t,arguments);return n||I({target:t,key:e,value:e,type:"add"}),a},set:function(e,t){var r=y.get(this),n=Reflect.getPrototypeOf(this),a=n.has.call(r,e),u=n.get.call(r,e),o=n.set.apply(r,arguments);return a?t!==u&&I({target:r,key:e,value:t,oldValue:u,type:"set"}):I({target:r,key:e,value:t,type:"add"}),o},delete:function(e){var t=y.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),a=r.get?r.get.call(t,e):void 0,u=r.delete.apply(t,arguments);return n&&I({target:t,key:e,oldValue:a,type:"delete"}),u},clear:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this),r=0!==e.size,n=e instanceof Map?new Map(e):new Set(e),a=t.clear.apply(e,arguments);return r&&I({target:e,oldTarget:n,type:"clear"}),a},forEach:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var a=y.get(this),u=Reflect.getPrototypeOf(this);D({target:a,type:"iterate"});var o=function(t,r){for(var n=[],u=2;u<arguments.length;u++)n[u-2]=arguments[u];return e.apply(void 0,U([ye(a,r,t),r],Q(n),!1))};return(t=u.forEach).call.apply(t,U([a,o],Q(r),!1))},keys:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);return D({target:e,type:"iterate"}),t.keys.apply(e,arguments)},values:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);D({target:e,type:"iterate"});var r=t.values.apply(e,arguments);return pe(e,"",r,!1)},entries:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);D({target:e,type:"iterate"});var r=t.entries.apply(e,arguments);return pe(e,"",r,!0)}},X[Symbol.iterator]=function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);D({target:e,type:"iterate"});var r=t[Symbol.iterator].apply(e,arguments);return pe(e,"",r,e instanceof Map)},Object.defineProperty(X,"size",{get:function(){var e=y.get(this),t=Reflect.getPrototypeOf(this);return D({target:e,type:"iterate"}),Reflect.get(t,"size",e)},enumerable:!1,configurable:!0}),X),he={get:function(e,t,r){return e=ve.call(de,t)?de:e,Reflect.get(e,t,r)}},ge={get:function(e,t,r){if(t){var n=e[t];if("symbol"==typeof t&&se.has(t))return n;D({target:e,key:t,receiver:r,type:"get"});var a=p.get(n);if(a)return a;if(!ie(n)&&le(n)){var u=Reflect.getOwnPropertyDescriptor(e,t);if(!u||!1!==u.writable||!1!==u.configurable)return ke(e,t,n)}return n}},has:function(e,t){var r=Reflect.has(e,t);return D({target:e,key:t,type:"has"}),r},ownKeys:function(e){var t=Reflect.ownKeys(e);return D({target:e,type:"iterate"}),t},set:function(e,t,r,n){var a=ve.call(e,t),u=ke(e,t,r),o=e[t];return e[t]=u,a?r!==o&&I({target:e,key:t,value:u,oldValue:o,receiver:n,type:"set"}):I({target:e,key:t,value:u,oldValue:o,receiver:n,type:"add"}),!0},deleteProperty:function(e,t){var r=e[t];return delete e[t],I({target:e,key:t,oldValue:r,type:"delete"}),!0}},be=function(e,t){var r=new Proxy(e,ge);return y.set(r,e),t?d.set(e,r):p.set(e,r),r},me=function(e,t){var r=new Proxy(e,he);return y.set(r,e),t?d.set(e,r):p.set(e,r),r},ke=function(e,t,r,n){if("object"!=typeof r)return r;var a=y.get(r);if(a){var u=te(a);return u.target||(u.target=e),u.key=t,r}if(!le(r))return r;if(e){var o=y.get(e)||e;if(d.get(o))return r}return ne(e,t,r),n?function(e){return f(e)?be(e,!0):l(e)?me(e,!0):e}(r):f(r)?be(r):l(r)?me(r):r},Oe=function(e){var t=function(t){return e({value:t})};return o(e)&&(t[j]=e),t},_e=function(e){if(e[j])return e[j][j]?_e(e[j]):e[j]},we=function(e,t){function r(r){var n;try{e(),o(r)&&(n=r())}finally{t()}return n}return r.bound=Pe(r),r},Pe=function(e){return function(t,r){return function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];return e((function(){return t.apply(r,n)}))}}},Se=function(e,t){var r=we(e,t),n=Oe((function(e){var t=e.target,n=e.key;return t[n]=r.bound(t[n],t),t}));return r[j]=n,r.bound[j]=n,r},Ee=Se(N,W);Ee.scope=Se(C,J),Ee.endpoint=function(e){o(e)&&(0===m.value?e():S.add(e))};var je=Se((function(){N(),z()}),(function(){F(),W()}));je.scope=Se((function(){C(),z()}),(function(){F(),J()}));var xe=we(z,F),Re=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:ke(t,r,t?t[r]:n)};return t?(Object.defineProperty(t,r,{set:function(e){var n=a.value;e=ke(t,r,e),a.value=e,n!==e&&I({target:t,key:r,type:"set",oldValue:n,value:e})},get:function(){return D({target:t,key:r,type:"get"}),a.value},enumerable:!0,configurable:!1}),t):a.value})),Ve=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:t?t[r]:n},u={set:function(e){var t=a.value;a.value=e,t!==e&&I({target:a,key:r,type:"set",oldValue:t,value:e})},get:function(){return D({target:a,key:r,type:"get"}),a.value}};return y.set(u,a),p.set(a,u),ne(t,r,a),t?(Object.defineProperty(t,r,{value:u,enumerable:!0,configurable:!1,writable:!1}),t):u})),Me=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:t?t[r]:n},u={},o=t||a,i=t?r:"value";function c(){return D({target:o,key:i,type:"get"}),a.value}function l(e){var t=a.value;a.value=e,t!==e&&I({target:o,key:i,type:"set",oldValue:t,value:e})}return t?(Object.defineProperty(t,r,{get:c,set:l,enumerable:!0}),t):(Object.defineProperty(u,"value",{set:l,get:c}),ne(t,r,a),u[x]=a,u)})),Ae=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={value:ke(t,r,t?t[r]:n,!0)};return t?(Object.defineProperty(t,r,{set:function(e){var n=a.value;e=ke(t,r,e,!0),a.value=e,n!==e&&I({target:t,key:r,type:"set",oldValue:n,value:e})},get:function(){return D({target:t,key:r,type:"get"}),a.value},enumerable:!0,configurable:!1}),t):a.value})),De=Object.getOwnPropertyDescriptor,Ie=Object.getPrototypeOf,qe=Symbol("ClassDescriptorSymbol");function Te(e,t){if(e)return De(e,t)||Te(Ie(e),t)}function Ne(e,t,r){if(!e)return r?o(r)?{get:r}:r:{};var n=function(e,t){var r=e.constructor;if(r===Object||r===Array)return Te(e,t);var n=r[qe]||{},a=n[t];if(a)return a;var u=Te(e,t);return r[qe]=n,n[t]=u,u}(e,t);return n||{}}var We=Oe((function(e){var t=e.target,r=e.key,n=e.value,a={},u={},i=t||a,c=t?r:"value",l=Ne(t,c,n);function f(){var e;a.value=null===(e=l.get)||void 0===e?void 0:e.call(i)}function s(){if(-1===b.indexOf(s)){q(s);try{b.push(s),f()}finally{b.pop()}}}function y(){return b.length>0&&function(e){if(o(e)){var t=b[b.length-1];if(t){var r=t._computesSet;r?r.add(e):t._computesSet=new v([e])}}}(s),Y()?f():s._dirty&&(s(),s._dirty=!1),D({target:i,key:c,type:"get"}),a.value}function p(e){var t;try{N(),null===(t=l.set)||void 0===t||t.call(i,e)}finally{W()}}return s._name="ComputedReaction",s._scheduler=function(){s._dirty=!0,I({target:i,key:c,value:a.value,type:"set"})},s._isComputed=!0,s._dirty=!0,s._context=i,s._property=c,t?(Object.defineProperty(t,r,{get:y,set:p,enumerable:!0}),t):(Object.defineProperty(u,"value",{set:p,get:y}),ne(t,r,a),u[x]=a,u)}));function Ce(e){return ke(null,null,e)}function Je(e,t){if(ie(e))return e;if(!le(e))return e;for(var r in e[x]=e,ne(void 0,void 0,e),t){var n=t[r];ce(n)&&_e(n)({target:e,key:r})}return e}Ce.box=Ve,Ce.ref=Me,Ce.deep=Re,Ce.shallow=Ae,Ce.computed=We,Ce[j]=Re;var ze=function(e,t){void 0===t&&(t="AutoRun");var r=function(){if(o(e)&&!(r._boundary>0)&&-1===b.indexOf(r)){q(r);try{N(),b.push(r),e()}finally{b.pop(),r._boundary++,W(),r._boundary=0,r._memos.cursor=0,r._effects.cursor=0}}},n=function(){r._memos={queue:[],cursor:0},r._effects={queue:[],cursor:0}};return r._boundary=0,r._name=t,n(),r(),function(){T(r),function(e){if(e._effects)try{N(),e._effects.queue.forEach((function(e){e&&e.dispose&&e.dispose()}))}finally{W()}}(r),n()}};ze.memo=function(e,t){if(o(e)){var r=b[b.length-1];if(!r||!r._memos)throw new Error("autorun.memo must used in autorun function body.");var n=s(t||[]),a=r._memos.cursor++,u=r._memos.queue[a];if(!u||G(n,u.deps)){var i=e();return r._memos.queue[a]={value:i,deps:n},i}return u.value}},ze.effect=function(e,t){if(o(e)){var r=b[b.length-1];if(!r||!r._effects)throw new Error("autorun.effect must used in autorun function body.");var n=r._effects,a=s(t||[{}]),u=n.cursor++,i=n.queue[u];i&&!G(a,i.deps)||(Promise.resolve(0).then((function(){if(!r._disposed){var t=e();o(t)&&(n.queue[u].dispose=t)}})),n.queue[u]={deps:a})}};var Fe=function(e,t){void 0===t&&(t="TrackerReaction");var r=this;this.track=function(e){if(!o(e))return r.results;if(!(r.track._boundary>0)){if(-1===b.indexOf(r.track)){q(r.track);try{N(),b.push(r.track),r.results=e()}finally{b.pop(),r.track._boundary++,W(),r.track._boundary=0}}return r.results}},this.dispose=function(){T(r.track)},this.track._scheduler=function(t){0===r.track._boundary&&r.dispose(),o(t)&&e(t)},this.track._name=t,this.track._boundary=0};e.DataChange=Z,e.DataNode=ee,e.Tracker=Fe,e.action=je,e.autorun=ze,e.batch=Ee,e.buildDataTree=ne,e.contains=function(e,t){var r=fe(e),n=fe(t);if(r===n)return!0;var a=te(r),u=te(n);return!!a&&(!!u&&a.contains(u))},e.define=Je,e.getDataNode=te,e.hasCollected=function(e){return _.value=!1,null==e||e(),_.value},e.isAnnotation=ce,e.isObservable=ie,e.isSupportObservable=le,e.markObservable=function(e){if(e)return o(e)?e.prototype[ue]=!0:e[ue]=!0,e},e.markRaw=function(e){if(e)return o(e)?e.prototype[ae]=!0:e[ae]=!0,e},e.model=function(e){var t=Object.keys(e||{}).reduce((function(t,r){var n=Object.getOwnPropertyDescriptor(e,r);return n&&n.get?t[r]=Ce.computed:o(e[r])?t[r]=je:t[r]=Ce,t}),{});return Je(e,t)},e.observable=Ce,e.observe=function(e,t,r){void 0===r&&(r=!0);if(e&&"object"!=typeof e)throw Error("Can not observe ".concat(typeof e," type."));return function(e){var n=fe(e),a=te(n),u=function(e){var n=fe(e.target),u=te(n);(r&&a.contains(u)||a===u||a.targetRaw===n&&a.key===e.key)&&t(new Z(e,u))};return a&&o(t)&&E.add(u),function(){E.delete(u)}}(e)},e.raw=fe,e.reaction=function(e,t,r){var n=H({name:"Reaction"},r),a={},u=function(){try{N(),o(t)&&t(a.currentValue,a.oldValue)}finally{W()}},i=function(){if(-1===b.indexOf(i)){q(i);try{b.push(i),a.currentValue=e()}finally{b.pop()}}};return i._scheduler=function(e){e(),(o(n.equals)?n.equals(a.oldValue,a.currentValue):a.oldValue===a.currentValue)||u(),a.oldValue=a.currentValue},i._name=n.name,i(),a.oldValue=a.currentValue,n.fireImmediately&&u(),function(){T(i)}},e.setDataNode=re,e.toJS=function(e){var t=new WeakSet,r=function(e){if(t.has(e))return e;if(e&&e[ae])return e;if(i(e)){if(ie(e)){t.add(e);var n=[];return e.forEach((function(e){n.push(r(e))})),t.delete(e),n}}else if(c(e)&&ie(e)){t.add(e);var a={};for(var u in e)oe.call(e,u)&&(a[u]=r(e[u]));return t.delete(e),a}return e};return r(e)},e.untracked=xe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=formily.reactive.umd.production.js.map |
{ | ||
"name": "@formily/reactive", | ||
"version": "2.2.29", | ||
"version": "2.2.30", | ||
"license": "MIT", | ||
@@ -42,3 +42,3 @@ "main": "lib", | ||
}, | ||
"gitHead": "5a126e2c7fe1fc4e6c9e3e138b5dbaae379041b6" | ||
"gitHead": "83b7473b4736b1eec4df678a6e084d3e620427d2" | ||
} |
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
610385
6319