Skip to content
Snippets Groups Projects
Commit ab6e8c26 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

Release 1.23.0

parent 9df2e110
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 25 deletions
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsArray extends AbstractConstraint{isValid(s){return isArray(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsArray);export{Monster,IsArray}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsArray extends AbstractConstraint{isValid(s){return isArray(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsArray);export{Monster,IsArray};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsObject extends AbstractConstraint{isValid(s){return isObject(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsObject);export{Monster,IsObject}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{AbstractConstraint}from"./abstract.js";class IsObject extends AbstractConstraint{isValid(s){return isObject(s)?Promise.resolve(s):Promise.reject(s)}}assignToNamespace("Monster.Constraints",IsObject);export{Monster,IsObject};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Constraints";export{namespace}; "use strict";const namespace="Monster.Constraints";export{namespace};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class OrOperator extends AbstractOperator{isValid(s){var o=this;return new Promise(function(t,r){let a,e;o.operantA.isValid(s).then(function(){t()}).catch(function(){(a=!1)===e&&r()}),o.operantB.isValid(s).then(function(){t()}).catch(function(){(e=!1)===a&&r()})})}}assignToNamespace("Monster.Constraints",OrOperator);export{Monster,OrOperator}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractOperator}from"./abstractoperator.js";class OrOperator extends AbstractOperator{isValid(s){var o=this;return new Promise(function(t,r){let a,e;o.operantA.isValid(s).then(function(){t()}).catch(function(){(a=!1)===e&&r()}),o.operantB.isValid(s).then(function(){t()}).catch(function(){(e=!1)===a&&r()})})}}assignToNamespace("Monster.Constraints",OrOperator);export{Monster,OrOperator};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Valid extends AbstractConstraint{isValid(s){return Promise.resolve(s)}}assignToNamespace("Monster.Constraints",Valid);export{Monster,Valid}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{AbstractConstraint}from"./abstract.js";class Valid extends AbstractConstraint{isValid(s){return Promise.resolve(s)}}assignToNamespace("Monster.Constraints",Valid);export{Monster,Valid};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isFunction,isObject,isString}from"../types/is.js";import{validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{DELIMITER,Pathfinder,WILDCARD}from"./pathfinder.js";function buildMap(t,e,a,n,r){const o=new Map;let i;if(isFunction(e)){if(i=e(t),!(i instanceof Map))throw new TypeError("the selector callback must return a map")}else{if(!isString(e))throw new TypeError("value is neither a string nor a function");i=new Map,buildFlatMap.call(i,t,e)}return i instanceof Map&&i.forEach((t,e,i)=>{isFunction(r)&&!0!==r.call(i,t,e)||(e=build(t,n,e),t=build(t,a),o.set(e,t))}),o}function buildFlatMap(i,t,a,n){var r=this;const o=new Map;var e=r.size;void 0===a&&(a=[]);let l=t.split(DELIMITER),s,p=[];do{if(s=l.shift(),p.push(s),s===WILDCARD){let t=new Pathfinder(i),e;try{e=t.getVia(p.join(DELIMITER))}catch(t){e=new Map}for(const[d,h]of e){let e=clone(a);p.map(t=>{e.push(t===WILDCARD?d:t)});var c=e.join(DELIMITER);let t=buildFlatMap.call(r,h,l.join(DELIMITER),e,h);isObject(t)&&(t["^"]=n),o.set(c,t)}}}while(0<l.length);if(e===r.size)for(var[f,u]of o)r.set(f,u);return i}function build(t,a,n){if(void 0===a)return n||t;validateString(a);const e=[...a.matchAll(/(?<placeholder>\${(?<path>[a-z\^A-Z.\-_0-9]*)})/gm)];let r=new Pathfinder(t);return 0===e.length?r.getVia(a):(e.forEach(e=>{var i=e?.groups,e=i?.placeholder;if(void 0!==e){i=i?.path;let t=r.getVia(i);void 0===t&&(t=n),a=a.replaceAll(e,t)}}),a)}assignToNamespace("Monster.Data",buildMap);export{Monster,buildMap}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isFunction,isObject,isString}from"../types/is.js";import{validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{DELIMITER,Pathfinder,WILDCARD}from"./pathfinder.js";function buildMap(t,e,a,n,r){const o=new Map;let i;if(isFunction(e)){if(i=e(t),!(i instanceof Map))throw new TypeError("the selector callback must return a map")}else{if(!isString(e))throw new TypeError("value is neither a string nor a function");i=new Map,buildFlatMap.call(i,t,e)}return i instanceof Map&&i.forEach((t,e,i)=>{isFunction(r)&&!0!==r.call(i,t,e)||(e=build(t,n,e),t=build(t,a),o.set(e,t))}),o}function buildFlatMap(i,t,a,n){var r=this;const o=new Map;var e=r.size;void 0===a&&(a=[]);let l=t.split(DELIMITER),s,p=[];do{if(s=l.shift(),p.push(s),s===WILDCARD){let t=new Pathfinder(i),e;try{e=t.getVia(p.join(DELIMITER))}catch(t){e=new Map}for(const[d,h]of e){let e=clone(a);p.map(t=>{e.push(t===WILDCARD?d:t)});var c=e.join(DELIMITER);let t=buildFlatMap.call(r,h,l.join(DELIMITER),e,h);isObject(t)&&(t["^"]=n),o.set(c,t)}}}while(0<l.length);if(e===r.size)for(var[f,u]of o)r.set(f,u);return i}function build(t,a,n){if(void 0===a)return n||t;validateString(a);const e=[...a.matchAll(/(?<placeholder>\${(?<path>[a-z\^A-Z.\-_0-9]*)})/gm)];let r=new Pathfinder(t);return 0===e.length?r.getVia(a):(e.forEach(e=>{var i=e?.groups,e=i?.placeholder;if(void 0!==e){i=i?.path;let t=r.getVia(i);void 0===t&&(t=n),a=a.replaceAll(e,t)}}),a)}assignToNamespace("Monster.Data",buildMap);export{Monster,buildMap};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{PROPERTY_KEY_INTERNALDATA}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{parseDataURL}from"../types/dataurl.js";import{isString}from"../types/is.js";import{clone}from"../util/clone.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateObject}from"../types/validate.js";import{extend}from"./extend.js";import{Pathfinder}from"./pathfinder.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class Datasource extends Base{constructor(){super(),this[internalDataSymbol]=new ProxyObserver({options:extend({},this.defaults),data:void 0})}get defaults(){return{}}setOption(t,e){return new Pathfinder(this[internalDataSymbol].getSubject().options).setVia(t,e),this}setOptions(t){isString(t)&&(t=parseOptionsJSON(t));var e=this;return extend(e[internalDataSymbol].getSubject().options,e.defaults,t),e}getOption(t,e){let r;try{r=new Pathfinder(this[internalDataSymbol].getRealSubject().options).getVia(t)}catch(t){}return void 0===r?e:r}read(){throw new Error("this method must be implemented by derived classes")}write(){throw new Error("this method must be implemented by derived classes")}get(){return clone(this[internalDataSymbol].getRealSubject().data)}set(t){return this[internalDataSymbol].getSubject().data=t,this}}function parseOptionsJSON(e){if(isString(e)){try{e=parseDataURL(e).content}catch(t){}try{var t=JSON.parse(e);return validateObject(t),t}catch(t){throw new Error("the options does not contain a valid json definition (actual: "+e+").")}}return{}}assignToNamespace("Monster.Data",Datasource);export{Monster,Datasource}; "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{parseDataURL}from"../types/dataurl.js";import{isString}from"../types/is.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateObject}from"../types/validate.js";import{extend}from"./extend.js";import{Pathfinder}from"./pathfinder.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class Datasource extends Base{constructor(){super(),this[internalDataSymbol]=new ProxyObserver({options:extend({},this.defaults),data:void 0})}get defaults(){return{}}setOption(t,e){return new Pathfinder(this[internalDataSymbol].getSubject().options).setVia(t,e),this}setOptions(t){isString(t)&&(t=parseOptionsJSON(t));var e=this;return extend(e[internalDataSymbol].getSubject().options,e.defaults,t),e}getOption(t,e){let r;try{r=new Pathfinder(this[internalDataSymbol].getRealSubject().options).getVia(t)}catch(t){}return void 0===r?e:r}read(){throw new Error("this method must be implemented by derived classes")}write(){throw new Error("this method must be implemented by derived classes")}get(){return this[internalDataSymbol].getSubject().data}set(t){return this[internalDataSymbol].getSubject().data=t,this}}function parseOptionsJSON(e){if(isString(e)){try{e=parseDataURL(e).content}catch(t){}try{var t=JSON.parse(e);return validateObject(t),t}catch(t){throw new Error("the options does not contain a valid json definition (actual: "+e+").")}}return{}}assignToNamespace("Monster.Data",Datasource);export{Monster,Datasource};
\ No newline at end of file \ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Data.Datasource";export{namespace}; "use strict";const namespace="Monster.Data.Datasource";export{namespace};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../../namespace.js";import{isObject}from"../../types/is.js";import{Datasource}from"../datasource.js";class RestAPI extends Datasource{constructor(t,e){super();const s={};isObject(t)&&(s.read=t),isObject(e)&&(s.write=e),this.setOptions(s)}get defaults(){return Object.assign({},super.defaults,{write:{init:{method:"POST"},acceptedStatus:[200,201],url:void 0},read:{init:{method:"GET"},acceptedStatus:[200],url:void 0}})}read(){const s=this;let r,t=s.getOption("read.init");return isObject(t)||(t={}),fetch(s.getOption("read.url"),t).then(t=>{r=t;const e=s.getOption("read.acceptedStatus",[200]);if(-1===e.indexOf(t.status))throw Error("the data cannot be read (response "+t.status+")");return t.text()}).then(e=>{let t;try{t=JSON.parse(e)}catch(t){throw 100<e.length&&(e=e.substring(0,97)+"..."),new Error("the response does not contain a valid json (actual: "+e+").")}return s.set(t),r})}write(){const s=this;let t=s.getOption("write.init");return isObject(t)||(t={}),"object"!=typeof t.headers&&(t.headers={"Content-Type":"application/json"}),t.body=JSON.stringify(s.get()),fetch(s.getOption("write.url"),t).then(t=>{const e=s.getOption("write.acceptedStatus",[200,2001]);if(-1===e.indexOf(t.status))throw Error("the data cannot be written (response "+t.status+")");return t})}}assignToNamespace("Monster.Data.Datasource",RestAPI);export{Monster,RestAPI}; "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../../constants.js";import{assignToNamespace,Monster}from"../../namespace.js";import{isObject}from"../../types/is.js";import{Datasource}from"../datasource.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class RestAPI extends Datasource{constructor(t,e){super();const s={};isObject(t)&&(s.read=t),isObject(e)&&(s.write=e),this.setOptions(s)}get defaults(){return Object.assign({},super.defaults,{write:{init:{method:"POST"},acceptedStatus:[200,201],url:void 0},read:{init:{method:"GET"},acceptedStatus:[200],url:void 0}})}read(){const s=this;let r,t=s.getOption("read.init");return isObject(t)||(t={}),fetch(s.getOption("read.url"),t).then(t=>{r=t;const e=s.getOption("read.acceptedStatus",[200]);if(-1===e.indexOf(t.status))throw Error("the data cannot be read (response "+t.status+")");return t.text()}).then(e=>{let t;try{t=JSON.parse(e)}catch(t){throw 100<e.length&&(e=e.substring(0,97)+"..."),new Error("the response does not contain a valid json (actual: "+e+").")}return s.set(t),r})}write(){const s=this;let t=s.getOption("write.init");return isObject(t)||(t={}),"object"!=typeof t.headers&&(t.headers={"Content-Type":"application/json"}),t.body=JSON.stringify(s.get()),fetch(s.getOption("write.url"),t).then(t=>{const e=s.getOption("write.acceptedStatus",[200,2001]);if(-1===e.indexOf(t.status))throw Error("the data cannot be written (response "+t.status+")");return t})}getClone(){return new RestAPI(this[internalDataSymbol].getRealSubject().options.read,this[internalDataSymbol].getRealSubject().options.write)}}assignToNamespace("Monster.Data.Datasource",RestAPI);export{Monster,RestAPI};
\ No newline at end of file \ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../../namespace.js";import{validateString}from"../../types/validate.js";import{Datasource}from"../datasource.js";const storageObjectSymbol=Symbol("storageObject");class Storage extends Datasource{constructor(e){super(),this.setOption("key",validateString(e))}get defaults(){return Object.assign({},super.defaults,{key:void 0})}[storageObjectSymbol](){throw new Error("this method must be implemented by derived classes")}read(){const s=this,o=s[storageObjectSymbol]();return new Promise(function(e){var t=JSON.parse(o.getItem(s.getOption("key")));s.set(t),e()})}write(){const t=this,s=t[storageObjectSymbol]();return new Promise(function(e){void 0===t.get()?s.removeItem(t.getOption("key")):s.setItem(t.getOption("key"),JSON.stringify(t.get())),e()})}}assignToNamespace("Monster.Data.Datasource",Storage);export{Monster,Storage,storageObjectSymbol}; "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../../constants.js";import{assignToNamespace,Monster}from"../../namespace.js";import{validateString}from"../../types/validate.js";import{Datasource}from"../datasource.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA),storageObjectSymbol=Symbol("storageObject");class Storage extends Datasource{constructor(e){super(),this.setOption("key",validateString(e))}get defaults(){return Object.assign({},super.defaults,{key:void 0})}[storageObjectSymbol](){throw new Error("this method must be implemented by derived classes")}read(){const o=this,s=o[storageObjectSymbol]();return new Promise(function(e){var t=JSON.parse(s.getItem(o.getOption("key")));o.set(t),e()})}write(){const t=this,o=t[storageObjectSymbol]();return new Promise(function(e){void 0===t.get()?o.removeItem(t.getOption("key")):o.setItem(t.getOption("key"),JSON.stringify(t.get())),e()})}getClone(){return new Storage(this[internalDataSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource",Storage);export{Monster,Storage,storageObjectSymbol};
\ No newline at end of file \ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";class LocalStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("localStorage")}}assignToNamespace("Monster.Data.Datasource.Storage",LocalStorage);export{Monster,LocalStorage}; "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../../../constants.js";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class LocalStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("localStorage")}getClone(){return new LocalStorage(this[internalDataSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource.Storage",LocalStorage);export{Monster,LocalStorage};
\ No newline at end of file \ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Data.Datasource.Storage";export{namespace}; "use strict";const namespace="Monster.Data.Datasource.Storage";export{namespace};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";class SessionStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("sessionStorage")}}assignToNamespace("Monster.Data.Datasource.Storage",SessionStorage);export{Monster,SessionStorage}; "use strict";import{PROPERTY_KEY_INTERNALDATA}from"../../../constants.js";import{assignToNamespace,Monster}from"../../../namespace.js";import{getGlobalObject}from"../../../types/global.js";import{Datasource}from"../../datasource.js";import{Storage,storageObjectSymbol}from"../storage.js";const internalDataSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class SessionStorage extends Storage{[storageObjectSymbol](){return getGlobalObject("sessionStorage")}getClone(){return new SessionStorage(this[internalDataSymbol].getRealSubject().options.key)}}assignToNamespace("Monster.Data.Datasource.Storage",SessionStorage);export{Monster,SessionStorage};
\ No newline at end of file \ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function Diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeOf(t),s=typeOf(n);const a=e||[],i=o||[];return r!==s||"object"!==r&&"array"!==r?void 0!==(s=getOperator(t,n,r,s))&&i.push(buildResult(t,n,s,e)):getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],a.concat(e),i):i.push(buildResult(t[e],n[e],"delete",a.concat(e))):i.push(buildResult(t[e],n[e],"add",a.concat(e)))}),i}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}assignToNamespace("Monster.Data",Diff);export{Monster,Diff}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function Diff(e,t){return doDiff(e,t)}function getKeys(e,t,n){if(isArray(n)){const o=e.length>t.length?new Array(e.length):new Array(t.length);return o.fill(0),new Set(o.map((e,t)=>t))}return new Set(Object.keys(e).concat(Object.keys(t)))}function doDiff(t,n,e,o){var r=typeOf(t),s=typeOf(n);const a=e||[],i=o||[];return r!==s||"object"!==r&&"array"!==r?void 0!==(s=getOperator(t,n,r,s))&&i.push(buildResult(t,n,s,e)):getKeys(t,n,r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)?Object.prototype.hasOwnProperty.call(n,e)?doDiff(t[e],n[e],a.concat(e),i):i.push(buildResult(t[e],n[e],"delete",a.concat(e))):i.push(buildResult(t[e],n[e],"add",a.concat(e)))}),i}function buildResult(e,t,n,o){const r={operator:n,path:o};return"add"!==n&&(r.first={value:e,type:typeof e},!isObject(e)||void 0!==(e=Object.getPrototypeOf(e)?.constructor?.name)&&(r.first.instance=e)),"add"!==n&&"update"!==n||(r.second={value:t,type:typeof t},!isObject(t)||void 0!==(t=Object.getPrototypeOf(t)?.constructor?.name)&&(r.second.instance=t)),r}function isNotEqual(e,t){return typeof e!=typeof t||(e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():e!==t)}function getOperator(e,t){let n;var o=typeof e,r=typeof t;return"undefined"==o&&"undefined"!=r?n="add":"undefined"!=o&&"undefined"==r?n="delete":isNotEqual(e,t)&&(n="update"),n}assignToNamespace("Monster.Data",Diff);export{Monster,Diff};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function extend(){let e,t;for(t=0;t<arguments.length;t++){var r=arguments[t];if(!isObject(r)&&!isArray(r))throw new Error("unsupported argument "+JSON.stringify(r));if(void 0!==e)for(var s in r){var i=r?.[s];if(i!==e?.[s])if(isObject(i)&&"object"===typeOf(i)||isArray(i)){if(void 0===e[s])isArray(i)?e[s]=[]:e[s]={};else if(typeOf(e[s])!==typeOf(i))throw new Error("type mismatch: "+JSON.stringify(e[s])+"("+typeOf(e[s])+") != "+JSON.stringify(i)+"("+typeOf(i)+")");e[s]=extend(e[s],i)}else e[s]=i}else e=r}return e}assignToNamespace("Monster.Data",extend);export{Monster,extend}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isObject}from"../types/is.js";import{typeOf}from"../types/typeof.js";function extend(){let e,t;for(t=0;t<arguments.length;t++){var r=arguments[t];if(!isObject(r)&&!isArray(r))throw new Error("unsupported argument "+JSON.stringify(r));if(void 0!==e)for(var s in r){var i=r?.[s];if(i!==e?.[s])if(isObject(i)&&"object"===typeOf(i)||isArray(i)){if(void 0===e[s])isArray(i)?e[s]=[]:e[s]={};else if(typeOf(e[s])!==typeOf(i))throw new Error("type mismatch: "+JSON.stringify(e[s])+"("+typeOf(e[s])+") != "+JSON.stringify(i)+"("+typeOf(i)+")");e[s]=extend(e[s],i)}else e[s]=i}else e=r}return e}assignToNamespace("Monster.Data",extend);export{Monster,extend};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Data";export{namespace}; "use strict";const namespace="Monster.Data";export{namespace};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInteger,isObject,isPrimitive}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInteger,validateString}from"../types/validate.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){if(super(),isPrimitive(t))throw new Error("the parameter must not be a simple type");this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a&&!e.hasOwnProperty(r))throw Error("unknown value");return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}assignToNamespace("Monster.Data",Pathfinder);export{DELIMITER,WILDCARD,Monster,Pathfinder}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isArray,isInteger,isObject,isPrimitive}from"../types/is.js";import{Stack}from"../types/stack.js";import{validateInteger,validateString}from"../types/validate.js";const DELIMITER=".",WILDCARD="*";class Pathfinder extends Base{constructor(t){if(super(),isPrimitive(t))throw new Error("the parameter must not be a simple type");this.object=t,this.wildCard=WILDCARD}setWildCard(t){return validateString(t),this.wildCard=t,this}getVia(t){return getValueViaPath.call(this,this.object,validateString(t))}setVia(t,e){return validateString(t),setValueViaPath.call(this,this.object,t,e),this}deleteVia(t){return validateString(t),deleteValueViaPath.call(this,this.object,t),this}exists(t){validateString(t);try{return getValueViaPath.call(this,this.object,t,!0),!0}catch(t){}return!1}}function iterate(t,e,a){const i=new Map;if(isObject(t)||isArray(t))for(var[r,s]of Object.entries(t))i.set(r,getValueViaPath.call(this,s,e,a));else{var n=e.split(DELIMITER).shift();i.set(n,getValueViaPath.call(this,t,e,a))}return i}function getValueViaPath(e,t,a){if(""===t)return e;let i=t.split(DELIMITER),r=i.shift();if(r===this.wildCard)return iterate.call(this,e,i.join(DELIMITER),a);if(isObject(e)||isArray(e)){let t;if(e instanceof Map||e instanceof WeakMap)t=e.get(r);else if(e instanceof Set||e instanceof WeakSet)r=parseInt(r),validateInteger(r),t=[...e][r];else{if("function"==typeof WeakRef&&e instanceof WeakRef)throw Error("unsupported action for this data type");t=(isArray(e)&&(r=parseInt(r),validateInteger(r)),e?.[r])}if(isObject(t)||isArray(t))return getValueViaPath.call(this,t,i.join(DELIMITER),a);if(0<i.length)throw Error("the journey is not at its end ("+i.join(DELIMITER)+")");if(!0===a&&!e.hasOwnProperty(r))throw Error("unknown value");return t}throw TypeError("unsupported type "+typeof e)}function setValueViaPath(e,t,a){validateString(t);let i=t.split(DELIMITER),r=i.pop();var s,t=i.join(DELIMITER);let n=new Stack,o=t;for(;;){try{getValueViaPath.call(this,e,o,!0);break}catch(t){}if(n.push(o),i.pop(),o=i.join(DELIMITER),""===o)break}for(;!n.isEmpty();){o=n.pop();let t={};n.isEmpty()||(s=n.peek().split(DELIMITER).pop(),isInteger(parseInt(s))&&(t=[])),setValueViaPath.call(this,e,o,t)}let l=getValueViaPath.call(this,e,t);if(!isObject(e)&&!isArray(e))throw TypeError("unsupported type: "+typeof e);if(l instanceof Map||l instanceof WeakMap)l.set(r,a);else if(l instanceof Set||l instanceof WeakSet)l.append(a);else{if("function"==typeof WeakRef&&l instanceof WeakRef)throw Error("unsupported action for this data type");isArray(l)&&(r=parseInt(r),validateInteger(r)),assignProperty(l,r,a)}}function assignProperty(t,e,a){t.hasOwnProperty(e)&&void 0===a&&delete t[e],t[e]=a}function deleteValueViaPath(t,e){const a=e.split(DELIMITER);let i=a.pop();e=a.join(DELIMITER);const r=getValueViaPath.call(this,t,e);if(r instanceof Map)r.delete(i);else{if(r instanceof Set||r instanceof WeakMap||r instanceof WeakSet||"function"==typeof WeakRef&&r instanceof WeakRef)throw Error("unsupported action for this data type");isArray(r)&&(i=parseInt(i),validateInteger(i)),delete r[i]}}assignToNamespace("Monster.Data",Pathfinder);export{DELIMITER,WILDCARD,Monster,Pathfinder};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateString}from"../types/validate.js";import{Transformer}from"./transformer.js";const DELIMITER="|";class Pipe extends Base{constructor(e){super(),validateString(e),this.pipe=e.split(DELIMITER).map(e=>new Transformer(e))}setCallback(e,s,r){for(var[,t]of Object.entries(this.pipe))t.setCallback(e,s,r);return this}run(e){return this.pipe.reduce((e,s,r,t)=>s.run(e),e)}}assignToNamespace("Monster.Data",Pipe);export{Monster,Pipe}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateString}from"../types/validate.js";import{Transformer}from"./transformer.js";const DELIMITER="|";class Pipe extends Base{constructor(e){super(),validateString(e),this.pipe=e.split(DELIMITER).map(e=>new Transformer(e))}setCallback(e,s,r){for(var[,t]of Object.entries(this.pipe))t.setCallback(e,s,r);return this}run(e){return this.pipe.reduce((e,s,r,t)=>s.run(e),e)}}assignToNamespace("Monster.Data",Pipe);export{Monster,Pipe};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobal}from"../types/global.js";import{ID}from"../types/id.js";import{isArray,isObject,isString}from"../types/is.js";import{validateFunction,validateInteger,validateObject,validatePrimitive,validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{Pathfinder}from"./pathfinder.js";class Transformer extends Base{constructor(e){super(),validateString(e),this.args=disassemble(e),this.command=this.args.shift(),this.callbacks=new Map}setCallback(e,t,r){return validateString(e),validateFunction(t),void 0!==r&&validateObject(r),this.callbacks.set(e,{callback:t,context:r}),this}run(e){return transform.apply(this,[e])}}function disassemble(e){validateString(e);let a=new Map;var t;for(t of e.matchAll(/((?<pattern>\\(?<char>.)){1})/gim)){var r,s,n=t?.groups;isObject(n)&&(s=n?.char,(r=n?.pattern)&&s&&(n="__"+(new ID).toString()+"__",a.set(n,s),e=e.replace(r,n)))}let i=e.split(":");return i=i.map(function(e){let t=e.trim();for(var r of a)t=t.replace(r[0],r[1]);return t}),i}function convertToString(e){return isObject(e)&&e.hasOwnProperty("toString")&&(e=e.toString()),validateString(e),e}function transform(s){let n=clone(this.args),i;switch(this.command){case"static":return this.args.join(":");case"tolower":case"strtolower":case"tolowercase":return validateString(s),s.toLowerCase();case"toupper":case"strtoupper":case"touppercase":return validateString(s),s.toUpperCase();case"tostring":return""+s;case"tointeger":var o=parseInt(s);return validateInteger(o),o;case"tojson":return JSON.stringify(s);case"fromjson":return JSON.parse(s);case"trim":return validateString(s),s.trim();case"rawurlencode":return validateString(s),encodeURIComponent(s).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A");case"call":let e;var c=n.shift();let t=getGlobal();return isObject(s)&&s.hasOwnProperty(c)?e=s[c]:this.callbacks.has(c)?(o=this.callbacks.get(c),e=o?.callback,t=o?.context):"object"==typeof window&&window.hasOwnProperty(c)&&(e=window[c]),validateFunction(e),n.unshift(s),e.call(t,...n);case"plain":case"plaintext":return validateString(s),(new DOMParser).parseFromString(s,"text/html").body.textContent||"";case"if":case"?":validatePrimitive(s);let r=n.shift()||void 0,a=n.shift()||void 0;return"value"===r&&(r=s),"\\value"===r&&(r="value"),"value"===a&&(a=s),"\\value"===a&&(a="value"),void 0!==s&&""!==s&&"off"!==s&&"false"!==s&&!1!==s||"on"===s||"true"===s||!0===s?r:a;case"ucfirst":return validateString(s),s.charAt(0).toUpperCase()+s.substr(1);case"ucwords":return validateString(s),s.replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g,function(e){return e.toUpperCase()});case"count":case"length":if((isString(s)||isObject(s)||isArray(s))&&s.hasOwnProperty("length"))return s.length;throw new TypeError("unsupported type "+typeof s);case"base64":return convertToString(s),btoa(s);case"empty":return"";case"undefined":return;case"prefix":return validateString(s),n?.[0]+s;case"suffix":return validateString(s),s+n?.[0];case"uniqid":return(new ID).toString();case"key":case"property":case"index":i=n.shift()||"undefined";var l=n.shift()||"";if(s instanceof Map)return s.has(i)?s.get(i):l;if(isObject(s)||isArray(s))return s?.[i]||l;throw new Error("type not supported");case"path":return i=n.shift()||"undefined",new Pathfinder(s).getVia(i);case"substring":validateString(s);c=parseInt(n[0])||0,l=(parseInt(n[1])||0)+c;return s.substring(c,l);case"nop":return s;case"default":return void 0!==s?s:n[0];default:throw new Error("unknown command "+this.command)}return s}assignToNamespace("Monster.Data",Transformer);export{Monster,Transformer}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobal}from"../types/global.js";import{ID}from"../types/id.js";import{isArray,isObject,isString}from"../types/is.js";import{validateFunction,validateInteger,validateObject,validatePrimitive,validateString}from"../types/validate.js";import{clone}from"../util/clone.js";import{Pathfinder}from"./pathfinder.js";class Transformer extends Base{constructor(e){super(),validateString(e),this.args=disassemble(e),this.command=this.args.shift(),this.callbacks=new Map}setCallback(e,t,r){return validateString(e),validateFunction(t),void 0!==r&&validateObject(r),this.callbacks.set(e,{callback:t,context:r}),this}run(e){return transform.apply(this,[e])}}function disassemble(e){validateString(e);let a=new Map;var t;for(t of e.matchAll(/((?<pattern>\\(?<char>.)){1})/gim)){var r,s,n=t?.groups;isObject(n)&&(s=n?.char,(r=n?.pattern)&&s&&(n="__"+(new ID).toString()+"__",a.set(n,s),e=e.replace(r,n)))}let i=e.split(":");return i=i.map(function(e){let t=e.trim();for(var r of a)t=t.replace(r[0],r[1]);return t}),i}function convertToString(e){return isObject(e)&&e.hasOwnProperty("toString")&&(e=e.toString()),validateString(e),e}function transform(s){let n=clone(this.args),i;switch(this.command){case"static":return this.args.join(":");case"tolower":case"strtolower":case"tolowercase":return validateString(s),s.toLowerCase();case"toupper":case"strtoupper":case"touppercase":return validateString(s),s.toUpperCase();case"tostring":return""+s;case"tointeger":var o=parseInt(s);return validateInteger(o),o;case"tojson":return JSON.stringify(s);case"fromjson":return JSON.parse(s);case"trim":return validateString(s),s.trim();case"rawurlencode":return validateString(s),encodeURIComponent(s).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A");case"call":let e;var c=n.shift();let t=getGlobal();return isObject(s)&&s.hasOwnProperty(c)?e=s[c]:this.callbacks.has(c)?(o=this.callbacks.get(c),e=o?.callback,t=o?.context):"object"==typeof window&&window.hasOwnProperty(c)&&(e=window[c]),validateFunction(e),n.unshift(s),e.call(t,...n);case"plain":case"plaintext":return validateString(s),(new DOMParser).parseFromString(s,"text/html").body.textContent||"";case"if":case"?":validatePrimitive(s);let r=n.shift()||void 0,a=n.shift()||void 0;return"value"===r&&(r=s),"\\value"===r&&(r="value"),"value"===a&&(a=s),"\\value"===a&&(a="value"),void 0!==s&&""!==s&&"off"!==s&&"false"!==s&&!1!==s||"on"===s||"true"===s||!0===s?r:a;case"ucfirst":return validateString(s),s.charAt(0).toUpperCase()+s.substr(1);case"ucwords":return validateString(s),s.replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g,function(e){return e.toUpperCase()});case"count":case"length":if((isString(s)||isObject(s)||isArray(s))&&s.hasOwnProperty("length"))return s.length;throw new TypeError("unsupported type "+typeof s);case"base64":return convertToString(s),btoa(s);case"empty":return"";case"undefined":return;case"prefix":return validateString(s),n?.[0]+s;case"suffix":return validateString(s),s+n?.[0];case"uniqid":return(new ID).toString();case"key":case"property":case"index":i=n.shift()||"undefined";var l=n.shift()||"";if(s instanceof Map)return s.has(i)?s.get(i):l;if(isObject(s)||isArray(s))return s?.[i]||l;throw new Error("type not supported");case"path":return i=n.shift()||"undefined",new Pathfinder(s).getVia(i);case"substring":validateString(s);c=parseInt(n[0])||0,l=(parseInt(n[1])||0)+c;return s.substring(c,l);case"nop":return s;case"default":return void 0!==s?s:n[0];default:throw new Error("unknown command "+this.command)}return s}assignToNamespace("Monster.Data",Transformer);export{Monster,Transformer};
\ No newline at end of file
/** Monster 1.22.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.23.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateInstance,validateString}from"../types/validate.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler}; "use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";import{validateInstance,validateString}from"../types/validate.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment