@graffiti-garden/wrapper-synchronize 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +0,0 @@
1
- import{b as K,c as _,d as A,e as d}from"./chunk-POQWWD2G.js";_();d();A();var M={};K(M,{JsonPatchError:()=>p,_areEquals:()=>P,applyOperation:()=>E,applyPatch:()=>C,applyReducer:()=>Z,deepClone:()=>X,getValueByPointer:()=>D,validate:()=>z,validator:()=>L});_();d();A();_();d();A();var G=function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,f){n.__proto__=f}||function(n,f){for(var o in f)f.hasOwnProperty(o)&&(n[o]=f[o])},e(r,t)};return function(r,t){e(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),W=Object.prototype.hasOwnProperty;function g(e,r){return W.call(e,r)}function R(e){if(Array.isArray(e)){for(var r=new Array(e.length),t=0;t<r.length;t++)r[t]=""+t;return r}if(Object.keys)return Object.keys(e);var n=[];for(var f in e)g(e,f)&&n.push(f);return n}function h(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function I(e){for(var r=0,t=e.length,n;r<t;){if(n=e.charCodeAt(r),n>=48&&n<=57){r++;continue}return!1}return!0}function O(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function T(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function m(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var r=0,t=e.length;r<t;r++)if(m(e[r]))return!0}else if(typeof e=="object"){for(var n=R(e),f=n.length,o=0;o<f;o++)if(m(e[n[o]]))return!0}}return!1}function Y(e,r){var t=[e];for(var n in r){var f=typeof r[n]=="object"?JSON.stringify(r[n],null,2):r[n];typeof f<"u"&&t.push(n+": "+f)}return t.join(`
2
- `)}var N=function(e){G(r,e);function r(t,n,f,o,s){var i=this.constructor,l=e.call(this,Y(t,{name:n,index:f,operation:o,tree:s}))||this;return l.name=n,l.index=f,l.operation=o,l.tree=s,Object.setPrototypeOf(l,i.prototype),l.message=Y(t,{name:n,index:f,operation:o,tree:s}),l}return r}(Error);var p=N,X=h,y={add:function(e,r,t){return e[r]=this.value,{newDocument:t}},remove:function(e,r,t){var n=e[r];return delete e[r],{newDocument:t,removed:n}},replace:function(e,r,t){var n=e[r];return e[r]=this.value,{newDocument:t,removed:n}},move:function(e,r,t){var n=D(t,this.path);n&&(n=h(n));var f=E(t,{op:"remove",path:this.from}).removed;return E(t,{op:"add",path:this.path,value:f}),{newDocument:t,removed:n}},copy:function(e,r,t){var n=D(t,this.from);return E(t,{op:"add",path:this.path,value:h(n)}),{newDocument:t}},test:function(e,r,t){return{newDocument:t,test:P(e[r],this.value)}},_get:function(e,r,t){return this.value=e[r],{newDocument:t}}},q={add:function(e,r,t){return I(r)?e.splice(r,0,this.value):e[r]=this.value,{newDocument:t,index:r}},remove:function(e,r,t){var n=e.splice(r,1);return{newDocument:t,removed:n[0]}},replace:function(e,r,t){var n=e[r];return e[r]=this.value,{newDocument:t,removed:n}},move:y.move,copy:y.copy,test:y.test,_get:y._get};function D(e,r){if(r=="")return e;var t={op:"_get",path:r};return E(e,t),t.value}function E(e,r,t,n,f,o){if(t===void 0&&(t=!1),n===void 0&&(n=!0),f===void 0&&(f=!0),o===void 0&&(o=0),t&&(typeof t=="function"?t(r,0,e,r.path):L(r,0)),r.path===""){var s={newDocument:e};if(r.op==="add")return s.newDocument=r.value,s;if(r.op==="replace")return s.newDocument=r.value,s.removed=e,s;if(r.op==="move"||r.op==="copy")return s.newDocument=D(e,r.from),r.op==="move"&&(s.removed=e),s;if(r.op==="test"){if(s.test=P(e,r.value),s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s.newDocument=e,s}else{if(r.op==="remove")return s.removed=e,s.newDocument=null,s;if(r.op==="_get")return r.value=e,s;if(t)throw new p("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,r,e);return s}}else{n||(e=h(e));var i=r.path||"",l=i.split("/"),u=e,a=1,c=l.length,w=void 0,v=void 0,x=void 0;for(typeof t=="function"?x=t:x=L;;){if(v=l[a],v&&v.indexOf("~")!=-1&&(v=T(v)),f&&(v=="__proto__"||v=="prototype"&&a>0&&l[a-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&w===void 0&&(u[v]===void 0?w=l.slice(0,a).join("/"):a==c-1&&(w=r.path),w!==void 0&&x(r,0,e,w)),a++,Array.isArray(u)){if(v==="-")v=u.length;else{if(t&&!I(v))throw new p("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,r,e);I(v)&&(v=~~v)}if(a>=c){if(t&&r.op==="add"&&v>u.length)throw new p("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,r,e);var s=q[r.op].call(r,u,v,e);if(s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s}}else if(a>=c){var s=y[r.op].call(r,u,v,e);if(s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s}if(u=u[v],t&&a<c&&(!u||typeof u!="object"))throw new p("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,r,e)}}}function C(e,r,t,n,f){if(n===void 0&&(n=!0),f===void 0&&(f=!0),t&&!Array.isArray(r))throw new p("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=h(e));for(var o=new Array(r.length),s=0,i=r.length;s<i;s++)o[s]=E(e,r[s],t,!0,f,s),e=o[s].newDocument;return o.newDocument=e,o}function Z(e,r,t){var n=E(e,r);if(n.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",t,r,e);return n.newDocument}function L(e,r,t,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new p("Operation is not an object","OPERATION_NOT_AN_OBJECT",r,e,t);if(y[e.op]){if(typeof e.path!="string")throw new p("Operation `path` property is not a string","OPERATION_PATH_INVALID",r,e,t);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new p('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",r,e,t);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new p("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&m(e.value))throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",r,e,t);if(t){if(e.op=="add"){var f=e.path.split("/").length,o=n.split("/").length;if(f!==o+1&&f!==o)throw new p("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",r,e,t)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new p("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",r,e,t)}else if(e.op==="move"||e.op==="copy"){var s={op:"_get",path:e.from,value:void 0},i=z([s],t);if(i&&i.name==="OPERATION_PATH_UNRESOLVABLE")throw new p("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",r,e,t)}}}else throw new p("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",r,e,t)}function z(e,r,t){try{if(!Array.isArray(e))throw new p("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(r)C(h(r),h(e),t||!0);else{t=t||L;for(var n=0;n<e.length;n++)t(e[n],n,r,void 0)}}catch(f){if(f instanceof p)return f;throw f}}function P(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){var t=Array.isArray(e),n=Array.isArray(r),f,o,s;if(t&&n){if(o=e.length,o!=r.length)return!1;for(f=o;f--!==0;)if(!P(e[f],r[f]))return!1;return!0}if(t!=n)return!1;var i=Object.keys(e);if(o=i.length,o!==Object.keys(r).length)return!1;for(f=o;f--!==0;)if(!r.hasOwnProperty(i[f]))return!1;for(f=o;f--!==0;)if(s=i[f],!P(e[s],r[s]))return!1;return!0}return e!==e&&r!==r}var Q={};K(Q,{compare:()=>te,generate:()=>H,observe:()=>re,unobserve:()=>ee});_();d();A();var B=new WeakMap,$=function(){function e(r){this.observers=new Map,this.obj=r}return e}(),j=function(){function e(r,t){this.callback=r,this.observer=t}return e}();function V(e){return B.get(e)}function b(e,r){return e.observers.get(r)}function k(e,r){e.observers.delete(r.callback)}function ee(e,r){r.unobserve()}function re(e,r){var t=[],n,f=V(e);if(!f)f=new $(e),B.set(e,f);else{var o=b(f,r);n=o&&o.observer}if(n)return n;if(n={},f.value=h(e),r){n.callback=r,n.next=null;var s=function(){H(n)},i=function(){clearTimeout(n.next),n.next=setTimeout(s)};typeof window<"u"&&(window.addEventListener("mouseup",i),window.addEventListener("keyup",i),window.addEventListener("mousedown",i),window.addEventListener("keydown",i),window.addEventListener("change",i))}return n.patches=t,n.object=e,n.unobserve=function(){H(n),clearTimeout(n.next),k(f,n),typeof window<"u"&&(window.removeEventListener("mouseup",i),window.removeEventListener("keyup",i),window.removeEventListener("mousedown",i),window.removeEventListener("keydown",i),window.removeEventListener("change",i))},f.observers.set(r,new j(r,n)),n}function H(e,r){r===void 0&&(r=!1);var t=B.get(e.object);F(t.value,e.object,e.patches,"",r),e.patches.length&&C(t.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function F(e,r,t,n,f){if(r!==e){typeof r.toJSON=="function"&&(r=r.toJSON());for(var o=R(r),s=R(e),i=!1,l=!1,u=s.length-1;u>=0;u--){var a=s[u],c=e[a];if(g(r,a)&&!(r[a]===void 0&&c!==void 0&&Array.isArray(r)===!1)){var w=r[a];typeof c=="object"&&c!=null&&typeof w=="object"&&w!=null&&Array.isArray(c)===Array.isArray(w)?F(c,w,t,n+"/"+O(a),f):c!==w&&(i=!0,f&&t.push({op:"test",path:n+"/"+O(a),value:h(c)}),t.push({op:"replace",path:n+"/"+O(a),value:h(w)}))}else Array.isArray(e)===Array.isArray(r)?(f&&t.push({op:"test",path:n+"/"+O(a),value:h(c)}),t.push({op:"remove",path:n+"/"+O(a)}),l=!0):(f&&t.push({op:"test",path:n,value:e}),t.push({op:"replace",path:n,value:r}),i=!0)}if(!(!l&&o.length==s.length))for(var u=0;u<o.length;u++){var a=o[u];!g(e,a)&&r[a]!==void 0&&t.push({op:"add",path:n+"/"+O(a),value:h(r[a])})}}}function te(e,r,t){t===void 0&&(t=!1);var n=[];return F(e,r,n,"",t),n}var _e=Object.assign({},M,Q,{JsonPatchError:N,deepClone:h,escapePathComponent:O,unescapePathComponent:T});export{N as JsonPatchError,P as _areEquals,E as applyOperation,C as applyPatch,Z as applyReducer,te as compare,h as deepClone,_e as default,O as escapePathComponent,H as generate,D as getValueByPointer,re as observe,T as unescapePathComponent,ee as unobserve,z as validate,L as validator};
3
- /*! Bundled license information:
4
-
5
- fast-json-patch/module/helpers.mjs:
6
- (*!
7
- * https://github.com/Starcounter-Jack/JSON-Patch
8
- * (c) 2017-2022 Joachim Wester
9
- * MIT licensed
10
- *)
11
-
12
- fast-json-patch/module/duplex.mjs:
13
- (*!
14
- * https://github.com/Starcounter-Jack/JSON-Patch
15
- * (c) 2017-2021 Joachim Wester
16
- * MIT license
17
- *)
18
- */
19
- //# sourceMappingURL=fast-json-patch-RVBYS6DB.js.map