jq79 0.3.30 → 0.3.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/jq79.ts","../src/dom.ts","../src/reactive.ts","../src/transform.ts"],"sourcesContent":["\nimport { $, $$, $create, sanitizeHTML } from \"./dom\"\nimport { $reactive, untracked, createEffectScope } from \"./reactive\"\nimport type { ReactiveDeepData, EffectScope } from \"./reactive\"\nimport { transformSetupScript, transformFactoryScript } from \"./transform\"\n\nexport { $, $$, $create } from \"./dom\"\nexport { $reactive } from \"./reactive\"\ntype TemplateNode = {\n tag: string\n attrs: Record<string, string>\n children: (TemplateNode | string)[]\n}\n\ntype TagBlock = {\n attrs: Record<string, string>\n content: string\n // <style scoped> only: `content` rewritten to require the component's scope\n // attribute. Kept beside the original rather than replacing it, because a\n // shadow root doesn't want it - see headStyle()\n scoped?: string\n}\n\nconst elementAttrs = (el: Element): Record<string, string> =>\n Object.fromEntries(Array.from(el.attributes).map(attr => [attr.name, attr.value]))\n\n// text is kept verbatim - not trimmed, not dropped when it's only whitespace.\n// A template is HTML, so the space in `<span>a</span>\\n<span>b</span>` is the\n// same space the browser would collapse-and-render between them, and CSS gets\n// to decide what it's worth (nothing in a block or flex container, one space\n// between inline elements). Trimming it here, as this used to, silently glued\n// siblings together and ate the spaces in `hola <b>mundo</b> adios`\nconst elementToAST = (el: Element): TemplateNode => ({\n tag: el.tagName.toLowerCase(),\n attrs: elementAttrs(el),\n children: Array.from(el.childNodes).flatMap((node): (TemplateNode | string)[] => {\n if (node.nodeType === Node.TEXT_NODE) {\n const text = node.textContent ?? \"\"\n return text ? [text] : []\n }\n if (node.nodeType === Node.ELEMENT_NODE) {\n return [elementToAST(node as Element)]\n }\n return []\n })\n})\n\n// evaluated with `with` (rather than passing scope keys as positional params)\n// so only the identifiers an expression actually references are read from\n// `scope` - which is what makes dependency tracking in $reactive\n// precise instead of \"read everything up front\". `extras` are passed as\n// function parameters (outside the `with`), so scope keys still win but names\n// like $event resolve when the scope doesn't shadow them\n//\n// Compiled functions are cached: an expression is re-evaluated on every effect\n// run - once per interpolation, once per :each item - while the set of distinct\n// expressions is fixed by the source. The `extras` names are part of the key,\n// not just the expression: they become the function's parameters, so the same\n// expression compiled with and without $event is two different functions. A\n// syntactically invalid expression caches its failure (null) so it isn't\n// recompiled, and rethrown as undefined, exactly as before\nconst compiled = new Map<string, Function | null>()\n\nconst compileExpr = (expr: string, params: string[]): Function | null => {\n const key = `${params.join(\",\")}|${expr}`\n let fn = compiled.get(key)\n if (fn === undefined) {\n try {\n fn = new Function(\"$scope\", ...params, `with ($scope) { return (${expr}); }`)\n } catch {\n fn = null // a syntax error: it will never compile, so don't try again\n }\n compiled.set(key, fn)\n }\n return fn\n}\n\nconst evalExpr = (expr: string, scope: Record<string, any>, extras?: Record<string, any>): any => {\n const fn = compileExpr(expr, extras ? Object.keys(extras) : [])\n if (!fn) return undefined\n try {\n return fn(scope, ...(extras ? Object.values(extras) : []))\n } catch {\n return undefined\n }\n}\n\n// [\\s\\S] rather than `.` so an expression can span lines, like the ones in\n// directive attributes (which reach evalExpr wrapped in parens either way)\nconst interpolate = (template: string, scope: Record<string, any>): string =>\n template.replace(/{{\\s*([\\s\\S]+?)\\s*}}/g, (_, expr) => evalExpr(expr, scope) ?? \"\")\n\n\nconst CONTROL_ATTRS = new Set([\":attrs\", \":if\", \":elseif\", \":else\", \":each\", \":key\", \":with\", \":text\", \":html\"])\n// the list expression can span lines, so it matches [\\s\\S] rather than `.`\nconst EACH_PATTERN = /^\\s*(\\w+)\\s+in\\s+([\\s\\S]+)$/\n\ntype ConditionalBranch = { expr?: string; node: TemplateNode }\n\n\n// @event attributes: @click=\"onClick\", @submit.prevent=\"$event => onSubmit($event)\",\n// or an inline statement like @click=\"count = count + 1\". The expression is\n// evaluated (with `$event` in scope) on every event; if it yields a function,\n// that function is then invoked with the event - so both a handler reference\n// and an inline arrow/statement work. Modifiers after dots: .prevent .stop\n// .self (runtime guards) and .once .capture (addEventListener options)\nconst bindEvent = (el: Element, attr: string, expr: string, scope: Record<string, any>) => {\n const [name, ...modifiers] = attr.slice(1).split(\".\")\n const mods = new Set(modifiers)\n\n el.addEventListener(name, event => {\n if (mods.has(\"self\") && event.target !== el) return\n if (mods.has(\"prevent\")) event.preventDefault()\n if (mods.has(\"stop\")) event.stopPropagation()\n\n const handler = evalExpr(expr, scope, { $event: event })\n if (typeof handler === \"function\") handler.call(el, event)\n }, { once: mods.has(\"once\"), capture: mods.has(\"capture\") })\n}\n\nconst kebabToCamel = (name: string) => name.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase())\n\n// finds the scope variable a template tag refers to. HTML parsing lowercases\n// tag names, so <NestedComponent> arrives as \"nestedcomponent\" and matching is\n// case-insensitive with dashes stripped (<nested-component> works too). Only\n// PascalCase scope keys participate, so ordinary variables named like real\n// elements (title, code, ...) never hijack them\nconst findComponentKey = (scope: Record<string, any>, tag: string): string | null => {\n const normalized = tag.replace(/-/g, \"\").toLowerCase()\n for (let obj: any = scope; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) {\n for (const key of Object.keys(obj)) {\n if (/^[A-Z]/.test(key) && key.replace(/-/g, \"\").toLowerCase() === normalized) return key\n }\n }\n return null\n}\n\n// <MyComponent :user :title=\"'str'\"></MyComponent> - renders a child\n// component instance at this position. Props: `:name=\"expr\"` evaluates expr\n// in the parent scope (`:name` alone is shorthand for `:name=\"name\"`), plain\n// attributes pass through as literal strings, and kebab-case prop names\n// become camelCase. Props stay live: a parent effect re-evaluates each\n// expression and writes it into the child's store. The component variable is\n// reactive too - while it's undefined (e.g. an `await import(...)` still in\n// flight) nothing renders, and the child appears when it resolves.\n// `shadow` is the parent's style mode, carried down the whole render: a child\n// of a shadow-rendered component renders inside that shadow root, so its\n// <style> has to go in there with it - document.head can't reach into a shadow\n// tree, and a style that never applies to its own component would still be\n// restyling the page around it\nconst renderNestedComponent = (key: string, node: TemplateNode, scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const anchor = document.createComment(key)\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n const props: Record<string, string> = {} // prop name -> expression in parent scope\n Object.entries(node.attrs).forEach(([attr, value]) => {\n // the parent's scope stamp is stamped on every template element, this tag\n // included - it's not a prop, and the child renders under its own scope\n if (attr === SCOPE_ATTR || CONTROL_ATTRS.has(attr) || attr.startsWith(\"@\")) return\n if (attr.startsWith(\":\")) {\n const name = kebabToCamel(attr.slice(1))\n props[name] = value || name\n } else {\n props[kebabToCamel(attr)] = JSON.stringify(value)\n }\n })\n\n let current: Component79 | null = null\n let currentDef: Component79 | null = null\n let childFx: EffectScope | null = null\n\n fx.effect(() => {\n const value = evalExpr(key, scope)\n const nextDef = value instanceof Component79 ? value : null\n if (nextDef === currentDef) return\n\n childFx?.dispose()\n childFx = null\n current?.destroy() // detaches its marker range, removing the child's DOM\n current = null\n currentDef = nextDef\n if (!nextDef) return\n\n // a fresh instance per usage site: the definition's parsed parts (and\n // pre-resolved modules) are shared, but store/effects/DOM are per instance\n const instance = new Component79({\n template: nextDef.template,\n scripts: nextDef.scripts,\n styles: nextDef.styles,\n modules: nextDef.modules,\n filename: nextDef.filename,\n })\n const seed = untracked(() =>\n Object.fromEntries(Object.entries(props).map(([name, expr]) => [name, evalExpr(expr, scope)]))\n )\n // mounting into a fragment attaches no shadow root of its own: a\n // shadow-rendered child keeps its <style> elements inline, next to the DOM\n // they style, and the parent's shadow root is what scopes both\n const holder = document.createDocumentFragment()\n ;(shadow ? instance.renderShadow(seed) : instance.render(seed)).mount(holder)\n anchor.parentNode!.insertBefore(holder, anchor.nextSibling)\n\n const syncFx = createEffectScope(scope)\n Object.entries(props).forEach(([name, expr]) => {\n syncFx.effect(() => { (instance.data as Record<string, any>)[name] = evalExpr(expr, scope) })\n })\n\n childFx = syncFx\n current = instance\n })\n\n fx.onDispose(() => {\n childFx?.dispose()\n current?.destroy()\n })\n\n return wrapper\n}\n\n// :with=\"expr\" narrows the scope for an element and its subtree: names\n// resolve against the expression's value first, then fall back to the outer\n// scope. The value is re-evaluated lazily on every name lookup (never\n// snapshotted), so an effect reading through this proxy tracks both the\n// expression's own dependencies and the property it reads - replacing the\n// object or mutating one of its properties re-renders exactly the dependents,\n// without rebuilding the subtree. Assignments to names the object owns write\n// through to it (reactively, if it came from a store); everything else\n// behaves as if the :with weren't there\nconst createWithScope = (expr: string, scope: Record<string, any>): Record<string, any> => {\n const source = (): Record<string, any> | null => {\n const value = evalExpr(expr, scope)\n return value !== null && typeof value === \"object\" ? value : null\n }\n return new Proxy(scope, {\n has(target, key) {\n const obj = source()\n return (obj !== null && Reflect.has(obj, key)) || Reflect.has(target, key)\n },\n get(target, key) {\n const obj = source()\n if (obj !== null && Reflect.has(obj, key)) return obj[key as string]\n return Reflect.get(target, key)\n },\n set(target, key, value) {\n const obj = source()\n if (obj !== null && Reflect.has(obj, key)) {\n obj[key as string] = value\n return true\n }\n return Reflect.set(target, key, value)\n },\n })\n}\n\n// renders a single element node: static attrs, @event listeners, a reactive\n// :attrs object, and its content - :text/:html override the element's own\n// children with a reactive textContent/innerHTML, otherwise children render\n// normally. :if/:elseif/:else/:each are handled by renderNodes, which decides\n// *whether*/*how many times* a node is rendered before calling this. Tags\n// matching a PascalCase scope variable render as nested components instead\nconst renderNode = (node: TemplateNode, outerScope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n // :with applies to the element's own bindings (@events, :attrs) and its\n // whole subtree. On a :each element the item scope is already in place, so\n // :with=\"item\" works\n const withExpr = node.attrs[\":with\"]\n const scope = withExpr !== undefined ? createWithScope(withExpr, outerScope) : outerScope\n\n const componentKey = findComponentKey(scope, node.tag)\n if (componentKey) return renderNestedComponent(componentKey, node, scope, fx, shadow)\n\n const el = document.createElement(node.tag)\n\n // a tag that isn't standard HTML but has no matching scope key *yet* may be\n // a component that arrives later (e.g. an async factory script exposing an\n // imported component after `await`). Watch for the key: the effect tracks\n // no deps, so it only re-runs on the store's new-key sweep, and swaps the\n // placeholder element for the component exactly once\n if (el instanceof HTMLUnknownElement || node.tag.includes(\"-\")) {\n let upgraded = false\n fx.effect(() => {\n if (upgraded) return\n const key = findComponentKey(scope, node.tag)\n if (!key) return\n upgraded = true\n el.replaceWith(renderNestedComponent(key, node, scope, fx, shadow))\n })\n }\n\n Object.entries(node.attrs).forEach(([key, value]) => {\n if (key.startsWith(\"@\")) bindEvent(el, key, value, scope)\n else if (!CONTROL_ATTRS.has(key)) el.setAttribute(key, value)\n })\n\n const bindExpr = node.attrs[\":attrs\"]\n if (bindExpr !== undefined) {\n let boundKeys: string[] = []\n\n fx.effect(() => {\n boundKeys.forEach(key => el.removeAttribute(key))\n const bound = evalExpr(bindExpr, scope)\n boundKeys = bound && typeof bound === \"object\" ? Object.keys(bound) : []\n boundKeys.forEach(key => {\n const value = bound[key]\n if (value != null && value !== false) el.setAttribute(key, String(value))\n })\n })\n }\n\n // :text=\"expr\" sets textContent reactively, replacing any children.\n // :html=\"expr\" sets innerHTML reactively, sanitizing the value first so\n // untrusted content can't inject scripts/attributes (see sanitizeHTML in\n // ./dom). Both skip rendering the element's own children/interpolation\n const textExpr = node.attrs[\":text\"]\n const htmlExpr = node.attrs[\":html\"]\n if (textExpr !== undefined) {\n fx.effect(() => { el.textContent = String(evalExpr(textExpr, scope) ?? \"\") })\n } else if (htmlExpr !== undefined) {\n fx.effect(() => { el.innerHTML = sanitizeHTML(String(evalExpr(htmlExpr, scope) ?? \"\")) })\n } else {\n el.appendChild(renderNodes(node.children, scope, fx, shadow))\n }\n\n return el\n}\n\n// a :if/:elseif*/:else? chain sharing one anchor comment so the active branch\n// can be swapped in place without disturbing sibling positions. Only depends\n// on whatever the branch expressions read (e.g. \"score\"), and skips\n// rebuilding entirely when the active branch hasn't actually changed\nconst renderConditional = (branches: ConditionalBranch[], scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const anchor = document.createComment(\"if\")\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n let current: Node | null = null\n let activeBranch: ConditionalBranch | null = null\n let branchFx: EffectScope | null = null\n\n fx.effect(() => {\n const next = branches.find(branch => branch.expr === undefined || evalExpr(branch.expr, scope)) ?? null\n if (next === activeBranch) return\n\n branchFx?.dispose()\n if (current) current.parentNode?.removeChild(current)\n current = null\n activeBranch = next\n if (!next) return\n\n branchFx = createEffectScope(scope)\n current = renderNode(next.node, scope, branchFx, shadow)\n anchor.parentNode!.insertBefore(current, anchor.nextSibling)\n })\n\n return wrapper\n}\n\n// defines a loop-local binding directly as `scope`'s own property. Plain\n// assignment (scope[key] = value) would only do this if the key isn't\n// already own on `scope` *or anywhere up its prototype chain* - if it isn't,\n// JS delegates the [[Set]] to whatever's up there, which for us is another\n// reactive proxy's `set` trap: it would wrap `value` as if it were a genuine\n// store mutation and fire a bogus notify() under a name (e.g. \"item\") shared\n// by every unrelated item in every :each on the page. defineProperty always\n// writes to `scope` itself, never delegating, so this can't happen\nconst defineScopeVar = (scope: Record<string, any>, key: string, value: any) => {\n Object.defineProperty(scope, key, { value, writable: true, enumerable: true, configurable: true })\n}\n\ntype EachEntry = { key: any; item: any; scope: Record<string, any>; node: Node; fx: EffectScope }\n\n// :each=\"item in items\", optionally keyed with :key=\"expr\". Only depends on\n// the list expression itself (e.g. \"items\"), and on each run diffs by key:\n// unchanged items (same key, same item reference) keep their DOM/effects,\n// changed/added ones are (re)rendered, removed ones are disposed. Without\n// :key, position is used as the key, so reordering rebuilds every item after\n// the first change - add :key for anything that gets reordered or filtered.\n// Each item gets its own scope via Object.create(scope), so `item`/`$index`\n// shadow same-named outer bindings without copying the parent scope's keys\nconst renderEach = (node: TemplateNode, scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const match = node.attrs[\":each\"].match(EACH_PATTERN)\n if (!match) return document.createComment(`invalid :each expression \"${node.attrs[\":each\"]}\"`)\n\n const [, itemName, listExpr] = match\n const keyExpr = node.attrs[\":key\"]\n const { [\":each\"]: _each, [\":key\"]: _key, ...itemAttrs } = node.attrs\n const itemNode: TemplateNode = { ...node, attrs: itemAttrs }\n\n const anchor = document.createComment(\"each\")\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n let entries: EachEntry[] = []\n\n fx.effect(() => {\n const list = evalExpr(listExpr, scope)\n const items = Array.isArray(list) ? list : []\n const previous = new Map(entries.map(entry => [entry.key, entry]))\n\n const nextEntries = items.map((item, index): EachEntry => {\n const itemScope = Object.create(scope)\n defineScopeVar(itemScope, itemName, item)\n defineScopeVar(itemScope, \"$index\", index)\n const key = keyExpr !== undefined ? evalExpr(keyExpr, itemScope) : index\n const existing = previous.get(key)\n\n if (existing && Object.is(existing.item, item)) {\n defineScopeVar(existing.scope, \"$index\", index)\n return existing\n }\n\n existing?.fx.dispose()\n existing?.node.parentNode?.removeChild(existing.node)\n\n const itemFx = createEffectScope(scope)\n return { key, item, scope: itemScope, fx: itemFx, node: renderNode(itemNode, itemScope, itemFx, shadow) }\n })\n\n const nextKeys = new Set(nextEntries.map(entry => entry.key))\n entries.forEach(entry => {\n if (!nextKeys.has(entry.key)) {\n entry.fx.dispose()\n entry.node.parentNode?.removeChild(entry.node)\n }\n })\n\n let prevNode: Node = anchor\n nextEntries.forEach(entry => {\n if (prevNode.nextSibling !== entry.node) anchor.parentNode!.insertBefore(entry.node, prevNode.nextSibling)\n prevNode = entry.node\n })\n\n entries = nextEntries\n })\n\n return wrapper\n}\n\n// renders a list of sibling template nodes (text + elements), grouping\n// consecutive :if/:elseif/:else nodes into a single conditional block\nconst renderNodes = (nodes: (TemplateNode | string)[], scope: Record<string, any>, fx: EffectScope, shadow = false): DocumentFragment => {\n const fragment = document.createDocumentFragment()\n let i = 0\n\n while (i < nodes.length) {\n const node = nodes[i]\n\n if (typeof node === \"string\") {\n const textNode = document.createTextNode(node)\n // static text is most of a template (all of its indentation, for a start):\n // only text with a {{ expression }} in it needs an effect to stay in sync\n if (node.includes(\"{{\")) fx.effect(() => { textNode.textContent = interpolate(node, scope) })\n fragment.appendChild(textNode)\n i++\n continue\n }\n\n if (\":each\" in node.attrs) {\n fragment.appendChild(renderEach(node, scope, fx, shadow))\n i++\n continue\n }\n\n if (\":if\" in node.attrs) {\n const branches: ConditionalBranch[] = [{ expr: node.attrs[\":if\"], node }]\n i++\n\n // the branches of a chain are siblings in the AST, but the template writes\n // them on their own lines - so the whitespace between them is indentation\n // and nothing else, and it's dropped rather than rendered: only one branch\n // is ever in the DOM, so there is nothing for it to be a space *between*\n const nextBranch = (attr: string): TemplateNode | undefined => {\n let next = i\n while (next < nodes.length && typeof nodes[next] === \"string\" && !(nodes[next] as string).trim()) next++\n const candidate = nodes[next]\n if (typeof candidate === \"object\" && attr in candidate.attrs) {\n i = next + 1\n return candidate\n }\n return undefined\n }\n\n for (let elseif = nextBranch(\":elseif\"); elseif; elseif = nextBranch(\":elseif\")) {\n branches.push({ expr: elseif.attrs[\":elseif\"], node: elseif })\n }\n const elseNode = nextBranch(\":else\")\n if (elseNode) branches.push({ node: elseNode })\n\n fragment.appendChild(renderConditional(branches, scope, fx, shadow))\n continue\n }\n\n fragment.appendChild(renderNode(node, scope, fx, shadow))\n i++\n }\n\n return fragment\n}\n\nexport const renderComponent = (component: Component79, data: ReactiveDeepData<Record<string, any>>, shadow = false): Node =>\n renderNodes(component.template, data, createEffectScope(data), shadow)\n\ntype ComponentParts = {\n template: TemplateNode[]\n scripts: TagBlock[]\n styles: TagBlock[]\n // pre-resolved modules for `import(...)` calls in setup scripts, keyed by\n // the literal specifier. Bundlers (the jq79/vite plugin) fill this so\n // imports resolve from the bundle instead of being fetched at runtime\n modules?: Record<string, any>\n // where this component came from (a URL for fetch(), a path for the vite\n // plugin). Names the setup scripts in devtools - see scriptSourceUrl\n filename?: string\n}\n\nconst VOID_ELEMENTS = new Set([\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\",\n \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\",\n])\n\n// a self-closing tag with its attributes; quoted attribute values are matched\n// as whole chunks so a \"/>\" inside one doesn't end the tag early\nconst SELF_CLOSING_RE = /<([A-Za-z][\\w-]*)((?:\"[^\"]*\"|'[^']*'|[^>\"'])*?)\\/>/g\nconst RAW_BLOCK_RE = /(<script[\\s\\S]*?<\\/script\\s*>|<style[\\s\\S]*?<\\/style\\s*>)/gi\n\n// expands self-closing tags (<MyComponent />, <div />) into explicit\n// open+close pairs BEFORE DOM parsing. The HTML parser ignores the slash and\n// would treat them as unclosed, swallowing the following siblings. Void\n// elements keep their native behavior, and <script>/<style> contents are\n// passed through untouched so code inside them is never rewritten\nconst expandSelfClosingTags = (src: string): string =>\n src\n .split(RAW_BLOCK_RE)\n .map((chunk, i) =>\n i % 2 === 1 // odd chunks are the captured script/style blocks\n ? chunk\n : chunk.replace(SELF_CLOSING_RE, (match, tag: string, attrs: string) =>\n VOID_ELEMENTS.has(tag.toLowerCase()) ? match : `<${tag}${attrs}></${tag}>`\n )\n )\n .join(\"\")\n\n// <style scoped> support. Every element of the component's own template is\n// stamped with data-jq79=\"<hash>\" and the style's selectors are rewritten to\n// require that attribute, so its rules can't reach anything the component\n// didn't render. Purely a runtime transform (the browser parses the CSS), so\n// it works the same for a bundled component and one loaded with fetch()\nconst SCOPE_ATTR = \"data-jq79\"\n\n// FNV-1a over the source: stable per definition (not per instance), so N\n// instances of the same component share one refcounted <style> in the head\nconst scopeHash = (src: string): string => {\n let hash = 2166136261\n for (let i = 0; i < src.length; i++) hash = Math.imul(hash ^ src.charCodeAt(i), 16777619)\n return (hash >>> 0).toString(36)\n}\n\nconst stampScope = (nodes: (TemplateNode | string)[], scope: string) => {\n nodes.forEach(node => {\n if (typeof node === \"string\") return\n node.attrs[SCOPE_ATTR] = scope\n stampScope(node.children, scope)\n })\n}\n\n// the scope attribute goes on the selector's last compound - the element the\n// rule actually targets - but *before* a pseudo-element, which must stay last\n// (\".a::before\" scopes to \".a[data-jq79='x']::before\", not \"::before[...]\")\nconst scopeSelector = (selectorText: string, scope: string): string =>\n selectorText\n .split(\",\")\n .map(part => {\n const selector = part.trim()\n const pseudoAt = selector.indexOf(\"::\")\n const target = pseudoAt === -1 ? selector : selector.slice(0, pseudoAt)\n const pseudoElement = pseudoAt === -1 ? \"\" : selector.slice(pseudoAt)\n return `${target}[${SCOPE_ATTR}=\"${scope}\"]${pseudoElement}`\n })\n .join(\", \")\n\n// CSSStyleRule is scoped in place; CSSGroupingRule (@media, @supports,\n// @container) is recursed into; everything else - notably @keyframes, whose\n// \"selectors\" are percentages - is left alone\nconst scopeRules = (rules: CSSRuleList, scope: string) => {\n Array.from(rules).forEach(rule => {\n if (rule instanceof CSSStyleRule) rule.selectorText = scopeSelector(rule.selectorText, scope)\n else if (rule instanceof CSSGroupingRule) scopeRules(rule.cssRules, scope)\n })\n}\n\n// the CSS parser is the browser's own (no dependency, no hand-rolled parser).\n// Note browsers *silently drop* rules whose selector they can't parse, which\n// is what Vue's :deep()/::v-deep/>>> escape hatches are - unsupported here,\n// and warned about rather than left to vanish\nconst scopeCss = (css: string, scope: string): string => {\n if (/:deep\\(|::v-deep|>>>/.test(css)) {\n console.warn(\"jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser\")\n }\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(css)\n scopeRules(sheet.cssRules, scope)\n return Array.from(sheet.cssRules).map(rule => rule.cssText).join(\"\\n\")\n}\n\n// converts a string of HTML into an AST representation of the component:\n// - template: the non-script/style top-level elements, as TemplateNodes\n// - scripts/styles: { attrs, content } blocks in source order\nconst parseComponentString = (component: string): ComponentParts => {\n // example\n // <script :setup=\"{ fname, lname }\">\n // const fullName = `${fname} ${lname}`\n // </script>\n //\n // <div :attrs=\"{ fullName }\"></div>\n // <div class=\"full-name\">\n // {{ fullName }}\n // </div>\n //\n // <style>\n // .full-name {\n // color: red;\n // }\n // </style>\n\n // parsed as the content of a <template> so leading <script>/<style> tags\n // aren't reparented into <head> by the HTML parser\n const parsedDOM = new DOMParser().parseFromString(`<template>${expandSelfClosingTags(component)}</template>`, \"text/html\")\n const root = parsedDOM.querySelector(\"template\") as HTMLTemplateElement\n\n const scripts: TagBlock[] = []\n const styles: TagBlock[] = []\n const template: TemplateNode[] = []\n\n Array.from(root.content.children).forEach(el => {\n const block: TagBlock = { attrs: elementAttrs(el), content: el.textContent ?? \"\" }\n\n if (el.tagName === \"SCRIPT\") scripts.push(block)\n else if (el.tagName === \"STYLE\") styles.push(block)\n else template.push(elementToAST(el))\n })\n\n // <style lang=\"scss\"> is compiled by the jq79/vite plugin, so a `lang` still\n // here means this component never went through it - it was fetched, loaded\n // from a URL, or built from an inline string. The browser would drop the\n // uncompiled source without a word, so say it out loud instead\n styles.forEach(style => {\n if (\"lang\" in style.attrs) {\n console.warn(\n `jq79: <style lang=\"${style.attrs.lang}\"> needs the jq79/vite plugin to compile it. ` +\n \"This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.\"\n )\n }\n })\n\n // scoping is resolved once, here: the stamped template and the scoped CSS\n // are what every instance of this definition renders and injects. An\n // uncompiled `lang` block is left as it was written - rewriting selectors\n // in something that isn't CSS yet would only garble what devtools shows\n const isScoped = (style: TagBlock) => \"scoped\" in style.attrs && !(\"lang\" in style.attrs)\n if (styles.some(isScoped)) {\n const scope = scopeHash(component)\n stampScope(template, scope)\n styles.forEach(style => {\n if (isScoped(style)) style.scoped = scopeCss(style.content, scope)\n })\n }\n\n return { template, scripts, styles }\n}\n\n// loads .html URLs as components, delegating anything else to native import()\nconst importResource = (url: string): Promise<any> =>\n /\\.html?([?#]|$)/.test(url) ? Component79.fetch(url) : import(url)\n\n// ---------------------------------------------------------------------------\n// naming scripts for devtools\n//\n// setup scripts are compiled with new Function (they need `with`, which is a\n// SyntaxError in a module), so no bundler source map can reach them: they show\n// up as an anonymous \"VM1234\" script, breakpoints don't survive a reload, and\n// stack traces name nothing. A //# sourceURL comment fixes all three - the\n// compiled script takes the component's name, so it is findable in the sources\n// tree, keeps its breakpoints, and appears by name in stack traces.\n//\n// The line numbers it reports are the compiled script's own, not the .html\n// file's: the engine wraps a Function body in a header (\"function anonymous(\n// args\\n) {\\n\") that shifts everything down, and no amount of padding can\n// shift code *up* to match a <script> sitting on line 1. Reporting the\n// component's real lines would need a source map, which the runtime doesn't\n// emit today\n// ---------------------------------------------------------------------------\n\n// where a script block came from: the component's filename, and its index\n// among the component's scripts (two scripts in one file need distinct names,\n// or devtools shows only one of them)\ntype ScriptLocation = { filename?: string; index?: number }\n\n// nothing to name an inline component's scripts after, so they stay anonymous\nconst sourceUrlComment = (filename: string | undefined, index: number): string =>\n filename ? `\\n//# sourceURL=${filename}?jq79-script=${index}` : \"\"\n\n// what a <style> block injects into document.head: the scoped rewrite when it\n// has one, the source otherwise. A shadow root uses `content` directly instead\n// - scoping is what a shadow root already does, and doing both would break the\n// `:host` rules only shadow rendering can have (`:host[data-jq79=...]` matches\n// nothing: the host element is outside the template, so it carries no stamp)\nconst headStyle = (style: TagBlock): string => style.scoped ?? style.content\n\n// document.head styles are shared by content and refcounted, so N instances\n// of the same component (e.g. one per :each item) inject a single <style> tag\n// that goes away when the last instance is destroyed\nconst styleRegistry = new Map<string, { el: HTMLStyleElement; count: number }>()\n\nconst acquireStyle = (content: string) => {\n let entry = styleRegistry.get(content)\n if (!entry) {\n const el = document.createElement(\"style\")\n el.textContent = content\n document.head.appendChild(el)\n entry = { el, count: 0 }\n styleRegistry.set(content, entry)\n }\n entry.count++\n}\n\nconst releaseStyle = (content: string) => {\n const entry = styleRegistry.get(content)\n if (entry && --entry.count <= 0) {\n entry.el.remove()\n styleRegistry.delete(content)\n }\n}\n\n// library helpers injected into setup scripts. They behave like extra\n// globals: a same-named scope property (render data or a top-level\n// declaration) shadows them\nconst SETUP_HELPERS: Record<string, any> = { $, $$, $create, $reactive }\n\n// scripts run inside `with (scriptScope)`, where scriptScope's `has` trap\n// claims ownership of every name that is neither a real global, an injected\n// library helper, nor one of the internal helpers. This makes `with` route ALL\n// other reads/writes through the reactive store - even bare assignments to\n// names never declared with let/const, which would otherwise leak onto\n// globalThis - while `console`, `Promise`, `fetch`, etc. still resolve\n// normally. get/set are deliberately not trapped: they default-forward to\n// `scope` (the reactive proxy), preserving tracking and notify.\n// The body is wrapped in an async IIFE so top-level `await` works: everything\n// up to the first await runs synchronously (before the template renders), and\n// later assignments update the DOM reactively when they happen\nconst runSetupScript = (code: string, scope: Record<string, any>, effect: (run: () => void) => void, instanceHelpers: Record<string, any> = {}, importer: (url: string) => Promise<any> = importResource, at: ScriptLocation = {}) => {\n // instanceHelpers are per-component-instance additions (e.g. $emit, which\n // is bound to this instance's DOM position)\n const helpers = { ...SETUP_HELPERS, ...instanceHelpers }\n const scriptScope = new Proxy(scope, {\n has: (target, key) =>\n key !== \"$__effect\" && key !== \"$__import\" &&\n (Reflect.has(target, key) || !(key in globalThis) && !(key in helpers)),\n })\n const result: Promise<void> = new Function(\n \"$scope\", \"$__effect\", \"$__import\", ...Object.keys(helpers),\n `return (async () => { with ($scope) { ${code} } })()${sourceUrlComment(at.filename, at.index ?? 0)}`\n )(scriptScope, effect, importer, ...Object.values(helpers))\n result.catch(error => console.error(\"jq79: error in :setup script\", error))\n}\n\n// default-import interop for factory scripts: real modules expose .default,\n// while importing an .html component resolves to the Component79 itself\nconst interopDefault = (mod: any) => (mod && mod.default !== undefined ? mod.default : mod)\n\n// runs a factory script: the (rewritten) module body executes in plain\n// lexical strict-mode scope - no `with`, no implicit reactivity - with the\n// library helpers as parameters, then the default export is called with the\n// instance context and a returned object is merged into the store. A fully\n// synchronous body invokes the factory before the first render, matching\n// setup-script timing; bodies with top-level await (static imports included)\n// resolve later and the template updates reactively\nconst runFactoryScript = (code: string, scope: Record<string, any>, effect: (run: () => void) => void, instanceHelpers: Record<string, any> = {}, importer: (url: string) => Promise<any> = importResource, at: ScriptLocation = {}) => {\n const helpers = { ...SETUP_HELPERS, ...instanceHelpers }\n const $__exports: { default?: (ctx: Record<string, any>) => any; done?: boolean } = {}\n const result: Promise<void> = new Function(\n \"$__exports\", \"$__default\", \"$__import\", ...Object.keys(helpers),\n `return (async () => { \"use strict\";\\n${code}\\n;$__exports.done = true })()${sourceUrlComment(at.filename, at.index ?? 0)}`\n )($__exports, interopDefault, importer, ...Object.values(helpers))\n\n const logError = (error: any) => console.error(\"jq79: error in factory script\", error)\n let invoked = false\n const invoke = () => {\n if (invoked) return\n invoked = true\n const factory = $__exports.default\n if (typeof factory !== \"function\") return\n const merge = (bindings: any) => {\n if (bindings && typeof bindings === \"object\") Object.assign(scope, bindings)\n }\n // the sync path is invoked straight from render(), so a throwing factory\n // must be caught here too - not just by the `result` rejection handler\n try {\n const returned = factory({ $data: scope, $effect: effect, ...instanceHelpers })\n if (returned instanceof Promise) returned.then(merge).catch(logError)\n else merge(returned)\n } catch (error) {\n logError(error)\n }\n }\n\n result.then(invoke, logError)\n if ($__exports.done) invoke() // fully-sync body: factory runs before first render\n}\n\n// ---------------------------------------------------------------------------\n// hot reload\n//\n// Both delivery paths want the same thing when a .html file changes: reparse\n// it, and re-render every live instance of it in place, keeping its data. The\n// swap lives in the runtime (hotReplace, below) so jq79/dev and the Vite\n// plugin share one implementation instead of two - and so it can reach the\n// private fields it needs (the markers, the holding fragment) rather than\n// poking at them from outside, which is what the plugin used to do.\n//\n// Finding the instances is the part only the runtime can do: a component\n// fetched at runtime is reachable from nothing but the DOM it rendered. So\n// instances register themselves - but only once a page opts in, before the\n// runtime loads. Nothing here costs a bundled app anything: with the registry\n// off, an instance is not tracked at all.\n// ---------------------------------------------------------------------------\n\nconst HOT_FLAG = \"__JQ79_HMR_ENABLED__\"\nconst HOT_RUNTIME = \"__JQ79_HMR__\"\n\n// live instances by filename. WeakRef because a destroyed component that the\n// page has dropped must stay collectable: `:each` churns through clones\nlet hotRegistry: Map<string, Set<WeakRef<Component79>>> | null = null\n\nconst hotRegister = (instance: Component79) => {\n if (!hotRegistry || !instance.filename) return\n let refs = hotRegistry.get(instance.filename)\n if (!refs) hotRegistry.set(instance.filename, (refs = new Set()))\n refs.add(new WeakRef(instance))\n}\n\n// the same file reaches the runtime under different names - \"./card.html\" from\n// an import() in a setup script, \"/cards/card.html\" from a fetch, \"cards/card.\n// html\" from the dev server that watched it - and they all have to land on one\n// key. Resolving against the page is what settles them\nconst hotKey = (filename: string): string => {\n try {\n return new URL(filename, document.baseURI).pathname\n } catch {\n return filename\n }\n}\n\n// swaps the file's new source into every instance that came from `filename`,\n// and returns how many of them were *on the page* and so re-rendered. Zero\n// means the change is not visible anywhere - the file is a page rather than a\n// component, or nothing has mounted it yet - and the caller (a dev server)\n// should fall back to reloading. Definitions and instances that have been\n// destroyed but not yet collected are patched all the same; they just don't\n// count, because nothing on screen changed for them\nexport const hotUpdate = (filename: string, src: string): number => {\n if (!hotRegistry) return 0\n\n const key = hotKey(filename)\n // parsed once and shared by every instance - which is already what a\n // definition and the clones :component makes from it do\n const parts = parseComponentString(src)\n\n let rerendered = 0\n for (const [name, refs] of hotRegistry) {\n if (hotKey(name) !== key) continue\n for (const ref of refs) {\n const instance = ref.deref()\n if (!instance) {\n refs.delete(ref) // collected since the last update\n continue\n }\n if (instance.hotReplace(parts)) rerendered++\n }\n if (!refs.size) hotRegistry.delete(name)\n }\n return rerendered\n}\n\n// starts tracking instances, so hotUpdate can find them. jq79/dev's client\n// calls this through the global handshake at the foot of this file; it is\n// exported so a bundled app - or a test - can opt in directly\nexport const enableHotReload = (): void => {\n hotRegistry ??= new Map()\n ;(globalThis as any)[HOT_RUNTIME] = { update: hotUpdate }\n}\n\ntype EmitListener = (event: CustomEvent, payload: any) => void\n\n// a parsed single-file component. Typical lifecycle:\n//\n// const jq79 = new Component79(src) // or await Component79.fetch(url)\n// jq79.on(\"submit\", (e, payload) => {}) // hear this instance's $emit events\n// jq79.mount(\"#app\", { user }) // render (reactive DOM, scripts, styles) + attach\n// ... // (mountShadow mounts into a shadow root)\n// jq79.detach() // detach, keeping state - mount() re-attaches\n// .destroy() // dispose effects and remove styles\nexport class Component79 {\n template: TemplateNode[]\n scripts: TagBlock[]\n styles: TagBlock[]\n // pre-resolved modules for setup-script `import(...)` calls (see\n // ComponentParts.modules); checked before falling back to fetch/import\n modules?: Record<string, any>\n // the component's origin, used to name its scripts in devtools\n filename?: string\n\n data: ReactiveDeepData<Record<string, any>> | null = null\n\n private fx: EffectScope | null = null\n // holds the rendered nodes while detached; anchors keep this fragment as\n // their parentNode, so effects keep the (detached) DOM up to date and a\n // later mount() shows current state\n private content: DocumentFragment | null = null\n // markers bracketing the component's output so detach() can collect nodes\n // that :if/:each inserted next to the anchors after mounting\n private startMarker: Comment | null = null\n private endMarker: Comment | null = null\n // shadow rendering keeps per-instance <style> elements; head rendering goes\n // through the shared refcounted styleRegistry instead\n private styleEls: HTMLStyleElement[] = []\n private ownsSharedStyles = false\n private useShadow = false\n private mountRoot: Element | ShadowRoot | DocumentFragment | null = null\n // settles the $mounted() promise handed to this render generation's scripts\n private resolveMounted: (() => void) | null = null\n // instance-level listeners for $emit events, registered with on(). Kept\n // outside the render generation so they survive re-render and destroy()\n private emitListeners = new Map<string, Set<EmitListener>>()\n\n constructor(src: string | ComponentParts, options: { modules?: Record<string, any>; filename?: string } = {}) {\n const parts = typeof src === \"string\" ? parseComponentString(src) : src\n this.template = parts.template\n this.scripts = parts.scripts\n this.styles = parts.styles\n this.modules = options.modules ?? (typeof src === \"string\" ? undefined : src.modules)\n this.filename = options.filename ?? (typeof src === \"string\" ? undefined : src.filename)\n hotRegister(this) // a no-op unless the page enabled hot reload\n }\n\n // swaps this component's parsed parts for `src`'s and, if it is on the page,\n // re-renders it where it stands - seeded with a snapshot of its data, so\n // props and store values survive (the setup script runs again, so whatever it\n // initializes is reset). Returns whether it re-rendered: an instance that was\n // never rendered is a *definition*, and patching its parts is all there is to\n // do - the clones :component made from it are instances in their own right,\n // registered under the same filename, and re-render themselves.\n //\n // Dev-only, and not part of the public API: jq79/dev and the Vite plugin call\n // it when a file changes. It re-attaches against the markers rather than\n // mountRoot on purpose - a nested clone is mounted into a fragment that is\n // then emptied into the page, so its mountRoot is a stale, detached fragment\n // while its markers sit where its DOM actually is\n hotReplace(src: string | ComponentParts): boolean {\n const parts = typeof src === \"string\" ? parseComponentString(src) : src\n const marker = this.startMarker\n const rendered = !!(marker && this.content)\n\n // where its output sits now, if it is on the page. A rendered-but-detached\n // instance (markers in the holding fragment) re-renders detached, and a\n // later mount() attaches the new output - like any update it missed away\n const live = rendered && marker!.isConnected\n const parent = live ? (marker!.parentNode as Element | ShadowRoot | DocumentFragment) : null\n const before = live ? this.endMarker!.nextSibling : null\n const data = { ...this.data }\n const shadow = this.useShadow\n\n // destroy() releases the styles it acquired, so it has to run while\n // this.styles is still the *old* set - swapping the parts first would leak\n // the old stylesheet into the head and release a new one nobody holds\n if (rendered) this.destroy()\n\n this.template = parts.template\n this.scripts = parts.scripts\n this.styles = parts.styles\n if (!rendered) return false // a definition: its clones re-render themselves\n\n this.renderWith(data, shadow)\n if (!parent) return false\n\n // shadow styles live inline, right before the DOM they style (attach()\n // appends them ahead of the content), so they go back the same way\n if (shadow) this.styleEls.forEach(el => parent.insertBefore(el, before))\n parent.insertBefore(this.content!, before)\n this.mountRoot = parent\n this.resolveMounted?.()\n return true\n }\n\n static async fetch(url: string): Promise<Component79> {\n const response = await fetch(url)\n if (!response.ok) throw new Error(`failed to fetch component from ${url}: ${response.status}`)\n // the URL names the component's scripts in devtools, and is where the\n // browser will look for the source when a breakpoint lands in one\n return new Component79(await response.text(), { filename: url })\n }\n\n // subscribes to this instance's $emit events, on top of the DOM CustomEvent\n // dispatch - so it hears emits even while the component is detached (where\n // the event has no ancestors to bubble to). Chainable; can be called before\n // render()\n on(eventName: string, listener: EmitListener): this {\n if (!this.emitListeners.has(eventName)) this.emitListeners.set(eventName, new Set())\n this.emitListeners.get(eventName)!.add(listener)\n return this\n }\n\n off(eventName: string, listener: EmitListener): this {\n this.emitListeners.get(eventName)?.delete(listener)\n return this\n }\n\n render(data: Record<string, any> = {}): this {\n return this.renderWith(data, false)\n }\n\n // like render(), but styles are injected into a shadow root attached to the\n // mount target instead of document.head, so they don't leak globally\n renderShadow(data: Record<string, any> = {}): this {\n return this.renderWith(data, true)\n }\n\n private renderWith(data: Record<string, any>, shadow: boolean): this {\n this.destroy()\n\n const store = $reactive({ ...data })\n const fx = createEffectScope(store)\n this.data = store\n this.fx = fx\n this.useShadow = shadow\n\n this.startMarker = document.createComment(\"jq79\")\n this.endMarker = document.createComment(\"/jq79\")\n\n // $emit dispatches a bubbling CustomEvent from this instance's start\n // marker, so once mounted it travels up the real DOM and parents can\n // listen on any ancestor (or with @event-name on a wrapping element).\n // Captures the marker rather than `this` so a later re-render's scripts\n // can't dispatch from the wrong generation - the same guard keeps stale\n // generations from reaching the instance's on() listeners\n const marker = this.startMarker\n const $emit = (eventName: string, payload?: any): boolean => {\n const event = new CustomEvent(eventName, { detail: payload, bubbles: true, composed: true })\n const result = marker.dispatchEvent(event)\n if (marker === this.startMarker) {\n this.emitListeners.get(eventName)?.forEach(listener => listener(event, payload))\n }\n return result\n }\n\n // `await $mounted()` suspends a setup script until mount() attaches the\n // component, so code below it can querySelector its own DOM. Resumption\n // is a microtask, so in the usual synchronous render().mount() flow the\n // whole tree (nested components included) is in the document before the\n // script continues. If this instance is never mounted, the promise stays\n // pending and the script's tail never runs\n let resolveMounted!: () => void\n const mounted = new Promise<void>(resolve => { resolveMounted = resolve })\n this.resolveMounted = resolveMounted\n const $mounted = () => mounted\n\n // $self / $$self mirror $ / $$ but only search this instance's own\n // output: the sibling nodes between its markers. They work detached too\n // (the holding fragment keeps markers and rendered nodes as siblings),\n // though the template renders after the scripts run, so they only find\n // something from post-await code or callbacks\n const endMarker = this.endMarker\n const $$self = (selector: string): Element[] => {\n const found: Element[] = []\n for (let node: Node | null = marker.nextSibling; node && node !== endMarker; node = node.nextSibling) {\n if (node instanceof Element) {\n if (node.matches(selector)) found.push(node)\n found.push(...Array.from(node.querySelectorAll(selector)))\n }\n }\n return found\n }\n const $self = (selector: string): Element | null => $$self(selector)[0] ?? null\n\n // import() calls whose specifier was pre-resolved by a bundler (the\n // modules map) get the bundled module; everything else falls back to the\n // runtime importResource (fetch for .html, native import otherwise)\n const modules = this.modules\n const $import = (url: string): Promise<any> =>\n modules && url in modules ? Promise.resolve(modules[url]) : importResource(url)\n\n // scripts run before the template renders so `$:` values are initialized;\n // a `:mounted` script defers entirely until mount() instead. A top-level\n // `export default` switches the script to factory mode (plain lexical JS)\n // a `:mounted` script is deferred by prepending the await on the code's own\n // first line, so deferring doesn't shift the lines devtools reports for it\n const defer = (code: string) => `await $mounted();${code}`\n\n this.scripts.forEach((script, index) => {\n const instanceHelpers = { $emit, $mounted, $self, $$self }\n const at: ScriptLocation = { filename: this.filename, index }\n const factoryCode = transformFactoryScript(script.content)\n if (factoryCode !== null) {\n const body = \":mounted\" in script.attrs ? defer(factoryCode) : factoryCode\n runFactoryScript(body, store, fx.effect, instanceHelpers, $import, at)\n return\n }\n const { vars, code } = transformSetupScript(script.content)\n // pre-declare script vars on the store so `with` resolves assignments\n // to them (and reads of them) through the reactive proxy\n vars.forEach(name => { if (!(name in store)) (store as any)[name] = undefined })\n const body = \":mounted\" in script.attrs ? defer(code) : code\n runSetupScript(body, store, fx.effect, instanceHelpers, $import, at)\n })\n\n const content = document.createDocumentFragment()\n content.append(this.startMarker, renderNodes(this.template, store, fx, shadow), this.endMarker)\n this.content = content\n\n if (shadow) {\n this.styleEls = this.styles.map(style => {\n const el = document.createElement(\"style\")\n el.textContent = style.content // the source: a shadow root scopes it already\n return el\n })\n } else {\n this.styles.forEach(style => acquireStyle(headStyle(style)))\n this.ownsSharedStyles = true\n }\n\n return this\n }\n\n // renders (when needed) and attaches in one call: the component is rendered\n // on the first mount, and re-rendered fresh whenever `data` is passed.\n // mount(el) on an already-rendered component just re-attaches, keeping its\n // state - the detach()/mount() round trip. Rendering here keeps whichever\n // style mode was last used (document.head unless renderShadow/mountShadow\n // chose a shadow root)\n mount(parent: Element | ShadowRoot | DocumentFragment | string, data?: Record<string, any>): this {\n const target = typeof parent === \"string\" ? $(parent) : parent\n if (!target) throw new Error(`mount target not found: ${parent}`)\n if (!this.content || data !== undefined) this.renderWith(data ?? {}, this.useShadow)\n return this.attach(target)\n }\n\n // like mount(), but renders with styles scoped to a shadow root on the\n // target instead of document.head\n mountShadow(parent: Element | ShadowRoot | DocumentFragment | string, data?: Record<string, any>): this {\n const target = typeof parent === \"string\" ? $(parent) : parent\n if (!target) throw new Error(`mount target not found: ${parent}`)\n if (!this.content || data !== undefined || !this.useShadow) this.renderWith(data ?? {}, true)\n return this.attach(target)\n }\n\n private attach(target: Element | ShadowRoot | DocumentFragment): this {\n if (this.mountRoot) this.detach()\n\n const root = this.useShadow && target instanceof Element\n ? target.shadowRoot ?? target.attachShadow({ mode: \"open\" })\n : target\n if (this.useShadow) this.styleEls.forEach(el => root.appendChild(el))\n root.appendChild(this.content!)\n this.mountRoot = root\n this.resolveMounted?.()\n return this\n }\n\n // detaches from the DOM while keeping all state; a later mount() re-attaches\n // with any updates that happened while detached already applied\n detach(): this {\n if (!this.mountRoot || !this.content || !this.startMarker || !this.endMarker) return this\n\n // move everything between the markers (inclusive) back into the holding\n // fragment - including nodes :if/:each inserted after mounting\n let node: Node | null = this.startMarker\n while (node) {\n const nextNode: Node | null = node.nextSibling\n this.content.appendChild(node)\n if (node === this.endMarker) break\n node = nextNode\n }\n\n this.mountRoot = null\n return this\n }\n\n destroy(): this {\n this.detach()\n this.fx?.dispose()\n this.fx = null\n // a store this component was handed (a shared `$reactive`) outlives it, and\n // holds a listener per store that nested it - drop this instance's\n this.data?.$dispose()\n this.styleEls.forEach(el => el.parentNode?.removeChild(el))\n this.styleEls = []\n if (this.ownsSharedStyles) {\n this.styles.forEach(style => releaseStyle(headStyle(style)))\n this.ownsSharedStyles = false\n }\n this.content = null\n this.startMarker = null\n this.endMarker = null\n this.data = null\n this.resolveMounted = null\n return this\n }\n}\n\nexport const parseComponent = (component: string): Component79 => new Component79(component)\n\n// the hot-reload handshake. jq79/dev serves a classic script that sets the flag\n// below; classic scripts run before deferred module ones, so the flag is always\n// set before this module evaluates. The page's copy of the runtime can come from\n// anywhere - a CDN, an import map, dist/ - and the dev client has no way to\n// import *that* copy, so the runtime hands itself to the client instead\nif (typeof globalThis !== \"undefined\" && (globalThis as any)[HOT_FLAG]) enableHotReload()\n\n","// DOM helpers: tiny query/create utilities, also injected into component\n// scripts as $, $$ and $create\n\n// $(selector) queries the document; $(el, selector) queries within el. The\n// selector is required in the element form - an empty one is a SyntaxError\nexport function $(selector: string): Element | null\nexport function $(el: Element, selector: string): Element | null\nexport function $(selectorOrEl: string | Element, selector?: string): Element | null {\n return typeof selectorOrEl === \"string\"\n ? document.querySelector(selectorOrEl)\n : selectorOrEl.querySelector(selector!)\n}\n\nexport function $$(selector: string): Element[]\nexport function $$(el: Element, selector: string): Element[]\nexport function $$(selectorOrEl: string | Element, selector?: string): Element[] {\n return Array.from(\n typeof selectorOrEl === \"string\"\n ? document.querySelectorAll(selectorOrEl)\n : selectorOrEl.querySelectorAll(selector!)\n )\n}\n\n// $create(tag, attrs): attrs are set as attributes, except className, which\n// may be a string or an array of class names.\nexport const $create = (tag: string, attrs: Record<string, any> = {}): HTMLElement => {\n const el = document.createElement(tag);\n for (const [name, value] of Object.entries(attrs)) {\n if (name === 'className') {\n el.className = Array.isArray(value) ? value.join(' ') : value;\n } else if (name === 'textContent') {\n el.textContent = value;\n } else if (name === 'children') {\n for (const child of value) {\n el.appendChild(child);\n }\n } else {\n el.setAttribute(name, value);\n }\n }\n return el;\n};\n\nconst ALLOWED_TAGS = new Set([\n 'a', 'b', 'i', 'em', 'strong', 'p', 'br', 'ul', 'ol', 'li',\n 'blockquote', 'code', 'pre', 'span', 'div', 'h1', 'h2', 'h3',\n 'h4', 'h5', 'h6', 'img'\n]);\n\nconst ALLOWED_ATTR: Record<string, Set<string>> = {\n a: new Set(['href', 'title']),\n img: new Set(['src', 'alt']),\n '*': new Set(['class']), // atributos permitidos en cualquier tag\n};\n\nconst SAFE_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:']);\n\nexport function isSafeUrl(value: string): boolean {\n try {\n // resolver relativo a algo neutro para poder leer el protocolo\n const url = new URL(value, 'https://example.com');\n return SAFE_URL_PROTOCOLS.has(url.protocol);\n } catch {\n return false;\n }\n}\n\n// copia los hijos de `source` en `target`, saneando los elementos y clonando\n// el texto; cualquier otra cosa (comentarios, etc.) se descarta\nfunction appendSanitizedChildren(source: ParentNode, target: HTMLElement): void {\n for (const child of Array.from(source.childNodes)) {\n if (child.nodeType === Node.ELEMENT_NODE) {\n const sanitizedChild = sanitizeNode(child as HTMLElement);\n if (sanitizedChild) target.appendChild(sanitizedChild);\n } else if (child.nodeType === Node.TEXT_NODE) {\n target.appendChild(child.cloneNode());\n }\n }\n}\n\n// sanea un elemento (los llamadores solo pasan nodos ELEMENT_NODE)\nfunction sanitizeNode(node: HTMLElement): HTMLElement | null {\n const tag = node.tagName.toLowerCase();\n if (!ALLOWED_TAGS.has(tag)) return null; // tag no permitido → se descarta el nodo entero\n\n const clean = document.createElement(tag);\n\n for (const attr of Array.from(node.attributes)) {\n const name = attr.name.toLowerCase();\n const allowedForTag = ALLOWED_ATTR[tag]?.has(name);\n const allowedGlobal = ALLOWED_ATTR['*']?.has(name);\n if (!allowedForTag && !allowedGlobal) continue;\n\n if ((name === 'href' || name === 'src') && !isSafeUrl(attr.value)) continue;\n\n clean.setAttribute(name, attr.value);\n }\n\n // fuerza rel seguro en enlaces (target nunca se copia: no está permitido)\n if (tag === 'a') clean.setAttribute('rel', 'noopener noreferrer');\n\n appendSanitizedChildren(node, clean);\n\n return clean;\n}\n\nexport function sanitizeHTML(html: string): string {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n const container = document.createElement('div');\n\n appendSanitizedChildren(doc.body, container);\n\n return container.innerHTML;\n}","// the reactive store ($reactive): proxy-based deep reactivity with\n// dot-path dependency tracking, plus the effect-scope helper the renderer\n// uses to tear down a subtree's bindings in one call\n\ntype ChangeListener = (value: any, dotKey: string) => void\ntype AnyChangeListener = (dotKey: string, value: any) => void\ntype ListenerOptions = { immediate?: boolean }\ntype Unsubscribe = () => void\n\nexport type ReactiveDeepData<T> = T & {\n $on: (dotKey: string, listener: ChangeListener, options?: ListenerOptions) => Unsubscribe\n $onAny: (listener: AnyChangeListener, options?: ListenerOptions) => Unsubscribe\n // runs `run` immediately, recording every dotKey it reads off this store, then\n // re-runs it whenever a changed dotKey overlaps one of those - see pathsOverlap\n $effect: (run: () => void) => Unsubscribe\n // drops this store's subscriptions to the stores nested inside it (see\n // bridge). A store that outlives the one holding it - the shared-state case -\n // would otherwise keep the dead holder's listeners on its own list forever\n $dispose: () => void\n}\n\nconst getByPath = (obj: Record<string, any>, dotKey: string): any =>\n dotKey.split(\".\").reduce((acc, key) => (acc == null ? undefined : acc[key]), obj)\n\n// only plain objects and arrays get deep-wrapped by the reactive store;\n// class instances (Component79, Date, DOM nodes, ...) pass through untouched\n// so their identity, prototypes and internals stay intact\nconst isPlainData = (value: object): boolean => {\n if (Array.isArray(value)) return true\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nconst walkLeaves = (obj: Record<string, any>, path: string, visit: (dotKey: string, value: any) => void) => {\n Object.entries(obj).forEach(([key, value]) => {\n const dotKey = path ? `${path}.${key}` : key\n if (value && typeof value === \"object\" && isPlainData(value)) walkLeaves(value, dotKey, visit)\n else visit(dotKey, value)\n })\n}\n\n// true when `a` and `b` sit on the same ancestor/descendant line, e.g.\n// \"user\" & \"user.address.city\" (a change to either affects the other) - false\n// for siblings like \"user.name\" & \"user.age\"\nconst pathsOverlap = (a: string, b: string): boolean =>\n a === b || a.startsWith(`${b}.`) || b.startsWith(`${a}.`)\n\n// reads the raw object behind a store proxy. Module-level (not per-store) so a\n// value that is already reactive - in this store or in another one - can be\n// unwrapped before being wrapped again. Without it, handing the same object to\n// two stores has each one wrapping the other's proxies, and since a wrap walks\n// what it wraps, the nesting compounds until the process stops responding\nconst RAW = Symbol(\"jq79.raw\")\n\nconst toRaw = <T>(value: T): T => {\n let raw: any = value\n while (raw !== null && typeof raw === \"object\" && raw[RAW]) raw = raw[RAW]\n return raw\n}\n\n// marks a store's *root* proxy. A store put inside another store (a setup\n// script's `const local = $reactive(...)`) has to pass through whole: it owns\n// its listeners and its $on/$effect, so unwrapping it would strip away the very\n// thing it is. Nested proxies carry no such marker and are unwrapped freely\nconst STORE = Symbol(\"jq79.store\")\n\nconst isStore = (value: any): boolean =>\n value !== null && typeof value === \"object\" && value[STORE] === true\n\n// active $effect() runs, innermost last - a module-level stack (rather than\n// one per store) so nested effects across stores still nest correctly; reads\n// during a proxy's `get` trap are attributed to whichever run is on top\nconst trackerStack: Set<string>[] = []\n\n// runs fn with dependency tracking suspended - reads inside it are attributed\n// to a throwaway set instead of the currently running effect\nexport const untracked = <T>(fn: () => T): T => {\n trackerStack.push(new Set())\n try {\n return fn()\n } finally {\n trackerStack.pop()\n }\n}\n\ntype Effect = { deps: Set<string>; run: () => void }\n\nexport const $reactive = <T extends Record<string, any>>(data: T): ReactiveDeepData<T> => {\n const exactListeners = new Map<string, Set<ChangeListener>>()\n const anyListeners = new Set<AnyChangeListener>()\n const effects = new Set<Effect>()\n\n // one proxy per raw object, for this store alone. Keyed by the *raw object*\n // rather than by its path, so identity travels with the object: :each diffs\n // its items by reference (Object.is), and a reordered list has to hand back\n // the same proxy for the same item or every row would re-render. The flip\n // side is that an object's path is fixed when it is first wrapped, so after a\n // reorder its notifications carry the old index - effects that read the list\n // itself still wake up (pathsOverlap), which is what makes it a non-issue in\n // practice\n const proxies = new WeakMap<object, Record<string, any>>()\n\n // $on/$onAny/$effect are served from the root proxy's `get` instead of being\n // defined on the object: a store must leave nothing behind on the data it was\n // handed, and two stores over one object would otherwise clobber each other's\n // handles. Null-prototype, so `key in storeApi` can't match Object.prototype\n const storeApi: Record<string, any> = Object.create(null)\n\n const notify = (dotKey: string, value: any, isNewKey = false) => {\n exactListeners.get(dotKey)?.forEach(listener => listener(value, dotKey))\n anyListeners.forEach(listener => listener(dotKey, value))\n effects.forEach(effect => {\n // a newly-created key re-runs every effect: an effect that read the\n // name while it didn't exist couldn't track it (`with` skipped the\n // store entirely), so dep matching would never wake it up\n if (isNewKey || Array.from(effect.deps).some(dep => pathsOverlap(dep, dotKey))) effect.run()\n })\n }\n\n const isWrappable = (value: any): value is Record<string, any> =>\n value !== null && typeof value === \"object\" && isPlainData(value)\n\n // a store nested inside this one keeps its own listeners and its own effects,\n // and this store's effects are not among them - so a write through the inner\n // store notifies nobody out here, and a component rendering `{{ cart.items }}`\n // off a `$reactive` it was handed would never update. The holder subscribes\n // instead, and re-notifies the inner store's changes under the path it sits at\n // (\"items.0\" -> \"cart.items.0\"). An effect that read through `cart` recorded\n // exactly that path's ancestor as a dependency, so pathsOverlap wakes it.\n // Chains compose: re-notifying runs this store's own $onAny listeners, which\n // is how a store two levels down still reaches the top\n const bridges = new Map<string, { store: any; unsubscribe: Unsubscribe }>()\n\n const bridge = (store: any, path: string) => {\n const current = bridges.get(path)\n if (current?.store === store) return\n current?.unsubscribe()\n bridges.set(path, {\n store,\n unsubscribe: store.$onAny((dotKey: string, value: any) => notify(`${path}.${dotKey}`, value)),\n })\n }\n\n // the key no longer holds the store it held: stop listening to it\n const unbridge = (path: string) => {\n bridges.get(path)?.unsubscribe()\n bridges.delete(path)\n }\n\n // the reactive view of `raw`, created on demand. Callers must hand it a raw\n // object (see toRaw at both call sites): wrapping a proxy is what compounds\n const wrap = (raw: Record<string, any>, path: string): Record<string, any> => {\n const cached = proxies.get(raw)\n if (cached) return cached\n\n const proxy: Record<string, any> = new Proxy(raw, {\n get(target, key, receiver) {\n if (key === RAW) return target\n if (key === STORE) return path === \"\"\n if (typeof key !== \"string\") return Reflect.get(target, key, receiver)\n if (path === \"\" && key in storeApi) return storeApi[key]\n\n const dotKey = path ? `${path}.${key}` : key\n trackerStack[trackerStack.length - 1]?.add(dotKey)\n\n // nested objects are wrapped here rather than up front, so the object\n // handed to $reactive is never rewritten\n const value = Reflect.get(target, key, receiver)\n if (isStore(value)) {\n bridge(value, dotKey)\n return value\n }\n\n const raw = toRaw(value)\n return isWrappable(raw) ? wrap(raw, dotKey) : raw\n },\n set(target, key: string, value, receiver) {\n // an assignment delegated up the prototype chain from a derived scope\n // (Object.create(store) child, or a wrapping proxy): if the key isn't\n // a real property of this store, honor the receiver so the new binding\n // lands on the derived scope - a scope-local variable, not a store\n // mutation, so no notify. If the key IS a store property, fall through\n // and mutate the store itself regardless of receiver, so assignments\n // like @click=\"count = count + 1\" work from any nested scope\n if (receiver !== proxy && !Object.prototype.hasOwnProperty.call(target, key)) {\n return Reflect.set(target, key, value, receiver)\n }\n\n const dotKey = path ? `${path}.${key}` : key\n // store the raw value, never a proxy - including one of our own, so\n // that `list = [list[1], list[0]]` doesn't write proxies back into the\n // data. Reads re-wrap it, from the cache, as the very same proxy. A\n // whole store assigned in is the exception: it stays as it is\n const stored = isStore(value) ? value : toRaw(value)\n const isNewKey = !Object.prototype.hasOwnProperty.call(target, key)\n target[key] = stored\n if (isStore(stored)) bridge(stored, dotKey)\n else unbridge(dotKey)\n const notified = isStore(stored) || !isWrappable(stored) ? stored : wrap(stored, dotKey)\n notify(dotKey, notified, isNewKey)\n return true\n }\n })\n\n proxies.set(raw, proxy)\n return proxy\n }\n\n const reactive = wrap(toRaw(data), \"\") as ReactiveDeepData<T>\n\n // a store handed in with the data (a prop, or render data) is bridged here\n // rather than on first read, so a listener registered before anything reads\n // the key still hears it. Only the top level is scanned: that's where a prop\n // lands, and descending would mean walking whatever else was handed in - a\n // highlighter, an API client - to its leaves. A store sitting deeper is\n // bridged when the read that reaches it wraps its parent\n Object.entries(toRaw(data)).forEach(([key, value]) => {\n if (isStore(value)) bridge(value, key)\n })\n\n const $on = (dotKey: string, listener: ChangeListener, { immediate = false }: ListenerOptions = {}): Unsubscribe => {\n if (!exactListeners.has(dotKey)) exactListeners.set(dotKey, new Set())\n exactListeners.get(dotKey)!.add(listener)\n if (immediate) listener(getByPath(reactive, dotKey), dotKey)\n return () => exactListeners.get(dotKey)?.delete(listener)\n }\n\n const $onAny = (listener: AnyChangeListener, { immediate = false }: ListenerOptions = {}): Unsubscribe => {\n anyListeners.add(listener)\n if (immediate) walkLeaves(reactive, \"\", (dotKey, value) => listener(dotKey, value))\n return () => anyListeners.delete(listener)\n }\n\n const $effect = (run: () => void): Unsubscribe => {\n const effect: Effect = {\n deps: new Set(),\n run: () => {\n const deps = new Set<string>()\n trackerStack.push(deps)\n try {\n run()\n } finally {\n trackerStack.pop()\n effect.deps = deps\n }\n },\n }\n effects.add(effect)\n effect.run()\n return () => { effects.delete(effect) }\n }\n\n const $dispose = () => {\n bridges.forEach(({ unsubscribe }) => unsubscribe())\n bridges.clear()\n }\n\n storeApi.$on = $on\n storeApi.$onAny = $onAny\n storeApi.$effect = $effect\n storeApi.$dispose = $dispose\n\n return reactive\n}\n// groups the disposers of every $effect created for one rendered subtree\n// (an :if branch, an :each item, ...) so the whole subtree's bindings can be\n// torn down in one call when that subtree is replaced/removed. `scope.$effect`\n// resolves through the prototype chain up to the root store no matter how\n// many nested :each scopes sit in between (see renderEach's itemScope)\nexport type EffectScope = {\n effect: (run: () => void) => void\n // registers an arbitrary cleanup (e.g. destroying a nested component) to\n // run when this subtree is torn down\n onDispose: (fn: Unsubscribe) => void\n dispose: () => void\n}\n\nexport const createEffectScope = (scope: Record<string, any>): EffectScope => {\n const disposers: Unsubscribe[] = []\n return {\n effect: run => { disposers.push(scope.$effect(run)) },\n onDispose: fn => { disposers.push(fn) },\n dispose: () => { disposers.splice(0).forEach(dispose => dispose()) },\n }\n}\n","// ---------------------------------------------------------------------------\n// :setup script transform\n//\n// setup scripts are written like Svelte components:\n//\n// let firstName = null\n// $: fullName = `${firstName} ${lastName}`\n// fetchUser().then(user => { firstName = user.firstName })\n//\n// and are executed inside `with ($scope)` against the component's reactive\n// store, so plain assignments (even from async callbacks) go through the\n// proxy's set trap and re-render whatever depends on them. To make that work\n// the source is lightly rewritten - no full JS parser, just a scanner that is\n// string/comment-aware and only touches code at brace/paren depth 0:\n// - `let/var/const x = ...` at the top level loses its keyword, becoming a\n// scope assignment (the name is pre-declared on the store so the `with`\n// lookup resolves it)\n// - `$: x = expr` becomes `$__effect(() => { x = expr })`, re-running when a\n// dependency read inside expr changes ($__effect is deliberately NOT a\n// property of the scope, so `with` falls through to the function parameter)\n// ---------------------------------------------------------------------------\n\ntype SetupTransform = { vars: string[]; code: string }\n\nconst DECLARATION_RE = /(?:let|var|const)\\s+([A-Za-z_$][\\w$]*)/y\nconst REACTIVE_LABEL_RE = /\\$:\\s*/y\nconst IMPORT_CALL_RE = /import(?=\\s*\\()/y\nconst REACTIVE_ASSIGN_RE = /\\$:\\s*([A-Za-z_$][\\w$]*)\\s*=(?!=)/y\n\nconst skipString = (src: string, start: number): number => {\n const quote = src[start]\n let i = start + 1\n while (i < src.length) {\n if (src[i] === \"\\\\\") { i += 2; continue }\n if (src[i] === quote) return i + 1\n i++\n }\n return src.length\n}\n\nconst skipLineComment = (src: string, start: number): number => {\n const end = src.indexOf(\"\\n\", start)\n return end === -1 ? src.length : end\n}\n\nconst skipBlockComment = (src: string, start: number): number => {\n const end = src.indexOf(\"*/\", start + 2)\n return end === -1 ? src.length : end + 2\n}\n\n// index of the next thing that isn't whitespace or a comment\nconst skipToToken = (src: string, start: number): number => {\n let i = start\n while (i < src.length) {\n if (/\\s/.test(src[i])) { i++; continue }\n if (src[i] === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (src[i] === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n break\n }\n return i\n}\n\n// tokens that can't *start* a statement, so a line beginning with one is\n// continuing the previous expression rather than opening a new statement -\n// the same call JS's automatic semicolon insertion makes. Unary-only forms\n// (!, ~, ++, --) are deliberately absent: those do start a statement, and JS\n// inserts the semicolon before them\nconst CONTINUATION_RE = /^(\\?\\.|\\?\\?|&&|\\|\\||\\*\\*|[.,+\\-*/%&|^<>=?:([])/\n\n// end of a statement starting at `start`: the first `;` or line break that\n// isn't inside a string/comment or unbalanced brackets. A line break only\n// ends the statement if the next line can't continue it, so leading-dot\n// method chains and multi-line operator chains stay in one piece:\n//\n// $: total = items\n// .filter(item => item.active) <- still the same statement\n// .length\nconst findStatementEnd = (src: string, start: number): number => {\n let depth = 0\n let i = start\n while (i < src.length) {\n const ch = src[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth--\n else if (depth <= 0 && ch === \";\") return i\n else if (depth <= 0 && ch === \"\\n\") {\n const next = skipToToken(src, i + 1)\n if (next >= src.length || !CONTINUATION_RE.test(src.slice(next, next + 2))) return i\n i = next\n continue\n }\n i++\n }\n return src.length\n}\n\nexport const transformSetupScript = (src: string): SetupTransform => {\n const vars: string[] = []\n let out = \"\"\n let i = 0\n let depth = 0\n let atStatementStart = true\n\n while (i < src.length) {\n const ch = src[i]\n const next = src[i + 1]\n\n if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n const end = skipString(src, i)\n out += src.slice(i, end)\n i = end\n atStatementStart = false\n continue\n }\n if (ch === \"/\" && (next === \"/\" || next === \"*\")) {\n const end = next === \"/\" ? skipLineComment(src, i) : skipBlockComment(src, i)\n out += src.slice(i, end)\n i = end\n continue\n }\n\n // `import(...)` is a keyword form, so it can't be intercepted through the\n // scope - rewrite the identifier to the injected $__import (which loads\n // .html URLs as components via Component79.fetch and delegates the rest to\n // native import). The `(` is left for the scanner so depth stays balanced\n if (ch === \"i\" && (i === 0 || !/[\\w$.]/.test(src[i - 1]))) {\n IMPORT_CALL_RE.lastIndex = i\n if (IMPORT_CALL_RE.test(src)) {\n out += \"$__import\"\n i += \"import\".length\n atStatementStart = false\n continue\n }\n }\n\n if (depth === 0 && atStatementStart) {\n DECLARATION_RE.lastIndex = i\n const decl = DECLARATION_RE.exec(src)\n if (decl) {\n vars.push(decl[1])\n out += decl[1]\n i += decl[0].length\n atStatementStart = false\n continue\n }\n\n REACTIVE_LABEL_RE.lastIndex = i\n const label = REACTIVE_LABEL_RE.exec(src)\n if (label) {\n REACTIVE_ASSIGN_RE.lastIndex = i\n const assign = REACTIVE_ASSIGN_RE.exec(src)\n if (assign) vars.push(assign[1])\n const start = i + label[0].length\n const end = findStatementEnd(src, start)\n out += `$__effect(() => { ${src.slice(start, end)} });`\n i = end\n continue\n }\n }\n\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth = Math.max(0, depth - 1)\n\n if (ch === \"\\n\" || ch === \";\" || ch === \"}\") atStatementStart = true\n else if (!/\\s/.test(ch)) atStatementStart = false\n\n out += ch\n i++\n }\n\n return { vars, code: out }\n}\n\n// ---------------------------------------------------------------------------\n// factory scripts - a <script> whose top level has `export default` runs as a\n// plain lexical module instead of a `with`-scoped setup script: no implicit\n// reactivity, no `$:` labels - standard JS that editors and type-checkers\n// understand. The default export is called with the instance context\n// ({ $data, $effect, $emit, $mounted, $self, $$self }) and a returned object\n// is merged into the reactive store for the template to use.\n// Detection is backwards-safe: `export default` is a SyntaxError inside a\n// setup script, so no previously-working component can change behavior.\n// The same scanner rewrites the module-only syntax into a Function body:\n// - `export default X` -> `$__exports.default = X`\n// - `import d from \"m\"` -> `const d = $__default(await $__import(\"m\"))`\n// (and the other static clause forms), so imports resolve through the same\n// $__import as setup scripts: bundler map first, then fetch/native import\n// ---------------------------------------------------------------------------\n\nconst EXPORT_DEFAULT_RE = /export\\s+default(?![\\w$])/y\n// clause (default/namespace/named, no quotes or parens) + specifier; the\n// no-clause alternative requires the specifier right away, so dynamic\n// `import(...)` and `import.meta` never match\nconst STATIC_IMPORT_RE = /import\\s*(?:([\\w$\\s,{}*]+?)\\s*from\\s*)?([\"'])([^\"'\\n]+)\\2/y\n\n// splits an import clause on top-level commas: `d, { a, b as c }` keeps the\n// braced group together\nconst splitImportClause = (clause: string): string[] => {\n const parts: string[] = []\n let depth = 0\n let start = 0\n for (let i = 0; i <= clause.length; i++) {\n const ch = clause[i]\n if (ch === \"{\") depth++\n else if (ch === \"}\") depth--\n else if (i === clause.length || (ch === \",\" && depth === 0)) {\n const part = clause.slice(start, i).trim()\n if (part) parts.push(part)\n start = i + 1\n }\n }\n return parts\n}\n\n// one static import statement -> const bindings from the awaited module\nconst staticImportToAwait = (clause: string | undefined, spec: string, n: number): string => {\n const source = `await $__import(${JSON.stringify(spec)})`\n if (clause === undefined) return source // side-effect import\n const parts = splitImportClause(clause)\n const bindings: string[] = []\n let ref = source\n if (parts.length > 1) {\n const tmp = `$__mod${n}`\n bindings.push(`${tmp} = ${source}`)\n ref = tmp\n }\n for (const part of parts) {\n if (part.startsWith(\"{\")) bindings.push(`${part.replace(/\\s+as\\s+/g, \": \")} = ${ref}`)\n else if (part.startsWith(\"*\")) bindings.push(`${part.replace(/^\\*\\s*as\\s+/, \"\")} = ${ref}`)\n else bindings.push(`${part} = $__default(${ref})`)\n }\n return `const ${bindings.join(\", \")}`\n}\n\n// rewrites a factory script into a Function body, or returns null when the\n// script has no top-level `export default` (i.e. it's a regular setup script)\nexport const transformFactoryScript = (src: string): string | null => {\n let out = \"\"\n let i = 0\n let depth = 0\n let atStatementStart = true\n let isFactory = false\n let modCount = 0\n\n while (i < src.length) {\n const ch = src[i]\n const next = src[i + 1]\n const atWordBoundary = i === 0 || !/[\\w$.]/.test(src[i - 1])\n\n if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n const end = skipString(src, i)\n out += src.slice(i, end)\n i = end\n atStatementStart = false\n continue\n }\n if (ch === \"/\" && (next === \"/\" || next === \"*\")) {\n const end = next === \"/\" ? skipLineComment(src, i) : skipBlockComment(src, i)\n out += src.slice(i, end)\n i = end\n continue\n }\n\n if (ch === \"i\" && atWordBoundary) {\n // dynamic import() -> $__import, same rewrite as setup scripts\n IMPORT_CALL_RE.lastIndex = i\n if (IMPORT_CALL_RE.test(src)) {\n out += \"$__import\"\n i += \"import\".length\n atStatementStart = false\n continue\n }\n if (depth === 0 && atStatementStart) {\n STATIC_IMPORT_RE.lastIndex = i\n const staticImport = STATIC_IMPORT_RE.exec(src)\n if (staticImport) {\n out += staticImportToAwait(staticImport[1], staticImport[3], modCount++)\n i += staticImport[0].length\n atStatementStart = false\n continue\n }\n }\n }\n\n if (ch === \"e\" && atWordBoundary && depth === 0 && atStatementStart) {\n EXPORT_DEFAULT_RE.lastIndex = i\n const exportDefault = EXPORT_DEFAULT_RE.exec(src)\n if (exportDefault) {\n isFactory = true\n out += \"$__exports.default =\"\n i += exportDefault[0].length\n atStatementStart = false\n continue\n }\n }\n\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth = Math.max(0, depth - 1)\n\n if (ch === \"\\n\" || ch === \";\" || ch === \"}\") atStatementStart = true\n else if (!/\\s/.test(ch)) atStatementStart = false\n\n out += ch\n i++\n }\n\n return isFactory ? out : null\n}\n\n"],"mappings":"+jBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,OAAAE,EAAA,OAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,gBAAAC,EAAA,oBAAAC,GAAA,cAAAC,GAAA,mBAAAC,GAAA,oBAAAC,KCOO,SAASC,EAAEC,EAAgCC,EAAmC,CACnF,OAAO,OAAOD,GAAiB,SAC3B,SAAS,cAAcA,CAAY,EACnCA,EAAa,cAAcC,CAAS,CAC1C,CAIO,SAASC,EAAGF,EAAgCC,EAA8B,CAC/E,OAAO,MAAM,KACX,OAAOD,GAAiB,SACpB,SAAS,iBAAiBA,CAAY,EACtCA,EAAa,iBAAiBC,CAAS,CAC7C,CACF,CAIO,IAAME,EAAU,CAACC,EAAaC,EAA6B,CAAC,IAAmB,CACpF,IAAMC,EAAK,SAAS,cAAcF,CAAG,EACrC,OAAW,CAACG,EAAMC,CAAK,IAAK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AAgB","names":["jq79_exports","__export","$","$$","$create","$reactive","Component79","enableHotReload","hotUpdate","parseComponent","renderComponent","$","selectorOrEl","selector","$$","$create","tag","attrs","el","name","value","child","ALLOWED_TAGS","ALLOWED_ATTR","SAFE_URL_PROTOCOLS","isSafeUrl","url","appendSanitizedChildren","source","target","sanitizedChild","sanitizeNode","node","clean","attr","allowedForTag","allowedGlobal","sanitizeHTML","html","doc","container","getByPath","obj","dotKey","acc","key","isPlainData","value","proto","walkLeaves","path","visit","pathsOverlap","a","b","RAW","toRaw","raw","STORE","isStore","trackerStack","untracked","fn","$reactive","data","exactListeners","anyListeners","effects","proxies","storeApi","notify","isNewKey","listener","effect","dep","isWrappable","bridges","bridge","store","current","unbridge","wrap","cached","proxy","target","receiver","stored","notified","reactive","$on","immediate","$onAny","$effect","run","deps","$dispose","unsubscribe","createEffectScope","scope","disposers","dispose","DECLARATION_RE","REACTIVE_LABEL_RE","IMPORT_CALL_RE","REACTIVE_ASSIGN_RE","skipString","src","start","quote","i","skipLineComment","end","skipBlockComment","skipToToken","CONTINUATION_RE","findStatementEnd","depth","ch","next","transformSetupScript","vars","out","atStatementStart","decl","label","assign","EXPORT_DEFAULT_RE","STATIC_IMPORT_RE","splitImportClause","clause","parts","part","staticImportToAwait","spec","source","bindings","ref","tmp","transformFactoryScript","isFactory","modCount","atWordBoundary","staticImport","exportDefault","elementAttrs","el","attr","elementToAST","node","text","compiled","compileExpr","expr","params","key","fn","evalExpr","scope","extras","interpolate","template","_","CONTROL_ATTRS","EACH_PATTERN","bindEvent","name","modifiers","mods","event","handler","kebabToCamel","c","findComponentKey","tag","normalized","obj","renderNestedComponent","fx","shadow","anchor","wrapper","props","value","SCOPE_ATTR","current","currentDef","childFx","nextDef","Component79","instance","seed","untracked","holder","syncFx","createEffectScope","createWithScope","source","target","renderNode","outerScope","withExpr","componentKey","upgraded","bindExpr","boundKeys","bound","textExpr","htmlExpr","sanitizeHTML","renderNodes","renderConditional","branches","activeBranch","branchFx","next","branch","defineScopeVar","renderEach","match","itemName","listExpr","keyExpr","_each","_key","itemAttrs","itemNode","entries","list","items","previous","entry","nextEntries","item","index","itemScope","existing","itemFx","nextKeys","prevNode","nodes","fragment","i","textNode","nextBranch","candidate","elseif","elseNode","renderComponent","component","data","VOID_ELEMENTS","SELF_CLOSING_RE","RAW_BLOCK_RE","expandSelfClosingTags","src","chunk","attrs","scopeHash","hash","stampScope","scopeSelector","selectorText","part","selector","pseudoAt","pseudoElement","scopeRules","rules","rule","scopeCss","css","sheet","parseComponentString","root","scripts","styles","block","style","isScoped","importResource","url","sourceUrlComment","filename","headStyle","styleRegistry","acquireStyle","content","releaseStyle","SETUP_HELPERS","$","$$","$create","$reactive","runSetupScript","code","effect","instanceHelpers","importer","at","helpers","scriptScope","error","interopDefault","mod","runFactoryScript","$__exports","result","logError","invoked","invoke","factory","merge","bindings","returned","HOT_FLAG","HOT_RUNTIME","hotRegistry","hotRegister","refs","hotKey","hotUpdate","parts","rerendered","ref","enableHotReload","_Component79","options","__publicField","marker","rendered","live","parent","before","response","eventName","listener","store","$emit","payload","resolveMounted","mounted","resolve","$mounted","endMarker","$$self","found","$self","modules","$import","defer","script","factoryCode","transformFactoryScript","body","vars","transformSetupScript","nextNode","parseComponent"]}
1
+ {"version":3,"sources":["../src/jq79.ts","../src/dom.ts","../src/reactive.ts","../src/transform.ts"],"sourcesContent":["\nimport { $, $$, $create, sanitizeHTML } from \"./dom\"\nimport { $reactive, untracked, createEffectScope } from \"./reactive\"\nimport type { ReactiveDeepData, EffectScope } from \"./reactive\"\nimport { transformSetupScript, transformFactoryScript, parsePropsPattern, parseFactoryProps, type PropDecl } from \"./transform\"\n\nexport { $, $$, $create } from \"./dom\"\nexport { $reactive } from \"./reactive\"\ntype TemplateNode = {\n tag: string\n attrs: Record<string, string>\n children: (TemplateNode | string)[]\n}\n\ntype TagBlock = {\n attrs: Record<string, string>\n content: string\n // <style scoped> only: `content` rewritten to require the component's scope\n // attribute. Kept beside the original rather than replacing it, because a\n // shadow root doesn't want it - see headStyle()\n scoped?: string\n}\n\nconst elementAttrs = (el: Element): Record<string, string> =>\n Object.fromEntries(Array.from(el.attributes).map(attr => [attr.name, attr.value]))\n\n// text is kept verbatim - not trimmed, not dropped when it's only whitespace.\n// A template is HTML, so the space in `<span>a</span>\\n<span>b</span>` is the\n// same space the browser would collapse-and-render between them, and CSS gets\n// to decide what it's worth (nothing in a block or flex container, one space\n// between inline elements). Trimming it here, as this used to, silently glued\n// siblings together and ate the spaces in `hola <b>mundo</b> adios`\nconst elementToAST = (el: Element): TemplateNode => ({\n tag: el.tagName.toLowerCase(),\n attrs: elementAttrs(el),\n children: Array.from(el.childNodes).flatMap((node): (TemplateNode | string)[] => {\n if (node.nodeType === Node.TEXT_NODE) {\n const text = node.textContent ?? \"\"\n return text ? [text] : []\n }\n if (node.nodeType === Node.ELEMENT_NODE) {\n return [elementToAST(node as Element)]\n }\n return []\n })\n})\n\n// evaluated with `with` (rather than passing scope keys as positional params)\n// so only the identifiers an expression actually references are read from\n// `scope` - which is what makes dependency tracking in $reactive\n// precise instead of \"read everything up front\". `extras` are passed as\n// function parameters (outside the `with`), so scope keys still win but names\n// like $event resolve when the scope doesn't shadow them\n//\n// Compiled functions are cached: an expression is re-evaluated on every effect\n// run - once per interpolation, once per :each item - while the set of distinct\n// expressions is fixed by the source. The `extras` names are part of the key,\n// not just the expression: they become the function's parameters, so the same\n// expression compiled with and without $event is two different functions. A\n// syntactically invalid expression caches its failure (null) so it isn't\n// recompiled, and rethrown as undefined, exactly as before\nconst compiled = new Map<string, Function | null>()\n\nconst compileExpr = (expr: string, params: string[]): Function | null => {\n const key = `${params.join(\",\")}|${expr}`\n let fn = compiled.get(key)\n if (fn === undefined) {\n try {\n fn = new Function(\"$scope\", ...params, `with ($scope) { return (${expr}); }`)\n } catch {\n fn = null // a syntax error: it will never compile, so don't try again\n }\n compiled.set(key, fn)\n }\n return fn\n}\n\nconst evalExpr = (expr: string, scope: Record<string, any>, extras?: Record<string, any>): any => {\n const fn = compileExpr(expr, extras ? Object.keys(extras) : [])\n if (!fn) return undefined\n try {\n return fn(scope, ...(extras ? Object.values(extras) : []))\n } catch {\n return undefined\n }\n}\n\n// [\\s\\S] rather than `.` so an expression can span lines, like the ones in\n// directive attributes (which reach evalExpr wrapped in parens either way)\nconst interpolate = (template: string, scope: Record<string, any>): string =>\n template.replace(/{{\\s*([\\s\\S]+?)\\s*}}/g, (_, expr) => evalExpr(expr, scope) ?? \"\")\n\n\nconst CONTROL_ATTRS = new Set([\":attrs\", \":if\", \":elseif\", \":else\", \":each\", \":key\", \":with\", \":text\", \":html\"])\n// the list expression can span lines, so it matches [\\s\\S] rather than `.`\nconst EACH_PATTERN = /^\\s*(\\w+)\\s+in\\s+([\\s\\S]+)$/\n\ntype ConditionalBranch = { expr?: string; node: TemplateNode }\n\n\n// @event attributes: @click=\"onClick\", @submit.prevent=\"$event => onSubmit($event)\",\n// or an inline statement like @click=\"count = count + 1\". The expression is\n// evaluated (with `$event` in scope) on every event; if it yields a function,\n// that function is then invoked with the event - so both a handler reference\n// and an inline arrow/statement work. Modifiers after dots: .prevent .stop\n// .self (runtime guards) and .once .capture (addEventListener options)\nconst bindEvent = (el: Element, attr: string, expr: string, scope: Record<string, any>) => {\n const [name, ...modifiers] = attr.slice(1).split(\".\")\n const mods = new Set(modifiers)\n\n el.addEventListener(name, event => {\n if (mods.has(\"self\") && event.target !== el) return\n if (mods.has(\"prevent\")) event.preventDefault()\n if (mods.has(\"stop\")) event.stopPropagation()\n\n const handler = evalExpr(expr, scope, { $event: event })\n if (typeof handler === \"function\") handler.call(el, event)\n }, { once: mods.has(\"once\"), capture: mods.has(\"capture\") })\n}\n\nconst kebabToCamel = (name: string) => name.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase())\n\n// finds the scope variable a template tag refers to. HTML parsing lowercases\n// tag names, so <NestedComponent> arrives as \"nestedcomponent\" and matching is\n// case-insensitive with dashes stripped (<nested-component> works too). Only\n// PascalCase scope keys participate, so ordinary variables named like real\n// elements (title, code, ...) never hijack them\nconst findComponentKey = (scope: Record<string, any>, tag: string): string | null => {\n const normalized = tag.replace(/-/g, \"\").toLowerCase()\n for (let obj: any = scope; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) {\n for (const key of Object.keys(obj)) {\n if (/^[A-Z]/.test(key) && key.replace(/-/g, \"\").toLowerCase() === normalized) return key\n }\n }\n return null\n}\n\n// <MyComponent :user :title=\"'str'\"></MyComponent> - renders a child\n// component instance at this position. Props: `:name=\"expr\"` evaluates expr\n// in the parent scope (`:name` alone is shorthand for `:name=\"name\"`), plain\n// attributes pass through as literal strings, and kebab-case prop names\n// become camelCase. Props stay live: a parent effect re-evaluates each\n// expression and writes it into the child's store. The component variable is\n// reactive too - while it's undefined (e.g. an `await import(...)` still in\n// flight) nothing renders, and the child appears when it resolves.\n// `shadow` is the parent's style mode, carried down the whole render: a child\n// of a shadow-rendered component renders inside that shadow root, so its\n// <style> has to go in there with it - document.head can't reach into a shadow\n// tree, and a style that never applies to its own component would still be\n// restyling the page around it\nconst renderNestedComponent = (key: string, node: TemplateNode, scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const anchor = document.createComment(key)\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n const props: Record<string, string> = {} // prop name -> expression in parent scope\n Object.entries(node.attrs).forEach(([attr, value]) => {\n // the parent's scope stamp is stamped on every template element, this tag\n // included - it's not a prop, and the child renders under its own scope\n if (attr === SCOPE_ATTR || CONTROL_ATTRS.has(attr) || attr.startsWith(\"@\")) return\n if (attr.startsWith(\":\")) {\n const name = kebabToCamel(attr.slice(1))\n props[name] = value || name\n } else {\n props[kebabToCamel(attr)] = JSON.stringify(value)\n }\n })\n\n let current: Component79 | null = null\n let currentDef: Component79 | null = null\n let childFx: EffectScope | null = null\n\n fx.effect(() => {\n const value = evalExpr(key, scope)\n const nextDef = value instanceof Component79 ? value : null\n if (nextDef === currentDef) return\n\n childFx?.dispose()\n childFx = null\n current?.destroy() // detaches its marker range, removing the child's DOM\n current = null\n currentDef = nextDef\n if (!nextDef) return\n\n // a fresh instance per usage site: the definition's parsed parts (and\n // pre-resolved modules) are shared, but store/effects/DOM are per instance\n const instance = new Component79({\n template: nextDef.template,\n scripts: nextDef.scripts,\n styles: nextDef.styles,\n modules: nextDef.modules,\n filename: nextDef.filename,\n })\n const seed = untracked(() =>\n Object.fromEntries(Object.entries(props).map(([name, expr]) => [name, evalExpr(expr, scope)]))\n )\n // mounting into a fragment attaches no shadow root of its own: a\n // shadow-rendered child keeps its <style> elements inline, next to the DOM\n // they style, and the parent's shadow root is what scopes both\n const holder = document.createDocumentFragment()\n ;(shadow ? instance.renderShadow(seed) : instance.render(seed)).mount(holder)\n anchor.parentNode!.insertBefore(holder, anchor.nextSibling)\n\n const syncFx = createEffectScope(scope)\n Object.entries(props).forEach(([name, expr]) => {\n syncFx.effect(() => { (instance.data as Record<string, any>)[name] = evalExpr(expr, scope) })\n })\n\n childFx = syncFx\n current = instance\n })\n\n fx.onDispose(() => {\n childFx?.dispose()\n current?.destroy()\n })\n\n return wrapper\n}\n\n// :with=\"expr\" narrows the scope for an element and its subtree: names\n// resolve against the expression's value first, then fall back to the outer\n// scope. The value is re-evaluated lazily on every name lookup (never\n// snapshotted), so an effect reading through this proxy tracks both the\n// expression's own dependencies and the property it reads - replacing the\n// object or mutating one of its properties re-renders exactly the dependents,\n// without rebuilding the subtree. Assignments to names the object owns write\n// through to it (reactively, if it came from a store); everything else\n// behaves as if the :with weren't there\nconst createWithScope = (expr: string, scope: Record<string, any>): Record<string, any> => {\n const source = (): Record<string, any> | null => {\n const value = evalExpr(expr, scope)\n return value !== null && typeof value === \"object\" ? value : null\n }\n return new Proxy(scope, {\n has(target, key) {\n const obj = source()\n return (obj !== null && Reflect.has(obj, key)) || Reflect.has(target, key)\n },\n get(target, key) {\n const obj = source()\n if (obj !== null && Reflect.has(obj, key)) return obj[key as string]\n return Reflect.get(target, key)\n },\n set(target, key, value) {\n const obj = source()\n if (obj !== null && Reflect.has(obj, key)) {\n obj[key as string] = value\n return true\n }\n return Reflect.set(target, key, value)\n },\n })\n}\n\n// renders a single element node: static attrs, @event listeners, a reactive\n// :attrs object, and its content - :text/:html override the element's own\n// children with a reactive textContent/innerHTML, otherwise children render\n// normally. :if/:elseif/:else/:each are handled by renderNodes, which decides\n// *whether*/*how many times* a node is rendered before calling this. Tags\n// matching a PascalCase scope variable render as nested components instead\nconst renderNode = (node: TemplateNode, outerScope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n // :with applies to the element's own bindings (@events, :attrs) and its\n // whole subtree. On a :each element the item scope is already in place, so\n // :with=\"item\" works\n const withExpr = node.attrs[\":with\"]\n const scope = withExpr !== undefined ? createWithScope(withExpr, outerScope) : outerScope\n\n const componentKey = findComponentKey(scope, node.tag)\n if (componentKey) return renderNestedComponent(componentKey, node, scope, fx, shadow)\n\n const el = document.createElement(node.tag)\n\n // a tag that isn't standard HTML but has no matching scope key *yet* may be\n // a component that arrives later (e.g. an async factory script exposing an\n // imported component after `await`). Watch for the key: the effect tracks\n // no deps, so it only re-runs on the store's new-key sweep, and swaps the\n // placeholder element for the component exactly once\n if (el instanceof HTMLUnknownElement || node.tag.includes(\"-\")) {\n let upgraded = false\n fx.effect(() => {\n if (upgraded) return\n const key = findComponentKey(scope, node.tag)\n if (!key) return\n upgraded = true\n el.replaceWith(renderNestedComponent(key, node, scope, fx, shadow))\n })\n }\n\n Object.entries(node.attrs).forEach(([key, value]) => {\n if (key.startsWith(\"@\")) bindEvent(el, key, value, scope)\n else if (!CONTROL_ATTRS.has(key)) el.setAttribute(key, value)\n })\n\n const bindExpr = node.attrs[\":attrs\"]\n if (bindExpr !== undefined) {\n let boundKeys: string[] = []\n\n fx.effect(() => {\n boundKeys.forEach(key => el.removeAttribute(key))\n const bound = evalExpr(bindExpr, scope)\n boundKeys = bound && typeof bound === \"object\" ? Object.keys(bound) : []\n boundKeys.forEach(key => {\n const value = bound[key]\n if (value != null && value !== false) el.setAttribute(key, String(value))\n })\n })\n }\n\n // :text=\"expr\" sets textContent reactively, replacing any children.\n // :html=\"expr\" sets innerHTML reactively, sanitizing the value first so\n // untrusted content can't inject scripts/attributes (see sanitizeHTML in\n // ./dom). Both skip rendering the element's own children/interpolation\n const textExpr = node.attrs[\":text\"]\n const htmlExpr = node.attrs[\":html\"]\n if (textExpr !== undefined) {\n fx.effect(() => { el.textContent = String(evalExpr(textExpr, scope) ?? \"\") })\n } else if (htmlExpr !== undefined) {\n fx.effect(() => { el.innerHTML = sanitizeHTML(String(evalExpr(htmlExpr, scope) ?? \"\")) })\n } else {\n el.appendChild(renderNodes(node.children, scope, fx, shadow))\n }\n\n return el\n}\n\n// a :if/:elseif*/:else? chain sharing one anchor comment so the active branch\n// can be swapped in place without disturbing sibling positions. Only depends\n// on whatever the branch expressions read (e.g. \"score\"), and skips\n// rebuilding entirely when the active branch hasn't actually changed\nconst renderConditional = (branches: ConditionalBranch[], scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const anchor = document.createComment(\"if\")\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n let current: Node | null = null\n let activeBranch: ConditionalBranch | null = null\n let branchFx: EffectScope | null = null\n\n fx.effect(() => {\n const next = branches.find(branch => branch.expr === undefined || evalExpr(branch.expr, scope)) ?? null\n if (next === activeBranch) return\n\n branchFx?.dispose()\n if (current) current.parentNode?.removeChild(current)\n current = null\n activeBranch = next\n if (!next) return\n\n branchFx = createEffectScope(scope)\n current = renderNode(next.node, scope, branchFx, shadow)\n anchor.parentNode!.insertBefore(current, anchor.nextSibling)\n })\n\n return wrapper\n}\n\n// defines a loop-local binding directly as `scope`'s own property. Plain\n// assignment (scope[key] = value) would only do this if the key isn't\n// already own on `scope` *or anywhere up its prototype chain* - if it isn't,\n// JS delegates the [[Set]] to whatever's up there, which for us is another\n// reactive proxy's `set` trap: it would wrap `value` as if it were a genuine\n// store mutation and fire a bogus notify() under a name (e.g. \"item\") shared\n// by every unrelated item in every :each on the page. defineProperty always\n// writes to `scope` itself, never delegating, so this can't happen\nconst defineScopeVar = (scope: Record<string, any>, key: string, value: any) => {\n Object.defineProperty(scope, key, { value, writable: true, enumerable: true, configurable: true })\n}\n\ntype EachEntry = { key: any; item: any; scope: Record<string, any>; node: Node; fx: EffectScope }\n\n// :each=\"item in items\", optionally keyed with :key=\"expr\". Only depends on\n// the list expression itself (e.g. \"items\"), and on each run diffs by key:\n// unchanged items (same key, same item reference) keep their DOM/effects,\n// changed/added ones are (re)rendered, removed ones are disposed. Without\n// :key, position is used as the key, so reordering rebuilds every item after\n// the first change - add :key for anything that gets reordered or filtered.\n// Each item gets its own scope via Object.create(scope), so `item`/`$index`\n// shadow same-named outer bindings without copying the parent scope's keys\nconst renderEach = (node: TemplateNode, scope: Record<string, any>, fx: EffectScope, shadow: boolean): Node => {\n const match = node.attrs[\":each\"].match(EACH_PATTERN)\n if (!match) return document.createComment(`invalid :each expression \"${node.attrs[\":each\"]}\"`)\n\n const [, itemName, listExpr] = match\n const keyExpr = node.attrs[\":key\"]\n const { [\":each\"]: _each, [\":key\"]: _key, ...itemAttrs } = node.attrs\n const itemNode: TemplateNode = { ...node, attrs: itemAttrs }\n\n const anchor = document.createComment(\"each\")\n const wrapper = document.createDocumentFragment()\n wrapper.appendChild(anchor)\n\n let entries: EachEntry[] = []\n\n fx.effect(() => {\n const list = evalExpr(listExpr, scope)\n const items = Array.isArray(list) ? list : []\n const previous = new Map(entries.map(entry => [entry.key, entry]))\n\n const nextEntries = items.map((item, index): EachEntry => {\n const itemScope = Object.create(scope)\n defineScopeVar(itemScope, itemName, item)\n defineScopeVar(itemScope, \"$index\", index)\n const key = keyExpr !== undefined ? evalExpr(keyExpr, itemScope) : index\n const existing = previous.get(key)\n\n if (existing && Object.is(existing.item, item)) {\n defineScopeVar(existing.scope, \"$index\", index)\n return existing\n }\n\n existing?.fx.dispose()\n existing?.node.parentNode?.removeChild(existing.node)\n\n const itemFx = createEffectScope(scope)\n return { key, item, scope: itemScope, fx: itemFx, node: renderNode(itemNode, itemScope, itemFx, shadow) }\n })\n\n const nextKeys = new Set(nextEntries.map(entry => entry.key))\n entries.forEach(entry => {\n if (!nextKeys.has(entry.key)) {\n entry.fx.dispose()\n entry.node.parentNode?.removeChild(entry.node)\n }\n })\n\n let prevNode: Node = anchor\n nextEntries.forEach(entry => {\n if (prevNode.nextSibling !== entry.node) anchor.parentNode!.insertBefore(entry.node, prevNode.nextSibling)\n prevNode = entry.node\n })\n\n entries = nextEntries\n })\n\n return wrapper\n}\n\n// renders a list of sibling template nodes (text + elements), grouping\n// consecutive :if/:elseif/:else nodes into a single conditional block\nconst renderNodes = (nodes: (TemplateNode | string)[], scope: Record<string, any>, fx: EffectScope, shadow = false): DocumentFragment => {\n const fragment = document.createDocumentFragment()\n let i = 0\n\n while (i < nodes.length) {\n const node = nodes[i]\n\n if (typeof node === \"string\") {\n const textNode = document.createTextNode(node)\n // static text is most of a template (all of its indentation, for a start):\n // only text with a {{ expression }} in it needs an effect to stay in sync\n if (node.includes(\"{{\")) fx.effect(() => { textNode.textContent = interpolate(node, scope) })\n fragment.appendChild(textNode)\n i++\n continue\n }\n\n if (\":each\" in node.attrs) {\n fragment.appendChild(renderEach(node, scope, fx, shadow))\n i++\n continue\n }\n\n if (\":if\" in node.attrs) {\n const branches: ConditionalBranch[] = [{ expr: node.attrs[\":if\"], node }]\n i++\n\n // the branches of a chain are siblings in the AST, but the template writes\n // them on their own lines - so the whitespace between them is indentation\n // and nothing else, and it's dropped rather than rendered: only one branch\n // is ever in the DOM, so there is nothing for it to be a space *between*\n const nextBranch = (attr: string): TemplateNode | undefined => {\n let next = i\n while (next < nodes.length && typeof nodes[next] === \"string\" && !(nodes[next] as string).trim()) next++\n const candidate = nodes[next]\n if (typeof candidate === \"object\" && attr in candidate.attrs) {\n i = next + 1\n return candidate\n }\n return undefined\n }\n\n for (let elseif = nextBranch(\":elseif\"); elseif; elseif = nextBranch(\":elseif\")) {\n branches.push({ expr: elseif.attrs[\":elseif\"], node: elseif })\n }\n const elseNode = nextBranch(\":else\")\n if (elseNode) branches.push({ node: elseNode })\n\n fragment.appendChild(renderConditional(branches, scope, fx, shadow))\n continue\n }\n\n fragment.appendChild(renderNode(node, scope, fx, shadow))\n i++\n }\n\n return fragment\n}\n\nexport const renderComponent = (component: Component79, data: ReactiveDeepData<Record<string, any>>, shadow = false): Node =>\n renderNodes(component.template, data, createEffectScope(data), shadow)\n\ntype ComponentParts = {\n template: TemplateNode[]\n scripts: TagBlock[]\n styles: TagBlock[]\n // pre-resolved modules for `import(...)` calls in setup scripts, keyed by\n // the literal specifier. Bundlers (the jq79/vite plugin) fill this so\n // imports resolve from the bundle instead of being fetched at runtime\n modules?: Record<string, any>\n // where this component came from (a URL for fetch(), a path for the vite\n // plugin). Names the setup scripts in devtools - see scriptSourceUrl\n filename?: string\n}\n\nconst VOID_ELEMENTS = new Set([\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\",\n \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\",\n])\n\n// a self-closing tag with its attributes; quoted attribute values are matched\n// as whole chunks so a \"/>\" inside one doesn't end the tag early\nconst SELF_CLOSING_RE = /<([A-Za-z][\\w-]*)((?:\"[^\"]*\"|'[^']*'|[^>\"'])*?)\\/>/g\nconst RAW_BLOCK_RE = /(<script[\\s\\S]*?<\\/script\\s*>|<style[\\s\\S]*?<\\/style\\s*>)/gi\n\n// expands self-closing tags (<MyComponent />, <div />) into explicit\n// open+close pairs BEFORE DOM parsing. The HTML parser ignores the slash and\n// would treat them as unclosed, swallowing the following siblings. Void\n// elements keep their native behavior, and <script>/<style> contents are\n// passed through untouched so code inside them is never rewritten\nconst expandSelfClosingTags = (src: string): string =>\n src\n .split(RAW_BLOCK_RE)\n .map((chunk, i) =>\n i % 2 === 1 // odd chunks are the captured script/style blocks\n ? chunk\n : chunk.replace(SELF_CLOSING_RE, (match, tag: string, attrs: string) =>\n VOID_ELEMENTS.has(tag.toLowerCase()) ? match : `<${tag}${attrs}></${tag}>`\n )\n )\n .join(\"\")\n\n// <style scoped> support. Every element of the component's own template is\n// stamped with data-jq79=\"<hash>\" and the style's selectors are rewritten to\n// require that attribute, so its rules can't reach anything the component\n// didn't render. Purely a runtime transform (the browser parses the CSS), so\n// it works the same for a bundled component and one loaded with fetch()\nconst SCOPE_ATTR = \"data-jq79\"\n\n// FNV-1a over the source: stable per definition (not per instance), so N\n// instances of the same component share one refcounted <style> in the head\nconst scopeHash = (src: string): string => {\n let hash = 2166136261\n for (let i = 0; i < src.length; i++) hash = Math.imul(hash ^ src.charCodeAt(i), 16777619)\n return (hash >>> 0).toString(36)\n}\n\nconst stampScope = (nodes: (TemplateNode | string)[], scope: string) => {\n nodes.forEach(node => {\n if (typeof node === \"string\") return\n node.attrs[SCOPE_ATTR] = scope\n stampScope(node.children, scope)\n })\n}\n\n// the scope attribute goes on the selector's last compound - the element the\n// rule actually targets - but *before* a pseudo-element, which must stay last\n// (\".a::before\" scopes to \".a[data-jq79='x']::before\", not \"::before[...]\")\nconst scopeSelector = (selectorText: string, scope: string): string =>\n selectorText\n .split(\",\")\n .map(part => {\n const selector = part.trim()\n const pseudoAt = selector.indexOf(\"::\")\n const target = pseudoAt === -1 ? selector : selector.slice(0, pseudoAt)\n const pseudoElement = pseudoAt === -1 ? \"\" : selector.slice(pseudoAt)\n return `${target}[${SCOPE_ATTR}=\"${scope}\"]${pseudoElement}`\n })\n .join(\", \")\n\n// CSSStyleRule is scoped in place; CSSGroupingRule (@media, @supports,\n// @container) is recursed into; everything else - notably @keyframes, whose\n// \"selectors\" are percentages - is left alone\nconst scopeRules = (rules: CSSRuleList, scope: string) => {\n Array.from(rules).forEach(rule => {\n if (rule instanceof CSSStyleRule) rule.selectorText = scopeSelector(rule.selectorText, scope)\n else if (rule instanceof CSSGroupingRule) scopeRules(rule.cssRules, scope)\n })\n}\n\n// the CSS parser is the browser's own (no dependency, no hand-rolled parser).\n// Note browsers *silently drop* rules whose selector they can't parse, which\n// is what Vue's :deep()/::v-deep/>>> escape hatches are - unsupported here,\n// and warned about rather than left to vanish\nconst scopeCss = (css: string, scope: string): string => {\n if (/:deep\\(|::v-deep|>>>/.test(css)) {\n console.warn(\"jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser\")\n }\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(css)\n scopeRules(sheet.cssRules, scope)\n return Array.from(sheet.cssRules).map(rule => rule.cssText).join(\"\\n\")\n}\n\n// converts a string of HTML into an AST representation of the component:\n// - template: the non-script/style top-level elements, as TemplateNodes\n// - scripts/styles: { attrs, content } blocks in source order\nconst parseComponentString = (component: string): ComponentParts => {\n // example\n // <script :setup=\"{ fname, lname }\">\n // const fullName = `${fname} ${lname}`\n // </script>\n //\n // <div :attrs=\"{ fullName }\"></div>\n // <div class=\"full-name\">\n // {{ fullName }}\n // </div>\n //\n // <style>\n // .full-name {\n // color: red;\n // }\n // </style>\n\n // parsed as the content of a <template> so leading <script>/<style> tags\n // aren't reparented into <head> by the HTML parser\n const parsedDOM = new DOMParser().parseFromString(`<template>${expandSelfClosingTags(component)}</template>`, \"text/html\")\n const root = parsedDOM.querySelector(\"template\") as HTMLTemplateElement\n\n const scripts: TagBlock[] = []\n const styles: TagBlock[] = []\n const template: TemplateNode[] = []\n\n Array.from(root.content.children).forEach(el => {\n const block: TagBlock = { attrs: elementAttrs(el), content: el.textContent ?? \"\" }\n\n if (el.tagName === \"SCRIPT\") scripts.push(block)\n else if (el.tagName === \"STYLE\") styles.push(block)\n else template.push(elementToAST(el))\n })\n\n // <style lang=\"scss\"> is compiled by the jq79/vite plugin, so a `lang` still\n // here means this component never went through it - it was fetched, loaded\n // from a URL, or built from an inline string. The browser would drop the\n // uncompiled source without a word, so say it out loud instead\n styles.forEach(style => {\n if (\"lang\" in style.attrs) {\n console.warn(\n `jq79: <style lang=\"${style.attrs.lang}\"> needs the jq79/vite plugin to compile it. ` +\n \"This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.\"\n )\n }\n })\n\n // scoping is resolved once, here: the stamped template and the scoped CSS\n // are what every instance of this definition renders and injects. An\n // uncompiled `lang` block is left as it was written - rewriting selectors\n // in something that isn't CSS yet would only garble what devtools shows\n const isScoped = (style: TagBlock) => \"scoped\" in style.attrs && !(\"lang\" in style.attrs)\n if (styles.some(isScoped)) {\n const scope = scopeHash(component)\n stampScope(template, scope)\n styles.forEach(style => {\n if (isScoped(style)) style.scoped = scopeCss(style.content, scope)\n })\n }\n\n return { template, scripts, styles }\n}\n\n// loads .html URLs as components, delegating anything else to native import()\nconst importResource = (url: string): Promise<any> =>\n /\\.html?([?#]|$)/.test(url) ? Component79.fetch(url) : import(url)\n\n// ---------------------------------------------------------------------------\n// naming scripts for devtools\n//\n// setup scripts are compiled with new Function (they need `with`, which is a\n// SyntaxError in a module), so no bundler source map can reach them: they show\n// up as an anonymous \"VM1234\" script, breakpoints don't survive a reload, and\n// stack traces name nothing. A //# sourceURL comment fixes all three - the\n// compiled script takes the component's name, so it is findable in the sources\n// tree, keeps its breakpoints, and appears by name in stack traces.\n//\n// The line numbers it reports are the compiled script's own, not the .html\n// file's: the engine wraps a Function body in a header (\"function anonymous(\n// args\\n) {\\n\") that shifts everything down, and no amount of padding can\n// shift code *up* to match a <script> sitting on line 1. Reporting the\n// component's real lines would need a source map, which the runtime doesn't\n// emit today\n// ---------------------------------------------------------------------------\n\n// where a script block came from: the component's filename, and its index\n// among the component's scripts (two scripts in one file need distinct names,\n// or devtools shows only one of them)\ntype ScriptLocation = { filename?: string; index?: number }\n\n// nothing to name an inline component's scripts after, so they stay anonymous\nconst sourceUrlComment = (filename: string | undefined, index: number): string =>\n filename ? `\\n//# sourceURL=${filename}?jq79-script=${index}` : \"\"\n\n// what a <style> block injects into document.head: the scoped rewrite when it\n// has one, the source otherwise. A shadow root uses `content` directly instead\n// - scoping is what a shadow root already does, and doing both would break the\n// `:host` rules only shadow rendering can have (`:host[data-jq79=...]` matches\n// nothing: the host element is outside the template, so it carries no stamp)\nconst headStyle = (style: TagBlock): string => style.scoped ?? style.content\n\n// document.head styles are shared by content and refcounted, so N instances\n// of the same component (e.g. one per :each item) inject a single <style> tag\n// that goes away when the last instance is destroyed\nconst styleRegistry = new Map<string, { el: HTMLStyleElement; count: number }>()\n\nconst acquireStyle = (content: string) => {\n let entry = styleRegistry.get(content)\n if (!entry) {\n const el = document.createElement(\"style\")\n el.textContent = content\n document.head.appendChild(el)\n entry = { el, count: 0 }\n styleRegistry.set(content, entry)\n }\n entry.count++\n}\n\nconst releaseStyle = (content: string) => {\n const entry = styleRegistry.get(content)\n if (entry && --entry.count <= 0) {\n entry.el.remove()\n styleRegistry.delete(content)\n }\n}\n\n// library helpers injected into setup scripts. They behave like extra\n// globals: a same-named scope property (render data or a top-level\n// declaration) shadows them\nconst SETUP_HELPERS: Record<string, any> = { $, $$, $create, $reactive }\n\n// scripts run inside `with (scriptScope)`, where scriptScope's `has` trap\n// claims ownership of every name that is neither a real global, an injected\n// library helper, nor one of the internal helpers. This makes `with` route ALL\n// other reads/writes through the reactive store - even bare assignments to\n// names never declared with let/const, which would otherwise leak onto\n// globalThis - while `console`, `Promise`, `fetch`, etc. still resolve\n// normally. get/set are deliberately not trapped: they default-forward to\n// `scope` (the reactive proxy), preserving tracking and notify.\n// The body is wrapped in an async IIFE so top-level `await` works: everything\n// up to the first await runs synchronously (before the template renders), and\n// later assignments update the DOM reactively when they happen\nconst runSetupScript = (code: string, scope: Record<string, any>, effect: (run: () => void) => void, instanceHelpers: Record<string, any> = {}, importer: (url: string) => Promise<any> = importResource, at: ScriptLocation = {}) => {\n // instanceHelpers are per-component-instance additions (e.g. $emit, which\n // is bound to this instance's DOM position)\n const helpers = { ...SETUP_HELPERS, ...instanceHelpers }\n const scriptScope = new Proxy(scope, {\n has: (target, key) =>\n key !== \"$__effect\" && key !== \"$__import\" &&\n (Reflect.has(target, key) || !(key in globalThis) && !(key in helpers)),\n })\n const result: Promise<void> = new Function(\n \"$scope\", \"$__effect\", \"$__import\", ...Object.keys(helpers),\n `return (async () => { with ($scope) { ${code} } })()${sourceUrlComment(at.filename, at.index ?? 0)}`\n )(scriptScope, effect, importer, ...Object.values(helpers))\n result.catch(error => console.error(\"jq79: error in :setup script\", error))\n}\n\n// puts a component's declared props on the store, before any script runs and\n// before the first render: the names, so the template can bind to them even\n// when the parent passes nothing, and the defaults, so it binds to something.\n//\n// A prop the parent *did* pass is already on the store (render() seeds it), so\n// a default only fills an `undefined` - which is also what JS destructuring\n// does with the same pattern, so both modes agree. It happens once, at setup:\n// re-applying a default later would need an effect that reads and writes the\n// same key, and that effect would wake itself forever.\n//\n// `null` props means the component declared no signature at all, which is not\n// the same as declaring an empty one: it keeps today's permissive behavior\nconst declareProps = (store: Record<string, any>, props: PropDecl[] | null) => {\n props?.forEach(({ name, default: expr }) => {\n if (store[name] !== undefined) return\n store[name] = expr === undefined ? undefined : evalExpr(expr, store)\n })\n}\n\n// default-import interop for factory scripts: real modules expose .default,\n// while importing an .html component resolves to the Component79 itself\nconst interopDefault = (mod: any) => (mod && mod.default !== undefined ? mod.default : mod)\n\n// runs a factory script: the (rewritten) module body executes in plain\n// lexical strict-mode scope - no `with`, no implicit reactivity - with the\n// library helpers as parameters, then the default export is called with the\n// instance context and a returned object is merged into the store. A fully\n// synchronous body invokes the factory before the first render, matching\n// setup-script timing; bodies with top-level await (static imports included)\n// resolve later and the template updates reactively\nconst runFactoryScript = (code: string, scope: Record<string, any>, effect: (run: () => void) => void, instanceHelpers: Record<string, any> = {}, importer: (url: string) => Promise<any> = importResource, at: ScriptLocation = {}) => {\n const helpers = { ...SETUP_HELPERS, ...instanceHelpers }\n const $__exports: { default?: (props: Record<string, any>, ctx: Record<string, any>) => any; done?: boolean } = {}\n const result: Promise<void> = new Function(\n \"$__exports\", \"$__default\", \"$__import\", ...Object.keys(helpers),\n `return (async () => { \"use strict\";\\n${code}\\n;$__exports.done = true })()${sourceUrlComment(at.filename, at.index ?? 0)}`\n )($__exports, interopDefault, importer, ...Object.values(helpers))\n\n const logError = (error: any) => console.error(\"jq79: error in factory script\", error)\n let invoked = false\n const invoke = () => {\n if (invoked) return\n invoked = true\n const factory = $__exports.default\n if (typeof factory !== \"function\") return\n const merge = (bindings: any) => {\n if (bindings && typeof bindings === \"object\") Object.assign(scope, bindings)\n }\n // the sync path is invoked straight from render(), so a throwing factory\n // must be caught here too - not just by the `result` rejection handler\n try {\n // props first, ctx second. Both are the store: the pattern destructures\n // the props it declared (copying, as destructuring does - $props is the\n // live view for a primitive the parent reassigns later)\n const returned = factory(scope, { $data: scope, $props: scope, $effect: effect, ...instanceHelpers })\n if (returned instanceof Promise) returned.then(merge).catch(logError)\n else merge(returned)\n } catch (error) {\n logError(error)\n }\n }\n\n result.then(invoke, logError)\n if ($__exports.done) invoke() // fully-sync body: factory runs before first render\n}\n\n// ---------------------------------------------------------------------------\n// hot reload\n//\n// Both delivery paths want the same thing when a .html file changes: reparse\n// it, and re-render every live instance of it in place, keeping its data. The\n// swap lives in the runtime (hotReplace, below) so jq79/dev and the Vite\n// plugin share one implementation instead of two - and so it can reach the\n// private fields it needs (the markers, the holding fragment) rather than\n// poking at them from outside, which is what the plugin used to do.\n//\n// Finding the instances is the part only the runtime can do: a component\n// fetched at runtime is reachable from nothing but the DOM it rendered. So\n// instances register themselves - but only once a page opts in, before the\n// runtime loads. Nothing here costs a bundled app anything: with the registry\n// off, an instance is not tracked at all.\n// ---------------------------------------------------------------------------\n\nconst HOT_FLAG = \"__JQ79_HMR_ENABLED__\"\nconst HOT_RUNTIME = \"__JQ79_HMR__\"\n\n// live instances by filename. WeakRef because a destroyed component that the\n// page has dropped must stay collectable: `:each` churns through clones\nlet hotRegistry: Map<string, Set<WeakRef<Component79>>> | null = null\n\nconst hotRegister = (instance: Component79) => {\n if (!hotRegistry || !instance.filename) return\n let refs = hotRegistry.get(instance.filename)\n if (!refs) hotRegistry.set(instance.filename, (refs = new Set()))\n refs.add(new WeakRef(instance))\n}\n\n// the same file reaches the runtime under different names - \"./card.html\" from\n// an import() in a setup script, \"/cards/card.html\" from a fetch, \"cards/card.\n// html\" from the dev server that watched it - and they all have to land on one\n// key. Resolving against the page is what settles them\nconst hotKey = (filename: string): string => {\n try {\n return new URL(filename, document.baseURI).pathname\n } catch {\n return filename\n }\n}\n\n// swaps the file's new source into every instance that came from `filename`,\n// and returns how many of them were *on the page* and so re-rendered. Zero\n// means the change is not visible anywhere - the file is a page rather than a\n// component, or nothing has mounted it yet - and the caller (a dev server)\n// should fall back to reloading. Definitions and instances that have been\n// destroyed but not yet collected are patched all the same; they just don't\n// count, because nothing on screen changed for them\nexport const hotUpdate = (filename: string, src: string): number => {\n if (!hotRegistry) return 0\n\n const key = hotKey(filename)\n // parsed once and shared by every instance - which is already what a\n // definition and the clones :component makes from it do\n const parts = parseComponentString(src)\n\n let rerendered = 0\n for (const [name, refs] of hotRegistry) {\n if (hotKey(name) !== key) continue\n for (const ref of refs) {\n const instance = ref.deref()\n if (!instance) {\n refs.delete(ref) // collected since the last update\n continue\n }\n if (instance.hotReplace(parts)) rerendered++\n }\n if (!refs.size) hotRegistry.delete(name)\n }\n return rerendered\n}\n\n// starts tracking instances, so hotUpdate can find them. jq79/dev's client\n// calls this through the global handshake at the foot of this file; it is\n// exported so a bundled app - or a test - can opt in directly\nexport const enableHotReload = (): void => {\n hotRegistry ??= new Map()\n ;(globalThis as any)[HOT_RUNTIME] = { update: hotUpdate }\n}\n\ntype EmitListener = (event: CustomEvent, payload: any) => void\n\n// a parsed single-file component. Typical lifecycle:\n//\n// const jq79 = new Component79(src) // or await Component79.fetch(url)\n// jq79.on(\"submit\", (e, payload) => {}) // hear this instance's $emit events\n// jq79.mount(\"#app\", { user }) // render (reactive DOM, scripts, styles) + attach\n// ... // (mountShadow mounts into a shadow root)\n// jq79.detach() // detach, keeping state - mount() re-attaches\n// .destroy() // dispose effects and remove styles\nexport class Component79 {\n template: TemplateNode[]\n scripts: TagBlock[]\n styles: TagBlock[]\n // pre-resolved modules for setup-script `import(...)` calls (see\n // ComponentParts.modules); checked before falling back to fetch/import\n modules?: Record<string, any>\n // the component's origin, used to name its scripts in devtools\n filename?: string\n\n data: ReactiveDeepData<Record<string, any>> | null = null\n\n private fx: EffectScope | null = null\n // holds the rendered nodes while detached; anchors keep this fragment as\n // their parentNode, so effects keep the (detached) DOM up to date and a\n // later mount() shows current state\n private content: DocumentFragment | null = null\n // markers bracketing the component's output so detach() can collect nodes\n // that :if/:each inserted next to the anchors after mounting\n private startMarker: Comment | null = null\n private endMarker: Comment | null = null\n // shadow rendering keeps per-instance <style> elements; head rendering goes\n // through the shared refcounted styleRegistry instead\n private styleEls: HTMLStyleElement[] = []\n private ownsSharedStyles = false\n private useShadow = false\n private mountRoot: Element | ShadowRoot | DocumentFragment | null = null\n // settles the $mounted() promise handed to this render generation's scripts\n private resolveMounted: (() => void) | null = null\n // instance-level listeners for $emit events, registered with on(). Kept\n // outside the render generation so they survive re-render and destroy()\n private emitListeners = new Map<string, Set<EmitListener>>()\n\n constructor(src: string | ComponentParts, options: { modules?: Record<string, any>; filename?: string } = {}) {\n const parts = typeof src === \"string\" ? parseComponentString(src) : src\n this.template = parts.template\n this.scripts = parts.scripts\n this.styles = parts.styles\n this.modules = options.modules ?? (typeof src === \"string\" ? undefined : src.modules)\n this.filename = options.filename ?? (typeof src === \"string\" ? undefined : src.filename)\n hotRegister(this) // a no-op unless the page enabled hot reload\n }\n\n // swaps this component's parsed parts for `src`'s and, if it is on the page,\n // re-renders it where it stands - seeded with a snapshot of its data, so\n // props and store values survive (the setup script runs again, so whatever it\n // initializes is reset). Returns whether it re-rendered: an instance that was\n // never rendered is a *definition*, and patching its parts is all there is to\n // do - the clones :component made from it are instances in their own right,\n // registered under the same filename, and re-render themselves.\n //\n // Dev-only, and not part of the public API: jq79/dev and the Vite plugin call\n // it when a file changes. It re-attaches against the markers rather than\n // mountRoot on purpose - a nested clone is mounted into a fragment that is\n // then emptied into the page, so its mountRoot is a stale, detached fragment\n // while its markers sit where its DOM actually is\n hotReplace(src: string | ComponentParts): boolean {\n const parts = typeof src === \"string\" ? parseComponentString(src) : src\n const marker = this.startMarker\n const rendered = !!(marker && this.content)\n\n // where its output sits now, if it is on the page. A rendered-but-detached\n // instance (markers in the holding fragment) re-renders detached, and a\n // later mount() attaches the new output - like any update it missed away\n const live = rendered && marker!.isConnected\n const parent = live ? (marker!.parentNode as Element | ShadowRoot | DocumentFragment) : null\n const before = live ? this.endMarker!.nextSibling : null\n const data = { ...this.data }\n const shadow = this.useShadow\n\n // destroy() releases the styles it acquired, so it has to run while\n // this.styles is still the *old* set - swapping the parts first would leak\n // the old stylesheet into the head and release a new one nobody holds\n if (rendered) this.destroy()\n\n this.template = parts.template\n this.scripts = parts.scripts\n this.styles = parts.styles\n if (!rendered) return false // a definition: its clones re-render themselves\n\n this.renderWith(data, shadow)\n if (!parent) return false\n\n // shadow styles live inline, right before the DOM they style (attach()\n // appends them ahead of the content), so they go back the same way\n if (shadow) this.styleEls.forEach(el => parent.insertBefore(el, before))\n parent.insertBefore(this.content!, before)\n this.mountRoot = parent\n this.resolveMounted?.()\n return true\n }\n\n static async fetch(url: string): Promise<Component79> {\n const response = await fetch(url)\n if (!response.ok) throw new Error(`failed to fetch component from ${url}: ${response.status}`)\n // the URL names the component's scripts in devtools, and is where the\n // browser will look for the source when a breakpoint lands in one\n return new Component79(await response.text(), { filename: url })\n }\n\n // subscribes to this instance's $emit events, on top of the DOM CustomEvent\n // dispatch - so it hears emits even while the component is detached (where\n // the event has no ancestors to bubble to). Chainable; can be called before\n // render()\n on(eventName: string, listener: EmitListener): this {\n if (!this.emitListeners.has(eventName)) this.emitListeners.set(eventName, new Set())\n this.emitListeners.get(eventName)!.add(listener)\n return this\n }\n\n off(eventName: string, listener: EmitListener): this {\n this.emitListeners.get(eventName)?.delete(listener)\n return this\n }\n\n render(data: Record<string, any> = {}): this {\n return this.renderWith(data, false)\n }\n\n // like render(), but styles are injected into a shadow root attached to the\n // mount target instead of document.head, so they don't leak globally\n renderShadow(data: Record<string, any> = {}): this {\n return this.renderWith(data, true)\n }\n\n private renderWith(data: Record<string, any>, shadow: boolean): this {\n this.destroy()\n\n const store = $reactive({ ...data })\n const fx = createEffectScope(store)\n this.data = store\n this.fx = fx\n this.useShadow = shadow\n\n this.startMarker = document.createComment(\"jq79\")\n this.endMarker = document.createComment(\"/jq79\")\n\n // $emit dispatches a bubbling CustomEvent from this instance's start\n // marker, so once mounted it travels up the real DOM and parents can\n // listen on any ancestor (or with @event-name on a wrapping element).\n // Captures the marker rather than `this` so a later re-render's scripts\n // can't dispatch from the wrong generation - the same guard keeps stale\n // generations from reaching the instance's on() listeners\n const marker = this.startMarker\n const $emit = (eventName: string, payload?: any): boolean => {\n const event = new CustomEvent(eventName, { detail: payload, bubbles: true, composed: true })\n const result = marker.dispatchEvent(event)\n if (marker === this.startMarker) {\n this.emitListeners.get(eventName)?.forEach(listener => listener(event, payload))\n }\n return result\n }\n\n // `await $mounted()` suspends a setup script until mount() attaches the\n // component, so code below it can querySelector its own DOM. Resumption\n // is a microtask, so in the usual synchronous render().mount() flow the\n // whole tree (nested components included) is in the document before the\n // script continues. If this instance is never mounted, the promise stays\n // pending and the script's tail never runs\n let resolveMounted!: () => void\n const mounted = new Promise<void>(resolve => { resolveMounted = resolve })\n this.resolveMounted = resolveMounted\n const $mounted = () => mounted\n\n // $self / $$self mirror $ / $$ but only search this instance's own\n // output: the sibling nodes between its markers. They work detached too\n // (the holding fragment keeps markers and rendered nodes as siblings),\n // though the template renders after the scripts run, so they only find\n // something from post-await code or callbacks\n const endMarker = this.endMarker\n const $$self = (selector: string): Element[] => {\n const found: Element[] = []\n for (let node: Node | null = marker.nextSibling; node && node !== endMarker; node = node.nextSibling) {\n if (node instanceof Element) {\n if (node.matches(selector)) found.push(node)\n found.push(...Array.from(node.querySelectorAll(selector)))\n }\n }\n return found\n }\n const $self = (selector: string): Element | null => $$self(selector)[0] ?? null\n\n // import() calls whose specifier was pre-resolved by a bundler (the\n // modules map) get the bundled module; everything else falls back to the\n // runtime importResource (fetch for .html, native import otherwise)\n const modules = this.modules\n const $import = (url: string): Promise<any> =>\n modules && url in modules ? Promise.resolve(modules[url]) : importResource(url)\n\n // scripts run before the template renders so `$:` values are initialized;\n // a `:mounted` script defers entirely until mount() instead. A top-level\n // `export default` switches the script to factory mode (plain lexical JS)\n // a `:mounted` script is deferred by prepending the await on the code's own\n // first line, so deferring doesn't shift the lines devtools reports for it\n const defer = (code: string) => `await $mounted();${code}`\n\n this.scripts.forEach((script, index) => {\n const instanceHelpers = { $emit, $mounted, $self, $$self }\n const at: ScriptLocation = { filename: this.filename, index }\n const factoryCode = transformFactoryScript(script.content)\n if (factoryCode !== null) {\n declareProps(store, parseFactoryProps(script.content))\n const body = \":mounted\" in script.attrs ? defer(factoryCode) : factoryCode\n runFactoryScript(body, store, fx.effect, instanceHelpers, $import, at)\n return\n }\n const { vars, code } = transformSetupScript(script.content)\n declareProps(store, parsePropsPattern(script.attrs[\":setup\"]))\n // pre-declare script vars on the store so `with` resolves assignments\n // to them (and reads of them) through the reactive proxy\n vars.forEach(name => { if (!(name in store)) (store as any)[name] = undefined })\n const body = \":mounted\" in script.attrs ? defer(code) : code\n runSetupScript(body, store, fx.effect, instanceHelpers, $import, at)\n })\n\n const content = document.createDocumentFragment()\n content.append(this.startMarker, renderNodes(this.template, store, fx, shadow), this.endMarker)\n this.content = content\n\n if (shadow) {\n this.styleEls = this.styles.map(style => {\n const el = document.createElement(\"style\")\n el.textContent = style.content // the source: a shadow root scopes it already\n return el\n })\n } else {\n this.styles.forEach(style => acquireStyle(headStyle(style)))\n this.ownsSharedStyles = true\n }\n\n return this\n }\n\n // renders (when needed) and attaches in one call: the component is rendered\n // on the first mount, and re-rendered fresh whenever `data` is passed.\n // mount(el) on an already-rendered component just re-attaches, keeping its\n // state - the detach()/mount() round trip. Rendering here keeps whichever\n // style mode was last used (document.head unless renderShadow/mountShadow\n // chose a shadow root)\n mount(parent: Element | ShadowRoot | DocumentFragment | string, data?: Record<string, any>): this {\n const target = typeof parent === \"string\" ? $(parent) : parent\n if (!target) throw new Error(`mount target not found: ${parent}`)\n if (!this.content || data !== undefined) this.renderWith(data ?? {}, this.useShadow)\n return this.attach(target)\n }\n\n // like mount(), but renders with styles scoped to a shadow root on the\n // target instead of document.head\n mountShadow(parent: Element | ShadowRoot | DocumentFragment | string, data?: Record<string, any>): this {\n const target = typeof parent === \"string\" ? $(parent) : parent\n if (!target) throw new Error(`mount target not found: ${parent}`)\n if (!this.content || data !== undefined || !this.useShadow) this.renderWith(data ?? {}, true)\n return this.attach(target)\n }\n\n private attach(target: Element | ShadowRoot | DocumentFragment): this {\n if (this.mountRoot) this.detach()\n\n const root = this.useShadow && target instanceof Element\n ? target.shadowRoot ?? target.attachShadow({ mode: \"open\" })\n : target\n if (this.useShadow) this.styleEls.forEach(el => root.appendChild(el))\n root.appendChild(this.content!)\n this.mountRoot = root\n this.resolveMounted?.()\n return this\n }\n\n // detaches from the DOM while keeping all state; a later mount() re-attaches\n // with any updates that happened while detached already applied\n detach(): this {\n if (!this.mountRoot || !this.content || !this.startMarker || !this.endMarker) return this\n\n // move everything between the markers (inclusive) back into the holding\n // fragment - including nodes :if/:each inserted after mounting\n let node: Node | null = this.startMarker\n while (node) {\n const nextNode: Node | null = node.nextSibling\n this.content.appendChild(node)\n if (node === this.endMarker) break\n node = nextNode\n }\n\n this.mountRoot = null\n return this\n }\n\n destroy(): this {\n this.detach()\n this.fx?.dispose()\n this.fx = null\n // a store this component was handed (a shared `$reactive`) outlives it, and\n // holds a listener per store that nested it - drop this instance's\n this.data?.$dispose()\n this.styleEls.forEach(el => el.parentNode?.removeChild(el))\n this.styleEls = []\n if (this.ownsSharedStyles) {\n this.styles.forEach(style => releaseStyle(headStyle(style)))\n this.ownsSharedStyles = false\n }\n this.content = null\n this.startMarker = null\n this.endMarker = null\n this.data = null\n this.resolveMounted = null\n return this\n }\n}\n\nexport const parseComponent = (component: string): Component79 => new Component79(component)\n\n// the hot-reload handshake. jq79/dev serves a classic script that sets the flag\n// below; classic scripts run before deferred module ones, so the flag is always\n// set before this module evaluates. The page's copy of the runtime can come from\n// anywhere - a CDN, an import map, dist/ - and the dev client has no way to\n// import *that* copy, so the runtime hands itself to the client instead\nif (typeof globalThis !== \"undefined\" && (globalThis as any)[HOT_FLAG]) enableHotReload()\n\n","// DOM helpers: tiny query/create utilities, also injected into component\n// scripts as $, $$ and $create\n\n// $(selector) queries the document; $(el, selector) queries within el. The\n// selector is required in the element form - an empty one is a SyntaxError\nexport function $(selector: string): Element | null\nexport function $(el: Element, selector: string): Element | null\nexport function $(selectorOrEl: string | Element, selector?: string): Element | null {\n return typeof selectorOrEl === \"string\"\n ? document.querySelector(selectorOrEl)\n : selectorOrEl.querySelector(selector!)\n}\n\nexport function $$(selector: string): Element[]\nexport function $$(el: Element, selector: string): Element[]\nexport function $$(selectorOrEl: string | Element, selector?: string): Element[] {\n return Array.from(\n typeof selectorOrEl === \"string\"\n ? document.querySelectorAll(selectorOrEl)\n : selectorOrEl.querySelectorAll(selector!)\n )\n}\n\n// $create(tag, attrs): attrs are set as attributes, except className, which\n// may be a string or an array of class names.\nexport const $create = (tag: string, attrs: Record<string, any> = {}): HTMLElement => {\n const el = document.createElement(tag);\n for (const [name, value] of Object.entries(attrs)) {\n if (name === 'className') {\n el.className = Array.isArray(value) ? value.join(' ') : value;\n } else if (name === 'textContent') {\n el.textContent = value;\n } else if (name === 'children') {\n for (const child of value) {\n el.appendChild(child);\n }\n } else {\n el.setAttribute(name, value);\n }\n }\n return el;\n};\n\nconst ALLOWED_TAGS = new Set([\n 'a', 'b', 'i', 'em', 'strong', 'p', 'br', 'ul', 'ol', 'li',\n 'blockquote', 'code', 'pre', 'span', 'div', 'h1', 'h2', 'h3',\n 'h4', 'h5', 'h6', 'img'\n]);\n\nconst ALLOWED_ATTR: Record<string, Set<string>> = {\n a: new Set(['href', 'title']),\n img: new Set(['src', 'alt']),\n '*': new Set(['class']), // atributos permitidos en cualquier tag\n};\n\nconst SAFE_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:']);\n\nexport function isSafeUrl(value: string): boolean {\n try {\n // resolver relativo a algo neutro para poder leer el protocolo\n const url = new URL(value, 'https://example.com');\n return SAFE_URL_PROTOCOLS.has(url.protocol);\n } catch {\n return false;\n }\n}\n\n// copia los hijos de `source` en `target`, saneando los elementos y clonando\n// el texto; cualquier otra cosa (comentarios, etc.) se descarta\nfunction appendSanitizedChildren(source: ParentNode, target: HTMLElement): void {\n for (const child of Array.from(source.childNodes)) {\n if (child.nodeType === Node.ELEMENT_NODE) {\n const sanitizedChild = sanitizeNode(child as HTMLElement);\n if (sanitizedChild) target.appendChild(sanitizedChild);\n } else if (child.nodeType === Node.TEXT_NODE) {\n target.appendChild(child.cloneNode());\n }\n }\n}\n\n// sanea un elemento (los llamadores solo pasan nodos ELEMENT_NODE)\nfunction sanitizeNode(node: HTMLElement): HTMLElement | null {\n const tag = node.tagName.toLowerCase();\n if (!ALLOWED_TAGS.has(tag)) return null; // tag no permitido → se descarta el nodo entero\n\n const clean = document.createElement(tag);\n\n for (const attr of Array.from(node.attributes)) {\n const name = attr.name.toLowerCase();\n const allowedForTag = ALLOWED_ATTR[tag]?.has(name);\n const allowedGlobal = ALLOWED_ATTR['*']?.has(name);\n if (!allowedForTag && !allowedGlobal) continue;\n\n if ((name === 'href' || name === 'src') && !isSafeUrl(attr.value)) continue;\n\n clean.setAttribute(name, attr.value);\n }\n\n // fuerza rel seguro en enlaces (target nunca se copia: no está permitido)\n if (tag === 'a') clean.setAttribute('rel', 'noopener noreferrer');\n\n appendSanitizedChildren(node, clean);\n\n return clean;\n}\n\nexport function sanitizeHTML(html: string): string {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n const container = document.createElement('div');\n\n appendSanitizedChildren(doc.body, container);\n\n return container.innerHTML;\n}","// the reactive store ($reactive): proxy-based deep reactivity with\n// dot-path dependency tracking, plus the effect-scope helper the renderer\n// uses to tear down a subtree's bindings in one call\n\ntype ChangeListener = (value: any, dotKey: string) => void\ntype AnyChangeListener = (dotKey: string, value: any) => void\ntype ListenerOptions = { immediate?: boolean }\ntype Unsubscribe = () => void\n\nexport type ReactiveDeepData<T> = T & {\n $on: (dotKey: string, listener: ChangeListener, options?: ListenerOptions) => Unsubscribe\n $onAny: (listener: AnyChangeListener, options?: ListenerOptions) => Unsubscribe\n // runs `run` immediately, recording every dotKey it reads off this store, then\n // re-runs it whenever a changed dotKey overlaps one of those - see pathsOverlap\n $effect: (run: () => void) => Unsubscribe\n // drops this store's subscriptions to the stores nested inside it (see\n // bridge). A store that outlives the one holding it - the shared-state case -\n // would otherwise keep the dead holder's listeners on its own list forever\n $dispose: () => void\n}\n\nconst getByPath = (obj: Record<string, any>, dotKey: string): any =>\n dotKey.split(\".\").reduce((acc, key) => (acc == null ? undefined : acc[key]), obj)\n\n// only plain objects and arrays get deep-wrapped by the reactive store;\n// class instances (Component79, Date, DOM nodes, ...) pass through untouched\n// so their identity, prototypes and internals stay intact\nconst isPlainData = (value: object): boolean => {\n if (Array.isArray(value)) return true\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nconst walkLeaves = (obj: Record<string, any>, path: string, visit: (dotKey: string, value: any) => void) => {\n Object.entries(obj).forEach(([key, value]) => {\n const dotKey = path ? `${path}.${key}` : key\n if (value && typeof value === \"object\" && isPlainData(value)) walkLeaves(value, dotKey, visit)\n else visit(dotKey, value)\n })\n}\n\n// true when `a` and `b` sit on the same ancestor/descendant line, e.g.\n// \"user\" & \"user.address.city\" (a change to either affects the other) - false\n// for siblings like \"user.name\" & \"user.age\"\nconst pathsOverlap = (a: string, b: string): boolean =>\n a === b || a.startsWith(`${b}.`) || b.startsWith(`${a}.`)\n\n// reads the raw object behind a store proxy. Module-level (not per-store) so a\n// value that is already reactive - in this store or in another one - can be\n// unwrapped before being wrapped again. Without it, handing the same object to\n// two stores has each one wrapping the other's proxies, and since a wrap walks\n// what it wraps, the nesting compounds until the process stops responding\nconst RAW = Symbol(\"jq79.raw\")\n\nconst toRaw = <T>(value: T): T => {\n let raw: any = value\n while (raw !== null && typeof raw === \"object\" && raw[RAW]) raw = raw[RAW]\n return raw\n}\n\n// marks a store's *root* proxy. A store put inside another store (a setup\n// script's `const local = $reactive(...)`) has to pass through whole: it owns\n// its listeners and its $on/$effect, so unwrapping it would strip away the very\n// thing it is. Nested proxies carry no such marker and are unwrapped freely\nconst STORE = Symbol(\"jq79.store\")\n\nconst isStore = (value: any): boolean =>\n value !== null && typeof value === \"object\" && value[STORE] === true\n\n// active $effect() runs, innermost last - a module-level stack (rather than\n// one per store) so nested effects across stores still nest correctly; reads\n// during a proxy's `get` trap are attributed to whichever run is on top\nconst trackerStack: Set<string>[] = []\n\n// runs fn with dependency tracking suspended - reads inside it are attributed\n// to a throwaway set instead of the currently running effect\nexport const untracked = <T>(fn: () => T): T => {\n trackerStack.push(new Set())\n try {\n return fn()\n } finally {\n trackerStack.pop()\n }\n}\n\ntype Effect = { deps: Set<string>; run: () => void }\n\nexport const $reactive = <T extends Record<string, any>>(data: T): ReactiveDeepData<T> => {\n const exactListeners = new Map<string, Set<ChangeListener>>()\n const anyListeners = new Set<AnyChangeListener>()\n const effects = new Set<Effect>()\n\n // one proxy per raw object, for this store alone. Keyed by the *raw object*\n // rather than by its path, so identity travels with the object: :each diffs\n // its items by reference (Object.is), and a reordered list has to hand back\n // the same proxy for the same item or every row would re-render. The flip\n // side is that an object's path is fixed when it is first wrapped, so after a\n // reorder its notifications carry the old index - effects that read the list\n // itself still wake up (pathsOverlap), which is what makes it a non-issue in\n // practice\n const proxies = new WeakMap<object, Record<string, any>>()\n\n // $on/$onAny/$effect are served from the root proxy's `get` instead of being\n // defined on the object: a store must leave nothing behind on the data it was\n // handed, and two stores over one object would otherwise clobber each other's\n // handles. Null-prototype, so `key in storeApi` can't match Object.prototype\n const storeApi: Record<string, any> = Object.create(null)\n\n const notify = (dotKey: string, value: any, isNewKey = false) => {\n exactListeners.get(dotKey)?.forEach(listener => listener(value, dotKey))\n anyListeners.forEach(listener => listener(dotKey, value))\n effects.forEach(effect => {\n // a newly-created key re-runs every effect: an effect that read the\n // name while it didn't exist couldn't track it (`with` skipped the\n // store entirely), so dep matching would never wake it up\n if (isNewKey || Array.from(effect.deps).some(dep => pathsOverlap(dep, dotKey))) effect.run()\n })\n }\n\n const isWrappable = (value: any): value is Record<string, any> =>\n value !== null && typeof value === \"object\" && isPlainData(value)\n\n // a store nested inside this one keeps its own listeners and its own effects,\n // and this store's effects are not among them - so a write through the inner\n // store notifies nobody out here, and a component rendering `{{ cart.items }}`\n // off a `$reactive` it was handed would never update. The holder subscribes\n // instead, and re-notifies the inner store's changes under the path it sits at\n // (\"items.0\" -> \"cart.items.0\"). An effect that read through `cart` recorded\n // exactly that path's ancestor as a dependency, so pathsOverlap wakes it.\n // Chains compose: re-notifying runs this store's own $onAny listeners, which\n // is how a store two levels down still reaches the top\n const bridges = new Map<string, { store: any; unsubscribe: Unsubscribe }>()\n\n const bridge = (store: any, path: string) => {\n const current = bridges.get(path)\n if (current?.store === store) return\n current?.unsubscribe()\n bridges.set(path, {\n store,\n unsubscribe: store.$onAny((dotKey: string, value: any) => notify(`${path}.${dotKey}`, value)),\n })\n }\n\n // the key no longer holds the store it held: stop listening to it\n const unbridge = (path: string) => {\n bridges.get(path)?.unsubscribe()\n bridges.delete(path)\n }\n\n // the reactive view of `raw`, created on demand. Callers must hand it a raw\n // object (see toRaw at both call sites): wrapping a proxy is what compounds\n const wrap = (raw: Record<string, any>, path: string): Record<string, any> => {\n const cached = proxies.get(raw)\n if (cached) return cached\n\n const proxy: Record<string, any> = new Proxy(raw, {\n get(target, key, receiver) {\n if (key === RAW) return target\n if (key === STORE) return path === \"\"\n if (typeof key !== \"string\") return Reflect.get(target, key, receiver)\n if (path === \"\" && key in storeApi) return storeApi[key]\n\n const dotKey = path ? `${path}.${key}` : key\n trackerStack[trackerStack.length - 1]?.add(dotKey)\n\n // nested objects are wrapped here rather than up front, so the object\n // handed to $reactive is never rewritten\n const value = Reflect.get(target, key, receiver)\n if (isStore(value)) {\n bridge(value, dotKey)\n return value\n }\n\n const raw = toRaw(value)\n return isWrappable(raw) ? wrap(raw, dotKey) : raw\n },\n set(target, key: string, value, receiver) {\n // an assignment delegated up the prototype chain from a derived scope\n // (Object.create(store) child, or a wrapping proxy): if the key isn't\n // a real property of this store, honor the receiver so the new binding\n // lands on the derived scope - a scope-local variable, not a store\n // mutation, so no notify. If the key IS a store property, fall through\n // and mutate the store itself regardless of receiver, so assignments\n // like @click=\"count = count + 1\" work from any nested scope\n if (receiver !== proxy && !Object.prototype.hasOwnProperty.call(target, key)) {\n return Reflect.set(target, key, value, receiver)\n }\n\n const dotKey = path ? `${path}.${key}` : key\n // store the raw value, never a proxy - including one of our own, so\n // that `list = [list[1], list[0]]` doesn't write proxies back into the\n // data. Reads re-wrap it, from the cache, as the very same proxy. A\n // whole store assigned in is the exception: it stays as it is\n const stored = isStore(value) ? value : toRaw(value)\n const isNewKey = !Object.prototype.hasOwnProperty.call(target, key)\n target[key] = stored\n if (isStore(stored)) bridge(stored, dotKey)\n else unbridge(dotKey)\n const notified = isStore(stored) || !isWrappable(stored) ? stored : wrap(stored, dotKey)\n notify(dotKey, notified, isNewKey)\n return true\n }\n })\n\n proxies.set(raw, proxy)\n return proxy\n }\n\n const reactive = wrap(toRaw(data), \"\") as ReactiveDeepData<T>\n\n // a store handed in with the data (a prop, or render data) is bridged here\n // rather than on first read, so a listener registered before anything reads\n // the key still hears it. Only the top level is scanned: that's where a prop\n // lands, and descending would mean walking whatever else was handed in - a\n // highlighter, an API client - to its leaves. A store sitting deeper is\n // bridged when the read that reaches it wraps its parent\n Object.entries(toRaw(data)).forEach(([key, value]) => {\n if (isStore(value)) bridge(value, key)\n })\n\n const $on = (dotKey: string, listener: ChangeListener, { immediate = false }: ListenerOptions = {}): Unsubscribe => {\n if (!exactListeners.has(dotKey)) exactListeners.set(dotKey, new Set())\n exactListeners.get(dotKey)!.add(listener)\n if (immediate) listener(getByPath(reactive, dotKey), dotKey)\n return () => exactListeners.get(dotKey)?.delete(listener)\n }\n\n const $onAny = (listener: AnyChangeListener, { immediate = false }: ListenerOptions = {}): Unsubscribe => {\n anyListeners.add(listener)\n if (immediate) walkLeaves(reactive, \"\", (dotKey, value) => listener(dotKey, value))\n return () => anyListeners.delete(listener)\n }\n\n const $effect = (run: () => void): Unsubscribe => {\n const effect: Effect = {\n deps: new Set(),\n run: () => {\n const deps = new Set<string>()\n trackerStack.push(deps)\n try {\n run()\n } finally {\n trackerStack.pop()\n effect.deps = deps\n }\n },\n }\n effects.add(effect)\n effect.run()\n return () => { effects.delete(effect) }\n }\n\n const $dispose = () => {\n bridges.forEach(({ unsubscribe }) => unsubscribe())\n bridges.clear()\n }\n\n storeApi.$on = $on\n storeApi.$onAny = $onAny\n storeApi.$effect = $effect\n storeApi.$dispose = $dispose\n\n return reactive\n}\n// groups the disposers of every $effect created for one rendered subtree\n// (an :if branch, an :each item, ...) so the whole subtree's bindings can be\n// torn down in one call when that subtree is replaced/removed. `scope.$effect`\n// resolves through the prototype chain up to the root store no matter how\n// many nested :each scopes sit in between (see renderEach's itemScope)\nexport type EffectScope = {\n effect: (run: () => void) => void\n // registers an arbitrary cleanup (e.g. destroying a nested component) to\n // run when this subtree is torn down\n onDispose: (fn: Unsubscribe) => void\n dispose: () => void\n}\n\nexport const createEffectScope = (scope: Record<string, any>): EffectScope => {\n const disposers: Unsubscribe[] = []\n return {\n effect: run => { disposers.push(scope.$effect(run)) },\n onDispose: fn => { disposers.push(fn) },\n dispose: () => { disposers.splice(0).forEach(dispose => dispose()) },\n }\n}\n","// ---------------------------------------------------------------------------\n// :setup script transform\n//\n// setup scripts are written like Svelte components:\n//\n// let firstName = null\n// $: fullName = `${firstName} ${lastName}`\n// fetchUser().then(user => { firstName = user.firstName })\n//\n// and are executed inside `with ($scope)` against the component's reactive\n// store, so plain assignments (even from async callbacks) go through the\n// proxy's set trap and re-render whatever depends on them. To make that work\n// the source is lightly rewritten - no full JS parser, just a scanner that is\n// string/comment-aware and only touches code at brace/paren depth 0:\n// - `let/var/const x = ...` at the top level loses its keyword, becoming a\n// scope assignment (the name is pre-declared on the store so the `with`\n// lookup resolves it)\n// - `$: x = expr` becomes `$__effect(() => { x = expr })`, re-running when a\n// dependency read inside expr changes ($__effect is deliberately NOT a\n// property of the scope, so `with` falls through to the function parameter)\n// ---------------------------------------------------------------------------\n\ntype SetupTransform = { vars: string[]; code: string }\n\nconst DECLARATION_RE = /(?:let|var|const)\\s+([A-Za-z_$][\\w$]*)/y\nconst REACTIVE_LABEL_RE = /\\$:\\s*/y\nconst IMPORT_CALL_RE = /import(?=\\s*\\()/y\nconst REACTIVE_ASSIGN_RE = /\\$:\\s*([A-Za-z_$][\\w$]*)\\s*=(?!=)/y\n\nconst skipString = (src: string, start: number): number => {\n const quote = src[start]\n let i = start + 1\n while (i < src.length) {\n if (src[i] === \"\\\\\") { i += 2; continue }\n if (src[i] === quote) return i + 1\n i++\n }\n return src.length\n}\n\nconst skipLineComment = (src: string, start: number): number => {\n const end = src.indexOf(\"\\n\", start)\n return end === -1 ? src.length : end\n}\n\nconst skipBlockComment = (src: string, start: number): number => {\n const end = src.indexOf(\"*/\", start + 2)\n return end === -1 ? src.length : end + 2\n}\n\n// index of the next thing that isn't whitespace or a comment\nconst skipToToken = (src: string, start: number): number => {\n let i = start\n while (i < src.length) {\n if (/\\s/.test(src[i])) { i++; continue }\n if (src[i] === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (src[i] === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n break\n }\n return i\n}\n\n// tokens that can't *start* a statement, so a line beginning with one is\n// continuing the previous expression rather than opening a new statement -\n// the same call JS's automatic semicolon insertion makes. Unary-only forms\n// (!, ~, ++, --) are deliberately absent: those do start a statement, and JS\n// inserts the semicolon before them\nconst CONTINUATION_RE = /^(\\?\\.|\\?\\?|&&|\\|\\||\\*\\*|[.,+\\-*/%&|^<>=?:([])/\n\n// end of a statement starting at `start`: the first `;` or line break that\n// isn't inside a string/comment or unbalanced brackets. A line break only\n// ends the statement if the next line can't continue it, so leading-dot\n// method chains and multi-line operator chains stay in one piece:\n//\n// $: total = items\n// .filter(item => item.active) <- still the same statement\n// .length\nconst findStatementEnd = (src: string, start: number): number => {\n let depth = 0\n let i = start\n while (i < src.length) {\n const ch = src[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth--\n else if (depth <= 0 && ch === \";\") return i\n else if (depth <= 0 && ch === \"\\n\") {\n const next = skipToToken(src, i + 1)\n if (next >= src.length || !CONTINUATION_RE.test(src.slice(next, next + 2))) return i\n i = next\n continue\n }\n i++\n }\n return src.length\n}\n\nexport const transformSetupScript = (src: string): SetupTransform => {\n const vars: string[] = []\n let out = \"\"\n let i = 0\n let depth = 0\n let atStatementStart = true\n\n while (i < src.length) {\n const ch = src[i]\n const next = src[i + 1]\n\n if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n const end = skipString(src, i)\n out += src.slice(i, end)\n i = end\n atStatementStart = false\n continue\n }\n if (ch === \"/\" && (next === \"/\" || next === \"*\")) {\n const end = next === \"/\" ? skipLineComment(src, i) : skipBlockComment(src, i)\n out += src.slice(i, end)\n i = end\n continue\n }\n\n // `import(...)` is a keyword form, so it can't be intercepted through the\n // scope - rewrite the identifier to the injected $__import (which loads\n // .html URLs as components via Component79.fetch and delegates the rest to\n // native import). The `(` is left for the scanner so depth stays balanced\n if (ch === \"i\" && (i === 0 || !/[\\w$.]/.test(src[i - 1]))) {\n IMPORT_CALL_RE.lastIndex = i\n if (IMPORT_CALL_RE.test(src)) {\n out += \"$__import\"\n i += \"import\".length\n atStatementStart = false\n continue\n }\n }\n\n if (depth === 0 && atStatementStart) {\n DECLARATION_RE.lastIndex = i\n const decl = DECLARATION_RE.exec(src)\n if (decl) {\n vars.push(decl[1])\n out += decl[1]\n i += decl[0].length\n atStatementStart = false\n continue\n }\n\n REACTIVE_LABEL_RE.lastIndex = i\n const label = REACTIVE_LABEL_RE.exec(src)\n if (label) {\n REACTIVE_ASSIGN_RE.lastIndex = i\n const assign = REACTIVE_ASSIGN_RE.exec(src)\n if (assign) vars.push(assign[1])\n const start = i + label[0].length\n const end = findStatementEnd(src, start)\n out += `$__effect(() => { ${src.slice(start, end)} });`\n i = end\n continue\n }\n }\n\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth = Math.max(0, depth - 1)\n\n if (ch === \"\\n\" || ch === \";\" || ch === \"}\") atStatementStart = true\n else if (!/\\s/.test(ch)) atStatementStart = false\n\n out += ch\n i++\n }\n\n return { vars, code: out }\n}\n\n// ---------------------------------------------------------------------------\n// factory scripts - a <script> whose top level has `export default` runs as a\n// plain lexical module instead of a `with`-scoped setup script: no implicit\n// reactivity, no `$:` labels - standard JS that editors and type-checkers\n// understand. The default export is called with the instance context\n// ({ $data, $effect, $emit, $mounted, $self, $$self }) and a returned object\n// is merged into the reactive store for the template to use.\n// Detection is backwards-safe: `export default` is a SyntaxError inside a\n// setup script, so no previously-working component can change behavior.\n// The same scanner rewrites the module-only syntax into a Function body:\n// - `export default X` -> `$__exports.default = X`\n// - `import d from \"m\"` -> `const d = $__default(await $__import(\"m\"))`\n// (and the other static clause forms), so imports resolve through the same\n// $__import as setup scripts: bundler map first, then fetch/native import\n// ---------------------------------------------------------------------------\n\nconst EXPORT_DEFAULT_RE = /export\\s+default(?![\\w$])/y\n// clause (default/namespace/named, no quotes or parens) + specifier; the\n// no-clause alternative requires the specifier right away, so dynamic\n// `import(...)` and `import.meta` never match\nconst STATIC_IMPORT_RE = /import\\s*(?:([\\w$\\s,{}*]+?)\\s*from\\s*)?([\"'])([^\"'\\n]+)\\2/y\n\n// splits an import clause on top-level commas: `d, { a, b as c }` keeps the\n// braced group together\nconst splitImportClause = (clause: string): string[] => {\n const parts: string[] = []\n let depth = 0\n let start = 0\n for (let i = 0; i <= clause.length; i++) {\n const ch = clause[i]\n if (ch === \"{\") depth++\n else if (ch === \"}\") depth--\n else if (i === clause.length || (ch === \",\" && depth === 0)) {\n const part = clause.slice(start, i).trim()\n if (part) parts.push(part)\n start = i + 1\n }\n }\n return parts\n}\n\n// one static import statement -> const bindings from the awaited module\nconst staticImportToAwait = (clause: string | undefined, spec: string, n: number): string => {\n const source = `await $__import(${JSON.stringify(spec)})`\n if (clause === undefined) return source // side-effect import\n const parts = splitImportClause(clause)\n const bindings: string[] = []\n let ref = source\n if (parts.length > 1) {\n const tmp = `$__mod${n}`\n bindings.push(`${tmp} = ${source}`)\n ref = tmp\n }\n for (const part of parts) {\n if (part.startsWith(\"{\")) bindings.push(`${part.replace(/\\s+as\\s+/g, \": \")} = ${ref}`)\n else if (part.startsWith(\"*\")) bindings.push(`${part.replace(/^\\*\\s*as\\s+/, \"\")} = ${ref}`)\n else bindings.push(`${part} = $__default(${ref})`)\n }\n return `const ${bindings.join(\", \")}`\n}\n\n// ---------------------------------------------------------------------------\n// the component's prop signature\n//\n// A component declares the props it takes as a destructuring pattern, in the\n// place each script mode already puts its inputs: the `:setup` attribute's\n// value, or the factory's *first* parameter (the ctx moved to the second).\n// Position is fixed, so the signature is read straight from the source string -\n// no parser, no execution - and the runtime can seed the defaults on the store\n// before the first render, which is what makes them reach the template even in\n// factory mode (where JS would only apply them inside the function body).\n//\n// <script :setup=\"{ label = 'Total', step = 1 }\">\n// export default ({ label = \"Total\" }, { $data }) => {}\n//\n// An object pattern *is* the declaration; anything else (`_`, a plain\n// identifier, no attribute at all) declares nothing and stays permissive.\n// ---------------------------------------------------------------------------\n\nexport type PropDecl = { name: string; default?: string }\n\nconst IDENTIFIER_RE = /^[A-Za-z_$][\\w$]*$/\n\n// index of the first `ch` at bracket depth 0, skipping strings and comments\nconst indexOfTopLevel = (src: string, ch: string): number => {\n let depth = 0\n let i = 0\n while (i < src.length) {\n const c = src[i]\n if (c === \"'\" || c === '\"' || c === \"`\") { i = skipString(src, i); continue }\n if (c === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (c === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n if (\"([{\".includes(c)) depth++\n else if (\")]}\".includes(c)) depth--\n else if (depth === 0 && c === ch) return i\n i++\n }\n return -1\n}\n\nconst splitTopLevel = (src: string): string[] => {\n const parts: string[] = []\n let depth = 0\n let start = 0\n let i = 0\n while (i <= src.length) {\n const ch = src[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n if (ch !== undefined && \"([{\".includes(ch)) depth++\n else if (ch !== undefined && \")]}\".includes(ch)) depth--\n else if (i === src.length || (ch === \",\" && depth === 0)) {\n const part = src.slice(start, i).trim()\n if (part) parts.push(part)\n start = i + 1\n }\n i++\n }\n return parts\n}\n\n// the `=` that opens a default value: the first one at depth 0 that isn't part\n// of `==`/`===` or an arrow's `=>` (so `{ format = a => a }` keeps its default)\nconst defaultAssignIndex = (src: string): number => {\n let from = 0\n while (from < src.length) {\n const at = indexOfTopLevel(src.slice(from), \"=\")\n if (at === -1) return -1\n const i = from + at\n if (src[i + 1] !== \"=\" && src[i + 1] !== \">\" && src[i - 1] !== \"=\" && src[i - 1] !== \"!\") return i\n from = i + 1\n }\n return -1\n}\n\n// a destructuring pattern -> the props it declares. null means \"no signature\":\n// the pattern isn't an object one (`_`, `props`, nothing at all), so the\n// component declares nothing and keeps the permissive, undeclared behavior.\n// `{}` parses to [] - a closed signature that declares zero props\nexport const parsePropsPattern = (pattern: string | undefined): PropDecl[] | null => {\n const src = (pattern ?? \"\").trim()\n if (!src.startsWith(\"{\")) return null\n\n // to the `}` that closes the pattern, so a parameter's own default value\n // (`({ label } = {})`) is left out of it\n let depth = 0\n let close = 0\n while (close < src.length) {\n const ch = src[close]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { close = skipString(src, close); continue }\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch) && --depth === 0) break\n close++\n }\n if (close >= src.length) return null // unbalanced: not a pattern we can read\n\n const props: PropDecl[] = []\n for (const part of splitTopLevel(src.slice(1, close))) {\n if (part.startsWith(\"...\")) continue // a rest element names no prop\n const assign = defaultAssignIndex(part)\n const named = assign === -1 ? part : part.slice(0, assign)\n const fallback = assign === -1 ? undefined : part.slice(assign + 1).trim()\n // `{ user: { id } }` and `{ user: renamed }` both declare `user`: what the\n // store holds is the key, whatever the pattern binds it to\n const colon = indexOfTopLevel(named, \":\")\n const name = (colon === -1 ? named : named.slice(0, colon)).trim()\n if (!IDENTIFIER_RE.test(name)) continue\n props.push(fallback === undefined ? { name } : { name, default: fallback })\n }\n return props\n}\n\n// index just past a top-level `export default`, or -1\nconst findExportDefault = (src: string): number => {\n let i = 0\n let depth = 0\n let atStatementStart = true\n while (i < src.length) {\n const ch = src[i]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { i = skipString(src, i); atStatementStart = false; continue }\n if (ch === \"/\" && src[i + 1] === \"/\") { i = skipLineComment(src, i); continue }\n if (ch === \"/\" && src[i + 1] === \"*\") { i = skipBlockComment(src, i); continue }\n\n if (ch === \"e\" && depth === 0 && atStatementStart && (i === 0 || !/[\\w$.]/.test(src[i - 1]))) {\n EXPORT_DEFAULT_RE.lastIndex = i\n const found = EXPORT_DEFAULT_RE.exec(src)\n if (found) return i + found[0].length\n }\n\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth = Math.max(0, depth - 1)\n if (ch === \"\\n\" || ch === \";\" || ch === \"}\") atStatementStart = true\n else if (!/\\s/.test(ch)) atStatementStart = false\n i++\n }\n return -1\n}\n\nconst ASYNC_RE = /^async(?![\\w$])/\nconst FUNCTION_RE = /^function(?![\\w$])\\s*\\*?\\s*[A-Za-z_$][\\w$]*|^function(?![\\w$])\\s*\\*?/\n\n// source text of the exported function's first parameter, or null when there\n// is no parameter list to read (`export default Factory`, `export default\n// props => ...`, an exported object) - all of which declare nothing\nconst firstParameterSource = (src: string): string | null => {\n const start = findExportDefault(src)\n if (start === -1) return null\n\n let i = skipToToken(src, start)\n const rest = src.slice(i)\n if (ASYNC_RE.test(rest)) i = skipToToken(src, i + \"async\".length)\n const fn = FUNCTION_RE.exec(src.slice(i))\n if (fn) i = skipToToken(src, i + fn[0].length)\n if (src[i] !== \"(\") return null\n\n // the parameter list runs to the `)` that closes this `(`\n let depth = 0\n let end = i\n while (end < src.length) {\n const ch = src[end]\n if (ch === \"'\" || ch === '\"' || ch === \"`\") { end = skipString(src, end); continue }\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch) && --depth === 0) break\n end++\n }\n return splitTopLevel(src.slice(i + 1, end))[0] ?? \"\"\n}\n\n// the props declared by a factory script's first parameter. Throws the\n// migration error when it finds the pre-0.4 signature there - the ctx used to\n// be the first parameter, and the change is silent otherwise ($data would just\n// come back undefined). `$` is what tells them apart: what carries one comes\n// from the library, what doesn't comes from the parent, everywhere in jq79\nexport const parseFactoryProps = (src: string): PropDecl[] | null => {\n const first = firstParameterSource(src)\n if (first === null) return null\n const props = parsePropsPattern(first)\n const ctxName = props?.find(prop => prop.name.startsWith(\"$\"))?.name\n if (ctxName) {\n throw new Error(\n `jq79: the factory signature is (props, ctx), so \\`${ctxName}\\` can't be destructured from the first parameter. ` +\n `Write \\`export default (props, { ${ctxName} }) => …\\`, or \\`_\\` in place of props if the component takes none.`\n )\n }\n return props\n}\n\n// rewrites a factory script into a Function body, or returns null when the\n// script has no top-level `export default` (i.e. it's a regular setup script)\nexport const transformFactoryScript = (src: string): string | null => {\n let out = \"\"\n let i = 0\n let depth = 0\n let atStatementStart = true\n let isFactory = false\n let modCount = 0\n\n while (i < src.length) {\n const ch = src[i]\n const next = src[i + 1]\n const atWordBoundary = i === 0 || !/[\\w$.]/.test(src[i - 1])\n\n if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n const end = skipString(src, i)\n out += src.slice(i, end)\n i = end\n atStatementStart = false\n continue\n }\n if (ch === \"/\" && (next === \"/\" || next === \"*\")) {\n const end = next === \"/\" ? skipLineComment(src, i) : skipBlockComment(src, i)\n out += src.slice(i, end)\n i = end\n continue\n }\n\n if (ch === \"i\" && atWordBoundary) {\n // dynamic import() -> $__import, same rewrite as setup scripts\n IMPORT_CALL_RE.lastIndex = i\n if (IMPORT_CALL_RE.test(src)) {\n out += \"$__import\"\n i += \"import\".length\n atStatementStart = false\n continue\n }\n if (depth === 0 && atStatementStart) {\n STATIC_IMPORT_RE.lastIndex = i\n const staticImport = STATIC_IMPORT_RE.exec(src)\n if (staticImport) {\n out += staticImportToAwait(staticImport[1], staticImport[3], modCount++)\n i += staticImport[0].length\n atStatementStart = false\n continue\n }\n }\n }\n\n if (ch === \"e\" && atWordBoundary && depth === 0 && atStatementStart) {\n EXPORT_DEFAULT_RE.lastIndex = i\n const exportDefault = EXPORT_DEFAULT_RE.exec(src)\n if (exportDefault) {\n isFactory = true\n out += \"$__exports.default =\"\n i += exportDefault[0].length\n atStatementStart = false\n continue\n }\n }\n\n if (\"([{\".includes(ch)) depth++\n else if (\")]}\".includes(ch)) depth = Math.max(0, depth - 1)\n\n if (ch === \"\\n\" || ch === \";\" || ch === \"}\") atStatementStart = true\n else if (!/\\s/.test(ch)) atStatementStart = false\n\n out += ch\n i++\n }\n\n return isFactory ? out : null\n}\n\n"],"mappings":"+jBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,OAAAE,EAAA,OAAAC,EAAA,YAAAC,EAAA,cAAAC,EAAA,gBAAAC,EAAA,oBAAAC,GAAA,cAAAC,GAAA,mBAAAC,GAA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CAAC,KAAK,aAAe,CAAC,KAAK,UAAW,OAAO,KAIrF,IAAI7H,EAAoB,KAAK,YAC7B,KAAOA,GAAM,CACX,IAAMmN,EAAwBnN,EAAK,YAEnC,GADA,KAAK,QAAQ,YAAYA,CAAI,EACzBA,IAAS,KAAK,UAAW,MAC7BA,EAAOmN,CACT,CAEA,YAAK,UAAY,KACV,IACT,CAEA,SAAgB,CACd,YAAK,OAAO,EACZ,KAAK,IAAI,QAAQ,EACjB,KAAK,GAAK,KAGV,KAAK,MAAM,SAAS,EACpB,KAAK,SAAS,QAAQtN,GAAMA,EAAG,YAAY,YAAYA,CAAE,CAAC,EAC1D,KAAK,SAAW,CAAC,EACb,KAAK,mBACP,KAAK,OAAO,QAAQoI,GAASU,GAAaJ,GAAUN,CAAK,CAAC,CAAC,EAC3D,KAAK,iBAAmB,IAE1B,KAAK,QAAU,KACf,KAAK,YAAc,KACnB,KAAK,UAAY,KACjB,KAAK,KAAO,KACZ,KAAK,eAAiB,KACf,IACT,CACF,EAEamF,GAAkBhH,GAAmC,IAAI5D,EAAY4D,CAAS,EAOvF,OAAO,WAAe,KAAgB,WAAmBoE,EAAQ,GAAGU,GAAgB","names":["jq79_exports","__export","$","$$","$create","$reactive","Component79","enableHotReload","hotUpdate","parseComponent","renderComponent","$","selectorOrEl","selector","$$","$create","tag","attrs","el","name","value","child","ALLOWED_TAGS","ALLOWED_ATTR","SAFE_URL_PROTOCOLS","isSafeUrl","url","appendSanitizedChildren","source","target","sanitizedChild","sanitizeNode","node","clean","attr","allowedForTag","allowedGlobal","sanitizeHTML","html","doc","container","getByPath","obj","dotKey","acc","key","isPlainData","value","proto","walkLeaves","path","visit","pathsOverlap","a","b","RAW","toRaw","raw","STORE","isStore","trackerStack","untracked","fn","$reactive","data","exactListeners","anyListeners","effects","proxies","storeApi","notify","isNewKey","listener","effect","dep","isWrappable","bridges","bridge","store","current","unbridge","wrap","cached","proxy","target","receiver","stored","notified","reactive","$on","immediate","$onAny","$effect","run","deps","$dispose","unsubscribe","createEffectScope","scope","disposers","dispose","DECLARATION_RE","REACTIVE_LABEL_RE","IMPORT_CALL_RE","REACTIVE_ASSIGN_RE","skipString","src","start","quote","i","skipLineComment","end","skipBlockComment","skipToToken","CONTINUATION_RE","findStatementEnd","depth","ch","next","transformSetupScript","vars","out","atStatementStart","decl","label","assign","EXPORT_DEFAULT_RE","STATIC_IMPORT_RE","splitImportClause","clause","parts","part","staticImportToAwait","spec","source","bindings","ref","tmp","IDENTIFIER_RE","indexOfTopLevel","c","splitTopLevel","defaultAssignIndex","from","at","parsePropsPattern","pattern","close","props","named","fallback","colon","name","findExportDefault","found","ASYNC_RE","FUNCTION_RE","firstParameterSource","rest","fn","parseFactoryProps","first","ctxName","prop","transformFactoryScript","isFactory","modCount","atWordBoundary","staticImport","exportDefault","elementAttrs","el","attr","elementToAST","node","text","compiled","compileExpr","expr","params","key","fn","evalExpr","scope","extras","interpolate","template","_","CONTROL_ATTRS","EACH_PATTERN","bindEvent","name","modifiers","mods","event","handler","kebabToCamel","c","findComponentKey","tag","normalized","obj","renderNestedComponent","fx","shadow","anchor","wrapper","props","value","SCOPE_ATTR","current","currentDef","childFx","nextDef","Component79","instance","seed","untracked","holder","syncFx","createEffectScope","createWithScope","source","target","renderNode","outerScope","withExpr","componentKey","upgraded","bindExpr","boundKeys","bound","textExpr","htmlExpr","sanitizeHTML","renderNodes","renderConditional","branches","activeBranch","branchFx","next","branch","defineScopeVar","renderEach","match","itemName","listExpr","keyExpr","_each","_key","itemAttrs","itemNode","entries","list","items","previous","entry","nextEntries","item","index","itemScope","existing","itemFx","nextKeys","prevNode","nodes","fragment","i","textNode","nextBranch","candidate","elseif","elseNode","renderComponent","component","data","VOID_ELEMENTS","SELF_CLOSING_RE","RAW_BLOCK_RE","expandSelfClosingTags","src","chunk","attrs","scopeHash","hash","stampScope","scopeSelector","selectorText","part","selector","pseudoAt","pseudoElement","scopeRules","rules","rule","scopeCss","css","sheet","parseComponentString","root","scripts","styles","block","style","isScoped","importResource","url","sourceUrlComment","filename","headStyle","styleRegistry","acquireStyle","content","releaseStyle","SETUP_HELPERS","$","$$","$create","$reactive","runSetupScript","code","effect","instanceHelpers","importer","at","helpers","scriptScope","error","declareProps","store","interopDefault","mod","runFactoryScript","$__exports","result","logError","invoked","invoke","factory","merge","bindings","returned","HOT_FLAG","HOT_RUNTIME","hotRegistry","hotRegister","refs","hotKey","hotUpdate","parts","rerendered","ref","enableHotReload","_Component79","options","__publicField","marker","rendered","live","parent","before","response","eventName","listener","$emit","payload","resolveMounted","mounted","resolve","$mounted","endMarker","$$self","found","$self","modules","$import","defer","script","factoryCode","transformFactoryScript","parseFactoryProps","body","vars","transformSetupScript","parsePropsPattern","nextNode","parseComponent"]}