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

Merge branch 'MONSTER/-/d249dd34-0c43-40b7-96fb-cb7a8624ad11' into 'master'

Release 1.20.0

See merge request oss/libraries/javascript/monster!27
parents ffae3931 745ae8dd
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 20 deletions
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.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{validateInteger}from"../types/validate.js";class LogEntry extends Base{constructor(e,...t){super(),validateInteger(e),this.loglevel=e,this.arguments=t}getLogLevel(){return this.loglevel}getArguments(){return this.arguments}}assignToNamespace("Monster.Logging",LogEntry);export{Monster,LogEntry}; 'use strict';import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateInteger}from"../types/validate.js";class LogEntry extends Base{constructor(loglevel,...args){super();validateInteger(loglevel);this.loglevel=loglevel;this.arguments=args}getLogLevel(){return this.loglevel}getArguments(){return this.arguments}}assignToNamespace("Monster.Logging",LogEntry);export{Monster,LogEntry};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Handler}from"../logging/handler.js";import{LogEntry}from"../logging/logentry.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateInteger,validateObject,validateString}from"../types/validate.js";const ALL=255,TRACE=64,DEBUG=32,INFO=16,WARN=8,ERROR=4,FATAL=2,OFF=0;class Logger extends Base{constructor(){super(),this.handler=new Set}addHandler(e){if(validateObject(e),!(e instanceof Handler))throw new Error("the handler must be an instance of Handler");return this.handler.add(e),this}removeHandler(e){if(validateObject(e),!(e instanceof Handler))throw new Error("the handler must be an instance of Handler");return this.handler.delete(e),this}logTrace(){return triggerLog.apply(this,[TRACE,...arguments]),this}logDebug(){return triggerLog.apply(this,[DEBUG,...arguments]),this}logInfo(){return triggerLog.apply(this,[INFO,...arguments]),this}logWarn(){return triggerLog.apply(this,[WARN,...arguments]),this}logError(){return triggerLog.apply(this,[ERROR,...arguments]),this}logFatal(){return triggerLog.apply(this,[FATAL,...arguments]),this}getLabel(e){return validateInteger(e),e===ALL?"ALL":e===TRACE?"TRACE":e===DEBUG?"DEBUG":e===INFO?"INFO":e===WARN?"WARN":e===ERROR?"ERROR":e===FATAL?"FATAL":e===OFF?"OFF":"unknown"}getLevel(e){return validateString(e),"ALL"===e?ALL:"TRACE"===e?TRACE:"DEBUG"===e?DEBUG:"INFO"===e?INFO:"WARN"===e?WARN:"ERROR"===e?ERROR:"FATAL"===e?FATAL:"OFF"===e?OFF:0}}function triggerLog(e,...r){var t;for(t of this.handler)t.log(new LogEntry(e,r));return this}assignToNamespace("Monster.Logging",Logger);export{Monster,Logger,ALL,TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF}; 'use strict';import{Handler}from"../logging/handler.js";import{LogEntry}from"../logging/logentry.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateInteger,validateObject,validateString}from"../types/validate.js";const ALL=255;const TRACE=64;const DEBUG=32;const INFO=16;const WARN=8;const ERROR=4;const FATAL=2;const OFF=0;class Logger extends Base{constructor(){super();this.handler=new Set}addHandler(handler){validateObject(handler);if(!(handler instanceof Handler)){throw new Error("the handler must be an instance of Handler")}this.handler.add(handler);return this}removeHandler(handler){validateObject(handler);if(!(handler instanceof Handler)){throw new Error("the handler must be an instance of Handler")}this.handler.delete(handler);return this}logTrace(){triggerLog.apply(this,[TRACE,...arguments]);return this}logDebug(){triggerLog.apply(this,[DEBUG,...arguments]);return this}logInfo(){triggerLog.apply(this,[INFO,...arguments]);return this}logWarn(){triggerLog.apply(this,[WARN,...arguments]);return this}logError(){triggerLog.apply(this,[ERROR,...arguments]);return this}logFatal(){triggerLog.apply(this,[FATAL,...arguments]);return this}getLabel(level){validateInteger(level);if(level===ALL)return"ALL";if(level===TRACE)return"TRACE";if(level===DEBUG)return"DEBUG";if(level===INFO)return"INFO";if(level===WARN)return"WARN";if(level===ERROR)return"ERROR";if(level===FATAL)return"FATAL";if(level===OFF)return"OFF";return"unknown"}getLevel(label){validateString(label);if(label==="ALL")return ALL;if(label==="TRACE")return TRACE;if(label==="DEBUG")return DEBUG;if(label==="INFO")return INFO;if(label==="WARN")return WARN;if(label==="ERROR")return ERROR;if(label==="FATAL")return FATAL;if(label==="OFF")return OFF;return 0}}assignToNamespace("Monster.Logging",Logger);export{Monster,Logger,ALL,TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF};function triggerLog(loglevel,...args){var logger=this;for(let handler of logger.handler){handler.log(new LogEntry(loglevel,args))}return logger}
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Logging";export{namespace}; 'use strict';export const namespace="Monster.Logging";
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Math";export{namespace}; 'use strict';export const namespace="Monster.Math";
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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;var n=t-r;if(n<2)throw new Error("the distance is too small to create a random number.");o=Math.ceil(Math.log2(n));if(53<o)throw new Error("we cannot generate numbers larger than 53 bits.");var i=Math.ceil(o/8),o=Math.pow(2,o)-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&=o,a>=n?create(r,t):r+a}Math.log2=Math.log2||function(r){return Math.log(r)/Math.log(2)},assignToNamespace("Monster.Math",random);export{Monster,random}; '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)}return min+rval}assignToNamespace("Monster.Math",random);export{Monster,random};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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(fn){try{if(typeof fn!=="function"){throw new Error("the first argument is not a function or class.")}if(fn.hasOwnProperty("name")){return fn.name}if("function"===typeof fn.toString){let s=fn.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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Pipe}from"../data/pipe.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateObject,validateString}from"../types/validate.js";class Formatter extends Base{constructor(e){super(),this.object=validateObject(e),this.openMarker="${",this.closeMarker="}"}setMarker(e,r){return void 0===r&&(r=e),this.openMarker=validateString(e),this.closeMarker=validateString(r),this}format(e){return tokenizer.call(this,validateString(e))}}function tokenizer(e){var r=this;let t=[];for(;;){var a=e.indexOf(r.openMarker);if(-1===a){t.push(e);break}0<a&&(t.push(e.substring(0,a)),e=e.substring(a));var s=e.substring(r.openMarker.length).indexOf(r.closeMarker)+r.openMarker.length;if(-1===s)throw new Error("syntax error in formatter template");a="path:"+e.substring(r.openMarker.length,s);t.push(validateString(new Pipe(a).run(r.object))),e=e.substring(s+r.closeMarker.length)}return t.join("")}assignToNamespace("Monster.Text",Formatter);export{Monster,Formatter}; 'use strict';import{Pipe}from"../data/pipe.js";import{assignToNamespace,Monster}from"../namespace.js";import{Base}from"../types/base.js";import{validateObject,validateString}from"../types/validate.js";class Formatter extends Base{constructor(object){super();this.object=validateObject(object);this.openMarker="${";this.closeMarker="}"}setMarker(open,close){if(close===undefined){close=open}this.openMarker=validateString(open);this.closeMarker=validateString(close);return this}format(text){return tokenizer.call(this,validateString(text))}}function tokenizer(text){const self=this;let formatted=[];while(true){let startIndex=text.indexOf(self.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(self.openMarker.length).indexOf(self.closeMarker)+self.openMarker.length;if(endIndex===-1){throw new Error("syntax error in formatter template");return}let command="path:"+text.substring(self.openMarker.length,endIndex);formatted.push(validateString(new Pipe(command).run(self.object)));text=text.substring(endIndex+self.closeMarker.length)}return formatted.join("")}assignToNamespace("Monster.Text",Formatter);export{Monster,Formatter};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Text";export{namespace}; 'use strict';export const namespace="Monster.Text";
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{PROPERTY_KEY_INTERNALDATA}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";const optionsSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class BaseWithOptions extends Base{constructor(t){super(),void 0===t&&(t={}),this[optionsSymbol]=extend({},this.defaults,validateObject(t))}get defaults(){return{}}getOption(t,e){let s;try{s=new Pathfinder(this[optionsSymbol]).getVia(t)}catch(t){}return void 0===s?e:s}}assignToNamespace("Monster.Types",BaseWithOptions);export{Monster,BaseWithOptions}; 'use strict';import{PROPERTY_KEY_INTERNALDATA}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";const optionsSymbol=Symbol.for(PROPERTY_KEY_INTERNALDATA);class BaseWithOptions extends Base{constructor(options){super();if(options===undefined){options={}}this[optionsSymbol]=extend({},this.defaults,validateObject(options))}get defaults(){return{}}getOption(path,defaultValue){let value;try{value=new Pathfinder(this[optionsSymbol]).getVia(path)}catch(e){}if(value===undefined)return defaultValue;return value}}assignToNamespace("Monster.Types",BaseWithOptions);export{Monster,BaseWithOptions};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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")?(e=n.lastIndexOf(";"),r=n.substring(0,e),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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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(),void 0===e&&(e="id"),validateString(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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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){if(Array.isArray(value)){return true}return false}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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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){var t=/(?<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===t)throw new TypeError("the mimetype can not be parsed");var r=t?.type,e=t?.subtype,t=t?.parameter;if(""===e||""===r)throw new TypeError("blank value is not allowed");return new MediaType(r,e,parseParameter(t))}function parseParameter(e){if(isString(e)){let r=[];return e.split(";").forEach(e=>{var t;""!==(e=e.trim())&&(t=e.split("="),e=validateString(t?.[0]).trim(),t=validateString(t?.[1]).trim(),r.push({key:e,value:t}))}),r}}assignToNamespace("Monster.Types",parseMediaType,MediaType);export{Monster,parseMediaType,MediaType}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";const namespace="Monster.Types";export{namespace}; 'use strict';export const namespace="Monster.Types";
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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}; '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};
\ No newline at end of file
/** Monster 1.19.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.19.0, © 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=[];for(var r=0,t=this.observers.length;r<t;r++)s.push(this.observers[r].update(e));return Promise.all(s)}}assignToNamespace("Monster.Types",ObserverList);export{Monster,ObserverList}; '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=[];var 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};
\ 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