brumate 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/check.d.ts +3 -3
- package/dist/{boot-DkbcqdUz.d.ts → boot-CMy0f_iC.d.ts} +2 -2
- package/dist/cli.js +77 -6
- package/dist/cli.js.map +1 -1
- package/dist/{client-C3vRNuLi.js → client-Bm0XbjHr.js} +274 -113
- package/dist/client-Bm0XbjHr.js.map +1 -0
- package/dist/{client-CqGDbWd_.d.ts → client-DnFF9_lv.d.ts} +40 -14
- package/dist/{client-routes-BtGpYCef.js → client-routes-BmPvNr4s.js} +10 -1
- package/dist/client-routes-BmPvNr4s.js.map +1 -0
- package/dist/{context-btHuB01Z.d.ts → context-BNgBXVUQ.d.ts} +7 -5
- package/dist/{context-CTiSzQRc.js → context-CU4Fpn5a.js} +10 -13
- package/dist/context-CU4Fpn5a.js.map +1 -0
- package/dist/{defer-M18UKyfG.js → defer-BWwxv7Qf.js} +2 -2
- package/dist/{defer-M18UKyfG.js.map → defer-BWwxv7Qf.js.map} +1 -1
- package/dist/{devtools-D9Q7a41M.js → devtools-Cl6AhENB.js} +4 -4
- package/dist/{devtools-D9Q7a41M.js.map → devtools-Cl6AhENB.js.map} +1 -1
- package/dist/{devtools-panel-DTQtljeA.js → devtools-panel-DLIeWcAj.js} +32 -9
- package/dist/devtools-panel-DLIeWcAj.js.map +1 -0
- package/dist/events-LgLdp1R7.js.map +1 -1
- package/dist/{features-CbgII-o7.js → features-DwMYKBIC.js} +6 -2
- package/dist/features-DwMYKBIC.js.map +1 -0
- package/dist/{files-DtDH5AR4.js → files-BuQvpBwF.js} +94 -3
- package/dist/files-BuQvpBwF.js.map +1 -0
- package/dist/{html-t1JpkODI.js → html-Cf5uKhLs.js} +3 -3
- package/dist/html-Cf5uKhLs.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-Bonq6EJO.js → inspect-BSHv1_25.js} +2739 -2080
- package/dist/inspect-BSHv1_25.js.map +1 -0
- package/dist/{loader-C-S3yzep.js → loader-BPNSRA2A.js} +5 -5
- package/dist/{loader-C-S3yzep.js.map → loader-BPNSRA2A.js.map} +1 -1
- package/dist/{rpc-C_znDZ_w.js → rpc-DqfCaYgF.js} +3 -3
- package/dist/{rpc-C_znDZ_w.js.map → rpc-DqfCaYgF.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/bundles.js +2 -0
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +1 -1
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +4 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +43 -5
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -0
- package/dist/runtime/store.js +1 -0
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{search-params-CM1RWR2P.js → search-params-C64liRBj.js} +34 -9
- package/dist/search-params-C64liRBj.js.map +1 -0
- package/dist/{server-dP_ucRiJ.d.ts → server-0rS5vUW1.d.ts} +37 -10
- package/dist/{server-BcT9icQ4.js → server-BVObWh-w.js} +132 -16
- package/dist/server-BVObWh-w.js.map +1 -0
- package/dist/{shared-CzbnWkVA.d.ts → shared-CuJdWifz.d.ts} +16 -3
- package/dist/{signals-BwD4u22K.d.ts → signals-DBnq9QRW.d.ts} +46 -6
- package/dist/{static-loader-DysAET-w.d.ts → static-loader-BYbXVJDY.d.ts} +2 -2
- package/dist/{static-loader-Bt2WDkY1.js → static-loader-V4V1Oy6G.js} +13 -5
- package/dist/static-loader-V4V1Oy6G.js.map +1 -0
- package/dist/store-BIBAYZo-.js +293 -0
- package/dist/store-BIBAYZo-.js.map +1 -0
- package/dist/store-xlTzAM_r.d.ts +171 -0
- package/dist/{stream-DRjx0keF.js → stream-RXLadXx1.js} +90 -4
- package/dist/stream-RXLadXx1.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +128 -13
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +349 -79
- package/package.json +5 -1
- package/skills/brumate/SKILL.md +1 -1
- package/skills/brumate/references/errors.md +127 -9
- package/skills/brumate/references/signals.md +37 -30
- package/skills/brumate/references/state.md +3 -2
- package/dist/client-C3vRNuLi.js.map +0 -1
- package/dist/client-routes-BtGpYCef.js.map +0 -1
- package/dist/context-CTiSzQRc.js.map +0 -1
- package/dist/devtools-panel-DTQtljeA.js.map +0 -1
- package/dist/features-CbgII-o7.js.map +0 -1
- package/dist/files-DtDH5AR4.js.map +0 -1
- package/dist/html-t1JpkODI.js.map +0 -1
- package/dist/inspect-Bonq6EJO.js.map +0 -1
- package/dist/search-params-CM1RWR2P.js.map +0 -1
- package/dist/server-BcT9icQ4.js.map +0 -1
- package/dist/static-loader-Bt2WDkY1.js.map +0 -1
- package/dist/stream-DRjx0keF.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-BSHv1_25.js","names":["parse","importSource","WRAPPERS","CLIENT_TRIGGERS","isFunction","calleeName","analyze","isWithinAny","WRAPPERS","VOID_ELEMENTS","parse","parse","analyze","hasEvent","WRAPPERS","isFunction","MARKUP_SITES","RAW_TEXT","DEFERRED_SITES","importSource","parse","analyze"],"sources":["../src/error-catalog.ts","../src/error.ts","../src/oxc.ts","../src/bridges.ts","../src/macros.ts","../src/model.ts","../src/analyze.ts","../src/ast.ts","../src/graph.ts","../src/event-names.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/primitive.ts","../src/codegen/patch.ts","../src/shared-module.ts","../src/pending-reads.ts","../src/css.ts","../src/plan.ts","../src/codegen/template.ts","../src/codegen/starts.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":["/** One compile error of a `.brm` file. */\nexport interface ErrorEntry {\n /** The message the compiler reports, with `{name}` for the parts that vary. */\n message: string;\n /** What causes it, in one sentence. */\n cause: string;\n /** The form to write instead, as a short `brm` example. */\n fix: string;\n /** A code such as BRM012. It never changes and is never reused. */\n code?: string;\n /** The docs page that explains the code. */\n link?: string;\n}\n\n/**\n * Codes are stable. A new entry takes the next number that was never used,\n * wherever the entry sits in the catalog. Never change the code of an entry,\n * and never reuse a code. When an error is removed, delete its entry and\n * leave its number unused. test/error-codes.json pins each code to its\n * message, so a test fails when a code changes or is reused. Rewording a\n * message needs a hand edit of that file, for the same code. Add the code of\n * a new entry to it with `UPDATE_SKILL=1 npx vitest run test/check-command.test.ts`.\n */\n\n/** The address of the docs site. Change it here when the site moves. */\nexport const DOCS_SITE = 'https://brumate-docs.vercel.app';\n\n/** The page of the docs that explains every code, with one anchor for each. */\nexport const ERRORS_PAGE: string = `${DOCS_SITE}/docs/errors`;\n\n/** The link to the explanation of a code. */\nexport function errorLink(code: string): string {\n return `${ERRORS_PAGE}#${code.toLowerCase()}`;\n}\n\nfunction entry(code: string, message: string, cause: string, fix: string): ErrorEntry {\n return { message, cause, fix, code, link: errorLink(code) };\n}\n\n/** Syntax errors of the parser, in the order of a file. */\nconst SYNTAX: ErrorEntry[] = [\n entry(\n 'BRM001',\n 'Unterminated comment',\n 'A comment starts and never ends.',\n '<!-- A comment ends with -->\\n<script>\\n /* and so does this one */\\n</script>',\n ),\n entry(\n 'BRM002',\n 'Unterminated string',\n 'A string in code starts and never ends.',\n \"const name = 'Ada';\",\n ),\n entry(\n 'BRM003',\n 'Unterminated template literal',\n 'A template string starts and never ends.',\n 'const label = `Hello ${name}`;',\n ),\n entry(\n 'BRM004',\n 'Unterminated regular expression',\n 'A regular expression starts and never ends.',\n 'const digits = /\\\\d+/;',\n ),\n entry(\n 'BRM005',\n 'Unexpected \"{char}\"',\n 'Code has a bracket that closes nothing.',\n 'const list = [1, 2];',\n ),\n entry(\n 'BRM006',\n 'Expected \"{char}\"',\n 'Code opens a bracket and never closes it. The message names the closing one.',\n 'const list = [1, 2];',\n ),\n entry(\n 'BRM007',\n 'Expected \"}\" to close the block',\n 'A `#` block opens with `{` and the file ends before its `}`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM008',\n 'Unexpected end of file, expected a closing tag',\n 'An element is never closed.',\n '<div>\\n <p>Text</p>\\n</div>',\n ),\n entry('BRM009', 'Unexpected closing tag', 'A closing tag has no opening tag.', '<p>Text</p>'),\n entry(\n 'BRM010',\n '<script> must be at the top level or at the start of a block',\n 'A `<script>` is inside an element, or after other markup in a block.',\n '#for (item of items) {\\n <script>\\n let open = $signal(false);\\n </script>\\n <p>{item}</p>\\n}',\n ),\n entry(\n 'BRM011',\n '<style> must be at the top level',\n 'A `<style>` is inside an element or a block.',\n '<style>\\n p {\\n color: red;\\n }\\n</style>\\n<p>Text</p>',\n ),\n entry(\n 'BRM012',\n '#template must be at the top level or at the start of a block',\n 'A `#template` is inside an element, or after other markup in a block.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n entry(\n 'BRM013',\n '#{branch} must follow its block',\n 'A branch such as `#else` or `#catch` comes without the block that it belongs to.',\n '#if (open) {\\n <p>Open</p>\\n} #else {\\n <p>Closed</p>\\n}',\n ),\n entry('BRM014', 'Expected a tag name', 'A `<` starts a tag with no name.', '<p>1 < 2</p>'),\n entry(\n 'BRM015',\n '<{name}> must end with \"/>\"',\n '`<window>` and `<document>` take no children, so they close with `/>`.',\n '<window onKeyDown=(handler) />',\n ),\n entry('BRM016', 'Expected </{name}>', 'A closing tag is not complete.', '<p>Text</p>'),\n entry(\n 'BRM017',\n 'Unexpected end of file, expected \">\"',\n 'A tag starts and the file ends before its `>`.',\n '<input value=name>',\n ),\n entry(\n 'BRM018',\n 'Expected whitespace between attributes',\n 'Two attributes touch each other.',\n '<input id=name type=\"text\">',\n ),\n entry(\n 'BRM019',\n 'Only event handlers are allowed here',\n '`<window>` and `<document>` take event handlers and nothing else.',\n '<document onKeyDown=(handler) />',\n ),\n entry(\n 'BRM020',\n 'Expected a spread or a shorthand attribute',\n 'A `{` in a tag holds something other than `...rest` or a name.',\n '<a {href} {...rest}>Open</a>',\n ),\n entry(\n 'BRM021',\n 'Expected an attribute name',\n 'A tag has a character where an attribute name belongs.',\n '<input disabled>',\n ),\n entry(\n 'BRM022',\n 'Event modifiers in the attribute name were removed. Write {fix}',\n 'A modifier follows the event name, as in `onSubmit:prevent=send`. Wrappers of `brumate/events` write modifiers now, and `:passive` is the default, since listeners are passive unless a handler prevents.',\n \"import { prevent } from 'brumate/events';\\n\\n<form onSubmit=(prevent(send))></form>\",\n ),\n entry(\n 'BRM180',\n '\"{name}\" is not an event name. Write \"{camel}\"',\n 'An event of more than one word is written in camel case. The lower-case form is an error.',\n '<input onKeyDown=(handle) onFocusOut=(handle) />',\n ),\n entry(\n 'BRM201',\n '\"{name}\" cannot be a handler. {fix}',\n \"The event has capitals in its name, or the browser fires another name for it, and a handler name is lower-cased to the event. `onDOMContentLoaded` would listen to `domcontentloaded`, which the browser never fires, and page code loads after the HTML, mostly after `DOMContentLoaded`. Use the event that the message names, or `$client(fn, 'load')` to run code at load.\",\n \"<script>\\n $client(() => {\\n start();\\n }, 'load');\\n</script>\",\n ),\n entry(\n 'BRM186',\n '\"{name}\" in the #loading header is not a memo that markup in the body reads. Name a $memo of the component or of a block script around the block',\n 'The header of `#loading (…)` names something other than a memo, or a memo that no markup in the body reads, so its loads would not show the fallback for that body.',\n 'const posts = $memo(loadPosts(id));\\n#loading (posts) {\\n <p>{posts.length} posts</p>\\n} #else {\\n <p>Loading</p>\\n}',\n ),\n entry(\n 'BRM182',\n 'The handler reads \"{name}\", a memo that can lack a value. Wait for it with await $resolve({name}), or check $isPending({name}) first',\n 'A handler, a handler prop or a `$client` callback reads an async memo that may still be loading, with no `$isPending` check or `await $resolve` before the read.',\n '<script>\\n const user = $memo(getUser(id));\\n async function save() {\\n await $resolve(user);\\n send(user.name);\\n }\\n</script>',\n ),\n entry(\n 'BRM183',\n '$resolve needs a $memo and, as an option, a timeout or a signal',\n '`$resolve` takes the name of a memo, and one object of options at most.',\n 'async function save() {\\n const profile = await $resolve(user, { timeout: 5000 });\\n}',\n ),\n entry(\n 'BRM184',\n '$resolve cannot run where a memo computes or markup renders. Call it in a handler, an effect or a $client callback',\n '`$resolve` waits, so it is called where an event starts the code, not where a memo computes or markup renders.',\n 'async function save() {\\n await $resolve(user);\\n}',\n ),\n entry(\n 'BRM185',\n '<{tag}> cannot be inside <{parent}>: the HTML parser closes or moves it before the page runs. Move it out of the <{parent}>, or use a <span> or as=\"span\"',\n 'The HTML parser does not keep this nesting. A `<p>` ends at a block element such as `<div>`, an `<a>` or a `<form>` inside the same tag starts again, and a table keeps only table parts. The browser builds a page that differs from the markup, and the start and end markers of a block can land in different parents.',\n '<p>Total: <span>{total}</span></p>\\n<div>\\n <p>Total</p>\\n</div>',\n ),\n entry(\n 'BRM187',\n 'The {kind} {name} of {component} did not settle: it writes a value that it reads, and runs again without end. Wrap the read or the write in $untrack, or write only when the value changes',\n 'In the browser, an effect or an update writes a value that it reads, so each run schedules the next. Past 1000 rounds of effects, or 10000 rounds of updates, in one change, the page stops the loop and sends this error to the nearest `#try` in place of hanging the tab. A production build sends the short form `Update loop {scope}:{name} [BRM187]`.',\n \"<script>\\n import { $effect, $signal, $untrack } from 'brumate/signals';\\n\\n let query = $signal('');\\n let saves = $signal(0);\\n\\n $effect(() => {\\n void query;\\n $untrack(saves++);\\n });\\n</script>\",\n ),\n entry(\n 'BRM188',\n '\"{name}\" gives a promise, and {place} cannot wait for one. Await it in the code that runs, or read its value with $memo',\n 'Markup waits for a promise in text and in attribute values only. An event handler, the key of a `#for`, a `ref` and a `$bind` need the value at once, and the compiler sees that this expression gives a promise: `new Promise(…)`, a call of a server function or of an async function, or a prop typed as a promise.',\n '<button onClick=(() => save(draft))>Save</button>\\n#for (user of users by user.id) {\\n <p>{user.name}</p>\\n}',\n ),\n entry(\n 'BRM024',\n 'Expected an event handler',\n 'An event attribute has no `=` and no value.',\n '<button onClick=(() => count++)>Add</button>',\n ),\n entry(\n 'BRM025',\n 'An event handler must be an expression, not a string',\n 'The value of an event attribute is a quoted string.',\n '<button onClick=(() => count++)>Add</button>',\n ),\n entry(\n 'BRM026',\n 'An attribute name can have one \":\" namespace',\n 'An attribute name has two or more `:`.',\n '<svg xlink:href=\"#icon\"></svg>',\n ),\n entry(\n 'BRM027',\n 'ref takes $bind, as in ref=$bind(name)',\n '`ref` has a value that is not `$bind(name)`.',\n '<input ref=$bind(input)>',\n ),\n entry(\n 'BRM028',\n 'prefetch is removed. The code of the page loads when it starts',\n 'The `prefetch` attribute no longer exists.',\n '<a href=\"/about\">About</a>',\n ),\n entry(\n 'BRM029',\n 'Markup is not allowed in attribute values. Use a #template.',\n 'An attribute value holds an element.',\n '<List item=row />\\n\\n#template row(name: string) {\\n <b>{name}</b>\\n}',\n ),\n entry(\n 'BRM030',\n 'Expected an attribute value',\n 'An attribute has `=` and nothing after it.',\n '<input value=name>',\n ),\n entry(\n 'BRM031',\n 'Wrap this attribute value in parentheses',\n 'An attribute value without quotes has an operator or a space in it.',\n '<button disabled=(count > 3)>Add</button>',\n ),\n entry(\n 'BRM032',\n 'Expected \">\" to end <{name}>',\n 'A tag has text where its `>` belongs.',\n '<input value=name>',\n ),\n entry(\n 'BRM033',\n 'Expected a quoted value',\n 'A `<script>` or `<style>` attribute has `=` without a quoted value.',\n '<script generics=\"T\"></script>',\n ),\n entry(\n 'BRM034',\n 'Expected {close}',\n 'A `<script>` or `<style>` is not closed.',\n '<script>\\n let a = 1;\\n</script>',\n ),\n entry(\n 'BRM035',\n 'Unknown <script> attribute \"{name}\"',\n 'A `<script>` has an attribute other than `module` and `generics`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM036',\n 'A file can have one <script module>',\n 'A file has two module scripts.',\n '<script module>\\n export const MAX = 10;\\n export const MIN = 1;\\n</script>',\n ),\n entry(\n 'BRM037',\n 'A file can have one <script>',\n 'A file has two instance scripts.',\n '<script>\\n let a = $signal(1);\\n let b = $signal(2);\\n</script>',\n ),\n entry(\n 'BRM038',\n 'lang must be \"css\", \"scss\" or \"less\"',\n 'A `<style>` names another language.',\n '<style lang=\"scss\">\\n p {\\n a {\\n color: red;\\n }\\n }\\n</style>',\n ),\n entry(\n 'BRM189',\n 'Unknown <style> attribute \"{name}\"',\n 'A `<style>` has an attribute other than `lang` and `global`.',\n '<style scoped>\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM190',\n 'global takes no value, as in <style global>',\n 'A `<style global>` gives `global` a value.',\n '<style global=\"true\">\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM039',\n \"#reveal takes an order, 'sequential', 'backwards', 'together' or 'natural', and collapsed, such as #reveal ('sequential', collapsed)\",\n '`#reveal` has an option that it does not know.',\n \"#reveal ('sequential', collapsed) {\\n …\\n}\",\n ),\n entry(\n 'BRM040',\n \"collapsed shows the fallback of the next body to show, so it needs the order 'sequential', not '{order}'\",\n '`collapsed` goes with `sequential` only.',\n \"#reveal ('sequential', collapsed) {\\n …\\n}\",\n ),\n entry(\n 'BRM041',\n '#reveal has no script of its own',\n 'A `#reveal` body starts with a `<script>`.',\n '<script>\\n let open = $signal(false);\\n</script>\\n#reveal {\\n …\\n}',\n ),\n entry(\n 'BRM042',\n 'Expected \"(\" after #{keyword}',\n 'A block that takes a condition or a list has no `(`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM043',\n 'Expected an expression after #{keyword}',\n 'The parentheses of a block are empty.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM044',\n 'Expected \"{\" after #{keyword}',\n 'The header of a block is not followed by `{`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM045',\n 'Expected \"{\" after #switch',\n '`#switch` has no `{` after it.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n}',\n ),\n entry(\n 'BRM046',\n 'The script of a block takes no attributes',\n 'A `<script>` at the start of a block has attributes such as `module`.',\n '#for (item of items) {\\n <script>\\n let open = $signal(false);\\n </script>\\n <p>{item}</p>\\n}',\n ),\n entry(\n 'BRM047',\n '#try needs a #catch block',\n 'A `#try` body is not followed by `#catch`.',\n '#try {\\n <p>{load()}</p>\\n} #catch (error, reset) {\\n <p>Failed</p>\\n}',\n ),\n entry(\n 'BRM048',\n 'Expected \"(error, reset)\" after #catch',\n 'The header of `#catch` names something other than a plain error name and a plain reset name.',\n '#catch (error, reset) {\\n <p>{String(error)}</p>\\n}',\n ),\n entry(\n 'BRM049',\n 'The trigger of #{keyword} must be \"visible\", \"idle\" or \"load\"',\n 'A `#client` block names another trigger.',\n \"#client ('idle') {\\n <p>In the browser</p>\\n}\",\n ),\n entry(\n 'BRM050',\n 'Unknown block #{keyword}',\n 'A `#` starts a block that does not exist.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM051',\n 'Expected \"index of count\" after #repeat',\n 'The header of `#repeat` is not `index of count`.',\n '#repeat (star of 5) {\\n <i>{star}</i>\\n}',\n ),\n entry(\n 'BRM052',\n 'Expected \"item of list\" or \"item, index of list\" after #for',\n 'The header of `#for` has no `of`.',\n '#for (item, index of items by item.id) {\\n <li>{item.name}</li>\\n}',\n ),\n entry(\n 'BRM053',\n 'Expected the height of an item in window(height)',\n '`window` after a `#for` header has no height.',\n '#for (row of rows by row.id) window(32) {\\n <tr><td>{row.name}</td></tr>\\n}',\n ),\n entry(\n 'BRM054',\n 'Only #case and #default are allowed in #switch',\n 'A `#switch` holds markup other than its cases.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n #default {\\n <p>Other</p>\\n }\\n}',\n ),\n entry(\n 'BRM055',\n '#default must be the last branch of #switch',\n 'A `#case` comes after the `#default`.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n #default {\\n <p>Other</p>\\n }\\n}',\n ),\n entry(\n 'BRM056',\n 'Expected \"(\" after the name of the template',\n 'A `#template` has no parameter list.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n entry(\n 'BRM057',\n 'Expected an expression',\n 'An attribute or a block has code that is not an expression.',\n '<p>{count + 1}</p>',\n ),\n entry(\n 'BRM058',\n 'Expected a binding pattern',\n 'The name of a `#for` or `#catch` is not a name or a pattern.',\n '#for ({ id, name } of people by id) {\\n <li>{name}</li>\\n}',\n ),\n entry(\n 'BRM059',\n 'Expected parameters',\n 'The parameters of a `#template` are not a parameter list.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n];\n\n/** Errors about `$signal`, `$memo` and the other compile-time functions. */\nconst SCRIPT: ErrorEntry[] = [\n entry(\n 'BRM060',\n '\"{name}\" is already declared',\n 'Two declarations of one scope have the same name.',\n 'let count = $signal(0);\\nlet total = $signal(0);',\n ),\n entry(\n 'BRM061',\n '{name} takes a handler',\n '`prevent`, `stop`, `once`, `capture` or `transition` has no handler, or `stop`, `once` or `capture` has keys.',\n '<form onSubmit=(prevent(send))></form>',\n ),\n entry(\n 'BRM062',\n 'Only prevent of a keyboard event takes keys, such as onKeyDown',\n 'Keys are given to `prevent` of an event that is not `onKeyDown`, `onKeyUp` or `onKeyPress`.',\n \"<ul onKeyDown=(prevent(move, 'ArrowDown'))></ul>\",\n ),\n entry(\n 'BRM063',\n \"Name each key of prevent as a string of its event.key, such as 'ArrowDown', 'Space' or 'a', with a modifier to hold if it needs one, such as 'Mod+ArrowDown'\",\n 'A key of `prevent` is not a string literal of an `event.key`.',\n \"<ul onKeyDown=(prevent(move, 'ArrowDown', 'Mod+ArrowUp'))></ul>\",\n ),\n entry(\n 'BRM064',\n \"Name each key of prevent as a string, such as 'Enter'\",\n 'A key of `prevent` is not a string literal.',\n \"<input onKeyDown=(prevent(submit, 'Enter'))>\",\n ),\n entry(\n 'BRM065',\n 'Server function \"{name}\" must be async',\n \"A function with `'use server'` is not `async`.\",\n \"async function save(list: string[]) {\\n 'use server';\\n await db.save(list);\\n}\",\n ),\n entry(\n 'BRM066',\n 'The module script cannot have a default export',\n '`<script module>` has `export default`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM067',\n 'A script cannot export values. Use <script module>',\n 'The instance script has an `export`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM068',\n '$title takes one argument, the title',\n '`$title` has no argument or more than one.',\n \"$title('Todos');\",\n ),\n entry(\n 'BRM069',\n 'await works with $memo, not {name}',\n 'A declaration awaits a compile-time function other than `$memo`.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM070',\n '$props() can only be called in the component script',\n '`$props()` is in a module script or a function.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM071',\n 'Assign $props() to a const or a let',\n 'The result of `$props()` is not assigned with `const` or `let`.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM072',\n '$props() takes no arguments',\n '`$props()` has an argument.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM073',\n 'Assign $props() to a name or an object pattern',\n '`$props()` is assigned to an array pattern.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM074',\n 'Create an ID with \"const name = $id()\"',\n '`$id()` is not the value of a `const`.',\n 'const field = $id();',\n ),\n entry('BRM075', '$id takes no arguments', '`$id` has an argument.', 'const field = $id();'),\n entry(\n 'BRM076',\n '$isPassed takes a prop that the component destructures, such as $isPassed(value)',\n 'The argument of `$isPassed` is not a prop of the component.',\n 'let { value } = $props<{ value?: Bindable<string> }>();\\nconst passed = $isPassed(value);',\n ),\n entry(\n 'BRM077',\n '$navigation takes no arguments',\n '`$navigation` has an argument.',\n 'const navigation = $navigation();',\n ),\n entry(\n 'BRM078',\n '$route takes at most one argument, the path of the route',\n '`$route` has more than one argument.',\n \"const route = $route('/posts/[id]');\",\n ),\n entry(\n 'BRM079',\n 'Read a context with \"const name = $getContext(Context)\"',\n '`$getContext` is not the value of a `const`.',\n 'const theme = $getContext(ThemeContext);',\n ),\n entry(\n 'BRM080',\n '$getContext takes the context, and a fallback for a read without a provider',\n '`$getContext` has no argument or more than two.',\n 'const theme = $getContext(ThemeContext);\\nconst locale = $getContext(LocaleContext, undefined);',\n ),\n entry(\n 'BRM081',\n '$setContext takes two arguments, the context and the value',\n '`$setContext` has fewer or more than two arguments.',\n '$setContext(ThemeContext, theme);',\n ),\n entry(\n 'BRM082',\n 'Declare the result of a form with \"const name = $action(serverFunction)\"',\n '`$action` is not the value of a `const`.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM083',\n '$action needs a server function of this file as its only argument',\n '`$action` has no argument, or more than one.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM084',\n '$action needs a server function of this file, and {name} is not one',\n \"The argument of `$action` is not a function with `'use server'` in this file.\",\n \"async function save(data: FormData) {\\n 'use server';\\n}\\nconst result = $action(save);\",\n ),\n entry(\n 'BRM085',\n 'Declare {name} with const',\n '`$debounced` or `$throttled` is declared with `let`.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM086',\n '{name} cannot be destructured',\n 'A signal, a memo or another value of a compile-time function is declared with a pattern.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM087',\n '{name} takes a value and a wait in milliseconds',\n '`$debounced` or `$throttled` does not have both arguments.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM088',\n 'The wait of {name} must be a number of milliseconds, such as 300',\n 'The wait of `$debounced` or `$throttled` is not a number literal.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM089',\n 'Declare {name} with {expected}',\n '`$signal` and `$optimistic` need `let`, and `$memo` needs `const`.',\n 'let count = $signal(0);\\nconst double = $memo(count * 2);',\n ),\n entry(\n 'BRM090',\n '{name} takes one argument',\n '`$signal`, `$memo` or `$optimistic` has more than one argument.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM091',\n '{name} needs a value',\n '`$memo` or `$optimistic` has no argument.',\n 'const double = $memo(count * 2);',\n ),\n entry(\n 'BRM092',\n '$optimistic needs the name of a value, such as a memo',\n 'The argument of `$optimistic` is not a name.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM093',\n '{name} does not return a value',\n '`$effect` or `$client` is assigned to a name.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM094',\n '{name} needs a function',\n '`$effect` or `$client` has no function as its callback.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM095',\n 'The callback of {name} takes no parameters',\n 'The callback of `$effect` or `$client` has parameters.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM096',\n 'The callback of {name} cannot be async',\n 'The callback of `$effect` or `$client` is `async`.',\n '$effect(() => {\\n load(id).then((value) => (data = value));\\n});',\n ),\n entry(\n 'BRM097',\n '$effect takes one argument',\n '`$effect` has more than one argument.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM098',\n 'The trigger of $client must be \"visible\", \"idle\" or \"load\"',\n 'The second argument of `$client` is another string.',\n \"$client(() => {\\n measure();\\n}, 'idle');\",\n ),\n entry(\n 'BRM099',\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 'The first argument of `$handler` is not a function.',\n 'onClick: $handler(prevent(removeAt), index),',\n ),\n entry(\n 'BRM100',\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 'A handler reads a local value of the function that calls `$handler`.',\n 'onClick: $handler(removeAt, index),',\n ),\n entry(\n 'BRM101',\n 'The arguments of $handler cannot be spread',\n '`$handler` has a spread argument.',\n 'onClick: $handler(removeAt, index, kind),',\n ),\n entry(\n 'BRM102',\n 'The second argument of $bind is a function that takes the new value: a function expression, or a function of the script',\n 'The setter of `$bind` is not a function.',\n '<Toggle on=$bind(open, (next) => (open = next)) />',\n ),\n entry(\n 'BRM103',\n 'The setter reads \"{name}\", a value of the function around $bind, which the browser does not have',\n 'The setter of `$bind` reads a local value that is not a value of the component.',\n '<Toggle on=$bind(open, (next) => (open = next)) />',\n ),\n entry(\n 'BRM104',\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 '`$bind` is somewhere else, such as on a `class` or a `<div>`.',\n '<input value=$bind(draft)>',\n ),\n entry(\n 'BRM105',\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 '`$bind` has no argument, or an argument that is not a name.',\n '<Toggle on=$bind(open) />',\n ),\n entry(\n 'BRM106',\n '$bind takes a signal, or a prop that the component destructures with let, and \"{name}\" is not one',\n 'The name in `$bind` is a memo, a const prop or another value.',\n 'let open = $signal(false);\\n<Toggle on=$bind(open) />',\n ),\n entry(\n 'BRM107',\n '$isBound takes a prop that the component destructures with let, such as $isBound(open)',\n 'The argument of `$isBound` is not a `let` prop.',\n 'let { open } = $props<{ open?: Bindable<boolean> }>();\\nconst bound = () => $isBound(open);',\n ),\n entry(\n 'BRM108',\n '$isPending needs async $memos as its arguments',\n 'An argument of `$isPending` is not a memo that holds a promise, or the call has none.',\n 'const results = $memo(search(query));\\n#if ($isPending(results)) {\\n <p>Searching…</p>\\n}',\n ),\n entry(\n 'BRM109',\n '$produce needs a signal as its first argument',\n 'The first argument of `$produce` is not a signal.',\n '$produce(todos, (draft) => {\\n draft.push(todo);\\n});',\n ),\n entry(\n 'BRM110',\n '$produce needs a recipe function as its second argument',\n 'The second argument of `$produce` is not a function.',\n '$produce(todos, (draft) => {\\n draft.push(todo);\\n});',\n ),\n entry(\n 'BRM111',\n '\"{name}\" is reserved. Brumate writes the attributes that start with \"b-\"',\n 'An attribute starts with `b-`.',\n '<div data-id=id></div>',\n ),\n entry(\n 'BRM112',\n '\"{name}\" is not declared',\n 'The name in `ref=$bind(name)` is not a value of the component.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM113',\n 'ref takes a $signal, or a prop that the component destructures with let, but \"{name}\" is {kind}',\n 'The name in `ref=$bind(name)` is a memo, a const prop or another value.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM114',\n 'The prop \"{name}\" is not Bindable. Type it as Bindable<HTMLElement>, so a parent can bind it',\n 'A `let` prop is used as a `ref` and its type is not `Bindable`.',\n 'let { ref } = $props<{ ref?: Bindable<HTMLButtonElement> }>();',\n ),\n entry(\n 'BRM115',\n '\"{name}\" is the props object, so read one key at a time, destructure it, or spread it in markup',\n 'The props object or the rest of `$props()` is used as a whole outside a markup spread: spread in code, passed to a function, `$memo`, `$setContext`, a signal or a variable, or given as a value in markup, such as `title=rest` or `<Badge {rest} />`. The copy loses the `ref` and the live props. A spread may hold the rest as a branch of `?:`, `&&`, `||` or `??` next to an object literal, `undefined`, `null` or `false`, such as `{...(open ? rest : {})}`.',\n 'const { class: className, ...rest } = $props();\\n<button {...rest} class=className>',\n ),\n entry(\n 'BRM116',\n '\"{name}\" is the props object, and props are read-only. Copy the key to a $signal or a $memo to change it',\n 'Code assigns to, updates or deletes a key of the props object or of the rest of `$props()`.',\n \"let title = $signal('');\\ntitle = 'New';\",\n ),\n entry(\n 'BRM117',\n 'Cannot assign to {kind} \"{name}\"',\n 'Code writes a memo, a const prop or another value that cannot change.',\n 'let count = $signal(0);\\ncount = 5;',\n ),\n entry(\n 'BRM118',\n 'Signal \"{name}\" can only be written in event handlers, effects, $client callbacks and functions',\n 'Setup code, which runs on the server, writes a signal.',\n 'let count = $signal(5);',\n ),\n entry(\n 'BRM119',\n 'Server function \"{name}\" captures \"{variable}\". Pass it as an argument',\n 'A server function reads a variable of the instance script.',\n \"async function save(user: string) {\\n 'use server';\\n}\",\n ),\n entry(\n 'BRM120',\n '$optimistic follows a memo, an action or a prop, not a signal',\n 'The source of `$optimistic` is a signal.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM121',\n 'Declare server functions at the top level of a script',\n \"A function with `'use server'` is inside another function or a block.\",\n \"async function save() {\\n 'use server';\\n}\",\n ),\n entry(\n 'BRM122',\n '{name} cannot be used here',\n 'A compile-time function is used where it is not allowed.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM123',\n 'Call $setContext at the top level of a script',\n '`$setContext` is inside a function or a block of code.',\n '$setContext(ThemeContext, theme);',\n ),\n entry(\n 'BRM124',\n 'Call $title at the top level of a script',\n '`$title` is inside a function or a block of code.',\n \"$title('Todos');\",\n ),\n entry(\n 'BRM125',\n 'Create an ID with \"const name = $id()\" at the top level of a script',\n '`$id` is inside a function or a block of code.',\n 'const field = $id();',\n ),\n entry(\n 'BRM126',\n 'Check a prop with \"const name = $isPassed(prop)\" at the top level of the component script',\n '`$isPassed` is inside a function or a block of code.',\n 'const passed = $isPassed(value);',\n ),\n entry(\n 'BRM127',\n 'Read a context with \"const name = $getContext(Context)\" at the top level of a script',\n '`$getContext` is inside a function or a block of code.',\n 'const theme = $getContext(ThemeContext);',\n ),\n entry(\n 'BRM128',\n 'Read the route with \"const name = $route()\" at the top level of a script',\n '`$route` is inside a function or a block of code.',\n 'const route = $route();',\n ),\n entry(\n 'BRM129',\n 'Read the navigation with \"const name = $navigation()\" at the top level of a script',\n '`$navigation` is inside a function or a block of code.',\n 'const navigation = $navigation();',\n ),\n entry(\n 'BRM130',\n 'Call $props() as the value of a const in the component script',\n '`$props` is used in another place than `const { … } = $props()`.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM131',\n 'Declare a signal with \"let name = $signal(value)\" at the top level of a script',\n '`$signal` is inside a function or a block of code.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM132',\n 'Declare a memo with \"const name = $memo(value)\" at the top level of a script',\n '`$memo` is inside a function or a block of code.',\n 'const double = $memo(count * 2);',\n ),\n entry(\n 'BRM202',\n '$gate takes a value and a function, as in $gate(value, (prev, next) => next > prev)',\n '`$gate` does not have a value and a guard function as its two arguments. The guard is an arrow function or a function expression.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM203',\n '$gate takes a value that is ready. Use $memo for a promise or a server function',\n 'The value of `$gate` awaits or calls a server function. The compiler catches these two; any other promise or stream, such as a call of a local async function, throws when the value is computed. A gate holds a value that the guard can compare, so it does not wait for one.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM204',\n 'Declare a gated value with \"const name = $gate(value, (prev, next) => boolean)\" at the top level of a script',\n '`$gate` is inside a function or a block of code.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM133',\n 'Declare a debounced value with \"const name = $debounced(value, ms)\" at the top level of a script',\n '`$debounced` is inside a function or a block of code.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM134',\n 'Declare a throttled value with \"const name = $throttled(value, ms)\" at the top level of a script',\n '`$throttled` is inside a function or a block of code.',\n 'const position = $throttled(pointer, 100);',\n ),\n entry(\n 'BRM135',\n 'Declare an optimistic value with \"let name = $optimistic(source)\" at the top level of a script',\n '`$optimistic` is inside a function or a block of code.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM136',\n 'Declare the result of a form with \"const name = $action(serverFunction)\" at the top level of a script',\n '`$action` is inside a function or a block of code.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM137',\n 'Call $effect at the top level of a script',\n '`$effect` is inside a function or a block of code.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM138',\n 'Call $client at the top level of a script',\n '`$client` is inside a function or a block of code.',\n \"$client(() => {\\n measure();\\n}, 'idle');\",\n ),\n entry(\n 'BRM139',\n '$ref is not supported. Use a $signal with ref=$bind(name)',\n '`$ref` was removed.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM140',\n '$watch is not supported. Use $effect',\n '`$watch` was removed.',\n '$effect(() => {\\n save(value);\\n});',\n ),\n entry(\n 'BRM141',\n '$settled is not supported. Use $client',\n '`$settled` was removed.',\n '$client(() => {\\n measure();\\n});',\n ),\n entry(\n 'BRM142',\n '$cleanup is not supported. Return a cleanup function from $effect or $client',\n '`$cleanup` was removed.',\n '$effect(() => {\\n const timer = setInterval(tick, 1000);\\n return () => clearInterval(timer);\\n});',\n ),\n entry(\n 'BRM191',\n 'Read a store with \"const name = $store(source)\" or \"let name = $store(source)\" at the top level of a script',\n '`$store` is not the whole value of a `const` or `let` at the top level of a script.',\n \"import { theme } from './theme';\\nconst value = $store(theme);\",\n ),\n entry(\n 'BRM192',\n '$store takes one argument, a store',\n '`$store` has no argument, or more than one.',\n 'const field = $getContext(Field);\\nconst state = $store(field.state);',\n ),\n entry(\n 'BRM193',\n '$toStore takes one argument, a memo, a signal or a prop, as a value of $setContext',\n '`$toStore` has no argument or more than one, or it is not a value of `$setContext`, alone or as a key of an object or an item of a list.',\n '$setContext(Field, { state: $toStore(state), pick });',\n ),\n entry(\n 'BRM195',\n '$store gives one name, not a pattern such as { a }',\n '`$store` initializes a pattern.',\n 'const value = $store(source);',\n ),\n entry(\n 'BRM196',\n 'The context value reads \"{name}\", which changes, but a context value is read once. Put it in a store with $toStore, or read it inside a function',\n 'The value of `$setContext` reads a signal, a memo, a prop or a `$bind` value that changes in the browser, and a context is read once, so readers would keep the first value. A call or an immediately invoked function in the value that reads such a name is not reported, and freezes the same way.',\n '$setContext(Field, { state: $toStore(state), pick: () => value });',\n ),\n entry(\n 'BRM197',\n 'Read a context that may have no provider with \"const name = $getContext(Context, undefined)\", and a store in it with \"const state = name ? $store(name.key) : undefined\", with const and no other test',\n 'A read of a context that may have no provider has another shape: `$hasContext`, which is removed, `$store(name?.key)`, a `let` or another test in the guard, an `else` that is not `undefined`, a guard on a name that is not the optional value of `$getContext(Context, undefined)`, or a key of that value read without the guard.',\n 'const field = $getContext(Field, undefined);\\nconst state = field ? $store(field.state) : undefined;',\n ),\n entry(\n 'BRM198',\n 'The source of $store gives its store at once, so it cannot await or call a server function',\n 'The source of `$store` awaits, or calls a server function. The browser runs the source again when the page resumes, and links the store in the same pass, so the source must give the store, not a promise of it.',\n \"import { theme } from './theme';\\nconst value = $store(theme);\",\n ),\n entry(\n 'BRM199',\n '$store takes a store. Read the store of a context with \"$store($getContext(Context))\", or give a store as the fallback, \"$store($getContext(Context, store(value)))\"',\n '`$store` reads a context that the file names in `$getContext` or `$setContext`, `undefined`, `null`, or `$getContext` with a literal fallback, which is no store. A context that the file only imports is found when the page renders, as a `TypeError`.',\n \"const level = $store($getContext(LevelContext));\\nconst locale = $store($getContext(LocaleContext, store('en-US')));\",\n ),\n entry(\n 'BRM200',\n 'The value of bridge() must be a module-level export of a script file or of <script module>, as \"export const name = bridge({ … })\"',\n 'A call of `bridge` from `brumate/store` is in the script of a component, or in a function, or is not the value of an exported `const`. The page state names a bridge by its module and its export, so the browser can load it.',\n \"// bears.ts, or the <script module> of a component\\nimport { bridge } from 'brumate/store';\\nexport const bearStore = bridge({ create, get, subscribe });\",\n ),\n entry(\n 'BRM144',\n '$get is not supported. Signals cannot leave the file',\n '`$get` was removed. A signal never leaves its file.',\n '// Pass the value, or a function that writes it.\\nonChange=((next) => (count = next))',\n ),\n entry(\n 'BRM145',\n '$set is not supported. Signals cannot leave the file',\n '`$set` was removed. A signal never leaves its file.',\n '// Pass the value, or a function that writes it.\\nonChange=((next) => (count = next))',\n ),\n entry(\n 'BRM146',\n \"{name} was renamed to {renamed}. Import {renamed} from '{module}'\",\n 'The file imports a name that the compiler knew before it was renamed.',\n \"import { $signal } from 'brumate/signals';\",\n ),\n entry(\n 'BRM147',\n \"Import {name} from '{module}'\",\n 'The file calls a compile-time function that it does not import.',\n \"import { $signal } from 'brumate/signals';\",\n ),\n];\n\n/** Errors about the code that the browser gets, and the markup that the browser renders. */\nconst OUTPUT: ErrorEntry[] = [\n entry(\n 'BRM148',\n '\"{name}\" holds a new {kind}, which cannot be sent to the browser, and code that runs in the browser reads it{reader}. Use it in a server function, or create it in the browser, such as in $client',\n 'A value that cannot be sent to the browser, such as a database client, is read by code that runs there.',\n \"async function list() {\\n 'use server';\\n return db.all();\\n}\",\n ),\n entry(\n 'BRM149',\n '{what} is read by code that runs in the browser ({site}). Read it in a server function',\n 'Code that runs in the browser reads an environment variable of the server.',\n \"async function key() {\\n 'use server';\\n return env.API_KEY;\\n}\",\n ),\n entry(\n 'BRM150',\n '\"{name}\" holds {what} and code that runs in the browser reads it. Keep server variables out of values that the browser reads',\n 'A value holds an environment variable of the server, and the browser reads the value.',\n \"async function key() {\\n 'use server';\\n return env.API_KEY;\\n}\",\n ),\n entry(\n 'BRM151',\n '#defer cannot be inside a #client body',\n 'A `#defer` is in markup that only the browser renders.',\n '#defer {\\n <Comments />\\n}',\n ),\n entry(\n 'BRM152',\n '#defer cannot be in markup that the browser renders',\n 'A `#defer` is in a body that the browser adds later, such as the body of a changing `#if`.',\n '#defer {\\n <Comments />\\n}',\n ),\n entry(\n 'BRM153',\n 'A value that changes in <{tag}> must be its whole content, such as <{tag}>{`Count ${count}`}</{tag}>',\n 'A `<title>`, `<textarea>`, `<style>` or `<script>` holds a changing value next to other content.',\n '<textarea>{`Count ${count}`}</textarea>',\n ),\n entry(\n 'BRM154',\n 'Put <title> in #head, as <meta> and <link>, such as #head { <title>{`${count} left`}</title> }',\n 'A `<title>` is outside `#head`.',\n '#head {\\n <title>{`${count} left`}</title>\\n}',\n ),\n entry(\n 'BRM155',\n 'A dynamic tag that changes on the client is not supported yet',\n 'No `.brm` file reaches it today: the parser keys every dynamic tag, and a `<{tag}>` whose tag a handler changes compiles. It is kept for a tag that the compiler could not update.',\n '<{tag} class=\"title\">Title</>',\n ),\n entry(\n 'BRM156',\n 'Code that the browser updates can await only a memo. Load the promise in a memo instead',\n 'Code that runs again in the browser awaits something other than a memo.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM157',\n 'Markup that the browser renders can await only a memo. Load the promise in a memo instead',\n 'Markup that the browser renders awaits something other than a memo.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM158',\n 'This attribute cannot change on the client yet',\n 'The name or the value of an attribute with a computed name, as in `[name]=value`, changes in the browser.',\n '<div class=(open ? \"open\" : \"closed\")></div>',\n ),\n entry(\n 'BRM159',\n 'This computed attribute has a name or value with no code in the browser, so it cannot stay when the attributes of the element update',\n 'An element has a computed attribute, as in `[name]=(value)`, and a spread or another computed attribute that can change. The name or the value is a constant, or a signal that nothing writes, so the browser has no code for it, and an update of the element would remove the attribute. Make both a signal that the page writes, or write the attribute without brackets.',\n \"let name = $signal('data-x');\\nlet value = $signal('on');\\n\\n<button onClick=(() => ((name = 'data-y'), (value = 'off')))>Change</button>\\n<p {...props} [name]=(value)></p>\\n<p {...props} data-x=\\\"on\\\"></p>\",\n ),\n entry(\n 'BRM160',\n 'Destructuring assignment to a signal is not supported in client code yet',\n 'Code that runs in the browser writes a signal in a destructuring assignment.',\n '[first, second] = pair;\\n// Write each signal on its own:\\nfirst = pair[0];\\nsecond = pair[1];',\n ),\n entry(\n 'BRM161',\n 'Assign to \"{name}\" with = instead of {op}',\n 'An optimistic value is changed with `++` or `--`.',\n 'shown = shown + 1;',\n ),\n entry(\n 'BRM162',\n 'Invalid CSS: {message}',\n 'A `<style>` has CSS that does not parse.',\n '<style>\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM163',\n 'Module functions call each other too deeply. A module function cannot call itself',\n 'A function of a module of reactive logic calls itself, or a loop of functions call each other.',\n 'function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n];\n\n/** Errors about modules of reactive logic, such as `counter.brm.ts`. */\nconst MODULES: ErrorEntry[] = [\n entry(\n 'BRM164',\n 'Destructure what {name} returns, as in const { value } = {name}(…)',\n 'The result of a module function is kept as one object.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM165',\n 'Declare what {name} returns with const',\n 'The result of a module function is declared with `let`.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM166',\n 'Call {name} at the top level of a script, as in const { value } = {name}(…). Its signals become values of the component, so it cannot run in a function, a condition or a loop',\n 'A module function is called inside a function, a condition or a loop.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM167',\n 'Cannot read {specifier}',\n 'The module that the component imports is not on disk.',\n \"import { counter } from './counter.brm.ts';\",\n ),\n entry(\n 'BRM168',\n '{specifier} does not export a function named {name}',\n 'The import names a function that the module does not export.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM169',\n '{name} needs a body that ends with return { … }',\n 'A module function is an arrow function with an expression body.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM170',\n '{name} must end with return { … }, an object of what it gives',\n 'A module function does not end with `return { … }`.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM171',\n '{name} can return only at its end',\n 'A module function returns in the middle of its body.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM172',\n 'Destructure {name} with plain names, as in const { value, other: renamed } = {name}(…)',\n 'The result of a module function is destructured with a default, a nested pattern or a rest.',\n 'const { count, increment: add } = counter(0);',\n ),\n entry(\n 'BRM173',\n '{name} must return an object with plain keys',\n 'The returned object has a computed key, a spread or a method.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM174',\n '{name} cannot return getters or setters. Return the values themselves',\n 'The returned object has a getter or a setter.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM175',\n '{name} does not return {key}',\n 'The component destructures a name that the module function does not return.',\n 'const { count } = counter(0);',\n ),\n entry(\n 'BRM176',\n '{name} returns {local} as {first} and as {key}. Return each local once, and give the other key a function of its own',\n 'A module function returns one local under two keys.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM177',\n '{name} is declared twice',\n 'A name of the module function is also a name of the component.',\n 'const { count: first } = counter(0);\\nconst { count: second } = counter(10);',\n ),\n entry(\n 'BRM178',\n 'Parameters of {name} must be plain names',\n 'A module function has a destructured or default parameter.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM179',\n '{name} reads {local}, which {specifier} does not export. Export it, so the component can import it',\n 'A module function reads a value of its module that is not exported.',\n 'export const STEP = 1;',\n ),\n];\n\nexport const ERRORS: readonly ErrorEntry[] = [...SYNTAX, ...SCRIPT, ...OUTPUT, ...MODULES];\n\n/** True when a message that the compiler reported has the form of an entry. */\nexport function matchesError(error: ErrorEntry, message: string): boolean {\n const escaped: string[] = [];\n for (const part of error.message.split(/\\{\\w+\\}/)) {\n escaped.push(part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n }\n const pattern = escaped.join('[\\\\s\\\\S]*?');\n return new RegExp(`^${pattern}$`).test(message);\n}\n\n/**\n * The entry for a message that the compiler reported. The place of the\n * error, as in `(File.brm:3:7)`, can follow the message.\n */\nexport function findError(message: string): ErrorEntry | undefined {\n const bare = message.replace(/(?:\\s\\([^()]*:\\d+:\\d+\\))+$/, '').replace(/\\s\\[BRM\\d+\\]$/, '');\n // Of the entries that match, the one with the most fixed text is the most specific.\n function fixed(error: ErrorEntry): number {\n return error.message.replace(/\\{\\w+\\}/g, '').length;\n }\n let found: ErrorEntry | undefined;\n for (const error of ERRORS) {\n if (matchesError(error, bare) && (!found || fixed(error) > fixed(found))) {\n found = error;\n }\n }\n return found;\n}\n\n/** The text of references/errors.md. */\nexport function renderErrors(): string {\n const lines = [\n '# Errors',\n '',\n 'The compiler reports each error with the place in the file, as `message (File.brm:line:column)`. This page lists every message, with its cause and the form to write instead. A `{name}` is a part that varies.',\n '',\n 'It is generated from `src/error-catalog.ts`. Do not edit it by hand.',\n ];\n for (const error of ERRORS) {\n lines.push('', `## ${error.code ? `${error.code}: ` : ''}${error.message}`, '', error.cause);\n if (error.link) {\n lines.push('', error.link);\n }\n lines.push('', '```brm fragment', error.fix, '```');\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/** The text of website/docs/errors.md: one section for each code. */\nexport function renderErrorsPage(): string {\n const lines = [\n '# Compile errors',\n '',\n 'Each compile error of brumate has a code. The code is part of the message, and `brumate check` prints it with a link to its section here. A `{name}` in a message is a part that varies.',\n '',\n 'This page is generated from `packages/brumate/src/error-catalog.ts`. Do not edit it by hand.',\n ];\n for (const error of ERRORS) {\n lines.push('', `## ${error.code}`, '', `\\`${error.message}\\``, '', error.cause);\n lines.push('', `\\`\\`\\`${fenceLanguage(error.fix)}`, error.fix, '```');\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The language of the code block of a fix on the site: `brm` when it has markup, and `ts` when it\n * is only script code, which the `.brm` highlighter would color as text.\n */\nfunction fenceLanguage(fix: string): 'brm' | 'ts' {\n return /^\\s*(?:<[A-Za-z/!]|#[a-z]+\\b|\\{)/m.test(fix) ? 'brm' : 'ts';\n}\n","import { findError } from './error-catalog.ts';\n\nexport 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/**\n * The message with the code of its catalog entry, as `message [BRM012]`.\n * A message that has no entry stays as it is.\n */\nexport function withCode(message: string): string {\n const code = findError(message)?.code;\n return code ? `${message} [${code}]` : message;\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(`${withCode(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 { 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\n/**\n * True for a fallback of `$getContext` that the code passes as it is, such as `undefined`, `false`\n * or `'en'`. Other code becomes a function, which runs only when no provider is above.\n */\nexport function isFallbackLiteral(node: oxc.Node): boolean {\n if (node.type === 'Identifier') {\n return node.name === 'undefined';\n }\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","// `bridge()` of `brumate/store`. The page state names a bridge by its module and its export, so\n// its value must be a module-level export of a script file. This finds the calls of `bridge` and\n// names the bridges that are valid; the compiler reports the rest.\n\nimport { parseSync } from 'oxc-parser';\nimport { BrumateError } from './error.ts';\nimport { children } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\n\nconst STORE_MODULE = 'brumate/store';\n/** The name that `export default bridge(…)` gets, so the module can name it. */\nconst DEFAULT_LOCAL = '$$default';\n\n/** The message of BRM200. */\nexport const BRIDGE_EXPORT =\n 'The value of bridge() must be a module-level export of a script file or of <script module>, as \"export const name = bridge({ … })\"';\n\n/** A call of `bridge`, and the name it is exported as when it is valid. */\nexport interface BridgeCall {\n call: oxc.Node;\n exported?: string;\n /** The name of the binding, which the module writes the name of the bridge for. */\n local?: string;\n /** For `export default bridge(…)`, the statement, which the transform rewrites. */\n statement?: oxc.Node;\n}\n\n/** True when a file can hold a call of `bridge`, which is cheap to know before it is parsed. */\nexport function mayHaveBridge(source: string): boolean {\n return source.includes('bridge') && source.includes(STORE_MODULE);\n}\n\n/** The import that the naming calls need. */\nexport const NAME_BRIDGE_IMPORT: string = `import { nameBridge as $$nameBridge } from ${JSON.stringify(STORE_MODULE)};`;\n\n/**\n * The calls that name the bridges of the `<script module>` of a component, by the ID of the\n * component, `bridge:<id>#<export>`. A bridge that is not an export by name is not in the list;\n * the analyzer reports it.\n */\nexport function moduleBridgeNames(program: oxc.Program | undefined, componentId: string): string[] {\n const lines: string[] = [];\n for (const { exported, local, statement } of program ? findBridgeCalls(program) : []) {\n if (exported !== undefined && local !== undefined && !statement) {\n lines.push(`$$nameBridge(${local}, ${JSON.stringify(`bridge:${componentId}#${exported}`)});`);\n }\n }\n return lines;\n}\n\n/** True when a script file has a bridge that is a module-level export. */\nexport function hasBridge(source: string, file: string): boolean {\n return scriptBridges(source, file).some((item) => item.exported !== undefined);\n}\n\n/** The id of the module of a file, from its name in the app or in its package. */\nexport function bridgeModuleId(name: string): string {\n return `bridge:${name}`;\n}\n\n/** The local names of `bridge` and of namespaces of `brumate/store` that a program imports. */\nfunction importedNames(program: oxc.Program): { direct: Set<string>; spaces: Set<string> } {\n const direct = new Set<string>();\n const spaces = new Set<string>();\n for (const statement of program.body) {\n if (statement.type !== 'ImportDeclaration' || statement.source.value !== STORE_MODULE) {\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportNamespaceSpecifier') {\n spaces.add(specifier.local.name);\n } else if (specifier.type === 'ImportSpecifier') {\n const imported =\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value;\n if (imported === 'bridge') {\n direct.add(specifier.local.name);\n }\n }\n }\n }\n return { direct, spaces };\n}\n\n/** True for a call of the imported `bridge`. */\nfunction isBridgeCall(node: oxc.Node, names: ReturnType<typeof importedNames>): boolean {\n if (node.type !== 'CallExpression') {\n return false;\n }\n const callee = node.callee;\n if (callee.type === 'Identifier') {\n return names.direct.has(callee.name);\n }\n return (\n callee.type === 'MemberExpression' &&\n !callee.computed &&\n callee.object.type === 'Identifier' &&\n names.spaces.has(callee.object.name) &&\n callee.property.type === 'Identifier' &&\n callee.property.name === 'bridge'\n );\n}\n\n/** The expression under `as`, `satisfies`, `!` and parentheses. */\nfunction unwrap(node: oxc.Node): oxc.Node {\n let current = node;\n while (\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSNonNullExpression' ||\n current.type === 'ParenthesizedExpression'\n ) {\n current = current.expression;\n }\n return current;\n}\n\n/** Every call of `bridge` under a node. */\nfunction collect(node: oxc.Node, names: ReturnType<typeof importedNames>, found: oxc.Node[]): void {\n if (isBridgeCall(node, names)) {\n found.push(node);\n }\n for (const [, child] of children(node)) {\n collect(child, names, found);\n }\n}\n\n/**\n * Finds the calls of `bridge` in a program. A call is valid when its value is a `const` that the\n * module exports by name: `export const name = bridge(…)`, or `const name = bridge(…)` with\n * `export { name }` or `export { name as other }`. Every other call has no `exported`.\n */\nexport function findBridgeCalls(program: oxc.Program): BridgeCall[] {\n const names = importedNames(program);\n if (names.direct.size === 0 && names.spaces.size === 0) {\n return [];\n }\n const calls: oxc.Node[] = [];\n collect(program, names, calls);\n if (calls.length === 0) {\n return [];\n }\n // The bridges that a top-level `const` holds, by the call.\n const locals = new Map<oxc.Node, string>();\n const exported = new Map<oxc.Node, string>();\n const declare = (declaration: oxc.Node, isExport: boolean): void => {\n if (declaration.type !== 'VariableDeclaration' || declaration.kind !== 'const') {\n return;\n }\n for (const declarator of declaration.declarations) {\n const init = declarator.init && unwrap(declarator.init);\n if (init && declarator.id.type === 'Identifier' && isBridgeCall(init, names)) {\n locals.set(init, declarator.id.name);\n if (isExport) {\n exported.set(init, declarator.id.name);\n }\n }\n }\n };\n const defaults = new Map<oxc.Node, oxc.Node>();\n for (const statement of program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n const init = unwrap(statement.declaration as oxc.Node);\n if (isBridgeCall(init, names)) {\n defaults.set(init, statement);\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 }` of a local that holds a bridge.\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 for (const [call, local] of locals) {\n if (specifier.local.type === 'Identifier' && specifier.local.name === local) {\n exported.set(\n call,\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value,\n );\n }\n }\n }\n }\n }\n const result: BridgeCall[] = [];\n for (const call of calls) {\n const statement = defaults.get(call);\n if (statement) {\n result.push({ call, exported: 'default', local: DEFAULT_LOCAL, statement });\n continue;\n }\n const name = exported.get(call);\n result.push(name === undefined ? { call } : { call, exported: name, local: locals.get(call) });\n }\n return result;\n}\n\n/** The calls of `bridge` in a script file, or none when it has none or does not parse. */\nexport function scriptBridges(source: string, file: string): BridgeCall[] {\n if (!mayHaveBridge(source)) {\n return [];\n }\n const { program, errors } = parseSync(file, source, {\n lang: /\\.[cm]?tsx?$/.test(file) ? 'ts' : 'js',\n });\n // Another tool reports a syntax error of a script.\n return errors[0] ? [] : findBridgeCalls(program);\n}\n\n/**\n * Checks the bridges of a script file and returns the file with each bridge named, or undefined\n * when it has none. The names are added at the end, so lines stay where they are; only\n * `export default bridge(…)` is rewritten, on its own line, to a `const` and an export. Throws a\n * `BrumateError` (BRM200) for a call that is not a module-level export.\n */\nexport function nameBridges(source: string, file: string, moduleId: string): string | undefined {\n const lines: string[] = [];\n const edits: [offset: number, remove: number, text: string][] = [];\n for (const { call, exported, local, statement } of scriptBridges(source, file)) {\n if (exported === undefined || local === undefined) {\n throw new BrumateError(BRIDGE_EXPORT, source, call.start, file);\n }\n if (statement) {\n // `export default` becomes `const $$default =`, and the export follows the call.\n edits.push([statement.start, 'export default'.length, `const ${local} =`]);\n edits.push([call.end, 0, `;export default ${local}`]);\n }\n lines.push(`$$nameBridge(${local}, ${JSON.stringify(`${moduleId}#${exported}`)});`);\n }\n if (lines.length === 0) {\n return undefined;\n }\n let code = source;\n // From the end, so the offsets stay right.\n for (const [offset, remove, text] of edits.toSorted((a, b) => b[0] - a[0])) {\n code = code.slice(0, offset) + text + code.slice(offset + remove);\n }\n return `${code}\\n${NAME_BRIDGE_IMPORT}\\n${lines.join('\\n')}\\n`;\n}\n","// 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 '$gate',\n '$optimistic',\n '$debounced',\n '$throttled',\n '$effect',\n '$client',\n '$untrack',\n '$produce',\n '$isPending',\n '$resolve',\n '$isBound',\n '$isPassed',\n '$setContext',\n '$getContext',\n '$store',\n '$toStore',\n '$route',\n '$searchParam',\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 isSignalsImport(statement: oxc.Node): boolean {\n return statement.type === 'ImportDeclaration' && statement.source.value === SIGNALS_MODULE;\n}\n\n/**\n * True for an import of `brumate/signals` that holds compile-time functions only, which the\n * compiler removes. One that also imports a function of the runtime, such as `flush`, stays.\n */\nexport function isMacroImport(statement: oxc.Node): boolean {\n if (!isSignalsImport(statement)) {\n return false;\n }\n for (const specifier of (statement as oxc.ImportDeclaration).specifiers) {\n if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type') {\n continue;\n }\n const name =\n specifier.imported.type === 'Identifier' ? specifier.imported.name : specifier.imported.value;\n if (!MACROS.has(name) && !RENAMED_MACROS.has(name)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The source of an import for the output. An import of `brumate/signals` that also names `flush`\n * keeps `flush` only, since the compile-time functions are gone.\n */\nexport function importSource(source: string, statement: oxc.ImportDeclaration): string {\n const text = source.slice(statement.start, statement.end);\n if (!isSignalsImport(statement)) {\n return text;\n }\n const named: string[] = [];\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type') {\n continue;\n }\n const imported =\n specifier.imported.type === 'Identifier' ? specifier.imported.name : specifier.imported.value;\n if (!MACROS.has(imported) && !RENAMED_MACROS.has(imported)) {\n named.push(\n imported === specifier.local.name ? imported : `${imported} as ${specifier.local.name}`,\n );\n }\n }\n return `import { ${named.join(', ')} } from '${SIGNALS_MODULE}';`;\n}\n\n/** Calls every AST node inside a value of the file, such as a script or an expression. */\nexport function walk(\n value: unknown,\n visit: (node: oxc.Node) => void,\n seen: Set<object> = new Set(),\n): 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 (!isSignalsImport(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 let renamedAny = false;\n for (const [local, imported] of aliases) {\n if (local !== imported) {\n renamedAny = true;\n break;\n }\n }\n if (renamedAny) {\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 const diagnostics: Diagnostic[] = [];\n for (const [name, range] of missing) {\n const renamed = RENAMED_MACROS.get(name);\n diagnostics.push({\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 return diagnostics;\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 /** True for a prop whose `$props<T>` type is written as `Promise<...>`, or a union with one. */\n promise?: boolean;\n /** True for the props object (`const props = $props()`) and the rest of `$props()`. */\n whole?: boolean;\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 an import that a component passes as a prop, true when it can be a function, so the\n * prop passes it as a reference that the browser can call. See `mayExportFunction`.\n */\n callable?: boolean;\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 `$gate(value, guard)`, the site of the guard function. */\n gate?: Site;\n /** For `let name = $searchParam(name, options)`, the call. */\n searchParam?: oxc.CallExpression;\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 /**\n * The props of components that the binding passes the declaration to, and `value` or `checked`\n * of an input. A signal that only `ref` binds holds an element that the browser fills.\n */\n boundAs?: Set<string>;\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 /** For `const name = $isPassed(prop)`, the key of the prop. */\n passedKey?: string;\n /** For `const field = $getContext(Context)`, the context. */\n contextSource?: oxc.Node;\n /** For `const field = $getContext(Context, fallback)`, the value without a provider. */\n contextFallback?: oxc.Node;\n /**\n * For `const state = field ? $store(field.key) : undefined`, the name `field` in the test. The\n * variable is `undefined` when `field` is.\n */\n guard?: oxc.Node;\n /**\n * For `const name = $store(source)` and `let name = $store(source)`: the code that gives the\n * store or its context, the site of the argument, the key of the value of `$getContext` that\n * holds the store, the index of the source that the browser runs again to find the store (see\n * `SemanticModel.storeSources`), and whether `let` writes it.\n */\n store?: {\n source: oxc.Node;\n site: Site;\n path?: string;\n link?: number;\n write: boolean;\n /**\n * For a source that reads its store from a value that the page sends, such as a prop, what\n * that value is, as `the prop \"s\"`. The server refuses a store of another library there.\n */\n sent?: string;\n /**\n * True for `$store($getContext(Context, fallback))`, whose source is the context. The site is\n * then the fallback's, when there is one, which the browser runs again without a provider.\n */\n read?: boolean;\n /** The fallback of `$store($getContext(Context, fallback))`. */\n fallback?: oxc.Node;\n };\n /** Elements whose `ref` targets this declaration. */\n refs: { attribute: RefAttribute; element: ElementNode | DynamicTagNode; 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 /** True when the site calls through a context value or a prop, outside `$untrack`. */\n opaqueCalls?: boolean;\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 /** True for the handler prop of a component, such as `onPick=(…)`, which the child calls. */\n handlerProp?: boolean;\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 /** For the value of `$toStore(value)` in `$setContext`, the call: its update writes the store. */\n store?: oxc.CallExpression;\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 * The sources of `$store` that are not a context or a key of a `$getContext` value. The update\n * part exports them as functions of the scope, `z`, and the browser runs one on resume to find\n * the store again.\n */\n storeSources: Site[];\n /** The `$isPending(memo)` and `$resolve(memo)` calls, with the read of their memo. */\n pendingCalls: { reference: Reference; at: Range }[];\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 function 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 { BRIDGE_EXPORT, findBridgeCalls } from './bridges.ts';\nimport { checkNesting } from './nesting.ts';\nimport {\n MACROS,\n SIGNALS_MODULE,\n checkMacroImports,\n isMacroImport,\n resolveMacros,\n} from './macros.ts';\nimport type {\n Attribute,\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 { isWithin, 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, isFallbackLiteral } 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 GATE_FORM =\n '$gate takes a value and a function, as in $gate(value, (prev, next) => next > prev)';\nconst GATE_ASYNC =\n '$gate takes a value that is ready. Use $memo for a promise or a server function';\n\n/** The messages of BRM191 to BRM193, BRM195 and BRM197 to BRM199. */\nconst STORE_FORM =\n 'Read a store with \"const name = $store(source)\" or \"let name = $store(source)\" at the top level of a script';\nconst STORE_ARGUMENT = '$store takes one argument, a store';\nconst TO_STORE_ARGUMENT =\n '$toStore takes one argument, a memo, a signal or a prop, as a value of $setContext';\nconst STORE_SOURCE =\n 'The source of $store gives its store at once, so it cannot await or call a server function';\nconst STORE_PATTERN = '$store gives one name, not a pattern such as { a }';\n/** The kinds of names whose values the page sends when browser code reads them. */\nconst SENT_KINDS = new Set<DeclarationKind>([\n 'prop',\n 'props-rest',\n 'const',\n 'let',\n 'signal',\n 'memo',\n 'async-memo',\n 'context',\n 'item',\n 'index',\n]);\n\n/**\n * The name whose value holds the store of a `$store` source, such as `s` of `s`, `s.state` or\n * `s?.state`, when the page sends that value. A call makes its value in the browser.\n */\nfunction findSentRoot(source: oxc.Node, scope: Scope): Declaration | undefined {\n let node = source;\n for (;;) {\n if (node.type === 'ChainExpression') {\n node = node.expression as oxc.Node;\n } else if (node.type === 'MemberExpression') {\n node = node.object as oxc.Node;\n } else {\n break;\n }\n }\n if (node.type !== 'Identifier') {\n return undefined;\n }\n const found = lookup(scope, node.name);\n return found && SENT_KINDS.has(found.kind) ? found : undefined;\n}\nconst OPTIONAL_FORM =\n 'Read a context that may have no provider with \"const name = $getContext(Context, undefined)\", and a store in it with \"const state = name ? $store(name.key) : undefined\", with const and no other test';\nconst STORE_ONLY =\n '$store takes a store. Read the store of a context with \"$store($getContext(Context))\", or give a store as the fallback, \"$store($getContext(Context, store(value)))\"';\nconst GET_CONTEXT_ARGUMENTS =\n '$getContext takes the context, and a fallback for a read without a provider';\n\n/** True for `undefined` or `null`, which give no store. */\nfunction isNullish(node: oxc.Node): boolean {\n return (\n (node.type === 'Identifier' && node.name === 'undefined') ||\n (node.type === 'Literal' && node.value === null && !('regex' in node && node.regex))\n );\n}\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 $isPassed:\n 'Check a prop with \"const name = $isPassed(prop)\" at the top level of the component script',\n $getContext:\n 'Read a context with \"const name = $getContext(Context)\" at the top level of a script',\n $store: STORE_FORM,\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 $gate:\n 'Declare a gated value with \"const name = $gate(value, (prev, next) => boolean)\" 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=$bind(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 $get: '$get is not supported. Signals cannot leave the file',\n $set: '$set is not supported. Signals cannot leave the file',\n $hasContext: OPTIONAL_FORM,\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.\n/** The sites whose code can wait for a memo with `$resolve`. */\nconst RESOLVING_SITES = new Set<SiteKind>(['function', 'event', 'effect', 'client']);\n\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 return memberNames(type, file, isBindableType);\n}\n\n/** True for `Bindable<...>`. */\nfunction isBindableType(annotation: oxc.Node | undefined): boolean {\n return (\n annotation?.type === 'TSTypeReference' &&\n annotation.typeName.type === 'Identifier' &&\n annotation.typeName.name === 'Bindable'\n );\n}\n\n/**\n * True for an expression that the compiler sees gives a promise: `new Promise(…)`, a call of a\n * method of `Promise` or of `fetch`, a call of a server function or of an async function of the\n * file, and a prop typed as a promise.\n */\nfunction givesPromise(node: oxc.Node, scope: Scope): boolean {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n return givesPromise(node.expression, scope);\n case 'NewExpression':\n return node.callee.type === 'Identifier' && node.callee.name === 'Promise';\n case 'Identifier':\n return lookup(scope, node.name)?.promise === true;\n case 'CallExpression': {\n const callee = node.callee;\n if (callee.type === 'MemberExpression') {\n return callee.object.type === 'Identifier' && callee.object.name === 'Promise';\n }\n if (callee.type !== 'Identifier') {\n return false;\n }\n if (callee.name === 'fetch') {\n return true;\n }\n const declaration = lookup(scope, callee.name);\n return (\n declaration?.kind === 'server-function' ||\n declaration?.serverImport !== undefined ||\n (declaration?.kind === 'function' &&\n (declaration.site?.node as { async?: boolean } | undefined)?.async === true)\n );\n }\n default:\n return false;\n }\n}\n\n/** The message of BRM188, for `code` at `place`. */\nfunction promiseMessage(code: string, place: string): string {\n return `\"${code}\" gives a promise, and ${place} cannot wait for one. Await it in the code that runs, or read its value with $memo`;\n}\n\n/** True for `Promise<...>`, or a union that holds one. */\nfunction isPromiseType(annotation: oxc.Node | undefined): boolean {\n if (annotation?.type === 'TSUnionType') {\n for (const type of annotation.types) {\n if (isPromiseType(type)) {\n return true;\n }\n }\n return false;\n }\n if (annotation?.type === 'TSParenthesizedType') {\n return isPromiseType(annotation.typeAnnotation);\n }\n return (\n annotation?.type === 'TSTypeReference' &&\n annotation.typeName.type === 'Identifier' &&\n annotation.typeName.name === 'Promise'\n );\n}\n\n/** The names of the members of a props type whose type passes `test`. */\nfunction memberNames(\n type: oxc.Node,\n file: SFCFile,\n test: (annotation: oxc.Node | undefined) => boolean,\n): 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: oxc.Node[] = [];\n for (const statement of [\n ...(file.moduleScript?.program.body ?? []),\n ...(file.instanceScript?.program.body ?? []),\n ]) {\n statements.push(\n statement.type === 'ExportNamedDeclaration' && statement.declaration\n ? statement.declaration\n : statement,\n );\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 memberNames(statement.typeAnnotation, file, test);\n }\n }\n }\n const names: string[] = [];\n for (const member of members ?? []) {\n const annotation =\n member.type === 'TSPropertySignature' ? member.typeAnnotation?.typeAnnotation : undefined;\n if (!test(annotation) || member.type !== 'TSPropertySignature' || member.computed) {\n continue;\n }\n if (member.key.type === 'Identifier') {\n names.push(member.key.name);\n } else if (member.key.type === 'Literal') {\n names.push(String(member.key.value));\n }\n }\n return names;\n}\n\n/**\n * The value, or the values of the keys of an object and the items of a list, also inside\n * each other, such as `{ slots: { increment: { onPress } } }` or `{ items: [{ run }] }`.\n */\nfunction readProvidedValues(value: oxc.Node): oxc.Node[] {\n const values: oxc.Node[] = [];\n if (value.type === 'ObjectExpression') {\n for (const property of value.properties) {\n if (property.type === 'Property' && !property.computed) {\n values.push(...readProvidedValues(property.value));\n }\n }\n return values;\n }\n if (value.type === 'ArrayExpression') {\n for (const element of value.elements) {\n if (element && element.type !== 'SpreadElement') {\n values.push(...readProvidedValues(element));\n }\n }\n return values;\n }\n return [value];\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 /** The declarations of `$store`, which `resolveStores` completes. */\n private readonly storeReaders: Declaration[] = [];\n /** The names that the file passes to `$getContext` or `$setContext` as the context. */\n private readonly contextNames = new Set<string>();\n /** The sources of `$store` that the browser runs again. See `SemanticModel.storeSources`. */\n private readonly storeSources: Site[] = [];\n /** The `$toStore` calls that a `$setContext` value holds. */\n readonly storeCalls = new Set<oxc.Node>();\n private readonly diagnostics: Diagnostic[] = [];\n private readonly refs: {\n attribute: RefAttribute;\n element: ElementNode | DynamicTagNode;\n scope: Scope;\n }[] = [];\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 // A bridge belongs to a module-level export, of a script file or of `<script module>`.\n for (const { call, exported, statement } of this.file.moduleScript\n ? findBridgeCalls(this.file.moduleScript.program)\n : []) {\n // `export default` in `<script module>` has its own error.\n if (exported === undefined && !statement) {\n this.report('error', BRIDGE_EXPORT, call);\n }\n }\n for (const { call } of this.file.instanceScript\n ? findBridgeCalls(this.file.instanceScript.program)\n : []) {\n this.report('error', BRIDGE_EXPORT, call);\n }\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 checkNesting(this.file, (message, at) => this.report('error', message, at));\n this.addProvidedFunctions();\n this.resolveStores();\n this.checkBindableProps();\n this.markPromiseProps();\n\n for (const site of this.sites) {\n new Resolver(this, site).run();\n }\n this.addPendingReads();\n this.addSearchParamReads();\n this.checkLoadingHeaders();\n this.resolveRefs();\n this.check();\n this.checkPromises();\n this.checkStoreSources();\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 storeSources: this.storeSources,\n diagnostics: this.diagnostics,\n pendingCalls: this.pendingCalls,\n };\n }\n\n /**\n * Finds where the browser gets the store of each `$store`. A context, or a key of the value of\n * `$getContext`, is found again from its provider. Any other source, and the fallback of\n * `$store($getContext(Context, fallback))`, is code that the browser runs again on resume, from\n * the exports `z` of the update part.\n */\n private resolveStores(): void {\n for (const declaration of this.storeReaders) {\n const store = declaration.store!;\n const guard = declaration.guard;\n\n // `$store($getContext(Context, fallback))`: the server records the key with a provider, and\n // the index of the fallback without one.\n if (store.read) {\n if (guard) {\n this.report('error', OPTIONAL_FORM, guard);\n continue;\n }\n if (store.fallback) {\n store.link = this.storeSources.push(store.site) - 1;\n }\n continue;\n }\n\n // `g.key` for a value `g` of `$getContext`: the context, and the key of its value.\n let argument = store.source;\n let path: string | undefined;\n if (\n argument.type === 'MemberExpression' &&\n !argument.computed &&\n argument.object.type === 'Identifier' &&\n argument.property.type === 'Identifier'\n ) {\n path = argument.property.name;\n argument = argument.object;\n }\n const root =\n argument.type === 'Identifier' ? lookup(declaration.scope, argument.name) : undefined;\n if (root?.kind === 'context' && root.contextSource) {\n // A value with a fallback is read only in the guard form, with the fallback `undefined`,\n // since a guarded store re-reads the provider. A guard needs a value that may be missing.\n const optional = root.contextFallback !== undefined;\n const guarded =\n guard?.type === 'Identifier' && lookup(declaration.scope, guard.name) === root;\n if (\n optional !== (guard !== undefined) ||\n (guard && (!guarded || store.write)) ||\n (optional && !isNullish(root.contextFallback!))\n ) {\n this.report('error', OPTIONAL_FORM, guard ?? store.source);\n continue;\n }\n store.source = root.contextSource;\n store.path = path;\n continue;\n }\n if (guard) {\n this.report('error', OPTIONAL_FORM, guard);\n continue;\n }\n\n // A context is no store. The file names its contexts in `$getContext` and `$setContext`.\n if (store.source.type === 'Identifier' && this.contextNames.has(store.source.name)) {\n this.report('error', STORE_ONLY, store.source);\n continue;\n }\n\n // Code that gives the store, which the browser runs again with the resumed values.\n store.link = this.storeSources.push(store.site) - 1;\n const held = findSentRoot(store.source, declaration.scope);\n if (held) {\n const prop = held.kind === 'prop' || held.kind === 'props-rest';\n store.sent = `${prop ? 'the prop' : 'the value'} \"${held.name}\"`;\n }\n }\n }\n\n /** A source of `$store` that the browser runs again must give its store at once. */\n private checkStoreSources(): void {\n for (const site of this.storeSources) {\n let server = site.awaits;\n for (const callee of site.calls) {\n if (callee.kind === 'server-function') {\n server = true;\n }\n }\n for (const read of site.reads) {\n if (read.declaration.serverImport !== undefined) {\n server = true;\n }\n }\n if (server) {\n this.report('error', STORE_SOURCE, site.node);\n }\n }\n }\n\n /**\n * The effect of a `$searchParam` reads its signal, so it runs again when the signal changes.\n * The range is empty, so no identifier starts there.\n */\n private addSearchParamReads(): void {\n for (const declaration of this.declarations) {\n if (!declaration.searchParam) {\n continue;\n }\n for (const site of this.sites) {\n if (site.node === declaration.searchParam && site.kind === 'effect') {\n const at = { start: site.node.end, end: site.node.end };\n const read: Reference = {\n range: at,\n declaration,\n site,\n tracked: true,\n inFunction: false,\n };\n declaration.reads.push(read);\n site.reads.push(read);\n }\n }\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 * The header of `#loading (posts) { … }` names memos that markup in the body reads. The block\n * shows its fallback again while one of them, or a memo upstream of it, loads, so the header\n * reads those memos too, as `$isPending(memo)` does.\n */\n private checkLoadingHeaders(): void {\n for (const site of this.sites) {\n const block = site.block;\n if (site.kind !== 'block' || block?.kind !== 'loading' || !block.on) {\n continue;\n }\n let body: Scope | undefined;\n for (const scope of this.scopes) {\n if (scope.block === block && scope.body === block.body) {\n body = scope;\n }\n }\n // `#loading (user, posts)` names two memos.\n const ast = unwrapTypes(block.on.ast);\n const names: oxc.Node[] = ast.type === 'SequenceExpression' ? ast.expressions : [ast];\n const reads = [...site.reads];\n for (const name of names) {\n const node = unwrapTypes(name);\n let read: Reference | undefined;\n for (const item of reads) {\n if (node.type === 'Identifier' && item.range.start === node.start) {\n read = item;\n }\n }\n const declaration = read?.declaration;\n if (\n !declaration ||\n (declaration.kind !== 'memo' && declaration.kind !== 'async-memo') ||\n !body ||\n !this.markupReads(declaration, body)\n ) {\n this.report(\n 'error',\n `\"${this.file.source.slice(name.start, name.end)}\" in the #loading header is not a memo that markup in the body reads. Name a $memo of the component or of a block script around the block`,\n name,\n );\n continue;\n }\n const upstream = upstreamMemos(declaration);\n for (const item of [declaration, ...upstream]) {\n if (item.timing) {\n this.report(\n 'warning',\n `#loading (${declaration.name}) shows its fallback while the $${item.timing.kind} memo \"${item.name}\" waits, at each change of its value`,\n name,\n );\n break;\n }\n }\n for (const item of upstream) {\n // An empty range after the name, which no identifier starts at.\n const added: Reference = {\n ...read!,\n declaration: item,\n range: { start: name.end, end: name.end },\n };\n item.reads.push(added);\n site.reads.push(added);\n }\n }\n }\n }\n\n /** True when markup or a memo inside `body` reads `declaration`, so it renders from it. */\n private markupReads(declaration: Declaration, body: Scope): boolean {\n for (const read of declaration.reads) {\n const kind = read.site.kind;\n if (\n read.range.start !== read.range.end &&\n kind !== 'function' &&\n kind !== 'server-function' &&\n kind !== 'event' &&\n kind !== 'effect' &&\n kind !== 'client' &&\n isWithin(read.site.scope, body)\n ) {\n return true;\n }\n }\n return false;\n }\n\n /** Marks the props that the type of `$props<T>()` writes as `Promise<...>`. */\n private markPromiseProps(): void {\n const names = new Set<string>();\n for (const type of this.propsTypes) {\n for (const name of memberNames(type, this.file, isPromiseType)) {\n names.add(name);\n }\n }\n for (const declaration of this.declarations) {\n if (\n declaration.kind === 'prop' &&\n declaration.scope === this.component &&\n declaration.propKey !== undefined &&\n names.has(declaration.propKey)\n ) {\n declaration.promise = true;\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 isBindableProp(propKey: string): boolean {\n for (const type of this.propsTypes) {\n if (bindableNames(type, this.file).includes(propKey)) {\n return true;\n }\n }\n return false;\n }\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: Declaration[] = [];\n const written = new Set<string>();\n for (const declaration of this.declarations) {\n if (\n declaration.kind === 'prop' &&\n declaration.scope === this.component &&\n declaration.propKey !== undefined &&\n bindable.has(declaration.propKey)\n ) {\n props.push(declaration);\n if (declaration.writable) {\n written.add(declaration.propKey);\n }\n }\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.\n */\n private readWrappers(site: Site, attribute: EventAttribute, scope: Scope): void {\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: (string | undefined)[] = [];\n for (const key of rest) {\n keys.push(\n key.type === 'Literal' && typeof key.value === 'string' ? key.value : undefined,\n );\n }\n let wrong: oxc.Node | undefined;\n for (const [index, item] of rest.entries()) {\n const key = keys[index];\n // A key can name a modifier that must be held, such as `Mod+ArrowDown`.\n const base = key?.replace(/^(?:Mod|Ctrl|Meta|Alt)\\+/, '');\n if (base === undefined || !(KEY_NAMES.includes(base) || /^[A-Za-z0-9]$/.test(base))) {\n wrong = item;\n break;\n }\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', with a modifier to hold if it needs one, such as 'Mod+ArrowDown'\",\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 // An import of `brumate/signals` that also takes `flush` stays, without its compile-time functions.\n if (\n specifier.type === 'ImportSpecifier' &&\n statement.source.value === SIGNALS_MODULE &&\n MACROS.has(\n specifier.imported.type === 'Identifier'\n ? specifier.imported.name\n : specifier.imported.value,\n )\n ) {\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 let init = awaitedName === '$memo' ? awaited!.argument : declarator.init;\n // `name ? $store(name.key) : undefined` reads a store only when the optional value `name` of\n // `$getContext(Context, undefined)` is there. `resolveStores` checks what `name` is.\n let guard: oxc.Node | undefined;\n if (init?.type === 'ConditionalExpression' && calleeName(init.consequent) === '$store') {\n if (\n kind !== 'const' ||\n id.type !== 'Identifier' ||\n init.test.type !== 'Identifier' ||\n init.alternate.type !== 'Identifier' ||\n init.alternate.name !== 'undefined'\n ) {\n this.report('error', OPTIONAL_FORM, declarator);\n return;\n }\n guard = init.test;\n init = init.consequent;\n }\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).whole = true;\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).whole = true;\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 let idCount = 0;\n for (const item of scope.declarations.values()) {\n if (item.idIndex !== undefined) {\n idCount++;\n }\n }\n declaration.idIndex = idCount;\n return;\n }\n\n if (name === '$isPassed') {\n if (kind !== 'const' || id.type !== 'Identifier' || !isComponent) {\n this.report('error', MISPLACED[name]!, declarator);\n return;\n }\n const [target] = call.arguments;\n const prop = target?.type === 'Identifier' ? scope.declarations.get(target.name) : undefined;\n if (call.arguments.length !== 1 || prop?.kind !== 'prop' || prop.propKey === undefined) {\n this.report(\n 'error',\n '$isPassed takes a prop that the component destructures, such as $isPassed(value)',\n call,\n );\n return;\n }\n // The caller's attributes decide it, so it never changes and depends on nothing.\n const declaration = this.addDeclaration(scope, id.name, 'const', id);\n declaration.passedKey = prop.propKey;\n return;\n }\n\n if (name === '$searchParam') {\n const expected = '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 const [first, options] = call.arguments;\n if (\n first?.type !== 'Literal' ||\n typeof first.value !== 'string' ||\n call.arguments.length > 2 ||\n (options && options.type !== 'ObjectExpression')\n ) {\n this.report('error', `${name} needs a value`, call);\n return;\n }\n // Two signals of one parameter in one component could disagree.\n for (const other of this.declarations) {\n const [earlier] = other.searchParam?.arguments ?? [];\n if (other.scope === scope && earlier?.type === 'Literal' && earlier.value === first.value) {\n this.report('error', `\"${id.name}\" is already declared`, id);\n return;\n }\n }\n // A signal whose value the server reads from the URL. An effect writes the URL when it\n // changes, and the browser writes it back when the history moves.\n const declaration = this.addDeclaration(scope, id.name, 'signal', id);\n declaration.searchParam = call;\n this.createSite('effect', scope, call, 'search param');\n // The first run, when the page loads, follows the history before any write.\n this.createSite('client', scope, call, 'search param', { trigger: 'load' });\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 === '$store') {\n if (kind !== 'const' && kind !== 'let') {\n this.report('error', STORE_FORM, declarator);\n return;\n }\n if (id.type !== 'Identifier') {\n this.report('error', STORE_PATTERN, id);\n return;\n }\n const argument = call.arguments[0];\n if (!argument || call.arguments.length !== 1 || argument.type === 'SpreadElement') {\n this.report('error', STORE_ARGUMENT, call);\n return;\n }\n // `undefined` and `null` give no store. `?.` gives `undefined` when its value is missing,\n // which the guard on the value says instead.\n if (isNullish(argument)) {\n this.report('error', STORE_ONLY, argument);\n return;\n }\n if (argument.type === 'ChainExpression') {\n this.report('error', OPTIONAL_FORM, argument);\n return;\n }\n // The slot holds the value of the store, which the store's sends write. `let` writes the\n // store back: a write of the variable calls the `set` of the store.\n const declaration = this.addDeclaration(scope, id.name, 'context', id);\n declaration.guard = guard;\n if (calleeName(argument) === '$getContext') {\n // `$store($getContext(Context, fallback))`: the store of the provider, found again by the\n // key of the context, or the store that the fallback makes when no provider is above.\n const read = argument as oxc.CallExpression;\n const [context, fallback] = read.arguments;\n if (\n !context ||\n read.arguments.length > 2 ||\n context.type === 'SpreadElement' ||\n fallback?.type === 'SpreadElement'\n ) {\n this.report('error', GET_CONTEXT_ARGUMENTS, read);\n return;\n }\n if (fallback && isFallbackLiteral(fallback)) {\n this.report('error', STORE_ONLY, fallback);\n return;\n }\n if (context.type === 'Identifier') {\n this.contextNames.add(context.name);\n }\n const site = this.createSite('setup', scope, context, `store ${id.name}`);\n declaration.store = { source: context, site, write: kind === 'let', read: true, fallback };\n if (fallback) {\n declaration.store.site = this.createSite('setup', scope, fallback, `fallback ${id.name}`);\n }\n } else {\n const site = this.createSite('setup', scope, argument, `store ${id.name}`);\n declaration.store = { source: argument, site, write: kind === 'let' };\n }\n this.storeReaders.push(declaration);\n if (guard) {\n this.createSite('setup', scope, guard, `guard ${id.name}`);\n }\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 const [argument, fallback] = call.arguments;\n if (\n call.arguments.length < 1 ||\n call.arguments.length > 2 ||\n argument?.type === 'SpreadElement' ||\n fallback?.type === 'SpreadElement'\n ) {\n this.report('error', GET_CONTEXT_ARGUMENTS, call);\n }\n const declaration = this.addDeclaration(scope, id.name, 'context', id);\n if (argument && argument.type !== 'SpreadElement') {\n declaration.contextSource = argument;\n if (argument.type === 'Identifier') {\n this.contextNames.add(argument.name);\n }\n this.createSite('setup', scope, argument, `context ${id.name}`);\n }\n // A fallback that is not a literal is code, which runs only when no provider is above.\n if (fallback && fallback.type !== 'SpreadElement') {\n declaration.contextFallback = fallback;\n if (!isFallbackLiteral(fallback)) {\n this.createSite('setup', scope, fallback, `fallback ${id.name}`);\n }\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 === '$gate') {\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, guardFunction] = call.arguments;\n const declaration = this.addDeclaration(scope, id.name, 'memo', id);\n if (\n !argument ||\n argument.type === 'SpreadElement' ||\n call.arguments.length !== 2 ||\n !guardFunction ||\n (guardFunction.type !== 'ArrowFunctionExpression' &&\n guardFunction.type !== 'FunctionExpression')\n ) {\n this.report('error', GATE_FORM, call);\n return;\n }\n declaration.site = this.createSite('memo', scope, argument, `memo ${id.name}`, {\n declaration,\n });\n // The guard runs only in the browser, on a change, and does not track what it reads.\n declaration.gate = this.createSite('function', scope, guardFunction, `gate ${id.name}`);\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 or an item of a list, such as\n * `toggle` in `$setContext(Theme, { theme, toggle })`, at any depth.\n */\n private addProvidedFunctions(): void {\n for (const site of this.sites) {\n if (site.kind !== 'provide' || site.store) {\n continue;\n }\n for (const part of readProvidedValues(site.node)) {\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 for (const argument of call.arguments.slice(1)) {\n if (argument.type === 'SpreadElement') {\n this.report('error', 'The arguments of $handler cannot be spread', call);\n break;\n }\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: (string | undefined)[] = [];\n let unnamed = false;\n for (const key of keys) {\n const keyName =\n key.type === 'Literal' && typeof key.value === 'string' ? key.value : undefined;\n if (keyName === undefined) {\n unnamed = true;\n }\n names.push(keyName);\n }\n if (unnamed) {\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 if (context.type === 'Identifier') {\n this.contextNames.add(context.name);\n }\n this.createSite('provide', scope, value, 'provide', { extra: [context] });\n // Each `$toStore(value)` is a site of its own, whose update writes the store. The provided\n // value does not read it, so a context whose live values are all stores is static.\n for (const part of readProvidedValues(value)) {\n if (\n part.type === 'CallExpression' &&\n part.callee.type === 'Identifier' &&\n part.callee.name === '$toStore'\n ) {\n const argument = part.arguments[0];\n if (!argument || part.arguments.length !== 1 || argument.type === 'SpreadElement') {\n this.report('error', TO_STORE_ARGUMENT, part);\n continue;\n }\n this.storeCalls.add(part);\n this.createSite('provide', scope, argument, 'store', { extra: [context], store: part });\n // The `set` of a store of a signal writes the signal, as a binding does.\n const declaration =\n argument.type === 'Identifier' ? lookup(scope, argument.name) : undefined;\n if (declaration?.kind === 'signal') {\n declaration.bound = true;\n }\n }\n }\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 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 {\n owner: node,\n event: isComponent ? undefined : attribute,\n handlerProp: isComponent,\n },\n );\n if (!isComponent) {\n this.readWrappers(site, attribute, scope);\n }\n break;\n }\n case 'ref':\n // A dynamic tag gets its element too, when its tag names an element.\n if (node.kind === 'element' || node.kind === 'dynamic') {\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.window) {\n this.header(block, scope, block.window.height, 'for window');\n if (block.window.count) {\n this.header(block, scope, block.window.count, 'for window');\n }\n }\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 (\n declaration.kind !== 'signal' &&\n !(declaration.kind === 'prop' && declaration.writable)\n ) {\n this.report(\n 'error',\n `ref takes a $signal, or a prop that the component destructures with let, but \"${declaration.name}\" is ${declaration.kind === 'prop' ? 'a prop read with const' : `a ${declaration.kind}`}`,\n ref.attribute,\n );\n } else if (\n declaration.kind === 'prop' &&\n this.propsTypes.length > 0 &&\n declaration.propKey !== undefined &&\n !this.isBindableProp(declaration.propKey)\n ) {\n this.report(\n 'error',\n `The prop \"${declaration.propKey}\" is not Bindable. Type it as Bindable<HTMLElement>, so a parent can bind it`,\n ref.attribute,\n );\n } else {\n declaration.refs.push(ref);\n }\n }\n }\n\n /**\n * Reports a promise where markup cannot wait for it: an event handler, the key of a `#for`, and\n * the name that `ref` or `$bind` binds. Markup waits for a promise in text and attributes only.\n */\n private checkPromises(): void {\n for (const site of this.sites) {\n let place: string | undefined;\n if (site.kind === 'event' || site.handlerProp) {\n place = 'an event handler';\n } else if (site.kind === 'block' && site.label === 'for key') {\n place = 'the key of a #for';\n }\n if (place && givesPromise(site.node, site.scope)) {\n this.report(\n 'error',\n promiseMessage(this.file.source.slice(site.node.start, site.node.end), place),\n site.range,\n );\n }\n }\n for (const binding of this.bindings) {\n if (binding.declaration.promise) {\n this.report('error', promiseMessage(binding.declaration.name, 'a binding'), binding.call);\n }\n }\n for (const declaration of this.declarations) {\n if (declaration.promise) {\n for (const ref of declaration.refs) {\n this.report('error', promiseMessage(declaration.name, 'a ref'), ref.attribute);\n }\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 && !declaration.store?.write) {\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 || declaration.store?.write) &&\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 let callsServer = false;\n for (const declaration of site.calls) {\n if (declaration.kind === 'server-function') {\n callsServer = true;\n break;\n }\n }\n // A function imported from a `'use server'` module is a server function too.\n let importsServer = false;\n for (const read of site.reads) {\n if (read.declaration.serverImport !== undefined) {\n importsServer = true;\n break;\n }\n }\n if (callsServer || importsServer || site.awaits) {\n site.declaration.kind = 'async-memo';\n if (site.declaration.gate) {\n this.report('error', GATE_ASYNC, site.node);\n }\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 let source: Declaration | undefined;\n for (const read of site.reads) {\n if (read.range.start === site.range.start) {\n source = read.declaration;\n break;\n }\n }\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 for (const scope of this.locals) {\n if (scope.has(name)) {\n return true;\n }\n }\n return false;\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 let element: Attribute | undefined;\n if (this.site.kind === 'attribute' && owner?.kind === 'element') {\n for (const attribute of owner.attributes) {\n if (attribute.kind === 'value' && attribute.value.ast === this.site.node) {\n element = attribute;\n break;\n }\n }\n }\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 let attribute: Attribute | undefined;\n for (const candidate of owner?.attributes ?? []) {\n if (candidate.kind === 'value' && candidate.value.ast === this.site.node) {\n attribute = candidate;\n break;\n }\n }\n if (attribute?.kind === 'value') {\n (declaration.boundAs ??= new Set()).add(attribute.name);\n }\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 const reference = this.reference(node, 'read');\n // A spread in markup is the only use of the whole object, so a ref in it reaches the element.\n if (\n reference?.declaration.whole &&\n !(this.site.kind === 'spread' && spreadsWhole(this.site.node, node))\n ) {\n this.analyzer.report(\n 'error',\n `\"${node.name}\" is the props object, so read one key at a time, destructure it, or spread it in markup`,\n node,\n );\n }\n return;\n }\n case 'ReturnStatement':\n // The cleanup that an effect returns runs later, so what it reads is not what the effect\n // depends on, as in Svelte and Solid.\n if (\n node.argument &&\n isFunction(node.argument) &&\n this.functionDepth === 0 &&\n (this.site.kind === 'effect' || this.site.kind === 'client')\n ) {\n this.untracked++;\n this.visit(node.argument);\n this.untracked--;\n return;\n }\n this.visitChildren(node);\n return;\n case 'MemberExpression':\n // Reading a key of the props is the one use of the object besides a spread.\n if (unwrapTypes(node.object).type === 'Identifier') {\n this.reference(unwrapTypes(node.object) as oxc.Node & { name: string }, 'read');\n } else {\n this.visit(node.object);\n }\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: string[] = [];\n if (declaration?.type === 'VariableDeclaration') {\n for (const item of declaration.declarations) {\n names.push(...readPatternNames(item.id));\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 const consequents: oxc.Node[] = [];\n for (const item of node.cases) {\n consequents.push(...item.consequent);\n }\n this.withLocals(lexicalNames(consequents), () => {\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(node.param ? readPatternNames(node.param) : [], () => {\n if (node.param) {\n this.visitDefaults(node.param);\n }\n this.visit(node.body);\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 'UnaryExpression':\n if (node.operator === 'delete') {\n this.checkPropsWrite(node.argument);\n }\n this.visitChildren(node);\n return;\n case 'AssignmentExpression':\n this.checkPropsWrite(node.left);\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.checkPropsWrite(node.argument);\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 // A call through a context value or a prop runs code that the compiler cannot see.\n if (this.untracked === 0) {\n let root: oxc.Node = node.callee;\n while (\n root.type === 'MemberExpression' ||\n root.type === 'TSNonNullExpression' ||\n root.type === 'ChainExpression'\n ) {\n root = root.type === 'MemberExpression' ? root.object : root.expression;\n }\n if (root.type === 'Identifier' && !this.isLocal(root.name)) {\n const target = lookup(this.site.scope, root.name);\n if (\n target?.kind === 'context' ||\n target?.kind === 'prop' ||\n target?.kind === 'props-rest'\n ) {\n this.site.opaqueCalls = true;\n }\n }\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 === '$toStore' && !this.analyzer.storeCalls.has(node)) {\n this.analyzer.report('error', TO_STORE_ARGUMENT, node);\n }\n if (name === '$untrack' || name === '$toStore') {\n // The value of `$toStore` is read by a site of its own, which writes the store.\n this.untracked++;\n for (const argument of node.arguments) {\n this.visit(argument);\n }\n this.untracked--;\n return;\n }\n if (name === '$isBound') {\n const [target] = node.arguments;\n const declaration =\n target?.type === 'Identifier' && !this.isLocal(target.name)\n ? lookup(this.site.scope, target.name)\n : undefined;\n if (\n node.arguments.length !== 1 ||\n declaration?.kind !== 'prop' ||\n !declaration.writable\n ) {\n this.analyzer.report(\n 'error',\n '$isBound takes a prop that the component destructures with let, such as $isBound(open)',\n node,\n );\n }\n this.visitChildren(node);\n return;\n }\n if (name === '$resolve') {\n const [target] = node.arguments;\n if (target?.type !== 'Identifier' || node.arguments.length > 2) {\n this.analyzer.report(\n 'error',\n '$resolve needs a $memo and, as an option, a timeout or a signal',\n node,\n );\n }\n // It waits, so it runs in code that an event starts, not where a memo computes or\n // markup renders.\n if (\n !RESOLVING_SITES.has(this.site.kind) &&\n !(this.site.kind === 'prop' && isFunction(this.site.node))\n ) {\n this.analyzer.report(\n 'error',\n '$resolve cannot run where a memo computes or markup renders. Call it in a handler, an effect or a $client callback',\n node,\n );\n }\n this.visitChildren(node);\n let reference: Reference | undefined;\n for (const read of this.site.reads) {\n if (target?.type === 'Identifier' && read.range.start === target.start) {\n reference = read;\n break;\n }\n }\n if (target?.type === 'Identifier' && reference) {\n this.analyzer.pendingCalls.push({ reference, at: range(node) });\n if (\n reference.declaration.kind !== 'memo' &&\n reference.declaration.kind !== 'async-memo'\n ) {\n this.analyzer.report(\n 'error',\n '$resolve needs a $memo and, as an option, a timeout or a signal',\n node,\n );\n }\n }\n return;\n }\n if (name === '$isPending') {\n let valid = node.arguments.length > 0;\n for (const target of node.arguments) {\n if (target.type !== 'Identifier') {\n valid = false;\n }\n }\n if (!valid) {\n this.analyzer.report('error', '$isPending needs async $memos as its arguments', node);\n }\n this.visitChildren(node);\n // Each name is a read of its own, which the call pins.\n for (const target of node.arguments) {\n if (target.type !== 'Identifier') {\n continue;\n }\n for (const reference of this.site.reads) {\n if (reference.range.start === target.start) {\n this.analyzer.pendingCalls.push({ reference, at: range(node) });\n break;\n }\n }\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 === '$searchParam' && this.site.node === node) {\n // The effect of the declaration: only its arguments are code of the site.\n for (const argument of node.arguments) {\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: string[] = [];\n for (const param of fn.params) {\n names.push(...readPatternNames(param));\n }\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 /** Reports a write to a key of the props object or of the rest of `$props()`. */\n private checkPropsWrite(target: oxc.Node): void {\n const node = unwrapTypes(target);\n if (node.type !== 'MemberExpression') {\n return;\n }\n const object = unwrapTypes(node.object);\n if (object.type !== 'Identifier' || this.isLocal(object.name)) {\n return;\n }\n if (lookup(this.site.scope, object.name)?.whole) {\n this.analyzer.report(\n 'error',\n `\"${object.name}\" is the props object, and props are read-only. Copy the key to a $signal or a $memo to change it`,\n target,\n );\n }\n }\n\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 /** Visits the target of an assignment. */\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/** True for an object literal, `undefined`, `null` or `false`, the branch of a spread that adds nothing. */\nfunction isEmptySpread(node: oxc.Node): boolean {\n const branch = unwrapTypes(node);\n return (\n branch.type === 'ObjectExpression' ||\n (branch.type === 'Identifier' && branch.name === 'undefined') ||\n (branch.type === 'Literal' && (branch.value === null || branch.value === false))\n );\n}\n\n/** The branches of `?:`, `&&`, `||` and `??`, or none for another expression. */\nfunction spreadBranches(root: oxc.Node): oxc.Node[] {\n if (root.type === 'ConditionalExpression') {\n return [root.consequent, root.alternate];\n }\n if (root.type === 'LogicalExpression') {\n // The left of `&&` is the condition, so it is not a branch.\n return root.operator === '&&' ? [root.right] : [root.left, root.right];\n }\n return [];\n}\n\n/**\n * True when `identifier`, the props object or the rest, is what a markup spread spreads: the\n * expression itself, or a branch of `?:`, `&&`, `||` or `??` whose other branches add nothing\n * (see isEmptySpread) or are the same name.\n */\nfunction spreadsWhole(expression: oxc.Node, identifier: oxc.Node): boolean {\n const root = unwrapTypes(expression);\n if (root === identifier) {\n return true;\n }\n let found = false;\n for (const branch of spreadBranches(root)) {\n const node = unwrapTypes(branch);\n if (node === identifier) {\n found = true;\n } else if (\n !isEmptySpread(node) &&\n !(\n node.type === 'Identifier' &&\n identifier.type === 'Identifier' &&\n node.name === identifier.name\n )\n ) {\n return false;\n }\n }\n return found;\n}\n\n/**\n * The props object or the rest that a conditional markup spread holds as a branch, such as\n * `rest` in `open ? rest : {}`. Undefined for a spread with no condition.\n */\nexport function conditionalSpread(expression: oxc.Node): oxc.Node | undefined {\n for (const branch of spreadBranches(unwrapTypes(expression))) {\n const node = unwrapTypes(branch);\n if (node.type === 'Identifier' && node.name !== 'undefined') {\n return node;\n }\n }\n return undefined;\n}\n\n/** Strips parentheses and type casts: `(rest as T)` is `rest`. */\nfunction unwrapTypes(node: oxc.Node): oxc.Node {\n while (node.type === 'ParenthesizedExpression' || TYPE_WRAPPERS.has(node.type)) {\n node = (node as { expression: oxc.Node }).expression;\n }\n return node;\n}\n\n/** Returns the names that a binding pattern declares. */\nfunction readPatternNames(pattern: oxc.Node): string[] {\n const names: string[] = [];\n for (const name of getPatternNames(pattern)) {\n names.push(name.name);\n }\n return names;\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(...readPatternNames(declarator.id));\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(...readPatternNames(declarator.id));\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 function 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","import type { oxc } from './oxc.ts';\n\nexport interface Range {\n start: number;\n end: number;\n}\n\n/** Source text that oxc parses. */\nexport interface Expression extends Range {\n code: string;\n ast: oxc.Expression;\n}\n\nexport interface Script extends Range {\n program: oxc.Program;\n}\n\nexport interface Style extends Range {\n lang: 'css' | 'scss' | 'less';\n /** True for `<style global>`: its rules get no scope attribute. */\n global: boolean;\n /** The CSS between the tags, with `${…}` interpolations left in place. */\n content: string;\n /** The `${…}` interpolations, in source order. */\n variables: Expression[];\n}\n\nexport interface SFCFile {\n filename: string;\n source: string;\n moduleScript?: Script;\n instanceScript?: Script;\n generics?: string;\n styles: Style[];\n templates: TemplateDecl[];\n children: Markup[];\n}\n\nexport type Markup =\n | ElementNode\n | ComponentNode\n | DynamicTagNode\n | FragmentNode\n | GlobalListenerNode\n | TextNode\n | InsertNode\n | Block;\n\nexport interface ElementNode extends Range {\n kind: 'element';\n tag: string;\n attributes: Attribute[];\n children: Markup[];\n}\n\nexport interface ComponentNode extends Range {\n kind: 'component';\n name: string;\n attributes: Attribute[];\n children: Markup[];\n}\n\nexport interface DynamicTagNode extends Range {\n kind: 'dynamic';\n tag: Expression;\n attributes: Attribute[];\n children: Markup[];\n /**\n * True inside the `#key` block that the parser wraps it in. The block\n * renders it again when the tag changes, so the tag itself needs no update.\n */\n keyed?: boolean;\n}\n\nexport interface FragmentNode extends Range {\n kind: 'fragment';\n children: Markup[];\n /**\n * For `#reveal`: the order in which the server shows the `#loading` bodies\n * inside, and whether only the next fallback shows. Elsewhere the children\n * render as they are.\n */\n reveal?: Reveal;\n}\n\n/** The order of `#reveal`, as its header writes it. */\nexport type RevealOrder = 'sequential' | 'backwards' | 'together' | 'natural';\n\nexport interface Reveal {\n order: RevealOrder;\n collapsed: boolean;\n}\n\nexport interface GlobalListenerNode extends Range {\n kind: 'listener';\n target: 'window' | 'document';\n attributes: EventAttribute[];\n}\n\nexport interface TextNode extends Range {\n kind: 'text';\n value: string;\n}\n\nexport interface InsertNode extends Range {\n kind: 'insert';\n expression: Expression;\n}\n\nexport interface StaticAttribute extends Range {\n kind: 'static';\n name: string;\n value: string | true;\n}\n\nexport interface ValueAttribute extends Range {\n kind: 'value';\n name: string;\n value: Expression;\n}\n\nexport interface EventAttribute extends Range {\n kind: 'event';\n /** The attribute name, such as `onClick`. */\n name: string;\n /** The DOM event name, such as `click`. */\n event: string;\n handler: Expression;\n}\n\nexport interface RefAttribute extends Range {\n kind: 'ref';\n /** The name in `ref=$bind(name)`: a signal, or a prop that the component writes. */\n target: string;\n /** The range of the name. */\n targetRange: Range;\n}\n\nexport interface SpreadAttribute extends Range {\n kind: 'spread';\n value: Expression;\n}\n\nexport interface ComputedAttribute extends Range {\n kind: 'computed';\n name: Expression;\n value: Expression | true;\n}\n\nexport type Attribute =\n | StaticAttribute\n | ValueAttribute\n | EventAttribute\n | RefAttribute\n | SpreadAttribute\n | ComputedAttribute;\n\nexport interface Body extends Range {\n script?: Script;\n templates: TemplateDecl[];\n children: Markup[];\n}\n\nexport interface Branch {\n condition: Expression;\n body: Body;\n}\n\nexport interface IfBlock extends Range {\n kind: 'if';\n branches: Branch[];\n fallback?: Body;\n}\n\nexport interface ForBlock extends Range {\n kind: 'for';\n item: oxc.BindingPattern;\n index?: oxc.BindingIdentifier;\n list: Expression;\n /** `'index'` keys items by position. */\n key?: Expression | 'index';\n /**\n * `window(height, count)`: the browser renders only the items in view, which are about\n * `height` pixels tall, and the server renders the first `count`.\n */\n window?: { height: Expression; count?: Expression };\n body: Body;\n fallback?: Body;\n}\n\nexport interface RepeatBlock extends Range {\n kind: 'repeat';\n index?: oxc.BindingIdentifier;\n count: Expression;\n body: Body;\n fallback?: Body;\n}\n\nexport interface SwitchBlock extends Range {\n kind: 'switch';\n cases: Branch[];\n fallback?: Body;\n}\n\nexport interface KeyBlock extends Range {\n kind: 'key';\n value: Expression;\n body: Body;\n}\n\nexport interface TryBlock extends Range {\n kind: 'try';\n body: Body;\n error?: oxc.BindingIdentifier;\n reset?: oxc.BindingIdentifier;\n fallback: Body;\n}\n\nexport interface LoadingBlock extends Range {\n kind: 'loading';\n on?: Expression;\n body: Body;\n fallback?: Body;\n}\n\n/** `#head { … }`: markup for the document's `<head>`. */\nexport interface HeadBlock extends Range {\n kind: 'head';\n body: Body;\n}\n\nexport interface PortalBlock extends Range {\n kind: 'portal';\n target?: Expression;\n body: Body;\n}\n\nexport type ClientTrigger = 'visible' | 'idle' | 'load';\n\nexport interface ClientBlock extends Range {\n kind: 'client';\n trigger: ClientTrigger;\n body: Body;\n /** Markup that the server renders in place of the body, until the body renders. */\n fallback?: Body;\n}\n\n/**\n * `#defer (trigger) { … } #else { … }`: a body that the server renders in a\n * later request, when the trigger fires in the browser. The page has the\n * fallback until then.\n */\nexport interface DeferBlock extends Range {\n kind: 'defer';\n trigger: ClientTrigger;\n body: Body;\n fallback?: Body;\n}\n\n/**\n * `#offscreen (visible) { … }`: a body that stays in the page while it is\n * hidden, with its markup and state, but does not run its effects.\n */\nexport interface OffscreenBlock extends Range {\n kind: 'offscreen';\n visible: Expression;\n body: Body;\n}\n\nexport type Block =\n | IfBlock\n | ForBlock\n | RepeatBlock\n | SwitchBlock\n | KeyBlock\n | TryBlock\n | LoadingBlock\n | PortalBlock\n | HeadBlock\n | ClientBlock\n | DeferBlock\n | OffscreenBlock;\n\nexport interface TemplateDecl extends Range {\n kind: 'template';\n name: string;\n nameRange: Range;\n params: oxc.ParamPattern[];\n body: Body;\n}\n\n/** The markup inside a node: the children of an element, or the bodies of a block. */\nexport function getChildren(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 const children: Markup[] = [];\n for (const branch of node.branches) {\n children.push(...branch.body.children);\n }\n children.push(...(node.fallback?.children ?? []));\n return children;\n }\n case 'switch': {\n const children: Markup[] = [];\n for (const branch of node.cases) {\n children.push(...branch.body.children);\n }\n children.push(...(node.fallback?.children ?? []));\n return 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(getChildren(node), visit);\n }\n}\n","import type { oxc } from './oxc.ts';\nimport type { Block, Markup } from './ast.ts';\nimport { forEachNode } from './ast.ts';\nimport { isWithin, lookup } from './model.ts';\nimport type {\n Declaration,\n DeclarationKind,\n Diagnostic,\n Reference,\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 /** Memos that no browser code reads, which the browser does not declare or compute. */\n unread: Set<Declaration>;\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\n/** True if the read is inside the compute of one of the memos; a read in its inner function counts. */\nfunction isReadIn(read: Reference, memos: Set<Declaration>): boolean {\n const site = read.site;\n return site.kind === 'memo' && site.declaration !== undefined && memos.has(site.declaration);\n}\n\n/**\n * Finds the memos that no browser code reads: no read at all, or reads only in the compute of\n * other such memos. The server computes a memo when something reads it, so the browser does not\n * compute these either. A memo that is awaited where it is declared, a debounced or throttled\n * value, an optimistic value, a search parameter, a bound value and a ref target stay.\n */\nfunction findUnread(model: SemanticModel): Set<Declaration> {\n const unread = new Set<Declaration>();\n const candidates: Declaration[] = [];\n for (const declaration of model.declarations) {\n if (\n isMemoKind(declaration.kind) &&\n declaration.site?.kind === 'memo' &&\n !declaration.awaited &&\n !declaration.timing &&\n !declaration.optimistic &&\n !declaration.writable &&\n !declaration.searchParam &&\n !declaration.bound &&\n declaration.refs.length === 0 &&\n declaration.writes.length === 0\n ) {\n candidates.push(declaration);\n }\n }\n // A memo that only an unread memo reads is unread too, so repeat until nothing changes.\n for (let changed = true; changed;) {\n changed = false;\n for (const declaration of candidates) {\n if (unread.has(declaration)) {\n continue;\n }\n let read = false;\n for (const item of declaration.reads) {\n if (!isReadIn(item, unread)) {\n read = true;\n break;\n }\n }\n if (!read) {\n unread.add(declaration);\n changed = true;\n }\n }\n }\n return unread;\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<string>();\n for (const item of declaration.scope.declarations.values()) {\n if (item.propKey) {\n named.add(item.propKey);\n }\n }\n for (const key of liveProps) {\n if (!named.has(key)) {\n return true;\n }\n }\n return false;\n }\n if (declaration.propKey === undefined) {\n // The props object, or a computed key.\n return liveProps.size > 0;\n }\n return (\n liveProps.has(declaration.propKey) || (liveProps.has('~') && declaration.propKey !== 'children')\n );\n}\n\n/** True if any of the sites was reached. */\nfunction anyReached(items: { site: Site }[], reached: Set<Site>): boolean {\n for (const item of items) {\n if (reached.has(item.site)) {\n return true;\n }\n }\n return false;\n}\n\n/** True if any of the items is in the set. */\nfunction anyIn<T>(items: Iterable<T>, set: Set<T>): boolean {\n for (const item of items) {\n if (set.has(item)) {\n return true;\n }\n }\n return false;\n}\n\n/** True if a function that the declaration calls asks the client to load again. */\nfunction callsRefreshed(declaration: Declaration): boolean {\n for (const callee of declaration.site?.calls ?? []) {\n if (callee.refreshed) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * True for a `$searchParam` that the browser can change without a request: the URL is the source\n * when the page loads, and the history writes it. One with `server: true` navigates instead. A spread in the options may hold `server`, and\n * such a signal stays live, which costs a slot and breaks nothing.\n */\nfunction followsUrl(declaration: Declaration): boolean {\n const options = declaration.searchParam?.arguments[1];\n if (!declaration.searchParam) {\n return false;\n }\n if (options?.type !== 'ObjectExpression') {\n return true;\n }\n for (const property of options.properties) {\n if (\n property.type === 'Property' &&\n property.key.type === 'Identifier' &&\n property.key.name === 'server'\n ) {\n return false;\n }\n }\n return true;\n}\n\n/** True if the declaration is referenced from one of the scopes. */\nfunction hasRefIn(declaration: Declaration, scopes: Set<Scope>): boolean {\n for (const ref of declaration.refs) {\n if (scopes.has(ref.scope)) {\n return true;\n }\n }\n return false;\n}\n\n/** Finds the scope of the body of a block. */\nfunction findBodyScope(model: SemanticModel, block: Block & { kind: 'try' }): Scope | undefined {\n for (const scope of model.scopes) {\n if (scope.block === block && scope.body === block.body) {\n return scope;\n }\n }\n return undefined;\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 for (const declaration of model.declarations) {\n if (\n declaration.kind === 'reset' &&\n declaration.block === block &&\n anyReached(declaration.reads, reached)\n ) {\n return true;\n }\n }\n return false;\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/** True if one of the markup nodes holds a component or a dynamic tag, whose code this file cannot see. */\nfunction holdsComponent(nodes: Markup[]): boolean {\n let found = false;\n forEachNode(nodes, (node) => {\n found ||= node.kind === 'component' || node.kind === 'dynamic';\n });\n return found;\n}\n\n/** True if `scope` is inside one of `ancestors`. */\nfunction isWithinAny(scope: Scope, ancestors: Scope[]): boolean {\n for (const ancestor of ancestors) {\n if (isWithin(scope, ancestor)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The scopes of the templates declared outside the body of a `#try` that are\n * called in it, in another such template, or in a function that one of them\n * calls. A template's scope links to where it is called at runtime, so the\n * `#try` catches the errors of these calls.\n */\nfunction calledTemplates(model: SemanticModel, block: Block & { kind: 'try' }): Scope[] {\n const body = findBodyScope(model, block);\n if (body === undefined) {\n return [];\n }\n const inside = [body];\n const found: Scope[] = [];\n // The functions and templates that the body calls, also through each other.\n const called = new Set<Declaration>();\n let added = true;\n while (added) {\n added = false;\n for (const site of model.sites) {\n if (\n !isWithinAny(site.scope, inside) &&\n (site.declaration === undefined || !called.has(site.declaration))\n ) {\n continue;\n }\n for (const declaration of site.calls) {\n if (\n (declaration.kind === 'function' || declaration.kind === 'template') &&\n !called.has(declaration)\n ) {\n called.add(declaration);\n added = true;\n }\n }\n }\n for (const scope of model.scopes) {\n if (scope.kind !== 'template' || isWithinAny(scope, inside)) {\n continue;\n }\n const declaration = lookup(scope.parent!, scope.template!.name);\n if (declaration && called.has(declaration)) {\n inside.push(scope);\n found.push(scope);\n added = true;\n }\n }\n }\n return found;\n}\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, a memo that loads, or a read of a\n * memo, which throws when the memo holds an error. An error in it renders\n * the `#catch` body in the browser, so both bodies ship. A component in the\n * body counts too, since its code can be any of these.\n */\nexport function tryCatchesClient(model: SemanticModel, block: Block & { kind: 'try' }): boolean {\n const body = findBodyScope(model, block);\n if (body === undefined) {\n return false;\n }\n // The templates that render in the body count as part of it.\n const inside = [body, ...calledTemplates(model, block)];\n if (holdsComponent(block.body.children)) {\n return true;\n }\n for (const scope of model.scopes) {\n if (\n scope.template &&\n isWithinAny(scope, inside) &&\n holdsComponent(scope.template.body.children)\n ) {\n return true;\n }\n }\n for (const site of model.sites) {\n if (\n (CLIENT_CODE.has(site.kind) ||\n (site.kind === 'memo' && site.declaration?.kind === 'async-memo')) &&\n isWithinAny(site.scope, inside)\n ) {\n return true;\n }\n }\n // A memo that threw holds its error, so each read of it throws.\n for (const declaration of model.declarations) {\n if (isMemoKind(declaration.kind)) {\n for (const read of declaration.reads) {\n if (isWithinAny(read.site.scope, inside)) {\n return true;\n }\n }\n }\n }\n return false;\n}\n\n/** True if the expression of a site is a prop that is typed as a promise, such as `$memo(user)`. */\nfunction isPropValue(site: Site | undefined): boolean {\n let node = site?.node;\n while (node?.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n if (node?.type !== 'Identifier') {\n return false;\n }\n const declaration = lookup(site!.scope, node.name);\n return declaration?.kind === 'prop' && declaration.promise === true;\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\n// True if the site, or a function it calls outside `$untrack`, writes a value or calls code\n// that the compiler cannot see: a handler, not a derivation.\nfunction writes(site: Site, seen = new Set<Site>()): boolean {\n if (seen.has(site)) {\n return false;\n }\n seen.add(site);\n if (site.opaqueCalls) {\n return true;\n }\n for (const write of site.writes) {\n if (write.tracked) {\n return true;\n }\n }\n for (const callee of site.trackedCalls) {\n if (callee.site && writes(callee.site, seen)) {\n return true;\n }\n }\n return false;\n}\n\n/** True for a function prop of a component that only reads values and is not an event. */\nfunction isDerivation(site: Site): boolean {\n const owner = site.owner;\n if (owner?.kind !== 'component' || writes(site)) {\n return false;\n }\n // The parser gives `onClick=…` and the like the kind `event`: those are handlers, which call\n // code that the compiler cannot see.\n for (const attribute of owner.attributes) {\n if (attribute.kind === 'value' && attribute.value.ast === site.node) {\n return true;\n }\n }\n return false;\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 node.callee.name === '$untrack' &&\n !lookup(site.scope, node.callee.name) &&\n node.arguments[0]\n ) {\n // `$untrack(fn)` marks the prop as fixed and still passes the function.\n node = node.arguments[0];\n continue;\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 declaration = lookup(site.scope, node.name);\n const kind = declaration?.kind;\n // A template passed as a prop renders in the browser too, such as in a list that changes.\n // An import is a function when its module exports one.\n return (\n kind === 'function' ||\n kind === 'server-function' ||\n kind === 'template' ||\n (kind === 'import' && declaration?.callable === true)\n );\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 function addNode(node: GraphNode): GraphNode {\n nodes.push(node);\n incoming.set(node, []);\n return node;\n }\n function 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 function 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 // A context value is read once. What a function in it reads is read when the function runs,\n // so only the reads outside a function count, and the calls of the value do not.\n const provided = site.kind === 'provide' && !site.store;\n for (const read of site.reads) {\n if (\n read.tracked &&\n !(provided && read.inFunction) &&\n declarationNodes.has(read.declaration)\n ) {\n result.push(read.declaration);\n }\n }\n if (provided) {\n return result;\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 // One that only reads is a derivation: the child can call it in a memo, in markup or in an\n // effect, so the prop counts as changed when the values it reads change.\n if (site.kind === 'prop' && isFunctionValue(site) && !isDerivation(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 const unread = findUnread(model);\n\n function 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 // The browser renders the items of a windowed list as they come into view.\n (block.kind === 'for' && block.window !== undefined && scope.body === block.body) ||\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 anyIn(headers.get(block) ?? [], live) ||\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 // The window of a windowed list reads its list, its key and its height in the browser.\n (site.kind === 'block' && site.block?.kind === 'for' && site.block.window !== undefined) ||\n (site.kind === 'effect' && live.has(siteNodes.get(site)!)) ||\n created.has(site.scope);\n if (isRoot && !(site.kind === 'memo' && unread.has(site.declaration!))) {\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 prop of `let` that client code writes, also when every parent passes a constant.\n (declaration.kind === 'prop' &&\n declaration.writable === true &&\n anyReached(declaration.writes, reached)) ||\n // The runtime changes `$route` and `$navigation`, and a store writes the slot of `$store`.\n // The value of `$getContext` is read once.\n (declaration.kind === 'context' && !declaration.contextSource) ||\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) && callsRefreshed(declaration)) ||\n // A memo of a prop, which can be a promise: its value arrives later, also in a component\n // that the browser renders.\n (declaration.kind === 'memo' && isPropValue(declaration.site)) ||\n // Handlers write an optimistic value.\n (declaration.optimistic !== undefined && anyReached(declaration.writes, reached)) ||\n (declaration.kind === 'signal' &&\n (anyReached(declaration.writes, reached) ||\n hasRefIn(declaration, created) ||\n followsUrl(declaration))) ||\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) && anyIn(incoming.get(node)!, live)) {\n live.add(node);\n propagated = true;\n }\n }\n }\n\n // The browser does not compute an unread memo, so it never changes there.\n for (const declaration of unread) {\n live.delete(declarationNodes.get(declaration)!);\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 for (const site of model.sites) {\n if (!template || !site.calls.has(template)) {\n continue;\n }\n const node = siteNodes.get(site);\n if (reached.has(site) || (node !== undefined && live.has(node))) {\n return true;\n }\n }\n return false;\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 = findBodyScope(model, block);\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 for (const scope of model.scopes) {\n if (created.has(scope) && isWithin(scope, body)) {\n return true;\n }\n }\n return false;\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, unread, diagnostics };\n}\n","// The events of the DOM whose name has more than one word, in camel case. A handler is written\n// in camel case only (`onKeyDown`), so the parser reports the lower-case form (`onKeydown`).\n// ElementEventNames in elements.d.ts has the same names, and a test keeps them equal.\nexport const CAMEL_EVENTS: readonly string[] = [\n 'AfterPrint',\n 'AnimationCancel',\n 'AnimationEnd',\n 'AnimationIteration',\n 'AnimationStart',\n 'AuxClick',\n 'BeforeInput',\n 'BeforeMatch',\n 'BeforePrint',\n 'BeforeToggle',\n 'BeforeUnload',\n 'CanPlay',\n 'CanPlayThrough',\n 'CompositionEnd',\n 'CompositionStart',\n 'CompositionUpdate',\n 'ContextLost',\n 'ContextMenu',\n 'ContextRestored',\n 'CueChange',\n 'DblClick',\n 'DeviceMotion',\n 'DeviceOrientation',\n 'DeviceOrientationAbsolute',\n 'DragEnd',\n 'DragEnter',\n 'DragLeave',\n 'DragOver',\n 'DragStart',\n 'DurationChange',\n 'FocusIn',\n 'FocusOut',\n 'FormData',\n 'FullscreenChange',\n 'FullscreenError',\n 'GamepadConnected',\n 'GamepadDisconnected',\n 'GotPointerCapture',\n 'HashChange',\n 'KeyDown',\n 'KeyPress',\n 'KeyUp',\n 'LanguageChange',\n 'LoadStart',\n 'LoadedData',\n 'LoadedMetadata',\n 'LostPointerCapture',\n 'MessageError',\n 'MouseDown',\n 'MouseEnter',\n 'MouseLeave',\n 'MouseMove',\n 'MouseOut',\n 'MouseOver',\n 'MouseUp',\n 'OrientationChange',\n 'PageHide',\n 'PageReveal',\n 'PageShow',\n 'PageSwap',\n 'PointerCancel',\n 'PointerDown',\n 'PointerEnter',\n 'PointerLeave',\n 'PointerLockChange',\n 'PointerLockError',\n 'PointerMove',\n 'PointerOut',\n 'PointerOver',\n 'PointerRawUpdate',\n 'PointerUp',\n 'PopState',\n 'RateChange',\n 'ReadyStateChange',\n 'RejectionHandled',\n 'ScrollEnd',\n 'SecurityPolicyViolation',\n 'SelectStart',\n 'SelectionChange',\n 'SlotChange',\n 'TimeUpdate',\n 'TouchCancel',\n 'TouchEnd',\n 'TouchMove',\n 'TouchStart',\n 'TransitionCancel',\n 'TransitionEnd',\n 'TransitionRun',\n 'TransitionStart',\n 'UnhandledRejection',\n 'VisibilityChange',\n 'VolumeChange',\n];\n\nconst BY_LOWER = new Map<string, string>();\nfor (const name of CAMEL_EVENTS) {\n BY_LOWER.set(`on${name.toLowerCase()}`, `on${name}`);\n}\n\n/** The camel-case name for a handler written in another case, such as `onKeyDown` for `onKeydown`. */\nexport function camelEventName(attribute: string): string | undefined {\n const camel = BY_LOWER.get(attribute.toLowerCase());\n return camel === attribute ? undefined : camel;\n}\n\n// Events of the DOM whose name has capitals, or whose lower-case form the browser never fires. A\n// handler name is lower-cased to the event (`onDOMContentLoaded` listens to `domcontentloaded`),\n// so none of these can be written as a handler. The value is what to write instead.\nconst NO_HANDLER = new Map<string, string>([\n [\n 'domcontentloaded',\n \"The page code loads after the HTML, mostly after this event, and a client navigation never fires it. Run code at load with $client(fn, 'load')\",\n ],\n ['domactivate', 'The event is deprecated. Write onClick'],\n ['domfocusin', 'The event is deprecated. Write onFocusIn'],\n ['domfocusout', 'The event is deprecated. Write onFocusOut'],\n ['dommousescroll', 'The event is not standard. Write onWheel'],\n ['mozmousepixelscroll', 'The event is not standard. Write onWheel'],\n ['webkitanimationstart', 'The browser fires the prefixed name only. Write onAnimationStart'],\n [\n 'webkitanimationiteration',\n 'The browser fires the prefixed name only. Write onAnimationIteration',\n ],\n ['webkitanimationend', 'The browser fires the prefixed name only. Write onAnimationEnd'],\n ['webkittransitionend', 'The browser fires the prefixed name only. Write onTransitionEnd'],\n]);\nfor (const mutation of [\n 'DOMAttrModified',\n 'DOMCharacterDataModified',\n 'DOMNodeInserted',\n 'DOMNodeInsertedIntoDocument',\n 'DOMNodeRemoved',\n 'DOMNodeRemovedFromDocument',\n 'DOMSubtreeModified',\n]) {\n NO_HANDLER.set(\n mutation.toLowerCase(),\n 'The event is removed. Observe the DOM with a MutationObserver',\n );\n}\n\n/** What to write instead of a handler for an event that has none, such as `onDOMContentLoaded`. */\nexport function noHandlerFix(attribute: string): string | undefined {\n return NO_HANDLER.get(attribute.slice(2).toLowerCase());\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 ForBlock,\n FragmentNode,\n KeyBlock,\n Markup,\n Reveal,\n RevealOrder,\n SFCFile,\n Script,\n Style,\n TemplateDecl,\n} from './ast.ts';\nimport { createFail } from './error.ts';\nimport { camelEventName, noHandlerFix } from './event-names.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\n// The wrappers of brumate/events that write a modifier.\nconst WRAPPERS = new Set(['prevent', 'stop', 'once', 'capture']);\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\n/** The keywords that open a block. The highlighter lists the same ones. */\nexport const BLOCK_KEYWORDS: Set<string> = 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\n/** The keywords of the branches of a block. */\nexport const BRANCH_KEYWORDS: Set<string> = new Set(['else', 'catch', 'case', 'default']);\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 /** A handler of an element is written in camel case: `onKeyDown`, not `onKeydown`. */\n private checkEventName(\n name: string,\n owner: 'element' | 'component' | 'dynamic' | 'listener',\n start: number,\n ): void {\n if (owner === 'component' || owner === 'dynamic') {\n return;\n }\n const camel = camelEventName(name);\n if (camel) {\n this.fail(`\"${name}\" is not an event name. Write \"${camel}\"`, start);\n }\n const fix = noHandlerFix(name);\n if (fix) {\n this.fail(`\"${name}\" cannot be a handler. ${fix}`, start);\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 // `{onClick}` is a handler, the same as `onClick=onClick`, as in Svelte.\n if (/^on[A-Z]/.test(name)) {\n this.checkEventName(name, owner, start);\n return {\n kind: 'event',\n start,\n end: this.pos,\n name,\n event: name.slice(2).toLowerCase(),\n handler: this.expression(inner.start, inner.end),\n };\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 this.checkEventName(name, owner, start);\n // Wrappers of brumate/events are the only way to write a modifier.\n if (parts.length > 1) {\n const rest = parts.slice(1);\n const wrappers: string[] = [];\n let unknown: string | undefined;\n for (const modifier of rest) {\n if (WRAPPERS.has(modifier)) {\n wrappers.push(modifier);\n } else if (modifier !== 'passive') {\n unknown ??= modifier;\n }\n }\n let fix: string;\n if (unknown !== undefined) {\n fix = `${name}=(handler) with the wrappers of brumate/events, since \":${unknown}\" is not a modifier`;\n } else if (wrappers.length === 0) {\n fix = `${name}=(handler), since listeners are passive unless a handler prevents`;\n } else {\n let call = 'handler';\n for (const wrapper of wrappers.toReversed()) {\n call = `${wrapper}(${call})`;\n }\n fix = `${name}=(${call}) with ${wrappers.join(' and ')} from brumate/events`;\n }\n this.fail(`Event modifiers in the attribute name were removed. Write ${fix}`, start);\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 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' || owner === 'dynamic') && fullName === 'ref') {\n const message = 'ref takes $bind, as in ref=$bind(name)';\n this.expect('=', message);\n const valueStart = this.pos;\n const match = /^\\$bind\\(\\s*([\\p{ID_Start}$_][\\p{ID_Continue}$\\u200c\\u200d]*)\\s*\\)/u.exec(\n this.source.slice(this.pos),\n );\n const next = match ? this.source[this.pos + match[0].length] : undefined;\n if (!match || !(next === undefined || isWhitespace(next) || next === '>' || next === '/')) {\n this.fail(message, valueStart);\n }\n const target = match![1]!;\n const targetStart = valueStart + match![0].indexOf(target, 5);\n this.pos = valueStart + match![0].length;\n return {\n kind: 'ref',\n start,\n end: this.pos,\n target,\n targetRange: { start: targetStart, end: targetStart + target.length },\n };\n }\n\n if (owner === 'element' && fullName === 'prefetch') {\n // The code of the page loads when it starts, so a handler has nothing to load early.\n this.fail('prefetch is removed. The code of the page loads when it starts', start);\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 for (const name of Object.keys(attributes)) {\n if (name !== 'lang' && name !== 'global') {\n this.fail(`Unknown <style> attribute \"${name}\"`, start);\n }\n }\n if (attributes.global !== undefined && attributes.global !== true) {\n this.fail('global takes no value, as in <style global>', start);\n }\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 global: attributes.global === true,\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 window = this.parseWindow();\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, window, body, fallback };\n }\n\n /** `window(height)` or `window(height, count)` after the header of a `#for`. */\n private parseWindow(): ForBlock['window'] {\n this.skipWhitespace();\n if (\n !this.source.startsWith('window', this.pos) ||\n /[\\w$]/.test(this.source[this.pos + 6] ?? '')\n ) {\n return undefined;\n }\n const at = this.pos;\n this.pos += 'window'.length;\n const inner = this.parseHeader('window', true)!;\n const code = this.source.slice(inner.start, inner.end);\n const comma = findTopLevel(code, ',', this.fail);\n if (code.trim() === '') {\n this.fail('Expected the height of an item in window(height)', at);\n }\n const height = this.expression(inner.start, comma === -1 ? inner.end : inner.start + comma);\n const count = comma === -1 ? undefined : this.expression(inner.start + comma + 1, inner.end);\n return { height, count };\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 { forEachNode } from './ast.ts';\nimport { buildGraph } from './graph.ts';\nimport type { Graph } from './graph.ts';\nimport type { SemanticModel, Site } from './model.ts';\nimport type { oxc } from './oxc.ts';\nimport { parse } from './parser.ts';\n\nexport { forEachNode, getChildren } from './ast.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 /** True for a dynamic tag, which can name the component. Only a component that declares the prop takes it. */\n dynamic?: boolean;\n /**\n * The props whose value names `.brm` imports, such as `as=Target` or `as=(flag ? A : B)`: the\n * prop name and the import specifiers.\n */\n components?: Map<string, string[]>;\n /**\n * The props whose value is a prop of this file, such as `{as}`: the prop name and the names of\n * this file's props. `*` means the whole props object.\n */\n passed?: Map<string, string[]>;\n}\n\n/** A dynamic tag of a file, with the props that name its tag and the props that can change. */\nexport interface DynamicTagUsage {\n /** The props that the tag expression reads. `*` means the whole props object. */\n tagProps: Set<string>;\n liveProps: Set<string>;\n}\n\n/** True if a component declares a prop by name, or takes the rest or the whole props object. */\nfunction declaresProp(model: SemanticModel, name: string): boolean {\n for (const declaration of model.declarations) {\n if (\n declaration.kind === 'props-rest' ||\n (declaration.kind === 'prop' &&\n (declaration.propKey === undefined || declaration.propKey === name || name === '~'))\n ) {\n return true;\n }\n }\n return false;\n}\n\n/** The names a value can be: the identifiers of an expression and of the branches of a condition. */\nfunction valueNames(node: oxc.Expression, names: string[] = []): string[] {\n switch (node.type) {\n case 'Identifier':\n names.push(node.name);\n break;\n case 'ConditionalExpression':\n valueNames(node.consequent, names);\n valueNames(node.alternate, names);\n break;\n case 'LogicalExpression':\n // The right side of `&&` is the value. Its left side is a condition.\n if (node.operator !== '&&') {\n valueNames(node.left, names);\n }\n valueNames(node.right, names);\n break;\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n valueNames(node.expression, names);\n break;\n default:\n break;\n }\n return names;\n}\n\n/** Returns the import specifier of a name that the file imports. */\nexport function 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 for (const specifier of statement.specifiers) {\n if (specifier.local.name === name) {\n return statement.source.value;\n }\n }\n }\n }\n return undefined;\n}\n\n/** The import specifiers of the `.brm` files that a file imports. */\nexport function importedComponents(file: SFCFile): string[] {\n const specifiers: string[] = [];\n for (const program of [file.moduleScript?.program, file.instanceScript?.program]) {\n for (const statement of program?.body ?? []) {\n if (statement.type === 'ImportDeclaration' && statement.source.value.endsWith('.brm')) {\n specifiers.push(statement.source.value);\n }\n }\n }\n return specifiers;\n}\n\n/**\n * The live prop that a dynamic tag gives to the component it names. A spread or a computed name\n * can hold any prop, but `children` come from the body of the tag, so they are left out: `~`.\n */\nfunction tagProp(name: string | undefined): string | undefined {\n return name === '*' ? '~' : name;\n}\n\n/** Returns a function that names the prop of an attribute when its value can change. */\nfunction liveChecker(graph: Graph): (attribute: Attribute) => string | undefined {\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 function isLive(expression: { ast: object }): boolean {\n const site = sites.get(expression.ast);\n return site !== undefined && live.has(site);\n }\n return (attribute) => {\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\n/** Lists the dynamic tags of a file that have props that can change. */\nexport function dynamicTags(file: SFCFile, graph: Graph): DynamicTagUsage[] {\n const liveProp = liveChecker(graph);\n const tags: DynamicTagUsage[] = [];\n function visit(node: Markup): void {\n if (node.kind !== 'dynamic') {\n return;\n }\n const liveProps = new Set<string>();\n for (const attribute of node.attributes) {\n const name = tagProp(liveProp(attribute));\n if (name) {\n liveProps.add(name);\n }\n }\n if (liveProps.size === 0) {\n return;\n }\n const tagProps = new Set<string>();\n for (const site of graph.model.sites) {\n if (site.node !== node.tag.ast) {\n continue;\n }\n for (const read of site.reads) {\n const declaration = read.declaration;\n if (declaration.kind === 'props-rest') {\n tagProps.add('*');\n } else if (declaration.kind === 'prop') {\n tagProps.add(declaration.propKey ?? '*');\n }\n }\n }\n if (tagProps.size > 0) {\n tags.push({ tagProps, liveProps });\n }\n }\n forEachNode(file.children, visit);\n for (const template of file.templates) {\n forEachNode(template.body.children, visit);\n }\n return tags;\n}\n\n/** Adds a value to the list under a key. */\nfunction append(map: Map<string, string[]>, key: string, value: string): void {\n const list = map.get(key);\n if (list) {\n list.push(value);\n } else {\n map.set(key, [value]);\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 liveProp = liveChecker(graph);\n\n const usages: ComponentUsage[] = [];\n // The components that the file reads as values. A dynamic tag can name any of them.\n const valueSources: string[] = [];\n for (const declaration of graph.model.declarations) {\n if (\n declaration.kind === 'import' &&\n declaration.imported?.source.endsWith('.brm') &&\n declaration.reads.length > 0\n ) {\n valueSources.push(declaration.imported.source);\n }\n }\n function visit(node: Markup): void {\n if (node.kind === 'dynamic') {\n // The props of a dynamic tag reach the component that it names, so each component that the\n // file reads as a value gets the props that can change.\n const liveProps = new Set<string>();\n for (const attribute of node.attributes) {\n const name = tagProp(liveProp(attribute));\n if (name) {\n liveProps.add(name);\n }\n }\n if (liveProps.size > 0) {\n for (const source of valueSources) {\n usages.push({ source, liveProps, dynamic: true });\n }\n }\n return;\n }\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 const components = new Map<string, string[]>();\n const passed = new Map<string, string[]>();\n for (const attribute of node.attributes) {\n const name = liveProp(attribute);\n if (name) {\n liveProps.add(name);\n }\n if (attribute.kind !== 'value') {\n continue;\n }\n for (const local of valueNames(attribute.value.ast)) {\n const named = importSource(file, local);\n if (named?.endsWith('.brm')) {\n append(components, attribute.name, named);\n continue;\n }\n for (const declaration of graph.model.declarations) {\n if (declaration.kind === 'prop' && declaration.name === local) {\n append(passed, attribute.name, declaration.propKey ?? '*');\n }\n }\n }\n }\n usages.push({ source, liveProps, components, passed });\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 each file and prop, the files of the components that parents give to it, such as `as=Target`.\n const given = new Map<string, Map<string, Set<string>>>();\n const models = new Map<string, SemanticModel>();\n for (const [filename, file] of parsed) {\n result.set(filename, new Map());\n models.set(filename, analyze(file));\n }\n // Each round can only add props, so this ends.\n for (let changed = true; changed;) {\n changed = false;\n // The dynamic tags of a file, with the props that can change in this round.\n const tagsOf = new Map<string, DynamicTagUsage[]>();\n function tagsFor(filename: string): DynamicTagUsage[] {\n let tags = tagsOf.get(filename);\n if (!tags) {\n const liveProps = new Set(result.get(filename)!.keys());\n const graph = buildGraph(models.get(filename)!, { liveProps });\n tags = dynamicTags(parsed.get(filename)!, graph);\n tagsOf.set(filename, tags);\n }\n return tags;\n }\n function add(target: string, name: string, parent: string): void {\n const props = result.get(target)!;\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(parent);\n }\n function give(target: string, prop: string, components: Iterable<string>): void {\n let props = given.get(target);\n if (!props) {\n props = new Map();\n given.set(target, props);\n }\n let set = props.get(prop);\n if (!set) {\n set = new Set();\n props.set(prop, set);\n }\n for (const component of components) {\n if (!set.has(component)) {\n set.add(component);\n changed = true;\n }\n }\n }\n for (const [filename, file] of parsed) {\n const liveProps = new Set(result.get(filename)!.keys());\n const graph = buildGraph(models.get(filename)!, { 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 if (usage.dynamic && !declaresProp(models.get(target!)!, name)) {\n continue;\n }\n add(target!, name, filename);\n }\n // A page that gives a component to a prop, such as `as=Target`, or a part that passes on\n // the component it was given, such as `{as}`, sends the live props of the dynamic tags\n // that read that prop to the component.\n for (const [prop, specifiers] of usage.components ?? []) {\n for (const specifier of specifiers) {\n const named = resolve(specifier, filename);\n if (named !== undefined && result.has(named)) {\n give(target!, prop, [named]);\n }\n }\n }\n const received = given.get(filename);\n for (const [prop, names] of usage.passed ?? []) {\n for (const name of names) {\n for (const [key, components] of received ?? []) {\n if (name === '*' || name === key) {\n give(target!, prop, components);\n }\n }\n }\n }\n }\n }\n for (const [target, props] of given) {\n for (const tag of tagsFor(target)) {\n for (const [prop, components] of props) {\n if (!tag.tagProps.has(prop) && !tag.tagProps.has('*')) {\n continue;\n }\n for (const named of components) {\n for (const name of tag.liveProps) {\n if (declaresProp(models.get(named)!, name)) {\n add(named, name, target);\n }\n }\n }\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 { getChildren } 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 for (const item of attributes) {\n if (item.kind === 'spread' || item.kind === 'computed') {\n return true;\n }\n }\n return false;\n}\n\nfunction hasEvent(element: ElementNode, events: string[]): boolean {\n for (const item of element.attributes) {\n if (item.kind === 'event' && events.includes(item.event)) {\n return true;\n }\n }\n return false;\n}\n\n/** True when an element names itself with ARIA or a title. */\nfunction hasAccessibleName(element: ElementNode): boolean {\n for (const name of ['aria-label', 'aria-labelledby', 'title']) {\n const value = attribute(element, name);\n if (value === true || (typeof value === 'string' && value.trim() !== '')) {\n return true;\n }\n }\n return false;\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 for (const node of nodes) {\n if (hasNodeText(node)) {\n return true;\n }\n }\n return false;\n}\n\nfunction hasNodeText(node: Markup): boolean {\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/** 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 function 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: Markup[][] = [file.children];\n for (const template of file.templates) {\n roots.push(template.body.children);\n }\n function 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(getChildren(node));\n }\n }\n for (const nodes of roots) {\n collect(nodes);\n }\n\n function visit(nodes: Markup[], inLabel: boolean): void {\n for (const node of nodes) {\n if (node.kind !== 'element') {\n visit(getChildren(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 function 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 for (const nodes of roots) {\n visit(nodes, false);\n }\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, Site } 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 function 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 function 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 let reader: Site | undefined;\n for (const read of declaration.reads) {\n if (plan.graph.reached.has(read.site)) {\n reader = read.site;\n break;\n }\n }\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 let holder: Declaration | undefined;\n for (const slot of slots) {\n const init = values.get(slot.range.start);\n if (init && read.range.start >= init.start && read.range.end <= init.end) {\n holder = slot;\n break;\n }\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: ReturnType<typeof lineIndex>[] = [];\n for (const file of files) {\n indexes.push(lineIndex(file.content));\n }\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 const sources: string[] = [];\n const sourcesContent: string[] = [];\n for (const file of files) {\n sources.push(file.name);\n sourcesContent.push(file.content);\n }\n return {\n code: output,\n map: {\n version: 3,\n file: files[0]!.name,\n sources,\n sourcesContent,\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 function 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/**\n * True when the export `name` of the module at `specifier` can be a function: a function that\n * the module exports, or an export of a module that the compiler cannot read, such as one of a\n * package. A value that the module declares, a component, a module of reactive logic and a\n * module that does not parse are not.\n */\nexport function mayExportFunction(\n specifier: string,\n name: string,\n importer: string,\n resolve: ResolveModule,\n seen: Set<string> = new Set(),\n): boolean {\n if (/\\.brm($|\\?)/.test(specifier) || isReactiveModule(specifier)) {\n return false;\n }\n const module = resolve(specifier, importer);\n if (!module) {\n return true;\n }\n if (seen.has(module.path)) {\n return false;\n }\n seen.add(module.path);\n const result = parseSync(module.path, module.source, { lang: 'ts', preserveParens: false });\n if (result.errors.length > 0) {\n return false;\n }\n // The top-level names: functions, other values, and imports.\n const functions = new Set<string>();\n const values = new Set<string>();\n const imports = new Map<string, { specifier: string; imported: string }>();\n const declare = (node: oxc.Node): void => {\n if (node.type === 'FunctionDeclaration' && node.id) {\n functions.add(node.id.name);\n } else if (node.type === 'VariableDeclaration') {\n for (const declarator of node.declarations) {\n const init = declarator.init;\n const isFunction =\n init?.type === 'ArrowFunctionExpression' || init?.type === 'FunctionExpression';\n for (const id of getPatternNames(declarator.id)) {\n (isFunction && declarator.id.type === 'Identifier' ? functions : values).add(id.name);\n }\n }\n }\n };\n for (const statement of result.program.body) {\n if (statement.type === 'ImportDeclaration') {\n for (const specifier of statement.specifiers) {\n let imported = '*';\n if (specifier.type === 'ImportDefaultSpecifier') {\n imported = 'default';\n } else if (specifier.type === 'ImportSpecifier') {\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 (\n (statement.type === 'ExportNamedDeclaration' ||\n statement.type === 'ExportDefaultDeclaration') &&\n statement.declaration\n ) {\n declare(statement.declaration);\n } else {\n declare(statement);\n }\n }\n // A local name that the module exports.\n const local = (localName: string): boolean => {\n if (functions.has(localName)) {\n return true;\n }\n const found = imports.get(localName);\n if (found && found.imported !== '*') {\n return mayExportFunction(found.specifier, found.imported, module.path, resolve, seen);\n }\n return false;\n };\n const stars: string[] = [];\n for (const statement of result.program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n if (name !== 'default') {\n continue;\n }\n const declaration = statement.declaration;\n if (\n declaration.type === 'FunctionDeclaration' ||\n declaration.type === 'ArrowFunctionExpression' ||\n declaration.type === 'FunctionExpression'\n ) {\n return true;\n }\n return declaration.type === 'Identifier' && local(declaration.name);\n }\n if (statement.type === 'ExportAllDeclaration') {\n if (!statement.exported) {\n stars.push(statement.source.value);\n }\n continue;\n }\n if (statement.type !== 'ExportNamedDeclaration') {\n continue;\n }\n if (statement.declaration) {\n const declaration = statement.declaration;\n if (declaration.type === 'FunctionDeclaration' && declaration.id?.name === name) {\n return true;\n }\n if (declaration.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n for (const id of getPatternNames(declarator.id)) {\n if (id.name === name) {\n return functions.has(name);\n }\n }\n }\n }\n continue;\n }\n for (const specifier of statement.specifiers) {\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (exported !== name) {\n continue;\n }\n const localName =\n specifier.local.type === 'Identifier' ? specifier.local.name : specifier.local.value;\n return statement.source\n ? mayExportFunction(statement.source.value, localName, module.path, resolve, seen)\n : local(localName);\n }\n }\n for (const star of stars) {\n if (mayExportFunction(star, name, module.path, resolve, seen)) {\n return true;\n }\n }\n return false;\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 = splitPath(normalize(directory(component)));\n let common = 0;\n const to: string[] = [];\n for (const part of target) {\n if (part) {\n to.push(part);\n }\n }\n while (common < from.length && common < to.length - 1 && from[common] === to[common]) {\n common++;\n }\n const up: string[] = [];\n for (let index = common; index < from.length; index++) {\n up.push('..');\n }\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 function 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 function 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 function 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/** Splits a path at its slashes and drops the empty parts. */\nfunction splitPath(value: string): string[] {\n const parts: string[] = [];\n for (const part of value.split('/')) {\n if (part) {\n parts.push(part);\n }\n }\n return parts;\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 function 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 function reactive(specifier: string): boolean {\n return (\n isReactiveModule(specifier) ||\n (!specifier.startsWith('.') &&\n specifier !== SIGNALS_MODULE &&\n isReactiveModule(resolve(specifier, path)?.path ?? ''))\n );\n }\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 function 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 function 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 function generated(text: string): void {\n builder.add(text, { offset: call.statement.start }, false);\n }\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 function 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 function origin(offset: number): Origin {\n return { module: module!, offset, call: site };\n }\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 // The key that returned each local first. A second key would be a copy of the local, and a\n // copy of a function is a value that the browser cannot get.\n const returnedBy = 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 (property.value.type === 'Identifier' && declared.has(property.value.name)) {\n const first = returnedBy.get(property.value.name);\n if (first !== undefined && target && wanted.has(first)) {\n throw new ModuleError(\n `${name} returns ${property.value.name} as ${first} and as ${key}. Return each local once, and give the other key a function of its own`,\n call.statement.start,\n );\n }\n returnedBy.set(property.value.name, key);\n }\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 for (const [index, param] of fn.params.entries()) {\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 continue;\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 continue;\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 function 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 function 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 function 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 const reactiveModules: ReactiveModule[] = [];\n for (const value of modules.values()) {\n reactiveModules.push(value.module);\n }\n\n return {\n source: builder.text,\n origin: (at) => builder.origin(at),\n modules: reactiveModules,\n calls: expanded,\n };\n}\n","import type { oxc } from '../oxc.ts';\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/** Expressions whose value is never a promise, as the memo of a list or a function. */\nconst NEVER_PROMISE = new Set(['ArrayExpression', 'ArrowFunctionExpression', 'FunctionExpression']);\n\n/** True for an expression that gives a primitive, an array or a function, never a promise. */\nexport function neverPromise(node: oxc.Node): boolean {\n return isPrimitive(node) || NEVER_PROMISE.has(node.type);\n}\n\n/** The operators of a binary expression that compare without a conversion. */\nconst STRICT_OPERATORS = new Set(['===', '!==']);\n\n/** The operators of a unary expression that do not convert their operand to a number. */\nconst PLAIN_UNARY = new Set(['!', 'typeof', 'void']);\n\n/**\n * True for an expression that evaluates without a throw, whatever its names hold. It has no\n * conversion that can throw, such as `big + 1` for a BigInt, a symbol or a `valueOf` that throws:\n * a name, a literal, an array or object without a spread, a function, `===`, `!==`, `!`, `typeof`,\n * `void`, `&&`, `||`, `??` and `?:` over those. `safe` tells which names do not throw when read.\n */\nexport function cannotThrow(\n node: oxc.Node,\n safe: (name: oxc.Node) => boolean = () => true,\n): boolean {\n switch (node.type) {\n case 'Identifier':\n return safe(node);\n case 'Literal':\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n return true;\n case 'TemplateLiteral':\n return node.expressions.length === 0;\n case 'CallExpression':\n // Both become `false`, so their argument is not read.\n return (\n node.callee.type === 'Identifier' &&\n (node.callee.name === '$isPending' || node.callee.name === '$isBound')\n );\n case 'UnaryExpression':\n return PLAIN_UNARY.has(node.operator) && cannotThrow(node.argument, safe);\n case 'BinaryExpression':\n return (\n STRICT_OPERATORS.has(node.operator) &&\n cannotThrow(node.left, safe) &&\n cannotThrow(node.right, safe)\n );\n case 'LogicalExpression':\n return cannotThrow(node.left, safe) && cannotThrow(node.right, safe);\n case 'ConditionalExpression':\n return (\n cannotThrow(node.test, safe) &&\n cannotThrow(node.consequent, safe) &&\n cannotThrow(node.alternate, safe)\n );\n case 'ArrayExpression':\n return allCannotThrow(node.elements, safe);\n case 'ObjectExpression': {\n const values: oxc.Node[] = [];\n for (const property of node.properties) {\n if (property.type !== 'Property' || property.kind !== 'init' || property.computed) {\n return false;\n }\n values.push(property.value);\n }\n return allCannotThrow(values, safe);\n }\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'ParenthesizedExpression':\n return cannotThrow(node.expression, safe);\n default:\n return false;\n }\n}\n\n/** True when none of the expressions throws. A hole or a spread of an array counts as a throw. */\nfunction allCannotThrow(nodes: (oxc.Node | null)[], safe: (name: oxc.Node) => boolean): boolean {\n for (const node of nodes) {\n if (node === null || node.type === 'SpreadElement' || !cannotThrow(node, safe)) {\n return false;\n }\n }\n return true;\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';\nimport { cannotThrow, neverPromise } from './primitive.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 // Take the edits inside the range, in source order.\n const inside: Edit[] = [];\n for (const edit of this.edits) {\n if (edit.start >= start && edit.end <= end) {\n inside.push(edit);\n }\n }\n const edits = inside.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', '$gate', '$optimistic', '$debounced', '$throttled']);\n\n/**\n * The code of an arrow function body, given the source offset where the user's expression starts.\n * An expression that starts with `{` is wrapped in parentheses, or the arrow reads it as a block.\n * This covers an object literal under `as`, `satisfies`, `!` and a `<T>` cast, and a sequence or\n * member access that starts with one. The source is checked, not the code, because the code can\n * start with a marker of the compiler.\n */\nexport function arrowBody(code: string, source: string, start: number): string {\n return source[start] === '{' ? `(${code})` : code;\n}\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\n/**\n * True for a memo expression that the browser render computes in place: it gives no promise, and\n * it cannot throw, so it has no error to hold. A name that reads a memo may throw, as the memo\n * may hold an error.\n */\nfunction isPlainMemo(site: Site, node: oxc.Node): boolean {\n const memoReads = new Set<number>();\n for (const read of site.reads) {\n if (read.declaration.kind === 'memo' || read.declaration.kind === 'async-memo') {\n memoReads.add(read.range.start);\n }\n }\n return (\n !site.awaits && neverPromise(node) && cannotThrow(node, (name) => !memoReads.has(name.start))\n );\n}\n\nexport function addValueEdits(\n patch: Patch,\n file: SFCFile,\n sites: Site[],\n mode: 'server' | 'client' | 'render' = 'server',\n inline: Set<Declaration> = new Set(),\n lazy: Set<Declaration> = new Set(),\n component?: number,\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 // The `$props()` calls whose pattern has a rest element.\n const restCalls = new Set<oxc.Node>();\n // The names that the other `$props()` calls destructure.\n function otherNames(call: oxc.Node): string[] {\n const own = new Set(propNames.get(call));\n const result = new Set<string>();\n for (const [other, names] of propNames) {\n if (other === call) {\n continue;\n }\n for (const name of names) {\n if (!own.has(name)) {\n result.add(name);\n }\n }\n }\n return [...result];\n }\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 const names: string[] = [];\n let hasRest = false;\n for (const property of declarator.id.properties) {\n const name = property.type === 'Property' ? keyName(property) : undefined;\n if (name !== undefined) {\n names.push(name);\n }\n if (property.type === 'RestElement') {\n hasRest = true;\n }\n }\n propNames.set(init, names);\n if (hasRest) {\n restCalls.add(init);\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 // The same reads by position, since a site can hold the node of another site.\n const replacedAt = new Set<number>();\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 // Reads of other memos become reads of the memos, so a value that is still loading throws.\n function readMemos(site: Site, node: oxc.Node, own?: Declaration, only?: Set<Declaration>): void {\n // A memo in a shorthand property, such as `{ id }`, keeps its key.\n const shorthands = new Set<number>();\n // `$isPending(memo)` and `$isBound(x)` become `false`, so their arguments are not reads.\n const folded: [number, number][] = [];\n function findShorthands(current: oxc.Node): void {\n if (\n current.type === 'CallExpression' &&\n (calleeName(current) === '$isPending' || calleeName(current) === '$isBound')\n ) {\n folded.push([current.start, current.end]);\n }\n if (current.type === 'Property' && current.shorthand) {\n shorthands.add(current.value.start);\n }\n for (const [, child] of children(current)) {\n findShorthands(child);\n }\n }\n findShorthands(node);\n // Whether a read sits inside one of the folded calls.\n function isFolded(read: Reference): boolean {\n for (const [start, end] of folded) {\n if (read.range.start >= start && read.range.end <= end) {\n return true;\n }\n }\n return false;\n }\n // The target of a write, such as `shown` in `shown = [...shown, name]`, stays a name.\n const targets = new Set<number>();\n for (const write of site.writes) {\n targets.add(write.range.start);\n }\n for (const read of site.reads) {\n if (\n read.range.start !== read.range.end &&\n read.range.start >= node.start &&\n read.range.end <= node.end &&\n !targets.has(read.range.start) &&\n !isFolded(read) &&\n read.declaration !== own &&\n !inline.has(read.declaration) &&\n (!only || only.has(read.declaration)) &&\n !replaced.has(read) &&\n !replacedAt.has((read.await ?? read.range).start) &&\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 const key = shorthands.has(range.start) ? `${read.declaration.name}: ` : '';\n patch.replace(\n range.start,\n range.end,\n mode === 'render'\n ? `${key}$$b.readMemo(${read.declaration.name})`\n : `${key}$$b.read(${promiseName(read.declaration.name)})`,\n );\n replaced.add(read);\n replacedAt.add(range.start);\n }\n }\n }\n if (mode === 'render') {\n // The memos that the render runs through `renderMemo`. A read of one throws the error that\n // it holds, as the server's does.\n const held = new Set<Declaration>();\n for (const site of sites) {\n if (site.kind === 'memo' && site.declaration && !inline.has(site.declaration)) {\n if (!isPlainMemo(site, site.node as oxc.Node)) {\n held.add(site.declaration);\n }\n }\n }\n for (const site of sites) {\n readMemos(site, site.node as oxc.Node, site.declaration, held);\n }\n }\n if (mode === 'server') {\n // A function can run while the server renders, such as one that the markup calls. The render\n // waits only for the memos that the markup reads, so the function reads its memos itself.\n for (const site of sites) {\n if (site.kind === 'function') {\n readMemos(site, site.node as oxc.Node);\n }\n }\n // A memo that the render waits for without `await` holds its error until a read, so the\n // markup reads it in place, and the `#try` around the read gets the error.\n if (lazy.size > 0) {\n for (const site of sites) {\n if (site.kind !== 'function' && site.kind !== 'memo') {\n readMemos(site, site.node as oxc.Node, undefined, lazy);\n }\n }\n }\n }\n function 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 // A rest prop leaves out the props that another `$props()` call names.\n const others = names && restCalls.has(node) ? otherNames(node) : [];\n // The scope of the component collects the promise props, so the page state can tell them\n // from the memos that stream. It is passed here since the call can follow an `await`.\n const sink =\n component === undefined\n ? ''\n : `${mode === 'server' ? '$$ctx' : '$$b'}.sink($$s${component})`;\n // Arguments the call leaves out are `undefined` when a later one follows.\n const list = ['$$props', names ? JSON.stringify(names) : 'undefined'];\n list.push(others.length > 0 ? JSON.stringify(others) : 'undefined');\n list.push(sink || 'undefined');\n while (list.at(-1) === 'undefined') {\n list.pop();\n }\n const code = `$$b.unbind(${list.join(', ')})`;\n patch.replace(node.start, node.end, code);\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 === '$searchParam' && argument) {\n // The server reads the URL of the request, and the browser reads `location`.\n patch.replace(\n node.start,\n argument.start,\n mode === 'server' ? '$$b.searchParam($$ctx, ' : '$$b.searchParam(',\n );\n for (const rest of node.arguments) {\n visit(rest);\n }\n return;\n }\n if (name === '$isBound') {\n // Nothing writes on the server.\n patch.replace(node.start, node.end, 'false');\n return;\n }\n if (name === '$resolve' && argument) {\n // The server has the value, or waits for it where it reads it.\n patch.replace(node.start, argument.start, 'Promise.resolve(');\n patch.replace(argument.end, node.end, ')');\n visit(argument);\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 readMemos(site!, argument, declaration);\n let open = site!.awaits ? '$$b.memo(async () => (' : '$$b.memo(() => (';\n if (declaration.gate) {\n // A promise is an error here, held until a read.\n open = '$$b.memo(() => $$b.gateValue(';\n }\n patch.replace(node.start, argument.start, open);\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 (mode === 'render' && declaration?.gate) {\n // A promise is an error here, held until a read.\n patch.replace(node.start, argument.start, '$$b.renderMemo(() => $$b.gateValue(');\n patch.replace(argument.end, node.end, '))');\n } else if (mode === 'render' && declaration && !isPlainMemo(site!, argument)) {\n // The render runs the memo through a helper, which holds a throw as a rejected promise\n // and marks a promise, so `setSlots` starts the load.\n patch.replace(\n node.start,\n argument.start,\n site!.awaits ? '$$b.renderMemo(async () => (' : '$$b.renderMemo(() => (',\n );\n patch.replace(argument.end, node.end, '))');\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 let inScript = false;\n for (const program of programs) {\n if (site.node.start >= program.start && site.node.end <= program.end) {\n inScript = true;\n break;\n }\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 '$resolve',\n '$isBound',\n '$isPassed',\n '$id',\n '$getContext',\n '$setContext',\n '$store',\n '$toStore',\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 function 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 function 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 function 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 const shared = new Map<number, SharedSite>();\n for (const [offset, { site }] of analyze(module).sites) {\n shared.set(offset, site);\n }\n return shared;\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 function 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: string[] = [];\n for (const local of usedDeclarations) {\n if (info.declarations.get(local)) {\n own.push(local);\n }\n }\n if (own.length > 0) {\n const exported = [...(bySpecifier.get(self) ?? [])];\n for (const local of own) {\n exported.push(\n info.declarations.get(local) === local\n ? local\n : `${info.declarations.get(local)} as ${local}`,\n );\n }\n bySpecifier.set(self, exported);\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 type { Range } from './ast.ts';\nimport { upstreamMemos } from './model.ts';\nimport type { Declaration, Site } from './model.ts';\nimport { children, getPatternNames } from './oxc.ts';\nimport type { oxc } from './oxc.ts';\n\n/** Reports a read that the compiler rejects, with the message and the place. */\ntype Report = (message: string, at: Range) => void;\n\n/** The message of a read of `name` that can lack a value. */\nexport function pendingReadMessage(name: string): string {\n return `The handler reads \"${name}\", a memo that can lack a value. Wait for it with await $resolve(${name}), or check $isPending(${name}) first`;\n}\n\n/** True for a memo that loads: it calls a server function, or awaits. */\nfunction isAsync(declaration: Declaration): boolean {\n if (declaration.kind === 'async-memo') {\n return true;\n }\n for (const read of declaration.site?.reads ?? []) {\n if (read.declaration.serverImport !== undefined) {\n return true;\n }\n }\n return false;\n}\n\n/** The starts of the memo names in `$isPending(…)` and `$resolve(…)` calls of the file. */\nlet checkedStarts: Set<number> = new Set();\n\n/** The sites that render markup, which the server waits for outside `#loading`. */\nconst MARKUP_SITES = new Set<Site['kind']>([\n 'insert',\n 'attribute',\n 'tag',\n 'spread',\n 'style',\n 'block',\n 'title',\n 'prop',\n]);\n\n/** True when a scope is inside a `#loading` or `#defer` body, where the server does not wait. */\nfunction inStreamedBody(site: Site): boolean {\n for (let scope: Site['scope'] | undefined = site.scope; scope; scope = scope.parent) {\n if (scope.block?.kind === 'loading' || scope.block?.kind === 'defer') {\n return true;\n }\n }\n return false;\n}\n\n/**\n * True when the server waited for the memo, so a page it rendered has the value: markup outside\n * `#loading` reads it, or a memo that is such a read does.\n */\nfunction waitedFor(declaration: Declaration, seen = new Set<Declaration>()): boolean {\n if (seen.has(declaration)) {\n return false;\n }\n seen.add(declaration);\n for (const read of declaration.reads) {\n // `$isPending` and `$resolve` do not read the value, and add reads with no range.\n if (read.range.start === read.range.end || checkedStarts.has(read.range.start)) {\n continue;\n }\n const site = read.site;\n const isHandlerProp =\n site.kind === 'prop' &&\n (site.handlerProp === true ||\n site.node.type === 'ArrowFunctionExpression' ||\n site.node.type === 'FunctionExpression');\n if (MARKUP_SITES.has(site.kind) && !isHandlerProp && !inStreamedBody(site)) {\n return true;\n }\n if (site.kind === 'memo' && site.declaration && waitedFor(site.declaration, seen)) {\n return true;\n }\n }\n return false;\n}\n\n/** True for a memo that loads and that nothing waits for. */\nfunction loads(memo: Declaration): boolean {\n return !memo.awaited && isAsync(memo) && !waitedFor(memo);\n}\n\n/**\n * True for a memo that can lack a value in the browser: it is async, or it reads an async memo, and\n * neither the server waited for it nor `await $memo(…)` declares it.\n */\nfunction lacksValue(declaration: Declaration): boolean {\n if (declaration.awaited || declaration.kind === 'prop') {\n return false;\n }\n if (declaration.kind === 'async-memo' || declaration.kind === 'memo') {\n if (loads(declaration)) {\n return true;\n }\n for (const memo of upstreamMemos(declaration)) {\n if (loads(memo)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/** The sites whose code runs from an event: handlers, `$client` callbacks and handler props. */\nfunction isRoot(site: Site): boolean {\n return site.kind === 'event' || site.kind === 'client' || site.handlerProp === true;\n}\n\n/**\n * Reports each read of a memo that can lack a value in code that runs from an event: a handler,\n * a handler prop of a component, a `$client` callback, and the functions of the same script that\n * they call. A read is fine after `$isPending(memo)` of the memo, or of a memo that reads it.\n */\nexport function checkPendingReads(\n sites: Site[],\n pendingCalls: { reference: { range: Range; declaration: Declaration } }[],\n report: Report,\n): void {\n // `$isPending(name)` calls by the start of their argument.\n const pending = new Map<number, Declaration>();\n for (const { reference } of pendingCalls) {\n pending.set(reference.range.start, reference.declaration);\n }\n checkedStarts = new Set(pending.keys());\n const done = new Set<Site>();\n const reported = new Set<number>();\n function visit(site: Site): void {\n if (done.has(site)) {\n return;\n }\n done.add(site);\n for (const read of site.reads) {\n const declaration = read.declaration;\n // The argument of `$isPending`, the reads that it adds for the memos upstream, and the read\n // of its source that a write of `$optimistic` adds (at the source's declaration).\n if (\n read.range.start === read.range.end ||\n read.range.start === declaration.range.start ||\n pending.has(read.range.start) ||\n !lacksValue(declaration) ||\n reported.has(read.range.start)\n ) {\n continue;\n }\n if (!isGuarded(site.node, read.range.start, declaration, pending)) {\n reported.add(read.range.start);\n report(pendingReadMessage(declaration.name), read.range);\n }\n }\n for (const called of site.calls) {\n if (called.kind === 'function' && called.site) {\n visit(called.site);\n }\n }\n }\n for (const site of sites) {\n if (isRoot(site)) {\n visit(site);\n }\n }\n}\n\n/** True when `$isPending` of `guard` tells whether `memo` has a value. */\nfunction covers(guard: Declaration, memo: Declaration): boolean {\n return guard === memo || upstreamMemos(guard).includes(memo);\n}\n\n/**\n * What a test says about a memo: `pending` when it is true while the memo loads, `ready` when it\n * is true once the memo has a value. `aliases` holds the constants of the blocks around the read,\n * such as `const loading = $isPending(memo)`.\n */\nfunction condition(\n test: oxc.Node,\n memo: Declaration,\n pending: Map<number, Declaration>,\n aliases: Map<string, oxc.Node>,\n): 'pending' | 'ready' | undefined {\n switch (test.type) {\n case 'Identifier': {\n const alias = aliases.get(test.name);\n return alias ? condition(alias, memo, pending, new Map()) : undefined;\n }\n case 'CallExpression': {\n if (test.callee.type === 'Identifier' && test.callee.name === '$isPending') {\n // Pending while any of the memos loads, so no memo loads when it is false.\n for (const target of test.arguments) {\n const guard = pending.get(target.start);\n if (guard && covers(guard, memo)) {\n return 'pending';\n }\n }\n }\n return undefined;\n }\n case 'UnaryExpression': {\n if (test.operator !== '!') {\n return undefined;\n }\n const inner = condition(test.argument, memo, pending, aliases);\n if (inner === 'pending') {\n return 'ready';\n }\n return inner === 'ready' ? 'pending' : undefined;\n }\n case 'LogicalExpression': {\n const left = condition(test.left, memo, pending, aliases);\n const right = condition(test.right, memo, pending, aliases);\n // `a || b` is true when a guard is pending, and `a && b` only when a guard is ready.\n if (test.operator === '||') {\n return left === 'pending' || right === 'pending' ? 'pending' : undefined;\n }\n if (test.operator === '&&') {\n return left === 'ready' || right === 'ready' ? 'ready' : undefined;\n }\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/** True when a statement always leaves the function, the loop or the case around it. */\nfunction exits(statement: oxc.Node): boolean {\n if (\n statement.type === 'ReturnStatement' ||\n statement.type === 'ThrowStatement' ||\n statement.type === 'ContinueStatement' ||\n statement.type === 'BreakStatement'\n ) {\n return true;\n }\n if (statement.type === 'BlockStatement') {\n const last = statement.body.at(-1);\n return last !== undefined && exits(last);\n }\n return false;\n}\n\n/** True when the node is `await $resolve(m)` for a memo that covers `memo`. */\nfunction isResolveFor(\n node: oxc.Node,\n memo: Declaration,\n pending: Map<number, Declaration>,\n): boolean {\n if (\n node.type === 'AwaitExpression' &&\n node.argument.type === 'CallExpression' &&\n node.argument.callee.type === 'Identifier' &&\n node.argument.callee.name === '$resolve'\n ) {\n const target = node.argument.arguments[0];\n const guard = target && pending.get(target.start);\n return guard !== undefined && covers(guard, memo);\n }\n return false;\n}\n\n/**\n * True when a statement of a block always waits with `await $resolve(…)` for a memo that covers\n * `memo`: it is the statement itself, the value of an assignment or a declaration, or read from\n * it. An await inside a condition, a logical expression or a `try` may not run.\n */\nfunction alwaysAwaits(\n node: oxc.Node,\n memo: Declaration,\n pending: Map<number, Declaration>,\n): boolean {\n switch (node.type) {\n case 'ExpressionStatement':\n return alwaysAwaits(node.expression, memo, pending);\n case 'VariableDeclaration':\n for (const declarator of node.declarations) {\n if (declarator.init && alwaysAwaits(declarator.init, memo, pending)) {\n return true;\n }\n }\n return false;\n case 'AssignmentExpression':\n return alwaysAwaits(node.right, memo, pending);\n case 'MemberExpression':\n return alwaysAwaits(node.object, memo, pending);\n case 'AwaitExpression':\n return isResolveFor(node, memo, pending);\n default:\n return false;\n }\n}\n\n/** Finds the chain of nodes from `root` to the identifier that starts at `start`. */\nfunction pathTo(root: oxc.Node, start: number): oxc.Node[] | undefined {\n if (root.start > start || root.end <= start) {\n return undefined;\n }\n if (root.type === 'Identifier' && root.start === start) {\n return [root];\n }\n for (const [, child] of children(root)) {\n const path = pathTo(child, start);\n if (path) {\n return [root, ...path];\n }\n }\n return undefined;\n}\n\n/** True when a guard on `memo` comes before the read that starts at `start` in `root`. */\nfunction isGuarded(\n root: oxc.Node,\n start: number,\n memo: Declaration,\n pending: Map<number, Declaration>,\n): boolean {\n const path = pathTo(root, start);\n if (!path) {\n return false;\n }\n // The constants of the blocks around the read, such as `const loading = $isPending(memo)`.\n const aliases = new Map<string, oxc.Node>();\n for (let i = 0; i < path.length - 1; i++) {\n const node = path[i]!;\n const child = path[i + 1]!;\n // A parameter of a function that the read is in hides a constant of the same name outside it.\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n for (const param of node.params) {\n for (const name of getPatternNames(param)) {\n aliases.delete(name.name);\n }\n }\n }\n if (node.type === 'BlockStatement' || node.type === 'Program') {\n for (const statement of node.body) {\n if (statement === child) {\n break;\n }\n if (statement.type === 'VariableDeclaration' && statement.kind === 'const') {\n for (const declarator of statement.declarations) {\n if (declarator.id.type === 'Identifier' && declarator.init) {\n aliases.set(declarator.id.name, declarator.init);\n }\n }\n }\n }\n for (const statement of node.body) {\n if (statement === child) {\n break;\n }\n // An earlier `if ($isPending(memo)) return;`, or `await $resolve(memo)`.\n if (\n statement.type === 'IfStatement' &&\n exits(statement.consequent) &&\n condition(statement.test, memo, pending, aliases) === 'pending'\n ) {\n return true;\n }\n if (alwaysAwaits(statement, memo, pending)) {\n return true;\n }\n }\n }\n }\n for (let i = 0; i < path.length - 1; i++) {\n const node = path[i]!;\n const child = path[i + 1]!;\n if (\n (node.type === 'IfStatement' || node.type === 'ConditionalExpression') &&\n child !== node.test\n ) {\n const kind = condition(node.test, memo, pending, aliases);\n if (\n (child === node.consequent && kind === 'ready') ||\n (child === node.alternate && kind === 'pending')\n ) {\n return true;\n }\n } else if (node.type === 'LogicalExpression' && child === node.right) {\n const kind = condition(node.left, memo, pending, aliases);\n if (\n (node.operator === '&&' && kind === 'ready') ||\n (node.operator === '||' && kind === 'pending')\n ) {\n return true;\n }\n }\n }\n return false;\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 CSS of every `<style>` block, scoped except `<style global>`, or an empty string. */\n css: string;\n /** The attribute that marks the component's elements, such as `b-c-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 for (const target of targets) {\n if (target.tag !== undefined && lower !== undefined && target.tag !== lower) {\n continue;\n }\n if (classes === undefined) {\n return true;\n }\n let hasClasses = true;\n for (const name of target.classes) {\n if (!classes.includes(name)) {\n hasClasses = false;\n break;\n }\n }\n if (hasClasses) {\n return true;\n }\n }\n return false;\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`. With `unscoped`, no\n * compound is scoped, and `:global(…)` is only unwrapped.\n */\nfunction scopeSelector(attribute: string, targets: ScopeTarget[], unscoped: boolean) {\n return 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: selectorParser.Selector[] = [];\n for (let item = 0; item < items.length; 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 copies.push(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 let global: selectorParser.Pseudo | undefined;\n for (const node of compound) {\n if (node.type === 'pseudo' && node.value === ':global') {\n global = node;\n break;\n }\n }\n if (global) {\n // `:global(.a)` becomes `.a`, without the scope.\n const inner = global.nodes[0]?.nodes ?? [];\n const clones: selectorParser.Node[] = [];\n for (const node of inner) {\n clones.push(node.clone());\n }\n global.replaceWith(...clones);\n continue;\n }\n if (compound.length === 0 || unscoped) {\n continue;\n }\n targets.push(scopeTarget(compound));\n // The attribute goes before pseudo-elements such as `::before`.\n let last: SelectorPart | undefined;\n for (let at = compound.length - 1; at >= 0; at--) {\n const node = compound[at]!;\n if (!(node.type === 'pseudo' && node.value.startsWith('::'))) {\n last = node;\n break;\n }\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}\n\nfunction scopeRules(\n root: Root,\n attribute: string,\n targets: ScopeTarget[],\n unscoped: boolean,\n): void {\n const processor = scopeSelector(attribute, targets, unscoped);\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 // Under `b-`, which the compiler reserves, so markup and data cannot write it.\n const attribute = `b-c-${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 = `--s-${scope}-${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, style.global);\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 {\n Block,\n Body,\n ComponentNode,\n DynamicTagNode,\n ElementNode,\n InsertNode,\n Markup,\n SFCFile,\n} 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 { forEachNode } from './project.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 /**\n * The children of each component and dynamic tag, which the browser renders each time the\n * component inserts them: the export of their render, such as `n0`, and their scope.\n */\n childrenRenders: Map<ComponentNode | DynamicTagNode, { symbol: string; scope: Scope }>;\n /**\n * The component whose children hold a block, for the blocks in children. The browser renders\n * the new bodies of such a block with the contexts of that component, as the server does.\n */\n blockHolders: Map<Block, { node: ComponentNode; scope: Scope }>;\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/** True if the range lies inside one of the ranges. */\nfunction isInRanges(ranges: { start: number; end: number }[], start: number, end: number): boolean {\n for (const range of ranges) {\n if (range.start <= start && end <= range.end) {\n return true;\n }\n }\n return false;\n}\n\n/** True if one of the items is at a site of the set. */\nfunction hasSiteIn(items: { site: Site }[], sites: Set<Site>): boolean {\n for (const item of items) {\n if (sites.has(item.site)) {\n return true;\n }\n }\n return false;\n}\n\n/** True if the declaration is a prop, or is referenced from a dynamic tag. */\nfunction hasDynamicRef(declaration: Declaration): boolean {\n for (const ref of declaration.refs) {\n if (declaration.kind === 'prop' || ref.element.kind === 'dynamic') {\n return true;\n }\n }\n return false;\n}\n\n/** The children without the text that is only whitespace. */\nfunction withoutBlankText(children: Markup[]): Markup[] {\n const kept: Markup[] = [];\n for (const child of children) {\n if (child.kind !== 'text' || cleanText(child.value) !== '') {\n kept.push(child);\n }\n }\n return kept;\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 for (const child of node.children) {\n const allowed =\n child.kind === 'text'\n ? cleanText(child.value).trim() === ''\n : child.kind === 'element' && ['td', 'th'].includes(child.tag.toLowerCase());\n if (!allowed) {\n return false;\n }\n }\n return true;\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 let name = '';\n for (const part of base.split(/[^A-Za-z0-9]+/)) {\n if (part) {\n name += part[0]!.toUpperCase() + part.slice(1);\n }\n }\n return /^\\d/.test(name) ? `Component${name}` : name || 'Component';\n}\n\n/**\n * The name of the function that a component compiles to: its name, or the name with `$` when a\n * script of the file has a top-level name of its own, such as an import of `ButtonContext` in\n * `button-context.brm`.\n */\nexport function componentFunctionName(file: SFCFile, name: string): string {\n const taken = new Set<string>();\n for (const script of [file.moduleScript, file.instanceScript]) {\n for (const statement of script?.program.body ?? []) {\n if (statement.type === 'ImportDeclaration') {\n for (const specifier of statement.specifiers ?? []) {\n taken.add(specifier.local.name);\n }\n } else if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n if (declarator.id.type === 'Identifier') {\n taken.add(declarator.id.name);\n }\n }\n } else if (\n (statement.type === 'FunctionDeclaration' || statement.type === 'ClassDeclaration') &&\n statement.id\n ) {\n taken.add(statement.id.name);\n }\n }\n }\n let result = name;\n while (taken.has(result)) {\n result += '$';\n }\n return result;\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 */\n/**\n * The components and dynamic tags of a file that have children. The server sends their children\n * as a reference to a render of the browser, so each insert makes new scopes, as a block does.\n */\nexport function childrenHolders(file: SFCFile): (ComponentNode | DynamicTagNode)[] {\n const found: (ComponentNode | DynamicTagNode)[] = [];\n function visit(node: Markup): void {\n if ((node.kind === 'component' || node.kind === 'dynamic') && node.children.length > 0) {\n found.push(node);\n }\n }\n forEachNode(file.children, visit);\n for (const template of file.templates) {\n forEachNode(template.body.children, visit);\n }\n return found;\n}\n\nexport function clientState(\n graph: Graph,\n file?: SFCFile,\n): {\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 function isLiveSite(site: Site): boolean {\n return siteNodes.get(site) === true;\n }\n\n // Code on the client: reached sites, live nodes, and the functions they call.\n const clientSites = new Set<Site>();\n function 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 // The browser runs a source of `$store` again on resume, with the values it reads.\n for (const site of model.storeSources) {\n addClientSite(site);\n }\n // Children render in the browser each time a component inserts them, so their code is there.\n const ranges: { start: number; end: number }[] = [];\n for (const node of file ? childrenHolders(file) : []) {\n ranges.push({ start: node.children[0]!.start, end: node.children.at(-1)!.end });\n }\n if (ranges.length > 0) {\n for (const site of model.sites) {\n const node = site.node as { start?: number; end?: number };\n if (\n node.start !== undefined &&\n node.end !== undefined &&\n isInRanges(ranges, node.start, node.end)\n ) {\n addClientSite(site);\n }\n }\n }\n // The update of a block reads all of its header, such as each condition of `#if` and\n // `#else if`, when one of them changes. So a condition that never changes, such as one of\n // `$isPassed`, is read in the browser too.\n const liveBlocks = new Set<Block>();\n for (const site of clientSites) {\n if (site.block) {\n liveBlocks.add(site.block);\n }\n }\n for (const site of model.sites) {\n if (site.block && liveBlocks.has(site.block)) {\n addClientSite(site);\n }\n }\n // The spreads of an element update together, so a spread that never changes, such as a rest\n // prop, is read in the browser when another spread of the same element changes. Without it,\n // the update would remove the attributes that it gives, such as a class. An attribute of the\n // element that changes reads them too, as a class of the element adds the class of a spread.\n const liveSpreads = new Set<Site['owner']>();\n for (const site of clientSites) {\n if ((site.kind === 'spread' || site.kind === 'attribute') && site.owner) {\n liveSpreads.add(site.owner);\n }\n }\n for (const site of model.sites) {\n if (site.kind === 'spread' && site.owner && liveSpreads.has(site.owner)) {\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 const needed: Declaration[] = [];\n for (const declaration of scope.declarations.values()) {\n if (\n !NO_SLOT.has(declaration.kind) &&\n (hasSiteIn(declaration.reads, clientSites) ||\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 // A `let` of `$store` keeps the setter that writes the store in its slot.\n declaration.store?.write === true ||\n // A prop forwards its element to the parent through its slot, and a dynamic tag\n // passes the slot of its signal to a component.\n hasDynamicRef(declaration) ||\n (declaration.kind === 'prop' &&\n declaration.writable === true &&\n hasSiteIn(declaration.writes, clientSites)))\n ) {\n needed.push(declaration);\n }\n }\n slots.set(scope, needed);\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, file);\n const blockHolders = new Map<Block, { node: ComponentNode; scope: Scope }>();\n // The components whose children are being visited, innermost last.\n const holders: ComponentNode[] = [];\n const holderScopes = new Map<ComponentNode, Scope>();\n const childrenRenders = new Map<\n ComponentNode | DynamicTagNode,\n { symbol: string; scope: Scope }\n >();\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>();\n for (const binding of model.bindings) {\n boundCalls.add(binding.call);\n }\n const anchors = new Map<AnchorTarget, number>();\n const anchorScopes = new Map<AnchorTarget, Scope>();\n function 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 function 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 function visitNodes(nodes: Markup[], scope: Scope, outer?: Scope): void {\n for (const node of nodes) {\n visitNode(node, scope, outer);\n }\n }\n\n function 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 let hasRef = false;\n for (const attribute of node.attributes) {\n const target = attribute.kind === 'ref' ? refTargets.get(attribute) : undefined;\n if (target !== undefined && slotted.has(target)) {\n hasRef = true;\n break;\n }\n }\n const content = node.kind === 'element' ? liveContent(node) : undefined;\n let events = false;\n for (const site of sites) {\n if (site.kind === 'event') {\n events = true;\n break;\n }\n }\n // `value=$bind(name)`: the core finds the scope of the name from the anchor of the element.\n let bound = false;\n if (node.kind === 'element') {\n for (const attribute of node.attributes) {\n if (attribute.kind === 'value' && boundCalls.has(unparen(attribute.value.ast))) {\n bound = true;\n break;\n }\n }\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 hasLiveSite(sites) ||\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 if (node.children.length > 0) {\n childrenRenders.set(node, { symbol: `n${childrenRenders.size}`, scope });\n }\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 (hasLiveSite(sites)) {\n anchor(scope, node);\n }\n if (node.children.length > 0) {\n childrenRenders.set(node, { symbol: `n${childrenRenders.size}`, scope });\n }\n // Children render inside the component's elements.\n holders.push(node);\n holderScopes.set(node, scope);\n visitNodes(node.children, scope);\n holders.pop();\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 function 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 /** True if one of the sites is live. */\n function hasLiveSite(sites: Site[]): boolean {\n for (const site of sites) {\n if (isLiveSite(site)) {\n return true;\n }\n }\n return false;\n }\n\n /** True if the scope has a `$client` callback. */\n function hasClientSite(scope: Scope): boolean {\n for (const site of model.sites) {\n if (site.kind === 'client' && site.scope === scope) {\n return true;\n }\n }\n return false;\n }\n\n /** The live insert that is the whole content of an element, if any. */\n function liveContent(node: ElementNode): InsertNode | undefined {\n const [only, ...rest] = withoutBlankText(node.children);\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 function 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 renders the items of a windowed list as they come into view.\n (block.kind === 'for' && block.window !== undefined) ||\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) ||\n tryCatchesClient(model, block) ||\n holdsStream(block))) ||\n hasLiveSite(headerSites.get(block) ?? []);\n if (live) {\n anchor(scope, block);\n // The component around it finds its scope by its anchor, for the contexts of its bodies.\n const holder = holders.at(-1);\n if (holder) {\n const holderScope = holderScopes.get(holder)!;\n blockHolders.set(block, { node: holder, scope: holderScope });\n if (!anchors.has(holder)) {\n anchor(holderScope, holder);\n }\n }\n }\n if (block.kind === 'try' && tryCatchesClient(model, block)) {\n // An error in client code finds its `#try` by the scope kinds above it, and the scope of\n // a child component has no other link to the body.\n scopes.get(bodyScopes.get(block.body)!)!.needsId = true;\n }\n if (live && (block.kind === 'offscreen' || block.kind === 'loading')) {\n // The client hides and shows the body's instance, and pauses the effects inside it. A\n // `#loading` block with a header hides its body while a memo of the header loads.\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 function singleRoot(body: Body): Markup | undefined {\n const scope = bodyScopes.get(body)!;\n // `$client` callbacks render `<template>` markers next to the markup.\n if (body.templates.length > 0 || hasClientSite(scope)) {\n return undefined;\n }\n const [only, ...rest] = withoutBlankText(body.children);\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 function 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 for (const declaration of plan.scope.declarations.values()) {\n if (declaration.idIndex !== undefined) {\n plan.needsId = true;\n break;\n }\n }\n }\n\n const styles = compileStyles(file, hash(file.filename), path);\n let liveStyles = false;\n for (const site of model.sites) {\n if (site.kind === 'style' && isLiveSite(site)) {\n liveStyles = true;\n break;\n }\n }\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 childrenRenders,\n blockHolders,\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 const children: Markup[] = [];\n for (const body of blockBodies(node)) {\n children.push(...body.children);\n }\n return children;\n }\n}\n\n/**\n * True if the body of a `#try` holds a `#loading` block or a component, which can hold one. A\n * body of it that fails after the page is sent renders the `#catch` body in place of the `#try`\n * body, so the block needs its markers.\n */\nexport function holdsStream(block: Block & { kind: 'try' }): boolean {\n let found = false;\n forEachNode(block.body.children, (node) => {\n found ||= node.kind === 'component' || node.kind === 'dynamic' || node.kind === 'loading';\n });\n return found;\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 const bodies: Body[] = [];\n for (const branch of block.branches) {\n bodies.push(branch.body);\n }\n if (block.fallback) {\n bodies.push(block.fallback);\n }\n return bodies;\n }\n case 'switch': {\n const bodies: Body[] = [];\n for (const branch of block.cases) {\n bodies.push(branch.body);\n }\n if (block.fallback) {\n bodies.push(block.fallback);\n }\n return bodies;\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\n/**\n * The arguments that tell the core which component holds a block in its children: the kind of the\n * scope that renders the component and its anchor. Empty for a block outside children.\n */\nexport function holderArguments(plan: Plan, block: Block): string {\n const holder = plan.blockHolders.get(block);\n const anchor = holder && plan.anchors.get(holder.node);\n return holder && anchor !== undefined ? `, ${holder.scope.id}, ${anchor}` : '';\n}\n","// Cloned templates of the markup that the browser renders. A render whose markup is one string\n// of static HTML, attributes, the content of elements, and anchors compiles to a `<template>`\n// that it clones, and writes the elements that it marks. The rest renders HTML.\nimport type { Markup, SFCFile } from '../ast.ts';\nimport { blockBodies } from '../plan.ts';\nimport type { Emitter, Level, Part, Settled } from './markup.ts';\n\nconst contexts = new WeakMap<SFCFile, Map<object, string | undefined>>();\n\n/**\n * `svg` or `math` when the elements around a body, or around the children of a component, put\n * its markup in SVG or MathML, which HTML that the browser parses there would find at run time.\n * `owner` is the body, or the component or dynamic tag that the children belong to.\n */\nexport function foreignContext(file: SFCFile, owner: object | undefined): string | undefined {\n if (!owner) {\n return undefined;\n }\n let found = contexts.get(file);\n if (!found) {\n found = new Map();\n contexts.set(file, found);\n const map = found;\n const walk = (nodes: Markup[], around: string | undefined): void => {\n for (const node of nodes) {\n switch (node.kind) {\n case 'element': {\n const tag = node.tag.toLowerCase();\n let inside = around;\n if (tag === 'svg' || tag === 'math') {\n inside = tag;\n } else if (tag === 'foreignobject') {\n inside = undefined;\n }\n walk(node.children, inside);\n break;\n }\n case 'component':\n case 'dynamic':\n map.set(node, around);\n walk(node.children, around);\n break;\n case 'fragment':\n walk(node.children, around);\n break;\n case 'text':\n case 'insert':\n case 'listener':\n break;\n default:\n for (const body of blockBodies(node)) {\n map.set(body, around);\n walk(body.children, around);\n }\n }\n }\n };\n walk(file.children, undefined);\n }\n return found.get(owner);\n}\n\n/** What a render writes on an element of its clone. */\nexport type Write =\n /** `named`: an element inside it has handlers and no anchor, and finds the scope from it. */\n | { kind: 'anchor'; scope: string; anchor: number; named?: boolean }\n /** `promise`: the scope of a value that can be a promise, which is written once it settles. */\n | { kind: 'attribute'; name: string; value: string; settled?: Settled; promise?: string }\n | { kind: 'content'; value: string; at?: string; settled?: Settled; promise?: string }\n /** A text insert, whose place in the clone a marked comment holds. */\n | { kind: 'text'; scope: string; anchor: number; value: string; at?: string; promise?: string }\n /** A text insert at the end of the marked element, which needs no comment. */\n | { kind: 'last'; scope: string; anchor: number; value: string; at?: string; promise?: string }\n /** A nested block, whose start comment the clone marks, and which a call fills. */\n | { kind: 'block'; scope: string; anchor: number }\n /** A child component or a dynamic tag, which renders in the place of a marked comment. */\n | { kind: 'component'; call: string; settled?: Settled }\n /** The attributes of spreads on the marked element, and then its `b-on`. */\n | { kind: 'call'; call: string; promise?: string }\n /** A comment whose data names a scope, such as the start of an item, `i` and the scope. */\n | { kind: 'comment'; data: string }\n /** A value with no markers around it, which renders in the place of a marked comment. */\n | { kind: 'put'; value: string; at?: string; settled?: Settled; promise?: string }\n /** The start comment of a block whose markup is in the template, which the scope keeps. */\n | { kind: 'marker'; scope: string; anchor: number; suffix: string };\n\nexport interface ClonedTemplate {\n /** `svg` or `math` when the markup starts with an element of SVG or MathML outside one. */\n foreign?: string;\n /**\n * The static HTML of the template. Each element that the render writes has `b-x` with its\n * index, which the browser reads, and removes, when it parses the template. A text insert is\n * a comment, `<!--x` and its index, which the clone replaces with a text node.\n */\n html: string;\n /** Whether the insert of a clone indexes its markers and starts its `<template>` elements. */\n indexed?: true;\n /** The writes on the marked elements, by their index. */\n writes: Write[][];\n}\n\nconst ATTRIBUTE = /^\\$\\$b\\.attribute\\((\"(?:[^\"\\\\]|\\\\.)*\"), ([\\s\\S]*)\\)$/;\n// A class that a condition adds to others, `cond ? \" name\" : \"\"`, with no character references.\nconst CLASS_TOKEN = /^\\(\\(([\\s\\S]*)\\) \\? \" ([^\"\\\\&<>]+)\" : \"\"\\)$/;\n\n/**\n * The static classes of a `class` with code in its quotes, and the calls that add the classes\n * that conditions add, when each piece of code is such a condition and no static class follows\n * one, so the classes keep their order. `parts` are the parts of\n * the value after its static `prefix`, up to its closing quote.\n */\nfunction classTokens(parts: Part[], prefix: string): { text: string; calls: string[] } | undefined {\n let text = prefix;\n const calls: string[] = [];\n for (const part of parts) {\n if ('static' in part) {\n // `classList.add` puts a class last, so a class after a condition cannot go in the template.\n if (calls.length > 0 && part.static.trim() !== '') {\n return undefined;\n }\n text += part.static;\n continue;\n }\n const token = CLASS_TOKEN.exec(part.code);\n if (!token) {\n return undefined;\n }\n const names: string[] = [];\n for (const name of token[2]!.trim().split(/\\s+/)) {\n names.push(JSON.stringify(name));\n }\n calls.push(`(${token[1]}) && $$m.classList.add(${names.join(', ')})`);\n }\n return /[&<>\"]/.test(text) ? undefined : { text: text.trim().replace(/\\s+/g, ' '), calls };\n}\n\n// An attribute that a condition adds, with a value that has no character references.\nconst CONDITIONAL = /^\\(\\(([\\s\\S]*)\\) \\? \" ([\\w:-]+)=\\\\\"([^\"\\\\&]*)\\\\\"\" : \"\"\\)$/;\n// The spreads of an element, and its `b-on` with the handlers of the spreads.\nconst SPREAD = /^\\$\\$b\\.(spread|onAttribute)\\(([\\s\\S]*)\\)$/;\n// `$$b.insert(value)`, or `$$b.insert(value, undefined, scope)`, whose value can be children or\n// a template, which render where they are inserted with the contexts of the scope.\nconst INSERT = /^\\$\\$b\\.insert\\(([\\s\\S]*?)(?:, undefined, ([\\w$.]+))?\\)$/;\n// A scope ID: of a scope that the render makes, or of an instance, such as the parent of children.\nconst SCOPE = /^\\$\\$(?:s\\d+|s\\d+\\.id|p\\.id)$/;\nconst ANCHOR_START = ' b-b=\"';\nconst ANCHOR_END = /^:(\\d+)\"/;\nconst TEXT_START = '<!--t';\nconst TEXT_END = /^:(\\d+)-->/;\nconst TEXT_CLOSE = '<!--/t-->';\nconst BLOCK_START = '<!--b';\nconst COMPONENT = /^\\$\\$b\\.component\\(/;\nconst DYNAMIC = /^\\$\\$b\\.dynamic\\(/;\n// The nodes of a block that renders where it is.\nconst NODES = /^\\$\\$b\\.nodes\\(([\\s\\S]*)\\)$/;\n// The rest of the start comment of a block: `:anchor`, maybe `:index`, and `-->`.\nconst MARKER_END = /^:(\\d+)((?::-?\\d+)?)-->/;\nconst BLOCK_END = /^:(\\d+)(?::-1)?--><!--\\/b-->/;\n\nconst VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;\n\n/** Elements of SVG and of MathML that HTML has no element of its own for. */\nconst SVG_ONLY = new Set(\n 'animate animatemotion animatetransform circle clippath defs desc ellipse feblend fecolormatrix fecomponenttransfer fecomposite feconvolvematrix fediffuselighting fedisplacementmap fedistantlight fedropshadow feflood fefunca fefuncb fefuncg fefuncr fegaussianblur feimage femerge femergenode femorphology feoffset fepointlight fespecularlighting fespotlight fetile feturbulence filter foreignobject g image line lineargradient marker mask metadata mpath path pattern polygon polyline radialgradient rect stop switch symbol text textpath tspan use view'.split(\n ' ',\n ),\n);\nconst MATH_ONLY = new Set(\n 'annotation maction menclose merror mfenced mfrac mi mmultiscripts mn mo mover mpadded mphantom mroot mrow ms mspace msqrt mstyle msub msubsup msup mtable mtd mtext mtr munder munderover semantics'.split(\n ' ',\n ),\n);\n\n/** Elements whose content is text that the parser keeps as it is, or that hold no markup. */\nconst RAW_TEXT = /^(?:script|style|textarea|title|template|noscript|xmp|iframe|noembed|noframes)$/;\n\n/**\n * Follows HTML as it is written, so the template knows where each element starts and whether it\n * is in a start tag. Quoted attribute values and comments can hold `<` and `>`.\n */\nclass Reader {\n html = '';\n /** In the start tag of `element`, before its `>`. */\n inTag = false;\n /** The start tag of `element` ended last, with nothing after it yet. */\n justOpened = false;\n /** The number of the element that started last, in the order of the markup. */\n element = -1;\n /** Where its start tag can take another attribute: after its name. */\n nameEnd = -1;\n /** Whether the element that started last has a raw text content, such as a `<textarea>`. */\n raw = false;\n /** The elements that are open, innermost last. */\n readonly open: number[] = [];\n /** The element around each element, by their numbers. */\n readonly parents = new Map<number, number | undefined>();\n /** The elements whose start tags have a `b-on`. */\n readonly handled = new Set<number>();\n /** The name of the attribute that the start tag is in. */\n private attribute = '';\n /** The tag names of the elements, by their numbers. */\n private readonly names = new Map<number, string>();\n /** `svg` or `math` when the first element at the top is of SVG or MathML only. */\n foreign: string | undefined;\n private top = true;\n\n /** `svg` or `math` when the open elements put what comes next in SVG or MathML. */\n foreignHere(): string | undefined {\n for (let at = this.open.length - 1; at >= 0; at--) {\n const name = this.names.get(this.open[at]!);\n if (name === 'foreignobject') {\n return undefined;\n }\n if (name === 'svg' || name === 'math') {\n return name;\n }\n }\n return this.foreign;\n }\n /** Where the start tag of each element can take another attribute, by its number. */\n private readonly ends = new Map<number, number>();\n private state: 'text' | 'open' | 'name' | 'tag' | 'quote' | 'close' | 'comment' = 'text';\n\n /** In a quoted attribute value. */\n get inQuote(): boolean {\n return this.state === 'quote';\n }\n private quote = '';\n private name = '';\n\n append(text: string): void {\n for (const char of text) {\n const at = this.html.length;\n this.html += char;\n switch (this.state) {\n case 'text':\n if (char === '<') {\n this.state = 'open';\n } else {\n this.justOpened = false;\n }\n break;\n case 'open':\n if (/[a-zA-Z]/.test(char)) {\n this.state = 'name';\n this.name = char;\n this.nameEnd = at + 1;\n this.raw = false;\n this.element++;\n this.parents.set(this.element, this.open.at(-1));\n this.attribute = '';\n this.inTag = true;\n this.justOpened = false;\n } else if (char === '/') {\n this.state = 'close';\n this.justOpened = false;\n } else if (char === '!') {\n this.state = 'comment';\n this.justOpened = false;\n } else {\n this.state = 'text';\n }\n break;\n case 'name':\n if (/[\\w-]/.test(char)) {\n this.name += char;\n this.nameEnd = at + 1;\n break;\n }\n this.state = 'tag';\n this.named();\n this.tag(char);\n break;\n case 'tag':\n this.tag(char);\n break;\n case 'quote':\n if (char === this.quote) {\n this.state = 'tag';\n }\n break;\n case 'close':\n if (char === '>') {\n this.state = 'text';\n this.open.pop();\n }\n break;\n case 'comment':\n if (this.html.endsWith('-->')) {\n this.state = 'text';\n }\n break;\n }\n }\n }\n\n /** The name of the element that started last is read. */\n private named(): void {\n const name = this.name.toLowerCase();\n this.names.set(this.element, name);\n if (this.top && this.open.length === 0) {\n this.top = false;\n if (SVG_ONLY.has(name)) {\n this.foreign = 'svg';\n } else if (MATH_ONLY.has(name)) {\n this.foreign = 'math';\n }\n }\n }\n\n private tag(char: string): void {\n if (char === '\"' || char === \"'\") {\n this.quote = char;\n this.state = 'quote';\n this.attribute = '';\n } else if (char === '=') {\n if (this.attribute === 'b-on') {\n this.handled.add(this.element);\n }\n this.attribute = '';\n } else if (/[\\s/]/.test(char)) {\n this.attribute = '';\n } else if (char !== '>') {\n this.attribute += char;\n }\n if (char === '>') {\n this.state = 'text';\n this.inTag = false;\n this.justOpened = true;\n this.raw = RAW_TEXT.test(this.name.toLowerCase());\n this.ends.set(this.element, this.nameEnd);\n if (!VOID.test(this.name) && !this.html.endsWith('/>')) {\n this.open.push(this.element);\n }\n }\n }\n\n /** Takes back the start of an attribute, such as `b-b=\"`, or of a comment, such as `<!--t`. */\n takeBack(text: string, state: 'tag' | 'text'): void {\n this.html = this.html.slice(0, -text.length);\n this.state = state;\n }\n\n /** Writes text into the start tag of an element, after its name: of the one that started last. */\n insertIntoTag(text: string, element = this.element): void {\n const at = element === this.element ? this.nameEnd : this.ends.get(element)!;\n this.html = this.html.slice(0, at) + text + this.html.slice(at);\n // The start tags after it move along.\n for (const [other, end] of this.ends) {\n if (end >= at && other !== element) {\n this.ends.set(other, end + text.length);\n }\n }\n if (element === this.element || this.nameEnd > at) {\n this.nameEnd += text.length;\n }\n this.ends.set(element, element === this.element ? this.nameEnd : at + text.length);\n }\n}\n\n/** The template of a render's parts, or undefined when its markup needs HTML. */\nexport function clonedTemplate(\n parts: readonly Part[],\n filled?: (scope: string, anchor: number) => boolean,\n around?: string,\n): ClonedTemplate | undefined {\n const reader = new Reader();\n reader.foreign = around;\n const writes: Write[][] = [];\n /** The index of each marked element, by its number in the order of the markup. */\n const marks = new Map<number, number>();\n function add(write: Write, element = reader.element): void {\n let index = marks.get(element);\n if (index === undefined) {\n index = writes.length;\n marks.set(element, index);\n writes.push([]);\n reader.insertIntoTag(` b-x=\"${index}\"`, element);\n }\n writes[index]!.push(write);\n }\n const list = [...parts];\n for (let index = 0; index < list.length; index++) {\n const part = list[index]!;\n if ('static' in part) {\n reader.append(part.static);\n continue;\n }\n const code = part.code;\n const next = list[index + 1];\n const nextStatic = next && 'static' in next ? next.static : undefined;\n const attribute = ATTRIBUTE.exec(code);\n if (attribute && reader.inTag) {\n add({\n kind: 'attribute',\n name: attribute[1]!,\n value: attribute[2]!,\n settled: part.settled,\n promise: part.promise,\n });\n continue;\n }\n const spread = SPREAD.exec(code);\n if (spread && reader.inTag) {\n // The values of a spread that can be promises are written once they settle.\n if (spread[1] === 'spread' && part.promise) {\n add({\n kind: 'call',\n call: `$$b.fillSpread($$q, $$m, ${spread[2]})`,\n promise: part.promise,\n });\n } else {\n add({\n kind: 'call',\n call: `$$b.${spread[1] === 'spread' ? 'setSpread' : 'setOn'}($$m, ${spread[2]})`,\n });\n }\n reader.handled.add(reader.element);\n continue;\n }\n const insert = INSERT.exec(code);\n // The only content of an element, which can be the text of a `<textarea>`.\n // A void element, such as an `<input>`, ends with its start tag, so the insert is after it.\n const holder = reader.open.at(-1);\n if (insert && reader.justOpened && holder === reader.element && nextStatic?.startsWith('</')) {\n add({\n kind: 'content',\n value: insert[1]!,\n at: insert[2],\n settled: part.settled,\n promise: part.promise,\n });\n continue;\n }\n // A text insert: `<!--t`, the scope, `:anchor-->`, the value, then `<!--/t-->`.\n const textEnd = nextStatic === undefined ? null : TEXT_END.exec(nextStatic);\n const value = list[index + 2];\n const close = list[index + 3];\n const textInsert = value && 'code' in value ? INSERT.exec(value.code) : null;\n if (\n SCOPE.test(code) &&\n reader.html.endsWith(TEXT_START) &&\n textEnd &&\n nextStatic!.length === textEnd[0].length &&\n textInsert &&\n close &&\n 'static' in close &&\n close.static.startsWith(TEXT_CLOSE)\n ) {\n reader.takeBack(TEXT_START, 'text');\n const rest = close.static.slice(TEXT_CLOSE.length);\n const parent = reader.open.at(-1);\n // At the end of its element, the clone appends the text node to the element.\n if (rest.startsWith('</') && parent !== undefined) {\n add(\n {\n kind: 'last',\n scope: code,\n anchor: Number(textEnd[1]),\n value: textInsert[1]!,\n at: textInsert[2],\n promise: (value as { promise?: string }).promise,\n },\n parent,\n );\n list[index + 3] = { static: rest };\n index += 2;\n continue;\n }\n const mark = writes.length;\n writes.push([\n {\n kind: 'text',\n scope: code,\n anchor: Number(textEnd[1]),\n value: textInsert[1]!,\n at: textInsert[2],\n promise: (value as { promise?: string }).promise,\n },\n ]);\n // One comment, so the static text around it stays apart when the template is parsed. The\n // clone puts a text node in its place, which it keeps.\n reader.append(`<!--x${mark}-->`);\n list[index + 3] = { static: close.static.slice(TEXT_CLOSE.length) };\n index += 2;\n continue;\n }\n // A child component, which renders where it is, after the elements before it.\n if (COMPONENT.test(code) && !reader.inTag && !reader.raw) {\n const mark = writes.length;\n writes.push([\n {\n kind: 'component',\n call: code.replace(COMPONENT, '$$$$b.componentNodes('),\n settled: part.settled,\n },\n ]);\n reader.append(`<!--x${mark}-->`);\n continue;\n }\n // A block that renders where it is, whose nodes go in the place of a comment.\n const nodes = NODES.exec(code);\n if (nodes && !reader.inTag && !reader.raw) {\n const mark = writes.length;\n writes.push([{ kind: 'component', call: nodes[1]!, settled: part.settled }]);\n reader.append(`<!--x${mark}-->`);\n continue;\n }\n // A dynamic tag, which builds its element where it is.\n if (DYNAMIC.test(code) && !reader.inTag && !reader.raw) {\n const mark = writes.length;\n const foreign = reader.foreignHere();\n const call = foreign\n ? code.replace(DYNAMIC, `$$$$b.foreignNodes(${JSON.stringify(foreign)}, `)\n : code.replace(DYNAMIC, '$$$$b.dynamicNodes(');\n writes.push([{ kind: 'component', call }]);\n reader.append(`<!--x${mark}-->`);\n continue;\n }\n // A nested block with nothing in it yet: `<!--b`, the scope, `:anchor-->`, `<!--/b-->`.\n const blockEnd = nextStatic === undefined ? null : BLOCK_END.exec(nextStatic);\n // A block that no call fills, such as a `#client`, keeps its markers, which are not empty\n // once it renders.\n if (\n SCOPE.test(code) &&\n reader.html.endsWith(BLOCK_START) &&\n blockEnd &&\n (!filled || filled(code, Number(blockEnd[1])))\n ) {\n reader.takeBack(BLOCK_START, 'text');\n const mark = writes.length;\n writes.push([{ kind: 'block', scope: code, anchor: Number(blockEnd[1]) }]);\n reader.append(`<!--x${mark}--><!--/b-->`);\n list[index + 1] = { static: nextStatic!.slice(blockEnd[0].length) };\n continue;\n }\n // The start of a block whose markup follows in the template, such as of a dynamic tag.\n const marker = nextStatic === undefined ? null : MARKER_END.exec(nextStatic);\n if (SCOPE.test(code) && !reader.inTag && reader.html.endsWith(BLOCK_START) && marker) {\n reader.takeBack(BLOCK_START, 'text');\n const mark = writes.length;\n writes.push([{ kind: 'marker', scope: code, anchor: Number(marker[1]), suffix: marker[2]! }]);\n reader.append(`<!--x${mark}-->`);\n list[index + 1] = { static: nextStatic!.slice(marker[0].length) };\n continue;\n }\n const end = nextStatic === undefined ? null : ANCHOR_END.exec(nextStatic);\n if (SCOPE.test(code) && reader.inTag && reader.html.endsWith(ANCHOR_START) && end) {\n reader.takeBack(ANCHOR_START, 'tag');\n add({ kind: 'anchor', scope: code, anchor: Number(end[1]) });\n list[index + 1] = { static: nextStatic!.slice(end[0].length) };\n continue;\n }\n // A comment that names a scope, such as `<!--i`, the scope, `-->`.\n const named = /<!--([a-zA-Z])$/.exec(reader.html);\n if (SCOPE.test(code) && named && nextStatic?.startsWith('-->')) {\n reader.takeBack(named[0], 'text');\n const mark = writes.length;\n writes.push([{ kind: 'comment', data: `${JSON.stringify(named[1])} + ${code}` }]);\n reader.append(`<!--x${mark}-->`);\n list[index + 1] = { static: nextStatic.slice(3) };\n continue;\n }\n // A value in quotes, such as `b-v=\"`, the scope, `\"`.\n const quoted = / ([^\\s\"'=<>/]+)=\"$/.exec(reader.html);\n if (reader.inQuote && quoted && nextStatic?.startsWith('\"')) {\n reader.takeBack(quoted[0], 'tag');\n add({ kind: 'attribute', name: JSON.stringify(quoted[1]), value: code });\n list[index + 1] = { static: nextStatic.slice(1) };\n continue;\n }\n // A value in quotes with static text and code, such as `class=\"bar`, a class that a condition\n // adds, `\"`. The code gives HTML, so the whole attribute is parsed.\n const mixed = / ([^\\s\"'=<>/]+)=\"([^\"]*)$/.exec(reader.html);\n if (reader.inQuote && mixed) {\n const pieces = [JSON.stringify(mixed[0])];\n let at = index;\n let closed = false;\n // The static text of the value before its closing quote.\n let tail = '';\n for (; at < list.length; at++) {\n const piece = list[at]!;\n if ('code' in piece) {\n pieces.push(`(${piece.code})`);\n continue;\n }\n const quote = piece.static.indexOf('\"');\n if (quote === -1) {\n pieces.push(JSON.stringify(piece.static));\n continue;\n }\n pieces.push(JSON.stringify(piece.static.slice(0, quote + 1)));\n tail = piece.static.slice(0, quote);\n list[at] = { static: piece.static.slice(quote + 1) };\n closed = true;\n break;\n }\n if (closed) {\n reader.takeBack(mixed[0], 'tag');\n const classes =\n mixed[1] === 'class'\n ? classTokens([...list.slice(index, at), { static: tail }], mixed[2]!)\n : undefined;\n if (classes) {\n // The static classes stay in the template, and a condition adds each of the others.\n if (classes.text) {\n reader.append(` class=\"${classes.text}\"`);\n }\n for (const call of classes.calls) {\n add({ kind: 'call', call });\n }\n } else {\n add({ kind: 'call', call: `$$b.setAttrText($$m, ${pieces.join(' + ')})` });\n }\n index = at - 1;\n continue;\n }\n }\n // Other code in a start tag gives the text of its attributes, such as a class that a\n // condition adds, or the attributes of a form of an action.\n if (reader.inTag && !reader.inQuote && !reader.html.endsWith('=')) {\n // An attribute that a condition adds, `cond ? \" name=\\\"value\\\"\" : \"\"`, is set as it is.\n const added = CONDITIONAL.exec(code);\n add({\n kind: 'call',\n call: added\n ? `(${added[1]}) && $$m.setAttribute(${JSON.stringify(added[2])}, ${JSON.stringify(added[3]!.replace(/\\\\\"/g, '\"'))})`\n : `$$b.setAttrText($$m, ${code})`,\n });\n continue;\n }\n // An insert with no markers, whose value renders once where it is.\n if (insert && !reader.inTag && !reader.raw) {\n const mark = writes.length;\n writes.push([\n {\n kind: 'put',\n value: insert[1]!,\n at: insert[2],\n settled: part.settled,\n promise: part.promise,\n },\n ]);\n reader.append(`<!--x${mark}-->`);\n continue;\n }\n return undefined;\n }\n // Other comments, such as markers that a write does not name, and `<template>` elements, such\n // as of a `$client` callback, are indexed and started when the clone is inserted, which the\n // template asks for. The core starts the `<template>` elements of a clone, not of its template.\n const comments = reader.html.replace(/<!--x\\d+-->|<!--\\/[biP]-->/g, '');\n const indexed = comments.includes('<!--') || /<template\\b/i.test(reader.html) || undefined;\n // An element with handlers and no anchor finds its scope with `closest`, from the anchor of an\n // element around it. The clone writes `b-b` only where it is asked to.\n function getAnchor(element: number): Write | undefined {\n for (const write of writes[marks.get(element) ?? -1] ?? []) {\n if (write.kind === 'anchor') {\n return write;\n }\n }\n return undefined;\n }\n for (const element of reader.handled) {\n if (getAnchor(element)) {\n continue;\n }\n for (let around = reader.parents.get(element); around !== undefined;) {\n const anchor = getAnchor(around);\n if (anchor?.kind === 'anchor') {\n // An element at the top of the clone gets its `b-b` anyway.\n anchor.named = reader.parents.get(around) !== undefined || undefined;\n break;\n }\n around = reader.parents.get(around);\n }\n }\n return { html: reader.html, writes, foreign: reader.foreign, indexed };\n}\n\n/**\n * A write of cloned markup, as a statement. With `scope`, its value can be a promise, which\n * `fillValue` waits for, with `key` naming its place among the places of the scope.\n */\nfunction promised(\n scope: string | undefined,\n key: string,\n value: string,\n write: (value: string) => string,\n): string {\n return scope\n ? `$$b.fillValue(${scope}, ${key}, ${value}, ($$v) => ${write('$$v')});`\n : `${write(value)};`;\n}\n\n/**\n * Replaces the `$$html +=` lines of a render with a clone of a template, and the writes on the\n * elements that it marks. `hoist` makes a constant of the module. Returns false when the markup\n * needs HTML, such as markup in a branch or a loop of the render.\n *\n * The lines between the first and the last `$$html +=` can only declare the values of the\n * writes, which run after them. Plain `{` blocks around them go, so the writes see them.\n */\nexport function cloneLines(\n emitter: Emitter,\n hoist: (code: string) => string,\n fn = 0,\n owner?: object,\n): boolean {\n const { lines: source, levels } = emitter;\n // Lines of the function, and lines in its branches and loops. Others are in functions inside.\n function isTop(at: number): boolean {\n return levels[at]!.fn === fn && !levels[at]!.control;\n }\n function isControl(at: number): boolean {\n return levels[at]!.fn === fn && levels[at]!.control;\n }\n // Find the flushes at the top of the function, and stop at one inside a branch or loop.\n const tops: typeof emitter.flushes = [];\n let controlled = false;\n for (const flush of emitter.flushes) {\n if (isTop(flush.line)) {\n tops.push(flush);\n }\n if (isControl(flush.line)) {\n controlled = true;\n }\n }\n if (tops.length === 0 || controlled) {\n return false;\n }\n const first = tops[0]!.line;\n const last = tops.at(-1)!.line;\n const flushLines = new Set<number>();\n for (const flush of tops) {\n flushLines.add(flush.line);\n }\n const dropped = new Set<number>();\n const declared = new Set<string>();\n for (let at = 0; at < source.length; at++) {\n if (flushLines.has(at) || !isTop(at)) {\n if (at > first && at < last && isControl(at)) {\n return false;\n }\n continue;\n }\n const line = source[at]!.trim();\n // Plain blocks go, so the clone and the writes see what the blocks declare.\n if (emitter.plainBraces.has(at)) {\n dropped.add(at);\n continue;\n }\n const declaration = /^(?:const|let) ([\\w$]+) =/.exec(line);\n if (declaration) {\n // Two blocks can declare the same name, which one function cannot.\n if (declared.has(declaration[1]!)) {\n return false;\n }\n declared.add(declaration[1]!);\n }\n if (at > first && at < last && !line.startsWith('const $$') && !line.startsWith('let $$')) {\n // A reference to an element finds it when it is read. A dynamic tag writes it unless the tag\n // names a component, which forwards the element itself.\n const reference = /^(?:if \\(typeof .+ !== 'function'\\) )?[\\w$]+ = \\$\\$b\\.elementAt\\(/.test(\n line,\n );\n if (line !== '});' && line !== '};' && !line.startsWith('$$b.') && !reference) {\n return false;\n }\n }\n }\n // One list of parts, with the static parts next to each other as one.\n const parts: Part[] = [];\n for (const flush of tops) {\n for (const part of flush.parts) {\n const previous = parts.at(-1);\n if (previous && 'static' in previous && 'static' in part) {\n parts[parts.length - 1] = { static: previous.static + part.static };\n } else {\n parts.push({ ...part });\n }\n }\n }\n const found = clonedTemplate(\n parts,\n (scope, anchor) => emitter.fills?.has(`${scope}:${anchor}`) ?? false,\n emitter.foreignAround(owner),\n );\n if (!found) {\n return false;\n }\n const flush = tops[0];\n const indent = /^ */.exec(emitter.lines[flush!.line]!)![0];\n // The arguments after the count: the foreign element, then 1 for markup that its insert indexes.\n let options = found.foreign ? `, ${JSON.stringify(found.foreign)}` : '';\n if (found.indexed) {\n options += `${found.foreign ? '' : ', undefined'}, 1`;\n }\n const name = hoist(\n `$$b.template(${JSON.stringify(found.html)}, ${found.writes.length}${options})`,\n );\n // The clone gives its marked nodes, then its fragment.\n const lines = [`${indent}const $$e = $$b.clone(${name}), $$f = $$e[${found.writes.length}];`];\n // The calls that fill the nested blocks, after the slots of the body are set, which the\n // renders of the blocks read.\n const fills: string[] = [];\n // The writes that read memos which never change, by the scope that reports their rejection\n // and the memos they read. They wait for those memos to settle, so one that loads longer\n // holds back only the writes that read it.\n const settled = new Map<string, { scope: string; names: string[]; writes: string[] }>();\n function addLine(line: string, memos: Settled | undefined): void {\n if (!memos) {\n lines.push(`${indent}${line}`);\n return;\n }\n const key = `${memos.scope} ${memos.names.join(' ')}`;\n let group = settled.get(key);\n if (!group) {\n group = { scope: memos.scope, names: memos.names, writes: [] };\n settled.set(key, group);\n }\n group.writes.push(line);\n }\n let missing = false;\n for (const [index, writes] of found.writes.entries()) {\n // The scope of the anchor of the element, where its content finds its contexts.\n let anchored: Write | undefined;\n for (const write of writes) {\n if (write.kind === 'anchor') {\n anchored = write;\n break;\n }\n }\n const at = anchored?.kind === 'anchor' ? `, ${anchored.scope}` : '';\n // The calls of an element, such as its spreads and their `b-on`, come first, so `keep` sees\n // a `b-on` and writes the `b-b` that its handlers read.\n const ordered: Write[] = [];\n for (const write of writes) {\n if (write.kind === 'call') {\n ordered.push(write);\n }\n }\n for (const write of writes) {\n if (write.kind !== 'call') {\n ordered.push(write);\n }\n }\n for (const write of ordered) {\n if (write.kind === 'anchor') {\n lines.push(\n `${indent}$$b.keep(${write.scope}, ${write.anchor}, $$e[${index}]${write.named ? ', true' : ''});`,\n );\n } else if (write.kind === 'last' && write.promise) {\n lines.push(\n `${indent}$$b.keepValue(${write.scope}, ${write.anchor}, $$e[${index}], ${write.value}, ${write.at ?? 'undefined'}, true);`,\n );\n } else if (write.kind === 'last') {\n lines.push(\n `${indent}$$b.appendText(${write.scope}, ${write.anchor}, $$e[${index}], ${write.value}${write.at ? `, ${write.at}` : ''});`,\n );\n } else if (write.kind === 'text') {\n // A value that can be a promise is written once it settles.\n const helper = write.promise ? 'keepValue' : 'keepText';\n lines.push(\n `${indent}$$b.${helper}(${write.scope}, ${write.anchor}, $$e[${index}], ${write.value}${write.at ? `, ${write.at}` : ''});`,\n );\n } else if (write.kind === 'attribute') {\n const key =\n anchored?.kind === 'anchor'\n ? `${anchored.anchor} ${JSON.parse(write.name) as string}`\n : `x${index} ${JSON.parse(write.name) as string}`;\n // The update of the attribute writes the same place of the scope of the anchor.\n addLine(\n promised(\n write.promise && (anchored?.kind === 'anchor' ? anchored.scope : write.promise),\n JSON.stringify(key),\n write.value,\n (value) => `$$b.setAttr($$e[${index}], ${write.name}, ${value})`,\n ),\n write.settled,\n );\n } else if (write.kind === 'component') {\n addLine(`$$b.place($$e[${index}], ${write.call});`, write.settled);\n } else if (write.kind === 'comment') {\n lines.push(`${indent}$$b.nameComment($$e[${index}], ${write.data});`);\n } else if (write.kind === 'put') {\n addLine(\n promised(\n write.promise,\n JSON.stringify(`x${index}`),\n write.value,\n (value) => `$$b.putText($$e[${index}], ${value}${write.at ? `, ${write.at}` : ''})`,\n ),\n write.settled,\n );\n } else if (write.kind === 'call') {\n // The places of a spread's promises are those that the update of the spread writes.\n const place =\n anchored?.kind === 'anchor'\n ? `${anchored.scope}, ${anchored.anchor}`\n : `${write.promise}, ${JSON.stringify(`x${index}`)}`;\n lines.push(\n `${indent}${write.call.replace('$$q', () => place).replace('$$m', () => `$$e[${index}]`)};`,\n );\n } else if (write.kind === 'marker') {\n lines.push(\n `${indent}$$b.markBlock($$e[${index}], ${write.scope}, ${write.anchor}, ${JSON.stringify(write.suffix)});`,\n );\n } else if (write.kind === 'block') {\n const call = emitter.fills.get(`${write.scope}:${write.anchor}`);\n if (call === undefined) {\n missing = true;\n } else {\n fills.push(`${indent}${call.replace('$$m', () => `$$e[${index}]`)};`);\n }\n } else {\n addLine(\n promised(\n write.promise && (anchored?.kind === 'anchor' ? anchored.scope : write.promise),\n anchored?.kind === 'anchor' ? String(anchored.anchor) : JSON.stringify(`x${index}`),\n write.value,\n (value) => `$$b.setContent($$e[${index}], ${value}${write.at ? `, ${write.at}` : at})`,\n ),\n write.settled,\n );\n }\n }\n }\n // The values of the memos shadow the memos, so the writes read the values.\n for (const group of settled.values()) {\n const names = group.names.join(', ');\n lines.push(\n `${indent}$$b.fillSettled(${group.scope}, [${names}], (${names}) => { ${group.writes.join(' ')} });`,\n );\n }\n if (missing) {\n return false;\n }\n // The scopes that the render makes keep their nodes in arrays of the right size from the start.\n const sizes = new Map<string, number>();\n for (const write of found.writes.flat()) {\n if ('anchor' in write && write.kind !== 'block' && /^\\$\\$s\\d+$/.test(write.scope)) {\n sizes.set(write.scope, Math.max(sizes.get(write.scope) ?? 0, write.anchor + 1));\n }\n }\n for (const [scope, size] of sizes) {\n let at = -1;\n for (const [position, line] of source.entries()) {\n if (line.trim().startsWith(`const ${scope} = $$b.createScope(`)) {\n at = position;\n break;\n }\n }\n const made =\n at === -1 ? undefined : /^(.*\\$\\$b\\.createScope\\()(\\d+), ([^,)]+)\\);$/.exec(source[at]!);\n if (made) {\n source[at] = `${made[1]}${made[2]}, ${made[3]}, undefined, ${size});`;\n }\n }\n // The clone and its writes go where the last `$$html +=` was, after the values they read.\n const result: string[] = [];\n const resultLevels: Level[] = [];\n const moved = new Map<number, number>();\n const level: Level = { fn, control: false };\n for (const [at, line] of source.entries()) {\n if (at === last) {\n result.push(...lines);\n for (const _ of lines) {\n resultLevels.push(level);\n }\n } else if (!flushLines.has(at) && !dropped.has(at)) {\n moved.set(at, result.length);\n result.push(line);\n resultLevels.push(levels[at]!);\n }\n }\n result.push(...fills);\n for (const _ of fills) {\n resultLevels.push(level);\n }\n source.splice(0, source.length, ...result);\n levels.splice(0, levels.length, ...resultLevels);\n // The lines of the other `$$html +=` and plain blocks, such as of a function inside, moved.\n const others: typeof emitter.flushes = [];\n for (const other of emitter.flushes) {\n if (!flushLines.has(other.line)) {\n others.push({ ...other, line: moved.get(other.line)! });\n }\n }\n emitter.flushes.splice(0, emitter.flushes.length, ...others);\n const braces: number[] = [];\n for (const at of emitter.plainBraces) {\n if (!dropped.has(at)) {\n braces.push(at);\n }\n }\n emitter.plainBraces.clear();\n for (const at of braces) {\n emitter.plainBraces.add(moved.get(at)!);\n }\n return true;\n}\n","import type { Declaration, Scope, Site } from '../model.ts';\nimport { children } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\n\n/** Where the load of a statement of awaited memos can start. */\nexport interface LoadStart {\n /**\n * The index of the last statement before it that declares or changes a\n * value that the memos read, or -1 when there is none.\n */\n after: number;\n /** The awaited memos of other loads that the memos read. Their loads must start first. */\n memos: Declaration[];\n}\n\n/**\n * Finds, for each statement of awaited memos (`loads`), the last statement\n * before it that its loads must run after. The memos of a statement read\n * names: those of their expressions, and those that the local functions\n * and memos they call or read read and write, followed through.\n *\n * A statement holds the load when it declares one of those names (or the\n * load would throw a TDZ `ReferenceError`), or can change one: a write such\n * as `q = x`, a call such as `params.set(…)`, an argument of a call, or a\n * mention of a local function that mentions it. A plain read does not hold\n * it. A function declaration does not hold\n * it, since it runs nothing where it is written. `runs` is false for the\n * statements that run nothing where they are written, such as `$effect` on\n * the server, which do not hold it either.\n *\n * An awaited memo of another load is not followed: the load reads it as a\n * memo, so it waits for it on its own. It is listed in `memos`, as its\n * memo must exist before the load starts.\n */\nexport function findLoadStarts(\n statements: oxc.Node[],\n scope: Scope,\n loads: Map<oxc.Node, Declaration[]>,\n runs: (statement: oxc.Node) => boolean,\n): Map<oxc.Node, LoadStart> {\n const awaited = new Set<Declaration>();\n for (const declarations of loads.values()) {\n for (const declaration of declarations) {\n awaited.add(declaration);\n }\n }\n\n // The names that each statement declares, and those it can change: through a write, a call\n // or an argument, or a local function that it mentions.\n const touched: Set<Declaration>[] = [];\n const declares: Set<Declaration>[] = [];\n const changing = new Set<number>();\n for (const statement of statements) {\n touched.push(new Set());\n declares.push(new Set());\n if (statement.type !== 'FunctionDeclaration') {\n addChanging(changing, statement, false);\n }\n }\n for (let current: Scope | undefined = scope; current; current = current.parent) {\n for (const declaration of current.declarations.values()) {\n const at = findStatement(statements, declaration.range.start);\n if (at !== -1 && statements[at]!.type !== 'FunctionDeclaration') {\n declares[at]!.add(declaration);\n }\n const isFunction = declaration.kind === 'function' || declaration.kind === 'server-function';\n for (const reference of [...declaration.reads, ...declaration.writes]) {\n const index = findStatement(statements, reference.range.start);\n const changes =\n isFunction ||\n changing.has(reference.range.start) ||\n declaration.writes.includes(reference);\n if (index !== -1 && changes) {\n addMentions(touched[index]!, declaration, awaited);\n }\n }\n }\n }\n\n const result = new Map<oxc.Node, LoadStart>();\n for (const [index, statement] of statements.entries()) {\n const declarations = loads.get(statement);\n if (!declarations) {\n continue;\n }\n // The names that the memos read and write, through functions and other memos.\n const names = new Set<Declaration>();\n const memos: Declaration[] = [];\n for (const declaration of declarations) {\n if (declaration.site) {\n addSiteNames(names, memos, declaration.site, awaited, new Set());\n }\n }\n // The last statement before it that holds it.\n let after = -1;\n for (let before = index - 1; before >= 0; before--) {\n const other = statements[before]!;\n if (\n loads.has(other) ||\n !runs(other) ||\n other.type === 'FunctionDeclaration' ||\n !(overlaps(touched[before]!, names) || overlaps(declares[before]!, names))\n ) {\n continue;\n }\n after = before;\n break;\n }\n result.set(statement, { after, memos });\n }\n return result;\n}\n\nconst WRAPPERS = new Set([\n 'ParenthesizedExpression',\n 'ChainExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n]);\n\n/**\n * Adds the positions of the names that code can change: the root of the\n * target of a write, of a callee and of an argument, such as `q` in `q = x`,\n * `params` in `params.set(…)`, and every name in an argument, such as\n * `list` in `fill({ list })`. `root` is true\n * when the node is in such a place.\n */\nfunction addChanging(into: Set<number>, node: oxc.Node, root: boolean): void {\n switch (node.type) {\n case 'Identifier':\n if (root) {\n into.add(node.start);\n }\n return;\n case 'MemberExpression':\n addChanging(into, node.object, root);\n if (node.computed) {\n addChanging(into, node.property, false);\n }\n return;\n case 'AssignmentExpression':\n addChanging(into, node.left, true);\n addChanging(into, node.right, false);\n return;\n case 'UpdateExpression':\n addChanging(into, node.argument, true);\n return;\n case 'UnaryExpression':\n addChanging(into, node.argument, node.operator === 'delete');\n return;\n case 'CallExpression':\n case 'NewExpression':\n addChanging(into, node.callee, true);\n for (const argument of node.arguments) {\n addEvery(into, argument);\n }\n return;\n case 'TaggedTemplateExpression':\n addChanging(into, node.tag, true);\n for (const expression of node.quasi.expressions) {\n addEvery(into, expression);\n }\n return;\n default:\n break;\n }\n // A wrapper and a pattern keep the place of the node. Anything else is read.\n const keep =\n root &&\n (WRAPPERS.has(node.type) ||\n node.type.endsWith('Pattern') ||\n node.type === 'SpreadElement' ||\n node.type === 'Property' ||\n node.type === 'RestElement');\n for (const [key, child] of children(node)) {\n if (node.type === 'Property' && key === 'key' && !node.computed) {\n continue;\n }\n addChanging(into, child, keep);\n }\n}\n\n/** Adds the position of every name in an argument, which the callee can change through it. */\nfunction addEvery(into: Set<number>, node: oxc.Node): void {\n if (node.type === 'Identifier') {\n into.add(node.start);\n return;\n }\n for (const [, child] of children(node)) {\n addEvery(into, child);\n }\n}\n\n/** The index of the statement that holds a position, or -1. */\nfunction findStatement(statements: oxc.Node[], position: number): number {\n for (const [index, statement] of statements.entries()) {\n if (position >= statement.start && position < statement.end) {\n return index;\n }\n }\n return -1;\n}\n\n/** Adds a name that a statement mentions, and the names that a local function it mentions mentions. */\nfunction addMentions(\n into: Set<Declaration>,\n declaration: Declaration,\n awaited: Set<Declaration>,\n): void {\n if (into.has(declaration)) {\n return;\n }\n into.add(declaration);\n const site = declaration.site;\n if (site && (declaration.kind === 'function' || declaration.kind === 'server-function')) {\n for (const reference of [...site.reads, ...site.writes]) {\n if (!awaited.has(reference.declaration)) {\n addMentions(into, reference.declaration, awaited);\n }\n }\n }\n}\n\n/** Adds the names that a site reads and writes, and those of the functions and memos it reads. */\nfunction addSiteNames(\n names: Set<Declaration>,\n memos: Declaration[],\n site: Site,\n awaited: Set<Declaration>,\n seen: Set<Site>,\n): void {\n if (seen.has(site)) {\n return;\n }\n seen.add(site);\n for (const reference of [...site.reads, ...site.writes]) {\n const declaration = reference.declaration;\n if (awaited.has(declaration)) {\n if (declaration.site !== site && !memos.includes(declaration)) {\n memos.push(declaration);\n }\n continue;\n }\n names.add(declaration);\n if (declaration.site && declaration.kind !== 'import') {\n addSiteNames(names, memos, declaration.site, awaited, seen);\n }\n }\n}\n\n/** True when two sets share a value. */\nfunction overlaps(left: Set<Declaration>, right: Set<Declaration>): boolean {\n for (const value of left) {\n if (right.has(value)) {\n return true;\n }\n }\n return false;\n}\n\nconst FUNCTIONS = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']);\n\n/** True when code waits where it runs: an `await` or a `for await` outside the functions it declares. */\nexport function hasAwait(node: oxc.Node): boolean {\n if (node.type === 'AwaitExpression' || (node.type === 'ForOfStatement' && node.await)) {\n return true;\n }\n if (FUNCTIONS.has(node.type)) {\n return false;\n }\n for (const [, child] of children(node)) {\n if (hasAwait(child)) {\n return true;\n }\n }\n return false;\n}\n","import type { ElementNode, 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 { cannotThrow, isPrimitive } from './primitive.ts';\nimport type { Plan } from '../plan.ts';\nimport { copy } from '../sourcemap.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/**\n * The parameters of a template of the file, and the `[slot, value]` pairs of its arguments, so a\n * call that comes again writes its new arguments into the scope that it rendered. `params` are\n * the parameters as written, `exported` have no default values (the call passes the values with\n * them), and `names` are the arguments when each parameter is a name and one has a default.\n * Nothing if the template has no scope of its own, or a destructured parameter has a default\n * value: it then renders again. An argument that no slot holds is never read in the browser.\n */\nexport function templateArgs(\n plan: Plan,\n source: string,\n scope: Scope,\n): { params: string; exported: string; names?: string[]; pairs: string[] } | undefined {\n const template = scope.template;\n if (!template || !plan.scopes.get(scope)?.needsId) {\n return undefined;\n }\n const first = template.params[0];\n const last = template.params.at(-1);\n const params = first && last ? copy(source, first.start, last.end) : '';\n const exported: string[] = [];\n const names: string[] = [];\n let simple = true;\n let defaults = false;\n for (const param of template.params) {\n const target = param.type === 'AssignmentPattern' ? param.left : param;\n defaults ||= target !== param;\n if (target.type === 'Identifier') {\n names.push(target.name);\n } else {\n simple = false;\n }\n // A default value of a destructured parameter can read what the export does not have.\n if (target.type !== 'Identifier' && hasDefault(target)) {\n return undefined;\n }\n exported.push(copy(source, target.start, target.end));\n }\n const pairs: string[] = [];\n for (const declaration of scope.declarations.values()) {\n if (declaration.kind !== 'template-param') {\n continue;\n }\n const slot = slotIndex(plan, declaration);\n if (slot !== -1) {\n pairs.push(`[${slot}, ${declaration.name}]`);\n }\n }\n return {\n params,\n exported: exported.join(', '),\n names: simple && defaults ? names : undefined,\n pairs,\n };\n}\n\nfunction hasDefault(node: oxc.Node): boolean {\n if (node.type === 'AssignmentPattern') {\n return true;\n }\n for (const [, child] of children(node)) {\n if (hasDefault(child)) {\n return true;\n }\n }\n return false;\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 * True for the header of `#loading (memo)`, which reads whether its memos are pending, not their\n * values, so the render does not wait for them.\n */\nexport function isLoadingHeader(site: Site): boolean {\n return site.kind === 'block' && site.block?.kind === 'loading';\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 || isLoadingHeader(read.site)) {\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 the server waits for where they are declared, but reads where the\n * markup reads them: those without `await`. They hold an error until a read.\n */\nexport function lazyMemos(blocking: Set<Declaration>, inline: Set<Declaration>): Set<Declaration> {\n const result = new Set<Declaration>();\n for (const declaration of blocking) {\n if (!declaration.awaited && !inline.has(declaration)) {\n result.add(declaration);\n }\n }\n return result;\n}\n\n/**\n * Returns the memos that the body of a `#loading` or `#defer` block waits for, which are not\n * plain values. Like `lazyMemos`, they hold their error until a read, so a `#try` inside the\n * body gets it.\n */\nexport function bodyMemos(\n plan: Plan,\n blocking: Set<Declaration>,\n inline: Set<Declaration>,\n): Set<Declaration> {\n const result = new Set<Declaration>();\n for (const scope of plan.bodyScopes.values()) {\n const kind = scope.block?.kind;\n if (kind !== 'loading' && kind !== 'defer') {\n continue;\n }\n for (const declaration of awaitedMemos(plan, scope, blocking)) {\n if (!inline.has(declaration)) {\n result.add(declaration);\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 (\n read.range.start === read.range.end ||\n isLoadingHeader(site) ||\n loadingBody(readScope(read)) !== body\n ) {\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/** Returns the site that holds a node. */\nfunction findSite(plan: Plan, node: oxc.Node): Site | undefined {\n for (const item of plan.graph.model.sites) {\n if (item.node === node) {\n return item;\n }\n }\n return undefined;\n}\n\n/** Global functions whose result is never a promise. */\nconst PLAIN_FUNCTIONS = new Set([\n 'Boolean',\n 'Number',\n 'String',\n 'decodeURIComponent',\n 'encodeURIComponent',\n 'parseFloat',\n 'parseInt',\n]);\n\n/** Methods of strings, numbers and arrays whose result is never a promise. */\nconst PLAIN_METHODS = new Set([\n 'concat',\n 'endsWith',\n 'filter',\n 'includes',\n 'indexOf',\n 'join',\n 'map',\n 'padEnd',\n 'padStart',\n 'repeat',\n 'replace',\n 'replaceAll',\n 'slice',\n 'split',\n 'startsWith',\n 'toFixed',\n 'toLocaleString',\n 'toLowerCase',\n 'toString',\n 'toUpperCase',\n 'trim',\n 'trimEnd',\n 'trimStart',\n]);\n\n/**\n * True if a value of markup can be a promise, which the browser writes once it settles: a call,\n * such as `{load(id)}` or `title=getTitle()`, or a read of a prop typed as a promise. A call of a\n * macro of brumate, such as `$isPending`, of `String` or of a method of strings and arrays, such\n * as `name.toUpperCase()`, gives no promise, nor does a string, a number or a property. An\n * object can hold one, for a spread.\n */\nexport function mayBePromise(node: oxc.Node, site: Site | undefined): boolean {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n return mayBePromise(node.expression, site);\n case 'ConditionalExpression':\n return mayBePromise(node.consequent, site) || mayBePromise(node.alternate, site);\n case 'LogicalExpression':\n return mayBePromise(node.left, site) || mayBePromise(node.right, site);\n case 'SequenceExpression':\n return mayBePromise(node.expressions.at(-1)!, site);\n case 'NewExpression':\n return node.callee.type === 'Identifier' && node.callee.name === 'Promise';\n case 'TaggedTemplateExpression':\n case 'ImportExpression':\n return true;\n // The attributes of a spread, such as `{...{ title: getTitle() }}`.\n case 'ObjectExpression':\n for (const property of node.properties) {\n if (\n mayBePromise(property.type === 'SpreadElement' ? property.argument : property.value, site)\n ) {\n return true;\n }\n }\n return false;\n case 'CallExpression': {\n const callee = node.callee;\n if (callee.type === 'Identifier') {\n return !callee.name.startsWith('$') && !PLAIN_FUNCTIONS.has(callee.name);\n }\n return !(\n callee.type === 'MemberExpression' &&\n callee.property.type === 'Identifier' &&\n PLAIN_METHODS.has(callee.property.name)\n );\n }\n case 'Identifier':\n for (const reference of site?.reads ?? []) {\n if (reference.declaration.promise === true && reference.range.start === node.start) {\n return true;\n }\n }\n return false;\n default:\n return false;\n }\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, an insert of\n * a prop, which can be a promise or the children of a parent, or an insert or\n * attribute whose value can be a promise, such as a call. Bodies that render\n * later, such as those of a `#loading` or a `#defer` inside it, wait on their\n * own.\n */\nexport function mayWait(plan: Plan, nodes: Markup[]): boolean {\n function insertWaits(node: InsertNode): boolean {\n const site = findSite(plan, node.expression.ast);\n if (mayBePromise(node.expression.ast, site)) {\n return true;\n }\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 // An attribute or spread whose value can be a promise: the server sends the element once it\n // settles.\n function attributesWait(node: ElementNode): boolean {\n for (const attribute of node.attributes) {\n const value =\n attribute.kind === 'value' || attribute.kind === 'spread' || attribute.kind === 'computed'\n ? attribute.value\n : true;\n if (value !== true && mayBePromise(value.ast, findSite(plan, value.ast))) {\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 if (attributesWait(node) || mayWait(plan, node.children)) {\n return true;\n }\n break;\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/** 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 for (const read of site?.reads ?? []) {\n if (read.range.start === name.start && read.range.end === name.end && plain(read.declaration)) {\n return true;\n }\n }\n return false;\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 function 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 function isPlainMemo(declaration: Declaration): boolean {\n const site = declaration.site;\n if (\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 !cannotThrow(site.node)\n ) {\n return false;\n }\n for (const read of site.reads) {\n if (isMemo(read.declaration) && !check(read.declaration)) {\n return false;\n }\n }\n return true;\n }\n function 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 = findSite(plan, init);\n if (!isPrimitive(init, (name) => readsPlain(site, name, check))) {\n return false;\n }\n }\n for (const write of declaration.writes) {\n const node = writeAt(write.site.node, write.range.start);\n if (node?.type === 'UpdateExpression') {\n continue;\n }\n if (node?.type !== 'AssignmentExpression') {\n return false;\n }\n if (\n !ARITHMETIC_ASSIGNMENTS.has(node.operator) &&\n !isPrimitive(node.right, (name) => readsPlain(write.site, name, check))\n ) {\n return false;\n }\n }\n return true;\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 { forEachNode } from '../ast.ts';\nimport { tryCatchesClient } from '../graph.ts';\nimport { isWithin, lookup } from '../model.ts';\nimport type { Declaration, Scope, Site } from '../model.ts';\nimport { isFallbackLiteral } from '../oxc.ts';\nimport type { oxc } from '../oxc.ts';\nimport { holdsStream, serverFunctionId } from '../plan.ts';\nimport { findLoadStarts, hasAwait } from './starts.ts';\nimport { cloneLines, foreignContext } from './template.ts';\nimport type { Plan } from '../plan.ts';\nimport { cleanText, promiseName } from './patch.ts';\nimport { isPrimitive, neverPromise } from './primitive.ts';\nimport type { Patch } from './patch.ts';\nimport {\n awaitedMemos,\n blockingMemos,\n mayBePromise,\n mayWait,\n plainValues,\n instanceScope,\n isMemo,\n readsPlain,\n scopePath,\n slotIndex,\n templateArgs,\n} from './scopes.ts';\nimport { needsScope } from '../css.ts';\nimport { copy, unmarked } from '../sourcemap.ts';\nimport { insertValue } from '../runtime/html.ts';\nimport { paragraphComponents } from '../nesting.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\n/**\n * A memo that a value in the browser render reads, which never changes and can be a promise, and\n * the scope that reports its rejection.\n */\nexport interface Settled {\n names: string[];\n scope: string;\n}\n\n/**\n * A part of the markup of a render: static HTML, or code that gives HTML. In the browser,\n * `settled` holds the memos that it waits for, and `promise` the scope of a value that can be a\n * promise, which the clone writes once it settles.\n */\nexport type Part = { static: string } | { code: string; settled?: Settled; promise?: string };\n\n/**\n * True for a memo whose value is never a promise in the browser, such as `count * 2`, an array or\n * a function. A memo with `await` inside is an async function, so its value is a promise whatever\n * its expression gives, as in ``$memo(`Hi ${(await load()).name}`)`` or `$memo([await load()])`.\n */\n/** The sites of markup, whose `await` of a memo the browser waits for at the start of the markup. */\nconst MARKUP_SITES = new Set(['insert', 'attribute', 'tag', 'spread', 'style', 'block', 'prop']);\n\nfunction isNeverPromise(declaration: Declaration): boolean {\n const node = declaration.site?.node;\n return declaration.kind === 'memo' && node !== undefined && neverPromise(node);\n}\n\n/**\n * True for a memo that can hold a promise in the browser: an `await` in it makes one, and others\n * give one unless they always give a primitive, an array or a function.\n */\nfunction mayLoad(declaration: Declaration): boolean {\n return (\n (declaration.kind === 'memo' || declaration.kind === 'async-memo') &&\n !isNeverPromise(declaration)\n );\n}\n\n/**\n * True if markup can render a `#loading` block: one of its own, or one in a component, or in\n * children or a template that an insert renders.\n */\nfunction mayReveal(nodes: Markup[]): boolean {\n let found = false;\n forEachNode(nodes, (node) => {\n found ||=\n node.kind === 'loading' ||\n node.kind === 'component' ||\n node.kind === 'dynamic' ||\n node.kind === 'insert';\n });\n return found;\n}\n\n/** The static or value attribute named `style`. */\nfunction findStyleAttribute(attributes: Attribute[]): Attribute | undefined {\n for (const attribute of attributes) {\n if ((attribute.kind === 'static' || attribute.kind === 'value') && attribute.name === 'style') {\n return attribute;\n }\n }\n return undefined;\n}\n\n/** Whether a value holds other values, so functions can sit inside it. */\nfunction nested(node: oxc.Node): boolean {\n return node.type === 'ObjectExpression' || node.type === 'ArrayExpression';\n}\n\n/** Whether any attribute is a spread. */\nfunction hasSpread(attributes: readonly { kind: string }[]): boolean {\n for (const attribute of attributes) {\n if (attribute.kind === 'spread') {\n return true;\n }\n }\n return false;\n}\n\n/** Whether a site reads a prop or the rest of the props. */\nfunction readsProps(site: Site | undefined): boolean {\n for (const read of site?.reads ?? []) {\n if (read.declaration.kind === 'prop' || read.declaration.kind === 'props-rest') {\n return true;\n }\n }\n return false;\n}\n\n/** True if a site calls a template, or a function, which can return the output of one. */\nfunction callsTemplate(site: Site | undefined): boolean {\n for (const declaration of site?.calls ?? []) {\n if (declaration.kind === 'template' || declaration.kind === 'function') {\n return true;\n }\n }\n return false;\n}\n\n/** The read of `field ? $store(field.key) : undefined`, or the node itself. */\nfunction guardedRead(node: oxc.Node | null | undefined): oxc.Node | null | undefined {\n return node?.type === 'ConditionalExpression' && node.test.type === 'Identifier'\n ? node.consequent\n : node;\n}\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' | '$store' | '$id' | '$isPassed' | '$route' | '$navigation' | undefined {\n const init = guardedRead(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' ||\n name === '$store' ||\n name === '$id' ||\n name === '$isPassed' ||\n name === '$route' ||\n 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 * For a render that clones a template: the render functions of the nested `#if` and `#for`\n * blocks that it fills after the clone, in place of their markup. A block that it gives none\n * for renders inline.\n */\n fills?: (block: Block) => Fill | undefined;\n /**\n * Makes a constant of the module, for the templates that the functions of children clone. The\n * functions of children render HTML without it.\n */\n hoist?: (code: string) => string;\n /**\n * For the render module: an `await $memo` of the instance script splits the render there, and\n * the rest of it runs in `$$b.wait` when the memo settles.\n */\n waits?: boolean;\n}\n\n/**\n * Where a line of a render is: in which function, by its number, or -1 outside any, and whether\n * in an `if`, a loop or another branch of it. See `Emitter.levels`.\n */\nexport interface Level {\n fn: number;\n control: boolean;\n}\n\n/** The render functions that fill a nested block of a clone. */\nexport type Fill = { kind: 'if'; renders: string[] } | { kind: 'for'; render: string };\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 consumeStore: 'consumeStore',\n toStore: 'toStore',\n head: 'addHead',\n portal: 'addPortal',\n style: 'addStyle',\n fn: 'handlerProp',\n bindings: 'bindings',\n after: 'afterInsert',\n restRef: 'restRef',\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 /** Each `$$html +=` line, by its index in `lines`, with its parts, for cloned templates. */\n readonly flushes: { line: number; parts: Part[] }[] = [];\n /**\n * Where each line of `lines` is, for cloned templates: in which function, the first being 0,\n * and whether in a branch or a loop of it. Plain `{` blocks do not count.\n */\n readonly levels: Level[] = [];\n /** The lines that open or close a plain `{` block, which a clone can drop. */\n readonly plainBraces: Set<number> = new Set();\n /** The kinds of the `{` that are open: of a function, a branch or loop, or a plain block. */\n private braces: { kind: 'fn' | 'control' | 'plain'; fn?: number }[] = [];\n private fnCount = 0;\n /** The number of `$$b.wait` calls that the render opened, which its end closes. */\n waits = 0;\n /** Declarations that the rest of a render after `await` can assign: `let` before the split. */\n private reassignable: Set<Declaration> = new Set();\n /**\n * The scope whose script the function that is being written splits at `await $memo`: the\n * component in the render module, or the body of a render function of a block.\n */\n private splitScope: Scope | undefined;\n /** The awaited memos that a split waits for, so markup after it reads their values. */\n private readonly splitMemos = new Set<Declaration>();\n /** In the browser, the awaited memos whose loads start before their `await`, in `$$w_<name>`. */\n private readonly startedMemos = new Set<Declaration>();\n /** The memos that hold a primitive on the server, for the start points of loads in the browser. */\n private serverInline: Set<Declaration> | undefined;\n /** In the browser, the awaited memos of other loads that the load of a statement reads. */\n private readonly loadMemos = new Map<oxc.Node, Declaration[]>();\n /**\n * The calls that fill the nested blocks of a clone, by the scope and the anchor of each block.\n * `$$m` in a call is the start comment of the block.\n */\n readonly fills: Map<string, string> = new Map();\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 /** The components inside a `<p>`, which the server checks in development. */\n private readonly inParagraph: Set<object>;\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 /** The sites of the markup that update in the browser. */\n private readonly liveSites = new Set<Site>();\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 /** The tags of the elements around the node that renders, innermost last. */\n private readonly elements: string[] = [];\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 // Only the dev server checks, so a build carries no hint.\n this.inParagraph =\n options.mode === 'server' && !plan.hideNames ? paragraphComponents(file) : new Set();\n this.blocking = blockingMemos(plan);\n this.splitScope = options.waits ? plan.graph.model.component : undefined;\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 for (const node of plan.graph.nodes) {\n if (node.kind !== 'source' && plan.graph.live.has(node)) {\n this.liveSites.add(node.site);\n }\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.push(`${' '.repeat(this.depth)}${code}`);\n if (code.endsWith('{')) {\n this.depth++;\n const trimmed = code.trim();\n if (trimmed === '{') {\n this.plainBraces.add(this.lines.length - 1);\n }\n if (trimmed === '{') {\n this.braces.push({ kind: 'plain' });\n } else if (/=> \\{$|^(?:export )?(?:default )?function\\b/.test(trimmed)) {\n this.braces.push({ kind: 'fn', fn: this.fnCount++ });\n } else {\n this.braces.push({ kind: 'control' });\n }\n }\n }\n\n /** Opens the rest of a render after `await`, which stays in the function that holds it. */\n private openRest(code: string): void {\n this.flush();\n const fn = this.currentFn;\n this.push(`${' '.repeat(this.depth)}${code}`);\n this.depth++;\n this.braces.push({ kind: 'fn', fn });\n this.waits++;\n }\n\n /**\n * Writes the body of a render function whose script `await $memo` splits: `content` writes\n * the body of `scope`, and the rests that it opened close after `end`, the return line.\n */\n splitBody(scope: Scope | undefined, content: () => void, end: () => void): void {\n const outer = this.splitScope;\n const waits = this.waits;\n const memos = [...this.splitMemos];\n this.splitScope = scope;\n content();\n this.splitScope = outer;\n end();\n // The memos that the function waited for are values only inside it.\n this.splitMemos.clear();\n for (const memo of memos) {\n this.splitMemos.add(memo);\n }\n for (; this.waits > waits; this.waits--) {\n this.close('});');\n }\n }\n\n close(code = '}'): void {\n this.flush();\n this.depth--;\n if (this.braces.pop()?.kind === 'plain' && code === '}') {\n this.plainBraces.add(this.lines.length);\n }\n this.push(`${' '.repeat(this.depth)}${code}`);\n if (code.endsWith('{')) {\n this.depth++;\n this.braces.push({ kind: 'control' });\n }\n }\n\n /** `svg` or `math` when the elements around `owner`, a body or children, put its markup there. */\n foreignAround(owner: object | undefined): string | undefined {\n return foreignContext(this.file, owner);\n }\n\n /**\n * The return of a render function of the browser: its clone, its HTML, or an empty string\n * for a function with no markup, which is not HTML that the core must parse.\n */\n returnLine(fn: number, cloned: boolean): string {\n if (cloned) {\n return 'return $$f;';\n }\n let markup = false;\n for (const flush of this.flushes) {\n if (this.levels[flush.line]!.fn === fn) {\n markup = true;\n break;\n }\n }\n return markup ? 'return $$html;' : \"return '';\";\n }\n\n /** The number of the function that the next line is in, or -1. */\n get currentFn(): number {\n for (let i = this.braces.length - 1; i >= 0; i--) {\n const brace = this.braces[i]!;\n if (brace.kind === 'fn') {\n return brace.fn ?? -1;\n }\n }\n return -1;\n }\n\n /** Adds a line, with where it is. */\n private push(line: string): void {\n this.lines.push(line);\n // The innermost function brace, and whether a control brace sits inside it.\n let at = -1;\n let control = false;\n for (let i = this.braces.length - 1; i >= 0; i--) {\n const kind = this.braces[i]!.kind;\n if (kind === 'fn') {\n at = i;\n break;\n }\n if (kind === 'control') {\n control = true;\n }\n }\n this.levels.push({\n fn: at === -1 ? -1 : this.braces[at]!.fn!,\n control,\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 for (const [index, line] of code.split('\\n').entries()) {\n const text = index === 0 ? line : line.replace(new RegExp(`^ {0,${column}}`), '');\n this.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, settled?: Settled, promise?: string): void {\n const part: Part = settled ? { code, settled } : { code };\n if (promise) {\n part.promise = promise;\n }\n this.parts.push(part);\n }\n\n /**\n * In the browser, the scope of a value of markup that can be a promise: one that calls code,\n * such as `{load(id)}`, or reads a prop typed as a promise. The clone writes its value once it\n * settles, and a `#loading` around it shows its fallback until then.\n */\n private promiseScope(expression: Expression, scope: Scope): string | undefined {\n return this.options.mode === 'client' &&\n mayBePromise(expression.ast, this.sitesByNode.get(expression.ast))\n ? this.scopeVar(instanceScope(this.plan, scope))\n : undefined;\n }\n\n /**\n * In the browser, the memos that values of the markup read that never change and can be a\n * promise, such as an insert, the headers of a block or the props of a component. No update\n * writes them when the memos settle, so the clone holds back what reads them.\n */\n private settledMemos(expressions: Expression[], scope: Scope): Settled | undefined {\n if (this.options.mode !== 'client') {\n return undefined;\n }\n const names: string[] = [];\n for (const expression of expressions) {\n const site = this.sitesByNode.get(expression.ast);\n // A site that reads a live memo is live too, as the graph spreads liveness to its readers,\n // so the memos below never change.\n if (!site || this.liveSites.has(site)) {\n return undefined;\n }\n for (const reference of site.reads) {\n const declaration = reference.declaration;\n // A read inside a function counts too, such as `list.map(() => value)`, as the function\n // gets the value that the memo settles to.\n if (\n isMemo(declaration) &&\n !isNeverPromise(declaration) &&\n // `wait` gives the rest of the render the value of a memo that the script awaits.\n !this.splitMemos.has(declaration) &&\n !names.includes(declaration.name)\n ) {\n names.push(declaration.name);\n }\n }\n }\n return names.length > 0\n ? { names, scope: this.scopeVar(instanceScope(this.plan, scope)) }\n : undefined;\n }\n\n flush(): void {\n if (this.parts.length === 0) {\n return;\n }\n const parts = this.parts;\n this.parts = [];\n this.flushes.push({ line: this.lines.length, parts });\n const pieces: string[] = [];\n for (const part of parts) {\n pieces.push('static' in part ? JSON.stringify(part.static) : part.code);\n }\n const value = pieces.join(' + ');\n this.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 if (!outer) {\n return true;\n }\n for (const item of outer.inside) {\n if (isWithin(scope, item)) {\n return true;\n }\n }\n return false;\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 if (index === undefined) {\n return undefined;\n }\n // A scope that a client render does not create is an instance, such as the scope that\n // children were written in, and an anchor names its ID.\n const name = this.scopeVar(scope);\n return { scope: this.isInside(scope) ? name : `${name}.id`, 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 /** On the server, records the bound props before the markup, for `refKey`. */\n private emitBound(scope: Scope): void {\n if (this.options.mode !== 'server') {\n return;\n }\n const bindable = this.bindableProps(scope);\n if (bindable.length > 0) {\n this.line(`$$ctx.bound(${this.scopeVar(scope)}, $$props, { ${bindable.join(', ')} });`);\n }\n }\n\n /** The props that the component writes, as `\"key\": slot` entries. */\n private bindableProps(scope: Scope): string[] {\n const bindable: string[] = [];\n const slots = this.plan.scopes.get(scope)?.slots ?? [];\n for (const [index, slot] of slots.entries()) {\n if (slot.kind === 'prop' && slot.writable && slot.propKey !== undefined) {\n bindable.push(`${JSON.stringify(slot.propKey)}: ${index}`);\n }\n }\n return bindable;\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: string[] = [];\n const slotNames: string[] = [];\n for (const slot of slots) {\n values.push(this.isPromise(slot) ? `$$b.stateValue(${promiseName(slot.name)})` : slot.name);\n slotNames.push(slot.name);\n }\n // The server also passes the names, so an error can say which value cannot be sent.\n const names = this.options.mode === 'server' ? `, ${JSON.stringify(slotNames)}` : '';\n this.line(\n `${this.helper('slots')}(${this.scopeVar(scope)}, [${values.join(', ')}]${names});`,\n );\n }\n // In the browser, a `#loading` body around the render waits for the memos that the server\n // waits for where they are declared, as markup outside every `#loading` body reads them.\n if (this.options.mode === 'client') {\n const loads: string[] = [];\n for (const declaration of scope.declarations.values()) {\n if (this.blocking.has(declaration) && mayLoad(declaration)) {\n loads.push(declaration.name);\n }\n }\n if (loads.length > 0) {\n this.line(\n `$$b.countLoads(${this.scopeVar(instanceScope(this.plan, scope))}, [${loads.join(', ')}]);`,\n );\n }\n }\n // The props that the component writes, which a parent can bind with `$bind`.\n if (scope.kind === 'component') {\n const bindable = this.bindableProps(scope);\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 server = this.options.mode === 'server',\n ): { declarations: Declaration[]; awaited: boolean } | undefined {\n if (!server || statement.type !== 'VariableDeclaration') {\n return undefined;\n }\n // The browser places loads as the server does, which knows the memos that hold a primitive.\n const inline =\n this.options.mode === 'server'\n ? this.inline\n : (this.serverInline ??= plainValues(this.plan, this.blocking));\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 (!inline.has(declaration)) {\n declarations.push(declaration);\n }\n }\n return declarations.length === 0 ? undefined : { declarations, awaited };\n }\n\n /**\n * Waits for a memo that the markup reads, and keeps its error for the read: the markup reads\n * the memo in place, so the `#try` around the read gets the error. A `#loading` or `#defer`\n * body waits for the memos that only it reads the same way.\n */\n private awaitHeld(declaration: Declaration): void {\n this.line(`let ${declaration.name};`);\n this.line(`try { ${declaration.name} = ${this.memoValue(declaration.name)}; } catch {}`);\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: string[] = [];\n for (const declaration of run) {\n names.push(promiseName(declaration.name));\n }\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 /**\n * True for a statement that runs nothing where it is written on the server,\n * such as `$effect`, an import or a type. It does not end a run of awaits.\n */\n private isQuiet(statement: oxc.Node): boolean {\n if (statement.type === 'ImportDeclaration' || TYPE_DECLARATIONS.has(statement.type)) {\n return true;\n }\n if (statement.type !== 'ExpressionStatement') {\n return false;\n }\n const expression = statement.expression;\n return (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'Identifier' &&\n (expression.callee.name === '$effect' || expression.callee.name === '$client')\n );\n }\n\n /**\n * The awaited memos whose loads start before statements that do not hold\n * them, by the index of the statement that they start after (-1 for the\n * top). Each `await` still waits where it is written. The browser, where\n * the script splits at each `await`, places them as the server does. A\n * load there reads the values of the memos whose loads it waits for as\n * parameters, so one that reads such a memo through a function or another\n * memo starts after that memo's `await`.\n */\n private earlyLoads(\n statements: oxc.Node[],\n scope: Scope,\n splits: boolean,\n ): Map<number, oxc.Node[]> {\n const moved = new Map<number, oxc.Node[]>();\n const server = this.options.mode === 'server';\n if (!server && !splits) {\n return moved;\n }\n // The statements whose every declarator is an awaited memo that the server reads as a memo,\n // and that the browser splits at.\n const loads = new Map<oxc.Node, Declaration[]>();\n const declaredAt = new Map<Declaration, number>();\n for (const [index, statement] of statements.entries()) {\n const blocking = this.blockingDeclarations(statement, true);\n if (\n blocking?.awaited &&\n statement.type === 'VariableDeclaration' &&\n blocking.declarations.length === statement.declarations.length &&\n (server || this.isAllAwaitedMemos(statement, scope))\n ) {\n loads.set(statement, blocking.declarations);\n for (const declaration of blocking.declarations) {\n declaredAt.set(declaration, index);\n }\n }\n }\n if (loads.size === 0) {\n return moved;\n }\n const starts = findLoadStarts(\n statements,\n scope,\n loads,\n (statement) => !this.isQuiet(statement),\n );\n // In the browser, each `await` waits on its own, so the awaits of a run, which the server\n // starts together, start before the first of them. By index, the first of the run.\n const runs = new Map<number, number>();\n if (!server) {\n let members: number[] = [];\n const endRun = (): void => {\n if (members.length > 1) {\n for (const member of members) {\n runs.set(member, members[0]!);\n }\n }\n members = [];\n };\n for (const [index, statement] of statements.entries()) {\n if (this.blockingDeclarations(statement, true)?.awaited) {\n members.push(index);\n } else if (!this.isQuiet(statement)) {\n endRun();\n }\n }\n endRun();\n }\n // The index of the statement that a load reading each memo must start after: the start\n // point of a memo that moves, or the statement of one that stays.\n const placed = new Map<Declaration, number>();\n for (const [index, statement] of statements.entries()) {\n const start = starts.get(statement);\n if (!start) {\n continue;\n }\n // A memo of another load must be declared first.\n let after = start.after;\n for (const memo of start.memos) {\n after = Math.max(after, placed.get(memo) ?? index - 1);\n }\n if (!server) {\n // In the browser, a memo that the load reads other than by its name has its value after\n // its `await`.\n const reads = new Set<Declaration>();\n for (const declaration of loads.get(statement)!) {\n for (const reference of declaration.site?.reads ?? []) {\n reads.add(reference.declaration);\n }\n }\n for (const memo of start.memos) {\n const at = declaredAt.get(memo) ?? -1;\n if (at > after && !reads.has(memo)) {\n after = at;\n }\n }\n this.loadMemos.set(statement, start.memos);\n }\n // The load moves only over a statement that waits: the end of a run of awaits before it,\n // a memo that the markup waits for, or an `await` of the script.\n let ends = false;\n let inRun = false;\n for (let between = after + 1; between < index && !ends; between++) {\n const other = statements[between]!;\n const blocking = this.blockingDeclarations(other, true);\n if (blocking?.awaited) {\n inRun = true;\n } else if (!this.isQuiet(other)) {\n ends = inRun || blocking !== undefined || hasAwait(other);\n }\n }\n const first = runs.get(index);\n if (!ends && first !== undefined) {\n after = Math.max(after, first - 1);\n ends = true;\n }\n // A memo that stays is declared in its own statement, after the loads that start before it.\n const at = ends ? after : index;\n for (const declaration of loads.get(statement)!) {\n placed.set(declaration, at);\n }\n if (ends) {\n const list = moved.get(after) ?? [];\n list.push(statement);\n moved.set(after, list);\n }\n }\n return moved;\n }\n\n /**\n * Declares the memos of a load that starts early, and starts them. In the browser, the load\n * goes in `$$w_<name>`, which its `await` waits for, and it waits for the loads of the memos\n * that it reads which have not reached their `await`.\n */\n private startLoads(statements: oxc.Node[] | undefined): void {\n for (const statement of statements ?? []) {\n if (this.options.mode === 'client') {\n const declarations = statement.type === 'VariableDeclaration' ? statement.declarations : [];\n for (const declarator of declarations) {\n const declaration = this.awaitedMemos(statement, this.splitScope!)![\n declarations.indexOf(declarator)\n ]!;\n const load = this.source(declarator.init!);\n const waits: string[] = [];\n const names: string[] = [];\n for (const memo of this.loadMemos.get(statement) ?? []) {\n if (this.startedMemos.has(memo) && !this.splitMemos.has(memo)) {\n waits.push(`$$w_${memo.name}`);\n names.push(memo.name);\n }\n }\n const value =\n waits.length > 0\n ? `$$b.after([${waits.join(', ')}], (${names.join(', ')}) => ${load})`\n : `$$b.started(() => ${load})`;\n this.line(`const $$w_${declaration.name} = ${value};`);\n this.startedMemos.add(declaration);\n }\n continue;\n }\n this.raw(this.patch.slice(statement.start, statement.end), statement.start);\n for (const declaration of this.blockingDeclarations(statement)!.declarations) {\n this.line(`$$b.start(${promiseName(declaration.name)});`);\n }\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 // In the browser, the script of a render function splits at each `await $memo`. The\n // statements before its last one declare with `let`, so the rest of the render can assign\n // what changed during a wait.\n const splits = this.options.mode === 'client' && scope === this.splitScope;\n const early = this.earlyLoads(statements, scope, splits);\n const started = new Set<oxc.Node>();\n for (const list of early.values()) {\n for (const statement of list) {\n started.add(statement);\n }\n }\n this.startLoads(early.get(-1));\n let lastAwait = -1;\n for (const [index, statement] of statements.entries()) {\n if (splits && this.awaitedMemos(statement, scope)) {\n lastAwait = index;\n }\n }\n // Markup that awaits a memo of the script waits after all of it, and assigns the memo.\n if (splits) {\n for (const declaration of this.markupAwaits(scope)) {\n if (declaration.scope === scope) {\n lastAwait = statements.length;\n }\n }\n }\n for (const [index, statement] of statements.entries()) {\n if (index > 0) {\n this.startLoads(early.get(index - 1));\n }\n const awaited = splits ? this.awaitedMemos(statement, scope) : undefined;\n if (awaited) {\n this.splitAtAwait(statement as oxc.VariableDeclaration, awaited, scope);\n continue;\n }\n const blocking = this.blockingDeclarations(statement);\n if (blocking?.awaited) {\n if (!started.has(statement)) {\n this.raw(this.patch.slice(statement.start, statement.end), statement.start);\n }\n run.push(...blocking.declarations);\n continue;\n }\n // A statement that runs nothing on the server does not end a run.\n if (this.options.mode === 'server' && this.isQuiet(statement)) {\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.awaitHeld(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 let code = this.patch.slice(statement.start, statement.end);\n let partial = false;\n if (this.options.mode === 'client' && statement.type === 'VariableDeclaration') {\n // The browser follows the server: a memo that no browser code reads is not computed.\n const kept: string[] = [];\n for (const declarator of statement.declarations) {\n const declaration =\n declarator.id.type === 'Identifier'\n ? scope.declarations.get(declarator.id.name)\n : undefined;\n if (!declaration || !this.plan.graph.unread.has(declaration)) {\n kept.push(this.patch.slice(declarator.start, declarator.end));\n }\n }\n if (kept.length === 0) {\n continue;\n }\n if (kept.length < statement.declarations.length) {\n // The kept slices of the patch carry their source markers, which map the line. `raw`\n // takes the offset only to strip the indent of later lines.\n code = `${statement.kind} ${kept.join(', ')};`;\n partial = true;\n }\n }\n if (index < lastAwait && statement.type === 'VariableDeclaration') {\n if (statement.kind === 'const') {\n // The patch can rewrite the keyword, so a statement that is whole starts at its offset.\n code = partial\n ? `let${code.slice('const'.length)}`\n : `let${this.patch.slice(statement.start + 'const'.length, statement.end)}`;\n }\n for (const declaration of scope.declarations.values()) {\n if (\n declaration.range.start >= statement.start &&\n declaration.range.end <= statement.end\n ) {\n this.reassignable.add(declaration);\n }\n }\n }\n this.raw(code, statement.start);\n if (this.options.mode === 'client' && statement.type === 'VariableDeclaration') {\n this.watchUnreadMemos(statement, scope, splits);\n }\n }\n endRun();\n }\n\n /**\n * Emits a body that renders inline, in the function of the markup around it. In the browser,\n * a body that waits at `await` renders through a function of its own, which can split.\n */\n private emitInlineBody(body: Body): void {\n const own = this.plan.bodyScopes.get(body)!;\n if (\n this.options.mode !== 'client' ||\n !this.options.hoist ||\n !this.splitsScript(body, own, own)\n ) {\n this.emitBody(body);\n return;\n }\n const fn = this.bodyFunction('', () => this.emitBody(body), own);\n this.code(`$$b.nodes($$b.branchNodes(undefined, undefined, 0, [${fn}]))`);\n }\n\n /** True when the script of a body splits its render function at `await $memo`. */\n private splitsScript(body: Body, scope: Scope, splitScope = this.splitScope): boolean {\n if (this.options.mode !== 'client' || scope !== splitScope) {\n return false;\n }\n for (const statement of body.script?.program.body ?? []) {\n if (this.awaitedMemos(statement, scope)) {\n return true;\n }\n }\n return this.markupAwaits(scope).length > 0;\n }\n\n /** The memos that the markup of a scope awaits, which no split before it waited for. */\n private markupAwaits(scope: Scope): Declaration[] {\n const result: Declaration[] = [];\n for (const site of this.plan.graph.model.sites) {\n if (site.scope !== scope || !MARKUP_SITES.has(site.kind)) {\n continue;\n }\n for (const read of site.reads) {\n const declaration = read.declaration;\n if (\n read.await &&\n isMemo(declaration) &&\n !this.splitMemos.has(declaration) &&\n !result.includes(declaration)\n ) {\n result.push(declaration);\n }\n }\n }\n return result;\n }\n\n /**\n * In the browser, markup that reads a memo with `await` waits for it at the start of the\n * markup, after the script, as the server waits for the memos that a `#loading` body reads at\n * its start. A memo of the scope is assigned its value. One of a scope around it is a constant\n * of the rest, with the value, since the scope that waits holds it after its slots.\n */\n private awaitMarkup(scope: Scope, end: number): void {\n if (this.options.mode !== 'client' || scope !== this.splitScope) {\n return;\n }\n const slots = this.plan.scopes.get(scope)?.slots ?? [];\n for (const declaration of this.markupAwaits(scope)) {\n const own = declaration.scope === scope;\n let at = own ? slots.indexOf(declaration) : -1;\n if (at === -1) {\n at = slots.length;\n }\n const values: string[] = [];\n const names: string[] = [];\n for (const [slot, declared] of slots.entries()) {\n const before = declared.range.start < end;\n values[slot] = before ? declared.name : '';\n names[slot] = before && this.reassignable.has(declared) ? declared.name : '';\n }\n values[at] = declaration.name;\n names[at] = own ? declaration.name : '';\n while (values.at(-1) === '') {\n values.pop();\n }\n while (names.at(-1) === '') {\n names.pop();\n }\n this.openRest(\n `return $$b.wait(${this.scopeVar(scope)}, [${values.join(', ')}], ${at}, ($$v) => {`,\n );\n if (names.length > 0) {\n this.line(`[${names.join(', ')}] = $$v;`);\n }\n if (!own) {\n // A pattern, as a clone of the rest reads the value, not the name of the scope around.\n this.line(`const [${','.repeat(at)}${declaration.name}] = $$v;`);\n }\n this.splitMemos.add(declaration);\n }\n }\n\n /** The awaited memos that the declarators of a statement declare, by declarator. */\n /** True when every declarator of a statement is an awaited memo. */\n private isAllAwaitedMemos(statement: oxc.Node, scope: Scope): boolean {\n const awaited = this.awaitedMemos(statement, scope);\n if (!awaited) {\n return false;\n }\n for (const declaration of awaited) {\n if (!declaration) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * True when every read of a memo drops its promise: the reader is a memo that is not declared,\n * or the read awaits the memo and is not the whole value of another memo.\n */\n private isEveryReadDropped(declaration: Declaration): boolean {\n for (const read of declaration.reads) {\n const dropped =\n (read.site.kind === 'memo' && this.plan.graph.unread.has(read.site.declaration!)) ||\n (read.await &&\n (read.site.kind !== 'memo' ||\n read.site.node.start !== read.await.start ||\n read.site.node.end !== read.await.end));\n if (!dropped) {\n return false;\n }\n }\n return true;\n }\n\n private awaitedMemos(statement: oxc.Node, scope: Scope): (Declaration | undefined)[] | undefined {\n if (statement.type !== 'VariableDeclaration') {\n return undefined;\n }\n const awaited: (Declaration | undefined)[] = [];\n let any = false;\n for (const declarator of statement.declarations) {\n const declaration =\n declarator.init?.type === 'AwaitExpression' && declarator.id.type === 'Identifier'\n ? scope.declarations.get(declarator.id.name)\n : undefined;\n const found =\n declaration && isMemo(declaration) && declaration.awaited ? declaration : undefined;\n awaited.push(found);\n any ||= found !== undefined;\n }\n return any ? awaited : undefined;\n }\n\n /**\n * In the render module, a declaration of `await $memo(...)` ends the code that runs now: the\n * rest of the render goes in `$$b.wait`, which gets the slots that the code so far set, with\n * the load at the slot of the memo. The memo is a `let` before the call, so a function\n * declared before the `await` reads it, and the rest assigns it and the slots that can change\n * during the wait, such as props.\n */\n private splitAtAwait(\n statement: oxc.VariableDeclaration,\n awaited: (Declaration | undefined)[],\n scope: Scope,\n ): void {\n const slots = this.plan.scopes.get(scope)?.slots ?? [];\n for (const [index, declarator] of statement.declarations.entries()) {\n const declaration = awaited[index];\n if (!declaration) {\n this.line(`${statement.kind} ${this.source(declarator)};`);\n continue;\n }\n // A memo that no update reads has no slot, so it waits past the last one.\n let at = slots.indexOf(declaration);\n if (at === -1) {\n at = slots.length;\n }\n // The slots that the code before the `await` declared. The others are holes until the\n // rest sets them. The rest assigns those that the code declared with `let`.\n const values: string[] = [];\n const names: string[] = [];\n for (const [slot, declared] of slots.entries()) {\n const before = declared.range.start < declarator.start;\n values[slot] = before ? declared.name : '';\n names[slot] = before && this.reassignable.has(declared) ? declared.name : '';\n }\n values[at] = this.startedMemos.has(declaration)\n ? `$$w_${declaration.name}`\n : this.source(declarator.init!);\n names[at] = declaration.name;\n while (values.at(-1) === '') {\n values.pop();\n }\n while (names.at(-1) === '') {\n names.pop();\n }\n this.line(`let ${declaration.name};`);\n this.openRest(\n `return $$b.wait(${this.scopeVar(scope)}, [${values.join(', ')}], ${at}, ($$v) => {`,\n );\n this.line(`[${names.join(', ')}] = $$v;`);\n this.reassignable.add(declaration);\n this.splitMemos.add(declaration);\n }\n }\n\n /**\n * In the browser, a memo that only `await` reads has no slot, so no load takes its promise.\n * The server waits at the `await` and throws the error there, so the rejection goes to the\n * nearest `#try`, which is where a memo that throws sends its error. A memo that always gives a\n * primitive, such as `count * 2`, is never a promise, unless it has `await` inside. `await memo`\n * compiles to a plain read of the promise, which drops it, unless the read is the whole value of\n * another memo, as in `$memo(await memo)`, which then holds the same promise. A memo that\n * nothing reads is not declared (`Graph.unread`), and neither is one that only such a memo reads.\n */\n private watchUnreadMemos(\n statement: oxc.VariableDeclaration,\n scope: Scope,\n splits: boolean,\n ): void {\n // Markup that awaits a memo waits for it at its start, which handles its rejection.\n const awaited = splits ? this.markupAwaits(scope) : [];\n for (const declarator of statement.declarations) {\n const declaration =\n declarator.id.type === 'Identifier'\n ? scope.declarations.get(declarator.id.name)\n : undefined;\n if (\n declaration &&\n !awaited.includes(declaration) &&\n (declaration.kind === 'memo' || declaration.kind === 'async-memo') &&\n !this.plan.graph.unread.has(declaration) &&\n this.isEveryReadDropped(declaration) &&\n slotIndex(this.plan, declaration) === -1 &&\n !isNeverPromise(declaration)\n ) {\n const target = this.scopeVar(instanceScope(this.plan, scope));\n this.line(`$$b.unreadMemo(${target}, ${declaration.name});`);\n }\n }\n }\n\n private source(node: { start: number; end: number }): string {\n return this.patch.slice(node.start, node.end);\n }\n\n /**\n * The fallback of a context read, which the runtime uses only when no provider is above. A\n * literal is passed as it is, and other code as a function, so it runs only then.\n */\n private fallback(node: oxc.Node): string {\n const code = this.source(node);\n return isFallbackLiteral(node) ? code : `() => (${code})`;\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 let special = false;\n for (const declarator of statement.declarations) {\n if (specialCall(declarator)) {\n special = true;\n break;\n }\n }\n if (!special) {\n return false;\n }\n const target = this.scopeVar(instanceScope(this.plan, scope));\n for (const declarator of statement.declarations) {\n const init = guardedRead(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 // A guarded read of a store is `undefined` when the optional value in its test is.\n const guard = declaration?.guard;\n const ask = guard ? `${this.source(guard)} ? ` : '';\n const otherwise = guard ? ' : 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 if (call === '$isPassed' && declaration?.passedKey !== undefined) {\n // The props as the caller passed them, before defaults apply.\n this.line(\n `const ${declaration.name} = ${JSON.stringify(declaration.passedKey)} in $$props;`,\n );\n continue;\n }\n if (call === '$store' && declaration?.store && declarator.id.type === 'Identifier') {\n // `$store(source)`: the source is a context, a store, or an object that holds the store at\n // `path`. `link` is the place of its import among the exports `z` of the update part.\n const { source, path, link, write, sent, fallback } = declaration.store;\n const slot = slotIndex(this.plan, declaration);\n // The server names a sent value that holds a store of another library.\n const named = this.options.mode === 'server' && sent ? JSON.stringify(sent) : undefined;\n const rest = [\n path === undefined ? undefined : JSON.stringify(path),\n link === undefined ? undefined : String(link),\n write ? 'true' : undefined,\n fallback ? this.fallback(fallback) : named,\n ];\n while (rest.length > 0 && rest.at(-1) === undefined) {\n rest.pop();\n }\n const more = rest.map((item) => `, ${item ?? 'undefined'}`).join('');\n this.line(\n `const ${declarator.id.name} = ${ask}${this.helper('consumeStore')}(${this.source(source)}, ${target}, ${slot}${more})${otherwise};`,\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 of `$route` and `$navigation` is recorded, so navigation reaches it on the\n // client. The value of `$getContext` is read once, and a fallback is the third argument.\n let more = '';\n if (slot !== -1 && BUILT_IN_CONTEXTS[call ?? '']) {\n more = `, undefined, ${slot}`;\n } else if (call === '$getContext' && init.arguments.length > 1) {\n more = `, ${this.fallback(init.arguments[1]!)}`;\n }\n this.line(\n `const ${declarator.id.name} = ${ask}${this.helper('consume')}(${context}, ${target}${more})${otherwise};`,\n );\n }\n return true;\n }\n\n private isServerStatement(statement: oxc.Node): boolean {\n const nodes: (oxc.Node | null | undefined)[] = [];\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n nodes.push(declarator.init);\n }\n } else {\n nodes.push(statement);\n }\n for (const node of nodes) {\n if (!node || this.sitesByNode.get(node)?.kind !== 'server-function') {\n return false;\n }\n }\n return true;\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 for (const declarator of statement.declarations) {\n const init = declarator.init;\n if (init?.type !== 'ArrowFunctionExpression' && init?.type !== 'FunctionExpression') {\n return false;\n }\n }\n return true;\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 } else if (site.trigger === 'visible' && this.options.mode === 'server') {\n // A signal that a component gets with `ref=$bind(name)` waits for the element it forwards.\n const forwarded = this.forwardedSignal(site, scope);\n if (forwarded) {\n this.code(`$$ctx.near(${anchor.scope}, ${slotIndex(this.plan, forwarded)})`);\n }\n }\n this.html('></template>');\n }\n }\n\n /** The code of the `b-r` attribute of an element that has `ref=$bind(name)` with a prop. */\n private forwardedRef(node: ElementNode): string | undefined {\n if (this.options.mode !== 'server') {\n return undefined;\n }\n for (const attribute of node.attributes) {\n const declaration = attribute.kind === 'ref' ? this.refTargets.get(attribute) : undefined;\n if (declaration?.kind === 'prop') {\n const scope = this.scopeVar(instanceScope(this.plan, declaration.scope));\n return `$$ctx.refKey(${scope}, ${slotIndex(this.plan, declaration)})`;\n }\n }\n return undefined;\n }\n\n /** The signal of `scope` that a site reads, which a component may forward its element to. */\n private forwardedSignal(site: Site, scope: Scope): Declaration | undefined {\n for (const read of site.reads) {\n const declaration = read.declaration;\n if (declaration.scope !== scope || declaration.kind !== 'signal') {\n continue;\n }\n for (const binding of this.plan.graph.model.bindings) {\n if (binding.declaration === declaration && !binding.setter) {\n return declaration;\n }\n }\n }\n return undefined;\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. The browser adds it\n // to the head, so it is not in the markup.\n if (this.options.mode === 'client') {\n this.line(`${this.helper('style')}(${JSON.stringify(this.plan.id)}, $$css);`);\n } else {\n this.code(`${this.helper('style')}(${JSON.stringify(this.plan.id)}, $$css)`);\n }\n }\n this.emitStatements(setup, component);\n this.awaitMarkup(component, this.file.instanceScript?.program.end ?? 0);\n this.emitBound(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 /**\n * Emits a body: its scope, script, templates, markup and slots. `markup` writes what goes\n * before the markup, after the script.\n */\n emitBody(body: Body, createScope = true, markup?: () => void): void {\n const scope = this.plan.bodyScopes.get(body)!;\n const plan = this.plan.scopes.get(scope)!;\n // A body that waits holds its slots in its scope while it waits.\n if ((plan.needsId || this.splitsScript(body, scope)) && createScope) {\n this.createScope(scope);\n }\n if (body.script) {\n this.emitStatements(body.script.program.body, scope);\n }\n this.awaitMarkup(scope, body.script?.program.end ?? body.start);\n markup?.();\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 // An item that waits at `await $memo` has its value before the wait, as the range of the\n // wait marks the item, and its start marker is in the rest of the render.\n const splits = this.splitsScript(block.body, scope);\n if (this.plan.scopes.get(scope)!.needsId || splits) {\n this.createScope(scope);\n }\n const from = source ? `, ${source}` : '';\n const setItem = `${this.helper('item')}(${this.scopeVar(scope)}, ${item}${from});`;\n if (splits && this.plan.anchors.has(block)) {\n this.line(setItem);\n }\n const open = (): void => {\n if (anchored) {\n this.html('<!--i');\n this.code(this.scopeVar(scope));\n this.html('-->');\n }\n };\n if (!splits) {\n open();\n }\n this.emitBody(block.body, false, splits ? open : undefined);\n if (this.plan.anchors.has(block) && !splits) {\n this.line(setItem);\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 const scope = this.plan.bodyScopes.get(template.body)!;\n // In the browser, a call of a template that updates in place makes a call that the insert\n // renders, or updates, with the arguments. The template's code is `name$`.\n const call = this.options.mode === 'client' && templateArgs(this.plan, this.file.source, scope);\n const name = call ? `${template.name}$` : template.name;\n if (call) {\n // Each argument is passed with the default value that the parameter gives it.\n const own = call.names ? call.params : '...$$a';\n const given = call.names ? `[${call.names.join(', ')}]` : '$$a';\n const owner = this.scopeVar(instanceScope(this.plan, scope.parent!));\n const ref = JSON.stringify(`${this.plan.id}#T${scope.id}`);\n this.line(\n `function ${template.name}(${own}) { return $$b.templateCall(${ref}, ${owner}, ${name}, ${given}); }`,\n );\n }\n this.line(`${this.async}function ${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 // The output names the template's scope, which the insert links to where it is called.\n const at = this.plan.scopes.get(scope)!.needsId ? `, ${this.scopeVar(scope)}` : '';\n this.line(`return $$b.raw($$html${at});`);\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 // A value that reads a prop can be children, or a template that a prop holds, such as\n // `{item(label)}`, which render where they are inserted too.\n const site = this.sitesByNode.get(node.expression.ast);\n const readsProp = readsProps(site);\n // Children in a table body or a list get the tag of the spacers of a windowed list in them.\n const spacer = this.parentSpacer();\n // On the server, children also get the anchor of the insert, so the browser knows that\n // the server rendered them here.\n const server = this.options.mode === 'server' && readsProp;\n let rest = server && spacer !== undefined ? `, ${JSON.stringify(spacer)}` : '';\n if (server && anchor) {\n rest = `${rest || ', undefined'}, ${anchor.index}`;\n }\n const at =\n // The output of a template links its scope to this insert, so a `#try` here catches\n // its errors. A function can return the output of one too.\n this.options.mode === 'server' || readsProp || callsTemplate(site)\n ? `, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))}${rest}`\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 settled = this.settledMemos([node.expression], scope);\n const promise = this.promiseScope(node.expression, scope);\n const emitValue = (): void =>\n text === undefined ? this.code(value, settled, promise) : 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 // In the browser, the `#loading` blocks that the body renders join a group of the block,\n // also those of the components inside it.\n if (node.reveal && this.options.mode === 'client' && mayReveal(node.children)) {\n const body = this.bodyFunction('', () => this.emitNodes(node.children, scope));\n this.code(\n `$$b.nodes($$b.reveal(${JSON.stringify(node.reveal.order)}, ${node.reveal.collapsed}, ${body}))`,\n );\n return;\n }\n this.emitNodes(node.children, scope);\n return;\n case 'listener': {\n const anchor = this.anchor(scope, node)!;\n const events: string[] = [];\n for (const attribute of node.attributes) {\n events.push(this.eventEntry(attribute));\n }\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 let binding: (typeof this.plan.graph.model.bindings)[number] | undefined;\n for (const item of this.plan.graph.model.bindings) {\n if (item.call === value) {\n binding = item;\n break;\n }\n }\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 let type: { value: string | true } | undefined;\n for (const item of node.attributes) {\n if (item.kind === 'static' && item.name === 'type') {\n type = item;\n break;\n }\n }\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, handler }: EventAttribute): string {\n const site = this.sitesByNode.get(handler.ast)!;\n // The modifiers of the wrappers of `brumate/events`.\n const all = [...new Set(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 when?: string,\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 const guard = when ? `if (${when}) ` : '';\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(() => { ${guard}$$b.set(${path}, ${slotIndex(this.plan, declaration)}, ${element}); });`,\n );\n } else {\n this.line(`${guard}${target} = ${element};`);\n }\n }\n\n /**\n * What `ref` passes a component, as `$bind(name)` does: the value of the name with its slot, so\n * the writes of the component reach it.\n */\n private getBinding(declaration: Declaration): string {\n const outer = this.options.outer;\n const slot = slotIndex(this.plan, declaration);\n if (outer && !this.isInside(declaration.scope)) {\n const path = scopePath(this.plan, outer.baseVar, outer.base, declaration.scope);\n return `$$b.binding($$b.get(${path}, ${slot}), ${path}, ${slot})`;\n }\n const scope = this.scopeVar(instanceScope(this.plan, declaration.scope));\n return `$$b.binding(${declaration.name}, ${scope}, ${slot})`;\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. An element with\n * spreads gets them after its attributes merge, so it returns them as code,\n * and the style of a spread does not take the place of the variables.\n */\n private emitVariables(node: ElementNode): string | undefined {\n const { variables } = this.plan.styles;\n if (variables.length === 0 || this.nesting > 0) {\n return undefined;\n }\n const values = this.variableValues();\n if (hasSpread(node.attributes)) {\n this.emitLiveStyles();\n return values;\n }\n const own = findStyleAttribute(node.attributes);\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}, ${existing}))`);\n this.emitLiveStyles();\n return values;\n }\n\n /** The style variables of the component and their values, as an object in code. */\n private variableValues(): string {\n const values: string[] = [];\n for (const variable of this.plan.styles.variables) {\n values.push(\n `${JSON.stringify(variable.name)}: ${variableValue(variable, this.expression(variable.expression))}`,\n );\n }\n return `{ ${values.join(', ')} }`;\n }\n\n /** The ID of the component scope, which `b-v` names. */\n private componentId(): string {\n const component = this.plan.graph.model.component;\n const name = this.scopeVar(component);\n // Outside the render function of the component, the name is the scope object.\n return this.isInside(component) ? name : `${name}.id`;\n }\n\n private emitLiveStyles(): void {\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.componentId());\n this.html('\"');\n }\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 let hasMethod = false;\n for (const attribute of node.attributes) {\n if ('name' in attribute && attribute.name === method) {\n hasMethod = true;\n break;\n }\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 let declaration: Declaration | undefined;\n for (const item of this.plan.graph.model.declarations) {\n if (item.kind === 'action' && item.action === fn.name) {\n declaration = item;\n break;\n }\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 (hasSpread(node.attributes)) {\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 anchor = this.anchor(scope, node);\n // With a spread, the element writes its own `b-b` before it. `spread` in html.ts still writes\n // the inherited `b-b` on purpose, for a component with no anchor of its own. The parser keeps\n // the first, so the element's own wins.\n if (anchor && spreadHandlers) {\n this.html(' b-b=\"');\n this.code(anchor.scope);\n this.html(`:${anchor.index}\"`);\n }\n const variables = this.emitVariables(node);\n const events: string[] = [];\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 = hasSpread(node.attributes) ? ([] as string[]) : undefined;\n // A spread that changes in the browser names the attributes that it wrote, so its first\n // update there removes only those, and keeps attributes that other code set.\n let liveSpread = false;\n for (const attribute of node.attributes) {\n const site =\n attribute.kind === 'spread' ? this.sitesByNode.get(attribute.value.ast) : undefined;\n if (site !== undefined && this.plan.clientSites.has(site)) {\n liveSpread = true;\n break;\n }\n }\n function spreadArguments(handlers: string | undefined): string {\n if (liveSpread) {\n return `, ${handlers ?? 'undefined'}, true`;\n }\n return handlers ? `, ${handlers}` : '';\n }\n for (const attribute of node.attributes) {\n if (\n variables &&\n !merged &&\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 // The server waits for a promise, so the element is sent with its final attributes. A\n // string or a number is no promise.\n const call = `$$b.attribute(${JSON.stringify(attribute.name)}, ${this.expression(attribute.value)})`;\n this.code(\n isPrimitive(attribute.value.ast) ? call : this.ready(call),\n this.settledMemos([attribute.value], scope),\n this.promiseScope(attribute.value, scope),\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 this.ready(\n `$$b.spread(${this.expression(attribute.value)}${spreadArguments(spreadHandlers)})`,\n ),\n undefined,\n this.promiseScope(attribute.value, scope),\n );\n break;\n case 'computed':\n this.code(\n this.ready(\n `$$b.attribute(${this.expression(attribute.name)}, ${attribute.value === true ? 'true' : this.expression(attribute.value)})`,\n ),\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 }\n }\n if (merged) {\n // A `ref` that a rest prop holds is a binding of the parent's signal. The element goes to it.\n const forwards = anchor !== undefined && this.spreadsRest(node.attributes);\n const attributes = `$$b.mergeAttributes([${merged.join(', ')}]${variables ? `, ${variables}` : ''})`;\n // A promise among the values is written once it settles.\n let promise: string | undefined;\n for (const attribute of node.attributes) {\n if (attribute.kind === 'value' || attribute.kind === 'spread') {\n promise ??= this.promiseScope(attribute.value, scope);\n }\n }\n this.code(\n this.ready(\n `$$b.spread(${forwards ? `${this.helper('restRef')}(${attributes}, ${anchor.scope}, ${anchor.index})` : attributes}${spreadArguments(spreadHandlers)})`,\n ),\n undefined,\n promise,\n );\n }\n // With a spread, the own `b-b` is already written, before it.\n if (anchor && !spreadHandlers) {\n this.html(' b-b=\"');\n this.code(anchor.scope);\n this.html(`:${anchor.index}\"`);\n }\n // An element that forwards a `ref` prop tells the loader which signal of the caller it is, so a\n // `$client` of the caller can wait for it.\n const forwarded = this.forwardedRef(node);\n if (forwarded) {\n this.code(forwarded);\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 this.html('>');\n if (VOID_ELEMENTS.has(node.tag)) {\n return;\n }\n this.nesting++;\n this.elements.push(node.tag.toLowerCase());\n this.emitNodes(node.children, scope);\n this.elements.pop();\n this.nesting--;\n this.html(`</${node.tag}>`);\n }\n\n /** True when no `ref` is written, and a spread reads the props of the component. */\n private spreadsRest(attributes: Attribute[]): boolean {\n let spreadsProps = false;\n for (const attribute of attributes) {\n if (attribute.kind === 'ref') {\n return false;\n }\n if (attribute.kind === 'spread' && readsProps(this.sitesByNode.get(attribute.value.ast))) {\n spreadsProps = true;\n }\n }\n return spreadsProps;\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: string[] = [];\n for (const child of node.children) {\n if (child.kind === 'insert') {\n parts.push(`(${this.expression(child.expression)} ?? '')`);\n } else if (child.kind === 'text') {\n parts.push(JSON.stringify(decodeText(cleanText(child.value))));\n }\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 function 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 const pieces: string[] = [];\n for (const part of classes) {\n pieces.push(piece(part));\n }\n this.code(`$$b.classAttribute(${pieces.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 /** Renders the children of a component or a dynamic tag, for their export in the browser. */\n emitChildrenBody(node: ComponentNode | DynamicTagNode, scope: Scope): void {\n this.atTopLevel(() => this.emitNodes(node.children, scope));\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 // The elements around markup that renders elsewhere are not these.\n const elements = this.elements.splice(0);\n this.nesting = 0;\n callback();\n this.nesting = nesting;\n this.elements.push(...elements);\n }\n\n /** Renders children into a variable, for a component or a dynamic tag. */\n private emitChildren(node: ComponentNode | DynamicTagNode, scope: Scope): string | undefined {\n const nodes = node.children;\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. The\n // browser renders them with their own export each time the component inserts them again.\n const render = this.plan.childrenRenders.get(node);\n const ref = render ? `, ${JSON.stringify(`${this.plan.id}#${render.symbol}`)}` : '';\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(`}${ref});`);\n return name;\n }\n this.line(\n `const ${name} = $$b.children(${this.scopeVar(instanceScope(this.plan, scope))}, () => {`,\n );\n const fn = this.currentFn;\n this.line(`let $$html = '';`);\n this.atTopLevel(() => this.emitNodes(nodes, scope));\n this.flush();\n // Children whose markup can clone give the clone, which the insert puts in place.\n const cloned =\n this.options.hoist !== undefined && cloneLines(this, this.options.hoist, fn, node);\n this.line(this.returnLine(fn, cloned));\n this.close('});');\n return name;\n }\n\n /**\n * The attributes of a dynamic tag. With a spread, they merge as the attributes of an element\n * do: a later one wins, and a `class` adds to the others, so a part that takes `as` keeps its\n * own class and the caller's.\n */\n private dynamicProps(attributes: Attribute[], scope: Scope, extra: string[]): string {\n if (!hasSpread(attributes)) {\n return this.props(attributes, scope, extra);\n }\n const parts: string[] = [];\n let run: Attribute[] = [];\n const flush = (): void => {\n if (run.length > 0) {\n parts.push(this.props(run, scope));\n run = [];\n }\n };\n for (const attribute of attributes) {\n if (attribute.kind === 'spread') {\n flush();\n parts.push(this.expression(attribute.value));\n } else {\n run.push(attribute);\n }\n }\n flush();\n if (extra.length > 0) {\n parts.push(`{ ${extra.join(', ')} }`);\n }\n return `$$b.mergeAttributes([${parts.join(', ')}])`;\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 // `$toStore(value)`: a store that the page state sends with its scope and site, and the\n // slot of a signal, which its `set` writes.\n if (\n part.type === 'CallExpression' &&\n part.callee.type === 'Identifier' &&\n part.callee.name === '$toStore' &&\n part.arguments[0]\n ) {\n const argument = part.arguments[0];\n const store = this.sitesByNode.get(argument);\n const declaration =\n argument.type === 'Identifier' ? lookup(scope, argument.name) : undefined;\n const slot = declaration?.kind === 'signal' ? `, ${slotIndex(this.plan, declaration)}` : '';\n return `${this.helper('toStore')}(${this.source(argument)}, ${instance}, ${store?.id ?? -1}${slot})`;\n }\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 // The functions can be the values of keys of objects, or items of lists, inside the value too.\n const visit = (node: oxc.Node): string => {\n if (node.type === 'ArrayExpression') {\n let code = '';\n let position = node.start;\n for (const element of node.elements) {\n if (!element || element.type === 'SpreadElement') {\n continue;\n }\n const marked = nested(element) ? visit(element) : mark(element);\n if (!marked) {\n continue;\n }\n code += this.patch.slice(position, element.start) + marked;\n position = element.end;\n }\n return code + this.patch.slice(position, node.end);\n }\n if (node.type !== 'ObjectExpression') {\n return mark(node) ?? this.source(node);\n }\n let code = '';\n let position = node.start;\n for (const property of node.properties) {\n if (property.type !== 'Property' || property.computed) {\n continue;\n }\n const marked = nested(property.value)\n ? visit(property.value)\n : 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, node.end);\n };\n return visit(value);\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 // A function of a module is one object for every render, so the server binds a copy, which\n // holds the reference of this prop.\n const copy =\n this.options.mode === 'server' && isImported(expression.ast, scope) ? ', []' : '';\n return `${this.helper('fn')}(${code}, ${JSON.stringify(`${this.plan.id}#${symbol}`)}, ${instance}${copy})`;\n }\n return code;\n }\n\n private emitComponent(node: ComponentNode, scope: Scope): void {\n const childrenName = this.emitChildren(node, 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 let link = anchor ? `, ${anchor.index}` : '';\n if (this.inParagraph.has(node)) {\n // Where the component is, so the server can name it when its element closes the `<p>`.\n const before = this.file.source.slice(0, node.start).split('\\n');\n const at = `${this.file.filename}:${before.length}:${before.at(-1)!.length + 1}`;\n link = `${link || ', undefined'}, ${JSON.stringify(`<${node.name}> in ${at}`)}`;\n }\n // The values of the props, without the handlers and functions, which the child can call\n // later, so the child does not wait for the memos that only they read.\n const values: Expression[] = [];\n for (const attribute of node.attributes) {\n const type = attribute.kind === 'value' ? attribute.value.ast.type : '';\n if (type === 'ArrowFunctionExpression' || type === 'FunctionExpression') {\n continue;\n }\n if (attribute.kind === 'value' || attribute.kind === 'spread') {\n values.push(attribute.value);\n } else if (attribute.kind === 'computed') {\n values.push(attribute.name);\n if (attribute.value !== true) {\n values.push(attribute.value);\n }\n }\n }\n this.code(\n `${this.wait}$$b.component(${node.name}, ${props}, ${this.ctxArgument}, ${owner}${link})`,\n this.settledMemos(values, scope),\n );\n }\n\n private emitDynamic(node: DynamicTagNode, scope: Scope): void {\n const childrenName = this.emitChildren(node, scope);\n const extra: string[] = [];\n if (this.hasScope(undefined, staticClasses(node.attributes))) {\n extra.push(`${JSON.stringify(this.plan.styles.attribute)}: $$b.internal(true)`);\n }\n const anchor = this.anchor(scope, node);\n if (anchor) {\n extra.push(`\"b-b\": $$b.internal(\\`\\${${anchor.scope}}:${anchor.index}\\`)`);\n }\n const events: string[] = [];\n for (const attribute of node.attributes) {\n if (attribute.kind === 'event') {\n events.push(this.eventEntry(attribute));\n }\n }\n if (events.length > 0) {\n // The entries name the scope of the handlers, for a component that renders the element.\n const owner = instanceScope(this.plan, scope);\n const id = this.isInside(owner) ? this.scopeVar(owner) : `${this.scopeVar(owner)}.id`;\n const entries: string[] = [];\n for (const event of events) {\n entries.push(`${JSON.stringify(`${event}@`)} + ${id}`);\n }\n extra.push(`\"b-on\": $$b.internal(${entries.join(' + \" \" + ')})`);\n }\n let attributes: Attribute[] = [];\n for (const attribute of node.attributes) {\n if (attribute.kind !== 'event') {\n attributes.push(attribute);\n }\n }\n const { variables } = this.plan.styles;\n // With a spread, the style variables go on after the attributes merge, so the style of the\n // spread does not take their place.\n let spreadVariables: string | undefined;\n if (variables.length > 0 && this.nesting === 0) {\n if (this.plan.liveStyles) {\n extra.push(`\"b-v\": $$b.internal(${this.componentId()})`);\n }\n }\n if (variables.length > 0 && this.nesting === 0 && hasSpread(attributes)) {\n spreadVariables = this.variableValues();\n } else 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 = findStyleAttribute(attributes);\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 const rest: Attribute[] = [];\n for (const attribute of attributes) {\n if (attribute !== own) {\n rest.push(attribute);\n }\n }\n attributes = rest;\n extra.push(`\"style\": $$b.vars(${this.variableValues()}, ${existing})`);\n }\n // A tag that names a component gets the binding of `ref` as its `ref` prop, and writes the\n // element itself. A tag that names an element writes the element here.\n const refs: (Attribute & { kind: 'ref' })[] = [];\n for (const attribute of node.attributes) {\n if (attribute.kind === 'ref') {\n refs.push(attribute);\n }\n }\n const tag = this.expression(node.tag);\n let tagName = tag;\n let binding = '';\n const forwards = anchor !== undefined && this.spreadsRest(node.attributes);\n if ((refs.length > 0 || forwards) && anchor) {\n // A plain name is read again where the element is written. The code of another tag\n // is read once, which keeps a block from cloning, so only such tags pay for it.\n if (!/^\\([^\\s()+\\-*/?:,;'\"`[\\]{}!&|<>=]+\\)$/.test(tag)) {\n tagName = this.unique('tag');\n this.line(`const ${tagName} = ${tag};`);\n }\n const declaration = this.refTargets.get(refs.at(-1)!);\n if (declaration) {\n binding = `, ${this.getBinding(declaration)}`;\n }\n }\n let props = spreadVariables\n ? `$$b.mergeAttributes([${this.dynamicProps(attributes, scope, extra)}], ${spreadVariables})`\n : this.dynamicProps(attributes, scope, extra);\n if (forwards && anchor) {\n // A `ref` in the rest props goes to the element, when the tag names one. A component\n // gets it as a prop and forwards it.\n props = `${this.helper('restRef')}(${props}, ${anchor.scope}, ${anchor.index}, ${tagName})`;\n }\n this.code(\n this.ready(\n `$$b.dynamic(${tagName}, ${props}, ${childrenName ?? 'undefined'}, ${this.ctxArgument}, ${this.scopeVar(instanceScope(this.plan, scope))}${binding})`,\n ),\n );\n // `ref` gets the element that the tag renders, when it names an element.\n for (const attribute of refs) {\n if (anchor) {\n this.emitRef(attribute.target, attribute, anchor, `typeof ${tagName} !== 'function'`);\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 const fn = this.currentFn;\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 // In the browser, the body clones its markup when it can.\n const cloned =\n this.options.mode === 'client' &&\n this.options.hoist !== undefined &&\n cloneLines(this, this.options.hoist, fn, block.body);\n this.line(cloned ? 'return $$f;' : '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: Declaration[] = [];\n const names: string[] = [];\n for (const declaration of awaitedMemos(this.plan, body, this.blocking)) {\n if (!this.inline.has(declaration)) {\n memos.push(declaration);\n names.push(promiseName(declaration.name));\n }\n }\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.emitLoadingBody(block, scope);\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.emitLoadingBody(block, scope);\n this.line('$$ctx.leave();');\n this.close('} else {');\n }\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.line(`$$ctx.defer(${boundary}, async ($$ctx) => {`);\n this.line(`let $$html = '';`);\n for (const declaration of memos) {\n this.awaitHeld(declaration);\n }\n this.emitLoadingBody(block, scope);\n this.flush();\n this.line('return $$html;');\n this.close('});');\n if (inPlace) {\n this.close();\n }\n }\n\n /**\n * In the browser, a `#loading` block renders as a streamed one shows: `$$b.loading` renders the\n * body in a boundary, and the fallback while a wait of the body has not ended. The body counts\n * the memos that it reads from outside, which the server waits for in the block. The block\n * joins the `#reveal` block whose body renders it.\n */\n private emitClientLoading(block: Block & { kind: 'loading' }, scope: Scope): void {\n const body = this.plan.bodyScopes.get(block.body)!;\n const reads: string[] = [];\n for (const declaration of awaitedMemos(this.plan, body, this.blocking)) {\n if (mayLoad(declaration)) {\n reads.push(declaration.name);\n }\n }\n const args = [\n this.bodyFunction(\n '',\n () => {\n if (reads.length > 0) {\n this.line(\n `$$b.countLoads(${this.scopeVar(instanceScope(this.plan, scope))}, [${reads.join(', ')}]);`,\n );\n }\n this.emitLoadingBody(block, scope);\n },\n body,\n ),\n ];\n const fallback = block.fallback;\n if (fallback) {\n args.push(\n this.bodyFunction('', () => this.emitBody(fallback), this.plan.bodyScopes.get(fallback)),\n );\n }\n this.code(`$$b.nodes($$b.loading(${args.join(', ')}))`);\n }\n\n /**\n * The body of a `#loading` block. With a header, its markers carry the scope and the anchor of\n * the block, so the browser finds the body to hide while a memo of the header loads.\n */\n private emitLoadingBody(block: Block & { kind: 'loading' }, scope: Scope): void {\n this.open(scope, block, '1');\n this.emitBody(block.body);\n this.end(block);\n }\n\n /**\n * Registers the `#catch` body of a `#try` on the server, and returns the name of the function\n * that ends the registration. The body renders again here for an error that comes after the\n * page is sent, in a context of its own.\n */\n private emitCatcher(block: Block & { kind: 'try' }, scope: Scope): string | undefined {\n // A `#try` that holds no `#loading` body and no component has nothing to catch later.\n const anchor = holdsStream(block) ? this.anchor(scope, block) : undefined;\n if (!anchor) {\n return undefined;\n }\n const end = this.unique('end');\n const raised = this.unique('raised');\n this.line(\n `const ${end} = $$ctx.catcher(${anchor.scope} + ${JSON.stringify(`:${anchor.index}`)}, async ($$ctx, ${raised}) => {`,\n );\n this.line(`let $$html = '';`);\n if (block.error) {\n this.line(`const ${block.error.name} = $$b.caught(${raised}, $$ctx);`);\n }\n if (block.reset) {\n this.line(`const ${block.reset.name} = undefined;`);\n }\n this.emitBody(block.fallback);\n this.flush();\n this.line('return $$html;');\n this.close('});');\n return end;\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.awaitHeld(declaration);\n }\n this.emitBody(block.body);\n this.flush();\n this.line('return $$html;');\n this.close('});');\n }\n\n /**\n * Writes the markers of a nested `#if` or `#for` of a clone, with nothing between them, and\n * the call that fills the block after the clone. Returns false for a block that renders inline.\n */\n private emitFill(block: Block, scope: Scope): boolean {\n // A block in the function of children renders there, which the calls of a clone do not fill.\n // A windowed list renders its first items inline.\n const windowed = block.kind === 'for' && block.window !== undefined;\n const fill = this.currentFn === 0 && !windowed ? this.options.fills?.(block) : undefined;\n const anchor = fill && this.anchor(scope, block);\n if (!fill || !anchor) {\n return false;\n }\n let call: string;\n if (fill.kind === 'if' && block.kind === 'if') {\n // The index of the branch that shows, or of the fallback, or -1.\n let index = block.fallback ? String(block.branches.length) : '-1';\n for (let at = block.branches.length - 1; at >= 0; at--) {\n index = `${this.expression(block.branches[at]!.condition)} ? ${at} : ${index}`;\n }\n call = `$$b.fillBranch($$m, ${anchor.scope}, ${anchor.index}, ${index}, [${fill.renders.join(', ')}])`;\n } else if (fill.kind === 'for' && block.kind === 'for') {\n call = `$$b.fillList($$m, ${anchor.scope}, ${anchor.index}, $$b.toList(${this.expression(block.list)}), ${fill.render})`;\n } else {\n return false;\n }\n this.open(scope, block, fill.kind === 'if' ? '-1' : undefined);\n this.end(block);\n this.fills.set(`${anchor.scope}:${anchor.index}`, call);\n return true;\n }\n\n /**\n * Emits a function that renders a body, as a constant, and returns its name. The function\n * clones its markup when it can, and gives its HTML otherwise.\n */\n private bodyFunction(params: string, content: () => void, scope?: Scope): string {\n const name = this.unique('body');\n this.line(`const ${name} = (${params}) => {`);\n const fn = this.currentFn;\n this.line(`let $$html = '';`);\n // The script of the body can split the function at `await $memo`.\n this.splitBody(scope, content, () => {\n this.flush();\n // The functions of children render HTML.\n const cloned =\n this.options.hoist !== undefined && cloneLines(this, this.options.hoist, fn, scope?.body);\n this.line(this.returnLine(fn, cloned));\n });\n this.close('};');\n return name;\n }\n\n /**\n * In the browser, an `#if`, a `#switch`, a `#for` or a `#repeat` that renders where it is\n * builds its nodes with a function for each body, so the markup around it and its bodies can\n * clone. `branchNodes` and `listNodes` write its markers, when it has them.\n */\n private emitNodesBlock(block: Block, scope: Scope): boolean {\n if (\n this.options.mode !== 'client' ||\n !this.options.hoist ||\n (block.kind === 'for' && block.window !== undefined)\n ) {\n return false;\n }\n const anchor = this.anchor(scope, block);\n const marks = anchor ? `${anchor.scope}, ${anchor.index}` : 'undefined, undefined';\n if (block.kind === 'if' || block.kind === 'switch') {\n const branches = block.kind === 'if' ? block.branches : block.cases;\n const bodies: string[] = [];\n for (const branch of branches) {\n bodies.push(\n this.bodyFunction(\n '',\n () => this.emitBody(branch.body),\n this.plan.bodyScopes.get(branch.body),\n ),\n );\n }\n const fallback = block.fallback;\n const other =\n fallback &&\n this.bodyFunction('', () => this.emitBody(fallback), this.plan.bodyScopes.get(fallback));\n // The index of the branch that shows, then its function.\n let index = other ? String(branches.length) : '-1';\n for (let at = branches.length - 1; at >= 0; at--) {\n index = `${this.expression(branches[at]!.condition)} ? ${at} : ${index}`;\n }\n const names = `[${[...bodies, ...(other ? [other] : [])].join(', ')}]`;\n const conditions: Expression[] = [];\n for (const branch of branches) {\n conditions.push(branch.condition);\n }\n this.code(\n `$$b.nodes($$b.branchNodes(${marks}, ${index}, ${names}))`,\n this.settledMemos(conditions, scope),\n );\n return true;\n }\n if (block.kind === 'for' || block.kind === 'repeat') {\n const item = this.unique('item');\n const index = this.unique('index');\n const body = this.bodyFunction(\n `${item}, ${index}`,\n () => this.emitItem(block, item, index),\n this.plan.bodyScopes.get(block.body),\n );\n const fallback = block.fallback;\n const other =\n fallback &&\n this.bodyFunction('', () => this.emitBody(fallback), this.plan.bodyScopes.get(fallback));\n const items =\n block.kind === 'for'\n ? `$$b.toList(${this.expression(block.list)})`\n : `Array.from({ length: ${this.expression(block.count)} }, (_, index) => index)`;\n this.code(\n `$$b.nodes($$b.listNodes(${marks}, ${items}, ${body}, ${other ?? 'undefined'}))`,\n this.settledMemos([block.kind === 'for' ? block.list : block.count], scope),\n );\n return true;\n }\n return false;\n }\n\n /** The tag of a spacer in the element around, for a row of a table or an item of a list. */\n private parentSpacer(): string | undefined {\n const parent = this.elements.at(-1);\n if (parent === undefined) {\n return undefined;\n }\n if (/^(tbody|thead|tfoot|table)$/.test(parent)) {\n return 'tr';\n }\n return /^(ul|ol|menu)$/.test(parent) ? 'li' : undefined;\n }\n\n /**\n * The tag of the spacers of a windowed list, as code: a row in a table, an item in a list, or\n * a `div`. In the children of a component, the element is the one where the component inserts\n * them, which the render gives as `$$ctx.tag`.\n */\n private spacerTag(): string {\n if (this.elements.length > 0) {\n return JSON.stringify(this.parentSpacer() ?? 'div');\n }\n return this.options.mode === 'server' ? `$$b.spacerTag($$ctx)` : `'div'`;\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 if (this.emitFill(block, scope) || this.emitNodesBlock(block, scope)) {\n return;\n }\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 for (const [index, branch] of branches.entries()) {\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 // A windowed list renders its first items, between spacers that give it the height of\n // the rest, and starts the window of the browser. See `windowStart` of the core.\n const windowed = block.kind === 'for' && block.window ? block.window : undefined;\n const shown = windowed && this.unique('shown');\n const spacer = windowed && this.spacerTag();\n if (windowed) {\n this.line(\n `const ${shown} = Math.min(${list}.length, ${windowed.count ? this.expression(windowed.count) : '20'});`,\n );\n this.html(`<`);\n this.code(spacer!);\n this.html(` data-window=\"before\" aria-hidden=\"true\" style=\"height: 0px\"></`);\n this.code(spacer!);\n this.html('>');\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} < ${shown ?? `${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 if (windowed) {\n const anchor = this.anchor(scope, block)!;\n this.html(`<`);\n this.code(spacer!);\n this.html(` data-window=\"after\" aria-hidden=\"true\" style=\"height: `);\n this.code(`((${list}.length - ${shown}) * (${this.expression(windowed.height)}))`);\n this.html(`px\"></`);\n this.code(spacer!);\n this.html('><template b-b=\"');\n this.code(anchor.scope);\n this.html(\n `:${anchor.index}\" b-client=\"load=${this.plan.id}#w${anchor.index}\"></template>`,\n );\n }\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 // A `#loading` body inside that fails after the page is sent renders the `#catch` body then.\n const end = server ? this.emitCatcher(block, scope) : undefined;\n this.line('try {');\n if (\n !server &&\n this.options.hoist &&\n this.plan.anchors.has(block) &&\n tryCatchesClient(this.plan.graph.model, block)\n ) {\n // A wait of the body that fails ends in the boundary of the `#try`, and `fail` shows the\n // `#catch` body in its place, as for any error of client code in the body.\n const fn = this.bodyFunction(\n '',\n () => this.emitBody(block.body),\n this.plan.bodyScopes.get(block.body),\n );\n this.code(`$$b.nodes($$b.attempt(${fn}))`);\n } else {\n this.emitInlineBody(block.body);\n }\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 // On the server the page state carries this value, so production sends a safe error.\n this.line(\n `const ${block.error.name} = ${server ? `$$b.caught(${error}, $$ctx)` : error};`,\n );\n }\n if (block.reset) {\n this.line(`const ${block.reset.name} = undefined;`);\n }\n this.emitBody(block.fallback);\n if (end) {\n this.close('} finally {');\n this.line(`${end}();`);\n }\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.emitClientLoading(block, scope);\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.emitInlineBody(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 for (const name of attribute.value.split(/\\s+/)) {\n if (name) {\n classes.push(name);\n }\n }\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> = { '&': '&', '<': '<', '\"': '"' };\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 function 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 for (const element of node.elements) {\n if (!visit(element)) {\n return false;\n }\n }\n return true;\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 let plain = true;\n const names: string[] = [];\n for (const part of classes) {\n if (part.condition !== undefined) {\n plain = false;\n }\n names.push(part.name);\n }\n if (plain) {\n return JSON.stringify(names.join(' '));\n }\n const [first] = classes;\n if (classes.length === 1 && first) {\n return `((${first.condition}) ? ${JSON.stringify(first.name)} : \"\")`;\n }\n const pieces: string[] = [];\n for (const part of classes) {\n const text = JSON.stringify(` ${part.name}`);\n pieces.push(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\n/** True for the name of an import, in parentheses or not. */\nfunction isImported(node: oxc.Node, scope: Scope): boolean {\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n return node.type === 'Identifier' && lookup(scope, node.name)?.kind === 'import';\n}\n","import { NAME_BRIDGE_IMPORT, moduleBridgeNames } from '../bridges.ts';\nimport { importSource, isMacroImport } from '../macros.ts';\nimport type { SFCFile } from '../ast.ts';\nimport type { Declaration } from '../model.ts';\nimport type { oxc } from '../oxc.ts';\nimport { componentFunctionName, 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, bodyMemos, lazyMemos, 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 if (statement.type !== 'VariableDeclaration') {\n return false;\n }\n for (const declarator of statement.declarations) {\n if (declarator.init === null || !nodes.has(declarator.init)) {\n return false;\n }\n }\n return true;\n}\n\n/** Returns the server functions of a file, which the server module exports for RPC. */\nexport function serverFunctions(plan: Plan): Declaration[] {\n const result: Declaration[] = [];\n for (const declaration of plan.graph.model.declarations) {\n if (declaration.kind === 'server-function') {\n result.push(declaration);\n }\n }\n return result;\n}\n\nexport function generateServer(file: SFCFile, plan: Plan): string {\n const model = plan.graph.model;\n const patch = new Patch(file.source);\n const blocking = blockingMemos(plan);\n const inline = plainValues(plan, blocking);\n const lazy = lazyMemos(blocking, inline);\n for (const declaration of bodyMemos(plan, blocking, inline)) {\n lazy.add(declaration);\n }\n addValueEdits(patch, file, model.sites, 'server', inline, lazy, model.component.id);\n addEventEdits(patch, model);\n function source(node: { start: number; end: number }): string {\n return patch.slice(node.start, node.end);\n }\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 if (statement.type === 'ImportDeclaration') {\n header.push(importSource(file.source, statement));\n } else {\n moduleBody.push(source(statement));\n }\n }\n // The page state names a bridge of `<script module>` by the ID of the component.\n const naming = moduleBridgeNames(file.moduleScript.program, plan.id);\n if (naming.length > 0) {\n header.push(NAME_BRIDGE_IMPORT);\n moduleBody.push(...naming);\n }\n }\n\n // Server functions only capture module bindings, so they move to the module and are exported for RPC.\n const servers: Declaration[] = [];\n const serverNodes = new Set<oxc.Node>();\n for (const declaration of serverFunctions(plan)) {\n if (declaration.scope !== model.module) {\n servers.push(declaration);\n serverNodes.add(declaration.site!.node);\n }\n }\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(importSource(file.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(importSource(file.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: string[] = [];\n for (const declaration of serverFunctions(plan)) {\n exported.push(\n `${JSON.stringify(serverFunctionId(plan, declaration.name))}: ${declaration.name}`,\n );\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 // The script can import a name that is the name of the component.\n const fn = componentFunctionName(file, plan.name);\n emitter.line(\n `export default async function ${fn}${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(`${fn}.brumateId = ${JSON.stringify(plan.id)};`);\n\n return [...header, ...hoisted, ...moduleBody, '', ...emitter.lines, ''].join('\\n');\n}\n","import type { Block, Body, Markup, SFCFile } from '../ast.ts';\nimport type { oxc } from '../oxc.ts';\nimport { componentFunctionName, serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { minifyCSS } from '../css.ts';\nimport { Emitter, TYPE_DECLARATIONS } from './markup.ts';\nimport { cloneLines } from './template.ts';\nimport type { Fill } 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 bodyNames(branch.body, names);\n }\n if (node.fallback) {\n bodyNames(node.fallback, names);\n }\n break;\n case 'switch':\n for (const branch of node.cases) {\n bodyNames(branch.body, names);\n }\n if (node.fallback) {\n bodyNames(node.fallback, names);\n }\n break;\n case 'for':\n case 'repeat':\n case 'loading':\n case 'client':\n case 'defer':\n bodyNames(node.body, names);\n if (node.fallback) {\n bodyNames(node.fallback, names);\n }\n break;\n case 'try':\n bodyNames(node.body, names);\n bodyNames(node.fallback, names);\n break;\n case 'key':\n case 'portal':\n case 'head':\n case 'offscreen':\n bodyNames(node.body, names);\n break;\n default:\n break;\n }\n }\n return names;\n}\n\n/** Adds the components that a block body renders, in its markup and its templates. */\nfunction bodyNames(body: Body, names: Set<string>): void {\n componentNames(body.children, names);\n for (const template of body.templates) {\n bodyNames(template.body, names);\n }\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: typeof statement.specifiers = [];\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {\n continue;\n }\n if (names.has(specifier.local.name)) {\n specifiers.push(specifier);\n }\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/** An export of the module script: the name in the script, and the name that others import. */\nexport interface ModuleExport {\n local: string;\n name: string;\n}\n\n/** The exports of the module script, from its declarations and its export lists. */\nexport function moduleExports(file: SFCFile, plan: Plan): ModuleExport[] {\n const result: ModuleExport[] = [];\n for (const statement of file.moduleScript?.program.body ?? []) {\n if (statement.type !== 'ExportNamedDeclaration' || statement.source) {\n continue;\n }\n if (statement.declaration) {\n for (const declaration of plan.graph.model.module.declarations.values()) {\n if (\n declaration.kind === 'module' &&\n declaration.range.start >= statement.start &&\n declaration.range.end <= statement.end\n ) {\n result.push({ local: declaration.name, name: declaration.name });\n }\n }\n continue;\n }\n for (const specifier of statement.specifiers) {\n const local = file.source.slice(specifier.local.start, specifier.local.end);\n const name = file.source.slice(specifier.exported.start, specifier.exported.end);\n if (plan.graph.model.module.declarations.get(local)?.kind === 'module') {\n result.push({ local, name });\n }\n }\n }\n return result;\n}\n\n/** True if the render module imports names of the module script from the shared part. */\nexport function rendersModule(plan: Plan): boolean {\n for (const site of plan.graph.model.sites) {\n if (!SKIPPED_SITES.has(site.kind)) {\n for (const read of site.reads) {\n if (read.declaration.kind === 'module') {\n return true;\n }\n }\n }\n }\n return false;\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 for (const site of plan.graph.model.sites) {\n if (\n site.awaits &&\n site.kind !== 'memo' &&\n site.kind !== 'function' &&\n !SKIPPED_SITES.has(site.kind)\n ) {\n return true;\n }\n }\n return false;\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(\n file: SFCFile,\n plan: Plan,\n getFill?: (block: Block) => Fill | undefined,\n): string {\n const model = plan.graph.model;\n const patch = new Patch(file.source);\n addValueEdits(patch, file, model.sites, 'render', undefined, undefined, model.component.id);\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 bodyNames(template.body, 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 // The module script runs once, in the shared part of the client entry, so a component that the\n // browser renders shares its state with the ones that resumed.\n const moduleNames: string[] = [];\n const serverNames: string[] = [];\n for (const name of names) {\n const found = model.module.declarations.get(name);\n if (found?.kind === 'module') {\n moduleNames.push(name);\n } else if (found?.kind === 'server-function') {\n serverNames.push(name);\n }\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 = 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 // Other modules import the exports from the render module, as they did from its copy.\n const exported = moduleNames.length > 0 ? moduleExports(file, plan) : [];\n const imports = new Set(moduleNames);\n for (const item of exported) {\n imports.add(item.name);\n }\n if (imports.size > 0) {\n const base = file.filename.split(/[\\\\/]/).pop()!;\n header.push(\n `import { ${[...imports].join(', ')} } from ${JSON.stringify(`./${base}?brumate-client&part=shared`)};`,\n );\n }\n if (exported.length > 0) {\n const exportedNames: string[] = [];\n for (const item of exported) {\n exportedNames.push(item.name);\n }\n moduleBody.push(`export { ${exportedNames.join(', ')} };`);\n }\n for (const name of serverNames) {\n if (model.module.declarations.get(name)?.scope === model.module) {\n moduleBody.push(\n `const ${name} = (...$$a) => $$b.rpc(${JSON.stringify(serverFunctionId(plan, name))}, $$a);`,\n );\n }\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: oxc.Node[] = [];\n for (const statement of file.instanceScript?.program.body ?? []) {\n if (statement.type !== 'ImportDeclaration' && !TYPE_DECLARATIONS.has(statement.type)) {\n setup.push(statement);\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 // The render functions of the client entry that fill the nested blocks of the clone.\n const imported = new Set<string>();\n function local(name: string): string {\n imported.add(name);\n return `$$${name}`;\n }\n const fills =\n getFill &&\n ((block: Block): Fill | undefined => {\n const fill = getFill(block);\n if (fill?.kind === 'if') {\n const renders: string[] = [];\n for (const name of fill.renders) {\n renders.push(local(name));\n }\n return { kind: 'if', renders };\n }\n return fill && { kind: 'for', render: local(fill.render) };\n });\n const generics = file.generics ? `<${file.generics}>` : '';\n // The script can import a name that is the name of the component.\n const fn = componentFunctionName(file, plan.name);\n // A parent that sends the component as a value registers it, and the core finds it by this ID.\n const markWithId = `${fn}.brumateId = ${JSON.stringify(plan.id)};`;\n const signature = `export default function ${fn}${generics}($$props: ${propsType(file)}): string | DocumentFragment {`;\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 const emitter = new Emitter(file, plan, patch, { mode: 'client', functions: true });\n emitter.line(signature);\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, markWithId, ''].join('\\n');\n }\n // The templates of the module, for the markup and the children that clone.\n const constants = new Map<string, string>();\n const templates: string[] = [];\n function hoist(code: string): string {\n let name = constants.get(code);\n if (!name) {\n name = `$$t${constants.size}`;\n constants.set(code, name);\n templates.push(`const ${name} = ${code};`);\n }\n return name;\n }\n function emit(fill: boolean): { emitter: Emitter; cloned: boolean } {\n const emitter = new Emitter(file, plan, patch, {\n mode: 'client',\n functions: true,\n fills: fill ? fills : undefined,\n hoist,\n waits: true,\n });\n emitter.line(signature);\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.flush();\n const cloned = cloneLines(emitter, hoist);\n emitter.line(emitter.returnLine(0, cloned));\n // The rests of the render that wait at `await`, innermost first.\n for (let wait = 0; wait < emitter.waits; wait++) {\n emitter.close('});');\n }\n emitter.close();\n return { emitter, cloned };\n }\n let emitted = fills ? emit(true) : undefined;\n // Markup that fills its blocks must clone, so markup that cannot renders again with its blocks.\n if (!emitted?.cloned) {\n imported.clear();\n templates.length = 0;\n constants.clear();\n emitted = emit(false);\n } else if (imported.size > 0) {\n const base = file.filename.split(/[\\\\/]/).pop()!;\n const aliases: string[] = [];\n for (const name of imported) {\n aliases.push(`${name} as $$${name}`);\n }\n header.push(\n `import { ${aliases.join(', ')} } from ${JSON.stringify(`./${base}?brumate-client`)};`,\n );\n }\n moduleBody.push(...templates);\n const { emitter } = emitted;\n\n return [...header, ...moduleBody, '', ...emitter.lines, markWithId, ''].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 { holderArguments } from '../plan.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 signals of `$searchParam` calls, by call. */\n private readonly searches = new Map<oxc.Node, Declaration>();\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 declaration of plan.graph.model.declarations) {\n if (declaration.searchParam) {\n this.searches.set(declaration.searchParam, declaration);\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: number[] = [];\n for (const scope of this.plan.graph.model.scopes) {\n if (isWithin(scope, body) || isWithin(scope, fallback)) {\n kinds.push(scope.id);\n }\n }\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 const held = holderArguments(this.plan, block);\n if (held) {\n args.push(held.slice(2));\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 function 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 let writes = false;\n for (const write of site.writes) {\n if (write.range.start >= node.left.start && write.range.end <= node.left.end) {\n writes = true;\n break;\n }\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 const searched = this.searches.get(node);\n if (searched && node.arguments[0]) {\n // The effect of a search parameter: it keeps the URL and the signal in step.\n const slot = slotIndex(this.plan, searched);\n patch.replace(\n node.start,\n node.arguments[0].start,\n `$$b.paramEffect(${path(searched)}, ${slot}, `,\n );\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 === '$isBound' &&\n !references.has(node.callee.start)\n ) {\n const prop = node.arguments[0];\n const declaration = prop && references.get(prop.start)?.declaration;\n const slot = declaration ? slotIndex(this.plan, declaration) : -1;\n patch.replace(\n node.start,\n node.end,\n declaration && slot !== -1 ? `$$b.isBound(${path(declaration)}, ${slot})` : 'false',\n );\n return;\n }\n if (\n node.callee.type === 'Identifier' &&\n (node.callee.name === '$isPending' || node.callee.name === '$resolve') &&\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. `$resolve` takes one memo.\n const checks: string[] = [];\n const seen = new Set<Declaration>();\n const targets = node.callee.name === '$isPending' ? node.arguments : [memo];\n for (const target of targets) {\n const found = target && references.get(target.start)?.declaration;\n for (const item of found ? [found, ...upstreamMemos(found)] : []) {\n const slot = slotIndex(this.plan, item);\n if (slot !== -1 && !seen.has(item)) {\n seen.add(item);\n checks.push(`$$b.pending(${path(item)}, ${slot})`);\n }\n }\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 if (node.callee.name === '$resolve' && memo) {\n // `$resolve(memo, options)` waits until the memo is not pending, then reads it.\n patch.replace(\n node.start,\n memo.start,\n `$$b.resolve(${declaration ? path(declaration) : scopeVar}, () => ${value}, () => `,\n );\n visit(memo);\n for (const rest of node.arguments.slice(1)) {\n visit(rest);\n }\n return;\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 { conditionalSpread } from '../analyze.ts';\nimport { isMacroImport } from '../macros.ts';\nimport type {\n Attribute,\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, holderArguments, serverFunctionId } from '../plan.ts';\nimport type { Plan } from '../plan.ts';\nimport { cloneLines } from './template.ts';\nimport type { Fill } from './markup.ts';\nimport { Emitter, classText, decodeAttribute, literalClasses, variableValue } from './markup.ts';\nimport { Patch, addValueEdits, arrowBody } from './patch.ts';\nimport { NAME_BRIDGE_IMPORT, moduleBridgeNames } from '../bridges.ts';\nimport {\n clientModuleScript,\n componentNames,\n moduleExports,\n renderImport,\n rendersModule,\n} from './render.ts';\nimport type { SharedContext } from '../shared-module.ts';\nimport { Rewriter } from './rewrite.ts';\nimport { instanceScope, mayBePromise, scopePath, slotIndex, templateArgs } from './scopes.ts';\nimport { copy, unmarked } from '../sourcemap.ts';\n\nexport interface ClientOutput {\n /** The entry module: the component ID, its props, and its update table. */\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 /** False when nothing of the component runs in the browser. */\n clientCode: boolean;\n /**\n * The render functions of the client entry that fill a nested `#if` or `#for` of a clone,\n * for the render module, which imports them.\n */\n fillOf: (block: Block) => Fill | undefined;\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// Sites whose code does not run while a body renders.\n// Sites that run only in the browser, where a component is its render function and not a stub.\nconst BROWSER_ONLY_SITES = new Set(['server-function', 'event', 'effect', 'client']);\nconst DEFERRED_SITES = new Set(['function', 'server-function', 'event', 'effect', 'client']);\n\n/** Whether a scope is within any scope of the list. */\nfunction isWithinAny(scope: Scope, list: Scope[]): boolean {\n for (const item of list) {\n if (isWithin(scope, item)) {\n return true;\n }\n }\n return false;\n}\n\n/** Whether a site that runs while a body renders reads the declaration. */\nfunction readsOutsideBrowser(declaration: Declaration): boolean {\n for (const read of declaration.reads) {\n if (!BROWSER_ONLY_SITES.has(read.site.kind)) {\n return true;\n }\n }\n return false;\n}\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 /** The module constants of each part, by their code. */\n private readonly constants = new Map<string, Map<string, string>>();\n private constantCount = 0;\n\n /**\n * A constant of the module of the current part, such as a list of scope kinds or a key\n * function that reads no scope, so an update does not make it again on each run.\n */\n private hoist(code: string): string {\n let known = this.constants.get(this.part);\n if (!known) {\n known = new Map();\n this.constants.set(this.part, known);\n }\n let name = known.get(code);\n if (!name) {\n // The parts of a small component share one module, so the names differ between parts.\n name = `$$k${this.constantCount++}`;\n known.set(code, name);\n this.emit(`const ${name} = ${code};`);\n }\n return name;\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.emitTemplateExports();\n this.emitUpdates();\n this.emitWindowStarts();\n this.emitRenders();\n this.emitChildrenRenders();\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, unless it holds\n // the sources of `$store` that the browser runs again.\n const stores = name === 'update' && this.model.storeSources.length > 0;\n if (name !== 'shared' && ((this.out.get(name)?.length ?? 0) > 0 || stores)) {\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: string[] = [];\n // The minified size decides, because that is what the browser loads.\n let size = 0;\n for (const [name, code] of Object.entries(parts)) {\n if (name !== 'shared') {\n names.push(name);\n }\n size += minifiedSize(code);\n }\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<number>();\n for (const match of code.matchAll(/\\$\\$m(\\d+)\\./g)) {\n used.add(Number(match[1]));\n }\n if (used.size > 0) {\n const imports: string[] = [];\n for (const index of used) {\n imports.push(\n `import * as $$m${index} from ${JSON.stringify(this.shared!.specifiers[index])};`,\n );\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 // The state holds a component that a prop gets as its ID, so the core finds its render\n // function in the entry of the component that sent it.\n const values = this.valueComponents();\n const sent: string[] = [];\n const renamed: string[] = [];\n for (const [index, code] of values.entries()) {\n sent.push(`$$v${index}`);\n renamed.push(code.replace('$$v', () => sent[index]!));\n }\n const registered =\n values.length > 0 ? [...renamed, `export const components = [${sent.join(', ')}];`] : [];\n // The names of the bridges of `<script module>` are written by the shared part, which the\n // entry imports even if no other part reads the module script.\n const bridged = this.bridgeNames().length > 0;\n const sharedImport = bridged ? [`import ${JSON.stringify(this.partPath('shared'))};`] : [];\n const clientCode = names.length > 0 || values.length > 0 || bridged;\n if (merged || names.length === 0) {\n // The entry holds the code itself, so the first event loads one module.\n const code = parts.all ?? '';\n delete parts.all;\n return {\n code: [...sharedImport, code, ...registered, ...table, ''].join('\\n'),\n table: table.join('\\n'),\n parts,\n clientCode,\n fillOf: (block) => this.createFill(block),\n diagnostics: this.diagnostics,\n };\n }\n // The page loads every part of a component with it, so the entry exports them, and a bundle\n // of the page holds them with the entry. The names of the parts' exports are their own.\n const reexports: string[] = [];\n for (const name of names) {\n reexports.push(`export * from ${JSON.stringify(this.partPath(name))};`);\n }\n const entry = [...sharedImport, ...reexports, ...registered, ...table, ''];\n return {\n code: entry.join('\\n'),\n table: table.join('\\n'),\n parts,\n clientCode,\n fillOf: (block) => this.createFill(block),\n diagnostics: this.diagnostics,\n };\n }\n\n /**\n * The imports, as `import $$v from …`, of the components that markup or script reads as values,\n * such as `as=Link`. A server render can send one in the page state, as its ID.\n */\n private valueComponents(): string[] {\n const result: string[] = [];\n for (const declaration of this.model.declarations) {\n const imported = declaration.imported;\n if (\n declaration.kind !== 'import' ||\n !imported?.source.endsWith('.brm') ||\n !readsOutsideBrowser(declaration)\n ) {\n continue;\n }\n const name = imported.name === 'default' ? '$$v' : `{ ${imported.name} as $$v }`;\n result.push(`import ${name} from ${JSON.stringify(`${imported.source}?brumate-render`)};`);\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 function 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 /** The sites that the renders of children run, other than handlers and effects. */\n private childrenSites(): Site[] {\n const result: Site[] = [];\n for (const [node, { scope }] of this.plan.childrenRenders) {\n const start = node.children[0]!.start;\n const end = node.children.at(-1)!.end;\n for (const site of this.model.sites) {\n const at = site.node as { start: number; end: number };\n if (\n site.scope === scope &&\n !DEFERRED_SITES.has(site.kind) &&\n start <= at.start &&\n at.end <= end\n ) {\n result.push(site);\n }\n }\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 const seed = [site];\n // A template part renders the markup of its templates, so their sites are part of it.\n if (symbol.startsWith('t')) {\n for (const scope of this.templateScopes(symbol)) {\n for (const item of this.model.sites) {\n if (isWithin(item.scope, scope) && !DEFERRED_SITES.has(item.kind)) {\n seed.push(item);\n }\n }\n }\n }\n this.reach.set(symbol, this.closure(seed));\n }\n const updates: Site[] = [];\n for (const site of this.plan.clientSites) {\n if (\n !this.plan.symbols.has(site) &&\n site.kind !== 'function' &&\n site.kind !== 'server-function'\n ) {\n updates.push(site);\n }\n }\n // A function prop that reads values is updated when they change, so its update writes the prop again with a new bound function.\n for (const node of this.plan.graph.nodes) {\n if (\n node.kind === 'binding' &&\n node.site.kind === 'prop' &&\n this.plan.symbols.has(node.site) &&\n this.plan.graph.live.has(node)\n ) {\n updates.push(node.site);\n }\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 // The render of children runs in the update part, so the sites in them are part of it.\n for (const site of this.childrenSites()) {\n updates.push(site);\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: string[] = [];\n for (const [name, sites] of this.reach) {\n if (sites.has(site)) {\n users.push(name);\n }\n }\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 // The guard of a `$gate` runs in the same part as its value, so the part imports its names.\n if (site.kind === 'memo' && declaration?.gate) {\n result.push(declaration.gate);\n }\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(\n names: Set<string>,\n components: boolean | Scope[],\n withChildren = components === true,\n copiesModule = false,\n ): string[] {\n // `true` for the scopes that render functions render, or the scopes of a template part.\n const rendered = [...(components === true ? this.renderedScopes() : components || [])];\n // The templates that the children call or pass on, such as `cell=day`, render in the update part.\n if (withChildren) {\n for (const site of this.childrenSites()) {\n const used: Declaration[] = [...site.calls];\n for (const read of site.reads) {\n if (read.declaration.kind === 'template') {\n used.push(read.declaration);\n }\n }\n for (const callee of used) {\n const template = callee.kind === 'template' ? this.findTemplateScope(callee) : undefined;\n for (const item of template ? this.inside(template) : []) {\n if (!rendered.includes(item)) {\n rendered.push(item);\n }\n }\n }\n }\n }\n for (const scope of rendered) {\n componentNames(scope.body?.children ?? [], names);\n // A component named in an attribute value, such as `as=Link`, is a read of the markup.\n for (const site of this.model.sites) {\n if (isWithin(site.scope, scope) && !DEFERRED_SITES.has(site.kind)) {\n for (const read of site.reads) {\n if (read.declaration.kind === 'import') {\n names.add(read.declaration.name);\n }\n }\n }\n }\n }\n // The renders of children are in the update part, with the components that they render.\n if (withChildren) {\n for (const node of this.plan.childrenRenders.keys()) {\n componentNames(node.children, names);\n }\n // What the sites in the children read, such as `prevent` in `onSubmit=(prevent(…))`.\n for (const site of this.childrenSites()) {\n for (const read of site.reads) {\n if (read.declaration.kind === 'import') {\n names.add(read.declaration.name);\n }\n }\n }\n }\n const result: string[] = [];\n for (const program of this.programs()) {\n // The shared part copies the imports of the module script itself. Another part imports\n // the names that its code reads, as the imports of the instance script.\n if (copiesModule && 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 /**\n * The sources of `$store` that the browser runs again on resume, as functions of the reader's\n * scope, which the update part exports as `z`. A reader whose store is not a context finds it\n * there by its index.\n */\n private storeSources(): string[] {\n const result: string[] = [];\n for (const site of this.model.storeSources) {\n result.push(`($$s) => (${this.rewrittenCode(site)})`);\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<string>();\n const stores = name === 'update' ? this.storeSources() : [];\n const shared: string[] = [];\n for (const item of reads) {\n if (item.kind === 'import') {\n names.add(item.name);\n }\n if (\n (item.kind === 'function' && this.placement.get(item) === 'shared') ||\n (item.kind === 'module' && item.scope === this.model.module)\n ) {\n shared.push(item.kind === 'function' ? `${item.name}$` : item.name);\n }\n }\n const lines = [\n \"import * as $$b from 'brumate/client';\",\n ...this.importsFor(names, this.partScopes(name), 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 if (stores.length > 0) {\n lines.push(`export const z = [${stores.join(', ')}];`);\n }\n lines.push('');\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 scopes = [...this.renderedScopes()];\n for (const name of names) {\n for (const scope of this.partScopes(name)) {\n if (!scopes.includes(scope)) {\n scopes.push(scope);\n }\n }\n }\n const stores = names.includes('update') ? this.storeSources() : [];\n const lines = [\n \"import * as $$b from 'brumate/client';\",\n ...this.importsFor(imports, scopes, names.includes('update')),\n '',\n ...this.serverStubs(names),\n ];\n for (const name of names) {\n lines.push('', ...(this.out.get(name) ?? []));\n }\n if (stores.length > 0) {\n lines.push(`export const z = [${stores.join(', ')}];`);\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<string>();\n for (const item of reads) {\n if (item.kind === 'import') {\n names.add(item.name);\n }\n }\n const lines = [\n \"import * as $$b from 'brumate/client';\",\n ...this.importsFor(names, false, false, this.usesModuleScript()),\n ];\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 naming = this.bridgeNames();\n if (naming.length > 0) {\n lines.push(NAME_BRIDGE_IMPORT, ...naming);\n }\n // The shared part exports each name that is not exported under its own name already.\n const exported = new Set<string>();\n for (const item of moduleExports(this.file, this.plan)) {\n if (item.local === item.name) {\n exported.add(item.name);\n }\n }\n const rest: string[] = [];\n for (const declaration of this.model.module.declarations.values()) {\n if (declaration.kind === 'module' && !exported.has(declaration.name)) {\n rest.push(declaration.name);\n }\n }\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 // Whether the site sits in a scope that a render function renders.\n let inRendered = false;\n for (const scope of rendered) {\n if (isWithin(site.scope, scope)) {\n inRendered = true;\n break;\n }\n }\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 || inRendered)\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 /** The calls that name the bridges of `<script module>`. */\n private bridgeNames(): string[] {\n return moduleBridgeNames(this.file.moduleScript?.program, this.plan.id);\n }\n\n private usesModuleScript(): boolean {\n // The render module imports what the markup reads from the shared part, and names its bridges.\n if (rendersModule(this.plan) || this.bridgeNames().length > 0) {\n return true;\n }\n for (const declaration of this.clientReads()) {\n if (declaration.kind === 'module') {\n return true;\n }\n }\n return false;\n }\n\n /**\n * The scopes of the templates that a template part renders, such as a template that is passed\n * to a component as a prop, which can render components of its own.\n */\n private templateScopes(part: string): Scope[] {\n const result: Scope[] = [];\n for (const [site, symbol] of this.plan.symbols) {\n if (symbol !== part || !symbol.startsWith('t')) {\n continue;\n }\n for (const callee of site.calls) {\n const template = callee.kind === 'template' ? this.findTemplateScope(callee) : undefined;\n if (template) {\n result.push(...this.inside(template));\n }\n }\n }\n return result;\n }\n\n /**\n * The scopes whose components and imports a part needs: the scopes that the update part\n * renders, the templates of a template part, and the templates that the code of the part\n * copies into itself, such as a call `row(item)` in an update.\n */\n private partScopes(part: string): Scope[] {\n const result = part === 'update' ? this.renderedScopes() : this.templateScopes(part);\n for (const site of this.partSites(part)) {\n const used: Declaration[] = [...site.calls];\n for (const read of site.reads) {\n used.push(read.declaration);\n }\n for (const callee of used) {\n const template = callee.kind === 'template' ? this.findTemplateScope(callee) : undefined;\n for (const item of template ? this.inside(template) : []) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n }\n }\n return result;\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 /** The scope of the template that a callee declares. */\n private findTemplateScope(callee: Declaration): Scope | undefined {\n for (const item of this.model.scopes) {\n if (item.template?.name === callee.name && item.parent === callee.scope) {\n return item;\n }\n }\n return undefined;\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.findTemplateScope(callee);\n if (template && !result.includes(template)) {\n result.push(template);\n }\n }\n }\n }\n return result;\n }\n\n /**\n * The scopes of a list that nothing else in it declares. A template that sits within a\n * scope of the list is emitted where its `#template` is, so a render emits only the others.\n */\n private declared(list: Scope[]): Scope[] {\n const result: Scope[] = [];\n for (const [index, item] of list.entries()) {\n let nested = false;\n for (const other of list.slice(0, index)) {\n if (isWithin(item, other)) {\n nested = true;\n break;\n }\n }\n if (!nested) {\n result.push(item);\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') {\n // The rest gets the props that have no name of their own, under `...`.\n const [name] = getPatternNames(property.argument);\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(`\"...\": ${slot}`);\n }\n continue;\n }\n if (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 (symbol.startsWith('t')) {\n this.emitTemplateArgs(site, symbol);\n }\n if (site.kind === 'client') {\n this.emit(\n `export function ${symbol}($$s) {\\n $$b.effect($$s, ${JSON.stringify(symbol)}, ${code}, 1);\\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 let fn: Declaration | undefined;\n if (node.type === 'Identifier') {\n for (const read of site.reads) {\n if (read.range.start === node.start) {\n fn = read.declaration;\n break;\n }\n }\n }\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 for (const callee of site.calls) {\n if (callee.kind === 'template') {\n return undefined;\n }\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 code = site.awaits ? `(async () => (${expression()}))()` : expression();\n const value = arrowBody(code, this.file.source, site.node.start);\n const timing = node.declaration.timing;\n // A debounced or throttled memo computes after its wait, with the values of then.\n const guard = node.declaration.gate;\n let call = `$$b.memo($$s, ${slot}, () => ${value})`;\n if (timing) {\n call = `$$b.timed($$s, ${slot}, ${timing.ms}, ${timing.kind === 'throttled'}, () => ${value})`;\n } else if (guard) {\n // The guard decides whether the new value replaces the old one.\n const code = this.withTemplates(guard, this.rewriter.rewrite(guard, '$$s', base));\n call = `$$b.gate($$s, ${slot}, ${code}, () => ${value})`;\n }\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 // A value that can be a promise is written once it settles, and the latest wins.\n const write =\n fn !== 'writeText' && mayBePromise(site.node, site)\n ? `$$b.fillValue($$s, ${anchor}, ${expression()}, ($$v) => $$b.${fn}($$s, ${anchor}, $$v))`\n : `$$b.${fn}($$s, ${anchor}, ${expression()})`;\n this.emit(`export function ${name('u')}($$s) {\\n ${write};\\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' && site.store) {\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.storeUpdate($$s, ${site.id}, ${expression()});\\n}`,\n );\n return;\n }\n if (site.kind === 'provide') {\n // A context value is read once, so a value that changes on the client never reaches it.\n // A store, or a read inside a function, is how a reader sees the change.\n const named = new Set<Declaration>();\n for (const edge of this.plan.graph.edges) {\n const from = edge.from;\n if (edge.to !== node || !this.plan.graph.live.has(from)) {\n continue;\n }\n if ((from.kind === 'source' || from.kind === 'memo') && !named.has(from.declaration)) {\n named.add(from.declaration);\n let range = site.range;\n for (const read of site.reads) {\n if (read.declaration === from.declaration) {\n range = read.range;\n break;\n }\n }\n this.error(\n `The context value reads \"${from.declaration.name}\", which changes, but a context value is read once. Put it in a store with $toStore, or read it inside a function`,\n range,\n );\n }\n }\n return;\n }\n if (site.kind === 'style') {\n let variable: (typeof this.plan.styles.variables)[number] | undefined;\n for (const item of this.plan.styles.variables) {\n if (item.expression.ast === site.node) {\n variable = item;\n break;\n }\n }\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 let attribute: Attribute | undefined;\n for (const item of owner.attributes) {\n if (\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 (item.kind === 'computed' &&\n (item.name.ast === site.node || (item.value !== true && item.value.ast === site.node)))\n ) {\n attribute = item;\n break;\n }\n }\n if (\n !attribute ||\n attribute.kind === 'static' ||\n attribute.kind === 'ref' ||\n (attribute.kind === 'computed' && owner.kind === 'component')\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: string[] = [];\n for (const item of owner.attributes.slice(owner.attributes.indexOf(attribute) + 1)) {\n if (item.kind === 'static' || item.kind === 'value' || item.kind === 'event') {\n after.push(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' || attribute.kind === 'computed') {\n // The attributes that are the element's own, which the spread does not remove.\n const own: string[] = [];\n for (const item of owner.attributes) {\n if (item.kind === 'static' || item.kind === 'value') {\n own.push(item.name);\n }\n }\n // The scope attribute is the element's own. Its style is not: a spread can write one, and\n // an update writes the style variables again with whatever style the spread passes on.\n if (this.plan.styles.css) {\n own.push(this.plan.styles.attribute);\n }\n // The other spreads of the element, which an update writes too. Each update tracks the\n // attributes that it wrote, so an update of one spread alone would remove the others'.\n const spreads = this.spreadCode(owner, attribute);\n // A computed attribute whose name or value has no code in the browser would drop out of the\n // update, and the attribute with it.\n for (const item of owner.attributes) {\n if (item.kind !== 'computed') {\n continue;\n }\n const code =\n item === attribute ? this.computedCode(item, site) : spreads.get(item.name.ast);\n if (code === undefined) {\n this.error(\n 'This computed attribute has a name or value with no code in the browser, so it cannot stay when the attributes of the element update',\n site.range,\n );\n return;\n }\n }\n // The element's static attributes merge with the spreads in their order, as on the server.\n const parts: string[] = [];\n for (const item of owner.attributes) {\n if (item === attribute) {\n const code = item.kind === 'computed' ? this.computedCode(item, site) : expression();\n if (code) {\n parts.push(code);\n }\n } else if (item.kind === 'spread' || item.kind === 'computed') {\n const code = spreads.get(item.kind === 'spread' ? item.value.ast : item.name.ast);\n if (code) {\n parts.push(code);\n }\n } else if (item.kind === 'static') {\n parts.push(\n `{ ${JSON.stringify(item.name)}: ${item.value === true ? \"''\" : JSON.stringify(decodeAttribute(item.value))} }`,\n );\n }\n }\n // The handlers of a dynamic tag name their scope, as in its first render, so the update\n // knows them from the entries of the spreads.\n const events = owner.kind === 'dynamic' ? this.ownEvents(owner) : [];\n if (events.length > 0) {\n parts.push(`{ \"b-on\": $$b.internal(${events.join(' + \" \" + ')}) }`);\n }\n const value =\n parts.length > 1 ? `$$b.mergeAttributes([${parts.join(', ')}])` : (parts[0] ?? '{}');\n // A spread whose values can be promises writes each one once it settles.\n const helper = mayBePromise(site.node, site) ? 'fillAttrs' : 'attrs';\n this.emit(\n `export function ${name('u')}($$s) {\\n $$b.${helper}($$s, ${anchor}, ${value}, ${JSON.stringify(own)}${this.heldRef(owner)});\\n}`,\n );\n } else if (attribute.kind === 'value') {\n let value =\n (attribute.name === 'class' ? classes(attribute.value.ast) : undefined) ?? expression();\n // A class adds to the classes of the spreads of the element, as on the server, so an update\n // of the element's own class keeps theirs.\n if (attribute.name === 'class') {\n const spreads = [...this.spreadCode(owner).values()];\n if (spreads.length > 0) {\n const classed: string[] = [value];\n for (const code of spreads) {\n classed.push(`(${code})?.class`);\n }\n value = `[${classed.join(', ')}]`;\n }\n }\n const write = mayBePromise(attribute.value.ast, site)\n ? `$$b.fillValue($$s, ${JSON.stringify(`${anchor} ${attribute.name}`)}, ${value}, ($$v) => $$b.attr($$s, ${anchor}, ${JSON.stringify(attribute.name)}, $$v))`\n : `$$b.attr($$s, ${anchor}, ${JSON.stringify(attribute.name)}, ${value})`;\n this.emit(`export function ${name('u')}($$s) {\\n ${write};\\n}`);\n }\n void node;\n }\n\n /**\n * The last argument of an update of a spread that holds the rest as a branch of a condition,\n * such as `open ? rest : {}`: the `ref` of the rest, which the update clears when the branch\n * is off and the server rendered it on.\n */\n private heldRef(owner: { attributes: Attribute[] }): string {\n for (const item of owner.attributes) {\n if (item.kind !== 'spread') {\n continue;\n }\n const held = conditionalSpread(item.value.ast);\n if (!held || this.valueCode(item.value.ast) === undefined) {\n continue;\n }\n for (const site of this.model.sites) {\n if (site.node === item.value.ast) {\n const range = { start: held.start, end: held.end };\n const code = this.rewriter.rewrite(site, '$$s', instanceScope(this.plan, site.scope), {\n range,\n });\n return `, (${this.withTemplates(site, code)}).ref`;\n }\n }\n }\n return '';\n }\n\n /** The `b-on` entries of the handlers of a dynamic tag, each as code that adds the scope ID. */\n private ownEvents(node: DynamicTagNode): string[] {\n const entries: string[] = [];\n for (const attribute of node.attributes) {\n let site: Site | undefined;\n if (attribute.kind === 'event') {\n for (const item of this.model.sites) {\n if (item.node === attribute.handler.ast) {\n site = item;\n break;\n }\n }\n }\n if (attribute.kind === 'event' && site) {\n const all = [...new Set(site.modifiers ?? [])];\n const entry = `${[attribute.event, ...all].join(':')}=${this.plan.id}#${this.plan.symbols.get(site)}@`;\n entries.push(`${JSON.stringify(entry)} + $$s.id`);\n }\n }\n return entries;\n }\n\n /**\n * The code of the spreads of an element, by their node, without `except`. A spread that\n * cannot change has code in the browser when each value that it reads has a slot, such as a\n * rest prop that markup of the browser reads.\n */\n private spreadCode(\n owner: { attributes: Attribute[] },\n except?: Attribute,\n ): Map<oxc.Node, string> {\n const spreads = new Map<oxc.Node, string>();\n for (const item of owner.attributes) {\n if (item === except) {\n continue;\n }\n if (item.kind === 'spread') {\n const code = this.valueCode(item.value.ast);\n if (code !== undefined) {\n spreads.set(item.value.ast, code);\n }\n } else if (item.kind === 'computed') {\n const code = this.computedCode(item);\n if (code !== undefined) {\n spreads.set(item.name.ast, code);\n }\n }\n }\n return spreads;\n }\n\n /** The code of a computed attribute, as an object, when the code of its name and value is known. */\n private computedCode(item: Attribute & { kind: 'computed' }, site?: Site): string | undefined {\n const part = (ast: oxc.Node): string | undefined =>\n site?.node === ast ? this.rewrittenCode(site) : this.valueCode(ast);\n const name = part(item.name.ast);\n const value = item.value === true ? 'true' : part(item.value.ast);\n return name === undefined || value === undefined ? undefined : `{ [${name}]: ${value} }`;\n }\n\n /** The code of an expression of the browser, or undefined when it has no code there. */\n private valueCode(ast: oxc.Node): string | undefined {\n for (const candidate of this.plan.graph.nodes) {\n if (candidate.kind === 'source' || candidate.site.node !== ast) {\n continue;\n }\n // A node that does not change needs a slot for each value that it reads.\n let slotted = true;\n for (const read of candidate.site.reads) {\n if (slotIndex(this.plan, read.declaration) === -1) {\n slotted = false;\n break;\n }\n }\n if (this.plan.graph.live.has(candidate) || slotted) {\n return this.rewrittenCode(candidate.site);\n }\n }\n return undefined;\n }\n\n private rewrittenCode(site: Site): string {\n return this.withTemplates(\n site,\n this.rewriter.rewrite(site, '$$s', instanceScope(this.plan, site.scope)),\n );\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 const result: Site[] = [];\n for (const site of this.model.sites) {\n if (site.kind === 'block' && site.block === block && site.label !== 'for key') {\n result.push(site);\n }\n }\n return result;\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 /** The windowed lists whose `w` export is emitted. */\n private readonly windowStarts = new Set<Block>();\n\n /**\n * The `w` export of each windowed list whose header does not change, which has no update. It\n * starts the window, which renders the items in view.\n */\n private emitWindowStarts(): void {\n for (const block of this.windowedBlocks()) {\n if (this.windowStarts.has(block)) {\n continue;\n }\n const site = this.headerSites(block)[0];\n if (!site) {\n continue;\n }\n this.emitBlockUpdate(\n block,\n `b${this.counterOfWindows++}w`,\n instanceScope(this.plan, site.scope),\n );\n }\n }\n\n private counterOfWindows = 0;\n\n private windowedBlocks(): Block[] {\n const found: Block[] = [];\n function visit(nodes: readonly unknown[]): void {\n for (const node of nodes as { kind?: string }[]) {\n if (!node || typeof node !== 'object') {\n continue;\n }\n const block = node as Block;\n if (block.kind === 'for' && block.window) {\n found.push(block);\n }\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) {\n visit(value);\n } else if (value && typeof value === 'object' && 'children' in (value as object)) {\n visit((value as { children: unknown[] }).children);\n }\n }\n }\n }\n visit(this.file.children);\n for (const template of this.file.templates) {\n visit(template.body.children);\n }\n return found;\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 held = holderArguments(this.plan, block);\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 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: string[] = [];\n for (const branch of branches) {\n renders.push(this.renderName(branch.body));\n }\n if (block.fallback) {\n renders.push(this.renderName(block.fallback));\n }\n this.emit(\n `export function ${fn}($$s) {\\n $$b.branch($$s, ${anchor}, ${index}, ${this.hoist(`[${renders.join(', ')}]`)}, ${this.hoist(`[${this.kinds(blockBodies(block)).join(', ')}]`)}${held});\\n}`,\n );\n return;\n }\n case 'for':\n case 'repeat': {\n const items =\n block.kind === 'for'\n ? `$$b.toList(${header(0)})`\n : `Array.from({ length: ${header(0)} }, (_, index) => index)`;\n const key = this.keyFunction(block, base);\n // A key that reads only the item is the same function for every update.\n const keyName = key.includes('$$s') ? key : this.hoist(key);\n const fallback = block.fallback ? this.renderName(block.fallback) : 'undefined';\n const fallbackKinds = block.fallback ? this.kinds([block.fallback]) : [];\n const kinds = this.hoist(`[${fallbackKinds.join(', ')}]`);\n const render = this.renderName(block.body);\n const assign = `a${this.plan.bodyScopes.get(block.body)!.id}`;\n // A windowed list renders the items in view, and its `w` export starts its window.\n const call =\n block.kind === 'for' && block.window\n ? `$$b.windowList($$s, ${anchor}, ${items}, ${keyName}, ${render}, ${assign}, ${fallback}, ${kinds}, ${header(1)}${held})`\n : `$$b.list($$s, ${anchor}, ${items}, ${keyName}, ${render}, ${assign}, ${fallback}, ${kinds}${held})`;\n this.emit([`export function ${fn}($$s) {`, ` ${call};`, '}'].join('\\n'));\n if (block.kind === 'for' && block.window) {\n this.emit(\n `export function w${anchor}($$s) {\\n $$b.windowStart($$s, ${anchor}, () => ${call});\\n}`,\n );\n this.windowStarts.add(block);\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}]${held});\\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}${held});\\n}`,\n );\n return;\n case 'loading': {\n // `#loading (posts)` holds while a memo of its header, or a memo upstream of it, loads.\n const checks: string[] = [];\n const seen = new Set<Declaration>();\n for (const read of headers[0]?.reads ?? []) {\n const slot = slotIndex(this.plan, read.declaration);\n if (slot !== -1 && !seen.has(read.declaration)) {\n seen.add(read.declaration);\n checks.push(\n `$$b.pending(${scopePath(this.plan, '$$s', base, read.declaration.scope)}, ${slot})`,\n );\n }\n }\n if (checks.length === 0) {\n return;\n }\n const fallback = block.fallback;\n const render = fallback ? this.renderName(fallback) : 'undefined';\n const kinds = this.hoist(`[${fallback ? this.kinds([fallback]).join(', ') : ''}]`);\n this.emit(\n `export function ${fn}($$s) {\\n $$b.held($$s, ${anchor}, ${checks.join(' || ')}, ${this.plan.bodyScopes.get(block.body)!.id}, ${render}, ${kinds}${held});\\n}`,\n );\n return;\n }\n case 'key': {\n // The block around a dynamic tag keeps the element that the server rendered with the tag.\n const [inner] = block.body.children;\n const helper = inner?.kind === 'dynamic' && inner.keyed ? 'retag' : 'rekey';\n this.emit(\n `export function ${fn}($$s) {\\n $$b.${helper}($$s, ${anchor}, ${header(0)}, ${this.renderName(block.body)}, ${this.hoist(`[${this.kinds([block.body]).join(', ')}]`)}${held});\\n}`,\n );\n return;\n }\n default:\n return;\n }\n }\n\n private itemDeclarations(block: ForBlock | RepeatBlock): Declaration[] {\n const result: Declaration[] = [];\n for (const declaration of this.model.declarations) {\n if (\n declaration.block === block &&\n (declaration.kind === 'item' || declaration.kind === 'index')\n ) {\n result.push(declaration);\n }\n }\n return result;\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 let site!: Site;\n for (const item of this.model.sites) {\n if (item.label === 'for key' && item.block === block) {\n site = item;\n break;\n }\n }\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 (node.block.kind === 'loading') {\n // The browser renders the fallback of a `#loading` block with a header, never its body.\n const fallback = node.block.fallback;\n if (fallback) {\n this.renders.set(this.plan.bodyScopes.get(fallback)!, {\n body: fallback,\n block: node.block,\n });\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 // The browser renders the items of a windowed list that come into view.\n (block?.kind === 'for' && block.window !== 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 /**\n * Replaces the one `$$html +=` line of a render with a clone of a template and the writes on\n * its elements. Returns false when the markup needs HTML.\n */\n private cloneRender(emitter: Emitter, body: Body): boolean {\n return cloneLines(emitter, (code) => this.hoist(code), 0, body);\n }\n\n /**\n * The code of the render function of a body. With `fill`, the body fills its nested blocks\n * after it clones its template, and gives undefined when it cannot clone.\n */\n private emitRender(scope: Scope, body: Body, block: Block, fill: boolean): string | undefined {\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 fills: fill ? (nested) => this.createFill(nested) : undefined,\n hoist: (code) => this.hoist(code),\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 this.declared(inside).slice(1)) {\n emitter.emitTemplate(template.template!);\n }\n // The script of the body can split the function at `await $memo`.\n let cloned = false;\n emitter.splitBody(\n scope,\n () => {\n if (isItem) {\n emitter.emitItem(block, '$$item', '$$index');\n } else {\n emitter.emitBody(body);\n }\n },\n () => {\n emitter.flush();\n // The body of an `#if` or a `#for`, and the fallback of a `#loading`, whose markup is one\n // string clones a template.\n cloned = this.cloneRender(emitter, body);\n emitter.line(emitter.returnLine(0, cloned));\n },\n );\n if (fill && !cloned) {\n return undefined;\n }\n emitter.close();\n return emitter.lines.join('\\n');\n }\n\n /** The name of the render function of a body, when the module has one. */\n private findRenderName(body: object | undefined): string | undefined {\n const scope = body && this.plan.bodyScopes.get(body as never);\n return scope && this.renders.has(scope) ? `r${scope.id}` : undefined;\n }\n\n /**\n * The render functions that fill a nested `#if` or `#for` of a clone, when the module has\n * them all. A `#for` with an `#else` renders inline.\n */\n private createFill(block: Block): Fill | undefined {\n if (block.kind === 'if') {\n const bodies: (Body | undefined)[] = [];\n for (const branch of block.branches) {\n bodies.push(branch.body);\n }\n bodies.push(block.fallback);\n const renders: string[] = [];\n for (const body of bodies) {\n if (body === undefined) {\n continue;\n }\n const name = this.findRenderName(body);\n if (name === undefined) {\n return undefined;\n }\n renders.push(name);\n }\n return { kind: 'if', renders };\n }\n if (block.kind === 'for' && !block.fallback) {\n const render = this.findRenderName(block.body);\n return render ? { kind: 'for', render } : undefined;\n }\n return undefined;\n }\n\n private emitRenders(): void {\n for (const [scope, { body, block }] of this.renders) {\n const clonable = block.kind === 'if' || block.kind === 'for';\n // A body that fills its nested blocks must clone, so one that cannot renders again inline.\n const lines =\n (clonable && this.emitRender(scope, body, block, true)) ||\n this.emitRender(scope, body, block, false)!;\n this.emit(lines);\n const base = scope.parent!;\n\n if (block.kind === 'portal' && block.target) {\n let header!: Site;\n for (const site of this.model.sites) {\n if (site.kind === 'block' && site.block === block) {\n header = site;\n break;\n }\n }\n const target = this.rewriter.rewrite(header, '$$s', instanceScope(this.plan, base));\n const held = holderArguments(this.plan, block);\n this.emit(\n `export function k${scope.id}($$s) {\\n $$b.portalTo($$s, ${target}, r${scope.id}${held && `, []${held}`});\\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 held = holderArguments(this.plan, block);\n const kinds = block.fallback\n ? this.hoist(`[${this.kinds([block.fallback]).join(', ')}]`)\n : '[]';\n const fallback = block.fallback || held ? `, ${kinds}${held}` : '';\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 * The renders of children, such as `n0`, which the browser calls each time a component inserts\n * them again, so they get new scopes, as the body of a block does.\n */\n private emitChildrenRenders(): void {\n for (const [node, { symbol, scope }] of this.plan.childrenRenders) {\n const range = { start: node.children[0]!.start, end: node.children.at(-1)!.end };\n function within(item: { start: number; end: number } | undefined): boolean {\n return item !== undefined && range.start <= item.start && item.end <= range.end;\n }\n // The scopes of the blocks in the children, and of the templates that the children call.\n const nested: Scope[] = [];\n for (const item of this.model.scopes) {\n if (item.parent === scope && item.kind === 'body' && within(item.block)) {\n nested.push(item);\n }\n }\n for (const site of this.model.sites) {\n if (site.scope !== scope || !within(site.node as { start: number; end: number })) {\n continue;\n }\n // The templates that the children call, and those that they pass on, such as a prop\n // `render=label`.\n const used: Declaration[] = [...site.calls];\n for (const read of site.reads) {\n used.push(read.declaration);\n }\n for (const callee of used) {\n const template = callee.kind === 'template' ? this.findTemplateScope(callee) : undefined;\n if (template && !nested.includes(template)) {\n nested.push(template);\n }\n }\n }\n const insideSet = new Set<Scope>();\n for (const item of nested) {\n for (const scoped of this.inside(item)) {\n insideSet.add(scoped);\n }\n }\n const inside = [...insideSet];\n const base = instanceScope(this.plan, scope);\n const emitter = new Emitter(this.file, this.plan, this.valuePatch, {\n mode: 'client',\n outer: { inside, base, baseVar: '$$p' },\n hoist: (code) => this.hoist(code),\n });\n emitter.line(`export function ${symbol}($$p) {`);\n emitter.line(`let $$html = '';`);\n for (const line of this.prologue(inside, base)) {\n emitter.line(line);\n }\n // The values that the children read in the scope that they were written in.\n const declarations = new Set<Declaration>();\n for (const site of this.model.sites) {\n if (site.scope === scope && within(site.node as { start: number; end: number })) {\n for (const read of site.reads) {\n // A handler is named by its table entry, so its function is not a local here. The\n // update part does not import a function that only handlers reach.\n if (read.declaration.kind === 'function' && DEFERRED_SITES.has(site.kind)) {\n continue;\n }\n if (!isWithinAny(read.declaration.scope, inside)) {\n declarations.add(read.declaration);\n }\n }\n }\n }\n for (const declaration of declarations) {\n if (['import', 'module', 'template'].includes(declaration.kind)) {\n continue;\n }\n const value = this.rewriter.value(declaration, '$$p', base);\n if (!value) {\n continue;\n }\n let declared = false;\n for (const line of emitter.lines) {\n if (line.trim().startsWith(`let ${declaration.name} =`)) {\n declared = true;\n break;\n }\n }\n if (!declared) {\n emitter.line(`let ${declaration.name} = ${value};`);\n }\n }\n for (const template of this.declared(inside)) {\n if (template.kind === 'template') {\n emitter.emitTemplate(template.template!);\n }\n }\n emitter.emitChildrenBody(node, scope);\n emitter.flush();\n const cloned = cloneLines(emitter, (code) => this.hoist(code), 0, node);\n emitter.line(emitter.returnLine(0, cloned));\n emitter.close();\n this.emit(emitter.lines.join('\\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 /**\n * The slots of the arguments of a template that a prop passes, as `[slot, value]` pairs, so an\n * insert that calls it again writes its new arguments into the scope that it rendered.\n */\n private emitTemplateArgs(site: Site, symbol: string): void {\n let callee: Declaration | undefined;\n for (const read of site.reads) {\n if (read.declaration.kind === 'template') {\n callee = read.declaration;\n break;\n }\n }\n const scope = callee && this.findTemplateScope(callee);\n if (scope) {\n this.emitArgsExports(symbol, scope);\n }\n }\n\n /** The `a` and `k` exports of a template, which `symbol` names. */\n private emitArgsExports(symbol: string, scope: Scope): void {\n const args = templateArgs(this.plan, this.file.source, scope);\n if (!args) {\n return;\n }\n this.emit(`export const ${symbol}a = (${args.exported}) => [${args.pairs.join(', ')}];`);\n // The ID of the template's scope, so an insert updates in place only a scope of this template.\n this.emit(`export const ${symbol}k = ${scope.id};`);\n }\n\n /**\n * The exports of the templates of the file that a call in markup can update in place: the\n * template is `T` and its scope ID, as `templateCall` of the template's code names it.\n */\n private emitTemplateExports(): void {\n this.part = 'update';\n for (const scope of this.model.scopes) {\n if (scope.template) {\n this.emitArgsExports(`T${scope.id}`, scope);\n }\n }\n }\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: Declaration[] = [...site.calls];\n for (const read of site.reads) {\n if (read.declaration.kind === 'template') {\n used.push(read.declaration);\n }\n }\n for (const callee of used) {\n if (callee.kind !== 'template') {\n continue;\n }\n const template = this.findTemplateScope(callee);\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 this.declared(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 function isInside(scope: Scope): boolean {\n return isWithinAny(scope, inside);\n }\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, and the holder of a block in children.\n */\n private triesTable(): string | undefined {\n // The entry of each `#try` that catches, by its body.\n const bodies = new Map<Scope, 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 held = holderArguments(this.plan, block);\n bodies.set(\n scope,\n `[${owner.id}, ${this.plan.anchors.get(block)}, ${JSON.stringify(`r${scope.id}`)}, ${JSON.stringify(`r${fallback.id}`)}, [${this.kinds(blockBodies(block)).join(', ')}]${held}]`,\n );\n }\n // Each scope takes the entry of the nearest `#try` around it. A template renders where it\n // is called, and its scope links there at runtime, so a scope in a template takes no entry\n // of a `#try` around the template.\n const entries: string[] = [];\n for (const inside of this.model.scopes) {\n let current: Scope | undefined = inside;\n while (current && !bodies.has(current) && current.kind !== 'template') {\n current = current.parent;\n }\n const entry = current && bodies.get(current);\n if (entry) {\n entries.push(`${inside.id}: ${entry}`);\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: string[] = [];\n for (const [id, entries] of table) {\n const pairs: string[] = [];\n for (const [kind, fn] of entries) {\n pairs.push(`[${kind}, ${JSON.stringify(fn)}]`);\n }\n items.push(`${JSON.stringify(id)}: [${pairs.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 let known = false;\n for (const [, name] of entries) {\n if (name === fn) {\n known = true;\n break;\n }\n }\n if (!known) {\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 const pairs: string[] = [];\n for (const [kind, name] of sorted) {\n pairs.push(`[${kind}, ${JSON.stringify(name)}]`);\n }\n items.push(`${slot}: [${pairs.join(', ')}]`);\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 {\n ModuleError,\n expandModules,\n mayExportFunction,\n relocate,\n resolveFromDisk,\n} 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 { checkPendingReads } from './pending-reads.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, withCode } from './error.ts';\nimport type { Location } from './error.ts';\nimport { buildGraph } from './graph.ts';\nimport { lookup } from './model.ts';\nimport type { oxc } from './oxc.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 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: string[] = [];\n for (const diagnostic of diagnostics) {\n const { line, column } = getLocation(source, diagnostic.range.start);\n lines.push(`${withCode(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/** Keeps the diagnostics of one severity. */\nfunction filterBySeverity(\n diagnostics: Diagnostic[],\n severity: Diagnostic['severity'],\n): Diagnostic[] {\n const kept: Diagnostic[] = [];\n for (const diagnostic of diagnostics) {\n if (diagnostic.severity === severity) {\n kept.push(diagnostic);\n }\n }\n return kept;\n}\n\n/** Finds the index of the module with this path, or -1. */\nfunction findModuleIndex(modules: ReactiveModule[], modulePath: string): number {\n for (const [index, module] of modules.entries()) {\n if (module.path === modulePath) {\n return index;\n }\n }\n return -1;\n}\n\n/** The origin of an offset of a component that calls no module function. */\nfunction identity(offset: number): Origin {\n return { offset };\n}\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+\\)$/, '').replace(/ \\[BRM\\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<number, ModuleCall>();\n for (const call of calls) {\n byStart.set(call.start, call);\n }\n const specifiers: string[] = [];\n for (const module of modules) {\n specifiers.push(\n `${relocate(`./${module.path.split('/').pop()}`, module.path, path)}${SHARED_QUERY}`,\n );\n }\n return {\n specifiers,\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: findModuleIndex(modules, 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 function 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 function fail(errors: Diagnostic[]): never {\n const translated: Diagnostic[] = [];\n for (const error of errors) {\n translated.push(translate(error));\n }\n throw new CompileError(source, filename, translated);\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 // An import that a prop passes can be a function, which the browser calls through a reference.\n for (const site of model.sites) {\n if (site.kind !== 'prop') {\n continue;\n }\n // The function in a wrapper, such as `$untrack(fn)` or `prevent(fn)`, or in parentheses.\n let node: oxc.Node = site.node;\n while (\n node.type === 'ParenthesizedExpression' ||\n (node.type === 'CallExpression' && node.arguments[0]?.type !== 'SpreadElement')\n ) {\n const inner: oxc.Node | undefined =\n node.type === 'ParenthesizedExpression' ? node.expression : node.arguments[0];\n if (!inner) {\n break;\n }\n node = inner;\n }\n if (node.type !== 'Identifier') {\n continue;\n }\n const declaration = lookup(site.scope, node.name);\n if (\n declaration?.kind === 'import' &&\n declaration.imported &&\n // A server function has its own reference.\n declaration.serverImport === undefined &&\n declaration.callable === undefined\n ) {\n declaration.callable = mayExportFunction(\n declaration.imported.source,\n declaration.imported.name,\n options.path ?? filename,\n options.resolveModule ?? resolveFromDisk,\n );\n }\n }\n checkPendingReads(model.sites, model.pendingCalls, (message, range) =>\n model.diagnostics.push({ severity: 'error', message, range }),\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 = filterBySeverity(diagnostics, 'error');\n if (errors.length > 0) {\n fail(errors);\n }\n const plan = createPlan(file, graph, options.path, options.hideNames);\n const styleErrors = filterBySeverity([...plan.styles.diagnostics, ...plan.diagnostics], 'error');\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 = filterBySeverity(client.diagnostics, '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 = [{ name: filename, content: source }];\n for (const module of modules) {\n files.push({ name: module.path, content: module.source });\n }\n function place(offset: number): { index: number; offset: number } {\n const at = origin(offset);\n return {\n index: at.module ? findModuleIndex(modules, at.module.path) + 1 : 0,\n offset: at.offset,\n };\n }\n function done(code: string) {\n return finish(code, files, place);\n }\n const server = done(generateServer(file, plan));\n const entry = done(client.code);\n const partCodes: Record<string, string> = {};\n const partMaps: Record<string, SourceMap> = {};\n for (const [name, code] of Object.entries(client.parts)) {\n const part = done(code);\n partCodes[name] = part.code;\n partMaps[name] = part.map;\n }\n const warnings: Diagnostic[] = [];\n for (const warning of filterBySeverity(diagnostics, 'warning')) {\n warnings.push(translate(warning));\n }\n const modulePaths: string[] = [];\n for (const module of modules) {\n modulePaths.push(module.path);\n }\n const render = done(generateRender(file, plan, client.fillOf));\n return {\n server: server.code,\n client: entry.code,\n parts: partCodes,\n table: client.table,\n clientCode: client.clientCode,\n render: render.code,\n maps: {\n server: server.map,\n client: entry.map,\n parts: partMaps,\n render: render.map,\n },\n css: plan.styles.css,\n file,\n plan,\n warnings,\n modules: modulePaths,\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 function 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: string[] = [];\n for (const edge of graph.edges) {\n if (edge.to === node && graph.live.has(edge.from)) {\n from.push(nodeLabel(edge.from));\n }\n }\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 const slots: string[] = [];\n for (const slot of layout.slots) {\n slots.push(slot.name);\n }\n state.push({ scope: scopeLabel(source, scope), slots });\n }\n }\n\n let elements = 0;\n let inserts = 0;\n function 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 (node.kind === 'element' && !plan.anchors.has(node) && !hasEvent(node)) {\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 function 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: string[] = [];\n for (const write of declaration.writes) {\n if (reached.has(write.site)) {\n writers.push(siteLabel(source, write.site));\n }\n }\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\n ? [declaration.propKey, '*', ...(declaration.propKey === 'children' ? [] : ['~'])]\n : [...(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\n/** True if the markup has an event attribute. */\nfunction hasEvent(node: Markup & { kind: 'element' }): boolean {\n for (const attribute of node.attributes) {\n if (attribute.kind === 'event') {\n return true;\n }\n }\n return false;\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 function 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":";;;;;;;AA4BA,MAAa,cAAsB;;AAGnC,SAAgB,UAAU,MAAsB;CAC9C,OAAO,GAAG,YAAY,GAAG,KAAK,YAAY;AAC5C;AAEA,SAAS,MAAM,MAAc,SAAiB,OAAe,KAAyB;CACpF,OAAO;EAAE;EAAS;EAAO;EAAK;EAAM,MAAM,UAAU,IAAI;CAAE;AAC5D;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,wBACA,oCACA,kFACF;CACA,MACE,UACA,uBACA,2CACA,qBACF;CACA,MACE,UACA,iCACA,4CACA,gCACF;CACA,MACE,UACA,mCACA,+CACA,wBACF;CACA,MACE,UACA,yBACA,2CACA,sBACF;CACA,MACE,UACA,uBACA,gFACA,sBACF;CACA,MACE,UACA,qCACA,gEACA,gCACF;CACA,MACE,UACA,kDACA,+BACA,8BACF;CACA,MAAM,UAAU,0BAA0B,qCAAqC,aAAa;CAC5F,MACE,UACA,gEACA,wEACA,sGACF;CACA,MACE,UACA,oCACA,gDACA,6DACF;CACA,MACE,UACA,iEACA,yEACA,yDACF;CACA,MACE,UACA,mCACA,oFACA,4DACF;CACA,MAAM,UAAU,uBAAuB,oCAAoC,iBAAiB;CAC5F,MACE,UACA,iCACA,0EACA,gCACF;CACA,MAAM,UAAU,sBAAsB,kCAAkC,aAAa;CACrF,MACE,UACA,0CACA,kDACA,oBACF;CACA,MACE,UACA,0CACA,oCACA,+BACF;CACA,MACE,UACA,wCACA,qEACA,kCACF;CACA,MACE,UACA,8CACA,kEACA,8BACF;CACA,MACE,UACA,8BACA,0DACA,kBACF;CACA,MACE,UACA,mEACA,6MACA,qFACF;CACA,MACE,UACA,sDACA,6FACA,kDACF;CACA,MACE,UACA,yCACA,kXACA,sEACF;CACA,MACE,UACA,sJACA,uKACA,wHACF;CACA,MACE,UACA,0IACA,oKACA,2IACF;CACA,MACE,UACA,mEACA,2EACA,wFACF;CACA,MACE,UACA,sHACA,kHACA,qDACF;CACA,MACE,UACA,+JACA,6TACA,mEACF;CACA,MACE,UACA,8LACA,+VACA,qNACF;CACA,MACE,UACA,6HACA,0TACA,+GACF;CACA,MACE,UACA,6BACA,+CACA,8CACF;CACA,MACE,UACA,wDACA,uDACA,8CACF;CACA,MACE,UACA,kDACA,0CACA,kCACF;CACA,MACE,UACA,0CACA,gDACA,0BACF;CACA,MACE,UACA,kEACA,8CACA,8BACF;CACA,MACE,UACA,+DACA,wCACA,wEACF;CACA,MACE,UACA,+BACA,8CACA,oBACF;CACA,MACE,UACA,4CACA,uEACA,2CACF;CACA,MACE,UACA,kCACA,yCACA,oBACF;CACA,MACE,UACA,2BACA,uEACA,mCACF;CACA,MACE,UACA,oBACA,4CACA,oCACF;CACA,MACE,UACA,yCACA,qEACA,uDACF;CACA,MACE,UACA,uCACA,kCACA,gFACF;CACA,MACE,UACA,gCACA,oCACA,oEACF;CACA,MACE,UACA,8CACA,uCACA,gFACF;CACA,MACE,UACA,wCACA,gEACA,uDACF;CACA,MACE,UACA,+CACA,8CACA,gEACF;CACA,MACE,UACA,wIACA,kDACA,6CACF;CACA,MACE,UACA,4GACA,4CACA,6CACF;CACA,MACE,UACA,oCACA,8CACA,uEACF;CACA,MACE,UACA,mCACA,wDACA,gCACF;CACA,MACE,UACA,2CACA,yCACA,gCACF;CACA,MACE,UACA,mCACA,iDACA,gCACF;CACA,MACE,UACA,gCACA,kCACA,0DACF;CACA,MACE,UACA,6CACA,yEACA,sGACF;CACA,MACE,UACA,6BACA,8CACA,0EACF;CACA,MACE,UACA,4CACA,gGACA,sDACF;CACA,MACE,UACA,uEACA,4CACA,gDACF;CACA,MACE,UACA,4BACA,6CACA,gCACF;CACA,MACE,UACA,6CACA,oDACA,2CACF;CACA,MACE,UACA,mEACA,qCACA,qEACF;CACA,MACE,UACA,oDACA,iDACA,8EACF;CACA,MACE,UACA,kDACA,kDACA,+FACF;CACA,MACE,UACA,+CACA,yCACA,+FACF;CACA,MACE,UACA,iDACA,wCACA,yDACF;CACA,MACE,UACA,0BACA,+DACA,oBACF;CACA,MACE,UACA,8BACA,gEACA,6DACF;CACA,MACE,UACA,uBACA,6DACA,yDACF;AACF;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,kCACA,qDACA,kDACF;CACA,MACE,UACA,0BACA,iHACA,wCACF;CACA,MACE,UACA,kEACA,+FACA,kDACF;CACA,MACE,UACA,gKACA,iEACA,iEACF;CACA,MACE,UACA,yDACA,+CACA,8CACF;CACA,MACE,UACA,4CACA,kDACA,mFACF;CACA,MACE,UACA,kDACA,2CACA,uDACF;CACA,MACE,UACA,sDACA,wCACA,uDACF;CACA,MACE,UACA,wCACA,8CACA,kBACF;CACA,MACE,UACA,sCACA,oEACA,qCACF;CACA,MACE,UACA,uDACA,mDACA,8CACF;CACA,MACE,UACA,uCACA,mEACA,8CACF;CACA,MACE,UACA,+BACA,+BACA,8CACF;CACA,MACE,UACA,kDACA,+CACA,8CACF;CACA,MACE,UACA,4CACA,0CACA,sBACF;CACA,MAAM,UAAU,0BAA0B,0BAA0B,sBAAsB;CAC1F,MACE,UACA,oFACA,+DACA,2FACF;CACA,MACE,UACA,kCACA,kCACA,mCACF;CACA,MACE,UACA,4DACA,wCACA,sCACF;CACA,MACE,UACA,6DACA,gDACA,0CACF;CACA,MACE,UACA,+EACA,mDACA,iGACF;CACA,MACE,UACA,8DACA,uDACA,mCACF;CACA,MACE,UACA,8EACA,4CACA,+BACF;CACA,MACE,UACA,qEACA,gDACA,+BACF;CACA,MACE,UACA,uEACA,iFACA,0FACF;CACA,MACE,UACA,6BACA,wDACA,sCACF;CACA,MACE,UACA,iCACA,4FACA,yBACF;CACA,MACE,UACA,mDACA,8DACA,sCACF;CACA,MACE,UACA,oEACA,qEACA,sCACF;CACA,MACE,UACA,kCACA,sEACA,2DACF;CACA,MACE,UACA,6BACA,mEACA,yBACF;CACA,MACE,UACA,wBACA,6CACA,kCACF;CACA,MACE,UACA,yDACA,gDACA,iCACF;CACA,MACE,UACA,kCACA,iDACA,iDACF;CACA,MACE,UACA,2BACA,2DACA,iDACF;CACA,MACE,UACA,8CACA,0DACA,iDACF;CACA,MACE,UACA,0CACA,sDACA,mEACF;CACA,MACE,UACA,8BACA,yCACA,iDACF;CACA,MACE,UACA,oEACA,uDACA,4CACF;CACA,MACE,UACA,mJACA,uDACA,8CACF;CACA,MACE,UACA,wJACA,wEACA,qCACF;CACA,MACE,UACA,8CACA,qCACA,2CACF;CACA,MACE,UACA,2HACA,4CACA,oDACF;CACA,MACE,UACA,sGACA,mFACA,oDACF;CACA,MACE,UACA,sHACA,iEACA,4BACF;CACA,MACE,UACA,gIACA,+DACA,2BACF;CACA,MACE,UACA,uGACA,iEACA,uDACF;CACA,MACE,UACA,0FACA,mDACA,6FACF;CACA,MACE,UACA,kDACA,yFACA,4FACF;CACA,MACE,UACA,iDACA,qDACA,wDACF;CACA,MACE,UACA,2DACA,wDACA,wDACF;CACA,MACE,UACA,gFACA,kCACA,wBACF;CACA,MACE,UACA,8BACA,kEACA,oEACF;CACA,MACE,UACA,qGACA,2EACA,oEACF;CACA,MACE,UACA,kGACA,mEACA,gEACF;CACA,MACE,UACA,qGACA,ycACA,qFACF;CACA,MACE,UACA,8GACA,+FACA,0CACF;CACA,MACE,UACA,sCACA,yEACA,qCACF;CACA,MACE,UACA,qGACA,0DACA,yBACF;CACA,MACE,UACA,8EACA,8DACA,yDACF;CACA,MACE,UACA,iEACA,4CACA,iCACF;CACA,MACE,UACA,yDACA,yEACA,6CACF;CACA,MACE,UACA,8BACA,4DACA,yBACF;CACA,MACE,UACA,iDACA,0DACA,mCACF;CACA,MACE,UACA,4CACA,qDACA,kBACF;CACA,MACE,UACA,yEACA,kDACA,sBACF;CACA,MACE,UACA,+FACA,wDACA,kCACF;CACA,MACE,UACA,0FACA,0DACA,0CACF;CACA,MACE,UACA,8EACA,qDACA,yBACF;CACA,MACE,UACA,wFACA,0DACA,mCACF;CACA,MACE,UACA,iEACA,oEACA,8CACF;CACA,MACE,UACA,oFACA,sDACA,yBACF;CACA,MACE,UACA,kFACA,oDACA,kCACF;CACA,MACE,UACA,uFACA,qIACA,4DACF;CACA,MACE,UACA,mFACA,mRACA,4DACF;CACA,MACE,UACA,kHACA,oDACA,4DACF;CACA,MACE,UACA,sGACA,yDACA,sCACF;CACA,MACE,UACA,sGACA,yDACA,4CACF;CACA,MACE,UACA,oGACA,0DACA,iCACF;CACA,MACE,UACA,2GACA,sDACA,+BACF;CACA,MACE,UACA,6CACA,sDACA,iDACF;CACA,MACE,UACA,6CACA,sDACA,4CACF;CACA,MACE,UACA,6DACA,uBACA,oEACF;CACA,MACE,UACA,wCACA,yBACA,sCACF;CACA,MACE,UACA,0CACA,2BACA,oCACF;CACA,MACE,UACA,gFACA,2BACA,sGACF;CACA,MACE,UACA,mHACA,uFACA,gEACF;CACA,MACE,UACA,sCACA,+CACA,uEACF;CACA,MACE,UACA,sFACA,4IACA,uDACF;CACA,MACE,UACA,sDACA,mCACA,+BACF;CACA,MACE,UACA,sJACA,ySACA,oEACF;CACA,MACE,UACA,8MACA,yUACA,sGACF;CACA,MACE,UACA,8FACA,qNACA,gEACF;CACA,MACE,UACA,4KACA,4PACA,sHACF;CACA,MACE,UACA,wIACA,kOACA,2JACF;CACA,MACE,UACA,wDACA,uDACA,uFACF;CACA,MACE,UACA,wDACA,uDACA,uFACF;CACA,MACE,UACA,qEACA,yEACA,4CACF;CACA,MACE,UACA,iCACA,mEACA,4CACF;AACF;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,wMACA,2GACA,iEACF;CACA,MACE,UACA,0FACA,8EACA,mEACF;CACA,MACE,UACA,kIACA,yFACA,mEACF;CACA,MACE,UACA,0CACA,0DACA,6BACF;CACA,MACE,UACA,uDACA,8FACA,6BACF;CACA,MACE,UACA,wGACA,oGACA,yCACF;CACA,MACE,UACA,kGACA,mCACA,gDACF;CACA,MACE,UACA,iEACA,sLACA,iCACF;CACA,MACE,UACA,2FACA,2EACA,qCACF;CACA,MACE,UACA,6FACA,uEACA,qCACF;CACA,MACE,UACA,kDACA,6GACA,kDACF;CACA,MACE,UACA,wIACA,gXACA,gNACF;CACA,MACE,UACA,4EACA,gFACA,gGACF;CACA,MACE,UACA,+CACA,qDACA,oBACF;CACA,MACE,UACA,0BACA,4CACA,gDACF;CACA,MACE,UACA,qFACA,kGACA,0FACF;AACF;;AAGA,MAAM,UAAwB;CAC5B,MACE,UACA,sEACA,0DACA,0CACF;CACA,MACE,UACA,0CACA,2DACA,0CACF;CACA,MACE,UACA,kLACA,yEACA,0CACF;CACA,MACE,UACA,2BACA,yDACA,6CACF;CACA,MACE,UACA,uDACA,gEACA,iGACF;CACA,MACE,UACA,mDACA,mEACA,iGACF;CACA,MACE,UACA,iEACA,uDACA,iGACF;CACA,MACE,UACA,qCACA,wDACA,iGACF;CACA,MACE,UACA,0FACA,+FACA,+CACF;CACA,MACE,UACA,gDACA,iEACA,8BACF;CACA,MACE,UACA,yEACA,iDACA,8BACF;CACA,MACE,UACA,gCACA,+EACA,+BACF;CACA,MACE,UACA,wHACA,uDACA,8BACF;CACA,MACE,UACA,4BACA,kEACA,8EACF;CACA,MACE,UACA,4CACA,8DACA,iGACF;CACA,MACE,UACA,sGACA,uEACA,wBACF;AACF;AAEA,MAAa,SAAgC;CAAC,GAAG;CAAQ,GAAG;CAAQ,GAAG;CAAQ,GAAG;AAAO;;AAGzF,SAAgB,aAAa,OAAmB,SAA0B;CACxE,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,MAAM,QAAQ,MAAM,SAAS,GAC9C,QAAQ,KAAK,KAAK,QAAQ,uBAAuB,MAAM,CAAC;CAE1D,MAAM,UAAU,QAAQ,KAAK,YAAY;CACzC,OAAO,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC,CAAC,KAAK,OAAO;AAChD;;;;;AAMA,SAAgB,UAAU,SAAyC;CACjE,MAAM,OAAO,QAAQ,QAAQ,8BAA8B,EAAE,CAAC,CAAC,QAAQ,iBAAiB,EAAE;CAE1F,SAAS,MAAM,OAA2B;EACxC,OAAO,MAAM,QAAQ,QAAQ,YAAY,EAAE,CAAC,CAAC;CAC/C;CACA,IAAI;CACJ,KAAK,MAAM,SAAS,QAClB,IAAI,a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A;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,2BAAW,IAAI,IAAoB;AACzC,KAAK,MAAM,QAAQ,cACjB,SAAS,IAAI,KAAK,KAAK,YAAY,KAAK,KAAK,MAAM;;AAIrD,SAAgB,eAAe,WAAuC;CACpE,MAAM,QAAQ,SAAS,IAAI,UAAU,YAAY,CAAC;CAClD,OAAO,UAAU,YAAY,KAAA,IAAY;AAC3C;AAKA,MAAM,6BAAa,IAAI,IAAoB;CACzC,CACE,oBACA,gJACF;CACA,CAAC,eAAe,wCAAwC;CACxD,CAAC,cAAc,0CAA0C;CACzD,CAAC,eAAe,2CAA2C;CAC3D,CAAC,kBAAkB,0CAA0C;CAC7D,CAAC,uBAAuB,0CAA0C;CAClE,CAAC,wBAAwB,kEAAkE;CAC3F,CACE,4BACA,sEACF;CACA,CAAC,sBAAsB,gEAAgE;CACvF,CAAC,uBAAuB,iEAAiE;AAC3F,CAAC;AACD,KAAK,MAAM,YAAY;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GACE,WAAW,IACT,SAAS,YAAY,GACrB,+DACF;;AAIF,SAAgB,aAAa,WAAuC;CAClE,OAAO,WAAW,IAAI,UAAU,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;AACxD;;;AClJA,SAAgB,aAAa,MAAmC;CAC9D,OAAO,SAAS,OAAO,SAAS,OAAQ,SAAS,QAAQ,SAAS,QAAQ,SAAS;AACrF;AAEA,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