UNPKG

apprun

Version:

JavaScript library that has Elm inspired architecture, event pub-sub and components

2 lines 8.15 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apprun=t():e.apprun=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createState:()=>q});var r=Symbol.for("immer-nothing"),n=Symbol.for("immer-draftable"),o=Symbol.for("immer-state");function i(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var c=Object.getPrototypeOf;function a(e){return!!e&&!!e[o]}function s(e){return!!e&&(f(e)||Array.isArray(e)||!!e[n]||!!e.constructor?.[n]||d(e)||h(e))}var u=Object.prototype.constructor.toString();function f(e){if(!e||"object"!=typeof e)return!1;const t=c(e);if(null===t)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===u}function l(e,t){0===p(e)?Reflect.ownKeys(e).forEach((r=>{t(r,e[r],e)})):e.forEach(((r,n)=>t(n,r,e)))}function p(e){const t=e[o];return t?t.type_:Array.isArray(e)?1:d(e)?2:h(e)?3:0}function _(e,t){return 2===p(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function y(e,t,r){const n=p(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function d(e){return e instanceof Map}function h(e){return e instanceof Set}function b(e){return e.copy_||e.base_}function m(e,t){if(d(e))return new Map(e);if(h(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=f(e);if(!0===t||"class_only"===t&&!r){const t=Object.getOwnPropertyDescriptors(e);delete t[o];let r=Reflect.ownKeys(t);for(let n=0;n<r.length;n++){const o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(c(e),t)}{const t=c(e);if(null!==t&&r)return{...e};const n=Object.create(t);return Object.assign(n,e)}}function v(e,t=!1){return P(e)||a(e)||!s(e)||(p(e)>1&&(e.set=e.add=e.clear=e.delete=g),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>v(t,!0)))),e}function g(){i(2)}function P(e){return Object.isFrozen(e)}var S,w={};function O(e){const t=w[e];return t||i(0),t}function z(){return S}function j(e,t){t&&(O("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function F(e){A(e),e.drafts_.forEach(M),e.drafts_=null}function A(e){e===S&&(S=e.parent_)}function D(e){return S={drafts_:[],parent_:S,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function M(e){const t=e[o];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function C(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[o].modified_&&(F(t),i(4)),s(e)&&(e=x(t,e),t.parent_||k(t,e)),t.patches_&&O("Patches").generateReplacementPatches_(n[o].base_,e,t.patches_,t.inversePatches_)):e=x(t,n,[]),F(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==r?e:void 0}function x(e,t,r){if(P(t))return t;const n=t[o];if(!n)return l(t,((o,i)=>E(e,n,t,o,i,r))),t;if(n.scope_!==e)return t;if(!n.modified_)return k(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let o=t,i=!1;3===n.type_&&(o=new Set(t),t.clear(),i=!0),l(o,((o,c)=>E(e,n,t,o,c,r,i))),k(e,t,!1),r&&e.patches_&&O("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function E(e,t,r,n,o,i,c){if(a(o)){const c=x(e,o,i&&t&&3!==t.type_&&!_(t.assigned_,n)?i.concat(n):void 0);if(y(r,n,c),!a(c))return;e.canAutoFreeze_=!1}else c&&r.add(o);if(s(o)&&!P(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;x(e,o),t&&t.scope_.parent_||"symbol"==typeof n||!Object.prototype.propertyIsEnumerable.call(r,n)||k(e,o)}}function k(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&v(t,r)}var N={get(e,t){if(t===o)return e;const r=b(e);if(!_(r,t))return function(e,t,r){const n=W(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}(e,r,t);const n=r[t];return e.finalized_||!s(n)?n:n===K(e.base_,t)?(I(e),e.copy_[t]=L(n,e)):n},has:(e,t)=>t in b(e),ownKeys:e=>Reflect.ownKeys(b(e)),set(e,t,r){const n=W(b(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const n=K(b(e),t),a=n?.[o];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(((i=r)===(c=n)?0!==i||1/i==1/c:i!=i&&c!=c)&&(void 0!==r||_(e.base_,t)))return!0;I(e),U(e)}var i,c;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:(e,t)=>(void 0!==K(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,I(e),U(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const r=b(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty(){i(11)},getPrototypeOf:e=>c(e.base_),setPrototypeOf(){i(12)}},R={};function K(e,t){const r=e[o];return(r?b(r):e)[t]}function W(e,t){if(!(t in e))return;let r=c(e);for(;r;){const e=Object.getOwnPropertyDescriptor(r,t);if(e)return e;r=c(r)}}function U(e){e.modified_||(e.modified_=!0,e.parent_&&U(e.parent_))}function I(e){e.copy_||(e.copy_=m(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function L(e,t){const r=d(e)?O("MapSet").proxyMap_(e,t):h(e)?O("MapSet").proxySet_(e,t):function(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:z(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,i=N;r&&(o=[n],i=R);const{revoke:c,proxy:a}=Proxy.revocable(o,i);return n.draft_=a,n.revoke_=c,a}(e,t);return(t?t.scope_:z()).drafts_.push(r),r}function T(e){if(!s(e)||P(e))return e;const t=e[o];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=m(e,t.scope_.immer_.useStrictShallowCopy_)}else r=m(e,!0);return l(r,((e,t)=>{y(r,e,T(t))})),t&&(t.finalized_=!1),r}l(N,((e,t)=>{R[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),R.deleteProperty=function(e,t){return R.set.call(this,e,t,void 0)},R.set=function(e,t,r){return N.set.call(this,e[0],t,r,e[0])};var X=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const r=t;t=e;const n=this;return function(e=r,...o){return n.produce(e,(e=>t.call(this,e,...o)))}}let o;if("function"!=typeof t&&i(6),void 0!==n&&"function"!=typeof n&&i(7),s(e)){const r=D(this),i=L(e,void 0);let c=!0;try{o=t(i),c=!1}finally{c?F(r):A(r)}return j(r,n),C(o,r)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===r&&(o=void 0),this.autoFreeze_&&v(o,!0),n){const t=[],r=[];O("Patches").generateReplacementPatches_(e,o,t,r),n(t,r)}return o}i(1)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...r)=>this.produceWithPatches(t,(t=>e(t,...r)));let r,n;return[this.produce(e,t,((e,t)=>{r=e,n=t})),r,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){var t;s(e)||i(8),a(e)&&(a(t=e)||i(10),e=T(t));const r=D(this),n=L(e,void 0);return n[o].isManual_=!0,A(r),n}finishDraft(e,t){const r=e&&e[o];r&&r.isManual_||i(9);const{scope_:n}=r;return j(n,t),C(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));const n=O("Patches").applyPatches_;return a(e)?n(e,t):this.produce(e,(e=>n(e,t)))}},$=X.produce;function q(e){return(t,...r)=>$(t,(t=>{e(t,...r)}))}return X.produceWithPatches.bind(X),X.setAutoFreeze.bind(X),X.setUseStrictShallowCopy.bind(X),X.applyPatches.bind(X),X.createDraft.bind(X),X.finishDraft.bind(X),t})())); //# sourceMappingURL=createState.js.map