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

#116

parent c3049ee8
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 27 deletions
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{Observer}from"./observer.js";import{validateInstance}from"./validate.js";class ObserverList extends Base{constructor(){super(),this.observers=[]}attach(e){return validateInstance(e,Observer),this.observers.push(e),this}detach(e){validateInstance(e,Observer);for(var s=0,r=this.observers.length;s<r;s++)this.observers[s]===e&&this.observers.splice(s,1);return this}contains(e){validateInstance(e,Observer);for(var s=0,r=this.observers.length;s<r;s++)if(this.observers[s]===e)return!0;return!1}notify(e){let s=[],r=0,t=this.observers.length;for(;r<t;r++)s.push(this.observers[r].update(e));return Promise.all(s)}}assignToNamespace("Monster.Types",ObserverList);export{Monster,ObserverList};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{Observer}from"./observer.js";import{validateInstance}from"./validate.js";class ObserverList extends Base{constructor(){super();this.observers=[]}attach(observer){validateInstance(observer,Observer);this.observers.push(observer);return this}detach(observer){validateInstance(observer,Observer);var i=0,l=this.observers.length;for(;i<l;i++){if(this.observers[i]===observer){this.observers.splice(i,1)}}return this}contains(observer){validateInstance(observer,Observer);var i=0,l=this.observers.length;for(;i<l;i++){if(this.observers[i]===observer){return true}}return false}notify(subject){let pomises=[];let i=0,l=this.observers.length;for(;i<l;i++){pomises.push(this.observers[i].update(subject))}return Promise.all(pomises)}}assignToNamespace("Monster.Types",ObserverList);export{Monster,ObserverList};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{isArray,isObject,isPrimitive}from"./is.js";import{Observer}from"./observer.js";import{ObserverList}from"./observerlist.js";import{validateObject}from"./validate.js";import{extend}from"../data/extend.js";class ProxyObserver extends Base{constructor(e){super(),this.realSubject=validateObject(e),this.subject=new Proxy(e,getHandler.call(this)),this.objectMap=new WeakMap,this.objectMap.set(this.realSubject,this.subject),this.proxyMap=new WeakMap,this.proxyMap.set(this.subject,this.realSubject),this.observers=new ObserverList}getSubject(){return this.subject}setSubject(e){let t,r=Object.keys(this.subject);for(t=0;t<r.length;t++)delete this.subject[r[t]];return this.subject=extend(this.subject,e),this}getRealSubject(){return this.realSubject}attachObserver(e){return this.observers.attach(e),this}detachObserver(e){return this.observers.detach(e),this}notifyObservers(){return this.observers.notify(this)}containsObserver(e){return this.observers.contains(e)}}function getHandler(){const a=this,s={get:function(e,t,r){e=Reflect.get(e,t,r);return"symbol"!=typeof t&&!isPrimitive(e)&&(isArray(e)||isObject(e))?a.objectMap.has(e)?a.objectMap.get(e):a.proxyMap.has(e)?e:(r=new Proxy(e,s),a.objectMap.set(e,r),a.proxyMap.set(r,e),r):e},set:function(e,t,r,s){a.proxyMap.has(r)&&(r=a.proxyMap.get(r)),a.proxyMap.has(e)&&(e=a.proxyMap.get(e));let o=Reflect.get(e,t,s);if(a.proxyMap.has(o)&&(o=a.proxyMap.get(o)),o===r)return!0;let i=Reflect.getOwnPropertyDescriptor(e,t);return void 0===i&&(i={writable:!0,enumerable:!0,configurable:!0}),i.value=r,s=Reflect.defineProperty(e,t,i),"symbol"!=typeof t&&a.observers.notify(a),s},deleteProperty:function(e,t){return t in e&&(delete e[t],"symbol"!=typeof t&&a.observers.notify(a),!0)},defineProperty:function(e,t,r){e=Reflect.defineProperty(e,t,r);return"symbol"!=typeof t&&a.observers.notify(a),e},setPrototypeOf:function(e,t){var r=Reflect.setPrototypeOf(object1,t);return"symbol"!=typeof t&&a.observers.notify(a),r}};return s}assignToNamespace("Monster.Types",ProxyObserver);export{Monster,ProxyObserver};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{isArray,isObject,isPrimitive}from"./is.js";import{Observer}from"./observer.js";import{ObserverList}from"./observerlist.js";import{validateObject}from"./validate.js";import{extend}from"../data/extend.js";class ProxyObserver extends Base{constructor(object){super();this.realSubject=validateObject(object);this.subject=new Proxy(object,getHandler.call(this));this.objectMap=new WeakMap;this.objectMap.set(this.realSubject,this.subject);this.proxyMap=new WeakMap;this.proxyMap.set(this.subject,this.realSubject);this.observers=new ObserverList}getSubject(){return this.subject}setSubject(obj){let i,k=Object.keys(this.subject);for(i=0;i<k.length;i++){delete this.subject[k[i]]}this.subject=extend(this.subject,obj);return this}getRealSubject(){return this.realSubject}attachObserver(observer){this.observers.attach(observer);return this}detachObserver(observer){this.observers.detach(observer);return this}notifyObservers(){return this.observers.notify(this)}containsObserver(observer){return this.observers.contains(observer)}}assignToNamespace("Monster.Types",ProxyObserver);export{Monster,ProxyObserver};function getHandler(){const proxy=this;const handler={get:function(target,key,receiver){const value=Reflect.get(target,key,receiver);if(typeof key==="symbol"){return value}if(isPrimitive(value)){return value}if(isArray(value)||isObject(value)){if(proxy.objectMap.has(value)){return proxy.objectMap.get(value)}else if(proxy.proxyMap.has(value)){return value}else{let p=new Proxy(value,handler);proxy.objectMap.set(value,p);proxy.proxyMap.set(p,value);return p}}return value},set:function(target,key,value,receiver){if(proxy.proxyMap.has(value)){value=proxy.proxyMap.get(value)}if(proxy.proxyMap.has(target)){target=proxy.proxyMap.get(target)}let current=Reflect.get(target,key,receiver);if(proxy.proxyMap.has(current)){current=proxy.proxyMap.get(current)}if(current===value){return true}let result;let descriptor=Reflect.getOwnPropertyDescriptor(target,key);if(descriptor===undefined){descriptor={writable:true,enumerable:true,configurable:true}}descriptor["value"]=value;result=Reflect.defineProperty(target,key,descriptor);if(typeof key!=="symbol"){proxy.observers.notify(proxy)}return result},deleteProperty:function(target,key){if(key in target){delete target[key];if(typeof key!=="symbol"){proxy.observers.notify(proxy)}return true}return false},defineProperty:function(target,key,descriptor){let result=Reflect.defineProperty(target,key,descriptor);if(typeof key!=="symbol"){proxy.observers.notify(proxy)}return result},setPrototypeOf:function(target,key){let result=Reflect.setPrototypeOf(object1,key);if(typeof key!=="symbol"){proxy.observers.notify(proxy)}return result}};return handler}
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Queue extends Base{constructor(){super(),this.data=[]}isEmpty(){return 0===this.data.length}peek(){if(!this.isEmpty())return this.data[0]}add(s){return this.data.push(s),this}clear(){return this.data=[],this}poll(){if(!this.isEmpty())return this.data.shift()}}assignToNamespace("Monster.Types",Queue);export{Monster,Queue};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Queue extends Base{constructor(){super();this.data=[]}isEmpty(){return this.data.length===0}peek(){if(this.isEmpty()){return undefined}return this.data[0]}add(value){this.data.push(value);return this}clear(){this.data=[];return this}poll(){if(this.isEmpty()){return undefined}return this.data.shift()}}assignToNamespace("Monster.Types",Queue);export{Monster,Queue};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{random}from"../math/random.js";import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"./global.js";import{ID}from"./id.js";let internalCounter=0;class RandomID extends ID{constructor(){super(),internalCounter+=1,this.id=getGlobal().btoa(random(1,1e4)).replace(/=/g,"").replace(/^[0-9]+/,"X")+internalCounter}}assignToNamespace("Monster.Types",RandomID);export{Monster,RandomID};
\ No newline at end of file
'use strict';import{random}from"../math/random.js";import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"./global.js";import{ID}from"./id.js";let internalCounter=0;class RandomID extends ID{constructor(){super();internalCounter+=1;this.id=getGlobal().btoa(random(1,10000)).replace(/=/g,"").replace(/^[0-9]+/,"X")+internalCounter}}assignToNamespace("Monster.Types",RandomID);export{Monster,RandomID};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{validateString}from"./validate.js";function escapeString(e){return validateString(e).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}assignToNamespace("Monster.Types",escapeString);export{Monster,escapeString};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{validateString}from"./validate.js";function escapeString(value){return validateString(value).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}assignToNamespace("Monster.Types",escapeString);export{Monster,escapeString};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Stack extends Base{constructor(){super(),this.data=[]}isEmpty(){return 0===this.data.length}peek(){if(!this.isEmpty())return this.data?.[this.data.length-1]}push(t){return this.data.push(t),this}clear(){return this.data=[],this}pop(){if(!this.isEmpty())return this.data.pop()}}assignToNamespace("Monster.Types",Stack);export{Monster,Stack};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Stack extends Base{constructor(){super();this.data=[]}isEmpty(){return this.data.length===0}peek(){if(this.isEmpty()){return undefined}return this.data?.[this.data.length-1]}push(value){this.data.push(value);return this}clear(){this.data=[];return this}pop(){if(this.isEmpty()){return undefined}return this.data.pop()}}assignToNamespace("Monster.Types",Stack);export{Monster,Stack};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isIterable,isString}from"../types/is.js";import{validateFunction,validateString}from"../types/validate.js";import{Base}from"./base.js";class TokenList extends Base{constructor(t){super(),this.tokens=new Set,void 0!==t&&this.add(t)}getIterator(){return this[Symbol.iterator]()}[Symbol.iterator](){let t=0,e=this.entries();return{next:()=>t<e.length?{value:e?.[t++],done:!1}:{done:!0}}}contains(i){if(isString(i)){i=i.trim();let e=0;return i.split(" ").forEach(t=>!1!==this.tokens.has(t.trim())&&void e++),0<e}if(isIterable(i)){let t=0;for(var e of i){if(validateString(e),!1===this.tokens.has(e.trim()))return!1;t++}return 0<t}return!1}add(t){if(isString(t))t.split(" ").forEach(t=>{this.tokens.add(t.trim())});else if(isIterable(t))for(var e of t)validateString(e),this.tokens.add(e.trim());else if(void 0!==t)throw new TypeError("unsupported value");return this}clear(){return this.tokens.clear(),this}remove(t){if(isString(t))t.split(" ").forEach(t=>{this.tokens.delete(t.trim())});else if(isIterable(t))for(var e of t)validateString(e),this.tokens.delete(e.trim());else if(void 0!==t)throw new TypeError("unsupported value","types/tokenlist.js");return this}replace(t,e){if(validateString(t),validateString(e),!this.contains(t))return this;let i=Array.from(this.tokens);t=i.indexOf(t);return-1===t||(i.splice(t,1,e),this.tokens=new Set,this.add(i)),this}toggle(t){if(isString(t))t.split(" ").forEach(t=>{toggleValue.call(this,t)});else if(isIterable(t))for(var e of t)toggleValue.call(this,e);else if(void 0!==t)throw new TypeError("unsupported value","types/tokenlist.js");return this}entries(){return Array.from(this.tokens)}forEach(t){return validateFunction(t),this.tokens.forEach(t),this}toString(){return this.entries().join(" ")}}function toggleValue(t){if(!(this instanceof TokenList))throw Error("must be called with TokenList.call");return validateString(t),t=t.trim(),this.contains(t)?this.remove(t):this.add(t),this}assignToNamespace("Monster.Types",TokenList);export{Monster,TokenList};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{isIterable,isString}from"../types/is.js";import{validateFunction,validateString}from"../types/validate.js";import{Base}from"./base.js";class TokenList extends Base{constructor(init){super();this.tokens=new Set;if(typeof init!=="undefined"){this.add(init)}}getIterator(){return this[Symbol.iterator]()}[Symbol.iterator](){let index=0;let entries=this.entries();return{next:()=>{if(index<entries.length){return{value:entries?.[index++],done:false}}else{return{done:true}}}}}contains(value){if(isString(value)){value=value.trim();let counter=0;value.split(" ").forEach(token=>{if(this.tokens.has(token.trim())===false)return false;counter++});return counter>0?true:false}if(isIterable(value)){let counter=0;for(let token of value){validateString(token);if(this.tokens.has(token.trim())===false)return false;counter++}return counter>0?true:false}return false}add(value){if(isString(value)){value.split(" ").forEach(token=>{this.tokens.add(token.trim())})}else if(isIterable(value)){for(let token of value){validateString(token);this.tokens.add(token.trim())}}else if(typeof value!=="undefined"){throw new TypeError("unsupported value")}return this}clear(){this.tokens.clear();return this}remove(value){if(isString(value)){value.split(" ").forEach(token=>{this.tokens.delete(token.trim())})}else if(isIterable(value)){for(let token of value){validateString(token);this.tokens.delete(token.trim())}}else if(typeof value!=="undefined"){throw new TypeError("unsupported value","types/tokenlist.js")}return this}replace(token,newToken){validateString(token);validateString(newToken);if(!this.contains(token)){return this}let a=Array.from(this.tokens);let i=a.indexOf(token);if(i===-1)return this;a.splice(i,1,newToken);this.tokens=new Set;this.add(a);return this}toggle(value){if(isString(value)){value.split(" ").forEach(token=>{toggleValue.call(this,token)})}else if(isIterable(value)){for(let token of value){toggleValue.call(this,token)}}else if(typeof value!=="undefined"){throw new TypeError("unsupported value","types/tokenlist.js")}return this}entries(){return Array.from(this.tokens)}forEach(callback){validateFunction(callback);this.tokens.forEach(callback);return this}toString(){return this.entries().join(" ")}}function toggleValue(token){if(!(this instanceof TokenList))throw Error("must be called with TokenList.call");validateString(token);token=token.trim();if(this.contains(token)){this.remove(token);return this}this.add(token);return this}assignToNamespace("Monster.Types",TokenList);export{Monster,TokenList};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";function typeOf(t){let e={}.toString.call(t).match(/\s([a-zA-Z]+)/)[1];return"Object"===e&&(t=/^(class|function)\s+(\w+)/.exec(t.constructor.toString()),e=t&&2<t.length?t[2]:""),e.toLowerCase()}assignToNamespace("Monster.Types",typeOf);export{Monster,typeOf};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";function typeOf(value){let type={}.toString.call(value).match(/\s([a-zA-Z]+)/)[1];if("Object"===type){const results=/^(class|function)\s+(\w+)/.exec(value.constructor.toString());type=results&&results.length>2?results[2]:""}return type.toLowerCase()}assignToNamespace("Monster.Types",typeOf);export{Monster,typeOf};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Queue}from"./queue.js";import{validateObject}from"./validate.js";class UniqueQueue extends Queue{constructor(){super(),this.unique=new WeakSet}add(e){return validateObject(e),this.unique.has(e)||(this.unique.add(e),super.add(e)),this}clear(){return super.clear(),this.unique=new WeakSet,this}poll(){var e;if(!this.isEmpty())return e=this.data.shift(),this.unique.delete(e),e}}assignToNamespace("Monster.Types",UniqueQueue);export{Monster,UniqueQueue};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Queue}from"./queue.js";import{validateObject}from"./validate.js";class UniqueQueue extends Queue{constructor(){super();this.unique=new WeakSet}add(value){validateObject(value);if(!this.unique.has(value)){this.unique.add(value);super.add(value)}return this}clear(){super.clear();this.unique=new WeakSet;return this}poll(){if(this.isEmpty()){return undefined}let value=this.data.shift();this.unique.delete(value);return value}}assignToNamespace("Monster.Types",UniqueQueue);export{Monster,UniqueQueue};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{internalSymbol}from"../constants.js";import{random}from"../math/random.js";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{Base}from"./base.js";import{getGlobalObject}from"./global.js";class UUID extends Base{constructor(){super();let t=createWithCrypto();if(void 0===t&&(t=createWithRandom()),void 0===t)throw new Error("unsupported");this[internalSymbol]={value:t}}toString(){return this[internalSymbol].value}}function createWithRandom(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var r=16*random(0,65e3)|0;return("x"===t?r:3&r|8).toString(16)[0]})}function createWithCrypto(){const t=getGlobalObject("crypto");isObject(t)&&t?.randomUUID}assignToNamespace("Monster.Types",UUID);export{Monster,UUID};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{random}from"../math/random.js";import{assignToNamespace,Monster}from"../namespace.js";import{isObject}from"../types/is.js";import{Base}from"./base.js";import{getGlobalObject}from"./global.js";class UUID extends Base{constructor(){super();let uuid=createWithCrypto();if(uuid===undefined){uuid=createWithRandom()}if(uuid===undefined){throw new Error("unsupported")}this[internalSymbol]={value:uuid}}toString(){return this[internalSymbol]["value"]}}function createWithRandom(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=random(0,65000)*16|0,v=c==="x"?r:r&3|8;return v.toString(16)[0]})}function createWithCrypto(){const crypt=getGlobalObject("crypto");if(!isObject(crypt))return;if(typeof crypt?.["randomUUID"])return;return crypt.randomUUID()}assignToNamespace("Monster.Types",UUID);export{Monster,UUID};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isBoolean,isFunction,isInstance,isInteger,isIterable,isObject,isPrimitive,isString,isSymbol}from"./is.js";function validateIterable(e){if(!isIterable(e))throw new TypeError("value is not iterable");return e}function validatePrimitive(e){if(!isPrimitive(e))throw new TypeError("value is not a primitive");return e}function validateBoolean(e){if(!isBoolean(e))throw new TypeError("value is not a boolean");return e}function validateString(e){if(!isString(e))throw new TypeError("value is not a string");return e}function validateObject(e){if(!isObject(e))throw new TypeError("value is not a object");return e}function validateInstance(e,i){if(isInstance(e,i))return e;{let e="";throw(isObject(i)||isFunction(i))&&(e=i?.name),e=e&&" "+e,new TypeError("value is not an instance of"+e)}}function validateArray(e){if(!isArray(e))throw new TypeError("value is not an array");return e}function validateSymbol(e){if(!isSymbol(e))throw new TypeError("value is not an symbol");return e}function validateFunction(e){if(!isFunction(e))throw new TypeError("value is not a function");return e}function validateInteger(e){if(!isInteger(e))throw new TypeError("value is not an integer");return e}assignToNamespace("Monster.Types",validatePrimitive,validateBoolean,validateString,validateObject,validateArray,validateFunction,validateIterable,validateInteger);export{Monster,validatePrimitive,validateBoolean,validateString,validateObject,validateInstance,validateArray,validateFunction,validateIterable,validateInteger,validateSymbol};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isBoolean,isFunction,isInstance,isInteger,isIterable,isObject,isPrimitive,isString,isSymbol}from"./is.js";function validateIterable(value){if(!isIterable(value)){throw new TypeError("value is not iterable")}return value}function validatePrimitive(value){if(!isPrimitive(value)){throw new TypeError("value is not a primitive")}return value}function validateBoolean(value){if(!isBoolean(value)){throw new TypeError("value is not a boolean")}return value}function validateString(value){if(!isString(value)){throw new TypeError("value is not a string")}return value}function validateObject(value){if(!isObject(value)){throw new TypeError("value is not a object")}return value}function validateInstance(value,instance){if(!isInstance(value,instance)){let n="";if(isObject(instance)||isFunction(instance)){n=instance?.["name"]}if(n){n=" "+n}throw new TypeError("value is not an instance of"+n)}return value}function validateArray(value){if(!isArray(value)){throw new TypeError("value is not an array")}return value}function validateSymbol(value){if(!isSymbol(value)){throw new TypeError("value is not an symbol")}return value}function validateFunction(value){if(!isFunction(value)){throw new TypeError("value is not a function")}return value}function validateInteger(value){if(!isInteger(value)){throw new TypeError("value is not an integer")}return value}assignToNamespace("Monster.Types",validatePrimitive,validateBoolean,validateString,validateObject,validateArray,validateFunction,validateIterable,validateInteger);export{Monster,validatePrimitive,validateBoolean,validateString,validateObject,validateInstance,validateArray,validateFunction,validateIterable,validateInteger,validateSymbol};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Version extends Base{constructor(r,t,e){var s;if(super(),"string"==typeof r&&void 0===t&&void 0===e&&(s=r.toString().split("."),r=parseInt(s[0]||0),t=parseInt(s[1]||0),e=parseInt(s[2]||0)),void 0===r)throw new Error("major version is undefined");if(void 0===t&&(t=0),void 0===e&&(e=0),this.major=parseInt(r),this.minor=parseInt(t),this.patch=parseInt(e),isNaN(this.major))throw new Error("major is not a number");if(isNaN(this.minor))throw new Error("minor is not a number");if(isNaN(this.patch))throw new Error("patch is not a number")}toString(){return this.major+"."+this.minor+"."+this.patch}compareTo(r){if("string"!=typeof(r=r instanceof Version?r.toString():r))throw new Error("type exception");if(r===this.toString())return 0;var t=[this.major,this.minor,this.patch],e=r.split("."),s=Math.max(t.length,e.length);for(let r=0;r<s;r+=1){if(t[r]&&!e[r]&&0<parseInt(t[r])||parseInt(t[r])>parseInt(e[r]))return 1;if(e[r]&&!t[r]&&0<parseInt(e[r])||parseInt(t[r])<parseInt(e[r]))return-1}return 0}}assignToNamespace("Monster.Types",Version);let monsterVersion;function getVersion(){return monsterVersion instanceof Version||(monsterVersion=new Version("1.30.1")),monsterVersion}assignToNamespace("Monster",getVersion);export{Monster,Version,getVersion};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";class Version extends Base{constructor(major,minor,patch){super();if(typeof major==="string"&&minor===undefined&&patch===undefined){let parts=major.toString().split(".");major=parseInt(parts[0]||0);minor=parseInt(parts[1]||0);patch=parseInt(parts[2]||0)}if(major===undefined){throw new Error("major version is undefined")}if(minor===undefined){minor=0}if(patch===undefined){patch=0}this.major=parseInt(major);this.minor=parseInt(minor);this.patch=parseInt(patch);if(isNaN(this.major)){throw new Error("major is not a number")}if(isNaN(this.minor)){throw new Error("minor is not a number")}if(isNaN(this.patch)){throw new Error("patch is not a number")}}toString(){return this.major+"."+this.minor+"."+this.patch}compareTo(version){if(version instanceof Version){version=version.toString()}if(typeof version!=="string"){throw new Error("type exception")}if(version===this.toString()){return 0}let a=[this.major,this.minor,this.patch];let b=version.split(".");let len=Math.max(a.length,b.length);for(let i=0;i<len;i+=1){if(a[i]&&!b[i]&&parseInt(a[i])>0||parseInt(a[i])>parseInt(b[i])){return 1}else if(b[i]&&!a[i]&&parseInt(b[i])>0||parseInt(a[i])<parseInt(b[i])){return-1}}return 0}}assignToNamespace("Monster.Types",Version);let monsterVersion;function getVersion(){if(monsterVersion instanceof Version){return monsterVersion}monsterVersion=new Version("1.30.1");return monsterVersion}assignToNamespace("Monster",getVersion);export{Monster,Version,getVersion};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"../types/global.js";import{isArray,isFunction,isObject,isPrimitive}from"../types/is.js";import{typeOf}from"../types/typeof.js";import{validateObject}from"../types/validate.js";function clone(t){if(null===t)return t;if(isPrimitive(t))return t;if(isFunction(t))return t;if(isArray(t)){let e=[];for(var n=0,o=t.length;n<o;n++)e[n]=clone(t[n]);return e}if(isObject(t)){if(t instanceof Date){let e=new Date;return e.setTime(t.getTime()),e}if("undefined"!=typeof Element&&t instanceof Element)return t;if("undefined"!=typeof HTMLDocument&&t instanceof HTMLDocument)return t;if("undefined"!=typeof DocumentFragment&&t instanceof DocumentFragment)return t;if(t===getGlobal())return t;if("undefined"!=typeof globalContext&&t===globalContext)return t;if("undefined"!=typeof window&&t===window)return t;if("undefined"!=typeof document&&t===document)return t;if("undefined"!=typeof navigator&&t===navigator)return t;if("undefined"!=typeof JSON&&t===JSON)return t;try{if(t instanceof Proxy)return t}catch(e){}return cloneObject(t)}throw new Error("unable to clone obj! its type isn't supported.")}function cloneObject(e){validateObject(e);var t,n=e?.constructor;if("function"===typeOf(n)){const r=n?.prototype;if("object"==typeof r&&r.hasOwnProperty("getClone")&&"function"===typeOf(e.getClone))return e.getClone()}let o={};for(t in"function"==typeof e.constructor&&"function"==typeof e.constructor.call&&(o=new e.constructor),e)e.hasOwnProperty(t)&&(isPrimitive(e[t])?o[t]=e[t]:o[t]=clone(e[t]));return o}assignToNamespace("Monster.Util",clone);export{Monster,clone};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"../types/global.js";import{isArray,isFunction,isObject,isPrimitive}from"../types/is.js";import{typeOf}from"../types/typeof.js";import{validateObject}from"../types/validate.js";function clone(obj){if(null===obj){return obj}if(isPrimitive(obj)){return obj}if(isFunction(obj)){return obj}if(isArray(obj)){let copy=[];for(var i=0,len=obj.length;i<len;i++){copy[i]=clone(obj[i])}return copy}if(isObject(obj)){if(obj instanceof Date){let copy=new Date;copy.setTime(obj.getTime());return copy}if(typeof Element!=="undefined"&&obj instanceof Element)return obj;if(typeof HTMLDocument!=="undefined"&&obj instanceof HTMLDocument)return obj;if(typeof DocumentFragment!=="undefined"&&obj instanceof DocumentFragment)return obj;if(obj===getGlobal())return obj;if(typeof globalContext!=="undefined"&&obj===globalContext)return obj;if(typeof window!=="undefined"&&obj===window)return obj;if(typeof document!=="undefined"&&obj===document)return obj;if(typeof navigator!=="undefined"&&obj===navigator)return obj;if(typeof JSON!=="undefined"&&obj===JSON)return obj;try{if(obj instanceof Proxy){return obj}}catch(e){}return cloneObject(obj)}throw new Error("unable to clone obj! its type isn't supported.")}function cloneObject(obj){validateObject(obj);const constructor=obj?.["constructor"];if(typeOf(constructor)==="function"){const prototype=constructor?.prototype;if(typeof prototype==="object"){if(prototype.hasOwnProperty("getClone")&&typeOf(obj.getClone)==="function"){return obj.getClone()}}}let copy={};if(typeof obj.constructor==="function"&&typeof obj.constructor.call==="function"){copy=new obj.constructor}for(let key in obj){if(!obj.hasOwnProperty(key)){continue}if(isPrimitive(obj[key])){copy[key]=obj[key];continue}copy[key]=clone(obj[key])}return copy}assignToNamespace("Monster.Util",clone);export{Monster,clone};
/** Monster 1.30.1, © 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{isFunction}from"../types/is.js";class Comparator extends Base{constructor(r){if(super(),isFunction(r))this.compare=r;else{if(void 0!==r)throw new TypeError("unsupported type");this.compare=function(r,e){if(typeof r!=typeof e)throw new TypeError("impractical comparison","types/comparator.js");return r===e?0:r<e?-1:1}}}reverse(){const s=this.compare;return this.compare=(r,e)=>s(e,r),this}equal(r,e){return 0===this.compare(r,e)}greaterThan(r,e){return 0<this.compare(r,e)}greaterThanOrEqual(r,e){return this.greaterThan(r,e)||this.equal(r,e)}lessThanOrEqual(r,e){return this.lessThan(r,e)||this.equal(r,e)}lessThan(r,e){return this.compare(r,e)<0}}assignToNamespace("Monster.Util",Comparator);export{Monster,Comparator};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isFunction}from"../types/is.js";class Comparator extends Base{constructor(callback){super();if(isFunction(callback)){this.compare=callback}else if(callback!==undefined){throw new TypeError("unsupported type")}else{this.compare=function(a,b){if(typeof a!==typeof b){throw new TypeError("impractical comparison","types/comparator.js")}if(a===b){return 0}return a<b?-1:1}}}reverse(){const original=this.compare;this.compare=(a,b)=>original(b,a);return this}equal(a,b){return this.compare(a,b)===0}greaterThan(a,b){return this.compare(a,b)>0}greaterThanOrEqual(a,b){return this.greaterThan(a,b)||this.equal(a,b)}lessThanOrEqual(a,b){return this.lessThan(a,b)||this.equal(a,b)}lessThan(a,b){return this.compare(a,b)<0}}assignToNamespace("Monster.Util",Comparator);export{Monster,Comparator};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isInteger}from"../types/is.js";import{validateFunction,validateInteger}from"../types/validate.js";class DeadMansSwitch extends Base{constructor(t,e){super(),init.call(this,validateInteger(t),validateFunction(e))}touch(t){if(!0===this[internalSymbol].isAlreadyRun)throw new Error("has already run");if(isInteger(t))this[internalSymbol].delay=t;else if(void 0!==t)throw new Error("unsupported argument");return clearTimeout(this[internalSymbol].timer),initCallback.call(this),this}}function initCallback(){const t=this;t[internalSymbol].timer=setTimeout(()=>{t[internalSymbol].isAlreadyRun=!0,t[internalSymbol].callback()},t[internalSymbol].delay)}function init(t,e){this[internalSymbol]={callback:e,delay:t,isAlreadyRun:!1,timer:void 0},initCallback.call(this)}assignToNamespace("Monster.Util",DeadMansSwitch);export{Monster,DeadMansSwitch};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{isInteger}from"../types/is.js";import{validateFunction,validateInteger}from"../types/validate.js";class DeadMansSwitch extends Base{constructor(delay,callback){super();init.call(this,validateInteger(delay),validateFunction(callback))}touch(delay){if(this[internalSymbol]["isAlreadyRun"]===true){throw new Error("has already run")}if(isInteger(delay)){this[internalSymbol]["delay"]=delay}else if(delay!==undefined){throw new Error("unsupported argument")}clearTimeout(this[internalSymbol]["timer"]);initCallback.call(this);return this}}function initCallback(){const self=this;self[internalSymbol]["timer"]=setTimeout(()=>{self[internalSymbol]["isAlreadyRun"]=true;self[internalSymbol]["callback"]()},self[internalSymbol]["delay"])}function init(delay,callback){const self=this;self[internalSymbol]={callback,delay,isAlreadyRun:false,timer:undefined};initCallback.call(self)}assignToNamespace("Monster.Util",DeadMansSwitch);export{Monster,DeadMansSwitch};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{validateObject}from"../types/validate.js";function deepFreeze(e){var t;validateObject(e);for(t of Object.getOwnPropertyNames(e)){var r=e[t];e[t]=r&&"object"==typeof r?deepFreeze(r):r}return Object.freeze(e)}assignToNamespace("Monster.Util",deepFreeze);export{Monster,deepFreeze};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{validateObject}from"../types/validate.js";function deepFreeze(object){validateObject(object);var propNames=Object.getOwnPropertyNames(object);for(let name of propNames){let value=object[name];object[name]=value&&typeof value==="object"?deepFreeze(value):value}return Object.freeze(object)}assignToNamespace("Monster.Util",deepFreeze);export{Monster,deepFreeze};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Util";export{namespace};
\ No newline at end of file
'use strict';export const namespace="Monster.Util";
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction}from"../types/global.js";import{isFunction,isInteger}from"../types/is.js";import{Queue}from"../types/queue.js";import{validateFunction,validateInteger}from"../types/validate.js";class Callback{constructor(e,t){this[internalSymbol]={callback:validateFunction(e),time:validateInteger(t??0)}}run(s){const n=this;return new Promise((e,t)=>{getGlobalFunction("setTimeout")(()=>{try{e(n[internalSymbol].callback(s))}catch(e){t(e)}},n[internalSymbol].time)})}}class Processing extends Base{constructor(){super(),this[internalSymbol]={queue:new Queue};let e=0;for(var[,t]of Object.entries(arguments))if(isInteger(t)&&0<=t)e=t;else{if(!isFunction(t))throw new TypeError("the arguments must be either integer or functions");this[internalSymbol].queue.add(new Callback(t,e))}}add(e,t){return this[internalSymbol].queue.add(new Callback(e,t)),this}run(e){const t=this;return this[internalSymbol].queue.isEmpty()?Promise.resolve(e):this[internalSymbol].queue.poll().run(e).then(e=>t.run(e))}}assignToNamespace("Monster.Util",Processing);export{Monster,Processing};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{getGlobalFunction}from"../types/global.js";import{isFunction,isInteger}from"../types/is.js";import{Queue}from"../types/queue.js";import{validateFunction,validateInteger}from"../types/validate.js";class Callback{constructor(callback,time){this[internalSymbol]={callback:validateFunction(callback),time:validateInteger(time??0)}}run(data){const self=this;return new Promise((resolve,reject)=>{getGlobalFunction("setTimeout")(()=>{try{resolve(self[internalSymbol].callback(data))}catch(e){reject(e)}},self[internalSymbol].time)})}}class Processing extends Base{constructor(){super();this[internalSymbol]={queue:new Queue};let time=0;for(const[,arg]of Object.entries(arguments)){if(isInteger(arg)&&arg>=0){time=arg}else if(isFunction(arg)){this[internalSymbol].queue.add(new Callback(arg,time))}else{throw new TypeError("the arguments must be either integer or functions")}}}add(callback,time){this[internalSymbol].queue.add(new Callback(callback,time));return this}run(data){const self=this;if(this[internalSymbol].queue.isEmpty()){return Promise.resolve(data)}return this[internalSymbol].queue.poll().run(data).then(result=>{return self.run(result)})}}assignToNamespace("Monster.Util",Processing);export{Monster,Processing};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{ID}from"../types/id.js";import{isObject}from"../types/is.js";import{validateString}from"../types/validate.js";function trimSpaces(r){validateString(r);let t=new Map;var e;for(e of r.matchAll(/((?<pattern>\\(?<char>.)){1})/gim)){var a,s,i=e?.groups;isObject(i)&&(a=i?.pattern,i=i?.char,a&&i&&(s="__"+(new ID).toString()+"__",t.set(s,i),r=r.replace(a,s)))}return r=r.trim(),t.forEach((t,e)=>{r=r.replace(e,"\\"+t)}),r}assignToNamespace("Monster.Util",trimSpaces);export{Monster,trimSpaces};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{ID}from"../types/id.js";import{isObject}from"../types/is.js";import{validateString}from"../types/validate.js";function trimSpaces(value){validateString(value);let placeholder=new Map;const regex=/((?<pattern>\\(?<char>.)){1})/mig;let result=value.matchAll(regex);for(let m of result){let g=m?.["groups"];if(!isObject(g)){continue}let p=g?.["pattern"];let c=g?.["char"];if(p&&c){let r="__"+new ID().toString()+"__";placeholder.set(r,c);value=value.replace(p,r)}}value=value.trim();placeholder.forEach((v,k)=>{value=value.replace(k,"\\"+v)});return value}assignToNamespace("Monster.Util",trimSpaces);export{Monster,trimSpaces};
......@@ -176,7 +176,7 @@ function assignToNamespace(ns) {
}
/**
*
* @param {class|function} fn
* @param {class|function|object} obj
* @returns {string}
* @private
* @throws {Error} the name of the class or function cannot be resolved.
......@@ -185,18 +185,18 @@ function assignToNamespace(ns) {
*/
 
 
function objectName(fn) {
function objectName(obj) {
try {
if (typeof fn !== 'function') {
if (typeof obj !== 'function') {
throw new Error("the first argument is not a function or class.");
}
 
if (fn.hasOwnProperty('name')) {
return fn.name;
if (obj.hasOwnProperty('name')) {
return obj.name;
}
 
if ("function" === typeof fn.toString) {
var s = fn.toString();
if ("function" === typeof obj.toString) {
var s = obj.toString();
var f = s.match(/^\s*function\s+([^\s(]+)/);
 
if (Array.isArray(f) && typeof f[1] === 'string') {
......@@ -8541,7 +8541,7 @@ var CustomElement = /*#__PURE__*/function (_HTMLElement) {
* }
* ```
*
* to set the options via the html tag the attribute data-monster-options must be set.
* To set the options via the html tag the attribute data-monster-options must be set.
* As value a JSON object with the desired values must be defined.
*
* Since 1.18.0 the JSON can be specified as a DataURI.
......@@ -8568,6 +8568,7 @@ var CustomElement = /*#__PURE__*/function (_HTMLElement) {
* </script>
* ```
*
* The individual configuration values can be found in the table.
*
* @property {boolean} disabled=false Object The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form.
* @property {string} shadowMode=open `open` Elements of the shadow root are accessible from JavaScript outside the root, for example using. `close` Denies access to the node(s) of a closed shadow root from JavaScript outside it
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment