index.js 8.8 KB

1
  1. var M=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var G=M(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0}),D.parseMultiDataPaths=D.getDataOnPath=void 0;var N=/^\s/,C=function(e,t){throw new Error('Parsing data path "'+e+'" failed at char "'+e[t]+'" (index '+t+")")},re=function(e,t){for(var r=t.index;t.index<t.length;){var a=e[t.index];if(/^[0-9]/.test(a)){t.index++;continue}break}return r===t.index&&C(e,t.index),parseInt(e.slice(r,t.index),10)},z=function(e,t){var r=t.index,a=e[r];if(/^[_a-zA-Z$]/.test(a))for(t.index++;t.index<t.length;){var f=e[t.index];if(/^[_a-zA-Z0-9$]/.test(f)){t.index++;continue}break}else C(e,t.index);return e.slice(r,t.index)},$=function(e,t){for(var r=[z(e,t)],a={deepCmp:!1};t.index<t.length;){var f=e[t.index];if(f==="[")t.index++,r.push("".concat(re(e,t))),e[t.index]!=="]"&&C(e,t.index),t.index++;else if(f==="."){if(t.index++,e[t.index]==="*"){if(t.index++,e[t.index]==="*"){t.index++,a.deepCmp=!0;break}C(e,t.index)}r.push(z(e,t))}else break}return{path:r,options:a}},ne=function(e,t){for(;N.test(e[t.index]);)t.index++;for(var r=[$(e,t)],a=!1;t.index<t.length;){var f=e[t.index];N.test(f)?t.index++:f===","?(a=!0,t.index++):a?(a=!1,r.push($(e,t))):C(e,t.index)}return r},oe=function(e,t){t.index<t.length&&C(e,t.index)},ie=function(e){var t={length:e.length,index:0},r=ne(e,t);return oe(e,t),r};D.parseMultiDataPaths=ie;var ae=function(e,t){var r=e;return t.forEach(function(a){r=typeof r!="object"||r===null?void 0:r[a]}),r};D.getDataOnPath=ae});var U=M((we,S)=>{S.exports=function(){let t=null,r;function a(n){return n?typeof n=="object"||typeof n=="function":!1}function f(n){if(n!==null&&!a(n))throw new TypeError("Object prototype may only be an Object or null: "+n)}let o=Object,l=Boolean(o.create)||!({__proto__:null}instanceof o),c=o.create||(l?function(i){return f(i),{__proto__:i}}:function(i){if(f(i),i===null)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var v=function(){};return v.prototype=i,new v}),h=function(){return null},_=o.getPrototypeOf||([].__proto__===Array.prototype?function(i){let v=i.__proto__;return a(v)?v:null}:h);return r=function(n,i){if((this&&this instanceof r?this.constructor:void 0)===void 0)throw new TypeError("Constructor Proxy requires 'new'");if(!a(n)||!a(i))throw new TypeError("Cannot create proxy with a non-object as target or handler");let y=function(){};t=function(){n=null,y=function(u){throw new TypeError(`Cannot perform '${u}' on a proxy that has been revoked`)}},setTimeout(function(){t=null},0);let d=i;i={get:null,set:null,apply:null,construct:null};for(let u in d){if(!(u in i))throw new TypeError(`Proxy polyfill does not support trap '${u}'`);i[u]=d[u]}typeof d=="function"&&(i.apply=d.apply.bind(d));let p=_(n),s,x=!1,j=!1;typeof n=="function"?(s=function(){let b=this&&this.constructor===s,P=Array.prototype.slice.call(arguments);if(y(b?"construct":"apply"),b&&i.construct)return i.construct.call(this,n,P);if(!b&&i.apply)return i.apply(n,this,P);if(b){P.unshift(n);let E=n.bind.apply(n,P);return new E}return n.apply(this,P)},x=!0):n instanceof Array?(s=[],j=!0):s=l||p!==null?c(p):{};let m=i.get?function(u){return y("get"),i.get(this,u,s)}:function(u){return y("get"),this[u]},F=i.set?function(u,b){y("set");let P=i.set(this,u,b,s)}:function(u,b){y("set"),this[u]=b},H=o.getOwnPropertyNames(n),T={};H.forEach(function(u){if((x||j)&&u in s)return;let b=o.getOwnPropertyDescriptor(n,u),P={enumerable:Boolean(b.enumerable),get:m.bind(n,u),set:F.bind(n,u)};o.defineProperty(s,u,P),T[u]=!0});let A=!0;if(x||j){let u=o.setPrototypeOf||([].__proto__===Array.prototype?function(P,E){return f(E),P.__proto__=E,P}:h);p&&u(s,p)||(A=!1)}if(i.get||!A)for(let u in n)T[u]||o.defineProperty(s,u,{get:m.bind(n,u)});return o.seal(n),o.seal(s),s},r.revocable=function(n,i){return{proxy:new r(n,i),revoke:t}},r}});var K=M(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0}),I.create=fe,I.unwrap=V;var ue=ce(U());function ce(e){return e&&e.__esModule?e:{default:e}}var se=ue.default(),X=function(e,t,r){if(typeof e!="object"||e===null)return e;var a={get:function(f,o){if(o==="__rawObject__")return f;var l=r.concat(o),c=f[o];return t.push({path:l,value:c}),X(c,t,l)}};try{return new Proxy(e,a)}catch(f){return new se(e,a)}};function fe(e,t){return X(e,t,[])}function V(e){if(e!==null&&typeof e=="object"&&typeof e.__rawObject__!="object"){if(Array.isArray(e))return e.map(function(r){return V(r)});var t={};return Object.keys(e).forEach(function(r){t[r]=V(e[r])}),t}return typeof e!="object"||e===null||typeof e.__rawObject__!="object"?e:e.__rawObject__}});var ee=M(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0}),R.behavior=void 0;var W,Y,g,pe=L(require("rfdc")),le=L(require("fast-deep-equal")),w=Z(G()),k=Z(K());function J(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function L(e){return e&&e.__esModule?e:{default:e}}function Z(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var a=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};a.get||a.set?Object.defineProperty(t,r,a):t[r]=e[r]}}return t.default=e,t}var Q=pe.default({proto:!0});(W=g||(g={}))[W.CREATED=0]="CREATED",W[W.ATTACHED=1]="ATTACHED";var de=0,he=Behavior({lifetimes:{attached:function(){this.setData({_computedWatchInit:g.ATTACHED})},created:function(){this.setData({_computedWatchInit:g.CREATED})}},definitionFilter:function(e){var t=e.computed,r=e.watch,a=[],f=de++;a.push({fields:"_computedWatchInit",observer:function(){var o=this.data._computedWatchInit;if(o===g.CREATED){var l={computedUpdaters:[],computedRelatedPathValues:{},watchCurVal:{},_triggerFromComputedAttached:{}};this._computedWatchInfo||(this._computedWatchInfo={}),this._computedWatchInfo[f]=l,r&&Object.keys(r).forEach(function(h){var _=w.parseMultiDataPaths(h).map(function(n){var i=n.path,v=n.options,y=w.getDataOnPath(this.data,i);return v.deepCmp?Q(y):y}.bind(this));l.watchCurVal[h]=_}.bind(this))}else if(o===g.ATTACHED){var c=this._computedWatchInfo[f];t&&Object.keys(t).forEach(function(h){var _=t[h],n=[],i=_(k.create(this.data,n)),v=n.map(function(d){var p=d.path;return{path:p,value:w.getDataOnPath(this.data,p)}}.bind(this));this.setData(J({},h,k.unwrap(i))),c._triggerFromComputedAttached[h]=!0,c.computedRelatedPathValues[h]=v;var y=function(){for(var d=c.computedRelatedPathValues[h],p=!1,s=0;s<d.length;s++){var x=d[s],j=x.path;if(x.value!==w.getDataOnPath(this.data,j)){p=!0;break}}if(!p)return!1;var m=[],F=_(k.create(this.data,m));this.setData(J({},h,k.unwrap(F)));var H=m.map(function(T){var A=T.path;return{path:A,value:w.getDataOnPath(this.data,A)}}.bind(this));return c.computedRelatedPathValues[h]=H,!0}.bind(this);c.computedUpdaters.push(y)}.bind(this))}}}),t&&a.push({fields:"**",observer:function(){if(this._computedWatchInfo){var o,l=this._computedWatchInfo[f];if(l)do o=l.computedUpdaters.some(function(c){return c.call(this)}.bind(this));while(o)}}}),r&&Object.keys(r).forEach(function(o){var l=w.parseMultiDataPaths(o);a.push({fields:o,observer:function(){if(this._computedWatchInfo){var c=this._computedWatchInfo[f];if(c){if(Object.keys(c._triggerFromComputedAttached).length){var h={};for(var _ in l.forEach(function(p){return h[p.path[0]]=!0}),c._triggerFromComputedAttached)if(c._triggerFromComputedAttached.hasOwnProperty(_)&&h[_]&&c._triggerFromComputedAttached[_])return void(c._triggerFromComputedAttached[_]=!1)}var n=c.watchCurVal[o],i=l.map(function(p){var s=p.path,x=p.options;return{val:w.getDataOnPath(this.data,s),options:x}}.bind(this)),v=i.map(function(p){var s=p.val;return p.options.deepCmp?Q(s):s});c.watchCurVal[o]=v;for(var y=!1,d=0;d<v.length;d++)if(l[d].options.deepCmp?!le.default(n[d],v[d]):n[d]!==v[d]){y=!0;break}y&&r[o].apply(this,i.map(function(p){return p.val}))}}}})}),typeof e.observers!="object"&&(e.observers={}),Array.isArray(e.observers)?(Y=e.observers).push.apply(Y,a):a.forEach(function(o){var l=e.observers[o.fields];l?e.observers[o.fields]=function(){o.observer.call(this),l.call(this)}:e.observers[o.fields]=o.observer})}});R.behavior=he});"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"behavior",{enumerable:!0,get:function(){return B.behavior}}),exports.ComponentWithComputed=ve,exports.BehaviorWithComputed=ye,exports.DataTracerMode=exports.setCurrentDataTracerMode=exports.getCurrentDataTracerMode=void 0;var O,q,B=ee();function ve(e){return Array.isArray(e.behaviors)||(e.behaviors=[]),e.behaviors.unshift(B.behavior),Component(e)}function ye(e){return Array.isArray(e.behaviors)||(e.behaviors=[]),e.behaviors.unshift(B.behavior),Behavior(e)}exports.DataTracerMode=q,(O=q||(exports.DataTracerMode=q={}))[O.Auto=0]="Auto",O[O.Proxy=1]="Proxy",O[O.DefineProperty=2]="DefineProperty";var te=q.Auto,_e=function(){return te};exports.getCurrentDataTracerMode=_e;var be=function(e){te=e};exports.setCurrentDataTracerMode=be;