jails-js 5.9.0 → 6.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1125 -0
- package/dist/index.js.map +1 -0
- package/dist/jails.js +1 -1
- package/dist/jails.js.map +1 -1
- package/{html.ts → html.js} +0 -1
- package/package.json +6 -6
- package/readme.md +1 -1
- package/src/component.ts +130 -102
- package/src/element.ts +21 -55
- package/src/index.ts +15 -30
- package/src/template-system.ts +161 -44
- package/src/utils/index.ts +11 -5
- package/src/utils/pubsub.ts +1 -1
- package/vite.config.ts +4 -2
- package/index.d.ts +0 -65
- package/logo.svg +0 -29
- package/src/transpile.ts +0 -79
- package/src/utils/events.ts +0 -86
- package/src/utils/hmr-register.ts +0 -41
@@ -0,0 +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\n// http://crockford.com/javascript/memory/leak.html\nexport const purge = (d) => {\n\tvar a = d.attributes, i, l, n\n\tif (a) {\n\t\tfor (i = a.length - 1; i >= 0; i -= 1) {\n\t\t\tn = a[i].name\n\t\t\tif (typeof d[n] === 'function') {\n\t\t\t\td[n] = null\n\t\t\t}\n\t\t}\n\t}\n\ta = d.childNodes\n\tif (a) {\n\t\tl = a.length\n\t\tfor (i = 0; i < l; i += 1) {\n\t\t\tpurge(d.childNodes[i])\n\t\t}\n\t}\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, rAF, g } 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\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-scope-id')\n\tconst tpl \t\t\t= templates[ tplid ]\n\tconst data \t\t\t= g.scope[ scopeid ]\n\tconst model \t\t= module?.model?.apply ? _model({ elm:node, initialState }) : _model\n\tconst state \t\t= Object.assign({}, data, model, initialState)\n\tconst view \t\t\t= module.view? module.view : (data) => data\n\n\tlet updates \t\t= []\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\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\n\t\t\t\tif( data.constructor === Function ) {\n\t\t\t\t\tdata( state )\n\t\t\t\t}\n\n\t\t\t\tupdates.push(data)\n\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\trAF(() => rAF(() => {\n\t\t\t\t\t\tObject.assign.apply(null, [state, ...updates ])\n\t\t\t\t\t\tif( updates.length ){\n\t\t\t\t\t\t\tconst newstate = Object.assign({}, state)\n\t\t\t\t\t\t\trender(newstate)\n\t\t\t\t\t\t\tresolve(newstate)\n\t\t\t\t\t\t\tupdates = []\n\t\t\t\t\t\t}\n\t\t\t\t\t}))\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\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 : elm\n\t\t\tconst clone = element.cloneNode()\n\t\t\tconst html = html_? html_ : target\n\t\t\tclone.innerHTML = html\n\n\t\t\trAF( _ => Idiomorph.morph(element, clone, IdiomorphOptions) )\n\t\t}\n\t}\n\n\tconst render = ( data ) => {\n\n\t\tconst html = tpl.render.call( view(data), node, safe, g )\n\t\tIdiomorph.morph( node, html, IdiomorphOptions(node) )\n\n\t\trAF(() => {\n\t\t\tnode.querySelectorAll('[tplid]').forEach((element) => {\n\t\t\t\tif(!element.base) return\n\t\t\t\tconst base = element.base\n\t\t\t\tconst props = Object.keys(base.model).reduce((acc, key) => {\n\t\t\t\t\tif( key in data ) {\n\t\t\t\t\t\tif( !acc ) acc = {}\n\t\t\t\t\t\tacc[key] = data[key]\n\t\t\t\t\t}\n\t\t\t\t\treturn acc\n\t\t\t\t}, null)\n\t\t\t\tif( props ) {\n\t\t\t\t\tbase.state.set( props )\n\t\t\t\t}\n\t\t\t})\n\t\t\trAF(() => g.scope = {})\n\t\t})\n\t}\n\n\tnode.base = base\n\tmodule.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\tconst abortController = new AbortController()\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\tif( !this.getAttribute('tplid') ) {\n\t\t\t\tstart( this.parentNode )\n\t\t\t}\n\n\t\t\tComponent({\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: abortController.signal\n\t\t\t})\n\n\t\t\tthis.dispatchEvent( new CustomEvent(':mount') )\n\t\t\tthis.base.state.set({})\n\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.dispatchEvent( new CustomEvent(':unmount') )\n\t\t\tabortController.abort()\n\t\t\tdelete this.base\n\t\t}\n\t}\n}\n","import { uuid } 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 ), 'template'] )\n\tconst clone = target.cloneNode( true )\n\n\ttransformTemplate( clone )\n\tremoveTemplateTagsRecursively( clone )\n\ttransformAttributes( clone )\n\tsetTemplates( clone, components )\n\n\treturn templates\n}\n\nexport const compile = ( html ) => {\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 '+variable+';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + 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})\n}\n\nconst transformAttributes = ( clone ) => {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\n\tclone.innerHTML = clone.innerHTML\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') {\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 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] = { ${varname} :${varname}, ${object}: ${object}, $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\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-scope-id', '%%_=$scopeid_%%')\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\n\t\t\t\tif( html.constructor === Promise ) {\n\t\t\t\t\thtml.then( htmlstring => {\n\t\t\t\t\t\tnode.innerHTML = htmlstring\n\t\t\t\t\t\tconst html = node.outerHTML\n\t\t\t\t\t\ttemplates[tplid] = {\n\t\t\t\t\t\t\ttemplate: html,\n\t\t\t\t\t\t\trender: compile(html)\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tnode.innerHTML = html\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst html = 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","data","base","Element","start","templateConfig","components","html","template"],"mappings":"AACiB,SAAS,cAAc,UAAU;AAE3C,MAAM,IAAI;AAAA,EAChB,OAAO,CAAA;AACR;AAOa,MAAA,MAAM,CAAC,OAAO;AACtB,MAAA;AACH,WAAO,sBAAsB,EAAE;AAAA;AAExB,WAAA,WAAW,IAAI,MAAO,EAAE;AACjC;AAEO,MAAM,OAAO,MAAM;AAClB,SAAA,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACjD;AA0Ba,MAAA,OAAO,CAAC,SAAS,QAAQ;AAClC,MAAA;AACF,WAAO,QAAQ;AAAA,WACT,KAAI;AACV,WAAO,OAAO;AAAA,EAAA;AAEhB;ACsCA,IAAI,YAAa,2BAAY;AA4B3B,MAAI,YAAY,oBAAI,IAAK;AAMzB,MAAI,WAAW;AAAA,IACb,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,MACxB,oBAAoB;AAAA,IAC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AAM,QAAQ,aAAa,GAAG,WAAAH,YAAW,MAAO,CAAA,CAAE;AAAA,IAAA;AAAA,EACvG,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=new DOMParser;const n=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},r=document.createElement("textarea"),o=e=>(r.innerHTML=e,r.value),l=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),i=e=>JSON.parse(JSON.stringify(e)),a=e=>{var t,n,r,o=e.attributes;if(o)for(t=o.length-1;t>=0;t-=1)"function"==typeof e[r=o[t].name]&&(e[r]=null);if(o=e.childNodes)for(n=o.length,t=0;t<n;t+=1)a(e.childNodes[t])},s=(e,t)=>{try{return e()}catch(n){return t||""}},c={tags:["{{","}}"]};function u(e){m(e);const r=function(e,r){const o=new RegExp(`\\${r.tags[0]}(.+?)\\${r.tags[1]}`,"g"),l=t.parseFromString(e.replace(/<\/?template[^>]*>/g,""),"text/html");return l.querySelectorAll("[html-for], [html-if], [html-inner], [html-class], [html-model]").forEach((e=>{const t=e.getAttribute("html-foreach"),r=e.getAttribute("html-for"),o=e.getAttribute("html-if"),l=e.getAttribute("html-inner"),i=e.getAttribute("html-class"),a=r||t;if(a){const t=r?"html-for":"html-foreach",o=a.match(/(.*)\sin\s(.*)/)||"",l=o[1],i=o[2];e.removeAttribute(t),e.setAttribute("scope","");const s=document.createElement("script");s.dataset.scope="",s.type="text/html",s.text="%%_= $scope _%%",e.appendChild(s);const c=document.createTextNode(`%%_(function(){ var $index = 0; for(var $key in safe(function(){ return ${i} }) ){ var ${l} = ${i}[$key]; var $scope = JSON.stringify({ '${l}':${l}, $index: $index, $key:$key }); _%%`),u=document.createTextNode("%%_ $index++; } })() _%%");n(c,e,u)}if(o){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${o} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");n(t,e,r)}l&&(e.removeAttribute("html-inner"),e.innerHTML=`%%_=${l}_%%`),i&&(e.removeAttribute("html-class"),e.className=(e.className+` %%_=${i}_%%`).trim())})),l.body.innerHTML.replace(o,"%%_=$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||"scope"==t?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))}(e.outerHTML,c),l=JSON.stringify(r);return new Function("$element","safe",`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${l.replace(/%%_=(.+?)_%%/g,(function(e,t){return'"+safe(function(){return '+o(t)+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+o(t)+'\noutput+="'}))};return output;\n\t\t}\n\t`)}const d=(e,t,n,r)=>{[].concat(e.matches&&e.matches(t)?e:[]).concat(Array.from(e.querySelectorAll(t))).reverse().forEach((e=>{e.querySelectorAll("template").forEach((e=>d(e.content,t,n,r))),f(e,n,r)}))},f=(e,t,n)=>{if(!e.getAttribute("tplid")){const r="xxxxxxxx".replace(/[xy]/g,(e=>{const t=8*Math.random()|0;return("x"==e?t:3&t|8).toString(8)}));e.setAttribute("tplid",r);const o=e.localName;if(o in n&&n[o].module.template){const l=e.innerHTML,i=n[o].module.template({children:l});i.constructor===Promise?(e.__template=i,i.then((n=>{e.innerHTML=n,t[r]=u(e)}))):e.innerHTML=i}t[r]=u(e)}},m=e=>{e.querySelectorAll("[html-if]").forEach((e=>{e.parentNode.insertBefore(document.createComment(""),e.nextSibling)}))},h={},p={},b=(e,t)=>{p[e]=Object.assign({},p[e],t),h[e]&&h[e].forEach((e=>e(t)))},v=(e,t)=>(h[e]=h[e]||[],h[e].push(t),e in p&&t(p[e]),()=>{h[e]=h[e].filter((e=>e!=t))});var g=function(){let e=new Set,t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:u,afterNodeAdded:u,beforeNodeMorphed:u,afterNodeMorphed:u,beforeNodeRemoved:u,afterNodeRemoved:u,beforeAttributeUpdated:u,beforeNodePantried:u},head:{style:"merge",shouldPreserve:function(e){return"true"===e.getAttribute("im-preserve")},shouldReAppend:function(e){return"true"===e.getAttribute("im-re-append")},shouldRemove:u,afterHeadMorphed:u}};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=c(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&&A(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,c=o(e,n,r);if(!n)return[];if(c){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,c,s);return r.config.twoPass&&A(c.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?c(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)}S(n,r);continue}if(f(r,i,n)){o(i,r,n),i=i.nextSibling,S(n,r);continue}let a=p(e,t,r,i,n);if(a){i=h(i,a,n),o(a,r,n),S(n,r);continue}let s=b(e,t,r,i,n);if(s)i=h(i,s,n),o(s,r,n),S(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)}S(n,r)}}for(;null!==i;){let e=i;i=i.nextSibling,_(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 c(e,t,n){let r=[],o=[],l=[],i=[],a=n.head.style,s=new Map;for(const u of e.children)s.set(u.outerHTML,u);for(const u of t.children){let e=s.has(u.outerHTML),t=n.head.shouldReAppend(u),r=n.head.shouldPreserve(u);e||r?t?o.push(u):(s.delete(u.outerHTML),l.push(u)):"append"===a?t&&(o.push(u),i.push(u)):!1!==n.head.shouldRemove(u)&&o.push(u)}i.push(...s.values());let c=[];for(const u of i){let e=document.createRange().createContextualFragment(u.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()})),c.push(n)}t.appendChild(e),n.callbacks.afterNodeAdded(e),r.push(e)}}for(const u of o)!1!==n.callbacks.beforeNodeRemoved(u)&&(t.removeChild(u),n.callbacks.afterNodeRemoved(u));return n.head.afterHeadMorphed(t,{added:r,kept:l,removed:o}),c}function u(){}function d(){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||k(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 h(e,t,n){let r=e;for(;r!==t;){let e=r;r=e.nextSibling,_(e,n)}return S(n,t),t.nextSibling}function p(e,t,n,r,o){let l=k(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+=k(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(k(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+k(n,e,t):0}function _(t,n){var r;if(S(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)y(t,n);else{if(!1===n.callbacks.beforeNodeRemoved(t))return;null==(r=t.parentNode)||r.removeChild(t),n.callbacks.afterNodeRemoved(t)}}function y(e,t){var n;if(!1!==t.callbacks.beforeNodePantried(e))if(Array.from(e.childNodes).forEach((e=>{y(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 A(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 E(e,t){return!e.deadIds.has(t)}function N(t,n,r){return(t.idMap.get(r)||e).has(n)}function S(t,n){let r=t.idMap.get(n)||e;for(const e of r)t.deadIds.add(e)}function k(t,n,r){let o=t.idMap.get(n)||e,l=0;for(const e of o)E(t,e)&&N(t,e,r)&&++l;return l}function x(e){let t=Array.from(e.querySelectorAll("[id]"));return e.id&&t.push(e),t}function M(e,t){let n=e.parentElement;for(const r of x(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 T(e,t){let n=new Map;return M(e,n),M(t,n),n}function w(e,t){const n=e=>e.tagName+"#"+e.id,r=new Set(x(e).map(n));let o=new Set;for(const l of x(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:T(e,n),deadIds:new Set,persistentIds:o.twoPass?w(e,n):new Set,pantry:o.twoPass?d():document.createElement("div"),callbacks:o.callbacks,head:o.head}}(e,l,o);return n(e,l,i)},defaults:t}}();const _="CustomEvent"in window&&"function"==typeof window.CustomEvent?(e,t)=>new CustomEvent(e,t):(e,t)=>{const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!0,!0,t),n},y=(e,t)=>function(n){const r=this,o=n.detail||{};e.__events[t].forEach((e=>{e.handler.apply(r,[n].concat(o.args))}))},A=(e,t)=>{e.__events[t]&&e.__events[t].listener&&(e.removeEventListener(t,e.__events[t].listener,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),delete e.__events[t])},E=(e,t,n)=>function(r){const o=this,l=r.detail||{};let i=r.target;for(;i&&(i.matches(t)&&(r.delegateTarget=i,n.apply(o,[r].concat(l.args))),i!==e);)i=i.parentNode},N=(e,t,n,r)=>{if(e.__events=e.__events||{},e.__events[t]=e.__events[t]||[],!e.__events[t].length){const n=y(e,t);e.addEventListener(t,n,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),e.__events[t].listener=n}n.call?e.__events[t].push({handler:n,callback:n}):e.__events[t].push({handler:E(e,n,r),callback:r})},S=(e,t,n)=>{if(n&&e.__events[t]&&e.__events[t].length){var r=e.__events[t];e.__events[t]=e.__events[t].filter((function(e){return e.callback!=n})),e.__events[t].listener=r.listener,e.__events[t].length||A(e,t)}else A(e,t)},k=(e,t,n)=>{e.dispatchEvent(_(t,{bubbles:!0,detail:n}))};const x=e=>({main:e=>e,unmount:e=>e,onupdate:e=>e,view:e.view?e.view:e=>e}),M=e=>{e.querySelectorAll("[scope]").forEach((e=>{e.querySelectorAll("[tplid]").forEach((t=>{if(!t.___scope___){const n=e.lastElementChild;t.___scope___="scope"in n.dataset?new Function(`return ${n.text}`)():{}}}))}))},T=e=>({callbacks:{beforeNodeMorphed(t){if(1===t.nodeType){if("html-static"in t.attributes)return!1;if(t.base&&t!==e)return!1}}}});function w(e,t,n,r){return class extends HTMLElement{constructor(){super()}connectedCallback(){const{base:o,options:a}=function(e,{module:t,dependencies:n,templates:r,components:o}){const a=x(t),c=new Function(`return ${e.getAttribute("html-model")||"{}"}`)(),u=Object.keys(o).toString();d(e,u,r,o);const f=e.getAttribute("tplid"),m=f?r[f]:null,h={data:t.model?i(t.model):{}};h.data=Object.assign(h.data,c);const p={template:m,elm:e,dependencies:n,publish:b,subscribe:v,main(e){a.main=e},unmount(e){a.unmount=e},onupdate(e){a.onupdate=e},on(t,n,r){N(e,t,n,r)},off(t,n){S(e,t,n)},trigger(t,n,r){n.constructor===String?Array.from(e.querySelectorAll(n)).forEach((e=>k(e,t,{args:r}))):k(e,t,{args:n})},emit:(...t)=>{k(e,t.shift(),{args:t})},state:{set(e){if(e.constructor===Function){const t=i(h.data);e(t),p.render(t)}else p.render(e);return new Promise((e=>l((t=>l((()=>e(h.data)))))))},get:()=>i(h.data),getRaw:()=>h.data},render(t=h.data){if(!document.body.contains(e))return;h.data=Object.assign(h.data,t);const n=i(h.data),o=r[f].call(Object.assign(a.view(n),e.___scope___),e,s);g.morph(e,o,T(e)),M(e),l((n=>{Array.from(e.querySelectorAll("[tplid]")).forEach((e=>{const n=Object.assign(e.base.state.getRaw(),t);e.options.onupdate(n),e.base.render(n)}))}))},innerHTML(t,n){const r=n?t:e,o=r.cloneNode(),i=n||t;o.innerHTML=i,l((e=>g.morph(r,o,T)))}};return{base:p,options:a}}(this,{module:e,dependencies:t,templates:n,components:r});if(this.base=o,this.options=a,this.base.render(),this.returns=e.default(o),this.__template&&this.__template.constructor===Promise)this.__template.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.returns&&this.returns.constructor===Promise)this.returns.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}disconnectedCallback(){this.options.unmount(this.base),l((()=>{document.body.contains(this)||(this.__events&&(this.__events=null),this.base&&(this.base.elm=null),this.base&&(this.base=null),a(this))}))}attributeChangedCallback(){}}}const C={},$={},H={templateConfig:e=>{Object.assign(c,e)},publish:b,subscribe:v,register(e,t,n={}){$[e]={name:e,module:t,dependencies:n}},start(e=document.body){const t=Object.keys($),n=t.toString();t.length&&(d(e,n,C,$),L())}},L=()=>{Object.values($).forEach((e=>{const{name:t,module:n,dependencies:r}=e;if(!customElements.get(t)){const e=w(n,r,C,$);customElements.define(t,e)}}))};e.attributes=e=>Object.entries(e).map((([e,t])=>""===t?e:`${e}="${t}"`)).join(" "),e.default=H,e.html=(e,...t)=>{let n=e.raw,r="";return t.forEach(((e,t)=>{let o=n[t];Array.isArray(e)&&(e=e.join("")),r+=o,r+=e})),r+=n[n.length-1],r},Object.defineProperties(e,{__esModule:{value:!0},[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";document.createElement("textarea");const t={scope:{}},n=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),r=(e,t)=>{try{return e()}catch(n){return t||""}};var o=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 a,i;if(r.head.block){let o=e.querySelector("head"),l=t.querySelector("head");if(o&&l){let a=d(l,o,r);return void Promise.all(a).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!=(a=null==n?void 0:n.previousSibling)?a:null,s=null!=(i=null==n?void 0:n.nextSibling)?i:null,d=o(e,n,r);if(!n)return[];if(d){const e=function(e,t,n){var r,o;let l=[],a=[];for(;null!=e;)l.push(e),e=e.previousSibling;let i=l.pop();for(;void 0!==i;)a.push(i),null==(r=t.parentElement)||r.insertBefore(i,t),i=l.pop();a.push(t);for(;null!=n;)l.push(n),a.push(n),n=n.nextSibling;for(;l.length>0;){const e=l.pop();null==(o=t.parentElement)||o.insertBefore(e,t.nextSibling)}return a}(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,a;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):(i(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==(a=e.parentNode)||a.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,a=t.firstChild;for(;l;){if(r=l,l=r.nextSibling,null==a){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)}M(n,r);continue}if(f(r,a,n)){o(a,r,n),a=a.nextSibling,M(n,r);continue}let i=h(e,t,r,a,n);if(i){a=p(a,i,n),o(i,r,n),M(n,r);continue}let s=b(e,t,r,a,n);if(s)a=p(a,s,n),o(s,r,n),M(n,r);else{if(n.config.twoPass&&n.persistentIds.has(r.id))t.insertBefore(r,a);else{if(!1===n.callbacks.beforeNodeAdded(r))continue;t.insertBefore(r,a),n.callbacks.afterNodeAdded(r)}M(n,r)}}for(;null!==a;){let e=a;a=a.nextSibling,y(e,n)}}function a(e,t,n,r){return!("value"!==e||!r.ignoreActiveValue||t!==document.activeElement)||!1===r.callbacks.beforeAttributeUpdated(e,t,n)}function i(e,t,n){let o=e.nodeType;if(1===o){const r=e,o=t,l=r.attributes,i=o.attributes;for(const e of l)a(e.name,o,"update",n)||o.getAttribute(e.name)!==e.value&&o.setAttribute(e.name,e.value);for(let e=i.length-1;0<=e;e--){const t=i[e];if(t&&!r.hasAttribute(t.name)){if(a(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&&(a("value",t,"update",n)||(t.setAttribute("value",r),t.value=r)):a("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(a("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=a(n,t,"update",r);l||(t[n]=e[n]),o?l||t.setAttribute(n,o):a(n,t,"remove",r)||t.removeAttribute(n)}}function d(e,t,n){let r=[],o=[],l=[],a=[],i=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"===i?t&&(o.push(c),a.push(c)):!1!==n.head.shouldRemove(c)&&o.push(c)}a.push(...s.values());let d=[];for(const c of a){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||k(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 M(n,t),t.nextSibling}function h(e,t,n,r,o){let l=k(o,n,t),a=null;if(l>0){a=r;let t=0;for(;null!=a;){if(f(n,a,o))return a;if(t+=k(o,a,e),t>l)return null;a=a.nextSibling}}return a}function b(e,t,n,r,o){let l=r,a=n.nextSibling,i=0;for(;null!=l;){if(k(o,l,e)>0)return null;if(m(l,n))return l;if(m(l,a)&&(i++,a=a.nextSibling,i>=2))return null;l=l.nextSibling}return l}const v=new WeakSet;function g(e,t,n){return m(t,e)?.5+k(n,e,t):0}function y(t,n){var r;if(M(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)&&(i(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 M(t,n){let r=t.idMap.get(n)||e;for(const e of r)t.deadIds.add(e)}function k(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 $(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 w(e,t){let n=new Map;return $(e,n),$(t,n),n}function C(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),a=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:w(e,n),deadIds:new Set,persistentIds:o.twoPass?C(e,n):new Set,pantry:o.twoPass?u():document.createElement("div"),callbacks:o.callbacks,head:o.head}}(e,l,o);return n(e,l,a)},defaults:t}}();const l={},a={},i=(e,t)=>{a[e]=Object.assign({},a[e],t),l[e]&&l[e].forEach((e=>e(t)))},s=(e,t)=>(l[e]=l[e]||[],l[e].push(t),e in a&&t(a[e]),()=>{l[e]=l[e].filter((e=>e!=t))}),d=e=>({callbacks:{beforeNodeMorphed(t){if(1===t.nodeType){if("html-static"in t.attributes)return!1;if(t.base&&t!==e)return!1}}}}),c=({component:e,templates:l,start:a})=>{const{name:c,module:u,dependencies:f}=e,m=new AbortController;return class extends HTMLElement{constructor(){super()}connectedCallback(){this.getAttribute("tplid")||a(this.parentNode),(({name:e,module:l,dependencies:a,node:c,templates:u,signal:f})=>{var m;const p=l.model||{},h=new Function(`return ${c.getAttribute("html-model")||"{}"}`)(),b=c.getAttribute("tplid"),v=c.getAttribute("html-scope-id"),g=u[b],y=t.scope[v],A=(null==(m=null==l?void 0:l.model)?void 0:m.apply)?p({elm:c,initialState:h}):p,E=Object.assign({},y,A,h),N=l.view?l.view:e=>e;let S=[];const M={name:e,model:A,elm:c,template:g.template,dependencies:a,publish:i,subscribe:s,main(e){c.addEventListener(":mount",e)},state:{save(e){e.constructor===Function?e(E):Object.assign(E,e)},set(e){if(document.body.contains(c))return e.constructor===Function&&e(E),S.push(e),new Promise((e=>{n((()=>n((()=>{if(Object.assign.apply(null,[E,...S]),S.length){const t=Object.assign({},E);k(t),e(t),S=[]}}))))}))},get:()=>Object.assign({},E)},on(e,t,n){n?(n.handler=e=>{const r=e.detail||{};let o=e.target;for(;o&&(o.matches(t)&&(e.delegateTarget=o,n.apply(c,[e].concat(r.args))),o!==c);)o=o.parentNode},c.addEventListener(e,n.handler,{signal:f,capture:"focus"==e||"blur"==e||"mouseenter"==e||"mouseleave"==e})):(t.handler=e=>{e.delegateTarget=c,t.apply(c,[e].concat(e.detail.args))},c.addEventListener(e,t.handler,{signal:f}))},off(e,t){t.handler&&c.removeEventListener(e,t.handler)},trigger(e,t,n){t.constructor===String?Array.from(c.querySelectorAll(t)).forEach((t=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))})):c.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:n}}))},emit(e,t){c.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{args:t}}))},unmount(e){c.addEventListener(":unmount",e)},innerHTML(e,t){const r=t?e:elm,l=r.cloneNode(),a=t||e;l.innerHTML=a,n((e=>o.morph(r,l,d)))}},k=e=>{const l=g.render.call(N(e),c,r,t);o.morph(c,l,d(c)),n((()=>{c.querySelectorAll("[tplid]").forEach((t=>{if(!t.base)return;const n=t.base,r=Object.keys(n.model).reduce(((t,n)=>(n in e&&(t||(t={}),t[n]=e[n]),t)),null);r&&n.state.set(r)})),n((()=>t.scope={}))}))};c.base=M,l.default(M)})({node:this,name:c,module:u,dependencies:f,templates:l,signal:m.signal}),this.dispatchEvent(new CustomEvent(":mount")),this.base.state.set({})}disconnectedCallback(){this.dispatchEvent(new CustomEvent(":unmount")),m.abort(),delete this.base}}},u={},f={tags:["{{","}}"]},m=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 '+t+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+t+'\noutput+="'}))};return output;\n\t\t}\n\t`)},p=(e,t)=>{e.querySelectorAll(t.toString()).forEach((e=>{if("template"===e.localName)return p(e.content,t);e.setAttribute("tplid",Math.random().toString(36).substring(2,9))}))},h=e=>{const t=new RegExp(`\\${f.tags[0]}(.+?)\\${f.tags[1]}`,"g");e.innerHTML=e.innerHTML.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?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))},b=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=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] = { ${r} :${r}, ${o}: ${o}, $index: $index, $key: $key }; _%%`),a=document.createTextNode("%%_ $index++; } })() _%%");y(l,e,a)}if(n){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${n} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");y(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&&b(e.content)}))},v=(e,t)=>{Array.from(e.querySelectorAll("[tplid]")).reverse().forEach((e=>{const n=e.getAttribute("tplid"),r=e.localName;if(e.setAttribute("html-scope-id","%%_=$scopeid_%%"),r in t&&t[r].module.template){const o=e.innerHTML,l=t[r].module.template({elm:e,children:o});l.constructor===Promise?l.then((t=>{e.innerHTML=t;const r=e.outerHTML;u[n]={template:r,render:m(r)}})):e.innerHTML=l}const o=e.outerHTML;u[n]={template:o,render:m(o)}}))},g=e=>{e.querySelectorAll("template").forEach((e=>{if(e.getAttribute("html-if")||e.getAttribute("html-inner"))return;g(e.content);const t=e.parentNode;if(t){const n=e.content;for(;n.firstChild;)t.insertBefore(n.firstChild,e);t.removeChild(e)}}))},y=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},A={},E=(e=document.body)=>{const t=((e,{components:t})=>{p(e,[...Object.keys(t),"template"]);const n=e.cloneNode(!0);return b(n),g(n),h(n),v(n,t),u})(e,{components:A});Object.values(A).forEach((({name:e,module:n,dependencies:r})=>{customElements.get(e)||customElements.define(e,c({component:{name:e,module:n,dependencies:r},templates:t,start:E}))}))};e.publish=i,e.register=(e,t,n)=>{A[e]={name:e,module:t,dependencies:n}},e.start=E,e.subscribe=s,e.templateConfig=e=>{var t;t=e,Object.assign(f,t)},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
2
2
|
//# sourceMappingURL=jails.js.map
|