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 20 additions and 20 deletions
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Logging";export{namespace};
\ No newline at end of file
'use strict';export const namespace="Monster.Logging";
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Math";export{namespace};
\ No newline at end of file
'use strict';export const namespace="Monster.Math";
/** 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";function random(r,t){if((t=void 0===t?MAX:t)<(r=void 0===r?0:r))throw new Error("max must be greater than min");return Math.round(create(r,t))}var MAX=1e9;function create(r,t){let e;var o=getGlobal();if(e=o?.crypto||o?.msCrypto||o?.crypto||void 0,void 0===e)throw new Error("missing crypt");let a=0;o=t-r;if(o<2)throw new Error("the distance is too small to create a random number.");var n=Math.ceil(Math.log2(o));if(53<n)throw new Error("we cannot generate numbers larger than 53 bits.");var i=Math.ceil(n/8),n=Math.pow(2,n)-1,s=new Uint8Array(i);e.getRandomValues(s);let l=8*(i-1);for(var m=0;m<i;m++)a+=s[m]*Math.pow(2,l),l-=8;return a&=n,a>=o?create(r,t):(a<r&&(a+=r),a)}Math.log2=Math.log2||function(r){return Math.log(r)/Math.log(2)},assignToNamespace("Monster.Math",random);export{Monster,random};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{getGlobal}from"../types/global.js";function random(min,max){if(min===undefined){min=0}if(max===undefined){max=MAX}if(max<min){throw new Error("max must be greater than min")}return Math.round(create(min,max))}var MAX=1000000000;Math.log2=Math.log2||function(n){return Math.log(n)/Math.log(2)};function create(min,max){let crypt;let globalReference=getGlobal();crypt=globalReference?.["crypto"]||globalReference?.["msCrypto"]||globalReference?.["crypto"]||undefined;if(typeof crypt==="undefined"){throw new Error("missing crypt")}let rval=0;const range=max-min;if(range<2){throw new Error("the distance is too small to create a random number.")}const bitsNeeded=Math.ceil(Math.log2(range));if(bitsNeeded>53){throw new Error("we cannot generate numbers larger than 53 bits.")}const bytesNeeded=Math.ceil(bitsNeeded/8);const mask=Math.pow(2,bitsNeeded)-1;const byteArray=new Uint8Array(bytesNeeded);crypt.getRandomValues(byteArray);let p=(bytesNeeded-1)*8;for(var i=0;i<bytesNeeded;i++){rval+=byteArray[i]*Math.pow(2,p);p-=8}rval=rval&mask;if(rval>=range){return create(min,max)}if(rval<min){rval+=min}return rval}assignToNamespace("Monster.Math",random);export{Monster,random};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import"./constants.js";import"./constraints/abstract.js";import"./constraints/abstractoperator.js";import"./constraints/andoperator.js";import"./constraints/invalid.js";import"./constraints/isarray.js";import"./constraints/isobject.js";import"./constraints/oroperator.js";import"./constraints/valid.js";import"./data/buildmap.js";import"./data/diff.js";import"./data/extend.js";import"./data/pathfinder.js";import"./data/pipe.js";import"./data/transformer.js";import"./dom/assembler.js";import"./dom/attributes.js";import"./dom/constants.js";import"./dom/customcontrol.js";import"./dom/customelement.js";import"./dom/events.js";import"./dom/locale.js";import"./dom/template.js";import"./dom/theme.js";import"./dom/updater.js";import"./dom/util.js";import"./i18n/locale.js";import"./i18n/provider.js";import"./i18n/providers/fetch.js";import"./i18n/translations.js";import"./logging/handler.js";import"./logging/handler/console.js";import"./logging/logentry.js";import"./logging/logger.js";import"./math/random.js";import{Monster}from"./namespace.js";import"./text/formatter.js";import"./types/base.js";import"./types/basewithoptions.js";import"./types/global.js";import"./types/id.js";import"./types/is.js";import"./types/observer.js";import"./types/observerlist.js";import"./types/proxyobserver.js";import"./types/queue.js";import"./types/randomid.js";import"./types/stack.js";import"./types/tokenlist.js";import"./types/typeof.js";import"./types/uniquequeue.js";import"./types/validate.js";import"./types/version.js";import"./util/clone.js";import"./util/comparator.js";import"./util/freeze.js";let rootName;try{rootName=Monster.Types.getGlobalObject("__MonsterRootName__")}catch(t){}rootName=rootName||"Monster",Monster.Types.getGlobal()[rootName]=Monster;export{Monster};
\ No newline at end of file
'use strict';import"./constants.js";import"./constraints/abstract.js";import"./constraints/abstractoperator.js";import"./constraints/andoperator.js";import"./constraints/invalid.js";import"./constraints/isarray.js";import"./constraints/isobject.js";import"./constraints/oroperator.js";import"./constraints/valid.js";import"./data/buildmap.js";import"./data/diff.js";import"./data/extend.js";import"./data/pathfinder.js";import"./data/pipe.js";import"./data/transformer.js";import"./dom/assembler.js";import"./dom/attributes.js";import"./dom/constants.js";import"./dom/customcontrol.js";import"./dom/customelement.js";import"./dom/events.js";import"./dom/locale.js";import"./dom/template.js";import"./dom/theme.js";import"./dom/updater.js";import"./dom/util.js";import"./i18n/locale.js";import"./i18n/provider.js";import"./i18n/providers/fetch.js";import"./i18n/translations.js";import"./logging/handler.js";import"./logging/handler/console.js";import"./logging/logentry.js";import"./logging/logger.js";import"./math/random.js";import{Monster}from"./namespace.js";import"./text/formatter.js";import"./types/base.js";import"./types/basewithoptions.js";import"./types/global.js";import"./types/id.js";import"./types/is.js";import"./types/observer.js";import"./types/observerlist.js";import"./types/proxyobserver.js";import"./types/queue.js";import"./types/randomid.js";import"./types/stack.js";import"./types/tokenlist.js";import"./types/typeof.js";import"./types/uniquequeue.js";import"./types/validate.js";import"./types/version.js";import"./util/clone.js";import"./util/comparator.js";import"./util/freeze.js";let rootName;try{rootName=Monster.Types.getGlobalObject("__MonsterRootName__")}catch(e){}if(!rootName)rootName="Monster";Monster.Types.getGlobal()[rootName]=Monster;export{Monster};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";class Namespace{constructor(e){if(void 0===e||"string"!=typeof e)throw new Error("namespace is not a string");this.namespace=e}getNamespace(){return this.namespace}toString(){return this.getNamespace()}}const Monster=new Namespace("Monster");function assignToNamespace(e,...r){let n=namespaceFor(e.split("."));if(0===r.length)throw new Error("no functions have been passed.");for(let e=0,t=r.length;e<t;e++)n[objectName(r[e])]=r[e];return n}function objectName(t){try{if("function"!=typeof t)throw new Error("the first argument is not a function or class.");if(t.hasOwnProperty("name"))return t.name;if("function"==typeof t.toString){let e=t.toString();var r=e.match(/^\s*function\s+([^\s(]+)/);if(Array.isArray(r)&&"string"==typeof r[1])return r[1];var n=e.match(/^\s*class\s+([^\s(]+)/);if(Array.isArray(n)&&"string"==typeof n[1])return n[1]}}catch(e){throw new Error("exception "+e)}throw new Error("the name of the class or function cannot be resolved.")}function namespaceFor(t){let r=Monster,n="Monster";for(let e=0;e<t.length;e++)"Monster"!==t[e]&&(n+="."+t[e],r.hasOwnProperty(t[e])||(r[t[e]]=new Namespace(n)),r=r[t[e]]);return r}assignToNamespace("Monster",assignToNamespace,Namespace);export{Monster,assignToNamespace};
\ No newline at end of file
'use strict';class Namespace{constructor(namespace){if(namespace===undefined||typeof namespace!=="string"){throw new Error("namespace is not a string")}this.namespace=namespace}getNamespace(){return this.namespace}toString(){return this.getNamespace()}}export const Monster=new Namespace("Monster");function assignToNamespace(ns,...obj){let current=namespaceFor(ns.split("."));if(obj.length===0){throw new Error("no functions have been passed.")}for(let i=0,l=obj.length;i<l;i++){current[objectName(obj[i])]=obj[i]}return current}function objectName(obj){try{if(typeof obj!=="function"){throw new Error("the first argument is not a function or class.")}if(obj.hasOwnProperty("name")){return obj.name}if("function"===typeof obj.toString){let s=obj.toString();let f=s.match(/^\s*function\s+([^\s(]+)/);if(Array.isArray(f)&&typeof f[1]==="string"){return f[1]}let c=s.match(/^\s*class\s+([^\s(]+)/);if(Array.isArray(c)&&typeof c[1]==="string"){return c[1]}}}catch(e){throw new Error("exception "+e)}throw new Error("the name of the class or function cannot be resolved.")}function namespaceFor(parts){let space=Monster,ns="Monster";for(let i=0;i<parts.length;i++){if("Monster"===parts[i]){continue}ns+="."+parts[i];if(!space.hasOwnProperty(parts[i])){space[parts[i]]=new Namespace(ns)}space=space[parts[i]]}return space}assignToNamespace("Monster",assignToNamespace,Namespace);export{assignToNamespace};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{Pipe}from"../data/pipe.js";import{assignToNamespace,Monster}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{isObject,isString}from"../types/is.js";import{validateArray,validateString}from"../types/validate.js";const internalObjectSymbol=Symbol("internalObject"),watchdogSymbol=Symbol("watchdog"),markerOpenIndexSymbol=Symbol("markerOpenIndex"),markerCloseIndexSymbol=Symbol("markercloseIndex"),workingDataSymbol=Symbol("workingData");class Formatter extends BaseWithOptions{constructor(t,e){super(e),this[internalObjectSymbol]=t||{},this[markerOpenIndexSymbol]=0,this[markerCloseIndexSymbol]=0}get defaults(){return extend({},super.defaults,{marker:{open:["${"],close:["}"]},parameter:{delimiter:"::",assignment:"="},callbacks:{}})}setParameterChars(t,e){return void 0!==t&&(this[internalSymbol].parameter.delimiter=validateString(t)),void 0!==e&&(this[internalSymbol].parameter.assignment=validateString(e)),this}setMarker(t,e){return void 0===e&&(e=t),isString(t)&&(t=[t]),isString(e)&&(e=[e]),this[internalSymbol].marker.open=validateArray(t),this[internalSymbol].marker.close=validateArray(e),this}format(t){return this[watchdogSymbol]=0,this[markerOpenIndexSymbol]=0,this[markerCloseIndexSymbol]=0,this[workingDataSymbol]={},format.call(this,t)}}function format(t){var e=this;if(e[watchdogSymbol]++,20<this[watchdogSymbol])throw new Error("too deep nesting");var r=e[internalSymbol].marker.open?.[this[markerOpenIndexSymbol]],n=e[internalSymbol].marker.close?.[this[markerCloseIndexSymbol]];if(-1===t.indexOf(r)||-1===t.indexOf(n))return t;t=tokenize.call(this,validateString(t),r,n);return e[internalSymbol].marker.open?.[this[markerOpenIndexSymbol]+1]&&this[markerOpenIndexSymbol]++,e[internalSymbol].marker.close?.[this[markerCloseIndexSymbol]+1]&&this[markerCloseIndexSymbol]++,format.call(e,t)}function tokenize(a,i,o){var s=this;let l=[];for(var S=s[internalSymbol].parameter.assignment,y=s[internalSymbol].parameter.delimiter,m=s[internalSymbol].callbacks;;){var b=a.indexOf(i);if(-1===b){l.push(a);break}0<b&&(l.push(a.substring(0,b)),a=a.substring(b));let t=a.substring(i.length).indexOf(o);-1!==t&&(t+=i.length);b=a.substring(i.length).indexOf(i);if(-1!==b&&(b+=i.length)<t&&(d=tokenize.call(s,a.substring(b),i,o),a=a.substring(0,b)+d,t=a.substring(i.length).indexOf(o),-1!==t&&(t+=i.length)),-1===t)throw new Error("syntax error in formatter template");let e=a.substring(i.length,t),r=e.split(y);b=r.shift();s[workingDataSymbol]=extend({},s[internalObjectSymbol],s[workingDataSymbol]);for(const O of r){var[g,c]=O.split(S);s[workingDataSymbol][g]=c}const x=e.split("|").shift().trim(),u=x.split("::").shift().trim();var d=u.split(".").shift().trim(),h=s[workingDataSymbol]?.[d]?"path:":"static:";let n="";h&&0!==e.indexOf(h)&&0!==e.indexOf("path:")&&0!==e.indexOf("static:")&&(n=h),n+=b;const p=new Pipe(n);if(isObject(m))for(var[f,k]of Object.entries(m))p.setCallback(f,k);l.push(validateString(p.run(s[workingDataSymbol]))),a=a.substring(t+o.length)}return l.join("")}assignToNamespace("Monster.Text",Formatter);export{Monster,Formatter};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{Pipe}from"../data/pipe.js";import{assignToNamespace,Monster}from"../namespace.js";import{BaseWithOptions}from"../types/basewithoptions.js";import{isObject,isString}from"../types/is.js";import{validateArray,validateString}from"../types/validate.js";const internalObjectSymbol=Symbol("internalObject");const watchdogSymbol=Symbol("watchdog");const markerOpenIndexSymbol=Symbol("markerOpenIndex");const markerCloseIndexSymbol=Symbol("markercloseIndex");const workingDataSymbol=Symbol("workingData");class Formatter extends BaseWithOptions{constructor(object,options){super(options);this[internalObjectSymbol]=object||{};this[markerOpenIndexSymbol]=0;this[markerCloseIndexSymbol]=0}get defaults(){return extend({},super.defaults,{marker:{open:["${"],close:["}"]},parameter:{delimiter:"::",assignment:"="},callbacks:{}})}setParameterChars(delimiter,assignment){if(delimiter!==undefined){this[internalSymbol]["parameter"]["delimiter"]=validateString(delimiter)}if(assignment!==undefined){this[internalSymbol]["parameter"]["assignment"]=validateString(assignment)}return this}setMarker(open,close){if(close===undefined){close=open}if(isString(open))open=[open];if(isString(close))close=[close];this[internalSymbol]["marker"]["open"]=validateArray(open);this[internalSymbol]["marker"]["close"]=validateArray(close);return this}format(text){this[watchdogSymbol]=0;this[markerOpenIndexSymbol]=0;this[markerCloseIndexSymbol]=0;this[workingDataSymbol]={};return format.call(this,text)}}function format(text){const self=this;self[watchdogSymbol]++;if(this[watchdogSymbol]>20){throw new Error("too deep nesting")}let openMarker=self[internalSymbol]["marker"]["open"]?.[this[markerOpenIndexSymbol]];let closeMarker=self[internalSymbol]["marker"]["close"]?.[this[markerCloseIndexSymbol]];if(text.indexOf(openMarker)===-1||text.indexOf(closeMarker)===-1){return text}let result=tokenize.call(this,validateString(text),openMarker,closeMarker);if(self[internalSymbol]["marker"]["open"]?.[this[markerOpenIndexSymbol]+1]){this[markerOpenIndexSymbol]++}if(self[internalSymbol]["marker"]["close"]?.[this[markerCloseIndexSymbol]+1]){this[markerCloseIndexSymbol]++}result=format.call(self,result);return result}function tokenize(text,openMarker,closeMarker){const self=this;let formatted=[];const parameterAssignment=self[internalSymbol]["parameter"]["assignment"];const parameterDelimiter=self[internalSymbol]["parameter"]["delimiter"];const callbacks=self[internalSymbol]["callbacks"];while(true){let startIndex=text.indexOf(openMarker);if(startIndex===-1){formatted.push(text);break}else if(startIndex>0){formatted.push(text.substring(0,startIndex));text=text.substring(startIndex)}let endIndex=text.substring(openMarker.length).indexOf(closeMarker);if(endIndex!==-1)endIndex+=openMarker.length;let insideStartIndex=text.substring(openMarker.length).indexOf(openMarker);if(insideStartIndex!==-1){insideStartIndex+=openMarker.length;if(insideStartIndex<endIndex){let result=tokenize.call(self,text.substring(insideStartIndex),openMarker,closeMarker);text=text.substring(0,insideStartIndex)+result;endIndex=text.substring(openMarker.length).indexOf(closeMarker);if(endIndex!==-1)endIndex+=openMarker.length}}if(endIndex===-1){throw new Error("syntax error in formatter template");return}let key=text.substring(openMarker.length,endIndex);let parts=key.split(parameterDelimiter);let currentPipe=parts.shift();self[workingDataSymbol]=extend({},self[internalObjectSymbol],self[workingDataSymbol]);for(const kv of parts){const[k,v]=kv.split(parameterAssignment);self[workingDataSymbol][k]=v}const t1=key.split("|").shift().trim();const t2=t1.split("::").shift().trim();const t3=t2.split(".").shift().trim();let prefix=self[workingDataSymbol]?.[t3]?"path:":"static:";let command="";if(prefix&&key.indexOf(prefix)!==0&&key.indexOf("path:")!==0&&key.indexOf("static:")!==0){command=prefix}command+=currentPipe;const pipe=new Pipe(command);if(isObject(callbacks)){for(const[name,callback]of Object.entries(callbacks)){pipe.setCallback(name,callback)}}formatted.push(validateString(pipe.run(self[workingDataSymbol])));text=text.substring(endIndex+closeMarker.length)}return formatted.join("")}assignToNamespace("Monster.Text",Formatter);export{Monster,Formatter};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Text";export{namespace};
\ No newline at end of file
'use strict';export const namespace="Monster.Text";
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";class Base extends Object{toString(){return JSON.stringify(this)}}assignToNamespace("Monster.Types",Base);export{Monster,Base};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";class Base extends Object{toString(){return JSON.stringify(this)}}assignToNamespace("Monster.Types",Base);export{Monster,Base};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{validateObject}from"./validate.js";class BaseWithOptions extends Base{constructor(t){super(),this[internalSymbol]=extend({},this.defaults,validateObject(t=void 0===t?{}:t))}get defaults(){return{}}getOption(t,e){let s;try{s=new Pathfinder(this[internalSymbol]).getVia(t)}catch(t){}return void 0===s?e:s}}assignToNamespace("Monster.Types",BaseWithOptions);export{Monster,BaseWithOptions};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{validateObject}from"./validate.js";class BaseWithOptions extends Base{constructor(options){super();if(options===undefined){options={}}this[internalSymbol]=extend({},this.defaults,validateObject(options))}get defaults(){return{}}getOption(path,defaultValue){let value;try{value=new Pathfinder(this[internalSymbol]).getVia(path)}catch(e){}if(value===undefined)return defaultValue;return value}}assignToNamespace("Monster.Types",BaseWithOptions);export{Monster,BaseWithOptions};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace}from"../namespace.js";import{Monster,validateString}from"./validate.js";function toBinary(t){const e=new Uint16Array(validateString(t).length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);var n=new Uint8Array(e.buffer);let a="";for(let r=0;r<n.byteLength;r++)a+=String.fromCharCode(n[r]);return a}function fromBinary(t){const e=new Uint8Array(validateString(t).length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);var n=new Uint16Array(e.buffer);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return a}assignToNamespace("Monster.Types",toBinary,fromBinary);export{Monster,toBinary,fromBinary};
\ No newline at end of file
'use strict';import{assignToNamespace}from"../namespace.js";import{Monster,validateString}from"./validate.js";function toBinary(string){const codeUnits=new Uint16Array(validateString(string).length);for(let i=0;i<codeUnits.length;i++){codeUnits[i]=string.charCodeAt(i)}const charCodes=new Uint8Array(codeUnits.buffer);let result="";for(let i=0;i<charCodes.byteLength;i++){result+=String.fromCharCode(charCodes[i])}return result}function fromBinary(binary){const bytes=new Uint8Array(validateString(binary).length);for(let i=0;i<bytes.length;i++){bytes[i]=binary.charCodeAt(i)}const charCodes=new Uint16Array(bytes.buffer);let result="";for(let i=0;i<charCodes.length;i++){result+=String.fromCharCode(charCodes[i])}return result}assignToNamespace("Monster.Types",toBinary,fromBinary);export{Monster,toBinary,fromBinary};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace}from"../namespace.js";import{Base,Monster}from"./base.js";import{isString}from"./is.js";import{MediaType,parseMediaType}from"./mediatype.js";import{validateBoolean,validateInstance,validateString}from"./validate.js";const internal=Symbol("internal");class DataUrl extends Base{constructor(t,e,a){super(),isString(e)&&(e=parseMediaType(e)),this[internal]={content:validateString(t),mediatype:validateInstance(e,MediaType),base64:validateBoolean(void 0===a||a)}}get content(){return this[internal].base64?atob(this[internal].content):this[internal].content}get mediatype(){return this[internal].mediatype}toString(){let t=this[internal].content;return t=!0===this[internal].base64?";base64,"+t:","+encodeURIComponent(t),"data:"+this[internal].mediatype.toString()+t}}function parseDataURL(t){if(validateString(t),"data:"!==(t=t.trim()).substring(0,5))throw new TypeError("incorrect or missing data protocol");var e=(t=t.substring(5)).indexOf(",");if(-1===e)throw new TypeError("malformed data url");let a=t.substring(e+1),n=t.substring(0,e).trim(),r="text/plain;charset=US-ASCII",i=!1;return""!==n?(r=n,n.endsWith("base64")?(t=n.lastIndexOf(";"),r=n.substring(0,t),i=!0):a=decodeURIComponent(a),r=parseMediaType(r)):a=decodeURIComponent(a),new DataUrl(a,r,i)}assignToNamespace("Monster.Types",parseDataURL,DataUrl);export{Monster,parseDataURL,DataUrl};
\ No newline at end of file
'use strict';import{assignToNamespace}from"../namespace.js";import{Base,Monster}from"./base.js";import{isString}from"./is.js";import{MediaType,parseMediaType}from"./mediatype.js";import{validateBoolean,validateInstance,validateString}from"./validate.js";const internal=Symbol("internal");class DataUrl extends Base{constructor(content,mediatype,base64){super();if(isString(mediatype)){mediatype=parseMediaType(mediatype)}this[internal]={content:validateString(content),mediatype:validateInstance(mediatype,MediaType),base64:validateBoolean(base64===undefined?true:base64)}}get content(){return this[internal].base64?atob(this[internal].content):this[internal].content}get mediatype(){return this[internal].mediatype}toString(){let content=this[internal].content;if(this[internal].base64===true){content=";base64,"+content}else{content=","+encodeURIComponent(content)}return"data:"+this[internal].mediatype.toString()+content}}function parseDataURL(dataurl){validateString(dataurl);dataurl=dataurl.trim();if(dataurl.substring(0,5)!=="data:"){throw new TypeError("incorrect or missing data protocol")}dataurl=dataurl.substring(5);let p=dataurl.indexOf(",");if(p===-1){throw new TypeError("malformed data url")}let content=dataurl.substring(p+1);let mediatypeAndBase64=dataurl.substring(0,p).trim();let mediatype="text/plain;charset=US-ASCII";let base64Flag=false;if(mediatypeAndBase64!==""){mediatype=mediatypeAndBase64;if(mediatypeAndBase64.endsWith("base64")){let i=mediatypeAndBase64.lastIndexOf(";");mediatype=mediatypeAndBase64.substring(0,i);base64Flag=true}else{content=decodeURIComponent(content)}mediatype=parseMediaType(mediatype)}else{content=decodeURIComponent(content)}return new DataUrl(content,mediatype,base64Flag)}assignToNamespace("Monster.Types",parseDataURL,DataUrl);export{Monster,parseDataURL,DataUrl};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{validateFunction,validateObject,validateString}from"./validate.js";let globalReference;function getGlobal(){return globalReference}function getGlobalObject(e){validateString(e);var t=globalReference?.[e];if(void 0===t)throw new Error("the object "+e+" is not defined");return validateObject(t),t}function getGlobalFunction(e){validateString(e);var t=globalReference?.[e];if(void 0===t)throw new Error("the function "+e+" is not defined");return validateFunction(t),t}!function(){if("object"!=typeof globalThis)if("undefined"==typeof self){if("undefined"==typeof window){if(Object.defineProperty(Object.prototype,"__monster__",{get:function(){return this},configurable:!0}),"object"==typeof __monster__)return __monster__.globalThis=__monster__,delete Object.prototype.__monster__,globalReference=globalThis;try{globalReference=Function("return this")()}catch(e){}throw new Error("unsupported environment.")}globalReference=window}else globalReference=self;else globalReference=globalThis}(),assignToNamespace("Monster.Types",getGlobal,getGlobalObject,getGlobalFunction);export{Monster,getGlobal,getGlobalObject,getGlobalFunction};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{validateFunction,validateObject,validateString}from"./validate.js";let globalReference;(function(){if(typeof globalThis==="object"){globalReference=globalThis;return}if(typeof self!=="undefined"){globalReference=self;return}else if(typeof window!=="undefined"){globalReference=window;return}Object.defineProperty(Object.prototype,"__monster__",{get:function(){return this},configurable:true});if(typeof __monster__==="object"){__monster__.globalThis=__monster__;delete Object.prototype.__monster__;globalReference=globalThis;return}try{globalReference=Function("return this")()}catch(e){}throw new Error("unsupported environment.")})();function getGlobal(){return globalReference}function getGlobalObject(name){validateString(name);let o=globalReference?.[name];if(typeof o==="undefined")throw new Error("the object "+name+" is not defined");validateObject(o);return o}function getGlobalFunction(name){validateString(name);let f=globalReference?.[name];if(typeof f==="undefined")throw new Error("the function "+name+" is not defined");validateFunction(f);return f}assignToNamespace("Monster.Types",getGlobal,getGlobalObject,getGlobalFunction);export{Monster,getGlobal,getGlobalObject,getGlobalFunction};
/** 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{validateString}from"./validate.js";let internalCounter=new Map;class ID extends Base{constructor(e){super(),validateString(e=void 0===e?"id":e),internalCounter.has(e)||internalCounter.set(e,1);var t=internalCounter.get(e);this.id=e+t,internalCounter.set(e,++t)}toString(){return this.id}}assignToNamespace("Monster.Types",ID);export{Monster,ID};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{validateString}from"./validate.js";let internalCounter=new Map;class ID extends Base{constructor(prefix){super();if(prefix===undefined){prefix="id"}validateString(prefix);if(!internalCounter.has(prefix)){internalCounter.set(prefix,1)}let count=internalCounter.get(prefix);this.id=prefix+count;internalCounter.set(prefix,++count)}toString(){return this.id}}assignToNamespace("Monster.Types",ID);export{Monster,ID};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";function isIterable(i){return void 0!==i&&(null!==i&&"function"==typeof i?.[Symbol.iterator])}function isPrimitive(i){return null==i||("string"==(i=typeof i)||"number"==i||"boolean"==i||"symbol"==i)}function isSymbol(i){return"symbol"==typeof i}function isBoolean(i){return!0===i||!1===i}function isString(i){return void 0!==i&&"string"==typeof i}function isObject(i){return!isArray(i)&&(!isPrimitive(i)&&"object"==typeof i)}function isInstance(i,n){return!!isObject(i)&&(!!isFunction(n)&&(!!n.hasOwnProperty("prototype")&&i instanceof n))}function isArray(i){return Array.isArray(i)}function isFunction(i){return!isArray(i)&&(!isPrimitive(i)&&"function"==typeof i)}function isInteger(i){return Number.isInteger(i)}assignToNamespace("Monster.Types",isPrimitive,isBoolean,isString,isObject,isArray,isFunction,isIterable,isInteger,isSymbol);export{Monster,isPrimitive,isBoolean,isString,isObject,isInstance,isArray,isFunction,isIterable,isInteger,isSymbol};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";function isIterable(value){if(value===undefined)return false;if(value===null)return false;return typeof value?.[Symbol.iterator]==="function"}function isPrimitive(value){var type;if(value===undefined||value===null){return true}type=typeof value;if(type==="string"||type==="number"||type==="boolean"||type==="symbol"){return true}return false}function isSymbol(value){return"symbol"===typeof value?true:false}function isBoolean(value){if(value===true||value===false){return true}return false}function isString(value){if(value===undefined||typeof value!=="string"){return false}return true}function isObject(value){if(isArray(value))return false;if(isPrimitive(value))return false;if(typeof value==="object"){return true}return false}function isInstance(value,instance){if(!isObject(value))return false;if(!isFunction(instance))return false;if(!instance.hasOwnProperty("prototype"))return false;return value instanceof instance?true:false}function isArray(value){return Array.isArray(value)}function isFunction(value){if(isArray(value))return false;if(isPrimitive(value))return false;if(typeof value==="function"){return true}return false}function isInteger(value){return Number.isInteger(value)}assignToNamespace("Monster.Types",isPrimitive,isBoolean,isString,isObject,isArray,isFunction,isIterable,isInteger,isSymbol);export{Monster,isPrimitive,isBoolean,isString,isObject,isInstance,isArray,isFunction,isIterable,isInteger,isSymbol};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace}from"../namespace.js";import{Base,Monster}from"./base.js";import{isString}from"./is.js";import{validateArray,validateString}from"./validate.js";const internal=Symbol("internal");class MediaType extends Base{constructor(e,t,r){super(),this[internal]={type:validateString(e).toLowerCase(),subtype:validateString(t).toLowerCase(),parameter:[]},void 0!==r&&(this[internal].parameter=validateArray(r))}get type(){return this[internal].type}get subtype(){return this[internal].subtype}get parameter(){return this[internal].parameter}get parameter(){const r=new Map;return this[internal].parameter.forEach(e=>{let t=e.value;t.startsWith('"')&&t.endsWith('"')&&(t=t.substring(1,t.length-1)),r.set(e.key,t)}),r}toString(){let e=[];for(var t of this[internal].parameter)e.push(t.key+"="+t.value);return this[internal].type+"/"+this[internal].subtype+(0<e.length?";"+e.join(";"):"")}}function parseMediaType(e){e=/(?<type>[A-Za-z]+|\*)\/(?<subtype>([a-zA-Z0-9.\+_\-]+)|\*|)(?<parameter>\s*;\s*([a-zA-Z0-9]+)\s*(=\s*("?[A-Za-z0-9_\-]+"?))?)*/g.exec(validateString(e))?.groups;if(void 0===e)throw new TypeError("the mimetype can not be parsed");var t=e?.type,r=e?.subtype,e=e?.parameter;if(""===r||""===t)throw new TypeError("blank value is not allowed");return new MediaType(t,r,parseParameter(e))}function parseParameter(e){if(isString(e)){let r=[];return e.split(";").forEach(e=>{var t;""!==(e=e.trim())&&(e=e.split("="),t=validateString(e?.[0]).trim(),e=validateString(e?.[1]).trim(),r.push({key:t,value:e}))}),r}}assignToNamespace("Monster.Types",parseMediaType,MediaType);export{Monster,parseMediaType,MediaType};
\ No newline at end of file
'use strict';import{assignToNamespace}from"../namespace.js";import{Base,Monster}from"./base.js";import{isString}from"./is.js";import{validateArray,validateString}from"./validate.js";const internal=Symbol("internal");class MediaType extends Base{constructor(type,subtype,parameter){super();this[internal]={type:validateString(type).toLowerCase(),subtype:validateString(subtype).toLowerCase(),parameter:[]};if(parameter!==undefined){this[internal]["parameter"]=validateArray(parameter)}}get type(){return this[internal].type}get subtype(){return this[internal].subtype}get parameter(){return this[internal].parameter}get parameter(){const result=new Map;this[internal]["parameter"].forEach(p=>{let value=p.value;if(value.startsWith("\"")&&value.endsWith("\"")){value=value.substring(1,value.length-1)}result.set(p.key,value)});return result}toString(){let parameter=[];for(let a of this[internal].parameter){parameter.push(a.key+"="+a.value)}return this[internal].type+"/"+this[internal].subtype+(parameter.length>0?";"+parameter.join(";"):"")}}function parseMediaType(mediatype){const regex=/(?<type>[A-Za-z]+|\*)\/(?<subtype>([a-zA-Z0-9.\+_\-]+)|\*|)(?<parameter>\s*;\s*([a-zA-Z0-9]+)\s*(=\s*("?[A-Za-z0-9_\-]+"?))?)*/g;const result=regex.exec(validateString(mediatype));const groups=result?.["groups"];if(groups===undefined){throw new TypeError("the mimetype can not be parsed")}const type=groups?.["type"];const subtype=groups?.["subtype"];const parameter=groups?.["parameter"];if(subtype===""||type===""){throw new TypeError("blank value is not allowed")}return new MediaType(type,subtype,parseParameter(parameter))}function parseParameter(parameter){if(!isString(parameter)){return undefined}let result=[];parameter.split(";").forEach(entry=>{entry=entry.trim();if(entry===""){return}const kv=entry.split("=");let key=validateString(kv?.[0]).trim();let value=validateString(kv?.[1]).trim();result.push({key:key,value:value})});return result}assignToNamespace("Monster.Types",parseMediaType,MediaType);export{Monster,parseMediaType,MediaType};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Types";export{namespace};
\ No newline at end of file
'use strict';export const namespace="Monster.Types";
/** 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{isPrimitive}from"./is.js";import{NodeList}from"./nodelist.js";import{validateInstance}from"./validate.js";const internalValueSymbol=Symbol("internalData"),treeStructureSymbol=Symbol("treeStructure");class Node extends Base{constructor(e){super(),this[internalValueSymbol]=e,this[treeStructureSymbol]={parent:null,childNodes:new NodeList,level:0}}get value(){return this[internalValueSymbol]}set value(e){this[internalValueSymbol]=e}get parent(){return this[treeStructureSymbol].parent}get level(){return this[treeStructureSymbol].level}get childNodes(){return this[treeStructureSymbol].childNodes}set childNodes(e){this[treeStructureSymbol].childNodes=validateInstance(e,NodeList),setChildLevelAndParent.call(this,this,1)}appendChild(e){return this[treeStructureSymbol].childNodes.add(validateInstance(e,Node)),e[treeStructureSymbol].parent=this,e[treeStructureSymbol].level=this.level+1,setChildLevelAndParent.call(this,e,1),this}removeChild(e){return this[treeStructureSymbol].childNodes.remove(validateInstance(e,Node)),e[treeStructureSymbol].parent=null,e[treeStructureSymbol].level=0,setChildLevelAndParent.call(this,e,-1),this}hasChildNodes(){return 0<this[treeStructureSymbol].childNodes.length}hasChild(e){return this[treeStructureSymbol].childNodes.has(validateInstance(e,Node))}toString(){let t=[];if(this[internalValueSymbol]){let e=this[internalValueSymbol];isPrimitive(e)||(e=JSON.stringify(this[internalValueSymbol])),t.push(e)}if(!this.hasChildNodes())return t.join("\n");let e=this.childNodes.length,r=0;for(const s of this.childNodes){r++;var l=(e===r?"":"").padStart(2*s.level," |");t.push(l+s.toString())}return t.join("\n")}}function setChildLevelAndParent(t,r){const l=this;return t!==this&&(t[treeStructureSymbol].parent=this),t[treeStructureSymbol].childNodes.forEach(function(e){e[treeStructureSymbol].parent=t,e[treeStructureSymbol].level=t[treeStructureSymbol].level+r,setChildLevelAndParent.call(l,e,r)}),this}assignToNamespace("Monster.Types",Node);export{Monster,Node};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{isPrimitive}from"./is.js";import{NodeList}from"./nodelist.js";import{validateInstance}from"./validate.js";const internalValueSymbol=Symbol("internalData");const treeStructureSymbol=Symbol("treeStructure");class Node extends Base{constructor(value){super();this[internalValueSymbol]=value;this[treeStructureSymbol]={parent:null,childNodes:new NodeList,level:0}}get value(){return this[internalValueSymbol]}set value(value){this[internalValueSymbol]=value}get parent(){return this[treeStructureSymbol].parent}get level(){return this[treeStructureSymbol].level}get childNodes(){return this[treeStructureSymbol].childNodes}set childNodes(childNodes){this[treeStructureSymbol].childNodes=validateInstance(childNodes,NodeList);setChildLevelAndParent.call(this,this,1)}appendChild(node){this[treeStructureSymbol].childNodes.add(validateInstance(node,Node));node[treeStructureSymbol].parent=this;node[treeStructureSymbol].level=this.level+1;setChildLevelAndParent.call(this,node,1);return this}removeChild(node){this[treeStructureSymbol].childNodes.remove(validateInstance(node,Node));node[treeStructureSymbol].parent=null;node[treeStructureSymbol].level=0;setChildLevelAndParent.call(this,node,-1);return this}hasChildNodes(){return this[treeStructureSymbol].childNodes.length>0}hasChild(node){return this[treeStructureSymbol].childNodes.has(validateInstance(node,Node))}toString(){let parts=[];if(this[internalValueSymbol]){let label=this[internalValueSymbol];if(!isPrimitive(label))label=JSON.stringify(this[internalValueSymbol]);parts.push(label)}if(!this.hasChildNodes()){return parts.join("\n")}let count=this.childNodes.length,counter=0;for(const node of this.childNodes){counter++;const prefix=(count===counter?"\u2514":"\u251C").padStart(2*node.level," |");parts.push(prefix+node.toString())}return parts.join("\n")}}function setChildLevelAndParent(node,operand){const self=this;if(node!==this){node[treeStructureSymbol].parent=this}node[treeStructureSymbol].childNodes.forEach(function(child){child[treeStructureSymbol].parent=node;child[treeStructureSymbol].level=node[treeStructureSymbol].level+operand;setChildLevelAndParent.call(self,child,operand)});return this}assignToNamespace("Monster.Types",Node);export{Monster,Node};
/** Monster 1.30.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isInstance}from"./is.js";import{Node}from"./node.js";import{validateInstance}from"./validate.js";class NodeList extends Set{constructor(e){super();const r=this;if(void 0!==e)if(isArray(e))e.forEach(e=>r.add(e));else if(isInstance(e,NodeList))e.forEach(e=>r.add(e));else{if(!isInstance(e,Node))throw new Error("invalid value type");r.add(e)}}add(e){return super.add(validateInstance(e,Node)),this}remove(e){return super.delete(validateInstance(e,Node)),this}has(e){return super.has(validateInstance(e,Node))}clear(){return super.clear(),this}toArray(){return Array.from(this)}toJSON(){return this.toArray()}toString(){let e=[];for(const r of this.toArray())e.push(r.toString());return e.join("\n")}get length(){return super.size}}assignToNamespace("Monster.Types",NodeList);export{Monster,NodeList};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{isArray,isInstance}from"./is.js";import{Node}from"./node.js";import{validateInstance}from"./validate.js";class NodeList extends Set{constructor(values){super();const self=this;if(values===undefined)return;if(isArray(values)){values.forEach(value=>self.add(value))}else if(isInstance(values,NodeList)){values.forEach(value=>self.add(value))}else if(isInstance(values,Node)){self.add(values)}else{throw new Error("invalid value type")}}add(node){super.add(validateInstance(node,Node));return this}remove(node){super.delete(validateInstance(node,Node));return this}has(node){return super.has(validateInstance(node,Node));return false}clear(){super.clear();return this}toArray(){return Array.from(this)}toJSON(){return this.toArray()}toString(){let parts=[];for(const node of this.toArray()){parts.push(node.toString())}return parts.join("\n")}get length(){return super.size}}assignToNamespace("Monster.Types",NodeList);export{Monster,NodeList};
/** 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"./base.js";import{isInstance}from"./is.js";import{Node}from"./node.js";import{NodeList}from"./nodelist.js";import{validateInstance}from"./validate.js";const isNodeListSymbol=Symbol("isNodeList");class NodeRecursiveIterator extends Base{constructor(s){var e;super(),this[isNodeListSymbol]=!1,isInstance(s,NodeList)&&(e=s,(s=new Node).childNodes=e,this[isNodeListSymbol]=!0),this[internalSymbol]=validateInstance(s,Node)}[Symbol.iterator]=function*(){var s;if(void 0!==this[internalSymbol]&&(!0!==this[isNodeListSymbol]&&(yield this[internalSymbol]),this[internalSymbol].hasChildNodes()))for(s of this[internalSymbol].childNodes)yield*new NodeRecursiveIterator(s)};forEach(s){for(const e of this)s(e);return this}}assignToNamespace("Monster.Types",NodeRecursiveIterator);export{Monster,NodeRecursiveIterator};
\ No newline at end of file
'use strict';import{internalSymbol}from"../constants.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{isInstance}from"./is.js";import{Node}from"./node.js";import{NodeList}from"./nodelist.js";import{validateInstance}from"./validate.js";const isNodeListSymbol=Symbol("isNodeList");class NodeRecursiveIterator extends Base{constructor(node){super();this[isNodeListSymbol]=false;if(isInstance(node,NodeList)){let children=node;node=new Node;node.childNodes=children;this[isNodeListSymbol]=true}this[internalSymbol]=validateInstance(node,Node)}[Symbol.iterator]=function*(){if(this[internalSymbol]===undefined){return}if(this[isNodeListSymbol]!==true){yield this[internalSymbol]}if(this[internalSymbol].hasChildNodes()){let childNodes=this[internalSymbol].childNodes;for(let node of childNodes){yield*new NodeRecursiveIterator(node)}}return};forEach(callback){for(const node of this){callback(node)}return this}}assignToNamespace("Monster.Types",NodeRecursiveIterator);export{Monster,NodeRecursiveIterator};
/** 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{isObject}from"./is.js";import{TokenList}from"./tokenlist.js";import{UniqueQueue}from"./uniquequeue.js";class Observer extends Base{constructor(e,...t){if(super(),"function"!=typeof e)throw new Error("observer callback must be a function");this.callback=e,this.arguments=t,this.tags=new TokenList,this.queue=new UniqueQueue}addTag(e){return this.tags.add(e),this}removeTag(e){return this.tags.remove(e),this}getTags(){return this.tags.entries()}hasTag(e){return this.tags.contains(e)}update(e){let i=this;return new Promise(function(s,r){isObject(e)?(i.queue.add(e),setTimeout(()=>{try{if(i.queue.isEmpty())return void s();var t=i.queue.poll();let e=i.callback.apply(t,i.arguments);if(isObject(e)&&e instanceof Promise)return void e.then(s).catch(r);s(e)}catch(e){r(e)}},0)):r("subject must be an object")})}}assignToNamespace("Monster.Types",Observer);export{Monster,Observer};
\ No newline at end of file
'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"./base.js";import{isObject}from"./is.js";import{TokenList}from"./tokenlist.js";import{UniqueQueue}from"./uniquequeue.js";class Observer extends Base{constructor(callback,...args){super();if(typeof callback!=="function"){throw new Error("observer callback must be a function")}this.callback=callback;this.arguments=args;this.tags=new TokenList;this.queue=new UniqueQueue}addTag(tag){this.tags.add(tag);return this}removeTag(tag){this.tags.remove(tag);return this}getTags(){return this.tags.entries()}hasTag(tag){return this.tags.contains(tag)}update(subject){let self=this;return new Promise(function(resolve,reject){if(!isObject(subject)){reject("subject must be an object");return}self.queue.add(subject);setTimeout(()=>{try{if(self.queue.isEmpty()){resolve();return}let s=self.queue.poll();let result=self.callback.apply(s,self.arguments);if(isObject(result)&&result instanceof Promise){result.then(resolve).catch(reject);return}resolve(result)}catch(e){reject(e)}},0)})}}assignToNamespace("Monster.Types",Observer);export{Monster,Observer};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment