UNPKG

alias-fields

Version:

Node module alias-fields (:construction: Under construction, usage is not recommended!)

14 lines 16.3 kB
/*! *** alias-fields 1.0.0 *** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT *** See https://github.com/Jaid/alias-fields !*/ !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=2)}([function(e,r,t){ /*! *** magina 1.1.0 *** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT *** See https://github.com/Jaid/magina !*/ e.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,r,t){t.r(r),t.d(r,"ensureArray",function(){return a}),t.d(r,"ensureObject",function(){return u}),t.d(r,"unpackObject",function(){return f});var n=t(0),o=t.n(n);const i=e=>!Array.isArray(e)&&o()(e),a=e=>void 0===e?[]:Array.isArray(e)?e:[e],u=(e,r)=>void 0===e?{}:i(e)?e:{[r]:e},f=(e,r)=>i(e)?e[r]:e}])},function(e,r,t){(function(e){var t,n="undefined"!=typeof Symbol?Symbol("immer-nothing"):((t={})["immer-nothing"]=!0,t),o="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-draftable"):"__$immer_draftable",i="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-state"):"__$immer_state";function a(e){return!!e&&!!e[i]}function u(e){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e))return!0;var r=Object.getPrototypeOf(e);return!r||r===Object.prototype||!!e[o]||!!e.constructor[o]}var f=Object.assign||function(e,r){for(var t in r)d(r,t)&&(e[t]=r[t]);return e},c="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function s(e,r){if(void 0===r&&(r=!1),Array.isArray(e))return e.slice();var t=Object.create(Object.getPrototypeOf(e));return c(e).forEach(function(n){if(n!==i){var o=Object.getOwnPropertyDescriptor(e,n),a=o.value;if(o.get){if(!r)throw new Error("Immer drafts cannot have computed properties");a=o.get.call(e)}o.enumerable?t[n]=a:Object.defineProperty(t,n,{value:a,writable:!0,configurable:!0})}}),t}function l(e,r){if(Array.isArray(e))for(var t=0;t<e.length;t++)r(t,e[t],e);else c(e).forEach(function(t){return r(t,e[t],e)})}function p(e,r){var t=Object.getOwnPropertyDescriptor(e,r);return!!t&&t.enumerable}function d(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function h(e,r){return e===r?0!==e||1/e==1/r:e!=e&&r!=r}var y=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function v(e){e[i].revoke()}y.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},y.prototype.revoke=function(){this.leave(),this.drafts.forEach(v),this.drafts=null},y.prototype.leave=function(){this===y.current&&(y.current=this.parent)},y.current=null,y.enter=function(){return this.current=new y(this.current)};var b={};function m(){this.revoked=!0}function g(e){return e.copy||e.base}function w(e,r){var t=e[i];if(t&&!t.finalizing){t.finalizing=!0;var n=e[r];return t.finalizing=!1,n}return e[r]}function O(e){e.modified||(e.modified=!0,e.parent&&O(e.parent))}function P(e){e.copy||(e.copy=j(e.base))}function j(e){var r=e&&e[i];if(r){r.finalizing=!0;var t=s(r.draft,!0);return r.finalizing=!1,t}return s(e)}function A(e){if(!0===e.revoked)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(g(e)))}function z(e){for(var r=e.length-1;r>=0;r--){var t=e[r][i];t.modified||(Array.isArray(t.base)?T(t)&&O(t):x(t)&&O(t))}}function x(e){for(var r=e.base,t=e.draft,n=Object.keys(t),o=n.length-1;o>=0;o--){var a=n[o],u=r[a];if(void 0===u&&!d(r,a))return!0;var f=t[a],c=f&&f[i];if(c?c.base!==u:!h(f,u))return!0}return n.length!==Object.keys(r).length}function T(e){var r=e.draft;if(r.length!==e.base.length)return!0;var t=Object.getOwnPropertyDescriptor(r,r.length-1);return!(!t||t.get)}var E=Object.freeze({willFinalize:function(e,r,t){e.drafts.forEach(function(e){e[i].finalizing=!0}),t?a(r)&&r[i].scope===e&&z(e.drafts):(e.patches&&function e(r){if(r&&"object"==typeof r){var t=r[i];if(t){var n=t.base,o=t.draft,a=t.assigned;if(Array.isArray(r)){if(T(t)){if(O(t),a.length=!0,o.length<n.length)for(var u=o.length;u<n.length;u++)a[u]=!1;else for(var f=n.length;f<o.length;f++)a[f]=!0;for(var c=0;c<o.length;c++)void 0===a[c]&&e(o[c])}}else Object.keys(o).forEach(function(r){void 0!==n[r]||d(n,r)?a[r]||e(o[r]):(a[r]=!0,O(t))}),Object.keys(n).forEach(function(e){void 0!==o[e]||d(o,e)||(a[e]=!1,O(t))})}}}(e.drafts[0]),z(e.drafts))},createProxy:function e(r,t){var n=Array.isArray(r),o=j(r);l(o,function(t){!function(r,t,n){var o=b[t];o?o.enumerable=n:b[t]=o={configurable:!0,enumerable:n,get:function(){return function(r,t){A(r);var n=w(g(r),t);return r.finalizing?n:n===w(r.base,t)&&u(n)?(P(r),r.copy[t]=e(n,r)):n}(this[i],t)},set:function(e){!function(e,r,t){if(A(e),e.assigned[r]=!0,!e.modified){if(h(t,w(g(e),r)))return;O(e),P(e)}e.copy[r]=t}(this[i],t,e)}},Object.defineProperty(r,t,o)}(o,t,n||p(r,t))});var a,f,c,s=t?t.scope:y.current;return a=o,f=i,c={scope:s,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:t,base:r,draft:o,copy:null,revoke:m,revoked:!1},Object.defineProperty(a,f,{value:c,enumerable:!1,writable:!0}),s.drafts.push(o),o}});function k(e,r){var t=r?r.scope:y.current,n={scope:t,modified:!1,finalized:!1,assigned:{},parent:r,base:e,draft:null,drafts:{},copy:null,revoke:null},o=Array.isArray(e)?Proxy.revocable([n],D):Proxy.revocable(n,S),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,t.drafts.push(a),a}var S={get:function(e,r){if(r===i)return e;var t=e.drafts;if(!e.modified&&d(t,r))return t[r];var n=_(e)[r];if(e.finalized||!u(n))return n;if(e.modified){if(n!==F(e.base,r))return n;t=e.copy}return t[r]=k(n,e)},has:function(e,r){return r in _(e)},ownKeys:function(e){return Reflect.ownKeys(_(e))},set:function(e,r,t){if(!e.modified){var n=F(e.base,r);if(t?h(n,t)||t===e.drafts[r]:h(n,t)&&r in e.base)return!0;M(e)}return e.assigned[r]=!0,e.copy[r]=t,!0},deleteProperty:function(e,r){return(void 0!==F(e.base,r)||r in e.base)&&(e.assigned[r]=!1,M(e)),e.copy&&delete e.copy[r],!0},getOwnPropertyDescriptor:function(e,r){var t=_(e),n=Reflect.getOwnPropertyDescriptor(t,r);return n&&(n.writable=!0,n.configurable=!Array.isArray(t)||"length"!==r),n},defineProperty:function(){throw new Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},D={};function _(e){return e.copy||e.base}function F(e,r){var t=e[i],n=Reflect.getOwnPropertyDescriptor(t?_(t):e,r);return n&&n.value}function M(e){e.modified||(e.modified=!0,e.copy=f(s(e.base),e.drafts),e.drafts=null,e.parent&&M(e.parent))}l(S,function(e,r){D[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),D.deleteProperty=function(e,r){if(isNaN(parseInt(r)))throw new Error("Immer only supports deleting array indices");return S.deleteProperty.call(this,e[0],r)},D.set=function(e,r,t){if("length"!==r&&isNaN(parseInt(r)))throw new Error("Immer only supports setting array indices and the 'length' property");return S.set.call(this,e[0],r,t)};var R=Object.freeze({willFinalize:function(){},createProxy:k});function I(e,r){for(var t=0;t<r.length;t++){var n=r[t],o=n.path;if(0===o.length&&"replace"===n.op)e=n.value;else{for(var i=e,a=0;a<o.length-1;a++)if(!(i=i[o[a]])||"object"!=typeof i)throw new Error("Cannot apply patch, path doesn't resolve: "+o.join("/"));var u=o[o.length-1];switch(n.op){case"replace":i[u]=n.value;break;case"add":Array.isArray(i)?i.splice(u,0,n.value):i[u]=n.value;break;case"remove":Array.isArray(i)?i.splice(u,1):delete i[u];break;default:throw new Error("Unsupported patch operation: "+n.op)}}}return e}var L={useProxies:"undefined"!=typeof Proxy&&"undefined"!=typeof Reflect,autoFreeze:void 0===e&&"verifyMinified"===function(){}.name,onAssign:null,onDelete:null,onCopy:null},N=function(e){f(this,L,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};N.prototype.produce=function(e,r,t){var o,i=this;if("function"==typeof e&&"function"!=typeof r){var a=r;r=e;var f=this;return function(e){var t=this;void 0===e&&(e=a);for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return f.produce(e,function(e){return r.call.apply(r,[t,e].concat(n))})}}if("function"!=typeof r)throw new Error("The first or second argument to `produce` must be a function");if(void 0!==t&&"function"!=typeof t)throw new Error("The third argument to `produce` must be a function or undefined");if(u(e)){var c=y.enter(),s=this.createProxy(e),l=!0;try{o=r(s),l=!1}finally{l?c.revoke():c.leave()}return o instanceof Promise?o.then(function(e){return c.usePatches(t),i.processResult(e,c)},function(e){throw c.revoke(),e}):(c.usePatches(t),this.processResult(o,c))}return void 0===(o=r(e))?e:o!==n?o:void 0},N.prototype.createDraft=function(e){if(!u(e))throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var r=y.enter(),t=this.createProxy(e);return t[i].isManual=!0,r.leave(),t},N.prototype.finishDraft=function(e,r){var t=e&&e[i];if(!t||!t.isManual)throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(t.finalized)throw new Error("The given draft is already finalized");var n=t.scope;return n.usePatches(r),this.processResult(void 0,n)},N.prototype.setAutoFreeze=function(e){this.autoFreeze=e},N.prototype.setUseProxies=function(e){this.useProxies=e,f(this,e?R:E)},N.prototype.applyPatches=function(e,r){return a(e)?I(e,r):this.produce(e,function(e){return I(e,r)})},N.prototype.processResult=function(e,r){var t=r.drafts[0],o=void 0!==e&&e!==t;if(this.willFinalize(r,e,o),o){if(t[i].modified)throw r.revoke(),new Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.");u(e)&&(e=this.finalize(e,null,r)),r.patches&&(r.patches.push({op:"replace",path:[],value:e}),r.inversePatches.push({op:"replace",path:[],value:t[i].base}))}else e=this.finalize(t,[],r);return r.revoke(),r.patches&&r.patchListener(r.patches,r.inversePatches),e!==n?e:void 0},N.prototype.finalize=function(e,r,t){var n=this,o=e[i];if(!o)return Object.isFrozen(e)?e:this.finalizeTree(e,null,t);if(o.scope!==t)return e;if(!o.modified)return o.base;if(!o.finalized){if(o.finalized=!0,this.finalizeTree(o.draft,r,t),this.onDelete)if(this.useProxies){var a=o.assigned;for(var u in a)a[u]||this.onDelete(o,u)}else{var f=o.base,c=o.copy;l(f,function(e){d(c,e)||n.onDelete(o,e)})}this.onCopy&&this.onCopy(o),this.autoFreeze&&t.canAutoFreeze&&Object.freeze(o.copy),r&&t.patches&&function(e,r,t,n){Array.isArray(e.base)?function(e,r,t,n){var o,i,a=e.base,u=e.copy,f=e.assigned;u.length<a.length&&(a=(o=[u,a])[0],u=o[1],t=(i=[n,t])[0],n=i[1]);for(var c=u.length-a.length,s=0;a[s]===u[s]&&s<a.length;)++s;for(var l=a.length;l>s&&a[l-1]===u[l+c-1];)--l;for(var p=s;l>p;++p)if(f[p]&&u[p]!==a[p]){var d=r.concat([p]);t.push({op:"replace",path:d,value:u[p]}),n.push({op:"replace",path:d,value:a[p]})}for(var h=l!=a.length,y=t.length,v=l+c-1;v>=l;--v){var b=r.concat([v]);t[y+v-l]={op:"add",path:b,value:u[v]},h&&n.push({op:"remove",path:b})}h||n.push({op:"replace",path:r.concat(["length"]),value:a.length})}(e,r,t,n):function(e,r,t,n){var o=e.base,i=e.copy;l(e.assigned,function(e,a){var u=o[e],f=i[e],c=a?e in o?"replace":"add":"remove";if(u!==f||"replace"!==c){var s=r.concat(e);t.push("remove"===c?{op:c,path:s}:{op:c,path:s,value:f}),n.push("add"===c?{op:"remove",path:s}:"remove"===c?{op:"add",path:s,value:u}:{op:"replace",path:s,value:u})}})}(e,r,t,n)}(o,r,t.patches,t.inversePatches)}return o.copy},N.prototype.finalizeTree=function(e,r,t){var n=this,o=e[i];o&&(this.useProxies||(o.copy=s(o.draft,!0)),e=o.copy);var f=!!r&&!!t.patches,c=function(i,s,d){if(s===d)throw Error("Immer forbids circular references");var y=!!o&&d===e;if(a(s)){var v=y&&f&&!o.assigned[i]?r.concat(i):null;if(a(s=n.finalize(s,v,t))&&(t.canAutoFreeze=!1),Array.isArray(d)||p(d,i)?d[i]=s:Object.defineProperty(d,i,{value:s}),y&&s===o.base[i])return}else{if(y&&h(s,o.base[i]))return;u(s)&&!Object.isFrozen(s)&&l(s,c)}y&&n.onAssign&&n.onAssign(o,i,s)};return l(e,c),e};var C=new N,K=C.produce;C.setAutoFreeze.bind(C),C.setUseProxies.bind(C),C.applyPatches.bind(C),C.createDraft.bind(C),C.finishDraft.bind(C),r.a=K}).call(this,t(3))},function(e,r,t){t.r(r);var n=t(0),o=t(1);r.default=(e={},r={})=>Object(o.a)(e,e=>{for(const[o,i]of Object.entries(r))for(const r of(t=i,Object(n.ensureArray)(t))){var t;e.hasOwnProperty(r)&&(e[o]=e[r],delete e[r])}})},function(e,r){var t,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var f,c=[],s=!1,l=-1;function p(){s&&f&&(s=!1,f.length?c=f.concat(c):l=-1,c.length&&d())}function d(){if(!s){var e=u(p);s=!0;for(var r=c.length;r;){for(f=c,c=[];++l<r;)f&&f[l].run();l=-1,r=c.length}f=null,s=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(r){try{return n.call(null,e)}catch(r){return n.call(this,e)}}}(e)}}function h(e,r){this.fun=e,this.array=r}function y(){}o.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];c.push(new h(e,r)),1!==c.length||s||u(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}}])});