jails-js 6.0.1-beta.9 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/index.ts","../node_modules/idiomorph/dist/idiomorph.esm.js","../src/utils/pubsub.ts","../src/component.ts","../src/element.ts","../src/template-system.ts","../src/index.ts"],"sourcesContent":["\nconst textarea = document.createElement('textarea')\n\nexport const g = {\n\tscope: {}\n}\n\nexport const decodeHTML = (text) => {\n\ttextarea.innerHTML = text\n\treturn textarea.value\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn Math.random().toString(36).substring(2, 9)\n}\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\nexport const safe = (execute, val) => {\n\ttry{\n\t\treturn execute()\n\t}catch(err){\n\t\treturn val || ''\n\t}\n}\n","/**\n * @typedef {object} ConfigHead\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} [style]\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {function(Element): boolean} [shouldPreserve]\n * @property {function(Element): boolean} [shouldReAppend]\n * @property {function(Element): boolean} [shouldRemove]\n * @property {function(Element, {added: Node[], kept: Element[], removed: Element[]}): void} [afterHeadMorphed]\n */\n\n/**\n * @typedef {object} ConfigCallbacks\n *\n * @property {function(Node): boolean} [beforeNodeAdded]\n * @property {function(Node): void} [afterNodeAdded]\n * @property {function(Element, Node): boolean} [beforeNodeMorphed]\n * @property {function(Element, Node): void} [afterNodeMorphed]\n * @property {function(Element): boolean} [beforeNodeRemoved]\n * @property {function(Element): void} [afterNodeRemoved]\n * @property {function(string, Element, \"update\" | \"remove\"): boolean} [beforeAttributeUpdated]\n * @property {function(Element): boolean} [beforeNodePantried]\n */\n\n/**\n * @typedef {object} Config\n *\n * @property {'outerHTML' | 'innerHTML'} [morphStyle]\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacks} [callbacks]\n * @property {ConfigHead} [head]\n */\n\n/**\n * @typedef {function} NoOp\n *\n * @returns {void}\n */\n\n/**\n * @typedef {object} ConfigHeadInternal\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} style\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {(function(Element): boolean) | NoOp} shouldPreserve\n * @property {(function(Element): boolean) | NoOp} shouldReAppend\n * @property {(function(Element): boolean) | NoOp} shouldRemove\n * @property {(function(Element, {added: Node[], kept: Element[], removed: Element[]}): void) | NoOp} afterHeadMorphed\n */\n\n/**\n * @typedef {object} ConfigCallbacksInternal\n *\n * @property {(function(Node): boolean) | NoOp} beforeNodeAdded\n * @property {(function(Node): void) | NoOp} afterNodeAdded\n * @property {(function(Node, Node): boolean) | NoOp} beforeNodeMorphed\n * @property {(function(Node, Node): void) | NoOp} afterNodeMorphed\n * @property {(function(Node): boolean) | NoOp} beforeNodeRemoved\n * @property {(function(Node): void) | NoOp} afterNodeRemoved\n * @property {(function(string, Element, \"update\" | \"remove\"): boolean) | NoOp} beforeAttributeUpdated\n * @property {(function(Node): boolean) | NoOp} beforeNodePantried\n */\n\n/**\n * @typedef {object} ConfigInternal\n *\n * @property {'outerHTML' | 'innerHTML'} morphStyle\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {ConfigCallbacksInternal} callbacks\n * @property {ConfigHeadInternal} head\n * @property {boolean} [twoPass]\n */\n\n/**\n * @typedef {Function} Morph\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n\n// base IIFE to define idiomorph\n/**\n *\n * @type {{defaults: ConfigInternal, morph: Morph}}\n */\nvar Idiomorph = (function () {\n \"use strict\";\n\n /**\n * @typedef {object} MorphContext\n *\n * @property {Node} target\n * @property {Node} newContent\n * @property {ConfigInternal} config\n * @property {ConfigInternal['morphStyle']} morphStyle\n * @property {ConfigInternal['ignoreActive']} ignoreActive\n * @property {ConfigInternal['ignoreActiveValue']} ignoreActiveValue\n * @property {Map<Node, Set<string>>} idMap\n * @property {Set<string>} persistentIds\n * @property {Set<string>} deadIds\n * @property {ConfigInternal['callbacks']} callbacks\n * @property {ConfigInternal['head']} head\n * @property {HTMLDivElement} pantry\n */\n\n //=============================================================================\n // AND NOW IT BEGINS...\n //=============================================================================\n\n /**\n *\n * @type {Set<string>}\n */\n let EMPTY_SET = new Set();\n\n /**\n * Default configuration values, updatable by users now\n * @type {ConfigInternal}\n */\n let defaults = {\n morphStyle: \"outerHTML\",\n callbacks: {\n beforeNodeAdded: noOp,\n afterNodeAdded: noOp,\n beforeNodeMorphed: noOp,\n afterNodeMorphed: noOp,\n beforeNodeRemoved: noOp,\n afterNodeRemoved: noOp,\n beforeAttributeUpdated: noOp,\n beforeNodePantried: noOp,\n },\n head: {\n style: \"merge\",\n shouldPreserve: function (elt) {\n return elt.getAttribute(\"im-preserve\") === \"true\";\n },\n shouldReAppend: function (elt) {\n return elt.getAttribute(\"im-re-append\") === \"true\";\n },\n shouldRemove: noOp,\n afterHeadMorphed: noOp,\n },\n };\n\n /**\n * =============================================================================\n * Core Morphing Algorithm - morph, morphNormalizedContent, morphOldNodeTo, morphChildren\n * =============================================================================\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n function morph(oldNode, newContent, config = {}) {\n if (oldNode instanceof Document) {\n oldNode = oldNode.documentElement;\n }\n\n if (typeof newContent === \"string\") {\n newContent = parseContent(newContent);\n }\n\n let normalizedContent = normalizeContent(newContent);\n\n let ctx = createMorphContext(oldNode, normalizedContent, config);\n\n return morphNormalizedContent(oldNode, normalizedContent, ctx);\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} normalizedNewContent\n * @param {MorphContext} ctx\n * @returns {undefined | Node[]}\n */\n function morphNormalizedContent(oldNode, normalizedNewContent, ctx) {\n if (ctx.head.block) {\n let oldHead = oldNode.querySelector(\"head\");\n let newHead = normalizedNewContent.querySelector(\"head\");\n if (oldHead && newHead) {\n let promises = handleHeadElement(newHead, oldHead, ctx);\n // when head promises resolve, call morph again, ignoring the head tag\n Promise.all(promises).then(function () {\n morphNormalizedContent(\n oldNode,\n normalizedNewContent,\n Object.assign(ctx, {\n head: {\n block: false,\n ignore: true,\n },\n }),\n );\n });\n return;\n }\n }\n\n if (ctx.morphStyle === \"innerHTML\") {\n // innerHTML, so we are only updating the children\n morphChildren(normalizedNewContent, oldNode, ctx);\n if (ctx.config.twoPass) {\n restoreFromPantry(oldNode, ctx);\n }\n return Array.from(oldNode.children);\n } else if (ctx.morphStyle === \"outerHTML\" || ctx.morphStyle == null) {\n // otherwise find the best element match in the new content, morph that, and merge its siblings\n // into either side of the best match\n let bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);\n\n // stash the siblings that will need to be inserted on either side of the best match\n let previousSibling = bestMatch?.previousSibling ?? null;\n let nextSibling = bestMatch?.nextSibling ?? null;\n\n // morph it\n let morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);\n\n if (bestMatch) {\n // if there was a best match, merge the siblings in too and return the\n // whole bunch\n if (morphedNode) {\n const elements = insertSiblings(\n previousSibling,\n morphedNode,\n nextSibling,\n );\n if (ctx.config.twoPass) {\n restoreFromPantry(morphedNode.parentNode, ctx);\n }\n return elements;\n }\n } else {\n // otherwise nothing was added to the DOM\n return [];\n }\n } else {\n throw \"Do not understand how to morph style \" + ctx.morphStyle;\n }\n }\n\n /**\n * @param {Node} possibleActiveElement\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: ignoreActive and ignoreActiveValue are marked as optional since they are not\n // initialised in the default config object. As a result the && in the function body may\n // return undefined instead of boolean. Either expand the type of the return value to\n // include undefined or wrap the ctx.ignoreActiveValue into a Boolean()\n function ignoreValueOfActiveElement(possibleActiveElement, ctx) {\n return (\n !!ctx.ignoreActiveValue &&\n possibleActiveElement === document.activeElement &&\n possibleActiveElement !== document.body\n );\n }\n\n /**\n * @param {Node} oldNode root node to merge content into\n * @param {Node | null} newContent new content to merge\n * @param {MorphContext} ctx the merge context\n * @returns {Node | null} the element that ended up in the DOM\n */\n function morphOldNodeTo(oldNode, newContent, ctx) {\n if (ctx.ignoreActive && oldNode === document.activeElement) {\n // don't morph focused element\n } else if (newContent == null) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n\n oldNode.parentNode?.removeChild(oldNode);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return null;\n } else if (!isSoftMatch(oldNode, newContent)) {\n if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n if (ctx.callbacks.beforeNodeAdded(newContent) === false) return oldNode;\n\n oldNode.parentNode?.replaceChild(newContent, oldNode);\n ctx.callbacks.afterNodeAdded(newContent);\n ctx.callbacks.afterNodeRemoved(oldNode);\n return newContent;\n } else {\n if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false)\n return oldNode;\n\n if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) {\n // ignore the head element\n } else if (\n oldNode instanceof HTMLHeadElement &&\n ctx.head.style !== \"morph\"\n ) {\n // ok to cast: if newContent wasn't also a <head>, it would've got caught in the `!isSoftMatch` branch above\n handleHeadElement(\n /** @type {HTMLHeadElement} */ (newContent),\n oldNode,\n ctx,\n );\n } else {\n syncNodeFrom(newContent, oldNode, ctx);\n if (!ignoreValueOfActiveElement(oldNode, ctx)) {\n morphChildren(newContent, oldNode, ctx);\n }\n }\n ctx.callbacks.afterNodeMorphed(oldNode, newContent);\n return oldNode;\n }\n return null;\n }\n\n /**\n * This is the core algorithm for matching up children. The idea is to use id sets to try to match up\n * nodes as faithfully as possible. We greedily match, which allows us to keep the algorithm fast, but\n * by using id sets, we are able to better match up with content deeper in the DOM.\n *\n * Basic algorithm is, for each node in the new content:\n *\n * - if we have reached the end of the old parent, append the new content\n * - if the new content has an id set match with the current insertion point, morph\n * - search for an id set match\n * - if id set match found, morph\n * - otherwise search for a \"soft\" match\n * - if a soft match is found, morph\n * - otherwise, prepend the new node before the current insertion point\n *\n * The two search algorithms terminate if competing node matches appear to outweigh what can be achieved\n * with the current node. See findIdSetMatch() and findSoftMatch() for details.\n *\n * @param {Node} newParent the parent element of the new content\n * @param {Node} oldParent the old content that we are merging the new content into\n * @param {MorphContext} ctx the merge context\n * @returns {void}\n */\n function morphChildren(newParent, oldParent, ctx) {\n if (\n newParent instanceof HTMLTemplateElement &&\n oldParent instanceof HTMLTemplateElement\n ) {\n newParent = newParent.content;\n oldParent = oldParent.content;\n }\n\n /**\n *\n * @type {Node | null}\n */\n let nextNewChild = newParent.firstChild;\n /**\n *\n * @type {Node | null}\n */\n let insertionPoint = oldParent.firstChild;\n let newChild;\n\n // run through all the new content\n while (nextNewChild) {\n newChild = nextNewChild;\n nextNewChild = newChild.nextSibling;\n\n // if we are at the end of the exiting parent's children, just append\n if (insertionPoint == null) {\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.appendChild(newChild);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.appendChild(newChild);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // if the current node has an id set match then morph\n if (isIdSetMatch(newChild, insertionPoint, ctx)) {\n morphOldNodeTo(insertionPoint, newChild, ctx);\n insertionPoint = insertionPoint.nextSibling;\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // otherwise search forward in the existing old children for an id set match\n let idSetMatch = findIdSetMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a potential match, remove the nodes until that point and morph\n if (idSetMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, idSetMatch, ctx);\n morphOldNodeTo(idSetMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // no id set match found, so scan forward for a soft match for the current node\n let softMatch = findSoftMatch(\n newParent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n\n // if we found a soft match for the current node, morph\n if (softMatch) {\n insertionPoint = removeNodesBetween(insertionPoint, softMatch, ctx);\n morphOldNodeTo(softMatch, newChild, ctx);\n removeIdsFromConsideration(ctx, newChild);\n continue;\n }\n\n // abandon all hope of morphing, just insert the new child before the insertion point\n // and move on\n\n // skip add callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n ctx.persistentIds.has(/** @type {Element} */ (newChild).id)\n ) {\n oldParent.insertBefore(newChild, insertionPoint);\n } else {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) continue;\n oldParent.insertBefore(newChild, insertionPoint);\n ctx.callbacks.afterNodeAdded(newChild);\n }\n removeIdsFromConsideration(ctx, newChild);\n }\n\n // remove any remaining old nodes that didn't match up with new content\n while (insertionPoint !== null) {\n let tempNode = insertionPoint;\n insertionPoint = insertionPoint.nextSibling;\n removeNode(tempNode, ctx);\n }\n }\n\n //=============================================================================\n // Attribute Syncing Code\n //=============================================================================\n\n /**\n * @param {string} attr the attribute to be mutated\n * @param {Element} to the element that is going to be updated\n * @param {\"update\" | \"remove\"} updateType\n * @param {MorphContext} ctx the merge context\n * @returns {boolean} true if the attribute should be ignored, false otherwise\n */\n function ignoreAttribute(attr, to, updateType, ctx) {\n if (\n attr === \"value\" &&\n ctx.ignoreActiveValue &&\n to === document.activeElement\n ) {\n return true;\n }\n return ctx.callbacks.beforeAttributeUpdated(attr, to, updateType) === false;\n }\n\n /**\n * syncs a given node with another node, copying over all attributes and\n * inner element state from the 'from' node to the 'to' node\n *\n * @param {Node} from the element to copy attributes & state from\n * @param {Node} to the element to copy attributes & state to\n * @param {MorphContext} ctx the merge context\n */\n function syncNodeFrom(from, to, ctx) {\n let type = from.nodeType;\n\n // if is an element type, sync the attributes from the\n // new node into the new node\n if (type === 1 /* element type */) {\n const fromEl = /** @type {Element} */ (from);\n const toEl = /** @type {Element} */ (to);\n const fromAttributes = fromEl.attributes;\n const toAttributes = toEl.attributes;\n for (const fromAttribute of fromAttributes) {\n if (ignoreAttribute(fromAttribute.name, toEl, \"update\", ctx)) {\n continue;\n }\n if (toEl.getAttribute(fromAttribute.name) !== fromAttribute.value) {\n toEl.setAttribute(fromAttribute.name, fromAttribute.value);\n }\n }\n // iterate backwards to avoid skipping over items when a delete occurs\n for (let i = toAttributes.length - 1; 0 <= i; i--) {\n const toAttribute = toAttributes[i];\n\n // toAttributes is a live NamedNodeMap, so iteration+mutation is unsafe\n // e.g. custom element attribute callbacks can remove other attributes\n if (!toAttribute) continue;\n\n if (!fromEl.hasAttribute(toAttribute.name)) {\n if (ignoreAttribute(toAttribute.name, toEl, \"remove\", ctx)) {\n continue;\n }\n toEl.removeAttribute(toAttribute.name);\n }\n }\n }\n\n // sync text nodes\n if (type === 8 /* comment */ || type === 3 /* text */) {\n if (to.nodeValue !== from.nodeValue) {\n to.nodeValue = from.nodeValue;\n }\n }\n\n if (!ignoreValueOfActiveElement(to, ctx)) {\n // sync input values\n syncInputValue(from, to, ctx);\n }\n }\n\n /**\n * @param {Element} from element to sync the value from\n * @param {Element} to element to sync the value to\n * @param {string} attributeName the attribute name\n * @param {MorphContext} ctx the merge context\n */\n function syncBooleanAttribute(from, to, attributeName, ctx) {\n // TODO: prefer set/getAttribute here\n if (!(from instanceof Element && to instanceof Element)) return;\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n const fromLiveValue = from[attributeName],\n toLiveValue = to[attributeName];\n if (fromLiveValue !== toLiveValue) {\n let ignoreUpdate = ignoreAttribute(attributeName, to, \"update\", ctx);\n if (!ignoreUpdate) {\n // update attribute's associated DOM property\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n to[attributeName] = from[attributeName];\n }\n if (fromLiveValue) {\n if (!ignoreUpdate) {\n // TODO: do we really want this? tests say so but it feels wrong\n to.setAttribute(attributeName, fromLiveValue);\n }\n } else {\n if (!ignoreAttribute(attributeName, to, \"remove\", ctx)) {\n to.removeAttribute(attributeName);\n }\n }\n }\n }\n\n /**\n * NB: many bothans died to bring us information:\n *\n * https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js\n * https://github.com/choojs/nanomorph/blob/master/lib/morph.jsL113\n *\n * @param {Node} from the element to sync the input value from\n * @param {Node} to the element to sync the input value to\n * @param {MorphContext} ctx the merge context\n */\n function syncInputValue(from, to, ctx) {\n if (\n from instanceof HTMLInputElement &&\n to instanceof HTMLInputElement &&\n from.type !== \"file\"\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n\n // sync boolean attributes\n syncBooleanAttribute(from, to, \"checked\", ctx);\n syncBooleanAttribute(from, to, \"disabled\", ctx);\n\n if (!from.hasAttribute(\"value\")) {\n if (!ignoreAttribute(\"value\", to, \"remove\", ctx)) {\n to.value = \"\";\n to.removeAttribute(\"value\");\n }\n } else if (fromValue !== toValue) {\n if (!ignoreAttribute(\"value\", to, \"update\", ctx)) {\n to.setAttribute(\"value\", fromValue);\n to.value = fromValue;\n }\n }\n // TODO: QUESTION(1cg): this used to only check `from` unlike the other branches -- why?\n // did I break something?\n } else if (\n from instanceof HTMLOptionElement &&\n to instanceof HTMLOptionElement\n ) {\n syncBooleanAttribute(from, to, \"selected\", ctx);\n } else if (\n from instanceof HTMLTextAreaElement &&\n to instanceof HTMLTextAreaElement\n ) {\n let fromValue = from.value;\n let toValue = to.value;\n if (ignoreAttribute(\"value\", to, \"update\", ctx)) {\n return;\n }\n if (fromValue !== toValue) {\n to.value = fromValue;\n }\n if (to.firstChild && to.firstChild.nodeValue !== fromValue) {\n to.firstChild.nodeValue = fromValue;\n }\n }\n }\n\n /**\n * =============================================================================\n * The HEAD tag can be handled specially, either w/ a 'merge' or 'append' style\n * =============================================================================\n * @param {Element} newHeadTag\n * @param {Element} currentHead\n * @param {MorphContext} ctx\n * @returns {Promise<void>[]}\n */\n function handleHeadElement(newHeadTag, currentHead, ctx) {\n /**\n * @type {Node[]}\n */\n let added = [];\n /**\n * @type {Element[]}\n */\n let removed = [];\n /**\n * @type {Element[]}\n */\n let preserved = [];\n /**\n * @type {Element[]}\n */\n let nodesToAppend = [];\n\n let headMergeStyle = ctx.head.style;\n\n // put all new head elements into a Map, by their outerHTML\n let srcToNewHeadNodes = new Map();\n for (const newHeadChild of newHeadTag.children) {\n srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);\n }\n\n // for each elt in the current head\n for (const currentHeadElt of currentHead.children) {\n // If the current head element is in the map\n let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);\n let isReAppended = ctx.head.shouldReAppend(currentHeadElt);\n let isPreserved = ctx.head.shouldPreserve(currentHeadElt);\n if (inNewContent || isPreserved) {\n if (isReAppended) {\n // remove the current version and let the new version replace it and re-execute\n removed.push(currentHeadElt);\n } else {\n // this element already exists and should not be re-appended, so remove it from\n // the new content map, preserving it in the DOM\n srcToNewHeadNodes.delete(currentHeadElt.outerHTML);\n preserved.push(currentHeadElt);\n }\n } else {\n if (headMergeStyle === \"append\") {\n // we are appending and this existing element is not new content\n // so if and only if it is marked for re-append do we do anything\n if (isReAppended) {\n removed.push(currentHeadElt);\n nodesToAppend.push(currentHeadElt);\n }\n } else {\n // if this is a merge, we remove this content since it is not in the new head\n if (ctx.head.shouldRemove(currentHeadElt) !== false) {\n removed.push(currentHeadElt);\n }\n }\n }\n }\n\n // Push the remaining new head elements in the Map into the\n // nodes to append to the head tag\n nodesToAppend.push(...srcToNewHeadNodes.values());\n log(\"to append: \", nodesToAppend);\n\n let promises = [];\n for (const newNode of nodesToAppend) {\n log(\"adding: \", newNode);\n // TODO: This could theoretically be null, based on type\n let newElt = /** @type {ChildNode} */ (\n document.createRange().createContextualFragment(newNode.outerHTML)\n .firstChild\n );\n log(newElt);\n if (ctx.callbacks.beforeNodeAdded(newElt) !== false) {\n if (\n (\"href\" in newElt && newElt.href) ||\n (\"src\" in newElt && newElt.src)\n ) {\n /** @type {(result?: any) => void} */ let resolve;\n let promise = new Promise(function (_resolve) {\n resolve = _resolve;\n });\n newElt.addEventListener(\"load\", function () {\n resolve();\n });\n promises.push(promise);\n }\n currentHead.appendChild(newElt);\n ctx.callbacks.afterNodeAdded(newElt);\n added.push(newElt);\n }\n }\n\n // remove all removed elements, after we have appended the new elements to avoid\n // additional network requests for things like style sheets\n for (const removedElement of removed) {\n if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {\n currentHead.removeChild(removedElement);\n ctx.callbacks.afterNodeRemoved(removedElement);\n }\n }\n\n ctx.head.afterHeadMorphed(currentHead, {\n added: added,\n kept: preserved,\n removed: removed,\n });\n return promises;\n }\n\n //=============================================================================\n // Misc\n //=============================================================================\n\n /**\n * @param {any[]} _args\n */\n function log(..._args) {\n //console.log(args);\n }\n\n function noOp() {}\n\n /**\n * Deep merges the config object and the Idiomoroph.defaults object to\n * produce a final configuration object\n * @param {Config} config\n * @returns {ConfigInternal}\n */\n function mergeDefaults(config) {\n /**\n * @type {ConfigInternal}\n */\n let finalConfig = Object.assign({}, defaults);\n\n // copy top level stuff into final config\n Object.assign(finalConfig, config);\n\n // copy callbacks into final config (do this to deep merge the callbacks)\n finalConfig.callbacks = Object.assign(\n {},\n defaults.callbacks,\n config.callbacks,\n );\n\n // copy head config into final config (do this to deep merge the head)\n finalConfig.head = Object.assign({}, defaults.head, config.head);\n\n return finalConfig;\n }\n\n /**\n *\n * @param {Element} oldNode\n * @param {Element} newContent\n * @param {Config} config\n * @returns {MorphContext}\n */\n function createMorphContext(oldNode, newContent, config) {\n const mergedConfig = mergeDefaults(config);\n return {\n target: oldNode,\n newContent: newContent,\n config: mergedConfig,\n morphStyle: mergedConfig.morphStyle,\n ignoreActive: mergedConfig.ignoreActive,\n ignoreActiveValue: mergedConfig.ignoreActiveValue,\n idMap: createIdMap(oldNode, newContent),\n deadIds: new Set(),\n persistentIds: mergedConfig.twoPass\n ? createPersistentIds(oldNode, newContent)\n : new Set(),\n pantry: mergedConfig.twoPass\n ? createPantry()\n : document.createElement(\"div\"),\n callbacks: mergedConfig.callbacks,\n head: mergedConfig.head,\n };\n }\n\n function createPantry() {\n const pantry = document.createElement(\"div\");\n pantry.hidden = true;\n document.body.insertAdjacentElement(\"afterend\", pantry);\n return pantry;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Node | null} node2\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n // TODO: The function handles this as if it's Element or null, but the function is called in\n // places where the arguments may be just a Node, not an Element\n function isIdSetMatch(node1, node2, ctx) {\n if (node1 == null || node2 == null) {\n return false;\n }\n if (\n node1 instanceof Element &&\n node2 instanceof Element &&\n node1.tagName === node2.tagName\n ) {\n if (node1.id !== \"\" && node1.id === node2.id) {\n return true;\n } else {\n return getIdIntersectionCount(ctx, node1, node2) > 0;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {Node | null} oldNode\n * @param {Node | null} newNode\n * @returns {boolean}\n */\n function isSoftMatch(oldNode, newNode) {\n if (oldNode == null || newNode == null) {\n return false;\n }\n // ok to cast: if one is not element, `id` or `tagName` will be undefined and we'll compare that\n // If oldNode has an `id` with possible state and it doesn't match newNode.id then avoid morphing\n if (\n /** @type {Element} */ (oldNode).id &&\n /** @type {Element} */ (oldNode).id !==\n /** @type {Element} */ (newNode).id\n ) {\n return false;\n }\n return (\n oldNode.nodeType === newNode.nodeType &&\n /** @type {Element} */ (oldNode).tagName ===\n /** @type {Element} */ (newNode).tagName\n );\n }\n\n /**\n *\n * @param {Node} startInclusive\n * @param {Node} endExclusive\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function removeNodesBetween(startInclusive, endExclusive, ctx) {\n /** @type {Node | null} */ let cursor = startInclusive;\n while (cursor !== endExclusive) {\n let tempNode = /** @type {Node} */ (cursor);\n // TODO: Prefer assigning to a new variable here or expand the type of startInclusive\n // to be Node | null\n cursor = tempNode.nextSibling;\n removeNode(tempNode, ctx);\n }\n removeIdsFromConsideration(ctx, endExclusive);\n return endExclusive.nextSibling;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential id match\n * for the newChild. We stop if we find a potential id match for the new child OR\n * if the number of potential id matches we are discarding is greater than the\n * potential id matches for the new child\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findIdSetMatch(\n newContent,\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n ) {\n // max id matches we are willing to discard in our search\n let newChildPotentialIdCount = getIdIntersectionCount(\n ctx,\n newChild,\n oldParent,\n );\n\n /**\n * @type {Node | null}\n */\n let potentialMatch = null;\n\n // only search forward if there is a possibility of an id match\n if (newChildPotentialIdCount > 0) {\n // TODO: This is ghosting the potentialMatch variable outside of this block.\n // Probably an error\n potentialMatch = insertionPoint;\n // if there is a possibility of an id match, scan forward\n // keep track of the potential id match count we are discarding (the\n // newChildPotentialIdCount must be greater than this to make it likely\n // worth it)\n let otherMatchCount = 0;\n while (potentialMatch != null) {\n // If we have an id match, return the current potential match\n if (isIdSetMatch(newChild, potentialMatch, ctx)) {\n return potentialMatch;\n }\n\n // computer the other potential matches of this new content\n otherMatchCount += getIdIntersectionCount(\n ctx,\n potentialMatch,\n newContent,\n );\n if (otherMatchCount > newChildPotentialIdCount) {\n // if we have more potential id matches in _other_ content, we\n // do not have a good candidate for an id match, so return null\n return null;\n }\n\n // advanced to the next old content child\n potentialMatch = potentialMatch.nextSibling;\n }\n }\n return potentialMatch;\n }\n\n /**\n * =============================================================================\n * Scans forward from the insertionPoint in the old parent looking for a potential soft match\n * for the newChild. We stop if we find a potential soft match for the new child OR\n * if we find a potential id match in the old parents children OR if we find two\n * potential soft matches for the next two pieces of new content\n * =============================================================================\n * @param {Node} newContent\n * @param {Node} oldParent\n * @param {Node} newChild\n * @param {Node} insertionPoint\n * @param {MorphContext} ctx\n * @returns {null | Node}\n */\n function findSoftMatch(newContent, oldParent, newChild, insertionPoint, ctx) {\n /**\n * @type {Node | null}\n */\n let potentialSoftMatch = insertionPoint;\n /**\n * @type {Node | null}\n */\n let nextSibling = newChild.nextSibling;\n let siblingSoftMatchCount = 0;\n\n while (potentialSoftMatch != null) {\n if (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) {\n // the current potential soft match has a potential id set match with the remaining new\n // content so bail out of looking\n return null;\n }\n\n // if we have a soft match with the current node, return it\n if (isSoftMatch(potentialSoftMatch, newChild)) {\n return potentialSoftMatch;\n }\n\n if (isSoftMatch(potentialSoftMatch, nextSibling)) {\n // the next new node has a soft match with this node, so\n // increment the count of future soft matches\n siblingSoftMatchCount++;\n // ok to cast: if it was null it couldn't be a soft match\n nextSibling = /** @type {Node} */ (nextSibling).nextSibling;\n\n // If there are two future soft matches, bail to allow the siblings to soft match\n // so that we don't consume future soft matches for the sake of the current node\n if (siblingSoftMatchCount >= 2) {\n return null;\n }\n }\n\n // advanced to the next old content child\n potentialSoftMatch = potentialSoftMatch.nextSibling;\n }\n\n return potentialSoftMatch;\n }\n\n /** @type {WeakSet<Node>} */\n const generatedByIdiomorph = new WeakSet();\n\n /**\n *\n * @param {string} newContent\n * @returns {Node | null | DocumentFragment}\n */\n function parseContent(newContent) {\n let parser = new DOMParser();\n\n // remove svgs to avoid false-positive matches on head, etc.\n let contentWithSvgsRemoved = newContent.replace(\n /<svg(\\s[^>]*>|>)([\\s\\S]*?)<\\/svg>/gim,\n \"\",\n );\n\n // if the newContent contains a html, head or body tag, we can simply parse it w/o wrapping\n if (\n contentWithSvgsRemoved.match(/<\\/html>/) ||\n contentWithSvgsRemoved.match(/<\\/head>/) ||\n contentWithSvgsRemoved.match(/<\\/body>/)\n ) {\n let content = parser.parseFromString(newContent, \"text/html\");\n // if it is a full HTML document, return the document itself as the parent container\n if (contentWithSvgsRemoved.match(/<\\/html>/)) {\n generatedByIdiomorph.add(content);\n return content;\n } else {\n // otherwise return the html element as the parent container\n let htmlElement = content.firstChild;\n if (htmlElement) {\n generatedByIdiomorph.add(htmlElement);\n return htmlElement;\n } else {\n return null;\n }\n }\n } else {\n // if it is partial HTML, wrap it in a template tag to provide a parent element and also to help\n // deal with touchy tags like tr, tbody, etc.\n let responseDoc = parser.parseFromString(\n \"<body><template>\" + newContent + \"</template></body>\",\n \"text/html\",\n );\n let content = /** @type {HTMLTemplateElement} */ (\n responseDoc.body.querySelector(\"template\")\n ).content;\n generatedByIdiomorph.add(content);\n return content;\n }\n }\n\n /**\n *\n * @param {null | Node | HTMLCollection | Node[] | Document & {generatedByIdiomorph:boolean}} newContent\n * @returns {Element}\n */\n function normalizeContent(newContent) {\n if (newContent == null) {\n // noinspection UnnecessaryLocalVariableJS\n const dummyParent = document.createElement(\"div\");\n return dummyParent;\n } else if (generatedByIdiomorph.has(/** @type {Element} */ (newContent))) {\n // the template tag created by idiomorph parsing can serve as a dummy parent\n return /** @type {Element} */ (newContent);\n } else if (newContent instanceof Node) {\n // a single node is added as a child to a dummy parent\n const dummyParent = document.createElement(\"div\");\n dummyParent.append(newContent);\n return dummyParent;\n } else {\n // all nodes in the array or HTMLElement collection are consolidated under\n // a single dummy parent element\n const dummyParent = document.createElement(\"div\");\n for (const elt of [...newContent]) {\n dummyParent.append(elt);\n }\n return dummyParent;\n }\n }\n\n /**\n *\n * @param {Node | null} previousSibling\n * @param {Node} morphedNode\n * @param {Node | null} nextSibling\n * @returns {Node[]}\n */\n function insertSiblings(previousSibling, morphedNode, nextSibling) {\n /**\n * @type {Node[]}\n */\n let stack = [];\n /**\n * @type {Node[]}\n */\n let added = [];\n while (previousSibling != null) {\n stack.push(previousSibling);\n previousSibling = previousSibling.previousSibling;\n }\n // Base the loop on the node variable, so that you do not need runtime checks for\n // undefined value inside the loop\n let node = stack.pop();\n while (node !== undefined) {\n added.push(node); // push added preceding siblings on in order and insert\n morphedNode.parentElement?.insertBefore(node, morphedNode);\n node = stack.pop();\n }\n added.push(morphedNode);\n while (nextSibling != null) {\n stack.push(nextSibling);\n added.push(nextSibling); // here we are going in order, so push on as we scan, rather than add\n nextSibling = nextSibling.nextSibling;\n }\n while (stack.length > 0) {\n const node = /** @type {Node} */ (stack.pop());\n morphedNode.parentElement?.insertBefore(node, morphedNode.nextSibling);\n }\n return added;\n }\n\n /**\n *\n * @param {Element} newContent\n * @param {Element} oldNode\n * @param {MorphContext} ctx\n * @returns {Node | null}\n */\n function findBestNodeMatch(newContent, oldNode, ctx) {\n /**\n * @type {Node | null}\n */\n let currentElement;\n currentElement = newContent.firstChild;\n /**\n * @type {Node | null}\n */\n let bestElement = currentElement;\n let score = 0;\n while (currentElement) {\n let newScore = scoreElement(currentElement, oldNode, ctx);\n if (newScore > score) {\n bestElement = currentElement;\n score = newScore;\n }\n currentElement = currentElement.nextSibling;\n }\n return bestElement;\n }\n\n /**\n *\n * @param {Node | null} node1\n * @param {Element} node2\n * @param {MorphContext} ctx\n * @returns {number}\n */\n // TODO: The function handles node1 and node2 as if they are Elements but the function is\n // called in places where node1 and node2 may be just Nodes, not Elements\n function scoreElement(node1, node2, ctx) {\n if (isSoftMatch(node2, node1)) {\n // ok to cast: isSoftMatch performs a null check\n return (\n 0.5 + getIdIntersectionCount(ctx, /** @type {Node} */ (node1), node2)\n );\n }\n return 0;\n }\n\n /**\n *\n * @param {Node} tempNode\n * @param {MorphContext} ctx\n */\n // TODO: The function handles tempNode as if it's Element but the function is called in\n // places where tempNode may be just a Node, not an Element\n function removeNode(tempNode, ctx) {\n removeIdsFromConsideration(ctx, tempNode);\n // skip remove callbacks when we're going to be restoring this from the pantry in the second pass\n if (\n ctx.config.twoPass &&\n hasPersistentIdNodes(ctx, tempNode) &&\n tempNode instanceof Element\n ) {\n moveToPantry(tempNode, ctx);\n } else {\n if (ctx.callbacks.beforeNodeRemoved(tempNode) === false) return;\n tempNode.parentNode?.removeChild(tempNode);\n ctx.callbacks.afterNodeRemoved(tempNode);\n }\n }\n\n /**\n *\n * @param {Node} node\n * @param {MorphContext} ctx\n */\n function moveToPantry(node, ctx) {\n if (ctx.callbacks.beforeNodePantried(node) === false) return;\n\n Array.from(node.childNodes).forEach((child) => {\n moveToPantry(child, ctx);\n });\n\n // After processing children, process the current node\n if (ctx.persistentIds.has(/** @type {Element} */ (node).id)) {\n // @ts-ignore - use proposed moveBefore feature\n if (ctx.pantry.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n ctx.pantry.moveBefore(node, null);\n } else {\n ctx.pantry.insertBefore(node, null);\n }\n } else {\n if (ctx.callbacks.beforeNodeRemoved(node) === false) return;\n node.parentNode?.removeChild(node);\n ctx.callbacks.afterNodeRemoved(node);\n }\n }\n\n /**\n *\n * @param {Node | null} root\n * @param {MorphContext} ctx\n */\n function restoreFromPantry(root, ctx) {\n if (root instanceof Element) {\n Array.from(ctx.pantry.children)\n .reverse()\n .forEach((element) => {\n const matchElement = root.querySelector(`#${element.id}`);\n if (matchElement) {\n // @ts-ignore - use proposed moveBefore feature\n if (matchElement.parentElement?.moveBefore) {\n // @ts-ignore - use proposed moveBefore feature\n matchElement.parentElement.moveBefore(element, matchElement);\n while (matchElement.hasChildNodes()) {\n // @ts-ignore - use proposed moveBefore feature\n element.moveBefore(matchElement.firstChild, null);\n }\n } else {\n matchElement.before(element);\n while (matchElement.firstChild) {\n element.insertBefore(matchElement.firstChild, null);\n }\n }\n if (\n ctx.callbacks.beforeNodeMorphed(element, matchElement) !== false\n ) {\n syncNodeFrom(matchElement, element, ctx);\n ctx.callbacks.afterNodeMorphed(element, matchElement);\n }\n matchElement.remove();\n }\n });\n ctx.pantry.remove();\n }\n }\n\n //=============================================================================\n // ID Set Functions\n //=============================================================================\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @returns {boolean}\n */\n function isIdInConsideration(ctx, id) {\n return !ctx.deadIds.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {string} id\n * @param {Node} targetNode\n * @returns {boolean}\n */\n function idIsWithinNode(ctx, id, targetNode) {\n let idSet = ctx.idMap.get(targetNode) || EMPTY_SET;\n return idSet.has(id);\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {void}\n */\n function removeIdsFromConsideration(ctx, node) {\n let idSet = ctx.idMap.get(node) || EMPTY_SET;\n for (const id of idSet) {\n ctx.deadIds.add(id);\n }\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node\n * @returns {boolean}\n */\n function hasPersistentIdNodes(ctx, node) {\n for (const id of ctx.idMap.get(node) || EMPTY_SET) {\n if (ctx.persistentIds.has(id)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} node1\n * @param {Node} node2\n * @returns {number}\n */\n function getIdIntersectionCount(ctx, node1, node2) {\n let sourceSet = ctx.idMap.get(node1) || EMPTY_SET;\n let matchCount = 0;\n for (const id of sourceSet) {\n // a potential match is an id in the source and potentialIdsSet, but\n // that has not already been merged into the DOM\n if (isIdInConsideration(ctx, id) && idIsWithinNode(ctx, id, node2)) {\n ++matchCount;\n }\n }\n return matchCount;\n }\n\n /**\n * @param {Element} content\n * @returns {Element[]}\n */\n function nodesWithIds(content) {\n let nodes = Array.from(content.querySelectorAll(\"[id]\"));\n if (content.id) {\n nodes.push(content);\n }\n return nodes;\n }\n\n /**\n * A bottom up algorithm that finds all elements with ids in the node\n * argument and populates id sets for those nodes and all their parents, generating\n * a set of ids contained within all nodes for the entire hierarchy in the DOM\n *\n * @param {Element} node\n * @param {Map<Node, Set<string>>} idMap\n */\n function populateIdMapForNode(node, idMap) {\n let nodeParent = node.parentElement;\n for (const elt of nodesWithIds(node)) {\n /**\n * @type {Element|null}\n */\n let current = elt;\n // walk up the parent hierarchy of that element, adding the id\n // of element to the parent's id set\n while (current !== nodeParent && current != null) {\n let idSet = idMap.get(current);\n // if the id set doesn't exist, create it and insert it in the map\n if (idSet == null) {\n idSet = new Set();\n idMap.set(current, idSet);\n }\n idSet.add(elt.id);\n current = current.parentElement;\n }\n }\n }\n\n /**\n * This function computes a map of nodes to all ids contained within that node (inclusive of the\n * node). This map can be used to ask if two nodes have intersecting sets of ids, which allows\n * for a looser definition of \"matching\" than tradition id matching, and allows child nodes\n * to contribute to a parent nodes matching.\n *\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Map<Node, Set<string>>} a map of nodes to id sets for the\n */\n function createIdMap(oldContent, newContent) {\n /**\n *\n * @type {Map<Node, Set<string>>}\n */\n let idMap = new Map();\n populateIdMapForNode(oldContent, idMap);\n populateIdMapForNode(newContent, idMap);\n return idMap;\n }\n\n /**\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {Set<string>} the id set of all persistent nodes that exist in both old and new content\n */\n function createPersistentIds(oldContent, newContent) {\n const toIdTagName = (node) => node.tagName + \"#\" + node.id;\n const oldIdSet = new Set(nodesWithIds(oldContent).map(toIdTagName));\n\n let matchIdSet = new Set();\n for (const newNode of nodesWithIds(newContent)) {\n if (oldIdSet.has(toIdTagName(newNode))) {\n matchIdSet.add(newNode.id);\n }\n }\n return matchIdSet;\n }\n\n //=============================================================================\n // This is what ends up becoming the Idiomorph global object\n //=============================================================================\n return {\n morph,\n defaults,\n };\n})();\n\nexport {Idiomorph};\n","\nconst topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n","import { safe, g, dup } from './utils'\nimport { Idiomorph } from 'idiomorph/dist/idiomorph.esm'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport const Component = ({ name, module, dependencies, node, templates, signal }) => {\n\n\tconst _model \t\t= module.model || {}\n\tconst initialState \t= (new Function( `return ${node.getAttribute('html-model') || '{}'}`))()\n\tconst tplid \t\t= node.getAttribute('tplid')\n\tconst scopeid \t\t= node.getAttribute('html-scopeid')\n\tconst tpl \t\t\t= templates[ tplid ]\n\tconst scope \t\t= g.scope[ scopeid ]\n\tconst model \t\t= dup(module?.model?.apply ? _model({ elm:node, initialState }) : _model)\n\tconst state \t\t= Object.assign({}, scope, model, initialState)\n\tconst view \t\t\t= module.view? module.view : (data) => data\n\tlet preserve\t\t= []\n\tlet tick\n\n\tconst base = {\n\t\tname,\n\t\tmodel,\n\t\telm: node,\n\t\ttemplate: tpl.template,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\tnode.addEventListener(':mount', fn)\n\t\t},\n\n\t\t/**\n\t\t * @State\n\t\t */\n\t\tstate : {\n\n\t\t\tprotected( list ) {\n\t\t\t\tif( list ) {\n\t\t\t\t\tpreserve = list\n\t\t\t\t} else {\n\t\t\t\t\treturn preserve\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tsave(data) {\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata( state )\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tset( data ) {\n\n\t\t\t\tif (!document.body.contains(node)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata(state)\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\n\t\t\t\tconst newstate = Object.assign({}, state, scope)\n\t\t\t\trender(newstate)\n\n\t\t\t\treturn Promise.resolve(newstate)\n\t\t\t},\n\n\t\t\tget() {\n\t\t\t\treturn Object.assign({}, state)\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * @Events\n\t\t */\n\t\ton( ev, selectorOrCallback, callback ) {\n\n\t\t\tif( callback ) {\n\t\t\t\tcallback.handler = (e) => {\n\t\t\t\t\tconst detail = e.detail || {}\n\t\t\t\t\tlet parent = e.target\n\t\t\t\t\twhile (parent) {\n\t\t\t\t\t\tif (parent.matches(selectorOrCallback)) {\n\t\t\t\t\t\t\te.delegateTarget = parent\n\t\t\t\t\t\t\tcallback.apply(node, [e].concat(detail.args))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parent === node) break\n\t\t\t\t\t\tparent = parent.parentNode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, callback.handler, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tcapture: (ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave')\n\t\t\t\t})\n\n\t\t\t} else {\n\t\t\t\tselectorOrCallback.handler = (e) => {\n\t\t\t\t\te.delegateTarget = node\n\t\t\t\t\tselectorOrCallback.apply(node, [e].concat(e.detail.args))\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, selectorOrCallback.handler, { signal })\n\t\t\t}\n\n\t\t},\n\n\t\toff( ev, callback ) {\n\t\t\tif( callback.handler ) {\n\t\t\t\tnode.removeEventListener(ev, callback.handler)\n\t\t\t}\n\t\t},\n\n\t\ttrigger(ev, selectorOrCallback, data) {\n\t\t\tif( selectorOrCallback.constructor === String ) {\n\t\t\t\tArray\n\t\t\t\t\t.from(node.querySelectorAll(selectorOrCallback))\n\t\t\t\t\t.forEach( children => {\n\t\t\t\t\t\tchildren.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }) )\n\t\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail:{ args: data } }))\n\t\t\t}\n\t\t},\n\n\t\temit(ev, data) {\n\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }))\n\t\t},\n\n\t\tunmount( fn ) {\n\t\t\tnode.addEventListener(':unmount', fn)\n\t\t},\n\n\t\tinnerHTML ( target, html_ ) {\n\t\t\tconst element = html_? target : node\n\t\t\tconst clone = element.cloneNode()\n\t\t\tconst html = html_? html_ : target\n\t\t\tclone.innerHTML = html\n\t\t\tIdiomorph.morph(element, clone)\n\t\t}\n\t}\n\n\tconst render = ( data ) => {\n\t\tclearTimeout( tick )\n\t\ttick = setTimeout(() => {\n\t\t\tconst html = tpl.render.call( view(data), node, safe, g )\n\t\t\tIdiomorph.morph( node, html, IdiomorphOptions(node) )\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tnode.querySelectorAll('[tplid]')\n\t\t\t\t\t.forEach((element) => {\n\t\t\t\t\t\tif(!element.base) return\n\t\t\t\t\t\telement.base.state.protected().forEach( key => delete data[key] )\n\t\t\t\t\t\telement.base.state.set(data)\n\t\t\t\t\t})\n\t\t\t\tPromise.resolve().then(() => g.scope = {})\n\t\t\t})\n\t\t})\n\t}\n\n\trender( state )\n\tnode.base = base\n\treturn module.default( base )\n}\n\nconst IdiomorphOptions = ( parent ) => ({\n\tcallbacks: {\n\t\tbeforeNodeMorphed( node ) {\n\t\t\tif( node.nodeType === 1 ) {\n\t\t\t\tif( 'html-static' in node.attributes ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif( node.base && node !== parent ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n","import { Component } from './component'\n\nexport const Element = ({ component, templates, start }) => {\n\n\tconst { name, module, dependencies } = component\n\n\treturn class extends HTMLElement {\n\n\t\tconstructor() {\n\t\t\tsuper()\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis.abortController = new AbortController()\n\n\t\t\tif( !this.getAttribute('tplid') ) {\n\t\t\t\tstart( this.parentNode )\n\t\t\t}\n\n\t\t\tconst rtrn = Component({\n\t\t\t\tnode:this,\n\t\t\t\tname,\n\t\t\t\tmodule,\n\t\t\t\tdependencies,\n\t\t\t\ttemplates,\n\t\t\t\tsignal: this.abortController.signal\n\t\t\t})\n\n\t\t\tif ( rtrn && rtrn.constructor === Promise ) {\n\t\t\t\trtrn.then(() => {\n\t\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t}\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.dispatchEvent( new CustomEvent(':unmount') )\n\t\t\tthis.abortController.abort()\n\t\t\tdelete this.base\n\t\t}\n\t}\n}\n","import { uuid, decodeHTML } from './utils'\n\nconst templates = {}\n\nconst config = {\n\ttags: ['{{', '}}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign( config, newconfig )\n}\n\nexport const template = ( target, { components }) => {\n\n\ttagElements( target, [...Object.keys( components ), '[html-if]', 'template'] )\n\tconst clone = target.cloneNode( true )\n\n\ttransformTemplate( clone )\n\tremoveTemplateTagsRecursively( clone )\n\tsetTemplates( clone, components )\n\n\treturn templates\n}\n\nexport const compile = ( html ) => {\n\n\tconst parsedHtml = JSON.stringify( html )\n\n\treturn new Function('$element', 'safe', '$g',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${parsedHtml\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+ decodeHTML(variable) +';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + decodeHTML(variable) +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nconst tagElements = ( target, keys ) => {\n\ttarget\n\t\t.querySelectorAll( keys.toString() )\n\t\t.forEach((node) => {\n\t\t\tif( node.localName === 'template' ) {\n\t\t\t\treturn tagElements( node.content, keys )\n\t\t\t}\n\t\t\tnode.setAttribute('tplid', uuid())\n\t\t\tif( node.getAttribute('html-if') && !node.id ) {\n\t\t\t\tnode.id = uuid()\n\t\t\t}\n\t\t})\n}\n\nconst transformAttributes = ( html ) => {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\n\treturn html\n\t\t.replace(/jails___scope-id/g, '%%_=$scopeid_%%')\n\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t// Booleans\n\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t// The rest\n\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\tif (key === 'key' || key === 'model' || key === 'scopeid' ) {\n\t\t\t\treturn all\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t} else {\n\t\t\t\treturn all\n\t\t\t}\n\t\t})\n}\n\nconst transformTemplate = ( clone ) => {\n\n\tclone.querySelectorAll('template, [html-for], [html-if], [html-inner], [html-class]')\n\t\t.forEach(( element ) => {\n\n\t\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\t\tconst htmlClass = element.getAttribute('html-class')\n\n\t\t\tif ( htmlFor ) {\n\n\t\t\t\telement.removeAttribute('html-for')\n\n\t\t\t\tconst split \t = htmlFor.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\t\tconst varname \t = split[1]\n\t\t\t\tconst object \t = split[2]\n\t\t\t\tconst objectname = object.split(/\\./).shift()\n\t\t\t\tconst open \t\t = document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${objectname}: ${objectname} }, { ${varname} :${varname}, $index: $index, $key: $key }); _%%`)\n\t\t\t\tconst close \t = document.createTextNode(`%%_ $index++; } })() _%%`)\n\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlIf) {\n\t\t\t\telement.removeAttribute('html-if')\n\t\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlInner) {\n\t\t\t\telement.removeAttribute('html-inner')\n\t\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t\t}\n\n\t\t\tif (htmlClass) {\n\t\t\t\telement.removeAttribute('html-class')\n\t\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t\t}\n\n\t\t\tif( element.localName === 'template' ) {\n\t\t\t\ttransformTemplate(element.content)\n\t\t\t}\n\t\t})\n}\n\nconst setTemplates = ( clone, components ) => {\n\n\tArray.from(clone.querySelectorAll('[tplid]'))\n\t\t.reverse()\n\t\t.forEach((node) => {\n\n\t\t\tconst tplid = node.getAttribute('tplid')\n\t\t\tconst name = node.localName\n\t\t\tnode.setAttribute('html-scopeid', 'jails___scope-id')\n\n\t\t\tif( name in components && components[name].module.template ) {\n\t\t\t\tconst children = node.innerHTML\n\t\t\t\tconst html = components[name].module.template({ elm:node, children })\n\t\t\t\tnode.innerHTML = html\n\t\t\t}\n\n\t\t\tconst html = transformAttributes(node.outerHTML)\n\n\t\t\ttemplates[ tplid ] = {\n\t\t\t\ttemplate: html,\n\t\t\t\trender\t: compile(html)\n\t\t\t}\n\t\t})\n}\n\nconst removeTemplateTagsRecursively = (node) => {\n\n\t// Get all <template> elements within the node\n\tconst templates = node.querySelectorAll('template')\n\n\ttemplates.forEach((template) => {\n\n\t\tif( template.getAttribute('html-if') || template.getAttribute('html-inner') ) {\n\t\t\treturn\n\t\t}\n\n\t\t// Process any nested <template> tags within this <template> first\n\t\tremoveTemplateTagsRecursively(template.content)\n\n\t\t// Get the parent of the <template> tag\n\t\tconst parent = template.parentNode\n\n\t\tif (parent) {\n\t\t\t// Move all child nodes from the <template>'s content to its parent\n\t\t\tconst content = template.content\n\t\t\twhile (content.firstChild) {\n\t\t\t\tparent.insertBefore(content.firstChild, template)\n\t\t\t}\n\t\t\t// Remove the <template> tag itself\n\t\t\tparent.removeChild(template)\n\t\t}\n\t})\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","import { Element } from './element'\nimport { template, templateConfig as config } from './template-system'\n\nconst components = {}\n\nexport { publish, subscribe } from './utils/pubsub'\n\nexport const templateConfig = (options) => {\n\tconfig( options )\n}\n\nexport const register = ( name, module, dependencies ) => {\n\tcomponents[ name ] = { name, module, dependencies }\n}\n\nexport const start = ( target = document.body ) => {\n\n\tconst templates = template( target, { components } )\n\n\tObject\n\t\t.values( components )\n\t\t.forEach(({ name, module, dependencies }) => {\n\t\t\tif( !customElements.get(name) ) {\n\t\t\t\tcustomElements.define( name, Element({ component: { name, module, dependencies }, templates, start }))\n\t\t\t}\n\t})\n}\n"],"names":["config","node","templates","Element","start","templateConfig","components","html","template"],"mappings":"AACA,MAAM,WAAW,SAAS,cAAc,UAAU;AAE3C,MAAM,IAAI;AAAA,EAChB,OAAO,CAAA;AACR;AAEa,MAAA,aAAa,CAAC,SAAS;AACnC,WAAS,YAAY;AACrB,SAAO,SAAS;AACjB;AASO,MAAM,OAAO,MAAM;AAClB,SAAA,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACjD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AY;AAC1CR,mBAAQ,OAAQ;AACjB;AAEO,MAAM,WAAW,CAAE,MAAM,QAAQ,iBAAkB;AACzD,aAAY,IAAK,IAAI,EAAE,MAAM,QAAQ,aAAa;AACnD;AAEO,MAAM,QAAQ,CAAE,SAAS,SAAS,SAAU;AAElD,QAAME,aAAY,SAAU,QAAQ,EAAE,YAAa;AAGjD,SAAA,OAAQ,UAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,QAAQ,mBAAmB;AAC5C,QAAI,CAAC,eAAe,IAAI,IAAI,GAAI;AAC/B,qBAAe,OAAQ,MAAMC,UAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,aAAa,GAAG,WAAAD,YAAW,MAAO,CAAA,CAAC;AAAA,IAAA;AAAA,EACtG,CACD;AACF;","x_google_ignoreList":[1]}
1
+ {"version":3,"file":"index.js","sources":["../src/utils/index.ts","../node_modules/idiomorph/dist/idiomorph.esm.js","../src/utils/pubsub.ts","../src/component.ts","../src/element.ts","../src/template-system.ts","../src/index.ts"],"sourcesContent":["\nconst textarea = document.createElement('textarea')\n\nexport const g = {\n\tscope: {}\n}\n\nexport const decodeHTML = (text) => {\n\ttextarea.innerHTML = text\n\treturn textarea.value\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn Math.random().toString(36).substring(2, 9)\n}\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\nexport const safe = (execute, val) => {\n\ttry{\n\t\treturn execute()\n\t}catch(err){\n\t\treturn val || ''\n\t}\n}\n","/**\n * @typedef {object} ConfigHead\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} [style]\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {function(Element): boolean} [shouldPreserve]\n * @property {function(Element): boolean} [shouldReAppend]\n * @property {function(Element): boolean} [shouldRemove]\n * @property {function(Element, {added: Node[], kept: Element[], removed: Element[]}): void} [afterHeadMorphed]\n */\n\n/**\n * @typedef {object} ConfigCallbacks\n *\n * @property {function(Node): boolean} [beforeNodeAdded]\n * @property {function(Node): void} [afterNodeAdded]\n * @property {function(Element, Node): boolean} [beforeNodeMorphed]\n * @property {function(Element, Node): void} [afterNodeMorphed]\n * @property {function(Element): boolean} [beforeNodeRemoved]\n * @property {function(Element): void} [afterNodeRemoved]\n * @property {function(string, Element, \"update\" | \"remove\"): boolean} [beforeAttributeUpdated]\n */\n\n/**\n * @typedef {object} Config\n *\n * @property {'outerHTML' | 'innerHTML'} [morphStyle]\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {boolean} [restoreFocus]\n * @property {ConfigCallbacks} [callbacks]\n * @property {ConfigHead} [head]\n */\n\n/**\n * @typedef {function} NoOp\n *\n * @returns {void}\n */\n\n/**\n * @typedef {object} ConfigHeadInternal\n *\n * @property {'merge' | 'append' | 'morph' | 'none'} style\n * @property {boolean} [block]\n * @property {boolean} [ignore]\n * @property {(function(Element): boolean) | NoOp} shouldPreserve\n * @property {(function(Element): boolean) | NoOp} shouldReAppend\n * @property {(function(Element): boolean) | NoOp} shouldRemove\n * @property {(function(Element, {added: Node[], kept: Element[], removed: Element[]}): void) | NoOp} afterHeadMorphed\n */\n\n/**\n * @typedef {object} ConfigCallbacksInternal\n *\n * @property {(function(Node): boolean) | NoOp} beforeNodeAdded\n * @property {(function(Node): void) | NoOp} afterNodeAdded\n * @property {(function(Node, Node): boolean) | NoOp} beforeNodeMorphed\n * @property {(function(Node, Node): void) | NoOp} afterNodeMorphed\n * @property {(function(Node): boolean) | NoOp} beforeNodeRemoved\n * @property {(function(Node): void) | NoOp} afterNodeRemoved\n * @property {(function(string, Element, \"update\" | \"remove\"): boolean) | NoOp} beforeAttributeUpdated\n */\n\n/**\n * @typedef {object} ConfigInternal\n *\n * @property {'outerHTML' | 'innerHTML'} morphStyle\n * @property {boolean} [ignoreActive]\n * @property {boolean} [ignoreActiveValue]\n * @property {boolean} [restoreFocus]\n * @property {ConfigCallbacksInternal} callbacks\n * @property {ConfigHeadInternal} head\n */\n\n/**\n * @typedef {Object} IdSets\n * @property {Set<string>} persistentIds\n * @property {Map<Node, Set<string>>} idMap\n */\n\n/**\n * @typedef {Function} Morph\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {undefined | Node[]}\n */\n\n// base IIFE to define idiomorph\n/**\n *\n * @type {{defaults: ConfigInternal, morph: Morph}}\n */\nvar Idiomorph = (function () {\n \"use strict\";\n\n /**\n * @typedef {object} MorphContext\n *\n * @property {Element} target\n * @property {Element} newContent\n * @property {ConfigInternal} config\n * @property {ConfigInternal['morphStyle']} morphStyle\n * @property {ConfigInternal['ignoreActive']} ignoreActive\n * @property {ConfigInternal['ignoreActiveValue']} ignoreActiveValue\n * @property {ConfigInternal['restoreFocus']} restoreFocus\n * @property {Map<Node, Set<string>>} idMap\n * @property {Set<string>} persistentIds\n * @property {ConfigInternal['callbacks']} callbacks\n * @property {ConfigInternal['head']} head\n * @property {HTMLDivElement} pantry\n */\n\n //=============================================================================\n // AND NOW IT BEGINS...\n //=============================================================================\n\n const noOp = () => {};\n /**\n * Default configuration values, updatable by users now\n * @type {ConfigInternal}\n */\n const defaults = {\n morphStyle: \"outerHTML\",\n callbacks: {\n beforeNodeAdded: noOp,\n afterNodeAdded: noOp,\n beforeNodeMorphed: noOp,\n afterNodeMorphed: noOp,\n beforeNodeRemoved: noOp,\n afterNodeRemoved: noOp,\n beforeAttributeUpdated: noOp,\n },\n head: {\n style: \"merge\",\n shouldPreserve: (elt) => elt.getAttribute(\"im-preserve\") === \"true\",\n shouldReAppend: (elt) => elt.getAttribute(\"im-re-append\") === \"true\",\n shouldRemove: noOp,\n afterHeadMorphed: noOp,\n },\n restoreFocus: true,\n };\n\n /**\n * Core idiomorph function for morphing one DOM tree to another\n *\n * @param {Element | Document} oldNode\n * @param {Element | Node | HTMLCollection | Node[] | string | null} newContent\n * @param {Config} [config]\n * @returns {Promise<Node[]> | Node[]}\n */\n function morph(oldNode, newContent, config = {}) {\n oldNode = normalizeElement(oldNode);\n const newNode = normalizeParent(newContent);\n const ctx = createMorphContext(oldNode, newNode, config);\n\n const morphedNodes = saveAndRestoreFocus(ctx, () => {\n return withHeadBlocking(\n ctx,\n oldNode,\n newNode,\n /** @param {MorphContext} ctx */ (ctx) => {\n if (ctx.morphStyle === \"innerHTML\") {\n morphChildren(ctx, oldNode, newNode);\n return Array.from(oldNode.childNodes);\n } else {\n return morphOuterHTML(ctx, oldNode, newNode);\n }\n },\n );\n });\n\n ctx.pantry.remove();\n return morphedNodes;\n }\n\n /**\n * Morph just the outerHTML of the oldNode to the newContent\n * We have to be careful because the oldNode could have siblings which need to be untouched\n * @param {MorphContext} ctx\n * @param {Element} oldNode\n * @param {Element} newNode\n * @returns {Node[]}\n */\n function morphOuterHTML(ctx, oldNode, newNode) {\n const oldParent = normalizeParent(oldNode);\n\n // basis for calulating which nodes were morphed\n // since there may be unmorphed sibling nodes\n let childNodes = Array.from(oldParent.childNodes);\n const index = childNodes.indexOf(oldNode);\n // how many elements are to the right of the oldNode\n const rightMargin = childNodes.length - (index + 1);\n\n morphChildren(\n ctx,\n oldParent,\n newNode,\n // these two optional params are the secret sauce\n oldNode, // start point for iteration\n oldNode.nextSibling, // end point for iteration\n );\n\n // return just the morphed nodes\n childNodes = Array.from(oldParent.childNodes);\n return childNodes.slice(index, childNodes.length - rightMargin);\n }\n\n /**\n * @param {MorphContext} ctx\n * @param {Function} fn\n * @returns {Promise<Node[]> | Node[]}\n */\n function saveAndRestoreFocus(ctx, fn) {\n if (!ctx.config.restoreFocus) return fn();\n let activeElement =\n /** @type {HTMLInputElement|HTMLTextAreaElement|null} */ (\n document.activeElement\n );\n\n // don't bother if the active element is not an input or textarea\n if (\n !(\n activeElement instanceof HTMLInputElement ||\n activeElement instanceof HTMLTextAreaElement\n )\n ) {\n return fn();\n }\n\n const { id: activeElementId, selectionStart, selectionEnd } = activeElement;\n\n const results = fn();\n\n if (activeElementId && activeElementId !== document.activeElement?.id) {\n activeElement = ctx.target.querySelector(`#${activeElementId}`);\n activeElement?.focus();\n }\n if (activeElement && !activeElement.selectionEnd && selectionEnd) {\n activeElement.setSelectionRange(selectionStart, selectionEnd);\n }\n\n return results;\n }\n\n const morphChildren = (function () {\n /**\n * This is the core algorithm for matching up children. The idea is to use id sets to try to match up\n * nodes as faithfully as possible. We greedily match, which allows us to keep the algorithm fast, but\n * by using id sets, we are able to better match up with content deeper in the DOM.\n *\n * Basic algorithm:\n * - for each node in the new content:\n * - search self and siblings for an id set match, falling back to a soft match\n * - if match found\n * - remove any nodes up to the match:\n * - pantry persistent nodes\n * - delete the rest\n * - morph the match\n * - elsif no match found, and node is persistent\n * - find its match by querying the old root (future) and pantry (past)\n * - move it and its children here\n * - morph it\n * - else\n * - create a new node from scratch as a last result\n *\n * @param {MorphContext} ctx the merge context\n * @param {Element} oldParent the old content that we are merging the new content into\n * @param {Element} newParent the parent element of the new content\n * @param {Node|null} [insertionPoint] the point in the DOM we start morphing at (defaults to first child)\n * @param {Node|null} [endPoint] the point in the DOM we stop morphing at (defaults to after last child)\n */\n function morphChildren(\n ctx,\n oldParent,\n newParent,\n insertionPoint = null,\n endPoint = null,\n ) {\n // normalize\n if (\n oldParent instanceof HTMLTemplateElement &&\n newParent instanceof HTMLTemplateElement\n ) {\n // @ts-ignore we can pretend the DocumentFragment is an Element\n oldParent = oldParent.content;\n // @ts-ignore ditto\n newParent = newParent.content;\n }\n insertionPoint ||= oldParent.firstChild;\n\n // run through all the new content\n for (const newChild of newParent.childNodes) {\n // once we reach the end of the old parent content skip to the end and insert the rest\n if (insertionPoint && insertionPoint != endPoint) {\n const bestMatch = findBestMatch(\n ctx,\n newChild,\n insertionPoint,\n endPoint,\n );\n if (bestMatch) {\n // if the node to morph is not at the insertion point then remove/move up to it\n if (bestMatch !== insertionPoint) {\n removeNodesBetween(ctx, insertionPoint, bestMatch);\n }\n morphNode(bestMatch, newChild, ctx);\n insertionPoint = bestMatch.nextSibling;\n continue;\n }\n }\n\n // if the matching node is elsewhere in the original content\n if (newChild instanceof Element && ctx.persistentIds.has(newChild.id)) {\n // move it and all its children here and morph\n const movedChild = moveBeforeById(\n oldParent,\n newChild.id,\n insertionPoint,\n ctx,\n );\n morphNode(movedChild, newChild, ctx);\n insertionPoint = movedChild.nextSibling;\n continue;\n }\n\n // last resort: insert the new node from scratch\n const insertedNode = createNode(\n oldParent,\n newChild,\n insertionPoint,\n ctx,\n );\n // could be null if beforeNodeAdded prevented insertion\n if (insertedNode) {\n insertionPoint = insertedNode.nextSibling;\n }\n }\n\n // remove any remaining old nodes that didn't match up with new content\n while (insertionPoint && insertionPoint != endPoint) {\n const tempNode = insertionPoint;\n insertionPoint = insertionPoint.nextSibling;\n removeNode(ctx, tempNode);\n }\n }\n\n /**\n * This performs the action of inserting a new node while handling situations where the node contains\n * elements with persistent ids and possible state info we can still preserve by moving in and then morphing\n *\n * @param {Element} oldParent\n * @param {Node} newChild\n * @param {Node|null} insertionPoint\n * @param {MorphContext} ctx\n * @returns {Node|null}\n */\n function createNode(oldParent, newChild, insertionPoint, ctx) {\n if (ctx.callbacks.beforeNodeAdded(newChild) === false) return null;\n if (ctx.idMap.has(newChild)) {\n // node has children with ids with possible state so create a dummy elt of same type and apply full morph algorithm\n const newEmptyChild = document.createElement(\n /** @type {Element} */ (newChild).tagName,\n );\n oldParent.insertBefore(newEmptyChild, insertionPoint);\n morphNode(newEmptyChild, newChild, ctx);\n ctx.callbacks.afterNodeAdded(newEmptyChild);\n return newEmptyChild;\n } else {\n // optimisation: no id state to preserve so we can just insert a clone of the newChild and its descendants\n const newClonedChild = document.importNode(newChild, true); // importNode to not mutate newParent\n oldParent.insertBefore(newClonedChild, insertionPoint);\n ctx.callbacks.afterNodeAdded(newClonedChild);\n return newClonedChild;\n }\n }\n\n //=============================================================================\n // Matching Functions\n //=============================================================================\n const findBestMatch = (function () {\n /**\n * Scans forward from the startPoint to the endPoint looking for a match\n * for the node. It looks for an id set match first, then a soft match.\n * We abort softmatching if we find two future soft matches, to reduce churn.\n * @param {Node} node\n * @param {MorphContext} ctx\n * @param {Node | null} startPoint\n * @param {Node | null} endPoint\n * @returns {Node | null}\n */\n function findBestMatch(ctx, node, startPoint, endPoint) {\n let softMatch = null;\n let nextSibling = node.nextSibling;\n let siblingSoftMatchCount = 0;\n\n let cursor = startPoint;\n while (cursor && cursor != endPoint) {\n // soft matching is a prerequisite for id set matching\n if (isSoftMatch(cursor, node)) {\n if (isIdSetMatch(ctx, cursor, node)) {\n return cursor; // found an id set match, we're done!\n }\n\n // we haven't yet saved a soft match fallback\n if (softMatch === null) {\n // the current soft match will hard match something else in the future, leave it\n if (!ctx.idMap.has(cursor)) {\n // save this as the fallback if we get through the loop without finding a hard match\n softMatch = cursor;\n }\n }\n }\n if (\n softMatch === null &&\n nextSibling &&\n isSoftMatch(cursor, nextSibling)\n ) {\n // The next new node has a soft match with this node, so\n // increment the count of future soft matches\n siblingSoftMatchCount++;\n nextSibling = nextSibling.nextSibling;\n\n // If there are two future soft matches, block soft matching for this node to allow\n // future siblings to soft match. This is to reduce churn in the DOM when an element\n // is prepended.\n if (siblingSoftMatchCount >= 2) {\n softMatch = undefined;\n }\n }\n\n // if the current node contains active element, stop looking for better future matches,\n // because if one is found, this node will be moved to the pantry, reparenting it and thus losing focus\n if (cursor.contains(document.activeElement)) break;\n\n cursor = cursor.nextSibling;\n }\n\n return softMatch || null;\n }\n\n /**\n *\n * @param {MorphContext} ctx\n * @param {Node} oldNode\n * @param {Node} newNode\n * @returns {boolean}\n */\n function isIdSetMatch(ctx, oldNode, newNode) {\n let oldSet = ctx.idMap.get(oldNode);\n let newSet = ctx.idMap.get(newNode);\n\n if (!newSet || !oldSet) return false;\n\n for (const id of oldSet) {\n // a potential match is an id in the new and old nodes that\n // has not already been merged into the DOM\n // But the newNode content we call this on has not been\n // merged yet and we don't allow duplicate IDs so it is simple\n if (newSet.has(id)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n *\n * @param {Node} oldNode\n * @param {Node} newNode\n * @returns {boolean}\n */\n function isSoftMatch(oldNode, newNode) {\n // ok to cast: if one is not element, `id` and `tagName` will be undefined and we'll just compare that.\n const oldElt = /** @type {Element} */ (oldNode);\n const newElt = /** @type {Element} */ (newNode);\n\n return (\n oldElt.nodeType === newElt.nodeType &&\n oldElt.tagName === newElt.tagName &&\n // If oldElt has an `id` with possible state and it doesn't match newElt.id then avoid morphing.\n // We'll still match an anonymous node with an IDed newElt, though, because if it got this far,\n // its not persistent, and new nodes can't have any hidden state.\n (!oldElt.id || oldElt.id === newElt.id)\n );\n }\n\n return findBestMatch;\n })();\n\n //=============================================================================\n // DOM Manipulation Functions\n //=============================================================================\n\n /**\n * Gets rid of an unwanted DOM node; strategy depends on nature of its reuse:\n * - Persistent nodes will be moved to the pantry for later reuse\n * - Other nodes will have their hooks called, and then are removed\n * @param {MorphContext} ctx\n * @param {Node} node\n */\n function removeNode(ctx, node) {\n // are we going to id set match this later?\n if (ctx.idMap.has(node)) {\n // skip callbacks and move to pantry\n moveBefore(ctx.pantry, node, null);\n } else {\n // remove for realsies\n if (ctx.callbacks.beforeNodeRemoved(node) === false) return;\n node.parentNode?.removeChild(node);\n ctx.callbacks.afterNodeRemoved(node);\n }\n }\n\n /**\n * Remove nodes between the start and end nodes\n * @param {MorphContext} ctx\n * @param {Node} startInclusive\n * @param {Node} endExclusive\n * @returns {Node|null}\n */\n function removeNodesBetween(ctx, startInclusive, endExclusive) {\n /** @type {Node | null} */\n let cursor = startInclusive;\n // remove nodes until the endExclusive node\n while (cursor && cursor !== endExclusive) {\n let tempNode = /** @type {Node} */ (cursor);\n cursor = cursor.nextSibling;\n removeNode(ctx, tempNode);\n }\n return cursor;\n }\n\n /**\n * Search for an element by id within the document and pantry, and move it using moveBefore.\n *\n * @param {Element} parentNode - The parent node to which the element will be moved.\n * @param {string} id - The ID of the element to be moved.\n * @param {Node | null} after - The reference node to insert the element before.\n * If `null`, the element is appended as the last child.\n * @param {MorphContext} ctx\n * @returns {Element} The found element\n */\n function moveBeforeById(parentNode, id, after, ctx) {\n const target =\n /** @type {Element} - will always be found */\n (\n ctx.target.querySelector(`#${id}`) ||\n ctx.pantry.querySelector(`#${id}`)\n );\n removeElementFromAncestorsIdMaps(target, ctx);\n moveBefore(parentNode, target, after);\n return target;\n }\n\n /**\n * Removes an element from its ancestors' id maps. This is needed when an element is moved from the\n * \"future\" via `moveBeforeId`. Otherwise, its erstwhile ancestors could be mistakenly moved to the\n * pantry rather than being deleted, preventing their removal hooks from being called.\n *\n * @param {Element} element - element to remove from its ancestors' id maps\n * @param {MorphContext} ctx\n */\n function removeElementFromAncestorsIdMaps(element, ctx) {\n const id = element.id;\n /** @ts-ignore - safe to loop in this way **/\n while ((element = element.parentNode)) {\n let idSet = ctx.idMap.get(element);\n if (idSet) {\n idSet.delete(id);\n if (!idSet.size) {\n ctx.idMap.delete(element);\n }\n }\n }\n }\n\n /**\n * Moves an element before another element within the same parent.\n * Uses the proposed `moveBefore` API if available (and working), otherwise falls back to `insertBefore`.\n * This is essentialy a forward-compat wrapper.\n *\n * @param {Element} parentNode - The parent node containing the after element.\n * @param {Node} element - The element to be moved.\n * @param {Node | null} after - The reference node to insert `element` before.\n * If `null`, `element` is appended as the last child.\n */\n function moveBefore(parentNode, element, after) {\n // @ts-ignore - use proposed moveBefore feature\n if (parentNode.moveBefore) {\n try {\n // @ts-ignore - use proposed moveBefore feature\n parentNode.moveBefore(element, after);\n } catch (e) {\n // fall back to insertBefore as some browsers may fail on moveBefore when trying to move Dom disconnected nodes to pantry\n parentNode.insertBefore(element, after);\n }\n } else {\n parentNode.insertBefore(element, after);\n }\n }\n\n return morphChildren;\n })();\n\n //=============================================================================\n // Single Node Morphing Code\n //=============================================================================\n const morphNode = (function () {\n /**\n * @param {Node} oldNode root node to merge content into\n * @param {Node} newContent new content to merge\n * @param {MorphContext} ctx the merge context\n * @returns {Node | null} the element that ended up in the DOM\n */\n function morphNode(oldNode, newContent, ctx) {\n if (ctx.ignoreActive && oldNode === document.activeElement) {\n // don't morph focused element\n return null;\n }\n\n if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false) {\n return oldNode;\n }\n\n if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) {\n // ignore the head element\n } else if (\n oldNode instanceof HTMLHeadElement &&\n ctx.head.style !== \"morph\"\n ) {\n // ok to cast: if newContent wasn't also a <head>, it would've got caught in the `!isSoftMatch` branch above\n handleHeadElement(\n oldNode,\n /** @type {HTMLHeadElement} */ (newContent),\n ctx,\n );\n } else {\n morphAttributes(oldNode, newContent, ctx);\n if (!ignoreValueOfActiveElement(oldNode, ctx)) {\n // @ts-ignore newContent can be a node here because .firstChild will be null\n morphChildren(ctx, oldNode, newContent);\n }\n }\n ctx.callbacks.afterNodeMorphed(oldNode, newContent);\n return oldNode;\n }\n\n /**\n * syncs the oldNode to the newNode, copying over all attributes and\n * inner element state from the newNode to the oldNode\n *\n * @param {Node} oldNode the node to copy attributes & state to\n * @param {Node} newNode the node to copy attributes & state from\n * @param {MorphContext} ctx the merge context\n */\n function morphAttributes(oldNode, newNode, ctx) {\n let type = newNode.nodeType;\n\n // if is an element type, sync the attributes from the\n // new node into the new node\n if (type === 1 /* element type */) {\n const oldElt = /** @type {Element} */ (oldNode);\n const newElt = /** @type {Element} */ (newNode);\n\n const oldAttributes = oldElt.attributes;\n const newAttributes = newElt.attributes;\n for (const newAttribute of newAttributes) {\n if (ignoreAttribute(newAttribute.name, oldElt, \"update\", ctx)) {\n continue;\n }\n if (oldElt.getAttribute(newAttribute.name) !== newAttribute.value) {\n oldElt.setAttribute(newAttribute.name, newAttribute.value);\n }\n }\n // iterate backwards to avoid skipping over items when a delete occurs\n for (let i = oldAttributes.length - 1; 0 <= i; i--) {\n const oldAttribute = oldAttributes[i];\n\n // toAttributes is a live NamedNodeMap, so iteration+mutation is unsafe\n // e.g. custom element attribute callbacks can remove other attributes\n if (!oldAttribute) continue;\n\n if (!newElt.hasAttribute(oldAttribute.name)) {\n if (ignoreAttribute(oldAttribute.name, oldElt, \"remove\", ctx)) {\n continue;\n }\n oldElt.removeAttribute(oldAttribute.name);\n }\n }\n\n if (!ignoreValueOfActiveElement(oldElt, ctx)) {\n syncInputValue(oldElt, newElt, ctx);\n }\n }\n\n // sync text nodes\n if (type === 8 /* comment */ || type === 3 /* text */) {\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n }\n }\n\n /**\n * NB: many bothans died to bring us information:\n *\n * https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js\n * https://github.com/choojs/nanomorph/blob/master/lib/morph.jsL113\n *\n * @param {Element} oldElement the element to sync the input value to\n * @param {Element} newElement the element to sync the input value from\n * @param {MorphContext} ctx the merge context\n */\n function syncInputValue(oldElement, newElement, ctx) {\n if (\n oldElement instanceof HTMLInputElement &&\n newElement instanceof HTMLInputElement &&\n newElement.type !== \"file\"\n ) {\n let newValue = newElement.value;\n let oldValue = oldElement.value;\n\n // sync boolean attributes\n syncBooleanAttribute(oldElement, newElement, \"checked\", ctx);\n syncBooleanAttribute(oldElement, newElement, \"disabled\", ctx);\n\n if (!newElement.hasAttribute(\"value\")) {\n if (!ignoreAttribute(\"value\", oldElement, \"remove\", ctx)) {\n oldElement.value = \"\";\n oldElement.removeAttribute(\"value\");\n }\n } else if (oldValue !== newValue) {\n if (!ignoreAttribute(\"value\", oldElement, \"update\", ctx)) {\n oldElement.setAttribute(\"value\", newValue);\n oldElement.value = newValue;\n }\n }\n // TODO: QUESTION(1cg): this used to only check `newElement` unlike the other branches -- why?\n // did I break something?\n } else if (\n oldElement instanceof HTMLOptionElement &&\n newElement instanceof HTMLOptionElement\n ) {\n syncBooleanAttribute(oldElement, newElement, \"selected\", ctx);\n } else if (\n oldElement instanceof HTMLTextAreaElement &&\n newElement instanceof HTMLTextAreaElement\n ) {\n let newValue = newElement.value;\n let oldValue = oldElement.value;\n if (ignoreAttribute(\"value\", oldElement, \"update\", ctx)) {\n return;\n }\n if (newValue !== oldValue) {\n oldElement.value = newValue;\n }\n if (\n oldElement.firstChild &&\n oldElement.firstChild.nodeValue !== newValue\n ) {\n oldElement.firstChild.nodeValue = newValue;\n }\n }\n }\n\n /**\n * @param {Element} oldElement element to write the value to\n * @param {Element} newElement element to read the value from\n * @param {string} attributeName the attribute name\n * @param {MorphContext} ctx the merge context\n */\n function syncBooleanAttribute(oldElement, newElement, attributeName, ctx) {\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n const newLiveValue = newElement[attributeName],\n // @ts-ignore ditto\n oldLiveValue = oldElement[attributeName];\n if (newLiveValue !== oldLiveValue) {\n const ignoreUpdate = ignoreAttribute(\n attributeName,\n oldElement,\n \"update\",\n ctx,\n );\n if (!ignoreUpdate) {\n // update attribute's associated DOM property\n // @ts-ignore this function is only used on boolean attrs that are reflected as dom properties\n oldElement[attributeName] = newElement[attributeName];\n }\n if (newLiveValue) {\n if (!ignoreUpdate) {\n // https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML\n // this is the correct way to set a boolean attribute to \"true\"\n oldElement.setAttribute(attributeName, \"\");\n }\n } else {\n if (!ignoreAttribute(attributeName, oldElement, \"remove\", ctx)) {\n oldElement.removeAttribute(attributeName);\n }\n }\n }\n }\n\n /**\n * @param {string} attr the attribute to be mutated\n * @param {Element} element the element that is going to be updated\n * @param {\"update\" | \"remove\"} updateType\n * @param {MorphContext} ctx the merge context\n * @returns {boolean} true if the attribute should be ignored, false otherwise\n */\n function ignoreAttribute(attr, element, updateType, ctx) {\n if (\n attr === \"value\" &&\n ctx.ignoreActiveValue &&\n element === document.activeElement\n ) {\n return true;\n }\n return (\n ctx.callbacks.beforeAttributeUpdated(attr, element, updateType) ===\n false\n );\n }\n\n /**\n * @param {Node} possibleActiveElement\n * @param {MorphContext} ctx\n * @returns {boolean}\n */\n function ignoreValueOfActiveElement(possibleActiveElement, ctx) {\n return (\n !!ctx.ignoreActiveValue &&\n possibleActiveElement === document.activeElement &&\n possibleActiveElement !== document.body\n );\n }\n\n return morphNode;\n })();\n\n //=============================================================================\n // Head Management Functions\n //=============================================================================\n /**\n * @param {MorphContext} ctx\n * @param {Element} oldNode\n * @param {Element} newNode\n * @param {function} callback\n * @returns {Node[] | Promise<Node[]>}\n */\n function withHeadBlocking(ctx, oldNode, newNode, callback) {\n if (ctx.head.block) {\n const oldHead = oldNode.querySelector(\"head\");\n const newHead = newNode.querySelector(\"head\");\n if (oldHead && newHead) {\n const promises = handleHeadElement(oldHead, newHead, ctx);\n // when head promises resolve, proceed ignoring the head tag\n return Promise.all(promises).then(() => {\n const newCtx = Object.assign(ctx, {\n head: {\n block: false,\n ignore: true,\n },\n });\n return callback(newCtx);\n });\n }\n }\n // just proceed if we not head blocking\n return callback(ctx);\n }\n\n /**\n * The HEAD tag can be handled specially, either w/ a 'merge' or 'append' style\n *\n * @param {Element} oldHead\n * @param {Element} newHead\n * @param {MorphContext} ctx\n * @returns {Promise<void>[]}\n */\n function handleHeadElement(oldHead, newHead, ctx) {\n let added = [];\n let removed = [];\n let preserved = [];\n let nodesToAppend = [];\n\n // put all new head elements into a Map, by their outerHTML\n let srcToNewHeadNodes = new Map();\n for (const newHeadChild of newHead.children) {\n srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);\n }\n\n // for each elt in the current head\n for (const currentHeadElt of oldHead.children) {\n // If the current head element is in the map\n let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);\n let isReAppended = ctx.head.shouldReAppend(currentHeadElt);\n let isPreserved = ctx.head.shouldPreserve(currentHeadElt);\n if (inNewContent || isPreserved) {\n if (isReAppended) {\n // remove the current version and let the new version replace it and re-execute\n removed.push(currentHeadElt);\n } else {\n // this element already exists and should not be re-appended, so remove it from\n // the new content map, preserving it in the DOM\n srcToNewHeadNodes.delete(currentHeadElt.outerHTML);\n preserved.push(currentHeadElt);\n }\n } else {\n if (ctx.head.style === \"append\") {\n // we are appending and this existing element is not new content\n // so if and only if it is marked for re-append do we do anything\n if (isReAppended) {\n removed.push(currentHeadElt);\n nodesToAppend.push(currentHeadElt);\n }\n } else {\n // if this is a merge, we remove this content since it is not in the new head\n if (ctx.head.shouldRemove(currentHeadElt) !== false) {\n removed.push(currentHeadElt);\n }\n }\n }\n }\n\n // Push the remaining new head elements in the Map into the\n // nodes to append to the head tag\n nodesToAppend.push(...srcToNewHeadNodes.values());\n\n let promises = [];\n for (const newNode of nodesToAppend) {\n // TODO: This could theoretically be null, based on type\n let newElt = /** @type {ChildNode} */ (\n document.createRange().createContextualFragment(newNode.outerHTML)\n .firstChild\n );\n if (ctx.callbacks.beforeNodeAdded(newElt) !== false) {\n if (\n (\"href\" in newElt && newElt.href) ||\n (\"src\" in newElt && newElt.src)\n ) {\n /** @type {(result?: any) => void} */ let resolve;\n let promise = new Promise(function (_resolve) {\n resolve = _resolve;\n });\n newElt.addEventListener(\"load\", function () {\n resolve();\n });\n promises.push(promise);\n }\n oldHead.appendChild(newElt);\n ctx.callbacks.afterNodeAdded(newElt);\n added.push(newElt);\n }\n }\n\n // remove all removed elements, after we have appended the new elements to avoid\n // additional network requests for things like style sheets\n for (const removedElement of removed) {\n if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {\n oldHead.removeChild(removedElement);\n ctx.callbacks.afterNodeRemoved(removedElement);\n }\n }\n\n ctx.head.afterHeadMorphed(oldHead, {\n added: added,\n kept: preserved,\n removed: removed,\n });\n return promises;\n }\n\n //=============================================================================\n // Create Morph Context Functions\n //=============================================================================\n const createMorphContext = (function () {\n /**\n *\n * @param {Element} oldNode\n * @param {Element} newContent\n * @param {Config} config\n * @returns {MorphContext}\n */\n function createMorphContext(oldNode, newContent, config) {\n const { persistentIds, idMap } = createIdMaps(oldNode, newContent);\n\n const mergedConfig = mergeDefaults(config);\n const morphStyle = mergedConfig.morphStyle || \"outerHTML\";\n if (![\"innerHTML\", \"outerHTML\"].includes(morphStyle)) {\n throw `Do not understand how to morph style ${morphStyle}`;\n }\n\n return {\n target: oldNode,\n newContent: newContent,\n config: mergedConfig,\n morphStyle: morphStyle,\n ignoreActive: mergedConfig.ignoreActive,\n ignoreActiveValue: mergedConfig.ignoreActiveValue,\n restoreFocus: mergedConfig.restoreFocus,\n idMap: idMap,\n persistentIds: persistentIds,\n pantry: createPantry(),\n callbacks: mergedConfig.callbacks,\n head: mergedConfig.head,\n };\n }\n\n /**\n * Deep merges the config object and the Idiomorph.defaults object to\n * produce a final configuration object\n * @param {Config} config\n * @returns {ConfigInternal}\n */\n function mergeDefaults(config) {\n let finalConfig = Object.assign({}, defaults);\n\n // copy top level stuff into final config\n Object.assign(finalConfig, config);\n\n // copy callbacks into final config (do this to deep merge the callbacks)\n finalConfig.callbacks = Object.assign(\n {},\n defaults.callbacks,\n config.callbacks,\n );\n\n // copy head config into final config (do this to deep merge the head)\n finalConfig.head = Object.assign({}, defaults.head, config.head);\n\n return finalConfig;\n }\n\n /**\n * @returns {HTMLDivElement}\n */\n function createPantry() {\n const pantry = document.createElement(\"div\");\n pantry.hidden = true;\n document.body.insertAdjacentElement(\"afterend\", pantry);\n return pantry;\n }\n\n /**\n * Returns all elements with an ID contained within the root element and its descendants\n *\n * @param {Element} root\n * @returns {Element[]}\n */\n function findIdElements(root) {\n let elements = Array.from(root.querySelectorAll(\"[id]\"));\n if (root.id) {\n elements.push(root);\n }\n return elements;\n }\n\n /**\n * A bottom-up algorithm that populates a map of Element -> IdSet.\n * The idSet for a given element is the set of all IDs contained within its subtree.\n * As an optimzation, we filter these IDs through the given list of persistent IDs,\n * because we don't need to bother considering IDed elements that won't be in the new content.\n *\n * @param {Map<Node, Set<string>>} idMap\n * @param {Set<string>} persistentIds\n * @param {Element} root\n * @param {Element[]} elements\n */\n function populateIdMapWithTree(idMap, persistentIds, root, elements) {\n for (const elt of elements) {\n if (persistentIds.has(elt.id)) {\n /** @type {Element|null} */\n let current = elt;\n // walk up the parent hierarchy of that element, adding the id\n // of element to the parent's id set\n while (current) {\n let idSet = idMap.get(current);\n // if the id set doesn't exist, create it and insert it in the map\n if (idSet == null) {\n idSet = new Set();\n idMap.set(current, idSet);\n }\n idSet.add(elt.id);\n\n if (current === root) break;\n current = current.parentElement;\n }\n }\n }\n }\n\n /**\n * This function computes a map of nodes to all ids contained within that node (inclusive of the\n * node). This map can be used to ask if two nodes have intersecting sets of ids, which allows\n * for a looser definition of \"matching\" than tradition id matching, and allows child nodes\n * to contribute to a parent nodes matching.\n *\n * @param {Element} oldContent the old content that will be morphed\n * @param {Element} newContent the new content to morph to\n * @returns {IdSets}\n */\n function createIdMaps(oldContent, newContent) {\n const oldIdElements = findIdElements(oldContent);\n const newIdElements = findIdElements(newContent);\n\n const persistentIds = createPersistentIds(oldIdElements, newIdElements);\n\n /** @type {Map<Node, Set<string>>} */\n let idMap = new Map();\n populateIdMapWithTree(idMap, persistentIds, oldContent, oldIdElements);\n\n /** @ts-ignore - if newContent is a duck-typed parent, pass its single child node as the root to halt upwards iteration */\n const newRoot = newContent.__idiomorphRoot || newContent;\n populateIdMapWithTree(idMap, persistentIds, newRoot, newIdElements);\n\n return { persistentIds, idMap };\n }\n\n /**\n * This function computes the set of ids that persist between the two contents excluding duplicates\n *\n * @param {Element[]} oldIdElements\n * @param {Element[]} newIdElements\n * @returns {Set<string>}\n */\n function createPersistentIds(oldIdElements, newIdElements) {\n let duplicateIds = new Set();\n\n /** @type {Map<string, string>} */\n let oldIdTagNameMap = new Map();\n for (const { id, tagName } of oldIdElements) {\n if (oldIdTagNameMap.has(id)) {\n duplicateIds.add(id);\n } else {\n oldIdTagNameMap.set(id, tagName);\n }\n }\n\n let persistentIds = new Set();\n for (const { id, tagName } of newIdElements) {\n if (persistentIds.has(id)) {\n duplicateIds.add(id);\n } else if (oldIdTagNameMap.get(id) === tagName) {\n persistentIds.add(id);\n }\n // skip if tag types mismatch because its not possible to morph one tag into another\n }\n\n for (const id of duplicateIds) {\n persistentIds.delete(id);\n }\n return persistentIds;\n }\n\n return createMorphContext;\n })();\n\n //=============================================================================\n // HTML Normalization Functions\n //=============================================================================\n const { normalizeElement, normalizeParent } = (function () {\n /** @type {WeakSet<Node>} */\n const generatedByIdiomorph = new WeakSet();\n\n /**\n *\n * @param {Element | Document} content\n * @returns {Element}\n */\n function normalizeElement(content) {\n if (content instanceof Document) {\n return content.documentElement;\n } else {\n return content;\n }\n }\n\n /**\n *\n * @param {null | string | Node | HTMLCollection | Node[] | Document & {generatedByIdiomorph:boolean}} newContent\n * @returns {Element}\n */\n function normalizeParent(newContent) {\n if (newContent == null) {\n return document.createElement(\"div\"); // dummy parent element\n } else if (typeof newContent === \"string\") {\n return normalizeParent(parseContent(newContent));\n } else if (\n generatedByIdiomorph.has(/** @type {Element} */ (newContent))\n ) {\n // the template tag created by idiomorph parsing can serve as a dummy parent\n return /** @type {Element} */ (newContent);\n } else if (newContent instanceof Node) {\n if (newContent.parentNode) {\n // we can't use the parent directly because newContent may have siblings\n // that we don't want in the morph, and reparenting might be expensive (TODO is it?),\n // so we create a duck-typed parent node instead.\n return createDuckTypedParent(newContent);\n } else {\n // a single node is added as a child to a dummy parent\n const dummyParent = document.createElement(\"div\");\n dummyParent.append(newContent);\n return dummyParent;\n }\n } else {\n // all nodes in the array or HTMLElement collection are consolidated under\n // a single dummy parent element\n const dummyParent = document.createElement(\"div\");\n for (const elt of [...newContent]) {\n dummyParent.append(elt);\n }\n return dummyParent;\n }\n }\n\n /**\n * Creates a fake duck-typed parent element to wrap a single node, without actually reparenting it.\n * \"If it walks like a duck, and quacks like a duck, then it must be a duck!\" -- James Whitcomb Riley (1849–1916)\n *\n * @param {Node} newContent\n * @returns {Element}\n */\n function createDuckTypedParent(newContent) {\n return /** @type {Element} */ (\n /** @type {unknown} */ ({\n childNodes: [newContent],\n /** @ts-ignore - cover your eyes for a minute, tsc */\n querySelectorAll: (s) => {\n /** @ts-ignore */\n const elements = newContent.querySelectorAll(s);\n /** @ts-ignore */\n return newContent.matches(s) ? [newContent, ...elements] : elements;\n },\n /** @ts-ignore */\n insertBefore: (n, r) => newContent.parentNode.insertBefore(n, r),\n /** @ts-ignore */\n moveBefore: (n, r) => newContent.parentNode.moveBefore(n, r),\n // for later use with populateIdMapWithTree to halt upwards iteration\n get __idiomorphRoot() {\n return newContent;\n },\n })\n );\n }\n\n /**\n *\n * @param {string} newContent\n * @returns {Node | null | DocumentFragment}\n */\n function parseContent(newContent) {\n let parser = new DOMParser();\n\n // remove svgs to avoid false-positive matches on head, etc.\n let contentWithSvgsRemoved = newContent.replace(\n /<svg(\\s[^>]*>|>)([\\s\\S]*?)<\\/svg>/gim,\n \"\",\n );\n\n // if the newContent contains a html, head or body tag, we can simply parse it w/o wrapping\n if (\n contentWithSvgsRemoved.match(/<\\/html>/) ||\n contentWithSvgsRemoved.match(/<\\/head>/) ||\n contentWithSvgsRemoved.match(/<\\/body>/)\n ) {\n let content = parser.parseFromString(newContent, \"text/html\");\n // if it is a full HTML document, return the document itself as the parent container\n if (contentWithSvgsRemoved.match(/<\\/html>/)) {\n generatedByIdiomorph.add(content);\n return content;\n } else {\n // otherwise return the html element as the parent container\n let htmlElement = content.firstChild;\n if (htmlElement) {\n generatedByIdiomorph.add(htmlElement);\n }\n return htmlElement;\n }\n } else {\n // if it is partial HTML, wrap it in a template tag to provide a parent element and also to help\n // deal with touchy tags like tr, tbody, etc.\n let responseDoc = parser.parseFromString(\n \"<body><template>\" + newContent + \"</template></body>\",\n \"text/html\",\n );\n let content = /** @type {HTMLTemplateElement} */ (\n responseDoc.body.querySelector(\"template\")\n ).content;\n generatedByIdiomorph.add(content);\n return content;\n }\n }\n\n return { normalizeElement, normalizeParent };\n })();\n\n //=============================================================================\n // This is what ends up becoming the Idiomorph global object\n //=============================================================================\n return {\n morph,\n defaults,\n };\n})();\n\nexport {Idiomorph};\n","\nconst topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n","import { safe, g, dup } from './utils'\nimport { Idiomorph } from 'idiomorph/dist/idiomorph.esm'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport const Component = ({ name, module, dependencies, node, templates, signal, register }) => {\n\n\tlet tick\n\tlet preserve\t\t= []\n\n\tconst _model \t\t= module.model || {}\n\tconst initialState \t= (new Function( `return ${node.getAttribute('html-model') || '{}'}`))()\n\tconst tplid \t\t= node.getAttribute('tplid')\n\tconst scopeid \t\t= node.getAttribute('html-scopeid')\n\tconst tpl \t\t\t= templates[ tplid ]\n\tconst scope \t\t= g.scope[ scopeid ]\n\tconst model \t\t= dup(module?.model?.apply ? _model({ elm:node, initialState }) : _model)\n\tconst state \t\t= Object.assign({}, scope, model, initialState)\n\tconst view \t\t\t= module.view? module.view : (data) => data\n\n\tconst base = {\n\t\tname,\n\t\tmodel,\n\t\telm: node,\n\t\ttemplate: tpl.template,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\tnode.addEventListener(':mount', fn)\n\t\t},\n\n\t\t/**\n\t\t * @State\n\t\t */\n\t\tstate : {\n\n\t\t\tprotected( list ) {\n\t\t\t\tif( list ) {\n\t\t\t\t\tpreserve = list\n\t\t\t\t} else {\n\t\t\t\t\treturn preserve\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tsave(data) {\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata( state )\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tset( data ) {\n\n\t\t\t\tif (!document.body.contains(node)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata(state)\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(state, data)\n\t\t\t\t}\n\n\t\t\t\tconst newstate = Object.assign({}, state, scope)\n\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\trender(newstate, () => resolve(newstate))\n\t\t\t\t})\n\t\t\t},\n\n\t\t\tget() {\n\t\t\t\treturn Object.assign({}, state)\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * @Events\n\t\t */\n\t\ton( ev, selectorOrCallback, callback ) {\n\n\t\t\tif( callback ) {\n\t\t\t\tcallback.handler = (e) => {\n\t\t\t\t\tconst detail = e.detail || {}\n\t\t\t\t\tlet parent = e.target\n\t\t\t\t\twhile (parent) {\n\t\t\t\t\t\tif (parent.matches(selectorOrCallback)) {\n\t\t\t\t\t\t\te.delegateTarget = parent\n\t\t\t\t\t\t\tcallback.apply(node, [e].concat(detail.args))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parent === node) break\n\t\t\t\t\t\tparent = parent.parentNode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, callback.handler, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tcapture: (ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave')\n\t\t\t\t})\n\n\t\t\t} else {\n\t\t\t\tselectorOrCallback.handler = (e) => {\n\t\t\t\t\te.delegateTarget = node\n\t\t\t\t\tselectorOrCallback.apply(node, [e].concat(e.detail.args))\n\t\t\t\t}\n\t\t\t\tnode.addEventListener(ev, selectorOrCallback.handler, { signal })\n\t\t\t}\n\n\t\t},\n\n\t\toff( ev, callback ) {\n\t\t\tif( callback.handler ) {\n\t\t\t\tnode.removeEventListener(ev, callback.handler)\n\t\t\t}\n\t\t},\n\n\t\ttrigger(ev, selectorOrCallback, data) {\n\t\t\tif( selectorOrCallback.constructor === String ) {\n\t\t\t\tArray\n\t\t\t\t\t.from(node.querySelectorAll(selectorOrCallback))\n\t\t\t\t\t.forEach( children => {\n\t\t\t\t\t\tchildren.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }) )\n\t\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail:{ args: data } }))\n\t\t\t}\n\t\t},\n\n\t\temit(ev, data) {\n\t\t\tnode.dispatchEvent(new CustomEvent(ev, { bubbles: true, detail: { args: data } }))\n\t\t},\n\n\t\tunmount( fn ) {\n\t\t\tnode.addEventListener(':unmount', fn)\n\t\t},\n\n\t\tinnerHTML ( target, html_ ) {\n\t\t\tconst element = html_? target : node\n\t\t\tconst clone = element.cloneNode()\n\t\t\tconst html = html_? html_ : target\n\t\t\tclone.innerHTML = html\n\t\t\tIdiomorph.morph(element, clone)\n\t\t}\n\t}\n\n\tconst render = ( data, callback = (() => {}) ) => {\n\t\tclearTimeout( tick )\n\t\ttick = setTimeout(() => {\n\t\t\tconst html = tpl.render.call( view(data), node, safe, g )\n\t\t\tIdiomorph.morph( node, html, IdiomorphOptions(node, register) )\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tnode.querySelectorAll('[tplid]')\n\t\t\t\t\t.forEach((element) => {\n\t\t\t\t\t\tconst child = register.get(element)\n\t\t\t\t\t\tif(!child) return\n\t\t\t\t\t\tchild.state.protected().forEach( key => delete data[key] )\n\t\t\t\t\t\tchild.state.set(data)\n\t\t\t\t\t})\n\t\t\t\tPromise.resolve().then(() => {\n\t\t\t\t\tg.scope = {}\n\t\t\t\t\tcallback()\n\t\t\t\t})\n\t\t\t})\n\t\t})\n\t}\n\n\trender( state )\n\tregister.set( node, base )\n\treturn module.default( base )\n}\n\nconst IdiomorphOptions = ( parent, register ) => ({\n\tcallbacks: {\n\t\tbeforeNodeMorphed( node ) {\n\t\t\tif( node.nodeType === 1 ) {\n\t\t\t\tif( 'html-static' in node.attributes ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif( register.get(node) && node !== parent ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n","import { Component } from './component'\n\nconst register = new WeakMap()\n\nexport const Element = ({ component, templates, start }) => {\n\n\tconst { name, module, dependencies } = component\n\n\treturn class extends HTMLElement {\n\n\t\tconstructor() {\n\t\t\tsuper()\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis.abortController = new AbortController()\n\n\t\t\tif( !this.getAttribute('tplid') ) {\n\t\t\t\tstart( this.parentNode )\n\t\t\t}\n\n\t\t\tconst rtrn = Component({\n\t\t\t\tnode:this,\n\t\t\t\tname,\n\t\t\t\tmodule,\n\t\t\t\tdependencies,\n\t\t\t\ttemplates,\n\t\t\t\tsignal: this.abortController.signal,\n\t\t\t\tregister\n\t\t\t})\n\n\t\t\tif ( rtrn && rtrn.constructor === Promise ) {\n\t\t\t\trtrn.then(() => {\n\t\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\t}\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.dispatchEvent( new CustomEvent(':unmount') )\n\t\t\tthis.abortController.abort()\n\t\t}\n\t}\n}\n","import { uuid, decodeHTML } from './utils'\n\nconst templates = {}\n\nconst config = {\n\ttags: ['{{', '}}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign( config, newconfig )\n}\n\nexport const template = ( target, { components }) => {\n\n\ttagElements( target, [...Object.keys( components ), '[html-if]', 'template'] )\n\tconst clone = target.cloneNode( true )\n\n\ttransformTemplate( clone )\n\tremoveTemplateTagsRecursively( clone )\n\tsetTemplates( clone, components )\n\n\treturn templates\n}\n\nexport const compile = ( html ) => {\n\n\tconst parsedHtml = JSON.stringify( html )\n\n\treturn new Function('$element', 'safe', '$g',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${parsedHtml\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+ decodeHTML(variable) +';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + decodeHTML(variable) +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nconst tagElements = ( target, keys ) => {\n\ttarget\n\t\t.querySelectorAll( keys.toString() )\n\t\t.forEach((node) => {\n\t\t\tif( node.localName === 'template' ) {\n\t\t\t\treturn tagElements( node.content, keys )\n\t\t\t}\n\t\t\tnode.setAttribute('tplid', uuid())\n\t\t\tif( node.getAttribute('html-if') && !node.id ) {\n\t\t\t\tnode.id = uuid()\n\t\t\t}\n\t\t})\n}\n\nconst transformAttributes = ( html ) => {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\n\treturn html\n\t\t.replace(/jails___scope-id/g, '%%_=$scopeid_%%')\n\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t// Booleans\n\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t// The rest\n\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\tif (key === 'key' || key === 'model' || key === 'scopeid' ) {\n\t\t\t\treturn all\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t} else {\n\t\t\t\treturn all\n\t\t\t}\n\t\t})\n}\n\nconst transformTemplate = ( clone ) => {\n\n\tclone.querySelectorAll('template, [html-for], [html-if], [html-inner], [html-class]')\n\t\t.forEach(( element ) => {\n\n\t\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\t\tconst htmlClass = element.getAttribute('html-class')\n\n\t\t\tif ( htmlFor ) {\n\n\t\t\t\telement.removeAttribute('html-for')\n\n\t\t\t\tconst split \t = htmlFor.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\t\tconst varname \t = split[1]\n\t\t\t\tconst object \t = split[2]\n\t\t\t\tconst objectname = object.split(/\\./).shift()\n\t\t\t\tconst open \t\t = document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${varname} = ${object}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${objectname}: ${objectname} }, { ${varname} :${varname}, $index: $index, $key: $key }); _%%`)\n\t\t\t\tconst close \t = document.createTextNode(`%%_ $index++; } })() _%%`)\n\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlIf) {\n\t\t\t\telement.removeAttribute('html-if')\n\t\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\t\twrap(open, element, close)\n\t\t\t}\n\n\t\t\tif (htmlInner) {\n\t\t\t\telement.removeAttribute('html-inner')\n\t\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t\t}\n\n\t\t\tif (htmlClass) {\n\t\t\t\telement.removeAttribute('html-class')\n\t\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t\t}\n\n\t\t\tif( element.localName === 'template' ) {\n\t\t\t\ttransformTemplate(element.content)\n\t\t\t}\n\t\t})\n}\n\nconst setTemplates = ( clone, components ) => {\n\n\tArray.from(clone.querySelectorAll('[tplid]'))\n\t\t.reverse()\n\t\t.forEach((node) => {\n\n\t\t\tconst tplid = node.getAttribute('tplid')\n\t\t\tconst name = node.localName\n\t\t\tnode.setAttribute('html-scopeid', 'jails___scope-id')\n\n\t\t\tif( name in components && components[name].module.template ) {\n\t\t\t\tconst children = node.innerHTML\n\t\t\t\tconst html = components[name].module.template({ elm:node, children })\n\t\t\t\tnode.innerHTML = html\n\t\t\t}\n\n\t\t\tconst html = transformAttributes(node.outerHTML)\n\n\t\t\ttemplates[ tplid ] = {\n\t\t\t\ttemplate: html,\n\t\t\t\trender\t: compile(html)\n\t\t\t}\n\t\t})\n}\n\nconst removeTemplateTagsRecursively = (node) => {\n\n\t// Get all <template> elements within the node\n\tconst templates = node.querySelectorAll('template')\n\n\ttemplates.forEach((template) => {\n\n\t\tif( template.getAttribute('html-if') || template.getAttribute('html-inner') ) {\n\t\t\treturn\n\t\t}\n\n\t\t// Process any nested <template> tags within this <template> first\n\t\tremoveTemplateTagsRecursively(template.content)\n\n\t\t// Get the parent of the <template> tag\n\t\tconst parent = template.parentNode\n\n\t\tif (parent) {\n\t\t\t// Move all child nodes from the <template>'s content to its parent\n\t\t\tconst content = template.content\n\t\t\twhile (content.firstChild) {\n\t\t\t\tparent.insertBefore(content.firstChild, template)\n\t\t\t}\n\t\t\t// Remove the <template> tag itself\n\t\t\tparent.removeChild(template)\n\t\t}\n\t})\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","\nimport { Element } from './element'\nimport { template, templateConfig as config } from './template-system'\n\nconst components = {}\n\nexport { publish, subscribe } from './utils/pubsub'\n\nexport const templateConfig = (options) => {\n\tconfig( options )\n}\n\nexport const register = ( name, module, dependencies ) => {\n\tcomponents[ name ] = { name, module, dependencies }\n}\n\nexport const start = ( target = document.body ) => {\n\n\tconst templates = template( target, { components } )\n\n\tObject\n\t\t.values( components )\n\t\t.forEach(({ name, module, dependencies }) => {\n\t\t\tif( !customElements.get(name) ) {\n\t\t\t\tcustomElements.define( name, Element({ component: { name, module, dependencies }, templates, start }))\n\t\t\t}\n\t})\n}\n"],"names":["config","ctx","morphChildren","findBestMatch","morphNode","createMorphContext","normalizeElement","normalizeParent","templates","register","Element","start","templateConfig","components","html","template"],"mappings":"AACA,MAAM,WAAW,SAAS,cAAc,UAAU;AAE3C,MAAM,IAAI;AAAA,EAChB,OAAO,CAAA;AACR;AAEa,MAAA,aAAa,CAAC,SAAS;AACnC,WAAS,YAAY;AACrB,SAAO,SAAS;AACjB;AASO,MAAM,OAAO,MAAM;AAClB,SAAA,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACjD;AAEa,MAAA,MAAM,CAAC,MAAM;AACzB,SAAO,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC;AACpC;AAEa,MAAA,OAAO,CAAC,SAAS,QAAQ;AAClC,MAAA;AACF,WAAO,QAAQ;AAAA,WACT,KAAI;AACV,WAAO,OAAO;AAAA,EAAA;AAEhB;AC+DA,IAAI,YAAa,WAAY;AAwB3B,QAAM,OAAO,MAAM;AAAA,EAAE;AAKrB,QAAM,WAAW;AAAA,IACf,YAAY;AAAA,IACZ,WAAW;AAAA,MACT,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,wBAAwB;AAAA,IACzB;AAAA,IACD,MAAM;AAAA,MACJ,OAAO;AAAA,MACP,gBAAgB,CAAC,QAAQ,IAAI,aAAa,aAAa,MAAM;AAAA,MAC7D,gBAAgB,CAAC,QAAQ,IAAI,aAAa,cAAc,MAAM;AAAA,MAC9D,cAAc;AAAA,MACd,kBAAkB;AAAA,IACnB;AAAA,IACD,cAAc;AAAA,EACf;AAUD,WAAS,MAAM,SAAS,YAAYA,UAAS,CAAA,GAAI;AAC/C,cAAU,iBAAiB,OAAO;AAClC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AS,OAAO;AAG9C,UAAM,SAASA,UAAS;AAExB,QAAI,QAAQ;AAEX,YAAM,UAAUA,UAAS;AACzB,aAAO,QAAQ,YAAY;AACnB,eAAA,aAAa,QAAQ,YAAYA,SAAQ;AAAA,MAAA;AAGjD,aAAO,YAAYA,SAAQ;AAAA,IAAA;AAAA,EAC5B,CACA;AACF;AAEA,MAAM,OAAO,CAAC,MAAM,MAAM,UAAU;ALpLpC;AKqLM,aAAA,eAAA,mBAAY,aAAa,MAAM;AACpC,aAAK,eAAL,mBAAiB,aAAa,OAAO,KAAK;AAC3C;ACpLA,MAAM,aAAa,CAAC;AAIP,MAAA,iBAAiB,CAAC,YAAY;AAC1Cf,mBAAQ,OAAQ;AACjB;AAEO,MAAM,WAAW,CAAE,MAAM,QAAQ,iBAAkB;AACzD,aAAY,IAAK,IAAI,EAAE,MAAM,QAAQ,aAAa;AACnD;AAEO,MAAM,QAAQ,CAAE,SAAS,SAAS,SAAU;AAElD,QAAMQ,aAAY,SAAU,QAAQ,EAAE,YAAa;AAGjD,SAAA,OAAQ,UAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,QAAQ,mBAAmB;AAC5C,QAAI,CAAC,eAAe,IAAI,IAAI,GAAI;AAC/B,qBAAe,OAAQ,MAAME,UAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,aAAa,GAAG,WAAAF,YAAW,MAAO,CAAA,CAAC;AAAA,IAAA;AAAA,EACtG,CACD;AACF;","x_google_ignoreList":[1]}
package/dist/jails.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jails={})}(this,(function(e){"use strict";const t=document.createElement("textarea"),n={scope:{}},r=e=>(t.innerHTML=e,t.value),o=()=>Math.random().toString(36).substring(2,9),l=(e,t)=>{try{return e()}catch(n){return t||""}};var i=function(){let e=new Set,t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:c,afterNodeAdded:c,beforeNodeMorphed:c,afterNodeMorphed:c,beforeNodeRemoved:c,afterNodeRemoved:c,beforeAttributeUpdated:c,beforeNodePantried:c},head:{style:"merge",shouldPreserve:function(e){return"true"===e.getAttribute("im-preserve")},shouldReAppend:function(e){return"true"===e.getAttribute("im-re-append")},shouldRemove:c,afterHeadMorphed:c}};function n(e,t,r){var i,a;if(r.head.block){let o=e.querySelector("head"),l=t.querySelector("head");if(o&&l){let i=d(l,o,r);return void Promise.all(i).then((function(){n(e,t,Object.assign(r,{head:{block:!1,ignore:!0}}))}))}}if("innerHTML"===r.morphStyle)return l(t,e,r),r.config.twoPass&&E(e,r),Array.from(e.children);if("outerHTML"!==r.morphStyle&&null!=r.morphStyle)throw"Do not understand how to morph style "+r.morphStyle;{let n=function(e,t,n){let r;r=e.firstChild;let o=r,l=0;for(;r;){let e=g(r,t,n);e>l&&(o=r,l=e),r=r.nextSibling}return o}(t,e,r),l=null!=(i=null==n?void 0:n.previousSibling)?i:null,s=null!=(a=null==n?void 0:n.nextSibling)?a:null,d=o(e,n,r);if(!n)return[];if(d){const e=function(e,t,n){var r,o;let l=[],i=[];for(;null!=e;)l.push(e),e=e.previousSibling;let a=l.pop();for(;void 0!==a;)i.push(a),null==(r=t.parentElement)||r.insertBefore(a,t),a=l.pop();i.push(t);for(;null!=n;)l.push(n),i.push(n),n=n.nextSibling;for(;l.length>0;){const e=l.pop();null==(o=t.parentElement)||o.insertBefore(e,t.nextSibling)}return i}(l,d,s);return r.config.twoPass&&E(d.parentNode,r),e}}}function r(e,t){return!!t.ignoreActiveValue&&e===document.activeElement&&e!==document.body}function o(e,t,n){var o,i;return n.ignoreActive&&e===document.activeElement?null:null==t?!1===n.callbacks.beforeNodeRemoved(e)?e:(null==(o=e.parentNode)||o.removeChild(e),n.callbacks.afterNodeRemoved(e),null):m(e,t)?(!1===n.callbacks.beforeNodeMorphed(e,t)||(e instanceof HTMLHeadElement&&n.head.ignore||(e instanceof HTMLHeadElement&&"morph"!==n.head.style?d(t,e,n):(a(t,e,n),r(e,n)||l(t,e,n))),n.callbacks.afterNodeMorphed(e,t)),e):!1===n.callbacks.beforeNodeRemoved(e)||!1===n.callbacks.beforeNodeAdded(t)?e:(null==(i=e.parentNode)||i.replaceChild(t,e),n.callbacks.afterNodeAdded(t),n.callbacks.afterNodeRemoved(e),t)}function l(e,t,n){e instanceof HTMLTemplateElement&&t instanceof HTMLTemplateElement&&(e=e.content,t=t.content);let r,l=e.firstChild,i=t.firstChild;for(;l;){if(r=l,l=r.nextSibling,null==i){if(n.config.twoPass&&n.persistentIds.has(r.id))t.appendChild(r);else{if(!1===n.callbacks.beforeNodeAdded(r))continue;t.appendChild(r),n.callbacks.afterNodeAdded(r)}k(n,r);continue}if(f(r,i,n)){o(i,r,n),i=i.nextSibling,k(n,r);continue}let a=h(e,t,r,i,n);if(a){i=p(i,a,n),o(a,r,n),k(n,r);continue}let s=b(e,t,r,i,n);if(s)i=p(i,s,n),o(s,r,n),k(n,r);else{if(n.config.twoPass&&n.persistentIds.has(r.id))t.insertBefore(r,i);else{if(!1===n.callbacks.beforeNodeAdded(r))continue;t.insertBefore(r,i),n.callbacks.afterNodeAdded(r)}k(n,r)}}for(;null!==i;){let e=i;i=i.nextSibling,y(e,n)}}function i(e,t,n,r){return!("value"!==e||!r.ignoreActiveValue||t!==document.activeElement)||!1===r.callbacks.beforeAttributeUpdated(e,t,n)}function a(e,t,n){let o=e.nodeType;if(1===o){const r=e,o=t,l=r.attributes,a=o.attributes;for(const e of l)i(e.name,o,"update",n)||o.getAttribute(e.name)!==e.value&&o.setAttribute(e.name,e.value);for(let e=a.length-1;0<=e;e--){const t=a[e];if(t&&!r.hasAttribute(t.name)){if(i(t.name,o,"remove",n))continue;o.removeAttribute(t.name)}}}8!==o&&3!==o||t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),r(t,n)||function(e,t,n){if(e instanceof HTMLInputElement&&t instanceof HTMLInputElement&&"file"!==e.type){let r=e.value,o=t.value;s(e,t,"checked",n),s(e,t,"disabled",n),e.hasAttribute("value")?r!==o&&(i("value",t,"update",n)||(t.setAttribute("value",r),t.value=r)):i("value",t,"remove",n)||(t.value="",t.removeAttribute("value"))}else if(e instanceof HTMLOptionElement&&t instanceof HTMLOptionElement)s(e,t,"selected",n);else if(e instanceof HTMLTextAreaElement&&t instanceof HTMLTextAreaElement){let r=e.value,o=t.value;if(i("value",t,"update",n))return;r!==o&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)}}(e,t,n)}function s(e,t,n,r){if(!(e instanceof Element&&t instanceof Element))return;const o=e[n];if(o!==t[n]){let l=i(n,t,"update",r);l||(t[n]=e[n]),o?l||t.setAttribute(n,o):i(n,t,"remove",r)||t.removeAttribute(n)}}function d(e,t,n){let r=[],o=[],l=[],i=[],a=n.head.style,s=new Map;for(const c of e.children)s.set(c.outerHTML,c);for(const c of t.children){let e=s.has(c.outerHTML),t=n.head.shouldReAppend(c),r=n.head.shouldPreserve(c);e||r?t?o.push(c):(s.delete(c.outerHTML),l.push(c)):"append"===a?t&&(o.push(c),i.push(c)):!1!==n.head.shouldRemove(c)&&o.push(c)}i.push(...s.values());let d=[];for(const c of i){let e=document.createRange().createContextualFragment(c.outerHTML).firstChild;if(!1!==n.callbacks.beforeNodeAdded(e)){if("href"in e&&e.href||"src"in e&&e.src){let t,n=new Promise((function(e){t=e}));e.addEventListener("load",(function(){t()})),d.push(n)}t.appendChild(e),n.callbacks.afterNodeAdded(e),r.push(e)}}for(const c of o)!1!==n.callbacks.beforeNodeRemoved(c)&&(t.removeChild(c),n.callbacks.afterNodeRemoved(c));return n.head.afterHeadMorphed(t,{added:r,kept:l,removed:o}),d}function c(){}function u(){const e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function f(e,t,n){return null!=e&&null!=t&&(e instanceof Element&&t instanceof Element&&e.tagName===t.tagName&&(""!==e.id&&e.id===t.id||M(n,e,t)>0))}function m(e,t){return null!=e&&null!=t&&((!e.id||e.id===t.id)&&(e.nodeType===t.nodeType&&e.tagName===t.tagName))}function p(e,t,n){let r=e;for(;r!==t;){let e=r;r=e.nextSibling,y(e,n)}return k(n,t),t.nextSibling}function h(e,t,n,r,o){let l=M(o,n,t),i=null;if(l>0){i=r;let t=0;for(;null!=i;){if(f(n,i,o))return i;if(t+=M(o,i,e),t>l)return null;i=i.nextSibling}}return i}function b(e,t,n,r,o){let l=r,i=n.nextSibling,a=0;for(;null!=l;){if(M(o,l,e)>0)return null;if(m(l,n))return l;if(m(l,i)&&(a++,i=i.nextSibling,a>=2))return null;l=l.nextSibling}return l}const v=new WeakSet;function g(e,t,n){return m(t,e)?.5+M(n,e,t):0}function y(t,n){var r;if(k(n,t),n.config.twoPass&&function(t,n){for(const r of t.idMap.get(n)||e)if(t.persistentIds.has(r))return!0;return!1}(n,t)&&t instanceof Element)A(t,n);else{if(!1===n.callbacks.beforeNodeRemoved(t))return;null==(r=t.parentNode)||r.removeChild(t),n.callbacks.afterNodeRemoved(t)}}function A(e,t){var n;if(!1!==t.callbacks.beforeNodePantried(e))if(Array.from(e.childNodes).forEach((e=>{A(e,t)})),t.persistentIds.has(e.id))t.pantry.moveBefore?t.pantry.moveBefore(e,null):t.pantry.insertBefore(e,null);else{if(!1===t.callbacks.beforeNodeRemoved(e))return;null==(n=e.parentNode)||n.removeChild(e),t.callbacks.afterNodeRemoved(e)}}function E(e,t){e instanceof Element&&(Array.from(t.pantry.children).reverse().forEach((n=>{var r;const o=e.querySelector(`#${n.id}`);if(o){if(null==(r=o.parentElement)?void 0:r.moveBefore)for(o.parentElement.moveBefore(n,o);o.hasChildNodes();)n.moveBefore(o.firstChild,null);else for(o.before(n);o.firstChild;)n.insertBefore(o.firstChild,null);!1!==t.callbacks.beforeNodeMorphed(n,o)&&(a(o,n,t),t.callbacks.afterNodeMorphed(n,o)),o.remove()}})),t.pantry.remove())}function N(e,t){return!e.deadIds.has(t)}function S(t,n,r){return(t.idMap.get(r)||e).has(n)}function k(t,n){let r=t.idMap.get(n)||e;for(const e of r)t.deadIds.add(e)}function M(t,n,r){let o=t.idMap.get(n)||e,l=0;for(const e of o)N(t,e)&&S(t,e,r)&&++l;return l}function T(e){let t=Array.from(e.querySelectorAll("[id]"));return e.id&&t.push(e),t}function C(e,t){let n=e.parentElement;for(const r of T(e)){let e=r;for(;e!==n&&null!=e;){let n=t.get(e);null==n&&(n=new Set,t.set(e,n)),n.add(r.id),e=e.parentElement}}}function $(e,t){let n=new Map;return C(e,n),C(t,n),n}function w(e,t){const n=e=>e.tagName+"#"+e.id,r=new Set(T(e).map(n));let o=new Set;for(const l of T(t))r.has(n(l))&&o.add(l.id);return o}return{morph:function(e,r,o={}){e instanceof Document&&(e=e.documentElement),"string"==typeof r&&(r=function(e){let t=new DOMParser,n=e.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(n.match(/<\/html>/)||n.match(/<\/head>/)||n.match(/<\/body>/)){let r=t.parseFromString(e,"text/html");if(n.match(/<\/html>/))return v.add(r),r;{let e=r.firstChild;return e?(v.add(e),e):null}}{let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html").body.querySelector("template").content;return v.add(n),n}}(r));let l=function(e){if(null==e){return document.createElement("div")}if(v.has(e))return e;if(e instanceof Node){const t=document.createElement("div");return t.append(e),t}{const t=document.createElement("div");for(const n of[...e])t.append(n);return t}}(r),i=function(e,n,r){const o=function(e){let n=Object.assign({},t);return Object.assign(n,e),n.callbacks=Object.assign({},t.callbacks,e.callbacks),n.head=Object.assign({},t.head,e.head),n}(r);return{target:e,newContent:n,config:o,morphStyle:o.morphStyle,ignoreActive:o.ignoreActive,ignoreActiveValue:o.ignoreActiveValue,idMap:$(e,n),deadIds:new Set,persistentIds:o.twoPass?w(e,n):new Set,pantry:o.twoPass?u():document.createElement("div"),callbacks:o.callbacks,head:o.head}}(e,l,o);return n(e,l,i)},defaults:t}}();const a={},s={},d=(e,t)=>{s[e]=Object.assign({},s[e],t),a[e]&&a[e].forEach((e=>e(t)))},c=(e,t)=>(a[e]=a[e]||[],a[e].push(t),e in s&&t(s[e]),()=>{a[e]=a[e].filter((e=>e!=t))}),u=({name:e,module:t,dependencies:r,node:o,templates:a,signal:s})=>{var u;const m=t.model||{},p=new Function(`return ${o.getAttribute("html-model")||"{}"}`)(),h=o.getAttribute("tplid"),b=o.getAttribute("html-scopeid"),v=a[h],g=n.scope[b],y=(A=(null==(u=null==t?void 0:t.model)?void 0:u.apply)?m({elm:o,initialState:p}):m,JSON.parse(JSON.stringify(A)));var A;const E=Object.assign({},g,y,p),N=t.view?t.view:e=>e;let S,k=[];const M={name:e,model:y,elm:o,template:v.template,dependencies:r,publish:d,subscribe:c,main(e){o.addEventListener(":mount",e)},state:{protected(e){if(!e)return k;k=e},save(e){e.constructor===Function?e(E):Object.assign(E,e)},set(e){if(!document.body.contains(o))return;e.constructor===Function?e(E):Object.assign(E,e);const t=Object.assign({},E,g);return T(t),Promise.resolve(t)},get:()=>Object.assign({},E)},on(e,t,n){n?(n.handler=e=>{const r=e.detail||{};let l=e.target;for(;l&&(l.matches(t)&&(e.delegateTarget=l,n.apply(o,[e].concat(r.args))),l!==o);)l=l.parentNode},o.addEventListener(e,n.handler,{signal:s,capture:"focus"==e||"blur"==e||"mouseenter"==e||"mouseleave"==e})):(t.handler=e=>{e.delegateTarget=o,t.apply(o,[e].concat(e.detail.args))},o.addEventListener(e,t.handler,{signal:s}))},off(e,t){t.handler&&o.removeEventListener(e,t.handler)},trigger(e,t,n){t.constructor===String?Array.from(o.querySelectorAll(t)).forEach((t=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))})):o.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))},emit(e,t){o.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:t}}))},unmount(e){o.addEventListener(":unmount",e)},innerHTML(e,t){const n=t?e:o,r=n.cloneNode(),l=t||e;r.innerHTML=l,i.morph(n,r)}},T=e=>{clearTimeout(S),S=setTimeout((()=>{const t=v.render.call(N(e),o,l,n);i.morph(o,t,f(o)),Promise.resolve().then((()=>{o.querySelectorAll("[tplid]").forEach((t=>{t.base&&(t.base.state.protected().forEach((t=>delete e[t])),t.base.state.set(e))})),Promise.resolve().then((()=>n.scope={}))}))}))};return T(E),o.base=M,t.default(M)},f=e=>({callbacks:{beforeNodeMorphed(t){if(1===t.nodeType){if("html-static"in t.attributes)return!1;if(t.base&&t!==e)return!1}}}}),m=({component:e,templates:t,start:n})=>{const{name:r,module:o,dependencies:l}=e;return class extends HTMLElement{constructor(){super()}connectedCallback(){this.abortController=new AbortController,this.getAttribute("tplid")||n(this.parentNode);const e=u({node:this,name:r,module:o,dependencies:l,templates:t,signal:this.abortController.signal});e&&e.constructor===Promise?e.then((()=>{this.dispatchEvent(new CustomEvent(":mount"))})):this.dispatchEvent(new CustomEvent(":mount"))}disconnectedCallback(){this.dispatchEvent(new CustomEvent(":unmount")),this.abortController.abort(),delete this.base}}},p={},h={tags:["{{","}}"]},b=e=>{const t=JSON.stringify(e);return new Function("$element","safe","$g",`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${t.replace(/%%_=(.+?)_%%/g,(function(e,t){return'"+safe(function(){return '+r(t)+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+r(t)+'\noutput+="'}))};return output;\n\t\t}\n\t`)},v=(e,t)=>{e.querySelectorAll(t.toString()).forEach((e=>{if("template"===e.localName)return v(e.content,t);e.setAttribute("tplid",o()),e.getAttribute("html-if")&&!e.id&&(e.id=o())}))},g=e=>{e.querySelectorAll("template, [html-for], [html-if], [html-inner], [html-class]").forEach((e=>{const t=e.getAttribute("html-for"),n=e.getAttribute("html-if"),r=e.getAttribute("html-inner"),o=e.getAttribute("html-class");if(t){e.removeAttribute("html-for");const n=t.match(/(.*)\sin\s(.*)/)||"",r=n[1],o=n[2],l=o.split(/\./).shift(),i=document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${o} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${r} = ${o}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${l}: ${l} }, { ${r} :${r}, $index: $index, $key: $key }); _%%`),a=document.createTextNode("%%_ $index++; } })() _%%");E(i,e,a)}if(n){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${n} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");E(t,e,r)}r&&(e.removeAttribute("html-inner"),e.innerHTML=`%%_=${r}_%%`),o&&(e.removeAttribute("html-class"),e.className=(e.className+` %%_=${o}_%%`).trim()),"template"===e.localName&&g(e.content)}))},y=(e,t)=>{Array.from(e.querySelectorAll("[tplid]")).reverse().forEach((e=>{const n=e.getAttribute("tplid"),r=e.localName;if(e.setAttribute("html-scopeid","jails___scope-id"),r in t&&t[r].module.template){const n=e.innerHTML,o=t[r].module.template({elm:e,children:n});e.innerHTML=o}const o=(e=>{const t=new RegExp(`\\${h.tags[0]}(.+?)\\${h.tags[1]}`,"g");return e.replace(/jails___scope-id/g,"%%_=$scopeid_%%").replace(t,"%%_=$1_%%").replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\"(.*?)\"/g,"%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%").replace(/html-(.*?)=\"(.*?)\"/g,((e,t,n)=>"key"===t||"model"===t||"scopeid"===t?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))})(e.outerHTML);p[n]={template:o,render:b(o)}}))},A=e=>{e.querySelectorAll("template").forEach((e=>{if(e.getAttribute("html-if")||e.getAttribute("html-inner"))return;A(e.content);const t=e.parentNode;if(t){const n=e.content;for(;n.firstChild;)t.insertBefore(n.firstChild,e);t.removeChild(e)}}))},E=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},N={},S=(e=document.body)=>{const t=((e,{components:t})=>{v(e,[...Object.keys(t),"[html-if]","template"]);const n=e.cloneNode(!0);return g(n),A(n),y(n,t),p})(e,{components:N});Object.values(N).forEach((({name:e,module:n,dependencies:r})=>{customElements.get(e)||customElements.define(e,m({component:{name:e,module:n,dependencies:r},templates:t,start:S}))}))};e.publish=d,e.register=(e,t,n)=>{N[e]={name:e,module:t,dependencies:n}},e.start=S,e.subscribe=c,e.templateConfig=e=>{var t;t=e,Object.assign(h,t)},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jails={})}(this,(function(e){"use strict";const t=document.createElement("textarea"),n={scope:{}},r=e=>(t.innerHTML=e,t.value),o=()=>Math.random().toString(36).substring(2,9),i=(e,t)=>{try{return e()}catch(n){return t||""}};var a=function(){const e=()=>{},t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:e=>"true"===e.getAttribute("im-preserve"),shouldReAppend:e=>"true"===e.getAttribute("im-re-append"),shouldRemove:e,afterHeadMorphed:e},restoreFocus:!0};const n=function(){function e(e,t,n,o){if(!1===o.callbacks.beforeNodeAdded(t))return null;if(o.idMap.has(t)){const i=document.createElement(t.tagName);return e.insertBefore(i,n),r(i,t,o),o.callbacks.afterNodeAdded(i),i}{const r=document.importNode(t,!0);return e.insertBefore(r,n),o.callbacks.afterNodeAdded(r),r}}const t=function(){function e(e,t,n){let r=e.idMap.get(t),o=e.idMap.get(n);if(!o||!r)return!1;for(const i of r)if(o.has(i))return!0;return!1}function t(e,t){const n=e,r=t;return n.nodeType===r.nodeType&&n.tagName===r.tagName&&(!n.id||n.id===r.id)}return function(n,r,o,i){let a=null,l=r.nextSibling,s=0,c=o;for(;c&&c!=i;){if(t(c,r)){if(e(n,c,r))return c;null===a&&(n.idMap.has(c)||(a=c))}if(null===a&&l&&t(c,l)&&(s++,l=l.nextSibling,s>=2&&(a=void 0)),c.contains(document.activeElement))break;c=c.nextSibling}return a||null}}();function n(e,t){var n;if(e.idMap.has(t))a(e.pantry,t,null);else{if(!1===e.callbacks.beforeNodeRemoved(t))return;null==(n=t.parentNode)||n.removeChild(t),e.callbacks.afterNodeRemoved(t)}}function o(e,t,r){let o=t;for(;o&&o!==r;){let t=o;o=o.nextSibling,n(e,t)}return o}function i(e,t,n,r){const o=r.target.querySelector(`#${t}`)||r.pantry.querySelector(`#${t}`);return function(e,t){const n=e.id;for(;e=e.parentNode;){let r=t.idMap.get(e);r&&(r.delete(n),r.size||t.idMap.delete(e))}}(o,r),a(e,o,n),o}function a(e,t,n){if(e.moveBefore)try{e.moveBefore(t,n)}catch(r){e.insertBefore(t,n)}else e.insertBefore(t,n)}return function(a,l,s,c=null,d=null){l instanceof HTMLTemplateElement&&s instanceof HTMLTemplateElement&&(l=l.content,s=s.content),c||(c=l.firstChild);for(const n of s.childNodes){if(c&&c!=d){const e=t(a,n,c,d);if(e){e!==c&&o(a,c,e),r(e,n,a),c=e.nextSibling;continue}}if(n instanceof Element&&a.persistentIds.has(n.id)){const e=i(l,n.id,c,a);r(e,n,a),c=e.nextSibling;continue}const s=e(l,n,c,a);s&&(c=s.nextSibling)}for(;c&&c!=d;){const e=c;c=c.nextSibling,n(a,e)}}}(),r=function(){function e(e,n,r,o){const i=n[r];if(i!==e[r]){const a=t(r,e,"update",o);a||(e[r]=n[r]),i?a||e.setAttribute(r,""):t(r,e,"remove",o)||e.removeAttribute(r)}}function t(e,t,n,r){return!("value"!==e||!r.ignoreActiveValue||t!==document.activeElement)||!1===r.callbacks.beforeAttributeUpdated(e,t,n)}function r(e,t){return!!t.ignoreActiveValue&&e===document.activeElement&&e!==document.body}return function(i,a,l){return l.ignoreActive&&i===document.activeElement?null:(!1===l.callbacks.beforeNodeMorphed(i,a)||(i instanceof HTMLHeadElement&&l.head.ignore||(i instanceof HTMLHeadElement&&"morph"!==l.head.style?o(i,a,l):(!function(n,o,i){let a=o.nodeType;if(1===a){const a=n,l=o,s=a.attributes,c=l.attributes;for(const e of c)t(e.name,a,"update",i)||a.getAttribute(e.name)!==e.value&&a.setAttribute(e.name,e.value);for(let e=s.length-1;0<=e;e--){const n=s[e];if(n&&!l.hasAttribute(n.name)){if(t(n.name,a,"remove",i))continue;a.removeAttribute(n.name)}}r(a,i)||function(n,r,o){if(n instanceof HTMLInputElement&&r instanceof HTMLInputElement&&"file"!==r.type){let i=r.value,a=n.value;e(n,r,"checked",o),e(n,r,"disabled",o),r.hasAttribute("value")?a!==i&&(t("value",n,"update",o)||(n.setAttribute("value",i),n.value=i)):t("value",n,"remove",o)||(n.value="",n.removeAttribute("value"))}else if(n instanceof HTMLOptionElement&&r instanceof HTMLOptionElement)e(n,r,"selected",o);else if(n instanceof HTMLTextAreaElement&&r instanceof HTMLTextAreaElement){let e=r.value,i=n.value;if(t("value",n,"update",o))return;e!==i&&(n.value=e),n.firstChild&&n.firstChild.nodeValue!==e&&(n.firstChild.nodeValue=e)}}(a,l,i)}8!==a&&3!==a||n.nodeValue!==o.nodeValue&&(n.nodeValue=o.nodeValue)}(i,a,l),r(i,l)||n(l,i,a))),l.callbacks.afterNodeMorphed(i,a)),i)}}();function o(e,t,n){let r=[],o=[],i=[],a=[],l=new Map;for(const c of t.children)l.set(c.outerHTML,c);for(const c of e.children){let e=l.has(c.outerHTML),t=n.head.shouldReAppend(c),r=n.head.shouldPreserve(c);e||r?t?o.push(c):(l.delete(c.outerHTML),i.push(c)):"append"===n.head.style?t&&(o.push(c),a.push(c)):!1!==n.head.shouldRemove(c)&&o.push(c)}a.push(...l.values());let s=[];for(const c of a){let t=document.createRange().createContextualFragment(c.outerHTML).firstChild;if(!1!==n.callbacks.beforeNodeAdded(t)){if("href"in t&&t.href||"src"in t&&t.src){let e,n=new Promise((function(t){e=t}));t.addEventListener("load",(function(){e()})),s.push(n)}e.appendChild(t),n.callbacks.afterNodeAdded(t),r.push(t)}}for(const c of o)!1!==n.callbacks.beforeNodeRemoved(c)&&(e.removeChild(c),n.callbacks.afterNodeRemoved(c));return n.head.afterHeadMorphed(e,{added:r,kept:i,removed:o}),s}const i=function(){function e(){const e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function n(e){let t=Array.from(e.querySelectorAll("[id]"));return e.id&&t.push(e),t}function r(e,t,n,r){for(const o of r)if(t.has(o.id)){let t=o;for(;t;){let r=e.get(t);if(null==r&&(r=new Set,e.set(t,r)),r.add(o.id),t===n)break;t=t.parentElement}}}return function(o,i,a){const{persistentIds:l,idMap:s}=function(e,t){const o=n(e),i=n(t),a=function(e,t){let n=new Set,r=new Map;for(const{id:i,tagName:a}of e)r.has(i)?n.add(i):r.set(i,a);let o=new Set;for(const{id:i,tagName:a}of t)o.has(i)?n.add(i):r.get(i)===a&&o.add(i);for(const i of n)o.delete(i);return o}(o,i);let l=new Map;r(l,a,e,o);const s=t.__idiomorphRoot||t;return r(l,a,s,i),{persistentIds:a,idMap:l}}(o,i),c=function(e){let n=Object.assign({},t);return Object.assign(n,e),n.callbacks=Object.assign({},t.callbacks,e.callbacks),n.head=Object.assign({},t.head,e.head),n}(a),d=c.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(d))throw`Do not understand how to morph style ${d}`;return{target:o,newContent:i,config:c,morphStyle:d,ignoreActive:c.ignoreActive,ignoreActiveValue:c.ignoreActiveValue,restoreFocus:c.restoreFocus,idMap:s,persistentIds:l,pantry:e(),callbacks:c.callbacks,head:c.head}}}(),{normalizeElement:a,normalizeParent:l}=function(){const e=new WeakSet;return{normalizeElement:function(e){return e instanceof Document?e.documentElement:e},normalizeParent:function t(n){if(null==n)return document.createElement("div");if("string"==typeof n)return t(function(t){let n=new DOMParser,r=t.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(r.match(/<\/html>/)||r.match(/<\/head>/)||r.match(/<\/body>/)){let o=n.parseFromString(t,"text/html");if(r.match(/<\/html>/))return e.add(o),o;{let t=o.firstChild;return t&&e.add(t),t}}{let r=n.parseFromString("<body><template>"+t+"</template></body>","text/html").body.querySelector("template").content;return e.add(r),r}}(n));if(e.has(n))return n;if(n instanceof Node){if(n.parentNode)return function(e){return{childNodes:[e],querySelectorAll:t=>{const n=e.querySelectorAll(t);return e.matches(t)?[e,...n]:n},insertBefore:(t,n)=>e.parentNode.insertBefore(t,n),moveBefore:(t,n)=>e.parentNode.moveBefore(t,n),get __idiomorphRoot(){return e}}}(n);{const e=document.createElement("div");return e.append(n),e}}{const e=document.createElement("div");for(const t of[...n])e.append(t);return e}}}}();return{morph:function(e,t,r={}){e=a(e);const s=l(t),c=i(e,s,r),d=function(e,t){var n;if(!e.config.restoreFocus)return t();let r=document.activeElement;if(!(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement))return t();const{id:o,selectionStart:i,selectionEnd:a}=r,l=t();o&&o!==(null==(n=document.activeElement)?void 0:n.id)&&(r=e.target.querySelector(`#${o}`),null==r||r.focus());r&&!r.selectionEnd&&a&&r.setSelectionRange(i,a);return l}(c,(()=>function(e,t,n,r){if(e.head.block){const i=t.querySelector("head"),a=n.querySelector("head");if(i&&a){const t=o(i,a,e);return Promise.all(t).then((()=>{const t=Object.assign(e,{head:{block:!1,ignore:!0}});return r(t)}))}}return r(e)}(c,e,s,(t=>"innerHTML"===t.morphStyle?(n(t,e,s),Array.from(e.childNodes)):function(e,t,r){const o=l(t);let i=Array.from(o.childNodes);const a=i.indexOf(t),s=i.length-(a+1);return n(e,o,r,t,t.nextSibling),i=Array.from(o.childNodes),i.slice(a,i.length-s)}(t,e,s)))));return c.pantry.remove(),d},defaults:t}}();const l={},s={},c=(e,t)=>{s[e]=Object.assign({},s[e],t),l[e]&&l[e].forEach((e=>e(t)))},d=(e,t)=>(l[e]=l[e]||[],l[e].push(t),e in s&&t(s[e]),()=>{l[e]=l[e].filter((e=>e!=t))}),u=({name:e,module:t,dependencies:r,node:o,templates:l,signal:s,register:u})=>{var m;let p,h=[];const b=t.model||{},g=new Function(`return ${o.getAttribute("html-model")||"{}"}`)(),v=o.getAttribute("tplid"),y=o.getAttribute("html-scopeid"),A=l[v],E=n.scope[y],M=(N=(null==(m=null==t?void 0:t.model)?void 0:m.apply)?b({elm:o,initialState:g}):b,JSON.parse(JSON.stringify(N)));var N;const T=Object.assign({},E,M,g),S=t.view?t.view:e=>e,$={name:e,model:M,elm:o,template:A.template,dependencies:r,publish:c,subscribe:d,main(e){o.addEventListener(":mount",e)},state:{protected(e){if(!e)return h;h=e},save(e){e.constructor===Function?e(T):Object.assign(T,e)},set(e){if(!document.body.contains(o))return;e.constructor===Function?e(T):Object.assign(T,e);const t=Object.assign({},T,E);return new Promise((e=>{k(t,(()=>e(t)))}))},get:()=>Object.assign({},T)},on(e,t,n){n?(n.handler=e=>{const r=e.detail||{};let i=e.target;for(;i&&(i.matches(t)&&(e.delegateTarget=i,n.apply(o,[e].concat(r.args))),i!==o);)i=i.parentNode},o.addEventListener(e,n.handler,{signal:s,capture:"focus"==e||"blur"==e||"mouseenter"==e||"mouseleave"==e})):(t.handler=e=>{e.delegateTarget=o,t.apply(o,[e].concat(e.detail.args))},o.addEventListener(e,t.handler,{signal:s}))},off(e,t){t.handler&&o.removeEventListener(e,t.handler)},trigger(e,t,n){t.constructor===String?Array.from(o.querySelectorAll(t)).forEach((t=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))})):o.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))},emit(e,t){o.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:t}}))},unmount(e){o.addEventListener(":unmount",e)},innerHTML(e,t){const n=t?e:o,r=n.cloneNode(),i=t||e;r.innerHTML=i,a.morph(n,r)}},k=(e,t=()=>{})=>{clearTimeout(p),p=setTimeout((()=>{const r=A.render.call(S(e),o,i,n);a.morph(o,r,f(o,u)),Promise.resolve().then((()=>{o.querySelectorAll("[tplid]").forEach((t=>{const n=u.get(t);n&&(n.state.protected().forEach((t=>delete e[t])),n.state.set(e))})),Promise.resolve().then((()=>{n.scope={},t()}))}))}))};return k(T),u.set(o,$),t.default($)},f=(e,t)=>({callbacks:{beforeNodeMorphed(n){if(1===n.nodeType){if("html-static"in n.attributes)return!1;if(t.get(n)&&n!==e)return!1}}}}),m=new WeakMap,p=({component:e,templates:t,start:n})=>{const{name:r,module:o,dependencies:i}=e;return class extends HTMLElement{constructor(){super()}connectedCallback(){this.abortController=new AbortController,this.getAttribute("tplid")||n(this.parentNode);const e=u({node:this,name:r,module:o,dependencies:i,templates:t,signal:this.abortController.signal,register:m});e&&e.constructor===Promise?e.then((()=>{this.dispatchEvent(new CustomEvent(":mount"))})):this.dispatchEvent(new CustomEvent(":mount"))}disconnectedCallback(){this.dispatchEvent(new CustomEvent(":unmount")),this.abortController.abort()}}},h={},b={tags:["{{","}}"]},g=e=>{const t=JSON.stringify(e);return new Function("$element","safe","$g",`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${t.replace(/%%_=(.+?)_%%/g,(function(e,t){return'"+safe(function(){return '+r(t)+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+r(t)+'\noutput+="'}))};return output;\n\t\t}\n\t`)},v=(e,t)=>{e.querySelectorAll(t.toString()).forEach((e=>{if("template"===e.localName)return v(e.content,t);e.setAttribute("tplid",o()),e.getAttribute("html-if")&&!e.id&&(e.id=o())}))},y=e=>{e.querySelectorAll("template, [html-for], [html-if], [html-inner], [html-class]").forEach((e=>{const t=e.getAttribute("html-for"),n=e.getAttribute("html-if"),r=e.getAttribute("html-inner"),o=e.getAttribute("html-class");if(t){e.removeAttribute("html-for");const n=t.match(/(.*)\sin\s(.*)/)||"",r=n[1],o=n[2],i=o.split(/\./).shift(),a=document.createTextNode(`%%_ ;(function(){ var $index = 0; for(var $key in safe(function(){ return ${o} }) ){ var $scopeid = Math.random().toString(36).substring(2, 9); var ${r} = ${o}[$key]; $g.scope[$scopeid] = Object.assign({}, { ${i}: ${i} }, { ${r} :${r}, $index: $index, $key: $key }); _%%`),l=document.createTextNode("%%_ $index++; } })() _%%");M(a,e,l)}if(n){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${n} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");M(t,e,r)}r&&(e.removeAttribute("html-inner"),e.innerHTML=`%%_=${r}_%%`),o&&(e.removeAttribute("html-class"),e.className=(e.className+` %%_=${o}_%%`).trim()),"template"===e.localName&&y(e.content)}))},A=(e,t)=>{Array.from(e.querySelectorAll("[tplid]")).reverse().forEach((e=>{const n=e.getAttribute("tplid"),r=e.localName;if(e.setAttribute("html-scopeid","jails___scope-id"),r in t&&t[r].module.template){const n=e.innerHTML,o=t[r].module.template({elm:e,children:n});e.innerHTML=o}const o=(e=>{const t=new RegExp(`\\${b.tags[0]}(.+?)\\${b.tags[1]}`,"g");return e.replace(/jails___scope-id/g,"%%_=$scopeid_%%").replace(t,"%%_=$1_%%").replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\"(.*?)\"/g,"%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%").replace(/html-(.*?)=\"(.*?)\"/g,((e,t,n)=>"key"===t||"model"===t||"scopeid"===t?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))})(e.outerHTML);h[n]={template:o,render:g(o)}}))},E=e=>{e.querySelectorAll("template").forEach((e=>{if(e.getAttribute("html-if")||e.getAttribute("html-inner"))return;E(e.content);const t=e.parentNode;if(t){const n=e.content;for(;n.firstChild;)t.insertBefore(n.firstChild,e);t.removeChild(e)}}))},M=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},N={},T=(e=document.body)=>{const t=((e,{components:t})=>{v(e,[...Object.keys(t),"[html-if]","template"]);const n=e.cloneNode(!0);return y(n),E(n),A(n,t),h})(e,{components:N});Object.values(N).forEach((({name:e,module:n,dependencies:r})=>{customElements.get(e)||customElements.define(e,p({component:{name:e,module:n,dependencies:r},templates:t,start:T}))}))};e.publish=c,e.register=(e,t,n)=>{N[e]={name:e,module:t,dependencies:n}},e.start=T,e.subscribe=d,e.templateConfig=e=>{var t;t=e,Object.assign(b,t)},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=jails.js.map