wraplet 0.28.0 → 0.29.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.
Files changed (60) hide show
  1. package/dist/AbstractWraplet.d.ts +16 -28
  2. package/dist/Core/DefaultArgCreator.d.ts +10 -0
  3. package/dist/{DefaultCore.d.ts → Core/DefaultCore.d.ts} +9 -11
  4. package/dist/Core/defaultWrapletCreator.d.ts +6 -0
  5. package/dist/Core/types/ArgCreator.d.ts +9 -0
  6. package/dist/{types → Core/types}/Core.d.ts +8 -21
  7. package/dist/{types → Core/types}/CoreInitOptions.d.ts +1 -1
  8. package/dist/Core/types/DestroyChildListener.d.ts +3 -0
  9. package/dist/{types → Core/types}/DestroyListener.d.ts +1 -1
  10. package/dist/Core/types/InstantiateChildListener.d.ts +3 -0
  11. package/dist/Core/types/WrapletCreator.d.ts +15 -0
  12. package/dist/Map/MapRepeat.d.ts +1 -1
  13. package/dist/Map/MapWrapper.d.ts +1 -1
  14. package/dist/Map/types/DynamicMap.d.ts +1 -1
  15. package/dist/{WrapletChildrenMap.d.ts → Map/utils.d.ts} +2 -2
  16. package/dist/NodeTreeManager/DefaultNodeTreeManager.d.ts +2 -2
  17. package/dist/NodeTreeManager/{NodeTreeManager.d.ts → types/NodeTreeManager.d.ts} +2 -2
  18. package/dist/{types → NodeTreeManager/types}/NodeTreeParent.d.ts +4 -2
  19. package/dist/{utils.d.ts → NodeTreeManager/utils.d.ts} +2 -2
  20. package/dist/Set/DefaultWrapletSet.d.ts +1 -1
  21. package/dist/Set/DefaultWrapletSetReadonly.d.ts +1 -1
  22. package/dist/Set/types/WrapletSet.d.ts +1 -1
  23. package/dist/Set/types/WrapletSetReadonly.d.ts +1 -1
  24. package/dist/Storage/{AbstractNongranularStorage.d.ts → AbstractNongranularKeyValueStorage.d.ts} +3 -2
  25. package/dist/Storage/ElementAttributeStorage.d.ts +2 -2
  26. package/dist/Storage/ElementStorage.d.ts +2 -2
  27. package/dist/Storage/InMemoryKeyValueStorage.d.ts +0 -0
  28. package/dist/Storage/StorageWrapper.d.ts +4 -3
  29. package/dist/Storage/types/KeyValueStorage.d.ts +13 -0
  30. package/dist/Storage/types/{StorageReadonly.d.ts → KeyValueStorageReadonly.d.ts} +1 -1
  31. package/dist/Wraplet/createWrapletApi.d.ts +6 -0
  32. package/dist/Wraplet/types/Status.d.ts +9 -0
  33. package/dist/Wraplet/types/Wraplet.d.ts +8 -0
  34. package/dist/Wraplet/types/WrapletApi.d.ts +12 -0
  35. package/dist/Wraplet/types/WrapletApiFactoryArgs.d.ts +16 -0
  36. package/dist/Wraplet/types/WrapletApiFactoryBasicCallback.d.ts +1 -0
  37. package/dist/{types → Wraplet/types}/WrapletChildDefinition.d.ts +3 -3
  38. package/dist/{types → Wraplet/types}/WrapletChildren.d.ts +2 -2
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +14 -9
  42. package/dist/index.js +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/storage.cjs +1 -1
  45. package/dist/storage.cjs.map +1 -1
  46. package/dist/storage.d.ts +3 -2
  47. package/dist/storage.js +1 -1
  48. package/dist/storage.js.map +1 -1
  49. package/dist/types/Groupable.d.ts +4 -2
  50. package/dist/utils/is.d.ts +5 -0
  51. package/dist/{types → utils/types}/Utils.d.ts +0 -5
  52. package/package.json +1 -1
  53. package/dist/Storage/types/Storage.d.ts +0 -9
  54. package/dist/Storage/types/StorageDefaults.d.ts +0 -1
  55. package/dist/types/DestroyChildListener.d.ts +0 -3
  56. package/dist/types/InstantiateChildListener.d.ts +0 -3
  57. package/dist/types/Wraplet.d.ts +0 -15
  58. package/dist/types/WrapletCreator.d.ts +0 -15
  59. /package/dist/{types → Wraplet/types}/ChildInstance.d.ts +0 -0
  60. /package/dist/{types → Wraplet/types}/WrapletChildrenMap.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","mappings":"AACA,IAAIA,EAAsB,C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B,OAAO,IAAIiC,EAAYrD,EAAMoB,EACjC,CAIA,qBAAOkI,CAAetJ,EAAMoB,EAAKmI,EAAWC,EAAkB,IAC1D,GAAIpK,OAASiJ,EACT,MAAM,IAAIpK,MAAM,6CAEpB,MAAMoH,EAAS,GACf,GAAIrF,aAAgBuI,SAAWvI,EAAKyJ,aAAaF,GAAY,CACzD,MAAMzF,EAAOuE,EAAgBgB,WAAWrJ,EAAMoB,GAC9CiE,EAAOhG,KAAK,IAAID,KAAK0E,KAAS0F,GAClC,CACA,MAAME,EAAgB1J,EAAK4E,iBAAiB,IAAI2E,MAChD,IAAK,MAAMxF,KAAW2F,EAAe,CACjC,MAAM5F,EAAOuE,EAAgBgB,WAAWtF,EAAS3C,GACjDiE,EAAOhG,KAAK,IAAID,KAAK0E,KAAS0F,GAClC,CACA,OAAOnE,CACX,ECjJG,MAAMsE,EACTC,OACA,CAACjI,IAAoB,EACrB,WAAAQ,CAAYyH,EAAS,GAEjB,GADAxK,KAAKwK,OAASA,EACVA,EAAS,EACT,MAAM,IAAI3L,MAAM,gDAExB,CACA,MAAA2E,CAAOiH,GACH,IAAK,IAAIC,EAAI,EAAGA,EAAI1K,KAAKwK,OAAQE,IAC7BD,EAAe3G,OAEnB,OAAO2G,EAAetH,eAC1B,CACA,aAAOK,CAAOgH,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkCjL,EAC3C,CAACgB,IAA4B,E","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/types/WrapletChildrenMap.ts","webpack://wraplet/./src/types/Utils.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/utils.ts","webpack://wraplet/./src/types/NodeTreeParent.ts","webpack://wraplet/./src/types/Core.ts","webpack://wraplet/./src/WrapletChildrenMap.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/DefaultCore.ts","webpack://wraplet/./src/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.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}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/* istanbul ignore next */\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 \"../../types/Utils\";\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.isGettingDestroyed && !wraplet.isDestroyed) {\n await wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\n/* istanbul ignore next */\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { is } from \"./Utils\";\nimport { NodeTreeParentSymbol } from \"./NodeTreeParent\";\nconst CoreSymbol = Symbol(\"ChildrenManager\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"./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 \"../../types/Utils\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"../WrapletChildrenMap\";\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 { ChildrenAreNotAvailableError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, ChildrenTooManyFoundError, ChildrenAreAlreadyDestroyedError, InternalLogicError, } from \"./errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"./types/WrapletChildrenMap\";\nimport { isParentNode } from \"./utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"./Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"./Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"./types/NodeTreeParent\";\nimport { MapWrapper } from \"./Map/MapWrapper\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n isDestroyed = false;\n isGettingDestroyed = false;\n isGettingInitialized = false;\n isInitialized = false;\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n defaultWrapletCreator = (args) => {\n const core = new this.constructor(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n };\n wrapletCreator = this.defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\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 initialize() {\n this.isGettingInitialized = true;\n const children = this.instantiateChildren();\n this.instantiatedChildren = this.wrapChildren(children);\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.initialize()));\n this.isInitialized = true;\n this.isGettingInitialized = false;\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 if (Object.keys(this.map).length > 0) {\n throw new MapError(\"If the node provided cannot have children, the children map should be empty.\");\n }\n return children;\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 // Now we should have all properties set, so let's assert the final form.\n return children;\n }\n syncChildren() {\n this.instantiatedChildren = this.instantiateChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\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.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.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 args = childDefinition.args;\n const wraplet = this.wrapletCreator({\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: args,\n defaultCreator: this.defaultWrapletCreator,\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 items.add(wraplet);\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.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.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.isGettingDestroyed = true;\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 await this.destroyChildren();\n this.isGettingDestroyed = false;\n this.isDestroyed = true;\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.isInitialized) {\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 get uninitializedChildren() {\n if (this.isInitialized) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");\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.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 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.destroy();\n }\n }\n else {\n await child.destroy();\n }\n }\n }\n}\n","import { is } from \"./Utils\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"./Utils\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\n/* istanbul ignore next */\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","import { WrapletSymbol } from \"./types/Wraplet\";\nimport { defaultGroupableAttribute, GroupableSymbol, } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol } from \"./types/NodeTreeParent\";\nimport { isCore } from \"./types/Core\";\nimport { DefaultCore } from \"./DefaultCore\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n isGettingDestroyed = false;\n isDestroyed = false;\n isGettingInitialized = false;\n isInitialized = false;\n groupsExtractor = (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 destroyListeners = [];\n /**\n * This is the log of all node accessors, available for easier debugging.\n */\n __debugNodeAccessors = [];\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n core.addDestroyChildListener(this.onChildDestroyed.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiated.bind(this));\n }\n getNodeTreeChildren() {\n return this.core.getNodeTreeChildren();\n }\n setGroupsExtractor(callback) {\n this.groupsExtractor = callback;\n }\n getGroups() {\n return this.groupsExtractor(this.node);\n }\n get children() {\n return this.core.children;\n }\n accessNode(callback) {\n this.__debugNodeAccessors.push(callback);\n callback(this.node);\n }\n async destroy() {\n if (this.isDestroyed) {\n // We are already destroyed.\n return;\n }\n this.isGettingDestroyed = true;\n if (this.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.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.isDestroyed = true;\n this.isGettingDestroyed = false;\n return;\n }\n for (const listener of this.destroyListeners) {\n await listener(this);\n }\n this.destroyListeners.length = 0;\n await this.core.destroy();\n this.isDestroyed = true;\n this.isGettingDestroyed = false;\n }\n addDestroyListener(callback) {\n this.destroyListeners.push(callback);\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 onChildDestroyed(child, id) { }\n async initialize() {\n this.isGettingInitialized = true;\n await this.core.initialize();\n this.isInitialized = true;\n this.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiated(\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 * 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 = AbstractWraplet.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 = AbstractWraplet.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"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","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","isGettingDestroyed","isDestroyed","destroy","NodeTreeParentSymbol","CoreSymbol","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","DefaultCore","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","core","element","initOptions","Class","wrapletCreator","processInitOptions","initialize","instantiateChildren","wrapChildren","childInstances","values","flatMap","Promise","all","querySelectorAll","keys","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","wrapletClass","defaultCreator","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","uninitializedChildren","required","isRequired","elements","mapItem","Proxy","target","defaultInitOptions","initOptionsPartial","assign","entries","WrapletSymbol","isWraplet","GroupableSymbol","AbstractWraplet","groupsExtractor","Element","groupsString","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","setGroupsExtractor","getGroups","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly"],"ignoreList":[],"sourceRoot":""}
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,oQCLhD,MAAMC,UAAkCC,OAExC,MAAMC,UAAiBD,OAEvB,MAAME,UAAoCF,OAE1C,MAAMG,UAAqCH,OAI3C,MAAMI,UAAkCJ,OAExC,MAAMK,UAAyCL,OAE/C,MAAMM,UAA2BN,OCdjC,SAASO,EAAiCC,GAC7C,OAAOrB,OAAOsB,eAAeD,KAAYrB,OAAOM,SACpD,CCCA,MAAM,EAAK,CAACe,EAAQE,IACU,iBAAXF,GACA,OAAXA,IACmB,IAAnBA,EAAOE,GCLTC,EAAmBf,OAAO,cAEzB,SAASgB,EAAaJ,GACzB,OAAO,EAAGA,EAAQG,EACtB,CCLO,MAAME,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,KAAQC,KACf,GAAIH,EAAOE,GACP,OAAOA,EAGf,OAAO,IACX,CACA,UAAAI,CAAWC,GACP,OAAOC,MAAMC,KAAKN,MAAMO,KAAK,CAACC,EAAGC,IAAML,EAASI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AAMqB,GACpB,OAAO,IAAIwC,EAAY7D,EAAMqB,EACjC,CAIA,qBAAO8I,CAAenK,EAAMqB,EAAK+I,EAAWC,EAAkB,IAC1D,GAAIjL,OAASwJ,EACT,MAAM,IAAI3K,MAAM,6CAEpB,MAAMwH,EAAS,GACf,GAAIzF,aAAgBoJ,SAAWpJ,EAAKsK,aAAaF,GAAY,CACzD,MAAM3G,EAAOrE,KAAK8K,WAAWlK,EAAMqB,GACnCoE,EAAOpG,KAAK,IAAID,KAAKqE,KAAS4G,GAClC,CACA,MAAME,EAAgBvK,EAAKgF,iBAAiB,IAAIoF,MAChD,IAAK,MAAM1G,KAAW6G,EAAe,CACjC,MAAM9G,EAAOrE,KAAK8K,WAAWxG,EAASrC,GACtCoE,EAAOpG,KAAK,IAAID,KAAKqE,KAAS4G,GAClC,CACA,OAAO5E,CACX,EEpFG,MAAM+E,EACTC,OACA,CAAC7I,IAAoB,EACrB,WAAAQ,CAAYqI,EAAS,GAEjB,GADArL,KAAKqL,OAASA,EACVA,EAAS,EACT,MAAM,IAAIxM,MAAM,gDAExB,CACA,MAAA4E,CAAO6H,GACH,IAAK,IAAIC,EAAI,EAAGA,EAAIvL,KAAKqL,OAAQE,IAC7BD,EAAevH,OAEnB,OAAOuH,EAAelI,eAC1B,CACA,aAAOK,CAAO4H,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkC9L,EAC3C,CAACgB,IAA4B,E","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/AbstractWraplet.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.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}\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(\"ChildrenManager\");\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, } 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 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 (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 initialize() {\n this.statusWritable.isGettingInitialized = true;\n const children = this.instantiateChildren();\n this.instantiatedChildren = this.wrapChildren(children);\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 if (Object.keys(this.map).length > 0) {\n throw new MapError(\"If the node provided cannot have children, the children map should be empty.\");\n }\n return children;\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 // Now we should have all properties set, so let's assert the final form.\n return children;\n }\n syncChildren() {\n this.instantiatedChildren = this.instantiateChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\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 const wraplet = this.wrapletCreator(creatorArgs, this.constructor);\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 items.add(wraplet);\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.statusWritable.isInitialized) {\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 get uninitializedChildren() {\n if (this.statusWritable.isInitialized) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");\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 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","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 { createWrapletApi } from \"./Wraplet/createWrapletApi\";\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 core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n this.wraplet = this.createWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n createWrapletApi(args) {\n return createWrapletApi(args);\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 * 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 { defaultGroupableAttribute, } from \"../types/Groupable\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\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 const destroyListeners = args.destroyListeners || [];\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n const destroyCallback = args.destroyCallback;\n const defaultStatus = {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n };\n const status = args.status || defaultStatus;\n const initializeCallback = args.initializeCallback;\n const destroyMethod = async () => {\n if (status.isDestroyed) {\n return;\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;\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;\n }\n await args.core.destroy();\n for (const listener of destroyListeners) {\n await listener(args.wraplet);\n }\n if (destroyCallback) {\n await destroyCallback();\n }\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n };\n return {\n __nodeAccessors: nodeAccessors,\n status: status,\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: async () => {\n if (status.isInitialized) {\n return;\n }\n status.isGettingInitialized = true;\n await args.core.initialize();\n if (initializeCallback) {\n await initializeCallback();\n }\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 },\n destroy: destroyMethod,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\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 { 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"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","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","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","processInitOptions","initialize","instantiateChildren","wrapChildren","childInstances","values","flatMap","Promise","all","querySelectorAll","keys","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","uninitializedChildren","required","isRequired","elements","mapItem","Proxy","target","defaultInitOptions","initOptionsPartial","assign","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","AbstractWraplet","destroyListeners","onChildDestroy","bind","onChildInstantiate","createWrapletApi","nodeAccessors","groupExtractor","Element","groupsString","getAttribute","split","destroyCallback","initializeCallback","destroyMethod","__nodeAccessors","setGroupsExtractor","extractor","getGroups","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly"],"ignoreList":[],"sourceRoot":""}
package/dist/index.d.ts CHANGED
@@ -1,17 +1,22 @@
1
- export type { Core } from "./types/Core";
2
- export type { WrapletCreator } from "./types/WrapletCreator";
3
- export { DefaultCore } from "./DefaultCore";
1
+ export type { Core } from "./Core/types/Core";
2
+ export type { WrapletCreator } from "./Core/types/WrapletCreator";
3
+ export type { ArgCreator } from "./Core/types/ArgCreator";
4
+ export { DefaultCore } from "./Core/DefaultCore";
5
+ export { DefaultArgCreator } from "./Core/DefaultArgCreator";
6
+ export { defaultWrapletCreator } from "./Core/defaultWrapletCreator";
4
7
  export { AbstractWraplet } from "./AbstractWraplet";
