From 4067cc710afff8e150547fba08755bf4ab201653 Mon Sep 17 00:00:00 2001 From: nvms Date: Sun, 20 Oct 2024 20:04:29 -0400 Subject: [PATCH] pass el to most directives --- package.json | 2 +- public/demo.js | 44 +++++++++++++++----------------- public/demo.js.map | 4 +-- public/index.css.br | Bin 0 -> 9650 bytes public/index.js | 6 +---- public/index.js.br | Bin 0 -> 8161 bytes src/directives/attribute.ts | 2 +- src/directives/event.ts | 2 +- src/directives/for.ts | 4 +-- src/directives/if.ts | 2 +- src/directives/interpolation.ts | 2 +- src/directives/show.ts | 2 +- src/index.ts | 26 +++++++++---------- src/plugins/router/plugin.ts | 14 +++++----- 14 files changed, 51 insertions(+), 59 deletions(-) create mode 100644 public/index.css.br create mode 100755 public/index.js.br diff --git a/package.json b/package.json index 653905f..b644007 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "scripts": { "serve": "esr --serve src/demo.ts", - "build": "esr --build src/index.ts", + "build": "esr --build src/index.ts && brotli -f -q 11 public/index.js && brotli -f -q 11 public/index.css", "build:watch": "esr --build --watch src/index.ts", "run": "esr --run src/index.ts", "run:watch": "esr --run --watch src/index.ts", diff --git a/public/demo.js b/public/demo.js index 9944b60..08aad94 100755 --- a/public/demo.js +++ b/public/demo.js @@ -203,7 +203,7 @@ var AttributeDirective = class { } } update() { - let value = evalGet(this.context.scope, this.expression); + let value = evalGet(this.context.scope, this.expression, this.element); if (this.is.spread && typeof value === "object") { for (const [key, val] of Object.entries(value)) { this.element.setAttribute(key, String(val)); @@ -259,7 +259,7 @@ var EventDirective = class { if (parts.includes("stop")) event.stopPropagation(); if (parts.includes("once") && this.eventCount > 0) return; this.eventCount++; - const handler = evalGet(context.scope, attr.value); + const handler = evalGet(context.scope, attr.value, element); if (typeof handler === "function") { handler(event); } @@ -345,7 +345,7 @@ var _for = (el, exp, ctx, component, componentProps, allProps) => { indexExp && (data[indexExp] = index); } const childCtx = createScopedContext(ctx, data); - const key = keyExp ? evalGet(childCtx.scope, keyExp) : index; + const key = keyExp ? evalGet(childCtx.scope, keyExp, el) : index; map.set(key, index); childCtx.key = key; return childCtx; @@ -357,7 +357,7 @@ var _for = (el, exp, ctx, component, componentProps, allProps) => { return block; }; ctx.effect(() => { - const source = evalGet(ctx.scope, sourceExp); + const source = evalGet(ctx.scope, sourceExp, el); const prevKeyToIndexMap = keyToIndexMap; [childCtxs, keyToIndexMap] = createChildContexts(source); if (!mounted) { @@ -429,7 +429,7 @@ function _if(el, exp, ctx, component, componentProps, allProps) { ctx.effect(() => { for (let i = 0; i < branches.length; i++) { const { exp: exp2, el: el2 } = branches[i]; - if (!exp2 || evalGet(ctx.scope, exp2)) { + if (!exp2 || evalGet(ctx.scope, exp2, el2)) { if (i !== activeBranchIndex) { removeActiveBlock(); block = new Block({ element: el2, parentContext: ctx, replacementType: "replace", component, componentProps, allProps }); @@ -459,7 +459,7 @@ var InterpolationDirective = class { this.textNodes.forEach((nodes, expression) => { const trimmedExpression = expression.slice(2, -2).trim(); nodes.forEach((node) => { - const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, node); + const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, element); context.effect(() => { node.textContent = toDisplayString(getter()); }); @@ -518,7 +518,7 @@ var ShowDirective = class { context.effect(this.update.bind(this)); } update() { - const shouldShow = Boolean(evalGet(this.context.scope, this.expression)); + const shouldShow = Boolean(evalGet(this.context.scope, this.expression, this.element)); this.element.style.display = shouldShow ? this.originalDisplay : "none"; } }; @@ -815,11 +815,7 @@ function unwrap(value) { // src/plugins/router/plugin.ts var activeRouters = /* @__PURE__ */ new Set(); var link = { - template: html` - - LINK - - `, + template: html``, props: { href: { default: "#" } }, main({ href }) { const go = (e) => { @@ -835,7 +831,7 @@ var link = { // src/index.ts var App2 = class { - rootBlock; + root; registry = /* @__PURE__ */ new Map(); plugins = /* @__PURE__ */ new Set(); register(name, component) { @@ -852,11 +848,11 @@ var App2 = class { const root = typeof target === "string" ? document.querySelector(target) : target; const display = root.style.display; root.style.display = "none"; - this.rootBlock = this._mount(component, root, props, true); + this.root = this._mount(component, root, props); root.style.display = display; - return this.rootBlock; + return this.root; } - _mount(component, target, props, isRoot = false) { + _mount(component, target, props) { const parentContext = createContext({ app: this }); if (props) { parentContext.scope = reactive(props); @@ -868,14 +864,14 @@ var App2 = class { element: target, parentContext, component, - isRoot, + isRoot: true, componentProps: props, replacementType: "replaceChildren" }); return block; } unmount() { - this.rootBlock.teardown(); + this.root.teardown(); } }; function createContext({ parentContext, app: app2 }) { @@ -1108,7 +1104,7 @@ function walk(node, context) { if (warnInvalidDirectives(node2, [":if", ":teleport"])) return; if (warnInvalidDirectives(node2, [":for", ":teleport"])) return; if (exp = checkAndRemoveAttribute(node2, ":scope")) { - const scope = evalGet(context2.scope, exp); + const scope = evalGet(context2.scope, exp, node2); if (typeof scope === "object") { Object.assign(context2.scope, scope); } @@ -1133,7 +1129,7 @@ function walk(node, context) { } if (exp = checkAndRemoveAttribute(node2, ":html")) { context2.effect(() => { - const result = evalGet(context2.scope, exp); + const result = evalGet(context2.scope, exp, node2); if (result instanceof Element) { node2.replaceChildren(); node2.append(result); @@ -1144,7 +1140,7 @@ function walk(node, context) { } if (exp = checkAndRemoveAttribute(node2, ":text")) { context2.effect(() => { - node2.textContent = toDisplayString(evalGet(context2.scope, exp)); + node2.textContent = toDisplayString(evalGet(context2.scope, exp, node2)); }); } }; @@ -1156,7 +1152,7 @@ function walk(node, context) { originalName: attr.name, extractedName: extractPropName(attr.name), exp: attr.value, - value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name)) : attr.value ? evalGet(context.scope, attr.value) : void 0 + value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name), node2) : attr.value ? evalGet(context.scope, attr.value, node2) : void 0 })); }; if (isComponent(node, context)) { @@ -1164,10 +1160,10 @@ function walk(node, context) { const allProps = processAttributes(node, component); const componentProps = allProps.reduce((acc, { isSpread, isMirror, extractedName, value }) => { if (isSpread) { - const spread = evalGet(context.scope, extractedName); + const spread = evalGet(context.scope, extractedName, node); if (isObject(spread)) Object.assign(acc, spread); } else if (isMirror) { - acc[extractedName] = evalGet(context.scope, extractedName); + acc[extractedName] = evalGet(context.scope, extractedName, node); } else { acc[extractedName] = value; } diff --git a/public/demo.js.map b/public/demo.js.map index ad6aef0..a2f98fc 100755 --- a/public/demo.js.map +++ b/public/demo.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/util.ts", "../src/directives/attribute.ts", "../src/directives/event.ts", "../src/directives/for.ts", "../src/directives/if.ts", "../src/directives/interpolation.ts", "../src/directives/show.ts", "../src/directives/teleport.ts", "../src/directives/value.ts", "../src/reactivity/effect.ts", "../src/reactivity/computed.ts", "../src/reactivity/ref.ts", "../src/reactivity/reactive.ts", "../src/reactivity/unwrap.ts", "../src/plugins/router/plugin.ts", "../src/index.ts", "../src/demo.ts"], - "sourcesContent": ["import { Component } from \".\";\n\nexport function stringToElement(template: string): Element {\n const parser = new DOMParser();\n const doc = parser.parseFromString(template, \"text/html\");\n return doc.body.firstChild as Element;\n}\n\nexport const isText = (node: Node): node is Text => {\n return node.nodeType === Node.TEXT_NODE;\n};\n\nexport const isTemplate = (node: Node): node is HTMLTemplateElement => {\n return node.nodeName === \"TEMPLATE\";\n};\n\nexport const isElement = (node: Node): node is Element => {\n return node.nodeType === Node.ELEMENT_NODE;\n};\n\nexport function isObject(value: any): value is object {\n return value !== null && typeof value === \"object\";\n}\n\nexport function isArray(value: any): value is any[] {\n return Array.isArray(value);\n}\n\nexport function checkAndRemoveAttribute(el: Element, attrName: string): string | null {\n // Attempt to get the attribute value\n const attributeValue = el.getAttribute(attrName);\n\n // If attribute exists, remove it from the element\n if (attributeValue !== null) {\n el.removeAttribute(attrName);\n }\n\n // Return the value of the attribute or null if not present\n return attributeValue;\n}\n\nexport interface Slot {\n node: Element;\n name: string;\n}\n\nexport interface Template {\n targetSlotName: string;\n node: HTMLTemplateElement;\n}\n\nexport function findSlotNodes(element: Element): Slot[] {\n const slots: Slot[] = [];\n\n const findSlots = (node: Element) => {\n Array.from(node.childNodes).forEach((node) => {\n if (isElement(node)) {\n if (node.nodeName === \"SLOT\") {\n slots.push({ node, name: node.getAttribute(\"name\") || \"default\" });\n }\n\n if (node.hasChildNodes()) {\n findSlots(node);\n }\n }\n });\n };\n\n findSlots(element);\n\n return slots;\n}\n\nexport function findTemplateNodes(element: Element) {\n const templates: Template[] = [];\n\n const findTemplates = (element: Element) => {\n let defaultContentNodes: Node[] = [];\n\n Array.from(element.childNodes).forEach((node) => {\n if (isElement(node) || isText(node)) {\n if (isElement(node) && node.nodeName === \"TEMPLATE\" && isTemplate(node)) {\n templates.push({ targetSlotName: node.getAttribute(\"slot\") || \"\", node });\n } else {\n // Capture non-template top-level nodes and text nodes for default slot\n defaultContentNodes.push(node);\n }\n }\n });\n\n if (defaultContentNodes.length > 0) {\n // Create a template element with a default slot\n const defaultTemplate = document.createElement(\"template\");\n defaultTemplate.setAttribute(\"slot\", \"default\");\n\n defaultContentNodes.forEach((node) => {\n defaultTemplate.content.appendChild(node);\n });\n\n templates.push({ targetSlotName: \"default\", node: defaultTemplate });\n }\n };\n\n findTemplates(element);\n\n return templates;\n}\n\nexport const nextTick = async (f?: Function) => {\n await new Promise((r) =>\n setTimeout((_) =>\n requestAnimationFrame((_) => {\n f && f();\n r();\n }),\n ),\n );\n};\n\nexport function html(strings: TemplateStringsArray, ...values: any[]): string {\n // List of valid self-closing tags in HTML\n const selfClosingTags = [\"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\"];\n\n // Join the strings and values into a single template\n let result = strings.reduce((acc, str, i) => acc + str + (values[i] || \"\"), \"\");\n\n // Match non-HTML valid self-closing tags\n result = result.replace(/<([a-zA-Z][^\\s/>]*)\\s*([^>]*?)\\/>/g, (match, tagName, attributes) => {\n // If the tag is a valid self-closing tag, return it as is\n if (selfClosingTags.includes(tagName.toLowerCase())) {\n return match;\n }\n\n // Return the tag as an open/close tag preserving attributes\n return `<${tagName} ${attributes}>`;\n });\n\n return result;\n}\n\nexport function toDisplayString(value: unknown) {\n return value == null ? \"\" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);\n}\n\nexport function insertAfter(newNode: Node, existingNode: Node) {\n if (existingNode.nextSibling) {\n existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);\n } else {\n existingNode?.parentNode?.appendChild(newNode);\n }\n}\n\nexport function isPropAttribute(attrName: string) {\n if (attrName.startsWith(\".\")) {\n return true;\n }\n\n if (attrName.startsWith(\"{\") && attrName.endsWith(\"}\")) {\n return true;\n }\n\n return false;\n}\n\nexport function isSpreadProp(attr: string) {\n return attr.startsWith(\"...\");\n}\n\nexport function isMirrorProp(attr: string) {\n return attr.startsWith(\"{\") && attr.endsWith(\"}\");\n}\n\nexport function isRegularProp(attr: string) {\n return attr.startsWith(\".\");\n}\n\nexport function isEventAttribute(attrName: string) {\n return attrName.startsWith(\"@\");\n}\n\nexport function componentHasPropByName(name: string, component: Component) {\n return Object.keys(component?.props ?? {}).some((prop) => prop === name);\n}\n\nexport function extractAttributeName(attrName: string) {\n return attrName\n .replace(/^\\.\\.\\./, \"\")\n .replace(/^\\./, \"\")\n .replace(/^{/, \"\")\n .replace(/}$/, \"\")\n .replace(/:bind$/, \"\");\n}\n\nfunction dashToCamel(str: string) {\n return str.toLowerCase().replace(/-([a-z])/g, (g) => g[1].toUpperCase());\n}\n\nexport function extractPropName(attrName: string) {\n return dashToCamel(extractAttributeName(attrName));\n}\n\nexport function classNames(_: any) {\n const classes = [];\n for (let i = 0; i < arguments.length; i++) {\n const arg = arguments[i];\n if (!arg) continue;\n const argType = typeof arg;\n if (argType === \"string\" || argType === \"number\") {\n classes.push(arg);\n } else if (Array.isArray(arg)) {\n if (arg.length) {\n const inner = classNames.apply(null, arg);\n if (inner) {\n classes.push(inner);\n }\n }\n } else if (argType === \"object\") {\n if (arg.toString === Object.prototype.toString) {\n for (let key in arg) {\n if (Object.hasOwnProperty.call(arg, key) && arg[key]) {\n classes.push(key);\n }\n }\n } else {\n classes.push(arg.toString());\n }\n }\n }\n return classes.join(\" \");\n}\n", "import { Context, evalGet } from \"..\";\nimport { classNames, extractAttributeName } from \"../util\";\n\ninterface AttributeDirectiveOptions {\n element: Element;\n context: Context;\n attr: Attr;\n}\n\ninterface Is {\n sameNameProperty: boolean;\n bound: boolean;\n spread: boolean;\n componentProp: boolean;\n}\n\nexport class AttributeDirective {\n element: Element;\n context: Context;\n expression: string;\n attr: Attr;\n extractedAttributeName: string;\n\n previousClasses: string[] = [];\n previousStyles: { [key: string]: string } = {};\n\n is: Is = {\n sameNameProperty: false,\n bound: false,\n spread: false,\n componentProp: false,\n };\n\n constructor({ element, context, attr }: AttributeDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = attr.value;\n this.attr = attr;\n this.extractedAttributeName = extractAttributeName(attr.name);\n\n this.is = {\n sameNameProperty: attr.name.startsWith(\"{\") && attr.name.endsWith(\"}\"),\n bound: attr.name.includes(\":bind\"),\n spread: attr.name.startsWith(\"...\"),\n componentProp: false,\n };\n\n if (this.is.sameNameProperty) {\n this.expression = this.extractedAttributeName;\n }\n\n if (this.is.spread) {\n this.expression = this.extractedAttributeName;\n }\n\n element.removeAttribute(attr.name);\n\n if (this.is.bound) {\n context.effect(this.update.bind(this));\n } else {\n this.update();\n }\n }\n\n update() {\n let value = evalGet(this.context.scope, this.expression);\n\n if (this.is.spread && typeof value === \"object\") {\n for (const [key, val] of Object.entries(value)) {\n this.element.setAttribute(key, String(val));\n }\n } else if ((typeof value === \"object\" || Array.isArray(value)) && this.extractedAttributeName === \"class\") {\n value = classNames(value);\n const next = value.split(\" \");\n\n // If we now have classes that are not already on the element, add them now.\n // Remove classes that are no longer on the element.\n const diff = next.filter((c: string) => !this.previousClasses.includes(c)).filter(Boolean);\n const rm = this.previousClasses.filter((c) => !next.includes(c));\n\n diff.forEach((c: string) => {\n this.previousClasses.push(c);\n this.element.classList.add(c);\n });\n\n rm.forEach((c) => {\n this.previousClasses = this.previousClasses.filter((addedClass) => addedClass !== c);\n this.element.classList.remove(c);\n });\n } else if (typeof value === \"object\" && this.extractedAttributeName === \"style\") {\n console.log(\"value is object\", value)\n const next = Object.keys(value);\n const rm = Object.keys(this.previousStyles).filter((style) => !next.includes(style));\n\n next.forEach((style) => {\n this.previousStyles[style] = value[style];\n // @ts-ignore\n this.element.style[style] = value[style];\n });\n\n rm.forEach((style) => {\n this.previousStyles[style] = \"\";\n // @ts-ignore\n this.element.style[style] = \"\";\n });\n\n this.previousStyles = value;\n } else {\n this.element.setAttribute(this.extractedAttributeName, value);\n }\n }\n}\n", "import { Context, evalGet } from \"..\";\n\ninterface EventDirectiveOptions {\n element: Element;\n context: Context;\n attr: Attr;\n}\n\nexport class EventDirective {\n element: Element;\n context: Context;\n expression: string;\n attr: Attr;\n eventCount = 0;\n\n constructor({ element, context, attr }: EventDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = attr.value;\n this.attr = attr;\n\n const eventName = attr.name.replace(/^@/, \"\");\n const parts = eventName.split(\".\");\n\n this.element.addEventListener(parts[0], (event) => {\n if (parts.includes(\"prevent\")) event.preventDefault();\n if (parts.includes(\"stop\")) event.stopPropagation();\n if (parts.includes(\"once\") && this.eventCount > 0) return;\n\n this.eventCount++;\n\n const handler = evalGet(context.scope, attr.value);\n if (typeof handler === \"function\") {\n handler(event);\n }\n });\n\n element.removeAttribute(attr.name);\n }\n}\n", "import { Block, Component, Context, createScopedContext, evalGet } from \"..\";\nimport { isArray, isObject } from \"../util\";\n\nconst forAliasRE = /([\\s\\S]*?)\\s+(?:in|of)\\s+([\\s\\S]*)/;\nconst forIteratorRE = /,([^,\\}\\]]*)(?:,([^,\\}\\]]*))?$/;\nconst stripParensRE = /^\\(|\\)$/g;\nconst destructureRE = /^[{[]\\s*((?:[\\w_$]+\\s*,?\\s*)+)[\\]}]$/;\n\ntype KeyToIndexMap = Map;\n\nexport const _for = (el: Element, exp: string, ctx: Context, component?: Component, componentProps?: Record, allProps?: Record) => {\n const inMatch = exp.match(forAliasRE);\n if (!inMatch) {\n console.warn(`invalid :for expression: ${exp}`);\n return;\n }\n\n const nextNode = el.nextSibling;\n\n const parent = el.parentElement!;\n const anchor = new Text(\"\");\n parent.insertBefore(anchor, el);\n parent.removeChild(el);\n\n const sourceExp = inMatch[2].trim();\n let valueExp = inMatch[1].trim().replace(stripParensRE, \"\").trim();\n let destructureBindings: string[] | undefined;\n let isArrayDestructure = false;\n let indexExp: string | undefined;\n let objIndexExp: string | undefined;\n\n let keyAttr = \"key\";\n let keyExp = el.getAttribute(keyAttr) || el.getAttribute((keyAttr = \":key\")) || el.getAttribute((keyAttr = \":key:bind\"));\n if (keyExp) {\n el.removeAttribute(keyAttr);\n if (keyAttr === \"key\") keyExp = JSON.stringify(keyExp);\n }\n\n let match: any;\n if ((match = valueExp.match(forIteratorRE))) {\n valueExp = valueExp.replace(forIteratorRE, \"\").trim();\n indexExp = match[1].trim();\n if (match[2]) {\n objIndexExp = match[2].trim();\n }\n }\n\n if ((match = valueExp.match(destructureRE))) {\n destructureBindings = match[1].split(\",\").map((s: string) => s.trim());\n isArrayDestructure = valueExp[0] === \"[\";\n }\n\n let mounted = false;\n let blocks: Block[];\n let childCtxs: Context[];\n let keyToIndexMap: Map;\n\n const createChildContexts = (source: unknown): [Context[], KeyToIndexMap] => {\n const map: KeyToIndexMap = new Map();\n const ctxs: Context[] = [];\n\n if (isArray(source)) {\n for (let i = 0; i < source.length; i++) {\n ctxs.push(createChildContext(map, source[i], i));\n }\n } else if (typeof source === \"number\") {\n for (let i = 0; i < source; i++) {\n ctxs.push(createChildContext(map, i + 1, i));\n }\n } else if (isObject(source)) {\n let i = 0;\n for (const key in source) {\n ctxs.push(createChildContext(map, source[key], i++, key));\n }\n }\n\n return [ctxs, map];\n };\n\n const createChildContext = (map: KeyToIndexMap, value: any, index: number, objKey?: string): Context => {\n const data: any = {};\n if (destructureBindings) {\n destructureBindings.forEach((b, i) => (data[b] = value[isArrayDestructure ? i : b]));\n } else {\n data[valueExp] = value;\n }\n if (objKey) {\n indexExp && (data[indexExp] = objKey);\n objIndexExp && (data[objIndexExp] = index);\n } else {\n indexExp && (data[indexExp] = index);\n }\n\n const childCtx = createScopedContext(ctx, data);\n const key = keyExp ? evalGet(childCtx.scope, keyExp) : index;\n map.set(key, index);\n childCtx.key = key;\n return childCtx;\n };\n\n const mountBlock = (ctx: Context, ref: Node) => {\n const block = new Block({ element: el, parentContext: ctx, replacementType: \"replace\", component, componentProps, allProps });\n block.key = ctx.key;\n block.insert(parent, ref);\n return block;\n };\n\n ctx.effect(() => {\n const source = evalGet(ctx.scope, sourceExp);\n const prevKeyToIndexMap = keyToIndexMap;\n [childCtxs, keyToIndexMap] = createChildContexts(source);\n if (!mounted) {\n blocks = childCtxs.map((s) => mountBlock(s, anchor));\n mounted = true;\n } else {\n for (let i = 0; i < blocks.length; i++) {\n if (!keyToIndexMap.has(blocks[i].key)) {\n blocks[i].remove();\n }\n }\n\n const nextBlocks: Block[] = [];\n let i = childCtxs.length;\n let nextBlock: Block | undefined;\n let prevMovedBlock: Block | undefined;\n while (i--) {\n const childCtx = childCtxs[i];\n const oldIndex = prevKeyToIndexMap.get(childCtx.key);\n let block: Block;\n if (oldIndex == null) {\n // new\n block = mountBlock(childCtx, nextBlock ? nextBlock.element : anchor);\n } else {\n // update\n block = blocks[oldIndex];\n Object.assign(block.context.scope, childCtx.scope);\n if (oldIndex !== i) {\n // moved\n if (\n blocks[oldIndex + 1] !== nextBlock ||\n // If the next has moved, it must move too\n prevMovedBlock === nextBlock\n ) {\n prevMovedBlock = block;\n block.insert(parent, nextBlock ? nextBlock.element : anchor);\n }\n }\n }\n nextBlocks.unshift((nextBlock = block));\n }\n blocks = nextBlocks;\n }\n });\n\n return nextNode;\n};\n", "import { Block, Component, Context, evalGet } from \"..\";\nimport { checkAndRemoveAttribute } from \"../util\";\n\ninterface Branch {\n exp?: string | null;\n el: Element;\n}\n\nexport function _if(el: Element, exp: string, ctx: Context, component?: Component, componentProps?: Record, allProps?: Record) {\n const parent = el.parentElement!;\n const anchor = new Comment(\":if\");\n\n parent.insertBefore(anchor, el);\n\n const branches: Branch[] = [{ exp, el }];\n\n let elseEl: Element | null;\n let elseExp: string | null;\n\n while ((elseEl = el.nextElementSibling)) {\n elseExp = null;\n\n if (checkAndRemoveAttribute(elseEl, \":else\") === \"\" || (elseExp = checkAndRemoveAttribute(elseEl, \":else-if\"))) {\n parent.removeChild(elseEl);\n branches.push({ exp: elseExp, el: elseEl });\n } else {\n break;\n }\n }\n\n const nextNode = el.nextSibling;\n parent.removeChild(el);\n\n let block: Block | undefined;\n let activeBranchIndex = -1;\n\n const removeActiveBlock = () => {\n if (block) {\n parent.insertBefore(anchor, block.element);\n block.remove();\n block = undefined;\n }\n };\n\n ctx.effect(() => {\n for (let i = 0; i < branches.length; i++) {\n const { exp, el } = branches[i];\n\n if (!exp || evalGet(ctx.scope, exp)) {\n if (i !== activeBranchIndex) {\n removeActiveBlock();\n block = new Block({ element: el, parentContext: ctx, replacementType: \"replace\", component, componentProps, allProps });\n block.insert(parent, anchor);\n parent.removeChild(anchor);\n activeBranchIndex = i;\n }\n\n return;\n }\n }\n\n activeBranchIndex = -1;\n removeActiveBlock();\n });\n\n return nextNode;\n}\n", "import { Context, evalGet } from \"../\";\nimport { insertAfter, toDisplayString } from \"../util\";\n\ninterface InterpolationDirectiveOptions {\n element: Text;\n context: Context;\n}\n\nconst delims = /{{\\s?(.*?)\\s?}}/g;\n\nexport class InterpolationDirective {\n element: Text;\n context: Context;\n textNodes: Map = new Map();\n\n constructor({ element, context }: InterpolationDirectiveOptions) {\n this.element = element;\n this.context = context;\n\n this.findNodes();\n\n this.textNodes.forEach((nodes, expression) => {\n const trimmedExpression = expression.slice(2, -2).trim();\n\n nodes.forEach((node) => {\n const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, node);\n\n context.effect(() => {\n node.textContent = toDisplayString(getter());\n });\n });\n });\n }\n\n findNodes() {\n const textContent = this.element.textContent.trim();\n if (textContent?.match(delims)) {\n const textNodes = textContent.split(/(\\{\\{\\s?[^}]+\\s?\\}\\})/g).filter(Boolean);\n if (textNodes) {\n let previousNode = this.element;\n\n for (let i = 0; i < textNodes.length; i++) {\n const textNode = textNodes[i];\n\n if (textNode.match(/\\{\\{\\s?.+\\s?\\}\\}/)) {\n const newNode = document.createTextNode(textNode);\n\n if (i === 0) {\n this.element.replaceWith(newNode);\n } else {\n insertAfter(newNode, previousNode);\n }\n\n previousNode = newNode;\n\n if (this.textNodes.has(textNode)) {\n this.textNodes.get(textNode).push(newNode);\n } else {\n this.textNodes.set(textNode, [newNode]);\n }\n } else {\n const newNode = document.createTextNode(textNodes[i]);\n\n if (i === 0) {\n this.element.replaceWith(newNode);\n } else {\n insertAfter(newNode, previousNode);\n }\n\n previousNode = newNode;\n }\n }\n }\n }\n }\n\n update() {}\n}\n", "import { Context, evalGet } from \"..\";\n\ninterface ShowDirectiveOptions {\n element: Element;\n context: Context;\n expression: string;\n}\n\nexport class ShowDirective {\n element: Element;\n context: Context;\n expression: string;\n originalDisplay: string;\n\n constructor({ element, context, expression }: ShowDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = expression;\n this.originalDisplay = getComputedStyle(this.element).display;\n\n context.effect(this.update.bind(this));\n }\n\n update() {\n const shouldShow = Boolean(evalGet(this.context.scope, this.expression));\n // @ts-ignore\n this.element.style.display = shouldShow ? this.originalDisplay : \"none\";\n }\n}\n", "import { Block, Context } from \"..\";\nimport { nextTick } from \"../util\";\n\nexport function _teleport(el: Element, exp: string, ctx: Context) {\n const anchor = new Comment(\":teleport\");\n el.replaceWith(anchor);\n\n const target = document.querySelector(exp);\n if (!target) {\n console.warn(`teleport target not found: ${exp}`);\n return;\n }\n\n nextTick(() => {\n target.appendChild(el);\n\n const observer = new MutationObserver((mutationsList) => {\n mutationsList.forEach((mutation) => {\n mutation.removedNodes.forEach((removedNode) => {\n if (removedNode.contains(anchor)) {\n el.remove();\n observer.disconnect();\n }\n });\n });\n });\n\n observer.observe(document.body, { childList: true, subtree: true });\n\n // Walks the tree of this teleported element.\n new Block({\n element: el,\n parentContext: ctx,\n });\n });\n\n // Return the anchor so walk continues down the tree in the right order.\n return anchor;\n}\n", "import { Context, evalGet, evalSet } from \"..\";\n\ninterface ValueDirectiveOptions {\n element: Element;\n context: Context;\n expression: string;\n}\n\ntype SupportedModelType = \"text\" | \"checkbox\" | \"radio\" | \"number\" | \"password\" | \"color\";\n\nfunction isInput(element: Element): element is HTMLInputElement {\n return element instanceof HTMLInputElement;\n}\n\nfunction isTextarea(element: Element): element is HTMLTextAreaElement {\n return element instanceof HTMLTextAreaElement;\n}\n\nfunction isSelect(element: Element): element is HTMLSelectElement {\n return element instanceof HTMLSelectElement;\n}\n\nexport class ValueDirective {\n element: Element;\n context: Context;\n expression: string;\n inputType: SupportedModelType;\n\n constructor({ element, context, expression }: ValueDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = expression;\n this.inputType = element.getAttribute(\"type\") as SupportedModelType;\n\n // Element -> Context\n if (isInput(element)) {\n switch (this.inputType) {\n case \"text\":\n case \"password\":\n case \"number\":\n case \"color\":\n element.addEventListener(\"input\", () => {\n const value = this.inputType === \"number\" ? (element.value ? parseFloat(element.value) : 0) : element.value;\n evalSet(this.context.scope, expression, value);\n });\n break;\n\n case \"checkbox\":\n element.addEventListener(\"change\", (e: any) => {\n evalSet(this.context.scope, expression, !!e.currentTarget.checked);\n });\n break;\n case \"radio\":\n element.addEventListener(\"change\", (e: any) => {\n if (e.currentTarget.checked) {\n evalSet(this.context.scope, expression, element.getAttribute(\"value\"));\n }\n });\n break;\n default:\n break;\n }\n }\n\n if (isTextarea(element)) {\n element.addEventListener(\"input\", () => {\n evalSet(this.context.scope, expression, element.value);\n });\n }\n\n if (isSelect(element)) {\n element.addEventListener(\"change\", () => {\n evalSet(this.context.scope, expression, element.value);\n });\n }\n\n // Context -> Element\n context.effect(this.updateElementValue.bind(this));\n }\n\n updateElementValue() {\n const value = evalGet(this.context.scope, this.expression, this.element);\n\n if (isInput(this.element)) {\n switch (this.inputType) {\n case \"text\":\n case \"password\":\n case \"number\":\n case \"color\":\n this.element.value = value;\n break;\n case \"checkbox\":\n this.element.checked = !!value;\n break;\n case \"radio\":\n this.element.checked = this.element.value === value;\n break;\n default:\n break;\n }\n }\n\n if (isTextarea(this.element)) {\n this.element.value = value;\n }\n\n if (isSelect(this.element)) {\n this.element.value = value;\n }\n }\n}\n", "interface EffectOptions {\n lazy?: boolean;\n}\n\ninterface EffectFunction {\n active: boolean;\n handler: () => void;\n refs: Set[];\n}\n\ntype Effects = Set;\ntype EffectsMap = Map;\ntype TargetMap = WeakMap;\n\nconst targetMap: TargetMap = new WeakMap();\nconst effectStack: (EffectFunction | undefined)[] = [];\n\nexport function track(target: T, key: PropertyKey) {\n const activeEffect = effectStack[effectStack.length - 1];\n\n if (!activeEffect) return;\n\n let effectsMap = targetMap.get(target);\n if (!effectsMap)\n targetMap.set(target, (effectsMap = new Map() as EffectsMap));\n\n let effects = effectsMap.get(key);\n if (!effects) effectsMap.set(key, (effects = new Set()));\n\n if (!effects.has(activeEffect)) {\n effects.add(activeEffect);\n activeEffect.refs.push(effects);\n }\n}\n\nexport function trigger(target: any, key: PropertyKey) {\n const effectsMap = targetMap.get(target);\n if (!effectsMap) return;\n\n const scheduled = new Set();\n\n effectsMap.get(key)?.forEach((effect) => {\n scheduled.add(effect);\n });\n\n scheduled.forEach(run);\n}\n\nfunction stop(effect: EffectFunction) {\n if (effect.active) cleanup(effect);\n effect.active = false;\n}\n\nfunction start(effect: EffectFunction) {\n if (!effect.active) {\n effect.active = true;\n run(effect);\n }\n}\n\nfunction run(effect: EffectFunction): unknown {\n if (!effect.active) return;\n\n if (effectStack.includes(effect)) return;\n\n cleanup(effect);\n\n let val: unknown;\n\n try {\n effectStack.push(effect);\n val = effect.handler();\n } finally {\n effectStack.pop();\n }\n\n return val;\n}\n\nfunction cleanup(effect: EffectFunction) {\n const { refs } = effect;\n\n if (refs.length) {\n for (const ref of refs) {\n ref.delete(effect);\n }\n }\n\n refs.length = 0;\n}\n\nexport function effect(handler: () => void, opts: EffectOptions = {}) {\n const { lazy } = opts;\n const newEffect: EffectFunction = {\n active: !lazy,\n handler,\n refs: [],\n };\n\n run(newEffect);\n\n return {\n start: () => {\n start(newEffect);\n },\n stop: () => {\n stop(newEffect);\n },\n toggle: () => {\n if (newEffect.active) {\n stop(newEffect);\n } else {\n start(newEffect);\n }\n return newEffect.active;\n },\n };\n}\n", "import { isObject } from \"../util\";\nimport { effect } from \"./effect\";\n\nconst $computed = Symbol(\"computed\");\n\nexport type Computed = {\n readonly value: T;\n readonly [$computed]: true;\n};\n\nexport function isComputed(value: unknown): value is Computed {\n return isObject(value) && value[$computed];\n}\n\nexport function computed(getter: () => T): Computed {\n const ref = {\n get value(): T {\n return getter();\n },\n [$computed]: true,\n } as const;\n\n effect(() => {\n getter();\n });\n\n return ref;\n}\n", "import { isObject } from \"../util\";\nimport { track, trigger } from \"./effect\";\nimport { Reactive, reactive } from \"./reactive\";\n\nexport const $ref = Symbol(\"ref\");\n\nexport type Ref = {\n value: T;\n [$ref]: true;\n};\n\nexport function isRef(value: unknown): value is Ref {\n return isObject(value) && !!value[$ref];\n}\n\nexport function ref(value: T = null as unknown as T): Ref {\n if (isObject(value)) {\n // @ts-ignore\n return isRef(value) ? (value as Ref) : (reactive(value) as Reactive);\n }\n\n const result = { value, [$ref]: true };\n\n return new Proxy(result, {\n get(target: object, key: string | symbol, receiver: any) {\n const val = Reflect.get(target, key, receiver);\n track(result, \"value\");\n return val;\n },\n set(target: object, key: string | symbol, value: unknown) {\n const oldValue = target[key];\n if (oldValue !== value) {\n const success = Reflect.set(target, key, value);\n if (success) {\n trigger(result, \"value\");\n }\n }\n return true;\n },\n }) as Ref;\n}\n", "import { isObject } from \"../util\";\nimport { track, trigger } from \"./effect\";\nimport { ref } from \"./ref\";\n\nconst $reactive = Symbol(\"reactive\");\n\nexport type Reactive = T & { [$reactive]: true };\n\nexport function isReactive(\n value: unknown,\n): value is Reactive {\n return isObject(value) && !!value[$reactive];\n}\n\nexport function reactive(value: T): Reactive {\n // @ts-ignore\n if (!isObject(value)) return ref(value) as Reactive;\n if (value[$reactive]) return value as Reactive;\n\n value[$reactive] = true;\n\n Object.keys(value).forEach((key) => {\n if (isObject(value[key])) {\n value[key] = reactive(value[key]);\n }\n });\n\n return new Proxy(value, reactiveProxyHandler()) as Reactive;\n}\n\nfunction reactiveProxyHandler() {\n return {\n deleteProperty(target: object, key: string | symbol) {\n const had = Reflect.has(target, key);\n const result = Reflect.deleteProperty(target, key);\n if (had) trigger(target, key);\n return result;\n },\n get(target: object, key: string | symbol) {\n track(target, key);\n return Reflect.get(target, key);\n },\n set(target: object, key: string | symbol, value: unknown) {\n if (target[key] === value) return true;\n let newObj = false;\n\n if (isObject(value) && !isObject(target[key])) {\n newObj = true;\n }\n\n if (Reflect.set(target, key, value)) {\n trigger(target, key);\n }\n\n if (newObj) {\n target[key] = reactive(target[key]);\n }\n\n return true;\n },\n };\n}\n", "import { isComputed } from \"./computed\";\nimport { isRef } from \"./ref\";\n\nexport function unwrap(value: unknown) {\n if (isRef(value) || isComputed(value)) {\n return value.value;\n }\n\n if (typeof value === \"function\") {\n return value();\n }\n\n return value;\n}\n", "import { pathToRegexp } from \"path-to-regexp\";\nimport { Route, RouteExpression, RouteMatch } from \".\";\nimport { Plugin } from \"..\";\nimport { App, Block, Component, current } from \"../..\";\nimport { reactive } from \"../../reactivity/reactive\";\nimport { unwrap } from \"../../reactivity/unwrap\";\nimport { html } from \"../../util\";\n\nconst activeRouters = new Set();\n\nconst link = {\n template: html`\n \n LINK\n \n `,\n props: { href: { default: \"#\" } },\n main({ href }: { href: string }) {\n const go = (e: Event) => {\n e.preventDefault();\n\n activeRouters.forEach((router) => {\n router.doRouteChange(unwrap(href as unknown) as string);\n });\n };\n\n const classes = reactive({ \"router-link\": true });\n\n return { go, classes, href };\n },\n};\n\nasync function runEnterTransition(enter: () => boolean | Promise): Promise {\n return await enter();\n}\n\nconst canEnterRoute = async (route: Route) => {\n if (route.beforeEnter) {\n return await runEnterTransition(route.beforeEnter);\n }\n return true;\n};\n\nconst maybeRedirectRoute = (route: Route) => {\n if (route.redirectTo) {\n activeRouters.forEach((plugin) => plugin.doRouteChange(route.redirectTo));\n }\n};\n\nexport class RouterPlugin implements Plugin {\n app: App;\n routes: Route[] = [];\n pathExpressions = new Map();\n lastPath = \"/\";\n knownRouterViews = new Map();\n knownRouterViewNames = new Map();\n populatedRouterViews = new Map();\n\n constructor(routes: Route[] = []) {\n this.routes = routes;\n }\n\n use(app: App, ...config: any[]) {\n this.app = app;\n this.app.register(\"router-link\", link);\n\n window.addEventListener(\"popstate\", this.onHistoryEvent.bind(this));\n window.addEventListener(\"pushstate\", this.onHistoryEvent.bind(this));\n window.addEventListener(\"load\", this.onHistoryEvent.bind(this));\n\n for (const route of this.routes) {\n this.cacheRouteExpression(route);\n }\n\n this.lastPath = `${location.pathname}${location.search}`;\n window.history.replaceState({}, \"\", this.lastPath);\n\n activeRouters.add(this);\n }\n\n compile(element: Element) {\n if (element.nodeType === Node.ELEMENT_NODE && element.nodeName === \"ROUTER-VIEW\" && !this.knownRouterViews.has(element) && current.componentBlock) {\n this.knownRouterViews.set(element, current.componentBlock);\n this.knownRouterViewNames.set(element.getAttribute(\"name\")?.trim() || \"\", element);\n }\n }\n\n onHistoryEvent(e: PopStateEvent | Event) {\n e.preventDefault();\n e.stopImmediatePropagation();\n\n // @ts-ignore\n const path = new URL(e.currentTarget.location.href).pathname;\n\n if (e.type === \"load\") {\n window.history.replaceState({}, \"\", this.lastPath);\n } else if (e.type === \"pushstate\") {\n window.history.replaceState({}, \"\", path);\n } else if (e.type === \"popstate\") {\n window.history.replaceState({}, \"\", path);\n }\n\n this.lastPath = path;\n\n const matches = this.getMatchesForURL(path);\n this.applyMatches(matches);\n }\n\n doRouteChange(to: string) {\n window.history.pushState({}, \"\", to);\n const matches = this.getMatchesForURL(`${location.pathname}${location.search}`);\n this.applyMatches(matches);\n }\n\n getMatchesForURL(url: string): RouteMatch[] {\n let matches: RouteMatch[] = [];\n\n const matchRoutes = (routes: Route[], parentPath: string = \"\", previousParents = []): RouteMatch[] => {\n let parents = [];\n\n for (const route of routes) {\n parents.push(route);\n const path = `${parentPath}${route.path}`.replace(/\\/\\//g, \"/\");\n const match = this.getPathMatch(path, url);\n if (match) matches.push({ match, parents: [...previousParents, ...parents] });\n if (route.children?.length) {\n matchRoutes(route.children, path, [...previousParents, ...parents]);\n parents = [];\n }\n }\n\n return matches;\n };\n matches = matchRoutes(this.routes);\n return matches;\n }\n\n /**\n * getRouteExpression takes a path like \"/users/:id\" and returns a regex\n * and an array of params that match the path.\n * \"/users/:id\" => { regex: /^\\/users\\/([^\\/]+)\\?jwt=(\\w)$/, params: [\"id\"], query: [\"jwt\"] }\n */\n getRouteExpression(path: string, route: Route): RouteExpression {\n if (this.pathExpressions.has(path)) return this.pathExpressions.get(path);\n\n const params = [];\n const regex = pathToRegexp(path, params, { strict: false, sensitive: false, end: true });\n const expression = { regex, params, path, route };\n this.pathExpressions.set(path, expression);\n return expression;\n }\n\n /**\n *\n * @param path A path like /foo/bar/:id\n * @param url A url like /foo/bar/1234\n * @returns A RouteExpression if the URL matches the regex cached for @param path, null otherwise.\n */\n getPathMatch(path: string, url: string): RouteExpression | null {\n if (this.pathExpressions.get(path)) {\n const match = this.pathExpressions.get(path).regex.exec(url);\n if (match) {\n return this.pathExpressions.get(path);\n }\n }\n\n return null;\n }\n\n async applyMatches(matches: RouteMatch[] | null) {\n if (!matches) return;\n\n const usedRouterViews = new Set();\n\n const renderRoutes = async (routeChain: Route[], rootNode?: Element) => {\n for (const route of routeChain) {\n if (route.view) {\n const viewNode = this.knownRouterViewNames.get(route.view);\n if (viewNode && (await canEnterAndRenderRoute(viewNode, route))) {\n continue;\n }\n } else if (rootNode && (await canEnterAndRenderRoute(rootNode, route))) {\n continue;\n }\n }\n };\n\n const canEnterAndRenderRoute = async (node: Element, route: Route) => {\n const canEnter = await canEnterRoute(route);\n if (canEnter) {\n renderRouteAtNode(node, route);\n return true;\n } else {\n if (route.componentFallback) {\n renderRouteAtNode(node, route, route.componentFallback);\n } else {\n maybeRedirectRoute(route);\n }\n\n return false;\n }\n };\n\n const renderRouteAtNode = (node: Element, route: Route, component?: Component) => {\n if (!usedRouterViews.has(node) || this.populatedRouterViews.get(node)?.route !== route) {\n const div = document.createElement(\"div\");\n node.replaceChildren(div);\n\n const target = div.parentElement;\n\n const block = new Block({\n element: div,\n component: component ? component : route.component,\n replacementType: \"replaceChildren\",\n parentContext: current.componentBlock.context,\n });\n\n target.replaceChild(block.element, div);\n\n this.populatedRouterViews.set(node, { block, route });\n\n usedRouterViews.add(node);\n }\n };\n\n for (const match of matches) {\n const routeChain = [...match.parents, match.match.route];\n const uniqueRouteChain = routeChain.filter((route, index, self) => index === self.findIndex((r) => r.path === route.path));\n const rootNode = this.knownRouterViewNames.get(\"\") ?? null;\n await renderRoutes(uniqueRouteChain, rootNode);\n }\n\n // Clean up stale views\n for (const node of this.knownRouterViews.keys()) {\n if (!usedRouterViews.has(node) && this.populatedRouterViews.has(node)) {\n const entry = this.populatedRouterViews.get(node);\n if (entry) {\n entry.block.teardown();\n this.populatedRouterViews.delete(node);\n }\n }\n }\n }\n\n cacheRouteExpression(route: Route, parentPath: string = \"\") {\n const path = `${parentPath}${route.path}`.replace(/\\/\\//g, \"/\");\n this.getRouteExpression(path, route);\n if (route.children?.length) {\n route.children.forEach((child) => {\n this.cacheRouteExpression(child, path);\n });\n }\n }\n\n destroy() {\n window.removeEventListener(\"popstate\", this.onHistoryEvent.bind(this));\n window.removeEventListener(\"pushstate\", this.onHistoryEvent.bind(this));\n window.removeEventListener(\"load\", this.onHistoryEvent.bind(this));\n }\n}\n", "import { AttributeDirective } from \"./directives/attribute\";\nimport { EventDirective } from \"./directives/event\";\nimport { _for } from \"./directives/for\";\nimport { _if } from \"./directives/if\";\nimport { InterpolationDirective } from \"./directives/interpolation\";\nimport { ShowDirective } from \"./directives/show\";\nimport { _teleport } from \"./directives/teleport\";\nimport { ValueDirective } from \"./directives/value\";\nimport { Plugin } from \"./plugins\";\nimport { isComputed } from \"./reactivity/computed\";\nimport { effect as _effect } from \"./reactivity/effect\";\nimport { reactive } from \"./reactivity/reactive\";\nimport { isRef } from \"./reactivity/ref\";\nimport { checkAndRemoveAttribute, componentHasPropByName, extractPropName, findSlotNodes, findTemplateNodes, isElement, isEventAttribute, isMirrorProp, isObject, isPropAttribute, isRegularProp, isSpreadProp, isText, Slot, stringToElement, Template, toDisplayString } from \"./util\";\n\nexport * from \"./plugins\";\nexport * from \"./plugins/router\";\n\nexport function provide(key: string, value: unknown) {\n if (!current.componentBlock) {\n console.warn(\"Can't provide: no current component block\");\n }\n\n current.componentBlock.provides.set(key, value);\n}\n\nexport function inject(key: string) {\n if (!current.componentBlock) {\n console.warn(\"Can't inject: no current component block\");\n }\n\n let c = current.componentBlock;\n\n while (c) {\n if (c.provides.has(key)) {\n return c.provides.get(key);\n }\n\n c = c.parentComponentBlock;\n }\n\n return undefined;\n}\n\nexport class App {\n rootBlock: Block;\n registry = new Map();\n plugins = new Set();\n\n register(name: string, component: Component) {\n this.registry.set(name, component);\n }\n\n use(plugin: Plugin, ...config: any[]) {\n this.plugins.add(plugin);\n plugin.use(this, ...config);\n }\n\n getComponent(tag: string) {\n return this.registry.get(tag);\n }\n\n mount(component: Component, target: string | HTMLElement = \"body\", props: Record = {}) {\n const root = typeof target === \"string\" ? (document.querySelector(target) as HTMLElement) : target;\n const display = root.style.display;\n root.style.display = \"none\";\n this.rootBlock = this._mount(component, root, props, true);\n root.style.display = display;\n return this.rootBlock;\n }\n\n private _mount(component: Component, target: HTMLElement, props: Record, isRoot = false) {\n const parentContext = createContext({ app: this });\n\n if (props) {\n parentContext.scope = reactive(props);\n bindContextMethods(parentContext.scope);\n }\n\n parentContext.scope.$isRef = isRef;\n parentContext.scope.$isComputed = isComputed;\n\n const block = new Block({\n element: target,\n parentContext,\n component,\n isRoot,\n componentProps: props,\n replacementType: \"replaceChildren\",\n });\n\n return block;\n }\n\n unmount() {\n this.rootBlock.teardown();\n }\n}\n\nexport interface Context {\n key?: any;\n app: App;\n scope: Record;\n blocks: Block[];\n effects: Array>;\n effect: typeof _effect;\n slots: Slot[];\n templates: Template[];\n}\n\ninterface CreateContextOptions {\n parentContext?: Context;\n app?: App;\n}\n\nexport function createContext({ parentContext, app }: CreateContextOptions): Context {\n const context: Context = {\n app: app ? app : parentContext && parentContext.app ? parentContext.app : null,\n // scope: parentContext ? parentContext.scope : reactive({}),\n scope: reactive({}),\n blocks: [],\n effects: [],\n slots: [],\n templates: parentContext ? parentContext.templates : [],\n effect: (handler: () => void) => {\n const e = _effect(handler);\n context.effects.push(e);\n return e;\n },\n };\n\n return context;\n}\n\nexport const createScopedContext = (ctx: Context, data = {}): Context => {\n const parentScope = ctx.scope;\n const mergedScope = Object.create(parentScope);\n Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));\n let proxy: any;\n proxy = reactive(\n new Proxy(mergedScope, {\n set(target, key, val, receiver) {\n // when setting a property that doesn't exist on current scope,\n // do not create it on the current scope and fallback to parent scope.\n if (receiver === proxy && !target.hasOwnProperty(key)) {\n return Reflect.set(parentScope, key, val);\n }\n return Reflect.set(target, key, val, receiver);\n },\n }),\n );\n\n bindContextMethods(proxy);\n\n const out: Context = {\n ...ctx,\n scope: {\n ...ctx.scope,\n ...proxy,\n },\n };\n\n return out;\n};\n\nfunction bindContextMethods(scope: Record) {\n for (const key of Object.keys(scope)) {\n if (typeof scope[key] === \"function\") {\n scope[key] = scope[key].bind(scope);\n }\n }\n}\n\nfunction mergeProps(props: Record, defaultProps: Record) {\n const merged = {};\n\n Object.keys(defaultProps).forEach((defaultProp) => {\n const propValue = props.hasOwnProperty(defaultProp) ? props[defaultProp] : defaultProps[defaultProp]?.default;\n\n merged[defaultProp] = reactive(typeof propValue === \"function\" ? propValue() : propValue);\n });\n\n return merged;\n}\n\nexport interface Component {\n template: string;\n props?: Record;\n main?: (props?: Record) => Record | void;\n}\n\ninterface Current {\n componentBlock?: Block;\n}\n\nexport const current: Current = { componentBlock: undefined };\n\ninterface BlockOptions {\n element: Element;\n isRoot?: boolean;\n replacementType?: \"replace\" | \"replaceChildren\";\n componentProps?: Record;\n allProps?: Record;\n parentContext?: Context;\n component?: Component;\n parentComponentBlock?: Block;\n templates?: Template[];\n}\n\nexport class Block {\n element: Element;\n context: Context;\n parentContext: Context;\n component: Component;\n provides = new Map();\n parentComponentBlock: Block | undefined;\n componentProps: Record;\n allProps: Record;\n\n isFragment: boolean;\n start?: Text;\n end?: Text;\n key?: any;\n\n constructor(opts: BlockOptions) {\n this.isFragment = opts.element instanceof HTMLTemplateElement;\n this.parentComponentBlock = opts.parentComponentBlock;\n\n if (opts.component) {\n current.componentBlock = this;\n this.element = stringToElement(opts.component.template);\n } else {\n if (this.isFragment) {\n this.element = (opts.element as HTMLTemplateElement).content.cloneNode(true) as Element;\n } else if (typeof opts.element === \"string\") {\n this.element = stringToElement(opts.element);\n } else {\n this.element = opts.element.cloneNode(true) as Element;\n opts.element.replaceWith(this.element);\n }\n }\n\n if (opts.isRoot) {\n this.context = opts.parentContext;\n } else {\n this.parentContext = opts.parentContext ? opts.parentContext : createContext({});\n this.parentContext.blocks.push(this);\n this.context = createContext({ parentContext: opts.parentContext });\n }\n\n if (opts.component) {\n this.componentProps = mergeProps(opts.componentProps ?? {}, opts.component.props ?? {});\n\n if (opts.component.main) {\n this.context.scope = {\n ...(opts.component.main(this.componentProps) || {}),\n };\n }\n }\n\n opts.allProps?.forEach((prop) => {\n if (prop.isBind) {\n this.context.effect(() => {\n let newValue: unknown;\n\n if (prop.isSpread) {\n const spreadProps = evalGet(this.parentContext.scope, prop.extractedName);\n if (isObject(spreadProps)) {\n Object.keys(spreadProps).forEach((key) => {\n newValue = spreadProps[key];\n this.setProp(key, newValue);\n });\n }\n } else {\n newValue = prop.isMirror ? evalGet(this.parentContext.scope, prop.extractedName) : evalGet(this.parentContext.scope, prop.exp);\n this.setProp(prop.extractedName, newValue);\n }\n });\n }\n });\n\n // Capture slots\n this.context.slots = findSlotNodes(this.element);\n this.context.templates = opts.templates ?? [];\n\n // Put templates into slots\n this.context.slots.forEach((slot) => {\n const template = this.context.templates.find((t) => t.targetSlotName === slot.name);\n\n if (template) {\n const templateContents = template.node.content.cloneNode(true);\n slot.node.replaceWith(templateContents);\n }\n });\n\n this.context.scope.$isRef = isRef;\n this.context.scope.$isComputed = isComputed;\n\n walk(this.element, this.context);\n\n if (opts.component) {\n if (opts.replacementType === \"replace\") {\n if (opts.element instanceof HTMLElement) {\n opts.element.replaceWith(this.element);\n }\n } else {\n if (opts.element instanceof HTMLElement) {\n opts.element.replaceChildren(this.element);\n }\n }\n }\n }\n\n setProp(name: string, value: unknown) {\n if (isRef(this.componentProps[name])) {\n this.componentProps[name].value = value;\n } else {\n this.componentProps[name] = value;\n }\n }\n\n insert(parent: Element, anchor: Node | null = null) {\n if (this.isFragment) {\n if (this.start) {\n // Already inserted, moving\n let node: Node | null = this.start;\n let next: Node | null;\n\n while (node) {\n next = node.nextSibling;\n parent.insertBefore(node, anchor);\n\n if (node === this.end) {\n break;\n }\n\n node = next;\n }\n } else {\n this.start = new Text(\"\");\n this.end = new Text(\"\");\n\n parent.insertBefore(this.end, anchor);\n parent.insertBefore(this.start, this.end);\n parent.insertBefore(this.element, this.end);\n }\n } else {\n parent.insertBefore(this.element, anchor);\n }\n }\n\n remove() {\n if (this.parentContext) {\n const i = this.parentContext.blocks.indexOf(this);\n\n if (i > -1) {\n this.parentContext.blocks.splice(i, 1);\n }\n }\n\n if (this.start) {\n const parent = this.start.parentNode!;\n let node: Node | null = this.start;\n let next: Node | null;\n\n while (node) {\n next = node.nextSibling;\n parent.removeChild(node);\n\n if (node === this.end) {\n break;\n }\n\n node = next;\n }\n } else {\n // this.element.parentNode!.removeChild(this.element);\n this.element.remove();\n }\n\n this.teardown();\n }\n\n teardown() {\n this.context.blocks.forEach((block) => {\n block.teardown();\n });\n\n this.context.effects.forEach(stop);\n }\n}\n\nfunction isComponent(element: Element, context: Context) {\n return !!context.app.getComponent(element.tagName.toLowerCase());\n}\n\nfunction warnInvalidDirectives(node: Element, directives: string[]): boolean {\n if (directives.every((d) => node.hasAttribute(d))) {\n console.warn(`These directives cannot be used together on the same node:`, directives);\n console.warn(\"Node ignored:\", node);\n return true;\n }\n\n return false;\n}\n\nfunction walk(node: Node, context: Context) {\n if (isText(node)) {\n new InterpolationDirective({ element: node, context });\n return;\n }\n\n if (isElement(node)) {\n let exp: string | null;\n\n const handleDirectives = (node: Element, context: Context, component?: Component, componentProps?: Record, allProps?: any[]) => {\n if (warnInvalidDirectives(node, [\":if\", \":for\"])) return;\n if (warnInvalidDirectives(node, [\":if\", \":teleport\"])) return;\n if (warnInvalidDirectives(node, [\":for\", \":teleport\"])) return;\n\n // e.g.
\n // In this case, the scope is merged into context.scope and will overwrite\n // anything returned from `main`.\n if ((exp = checkAndRemoveAttribute(node, \":scope\"))) {\n const scope = evalGet(context.scope, exp);\n if (typeof scope === \"object\") {\n Object.assign(context.scope, scope);\n // context = createScopedContext(context, scope);\n }\n }\n\n if ((exp = checkAndRemoveAttribute(node, \":teleport\"))) {\n return _teleport(node, exp, context);\n }\n if ((exp = checkAndRemoveAttribute(node, \":if\"))) {\n return _if(node, exp, context, component, componentProps, allProps);\n }\n if ((exp = checkAndRemoveAttribute(node, \":for\"))) {\n return _for(node, exp, context, component, componentProps, allProps);\n }\n if ((exp = checkAndRemoveAttribute(node, \":show\"))) {\n new ShowDirective({ element: node, context, expression: exp });\n }\n if ((exp = checkAndRemoveAttribute(node, \":ref\"))) {\n context.scope[exp].value = node;\n }\n if ((exp = checkAndRemoveAttribute(node, \":value\"))) {\n new ValueDirective({ element: node, context, expression: exp });\n }\n if ((exp = checkAndRemoveAttribute(node, \":html\"))) {\n context.effect(() => {\n const result = evalGet(context.scope, exp);\n if (result instanceof Element) {\n node.replaceChildren();\n node.append(result);\n } else {\n node.innerHTML = result;\n }\n });\n }\n if ((exp = checkAndRemoveAttribute(node, \":text\"))) {\n context.effect(() => {\n node.textContent = toDisplayString(evalGet(context.scope, exp));\n });\n }\n };\n\n const processAttributes = (node: Element, component?: Component) => {\n return Array.from(node.attributes)\n .filter((attr) => isSpreadProp(attr.name) || isMirrorProp(attr.name) || (isRegularProp(attr.name) && componentHasPropByName(extractPropName(attr.name), component)))\n .map((attr) => ({\n isMirror: isMirrorProp(attr.name),\n isSpread: isSpreadProp(attr.name),\n isBind: attr.name.includes(\"bind\"),\n originalName: attr.name,\n extractedName: extractPropName(attr.name),\n exp: attr.value,\n value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name)) : attr.value ? evalGet(context.scope, attr.value) : undefined,\n }));\n };\n\n if (isComponent(node, context)) {\n const component = context.app.getComponent(node.tagName.toLowerCase());\n const allProps = processAttributes(node, component);\n\n const componentProps = allProps.reduce((acc, { isSpread, isMirror, extractedName, value }) => {\n if (isSpread) {\n const spread = evalGet(context.scope, extractedName);\n if (isObject(spread)) Object.assign(acc, spread);\n } else if (isMirror) {\n acc[extractedName] = evalGet(context.scope, extractedName);\n } else {\n acc[extractedName] = value;\n }\n return acc;\n }, {});\n\n const next = handleDirectives(node, context, component, componentProps, allProps);\n if (next) return next;\n\n const templates = findTemplateNodes(node);\n\n return new Block({\n element: node,\n parentContext: context,\n component,\n replacementType: \"replace\",\n parentComponentBlock: current.componentBlock,\n templates,\n componentProps,\n allProps,\n }).element;\n }\n\n const next = handleDirectives(node, context);\n if (next) return next;\n\n Array.from(node.attributes).forEach((attr) => {\n if (isPropAttribute(attr.name)) {\n new AttributeDirective({ element: node, context, attr });\n }\n\n if (isEventAttribute(attr.name)) {\n new EventDirective({ element: node, context, attr });\n }\n });\n\n walkChildren(node, context);\n }\n}\n\nfunction walkChildren(node: Node, context: Context) {\n let child = node.firstChild;\n\n while (child) {\n child = walk(child, context) || child.nextSibling;\n }\n}\n\nconst evalFuncCache: Record = {};\n\nexport function evalGet(scope: any, exp: string, el?: Node) {\n if (!exp.trim()) return undefined;\n return execute(scope, `const ___value = (${exp.trim()}); return ___value;`, el);\n}\n\nexport function evalSet(scope: any, exp: string, value: unknown) {\n value = typeof value === \"string\" ? `\"${value}\"` : value;\n return execute(scope, `const ___target = (${exp.trim()}); return $isRef(___target) ? ___target.value = ${value} : ___target = ${value};`, null, false);\n}\n\nfunction execute(scope: any, exp: string, el?: Node, flatRefs = true) {\n const newScope = flatRefs ? flattenRefs(scope) : scope;\n const fn = evalFuncCache[exp] || (evalFuncCache[exp] = toFunction(exp));\n\n try {\n return fn(newScope, el);\n } catch (e) {\n console.warn(`Error evaluating expression: \"${exp}\":`);\n console.error(e);\n }\n}\n\n// Function to convert expression strings to functions\nfunction toFunction(exp: string) {\n try {\n return new Function(\"$data\", \"$el\", `with($data){${exp}}`);\n } catch (e) {\n console.error(`${(e as Error).message} in expression: ${exp}`);\n return () => {};\n }\n}\n\n// Map all ref properties in scope to their `.value`\nfunction flattenRefs(scope: any): any {\n const mapped = {};\n\n for (const key in scope) {\n if (scope.hasOwnProperty(key)) {\n // Check if the value is a Ref\n if (isRef(scope[key])) {\n mapped[key] = scope[key].value;\n } else {\n mapped[key] = scope[key];\n }\n }\n }\n return mapped;\n}\n", "import { App } from \".\";\nimport { ref } from \"./reactivity/ref\";\nimport { html } from \"./util\";\n\n// ------------------------------------------------\n// Slots, multiple default and named, :if and :for\n// const card = {\n// template: html`
\n//

\n// \n//
`,\n// };\n\n// const main = {\n// template: html`\n//
\n//

card below

\n// \n// card title\n// \n// \n//
\n// `,\n// };\n\n// const app = new App();\n// app.register(\"card\", card);\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// Slots, multiple default and named, :if and :for\n// const app = new App();\n\n// const parent = {\n// template: html`\n//
\n//

parent

\n// \n// \n//
\n//
\n//
1
\n//
2
\n//
3
\n//
\n//
\n// content 1 always shown\n//
\n// content 2, animals:\n//
animal: {{animal}}
\n//
\n\n// \n// \n//
\n//
\n// `,\n// main() {\n// const bool = ref(true);\n// const animals = reactive([\"dog\", \"cat\", \"bear\"]);\n\n// setInterval(() => {\n// bool.value = !bool.value;\n// }, 2000);\n\n// return { bool, animals };\n// },\n// };\n// const card = {\n// template: html`
\n//

card

\n//

\n// \n//
`,\n// };\n// app.register(\"card\", card);\n// const parentBlock = app.mount(parent, \"body\");\n// const cardBlock = parentBlock.context.blocks[0];\n\n// ------------------------------------------------\n// Component pros, mirror and spread, bind and no bind\n// const child = {\n// template: html`
Animal: {{animal}} {{index}}
`,\n// props: { animal: { default: \"cat\" }, index: { default: 0 } },\n// main({ animal, index }) {\n// return { animal, index };\n// },\n// };\n\n// const parent = {\n// template: html`\n//
\n// \n// mirror, no bind:\n// \n//
\n// mirror, bind:\n// \n//
\n// spread, no bind:\n// \n//
\n// spread, bind:\n// \n//
\n// regular prop:\n// \n//
\n// regular prop, bind:\n// \n//
\n//
div has \"id\" set to animal.value
\n//
\n//
div has \"id\" set and bound to animal.value
\n//
\n//
div has \"animal\" set to animal.value
\n//
\n//
div has \"animal\" set and bound to animal.value
\n//
\n//
div has \"animal\" spread
\n//
\n//
div has \"animal\" spread and bound
\n//
\n//
\n//
\n//
\n// if bool, mirror, no bind:\n// \n// if bool, mirror, bind:\n// \n//
\n// for list, mirror, no bind:\n// \n//
\n// for list, mirror, bind:\n// \n// if bool, for list, mirror, no bind: these have the value \"DOG!\" because by the time for :for directive is evaluated, animal.value is \"DOG!\", and no longer \"dog\".\n//
\n// \n//
\n//
\n// `,\n// main() {\n// const bool = ref(false);\n// const animal = ref(\"dog\");\n// const spread = reactive({ animal: \"panther\" });\n// const list = reactive([1, 2, 3]);\n\n// setTimeout(() => {\n// spread.animal = \"PANTHER!\";\n// animal.value = \"DOG!\";\n// bool.value = true;\n// }, 500);\n\n// setTimeout(() => {\n// animal.value = \"DOG!!!!!\";\n// }, 1000);\n\n// return { animal, spread, bool, list };\n// },\n// };\n\n// const app = new App();\n// app.register(\"child\", child);\n// app.mount(parent, \"#app\");\n\n// ------------------------------------------------\n// Event directive\n// const counter = {\n// template: html`\n//
\n//
true
\n//

Count: {{count}}{{count >= 2 ? '!!!' : ''}}

\n// \n// \n//
\n// `,\n// main() {\n// const count = ref(0);\n// const style = reactive({ color: \"gray\" });\n// const increment = () => count.value++;\n// const decrement = () => count.value--;\n\n// setInterval(() => {\n// style.color = style.color === \"gray\" ? \"white\" : \"gray\";\n// }, 500);\n\n// return { count, increment, decrement, style };\n// },\n// };\n\n// const app = new App();\n// app.mount(counter, \"#app\");\n\n// ------------------------------------------------\n// Template\n// const main = {\n// template: html`\n//
\n//
\n//
{{item}}
\n//
\n//
\n// `,\n// main() {\n// const items = reactive([1, 2, 3, 4, 5]);\n// const bool = ref(true);\n// setInterval(() => (bool.value = !bool.value), 250);\n// return { items, bool };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// :html\n// const main = {\n// template: html`
`,\n// main() {\n// const html = ref(\"

hello

\");\n\n// setTimeout(() => {\n// if (html.value === \"

hello

\") {\n// html.value = \"

world

\";\n// }\n// }, 1000);\n\n// return { html };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// Colors from css framework\n// const main = {\n// template: html`\n//
\n//

Colors

\n// \n//
\n//
\n//
{{variant}}-{{rank}}
\n//
\n//
\n//
\n//
\n// `,\n// main() {\n// const ranks = reactive([\"5\", \"10\", \"20\", \"30\", \"40\", \"50\", \"60\", \"70\", \"80\", \"90\"]);\n// const basesReverse = computed(() => Array.from(ranks).reverse());\n// const bg = (variant: string, rank: string, index: number) => ({ backgroundColor: `var(--${variant}-${rank})`, color: `var(--${variant}-${basesReverse.value[index]})` });\n\n// return { ranks, bg };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// :scope\nconst child = {\n template: html`\n
\n hello from child, food: \"{{food}}\" (does not inherit)\n
\n \n
\n
\n `,\n main() {\n const food = ref(\"\uD83C\uDF54\");\n return { food };\n },\n};\n\nconst main = {\n template: html`\n
\n
\n \n
Scoped data: {{food}}
\n Child slot, food: {{food}}\n
No pizza \uD83D\uDE22
\n
Pizza!
\n
\n
\n `,\n main() {\n return { food: ref(\"nothing\") };\n },\n};\n\nconst app = new App();\napp.register(\"child\", child);\napp.mount(main, \"#app\");\n"], - "mappings": ";AAEO,SAAS,gBAAgB,UAA2B;AACzD,QAAM,SAAS,IAAI,UAAU;AAC7B,QAAM,MAAM,OAAO,gBAAgB,UAAU,WAAW;AACxD,SAAO,IAAI,KAAK;AAClB;AAEO,IAAM,SAAS,CAAC,SAA6B;AAClD,SAAO,KAAK,aAAa,KAAK;AAChC;AAEO,IAAM,aAAa,CAAC,SAA4C;AACrE,SAAO,KAAK,aAAa;AAC3B;AAEO,IAAM,YAAY,CAAC,SAAgC;AACxD,SAAO,KAAK,aAAa,KAAK;AAChC;AAEO,SAAS,SAAS,OAA6B;AACpD,SAAO,UAAU,QAAQ,OAAO,UAAU;AAC5C;AAEO,SAAS,QAAQ,OAA4B;AAClD,SAAO,MAAM,QAAQ,KAAK;AAC5B;AAEO,SAAS,wBAAwB,IAAa,UAAiC;AAEpF,QAAM,iBAAiB,GAAG,aAAa,QAAQ;AAG/C,MAAI,mBAAmB,MAAM;AAC3B,OAAG,gBAAgB,QAAQ;AAAA,EAC7B;AAGA,SAAO;AACT;AAYO,SAAS,cAAc,SAA0B;AACtD,QAAM,QAAgB,CAAC;AAEvB,QAAM,YAAY,CAAC,SAAkB;AACnC,UAAM,KAAK,KAAK,UAAU,EAAE,QAAQ,CAACA,UAAS;AAC5C,UAAI,UAAUA,KAAI,GAAG;AACnB,YAAIA,MAAK,aAAa,QAAQ;AAC5B,gBAAM,KAAK,EAAE,MAAAA,OAAM,MAAMA,MAAK,aAAa,MAAM,KAAK,UAAU,CAA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AAG;AACV,YAAQ,MAAM,GAAI,EAAY,OAAO,mBAAmB,GAAG,EAAE;AAC7D,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACF;AAGA,SAAS,YAAY,OAAiB;AACpC,QAAM,SAAS,CAAC;AAEhB,aAAW,OAAO,OAAO;AACvB,QAAI,MAAM,eAAe,GAAG,GAAG;AAE7B,UAAI,MAAM,MAAM,GAAG,CAAC,GAAG;AACrB,eAAO,GAAG,IAAI,MAAM,GAAG,EAAE;AAAA,MAC3B,OAAO;AACL,eAAO,GAAG,IAAI,MAAM,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ACpUA,IAAM,QAAQ;AAAA,EACZ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQV,OAAO;AACL,UAAM,OAAO,IAAI,WAAI;AACrB,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;AAEA,IAAM,OAAO;AAAA,EACX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWV,OAAO;AACL,WAAO,EAAE,MAAM,IAAI,SAAS,EAAE;AAAA,EAChC;AACF;AAEA,IAAM,MAAM,IAAIC,KAAI;AACpB,IAAI,SAAS,SAAS,KAAK;AAC3B,IAAI,MAAM,MAAM,MAAM;", + "sourcesContent": ["import { Component } from \".\";\n\nexport function stringToElement(template: string): Element {\n const parser = new DOMParser();\n const doc = parser.parseFromString(template, \"text/html\");\n return doc.body.firstChild as Element;\n}\n\nexport const isText = (node: Node): node is Text => {\n return node.nodeType === Node.TEXT_NODE;\n};\n\nexport const isTemplate = (node: Node): node is HTMLTemplateElement => {\n return node.nodeName === \"TEMPLATE\";\n};\n\nexport const isElement = (node: Node): node is Element => {\n return node.nodeType === Node.ELEMENT_NODE;\n};\n\nexport function isObject(value: any): value is object {\n return value !== null && typeof value === \"object\";\n}\n\nexport function isArray(value: any): value is any[] {\n return Array.isArray(value);\n}\n\nexport function checkAndRemoveAttribute(el: Element, attrName: string): string | null {\n // Attempt to get the attribute value\n const attributeValue = el.getAttribute(attrName);\n\n // If attribute exists, remove it from the element\n if (attributeValue !== null) {\n el.removeAttribute(attrName);\n }\n\n // Return the value of the attribute or null if not present\n return attributeValue;\n}\n\nexport interface Slot {\n node: Element;\n name: string;\n}\n\nexport interface Template {\n targetSlotName: string;\n node: HTMLTemplateElement;\n}\n\nexport function findSlotNodes(element: Element): Slot[] {\n const slots: Slot[] = [];\n\n const findSlots = (node: Element) => {\n Array.from(node.childNodes).forEach((node) => {\n if (isElement(node)) {\n if (node.nodeName === \"SLOT\") {\n slots.push({ node, name: node.getAttribute(\"name\") || \"default\" });\n }\n\n if (node.hasChildNodes()) {\n findSlots(node);\n }\n }\n });\n };\n\n findSlots(element);\n\n return slots;\n}\n\nexport function findTemplateNodes(element: Element) {\n const templates: Template[] = [];\n\n const findTemplates = (element: Element) => {\n let defaultContentNodes: Node[] = [];\n\n Array.from(element.childNodes).forEach((node) => {\n if (isElement(node) || isText(node)) {\n if (isElement(node) && node.nodeName === \"TEMPLATE\" && isTemplate(node)) {\n templates.push({ targetSlotName: node.getAttribute(\"slot\") || \"\", node });\n } else {\n // Capture non-template top-level nodes and text nodes for default slot\n defaultContentNodes.push(node);\n }\n }\n });\n\n if (defaultContentNodes.length > 0) {\n // Create a template element with a default slot\n const defaultTemplate = document.createElement(\"template\");\n defaultTemplate.setAttribute(\"slot\", \"default\");\n\n defaultContentNodes.forEach((node) => {\n defaultTemplate.content.appendChild(node);\n });\n\n templates.push({ targetSlotName: \"default\", node: defaultTemplate });\n }\n };\n\n findTemplates(element);\n\n return templates;\n}\n\nexport const nextTick = async (f?: Function) => {\n await new Promise((r) =>\n setTimeout((_) =>\n requestAnimationFrame((_) => {\n f && f();\n r();\n }),\n ),\n );\n};\n\nexport function html(strings: TemplateStringsArray, ...values: any[]): string {\n // List of valid self-closing tags in HTML\n const selfClosingTags = [\"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\"];\n\n // Join the strings and values into a single template\n let result = strings.reduce((acc, str, i) => acc + str + (values[i] || \"\"), \"\");\n\n // Match non-HTML valid self-closing tags\n result = result.replace(/<([a-zA-Z][^\\s/>]*)\\s*([^>]*?)\\/>/g, (match, tagName, attributes) => {\n // If the tag is a valid self-closing tag, return it as is\n if (selfClosingTags.includes(tagName.toLowerCase())) {\n return match;\n }\n\n // Return the tag as an open/close tag preserving attributes\n return `<${tagName} ${attributes}>`;\n });\n\n return result;\n}\n\nexport function toDisplayString(value: unknown) {\n return value == null ? \"\" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);\n}\n\nexport function insertAfter(newNode: Node, existingNode: Node) {\n if (existingNode.nextSibling) {\n existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);\n } else {\n existingNode?.parentNode?.appendChild(newNode);\n }\n}\n\nexport function isPropAttribute(attrName: string) {\n if (attrName.startsWith(\".\")) {\n return true;\n }\n\n if (attrName.startsWith(\"{\") && attrName.endsWith(\"}\")) {\n return true;\n }\n\n return false;\n}\n\nexport function isSpreadProp(attr: string) {\n return attr.startsWith(\"...\");\n}\n\nexport function isMirrorProp(attr: string) {\n return attr.startsWith(\"{\") && attr.endsWith(\"}\");\n}\n\nexport function isRegularProp(attr: string) {\n return attr.startsWith(\".\");\n}\n\nexport function isEventAttribute(attrName: string) {\n return attrName.startsWith(\"@\");\n}\n\nexport function componentHasPropByName(name: string, component: Component) {\n return Object.keys(component?.props ?? {}).some((prop) => prop === name);\n}\n\nexport function extractAttributeName(attrName: string) {\n return attrName\n .replace(/^\\.\\.\\./, \"\")\n .replace(/^\\./, \"\")\n .replace(/^{/, \"\")\n .replace(/}$/, \"\")\n .replace(/:bind$/, \"\");\n}\n\nfunction dashToCamel(str: string) {\n return str.toLowerCase().replace(/-([a-z])/g, (g) => g[1].toUpperCase());\n}\n\nexport function extractPropName(attrName: string) {\n return dashToCamel(extractAttributeName(attrName));\n}\n\nexport function classNames(_: any) {\n const classes = [];\n for (let i = 0; i < arguments.length; i++) {\n const arg = arguments[i];\n if (!arg) continue;\n const argType = typeof arg;\n if (argType === \"string\" || argType === \"number\") {\n classes.push(arg);\n } else if (Array.isArray(arg)) {\n if (arg.length) {\n const inner = classNames.apply(null, arg);\n if (inner) {\n classes.push(inner);\n }\n }\n } else if (argType === \"object\") {\n if (arg.toString === Object.prototype.toString) {\n for (let key in arg) {\n if (Object.hasOwnProperty.call(arg, key) && arg[key]) {\n classes.push(key);\n }\n }\n } else {\n classes.push(arg.toString());\n }\n }\n }\n return classes.join(\" \");\n}\n", "import { Context, evalGet } from \"..\";\nimport { classNames, extractAttributeName } from \"../util\";\n\ninterface AttributeDirectiveOptions {\n element: Element;\n context: Context;\n attr: Attr;\n}\n\ninterface Is {\n sameNameProperty: boolean;\n bound: boolean;\n spread: boolean;\n componentProp: boolean;\n}\n\nexport class AttributeDirective {\n element: Element;\n context: Context;\n expression: string;\n attr: Attr;\n extractedAttributeName: string;\n\n previousClasses: string[] = [];\n previousStyles: { [key: string]: string } = {};\n\n is: Is = {\n sameNameProperty: false,\n bound: false,\n spread: false,\n componentProp: false,\n };\n\n constructor({ element, context, attr }: AttributeDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = attr.value;\n this.attr = attr;\n this.extractedAttributeName = extractAttributeName(attr.name);\n\n this.is = {\n sameNameProperty: attr.name.startsWith(\"{\") && attr.name.endsWith(\"}\"),\n bound: attr.name.includes(\":bind\"),\n spread: attr.name.startsWith(\"...\"),\n componentProp: false,\n };\n\n if (this.is.sameNameProperty) {\n this.expression = this.extractedAttributeName;\n }\n\n if (this.is.spread) {\n this.expression = this.extractedAttributeName;\n }\n\n element.removeAttribute(attr.name);\n\n if (this.is.bound) {\n context.effect(this.update.bind(this));\n } else {\n this.update();\n }\n }\n\n update() {\n let value = evalGet(this.context.scope, this.expression, this.element);\n\n if (this.is.spread && typeof value === \"object\") {\n for (const [key, val] of Object.entries(value)) {\n this.element.setAttribute(key, String(val));\n }\n } else if ((typeof value === \"object\" || Array.isArray(value)) && this.extractedAttributeName === \"class\") {\n value = classNames(value);\n const next = value.split(\" \");\n\n // If we now have classes that are not already on the element, add them now.\n // Remove classes that are no longer on the element.\n const diff = next.filter((c: string) => !this.previousClasses.includes(c)).filter(Boolean);\n const rm = this.previousClasses.filter((c) => !next.includes(c));\n\n diff.forEach((c: string) => {\n this.previousClasses.push(c);\n this.element.classList.add(c);\n });\n\n rm.forEach((c) => {\n this.previousClasses = this.previousClasses.filter((addedClass) => addedClass !== c);\n this.element.classList.remove(c);\n });\n } else if (typeof value === \"object\" && this.extractedAttributeName === \"style\") {\n console.log(\"value is object\", value)\n const next = Object.keys(value);\n const rm = Object.keys(this.previousStyles).filter((style) => !next.includes(style));\n\n next.forEach((style) => {\n this.previousStyles[style] = value[style];\n // @ts-ignore\n this.element.style[style] = value[style];\n });\n\n rm.forEach((style) => {\n this.previousStyles[style] = \"\";\n // @ts-ignore\n this.element.style[style] = \"\";\n });\n\n this.previousStyles = value;\n } else {\n this.element.setAttribute(this.extractedAttributeName, value);\n }\n }\n}\n", "import { Context, evalGet } from \"..\";\n\ninterface EventDirectiveOptions {\n element: Element;\n context: Context;\n attr: Attr;\n}\n\nexport class EventDirective {\n element: Element;\n context: Context;\n expression: string;\n attr: Attr;\n eventCount = 0;\n\n constructor({ element, context, attr }: EventDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = attr.value;\n this.attr = attr;\n\n const eventName = attr.name.replace(/^@/, \"\");\n const parts = eventName.split(\".\");\n\n this.element.addEventListener(parts[0], (event) => {\n if (parts.includes(\"prevent\")) event.preventDefault();\n if (parts.includes(\"stop\")) event.stopPropagation();\n if (parts.includes(\"once\") && this.eventCount > 0) return;\n\n this.eventCount++;\n\n const handler = evalGet(context.scope, attr.value, element);\n if (typeof handler === \"function\") {\n handler(event);\n }\n });\n\n element.removeAttribute(attr.name);\n }\n}\n", "import { Block, Component, Context, createScopedContext, evalGet } from \"..\";\nimport { isArray, isObject } from \"../util\";\n\nconst forAliasRE = /([\\s\\S]*?)\\s+(?:in|of)\\s+([\\s\\S]*)/;\nconst forIteratorRE = /,([^,\\}\\]]*)(?:,([^,\\}\\]]*))?$/;\nconst stripParensRE = /^\\(|\\)$/g;\nconst destructureRE = /^[{[]\\s*((?:[\\w_$]+\\s*,?\\s*)+)[\\]}]$/;\n\ntype KeyToIndexMap = Map;\n\nexport const _for = (el: Element, exp: string, ctx: Context, component?: Component, componentProps?: Record, allProps?: Record) => {\n const inMatch = exp.match(forAliasRE);\n if (!inMatch) {\n console.warn(`invalid :for expression: ${exp}`);\n return;\n }\n\n const nextNode = el.nextSibling;\n\n const parent = el.parentElement!;\n const anchor = new Text(\"\");\n parent.insertBefore(anchor, el);\n parent.removeChild(el);\n\n const sourceExp = inMatch[2].trim();\n let valueExp = inMatch[1].trim().replace(stripParensRE, \"\").trim();\n let destructureBindings: string[] | undefined;\n let isArrayDestructure = false;\n let indexExp: string | undefined;\n let objIndexExp: string | undefined;\n\n let keyAttr = \"key\";\n let keyExp = el.getAttribute(keyAttr) || el.getAttribute((keyAttr = \":key\")) || el.getAttribute((keyAttr = \":key:bind\"));\n if (keyExp) {\n el.removeAttribute(keyAttr);\n if (keyAttr === \"key\") keyExp = JSON.stringify(keyExp);\n }\n\n let match: any;\n if ((match = valueExp.match(forIteratorRE))) {\n valueExp = valueExp.replace(forIteratorRE, \"\").trim();\n indexExp = match[1].trim();\n if (match[2]) {\n objIndexExp = match[2].trim();\n }\n }\n\n if ((match = valueExp.match(destructureRE))) {\n destructureBindings = match[1].split(\",\").map((s: string) => s.trim());\n isArrayDestructure = valueExp[0] === \"[\";\n }\n\n let mounted = false;\n let blocks: Block[];\n let childCtxs: Context[];\n let keyToIndexMap: Map;\n\n const createChildContexts = (source: unknown): [Context[], KeyToIndexMap] => {\n const map: KeyToIndexMap = new Map();\n const ctxs: Context[] = [];\n\n if (isArray(source)) {\n for (let i = 0; i < source.length; i++) {\n ctxs.push(createChildContext(map, source[i], i));\n }\n } else if (typeof source === \"number\") {\n for (let i = 0; i < source; i++) {\n ctxs.push(createChildContext(map, i + 1, i));\n }\n } else if (isObject(source)) {\n let i = 0;\n for (const key in source) {\n ctxs.push(createChildContext(map, source[key], i++, key));\n }\n }\n\n return [ctxs, map];\n };\n\n const createChildContext = (map: KeyToIndexMap, value: any, index: number, objKey?: string): Context => {\n const data: any = {};\n if (destructureBindings) {\n destructureBindings.forEach((b, i) => (data[b] = value[isArrayDestructure ? i : b]));\n } else {\n data[valueExp] = value;\n }\n if (objKey) {\n indexExp && (data[indexExp] = objKey);\n objIndexExp && (data[objIndexExp] = index);\n } else {\n indexExp && (data[indexExp] = index);\n }\n\n const childCtx = createScopedContext(ctx, data);\n const key = keyExp ? evalGet(childCtx.scope, keyExp, el) : index;\n map.set(key, index);\n childCtx.key = key;\n return childCtx;\n };\n\n const mountBlock = (ctx: Context, ref: Node) => {\n const block = new Block({ element: el, parentContext: ctx, replacementType: \"replace\", component, componentProps, allProps });\n block.key = ctx.key;\n block.insert(parent, ref);\n return block;\n };\n\n ctx.effect(() => {\n const source = evalGet(ctx.scope, sourceExp, el);\n const prevKeyToIndexMap = keyToIndexMap;\n [childCtxs, keyToIndexMap] = createChildContexts(source);\n if (!mounted) {\n blocks = childCtxs.map((s) => mountBlock(s, anchor));\n mounted = true;\n } else {\n for (let i = 0; i < blocks.length; i++) {\n if (!keyToIndexMap.has(blocks[i].key)) {\n blocks[i].remove();\n }\n }\n\n const nextBlocks: Block[] = [];\n let i = childCtxs.length;\n let nextBlock: Block | undefined;\n let prevMovedBlock: Block | undefined;\n while (i--) {\n const childCtx = childCtxs[i];\n const oldIndex = prevKeyToIndexMap.get(childCtx.key);\n let block: Block;\n if (oldIndex == null) {\n // new\n block = mountBlock(childCtx, nextBlock ? nextBlock.element : anchor);\n } else {\n // update\n block = blocks[oldIndex];\n Object.assign(block.context.scope, childCtx.scope);\n if (oldIndex !== i) {\n // moved\n if (\n blocks[oldIndex + 1] !== nextBlock ||\n // If the next has moved, it must move too\n prevMovedBlock === nextBlock\n ) {\n prevMovedBlock = block;\n block.insert(parent, nextBlock ? nextBlock.element : anchor);\n }\n }\n }\n nextBlocks.unshift((nextBlock = block));\n }\n blocks = nextBlocks;\n }\n });\n\n return nextNode;\n};\n", "import { Block, Component, Context, evalGet } from \"..\";\nimport { checkAndRemoveAttribute } from \"../util\";\n\ninterface Branch {\n exp?: string | null;\n el: Element;\n}\n\nexport function _if(el: Element, exp: string, ctx: Context, component?: Component, componentProps?: Record, allProps?: Record) {\n const parent = el.parentElement!;\n const anchor = new Comment(\":if\");\n\n parent.insertBefore(anchor, el);\n\n const branches: Branch[] = [{ exp, el }];\n\n let elseEl: Element | null;\n let elseExp: string | null;\n\n while ((elseEl = el.nextElementSibling)) {\n elseExp = null;\n\n if (checkAndRemoveAttribute(elseEl, \":else\") === \"\" || (elseExp = checkAndRemoveAttribute(elseEl, \":else-if\"))) {\n parent.removeChild(elseEl);\n branches.push({ exp: elseExp, el: elseEl });\n } else {\n break;\n }\n }\n\n const nextNode = el.nextSibling;\n parent.removeChild(el);\n\n let block: Block | undefined;\n let activeBranchIndex = -1;\n\n const removeActiveBlock = () => {\n if (block) {\n parent.insertBefore(anchor, block.element);\n block.remove();\n block = undefined;\n }\n };\n\n ctx.effect(() => {\n for (let i = 0; i < branches.length; i++) {\n const { exp, el } = branches[i];\n\n if (!exp || evalGet(ctx.scope, exp, el)) {\n if (i !== activeBranchIndex) {\n removeActiveBlock();\n block = new Block({ element: el, parentContext: ctx, replacementType: \"replace\", component, componentProps, allProps });\n block.insert(parent, anchor);\n parent.removeChild(anchor);\n activeBranchIndex = i;\n }\n\n return;\n }\n }\n\n activeBranchIndex = -1;\n removeActiveBlock();\n });\n\n return nextNode;\n}\n", "import { Context, evalGet } from \"../\";\nimport { insertAfter, toDisplayString } from \"../util\";\n\ninterface InterpolationDirectiveOptions {\n element: Text;\n context: Context;\n}\n\nconst delims = /{{\\s?(.*?)\\s?}}/g;\n\nexport class InterpolationDirective {\n element: Text;\n context: Context;\n textNodes: Map = new Map();\n\n constructor({ element, context }: InterpolationDirectiveOptions) {\n this.element = element;\n this.context = context;\n\n this.findNodes();\n\n this.textNodes.forEach((nodes, expression) => {\n const trimmedExpression = expression.slice(2, -2).trim();\n\n nodes.forEach((node) => {\n const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, element);\n\n context.effect(() => {\n node.textContent = toDisplayString(getter());\n });\n });\n });\n }\n\n findNodes() {\n const textContent = this.element.textContent.trim();\n if (textContent?.match(delims)) {\n const textNodes = textContent.split(/(\\{\\{\\s?[^}]+\\s?\\}\\})/g).filter(Boolean);\n if (textNodes) {\n let previousNode = this.element;\n\n for (let i = 0; i < textNodes.length; i++) {\n const textNode = textNodes[i];\n\n if (textNode.match(/\\{\\{\\s?.+\\s?\\}\\}/)) {\n const newNode = document.createTextNode(textNode);\n\n if (i === 0) {\n this.element.replaceWith(newNode);\n } else {\n insertAfter(newNode, previousNode);\n }\n\n previousNode = newNode;\n\n if (this.textNodes.has(textNode)) {\n this.textNodes.get(textNode).push(newNode);\n } else {\n this.textNodes.set(textNode, [newNode]);\n }\n } else {\n const newNode = document.createTextNode(textNodes[i]);\n\n if (i === 0) {\n this.element.replaceWith(newNode);\n } else {\n insertAfter(newNode, previousNode);\n }\n\n previousNode = newNode;\n }\n }\n }\n }\n }\n\n update() {}\n}\n", "import { Context, evalGet } from \"..\";\n\ninterface ShowDirectiveOptions {\n element: Element;\n context: Context;\n expression: string;\n}\n\nexport class ShowDirective {\n element: Element;\n context: Context;\n expression: string;\n originalDisplay: string;\n\n constructor({ element, context, expression }: ShowDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = expression;\n this.originalDisplay = getComputedStyle(this.element).display;\n\n context.effect(this.update.bind(this));\n }\n\n update() {\n const shouldShow = Boolean(evalGet(this.context.scope, this.expression, this.element));\n // @ts-ignore\n this.element.style.display = shouldShow ? this.originalDisplay : \"none\";\n }\n}\n", "import { Block, Context } from \"..\";\nimport { nextTick } from \"../util\";\n\nexport function _teleport(el: Element, exp: string, ctx: Context) {\n const anchor = new Comment(\":teleport\");\n el.replaceWith(anchor);\n\n const target = document.querySelector(exp);\n if (!target) {\n console.warn(`teleport target not found: ${exp}`);\n return;\n }\n\n nextTick(() => {\n target.appendChild(el);\n\n const observer = new MutationObserver((mutationsList) => {\n mutationsList.forEach((mutation) => {\n mutation.removedNodes.forEach((removedNode) => {\n if (removedNode.contains(anchor)) {\n el.remove();\n observer.disconnect();\n }\n });\n });\n });\n\n observer.observe(document.body, { childList: true, subtree: true });\n\n // Walks the tree of this teleported element.\n new Block({\n element: el,\n parentContext: ctx,\n });\n });\n\n // Return the anchor so walk continues down the tree in the right order.\n return anchor;\n}\n", "import { Context, evalGet, evalSet } from \"..\";\n\ninterface ValueDirectiveOptions {\n element: Element;\n context: Context;\n expression: string;\n}\n\ntype SupportedModelType = \"text\" | \"checkbox\" | \"radio\" | \"number\" | \"password\" | \"color\";\n\nfunction isInput(element: Element): element is HTMLInputElement {\n return element instanceof HTMLInputElement;\n}\n\nfunction isTextarea(element: Element): element is HTMLTextAreaElement {\n return element instanceof HTMLTextAreaElement;\n}\n\nfunction isSelect(element: Element): element is HTMLSelectElement {\n return element instanceof HTMLSelectElement;\n}\n\nexport class ValueDirective {\n element: Element;\n context: Context;\n expression: string;\n inputType: SupportedModelType;\n\n constructor({ element, context, expression }: ValueDirectiveOptions) {\n this.element = element;\n this.context = context;\n this.expression = expression;\n this.inputType = element.getAttribute(\"type\") as SupportedModelType;\n\n // Element -> Context\n if (isInput(element)) {\n switch (this.inputType) {\n case \"text\":\n case \"password\":\n case \"number\":\n case \"color\":\n element.addEventListener(\"input\", () => {\n const value = this.inputType === \"number\" ? (element.value ? parseFloat(element.value) : 0) : element.value;\n evalSet(this.context.scope, expression, value);\n });\n break;\n\n case \"checkbox\":\n element.addEventListener(\"change\", (e: any) => {\n evalSet(this.context.scope, expression, !!e.currentTarget.checked);\n });\n break;\n case \"radio\":\n element.addEventListener(\"change\", (e: any) => {\n if (e.currentTarget.checked) {\n evalSet(this.context.scope, expression, element.getAttribute(\"value\"));\n }\n });\n break;\n default:\n break;\n }\n }\n\n if (isTextarea(element)) {\n element.addEventListener(\"input\", () => {\n evalSet(this.context.scope, expression, element.value);\n });\n }\n\n if (isSelect(element)) {\n element.addEventListener(\"change\", () => {\n evalSet(this.context.scope, expression, element.value);\n });\n }\n\n // Context -> Element\n context.effect(this.updateElementValue.bind(this));\n }\n\n updateElementValue() {\n const value = evalGet(this.context.scope, this.expression, this.element);\n\n if (isInput(this.element)) {\n switch (this.inputType) {\n case \"text\":\n case \"password\":\n case \"number\":\n case \"color\":\n this.element.value = value;\n break;\n case \"checkbox\":\n this.element.checked = !!value;\n break;\n case \"radio\":\n this.element.checked = this.element.value === value;\n break;\n default:\n break;\n }\n }\n\n if (isTextarea(this.element)) {\n this.element.value = value;\n }\n\n if (isSelect(this.element)) {\n this.element.value = value;\n }\n }\n}\n", "interface EffectOptions {\n lazy?: boolean;\n}\n\ninterface EffectFunction {\n active: boolean;\n handler: () => void;\n refs: Set[];\n}\n\ntype Effects = Set;\ntype EffectsMap = Map;\ntype TargetMap = WeakMap;\n\nconst targetMap: TargetMap = new WeakMap();\nconst effectStack: (EffectFunction | undefined)[] = [];\n\nexport function track(target: T, key: PropertyKey) {\n const activeEffect = effectStack[effectStack.length - 1];\n\n if (!activeEffect) return;\n\n let effectsMap = targetMap.get(target);\n if (!effectsMap)\n targetMap.set(target, (effectsMap = new Map() as EffectsMap));\n\n let effects = effectsMap.get(key);\n if (!effects) effectsMap.set(key, (effects = new Set()));\n\n if (!effects.has(activeEffect)) {\n effects.add(activeEffect);\n activeEffect.refs.push(effects);\n }\n}\n\nexport function trigger(target: any, key: PropertyKey) {\n const effectsMap = targetMap.get(target);\n if (!effectsMap) return;\n\n const scheduled = new Set();\n\n effectsMap.get(key)?.forEach((effect) => {\n scheduled.add(effect);\n });\n\n scheduled.forEach(run);\n}\n\nfunction stop(effect: EffectFunction) {\n if (effect.active) cleanup(effect);\n effect.active = false;\n}\n\nfunction start(effect: EffectFunction) {\n if (!effect.active) {\n effect.active = true;\n run(effect);\n }\n}\n\nfunction run(effect: EffectFunction): unknown {\n if (!effect.active) return;\n\n if (effectStack.includes(effect)) return;\n\n cleanup(effect);\n\n let val: unknown;\n\n try {\n effectStack.push(effect);\n val = effect.handler();\n } finally {\n effectStack.pop();\n }\n\n return val;\n}\n\nfunction cleanup(effect: EffectFunction) {\n const { refs } = effect;\n\n if (refs.length) {\n for (const ref of refs) {\n ref.delete(effect);\n }\n }\n\n refs.length = 0;\n}\n\nexport function effect(handler: () => void, opts: EffectOptions = {}) {\n const { lazy } = opts;\n const newEffect: EffectFunction = {\n active: !lazy,\n handler,\n refs: [],\n };\n\n run(newEffect);\n\n return {\n start: () => {\n start(newEffect);\n },\n stop: () => {\n stop(newEffect);\n },\n toggle: () => {\n if (newEffect.active) {\n stop(newEffect);\n } else {\n start(newEffect);\n }\n return newEffect.active;\n },\n };\n}\n", "import { isObject } from \"../util\";\nimport { effect } from \"./effect\";\n\nconst $computed = Symbol(\"computed\");\n\nexport type Computed = {\n readonly value: T;\n readonly [$computed]: true;\n};\n\nexport function isComputed(value: unknown): value is Computed {\n return isObject(value) && value[$computed];\n}\n\nexport function computed(getter: () => T): Computed {\n const ref = {\n get value(): T {\n return getter();\n },\n [$computed]: true,\n } as const;\n\n effect(() => {\n getter();\n });\n\n return ref;\n}\n", "import { isObject } from \"../util\";\nimport { track, trigger } from \"./effect\";\nimport { Reactive, reactive } from \"./reactive\";\n\nexport const $ref = Symbol(\"ref\");\n\nexport type Ref = {\n value: T;\n [$ref]: true;\n};\n\nexport function isRef(value: unknown): value is Ref {\n return isObject(value) && !!value[$ref];\n}\n\nexport function ref(value: T = null as unknown as T): Ref {\n if (isObject(value)) {\n // @ts-ignore\n return isRef(value) ? (value as Ref) : (reactive(value) as Reactive);\n }\n\n const result = { value, [$ref]: true };\n\n return new Proxy(result, {\n get(target: object, key: string | symbol, receiver: any) {\n const val = Reflect.get(target, key, receiver);\n track(result, \"value\");\n return val;\n },\n set(target: object, key: string | symbol, value: unknown) {\n const oldValue = target[key];\n if (oldValue !== value) {\n const success = Reflect.set(target, key, value);\n if (success) {\n trigger(result, \"value\");\n }\n }\n return true;\n },\n }) as Ref;\n}\n", "import { isObject } from \"../util\";\nimport { track, trigger } from \"./effect\";\nimport { ref } from \"./ref\";\n\nconst $reactive = Symbol(\"reactive\");\n\nexport type Reactive = T & { [$reactive]: true };\n\nexport function isReactive(\n value: unknown,\n): value is Reactive {\n return isObject(value) && !!value[$reactive];\n}\n\nexport function reactive(value: T): Reactive {\n // @ts-ignore\n if (!isObject(value)) return ref(value) as Reactive;\n if (value[$reactive]) return value as Reactive;\n\n value[$reactive] = true;\n\n Object.keys(value).forEach((key) => {\n if (isObject(value[key])) {\n value[key] = reactive(value[key]);\n }\n });\n\n return new Proxy(value, reactiveProxyHandler()) as Reactive;\n}\n\nfunction reactiveProxyHandler() {\n return {\n deleteProperty(target: object, key: string | symbol) {\n const had = Reflect.has(target, key);\n const result = Reflect.deleteProperty(target, key);\n if (had) trigger(target, key);\n return result;\n },\n get(target: object, key: string | symbol) {\n track(target, key);\n return Reflect.get(target, key);\n },\n set(target: object, key: string | symbol, value: unknown) {\n if (target[key] === value) return true;\n let newObj = false;\n\n if (isObject(value) && !isObject(target[key])) {\n newObj = true;\n }\n\n if (Reflect.set(target, key, value)) {\n trigger(target, key);\n }\n\n if (newObj) {\n target[key] = reactive(target[key]);\n }\n\n return true;\n },\n };\n}\n", "import { isComputed } from \"./computed\";\nimport { isRef } from \"./ref\";\n\nexport function unwrap(value: unknown) {\n if (isRef(value) || isComputed(value)) {\n return value.value;\n }\n\n if (typeof value === \"function\") {\n return value();\n }\n\n return value;\n}\n", "import { pathToRegexp } from \"path-to-regexp\";\nimport { Route, RouteExpression, RouteMatch } from \".\";\nimport { Plugin } from \"..\";\nimport { App, Block, Component, current } from \"../..\";\nimport { reactive } from \"../../reactivity/reactive\";\nimport { unwrap } from \"../../reactivity/unwrap\";\nimport { html } from \"../../util\";\n\nexport const activeRouters = new Set();\n\nexport function getRouter(): RouterPlugin | undefined {\n return current.componentBlock ? [...activeRouters].find((router) => router.app === current.componentBlock.context.app) : undefined;\n}\n\nconst link = {\n template: html``,\n props: { href: { default: \"#\" } },\n main({ href }: { href: string }) {\n const go = (e: Event) => {\n e.preventDefault();\n\n activeRouters.forEach((router) => {\n router.doRouteChange(unwrap(href as unknown) as string);\n });\n };\n\n const classes = reactive({ \"router-link\": true });\n\n return { go, classes, href };\n },\n};\n\nasync function runEnterTransition(enter: () => boolean | Promise): Promise {\n return await enter();\n}\n\nconst canEnterRoute = async (route: Route) => {\n if (route.beforeEnter) {\n return await runEnterTransition(route.beforeEnter);\n }\n return true;\n};\n\nconst maybeRedirectRoute = (route: Route) => {\n if (route.redirectTo) {\n activeRouters.forEach((plugin) => plugin.doRouteChange(route.redirectTo));\n }\n};\n\nexport class RouterPlugin implements Plugin {\n app: App;\n routes: Route[] = [];\n pathExpressions = new Map();\n lastPath = \"/\";\n knownRouterViews = new Map();\n knownRouterViewNames = new Map();\n populatedRouterViews = new Map();\n\n constructor(routes: Route[] = []) {\n this.routes = routes;\n }\n\n use(app: App, ..._: any[]) {\n this.app = app;\n this.app.register(\"router-link\", link);\n\n window.addEventListener(\"popstate\", this.onHistoryEvent.bind(this));\n window.addEventListener(\"pushstate\", this.onHistoryEvent.bind(this));\n window.addEventListener(\"load\", this.onHistoryEvent.bind(this));\n\n for (const route of this.routes) {\n this.cacheRouteExpression(route);\n }\n\n this.lastPath = `${location.pathname}${location.search}`;\n window.history.replaceState({}, \"\", this.lastPath);\n\n activeRouters.add(this);\n }\n\n compile(element: Element) {\n if (element.nodeType === Node.ELEMENT_NODE && element.nodeName === \"ROUTER-VIEW\" && !this.knownRouterViews.has(element) && current.componentBlock) {\n this.knownRouterViews.set(element, current.componentBlock);\n this.knownRouterViewNames.set(element.getAttribute(\"name\")?.trim() || \"\", element);\n }\n }\n\n onHistoryEvent(e: PopStateEvent | Event) {\n e.preventDefault();\n e.stopImmediatePropagation();\n\n // @ts-ignore\n const path = new URL(e.currentTarget.location.href).pathname;\n\n if (e.type === \"load\") {\n window.history.replaceState({}, \"\", this.lastPath);\n } else if (e.type === \"pushstate\") {\n window.history.replaceState({}, \"\", path);\n } else if (e.type === \"popstate\") {\n window.history.replaceState({}, \"\", path);\n }\n\n this.lastPath = path;\n\n const matches = this.getMatchesForURL(path);\n this.applyMatches(matches);\n }\n\n doRouteChange(to: string) {\n window.history.pushState({}, \"\", to);\n const matches = this.getMatchesForURL(`${location.pathname}${location.search}`);\n this.applyMatches(matches);\n }\n\n getMatchesForURL(url: string): RouteMatch[] {\n let matches: RouteMatch[] = [];\n\n const matchRoutes = (routes: Route[], parentPath: string = \"\", previousParents = []): RouteMatch[] => {\n let parents = [];\n\n for (const route of routes) {\n parents.push(route);\n const path = `${parentPath}${route.path}`.replace(/\\/\\//g, \"/\");\n const match = this.getPathMatch(path, url);\n if (match) matches.push({ match, parents: [...previousParents, ...parents] });\n if (route.children?.length) {\n matchRoutes(route.children, path, [...previousParents, ...parents]);\n parents = [];\n }\n }\n\n return matches;\n };\n matches = matchRoutes(this.routes);\n return matches;\n }\n\n /**\n * getRouteExpression takes a path like \"/users/:id\" and returns a regex\n * and an array of params that match the path.\n * \"/users/:id\" => { regex: /^\\/users\\/([^\\/]+)\\?jwt=(\\w)$/, params: [\"id\"], query: [\"jwt\"] }\n */\n getRouteExpression(path: string, route: Route): RouteExpression {\n if (this.pathExpressions.has(path)) return this.pathExpressions.get(path);\n\n const params = [];\n const regex = pathToRegexp(path, params, { strict: false, sensitive: false, end: true });\n const expression = { regex, params, path, route };\n this.pathExpressions.set(path, expression);\n return expression;\n }\n\n /**\n *\n * @param path A path like /foo/bar/:id\n * @param url A url like /foo/bar/1234\n * @returns A RouteExpression if the URL matches the regex cached for @param path, null otherwise.\n */\n getPathMatch(path: string, url: string): RouteExpression | null {\n if (this.pathExpressions.get(path)) {\n const match = this.pathExpressions.get(path).regex.exec(url);\n if (match) {\n return this.pathExpressions.get(path);\n }\n }\n\n return null;\n }\n\n async applyMatches(matches: RouteMatch[] | null) {\n if (!matches) return;\n\n const usedRouterViews = new Set();\n\n const renderRoutes = async (routeChain: Route[], rootNode?: Element) => {\n for (const route of routeChain) {\n if (route.view) {\n const viewNode = this.knownRouterViewNames.get(route.view);\n if (viewNode && (await canEnterAndRenderRoute(viewNode, route))) {\n continue;\n }\n } else if (rootNode && (await canEnterAndRenderRoute(rootNode, route))) {\n continue;\n }\n }\n };\n\n const canEnterAndRenderRoute = async (node: Element, route: Route) => {\n const canEnter = await canEnterRoute(route);\n if (canEnter) {\n renderRouteAtNode(node, route);\n return true;\n } else {\n if (route.componentFallback) {\n renderRouteAtNode(node, route, route.componentFallback);\n } else {\n maybeRedirectRoute(route);\n }\n\n return false;\n }\n };\n\n const renderRouteAtNode = (node: Element, route: Route, component?: Component) => {\n if (!usedRouterViews.has(node) || this.populatedRouterViews.get(node)?.route !== route) {\n const div = document.createElement(\"div\");\n node.replaceChildren(div);\n\n const target = div.parentElement;\n\n const block = new Block({\n element: div,\n component: component ? component : route.component,\n replacementType: \"replaceChildren\",\n parentContext: current.componentBlock.context,\n });\n\n target.replaceChild(block.element, div);\n\n this.populatedRouterViews.set(node, { block, route });\n\n usedRouterViews.add(node);\n }\n };\n\n for (const match of matches) {\n const routeChain = [...match.parents, match.match.route];\n const uniqueRouteChain = routeChain.filter((route, index, self) => index === self.findIndex((r) => r.path === route.path));\n const rootNode = this.knownRouterViewNames.get(\"\") ?? null;\n await renderRoutes(uniqueRouteChain, rootNode);\n }\n\n // Clean up stale views\n for (const node of this.knownRouterViews.keys()) {\n if (!usedRouterViews.has(node) && this.populatedRouterViews.has(node)) {\n const entry = this.populatedRouterViews.get(node);\n if (entry) {\n entry.block.teardown();\n this.populatedRouterViews.delete(node);\n }\n }\n }\n }\n\n cacheRouteExpression(route: Route, parentPath: string = \"\") {\n const path = `${parentPath}${route.path}`.replace(/\\/\\//g, \"/\");\n this.getRouteExpression(path, route);\n if (route.children?.length) {\n route.children.forEach((child) => {\n this.cacheRouteExpression(child, path);\n });\n }\n }\n\n destroy() {\n window.removeEventListener(\"popstate\", this.onHistoryEvent.bind(this));\n window.removeEventListener(\"pushstate\", this.onHistoryEvent.bind(this));\n window.removeEventListener(\"load\", this.onHistoryEvent.bind(this));\n }\n}\n", "import { AttributeDirective } from \"./directives/attribute\";\nimport { EventDirective } from \"./directives/event\";\nimport { _for } from \"./directives/for\";\nimport { _if } from \"./directives/if\";\nimport { InterpolationDirective } from \"./directives/interpolation\";\nimport { ShowDirective } from \"./directives/show\";\nimport { _teleport } from \"./directives/teleport\";\nimport { ValueDirective } from \"./directives/value\";\nimport { Plugin } from \"./plugins\";\nimport { isComputed } from \"./reactivity/computed\";\nimport { effect as _effect } from \"./reactivity/effect\";\nimport { reactive } from \"./reactivity/reactive\";\nimport { isRef } from \"./reactivity/ref\";\nimport { checkAndRemoveAttribute, componentHasPropByName, extractPropName, findSlotNodes, findTemplateNodes, isElement, isEventAttribute, isMirrorProp, isObject, isPropAttribute, isRegularProp, isSpreadProp, isText, Slot, stringToElement, Template, toDisplayString } from \"./util\";\n\nexport * from \"./plugins\";\nexport * from \"./plugins/router\";\n\nexport function provide(key: string, value: unknown) {\n if (!current.componentBlock) {\n console.warn(\"Can't provide: no current component block\");\n }\n\n current.componentBlock.provides.set(key, value);\n}\n\nexport function inject(key: string) {\n if (!current.componentBlock) {\n console.warn(\"Can't inject: no current component block\");\n }\n\n let c = current.componentBlock;\n\n while (c) {\n if (c.provides.has(key)) {\n return c.provides.get(key);\n }\n\n c = c.parentComponentBlock;\n }\n\n return undefined;\n}\n\nexport class App {\n root: Block;\n registry = new Map();\n plugins = new Set();\n\n register(name: string, component: Component) {\n this.registry.set(name, component);\n }\n\n use(plugin: Plugin, ...config: any[]) {\n this.plugins.add(plugin);\n plugin.use(this, ...config);\n }\n\n getComponent(tag: string) {\n return this.registry.get(tag);\n }\n\n mount(component: Component, target: string | HTMLElement = \"body\", props: Record = {}) {\n const root = typeof target === \"string\" ? (document.querySelector(target) as HTMLElement) : target;\n const display = root.style.display;\n root.style.display = \"none\";\n this.root = this._mount(component, root, props);\n root.style.display = display;\n return this.root;\n }\n\n private _mount(component: Component, target: HTMLElement, props: Record) {\n const parentContext = createContext({ app: this });\n\n if (props) {\n parentContext.scope = reactive(props);\n bindContextMethods(parentContext.scope);\n }\n\n parentContext.scope.$isRef = isRef;\n parentContext.scope.$isComputed = isComputed;\n\n const block = new Block({\n element: target,\n parentContext,\n component,\n isRoot: true,\n componentProps: props,\n replacementType: \"replaceChildren\",\n });\n\n return block;\n }\n\n unmount() {\n this.root.teardown();\n }\n}\n\nexport interface Context {\n key?: any;\n app: App;\n scope: Record;\n blocks: Block[];\n effects: Array>;\n effect: typeof _effect;\n slots: Slot[];\n templates: Template[];\n}\n\ninterface CreateContextOptions {\n parentContext?: Context;\n app?: App;\n}\n\nexport function createContext({ parentContext, app }: CreateContextOptions): Context {\n const context: Context = {\n app: app ? app : parentContext && parentContext.app ? parentContext.app : null,\n // scope: parentContext ? parentContext.scope : reactive({}),\n scope: reactive({}),\n blocks: [],\n effects: [],\n slots: [],\n templates: parentContext ? parentContext.templates : [],\n effect: (handler: () => void) => {\n const e = _effect(handler);\n context.effects.push(e);\n return e;\n },\n };\n\n return context;\n}\n\nexport const createScopedContext = (ctx: Context, data = {}): Context => {\n const parentScope = ctx.scope;\n const mergedScope = Object.create(parentScope);\n Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));\n let proxy: any;\n proxy = reactive(\n new Proxy(mergedScope, {\n set(target, key, val, receiver) {\n // when setting a property that doesn't exist on current scope,\n // do not create it on the current scope and fallback to parent scope.\n if (receiver === proxy && !target.hasOwnProperty(key)) {\n return Reflect.set(parentScope, key, val);\n }\n return Reflect.set(target, key, val, receiver);\n },\n }),\n );\n\n bindContextMethods(proxy);\n\n const out: Context = {\n ...ctx,\n scope: {\n ...ctx.scope,\n ...proxy,\n },\n };\n\n return out;\n};\n\nfunction bindContextMethods(scope: Record) {\n for (const key of Object.keys(scope)) {\n if (typeof scope[key] === \"function\") {\n scope[key] = scope[key].bind(scope);\n }\n }\n}\n\nfunction mergeProps(props: Record, defaultProps: Record) {\n const merged = {};\n\n Object.keys(defaultProps).forEach((defaultProp) => {\n const propValue = props.hasOwnProperty(defaultProp) ? props[defaultProp] : defaultProps[defaultProp]?.default;\n\n merged[defaultProp] = reactive(typeof propValue === \"function\" ? propValue() : propValue);\n });\n\n return merged;\n}\n\nexport interface Component {\n template: string;\n props?: Record;\n main?: (props?: Record) => Record | void;\n}\n\ninterface Current {\n componentBlock?: Block;\n}\n\nexport const current: Current = { componentBlock: undefined };\n\ninterface BlockOptions {\n element: Element;\n isRoot?: boolean;\n replacementType?: \"replace\" | \"replaceChildren\";\n componentProps?: Record;\n allProps?: Record;\n parentContext?: Context;\n component?: Component;\n parentComponentBlock?: Block;\n templates?: Template[];\n}\n\nexport class Block {\n element: Element;\n context: Context;\n parentContext: Context;\n component: Component;\n provides = new Map();\n parentComponentBlock: Block | undefined;\n componentProps: Record;\n allProps: Record;\n\n isFragment: boolean;\n start?: Text;\n end?: Text;\n key?: any;\n\n constructor(opts: BlockOptions) {\n this.isFragment = opts.element instanceof HTMLTemplateElement;\n this.parentComponentBlock = opts.parentComponentBlock;\n\n if (opts.component) {\n current.componentBlock = this;\n this.element = stringToElement(opts.component.template);\n } else {\n if (this.isFragment) {\n this.element = (opts.element as HTMLTemplateElement).content.cloneNode(true) as Element;\n } else if (typeof opts.element === \"string\") {\n this.element = stringToElement(opts.element);\n } else {\n this.element = opts.element.cloneNode(true) as Element;\n opts.element.replaceWith(this.element);\n }\n }\n\n if (opts.isRoot) {\n this.context = opts.parentContext;\n } else {\n this.parentContext = opts.parentContext ? opts.parentContext : createContext({});\n this.parentContext.blocks.push(this);\n this.context = createContext({ parentContext: opts.parentContext });\n }\n\n if (opts.component) {\n this.componentProps = mergeProps(opts.componentProps ?? {}, opts.component.props ?? {});\n\n if (opts.component.main) {\n this.context.scope = {\n ...(opts.component.main(this.componentProps) || {}),\n };\n }\n }\n\n opts.allProps?.forEach((prop: any) => {\n if (prop.isBind) {\n this.context.effect(() => {\n let newValue: unknown;\n\n if (prop.isSpread) {\n const spreadProps = evalGet(this.parentContext.scope, prop.extractedName);\n if (isObject(spreadProps)) {\n Object.keys(spreadProps).forEach((key) => {\n newValue = spreadProps[key];\n this.setProp(key, newValue);\n });\n }\n } else {\n newValue = prop.isMirror ? evalGet(this.parentContext.scope, prop.extractedName) : evalGet(this.parentContext.scope, prop.exp);\n this.setProp(prop.extractedName, newValue);\n }\n });\n }\n });\n\n // Capture slots\n this.context.slots = findSlotNodes(this.element);\n this.context.templates = opts.templates ?? [];\n\n // Put templates into slots\n this.context.slots.forEach((slot) => {\n const template = this.context.templates.find((t) => t.targetSlotName === slot.name);\n\n if (template) {\n const templateContents = template.node.content.cloneNode(true);\n slot.node.replaceWith(templateContents);\n }\n });\n\n this.context.scope.$isRef = isRef;\n this.context.scope.$isComputed = isComputed;\n\n walk(this.element, this.context);\n\n if (opts.component) {\n if (opts.replacementType === \"replace\") {\n if (opts.element instanceof HTMLElement) {\n opts.element.replaceWith(this.element);\n }\n } else {\n if (opts.element instanceof HTMLElement) {\n opts.element.replaceChildren(this.element);\n }\n }\n }\n }\n\n setProp(name: string, value: unknown) {\n if (isRef(this.componentProps[name])) {\n this.componentProps[name].value = value;\n } else {\n this.componentProps[name] = value;\n }\n }\n\n insert(parent: Element, anchor: Node | null = null) {\n if (this.isFragment) {\n if (this.start) {\n // Already inserted, moving\n let node: Node | null = this.start;\n let next: Node | null;\n\n while (node) {\n next = node.nextSibling;\n parent.insertBefore(node, anchor);\n\n if (node === this.end) {\n break;\n }\n\n node = next;\n }\n } else {\n this.start = new Text(\"\");\n this.end = new Text(\"\");\n\n parent.insertBefore(this.end, anchor);\n parent.insertBefore(this.start, this.end);\n parent.insertBefore(this.element, this.end);\n }\n } else {\n parent.insertBefore(this.element, anchor);\n }\n }\n\n remove() {\n if (this.parentContext) {\n const i = this.parentContext.blocks.indexOf(this);\n\n if (i > -1) {\n this.parentContext.blocks.splice(i, 1);\n }\n }\n\n if (this.start) {\n const parent = this.start.parentNode!;\n let node: Node | null = this.start;\n let next: Node | null;\n\n while (node) {\n next = node.nextSibling;\n parent.removeChild(node);\n\n if (node === this.end) {\n break;\n }\n\n node = next;\n }\n } else {\n // this.element.parentNode!.removeChild(this.element);\n this.element.remove();\n }\n\n this.teardown();\n }\n\n teardown() {\n this.context.blocks.forEach((block) => {\n block.teardown();\n });\n\n this.context.effects.forEach(stop);\n }\n}\n\nfunction isComponent(element: Element, context: Context) {\n return !!context.app.getComponent(element.tagName.toLowerCase());\n}\n\nfunction warnInvalidDirectives(node: Element, directives: string[]): boolean {\n if (directives.every((d) => node.hasAttribute(d))) {\n console.warn(`These directives cannot be used together on the same node:`, directives);\n console.warn(\"Node ignored:\", node);\n return true;\n }\n\n return false;\n}\n\nfunction walk(node: Node, context: Context) {\n if (isText(node)) {\n new InterpolationDirective({ element: node, context });\n return;\n }\n\n if (isElement(node)) {\n let exp: string | null;\n\n const handleDirectives = (node: Element, context: Context, component?: Component, componentProps?: Record, allProps?: any[]) => {\n if (warnInvalidDirectives(node, [\":if\", \":for\"])) return;\n if (warnInvalidDirectives(node, [\":if\", \":teleport\"])) return;\n if (warnInvalidDirectives(node, [\":for\", \":teleport\"])) return;\n\n // e.g.
\n // In this case, the scope is merged into context.scope and will overwrite\n // anything returned from `main`.\n if ((exp = checkAndRemoveAttribute(node, \":scope\"))) {\n const scope = evalGet(context.scope, exp, node);\n if (typeof scope === \"object\") {\n Object.assign(context.scope, scope);\n // context = createScopedContext(context, scope);\n }\n }\n\n if ((exp = checkAndRemoveAttribute(node, \":teleport\"))) {\n return _teleport(node, exp, context);\n }\n if ((exp = checkAndRemoveAttribute(node, \":if\"))) {\n return _if(node, exp, context, component, componentProps, allProps);\n }\n if ((exp = checkAndRemoveAttribute(node, \":for\"))) {\n return _for(node, exp, context, component, componentProps, allProps);\n }\n if ((exp = checkAndRemoveAttribute(node, \":show\"))) {\n new ShowDirective({ element: node, context, expression: exp });\n }\n if ((exp = checkAndRemoveAttribute(node, \":ref\"))) {\n context.scope[exp].value = node;\n }\n if ((exp = checkAndRemoveAttribute(node, \":value\"))) {\n new ValueDirective({ element: node, context, expression: exp });\n }\n if ((exp = checkAndRemoveAttribute(node, \":html\"))) {\n context.effect(() => {\n const result = evalGet(context.scope, exp, node);\n if (result instanceof Element) {\n node.replaceChildren();\n node.append(result);\n } else {\n node.innerHTML = result;\n }\n });\n }\n if ((exp = checkAndRemoveAttribute(node, \":text\"))) {\n context.effect(() => {\n node.textContent = toDisplayString(evalGet(context.scope, exp, node));\n });\n }\n };\n\n const processAttributes = (node: Element, component?: Component) => {\n return Array.from(node.attributes)\n .filter((attr) => isSpreadProp(attr.name) || isMirrorProp(attr.name) || (isRegularProp(attr.name) && componentHasPropByName(extractPropName(attr.name), component)))\n .map((attr) => ({\n isMirror: isMirrorProp(attr.name),\n isSpread: isSpreadProp(attr.name),\n isBind: attr.name.includes(\"bind\"),\n originalName: attr.name,\n extractedName: extractPropName(attr.name),\n exp: attr.value,\n value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name), node) : attr.value ? evalGet(context.scope, attr.value, node) : undefined,\n }));\n };\n\n if (isComponent(node, context)) {\n const component = context.app.getComponent(node.tagName.toLowerCase());\n const allProps = processAttributes(node, component);\n\n const componentProps = allProps.reduce((acc, { isSpread, isMirror, extractedName, value }) => {\n if (isSpread) {\n const spread = evalGet(context.scope, extractedName, node);\n if (isObject(spread)) Object.assign(acc, spread);\n } else if (isMirror) {\n acc[extractedName] = evalGet(context.scope, extractedName, node);\n } else {\n acc[extractedName] = value;\n }\n return acc;\n }, {});\n\n const next = handleDirectives(node, context, component, componentProps, allProps);\n if (next) return next;\n\n const templates = findTemplateNodes(node);\n\n return new Block({\n element: node,\n parentContext: context,\n component,\n replacementType: \"replace\",\n parentComponentBlock: current.componentBlock,\n templates,\n componentProps,\n allProps,\n }).element;\n }\n\n const next = handleDirectives(node, context);\n if (next) return next;\n\n Array.from(node.attributes).forEach((attr) => {\n if (isPropAttribute(attr.name)) {\n new AttributeDirective({ element: node, context, attr });\n }\n\n if (isEventAttribute(attr.name)) {\n new EventDirective({ element: node, context, attr });\n }\n });\n\n walkChildren(node, context);\n }\n}\n\nfunction walkChildren(node: Node, context: Context) {\n let child = node.firstChild;\n\n while (child) {\n child = walk(child, context) || child.nextSibling;\n }\n}\n\nconst evalFuncCache: Record = {};\n\nexport function evalGet(scope: any, exp: string, el?: Node) {\n if (!exp.trim()) return undefined;\n return execute(scope, `const ___value = (${exp.trim()}); return ___value;`, el);\n}\n\nexport function evalSet(scope: any, exp: string, value: unknown) {\n value = typeof value === \"string\" ? `\"${value}\"` : value;\n return execute(scope, `const ___target = (${exp.trim()}); return $isRef(___target) ? ___target.value = ${value} : ___target = ${value};`, null, false);\n}\n\nfunction execute(scope: any, exp: string, el?: Node, flatRefs = true) {\n const newScope = flatRefs ? flattenRefs(scope) : scope;\n const fn = evalFuncCache[exp] || (evalFuncCache[exp] = toFunction(exp));\n\n try {\n return fn(newScope, el);\n } catch (e) {\n console.warn(`Error evaluating expression: \"${exp}\":`);\n console.error(e);\n }\n}\n\n// Function to convert expression strings to functions\nfunction toFunction(exp: string) {\n try {\n return new Function(\"$data\", \"$el\", `with($data){${exp}}`);\n } catch (e) {\n console.error(`${(e as Error).message} in expression: ${exp}`);\n return () => {};\n }\n}\n\n// Map all ref properties in scope to their `.value`\nfunction flattenRefs(scope: any): any {\n const mapped = {};\n\n for (const key in scope) {\n if (scope.hasOwnProperty(key)) {\n // Check if the value is a Ref\n if (isRef(scope[key])) {\n mapped[key] = scope[key].value;\n } else {\n mapped[key] = scope[key];\n }\n }\n }\n return mapped;\n}\n", "import { App } from \".\";\nimport { ref } from \"./reactivity/ref\";\nimport { html } from \"./util\";\n\n// ------------------------------------------------\n// Slots, multiple default and named, :if and :for\n// const card = {\n// template: html`
\n//

\n// \n//
`,\n// };\n\n// const main = {\n// template: html`\n//
\n//

card below

\n// \n// card title\n// \n// \n//
\n// `,\n// };\n\n// const app = new App();\n// app.register(\"card\", card);\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// Slots, multiple default and named, :if and :for\n// const app = new App();\n\n// const parent = {\n// template: html`\n//
\n//

parent

\n// \n// \n//
\n//
\n//
1
\n//
2
\n//
3
\n//
\n//
\n// content 1 always shown\n//
\n// content 2, animals:\n//
animal: {{animal}}
\n//
\n\n// \n// \n//
\n//
\n// `,\n// main() {\n// const bool = ref(true);\n// const animals = reactive([\"dog\", \"cat\", \"bear\"]);\n\n// setInterval(() => {\n// bool.value = !bool.value;\n// }, 2000);\n\n// return { bool, animals };\n// },\n// };\n// const card = {\n// template: html`
\n//

card

\n//

\n// \n//
`,\n// };\n// app.register(\"card\", card);\n// const parentBlock = app.mount(parent, \"body\");\n// const cardBlock = parentBlock.context.blocks[0];\n\n// ------------------------------------------------\n// Component pros, mirror and spread, bind and no bind\n// const child = {\n// template: html`
Animal: {{animal}} {{index}}
`,\n// props: { animal: { default: \"cat\" }, index: { default: 0 } },\n// main({ animal, index }) {\n// return { animal, index };\n// },\n// };\n\n// const parent = {\n// template: html`\n//
\n// \n// mirror, no bind:\n// \n//
\n// mirror, bind:\n// \n//
\n// spread, no bind:\n// \n//
\n// spread, bind:\n// \n//
\n// regular prop:\n// \n//
\n// regular prop, bind:\n// \n//
\n//
div has \"id\" set to animal.value
\n//
\n//
div has \"id\" set and bound to animal.value
\n//
\n//
div has \"animal\" set to animal.value
\n//
\n//
div has \"animal\" set and bound to animal.value
\n//
\n//
div has \"animal\" spread
\n//
\n//
div has \"animal\" spread and bound
\n//
\n//
\n//
\n//
\n// if bool, mirror, no bind:\n// \n// if bool, mirror, bind:\n// \n//
\n// for list, mirror, no bind:\n// \n//
\n// for list, mirror, bind:\n// \n// if bool, for list, mirror, no bind: these have the value \"DOG!\" because by the time for :for directive is evaluated, animal.value is \"DOG!\", and no longer \"dog\".\n//
\n// \n//
\n//
\n// `,\n// main() {\n// const bool = ref(false);\n// const animal = ref(\"dog\");\n// const spread = reactive({ animal: \"panther\" });\n// const list = reactive([1, 2, 3]);\n\n// setTimeout(() => {\n// spread.animal = \"PANTHER!\";\n// animal.value = \"DOG!\";\n// bool.value = true;\n// }, 500);\n\n// setTimeout(() => {\n// animal.value = \"DOG!!!!!\";\n// }, 1000);\n\n// return { animal, spread, bool, list };\n// },\n// };\n\n// const app = new App();\n// app.register(\"child\", child);\n// app.mount(parent, \"#app\");\n\n// ------------------------------------------------\n// Event directive\n// const counter = {\n// template: html`\n//
\n//
true
\n//

Count: {{count}}{{count >= 2 ? '!!!' : ''}}

\n// \n// \n//
\n// `,\n// main() {\n// const count = ref(0);\n// const style = reactive({ color: \"gray\" });\n// const increment = () => count.value++;\n// const decrement = () => count.value--;\n\n// setInterval(() => {\n// style.color = style.color === \"gray\" ? \"white\" : \"gray\";\n// }, 500);\n\n// return { count, increment, decrement, style };\n// },\n// };\n\n// const app = new App();\n// app.mount(counter, \"#app\");\n\n// ------------------------------------------------\n// Template\n// const main = {\n// template: html`\n//
\n//
\n//
{{item}}
\n//
\n//
\n// `,\n// main() {\n// const items = reactive([1, 2, 3, 4, 5]);\n// const bool = ref(true);\n// setInterval(() => (bool.value = !bool.value), 250);\n// return { items, bool };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// :html\n// const main = {\n// template: html`
`,\n// main() {\n// const html = ref(\"

hello

\");\n\n// setTimeout(() => {\n// if (html.value === \"

hello

\") {\n// html.value = \"

world

\";\n// }\n// }, 1000);\n\n// return { html };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// Colors from css framework\n// const main = {\n// template: html`\n//
\n//

Colors

\n// \n//
\n//
\n//
{{variant}}-{{rank}}
\n//
\n//
\n//
\n//
\n// `,\n// main() {\n// const ranks = reactive([\"5\", \"10\", \"20\", \"30\", \"40\", \"50\", \"60\", \"70\", \"80\", \"90\"]);\n// const basesReverse = computed(() => Array.from(ranks).reverse());\n// const bg = (variant: string, rank: string, index: number) => ({ backgroundColor: `var(--${variant}-${rank})`, color: `var(--${variant}-${basesReverse.value[index]})` });\n\n// return { ranks, bg };\n// },\n// };\n\n// const app = new App();\n// app.mount(main, \"#app\");\n\n// ------------------------------------------------\n// :scope\nconst child = {\n template: html`\n
\n hello from child, food: \"{{food}}\" (does not inherit)\n
\n \n
\n
\n `,\n main() {\n const food = ref(\"\uD83C\uDF54\");\n return { food };\n },\n};\n\nconst main = {\n template: html`\n
\n
\n \n
Scoped data: {{food}}
\n Child slot, food: {{food}}\n
No pizza \uD83D\uDE22
\n
Pizza!
\n
\n
\n `,\n main() {\n return { food: ref(\"nothing\") };\n },\n};\n\nconst app = new App();\napp.register(\"child\", child);\napp.mount(main, \"#app\");\n"], + "mappings": ";AAEO,SAAS,gBAAgB,UAA2B;AACzD,QAAM,SAAS,IAAI,UAAU;AAC7B,QAAM,MAAM,OAAO,gBAAgB,UAAU,WAAW;AACxD,SAAO,IAAI,KAAK;AAClB;AAEO,IAAM,SAAS,CAAC,SAA6B;AAClD,SAAO,KAAK,aAAa,KAAK;AAChC;AAEO,IAAM,aAAa,CAAC,SAA4C;AACrE,SAAO,KAAK,aAAa;AAC3B;AAEO,IAAM,YAAY,CAAC,SAAgC;AACxD,SAAO,KAAK,aAAa,KAAK;AAChC;AAEO,SAAS,SAAS,OAA6B;AACpD,SAAO,UAAU,QAAQ,OAAO,UAAU;AAC5C;AAEO,SAAS,QAAQ,OAA4B;AAClD,SAAO,MAAM,QAAQ,KAAK;AAC5B;AAEO,SAAS,wBAAwB,IAAa,UAAiC;AAEpF,QAAM,iBAAiB,GAAG,aAAa,QAA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AAS,SAAS,KAAK;AAC3B,IAAI,MAAM,MAAM,MAAM;", "names": ["node", "element", "_", "ctx", "ref", "i", "exp", "el", "effect", "stop", "ref", "value", "App", "app", "node", "context", "next", "child", "App"] } diff --git a/public/index.css.br b/public/index.css.br new file mode 100644 index 0000000000000000000000000000000000000000..37e597fe5a4712c78e94f04d2153c64c55e176f0 GIT binary patch literal 9650 zcmb`NWl$Yox8`vO90=|Z+~q)UcZUGM-3}1k-Q8V+I|O%kmxF7_!QCYUCvdrQ>(0FY zcfQ=3nyRkVUER-KyLZ=GYyWn42dXB`>nb(R zId~o|`8B)j_rSWd8MPXq=hc+S5c_7;syCDKUUlipdly*Nbg-Mwer$XJl4Wz)D3;k6 zAoZ>I9KqkvLwC89E8Q|^i2^S$MSn5!t z_&}APpAoeQc|pGf$dUPiO%57xRaVFN%rd+lu$=uHu~Qig{plk~)I8%hr-=pNT-lJz zmntxs{`erG9>u#v3z;(O%rYjR33e5sqam~ug}v~UHpDRIALX@SK-ttTQYus(Jb)kh z77g^|@ksmwj4hsv|71LHW&2l6iXkV<1o|aw1`2_?t2x?tUS z&E=MK2G~jg5uB7a&-zc!2QVk|6X)vLop>ElHkpnpo=cuP--O2GH}%@gXICgiT%8p@ zhH&m`hH+x?5;R#$TM)6T^Pxlx`BPa>@aiCQeC(}QT(fevq+{T3? zqa%DvHU+RZ)zJ%B4R8SoQYU zc?%~DWB2l-RuLUzuPIZ3pTn;OoGjHFQ%j5PF&f)`=hHCJR#F4S-VwbGJ%+Qc++6Dx zM9>W?A&SJ~u%9nlj{7d4)BCo-d2uMo5D{8-r$3sFb**Q7vAe6B#Lt~d%lcX^?pM*!(|ca;a8 zgdM_p$J{D{s%uA{6pW$8tNu-<#LQ!H$sBj{Z0u0Z1Aeyact(0ha$7Py?UiW~{HIj| z>YDqlYN4d;{ot{T&}&o0(sl1f>ieav0mPWkLK;=FL=z|XK7GH2?o>m(zjig|1Jd&t z@`08|lW?5Qqp7NLpYVQkGQrG;MJ|)c1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)|<(Keg^iMsuFVzTCVU)(|J z_e0I*K+A#Xux~%Z_%nK@IM#?t?Z+`l*1`VE#-0V);^3QG!3~5bUYLw(GScK*8W-&G zhDM$txxY8EXUrsOy7qr0R=PmxbRUxIbgYzd;YNnN`uEz6g$;G3CQvvR&*=7-N>O|RK5Py#% zIQ3vNm(W|==j}xZj6$G`b3rT|URzn0`}&m|vaeTH$NJh)IGWsfxX(sjUhS!sG|vt* z`FIWK+8>;tYH}j%eWeDkt|Uv)s`vFp)Lgsr5WN`!ZO83lB-ayWh$;ZuFB%2$P%o4t zOQS00>t__z3RM9LB4Wvp3~hep`y$5j2o;f7N8eAtjB0+n^ z`rVU{b)2n37&V8oclijxT5E; literal 0 HcmV?d00001 diff --git a/public/index.js b/public/index.js index c6c882c..867e573 100755 --- a/public/index.js +++ b/public/index.js @@ -1,5 +1 @@ -function re(t){return new DOMParser().parseFromString(t,"text/html").body.firstChild}var oe=t=>t.nodeType===Node.TEXT_NODE,qe=t=>t.nodeName==="TEMPLATE",W=t=>t.nodeType===Node.ELEMENT_NODE;function R(t){return t!==null&&typeof t=="object"}function ge(t){return Array.isArray(t)}function N(t,e){let n=t.getAttribute(e);return n!==null&&t.removeAttribute(e),n}function ye(t){let e=[],n=r=>{Array.from(r.childNodes).forEach(o=>{W(o)&&(o.nodeName==="SLOT"&&e.push({node:o,name:o.getAttribute("name")||"default"}),o.hasChildNodes()&&n(o))})};return n(t),e}function ve(t){let e=[];return(r=>{let o=[];if(Array.from(r.childNodes).forEach(s=>{(W(s)||oe(s))&&(W(s)&&s.nodeName==="TEMPLATE"&&qe(s)?e.push({targetSlotName:s.getAttribute("slot")||"",node:s}):o.push(s))}),o.length>0){let s=document.createElement("template");s.setAttribute("slot","default"),o.forEach(i=>{s.content.appendChild(i)}),e.push({targetSlotName:"default",node:s})}})(t),e}var Ee=async t=>{await new Promise(e=>setTimeout(n=>requestAnimationFrame(r=>{t&&t(),e()})))};function be(t,...e){let n=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],r=t.reduce((o,s,i)=>o+s+(e[i]||""),"");return r=r.replace(/<([a-zA-Z][^\s/>]*)\s*([^>]*?)\/>/g,(o,s,i)=>n.includes(s.toLowerCase())?o:`<${s} ${i}>`),r}function z(t){return t==null?"":R(t)?JSON.stringify(t,null,2):String(t)}function ie(t,e){e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e?.parentNode?.appendChild(t)}function we(t){return!!(t.startsWith(".")||t.startsWith("{")&&t.endsWith("}"))}function se(t){return t.startsWith("...")}function J(t){return t.startsWith("{")&&t.endsWith("}")}function Ce(t){return t.startsWith(".")}function Re(t){return t.startsWith("@")}function Te(t,e){return Object.keys(e?.props??{}).some(n=>n===t)}function ae(t){return t.replace(/^\.\.\./,"").replace(/^\./,"").replace(/^{/,"").replace(/}$/,"").replace(/:bind$/,"")}function ze(t){return t.toLowerCase().replace(/-([a-z])/g,e=>e[1].toUpperCase())}function X(t){return ze(ae(t))}function ce(t){let e=[];for(let n=0;n!this.previousClasses.includes(s)).filter(Boolean),o=this.previousClasses.filter(s=>!n.includes(s));r.forEach(s=>{this.previousClasses.push(s),this.element.classList.add(s)}),o.forEach(s=>{this.previousClasses=this.previousClasses.filter(i=>i!==s),this.element.classList.remove(s)})}else if(typeof e=="object"&&this.extractedAttributeName==="style"){console.log("value is object",e);let n=Object.keys(e),r=Object.keys(this.previousStyles).filter(o=>!n.includes(o));n.forEach(o=>{this.previousStyles[o]=e[o],this.element.style[o]=e[o]}),r.forEach(o=>{this.previousStyles[o]="",this.element.style[o]=""}),this.previousStyles=e}else this.element.setAttribute(this.extractedAttributeName,e)}};var Q=class{element;context;expression;attr;eventCount=0;constructor({element:e,context:n,attr:r}){this.element=e,this.context=n,this.expression=r.value,this.attr=r;let s=r.name.replace(/^@/,"").split(".");this.element.addEventListener(s[0],i=>{if(s.includes("prevent")&&i.preventDefault(),s.includes("stop")&&i.stopPropagation(),s.includes("once")&&this.eventCount>0)return;this.eventCount++;let a=m(n.scope,r.value);typeof a=="function"&&a(i)}),e.removeAttribute(r.name)}};var Je=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,ke=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Xe=/^\(|\)$/g,Ze=/^[{[]\s*((?:[\w_$]+\s*,?\s*)+)[\]}]$/,Ne=(t,e,n,r,o,s)=>{let i=e.match(Je);if(!i){console.warn(`invalid :for expression: ${e}`);return}let a=t.nextSibling,c=t.parentElement,l=new Text("");c.insertBefore(l,t),c.removeChild(t);let f=i[2].trim(),u=i[1].trim().replace(Xe,"").trim(),d,h=!1,x,E,p="key",w=t.getAttribute(p)||t.getAttribute(p=":key")||t.getAttribute(p=":key:bind");w&&(t.removeAttribute(p),p==="key"&&(w=JSON.stringify(w)));let T;(T=u.match(ke))&&(u=u.replace(ke,"").trim(),x=T[1].trim(),T[2]&&(E=T[2].trim())),(T=u.match(Ze))&&(d=T[1].split(",").map(g=>g.trim()),h=u[0]==="[");let _=!1,C,O,k,j=g=>{let S=new Map,y=[];if(ge(g))for(let v=0;v{let b={};d?d.forEach((D,L)=>b[D]=S[h?L:D]):b[u]=S,v?(x&&(b[x]=v),E&&(b[E]=y)):x&&(b[x]=y);let H=Ae(n,b),M=w?m(H.scope,w):y;return g.set(M,y),H.key=M,H},q=(g,S)=>{let y=new A({element:t,parentContext:g,replacementType:"replace",component:r,componentProps:o,allProps:s});return y.key=g.key,y.insert(c,S),y};return n.effect(()=>{let g=m(n.scope,f),S=k;if([O,k]=j(g),!_)C=O.map(y=>q(y,l)),_=!0;else{for(let M=0;M{d&&(i.insertBefore(a,d.element),d.remove(),d=void 0)};return n.effect(()=>{for(let E=0;E{let s=o.slice(2,-2).trim();r.forEach(i=>{let a=(c=s)=>m(this.context.scope,c,i);n.effect(()=>{i.textContent=z(a())})})})}findNodes(){let e=this.element.textContent.trim();if(e?.match(Qe)){let n=e.split(/(\{\{\s?[^}]+\s?\}\})/g).filter(Boolean);if(n){let r=this.element;for(let o=0;o{o.appendChild(t);let s=new MutationObserver(i=>{i.forEach(a=>{a.removedNodes.forEach(c=>{c.contains(r)&&(t.remove(),s.disconnect())})})});s.observe(document.body,{childList:!0,subtree:!0}),new A({element:t,parentContext:n})}),r}function Pe(t){return t instanceof HTMLInputElement}function Be(t){return t instanceof HTMLTextAreaElement}function Oe(t){return t instanceof HTMLSelectElement}var te=class{element;context;expression;inputType;constructor({element:e,context:n,expression:r}){if(this.element=e,this.context=n,this.expression=r,this.inputType=e.getAttribute("type"),Pe(e))switch(this.inputType){case"text":case"password":case"number":case"color":e.addEventListener("input",()=>{let o=this.inputType==="number"?e.value?parseFloat(e.value):0:e.value;I(this.context.scope,r,o)});break;case"checkbox":e.addEventListener("change",o=>{I(this.context.scope,r,!!o.currentTarget.checked)});break;case"radio":e.addEventListener("change",o=>{o.currentTarget.checked&&I(this.context.scope,r,e.getAttribute("value"))});break;default:break}Be(e)&&e.addEventListener("input",()=>{I(this.context.scope,r,e.value)}),Oe(e)&&e.addEventListener("change",()=>{I(this.context.scope,r,e.value)}),n.effect(this.updateElementValue.bind(this))}updateElementValue(){let e=m(this.context.scope,this.expression,this.element);if(Pe(this.element))switch(this.inputType){case"text":case"password":case"number":case"color":this.element.value=e;break;case"checkbox":this.element.checked=!!e;break;case"radio":this.element.checked=this.element.value===e;break;default:break}Be(this.element)&&(this.element.value=e),Oe(this.element)&&(this.element.value=e)}};var le=new WeakMap,G=[];function ne(t,e){let n=G[G.length-1];if(!n)return;let r=le.get(t);r||le.set(t,r=new Map);let o=r.get(e);o||r.set(e,o=new Set),o.has(n)||(o.add(n),n.refs.push(o))}function K(t,e){let n=le.get(t);if(!n)return;let r=new Set;n.get(e)?.forEach(o=>{r.add(o)}),r.forEach(pe)}function Le(t){t.active&&_e(t),t.active=!1}function $e(t){t.active||(t.active=!0,pe(t))}function pe(t){if(!t.active||G.includes(t))return;_e(t);let e;try{G.push(t),e=t.handler()}finally{G.pop()}return e}function _e(t){let{refs:e}=t;if(e.length)for(let n of e)n.delete(t);e.length=0}function fe(t,e={}){let{lazy:n}=e,r={active:!n,handler:t,refs:[]};return pe(r),{start:()=>{$e(r)},stop:()=>{Le(r)},toggle:()=>(r.active?Le(r):$e(r),r.active)}}var Ye=Symbol("computed");function U(t){return R(t)&&t[Ye]}var je=Symbol("ref");function $(t){return R(t)&&!!t[je]}function De(t=null){if(R(t))return $(t)?t:P(t);let e={value:t,[je]:!0};return new Proxy(e,{get(n,r,o){let s=Reflect.get(n,r,o);return ne(e,"value"),s},set(n,r,o){return n[r]!==o&&Reflect.set(n,r,o)&&K(e,"value"),!0}})}var Fe=Symbol("reactive");function P(t){return R(t)?t[Fe]?t:(t[Fe]=!0,Object.keys(t).forEach(e=>{R(t[e])&&(t[e]=P(t[e]))}),new Proxy(t,et())):De(t)}function et(){return{deleteProperty(t,e){let n=Reflect.has(t,e),r=Reflect.deleteProperty(t,e);return n&&K(t,e),r},get(t,e){return ne(t,e),Reflect.get(t,e)},set(t,e,n){if(t[e]===n)return!0;let r=!1;return R(n)&&!R(t[e])&&(r=!0),Reflect.set(t,e,n)&&K(t,e),r&&(t[e]=P(t[e])),!0}}}function tt(t){for(var e=[],n=0;n=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95){o+=t[s++];continue}break}if(!o)throw new TypeError("Missing parameter name at "+n);e.push({type:"NAME",index:n,value:o}),n=s;continue}if(r==="("){var a=1,c="",s=n+1;if(t[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,r=0,o=n.exec(t.source);o;)e.push({name:o[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),o=n.exec(t.source);return t}function ot(t,e,n){var r=t.map(function(o){return ue(o,e,n).source});return new RegExp("(?:"+r.join("|")+")",He(n))}function it(t,e,n){return st(nt(t,n),e,n)}function st(t,e,n){n===void 0&&(n={});for(var r=n.strict,o=r===void 0?!1:r,s=n.start,i=s===void 0?!0:s,a=n.end,c=a===void 0?!0:a,l=n.encode,f=l===void 0?function(k){return k}:l,u="["+V(n.endsWith||"")+"]|$",d="["+V(n.delimiter||"/#?")+"]",h=i?"^":"",x=0,E=t;x-1:C===void 0;o||(h+="(?:"+d+"(?="+u+"))?"),O||(h+="(?="+d+"|"+u+")")}return new RegExp(h,He(n))}function ue(t,e,n){return t instanceof RegExp?rt(t,e):Array.isArray(t)?ot(t,e,n):it(t,e,n)}function Ie(t){return $(t)||U(t)?t.value:typeof t=="function"?t():t}var he=new Set,at={template:be` - - LINK - - `,props:{href:{default:"#"}},main({href:t}){let e=r=>{r.preventDefault(),he.forEach(o=>{o.doRouteChange(Ie(t))})},n=P({"router-link":!0});return{go:e,classes:n,href:t}}};async function ct(t){return await t()}var lt=async t=>t.beforeEnter?await ct(t.beforeEnter):!0,pt=t=>{t.redirectTo&&he.forEach(e=>e.doRouteChange(t.redirectTo))},me=class{app;routes=[];pathExpressions=new Map;lastPath="/";knownRouterViews=new Map;knownRouterViewNames=new Map;populatedRouterViews=new Map;constructor(e=[]){this.routes=e}use(e,...n){this.app=e,this.app.register("router-link",at),window.addEventListener("popstate",this.onHistoryEvent.bind(this)),window.addEventListener("pushstate",this.onHistoryEvent.bind(this)),window.addEventListener("load",this.onHistoryEvent.bind(this));for(let r of this.routes)this.cacheRouteExpression(r);this.lastPath=`${location.pathname}${location.search}`,window.history.replaceState({},"",this.lastPath),he.add(this)}compile(e){e.nodeType===Node.ELEMENT_NODE&&e.nodeName==="ROUTER-VIEW"&&!this.knownRouterViews.has(e)&&B.componentBlock&&(this.knownRouterViews.set(e,B.componentBlock),this.knownRouterViewNames.set(e.getAttribute("name")?.trim()||"",e))}onHistoryEvent(e){e.preventDefault(),e.stopImmediatePropagation();let n=new URL(e.currentTarget.location.href).pathname;e.type==="load"?window.history.replaceState({},"",this.lastPath):e.type==="pushstate"?window.history.replaceState({},"",n):e.type==="popstate"&&window.history.replaceState({},"",n),this.lastPath=n;let r=this.getMatchesForURL(n);this.applyMatches(r)}doRouteChange(e){window.history.pushState({},"",e);let n=this.getMatchesForURL(`${location.pathname}${location.search}`);this.applyMatches(n)}getMatchesForURL(e){let n=[],r=(o,s="",i=[])=>{let a=[];for(let c of o){a.push(c);let l=`${s}${c.path}`.replace(/\/\//g,"/"),f=this.getPathMatch(l,e);f&&n.push({match:f,parents:[...i,...a]}),c.children?.length&&(r(c.children,l,[...i,...a]),a=[])}return n};return n=r(this.routes),n}getRouteExpression(e,n){if(this.pathExpressions.has(e))return this.pathExpressions.get(e);let r=[],s={regex:ue(e,r,{strict:!1,sensitive:!1,end:!0}),params:r,path:e,route:n};return this.pathExpressions.set(e,s),s}getPathMatch(e,n){return this.pathExpressions.get(e)&&this.pathExpressions.get(e).regex.exec(n)?this.pathExpressions.get(e):null}async applyMatches(e){if(!e)return;let n=new Set,r=async(i,a)=>{for(let c of i)if(c.view){let l=this.knownRouterViewNames.get(c.view);if(l&&await o(l,c))continue}else if(a&&await o(a,c))continue},o=async(i,a)=>await lt(a)?(s(i,a),!0):(a.componentFallback?s(i,a,a.componentFallback):pt(a),!1),s=(i,a,c)=>{if(!n.has(i)||this.populatedRouterViews.get(i)?.route!==a){let l=document.createElement("div");i.replaceChildren(l);let f=l.parentElement,u=new A({element:l,component:c||a.component,replacementType:"replaceChildren",parentContext:B.componentBlock.context});f.replaceChild(u.element,l),this.populatedRouterViews.set(i,{block:u,route:a}),n.add(i)}};for(let i of e){let c=[...i.parents,i.match.route].filter((f,u,d)=>u===d.findIndex(h=>h.path===f.path)),l=this.knownRouterViewNames.get("")??null;await r(c,l)}for(let i of this.knownRouterViews.keys())if(!n.has(i)&&this.populatedRouterViews.has(i)){let a=this.populatedRouterViews.get(i);a&&(a.block.teardown(),this.populatedRouterViews.delete(i))}}cacheRouteExpression(e,n=""){let r=`${n}${e.path}`.replace(/\/\//g,"/");this.getRouteExpression(r,e),e.children?.length&&e.children.forEach(o=>{this.cacheRouteExpression(o,r)})}destroy(){window.removeEventListener("popstate",this.onHistoryEvent.bind(this)),window.removeEventListener("pushstate",this.onHistoryEvent.bind(this)),window.removeEventListener("load",this.onHistoryEvent.bind(this))}};function Fn(t,e){B.componentBlock||console.warn("Can't provide: no current component block"),B.componentBlock.provides.set(t,e)}function Hn(t){B.componentBlock||console.warn("Can't inject: no current component block");let e=B.componentBlock;for(;e;){if(e.provides.has(t))return e.provides.get(t);e=e.parentComponentBlock}}var Ve=class{rootBlock;registry=new Map;plugins=new Set;register(e,n){this.registry.set(e,n)}use(e,...n){this.plugins.add(e),e.use(this,...n)}getComponent(e){return this.registry.get(e)}mount(e,n="body",r={}){let o=typeof n=="string"?document.querySelector(n):n,s=o.style.display;return o.style.display="none",this.rootBlock=this._mount(e,o,r,!0),o.style.display=s,this.rootBlock}_mount(e,n,r,o=!1){let s=xe({app:this});return r&&(s.scope=P(r),Ge(s.scope)),s.scope.$isRef=$,s.scope.$isComputed=U,new A({element:n,parentContext:s,component:e,isRoot:o,componentProps:r,replacementType:"replaceChildren"})}unmount(){this.rootBlock.teardown()}};function xe({parentContext:t,app:e}){let n={app:e||(t&&t.app?t.app:null),scope:P({}),blocks:[],effects:[],slots:[],templates:t?t.templates:[],effect:r=>{let o=fe(r);return n.effects.push(o),o}};return n}var Ae=(t,e={})=>{let n=t.scope,r=Object.create(n);Object.defineProperties(r,Object.getOwnPropertyDescriptors(e));let o;return o=P(new Proxy(r,{set(i,a,c,l){return l===o&&!i.hasOwnProperty(a)?Reflect.set(n,a,c):Reflect.set(i,a,c,l)}})),Ge(o),{...t,scope:{...t.scope,...o}}};function Ge(t){for(let e of Object.keys(t))typeof t[e]=="function"&&(t[e]=t[e].bind(t))}function ft(t,e){let n={};return Object.keys(e).forEach(r=>{let o=t.hasOwnProperty(r)?t[r]:e[r]?.default;n[r]=P(typeof o=="function"?o():o)}),n}var B={componentBlock:void 0},A=class{element;context;parentContext;component;provides=new Map;parentComponentBlock;componentProps;allProps;isFragment;start;end;key;constructor(e){this.isFragment=e.element instanceof HTMLTemplateElement,this.parentComponentBlock=e.parentComponentBlock,e.component?(B.componentBlock=this,this.element=re(e.component.template)):this.isFragment?this.element=e.element.content.cloneNode(!0):typeof e.element=="string"?this.element=re(e.element):(this.element=e.element.cloneNode(!0),e.element.replaceWith(this.element)),e.isRoot?this.context=e.parentContext:(this.parentContext=e.parentContext?e.parentContext:xe({}),this.parentContext.blocks.push(this),this.context=xe({parentContext:e.parentContext})),e.component&&(this.componentProps=ft(e.componentProps??{},e.component.props??{}),e.component.main&&(this.context.scope={...e.component.main(this.componentProps)||{}})),e.allProps?.forEach(n=>{n.isBind&&this.context.effect(()=>{let r;if(n.isSpread){let o=m(this.parentContext.scope,n.extractedName);R(o)&&Object.keys(o).forEach(s=>{r=o[s],this.setProp(s,r)})}else r=n.isMirror?m(this.parentContext.scope,n.extractedName):m(this.parentContext.scope,n.exp),this.setProp(n.extractedName,r)})}),this.context.slots=ye(this.element),this.context.templates=e.templates??[],this.context.slots.forEach(n=>{let r=this.context.templates.find(o=>o.targetSlotName===n.name);if(r){let o=r.node.content.cloneNode(!0);n.node.replaceWith(o)}}),this.context.scope.$isRef=$,this.context.scope.$isComputed=U,Ke(this.element,this.context),e.component&&(e.replacementType==="replace"?e.element instanceof HTMLElement&&e.element.replaceWith(this.element):e.element instanceof HTMLElement&&e.element.replaceChildren(this.element))}setProp(e,n){$(this.componentProps[e])?this.componentProps[e].value=n:this.componentProps[e]=n}insert(e,n=null){if(this.isFragment)if(this.start){let r=this.start,o;for(;r&&(o=r.nextSibling,e.insertBefore(r,n),r!==this.end);)r=o}else this.start=new Text(""),this.end=new Text(""),e.insertBefore(this.end,n),e.insertBefore(this.start,this.end),e.insertBefore(this.element,this.end);else e.insertBefore(this.element,n)}remove(){if(this.parentContext){let e=this.parentContext.blocks.indexOf(this);e>-1&&this.parentContext.blocks.splice(e,1)}if(this.start){let e=this.start.parentNode,n=this.start,r;for(;n&&(r=n.nextSibling,e.removeChild(n),n!==this.end);)n=r}else this.element.remove();this.teardown()}teardown(){this.context.blocks.forEach(e=>{e.teardown()}),this.context.effects.forEach(stop)}};function ut(t,e){return!!e.app.getComponent(t.tagName.toLowerCase())}function de(t,e){return e.every(n=>t.hasAttribute(n))?(console.warn("These directives cannot be used together on the same node:",e),console.warn("Node ignored:",t),!0):!1}function Ke(t,e){if(oe(t)){new Y({element:t,context:e});return}if(W(t)){let n,r=(i,a,c,l,f)=>{if(!de(i,[":if",":for"])&&!de(i,[":if",":teleport"])&&!de(i,[":for",":teleport"])){if(n=N(i,":scope")){let u=m(a.scope,n);typeof u=="object"&&Object.assign(a.scope,u)}if(n=N(i,":teleport"))return Me(i,n,a);if(n=N(i,":if"))return Se(i,n,a,c,l,f);if(n=N(i,":for"))return Ne(i,n,a,c,l,f);(n=N(i,":show"))&&new ee({element:i,context:a,expression:n}),(n=N(i,":ref"))&&(a.scope[n].value=i),(n=N(i,":value"))&&new te({element:i,context:a,expression:n}),(n=N(i,":html"))&&a.effect(()=>{let u=m(a.scope,n);u instanceof Element?(i.replaceChildren(),i.append(u)):i.innerHTML=u}),(n=N(i,":text"))&&a.effect(()=>{i.textContent=z(m(a.scope,n))})}},o=(i,a)=>Array.from(i.attributes).filter(c=>se(c.name)||J(c.name)||Ce(c.name)&&Te(X(c.name),a)).map(c=>({isMirror:J(c.name),isSpread:se(c.name),isBind:c.name.includes("bind"),originalName:c.name,extractedName:X(c.name),exp:c.value,value:J(c.name)?m(e.scope,X(c.name)):c.value?m(e.scope,c.value):void 0}));if(ut(t,e)){let i=e.app.getComponent(t.tagName.toLowerCase()),a=o(t,i),c=a.reduce((u,{isSpread:d,isMirror:h,extractedName:x,value:E})=>{if(d){let p=m(e.scope,x);R(p)&&Object.assign(u,p)}else h?u[x]=m(e.scope,x):u[x]=E;return u},{}),l=r(t,e,i,c,a);if(l)return l;let f=ve(t);return new A({element:t,parentContext:e,component:i,replacementType:"replace",parentComponentBlock:B.componentBlock,templates:f,componentProps:c,allProps:a}).element}let s=r(t,e);if(s)return s;Array.from(t.attributes).forEach(i=>{we(i.name)&&new Z({element:t,context:e,attr:i}),Re(i.name)&&new Q({element:t,context:e,attr:i})}),mt(t,e)}}function mt(t,e){let n=t.firstChild;for(;n;)n=Ke(n,e)||n.nextSibling}var We={};function m(t,e,n){if(e.trim())return Ue(t,`const ___value = (${e.trim()}); return ___value;`,n)}function I(t,e,n){return n=typeof n=="string"?`"${n}"`:n,Ue(t,`const ___target = (${e.trim()}); return $isRef(___target) ? ___target.value = ${n} : ___target = ${n};`,null,!1)}function Ue(t,e,n,r=!0){let o=r?dt(t):t,s=We[e]||(We[e]=ht(e));try{return s(o,n)}catch(i){console.warn(`Error evaluating expression: "${e}":`),console.error(i)}}function ht(t){try{return new Function("$data","$el",`with($data){${t}}`)}catch(e){return console.error(`${e.message} in expression: ${t}`),()=>{}}}function dt(t){let e={};for(let n in t)t.hasOwnProperty(n)&&($(t[n])?e[n]=t[n].value:e[n]=t[n]);return e}export{Ve as App,A as Block,me as RouterPlugin,xe as createContext,Ae as createScopedContext,B as current,m as evalGet,I as evalSet,Hn as inject,Fn as provide}; +function re(t){return new DOMParser().parseFromString(t,"text/html").body.firstChild}var oe=t=>t.nodeType===Node.TEXT_NODE,qe=t=>t.nodeName==="TEMPLATE",W=t=>t.nodeType===Node.ELEMENT_NODE;function R(t){return t!==null&&typeof t=="object"}function ge(t){return Array.isArray(t)}function N(t,e){let n=t.getAttribute(e);return n!==null&&t.removeAttribute(e),n}function ye(t){let e=[],n=r=>{Array.from(r.childNodes).forEach(o=>{W(o)&&(o.nodeName==="SLOT"&&e.push({node:o,name:o.getAttribute("name")||"default"}),o.hasChildNodes()&&n(o))})};return n(t),e}function ve(t){let e=[];return(r=>{let o=[];if(Array.from(r.childNodes).forEach(s=>{(W(s)||oe(s))&&(W(s)&&s.nodeName==="TEMPLATE"&&qe(s)?e.push({targetSlotName:s.getAttribute("slot")||"",node:s}):o.push(s))}),o.length>0){let s=document.createElement("template");s.setAttribute("slot","default"),o.forEach(i=>{s.content.appendChild(i)}),e.push({targetSlotName:"default",node:s})}})(t),e}var Ee=async t=>{await new Promise(e=>setTimeout(n=>requestAnimationFrame(r=>{t&&t(),e()})))};function be(t,...e){let n=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],r=t.reduce((o,s,i)=>o+s+(e[i]||""),"");return r=r.replace(/<([a-zA-Z][^\s/>]*)\s*([^>]*?)\/>/g,(o,s,i)=>n.includes(s.toLowerCase())?o:`<${s} ${i}>`),r}function z(t){return t==null?"":R(t)?JSON.stringify(t,null,2):String(t)}function ie(t,e){e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e?.parentNode?.appendChild(t)}function we(t){return!!(t.startsWith(".")||t.startsWith("{")&&t.endsWith("}"))}function se(t){return t.startsWith("...")}function J(t){return t.startsWith("{")&&t.endsWith("}")}function Ce(t){return t.startsWith(".")}function Re(t){return t.startsWith("@")}function Te(t,e){return Object.keys(e?.props??{}).some(n=>n===t)}function ae(t){return t.replace(/^\.\.\./,"").replace(/^\./,"").replace(/^{/,"").replace(/}$/,"").replace(/:bind$/,"")}function ze(t){return t.toLowerCase().replace(/-([a-z])/g,e=>e[1].toUpperCase())}function X(t){return ze(ae(t))}function ce(t){let e=[];for(let n=0;n!this.previousClasses.includes(s)).filter(Boolean),o=this.previousClasses.filter(s=>!n.includes(s));r.forEach(s=>{this.previousClasses.push(s),this.element.classList.add(s)}),o.forEach(s=>{this.previousClasses=this.previousClasses.filter(i=>i!==s),this.element.classList.remove(s)})}else if(typeof e=="object"&&this.extractedAttributeName==="style"){console.log("value is object",e);let n=Object.keys(e),r=Object.keys(this.previousStyles).filter(o=>!n.includes(o));n.forEach(o=>{this.previousStyles[o]=e[o],this.element.style[o]=e[o]}),r.forEach(o=>{this.previousStyles[o]="",this.element.style[o]=""}),this.previousStyles=e}else this.element.setAttribute(this.extractedAttributeName,e)}};var Q=class{element;context;expression;attr;eventCount=0;constructor({element:e,context:n,attr:r}){this.element=e,this.context=n,this.expression=r.value,this.attr=r;let s=r.name.replace(/^@/,"").split(".");this.element.addEventListener(s[0],i=>{if(s.includes("prevent")&&i.preventDefault(),s.includes("stop")&&i.stopPropagation(),s.includes("once")&&this.eventCount>0)return;this.eventCount++;let a=m(n.scope,r.value);typeof a=="function"&&a(i)}),e.removeAttribute(r.name)}};var Je=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,ke=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Xe=/^\(|\)$/g,Ze=/^[{[]\s*((?:[\w_$]+\s*,?\s*)+)[\]}]$/,Ne=(t,e,n,r,o,s)=>{let i=e.match(Je);if(!i){console.warn(`invalid :for expression: ${e}`);return}let a=t.nextSibling,c=t.parentElement,l=new Text("");c.insertBefore(l,t),c.removeChild(t);let u=i[2].trim(),f=i[1].trim().replace(Xe,"").trim(),d,h=!1,x,E,p="key",w=t.getAttribute(p)||t.getAttribute(p=":key")||t.getAttribute(p=":key:bind");w&&(t.removeAttribute(p),p==="key"&&(w=JSON.stringify(w)));let T;(T=f.match(ke))&&(f=f.replace(ke,"").trim(),x=T[1].trim(),T[2]&&(E=T[2].trim())),(T=f.match(Ze))&&(d=T[1].split(",").map(g=>g.trim()),h=f[0]==="[");let _=!1,C,B,k,j=g=>{let S=new Map,y=[];if(ge(g))for(let v=0;v{let b={};d?d.forEach((D,$)=>b[D]=S[h?$:D]):b[f]=S,v?(x&&(b[x]=v),E&&(b[E]=y)):x&&(b[x]=y);let H=Ae(n,b),M=w?m(H.scope,w):y;return g.set(M,y),H.key=M,H},q=(g,S)=>{let y=new A({element:t,parentContext:g,replacementType:"replace",component:r,componentProps:o,allProps:s});return y.key=g.key,y.insert(c,S),y};return n.effect(()=>{let g=m(n.scope,u),S=k;if([B,k]=j(g),!_)C=B.map(y=>q(y,l)),_=!0;else{for(let M=0;M{d&&(i.insertBefore(a,d.element),d.remove(),d=void 0)};return n.effect(()=>{for(let E=0;E{let s=o.slice(2,-2).trim();r.forEach(i=>{let a=(c=s)=>m(this.context.scope,c,i);n.effect(()=>{i.textContent=z(a())})})})}findNodes(){let e=this.element.textContent.trim();if(e?.match(Qe)){let n=e.split(/(\{\{\s?[^}]+\s?\}\})/g).filter(Boolean);if(n){let r=this.element;for(let o=0;o{o.appendChild(t);let s=new MutationObserver(i=>{i.forEach(a=>{a.removedNodes.forEach(c=>{c.contains(r)&&(t.remove(),s.disconnect())})})});s.observe(document.body,{childList:!0,subtree:!0}),new A({element:t,parentContext:n})}),r}function Pe(t){return t instanceof HTMLInputElement}function Oe(t){return t instanceof HTMLTextAreaElement}function Be(t){return t instanceof HTMLSelectElement}var te=class{element;context;expression;inputType;constructor({element:e,context:n,expression:r}){if(this.element=e,this.context=n,this.expression=r,this.inputType=e.getAttribute("type"),Pe(e))switch(this.inputType){case"text":case"password":case"number":case"color":e.addEventListener("input",()=>{let o=this.inputType==="number"?e.value?parseFloat(e.value):0:e.value;I(this.context.scope,r,o)});break;case"checkbox":e.addEventListener("change",o=>{I(this.context.scope,r,!!o.currentTarget.checked)});break;case"radio":e.addEventListener("change",o=>{o.currentTarget.checked&&I(this.context.scope,r,e.getAttribute("value"))});break;default:break}Oe(e)&&e.addEventListener("input",()=>{I(this.context.scope,r,e.value)}),Be(e)&&e.addEventListener("change",()=>{I(this.context.scope,r,e.value)}),n.effect(this.updateElementValue.bind(this))}updateElementValue(){let e=m(this.context.scope,this.expression,this.element);if(Pe(this.element))switch(this.inputType){case"text":case"password":case"number":case"color":this.element.value=e;break;case"checkbox":this.element.checked=!!e;break;case"radio":this.element.checked=this.element.value===e;break;default:break}Oe(this.element)&&(this.element.value=e),Be(this.element)&&(this.element.value=e)}};var le=new WeakMap,G=[];function ne(t,e){let n=G[G.length-1];if(!n)return;let r=le.get(t);r||le.set(t,r=new Map);let o=r.get(e);o||r.set(e,o=new Set),o.has(n)||(o.add(n),n.refs.push(o))}function U(t,e){let n=le.get(t);if(!n)return;let r=new Set;n.get(e)?.forEach(o=>{r.add(o)}),r.forEach(pe)}function $e(t){t.active&&_e(t),t.active=!1}function Le(t){t.active||(t.active=!0,pe(t))}function pe(t){if(!t.active||G.includes(t))return;_e(t);let e;try{G.push(t),e=t.handler()}finally{G.pop()}return e}function _e(t){let{refs:e}=t;if(e.length)for(let n of e)n.delete(t);e.length=0}function ue(t,e={}){let{lazy:n}=e,r={active:!n,handler:t,refs:[]};return pe(r),{start:()=>{Le(r)},stop:()=>{$e(r)},toggle:()=>(r.active?$e(r):Le(r),r.active)}}var Ye=Symbol("computed");function K(t){return R(t)&&t[Ye]}var je=Symbol("ref");function L(t){return R(t)&&!!t[je]}function De(t=null){if(R(t))return L(t)?t:P(t);let e={value:t,[je]:!0};return new Proxy(e,{get(n,r,o){let s=Reflect.get(n,r,o);return ne(e,"value"),s},set(n,r,o){return n[r]!==o&&Reflect.set(n,r,o)&&U(e,"value"),!0}})}var Fe=Symbol("reactive");function P(t){return R(t)?t[Fe]?t:(t[Fe]=!0,Object.keys(t).forEach(e=>{R(t[e])&&(t[e]=P(t[e]))}),new Proxy(t,et())):De(t)}function et(){return{deleteProperty(t,e){let n=Reflect.has(t,e),r=Reflect.deleteProperty(t,e);return n&&U(t,e),r},get(t,e){return ne(t,e),Reflect.get(t,e)},set(t,e,n){if(t[e]===n)return!0;let r=!1;return R(n)&&!R(t[e])&&(r=!0),Reflect.set(t,e,n)&&U(t,e),r&&(t[e]=P(t[e])),!0}}}function tt(t){for(var e=[],n=0;n=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95){o+=t[s++];continue}break}if(!o)throw new TypeError("Missing parameter name at "+n);e.push({type:"NAME",index:n,value:o}),n=s;continue}if(r==="("){var a=1,c="",s=n+1;if(t[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,r=0,o=n.exec(t.source);o;)e.push({name:o[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),o=n.exec(t.source);return t}function ot(t,e,n){var r=t.map(function(o){return fe(o,e,n).source});return new RegExp("(?:"+r.join("|")+")",He(n))}function it(t,e,n){return st(nt(t,n),e,n)}function st(t,e,n){n===void 0&&(n={});for(var r=n.strict,o=r===void 0?!1:r,s=n.start,i=s===void 0?!0:s,a=n.end,c=a===void 0?!0:a,l=n.encode,u=l===void 0?function(k){return k}:l,f="["+V(n.endsWith||"")+"]|$",d="["+V(n.delimiter||"/#?")+"]",h=i?"^":"",x=0,E=t;x-1:C===void 0;o||(h+="(?:"+d+"(?="+f+"))?"),B||(h+="(?="+d+"|"+f+")")}return new RegExp(h,He(n))}function fe(t,e,n){return t instanceof RegExp?rt(t,e):Array.isArray(t)?ot(t,e,n):it(t,e,n)}function Ie(t){return L(t)||K(t)?t.value:typeof t=="function"?t():t}var he=new Set;var at={template:be``,props:{href:{default:"#"}},main({href:t}){let e=r=>{r.preventDefault(),he.forEach(o=>{o.doRouteChange(Ie(t))})},n=P({"router-link":!0});return{go:e,classes:n,href:t}}};async function ct(t){return await t()}var lt=async t=>t.beforeEnter?await ct(t.beforeEnter):!0,pt=t=>{t.redirectTo&&he.forEach(e=>e.doRouteChange(t.redirectTo))},me=class{app;routes=[];pathExpressions=new Map;lastPath="/";knownRouterViews=new Map;knownRouterViewNames=new Map;populatedRouterViews=new Map;constructor(e=[]){this.routes=e}use(e,...n){this.app=e,this.app.register("router-link",at),window.addEventListener("popstate",this.onHistoryEvent.bind(this)),window.addEventListener("pushstate",this.onHistoryEvent.bind(this)),window.addEventListener("load",this.onHistoryEvent.bind(this));for(let r of this.routes)this.cacheRouteExpression(r);this.lastPath=`${location.pathname}${location.search}`,window.history.replaceState({},"",this.lastPath),he.add(this)}compile(e){e.nodeType===Node.ELEMENT_NODE&&e.nodeName==="ROUTER-VIEW"&&!this.knownRouterViews.has(e)&&O.componentBlock&&(this.knownRouterViews.set(e,O.componentBlock),this.knownRouterViewNames.set(e.getAttribute("name")?.trim()||"",e))}onHistoryEvent(e){e.preventDefault(),e.stopImmediatePropagation();let n=new URL(e.currentTarget.location.href).pathname;e.type==="load"?window.history.replaceState({},"",this.lastPath):e.type==="pushstate"?window.history.replaceState({},"",n):e.type==="popstate"&&window.history.replaceState({},"",n),this.lastPath=n;let r=this.getMatchesForURL(n);this.applyMatches(r)}doRouteChange(e){window.history.pushState({},"",e);let n=this.getMatchesForURL(`${location.pathname}${location.search}`);this.applyMatches(n)}getMatchesForURL(e){let n=[],r=(o,s="",i=[])=>{let a=[];for(let c of o){a.push(c);let l=`${s}${c.path}`.replace(/\/\//g,"/"),u=this.getPathMatch(l,e);u&&n.push({match:u,parents:[...i,...a]}),c.children?.length&&(r(c.children,l,[...i,...a]),a=[])}return n};return n=r(this.routes),n}getRouteExpression(e,n){if(this.pathExpressions.has(e))return this.pathExpressions.get(e);let r=[],s={regex:fe(e,r,{strict:!1,sensitive:!1,end:!0}),params:r,path:e,route:n};return this.pathExpressions.set(e,s),s}getPathMatch(e,n){return this.pathExpressions.get(e)&&this.pathExpressions.get(e).regex.exec(n)?this.pathExpressions.get(e):null}async applyMatches(e){if(!e)return;let n=new Set,r=async(i,a)=>{for(let c of i)if(c.view){let l=this.knownRouterViewNames.get(c.view);if(l&&await o(l,c))continue}else if(a&&await o(a,c))continue},o=async(i,a)=>await lt(a)?(s(i,a),!0):(a.componentFallback?s(i,a,a.componentFallback):pt(a),!1),s=(i,a,c)=>{if(!n.has(i)||this.populatedRouterViews.get(i)?.route!==a){let l=document.createElement("div");i.replaceChildren(l);let u=l.parentElement,f=new A({element:l,component:c||a.component,replacementType:"replaceChildren",parentContext:O.componentBlock.context});u.replaceChild(f.element,l),this.populatedRouterViews.set(i,{block:f,route:a}),n.add(i)}};for(let i of e){let c=[...i.parents,i.match.route].filter((u,f,d)=>f===d.findIndex(h=>h.path===u.path)),l=this.knownRouterViewNames.get("")??null;await r(c,l)}for(let i of this.knownRouterViews.keys())if(!n.has(i)&&this.populatedRouterViews.has(i)){let a=this.populatedRouterViews.get(i);a&&(a.block.teardown(),this.populatedRouterViews.delete(i))}}cacheRouteExpression(e,n=""){let r=`${n}${e.path}`.replace(/\/\//g,"/");this.getRouteExpression(r,e),e.children?.length&&e.children.forEach(o=>{this.cacheRouteExpression(o,r)})}destroy(){window.removeEventListener("popstate",this.onHistoryEvent.bind(this)),window.removeEventListener("pushstate",this.onHistoryEvent.bind(this)),window.removeEventListener("load",this.onHistoryEvent.bind(this))}};function jn(t,e){O.componentBlock||console.warn("Can't provide: no current component block"),O.componentBlock.provides.set(t,e)}function Dn(t){O.componentBlock||console.warn("Can't inject: no current component block");let e=O.componentBlock;for(;e;){if(e.provides.has(t))return e.provides.get(t);e=e.parentComponentBlock}}var Ve=class{root;registry=new Map;plugins=new Set;register(e,n){this.registry.set(e,n)}use(e,...n){this.plugins.add(e),e.use(this,...n)}getComponent(e){return this.registry.get(e)}mount(e,n="body",r={}){let o=typeof n=="string"?document.querySelector(n):n,s=o.style.display;return o.style.display="none",this.root=this._mount(e,o,r),o.style.display=s,this.root}_mount(e,n,r){let o=xe({app:this});return r&&(o.scope=P(r),Ge(o.scope)),o.scope.$isRef=L,o.scope.$isComputed=K,new A({element:n,parentContext:o,component:e,isRoot:!0,componentProps:r,replacementType:"replaceChildren"})}unmount(){this.root.teardown()}};function xe({parentContext:t,app:e}){let n={app:e||(t&&t.app?t.app:null),scope:P({}),blocks:[],effects:[],slots:[],templates:t?t.templates:[],effect:r=>{let o=ue(r);return n.effects.push(o),o}};return n}var Ae=(t,e={})=>{let n=t.scope,r=Object.create(n);Object.defineProperties(r,Object.getOwnPropertyDescriptors(e));let o;return o=P(new Proxy(r,{set(i,a,c,l){return l===o&&!i.hasOwnProperty(a)?Reflect.set(n,a,c):Reflect.set(i,a,c,l)}})),Ge(o),{...t,scope:{...t.scope,...o}}};function Ge(t){for(let e of Object.keys(t))typeof t[e]=="function"&&(t[e]=t[e].bind(t))}function ut(t,e){let n={};return Object.keys(e).forEach(r=>{let o=t.hasOwnProperty(r)?t[r]:e[r]?.default;n[r]=P(typeof o=="function"?o():o)}),n}var O={componentBlock:void 0},A=class{element;context;parentContext;component;provides=new Map;parentComponentBlock;componentProps;allProps;isFragment;start;end;key;constructor(e){this.isFragment=e.element instanceof HTMLTemplateElement,this.parentComponentBlock=e.parentComponentBlock,e.component?(O.componentBlock=this,this.element=re(e.component.template)):this.isFragment?this.element=e.element.content.cloneNode(!0):typeof e.element=="string"?this.element=re(e.element):(this.element=e.element.cloneNode(!0),e.element.replaceWith(this.element)),e.isRoot?this.context=e.parentContext:(this.parentContext=e.parentContext?e.parentContext:xe({}),this.parentContext.blocks.push(this),this.context=xe({parentContext:e.parentContext})),e.component&&(this.componentProps=ut(e.componentProps??{},e.component.props??{}),e.component.main&&(this.context.scope={...e.component.main(this.componentProps)||{}})),e.allProps?.forEach(n=>{n.isBind&&this.context.effect(()=>{let r;if(n.isSpread){let o=m(this.parentContext.scope,n.extractedName);R(o)&&Object.keys(o).forEach(s=>{r=o[s],this.setProp(s,r)})}else r=n.isMirror?m(this.parentContext.scope,n.extractedName):m(this.parentContext.scope,n.exp),this.setProp(n.extractedName,r)})}),this.context.slots=ye(this.element),this.context.templates=e.templates??[],this.context.slots.forEach(n=>{let r=this.context.templates.find(o=>o.targetSlotName===n.name);if(r){let o=r.node.content.cloneNode(!0);n.node.replaceWith(o)}}),this.context.scope.$isRef=L,this.context.scope.$isComputed=K,Ue(this.element,this.context),e.component&&(e.replacementType==="replace"?e.element instanceof HTMLElement&&e.element.replaceWith(this.element):e.element instanceof HTMLElement&&e.element.replaceChildren(this.element))}setProp(e,n){L(this.componentProps[e])?this.componentProps[e].value=n:this.componentProps[e]=n}insert(e,n=null){if(this.isFragment)if(this.start){let r=this.start,o;for(;r&&(o=r.nextSibling,e.insertBefore(r,n),r!==this.end);)r=o}else this.start=new Text(""),this.end=new Text(""),e.insertBefore(this.end,n),e.insertBefore(this.start,this.end),e.insertBefore(this.element,this.end);else e.insertBefore(this.element,n)}remove(){if(this.parentContext){let e=this.parentContext.blocks.indexOf(this);e>-1&&this.parentContext.blocks.splice(e,1)}if(this.start){let e=this.start.parentNode,n=this.start,r;for(;n&&(r=n.nextSibling,e.removeChild(n),n!==this.end);)n=r}else this.element.remove();this.teardown()}teardown(){this.context.blocks.forEach(e=>{e.teardown()}),this.context.effects.forEach(stop)}};function ft(t,e){return!!e.app.getComponent(t.tagName.toLowerCase())}function de(t,e){return e.every(n=>t.hasAttribute(n))?(console.warn("These directives cannot be used together on the same node:",e),console.warn("Node ignored:",t),!0):!1}function Ue(t,e){if(oe(t)){new Y({element:t,context:e});return}if(W(t)){let n,r=(i,a,c,l,u)=>{if(!de(i,[":if",":for"])&&!de(i,[":if",":teleport"])&&!de(i,[":for",":teleport"])){if(n=N(i,":scope")){let f=m(a.scope,n);typeof f=="object"&&Object.assign(a.scope,f)}if(n=N(i,":teleport"))return Me(i,n,a);if(n=N(i,":if"))return Se(i,n,a,c,l,u);if(n=N(i,":for"))return Ne(i,n,a,c,l,u);(n=N(i,":show"))&&new ee({element:i,context:a,expression:n}),(n=N(i,":ref"))&&(a.scope[n].value=i),(n=N(i,":value"))&&new te({element:i,context:a,expression:n}),(n=N(i,":html"))&&a.effect(()=>{let f=m(a.scope,n);f instanceof Element?(i.replaceChildren(),i.append(f)):i.innerHTML=f}),(n=N(i,":text"))&&a.effect(()=>{i.textContent=z(m(a.scope,n))})}},o=(i,a)=>Array.from(i.attributes).filter(c=>se(c.name)||J(c.name)||Ce(c.name)&&Te(X(c.name),a)).map(c=>({isMirror:J(c.name),isSpread:se(c.name),isBind:c.name.includes("bind"),originalName:c.name,extractedName:X(c.name),exp:c.value,value:J(c.name)?m(e.scope,X(c.name)):c.value?m(e.scope,c.value):void 0}));if(ft(t,e)){let i=e.app.getComponent(t.tagName.toLowerCase()),a=o(t,i),c=a.reduce((f,{isSpread:d,isMirror:h,extractedName:x,value:E})=>{if(d){let p=m(e.scope,x);R(p)&&Object.assign(f,p)}else h?f[x]=m(e.scope,x):f[x]=E;return f},{}),l=r(t,e,i,c,a);if(l)return l;let u=ve(t);return new A({element:t,parentContext:e,component:i,replacementType:"replace",parentComponentBlock:O.componentBlock,templates:u,componentProps:c,allProps:a}).element}let s=r(t,e);if(s)return s;Array.from(t.attributes).forEach(i=>{we(i.name)&&new Z({element:t,context:e,attr:i}),Re(i.name)&&new Q({element:t,context:e,attr:i})}),mt(t,e)}}function mt(t,e){let n=t.firstChild;for(;n;)n=Ue(n,e)||n.nextSibling}var We={};function m(t,e,n){if(e.trim())return Ke(t,`const ___value = (${e.trim()}); return ___value;`,n)}function I(t,e,n){return n=typeof n=="string"?`"${n}"`:n,Ke(t,`const ___target = (${e.trim()}); return $isRef(___target) ? ___target.value = ${n} : ___target = ${n};`,null,!1)}function Ke(t,e,n,r=!0){let o=r?dt(t):t,s=We[e]||(We[e]=ht(e));try{return s(o,n)}catch(i){console.warn(`Error evaluating expression: "${e}":`),console.error(i)}}function ht(t){try{return new Function("$data","$el",`with($data){${t}}`)}catch(e){return console.error(`${e.message} in expression: ${t}`),()=>{}}}function dt(t){let e={};for(let n in t)t.hasOwnProperty(n)&&(L(t[n])?e[n]=t[n].value:e[n]=t[n]);return e}export{Ve as App,A as Block,me as RouterPlugin,xe as createContext,Ae as createScopedContext,O as current,m as evalGet,I as evalSet,Dn as inject,jn as provide}; diff --git a/public/index.js.br b/public/index.js.br new file mode 100755 index 0000000000000000000000000000000000000000..206ed92cee371282f1c4ff125ef6de4608cbca5b GIT binary patch literal 8161 zcmV<7A0FWGa371JoV2zEK#Kyq@!}H&EXmb620rDeqitSm1izMJXB`YDQ$_4*rcMRvG_z!) zIW)$AC{VFdQ>#`=!MP3A=U&u?lP*P%!2j7lA<1yZ`#)97w;dqu#n?Gj-AWFza#tPy zpFjUJAixzskZ(zm8%VA~@=@VJni)_$5E~vzY5gEw(yh}5r(F3?j)FO3Sss6TTGb#&llwRu^^nH+&%CP z1f2k3d@cC|q;I!#zPHH6v2)d2+Z98eRLP-+m+^!reJ`T#uXAvCUAV5DaHqUskL9Oa zqlElVakNz58XrS2%=XWKZ{H2-?qR9gMgcOe4t0)#Y1&1}#id1seEW{5DmLvUvXolOGK$eqtjX6LfrhX%z3Mqm8 z6Y}cl8L4vZ@!F3xtk?t$8gADs7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uq^ z=umG)VjnvoN56Ys|G>Zlbe)b7jb-SIPN(QW-|^}No3q-#fvkAsR(x`^bk}LyaPMI6 zU*||zuE@!i!>G@dG<1NDnNr|Ibkwn$*OH`7PDBTZLLLW2hbt)xkW*#N`RvJ8TJ)W| zHV}iu1bWdu(B6O>vBHXt#GYJep~>yS(u<(ZP;e+pW^27BdzZN z`bXm7!XJgcSgp^YaomP^FJ2a!zwR>Eo@g)kpK13IK$-+721{?km_^alD6lUke22au z4WvGQ%7-b4q=dSt*}Qq*$jQCWAG#;3CiVv3nZD~|_B6)NZSQPWeHY}O=J1$?er|Ms ztju^tBd51_(JCpybB=c*WH3P*A{g4KBkeBdd`a=)YL0XH0#AxF!?+bSyHw*RAe^Rm zsAwzV>y2|Y0BD}5WS>G=~kBb)ST9IR~A=GyUn^ZpzC7ddU}i3 z { - const source = evalGet(ctx.scope, sourceExp); + const source = evalGet(ctx.scope, sourceExp, el); const prevKeyToIndexMap = keyToIndexMap; [childCtxs, keyToIndexMap] = createChildContexts(source); if (!mounted) { diff --git a/src/directives/if.ts b/src/directives/if.ts index 24b59bd..b9f171c 100644 --- a/src/directives/if.ts +++ b/src/directives/if.ts @@ -46,7 +46,7 @@ export function _if(el: Element, exp: string, ctx: Context, component?: Componen for (let i = 0; i < branches.length; i++) { const { exp, el } = branches[i]; - if (!exp || evalGet(ctx.scope, exp)) { + if (!exp || evalGet(ctx.scope, exp, el)) { if (i !== activeBranchIndex) { removeActiveBlock(); block = new Block({ element: el, parentContext: ctx, replacementType: "replace", component, componentProps, allProps }); diff --git a/src/directives/interpolation.ts b/src/directives/interpolation.ts index e6cb688..fa5faf1 100644 --- a/src/directives/interpolation.ts +++ b/src/directives/interpolation.ts @@ -23,7 +23,7 @@ export class InterpolationDirective { const trimmedExpression = expression.slice(2, -2).trim(); nodes.forEach((node) => { - const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, node); + const getter = (exp = trimmedExpression) => evalGet(this.context.scope, exp, element); context.effect(() => { node.textContent = toDisplayString(getter()); diff --git a/src/directives/show.ts b/src/directives/show.ts index 879ac88..ebe4122 100644 --- a/src/directives/show.ts +++ b/src/directives/show.ts @@ -22,7 +22,7 @@ export class ShowDirective { } update() { - const shouldShow = Boolean(evalGet(this.context.scope, this.expression)); + const shouldShow = Boolean(evalGet(this.context.scope, this.expression, this.element)); // @ts-ignore this.element.style.display = shouldShow ? this.originalDisplay : "none"; } diff --git a/src/index.ts b/src/index.ts index f9536b9..eeeb5ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,7 +43,7 @@ export function inject(key: string) { } export class App { - rootBlock: Block; + root: Block; registry = new Map(); plugins = new Set(); @@ -64,12 +64,12 @@ export class App { const root = typeof target === "string" ? (document.querySelector(target) as HTMLElement) : target; const display = root.style.display; root.style.display = "none"; - this.rootBlock = this._mount(component, root, props, true); + this.root = this._mount(component, root, props); root.style.display = display; - return this.rootBlock; + return this.root; } - private _mount(component: Component, target: HTMLElement, props: Record, isRoot = false) { + private _mount(component: Component, target: HTMLElement, props: Record) { const parentContext = createContext({ app: this }); if (props) { @@ -84,7 +84,7 @@ export class App { element: target, parentContext, component, - isRoot, + isRoot: true, componentProps: props, replacementType: "replaceChildren", }); @@ -93,7 +93,7 @@ export class App { } unmount() { - this.rootBlock.teardown(); + this.root.teardown(); } } @@ -258,7 +258,7 @@ export class Block { } } - opts.allProps?.forEach((prop) => { + opts.allProps?.forEach((prop: any) => { if (prop.isBind) { this.context.effect(() => { let newValue: unknown; @@ -422,7 +422,7 @@ function walk(node: Node, context: Context) { // In this case, the scope is merged into context.scope and will overwrite // anything returned from `main`. if ((exp = checkAndRemoveAttribute(node, ":scope"))) { - const scope = evalGet(context.scope, exp); + const scope = evalGet(context.scope, exp, node); if (typeof scope === "object") { Object.assign(context.scope, scope); // context = createScopedContext(context, scope); @@ -449,7 +449,7 @@ function walk(node: Node, context: Context) { } if ((exp = checkAndRemoveAttribute(node, ":html"))) { context.effect(() => { - const result = evalGet(context.scope, exp); + const result = evalGet(context.scope, exp, node); if (result instanceof Element) { node.replaceChildren(); node.append(result); @@ -460,7 +460,7 @@ function walk(node: Node, context: Context) { } if ((exp = checkAndRemoveAttribute(node, ":text"))) { context.effect(() => { - node.textContent = toDisplayString(evalGet(context.scope, exp)); + node.textContent = toDisplayString(evalGet(context.scope, exp, node)); }); } }; @@ -475,7 +475,7 @@ function walk(node: Node, context: Context) { originalName: attr.name, extractedName: extractPropName(attr.name), exp: attr.value, - value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name)) : attr.value ? evalGet(context.scope, attr.value) : undefined, + value: isMirrorProp(attr.name) ? evalGet(context.scope, extractPropName(attr.name), node) : attr.value ? evalGet(context.scope, attr.value, node) : undefined, })); }; @@ -485,10 +485,10 @@ function walk(node: Node, context: Context) { const componentProps = allProps.reduce((acc, { isSpread, isMirror, extractedName, value }) => { if (isSpread) { - const spread = evalGet(context.scope, extractedName); + const spread = evalGet(context.scope, extractedName, node); if (isObject(spread)) Object.assign(acc, spread); } else if (isMirror) { - acc[extractedName] = evalGet(context.scope, extractedName); + acc[extractedName] = evalGet(context.scope, extractedName, node); } else { acc[extractedName] = value; } diff --git a/src/plugins/router/plugin.ts b/src/plugins/router/plugin.ts index a40743d..909ed28 100644 --- a/src/plugins/router/plugin.ts +++ b/src/plugins/router/plugin.ts @@ -6,14 +6,14 @@ import { reactive } from "../../reactivity/reactive"; import { unwrap } from "../../reactivity/unwrap"; import { html } from "../../util"; -const activeRouters = new Set(); +export const activeRouters = new Set(); + +export function getRouter(): RouterPlugin | undefined { + return current.componentBlock ? [...activeRouters].find((router) => router.app === current.componentBlock.context.app) : undefined; +} const link = { - template: html` - - LINK - - `, + template: html``, props: { href: { default: "#" } }, main({ href }: { href: string }) { const go = (e: Event) => { @@ -60,7 +60,7 @@ export class RouterPlugin implements Plugin { this.routes = routes; } - use(app: App, ...config: any[]) { + use(app: App, ..._: any[]) { this.app = app; this.app.register("router-link", link);