wraplet 0.43.0 → 0.45.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AbstractWraplet:()=>Y,ChildrenAreAlreadyDestroyedError:()=>l,ChildrenAreNotAvailableError:()=>n,ChildrenTooManyFoundError:()=>o,DefaultArgCreator:()=>G,DefaultCore:()=>A,DefaultWrapletSet:()=>C,DefaultWrapletSetReadonly:()=>V,InternalLogicError:()=>d,MapError:()=>i,MapRepeat:()=>U,MissingRequiredChildError:()=>r,RequiredChildDestroyedError:()=>s,StorageValidationError:()=>a,UnsupportedNodeTypeError:()=>h,createDefaultDestroyCallback:()=>R,createDefaultInitializeCallback:()=>k,createRichWrapletApi:()=>F,createWrapletApi:()=>_,customizeDefaultWrapletApi:()=>B,defaultWrapletCreator:()=>O,destroyWrapletsRecursively:()=>v,destructionCompleted:()=>q,destructionStarted:()=>T,getWrapletsFromNode:()=>g,initializationCompleted:()=>$,initializationStarted:()=>P,isWraplet:()=>N});class r extends Error{}class i extends Error{}class s extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}class d extends Error{}class h extends Error{}function c(t){return Object.getPrototypeOf(t)===Object.prototype}const u=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],p=Symbol("WrapletSet");function f(t){return u(t,p)}class y extends Set{find(t){const e=[];for(const r of this)t(r)&&e.push(r);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,r)=>t(e)-t(r))}}const w=Symbol("WrapletSetReadonly");class C extends y{[w]=!0;[p]=!0}function g(t){const e=t.wraplets;return f(e)&&0!==e.size?e:new C}function m(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function b(t,e){await e(t);const r=t.childNodes;for(const t of r)await b(t,e)}async function v(t){await b(t,async t=>{const e=g(t);for(const r of e)r.wraplet.status.isGettingDestroyed||r.wraplet.status.isDestroyed||await r.wraplet.destroy(),m(r,t)})}const W=Symbol("Core"),I=Symbol("NodeTreeParent");function E(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function D(t){const e={};for(const r in t){const i=t[r];e[r]=E(i);const s=i.map;s&&c(s)&&(e[r].map=D(s))}return e}const M=Symbol("DynamicMap");function z(t){return u(t,M)}class S{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],r=!0){this.path=e,this.startingPath=e,this.fullMap=D(t),r&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const r of t){if(!e[r])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const i=e[r].map;if(c(i))e=i;else{if(!z(i))throw new Error("Invalid map type.");e=i.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const r of t){if(!Object.hasOwn(e,r))return!1;const t=e[r].map;if(z(t))return!0;if(!c(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new S(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const L=Symbol("ArgCreator");function O(t,e){const r=new e(t.element,t.map,t.initOptions);return new t.Class(r,...t.args)}class A{node;[W]=!0;[I]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=O;constructor(t,e,r={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(c(e))this.mapWrapper=new S(e);else{if(!(e instanceof S))throw new i("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(r),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?f(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const r=this.map[e],i=r.multiple,s=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,r),t[e]=i?this.instantiateMultipleWrapletsChild(r,s,this.node,e):this.instantiateSingleWrapletChild(r,s,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(f(e))for(const r of e)t.push(r);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const r=this.instantiatedChildren[t];if(this.map[t].multiple){if(!f(r))throw new d("Internal logic error. Expected a WrapletSet.");const t=r.find(t=>{let r=!1;return t.wraplet.accessNode(t=>{t===e&&(r=!0)}),r});if(0===t.length)return null;if(t.length>1)throw new d("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return r}instantiateSingleWrapletChild(t,e,r,i){if(!t.selector)return null;const s=t.selector,n=this.findChildren(s,r);if(this.validateElements(i,n,t),0===n.length)return null;if(n.length>1)throw new o(`${this.constructor.name}: More than one element was found for the "${i}" child. Selector used: "${s}".`);const a=n[0];return this.instantiateWrapletItem(i,t,e,a)}instantiateWrapletItem(t,e,r,i){const s=this.findExistingWraplet(t,i);if(s)return s;const n={id:t,Class:e.Class,element:i,map:r,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>u(t,L)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(r){if(r instanceof h&&!e.required)return console.warn(`${r.message} Skipping instantiation of the "${t}" child.`),null;throw r}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,r,i){const s=t.selector;if(!s)return new C;const n=this.findChildren(s,r);this.validateElements(i,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[i]?this.instantiatedChildren[i]:new C;for(const r of n){if(this.findExistingWraplet(i,r))continue;const s=this.instantiateWrapletItem(i,t,e,r);s&&a.add(s)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const r of this.destroyChildListeners)r(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new l("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,r=t.eventName,i=t.callback,s=t.options;e.removeEventListener(r,i,s)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,r,i){this.listeners.push({node:t,eventName:e,callback:r,options:i}),t.addEventListener(e,r,i)}get children(){if(!this.childrenAreInstantiated)throw new n("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(f(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new d("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new s("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new d("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,e){const r=e.selector,s=e.required;if(!r&&s)throw new i(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,e){if(e.required)throw new i(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(t,e,i){if(0===e.length&&i.required)throw new r(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${i.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(f(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class G{creator;[L]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new G(t)}}const x=Symbol("Wraplet");function N(t){return u(t,x)}const j=Symbol("Groupable");async function P(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function T(t,e,r,i){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of i)await t(r);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function k(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const r=t.status||this.status;await P(r,t.core)&&(e&&await e(),await $(r,t.destroyCallback))}}function R(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const r=t.status||this.status;await T(r,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(r))}}const _=t=>{const e=[],r={},i=t.destroyListeners||[],s=t.destroyCallback||R({core:t.core,wraplet:t.wraplet,destroyListeners:i}).bind(r);r.destroy=s;const n=t.initializeCallback||k({core:t.core,destroyCallback:r.destroy}).bind(r);return Object.assign(r,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{i.push(t)},initialize:n,destroy:s,accessNode:r=>{e.push(r),r(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign(_(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class Y{core;[x]=!0;[j]=!0;[I]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!u(t,W))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.includes(t.node.constructor))throw new h(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,r=null){return e===(r||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new A(t,e)}static createWraplets(t,e,r,i=[]){if(this===Y)throw new Error("You cannot instantiate an abstract class.");const s=[];if(t instanceof Element&&t.hasAttribute(r)){const r=this.createCore(t,e);s.push(new this(r,...i))}const n=t.querySelectorAll(`[${r}]`);for(const t of n){const r=this.createCore(t,e);s.push(new this(r,...i))}return s}}class U{levels;[M]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error("There have to be more than 0 repeated levels.")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new U(t)}}class V extends y{[w]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}var H=exports;for(var J in e)H[J]=e[J];e.__esModule&&Object.defineProperty(H,"__esModule",{value:!0});
|
|
1
|
+
var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AbstractWraplet:()=>Y,ChildrenAreAlreadyDestroyedError:()=>l,ChildrenAreNotAvailableError:()=>n,ChildrenTooManyFoundError:()=>o,DefaultArgCreator:()=>G,DefaultCore:()=>A,DefaultWrapletSet:()=>C,DefaultWrapletSetReadonly:()=>V,InternalLogicError:()=>d,MapError:()=>i,MapRepeat:()=>U,MissingRequiredChildError:()=>r,RequiredChildDestroyedError:()=>s,StorageValidationError:()=>a,UnsupportedNodeTypeError:()=>h,WrapletSymbol:()=>x,createDefaultDestroyCallback:()=>R,createDefaultInitializeCallback:()=>k,createRichWrapletApi:()=>F,createWrapletApi:()=>_,customizeDefaultWrapletApi:()=>B,defaultWrapletCreator:()=>O,destroyWrapletsRecursively:()=>v,destructionCompleted:()=>q,destructionStarted:()=>T,getWrapletsFromNode:()=>g,initializationCompleted:()=>$,initializationStarted:()=>P,isWraplet:()=>N});class r extends Error{}class i extends Error{}class s extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}class d extends Error{}class h extends Error{}function c(t){return Object.getPrototypeOf(t)===Object.prototype}const u=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],p=Symbol("WrapletSet");function f(t){return u(t,p)}class y extends Set{find(t){const e=[];for(const r of this)t(r)&&e.push(r);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,r)=>t(e)-t(r))}}const w=Symbol("WrapletSetReadonly");class C extends y{[w]=!0;[p]=!0}function g(t){const e=t.wraplets;return f(e)&&0!==e.size?e:new C}function m(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function b(t,e){await e(t);const r=t.childNodes;for(const t of r)await b(t,e)}async function v(t){await b(t,async t=>{const e=g(t);for(const r of e)r.wraplet.status.isGettingDestroyed||r.wraplet.status.isDestroyed||await r.wraplet.destroy(),m(r,t)})}const W=Symbol("Core"),I=Symbol("NodeTreeParent");function E(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function D(t){const e={};for(const r in t){const i=t[r];e[r]=E(i);const s=i.map;s&&c(s)&&(e[r].map=D(s))}return e}const M=Symbol("DynamicMap");function z(t){return u(t,M)}class S{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],r=!0){this.path=e,this.startingPath=e,this.fullMap=D(t),r&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const r of t){if(!e[r])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const i=e[r].map;if(c(i))e=i;else{if(!z(i))throw new Error("Invalid map type.");e=i.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const r of t){if(!Object.hasOwn(e,r))return!1;const t=e[r].map;if(z(t))return!0;if(!c(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new S(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const L=Symbol("ArgCreator");function O(t,e){const r=new e(t.element,t.map,t.initOptions);return new t.Class(r,...t.args)}class A{node;[W]=!0;[I]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=O;constructor(t,e,r={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(c(e))this.mapWrapper=new S(e);else{if(!(e instanceof S))throw new i("The map provided to the Core is not a valid map.");this.mapWrapper=e}this.processInitOptions(r),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?f(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const r=this.map[e],i=r.multiple,s=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,r),t[e]=i?this.instantiateMultipleWrapletsChild(r,s,this.node,e):this.instantiateSingleWrapletChild(r,s,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(f(e))for(const r of e)t.push(r);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const r=this.instantiatedChildren[t];if(this.map[t].multiple){if(!f(r))throw new d("Internal logic error. Expected a WrapletSet.");const t=r.find(t=>{let r=!1;return t.wraplet.accessNode(t=>{t===e&&(r=!0)}),r});if(0===t.length)return null;if(t.length>1)throw new d("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return r}instantiateSingleWrapletChild(t,e,r,i){if(!t.selector)return null;const s=t.selector,n=this.findChildren(s,r);if(this.validateElements(i,n,t),0===n.length)return null;if(n.length>1)throw new o(`${this.constructor.name}: More than one element was found for the "${i}" child. Selector used: "${s}".`);const a=n[0];return this.instantiateWrapletItem(i,t,e,a)}instantiateWrapletItem(t,e,r,i){const s=this.findExistingWraplet(t,i);if(s)return s;const n={id:t,Class:e.Class,element:i,map:r,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>u(t,L)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(r){if(r instanceof h&&!e.required)return console.warn(`${r.message} Skipping instantiation of the "${t}" child.`),null;throw r}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,r,i){const s=t.selector;if(!s)return new C;const n=this.findChildren(s,r);this.validateElements(i,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[i]?this.instantiatedChildren[i]:new C;for(const r of n){if(this.findExistingWraplet(i,r))continue;const s=this.instantiateWrapletItem(i,t,e,r);s&&a.add(s)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const r of this.destroyChildListeners)r(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new l("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,r=t.eventName,i=t.callback,s=t.options;e.removeEventListener(r,i,s)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,r,i){this.listeners.push({node:t,eventName:e,callback:r,options:i}),t.addEventListener(e,r,i)}get children(){if(!this.childrenAreInstantiated)throw new n("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(f(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new d("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new s("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new d("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,e){const r=e.selector,s=e.required;if(!r&&s)throw new i(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,e){if(e.required)throw new i(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(t,e,i){if(0===e.length&&i.required)throw new r(`${this.constructor.name}: Couldn't find a node for the wraplet "${t}". Selector used: "${i.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(f(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class G{creator;[L]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new G(t)}}const x=Symbol("Wraplet");function N(t){return u(t,x)}const j=Symbol("Groupable");async function P(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function T(t,e,r,i){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of i)await t(r);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function k(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const r=t.status||this.status;await P(r,t.core)&&(e&&await e(),await $(r,t.destroyCallback))}}function R(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const r=t.status||this.status;await T(r,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(r))}}const _=t=>{const e=[],r={},i=t.destroyListeners||[],s=t.destroyCallback||R({core:t.core,wraplet:t.wraplet,destroyListeners:i}).bind(r);r.destroy=s;const n=t.initializeCallback||k({core:t.core,destroyCallback:r.destroy}).bind(r);return Object.assign(r,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{i.push(t)},initialize:n,destroy:s,accessNode:r=>{e.push(r),r(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign(_(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class Y{core;[x]=!0;[j]=!0;[I]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!u(t,W))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new h(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,r=null){return e===(r||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new A(t,e)}static createWraplets(t,e,r,i=[]){if(this===Y)throw new Error("You cannot instantiate an abstract class.");const s=[];if(t instanceof Element&&t.hasAttribute(r)){const r=this.createCore(t,e);s.push(new this(r,...i))}const n=t.querySelectorAll(`[${r}]`);for(const t of n){const r=this.createCore(t,e);s.push(new this(r,...i))}return s}}class U{levels;[M]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error("There have to be more than 0 repeated levels.")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new U(t)}}class V extends y{[w]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}var H=exports;for(var J in e)H[J]=e[J];e.__esModule&&Object.defineProperty(H,"__esModule",{value:!0});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,8xBCLhD,MAAMC,UAAkCC,OAExC,MAAMC,UAAiBD,OAEvB,MAAME,UAAoCF,OAE1C,MAAMG,UAAqCH,OAE3C,MAAMI,UAA+BJ,OAErC,MAAMK,UAAkCL,OAExC,MAAMM,UAAyCN,OAE/C,MAAMO,UAA2BP,OAEjC,MAAMQ,UAAiCR,OChBvC,SAASS,EAAiCC,GAC7C,OAAOvB,OAAOwB,eAAeD,KAAYvB,OAAOM,SACpD,CCCA,MAAM,EAAK,CAACiB,EAAQE,IACU,iBAAXF,GACA,OAAXA,IACm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EAAS,EACT,MAAM,IAAI/N,MAAM,gDAExB,CACA,MAAA8E,CAAOkJ,GACH,IAAK,IAAIC,EAAI,EAAGA,EAAI5M,KAAK0M,OAAQE,IAC7BD,EAAe5I,OAEnB,OAAO4I,EAAevJ,eAC1B,CACA,aAAOK,CAAOiJ,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkCnN,EAC3C,CAACgB,IAA4B,ECH1B,SAASoM,EAA2B/K,EAAMgL,GAC7C,IAAKhL,EAAKP,SAAWO,EAAKJ,SAAWI,EAAK6D,YACtC,MAAM,IAAIjH,MAAM,+HAGpB,OAAOb,OAAOyL,OAAOwD,EAAYhL,EACrC,C","sources":["webpack://wraplet/webpack/bootstrap","webpack://wraplet/webpack/runtime/define property getters","webpack://wraplet/webpack/runtime/hasOwnProperty shorthand","webpack://wraplet/webpack/runtime/make namespace object","webpack://wraplet/./src/errors.ts","webpack://wraplet/./src/Wraplet/types/WrapletChildrenMap.ts","webpack://wraplet/./src/utils/is.ts","webpack://wraplet/./src/Set/types/WrapletSet.ts","webpack://wraplet/./src/Set/DefaultSearchableSet.ts","webpack://wraplet/./src/Set/types/WrapletSetReadonly.ts","webpack://wraplet/./src/Set/DefaultWrapletSet.ts","webpack://wraplet/./src/NodeTreeManager/utils.ts","webpack://wraplet/./src/Core/types/Core.ts","webpack://wraplet/./src/NodeTreeManager/types/NodeTreeParent.ts","webpack://wraplet/./src/Map/utils.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/Core/types/ArgCreator.ts","webpack://wraplet/./src/Core/defaultWrapletCreator.ts","webpack://wraplet/./src/Core/DefaultCore.ts","webpack://wraplet/./src/Core/DefaultArgCreator.ts","webpack://wraplet/./src/Wraplet/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/Wraplet/statusActions.ts","webpack://wraplet/./src/Wraplet/createDefaultInitializeCallback.ts","webpack://wraplet/./src/Wraplet/createDefaultDestroyCallback.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Wraplet/createRichWrapletApi.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.ts","webpack://wraplet/./src/Wraplet/customizeDefaultWrapletApi.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export class MissingRequiredChildError extends Error {\n}\nexport class MapError extends Error {\n}\nexport class RequiredChildDestroyedError extends Error {\n}\nexport class ChildrenAreNotAvailableError extends Error {\n}\nexport class StorageValidationError extends Error {\n}\nexport class ChildrenTooManyFoundError extends Error {\n}\nexport class ChildrenAreAlreadyDestroyedError extends Error {\n}\nexport class InternalLogicError extends Error {\n}\nexport class UnsupportedNodeTypeError extends Error {\n}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/**\n * Generic guard.\n */\nconst is = (object, symbol) => {\n return (typeof object === \"object\" &&\n object !== null &&\n object[symbol] === true);\n};\nexport { is };\n","import { is } from \"../../utils/is\";\nconst WrapletSetSymbol = Symbol(\"WrapletSet\");\nexport { WrapletSetSymbol };\nexport function isWrapletSet(object) {\n return is(object, WrapletSetSymbol);\n}\n","export class DefaultSearchableSet extends Set {\n find(filter) {\n const results = [];\n for (const item of this) {\n if (!filter(item)) {\n continue;\n }\n results.push(item);\n }\n return results;\n }\n findOne(filter) {\n for (const item of this) {\n if (filter(item)) {\n return item;\n }\n }\n return null;\n }\n getOrdered(callback) {\n return Array.from(this).sort((a, b) => callback(a) - callback(b));\n }\n}\n","const WrapletSetReadonlySymbol = Symbol(\"WrapletSetReadonly\");\nexport { WrapletSetReadonlySymbol };\n","import { WrapletSetSymbol } from \"./types/WrapletSet\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nimport { WrapletSetReadonlySymbol } from \"./types/WrapletSetReadonly\";\nexport class DefaultWrapletSet extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n [WrapletSetSymbol] = true;\n}\n","import { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nexport function isParentNode(node) {\n return (typeof node.querySelectorAll ===\n \"function\");\n}\nexport function getWrapletsFromNode(node) {\n const wraplets = node.wraplets;\n if (!isWrapletSet(wraplets) || wraplets.size === 0) {\n return new DefaultWrapletSet();\n }\n return wraplets;\n}\nexport function removeWrapletFromNode(wraplet, node) {\n if (!node.wraplets) {\n return false;\n }\n return node.wraplets.delete(wraplet);\n}\nexport function addWrapletToNode(wraplet, node) {\n if (!node.wraplets) {\n node.wraplets = new DefaultWrapletSet();\n }\n node.wraplets.add(wraplet);\n}\nexport async function actOnNodesRecursively(node, callback) {\n await callback(node);\n const children = node.childNodes;\n for (const child of children) {\n await actOnNodesRecursively(child, callback);\n }\n}\nexport async function destroyWrapletsRecursively(node) {\n await actOnNodesRecursively(node, async (node) => {\n const wraplets = getWrapletsFromNode(node);\n for (const wraplet of wraplets) {\n if (!wraplet.wraplet.status.isGettingDestroyed &&\n !wraplet.wraplet.status.isDestroyed) {\n await wraplet.wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","import { is } from \"../../utils/is\";\nconst CoreSymbol = Symbol(\"Core\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nexport function addDefaultsToChildDefinition(definition) {\n return {\n ...{\n args: [],\n destructible: true,\n map: {},\n coreOptions: {},\n },\n ...definition,\n };\n}\nexport function fillMapWithDefaults(map) {\n const newMap = {};\n for (const id in map) {\n const def = map[id];\n newMap[id] = addDefaultsToChildDefinition(def);\n const subMap = def[\"map\"];\n if (subMap && isWrapletChildrenMapWithDefaults(subMap)) {\n newMap[id][\"map\"] = fillMapWithDefaults(subMap);\n }\n }\n return newMap;\n}\n","import { is } from \"../../utils/is\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"./utils\";\nimport { isDynamicMap } from \"./types/DynamicMap\";\nexport class MapWrapper {\n fullMap;\n startingPath;\n currentMap = null;\n path;\n currentPath = [];\n /**\n * @param fullMap\n * @param path\n * Path to the current definition.\n * @param resolveImmediately\n */\n constructor(fullMap, path = [], resolveImmediately = true) {\n this.path = path;\n this.startingPath = path;\n this.fullMap = fillMapWithDefaults(fullMap);\n if (resolveImmediately) {\n this.currentMap = this.resolve(this.path);\n }\n }\n getStartingMap() {\n return this.resolve(this.startingPath);\n }\n getCurrentMap() {\n if (!this.currentMap || this.currentPath != this.path) {\n this.currentMap = this.resolve(this.path);\n this.currentPath = this.path;\n }\n return this.currentMap;\n }\n /**\n * @param path\n * @private\n */\n findMap(path) {\n let resultMap = this.fullMap;\n for (const pathPart of path) {\n if (!resultMap[pathPart]) {\n throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);\n }\n const map = resultMap[pathPart][\"map\"];\n if (isWrapletChildrenMapWithDefaults(map)) {\n resultMap = map;\n }\n else if (isDynamicMap(map)) {\n resultMap = map.create(this.clone(path, false));\n }\n else {\n throw new Error(\"Invalid map type.\");\n }\n }\n return resultMap;\n }\n up(pathPart, resolve = true) {\n if (!this.pathExists([...this.path, pathPart])) {\n throw new Error(\"Map doesn't exist.\");\n }\n this.path.push(pathPart);\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n pathExists(path) {\n let tempMap = this.fullMap;\n for (const pathPart of path) {\n if (!Object.hasOwn(tempMap, pathPart)) {\n return false;\n }\n const map = tempMap[pathPart][\"map\"];\n if (isDynamicMap(map)) {\n return true;\n }\n if (!isWrapletChildrenMapWithDefaults(map)) {\n throw new Error(\"Invalid map type.\");\n }\n tempMap = map;\n }\n return true;\n }\n down(resolve = true) {\n if (this.path.length === 0) {\n throw new Error(\"At the root already.\");\n }\n this.path.pop();\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n clone(path, resolveImmediately = true) {\n return new MapWrapper(this.fullMap, path, resolveImmediately);\n }\n resolve(path) {\n return this.findMap(path);\n }\n}\n","import { is } from \"../../utils/is\";\nconst ArgCreatorSymbol = Symbol(\"ArgCreator\");\nexport { ArgCreatorSymbol };\nexport function isArgCreator(object) {\n return is(object, ArgCreatorSymbol);\n}\n","export function defaultWrapletCreator(args, currentCoreClass) {\n const core = new currentCoreClass(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n}\n","import { ChildrenAreAlreadyDestroyedError, ChildrenAreNotAvailableError, ChildrenTooManyFoundError, InternalLogicError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, UnsupportedNodeTypeError, } from \"../errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { isParentNode } from \"../NodeTreeManager/utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"../NodeTreeManager/types/NodeTreeParent\";\nimport { MapWrapper } from \"../Map/MapWrapper\";\nimport { isArgCreator } from \"./types/ArgCreator\";\nimport { defaultWrapletCreator } from \"./defaultWrapletCreator\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n childrenAreInstantiated = false;\n statusWritable = {\n isDestroyed: false,\n isGettingDestroyed: false,\n isInitialized: false,\n isGettingInitialized: false,\n };\n get status() {\n return this.statusWritable;\n }\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n wrapletCreator = defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\n if (!(node instanceof Node)) {\n throw new Error(\"The node provided to the Core is not a valid node.\");\n }\n if (isWrapletChildrenMapWithDefaults(map)) {\n this.mapWrapper = new MapWrapper(map);\n }\n else if (map instanceof MapWrapper) {\n this.mapWrapper = map;\n }\n else {\n throw new MapError(\"The map provided to the Core is not a valid map.\");\n }\n this.processInitOptions(initOptions);\n this.instantiatedChildren = {};\n }\n /**\n * Initialize core.\n *\n * We couldn't put this step in the constructor, because during initialization some wraplet\n * processing occurs (instantiate child listeners) that needs access to the children manager,\n * so the children manager has to exist already.\n */\n async initializeChildren() {\n this.statusWritable.isGettingInitialized = true;\n const childInstances = Object.values(this.instantiatedChildren).flatMap((child) => {\n if (!child)\n return [];\n return isWrapletSet(child) ? Array.from(child) : [child];\n });\n await Promise.all(childInstances.map((child) => child.wraplet.initialize()));\n this.statusWritable.isInitialized = true;\n this.statusWritable.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.statusWritable.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get map() {\n return this.mapWrapper.getStartingMap();\n }\n instantiateChildren() {\n const children = this.instantiatedChildren;\n // We check if are dealing with the ParentNode object.\n if (!isParentNode(this.node)) {\n for (const id in this.map) {\n const childDefinition = this.map[id];\n this.validateMapItemForNonParent(id, childDefinition);\n }\n return;\n }\n for (const id in this.map) {\n const childDefinition = this.map[id];\n const multiple = childDefinition.multiple;\n const mapWrapper = this.mapWrapper.clone([...this.mapWrapper.path, id]);\n this.validateMapItem(id, childDefinition);\n if (multiple) {\n // We can assert as much because items\n children[id] = this.instantiateMultipleWrapletsChild(childDefinition, mapWrapper, this.node, id);\n continue;\n }\n children[id] = this.instantiateSingleWrapletChild(childDefinition, mapWrapper, this.node, id);\n }\n if (!this.childrenAreInstantiated) {\n this.instantiatedChildren = this.wrapChildren(children);\n this.childrenAreInstantiated = true;\n }\n }\n async syncChildren() {\n this.instantiateChildren();\n await this.initializeChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\n if (child === null) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n children.push(item);\n }\n }\n else {\n children.push(child);\n }\n }\n // Return only descendants.\n return children.filter((child) => {\n let result = false;\n child.wraplet.accessNode((childsNode) => {\n result = this.node.contains(childsNode);\n });\n return result;\n });\n }\n findExistingWraplet(id, childElement) {\n // If a child doesn't have instantiated wraplets yet, then return null.\n if (this.instantiatedChildren === undefined ||\n !this.instantiatedChildren[id]) {\n return null;\n }\n const existingChild = this.instantiatedChildren[id];\n // Handle multiple.\n if (this.map[id][\"multiple\"]) {\n if (!isWrapletSet(existingChild)) {\n throw new InternalLogicError(\"Internal logic error. Expected a WrapletSet.\");\n }\n const existingWraplets = existingChild.find((wraplet) => {\n let result = false;\n wraplet.wraplet.accessNode((node) => {\n if (node === childElement) {\n result = true;\n }\n });\n return result;\n });\n if (existingWraplets.length === 0) {\n return null;\n }\n if (existingWraplets.length > 1) {\n throw new InternalLogicError(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");\n }\n return existingWraplets[0];\n }\n // Handle single.\n return existingChild;\n }\n instantiateSingleWrapletChild(childDefinition, childMap, node, id) {\n if (!childDefinition.selector) {\n return null;\n }\n const selector = childDefinition.selector;\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n if (childElements.length === 0) {\n return null;\n }\n if (childElements.length > 1) {\n throw new ChildrenTooManyFoundError(`${this.constructor.name}: More than one element was found for the \"${id}\" child. Selector used: \"${selector}\".`);\n }\n const childElement = childElements[0];\n return this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n }\n instantiateWrapletItem(id, childDefinition, childMap, node) {\n // Re-use existing wraplet.\n const existingWraplet = this.findExistingWraplet(id, node);\n if (existingWraplet) {\n return existingWraplet;\n }\n const wrapletClass = childDefinition.Class;\n const creatorArgs = {\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: childDefinition.args,\n };\n creatorArgs.args = creatorArgs.args.map((arg) => {\n if (isArgCreator(arg)) {\n return arg.createArg(creatorArgs);\n }\n return arg;\n });\n let wraplet = null;\n try {\n wraplet = this.wrapletCreator(creatorArgs, this.constructor);\n }\n catch (e) {\n if (e instanceof UnsupportedNodeTypeError) {\n if (!childDefinition.required) {\n console.warn(`${e.message} Skipping instantiation of the \"${id}\" child.`);\n return null;\n }\n }\n throw e;\n }\n this.prepareIndividualWraplet(id, wraplet);\n for (const listener of this.instantiateChildListeners) {\n listener(wraplet, id);\n }\n return wraplet;\n }\n instantiateMultipleWrapletsChild(childDefinition, childMap, node, id) {\n const selector = childDefinition.selector;\n if (!selector) {\n return new DefaultWrapletSet();\n }\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n const items = this.instantiatedChildren && this.instantiatedChildren[id]\n ? this.instantiatedChildren[id]\n : new DefaultWrapletSet();\n for (const childElement of childElements) {\n const existingWraplet = this.findExistingWraplet(id, childElement);\n if (existingWraplet) {\n continue;\n }\n const wraplet = this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n if (wraplet) {\n items.add(wraplet);\n }\n }\n return items;\n }\n addDestroyChildListener(callback) {\n this.destroyChildListeners.push(callback);\n }\n addInstantiateChildListener(callback) {\n this.instantiateChildListeners.push(callback);\n }\n setWrapletCreator(wrapletCreator) {\n this.wrapletCreator = wrapletCreator;\n }\n prepareIndividualWraplet(id, wraplet) {\n const destroyListener = ((wraplet) => {\n this.removeChild(wraplet, id);\n for (const listener of this.destroyChildListeners) {\n listener(wraplet, id);\n }\n });\n // Listen for the child's destruction.\n wraplet.wraplet.addDestroyListener(destroyListener);\n }\n /**\n * This method removes from nodes references to this wraplet and its children recursively.\n */\n async destroy() {\n if (this.statusWritable.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.statusWritable.isGettingDestroyed = true;\n if (this.statusWritable.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return;\n }\n if (!this.statusWritable.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n return;\n }\n // Remove listeners.\n for (const listener of this.listeners) {\n const node = listener.node;\n const eventName = listener.eventName;\n const callback = listener.callback;\n const options = listener.options;\n node.removeEventListener(eventName, callback, options);\n }\n this.listeners.length = 0;\n await this.destroyChildren();\n this.statusWritable.isInitialized = false;\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n }\n findChildren(selector, node) {\n const defaultSelectorCallback = (selector, node) => {\n return Array.from(node.querySelectorAll(selector));\n };\n // Find children elements based on the map.\n return typeof selector === \"string\"\n ? defaultSelectorCallback(selector, node)\n : selector(node);\n }\n addEventListener(node, eventName, callback, options) {\n this.listeners.push({ node, eventName, callback, options });\n node.addEventListener(eventName, callback, options);\n }\n get children() {\n if (!this.childrenAreInstantiated) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");\n }\n return this.instantiatedChildren;\n }\n removeChild(wraplet, id) {\n if (isWrapletSet(this.instantiatedChildren[id])) {\n if (!this.instantiatedChildren[id].delete(wraplet)) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\");\n }\n return;\n }\n if (this.map[id].required && !this.statusWritable.isGettingDestroyed) {\n throw new RequiredChildDestroyedError(\"Required child has been destroyed.\");\n }\n if (this.instantiatedChildren[id] === null) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");\n }\n // @ts-expect-error The type is unknown because we are dealing with a generic here.\n this.instantiatedChildren[id] = null;\n }\n validateMapItem(id, item) {\n const selector = item.selector;\n const isRequired = item.required;\n if (!selector) {\n if (isRequired) {\n throw new MapError(`${this.constructor.name}: Child \"${id}\" cannot at the same be required and have no selector.`);\n }\n }\n }\n validateMapItemForNonParent(id, item) {\n if (item.required) {\n throw new MapError(`Dependency \"${id}\" error: If the node provided cannot have children, there should be no required children.`);\n }\n }\n validateElements(id, elements, mapItem) {\n if (elements.length === 0 && mapItem.required) {\n throw new MissingRequiredChildError(`${this.constructor.name}: Couldn't find a node for the wraplet \"${id}\". Selector used: \"${mapItem.selector}\".`);\n }\n }\n /**\n * Set up a proxy to check if children have not been destroyed before fetching them.\n */\n wrapChildren(children) {\n return new Proxy(children, {\n get: function get(target, name) {\n if (!(name in target)) {\n throw new Error(`Child '${name}' has not been found.`);\n }\n return target[name];\n },\n });\n }\n defaultInitOptions() {\n return {\n instantiateChildListeners: [],\n destroyChildListeners: [],\n };\n }\n processInitOptions(initOptionsPartial) {\n const initOptions = Object.assign(this.defaultInitOptions(), initOptionsPartial);\n for (const listener of initOptions.instantiateChildListeners) {\n this.instantiateChildListeners.push(listener);\n }\n for (const listener of initOptions.destroyChildListeners) {\n this.destroyChildListeners.push(listener);\n }\n }\n async destroyChildren() {\n for (const [key, child] of Object.entries(this.children)) {\n if (!child || !this.map[key][\"destructible\"]) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n await item.wraplet.destroy();\n }\n }\n else {\n await child.wraplet.destroy();\n }\n }\n }\n}\n","import { ArgCreatorSymbol } from \"./types/ArgCreator\";\nexport class DefaultArgCreator {\n creator;\n [ArgCreatorSymbol] = true;\n constructor(creator) {\n this.creator = creator;\n }\n createArg(args) {\n return this.creator(args);\n }\n static create(creator) {\n return new DefaultArgCreator(creator);\n }\n}\n","import { is } from \"../../utils/is\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"../utils/is\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","export async function initializationStarted(status, core) {\n if (status.isInitialized) {\n return false;\n }\n status.isGettingInitialized = true;\n await core.initializeChildren();\n return true;\n}\nexport async function initializationCompleted(status, destroyMethod) {\n status.isInitialized = true;\n status.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (status.isGettingDestroyed) {\n await destroyMethod();\n }\n}\nexport async function destructionStarted(status, core, wraplet, destroyListeners) {\n if (status.isDestroyed) {\n return false;\n }\n status.isGettingDestroyed = true;\n if (status.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return false;\n }\n if (!status.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n status.isDestroyed = true;\n status.isGettingDestroyed = false;\n return false;\n }\n await core.destroy();\n for (const listener of destroyListeners) {\n await listener(wraplet);\n }\n return true;\n}\nexport async function destructionCompleted(status) {\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n}\n","import { initializationCompleted, initializationStarted, } from \"../Wraplet/statusActions\";\n/**\n * Note: If status is not provided, this function will attempt to get it from \"this\".\n */\nexport function createDefaultInitializeCallback(args, customInitializeLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot initialize without status available.\");\n }\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n const outerStatus = args.status || this.status;\n if (!(await initializationStarted(outerStatus, args.core))) {\n return;\n }\n if (customInitializeLogic) {\n await customInitializeLogic();\n }\n await initializationCompleted(outerStatus, args.destroyCallback);\n };\n}\n","import { destructionCompleted, destructionStarted, } from \"../Wraplet/statusActions\";\nexport function createDefaultDestroyCallback(args, customDestroyLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot destroy without status available.\");\n }\n // @ts-expect-error Default callbacks depend on the status from the outer object for the easier usage.\n const outerStatus = args.status || this.status;\n if (!(await destructionStarted(outerStatus, args.core, args.wraplet, args.destroyListeners))) {\n return;\n }\n if (customDestroyLogic) {\n await customDestroyLogic();\n }\n await destructionCompleted(outerStatus);\n };\n}\n","import { createDefaultInitializeCallback } from \"../Wraplet/createDefaultInitializeCallback\";\nimport { createDefaultDestroyCallback } from \"../Wraplet/createDefaultDestroyCallback\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\n const api = {};\n const destroyListeners = args.destroyListeners || [];\n const destroyCallback = args.destroyCallback ||\n createDefaultDestroyCallback({\n core: args.core,\n wraplet: args.wraplet,\n destroyListeners: destroyListeners,\n }).bind(api);\n api.destroy = destroyCallback;\n const initializeCallback = args.initializeCallback ||\n createDefaultInitializeCallback({\n core: args.core,\n destroyCallback: api.destroy,\n }).bind(api);\n return Object.assign(api, {\n __nodeAccessors: nodeAccessors,\n status: {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n },\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: initializeCallback,\n destroy: destroyCallback,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\n });\n};\n","import { defaultGroupableAttribute } from \"../types/Groupable\";\nimport { createWrapletApi } from \"./createWrapletApi\";\nexport const createRichWrapletApi = (args) => {\n const defaultGroupExtractor = (node) => {\n if (node instanceof Element) {\n const groupsString = node.getAttribute(defaultGroupableAttribute);\n if (groupsString) {\n return groupsString.split(\",\");\n }\n }\n return [];\n };\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n return Object.assign(createWrapletApi(args), {\n getNodeTreeChildren: () => {\n return args.core.getNodeTreeChildren();\n },\n setGroupsExtractor: (extractor) => {\n groupExtractor = extractor;\n },\n getGroups: () => {\n return groupExtractor(args.core.node);\n },\n });\n};\n","import { WrapletSymbol } from \"./Wraplet/types/Wraplet\";\nimport { GroupableSymbol } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol, } from \"./NodeTreeManager/types/NodeTreeParent\";\nimport { isCore } from \"./Core/types/Core\";\nimport { DefaultCore } from \"./Core/DefaultCore\";\nimport { createRichWrapletApi } from \"./Wraplet/createRichWrapletApi\";\nimport { UnsupportedNodeTypeError } from \"./errors\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n destroyListeners = [];\n wraplet;\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n const supportedNodeTypes = this.supportedNodeTypes();\n if (supportedNodeTypes !== null) {\n if (!supportedNodeTypes.includes(core.node.constructor)) {\n throw new UnsupportedNodeTypeError(`Node type ${core.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);\n }\n }\n core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n core.instantiateChildren();\n this.wraplet = createRichWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n get children() {\n return this.core.children;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been destroyed.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onChildDestroy(child, id) { }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be invoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiate(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n child, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id) { }\n /**\n * Subclasses must return an array of constructors covering all types in union N.\n * Wrap the result in the `supportedTypeCheck` helper to make sure that the array contains all\n * and only classes that extend the given type.\n */\n supportedNodeTypes() {\n return null;\n }\n /**\n * Helper for subclasses to easily satisfy the exhaustive check.\n */\n supportedNodeTypesGuard(types) {\n return types;\n }\n /**\n * This method makes sure that the given instance is an instance of a class belonging to the\n * given child.\n *\n * @param item\n * @param actualUnknownId\n * @param onlyId\n * By hardcoding onlyId you can filter out any other children. It allows you to learn not only\n * that the class is correct, but also that the child is correct (in case multiple children can\n * use the same class).\n * @protected\n */\n isChildInstance(item, actualUnknownId, onlyId = null) {\n return (actualUnknownId === (onlyId || actualUnknownId) &&\n item instanceof this.core.map[actualUnknownId][\"Class\"]);\n }\n static createCore(node, map) {\n return new DefaultCore(node, map);\n }\n // We can afford \"any\" here because this method is only for the external usage, and external\n // callers don't need to know what map is the current wraplet using, as it's its internal\n // matter.\n static createWraplets(node, map, attribute, additional_args = []) {\n if (this === AbstractWraplet) {\n throw new Error(\"You cannot instantiate an abstract class.\");\n }\n const result = [];\n if (node instanceof Element && node.hasAttribute(attribute)) {\n const core = this.createCore(node, map);\n result.push(new this(core, ...additional_args));\n }\n const foundElements = node.querySelectorAll(`[${attribute}]`);\n for (const element of foundElements) {\n const core = this.createCore(element, map);\n result.push(new this(core, ...additional_args));\n }\n return result;\n }\n}\n","import { DynamicMapSymbol } from \"./types/DynamicMap\";\nexport class MapRepeat {\n levels;\n [DynamicMapSymbol] = true;\n constructor(levels = 1) {\n this.levels = levels;\n if (levels < 1) {\n throw new Error(\"There have to be more than 0 repeated levels.\");\n }\n }\n create(parentMapClone) {\n for (let i = 0; i < this.levels; i++) {\n parentMapClone.down();\n }\n return parentMapClone.getCurrentMap();\n }\n static create(levels = 1) {\n return new MapRepeat(levels);\n }\n}\n","import { WrapletSetReadonlySymbol, } from \"./types/WrapletSetReadonly\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nexport class DefaultWrapletSetReadonly extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n}\n","export function customizeDefaultWrapletApi(args, wrapletApi) {\n if (!args.status && (args.destroy || args.initialize)) {\n throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");\n }\n // We don't want to create a new object because the default callbacks are bound to the old one.\n return Object.assign(wrapletApi, args);\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","StorageValidationError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","UnsupportedNodeTypeError","isWrapletChildrenMapWithDefaults","object","getPrototypeOf","symbol","WrapletSetSymbol","isWrapletSet","DefaultSearchableSet","Set","find","filter","results","item","this","push","findOne","getOrdered","callback","Array","from","sort","a","b","WrapletSetReadonlySymbol","getWrapletsFromNode","node","wraplets","size","removeWrapletFromNode","wraplet","delete","async","actOnNodesRecursively","children","childNodes","child","destroyWrapletsRecursively","status","isGettingDestroyed","isDestroyed","destroy","CoreSymbol","NodeTreeParentSymbol","addDefaultsToChildDefinition","args","destructible","map","coreOptions","fillMapWithDefaults","newMap","id","def","subMap","DynamicMapSymbol","isDynamicMap","MapWrapper","fullMap","startingPath","currentMap","path","currentPath","constructor","resolveImmediately","resolve","getStartingMap","getCurrentMap","findMap","resultMap","pathPart","join","create","clone","up","pathExists","tempMap","hasOwn","down","length","pop","ArgCreatorSymbol","defaultWrapletCreator","currentCoreClass","core","element","initOptions","Class","DefaultCore","childrenAreInstantiated","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","childInstances","values","flatMap","Promise","all","initialize","instantiateChildren","querySelectorAll","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","e","required","console","warn","message","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","isRequired","elements","mapItem","Proxy","target","defaultInitOptions","initOptionsPartial","assign","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","initializationStarted","initializationCompleted","destroyMethod","destructionStarted","destroyListeners","destructionCompleted","createDefaultInitializeCallback","customInitializeLogic","outerStatus","destroyCallback","createDefaultDestroyCallback","customDestroyLogic","createWrapletApi","nodeAccessors","api","bind","initializeCallback","__nodeAccessors","createRichWrapletApi","groupExtractor","Element","groupsString","getAttribute","split","setGroupsExtractor","extractor","getGroups","AbstractWraplet","supportedNodeTypes","includes","onChildDestroy","onChildInstantiate","supportedNodeTypesGuard","types","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly","customizeDefaultWrapletApi","wrapletApi"],"ignoreList":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA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define property getters","webpack://wraplet/webpack/runtime/hasOwnProperty shorthand","webpack://wraplet/webpack/runtime/make namespace object","webpack://wraplet/./src/errors.ts","webpack://wraplet/./src/Wraplet/types/WrapletChildrenMap.ts","webpack://wraplet/./src/utils/is.ts","webpack://wraplet/./src/Set/types/WrapletSet.ts","webpack://wraplet/./src/Set/DefaultSearchableSet.ts","webpack://wraplet/./src/Set/types/WrapletSetReadonly.ts","webpack://wraplet/./src/Set/DefaultWrapletSet.ts","webpack://wraplet/./src/NodeTreeManager/utils.ts","webpack://wraplet/./src/Core/types/Core.ts","webpack://wraplet/./src/NodeTreeManager/types/NodeTreeParent.ts","webpack://wraplet/./src/Map/utils.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/Core/types/ArgCreator.ts","webpack://wraplet/./src/Core/defaultWrapletCreator.ts","webpack://wraplet/./src/Core/DefaultCore.ts","webpack://wraplet/./src/Core/DefaultArgCreator.ts","webpack://wraplet/./src/Wraplet/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/Wraplet/statusActions.ts","webpack://wraplet/./src/Wraplet/createDefaultInitializeCallback.ts","webpack://wraplet/./src/Wraplet/createDefaultDestroyCallback.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Wraplet/createRichWrapletApi.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.ts","webpack://wraplet/./src/Wraplet/customizeDefaultWrapletApi.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export class MissingRequiredChildError extends Error {\n}\nexport class MapError extends Error {\n}\nexport class RequiredChildDestroyedError extends Error {\n}\nexport class ChildrenAreNotAvailableError extends Error {\n}\nexport class StorageValidationError extends Error {\n}\nexport class ChildrenTooManyFoundError extends Error {\n}\nexport class ChildrenAreAlreadyDestroyedError extends Error {\n}\nexport class InternalLogicError extends Error {\n}\nexport class UnsupportedNodeTypeError extends Error {\n}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/**\n * Generic guard.\n */\nconst is = (object, symbol) => {\n return (typeof object === \"object\" &&\n object !== null &&\n object[symbol] === true);\n};\nexport { is };\n","import { is } from \"../../utils/is\";\nconst WrapletSetSymbol = Symbol(\"WrapletSet\");\nexport { WrapletSetSymbol };\nexport function isWrapletSet(object) {\n return is(object, WrapletSetSymbol);\n}\n","export class DefaultSearchableSet extends Set {\n find(filter) {\n const results = [];\n for (const item of this) {\n if (!filter(item)) {\n continue;\n }\n results.push(item);\n }\n return results;\n }\n findOne(filter) {\n for (const item of this) {\n if (filter(item)) {\n return item;\n }\n }\n return null;\n }\n getOrdered(callback) {\n return Array.from(this).sort((a, b) => callback(a) - callback(b));\n }\n}\n","const WrapletSetReadonlySymbol = Symbol(\"WrapletSetReadonly\");\nexport { WrapletSetReadonlySymbol };\n","import { WrapletSetSymbol } from \"./types/WrapletSet\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nimport { WrapletSetReadonlySymbol } from \"./types/WrapletSetReadonly\";\nexport class DefaultWrapletSet extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n [WrapletSetSymbol] = true;\n}\n","import { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nexport function isParentNode(node) {\n return (typeof node.querySelectorAll ===\n \"function\");\n}\nexport function getWrapletsFromNode(node) {\n const wraplets = node.wraplets;\n if (!isWrapletSet(wraplets) || wraplets.size === 0) {\n return new DefaultWrapletSet();\n }\n return wraplets;\n}\nexport function removeWrapletFromNode(wraplet, node) {\n if (!node.wraplets) {\n return false;\n }\n return node.wraplets.delete(wraplet);\n}\nexport function addWrapletToNode(wraplet, node) {\n if (!node.wraplets) {\n node.wraplets = new DefaultWrapletSet();\n }\n node.wraplets.add(wraplet);\n}\nexport async function actOnNodesRecursively(node, callback) {\n await callback(node);\n const children = node.childNodes;\n for (const child of children) {\n await actOnNodesRecursively(child, callback);\n }\n}\nexport async function destroyWrapletsRecursively(node) {\n await actOnNodesRecursively(node, async (node) => {\n const wraplets = getWrapletsFromNode(node);\n for (const wraplet of wraplets) {\n if (!wraplet.wraplet.status.isGettingDestroyed &&\n !wraplet.wraplet.status.isDestroyed) {\n await wraplet.wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","import { is } from \"../../utils/is\";\nconst CoreSymbol = Symbol(\"Core\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nexport function addDefaultsToChildDefinition(definition) {\n return {\n ...{\n args: [],\n destructible: true,\n map: {},\n coreOptions: {},\n },\n ...definition,\n };\n}\nexport function fillMapWithDefaults(map) {\n const newMap = {};\n for (const id in map) {\n const def = map[id];\n newMap[id] = addDefaultsToChildDefinition(def);\n const subMap = def[\"map\"];\n if (subMap && isWrapletChildrenMapWithDefaults(subMap)) {\n newMap[id][\"map\"] = fillMapWithDefaults(subMap);\n }\n }\n return newMap;\n}\n","import { is } from \"../../utils/is\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"./utils\";\nimport { isDynamicMap } from \"./types/DynamicMap\";\nexport class MapWrapper {\n fullMap;\n startingPath;\n currentMap = null;\n path;\n currentPath = [];\n /**\n * @param fullMap\n * @param path\n * Path to the current definition.\n * @param resolveImmediately\n */\n constructor(fullMap, path = [], resolveImmediately = true) {\n this.path = path;\n this.startingPath = path;\n this.fullMap = fillMapWithDefaults(fullMap);\n if (resolveImmediately) {\n this.currentMap = this.resolve(this.path);\n }\n }\n getStartingMap() {\n return this.resolve(this.startingPath);\n }\n getCurrentMap() {\n if (!this.currentMap || this.currentPath != this.path) {\n this.currentMap = this.resolve(this.path);\n this.currentPath = this.path;\n }\n return this.currentMap;\n }\n /**\n * @param path\n * @private\n */\n findMap(path) {\n let resultMap = this.fullMap;\n for (const pathPart of path) {\n if (!resultMap[pathPart]) {\n throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);\n }\n const map = resultMap[pathPart][\"map\"];\n if (isWrapletChildrenMapWithDefaults(map)) {\n resultMap = map;\n }\n else if (isDynamicMap(map)) {\n resultMap = map.create(this.clone(path, false));\n }\n else {\n throw new Error(\"Invalid map type.\");\n }\n }\n return resultMap;\n }\n up(pathPart, resolve = true) {\n if (!this.pathExists([...this.path, pathPart])) {\n throw new Error(\"Map doesn't exist.\");\n }\n this.path.push(pathPart);\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n pathExists(path) {\n let tempMap = this.fullMap;\n for (const pathPart of path) {\n if (!Object.hasOwn(tempMap, pathPart)) {\n return false;\n }\n const map = tempMap[pathPart][\"map\"];\n if (isDynamicMap(map)) {\n return true;\n }\n if (!isWrapletChildrenMapWithDefaults(map)) {\n throw new Error(\"Invalid map type.\");\n }\n tempMap = map;\n }\n return true;\n }\n down(resolve = true) {\n if (this.path.length === 0) {\n throw new Error(\"At the root already.\");\n }\n this.path.pop();\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n clone(path, resolveImmediately = true) {\n return new MapWrapper(this.fullMap, path, resolveImmediately);\n }\n resolve(path) {\n return this.findMap(path);\n }\n}\n","import { is } from \"../../utils/is\";\nconst ArgCreatorSymbol = Symbol(\"ArgCreator\");\nexport { ArgCreatorSymbol };\nexport function isArgCreator(object) {\n return is(object, ArgCreatorSymbol);\n}\n","export function defaultWrapletCreator(args, currentCoreClass) {\n const core = new currentCoreClass(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n}\n","import { ChildrenAreAlreadyDestroyedError, ChildrenAreNotAvailableError, ChildrenTooManyFoundError, InternalLogicError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, UnsupportedNodeTypeError, } from \"../errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { isParentNode } from \"../NodeTreeManager/utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"../NodeTreeManager/types/NodeTreeParent\";\nimport { MapWrapper } from \"../Map/MapWrapper\";\nimport { isArgCreator } from \"./types/ArgCreator\";\nimport { defaultWrapletCreator } from \"./defaultWrapletCreator\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n childrenAreInstantiated = false;\n statusWritable = {\n isDestroyed: false,\n isGettingDestroyed: false,\n isInitialized: false,\n isGettingInitialized: false,\n };\n get status() {\n return this.statusWritable;\n }\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n wrapletCreator = defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\n if (!(node instanceof Node)) {\n throw new Error(\"The node provided to the Core is not a valid node.\");\n }\n if (isWrapletChildrenMapWithDefaults(map)) {\n this.mapWrapper = new MapWrapper(map);\n }\n else if (map instanceof MapWrapper) {\n this.mapWrapper = map;\n }\n else {\n throw new MapError(\"The map provided to the Core is not a valid map.\");\n }\n this.processInitOptions(initOptions);\n this.instantiatedChildren = {};\n }\n /**\n * Initialize core.\n *\n * We couldn't put this step in the constructor, because during initialization some wraplet\n * processing occurs (instantiate child listeners) that needs access to the children manager,\n * so the children manager has to exist already.\n */\n async initializeChildren() {\n this.statusWritable.isGettingInitialized = true;\n const childInstances = Object.values(this.instantiatedChildren).flatMap((child) => {\n if (!child)\n return [];\n return isWrapletSet(child) ? Array.from(child) : [child];\n });\n await Promise.all(childInstances.map((child) => child.wraplet.initialize()));\n this.statusWritable.isInitialized = true;\n this.statusWritable.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.statusWritable.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get map() {\n return this.mapWrapper.getStartingMap();\n }\n instantiateChildren() {\n const children = this.instantiatedChildren;\n // We check if are dealing with the ParentNode object.\n if (!isParentNode(this.node)) {\n for (const id in this.map) {\n const childDefinition = this.map[id];\n this.validateMapItemForNonParent(id, childDefinition);\n }\n return;\n }\n for (const id in this.map) {\n const childDefinition = this.map[id];\n const multiple = childDefinition.multiple;\n const mapWrapper = this.mapWrapper.clone([...this.mapWrapper.path, id]);\n this.validateMapItem(id, childDefinition);\n if (multiple) {\n // We can assert as much because items\n children[id] = this.instantiateMultipleWrapletsChild(childDefinition, mapWrapper, this.node, id);\n continue;\n }\n children[id] = this.instantiateSingleWrapletChild(childDefinition, mapWrapper, this.node, id);\n }\n if (!this.childrenAreInstantiated) {\n this.instantiatedChildren = this.wrapChildren(children);\n this.childrenAreInstantiated = true;\n }\n }\n async syncChildren() {\n this.instantiateChildren();\n await this.initializeChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\n if (child === null) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n children.push(item);\n }\n }\n else {\n children.push(child);\n }\n }\n // Return only descendants.\n return children.filter((child) => {\n let result = false;\n child.wraplet.accessNode((childsNode) => {\n result = this.node.contains(childsNode);\n });\n return result;\n });\n }\n findExistingWraplet(id, childElement) {\n // If a child doesn't have instantiated wraplets yet, then return null.\n if (this.instantiatedChildren === undefined ||\n !this.instantiatedChildren[id]) {\n return null;\n }\n const existingChild = this.instantiatedChildren[id];\n // Handle multiple.\n if (this.map[id][\"multiple\"]) {\n if (!isWrapletSet(existingChild)) {\n throw new InternalLogicError(\"Internal logic error. Expected a WrapletSet.\");\n }\n const existingWraplets = existingChild.find((wraplet) => {\n let result = false;\n wraplet.wraplet.accessNode((node) => {\n if (node === childElement) {\n result = true;\n }\n });\n return result;\n });\n if (existingWraplets.length === 0) {\n return null;\n }\n if (existingWraplets.length > 1) {\n throw new InternalLogicError(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");\n }\n return existingWraplets[0];\n }\n // Handle single.\n return existingChild;\n }\n instantiateSingleWrapletChild(childDefinition, childMap, node, id) {\n if (!childDefinition.selector) {\n return null;\n }\n const selector = childDefinition.selector;\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n if (childElements.length === 0) {\n return null;\n }\n if (childElements.length > 1) {\n throw new ChildrenTooManyFoundError(`${this.constructor.name}: More than one element was found for the \"${id}\" child. Selector used: \"${selector}\".`);\n }\n const childElement = childElements[0];\n return this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n }\n instantiateWrapletItem(id, childDefinition, childMap, node) {\n // Re-use existing wraplet.\n const existingWraplet = this.findExistingWraplet(id, node);\n if (existingWraplet) {\n return existingWraplet;\n }\n const wrapletClass = childDefinition.Class;\n const creatorArgs = {\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: childDefinition.args,\n };\n creatorArgs.args = creatorArgs.args.map((arg) => {\n if (isArgCreator(arg)) {\n return arg.createArg(creatorArgs);\n }\n return arg;\n });\n let wraplet = null;\n try {\n wraplet = this.wrapletCreator(creatorArgs, this.constructor);\n }\n catch (e) {\n if (e instanceof UnsupportedNodeTypeError) {\n if (!childDefinition.required) {\n console.warn(`${e.message} Skipping instantiation of the \"${id}\" child.`);\n return null;\n }\n }\n throw e;\n }\n this.prepareIndividualWraplet(id, wraplet);\n for (const listener of this.instantiateChildListeners) {\n listener(wraplet, id);\n }\n return wraplet;\n }\n instantiateMultipleWrapletsChild(childDefinition, childMap, node, id) {\n const selector = childDefinition.selector;\n if (!selector) {\n return new DefaultWrapletSet();\n }\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n const items = this.instantiatedChildren && this.instantiatedChildren[id]\n ? this.instantiatedChildren[id]\n : new DefaultWrapletSet();\n for (const childElement of childElements) {\n const existingWraplet = this.findExistingWraplet(id, childElement);\n if (existingWraplet) {\n continue;\n }\n const wraplet = this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n if (wraplet) {\n items.add(wraplet);\n }\n }\n return items;\n }\n addDestroyChildListener(callback) {\n this.destroyChildListeners.push(callback);\n }\n addInstantiateChildListener(callback) {\n this.instantiateChildListeners.push(callback);\n }\n setWrapletCreator(wrapletCreator) {\n this.wrapletCreator = wrapletCreator;\n }\n prepareIndividualWraplet(id, wraplet) {\n const destroyListener = ((wraplet) => {\n this.removeChild(wraplet, id);\n for (const listener of this.destroyChildListeners) {\n listener(wraplet, id);\n }\n });\n // Listen for the child's destruction.\n wraplet.wraplet.addDestroyListener(destroyListener);\n }\n /**\n * This method removes from nodes references to this wraplet and its children recursively.\n */\n async destroy() {\n if (this.statusWritable.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.statusWritable.isGettingDestroyed = true;\n if (this.statusWritable.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return;\n }\n if (!this.statusWritable.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n return;\n }\n // Remove listeners.\n for (const listener of this.listeners) {\n const node = listener.node;\n const eventName = listener.eventName;\n const callback = listener.callback;\n const options = listener.options;\n node.removeEventListener(eventName, callback, options);\n }\n this.listeners.length = 0;\n await this.destroyChildren();\n this.statusWritable.isInitialized = false;\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n }\n findChildren(selector, node) {\n const defaultSelectorCallback = (selector, node) => {\n return Array.from(node.querySelectorAll(selector));\n };\n // Find children elements based on the map.\n return typeof selector === \"string\"\n ? defaultSelectorCallback(selector, node)\n : selector(node);\n }\n addEventListener(node, eventName, callback, options) {\n this.listeners.push({ node, eventName, callback, options });\n node.addEventListener(eventName, callback, options);\n }\n get children() {\n if (!this.childrenAreInstantiated) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");\n }\n return this.instantiatedChildren;\n }\n removeChild(wraplet, id) {\n if (isWrapletSet(this.instantiatedChildren[id])) {\n if (!this.instantiatedChildren[id].delete(wraplet)) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\");\n }\n return;\n }\n if (this.map[id].required && !this.statusWritable.isGettingDestroyed) {\n throw new RequiredChildDestroyedError(\"Required child has been destroyed.\");\n }\n if (this.instantiatedChildren[id] === null) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");\n }\n // @ts-expect-error The type is unknown because we are dealing with a generic here.\n this.instantiatedChildren[id] = null;\n }\n validateMapItem(id, item) {\n const selector = item.selector;\n const isRequired = item.required;\n if (!selector) {\n if (isRequired) {\n throw new MapError(`${this.constructor.name}: Child \"${id}\" cannot at the same be required and have no selector.`);\n }\n }\n }\n validateMapItemForNonParent(id, item) {\n if (item.required) {\n throw new MapError(`Dependency \"${id}\" error: If the node provided cannot have children, there should be no required children.`);\n }\n }\n validateElements(id, elements, mapItem) {\n if (elements.length === 0 && mapItem.required) {\n throw new MissingRequiredChildError(`${this.constructor.name}: Couldn't find a node for the wraplet \"${id}\". Selector used: \"${mapItem.selector}\".`);\n }\n }\n /**\n * Set up a proxy to check if children have not been destroyed before fetching them.\n */\n wrapChildren(children) {\n return new Proxy(children, {\n get: function get(target, name) {\n if (!(name in target)) {\n throw new Error(`Child '${name}' has not been found.`);\n }\n return target[name];\n },\n });\n }\n defaultInitOptions() {\n return {\n instantiateChildListeners: [],\n destroyChildListeners: [],\n };\n }\n processInitOptions(initOptionsPartial) {\n const initOptions = Object.assign(this.defaultInitOptions(), initOptionsPartial);\n for (const listener of initOptions.instantiateChildListeners) {\n this.instantiateChildListeners.push(listener);\n }\n for (const listener of initOptions.destroyChildListeners) {\n this.destroyChildListeners.push(listener);\n }\n }\n async destroyChildren() {\n for (const [key, child] of Object.entries(this.children)) {\n if (!child || !this.map[key][\"destructible\"]) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n await item.wraplet.destroy();\n }\n }\n else {\n await child.wraplet.destroy();\n }\n }\n }\n}\n","import { ArgCreatorSymbol } from \"./types/ArgCreator\";\nexport class DefaultArgCreator {\n creator;\n [ArgCreatorSymbol] = true;\n constructor(creator) {\n this.creator = creator;\n }\n createArg(args) {\n return this.creator(args);\n }\n static create(creator) {\n return new DefaultArgCreator(creator);\n }\n}\n","import { is } from \"../../utils/is\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"../utils/is\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","export async function initializationStarted(status, core) {\n if (status.isInitialized) {\n return false;\n }\n status.isGettingInitialized = true;\n await core.initializeChildren();\n return true;\n}\nexport async function initializationCompleted(status, destroyMethod) {\n status.isInitialized = true;\n status.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (status.isGettingDestroyed) {\n await destroyMethod();\n }\n}\nexport async function destructionStarted(status, core, wraplet, destroyListeners) {\n if (status.isDestroyed) {\n return false;\n }\n status.isGettingDestroyed = true;\n if (status.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return false;\n }\n if (!status.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n status.isDestroyed = true;\n status.isGettingDestroyed = false;\n return false;\n }\n await core.destroy();\n for (const listener of destroyListeners) {\n await listener(wraplet);\n }\n return true;\n}\nexport async function destructionCompleted(status) {\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n}\n","import { initializationCompleted, initializationStarted, } from \"../Wraplet/statusActions\";\n/**\n * Note: If status is not provided, this function will attempt to get it from \"this\".\n */\nexport function createDefaultInitializeCallback(args, customInitializeLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot initialize without status available.\");\n }\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n const outerStatus = args.status || this.status;\n if (!(await initializationStarted(outerStatus, args.core))) {\n return;\n }\n if (customInitializeLogic) {\n await customInitializeLogic();\n }\n await initializationCompleted(outerStatus, args.destroyCallback);\n };\n}\n","import { destructionCompleted, destructionStarted, } from \"../Wraplet/statusActions\";\nexport function createDefaultDestroyCallback(args, customDestroyLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot destroy without status available.\");\n }\n // @ts-expect-error Default callbacks depend on the status from the outer object for the easier usage.\n const outerStatus = args.status || this.status;\n if (!(await destructionStarted(outerStatus, args.core, args.wraplet, args.destroyListeners))) {\n return;\n }\n if (customDestroyLogic) {\n await customDestroyLogic();\n }\n await destructionCompleted(outerStatus);\n };\n}\n","import { createDefaultInitializeCallback } from \"../Wraplet/createDefaultInitializeCallback\";\nimport { createDefaultDestroyCallback } from \"../Wraplet/createDefaultDestroyCallback\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\n const api = {};\n const destroyListeners = args.destroyListeners || [];\n const destroyCallback = args.destroyCallback ||\n createDefaultDestroyCallback({\n core: args.core,\n wraplet: args.wraplet,\n destroyListeners: destroyListeners,\n }).bind(api);\n api.destroy = destroyCallback;\n const initializeCallback = args.initializeCallback ||\n createDefaultInitializeCallback({\n core: args.core,\n destroyCallback: api.destroy,\n }).bind(api);\n return Object.assign(api, {\n __nodeAccessors: nodeAccessors,\n status: {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n },\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: initializeCallback,\n destroy: destroyCallback,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\n });\n};\n","import { defaultGroupableAttribute } from \"../types/Groupable\";\nimport { createWrapletApi } from \"./createWrapletApi\";\nexport const createRichWrapletApi = (args) => {\n const defaultGroupExtractor = (node) => {\n if (node instanceof Element) {\n const groupsString = node.getAttribute(defaultGroupableAttribute);\n if (groupsString) {\n return groupsString.split(\",\");\n }\n }\n return [];\n };\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n return Object.assign(createWrapletApi(args), {\n getNodeTreeChildren: () => {\n return args.core.getNodeTreeChildren();\n },\n setGroupsExtractor: (extractor) => {\n groupExtractor = extractor;\n },\n getGroups: () => {\n return groupExtractor(args.core.node);\n },\n });\n};\n","import { WrapletSymbol } from \"./Wraplet/types/Wraplet\";\nimport { GroupableSymbol } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol, } from \"./NodeTreeManager/types/NodeTreeParent\";\nimport { isCore } from \"./Core/types/Core\";\nimport { DefaultCore } from \"./Core/DefaultCore\";\nimport { createRichWrapletApi } from \"./Wraplet/createRichWrapletApi\";\nimport { UnsupportedNodeTypeError } from \"./errors\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n destroyListeners = [];\n wraplet;\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n const supportedNodeTypes = this.supportedNodeTypes();\n if (supportedNodeTypes !== null) {\n if (!supportedNodeTypes.find((value) => core.node instanceof value)) {\n throw new UnsupportedNodeTypeError(`Node type ${core.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);\n }\n }\n core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n core.instantiateChildren();\n this.wraplet = createRichWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n get children() {\n return this.core.children;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been destroyed.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onChildDestroy(child, id) { }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be invoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiate(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n child, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id) { }\n /**\n * Subclasses must return an array of constructors covering all types in union N.\n * Wrap the result in the `supportedTypeCheck` helper to make sure that the array contains all\n * and only classes that extend the given type.\n */\n supportedNodeTypes() {\n return null;\n }\n /**\n * Helper for subclasses to easily satisfy the exhaustive check.\n */\n supportedNodeTypesGuard(types) {\n return types;\n }\n /**\n * This method makes sure that the given instance is an instance of a class belonging to the\n * given child.\n *\n * @param item\n * @param actualUnknownId\n * @param onlyId\n * By hardcoding onlyId you can filter out any other children. It allows you to learn not only\n * that the class is correct, but also that the child is correct (in case multiple children can\n * use the same class).\n * @protected\n */\n isChildInstance(item, actualUnknownId, onlyId = null) {\n return (actualUnknownId === (onlyId || actualUnknownId) &&\n item instanceof this.core.map[actualUnknownId][\"Class\"]);\n }\n static createCore(node, map) {\n return new DefaultCore(node, map);\n }\n // We can afford \"any\" here because this method is only for the external usage, and external\n // callers don't need to know what map is the current wraplet using, as it's its internal\n // matter.\n static createWraplets(node, map, attribute, additional_args = []) {\n if (this === AbstractWraplet) {\n throw new Error(\"You cannot instantiate an abstract class.\");\n }\n const result = [];\n if (node instanceof Element && node.hasAttribute(attribute)) {\n const core = this.createCore(node, map);\n result.push(new this(core, ...additional_args));\n }\n const foundElements = node.querySelectorAll(`[${attribute}]`);\n for (const element of foundElements) {\n const core = this.createCore(element, map);\n result.push(new this(core, ...additional_args));\n }\n return result;\n }\n}\n","import { DynamicMapSymbol } from \"./types/DynamicMap\";\nexport class MapRepeat {\n levels;\n [DynamicMapSymbol] = true;\n constructor(levels = 1) {\n this.levels = levels;\n if (levels < 1) {\n throw new Error(\"There have to be more than 0 repeated levels.\");\n }\n }\n create(parentMapClone) {\n for (let i = 0; i < this.levels; i++) {\n parentMapClone.down();\n }\n return parentMapClone.getCurrentMap();\n }\n static create(levels = 1) {\n return new MapRepeat(levels);\n }\n}\n","import { WrapletSetReadonlySymbol, } from \"./types/WrapletSetReadonly\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nexport class DefaultWrapletSetReadonly extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n}\n","export function customizeDefaultWrapletApi(args, wrapletApi) {\n if (!args.status && (args.destroy || args.initialize)) {\n throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");\n }\n // We don't want to create a new object because the default callbacks are bound to the old one.\n return Object.assign(wrapletApi, args);\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","StorageValidationError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","UnsupportedNodeTypeError","isWrapletChildrenMapWithDefaults","object","getPrototypeOf","symbol","WrapletSetSymbol","isWrapletSet","DefaultSearchableSet","Set","find","filter","results","item","this","push","findOne","getOrdered","callback","Array","from","sort","a","b","WrapletSetReadonlySymbol","getWrapletsFromNode","node","wraplets","size","removeWrapletFromNode","wraplet","delete","async","actOnNodesRecursively","children","childNodes","child","destroyWrapletsRecursively","status","isGettingDestroyed","isDestroyed","destroy","CoreSymbol","NodeTreeParentSymbol","addDefaultsToChildDefinition","args","destructible","map","coreOptions","fillMapWithDefaults","newMap","id","def","subMap","DynamicMapSymbol","isDynamicMap","MapWrapper","fullMap","startingPath","currentMap","path","currentPath","constructor","resolveImmediately","resolve","getStartingMap","getCurrentMap","findMap","resultMap","pathPart","join","create","clone","up","pathExists","tempMap","hasOwn","down","length","pop","ArgCreatorSymbol","defaultWrapletCreator","currentCoreClass","core","element","initOptions","Class","DefaultCore","childrenAreInstantiated","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","childInstances","values","flatMap","Promise","all","initialize","instantiateChildren","querySelectorAll","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","e","required","console","warn","message","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","isRequired","elements","mapItem","Proxy","target","defaultInitOptions","initOptionsPartial","assign","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","initializationStarted","initializationCompleted","destroyMethod","destructionStarted","destroyListeners","destructionCompleted","createDefaultInitializeCallback","customInitializeLogic","outerStatus","destroyCallback","createDefaultDestroyCallback","customDestroyLogic","createWrapletApi","nodeAccessors","api","bind","initializeCallback","__nodeAccessors","createRichWrapletApi","groupExtractor","Element","groupsString","getAttribute","split","setGroupsExtractor","extractor","getGroups","AbstractWraplet","supportedNodeTypes","onChildDestroy","onChildInstantiate","supportedNodeTypesGuard","types","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly","customizeDefaultWrapletApi","wrapletApi"],"ignoreList":[],"sourceRoot":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export type { WrapletSetReadonly } from "./Set/types/WrapletSetReadonly";
|
|
|
12
12
|
export type { WrapletSet } from "./Set/types/WrapletSet";
|
|
13
13
|
export { DefaultWrapletSetReadonly } from "./Set/DefaultWrapletSetReadonly";
|
|
14
14
|
export { DefaultWrapletSet } from "./Set/DefaultWrapletSet";
|
|
15
|
-
export type { Wraplet
|
|
15
|
+
export type { Wraplet } from "./Wraplet/types/Wraplet";
|
|
16
16
|
export type { WrapletApi, WrapletApiDebug } from "./Wraplet/types/WrapletApi";
|
|
17
17
|
export type { RichWrapletApi } from "./Wraplet/types/RichWrapletApi";
|
|
18
18
|
export type { WrapletApiFactoryArgs } from "./Wraplet/types/WrapletApiFactoryArgs";
|
|
19
19
|
export type { RichWrapletApiFactoryArgs } from "./Wraplet/types/RichWrapletApiFactoryArgs";
|
|
20
20
|
export type { Status } from "./Wraplet/types/Status";
|
|
21
|
-
export { isWraplet } from "./Wraplet/types/Wraplet";
|
|
21
|
+
export { isWraplet, WrapletSymbol } from "./Wraplet/types/Wraplet";
|
|
22
22
|
export * from "./Wraplet/createRichWrapletApi";
|
|
23
23
|
export * from "./Wraplet/createWrapletApi";
|
|
24
24
|
export * from "./Wraplet/statusActions";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],c=Symbol("WrapletSet");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol("WrapletSetReadonly");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol("Core"),v=Symbol("NodeTreeParent");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol("DynamicMap");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol("ArgCreator");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${r}".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new o("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol("Wraplet");function O(t){return d(t,S)}const A=Symbol("Groupable");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.includes(t.node.constructor))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error("There have to be more than 0 repeated levels.")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};
|
|
1
|
+
class t extends Error{}class e extends Error{}class i extends Error{}class s extends Error{}class r extends Error{}class n extends Error{}class a extends Error{}class o extends Error{}class l extends Error{}function h(t){return Object.getPrototypeOf(t)===Object.prototype}const d=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],c=Symbol("WrapletSet");function u(t){return d(t,c)}class p extends Set{find(t){const e=[];for(const i of this)t(i)&&e.push(i);return e}findOne(t){for(const e of this)if(t(e))return e;return null}getOrdered(t){return Array.from(this).sort((e,i)=>t(e)-t(i))}}const f=Symbol("WrapletSetReadonly");class w extends p{[f]=!0;[c]=!0}function y(t){const e=t.wraplets;return u(e)&&0!==e.size?e:new w}function C(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function g(t,e){await e(t);const i=t.childNodes;for(const t of i)await g(t,e)}async function m(t){await g(t,async t=>{const e=y(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),C(i,t)})}const b=Symbol("Core"),v=Symbol("NodeTreeParent");function I(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=I(s);const r=s.map;r&&h(r)&&(e[i].map=W(r))}return e}const E=Symbol("DynamicMap");function D(t){return d(t,E)}class z{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=W(t),i&&(this.currentMap=this.resolve(this.path))}getStartingMap(){return this.resolve(this.startingPath)}getCurrentMap(){return this.currentMap&&this.currentPath==this.path||(this.currentMap=this.resolve(this.path),this.currentPath=this.path),this.currentMap}findMap(t){let e=this.fullMap;for(const i of t){if(!e[i])throw new Error(`Invalid path: ${this.path.join(".")} . No such definition.`);const s=e[i].map;if(h(s))e=s;else{if(!D(s))throw new Error("Invalid map type.");e=s.create(this.clone(t,!1))}}return e}up(t,e=!0){if(!this.pathExists([...this.path,t]))throw new Error("Map doesn't exist.");this.path.push(t),e&&(this.currentMap=this.resolve(this.path))}pathExists(t){let e=this.fullMap;for(const i of t){if(!Object.hasOwn(e,i))return!1;const t=e[i].map;if(D(t))return!0;if(!h(t))throw new Error("Invalid map type.");e=t}return!0}down(t=!0){if(0===this.path.length)throw new Error("At the root already.");this.path.pop(),t&&(this.currentMap=this.resolve(this.path))}clone(t,e=!0){return new z(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const M=Symbol("ArgCreator");function L(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class G{node;[b]=!0;[v]=!0;childrenAreInstantiated=!1;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=L;constructor(t,i,s={}){if(this.node=t,!(t instanceof Node))throw new Error("The node provided to the Core is not a valid node.");if(h(i))this.mapWrapper=new z(i);else{if(!(i instanceof z))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initializeChildren(){this.statusWritable.isGettingInitialized=!0;const t=Object.values(this.instantiatedChildren).flatMap(t=>t?u(t)?Array.from(t):[t]:[]);await Promise.all(t.map(t=>t.wraplet.initialize())),this.statusWritable.isInitialized=!0,this.statusWritable.isGettingInitialized=!1,this.statusWritable.isGettingDestroyed&&await this.destroy()}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"==typeof this.node.querySelectorAll){for(const e in this.map){const i=this.map[e],s=i.multiple,r=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=s?this.instantiateMultipleWrapletsChild(i,r,this.node,e):this.instantiateSingleWrapletChild(i,r,this.node,e)}this.childrenAreInstantiated||(this.instantiatedChildren=this.wrapChildren(t),this.childrenAreInstantiated=!0)}else for(const t in this.map){const e=this.map[t];this.validateMapItemForNonParent(t,e)}}async syncChildren(){this.instantiateChildren(),await this.initializeChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(null!==e)if(u(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.wraplet.accessNode(t=>{e=this.node.contains(t)}),e})}findExistingWraplet(t,e){if(void 0===this.instantiatedChildren||!this.instantiatedChildren[t])return null;const i=this.instantiatedChildren[t];if(this.map[t].multiple){if(!u(i))throw new o("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.wraplet.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new o("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,s){if(!t.selector)return null;const r=t.selector,a=this.findChildren(r,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new n(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${r}".`);const o=a[0];return this.instantiateWrapletItem(s,t,e,o)}instantiateWrapletItem(t,e,i,s){const r=this.findExistingWraplet(t,s);if(r)return r;const n={id:t,Class:e.Class,element:s,map:i,initOptions:e.coreOptions,args:e.args};n.args=n.args.map(t=>d(t,M)?t.createArg(n):t);let a=null;try{a=this.wrapletCreator(n,this.constructor)}catch(i){if(i instanceof l&&!e.required)return console.warn(`${i.message} Skipping instantiation of the "${t}" child.`),null;throw i}this.prepareIndividualWraplet(t,a);for(const e of this.instantiateChildListeners)e(a,t);return a}instantiateMultipleWrapletsChild(t,e,i,s){const r=t.selector;if(!r)return new w;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new w;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);r&&a.add(r)}return a}addDestroyChildListener(t){this.destroyChildListeners.push(t)}addInstantiateChildListener(t){this.instantiateChildListeners.push(t)}setWrapletCreator(t){this.wrapletCreator=t}prepareIndividualWraplet(t,e){e.wraplet.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.statusWritable.isDestroyed)throw new a("Children are already destroyed.");if(this.statusWritable.isGettingDestroyed=!0,!this.statusWritable.isGettingInitialized){if(!this.statusWritable.isInitialized)return this.statusWritable.isDestroyed=!0,void(this.statusWritable.isGettingDestroyed=!1);for(const t of this.listeners){const e=t.node,i=t.eventName,s=t.callback,r=t.options;e.removeEventListener(i,s,r)}this.listeners.length=0,await this.destroyChildren(),this.statusWritable.isInitialized=!1,this.statusWritable.isDestroyed=!0,this.statusWritable.isGettingDestroyed=!1}}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,s){this.listeners.push({node:t,eventName:e,callback:i,options:s}),t.addEventListener(e,i,s)}get children(){if(!this.childrenAreInstantiated)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}removeChild(t,e){if(u(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new o("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.statusWritable.isGettingDestroyed)throw new i("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new o("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const s=i.selector,r=i.required;if(!s&&r)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateMapItemForNonParent(t,i){if(i.required)throw new e(`Dependency "${t}" error: If the node provided cannot have children, there should be no required children.`)}validateElements(e,i,s){if(0===i.length&&s.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${s.selector}".`)}wrapChildren(t){return new Proxy(t,{get:function(t,e){if(!(e in t))throw new Error(`Child '${e}' has not been found.`);return t[e]}})}defaultInitOptions(){return{instantiateChildListeners:[],destroyChildListeners:[]}}processInitOptions(t){const e=Object.assign(this.defaultInitOptions(),t);for(const t of e.instantiateChildListeners)this.instantiateChildListeners.push(t);for(const t of e.destroyChildListeners)this.destroyChildListeners.push(t)}async destroyChildren(){for(const[t,e]of Object.entries(this.children))if(e&&this.map[t].destructible)if(u(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class x{creator;[M]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new x(t)}}const S=Symbol("Wraplet");function O(t){return d(t,S)}const A=Symbol("Groupable");async function N(t,e){return!t.isInitialized&&(t.isGettingInitialized=!0,await e.initializeChildren(),!0)}async function $(t,e){t.isInitialized=!0,t.isGettingInitialized=!1,t.isGettingDestroyed&&await e()}async function j(t,e,i,s){if(t.isDestroyed)return!1;if(t.isGettingDestroyed=!0,t.isGettingInitialized)return!1;if(!t.isInitialized)return t.isDestroyed=!0,t.isGettingDestroyed=!1,!1;await e.destroy();for(const t of s)await t(i);return!0}async function q(t){t.isGettingDestroyed=!1,t.isInitialized=!1,t.isDestroyed=!0}function P(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot initialize without status available.");const i=t.status||this.status;await N(i,t.core)&&(e&&await e(),await $(i,t.destroyCallback))}}function T(t,e){return async function(){if(!(t.status||this&&this.status))throw new Error("Cannot destroy without status available.");const i=t.status||this.status;await j(i,t.core,t.wraplet,t.destroyListeners)&&(e&&await e(),await q(i))}}const k=t=>{const e=[],i={},s=t.destroyListeners||[],r=t.destroyCallback||T({core:t.core,wraplet:t.wraplet,destroyListeners:s}).bind(i);i.destroy=r;const n=t.initializeCallback||P({core:t.core,destroyCallback:i.destroy}).bind(i);return Object.assign(i,{__nodeAccessors:e,status:{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},addDestroyListener:t=>{s.push(t)},initialize:n,destroy:r,accessNode:i=>{e.push(i),i(t.core.node)}})},F=t=>{let e=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});return Object.assign(k(t),{getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{e=t},getGroups:()=>e(t.core.node)})};class R{core;[S]=!0;[A]=!0;[v]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!d(t,b))throw new Error("AbstractWraplet requires a Core instance.");const e=this.supportedNodeTypes();if(null!==e&&!e.find(e=>t.node instanceof e))throw new l(`Node type ${t.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),t.instantiateChildren(),this.wraplet=F({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}supportedNodeTypes(){return null}supportedNodeTypesGuard(t){return t}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new G(t,e)}static createWraplets(t,e,i,s=[]){if(this===R)throw new Error("You cannot instantiate an abstract class.");const r=[];if(t instanceof Element&&t.hasAttribute(i)){const i=this.createCore(t,e);r.push(new this(i,...s))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=this.createCore(t,e);r.push(new this(i,...s))}return r}}class Y{levels;[E]=!0;constructor(t=1){if(this.levels=t,t<1)throw new Error("There have to be more than 0 repeated levels.")}create(t){for(let e=0;e<this.levels;e++)t.down();return t.getCurrentMap()}static create(t=1){return new Y(t)}}class _ extends p{[f]=!0}function B(t,e){if(!t.status&&(t.destroy||t.initialize))throw new Error("Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.");return Object.assign(e,t)}export{R as AbstractWraplet,a as ChildrenAreAlreadyDestroyedError,s as ChildrenAreNotAvailableError,n as ChildrenTooManyFoundError,x as DefaultArgCreator,G as DefaultCore,w as DefaultWrapletSet,_ as DefaultWrapletSetReadonly,o as InternalLogicError,e as MapError,Y as MapRepeat,t as MissingRequiredChildError,i as RequiredChildDestroyedError,r as StorageValidationError,l as UnsupportedNodeTypeError,S as WrapletSymbol,T as createDefaultDestroyCallback,P as createDefaultInitializeCallback,F as createRichWrapletApi,k as createWrapletApi,B as customizeDefaultWrapletApi,L as defaultWrapletCreator,m as destroyWrapletsRecursively,q as destructionCompleted,j as destructionStarted,y as getWrapletsFromNode,$ as initializationCompleted,N as initializationStarted,O as isWraplet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","mappings":"AAAO,MAAMA,UAAkCC,OAExC,MAAMC,UAAiBD,OAEvB,MAAME,UAAoCF,OAE1C,MAAMG,UAAqCH,OAE3C,MAAMI,UAA+BJ,OAErC,MAAMK,UAAkCL,OAExC,MAAMM,UAAyCN,OAE/C,MAAMO,UAA2BP,OAEjC,MAAMQ,UAAiCR,OChBvC,SAASS,EAAiCC,GAC7C,OAAOC,OAAOC,eAAeF,KAAYC,OAAOE,SACpD,CCCA,MAAM,EAAK,CAACH,EAAQI,IACU,iBAAXJ,GACA,OAAXA,IACmB,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OAASA,EACVA,EAAS,EACT,MAAM,IAAIrO,MAAM,gDAExB,CACA,MAAAkF,CAAOoJ,GACH,IAAK,IAAIC,EAAI,EAAGA,EAAI/M,KAAK6M,OAAQE,IAC7BD,EAAe9I,OAEnB,OAAO8I,EAAezJ,eAC1B,CACA,aAAOK,CAAOmJ,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkCtN,EAC3C,CAACgB,IAA4B,ECH1B,SAASuM,EAA2BjL,EAAMkL,GAC7C,IAAKlL,EAAKR,SAAWQ,EAAKL,SAAWK,EAAK6D,YACtC,MAAM,IAAIrH,MAAM,+HAGpB,OAAOW,OAAOsK,OAAOyD,EAAYlL,EACrC,Q","sources":["webpack://wraplet/./src/errors.ts","webpack://wraplet/./src/Wraplet/types/WrapletChildrenMap.ts","webpack://wraplet/./src/utils/is.ts","webpack://wraplet/./src/Set/types/WrapletSet.ts","webpack://wraplet/./src/Set/DefaultSearchableSet.ts","webpack://wraplet/./src/Set/types/WrapletSetReadonly.ts","webpack://wraplet/./src/Set/DefaultWrapletSet.ts","webpack://wraplet/./src/NodeTreeManager/utils.ts","webpack://wraplet/./src/Core/types/Core.ts","webpack://wraplet/./src/NodeTreeManager/types/NodeTreeParent.ts","webpack://wraplet/./src/Map/utils.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/Core/types/ArgCreator.ts","webpack://wraplet/./src/Core/defaultWrapletCreator.ts","webpack://wraplet/./src/Core/DefaultCore.ts","webpack://wraplet/./src/Core/DefaultArgCreator.ts","webpack://wraplet/./src/Wraplet/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/Wraplet/statusActions.ts","webpack://wraplet/./src/Wraplet/createDefaultInitializeCallback.ts","webpack://wraplet/./src/Wraplet/createDefaultDestroyCallback.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Wraplet/createRichWrapletApi.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.ts","webpack://wraplet/./src/Wraplet/customizeDefaultWrapletApi.ts"],"sourcesContent":["export class MissingRequiredChildError extends Error {\n}\nexport class MapError extends Error {\n}\nexport class RequiredChildDestroyedError extends Error {\n}\nexport class ChildrenAreNotAvailableError extends Error {\n}\nexport class StorageValidationError extends Error {\n}\nexport class ChildrenTooManyFoundError extends Error {\n}\nexport class ChildrenAreAlreadyDestroyedError extends Error {\n}\nexport class InternalLogicError extends Error {\n}\nexport class UnsupportedNodeTypeError extends Error {\n}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/**\n * Generic guard.\n */\nconst is = (object, symbol) => {\n return (typeof object === \"object\" &&\n object !== null &&\n object[symbol] === true);\n};\nexport { is };\n","import { is } from \"../../utils/is\";\nconst WrapletSetSymbol = Symbol(\"WrapletSet\");\nexport { WrapletSetSymbol };\nexport function isWrapletSet(object) {\n return is(object, WrapletSetSymbol);\n}\n","export class DefaultSearchableSet extends Set {\n find(filter) {\n const results = [];\n for (const item of this) {\n if (!filter(item)) {\n continue;\n }\n results.push(item);\n }\n return results;\n }\n findOne(filter) {\n for (const item of this) {\n if (filter(item)) {\n return item;\n }\n }\n return null;\n }\n getOrdered(callback) {\n return Array.from(this).sort((a, b) => callback(a) - callback(b));\n }\n}\n","const WrapletSetReadonlySymbol = Symbol(\"WrapletSetReadonly\");\nexport { WrapletSetReadonlySymbol };\n","import { WrapletSetSymbol } from \"./types/WrapletSet\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nimport { WrapletSetReadonlySymbol } from \"./types/WrapletSetReadonly\";\nexport class DefaultWrapletSet extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n [WrapletSetSymbol] = true;\n}\n","import { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nexport function isParentNode(node) {\n return (typeof node.querySelectorAll ===\n \"function\");\n}\nexport function getWrapletsFromNode(node) {\n const wraplets = node.wraplets;\n if (!isWrapletSet(wraplets) || wraplets.size === 0) {\n return new DefaultWrapletSet();\n }\n return wraplets;\n}\nexport function removeWrapletFromNode(wraplet, node) {\n if (!node.wraplets) {\n return false;\n }\n return node.wraplets.delete(wraplet);\n}\nexport function addWrapletToNode(wraplet, node) {\n if (!node.wraplets) {\n node.wraplets = new DefaultWrapletSet();\n }\n node.wraplets.add(wraplet);\n}\nexport async function actOnNodesRecursively(node, callback) {\n await callback(node);\n const children = node.childNodes;\n for (const child of children) {\n await actOnNodesRecursively(child, callback);\n }\n}\nexport async function destroyWrapletsRecursively(node) {\n await actOnNodesRecursively(node, async (node) => {\n const wraplets = getWrapletsFromNode(node);\n for (const wraplet of wraplets) {\n if (!wraplet.wraplet.status.isGettingDestroyed &&\n !wraplet.wraplet.status.isDestroyed) {\n await wraplet.wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","import { is } from \"../../utils/is\";\nconst CoreSymbol = Symbol(\"Core\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nexport function addDefaultsToChildDefinition(definition) {\n return {\n ...{\n args: [],\n destructible: true,\n map: {},\n coreOptions: {},\n },\n ...definition,\n };\n}\nexport function fillMapWithDefaults(map) {\n const newMap = {};\n for (const id in map) {\n const def = map[id];\n newMap[id] = addDefaultsToChildDefinition(def);\n const subMap = def[\"map\"];\n if (subMap && isWrapletChildrenMapWithDefaults(subMap)) {\n newMap[id][\"map\"] = fillMapWithDefaults(subMap);\n }\n }\n return newMap;\n}\n","import { is } from \"../../utils/is\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"./utils\";\nimport { isDynamicMap } from \"./types/DynamicMap\";\nexport class MapWrapper {\n fullMap;\n startingPath;\n currentMap = null;\n path;\n currentPath = [];\n /**\n * @param fullMap\n * @param path\n * Path to the current definition.\n * @param resolveImmediately\n */\n constructor(fullMap, path = [], resolveImmediately = true) {\n this.path = path;\n this.startingPath = path;\n this.fullMap = fillMapWithDefaults(fullMap);\n if (resolveImmediately) {\n this.currentMap = this.resolve(this.path);\n }\n }\n getStartingMap() {\n return this.resolve(this.startingPath);\n }\n getCurrentMap() {\n if (!this.currentMap || this.currentPath != this.path) {\n this.currentMap = this.resolve(this.path);\n this.currentPath = this.path;\n }\n return this.currentMap;\n }\n /**\n * @param path\n * @private\n */\n findMap(path) {\n let resultMap = this.fullMap;\n for (const pathPart of path) {\n if (!resultMap[pathPart]) {\n throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);\n }\n const map = resultMap[pathPart][\"map\"];\n if (isWrapletChildrenMapWithDefaults(map)) {\n resultMap = map;\n }\n else if (isDynamicMap(map)) {\n resultMap = map.create(this.clone(path, false));\n }\n else {\n throw new Error(\"Invalid map type.\");\n }\n }\n return resultMap;\n }\n up(pathPart, resolve = true) {\n if (!this.pathExists([...this.path, pathPart])) {\n throw new Error(\"Map doesn't exist.\");\n }\n this.path.push(pathPart);\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n pathExists(path) {\n let tempMap = this.fullMap;\n for (const pathPart of path) {\n if (!Object.hasOwn(tempMap, pathPart)) {\n return false;\n }\n const map = tempMap[pathPart][\"map\"];\n if (isDynamicMap(map)) {\n return true;\n }\n if (!isWrapletChildrenMapWithDefaults(map)) {\n throw new Error(\"Invalid map type.\");\n }\n tempMap = map;\n }\n return true;\n }\n down(resolve = true) {\n if (this.path.length === 0) {\n throw new Error(\"At the root already.\");\n }\n this.path.pop();\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n clone(path, resolveImmediately = true) {\n return new MapWrapper(this.fullMap, path, resolveImmediately);\n }\n resolve(path) {\n return this.findMap(path);\n }\n}\n","import { is } from \"../../utils/is\";\nconst ArgCreatorSymbol = Symbol(\"ArgCreator\");\nexport { ArgCreatorSymbol };\nexport function isArgCreator(object) {\n return is(object, ArgCreatorSymbol);\n}\n","export function defaultWrapletCreator(args, currentCoreClass) {\n const core = new currentCoreClass(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n}\n","import { ChildrenAreAlreadyDestroyedError, ChildrenAreNotAvailableError, ChildrenTooManyFoundError, InternalLogicError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, UnsupportedNodeTypeError, } from \"../errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { isParentNode } from \"../NodeTreeManager/utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"../NodeTreeManager/types/NodeTreeParent\";\nimport { MapWrapper } from \"../Map/MapWrapper\";\nimport { isArgCreator } from \"./types/ArgCreator\";\nimport { defaultWrapletCreator } from \"./defaultWrapletCreator\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n childrenAreInstantiated = false;\n statusWritable = {\n isDestroyed: false,\n isGettingDestroyed: false,\n isInitialized: false,\n isGettingInitialized: false,\n };\n get status() {\n return this.statusWritable;\n }\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n wrapletCreator = defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\n if (!(node instanceof Node)) {\n throw new Error(\"The node provided to the Core is not a valid node.\");\n }\n if (isWrapletChildrenMapWithDefaults(map)) {\n this.mapWrapper = new MapWrapper(map);\n }\n else if (map instanceof MapWrapper) {\n this.mapWrapper = map;\n }\n else {\n throw new MapError(\"The map provided to the Core is not a valid map.\");\n }\n this.processInitOptions(initOptions);\n this.instantiatedChildren = {};\n }\n /**\n * Initialize core.\n *\n * We couldn't put this step in the constructor, because during initialization some wraplet\n * processing occurs (instantiate child listeners) that needs access to the children manager,\n * so the children manager has to exist already.\n */\n async initializeChildren() {\n this.statusWritable.isGettingInitialized = true;\n const childInstances = Object.values(this.instantiatedChildren).flatMap((child) => {\n if (!child)\n return [];\n return isWrapletSet(child) ? Array.from(child) : [child];\n });\n await Promise.all(childInstances.map((child) => child.wraplet.initialize()));\n this.statusWritable.isInitialized = true;\n this.statusWritable.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.statusWritable.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get map() {\n return this.mapWrapper.getStartingMap();\n }\n instantiateChildren() {\n const children = this.instantiatedChildren;\n // We check if are dealing with the ParentNode object.\n if (!isParentNode(this.node)) {\n for (const id in this.map) {\n const childDefinition = this.map[id];\n this.validateMapItemForNonParent(id, childDefinition);\n }\n return;\n }\n for (const id in this.map) {\n const childDefinition = this.map[id];\n const multiple = childDefinition.multiple;\n const mapWrapper = this.mapWrapper.clone([...this.mapWrapper.path, id]);\n this.validateMapItem(id, childDefinition);\n if (multiple) {\n // We can assert as much because items\n children[id] = this.instantiateMultipleWrapletsChild(childDefinition, mapWrapper, this.node, id);\n continue;\n }\n children[id] = this.instantiateSingleWrapletChild(childDefinition, mapWrapper, this.node, id);\n }\n if (!this.childrenAreInstantiated) {\n this.instantiatedChildren = this.wrapChildren(children);\n this.childrenAreInstantiated = true;\n }\n }\n async syncChildren() {\n this.instantiateChildren();\n await this.initializeChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\n if (child === null) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n children.push(item);\n }\n }\n else {\n children.push(child);\n }\n }\n // Return only descendants.\n return children.filter((child) => {\n let result = false;\n child.wraplet.accessNode((childsNode) => {\n result = this.node.contains(childsNode);\n });\n return result;\n });\n }\n findExistingWraplet(id, childElement) {\n // If a child doesn't have instantiated wraplets yet, then return null.\n if (this.instantiatedChildren === undefined ||\n !this.instantiatedChildren[id]) {\n return null;\n }\n const existingChild = this.instantiatedChildren[id];\n // Handle multiple.\n if (this.map[id][\"multiple\"]) {\n if (!isWrapletSet(existingChild)) {\n throw new InternalLogicError(\"Internal logic error. Expected a WrapletSet.\");\n }\n const existingWraplets = existingChild.find((wraplet) => {\n let result = false;\n wraplet.wraplet.accessNode((node) => {\n if (node === childElement) {\n result = true;\n }\n });\n return result;\n });\n if (existingWraplets.length === 0) {\n return null;\n }\n if (existingWraplets.length > 1) {\n throw new InternalLogicError(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");\n }\n return existingWraplets[0];\n }\n // Handle single.\n return existingChild;\n }\n instantiateSingleWrapletChild(childDefinition, childMap, node, id) {\n if (!childDefinition.selector) {\n return null;\n }\n const selector = childDefinition.selector;\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n if (childElements.length === 0) {\n return null;\n }\n if (childElements.length > 1) {\n throw new ChildrenTooManyFoundError(`${this.constructor.name}: More than one element was found for the \"${id}\" child. Selector used: \"${selector}\".`);\n }\n const childElement = childElements[0];\n return this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n }\n instantiateWrapletItem(id, childDefinition, childMap, node) {\n // Re-use existing wraplet.\n const existingWraplet = this.findExistingWraplet(id, node);\n if (existingWraplet) {\n return existingWraplet;\n }\n const wrapletClass = childDefinition.Class;\n const creatorArgs = {\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: childDefinition.args,\n };\n creatorArgs.args = creatorArgs.args.map((arg) => {\n if (isArgCreator(arg)) {\n return arg.createArg(creatorArgs);\n }\n return arg;\n });\n let wraplet = null;\n try {\n wraplet = this.wrapletCreator(creatorArgs, this.constructor);\n }\n catch (e) {\n if (e instanceof UnsupportedNodeTypeError) {\n if (!childDefinition.required) {\n console.warn(`${e.message} Skipping instantiation of the \"${id}\" child.`);\n return null;\n }\n }\n throw e;\n }\n this.prepareIndividualWraplet(id, wraplet);\n for (const listener of this.instantiateChildListeners) {\n listener(wraplet, id);\n }\n return wraplet;\n }\n instantiateMultipleWrapletsChild(childDefinition, childMap, node, id) {\n const selector = childDefinition.selector;\n if (!selector) {\n return new DefaultWrapletSet();\n }\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n const items = this.instantiatedChildren && this.instantiatedChildren[id]\n ? this.instantiatedChildren[id]\n : new DefaultWrapletSet();\n for (const childElement of childElements) {\n const existingWraplet = this.findExistingWraplet(id, childElement);\n if (existingWraplet) {\n continue;\n }\n const wraplet = this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n if (wraplet) {\n items.add(wraplet);\n }\n }\n return items;\n }\n addDestroyChildListener(callback) {\n this.destroyChildListeners.push(callback);\n }\n addInstantiateChildListener(callback) {\n this.instantiateChildListeners.push(callback);\n }\n setWrapletCreator(wrapletCreator) {\n this.wrapletCreator = wrapletCreator;\n }\n prepareIndividualWraplet(id, wraplet) {\n const destroyListener = ((wraplet) => {\n this.removeChild(wraplet, id);\n for (const listener of this.destroyChildListeners) {\n listener(wraplet, id);\n }\n });\n // Listen for the child's destruction.\n wraplet.wraplet.addDestroyListener(destroyListener);\n }\n /**\n * This method removes from nodes references to this wraplet and its children recursively.\n */\n async destroy() {\n if (this.statusWritable.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.statusWritable.isGettingDestroyed = true;\n if (this.statusWritable.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return;\n }\n if (!this.statusWritable.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n return;\n }\n // Remove listeners.\n for (const listener of this.listeners) {\n const node = listener.node;\n const eventName = listener.eventName;\n const callback = listener.callback;\n const options = listener.options;\n node.removeEventListener(eventName, callback, options);\n }\n this.listeners.length = 0;\n await this.destroyChildren();\n this.statusWritable.isInitialized = false;\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n }\n findChildren(selector, node) {\n const defaultSelectorCallback = (selector, node) => {\n return Array.from(node.querySelectorAll(selector));\n };\n // Find children elements based on the map.\n return typeof selector === \"string\"\n ? defaultSelectorCallback(selector, node)\n : selector(node);\n }\n addEventListener(node, eventName, callback, options) {\n this.listeners.push({ node, eventName, callback, options });\n node.addEventListener(eventName, callback, options);\n }\n get children() {\n if (!this.childrenAreInstantiated) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");\n }\n return this.instantiatedChildren;\n }\n removeChild(wraplet, id) {\n if (isWrapletSet(this.instantiatedChildren[id])) {\n if (!this.instantiatedChildren[id].delete(wraplet)) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\");\n }\n return;\n }\n if (this.map[id].required && !this.statusWritable.isGettingDestroyed) {\n throw new RequiredChildDestroyedError(\"Required child has been destroyed.\");\n }\n if (this.instantiatedChildren[id] === null) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");\n }\n // @ts-expect-error The type is unknown because we are dealing with a generic here.\n this.instantiatedChildren[id] = null;\n }\n validateMapItem(id, item) {\n const selector = item.selector;\n const isRequired = item.required;\n if (!selector) {\n if (isRequired) {\n throw new MapError(`${this.constructor.name}: Child \"${id}\" cannot at the same be required and have no selector.`);\n }\n }\n }\n validateMapItemForNonParent(id, item) {\n if (item.required) {\n throw new MapError(`Dependency \"${id}\" error: If the node provided cannot have children, there should be no required children.`);\n }\n }\n validateElements(id, elements, mapItem) {\n if (elements.length === 0 && mapItem.required) {\n throw new MissingRequiredChildError(`${this.constructor.name}: Couldn't find a node for the wraplet \"${id}\". Selector used: \"${mapItem.selector}\".`);\n }\n }\n /**\n * Set up a proxy to check if children have not been destroyed before fetching them.\n */\n wrapChildren(children) {\n return new Proxy(children, {\n get: function get(target, name) {\n if (!(name in target)) {\n throw new Error(`Child '${name}' has not been found.`);\n }\n return target[name];\n },\n });\n }\n defaultInitOptions() {\n return {\n instantiateChildListeners: [],\n destroyChildListeners: [],\n };\n }\n processInitOptions(initOptionsPartial) {\n const initOptions = Object.assign(this.defaultInitOptions(), initOptionsPartial);\n for (const listener of initOptions.instantiateChildListeners) {\n this.instantiateChildListeners.push(listener);\n }\n for (const listener of initOptions.destroyChildListeners) {\n this.destroyChildListeners.push(listener);\n }\n }\n async destroyChildren() {\n for (const [key, child] of Object.entries(this.children)) {\n if (!child || !this.map[key][\"destructible\"]) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n await item.wraplet.destroy();\n }\n }\n else {\n await child.wraplet.destroy();\n }\n }\n }\n}\n","import { ArgCreatorSymbol } from \"./types/ArgCreator\";\nexport class DefaultArgCreator {\n creator;\n [ArgCreatorSymbol] = true;\n constructor(creator) {\n this.creator = creator;\n }\n createArg(args) {\n return this.creator(args);\n }\n static create(creator) {\n return new DefaultArgCreator(creator);\n }\n}\n","import { is } from \"../../utils/is\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"../utils/is\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","export async function initializationStarted(status, core) {\n if (status.isInitialized) {\n return false;\n }\n status.isGettingInitialized = true;\n await core.initializeChildren();\n return true;\n}\nexport async function initializationCompleted(status, destroyMethod) {\n status.isInitialized = true;\n status.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (status.isGettingDestroyed) {\n await destroyMethod();\n }\n}\nexport async function destructionStarted(status, core, wraplet, destroyListeners) {\n if (status.isDestroyed) {\n return false;\n }\n status.isGettingDestroyed = true;\n if (status.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return false;\n }\n if (!status.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n status.isDestroyed = true;\n status.isGettingDestroyed = false;\n return false;\n }\n await core.destroy();\n for (const listener of destroyListeners) {\n await listener(wraplet);\n }\n return true;\n}\nexport async function destructionCompleted(status) {\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n}\n","import { initializationCompleted, initializationStarted, } from \"../Wraplet/statusActions\";\n/**\n * Note: If status is not provided, this function will attempt to get it from \"this\".\n */\nexport function createDefaultInitializeCallback(args, customInitializeLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot initialize without status available.\");\n }\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n const outerStatus = args.status || this.status;\n if (!(await initializationStarted(outerStatus, args.core))) {\n return;\n }\n if (customInitializeLogic) {\n await customInitializeLogic();\n }\n await initializationCompleted(outerStatus, args.destroyCallback);\n };\n}\n","import { destructionCompleted, destructionStarted, } from \"../Wraplet/statusActions\";\nexport function createDefaultDestroyCallback(args, customDestroyLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot destroy without status available.\");\n }\n // @ts-expect-error Default callbacks depend on the status from the outer object for the easier usage.\n const outerStatus = args.status || this.status;\n if (!(await destructionStarted(outerStatus, args.core, args.wraplet, args.destroyListeners))) {\n return;\n }\n if (customDestroyLogic) {\n await customDestroyLogic();\n }\n await destructionCompleted(outerStatus);\n };\n}\n","import { createDefaultInitializeCallback } from \"../Wraplet/createDefaultInitializeCallback\";\nimport { createDefaultDestroyCallback } from \"../Wraplet/createDefaultDestroyCallback\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\n const api = {};\n const destroyListeners = args.destroyListeners || [];\n const destroyCallback = args.destroyCallback ||\n createDefaultDestroyCallback({\n core: args.core,\n wraplet: args.wraplet,\n destroyListeners: destroyListeners,\n }).bind(api);\n api.destroy = destroyCallback;\n const initializeCallback = args.initializeCallback ||\n createDefaultInitializeCallback({\n core: args.core,\n destroyCallback: api.destroy,\n }).bind(api);\n return Object.assign(api, {\n __nodeAccessors: nodeAccessors,\n status: {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n },\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: initializeCallback,\n destroy: destroyCallback,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\n });\n};\n","import { defaultGroupableAttribute } from \"../types/Groupable\";\nimport { createWrapletApi } from \"./createWrapletApi\";\nexport const createRichWrapletApi = (args) => {\n const defaultGroupExtractor = (node) => {\n if (node instanceof Element) {\n const groupsString = node.getAttribute(defaultGroupableAttribute);\n if (groupsString) {\n return groupsString.split(\",\");\n }\n }\n return [];\n };\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n return Object.assign(createWrapletApi(args), {\n getNodeTreeChildren: () => {\n return args.core.getNodeTreeChildren();\n },\n setGroupsExtractor: (extractor) => {\n groupExtractor = extractor;\n },\n getGroups: () => {\n return groupExtractor(args.core.node);\n },\n });\n};\n","import { WrapletSymbol } from \"./Wraplet/types/Wraplet\";\nimport { GroupableSymbol } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol, } from \"./NodeTreeManager/types/NodeTreeParent\";\nimport { isCore } from \"./Core/types/Core\";\nimport { DefaultCore } from \"./Core/DefaultCore\";\nimport { createRichWrapletApi } from \"./Wraplet/createRichWrapletApi\";\nimport { UnsupportedNodeTypeError } from \"./errors\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n destroyListeners = [];\n wraplet;\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n const supportedNodeTypes = this.supportedNodeTypes();\n if (supportedNodeTypes !== null) {\n if (!supportedNodeTypes.includes(core.node.constructor)) {\n throw new UnsupportedNodeTypeError(`Node type ${core.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);\n }\n }\n core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n core.instantiateChildren();\n this.wraplet = createRichWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n get children() {\n return this.core.children;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been destroyed.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onChildDestroy(child, id) { }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be invoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiate(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n child, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id) { }\n /**\n * Subclasses must return an array of constructors covering all types in union N.\n * Wrap the result in the `supportedTypeCheck` helper to make sure that the array contains all\n * and only classes that extend the given type.\n */\n supportedNodeTypes() {\n return null;\n }\n /**\n * Helper for subclasses to easily satisfy the exhaustive check.\n */\n supportedNodeTypesGuard(types) {\n return types;\n }\n /**\n * This method makes sure that the given instance is an instance of a class belonging to the\n * given child.\n *\n * @param item\n * @param actualUnknownId\n * @param onlyId\n * By hardcoding onlyId you can filter out any other children. It allows you to learn not only\n * that the class is correct, but also that the child is correct (in case multiple children can\n * use the same class).\n * @protected\n */\n isChildInstance(item, actualUnknownId, onlyId = null) {\n return (actualUnknownId === (onlyId || actualUnknownId) &&\n item instanceof this.core.map[actualUnknownId][\"Class\"]);\n }\n static createCore(node, map) {\n return new DefaultCore(node, map);\n }\n // We can afford \"any\" here because this method is only for the external usage, and external\n // callers don't need to know what map is the current wraplet using, as it's its internal\n // matter.\n static createWraplets(node, map, attribute, additional_args = []) {\n if (this === AbstractWraplet) {\n throw new Error(\"You cannot instantiate an abstract class.\");\n }\n const result = [];\n if (node instanceof Element && node.hasAttribute(attribute)) {\n const core = this.createCore(node, map);\n result.push(new this(core, ...additional_args));\n }\n const foundElements = node.querySelectorAll(`[${attribute}]`);\n for (const element of foundElements) {\n const core = this.createCore(element, map);\n result.push(new this(core, ...additional_args));\n }\n return result;\n }\n}\n","import { DynamicMapSymbol } from \"./types/DynamicMap\";\nexport class MapRepeat {\n levels;\n [DynamicMapSymbol] = true;\n constructor(levels = 1) {\n this.levels = levels;\n if (levels < 1) {\n throw new Error(\"There have to be more than 0 repeated levels.\");\n }\n }\n create(parentMapClone) {\n for (let i = 0; i < this.levels; i++) {\n parentMapClone.down();\n }\n return parentMapClone.getCurrentMap();\n }\n static create(levels = 1) {\n return new MapRepeat(levels);\n }\n}\n","import { WrapletSetReadonlySymbol, } from \"./types/WrapletSetReadonly\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nexport class DefaultWrapletSetReadonly extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n}\n","export function customizeDefaultWrapletApi(args, wrapletApi) {\n if (!args.status && (args.destroy || args.initialize)) {\n throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");\n }\n // We don't want to create a new object because the default callbacks are bound to the old one.\n return Object.assign(wrapletApi, args);\n}\n"],"names":["MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","StorageValidationError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","UnsupportedNodeTypeError","isWrapletChildrenMapWithDefaults","object","Object","getPrototypeOf","prototype","symbol","WrapletSetSymbol","Symbol","isWrapletSet","DefaultSearchableSet","Set","find","filter","results","item","this","push","findOne","getOrdered","callback","Array","from","sort","a","b","WrapletSetReadonlySymbol","getWrapletsFromNode","node","wraplets","size","removeWrapletFromNode","wraplet","delete","async","actOnNodesRecursively","children","childNodes","child","destroyWrapletsRecursively","status","isGettingDestroyed","isDestroyed","destroy","CoreSymbol","NodeTreeParentSymbol","addDefaultsToChildDefinition","definition","args","destructible","map","coreOptions","fillMapWithDefaults","newMap","id","def","subMap","DynamicMapSymbol","isDynamicMap","MapWrapper","fullMap","startingPath","currentMap","path","currentPath","constructor","resolveImmediately","resolve","getStartingMap","getCurrentMap","findMap","resultMap","pathPart","join","create","clone","up","pathExists","tempMap","hasOwn","down","length","pop","ArgCreatorSymbol","defaultWrapletCreator","currentCoreClass","core","element","initOptions","Class","DefaultCore","childrenAreInstantiated","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","childInstances","values","flatMap","Promise","all","initialize","instantiateChildren","querySelectorAll","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","e","required","console","warn","message","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","isRequired","elements","mapItem","Proxy","get","target","defaultInitOptions","initOptionsPartial","assign","key","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","initializationStarted","initializationCompleted","destroyMethod","destructionStarted","destroyListeners","destructionCompleted","createDefaultInitializeCallback","customInitializeLogic","outerStatus","destroyCallback","createDefaultDestroyCallback","customDestroyLogic","createWrapletApi","nodeAccessors","api","bind","initializeCallback","__nodeAccessors","createRichWrapletApi","groupExtractor","Element","groupsString","getAttribute","split","setGroupsExtractor","extractor","getGroups","AbstractWraplet","supportedNodeTypes","includes","onChildDestroy","onChildInstantiate","supportedNodeTypesGuard","types","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly","customizeDefaultWrapletApi","wrapletApi"],"ignoreList":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"AAAO,MAAMA,UAAkCC,OAExC,MAAMC,UAAiBD,OAEvB,MAAME,UAAoCF,OAE1C,MAAMG,UAAqCH,OAE3C,MAAMI,UAA+BJ,OAErC,MAAMK,UAAkCL,OAExC,MAAMM,UAAyCN,OAE/C,MAAMO,UAA2BP,OAEjC,MAAMQ,UAAiCR,OChBvC,SAASS,EAAiCC,GAC7C,OAAOC,OAAOC,eAAeF,KAAYC,OAAOE,SACpD,CCCA,MAAM,EAAK,CAACH,EAAQI,IACU,iBAAXJ,GACA,OAAXA,IACmB,IAAnBA,EAAOI,GCLTC,EAAmBC,OAAO,cAEzB,SAASC,EAAaP,GACzB,OAAO,EAAGA,EAAQK,EACtB,CCLO,MAAMG,UAA6BC,IACtC,IAAAC,CAAKC,GACD,MAAMC,EAAU,GAChB,IAAK,MAAMC,KAAQC,KACVH,EAAOE,IAGZD,EAAQG,KAAKF,GAEjB,OAAOD,CACX,CACA,OAAAI,CAAQL,GACJ,IAAK,MAAME,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tN,EAC3C,CAACgB,IAA4B,ECH1B,SAASuM,EAA2BjL,EAAMkL,GAC7C,IAAKlL,EAAKR,SAAWQ,EAAKL,SAAWK,EAAK6D,YACtC,MAAM,IAAIrH,MAAM,+HAGpB,OAAOW,OAAOsK,OAAOyD,EAAYlL,EACrC,Q","sources":["webpack://wraplet/./src/errors.ts","webpack://wraplet/./src/Wraplet/types/WrapletChildrenMap.ts","webpack://wraplet/./src/utils/is.ts","webpack://wraplet/./src/Set/types/WrapletSet.ts","webpack://wraplet/./src/Set/DefaultSearchableSet.ts","webpack://wraplet/./src/Set/types/WrapletSetReadonly.ts","webpack://wraplet/./src/Set/DefaultWrapletSet.ts","webpack://wraplet/./src/NodeTreeManager/utils.ts","webpack://wraplet/./src/Core/types/Core.ts","webpack://wraplet/./src/NodeTreeManager/types/NodeTreeParent.ts","webpack://wraplet/./src/Map/utils.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/Core/types/ArgCreator.ts","webpack://wraplet/./src/Core/defaultWrapletCreator.ts","webpack://wraplet/./src/Core/DefaultCore.ts","webpack://wraplet/./src/Core/DefaultArgCreator.ts","webpack://wraplet/./src/Wraplet/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/Wraplet/statusActions.ts","webpack://wraplet/./src/Wraplet/createDefaultInitializeCallback.ts","webpack://wraplet/./src/Wraplet/createDefaultDestroyCallback.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Wraplet/createRichWrapletApi.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.ts","webpack://wraplet/./src/Wraplet/customizeDefaultWrapletApi.ts"],"sourcesContent":["export class MissingRequiredChildError extends Error {\n}\nexport class MapError extends Error {\n}\nexport class RequiredChildDestroyedError extends Error {\n}\nexport class ChildrenAreNotAvailableError extends Error {\n}\nexport class StorageValidationError extends Error {\n}\nexport class ChildrenTooManyFoundError extends Error {\n}\nexport class ChildrenAreAlreadyDestroyedError extends Error {\n}\nexport class InternalLogicError extends Error {\n}\nexport class UnsupportedNodeTypeError extends Error {\n}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/**\n * Generic guard.\n */\nconst is = (object, symbol) => {\n return (typeof object === \"object\" &&\n object !== null &&\n object[symbol] === true);\n};\nexport { is };\n","import { is } from \"../../utils/is\";\nconst WrapletSetSymbol = Symbol(\"WrapletSet\");\nexport { WrapletSetSymbol };\nexport function isWrapletSet(object) {\n return is(object, WrapletSetSymbol);\n}\n","export class DefaultSearchableSet extends Set {\n find(filter) {\n const results = [];\n for (const item of this) {\n if (!filter(item)) {\n continue;\n }\n results.push(item);\n }\n return results;\n }\n findOne(filter) {\n for (const item of this) {\n if (filter(item)) {\n return item;\n }\n }\n return null;\n }\n getOrdered(callback) {\n return Array.from(this).sort((a, b) => callback(a) - callback(b));\n }\n}\n","const WrapletSetReadonlySymbol = Symbol(\"WrapletSetReadonly\");\nexport { WrapletSetReadonlySymbol };\n","import { WrapletSetSymbol } from \"./types/WrapletSet\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nimport { WrapletSetReadonlySymbol } from \"./types/WrapletSetReadonly\";\nexport class DefaultWrapletSet extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n [WrapletSetSymbol] = true;\n}\n","import { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nexport function isParentNode(node) {\n return (typeof node.querySelectorAll ===\n \"function\");\n}\nexport function getWrapletsFromNode(node) {\n const wraplets = node.wraplets;\n if (!isWrapletSet(wraplets) || wraplets.size === 0) {\n return new DefaultWrapletSet();\n }\n return wraplets;\n}\nexport function removeWrapletFromNode(wraplet, node) {\n if (!node.wraplets) {\n return false;\n }\n return node.wraplets.delete(wraplet);\n}\nexport function addWrapletToNode(wraplet, node) {\n if (!node.wraplets) {\n node.wraplets = new DefaultWrapletSet();\n }\n node.wraplets.add(wraplet);\n}\nexport async function actOnNodesRecursively(node, callback) {\n await callback(node);\n const children = node.childNodes;\n for (const child of children) {\n await actOnNodesRecursively(child, callback);\n }\n}\nexport async function destroyWrapletsRecursively(node) {\n await actOnNodesRecursively(node, async (node) => {\n const wraplets = getWrapletsFromNode(node);\n for (const wraplet of wraplets) {\n if (!wraplet.wraplet.status.isGettingDestroyed &&\n !wraplet.wraplet.status.isDestroyed) {\n await wraplet.wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","import { is } from \"../../utils/is\";\nconst CoreSymbol = Symbol(\"Core\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nexport function addDefaultsToChildDefinition(definition) {\n return {\n ...{\n args: [],\n destructible: true,\n map: {},\n coreOptions: {},\n },\n ...definition,\n };\n}\nexport function fillMapWithDefaults(map) {\n const newMap = {};\n for (const id in map) {\n const def = map[id];\n newMap[id] = addDefaultsToChildDefinition(def);\n const subMap = def[\"map\"];\n if (subMap && isWrapletChildrenMapWithDefaults(subMap)) {\n newMap[id][\"map\"] = fillMapWithDefaults(subMap);\n }\n }\n return newMap;\n}\n","import { is } from \"../../utils/is\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"./utils\";\nimport { isDynamicMap } from \"./types/DynamicMap\";\nexport class MapWrapper {\n fullMap;\n startingPath;\n currentMap = null;\n path;\n currentPath = [];\n /**\n * @param fullMap\n * @param path\n * Path to the current definition.\n * @param resolveImmediately\n */\n constructor(fullMap, path = [], resolveImmediately = true) {\n this.path = path;\n this.startingPath = path;\n this.fullMap = fillMapWithDefaults(fullMap);\n if (resolveImmediately) {\n this.currentMap = this.resolve(this.path);\n }\n }\n getStartingMap() {\n return this.resolve(this.startingPath);\n }\n getCurrentMap() {\n if (!this.currentMap || this.currentPath != this.path) {\n this.currentMap = this.resolve(this.path);\n this.currentPath = this.path;\n }\n return this.currentMap;\n }\n /**\n * @param path\n * @private\n */\n findMap(path) {\n let resultMap = this.fullMap;\n for (const pathPart of path) {\n if (!resultMap[pathPart]) {\n throw new Error(`Invalid path: ${this.path.join(\".\")} . No such definition.`);\n }\n const map = resultMap[pathPart][\"map\"];\n if (isWrapletChildrenMapWithDefaults(map)) {\n resultMap = map;\n }\n else if (isDynamicMap(map)) {\n resultMap = map.create(this.clone(path, false));\n }\n else {\n throw new Error(\"Invalid map type.\");\n }\n }\n return resultMap;\n }\n up(pathPart, resolve = true) {\n if (!this.pathExists([...this.path, pathPart])) {\n throw new Error(\"Map doesn't exist.\");\n }\n this.path.push(pathPart);\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n pathExists(path) {\n let tempMap = this.fullMap;\n for (const pathPart of path) {\n if (!Object.hasOwn(tempMap, pathPart)) {\n return false;\n }\n const map = tempMap[pathPart][\"map\"];\n if (isDynamicMap(map)) {\n return true;\n }\n if (!isWrapletChildrenMapWithDefaults(map)) {\n throw new Error(\"Invalid map type.\");\n }\n tempMap = map;\n }\n return true;\n }\n down(resolve = true) {\n if (this.path.length === 0) {\n throw new Error(\"At the root already.\");\n }\n this.path.pop();\n if (resolve) {\n this.currentMap = this.resolve(this.path);\n }\n }\n clone(path, resolveImmediately = true) {\n return new MapWrapper(this.fullMap, path, resolveImmediately);\n }\n resolve(path) {\n return this.findMap(path);\n }\n}\n","import { is } from \"../../utils/is\";\nconst ArgCreatorSymbol = Symbol(\"ArgCreator\");\nexport { ArgCreatorSymbol };\nexport function isArgCreator(object) {\n return is(object, ArgCreatorSymbol);\n}\n","export function defaultWrapletCreator(args, currentCoreClass) {\n const core = new currentCoreClass(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n}\n","import { ChildrenAreAlreadyDestroyedError, ChildrenAreNotAvailableError, ChildrenTooManyFoundError, InternalLogicError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, UnsupportedNodeTypeError, } from \"../errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"../Wraplet/types/WrapletChildrenMap\";\nimport { isParentNode } from \"../NodeTreeManager/utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"../Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"../Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"../NodeTreeManager/types/NodeTreeParent\";\nimport { MapWrapper } from \"../Map/MapWrapper\";\nimport { isArgCreator } from \"./types/ArgCreator\";\nimport { defaultWrapletCreator } from \"./defaultWrapletCreator\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n childrenAreInstantiated = false;\n statusWritable = {\n isDestroyed: false,\n isGettingDestroyed: false,\n isInitialized: false,\n isGettingInitialized: false,\n };\n get status() {\n return this.statusWritable;\n }\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n wrapletCreator = defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\n if (!(node instanceof Node)) {\n throw new Error(\"The node provided to the Core is not a valid node.\");\n }\n if (isWrapletChildrenMapWithDefaults(map)) {\n this.mapWrapper = new MapWrapper(map);\n }\n else if (map instanceof MapWrapper) {\n this.mapWrapper = map;\n }\n else {\n throw new MapError(\"The map provided to the Core is not a valid map.\");\n }\n this.processInitOptions(initOptions);\n this.instantiatedChildren = {};\n }\n /**\n * Initialize core.\n *\n * We couldn't put this step in the constructor, because during initialization some wraplet\n * processing occurs (instantiate child listeners) that needs access to the children manager,\n * so the children manager has to exist already.\n */\n async initializeChildren() {\n this.statusWritable.isGettingInitialized = true;\n const childInstances = Object.values(this.instantiatedChildren).flatMap((child) => {\n if (!child)\n return [];\n return isWrapletSet(child) ? Array.from(child) : [child];\n });\n await Promise.all(childInstances.map((child) => child.wraplet.initialize()));\n this.statusWritable.isInitialized = true;\n this.statusWritable.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.statusWritable.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get map() {\n return this.mapWrapper.getStartingMap();\n }\n instantiateChildren() {\n const children = this.instantiatedChildren;\n // We check if are dealing with the ParentNode object.\n if (!isParentNode(this.node)) {\n for (const id in this.map) {\n const childDefinition = this.map[id];\n this.validateMapItemForNonParent(id, childDefinition);\n }\n return;\n }\n for (const id in this.map) {\n const childDefinition = this.map[id];\n const multiple = childDefinition.multiple;\n const mapWrapper = this.mapWrapper.clone([...this.mapWrapper.path, id]);\n this.validateMapItem(id, childDefinition);\n if (multiple) {\n // We can assert as much because items\n children[id] = this.instantiateMultipleWrapletsChild(childDefinition, mapWrapper, this.node, id);\n continue;\n }\n children[id] = this.instantiateSingleWrapletChild(childDefinition, mapWrapper, this.node, id);\n }\n if (!this.childrenAreInstantiated) {\n this.instantiatedChildren = this.wrapChildren(children);\n this.childrenAreInstantiated = true;\n }\n }\n async syncChildren() {\n this.instantiateChildren();\n await this.initializeChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\n if (child === null) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n children.push(item);\n }\n }\n else {\n children.push(child);\n }\n }\n // Return only descendants.\n return children.filter((child) => {\n let result = false;\n child.wraplet.accessNode((childsNode) => {\n result = this.node.contains(childsNode);\n });\n return result;\n });\n }\n findExistingWraplet(id, childElement) {\n // If a child doesn't have instantiated wraplets yet, then return null.\n if (this.instantiatedChildren === undefined ||\n !this.instantiatedChildren[id]) {\n return null;\n }\n const existingChild = this.instantiatedChildren[id];\n // Handle multiple.\n if (this.map[id][\"multiple\"]) {\n if (!isWrapletSet(existingChild)) {\n throw new InternalLogicError(\"Internal logic error. Expected a WrapletSet.\");\n }\n const existingWraplets = existingChild.find((wraplet) => {\n let result = false;\n wraplet.wraplet.accessNode((node) => {\n if (node === childElement) {\n result = true;\n }\n });\n return result;\n });\n if (existingWraplets.length === 0) {\n return null;\n }\n if (existingWraplets.length > 1) {\n throw new InternalLogicError(\"Internal logic error. Multiple instances wrapping the same element found in the core.\");\n }\n return existingWraplets[0];\n }\n // Handle single.\n return existingChild;\n }\n instantiateSingleWrapletChild(childDefinition, childMap, node, id) {\n if (!childDefinition.selector) {\n return null;\n }\n const selector = childDefinition.selector;\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n if (childElements.length === 0) {\n return null;\n }\n if (childElements.length > 1) {\n throw new ChildrenTooManyFoundError(`${this.constructor.name}: More than one element was found for the \"${id}\" child. Selector used: \"${selector}\".`);\n }\n const childElement = childElements[0];\n return this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n }\n instantiateWrapletItem(id, childDefinition, childMap, node) {\n // Re-use existing wraplet.\n const existingWraplet = this.findExistingWraplet(id, node);\n if (existingWraplet) {\n return existingWraplet;\n }\n const wrapletClass = childDefinition.Class;\n const creatorArgs = {\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: childDefinition.args,\n };\n creatorArgs.args = creatorArgs.args.map((arg) => {\n if (isArgCreator(arg)) {\n return arg.createArg(creatorArgs);\n }\n return arg;\n });\n let wraplet = null;\n try {\n wraplet = this.wrapletCreator(creatorArgs, this.constructor);\n }\n catch (e) {\n if (e instanceof UnsupportedNodeTypeError) {\n if (!childDefinition.required) {\n console.warn(`${e.message} Skipping instantiation of the \"${id}\" child.`);\n return null;\n }\n }\n throw e;\n }\n this.prepareIndividualWraplet(id, wraplet);\n for (const listener of this.instantiateChildListeners) {\n listener(wraplet, id);\n }\n return wraplet;\n }\n instantiateMultipleWrapletsChild(childDefinition, childMap, node, id) {\n const selector = childDefinition.selector;\n if (!selector) {\n return new DefaultWrapletSet();\n }\n // Find children elements based on the map.\n const childElements = this.findChildren(selector, node);\n this.validateElements(id, childElements, childDefinition);\n const items = this.instantiatedChildren && this.instantiatedChildren[id]\n ? this.instantiatedChildren[id]\n : new DefaultWrapletSet();\n for (const childElement of childElements) {\n const existingWraplet = this.findExistingWraplet(id, childElement);\n if (existingWraplet) {\n continue;\n }\n const wraplet = this.instantiateWrapletItem(id, childDefinition, childMap, childElement);\n if (wraplet) {\n items.add(wraplet);\n }\n }\n return items;\n }\n addDestroyChildListener(callback) {\n this.destroyChildListeners.push(callback);\n }\n addInstantiateChildListener(callback) {\n this.instantiateChildListeners.push(callback);\n }\n setWrapletCreator(wrapletCreator) {\n this.wrapletCreator = wrapletCreator;\n }\n prepareIndividualWraplet(id, wraplet) {\n const destroyListener = ((wraplet) => {\n this.removeChild(wraplet, id);\n for (const listener of this.destroyChildListeners) {\n listener(wraplet, id);\n }\n });\n // Listen for the child's destruction.\n wraplet.wraplet.addDestroyListener(destroyListener);\n }\n /**\n * This method removes from nodes references to this wraplet and its children recursively.\n */\n async destroy() {\n if (this.statusWritable.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.statusWritable.isGettingDestroyed = true;\n if (this.statusWritable.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return;\n }\n if (!this.statusWritable.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n return;\n }\n // Remove listeners.\n for (const listener of this.listeners) {\n const node = listener.node;\n const eventName = listener.eventName;\n const callback = listener.callback;\n const options = listener.options;\n node.removeEventListener(eventName, callback, options);\n }\n this.listeners.length = 0;\n await this.destroyChildren();\n this.statusWritable.isInitialized = false;\n this.statusWritable.isDestroyed = true;\n this.statusWritable.isGettingDestroyed = false;\n }\n findChildren(selector, node) {\n const defaultSelectorCallback = (selector, node) => {\n return Array.from(node.querySelectorAll(selector));\n };\n // Find children elements based on the map.\n return typeof selector === \"string\"\n ? defaultSelectorCallback(selector, node)\n : selector(node);\n }\n addEventListener(node, eventName, callback, options) {\n this.listeners.push({ node, eventName, callback, options });\n node.addEventListener(eventName, callback, options);\n }\n get children() {\n if (!this.childrenAreInstantiated) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.\");\n }\n return this.instantiatedChildren;\n }\n removeChild(wraplet, id) {\n if (isWrapletSet(this.instantiatedChildren[id])) {\n if (!this.instantiatedChildren[id].delete(wraplet)) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's not among the children.\");\n }\n return;\n }\n if (this.map[id].required && !this.statusWritable.isGettingDestroyed) {\n throw new RequiredChildDestroyedError(\"Required child has been destroyed.\");\n }\n if (this.instantiatedChildren[id] === null) {\n throw new InternalLogicError(\"Internal logic error. Destroyed child couldn't be removed because it's already null.\");\n }\n // @ts-expect-error The type is unknown because we are dealing with a generic here.\n this.instantiatedChildren[id] = null;\n }\n validateMapItem(id, item) {\n const selector = item.selector;\n const isRequired = item.required;\n if (!selector) {\n if (isRequired) {\n throw new MapError(`${this.constructor.name}: Child \"${id}\" cannot at the same be required and have no selector.`);\n }\n }\n }\n validateMapItemForNonParent(id, item) {\n if (item.required) {\n throw new MapError(`Dependency \"${id}\" error: If the node provided cannot have children, there should be no required children.`);\n }\n }\n validateElements(id, elements, mapItem) {\n if (elements.length === 0 && mapItem.required) {\n throw new MissingRequiredChildError(`${this.constructor.name}: Couldn't find a node for the wraplet \"${id}\". Selector used: \"${mapItem.selector}\".`);\n }\n }\n /**\n * Set up a proxy to check if children have not been destroyed before fetching them.\n */\n wrapChildren(children) {\n return new Proxy(children, {\n get: function get(target, name) {\n if (!(name in target)) {\n throw new Error(`Child '${name}' has not been found.`);\n }\n return target[name];\n },\n });\n }\n defaultInitOptions() {\n return {\n instantiateChildListeners: [],\n destroyChildListeners: [],\n };\n }\n processInitOptions(initOptionsPartial) {\n const initOptions = Object.assign(this.defaultInitOptions(), initOptionsPartial);\n for (const listener of initOptions.instantiateChildListeners) {\n this.instantiateChildListeners.push(listener);\n }\n for (const listener of initOptions.destroyChildListeners) {\n this.destroyChildListeners.push(listener);\n }\n }\n async destroyChildren() {\n for (const [key, child] of Object.entries(this.children)) {\n if (!child || !this.map[key][\"destructible\"]) {\n continue;\n }\n if (isWrapletSet(child)) {\n for (const item of child) {\n await item.wraplet.destroy();\n }\n }\n else {\n await child.wraplet.destroy();\n }\n }\n }\n}\n","import { ArgCreatorSymbol } from \"./types/ArgCreator\";\nexport class DefaultArgCreator {\n creator;\n [ArgCreatorSymbol] = true;\n constructor(creator) {\n this.creator = creator;\n }\n createArg(args) {\n return this.creator(args);\n }\n static create(creator) {\n return new DefaultArgCreator(creator);\n }\n}\n","import { is } from \"../../utils/is\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"../utils/is\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","export async function initializationStarted(status, core) {\n if (status.isInitialized) {\n return false;\n }\n status.isGettingInitialized = true;\n await core.initializeChildren();\n return true;\n}\nexport async function initializationCompleted(status, destroyMethod) {\n status.isInitialized = true;\n status.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (status.isGettingDestroyed) {\n await destroyMethod();\n }\n}\nexport async function destructionStarted(status, core, wraplet, destroyListeners) {\n if (status.isDestroyed) {\n return false;\n }\n status.isGettingDestroyed = true;\n if (status.isGettingInitialized) {\n // If we are still initializing, then postpone destruction until after\n // initialization is finished.\n // We are leaving this method, but with `isGettingDestroyed` set to true, so\n // the initialization process will know to return here after it will finish.\n return false;\n }\n if (!status.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n status.isDestroyed = true;\n status.isGettingDestroyed = false;\n return false;\n }\n await core.destroy();\n for (const listener of destroyListeners) {\n await listener(wraplet);\n }\n return true;\n}\nexport async function destructionCompleted(status) {\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n}\n","import { initializationCompleted, initializationStarted, } from \"../Wraplet/statusActions\";\n/**\n * Note: If status is not provided, this function will attempt to get it from \"this\".\n */\nexport function createDefaultInitializeCallback(args, customInitializeLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot initialize without status available.\");\n }\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n const outerStatus = args.status || this.status;\n if (!(await initializationStarted(outerStatus, args.core))) {\n return;\n }\n if (customInitializeLogic) {\n await customInitializeLogic();\n }\n await initializationCompleted(outerStatus, args.destroyCallback);\n };\n}\n","import { destructionCompleted, destructionStarted, } from \"../Wraplet/statusActions\";\nexport function createDefaultDestroyCallback(args, customDestroyLogic) {\n return async function () {\n // @ts-expect-error \"this\" is a fallback if status is not provided.\n if (!args.status && (!this || !this.status)) {\n throw new Error(\"Cannot destroy without status available.\");\n }\n // @ts-expect-error Default callbacks depend on the status from the outer object for the easier usage.\n const outerStatus = args.status || this.status;\n if (!(await destructionStarted(outerStatus, args.core, args.wraplet, args.destroyListeners))) {\n return;\n }\n if (customDestroyLogic) {\n await customDestroyLogic();\n }\n await destructionCompleted(outerStatus);\n };\n}\n","import { createDefaultInitializeCallback } from \"../Wraplet/createDefaultInitializeCallback\";\nimport { createDefaultDestroyCallback } from \"../Wraplet/createDefaultDestroyCallback\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\n const api = {};\n const destroyListeners = args.destroyListeners || [];\n const destroyCallback = args.destroyCallback ||\n createDefaultDestroyCallback({\n core: args.core,\n wraplet: args.wraplet,\n destroyListeners: destroyListeners,\n }).bind(api);\n api.destroy = destroyCallback;\n const initializeCallback = args.initializeCallback ||\n createDefaultInitializeCallback({\n core: args.core,\n destroyCallback: api.destroy,\n }).bind(api);\n return Object.assign(api, {\n __nodeAccessors: nodeAccessors,\n status: {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n },\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: initializeCallback,\n destroy: destroyCallback,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\n });\n};\n","import { defaultGroupableAttribute } from \"../types/Groupable\";\nimport { createWrapletApi } from \"./createWrapletApi\";\nexport const createRichWrapletApi = (args) => {\n const defaultGroupExtractor = (node) => {\n if (node instanceof Element) {\n const groupsString = node.getAttribute(defaultGroupableAttribute);\n if (groupsString) {\n return groupsString.split(\",\");\n }\n }\n return [];\n };\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n return Object.assign(createWrapletApi(args), {\n getNodeTreeChildren: () => {\n return args.core.getNodeTreeChildren();\n },\n setGroupsExtractor: (extractor) => {\n groupExtractor = extractor;\n },\n getGroups: () => {\n return groupExtractor(args.core.node);\n },\n });\n};\n","import { WrapletSymbol } from \"./Wraplet/types/Wraplet\";\nimport { GroupableSymbol } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol, } from \"./NodeTreeManager/types/NodeTreeParent\";\nimport { isCore } from \"./Core/types/Core\";\nimport { DefaultCore } from \"./Core/DefaultCore\";\nimport { createRichWrapletApi } from \"./Wraplet/createRichWrapletApi\";\nimport { UnsupportedNodeTypeError } from \"./errors\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n destroyListeners = [];\n wraplet;\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n const supportedNodeTypes = this.supportedNodeTypes();\n if (supportedNodeTypes !== null) {\n if (!supportedNodeTypes.find((value) => core.node instanceof value)) {\n throw new UnsupportedNodeTypeError(`Node type ${core.node.constructor.name} is not supported by the ${this.constructor.name} wraplet.`);\n }\n }\n core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n core.instantiateChildren();\n this.wraplet = createRichWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n get children() {\n return this.core.children;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been destroyed.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onChildDestroy(child, id) { }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be invoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiate(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n child, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id) { }\n /**\n * Subclasses must return an array of constructors covering all types in union N.\n * Wrap the result in the `supportedTypeCheck` helper to make sure that the array contains all\n * and only classes that extend the given type.\n */\n supportedNodeTypes() {\n return null;\n }\n /**\n * Helper for subclasses to easily satisfy the exhaustive check.\n */\n supportedNodeTypesGuard(types) {\n return types;\n }\n /**\n * This method makes sure that the given instance is an instance of a class belonging to the\n * given child.\n *\n * @param item\n * @param actualUnknownId\n * @param onlyId\n * By hardcoding onlyId you can filter out any other children. It allows you to learn not only\n * that the class is correct, but also that the child is correct (in case multiple children can\n * use the same class).\n * @protected\n */\n isChildInstance(item, actualUnknownId, onlyId = null) {\n return (actualUnknownId === (onlyId || actualUnknownId) &&\n item instanceof this.core.map[actualUnknownId][\"Class\"]);\n }\n static createCore(node, map) {\n return new DefaultCore(node, map);\n }\n // We can afford \"any\" here because this method is only for the external usage, and external\n // callers don't need to know what map is the current wraplet using, as it's its internal\n // matter.\n static createWraplets(node, map, attribute, additional_args = []) {\n if (this === AbstractWraplet) {\n throw new Error(\"You cannot instantiate an abstract class.\");\n }\n const result = [];\n if (node instanceof Element && node.hasAttribute(attribute)) {\n const core = this.createCore(node, map);\n result.push(new this(core, ...additional_args));\n }\n const foundElements = node.querySelectorAll(`[${attribute}]`);\n for (const element of foundElements) {\n const core = this.createCore(element, map);\n result.push(new this(core, ...additional_args));\n }\n return result;\n }\n}\n","import { DynamicMapSymbol } from \"./types/DynamicMap\";\nexport class MapRepeat {\n levels;\n [DynamicMapSymbol] = true;\n constructor(levels = 1) {\n this.levels = levels;\n if (levels < 1) {\n throw new Error(\"There have to be more than 0 repeated levels.\");\n }\n }\n create(parentMapClone) {\n for (let i = 0; i < this.levels; i++) {\n parentMapClone.down();\n }\n return parentMapClone.getCurrentMap();\n }\n static create(levels = 1) {\n return new MapRepeat(levels);\n }\n}\n","import { WrapletSetReadonlySymbol, } from \"./types/WrapletSetReadonly\";\nimport { DefaultSearchableSet } from \"./DefaultSearchableSet\";\nexport class DefaultWrapletSetReadonly extends DefaultSearchableSet {\n [WrapletSetReadonlySymbol] = true;\n}\n","export function customizeDefaultWrapletApi(args, wrapletApi) {\n if (!args.status && (args.destroy || args.initialize)) {\n throw new Error(\"Cannot customize lifecycle callbacks without providing status. This is because all callbacks have to share the same status.\");\n }\n // We don't want to create a new object because the default callbacks are bound to the old one.\n return Object.assign(wrapletApi, args);\n}\n"],"names":["MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","StorageValidationError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","UnsupportedNodeTypeError","isWrapletChildrenMapWithDefaults","object","Object","getPrototypeOf","prototype","symbol","WrapletSetSymbol","Symbol","isWrapletSet","DefaultSearchableSet","Set","find","filter","results","item","this","push","findOne","getOrdered","callback","Array","from","sort","a","b","WrapletSetReadonlySymbol","getWrapletsFromNode","node","wraplets","size","removeWrapletFromNode","wraplet","delete","async","actOnNodesRecursively","children","childNodes","child","destroyWrapletsRecursively","status","isGettingDestroyed","isDestroyed","destroy","CoreSymbol","NodeTreeParentSymbol","addDefaultsToChildDefinition","definition","args","destructible","map","coreOptions","fillMapWithDefaults","newMap","id","def","subMap","DynamicMapSymbol","isDynamicMap","MapWrapper","fullMap","startingPath","currentMap","path","currentPath","constructor","resolveImmediately","resolve","getStartingMap","getCurrentMap","findMap","resultMap","pathPart","join","create","clone","up","pathExists","tempMap","hasOwn","down","length","pop","ArgCreatorSymbol","defaultWrapletCreator","currentCoreClass","core","element","initOptions","Class","DefaultCore","childrenAreInstantiated","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","Node","processInitOptions","initializeChildren","childInstances","values","flatMap","Promise","all","initialize","instantiateChildren","querySelectorAll","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","wrapChildren","validateMapItemForNonParent","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","e","required","console","warn","message","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","isRequired","elements","mapItem","Proxy","get","target","defaultInitOptions","initOptionsPartial","assign","key","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","initializationStarted","initializationCompleted","destroyMethod","destructionStarted","destroyListeners","destructionCompleted","createDefaultInitializeCallback","customInitializeLogic","outerStatus","destroyCallback","createDefaultDestroyCallback","customDestroyLogic","createWrapletApi","nodeAccessors","api","bind","initializeCallback","__nodeAccessors","createRichWrapletApi","groupExtractor","Element","groupsString","getAttribute","split","setGroupsExtractor","extractor","getGroups","AbstractWraplet","supportedNodeTypes","value","onChildDestroy","onChildInstantiate","supportedNodeTypesGuard","types","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly","customizeDefaultWrapletApi","wrapletApi"],"ignoreList":[],"sourceRoot":""}
|