5
- export { destroyWrapletsRecursively, getWrapletsFromNode } from "./utils";
8
+ export { destroyWrapletsRecursively, getWrapletsFromNode, } from "./NodeTreeManager/utils";
6
9
  export type { DynamicMap } from "./Map/types/DynamicMap";
7
10
  export { MapRepeat } from "./Map/MapRepeat";
8
11
  export type { WrapletSetReadonly } from "./Set/types/WrapletSetReadonly";
9
12
  export type { WrapletSet } from "./Set/types/WrapletSet";
10
13
  export { DefaultWrapletSetReadonly } from "./Set/DefaultWrapletSetReadonly";
11
14
  export { DefaultWrapletSet } from "./Set/DefaultWrapletSet";
12
- export { isWraplet } from "./types/Wraplet";
13
- export type { WrapletChildrenMap } from "./types/WrapletChildrenMap";
14
- export type { Wraplet } from "./types/Wraplet";
15
- export type { SelectorCallback } from "./types/WrapletChildDefinition";
16
- export type { Constructable } from "./types/Utils";
15
+ export type { Wraplet } from "./Wraplet/types/Wraplet";
16
+ export type { WrapletApi } from "./Wraplet/types/WrapletApi";
17
+ export type { Status } from "./Wraplet/types/Status";
18
+ export { isWraplet } from "./Wraplet/types/Wraplet";
19
+ export type { WrapletChildrenMap } from "./Wraplet/types/WrapletChildrenMap";
20
+ export type { SelectorCallback } from "./Wraplet/types/WrapletChildDefinition";
21
+ export type { Constructable } from "./utils/types/Utils";
17
22
  import "./types/global";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- class t extends Error{}class e extends Error{}class i extends Error{}class r extends Error{}class s extends Error{}class n extends Error{}class a extends Error{}function o(t){return Object.getPrototypeOf(t)===Object.prototype}const h=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],l=Symbol("WrapletSet");function d(t){return h(t,l)}class c 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 p=Symbol("WrapletSetReadonly");class u extends c{[p]=!0;[l]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new u}function y(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function w(t,e){await e(t);const i=t.childNodes;for(const t of i)await w(t,e)}async function C(t){await w(t,async t=>{const e=f(t);for(const i of e)i.isGettingDestroyed||i.isDestroyed||await i.destroy(),y(i,t)})}const g=Symbol("NodeTreeParent"),m=Symbol("ChildrenManager");function v(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function b(t){const e={};for(const i in t){const r=t[i];e[i]=v(r);const s=r.map;s&&o(s)&&(e[i].map=b(s))}return e}const I=Symbol("DynamicMap");function E(t){return h(t,I)}class W{fullMap;startingPath;currentMap=null;path;currentPath=[];constructor(t,e=[],i=!0){this.path=e,this.startingPath=e,this.fullMap=b(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 r=e[i].map;if(o(r))e=r;else{if(!E(r))throw new Error("Invalid map type.");e=r.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(E(t))return!0;if(!o(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 W(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}class D{node;[m]=!0;[g]=!0;isDestroyed=!1;isGettingDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];defaultWrapletCreator=t=>{const e=new this.constructor(t.element,t.map,t.initOptions);return new t.Class(e,...t.args)};wrapletCreator=this.defaultWrapletCreator;constructor(t,i,r={}){if(this.node=t,o(i))this.mapWrapper=new W(i);else{if(!(i instanceof W))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(r),this.instantiatedChildren={}}async initialize(){this.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t);const e=Object.values(this.instantiatedChildren).flatMap(t=>t?d(t)?Array.from(t):[t]:[]);await Promise.all(e.map(t=>t.initialize())),this.isInitialized=!0,this.isGettingInitialized=!1}get map(){return this.mapWrapper.getStartingMap()}instantiateChildren(){const t=this.instantiatedChildren;if("function"!=typeof this.node.querySelectorAll){if(Object.keys(this.map).length>0)throw new e("If the node provided cannot have children, the children map should be empty.");return t}for(const e in this.map){const i=this.map[e],r=i.multiple,s=this.mapWrapper.clone([...this.mapWrapper.path,e]);this.validateMapItem(e,i),t[e]=r?this.instantiateMultipleWrapletsChild(i,s,this.node,e):this.instantiateSingleWrapletChild(i,s,this.node,e)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(e))for(const i of e)t.push(i);else t.push(e);return t.filter(t=>{let e=!1;return t.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(!d(i))throw new a("Internal logic error. Expected a WrapletSet.");const t=i.find(t=>{let i=!1;return t.accessNode(t=>{t===e&&(i=!0)}),i});if(0===t.length)return null;if(t.length>1)throw new a("Internal logic error. Multiple instances wrapping the same element found in the core.");return t[0]}return i}instantiateSingleWrapletChild(t,e,i,r){if(!t.selector)return null;const n=t.selector,a=this.findChildren(n,i);if(this.validateElements(r,a,t),0===a.length)return null;if(a.length>1)throw new s(`${this.constructor.name}: More than one element was found for the "${r}" child. Selector used: "${n}".`);const o=a[0];return this.instantiateWrapletItem(r,t,e,o)}instantiateWrapletItem(t,e,i,r){const s=this.findExistingWraplet(t,r);if(s)return s;const n=e.Class,a=e.args,o=this.wrapletCreator({id:t,Class:n,element:r,map:i,initOptions:e.coreOptions,args:a,defaultCreator:this.defaultWrapletCreator});this.prepareIndividualWraplet(t,o);for(const e of this.instantiateChildListeners)e(o,t);return o}instantiateMultipleWrapletsChild(t,e,i,r){const s=t.selector;if(!s)return new u;const n=this.findChildren(s,i);this.validateElements(r,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[r]?this.instantiatedChildren[r]:new u;for(const i of n){if(this.findExistingWraplet(r,i))continue;const s=this.instantiateWrapletItem(r,t,e,i);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.addDestroyListener(e=>{this.removeChild(e,t);for(const i of this.destroyChildListeners)i(e,t)})}async destroy(){if(this.isDestroyed)throw new n("Children are already destroyed.");this.isGettingDestroyed=!0;for(const t of this.listeners){const e=t.node,i=t.eventName,r=t.callback,s=t.options;e.removeEventListener(i,r,s)}await this.destroyChildren(),this.isGettingDestroyed=!1,this.isDestroyed=!0}findChildren(t,e){return"string"==typeof t?((t,e)=>Array.from(e.querySelectorAll(t)))(t,e):t(e)}addEventListener(t,e,i,r){this.listeners.push({node:t,eventName:e,callback:i,options:r}),t.addEventListener(e,i,r)}get children(){if(!this.isInitialized)throw new r("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.isInitialized)throw new r("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(d(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new a("Internal logic error. Destroyed child couldn't be removed because it's not among the children.")}else{if(this.map[e].required&&!this.isGettingDestroyed)throw new i("Required child has been destroyed.");if(null===this.instantiatedChildren[e])throw new a("Internal logic error. Destroyed child couldn't be removed because it's already null.");this.instantiatedChildren[e]=null}}validateMapItem(t,i){const r=i.selector,s=i.required;if(!r&&s)throw new e(`${this.constructor.name}: Child "${t}" cannot at the same be required and have no selector.`)}validateElements(e,i,r){if(0===i.length&&r.required)throw new t(`${this.constructor.name}: Couldn't find a node for the wraplet "${e}". Selector used: "${r.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(d(e))for(const t of e)await t.destroy();else await e.destroy()}}const M=Symbol("Wraplet");function L(t){return h(t,M)}const x=Symbol("Groupable");class z{core;[M]=!0;[x]=!0;[g]=!0;isGettingDestroyed=!1;isDestroyed=!1;isGettingInitialized=!1;isInitialized=!1;groupsExtractor=t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]};destroyListeners=[];__debugNodeAccessors=[];constructor(t){if(this.core=t,!h(t,m))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroyed.bind(this)),t.addInstantiateChildListener(this.onChildInstantiated.bind(this))}getNodeTreeChildren(){return this.core.getNodeTreeChildren()}setGroupsExtractor(t){this.groupsExtractor=t}getGroups(){return this.groupsExtractor(this.node)}get children(){return this.core.children}accessNode(t){this.__debugNodeAccessors.push(t),t(this.node)}async destroy(){if(!this.isDestroyed&&(this.isGettingDestroyed=!0,!this.isGettingInitialized)){if(!this.isInitialized)return this.isDestroyed=!0,void(this.isGettingDestroyed=!1);for(const t of this.destroyListeners)await t(this);this.destroyListeners.length=0,await this.core.destroy(),this.isDestroyed=!0,this.isGettingDestroyed=!1}}addDestroyListener(t){this.destroyListeners.push(t)}onChildDestroyed(t,e){}async initialize(){this.isGettingInitialized=!0,await this.core.initialize(),this.isInitialized=!0,this.isGettingInitialized=!1,this.isGettingDestroyed&&await this.destroy()}get node(){return this.core.node}onChildInstantiated(t,e){}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new D(t,e)}static createWraplets(t,e,i,r=[]){if(this===z)throw new Error("You cannot instantiate an abstract class.");const s=[];if(t instanceof Element&&t.hasAttribute(i)){const i=z.createCore(t,e);s.push(new this(i,...r))}const n=t.querySelectorAll(`[${i}]`);for(const t of n){const i=z.createCore(t,e);s.push(new this(i,...r))}return s}}class S{levels;[I]=!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 S(t)}}class G extends c{[p]=!0}export{z as AbstractWraplet,D as DefaultCore,u as DefaultWrapletSet,G as DefaultWrapletSetReadonly,S as MapRepeat,C as destroyWrapletsRecursively,f as getWrapletsFromNode,L 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{}function o(t){return Object.getPrototypeOf(t)===Object.prototype}const l=(t,e)=>"object"==typeof t&&null!==t&&!0===t[e],h=Symbol("WrapletSet");function d(t){return l(t,h)}class c 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 u=Symbol("WrapletSetReadonly");class p extends c{[u]=!0;[h]=!0}function f(t){const e=t.wraplets;return d(e)&&0!==e.size?e:new p}function w(t,e){return!!e.wraplets&&e.wraplets.delete(t)}async function y(t,e){await e(t);const i=t.childNodes;for(const t of i)await y(t,e)}async function C(t){await y(t,async t=>{const e=f(t);for(const i of e)i.wraplet.status.isGettingDestroyed||i.wraplet.status.isDestroyed||await i.wraplet.destroy(),w(i,t)})}const g=Symbol("ChildrenManager"),m=Symbol("NodeTreeParent");function b(t){return{args:[],destructible:!0,map:{},coreOptions:{},...t}}function W(t){const e={};for(const i in t){const s=t[i];e[i]=b(s);const r=s.map;r&&o(r)&&(e[i].map=W(r))}return e}const I=Symbol("DynamicMap");function v(t){return l(t,I)}class E{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(o(s))e=s;else{if(!v(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(v(t))return!0;if(!o(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 E(this.fullMap,t,e)}resolve(t){return this.findMap(t)}}const D=Symbol("ArgCreator");function z(t,e){const i=new e(t.element,t.map,t.initOptions);return new t.Class(i,...t.args)}class M{node;[g]=!0;[m]=!0;statusWritable={isDestroyed:!1,isGettingDestroyed:!1,isInitialized:!1,isGettingInitialized:!1};get status(){return this.statusWritable}mapWrapper;instantiatedChildren={};destroyChildListeners=[];instantiateChildListeners=[];listeners=[];wrapletCreator=z;constructor(t,i,s={}){if(this.node=t,o(i))this.mapWrapper=new E(i);else{if(!(i instanceof E))throw new e("The map provided to the Core is not a valid map.");this.mapWrapper=i}this.processInitOptions(s),this.instantiatedChildren={}}async initialize(){this.statusWritable.isGettingInitialized=!0;const t=this.instantiateChildren();this.instantiatedChildren=this.wrapChildren(t);const e=Object.values(this.instantiatedChildren).flatMap(t=>t?d(t)?Array.from(t):[t]:[]);await Promise.all(e.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){if(Object.keys(this.map).length>0)throw new e("If the node provided cannot have children, the children map should be empty.");return t}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)}return t}syncChildren(){this.instantiatedChildren=this.instantiateChildren()}getNodeTreeChildren(){const t=[];for(const e of Object.values(this.children))if(d(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(!d(i))throw new a("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 a("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 n=t.selector,a=this.findChildren(n,i);if(this.validateElements(s,a,t),0===a.length)return null;if(a.length>1)throw new r(`${this.constructor.name}: More than one element was found for the "${s}" child. Selector used: "${n}".`);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=>l(t,D)?t.createArg(n):t);const a=this.wrapletCreator(n,this.constructor);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 p;const n=this.findChildren(r,i);this.validateElements(s,n,t);const a=this.instantiatedChildren&&this.instantiatedChildren[s]?this.instantiatedChildren[s]:new p;for(const i of n){if(this.findExistingWraplet(s,i))continue;const r=this.instantiateWrapletItem(s,t,e,i);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 n("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.statusWritable.isInitialized)throw new s("Wraplet is not yet fully initialized. You can fetch partial children with the 'uninitializedChildren' property.");return this.instantiatedChildren}get uninitializedChildren(){if(this.statusWritable.isInitialized)throw new s("Wraplet is already initialized. Fetch children with 'children' property instead.");return this.instantiatedChildren}removeChild(t,e){if(d(this.instantiatedChildren[e])){if(!this.instantiatedChildren[e].delete(t))throw new a("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 a("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.`)}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(d(e))for(const t of e)await t.wraplet.destroy();else await e.wraplet.destroy()}}class L{creator;[D]=!0;constructor(t){this.creator=t}createArg(t){return this.creator(t)}static create(t){return new L(t)}}const G=Symbol("Wraplet");function S(t){return l(t,G)}const x=Symbol("Groupable");class O{core;[G]=!0;[x]=!0;[m]=!0;destroyListeners=[];wraplet;constructor(t){if(this.core=t,!l(t,g))throw new Error("AbstractWraplet requires a Core instance.");t.addDestroyChildListener(this.onChildDestroy.bind(this)),t.addInstantiateChildListener(this.onChildInstantiate.bind(this)),this.wraplet=this.createWrapletApi({core:this.core,wraplet:this,destroyListeners:this.destroyListeners})}createWrapletApi(t){return(t=>{const e=[],i=t.destroyListeners||[];let s=t.groupExtractor||(t=>{if(t instanceof Element){const e=t.getAttribute("data-js-wraplet-groupable");if(e)return e.split(",")}return[]});const r=t.destroyCallback,n=t.status||{isGettingInitialized:!1,isDestroyed:!1,isInitialized:!1,isGettingDestroyed:!1},a=t.initializeCallback,o=async()=>{if(!n.isDestroyed&&(n.isGettingDestroyed=!0,!n.isGettingInitialized)){if(!n.isInitialized)return n.isDestroyed=!0,void(n.isGettingDestroyed=!1);await t.core.destroy();for(const e of i)await e(t.wraplet);r&&await r(),n.isGettingDestroyed=!1,n.isInitialized=!1,n.isDestroyed=!0}};return{__nodeAccessors:e,status:n,addDestroyListener:t=>{i.push(t)},initialize:async()=>{n.isInitialized||(n.isGettingInitialized=!0,await t.core.initialize(),a&&await a(),n.isInitialized=!0,n.isGettingInitialized=!1,n.isGettingDestroyed&&await o())},destroy:o,accessNode:i=>{e.push(i),i(t.core.node)},getNodeTreeChildren:()=>t.core.getNodeTreeChildren(),setGroupsExtractor:t=>{s=t},getGroups:()=>s(t.core.node)}})(t)}get children(){return this.core.children}onChildDestroy(t,e){}get node(){return this.core.node}onChildInstantiate(t,e){}isChildInstance(t,e,i=null){return e===(i||e)&&t instanceof this.core.map[e].Class}static createCore(t,e){return new M(t,e)}static createWraplets(t,e,i,s=[]){if(this===O)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 A{levels;[I]=!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 A(t)}}class j extends c{[u]=!0}export{O as AbstractWraplet,L as DefaultArgCreator,M as DefaultCore,p as DefaultWrapletSet,j as DefaultWrapletSetReadonly,A as MapRepeat,z as defaultWrapletCreator,C as destroyWrapletsRecursively,f as getWrapletsFromNode,S 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,OAI3C,MAAMI,UAAkCJ,OAExC,MAAMK,UAAyCL,OAE/C,MAAMM,UAA2BN,OCdjC,SAASO,EAAiCC,GAC7C,OAAOC,OAAOC,eAAeF,KAAYC,OAAOE,SACpD,CCEA,MAAM,EAAK,CAACH,EAAQI,IACU,iBAAXJ,GACA,OAAXA,IACmB,IAAnBA,EAAOI,GCNTC,EAAmBC,OAAO,cAEzB,SAASC,EAAaP,GACzB,OAAO,EAAGA,EAAQK,EACtB,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CAAOkH,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkCpL,EAC3C,CAACgB,IAA4B,S","sources":["webpack://wraplet/./src/errors.ts","webpack://wraplet/./src/types/WrapletChildrenMap.ts","webpack://wraplet/./src/types/Utils.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/utils.ts","webpack://wraplet/./src/types/NodeTreeParent.ts","webpack://wraplet/./src/types/Core.ts","webpack://wraplet/./src/WrapletChildrenMap.ts","webpack://wraplet/./src/Map/types/DynamicMap.ts","webpack://wraplet/./src/Map/MapWrapper.ts","webpack://wraplet/./src/DefaultCore.ts","webpack://wraplet/./src/types/Wraplet.ts","webpack://wraplet/./src/types/Groupable.ts","webpack://wraplet/./src/AbstractWraplet.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.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}\n","export function isWrapletChildrenMapWithDefaults(object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n","/* istanbul ignore next */\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 \"../../types/Utils\";\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.isGettingDestroyed && !wraplet.isDestroyed) {\n await wraplet.destroy();\n }\n removeWrapletFromNode(wraplet, node);\n }\n });\n}\n","const NodeTreeParentSymbol = Symbol(\"NodeTreeParent\");\nexport { NodeTreeParentSymbol };\n/* istanbul ignore next */\nexport function isNodeTreeParent(object) {\n return (object[NodeTreeParentSymbol] ===\n true);\n}\n","import { is } from \"./Utils\";\nimport { NodeTreeParentSymbol } from \"./NodeTreeParent\";\nconst CoreSymbol = Symbol(\"ChildrenManager\");\nexport { CoreSymbol };\nexport function isCore(object) {\n return is(object, CoreSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"./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 \"../../types/Utils\";\nconst DynamicMapSymbol = Symbol(\"DynamicMap\");\nexport { DynamicMapSymbol };\nexport function isDynamicMap(object) {\n return is(object, DynamicMapSymbol);\n}\n","import { isWrapletChildrenMapWithDefaults, } from \"../types/WrapletChildrenMap\";\nimport { fillMapWithDefaults } from \"../WrapletChildrenMap\";\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 { ChildrenAreNotAvailableError, MapError, MissingRequiredChildError, RequiredChildDestroyedError, ChildrenTooManyFoundError, ChildrenAreAlreadyDestroyedError, InternalLogicError, } from \"./errors\";\nimport { isWrapletChildrenMapWithDefaults, } from \"./types/WrapletChildrenMap\";\nimport { isParentNode } from \"./utils\";\nimport { CoreSymbol } from \"./types/Core\";\nimport { isWrapletSet } from \"./Set/types/WrapletSet\";\nimport { DefaultWrapletSet } from \"./Set/DefaultWrapletSet\";\nimport { NodeTreeParentSymbol } from \"./types/NodeTreeParent\";\nimport { MapWrapper } from \"./Map/MapWrapper\";\nexport class DefaultCore {\n node;\n [CoreSymbol] = true;\n [NodeTreeParentSymbol] = true;\n isDestroyed = false;\n isGettingDestroyed = false;\n isGettingInitialized = false;\n isInitialized = false;\n mapWrapper;\n instantiatedChildren = {};\n destroyChildListeners = [];\n instantiateChildListeners = [];\n listeners = [];\n defaultWrapletCreator = (args) => {\n const core = new this.constructor(args.element, args.map, args.initOptions);\n return new args.Class(core, ...args.args);\n };\n wrapletCreator = this.defaultWrapletCreator;\n constructor(node, map, initOptions = {}) {\n this.node = node;\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 initialize() {\n this.isGettingInitialized = true;\n const children = this.instantiateChildren();\n this.instantiatedChildren = this.wrapChildren(children);\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.initialize()));\n this.isInitialized = true;\n this.isGettingInitialized = false;\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 if (Object.keys(this.map).length > 0) {\n throw new MapError(\"If the node provided cannot have children, the children map should be empty.\");\n }\n return children;\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 // Now we should have all properties set, so let's assert the final form.\n return children;\n }\n syncChildren() {\n this.instantiatedChildren = this.instantiateChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\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.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.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 args = childDefinition.args;\n const wraplet = this.wrapletCreator({\n id: id,\n Class: wrapletClass,\n element: node,\n map: childMap,\n initOptions: childDefinition.coreOptions,\n args: args,\n defaultCreator: this.defaultWrapletCreator,\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 items.add(wraplet);\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.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.isDestroyed) {\n throw new ChildrenAreAlreadyDestroyedError(\"Children are already destroyed.\");\n }\n this.isGettingDestroyed = true;\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 await this.destroyChildren();\n this.isGettingDestroyed = false;\n this.isDestroyed = true;\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.isInitialized) {\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 get uninitializedChildren() {\n if (this.isInitialized) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");\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.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 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.destroy();\n }\n }\n else {\n await child.destroy();\n }\n }\n }\n}\n","import { is } from \"./Utils\";\nconst WrapletSymbol = Symbol(\"Wraplet\");\nexport { WrapletSymbol };\nexport function isWraplet(object) {\n return is(object, WrapletSymbol);\n}\n","import { is } from \"./Utils\";\nconst GroupableSymbol = Symbol(\"Groupable\");\nexport { GroupableSymbol };\n/* istanbul ignore next */\nexport function isGroupable(object) {\n return is(object, GroupableSymbol);\n}\nconst defaultGroupableAttribute = \"data-js-wraplet-groupable\";\nexport { defaultGroupableAttribute };\n","import { WrapletSymbol } from \"./types/Wraplet\";\nimport { defaultGroupableAttribute, GroupableSymbol, } from \"./types/Groupable\";\nimport { NodeTreeParentSymbol } from \"./types/NodeTreeParent\";\nimport { isCore } from \"./types/Core\";\nimport { DefaultCore } from \"./DefaultCore\";\nexport class AbstractWraplet {\n core;\n [WrapletSymbol] = true;\n [GroupableSymbol] = true;\n [NodeTreeParentSymbol] = true;\n isGettingDestroyed = false;\n isDestroyed = false;\n isGettingInitialized = false;\n isInitialized = false;\n groupsExtractor = (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 destroyListeners = [];\n /**\n * This is the log of all node accessors, available for easier debugging.\n */\n __debugNodeAccessors = [];\n constructor(core) {\n this.core = core;\n if (!isCore(core)) {\n throw new Error(\"AbstractWraplet requires a Core instance.\");\n }\n core.addDestroyChildListener(this.onChildDestroyed.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiated.bind(this));\n }\n getNodeTreeChildren() {\n return this.core.getNodeTreeChildren();\n }\n setGroupsExtractor(callback) {\n this.groupsExtractor = callback;\n }\n getGroups() {\n return this.groupsExtractor(this.node);\n }\n get children() {\n return this.core.children;\n }\n accessNode(callback) {\n this.__debugNodeAccessors.push(callback);\n callback(this.node);\n }\n async destroy() {\n if (this.isDestroyed) {\n // We are already destroyed.\n return;\n }\n this.isGettingDestroyed = true;\n if (this.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.isInitialized) {\n // If we are not initialized, then we have nothing to do here.\n this.isDestroyed = true;\n this.isGettingDestroyed = false;\n return;\n }\n for (const listener of this.destroyListeners) {\n await listener(this);\n }\n this.destroyListeners.length = 0;\n await this.core.destroy();\n this.isDestroyed = true;\n this.isGettingDestroyed = false;\n }\n addDestroyListener(callback) {\n this.destroyListeners.push(callback);\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 onChildDestroyed(child, id) { }\n async initialize() {\n this.isGettingInitialized = true;\n await this.core.initialize();\n this.isInitialized = true;\n this.isGettingInitialized = false;\n // If destruction has been invoked in the meantime, we can finally do it, when initialization\n // is finished.\n if (this.isGettingDestroyed) {\n await this.destroy();\n }\n }\n get node() {\n return this.core.node;\n }\n /**\n * This method will be ivoked if one of the wraplet's children has been instantiated.\n */\n onChildInstantiated(\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 * 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 = AbstractWraplet.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 = AbstractWraplet.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"],"names":["MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","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","isGettingDestroyed","isDestroyed","destroy","NodeTreeParentSymbol","CoreSymbol","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","DefaultCore","isGettingInitialized","isInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","defaultWrapletCreator","core","element","initOptions","Class","wrapletCreator","processInitOptions","initialize","instantiateChildren","wrapChildren","childInstances","values","flatMap","Promise","all","querySelectorAll","keys","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","wrapletClass","defaultCreator","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","uninitializedChildren","required","isRequired","elements","mapItem","Proxy","get","target","defaultInitOptions","initOptionsPartial","assign","key","entries","WrapletSymbol","isWraplet","GroupableSymbol","AbstractWraplet","groupsExtractor","Element","groupsString","getAttribute","split","destroyListeners","__debugNodeAccessors","onChildDestroyed","bind","onChildInstantiated","setGroupsExtractor","getGroups","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly"],"ignoreList":[],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"AAAO,MAAMA,UAAkCC,OAExC,MAAMC,UAAiBD,OAEvB,MAAME,UAA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uI,EAAS,GAEjB,GADAxL,KAAKwL,OAASA,EACVA,EAAS,EACT,MAAM,IAAI9M,MAAM,gDAExB,CACA,MAAAgF,CAAO+H,GACH,IAAK,IAAIC,EAAI,EAAGA,EAAI1L,KAAKwL,OAAQE,IAC7BD,EAAezH,OAEnB,OAAOyH,EAAepI,eAC1B,CACA,aAAOK,CAAO8H,EAAS,GACnB,OAAO,IAAID,EAAUC,EACzB,EChBG,MAAMG,UAAkCjM,EAC3C,CAACgB,IAA4B,S","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/AbstractWraplet.ts","webpack://wraplet/./src/Wraplet/createWrapletApi.ts","webpack://wraplet/./src/Map/MapRepeat.ts","webpack://wraplet/./src/Set/DefaultWrapletSetReadonly.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}\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(\"ChildrenManager\");\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, } 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 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 (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 initialize() {\n this.statusWritable.isGettingInitialized = true;\n const children = this.instantiateChildren();\n this.instantiatedChildren = this.wrapChildren(children);\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 if (Object.keys(this.map).length > 0) {\n throw new MapError(\"If the node provided cannot have children, the children map should be empty.\");\n }\n return children;\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 // Now we should have all properties set, so let's assert the final form.\n return children;\n }\n syncChildren() {\n this.instantiatedChildren = this.instantiateChildren();\n }\n getNodeTreeChildren() {\n const children = [];\n for (const child of Object.values(this.children)) {\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 const wraplet = this.wrapletCreator(creatorArgs, this.constructor);\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 items.add(wraplet);\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.statusWritable.isInitialized) {\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 get uninitializedChildren() {\n if (this.statusWritable.isInitialized) {\n throw new ChildrenAreNotAvailableError(\"Wraplet is already initialized. Fetch children with 'children' property instead.\");\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 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","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 { createWrapletApi } from \"./Wraplet/createWrapletApi\";\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 core.addDestroyChildListener(this.onChildDestroy.bind(this));\n core.addInstantiateChildListener(this.onChildInstantiate.bind(this));\n this.wraplet = this.createWrapletApi({\n core: this.core,\n wraplet: this,\n destroyListeners: this.destroyListeners,\n });\n }\n createWrapletApi(args) {\n return createWrapletApi(args);\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 * 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 { defaultGroupableAttribute, } from \"../types/Groupable\";\nexport const createWrapletApi = (args) => {\n const nodeAccessors = [];\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 const destroyListeners = args.destroyListeners || [];\n let groupExtractor = args.groupExtractor || defaultGroupExtractor;\n const destroyCallback = args.destroyCallback;\n const defaultStatus = {\n isGettingInitialized: false,\n isDestroyed: false,\n isInitialized: false,\n isGettingDestroyed: false,\n };\n const status = args.status || defaultStatus;\n const initializeCallback = args.initializeCallback;\n const destroyMethod = async () => {\n if (status.isDestroyed) {\n return;\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;\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;\n }\n await args.core.destroy();\n for (const listener of destroyListeners) {\n await listener(args.wraplet);\n }\n if (destroyCallback) {\n await destroyCallback();\n }\n status.isGettingDestroyed = false;\n status.isInitialized = false;\n status.isDestroyed = true;\n };\n return {\n __nodeAccessors: nodeAccessors,\n status: status,\n addDestroyListener: (callback) => {\n destroyListeners.push(callback);\n },\n initialize: async () => {\n if (status.isInitialized) {\n return;\n }\n status.isGettingInitialized = true;\n await args.core.initialize();\n if (initializeCallback) {\n await initializeCallback();\n }\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 },\n destroy: destroyMethod,\n accessNode: (callback) => {\n nodeAccessors.push(callback);\n callback(args.core.node);\n },\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 { 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"],"names":["MissingRequiredChildError","Error","MapError","RequiredChildDestroyedError","ChildrenAreNotAvailableError","ChildrenTooManyFoundError","ChildrenAreAlreadyDestroyedError","InternalLogicError","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","statusWritable","isInitialized","isGettingInitialized","mapWrapper","instantiatedChildren","destroyChildListeners","instantiateChildListeners","listeners","wrapletCreator","processInitOptions","initialize","instantiateChildren","wrapChildren","childInstances","values","flatMap","Promise","all","querySelectorAll","keys","childDefinition","multiple","validateMapItem","instantiateMultipleWrapletsChild","instantiateSingleWrapletChild","syncChildren","getNodeTreeChildren","result","accessNode","childsNode","contains","findExistingWraplet","childElement","undefined","existingChild","existingWraplets","childMap","selector","childElements","findChildren","validateElements","name","instantiateWrapletItem","existingWraplet","creatorArgs","arg","createArg","prepareIndividualWraplet","listener","items","add","addDestroyChildListener","addInstantiateChildListener","setWrapletCreator","addDestroyListener","removeChild","eventName","options","removeEventListener","destroyChildren","defaultSelectorCallback","addEventListener","uninitializedChildren","required","isRequired","elements","mapItem","Proxy","get","target","defaultInitOptions","initOptionsPartial","assign","key","entries","DefaultArgCreator","creator","WrapletSymbol","isWraplet","GroupableSymbol","AbstractWraplet","destroyListeners","onChildDestroy","bind","onChildInstantiate","createWrapletApi","nodeAccessors","groupExtractor","Element","groupsString","getAttribute","split","destroyCallback","initializeCallback","destroyMethod","__nodeAccessors","setGroupsExtractor","extractor","getGroups","isChildInstance","actualUnknownId","onlyId","createCore","createWraplets","attribute","additional_args","hasAttribute","foundElements","MapRepeat","levels","parentMapClone","i","DefaultWrapletSetReadonly"],"ignoreList":[],"sourceRoot":""}