@aegis-framework/artemis 0.3.29 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/artemis.browser.js +4 -0
- package/dist/artemis.browser.js.map +24 -0
- package/dist/artemis.js +3 -1
- package/dist/artemis.js.map +23 -1
- package/dist/types/DOM.d.ts +383 -0
- package/dist/types/DOM.d.ts.map +1 -0
- package/dist/types/Debug.d.ts +118 -0
- package/dist/types/Debug.d.ts.map +1 -0
- package/dist/types/FileSystem.d.ts +69 -0
- package/dist/types/FileSystem.d.ts.map +1 -0
- package/dist/types/Form.d.ts +32 -0
- package/dist/types/Form.d.ts.map +1 -0
- package/dist/types/Platform.d.ts +93 -0
- package/dist/types/Platform.d.ts.map +1 -0
- package/dist/types/Preload.d.ts +26 -0
- package/dist/types/Preload.d.ts.map +1 -0
- package/dist/types/Request.d.ts +86 -0
- package/dist/types/Request.d.ts.map +1 -0
- package/dist/types/Space.d.ts +205 -0
- package/dist/types/Space.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/IndexedDB.d.ts +130 -0
- package/dist/types/SpaceAdapter/IndexedDB.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/LocalStorage.d.ts +125 -0
- package/dist/types/SpaceAdapter/LocalStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/RemoteStorage.d.ts +122 -0
- package/dist/types/SpaceAdapter/RemoteStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/SessionStorage.d.ts +30 -0
- package/dist/types/SpaceAdapter/SessionStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/types.d.ts +76 -0
- package/dist/types/SpaceAdapter/types.d.ts.map +1 -0
- package/dist/types/Text.d.ts +47 -0
- package/dist/types/Text.d.ts.map +1 -0
- package/dist/types/Util.d.ts +31 -0
- package/dist/types/Util.d.ts.map +1 -0
- package/dist/types/browser.d.ts +7 -0
- package/dist/types/browser.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +42 -53
- package/dist/artemis.min.js +0 -2
- package/dist/artemis.min.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/index.js +0 -10
- package/src/DOM.js +0 -993
- package/src/Debug.js +0 -233
- package/src/FileSystem.js +0 -109
- package/src/Form.js +0 -73
- package/src/Platform.js +0 -166
- package/src/Preload.js +0 -48
- package/src/Request.js +0 -163
- package/src/Space.js +0 -334
- package/src/SpaceAdapter/IndexedDB.js +0 -345
- package/src/SpaceAdapter/LocalStorage.js +0 -395
- package/src/SpaceAdapter/RemoteStorage.js +0 -225
- package/src/SpaceAdapter/SessionStorage.js +0 -46
- package/src/Text.js +0 -133
- package/src/Util.js +0 -55
package/LICENSE
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var h=Object.defineProperty;var D=(z,H)=>{for(var Q in H)h(z,Q,{get:H[Q],enumerable:!0,configurable:!0,set:(X)=>H[Q]=()=>X})};var T={};D(T,{Util:()=>S,Text:()=>V,SpaceAdapter:()=>R,Space:()=>x,SessionStorage:()=>P,Request:()=>G,RemoteStorage:()=>E,Preload:()=>O,Platform:()=>C,LocalStorage:()=>F,IndexedDB:()=>U,Form:()=>q,FileSystem:()=>A,DebugLevel:()=>M,Debug:()=>j,DOM:()=>$,$_ready:()=>b,$_:()=>w});var M;((Z)=>{Z[Z.NONE=0]="NONE";Z[Z.ERROR=1]="ERROR";Z[Z.WARNING=2]="WARNING";Z[Z.INFO=3]="INFO";Z[Z.DEBUG=4]="DEBUG";Z[Z.ALL=5]="ALL"})(M||={});class j{static _level=0;static level(z){if(typeof z==="number")this._level=z;return this._level}static log(...z){if(this.level()>=4)console.log(...z)}static debug(...z){if(this.level()>=4)console.debug(...z)}static info(...z){if(this.level()>=3)console.info(...z)}static error(...z){if(this.level()>=1)console.error(...z)}static warning(...z){if(this.level()>=2)console.warn(...z)}static table(...z){if(this.level()>=4)console.table(...z)}static group(...z){if(this.level()>=4)console.group(...z)}static groupCollapsed(...z){if(this.level()>=4)console.groupCollapsed(...z)}static groupEnd(){if(this.level()>=4)console.groupEnd()}static time(z){if(this.level()>=4)console.time(z)}static timeLog(z,...H){if(this.level()>=4)console.timeLog(z,...H)}static timeEnd(z){if(this.level()>=4)console.timeEnd(z)}static trace(...z){if(this.level()>=4)console.trace(...z)}}class ${collection;length;_selector;constructor(z){if(z===null){this.collection=[],this.length=0,this._selector=null;return}if(typeof z==="string")this.collection=document.querySelectorAll(z),this.length=this.collection.length,this._selector=z;else if(z instanceof NodeList)this.collection=z,this.length=z.length,this._selector=z;else if(z instanceof $)this.collection=z.collection,this.length=this.collection.length,this._selector=z._selector;else if(z instanceof HTMLElement)this.collection=[z],this.length=this.collection.length,this._selector=z;else if(Array.isArray(z))this.collection=z,this.length=z.length,this._selector=z;else this.collection=[],this.length=0,this._selector=null}hide(){for(let z of this.collection)z.style.display="none";return this}show(z="block"){for(let H of this.collection)H.style.display=z;return this}addClass(z){for(let H of this.collection)H.classList.add(z);return this}removeClass(z=null){if(z!==null)for(let H of this.collection)H.classList.remove(z);else for(let H of this.collection)while(H.classList.length>0){let Q=H.classList.item(0);if(Q)H.classList.remove(Q)}return this}toggleClass(z){let H=z.split(" ");for(let Q of this.collection)for(let X of H)Q.classList.toggle(X);return this}hasClass(z){for(let H of this.collection)if(!H.classList.contains(z))return!1;return!0}value(z){if(typeof z<"u"){for(let H of this.collection)H.value=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].value;let H=[];for(let Q of this.collection)H.push(Q.value);return H}}focus(){if(this.length>0)this.collection[0].focus();return this}click(z){for(let H of this.collection)H.addEventListener("click",z,!1);return this}keyup(z){for(let H of this.collection)H.addEventListener("keyup",z,!1);return this}keydown(z){for(let H of this.collection)H.addEventListener("keydown",z,!1);return this}submit(z){for(let H of this.collection)H.addEventListener("submit",z,!1);return this}change(z){for(let H of this.collection)H.addEventListener("change",z,!1);return this}scroll(z){for(let H of this.collection)H.addEventListener("scroll",z,!1);return this}on(z,H,Q){let X=z.split(" ");for(let Y of this.collection)for(let W of X)if(typeof H==="function")Y.addEventListener(W,H,!1);else if(typeof H==="string"&&typeof Q==="function")Y.addEventListener(W,(Z)=>{if(!Z.target)return;let _=new $(Z.target).closestParent(H,this._selector);if(_.exists())Q.call(_.get(0),Z)},!1);return this}filter(z){let H=[];for(let Q of this.collection)if(Q.matches(z))H.push(Q);return new $(H.length>0?H:null)}exists(){return this.length>0}data(z,H){if(typeof H<"u"){for(let Q of this.collection)Q.dataset[z]=H;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].dataset[z];let Q=[];for(let X of this.collection)Q.push(X.dataset[z]);return Q}}removeData(z){for(let H of this.collection)delete H.dataset[z];return this}text(z){if(typeof z<"u"){for(let H of this.collection)H.textContent=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].textContent;let H=[];for(let Q of this.collection)H.push(Q.textContent);return H}}html(z){if(typeof z<"u"){for(let H of this.collection)H.innerHTML=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].innerHTML;let H=[];for(let Q of this.collection)H.push(Q.innerHTML);return H}}append(z){for(let H of this.collection)if(typeof z==="string"){let Q=document.createElement("div");if(Q.innerHTML=z.trim(),Q.firstChild)H.appendChild(Q.firstChild.cloneNode(!0))}else H.appendChild(z.cloneNode(!0));return this}prepend(z){for(let H of this.collection)if(typeof z==="string"){let Q=document.createElement("div");if(Q.innerHTML=z.trim(),Q.firstChild)if(H.childNodes.length>0)H.insertBefore(Q.firstChild.cloneNode(!0),H.childNodes[0]);else H.appendChild(Q.firstChild.cloneNode(!0))}else if(H.childNodes.length>0)H.insertBefore(z.cloneNode(!0),H.childNodes[0]);else H.appendChild(z.cloneNode(!0));return this}each(z){for(let H of this.collection)z(H);return this}get(z){return this.collection[z]}first(){if(this.length>0)return new $(this.collection[0]);return new $(null)}last(){if(this.length>0)return new $(this.collection[this.collection.length-1]);return new $(null)}isVisible(){for(let z of this.collection){let H=z;if(H.style.display!=="none"&&H.offsetWidth>0&&H.offsetHeight>0)return!0}return!1}parent(){let z=[];for(let H of this.collection)if(H.parentElement&&!z.includes(H.parentElement))z.push(H.parentElement);return new $(z.length>0?z:null)}find(z){let H=[];for(let Q of this.collection){let X=Q.querySelectorAll(z);for(let Y of X)if(!H.includes(Y))H.push(Y)}return new $(H.length>0?H:null)}offset(){if(this.length===0)return;if(this.length===1){let H=this.collection[0].getBoundingClientRect();return{top:H.top+document.body.scrollTop,left:H.left+document.body.scrollLeft}}let z=[];for(let H of this.collection){let Q=H.getBoundingClientRect();z.push({top:Q.top+document.body.scrollTop,left:Q.left+document.body.scrollLeft})}return z}closest(z){let H=[];for(let Q of this.collection){let X=Q.closest(z);if(X&&!H.includes(X))H.push(X)}return new $(H.length>0?H:null)}closestParent(z,H){if(this.length===0)return new $(null);let Q=this.collection[0];while(Q){if(Q.matches(z))return new $(Q);if(typeof H==="string"&&Q.matches(H))break;Q=Q.parentElement}return new $(null)}attribute(z,H){if(typeof H<"u"){for(let Q of this.collection)Q.setAttribute(z,String(H));return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].getAttribute(z);let Q=[];for(let X of this.collection)Q.push(X.getAttribute(z));return Q}}hasAttribute(z){for(let H of this.collection)if(!H.hasAttribute(z))return!1;return!0}after(z){for(let H of this.collection)H.insertAdjacentHTML("afterend",z);return this}before(z){for(let H of this.collection)H.insertAdjacentHTML("beforebegin",z);return this}style(z,H){if(typeof z==="string"&&typeof H>"u"){if(this.length===0)return;if(this.length===1)return this.collection[0].style.getPropertyValue(z);let Q=[];for(let X of this.collection)Q.push(X.style.getPropertyValue(z));return Q}for(let Q of this.collection){let X=Q;if(typeof z==="string"&&typeof H<"u")X.style.setProperty(z,H);else if(typeof z==="object")for(let Y in z)X.style.setProperty(Y,String(z[Y]))}return this}animate(z,H){for(let Q=0;Q<this.collection.length;Q++){let X=this.collection[Q];for(let Y in z){let W=Date.now(),Z;if(typeof X.style.getPropertyValue(Y)<"u"&&X.style.getPropertyValue(Y)!==""){Z=parseFloat(X.style.getPropertyValue(Y));let J=setInterval(()=>{let _=Math.min(1,(Date.now()-W)/H);if(X.style.setProperty(Y,String(Z+_*(z[Y]-Z))),_===1)clearInterval(J)},25);X.style.setProperty(Y,String(Z))}else if(typeof X[Y]<"u"){Z=X[Y];let J=setInterval(()=>{let _=Math.min(1,(Date.now()-W)/H);if(X[Y]=Z+_*(z[Y]-Z),_===1)clearInterval(J)},25);X[Y]=Z}}}return this}fadeIn(z=400,H){let Q=0,X=this.collection.length;for(let Y of this.collection){let W=Y;W.style.opacity="0";let Z=Date.now(),J=()=>{if(W.style.opacity=String(parseFloat(W.style.opacity)+(Date.now()-Z)/z),Z=Date.now(),parseFloat(W.style.opacity)<1)requestAnimationFrame(J);else if(Q++,Q===X&&typeof H==="function")H()};J()}return this}fadeOut(z=400,H){let Q=0,X=this.collection.length;for(let Y of this.collection){let W=Y,Z=Date.now(),J=()=>{if(W.style.opacity=String(parseFloat(W.style.opacity)-(Date.now()-Z)/z),Z=Date.now(),parseFloat(W.style.opacity)>0)requestAnimationFrame(J);else if(Q++,Q===X&&typeof H==="function")H()};J()}return this}matches(z){if(this.length===0)return!1;for(let H of this.collection)if(!H.matches(z))return!1;return!0}remove(){for(let z of this.collection)z.parentNode?.removeChild(z);return this}replaceWith(z){for(let H of this.collection){let Q;if(typeof z==="string"){let X=document.createElement("div");X.innerHTML=z,Q=X.firstChild}else Q=z.cloneNode(!0);H.parentElement?.replaceChild(Q,H)}return this}reset(){for(let z of this.collection)if(z.reset)z.reset();return this}property(z,H){if(typeof H<"u"){for(let Q of this.collection)Q[z]=H;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0][z];let Q=[];for(let X of this.collection)Q.push(X[z]);return Q}}}function w(z){return new $(z)}function b(z){window.addEventListener("load",z)}class G{static serialize(z){return Object.keys(z).map((H)=>{return encodeURIComponent(H)+"="+encodeURIComponent(String(z[H]))}).join("&")}static get(z,H={},Q={}){let X=G.serialize(H);if(X!=="")z=`${z}?${X}`;return fetch(z,Q)}static post(z,H,Q={}){let X,Y=Q.headers?.["Content-Type"];if(Y!==void 0)if(Y==="multipart/form-data"){X=new FormData;for(let J in H)X.append(J,String(H[J]))}else if(Y==="application/json")X=JSON.stringify(H);else X=G.serialize(H);else X=G.serialize(H);let W={"Content-Type":"application/x-www-form-urlencoded",...Q.headers};if(W["Content-Type"]==="multipart/form-data")delete W["Content-Type"];let Z={...Q,method:"POST",headers:W,body:X};return fetch(z,Z)}static put(z,H,Q={}){return G.post(z,H,Object.assign({},{method:"PUT"},Q))}static delete(z,H,Q={}){return G.get(z,H,Object.assign({},{method:"DELETE"},Q))}static json(z,H={},Q={}){return G.get(z,H,Q).then((X)=>{return X.json()})}static blob(z,H={},Q={}){return G.get(z,H,Q).then((X)=>{return X.blob()})}}class A{static readRemote(z,H="base64",Q={}){return G.blob(z,{},Q).then((X)=>{return A.read(X,H)})}static read(z,H="text"){return new Promise((Q,X)=>{let Y=new FileReader;if(Y.onload=(W)=>{Q({event:W,content:W.target?.result??null})},Y.onerror=(W)=>{X(W)},H==="base64")Y.readAsDataURL(z);else if(H==="buffer")Y.readAsArrayBuffer(z);else Y.readAsText(z,"UTF-8")})}static create(z,H,Q="text/plain"){return Promise.resolve(new File([H],z,{type:Q}))}static extension(z){return z.split(".").pop()??""}static isImage(z){return["jpg","jpeg","png","gif","svg","webp","bmp"].indexOf(A.extension(z).toLowerCase())>-1}}class q{static fill(z,H){for(let Q in H){let X=w(`form[data-form='${z}'] [name='${Q}']`).get(0);if(typeof X<"u")switch(X.type){case"file":case"file[]":break;default:X.value=H[Q];break}}}static values(z){let H={};return w(`form[data-form='${z}'] [name]`).each((Q)=>{let X=Q,Y;switch(X.type){case"file[]":Y=X.files??void 0;break;case"file":Y=X.files?.[0];break;default:Y=X.value;break}if(typeof Y<"u"&&Y!==null)H[X.name]=Y}),H}}class C{static retina(){return window.devicePixelRatio>=2}static portrait(){return window.screen.orientation.type==="portrait-primary"||window.screen.orientation.type==="portrait-secondary"}static landscape(){return window.screen.orientation.type==="landscape-primary"||window.screen.orientation.type==="landscape-secondary"}static orientation(){return C.portrait()?"portrait":"landscape"}static electron(){let z=window;if(typeof z<"u"&&typeof z.process==="object"&&z.process?.type==="renderer")return!0;let H=typeof globalThis<"u"?globalThis.process:void 0;if(H&&typeof H.versions==="object"&&!!H.versions?.electron)return!0;if(typeof navigator==="object"&&typeof navigator.userAgent==="string"&&navigator.userAgent.indexOf("Electron")>=0)return!0;return!1}static cordova(){return!!window.cordova}static getPlatformString(){if(navigator.userAgentData?.platform)return navigator.userAgentData.platform;let z=navigator.userAgent;if(z.includes("Win"))return"Windows";if(z.includes("Mac"))return"macOS";if(z.includes("Linux"))return"Linux";if(z.includes("FreeBSD"))return"FreeBSD";if(z.includes("WebTV"))return"webOS";return""}static desktop(z="Any"){let H=C.getPlatformString();switch(z){case"Windows":return H==="Windows"||H.includes("Win");case"macOS":return H==="macOS"||H.includes("Mac");case"Linux":return H==="Linux"||H.includes("Linux");case"FreeBSD":return H==="FreeBSD"||H.includes("FreeBSD");case"webOS":return H==="webOS"||H.includes("WebTV");case"Any":default:return["Windows","macOS","Linux","FreeBSD","webOS"].some((Q)=>H===Q||H.includes(Q.replace("macOS","Mac").replace("webOS","WebTV")))}}static mobile(z="Any"){if(navigator.userAgentData?.mobile!==void 0&&z==="Any")return navigator.userAgentData.mobile;let H=navigator.userAgent;switch(z){case"Android":return/Android/i.test(H);case"iOS":return/iPhone|iPad|iPod/i.test(H);case"Opera":return/Opera Mini/i.test(H);case"Windows":return/Windows Phone|IEMobile|WPDesktop/i.test(H);case"BlackBerry":return/BlackBerry|BB10/i.test(H);case"Any":default:return/Android|iPhone|iPad|iPod|Windows Phone|IEMobile|WPDesktop|BlackBerry|BB10/i.test(H)}}static serviceWorkers(){if(typeof navigator<"u"){if("serviceWorker"in navigator&&location.protocol.indexOf("http")>-1)return!0}return!1}}class O{static image(z){return new Promise((H,Q)=>{let X=new Image;X.onload=()=>{H(X)},X.onerror=(Y)=>{Q(Y)},X.src=z})}static file(z){return G.blob(z)}}class F{name;version;store;id;numericVersion;upgrades;storage;constructor({name:z="",version:H="",store:Q=""}){if(this.name=z,this.version=H,this.store=Q,this.upgrades={},this.version==="")this.numericVersion=0;else this.numericVersion=parseInt(H.replace(/\./g,""));if(z!==""&&H!==""&&Q!=="")this.id=`${this.name}::${this.store}::${this.version}_`;else if(z!==""&&H!=="")this.id=`${this.name}::${this.version}_`;else if(z!=="")this.id=`${this.name}::_`;else this.id=""}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(this.storage instanceof Storage)return Promise.resolve(this);else if(this.storage instanceof Promise)return this.storage;else{let z=new Promise((H)=>{let Q=[];if(this.version!==""){let X="";if(this.name!==""&&this.version!==""&&this.store!=="")X=`${this.name}::${this.store}::`;else if(this.name!==""&&this.version!=="")X=`${this.name}::`;let Y=Object.keys(window.localStorage).filter((W)=>{return W.indexOf(X)===0}).map((W)=>{return W.replace(X,"").split("_")[0]}).filter((W)=>{return W.indexOf("::")===-1}).sort();if(Y.length>0){let W=Y[0],Z=parseInt(W.replace(/\./g,""));if(Z<this.numericVersion){let J=Object.keys(this.upgrades).sort(),_=J.findIndex((K)=>{let[N]=K.split("::");return parseInt(N)===Z});if(_>-1)Q=J.slice(_).filter((K)=>{let[N,L]=K.split("::");return parseInt(N)<this.numericVersion&&parseInt(L)<=this.numericVersion});let B=`${this.name}::${W}_`;if(this.name!==""&&this.version!==""&&this.store!=="")B=`${this.name}::${this.store}::${W}_`;else if(this.name!==""&&this.version!=="")B=`${this.name}::${W}_`;let I=Object.keys(window.localStorage).filter((K)=>{return K.indexOf(B)===0}).map((K)=>{return K.replace(B,"")});for(let K of I){let N=window.localStorage.getItem(`${B}${K}`);if(N!==null)window.localStorage.setItem(this.id+K,N);window.localStorage.removeItem(`${B}${K}`)}}}}H({upgrades:Q})}).then(({upgrades:H})=>{return this.storage=window.localStorage,new Promise((Q)=>{let X=()=>Q(this);this._upgrade(H,X)})});return this.storage=z,z}}set(z,H){return this.open().then(()=>{if(typeof H==="object")this.storage.setItem(this.id+z,JSON.stringify(H));else this.storage.setItem(this.id+z,String(H));return Promise.resolve({key:z,value:H})})}update(z,H){return this.get(z).then((Q)=>{if(typeof Q==="object"&&Q!==null){if(typeof H==="object"&&H!==null)H=Object.assign({},Q,H);this.storage.setItem(this.id+z,JSON.stringify(H))}else this.storage.setItem(this.id+z,String(H));return Promise.resolve({key:z,value:H})}).catch(()=>{return this.set(z,H)})}get(z){return this.open().then(()=>{return new Promise((H,Q)=>{let X=this.storage.getItem(this.id+z);try{let Y=JSON.parse(X);if(Y&&typeof Y==="object")X=Y}catch{}if(typeof X<"u"&&X!==null)H(X);else Q()})})}getAll(){return this.keys().then((z)=>{let H={},Q=[];for(let X of z)Q.push(this.get(X).then((Y)=>{H[X]=Y}));return Promise.all(Q).then(()=>H)})}contains(z){return this.keys().then((H)=>{if(H.includes(z))return Promise.resolve();else return Promise.reject()})}upgrade(z,H,Q){let X=`${parseInt(z.replace(/\./g,""))}::${parseInt(H.replace(/\./g,""))}`;return this.upgrades[X]=Q,Promise.resolve()}_upgrade(z,H){if(z.length>0)this.upgrades[z[0]].call(this,this).then(()=>{this._upgrade(z.slice(1),H)}).catch((Q)=>console.error(Q));else H()}rename(z){if(this.name!==z)return this.keys().then((H)=>{let Q=this.id;if(this.name=z,this.name!==""&&this.version!==""&&this.store!=="")this.id=`${this.name}::${this.store}::${this.version}_`;else if(this.name!==""&&this.version!=="")this.id=`${this.name}::${this.version}_`;else if(this.name!=="")this.id=`${this.name}::_`;else this.id="";let X=[];for(let Y of H){let W=this.storage.getItem(`${Q}${Y}`);if(W!==null)X.push(this.set(Y,W).then(()=>{this.storage.removeItem(`${Q}${Y}`)}))}return Promise.all(X).then(()=>{})});else return Promise.reject()}key(z,H=!1){return this.open().then(()=>{let Q=this.storage.key(z);if(H===!0)return Promise.resolve(Q??"");else return Promise.resolve((Q??"").replace(this.id,""))})}keys(z=!1){return this.open().then(()=>{return Promise.resolve(Object.keys(this.storage).filter((H)=>{return H.indexOf(this.id)===0}).map((H)=>{if(z===!0)return H;else return H.replace(this.id,"")}))})}remove(z){return this.get(z).then((H)=>{return this.storage.removeItem(this.id+z),Promise.resolve(H)})}clear(){return this.keys().then((z)=>{for(let H of z)this.remove(H);return Promise.resolve()})}}class P extends F{constructor({name:z="",version:H="",store:Q=""}){super({name:z,version:H,store:Q})}open(){if(typeof this.storage>"u")this.storage=window.sessionStorage;return Promise.resolve(this)}}class U{name;version;store;props;index;keyPath;numericVersion;upgrades;storage;constructor({name:z="",version:H="",store:Q="",props:X={},index:Y={}}){if(this.name=z,this.version=H,this.store=Q,this.props=X||{},this.index=Y,this.keyPath=X?.keyPath||"id",this.upgrades={},this.version==="")this.numericVersion=0;else this.numericVersion=parseInt(H.replace(/\./g,""))}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(this.name==="")return console.error("No name has been defined for IndexedDB space."),Promise.reject();if(this.store==="")return console.error("No store has been defined for IndexedDB space."),Promise.reject();if(this.storage instanceof IDBDatabase)return Promise.resolve(this);else if(this.storage instanceof Promise)return this.storage;else{let z,H=new Promise((Q,X)=>{let Y=[],W=window.indexedDB.open(this.name,this.numericVersion);W.onerror=(Z)=>{X(Z)},W.onsuccess=(Z)=>{Q({storage:Z.target.result,upgrades:Y})},W.onupgradeneeded=(Z)=>{z=Z;let J=Z.target.result;if(Z.oldVersion<1){let B=J.createObjectStore(this.store,this.props);for(let I of Object.keys(this.index)){let K=this.index[I];B.createIndex(K.name,K.field,K.props)}}else{let B=Object.keys(this.upgrades).sort(),I=B.findIndex((K)=>{let[N]=K.split("::");return parseInt(N)===Z.oldVersion});if(I>-1)Y=B.slice(I).filter((K)=>{let[N,L]=K.split("::");return parseInt(N)<this.numericVersion&&parseInt(L)<=this.numericVersion})}let _=Z.target.transaction;if(_)_.addEventListener("complete",()=>{Q({storage:J,upgrades:Y})})}}).then(({storage:Q,upgrades:X})=>{return this.storage=Q,new Promise((Y)=>{let W=()=>Y(this);this._upgrade(X,W,z)})});return this.storage=H,H}}set(z=null,H){return this.open().then(()=>{return new Promise((Q,X)=>{let Y=this.storage.transaction(this.store,"readwrite").objectStore(this.store),W;if(z!==null){let Z={};Z[this.keyPath]=z,W=Y.put(Object.assign({},Z,H))}else W=Y.add(H);W.addEventListener("success",(Z)=>{Q({key:String(Z.target.result),value:H})}),W.addEventListener("error",(Z)=>{X(Z)})})})}update(z,H){return this.get(z).then((Q)=>{if(typeof Q>"u")return this.set(z,H);return new Promise((X,Y)=>{let Z=this.storage.transaction(this.store,"readwrite").objectStore(this.store).put(Object.assign({},Q,H));Z.addEventListener("success",(J)=>{X({key:String(J.target.result),value:H})}),Z.addEventListener("error",(J)=>{Y(J)})})})}get(z){return this.open().then(()=>{return new Promise((H,Q)=>{let Y=this.storage.transaction(this.store).objectStore(this.store).get(z);Y.addEventListener("success",(W)=>{let Z=W.target.result;if(typeof Z<"u"&&Z!==null)H(Z);else Q()}),Y.addEventListener("error",(W)=>{Q(W)})})})}getAll(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store).objectStore(this.store).getAll();X.addEventListener("success",(Y)=>{let W={};Y.target.result.forEach((J)=>{let _=J[this.keyPath];delete J[this.keyPath],W[_]=J}),z(W)}),X.addEventListener("error",(Y)=>{H(Y)})})})}contains(z){return this.get(z).then(()=>{return Promise.resolve()})}upgrade(z,H,Q){let X=`${parseInt(z.replace(/\./g,""))}::${parseInt(H.replace(/\./g,""))}`;return this.upgrades[X]=Q,Promise.resolve()}_upgrade(z,H,Q){if(z.length>0)this.upgrades[z[0]].call(this,this,Q).then(()=>{this._upgrade(z.slice(1),H,Q)}).catch((X)=>console.error(X));else H()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store,"readwrite").objectStore(this.store).getAllKeys();X.addEventListener("success",(Y)=>{z(Y.target.result.map(String))},!1),X.addEventListener("error",(Y)=>{H(Y)},!1)})})}remove(z){return this.get(z).then((H)=>{return new Promise((Q,X)=>{let W=this.storage.transaction(this.store,"readwrite").objectStore(this.store).delete(z);W.addEventListener("success",()=>{Q(H)},!1),W.addEventListener("error",(Z)=>{X(Z)},!1)})})}clear(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store,"readwrite").objectStore(this.store).clear();X.addEventListener("success",()=>{z()},!1),X.addEventListener("error",(Y)=>{H(Y)},!1)})})}}class E{name;version;store;endpoint;props;storage;constructor({name:z="",version:H="",store:Q="",endpoint:X="",props:Y={}}){this.name=z,this.version=H,this.store=Q,this.endpoint=`${X}${Q}/`,this.props=Y}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(typeof this.storage>"u")this.storage=G;return Promise.resolve(this)}set(z,H){return this.open().then(()=>{return this.storage.post(this.endpoint+z,H,this.props).then((Q)=>{return Promise.resolve({key:z,value:Q.json()})})})}update(z,H){return this.get(z).then((Q)=>{let X=Object.assign({},Q,H);return this.storage.put(this.endpoint+z,X,this.props).then((Y)=>{return Promise.resolve({key:z,value:Y.json()})})})}get(z){return this.open().then(()=>{return this.storage.json(this.endpoint+z,{},this.props)})}getAll(){return this.open().then(()=>{return this.storage.json(this.endpoint,{},this.props)})}contains(z){return this.keys().then((H)=>{if(H.includes(z))return Promise.resolve();else return Promise.reject()})}upgrade(){return Promise.reject()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then(()=>{return this.storage.json(this.endpoint,{keys:!0},this.props)})}remove(z){return this.open().then(()=>{return this.storage.delete(this.endpoint+z,{},this.props).then((H)=>{return H.json()})})}clear(){return this.open().then(()=>{return this.storage.delete(this.endpoint,{},this.props).then(()=>{})})}}var R={LocalStorage:F,SessionStorage:P,IndexedDB:U,RemoteStorage:E};class x{_configuration;adapter;callbacks;transformations;constructor(z=R.LocalStorage,H={}){this._configuration=Object.assign({},{name:"",version:"",store:""},H),this.adapter=new z(this._configuration),this.callbacks={create:[],update:[],delete:[]},this.transformations={}}configuration(z=null){if(z!==null){if(this._configuration=Object.assign({},this._configuration,z),this.adapter.configuration)this.adapter.configuration(z)}else return this._configuration}open(){return this.adapter.open().then(()=>{return Promise.resolve(this)})}set(z,H){for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].set==="function")H=this.transformations[Q].set(z,H);return this.adapter.set(z,H).then(({key:Q,value:X})=>{for(let Y of this.callbacks.create)Y.call(null,Q,X);return Promise.resolve({key:Q,value:X})})}update(z,H){for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].set==="function")H=this.transformations[Q].set(z,H);return this.adapter.update(z,H).then(({key:Q,value:X})=>{for(let Y of this.callbacks.update)Y.call(null,Q,X);return Promise.resolve({key:Q,value:X})})}get(z){return this.adapter.get(z).then((H)=>{for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].get==="function")H=this.transformations[Q].get(z,H);return H})}getAll(){return this.adapter.getAll().then((z)=>{for(let H of Object.keys(z))for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].get==="function")z[H]=this.transformations[Q].get(H,z[H]);return z})}each(z){return this.getAll().then((H)=>{let Q=[];for(let X of Object.keys(H))Q.push(z.call(this,X,H[X]));return Promise.all(Q)})}contains(z){return this.adapter.contains(z)}upgrade(z,H,Q){return this.adapter.upgrade(z,H,Q).then(()=>{return Promise.resolve(this)})}rename(z){return this.adapter.rename(z)}onCreate(z){this.callbacks.create.push(z)}onUpdate(z){this.callbacks.update.push(z)}onDelete(z){this.callbacks.delete.push(z)}addTransformation({id:z,get:H,set:Q}){this.transformations[z]={id:z,get:H,set:Q}}removeTransformation(z){delete this.transformations[z]}key(z,H=!1){return this.adapter.key(z,H)}keys(z=!1){return this.adapter.keys(z)}remove(z){return this.adapter.remove(z).then((H)=>{for(let Q of this.callbacks.delete)Q.call(null,z,H)})}clear(){return this.adapter.clear()}}class V{static capitalize(z){return z.replace(/\w\S*/g,(H)=>{return H.charAt(0).toUpperCase()+H.substring(1).toLowerCase()})}static suffix(z,H){let Q="",X=H.indexOf(z);if(X!==-1)X+=z.length,Q=H.substring(X);return Q}static selection(){let z=window.getSelection();if(z)return z.toString();return""}static prefix(z,H){let Q="",X=H.indexOf(z);if(X!==-1)Q=H.substring(0,X);return Q}static friendly(z){let H=[/[áàâãªä]/g,/[ÁÀÂÃÄ]/g,/[ÍÌÎÏ]/g,/[íìîï]/g,/[éèêë]/g,/[ÉÈÊË]/g,/[óòôõºö]/g,/[ÓÒÔÕÖ]/g,/[úùûü]/g,/[ÚÙÛÜ]/g,/ç/g,/Ç/g,/ñ/g,/Ñ/g,/_/g,/[''‹›<>']/g,/[""«»„"]/g,/[(){}[\]]/g,/[?¿!¡#$%&^*´`~/°|]/g,/[,.:;]/g,/ /g],Q=["a","A","I","i","e","E","o","O","u","U","c","C","n","N","-","","","","","","-"],X=z;for(let Y=0;Y<H.length;Y++)X=X.replace(H[Y],Q[Y]);return X}}class S{static callAsync(z,H,...Q){try{let X=z.apply(H,Q);if(X instanceof Promise)return X;else return Promise.resolve(X)}catch(X){return Promise.reject(X)}}static uuid(){if(typeof crypto<"u"&&crypto.getRandomValues)return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(z)=>{let H=parseInt(z,10);return(H^crypto.getRandomValues(new Uint8Array(1))[0]&15>>H/4).toString(16)});else{let z=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return z()+z()+"-"+z()+"-"+z()+"-"+z()+"-"+z()+z()+z()}}}if(typeof window==="object")window.Artemis=T;
|
|
2
|
+
|
|
3
|
+
//# debugId=D9F571478C6F1C6364756E2164756E21
|
|
4
|
+
//# sourceMappingURL=artemis.browser.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/Debug.ts", "../src/DOM.ts", "../src/Request.ts", "../src/FileSystem.ts", "../src/Form.ts", "../src/Platform.ts", "../src/Preload.ts", "../src/SpaceAdapter/LocalStorage.ts", "../src/SpaceAdapter/SessionStorage.ts", "../src/SpaceAdapter/IndexedDB.ts", "../src/SpaceAdapter/RemoteStorage.ts", "../src/Space.ts", "../src/Text.ts", "../src/Util.ts", "../src/browser.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * ==============================\n * Debug\n * ==============================\n */\n\n\n/**\n * Debug level enum\n */\nexport enum DebugLevel {\n\tNONE = 0,\n\tERROR = 1,\n\tWARNING = 2,\n\tINFO = 3,\n\tDEBUG = 4,\n\tALL = 5\n}\n\n/**\n * This class acts as a proxy for the console. It shares the same methods as the\n * web console but they are conditioned to a debug level.\n */\nexport class Debug {\n\tprivate static _level: DebugLevel = DebugLevel.NONE;\n\n\t/**\n\t * Set or get the log level\n\t *\n\t * @param level - The debug level to use\n\t * @returns The current debug level\n\t */\n\tstatic level(level?: DebugLevel): DebugLevel {\n\t\tif (typeof level === 'number') {\n\t\t\tthis._level = level;\n\t\t}\n\t\treturn this._level;\n\t}\n\n\t/**\n\t * Log the given elements.\n\t * Logs will only be made if the level is set to DEBUG or above\n\t *\n\t * @param args - Arguments to log\n\t */\n\tstatic log(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.log(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Show a debugging log\n\t * Logs will only be made if the level is set DEBUG or above\n\t *\n\t * @param args - Arguments to log\n\t */\n\tstatic debug(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.debug(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Show an info log\n\t * Logs will only be made if the level is set to INFO or above\n\t *\n\t * @param args - Arguments to log\n\t */\n\tstatic info(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.INFO) {\n\t\t\tconsole.info(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Show an error log\n\t * Logs will only be made if the level is set to ERROR or above\n\t *\n\t * @param args - Arguments to log\n\t */\n\tstatic error(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.ERROR) {\n\t\t\tconsole.error(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Show a warning log\n\t * Logs will only be made if the level is set to WARNING or above\n\t *\n\t * @param args - Arguments to log\n\t */\n\tstatic warning(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.WARNING) {\n\t\t\tconsole.warn(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Show data as a table\n\t * Table will only be made if the level is set to DEBUG or above\n\t *\n\t * @param args - Arguments to display as table\n\t */\n\tstatic table(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.table(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Start an indented group\n\t *\n\t * @param args - Group label arguments\n\t */\n\tstatic group(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.group(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Start an indented group collapsed by default\n\t *\n\t * @param args - Group label arguments\n\t */\n\tstatic groupCollapsed(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.groupCollapsed(...args);\n\t\t}\n\t}\n\n\t/**\n\t * End a previously started group\n\t */\n\tstatic groupEnd(): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.groupEnd();\n\t\t}\n\t}\n\n\t/**\n\t * Start a timer\n\t * The timer will only start if the level is set to DEBUG or above\n\t *\n\t * @param label - Timer label\n\t */\n\tstatic time(label?: string): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.time(label);\n\t\t}\n\t}\n\n\t/**\n\t * Log the time a timer has been running for\n\t * The time will only be logged if the level is set to DEBUG or above\n\t *\n\t * @param label - Timer label\n\t * @param args - Additional arguments to log\n\t */\n\tstatic timeLog(label?: string, ...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.timeLog(label, ...args);\n\t\t}\n\t}\n\n\t/**\n\t * End a timer\n\t * The timer will only be available if the level is set to DEBUG or above\n\t *\n\t * @param label - Timer label\n\t */\n\tstatic timeEnd(label?: string): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.timeEnd(label);\n\t\t}\n\t}\n\n\t/**\n\t * Show the stack trace\n\t * The stack trace will only be available if the level is set to DEBUG or above\n\t *\n\t * @param args - Arguments to log with trace\n\t */\n\tstatic trace(...args: unknown[]): void {\n\t\tif (this.level() >= DebugLevel.DEBUG) {\n\t\t\tconsole.trace(...args);\n\t\t}\n\t}\n}\n\n",
|
|
6
|
+
"/**\n * ==============================\n * DOM\n * ==============================\n */\n\n/**\n * Type for elements that can be used as a selector\n */\nexport type DOMSelector = string | Element | Element[] | NodeList | NodeListOf<Element> | HTMLElement[] | DOM | null;\n\n/**\n * Type for style properties object\n */\nexport type StyleProperties = Record<string, string | number>;\n\n/**\n * Type for offset object\n */\nexport interface DOMOffset {\n\ttop: number;\n\tleft: number;\n}\n\n/**\n * Event callback type\n */\nexport type EventCallback = (event: Event) => void;\n\n/**\n * Element callback type\n */\nexport type ElementCallback = (element: Element) => void;\n\n/**\n * Simple DOM manipulation functions\n */\nexport class DOM {\n\tpublic collection: Element[] | NodeListOf<Element>;\n\tpublic length: number;\n\tpublic _selector: DOMSelector;\n\n\t/**\n\t * Create a new DOM object\n\t *\n\t * @param selector - Selector or DOM element to use\n\t */\n\tconstructor(selector: DOMSelector) {\n\t\tif (selector === null) {\n\t\t\tthis.collection = [];\n\t\t\tthis.length = 0;\n\t\t\tthis._selector = null;\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof selector === 'string') {\n\t\t\tthis.collection = document.querySelectorAll(selector);\n\t\t\tthis.length = this.collection.length;\n\t\t\tthis._selector = selector;\n\t\t} else if (selector instanceof NodeList) {\n\t\t\tthis.collection = selector as NodeListOf<Element>;\n\t\t\tthis.length = selector.length;\n\t\t\tthis._selector = selector;\n\t\t} else if (selector instanceof DOM) {\n\t\t\tthis.collection = selector.collection;\n\t\t\tthis.length = this.collection.length;\n\t\t\tthis._selector = selector._selector;\n\t\t} else if (selector instanceof HTMLElement) {\n\t\t\tthis.collection = [selector];\n\t\t\tthis.length = this.collection.length;\n\t\t\tthis._selector = selector;\n\t\t} else if (Array.isArray(selector)) {\n\t\t\tthis.collection = selector;\n\t\t\tthis.length = selector.length;\n\t\t\tthis._selector = selector;\n\t\t} else {\n\t\t\tthis.collection = [];\n\t\t\tthis.length = 0;\n\t\t\tthis._selector = null;\n\t\t}\n\t}\n\n\t/**\n\t * Hide elements by setting their `display` property to 'none'.\n\t *\n\t * @returns Current instance\n\t */\n\thide(): this {\n\t\tfor (const element of this.collection) {\n\t\t\t(element as HTMLElement).style.display = 'none';\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Show elements by setting their `display` property to the given value.\n\t *\n\t * @param display - Display property to set\n\t * @returns Current instance\n\t */\n\tshow(display: string = 'block'): this {\n\t\tfor (const element of this.collection) {\n\t\t\t(element as HTMLElement).style.display = display;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a class to the classList object\n\t *\n\t * @param newClass - Class name to add\n\t * @returns Current instance\n\t */\n\taddClass(newClass: string): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.classList.add(newClass);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove a given class from the classList object\n\t *\n\t * @param oldClass - Class to remove. If it's empty or null, all classes will be removed\n\t * @returns Current instance\n\t */\n\tremoveClass(oldClass: string | null = null): this {\n\t\tif (oldClass !== null) {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\telement.classList.remove(oldClass);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\twhile (element.classList.length > 0) {\n\t\t\t\t\tconst className = element.classList.item(0);\n\t\t\t\t\tif (className) {\n\t\t\t\t\t\telement.classList.remove(className);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Toggle between two classes\n\t *\n\t * @param classes - Space separated class names\n\t * @returns Current instance\n\t */\n\ttoggleClass(classes: string): this {\n\t\tconst classList = classes.split(' ');\n\t\tfor (const element of this.collection) {\n\t\t\tfor (const className of classList) {\n\t\t\t\telement.classList.toggle(className);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Check if ALL elements in the collection have the given class\n\t *\n\t * @param classToCheck - Class name to check for\n\t * @returns Whether all elements have the class\n\t */\n\thasClass(classToCheck: string): boolean {\n\t\tfor (const element of this.collection) {\n\t\t\tif (!element.classList.contains(classToCheck)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Get or set the value from the elements\n\t *\n\t * @param value - Value to set to the elements\n\t * @returns If a value is provided, returns current instance. Otherwise returns the value(s) - single value if one element, array if multiple.\n\t */\n\tvalue(value?: string): this | string | string[] | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\t(element as HTMLInputElement).value = value;\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn (this.collection[0] as HTMLInputElement).value;\n\t\t\t}\n\t\t\tconst values: string[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push((element as HTMLInputElement).value);\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\t}\n\n\t/**\n\t * Focus on the first element matching the selector\n\t *\n\t * @returns Current instance\n\t */\n\tfocus(): this {\n\t\tif (this.length > 0) {\n\t\t\t(this.collection[0] as HTMLElement).focus();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'click' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tclick(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('click', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'keyup' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tkeyup(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('keyup', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'keydown' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tkeydown(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('keydown', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'submit' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tsubmit(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('submit', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'change' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tchange(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('change', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback for the 'scroll' event on every element matching the selector\n\t *\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\tscroll(callback: EventCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.addEventListener('scroll', callback, false);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a callback function to a given event\n\t *\n\t * @param event - Event to add the listener to\n\t * @param target - Target element on which to detect the event or callback function\n\t * @param callback - Callback function to run when the event is triggered\n\t * @returns Current instance\n\t */\n\ton(event: string, target: string | EventCallback, callback?: EventCallback): this {\n\t\tconst events = event.split(' ');\n\t\tfor (const element of this.collection) {\n\t\t\tfor (const evt of events) {\n\t\t\t\t// Check if no target was defined and just a function was provided\n\t\t\t\tif (typeof target === 'function') {\n\t\t\t\t\telement.addEventListener(evt, target, false);\n\t\t\t\t} else if (typeof target === 'string' && typeof callback === 'function') {\n\t\t\t\t\telement.addEventListener(evt, (e: Event) => {\n\t\t\t\t\t\tif (!e.target) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst domInstance = new DOM(e.target as Element);\n\t\t\t\t\t\tconst targetElement = domInstance.closestParent(target, this._selector as string);\n\n\t\t\t\t\t\tif (targetElement.exists()) {\n\t\t\t\t\t\t\tcallback.call(targetElement.get(0), e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Filter from the current collection to only those matching the new selector\n\t * Applies to ALL elements in the collection\n\t *\n\t * @param selector - Selector to filter the collection with\n\t * @returns New DOM instance with the filtered collection\n\t */\n\tfilter(selector: string): DOM {\n\t\tconst filtered: HTMLElement[] = [];\n\t\tfor (const element of this.collection) {\n\t\t\tif (element.matches(selector)) {\n\t\t\t\tfiltered.push(element as HTMLElement);\n\t\t\t}\n\t\t}\n\t\treturn new DOM(filtered.length > 0 ? filtered : null);\n\t}\n\n\t/**\n\t * Check if there are any elements that match the selector.\n\t *\n\t * @returns Whether elements matching the selector existed or not\n\t */\n\texists(): boolean {\n\t\treturn this.length > 0;\n\t}\n\n\t/**\n\t * Get or set a `data` property\n\t *\n\t * @param name - Name of the data property\n\t * @param value - Value of the property\n\t * @returns If no value is provided, returns the value(s) - single value if one element, array if multiple.\n\t */\n\tdata(name: string, value?: string): this | string | string[] | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\t(element as HTMLElement).dataset[name] = value;\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn (this.collection[0] as HTMLElement).dataset[name];\n\t\t\t}\n\t\t\tconst values: (string | undefined)[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push((element as HTMLElement).dataset[name]);\n\t\t\t}\n\t\t\treturn values as string[];\n\t\t}\n\t}\n\n\t/**\n\t * Remove a data property from all the elements on the collection given its name.\n\t *\n\t * @param name - Name of the data property to remove\n\t * @returns Current instance\n\t */\n\tremoveData(name: string): this {\n\t\tfor (const element of this.collection) {\n\t\t\tdelete (element as HTMLElement).dataset[name];\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get or set the text of elements\n\t *\n\t * @param value - Value to set the text to\n\t * @returns If no value is provided, returns the text(s) - single value if one element, array if multiple.\n\t */\n\ttext(value?: string): this | string | (string | null)[] | null | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\telement.textContent = value;\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn this.collection[0].textContent;\n\t\t\t}\n\t\t\tconst values: (string | null)[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push(element.textContent);\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\t}\n\n\t/**\n\t * Get or set the inner HTML of elements\n\t *\n\t * @param value - Value to set the HTML to\n\t * @returns If no value is provided, returns the HTML(s) - single value if one element, array if multiple.\n\t */\n\thtml(value?: string): this | string | string[] | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\telement.innerHTML = value;\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn this.collection[0].innerHTML;\n\t\t\t}\n\t\t\tconst values: string[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push(element.innerHTML);\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\t}\n\n\t/**\n\t * Append an element to ALL elements in the collection\n\t *\n\t * @param element - String representation of the element to add or an Element\n\t * @returns Current instance\n\t */\n\tappend(element: string | Element): this {\n\t\tfor (const el of this.collection) {\n\t\t\tif (typeof element === 'string') {\n\t\t\t\tconst div = document.createElement('div');\n\t\t\t\tdiv.innerHTML = element.trim();\n\t\t\t\tif (div.firstChild) {\n\t\t\t\t\tel.appendChild(div.firstChild.cloneNode(true));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tel.appendChild(element.cloneNode(true));\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepend an element to ALL elements in the collection\n\t *\n\t * @param element - String representation of the element to add or an Element\n\t * @returns Current instance\n\t */\n\tprepend(element: string | Element): this {\n\t\tfor (const el of this.collection) {\n\t\t\tif (typeof element === 'string') {\n\t\t\t\tconst div = document.createElement('div');\n\t\t\t\tdiv.innerHTML = element.trim();\n\t\t\t\tif (div.firstChild) {\n\t\t\t\t\tif (el.childNodes.length > 0) {\n\t\t\t\t\t\tel.insertBefore(div.firstChild.cloneNode(true), el.childNodes[0]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tel.appendChild(div.firstChild.cloneNode(true));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (el.childNodes.length > 0) {\n\t\t\t\t\tel.insertBefore(element.cloneNode(true), el.childNodes[0]);\n\t\t\t\t} else {\n\t\t\t\t\tel.appendChild(element.cloneNode(true));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Iterate over the collection of elements matching the selector\n\t *\n\t * @param callback - Callback to run for every element\n\t * @returns Current instance\n\t */\n\teach(callback: ElementCallback): this {\n\t\tfor (const element of this.collection) {\n\t\t\tcallback(element);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get an element from the collection given its index\n\t *\n\t * @param index - Index of the element to retrieve\n\t * @returns HTML Element in the position indicated by the index\n\t */\n\tget(index: number): Element | undefined {\n\t\treturn this.collection[index];\n\t}\n\n\t/**\n\t * Get the first element in the collection\n\t *\n\t * @returns DOM instance with the first element\n\t */\n\tfirst(): DOM {\n\t\tif (this.length > 0) {\n\t\t\treturn new DOM(this.collection[0] as HTMLElement);\n\t\t}\n\t\treturn new DOM(null);\n\t}\n\n\t/**\n\t * Get the last element in the collection\n\t *\n\t * @returns DOM instance with the last element\n\t */\n\tlast(): DOM {\n\t\tif (this.length > 0) {\n\t\t\treturn new DOM(this.collection[this.collection.length - 1] as HTMLElement);\n\t\t}\n\t\treturn new DOM(null);\n\t}\n\n\t/**\n\t * Check if any element in the collection is visible by checking their\n\t * display, offsetWidth and offsetHeight properties\n\t *\n\t * @returns Whether any element is visible\n\t */\n\tisVisible(): boolean {\n\t\tfor (const element of this.collection) {\n\t\t\tconst el = element as HTMLElement;\n\t\t\tif (el.style.display !== 'none' && el.offsetWidth > 0 && el.offsetHeight > 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Get the parents of ALL elements in the collection\n\t *\n\t * @returns DOM instance of the parent elements\n\t */\n\tparent(): DOM {\n\t\tconst parents: HTMLElement[] = [];\n\t\tfor (const element of this.collection) {\n\t\t\tif (element.parentElement && !parents.includes(element.parentElement)) {\n\t\t\t\tparents.push(element.parentElement);\n\t\t\t}\n\t\t}\n\t\treturn new DOM(parents.length > 0 ? parents : null);\n\t}\n\n\t/**\n\t * Find elements that match the given selector in ALL elements of the collection\n\t *\n\t * @param selector - Selector to find elements with\n\t * @returns DOM instance with found elements\n\t */\n\tfind(selector: string): DOM {\n\t\tconst found: HTMLElement[] = [];\n\t\tfor (const element of this.collection) {\n\t\t\tconst results = element.querySelectorAll(selector);\n\t\t\tfor (const result of results) {\n\t\t\t\tif (!found.includes(result as HTMLElement)) {\n\t\t\t\t\tfound.push(result as HTMLElement);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn new DOM(found.length > 0 ? found : null);\n\t}\n\n\t/**\n\t * Get the top and left offsets of elements in the collection\n\t *\n\t * @returns Single offset object if one element, array of offset objects if multiple\n\t */\n\toffset(): DOMOffset | DOMOffset[] | undefined {\n\t\tif (this.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (this.length === 1) {\n\t\t\tconst rect = this.collection[0].getBoundingClientRect();\n\t\t\treturn {\n\t\t\t\ttop: rect.top + document.body.scrollTop,\n\t\t\t\tleft: rect.left + document.body.scrollLeft\n\t\t\t};\n\t\t}\n\t\tconst offsets: DOMOffset[] = [];\n\t\tfor (const element of this.collection) {\n\t\t\tconst rect = element.getBoundingClientRect();\n\t\t\toffsets.push({\n\t\t\t\ttop: rect.top + document.body.scrollTop,\n\t\t\t\tleft: rect.left + document.body.scrollLeft\n\t\t\t});\n\t\t}\n\t\treturn offsets;\n\t}\n\n\t/**\n\t * Find the closest element matching the given selector for ALL elements.\n\t * This bubbles up from the initial object and then follows to its parents.\n\t *\n\t * @param selector - Selector to match the closest element with\n\t * @returns DOM instance with the closest HTML elements matching the selector\n\t */\n\tclosest(selector: string): DOM {\n\t\tconst found: HTMLElement[] = [];\n\t\tfor (const element of this.collection) {\n\t\t\tconst closest = element.closest(selector) as HTMLElement | null;\n\t\t\tif (closest && !found.includes(closest)) {\n\t\t\t\tfound.push(closest);\n\t\t\t}\n\t\t}\n\t\treturn new DOM(found.length > 0 ? found : null);\n\t}\n\n\t/**\n\t * Find the closest parent element matching the given selector. This bubbles up\n\t * from the initial object and then follows to its parents.\n\t *\n\t * @param selector - Selector to match the closest element with\n\t * @param limit - Selector for limit element. If the limit is reached and no element matching the provided selector was found, it will cause an early return.\n\t * @returns DOM instance with the closest HTML element matching the selector\n\t */\n\tclosestParent(selector: string, limit?: string): DOM {\n\t\tif (this.length === 0) {\n\t\t\treturn new DOM(null);\n\t\t}\n\n\t\tlet current: Element | null = this.collection[0];\n\t\twhile (current) {\n\t\t\t// Check if the current element matches the selector\n\t\t\tif (current.matches(selector)) {\n\t\t\t\treturn new DOM(current as HTMLElement);\n\t\t\t}\n\n\t\t\t// Check if we hit the limit\n\t\t\tif (typeof limit === 'string' && current.matches(limit)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcurrent = current.parentElement;\n\t\t}\n\t\treturn new DOM(null);\n\t}\n\n\t/**\n\t * Get or set the value of a given attribute\n\t *\n\t * @param attribute - Attribute's name\n\t * @param value - Value to set the attribute to\n\t * @returns If no value is provided, returns the attribute value(s) - single value if one element, array if multiple.\n\t */\n\tattribute(attribute: string, value?: string | number): this | string | (string | null)[] | null | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\telement.setAttribute(attribute, String(value));\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn this.collection[0].getAttribute(attribute);\n\t\t\t}\n\t\t\tconst values: (string | null)[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push(element.getAttribute(attribute));\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\t}\n\n\t/**\n\t * Check whether ALL elements have an attribute\n\t *\n\t * @param attribute - The name of the attribute to check existence for\n\t * @returns Whether all elements have the attribute\n\t */\n\thasAttribute(attribute: string): boolean {\n\t\tfor (const element of this.collection) {\n\t\t\tif (!element.hasAttribute(attribute)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Insert content after all elements in the collection\n\t *\n\t * @param content - String representation of the content to add\n\t * @returns Current instance\n\t */\n\tafter(content: string): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.insertAdjacentHTML('afterend', content);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Insert content before all elements in the collection\n\t *\n\t * @param content - String representation of the content to add\n\t * @returns Current instance\n\t */\n\tbefore(content: string): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.insertAdjacentHTML('beforebegin', content);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get or modify the `style` properties of the elements matching the selector\n\t *\n\t * @param properties - Properties to change or get. Can be either an individual property or a JSON object with key-value pairs\n\t * @param value - Value to set the property to when only changing one property\n\t * @returns If a property is given but not a value for it, returns the style value(s) - single value if one element, array if multiple.\n\t */\n\tstyle(properties: string | StyleProperties, value?: string): this | string | string[] | undefined {\n\t\t// Getting a style property\n\t\tif (typeof properties === 'string' && typeof value === 'undefined') {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn (this.collection[0] as HTMLElement).style.getPropertyValue(properties);\n\t\t\t}\n\t\t\tconst values: string[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push((element as HTMLElement).style.getPropertyValue(properties));\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\n\t\t// Setting style properties\n\t\tfor (const element of this.collection) {\n\t\t\tconst el = element as HTMLElement;\n\t\t\tif (typeof properties === 'string' && typeof value !== 'undefined') {\n\t\t\t\tel.style.setProperty(properties, value);\n\t\t\t} else if (typeof properties === 'object') {\n\t\t\t\tfor (const property in properties) {\n\t\t\t\t\tel.style.setProperty(property, String(properties[property]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Animate the given `style` properties on all elements in the collection\n\t * with a given time duration\n\t *\n\t * @param style - JSON object with the key-value pairs of properties to animate\n\t * @param time - Time in milliseconds during which the properties will be animated\n\t * @returns Current instance\n\t */\n\tanimate(style: Record<string, number>, time: number): this {\n\t\tfor (let i = 0; i < this.collection.length; i++) {\n\t\t\tconst element = this.collection[i] as HTMLElement;\n\t\t\tfor (const property in style) {\n\t\t\t\tconst start = Date.now();\n\t\t\t\tlet initialValue: number;\n\n\t\t\t\tif (typeof element.style.getPropertyValue(property) !== 'undefined' && element.style.getPropertyValue(property) !== '') {\n\t\t\t\t\tinitialValue = parseFloat(element.style.getPropertyValue(property));\n\n\t\t\t\t\tconst timer = setInterval(() => {\n\t\t\t\t\t\tconst step = Math.min(1, (Date.now() - start) / time);\n\t\t\t\t\t\telement.style.setProperty(property, String(initialValue + step * (style[property] - initialValue)));\n\n\t\t\t\t\t\tif (step === 1) {\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 25);\n\t\t\t\t\telement.style.setProperty(property, String(initialValue));\n\t\t\t\t} else if (typeof (element as unknown as Record<string, number>)[property] !== 'undefined') {\n\t\t\t\t\tinitialValue = (element as unknown as Record<string, number>)[property];\n\n\t\t\t\t\tconst timer = setInterval(() => {\n\t\t\t\t\t\tconst step = Math.min(1, (Date.now() - start) / time);\n\t\t\t\t\t\t(element as unknown as Record<string, number>)[property] = initialValue + step * (style[property] - initialValue);\n\n\t\t\t\t\t\tif (step === 1) {\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 25);\n\t\t\t\t\t(element as unknown as Record<string, number>)[property] = initialValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Use a fade in animation on ALL elements in the collection\n\t *\n\t * @param time - Time duration for the animation\n\t * @param callback - Callback function to run once all animations are over\n\t * @returns Current instance\n\t */\n\tfadeIn(time: number = 400, callback?: () => void): this {\n\t\tlet completed = 0;\n\t\tconst total = this.collection.length;\n\n\t\tfor (const el of this.collection) {\n\t\t\tconst element = el as HTMLElement;\n\t\t\telement.style.opacity = '0';\n\n\t\t\tlet last = Date.now();\n\n\t\t\tconst tick = (): void => {\n\t\t\t\telement.style.opacity = String(parseFloat(element.style.opacity) + (Date.now() - last) / time);\n\t\t\t\tlast = Date.now();\n\n\t\t\t\tif (parseFloat(element.style.opacity) < 1) {\n\t\t\t\t\trequestAnimationFrame(tick);\n\t\t\t\t} else {\n\t\t\t\t\tcompleted++;\n\t\t\t\t\tif (completed === total && typeof callback === 'function') {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttick();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Use a fade out animation on ALL elements in the collection\n\t *\n\t * @param time - Time duration for the animation\n\t * @param callback - Callback function to run once all animations are over\n\t * @returns Current instance\n\t */\n\tfadeOut(time: number = 400, callback?: () => void): this {\n\t\tlet completed = 0;\n\t\tconst total = this.collection.length;\n\n\t\tfor (const el of this.collection) {\n\t\t\tconst element = el as HTMLElement;\n\t\t\tlet last = Date.now();\n\n\t\t\tconst tick = (): void => {\n\t\t\t\telement.style.opacity = String(parseFloat(element.style.opacity) - (Date.now() - last) / time);\n\t\t\t\tlast = Date.now();\n\n\t\t\t\tif (parseFloat(element.style.opacity) > 0) {\n\t\t\t\t\trequestAnimationFrame(tick);\n\t\t\t\t} else {\n\t\t\t\t\tcompleted++;\n\t\t\t\t\tif (completed === total && typeof callback === 'function') {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttick();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Check if ALL elements in the collection match a given selector\n\t *\n\t * @param selector - Selector to match\n\t * @returns Whether all elements match the selector\n\t */\n\tmatches(selector: string): boolean {\n\t\tif (this.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const element of this.collection) {\n\t\t\tif (!element.matches(selector)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Remove all elements in the collection\n\t *\n\t * @returns Current instance\n\t */\n\tremove(): this {\n\t\tfor (const element of this.collection) {\n\t\t\telement.parentNode?.removeChild(element);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Replace ALL elements in the collection with a new element\n\t *\n\t * @param newElement - The replacement element or HTML string\n\t * @returns Current instance\n\t */\n\treplaceWith(newElement: string | Element): this {\n\t\tfor (const element of this.collection) {\n\t\t\tlet replaceElement: Element;\n\n\t\t\tif (typeof newElement === 'string') {\n\t\t\t\tconst div = document.createElement('div');\n\t\t\t\tdiv.innerHTML = newElement;\n\t\t\t\treplaceElement = div.firstChild as Element;\n\t\t\t} else {\n\t\t\t\treplaceElement = newElement.cloneNode(true) as Element;\n\t\t\t}\n\n\t\t\telement.parentElement?.replaceChild(replaceElement, element);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Reset every element in the collection (for form elements)\n\t *\n\t * @returns Current instance\n\t */\n\treset(): this {\n\t\tfor (const element of this.collection) {\n\t\t\tif ((element as HTMLFormElement).reset) {\n\t\t\t\t(element as HTMLFormElement).reset();\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get or set a property for elements in the collection\n\t *\n\t * @param property - Property name to set or get\n\t * @param value - Value to set the property to\n\t * @returns If no value is provided, returns the property value(s) - single value if one element, array if multiple.\n\t */\n\tproperty<T = unknown>(property: string, value?: T): this | T | T[] | undefined {\n\t\tif (typeof value !== 'undefined') {\n\t\t\tfor (const element of this.collection) {\n\t\t\t\t(element as unknown as Record<string, T>)[property] = value;\n\t\t\t}\n\t\t\treturn this;\n\t\t} else {\n\t\t\tif (this.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (this.length === 1) {\n\t\t\t\treturn (this.collection[0] as unknown as Record<string, T>)[property];\n\t\t\t}\n\t\t\tconst values: T[] = [];\n\t\t\tfor (const element of this.collection) {\n\t\t\t\tvalues.push((element as unknown as Record<string, T>)[property]);\n\t\t\t}\n\t\t\treturn values;\n\t\t}\n\t}\n}\n\n/**\n * Simple wrapper function to use the DOM library\n *\n * @param selector - Selector or DOM element to use\n * @returns DOM instance\n */\nexport function $_(selector: DOMSelector): DOM {\n\treturn new DOM(selector);\n}\n\n/**\n * Utility function to attach the 'load' listener to the window\n *\n * @param callback - Callback function to run when the window is ready\n */\nexport function $_ready(callback: EventListener): void {\n\twindow.addEventListener('load', callback);\n}\n\n",
|
|
7
|
+
"/**\n * ==============================\n * Request\n * ==============================\n */\n\n/**\n * Type for request data object\n */\nexport type RequestData = Record<string, string | number | boolean>;\n\n/**\n * Type for request options\n */\nexport interface RequestOptions extends Omit<RequestInit, 'headers'> {\n\theaders?: Record<string, string>;\n}\n\n/**\n * Simple Wrapper for the fetch API, providing simple functions to handle requests\n */\nexport class Request {\n\t/**\n\t * Serialize an object of data into a URI encoded format\n\t *\n\t * @param data - Key-value object of data to serialize\n\t * @returns Serialized Data\n\t */\n\tstatic serialize(data: RequestData): string {\n\t\treturn Object.keys(data).map((key) => {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(String(data[key]));\n\t\t}).join('&');\n\t}\n\n\t/**\n\t * Make a GET request to a given URL with the provided data parameters\n\t * and an optional configuration object for the request.\n\t *\n\t * @param url - URL to make the request to\n\t * @param data - Parameters to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the response of the request\n\t */\n\tstatic get(url: string, data: RequestData = {}, options: RequestOptions = {}): Promise<Response> {\n\t\tconst query = Request.serialize(data);\n\n\t\t// Check if there is actually any data parameters and join them to the\n\t\t// url as query parameters\n\t\tif (query !== '') {\n\t\t\turl = `${url}?${query}`;\n\t\t}\n\n\t\treturn fetch(url, options as RequestInit);\n\t}\n\n\t/**\n\t * Make a POST request to a given URL with the provided data and an optional\n\t * configuration object for the request.\n\t *\n\t * @param url - URL to make the request\n\t * @param data - Set of data to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the response of the request\n\t */\n\tstatic post(url: string, data: RequestData, options: RequestOptions = {}): Promise<Response> {\n\t\tlet formData: FormData | string;\n\n\t\tconst contentType = options.headers?.['Content-Type'];\n\t\tif (contentType !== undefined) {\n\t\t\tif (contentType === 'multipart/form-data') {\n\t\t\t\tformData = new FormData();\n\t\t\t\tfor (const value in data) {\n\t\t\t\t\tformData.append(value, String(data[value]));\n\t\t\t\t}\n\t\t\t} else if (contentType === 'application/json') {\n\t\t\t\tformData = JSON.stringify(data);\n\t\t\t} else {\n\t\t\t\tformData = Request.serialize(data);\n\t\t\t}\n\t\t} else {\n\t\t\tformData = Request.serialize(data);\n\t\t}\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/x-www-form-urlencoded',\n\t\t\t...options.headers\n\t\t};\n\n\t\t// Delete the explicit multipart/form-data header to allow boundary automatic filling\n\t\tif (headers['Content-Type'] === 'multipart/form-data') {\n\t\t\tdelete headers['Content-Type'];\n\t\t}\n\n\t\tconst props: RequestInit = {\n\t\t\t...options,\n\t\t\tmethod: 'POST',\n\t\t\theaders,\n\t\t\tbody: formData\n\t\t};\n\n\t\treturn fetch(url, props);\n\t}\n\n\t/**\n\t * Make a PUT request to a given URL with the provided data and an optional\n\t * configuration object for the request.\n\t *\n\t * @param url - URL to make the request\n\t * @param data - Set of data to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the response of the request\n\t */\n\tstatic put(url: string, data: RequestData, options: RequestOptions = {}): Promise<Response> {\n\t\treturn Request.post(url, data, Object.assign({}, { method: 'PUT' }, options));\n\t}\n\n\t/**\n\t * Make a DELETE request to a given URL with the provided data and an optional\n\t * configuration object for the request.\n\t *\n\t * @param url - URL to make the request\n\t * @param data - Parameters to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the response of the request\n\t */\n\tstatic delete(url: string, data: RequestData, options: RequestOptions = {}): Promise<Response> {\n\t\treturn Request.get(url, data, Object.assign({}, { method: 'DELETE' }, options));\n\t}\n\n\t/**\n\t * Request a JSON object from a given URL through a GET request\n\t *\n\t * @param url - URL to make the request to\n\t * @param data - Parameters to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the json object obtained from the request response\n\t */\n\tstatic json<T = unknown>(url: string, data: RequestData = {}, options: RequestOptions = {}): Promise<T> {\n\t\treturn Request.get(url, data, options).then((response) => {\n\t\t\treturn response.json() as Promise<T>;\n\t\t});\n\t}\n\n\t/**\n\t * Request a Blob from a given URL through a GET request\n\t *\n\t * @param url - URL to make the request to\n\t * @param data - Parameters to send in the URL, represented as a JSON object\n\t * @param options - Options object for configurations you want to use in the fetch request\n\t * @returns Resolves to the blob obtained from the request response\n\t */\n\tstatic blob(url: string, data: RequestData = {}, options: RequestOptions = {}): Promise<Blob> {\n\t\treturn Request.get(url, data, options).then((response) => {\n\t\t\treturn response.blob();\n\t\t});\n\t}\n}\n\n",
|
|
8
|
+
"/**\n * ==============================\n * File System\n * ==============================\n */\n\nimport { Request, RequestOptions } from './Request';\n\n/**\n * File read type options\n */\nexport type FileReadType = 'text' | 'base64' | 'buffer';\n\n/**\n * File read result type based on read type\n */\nexport interface FileReadResult {\n\tevent: ProgressEvent<FileReader>;\n\tcontent: string | ArrayBuffer | null;\n}\n\n/**\n * A simple class wrapper for the File and FileReader web API, while this class\n * doesn't actually provide access to the host file system, it does provide useful\n * utilities for form file inputs and remote content loading.\n */\nexport class FileSystem {\n\t/**\n\t * Read a file from a remote location given a URL. This function will fetch\n\t * the file blob using the Request class and then use the read() function\n\t * to read the blob in the format required.\n\t *\n\t * @param url - URL to fetch the file from\n\t * @param type - Type of data to be read, values can be 'text', 'base64' and 'buffer'\n\t * @param props - Props to send to the Request object\n\t * @returns Content of the file. The format depends on the type parameter used.\n\t */\n\tstatic readRemote(url: string, type: FileReadType = 'base64', props: RequestOptions = {}): Promise<FileReadResult> {\n\t\treturn Request.blob(url, {}, props).then((file) => {\n\t\t\treturn FileSystem.read(file, type);\n\t\t});\n\t}\n\n\t/**\n\t * Read a given File or Blob object.\n\t *\n\t * @param file - File to read\n\t * @param type - Type of data to be read, values can be 'text', 'base64' and 'buffer'\n\t * @returns Promise that resolves to the load event and content of the file\n\t */\n\tstatic read(file: File | Blob, type: FileReadType = 'text'): Promise<FileReadResult> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst reader = new FileReader();\n\n\t\t\treader.onload = (event: ProgressEvent<FileReader>) => {\n\t\t\t\t// Pass down the event object and the content\n\t\t\t\tresolve({\n\t\t\t\t\tevent,\n\t\t\t\t\tcontent: event.target?.result ?? null\n\t\t\t\t});\n\t\t\t};\n\n\t\t\treader.onerror = (error) => {\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tif (type === 'base64') {\n\t\t\t\treader.readAsDataURL(file);\n\t\t\t} else if (type === 'buffer') {\n\t\t\t\treader.readAsArrayBuffer(file);\n\t\t\t} else {\n\t\t\t\treader.readAsText(file, 'UTF-8');\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Create a new File, this uses the File API and will not actually create\n\t * a file in the user's file system, however using it with other features,\n\t * that may be possible\n\t *\n\t * @param name - Name of the file (Including extension)\n\t * @param content - Content to save in the file\n\t * @param type - Mime Type for the file\n\t * @returns Promise resolving to the created File\n\t */\n\tstatic create(name: string, content: BlobPart, type: string = 'text/plain'): Promise<File> {\n\t\treturn Promise.resolve(new File([content], name, { type }));\n\t}\n\n\t/**\n\t * Returns the extension of a file given its file name.\n\t *\n\t * @param name - Name or full path of the file\n\t * @returns File extension without the leading dot (.)\n\t */\n\tstatic extension(name: string): string {\n\t\treturn name.split('.').pop() ?? '';\n\t}\n\n\t/**\n\t * Check if a file is an image by its extension.\n\t *\n\t * @param name - Name or full path of the file\n\t * @returns Whether the file is an image\n\t */\n\tstatic isImage(name: string): boolean {\n\t\tconst extensions = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'bmp'];\n\t\treturn extensions.indexOf(FileSystem.extension(name).toLowerCase()) > -1;\n\t}\n}\n\n",
|
|
9
|
+
"/**\n * ==============================\n * Form\n * ==============================\n */\n\nimport { $_ } from './DOM';\n\n/**\n * Form data object type\n */\nexport type FormData = Record<string, string | File | FileList | undefined>;\n\n/**\n * Utility class that provides simple functions for filling and retrieving values\n * from forms. This class requires the use of the `data-form` attribute.\n */\nexport class Form {\n\t/**\n\t * Fill a form's inputs with the given values. Each key in the provided object\n\t * must match the `name` attribute of the input to fill.\n\t *\n\t * @param name - Form name. Must match the `data-form` attribute of the Form.\n\t * @param data - JSON object with key-value pairs to fill the inputs.\n\t */\n\tstatic fill(name: string, data: Record<string, string>): void {\n\t\tfor (const field in data) {\n\t\t\tconst element = $_(`form[data-form='${name}'] [name='${field}']`).get(0) as HTMLInputElement | undefined;\n\t\t\tif (typeof element !== 'undefined') {\n\t\t\t\tswitch (element.type) {\n\t\t\t\t\tcase 'file':\n\t\t\t\t\tcase 'file[]':\n\t\t\t\t\t\t// Cannot programmatically set file input values\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\telement.value = data[field];\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get all the values from a form's inputs. The keys are mapped using the\n\t * `name` attribute of each input.\n\t *\n\t * @param name - Form name. Must match the `data-form` attribute of the Form.\n\t * @returns Key-value JSON object\n\t */\n\tstatic values(name: string): FormData {\n\t\tconst data: FormData = {};\n\t\t$_(`form[data-form='${name}'] [name]`).each((el: Element) => {\n\t\t\tconst element = el as HTMLInputElement;\n\t\t\tlet value: string | File | FileList | undefined;\n\t\t\tswitch (element.type) {\n\t\t\t\tcase 'file[]':\n\t\t\t\t\tvalue = element.files ?? undefined;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'file':\n\t\t\t\t\tvalue = element.files?.[0];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = element.value;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (typeof value !== 'undefined' && value !== null) {\n\t\t\t\tdata[element.name] = value;\n\t\t\t}\n\t\t});\n\n\t\treturn data;\n\t}\n}\n\n",
|
|
10
|
+
"/**\n * ==============================\n * Platform\n * ==============================\n */\n\n/**\n * Desktop platform types\n */\nexport type DesktopPlatform = 'Windows' | 'macOS' | 'Linux' | 'FreeBSD' | 'webOS' | 'Any';\n\n/**\n * Mobile platform types\n */\nexport type MobilePlatform = 'Android' | 'iOS' | 'Opera' | 'Windows' | 'BlackBerry' | 'Any';\n\n/**\n * Orientation types\n */\nexport type Orientation = 'portrait' | 'landscape';\n\n/**\n * Extended Navigator interface for userAgentData\n */\ninterface NavigatorUAData {\n\tplatform?: string;\n\tbrands?: { brand: string; version: string }[];\n\tmobile?: boolean;\n}\n\ndeclare global {\n\tinterface Navigator {\n\t\tuserAgentData?: NavigatorUAData;\n\t}\n}\n\n/**\n * Extended window interface for process (Electron)\n */\ninterface ElectronWindow extends Window {\n\tprocess?: {\n\t\ttype?: string;\n\t\tversions?: {\n\t\t\telectron?: string;\n\t\t};\n\t};\n\tcordova?: unknown;\n}\n\n/**\n * General checks for what kind of platform is being used to run the app.\n */\nexport class Platform {\n\t/**\n\t * Check if the screen has a retina pixel ratio\n\t * @returns Whether the screen is retina\n\t */\n\tstatic retina(): boolean {\n\t\treturn window.devicePixelRatio >= 2;\n\t}\n\n\t/**\n\t * Check if the device is on portrait orientation\n\t * @returns Whether device is in portrait mode\n\t */\n\tstatic portrait(): boolean {\n\t\treturn window.screen.orientation.type === 'portrait-primary' || window.screen.orientation.type === 'portrait-secondary';\n\t}\n\n\t/**\n\t * Check if the device is on landscape orientation\n\t * @returns Whether device is in landscape mode\n\t */\n\tstatic landscape(): boolean {\n\t\treturn window.screen.orientation.type === 'landscape-primary' || window.screen.orientation.type === 'landscape-secondary';\n\t}\n\n\t/**\n\t * Get device Orientation\n\t * @returns 'portrait' or 'landscape'\n\t */\n\tstatic orientation(): Orientation {\n\t\treturn Platform.portrait() ? 'portrait' : 'landscape';\n\t}\n\n\t/**\n\t * Check if the app is running over Electron\n\t * @returns Whether running in Electron\n\t */\n\tstatic electron(): boolean {\n\t\tconst win = window as ElectronWindow;\n\n\t\t// Renderer process\n\t\tif (typeof win !== 'undefined' && typeof win.process === 'object' && win.process?.type === 'renderer') {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Main process (Node.js/Electron environment)\n\t\tconst nodeProcess = typeof globalThis !== 'undefined' ? (globalThis as { process?: { versions?: { electron?: string } } }).process : undefined;\n\t\tif (nodeProcess && typeof nodeProcess.versions === 'object' && !!nodeProcess.versions?.electron) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Detect the user agent when the `nodeIntegration` option is set to true\n\t\tif (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if the app is running over Cordova\n\t * @returns Whether running in Cordova\n\t */\n\tstatic cordova(): boolean {\n\t\treturn !!(window as ElectronWindow).cordova;\n\t}\n\n\t/**\n\t * Get the platform string using modern userAgentData API with fallback\n\t * @returns Platform string\n\t */\n\tprivate static getPlatformString(): string {\n\t\t// Try modern userAgentData first\n\t\tif (navigator.userAgentData?.platform) {\n\t\t\treturn navigator.userAgentData.platform;\n\t\t}\n\t\t// Fallback to userAgent parsing\n\t\tconst ua = navigator.userAgent;\n\t\tif (ua.includes('Win')) return 'Windows';\n\t\tif (ua.includes('Mac')) return 'macOS';\n\t\tif (ua.includes('Linux')) return 'Linux';\n\t\tif (ua.includes('FreeBSD')) return 'FreeBSD';\n\t\tif (ua.includes('WebTV')) return 'webOS';\n\t\treturn '';\n\t}\n\n\t/**\n\t * Check if the app is running in a desktop platform\n\t * @param platform - Check for a specific desktop platform\n\t * @returns Whether running on specified desktop platform\n\t */\n\tstatic desktop(platform: DesktopPlatform = 'Any'): boolean {\n\t\tconst platformString = Platform.getPlatformString();\n\n\t\tswitch (platform) {\n\t\t\tcase 'Windows':\n\t\t\t\treturn platformString === 'Windows' || platformString.includes('Win');\n\n\t\t\tcase 'macOS':\n\t\t\t\treturn platformString === 'macOS' || platformString.includes('Mac');\n\n\t\t\tcase 'Linux':\n\t\t\t\treturn platformString === 'Linux' || platformString.includes('Linux');\n\n\t\t\tcase 'FreeBSD':\n\t\t\t\treturn platformString === 'FreeBSD' || platformString.includes('FreeBSD');\n\n\t\t\tcase 'webOS':\n\t\t\t\treturn platformString === 'webOS' || platformString.includes('WebTV');\n\n\t\t\tcase 'Any':\n\t\t\tdefault:\n\t\t\t\treturn ['Windows', 'macOS', 'Linux', 'FreeBSD', 'webOS'].some(p =>\n\t\t\t\t\tplatformString === p || platformString.includes(p.replace('macOS', 'Mac').replace('webOS', 'WebTV'))\n\t\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check if the app is running in a mobile platform\n\t * @param platform - Check for a specific mobile platform\n\t * @returns Whether running on specified mobile platform\n\t */\n\tstatic mobile(platform: MobilePlatform = 'Any'): boolean {\n\t\t// Try modern userAgentData first for general mobile detection\n\t\tif (navigator.userAgentData?.mobile !== undefined && platform === 'Any') {\n\t\t\treturn navigator.userAgentData.mobile;\n\t\t}\n\n\t\t// Fallback to userAgent for specific platform detection\n\t\tconst ua = navigator.userAgent;\n\n\t\tswitch (platform) {\n\t\t\tcase 'Android':\n\t\t\t\treturn /Android/i.test(ua);\n\n\t\t\tcase 'iOS':\n\t\t\t\treturn /iPhone|iPad|iPod/i.test(ua);\n\n\t\t\tcase 'Opera':\n\t\t\t\treturn /Opera Mini/i.test(ua);\n\n\t\t\tcase 'Windows':\n\t\t\t\treturn /Windows Phone|IEMobile|WPDesktop/i.test(ua);\n\n\t\t\tcase 'BlackBerry':\n\t\t\t\treturn /BlackBerry|BB10/i.test(ua);\n\n\t\t\tcase 'Any':\n\t\t\tdefault:\n\t\t\t\treturn /Android|iPhone|iPad|iPod|Windows Phone|IEMobile|WPDesktop|BlackBerry|BB10/i.test(ua);\n\t\t}\n\t}\n\n\t/**\n\t * Check if the platform allows the use of service workers\n\t *\n\t * @returns Whether service workers are supported\n\t */\n\tstatic serviceWorkers(): boolean {\n\t\tif (typeof navigator !== 'undefined') {\n\t\t\tif ('serviceWorker' in navigator && location.protocol.indexOf('http') > -1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n\n",
|
|
11
|
+
"/**\n * ==============================\n * Preload\n * ==============================\n */\n\nimport { Request } from './Request';\n\n/**\n * A simple class for asset preloading. This class assumes you have a service\n * worker set up that will be caching all requests.\n */\nexport class Preload {\n\t/**\n\t * Preload an image file\n\t *\n\t * @param route - Route to the image\n\t * @returns Resolves to the image object or gets rejected with the rejection event\n\t */\n\tstatic image(route: string): Promise<HTMLImageElement> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst image = new Image();\n\n\t\t\timage.onload = () => {\n\t\t\t\tresolve(image);\n\t\t\t};\n\n\t\t\timage.onerror = (e) => {\n\t\t\t\treject(e);\n\t\t\t};\n\n\t\t\timage.src = route;\n\t\t});\n\t}\n\n\t/**\n\t * Preload any kind of file\n\t *\n\t * @param route - Route to the file\n\t * @returns Resolves or rejects depending on request success\n\t */\n\tstatic file(route: string): Promise<Blob> {\n\t\treturn Request.blob(route);\n\t}\n}\n\n",
|
|
12
|
+
"/**\n * ==============================\n * Local Storage Adapter\n * ==============================\n */\n\nimport type { LocalStorageConfiguration, StorageValue, KeyValueResult, UpgradeCallback } from './types';\n\n/**\n * The Local Storage Adapter provides the Space Class the ability to interact\n * with the localStorage API found in most modern browsers.\n */\nexport class LocalStorage {\n\tpublic name: string;\n\tpublic version: string;\n\tpublic store: string;\n\tpublic id: string;\n\tpublic numericVersion: number;\n\tpublic upgrades: Record<string, UpgradeCallback<LocalStorage>>;\n\tpublic storage: Storage | Promise<LocalStorage> | undefined;\n\n\t/**\n\t * Create a new LocalStorage. If no configuration is provided, the LocalStorage\n\t * global object is used. The LocalStorage Adapter can provide independency\n\t * by store name and space name.\n\t *\n\t * @param configuration - Configuration Object for the Adapter\n\t */\n\tconstructor({ name = '', version = '', store = '' }: LocalStorageConfiguration) {\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.store = store;\n\t\tthis.upgrades = {};\n\n\t\tif (this.version === '') {\n\t\t\tthis.numericVersion = 0;\n\t\t} else {\n\t\t\tthis.numericVersion = parseInt(version.replace(/\\./g, ''));\n\t\t}\n\n\t\tif (name !== '' && version !== '' && store !== '') {\n\t\t\tthis.id = `${this.name}::${this.store}::${this.version}_`;\n\t\t} else if (name !== '' && version !== '') {\n\t\t\tthis.id = `${this.name}::${this.version}_`;\n\t\t} else if (name !== '') {\n\t\t\tthis.id = `${this.name}::_`;\n\t\t} else {\n\t\t\tthis.id = '';\n\t\t}\n\t}\n\n\t/**\n\t * Modify the configuration\n\t *\n\t * @param config - Configuration object to set up\n\t */\n\tconfiguration(config: LocalStorageConfiguration): void {\n\t\tif (config.name) this.name = config.name;\n\t\tif (config.version) this.version = config.version;\n\t\tif (config.store) this.store = config.store;\n\t}\n\n\t/**\n\t * Open the Storage Object\n\t *\n\t * @returns Promise resolving to this adapter\n\t */\n\topen(): Promise<this> {\n\t\tif (this.storage instanceof Storage) {\n\t\t\treturn Promise.resolve(this);\n\t\t} else if (this.storage instanceof Promise) {\n\t\t\treturn this.storage as Promise<this>;\n\t\t} else {\n\t\t\tconst openPromise: Promise<this> = new Promise<{ upgrades: string[] }>((resolve) => {\n\t\t\t\tlet upgradesToApply: string[] = [];\n\n\t\t\t\t// Check if this space is versioned\n\t\t\t\tif (this.version !== '') {\n\t\t\t\t\t// Get the versionless part of the ID\n\t\t\t\t\tlet versionless = '';\n\t\t\t\t\tif (this.name !== '' && this.version !== '' && this.store !== '') {\n\t\t\t\t\t\tversionless = `${this.name}::${this.store}::`;\n\t\t\t\t\t} else if (this.name !== '' && this.version !== '') {\n\t\t\t\t\t\tversionless = `${this.name}::`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get all the currently stored keys that contain the versionless ID\n\t\t\t\t\tconst storedVersions = Object.keys(window.localStorage).filter((key) => {\n\t\t\t\t\t\treturn key.indexOf(versionless) === 0;\n\t\t\t\t\t}).map((key) => {\n\t\t\t\t\t\treturn key.replace(versionless, '').split('_')[0];\n\t\t\t\t\t}).filter((key) => {\n\t\t\t\t\t\treturn key.indexOf('::') === -1;\n\t\t\t\t\t}).sort();\n\n\t\t\t\t\tif (storedVersions.length > 0) {\n\t\t\t\t\t\tconst oldVersion = storedVersions[0];\n\t\t\t\t\t\tconst oldVersionNumeric = parseInt(oldVersion.replace(/\\./g, ''));\n\n\t\t\t\t\t\tif (oldVersionNumeric < this.numericVersion) {\n\t\t\t\t\t\t\tconst availableUpgrades = Object.keys(this.upgrades).sort();\n\n\t\t\t\t\t\t\tconst startFrom = availableUpgrades.findIndex((u) => {\n\t\t\t\t\t\t\t\tconst [old] = u.split('::');\n\t\t\t\t\t\t\t\treturn parseInt(old) === oldVersionNumeric;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (startFrom > -1) {\n\t\t\t\t\t\t\t\tupgradesToApply = availableUpgrades.slice(startFrom).filter((u) => {\n\t\t\t\t\t\t\t\t\tconst [old, next] = u.split('::');\n\t\t\t\t\t\t\t\t\treturn parseInt(old) < this.numericVersion && parseInt(next) <= this.numericVersion;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Get the previous ID using the old version\n\t\t\t\t\t\t\tlet previousId = `${this.name}::${oldVersion}_`;\n\n\t\t\t\t\t\t\tif (this.name !== '' && this.version !== '' && this.store !== '') {\n\t\t\t\t\t\t\t\tpreviousId = `${this.name}::${this.store}::${oldVersion}_`;\n\t\t\t\t\t\t\t} else if (this.name !== '' && this.version !== '') {\n\t\t\t\t\t\t\t\tpreviousId = `${this.name}::${oldVersion}_`;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Get all keys from the previous version\n\t\t\t\t\t\t\tconst keys = Object.keys(window.localStorage).filter((key) => {\n\t\t\t\t\t\t\t\treturn key.indexOf(previousId) === 0;\n\t\t\t\t\t\t\t}).map((key) => {\n\t\t\t\t\t\t\t\treturn key.replace(previousId, '');\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tfor (const key of keys) {\n\t\t\t\t\t\t\t\tconst previous = window.localStorage.getItem(`${previousId}${key}`);\n\t\t\t\t\t\t\t\tif (previous !== null) {\n\t\t\t\t\t\t\t\t\twindow.localStorage.setItem(this.id + key, previous);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\twindow.localStorage.removeItem(`${previousId}${key}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresolve({ upgrades: upgradesToApply });\n\t\t\t}).then(({ upgrades }) => {\n\t\t\t\tthis.storage = window.localStorage;\n\t\t\t\treturn new Promise<this>((resolve) => {\n\t\t\t\t\tconst res = () => resolve(this);\n\t\t\t\t\tthis._upgrade(upgrades, res);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tthis.storage = openPromise as unknown as Promise<LocalStorage>;\n\t\t\treturn openPromise;\n\t\t}\n\t}\n\n\t/**\n\t * Store a key-value pair\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tset(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.open().then(() => {\n\t\t\tif (typeof value === 'object') {\n\t\t\t\t(this.storage as Storage).setItem(this.id + key, JSON.stringify(value));\n\t\t\t} else {\n\t\t\t\t(this.storage as Storage).setItem(this.id + key, String(value));\n\t\t\t}\n\t\t\treturn Promise.resolve({ key, value });\n\t\t});\n\t}\n\n\t/**\n\t * Update a key-value pair. The update method will use Object.assign()\n\t * in the case of objects so no value is lost.\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tupdate(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.get(key).then((currentValue) => {\n\t\t\tif (typeof currentValue === 'object' && currentValue !== null) {\n\t\t\t\tif (typeof value === 'object' && value !== null) {\n\t\t\t\t\tvalue = Object.assign({}, currentValue as object, value as object);\n\t\t\t\t}\n\t\t\t\t(this.storage as Storage).setItem(this.id + key, JSON.stringify(value));\n\t\t\t} else {\n\t\t\t\t(this.storage as Storage).setItem(this.id + key, String(value));\n\t\t\t}\n\t\t\treturn Promise.resolve({ key, value });\n\t\t}).catch(() => {\n\t\t\treturn this.set(key, value);\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves a value from storage given its key\n\t *\n\t * @param key - Key with which the value was saved\n\t * @returns Promise resolving to the retrieved value\n\t */\n\tget(key: string): Promise<StorageValue> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tlet value: StorageValue = (this.storage as Storage).getItem(this.id + key);\n\t\t\t\ttry {\n\t\t\t\t\tconst o = JSON.parse(value as string);\n\t\t\t\t\tif (o && typeof o === 'object') {\n\t\t\t\t\t\tvalue = o;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Unable to parse to JSON\n\t\t\t\t}\n\n\t\t\t\tif (typeof value !== 'undefined' && value !== null) {\n\t\t\t\t\tresolve(value);\n\t\t\t\t} else {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves all the values in the space in a key-value JSON object\n\t *\n\t * @returns Promise resolving to all values\n\t */\n\tgetAll(): Promise<Record<string, StorageValue>> {\n\t\treturn this.keys().then((keys) => {\n\t\t\tconst values: Record<string, StorageValue> = {};\n\t\t\tconst promises: Promise<void>[] = [];\n\t\t\tfor (const key of keys) {\n\t\t\t\tpromises.push(this.get(key).then((value) => {\n\t\t\t\t\tvalues[key] = value;\n\t\t\t\t}));\n\t\t\t}\n\t\t\treturn Promise.all(promises).then(() => values);\n\t\t});\n\t}\n\n\t/**\n\t * Check if the space contains a given key.\n\t *\n\t * @param key - Key to look for\n\t * @returns Promise that resolves if key exists\n\t */\n\tcontains(key: string): Promise<void> {\n\t\treturn this.keys().then((keys) => {\n\t\t\tif (keys.includes(key)) {\n\t\t\t\treturn Promise.resolve();\n\t\t\t} else {\n\t\t\t\treturn Promise.reject();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Upgrade a Space Version\n\t *\n\t * @param oldVersion - The version of the storage to be upgraded\n\t * @param newVersion - The version to be upgraded to\n\t * @param callback - Function to transform the old stored values\n\t * @returns Promise\n\t */\n\tupgrade(oldVersion: string, newVersion: string, callback: UpgradeCallback<LocalStorage>): Promise<void> {\n\t\tconst key = `${parseInt(oldVersion.replace(/\\./g, ''))}::${parseInt(newVersion.replace(/\\./g, ''))}`;\n\t\tthis.upgrades[key] = callback;\n\t\treturn Promise.resolve();\n\t}\n\n\t/**\n\t * Helper for the upgrade progress by executing callbacks in order\n\t */\n\tprivate _upgrade(upgradesToApply: string[], resolve: () => void): void {\n\t\tif (upgradesToApply.length > 0) {\n\t\t\tthis.upgrades[upgradesToApply[0]].call(this, this).then(() => {\n\t\t\t\tthis._upgrade(upgradesToApply.slice(1), resolve);\n\t\t\t}).catch((e) => console.error(e));\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t}\n\n\t/**\n\t * Rename a Space\n\t *\n\t * @param name - New name to be used\n\t * @returns Promise for the rename operation\n\t */\n\trename(name: string): Promise<void> {\n\t\tif (this.name !== name) {\n\t\t\treturn this.keys().then((keys) => {\n\t\t\t\tconst oldId = this.id;\n\t\t\t\tthis.name = name;\n\n\t\t\t\tif (this.name !== '' && this.version !== '' && this.store !== '') {\n\t\t\t\t\tthis.id = `${this.name}::${this.store}::${this.version}_`;\n\t\t\t\t} else if (this.name !== '' && this.version !== '') {\n\t\t\t\t\tthis.id = `${this.name}::${this.version}_`;\n\t\t\t\t} else if (this.name !== '') {\n\t\t\t\t\tthis.id = `${this.name}::_`;\n\t\t\t\t} else {\n\t\t\t\t\tthis.id = '';\n\t\t\t\t}\n\n\t\t\t\tconst promises: Promise<void>[] = [];\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\tconst value = (this.storage as Storage).getItem(`${oldId}${key}`);\n\t\t\t\t\tif (value !== null) {\n\t\t\t\t\t\tpromises.push(this.set(key, value).then(() => {\n\t\t\t\t\t\t\t(this.storage as Storage).removeItem(`${oldId}${key}`);\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Promise.all(promises).then(() => {});\n\t\t\t});\n\t\t} else {\n\t\t\treturn Promise.reject();\n\t\t}\n\t}\n\n\t/**\n\t * Get the key that corresponds to a given index in the storage\n\t *\n\t * @param index - Index to get the key from\n\t * @param full - Whether to return the full key name including space id\n\t * @returns Promise resolving to the key's name\n\t */\n\tkey(index: number, full: boolean = false): Promise<string> {\n\t\treturn this.open().then(() => {\n\t\t\tconst keyValue = (this.storage as Storage).key(index);\n\t\t\tif (full === true) {\n\t\t\t\treturn Promise.resolve(keyValue ?? '');\n\t\t\t} else {\n\t\t\t\treturn Promise.resolve((keyValue ?? '').replace(this.id, ''));\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Return all keys stored in the space.\n\t *\n\t * @param full - Whether to return the full key name including space id\n\t * @returns Promise resolving to array of keys\n\t */\n\tkeys(full: boolean = false): Promise<string[]> {\n\t\treturn this.open().then(() => {\n\t\t\treturn Promise.resolve(Object.keys(this.storage as Storage).filter((key) => {\n\t\t\t\treturn key.indexOf(this.id) === 0;\n\t\t\t}).map((key) => {\n\t\t\t\tif (full === true) {\n\t\t\t\t\treturn key;\n\t\t\t\t} else {\n\t\t\t\t\treturn key.replace(this.id, '');\n\t\t\t\t}\n\t\t\t}));\n\t\t});\n\t}\n\n\t/**\n\t * Delete a value from the space given its key\n\t *\n\t * @param key - Key of the item to delete\n\t * @returns Promise resolving to the value of the deleted object\n\t */\n\tremove(key: string): Promise<StorageValue> {\n\t\treturn this.get(key).then((value) => {\n\t\t\t(this.storage as Storage).removeItem(this.id + key);\n\t\t\treturn Promise.resolve(value);\n\t\t});\n\t}\n\n\t/**\n\t * Clear the entire space\n\t *\n\t * @returns Promise for the clear operation\n\t */\n\tclear(): Promise<void> {\n\t\treturn this.keys().then((keys) => {\n\t\t\tfor (const key of keys) {\n\t\t\t\tthis.remove(key);\n\t\t\t}\n\t\t\treturn Promise.resolve();\n\t\t});\n\t}\n}\n\n",
|
|
13
|
+
"/**\n * ==============================\n * Session Storage Adapter\n * ==============================\n */\n\nimport { LocalStorage } from './LocalStorage';\nimport type { LocalStorageConfiguration } from './types';\n\n/**\n * The Session Storage Adapter provides the Space Class the ability to interact\n * with the sessionStorage API found in most modern browsers. Since this API\n * shares pretty much the same methods as the local storage one, this class\n * inherits from the LocalStorage adapter.\n */\nexport class SessionStorage extends LocalStorage {\n\t/**\n\t * Create a new SessionStorage. If no configuration is provided, the SessionStorage\n\t * global object is used. The SessionStorage Adapter can provide independency\n\t * by store name and space name.\n\t *\n\t * @param configuration - Configuration Object for the Adapter\n\t */\n\tconstructor({ name = '', version = '', store = '' }: LocalStorageConfiguration) {\n\t\tsuper({ name, version, store });\n\t}\n\n\t/**\n\t * Open the Storage Object\n\t *\n\t * @returns Promise resolving to this adapter\n\t */\n\topen(): Promise<this> {\n\t\tif (typeof this.storage === 'undefined') {\n\t\t\tthis.storage = window.sessionStorage;\n\t\t}\n\t\treturn Promise.resolve(this);\n\t}\n}\n\n",
|
|
14
|
+
"/**\n * ==============================\n * IndexedDB Adapter\n * ==============================\n */\n\nimport type { IndexedDBConfiguration, StorageValue, KeyValueResult, UpgradeCallback } from './types';\n\n/**\n * The IndexedDB Adapter provides the Space Class the ability to interact\n * with the IndexedDB API found in most modern browsers.\n */\nexport class IndexedDB {\n\tpublic name: string;\n\tpublic version: string;\n\tpublic store: string;\n\tpublic props: IDBObjectStoreParameters;\n\tpublic index: Record<string, { name: string; field: string; props?: IDBIndexParameters }>;\n\tpublic keyPath: string;\n\tpublic numericVersion: number;\n\tpublic upgrades: Record<string, UpgradeCallback<IndexedDB>>;\n\tpublic storage: IDBDatabase | Promise<IDBDatabase> | undefined;\n\n\t/**\n\t * Create a new IndexedDB. Differently from Local and Session Storages, the\n\t * IndexedDB Adapter requires a mandatory name, version and store name.\n\t *\n\t * @param configuration - Configuration Object for the Adapter\n\t */\n\tconstructor({ name = '', version = '', store = '', props = {}, index = {} }: IndexedDBConfiguration) {\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.store = store;\n\t\tthis.props = props || {};\n\t\tthis.index = index;\n\n\t\tthis.keyPath = (props?.keyPath as string) || 'id';\n\t\tthis.upgrades = {};\n\n\t\tif (this.version === '') {\n\t\t\tthis.numericVersion = 0;\n\t\t} else {\n\t\t\tthis.numericVersion = parseInt(version.replace(/\\./g, ''));\n\t\t}\n\t}\n\n\t/**\n\t * Modify the configuration\n\t *\n\t * @param config - Configuration object to set up\n\t */\n\tconfiguration(config: IndexedDBConfiguration): void {\n\t\tif (config.name) this.name = config.name;\n\t\tif (config.version) this.version = config.version;\n\t\tif (config.store) this.store = config.store;\n\t}\n\n\t/**\n\t * Open the Storage Object\n\t *\n\t * @returns Promise resolving to this adapter\n\t */\n\topen(): Promise<this> {\n\t\tif (this.name === '') {\n\t\t\tconsole.error('No name has been defined for IndexedDB space.');\n\t\t\treturn Promise.reject();\n\t\t}\n\n\t\tif (this.store === '') {\n\t\t\tconsole.error('No store has been defined for IndexedDB space.');\n\t\t\treturn Promise.reject();\n\t\t}\n\n\t\tif (this.storage instanceof IDBDatabase) {\n\t\t\treturn Promise.resolve(this);\n\t\t} else if (this.storage instanceof Promise) {\n\t\t\treturn this.storage as unknown as Promise<this>;\n\t\t} else {\n\t\t\tlet upgradeEvent: IDBVersionChangeEvent | undefined;\n\n\t\t\tconst openPromise = new Promise<{ storage: IDBDatabase; upgrades: string[] }>((resolve, reject) => {\n\t\t\t\tlet upgradesToApply: string[] = [];\n\t\t\t\tconst request = window.indexedDB.open(this.name, this.numericVersion);\n\n\t\t\t\trequest.onerror = (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t};\n\n\t\t\t\trequest.onsuccess = (event) => {\n\t\t\t\t\tresolve({ storage: (event.target as IDBOpenDBRequest).result, upgrades: upgradesToApply });\n\t\t\t\t};\n\n\t\t\t\trequest.onupgradeneeded = (event: IDBVersionChangeEvent) => {\n\t\t\t\t\tupgradeEvent = event;\n\t\t\t\t\tconst db = (event.target as IDBOpenDBRequest).result;\n\n\t\t\t\t\tif (event.oldVersion < 1) {\n\t\t\t\t\t\t// Create all the needed Stores\n\t\t\t\t\t\tconst store = db.createObjectStore(this.store, this.props);\n\t\t\t\t\t\tfor (const indexKey of Object.keys(this.index)) {\n\t\t\t\t\t\t\tconst idx = this.index[indexKey];\n\t\t\t\t\t\t\tstore.createIndex(idx.name, idx.field, idx.props);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Check what upgrade functions have been declared\n\t\t\t\t\t\tconst availableUpgrades = Object.keys(this.upgrades).sort();\n\n\t\t\t\t\t\tconst startFrom = availableUpgrades.findIndex((u) => {\n\t\t\t\t\t\t\tconst [old] = u.split('::');\n\t\t\t\t\t\t\treturn parseInt(old) === event.oldVersion;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (startFrom > -1) {\n\t\t\t\t\t\t\tupgradesToApply = availableUpgrades.slice(startFrom).filter((u) => {\n\t\t\t\t\t\t\t\tconst [old, next] = u.split('::');\n\t\t\t\t\t\t\t\treturn parseInt(old) < this.numericVersion && parseInt(next) <= this.numericVersion;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Once the transaction is done, resolve the storage object\n\t\t\t\t\tconst transaction = (event.target as IDBOpenDBRequest).transaction;\n\t\t\t\t\tif (transaction) {\n\t\t\t\t\t\ttransaction.addEventListener('complete', () => {\n\t\t\t\t\t\t\tresolve({ storage: db, upgrades: upgradesToApply });\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}).then(({ storage, upgrades }) => {\n\t\t\t\tthis.storage = storage;\n\t\t\t\treturn new Promise<this>((resolve) => {\n\t\t\t\t\tconst res = () => resolve(this);\n\t\t\t\t\tthis._upgrade(upgrades, res, upgradeEvent);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tthis.storage = openPromise as unknown as Promise<IDBDatabase>;\n\t\t\treturn openPromise;\n\t\t}\n\t}\n\n\t/**\n\t * Store a key-value pair. Because of the nature of IndexedDB,\n\t * stored values must be JSON objects.\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tset(key: string | null = null, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store, 'readwrite')\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tlet op: IDBRequest;\n\n\t\t\t\tif (key !== null) {\n\t\t\t\t\tconst temp: Record<string, unknown> = {};\n\t\t\t\t\ttemp[this.keyPath] = key;\n\t\t\t\t\top = transaction.put(Object.assign({}, temp, value as object));\n\t\t\t\t} else {\n\t\t\t\t\top = transaction.add(value);\n\t\t\t\t}\n\n\t\t\t\top.addEventListener('success', (event) => {\n\t\t\t\t\tresolve({ key: String((event.target as IDBRequest).result), value });\n\t\t\t\t});\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Update a key-value pair. The update method will use Object.assign()\n\t * in the case of objects so no value is lost.\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tupdate(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.get(key).then((currentValue) => {\n\t\t\tif (typeof currentValue === 'undefined') {\n\t\t\t\treturn this.set(key, value);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store, 'readwrite')\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.put(Object.assign({}, currentValue as object, value as object));\n\n\t\t\t\top.addEventListener('success', (event) => {\n\t\t\t\t\tresolve({ key: String((event.target as IDBRequest).result), value });\n\t\t\t\t});\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves a value from storage given its key\n\t *\n\t * @param key - Key with which the value was saved\n\t * @returns Promise resolving to the retrieved value\n\t */\n\tget(key: string): Promise<StorageValue> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store)\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.get(key);\n\n\t\t\t\top.addEventListener('success', (event) => {\n\t\t\t\t\tconst value = (event.target as IDBRequest).result;\n\t\t\t\t\tif (typeof value !== 'undefined' && value !== null) {\n\t\t\t\t\t\tresolve(value);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treject();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves all the values in the space in a key-value JSON object\n\t *\n\t * @returns Promise resolving to all values\n\t */\n\tgetAll(): Promise<Record<string, StorageValue>> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store)\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.getAll();\n\n\t\t\t\top.addEventListener('success', (event) => {\n\t\t\t\t\tconst results: Record<string, StorageValue> = {};\n\t\t\t\t\tconst items = (event.target as IDBRequest).result as Record<string, unknown>[];\n\t\t\t\t\titems.forEach((item) => {\n\t\t\t\t\t\tconst id = item[this.keyPath] as string;\n\t\t\t\t\t\tdelete item[this.keyPath];\n\t\t\t\t\t\tresults[id] = item;\n\t\t\t\t\t});\n\t\t\t\t\tresolve(results);\n\t\t\t\t});\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Check if the space contains a given key.\n\t *\n\t * @param key - Key to look for\n\t * @returns Promise that resolves if key exists\n\t */\n\tcontains(key: string): Promise<void> {\n\t\treturn this.get(key).then(() => {\n\t\t\treturn Promise.resolve();\n\t\t});\n\t}\n\n\t/**\n\t * Upgrade a Space Version. Upgrades must be declared before the open()\n\t * method is executed.\n\t *\n\t * @param oldVersion - The version to be upgraded\n\t * @param newVersion - The version to be upgraded to\n\t * @param callback - Function to transform the old stored values\n\t * @returns Promise\n\t */\n\tupgrade(oldVersion: string, newVersion: string, callback: UpgradeCallback<IndexedDB>): Promise<void> {\n\t\tconst key = `${parseInt(oldVersion.replace(/\\./g, ''))}::${parseInt(newVersion.replace(/\\./g, ''))}`;\n\t\tthis.upgrades[key] = callback;\n\t\treturn Promise.resolve();\n\t}\n\n\t/**\n\t * Helper for the upgrade progress by executing callbacks in order\n\t */\n\tprivate _upgrade(upgradesToApply: string[], resolve: () => void, event?: IDBVersionChangeEvent): void {\n\t\tif (upgradesToApply.length > 0) {\n\t\t\tthis.upgrades[upgradesToApply[0]].call(this, this, event).then(() => {\n\t\t\t\tthis._upgrade(upgradesToApply.slice(1), resolve, event);\n\t\t\t}).catch((e) => console.error(e));\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t}\n\n\t/**\n\t * Renaming the space is not possible with the IndexedDB adapter therefore\n\t * this function always gets rejected.\n\t *\n\t * @returns Promise rejection\n\t */\n\trename(): Promise<never> {\n\t\treturn Promise.reject();\n\t}\n\n\t/**\n\t * Getting a key by its index is not possible in this adapter, therefore this\n\t * function always gets rejected.\n\t *\n\t * @returns Promise rejection\n\t */\n\tkey(): Promise<never> {\n\t\treturn Promise.reject();\n\t}\n\n\t/**\n\t * Return all keys stored in the space.\n\t *\n\t * @returns Promise resolving to array of keys\n\t */\n\tkeys(): Promise<string[]> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store, 'readwrite')\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.getAllKeys();\n\n\t\t\t\top.addEventListener('success', (event) => {\n\t\t\t\t\tresolve((event.target as IDBRequest).result.map(String));\n\t\t\t\t}, false);\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t}, false);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Delete a value from the space given its key\n\t *\n\t * @param key - Key of the item to delete\n\t * @returns Promise resolving to the value of the deleted object\n\t */\n\tremove(key: string): Promise<StorageValue> {\n\t\treturn this.get(key).then((value) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store, 'readwrite')\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.delete(key);\n\n\t\t\t\top.addEventListener('success', () => {\n\t\t\t\t\tresolve(value);\n\t\t\t\t}, false);\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t}, false);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Clear the entire space\n\t *\n\t * @returns Promise for the clear operation\n\t */\n\tclear(): Promise<void> {\n\t\treturn this.open().then(() => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst transaction = (this.storage as IDBDatabase)\n\t\t\t\t\t.transaction(this.store, 'readwrite')\n\t\t\t\t\t.objectStore(this.store);\n\t\t\t\tconst op = transaction.clear();\n\n\t\t\t\top.addEventListener('success', () => {\n\t\t\t\t\tresolve();\n\t\t\t\t}, false);\n\t\t\t\top.addEventListener('error', (event) => {\n\t\t\t\t\treject(event);\n\t\t\t\t}, false);\n\t\t\t});\n\t\t});\n\t}\n}\n\n",
|
|
15
|
+
"/**\n * ==============================\n * Remote Storage Adapter\n * ==============================\n */\n\nimport { Request } from '../Request';\nimport type { RequestOptions } from '../Request';\nimport type { RemoteStorageConfiguration, StorageValue, KeyValueResult } from './types';\n\n/**\n * The Remote Storage Adapter provides the Space Class the ability to interact\n * with a server in order to handle data persistence. The server's implementation\n * is up to the developer but it will need to respond to this adapter's request\n * formatting. This adapter uses the Request class to perform its tasks.\n */\nexport class RemoteStorage {\n\tpublic name: string;\n\tpublic version: string;\n\tpublic store: string;\n\tpublic endpoint: string;\n\tpublic props: RequestOptions;\n\tpublic storage: typeof Request | undefined;\n\n\t/**\n\t * Create a new Remote Storage. This adapter requires an endpoint URL where\n\t * it will make the requests.\n\t *\n\t * @param configuration - Configuration Object for the Adapter\n\t */\n\tconstructor({ name = '', version = '', store = '', endpoint = '', props = {} }: RemoteStorageConfiguration) {\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.store = store;\n\t\tthis.endpoint = `${endpoint}${store}/`;\n\t\tthis.props = props;\n\t}\n\n\t/**\n\t * Modify the configuration\n\t *\n\t * @param config - Configuration object to set up\n\t */\n\tconfiguration(config: RemoteStorageConfiguration): void {\n\t\tif (config.name) this.name = config.name;\n\t\tif (config.version) this.version = config.version;\n\t\tif (config.store) this.store = config.store;\n\t}\n\n\t/**\n\t * Open the Storage Object\n\t *\n\t * @returns Promise resolving to this adapter\n\t */\n\topen(): Promise<this> {\n\t\tif (typeof this.storage === 'undefined') {\n\t\t\tthis.storage = Request;\n\t\t}\n\t\treturn Promise.resolve(this);\n\t}\n\n\t/**\n\t * Store a key-value pair. This function sends a POST request to the server\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and response\n\t */\n\tset(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.post(this.endpoint + key, value as Record<string, string | number | boolean>, this.props).then((response) => {\n\t\t\t\treturn Promise.resolve({ key, value: response.json() });\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Update a key-value pair. The update method will use Object.assign()\n\t * in the case of objects so no value is lost. This function sends a PUT\n\t * request to the server.\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and response\n\t */\n\tupdate(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\treturn this.get(key).then((currentValue) => {\n\t\t\tconst merged = Object.assign({}, currentValue as object, value as object);\n\t\t\treturn this.storage!.put(this.endpoint + key, merged as Record<string, string | number | boolean>, this.props).then((response) => {\n\t\t\t\treturn Promise.resolve({ key, value: response.json() });\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves a value from storage given its key\n\t *\n\t * @param key - Key with which the value was saved\n\t * @returns Promise resolving to the retrieved value\n\t */\n\tget(key: string): Promise<StorageValue> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.json(this.endpoint + key, {}, this.props);\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves all the values in the space in a key-value JSON object\n\t *\n\t * @returns Promise resolving to all values\n\t */\n\tgetAll(): Promise<Record<string, StorageValue>> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.json(this.endpoint, {}, this.props);\n\t\t});\n\t}\n\n\t/**\n\t * Check if a space contains a given key.\n\t *\n\t * @param key - Key to look for\n\t * @returns Promise that resolves if key exists\n\t */\n\tcontains(key: string): Promise<void> {\n\t\treturn this.keys().then((keys) => {\n\t\t\tif (keys.includes(key)) {\n\t\t\t\treturn Promise.resolve();\n\t\t\t} else {\n\t\t\t\treturn Promise.reject();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Upgrading the Storage must be done on the server side, therefore this\n\t * function always gets rejected.\n\t *\n\t * @returns Promise rejection\n\t */\n\tupgrade(): Promise<never> {\n\t\treturn Promise.reject();\n\t}\n\n\t/**\n\t * Renaming the Storage must be done on the server side, therefore this\n\t * function always gets rejected.\n\t *\n\t * @returns Promise rejection\n\t */\n\trename(): Promise<never> {\n\t\treturn Promise.reject();\n\t}\n\n\t/**\n\t * Getting a key by its index is not possible in this adapter, therefore\n\t * this function always gets rejected.\n\t *\n\t * @returns Promise rejection\n\t */\n\tkey(): Promise<never> {\n\t\treturn Promise.reject();\n\t}\n\n\t/**\n\t * Return all keys stored in the space. This makes a GET request to the\n\t * full endpoint with a keys query parameter.\n\t *\n\t * @returns Promise resolving to array of keys\n\t */\n\tkeys(): Promise<string[]> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.json<string[]>(this.endpoint, { keys: true }, this.props);\n\t\t});\n\t}\n\n\t/**\n\t * Delete a value from the space given its key. This function sends a\n\t * DELETE request to the server.\n\t *\n\t * @param key - Key of the item to delete\n\t * @returns Promise resolving to the key and response\n\t */\n\tremove(key: string): Promise<StorageValue> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.delete(this.endpoint + key, {}, this.props).then((response) => {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Clear the entire space. This function sends a DELETE request to the server.\n\t *\n\t * @returns Promise for the clear operation\n\t */\n\tclear(): Promise<void> {\n\t\treturn this.open().then(() => {\n\t\t\treturn this.storage!.delete(this.endpoint, {}, this.props).then(() => {});\n\t\t});\n\t}\n}\n\n",
|
|
16
|
+
"/**\n * ==============================\n * Space\n * ==============================\n */\n\nimport { LocalStorage } from './SpaceAdapter/LocalStorage';\nimport { SessionStorage } from './SpaceAdapter/SessionStorage';\nimport { IndexedDB } from './SpaceAdapter/IndexedDB';\nimport { RemoteStorage } from './SpaceAdapter/RemoteStorage';\nimport type { SpaceConfiguration, StorageValue, KeyValueResult, UpgradeCallback } from './SpaceAdapter/types';\n\n/**\n * List of Adapters Available\n */\nexport const SpaceAdapter = {\n\tLocalStorage,\n\tSessionStorage,\n\tIndexedDB,\n\tRemoteStorage\n};\n\n/**\n * Space adapter type (any of the available adapters)\n */\nexport type SpaceAdapterType = LocalStorage | SessionStorage | IndexedDB | RemoteStorage;\n\n/**\n * Space adapter constructor type\n */\nexport type SpaceAdapterConstructor = typeof LocalStorage | typeof SessionStorage | typeof IndexedDB | typeof RemoteStorage;\n\n/**\n * Callback function type for space events\n */\nexport type SpaceCallback = (key: string, value: StorageValue) => void;\n\n/**\n * Transformation function type\n */\nexport type TransformationFunction = (key: string, value: StorageValue) => StorageValue;\n\n/**\n * Transformation configuration\n */\nexport interface Transformation {\n\tid: string;\n\tget?: TransformationFunction | null;\n\tset?: TransformationFunction | null;\n}\n\n/**\n * Space provides a simple wrapper for different Storage APIs. It aims to\n * provide data independence through storage namespaces and versioning, allowing\n * transparent data formatting and content modifications through versions.\n */\nexport class Space {\n\tprivate _configuration: SpaceConfiguration;\n\tpublic adapter: SpaceAdapterType;\n\tpublic callbacks: {\n\t\tcreate: SpaceCallback[];\n\t\tupdate: SpaceCallback[];\n\t\tdelete: SpaceCallback[];\n\t};\n\tpublic transformations: Record<string, Transformation>;\n\n\t/**\n\t * Create a new Space Object. If no name and version is defined, the global\n\t * LocalSpace space is used.\n\t *\n\t * @param adapter - Space Adapter to use\n\t * @param configuration - Configuration object for the space\n\t */\n\tconstructor(adapter: SpaceAdapterConstructor = SpaceAdapter.LocalStorage, configuration: SpaceConfiguration = {}) {\n\t\t// Assign the provided configuration to the default one\n\t\tthis._configuration = Object.assign({}, { name: '', version: '', store: '' }, configuration);\n\n\t\t// Set up the adapter instance to use\n\t\tthis.adapter = new adapter(this._configuration);\n\n\t\t// This object stores all the callbacks the user can define for the space operations\n\t\tthis.callbacks = {\n\t\t\tcreate: [],\n\t\t\tupdate: [],\n\t\t\tdelete: []\n\t\t};\n\n\t\t// A transformation is an object that can contain set and get functions\n\t\tthis.transformations = {};\n\t}\n\n\t/**\n\t * Modify the space configuration, it will also be passed down to the adapter\n\t * using its configuration() function.\n\t *\n\t * @param object - Configuration object to set up\n\t * @returns Configuration object if no param was passed\n\t */\n\tconfiguration(object: SpaceConfiguration | null = null): SpaceConfiguration | void {\n\t\tif (object !== null) {\n\t\t\tthis._configuration = Object.assign({}, this._configuration, object);\n\t\t\tif (this.adapter.configuration) {\n\t\t\t\tthis.adapter.configuration(object);\n\t\t\t}\n\t\t} else {\n\t\t\treturn this._configuration;\n\t\t}\n\t}\n\n\t/**\n\t * Open the Storage Object to be used depending on the SpaceAdapter\n\t *\n\t * @returns Promise resolving to this Space\n\t */\n\topen(): Promise<this> {\n\t\treturn this.adapter.open().then(() => {\n\t\t\treturn Promise.resolve(this);\n\t\t});\n\t}\n\n\t/**\n\t * Store a key-value pair\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tset(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\t// Apply all set transformations to the value\n\t\tfor (const id of Object.keys(this.transformations)) {\n\t\t\tif (typeof this.transformations[id].set === 'function') {\n\t\t\t\tvalue = this.transformations[id].set!(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn this.adapter.set(key, value).then(({ key, value }) => {\n\t\t\tfor (const callback of this.callbacks.create) {\n\t\t\t\tcallback.call(null, key, value);\n\t\t\t}\n\t\t\treturn Promise.resolve({ key, value });\n\t\t});\n\t}\n\n\t/**\n\t * Update a key-value pair. In difference with the set() method, the update\n\t * method will use Object.assign() in the case of objects so no value is lost.\n\t *\n\t * @param key - Key with which this value will be saved\n\t * @param value - Value to save\n\t * @returns Promise with key and value\n\t */\n\tupdate(key: string, value: StorageValue): Promise<KeyValueResult> {\n\t\t// Apply all set transformations to the value\n\t\tfor (const id of Object.keys(this.transformations)) {\n\t\t\tif (typeof this.transformations[id].set === 'function') {\n\t\t\t\tvalue = this.transformations[id].set!(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn this.adapter.update(key, value).then(({ key, value }) => {\n\t\t\tfor (const callback of this.callbacks.update) {\n\t\t\t\tcallback.call(null, key, value);\n\t\t\t}\n\t\t\treturn Promise.resolve({ key, value });\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves a value from storage given its key\n\t *\n\t * @param key - Key with which the value was saved\n\t * @returns Promise resolving to the retrieved value\n\t */\n\tget(key: string): Promise<StorageValue> {\n\t\treturn this.adapter.get(key).then((value) => {\n\t\t\t// Apply all get transformations to the value\n\t\t\tfor (const id of Object.keys(this.transformations)) {\n\t\t\t\tif (typeof this.transformations[id].get === 'function') {\n\t\t\t\t\tvalue = this.transformations[id].get!(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn value;\n\t\t});\n\t}\n\n\t/**\n\t * Retrieves all the values in the space in a key-value JSON object\n\t *\n\t * @returns Promise resolving to all values\n\t */\n\tgetAll(): Promise<Record<string, StorageValue>> {\n\t\treturn this.adapter.getAll().then((values) => {\n\t\t\t// Apply all get transformations to the values\n\t\t\tfor (const key of Object.keys(values)) {\n\t\t\t\tfor (const id of Object.keys(this.transformations)) {\n\t\t\t\t\tif (typeof this.transformations[id].get === 'function') {\n\t\t\t\t\t\tvalues[key] = this.transformations[id].get!(key, values[key]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn values;\n\t\t});\n\t}\n\n\t/**\n\t * Iterate over every value in the space\n\t *\n\t * @param callback - A callback function receiving the key and value\n\t * @returns Promise resolving when all callbacks have been resolved\n\t */\n\teach(callback: (key: string, value: StorageValue) => unknown): Promise<unknown[]> {\n\t\treturn this.getAll().then((values) => {\n\t\t\tconst promises: unknown[] = [];\n\t\t\tfor (const i of Object.keys(values)) {\n\t\t\t\tpromises.push(callback.call(this, i, values[i]));\n\t\t\t}\n\t\t\treturn Promise.all(promises);\n\t\t});\n\t}\n\n\t/**\n\t * Check if a space contains a given key. Not all adapters may give this information\n\t *\n\t * @param key - Key to look for\n\t * @returns Promise that resolves if key exists\n\t */\n\tcontains(key: string): Promise<void> {\n\t\treturn this.adapter.contains(key);\n\t}\n\n\t/**\n\t * Upgrade a Space Version. Not all adapters may provide this functionality\n\t *\n\t * @param oldVersion - The version of the storage to be upgraded\n\t * @param newVersion - The version to be upgraded to\n\t * @param callback - Function to transform the old stored values\n\t * @returns Promise for the upgrade operation\n\t */\n\tupgrade(oldVersion: string, newVersion: string, callback: UpgradeCallback): Promise<this> {\n\t\treturn this.adapter.upgrade(oldVersion, newVersion, callback).then(() => {\n\t\t\treturn Promise.resolve(this);\n\t\t});\n\t}\n\n\t/**\n\t * Rename a Space. Not all adapters may provide this functionality\n\t *\n\t * @param name - New name to be used\n\t * @returns Promise for the rename operation\n\t */\n\trename(name: string): Promise<void> {\n\t\treturn this.adapter.rename(name);\n\t}\n\n\t/**\n\t * Add a callback function to be run every time a value is created.\n\t *\n\t * @param callback - Callback Function. Key and Value pair will be sent as parameters.\n\t */\n\tonCreate(callback: SpaceCallback): void {\n\t\tthis.callbacks.create.push(callback);\n\t}\n\n\t/**\n\t * Add a callback function to be run every time a value is updated.\n\t *\n\t * @param callback - Callback Function. Key and Value pair will be sent as parameters.\n\t */\n\tonUpdate(callback: SpaceCallback): void {\n\t\tthis.callbacks.update.push(callback);\n\t}\n\n\t/**\n\t * Add a callback function to be run every time a value is deleted.\n\t *\n\t * @param callback - Callback Function. Key and Value pair will be sent as parameters.\n\t */\n\tonDelete(callback: SpaceCallback): void {\n\t\tthis.callbacks.delete.push(callback);\n\t}\n\n\t/**\n\t * Add a transformation function to the space.\n\t *\n\t * @param transformation - Transformation configuration with id, get, and set functions\n\t */\n\taddTransformation({ id, get, set }: Transformation): void {\n\t\tthis.transformations[id] = { id, get, set };\n\t}\n\n\t/**\n\t * Remove a transformation function given its id\n\t *\n\t * @param id - Name or identifier of the transformation to remove\n\t */\n\tremoveTransformation(id: string): void {\n\t\tdelete this.transformations[id];\n\t}\n\n\t/**\n\t * Get the key that corresponds to a given index in the storage.\n\t * Not all adapters may provide this functionality\n\t *\n\t * @param index - Index to get the key from\n\t * @param full - Whether to return the full key name including space id\n\t * @returns Promise resolving to the key's name\n\t */\n\tkey(index: number, full: boolean = false): Promise<string> {\n\t\treturn this.adapter.key(index, full);\n\t}\n\n\t/**\n\t * Return all keys stored in the space. Not all adapters may provide this functionality\n\t *\n\t * @param full - Whether to return the full key name including space id\n\t * @returns Promise resolving to array of keys\n\t */\n\tkeys(full: boolean = false): Promise<string[]> {\n\t\treturn this.adapter.keys(full);\n\t}\n\n\t/**\n\t * Delete a value from the space given its key\n\t *\n\t * @param key - Key of the item to delete\n\t * @returns Promise that resolves after deletion\n\t */\n\tremove(key: string): Promise<void> {\n\t\treturn this.adapter.remove(key).then((value) => {\n\t\t\t// Run the callback for deletions\n\t\t\tfor (const callback of this.callbacks.delete) {\n\t\t\t\tcallback.call(null, key, value);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Clear the entire space\n\t *\n\t * @returns Promise for the clear operation\n\t */\n\tclear(): Promise<void> {\n\t\treturn this.adapter.clear();\n\t}\n}\n\n// Re-export adapter types\nexport { LocalStorage } from './SpaceAdapter/LocalStorage';\nexport { SessionStorage } from './SpaceAdapter/SessionStorage';\nexport { IndexedDB } from './SpaceAdapter/IndexedDB';\nexport { RemoteStorage } from './SpaceAdapter/RemoteStorage';\nexport type { SpaceConfiguration, StorageValue, KeyValueResult, UpgradeCallback } from './SpaceAdapter/types';\n\n",
|
|
17
|
+
"/**\n * ==============================\n * Text\n * ==============================\n */\n\n/**\n * Provides utility functions for texts\n */\nexport class Text {\n\t/**\n\t * Capitalizes every word in a string\n\t *\n\t * @param text - Text string to capitalize\n\t * @returns Capitalized string\n\t */\n\tstatic capitalize(text: string): string {\n\t\treturn text.replace(/\\w\\S*/g, (txt) => {\n\t\t\treturn txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();\n\t\t});\n\t}\n\n\t/**\n\t * Gets the suffix of a string given a key\n\t *\n\t * @param key - Key part of the string\n\t * @param text - Full string to extract the suffix from\n\t * @returns Suffix\n\t */\n\tstatic suffix(key: string, text: string): string {\n\t\tlet suffix = '';\n\t\tlet position = text.indexOf(key);\n\t\tif (position !== -1) {\n\t\t\tposition += key.length;\n\t\t\tsuffix = text.substring(position);\n\t\t}\n\t\treturn suffix;\n\t}\n\n\t/**\n\t * Get the currently selected text\n\t *\n\t * @returns Text selection\n\t */\n\tstatic selection(): string {\n\t\tconst selection = window.getSelection();\n\t\tif (selection) {\n\t\t\treturn selection.toString();\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Gets the prefix of a string given a key\n\t *\n\t * @param key - Key part of the string\n\t * @param text - Full string to extract the prefix from\n\t * @returns Prefix\n\t */\n\tstatic prefix(key: string, text: string): string {\n\t\tlet prefix = '';\n\t\tconst position = text.indexOf(key);\n\t\tif (position !== -1) {\n\t\t\tprefix = text.substring(0, position);\n\t\t}\n\t\treturn prefix;\n\t}\n\n\t/**\n\t * Transforms a given text into a friendly URL string replacing all special characters\n\t *\n\t * @param text - The text to build the url from\n\t * @returns Friendly URL\n\t */\n\tstatic friendly(text: string): string {\n\t\tconst regex: RegExp[] = [\n\t\t\t/[áàâãªä]/g,\n\t\t\t/[ÁÀÂÃÄ]/g,\n\t\t\t/[ÍÌÎÏ]/g,\n\t\t\t/[íìîï]/g,\n\t\t\t/[éèêë]/g,\n\t\t\t/[ÉÈÊË]/g,\n\t\t\t/[óòôõºö]/g,\n\t\t\t/[ÓÒÔÕÖ]/g,\n\t\t\t/[úùûü]/g,\n\t\t\t/[ÚÙÛÜ]/g,\n\t\t\t/ç/g,\n\t\t\t/Ç/g,\n\t\t\t/ñ/g,\n\t\t\t/Ñ/g,\n\t\t\t/_/g,\n\t\t\t/[''‹›<>']/g,\n\t\t\t/[\"\"«»„\"]/g,\n\t\t\t/[(){}[\\]]/g,\n\t\t\t/[?¿!¡#$%&^*´`~/°|]/g,\n\t\t\t/[,.:;]/g,\n\t\t\t/ /g\n\t\t];\n\n\t\tconst replacements: string[] = [\n\t\t\t'a',\n\t\t\t'A',\n\t\t\t'I',\n\t\t\t'i',\n\t\t\t'e',\n\t\t\t'E',\n\t\t\t'o',\n\t\t\t'O',\n\t\t\t'u',\n\t\t\t'U',\n\t\t\t'c',\n\t\t\t'C',\n\t\t\t'n',\n\t\t\t'N',\n\t\t\t'-',\n\t\t\t'',\n\t\t\t'',\n\t\t\t'',\n\t\t\t'',\n\t\t\t'',\n\t\t\t'-'\n\t\t];\n\n\t\tlet result = text;\n\t\tfor (let i = 0; i < regex.length; i++) {\n\t\t\tresult = result.replace(regex[i], replacements[i]);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n",
|
|
18
|
+
"/**\n * ==============================\n * Util\n * ==============================\n */\n\n/**\n * Callable function type\n */\nexport type Callable<T = unknown> = (...args: unknown[]) => T | Promise<T>;\n\n/**\n * Provides diverse utility functions\n */\nexport class Util {\n\t/**\n\t * Calls any function using promises to keep a standard behavior between\n\t * async and sync functions.\n\t *\n\t * @param callable - The function to run\n\t * @param context - The object `this` will be mapped to\n\t * @param args - List of parameters to pass to the function when called\n\t * @returns A promise that resolves to the result of the function\n\t */\n\tstatic callAsync<T = unknown>(callable: Callable<T>, context: unknown, ...args: unknown[]): Promise<T> {\n\t\ttry {\n\t\t\t// Call the provided function using the context and arguments given\n\t\t\tconst result = callable.apply(context, args);\n\n\t\t\t// Check if the function returned a simple value or a Promise\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\treturn Promise.resolve(result);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a UUID. These UUIDs should not be trusted for uniqueness\n\t *\n\t * @returns Generated UUID\n\t */\n\tstatic uuid(): string {\n\t\tif (typeof crypto !== 'undefined' && crypto.getRandomValues) {\n\t\t\treturn '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => {\n\t\t\t\tconst num = parseInt(c, 10);\n\t\t\t\treturn (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16);\n\t\t\t});\n\t\t} else {\n\t\t\tconst generate = (): string => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);\n\t\t\treturn generate() + generate() + '-' + generate() + '-' + generate() + '-' +\n\t\t\t\tgenerate() + '-' + generate() + generate() + generate();\n\t\t}\n\t}\n}\n\n",
|
|
19
|
+
"// This file is basically just a hack to expose the Artemis namespace in the\n// window object. Once/if bun adds support for this, we can remove this file.\n\nimport * as Artemis from './index';\n\ndeclare global {\n\tinterface Window {\n\t\tArtemis: typeof Artemis;\n\t}\n}\n\nif (typeof window === 'object') {\n\twindow.Artemis = Artemis;\n}\n\n"
|
|
20
|
+
],
|
|
21
|
+
"mappings": "oZAUO,IAAK,GAAL,CAAK,IAAL,CACN,SAAO,GAAP,OACA,UAAQ,GAAR,QACA,YAAU,GAAV,UACA,SAAO,GAAP,OACA,UAAQ,GAAR,QACA,QAAM,GAAN,QANW,QAaL,MAAM,CAAM,OACH,QAAqB,QAQ7B,MAAK,CAAC,EAAgC,CAC5C,GAAI,OAAO,IAAU,SACpB,KAAK,OAAS,EAEf,OAAO,KAAK,aASN,IAAG,IAAI,EAAuB,CACpC,GAAI,KAAK,MAAM,GAAK,EACnB,QAAQ,IAAI,GAAG,CAAI,QAUd,MAAK,IAAI,EAAuB,CACtC,GAAI,KAAK,MAAM,GAAK,EACnB,QAAQ,MAAM,GAAG,CAAI,QAUhB,KAAI,IAAI,EAAuB,CACrC,GAAI,KAAK,MAAM,GAAK,EACnB,QAAQ,KAAK,GAAG,CAAI,QAUf,MAAK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B,CAC9B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,GACA,GACA,GACA,GACA,GACA,GACD,EAEI,EAAS,EACb,QAAS,EAAI,EAAG,EAAI,EAAM,OAAQ,IACjC,EAAS,EAAO,QAAQ,EAAM,GAAI,EAAa,EAAE,EAGlD,OAAO,EAET,CCpHO,MAAM,CAAK,OAUV,UAAsB,CAAC,EAAuB,KAAqB,EAA6B,CACtG,GAAI,CAEH,IAAM,EAAS,EAAS,MAAM,EAAS,CAAI,EAG3C,GAAI,aAAkB,QACrB,OAAO,EAEP,YAAO,QAAQ,QAAQ,CAAM,EAE7B,MAAO,EAAG,CACX,OAAO,QAAQ,OAAO,CAAC,SASlB,KAAI,EAAW,CACrB,GAAI,OAAO,OAAW,KAAe,OAAO,gBAC3C,MAAO,uCAAuC,QAAQ,SAAU,CAAC,IAAM,CACtE,IAAM,EAAM,SAAS,EAAG,EAAE,EAC1B,OAAQ,EAAO,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC,EAAE,GAAM,IAAO,EAAM,GAAM,SAAS,EAAE,EAC7F,EACK,KACN,IAAM,EAAW,IAAc,KAAK,OAAO,EAAI,KAAK,OAAO,GAAK,KAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,EACjG,OAAO,EAAS,EAAI,EAAS,EAAI,IAAM,EAAS,EAAI,IAAM,EAAS,EAAI,IACtE,EAAS,EAAI,IAAM,EAAS,EAAI,EAAS,EAAI,EAAS,GAG1D,CC9CA,GAAI,OAAO,SAAW,SACrB,OAAO,QAAU",
|
|
22
|
+
"debugId": "D9F571478C6F1C6364756E2164756E21",
|
|
23
|
+
"names": []
|
|
24
|
+
}
|
package/dist/artemis.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
function e(e,t,s,r){Object.defineProperty(e,t,{get:s,set:r,enumerable:!0,configurable:!0})}var t={};e(t,"DebugLevel",(()=>s)),e(t,"Debug",(()=>r));const s={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4,ALL:5};class r{static level(e){return"number"==typeof e&&(this._level=e),this._level}static log(...e){this.level()>=s.DEBUG&&console.log(...e)}static debug(...e){this.level()>=s.DEBUG&&console.debug(...e)}static info(...e){this.level()>=s.INFO&&console.info(...e)}static error(...e){this.level()>=s.ERROR&&console.error(...e)}static warning(...e){this.level()>=s.WARNING&&console.warn(...e)}static table(...e){this.level()>=s.DEBUG&&console.table(...e)}static group(...e){this.level()>=s.DEBUG&&console.group(...e)}static groupCollapsed(...e){this.level()>=s.DEBUG&&console.groupCollapsed(...e)}static groupEnd(...e){this.level()>=s.DEBUG&&console.groupEnd(...e)}static time(...e){this.level()>=s.DEBUG&&console.time(...e)}static timeLog(...e){this.level()>=s.DEBUG&&console.timeLog(...e)}static timeEnd(...e){this.level()>=s.DEBUG&&console.timeEnd(...e)}static trace(...e){this.level()>=s.DEBUG&&console.trace(...e)}}r._level=s.NONE;var n={};e(n,"DOM",(()=>i)),e(n,"$_",(()=>o)),e(n,"$_ready",(()=>a));class i{constructor(e){if(null===e)return this.collection=[],void(this.length=0);if("string"==typeof e)this.collection=document.querySelectorAll(e),this.length=this.collection.length,this._selector=e;else if(e instanceof NodeList)this.collection=e,this.length=e.length,this._selector=e;else if(e instanceof i)this.collection=e.collection,this.length=this.collection.length,this._selector=e._selector;else if(e instanceof HTMLElement)this.collection=[e],this.length=this.collection.length,this._selector=e;else{if("object"!=typeof e)return;e.length>=1?this.collection=e:this.collection=[e],this.length=this.collection.length,this._selector=e}}hide(){for(const e of this.collection)e.style.display="none";return this}show(e="block"){for(const t of this.collection)t.style.display=e;return this}addClass(e){for(const t of this.collection)t.classList.add(e);return this}removeClass(e=null){if(null!==e)for(const t of this.collection)t.classList.remove(e);else for(const e of this.collection)for(;e.classList.length>0;)e.classList.remove(e.classList.item(0));return this}toggleClass(e){e=e.split(" ");for(const t of this.collection)for(let s=0;s<e.length;s++)t.classList.toggle(e[s]);return this}hasClass(e){for(const t of this.collection)if(!t.classList.contains(e))return!1;return!0}value(e){if(void 0!==e){for(const t of this.collection)t.value=e;return this}if(this.length>0)return this.collection[0].value}focus(){return this.length>0&&this.collection[0].focus(),this}click(e){for(const t of this.collection)t.addEventListener("click",e,!1);return this}keyup(e){for(const t of this.collection)t.addEventListener("keyup",e,!1);return this}keydown(e){for(const t of this.collection)t.addEventListener("keydown",e,!1);return this}submit(e){for(const t of this.collection)t.addEventListener("submit",e,!1);return this}change(e){for(const t of this.collection)t.addEventListener("change",e,!1);return this}scroll(e){for(const t of this.collection)t.addEventListener("scroll",e,!1);return this}on(e,t,s){e=e.split(" ");for(const r of this.collection)for(let n=0;n<e.length;n++)"function"==typeof t?r.addEventListener(e[n],t,!1):"string"==typeof t&&"function"==typeof s&&r.addEventListener(e[n],(e=>{if(!e.target)return;const r=o(e.target).closestParent(t,this._selector);r.exists()&&s.call(r.get(0),e)}),!1);return this}filter(e){return this.length>0?new i(this.collection[0].querySelector(e)):new i(null)}exists(){return this.length>0}data(e,t){if(void 0!==t){for(const s of this.collection)s.dataset[e]=t;return this}if(this.length>0)return this.collection[0].dataset[e]}removeData(e){for(const t of this.collection)delete t.dataset[e];return this}text(e){if(void 0!==e){for(const t of this.collection)t.textContent=e;return this}if(this.length>0)return this.collection[0].textContent}html(e){if(void 0!==e){for(const t of this.collection)t.innerHTML=e;return this}if(this.length>0)return this.collection[0].innerHTML}append(e){if(this.length>0)if("string"==typeof e){const t=document.createElement("div");t.innerHTML="string"==typeof e?e.trim():e,this.collection[0].appendChild(t.firstChild)}else this.collection[0].appendChild(e);return this}prepend(e){if(this.length>0)if("string"==typeof e){const t=document.createElement("div");t.innerHTML="string"==typeof e?e.trim():e,this.collection[0].childNodes.length>0?this.collection[0].insertBefore(t.firstChild,this.collection[0].childNodes[0]):this.collection[0].appendChild(t.firstChild)}else this.collection[0].childNodes.length>0?this.collection[0].insertBefore(e,this.collection[0].childNodes[0]):this.collection[0].appendChild(e);return this}each(e){for(const t of this.collection)e(t);return this}get(e){return this.collection[e]}first(){return this.length>0?new i(this.collection[0]):new i(null)}last(){return this.length>0?new i(this.collection[this.collection.length-1]):new i(null)}isVisible(){for(const e of this.collection)if("none"!=e.display&&e.offsetWidth>0&&e.offsetHeight>0)return!0;return!1}parent(){return this.length>0?new i(this.collection[0].parentElement):new i(null)}find(e){return this.length>0?new i(this.collection[0].querySelectorAll(e)):new i(null)}offset(){if(this.length>0){const e=this.collection[0].getBoundingClientRect();return{top:e.top+document.body.scrollTop,left:e.left+document.body.scrollLeft}}}closest(e){let t=null,s=this;for(;s.exists()&&null===t;){if(!0===s.matches(e))return s;const r=s.find(e);r&&r.length>0&&(t=r),s=s.parent()}return null!==t?t:s}closestParent(e,t){let s=this;for(;s.exists();){if(!0===s.matches(e))return s;if("string"==typeof t&&s.matches(t))break;s=s.parent()}return new i(null)}attribute(e,t){if(void 0!==t){for(const s of this.collection)s.setAttribute(e,t);return this}if(this.length>0)return this.collection[0].getAttribute(e)}hasAttribute(e){for(const t of this.collection)if(!t.hasAttribute(e))return!1;return!0}after(e){for(const t of this.collection)t.insertAdjacentHTML("afterend",e);return this}before(e){for(const t of this.collection)t.insertAdjacentHTML("beforebegin",e);return this}style(e,t){for(let s=0;s<this.collection.length;s++)if("string"==typeof e&&void 0!==t)this.collection[s].style[e]=t;else{if("string"==typeof e&&void 0===t)return this.collection[s].style[e];if("object"==typeof e)for(const t in e)this.collection[s].style[t]=e[t]}return this}animate(e,t){for(let s=0;s<this.collection.length;s++)for(const r in e){const n=(new Date).getTime(),i=this.collection;let o,a;void 0!==this.collection[s].style[r]?(a=this.collection[s].style[r],o=setInterval((()=>{const l=Math.min(1,((new Date).getTime()-n)/t);i[s].style[r]=a+l*(e[r]-a),1==l&&clearInterval(o)}),25),this.collection[s].style[r]=a):void 0!==this.collection[s][r]&&(a=this.collection[s][r],o=setInterval((()=>{const l=Math.min(1,((new Date).getTime()-n)/t);i[s][r]=a+l*(e[r]-a),1==l&&clearInterval(o)}),25),this.collection[s][r]=a)}return this}fadeIn(e=400,t){if(this.length>0){const s=this.collection[0];s.style.opacity=0;let r=+new Date;const n=()=>{s.style.opacity=+s.style.opacity+(new Date-r)/e,r=+new Date,+s.style.opacity<1?window.requestAnimationFrame&&requestAnimationFrame(n)||setTimeout(n,16):"function"==typeof t&&t()};n()}return this}fadeOut(e=400,t){if(this.length>0){let s=+new Date;const r=this.collection[0],n=()=>{r.style.opacity=+r.style.opacity-(new Date-s)/e,s=+new Date,+r.style.opacity>0?window.requestAnimationFrame&&requestAnimationFrame(n)||setTimeout(n,16):"function"==typeof t&&t()};n()}return this}matches(e){const t=Element.prototype,s=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||function(){return-1!==[].indexOf.call(document.querySelectorAll(e),this)};return this.length>0&&s.call(this.collection[0],e)}remove(){for(const e of this.collection)e.parentNode.removeChild(e);return this}replaceWith(e){let t=e;if("string"==typeof e){const s=document.createElement("div");s.innerHTML=e,t=s.firstChild}for(const e of this.collection)e.parentElement.replaceChild(t,e);return this}reset(){for(const e of this.collection)e.reset();return this}property(e,t){if(void 0!==t){for(const s of this.collection)s[e]=t;return this}if(this.length>0)return this.collection[0][e]}}function o(e){return void 0!==e?new i(e):i}function a(e){window.addEventListener("load",e)}e({},"FileSystem",(()=>c));e({},"Request",(()=>l));class l{static serialize(e){return Object.keys(e).map((t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&")}static get(e,t={},s={}){const r=l.serialize(t);return""!==r&&(e=`${e}?${r}`),fetch(e,s)}static post(e,t,s={}){let r;if(void 0!==s.headers){const e=s.headers["Content-Type"];if(void 0!==e)if("multipart/form-data"==e){r=new FormData;for(const e in t)r.append(e,t[e])}else r="application/json"==e?JSON.stringify(t):l.serialize(t)}else r=l.serialize(t);const n=Object.assign({},{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r},s);return void 0!==n.headers&&"multipart/form-data"===n.headers["Content-Type"]&&delete n.headers["Content-Type"],fetch(e,n)}static put(e,t,s={}){return l.post(e,t,Object.assign({},{method:"PUT"},s))}static delete(e,t,s={}){return l.get(e,t,Object.assign({},{method:"DELETE"},s))}static json(e,t={},s={}){return l.get(e,t,s).then((e=>e.json()))}static blob(e,t={},s={}){return l.get(e,t,s).then((e=>e.blob()))}}class c{static readRemote(e,t="base64",s={}){return l.blob(e,{},s).then((e=>c.read(e,t)))}static read(e,t="text"){return new Promise(((s,r)=>{const n=new FileReader;n.onload=e=>{s(e,e.target.result)},n.onerror=e=>{r(e)},"base64"===t?n.readAsDataURL(e):"buffer"===t?n.readAsArrayBuffer(e):n.readAsText(e,"UTF-8")}))}static create(e,t,s="text/plain"){return Promise.resolve(new File([t],e,{type:s}))}static extension(e){return e.split(".").pop()}static isImage(e){return["jpg","jpeg","png","gif","svg","webp","bmp"].indexOf(c.extension(e).toLowerCase())>-1}}e({},"Form",(()=>h));class h{static fill(e,t){for(const s in t){const r=o(`form[data-form='${e}'] [name='${s}']`).get(0);if(void 0!==r)switch(r.type){case"file":case"file[]":break;default:r.value=t[s]}}}static values(e){const t={};return o(`form[data-form='${e}'] [name]`).each((e=>{let s;switch(e.type){case"file[]":s=e.files;break;case"file":s=e.files[0];break;default:s=e.value}null!=s&&(t[e.name]=s)})),t}}e({},"Platform",(()=>O));var u,d,f,p=u={};function g(){throw new Error("setTimeout has not been defined")}function m(){throw new Error("clearTimeout has not been defined")}function v(e){if(d===setTimeout)return setTimeout(e,0);if((d===g||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}!function(){try{d="function"==typeof setTimeout?setTimeout:g}catch(e){d=g}try{f="function"==typeof clearTimeout?clearTimeout:m}catch(e){f=m}}();var y,w=[],b=!1,k=-1;function P(){b&&y&&(b=!1,y.length?w=y.concat(w):k=-1,w.length&&j())}function j(){if(!b){var e=v(P);b=!0;for(var t=w.length;t;){for(y=w,w=[];++k<t;)y&&y[k].run();k=-1,t=w.length}y=null,b=!1,function(e){if(f===clearTimeout)return clearTimeout(e);if((f===m||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}(e)}}function E(e,t){this.fun=e,this.array=t}function L(){}p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];w.push(new E(e,t)),1!==w.length||b||v(j)},E.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=L,p.addListener=L,p.once=L,p.off=L,p.removeListener=L,p.removeAllListeners=L,p.emit=L,p.prependListener=L,p.prependOnceListener=L,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0};class O{static retina(){return window.devicePixelRatio>=2}static portrait(){return 0===window.orientation||180===window.orientation}static landscape(){return 90===window.orientation||-90===window.orientation}static orientation(){return O.portrait()?"portrait":"landscape"}static electron(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!(void 0===u||"object"!=typeof u.versions||!u.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>-1)}static cordova(){return!!window.cordova}static desktop(e="Any"){let t=!1;switch(e){case"Windows":t=navigator.platform.includes("Win");break;case"macOS":t=navigator.platform.includes("Mac");break;case"Linux":t=navigator.platform.includes("Linux");break;case"FreeBSD":t=navigator.platform.includes("FreeBSD");break;case"webOS":t=navigator.platform.includes("WebTV");break;default:t=navigator.platform.includes("Win")||navigator.platform.includes("Mac")||navigator.platform.includes("Linux")||navigator.platform.includes("FreeBSD")||navigator.platform.includes("WebTV")}return t}static mobile(e="Any"){let t=!1;switch(e){case"Android":t=/Android/i.test(navigator.userAgent);break;case"iOS":t=/iPhone|iPad|iPod/i.test(navigator.userAgent);break;case"Opera":t=/Opera Mini/i.test(navigator.userAgent);break;case"Windows":t=/Windows Phone|IEMobile|WPDesktop/i.test(navigator.userAgent);break;case"BlackBerry":t=/BlackBerry|BB10/i.test(navigator.userAgent);break;default:t=/Android|iPhone|iPad|iPod|Windows Phone|IEMobile|WPDesktop|BlackBerry|BB10/i.test(navigator.userAgent)}return t}static serviceWorkers(){return"undefined"!=typeof navigator&&"serviceWorker"in navigator&&location.protocol.indexOf("http")>-1}}e({},"Preload",(()=>S));class S{static image(e){return new Promise(((t,s)=>{const r=new Image;r.onload=()=>{t(r)},r.onerror=e=>{s(e)},r.src=e}))}static file(e){return l.blob(e)}}var x={};e(x,"SpaceAdapter",(()=>I)),e(x,"Space",(()=>T));class A{constructor({name:e="",version:t="",store:s=""}){this.name=e,this.version=t,this.store=s,this.upgrades={},""===this.version?this.numericVersion=0:this.numericVersion=parseInt(t.replace(/\./g,"")),this.id=""!==e&&""!==t&&""!==s?`${this.name}::${this.store}::${this.version}_`:""!==e&&""!==t?`${this.name}::${this.version}_`:""!==e?`${this.name}::_`:""}open(){return"object"!=typeof this.storage||this.storage instanceof Promise?(this.storage instanceof Promise||(this.storage=new Promise((e=>{let t=[];if(""!==this.version){let e="";""!==this.name&&""!==this.version&&""!==this.store?e=`${this.name}::${this.store}::`:""!==this.name&&""!==this.version&&(e=`${this.name}::`);const s=Object.keys(window.localStorage).filter((t=>0===t.indexOf(e))).map((t=>t.replace(e,"").split("_")[0])).filter((e=>-1===e.indexOf("::"))).sort();if(s.length>0){const e=s[0],r=parseInt(e.replace(/\./g,""));if(r<this.numericVersion){const s=Object.keys(this.upgrades).sort(),n=s.findIndex((e=>{const[t]=e.split("::");return parseInt(t)===r}));n>-1&&(t=s.slice(n).filter((e=>{const[t,s]=e.split("::");return parseInt(t)<this.numericVersion&&parseInt(s)<=this.numericVersion})));let i=`${this.name}::${e}_`;""!==this.name&&""!==this.version&&""!==this.store?i=`${this.name}::${this.store}::${e}_`:""!==this.name&&""!==this.version&&(i=`${this.name}::${e}_`);const o=Object.keys(window.localStorage).filter((e=>0===e.indexOf(i))).map((e=>e.replace(i,"")));for(const e of o){const t=window.localStorage.getItem(`${i}${e}`);window.localStorage.setItem(this.id+e,t),window.localStorage.removeItem(`${i}${e}`)}}}}e({upgrades:t})})).then((({upgrades:e})=>(this.storage=window.localStorage,new Promise((t=>{this._upgrade(e,(()=>t(this)))})))))),this.storage):Promise.resolve(this)}set(e,t){return this.open().then((()=>("object"==typeof t?this.storage.setItem(this.id+e,JSON.stringify(t)):this.storage.setItem(this.id+e,t),Promise.resolve({key:e,value:t}))))}update(e,t){return this.get(e).then((s=>("object"==typeof s?("object"==typeof t&&(t=Object.assign({},s,t)),this.storage.setItem(this.id+e,JSON.stringify(t))):this.storage.setItem(this.id+e,t),Promise.resolve({key:e,value:t})))).catch((()=>this.set(e,t)))}get(e){return this.open().then((()=>new Promise(((t,s)=>{let r=null;r=this.storage.getItem(this.id+e);try{const e=JSON.parse(r);e&&"object"==typeof e&&(r=e)}catch(e){}null!=r?t(r):s()}))))}getAll(){return this.keys().then((e=>{const t={},s=[];for(const r of e)s.push(this.get(r).then((e=>{t[r]=e})));return Promise.all(s).then((()=>t))}))}contains(e){return this.keys().then((t=>{if(!t.includes(e))return Promise.reject();Promise.resolve()}))}upgrade(e,t,s){return this.upgrades[`${parseInt(e.replace(/\./g,""))}::${parseInt(t.replace(/\./g,""))}`]=s,Promise.resolve()}_upgrade(e,t){e.length>0?this.upgrades[e[0]].call(this,this).then((()=>{this._upgrade(e.slice(1),t)})).catch((e=>console.error(e))):t()}rename(e){return this.name!==e?this.keys().then((t=>{const s=this.id;this.name=e,""!==this.name&&""!==this.version&&""!==this.store?this.id=`${this.name}::${this.store}::${this.version}_`:""!==this.name&&""!==this.version?this.id=`${this.name}::${this.version}_`:""!==this.name?this.id=`${this.name}::_`:this.id="";const r=[];for(const e of t)r.push(this.set(e,this.storage.getItem(`${s}${e}`)).then((()=>{this.storage.removeItem(`${s}${e}`)})));return Promise.all(r)})):Promise.reject()}key(e,t=!1){return this.open().then((()=>!0===t?Promise.resolve(this.storage.key(e)):Promise.resolve(this.storage.key(e).replace(this.id,""))))}keys(e=!1){return this.open().then((()=>Promise.resolve(Object.keys(this.storage).filter((e=>0===e.indexOf(this.id))).map((t=>!0===e?t:t.replace(this.id,""))))))}remove(e){return this.get(e).then((t=>(this.storage.removeItem(this.id+e),Promise.resolve(t))))}clear(){return this.keys().then((e=>{for(const t of e)this.remove(t);return Promise.resolve()}))}}const I={LocalStorage:A,SessionStorage:class extends A{constructor({name:e="",version:t="",store:s=""}){super({name:e,version:t,store:s})}open(){return void 0===this.storage&&(this.storage=window.sessionStorage),Promise.resolve(this)}},IndexedDB:class{constructor({name:e="",version:t="",store:s="",props:r={},index:n={}}){this.name=e,this.version=t,this.store=s,this.props=r||{},this.index=n,this.keyPath=r.keyPath||"id",this.upgrades={},""===this.version?this.numericVersion=0:this.numericVersion=parseInt(t.replace(/\./g,""))}open(){return""===this.name?(console.error("No name has been defined for IndexedDB space."),Promise.reject()):""===this.store?(console.error("No store has been defined for IndexedDB space."),Promise.reject()):this.storage instanceof IDBDatabase?Promise.resolve(this):(this.storage instanceof Promise||(this.storage=new Promise(((e,t)=>{let s=[];const r=window.indexedDB.open(this.name,this.numericVersion);r.onerror=e=>{t(e)},r.onsuccess=t=>{e({storage:t.target.result,upgrades:s})},r.onupgradeneeded=t=>{if(t.oldVersion<1){const e=t.target.result.createObjectStore(this.store,this.props);for(const t of Object.keys(this.index))e.createIndex(this.index[t].name,this.index[t].field,this.index[t].props)}else{const e=Object.keys(this.upgrades).sort(),r=e.findIndex((e=>{const[s]=e.split("::");return parseInt(s)===t.oldVersion}));r>-1&&(s=e.slice(r).filter((e=>{const[t,s]=e.split("::");return parseInt(t)<this.numericVersion&&parseInt(s)<=this.numericVersion})))}t.target.transaction.addEventListener("success",(()=>{e({storage:t.target.result,upgrades:s})}))}})).then((({storage:e,upgrades:t})=>(this.storage=e,new Promise((s=>{this._upgrade(t,(()=>s(e)),event)})))))),this.storage)}set(e=null,t){return this.open().then((()=>new Promise(((s,r)=>{const n=this.storage.transaction(this.store,"readwrite").objectStore(this.store);let i;if(null!==e){const s={};s[this.keyPath]=e,i=n.put(Object.assign({},s,t))}else i=n.add(t);i.addEventListener("success",(e=>{s({key:e.target.result,value:t})})),i.addEventListener("error",(e=>{r(e)}))}))))}update(e,t){return this.get(e).then((s=>void 0===s?this.set(e,t):new Promise(((e,r)=>{const n=this.storage.transaction(this.store,"readwrite").objectStore(this.store).put(Object.assign({},s,t));n.addEventListener("success",(s=>{e({key:s.target.result,value:t})})),n.addEventListener("error",(e=>{r(e)}))}))))}get(e){return this.open().then((()=>new Promise(((t,s)=>{const r=this.storage.transaction(this.store).objectStore(this.store).get(e);r.addEventListener("success",(e=>{const r=e.target.result;null!=r?t(r):s()})),r.addEventListener("error",(e=>{s(e)}))}))))}getAll(){return this.open().then((()=>new Promise(((e,t)=>{const s=this.storage.transaction(this.store).objectStore(this.store).getAll();s.addEventListener("success",(t=>{const s={};t.target.result.forEach((e=>{const t=e[this.keyPath];delete e[this.keyPath],s[t]=e})),e(s)})),s.addEventListener("error",(e=>{t(e)}))}))))}contains(e){return this.get(e).then((t=>{if(!t.includes(e))return Promise.reject();Promise.resolve()}))}upgrade(e,t,s){return this.upgrades[`${parseInt(e.replace(/\./g,""))}::${parseInt(t.replace(/\./g,""))}`]=s,Promise.resolve()}_upgrade(e,t,s){e.length>0?this.upgrades[e[0]].call(this,this,s).then((()=>{this._upgrade(e.slice(1),t,s)})).catch((e=>console.error(e))):t()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then((()=>new Promise(((e,t)=>{const s=this.storage.transaction(this.store,"readwrite").objectStore(this.store).getAllKeys();s.addEventListener("success",(t=>{e(t.target.result)}),!1),s.addEventListener("error",(e=>{t(e)}),!1)}))))}remove(e){return this.get(e).then((t=>new Promise(((s,r)=>{const n=this.storage.transaction(this.store,"readwrite").objectStore(this.store).delete(e);n.addEventListener("success",(()=>{s(t)}),!1),n.addEventListener("error",(e=>{r(e)}),!1)}))))}clear(){return this.open().then((()=>new Promise(((e,t)=>{const s=this.storage.transaction(this.store,"readwrite").objectStore(this.store).clear();s.addEventListener("success",(()=>{e()}),!1),s.addEventListener("error",(e=>{t(e)}),!1)}))))}},RemoteStorage:class{constructor({name:e="",version:t="",store:s="",endpoint:r="",props:n={}}){this.name=e,this.version=t,this.store=s,this.endpoint=`${r}${s}/`,this.props=n}open(){return void 0===this.storage&&(this.storage=l),Promise.resolve(this)}set(e,t){return this.open().then((()=>this.storage.post(this.endpoint+e,t,this.props).then((e=>e.json())).then((t=>Promise.resolve({key:e,value:t})))))}update(e,t){return this.get(e).then((s=>this.storage.put(this.endpoint+e,Object.assign({},s,t),this.props).then((e=>e.json())).then((t=>Promise.resolve({key:e,value:t})))))}get(e){return this.open().then((()=>this.storage.json(this.endpoint+e,{},this.props)))}getAll(){return this.open().then((()=>this.storage.json(this.endpoint,{},this.props)))}contains(e){return this.keys().then((t=>{if(!t.includes(e))return Promise.reject();Promise.resolve()}))}upgrade(){return Promise.reject()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then((()=>this.storage.json(this.endpoint,{keys:!0},this.props)))}remove(e){return this.open().then((()=>this.storage.delete(this.endpoint+e,{},this.props).then((e=>e.json())).then((t=>Promise.resolve(e,t)))))}clear(){return this.open().then((()=>this.storage.delete(this.endpoint,{},this.props)))}}};class T{constructor(e=I.LocalStorage,t={}){this._configuration=Object.assign({},{name:"",version:"",store:""},t),this.adapter=new e(this._configuration),this.callbacks={create:[],update:[],delete:[]},this.transformations={}}configuration(e=null){if(null===e)return this._configuration;this._configuration=Object.assign({},this._configuration,e),this.adapter.configuration(e)}open(){return this.adapter.open().then((()=>Promise.resolve(this)))}set(e,t){for(const s of Object.keys(this.transformations))"function"==typeof this.transformations[s].set&&(t=this.transformations[s].set.call(null,e,t));return this.adapter.set(e,t).then((({key:e,value:t})=>{for(const s of this.callbacks.create)s.call(null,e,t);return Promise.resolve({key:e,value:t})}))}update(e,t){for(const s of Object.keys(this.transformations))"function"==typeof this.transformations[s].set&&(t=this.transformations[s].set.call(null,e,t));return this.adapter.update(e,t).then((({key:e,value:t})=>{for(const s of this.callbacks.update)s.call(null,e,t);return Promise.resolve({key:e,value:t})}))}get(e){return this.adapter.get(e).then((t=>{for(const s of Object.keys(this.transformations))"function"==typeof this.transformations[s].get&&(t=this.transformations[s].get.call(null,e,t));return t}))}getAll(){return this.adapter.getAll().then((e=>{for(const t of Object.keys(e))for(const s of Object.keys(this.transformations))"function"==typeof this.transformations[s].get&&(e[t]=this.transformations[s].get.call(null,t,e[t]));return e}))}each(e){return this.getAll().then((t=>{const s=[];for(const r of Object.keys(t))s.push(e.call(this,r,t[r]));return Promise.all(s)}))}contains(e){return this.adapter.contains(e)}upgrade(e,t,s){return this.adapter.upgrade(e,t,s).then((()=>Promise.resolve(this)))}rename(e){return this.adapter.rename(e)}onCreate(e){this.callbacks.create.push(e)}onUpdate(e){this.callbacks.update.push(e)}onDelete(e){this.callbacks.delete.push(e)}addTransformation({id:e,get:t,set:s}){this.transformations[e]={id:e,get:t,set:s}}removeTransformation(e){delete this.transformations[e]}key(e,t=!1){return this.adapter.key(e,t)}keys(e=!1){return this.adapter.keys(e)}remove(e){return this.adapter.remove(e).then((t=>{for(const s of this.callbacks.delete)s.call(null,e,t)}))}clear(){return this.adapter.clear()}}e({},"Text",(()=>$));class ${static capitalize(e){return e.replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}static suffix(e,t){let s="",r=t.indexOf(e);return-1!==r&&(r+=e.length,s=t.substr(r,t.length-r)),s}static selection(){return window.getSelection?window.getSelection().toString():document.selection&&"Control"!=document.selection.type?document.selection.createRange().text:void 0}static prefix(e,t){let s="";const r=t.indexOf(e);return-1!=r&&(s=t.substr(0,r)),s}static friendly(e){const t=[/[áàâãªä]/,/[ÁÀÂÃÄ]/,/[ÍÌÎÏ]/,/[íìîï]/,/[éèêë]/,/[ÉÈÊË]/,/[óòôõºö]/,/[ÓÒÔÕÖ]/,/[úùûü]/,/[ÚÙÛÜ]/,/ç/,/Ç/,/ñ/,/Ñ/,/_/,/[’‘‹›<>']/,/[“”«»„"]/,/[(){}[\]]/,/[?¿!¡#$%&^*´`~/°|]/,/[,.:;]/,/ /],s=["a","A","I","i","e","E","o","O","u","U","c","C","n","N","-","","","","","","-"];for(const r in t)e=e.replace(new RegExp(t[r],"g"),s[r]);return e}}e({},"Util",(()=>D));class D{static callAsync(e,t,...s){try{const r=e.apply(t,s);return r instanceof Promise?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}static uuid(){if(window.crypto)return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)));{const e=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}}}export{s as DebugLevel,r as Debug,i as DOM,o as $_,a as $_ready,c as FileSystem,h as Form,O as Platform,S as Preload,l as Request,I as SpaceAdapter,T as Space,$ as Text,D as Util};
|
|
1
|
+
var M;((Z)=>{Z[Z.NONE=0]="NONE";Z[Z.ERROR=1]="ERROR";Z[Z.WARNING=2]="WARNING";Z[Z.INFO=3]="INFO";Z[Z.DEBUG=4]="DEBUG";Z[Z.ALL=5]="ALL"})(M||={});class T{static _level=0;static level(z){if(typeof z==="number")this._level=z;return this._level}static log(...z){if(this.level()>=4)console.log(...z)}static debug(...z){if(this.level()>=4)console.debug(...z)}static info(...z){if(this.level()>=3)console.info(...z)}static error(...z){if(this.level()>=1)console.error(...z)}static warning(...z){if(this.level()>=2)console.warn(...z)}static table(...z){if(this.level()>=4)console.table(...z)}static group(...z){if(this.level()>=4)console.group(...z)}static groupCollapsed(...z){if(this.level()>=4)console.groupCollapsed(...z)}static groupEnd(){if(this.level()>=4)console.groupEnd()}static time(z){if(this.level()>=4)console.time(z)}static timeLog(z,...H){if(this.level()>=4)console.timeLog(z,...H)}static timeEnd(z){if(this.level()>=4)console.timeEnd(z)}static trace(...z){if(this.level()>=4)console.trace(...z)}}class ${collection;length;_selector;constructor(z){if(z===null){this.collection=[],this.length=0,this._selector=null;return}if(typeof z==="string")this.collection=document.querySelectorAll(z),this.length=this.collection.length,this._selector=z;else if(z instanceof NodeList)this.collection=z,this.length=z.length,this._selector=z;else if(z instanceof $)this.collection=z.collection,this.length=this.collection.length,this._selector=z._selector;else if(z instanceof HTMLElement)this.collection=[z],this.length=this.collection.length,this._selector=z;else if(Array.isArray(z))this.collection=z,this.length=z.length,this._selector=z;else this.collection=[],this.length=0,this._selector=null}hide(){for(let z of this.collection)z.style.display="none";return this}show(z="block"){for(let H of this.collection)H.style.display=z;return this}addClass(z){for(let H of this.collection)H.classList.add(z);return this}removeClass(z=null){if(z!==null)for(let H of this.collection)H.classList.remove(z);else for(let H of this.collection)while(H.classList.length>0){let Q=H.classList.item(0);if(Q)H.classList.remove(Q)}return this}toggleClass(z){let H=z.split(" ");for(let Q of this.collection)for(let X of H)Q.classList.toggle(X);return this}hasClass(z){for(let H of this.collection)if(!H.classList.contains(z))return!1;return!0}value(z){if(typeof z<"u"){for(let H of this.collection)H.value=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].value;let H=[];for(let Q of this.collection)H.push(Q.value);return H}}focus(){if(this.length>0)this.collection[0].focus();return this}click(z){for(let H of this.collection)H.addEventListener("click",z,!1);return this}keyup(z){for(let H of this.collection)H.addEventListener("keyup",z,!1);return this}keydown(z){for(let H of this.collection)H.addEventListener("keydown",z,!1);return this}submit(z){for(let H of this.collection)H.addEventListener("submit",z,!1);return this}change(z){for(let H of this.collection)H.addEventListener("change",z,!1);return this}scroll(z){for(let H of this.collection)H.addEventListener("scroll",z,!1);return this}on(z,H,Q){let X=z.split(" ");for(let Y of this.collection)for(let J of X)if(typeof H==="function")Y.addEventListener(J,H,!1);else if(typeof H==="string"&&typeof Q==="function")Y.addEventListener(J,(Z)=>{if(!Z.target)return;let _=new $(Z.target).closestParent(H,this._selector);if(_.exists())Q.call(_.get(0),Z)},!1);return this}filter(z){let H=[];for(let Q of this.collection)if(Q.matches(z))H.push(Q);return new $(H.length>0?H:null)}exists(){return this.length>0}data(z,H){if(typeof H<"u"){for(let Q of this.collection)Q.dataset[z]=H;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].dataset[z];let Q=[];for(let X of this.collection)Q.push(X.dataset[z]);return Q}}removeData(z){for(let H of this.collection)delete H.dataset[z];return this}text(z){if(typeof z<"u"){for(let H of this.collection)H.textContent=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].textContent;let H=[];for(let Q of this.collection)H.push(Q.textContent);return H}}html(z){if(typeof z<"u"){for(let H of this.collection)H.innerHTML=z;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].innerHTML;let H=[];for(let Q of this.collection)H.push(Q.innerHTML);return H}}append(z){for(let H of this.collection)if(typeof z==="string"){let Q=document.createElement("div");if(Q.innerHTML=z.trim(),Q.firstChild)H.appendChild(Q.firstChild.cloneNode(!0))}else H.appendChild(z.cloneNode(!0));return this}prepend(z){for(let H of this.collection)if(typeof z==="string"){let Q=document.createElement("div");if(Q.innerHTML=z.trim(),Q.firstChild)if(H.childNodes.length>0)H.insertBefore(Q.firstChild.cloneNode(!0),H.childNodes[0]);else H.appendChild(Q.firstChild.cloneNode(!0))}else if(H.childNodes.length>0)H.insertBefore(z.cloneNode(!0),H.childNodes[0]);else H.appendChild(z.cloneNode(!0));return this}each(z){for(let H of this.collection)z(H);return this}get(z){return this.collection[z]}first(){if(this.length>0)return new $(this.collection[0]);return new $(null)}last(){if(this.length>0)return new $(this.collection[this.collection.length-1]);return new $(null)}isVisible(){for(let z of this.collection){let H=z;if(H.style.display!=="none"&&H.offsetWidth>0&&H.offsetHeight>0)return!0}return!1}parent(){let z=[];for(let H of this.collection)if(H.parentElement&&!z.includes(H.parentElement))z.push(H.parentElement);return new $(z.length>0?z:null)}find(z){let H=[];for(let Q of this.collection){let X=Q.querySelectorAll(z);for(let Y of X)if(!H.includes(Y))H.push(Y)}return new $(H.length>0?H:null)}offset(){if(this.length===0)return;if(this.length===1){let H=this.collection[0].getBoundingClientRect();return{top:H.top+document.body.scrollTop,left:H.left+document.body.scrollLeft}}let z=[];for(let H of this.collection){let Q=H.getBoundingClientRect();z.push({top:Q.top+document.body.scrollTop,left:Q.left+document.body.scrollLeft})}return z}closest(z){let H=[];for(let Q of this.collection){let X=Q.closest(z);if(X&&!H.includes(X))H.push(X)}return new $(H.length>0?H:null)}closestParent(z,H){if(this.length===0)return new $(null);let Q=this.collection[0];while(Q){if(Q.matches(z))return new $(Q);if(typeof H==="string"&&Q.matches(H))break;Q=Q.parentElement}return new $(null)}attribute(z,H){if(typeof H<"u"){for(let Q of this.collection)Q.setAttribute(z,String(H));return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0].getAttribute(z);let Q=[];for(let X of this.collection)Q.push(X.getAttribute(z));return Q}}hasAttribute(z){for(let H of this.collection)if(!H.hasAttribute(z))return!1;return!0}after(z){for(let H of this.collection)H.insertAdjacentHTML("afterend",z);return this}before(z){for(let H of this.collection)H.insertAdjacentHTML("beforebegin",z);return this}style(z,H){if(typeof z==="string"&&typeof H>"u"){if(this.length===0)return;if(this.length===1)return this.collection[0].style.getPropertyValue(z);let Q=[];for(let X of this.collection)Q.push(X.style.getPropertyValue(z));return Q}for(let Q of this.collection){let X=Q;if(typeof z==="string"&&typeof H<"u")X.style.setProperty(z,H);else if(typeof z==="object")for(let Y in z)X.style.setProperty(Y,String(z[Y]))}return this}animate(z,H){for(let Q=0;Q<this.collection.length;Q++){let X=this.collection[Q];for(let Y in z){let J=Date.now(),Z;if(typeof X.style.getPropertyValue(Y)<"u"&&X.style.getPropertyValue(Y)!==""){Z=parseFloat(X.style.getPropertyValue(Y));let K=setInterval(()=>{let _=Math.min(1,(Date.now()-J)/H);if(X.style.setProperty(Y,String(Z+_*(z[Y]-Z))),_===1)clearInterval(K)},25);X.style.setProperty(Y,String(Z))}else if(typeof X[Y]<"u"){Z=X[Y];let K=setInterval(()=>{let _=Math.min(1,(Date.now()-J)/H);if(X[Y]=Z+_*(z[Y]-Z),_===1)clearInterval(K)},25);X[Y]=Z}}}return this}fadeIn(z=400,H){let Q=0,X=this.collection.length;for(let Y of this.collection){let J=Y;J.style.opacity="0";let Z=Date.now(),K=()=>{if(J.style.opacity=String(parseFloat(J.style.opacity)+(Date.now()-Z)/z),Z=Date.now(),parseFloat(J.style.opacity)<1)requestAnimationFrame(K);else if(Q++,Q===X&&typeof H==="function")H()};K()}return this}fadeOut(z=400,H){let Q=0,X=this.collection.length;for(let Y of this.collection){let J=Y,Z=Date.now(),K=()=>{if(J.style.opacity=String(parseFloat(J.style.opacity)-(Date.now()-Z)/z),Z=Date.now(),parseFloat(J.style.opacity)>0)requestAnimationFrame(K);else if(Q++,Q===X&&typeof H==="function")H()};K()}return this}matches(z){if(this.length===0)return!1;for(let H of this.collection)if(!H.matches(z))return!1;return!0}remove(){for(let z of this.collection)z.parentNode?.removeChild(z);return this}replaceWith(z){for(let H of this.collection){let Q;if(typeof z==="string"){let X=document.createElement("div");X.innerHTML=z,Q=X.firstChild}else Q=z.cloneNode(!0);H.parentElement?.replaceChild(Q,H)}return this}reset(){for(let z of this.collection)if(z.reset)z.reset();return this}property(z,H){if(typeof H<"u"){for(let Q of this.collection)Q[z]=H;return this}else{if(this.length===0)return;if(this.length===1)return this.collection[0][z];let Q=[];for(let X of this.collection)Q.push(X[z]);return Q}}}function A(z){return new $(z)}function D(z){window.addEventListener("load",z)}class G{static serialize(z){return Object.keys(z).map((H)=>{return encodeURIComponent(H)+"="+encodeURIComponent(String(z[H]))}).join("&")}static get(z,H={},Q={}){let X=G.serialize(H);if(X!=="")z=`${z}?${X}`;return fetch(z,Q)}static post(z,H,Q={}){let X,Y=Q.headers?.["Content-Type"];if(Y!==void 0)if(Y==="multipart/form-data"){X=new FormData;for(let K in H)X.append(K,String(H[K]))}else if(Y==="application/json")X=JSON.stringify(H);else X=G.serialize(H);else X=G.serialize(H);let J={"Content-Type":"application/x-www-form-urlencoded",...Q.headers};if(J["Content-Type"]==="multipart/form-data")delete J["Content-Type"];let Z={...Q,method:"POST",headers:J,body:X};return fetch(z,Z)}static put(z,H,Q={}){return G.post(z,H,Object.assign({},{method:"PUT"},Q))}static delete(z,H,Q={}){return G.get(z,H,Object.assign({},{method:"DELETE"},Q))}static json(z,H={},Q={}){return G.get(z,H,Q).then((X)=>{return X.json()})}static blob(z,H={},Q={}){return G.get(z,H,Q).then((X)=>{return X.blob()})}}class w{static readRemote(z,H="base64",Q={}){return G.blob(z,{},Q).then((X)=>{return w.read(X,H)})}static read(z,H="text"){return new Promise((Q,X)=>{let Y=new FileReader;if(Y.onload=(J)=>{Q({event:J,content:J.target?.result??null})},Y.onerror=(J)=>{X(J)},H==="base64")Y.readAsDataURL(z);else if(H==="buffer")Y.readAsArrayBuffer(z);else Y.readAsText(z,"UTF-8")})}static create(z,H,Q="text/plain"){return Promise.resolve(new File([H],z,{type:Q}))}static extension(z){return z.split(".").pop()??""}static isImage(z){return["jpg","jpeg","png","gif","svg","webp","bmp"].indexOf(w.extension(z).toLowerCase())>-1}}class q{static fill(z,H){for(let Q in H){let X=A(`form[data-form='${z}'] [name='${Q}']`).get(0);if(typeof X<"u")switch(X.type){case"file":case"file[]":break;default:X.value=H[Q];break}}}static values(z){let H={};return A(`form[data-form='${z}'] [name]`).each((Q)=>{let X=Q,Y;switch(X.type){case"file[]":Y=X.files??void 0;break;case"file":Y=X.files?.[0];break;default:Y=X.value;break}if(typeof Y<"u"&&Y!==null)H[X.name]=Y}),H}}class C{static retina(){return window.devicePixelRatio>=2}static portrait(){return window.screen.orientation.type==="portrait-primary"||window.screen.orientation.type==="portrait-secondary"}static landscape(){return window.screen.orientation.type==="landscape-primary"||window.screen.orientation.type==="landscape-secondary"}static orientation(){return C.portrait()?"portrait":"landscape"}static electron(){let z=window;if(typeof z<"u"&&typeof z.process==="object"&&z.process?.type==="renderer")return!0;let H=typeof globalThis<"u"?globalThis.process:void 0;if(H&&typeof H.versions==="object"&&!!H.versions?.electron)return!0;if(typeof navigator==="object"&&typeof navigator.userAgent==="string"&&navigator.userAgent.indexOf("Electron")>=0)return!0;return!1}static cordova(){return!!window.cordova}static getPlatformString(){if(navigator.userAgentData?.platform)return navigator.userAgentData.platform;let z=navigator.userAgent;if(z.includes("Win"))return"Windows";if(z.includes("Mac"))return"macOS";if(z.includes("Linux"))return"Linux";if(z.includes("FreeBSD"))return"FreeBSD";if(z.includes("WebTV"))return"webOS";return""}static desktop(z="Any"){let H=C.getPlatformString();switch(z){case"Windows":return H==="Windows"||H.includes("Win");case"macOS":return H==="macOS"||H.includes("Mac");case"Linux":return H==="Linux"||H.includes("Linux");case"FreeBSD":return H==="FreeBSD"||H.includes("FreeBSD");case"webOS":return H==="webOS"||H.includes("WebTV");case"Any":default:return["Windows","macOS","Linux","FreeBSD","webOS"].some((Q)=>H===Q||H.includes(Q.replace("macOS","Mac").replace("webOS","WebTV")))}}static mobile(z="Any"){if(navigator.userAgentData?.mobile!==void 0&&z==="Any")return navigator.userAgentData.mobile;let H=navigator.userAgent;switch(z){case"Android":return/Android/i.test(H);case"iOS":return/iPhone|iPad|iPod/i.test(H);case"Opera":return/Opera Mini/i.test(H);case"Windows":return/Windows Phone|IEMobile|WPDesktop/i.test(H);case"BlackBerry":return/BlackBerry|BB10/i.test(H);case"Any":default:return/Android|iPhone|iPad|iPod|Windows Phone|IEMobile|WPDesktop|BlackBerry|BB10/i.test(H)}}static serviceWorkers(){if(typeof navigator<"u"){if("serviceWorker"in navigator&&location.protocol.indexOf("http")>-1)return!0}return!1}}class R{static image(z){return new Promise((H,Q)=>{let X=new Image;X.onload=()=>{H(X)},X.onerror=(Y)=>{Q(Y)},X.src=z})}static file(z){return G.blob(z)}}class I{name;version;store;id;numericVersion;upgrades;storage;constructor({name:z="",version:H="",store:Q=""}){if(this.name=z,this.version=H,this.store=Q,this.upgrades={},this.version==="")this.numericVersion=0;else this.numericVersion=parseInt(H.replace(/\./g,""));if(z!==""&&H!==""&&Q!=="")this.id=`${this.name}::${this.store}::${this.version}_`;else if(z!==""&&H!=="")this.id=`${this.name}::${this.version}_`;else if(z!=="")this.id=`${this.name}::_`;else this.id=""}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(this.storage instanceof Storage)return Promise.resolve(this);else if(this.storage instanceof Promise)return this.storage;else{let z=new Promise((H)=>{let Q=[];if(this.version!==""){let X="";if(this.name!==""&&this.version!==""&&this.store!=="")X=`${this.name}::${this.store}::`;else if(this.name!==""&&this.version!=="")X=`${this.name}::`;let Y=Object.keys(window.localStorage).filter((J)=>{return J.indexOf(X)===0}).map((J)=>{return J.replace(X,"").split("_")[0]}).filter((J)=>{return J.indexOf("::")===-1}).sort();if(Y.length>0){let J=Y[0],Z=parseInt(J.replace(/\./g,""));if(Z<this.numericVersion){let K=Object.keys(this.upgrades).sort(),_=K.findIndex((W)=>{let[N]=W.split("::");return parseInt(N)===Z});if(_>-1)Q=K.slice(_).filter((W)=>{let[N,L]=W.split("::");return parseInt(N)<this.numericVersion&&parseInt(L)<=this.numericVersion});let B=`${this.name}::${J}_`;if(this.name!==""&&this.version!==""&&this.store!=="")B=`${this.name}::${this.store}::${J}_`;else if(this.name!==""&&this.version!=="")B=`${this.name}::${J}_`;let F=Object.keys(window.localStorage).filter((W)=>{return W.indexOf(B)===0}).map((W)=>{return W.replace(B,"")});for(let W of F){let N=window.localStorage.getItem(`${B}${W}`);if(N!==null)window.localStorage.setItem(this.id+W,N);window.localStorage.removeItem(`${B}${W}`)}}}}H({upgrades:Q})}).then(({upgrades:H})=>{return this.storage=window.localStorage,new Promise((Q)=>{let X=()=>Q(this);this._upgrade(H,X)})});return this.storage=z,z}}set(z,H){return this.open().then(()=>{if(typeof H==="object")this.storage.setItem(this.id+z,JSON.stringify(H));else this.storage.setItem(this.id+z,String(H));return Promise.resolve({key:z,value:H})})}update(z,H){return this.get(z).then((Q)=>{if(typeof Q==="object"&&Q!==null){if(typeof H==="object"&&H!==null)H=Object.assign({},Q,H);this.storage.setItem(this.id+z,JSON.stringify(H))}else this.storage.setItem(this.id+z,String(H));return Promise.resolve({key:z,value:H})}).catch(()=>{return this.set(z,H)})}get(z){return this.open().then(()=>{return new Promise((H,Q)=>{let X=this.storage.getItem(this.id+z);try{let Y=JSON.parse(X);if(Y&&typeof Y==="object")X=Y}catch{}if(typeof X<"u"&&X!==null)H(X);else Q()})})}getAll(){return this.keys().then((z)=>{let H={},Q=[];for(let X of z)Q.push(this.get(X).then((Y)=>{H[X]=Y}));return Promise.all(Q).then(()=>H)})}contains(z){return this.keys().then((H)=>{if(H.includes(z))return Promise.resolve();else return Promise.reject()})}upgrade(z,H,Q){let X=`${parseInt(z.replace(/\./g,""))}::${parseInt(H.replace(/\./g,""))}`;return this.upgrades[X]=Q,Promise.resolve()}_upgrade(z,H){if(z.length>0)this.upgrades[z[0]].call(this,this).then(()=>{this._upgrade(z.slice(1),H)}).catch((Q)=>console.error(Q));else H()}rename(z){if(this.name!==z)return this.keys().then((H)=>{let Q=this.id;if(this.name=z,this.name!==""&&this.version!==""&&this.store!=="")this.id=`${this.name}::${this.store}::${this.version}_`;else if(this.name!==""&&this.version!=="")this.id=`${this.name}::${this.version}_`;else if(this.name!=="")this.id=`${this.name}::_`;else this.id="";let X=[];for(let Y of H){let J=this.storage.getItem(`${Q}${Y}`);if(J!==null)X.push(this.set(Y,J).then(()=>{this.storage.removeItem(`${Q}${Y}`)}))}return Promise.all(X).then(()=>{})});else return Promise.reject()}key(z,H=!1){return this.open().then(()=>{let Q=this.storage.key(z);if(H===!0)return Promise.resolve(Q??"");else return Promise.resolve((Q??"").replace(this.id,""))})}keys(z=!1){return this.open().then(()=>{return Promise.resolve(Object.keys(this.storage).filter((H)=>{return H.indexOf(this.id)===0}).map((H)=>{if(z===!0)return H;else return H.replace(this.id,"")}))})}remove(z){return this.get(z).then((H)=>{return this.storage.removeItem(this.id+z),Promise.resolve(H)})}clear(){return this.keys().then((z)=>{for(let H of z)this.remove(H);return Promise.resolve()})}}class P extends I{constructor({name:z="",version:H="",store:Q=""}){super({name:z,version:H,store:Q})}open(){if(typeof this.storage>"u")this.storage=window.sessionStorage;return Promise.resolve(this)}}class U{name;version;store;props;index;keyPath;numericVersion;upgrades;storage;constructor({name:z="",version:H="",store:Q="",props:X={},index:Y={}}){if(this.name=z,this.version=H,this.store=Q,this.props=X||{},this.index=Y,this.keyPath=X?.keyPath||"id",this.upgrades={},this.version==="")this.numericVersion=0;else this.numericVersion=parseInt(H.replace(/\./g,""))}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(this.name==="")return console.error("No name has been defined for IndexedDB space."),Promise.reject();if(this.store==="")return console.error("No store has been defined for IndexedDB space."),Promise.reject();if(this.storage instanceof IDBDatabase)return Promise.resolve(this);else if(this.storage instanceof Promise)return this.storage;else{let z,H=new Promise((Q,X)=>{let Y=[],J=window.indexedDB.open(this.name,this.numericVersion);J.onerror=(Z)=>{X(Z)},J.onsuccess=(Z)=>{Q({storage:Z.target.result,upgrades:Y})},J.onupgradeneeded=(Z)=>{z=Z;let K=Z.target.result;if(Z.oldVersion<1){let B=K.createObjectStore(this.store,this.props);for(let F of Object.keys(this.index)){let W=this.index[F];B.createIndex(W.name,W.field,W.props)}}else{let B=Object.keys(this.upgrades).sort(),F=B.findIndex((W)=>{let[N]=W.split("::");return parseInt(N)===Z.oldVersion});if(F>-1)Y=B.slice(F).filter((W)=>{let[N,L]=W.split("::");return parseInt(N)<this.numericVersion&&parseInt(L)<=this.numericVersion})}let _=Z.target.transaction;if(_)_.addEventListener("complete",()=>{Q({storage:K,upgrades:Y})})}}).then(({storage:Q,upgrades:X})=>{return this.storage=Q,new Promise((Y)=>{let J=()=>Y(this);this._upgrade(X,J,z)})});return this.storage=H,H}}set(z=null,H){return this.open().then(()=>{return new Promise((Q,X)=>{let Y=this.storage.transaction(this.store,"readwrite").objectStore(this.store),J;if(z!==null){let Z={};Z[this.keyPath]=z,J=Y.put(Object.assign({},Z,H))}else J=Y.add(H);J.addEventListener("success",(Z)=>{Q({key:String(Z.target.result),value:H})}),J.addEventListener("error",(Z)=>{X(Z)})})})}update(z,H){return this.get(z).then((Q)=>{if(typeof Q>"u")return this.set(z,H);return new Promise((X,Y)=>{let Z=this.storage.transaction(this.store,"readwrite").objectStore(this.store).put(Object.assign({},Q,H));Z.addEventListener("success",(K)=>{X({key:String(K.target.result),value:H})}),Z.addEventListener("error",(K)=>{Y(K)})})})}get(z){return this.open().then(()=>{return new Promise((H,Q)=>{let Y=this.storage.transaction(this.store).objectStore(this.store).get(z);Y.addEventListener("success",(J)=>{let Z=J.target.result;if(typeof Z<"u"&&Z!==null)H(Z);else Q()}),Y.addEventListener("error",(J)=>{Q(J)})})})}getAll(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store).objectStore(this.store).getAll();X.addEventListener("success",(Y)=>{let J={};Y.target.result.forEach((K)=>{let _=K[this.keyPath];delete K[this.keyPath],J[_]=K}),z(J)}),X.addEventListener("error",(Y)=>{H(Y)})})})}contains(z){return this.get(z).then(()=>{return Promise.resolve()})}upgrade(z,H,Q){let X=`${parseInt(z.replace(/\./g,""))}::${parseInt(H.replace(/\./g,""))}`;return this.upgrades[X]=Q,Promise.resolve()}_upgrade(z,H,Q){if(z.length>0)this.upgrades[z[0]].call(this,this,Q).then(()=>{this._upgrade(z.slice(1),H,Q)}).catch((X)=>console.error(X));else H()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store,"readwrite").objectStore(this.store).getAllKeys();X.addEventListener("success",(Y)=>{z(Y.target.result.map(String))},!1),X.addEventListener("error",(Y)=>{H(Y)},!1)})})}remove(z){return this.get(z).then((H)=>{return new Promise((Q,X)=>{let J=this.storage.transaction(this.store,"readwrite").objectStore(this.store).delete(z);J.addEventListener("success",()=>{Q(H)},!1),J.addEventListener("error",(Z)=>{X(Z)},!1)})})}clear(){return this.open().then(()=>{return new Promise((z,H)=>{let X=this.storage.transaction(this.store,"readwrite").objectStore(this.store).clear();X.addEventListener("success",()=>{z()},!1),X.addEventListener("error",(Y)=>{H(Y)},!1)})})}}class E{name;version;store;endpoint;props;storage;constructor({name:z="",version:H="",store:Q="",endpoint:X="",props:Y={}}){this.name=z,this.version=H,this.store=Q,this.endpoint=`${X}${Q}/`,this.props=Y}configuration(z){if(z.name)this.name=z.name;if(z.version)this.version=z.version;if(z.store)this.store=z.store}open(){if(typeof this.storage>"u")this.storage=G;return Promise.resolve(this)}set(z,H){return this.open().then(()=>{return this.storage.post(this.endpoint+z,H,this.props).then((Q)=>{return Promise.resolve({key:z,value:Q.json()})})})}update(z,H){return this.get(z).then((Q)=>{let X=Object.assign({},Q,H);return this.storage.put(this.endpoint+z,X,this.props).then((Y)=>{return Promise.resolve({key:z,value:Y.json()})})})}get(z){return this.open().then(()=>{return this.storage.json(this.endpoint+z,{},this.props)})}getAll(){return this.open().then(()=>{return this.storage.json(this.endpoint,{},this.props)})}contains(z){return this.keys().then((H)=>{if(H.includes(z))return Promise.resolve();else return Promise.reject()})}upgrade(){return Promise.reject()}rename(){return Promise.reject()}key(){return Promise.reject()}keys(){return this.open().then(()=>{return this.storage.json(this.endpoint,{keys:!0},this.props)})}remove(z){return this.open().then(()=>{return this.storage.delete(this.endpoint+z,{},this.props).then((H)=>{return H.json()})})}clear(){return this.open().then(()=>{return this.storage.delete(this.endpoint,{},this.props).then(()=>{})})}}var O={LocalStorage:I,SessionStorage:P,IndexedDB:U,RemoteStorage:E};class j{_configuration;adapter;callbacks;transformations;constructor(z=O.LocalStorage,H={}){this._configuration=Object.assign({},{name:"",version:"",store:""},H),this.adapter=new z(this._configuration),this.callbacks={create:[],update:[],delete:[]},this.transformations={}}configuration(z=null){if(z!==null){if(this._configuration=Object.assign({},this._configuration,z),this.adapter.configuration)this.adapter.configuration(z)}else return this._configuration}open(){return this.adapter.open().then(()=>{return Promise.resolve(this)})}set(z,H){for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].set==="function")H=this.transformations[Q].set(z,H);return this.adapter.set(z,H).then(({key:Q,value:X})=>{for(let Y of this.callbacks.create)Y.call(null,Q,X);return Promise.resolve({key:Q,value:X})})}update(z,H){for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].set==="function")H=this.transformations[Q].set(z,H);return this.adapter.update(z,H).then(({key:Q,value:X})=>{for(let Y of this.callbacks.update)Y.call(null,Q,X);return Promise.resolve({key:Q,value:X})})}get(z){return this.adapter.get(z).then((H)=>{for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].get==="function")H=this.transformations[Q].get(z,H);return H})}getAll(){return this.adapter.getAll().then((z)=>{for(let H of Object.keys(z))for(let Q of Object.keys(this.transformations))if(typeof this.transformations[Q].get==="function")z[H]=this.transformations[Q].get(H,z[H]);return z})}each(z){return this.getAll().then((H)=>{let Q=[];for(let X of Object.keys(H))Q.push(z.call(this,X,H[X]));return Promise.all(Q)})}contains(z){return this.adapter.contains(z)}upgrade(z,H,Q){return this.adapter.upgrade(z,H,Q).then(()=>{return Promise.resolve(this)})}rename(z){return this.adapter.rename(z)}onCreate(z){this.callbacks.create.push(z)}onUpdate(z){this.callbacks.update.push(z)}onDelete(z){this.callbacks.delete.push(z)}addTransformation({id:z,get:H,set:Q}){this.transformations[z]={id:z,get:H,set:Q}}removeTransformation(z){delete this.transformations[z]}key(z,H=!1){return this.adapter.key(z,H)}keys(z=!1){return this.adapter.keys(z)}remove(z){return this.adapter.remove(z).then((H)=>{for(let Q of this.callbacks.delete)Q.call(null,z,H)})}clear(){return this.adapter.clear()}}class x{static capitalize(z){return z.replace(/\w\S*/g,(H)=>{return H.charAt(0).toUpperCase()+H.substring(1).toLowerCase()})}static suffix(z,H){let Q="",X=H.indexOf(z);if(X!==-1)X+=z.length,Q=H.substring(X);return Q}static selection(){let z=window.getSelection();if(z)return z.toString();return""}static prefix(z,H){let Q="",X=H.indexOf(z);if(X!==-1)Q=H.substring(0,X);return Q}static friendly(z){let H=[/[áàâãªä]/g,/[ÁÀÂÃÄ]/g,/[ÍÌÎÏ]/g,/[íìîï]/g,/[éèêë]/g,/[ÉÈÊË]/g,/[óòôõºö]/g,/[ÓÒÔÕÖ]/g,/[úùûü]/g,/[ÚÙÛÜ]/g,/ç/g,/Ç/g,/ñ/g,/Ñ/g,/_/g,/[''‹›<>']/g,/[""«»„"]/g,/[(){}[\]]/g,/[?¿!¡#$%&^*´`~/°|]/g,/[,.:;]/g,/ /g],Q=["a","A","I","i","e","E","o","O","u","U","c","C","n","N","-","","","","","","-"],X=z;for(let Y=0;Y<H.length;Y++)X=X.replace(H[Y],Q[Y]);return X}}class V{static callAsync(z,H,...Q){try{let X=z.apply(H,Q);if(X instanceof Promise)return X;else return Promise.resolve(X)}catch(X){return Promise.reject(X)}}static uuid(){if(typeof crypto<"u"&&crypto.getRandomValues)return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(z)=>{let H=parseInt(z,10);return(H^crypto.getRandomValues(new Uint8Array(1))[0]&15>>H/4).toString(16)});else{let z=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return z()+z()+"-"+z()+"-"+z()+"-"+z()+"-"+z()+z()+z()}}}export{V as Util,x as Text,O as SpaceAdapter,j as Space,P as SessionStorage,G as Request,E as RemoteStorage,R as Preload,C as Platform,I as LocalStorage,U as IndexedDB,q as Form,w as FileSystem,M as DebugLevel,T as Debug,$ as DOM,D as $_ready,A as $_};
|
|
2
|
+
|
|
3
|
+
//# debugId=107A87F78AE89FB864756E2164756E21
|
|
2
4
|
//# sourceMappingURL=artemis.js.map
|