brumate 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +2 -2
  2. package/check.d.ts +49 -0
  3. package/dist/{boot-C25Sa6vq.d.ts → boot-DLlRmD9z.d.ts} +8 -10
  4. package/dist/cli.js +275 -15
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client-BvDsC6Qr.js +3463 -0
  7. package/dist/client-BvDsC6Qr.js.map +1 -0
  8. package/dist/{client-D0CqSxoO.d.ts → client-DBwL2wKQ.d.ts} +390 -181
  9. package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
  10. package/dist/client-routes-BtGpYCef.js.map +1 -0
  11. package/dist/{cookies-BzllthiF.js → cookies-Cnbf4w-S.js} +14 -7
  12. package/dist/cookies-Cnbf4w-S.js.map +1 -0
  13. package/dist/{defer-BbD7JQhj.js → defer-CKWZLv2K.js} +4 -4
  14. package/dist/defer-CKWZLv2K.js.map +1 -0
  15. package/dist/{devtools-CQgD7NPB.js → devtools-4uTPwR_v.js} +56 -82
  16. package/dist/devtools-4uTPwR_v.js.map +1 -0
  17. package/dist/{devtools-panel-BVB-W5q4.js → devtools-panel-Be9pxYgv.js} +397 -333
  18. package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
  19. package/dist/{events-CSs7OwIC.js → events-LgLdp1R7.js} +34 -5
  20. package/dist/events-LgLdp1R7.js.map +1 -0
  21. package/dist/features-CHY5Ekku.js +30 -0
  22. package/dist/features-CHY5Ekku.js.map +1 -0
  23. package/dist/files-WW4RlajL.js +506 -0
  24. package/dist/files-WW4RlajL.js.map +1 -0
  25. package/dist/{forms-Cl21hkHt.d.ts → forms-j1xPAR14.d.ts} +3 -3
  26. package/dist/{forms-Bg-CwGqX.js → forms-nXK7-Lv_.js} +78 -44
  27. package/dist/forms-nXK7-Lv_.js.map +1 -0
  28. package/dist/highlight.js +31 -22
  29. package/dist/highlight.js.map +1 -1
  30. package/dist/{html-mNTKzaDD.js → html-BtKRyi7g.js} +86 -22
  31. package/dist/html-BtKRyi7g.js.map +1 -0
  32. package/dist/{html-Bq1rFxX_.d.ts → html-Bw9Qwu6F.d.ts} +20 -5
  33. package/dist/index.d.ts +96 -10
  34. package/dist/index.js +639 -104
  35. package/dist/index.js.map +1 -1
  36. package/dist/{inspect-BHpOw1LF.js → inspect-Y6y4uNZp.js} +3751 -676
  37. package/dist/inspect-Y6y4uNZp.js.map +1 -0
  38. package/dist/{loader-Dos_3NP0.js → loader-BjKGJzLN.js} +20 -14
  39. package/dist/loader-BjKGJzLN.js.map +1 -0
  40. package/dist/logo-DQ_OYhBi.js +10 -0
  41. package/dist/logo-DQ_OYhBi.js.map +1 -0
  42. package/dist/{navigate-O78d_zGN.js → navigate-CfOr-TRF.js} +94 -31
  43. package/dist/navigate-CfOr-TRF.js.map +1 -0
  44. package/dist/nesting-DA5vJw9X.js +265 -0
  45. package/dist/nesting-DA5vJw9X.js.map +1 -0
  46. package/dist/{produce-Doc91GkX.js → produce-B7X9ori9.js} +137 -9
  47. package/dist/produce-B7X9ori9.js.map +1 -0
  48. package/dist/{produce-D0V0ICkz.d.ts → produce-DIgHBVwL.d.ts} +39 -5
  49. package/dist/{rpc-ygMRPmN4.js → rpc-Q-XkLwFh.js} +11 -6
  50. package/dist/rpc-Q-XkLwFh.js.map +1 -0
  51. package/dist/runtime/batch.js +9 -7
  52. package/dist/runtime/batch.js.map +1 -1
  53. package/dist/runtime/client.d.ts +4 -4
  54. package/dist/runtime/client.js +4 -4
  55. package/dist/runtime/devtools.d.ts +11 -29
  56. package/dist/runtime/devtools.js +3 -1
  57. package/dist/runtime/env.js +14 -2
  58. package/dist/runtime/env.js.map +1 -1
  59. package/dist/runtime/events.d.ts +23 -1
  60. package/dist/runtime/events.js +1 -1
  61. package/dist/runtime/forms.d.ts +2 -2
  62. package/dist/runtime/forms.js +1 -1
  63. package/dist/runtime/hot.d.ts +1 -1
  64. package/dist/runtime/hot.js +5 -2
  65. package/dist/runtime/hot.js.map +1 -1
  66. package/dist/runtime/html.d.ts +2 -2
  67. package/dist/runtime/html.js +1 -1
  68. package/dist/runtime/loader.d.ts +2 -2
  69. package/dist/runtime/loader.js +2 -2
  70. package/dist/runtime/routes.js +4 -1
  71. package/dist/runtime/routes.js.map +1 -1
  72. package/dist/runtime/server.d.ts +5 -5
  73. package/dist/runtime/server.js +5 -5
  74. package/dist/runtime/signals.d.ts +38 -1
  75. package/dist/runtime/signals.js +33 -1
  76. package/dist/runtime/signals.js.map +1 -1
  77. package/dist/runtime/static-loader.d.ts +2 -2
  78. package/dist/runtime/static-loader.js +1 -1
  79. package/dist/runtime/testing.d.ts +18 -3
  80. package/dist/runtime/testing.js +150 -33
  81. package/dist/runtime/testing.js.map +1 -1
  82. package/dist/{server-DuFYRXrd.d.ts → server-BvPIg9pT.d.ts} +84 -22
  83. package/dist/{server-CxVDYE_V.js → server-DjyOVJtJ.js} +598 -164
  84. package/dist/server-DjyOVJtJ.js.map +1 -0
  85. package/dist/{static-loader-Drpr0AzI.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
  86. package/dist/{static-loader-nZssh66R.js → static-loader-BZR17hSw.js} +78 -99
  87. package/dist/static-loader-BZR17hSw.js.map +1 -0
  88. package/dist/{stream-DCYZO4IF.js → stream-BP5AVmg5.js} +102 -16
  89. package/dist/stream-BP5AVmg5.js.map +1 -0
  90. package/dist/vite.d.ts +13 -20
  91. package/dist/vite.js +1890 -548
  92. package/dist/vite.js.map +1 -1
  93. package/elements.d.ts +951 -0
  94. package/forms/forms.brm.ts +3 -3
  95. package/package.json +12 -3
  96. package/skills/brumate/SKILL.md +58 -0
  97. package/skills/brumate/references/errors.md +2078 -0
  98. package/skills/brumate/references/events.md +117 -0
  99. package/skills/brumate/references/signals.md +61 -0
  100. package/skills/brumate/references/state.md +235 -0
  101. package/skills/brumate/references/syntax.md +250 -0
  102. package/types.d.ts +4 -4
  103. package/dist/client-BD6XT-s5.js +0 -1968
  104. package/dist/client-BD6XT-s5.js.map +0 -1
  105. package/dist/client-routes-JTbGtukf.js.map +0 -1
  106. package/dist/cookies-BzllthiF.js.map +0 -1
  107. package/dist/defer-BbD7JQhj.js.map +0 -1
  108. package/dist/devtools-CQgD7NPB.js.map +0 -1
  109. package/dist/devtools-panel-BVB-W5q4.js.map +0 -1
  110. package/dist/events-CSs7OwIC.js.map +0 -1
  111. package/dist/files-BXSSrQgc.js +0 -205
  112. package/dist/files-BXSSrQgc.js.map +0 -1
  113. package/dist/forms-Bg-CwGqX.js.map +0 -1
  114. package/dist/html-mNTKzaDD.js.map +0 -1
  115. package/dist/inspect-BHpOw1LF.js.map +0 -1
  116. package/dist/loader-Dos_3NP0.js.map +0 -1
  117. package/dist/navigate-O78d_zGN.js.map +0 -1
  118. package/dist/produce-Doc91GkX.js.map +0 -1
  119. package/dist/rpc-ygMRPmN4.js.map +0 -1
  120. package/dist/server-CxVDYE_V.js.map +0 -1
  121. package/dist/static-loader-nZssh66R.js.map +0 -1
  122. package/dist/stream-DCYZO4IF.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"inspect-BHpOw1LF.js","names":["parse","WRAPPERS","CLIENT_TRIGGERS","isFunction","calleeName","analyze","VOID_ELEMENTS","parse","parse","analyze","isFunction","DEFERRED_SITES","parse","analyze"],"sources":["../src/macros.ts","../src/model.ts","../src/oxc.ts","../src/analyze.ts","../src/error.ts","../src/graph.ts","../src/scan.ts","../src/parser.ts","../src/project.ts","../src/a11y.ts","../src/refreshes.ts","../src/captures.ts","../src/env-check.ts","../src/sourcemap.ts","../src/node.ts","../src/modules.ts","../src/codegen/patch.ts","../src/shared-module.ts","../src/css.ts","../src/plan.ts","../src/codegen/scopes.ts","../src/codegen/markup.ts","../src/codegen/server.ts","../src/codegen/render.ts","../src/codegen/rewrite.ts","../src/codegen/client.ts","../src/compile.ts","../src/inspect.ts"],"sourcesContent":["// Compile-time functions, such as `$signal`, come from `brumate/signals`.\n// This pass reads those imports, gives renamed imports their own names\n// back, and finds calls that are not imported.\n\nimport type { Range, SFCFile } from './ast.ts';\nimport type { Diagnostic } from './model.ts';\nimport type { oxc } from './oxc.ts';\n\n/** The module of the compile-time functions. */\nexport const SIGNALS_MODULE = 'brumate/signals';\n\n/** The compile-time functions that `brumate/signals` exports. */\nexport const MACROS: Set<string> = new Set([\n '$props',\n '$signal',\n '$memo',\n '$optimistic',\n '$debounced',\n '$throttled',\n '$effect',\n '$client',\n '$untrack',\n '$produce',\n '$isPending',\n '$setContext',\n '$getContext',\n '$route',\n '$navigation',\n '$id',\n '$title',\n '$action',\n '$handler',\n '$bind',\n]);\n\n/** Compile-time functions that have a new name, by old name. */\nexport const RENAMED_MACROS: ReadonlyMap<string, string> = new Map([\n ['$provide', '$setContext'],\n ['$context', '$getContext'],\n]);\n\n/** True for `import … from 'brumate/signals'`, which the compiler removes. */\nexport function isMacroImport(statement: oxc.Node): boolean {\n return statement.type === 'ImportDeclaration' && statement.source.value === SIGNALS_MODULE;\n}\n\n/** Calls every AST node inside a value of the file, such as a script or an expression. */\nfunction walk(value: unknown, visit: (node: oxc.Node) => void, seen = new Set<object>()): void {\n if (typeof value !== 'object' || value === null || seen.has(value)) {\n return;\n }\n seen.add(value);\n if (Array.isArray(value)) {\n for (const item of value) {\n walk(item, visit, seen);\n }\n return;\n }\n if (typeof (value as { type?: unknown }).type === 'string') {\n visit(value as oxc.Node);\n }\n for (const [key, child] of Object.entries(value)) {\n // `source` is the text of the file, and ranges hold numbers only.\n if (key !== 'source') {\n walk(child, visit, seen);\n }\n }\n}\n\n/**\n * Reads the imports of `brumate/signals` in the file. A call of a renamed\n * import, such as `signal(0)` after `import { $signal as signal }`, gets the\n * name of the compile-time function, so the compiler sees `$signal(0)`.\n * Returns the compile-time functions that the file imports, and errors for\n * imports of compile-time functions that have a new name.\n */\nexport function resolveMacros(file: SFCFile): {\n imported: Set<string>;\n diagnostics: Diagnostic[];\n} {\n const aliases = new Map<string, string>();\n const diagnostics: Diagnostic[] = [];\n walk(file, (node) => {\n if (!isMacroImport(node)) {\n return;\n }\n for (const specifier of (node as oxc.ImportDeclaration).specifiers) {\n if (specifier.type === 'ImportSpecifier') {\n const imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n aliases.set(specifier.local.name, imported);\n const renamed = RENAMED_MACROS.get(imported);\n if (renamed) {\n diagnostics.push({\n severity: 'error',\n message: `${imported} was renamed to ${renamed}. Import ${renamed} from '${SIGNALS_MODULE}'`,\n range: { start: specifier.start, end: specifier.end },\n });\n }\n }\n }\n });\n if ([...aliases].some(([local, imported]) => local !== imported)) {\n walk(file, (node) => {\n if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {\n const imported = aliases.get(node.callee.name);\n if (imported) {\n node.callee.name = imported;\n }\n }\n });\n }\n return { imported: new Set(aliases.values()), diagnostics };\n}\n\n/** Reports calls of compile-time functions that the file does not import. */\nexport function checkMacroImports(file: SFCFile, imported: Set<string>): Diagnostic[] {\n const missing = new Map<string, Range>();\n walk(file, (node) => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n (MACROS.has(node.callee.name) || RENAMED_MACROS.has(node.callee.name)) &&\n !imported.has(node.callee.name) &&\n !missing.has(node.callee.name)\n ) {\n missing.set(node.callee.name, { start: node.start, end: node.end });\n }\n });\n return [...missing].map(([name, range]) => {\n const renamed = RENAMED_MACROS.get(name);\n return {\n severity: 'error',\n message: renamed\n ? `${name} was renamed to ${renamed}. Import ${renamed} from '${SIGNALS_MODULE}'`\n : `Import ${name} from '${SIGNALS_MODULE}'`,\n range,\n };\n });\n}\n","import type {\n Block,\n Body,\n ComponentNode,\n DynamicTagNode,\n ElementNode,\n EventAttribute,\n GlobalListenerNode,\n Range,\n RefAttribute,\n TemplateDecl,\n} from './ast.ts';\nimport type { oxc } from './oxc.ts';\n\nexport type ScopeKind = 'module' | 'component' | 'body' | 'template';\n\nexport interface Scope {\n id: number;\n kind: ScopeKind;\n parent?: Scope;\n children: Scope[];\n declarations: Map<string, Declaration>;\n /** The block that owns a body scope. */\n block?: Block;\n /** The body or template that a scope holds. */\n body?: Body;\n template?: TemplateDecl;\n}\n\nexport type DeclarationKind =\n | 'import'\n | 'module'\n | 'prop'\n | 'props-rest'\n | 'signal'\n | 'memo'\n | 'async-memo'\n | 'function'\n | 'server-function'\n | 'const'\n | 'let'\n | 'item'\n | 'index'\n | 'error'\n | 'reset'\n | 'template'\n | 'template-param'\n | 'context'\n | 'action';\n\nexport interface Declaration {\n id: number;\n name: string;\n kind: DeclarationKind;\n scope: Scope;\n range: Range;\n /** The site of a function, a server function or a memo. */\n site?: Site;\n /** The block that declares an item, an index, an error or a reset function. */\n block?: Block;\n reads: Reference[];\n writes: Reference[];\n /**\n * The prop that a destructured prop reads, such as `user` for\n * `const { user: { name } } = $props()`. Undefined for the props object.\n */\n propKey?: string;\n /** For `const result = $action(fn)`, the name of the server function. */\n action?: string;\n /** True for a server function that a server function refreshes with `refresh(fn)`. */\n refreshed?: boolean;\n /** For an import, the module and the name that it imports, such as `default`. */\n imported?: { source: string; name: string };\n /** For an import of a function of a `'use server'` file, the ID of the function. */\n serverImport?: string;\n /**\n * For `let shown = $optimistic(source)`, the value it follows. A write sets\n * a guess, until the source changes or the server calls of the page finish.\n */\n optimistic?: Declaration;\n /**\n * For `$debounced(value, ms)` and `$throttled(value, ms)`, how the browser\n * writes the memo: after the value stops changing for `ms`, or at most once every `ms`.\n */\n timing?: { kind: 'debounced' | 'throttled'; ms: number };\n /** For `let name = $signal(value)`, the value. */\n init?: oxc.Node;\n /**\n * True for a memo declared with `$optimistic`, before its source is known,\n * and for a prop that the component destructures with `let`.\n */\n writable?: boolean;\n /** True for a signal or a writable prop that `$bind` passes to a child, which needs a slot. */\n bound?: boolean;\n /** True for `const name = await $memo(value)`: the render waits for the memo where it is declared. */\n awaited?: boolean;\n /** For `const name = $id()`, the position of the call among the `$id` calls of its scope. */\n idIndex?: number;\n /** Elements whose `ref` targets this declaration. */\n refs: { attribute: RefAttribute; element: ElementNode; scope: Scope }[];\n}\n\nexport interface Reference {\n range: Range;\n declaration: Declaration;\n site: Site;\n /** False inside `$untrack(…)`. */\n tracked: boolean;\n /** True inside a function that the site contains, such as an inline arrow function. */\n inFunction: boolean;\n /**\n * For `await name` of a memo, the range of the whole `await` expression.\n * The render around the read waits for the memo, and the read compiles to\n * a plain read of its value.\n */\n await?: Range;\n}\n\nexport type SiteKind =\n | 'setup'\n | 'function'\n | 'server-function'\n | 'memo'\n | 'effect'\n | 'client'\n | 'insert'\n | 'attribute'\n | 'event'\n | 'prop'\n | 'spread'\n | 'tag'\n | 'block'\n | 'style'\n | 'provide'\n | 'title';\n\n/** A place where code runs: a function, a statement or a markup expression. */\nexport interface Site {\n id: number;\n kind: SiteKind;\n scope: Scope;\n range: Range;\n node: oxc.Node;\n /** A short name for printing, such as `function add` or `insert`. */\n label: string;\n reads: Reference[];\n writes: Reference[];\n /** Functions, server functions and templates that the site references. */\n calls: Set<Declaration>;\n /**\n * The calls outside `$untrack`. The values that their functions read are\n * values that the site depends on.\n */\n trackedCalls: Set<Declaration>;\n /** The declaration that a function or memo site belongs to. */\n declaration?: Declaration;\n /** The element, component or listener of an attribute or event site. */\n owner?: ElementNode | ComponentNode | DynamicTagNode | GlobalListenerNode;\n event?: EventAttribute;\n /**\n * For a handler wrapped by `brumate/events`, such as `prevent(move, 'Enter')`,\n * the modifiers that `b-on` holds, such as `prevent(Enter)`.\n */\n modifiers?: string[];\n /** The block whose header this site is. */\n block?: Block;\n /** The trigger of a `$client` site. */\n trigger?: 'visible' | 'idle' | 'load';\n /** True if the site awaits outside a nested function. */\n awaits: boolean;\n /** More code of the site, such as the context of `$setContext(context, value)`. */\n extra?: oxc.Node[];\n /**\n * For the function of `$handler(fn, ...args)`, the call, which the server\n * turns into a reference that a spread can pass on, with its arguments.\n */\n handler?: oxc.CallExpression;\n /** For the function of `$bind(name, fn)`, the call, which passes it as the setter of the binding. */\n setter?: oxc.CallExpression;\n}\n\nexport type Severity = 'error' | 'warning';\n\nexport interface Diagnostic {\n severity: Severity;\n message: string;\n range: Range;\n}\n\nexport interface SemanticModel {\n module: Scope;\n component: Scope;\n scopes: Scope[];\n declarations: Declaration[];\n sites: Site[];\n /** The `$bind(name)` calls, with the declaration of their name. */\n /** The `$bind` calls, with the declaration of their name and the site of their setter. */\n bindings: { call: oxc.CallExpression; declaration: Declaration; setter?: Site }[];\n diagnostics: Diagnostic[];\n}\n\n/** Returns true if `scope` is `ancestor` or inside it. */\nexport function isWithin(scope: Scope, ancestor: Scope): boolean {\n for (let current: Scope | undefined = scope; current; current = current.parent) {\n if (current === ancestor) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Returns the memos and props that a memo reads, directly or through other\n * memos. A memo is pending while any of them loads. A prop loads when a\n * parent passes it a promise.\n */\nexport function upstreamMemos(declaration: Declaration): Declaration[] {\n const result = new Set<Declaration>();\n const visit = (current: Declaration): void => {\n for (const read of current.site?.reads ?? []) {\n const next = read.declaration;\n if (next === declaration || result.has(next)) {\n continue;\n }\n if (next.kind === 'memo' || next.kind === 'async-memo') {\n result.add(next);\n visit(next);\n } else if (next.kind === 'prop') {\n result.add(next);\n }\n }\n };\n visit(declaration);\n return [...result];\n}\n\n/** Finds a declaration by name, from `scope` outwards. */\nexport function lookup(scope: Scope, name: string): Declaration | undefined {\n for (let current: Scope | undefined = scope; current; current = current.parent) {\n const declaration = current.declarations.get(name);\n if (declaration) {\n return declaration;\n }\n }\n return undefined;\n}\n","import { parseSync } from 'oxc-parser';\nimport type * as oxc from '@oxc-project/types';\nimport type { Fail } from './error.ts';\n\nexport type { oxc };\n\nconst SKIPPED_KEYS = new Set(['type', 'start', 'end', 'range', 'loc', 'parent']);\n\n/** Returns the child nodes of a node, with the key that holds each. */\nexport function* children(node: object): Generator<[key: string, child: oxc.Node]> {\n for (const [key, value] of Object.entries(node)) {\n if (SKIPPED_KEYS.has(key) || value === null || typeof value !== 'object') {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item !== null && typeof item === 'object' && typeof item.type === 'string') {\n yield [key, item];\n }\n }\n } else if (typeof value.type === 'string') {\n yield [key, value];\n }\n }\n}\n\n// Moves every node by `delta`, so offsets point into the whole file.\nfunction shift(node: object, delta: number, seen: WeakSet<object>): void {\n if (seen.has(node)) {\n return;\n }\n seen.add(node);\n const span = node as { start?: number; end?: number };\n if (typeof span.start === 'number' && typeof span.end === 'number') {\n span.start += delta;\n span.end += delta;\n }\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item !== null && typeof item === 'object') {\n shift(item, delta, seen);\n }\n }\n } else if (value !== null && typeof value === 'object') {\n shift(value, delta, seen);\n }\n }\n}\n\nfunction parse(code: string, delta: number, fail: Fail): oxc.Program {\n const result = parseSync('source.ts', code, { lang: 'ts', preserveParens: false });\n const error = result.errors[0];\n if (error) {\n fail(error.message, (error.labels[0]?.start ?? 0) + delta);\n }\n shift(result.program, delta, new WeakSet());\n return result.program;\n}\n\n/** Parses a script whose code starts at `offset` in the file. */\nexport function parseScript(code: string, offset: number, fail: Fail): oxc.Program {\n return parse(code, offset, fail);\n}\n\n/** Parses an expression whose code starts at `offset` in the file. */\nexport function parseExpression(code: string, offset: number, fail: Fail): oxc.Expression {\n if (code.trim() === '') {\n fail('Expected an expression', offset);\n }\n const program = parse(`(${code}\\n)`, offset - 1, fail);\n const statement = program.body[0];\n if (program.body.length !== 1 || statement?.type !== 'ExpressionStatement') {\n return fail('Expected an expression', offset);\n }\n return statement.expression;\n}\n\n/** Parses a binding pattern, such as the item of `#for`. */\nexport function parsePattern(code: string, offset: number, fail: Fail): oxc.BindingPattern {\n const prefix = 'let ';\n const program = parse(`${prefix}${code} = 0;`, offset - prefix.length, fail);\n const statement = program.body[0];\n if (statement?.type !== 'VariableDeclaration') {\n return fail('Expected a binding pattern', offset);\n }\n return statement.declarations[0]!.id;\n}\n\n/** Parses function parameters, such as those of `#template`. */\nexport function parseParameters(code: string, offset: number, fail: Fail): oxc.ParamPattern[] {\n const prefix = 'function f(';\n const program = parse(`${prefix}${code}\\n) {}`, offset - prefix.length, fail);\n const statement = program.body[0];\n if (statement?.type !== 'FunctionDeclaration') {\n return fail('Expected parameters', offset);\n }\n return statement.params;\n}\n\n/** Returns the names that a binding pattern declares. */\nexport function getPatternNames(\n pattern: oxc.Node,\n names: oxc.BindingIdentifier[] = [],\n): oxc.BindingIdentifier[] {\n switch (pattern.type) {\n case 'Identifier':\n names.push(pattern as oxc.BindingIdentifier);\n break;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n getPatternNames(\n property.type === 'RestElement' ? property.argument : property.value,\n names,\n );\n }\n break;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n getPatternNames(element, names);\n }\n }\n break;\n case 'AssignmentPattern':\n getPatternNames(pattern.left, names);\n break;\n case 'RestElement':\n getPatternNames(pattern.argument, names);\n break;\n case 'TSParameterProperty':\n getPatternNames(pattern.parameter, names);\n break;\n default:\n break;\n }\n return names;\n}\n","import { MACROS, checkMacroImports, isMacroImport, resolveMacros } from './macros.ts';\nimport type {\n Block,\n Body,\n ComponentNode,\n DynamicTagNode,\n ElementNode,\n EventAttribute,\n Expression,\n Markup,\n Range,\n RefAttribute,\n SFCFile,\n TemplateDecl,\n} from './ast.ts';\nimport { lookup, upstreamMemos } from './model.ts';\nimport { KEY_NAMES } from './runtime/events.ts';\nimport type {\n Declaration,\n DeclarationKind,\n Diagnostic,\n Reference,\n Scope,\n ScopeKind,\n SemanticModel,\n Site,\n SiteKind,\n} from './model.ts';\nimport { children, getPatternNames } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\n\n/** Methods that change an array, a `Map` or a `Set` in place. */\nconst MUTATORS = new Set([\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n 'fill',\n 'copyWithin',\n 'set',\n 'add',\n 'delete',\n 'clear',\n]);\n\n/** Declarations whose value the client tracks. Changing their value in place updates nothing. */\nconst REACTIVE = new Set<string>([\n 'signal',\n 'memo',\n 'async-memo',\n 'prop',\n 'props-rest',\n 'item',\n 'action',\n]);\n\n/** The module of the wrappers of event handlers, which the compiler reads. */\nconst EVENTS_MODULE = 'brumate/events';\n/** The wrappers that `brumate/events` exports. */\nconst WRAPPERS = new Set(['prevent', 'stop', 'once', 'capture']);\n/** The events whose `prevent` can name keys. */\nconst KEY_EVENTS = new Set(['keydown', 'keyup', 'keypress']);\n\nconst COMPILE_TIME_FUNCTIONS = MACROS;\n\nconst MISPLACED: Record<string, string> = {\n $setContext: 'Call $setContext at the top level of a script',\n $title: 'Call $title at the top level of a script',\n $id: 'Create an ID with \"const name = $id()\" at the top level of a script',\n $getContext:\n 'Read a context with \"const name = $getContext(Context)\" at the top level of a script',\n $route: 'Read the route with \"const name = $route()\" at the top level of a script',\n $navigation: 'Read the navigation with \"const name = $navigation()\" at the top level of a script',\n $props: 'Call $props() as the value of a const in the component script',\n $signal: 'Declare a signal with \"let name = $signal(value)\" at the top level of a script',\n $memo: 'Declare a memo with \"const name = $memo(value)\" at the top level of a script',\n $debounced:\n 'Declare a debounced value with \"const name = $debounced(value, ms)\" at the top level of a script',\n $throttled:\n 'Declare a throttled value with \"const name = $throttled(value, ms)\" at the top level of a script',\n $optimistic:\n 'Declare an optimistic value with \"let name = $optimistic(source)\" at the top level of a script',\n $action:\n 'Declare the result of a form with \"const name = $action(serverFunction)\" at the top level of a script',\n $effect: 'Call $effect at the top level of a script',\n $client: 'Call $client at the top level of a script',\n};\n\nconst REMOVED: Record<string, string> = {\n $ref: '$ref is not supported. Use a $signal with ref=name',\n $watch: '$watch is not supported. Use $effect',\n $settled: '$settled is not supported. Use $client',\n $cleanup: '$cleanup is not supported. Return a cleanup function from $effect or $client',\n $store: '$store is not supported yet',\n $get: '$get is not supported. Signals cannot leave the file',\n $set: '$set is not supported. Signals cannot leave the file',\n};\n\nconst CLIENT_TRIGGERS = new Set(['visible', 'idle', 'load']);\n\n// Kinds that a write can target.\nconst WRITABLE = new Set<DeclarationKind>(['signal', 'let']);\n\n// Sites that run in response to an event, so they can write signals.\nconst WRITING_SITES = new Set<SiteKind>(['function', 'event', 'effect', 'client']);\n\n// Declarations that a server function can capture.\nconst SERVER_CAPTURABLE = new Set<DeclarationKind>(['import', 'module', 'server-function']);\n\nconst TYPE_KEYS = new Set([\n 'typeAnnotation',\n 'typeParameters',\n 'typeArguments',\n 'returnType',\n 'superTypeArguments',\n 'implements',\n]);\n\nconst TYPE_WRAPPERS = new Set([\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n 'TSInstantiationExpression',\n]);\n\ntype Fn = oxc.Function | oxc.ArrowFunctionExpression;\n\nfunction isFunction(node: oxc.Node | null | undefined): node is Fn {\n return (\n node?.type === 'ArrowFunctionExpression' ||\n node?.type === 'FunctionExpression' ||\n node?.type === 'FunctionDeclaration'\n );\n}\n\nfunction hasUseServer(fn: Fn): boolean {\n const body = fn.body;\n if (!body || body.type !== 'BlockStatement') {\n return false;\n }\n for (const statement of body.body) {\n if (statement.type !== 'ExpressionStatement' || typeof statement.directive !== 'string') {\n return false;\n }\n if (statement.directive === 'use server') {\n return true;\n }\n }\n return false;\n}\n\n/** Returns the name of a compile-time function that `node` calls, if any. */\nfunction calleeName(node: oxc.Node | null | undefined): string | undefined {\n if (node?.type === 'CallExpression' && node.callee.type === 'Identifier') {\n return node.callee.name;\n }\n return undefined;\n}\n\nfunction range(node: Range): Range {\n return { start: node.start, end: node.end };\n}\n\n/**\n * The names of the props that a type marks `Bindable`, such as `open` in\n * `{ open?: Bindable<boolean> }`. A name of a type is looked up among the\n * interfaces and the type aliases of the scripts.\n */\nfunction bindableNames(type: oxc.Node, file: SFCFile): string[] {\n let members: oxc.Node[] | undefined;\n if (type.type === 'TSTypeLiteral') {\n members = type.members;\n } else if (type.type === 'TSTypeReference' && type.typeName.type === 'Identifier') {\n const name = type.typeName.name;\n const statements = [\n ...(file.moduleScript?.program.body ?? []),\n ...(file.instanceScript?.program.body ?? []),\n ].map((statement) =>\n statement.type === 'ExportNamedDeclaration' && statement.declaration\n ? statement.declaration\n : statement,\n );\n for (const statement of statements) {\n if (statement.type === 'TSInterfaceDeclaration' && statement.id.name === name) {\n members = statement.body.body;\n } else if (statement.type === 'TSTypeAliasDeclaration' && statement.id.name === name) {\n return bindableNames(statement.typeAnnotation, file);\n }\n }\n }\n return (members ?? []).flatMap((member) => {\n const annotation =\n member.type === 'TSPropertySignature' ? member.typeAnnotation?.typeAnnotation : undefined;\n const isBindable =\n annotation?.type === 'TSTypeReference' &&\n annotation.typeName.type === 'Identifier' &&\n annotation.typeName.name === 'Bindable';\n if (!isBindable || member.type !== 'TSPropertySignature' || member.computed) {\n return [];\n }\n if (member.key.type === 'Identifier') {\n return [member.key.name];\n }\n return member.key.type === 'Literal' ? [String(member.key.value)] : [];\n });\n}\n\nexport function analyze(file: SFCFile): SemanticModel {\n return new Analyzer(file).run();\n}\n\nclass Analyzer {\n private readonly file: SFCFile;\n private readonly scopes: Scope[] = [];\n private readonly declarations: Declaration[] = [];\n private readonly sites: Site[] = [];\n readonly bindings: SemanticModel['bindings'] = [];\n private readonly diagnostics: Diagnostic[] = [];\n private readonly refs: { attribute: RefAttribute; element: ElementNode; scope: Scope }[] = [];\n /** The type arguments of the `$props<T>()` calls. */\n private readonly propsTypes: oxc.Node[] = [];\n private readonly module: Scope;\n private readonly component: Scope;\n\n constructor(file: SFCFile) {\n this.file = file;\n this.module = this.createScope('module', undefined);\n this.component = this.createScope('component', this.module);\n }\n\n run(): SemanticModel {\n const { imported, diagnostics } = resolveMacros(this.file);\n this.diagnostics.push(...diagnostics, ...checkMacroImports(this.file, imported));\n if (this.file.moduleScript) {\n this.declareModuleScript(this.file.moduleScript.program);\n }\n if (this.file.instanceScript) {\n this.declareScript(this.file.instanceScript.program, this.component, true);\n }\n for (const template of this.file.templates) {\n this.declareTemplate(template, this.component);\n }\n for (const style of this.file.styles) {\n for (const variable of style.variables) {\n this.createExpressionSite('style', this.component, variable, 'style');\n }\n }\n this.visitNodes(this.file.children, this.component);\n this.addProvidedFunctions();\n this.checkBindableProps();\n\n for (const site of this.sites) {\n new Resolver(this, site).run();\n }\n this.addPendingReads();\n this.resolveRefs();\n this.check();\n\n return {\n module: this.module,\n component: this.component,\n scopes: this.scopes,\n declarations: this.declarations,\n sites: this.sites,\n bindings: this.bindings,\n diagnostics: this.diagnostics,\n };\n }\n\n /** `$isPending(memo)` calls, which also read the memos that the memo reads. */\n readonly pendingCalls: { reference: Reference; at: Range }[] = [];\n\n /**\n * A memo is pending while a memo that it reads loads. `$isPending(memo)`\n * reads those memos too, so it updates when they start and stop loading.\n */\n private addPendingReads(): void {\n for (const { reference, at } of this.pendingCalls) {\n for (const declaration of upstreamMemos(reference.declaration)) {\n // An empty range after the call, which no identifier starts at.\n const read: Reference = {\n ...reference,\n declaration,\n range: { start: at.end, end: at.end },\n };\n declaration.reads.push(read);\n reference.site.reads.push(read);\n }\n }\n }\n\n /**\n * Warns about a prop that the type of `$props<T>()` marks `Bindable`, but\n * that the component reads only with `const`, so a binding of it never\n * changes the parent's value. It reads the type in the file: a type\n * literal, or an interface or a type alias of the scripts.\n */\n private checkBindableProps(): void {\n const bindable = new Set<string>();\n for (const type of this.propsTypes) {\n for (const name of bindableNames(type, this.file)) {\n bindable.add(name);\n }\n }\n if (bindable.size === 0) {\n return;\n }\n const props = this.declarations.filter(\n (declaration) =>\n declaration.kind === 'prop' &&\n declaration.scope === this.component &&\n declaration.propKey !== undefined &&\n bindable.has(declaration.propKey),\n );\n const written = new Set(\n props.filter((declaration) => declaration.writable).map((declaration) => declaration.propKey),\n );\n for (const declaration of props) {\n if (!written.has(declaration.propKey)) {\n this.report(\n 'warning',\n `The prop \"${declaration.propKey}\" is Bindable, but the component reads it with const and never writes it. Destructure it with let`,\n declaration.range,\n );\n }\n }\n }\n\n report(severity: Diagnostic['severity'], message: string, at: Range): void {\n this.diagnostics.push({ severity, message, range: range(at) });\n }\n\n // Scopes and declarations\n\n private createScope(\n kind: ScopeKind,\n parent: Scope | undefined,\n extra: Partial<Scope> = {},\n ): Scope {\n const scope: Scope = {\n id: this.scopes.length,\n kind,\n parent,\n children: [],\n declarations: new Map(),\n ...extra,\n };\n parent?.children.push(scope);\n this.scopes.push(scope);\n return scope;\n }\n\n private addDeclaration(\n scope: Scope,\n name: string,\n kind: DeclarationKind,\n at: Range,\n block?: Block,\n ): Declaration {\n if (scope.declarations.has(name)) {\n this.report('error', `\"${name}\" is already declared`, at);\n }\n const declaration: Declaration = {\n id: this.declarations.length,\n name,\n kind,\n scope,\n range: range(at),\n block,\n reads: [],\n writes: [],\n refs: [],\n };\n scope.declarations.set(name, declaration);\n this.declarations.push(declaration);\n return declaration;\n }\n\n private createSite(\n kind: SiteKind,\n scope: Scope,\n node: oxc.Node,\n label: string,\n extra: Partial<Site> = {},\n ): Site {\n const site: Site = {\n id: this.sites.length,\n kind,\n scope,\n range: range(node),\n node,\n label,\n reads: [],\n writes: [],\n calls: new Set(),\n trackedCalls: new Set(),\n awaits: false,\n ...extra,\n };\n this.sites.push(site);\n return site;\n }\n\n private createExpressionSite(\n kind: SiteKind,\n scope: Scope,\n expression: Expression,\n label: string,\n extra: Partial<Site> = {},\n ): Site {\n const site = this.createSite(kind, scope, expression.ast, label, extra);\n site.range = range(expression);\n return site;\n }\n\n /**\n * Reads the wrappers of `brumate/events` around a handler, such as\n * `prevent(move, 'Enter')`, into the modifiers that `b-on` holds, so the\n * loader applies them before the handler's code loads. A modifier in the\n * attribute name, such as `onSubmit:prevent`, still works, with a warning.\n */\n private readWrappers(site: Site, attribute: EventAttribute, scope: Scope): void {\n if (attribute.modifiers.length > 0) {\n const [first] = attribute.modifiers;\n this.report(\n 'warning',\n `${attribute.name}:${first} is replaced by ${attribute.name}=(${first === 'passive' ? 'handler' : `${first}(handler)`}) from brumate/events${first === 'passive' ? ', since listeners are passive unless a handler prevents' : ''}`,\n attribute,\n );\n }\n const modifiers: string[] = [];\n let node: oxc.Node = attribute.handler.ast;\n for (;;) {\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier') {\n break;\n }\n const imported = lookup(scope, node.callee.name)?.imported;\n const name = imported?.source === EVENTS_MODULE ? imported.name : undefined;\n // `transition` acts when the handler runs, so the wrappers inside it still count.\n if (name === 'transition' && node.arguments[0]) {\n node = node.arguments[0];\n continue;\n }\n if (name === undefined || !WRAPPERS.has(name)) {\n break;\n }\n const [handler, ...rest]: oxc.Node[] = node.arguments;\n if (!handler || (name !== 'prevent' && rest.length > 0)) {\n this.report('error', `${name} takes a handler`, node);\n break;\n }\n if (rest.length > 0) {\n const keys = rest.map((key) =>\n key.type === 'Literal' && typeof key.value === 'string' ? key.value : undefined,\n );\n const wrong = rest.find((_, index) => {\n const key = keys[index];\n return key === undefined || !(KEY_NAMES.includes(key) || /^[A-Za-z0-9]$/.test(key));\n });\n if (!KEY_EVENTS.has(attribute.event)) {\n this.report(\n 'error',\n 'Only prevent of a keyboard event takes keys, such as onKeyDown',\n node,\n );\n } else if (wrong) {\n this.report(\n 'error',\n \"Name each key of prevent as a string of its event.key, such as 'ArrowDown', 'Space' or 'a'\",\n wrong,\n );\n }\n modifiers.push(`prevent(${keys.join(',')})`);\n } else {\n modifiers.push(name);\n }\n node = handler;\n }\n if (modifiers.length > 0) {\n site.modifiers = modifiers;\n }\n }\n\n private declareFunction(name: string, fn: Fn, scope: Scope, at: Range): void {\n const server = hasUseServer(fn);\n const kind = server ? 'server-function' : 'function';\n const declaration = this.addDeclaration(scope, name, kind, at);\n const site = this.createSite(\n kind,\n scope,\n fn,\n `${server ? 'server function' : 'function'} ${name}`,\n {\n declaration,\n },\n );\n site.range = range(at);\n declaration.site = site;\n if (server && !fn.async) {\n this.report('error', `Server function \"${name}\" must be async`, at);\n }\n }\n\n private declareModuleScript(program: oxc.Program): void {\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n this.declareImport(statement, this.module);\n } else if (statement.type === 'ExportDefaultDeclaration') {\n this.report('error', 'The module script cannot have a default export', statement);\n } else if (statement.type === 'ExportNamedDeclaration') {\n if (statement.declaration) {\n this.declareModuleStatement(statement.declaration);\n }\n } else {\n this.declareModuleStatement(statement);\n }\n }\n }\n\n private declareModuleStatement(statement: oxc.Node): void {\n switch (statement.type) {\n case 'FunctionDeclaration':\n if (statement.id) {\n const server = hasUseServer(statement);\n this.addDeclaration(\n this.module,\n statement.id.name,\n server ? 'server-function' : 'module',\n statement.id,\n );\n if (server && !statement.async) {\n this.report(\n 'error',\n `Server function \"${statement.id.name}\" must be async`,\n statement.id,\n );\n }\n }\n break;\n case 'VariableDeclaration':\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n const server =\n declarator.id.type === 'Identifier' && isFunction(init) && hasUseServer(init);\n for (const name of getPatternNames(declarator.id)) {\n this.addDeclaration(\n this.module,\n name.name,\n server ? 'server-function' : 'module',\n name,\n );\n }\n }\n break;\n case 'ClassDeclaration':\n case 'TSEnumDeclaration':\n if (statement.id) {\n this.addDeclaration(this.module, statement.id.name, 'module', statement.id);\n }\n break;\n default:\n break;\n }\n }\n\n private declareImport(statement: oxc.ImportDeclaration, scope: Scope): void {\n // Compile-time functions are not values. The compiler replaces their calls.\n if (statement.importKind === 'type' || isMacroImport(statement)) {\n return;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {\n continue;\n }\n const declaration = this.addDeclaration(\n scope,\n specifier.local.name,\n 'import',\n specifier.local,\n );\n if (specifier.type !== 'ImportNamespaceSpecifier') {\n let imported = 'default';\n if (specifier.type !== 'ImportDefaultSpecifier') {\n imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n }\n declaration.imported = { source: statement.source.value, name: imported };\n }\n }\n }\n\n /** Declares the statements of the component script or a block script. */\n private declareScript(program: oxc.Program, scope: Scope, isComponent: boolean): void {\n for (const statement of program.body) {\n switch (statement.type) {\n case 'ImportDeclaration':\n // Imports move to the top of the module.\n this.declareImport(statement, isComponent ? this.module : scope);\n break;\n case 'ExportNamedDeclaration':\n case 'ExportDefaultDeclaration':\n case 'ExportAllDeclaration':\n case 'TSExportAssignment':\n if (\n !('exportKind' in statement && statement.exportKind === 'type') &&\n !this.isTypeExport(statement)\n ) {\n this.report('error', 'A script cannot export values. Use <script module>', statement);\n }\n break;\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSDeclareFunction':\n case 'TSModuleDeclaration':\n break;\n case 'FunctionDeclaration':\n if (statement.id) {\n this.declareFunction(statement.id.name, statement, scope, statement.id);\n }\n break;\n case 'VariableDeclaration':\n for (const declarator of statement.declarations) {\n this.declareVariable(declarator, statement.kind, scope, isComponent);\n }\n break;\n case 'ClassDeclaration':\n case 'TSEnumDeclaration':\n if (statement.id) {\n this.addDeclaration(scope, statement.id.name, 'const', statement.id);\n }\n this.createSite('setup', scope, statement, 'setup');\n break;\n case 'ExpressionStatement': {\n const name = calleeName(statement.expression);\n if (name === '$title') {\n const call = statement.expression as oxc.CallExpression;\n if (call.arguments.length !== 1) {\n this.report('error', '$title takes one argument, the title', call);\n } else {\n this.report(\n 'warning',\n '$title is replaced by <title> in #head, such as #head { <title>{`${count} left`}</title> }, and goes in a later version',\n call,\n );\n this.createSite('title', scope, call.arguments[0]!, 'title');\n }\n } else if (name === '$setContext') {\n this.declareProvide(statement.expression as oxc.CallExpression, scope);\n } else if (name === '$effect' || name === '$client') {\n this.declareEffect(statement.expression as oxc.CallExpression, name, scope);\n } else {\n this.createSite('setup', scope, statement, 'setup');\n }\n break;\n }\n default:\n this.createSite('setup', scope, statement, 'setup');\n break;\n }\n }\n }\n\n private isTypeExport(statement: oxc.Node): boolean {\n if (statement.type !== 'ExportNamedDeclaration' || !statement.declaration) {\n return false;\n }\n const type = statement.declaration.type;\n return type === 'TSInterfaceDeclaration' || type === 'TSTypeAliasDeclaration';\n }\n\n private declareVariable(\n declarator: oxc.VariableDeclarator,\n kind: oxc.VariableDeclaration['kind'],\n scope: Scope,\n isComponent: boolean,\n ): void {\n const id = declarator.id;\n // `const name = await $memo(value)` declares a memo that the render waits for.\n const awaited = declarator.init?.type === 'AwaitExpression' ? declarator.init : undefined;\n const awaitedName = awaited && calleeName(awaited.argument);\n if (\n awaited &&\n awaitedName !== undefined &&\n MACROS.has(awaitedName) &&\n awaitedName !== '$memo'\n ) {\n this.report('error', `await works with $memo, not ${awaitedName}`, awaited);\n }\n const init = awaitedName === '$memo' ? awaited!.argument : declarator.init;\n const name = calleeName(init);\n const call = init as oxc.CallExpression;\n\n if (name === '$props') {\n if (!isComponent) {\n this.report('error', '$props() can only be called in the component script', declarator);\n }\n // `let` makes the props that it destructures writable: the component writes its own copy,\n // or, when a parent binds the prop with `$bind`, the parent's signal.\n if (kind !== 'const' && kind !== 'let') {\n this.report('error', 'Assign $props() to a const or a let', declarator);\n }\n if (call.arguments.length > 0) {\n this.report('error', '$props() takes no arguments', call);\n }\n const type = (call as { typeArguments?: { params: oxc.Node[] } }).typeArguments?.params[0];\n if (type) {\n this.propsTypes.push(type);\n }\n if (id.type === 'ObjectPattern') {\n for (const property of id.properties) {\n if (property.type === 'RestElement') {\n for (const binding of getPatternNames(property.argument)) {\n this.addDeclaration(scope, binding.name, 'props-rest', binding);\n }\n } else {\n let key: string | undefined;\n if (!property.computed) {\n key =\n property.key.type === 'Identifier'\n ? property.key.name\n : String((property.key as { value?: unknown }).value);\n }\n for (const binding of getPatternNames(property.value)) {\n const declaration = this.addDeclaration(scope, binding.name, 'prop', binding);\n declaration.propKey = key;\n if (kind === 'let') {\n declaration.writable = true;\n }\n }\n }\n }\n this.createDefaultSites(id, scope);\n } else if (id.type === 'Identifier') {\n this.addDeclaration(scope, id.name, 'prop', id);\n } else {\n this.report('error', 'Assign $props() to a name or an object pattern', id);\n }\n return;\n }\n\n if (name === '$id') {\n if (kind !== 'const' || id.type !== 'Identifier') {\n this.report('error', 'Create an ID with \"const name = $id()\"', declarator);\n return;\n }\n if (call.arguments.length > 0) {\n this.report('error', '$id takes no arguments', call);\n }\n const declaration = this.addDeclaration(scope, id.name, 'const', id);\n declaration.idIndex = [...scope.declarations.values()].filter(\n (item) => item.idIndex !== undefined,\n ).length;\n return;\n }\n\n if (name === '$route' || name === '$navigation') {\n if (kind !== 'const' || id.type !== 'Identifier') {\n this.report('error', MISPLACED[name]!, declarator);\n return;\n }\n if (name === '$navigation' ? call.arguments.length > 0 : call.arguments.length > 1) {\n this.report(\n 'error',\n name === '$navigation'\n ? '$navigation takes no arguments'\n : '$route takes at most one argument, the path of the route',\n call,\n );\n }\n // A context that the runtime provides, so it changes when navigation changes the page.\n this.addDeclaration(scope, id.name, 'context', id);\n return;\n }\n\n if (name === '$getContext') {\n if (kind !== 'const' || id.type !== 'Identifier') {\n this.report('error', 'Read a context with \"const name = $getContext(Context)\"', declarator);\n return;\n }\n if (call.arguments.length !== 1) {\n this.report('error', '$getContext takes one argument, the context', call);\n }\n this.addDeclaration(scope, id.name, 'context', id);\n const argument = call.arguments[0];\n if (argument) {\n this.createSite('setup', scope, argument, `context ${id.name}`);\n }\n return;\n }\n\n if (name === '$action') {\n const argument = call.arguments[0];\n if (kind !== 'const' || id.type !== 'Identifier') {\n this.report(\n 'error',\n 'Declare the result of a form with \"const name = $action(serverFunction)\"',\n declarator,\n );\n return;\n }\n if (argument?.type !== 'Identifier' || call.arguments.length !== 1) {\n this.report(\n 'error',\n '$action needs a server function of this file as its only argument',\n call,\n );\n return;\n }\n const declaration = this.addDeclaration(scope, id.name, 'action', id);\n declaration.action = argument.name;\n return;\n }\n\n if (name === '$debounced' || name === '$throttled') {\n if (kind !== 'const') {\n this.report('error', `Declare ${name} with const`, declarator);\n }\n if (id.type !== 'Identifier') {\n this.report('error', `${name} cannot be destructured`, id);\n return;\n }\n const [argument, wait] = call.arguments;\n const declaration = this.addDeclaration(scope, id.name, 'memo', id);\n if (!argument || call.arguments.length !== 2) {\n this.report('error', `${name} takes a value and a wait in milliseconds`, call);\n return;\n }\n const ms = wait?.type === 'Literal' && typeof wait.value === 'number' ? wait.value : NaN;\n // A timer cannot wait longer than 2^31 - 1 ms, and fires at once for a longer wait.\n if (!(ms >= 0 && ms <= 2147483647)) {\n this.report(\n 'error',\n `The wait of ${name} must be a number of milliseconds, such as 300`,\n wait!,\n );\n }\n declaration.timing = { kind: name === '$debounced' ? 'debounced' : 'throttled', ms };\n declaration.site = this.createSite('memo', scope, argument, `memo ${id.name}`, {\n declaration,\n });\n return;\n }\n\n if (name === '$signal' || name === '$memo' || name === '$optimistic') {\n const expected = name === '$memo' ? 'const' : 'let';\n if (kind !== expected) {\n this.report('error', `Declare ${name} with ${expected}`, declarator);\n }\n if (id.type !== 'Identifier') {\n this.report('error', `${name} cannot be destructured`, id);\n return;\n }\n if (call.arguments.length > 1) {\n this.report('error', `${name} takes one argument`, call);\n }\n const argument = call.arguments[0];\n if (name === '$signal') {\n const declaration = this.addDeclaration(scope, id.name, 'signal', id);\n if (argument) {\n declaration.init = argument;\n this.createSite('setup', scope, argument, `signal ${id.name}`);\n }\n return;\n }\n const declaration = this.addDeclaration(scope, id.name, 'memo', id);\n if (awaited && name === '$memo') {\n declaration.awaited = true;\n }\n if (!argument) {\n this.report('error', `${name} needs a value`, call);\n return;\n }\n if (name === '$optimistic') {\n // A memo of its source, which handlers can write.\n declaration.writable = true;\n if (argument.type !== 'Identifier') {\n this.report('error', '$optimistic needs the name of a value, such as a memo', argument);\n }\n }\n declaration.site = this.createSite('memo', scope, argument, `memo ${id.name}`, {\n declaration,\n });\n return;\n }\n\n if (name === '$effect' || name === '$client') {\n this.report('error', `${name} does not return a value`, call);\n return;\n }\n\n if (kind === 'const' && id.type === 'Identifier' && isFunction(init)) {\n this.declareFunction(id.name, init, scope, id);\n return;\n }\n\n for (const binding of getPatternNames(id)) {\n this.addDeclaration(scope, binding.name, kind === 'const' ? 'const' : 'let', binding);\n }\n this.createDefaultSites(id, scope);\n if (init) {\n this.createSite('setup', scope, init, 'setup');\n }\n }\n\n /** Creates setup sites for the default values and computed keys of a pattern. */\n private createDefaultSites(pattern: oxc.Node, scope: Scope): void {\n switch (pattern.type) {\n case 'AssignmentPattern':\n this.createSite('setup', scope, pattern.right, 'default');\n this.createDefaultSites(pattern.left, scope);\n break;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n if (property.type === 'RestElement') {\n this.createDefaultSites(property.argument, scope);\n } else {\n if (property.computed) {\n this.createSite('setup', scope, property.key, 'key');\n }\n this.createDefaultSites(property.value, scope);\n }\n }\n break;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n this.createDefaultSites(element, scope);\n }\n }\n break;\n case 'RestElement':\n this.createDefaultSites(pattern.argument, scope);\n break;\n default:\n break;\n }\n }\n\n /**\n * Functions in a provided value run in the browser, where a component that\n * reads the context calls them. Each one is a client root, as a function\n * prop is: the value itself, or the value of a key of an object, such as\n * `toggle` in `$setContext(Theme, { theme, toggle })`.\n */\n private addProvidedFunctions(): void {\n for (const site of this.sites.filter((item) => item.kind === 'provide')) {\n const value = site.node;\n const parts =\n value.type === 'ObjectExpression'\n ? value.properties.flatMap((property) =>\n property.type === 'Property' && !property.computed ? [property.value] : [],\n )\n : [value];\n for (const part of parts) {\n const isFunctionPart =\n isFunction(part) ||\n (part.type === 'Identifier' &&\n ['function', 'server-function'].includes(lookup(site.scope, part.name)?.kind ?? ''));\n if (isFunctionPart) {\n this.createSite('prop', site.scope, part, 'provided function');\n }\n }\n }\n }\n\n /**\n * `$handler(fn, ...args)`: `fn` is a client root, as a function prop is, and\n * its reference goes with the arguments. `isLocal` tells a name that a\n * function around the call declares: `fn` cannot read one, since only the\n * values of the scope and the arguments reach the browser.\n */\n declareHandler(call: oxc.CallExpression, scope: Scope, isLocal: (name: string) => boolean): void {\n const [fn] = call.arguments;\n if (!fn || fn.type === 'SpreadElement' || !this.isHandlerFunction(fn, scope)) {\n this.report(\n 'error',\n '$handler needs a function as its first argument: a function expression, a function of the script, or one of them in a wrapper of brumate/events',\n call,\n );\n return;\n }\n for (const name of freeNames(fn)) {\n if (isLocal(name)) {\n this.report(\n 'error',\n `The handler reads \"${name}\", a value of the function around $handler, which the browser does not have. Pass it as an argument: $handler(fn, ${name})`,\n fn,\n );\n return;\n }\n }\n if (call.arguments.slice(1).some((argument) => argument.type === 'SpreadElement')) {\n this.report('error', 'The arguments of $handler cannot be spread', call);\n }\n this.createSite('prop', scope, fn, 'handler', {\n handler: call,\n modifiers: this.handlerModifiers(fn, scope),\n });\n }\n\n /**\n * The function of `$bind(name, fn)`, which a write of the binding calls\n * with the new value in place of writing the name. It compiles as a\n * handler does, with its own part.\n */\n declareSetter(\n call: oxc.CallExpression,\n scope: Scope,\n isLocal: (name: string) => boolean,\n ): Site | undefined {\n const fn = call.arguments[1]!;\n if (fn.type === 'SpreadElement' || !this.isHandlerFunction(fn, scope)) {\n this.report(\n 'error',\n 'The second argument of $bind is a function that takes the new value: a function expression, or a function of the script',\n fn,\n );\n return undefined;\n }\n for (const name of freeNames(fn)) {\n if (isLocal(name)) {\n this.report(\n 'error',\n `The setter reads \"${name}\", a value of the function around $bind, which the browser does not have`,\n fn,\n );\n return undefined;\n }\n }\n return this.createSite('prop', scope, fn, 'setter', { setter: call });\n }\n\n /**\n * The modifiers of the wrappers around the function of `$handler`, such as\n * `prevent`, as `b-on` holds them. Markup that the browser renders writes\n * them without loading the code of the handler.\n */\n private handlerModifiers(node: oxc.Node, scope: Scope): string[] | undefined {\n const modifiers: string[] = [];\n while (node.type === 'CallExpression' && node.callee.type === 'Identifier') {\n const imported = lookup(scope, node.callee.name)?.imported;\n const name = imported?.source === EVENTS_MODULE ? imported.name : undefined;\n const [handler, ...keys] = node.arguments;\n if (name === 'transition' && handler) {\n node = handler;\n continue;\n }\n if (name === undefined || !WRAPPERS.has(name) || !handler) {\n break;\n }\n const names = keys.map((key) =>\n key.type === 'Literal' && typeof key.value === 'string' ? key.value : undefined,\n );\n if (names.some((key) => key === undefined)) {\n this.report('error', \"Name each key of prevent as a string, such as 'Enter'\", node);\n }\n modifiers.push(names.length > 0 ? `${name}(${names.join(',')})` : name);\n node = handler;\n }\n return modifiers.length > 0 ? modifiers : undefined;\n }\n\n /** A function, a function of the script, or one of them in wrappers of `brumate/events`. */\n private isHandlerFunction(node: oxc.Node, scope: Scope): boolean {\n while (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n lookup(scope, node.callee.name)?.imported?.source === EVENTS_MODULE &&\n node.arguments[0]\n ) {\n node = node.arguments[0];\n }\n if (isFunction(node)) {\n return true;\n }\n if (node.type === 'Identifier') {\n const kind = lookup(scope, node.name)?.kind;\n return kind === 'function' || kind === 'server-function';\n }\n return false;\n }\n\n private declareProvide(call: oxc.CallExpression, scope: Scope): void {\n const [context, value] = call.arguments;\n if (!context || !value || call.arguments.length !== 2) {\n this.report('error', '$setContext takes two arguments, the context and the value', call);\n return;\n }\n this.createSite('provide', scope, value, 'provide', { extra: [context] });\n }\n\n private declareEffect(call: oxc.CallExpression, name: '$effect' | '$client', scope: Scope): void {\n const callback = call.arguments[0];\n if (!isFunction(callback)) {\n this.report('error', `${name} needs a function`, call);\n return;\n }\n if (callback.params.length > 0) {\n this.report('error', `The callback of ${name} takes no parameters`, callback);\n }\n if (callback.async) {\n this.report('error', `The callback of ${name} cannot be async`, callback);\n }\n if (name === '$effect') {\n if (call.arguments.length > 1) {\n this.report('error', '$effect takes one argument', call);\n }\n this.createSite('effect', scope, callback, 'effect');\n return;\n }\n let trigger: Site['trigger'] = 'visible';\n const argument = call.arguments[1];\n if (argument) {\n if (\n argument.type !== 'Literal' ||\n typeof argument.value !== 'string' ||\n !CLIENT_TRIGGERS.has(argument.value)\n ) {\n this.report(\n 'error',\n 'The trigger of $client must be \"visible\", \"idle\" or \"load\"',\n argument,\n );\n } else {\n trigger = argument.value as Site['trigger'];\n }\n }\n if (trigger === 'load') {\n this.report('warning', '$client with \"load\" runs before any interaction', call);\n }\n this.createSite('client', scope, callback, `client ${trigger}`, { trigger });\n }\n\n private declareTemplate(template: TemplateDecl, scope: Scope): void {\n this.addDeclaration(scope, template.name, 'template', template.nameRange);\n const templateScope = this.createScope('template', scope, { template, body: template.body });\n for (const param of template.params) {\n for (const binding of getPatternNames(param)) {\n this.addDeclaration(templateScope, binding.name, 'template-param', binding);\n }\n this.createDefaultSites(param, templateScope);\n }\n this.visitBodyContent(template.body, templateScope);\n }\n\n // Markup\n\n private visitBody(\n body: Body,\n parent: Scope,\n block: Block,\n declare?: (scope: Scope) => void,\n ): void {\n const scope = this.createScope('body', parent, { block, body });\n declare?.(scope);\n this.visitBodyContent(body, scope);\n }\n\n private visitBodyContent(body: Body, scope: Scope): void {\n if (body.script) {\n this.declareScript(body.script.program, scope, false);\n }\n for (const template of body.templates) {\n this.declareTemplate(template, scope);\n }\n this.visitNodes(body.children, scope);\n }\n\n private visitNodes(nodes: Markup[], scope: Scope): void {\n for (const node of nodes) {\n this.visitNode(node, scope);\n }\n }\n\n private visitNode(node: Markup, scope: Scope): void {\n switch (node.kind) {\n case 'text':\n break;\n case 'insert':\n this.createExpressionSite('insert', scope, node.expression, 'insert');\n break;\n case 'element':\n case 'dynamic':\n if (node.kind === 'dynamic') {\n this.createExpressionSite('tag', scope, node.tag, 'tag', { owner: node });\n }\n this.visitAttributes(node, scope);\n this.visitNodes(node.children, scope);\n break;\n case 'component':\n this.visitAttributes(node, scope);\n this.visitNodes(node.children, scope);\n break;\n case 'fragment':\n this.visitNodes(node.children, scope);\n break;\n case 'listener':\n for (const attribute of node.attributes) {\n const site = this.createExpressionSite(\n 'event',\n scope,\n attribute.handler,\n `event ${node.target}.${attribute.event}`,\n {\n owner: node,\n event: attribute,\n },\n );\n this.readWrappers(site, attribute, scope);\n }\n break;\n default:\n this.visitBlock(node, scope);\n break;\n }\n }\n\n private visitAttributes(node: ElementNode | ComponentNode | DynamicTagNode, scope: Scope): void {\n const isComponent = node.kind === 'component';\n let tag = 'dynamic';\n if (node.kind === 'element') {\n tag = node.tag;\n } else if (node.kind === 'component') {\n tag = node.name;\n }\n for (const attribute of node.attributes) {\n if (\n !isComponent &&\n (attribute.kind === 'static' || attribute.kind === 'value') &&\n attribute.name.startsWith('b-')\n ) {\n this.report(\n 'error',\n `\"${attribute.name}\" is reserved. Brumate writes the attributes that start with \"b-\"`,\n attribute,\n );\n }\n switch (attribute.kind) {\n case 'static':\n case 'prefetch':\n break;\n case 'value':\n this.createExpressionSite(\n isComponent ? 'prop' : 'attribute',\n scope,\n attribute.value,\n `${isComponent ? 'prop' : 'attribute'} ${tag}.${attribute.name}`,\n { owner: node },\n );\n break;\n case 'event': {\n const site = this.createExpressionSite(\n isComponent ? 'prop' : 'event',\n scope,\n attribute.handler,\n isComponent ? `prop ${tag}.${attribute.name}` : `event ${tag}.${attribute.event}`,\n { owner: node, event: isComponent ? undefined : attribute },\n );\n if (!isComponent) {\n this.readWrappers(site, attribute, scope);\n }\n break;\n }\n case 'ref':\n if (node.kind === 'element') {\n this.refs.push({ attribute, element: node, scope });\n }\n break;\n case 'spread':\n this.createExpressionSite('spread', scope, attribute.value, `spread ${tag}`, {\n owner: node,\n });\n break;\n case 'computed':\n this.createExpressionSite(\n isComponent ? 'prop' : 'attribute',\n scope,\n attribute.name,\n `computed ${tag}`,\n {\n owner: node,\n },\n );\n if (attribute.value !== true) {\n this.createExpressionSite(\n isComponent ? 'prop' : 'attribute',\n scope,\n attribute.value,\n `computed ${tag}`,\n {\n owner: node,\n },\n );\n }\n break;\n }\n }\n }\n\n private header(block: Block, scope: Scope, expression: Expression, label: string): void {\n this.createExpressionSite('block', scope, expression, label, { block });\n }\n\n private visitBlock(block: Block, scope: Scope): void {\n switch (block.kind) {\n case 'if':\n for (const branch of block.branches) {\n this.header(block, scope, branch.condition, 'if');\n this.visitBody(branch.body, scope, block);\n }\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'for':\n this.header(block, scope, block.list, 'for');\n if (block.key && block.key !== 'index') {\n // The key reads the item, so it resolves in the body scope.\n const key = block.key;\n this.visitBody(block.body, scope, block, (body) => {\n this.declareLoopVariables(block, body);\n this.createExpressionSite('block', body, key, 'for key', { block });\n });\n } else {\n this.visitBody(block.body, scope, block, (body) =>\n this.declareLoopVariables(block, body),\n );\n }\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'repeat':\n this.header(block, scope, block.count, 'repeat');\n this.visitBody(block.body, scope, block, (body) => {\n if (block.index) {\n this.addDeclaration(body, block.index.name, 'index', block.index, block);\n }\n });\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'switch':\n for (const branch of block.cases) {\n this.header(block, scope, branch.condition, 'case');\n this.visitBody(branch.body, scope, block);\n }\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'key':\n this.header(block, scope, block.value, 'key');\n this.visitBody(block.body, scope, block);\n break;\n case 'try':\n this.visitBody(block.body, scope, block);\n this.visitBody(block.fallback, scope, block, (body) => {\n if (block.error) {\n this.addDeclaration(body, block.error.name, 'error', block.error, block);\n }\n if (block.reset) {\n this.addDeclaration(body, block.reset.name, 'reset', block.reset, block);\n }\n });\n break;\n case 'loading':\n if (block.on) {\n this.header(block, scope, block.on, 'loading');\n }\n this.visitBody(block.body, scope, block);\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'head':\n this.visitBody(block.body, scope, block);\n break;\n case 'portal':\n if (block.target) {\n this.header(block, scope, block.target, 'portal');\n }\n this.visitBody(block.body, scope, block);\n break;\n case 'client':\n case 'defer':\n this.visitBody(block.body, scope, block);\n if (block.fallback) {\n this.visitBody(block.fallback, scope, block);\n }\n break;\n case 'offscreen':\n this.header(block, scope, block.visible, 'offscreen');\n this.visitBody(block.body, scope, block);\n break;\n }\n }\n\n private declareLoopVariables(block: Block & { kind: 'for' }, body: Scope): void {\n for (const binding of getPatternNames(block.item)) {\n this.addDeclaration(body, binding.name, 'item', binding, block);\n }\n this.createDefaultSites(block.item, body);\n if (block.index) {\n this.addDeclaration(body, block.index.name, 'index', block.index, block);\n }\n }\n\n // Checks\n\n private resolveRefs(): void {\n for (const ref of this.refs) {\n const declaration = lookup(ref.scope, ref.attribute.target);\n if (!declaration) {\n this.report(\n 'error',\n `\"${ref.attribute.target}\" is not declared`,\n ref.attribute.targetRange,\n );\n } else if (declaration.kind !== 'signal') {\n this.report(\n 'error',\n `ref must name a $signal, but \"${declaration.name}\" is a ${declaration.kind}`,\n ref.attribute,\n );\n } else {\n declaration.refs.push(ref);\n }\n }\n }\n\n private check(): void {\n for (const declaration of this.declarations) {\n if (declaration.kind === 'action') {\n const target = lookup(declaration.scope, declaration.action!);\n if (target?.kind !== 'server-function') {\n this.report(\n 'error',\n `$action needs a server function of this file, and ${declaration.action} is not one`,\n declaration.range,\n );\n }\n }\n }\n for (const site of this.sites) {\n for (const write of site.writes) {\n const declaration = write.declaration;\n if (!WRITABLE.has(declaration.kind) && !declaration.writable) {\n this.report(\n 'error',\n `Cannot assign to ${declaration.kind} \"${declaration.name}\"`,\n write.range,\n );\n } else if (\n (declaration.kind === 'signal' || declaration.writable) &&\n !write.inFunction &&\n !WRITING_SITES.has(site.kind)\n ) {\n this.report(\n 'error',\n `Signal \"${declaration.name}\" can only be written in event handlers, effects, $client callbacks and functions`,\n write.range,\n );\n }\n }\n if (site.kind === 'server-function') {\n for (const read of site.reads) {\n if (!SERVER_CAPTURABLE.has(read.declaration.kind)) {\n this.report(\n 'error',\n `Server function \"${site.declaration?.name}\" captures \"${read.declaration.name}\". Pass it as an argument`,\n read.range,\n );\n }\n }\n }\n if (site.kind === 'memo' && site.declaration?.writable) {\n this.linkOptimistic(site.declaration);\n }\n if (site.kind === 'memo' && site.declaration) {\n const callsServer = [...site.calls].some(\n (declaration) => declaration.kind === 'server-function',\n );\n if (callsServer || site.awaits) {\n site.declaration.kind = 'async-memo';\n }\n }\n }\n }\n\n /**\n * Finds the source of `$optimistic(source)`. A write reads the source too,\n * so the source has a slot that the browser can reset the guess from.\n */\n private linkOptimistic(declaration: Declaration): void {\n const site = declaration.site!;\n const source = site.reads.find((read) => read.range.start === site.range.start)?.declaration;\n if (!source) {\n return;\n }\n declaration.optimistic = source;\n if (source.kind === 'signal' || source.kind === 'let') {\n // A value that handlers write can be written directly, without a guess.\n this.report(\n 'error',\n '$optimistic follows a memo, an action or a prop, not a signal',\n site.range,\n );\n }\n for (const write of declaration.writes) {\n const read = { ...write, declaration: source, range: source.range };\n source.reads.push(read);\n write.site.reads.push(read);\n }\n }\n}\n\n/** Resolves the identifiers of one site to declarations. */\nclass Resolver {\n private readonly analyzer: Analyzer;\n private readonly site: Site;\n private readonly locals: Set<string>[] = [];\n private functionDepth = 0;\n private untracked = 0;\n\n constructor(analyzer: Analyzer, site: Site) {\n this.analyzer = analyzer;\n this.site = site;\n }\n\n run(): void {\n const node = this.site.node;\n if (\n isFunction(node) &&\n (this.site.kind === 'function' || this.site.kind === 'server-function')\n ) {\n // The function itself is the site, so its body is not an inner function.\n this.visitFunction(node, true);\n } else if (isFunction(node) && (this.site.kind === 'effect' || this.site.kind === 'client')) {\n this.visitFunction(node, true);\n } else {\n this.visit(node);\n }\n for (const extra of this.site.extra ?? []) {\n this.visit(extra);\n }\n }\n\n private isLocal(name: string): boolean {\n return this.locals.some((scope) => scope.has(name));\n }\n\n private withLocals(names: Iterable<string>, callback: () => void): void {\n this.locals.push(new Set(names));\n callback();\n this.locals.pop();\n }\n\n private reference(\n identifier: oxc.Node & { name: string },\n mode: 'read' | 'write' | 'update',\n ): Reference | undefined {\n if (this.isLocal(identifier.name)) {\n return undefined;\n }\n const declaration = lookup(this.site.scope, identifier.name);\n if (!declaration) {\n return undefined;\n }\n const reference: Reference = {\n range: range(identifier),\n declaration,\n site: this.site,\n tracked: this.untracked === 0,\n inFunction: this.functionDepth > 0,\n };\n if (mode !== 'write') {\n declaration.reads.push(reference);\n this.site.reads.push(reference);\n }\n if (mode !== 'read') {\n declaration.writes.push(reference);\n this.site.writes.push(reference);\n }\n if (\n declaration.kind === 'function' ||\n declaration.kind === 'server-function' ||\n declaration.kind === 'template'\n ) {\n this.site.calls.add(declaration);\n if (this.untracked === 0) {\n this.site.trackedCalls.add(declaration);\n }\n }\n return reference;\n }\n\n /**\n * `$bind(name)` passes a child a reference to a signal, or to a prop that\n * the component writes, so the child's writes reach it. It is the whole\n * value of a prop of a component. The name gets a slot, which the\n * reference points to.\n */\n private declareBinding(call: oxc.CallExpression): void {\n let node: oxc.Node = this.site.node;\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n const owner = this.site.owner;\n // On an element, it is the value of an input, a select or a text area, or whether a box is checked.\n const element =\n this.site.kind === 'attribute' && owner?.kind === 'element'\n ? owner.attributes.find(\n (attribute) => attribute.kind === 'value' && attribute.value.ast === this.site.node,\n )\n : undefined;\n const onElement =\n element?.kind === 'value' &&\n (element.name === 'value' || element.name === 'checked') &&\n ['input', 'select', 'textarea'].includes((owner as { tag: string }).tag.toLowerCase());\n if (!(this.site.kind === 'prop' || onElement) || node !== call) {\n this.analyzer.report(\n 'error',\n 'Pass $bind(name) as the value of a prop of a component, or of value or checked of an input, a select or a textarea',\n call,\n );\n return;\n }\n const [target, fn, ...rest] = call.arguments;\n if (!target || target.type !== 'Identifier' || rest.length > 0) {\n this.analyzer.report(\n 'error',\n '$bind takes the name of a signal, and a function that writes it, such as $bind(open) or $bind(open, (next) => (open = next))',\n call,\n );\n return;\n }\n const declaration = this.isLocal(target.name)\n ? undefined\n : lookup(this.site.scope, target.name);\n if (\n !declaration ||\n !(declaration.kind === 'signal' || (declaration.kind === 'prop' && declaration.writable))\n ) {\n this.analyzer.report(\n 'error',\n `$bind takes a signal, or a prop that the component destructures with let, and \"${target.name}\" is not one`,\n target,\n );\n return;\n }\n declaration.bound = true;\n const setter =\n fn === undefined\n ? undefined\n : this.analyzer.declareSetter(call, this.site.scope, (local) => this.isLocal(local));\n this.analyzer.bindings.push({ call, declaration, setter });\n }\n\n private visitChildren(node: oxc.Node): void {\n for (const [key, child] of children(node)) {\n if (!TYPE_KEYS.has(key)) {\n this.visit(child);\n }\n }\n }\n\n private visitStatements(statements: oxc.Node[]): void {\n this.withLocals(lexicalNames(statements), () => {\n for (const statement of statements) {\n this.visit(statement);\n }\n });\n }\n\n private visit(node: oxc.Node): void {\n switch (node.type) {\n case 'Identifier':\n this.reference(node, 'read');\n return;\n case 'MemberExpression':\n this.visit(node.object);\n if (node.computed) {\n this.visit(node.property);\n }\n return;\n case 'Property':\n case 'MethodDefinition':\n case 'PropertyDefinition':\n case 'AccessorProperty':\n if (node.computed) {\n this.visit(node.key);\n }\n if (node.value) {\n this.visit(node.value);\n }\n return;\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'ArrowFunctionExpression':\n this.visitFunction(node, false);\n return;\n case 'ClassDeclaration':\n case 'ClassExpression':\n this.withLocals(node.type === 'ClassExpression' && node.id ? [node.id.name] : [], () => {\n if (node.superClass) {\n this.visit(node.superClass);\n }\n this.visit(node.body);\n });\n return;\n case 'BlockStatement':\n case 'StaticBlock':\n this.visitStatements(node.body);\n return;\n case 'ForStatement':\n case 'ForInStatement':\n case 'ForOfStatement': {\n const declaration = node.type === 'ForStatement' ? node.init : node.left;\n const names =\n declaration?.type === 'VariableDeclaration'\n ? declaration.declarations.flatMap((item) =>\n getPatternNames(item.id).map((name) => name.name),\n )\n : [];\n this.withLocals(names, () => {\n if (node.type === 'ForStatement') {\n this.visitChildren(node);\n } else {\n if (node.left.type === 'VariableDeclaration') {\n this.visit(node.left);\n } else {\n this.visitTarget(node.left, 'write');\n }\n this.visit(node.right);\n this.visit(node.body);\n }\n });\n return;\n }\n case 'SwitchStatement':\n this.visit(node.discriminant);\n this.withLocals(lexicalNames(node.cases.flatMap((item) => item.consequent)), () => {\n for (const item of node.cases) {\n if (item.test) {\n this.visit(item.test);\n }\n for (const statement of item.consequent) {\n this.visit(statement);\n }\n }\n });\n return;\n case 'CatchClause':\n this.withLocals(\n node.param ? getPatternNames(node.param).map((name) => name.name) : [],\n () => {\n if (node.param) {\n this.visitDefaults(node.param);\n }\n this.visit(node.body);\n },\n );\n return;\n case 'VariableDeclaration':\n for (const declarator of node.declarations) {\n this.visitDefaults(declarator.id);\n if (declarator.init) {\n this.visit(declarator.init);\n }\n }\n return;\n case 'AssignmentExpression':\n this.checkMutation(node.left, node);\n this.visitTarget(node.left, node.operator === '=' ? 'write' : 'update');\n this.visit(node.right);\n return;\n case 'UpdateExpression':\n this.checkMutation(node.argument, node);\n if (node.argument.type === 'Identifier') {\n this.reference(node.argument, 'update');\n } else {\n this.visit(node.argument);\n }\n return;\n case 'LabeledStatement':\n this.visit(node.body);\n return;\n case 'BreakStatement':\n case 'ContinueStatement':\n case 'MetaProperty':\n return;\n case 'AwaitExpression': {\n // `await name` of a memo waits for its value in the render around the read, and is a\n // plain read of the value in the browser. Every other await waits for a promise.\n const argument = node.argument;\n if (argument.type === 'Identifier') {\n const declaration = this.isLocal(argument.name)\n ? undefined\n : lookup(this.site.scope, argument.name);\n if (declaration?.kind === 'memo' || declaration?.kind === 'async-memo') {\n const reference = this.reference(argument, 'read');\n if (reference) {\n reference.await = range(node);\n }\n return;\n }\n }\n if (this.functionDepth === 0) {\n this.site.awaits = true;\n }\n this.visit(argument);\n return;\n }\n case 'CallExpression': {\n // `event.refresh(fn)` in a server function: memos that call `fn` load again.\n if (\n this.site.kind === 'server-function' &&\n node.callee.type === 'MemberExpression' &&\n !node.callee.computed &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'refresh' &&\n node.arguments[0]?.type === 'Identifier'\n ) {\n const target = lookup(this.site.scope, node.arguments[0].name);\n if (target?.kind === 'server-function') {\n target.refreshed = true;\n }\n }\n if (\n node.callee.type === 'MemberExpression' &&\n !node.callee.computed &&\n node.callee.property.type === 'Identifier' &&\n MUTATORS.has(node.callee.property.name)\n ) {\n this.checkMutation(node.callee.object, node);\n }\n const name = node.callee.type === 'Identifier' ? node.callee.name : undefined;\n if (name && !this.isLocal(name) && !lookup(this.site.scope, name)) {\n if (name === '$untrack') {\n this.untracked++;\n for (const argument of node.arguments) {\n this.visit(argument);\n }\n this.untracked--;\n return;\n }\n if (name === '$isPending') {\n const [target] = node.arguments;\n if (target?.type !== 'Identifier' || node.arguments.length !== 1) {\n this.analyzer.report(\n 'error',\n '$isPending needs an async $memo as its only argument',\n node,\n );\n }\n this.visitChildren(node);\n const reference = this.site.reads.at(-1);\n if (target?.type === 'Identifier' && reference?.range.start === target.start) {\n this.analyzer.pendingCalls.push({ reference, at: range(node) });\n }\n return;\n }\n if (name === '$produce') {\n // `$produce(todos, recipe)` reads and writes `todos`.\n const [target, recipe, ...rest] = node.arguments;\n if (target?.type === 'Identifier') {\n this.reference(target, 'update');\n } else {\n this.analyzer.report('error', '$produce needs a signal as its first argument', node);\n }\n if (!isFunction(recipe)) {\n this.analyzer.report(\n 'error',\n '$produce needs a recipe function as its second argument',\n node,\n );\n }\n for (const argument of recipe ? [recipe, ...rest] : rest) {\n this.visit(argument);\n }\n return;\n }\n if (name === '$bind') {\n this.declareBinding(node);\n for (const argument of node.arguments) {\n this.visit(argument);\n }\n return;\n }\n if (name === '$handler') {\n this.analyzer.declareHandler(node, this.site.scope, (local) => this.isLocal(local));\n // The arguments are values of this site, which go with the handler.\n for (const argument of node.arguments.slice(1)) {\n this.visit(argument);\n }\n return;\n }\n if (COMPILE_TIME_FUNCTIONS.has(name)) {\n this.analyzer.report('error', MISPLACED[name] ?? `${name} cannot be used here`, node);\n } else if (name in REMOVED) {\n this.analyzer.report('error', REMOVED[name]!, node);\n }\n }\n this.visitChildren(node);\n return;\n }\n default:\n if (TYPE_WRAPPERS.has(node.type)) {\n this.visit((node as { expression: oxc.Node }).expression);\n } else if (!node.type.startsWith('TS')) {\n this.visitChildren(node);\n }\n }\n }\n\n private visitFunction(fn: Fn, isSite: boolean): void {\n if (!isSite && hasUseServer(fn)) {\n this.analyzer.report('error', 'Declare server functions at the top level of a script', fn);\n }\n const names = fn.params.flatMap((param) => getPatternNames(param).map((name) => name.name));\n if (fn.type === 'FunctionExpression' && fn.id) {\n names.push(fn.id.name);\n }\n const body = fn.body;\n if (body?.type === 'BlockStatement') {\n names.push(...lexicalNames(body.body), ...varNames(body));\n }\n if (!isSite) {\n this.functionDepth++;\n }\n this.withLocals(names, () => {\n for (const param of fn.params) {\n this.visitDefaults(param);\n }\n if (body?.type === 'BlockStatement') {\n for (const statement of body.body) {\n this.visit(statement);\n }\n } else if (body) {\n this.visit(body);\n }\n });\n if (!isSite) {\n this.functionDepth--;\n }\n }\n\n /** Visits the default values and computed keys of a binding pattern. */\n private visitDefaults(pattern: oxc.Node): void {\n switch (pattern.type) {\n case 'AssignmentPattern':\n this.visitDefaults(pattern.left);\n this.visit(pattern.right);\n break;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n if (property.type === 'RestElement') {\n this.visitDefaults(property.argument);\n } else {\n if (property.computed) {\n this.visit(property.key);\n }\n this.visitDefaults(property.value);\n }\n }\n break;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n this.visitDefaults(element);\n }\n }\n break;\n case 'RestElement':\n this.visitDefaults(pattern.argument);\n break;\n case 'TSParameterProperty':\n this.visitDefaults(pattern.parameter);\n break;\n default:\n break;\n }\n }\n\n /** Visits the target of an assignment. */\n /**\n * Warns when code changes a reactive value in place, such as\n * `todos.push(todo)` or `todo.done = true`. The value does not change, so\n * nothing that reads it updates.\n */\n private checkMutation(target: oxc.Node, at: oxc.Node): void {\n // Writing a variable itself is how values change. Only writes into the value are in place.\n if (at.type !== 'CallExpression' && target.type !== 'MemberExpression') {\n return;\n }\n let object = target;\n while (object.type === 'MemberExpression') {\n object = object.object;\n }\n if (object.type !== 'Identifier' || this.isLocal(object.name)) {\n return;\n }\n const declaration = lookup(this.site.scope, object.name);\n if (!declaration || !REACTIVE.has(declaration.kind)) {\n return;\n }\n this.analyzer.report(\n 'warning',\n `This changes the value of ${object.name} in place, so nothing that reads it updates. Write a new value, such as with $produce(${object.name}, (draft) => { … })`,\n at,\n );\n }\n\n private visitTarget(target: oxc.Node, mode: 'write' | 'update'): void {\n switch (target.type) {\n case 'Identifier':\n this.reference(target, mode);\n break;\n case 'ObjectPattern':\n for (const property of target.properties) {\n if (property.type === 'RestElement') {\n this.visitTarget(property.argument, 'write');\n } else {\n if (property.computed) {\n this.visit(property.key);\n }\n this.visitTarget(property.value, 'write');\n }\n }\n break;\n case 'ArrayPattern':\n for (const element of target.elements) {\n if (element) {\n this.visitTarget(element, 'write');\n }\n }\n break;\n case 'AssignmentPattern':\n this.visitTarget(target.left, 'write');\n this.visit(target.right);\n break;\n case 'RestElement':\n this.visitTarget(target.argument, 'write');\n break;\n default:\n if (TYPE_WRAPPERS.has(target.type)) {\n this.visitTarget((target as { expression: oxc.Node }).expression, mode);\n } else {\n this.visit(target);\n }\n }\n }\n}\n\n/** Returns the names that statements declare in their own block. */\nfunction lexicalNames(statements: oxc.Node[]): string[] {\n const names: string[] = [];\n for (const statement of statements) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n names.push(...getPatternNames(declarator.id).map((name) => name.name));\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n names.push(statement.id.name);\n }\n }\n return names;\n}\n\n/** Returns the names of `var` declarations in a function body, outside nested functions. */\nfunction varNames(node: oxc.Node, names: string[] = []): string[] {\n for (const [, child] of children(node)) {\n if (isFunction(child)) {\n continue;\n }\n if (child.type === 'VariableDeclaration' && child.kind === 'var') {\n for (const declarator of child.declarations) {\n names.push(...getPatternNames(declarator.id).map((name) => name.name));\n }\n }\n varNames(child, names);\n }\n return names;\n}\n\n/**\n * The names that code reads and does not declare itself, such as what a\n * function reads from around it. Property names are not reads.\n */\nfunction freeNames(node: oxc.Node): Set<string> {\n const free = new Set<string>();\n const visit = (current: oxc.Node, bound: Set<string>): void => {\n if (isFunction(current)) {\n const inner = new Set(bound);\n for (const param of current.params) {\n for (const name of getPatternNames(param)) {\n inner.add(name.name);\n }\n }\n if (current.type === 'FunctionExpression' && current.id) {\n inner.add(current.id.name);\n }\n const body = current.body;\n if (body?.type === 'BlockStatement') {\n for (const name of [...lexicalNames(body.body), ...varNames(body)]) {\n inner.add(name);\n }\n }\n for (const param of current.params) {\n visit(param, inner);\n }\n if (body) {\n visit(body, inner);\n }\n return;\n }\n if (current.type === 'Identifier') {\n if (!bound.has(current.name)) {\n free.add(current.name);\n }\n return;\n }\n if (current.type === 'MemberExpression' && !current.computed) {\n visit(current.object, bound);\n return;\n }\n if (current.type === 'Property' && !current.computed) {\n visit(current.value, bound);\n return;\n }\n for (const [, child] of children(current)) {\n visit(child, bound);\n }\n };\n visit(node, new Set());\n return free;\n}\n","export interface Location {\n /** 1-based. */\n line: number;\n /** 1-based. */\n column: number;\n}\n\nexport function getLocation(source: string, offset: number): Location {\n let line = 1;\n let lineStart = 0;\n for (let i = 0; i < offset && i < source.length; i++) {\n if (source[i] === '\\n') {\n line++;\n lineStart = i + 1;\n }\n }\n return { line, column: offset - lineStart + 1 };\n}\n\n/**\n * The lines around an offset, with line numbers and a caret under the\n * column, as Vite shows in its error overlay.\n */\nexport function codeFrame(source: string, offset: number): string {\n const { line, column } = getLocation(source, offset);\n const lines = source.split('\\n');\n const first = Math.max(1, line - 2);\n const last = Math.min(lines.length, line + 2);\n const width = String(last).length;\n const result: string[] = [];\n for (let number = first; number <= last; number++) {\n const marker = number === line ? '>' : ' ';\n result.push(`${marker} ${String(number).padStart(width)} | ${lines[number - 1]}`);\n if (number === line) {\n result.push(` ${' '.repeat(width)} | ${' '.repeat(column - 1)}^`);\n }\n }\n return result.join('\\n');\n}\n\n/** A syntax error. Parsing stops at the first one. */\nexport class BrumateError extends Error {\n readonly filename: string;\n readonly offset: number;\n readonly location: Location;\n /** The lines around the error. */\n readonly frame: string;\n\n constructor(message: string, source: string, offset: number, filename: string) {\n const location = getLocation(source, offset);\n super(`${message} (${filename}:${location.line}:${location.column})`);\n this.name = 'BrumateError';\n this.filename = filename;\n this.offset = offset;\n this.location = location;\n this.frame = codeFrame(source, offset);\n }\n}\n\n/** Throws a syntax error at an offset of the file. */\nexport type Fail = (message: string, offset: number) => never;\n\nexport function createFail(source: string, filename: string): Fail {\n return (message, offset) => {\n throw new BrumateError(message, source, offset, filename);\n };\n}\n","import type { oxc } from './oxc.ts';\nimport type { Block } from './ast.ts';\nimport { isWithin, lookup } from './model.ts';\nimport type {\n Declaration,\n DeclarationKind,\n Diagnostic,\n Scope,\n SemanticModel,\n Site,\n} from './model.ts';\n\nexport type GraphNode =\n | { kind: 'source'; declaration: Declaration }\n | { kind: 'memo'; declaration: Declaration; site: Site }\n | { kind: 'binding'; site: Site }\n | { kind: 'block'; site: Site; block: Block }\n | { kind: 'effect'; site: Site };\n\nexport interface Edge {\n from: GraphNode;\n to: GraphNode;\n}\n\nexport interface Graph {\n model: SemanticModel;\n nodes: GraphNode[];\n edges: Edge[];\n /** Nodes whose value can change on the client. */\n live: Set<GraphNode>;\n /** Sites whose code can run on the client. */\n reached: Set<Site>;\n /** Body and template scopes that the client may create. */\n created: Set<Scope>;\n diagnostics: Diagnostic[];\n}\n\n/** Memos that a server function refreshes are live, so they have client code. */\nfunction isMemoKind(kind: DeclarationKind): boolean {\n return kind === 'memo' || kind === 'async-memo';\n}\n\nconst SOURCE_KINDS = new Set<DeclarationKind>([\n 'context',\n 'signal',\n 'action',\n 'prop',\n 'props-rest',\n 'item',\n 'index',\n 'error',\n 'template-param',\n]);\n\nexport interface GraphOptions {\n /**\n * The props that a parent can change on the client. `*` means every prop.\n * Without it, every prop can change, as when a file is compiled alone.\n */\n liveProps?: Set<string>;\n}\n\n/** True if a prop or the rest of the props can change on the client. */\nfunction isLiveProp(declaration: Declaration, liveProps: Set<string> | undefined): boolean {\n if (!liveProps || liveProps.has('*')) {\n return true;\n }\n if (declaration.kind === 'props-rest') {\n // The rest changes when a prop that is not destructured by name changes.\n const named = new Set(\n [...declaration.scope.declarations.values()].flatMap((item) =>\n item.propKey ? [item.propKey] : [],\n ),\n );\n return [...liveProps].some((key) => !named.has(key));\n }\n if (declaration.propKey === undefined) {\n // The props object, or a computed key.\n return liveProps.size > 0;\n }\n return liveProps.has(declaration.propKey);\n}\n\n/** True if client code reads the `reset` function of a `#try` block. */\nexport function resetUsed(model: SemanticModel, block: Block, reached: Set<Site>): boolean {\n return model.declarations.some(\n (declaration) =>\n declaration.kind === 'reset' &&\n declaration.block === block &&\n declaration.reads.some((read) => reached.has(read.site)),\n );\n}\n\n/** Sites whose code runs in the browser after the page renders, and can throw there. */\nconst CLIENT_CODE = new Set(['event', 'effect', 'client']);\n\n/**\n * True if the body of a `#try` holds code that runs in the browser: a\n * handler, an effect, a `$client` callback or a memo that loads. An error\n * in it renders the `#catch` body in the browser, so both bodies ship.\n */\nexport function tryCatchesClient(model: SemanticModel, block: Block & { kind: 'try' }): boolean {\n const body = model.scopes.find((scope) => scope.block === block && scope.body === block.body);\n return (\n body !== undefined &&\n model.sites.some(\n (site) =>\n (CLIENT_CODE.has(site.kind) ||\n (site.kind === 'memo' && site.declaration?.kind === 'async-memo')) &&\n isWithin(site.scope, body),\n )\n );\n}\n\n/** True if a site's expression is a function, such as a function passed as a prop. */\n/** True for a site whose value is a `#template`, such as the prop `item=option`. */\nexport function isTemplateValue(site: Site): boolean {\n return site.node.type === 'Identifier' && lookup(site.scope, site.node.name)?.kind === 'template';\n}\n\nexport function isFunctionValue(site: Site): boolean {\n let node: oxc.Node = site.node;\n // A wrapper of `brumate/events`, such as `prevent(save)`, returns the handler that it wraps.\n for (;;) {\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n if (\n node.type !== 'CallExpression' ||\n node.callee.type !== 'Identifier' ||\n lookup(site.scope, node.callee.name)?.imported?.source !== 'brumate/events' ||\n !node.arguments[0]\n ) {\n break;\n }\n node = node.arguments[0];\n }\n if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') {\n return true;\n }\n if (node.type === 'Identifier') {\n const kind = lookup(site.scope, node.name)?.kind;\n // A template passed as a prop renders in the browser too, such as in a list that changes.\n return kind === 'function' || kind === 'server-function' || kind === 'template';\n }\n return false;\n}\n\nexport function buildGraph(model: SemanticModel, options: GraphOptions = {}): Graph {\n const nodes: GraphNode[] = [];\n const edges: Edge[] = [];\n const declarationNodes = new Map<Declaration, GraphNode>();\n const siteNodes = new Map<Site, GraphNode>();\n const incoming = new Map<GraphNode, GraphNode[]>();\n const diagnostics: Diagnostic[] = [];\n\n const addNode = (node: GraphNode): GraphNode => {\n nodes.push(node);\n incoming.set(node, []);\n return node;\n };\n const addEdge = (from: GraphNode, to: GraphNode): void => {\n if (!incoming.get(to)!.includes(from)) {\n edges.push({ from, to });\n incoming.get(to)!.push(from);\n }\n };\n\n for (const declaration of model.declarations) {\n if (SOURCE_KINDS.has(declaration.kind)) {\n declarationNodes.set(declaration, addNode({ kind: 'source', declaration }));\n }\n }\n for (const site of model.sites) {\n let node: GraphNode | undefined;\n switch (site.kind) {\n case 'memo':\n node = addNode({ kind: 'memo', declaration: site.declaration!, site });\n declarationNodes.set(site.declaration!, node);\n break;\n case 'insert':\n case 'attribute':\n case 'prop':\n case 'tag':\n case 'spread':\n case 'style':\n case 'provide':\n case 'title':\n node = addNode({ kind: 'binding', site });\n break;\n case 'block':\n node = addNode({ kind: 'block', site, block: site.block! });\n break;\n case 'effect':\n node = addNode({ kind: 'effect', site });\n break;\n default:\n break;\n }\n if (node) {\n siteNodes.set(site, node);\n }\n }\n\n // The values that a site depends on, through the functions it calls.\n const dependencies = (site: Site, seen = new Set<Site>()): Declaration[] => {\n if (seen.has(site)) {\n return [];\n }\n seen.add(site);\n const result: Declaration[] = [];\n for (const read of site.reads) {\n if (read.tracked && declarationNodes.has(read.declaration)) {\n result.push(read.declaration);\n }\n }\n // A call inside `$untrack` reads its values without depending on them.\n for (const callee of site.trackedCalls) {\n if (callee.kind === 'function' && callee.site) {\n result.push(...dependencies(callee.site, seen));\n }\n }\n return result;\n };\n\n for (const [site, node] of siteNodes) {\n // A function prop is a fixed reference to a handler, which reads current values when it runs.\n if (site.kind === 'prop' && isFunctionValue(site)) {\n continue;\n }\n for (const declaration of dependencies(site)) {\n addEdge(declarationNodes.get(declaration)!, node);\n }\n }\n // Loop variables change with the list.\n for (const [site, node] of siteNodes) {\n const block = site.block;\n if (site.kind !== 'block' || !block || (block.kind !== 'for' && block.kind !== 'repeat')) {\n continue;\n }\n if (site.label === 'for key') {\n continue;\n }\n for (const declaration of model.declarations) {\n if (\n declaration.block === block &&\n (declaration.kind === 'item' || declaration.kind === 'index')\n ) {\n addEdge(node, declarationNodes.get(declaration)!);\n }\n }\n }\n\n const headers = new Map<Block, GraphNode[]>();\n for (const [site, node] of siteNodes) {\n if (site.kind === 'block' && site.block && site.label !== 'for key') {\n const list = headers.get(site.block) ?? [];\n list.push(node);\n headers.set(site.block, list);\n }\n }\n\n const live = new Set<GraphNode>();\n const reached = new Set<Site>();\n const created = new Set<Scope>();\n\n const reach = (site: Site): void => {\n if (reached.has(site)) {\n return;\n }\n reached.add(site);\n for (const callee of site.calls) {\n if (callee.site) {\n reach(callee.site);\n }\n }\n };\n\n for (let changed = true; changed;) {\n changed = false;\n const before = live.size + reached.size + created.size;\n\n // Scopes that the client creates.\n for (const scope of model.scopes) {\n if (created.has(scope)) {\n continue;\n }\n const block = scope.block;\n const parentCreated = scope.parent !== undefined && created.has(scope.parent);\n const blockLive =\n scope.kind === 'body' &&\n block !== undefined &&\n // The client renders the body of a `#client` block. The server renders its fallback.\n ((block.kind === 'client' && scope.body === block.body) ||\n // A portal into a target renders on the client, where the target is.\n (block.kind === 'portal' && block.target !== undefined) ||\n // Client code can call `reset` to render a `#try` body again, and an error in the\n // client code of the body renders the `#catch` body.\n (block.kind === 'try' &&\n (resetUsed(model, block, reached) || tryCatchesClient(model, block))) ||\n (headers.get(block) ?? []).some((node) => live.has(node)) ||\n (block.kind === 'try' && scope.body === block.fallback && tryChanges(block)));\n const templateUsed = scope.kind === 'template' && templateCallChanges(scope);\n if (parentCreated || blockLive || templateUsed) {\n created.add(scope);\n }\n }\n\n // Code that runs on the client.\n for (const site of model.sites) {\n const isRoot =\n site.kind === 'event' ||\n site.kind === 'client' ||\n (site.kind === 'prop' && isFunctionValue(site)) ||\n (site.kind === 'effect' && live.has(siteNodes.get(site)!)) ||\n created.has(site.scope);\n if (isRoot) {\n reach(site);\n }\n }\n\n // Values that change on the client.\n for (const [declaration, node] of declarationNodes) {\n if (live.has(node)) {\n continue;\n }\n const isLive =\n ((declaration.kind === 'prop' || declaration.kind === 'props-rest') &&\n isLiveProp(declaration, options.liveProps)) ||\n // A provider above can change the value.\n declaration.kind === 'context' ||\n // A form writes the result of its server function.\n declaration.kind === 'action' ||\n // A server function can ask the client to load the memo again.\n (isMemoKind(declaration.kind) &&\n [...(declaration.site?.calls ?? [])].some((callee) => callee.refreshed)) ||\n // Handlers write an optimistic value.\n (declaration.optimistic !== undefined &&\n declaration.writes.some((write) => reached.has(write.site))) ||\n (declaration.kind === 'signal' &&\n (declaration.writes.some((write) => reached.has(write.site)) ||\n declaration.refs.some((ref) => created.has(ref.scope)))) ||\n (declaration.kind === 'error' &&\n declaration.block?.kind === 'try' &&\n tryChanges(declaration.block)) ||\n // A child or an element writes it through `$bind`.\n declaration.bound === true ||\n (declaration.kind === 'template-param' && templateCallChanges(declaration.scope));\n if (isLive) {\n live.add(node);\n }\n }\n for (let propagated = true; propagated;) {\n propagated = false;\n for (const node of nodes) {\n if (!live.has(node) && incoming.get(node)!.some((from) => live.has(from))) {\n live.add(node);\n propagated = true;\n }\n }\n }\n\n if (live.size + reached.size + created.size !== before) {\n changed = true;\n }\n }\n\n // A template's arguments change when a call to it changes or runs on the client.\n function templateCallChanges(scope: Scope): boolean {\n const template = scope.template && lookup(scope.parent!, scope.template.name);\n return model.sites.some((site) => {\n if (!template || !site.calls.has(template)) {\n return false;\n }\n const node = siteNodes.get(site);\n return reached.has(site) || (node !== undefined && live.has(node));\n });\n }\n\n // A #try can fail on the client only if its body changes there.\n function tryChanges(block: Block & { kind: 'try' }): boolean {\n const body = model.scopes.find((scope) => scope.block === block && scope.body === block.body);\n if (!body) {\n return false;\n }\n for (const [site, node] of siteNodes) {\n if (live.has(node) && isWithin(site.scope, body)) {\n return true;\n }\n }\n return model.scopes.some((scope) => created.has(scope) && isWithin(scope, body));\n }\n\n for (const [site, node] of siteNodes) {\n if (site.kind === 'effect' && !live.has(node)) {\n diagnostics.push({\n severity: 'warning',\n message: 'This $effect reads no value that changes on the client, so it never runs',\n range: site.range,\n });\n }\n }\n\n // The server renders a `#defer` body again in a request of its own, with the rest of the page,\n // so the block must be in markup that the server renders. The browser renders `#client` bodies.\n for (const scope of model.scopes) {\n const block = scope.block;\n if (block?.kind !== 'defer' || scope.body !== block.body) {\n continue;\n }\n let message: string | undefined;\n for (let outer = scope.parent; outer && !message; outer = outer.parent) {\n const around = outer.block;\n if (around?.kind === 'client' && outer.body === around.body) {\n message = '#defer cannot be inside a #client body';\n } else if (created.has(outer)) {\n message = '#defer cannot be in markup that the browser renders';\n }\n }\n if (message) {\n diagnostics.push({\n severity: 'error',\n message,\n range: { start: block.start, end: block.start + '#defer'.length },\n });\n }\n }\n\n return { model, nodes, edges, live, reached, created, diagnostics };\n}\n","import type { Fail } from './error.ts';\n\nexport function isWhitespace(char: string | undefined): boolean {\n return char === ' ' || char === '\\t' || char === '\\n' || char === '\\r' || char === '\\f';\n}\n\nexport function isIdentifierStart(char: string | undefined): boolean {\n if (char === undefined) {\n return false;\n }\n return /[A-Za-z_$]/.test(char) || char.charCodeAt(0) > 127;\n}\n\nexport function isIdentifierPart(char: string | undefined): boolean {\n if (char === undefined) {\n return false;\n }\n return /[\\w$]/.test(char) || char.charCodeAt(0) > 127;\n}\n\n/** Reads an identifier at `start`. Returns an empty string if there is none. */\nexport function readIdentifier(source: string, start: number): string {\n if (!isIdentifierStart(source[start])) {\n return '';\n }\n let end = start + 1;\n while (isIdentifierPart(source[end])) {\n end++;\n }\n return source.slice(start, end);\n}\n\nconst CLOSERS: Record<string, string> = { '(': ')', '[': ']', '{': '}' };\n\n// Keywords after which a `/` starts a regular expression, not a division.\nconst REGEXP_KEYWORDS = new Set([\n 'return',\n 'typeof',\n 'instanceof',\n 'in',\n 'of',\n 'new',\n 'delete',\n 'void',\n 'throw',\n 'case',\n 'do',\n 'else',\n 'yield',\n 'await',\n]);\n\n/** Returns the offset after the quote that closes the string at `start`. */\nexport function skipString(source: string, start: number, fail: Fail): number {\n const quote = source[start];\n let i = start + 1;\n while (i < source.length) {\n const char = source[i];\n if (char === '\\\\') {\n i += 2;\n } else if (char === quote) {\n return i + 1;\n } else if (char === '\\n') {\n break;\n } else {\n i++;\n }\n }\n return fail('Unterminated string', start);\n}\n\n/** Returns the offset after the backtick that closes the template literal at `start`. */\nexport function skipTemplate(source: string, start: number, fail: Fail): number {\n let i = start + 1;\n while (i < source.length) {\n const char = source[i];\n if (char === '\\\\') {\n i += 2;\n } else if (char === '`') {\n return i + 1;\n } else if (char === '$' && source[i + 1] === '{') {\n i = skipBalanced(source, i + 1, fail);\n } else {\n i++;\n }\n }\n return fail('Unterminated template literal', start);\n}\n\n/** Returns the offset after the flags of the regular expression at `start`. */\nexport function skipRegExp(source: string, start: number, fail: Fail): number {\n let i = start + 1;\n let inClass = false;\n while (i < source.length) {\n const char = source[i];\n if (char === '\\\\') {\n i += 2;\n continue;\n }\n if (char === '\\n') {\n break;\n }\n if (char === '[') {\n inClass = true;\n } else if (char === ']') {\n inClass = false;\n } else if (char === '/' && !inClass) {\n i++;\n while (isIdentifierPart(source[i])) {\n i++;\n }\n return i;\n }\n i++;\n }\n return fail('Unterminated regular expression', start);\n}\n\n/**\n * Returns the offset after a comment at `start`, or `start` if there is no\n * comment there.\n */\nexport function skipComment(source: string, start: number, fail: Fail): number {\n if (source[start] !== '/') {\n return start;\n }\n if (source[start + 1] === '/') {\n const end = source.indexOf('\\n', start);\n return end === -1 ? source.length : end;\n }\n if (source[start + 1] === '*') {\n const end = source.indexOf('*/', start + 2);\n if (end === -1) {\n fail('Unterminated comment', start);\n }\n return end + 2;\n }\n return start;\n}\n\n/**\n * Returns the offset after the bracket that closes the one at `start`. Skips\n * strings, template literals, regular expressions and comments.\n */\nexport function skipBalanced(source: string, start: number, fail: Fail): number {\n const stack: string[] = [];\n let i = start;\n let regExpAllowed = true;\n while (i < source.length) {\n const char = source[i];\n if (char === '\"' || char === \"'\") {\n i = skipString(source, i, fail);\n regExpAllowed = false;\n } else if (char === '`') {\n i = skipTemplate(source, i, fail);\n regExpAllowed = false;\n } else if (char === '/') {\n const end = skipComment(source, i, fail);\n if (end !== i) {\n i = end;\n } else if (regExpAllowed) {\n i = skipRegExp(source, i, fail);\n regExpAllowed = false;\n } else {\n i++;\n regExpAllowed = true;\n }\n } else if (char in CLOSERS) {\n stack.push(CLOSERS[char]);\n i++;\n regExpAllowed = true;\n } else if (char === ')' || char === ']' || char === '}') {\n if (stack.pop() !== char) {\n fail(`Unexpected \"${char}\"`, i);\n }\n i++;\n if (stack.length === 0) {\n return i;\n }\n regExpAllowed = char === '}';\n } else if (isIdentifierPart(char)) {\n let end = i + 1;\n while (isIdentifierPart(source[end])) {\n end++;\n }\n regExpAllowed = REGEXP_KEYWORDS.has(source.slice(i, end));\n i = end;\n } else if (isWhitespace(char)) {\n i++;\n } else {\n regExpAllowed = true;\n i++;\n }\n }\n return fail(`Expected \"${stack.at(-1) ?? ''}\"`, start);\n}\n\n/**\n * Finds `word` in `code` outside brackets, strings and comments. Returns its\n * offset, or -1.\n */\nexport function findTopLevel(code: string, word: string, fail: Fail): number {\n let i = 0;\n while (i < code.length) {\n const char = code[i];\n if (char === '\"' || char === \"'\") {\n i = skipString(code, i, fail);\n } else if (char === '`') {\n i = skipTemplate(code, i, fail);\n } else if (char === '/' && skipComment(code, i, fail) !== i) {\n i = skipComment(code, i, fail);\n } else if (char in CLOSERS) {\n i = skipBalanced(code, i, fail);\n } else if (code.startsWith(word, i)) {\n const isWord = isIdentifierPart(word[0]);\n if (!isWord || (!isIdentifierPart(code[i - 1]) && !isIdentifierPart(code[i + word.length]))) {\n return i;\n }\n i += word.length;\n } else if (isIdentifierPart(char)) {\n while (isIdentifierPart(code[i])) {\n i++;\n }\n } else {\n i++;\n }\n }\n return -1;\n}\n","import type {\n Attribute,\n Block,\n Body,\n Branch,\n ClientTrigger,\n DynamicTagNode,\n EventAttribute,\n Expression,\n FragmentNode,\n KeyBlock,\n Markup,\n Modifier,\n PrefetchStrategy,\n Reveal,\n RevealOrder,\n SFCFile,\n Script,\n Style,\n TemplateDecl,\n} from './ast.ts';\nimport { createFail } from './error.ts';\nimport type { Fail } from './error.ts';\nimport { parseExpression, parseParameters, parsePattern, parseScript } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\nimport {\n findTopLevel,\n isIdentifierPart,\n isIdentifierStart,\n isWhitespace,\n readIdentifier,\n skipBalanced,\n skipComment,\n skipRegExp,\n skipString,\n skipTemplate,\n} from './scan.ts';\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nconst BLOCK_KEYWORDS = new Set([\n 'if',\n 'for',\n 'repeat',\n 'switch',\n 'key',\n 'try',\n 'loading',\n 'portal',\n 'head',\n 'client',\n 'offscreen',\n 'reveal',\n // Reserved for a future block, so it is an error and not text.\n 'defer',\n 'template',\n]);\n\nconst BRANCH_KEYWORDS = new Set(['else', 'catch', 'case', 'default']);\n\nconst MODIFIERS = new Set<string>(['prevent', 'stop', 'passive', 'once', 'capture']);\n\nconst PREFETCH_STRATEGIES = new Set<string>(['hover', 'visible', 'idle', 'none']);\n\nconst CLIENT_TRIGGERS = new Set<string>(['visible', 'idle', 'load']);\n\ntype Mode = 'file' | 'body' | 'element';\n\nexport interface ParseOptions {\n /** Used for error messages. */\n filename?: string;\n}\n\nexport function parse(source: string, options: ParseOptions = {}): SFCFile {\n return new Parser(source, options.filename ?? 'Component.brm').parseFile();\n}\n\nclass Parser {\n private pos = 0;\n private readonly source: string;\n private readonly fail: Fail;\n private readonly file: SFCFile;\n\n constructor(source: string, filename: string) {\n this.source = source;\n this.fail = createFail(source, filename);\n this.file = { filename, source, styles: [], templates: [], children: [] };\n }\n\n parseFile(): SFCFile {\n this.file.children = this.parseNodes('file', this.file.templates);\n return this.file;\n }\n\n // Helpers\n\n private startsWith(text: string): boolean {\n return this.source.startsWith(text, this.pos);\n }\n\n private peek(): string | undefined {\n return this.source[this.pos];\n }\n\n private skipWhitespace(): boolean {\n const start = this.pos;\n while (isWhitespace(this.peek())) {\n this.pos++;\n }\n return this.pos > start;\n }\n\n /** Skips whitespace and HTML comments. */\n private skipTrivia(): void {\n for (;;) {\n this.skipWhitespace();\n if (!this.startsWith('<!--')) {\n return;\n }\n this.skipHTMLComment();\n }\n }\n\n private skipHTMLComment(): void {\n const end = this.source.indexOf('-->', this.pos + 4);\n if (end === -1) {\n this.fail('Unterminated comment', this.pos);\n }\n this.pos = end + 3;\n }\n\n private expect(text: string, message = `Expected \"${text}\"`): void {\n if (!this.startsWith(text)) {\n this.fail(message, this.pos);\n }\n this.pos += text.length;\n }\n\n /** Parses the code between `start` and `end` as an expression. */\n private expression(start: number, end: number): Expression {\n const code = this.source.slice(start, end);\n return { start, end, code, ast: parseExpression(code, start, this.fail) };\n }\n\n /** Reads a bracketed region at the current position. Returns the range inside the brackets. */\n private bracketed(): { start: number; end: number } {\n const open = this.pos;\n this.pos = skipBalanced(this.source, open, this.fail);\n return { start: open + 1, end: this.pos - 1 };\n }\n\n private isTagStart(name: string): boolean {\n const next = this.source[this.pos + name.length + 1];\n return this.startsWith(`<${name}`) && (isWhitespace(next) || next === '>' || next === '/');\n }\n\n /** Returns the keyword of a block that starts at the current position. */\n private blockKeyword(keywords: Set<string>): string | undefined {\n if (this.peek() !== '#' || isIdentifierPart(this.source[this.pos - 1])) {\n return undefined;\n }\n const match = /^[a-z]+/.exec(this.source.slice(this.pos + 1, this.pos + 20));\n if (!match || !keywords.has(match[0])) {\n return undefined;\n }\n const keyword = match[0];\n let next = this.pos + 1 + keyword.length;\n if (keyword === 'template') {\n if (!isWhitespace(this.source[next])) {\n return undefined;\n }\n while (isWhitespace(this.source[next])) {\n next++;\n }\n return isIdentifierStart(this.source[next]) ? keyword : undefined;\n }\n while (isWhitespace(this.source[next])) {\n next++;\n }\n const after = this.source[next];\n if (after === '(' || after === '{') {\n return keyword;\n }\n // `#else if` has a keyword after `#else`.\n if (keyword === 'else' && this.source.startsWith('if', next)) {\n return keyword;\n }\n return undefined;\n }\n\n // Nodes\n\n private parseNodes(mode: Mode, templates?: TemplateDecl[]): Markup[] {\n const nodes: Markup[] = [];\n for (;;) {\n if (this.pos >= this.source.length) {\n if (mode !== 'file') {\n this.fail(\n mode === 'body'\n ? 'Expected \"}\" to close the block'\n : 'Unexpected end of file, expected a closing tag',\n this.pos,\n );\n }\n return nodes;\n }\n if (mode === 'body' && this.peek() === '}') {\n return nodes;\n }\n if (this.startsWith('</')) {\n if (mode === 'element') {\n return nodes;\n }\n this.fail('Unexpected closing tag', this.pos);\n }\n if (this.startsWith('<!--')) {\n this.skipHTMLComment();\n continue;\n }\n if (this.isTagStart('script')) {\n if (mode !== 'file') {\n this.fail('<script> must be at the top level or at the start of a block', this.pos);\n }\n this.parseTopLevelScript();\n continue;\n }\n if (this.isTagStart('style')) {\n if (mode !== 'file') {\n this.fail('<style> must be at the top level', this.pos);\n }\n this.file.styles.push(this.parseStyle());\n continue;\n }\n if (this.peek() === '<') {\n nodes.push(this.parseTag());\n continue;\n }\n if (this.peek() === '{') {\n const start = this.pos;\n const inner = this.bracketed();\n nodes.push({\n kind: 'insert',\n start,\n end: this.pos,\n expression: this.expression(inner.start, inner.end),\n });\n continue;\n }\n const keyword = this.blockKeyword(BLOCK_KEYWORDS);\n if (keyword === 'template') {\n if (!templates) {\n this.fail('#template must be at the top level or at the start of a block', this.pos);\n }\n templates.push(this.parseTemplate());\n continue;\n }\n if (keyword) {\n nodes.push(this.parseBlock(keyword));\n continue;\n }\n const branch = this.blockKeyword(BRANCH_KEYWORDS);\n if (branch) {\n this.fail(`#${branch} must follow its block`, this.pos);\n }\n this.parseText(nodes, mode);\n }\n }\n\n private parseText(nodes: Markup[], mode: Mode): void {\n const start = this.pos;\n this.pos++;\n while (this.pos < this.source.length) {\n const char = this.peek();\n if (char === '<' || char === '{' || (char === '}' && mode === 'body')) {\n break;\n }\n if (\n char === '#' &&\n (this.blockKeyword(BLOCK_KEYWORDS) || this.blockKeyword(BRANCH_KEYWORDS))\n ) {\n break;\n }\n this.pos++;\n }\n const value = this.source.slice(start, this.pos);\n // As in JSX, text that is only whitespace across lines is dropped.\n if (value.trim() === '' && value.includes('\\n')) {\n return;\n }\n nodes.push({ kind: 'text', start, end: this.pos, value });\n }\n\n private parseTag(): Markup {\n const start = this.pos;\n if (this.startsWith('<>')) {\n this.pos += 2;\n const children = this.parseNodes('element');\n this.expect('</>');\n return { kind: 'fragment', start, end: this.pos, children };\n }\n if (this.startsWith('<{')) {\n this.pos++;\n const inner = this.bracketed();\n const tag = this.expression(inner.start, inner.end);\n const attributes = this.parseAttributes('dynamic');\n let children: Markup[] = [];\n if (this.startsWith('/>')) {\n this.pos += 2;\n } else {\n this.pos++;\n children = this.parseNodes('element');\n this.expect('</>');\n }\n const node: DynamicTagNode = {\n kind: 'dynamic',\n start,\n end: this.pos,\n tag,\n attributes,\n children,\n keyed: true,\n };\n // A new tag is a new element or component, so the tag is the key of a block around it.\n const block: KeyBlock = {\n kind: 'key',\n start,\n end: this.pos,\n value: this.expression(inner.start, inner.end),\n body: { start, end: this.pos, templates: [], children: [node] },\n };\n return block;\n }\n this.pos++;\n const match = /^[A-Za-z][\\w.:-]*/.exec(this.source.slice(this.pos, this.pos + 200));\n if (!match) {\n return this.fail('Expected a tag name', this.pos);\n }\n const name = match[0];\n this.pos += name.length;\n\n if (name === 'window' || name === 'document') {\n const attributes = this.parseAttributes('listener');\n if (!this.startsWith('/>')) {\n this.fail(`<${name}> must end with \"/>\"`, this.pos);\n }\n this.pos += 2;\n return {\n kind: 'listener',\n start,\n end: this.pos,\n target: name,\n attributes: attributes as EventAttribute[],\n };\n }\n\n const isComponent = /^[A-Z]/.test(name);\n const attributes = this.parseAttributes(isComponent ? 'component' : 'element');\n let children: Markup[] = [];\n if (this.startsWith('/>')) {\n this.pos += 2;\n } else {\n this.pos++;\n if (isComponent || !VOID_ELEMENTS.has(name)) {\n children = this.parseNodes('element');\n const close = `</${name}`;\n if (!this.startsWith(close)) {\n this.fail(`Expected </${name}>`, this.pos);\n }\n this.pos += close.length;\n this.skipWhitespace();\n this.expect('>', `Expected </${name}>`);\n }\n }\n if (isComponent) {\n return { kind: 'component', start, end: this.pos, name, attributes, children };\n }\n return { kind: 'element', start, end: this.pos, tag: name, attributes, children };\n }\n\n // Attributes\n\n private parseAttributes(owner: 'element' | 'component' | 'dynamic' | 'listener'): Attribute[] {\n const attributes: Attribute[] = [];\n for (;;) {\n const separated = this.skipWhitespace();\n if (this.pos >= this.source.length) {\n this.fail('Unexpected end of file, expected \">\"', this.pos);\n }\n if (this.peek() === '>' || this.startsWith('/>')) {\n return attributes;\n }\n if (!separated) {\n this.fail('Expected whitespace between attributes', this.pos);\n }\n const attribute = this.parseAttribute(owner);\n if (owner === 'listener' && attribute.kind !== 'event') {\n this.fail('Only event handlers are allowed here', attribute.start);\n }\n attributes.push(attribute);\n }\n }\n\n private parseAttribute(owner: 'element' | 'component' | 'dynamic' | 'listener'): Attribute {\n const start = this.pos;\n if (this.peek() === '{') {\n const inner = this.bracketed();\n const code = this.source.slice(inner.start, inner.end);\n if (code.startsWith('...')) {\n return {\n kind: 'spread',\n start,\n end: this.pos,\n value: this.expression(inner.start + 3, inner.end),\n };\n }\n const name = code.trim();\n if (readIdentifier(name, 0) !== name) {\n this.fail('Expected a spread or a shorthand attribute', start);\n }\n return {\n kind: 'value',\n start,\n end: this.pos,\n name,\n value: this.expression(inner.start, inner.end),\n };\n }\n if (this.peek() === '[') {\n const inner = this.bracketed();\n const name = this.expression(inner.start, inner.end);\n let value: Expression | true = true;\n if (this.peek() === '=') {\n this.pos++;\n const parsed = this.parseValue();\n value = typeof parsed === 'string' ? this.stringExpression(parsed) : parsed;\n }\n return { kind: 'computed', start, end: this.pos, name, value };\n }\n\n const match = /^[A-Za-z_][\\w-]*(?::[\\w-]+)*/.exec(this.source.slice(this.pos, this.pos + 200));\n if (!match) {\n return this.fail('Expected an attribute name', this.pos);\n }\n const fullName = match[0];\n this.pos += fullName.length;\n const parts = fullName.split(':');\n\n if (/^on[A-Z]/.test(fullName)) {\n const name = parts[0]!;\n const modifiers = parts.slice(1);\n for (const modifier of modifiers) {\n if (!MODIFIERS.has(modifier)) {\n this.fail(`Unknown event modifier \":${modifier}\"`, start);\n }\n }\n // A component gets the handler as a prop, and nothing would apply the modifiers.\n if (owner === 'component' && modifiers.length > 0) {\n this.fail(\n `Modifiers apply to elements. Put \":${modifiers[0]}\" on the element that the component renders`,\n start,\n );\n }\n if (this.peek() !== '=') {\n this.fail('Expected an event handler', this.pos);\n }\n this.pos++;\n const value = this.parseValue();\n if (typeof value === 'string') {\n return this.fail('An event handler must be an expression, not a string', start);\n }\n return {\n kind: 'event',\n start,\n end: this.pos,\n name,\n event: name.slice(2).toLowerCase(),\n modifiers: modifiers as Modifier[],\n handler: value,\n };\n }\n if (parts.length > 2) {\n this.fail('An attribute name can have one \":\" namespace', start);\n }\n\n if (owner === 'element' && fullName === 'ref') {\n this.expect('=', 'Expected the name of a signal after \"ref=\"');\n const targetStart = this.pos;\n const target = readIdentifier(this.source, this.pos);\n this.pos += target.length;\n if (!target || !(isWhitespace(this.peek()) || this.peek() === '>' || this.peek() === '/')) {\n this.fail('Expected the name of a signal after \"ref=\"', targetStart);\n }\n return {\n kind: 'ref',\n start,\n end: this.pos,\n target,\n targetRange: { start: targetStart, end: this.pos },\n };\n }\n\n if (owner === 'element' && fullName === 'prefetch') {\n this.expect('=', 'Expected a prefetch strategy');\n const value = this.parseValue();\n if (typeof value !== 'string' || !PREFETCH_STRATEGIES.has(value)) {\n this.fail('prefetch must be \"hover\", \"visible\", \"idle\" or \"none\"', start);\n }\n return { kind: 'prefetch', start, end: this.pos, strategy: value as PrefetchStrategy };\n }\n\n if (this.peek() !== '=') {\n return { kind: 'static', start, end: this.pos, name: fullName, value: true };\n }\n this.pos++;\n const value = this.parseValue();\n if (typeof value === 'string') {\n return { kind: 'static', start, end: this.pos, name: fullName, value };\n }\n return { kind: 'value', start, end: this.pos, name: fullName, value };\n }\n\n /** Makes an expression for a string value, such as the value of a computed attribute. */\n private stringExpression(value: string): Expression {\n const start = this.pos - value.length - 2;\n return this.expression(start, this.pos);\n }\n\n /** Parses an attribute value. Returns a string for a quoted value. */\n private parseValue(): string | Expression {\n const start = this.pos;\n const char = this.peek();\n if (char === '\"' || char === \"'\") {\n this.pos = skipString(this.source, start, this.fail);\n return this.source.slice(start + 1, this.pos - 1);\n }\n if (char === '(') {\n const inner = this.bracketed();\n return this.expression(inner.start, inner.end);\n }\n if (char === '{' || char === '[') {\n this.pos = skipBalanced(this.source, start, this.fail);\n return this.expression(start, this.pos);\n }\n if (char === '`') {\n this.pos = skipTemplate(this.source, start, this.fail);\n return this.expression(start, this.pos);\n }\n if (char === '/') {\n this.pos = skipRegExp(this.source, start, this.fail);\n return this.expression(start, this.pos);\n }\n if (char === '<') {\n return this.fail('Markup is not allowed in attribute values. Use a #template.', start);\n }\n\n while (\n this.peek() === '!' ||\n this.peek() === '-' ||\n this.peek() === '+' ||\n this.peek() === '~'\n ) {\n this.pos++;\n }\n const primary = /^(?:[A-Za-z_$][\\w$]*|\\d[\\w.]*|\\.\\d[\\w]*)/.exec(\n this.source.slice(this.pos, this.pos + 200),\n );\n if (!primary) {\n return this.fail('Expected an attribute value', start);\n }\n this.pos += primary[0].length;\n for (;;) {\n if (this.startsWith('?.') && isIdentifierStart(this.source[this.pos + 2])) {\n this.pos += 2;\n this.pos += readIdentifier(this.source, this.pos).length;\n } else if (this.peek() === '.' && isIdentifierStart(this.source[this.pos + 1])) {\n this.pos++;\n this.pos += readIdentifier(this.source, this.pos).length;\n } else if (this.peek() === '(' || this.peek() === '[') {\n this.pos = skipBalanced(this.source, this.pos, this.fail);\n } else if (this.peek() === '!') {\n this.pos++;\n } else {\n break;\n }\n }\n if (\n !(\n this.pos >= this.source.length ||\n isWhitespace(this.peek()) ||\n this.peek() === '>' ||\n this.peek() === '/'\n )\n ) {\n this.fail('Wrap this attribute value in parentheses', start);\n }\n return this.expression(start, this.pos);\n }\n\n // Scripts and styles\n\n /** Reads the attributes of a `<script>` or `<style>` tag. */\n private parseBlockTag(name: string): {\n attributes: Record<string, string | true>;\n contentStart: number;\n } {\n this.pos += name.length + 1;\n const attributes: Record<string, string | true> = {};\n for (;;) {\n this.skipWhitespace();\n if (this.peek() === '>') {\n this.pos++;\n return { attributes, contentStart: this.pos };\n }\n const attribute = /^[A-Za-z][\\w-]*/.exec(this.source.slice(this.pos, this.pos + 100));\n if (!attribute) {\n return this.fail(`Expected \">\" to end <${name}>`, this.pos);\n }\n this.pos += attribute[0].length;\n if (this.peek() === '=') {\n this.pos++;\n const valueStart = this.pos;\n if (this.peek() !== '\"' && this.peek() !== \"'\") {\n this.fail('Expected a quoted value', this.pos);\n }\n this.pos = skipString(this.source, valueStart, this.fail);\n attributes[attribute[0]] = this.source.slice(valueStart + 1, this.pos - 1);\n } else {\n attributes[attribute[0]] = true;\n }\n }\n }\n\n private readBlockContent(name: string, contentStart: number): { contentEnd: number } {\n const close = `</${name}>`;\n const contentEnd = this.source.indexOf(close, contentStart);\n if (contentEnd === -1) {\n this.fail(`Expected ${close}`, contentStart);\n }\n this.pos = contentEnd + close.length;\n return { contentEnd };\n }\n\n private parseScriptBlock(): { script: Script; attributes: Record<string, string | true> } {\n const start = this.pos;\n const { attributes, contentStart } = this.parseBlockTag('script');\n const { contentEnd } = this.readBlockContent('script', contentStart);\n const program = parseScript(\n this.source.slice(contentStart, contentEnd),\n contentStart,\n this.fail,\n );\n return { script: { start, end: this.pos, program }, attributes };\n }\n\n private parseTopLevelScript(): void {\n const start = this.pos;\n const { script, attributes } = this.parseScriptBlock();\n for (const name of Object.keys(attributes)) {\n if (name !== 'module' && name !== 'generics' && name !== 'lang') {\n this.fail(`Unknown <script> attribute \"${name}\"`, start);\n }\n }\n if (attributes.module) {\n if (this.file.moduleScript) {\n this.fail('A file can have one <script module>', start);\n }\n this.file.moduleScript = script;\n return;\n }\n if (this.file.instanceScript) {\n this.fail('A file can have one <script>', start);\n }\n this.file.instanceScript = script;\n if (typeof attributes.generics === 'string') {\n this.file.generics = attributes.generics;\n }\n }\n\n private parseStyle(): Style {\n const start = this.pos;\n const { attributes, contentStart } = this.parseBlockTag('style');\n const { contentEnd } = this.readBlockContent('style', contentStart);\n const lang = attributes.lang ?? 'css';\n if (lang !== 'css' && lang !== 'scss' && lang !== 'less') {\n return this.fail('lang must be \"css\", \"scss\" or \"less\"', start);\n }\n const variables: Expression[] = [];\n let i = contentStart;\n while (i < contentEnd) {\n const end = skipComment(this.source, i, this.fail);\n if (end !== i) {\n i = end;\n } else if (this.source.startsWith('${', i)) {\n const close = skipBalanced(this.source, i + 1, this.fail);\n variables.push(this.expression(i + 2, close - 1));\n i = close;\n } else {\n i++;\n }\n }\n return {\n start,\n end: this.pos,\n lang,\n content: this.source.slice(contentStart, contentEnd),\n variables,\n };\n }\n\n // Blocks\n\n /** Parses `( … )` at the current position, after optional whitespace. */\n /**\n * `#reveal ('sequential', collapsed) { … }`: an order as a string, and\n * `collapsed`, both optional. The body is the children of a fragment.\n */\n private parseReveal(start: number): FragmentNode {\n const header = this.parseHeader('reveal', false);\n const reveal: Reveal = { order: 'sequential', collapsed: false };\n if (header) {\n const code = this.source.slice(header.start, header.end);\n let offset = header.start;\n for (const part of code.split(',')) {\n const word = part.trim();\n const string = /^(['\"])(sequential|backwards|together|natural)\\1$/.exec(word);\n if (string) {\n reveal.order = string[2] as RevealOrder;\n } else if (word === 'collapsed') {\n reveal.collapsed = true;\n } else {\n this.fail(\n \"#reveal takes an order, 'sequential', 'backwards', 'together' or 'natural', and collapsed, such as #reveal ('sequential', collapsed)\",\n offset + part.length - part.trimStart().length,\n );\n }\n offset += part.length + 1;\n }\n }\n if (reveal.collapsed && reveal.order !== 'sequential') {\n this.fail(\n `collapsed shows the fallback of the next body to show, so it needs the order 'sequential', not '${reveal.order}'`,\n header!.start,\n );\n }\n const body = this.parseBody('reveal');\n if (body.script) {\n this.fail('#reveal has no script of its own', body.script.start);\n }\n return { kind: 'fragment', start, end: this.pos, children: body.children, reveal };\n }\n\n private parseHeader(\n keyword: string,\n required: boolean,\n ): { start: number; end: number } | undefined {\n this.skipWhitespace();\n if (this.peek() !== '(') {\n if (required) {\n this.fail(`Expected \"(\" after #${keyword}`, this.pos);\n }\n return undefined;\n }\n const inner = this.bracketed();\n if (this.source.slice(inner.start, inner.end).trim() === '') {\n this.fail(`Expected an expression after #${keyword}`, inner.start);\n }\n return inner;\n }\n\n private parseBody(keyword: string): Body {\n this.skipWhitespace();\n if (this.peek() !== '{') {\n this.fail(`Expected \"{\" after #${keyword}`, this.pos);\n }\n const start = this.pos;\n this.pos++;\n this.skipTrivia();\n let script: Script | undefined;\n if (this.isTagStart('script')) {\n const scriptStart = this.pos;\n const parsed = this.parseScriptBlock();\n if (Object.keys(parsed.attributes).length > 0) {\n this.fail('The script of a block takes no attributes', scriptStart);\n }\n script = parsed.script;\n }\n const templates: TemplateDecl[] = [];\n const children = this.parseNodes('body', templates);\n this.pos++;\n return { start, end: this.pos, script, templates, children };\n }\n\n /** Consumes `#keyword` if it comes next, after whitespace and comments. */\n private parseBranch(keyword: string): boolean {\n const saved = this.pos;\n this.skipTrivia();\n if (this.blockKeyword(BRANCH_KEYWORDS) === keyword) {\n this.pos += keyword.length + 1;\n return true;\n }\n this.pos = saved;\n return false;\n }\n\n private parseBlock(keyword: string): Block | FragmentNode {\n const start = this.pos;\n this.pos += keyword.length + 1;\n switch (keyword) {\n case 'if': {\n const branches: Branch[] = [];\n let header = this.parseHeader('if', true)!;\n branches.push({\n condition: this.expression(header.start, header.end),\n body: this.parseBody('if'),\n });\n let fallback: Body | undefined;\n while (this.parseBranch('else')) {\n this.skipWhitespace();\n if (this.startsWith('if') && !isIdentifierPart(this.source[this.pos + 2])) {\n this.pos += 2;\n header = this.parseHeader('else if', true)!;\n branches.push({\n condition: this.expression(header.start, header.end),\n body: this.parseBody('else if'),\n });\n } else {\n fallback = this.parseBody('else');\n break;\n }\n }\n return { kind: 'if', start, end: this.pos, branches, fallback };\n }\n case 'for':\n return this.parseFor(start);\n case 'repeat': {\n const header = this.parseHeader('repeat', true)!;\n const code = this.source.slice(header.start, header.end);\n const of = findTopLevel(code, 'of', this.fail);\n let index: oxc.BindingIdentifier | undefined;\n let countStart = header.start;\n if (of !== -1) {\n index = this.parseIdentifier(\n header.start,\n header.start + of,\n 'Expected \"index of count\" after #repeat',\n );\n countStart = header.start + of + 2;\n }\n const count = this.expression(countStart, header.end);\n const body = this.parseBody('repeat');\n const fallback = this.parseBranch('else') ? this.parseBody('else') : undefined;\n return { kind: 'repeat', start, end: this.pos, index, count, body, fallback };\n }\n case 'switch':\n return this.parseSwitch(start);\n case 'key': {\n const header = this.parseHeader('key', true)!;\n const value = this.expression(header.start, header.end);\n return { kind: 'key', start, end: this.pos, value, body: this.parseBody('key') };\n }\n case 'try': {\n const body = this.parseBody('try');\n if (!this.parseBranch('catch')) {\n this.fail('#try needs a #catch block', this.pos);\n }\n const header = this.parseHeader('catch', false);\n let error: oxc.BindingIdentifier | undefined;\n let reset: oxc.BindingIdentifier | undefined;\n if (header) {\n const code = this.source.slice(header.start, header.end);\n const comma = findTopLevel(code, ',', this.fail);\n const errorEnd = comma === -1 ? header.end : header.start + comma;\n error = this.parseIdentifier(\n header.start,\n errorEnd,\n 'Expected \"(error, reset)\" after #catch',\n );\n if (comma !== -1) {\n reset = this.parseIdentifier(\n errorEnd + 1,\n header.end,\n 'Expected \"(error, reset)\" after #catch',\n );\n }\n }\n const fallback = this.parseBody('catch');\n return { kind: 'try', start, end: this.pos, body, error, reset, fallback };\n }\n case 'loading': {\n const header = this.parseHeader('loading', false);\n const on = header ? this.expression(header.start, header.end) : undefined;\n const body = this.parseBody('loading');\n const fallback = this.parseBranch('else') ? this.parseBody('else') : undefined;\n return { kind: 'loading', start, end: this.pos, on, body, fallback };\n }\n case 'head':\n return { kind: 'head', start, end: this.pos, body: this.parseBody('head') };\n case 'reveal':\n return this.parseReveal(start);\n case 'portal': {\n const header = this.parseHeader('portal', false);\n const target = header ? this.expression(header.start, header.end) : undefined;\n return { kind: 'portal', start, end: this.pos, target, body: this.parseBody('portal') };\n }\n case 'client':\n case 'defer': {\n const header = this.parseHeader(keyword, false);\n let trigger: ClientTrigger = 'visible';\n if (header) {\n const code = this.source.slice(header.start, header.end).trim();\n const value = code.slice(1, -1);\n if (!/^(['\"]).*\\1$/.test(code) || !CLIENT_TRIGGERS.has(value)) {\n this.fail(\n `The trigger of #${keyword} must be \"visible\", \"idle\" or \"load\"`,\n header.start,\n );\n }\n trigger = value as ClientTrigger;\n }\n const body = this.parseBody(keyword);\n const fallback = this.parseBranch('else') ? this.parseBody('else') : undefined;\n return { kind: keyword, start, end: this.pos, trigger, body, fallback };\n }\n case 'offscreen': {\n const header = this.parseHeader('offscreen', true)!;\n const visible = this.expression(header.start, header.end);\n const body = this.parseBody('offscreen');\n return { kind: 'offscreen', start, end: this.pos, visible, body };\n }\n default:\n return this.fail(`Unknown block #${keyword}`, start);\n }\n }\n\n private parseIdentifier(start: number, end: number, message: string): oxc.BindingIdentifier {\n const pattern = parsePattern(this.source.slice(start, end), start, this.fail);\n if (pattern.type !== 'Identifier') {\n return this.fail(message, start);\n }\n return pattern;\n }\n\n private parseFor(start: number): Block {\n const header = this.parseHeader('for', true)!;\n const code = this.source.slice(header.start, header.end);\n const message = 'Expected \"item of list\" or \"item, index of list\" after #for';\n const of = findTopLevel(code, 'of', this.fail);\n if (of === -1) {\n this.fail(message, header.start);\n }\n const left = code.slice(0, of);\n const comma = findTopLevel(left, ',', this.fail);\n const itemEnd = comma === -1 ? header.start + of : header.start + comma;\n const item = parsePattern(this.source.slice(header.start, itemEnd), header.start, this.fail);\n let index: oxc.BindingIdentifier | undefined;\n if (comma !== -1) {\n index = this.parseIdentifier(itemEnd + 1, header.start + of, message);\n }\n\n const listStart = header.start + of + 2;\n const by = findTopLevel(this.source.slice(listStart, header.end), 'by', this.fail);\n const listEnd = by === -1 ? header.end : listStart + by;\n const list = this.expression(listStart, listEnd);\n let key: Expression | 'index' | undefined;\n if (by !== -1) {\n const keyStart = listEnd + 2;\n const keyCode = this.source.slice(keyStart, header.end).trim();\n key =\n keyCode === 'index' || keyCode === index?.name\n ? 'index'\n : this.expression(keyStart, header.end);\n }\n const body = this.parseBody('for');\n const fallback = this.parseBranch('else') ? this.parseBody('else') : undefined;\n return { kind: 'for', start, end: this.pos, item, index, list, key, body, fallback };\n }\n\n private parseSwitch(start: number): Block {\n this.skipWhitespace();\n this.expect('{', 'Expected \"{\" after #switch');\n const cases: Branch[] = [];\n let fallback: Body | undefined;\n for (;;) {\n this.skipTrivia();\n if (this.peek() === '}') {\n this.pos++;\n return { kind: 'switch', start, end: this.pos, cases, fallback };\n }\n const keyword = this.blockKeyword(BRANCH_KEYWORDS);\n if (keyword !== 'case' && keyword !== 'default') {\n return this.fail('Only #case and #default are allowed in #switch', this.pos);\n }\n if (fallback) {\n this.fail('#default must be the last branch of #switch', this.pos);\n }\n this.pos += keyword.length + 1;\n if (keyword === 'case') {\n const header = this.parseHeader('case', true)!;\n cases.push({\n condition: this.expression(header.start, header.end),\n body: this.parseBody('case'),\n });\n } else {\n fallback = this.parseBody('default');\n }\n }\n }\n\n private parseTemplate(): TemplateDecl {\n const start = this.pos;\n this.pos += '#template'.length;\n this.skipWhitespace();\n const nameStart = this.pos;\n const name = readIdentifier(this.source, this.pos);\n this.pos += name.length;\n this.skipWhitespace();\n if (this.peek() !== '(') {\n this.fail('Expected \"(\" after the name of the template', this.pos);\n }\n const inner = this.bracketed();\n const params = parseParameters(\n this.source.slice(inner.start, inner.end),\n inner.start,\n this.fail,\n );\n const body = this.parseBody('template');\n return {\n kind: 'template',\n start,\n end: this.pos,\n name,\n nameRange: { start: nameStart, end: nameStart + name.length },\n params,\n body,\n };\n }\n}\n","import { analyze } from './analyze.ts';\nimport type { Attribute, Markup, SFCFile } from './ast.ts';\nimport { buildGraph } from './graph.ts';\nimport type { Graph } from './graph.ts';\nimport type { Site } from './model.ts';\nimport { parse } from './parser.ts';\n\n/** A component that a file renders, and the props it passes that can change. */\nexport interface ComponentUsage {\n /** The import specifier of the component. */\n source: string;\n /** The props whose values can change on the client. `*` means every prop. */\n liveProps: Set<string>;\n}\n\n/** Returns the import specifier of a name that the file imports. */\nfunction importSource(file: SFCFile, name: string): string | undefined {\n const programs = [file.moduleScript?.program, file.instanceScript?.program];\n for (const program of programs) {\n for (const statement of program?.body ?? []) {\n if (statement.type !== 'ImportDeclaration') {\n continue;\n }\n if (statement.specifiers.some((specifier) => specifier.local.name === name)) {\n return statement.source.value;\n }\n }\n }\n return undefined;\n}\n\n/** The markup inside a node: the children of an element, or the bodies of a block. */\nexport function childrenOf(node: Markup): Markup[] {\n switch (node.kind) {\n case 'element':\n case 'component':\n case 'dynamic':\n case 'fragment':\n return node.children;\n case 'if':\n return [\n ...node.branches.flatMap((branch) => branch.body.children),\n ...(node.fallback?.children ?? []),\n ];\n case 'switch':\n return [\n ...node.cases.flatMap((branch) => branch.body.children),\n ...(node.fallback?.children ?? []),\n ];\n case 'for':\n case 'repeat':\n case 'loading':\n case 'client':\n case 'defer':\n return [...node.body.children, ...(node.fallback?.children ?? [])];\n case 'try':\n return [...node.body.children, ...node.fallback.children];\n case 'key':\n case 'portal':\n case 'head':\n case 'offscreen':\n return node.body.children;\n default:\n return [];\n }\n}\n\n/** Visits every markup node of a file, including blocks and templates. */\nexport function forEachNode(nodes: Markup[], visit: (node: Markup) => void): void {\n for (const node of nodes) {\n visit(node);\n forEachNode(childrenOf(node), visit);\n }\n}\n\n/** Lists the components that a file renders, and the props it passes that can change. */\nexport function summarize(file: SFCFile, graph: Graph): ComponentUsage[] {\n const live = new Set<Site>();\n for (const node of graph.nodes) {\n if (node.kind !== 'source' && graph.live.has(node)) {\n live.add(node.site);\n }\n }\n const sites = new Map<object, Site>();\n for (const site of graph.model.sites) {\n sites.set(site.node, site);\n }\n const isLive = (expression: { ast: object }): boolean => {\n const site = sites.get(expression.ast);\n return site !== undefined && live.has(site);\n };\n const liveProp = (attribute: Attribute): string | undefined => {\n switch (attribute.kind) {\n case 'value':\n return isLive(attribute.value) ? attribute.name : undefined;\n case 'event':\n return isLive(attribute.handler) ? attribute.name : undefined;\n case 'spread':\n return isLive(attribute.value) ? '*' : undefined;\n case 'computed':\n return isLive(attribute.name) || (attribute.value !== true && isLive(attribute.value))\n ? '*'\n : undefined;\n default:\n return undefined;\n }\n };\n\n const usages: ComponentUsage[] = [];\n const visit = (node: Markup): void => {\n if (node.kind !== 'component') {\n return;\n }\n const source = importSource(file, node.name.split('.')[0]!);\n if (!source) {\n return;\n }\n const liveProps = new Set<string>();\n for (const attribute of node.attributes) {\n const name = liveProp(attribute);\n if (name) {\n liveProps.add(name);\n }\n }\n usages.push({ source, liveProps });\n };\n forEachNode(file.children, visit);\n for (const template of file.templates) {\n forEachNode(template.body.children, visit);\n }\n return usages;\n}\n\n/** Resolves an import specifier of a file to a project file, or undefined if it is not one. */\nexport type Resolve = (specifier: string, importer: string) => string | undefined;\n\n/** Resolves relative imports of `.brm` files. */\nexport function resolveRelative(specifier: string, importer: string): string | undefined {\n if (!specifier.startsWith('.') || !specifier.endsWith('.brm')) {\n return undefined;\n }\n return joinPosix(importer.slice(0, Math.max(0, importer.lastIndexOf('/'))), specifier);\n}\n\n/** For each file, each prop that can change, and the files that change it. */\nexport type ProjectProps = Map<string, Map<string, Set<string>>>;\n\n/**\n * Finds the props that can change on the client, and the parents that\n * change them, for every file of a project. Props start out unchanged,\n * because code outside `.brm` files renders components only on the server.\n * A prop can change when a parent passes it a value that can change. Files\n * with errors are skipped.\n */\nexport function analyzeProjectProps(\n files: Map<string, string>,\n resolve: Resolve = resolveRelative,\n): ProjectProps {\n const parsed = new Map<string, SFCFile>();\n for (const [filename, source] of files) {\n try {\n parsed.set(filename, parse(source, { filename }));\n } catch {\n // The compile of this file reports the error.\n }\n }\n const result: ProjectProps = new Map();\n for (const filename of parsed.keys()) {\n result.set(filename, new Map());\n }\n // Each round can only add props, so this ends.\n for (let changed = true; changed;) {\n changed = false;\n for (const [filename, file] of parsed) {\n const liveProps = new Set(result.get(filename)!.keys());\n const graph = buildGraph(analyze(file), { liveProps });\n for (const usage of summarize(file, graph)) {\n const target = resolve(usage.source, filename);\n const props = target === undefined ? undefined : result.get(target);\n if (!props) {\n continue;\n }\n for (const name of usage.liveProps) {\n const parents = props.get(name) ?? new Set<string>();\n if (!props.has(name)) {\n props.set(name, parents);\n changed = true;\n }\n parents.add(filename);\n }\n }\n }\n }\n return result;\n}\n\n/** Finds the props that can change on the client, for every file of a project. */\nexport function analyzeProject(\n files: Map<string, string>,\n resolve: Resolve = resolveRelative,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [filename, props] of analyzeProjectProps(files, resolve)) {\n result.set(filename, new Set(props.keys()));\n }\n return result;\n}\n\n/** Joins a directory and a relative path with `/`, resolving `.` and `..`. */\nfunction joinPosix(directory: string, specifier: string): string {\n const parts: string[] = [];\n for (const part of `${directory}/${specifier}`.split('/')) {\n if (part === '..') {\n parts.pop();\n } else if (part && part !== '.') {\n parts.push(part);\n }\n }\n return (directory.startsWith('/') ? '/' : '') + parts.join('/');\n}\n","// Warnings for common accessibility mistakes in markup. The compiler sees\n// every element and attribute, so it can find them before the page runs.\n\nimport type { Attribute, ElementNode, Markup, SFCFile } from './ast.ts';\nimport type { Diagnostic } from './model.ts';\nimport { childrenOf } from './project.ts';\n\n/** Elements that a keyboard can reach and use without help. */\nconst INTERACTIVE = new Set([\n 'a',\n 'button',\n 'details',\n 'input',\n 'label',\n 'option',\n 'select',\n 'summary',\n 'textarea',\n]);\n\n/** Fields whose type has no label of its own to give. */\nconst UNLABELLED_TYPES = new Set(['hidden', 'submit', 'reset', 'button', 'image']);\n\n/** An attribute of an element: its static value, `true` for a dynamic one, or undefined. */\nfunction attribute(element: ElementNode, name: string): string | true | undefined {\n for (const item of element.attributes) {\n if (item.kind === 'static' && item.name === name) {\n return item.value;\n }\n if (item.kind === 'value' && item.name === name) {\n return true;\n }\n }\n return undefined;\n}\n\n/** True when the element spreads or computes attributes, so any attribute can be there. */\nfunction hasUnknownAttributes(attributes: Attribute[]): boolean {\n return attributes.some((item) => item.kind === 'spread' || item.kind === 'computed');\n}\n\nfunction hasEvent(element: ElementNode, events: string[]): boolean {\n return element.attributes.some((item) => item.kind === 'event' && events.includes(item.event));\n}\n\n/** True when an element names itself with ARIA or a title. */\nfunction hasAccessibleName(element: ElementNode): boolean {\n return ['aria-label', 'aria-labelledby', 'title'].some((name) => {\n const value = attribute(element, name);\n return value === true || (typeof value === 'string' && value.trim() !== '');\n });\n}\n\n/**\n * True when markup has text for a screen reader to read. An inserted value,\n * a component or a block may render text, so they count.\n */\nfunction hasText(nodes: Markup[]): boolean {\n return nodes.some((node) => {\n switch (node.kind) {\n case 'text':\n return node.value.trim() !== '';\n case 'element': {\n if (hasUnknownAttributes(node.attributes) || hasAccessibleName(node)) {\n return true;\n }\n if (node.tag === 'img') {\n const alt = attribute(node, 'alt');\n return alt === true || (typeof alt === 'string' && alt.trim() !== '');\n }\n return attribute(node, 'aria-hidden') !== 'true' && hasText(node.children);\n }\n case 'fragment':\n return hasText(node.children);\n case 'listener':\n return false;\n default:\n return true;\n }\n });\n}\n\n/** The range of the start of an opening tag, such as `<img`. */\nfunction tagRange(element: ElementNode): { start: number; end: number } {\n return { start: element.start, end: element.start + 1 + element.tag.length };\n}\n\n/** Finds common accessibility mistakes in the markup of a file. */\nexport function checkAccessibility(file: SFCFile): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const warn = (element: ElementNode, message: string): void => {\n diagnostics.push({ severity: 'warning', message, range: tagRange(element) });\n };\n\n // The IDs that a `<label for>` names, so the field with that ID has a label.\n const labelled = new Set<string>();\n let dynamicLabel = false;\n const roots = [file.children, ...file.templates.map((template) => template.body.children)];\n const collect = (nodes: Markup[]): void => {\n for (const node of nodes) {\n if (node.kind === 'element' && node.tag === 'label') {\n const target = attribute(node, 'for');\n if (typeof target === 'string') {\n labelled.add(target);\n } else if (target === true) {\n dynamicLabel = true;\n }\n }\n collect(childrenOf(node));\n }\n };\n roots.forEach(collect);\n\n const visit = (nodes: Markup[], inLabel: boolean): void => {\n for (const node of nodes) {\n if (node.kind !== 'element') {\n visit(childrenOf(node), inLabel);\n continue;\n }\n if (!hasUnknownAttributes(node.attributes)) {\n check(node, inLabel);\n }\n visit(node.children, inLabel || node.tag === 'label');\n }\n };\n\n const check = (element: ElementNode, inLabel: boolean): void => {\n const { tag } = element;\n if (tag === 'img' && attribute(element, 'alt') === undefined) {\n warn(element, 'An <img> needs alt text. Use alt=\"\" for an image that only decorates.');\n }\n if (\n hasEvent(element, ['click']) &&\n !INTERACTIVE.has(tag) &&\n (attribute(element, 'role') === undefined ||\n !hasEvent(element, ['keydown', 'keyup', 'keypress']))\n ) {\n warn(\n element,\n `A click handler on <${tag}> works only with a pointer. Use a <button>, or add a role, a tabindex and a key handler.`,\n );\n }\n const type = attribute(element, 'type');\n const isField =\n tag === 'select' ||\n tag === 'textarea' ||\n (tag === 'input' && !(typeof type === 'string' && UNLABELLED_TYPES.has(type)));\n if (isField && !inLabel && !hasAccessibleName(element)) {\n const id = attribute(element, 'id');\n const named = id === true || dynamicLabel || (typeof id === 'string' && labelled.has(id));\n if (!named) {\n warn(\n element,\n `A <${tag}> needs a label. Put it in a <label>, point a <label for> at its id, or add aria-label. A placeholder is not a label.`,\n );\n }\n }\n if (\n (tag === 'a' || tag === 'button') &&\n !hasAccessibleName(element) &&\n !hasText(element.children)\n ) {\n warn(\n element,\n tag === 'a'\n ? 'A link needs text that says where it goes, or aria-label.'\n : 'A button needs text that says what it does, or aria-label.',\n );\n }\n };\n roots.forEach((nodes) => visit(nodes, false));\n return diagnostics;\n}\n","// The server functions that a project ever refreshes. A memo that calls one\n// loads again in the browser after a call that refreshes it, so its value goes\n// to the browser with update code. A memo of a function that nothing refreshes\n// renders on the server only.\n\n/** Every name, as `*` in the set, for a call of `refresh` that the scan cannot read. */\nexport const ANY = '*';\n\nconst NAME = '[A-Za-z_$][\\\\w$]*';\n// `.refresh(fn)` and `.refresh(module.fn)`, such as `event.refresh(listNotes)`.\nconst REFRESH = new RegExp(`\\\\.refresh\\\\(\\\\s*(${NAME}(?:\\\\s*\\\\.\\\\s*${NAME})*)?\\\\s*([,)])`, 'g');\nconst IMPORT = /import\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from/g;\n\n/**\n * The names of the server functions that the sources pass to `refresh`, by\n * the name that their file exports. A local name of an import, such as `ln`\n * of `import { listNotes as ln }`, counts as the name that it imports. A\n * call that the scan cannot read, such as `refresh(pick())`, adds `ANY`.\n */\nexport function refreshedNames(sources: Iterable<string>): Set<string> {\n const names = new Set<string>();\n for (const source of sources) {\n if (!source.includes('.refresh(')) {\n continue;\n }\n const aliases = new Map<string, string>();\n for (const [, list] of source.matchAll(IMPORT)) {\n for (const item of list!.split(',')) {\n const [imported, local] = item\n .trim()\n .replace(/^type\\s+/, '')\n .split(/\\s+as\\s+/);\n if (imported && local) {\n aliases.set(local.trim(), imported.trim());\n }\n }\n }\n for (const match of source.matchAll(REFRESH)) {\n const target = match[1];\n if (target === undefined) {\n // `refresh()` names no function.\n continue;\n }\n const last = target.split('.').at(-1)!.trim();\n names.add(aliases.get(last) ?? last);\n }\n // A `refresh(` that the pattern did not read, such as `refresh(fns[0])`.\n const calls = source.split('.refresh(').length - 1;\n const read = [...source.matchAll(REFRESH)].length;\n if (calls > read) {\n names.add(ANY);\n }\n }\n return names;\n}\n","// Values that code in the browser reads go to the browser with the page.\n// A value made with `new`, such as a database client, usually cannot be\n// sent, and the page would fail when it renders. This finds such values\n// when the component compiles, and names the code that reads them.\n\nimport type { SFCFile } from './ast.ts';\nimport type { Declaration, Diagnostic } from './model.ts';\nimport { children } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\nimport type { Plan } from './plan.ts';\n\n/** Classes whose instances brumate can send to the browser. */\nconst SENDABLE = new Set([\n 'Array',\n 'Object',\n 'Date',\n 'URL',\n 'URLSearchParams',\n // The web values of seroval-plugins.\n 'Headers',\n 'FormData',\n 'Request',\n 'Response',\n 'ReadableStream',\n 'Event',\n 'CustomEvent',\n 'DOMException',\n 'AbortSignal',\n 'ImageData',\n 'Map',\n 'Set',\n 'Promise',\n 'Error',\n 'EvalError',\n 'RangeError',\n 'ReferenceError',\n 'SyntaxError',\n 'TypeError',\n 'URIError',\n 'AggregateError',\n 'ArrayBuffer',\n 'DataView',\n 'Int8Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array',\n 'String',\n 'Number',\n 'Boolean',\n]);\n\n/** Compile-time functions whose argument is the value, such as `$signal(new Foo())`. */\nconst WRAPPERS = new Set(['$signal', '$memo', '$debounced', '$throttled']);\n\n/** The value that a declaration holds, by the offset of its name. */\nexport function initializers(file: SFCFile): Map<number, oxc.Node> {\n const result = new Map<number, oxc.Node>();\n const visit = (node: oxc.Node): void => {\n if (node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.init) {\n let init: oxc.Node = node.init;\n if (\n init.type === 'CallExpression' &&\n init.callee.type === 'Identifier' &&\n WRAPPERS.has(init.callee.name) &&\n init.arguments[0]\n ) {\n init = init.arguments[0];\n }\n result.set(node.id.start, init);\n }\n for (const [, child] of children(node)) {\n visit(child);\n }\n };\n if (file.instanceScript) {\n visit(file.instanceScript.program);\n }\n return result;\n}\n\n/** The class of a value made with `new`, unless brumate or a plugin of the app can send it. */\nfunction unsendableClass(node: oxc.Node, sendable: readonly string[]): string | undefined {\n if (node.type !== 'NewExpression') {\n return undefined;\n }\n const callee = node.callee;\n let name = 'class';\n if (callee.type === 'Identifier') {\n name = callee.name;\n } else if (callee.type === 'MemberExpression' && callee.property.type === 'Identifier') {\n name = callee.property.name;\n }\n return SENDABLE.has(name) || sendable.includes(name) ? undefined : name;\n}\n\n/**\n * The classes that the plugins of a serial entry send: the names on the\n * right of `instanceof` in the file, such as `Money` in\n * `test: (value) => value instanceof Money`.\n */\nexport function entryClasses(program: oxc.Node): string[] {\n const names = new Set<string>();\n const visit = (node: oxc.Node): void => {\n if (node.type === 'BinaryExpression' && node.operator === 'instanceof') {\n const right = node.right;\n if (right.type === 'Identifier') {\n names.add(right.name);\n } else if (right.type === 'MemberExpression' && right.property.type === 'Identifier') {\n names.add(right.property.name);\n }\n }\n for (const [, child] of children(node)) {\n visit(child);\n }\n };\n visit(program);\n return [...names];\n}\n\n/** Errors for values that the browser reads but that cannot be sent to it. */\nexport function checkCaptures(\n file: SFCFile,\n plan: Plan,\n sendable: readonly string[] = [],\n): Diagnostic[] {\n const values = initializers(file);\n const diagnostics: Diagnostic[] = [];\n const reported = new Set<Declaration>();\n for (const layout of plan.scopes.values()) {\n for (const declaration of layout.slots) {\n const init = values.get(declaration.range.start);\n const kind = init && unsendableClass(init, sendable);\n if (!kind || reported.has(declaration)) {\n continue;\n }\n reported.add(declaration);\n // The code in the browser that reads the value, to name it in the error.\n const reader = declaration.reads.find((read) => plan.graph.reached.has(read.site))?.site;\n diagnostics.push({\n severity: 'error',\n message: `\"${declaration.name}\" holds a new ${kind}, which cannot be sent to the browser, and code that runs in the browser reads it${reader ? ` (${reader.label})` : ''}. Use it in a server function, or create it in the browser, such as in $client`,\n range: { start: init.start, end: init.end },\n });\n }\n }\n return diagnostics;\n}\n","// Server environment variables stay on the server. The compiler knows which\n// code runs in the browser, so it reports a read of a server variable there,\n// and a value made from one that the page state would send.\n\nimport type { SFCFile } from './ast.ts';\nimport { initializers } from './captures.ts';\nimport type { Declaration, Diagnostic, Reference } from './model.ts';\nimport { children } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\nimport type { Plan } from './plan.ts';\n\n/**\n * The names of the server variables that an import gives, such as\n * `import env from './env.ts'`, or undefined for other imports.\n */\nexport type EnvImport = (specifier: string, name: string) => string[] | undefined;\n\n/** The property that a read of `env` reads, such as `DATABASE_URL` for `env.DATABASE_URL`. */\nfunction propertyAt(node: oxc.Node, at: number): string | undefined | null {\n if (\n node.type === 'MemberExpression' &&\n node.object.type === 'Identifier' &&\n node.object.start === at\n ) {\n if (node.computed) {\n return node.property.type === 'Literal' ? String(node.property.value) : null;\n }\n return node.property.type === 'Identifier' ? node.property.name : null;\n }\n for (const [, child] of children(node)) {\n const found = propertyAt(child, at);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/** The server variable that a read reads, or `*` for a read of the whole object. */\nfunction serverRead(read: Reference, server: string[]): string | undefined {\n const nodes = [read.site.node, ...(read.site.extra ?? [])];\n for (const node of nodes) {\n const property = propertyAt(node, read.range.start);\n if (property === undefined) {\n continue;\n }\n if (property === null) {\n return '*';\n }\n return server.includes(property) ? property : undefined;\n }\n return '*';\n}\n\n/** Errors for server variables that code in the browser reads, or that the page state would send. */\nexport function checkEnv(file: SFCFile, plan: Plan, envImport: EnvImport): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const values = initializers(file);\n const slots = new Set<Declaration>();\n for (const layout of plan.scopes.values()) {\n for (const declaration of layout.slots) {\n slots.add(declaration);\n }\n }\n for (const declaration of plan.graph.model.declarations) {\n if (!declaration.imported) {\n continue;\n }\n const server = envImport(declaration.imported.source, declaration.imported.name);\n if (!server) {\n continue;\n }\n const name = declaration.name;\n for (const read of declaration.reads) {\n const variable = serverRead(read, server);\n if (variable === undefined) {\n continue;\n }\n const what =\n variable === '*'\n ? `${name}, with its server variables,`\n : `${name}.${variable}, a server variable,`;\n if (plan.graph.reached.has(read.site)) {\n diagnostics.push({\n severity: 'error',\n message: `${what} is read by code that runs in the browser (${read.site.label}). Read it in a server function`,\n range: read.range,\n });\n continue;\n }\n // A value made from it that client code reads would go to the browser with the page.\n const holder = [...slots].find((slot) => {\n const init = values.get(slot.range.start);\n return init && read.range.start >= init.start && read.range.end <= init.end;\n });\n if (holder) {\n diagnostics.push({\n severity: 'error',\n message: `\"${holder.name}\" holds ${what} and code that runs in the browser reads it. Keep server variables out of values that the browser reads`,\n range: read.range,\n });\n }\n }\n }\n return diagnostics;\n}\n","// Source maps from generated modules back to the `.brm` file.\n//\n// Code generation builds modules from strings, and copies code of the file\n// into them in many places. Instead of tracking positions through every\n// string, each copy carries markers: a character of the private use area,\n// the offset in the file in base 36, and another such character. A marker\n// goes before each copied piece and after each line break in it. When the\n// module is done, `finish` removes the markers and writes where each one\n// was as a mapping.\n\nconst OPEN = '';\nconst CLOSE = '';\nconst MARKER = /([0-9a-z]+)/g;\n\n/** The marker of an offset in the file. */\nfunction marker(offset: number): string {\n return `${OPEN}${offset.toString(36)}${CLOSE}`;\n}\n\n/**\n * Copies a range of the file, with a marker before it and before the first\n * character of each line after it, so the source map points each line at its\n * place in the file. The marker of a line goes after its indentation, so\n * code that changes indentation still finds it, and blank lines get none.\n */\nexport function copy(source: string, start: number, end: number): string {\n if (end <= start) {\n return '';\n }\n let result = marker(start);\n let position = start;\n for (;;) {\n const lineBreak = source.indexOf('\\n', position);\n if (lineBreak === -1 || lineBreak >= end - 1) {\n break;\n }\n let first = lineBreak + 1;\n while (first < end && (source[first] === ' ' || source[first] === '\\t')) {\n first++;\n }\n result += source.slice(position, first);\n if (first < end && source[first] !== '\\n' && source[first] !== '\\r') {\n result += marker(first);\n }\n position = first;\n }\n return result + source.slice(position, end);\n}\n\n/** Removes the markers of a text, for code that checks what a copy holds. */\nexport function unmarked(text: string): string {\n return text.replace(MARKER, '');\n}\n\n/** A source map, version 3. */\nexport interface SourceMap {\n version: 3;\n file: string;\n sources: string[];\n sourcesContent: string[];\n names: string[];\n mappings: string;\n}\n\nconst BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nfunction vlq(value: number): string {\n let rest = value < 0 ? (-value << 1) | 1 : value << 1;\n let result = '';\n do {\n let digit = rest & 31;\n rest >>>= 5;\n if (rest > 0) {\n digit |= 32;\n }\n result += BASE64[digit];\n } while (rest > 0);\n return result;\n}\n\n/** A file that code comes from. */\nexport interface SourceFile {\n name: string;\n content: string;\n}\n\n/** The line and column of each offset of a text, both from 0. */\nfunction lineIndex(text: string): (offset: number) => [line: number, column: number] {\n const lineStarts = [0];\n for (let index = text.indexOf('\\n'); index !== -1; index = text.indexOf('\\n', index + 1)) {\n lineStarts.push(index + 1);\n }\n return (offset) => {\n let low = 0;\n let high = lineStarts.length - 1;\n while (low < high) {\n const middle = (low + high + 1) >> 1;\n if (lineStarts[middle]! <= offset) {\n low = middle;\n } else {\n high = middle - 1;\n }\n }\n return [low, offset - lineStarts[low]!];\n };\n}\n\n/**\n * Removes the markers of a generated module, and returns the module with a\n * source map that points the code that came from the files back to them.\n * The markers hold offsets of the code that was compiled. `place` turns one\n * into the index of its file in `files` and the offset in that file, for\n * code that a component copied from a module.\n */\nexport function finish(\n code: string,\n files: SourceFile[],\n place: (offset: number) => { index: number; offset: number } = (offset) => ({ index: 0, offset }),\n): { code: string; map: SourceMap } {\n const indexes = files.map((file) => lineIndex(file.content));\n let previousSource = 0;\n\n let output = '';\n const lines: string[] = [''];\n let column = 0;\n let previousColumn = 0;\n let previousLine = 0;\n let previousSourceColumn = 0;\n let position = 0;\n // The segments of the current line, so two markers at one column write one segment.\n let lastColumn = -1;\n for (const match of code.matchAll(MARKER)) {\n const text = code.slice(position, match.index);\n output += text;\n for (const char of text) {\n if (char === '\\n') {\n lines.push('');\n column = 0;\n previousColumn = 0;\n lastColumn = -1;\n } else {\n column += char.length;\n }\n }\n position = match.index + match[0].length;\n if (column === lastColumn) {\n continue;\n }\n lastColumn = column;\n const placed = place(Number.parseInt(match[1]!, 36));\n const [line, sourceColumn] = indexes[placed.index]!(placed.offset);\n const segment =\n vlq(column - previousColumn) +\n vlq(placed.index - previousSource) +\n vlq(line - previousLine) +\n vlq(sourceColumn - previousSourceColumn);\n previousSource = placed.index;\n const current = lines.length - 1;\n lines[current] = lines[current] ? `${lines[current]},${segment}` : segment;\n previousColumn = column;\n previousLine = line;\n previousSourceColumn = sourceColumn;\n }\n output += code.slice(position);\n return {\n code: output,\n map: {\n version: 3,\n file: files[0]!.name,\n sources: files.map((file) => file.name),\n sourcesContent: files.map((file) => file.content),\n names: [],\n mappings: lines.join(';'),\n },\n };\n}\n\n/**\n * The place in a source that a position of generated code came from, by a\n * source map. Lines and columns count from 1. Undefined when the map has no\n * mapping on that line at or before the column.\n */\nexport function originalPosition(\n map: { sources: (string | null)[]; mappings: string },\n line: number,\n column: number,\n): { source: string; line: number; column: number } | undefined {\n // The fields of a segment are relative to the segment before, across lines but the column.\n const state = [0, 0, 0, 0];\n let found: number[] | undefined;\n const lines = map.mappings.split(';');\n for (let index = 0; index < line && index < lines.length; index++) {\n let generated = 0;\n for (const segment of lines[index]!.split(',')) {\n if (!segment) {\n continue;\n }\n const fields: number[] = [];\n let value = 0;\n let shift = 0;\n for (const char of segment) {\n const digit = BASE64.indexOf(char);\n value += (digit & 31) << shift;\n if (digit & 32) {\n shift += 5;\n } else {\n fields.push(value & 1 ? -(value >>> 1) : value >>> 1);\n value = 0;\n shift = 0;\n }\n }\n generated += fields[0]!;\n if (fields.length >= 4) {\n state[1]! += fields[1]!;\n state[2]! += fields[2]!;\n state[3]! += fields[3]!;\n }\n if (index === line - 1 && fields.length >= 4 && generated <= column - 1) {\n found = [state[1]!, state[2]!, state[3]!];\n }\n }\n }\n const source = found && map.sources[found[0]!];\n return found && source ? { source, line: found[1]! + 1, column: found[2]! + 1 } : undefined;\n}\n","// Node built-ins that the compiler uses only for some features, loaded when\n// they are needed, so the compiler also runs in a browser.\n\nimport type * as NodeFs from 'node:fs';\nimport type * as NodeModule from 'node:module';\nimport type * as NodePath from 'node:path';\nimport type * as NodeURL from 'node:url';\nimport type * as NodeZlib from 'node:zlib';\n\ninterface Builtins {\n 'node:fs': typeof NodeFs;\n 'node:module': typeof NodeModule;\n 'node:path': typeof NodePath;\n 'node:url': typeof NodeURL;\n 'node:zlib': typeof NodeZlib;\n}\n\n/** Returns a Node built-in, or undefined outside Node. */\nexport function builtin<K extends keyof Builtins>(name: K): Builtins[K] | undefined {\n const process = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } })\n .process;\n return process?.getBuiltinModule?.(name) as Builtins[K] | undefined;\n}\n","// Reactive logic in modules. A `.brm.ts` module exports functions that use\n// compile-time functions, such as `$signal`. A component calls one at the top\n// level of a script and destructures what it returns:\n//\n// const { count, increment } = counter(5);\n//\n// The compiler copies the body of the function in place of the call, before\n// it analyzes the component. Its signals and memos become values of the\n// component, so the graph stays static and nothing else changes.\n//\n// - Locals of the function get new names, so they cannot clash with names of\n// the component. What it returns takes the names of the destructuring.\n// - A parameter whose argument is a name reads that name, so a signal passed\n// in stays reactive. Other arguments become constants.\n// - Names that the function reads from its module are imported into the\n// component, from paths relative to the component.\n\nimport { parseSync } from 'oxc-parser';\nimport type { SFCFile } from './ast.ts';\nimport { MACROS, SIGNALS_MODULE } from './macros.ts';\nimport { builtin } from './node.ts';\nimport { children, getPatternNames } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\nimport { forEachNode } from './project.ts';\n\n/** A module of reactive logic, read by its path. */\nexport interface ReactiveModule {\n /** The absolute path of the module. */\n path: string;\n source: string;\n}\n\n/** Finds a module that a file imports, or returns undefined if it cannot. */\nexport type ResolveModule = (specifier: string, importer: string) => ReactiveModule | undefined;\n\n/** True for the specifier of a module of reactive logic, such as `./counter.brm.ts`. */\nexport function isReactiveModule(specifier: string): boolean {\n return /\\.brm\\.[cm]?[jt]s$/.test(specifier);\n}\n\n/** Reads a module next to the importer from the file system, where there is one. */\nexport const resolveFromDisk: ResolveModule = (specifier, importer) => {\n const fs = builtin('node:fs');\n const path = builtin('node:path');\n if (!fs || !path || !specifier.startsWith('.')) {\n return undefined;\n }\n const file = path.resolve(path.dirname(importer), specifier);\n try {\n return { path: file, source: fs.readFileSync(file, 'utf8') };\n } catch {\n return undefined;\n }\n};\n\n/** Where an offset of the expanded source comes from. */\nexport interface Origin {\n /** The module that the code comes from, or undefined for the component. */\n module?: ReactiveModule;\n /** The offset in the component, or in the module. */\n offset: number;\n /** The call in the component that the code of a module replaces. */\n call?: { start: number; end: number };\n /** True for code of a module function that another module function calls. */\n nested?: boolean;\n}\n\n/** The source of a component with its calls of module functions replaced. */\nexport interface Expansion {\n source: string;\n origin: (offset: number) => Origin;\n /** The modules that the component reads, so a change to one compiles it again. */\n modules: ReactiveModule[];\n /** Each call, by the offset of its statement in the source before this expansion. */\n calls: ModuleCall[];\n}\n\n/** What a name of a module function is in the component that calls it. */\nexport type CallName = { name: string } | { literal: string };\n\n/** A call of a module function, and what each name of the function became. */\nexport interface ModuleCall {\n /** The offset of the statement of the call. */\n start: number;\n /** The path of the module. */\n module: string;\n /** The name of the function. */\n fn: string;\n names: Map<string, CallName>;\n}\n\n/** True for an argument that can be written into the code as it is, such as `'name'` or `-1`. */\nfunction isLiteral(node: oxc.Node): boolean {\n if (node.type === 'Literal') {\n return !('regex' in node && node.regex);\n }\n if (node.type === 'TemplateLiteral') {\n return node.expressions.length === 0;\n }\n return (\n node.type === 'UnaryExpression' &&\n (node.operator === '-' || node.operator === '+') &&\n node.argument.type === 'Literal' &&\n typeof node.argument.value === 'number'\n );\n}\n\n/** The names that code assigns to, such as `start` in `start = 1` or `start++`. */\nfunction assignedNames(node: oxc.Node, names: Set<string> = new Set()): Set<string> {\n if (node.type === 'AssignmentExpression' && node.left.type === 'Identifier') {\n names.add(node.left.name);\n } else if (node.type === 'UpdateExpression' && node.argument.type === 'Identifier') {\n names.add(node.argument.name);\n }\n for (const [, child] of children(node)) {\n assignedNames(child, names);\n }\n return names;\n}\n\n/** An error in a module function or in a call of one. */\nexport class ModuleError extends Error {\n /** The offset in the component of the call that the error is about. */\n readonly offset: number;\n\n constructor(message: string, offset: number) {\n super(message);\n this.name = 'ModuleError';\n this.offset = offset;\n }\n}\n\ninterface Piece {\n /** The offset of the piece in the expanded source. */\n start: number;\n length: number;\n origin: Origin;\n /** True when each character maps to the next one of the origin, as for copied code. */\n linear: boolean;\n}\n\n/** Builds the expanded source, and remembers where each piece comes from. */\nclass Builder {\n text = '';\n readonly pieces: Piece[] = [];\n\n add(text: string, origin: Origin, linear: boolean): void {\n if (text) {\n this.pieces.push({ start: this.text.length, length: text.length, origin, linear });\n this.text += text;\n }\n }\n\n origin(offset: number): Origin {\n let low = 0;\n let high = this.pieces.length - 1;\n while (low < high) {\n const middle = (low + high + 1) >> 1;\n if (this.pieces[middle]!.start <= offset) {\n low = middle;\n } else {\n high = middle - 1;\n }\n }\n const piece = this.pieces[low];\n if (!piece) {\n return { offset };\n }\n const delta = piece.linear ? Math.min(offset - piece.start, piece.length) : 0;\n return { ...piece.origin, offset: piece.origin.offset + delta };\n }\n}\n\nexport interface ModuleInfo {\n module: ReactiveModule;\n program: oxc.Program;\n /** Imports by local name. `imported` is the exported name, `default` or `*`. */\n imports: Map<string, { specifier: string; imported: string }>;\n /** Names declared at the top level, with the name each is exported as, if it is. */\n declarations: Map<string, string | undefined>;\n /** Exported functions of reactive logic, by exported name. */\n functions: Map<string, oxc.Function | oxc.ArrowFunctionExpression>;\n}\n\nexport function parseModule(module: ReactiveModule): ModuleInfo {\n const result = parseSync(module.path, module.source, { lang: 'ts', preserveParens: false });\n const error = result.errors[0];\n if (error) {\n throw new ModuleError(`${error.message} (${module.path})`, 0);\n }\n const program = result.program;\n const imports = new Map<string, { specifier: string; imported: string }>();\n const declarations = new Map<string, string | undefined>();\n const functions = new Map<string, oxc.Function | oxc.ArrowFunctionExpression>();\n const declare = (node: oxc.Node, exported: boolean): void => {\n switch (node.type) {\n case 'VariableDeclaration':\n for (const declarator of node.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n declarations.set(id.name, exported ? id.name : undefined);\n }\n const init = declarator.init;\n if (\n exported &&\n declarator.id.type === 'Identifier' &&\n (init?.type === 'ArrowFunctionExpression' || init?.type === 'FunctionExpression')\n ) {\n functions.set(declarator.id.name, init);\n }\n }\n break;\n case 'FunctionDeclaration':\n if (node.id) {\n declarations.set(node.id.name, exported ? node.id.name : undefined);\n if (exported) {\n functions.set(node.id.name, node);\n }\n }\n break;\n case 'ClassDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n case 'TSEnumDeclaration':\n if (node.id) {\n declarations.set(node.id.name, exported ? node.id.name : undefined);\n }\n break;\n default:\n break;\n }\n };\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n for (const specifier of statement.specifiers) {\n let imported: string;\n if (specifier.type === 'ImportDefaultSpecifier') {\n imported = 'default';\n } else if (specifier.type === 'ImportNamespaceSpecifier') {\n imported = '*';\n } else {\n imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n }\n imports.set(specifier.local.name, { specifier: statement.source.value, imported });\n }\n } else if (statement.type === 'ExportNamedDeclaration' && statement.declaration) {\n declare(statement.declaration, true);\n } else {\n declare(statement, false);\n }\n }\n // `export { name }` exports a declaration after the fact.\n for (const statement of program.body) {\n if (\n statement.type === 'ExportNamedDeclaration' &&\n !statement.declaration &&\n !statement.source\n ) {\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (declarations.has(local)) {\n declarations.set(local, exported);\n }\n }\n }\n }\n return { module, program, imports, declarations, functions };\n}\n\n/** Joins and normalizes paths with `/`. */\nfunction normalize(path: string): string {\n const parts: string[] = [];\n for (const part of path.split('/')) {\n if (part === '..' && parts.length > 0 && parts.at(-1) !== '..') {\n parts.pop();\n } else if (part !== '.' && part !== '') {\n parts.push(part);\n } else if (part === '' && parts.length === 0) {\n parts.push('');\n }\n }\n return parts.join('/');\n}\n\nfunction directory(path: string): string {\n return path.slice(0, path.lastIndexOf('/') + 1);\n}\n\n/** A specifier of the module, relative to the component. Package names stay as they are. */\nexport function relocate(specifier: string, module: string, component: string): string {\n if (!specifier.startsWith('.')) {\n return specifier;\n }\n const target = normalize(`${directory(module)}${specifier}`).split('/');\n const from = normalize(directory(component)).split('/').filter(Boolean);\n let common = 0;\n const to = target.filter(Boolean);\n while (common < from.length && common < to.length - 1 && from[common] === to[common]) {\n common++;\n }\n const up = from.slice(common).map(() => '..');\n const rest = to.slice(common);\n const result = [...up, ...rest].join('/');\n return result.startsWith('.') ? result : `./${result}`;\n}\n\n/**\n * Scope-aware renaming. Walks a node and calls `visit` for each identifier\n * that reads or writes a name, with the scopes of names declared inside the\n * node, so a name that a nested function or block declares again is left alone.\n */\nexport function forEachReference(\n node: oxc.Node,\n visit: (identifier: oxc.IdentifierReference, shorthand: boolean) => void,\n shadowed: Set<string> = new Set(),\n): void {\n const declaredIn = (statements: oxc.Node[]): Set<string> => {\n const names = new Set(shadowed);\n for (const statement of statements) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n names.add(id.name);\n }\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n names.add(statement.id.name);\n }\n }\n return names;\n };\n const walk = (current: oxc.Node, scope: Set<string>): void => {\n switch (current.type) {\n case 'Identifier': {\n const identifier = current as oxc.IdentifierReference;\n if (!scope.has(identifier.name)) {\n visit(identifier, false);\n }\n return;\n }\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'ArrowFunctionExpression': {\n const inner = new Set(scope);\n for (const param of current.params) {\n for (const id of getPatternNames(\n param.type === 'TSParameterProperty' ? param.parameter : param,\n )) {\n inner.add(id.name);\n }\n }\n if (current.type === 'FunctionExpression' && current.id) {\n inner.add(current.id.name);\n }\n for (const param of current.params) {\n walkPattern(param, inner);\n }\n if (current.body) {\n walk(current.body, current.body.type === 'BlockStatement' ? inner : inner);\n }\n return;\n }\n case 'BlockStatement':\n case 'Program': {\n const inner = declaredIn(current.body);\n for (const name of scope) {\n inner.add(name);\n }\n for (const statement of current.body) {\n walk(statement, inner);\n }\n return;\n }\n case 'CatchClause': {\n const inner = new Set(scope);\n if (current.param) {\n for (const id of getPatternNames(current.param)) {\n inner.add(id.name);\n }\n }\n walk(current.body, inner);\n return;\n }\n case 'ForStatement':\n case 'ForInStatement':\n case 'ForOfStatement': {\n const head = current.type === 'ForStatement' ? current.init : current.left;\n const inner = head?.type === 'VariableDeclaration' ? declaredIn([head]) : new Set<string>();\n for (const name of scope) {\n inner.add(name);\n }\n for (const [, child] of children(current)) {\n walk(child, inner);\n }\n return;\n }\n case 'VariableDeclarator':\n walkPattern(current.id, scope);\n if (current.init) {\n walk(current.init, scope);\n }\n return;\n case 'MemberExpression':\n walk(current.object, scope);\n if (current.computed) {\n walk(current.property, scope);\n }\n return;\n case 'Property':\n if (current.shorthand && current.value.type === 'Identifier') {\n const identifier = current.value as oxc.IdentifierReference;\n if (!scope.has(identifier.name)) {\n visit(identifier, true);\n }\n return;\n }\n if (current.computed) {\n walk(current.key, scope);\n }\n walk(current.value, scope);\n return;\n case 'MethodDefinition':\n case 'PropertyDefinition':\n if (current.computed) {\n walk(current.key, scope);\n }\n if (current.value) {\n walk(current.value, scope);\n }\n return;\n case 'LabeledStatement':\n walk(current.body, scope);\n return;\n case 'BreakStatement':\n case 'ContinueStatement':\n return;\n default:\n for (const [key, child] of children(current)) {\n // Type annotations name types, which are imported like values.\n if (key !== 'typeAnnotation' || child.type !== 'Identifier') {\n walk(child, scope);\n }\n }\n }\n };\n // A pattern declares names, and its default values read names.\n const walkPattern = (pattern: oxc.Node, scope: Set<string>): void => {\n switch (pattern.type) {\n case 'Identifier':\n if (pattern.typeAnnotation) {\n walk(pattern.typeAnnotation, scope);\n }\n return;\n case 'AssignmentPattern':\n walkPattern(pattern.left, scope);\n walk(pattern.right, scope);\n return;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n if (property.type === 'RestElement') {\n walkPattern(property.argument, scope);\n } else {\n if (property.computed) {\n walk(property.key, scope);\n }\n walkPattern(property.value, scope);\n }\n }\n return;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n walkPattern(element, scope);\n }\n }\n return;\n case 'RestElement':\n walkPattern(pattern.argument, scope);\n return;\n default:\n walk(pattern, scope);\n }\n };\n walk(node, shadowed);\n}\n\n/** A call of a module function in a script of the component. */\ninterface Call {\n statement: oxc.VariableDeclaration;\n call: oxc.CallExpression;\n pattern: oxc.ObjectPattern;\n /** The local name of the function in the component. */\n local: string;\n}\n\n/** The scripts of a component: its instance script, and the scripts of its blocks. */\nfunction scripts(file: SFCFile): oxc.Program[] {\n const result: oxc.Program[] = [];\n if (file.instanceScript) {\n result.push(file.instanceScript.program);\n }\n const visit = (nodes: SFCFile['children']): void => {\n forEachNode(nodes, (node) => {\n if ('body' in node && node.body && 'script' in node.body && node.body.script) {\n result.push(node.body.script.program);\n }\n });\n };\n visit(file.children);\n for (const template of file.templates) {\n if (template.body.script) {\n result.push(template.body.script.program);\n }\n visit(template.body.children);\n }\n return result;\n}\n\n/**\n * Replaces the calls of module functions in a component with their bodies.\n * Returns undefined when the component calls none. `path` is the path of the\n * component, which relative imports of modules start from.\n */\nexport function expandModules(\n file: SFCFile,\n path: string,\n resolve: ResolveModule,\n): Expansion | undefined {\n const source = file.source;\n const program = file.instanceScript?.program;\n if (!program) {\n return undefined;\n }\n // A specifier of a package, such as `brumate/forms`, names a module when its export is one.\n const reactive = (specifier: string): boolean =>\n isReactiveModule(specifier) ||\n (!specifier.startsWith('.') &&\n specifier !== SIGNALS_MODULE &&\n isReactiveModule(resolve(specifier, path)?.path ?? ''));\n // The module functions that the component imports, by local name.\n const imported = new Map<string, { specifier: string; name: string }>();\n // The local names of compile-time functions in the component.\n const macroNames = new Map<string, string>();\n const topNames = new Set<string>();\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n for (const specifier of statement.specifiers) {\n topNames.add(specifier.local.name);\n if (specifier.type !== 'ImportSpecifier') {\n continue;\n }\n const name =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n if (reactive(statement.source.value)) {\n imported.set(specifier.local.name, { specifier: statement.source.value, name });\n } else if (statement.source.value === SIGNALS_MODULE && MACROS.has(name)) {\n macroNames.set(name, specifier.local.name);\n }\n }\n } else if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n topNames.add(id.name);\n }\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n topNames.add(statement.id.name);\n }\n }\n if (imported.size === 0) {\n return undefined;\n }\n\n // Each call must be the value of a destructuring at the top level of a script.\n const calls: Call[] = [];\n const allowed = new Set<oxc.Node>();\n for (const script of scripts(file)) {\n for (const statement of script.body) {\n if (statement.type !== 'VariableDeclaration') {\n continue;\n }\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (init?.type !== 'CallExpression' || init.callee.type !== 'Identifier') {\n continue;\n }\n if (!imported.has(init.callee.name)) {\n continue;\n }\n if (declarator.id.type !== 'ObjectPattern' || statement.declarations.length !== 1) {\n throw new ModuleError(\n `Destructure what ${init.callee.name} returns, as in const { value } = ${init.callee.name}(…)`,\n init.start,\n );\n }\n if (statement.kind !== 'const') {\n throw new ModuleError(\n `Declare what ${init.callee.name} returns with const`,\n statement.start,\n );\n }\n allowed.add(init);\n calls.push({ statement, call: init, pattern: declarator.id, local: init.callee.name });\n }\n }\n }\n for (const script of scripts(file)) {\n const find = (node: oxc.Node): void => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n imported.has(node.callee.name) &&\n !allowed.has(node)\n ) {\n throw new ModuleError(\n `Call ${node.callee.name} at the top level of a script, as in const { value } = ${node.callee.name}(…). Its signals become values of the component, so it cannot run in a function, a condition or a loop`,\n node.start,\n );\n }\n for (const [, child] of children(node)) {\n find(child);\n }\n };\n find(script);\n }\n if (calls.length === 0) {\n return undefined;\n }\n\n const modules = new Map<string, ModuleInfo>();\n const used = new Set(topNames);\n const unique = (name: string): string => {\n let candidate = name;\n for (let index = 2; used.has(candidate); index++) {\n candidate = `${name}${index}`;\n }\n used.add(candidate);\n return candidate;\n };\n // Imports that the copied code needs, by local name in the component.\n const imports = new Map<string, { specifier: string; imported: string }>();\n const macrosToImport = new Set<string>();\n\n // The imports that the copied code needs go right after `<script>`. They are known once every call is copied.\n const importsOffset =\n file.instanceScript!.start + source.slice(file.instanceScript!.start).indexOf('>') + 1;\n\n const expanded: ModuleCall[] = [];\n\n function inline(call: Call, builder: Builder): void {\n const site = { start: call.statement.start, end: call.statement.end };\n const generated = (text: string): void =>\n builder.add(text, { offset: call.statement.start }, false);\n const { specifier, name } = imported.get(call.local)!;\n const module = resolve(specifier, path);\n if (!module) {\n throw new ModuleError(`Cannot read ${specifier}`, call.call.start);\n }\n let info = modules.get(module.path);\n if (!info) {\n info = parseModule(module);\n modules.set(module.path, info);\n }\n const fn = info.functions.get(name);\n if (!fn) {\n throw new ModuleError(\n `${specifier} does not export a function named ${name}`,\n call.call.start,\n );\n }\n const body = fn.body;\n if (body?.type !== 'BlockStatement') {\n throw new ModuleError(`${name} needs a body that ends with return { … }`, call.call.start);\n }\n const last = body.body.at(-1);\n const returned = last?.type === 'ReturnStatement' ? last.argument : undefined;\n if (returned?.type !== 'ObjectExpression') {\n throw new ModuleError(\n `${name} must end with return { … }, an object of what it gives`,\n call.call.start,\n );\n }\n const checkReturns = (node: oxc.Node): void => {\n if (node === last) {\n return;\n }\n if (node.type === 'ReturnStatement') {\n throw new ModuleError(`${name} can return only at its end`, call.call.start);\n }\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n return;\n }\n for (const [, child] of children(node)) {\n checkReturns(child);\n }\n };\n for (const statement of body.body) {\n checkReturns(statement);\n }\n\n const origin = (offset: number): Origin => ({ module, offset, call: site });\n const renames = new Map<string, string>();\n // What each name of the function is in the component: a name, or a literal argument.\n const names = new Map<string, CallName>();\n const before: string[] = [];\n\n // What the component destructures, by the key that the function returns.\n const wanted = new Map<string, string>();\n for (const property of call.pattern.properties) {\n if (\n property.type === 'RestElement' ||\n property.computed ||\n property.key.type !== 'Identifier' ||\n property.value.type !== 'Identifier'\n ) {\n throw new ModuleError(\n `Destructure ${name} with plain names, as in const { value, other: renamed } = ${name}(…)`,\n property.start,\n );\n }\n wanted.set(property.key.name, property.value.name);\n }\n const keys = new Set<string>();\n for (const property of returned.properties) {\n if (\n property.type === 'SpreadElement' ||\n property.computed ||\n property.key.type !== 'Identifier'\n ) {\n throw new ModuleError(`${name} must return an object with plain keys`, call.call.start);\n }\n if (property.kind !== 'init') {\n throw new ModuleError(\n `${name} cannot return getters or setters. Return the values themselves`,\n call.call.start,\n );\n }\n keys.add(property.key.name);\n }\n for (const key of wanted.keys()) {\n if (!keys.has(key)) {\n throw new ModuleError(`${name} does not return ${key}`, call.call.start);\n }\n }\n\n // Names declared at the top of the body, and the parameters.\n const declared = new Set<string>();\n for (const statement of body.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n declared.add(id.name);\n }\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n declared.add(statement.id.name);\n }\n }\n // A returned local takes the name that the component gives it.\n const returnedNames = new Map<string, string>();\n for (const property of returned.properties as oxc.ObjectProperty[]) {\n const key = (property.key as oxc.IdentifierName).name;\n const target = wanted.get(key);\n if (\n target &&\n property.value.type === 'Identifier' &&\n declared.has(property.value.name) &&\n !renames.has(property.value.name)\n ) {\n if (used.has(target) && !topNames.has(target)) {\n throw new ModuleError(`${target} is declared twice`, call.statement.start);\n }\n used.add(target);\n renames.set(property.value.name, target);\n returnedNames.set(key, target);\n }\n }\n for (const local of declared) {\n if (!renames.has(local)) {\n renames.set(local, unique(`${name}_${local}`));\n }\n }\n\n // A parameter reads its argument in place when the argument is a name, so a signal stays\n // reactive, or a literal, so the value is in the code instead of in the state of the page.\n // A parameter that the function assigns to keeps a local of its own.\n const assigned = assignedNames(body);\n fn.params.forEach((param, index) => {\n const argument = call.call.arguments[index];\n const pattern = param.type === 'AssignmentPattern' ? param.left : param;\n if (pattern.type !== 'Identifier') {\n throw new ModuleError(`Parameters of ${name} must be plain names`, call.call.start);\n }\n if (!assigned.has(pattern.name) && argument?.type === 'Identifier') {\n renames.set(pattern.name, argument.name);\n names.set(pattern.name, { name: argument.name });\n return;\n }\n if (!assigned.has(pattern.name) && argument && isLiteral(argument)) {\n const text = source.slice(argument.start, argument.end);\n renames.set(pattern.name, text);\n names.set(pattern.name, { literal: text });\n return;\n }\n const local = unique(`${name}_${pattern.name}`);\n renames.set(pattern.name, local);\n const declare = assigned.has(pattern.name) ? 'let' : 'const';\n if (argument && argument.type !== 'SpreadElement') {\n before.push(local);\n generated(`${declare} ${local} = (`);\n builder.add(source.slice(argument.start, argument.end), { offset: argument.start }, true);\n generated(');\\n');\n } else if (param.type === 'AssignmentPattern') {\n generated(`${declare} ${local} = (`);\n copy(param.right);\n generated(');\\n');\n } else {\n generated(`${declare} ${local} = undefined;\\n`);\n }\n });\n\n for (const [local, renamed] of renames) {\n if (!names.has(local)) {\n names.set(local, { name: renamed });\n }\n }\n expanded.push({ start: call.statement.start, module: module.path, fn: name, names });\n\n // A name of the module that the body reads: imported into the component.\n const moduleName = (local: string): string | undefined => {\n const from = info!.imports.get(local);\n if (from?.specifier === SIGNALS_MODULE && MACROS.has(from.imported)) {\n const existing = macroNames.get(from.imported);\n if (existing) {\n return existing;\n }\n macrosToImport.add(from.imported);\n macroNames.set(from.imported, from.imported);\n used.add(from.imported);\n return from.imported;\n }\n let target: { specifier: string; imported: string } | undefined;\n if (from) {\n target = {\n specifier: relocate(from.specifier, module!.path, path),\n imported: from.imported,\n };\n } else if (info!.declarations.has(local)) {\n const exported = info!.declarations.get(local);\n if (!exported) {\n throw new ModuleError(\n `${name} reads ${local}, which ${specifier} does not export. Export it, so the component can import it`,\n call.call.start,\n );\n }\n target = {\n specifier: relocate(`./${module!.path.split('/').pop()}`, module!.path, path),\n imported: exported,\n };\n }\n if (!target) {\n return undefined;\n }\n for (const [existing, value] of imports) {\n if (value.specifier === target.specifier && value.imported === target.imported) {\n return existing;\n }\n }\n const alias = topNames.has(local) || used.has(local) ? unique(`${name}_${local}`) : local;\n used.add(alias);\n imports.set(alias, target);\n return alias;\n };\n\n /** Copies code of the module, with its names renamed. */\n function copy(node: oxc.Node): void {\n const edits: { start: number; end: number; text: string }[] = [];\n // The names that a statement at the top of the body declares get their new names too.\n const renameBinding = (id: oxc.Node, shorthand: boolean): void => {\n if (id.type !== 'Identifier') {\n return;\n }\n const renamed = renames.get(id.name);\n if (renamed && renamed !== id.name) {\n edits.push({\n start: id.start,\n end: id.start + id.name.length,\n text: shorthand ? `${id.name}: ${renamed}` : renamed,\n });\n }\n };\n const renamePattern = (pattern: oxc.Node): void => {\n switch (pattern.type) {\n case 'Identifier':\n renameBinding(pattern, false);\n break;\n case 'AssignmentPattern':\n renamePattern(pattern.left);\n break;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n renamePattern(element);\n }\n }\n break;\n case 'RestElement':\n renamePattern(pattern.argument);\n break;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n if (property.type === 'RestElement') {\n renamePattern(property.argument);\n } else if (property.shorthand && property.value.type === 'Identifier') {\n renameBinding(property.value, true);\n } else if (property.shorthand && property.value.type === 'AssignmentPattern') {\n renameBinding(property.value.left, true);\n } else {\n renamePattern(property.value);\n }\n }\n break;\n default:\n break;\n }\n };\n if (node.type === 'VariableDeclaration') {\n for (const declarator of node.declarations) {\n renamePattern(declarator.id);\n }\n } else if (\n (node.type === 'FunctionDeclaration' || node.type === 'ClassDeclaration') &&\n node.id\n ) {\n renameBinding(node.id, false);\n }\n forEachReference(node, (identifier, shorthand) => {\n const renamed = renames.get(identifier.name) ?? moduleName(identifier.name);\n if (renamed && renamed !== identifier.name) {\n edits.push({\n start: identifier.start,\n end: identifier.end,\n text: shorthand ? `${identifier.name}: ${renamed}` : renamed,\n });\n }\n });\n edits.sort((a, b) => a.start - b.start);\n let at = node.start;\n for (const edit of edits) {\n builder.add(module!.source.slice(at, edit.start), origin(at), true);\n builder.add(edit.text, origin(edit.start), false);\n at = edit.end;\n }\n builder.add(module!.source.slice(at, node.end), origin(at), true);\n }\n\n for (const statement of body.body) {\n if (statement !== last) {\n copy(statement);\n generated('\\n');\n }\n }\n // Returned values that are not locals of the body get the name that the component gives them.\n for (const property of returned.properties as oxc.ObjectProperty[]) {\n const key = (property.key as oxc.IdentifierName).name;\n const target = wanted.get(key);\n if (!target || returnedNames.has(key)) {\n continue;\n }\n used.add(target);\n // A method becomes a function expression with its parameters and body.\n generated(property.method ? `const ${target} = function ` : `const ${target} = `);\n copy(property.value);\n generated(';\\n');\n }\n }\n\n // The component's code after `<script>`, with each call replaced.\n const after = new Builder();\n let position = importsOffset;\n for (const call of calls.toSorted((a, b) => a.statement.start - b.statement.start)) {\n after.add(source.slice(position, call.statement.start), { offset: position }, true);\n inline(call, after);\n position = call.statement.end;\n }\n after.add(source.slice(position), { offset: position }, true);\n\n const builder = new Builder();\n builder.add(source.slice(0, importsOffset), { offset: 0 }, true);\n const lines: string[] = [];\n if (macrosToImport.size > 0) {\n lines.push(`\\nimport { ${[...macrosToImport].join(', ')} } from '${SIGNALS_MODULE}';`);\n }\n for (const [alias, { specifier, imported: name }] of imports) {\n if (name === '*') {\n lines.push(`\\nimport * as ${alias} from '${specifier}';`);\n } else if (name === 'default') {\n lines.push(`\\nimport ${alias} from '${specifier}';`);\n } else {\n const binding = name === alias ? name : `${name} as ${alias}`;\n lines.push(`\\nimport { ${binding} } from '${specifier}';`);\n }\n }\n builder.add(lines.join(''), { offset: importsOffset }, false);\n const offset = builder.text.length;\n for (const piece of after.pieces) {\n builder.pieces.push({ ...piece, start: piece.start + offset });\n }\n builder.text += after.text;\n\n return {\n source: builder.text,\n origin: (at) => builder.origin(at),\n modules: [...modules.values()].map((value) => value.module),\n calls: expanded,\n };\n}\n","import type { SFCFile } from '../ast.ts';\nimport { copy } from '../sourcemap.ts';\nimport type { Declaration, Reference, SemanticModel, Site } from '../model.ts';\nimport { children } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\n/** Rewrites ranges of the source with edits that do not overlap. */\nexport class Patch {\n private readonly source: string;\n private readonly edits: Edit[] = [];\n\n constructor(source: string) {\n this.source = source;\n }\n\n replace(start: number, end: number, text: string): void {\n this.edits.push({ start, end, text });\n }\n\n insert(offset: number, text: string): void {\n this.edits.push({ start: offset, end: offset, text });\n }\n\n slice(start: number, end: number): string {\n const edits = this.edits\n .filter((edit) => edit.start >= start && edit.end <= end)\n .toSorted((a, b) => a.start - b.start || a.end - b.end);\n let result = '';\n let position = start;\n for (const edit of edits) {\n result += copy(this.source, position, edit.start) + edit.text;\n position = edit.end;\n }\n return result + copy(this.source, position, end);\n }\n}\n\n/** The name of the function that a call expression calls, when it is a plain name. */\nfunction calleeName(node: oxc.CallExpression): string | undefined {\n return node.callee.type === 'Identifier' ? node.callee.name : undefined;\n}\n\n/** The variable that holds a memo on the server, which can be a promise. */\n/** The compile-time functions that declare a memo of their first argument. The others are options. */\nconst MEMOS = new Set(['$memo', '$optimistic', '$debounced', '$throttled']);\n\nexport function promiseName(name: string): string {\n return `$$p_${name}`;\n}\n\n/**\n * Adds edits that turn compile-time functions into plain values:\n * `$signal(x)` and `$memo(x)` become `(x)`, `$props()` becomes `$$props`\n * and `$untrack(x)` becomes `(x)`. On the server, a memo is renamed to\n * `$$p_<name>`, because it can hold a promise that is awaited where it is read.\n * The memos in `inline` are plain values on the server too.\n */\n/** The name of the key of a property, or undefined for a computed key. */\nfunction keyName(property: oxc.BindingProperty): string | undefined {\n if (property.computed) {\n return undefined;\n }\n if (property.key.type === 'Identifier') {\n return property.key.name;\n }\n return property.key.type === 'Literal' ? String(property.key.value) : undefined;\n}\n\nexport function addValueEdits(\n patch: Patch,\n file: SFCFile,\n sites: Site[],\n mode: 'server' | 'client' = 'server',\n inline: Set<Declaration> = new Set(),\n): void {\n const sitesByNode = new Map<object, Site>();\n // The names that each `$props()` destructures, by the call.\n const propNames = new Map<oxc.Node, string[]>();\n for (const statement of file.instanceScript?.program.body ?? []) {\n if (statement.type !== 'VariableDeclaration') {\n continue;\n }\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (\n init?.type === 'CallExpression' &&\n calleeName(init) === '$props' &&\n declarator.id.type === 'ObjectPattern'\n ) {\n propNames.set(\n init,\n declarator.id.properties.flatMap((property) => {\n const name = property.type === 'Property' ? keyName(property) : undefined;\n return name === undefined ? [] : [name];\n }),\n );\n }\n }\n }\n // Reads of memos with `await`, by the start of the `await` expression.\n const awaits = new Map<number, Reference>();\n // Reads that the edits of a memo replace, which the visit must leave alone.\n const replaced = new Set<Reference>();\n for (const site of sites) {\n sitesByNode.set(site.node, site);\n for (const read of site.reads) {\n if (read.await) {\n awaits.set(read.await.start, read);\n }\n }\n }\n const visit = (node: oxc.Node): void => {\n if (node.type === 'AwaitExpression') {\n const argument = node.argument;\n if (argument.type === 'CallExpression' && calleeName(argument) === '$memo') {\n // `await $memo(x)` waits where the memo is declared. The wait is in the render around.\n patch.replace(node.start, argument.start, '');\n visit(argument);\n return;\n }\n const read = awaits.get(node.start);\n if (read && !replaced.has(read)) {\n // `await name` of a memo is a read of its value, which the render around it waited for.\n patch.replace(node.start, node.end, read.declaration.name);\n return;\n }\n }\n if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {\n const name = node.callee.name;\n const argument = node.arguments[0];\n if (name === '$props') {\n // The props that the component destructures by name get the values of their bindings, and\n // a rest prop keeps them, so a spread passes them on. See `unbind`.\n const names = propNames.get(node);\n patch.replace(\n node.start,\n node.end,\n names ? `$$b.unbind($$props, ${JSON.stringify(names)})` : '$$b.unbind($$props)',\n );\n return;\n }\n if (name === '$action') {\n // The server reads the result of a form post to this page. The client gets it from the state.\n patch.replace(\n node.start,\n node.end,\n mode === 'server' && argument?.type === 'Identifier'\n ? `$$b.actionResult($$ctx, ${argument.name})`\n : 'undefined',\n );\n return;\n }\n if (name === '$isPending') {\n // Nothing loads again on the server.\n patch.replace(node.start, node.end, 'false');\n return;\n }\n if (name === '$produce' && argument?.type === 'Identifier') {\n // `$produce(todos, recipe)` becomes `(todos = $$b.produce(todos, recipe))`.\n patch.replace(node.start, argument.start, `(${argument.name} = $$b.produce(`);\n patch.insert(node.end, ')');\n for (const rest of node.arguments.slice(1)) {\n visit(rest);\n }\n return;\n }\n if (MEMOS.has(name!) || name === '$signal' || name === '$untrack') {\n if (!argument) {\n patch.replace(node.start, node.end, 'undefined');\n return;\n }\n const site = MEMOS.has(name!) ? sitesByNode.get(argument) : undefined;\n const declaration =\n site?.declaration && !inline.has(site.declaration) ? site.declaration : undefined;\n if (declaration && mode === 'server') {\n // Any memo can be a promise, so the server holds it as one and awaits it where it is read.\n patch.replace(\n declaration.range.start,\n declaration.range.end,\n promiseName(declaration.name),\n );\n }\n if (declaration && mode === 'server') {\n // The server computes a memo when it is read. Memos that it reads are read as memos,\n // so a value that is still loading stops it until the load settles.\n for (const read of site!.reads) {\n if (\n read.range.start !== read.range.end &&\n read.declaration !== declaration &&\n !inline.has(read.declaration) &&\n (read.declaration.kind === 'memo' || read.declaration.kind === 'async-memo')\n ) {\n // A read with `await` is the read: the value throws when it is still loading.\n const range = read.await ?? read.range;\n patch.replace(\n range.start,\n range.end,\n `$$b.read(${promiseName(read.declaration.name)})`,\n );\n replaced.add(read);\n }\n }\n patch.replace(\n node.start,\n argument.start,\n site!.awaits ? '$$b.memo(async () => (' : '$$b.memo(() => (',\n );\n // The render context, so server functions that the memo calls read the event of the page,\n // and the name of the memo, for the trace of the devtools.\n patch.replace(argument.end, node.end, `), $$ctx, ${JSON.stringify(declaration.name)})`);\n } else if (site?.awaits) {\n // `await` needs an async function, and then it does not hold up the code after it.\n patch.replace(node.start, argument.start, '(async () => (');\n patch.replace(argument.end, node.end, '))()');\n } else {\n patch.replace(node.start, argument.start, '(');\n patch.replace(argument.end, node.end, ')');\n }\n visit(argument);\n return;\n }\n }\n for (const [, child] of children(node)) {\n visit(child);\n }\n };\n const programs: oxc.Program[] = [];\n if (file.instanceScript) {\n programs.push(file.instanceScript.program);\n }\n for (const site of sites) {\n const body = site.scope.body;\n if (body?.script && !programs.includes(body.script.program)) {\n programs.push(body.script.program);\n }\n }\n for (const program of programs) {\n visit(program);\n }\n for (const site of sites) {\n const inScript = programs.some(\n (program) => site.node.start >= program.start && site.node.end <= program.end,\n );\n if (!inScript) {\n visit(site.node);\n }\n }\n}\n\n/** Applies JSX whitespace rules: lines are trimmed and whitespace-only lines are dropped. */\nexport function cleanText(value: string): string {\n if (!value.includes('\\n')) {\n return value;\n }\n const lines = value.split('\\n');\n const result: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i]!.replace(/\\t/g, ' ');\n if (i > 0) {\n line = line.trimStart();\n }\n if (i < lines.length - 1) {\n line = line.trimEnd();\n }\n if (line) {\n result.push(line);\n }\n }\n return result.join(' ');\n}\n\n/**\n * Turns `getEvent()` from `brumate/server` in the code of a component into\n * `$$ctx.getEvent()`, which reads the event of the render. The render awaits\n * memos in the middle of the code, so the event that the runtime sets for\n * the first part of a call would be gone. Server functions and the module\n * script keep `getEvent()`, which the runtime gives the event of their call.\n */\nexport function addEventEdits(patch: Patch, model: SemanticModel): void {\n for (const declaration of model.declarations) {\n if (\n declaration.kind !== 'import' ||\n declaration.imported?.source !== 'brumate/server' ||\n declaration.imported.name !== 'getEvent'\n ) {\n continue;\n }\n for (const read of declaration.reads) {\n if (read.site.kind !== 'server-function' && read.site.scope.kind !== 'module') {\n patch.replace(read.range.start, read.range.end, '$$ctx.getEvent');\n }\n }\n }\n}\n","// The code of module functions that runs in the browser, compiled once per\n// module. A component copies the body of a module function where it calls\n// it, so the graph stays static. Without sharing, the browser code of the\n// function would ship once for each call. Instead, each function of the\n// body that runs in the browser, and each memo and effect, is a function of\n// this module, and the component calls it with an object of cells: a getter\n// and a setter for each name of the function, which read and write the\n// values of that call.\n//\n// // counter.brm.ts?brumate-shared\n// export const s120 = ($$c) => { $$c.count++; };\n//\n// // a part of the component\n// const increment$ = ($$s, ...$$a) =>\n// $$m0.s120({ get count() { … }, set count($$v) { … } }, ...$$a);\n\nimport { MACROS, SIGNALS_MODULE } from './macros.ts';\nimport { forEachReference, parseModule } from './modules.ts';\nimport type { CallName, ModuleInfo, ReactiveModule } from './modules.ts';\nimport { children, getPatternNames } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\nimport { finish } from './sourcemap.ts';\nimport type { SourceMap } from './sourcemap.ts';\nimport { Patch } from './codegen/patch.ts';\n\n/** The query of the shared module of a module of reactive logic. */\nexport const SHARED_QUERY = '?brumate-shared';\n\n/** A piece of a module function that the shared module holds. */\nexport interface SharedSite {\n /** The name of its export. */\n name: string;\n /** A function, called with its arguments, or an expression, such as the value of a memo. */\n kind: 'function' | 'expression';\n /** The names of the function that it reads or writes, in the order of the refs that a call passes. */\n names: string[];\n /** The names of the function that it writes. */\n writes: string[];\n}\n\n/** Compile-time functions that need the component to compile them, so their code is not shared. */\nconst UNSHARED = new Set([\n '$isPending',\n '$id',\n '$getContext',\n '$setContext',\n '$title',\n '$action',\n '$props',\n // The reference of a handler names a part of the component that calls the function.\n '$handler',\n]);\n\ninterface Analysis {\n info: ModuleInfo;\n /** Sites by the offset of their node in the module. */\n sites: Map<number, { site: SharedSite; node: oxc.Node; locals: Set<string> }>;\n}\n\nconst analyses = new WeakMap<ReactiveModule, Analysis>();\n\nfunction isFunction(node: oxc.Node): node is oxc.Function | oxc.ArrowFunctionExpression {\n return (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n );\n}\n\nfunction analyze(module: ReactiveModule): Analysis {\n const cached = analyses.get(module);\n if (cached) {\n return cached;\n }\n const info = parseModule(module);\n // The local name of each compile-time function in the module.\n const macros = new Map<string, string>();\n for (const [local, from] of info.imports) {\n if (from.specifier === SIGNALS_MODULE && MACROS.has(from.imported)) {\n macros.set(local, from.imported);\n }\n }\n const sites = new Map<number, { site: SharedSite; node: oxc.Node; locals: Set<string> }>();\n for (const fn of info.functions.values()) {\n const body = fn.body;\n if (body?.type !== 'BlockStatement') {\n continue;\n }\n // The names of the function: its parameters and what its body declares.\n const locals = new Set<string>();\n for (const param of fn.params) {\n for (const id of getPatternNames(\n param.type === 'TSParameterProperty' ? param.parameter : param,\n )) {\n locals.add(id.name);\n }\n }\n for (const statement of body.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n locals.add(id.name);\n }\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n locals.add(statement.id.name);\n }\n }\n const candidates: oxc.Node[] = [];\n const macroArgument = (\n node: oxc.Node | null | undefined,\n names: string[],\n ): oxc.Node | undefined => {\n if (node?.type !== 'CallExpression' || node.callee.type !== 'Identifier') {\n return undefined;\n }\n const macro = macros.get(node.callee.name);\n return macro && names.includes(macro) ? node.arguments[0] : undefined;\n };\n for (const statement of body.body) {\n if (statement.type === 'FunctionDeclaration') {\n candidates.push(statement);\n } else if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (init && isFunction(init)) {\n candidates.push(init);\n }\n const memo = macroArgument(init, ['$memo']);\n if (memo) {\n candidates.push(memo);\n }\n }\n } else if (statement.type === 'ExpressionStatement') {\n const callback = macroArgument(statement.expression, ['$effect', '$client']);\n if (callback) {\n candidates.push(callback);\n }\n } else if (\n statement.type === 'ReturnStatement' &&\n statement.argument?.type === 'ObjectExpression'\n ) {\n for (const property of statement.argument.properties) {\n if (property.type === 'Property' && !property.method && isFunction(property.value)) {\n candidates.push(property.value);\n }\n }\n }\n }\n for (const node of candidates) {\n let shareable = true;\n const check = (current: oxc.Node): void => {\n if (\n current.type === 'CallExpression' &&\n current.callee.type === 'Identifier' &&\n UNSHARED.has(macros.get(current.callee.name) ?? '')\n ) {\n shareable = false;\n }\n if (\n current.type === 'ExpressionStatement' &&\n current.expression.type === 'Literal' &&\n current.expression.value === 'use server'\n ) {\n shareable = false;\n }\n for (const [, child] of children(current)) {\n check(child);\n }\n };\n check(node);\n if (!shareable) {\n continue;\n }\n const reads = new Set<string>();\n const writes = new Set<string>();\n forEachReference(node, (identifier) => {\n if (locals.has(identifier.name)) {\n reads.add(identifier.name);\n }\n });\n const findWrites = (current: oxc.Node): void => {\n let target: oxc.Node | undefined;\n if (current.type === 'AssignmentExpression') {\n target = current.left;\n } else if (current.type === 'UpdateExpression') {\n target = current.argument;\n } else if (\n current.type === 'CallExpression' &&\n current.callee.type === 'Identifier' &&\n macros.get(current.callee.name) === '$produce'\n ) {\n target = current.arguments[0];\n }\n if (target?.type === 'Identifier' && locals.has(target.name)) {\n writes.add(target.name);\n }\n for (const [, child] of children(current)) {\n findWrites(child);\n }\n };\n findWrites(node);\n sites.set(node.start, {\n node,\n locals,\n site: {\n name: `s${node.start}`,\n kind: isFunction(node) ? 'function' : 'expression',\n names: [...new Set([...reads, ...writes])],\n writes: [...writes],\n },\n });\n }\n }\n const analysis = { info, sites };\n analyses.set(module, analysis);\n return analysis;\n}\n\n/** The pieces of the functions of a module that its shared module holds, by their offset in the module. */\nexport function sharedSites(module: ReactiveModule): Map<number, SharedSite> {\n return new Map([...analyze(module).sites].map(([offset, { site }]) => [offset, site]));\n}\n\n/** The shared module of a module of reactive logic, as TypeScript, with its source map. */\nexport function generateShared(module: ReactiveModule): { code: string; map: SourceMap } {\n const { info, sites } = analyze(module);\n const macros = new Map<string, string>();\n for (const [local, from] of info.imports) {\n if (from.specifier === SIGNALS_MODULE && MACROS.has(from.imported)) {\n macros.set(local, from.imported);\n }\n }\n const usedImports = new Set<string>();\n const usedDeclarations = new Set<string>();\n let usesRuntime = false;\n const body: string[] = [];\n for (const { site, node, locals } of sites.values()) {\n const patch = new Patch(module.source);\n forEachReference(node, (identifier, shorthand) => {\n if (locals.has(identifier.name)) {\n patch.replace(\n identifier.start,\n identifier.end,\n shorthand ? `${identifier.name}: $$c.${identifier.name}` : `$$c.${identifier.name}`,\n );\n } else if (info.imports.has(identifier.name) && !macros.has(identifier.name)) {\n usedImports.add(identifier.name);\n } else if (info.declarations.has(identifier.name)) {\n usedDeclarations.add(identifier.name);\n }\n });\n // Compile-time functions become what they do at run time.\n const rewriteMacros = (current: oxc.Node): void => {\n if (current.type === 'CallExpression' && current.callee.type === 'Identifier') {\n const macro = macros.get(current.callee.name);\n const [first] = current.arguments;\n if (macro === '$untrack' && first) {\n patch.replace(current.start, first.start, '(');\n patch.replace(first.end, current.end, ')');\n } else if (macro === '$produce' && first?.type === 'Identifier' && locals.has(first.name)) {\n // `$produce(todos, recipe)` becomes `($$c.todos = $$b.produce($$c.todos, recipe))`.\n usesRuntime = true;\n patch.replace(\n current.start,\n first.end,\n `($$c.${first.name} = $$b.produce($$c.${first.name}`,\n );\n patch.insert(current.end, ')');\n }\n }\n for (const [, child] of children(current)) {\n rewriteMacros(child);\n }\n };\n rewriteMacros(node);\n // The names of the call, built once from the refs that the component passes.\n const cells = `const $$c: any = $$b.cells($$s, $$k, ${JSON.stringify(site.names)});`;\n if (site.kind === 'expression') {\n const awaits = module.source.slice(node.start, node.end).includes('await');\n body.push(\n `export const ${site.name} = ${awaits ? 'async ' : ''}($$s: any, $$k: any[]) => {\\n ${cells}\\n return (${patch.slice(node.start, node.end)});\\n};`,\n );\n continue;\n }\n const fn = node as oxc.Function | oxc.ArrowFunctionExpression;\n const params =\n fn.params.length > 0 ? `, ${patch.slice(fn.params[0]!.start, fn.params.at(-1)!.end)}` : '';\n const code = patch.slice(fn.body!.start, fn.body!.end);\n // The cells go first in the body. The body's text can start with a source map mark, so the\n // brace is found rather than taken as the first character.\n const brace = code.indexOf('{');\n const block =\n fn.body!.type === 'BlockStatement'\n ? `${code.slice(0, brace + 1)}\\n ${cells}${code.slice(brace + 1)}`\n : `{\\n ${cells}\\n return (${code});\\n}`;\n body.push(\n fn.type === 'ArrowFunctionExpression'\n ? `export const ${site.name} = ${fn.async ? 'async ' : ''}($$s: any, $$k: any[]${params}) => ${block};`\n : `export ${fn.async ? 'async ' : ''}function${fn.generator ? '*' : ''} ${site.name}($$s: any, $$k: any[]${params}) ${block}`,\n );\n }\n const self = `./${module.path.split('/').pop()}`;\n void usesRuntime;\n const header: string[] = [\"import * as $$b from 'brumate/client';\"];\n const bySpecifier = new Map<string, string[]>();\n for (const local of usedImports) {\n const { specifier, imported } = info.imports.get(local)!;\n if (imported === '*') {\n header.push(`import * as ${local} from ${JSON.stringify(specifier)};`);\n } else if (imported === 'default') {\n header.push(`import ${local} from ${JSON.stringify(specifier)};`);\n } else {\n bySpecifier.set(specifier, [\n ...(bySpecifier.get(specifier) ?? []),\n imported === local ? local : `${imported} as ${local}`,\n ]);\n }\n }\n // Exported declarations of the module itself. The component already needs them exported.\n const own = [...usedDeclarations].filter((local) => info.declarations.get(local));\n if (own.length > 0) {\n bySpecifier.set(self, [\n ...(bySpecifier.get(self) ?? []),\n ...own.map((local) =>\n info.declarations.get(local) === local\n ? local\n : `${info.declarations.get(local)} as ${local}`,\n ),\n ]);\n }\n for (const [specifier, names] of bySpecifier) {\n header.push(`import { ${names.join(', ')} } from ${JSON.stringify(specifier)};`);\n }\n const marked = [...header, '', ...body, ''].join('\\n');\n return finish(marked, [{ name: module.path, content: module.source }]);\n}\n\n/** What code generation needs to call shared code instead of copying it. */\nexport interface SharedContext {\n /**\n * The shared site of a node of the compiled source, if the node is code of\n * a module function that the component calls, with what the names of the\n * function are in that call.\n */\n find(\n node: oxc.Node,\n ): { module: number; site: SharedSite; names: Map<string, CallName> } | undefined;\n /** The import specifier of each shared module, relative to the component. */\n specifiers: string[];\n}\n","import { builtin } from './node.ts';\nimport { parse } from 'postcss';\nimport type { AtRule, Root } from 'postcss';\nimport selectorParser from 'postcss-selector-parser';\nimport type { Expression, SFCFile } from './ast.ts';\nimport type { Diagnostic } from './model.ts';\n\nexport interface StyleOutput {\n /** The scoped CSS of every `<style>` block, or an empty string. */\n css: string;\n /** The attribute that marks the component's elements, such as `s-1abc`. */\n attribute: string;\n /**\n * The custom property for each `${…}` interpolation, in source order. Text\n * right before or after it, such as a unit in `${size}px`, is part of the\n * value, because `var(--x)px` is not valid CSS.\n */\n variables: { name: string; expression: Expression; prefix: string; suffix: string }[];\n diagnostics: Diagnostic[];\n /** Absolute paths of the files that SCSS or Less imported. */\n dependencies: string[];\n /**\n * The compound selectors that got the scope attribute, by what an element\n * needs to match one. See `needsScope`.\n */\n targets: ScopeTarget[];\n}\n\n/**\n * What a scoped compound selector needs of an element: its tag, in lower\n * case, and its classes. A compound without either can match any element.\n */\nexport interface ScopeTarget {\n tag?: string;\n classes: string[];\n}\n\n/**\n * True if a scoped selector could match an element, so the element needs the\n * scope attribute. `tag` is undefined when it is not known at compile time,\n * and `classes` is undefined when the element can have classes that are not\n * known.\n */\nexport function needsScope(\n targets: ScopeTarget[],\n tag: string | undefined,\n classes: string[] | undefined,\n): boolean {\n const lower = tag?.toLowerCase();\n return targets.some(\n (target) =>\n (target.tag === undefined || lower === undefined || target.tag === lower) &&\n (classes === undefined || target.classes.every((name) => classes.includes(name))),\n );\n}\n\n/** What an element needs to match a compound. Selectors inside pseudo-classes are not read. */\nfunction scopeTarget(compound: SelectorPart[]): ScopeTarget {\n const target: ScopeTarget = { classes: [] };\n for (const node of compound) {\n if (node.type === 'tag') {\n target.tag = node.value.toLowerCase();\n } else if (node.type === 'class') {\n target.classes.push(node.value);\n }\n }\n return target;\n}\n\ntype SelectorPart = Parameters<Parameters<selectorParser.Selector['each']>[0]>[0];\n\n/**\n * Adds the scope attribute to every compound selector, except inside\n * `:global(…)`. Each scoped compound goes into `targets`.\n */\nconst scopeSelector = (attribute: string, targets: ScopeTarget[]) =>\n selectorParser((selectors) => {\n // `:global(h1, h2)` is a list: the selector around it becomes one selector for each item.\n for (let index = 0; index < selectors.nodes.length; index++) {\n const selector = selectors.nodes[index]!;\n let list: selectorParser.Pseudo | undefined;\n selector.walkPseudos((pseudo) => {\n if (!list && pseudo.value === ':global' && pseudo.nodes.length > 1) {\n list = pseudo;\n }\n });\n if (!list) {\n continue;\n }\n const items = list.nodes;\n const copies = items.map((_, item) => {\n const copy = selector.clone() as selectorParser.Selector;\n let found: selectorParser.Pseudo | undefined;\n copy.walkPseudos((pseudo) => {\n if (!found && pseudo.value === ':global' && pseudo.nodes.length > 1) {\n found = pseudo;\n }\n });\n const only = found!.nodes[item]!;\n // The space after the comma of the list.\n if (only.first) {\n only.first.spaces.before = '';\n }\n found!.nodes = [only];\n return copy;\n });\n selector.replaceWith(...copies);\n // The copies can hold another list, so they are looked at again.\n index--;\n }\n selectors.each((selector) => {\n // Split the selector into compounds at combinators.\n const compounds: SelectorPart[][] = [[]];\n selector.each((node) => {\n if (node.type === 'combinator') {\n compounds.push([]);\n } else {\n compounds.at(-1)!.push(node);\n }\n });\n for (const compound of compounds) {\n const global = compound.find(\n (node): node is selectorParser.Pseudo =>\n node.type === 'pseudo' && node.value === ':global',\n );\n if (global) {\n // `:global(.a)` becomes `.a`, without the scope.\n const inner = global.nodes[0]?.nodes ?? [];\n global.replaceWith(...inner.map((node) => node.clone()));\n continue;\n }\n if (compound.length === 0) {\n continue;\n }\n targets.push(scopeTarget(compound));\n // The attribute goes before pseudo-elements such as `::before`.\n const last = compound.findLast(\n (node) => !(node.type === 'pseudo' && node.value.startsWith('::')),\n );\n const scope = selectorParser.attribute({ attribute, value: undefined, raws: {} } as never);\n if (last) {\n selector.insertAfter(last, scope);\n } else {\n selector.insertBefore(compound[0]!, scope);\n }\n }\n });\n });\n\nfunction scopeRules(root: Root, attribute: string, targets: ScopeTarget[]): void {\n const processor = scopeSelector(attribute, targets);\n root.walkRules((rule) => {\n // Keyframe steps such as `from` and `50%` are not selectors.\n if (rule.parent?.type === 'atrule' && /keyframes$/i.test((rule.parent as AtRule).name)) {\n return;\n }\n rule.selector = processor.processSync(rule.selector);\n });\n}\n\n/** Line breaks in a selector, value or at-rule are whitespace, because strings cannot hold them. */\nfunction collapse(text: string): string {\n return text.replace(/\\s*\\n\\s*/g, ' ').trim();\n}\n\n/**\n * Removes the comments and the whitespace that CSS does not need, for a\n * build. Comments that start with `/*!`, such as licenses, stay.\n */\nexport function minifyCSS(css: string): string {\n if (!css) {\n return css;\n }\n const root = parse(css);\n root.raws.after = '';\n root.raws.semicolon = false;\n root.walk((node) => {\n node.raws.before = '';\n switch (node.type) {\n case 'comment':\n if (!node.text.startsWith('!')) {\n node.remove();\n }\n break;\n case 'decl':\n node.raws.between = ':';\n // The raw value holds comments.\n delete node.raws.value;\n node.value = collapse(node.value);\n if (node.important) {\n node.raws.important = '!important';\n }\n break;\n case 'rule':\n delete node.raws.selector;\n node.selector = collapse(node.selector);\n node.raws.between = '';\n node.raws.after = '';\n node.raws.semicolon = false;\n break;\n case 'atrule':\n delete node.raws.params;\n node.params = collapse(node.params);\n node.raws.afterName = node.params ? ' ' : '';\n node.raws.between = '';\n node.raws.after = '';\n node.raws.semicolon = false;\n break;\n }\n });\n return root.toString();\n}\n\n/**\n * Loads a style preprocessor from the project, or from beside this package.\n * Returns undefined when it is not installed.\n */\nfunction loadPreprocessor<T>(name: string): T | undefined {\n const module = builtin('node:module');\n const path = builtin('node:path');\n if (!module || !path) {\n // In a browser, preprocessors are not available.\n return undefined;\n }\n for (const base of [path.join(process.cwd(), 'package.json'), import.meta.url]) {\n try {\n return module.createRequire(base)(name) as T;\n } catch {\n // Not installed here.\n }\n }\n return undefined;\n}\n\ninterface Sass {\n compileString(\n source: string,\n options: { syntax: 'scss'; url?: URL },\n ): { css: string; loadedUrls: URL[] };\n}\n\ninterface Less {\n render(\n source: string,\n options: { syncImport: boolean; filename?: string },\n callback: (\n error: Error | undefined,\n output: { css: string; imports: string[] } | undefined,\n ) => void,\n ): void;\n}\n\n/**\n * Turns SCSS or Less into CSS. `file` is the absolute path of the component,\n * for imports of files next to it. Throws with a message when it cannot.\n */\nfunction preprocess(\n lang: 'scss' | 'less',\n source: string,\n file: string | undefined,\n dependencies: string[],\n): string {\n if (lang === 'scss') {\n const sass = loadPreprocessor<Sass>('sass');\n if (!sass) {\n throw new Error('<style lang=\"scss\"> needs the sass package. Install it in the project');\n }\n const url = builtin('node:url')!;\n const result = sass.compileString(source, {\n syntax: 'scss',\n url: file ? url.pathToFileURL(file) : undefined,\n });\n for (const loaded of result.loadedUrls) {\n if (loaded.protocol === 'file:' && url.fileURLToPath(loaded) !== file) {\n dependencies.push(url.fileURLToPath(loaded));\n }\n }\n return result.css;\n }\n const less = loadPreprocessor<Less>('less');\n if (!less) {\n throw new Error('<style lang=\"less\"> needs the less package. Install it in the project');\n }\n let css: string | undefined;\n let failure: Error | undefined;\n // Less calls back before render returns when nothing is imported.\n less.render(source, { syncImport: true, filename: file }, (error, output) => {\n failure = error;\n css = output?.css;\n dependencies.push(...(output?.imports ?? []));\n });\n if (failure) {\n throw failure;\n }\n if (css === undefined) {\n throw new Error('Less did not finish. Imports that load over the network are not supported');\n }\n return css;\n}\n\n/** Compiles the `<style>` blocks of a file into scoped CSS. */\nexport function compileStyles(file: SFCFile, scope: string, filePath?: string): StyleOutput {\n const attribute = `s-${scope}`;\n const diagnostics: Diagnostic[] = [];\n const variables: StyleOutput['variables'] = [];\n const dependencies: string[] = [];\n const parts: string[] = [];\n const targets: ScopeTarget[] = [];\n for (const style of file.styles) {\n // Interpolations become custom properties. Offsets in `content` start after `<style>`.\n const contentStart = file.source.indexOf(style.content, style.start);\n let content = '';\n let position = 0;\n for (const expression of style.variables) {\n const name = `--${attribute}-${variables.length}`;\n let start = expression.start - 2 - contentStart;\n let end = expression.end + 1 - contentStart;\n // Text that touches the interpolation, such as `px` or `#`, goes into the value.\n const prefixStart = start;\n while (start > position && /[#\\w.%-]/.test(style.content[start - 1]!)) {\n start--;\n }\n const prefix = style.content.slice(start, prefixStart);\n const suffixStart = end;\n while (end < style.content.length && /[\\w.%-]/.test(style.content[end]!)) {\n end++;\n }\n const suffix = style.content.slice(suffixStart, end);\n variables.push({ name, expression, prefix, suffix });\n content += `${style.content.slice(position, start)}var(${name})`;\n position = end;\n }\n content += style.content.slice(position);\n try {\n const root = parse(\n style.lang === 'css' ? content : preprocess(style.lang, content, filePath, dependencies),\n );\n scopeRules(root, attribute, targets);\n parts.push(root.toString().trim());\n } catch (error) {\n diagnostics.push({\n severity: 'error',\n message:\n style.lang === 'css'\n ? `Invalid CSS: ${(error as Error).message}`\n : (error as Error).message,\n range: { start: style.start, end: style.end },\n });\n }\n }\n return { css: parts.join('\\n'), attribute, variables, diagnostics, dependencies, targets };\n}\n","import type { oxc } from './oxc.ts';\nimport type { Block, Body, ElementNode, InsertNode, Markup, SFCFile } from './ast.ts';\nimport { cleanText } from './codegen/patch.ts';\nimport { isFunctionValue, isTemplateValue, resetUsed, tryCatchesClient } from './graph.ts';\nimport type { Graph } from './graph.ts';\nimport { compileStyles } from './css.ts';\nimport type { StyleOutput } from './css.ts';\nimport type { Declaration, DeclarationKind, Diagnostic, Scope, Site } from './model.ts';\n\nexport interface ScopePlan {\n scope: Scope;\n /** Declarations that client code reads, in slot order. */\n slots: Declaration[];\n /** True if the scope gets an ID at render time. */\n needsId: boolean;\n /** The number of anchors in the scope. */\n anchors: number;\n}\n\n/** A node without the parentheses around it. */\nfunction unparen(node: oxc.Node): oxc.Node {\n let current = node;\n while (current.type === 'ParenthesizedExpression') {\n current = current.expression;\n }\n return current;\n}\n\n/** A markup node or a site that the client must find in the page. */\nexport type AnchorTarget = Markup | Site;\n\nexport interface Plan {\n graph: Graph;\n /** The name of the component function, from the file name. */\n name: string;\n /** Identifies the component in handler references. */\n id: string;\n scopes: Map<Scope, ScopePlan>;\n /** The scope of each body, including template bodies. */\n bodyScopes: Map<Body, Scope>;\n /** The anchor index of a node within its scope. */\n anchors: Map<AnchorTarget, number>;\n /** The scope of each anchor, for the devtools, which find an element by its scope and anchor. */\n anchorScopes: Map<AnchorTarget, Scope>;\n /**\n * Inserts that are the only content of their element. They share the\n * element's anchor and update its children, so they have no markers.\n */\n contents: Set<Markup>;\n /**\n * The inserts of `contents` whose element holds text, such as a\n * `<textarea>` or a `<title>`. The client sets the element's text.\n */\n textContents: Set<Markup>;\n /**\n * Lists whose item bodies are one element. The element's `b-b` marks\n * the item, in place of `<!--i…-->` and `<!--/i-->`.\n */\n elementItems: Set<Block>;\n /** The export name of each client root, such as `h3`. */\n symbols: Map<Site, string>;\n /** Sites whose code runs on the client, including update code for live nodes. */\n clientSites: Set<Site>;\n /** The compiled `<style>` blocks. */\n styles: StyleOutput;\n /** True if a style variable can change on the client. */\n liveStyles: boolean;\n /** True when server function IDs hash the names of the functions. */\n hideNames: boolean;\n /** Errors in markup that the client could not update. */\n diagnostics: Diagnostic[];\n}\n\n/**\n * Elements that the HTML parser can end before their end tag, or whose\n * content it moves out, when they hold some other elements: a `<p>` ends at\n * a `<div>`, and a `<table>` moves out content that is not part of a table.\n */\nconst UNSTABLE = new Set([\n 'p',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'dt',\n 'dd',\n 'option',\n 'optgroup',\n 'select',\n 'rb',\n 'rp',\n 'rt',\n 'rtc',\n 'table',\n 'caption',\n 'colgroup',\n 'thead',\n 'tbody',\n 'tfoot',\n 'template',\n]);\n\n/**\n * True if the browser keeps the element's content inside it, whatever that\n * content renders. Then an element inside it can find it with `closest`, and\n * it can stand for a list item. A `<tr>` is one when it holds only cells.\n */\nfunction isStable(node: ElementNode): boolean {\n const tag = node.tag.toLowerCase();\n if (tag === 'tr') {\n return node.children.every((child) =>\n child.kind === 'text'\n ? cleanText(child.value).trim() === ''\n : child.kind === 'element' && ['td', 'th'].includes(child.tag.toLowerCase()),\n );\n }\n return !UNSTABLE.has(tag);\n}\n\n/**\n * Elements whose content is text, where a comment would be text too. The\n * parser reads `<script>` and `<style>` itself, so only these reach markup.\n */\nconst RAW_TEXT = new Set(['textarea', 'title']);\n\n// Declarations that are code or come from imports, so they never need a slot.\nconst NO_SLOT = new Set<DeclarationKind>([\n 'import',\n 'module',\n 'function',\n 'server-function',\n 'template',\n 'reset',\n]);\n\n/** Returns the component name for a file name, such as `TodoList` for `todo-list.brm`. */\nexport function getComponentName(filename: string): string {\n const base = filename\n .split(/[\\\\/]/)\n .pop()!\n .replace(/\\.[^.]*$/, '');\n const name = base\n .split(/[^A-Za-z0-9]+/)\n .filter(Boolean)\n .map((part) => part[0]!.toUpperCase() + part.slice(1))\n .join('');\n return /^\\d/.test(name) ? `Component${name}` : name || 'Component';\n}\n\n/**\n * The ID of a server function: the component or file ID, and the name of the\n * function, or a hash of it, so a production build does not show the names.\n */\nexport function functionId(owner: string, name: string, hidden = false): string {\n return `${owner}#${hidden ? `f${hash(`${owner}#${name}`)}` : name}`;\n}\n\n/** The ID of a server function of a component. */\nexport function serverFunctionId(plan: Plan, name: string): string {\n return functionId(plan.id, name, plan.hideNames);\n}\n\n/** A short, stable hash of a string, in base 36. */\nexport function hash(value: string): string {\n let result = 0x811c9dc5;\n for (let i = 0; i < value.length; i++) {\n result ^= value.charCodeAt(i);\n result = Math.imul(result, 0x01000193);\n }\n return (result >>> 0).toString(36);\n}\n\n/**\n * Finds the code that runs on the client, and the declarations that it\n * reads, by scope. Those declarations are the slots: the server writes\n * their values into the page state.\n */\nexport function clientState(graph: Graph): {\n isLiveSite: (site: Site) => boolean;\n clientSites: Set<Site>;\n slots: Map<Scope, Declaration[]>;\n} {\n const model = graph.model;\n const siteNodes = new Map<Site, boolean>();\n for (const node of graph.nodes) {\n if (node.kind !== 'source') {\n siteNodes.set(node.site, graph.live.has(node));\n }\n }\n const isLiveSite = (site: Site): boolean => siteNodes.get(site) === true;\n\n // Code on the client: reached sites, live nodes, and the functions they call.\n const clientSites = new Set<Site>();\n const addClientSite = (site: Site): void => {\n if (clientSites.has(site)) {\n return;\n }\n clientSites.add(site);\n for (const callee of site.calls) {\n if (callee.kind === 'function' && callee.site) {\n addClientSite(callee.site);\n }\n }\n };\n for (const site of model.sites) {\n if (graph.reached.has(site) || isLiveSite(site)) {\n addClientSite(site);\n }\n }\n\n const slots = new Map<Scope, Declaration[]>();\n for (const scope of model.scopes) {\n if (scope.kind === 'module') {\n continue;\n }\n slots.set(\n scope,\n [...scope.declarations.values()].filter(\n (declaration) =>\n !NO_SLOT.has(declaration.kind) &&\n (declaration.reads.some((read) => clientSites.has(read.site)) ||\n // A binding writes the slot of its name, and a bound prop writes the parent's\n // through its own, so they need slots without a read in the browser.\n declaration.bound === true ||\n (declaration.kind === 'prop' &&\n declaration.writable === true &&\n declaration.writes.some((write) => clientSites.has(write.site)))),\n ),\n );\n }\n return { isLiveSite, clientSites, slots };\n}\n\nexport function createPlan(file: SFCFile, graph: Graph, path?: string, hideNames = false): Plan {\n const model = graph.model;\n const name = getComponentName(file.filename);\n const bodyScopes = new Map<Body, Scope>();\n for (const scope of model.scopes) {\n if (scope.body) {\n bodyScopes.set(scope.body, scope);\n }\n }\n\n const { isLiveSite, clientSites, slots: slotLists } = clientState(graph);\n const scopes = new Map<Scope, ScopePlan>();\n for (const [scope, slots] of slotLists) {\n scopes.set(scope, { scope, slots, needsId: scope.kind === 'component', anchors: 0 });\n }\n\n // The `$bind` calls of the file, which make an element bind a value.\n const boundCalls = new Set<oxc.Node>(model.bindings.map((binding) => binding.call));\n const anchors = new Map<AnchorTarget, number>();\n const anchorScopes = new Map<AnchorTarget, Scope>();\n const anchor = (scope: Scope, target: AnchorTarget): void => {\n const plan = scopes.get(scope)!;\n anchors.set(target, plan.anchors++);\n anchorScopes.set(target, scope);\n plan.needsId = true;\n };\n\n const symbols = new Map<Site, string>();\n for (const site of model.sites) {\n if (site.kind === 'prop' && isTemplateValue(site)) {\n // A template that a component renders in the browser, which the core calls at once.\n symbols.set(site, `t${site.id}`);\n } else if (site.kind === 'event' || (site.kind === 'prop' && isFunctionValue(site))) {\n symbols.set(site, `h${site.id}`);\n } else if (site.kind === 'client') {\n symbols.set(site, `c${site.id}`);\n anchor(site.scope, site);\n }\n }\n\n const sitesByNode = new Map<object, Site[]>();\n for (const site of model.sites) {\n if (site.owner) {\n const list = sitesByNode.get(site.owner) ?? [];\n list.push(site);\n sitesByNode.set(site.owner, list);\n }\n }\n const insertSites = new Map<object, Site>();\n for (const site of model.sites) {\n if (site.kind === 'insert') {\n insertSites.set(site.node, site);\n }\n }\n const headerSites = new Map<Block, Site[]>();\n for (const site of model.sites) {\n if (site.kind === 'block' && site.block && site.label !== 'for key') {\n const list = headerSites.get(site.block) ?? [];\n list.push(site);\n headerSites.set(site.block, list);\n }\n }\n const refTargets = new Map<object, Declaration>();\n for (const declaration of model.declarations) {\n for (const ref of declaration.refs) {\n refTargets.set(ref.attribute, declaration);\n }\n }\n const slotted = new Set<Declaration>();\n for (const plan of scopes.values()) {\n for (const declaration of plan.slots) {\n slotted.add(declaration);\n }\n }\n\n const contents = new Set<Markup>();\n const textContents = new Set<Markup>();\n const diagnostics: Diagnostic[] = [];\n const elementItems = new Set<Block>();\n // Root elements of list items, which get an anchor so they mark their item.\n const itemRoots = new Set<Markup>();\n\n // `outer` is the scope of the nearest element around the nodes that has an anchor, in the same\n // markup. An element inside it in the same scope finds its handlers' scope from that anchor.\n const visitBody = (body: Body, outer?: Scope): void => {\n const scope = bodyScopes.get(body)!;\n for (const template of body.templates) {\n visitBody(template.body);\n }\n visitNodes(body.children, scope, outer);\n };\n\n const visitNodes = (nodes: Markup[], scope: Scope, outer?: Scope): void => {\n for (const node of nodes) {\n visitNode(node, scope, outer);\n }\n };\n\n const visitNode = (node: Markup, scope: Scope, outer?: Scope): void => {\n switch (node.kind) {\n case 'text':\n return;\n case 'insert': {\n const site = insertSites.get(node.expression.ast);\n if (site && isLiveSite(site)) {\n anchor(scope, node);\n }\n return;\n }\n case 'element':\n case 'dynamic': {\n const sites = sitesByNode.get(node) ?? [];\n const hasRef =\n node.kind === 'element' &&\n node.attributes.some((attribute) => {\n const target = attribute.kind === 'ref' ? refTargets.get(attribute) : undefined;\n return target !== undefined && slotted.has(target);\n });\n const content = node.kind === 'element' ? liveContent(node) : undefined;\n const events = sites.some((site) => site.kind === 'event');\n // `value=$bind(name)`: the core finds the scope of the name from the anchor of the element.\n const bound =\n node.kind === 'element' &&\n node.attributes.some(\n (attribute) =>\n attribute.kind === 'value' && boundCalls.has(unparen(attribute.value.ast)),\n );\n // An element whose only anchor would be for its handlers finds their scope from\n // the anchor of an element around it, with `closest`.\n const implied = node.kind === 'element' && outer === scope;\n if (\n hasRef ||\n bound ||\n content ||\n itemRoots.has(node) ||\n sites.some((site) => isLiveSite(site)) ||\n (events && !implied)\n ) {\n anchor(scope, node);\n }\n if (content) {\n anchors.set(content, anchors.get(node)!);\n anchorScopes.set(content, scope);\n contents.add(content);\n if (node.kind === 'element' && RAW_TEXT.has(node.tag.toLowerCase())) {\n textContents.add(content);\n }\n return;\n }\n // The children of a dynamic tag can render inside a component. An element that the\n // browser can end early, before its children, is not one that they can find.\n let inner = outer;\n if (node.kind === 'dynamic') {\n inner = undefined;\n } else if (anchors.has(node)) {\n inner = isStable(node) ? scope : undefined;\n }\n visitNodes(node.children, scope, inner);\n if (node.kind === 'element' && RAW_TEXT.has(node.tag.toLowerCase())) {\n checkText(node);\n }\n return;\n }\n case 'component': {\n const sites = sitesByNode.get(node) ?? [];\n if (sites.some((site) => isLiveSite(site))) {\n anchor(scope, node);\n }\n // Children render inside the component's elements.\n visitNodes(node.children, scope);\n return;\n }\n case 'fragment':\n visitNodes(node.children, scope, outer);\n return;\n case 'listener':\n anchor(scope, node);\n return;\n default:\n visitBlock(node, scope, outer);\n }\n };\n\n /**\n * Reports live markup inside an element whose content is text. Its markers\n * would be text, so the client can only update a value that is the whole content.\n */\n const checkText = (element: ElementNode): void => {\n const found = firstAnchored(element.children, anchors);\n if (found) {\n const tag = element.tag.toLowerCase();\n diagnostics.push({\n severity: 'error',\n message: `A value that changes in <${tag}> must be its whole content, such as <${tag}>{\\`Count \\${count}\\`}</${tag}>`,\n range: { start: found.start, end: found.end },\n });\n }\n };\n\n /** The live insert that is the whole content of an element, if any. */\n const liveContent = (node: ElementNode): InsertNode | undefined => {\n const [only, ...rest] = node.children.filter(\n (child) => child.kind !== 'text' || cleanText(child.value) !== '',\n );\n if (rest.length > 0 || only?.kind !== 'insert') {\n return undefined;\n }\n const site = insertSites.get(only.expression.ast);\n return site && isLiveSite(site) ? only : undefined;\n };\n\n const visitBlock = (block: Block, scope: Scope, outer?: Scope): void => {\n const portalTarget = block.kind === 'portal' && block.target !== undefined;\n const live =\n block.kind === 'client' ||\n // The browser asks for the body of a `#defer` block by its anchor.\n block.kind === 'defer' ||\n portalTarget ||\n (block.kind === 'try' &&\n (resetUsed(model, block, graph.reached) || tryCatchesClient(model, block))) ||\n (headerSites.get(block) ?? []).some((site) => isLiveSite(site));\n if (live) {\n anchor(scope, block);\n }\n if (live && block.kind === 'offscreen') {\n // The client hides and shows the body's instance, and pauses the effects inside it.\n scopes.get(bodyScopes.get(block.body)!)!.needsId = true;\n }\n if (block.kind === 'portal' || block.kind === 'head') {\n // Portal content is marked with its scope ID, so it can be removed with its block.\n scopes.get(bodyScopes.get(block.body)!)!.needsId = true;\n }\n // Portal and head content renders elsewhere in the page.\n const inner = block.kind === 'portal' || block.kind === 'head' ? undefined : outer;\n for (const body of blockBodies(block)) {\n if (live && (block.kind === 'for' || block.kind === 'repeat') && body === block.body) {\n // Each item gets an ID for its marker.\n scopes.get(bodyScopes.get(body)!)!.needsId = true;\n const root = singleRoot(body);\n if (root) {\n itemRoots.add(root);\n elementItems.add(block);\n }\n }\n visitBody(body, inner);\n }\n };\n\n /** The element that is the whole markup of a body, when nothing else renders next to it. */\n const singleRoot = (body: Body): Markup | undefined => {\n const scope = bodyScopes.get(body)!;\n // `$client` callbacks render `<template>` markers next to the markup.\n if (\n body.templates.length > 0 ||\n model.sites.some((site) => site.kind === 'client' && site.scope === scope)\n ) {\n return undefined;\n }\n const [only, ...rest] = body.children.filter(\n (child) => child.kind !== 'text' || cleanText(child.value) !== '',\n );\n return rest.length === 0 && only?.kind === 'element' && isStable(only) ? only : undefined;\n };\n\n for (const template of file.templates) {\n visitBody(template.body);\n }\n visitNodes(file.children, model.component);\n\n // A `<title>` sets the title of the page from `#head`, as the tags of the head do. One in a\n // `<head>` element is the head's own, and one in an `<svg>` names a shape.\n const checkTitles = (nodes: Markup[], inHead: boolean): void => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'element': {\n const tag = node.tag.toLowerCase();\n if (tag === 'title' && !inHead) {\n diagnostics.push({\n severity: 'error',\n message:\n 'Put <title> in #head, as <meta> and <link>, such as #head { <title>{`${count} left`}</title> }',\n range: { start: node.start, end: node.end },\n });\n } else if (tag !== 'head' && tag !== 'svg') {\n checkTitles(node.children, inHead);\n }\n break;\n }\n case 'component':\n case 'dynamic':\n case 'fragment':\n checkTitles(node.children, inHead);\n break;\n case 'text':\n case 'insert':\n case 'listener':\n break;\n default:\n for (const body of blockBodies(node)) {\n checkTitles(body.children, inHead || node.kind === 'head');\n }\n }\n }\n };\n for (const template of file.templates) {\n checkTitles(template.body.children, false);\n }\n checkTitles(file.children, false);\n\n for (const plan of scopes.values()) {\n if (plan.slots.length > 0) {\n plan.needsId = true;\n }\n // IDs from `$id()` are made from the scope's ID, so each instance needs its own.\n if (\n [...plan.scope.declarations.values()].some((declaration) => declaration.idIndex !== undefined)\n ) {\n plan.needsId = true;\n }\n }\n\n const styles = compileStyles(file, hash(file.filename), path);\n const liveStyles = model.sites.some((site) => site.kind === 'style' && isLiveSite(site));\n\n return {\n graph,\n name,\n id: `${name}_${hash(file.filename)}`,\n styles,\n liveStyles,\n hideNames,\n scopes,\n bodyScopes,\n anchors,\n anchorScopes,\n contents,\n textContents,\n elementItems,\n symbols,\n clientSites,\n diagnostics,\n };\n}\n\n/** The first node in the markup that has an anchor, at any depth. */\nfunction firstAnchored(nodes: Markup[], anchors: Map<AnchorTarget, number>): Markup | undefined {\n for (const node of nodes) {\n const found = anchors.has(node) ? node : firstAnchored(childNodes(node), anchors);\n if (found) {\n return found;\n }\n }\n return undefined;\n}\n\n/** Returns the markup inside a node, with the bodies of a block. */\nfunction childNodes(node: Markup): Markup[] {\n switch (node.kind) {\n case 'text':\n case 'insert':\n case 'listener':\n return [];\n case 'element':\n case 'component':\n case 'dynamic':\n case 'fragment':\n return node.children;\n default:\n return blockBodies(node).flatMap((body) => body.children);\n }\n}\n\n/** Returns the bodies of a block, in source order. */\nexport function blockBodies(block: Block): Body[] {\n switch (block.kind) {\n case 'if':\n return [\n ...block.branches.map((branch) => branch.body),\n ...(block.fallback ? [block.fallback] : []),\n ];\n case 'switch':\n return [\n ...block.cases.map((branch) => branch.body),\n ...(block.fallback ? [block.fallback] : []),\n ];\n case 'for':\n case 'repeat':\n case 'loading':\n case 'client':\n case 'defer':\n return [block.body, ...(block.fallback ? [block.fallback] : [])];\n case 'try':\n return [block.body, block.fallback];\n default:\n return [block.body];\n }\n}\n","import type { InsertNode, Markup } from '../ast.ts';\nimport type { Declaration, Reference, Scope, Site } from '../model.ts';\nimport { children } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\nimport { blockBodies } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\n\n/** Returns the nearest scope, from `scope` outwards, that gets an ID at render time. */\nexport function instanceScope(plan: Plan, scope: Scope): Scope {\n for (let current: Scope | undefined = scope; current; current = current.parent) {\n if (plan.scopes.get(current)?.needsId) {\n return current;\n }\n }\n return plan.graph.model.component;\n}\n\n/**\n * Returns an expression for the instance of `target`, starting from `base`,\n * an expression for the instance of `from`. Instances link to their parent\n * instance with `p`.\n */\nexport function scopePath(plan: Plan, base: string, from: Scope, target: Scope): string {\n let expression = base;\n let current = instanceScope(plan, from);\n const goal = instanceScope(plan, target);\n while (current !== goal) {\n if (!current.parent || current.kind === 'component') {\n throw new Error(`Scope ${target.id} does not contain scope ${from.id}`);\n }\n expression += '.p';\n current = instanceScope(plan, current.parent);\n }\n return expression;\n}\n\n/** Returns the slot index of a declaration, or -1. */\nexport function slotIndex(plan: Plan, declaration: Declaration): number {\n return plan.scopes.get(declaration.scope)?.slots.indexOf(declaration) ?? -1;\n}\n\n// Sites that do not run while the server renders.\nconst DEFERRED_SITES = new Set(['function', 'server-function', 'event', 'effect', 'client']);\n\n/**\n * Returns the nearest `#loading` or `#defer` body scope that contains a\n * scope, up to `limit`. Both render after the rest of the page, so the\n * page does not wait for the memos that only they read.\n */\nexport function loadingBody(scope: Scope, limit?: Scope): Scope | undefined {\n for (\n let current: Scope | undefined = scope;\n current && current !== limit;\n current = current.parent\n ) {\n const block = current.block;\n if ((block?.kind === 'loading' || block?.kind === 'defer') && current.body === block.body) {\n return current;\n }\n }\n return undefined;\n}\n\n/** Any memo can hold a promise, because its expression can call code that returns one. */\nexport function isMemo(declaration: Declaration): boolean {\n return declaration.kind === 'memo' || declaration.kind === 'async-memo';\n}\n\n/**\n * The scope whose render waits for a read. A read with `await` inside a\n * `#loading` body makes the render around the block wait, so it counts as\n * a read in the scope that holds the block. Inside a `#defer` body, the\n * request for the body waits, so the read stays where it is. `limit` is\n * the scope of the declaration, which a read inside it never leaves.\n */\nfunction readScope(read: Reference, limit?: Scope): Scope {\n const scope = read.site.scope;\n if (!read.await) {\n return scope;\n }\n const body = loadingBody(scope, limit);\n return body?.block?.kind === 'loading' ? body.parent! : scope;\n}\n\n/**\n * Returns the memos that the server awaits where they are declared: those\n * declared with `await $memo(…)`, and those that markup or code outside\n * every `#loading` body reads, with `await` or without. The others are\n * awaited by the `#loading` bodies that read them.\n */\nexport function blockingMemos(plan: Plan): Set<Declaration> {\n const result = new Set<Declaration>();\n for (const declaration of plan.graph.model.declarations) {\n if (!isMemo(declaration)) {\n continue;\n }\n if (declaration.awaited) {\n result.add(declaration);\n continue;\n }\n for (const read of declaration.reads) {\n if (read.range.start === read.range.end) {\n continue;\n }\n const site = read.site;\n // A memo reads another memo when it computes, so it does not need the value where it is declared.\n if (DEFERRED_SITES.has(site.kind) || site.kind === 'memo') {\n continue;\n }\n // Templates can render anywhere, so their reads count as outside.\n let template = false;\n for (let scope: Scope | undefined = site.scope; scope; scope = scope.parent) {\n template ||= scope.kind === 'template';\n }\n if (template || !loadingBody(readScope(read, declaration.scope), declaration.scope)) {\n result.add(declaration);\n break;\n }\n }\n }\n return result;\n}\n\n/**\n * Returns the memos that a `#loading` body waits for before it renders:\n * the memos that its markup reads, and the memos that a `#loading` body\n * inside it reads with `await`. Memos that the page or a body around it\n * waits for are left out.\n */\nexport function awaitedMemos(plan: Plan, body: Scope, blocking: Set<Declaration>): Declaration[] {\n const result = new Set<Declaration>();\n for (const site of plan.graph.model.sites) {\n if (DEFERRED_SITES.has(site.kind)) {\n continue;\n }\n for (const read of site.reads) {\n // Reads that `$isPending` adds for the memos a memo reads have no range, and need no value.\n if (read.range.start === read.range.end || loadingBody(readScope(read)) !== body) {\n continue;\n }\n if (isMemo(read.declaration) && !blocking.has(read.declaration)) {\n result.add(read.declaration);\n }\n }\n }\n const outer = body.parent && loadingBody(body.parent);\n if (outer) {\n for (const declaration of awaitedMemos(plan, outer, blocking)) {\n result.delete(declaration);\n }\n }\n return [...result];\n}\n\n/**\n * True if the markup of a `#loading` body may wait for something other than\n * the memos it reads, so the body cannot render in place when those memos\n * are ready: a child component, a dynamic tag, a template, or an insert of\n * a prop, which can be a promise or the children of a parent. Bodies that\n * render later, such as those of a `#loading` or a `#defer` inside it, wait\n * on their own.\n */\nexport function mayWait(plan: Plan, nodes: Markup[]): boolean {\n const insertWaits = (node: InsertNode): boolean => {\n const site = plan.graph.model.sites.find((item) => item.node === node.expression.ast);\n if (!site) {\n return false;\n }\n for (const read of site.reads) {\n const kind = read.declaration.kind;\n if (kind === 'prop' || kind === 'props-rest' || kind === 'template') {\n return true;\n }\n }\n return false;\n };\n for (const node of nodes) {\n switch (node.kind) {\n case 'component':\n case 'dynamic':\n return true;\n case 'insert':\n if (insertWaits(node)) {\n return true;\n }\n break;\n case 'element':\n case 'fragment':\n if (mayWait(plan, node.children)) {\n return true;\n }\n break;\n case 'text':\n case 'listener':\n break;\n default: {\n let bodies: ReturnType<typeof blockBodies>;\n if (node.kind === 'loading' || node.kind === 'defer' || node.kind === 'client') {\n bodies = node.fallback ? [node.fallback] : [];\n } else {\n bodies = blockBodies(node);\n }\n for (const body of bodies) {\n if (mayWait(plan, body.children)) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\n/** Expressions that run code the compiler cannot see, or that a memo should not hold. */\nconst UNSAFE_NODES = new Set([\n 'CallExpression',\n 'NewExpression',\n 'TaggedTemplateExpression',\n 'AwaitExpression',\n 'YieldExpression',\n 'ImportExpression',\n 'AssignmentExpression',\n 'UpdateExpression',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'ClassExpression',\n]);\n\n/**\n * True if an expression always gives a primitive, so it is never a promise\n * or an async iterable. A name is a primitive when `plain` says that it reads\n * a declaration that holds one.\n */\nexport function isPrimitive(\n node: oxc.Node,\n plain: (name: oxc.Node) => boolean = () => false,\n): boolean {\n switch (node.type) {\n case 'Identifier':\n return plain(node);\n case 'Literal':\n return !('regex' in node && node.regex);\n case 'TemplateLiteral':\n case 'BinaryExpression':\n case 'UnaryExpression':\n return true;\n case 'LogicalExpression':\n return isPrimitive(node.left, plain) && isPrimitive(node.right, plain);\n case 'ConditionalExpression':\n return isPrimitive(node.consequent, plain) && isPrimitive(node.alternate, plain);\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n return isPrimitive(node.expression, plain);\n default:\n return false;\n }\n}\n\n/** True if an expression calls no code and, unless `members`, reads no property. */\nfunction isSafe(node: oxc.Node, members: boolean): boolean {\n if (UNSAFE_NODES.has(node.type)) {\n return false;\n }\n if (!members && (node.type === 'MemberExpression' || node.type === 'ChainExpression')) {\n return false;\n }\n for (const [, child] of children(node)) {\n if (!isSafe(child, members)) {\n return false;\n }\n }\n return true;\n}\n\n/** True if a name in the code of a site reads a declaration that `plain` accepts. */\nexport function readsPlain(\n site: Site | undefined,\n name: oxc.Node,\n plain: (declaration: Declaration) => boolean,\n): boolean {\n return (\n site?.reads.some(\n (read) =>\n read.range.start === name.start && read.range.end === name.end && plain(read.declaration),\n ) ?? false\n );\n}\n\n// Compound assignments that give a primitive whatever the value that they assign.\nconst ARITHMETIC_ASSIGNMENTS = new Set([\n '+=',\n '-=',\n '*=',\n '/=',\n '%=',\n '**=',\n '<<=',\n '>>=',\n '>>>=',\n '&=',\n '|=',\n '^=',\n]);\n\n/** Returns the assignment or update of a site whose target is at `at`. */\nfunction writeAt(node: oxc.Node, at: number): oxc.Node | undefined {\n if (\n (node.type === 'AssignmentExpression' &&\n node.left.type === 'Identifier' &&\n node.left.start === at) ||\n (node.type === 'UpdateExpression' &&\n node.argument.type === 'Identifier' &&\n node.argument.start === at)\n ) {\n return node;\n }\n for (const [, child] of children(node)) {\n const found = writeAt(child, at);\n if (found) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * Returns the memos and signals that always hold a primitive on the server,\n * so the server reads them as plain values.\n *\n * - A memo gives a primitive and calls nothing, so it is never a promise and\n * needs no render context. Each memo that it reads is one too, so no read\n * waits for a load. A memo that the server would not compute where it is\n * declared reads no property, because computing it early must not throw.\n * - A signal starts with a primitive, and each write gives a primitive, such\n * as `count++`. A signal that an element ref sets is left out.\n */\nexport function plainValues(plan: Plan, blocking: Set<Declaration>): Set<Declaration> {\n const result = new Set<Declaration>();\n const visiting = new Set<Declaration>();\n const check = (declaration: Declaration): boolean => {\n if (result.has(declaration)) {\n return true;\n }\n if (visiting.has(declaration)) {\n return false;\n }\n visiting.add(declaration);\n const plain =\n declaration.kind === 'signal' ? isPlainSignal(declaration) : isPlainMemo(declaration);\n visiting.delete(declaration);\n if (plain) {\n result.add(declaration);\n }\n return plain;\n };\n const isPlainMemo = (declaration: Declaration): boolean => {\n const site = declaration.site;\n return (\n declaration.kind === 'memo' &&\n !declaration.writable &&\n !declaration.optimistic &&\n site !== undefined &&\n isPrimitive(site.node, (name) => readsPlain(site, name, check)) &&\n isSafe(site.node, blocking.has(declaration)) &&\n site.reads.every((read) => !isMemo(read.declaration) || check(read.declaration))\n );\n };\n const isPlainSignal = (declaration: Declaration): boolean => {\n if (declaration.refs.length > 0) {\n return false;\n }\n const init = declaration.init;\n if (init) {\n const site = plan.graph.model.sites.find((item) => item.node === init);\n if (!isPrimitive(init, (name) => readsPlain(site, name, check))) {\n return false;\n }\n }\n return declaration.writes.every((write) => {\n const node = writeAt(write.site.node, write.range.start);\n if (node?.type === 'UpdateExpression') {\n return true;\n }\n if (node?.type !== 'AssignmentExpression') {\n return false;\n }\n return (\n ARITHMETIC_ASSIGNMENTS.has(node.operator) ||\n isPrimitive(node.right, (name) => readsPlain(write.site, name, check))\n );\n });\n };\n for (const declaration of plan.graph.model.declarations) {\n check(declaration);\n }\n return result;\n}\n","import type {\n Attribute,\n Block,\n Body,\n ComponentNode,\n DynamicTagNode,\n ElementNode,\n EventAttribute,\n Expression,\n ForBlock,\n Markup,\n RepeatBlock,\n SFCFile,\n TemplateDecl,\n ValueAttribute,\n} from '../ast.ts';\nimport { isWithin, lookup } from '../model.ts';\nimport type { Declaration, Scope, Site } from '../model.ts';\nimport type { oxc } from '../oxc.ts';\nimport { serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { cleanText, promiseName } from './patch.ts';\nimport type { Patch } from './patch.ts';\nimport {\n awaitedMemos,\n blockingMemos,\n mayWait,\n plainValues,\n instanceScope,\n isMemo,\n isPrimitive,\n readsPlain,\n scopePath,\n slotIndex,\n} from './scopes.ts';\nimport { needsScope } from '../css.ts';\nimport { copy, unmarked } from '../sourcemap.ts';\nimport { insertValue } from '../runtime/html.ts';\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport const TYPE_DECLARATIONS: Set<string> = new Set([\n 'TSInterfaceDeclaration',\n 'TSTypeAliasDeclaration',\n 'TSDeclareFunction',\n 'TSModuleDeclaration',\n]);\n\ntype Part = { static: string } | { code: string };\n\n/** The name of the compile-time function that a declarator calls, for `$getContext` and `$id`. */\nfunction specialCall(\n declarator: oxc.VariableDeclarator,\n): '$getContext' | '$id' | '$route' | '$navigation' | undefined {\n const init = declarator.init;\n if (init?.type !== 'CallExpression' || init.callee.type !== 'Identifier') {\n return undefined;\n }\n const name = init.callee.name;\n return name === '$getContext' || name === '$id' || name === '$route' || name === '$navigation'\n ? name\n : undefined;\n}\n\n/** The attribute that sets the method of a form, by the attribute that sets its action. */\nconst FORM_METHODS = new Map([\n ['action', 'method'],\n ['formaction', 'formmethod'],\n]);\n\n/** The contexts that the runtime provides, by the compile-time function that reads them. */\nconst BUILT_IN_CONTEXTS: Record<string, string> = {\n $route: '$$b.routeContext',\n $navigation: '$$b.navigationContext',\n};\n\nexport interface EmitterOptions {\n mode: 'server' | 'client';\n /**\n * Keeps local functions in client code. Render functions of a client\n * module skip them, because the module has its own copies that read slots.\n */\n functions?: boolean;\n /**\n * For a client render function: the scopes it renders (a body and the\n * templates it calls), the scope that contains the body, and the\n * expression for that scope's instance.\n */\n outer?: { inside: Scope[]; base: Scope; baseVar: string };\n}\n\n/** Writes code that renders markup to an HTML string, on the server or on the client. */\n/** The exports of the core that do on the client what the server's render context does. */\n/** The `$handler` calls that each patch has edited, since emitters of a file share its patch. */\nconst handlerEdits = new WeakMap<Patch, Set<object>>();\n\nconst CLIENT_HELPERS: Record<string, string> = {\n scope: 'createScope',\n slots: 'setSlots',\n item: 'setItem',\n element: 'elementAt',\n id: 'makeId',\n own: 'setOwner',\n provide: 'provideValue',\n consume: 'consumeContext',\n head: 'addHead',\n portal: 'addPortal',\n style: 'addStyle',\n fn: 'handlerProp',\n bindings: 'bindings',\n after: 'afterInsert',\n title: 'title',\n};\n\n/** The named character references that markup reads. Others stay as they are written. */\nconst NAMED: Record<string, string> = {\n amp: '&',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n nbsp: '\\u00a0',\n copy: '\\u00a9',\n reg: '\\u00ae',\n trade: '\\u2122',\n hellip: '\\u2026',\n mdash: '\\u2014',\n ndash: '\\u2013',\n lsquo: '\\u2018',\n rsquo: '\\u2019',\n ldquo: '\\u201c',\n rdquo: '\\u201d',\n laquo: '\\u00ab',\n raquo: '\\u00bb',\n middot: '\\u00b7',\n bull: '\\u2022',\n times: '\\u00d7',\n euro: '\\u20ac',\n};\n\n/**\n * Markup text or a static attribute value, with its character references\n * read. A number that is no character, such as one past 0x10FFFF, reads as\n * U+FFFD, as the browser reads it.\n */\nfunction decodeReferences(html: string): string {\n return html.replace(/&(#x[\\da-f]+|#\\d+|[a-z]+);/gi, (match, name: string) => {\n if (name[0] === '#') {\n const code =\n name[1] === 'x' || name[1] === 'X' ? parseInt(name.slice(2), 16) : Number(name.slice(1));\n const valid = code > 0 && code <= 0x10ffff && (code < 0xd800 || code > 0xdfff);\n return valid ? String.fromCodePoint(code) : '\\ufffd';\n }\n return NAMED[name.toLowerCase()] ?? match;\n });\n}\n\n/** The value of a static attribute, with its character references read. */\nexport function decodeAttribute(text: string): string {\n return decodeReferences(text);\n}\n\n/** The text that markup text shows, with its character references read. */\nfunction decodeText(html: string): string {\n return decodeReferences(html);\n}\n\n/** The markup of an inserted literal, such as `{'<b>'}`, or undefined for other code. */\nfunction literalText(node: oxc.Node): string | undefined {\n if (node.type === 'Literal') {\n return 'regex' in node && node.regex ? undefined : insertValue(node.value);\n }\n if (node.type === 'TemplateLiteral' && node.expressions.length === 0) {\n return insertValue(node.quasis[0]!.value.cooked);\n }\n return undefined;\n}\n\n/**\n * Blocks whose shape on the server depends on data: which branch renders,\n * how many items a list has, whether a body throws or shows. The server\n * numbers the scopes of their bodies after an ID of the block's own.\n */\nconst DATA_SHAPED = new Set(['if', 'switch', 'for', 'repeat', 'try', 'offscreen']);\n\nexport class Emitter {\n readonly lines: string[] = [];\n private readonly file: SFCFile;\n private readonly plan: Plan;\n private readonly patch: Patch;\n private readonly options: EmitterOptions;\n private readonly sitesByNode = new Map<object, Site>();\n private readonly refTargets = new Map<object, Declaration>();\n private readonly wait: string;\n private readonly async: string;\n /** The render context as an argument, which the client's helpers do not take. */\n private readonly ctxArgument: string;\n /** Async memos that the server awaits where they are declared. */\n private readonly blocking: Set<Declaration>;\n /** Memos and signals that hold a primitive on the server, so it awaits none of them. */\n private readonly inline: Set<Declaration>;\n private parts: Part[] = [];\n private depth = 0;\n /** How many of this component's elements contain the current node. */\n private nesting = 0;\n /** How many `#head` blocks contain the current node, where a `<title>` sets the title of the page. */\n private headBlocks = 0;\n private counter = 0;\n\n constructor(file: SFCFile, plan: Plan, patch: Patch, options: EmitterOptions) {\n this.file = file;\n this.plan = plan;\n this.patch = patch;\n this.options = options;\n this.wait = options.mode === 'server' ? 'await ' : '';\n this.async = options.mode === 'server' ? 'async ' : '';\n this.ctxArgument = options.mode === 'server' ? '$$ctx' : 'undefined';\n this.blocking = blockingMemos(plan);\n this.inline = options.mode === 'server' ? plainValues(plan, this.blocking) : new Set();\n for (const site of plan.graph.model.sites) {\n this.sitesByNode.set(site.node, site);\n }\n this.addHandlerEdits();\n this.addBindEdits();\n for (const declaration of plan.graph.model.declarations) {\n for (const ref of declaration.refs) {\n this.refTargets.set(ref.attribute, declaration);\n }\n }\n }\n\n /**\n * `$handler(fn, ...args)` marks its function as a client function with its\n * arguments, `fn(fn, \"<id>#<export>\", scope, [args])`, so a spread can\n * pass it on. The calls are edits of the source, wherever they are in a\n * script. Emitters of one file share its patch, so each call is edited once.\n */\n private addHandlerEdits(): void {\n let edited = handlerEdits.get(this.patch);\n if (!edited) {\n handlerEdits.set(this.patch, (edited = new Set()));\n }\n for (const site of this.plan.graph.model.sites) {\n const call = site.handler;\n const fn = call?.arguments[0];\n if (!call || !fn || edited.has(call)) {\n continue;\n }\n edited.add(call);\n const args = call.arguments.slice(1);\n const symbol = this.plan.symbols.get(site);\n if (!symbol) {\n // A handler that nothing in the browser can reach is the function alone.\n this.patch.replace(call.start, fn.start, '(');\n this.patch.replace(fn.end, call.end, ')');\n continue;\n }\n const ref = JSON.stringify(`${this.plan.id}#${symbol}`);\n const scope = this.scopeVar(instanceScope(this.plan, site.scope));\n this.patch.replace(call.start, fn.start, `${this.helper('fn')}(`);\n if (args.length === 0) {\n this.patch.replace(fn.end, call.end, `, ${ref}, ${scope})`);\n } else {\n this.patch.replace(fn.end, args[0]!.start, `, ${ref}, ${scope}, [`);\n this.patch.replace(args.at(-1)!.end, call.end, '])');\n }\n }\n }\n\n /**\n * `$bind(name)` passes the child the value of the name with its slot,\n * `binding(name, scope, slot)`, so the child's writes reach it.\n */\n private addBindEdits(): void {\n let edited = handlerEdits.get(this.patch);\n if (!edited) {\n handlerEdits.set(this.patch, (edited = new Set()));\n }\n for (const { call, declaration, setter } of this.plan.graph.model.bindings) {\n const [target, fn] = call.arguments;\n if (!target || edited.has(call)) {\n continue;\n }\n edited.add(call);\n const scope = this.scopeVar(instanceScope(this.plan, declaration.scope));\n const slot = slotIndex(this.plan, declaration);\n this.patch.replace(call.start, target.start, '$$b.binding((');\n const symbol = setter && this.plan.symbols.get(setter);\n if (!fn || !setter || !symbol) {\n this.patch.replace(target.end, call.end, `), ${scope}, ${slot})`);\n continue;\n }\n // The setter loads with its own part, as a handler of `$handler` does.\n const ref = JSON.stringify(`${this.plan.id}#${symbol}`);\n const owner = this.scopeVar(instanceScope(this.plan, setter.scope));\n this.patch.replace(target.end, fn.start, `), ${scope}, ${slot}, ${this.helper('fn')}(`);\n this.patch.replace(fn.end, call.end, `, ${ref}, ${owner}))`);\n }\n }\n\n // Output\n\n line(code: string): void {\n this.flush();\n this.lines.push(`${' '.repeat(this.depth)}${code}`);\n if (code.endsWith('{')) {\n this.depth++;\n }\n }\n\n close(code = '}'): void {\n this.flush();\n this.depth--;\n this.lines.push(`${' '.repeat(this.depth)}${code}`);\n if (code.endsWith('{')) {\n this.depth++;\n }\n }\n\n /** Copies source code, keeping the indentation of its lines relative to the first. */\n raw(code: string, offset: number): void {\n this.flush();\n const lineStart = this.file.source.lastIndexOf('\\n', offset - 1) + 1;\n const column = offset - lineStart;\n const indent = ' '.repeat(this.depth);\n code.split('\\n').forEach((line, index) => {\n const text = index === 0 ? line : line.replace(new RegExp(`^ {0,${column}}`), '');\n this.lines.push(unmarked(text).trim() === '' ? '' : `${indent}${text}`);\n });\n }\n\n private html(text: string): void {\n const last = this.parts.at(-1);\n if (last && 'static' in last) {\n last.static += text;\n } else {\n this.parts.push({ static: text });\n }\n }\n\n private code(code: string): void {\n this.parts.push({ code });\n }\n\n flush(): void {\n if (this.parts.length === 0) {\n return;\n }\n const parts = this.parts;\n this.parts = [];\n const value = parts\n .map((part) => ('static' in part ? JSON.stringify(part.static) : part.code))\n .join(' + ');\n this.lines.push(`${' '.repeat(this.depth)}$$html += ${value};`);\n }\n\n /**\n * The value of a runtime call that returns a string, or a promise when it\n * is not ready. The server awaits only a promise, because most values are\n * ready and each await pauses the render. `$$t` is a variable of the\n * module. Nothing runs between its write and its read.\n */\n private ready(call: string): string {\n return this.options.mode === 'server'\n ? `(typeof ($$t = ${call}) === 'string' ? $$t : await $$t)`\n : call;\n }\n\n /** The value of a memo, which the server awaits only when it is still loading. */\n private memoValue(name: string): string {\n return `(($$t = $$b.ready(${promiseName(name)})) instanceof Promise ? await $$t : $$t)`;\n }\n\n private unique(prefix: string): string {\n return `$$${prefix}${this.counter++}`;\n }\n\n private expression(expression: Expression): string {\n return `(${this.patch.slice(expression.start, expression.end)})`;\n }\n\n // Scopes\n\n /** The expression for the instance of a scope that gets an ID. */\n scopeVar(scope: Scope): string {\n const outer = this.options.outer;\n if (outer && !this.isInside(scope)) {\n return scopePath(this.plan, outer.baseVar, outer.base, scope);\n }\n return `$$s${scope.id}`;\n }\n\n /** True if a client render function renders the scope, so its variables are local. */\n private isInside(scope: Scope): boolean {\n const outer = this.options.outer;\n return !outer || outer.inside.some((item) => isWithin(scope, item));\n }\n\n private anchor(scope: Scope, target: object): { scope: string; index: number } | undefined {\n const index = this.plan.anchors.get(target as Markup);\n return index === undefined ? undefined : { scope: this.scopeVar(scope), index };\n }\n\n /** Creates the instance of a body scope. */\n private createScope(scope: Scope): void {\n const parent = instanceScope(this.plan, scope.parent!);\n this.line(\n `const ${this.scopeVar(scope)} = ${this.helper('scope')}(${scope.id}, ${this.scopeVar(parent)});`,\n );\n }\n\n emitSlots(scope: Scope): void {\n const slots = this.plan.scopes.get(scope)?.slots ?? [];\n if (slots.length > 0) {\n // A memo that the render did not wait for is in the state as its value when it is ready,\n // such as one that a `#loading` body rendered in place, and as a promise while it loads.\n const values = slots.map((slot) =>\n this.isPromise(slot) ? `$$b.stateValue(${promiseName(slot.name)})` : slot.name,\n );\n // The server also passes the names, so an error can say which value cannot be sent.\n const names =\n this.options.mode === 'server' ? `, ${JSON.stringify(slots.map((slot) => slot.name))}` : '';\n this.line(\n `${this.helper('slots')}(${this.scopeVar(scope)}, [${values.join(', ')}]${names});`,\n );\n }\n // The props that the component writes, which a parent can bind with `$bind`.\n if (scope.kind === 'component') {\n const bindable = slots.flatMap((slot, index) =>\n slot.kind === 'prop' && slot.writable && slot.propKey !== undefined\n ? [`${JSON.stringify(slot.propKey)}: ${index}`]\n : [],\n );\n if (bindable.length > 0) {\n this.line(\n `${this.helper('bindings')}(${this.scopeVar(scope)}, $$props, { ${bindable.join(', ')} });`,\n );\n }\n }\n }\n\n /** True if the server inserts a primitive, such as a memo that it computes as a plain value. */\n private isPrimitiveInsert(expression: Expression): boolean {\n if (this.options.mode !== 'server') {\n return false;\n }\n const site = this.sitesByNode.get(expression.ast);\n return isPrimitive(expression.ast, (name) =>\n readsPlain(site, name, (declaration) => this.inline.has(declaration)),\n );\n }\n\n /** True for an async memo that is a promise where its scope ends, on the server. */\n private isPromise(declaration: Declaration): boolean {\n return (\n this.options.mode === 'server' &&\n isMemo(declaration) &&\n !this.blocking.has(declaration) &&\n !this.inline.has(declaration)\n );\n }\n\n /**\n * The memos of a statement that the server waits for where they are\n * declared. `awaited` is true when every one of them is declared with\n * `await $memo(…)`. Such statements in a row form a run: every memo of\n * the run starts, and the render waits for all of them where the run\n * ends, so independent memos load at the same time. A memo that the\n * markup makes the page wait for, without the keyword, is awaited on its\n * own, as the code reads.\n */\n private blockingDeclarations(\n statement: oxc.Node,\n ): { declarations: Declaration[]; awaited: boolean } | undefined {\n if (this.options.mode !== 'server' || statement.type !== 'VariableDeclaration') {\n return undefined;\n }\n const declarations: Declaration[] = [];\n let awaited = true;\n for (const declarator of statement.declarations) {\n let init = declarator.init;\n if (init?.type === 'AwaitExpression') {\n init = init.argument;\n }\n const argument = init?.type === 'CallExpression' ? init.arguments[0] : undefined;\n const declaration = argument && this.sitesByNode.get(argument)?.declaration;\n if (!declaration || !isMemo(declaration) || !this.blocking.has(declaration)) {\n awaited = false;\n continue;\n }\n awaited &&= declaration.awaited === true;\n if (!this.inline.has(declaration)) {\n declarations.push(declaration);\n }\n }\n return declarations.length === 0 ? undefined : { declarations, awaited };\n }\n\n /** Waits for the memos of a run of declarations, and gives each its value. */\n private awaitRun(run: Declaration[]): void {\n if (run.length === 1) {\n const [declaration] = run as [Declaration];\n this.line(`const ${declaration.name} = ${this.memoValue(declaration.name)};`);\n return;\n }\n const names = run.map((declaration) => promiseName(declaration.name));\n this.line(`if (($$t = $$b.waitAll([${names.join(', ')}])) !== undefined) await $$t;`);\n for (const declaration of run) {\n this.line(`const ${declaration.name} = $$b.read(${promiseName(declaration.name)});`);\n }\n }\n\n emitStatements(statements: oxc.Node[], scope: Scope): void {\n let run: Declaration[] = [];\n const endRun = (): void => {\n if (run.length > 0) {\n this.awaitRun(run);\n run = [];\n }\n };\n for (const statement of statements) {\n const blocking = this.blockingDeclarations(statement);\n if (blocking?.awaited) {\n this.raw(this.patch.slice(statement.start, statement.end), statement.start);\n run.push(...blocking.declarations);\n continue;\n }\n endRun();\n if (blocking) {\n this.raw(this.patch.slice(statement.start, statement.end), statement.start);\n for (const declaration of blocking.declarations) {\n this.awaitRun([declaration]);\n }\n continue;\n }\n if (statement.type === 'ExpressionStatement') {\n const expression = statement.expression;\n const name =\n expression.type === 'CallExpression' && expression.callee.type === 'Identifier'\n ? expression.callee.name\n : undefined;\n if (name === '$effect' || name === '$client') {\n continue;\n }\n if (name === '$title' && expression.type === 'CallExpression' && expression.arguments[0]) {\n this.line(`${this.helper('title')}(${this.source(expression.arguments[0])});`);\n continue;\n }\n if (name === '$setContext' && expression.type === 'CallExpression') {\n const [context, value] = expression.arguments;\n if (context && value) {\n const target = this.scopeVar(instanceScope(this.plan, scope));\n this.line(\n `${this.helper('provide')}(${this.source(context)}, ${this.providedValue(value, scope)}, ${target});`,\n );\n }\n continue;\n }\n }\n if (statement.type === 'VariableDeclaration' && this.emitContexts(statement, scope)) {\n continue;\n }\n if (statement.type === 'ImportDeclaration' || TYPE_DECLARATIONS.has(statement.type)) {\n continue;\n }\n if (this.options.mode === 'client') {\n if (this.isServerStatement(statement)) {\n // Server functions are stubs at the top of the module.\n continue;\n }\n if (!this.options.functions && this.isFunctionStatement(statement)) {\n // Client functions are module functions in the client module.\n continue;\n }\n }\n this.raw(this.patch.slice(statement.start, statement.end), statement.start);\n }\n endRun();\n }\n\n private source(node: { start: number; end: number }): string {\n return this.patch.slice(node.start, node.end);\n }\n\n /**\n * Writes the declarations of a statement that reads contexts or creates\n * IDs, one per line. Returns false if the statement does neither.\n */\n private emitContexts(statement: oxc.VariableDeclaration, scope: Scope): boolean {\n if (!statement.declarations.some((declarator) => specialCall(declarator))) {\n return false;\n }\n const target = this.scopeVar(instanceScope(this.plan, scope));\n for (const declarator of statement.declarations) {\n const init = declarator.init as oxc.CallExpression;\n const call = specialCall(declarator);\n const declaration =\n declarator.id.type === 'Identifier'\n ? scope.declarations.get(declarator.id.name)\n : undefined;\n if (call === '$id' && declaration?.idIndex !== undefined) {\n this.line(\n `const ${declaration.name} = ${this.helper('id')}(${target}, ${declaration.idIndex});`,\n );\n continue;\n }\n let context: string | undefined;\n if (call && BUILT_IN_CONTEXTS[call]) {\n context = BUILT_IN_CONTEXTS[call];\n } else if (call === '$getContext' && init.arguments[0]) {\n context = this.source(init.arguments[0]);\n }\n if (!context || declarator.id.type !== 'Identifier') {\n this.line(`${statement.kind} ${this.source(declarator)};`);\n continue;\n }\n const slot = declaration ? slotIndex(this.plan, declaration) : -1;\n // The slot is recorded, so a change to the provided value reaches it on the client.\n const record = slot === -1 ? '' : `, ${slot}`;\n this.line(\n `const ${declarator.id.name} = ${this.helper('consume')}(${context}, ${target}${record});`,\n );\n }\n return true;\n }\n\n private isServerStatement(statement: oxc.Node): boolean {\n const nodes =\n statement.type === 'VariableDeclaration'\n ? statement.declarations.map((declarator) => declarator.init)\n : [statement];\n return nodes.every((node) => node && this.sitesByNode.get(node)?.kind === 'server-function');\n }\n\n private isFunctionStatement(statement: oxc.Node): boolean {\n if (statement.type === 'FunctionDeclaration') {\n return true;\n }\n if (statement.type !== 'VariableDeclaration') {\n return false;\n }\n return statement.declarations.every((declarator) => {\n const init = declarator.init;\n return init?.type === 'ArrowFunctionExpression' || init?.type === 'FunctionExpression';\n });\n }\n\n /** Emits `<template>` markers for the `$client` callbacks of a scope. */\n private emitClientAnchors(scope: Scope): void {\n for (const site of this.plan.graph.model.sites) {\n if (site.kind !== 'client' || site.scope !== scope) {\n continue;\n }\n const anchor = this.anchor(scope, site)!;\n this.html('<template b-b=\"');\n this.code(anchor.scope);\n this.html(\n `:${anchor.index}\" b-client=\"${site.trigger}=${this.plan.id}#${this.plan.symbols.get(site)}\"`,\n );\n // A callback that reads an element of this scope through `ref` runs when that element\n // comes into view, instead of the first element of the scope.\n const near = site.trigger === 'visible' ? this.refElement(site, scope) : undefined;\n if (near !== undefined) {\n this.html(' b-near=\"');\n this.code(anchor.scope);\n this.html(`:${near}\"`);\n }\n this.html('></template>');\n }\n }\n\n /** The anchor of the first element of `scope` that a site reads through `ref`. */\n private refElement(site: Site, scope: Scope): number | undefined {\n for (const read of site.reads) {\n for (const ref of read.declaration.refs) {\n const index = ref.scope === scope ? this.plan.anchors.get(ref.element) : undefined;\n if (index !== undefined) {\n return index;\n }\n }\n }\n return undefined;\n }\n\n /** Emits the content of the component, without creating its scope. */\n emitComponentContent(setup: oxc.Node[]): void {\n const component = this.plan.graph.model.component;\n if (this.plan.styles.css) {\n // The stylesheet is written once per page, before the first instance.\n this.code(`${this.helper('style')}(${JSON.stringify(this.plan.id)}, $$css)`);\n }\n this.emitStatements(setup, component);\n for (const template of this.file.templates) {\n this.emitTemplate(template);\n }\n this.emitClientAnchors(component);\n this.emitNodes(this.file.children, component);\n this.emitSlots(component);\n this.flush();\n }\n\n /** Emits a body: its scope, script, templates, markup and slots. */\n emitBody(body: Body, createScope = true): void {\n const scope = this.plan.bodyScopes.get(body)!;\n const plan = this.plan.scopes.get(scope)!;\n if (plan.needsId && createScope) {\n this.createScope(scope);\n }\n if (body.script) {\n this.emitStatements(body.script.program.body, scope);\n }\n for (const template of body.templates) {\n this.emitTemplate(template);\n }\n this.emitClientAnchors(scope);\n this.emitNodes(body.children, scope);\n this.emitSlots(scope);\n }\n\n /**\n * On the server, the scope and slot of the list of a `#for` whose list is\n * a signal, memo or prop of an enclosing scope that the client gets, as an\n * expression. The client then takes each item from that list, and the\n * server does not write it. The server checks that each item is the value\n * of the list at its position before it leaves one out.\n */\n private itemSource(block: ForBlock | RepeatBlock): string | undefined {\n if (\n this.options.mode !== 'server' ||\n block.kind !== 'for' ||\n block.list.ast.type !== 'Identifier' ||\n block.item.type !== 'Identifier' ||\n !this.plan.anchors.has(block)\n ) {\n return undefined;\n }\n const scope = this.plan.bodyScopes.get(block.body)!.parent!;\n const declaration = lookup(scope, block.list.ast.name);\n if (!declaration || !['signal', 'memo', 'prop'].includes(declaration.kind)) {\n return undefined;\n }\n // A template renders anywhere, so its scopes are not the ones around its markup.\n for (let current: Scope | undefined = scope; current; current = current.parent) {\n if (current.kind === 'template') {\n return undefined;\n }\n if (current === declaration.scope) {\n break;\n }\n }\n const slot = this.plan.scopes.get(declaration.scope)?.slots.indexOf(declaration) ?? -1;\n return slot === -1 ? undefined : `[${this.scopeVar(declaration.scope)}, ${slot}]`;\n }\n\n /**\n * Emits one item of `#for` or `#repeat`, given expressions for the item and\n * its index, and on the server the scope and slot of its list.\n */\n emitItem(block: ForBlock | RepeatBlock, item: string, index: string, source?: string): void {\n const scope = this.plan.bodyScopes.get(block.body)!;\n // An item whose markup is one element is marked by the element's `b-b`.\n const anchored = this.plan.anchors.has(block) && !this.plan.elementItems.has(block);\n if (block.kind === 'for') {\n this.line(`const ${copy(this.file.source, block.item.start, block.item.end)} = ${item};`);\n }\n if (block.index) {\n this.line(`const ${block.index.name} = ${index};`);\n }\n const needsId = this.plan.scopes.get(scope)!.needsId;\n if (needsId) {\n this.createScope(scope);\n }\n if (anchored) {\n this.html('<!--i');\n this.code(this.scopeVar(scope));\n this.html('-->');\n }\n this.emitBody(block.body, false);\n if (this.plan.anchors.has(block)) {\n const from = source ? `, ${source}` : '';\n this.line(`${this.helper('item')}(${this.scopeVar(scope)}, ${item}${from});`);\n }\n if (anchored) {\n this.html('<!--/i-->');\n }\n }\n\n emitTemplate(template: TemplateDecl): void {\n const first = template.params[0];\n const last = template.params.at(-1);\n const params = first && last ? copy(this.file.source, first.start, last.end) : '';\n const type = this.options.mode === 'server' ? ': Promise<$$b.Raw>' : '';\n this.line(`${this.async}function ${template.name}(${params})${type} {`);\n this.line(`let $$html = '';`);\n // A template can render anywhere, so its elements get the style variables.\n this.atTopLevel(() => this.emitBody(template.body));\n this.flush();\n this.line('return $$b.raw($$html);');\n this.close();\n }\n\n // Markup\n\n emitNodes(nodes: Markup[], scope: Scope): void {\n for (const node of nodes) {\n this.emitNode(node, scope);\n }\n }\n\n /**\n * A render helper: a method of the render context on the server, and an\n * export of the core on the client, where a build keeps only the helpers\n * that its components call.\n */\n private helper(name: string): string {\n return this.options.mode === 'server' ? `$$ctx.${name}` : `$$b.${CLIENT_HELPERS[name]!}`;\n }\n\n private emitNode(node: Markup, scope: Scope): void {\n switch (node.kind) {\n case 'text':\n this.html(cleanText(node.value));\n return;\n case 'insert': {\n const anchor = this.anchor(scope, node);\n // On the server, the insert knows where it is, for markup that renders there, such as children.\n // In the browser, only a prop can hold children, which render where they are inserted.\n const ast = node.expression.ast;\n const kind = ast.type === 'Identifier' ? lookup(scope, ast.name)?.kind : undefined;\n const at =\n this.options.mode === 'server' || kind === 'prop' || kind === 'props-rest'\n ? `, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))}`\n : '';\n // A primitive renders as text, so it needs neither the place of the insert nor an await.\n const value = this.isPrimitiveInsert(node.expression)\n ? `$$b.insert(${this.expression(node.expression)})`\n : this.ready(`$$b.insert(${this.expression(node.expression)}${at})`);\n // A literal renders when the component compiles.\n const text = literalText(node.expression.ast);\n const emitValue = (): void => (text === undefined ? this.code(value) : this.html(text));\n // An insert that is the whole content of its element updates through the element's anchor.\n if (anchor && !this.plan.contents.has(node)) {\n this.html('<!--t');\n this.code(anchor.scope);\n this.html(`:${anchor.index}-->`);\n emitValue();\n this.html('<!--/t-->');\n } else {\n emitValue();\n }\n return;\n }\n case 'element':\n this.emitElement(node, scope);\n return;\n case 'component':\n this.emitComponent(node, scope);\n return;\n case 'dynamic':\n this.emitDynamic(node, scope);\n return;\n case 'fragment':\n // `#reveal` orders the `#loading` bodies that stream from the server. Markup that the\n // browser renders has no stream, so its children render as they are.\n if (node.reveal && this.options.mode === 'server') {\n this.line(\n `$$ctx.revealStart(${JSON.stringify(node.reveal.order)}, ${node.reveal.collapsed});`,\n );\n this.emitNodes(node.children, scope);\n this.line('$$ctx.revealEnd();');\n return;\n }\n this.emitNodes(node.children, scope);\n return;\n case 'listener': {\n const anchor = this.anchor(scope, node)!;\n const events = node.attributes.map((attribute) => this.eventEntry(attribute));\n this.html('<template b-b=\"');\n this.code(anchor.scope);\n this.html(\n `:${anchor.index}\" b-listen=\"${node.target}\" b-on=\"${events.join(' ')}\"></template>`,\n );\n return;\n }\n default:\n if (this.options.mode === 'server' && DATA_SHAPED.has(node.kind)) {\n // The markup after the block keeps its IDs, whatever the block rendered.\n this.line('$$ctx.enter();');\n this.emitBlock(node, scope);\n this.line('$$ctx.leave();');\n } else {\n this.emitBlock(node, scope);\n }\n }\n }\n\n /**\n * The `b-on` entry of `value=$bind(name)` or `checked=$bind(name)` on an\n * element: `input=$bind#<hops>.<slot>`, where `hops` counts the parents\n * from the scope of the element to the scope of the name. The core writes\n * the slot from the element without loading any code of the component.\n */\n private bindEntry(\n node: ElementNode,\n attribute: ValueAttribute,\n scope: Scope,\n ): string | undefined {\n let value: oxc.Node = attribute.value.ast;\n while (value.type === 'ParenthesizedExpression') {\n value = value.expression;\n }\n const binding = this.plan.graph.model.bindings.find((item) => item.call === value);\n if (!binding) {\n return undefined;\n }\n const setter = binding.setter && this.plan.symbols.get(binding.setter);\n const path = scopePath(\n this.plan,\n '$$s',\n instanceScope(this.plan, scope),\n instanceScope(this.plan, binding.declaration.scope),\n );\n const hops = path.split('.p').length - 1;\n const type = node.attributes.find((item) => item.kind === 'static' && item.name === 'type') as\n | { value: string | true }\n | undefined;\n const box = type && typeof type.value === 'string' && /^(checkbox|radio)$/i.test(type.value);\n // A box and a select change at once. A text field writes as the user types.\n const event =\n attribute.name === 'checked' || box || node.tag.toLowerCase() === 'select'\n ? 'change'\n : 'input';\n // `$bind(name, fn)` calls the setter with the value of the element.\n if (setter) {\n return `${event}=$set:${this.plan.id}#${setter}`;\n }\n return `${event}=$bind#${hops}.${slotIndex(this.plan, binding.declaration)}`;\n }\n\n private eventEntry({ event, modifiers, handler }: EventAttribute): string {\n const site = this.sitesByNode.get(handler.ast)!;\n // The modifiers of the attribute name, and those of the wrappers of `brumate/events`.\n const all = [...new Set([...modifiers, ...(site.modifiers ?? [])])];\n return `${[event, ...all].join(':')}=${this.plan.id}#${this.plan.symbols.get(site)}`;\n }\n\n private emitRef(\n target: string,\n attribute: object,\n anchor: { scope: string; index: number },\n ): void {\n const declaration = this.refTargets.get(attribute);\n const element = `${this.helper('element')}(${anchor.scope}, ${anchor.index})`;\n const outer = this.options.outer;\n if (declaration && outer && !this.isInside(declaration.scope)) {\n // The signal belongs to a scope outside this render, so it is written after the element is in the page.\n const path = scopePath(this.plan, outer.baseVar, outer.base, declaration.scope);\n this.line(\n `${this.helper('after')}.push(() => $$b.set(${path}, ${slotIndex(this.plan, declaration)}, ${element}));`,\n );\n } else {\n this.line(`${target} = ${element};`);\n }\n }\n\n /**\n * The style attribute of a top-level element, with the style variables of\n * the component, so the elements inside inherit them.\n */\n private emitVariables(node: ElementNode): boolean {\n const { variables } = this.plan.styles;\n if (variables.length === 0 || this.nesting > 0) {\n return false;\n }\n const values = variables.map(\n (variable) =>\n `${JSON.stringify(variable.name)}: ${variableValue(variable, this.expression(variable.expression))}`,\n );\n const own = node.attributes.find(\n (attribute) =>\n (attribute.kind === 'static' || attribute.kind === 'value') && attribute.name === 'style',\n );\n let existing = 'undefined';\n if (own?.kind === 'static') {\n existing = own.value === true ? 'undefined' : JSON.stringify(own.value);\n } else if (own?.kind === 'value') {\n existing = this.expression(own.value);\n }\n this.code(`$$b.attribute(\"style\", $$b.vars({ ${values.join(', ')} }, ${existing}))`);\n if (this.plan.liveStyles) {\n // Marks the element, so changes to the variables reach it.\n this.html(' b-v=\"');\n this.code(this.scopeVar(this.plan.graph.model.component));\n this.html('\"');\n }\n return true;\n }\n\n /**\n * Returns the code for `action={fn}` on a form, or `formaction={fn}` on a\n * button, when `fn` is a server function. The form then posts to the\n * server function without client code. Returns undefined otherwise.\n */\n private formAction(\n node: ElementNode,\n name: string,\n value: Expression,\n scope: Scope,\n ): string | undefined {\n const method = FORM_METHODS.get(name);\n if (!method || value.ast.type !== 'Identifier') {\n return undefined;\n }\n const declaration = lookup(scope, value.ast.name);\n // A server function of the component, or one that it imports from a `'use server'` file.\n if (declaration?.kind !== 'server-function' && declaration?.serverImport === undefined) {\n return undefined;\n }\n const ref = JSON.stringify(\n declaration.serverImport ?? serverFunctionId(this.plan, declaration.name),\n );\n // The form posts, unless the element sets its own method.\n const hasMethod = node.attributes.some(\n (attribute) => 'name' in attribute && attribute.name === method,\n );\n const methodArgument = hasMethod ? '' : `, ${JSON.stringify(method)}`;\n // A form whose result a `$action` reads posts to its page, and the result is written into that slot.\n const result = name === 'action' ? this.actionSlot(declaration) : undefined;\n const resultArgument = result ? `${hasMethod ? ', undefined' : ''}, ${result}` : '';\n return this.options.mode === 'server'\n ? `$$b.action($$ctx, ${JSON.stringify(name)}, ${ref}${methodArgument}${resultArgument})`\n : `$$b.action(${JSON.stringify(name)}, ${ref}${methodArgument}${resultArgument})`;\n }\n\n /** The `scope:slot` of the `$action` that reads the result of a server function, as code. */\n private actionSlot(fn: Declaration): string | undefined {\n const declaration = this.plan.graph.model.declarations.find(\n (item) => item.kind === 'action' && item.action === fn.name,\n );\n const slot = declaration ? slotIndex(this.plan, declaration) : -1;\n if (!declaration || slot === -1) {\n return undefined;\n }\n return `\\`\\${${this.scopeVar(instanceScope(this.plan, declaration.scope))}}:${slot}\\``;\n }\n\n private emitElement(node: ElementNode, scope: Scope): void {\n // A `<title>` in `#head` sets the title of the page. The core sets it from the last one in\n // the page, so a block that renders one decides the title. The plan reports the others.\n const pageTitle = node.tag === 'title' && this.headBlocks > 0;\n if (pageTitle && this.options.mode === 'server') {\n this.line(`${this.helper('title')}(${this.titleText(node)}, true);`);\n }\n // A spread can pass on handlers, such as the `onClick` of `...rest`, on the server and in\n // markup that the browser renders.\n let spreadHandlers: string | undefined;\n if (node.attributes.some((attribute) => attribute.kind === 'spread')) {\n spreadHandlers = this.unique('on');\n this.line(`const ${spreadHandlers}: string[] = [];`);\n }\n this.html(`<${node.tag}`);\n if (this.hasScope(node.tag, staticClasses(node.attributes))) {\n this.html(` ${this.plan.styles.attribute}`);\n }\n const ownStyle = this.emitVariables(node);\n const events: string[] = [];\n let prefetch: string | undefined;\n const anchor = this.anchor(scope, node);\n // With spreads, the attributes are one object in their order, so a name is written once:\n // a later value wins, and classes add up.\n const merged = node.attributes.some((attribute) => attribute.kind === 'spread')\n ? ([] as string[])\n : undefined;\n for (const attribute of node.attributes) {\n if (\n ownStyle &&\n (attribute.kind === 'static' || attribute.kind === 'value') &&\n attribute.name === 'style'\n ) {\n continue;\n }\n if (merged && this.mergedAttribute(node, attribute, scope, merged)) {\n continue;\n }\n switch (attribute.kind) {\n case 'static':\n this.html(\n attribute.value === true\n ? ` ${attribute.name}`\n : ` ${attribute.name}=\"${attribute.value}\"`,\n );\n break;\n case 'value': {\n const action = this.formAction(node, attribute.name, attribute.value, scope);\n if (action) {\n this.code(action);\n break;\n }\n const classes =\n attribute.name === 'class'\n ? literalClasses(attribute.value.ast, (start, end) => this.patch.slice(start, end))\n : undefined;\n if (classes) {\n this.emitClasses(classes);\n break;\n }\n this.code(\n `$$b.attribute(${JSON.stringify(attribute.name)}, ${this.expression(attribute.value)})`,\n );\n // `value=$bind(name)` writes the name back as the element changes, before the element's\n // own handlers run.\n const bound = this.bindEntry(node, attribute, scope);\n if (bound) {\n events.unshift(bound);\n }\n break;\n }\n case 'spread':\n this.code(\n `$$b.spread(${this.expression(attribute.value)}${spreadHandlers ? `, ${spreadHandlers}` : ''})`,\n );\n break;\n case 'computed':\n this.code(\n `$$b.attribute(${this.expression(attribute.name)}, ${attribute.value === true ? 'true' : this.expression(attribute.value)})`,\n );\n break;\n case 'event':\n events.push(this.eventEntry(attribute));\n break;\n case 'ref':\n if (anchor) {\n this.emitRef(attribute.target, attribute, anchor);\n }\n break;\n case 'prefetch':\n prefetch = attribute.strategy;\n break;\n }\n }\n if (merged) {\n this.code(\n `$$b.spread($$b.mergeAttributes([${merged.join(', ')}])${spreadHandlers ? `, ${spreadHandlers}` : ''})`,\n );\n }\n if (anchor) {\n this.html(' b-b=\"');\n this.code(anchor.scope);\n this.html(`:${anchor.index}\"`);\n }\n if (pageTitle) {\n this.html(' b-t');\n }\n if (spreadHandlers) {\n // One `b-on` for the handlers of the element and those that its spreads pass on.\n this.code(`$$b.onAttribute(${spreadHandlers}, ${JSON.stringify(events.join(' '))})`);\n } else if (events.length > 0) {\n this.html(` b-on=\"${events.join(' ')}\"`);\n }\n if (events.length > 0 && prefetch) {\n this.html(` data-prefetch=\"${prefetch}\"`);\n }\n this.html('>');\n if (VOID_ELEMENTS.has(node.tag)) {\n return;\n }\n this.nesting++;\n this.emitNodes(node.children, scope);\n this.nesting--;\n this.html(`</${node.tag}>`);\n }\n\n /**\n * Adds an attribute of an element with spreads to `parts`, the objects\n * that its spread merges. Returns false for an attribute that stays apart,\n * such as a handler or a `ref`.\n */\n private mergedAttribute(\n node: ElementNode,\n attribute: Attribute,\n scope: Scope,\n parts: string[],\n ): boolean {\n switch (attribute.kind) {\n case 'static':\n parts.push(\n // An attribute without a value is empty, as HTML reads it, so `aria-hidden` stays empty.\n `{ ${JSON.stringify(attribute.name)}: ${attribute.value === true ? \"''\" : JSON.stringify(decodeAttribute(attribute.value))} }`,\n );\n return true;\n case 'value':\n if (this.formAction(node, attribute.name, attribute.value, scope)) {\n return false;\n }\n parts.push(`{ ${JSON.stringify(attribute.name)}: ${this.expression(attribute.value)} }`);\n return true;\n case 'computed':\n parts.push(\n `{ [${this.expression(attribute.name)}]: ${attribute.value === true ? 'true' : this.expression(attribute.value)} }`,\n );\n return true;\n case 'spread':\n parts.push(this.expression(attribute.value));\n return true;\n default:\n return false;\n }\n }\n\n /**\n * The text of a `<title>`, as code: its one insert, or its text and the\n * inserts in it joined, such as `Items ({count})`.\n */\n private titleText(node: ElementNode): string {\n const [only] = node.children;\n if (only?.kind === 'insert' && node.children.length === 1) {\n return this.expression(only.expression);\n }\n const parts = node.children.flatMap((child) => {\n if (child.kind === 'insert') {\n return [`(${this.expression(child.expression)} ?? '')`];\n }\n return child.kind === 'text' ? [JSON.stringify(decodeText(cleanText(child.value)))] : [];\n });\n return parts.length === 0 ? '\"\"' : parts.join(' + ');\n }\n\n /**\n * Renders a literal `class` value as the runtime renders it, without\n * building the value. A class with a condition is added when the condition\n * is truthy. No class leaves the attribute out.\n */\n private emitClasses(classes: ClassPart[]): void {\n const [first, ...rest] = classes;\n if (!first) {\n return;\n }\n const piece = (part: ClassPart): string => {\n const text = JSON.stringify(` ${escapeClass(part.name)}`);\n return part.condition === undefined ? text : `((${part.condition}) ? ${text} : \"\")`;\n };\n if (first.condition === undefined) {\n this.html(` class=\"${escapeClass(first.name)}`);\n for (const part of rest) {\n if (part.condition === undefined) {\n this.html(` ${escapeClass(part.name)}`);\n } else {\n this.code(piece(part));\n }\n }\n this.html('\"');\n } else if (rest.length === 0) {\n const text = JSON.stringify(` class=\"${escapeClass(first.name)}\"`);\n this.code(`((${first.condition}) ? ${text} : \"\")`);\n } else {\n this.code(`$$b.classAttribute(${classes.map(piece).join(' + ')})`);\n }\n }\n\n /**\n * True if an element gets the scope attribute. In a build, only elements\n * that a scoped selector could match get it. In development, every\n * element of a component with styles gets it, so a change to the styles\n * applies without rendering the page again.\n */\n private hasScope(tag: string | undefined, classes: string[] | undefined): boolean {\n const { css, targets } = this.plan.styles;\n if (!css) {\n return false;\n }\n return !this.plan.hideNames || needsScope(targets, tag, classes);\n }\n\n /** Runs a callback for markup that renders outside this component's elements, such as children. */\n private atTopLevel(callback: () => void): void {\n const nesting = this.nesting;\n this.nesting = 0;\n callback();\n this.nesting = nesting;\n }\n\n /** Renders children into a variable, for a component or a dynamic tag. */\n private emitChildren(nodes: Markup[], scope: Scope): string | undefined {\n if (nodes.length === 0) {\n return undefined;\n }\n const name = this.unique('children');\n if (this.options.mode === 'server') {\n // The children render where the component inserts them, so they read its contexts.\n this.line(\n `const ${name} = $$b.children(${this.scopeVar(instanceScope(this.plan, scope))}, async ($$ctx) => {`,\n );\n this.line(`let $$html = '';`);\n this.atTopLevel(() => this.emitNodes(nodes, scope));\n this.flush();\n this.line('return $$html;');\n this.close('});');\n return name;\n }\n this.line(\n `const ${name} = $$b.children(${this.scopeVar(instanceScope(this.plan, scope))}, () => {`,\n );\n this.line(`let $$html = '';`);\n this.atTopLevel(() => this.emitNodes(nodes, scope));\n this.flush();\n this.line('return $$html;');\n this.close('});');\n return name;\n }\n\n private props(attributes: Attribute[], scope: Scope, extra: string[] = []): string {\n const entries: string[] = [];\n for (const attribute of attributes) {\n switch (attribute.kind) {\n case 'static':\n entries.push(\n `${JSON.stringify(attribute.name)}: ${attribute.value === true ? 'true' : JSON.stringify(attribute.value)}`,\n );\n break;\n case 'value':\n entries.push(\n `${JSON.stringify(attribute.name)}: ${this.propValue(attribute.value, scope)}`,\n );\n break;\n case 'event':\n entries.push(\n `${JSON.stringify(attribute.name)}: ${this.propValue(attribute.handler, scope)}`,\n );\n break;\n case 'spread':\n entries.push(`...${this.expression(attribute.value)}`);\n break;\n case 'computed':\n entries.push(\n `[${this.expression(attribute.name)}]: ${attribute.value === true ? 'true' : this.expression(attribute.value)}`,\n );\n break;\n default:\n break;\n }\n }\n return `{ ${[...entries, ...extra].join(', ')} }`;\n }\n\n /**\n * A provided value. Its functions are marked, as function props are, so\n * they serialize as references that the browser can call.\n */\n private providedValue(value: oxc.Node, scope: Scope): string {\n const instance = this.scopeVar(instanceScope(this.plan, scope));\n const mark = (part: oxc.Node, method = false): string | undefined => {\n const site = this.sitesByNode.get(part);\n const symbol = site?.kind === 'prop' ? this.plan.symbols.get(site) : undefined;\n // A method, such as `toggle() {}`, is a function expression without the keyword.\n const code = `${method ? 'function ' : ''}${this.source(part)}`;\n return symbol\n ? `${this.helper('fn')}(${code}, ${JSON.stringify(`${this.plan.id}#${symbol}`)}, ${instance})`\n : undefined;\n };\n if (value.type !== 'ObjectExpression') {\n return mark(value) ?? this.source(value);\n }\n let code = '';\n let position = value.start;\n for (const property of value.properties) {\n if (property.type !== 'Property' || property.computed) {\n continue;\n }\n const marked = mark(property.value, property.method);\n if (!marked) {\n continue;\n }\n code += this.patch.slice(position, property.start);\n const key = this.patch.slice(property.key.start, property.key.end);\n code += `${key}: ${marked}`;\n position = property.end;\n }\n return code + this.patch.slice(position, value.end);\n }\n\n /** A prop value. A client function is marked so it serializes as a reference. */\n private propValue(expression: Expression, scope: Scope): string {\n const code = this.expression(expression);\n const site = this.sitesByNode.get(expression.ast);\n const symbol = site && this.plan.symbols.get(site);\n if (symbol) {\n const instance = this.scopeVar(instanceScope(this.plan, scope));\n return `${this.helper('fn')}(${code}, ${JSON.stringify(`${this.plan.id}#${symbol}`)}, ${instance})`;\n }\n return code;\n }\n\n private emitComponent(node: ComponentNode, scope: Scope): void {\n const childrenName = this.emitChildren(node.children, scope);\n const props = this.props(\n node.attributes,\n scope,\n childrenName ? [`children: ${childrenName}`] : [],\n );\n const anchor = this.anchor(scope, node);\n // The rendering scope becomes the owner of the child, so the child finds the contexts above it.\n const owner = this.scopeVar(instanceScope(this.plan, scope));\n const link = anchor ? `, ${anchor.index}` : '';\n this.code(\n `${this.wait}$$b.component(${node.name}, ${props}, ${this.ctxArgument}, ${owner}${link})`,\n );\n }\n\n private emitDynamic(node: DynamicTagNode, scope: Scope): void {\n const childrenName = this.emitChildren(node.children, scope);\n const extra: string[] = [];\n if (this.hasScope(undefined, staticClasses(node.attributes))) {\n extra.push(`${JSON.stringify(this.plan.styles.attribute)}: true`);\n }\n const anchor = this.anchor(scope, node);\n if (anchor) {\n extra.push(`\"b-b\": \\`\\${${anchor.scope}}:${anchor.index}\\``);\n }\n const events = node.attributes.flatMap((attribute) =>\n attribute.kind === 'event' ? [this.eventEntry(attribute)] : [],\n );\n if (events.length > 0) {\n extra.push(`\"b-on\": ${JSON.stringify(events.join(' '))}`);\n }\n let attributes = node.attributes.filter((attribute) => attribute.kind !== 'event');\n const { variables } = this.plan.styles;\n if (variables.length > 0 && this.nesting === 0) {\n // A top-level dynamic tag sets the style variables, as a top-level element does.\n const own = attributes.find(\n (attribute) =>\n (attribute.kind === 'static' || attribute.kind === 'value') && attribute.name === 'style',\n );\n let existing = 'undefined';\n if (own?.kind === 'static') {\n existing = own.value === true ? 'undefined' : JSON.stringify(own.value);\n } else if (own?.kind === 'value') {\n existing = this.expression(own.value);\n }\n attributes = attributes.filter((attribute) => attribute !== own);\n const values = variables.map(\n (variable) =>\n `${JSON.stringify(variable.name)}: ${variableValue(variable, this.expression(variable.expression))}`,\n );\n extra.push(`\"style\": $$b.vars({ ${values.join(', ')} }, ${existing})`);\n if (this.plan.liveStyles) {\n extra.push(`\"b-v\": ${this.scopeVar(this.plan.graph.model.component)}`);\n }\n }\n this.code(\n this.ready(\n `$$b.dynamic(${this.expression(node.tag)}, ${this.props(attributes, scope, extra)}, ${childrenName ?? 'undefined'}, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))})`,\n ),\n );\n }\n\n // Blocks\n\n /**\n * Renders a portal. Without a target, the body goes to the end of the page,\n * between markers with its scope ID. With a target, the client renders it\n * into the target when the page loads.\n */\n private emitPortal(block: Block & { kind: 'portal' | 'head' }, scope: Scope): void {\n const body = this.plan.bodyScopes.get(block.body)!;\n if (block.kind === 'portal' && block.target) {\n const anchor = this.anchor(scope, block)!;\n this.html('<template b-b=\"');\n this.code(anchor.scope);\n this.html(`:${anchor.index}\" b-client=\"load=${this.plan.id}#k${body.id}\"></template>`);\n return;\n }\n const name = this.unique('portal');\n this.line(`const ${name} = ${this.wait}(${this.async}() => {`);\n this.line(`let $$html = '';`);\n this.createScope(body);\n this.html('<!--P');\n this.code(this.scopeVar(body));\n this.html('-->');\n this.headBlocks += block.kind === 'head' ? 1 : 0;\n this.atTopLevel(() => this.emitBody(block.body, false));\n this.headBlocks -= block.kind === 'head' ? 1 : 0;\n this.html('<!--/P-->');\n this.flush();\n this.line('return $$html;');\n this.close('})();');\n // `#head` content goes to the document's head, and portal content to the end of the page.\n this.line(`${this.helper(block.kind === 'head' ? 'head' : 'portal')}(${name});`);\n }\n\n /**\n * Renders a `#loading` block. When the memos that its body reads are\n * ready, and the body waits for nothing else, the body renders in place,\n * in the ID space of its boundary. Otherwise the fallback renders, and the\n * body renders after the rest of the page, so data that the body waits\n * for does not hold up the page. The memos that the body reads with\n * `await` are ready here, because the render around the block waited for\n * them.\n */\n private emitLoading(block: Block & { kind: 'loading' }, scope: Scope): void {\n const boundary = this.unique('boundary');\n const body = this.plan.bodyScopes.get(block.body)!;\n const memos = awaitedMemos(this.plan, body, this.blocking).filter(\n (declaration) => !this.inline.has(declaration),\n );\n const names = memos.map((declaration) => promiseName(declaration.name));\n const inPlace = !mayWait(this.plan, block.body.children);\n if (inPlace && memos.length === 0) {\n // Nothing can hold the body up, so it always renders in place.\n this.line('$$ctx.enter();');\n this.emitBody(block.body);\n this.line('$$ctx.leave();');\n return;\n }\n this.line(`const ${boundary} = $$ctx.boundary();`);\n if (inPlace) {\n // A `#reveal` around the block, in this file or in a component that renders it, can hold a\n // body that is ready, so it shows in its turn.\n this.line(`if ($$b.settled([${names.join(', ')}]) && $$ctx.mayShow()) {`);\n this.line(`$$ctx.enter(${boundary});`);\n for (const declaration of memos) {\n this.line(`const ${declaration.name} = $$b.read(${promiseName(declaration.name)});`);\n }\n this.emitBody(block.body);\n this.line('$$ctx.leave();');\n this.close('} else {');\n }\n this.open(scope, block);\n this.html('<!--l');\n this.code(boundary);\n this.html('-->');\n if (block.fallback) {\n // `#reveal (collapsed)` holds the fallback in a template until the body before it shows.\n this.code(`$$ctx.fallbackStart(${boundary})`);\n this.line('{');\n this.emitBody(block.fallback);\n this.close();\n this.code(`$$ctx.fallbackEnd(${boundary})`);\n }\n this.html('<!--/l-->');\n this.end(block);\n this.line(`$$ctx.defer(${boundary}, async ($$ctx) => {`);\n this.line(`let $$html = '';`);\n for (const declaration of memos) {\n this.line(`const ${declaration.name} = ${this.memoValue(declaration.name)};`);\n }\n this.emitBody(block.body);\n this.flush();\n this.line('return $$html;');\n this.close('});');\n if (inPlace) {\n this.close();\n }\n }\n\n /**\n * Renders the fallback of a `#defer` block between the markers of a\n * boundary, and a template that the loader starts when the trigger fires.\n * The body renders only in the request for it, and replaces the fallback\n * as a `#loading` body does.\n */\n private emitDefer(block: Block & { kind: 'defer' }, scope: Scope): void {\n const boundary = this.unique('boundary');\n const anchor = this.anchor(scope, block)!;\n const body = this.plan.bodyScopes.get(block.body)!;\n this.line(`const ${boundary} = $$ctx.boundary();`);\n this.html('<template b-b=\"');\n this.code(anchor.scope);\n this.html(`:${anchor.index}\" b-defer=\"${block.trigger}:`);\n this.code(boundary);\n this.html(':');\n this.code('$$ctx.base()');\n this.html('\"></template><!--l');\n this.code(boundary);\n this.html('-->');\n if (block.fallback) {\n this.line('{');\n this.emitBody(block.fallback);\n this.close();\n }\n this.html('<!--/l-->');\n this.line(\n `$$ctx.deferBlock(${boundary}, ${anchor.scope} + ${JSON.stringify(`:${anchor.index}`)}, async ($$ctx) => {`,\n );\n this.line(`let $$html = '';`);\n for (const declaration of awaitedMemos(this.plan, body, this.blocking)) {\n if (this.inline.has(declaration)) {\n continue;\n }\n this.line(`const ${declaration.name} = ${this.memoValue(declaration.name)};`);\n }\n this.emitBody(block.body);\n this.flush();\n this.line('return $$html;');\n this.close('});');\n }\n\n private open(scope: Scope, block: Block, suffix?: string): void {\n const anchor = this.anchor(scope, block);\n if (anchor) {\n this.html('<!--b');\n this.code(anchor.scope);\n this.html(`:${anchor.index}${suffix === undefined ? '' : `:${suffix}`}-->`);\n }\n }\n\n private end(block: Block): void {\n if (this.plan.anchors.has(block)) {\n this.html('<!--/b-->');\n }\n }\n\n private emitBlock(block: Block, scope: Scope): void {\n switch (block.kind) {\n case 'if':\n case 'switch': {\n const branches = block.kind === 'if' ? block.branches : block.cases;\n const fallback = block.fallback;\n branches.forEach((branch, index) => {\n if (index === 0) {\n this.line(`if ${this.expression(branch.condition)} {`);\n } else {\n this.close(`} else if ${this.expression(branch.condition)} {`);\n }\n this.open(scope, block, String(index));\n this.emitBody(branch.body);\n this.end(block);\n });\n this.close('} else {');\n this.open(scope, block, fallback ? String(branches.length) : '-1');\n if (fallback) {\n this.emitBody(fallback);\n }\n this.end(block);\n this.close();\n return;\n }\n case 'for':\n case 'repeat': {\n const list = this.unique('list');\n const item = this.unique('item');\n const index = this.unique('index');\n this.line('{');\n if (block.kind === 'for') {\n // An array is read in place. Other iterables become one.\n const value = `${list}v`;\n this.line(`const ${value} = ${this.expression(block.list)};`);\n this.line(`const ${list} = Array.isArray(${value}) ? ${value} : Array.from(${value});`);\n } else {\n this.line(\n `const ${list} = Array.from({ length: ${this.expression(block.count)} }, (_, index) => index);`,\n );\n }\n this.open(scope, block);\n const from = this.itemSource(block);\n const source = from && this.unique('source');\n if (source) {\n // One array for the list, which every item shares.\n this.line(`const ${source} = ${from};`);\n }\n // An indexed loop, without an iterator and an `[index, item]` pair for each item.\n this.line(`for (let ${index} = 0; ${index} < ${list}.length; ${index}++) {`);\n this.line(`const ${item} = ${list}[${index}];`);\n this.emitItem(block, item, index, source);\n this.close();\n if (block.fallback) {\n this.line(`if (${list}.length === 0) {`);\n this.emitBody(block.fallback);\n this.close();\n }\n this.end(block);\n this.close();\n return;\n }\n case 'try': {\n const before = this.unique('before');\n const error = this.unique('error');\n const server = this.options.mode === 'server';\n const mark = server ? this.unique('mark') : undefined;\n this.open(scope, block);\n this.flush();\n this.line(`const ${before} = $$html;`);\n if (mark) {\n this.line(`const ${mark} = $$ctx.mark();`);\n }\n this.line('try {');\n this.emitBody(block.body);\n this.close(`} catch (${error}) {`);\n this.line(`$$html = ${before};`);\n // The body's markup is not sent, so the page must not keep what it added: its\n // scopes, stylesheets, portals, head markup and `#loading` bodies.\n if (mark) {\n this.line(`$$ctx.restore(${mark});`);\n }\n if (block.error) {\n this.line(`const ${block.error.name} = ${error};`);\n }\n if (block.reset) {\n this.line(`const ${block.reset.name} = undefined;`);\n }\n this.emitBody(block.fallback);\n this.close();\n this.end(block);\n return;\n }\n case 'client': {\n const anchor = this.anchor(scope, block)!;\n const body = this.plan.bodyScopes.get(block.body)!;\n this.html('<template b-b=\"');\n this.code(anchor.scope);\n this.html(\n `:${anchor.index}\" b-client=\"${block.trigger}=${this.plan.id}#k${body.id}\"></template>`,\n );\n this.open(scope, block);\n if (block.fallback) {\n this.line('{');\n this.emitBody(block.fallback);\n this.close();\n }\n this.end(block);\n return;\n }\n case 'defer':\n if (this.options.mode === 'server') {\n this.emitDefer(block, scope);\n } else {\n // Markup that the browser renders cannot be rendered again on the server, so it keeps\n // the fallback. The compiler cannot see this when a parent in another file renders it.\n this.line(`$$b.deferInBrowser(${JSON.stringify(this.plan.id)});`);\n if (block.fallback) {\n this.line('{');\n this.emitBody(block.fallback);\n this.close();\n }\n }\n return;\n case 'loading':\n if (this.options.mode === 'server') {\n this.emitLoading(block, scope);\n return;\n }\n this.open(scope, block);\n this.line('{');\n this.emitBody(block.body);\n this.close();\n this.end(block);\n return;\n case 'portal':\n case 'head':\n this.emitPortal(block, scope);\n return;\n case 'offscreen':\n // A hidden body renders the first time it shows. The marker says which of the two\n // it is: 1 for a body that renders, and -1 for one that has not rendered yet.\n this.line(`if ${this.expression(block.visible)} {`);\n this.open(scope, block, '1');\n this.emitBody(block.body);\n this.end(block);\n this.close('} else {');\n this.open(scope, block, '-1');\n this.end(block);\n this.close();\n return;\n default:\n // `#key` renders its body in place.\n this.open(scope, block);\n this.line('{');\n this.emitBody(block.body);\n this.close();\n this.end(block);\n }\n }\n}\n\n/**\n * The classes of an element, or undefined when it can have classes that are\n * not known. Code can add classes to an element that it has a ref to or that\n * it handles events of, such as `event.currentTarget.classList`.\n */\nfunction staticClasses(attributes: Attribute[]): string[] | undefined {\n const classes: string[] = [];\n for (const attribute of attributes) {\n if (\n attribute.kind === 'spread' ||\n attribute.kind === 'computed' ||\n attribute.kind === 'ref' ||\n attribute.kind === 'event'\n ) {\n return undefined;\n }\n if (\n (attribute.kind === 'static' || attribute.kind === 'value') &&\n attribute.name.toLowerCase() === 'class'\n ) {\n if (attribute.kind === 'value') {\n return undefined;\n }\n if (attribute.value !== true) {\n classes.push(...attribute.value.split(/\\s+/).filter(Boolean));\n }\n }\n }\n return classes;\n}\n\n/** A class of a literal `class` value, with the code of its condition if it has one. */\nexport interface ClassPart {\n name: string;\n condition?: string;\n}\n\n/** The entities that escape the characters of a class in an attribute. */\nconst CLASS_ESCAPES: Record<string, string> = { '&': '&amp;', '<': '&lt;', '\"': '&quot;' };\n\n/** Escapes a class for an attribute, as the runtime does. */\nfunction escapeClass(name: string): string {\n return name.replace(/[&<\"]/g, (char) => CLASS_ESCAPES[char]!);\n}\n\n/**\n * The classes of a literal `class` value, such as `{ done: todo.done }` or\n * `['todo', { done: todo.done }]`, in the order that the runtime joins them.\n * `slice` returns the compiled code of a range of the source. Returns\n * undefined for a value that only the runtime can read, such as one with a\n * spread or a computed key.\n */\nexport function literalClasses(\n value: oxc.Node,\n slice: (start: number, end: number) => string,\n): ClassPart[] | undefined {\n if (value.type !== 'ObjectExpression' && value.type !== 'ArrayExpression') {\n return undefined;\n }\n const parts: ClassPart[] = [];\n const visit = (node: oxc.Node | null): boolean => {\n // A hole in an array renders nothing.\n if (node === null) {\n return true;\n }\n if (node.type === 'Literal' && typeof node.value === 'string') {\n if (node.value !== '') {\n parts.push({ name: node.value });\n }\n return true;\n }\n if (node.type === 'ArrayExpression') {\n return node.elements.every(visit);\n }\n if (node.type !== 'ObjectExpression') {\n return false;\n }\n const names = new Set<string>();\n for (const property of node.properties) {\n if (\n property.type !== 'Property' ||\n property.kind !== 'init' ||\n property.method ||\n property.computed\n ) {\n return false;\n }\n const { key } = property;\n let name: string | undefined;\n if (key.type === 'Identifier') {\n name = key.name;\n } else if (key.type === 'Literal' && typeof key.value === 'string') {\n name = key.value;\n }\n // The runtime puts keys like `1` first, `__proto__` sets the prototype, a key that\n // comes again keeps its first place, and an empty key adds a space.\n if (!name || /^\\d+$/.test(name) || name === '__proto__' || names.has(name)) {\n return false;\n }\n names.add(name);\n const constant = property.value;\n if (\n constant.type === 'Literal' &&\n (constant.value === null || ['boolean', 'number', 'string'].includes(typeof constant.value))\n ) {\n // A literal condition such as `true` is known now.\n if (constant.value) {\n parts.push({ name });\n }\n continue;\n }\n let condition = slice(property.value.start, property.value.end);\n if (property.shorthand) {\n // A shorthand property that the compiler rewrites becomes `name: value`.\n const whole = slice(property.start, property.end);\n if (whole.startsWith(`${name}: `)) {\n condition = whole.slice(name.length + 2);\n } else if (unmarked(whole) !== name) {\n return false;\n }\n }\n parts.push({ name, condition });\n }\n return true;\n };\n return visit(value) ? parts : undefined;\n}\n\n/**\n * The code of the text that the runtime makes of a literal class value,\n * for the client to set. An empty text removes the attribute.\n */\nexport function classText(classes: ClassPart[]): string {\n if (classes.every((part) => part.condition === undefined)) {\n return JSON.stringify(classes.map((part) => part.name).join(' '));\n }\n const [first] = classes;\n if (classes.length === 1 && first) {\n return `((${first.condition}) ? ${JSON.stringify(first.name)} : \"\")`;\n }\n const pieces = classes.map((part) => {\n const text = JSON.stringify(` ${part.name}`);\n return part.condition === undefined ? text : `((${part.condition}) ? ${text} : \"\")`;\n });\n return `(${pieces.join(' + ')}).slice(1)`;\n}\n\n/** The value of a style variable, with the text around its interpolation, such as a unit. */\nexport function variableValue(\n variable: { prefix: string; suffix: string },\n expression: string,\n): string {\n return variable.prefix || variable.suffix\n ? `$$b.affix(${JSON.stringify(variable.prefix)}, ${expression}, ${JSON.stringify(variable.suffix)})`\n : expression;\n}\n","import { isMacroImport } from '../macros.ts';\nimport type { SFCFile } from '../ast.ts';\nimport type { Declaration } from '../model.ts';\nimport type { oxc } from '../oxc.ts';\nimport { serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { minifyCSS } from '../css.ts';\nimport { Emitter, TYPE_DECLARATIONS } from './markup.ts';\nimport { Patch, addEventEdits, addValueEdits } from './patch.ts';\nimport { blockingMemos, plainValues } from './scopes.ts';\n\nexport function propsType(file: SFCFile): string {\n for (const statement of file.instanceScript?.program.body ?? []) {\n if (statement.type !== 'VariableDeclaration') {\n continue;\n }\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (\n init?.type === 'CallExpression' &&\n init.callee.type === 'Identifier' &&\n init.callee.name === '$props'\n ) {\n const type = init.typeArguments?.params[0];\n return type ? file.source.slice(type.start, type.end) : 'Record<string, any>';\n }\n }\n }\n return 'Record<string, never>';\n}\n\nfunction isTypeExport(statement: oxc.Node): boolean {\n return statement.type === 'ExportNamedDeclaration' && statement.exportKind === 'type';\n}\n\nfunction isServerStatement(statement: oxc.Node, nodes: Set<oxc.Node>): boolean {\n if (nodes.has(statement)) {\n return true;\n }\n return (\n statement.type === 'VariableDeclaration' &&\n statement.declarations.every(\n (declarator) => declarator.init !== null && nodes.has(declarator.init),\n )\n );\n}\n\n/** Returns the server functions of a file, which the server module exports for RPC. */\nexport function serverFunctions(plan: Plan): Declaration[] {\n return plan.graph.model.declarations.filter(\n (declaration) => declaration.kind === 'server-function',\n );\n}\n\nexport function generateServer(file: SFCFile, plan: Plan): string {\n const model = plan.graph.model;\n const patch = new Patch(file.source);\n addValueEdits(patch, file, model.sites, 'server', plainValues(plan, blockingMemos(plan)));\n addEventEdits(patch, model);\n const source = (node: { start: number; end: number }): string =>\n patch.slice(node.start, node.end);\n\n const header: string[] = [\"import * as $$b from 'brumate/server';\"];\n const moduleBody: string[] = [];\n const hoisted: string[] = [];\n\n if (file.moduleScript) {\n for (const statement of file.moduleScript.program.body) {\n if (isMacroImport(statement)) {\n continue;\n }\n (statement.type === 'ImportDeclaration' ? header : moduleBody).push(source(statement));\n }\n }\n\n // Server functions only capture module bindings, so they move to the module and are exported for RPC.\n const servers = serverFunctions(plan).filter((declaration) => declaration.scope !== model.module);\n const serverNodes = new Set(servers.map((declaration) => declaration.site!.node));\n\n const setup: oxc.Node[] = [];\n for (const statement of file.instanceScript?.program.body ?? []) {\n if (isMacroImport(statement)) {\n continue;\n } else if (statement.type === 'ImportDeclaration') {\n header.push(source(statement));\n } else if (TYPE_DECLARATIONS.has(statement.type) || isTypeExport(statement)) {\n moduleBody.push(source(statement));\n } else if (!isServerStatement(statement, serverNodes)) {\n setup.push(statement);\n }\n }\n for (const scope of model.scopes) {\n for (const statement of scope.body?.script?.program.body ?? []) {\n if (statement.type === 'ImportDeclaration' && !isMacroImport(statement)) {\n hoisted.push(source(statement));\n }\n }\n }\n for (const declaration of servers) {\n const node = declaration.site!.node;\n if (node.type === 'FunctionDeclaration') {\n moduleBody.push(source(node));\n } else {\n // `let`, so the function can be wrapped below.\n moduleBody.push(`let ${declaration.name} = ${source(node)};`);\n }\n }\n const exported = serverFunctions(plan).map(\n (declaration) =>\n `${JSON.stringify(serverFunctionId(plan, declaration.name))}: ${declaration.name}`,\n );\n // Every server module has it, so the server function registry can read it from any file.\n moduleBody.push(`export const rpc = { ${exported.join(', ')} };`);\n // Calls while a page renders share a result when their arguments are the same. Calls from\n // the browser use the functions of `rpc`, which run each time.\n for (const declaration of serverFunctions(plan)) {\n moduleBody.push(\n `${declaration.name} = $$b.dedupe(${declaration.name}, ${JSON.stringify(serverFunctionId(plan, declaration.name))});`,\n );\n }\n\n if (plan.styles.css) {\n // A build (`hideNames`) sends the stylesheet without comments and whitespace.\n const css = plan.hideNames ? minifyCSS(plan.styles.css) : plan.styles.css;\n moduleBody.push(`const $$css = ${JSON.stringify(css)};`);\n }\n // Holds a value that the render may await. See `Emitter.ready`.\n moduleBody.push('let $$t: any;');\n const emitter = new Emitter(file, plan, patch, { mode: 'server' });\n const generics = file.generics ? `<${file.generics}>` : '';\n emitter.line(\n `export default async function ${plan.name}${generics}($$props: ${propsType(file)}, $$ctx: $$b.Context): Promise<string> {`,\n );\n emitter.line(`let $$html = '';`);\n emitter.line(\n `const ${emitter.scopeVar(model.component)} = $$ctx.scope(${model.component.id}, undefined, ${JSON.stringify(plan.id)});`,\n );\n emitter.emitComponentContent(setup);\n emitter.line('return $$html;');\n emitter.close();\n // The ID lets the page state hold the component, such as the value of a dynamic tag.\n emitter.line(`${plan.name}.brumateId = ${JSON.stringify(plan.id)};`);\n\n return [...header, ...hoisted, ...moduleBody, '', ...emitter.lines, ''].join('\\n');\n}\n","import type { Markup, SFCFile } from '../ast.ts';\nimport type { oxc } from '../oxc.ts';\nimport { serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { minifyCSS } from '../css.ts';\nimport { Emitter, TYPE_DECLARATIONS } from './markup.ts';\nimport { Patch, addValueEdits } from './patch.ts';\nimport { propsType } from './server.ts';\nimport { copy } from '../sourcemap.ts';\n\n// Sites whose reads a render module never runs.\nconst SKIPPED_SITES = new Set(['server-function', 'event', 'effect', 'client']);\n\n/** Returns the names of the components that markup renders. */\nexport function componentNames(nodes: Markup[], names: Set<string> = new Set()): Set<string> {\n for (const node of nodes) {\n switch (node.kind) {\n case 'component':\n names.add(node.name.split('.')[0]!);\n componentNames(node.children, names);\n break;\n case 'element':\n case 'dynamic':\n case 'fragment':\n componentNames(node.children, names);\n break;\n case 'if':\n for (const branch of node.branches) {\n componentNames(branch.body.children, names);\n }\n componentNames(node.fallback?.children ?? [], names);\n break;\n case 'switch':\n for (const branch of node.cases) {\n componentNames(branch.body.children, names);\n }\n componentNames(node.fallback?.children ?? [], names);\n break;\n case 'for':\n case 'repeat':\n case 'loading':\n case 'client':\n case 'defer':\n componentNames(node.body.children, names);\n componentNames(node.fallback?.children ?? [], names);\n break;\n case 'try':\n componentNames(node.body.children, names);\n componentNames(node.fallback.children, names);\n break;\n case 'key':\n case 'portal':\n case 'head':\n case 'offscreen':\n componentNames(node.body.children, names);\n break;\n default:\n break;\n }\n }\n return names;\n}\n\n/** Returns the source of an import, with `.brm` imports pointing to render modules. */\nexport function renderImport(\n file: SFCFile,\n statement: oxc.ImportDeclaration,\n names: Set<string>,\n): string | undefined {\n const specifiers = statement.specifiers.filter((specifier) => {\n if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {\n return false;\n }\n return names.has(specifier.local.name);\n });\n if (statement.importKind === 'type' || specifiers.length === 0) {\n return undefined;\n }\n const parts: string[] = [];\n const named: string[] = [];\n for (const specifier of specifiers) {\n const local = specifier.local.name;\n if (specifier.type === 'ImportDefaultSpecifier') {\n parts.push(local);\n } else if (specifier.type === 'ImportNamespaceSpecifier') {\n parts.push(`* as ${local}`);\n } else {\n const imported = file.source.slice(specifier.imported.start, specifier.imported.end);\n named.push(imported === local ? local : `${imported} as ${local}`);\n }\n }\n if (named.length > 0) {\n parts.push(`{ ${named.join(', ')} }`);\n }\n const source = statement.source.value;\n const target = source.endsWith('.brm') ? `${source}?brumate-render` : source;\n return `import ${parts.join(', ')} from ${JSON.stringify(target)};`;\n}\n\n/** Returns the module script for client code. Server functions become `rpc` stubs. */\nexport function clientModuleScript(file: SFCFile, plan: Plan): string[] {\n const result: string[] = [];\n for (const statement of file.moduleScript?.program.body ?? []) {\n if (statement.type === 'ImportDeclaration') {\n continue;\n }\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n const found = plan.graph.model.module.declarations.get(declaration.id.name);\n if (found?.kind === 'server-function') {\n result.push(\n `const ${found.name} = (...$$a) => $$b.rpc(${JSON.stringify(serverFunctionId(plan, found.name))}, $$a);`,\n );\n continue;\n }\n }\n result.push(copy(file.source, statement.start, statement.end));\n }\n return result;\n}\n\n/** True if the render of the component awaits a promise, outside memos and the code of handlers. */\nexport function awaitsPromise(plan: Plan): boolean {\n return plan.graph.model.sites.some(\n (site) =>\n site.awaits &&\n site.kind !== 'memo' &&\n site.kind !== 'function' &&\n !SKIPPED_SITES.has(site.kind),\n );\n}\n\n/**\n * Generates the render module: the component's render function for the\n * client, used when a parent renders it inside a block that changes.\n */\nexport function generateRender(file: SFCFile, plan: Plan): string {\n const model = plan.graph.model;\n const patch = new Patch(file.source);\n addValueEdits(patch, file, model.sites, 'client');\n\n // The names that rendering reads, so server-only imports stay out.\n const names = componentNames(file.children);\n for (const template of file.templates) {\n componentNames(template.body.children, names);\n }\n for (const site of model.sites) {\n if (!SKIPPED_SITES.has(site.kind)) {\n for (const read of site.reads) {\n names.add(read.declaration.name);\n }\n }\n }\n const usesModule = [...names].some(\n (name) => model.module.declarations.get(name)?.kind === 'module',\n );\n\n const header = [\"import * as $$b from 'brumate/client';\"];\n const moduleBody: string[] = [];\n const programs: oxc.Program[] = [];\n if (file.moduleScript) {\n programs.push(file.moduleScript.program);\n }\n if (file.instanceScript) {\n programs.push(file.instanceScript.program);\n }\n for (const scope of model.scopes) {\n if (scope.body?.script && !programs.includes(scope.body.script.program)) {\n programs.push(scope.body.script.program);\n }\n }\n for (const program of programs) {\n const isModule = program === file.moduleScript?.program;\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const code =\n isModule && usesModule\n ? renderImport(\n file,\n statement,\n new Set(statement.specifiers.map((specifier) => specifier.local.name)),\n )\n : renderImport(file, statement, names);\n if (code) {\n header.push(code);\n }\n } else if (!isModule && TYPE_DECLARATIONS.has(statement.type)) {\n moduleBody.push(copy(file.source, statement.start, statement.end));\n }\n }\n }\n if (usesModule) {\n moduleBody.push(...clientModuleScript(file, plan));\n }\n for (const declaration of model.declarations) {\n if (declaration.kind === 'server-function' && declaration.scope !== model.module) {\n const ref = serverFunctionId(plan, declaration.name);\n moduleBody.push(\n `const ${declaration.name} = (...$$a) => $$b.rpc(${JSON.stringify(ref)}, $$a);`,\n );\n }\n }\n\n const setup = (file.instanceScript?.program.body ?? []).filter(\n (statement) => statement.type !== 'ImportDeclaration' && !TYPE_DECLARATIONS.has(statement.type),\n );\n if (plan.styles.css) {\n // A build (`hideNames`) sends the stylesheet without comments and whitespace.\n const css = plan.hideNames ? minifyCSS(plan.styles.css) : plan.styles.css;\n moduleBody.push(`const $$css = ${JSON.stringify(css)};`);\n }\n const emitter = new Emitter(file, plan, patch, { mode: 'client', functions: true });\n const generics = file.generics ? `<${file.generics}>` : '';\n emitter.line(\n `export default function ${plan.name}${generics}($$props: ${propsType(file)}): string {`,\n );\n // A render function cannot wait, so a component whose render awaits a promise renders only\n // on the server. Its memos can await: they load in the browser.\n if (awaitsPromise(plan)) {\n emitter.line(\n `throw new Error(${JSON.stringify(`${plan.name} awaits a promise in its script or markup, so only the server can render it`)});`,\n );\n emitter.close();\n return [...header, ...moduleBody, '', ...emitter.lines, ''].join('\\n');\n }\n emitter.line(`let $$html = '';`);\n emitter.line(\n `const ${emitter.scopeVar(model.component)} = $$b.createScope(${model.component.id}, undefined, ${JSON.stringify(plan.id)});`,\n );\n emitter.emitComponentContent(setup);\n emitter.line('return $$html;');\n emitter.close();\n\n return [...header, ...moduleBody, '', ...emitter.lines, ''].join('\\n');\n}\n","import type { Block, Range, SFCFile } from '../ast.ts';\nimport { isWithin, lookup, upstreamMemos } from '../model.ts';\nimport type { Declaration, Diagnostic, Reference, Scope, SemanticModel, Site } from '../model.ts';\nimport { children } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\nimport type { Plan } from '../plan.ts';\nimport type { SharedContext } from '../shared-module.ts';\nimport { Patch } from './patch.ts';\nimport { instanceScope, scopePath, slotIndex } from './scopes.ts';\n\nconst COMPOUND: Record<string, string> = {\n '+=': '+',\n '-=': '-',\n '*=': '*',\n '/=': '/',\n '%=': '%',\n '**=': '**',\n '<<=': '<<',\n '>>=': '>>',\n '>>>=': '>>>',\n '&=': '&',\n '|=': '|',\n '^=': '^',\n '&&=': '&&',\n '||=': '||',\n '??=': '??',\n};\n\nexport interface RewriteOptions {\n /** Declarations that are plain variables in the output, such as the item of a key function. */\n locals?: Set<Declaration>;\n /** The range to return. Defaults to the site's node. */\n range?: Range;\n /** Adds more edits, such as renaming a function. */\n edit?: (patch: Patch) => void;\n}\n\n/** Rewrites the code of client sites to read and write slots of scope instances. */\nexport class Rewriter {\n private readonly file: SFCFile;\n private readonly plan: Plan;\n private readonly diagnostics: Diagnostic[];\n\n private readonly shared: SharedContext | undefined;\n\n /** The sites of `$handler` calls, by call. */\n private readonly handlers = new Map<oxc.Node, Site>();\n /** The declarations of the names of `$bind` calls, by call. */\n private readonly bindings = new Map<oxc.Node, SemanticModel['bindings'][number]>();\n\n constructor(file: SFCFile, plan: Plan, diagnostics: Diagnostic[], shared?: SharedContext) {\n this.file = file;\n this.plan = plan;\n this.diagnostics = diagnostics;\n this.shared = shared;\n for (const site of plan.graph.model.sites) {\n if (site.handler) {\n this.handlers.set(site.handler, site);\n }\n }\n for (const binding of plan.graph.model.bindings) {\n this.bindings.set(binding.call, binding);\n }\n }\n\n /**\n * The call of the shared code of a site that a module function gave the\n * component: the function to call, and the cells of its names in this\n * call. Undefined when the site is the component's own code, or when a\n * name it reads has no value in the browser.\n */\n sharedCall(\n site: Site,\n scopeVar: string,\n base: Scope,\n ): { fn: string; refs: string; kind: 'function' | 'expression' } | undefined {\n const found = this.shared?.find(site.node);\n if (!found) {\n return undefined;\n }\n // A ref for each name: a slot of this scope, `[scope, slot]`, or `[value]`. See `cells`.\n const refs: string[] = [];\n for (const name of found.site.names) {\n const value = found.names.get(name);\n if (!value) {\n return undefined;\n }\n if ('literal' in value) {\n refs.push(`[${value.literal}]`);\n continue;\n }\n const declaration = lookup(site.scope, value.name);\n if (!declaration) {\n return undefined;\n }\n const slot = slotIndex(this.plan, declaration);\n if (slot !== -1) {\n const path = scopePath(this.plan, scopeVar, base, declaration.scope);\n refs.push(path === scopeVar ? String(slot) : `[${path}, ${slot}]`);\n continue;\n }\n const read = this.value(declaration, scopeVar, base);\n if (!read) {\n return undefined;\n }\n refs.push(`[${read}]`);\n }\n return {\n fn: `$$m${found.module}.${found.site.name}`,\n refs: `[${refs.join(', ')}]`,\n kind: found.site.kind,\n };\n }\n\n /**\n * Returns an expression for a declaration, read from code whose scope\n * instance is `scopeVar`, the instance of `base`.\n */\n value(declaration: Declaration, scopeVar: string, base: Scope): string | undefined {\n const slot = slotIndex(this.plan, declaration);\n if (slot !== -1) {\n return `$$b.get(${scopePath(this.plan, scopeVar, base, declaration.scope)}, ${slot})`;\n }\n switch (declaration.kind) {\n case 'function': {\n const owner = instanceScope(this.plan, declaration.scope);\n return `${declaration.name}$.bind(null, ${scopePath(this.plan, scopeVar, base, owner)})`;\n }\n case 'server-function':\n return `${declaration.name}$`;\n case 'reset': {\n // Renders the `#try` body again, in the range of the block.\n const block = declaration.block as Block & { kind: 'try' };\n const owner = declaration.scope.parent!;\n const body = this.plan.bodyScopes.get(block.body)!;\n const fallback = this.plan.bodyScopes.get(block.fallback)!;\n const kinds = this.plan.graph.model.scopes\n .filter((scope) => isWithin(scope, body) || isWithin(scope, fallback))\n .map((scope) => scope.id);\n const args = [\n scopePath(this.plan, scopeVar, base, owner),\n this.plan.anchors.get(block),\n JSON.stringify(this.plan.id),\n JSON.stringify(`r${body.id}`),\n JSON.stringify(`r${fallback.id}`),\n `[${kinds.join(', ')}]`,\n ];\n return `$$b.reset.bind(null, ${args.join(', ')})`;\n }\n default:\n return undefined;\n }\n }\n\n /** `$produce(todos, recipe)` writes the slot of `todos` with the result of the recipe. */\n private rewriteProduce(\n node: oxc.CallExpression,\n target: oxc.IdentifierReference,\n patch: Patch,\n references: Map<number, Reference>,\n locals: Set<Declaration>,\n scopeVar: string,\n base: Scope,\n visit: (node: oxc.Node) => void,\n ): void {\n const reference = references.get(target.start);\n const declaration = reference?.declaration;\n const slot = declaration && !locals.has(declaration) ? slotIndex(this.plan, declaration) : -1;\n if (declaration && slot !== -1) {\n const path = scopePath(this.plan, scopeVar, base, declaration.scope);\n patch.replace(\n node.start,\n target.end,\n `$$b.set(${path}, ${slot}, $$b.produce($$b.get(${path}, ${slot})`,\n );\n } else if (declaration && !locals.has(declaration)) {\n // Nothing on the client reads the value, so there is nothing to change.\n patch.replace(node.start, node.end, 'undefined');\n return;\n } else {\n patch.replace(node.start, target.end, `(${target.name} = $$b.produce(${target.name}`);\n }\n patch.insert(node.end, ')');\n for (const argument of node.arguments.slice(1)) {\n visit(argument);\n }\n }\n\n rewrite(site: Site, scopeVar: string, base: Scope, options: RewriteOptions = {}): string {\n // Code that a module function gave the component calls the shared module instead.\n if (!options.range && !options.edit && !options.locals) {\n const shared = this.sharedCall(site, scopeVar, base);\n if (shared) {\n return shared.kind === 'function'\n ? `((...$$a) => ${shared.fn}(${scopeVar}, ${shared.refs}, ...$$a))`\n : `${shared.fn}(${scopeVar}, ${shared.refs})`;\n }\n }\n const patch = this.edits(site, scopeVar, base, options);\n const range = options.range ?? site.node;\n return patch.slice(range.start, range.end);\n }\n\n /**\n * Rewrites the code of a site, and passes `read` a function that returns\n * the rewritten code of a range in it. Returns undefined for a site that\n * calls the shared module, because its code is not in the component.\n */\n rewriteRanges<T>(\n site: Site,\n scopeVar: string,\n base: Scope,\n read: (slice: (start: number, end: number) => string) => T,\n ): T | undefined {\n if (this.sharedCall(site, scopeVar, base)) {\n return undefined;\n }\n const patch = this.edits(site, scopeVar, base, {});\n return read((start, end) => patch.slice(start, end));\n }\n\n /** The edits that rewrite the code of a site. */\n private edits(site: Site, scopeVar: string, base: Scope, options: RewriteOptions): Patch {\n const patch = new Patch(this.file.source);\n const locals = options.locals ?? new Set();\n const references = new Map<number, Reference>();\n for (const reference of [...site.reads, ...site.writes]) {\n references.set(reference.range.start, reference);\n }\n const target = (node: oxc.Node): Reference | undefined => {\n if (node.type !== 'Identifier') {\n return undefined;\n }\n const reference = references.get(node.start);\n return reference && !locals.has(reference.declaration) ? reference : undefined;\n };\n const path = (declaration: Declaration): string =>\n scopePath(this.plan, scopeVar, base, declaration.scope);\n\n const visit = (node: oxc.Node): void => {\n switch (node.type) {\n case 'Identifier': {\n const reference = target(node);\n const value = reference && this.value(reference.declaration, scopeVar, base);\n if (value) {\n patch.replace(node.start, node.end, value);\n }\n return;\n }\n case 'AwaitExpression': {\n // `await name` of a memo is a plain read of its value, which is settled in the browser.\n const reference = target(node.argument);\n if (reference?.await) {\n const value = this.value(reference.declaration, scopeVar, base);\n patch.replace(node.start, node.end, value ?? reference.declaration.name);\n return;\n }\n break;\n }\n case 'Property':\n if (node.shorthand && node.value.type === 'Identifier') {\n const reference = target(node.value);\n const value = reference && this.value(reference.declaration, scopeVar, base);\n if (value) {\n patch.replace(node.start, node.end, `${node.value.name}: ${value}`);\n }\n return;\n }\n break;\n case 'AssignmentExpression': {\n const reference = target(node.left);\n if (reference) {\n const declaration = reference.declaration;\n const slot = slotIndex(this.plan, declaration);\n if (slot === -1) {\n // Nothing on the client reads it, so only the value is kept.\n patch.replace(node.start, node.right.start, '(');\n } else if (declaration.optimistic) {\n // A guess, which goes back to the source when the server calls of the page finish.\n const source = declaration.optimistic;\n const sourceSlot = slotIndex(this.plan, source);\n const reset = sourceSlot === -1 ? '' : `, ${path(source)}, ${sourceSlot}`;\n const read = `$$b.get(${path(declaration)}, ${slot})`;\n patch.replace(\n node.start,\n node.right.start,\n node.operator === '='\n ? `$$b.guess(${path(declaration)}, ${slot}${reset}, `\n : `$$b.guess(${path(declaration)}, ${slot}${reset}, ${read} ${COMPOUND[node.operator]} (`,\n );\n if (node.operator !== '=') {\n patch.insert(node.end, ')');\n }\n } else if (node.operator === '=') {\n patch.replace(\n node.start,\n node.right.start,\n `$$b.set(${path(declaration)}, ${slot}, `,\n );\n } else {\n const read = `$$b.get(${path(declaration)}, ${slot})`;\n patch.replace(\n node.start,\n node.right.start,\n `$$b.set(${path(declaration)}, ${slot}, ${read} ${COMPOUND[node.operator]} (`,\n );\n patch.insert(node.end, ')');\n }\n patch.insert(node.end, ')');\n visit(node.right);\n return;\n }\n if (node.left.type === 'ObjectPattern' || node.left.type === 'ArrayPattern') {\n const writes = site.writes.some(\n (write) => write.range.start >= node.left.start && write.range.end <= node.left.end,\n );\n if (writes) {\n this.diagnostics.push({\n severity: 'error',\n message: 'Destructuring assignment to a signal is not supported in client code yet',\n range: { start: node.start, end: node.end },\n });\n }\n }\n break;\n }\n case 'UpdateExpression': {\n const reference = target(node.argument);\n if (reference?.declaration.optimistic) {\n this.diagnostics.push({\n severity: 'error',\n message: `Assign to \"${reference.declaration.name}\" with = instead of ${node.operator}`,\n range: { start: node.start, end: node.end },\n });\n return;\n }\n if (reference) {\n const declaration = reference.declaration;\n const slot = slotIndex(this.plan, declaration);\n const delta = node.operator === '++' ? 1 : -1;\n patch.replace(\n node.start,\n node.end,\n slot === -1\n ? 'undefined'\n : `$$b.update(${path(declaration)}, ${slot}, ${delta}, ${node.prefix})`,\n );\n return;\n }\n break;\n }\n case 'CallExpression': {\n // `$handler(fn, ...args)` in code that the browser runs, such as a function that renders\n // the items of a list: a handler with its reference, which a spread passes on. The\n // function is the code of its own site.\n // `$bind(name)` passes a child the value of the name with its slot, which the child's\n // writes go to. The runtime's prop update takes the value.\n const bound = this.bindings.get(node);\n const [name, setterFn] = node.arguments;\n if (bound && name) {\n const { declaration, setter } = bound;\n const path = scopePath(this.plan, scopeVar, base, declaration.scope);\n const slot = slotIndex(this.plan, declaration);\n const symbol = setter && this.plan.symbols.get(setter);\n patch.replace(node.start, name.start, '$$b.binding((');\n if (setterFn && setter && symbol) {\n // The setter loads with its own part, so the binding holds its reference.\n const ref = JSON.stringify(`${this.plan.id}#${symbol}`);\n const owner = scopePath(\n this.plan,\n scopeVar,\n base,\n instanceScope(this.plan, setter.scope),\n );\n patch.replace(\n name.end,\n node.end,\n `), ${path}, ${slot}, $$b.handlerProp(() => {}, ${ref}, ${owner}))`,\n );\n } else {\n patch.replace(name.end, node.end, `), ${path}, ${slot})`);\n }\n visit(name);\n return;\n }\n const handler = this.handlers.get(node);\n if (handler) {\n const [fn, ...args] = node.arguments;\n const symbol = this.plan.symbols.get(handler);\n // The code of the handler loads with its part, so the call holds its reference, and\n // the modifiers of its wrappers, which the compiler read, in place of its function.\n const ref = JSON.stringify(`${this.plan.id}#${symbol}`);\n const owner = scopePath(\n this.plan,\n scopeVar,\n base,\n instanceScope(this.plan, handler.scope),\n );\n const modifiers = JSON.stringify(handler.modifiers ?? []);\n patch.replace(node.start, fn!.end, `$$b.handlerProp(() => {}, ${ref}, ${owner}`);\n if (args.length === 0) {\n patch.replace(fn!.end, node.end, `, [], ${modifiers})`);\n } else {\n patch.replace(fn!.end, args[0]!.start, ', [');\n patch.replace(args.at(-1)!.end, node.end, `], ${modifiers})`);\n }\n for (const argument of args) {\n visit(argument);\n }\n return;\n }\n // A call of a local function passes the scope itself. `.bind` is only for a function\n // value that escapes, such as one passed as an argument.\n const fn = target(node.callee)?.declaration;\n if (fn?.kind === 'function' && slotIndex(this.plan, fn) === -1) {\n const owner = scopePath(this.plan, scopeVar, base, instanceScope(this.plan, fn.scope));\n const open = this.file.source.indexOf('(', node.typeArguments?.end ?? node.callee.end);\n patch.replace(node.callee.start, node.callee.end, `${fn.name}$`);\n patch.insert(open + 1, node.arguments.length > 0 ? `${owner}, ` : owner);\n for (const argument of node.arguments) {\n visit(argument);\n }\n return;\n }\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === '$isPending' &&\n !references.has(node.callee.start)\n ) {\n const memo = node.arguments[0];\n const declaration = memo && references.get(memo.start)?.declaration;\n // A memo is pending while it or a memo that it reads loads.\n const checks = (\n declaration ? [declaration, ...upstreamMemos(declaration)] : []\n ).flatMap((item) => {\n const slot = slotIndex(this.plan, item);\n return slot === -1 ? [] : [`$$b.pending(${path(item)}, ${slot})`];\n });\n let value: string;\n if (checks.length === 0) {\n value = 'false';\n } else if (checks.length === 1) {\n value = checks[0]!;\n } else {\n value = `(${checks.join(' || ')})`;\n }\n patch.replace(node.start, node.end, value);\n return;\n }\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === '$produce' &&\n !references.has(node.callee.start) &&\n node.arguments[0]?.type === 'Identifier'\n ) {\n this.rewriteProduce(\n node,\n node.arguments[0],\n patch,\n references,\n locals,\n scopeVar,\n base,\n visit,\n );\n return;\n }\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === '$untrack' &&\n node.arguments[0] &&\n !references.has(node.callee.start)\n ) {\n const argument = node.arguments[0];\n patch.replace(node.start, argument.start, '(');\n patch.replace(argument.end, node.end, ')');\n visit(argument);\n return;\n }\n break;\n }\n case 'MemberExpression':\n visit(node.object);\n if (node.computed) {\n visit(node.property);\n }\n return;\n default:\n break;\n }\n for (const [key, child] of children(node)) {\n if (\n key === 'typeAnnotation' ||\n key === 'typeArguments' ||\n key === 'typeParameters' ||\n key === 'returnType'\n ) {\n continue;\n }\n if (node.type === 'Property' && key === 'key' && !node.computed) {\n continue;\n }\n visit(child);\n }\n };\n\n visit(site.node);\n options.edit?.(patch);\n return patch;\n }\n}\n","import { isMacroImport } from '../macros.ts';\nimport type {\n Block,\n Body,\n DynamicTagNode,\n ForBlock,\n Markup,\n RepeatBlock,\n SFCFile,\n} from '../ast.ts';\nimport { tryCatchesClient } from '../graph.ts';\nimport type { GraphNode } from '../graph.ts';\nimport { isWithin } from '../model.ts';\nimport type { Declaration, Diagnostic, Scope, Site } from '../model.ts';\nimport { getPatternNames } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\nimport { blockBodies, serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { Emitter, classText, decodeAttribute, literalClasses, variableValue } from './markup.ts';\nimport { Patch, addValueEdits } from './patch.ts';\nimport { clientModuleScript, componentNames, renderImport } from './render.ts';\nimport type { SharedContext } from '../shared-module.ts';\nimport { Rewriter } from './rewrite.ts';\nimport { instanceScope, scopePath, slotIndex } from './scopes.ts';\nimport { copy, unmarked } from '../sourcemap.ts';\n\nexport interface ClientOutput {\n /** The entry module: the component ID, its props, its update table and its part loaders. */\n code: string;\n /**\n * The parts, by name. `h<n>` and `c<n>` parts hold one client root each,\n * `update` holds the code that updates the page, and `shared` holds the\n * functions that more than one part calls.\n */\n parts: Record<string, string>;\n /** The ID, the props map, the update table and the refresh table: what the page depends on. */\n table: string;\n /**\n * The parts that each export part loads, by name: its own first, then the\n * ones it starts loading with it. Empty when the entry holds the code.\n */\n loaders: Record<string, string[]>;\n /** False when nothing of the component runs in the browser. */\n clientCode: boolean;\n diagnostics: Diagnostic[];\n}\n\n/**\n * About the size of code after a minifier: without comments, extra\n * whitespace and long generated names. Merging parts compares it.\n */\nexport function minifiedSize(code: string): number {\n return code\n .replace(/\\/\\*[\\s\\S]*?\\*\\/|^\\s*\\/\\/[^\\n]*/gm, '')\n .replace(/\\$\\$\\w+/g, 'e')\n .replace(/\\s+/g, ' ')\n .replace(/ ?([{}()[\\];,:=+\\-*/<>!?&|.]) ?/g, '$1').length;\n}\n\n/**\n * The `merge` of the Vite plugin. Below it, one module costs less than the\n * entry and the parts that a first event loads: each file has its own\n * request, imports and gzip header, and the parts wait for the entry.\n */\nexport const DEFAULT_MERGE = 4096;\n\n/** The part that holds an export of a client module. */\nexport function partOf(name: string): string {\n return /^[hct]\\d/.test(name) ? name : 'update';\n}\n\n// Sites whose code does not run while a body renders.\nconst DEFERRED_SITES = new Set(['function', 'server-function', 'event', 'effect', 'client']);\n\n/**\n * Generates the client entry and its parts. When the parts are smaller than\n * `merge` bytes in all, after minifying, the entry holds their code itself,\n * so the first event loads one module instead of several.\n */\nexport function generateClient(\n file: SFCFile,\n plan: Plan,\n merge = 0,\n shared?: SharedContext,\n): ClientOutput {\n return new ClientGenerator(file, plan, merge, shared).generate();\n}\n\nclass ClientGenerator {\n private readonly file: SFCFile;\n private readonly plan: Plan;\n private readonly diagnostics: Diagnostic[] = [];\n private readonly rewriter: Rewriter;\n private readonly valuePatch: Patch;\n /** Code by part. */\n private readonly out = new Map<string, string[]>();\n /** The part that `emit` writes to. */\n private part = 'update';\n /** The sites whose code each part holds, before functions are placed. */\n private readonly reach = new Map<string, Set<Site>>();\n /** The part of each client function. */\n private readonly placement = new Map<Declaration, string>();\n private readonly live = new Map<Site, GraphNode>();\n /** The export that updates each live node. */\n private readonly updates = new Map<GraphNode, string>();\n /** Bodies that the client renders, by scope. */\n private readonly renders = new Map<Scope, { body: Body; block: Block }>();\n\n private readonly merge: number;\n private readonly shared: SharedContext | undefined;\n\n constructor(file: SFCFile, plan: Plan, merge: number, shared?: SharedContext) {\n this.merge = merge;\n this.file = file;\n this.plan = plan;\n this.shared = shared;\n this.rewriter = new Rewriter(file, plan, this.diagnostics, shared);\n this.valuePatch = new Patch(file.source);\n addValueEdits(this.valuePatch, file, plan.graph.model.sites, 'client');\n for (const node of plan.graph.nodes) {\n if (node.kind !== 'source' && plan.graph.live.has(node)) {\n this.live.set(node.site, node);\n }\n }\n }\n\n private get model() {\n return this.plan.graph.model;\n }\n\n private error(message: string, range: { start: number; end: number }): void {\n this.diagnostics.push({\n severity: 'error',\n message,\n range: { start: range.start, end: range.end },\n });\n }\n\n private emit(code: string): void {\n const lines = this.out.get(this.part) ?? [];\n this.out.set(this.part, lines);\n lines.push(code);\n }\n\n generate(): ClientOutput {\n this.collectRenders();\n this.checkSupport();\n this.placeCode();\n\n this.emitFunctions();\n this.emitRoots();\n this.part = 'update';\n this.emitUpdates();\n this.emitRenders();\n\n const parts: Record<string, string> = {};\n for (const name of new Set([...this.out.keys(), ...this.reach.keys()])) {\n // A component whose updates are all on the server has no `update` part.\n if (name !== 'shared' && (this.out.get(name)?.length ?? 0) > 0) {\n parts[name] = this.assemble(name);\n }\n }\n if (this.out.has('shared') || this.usesModuleScript()) {\n parts.shared = this.assembleShared();\n }\n const names = Object.keys(parts).filter((name) => name !== 'shared');\n // The minified size decides, because that is what the browser loads.\n const size = Object.values(parts).reduce((total, code) => total + minifiedSize(code), 0);\n const merged = !parts.shared && names.length > 0 && size < this.merge;\n if (merged) {\n for (const name of names) {\n delete parts[name];\n }\n parts.all = this.assembleAll(names);\n }\n // A part that calls shared code of module functions imports their shared modules.\n for (const [name, code] of Object.entries(parts)) {\n const used = new Set([...code.matchAll(/\\$\\$m(\\d+)\\./g)].map((match) => Number(match[1])));\n if (used.size > 0) {\n const imports = [...used].map(\n (index) =>\n `import * as $$m${index} from ${JSON.stringify(this.shared!.specifiers[index])};`,\n );\n parts[name] = `${imports.join('\\n')}\\n${code}`;\n }\n }\n const refresh = this.refreshTable();\n const tries = this.triesTable();\n const table = [\n `export const id = ${JSON.stringify(this.plan.id)};`,\n `export const props = ${this.propsMap()};`,\n `export const g = ${this.table()};`,\n ...(refresh ? [`export const refresh = ${refresh};`] : []),\n ...(tries ? [`export const t = ${tries};`] : []),\n ];\n const clientCode = names.length > 0;\n if (merged || !clientCode) {\n // The entry holds the code itself, so the first event loads one module. An entry\n // without `load` is its own only part.\n const code = parts.all ?? '';\n delete parts.all;\n return {\n code: [code, ...table, ''].join('\\n'),\n table: table.join('\\n'),\n parts,\n loaders: Object.fromEntries(names.map((name) => [name, []])),\n clientCode,\n diagnostics: this.diagnostics,\n };\n }\n // A handler that writes a slot that the page shows loads the updates with its own part,\n // so the write does not wait for another request.\n const writers = this.liveWrites();\n const loaders: Record<string, string[]> = {};\n for (const name of names) {\n loaders[name] =\n name !== 'update' && parts.update && writers.has(name) ? [name, 'update'] : [name];\n }\n const withUpdate = Object.values(loaders).some((list) => list.length > 1);\n const lines = Object.entries(loaders).map(([name, [own, extra]]) => {\n if (name === 'update' && withUpdate) {\n return ' \"update\": update,';\n }\n const load = `import(${JSON.stringify(this.partPath(own!))})`;\n return ` ${JSON.stringify(name)}: () => ${extra ? `(update().catch(() => {}), ${load})` : load},`;\n });\n const entry = [\n ...table,\n ...(withUpdate\n ? [`const update = () => import(${JSON.stringify(this.partPath('update'))});`]\n : []),\n 'const parts = {',\n ...lines,\n '};',\n '/** Imports a part of this module. */',\n 'export function load(part) {',\n ' return parts[part]();',\n '}',\n '',\n ];\n return {\n code: entry.join('\\n'),\n table: table.join('\\n'),\n parts,\n loaders,\n clientCode,\n diagnostics: this.diagnostics,\n };\n }\n\n /**\n * The parts whose code can write a slot that an update reads, or that call\n * shared code of a module function, which can write one.\n */\n private liveWrites(): Set<string> {\n const live = new Set<Declaration>();\n for (const edge of this.plan.graph.edges) {\n const from = edge.from;\n if ((from.kind === 'source' || from.kind === 'memo') && this.updates.has(edge.to)) {\n live.add(from.declaration);\n }\n }\n const result = new Set<string>();\n for (const [name, sites] of this.reach) {\n for (const site of sites) {\n if (\n site.writes.some((write) => live.has(write.declaration)) ||\n site.reads.some((read) => read.declaration.kind === 'reset') ||\n this.shared?.find(site.node) !== undefined\n ) {\n result.add(name);\n break;\n }\n }\n }\n return result;\n }\n\n /** The import path of a part, relative to the component's file. */\n private partPath(name: string): string {\n const base = this.file.filename.split(/[\\\\/]/).pop()!;\n return `./${base}?brumate-client&part=${name}`;\n }\n\n /** Follows the client functions that sites call. */\n private closure(seed: Iterable<Site>): Set<Site> {\n const result = new Set<Site>();\n const visit = (site: Site): void => {\n if (result.has(site)) {\n return;\n }\n result.add(site);\n for (const callee of site.calls) {\n if (callee.kind === 'function' && callee.site) {\n visit(callee.site);\n }\n }\n };\n for (const site of seed) {\n visit(site);\n }\n return result;\n }\n\n /** Decides which part holds each client root, update and function. */\n private placeCode(): void {\n for (const [site, symbol] of this.plan.symbols) {\n this.reach.set(symbol, this.closure([site]));\n }\n const updates = [...this.plan.clientSites].filter(\n (site) =>\n !this.plan.symbols.has(site) && site.kind !== 'function' && site.kind !== 'server-function',\n );\n for (const scope of this.renderedScopes()) {\n for (const site of this.model.sites) {\n if (isWithin(site.scope, scope) && !DEFERRED_SITES.has(site.kind)) {\n updates.push(site);\n }\n }\n }\n this.reach.set('update', this.closure(updates));\n for (const declaration of this.model.declarations) {\n const site = declaration.site;\n if (declaration.kind !== 'function' || !site || !this.plan.clientSites.has(site)) {\n continue;\n }\n const users = [...this.reach].filter(([, sites]) => sites.has(site)).map(([name]) => name);\n this.placement.set(declaration, users.length === 1 ? users[0]! : 'shared');\n }\n }\n\n /** The sites whose code a part holds: its own sites and the functions placed in it. */\n private partSites(name: string): Site[] {\n const result: Site[] = [];\n for (const site of this.reach.get(name) ?? []) {\n const declaration = site.declaration;\n if (site.kind === 'function' && declaration) {\n if (this.placement.get(declaration) === name) {\n result.push(site);\n }\n } else {\n result.push(site);\n }\n }\n if (name === 'shared') {\n for (const [declaration, part] of this.placement) {\n if (part === 'shared') {\n result.push(declaration.site!);\n }\n }\n }\n return result;\n }\n\n private reads(sites: Site[]): Set<Declaration> {\n const result = new Set<Declaration>();\n for (const site of sites) {\n // Shared code of a module function imports what it needs itself. The part only builds its\n // cells, which read values and functions of the component. Code whose names have no value\n // in the browser, such as a constant of the module script, is copied with its imports.\n const shared =\n this.rewriter.sharedCall(site, '$$s', instanceScope(this.plan, site.scope)) !== undefined;\n for (const read of site.reads) {\n if (!shared || read.declaration.kind !== 'import') {\n result.add(read.declaration);\n }\n }\n }\n return result;\n }\n\n /** The import statements for the names that some code reads. */\n private importsFor(names: Set<string>, components: boolean): string[] {\n if (components) {\n for (const scope of this.renderedScopes()) {\n componentNames(scope.body?.children ?? [], names);\n }\n }\n const result: string[] = [];\n for (const program of this.programs()) {\n if (program === this.file.moduleScript?.program) {\n continue;\n }\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n const code = renderImport(this.file, statement, names);\n if (code) {\n result.push(code);\n }\n }\n }\n }\n return result;\n }\n\n private programs(): oxc.Program[] {\n const result: oxc.Program[] = [];\n if (this.file.moduleScript) {\n result.push(this.file.moduleScript.program);\n }\n if (this.file.instanceScript) {\n result.push(this.file.instanceScript.program);\n }\n for (const scope of this.model.scopes) {\n if (scope.body?.script && !result.includes(scope.body.script.program)) {\n result.push(scope.body.script.program);\n }\n }\n return result;\n }\n\n private assemble(name: string): string {\n const reads = this.reads(this.partSites(name));\n const names = new Set(\n [...reads].filter((item) => item.kind === 'import').map((item) => item.name),\n );\n const shared = [...reads]\n .filter(\n (item) =>\n (item.kind === 'function' && this.placement.get(item) === 'shared') ||\n (item.kind === 'module' && item.scope === this.model.module),\n )\n .map((item) => (item.kind === 'function' ? `${item.name}$` : item.name));\n const lines = [\n \"import * as $$b from 'brumate/client';\",\n ...this.importsFor(names, name === 'update'),\n ];\n if (shared.length > 0) {\n lines.push(\n `import { ${[...new Set(shared)].join(', ')} } from ${JSON.stringify(this.partPath('shared'))};`,\n );\n }\n lines.push('', ...this.serverStubs([name]), ...(this.out.get(name) ?? []), '');\n return lines.join('\\n');\n }\n\n /** One module with the code of every part, for a small component. */\n private assembleAll(names: string[]): string {\n const imports = new Set<string>();\n for (const name of names) {\n for (const item of this.reads(this.partSites(name))) {\n if (item.kind === 'import') {\n imports.add(item.name);\n }\n }\n }\n const lines = [\n \"import * as $$b from 'brumate/client';\",\n ...this.importsFor(imports, true),\n '',\n ...this.serverStubs(names),\n ];\n for (const name of names) {\n lines.push('', ...(this.out.get(name) ?? []));\n }\n lines.push('');\n return lines.join('\\n');\n }\n\n private assembleShared(): string {\n const reads = this.reads(this.partSites('shared'));\n const names = new Set(\n [...reads].filter((item) => item.kind === 'import').map((item) => item.name),\n );\n const lines = [\"import * as $$b from 'brumate/client';\", ...this.importsFor(names, false)];\n if (this.usesModuleScript()) {\n for (const statement of this.file.moduleScript!.program.body) {\n if (statement.type === 'ImportDeclaration' && !isMacroImport(statement)) {\n lines.push(copy(this.file.source, statement.start, statement.end));\n }\n }\n lines.push(...clientModuleScript(this.file, this.plan));\n const exported = new Set<string>();\n for (const statement of this.file.moduleScript!.program.body) {\n if (statement.type === 'ExportNamedDeclaration' && statement.declaration) {\n for (const declaration of this.model.module.declarations.values()) {\n if (\n declaration.range.start >= statement.start &&\n declaration.range.end <= statement.end\n ) {\n exported.add(declaration.name);\n }\n }\n }\n }\n const rest = [...this.model.module.declarations.values()]\n .filter((declaration) => declaration.kind === 'module' && !exported.has(declaration.name))\n .map((declaration) => declaration.name);\n if (rest.length > 0) {\n lines.push(`export { ${rest.join(', ')} };`);\n }\n }\n lines.push('', ...this.serverStubs(['shared']), ...(this.out.get('shared') ?? []), '');\n return lines.join('\\n');\n }\n\n // Checks\n\n private checkSupport(): void {\n const rendered = this.renderedScopes();\n for (const site of this.model.sites) {\n const live = this.live.has(site);\n if (live && site.kind === 'tag' && !(site.owner as DynamicTagNode | undefined)?.keyed) {\n this.error('A dynamic tag that changes on the client is not supported yet', site.range);\n }\n // A render function or an update runs without waiting, so it can await only a memo, whose\n // value is settled in the browser. A memo that awaits a promise loads it instead.\n if (\n site.awaits &&\n site.kind !== 'memo' &&\n !DEFERRED_SITES.has(site.kind) &&\n (live || rendered.some((scope) => isWithin(site.scope, scope)))\n ) {\n this.error(\n live\n ? 'Code that the browser updates can await only a memo. Load the promise in a memo instead'\n : 'Markup that the browser renders can await only a memo. Load the promise in a memo instead',\n site.range,\n );\n }\n }\n }\n\n // Imports and module code\n\n private clientReads(): Set<Declaration> {\n const reads = new Set<Declaration>();\n for (const site of this.plan.clientSites) {\n for (const read of site.reads) {\n reads.add(read.declaration);\n }\n }\n for (const scope of this.renderedScopes()) {\n for (const site of this.model.sites) {\n if (isWithin(site.scope, scope)) {\n for (const read of site.reads) {\n reads.add(read.declaration);\n }\n }\n }\n }\n return reads;\n }\n\n private usesModuleScript(): boolean {\n return [...this.clientReads()].some((declaration) => declaration.kind === 'module');\n }\n\n /** Every scope that a render function of this module renders, including templates. */\n private renderedScopes(): Scope[] {\n const result = new Set<Scope>();\n for (const scope of this.renders.keys()) {\n for (const item of this.inside(scope)) {\n result.add(item);\n }\n }\n return [...result];\n }\n\n /** A body scope and the template scopes that it calls, directly or through other templates. */\n private inside(scope: Scope): Scope[] {\n const result: Scope[] = [scope];\n for (let i = 0; i < result.length; i++) {\n const current = result[i]!;\n for (const site of this.model.sites) {\n if (!isWithin(site.scope, current) || DEFERRED_SITES.has(site.kind)) {\n continue;\n }\n for (const callee of site.calls) {\n if (callee.kind !== 'template') {\n continue;\n }\n const template = this.model.scopes.find(\n (item) => item.template?.name === callee.name && item.parent === callee.scope,\n );\n if (template && !result.some((item) => isWithin(template, item))) {\n result.push(template);\n }\n }\n }\n }\n return result;\n }\n\n private propsMap(): string {\n const entries: string[] = [];\n for (const statement of this.file.instanceScript?.program.body ?? []) {\n if (statement.type !== 'VariableDeclaration') {\n continue;\n }\n for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (\n !(\n init?.type === 'CallExpression' &&\n init.callee.type === 'Identifier' &&\n init.callee.name === '$props'\n )\n ) {\n continue;\n }\n const component = this.model.component;\n if (declarator.id.type === 'Identifier') {\n const slot = slotIndex(this.plan, component.declarations.get(declarator.id.name)!);\n if (slot !== -1) {\n entries.push(`\"*\": ${slot}`);\n }\n } else if (declarator.id.type === 'ObjectPattern') {\n for (const property of declarator.id.properties) {\n if (property.type === 'RestElement' || property.computed) {\n continue;\n }\n const key =\n property.key.type === 'Identifier'\n ? property.key.name\n : String((property.key as { value?: unknown }).value);\n const [name] = getPatternNames(property.value);\n const declaration = name && component.declarations.get(name.name);\n const slot = declaration ? slotIndex(this.plan, declaration) : -1;\n if (slot !== -1) {\n entries.push(`${JSON.stringify(key)}: ${slot}`);\n }\n }\n }\n }\n }\n return `{ ${entries.join(', ')} }`;\n }\n\n // Functions\n\n /**\n * A stub for each server function that some parts call, also one of the\n * module script. A merged module gets each stub once.\n */\n private serverStubs(names: string[]): string[] {\n const result = new Set<string>();\n for (const name of names) {\n for (const declaration of this.reads(this.partSites(name))) {\n if (declaration.kind === 'server-function') {\n const ref = serverFunctionId(this.plan, declaration.name);\n result.add(\n `const ${declaration.name}$ = (...$$a) => $$b.rpc(${JSON.stringify(ref)}, $$a);`,\n );\n }\n }\n }\n return [...result];\n }\n\n private emitFunctions(): void {\n for (const declaration of this.model.declarations) {\n const site = declaration.site;\n if (declaration.kind !== 'function' || !site || !this.plan.clientSites.has(site)) {\n continue;\n }\n const fn = site.node as oxc.Function | oxc.ArrowFunctionExpression;\n const base = instanceScope(this.plan, declaration.scope);\n // A function that a module function gave the component calls its shared code.\n const shared = this.rewriter.sharedCall(site, '$$s', base);\n if (shared) {\n this.part = this.placement.get(declaration)!;\n this.emit(\n `${this.part === 'shared' ? 'export ' : ''}const ${declaration.name}$ = ($$s, ...$$a) => ${shared.fn}($$s, ${shared.refs}, ...$$a);`,\n );\n continue;\n }\n const code = this.rewriter.rewrite(site, '$$s', base, {\n edit: (patch) => {\n if (fn.type === 'FunctionDeclaration' && fn.id) {\n patch.replace(fn.id.start, fn.id.end, `${declaration.name}$`);\n }\n const first = fn.params[0];\n if (first) {\n // An arrow such as `(n) => n` starts at its parenthesis.\n const parenthesized = this.file.source.lastIndexOf('(', first.start) >= fn.start;\n patch.insert(first.start, parenthesized ? '$$s, ' : '($$s, ');\n if (!parenthesized) {\n patch.insert(first.end, ')');\n }\n } else {\n const open = this.file.source.indexOf(\n '(',\n fn.type === 'FunctionDeclaration' && fn.id ? fn.id.end : fn.start,\n );\n patch.insert(open + 1, '$$s');\n }\n },\n });\n this.part = this.placement.get(declaration)!;\n const prefix = this.part === 'shared' ? 'export ' : '';\n this.emit(\n fn.type === 'FunctionDeclaration'\n ? `${prefix}${code}`\n : `${prefix}const ${declaration.name}$ = ${code};`,\n );\n }\n }\n\n private emitRoots(): void {\n for (const site of this.model.sites) {\n const symbol = this.plan.symbols.get(site);\n if (!symbol) {\n continue;\n }\n const base = instanceScope(this.plan, site.scope);\n // A template passed as a prop, such as `item=option`, renders in the browser with its code.\n let code = this.withTemplates(site, this.rewriter.rewrite(site, '$$s', base));\n // A method of a provided object, such as `reset() {}`, has no `function` keyword of its own.\n if (site.node.type === 'FunctionExpression' && unmarked(code).trimStart().startsWith('(')) {\n code = `function ${code}`;\n }\n this.part = symbol;\n if (site.kind === 'client') {\n this.emit(\n `export function ${symbol}($$s) {\\n $$b.effect($$s, ${JSON.stringify(symbol)}, ${code});\\n}`,\n );\n } else {\n this.emit(this.handlerExport(site, symbol, code, base));\n }\n }\n }\n\n /**\n * The export of a handler, which the core calls with the scope and the\n * arguments. A local function already takes them, so it is exported as it\n * is. An arrow function gets the scope as its first parameter.\n */\n private handlerExport(site: Site, symbol: string, code: string, base: Scope): string {\n const node = site.node;\n const fn =\n node.type === 'Identifier'\n ? site.reads.find((read) => read.range.start === node.start)?.declaration\n : undefined;\n if (fn?.kind === 'function' && slotIndex(this.plan, fn) === -1) {\n const owner = scopePath(this.plan, '$$s', base, instanceScope(this.plan, fn.scope));\n if (owner === '$$s') {\n return `export { ${fn.name}$ as ${symbol} };`;\n }\n return `export const ${symbol} = ($$s, ...$$a) => ${fn.name}$(${owner}, ...$$a);`;\n }\n if (node.type === 'ArrowFunctionExpression' && !this.rewriter.sharedCall(site, '$$s', base)) {\n const arrow = this.rewriter.rewrite(site, '$$s', base, {\n edit: (patch) => {\n const first = node.params[0];\n if (first) {\n // An arrow such as `(n) => n` starts at its parenthesis, after `async` if it has it.\n const parenthesized = this.file.source.lastIndexOf('(', first.start) >= node.start;\n patch.insert(first.start, parenthesized ? '$$s, ' : '($$s, ');\n if (!parenthesized) {\n patch.insert(first.end, ')');\n }\n } else {\n patch.insert(this.file.source.indexOf('(', node.start) + 1, '$$s');\n }\n },\n });\n return `export const ${symbol} = ${arrow};`;\n }\n return `export const ${symbol} = ($$s, ...$$a) => (${code})(...$$a);`;\n }\n\n // Updates\n\n private emitUpdates(): void {\n const blocks = new Map<Block, string>();\n for (const node of this.plan.graph.nodes) {\n if (node.kind === 'source' || !this.plan.graph.live.has(node)) {\n continue;\n }\n const site = node.site;\n const base = instanceScope(this.plan, site.scope);\n const expression = (): string =>\n this.withTemplates(site, this.rewriter.rewrite(site, '$$s', base));\n // A literal class value, as the code of its text. A template call needs the code around it.\n const classes = (value: oxc.Node): string | undefined => {\n if ([...site.calls].some((callee) => callee.kind === 'template')) {\n return undefined;\n }\n const parts = this.rewriter.rewriteRanges(site, '$$s', base, (slice) =>\n literalClasses(value, slice),\n );\n return parts && classText(parts);\n };\n const name = (prefix: string): string => {\n const value = `${prefix}${site.id}`;\n this.updates.set(node, value);\n return value;\n };\n switch (node.kind) {\n case 'memo': {\n const slot = slotIndex(this.plan, node.declaration);\n if (slot !== -1) {\n // A promise is loaded with the old value kept until it settles. `await` needs an async function.\n const value = site.awaits ? `(async () => (${expression()}))()` : expression();\n const timing = node.declaration.timing;\n // A debounced or throttled memo computes after its wait, with the values of then.\n const call = timing\n ? `$$b.timed($$s, ${slot}, ${timing.ms}, ${timing.kind === 'throttled'}, () => ${value})`\n : `$$b.memo($$s, ${slot}, () => ${value})`;\n this.emit(`export function ${name('m')}($$s) {\\n ${call};\\n}`);\n }\n break;\n }\n case 'effect':\n this.emit(\n `export function ${name('e')}($$s) {\\n $$b.effect($$s, ${JSON.stringify(`e${site.id}`)}, ${expression()});\\n}`,\n );\n break;\n case 'binding':\n this.emitBinding(node, site, expression, name, classes);\n break;\n case 'block': {\n if (site.label === 'for key') {\n break;\n }\n const existing = blocks.get(node.block);\n if (existing) {\n this.updates.set(node, existing);\n break;\n }\n const fn = name('b');\n blocks.set(node.block, fn);\n this.emitBlockUpdate(node.block, fn, base);\n break;\n }\n }\n }\n }\n\n private emitBinding(\n node: GraphNode,\n site: Site,\n expression: () => string,\n name: (prefix: string) => string,\n classes: (node: oxc.Node) => string | undefined,\n ): void {\n const owner = site.owner;\n if (site.kind === 'insert') {\n const insert = this.findInsert(site);\n const anchor = insert && this.plan.anchors.get(insert);\n if (anchor !== undefined) {\n let fn = 'text';\n if (this.plan.textContents.has(insert!)) {\n fn = 'writeText';\n } else if (this.plan.contents.has(insert!)) {\n fn = 'content';\n }\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.${fn}($$s, ${anchor}, ${expression()});\\n}`,\n );\n }\n return;\n }\n if (site.kind === 'title') {\n this.emit(`export function ${name('u')}($$s) {\\n $$b.title(${expression()});\\n}`);\n return;\n }\n if (site.kind === 'provide') {\n const context = site.extra![0]!;\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.updateContext($$s, ${copy(this.file.source, context.start, context.end)}, ${expression()});\\n}`,\n );\n return;\n }\n if (site.kind === 'style') {\n const variable = this.plan.styles.variables.find((item) => item.expression.ast === site.node);\n if (variable) {\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.setVar($$s, ${JSON.stringify(variable.name)}, ${variableValue(variable, expression())});\\n}`,\n );\n }\n return;\n }\n // The `#key` block around a dynamic tag renders it again when the tag changes.\n if (!owner || owner.kind === 'listener' || site.kind === 'tag') {\n return;\n }\n const anchor = this.plan.anchors.get(owner);\n if (anchor === undefined) {\n return;\n }\n const attribute = owner.attributes.find(\n (item) =>\n (item.kind === 'value' && item.value.ast === site.node) ||\n (item.kind === 'event' && item.handler.ast === site.node) ||\n (item.kind === 'spread' && item.value.ast === site.node),\n );\n if (\n !attribute ||\n attribute.kind === 'static' ||\n attribute.kind === 'ref' ||\n attribute.kind === 'prefetch' ||\n attribute.kind === 'computed'\n ) {\n this.error('This attribute cannot change on the client yet', site.range);\n return;\n }\n if (owner.kind === 'component') {\n if (attribute.kind === 'spread') {\n // The props after the spread win over it, as on the server.\n const after = owner.attributes\n .slice(owner.attributes.indexOf(attribute) + 1)\n .flatMap((item) =>\n item.kind === 'static' || item.kind === 'value' || item.kind === 'event'\n ? [item.name]\n : [],\n );\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.spreadProps($$s, ${anchor}, ${expression()}, ${JSON.stringify(after)});\\n}`,\n );\n return;\n }\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.prop($$s, ${anchor}, ${JSON.stringify(attribute.name)}, ${expression()});\\n}`,\n );\n return;\n }\n if (attribute.kind === 'spread') {\n // The attributes that are the element's own, which the spread does not remove.\n const own = owner.attributes.flatMap((item) =>\n item.kind === 'static' || item.kind === 'value' ? [item.name] : [],\n );\n if (this.plan.styles.css) {\n own.push(this.plan.styles.attribute, 'style');\n }\n // The element's static attributes merge with the spread in their order, as on the server.\n const parts = owner.attributes.flatMap((item) => {\n if (item === attribute) {\n return [expression()];\n }\n return item.kind === 'static'\n ? [\n `{ ${JSON.stringify(item.name)}: ${item.value === true ? \"''\" : JSON.stringify(decodeAttribute(item.value))} }`,\n ]\n : [];\n });\n const value = parts.length > 1 ? `$$b.mergeAttributes([${parts.join(', ')}])` : expression();\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.attrs($$s, ${anchor}, ${value}, ${JSON.stringify(own)});\\n}`,\n );\n } else if (attribute.kind === 'value') {\n const value =\n (attribute.name === 'class' ? classes(attribute.value.ast) : undefined) ?? expression();\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.attr($$s, ${anchor}, ${JSON.stringify(attribute.name)}, ${value});\\n}`,\n );\n }\n void node;\n }\n\n private findInsert(site: Site): Markup | undefined {\n for (const target of this.plan.anchors.keys()) {\n if (\n 'expression' in target &&\n target.kind === 'insert' &&\n target.expression.ast === site.node\n ) {\n return target;\n }\n }\n return undefined;\n }\n\n private headerSites(block: Block): Site[] {\n return this.model.sites.filter(\n (site) => site.kind === 'block' && site.block === block && site.label !== 'for key',\n );\n }\n\n /** The scope IDs inside the bodies of a block, for disposing their instances. */\n private kinds(bodies: Body[]): number[] {\n const result: number[] = [];\n for (const body of bodies) {\n const scope = this.plan.bodyScopes.get(body)!;\n for (const item of this.model.scopes) {\n if (isWithin(item, scope)) {\n result.push(item.id);\n }\n }\n }\n return result;\n }\n\n private renderName(body: Body): string {\n return `r${this.plan.bodyScopes.get(body)!.id}`;\n }\n\n private emitBlockUpdate(block: Block, fn: string, base: Scope): void {\n const anchor = this.plan.anchors.get(block);\n if (anchor === undefined) {\n return;\n }\n const headers = this.headerSites(block);\n const header = (index: number): string => this.rewriter.rewrite(headers[index]!, '$$s', base);\n switch (block.kind) {\n case 'if':\n case 'switch': {\n const branches = block.kind === 'if' ? block.branches : block.cases;\n const bodies = branches.map((branch) => branch.body);\n let index = block.fallback ? String(branches.length) : '-1';\n for (let i = branches.length - 1; i >= 0; i--) {\n index = `(${header(i)}) ? ${i} : ${index}`;\n }\n const renders = [...bodies, ...(block.fallback ? [block.fallback] : [])].map((body) =>\n this.renderName(body),\n );\n this.emit(\n `export function ${fn}($$s) {\\n $$b.branch($$s, ${anchor}, ${index}, [${renders.join(', ')}], [${this.kinds(blockBodies(block)).join(', ')}]);\\n}`,\n );\n return;\n }\n case 'for':\n case 'repeat': {\n const items =\n block.kind === 'for'\n ? `$$b.listOf(${header(0)})`\n : `Array.from({ length: ${header(0)} }, (_, index) => index)`;\n const key = this.keyFunction(block, base);\n const fallback = block.fallback ? this.renderName(block.fallback) : 'undefined';\n const fallbackKinds = block.fallback ? this.kinds([block.fallback]) : [];\n this.emit(\n [\n `export function ${fn}($$s) {`,\n ` $$b.list($$s, ${anchor}, ${items}, ${key}, ${this.renderName(block.body)}, a${this.plan.bodyScopes.get(block.body)!.id}, ${fallback}, [${fallbackKinds.join(', ')}]);`,\n '}',\n ].join('\\n'),\n );\n this.emitAssign(block);\n return;\n }\n case 'portal': {\n if (!block.target) {\n return;\n }\n // A new target moves the body: the old one is removed and the body renders into the new one.\n const body = this.plan.bodyScopes.get(block.body)!;\n this.emit(\n `export function ${fn}($$s) {\\n $$b.portalTo($$s, ${header(0)}, r${body.id}, [${body.id}]);\\n}`,\n );\n return;\n }\n case 'offscreen':\n this.emit(\n `export function ${fn}($$s) {\\n $$b.offscreen($$s, ${anchor}, ${header(0)}, ${this.renderName(block.body)}, ${this.plan.bodyScopes.get(block.body)!.id});\\n}`,\n );\n return;\n case 'key':\n this.emit(\n `export function ${fn}($$s) {\\n $$b.rekey($$s, ${anchor}, ${header(0)}, ${this.renderName(block.body)}, [${this.kinds([block.body]).join(', ')}]);\\n}`,\n );\n return;\n default:\n return;\n }\n }\n\n private itemDeclarations(block: ForBlock | RepeatBlock): Declaration[] {\n return this.model.declarations.filter(\n (declaration) =>\n declaration.block === block &&\n (declaration.kind === 'item' || declaration.kind === 'index'),\n );\n }\n\n private keyFunction(block: ForBlock | RepeatBlock, base: Scope): string {\n if (block.kind === 'repeat' || block.key === 'index') {\n return '($$item, $$index) => $$index';\n }\n if (!block.key) {\n return '($$item) => $$item';\n }\n const site = this.model.sites.find((item) => item.label === 'for key' && item.block === block)!;\n const locals = new Set(this.itemDeclarations(block));\n const key = this.rewriter.rewrite(site, '$$s', base, { locals });\n const pattern = copy(this.file.source, block.item.start, block.item.end);\n const index = block.index ? ` const ${block.index.name} = $$index;` : '';\n return `($$item, $$index) => { const ${pattern} = $$item;${index} return ${key}; }`;\n }\n\n /** Emits the function that writes a new item and index into an item's scope. */\n private emitAssign(block: ForBlock | RepeatBlock): void {\n const scope = this.plan.bodyScopes.get(block.body)!;\n const lines = [`export function a${scope.id}($$s, $$item, $$index) {`, ' $$s.i = $$item;'];\n if (block.kind === 'for') {\n lines.push(` const ${copy(this.file.source, block.item.start, block.item.end)} = $$item;`);\n }\n for (const declaration of this.itemDeclarations(block)) {\n const slot = slotIndex(this.plan, declaration);\n if (slot !== -1) {\n const value = declaration.kind === 'index' ? '$$index' : declaration.name;\n lines.push(` $$b.set($$s, ${slot}, ${value});`);\n }\n }\n lines.push('}');\n this.emit(lines.join('\\n'));\n }\n\n // Render functions\n\n private collectRenders(): void {\n for (const node of this.plan.graph.nodes) {\n if (\n node.kind !== 'block' ||\n !this.plan.graph.live.has(node) ||\n node.site.label === 'for key'\n ) {\n continue;\n }\n if (!['if', 'switch', 'for', 'repeat', 'key', 'offscreen'].includes(node.block.kind)) {\n continue;\n }\n for (const body of blockBodies(node.block)) {\n this.renders.set(this.plan.bodyScopes.get(body)!, { body, block: node.block });\n }\n }\n for (const scope of this.model.scopes) {\n const block = scope.block;\n const clientOnly =\n (block?.kind === 'client' && scope.body === block.body) ||\n (block?.kind === 'portal' && block.target !== undefined) ||\n (block?.kind === 'try' && this.plan.anchors.has(block));\n if (scope.kind === 'body' && block && clientOnly && scope.body) {\n this.renders.set(scope, { body: scope.body, block });\n }\n }\n }\n\n private emitRenders(): void {\n for (const [scope, { body, block }] of this.renders) {\n const base = scope.parent!;\n const inside = this.inside(scope);\n const emitter = new Emitter(this.file, this.plan, this.valuePatch, {\n mode: 'client',\n outer: { inside, base, baseVar: '$$p' },\n });\n const isItem = (block.kind === 'for' || block.kind === 'repeat') && block.body === body;\n const isCatch = block.kind === 'try' && block.fallback === body;\n let params = '';\n if (isItem) {\n params = ', $$item, $$index';\n } else if (isCatch) {\n params = ', $$error';\n }\n emitter.line(`export function r${scope.id}($$p${params}) {`);\n emitter.line(`let $$html = '';`);\n if (block.kind === 'try' && isCatch) {\n if (block.error) {\n emitter.line(`const ${block.error.name} = $$error;`);\n }\n if (block.reset) {\n emitter.line(`const ${block.reset.name} = undefined;`);\n }\n }\n for (const line of this.prologue(inside, base)) {\n emitter.line(line);\n }\n for (const template of inside.slice(1)) {\n emitter.emitTemplate(template.template!);\n }\n if (isItem) {\n emitter.emitItem(block, '$$item', '$$index');\n } else {\n emitter.emitBody(body);\n }\n emitter.flush();\n emitter.line('return $$html;');\n emitter.close();\n this.emit(emitter.lines.join('\\n'));\n if (block.kind === 'portal' && block.target) {\n const header = this.model.sites.find(\n (site) => site.kind === 'block' && site.block === block,\n )!;\n const target = this.rewriter.rewrite(header, '$$s', instanceScope(this.plan, base));\n this.emit(\n `export function k${scope.id}($$s) {\\n $$b.portalTo($$s, ${target}, r${scope.id});\\n}`,\n );\n }\n if (block.kind === 'client') {\n const anchor = this.plan.anchors.get(block)!;\n // The fallback's scopes go when the body renders in its place.\n const fallback = block.fallback ? `, [${this.kinds([block.fallback]).join(', ')}]` : '';\n this.emit(\n `export function k${scope.id}($$s) {\\n $$b.fill($$s, ${anchor}, r${scope.id}${fallback});\\n}`,\n );\n }\n }\n }\n\n /**\n * Code that calls `#template`s, such as an insert of `{price(total)}` that\n * updates. The render module defines templates inside the component's\n * render function, so an update defines the ones that it calls itself.\n */\n private withTemplates(site: Site, code: string): string {\n const templates: Scope[] = [];\n // The templates that the code calls, and those that it passes on, such as a prop `item=option`.\n const used = [\n ...site.calls,\n ...site.reads.map((read) => read.declaration).filter((item) => item.kind === 'template'),\n ];\n for (const callee of used) {\n if (callee.kind !== 'template') {\n continue;\n }\n const template = this.model.scopes.find(\n (item) => item.template?.name === callee.name && item.parent === callee.scope,\n );\n for (const item of template ? this.inside(template) : []) {\n if (!templates.includes(item)) {\n templates.push(item);\n }\n }\n }\n if (templates.length === 0) {\n return code;\n }\n const base = templates[0]!.parent!;\n const emitter = new Emitter(this.file, this.plan, this.valuePatch, {\n mode: 'client',\n outer: { inside: templates, base, baseVar: '$$p' },\n });\n for (const line of this.prologue(templates, base)) {\n emitter.line(line);\n }\n for (const template of templates) {\n emitter.emitTemplate(template.template!);\n }\n emitter.flush();\n const parent = scopePath(this.plan, '$$s', site.scope, base);\n return `(($$p) => {\\n${emitter.lines.join('\\n')}\\nreturn ${code};\\n})(${parent})`;\n }\n\n /** Declares the outer values that a render function reads, as local variables. */\n private prologue(inside: Scope[], base: Scope): string[] {\n const isInside = (scope: Scope): boolean => inside.some((item) => isWithin(scope, item));\n const declarations = new Set<Declaration>();\n for (const site of this.model.sites) {\n // Top-level elements of a body render the style variables of the component.\n const rendered = isInside(site.scope) || site.kind === 'style';\n if (!rendered || DEFERRED_SITES.has(site.kind)) {\n continue;\n }\n for (const read of site.reads) {\n if (!isInside(read.declaration.scope)) {\n declarations.add(read.declaration);\n }\n }\n }\n const lines: string[] = [];\n for (const declaration of declarations) {\n if (\n declaration.kind === 'import' ||\n declaration.kind === 'module' ||\n declaration.kind === 'template'\n ) {\n continue;\n }\n const value = this.rewriter.value(declaration, '$$p', base);\n if (value) {\n // `let`, because inline function props in the markup can assign to it. They never run here.\n lines.push(`let ${declaration.name} = ${value};`);\n }\n }\n return lines;\n }\n\n // Dependency table\n\n /**\n * The memos to load again when a server function calls `refresh(fn)`:\n * by the ID of `fn`, the scope kind and the update of each memo.\n */\n /**\n * The `#try` blocks that catch errors of client code, by the scope kinds\n * inside their bodies: the kind of the scope that holds the block, the\n * anchor of the block, the render functions of the body and the `#catch`\n * body, and the kinds of both bodies.\n */\n private triesTable(): string | undefined {\n const entries: string[] = [];\n for (const scope of this.model.scopes) {\n const block = scope.block;\n if (\n block?.kind !== 'try' ||\n scope.body !== block.body ||\n !this.plan.anchors.has(block) ||\n !tryCatchesClient(this.model, block)\n ) {\n continue;\n }\n const owner = instanceScope(this.plan, scope.parent!);\n const fallback = this.plan.bodyScopes.get(block.fallback)!;\n const entry = `[${owner.id}, ${this.plan.anchors.get(block)}, ${JSON.stringify(`r${scope.id}`)}, ${JSON.stringify(`r${fallback.id}`)}, [${this.kinds(blockBodies(block)).join(', ')}]]`;\n for (const inside of this.model.scopes) {\n if (isWithin(inside, scope)) {\n entries.push(`${inside.id}: ${entry}`);\n }\n }\n }\n return entries.length > 0 ? `{ ${entries.join(', ')} }` : undefined;\n }\n\n private refreshTable(): string | undefined {\n const table = new Map<string, [number, string][]>();\n for (const node of this.plan.graph.nodes) {\n if (node.kind !== 'memo') {\n continue;\n }\n const fn = this.updates.get(node);\n if (!fn) {\n continue;\n }\n for (const callee of node.site.calls) {\n if (callee.serverImport || (callee.kind === 'server-function' && callee.refreshed)) {\n const id = callee.serverImport ?? serverFunctionId(this.plan, callee.name);\n const entries = table.get(id) ?? [];\n entries.push([instanceScope(this.plan, node.declaration.scope).id, fn]);\n table.set(id, entries);\n }\n }\n }\n if (table.size === 0) {\n return undefined;\n }\n const items = [...table].map(\n ([id, entries]) =>\n `${JSON.stringify(id)}: [${entries.map(([kind, fn]) => `[${kind}, ${JSON.stringify(fn)}]`).join(', ')}]`,\n );\n return `{ ${items.join(', ')} }`;\n }\n\n private table(): string {\n const table = new Map<number, Map<number, [number, string, boolean][]>>();\n for (const edge of this.plan.graph.edges) {\n const from = edge.from;\n if (from.kind !== 'source' && from.kind !== 'memo') {\n continue;\n }\n const fn = this.updates.get(edge.to);\n if (!fn || edge.to.kind === 'source') {\n continue;\n }\n const slot = slotIndex(this.plan, from.declaration);\n if (slot === -1) {\n continue;\n }\n const kind = instanceScope(this.plan, edge.to.site.scope).id;\n const scope = from.declaration.scope.id;\n const slots = table.get(scope) ?? new Map<number, [number, string, boolean][]>();\n table.set(scope, slots);\n const entries = slots.get(slot) ?? [];\n slots.set(slot, entries);\n if (!entries.some(([, name]) => name === fn)) {\n entries.push([kind, fn, edge.to.kind === 'memo']);\n }\n }\n const scopes: string[] = [];\n for (const [scope, slots] of table) {\n const items: string[] = [];\n for (const [slot, entries] of slots) {\n // Memos update first, so bindings read their new values.\n const sorted = entries.toSorted((a, b) => Number(b[2]) - Number(a[2]));\n items.push(\n `${slot}: [${sorted.map(([kind, name]) => `[${kind}, ${JSON.stringify(name)}]`).join(', ')}]`,\n );\n }\n scopes.push(`${scope}: { ${items.join(', ')} }`);\n }\n return `{ ${scopes.join(', ')} }`;\n }\n}\n","import { checkAccessibility } from './a11y.ts';\nimport { ANY } from './refreshes.ts';\nimport { checkCaptures } from './captures.ts';\nimport { checkEnv } from './env-check.ts';\nimport type { EnvImport } from './env-check.ts';\nimport { finish } from './sourcemap.ts';\nimport { ModuleError, expandModules, relocate, resolveFromDisk } from './modules.ts';\nimport type { ModuleCall, Origin, ReactiveModule, ResolveModule } from './modules.ts';\nimport { SHARED_QUERY, sharedSites } from './shared-module.ts';\nimport type { SharedContext } from './shared-module.ts';\nimport type { SourceMap } from './sourcemap.ts';\nimport { analyze } from './analyze.ts';\nimport { generateClient } from './codegen/client.ts';\nimport { generateRender } from './codegen/render.ts';\nimport { generateServer } from './codegen/server.ts';\nimport { BrumateError, codeFrame, getLocation } from './error.ts';\nimport type { Location } from './error.ts';\nimport { buildGraph } from './graph.ts';\nimport type { Diagnostic } from './model.ts';\nimport { parse } from './parser.ts';\nimport { createPlan } from './plan.ts';\nimport type { Plan } from './plan.ts';\nimport type { SFCFile } from './ast.ts';\n\nexport interface CompileOptions {\n /** Used for error messages, the component name and the component ID. */\n filename?: string;\n /**\n * The props that a parent can change on the client, from `analyzeProject`.\n * `*` means every prop. Without it, every prop can change.\n */\n liveProps?: Set<string>;\n /** The absolute path of the file, so SCSS and Less can import files next to it. */\n path?: string;\n /**\n * When the client parts of a component are smaller than this many bytes\n * in all, they become one module. Defaults to 0, which keeps one module\n * per part.\n */\n merge?: number;\n /** Warns about common accessibility mistakes in the markup. Defaults to true. */\n a11y?: boolean;\n /**\n * The ID of a function that the file imports from a `'use server'` file,\n * or undefined for other imports. Memos that call one load again when a\n * server function calls `refresh` with it. The Vite plugin passes it.\n */\n serverImport?: (specifier: string, name: string) => string | undefined;\n /**\n * The names of the server functions that the project passes to\n * `refresh`, from `refreshedNames`. A memo that calls an imported server\n * function outside it renders on the server only. Without it, any imported\n * server function can be refreshed.\n */\n refreshed?: ReadonlySet<string>;\n /**\n * The names of the server environment variables that an import gives,\n * such as `import env from './env.ts'`, or undefined for other imports.\n * Code that runs in the browser cannot read them. The Vite plugin passes\n * it for the imports that resolve to the env file.\n */\n envImport?: EnvImport;\n /**\n * Classes that the plugins of the serial entry send, such as `Money`, so a\n * signal can hold an instance. The Vite plugin reads them from the entry.\n */\n sendableClasses?: readonly string[];\n /**\n * Server function IDs use a hash of each function's name instead of the\n * name, so the browser does not see it. The Vite plugin sets it in builds.\n */\n hideNames?: boolean;\n /**\n * Reads a module of reactive logic, such as `./counter.brm.ts`, that the\n * component imports. Defaults to reading it from disk next to `path`.\n */\n resolveModule?: ResolveModule;\n}\n\nexport interface CompileResult {\n /** The server module, as TypeScript. Its default export renders the component. */\n server: string;\n /** The client entry module, as TypeScript. The loader imports it on the first event. */\n client: string;\n /**\n * The parts of the client module, by name. The entry imports them when\n * they are needed. A small component has none: its entry holds the code.\n */\n parts: Record<string, string>;\n /** The parts that the entry loads for each part name, its own first. See `ClientOutput`. */\n loaders: Record<string, string[]>;\n /** The ID, the props map and the update tables of the client entry, without code. */\n table: string;\n /** False when nothing of the component runs in the browser, so it needs no client module. */\n clientCode: boolean;\n /**\n * The render module, as TypeScript. It renders the component on the\n * client, inside a parent's block that changes.\n */\n render: string;\n /** The scoped CSS of the component. Server and render modules add it to the page. */\n css: string;\n /** The parsed file. */\n file: SFCFile;\n plan: Plan;\n warnings: Diagnostic[];\n /** The paths of the modules of reactive logic that the component calls into. */\n modules: string[];\n /**\n * Where an offset of `file.source` comes from: the component, or a module\n * whose function the component calls. `file.source` holds the bodies of\n * those functions in place of their calls.\n */\n locate: (offset: number) => { file: string | undefined; offset: number };\n /** Source maps from each module back to the `.brm` file. */\n maps: {\n server: SourceMap;\n client: SourceMap;\n parts: Record<string, SourceMap>;\n render: SourceMap;\n };\n}\n\n/** Thrown when a file has errors. Every error is in `diagnostics`. */\nexport class CompileError extends Error {\n readonly diagnostics: Diagnostic[];\n readonly filename: string;\n /** Where the first error is. */\n readonly location: Location;\n /** The lines around the first error. */\n readonly frame: string;\n\n constructor(source: string, filename: string, diagnostics: Diagnostic[]) {\n const lines = diagnostics.map((diagnostic) => {\n const { line, column } = getLocation(source, diagnostic.range.start);\n return `${diagnostic.message} (${filename}:${line}:${column})`;\n });\n super(lines.join('\\n'));\n this.name = 'CompileError';\n this.diagnostics = diagnostics;\n this.filename = filename;\n const start = diagnostics[0]?.range.start ?? 0;\n this.location = getLocation(source, start);\n this.frame = codeFrame(source, start);\n }\n}\n\n/** The origin of an offset of a component that calls no module function. */\nconst identity = (offset: number): Origin => ({ offset });\n\n/** How deep module functions can call module functions, so a function that calls itself stops. */\nconst MAX_EXPANSIONS = 16;\n\n/**\n * Parses a component, and copies the bodies of the module functions that it\n * calls in place of the calls. Returns the parsed file, which holds the\n * expanded source, and where each offset of that source comes from.\n */\nfunction expand(\n source: string,\n filename: string,\n path: string,\n resolve: ResolveModule,\n): {\n file: SFCFile;\n origin: (offset: number) => Origin;\n modules: ReactiveModule[];\n calls: ModuleCall[];\n} {\n let file = parse(source, { filename });\n let origin = identity;\n const modules = new Map<string, ReactiveModule>();\n // The calls that the component itself makes. Their offsets are offsets of `source`.\n let calls: ModuleCall[] = [];\n for (let round = 0; ; round++) {\n let expansion;\n try {\n expansion = expandModules(file, path, resolve);\n } catch (error) {\n if (error instanceof ModuleError) {\n const at = origin(error.offset);\n throw new CompileError(source, filename, [\n {\n severity: 'error',\n message: error.message,\n range: at.call ?? { start: at.offset, end: at.offset + 1 },\n },\n ]);\n }\n throw error;\n }\n if (!expansion) {\n return { file, origin, modules: [...modules.values()], calls };\n }\n if (round === 0) {\n calls = expansion.calls;\n }\n if (round === MAX_EXPANSIONS) {\n throw new CompileError(source, filename, [\n {\n severity: 'error',\n message:\n 'Module functions call each other too deeply. A module function cannot call itself',\n range: { start: 0, end: 1 },\n },\n ]);\n }\n for (const module of expansion.modules) {\n modules.set(module.path, module);\n }\n // An offset of the new source maps through this round, then through the earlier ones.\n const outer = origin;\n const inner = expansion.origin;\n origin = (offset) => {\n const found = inner(offset);\n if (!found.module) {\n return outer(found.offset);\n }\n const call = found.call && outer(found.call.start);\n return {\n ...found,\n call: call?.call ?? (call && { start: call.offset, end: outer(found.call!.end).offset }),\n // Code of a module function that a module function calls, rather than the component.\n nested: round > 0,\n };\n };\n try {\n file = parse(expansion.source, { filename });\n } catch (error) {\n if (error instanceof BrumateError) {\n const at = origin(error.offset);\n const where = at.module ? ` (${locationIn(at.module, at.offset)})` : '';\n throw new BrumateError(\n `${error.message.replace(/ \\([^()]*:\\d+:\\d+\\)$/, '')}${where}`,\n source,\n at.call?.start ?? at.offset,\n filename,\n );\n }\n throw error;\n }\n }\n}\n\n/** `file:line:column` of an offset of a module, with the file name only. */\nfunction locationIn(module: ReactiveModule, offset: number): string {\n const { line, column } = getLocation(module.source, offset);\n return `${module.path.split(/[\\\\/]/).pop()}:${line}:${column}`;\n}\n\n/** True for a function node, whose shared code is called with its arguments. */\nfunction isFunction(node: { type: string }): boolean {\n return (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n );\n}\n\n/**\n * Lets code generation call the shared module of a module function for the\n * code that a call of it gave the component, instead of copying the code.\n */\nfunction sharedContext(\n origin: (offset: number) => Origin,\n modules: ReactiveModule[],\n calls: ModuleCall[],\n path: string,\n): SharedContext | undefined {\n if (calls.length === 0) {\n return undefined;\n }\n const byStart = new Map(calls.map((call) => [call.start, call]));\n return {\n specifiers: modules.map(\n (module) =>\n `${relocate(`./${module.path.split('/').pop()}`, module.path, path)}${SHARED_QUERY}`,\n ),\n find(node) {\n const at = origin(node.start);\n if (!at.module || at.nested || !at.call) {\n return undefined;\n }\n const call = byStart.get(at.call.start);\n const site = sharedSites(at.module).get(at.offset);\n if (!call || call.module !== at.module.path || !site) {\n return undefined;\n }\n if ((site.kind === 'function') !== isFunction(node)) {\n return undefined;\n }\n return {\n module: modules.findIndex((module) => module.path === at.module!.path),\n site,\n names: call.names,\n };\n },\n };\n}\n\nexport function compile(source: string, options: CompileOptions = {}): CompileResult {\n const filename = options.filename ?? 'Component.brm';\n const { file, origin, modules, calls } = expand(\n source,\n filename,\n options.path ?? filename,\n options.resolveModule ?? resolveFromDisk,\n );\n // A diagnostic about code of a module points at its call, and names its place in the module.\n const translate = (diagnostic: Diagnostic): Diagnostic => {\n const start = origin(diagnostic.range.start);\n if (!start.module) {\n const end = origin(diagnostic.range.end);\n return {\n ...diagnostic,\n range: { start: start.offset, end: end.module ? start.offset + 1 : end.offset },\n };\n }\n return {\n ...diagnostic,\n message: `${diagnostic.message} (in ${locationIn(start.module, start.offset)})`,\n range: start.call ?? { start: 0, end: 1 },\n };\n };\n const fail = (errors: Diagnostic[]): never => {\n throw new CompileError(source, filename, errors.map(translate));\n };\n const model = analyze(file);\n for (const declaration of model.declarations) {\n if (declaration.imported && options.serverImport) {\n declaration.serverImport = options.serverImport(\n declaration.imported.source,\n declaration.imported.name,\n );\n if (declaration.serverImport !== undefined) {\n // A server function that the project refreshes, or any when the project is not known:\n // the memos that call it load again on the client.\n const name = declaration.imported.name;\n declaration.refreshed =\n !options.refreshed || options.refreshed.has(ANY) || options.refreshed.has(name);\n for (const read of declaration.reads) {\n read.site.calls.add(declaration);\n }\n }\n }\n }\n const graph = buildGraph(model, { liveProps: options.liveProps });\n const diagnostics = [\n ...model.diagnostics,\n ...graph.diagnostics,\n ...(options.a11y === false ? [] : checkAccessibility(file)),\n ];\n const errors = diagnostics.filter((diagnostic) => diagnostic.severity === 'error');\n if (errors.length > 0) {\n fail(errors);\n }\n const plan = createPlan(file, graph, options.path, options.hideNames);\n const styleErrors = [...plan.styles.diagnostics, ...plan.diagnostics].filter(\n (diagnostic) => diagnostic.severity === 'error',\n );\n if (styleErrors.length > 0) {\n fail(styleErrors);\n }\n const captures = [\n ...checkCaptures(file, plan, options.sendableClasses),\n ...(options.envImport ? checkEnv(file, plan, options.envImport) : []),\n ];\n if (captures.length > 0) {\n fail(captures);\n }\n const shared = sharedContext(origin, modules, calls, options.path ?? filename);\n const client = generateClient(file, plan, options.merge, shared);\n const clientErrors = client.diagnostics.filter((diagnostic) => diagnostic.severity === 'error');\n if (clientErrors.length > 0) {\n fail(clientErrors);\n }\n // The generated code marks what it copied from the file. `finish` turns the marks into\n // source maps, which point code that a module function gave back to the module.\n const files = [\n { name: filename, content: source },\n ...modules.map((module) => ({ name: module.path, content: module.source })),\n ];\n const place = (offset: number): { index: number; offset: number } => {\n const at = origin(offset);\n return {\n index: at.module ? modules.findIndex((module) => module.path === at.module!.path) + 1 : 0,\n offset: at.offset,\n };\n };\n const done = (code: string) => finish(code, files, place);\n const server = done(generateServer(file, plan));\n const entry = done(client.code);\n const parts = Object.fromEntries(\n Object.entries(client.parts).map(([name, code]) => [name, done(code)]),\n );\n const render = done(generateRender(file, plan));\n return {\n server: server.code,\n client: entry.code,\n parts: Object.fromEntries(Object.entries(parts).map(([name, part]) => [name, part.code])),\n loaders: client.loaders,\n table: client.table,\n clientCode: client.clientCode,\n render: render.code,\n maps: {\n server: server.map,\n client: entry.map,\n parts: Object.fromEntries(Object.entries(parts).map(([name, part]) => [name, part.map])),\n render: render.map,\n },\n css: plan.styles.css,\n file,\n plan,\n warnings: diagnostics.filter((diagnostic) => diagnostic.severity === 'warning').map(translate),\n modules: modules.map((module) => module.path),\n locate: (offset) => {\n const at = origin(offset);\n return at.module\n ? { file: at.module.path, offset: at.offset }\n : { file: undefined, offset: at.offset };\n },\n };\n}\n","import { builtin } from './node.ts';\nimport type { Markup } from './ast.ts';\nimport { compile } from './compile.ts';\nimport type { CompileOptions, CompileResult } from './compile.ts';\nimport { getLocation } from './error.ts';\nimport type { GraphNode } from './graph.ts';\nimport type { AnchorTarget } from './plan.ts';\nimport type { Declaration, Scope, Site } from './model.ts';\nimport { forEachNode } from './project.ts';\n\nexport interface InspectEntry {\n /** What it is, such as `signal count` or `event button.click`. */\n label: string;\n /** `line:column` in the source. */\n at: string;\n /** Why it ships or changes. */\n reason: string;\n}\n\nexport interface InspectReport {\n filename: string;\n name: string;\n id: string;\n /** Code that runs in the browser when an event or trigger happens. */\n roots: InspectEntry[];\n /** Values and markup that can change on the client. */\n changes: InspectEntry[];\n /** Serialized values, by scope. */\n state: { scope: string; slots: string[] }[];\n /** Markup that ships as HTML only. */\n staticMarkup: { elements: number; inserts: number };\n /** The size of each client module, in bytes. */\n sizes: { module: string; bytes: number; gzip: number }[];\n}\n\nfunction at(source: string, range: { start: number }): string {\n const { line, column } = getLocation(source, range.start);\n return `${line}:${column}`;\n}\n\nfunction siteLabel(source: string, site: Site): string {\n return `${site.label} (${at(source, site.range)})`;\n}\n\n/** A short name for a scope, such as `body of #for (12:3)`. */\n/** A short name of an anchor for the devtools: its tag, its block, or `$client`. */\nexport function anchorLabel(target: AnchorTarget): string {\n if ('range' in target) {\n return target.kind === 'client' ? '$client' : target.label;\n }\n switch (target.kind) {\n case 'element':\n return `<${target.tag}>`;\n case 'component':\n return `<${target.name}>`;\n case 'dynamic':\n return '<dynamic tag>';\n case 'listener':\n return `#${target.target} listener`;\n case 'insert':\n return 'insert';\n default:\n return `#${target.kind}`;\n }\n}\n\nexport function scopeLabel(source: string, scope: Scope): string {\n if (scope.kind === 'body' && scope.block) {\n return `body of #${scope.block.kind} (${at(source, scope.block)})`;\n }\n if (scope.kind === 'template' && scope.template) {\n return `#template ${scope.template.name}`;\n }\n return scope.kind;\n}\n\nfunction list(items: string[]): string {\n return items.length > 2\n ? `${items.slice(0, -1).join(', ')} and ${items.at(-1)}`\n : items.join(' and ');\n}\n\nfunction nodeLabel(node: GraphNode): string {\n return node.kind === 'source' || node.kind === 'memo'\n ? `${node.declaration.kind} ${node.declaration.name}`\n : node.site.label;\n}\n\n/** Describes what a compiled component ships to the client, and why. */\nexport function report(\n source: string,\n result: CompileResult,\n liveProps?: Set<string>,\n parents?: Map<string, Set<string>>,\n): InspectReport {\n const { plan } = result;\n const { graph } = plan;\n\n const roots: InspectEntry[] = [];\n for (const [site, symbol] of plan.symbols) {\n const reached = new Set<string>();\n const visit = (current: Site): void => {\n for (const callee of current.calls) {\n if (callee.kind === 'server-function') {\n reached.add(`${callee.name} (server)`);\n } else if (callee.kind === 'function' && callee.site && !reached.has(callee.name)) {\n reached.add(callee.name);\n visit(callee.site);\n }\n }\n };\n visit(site);\n let kind = 'runs on the event';\n if (site.kind === 'client') {\n kind = `runs when the browser is ${site.trigger === 'load' ? 'loaded' : site.trigger}`;\n } else if (site.kind === 'prop') {\n kind = 'a function passed to a component';\n }\n roots.push({\n label: `${symbol}: ${site.label}`,\n at: at(source, site.range),\n reason: reached.size > 0 ? `${kind}, calls ${list([...reached])}` : kind,\n });\n }\n\n const changes: InspectEntry[] = [];\n for (const node of graph.nodes) {\n if (!graph.live.has(node)) {\n continue;\n }\n let reason: string;\n if (node.kind === 'source') {\n const declaration = node.declaration;\n reason = sourceReason(source, declaration, graph.reached, liveProps, parents);\n changes.push({ label: nodeLabel(node), at: at(source, declaration.range), reason });\n continue;\n }\n const from = graph.edges\n .filter((edge) => edge.to === node && graph.live.has(edge.from))\n .map((edge) => nodeLabel(edge.from));\n reason = from.length > 0 ? `reads ${list(from)}` : 'changes on the client';\n changes.push({ label: nodeLabel(node), at: at(source, node.site.range), reason });\n }\n\n const state: InspectReport['state'] = [];\n for (const [scope, layout] of plan.scopes) {\n if (layout.slots.length > 0) {\n state.push({\n scope: scopeLabel(source, scope),\n slots: layout.slots.map((slot) => slot.name),\n });\n }\n }\n\n let elements = 0;\n let inserts = 0;\n const count = (node: Markup): void => {\n // An element with handlers ships client code, even when it finds its scope from an element around it.\n if (\n node.kind === 'element' &&\n !plan.anchors.has(node) &&\n !node.attributes.some((attribute) => attribute.kind === 'event')\n ) {\n elements++;\n } else if (node.kind === 'insert' && !plan.anchors.has(node)) {\n inserts++;\n }\n };\n forEachNode(result.file.children, count);\n for (const template of result.file.templates) {\n forEachNode(template.body.children, count);\n }\n\n const sizes: InspectReport['sizes'] = [];\n const add = (module: string, code: string): void => {\n // Outside Node, such as in a browser, the gzip size is not measured.\n const zlib = builtin('node:zlib');\n sizes.push({\n module,\n bytes: new TextEncoder().encode(code).length,\n gzip: zlib ? zlib.gzipSync(code).length : 0,\n });\n };\n add('entry', result.client);\n for (const [name, code] of Object.entries(result.parts)) {\n if (/export /.test(code)) {\n add(name, code);\n }\n }\n\n return {\n filename: result.file.filename,\n name: plan.name,\n id: plan.id,\n roots,\n changes,\n state,\n staticMarkup: { elements, inserts },\n sizes,\n };\n}\n\nfunction sourceReason(\n source: string,\n declaration: Declaration,\n reached: Set<Site>,\n liveProps: Set<string> | undefined,\n parents: Map<string, Set<string>> | undefined,\n): string {\n switch (declaration.kind) {\n case 'signal': {\n const writers = declaration.writes\n .filter((write) => reached.has(write.site))\n .map((write) => siteLabel(source, write.site));\n const unique = [...new Set(writers)];\n if (unique.length > 0) {\n return `written by ${list(unique)}`;\n }\n return 'its element is created on the client';\n }\n case 'prop':\n case 'props-rest': {\n if (!liveProps) {\n return 'compiled alone, so every prop can change';\n }\n const keys = declaration.propKey ? [declaration.propKey, '*'] : [...(parents?.keys() ?? [])];\n const files = new Set<string>();\n for (const key of keys) {\n for (const file of parents?.get(key) ?? []) {\n files.add(file);\n }\n }\n if (files.size === 0) {\n return 'a parent passes a value that changes';\n }\n return `${list([...files])} ${files.size === 1 ? 'passes' : 'pass'} a value that changes`;\n }\n case 'item':\n case 'index':\n return 'its list changes';\n case 'error':\n return 'its #try body changes';\n case 'template-param':\n return 'a call to its template changes';\n default:\n return 'changes on the client';\n }\n}\n\nfunction plural(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? '' : 's'}`;\n}\n\n/** Formats a report as text. */\nexport function formatReport(value: InspectReport): string {\n const lines = [`${value.name} (${value.filename}) ${value.id}`, ''];\n const section = (title: string, entries: InspectEntry[]): void => {\n lines.push(title);\n if (entries.length === 0) {\n lines.push(' none');\n }\n for (const entry of entries) {\n lines.push(` ${entry.label} (${entry.at})`, ` ${entry.reason}`);\n }\n lines.push('');\n };\n section('Client code', value.roots);\n section('Changes on the client', value.changes);\n lines.push('State');\n if (value.state.length === 0) {\n lines.push(' none');\n }\n for (const item of value.state) {\n lines.push(` ${item.scope}: ${item.slots.join(', ')}`);\n }\n lines.push('');\n lines.push(\n 'HTML only',\n ` ${plural(value.staticMarkup.elements, 'element')} and ${plural(value.staticMarkup.inserts, 'inserted value')} ship no client code`,\n '',\n );\n lines.push('Client modules, before minifying (bytes, gzip)');\n for (const size of value.sizes) {\n lines.push(` ${size.module}: ${size.bytes} B, ${size.gzip} B`);\n }\n return lines.join('\\n');\n}\n\nexport interface InspectOptions extends CompileOptions {\n /** For each prop that can change, the files that change it, from `analyzeProjectProps`. */\n parents?: Map<string, Set<string>>;\n}\n\n/** Compiles a file and describes what it ships to the client, and why. */\nexport function inspect(\n source: string,\n options: InspectOptions = {},\n): { report: InspectReport; text: string } {\n const result = compile(source, options);\n const value = report(source, result, options.liveProps, options.parents);\n return { report: value, text: formatReport(value) };\n}\n"],"mappings":";;;;;;;AASA,MAAa,iBAAiB;;AAG9B,MAAa,yBAAsB,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,iCAA8C,IAAI,IAAI,CACjE,CAAC,YAAY,aAAa,GAC1B,CAAC,YAAY,aAAa,CAC5B,CAAC;;AAGD,SAAgB,cAAc,WAA8B;CAC1D,OAAO,UAAU,SAAS,uBAAuB,UAAU,OAAO,UAAA;AACpE;;AAGA,SAAS,KAAK,OAAgB,OAAiC,uBAAO,IAAI,IAAY,GAAS;CAC7F,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,KAAK,IAAI,KAAK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