Comparing version 5.1.1 to 5.1.2
@@ -1,1 +0,1 @@ | ||
!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=r(1),u=t(i);!function(){(0,u["default"])()}(),n.createCache=u["default"]},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)}function o(){var e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"One":arguments[1];return window?(void 0===window[n]&&(window[n]=f(e)),window[n]):f(e)}function f(){function e(){return c||(c=r(),c.current=-1,c.nodes=[]),c}function n(){var e=r();return e.id=s,s+=1,l.set(e.id,e),e}function r(){var e={};return Object.defineProperty(e,"length",{value:0,enumerable:!1,writable:!0}),e}function t(e,n){for(var r,t,i=0,u=e.length-1;u>=i;)if(r=(i+u)/2|0,t=e[r],n>t)i=r+1;else{if(!(t>n))return r;u=r-1}return-1}function i(){var e=c.nodes[c.current];return e>=0?o(e):void 0}function o(e){return l.get(e)}var f=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],c=void 0,s=0,l=new Map,O=r(),h=r(),E=[],g=function(){O=r(),l.clear(),c=void 0,c=e(),s=0};g();for(var F=function(e){if(pe()>0)throw new Error("You may only configure an empty cache. Please clear the cache first and then configure.");d.config(e)},R=function(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];if((0,a.isArray)(e)||(0,a.isObject)(e)){var r=new Map,t=new Map;r.set(p.UPDATED_KEY,!1),S(e,r,null,t,n),w(r);var i=r.get(p.UPDATED_KEY);r["delete"](p.UPDATED_KEY);var o=!1;return r.size>0&&i&&(Ee(),$([].concat(u(r.values())),t),me(),o=!0),de(o)}return de(!1)},_=function(e){function n(e,n){if((0,a.hasUid)(e)){var t=e[d.prop.uidName],i=O[t];!r&&i||!r&&M(t)||(m(t)||(O.length+=1),O[t]=e,n.push(t))}}var r=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],t=[];(0,a.isArray)(e)?e.forEach(function(e){n(e,t)}):(0,a.isObject)(e)&&n(e,t);var i=t.length>0;return i&&me(t),t.length},y=function(e){var n=ne(e);if(n)return O[n]?(O[n]=void 0,O.length>0&&(O.length-=1),!0):!1},T=function(e){var n=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];if(O.length>0){var t=[];for(var i in O)O.hasOwnProperty(i)&&t.push(O[i]);var u=R(t,e,n);return u.success===!0&&(O=r()),u}return de(!1)},b=function(e){return e&&(0,a.hasUid)(e)?(h[e[d.prop.uidName]]=e,!0):!1},m=function(e){var n=ne(e);if(n)return O[n]},M=function(e){if(!e)throw new TypeError("Cache-uid get(): requires a uid to retrieve an item from the cache.");return(0,a.isArray)(e)?e.map(function(e){return ee(e)}).filter(function(e){return null!==e&&void 0!==e}):ee(e)},j=function(e){var n=N(e);if(0==n.length)return!1;var r=X(),t=n.some(function(e){return r&&r.has(String(e))});if(!t)return!1;var i=new Map;r.forEach(function(e,n){i.set(n,e)}),Ee();var u=new Map,o=new Map;return n.forEach(function(e){Y(e,u,o),o.set(e,null),z(e,u)}),u.forEach(function(e,n){i.set(n,e)}),o.forEach(function(e,n){i["delete"](n)}),Fe(i),me(),!0},N=function(e){var n=[];if((0,a.isArray)(e))e.forEach(function(e){(0,a.hasUid)(e)?n.push(String(e[d.prop.uidName])):"string"!=typeof e&&"number"!=typeof e||n.push(String(e))});else{var r=e;if((0,a.isObject)(e)&&(r=e[d.prop.uidName]),void 0===r)return n;n.push(String(r))}return n},w=function(e){e.forEach(function(n,r){if(r!==p.UPDATED_KEY){var t=n[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var u=t[i],o=e.get(i);if(o||(o=Re(i)),o&&u.length>0){var f=u[0],c=v.get(o[p.ENTITY],f),s=c&&c!==n[p.ENTITY];s===!0&&(o=oe(o[p.ENTITY],e),o[p.ENTITY]=(0,a.deepClone)(o[p.ENTITY],n[p.ENTITY],!0,!0))}}}})},S=function(e,n,r,t,i){(0,a.hasUid)(e)?P(e,n,r,t,i):((0,a.isArray)(e)?L(e,n,r,t,i):G(e,n,r,t,i),Object.freeze(e))},P=function(e,n,r,t,i){var u=String(e[d.prop.uidName]);Z(e)!==!0&&(n.has(u)?G(e,n,r,t):(oe(e,n),r=String(u),G(e,n,r,t),Object.isFrozen(e)||Object.freeze(e)),A(u,n,t))},Y=function Ye(e,n,r){var t=Re(e);if(t){var i=t[p.REF_TO];for(var u in i)if(i.hasOwnProperty(u)){var o=I(u,n);o&&(q(o,e),0===o[p.REF_FROM].length?(Ye(u,n,r),r.set(u,o)):n.set(u,o))}}},z=function(e,n){var r=I(e,n);if(r){var t=r[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var u=I(i,n);if(u){var o=H(u,e);o===!0&&n.set(i,u)}}}},I=function(e,n){if(e){e=String(e);var r=n.get(e);return r||(r=Re(e)),Object.isFrozen(r)&&(r=fe(r)),r}},A=function(e,n,r){var t=I(e,n);if(t){var i=t[p.REF_TO],u=function(u){if(i.hasOwnProperty(u)){var o=i[u],f=o.map(function(i){var o=v.get(t[p.ENTITY],i);if(o){var f=o[d.prop.uidName];if(f){var a=f==u;if(a===!0)return i}}U(e,u,i,n,r)}).filter(function(e){return null!==e&&void 0!==e});f.length>0?t[p.REF_TO][u]=f:(t[p.REF_TO][u]=void 0,delete t[p.REF_TO][u])}};for(var o in i)u(o)}},x=function(e){Object.freeze(e),Object.freeze(e[p.ENTITY]),Object.freeze(e[p.REF_TO]),Object.freeze(e[p.REF_FROM])},U=function(e,n,r,t,i){var u=I(n,t);u&&(u=Object.assign({},u),D(u,p.REF_FROM),u[p.REF_FROM].hasOwnProperty(e)&&(J(u,e,r),0===u[p.REF_FROM].length?(i.set(n,u),t["delete"](n)):(t.set(n,u),i["delete"](n))))},D=function(e,n){var t=e[n].length;e[n]=Object.assign(r(),e[n]),e[n].length=t},C=function(e,n,r){var t=e[p.REF_TO];e[p.REF_TO][n]||(e[p.REF_TO][n]=[],e[p.REF_TO].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},K=function(e,n,r){var t=e[p.REF_FROM];e[p.REF_FROM][n]||(e[p.REF_FROM][n]=[],e[p.REF_FROM].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},J=function(e,n,r){var t=e[p.REF_FROM][n],i=t.indexOf(r);t=t.slice(),t.splice(i,1),e[p.REF_FROM][n]=t,0==t.length&&(e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length-=1)},q=function(e,n){var r=e[p.REF_FROM][n];r&&(D(e,p.REF_FROM),e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length>0&&(e[p.REF_FROM].length-=1))},H=function(e,n){var r=e[p.ENTITY];Object.isFrozen(r)&&(r=re(r[d.prop.uidName]),e[p.ENTITY]=r);var t=e[p.REF_TO][n];return t.forEach(function(e){v.del(r,e)}),Object.isFrozen(r)||Object.freeze(r),e[p.ENTITY]=r,D(e,p.REF_TO),e[p.REF_TO][n]=void 0,delete e[p.REF_TO][n],e[p.REF_TO].length>0&&(e[p.REF_TO].length-=1),!0},Q=function(e){O[e]&&(O[e]=void 0,O.length>0&&(O.length-=1))},G=function(e,n,r,t,i,u){void 0===i&&(i="");for(var o in e){if(e.hasOwnProperty(o)){i=W(i,o);var f=e[o];(0,a.isArray)(f)?L(f,n,r,t,i,u):(0,a.isObject)(f)&&k(f,n,r,t,i,u),Object.freeze(f)}i=""}},Z=function(e){var n=e[d.prop.uidName],r=Re(n);return r&&r[p.ENTITY]===e},k=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4];if((0,a.hasUid)(e)){var u=oe(e,n);if(u){B(u,r,i,n);var o=Z(e);if(o===!0)return;u[p.ENTITY]=e,r=String(e[d.prop.uidName]),S(e,n,r,t)}}else G(e,n,r,t,i);Object.freeze(e)},B=function(e,n,r,t){var i=I(n,t);i&&r&&""!==r&&V(i,e,r)},L=function ze(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],u=void 0;e.forEach(function(e,o){u=i+"."+o,(0,a.isArray)(e)?ze(e,n,r,t,u):(0,a.isObject)(e)&&k(e,n,r,t,u)}),Object.freeze(e)},V=function(e,n,r){var t=e[p.ENTITY][d.prop.uidName],i=n[p.ENTITY][d.prop.uidName];C(e,i,r),K(n,t,r)},W=function(e,n){return e=""===e?n:e+"."+n},X=function(){var e=i();return e?e.items:new Map},$=function(e,n){var r=new Map,t=X();t.forEach(function(e,n){r.set(n,e)}),e.forEach(function(e){var n=e[p.ENTITY][d.prop.uidName];x(e),r.set(String(n),e)}),n.size>0&&n.forEach(function(e,n){r["delete"](String(n))}),Fe(r)},ee=function(e){var n=ne(e);if(n){var r=Re(n);if(void 0!==r)return r[p.ENTITY];var t=O[n];if(t)return t}},ne=function(e){return"string"==typeof e?e:"number"==typeof e?String(e):(0,a.isObject)(e)&&(0,a.hasUid)(e)?e[d.prop.uidName]:void 0},re=function(e){return(0,a.isArray)(e)?e.map(function(e){return ue(e)}).filter(function(e){return null!==e&void 0!==e}):ue(e)},te=function(e){if((0,a.isNumber)(e)===!0){if(c.current!==e){if(!(e>=0&&e<Oe()))throw new TypeError("Index out of bounds");return c.current=e,me(),!0}return!1}return c.current},ie=function(e){if("undefined"==typeof e){var n=i();return n?n.id:-1}if(!(0,a.isNumber)(e))throw new TypeError("The node id must be a number.");var r=o(e);return r?(c.current=t(c.nodes,e),de(!0)):de(!1)},ue=function(e){var n=ne(e);if(m(n))return O[n];var r=M(n);if(r)return(0,a.deepClone)(r,void 0,!1)},oe=function(e,n){var t=String(e[d.prop.uidName]),i=n.get(t);if(i)return i;i={};var u=Re(t);return i[p.ENTITY]=e,void 0!==u?(i=Object.assign(i,u),i[p.ENTITY]=e,i[p.REF_FROM]=Object.assign(r(),u[p.REF_FROM]),i[p.REF_FROM].length=u[p.REF_FROM].length,i[p.REF_TO]=Object.assign(r(),u[p.REF_TO]),i[p.REF_TO].length=u[p.REF_TO].length):(i[p.REF_FROM]=r(),i[p.REF_TO]=r()),n.set(t,i),n.set(p.UPDATED_KEY,!0),Q(t),i},fe=function(e){var n=Object.assign({},e);return D(n,p.REF_FROM),D(n,p.REF_TO),n},ae=function(e){return(0,a.hasUid)(e)?"undefined"!=typeof Re(e[d.prop.uidName]):!1},ce=function(){var e=!1;return ve()&&(c.current-=1,e=!0),de(e)},se=function(){var e=!1;return le()&&(c.current+=1,e=!0),de(e)},de=function(e){var n={};return n.success=e,n.index=te(),n.node=ie(),n.length=Oe(),n.hasPrev=n.index>0,n.hasNext=n.index<n.length-1,n},le=function(){return c.current<c.nodes.length-1},ve=function(){return c.current>0},pe=function(){var e=i();return e?e.items.size:0},Oe=function(){return c.nodes.length},he=function(){return{queue:O.length}},Ee=function(){if(c.current<c.nodes.length-1){var e=c.nodes.slice(c.current+1,c.nodes.length);c.nodes=c.nodes.slice(0,c.current+1),c.current=c.nodes.length-1,ge(e)}},ge=function(e){e.forEach(function(e){var n=l.get(e);n&&l["delete"](e)})},Fe=function(e,r){if(null!==e){Object.freeze(e);var t=n();t.items=e,c.nodes.indexOf(t.id)<0&&(c.nodes.push(t.id),c.current+=1)}},Re=function(e){var n=i();return n?n.items.get(String(e)):void 0},_e=function(){var e="",n=0,r=c.current;c.nodes.map(function(t){var i="",u=l.get(t),o=n+":"+i+"\n["+ye(u.items)+"],\n\n";n===r&&(o="-> "+o),e+=o,n++}),e=e.substring(0,e.length-2),n=0,console.log("\n------ One -------\nSTACK:\n"+e+"\n\nCONFIG:"+JSON.stringify(d,null,2)+"\n\nQUEUE:"+JSON.stringify(O,null,2)+"\n\nHISTORY:"+JSON.stringify(de(),null,2)+"\n\nREPO SIZE:"+l.size+"\n===================\n")},ye=function(e){var n="",r=[].concat(u(e.values()));return r.map(function(e){var r=void 0;r=JSON.stringify(e,null,2)+",\n",r.indexOf(p.REF_FROM)>=0&&e[p.REF_FROM]&&(r=r.replace('"'+p.REF_FROM+'": {}','"'+p.REF_FROM+'": '+JSON.stringify([].concat(u(e[p.REF_FROM]))))),r.indexOf(p.REF_TO)>=0&&e[p.REF_TO]&&(r=r.replace('"'+p.REF_TO+'": {}','"'+p.REF_TO+'": '+JSON.stringify(e[p.REF_TO]))),n+=r}),n.length>2&&(n=n.substring(0,n.length-2)),n},Te=function(e){if(!(0,a.hasUid)(e))return!0;var n=e[d.prop.uidName],r=M(n);return r?r!==e:!0},be=function(e){E.push(e);var n=!0;return function(){if(n){n=!1;var r=E.indexOf(e);E.splice(r,1)}}},me=function(e){E.slice().forEach(function(n){n(e)})},Me=[],je=0;256>je;je++)Me[je]=(16>je?"0":"")+je.toString(16);var Ne=function(){var e=4294967296*Math.random()|0,n=4294967296*Math.random()|0,r=4294967296*Math.random()|0,t=4294967296*Math.random()|0;return Me[255&e]+Me[e>>8&255]+Me[e>>16&255]+Me[e>>24&255]+"-"+Me[255&n]+Me[n>>8&255]+"-"+Me[n>>16&15|64]+Me[n>>24&255]+"-"+Me[63&r|128]+Me[r>>8&255]+"-"+Me[r>>16&255]+Me[r>>24&255]+Me[255&t]+Me[t>>8&255]+Me[t>>16&255]+Me[t>>24&255]},we=function(e){var n=Re(e);return n[p.REF_FROM]},Se=function(e){var n=Re(e);return n[p.REF_TO]},Pe={put:R,get:M,getEdit:re,evict:j,reset:g,queue:_,unQueue:y,queueEvict:b,getQueued:m,commit:T,undo:ce,redo:se,index:te,node:ie,getHistoryState:de,isDirty:Te,uuid:Ne,contains:ae,config:F,subscribe:be};return f===!0&&(Pe.getCurrentNode=i,Pe.refFrom=we,Pe.refTo=Se,Pe.size=pe,Pe.length=Oe,Pe.pending=he,Pe.print=_e),Pe}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var a=r(2),c=r(4),s=(i(c),r(3)),d=t(s),l=r(5),v=t(l),p=r(6);e.exports=n["default"]},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return"number"==typeof e||"[object Number]"===toString(e)}function u(e){return"string"==typeof e||"[object String]"===toString(e)}function o(e){if(!e)return!0;if(d(e)&&0===e.length)return!0;if(!u(e)){for(var n in e)if(h.call(e,n))return!1;return!0}return!1}function f(e,n){var r=arguments.length<=2||void 0===arguments[2]?!0:arguments[2],t=arguments.length<=3||void 0===arguments[3]?!1:arguments[3];if(!e||!s(e)&&!d(e))return e;if(r===!0&&n&&!Object.isFrozen(n)&&Object.freeze(n),n&&c(e)&&e[O.prop.uidName]===n[O.prop.uidName])return n;var i=Object.assign({},e);for(var u in i)if(i.hasOwnProperty(u)){var o=i[u];if(o)if(d(o))i[u]=a(o,n,t);else if(v(o)){var l=new Date(o.getTime());r===!0&&Object.freeze(l),i[u]=l}else s(o)&&(c(o)?(i[u]=o,n&&c(n)&&o!==n&&o.uid===n.uid&&o!==n&&(i[u]=n)):i[u]=f(o,n,r,t))}return r!==!0||Object.isFrozen(i)||Object.freeze(i),i}function a(e,n,r){return e.map(function(e){return d(e)?a(e,n,r):s(e)?c(e)&&r===!1?e:f(e,n,r):e})}function c(e){if(!e)return!1;if(!s(e))return!1;if("undefined"==typeof e[O.prop.uidName])return!1;var n=e[O.prop.uidName];return 0!==n.length}function s(e){return"[object Array]"===Object.prototype.toString.call(e)?!1:null!==e&&"object"==typeof e}function d(e){return e&&null!==e?Array.isArray(e)||e&&"object"==typeof e&&"number"==typeof e.length&&"function"==typeof e.splice&&!e.propertyIsEnumerable("length"):!1}function l(e){return Object.prototype.toString.call(e)}function v(e){return s(e)&&"[object Date]"===l(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.isNumber=i,n.isString=u,n.isEmpty=o,n.deepClone=f,n.hasUid=c,n.isObject=s,n.isArray=d,n.isDate=v;var p=r(3),O=t(p),h=Object.prototype.hasOwnProperty},function(e,n){"use strict";function r(e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(t[n]=e[n])}Object.defineProperty(n,"__esModule",{value:!0}),n.config=r;var t={uidName:"uid",maxHistoryStates:1e3};n.prop=t},function(e,n){"use strict";function r(e){return e?(Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(n){!e.hasOwnProperty(n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||r(e[n])}),e):void 0}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,e.exports=n["default"]},function(e,n,r){"use strict";function t(e){var n=parseInt(e);return n.toString()===e?n:e}function i(e,n){var r=!0;e:for(;r;){var i=e,u=n;if(r=!1,(0,o.isNumber)(u)&&(u=[u]),(0,o.isEmpty)(i))return;if((0,o.isEmpty)(u))return i;if(!(0,o.isString)(u)){var f=t(u[0]),a=i[f];if(1===u.length)void 0!==a&&((0,o.isArray)(i)?i.splice(f,1):delete i[f]);else if(void 0!==i[f]){e=i[f],n=u.slice(1),r=!0,f=a=void 0;continue e}return i}e=i,n=u.split("."),r=!0}}function u(e,n,r){for(var i=!0;i;){var u=e,f=n,a=r;if(i=!1,(0,o.isNumber)(f)&&(f=[f]),(0,o.isEmpty)(f))return u;if((0,o.isEmpty)(u))return a;if((0,o.isString)(f))e=u,n=f.split("."),r=a,i=!0;else{var c=t(f[0]);if(1===f.length)return void 0===u[c]?a:u[c];e=u[c],n=f.slice(1),r=a,i=!0,c=void 0}}}Object.defineProperty(n,"__esModule",{value:!0}),n.del=i,n.get=u;var o=r(2)},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r="entity";n.ENTITY=r;var t="ref_from";n.REF_FROM=t;var i="ref_to";n.REF_TO=i;var u="mapUpdatedKey";n.UPDATED_KEY=u}]); | ||
!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=r(1),u=t(i);!function(){(0,u["default"])()}(),n.createCache=u["default"]},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return e&&e.__esModule?e:{"default":e}}function u(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)}function o(){var e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"One":arguments[1];return window?(void 0===window[n]&&(window[n]=f(e)),window[n]):f(e)}function f(){function e(){return c||(c=r(),c.current=-1,c.nodes=[]),c}function n(){var e=r();return e.id=s,s+=1,l.set(e.id,e),e}function r(){var e={};return Object.defineProperty(e,"length",{value:0,enumerable:!1,writable:!0}),e}function t(e,n){for(var r,t,i=0,u=e.length-1;u>=i;)if(r=(i+u)/2|0,t=e[r],n>t)i=r+1;else{if(!(t>n))return r;u=r-1}return-1}function i(){var e=c.nodes[c.current];return e>=0?o(e):void 0}function o(e){return l.get(e)}var f=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],c=void 0,s=0,l=new Map,O=r(),E=r(),g=[],h=function(){O=r(),l.clear(),c=void 0,c=e(),s=0};h();for(var F=function(e){if(pe()>0)throw new Error("You may only configure an empty cache. Please clear the cache first and then configure.");d.config(e)},R=function(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];if((0,a.isArray)(e)||(0,a.isObject)(e)){var r=new Map,t=new Map;r.set(p.UPDATED_KEY,!1),S(e,r,null,t,n),w(r);var i=r.get(p.UPDATED_KEY);r["delete"](p.UPDATED_KEY);var o=!1;return r.size>0&&i&&(ge(),$([].concat(u(r.values())),t),me(),o=!0),de(o)}return de(!1)},_=function(e){function n(e,n){if((0,a.hasUid)(e)){var t=e[d.prop.uidName],i=O[t];!r&&i||!r&&N(t)||(m(t)||(O.length+=1),O[t]=e,n.push(t))}}var r=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],t=[];(0,a.isArray)(e)?e.forEach(function(e){n(e,t)}):(0,a.isObject)(e)&&n(e,t);var i=t.length>0;return i&&me(t),t.length},y=function(e){var n=ne(e);if(n)return O[n]?(O[n]=void 0,O.length>0&&(O.length-=1),!0):!1},T=function(e){var n=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];if(O.length>0){var t=[];for(var i in O)O.hasOwnProperty(i)&&t.push(O[i]);var u=R(t,e,n);return u.success===!0&&(O=r()),u}return de(!1)},b=function(e){return e&&(0,a.hasUid)(e)?(E[e[d.prop.uidName]]=e,!0):!1},m=function(e){var n=ne(e);if(n)return O[n]},N=function(e){if(!e)throw new TypeError("One get(): requires a uid to retrieve an item from the cache.");return(0,a.isArray)(e)?e.map(function(e){return ee(e)}).filter(function(e){return null!==e&&void 0!==e}):ee(e)},M=function(e){var n=j(e);if(0==n.length)return!1;var r=X(),t=n.some(function(e){return r&&r.has(String(e))});if(!t)return!1;var i=new Map;r.forEach(function(e,n){i.set(n,e)}),ge();var u=new Map,o=new Map;return n.forEach(function(e){Y(e,u,o),o.set(e,null),z(e,u)}),u.forEach(function(e,n){i.set(n,e)}),o.forEach(function(e,n){i["delete"](n)}),Fe(i),me(),!0},j=function(e){var n=[];if((0,a.isArray)(e))e.forEach(function(e){(0,a.hasUid)(e)?n.push(String(e[d.prop.uidName])):"string"!=typeof e&&"number"!=typeof e||n.push(String(e))});else{var r=e;if((0,a.isObject)(e)&&(r=e[d.prop.uidName]),void 0===r)return n;n.push(String(r))}return n},w=function(e){e.forEach(function(n,r){if(r!==p.UPDATED_KEY){var t=n[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var u=t[i],o=e.get(i);if(o||(o=Re(i)),o&&u.length>0){var f=u[0],c=v.get(o[p.ENTITY],f),s=c&&c!==n[p.ENTITY];s===!0&&(o=oe(o[p.ENTITY],e),o[p.ENTITY]=(0,a.deepClone)(o[p.ENTITY],n[p.ENTITY],!0))}}}})},S=function(e,n,r,t,i){(0,a.hasUid)(e)?P(e,n,r,t,i):((0,a.isArray)(e)?L(e,n,r,t,i):G(e,n,r,t,i),Object.freeze(e))},P=function(e,n,r,t,i){var u=String(e[d.prop.uidName]);Z(e)!==!0&&(n.has(u)?G(e,n,r,t):(oe(e,n),r=String(u),G(e,n,r,t),Object.isFrozen(e)||Object.freeze(e)),A(u,n,t))},Y=function Ye(e,n,r){var t=Re(e);if(t){var i=t[p.REF_TO];for(var u in i)if(i.hasOwnProperty(u)){var o=I(u,n);o&&(q(o,e),0===o[p.REF_FROM].length?(Ye(u,n,r),r.set(u,o)):n.set(u,o))}}},z=function(e,n){var r=I(e,n);if(r){var t=r[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var u=I(i,n);if(u){var o=H(u,e);o===!0&&n.set(i,u)}}}},I=function(e,n){if(e){e=String(e);var r=n.get(e);return r||(r=Re(e)),Object.isFrozen(r)&&(r=fe(r)),r}},A=function(e,n,r){var t=I(e,n);if(t){var i=t[p.REF_TO],u=function(u){if(i.hasOwnProperty(u)){var o=i[u],f=o.map(function(i){var o=v.get(t[p.ENTITY],i);if(o){var f=o[d.prop.uidName];if(f){var a=f==u;if(a===!0)return i}}U(e,u,i,n,r)}).filter(function(e){return null!==e&&void 0!==e});f.length>0?t[p.REF_TO][u]=f:(t[p.REF_TO][u]=void 0,delete t[p.REF_TO][u])}};for(var o in i)u(o)}},x=function(e){Object.freeze(e),Object.freeze(e[p.ENTITY]),Object.freeze(e[p.REF_TO]),Object.freeze(e[p.REF_FROM])},U=function(e,n,r,t,i){var u=I(n,t);u&&(u=Object.assign({},u),D(u,p.REF_FROM),u[p.REF_FROM].hasOwnProperty(e)&&(J(u,e,r),0===u[p.REF_FROM].length?(i.set(n,u),t["delete"](n)):(t.set(n,u),i["delete"](n))))},D=function(e,n){var t=e[n].length;e[n]=Object.assign(r(),e[n]),e[n].length=t},K=function(e,n,r){var t=e[p.REF_TO];e[p.REF_TO][n]||(e[p.REF_TO][n]=[],e[p.REF_TO].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},C=function(e,n,r){var t=e[p.REF_FROM];e[p.REF_FROM][n]||(e[p.REF_FROM][n]=[],e[p.REF_FROM].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},J=function(e,n,r){var t=e[p.REF_FROM][n],i=t.indexOf(r);t=t.slice(),t.splice(i,1),e[p.REF_FROM][n]=t,0==t.length&&(e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length-=1)},q=function(e,n){var r=e[p.REF_FROM][n];r&&(D(e,p.REF_FROM),e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length>0&&(e[p.REF_FROM].length-=1))},H=function(e,n){var r=e[p.ENTITY];Object.isFrozen(r)&&(r=re(r[d.prop.uidName]),e[p.ENTITY]=r);var t=e[p.REF_TO][n];return t.forEach(function(e){v.del(r,e)}),Object.isFrozen(r)||Object.freeze(r),e[p.ENTITY]=r,D(e,p.REF_TO),e[p.REF_TO][n]=void 0,delete e[p.REF_TO][n],e[p.REF_TO].length>0&&(e[p.REF_TO].length-=1),!0},Q=function(e){O[e]&&(O[e]=void 0,O.length>0&&(O.length-=1))},G=function(e,n,r,t,i,u){void 0===i&&(i="");for(var o in e){if(e.hasOwnProperty(o)){i=W(i,o);var f=e[o];(0,a.isArray)(f)?L(f,n,r,t,i,u):(0,a.isObject)(f)&&k(f,n,r,t,i,u),Object.freeze(f)}i=""}},Z=function(e){var n=e[d.prop.uidName],r=Re(n);return r&&r[p.ENTITY]===e},k=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4];if((0,a.hasUid)(e)){var u=oe(e,n);if(u){B(u,r,i,n);var o=Z(e);if(o===!0)return;u[p.ENTITY]=e,r=String(e[d.prop.uidName]),S(e,n,r,t)}}else G(e,n,r,t,i);Object.freeze(e)},B=function(e,n,r,t){var i=I(n,t);i&&r&&""!==r&&V(i,e,r)},L=function ze(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],u=void 0;e.forEach(function(e,o){u=i+"."+o,(0,a.isArray)(e)?ze(e,n,r,t,u):(0,a.isObject)(e)&&k(e,n,r,t,u)}),Object.freeze(e)},V=function(e,n,r){var t=e[p.ENTITY][d.prop.uidName],i=n[p.ENTITY][d.prop.uidName];K(e,i,r),C(n,t,r)},W=function(e,n){return e=""===e?n:e+"."+n},X=function(){var e=i();return e?e.items:new Map},$=function(e,n){var r=new Map,t=X();t.forEach(function(e,n){r.set(n,e)}),e.forEach(function(e){var n=e[p.ENTITY][d.prop.uidName];x(e),r.set(String(n),e)}),n.size>0&&n.forEach(function(e,n){r["delete"](String(n))}),Fe(r)},ee=function(e){var n=ne(e);if(n){var r=Re(n);if(void 0!==r)return r[p.ENTITY];var t=O[n];if(t)return t}},ne=function(e){return"string"==typeof e?e:"number"==typeof e?String(e):(0,a.isObject)(e)&&(0,a.hasUid)(e)?e[d.prop.uidName]:void 0},re=function(e){return(0,a.isArray)(e)?e.map(function(e){return ue(e)}).filter(function(e){return null!==e&void 0!==e}):ue(e)},te=function(e){if((0,a.isNumber)(e)===!0){if(c.current!==e){if(!(e>=0&&e<Oe()))throw new TypeError("Index out of bounds");return c.current=e,me(),!0}return!1}return c.current},ie=function(e){if("undefined"==typeof e){var n=i();return n?n.id:-1}if(!(0,a.isNumber)(e))throw new TypeError("The node id must be a number.");var r=o(e);return r?(c.current=t(c.nodes,e),de(!0)):de(!1)},ue=function(e){var n=ne(e);if(m(n))return O[n];var r=N(n);if(r)return(0,a.deepClone)(r,void 0,!1)},oe=function(e,n){var t=String(e[d.prop.uidName]),i=n.get(t);if(i)return i;i={};var u=Re(t);return i[p.ENTITY]=e,void 0!==u?(i=Object.assign(i,u),i[p.ENTITY]=e,i[p.REF_FROM]=Object.assign(r(),u[p.REF_FROM]),i[p.REF_FROM].length=u[p.REF_FROM].length,i[p.REF_TO]=Object.assign(r(),u[p.REF_TO]),i[p.REF_TO].length=u[p.REF_TO].length):(i[p.REF_FROM]=r(),i[p.REF_TO]=r()),n.set(t,i),n.set(p.UPDATED_KEY,!0),Q(t),i},fe=function(e){var n=Object.assign({},e);return D(n,p.REF_FROM),D(n,p.REF_TO),n},ae=function(e){return(0,a.hasUid)(e)?"undefined"!=typeof Re(e[d.prop.uidName]):!1},ce=function(){var e=!1;return ve()&&(c.current-=1,e=!0),de(e)},se=function(){var e=!1;return le()&&(c.current+=1,e=!0),de(e)},de=function(e){var n={};return n.success=e,n.index=te(),n.node=ie(),n.length=Oe(),n.hasPrev=n.index>0,n.hasNext=n.index<n.length-1,n},le=function(){return c.current<c.nodes.length-1},ve=function(){return c.current>0},pe=function(){var e=i();return e?e.items.size:0},Oe=function(){return c.nodes.length},Ee=function(){return{queue:O.length}},ge=function(){if(c.current<c.nodes.length-1){var e=c.nodes.slice(c.current+1,c.nodes.length);c.nodes=c.nodes.slice(0,c.current+1),c.current=c.nodes.length-1,he(e)}},he=function(e){e.forEach(function(e){var n=l.get(e);n&&l["delete"](e)})},Fe=function(e,r){if(null!==e){Object.freeze(e);var t=n();t.items=e,c.nodes.indexOf(t.id)<0&&(c.nodes.push(t.id),c.current+=1)}},Re=function(e){var n=i();return n?n.items.get(String(e)):void 0},_e=function(){var e="",n=0,r=c.current;c.nodes.map(function(t){var i="",u=l.get(t),o=n+":"+i+"\n["+ye(u.items)+"],\n\n";n===r&&(o="-> "+o),e+=o,n++}),e=e.substring(0,e.length-2),n=0,console.log("\n------ One -------\nSTACK:\n"+e+"\n\nCONFIG:"+JSON.stringify(d,null,2)+"\n\nQUEUE:"+JSON.stringify(O,null,2)+"\n\nHISTORY:"+JSON.stringify(de(),null,2)+"\n\nREPO SIZE:"+l.size+"\n===================\n")},ye=function(e){var n="",r=[].concat(u(e.values()));return r.map(function(e){var r=void 0;r=JSON.stringify(e,null,2)+",\n",r.indexOf(p.REF_FROM)>=0&&e[p.REF_FROM]&&(r=r.replace('"'+p.REF_FROM+'": {}','"'+p.REF_FROM+'": '+JSON.stringify([].concat(u(e[p.REF_FROM]))))),r.indexOf(p.REF_TO)>=0&&e[p.REF_TO]&&(r=r.replace('"'+p.REF_TO+'": {}','"'+p.REF_TO+'": '+JSON.stringify(e[p.REF_TO]))),n+=r}),n.length>2&&(n=n.substring(0,n.length-2)),n},Te=function(e){if(!(0,a.hasUid)(e))return!0;var n=e[d.prop.uidName],r=N(n);return r?r!==e:!0},be=function(e){g.push(e);var n=!0;return function(){if(n){n=!1;var r=g.indexOf(e);g.splice(r,1)}}},me=function(e){g.slice().forEach(function(n){n(e)})},Ne=[],Me=0;256>Me;Me++)Ne[Me]=(16>Me?"0":"")+Me.toString(16);var je=function(){var e=4294967296*Math.random()|0,n=4294967296*Math.random()|0,r=4294967296*Math.random()|0,t=4294967296*Math.random()|0;return Ne[255&e]+Ne[e>>8&255]+Ne[e>>16&255]+Ne[e>>24&255]+"-"+Ne[255&n]+Ne[n>>8&255]+"-"+Ne[n>>16&15|64]+Ne[n>>24&255]+"-"+Ne[63&r|128]+Ne[r>>8&255]+"-"+Ne[r>>16&255]+Ne[r>>24&255]+Ne[255&t]+Ne[t>>8&255]+Ne[t>>16&255]+Ne[t>>24&255]},we=function(e){var n=Re(e);return n[p.REF_FROM]},Se=function(e){var n=Re(e);return n[p.REF_TO]},Pe={put:R,get:N,getEdit:re,evict:M,reset:h,queue:_,unQueue:y,queueEvict:b,getQueued:m,commit:T,undo:ce,redo:se,index:te,node:ie,getHistoryState:de,isDirty:Te,uuid:je,contains:ae,config:F,subscribe:be};return f===!0&&(Pe.getCurrentNode=i,Pe.refFrom=we,Pe.refTo=Se,Pe.size=pe,Pe.length=Oe,Pe.pending=Ee,Pe.print=_e),Pe}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var a=r(2),c=r(4),s=(i(c),r(3)),d=t(s),l=r(5),v=t(l),p=r(6);e.exports=n["default"]},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return"number"==typeof e||"[object Number]"===toString(e)}function u(e){return"string"==typeof e||"[object String]"===toString(e)}function o(e){if(!e)return!0;if(d(e)&&0===e.length)return!0;if(!u(e)){for(var n in e)if(E.call(e,n))return!1;return!0}return!1}function f(e,n){var r=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];if(!e||!s(e)&&!d(e))return e;if(r===!0&&n&&!Object.isFrozen(n)&&Object.freeze(n),n&&c(e)&&e[O.prop.uidName]===n[O.prop.uidName])return n;var t=Object.assign({},e);for(var i in t)if(t.hasOwnProperty(i)){var u=t[i];if(u)if(d(u))t[i]=a(u,n,r);else if(v(u)){var o=new Date(u.getTime());r===!0&&Object.freeze(o),t[i]=o}else s(u)&&(c(u)?(t[i]=u,n&&c(n)&&u!==n&&u.uid===n.uid&&u!==n&&(t[i]=n)):t[i]=f(u,n,r))}return r!==!0||Object.isFrozen(t)||Object.freeze(t),t}function a(e,n,r){return e.map(function(e){return d(e)?a(e,n,r):s(e)?c(e)?n&&e[O.prop.uidName]===n[O.prop.uidName]?n:e:f(e,n,r):e})}function c(e){if(!e)return!1;if(!s(e))return!1;if("undefined"==typeof e[O.prop.uidName])return!1;var n=e[O.prop.uidName];return 0!==n.length}function s(e){return"[object Array]"===Object.prototype.toString.call(e)?!1:null!==e&&"object"==typeof e}function d(e){return e&&null!==e?Array.isArray(e)||e&&"object"==typeof e&&"number"==typeof e.length&&"function"==typeof e.splice&&!e.propertyIsEnumerable("length"):!1}function l(e){return Object.prototype.toString.call(e)}function v(e){return s(e)&&"[object Date]"===l(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.isNumber=i,n.isString=u,n.isEmpty=o,n.deepClone=f,n.hasUid=c,n.isObject=s,n.isArray=d,n.isDate=v;var p=r(3),O=t(p),E=Object.prototype.hasOwnProperty},function(e,n){"use strict";function r(e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(t[n]=e[n])}Object.defineProperty(n,"__esModule",{value:!0}),n.config=r;var t={uidName:"uid",maxHistoryStates:1e3};n.prop=t},function(e,n){"use strict";function r(e){return e?(Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(n){!e.hasOwnProperty(n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||r(e[n])}),e):void 0}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,e.exports=n["default"]},function(e,n,r){"use strict";function t(e){var n=parseInt(e);return n.toString()===e?n:e}function i(e,n){var r=!0;e:for(;r;){var i=e,u=n;if(r=!1,(0,o.isNumber)(u)&&(u=[u]),(0,o.isEmpty)(i))return;if((0,o.isEmpty)(u))return i;if(!(0,o.isString)(u)){var f=t(u[0]),a=i[f];if(1===u.length)void 0!==a&&((0,o.isArray)(i)?i.splice(f,1):delete i[f]);else if(void 0!==i[f]){e=i[f],n=u.slice(1),r=!0,f=a=void 0;continue e}return i}e=i,n=u.split("."),r=!0}}function u(e,n,r){for(var i=!0;i;){var u=e,f=n,a=r;if(i=!1,(0,o.isNumber)(f)&&(f=[f]),(0,o.isEmpty)(f))return u;if((0,o.isEmpty)(u))return a;if((0,o.isString)(f))e=u,n=f.split("."),r=a,i=!0;else{var c=t(f[0]);if(1===f.length)return void 0===u[c]?a:u[c];e=u[c],n=f.slice(1),r=a,i=!0,c=void 0}}}Object.defineProperty(n,"__esModule",{value:!0}),n.del=i,n.get=u;var o=r(2)},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r="entity";n.ENTITY=r;var t="ref_from";n.REF_FROM=t;var i="ref_to";n.REF_TO=i;var u="mapUpdatedKey";n.UPDATED_KEY=u}]); |
@@ -400,3 +400,3 @@ "use strict"; | ||
if (!uidOrEntityOrArray) { | ||
throw new TypeError("Cache-uid get(): requires a uid to retrieve an item from the cache."); | ||
throw new TypeError("One get(): requires a uid to retrieve an item from the cache."); | ||
} | ||
@@ -509,7 +509,10 @@ if ((0, _utilsClone.isArray)(uidOrEntityOrArray)) { | ||
if (key !== _utilsConstants.UPDATED_KEY) { | ||
// do not modify flush map on its own iteration but ok to pass along for reference | ||
var refsFrom = item[_utilsConstants.REF_FROM]; | ||
// parentUid = uid of the item being targeted for ref update (ie the ref's parent) | ||
for (var parentUid in refsFrom) { | ||
if (refsFrom.hasOwnProperty(parentUid)) { | ||
var paths = refsFrom[parentUid]; | ||
@@ -520,2 +523,3 @@ var parentItem = flushMap.get(parentUid); | ||
} | ||
/* only update if dirty - no need to iterate all paths - just check the first one | ||
@@ -529,6 +533,11 @@ - if dirty then the parent entity needs to be cloned and updated anyways so pass in | ||
var dirty = targetRef && targetRef !== item[_utilsConstants.ENTITY]; | ||
if (dirty === true) { | ||
parentItem = ensureItem(parentItem[_utilsConstants.ENTITY], flushMap); | ||
// TODO figure out a way to not clone the entity every time particularly if it is | ||
// already present on the flush map | ||
// the entity is still frozen here - clone it to update and freeze it deeply | ||
parentItem[_utilsConstants.ENTITY] = (0, _utilsClone.deepClone)(parentItem[_utilsConstants.ENTITY], item[_utilsConstants.ENTITY], true, true); | ||
parentItem[_utilsConstants.ENTITY] = (0, _utilsClone.deepClone)(parentItem[_utilsConstants.ENTITY], item[_utilsConstants.ENTITY], true); | ||
} | ||
@@ -535,0 +544,0 @@ } |
@@ -62,3 +62,2 @@ /** | ||
var freeze = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; | ||
var force = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; | ||
@@ -85,3 +84,3 @@ if (!obj || !isObject(obj) && !isArray(obj)) { | ||
if (isArray(value)) { | ||
result[propName] = deepCloneArray(value, uidReference, force); | ||
result[propName] = deepCloneArray(value, uidReference, freeze); | ||
} else if (isDate(value)) { | ||
@@ -105,3 +104,3 @@ var date = new Date(value.getTime()); | ||
} else { | ||
result[propName] = deepClone(value, uidReference, freeze, force); | ||
result[propName] = deepClone(value, uidReference, freeze); | ||
} | ||
@@ -118,12 +117,15 @@ } | ||
function deepCloneArray(arr, uidReference, force) { | ||
function deepCloneArray(arr, uidReference, freeze) { | ||
return arr.map(function (item) { | ||
if (isArray(item)) { | ||
return deepCloneArray(item, uidReference, force); | ||
return deepCloneArray(item, uidReference, freeze); | ||
} else if (isObject(item)) { | ||
// *** keep items inside clones as we're not editing them = must getEdit on item | ||
if (hasUid(item) && force === false) { | ||
if (hasUid(item)) { | ||
if (uidReference && item[config.prop.uidName] === uidReference[config.prop.uidName]) { | ||
return uidReference; | ||
} | ||
return item; | ||
} else { | ||
return deepClone(item, uidReference, force); | ||
return deepClone(item, uidReference, freeze); | ||
} | ||
@@ -130,0 +132,0 @@ } else { |
{ | ||
"name": "one", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"description": "Browser application cache. It guarantees entity uniqueness across the entire cache.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -502,2 +502,6 @@ "use strict"; | ||
parentItem = ensureItem(parentItem[ENTITY], flushMap); | ||
// TODO figure out a way to not clone the entity every time particularly if it is | ||
// already present on the flush map | ||
// the entity is still frozen here - clone it to update and freeze it deeply | ||
@@ -504,0 +508,0 @@ parentItem[ENTITY] = deepClone(parentItem[ENTITY], item[ENTITY], true); |
Sorry, the diff of this file is too big to display
242675
5545