brumate 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/{boot-CMy0f_iC.d.ts → boot-BkUdiYOF.d.ts} +2 -2
  2. package/dist/cli.js +3 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{client-COm1iA6w.js → client-B0FXW5Kw.js} +48 -14
  5. package/dist/client-B0FXW5Kw.js.map +1 -0
  6. package/dist/{client-DnFF9_lv.d.ts → client-Cq6aTiDs.d.ts} +15 -7
  7. package/dist/{defer-Cesb-k2Q.js → defer-BMIMP4Hq.js} +2 -2
  8. package/dist/{defer-Cesb-k2Q.js.map → defer-BMIMP4Hq.js.map} +1 -1
  9. package/dist/{devtools-C9IEkgc1.js → devtools-B4prrxht.js} +257 -118
  10. package/dist/devtools-B4prrxht.js.map +1 -0
  11. package/dist/devtools-calls-DGW6nLZ2.js +249 -0
  12. package/dist/devtools-calls-DGW6nLZ2.js.map +1 -0
  13. package/dist/devtools-panel-B1nF1KB7.js +3978 -0
  14. package/dist/devtools-panel-B1nF1KB7.js.map +1 -0
  15. package/dist/error-catalog-DakxjSgj.js +308 -0
  16. package/dist/error-catalog-DakxjSgj.js.map +1 -0
  17. package/dist/error-catalog-VxLbz-6p.js +1 -0
  18. package/dist/{files-BuQvpBwF.js → files-D5GtxwEQ.js} +2 -2
  19. package/dist/{files-BuQvpBwF.js.map → files-D5GtxwEQ.js.map} +1 -1
  20. package/dist/index.d.ts +73 -18
  21. package/dist/index.js +11 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/{inspect-BSHv1_25.js → inspect-CGl5Y8q6.js} +581 -399
  24. package/dist/inspect-CGl5Y8q6.js.map +1 -0
  25. package/dist/{loader-CLKrJMqw.js → loader-BsaSuIoG.js} +4 -4
  26. package/dist/{loader-CLKrJMqw.js.map → loader-BsaSuIoG.js.map} +1 -1
  27. package/dist/{navigate-OHb0Uw1P.js → navigate-BlowKvhB.js} +13 -6
  28. package/dist/navigate-BlowKvhB.js.map +1 -0
  29. package/dist/{rpc-BAKbRWOT.js → rpc-C1jYVNAe.js} +5 -4
  30. package/dist/rpc-C1jYVNAe.js.map +1 -0
  31. package/dist/runtime/bundles.d.ts +1 -1
  32. package/dist/runtime/client.d.ts +2 -2
  33. package/dist/runtime/client.js +4 -3
  34. package/dist/runtime/devtools.d.ts +59 -1
  35. package/dist/runtime/devtools.js +1 -1
  36. package/dist/runtime/hot.d.ts +1 -1
  37. package/dist/runtime/hot.js +6 -2
  38. package/dist/runtime/hot.js.map +1 -1
  39. package/dist/runtime/loader.d.ts +2 -2
  40. package/dist/runtime/loader.js +2 -2
  41. package/dist/runtime/server.d.ts +1 -1
  42. package/dist/runtime/server.js +3 -2
  43. package/dist/runtime/signals.d.ts +1 -1
  44. package/dist/runtime/static-loader.d.ts +2 -2
  45. package/dist/runtime/static-loader.js +1 -1
  46. package/dist/runtime/store.d.ts +2 -2
  47. package/dist/runtime/store.js +1 -1
  48. package/dist/runtime/testing.d.ts +2 -2
  49. package/dist/runtime/testing.js +2 -2
  50. package/dist/search-params-Wg-0FsMj.js +148 -0
  51. package/dist/search-params-Wg-0FsMj.js.map +1 -0
  52. package/dist/{stream-RXLadXx1.js → serial-ioa17MuY.js} +67 -168
  53. package/dist/serial-ioa17MuY.js.map +1 -0
  54. package/dist/serial-ribg9NAj.js +1 -0
  55. package/dist/{server-BVObWh-w.js → server-BUuf7XPZ.js} +61 -16
  56. package/dist/server-BUuf7XPZ.js.map +1 -0
  57. package/dist/{server-0rS5vUW1.d.ts → server-DesBZv5g.d.ts} +8 -3
  58. package/dist/{search-params-C64liRBj.js → shared-CX_YacDm.js} +3 -148
  59. package/dist/shared-CX_YacDm.js.map +1 -0
  60. package/dist/{signals-DBnq9QRW.d.ts → signals-7VVD9C_H.d.ts} +2 -2
  61. package/dist/{static-loader-CxANokZ4.js → static-loader-C_en-4v8.js} +2 -2
  62. package/dist/{static-loader-CxANokZ4.js.map → static-loader-C_en-4v8.js.map} +1 -1
  63. package/dist/{static-loader-BYbXVJDY.d.ts → static-loader-UKnK11Em.d.ts} +2 -2
  64. package/dist/{store-xlTzAM_r.d.ts → store-9_oa0HG1.d.ts} +15 -2
  65. package/dist/{store-BIBAYZo-.js → store-Cy4EEyZ7.js} +148 -2
  66. package/dist/store-Cy4EEyZ7.js.map +1 -0
  67. package/dist/stream-read-BTsYstJY.js +22 -0
  68. package/dist/stream-read-BTsYstJY.js.map +1 -0
  69. package/dist/stream-read-Dek3HnqO.js +1 -0
  70. package/dist/vite.d.ts +1 -1
  71. package/dist/vite.js +37 -5
  72. package/dist/vite.js.map +1 -1
  73. package/package.json +7 -4
  74. package/skills/brumate/SKILL.md +6 -2
  75. package/skills/brumate/references/errors.md +21 -2
  76. package/skills/brumate/references/state.md +31 -0
  77. package/skills/brumate/references/syntax.md +45 -1
  78. package/dist/client-COm1iA6w.js.map +0 -1
  79. package/dist/devtools-C9IEkgc1.js.map +0 -1
  80. package/dist/devtools-panel-Doit__YG.js +0 -2018
  81. package/dist/devtools-panel-Doit__YG.js.map +0 -1
  82. package/dist/inspect-BSHv1_25.js.map +0 -1
  83. package/dist/navigate-OHb0Uw1P.js.map +0 -1
  84. package/dist/rpc-BAKbRWOT.js.map +0 -1
  85. package/dist/search-params-C64liRBj.js.map +0 -1
  86. package/dist/server-BVObWh-w.js.map +0 -1
  87. package/dist/store-BIBAYZo-.js.map +0 -1
  88. package/dist/stream-RXLadXx1.js.map +0 -1
@@ -1,263 +1,10 @@
1
+ import { a as findError } from "./error-catalog-DakxjSgj.js";
1
2
  import { i as paragraphComponents, t as checkNesting } from "./nesting-DA5vJw9X.js";
2
3
  import { t as KEY_NAMES } from "./events-LgLdp1R7.js";
3
4
  import { p as insertValue } from "./html-Cf5uKhLs.js";
4
5
  import { parseSync } from "oxc-parser";
5
6
  import { parse } from "postcss";
6
7
  import selectorParser from "postcss-selector-parser";
7
- /** The page of the docs that explains every code, with one anchor for each. */
8
- const ERRORS_PAGE = `https://brumate-docs.vercel.app/docs/errors`;
9
- /** The link to the explanation of a code. */
10
- function errorLink(code) {
11
- return `${ERRORS_PAGE}#${code.toLowerCase()}`;
12
- }
13
- function entry(code, message, cause, fix) {
14
- return {
15
- message,
16
- cause,
17
- fix,
18
- code,
19
- link: errorLink(code)
20
- };
21
- }
22
- /** Syntax errors of the parser, in the order of a file. */
23
- const SYNTAX = [
24
- entry("BRM001", "Unterminated comment", "A comment starts and never ends.", "<!-- A comment ends with -->\n<script>\n /* and so does this one */\n<\/script>"),
25
- entry("BRM002", "Unterminated string", "A string in code starts and never ends.", "const name = 'Ada';"),
26
- entry("BRM003", "Unterminated template literal", "A template string starts and never ends.", "const label = `Hello ${name}`;"),
27
- entry("BRM004", "Unterminated regular expression", "A regular expression starts and never ends.", "const digits = /\\d+/;"),
28
- entry("BRM005", "Unexpected \"{char}\"", "Code has a bracket that closes nothing.", "const list = [1, 2];"),
29
- entry("BRM006", "Expected \"{char}\"", "Code opens a bracket and never closes it. The message names the closing one.", "const list = [1, 2];"),
30
- entry("BRM007", "Expected \"}\" to close the block", "A `#` block opens with `{` and the file ends before its `}`.", "#if (open) {\n <p>Open</p>\n}"),
31
- entry("BRM008", "Unexpected end of file, expected a closing tag", "An element is never closed.", "<div>\n <p>Text</p>\n</div>"),
32
- entry("BRM009", "Unexpected closing tag", "A closing tag has no opening tag.", "<p>Text</p>"),
33
- entry("BRM010", "<script> must be at the top level or at the start of a block", "A `<script>` is inside an element, or after other markup in a block.", "#for (item of items) {\n <script>\n let open = $signal(false);\n <\/script>\n <p>{item}</p>\n}"),
34
- entry("BRM011", "<style> must be at the top level", "A `<style>` is inside an element or a block.", "<style>\n p {\n color: red;\n }\n</style>\n<p>Text</p>"),
35
- entry("BRM012", "#template must be at the top level or at the start of a block", "A `#template` is inside an element, or after other markup in a block.", "#template price(amount: number) {\n <b>{amount}</b>\n}"),
36
- entry("BRM013", "#{branch} must follow its block", "A branch such as `#else` or `#catch` comes without the block that it belongs to.", "#if (open) {\n <p>Open</p>\n} #else {\n <p>Closed</p>\n}"),
37
- entry("BRM014", "Expected a tag name", "A `<` starts a tag with no name.", "<p>1 &lt; 2</p>"),
38
- entry("BRM015", "<{name}> must end with \"/>\"", "`<window>` and `<document>` take no children, so they close with `/>`.", "<window onKeyDown=(handler) />"),
39
- entry("BRM016", "Expected </{name}>", "A closing tag is not complete.", "<p>Text</p>"),
40
- entry("BRM017", "Unexpected end of file, expected \">\"", "A tag starts and the file ends before its `>`.", "<input value=name>"),
41
- entry("BRM018", "Expected whitespace between attributes", "Two attributes touch each other.", "<input id=name type=\"text\">"),
42
- entry("BRM019", "Only event handlers are allowed here", "`<window>` and `<document>` take event handlers and nothing else.", "<document onKeyDown=(handler) />"),
43
- entry("BRM020", "Expected a spread or a shorthand attribute", "A `{` in a tag holds something other than `...rest` or a name.", "<a {href} {...rest}>Open</a>"),
44
- entry("BRM021", "Expected an attribute name", "A tag has a character where an attribute name belongs.", "<input disabled>"),
45
- entry("BRM022", "Event modifiers in the attribute name were removed. Write {fix}", "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.", "import { prevent } from 'brumate/events';\n\n<form onSubmit=(prevent(send))></form>"),
46
- entry("BRM180", "\"{name}\" is not an event name. Write \"{camel}\"", "An event of more than one word is written in camel case. The lower-case form is an error.", "<input onKeyDown=(handle) onFocusOut=(handle) />"),
47
- entry("BRM201", "\"{name}\" cannot be a handler. {fix}", "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.", "<script>\n $client(() => {\n start();\n }, 'load');\n<\/script>"),
48
- entry("BRM186", "\"{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", "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.", "const posts = $memo(loadPosts(id));\n#loading (posts) {\n <p>{posts.length} posts</p>\n} #else {\n <p>Loading</p>\n}"),
49
- entry("BRM182", "The handler reads \"{name}\", a memo that can lack a value. Wait for it with await $resolve({name}), or check $isPending({name}) first", "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.", "<script>\n const user = $memo(getUser(id));\n async function save() {\n await $resolve(user);\n send(user.name);\n }\n<\/script>"),
50
- entry("BRM183", "$resolve needs a $memo and, as an option, a timeout or a signal", "`$resolve` takes the name of a memo, and one object of options at most.", "async function save() {\n const profile = await $resolve(user, { timeout: 5000 });\n}"),
51
- entry("BRM184", "$resolve cannot run where a memo computes or markup renders. Call it in a handler, an effect or a $client callback", "`$resolve` waits, so it is called where an event starts the code, not where a memo computes or markup renders.", "async function save() {\n await $resolve(user);\n}"),
52
- entry("BRM185", "<{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\"", "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.", "<p>Total: <span>{total}</span></p>\n<div>\n <p>Total</p>\n</div>"),
53
- entry("BRM187", "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", "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]`.", "<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>"),
54
- entry("BRM188", "\"{name}\" gives a promise, and {place} cannot wait for one. Await it in the code that runs, or read its value with $memo", "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.", "<button onClick=(() => save(draft))>Save</button>\n#for (user of users by user.id) {\n <p>{user.name}</p>\n}"),
55
- entry("BRM024", "Expected an event handler", "An event attribute has no `=` and no value.", "<button onClick=(() => count++)>Add</button>"),
56
- entry("BRM025", "An event handler must be an expression, not a string", "The value of an event attribute is a quoted string.", "<button onClick=(() => count++)>Add</button>"),
57
- entry("BRM026", "An attribute name can have one \":\" namespace", "An attribute name has two or more `:`.", "<svg xlink:href=\"#icon\"></svg>"),
58
- entry("BRM027", "ref takes $bind, as in ref=$bind(name)", "`ref` has a value that is not `$bind(name)`.", "<input ref=$bind(input)>"),
59
- entry("BRM028", "prefetch is removed. The code of the page loads when it starts", "The `prefetch` attribute no longer exists.", "<a href=\"/about\">About</a>"),
60
- entry("BRM029", "Markup is not allowed in attribute values. Use a #template.", "An attribute value holds an element.", "<List item=row />\n\n#template row(name: string) {\n <b>{name}</b>\n}"),
61
- entry("BRM030", "Expected an attribute value", "An attribute has `=` and nothing after it.", "<input value=name>"),
62
- entry("BRM031", "Wrap this attribute value in parentheses", "An attribute value without quotes has an operator or a space in it.", "<button disabled=(count > 3)>Add</button>"),
63
- entry("BRM032", "Expected \">\" to end <{name}>", "A tag has text where its `>` belongs.", "<input value=name>"),
64
- entry("BRM033", "Expected a quoted value", "A `<script>` or `<style>` attribute has `=` without a quoted value.", "<script generics=\"T\"><\/script>"),
65
- entry("BRM034", "Expected {close}", "A `<script>` or `<style>` is not closed.", "<script>\n let a = 1;\n<\/script>"),
66
- entry("BRM035", "Unknown <script> attribute \"{name}\"", "A `<script>` has an attribute other than `module` and `generics`.", "<script module>\n export const MAX = 10;\n<\/script>"),
67
- entry("BRM036", "A file can have one <script module>", "A file has two module scripts.", "<script module>\n export const MAX = 10;\n export const MIN = 1;\n<\/script>"),
68
- entry("BRM037", "A file can have one <script>", "A file has two instance scripts.", "<script>\n let a = $signal(1);\n let b = $signal(2);\n<\/script>"),
69
- entry("BRM038", "lang must be \"css\", \"scss\" or \"less\"", "A `<style>` names another language.", "<style lang=\"scss\">\n p {\n a {\n color: red;\n }\n }\n</style>"),
70
- entry("BRM189", "Unknown <style> attribute \"{name}\"", "A `<style>` has an attribute other than `lang` and `global`.", "<style scoped>\n p {\n color: red;\n }\n</style>"),
71
- entry("BRM190", "global takes no value, as in <style global>", "A `<style global>` gives `global` a value.", "<style global=\"true\">\n p {\n color: red;\n }\n</style>"),
72
- entry("BRM039", "#reveal takes an order, 'sequential', 'backwards', 'together' or 'natural', and collapsed, such as #reveal ('sequential', collapsed)", "`#reveal` has an option that it does not know.", "#reveal ('sequential', collapsed) {\n …\n}"),
73
- entry("BRM040", "collapsed shows the fallback of the next body to show, so it needs the order 'sequential', not '{order}'", "`collapsed` goes with `sequential` only.", "#reveal ('sequential', collapsed) {\n …\n}"),
74
- entry("BRM041", "#reveal has no script of its own", "A `#reveal` body starts with a `<script>`.", "<script>\n let open = $signal(false);\n<\/script>\n#reveal {\n …\n}"),
75
- entry("BRM042", "Expected \"(\" after #{keyword}", "A block that takes a condition or a list has no `(`.", "#if (open) {\n <p>Open</p>\n}"),
76
- entry("BRM043", "Expected an expression after #{keyword}", "The parentheses of a block are empty.", "#if (open) {\n <p>Open</p>\n}"),
77
- entry("BRM044", "Expected \"{\" after #{keyword}", "The header of a block is not followed by `{`.", "#if (open) {\n <p>Open</p>\n}"),
78
- entry("BRM045", "Expected \"{\" after #switch", "`#switch` has no `{` after it.", "#switch {\n #case (tab === 1) {\n <p>One</p>\n }\n}"),
79
- entry("BRM046", "The script of a block takes no attributes", "A `<script>` at the start of a block has attributes such as `module`.", "#for (item of items) {\n <script>\n let open = $signal(false);\n <\/script>\n <p>{item}</p>\n}"),
80
- entry("BRM047", "#try needs a #catch block", "A `#try` body is not followed by `#catch`.", "#try {\n <p>{load()}</p>\n} #catch (error, reset) {\n <p>Failed</p>\n}"),
81
- entry("BRM048", "Expected \"(error, reset)\" after #catch", "The header of `#catch` names something other than a plain error name and a plain reset name.", "#catch (error, reset) {\n <p>{String(error)}</p>\n}"),
82
- entry("BRM049", "The trigger of #{keyword} must be \"visible\", \"idle\" or \"load\"", "A `#client` block names another trigger.", "#client ('idle') {\n <p>In the browser</p>\n}"),
83
- entry("BRM050", "Unknown block #{keyword}", "A `#` starts a block that does not exist.", "#if (open) {\n <p>Open</p>\n}"),
84
- entry("BRM051", "Expected \"index of count\" after #repeat", "The header of `#repeat` is not `index of count`.", "#repeat (star of 5) {\n <i>{star}</i>\n}"),
85
- entry("BRM052", "Expected \"item of list\" or \"item, index of list\" after #for", "The header of `#for` has no `of`.", "#for (item, index of items by item.id) {\n <li>{item.name}</li>\n}"),
86
- entry("BRM053", "Expected the height of an item in window(height)", "`window` after a `#for` header has no height.", "#for (row of rows by row.id) window(32) {\n <tr><td>{row.name}</td></tr>\n}"),
87
- entry("BRM054", "Only #case and #default are allowed in #switch", "A `#switch` holds markup other than its cases.", "#switch {\n #case (tab === 1) {\n <p>One</p>\n }\n #default {\n <p>Other</p>\n }\n}"),
88
- entry("BRM055", "#default must be the last branch of #switch", "A `#case` comes after the `#default`.", "#switch {\n #case (tab === 1) {\n <p>One</p>\n }\n #default {\n <p>Other</p>\n }\n}"),
89
- entry("BRM056", "Expected \"(\" after the name of the template", "A `#template` has no parameter list.", "#template price(amount: number) {\n <b>{amount}</b>\n}"),
90
- entry("BRM057", "Expected an expression", "An attribute or a block has code that is not an expression.", "<p>{count + 1}</p>"),
91
- entry("BRM058", "Expected a binding pattern", "The name of a `#for` or `#catch` is not a name or a pattern.", "#for ({ id, name } of people by id) {\n <li>{name}</li>\n}"),
92
- entry("BRM059", "Expected parameters", "The parameters of a `#template` are not a parameter list.", "#template price(amount: number) {\n <b>{amount}</b>\n}")
93
- ];
94
- /** Errors about `$signal`, `$memo` and the other compile-time functions. */
95
- const SCRIPT = [
96
- entry("BRM060", "\"{name}\" is already declared", "Two declarations of one scope have the same name.", "let count = $signal(0);\nlet total = $signal(0);"),
97
- entry("BRM061", "{name} takes a handler", "`prevent`, `stop`, `once`, `capture` or `transition` has no handler, or `stop`, `once` or `capture` has keys.", "<form onSubmit=(prevent(send))></form>"),
98
- entry("BRM062", "Only prevent of a keyboard event takes keys, such as onKeyDown", "Keys are given to `prevent` of an event that is not `onKeyDown`, `onKeyUp` or `onKeyPress`.", "<ul onKeyDown=(prevent(move, 'ArrowDown'))></ul>"),
99
- entry("BRM063", "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'", "A key of `prevent` is not a string literal of an `event.key`.", "<ul onKeyDown=(prevent(move, 'ArrowDown', 'Mod+ArrowUp'))></ul>"),
100
- entry("BRM064", "Name each key of prevent as a string, such as 'Enter'", "A key of `prevent` is not a string literal.", "<input onKeyDown=(prevent(submit, 'Enter'))>"),
101
- entry("BRM065", "Server function \"{name}\" must be async", "A function with `'use server'` is not `async`.", "async function save(list: string[]) {\n 'use server';\n await db.save(list);\n}"),
102
- entry("BRM066", "The module script cannot have a default export", "`<script module>` has `export default`.", "<script module>\n export const MAX = 10;\n<\/script>"),
103
- entry("BRM067", "A script cannot export values. Use <script module>", "The instance script has an `export`.", "<script module>\n export const MAX = 10;\n<\/script>"),
104
- entry("BRM068", "$title takes one argument, the title", "`$title` has no argument or more than one.", "$title('Todos');"),
105
- entry("BRM069", "await works with $memo, not {name}", "A declaration awaits a compile-time function other than `$memo`.", "const user = $memo(await load(id));"),
106
- entry("BRM070", "$props() can only be called in the component script", "`$props()` is in a module script or a function.", "const { name } = $props<{ name: string }>();"),
107
- entry("BRM071", "Assign $props() to a const or a let", "The result of `$props()` is not assigned with `const` or `let`.", "const { name } = $props<{ name: string }>();"),
108
- entry("BRM072", "$props() takes no arguments", "`$props()` has an argument.", "const { name } = $props<{ name: string }>();"),
109
- entry("BRM073", "Assign $props() to a name or an object pattern", "`$props()` is assigned to an array pattern.", "const { name } = $props<{ name: string }>();"),
110
- entry("BRM074", "Create an ID with \"const name = $id()\"", "`$id()` is not the value of a `const`.", "const field = $id();"),
111
- entry("BRM075", "$id takes no arguments", "`$id` has an argument.", "const field = $id();"),
112
- entry("BRM076", "$isPassed takes a prop that the component destructures, such as $isPassed(value)", "The argument of `$isPassed` is not a prop of the component.", "let { value } = $props<{ value?: Bindable<string> }>();\nconst passed = $isPassed(value);"),
113
- entry("BRM077", "$navigation takes no arguments", "`$navigation` has an argument.", "const navigation = $navigation();"),
114
- entry("BRM078", "$route takes at most one argument, the path of the route", "`$route` has more than one argument.", "const route = $route('/posts/[id]');"),
115
- entry("BRM079", "Read a context with \"const name = $getContext(Context)\"", "`$getContext` is not the value of a `const`.", "const theme = $getContext(ThemeContext);"),
116
- entry("BRM080", "$getContext takes the context, and a fallback for a read without a provider", "`$getContext` has no argument or more than two.", "const theme = $getContext(ThemeContext);\nconst locale = $getContext(LocaleContext, undefined);"),
117
- entry("BRM081", "$setContext takes two arguments, the context and the value", "`$setContext` has fewer or more than two arguments.", "$setContext(ThemeContext, theme);"),
118
- entry("BRM082", "Declare the result of a form with \"const name = $action(serverFunction)\"", "`$action` is not the value of a `const`.", "const result = $action(save);"),
119
- entry("BRM083", "$action needs a server function of this file as its only argument", "`$action` has no argument, or more than one.", "const result = $action(save);"),
120
- entry("BRM084", "$action needs a server function of this file, and {name} is not one", "The argument of `$action` is not a function with `'use server'` in this file.", "async function save(data: FormData) {\n 'use server';\n}\nconst result = $action(save);"),
121
- entry("BRM085", "Declare {name} with const", "`$debounced` or `$throttled` is declared with `let`.", "const query = $debounced(text, 300);"),
122
- entry("BRM086", "{name} cannot be destructured", "A signal, a memo or another value of a compile-time function is declared with a pattern.", "let count = $signal(0);"),
123
- entry("BRM087", "{name} takes a value and a wait in milliseconds", "`$debounced` or `$throttled` does not have both arguments.", "const query = $debounced(text, 300);"),
124
- entry("BRM088", "The wait of {name} must be a number of milliseconds, such as 300", "The wait of `$debounced` or `$throttled` is not a number literal.", "const query = $debounced(text, 300);"),
125
- entry("BRM089", "Declare {name} with {expected}", "`$signal` and `$optimistic` need `let`, and `$memo` needs `const`.", "let count = $signal(0);\nconst double = $memo(count * 2);"),
126
- entry("BRM090", "{name} takes one argument", "`$signal`, `$memo` or `$optimistic` has more than one argument.", "let count = $signal(0);"),
127
- entry("BRM091", "{name} needs a value", "`$memo` or `$optimistic` has no argument.", "const double = $memo(count * 2);"),
128
- entry("BRM092", "$optimistic needs the name of a value, such as a memo", "The argument of `$optimistic` is not a name.", "let shown = $optimistic(items);"),
129
- entry("BRM093", "{name} does not return a value", "`$effect` or `$client` is assigned to a name.", "$effect(() => {\n document.title = title;\n});"),
130
- entry("BRM094", "{name} needs a function", "`$effect` or `$client` has no function as its callback.", "$effect(() => {\n document.title = title;\n});"),
131
- entry("BRM095", "The callback of {name} takes no parameters", "The callback of `$effect` or `$client` has parameters.", "$effect(() => {\n document.title = title;\n});"),
132
- entry("BRM096", "The callback of {name} cannot be async", "The callback of `$effect` or `$client` is `async`.", "$effect(() => {\n load(id).then((value) => (data = value));\n});"),
133
- entry("BRM097", "$effect takes one argument", "`$effect` has more than one argument.", "$effect(() => {\n document.title = title;\n});"),
134
- entry("BRM098", "The trigger of $client must be \"visible\", \"idle\" or \"load\"", "The second argument of `$client` is another string.", "$client(() => {\n measure();\n}, 'idle');"),
135
- entry("BRM099", "$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", "The first argument of `$handler` is not a function.", "onClick: $handler(prevent(removeAt), index),"),
136
- entry("BRM100", "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})", "A handler reads a local value of the function that calls `$handler`.", "onClick: $handler(removeAt, index),"),
137
- entry("BRM101", "The arguments of $handler cannot be spread", "`$handler` has a spread argument.", "onClick: $handler(removeAt, index, kind),"),
138
- entry("BRM102", "The second argument of $bind is a function that takes the new value: a function expression, or a function of the script", "The setter of `$bind` is not a function.", "<Toggle on=$bind(open, (next) => (open = next)) />"),
139
- entry("BRM103", "The setter reads \"{name}\", a value of the function around $bind, which the browser does not have", "The setter of `$bind` reads a local value that is not a value of the component.", "<Toggle on=$bind(open, (next) => (open = next)) />"),
140
- entry("BRM104", "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", "`$bind` is somewhere else, such as on a `class` or a `<div>`.", "<input value=$bind(draft)>"),
141
- entry("BRM105", "$bind takes the name of a signal, and a function that writes it, such as $bind(open) or $bind(open, (next) => (open = next))", "`$bind` has no argument, or an argument that is not a name.", "<Toggle on=$bind(open) />"),
142
- entry("BRM106", "$bind takes a signal, or a prop that the component destructures with let, and \"{name}\" is not one", "The name in `$bind` is a memo, a const prop or another value.", "let open = $signal(false);\n<Toggle on=$bind(open) />"),
143
- entry("BRM107", "$isBound takes a prop that the component destructures with let, such as $isBound(open)", "The argument of `$isBound` is not a `let` prop.", "let { open } = $props<{ open?: Bindable<boolean> }>();\nconst bound = () => $isBound(open);"),
144
- entry("BRM108", "$isPending needs async $memos as its arguments", "An argument of `$isPending` is not a memo that holds a promise, or the call has none.", "const results = $memo(search(query));\n#if ($isPending(results)) {\n <p>Searching…</p>\n}"),
145
- entry("BRM109", "$produce needs a signal as its first argument", "The first argument of `$produce` is not a signal.", "$produce(todos, (draft) => {\n draft.push(todo);\n});"),
146
- entry("BRM110", "$produce needs a recipe function as its second argument", "The second argument of `$produce` is not a function.", "$produce(todos, (draft) => {\n draft.push(todo);\n});"),
147
- entry("BRM111", "\"{name}\" is reserved. Brumate writes the attributes that start with \"b-\"", "An attribute starts with `b-`.", "<div data-id=id></div>"),
148
- entry("BRM112", "\"{name}\" is not declared", "The name in `ref=$bind(name)` is not a value of the component.", "let input = $signal<HTMLInputElement>();\n<input ref=$bind(input)>"),
149
- entry("BRM113", "ref takes a $signal, or a prop that the component destructures with let, but \"{name}\" is {kind}", "The name in `ref=$bind(name)` is a memo, a const prop or another value.", "let input = $signal<HTMLInputElement>();\n<input ref=$bind(input)>"),
150
- entry("BRM114", "The prop \"{name}\" is not Bindable. Type it as Bindable<HTMLElement>, so a parent can bind it", "A `let` prop is used as a `ref` and its type is not `Bindable`.", "let { ref } = $props<{ ref?: Bindable<HTMLButtonElement> }>();"),
151
- entry("BRM115", "\"{name}\" is the props object, so read one key at a time, destructure it, or spread it in markup", "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 : {})}`.", "const { class: className, ...rest } = $props();\n<button {...rest} class=className>"),
152
- entry("BRM116", "\"{name}\" is the props object, and props are read-only. Copy the key to a $signal or a $memo to change it", "Code assigns to, updates or deletes a key of the props object or of the rest of `$props()`.", "let title = $signal('');\ntitle = 'New';"),
153
- entry("BRM117", "Cannot assign to {kind} \"{name}\"", "Code writes a memo, a const prop or another value that cannot change.", "let count = $signal(0);\ncount = 5;"),
154
- entry("BRM118", "Signal \"{name}\" can only be written in event handlers, effects, $client callbacks and functions", "Setup code, which runs on the server, writes a signal.", "let count = $signal(5);"),
155
- entry("BRM119", "Server function \"{name}\" captures \"{variable}\". Pass it as an argument", "A server function reads a variable of the instance script.", "async function save(user: string) {\n 'use server';\n}"),
156
- entry("BRM120", "$optimistic follows a memo, an action or a prop, not a signal", "The source of `$optimistic` is a signal.", "let shown = $optimistic(items);"),
157
- entry("BRM121", "Declare server functions at the top level of a script", "A function with `'use server'` is inside another function or a block.", "async function save() {\n 'use server';\n}"),
158
- entry("BRM122", "{name} cannot be used here", "A compile-time function is used where it is not allowed.", "let count = $signal(0);"),
159
- entry("BRM123", "Call $setContext at the top level of a script", "`$setContext` is inside a function or a block of code.", "$setContext(ThemeContext, theme);"),
160
- entry("BRM124", "Call $title at the top level of a script", "`$title` is inside a function or a block of code.", "$title('Todos');"),
161
- entry("BRM125", "Create an ID with \"const name = $id()\" at the top level of a script", "`$id` is inside a function or a block of code.", "const field = $id();"),
162
- entry("BRM126", "Check a prop with \"const name = $isPassed(prop)\" at the top level of the component script", "`$isPassed` is inside a function or a block of code.", "const passed = $isPassed(value);"),
163
- entry("BRM127", "Read a context with \"const name = $getContext(Context)\" at the top level of a script", "`$getContext` is inside a function or a block of code.", "const theme = $getContext(ThemeContext);"),
164
- entry("BRM128", "Read the route with \"const name = $route()\" at the top level of a script", "`$route` is inside a function or a block of code.", "const route = $route();"),
165
- entry("BRM129", "Read the navigation with \"const name = $navigation()\" at the top level of a script", "`$navigation` is inside a function or a block of code.", "const navigation = $navigation();"),
166
- entry("BRM130", "Call $props() as the value of a const in the component script", "`$props` is used in another place than `const { … } = $props()`.", "const { name } = $props<{ name: string }>();"),
167
- entry("BRM131", "Declare a signal with \"let name = $signal(value)\" at the top level of a script", "`$signal` is inside a function or a block of code.", "let count = $signal(0);"),
168
- entry("BRM132", "Declare a memo with \"const name = $memo(value)\" at the top level of a script", "`$memo` is inside a function or a block of code.", "const double = $memo(count * 2);"),
169
- entry("BRM202", "$gate takes a value and a function, as in $gate(value, (prev, next) => next > prev)", "`$gate` does not have a value and a guard function as its two arguments. The guard is an arrow function or a function expression.", "const query = $gate(input, (_, next) => next.length >= 2);"),
170
- entry("BRM203", "$gate takes a value that is ready. Use $memo for a promise or a server function", "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.", "const query = $gate(input, (_, next) => next.length >= 2);"),
171
- entry("BRM204", "Declare a gated value with \"const name = $gate(value, (prev, next) => boolean)\" at the top level of a script", "`$gate` is inside a function or a block of code.", "const query = $gate(input, (_, next) => next.length >= 2);"),
172
- entry("BRM133", "Declare a debounced value with \"const name = $debounced(value, ms)\" at the top level of a script", "`$debounced` is inside a function or a block of code.", "const query = $debounced(text, 300);"),
173
- entry("BRM134", "Declare a throttled value with \"const name = $throttled(value, ms)\" at the top level of a script", "`$throttled` is inside a function or a block of code.", "const position = $throttled(pointer, 100);"),
174
- entry("BRM135", "Declare an optimistic value with \"let name = $optimistic(source)\" at the top level of a script", "`$optimistic` is inside a function or a block of code.", "let shown = $optimistic(items);"),
175
- entry("BRM136", "Declare the result of a form with \"const name = $action(serverFunction)\" at the top level of a script", "`$action` is inside a function or a block of code.", "const result = $action(save);"),
176
- entry("BRM137", "Call $effect at the top level of a script", "`$effect` is inside a function or a block of code.", "$effect(() => {\n document.title = title;\n});"),
177
- entry("BRM138", "Call $client at the top level of a script", "`$client` is inside a function or a block of code.", "$client(() => {\n measure();\n}, 'idle');"),
178
- entry("BRM139", "$ref is not supported. Use a $signal with ref=$bind(name)", "`$ref` was removed.", "let input = $signal<HTMLInputElement>();\n<input ref=$bind(input)>"),
179
- entry("BRM140", "$watch is not supported. Use $effect", "`$watch` was removed.", "$effect(() => {\n save(value);\n});"),
180
- entry("BRM141", "$settled is not supported. Use $client", "`$settled` was removed.", "$client(() => {\n measure();\n});"),
181
- entry("BRM142", "$cleanup is not supported. Return a cleanup function from $effect or $client", "`$cleanup` was removed.", "$effect(() => {\n const timer = setInterval(tick, 1000);\n return () => clearInterval(timer);\n});"),
182
- entry("BRM191", "Read a store with \"const name = $store(source)\" or \"let name = $store(source)\" at the top level of a script", "`$store` is not the whole value of a `const` or `let` at the top level of a script.", "import { theme } from './theme';\nconst value = $store(theme);"),
183
- entry("BRM192", "$store takes one argument, a store", "`$store` has no argument, or more than one.", "const field = $getContext(Field);\nconst state = $store(field.state);"),
184
- entry("BRM193", "$toStore takes one argument, a memo, a signal or a prop, as a value of $setContext", "`$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.", "$setContext(Field, { state: $toStore(state), pick });"),
185
- entry("BRM195", "$store gives one name, not a pattern such as { a }", "`$store` initializes a pattern.", "const value = $store(source);"),
186
- entry("BRM196", "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", "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.", "$setContext(Field, { state: $toStore(state), pick: () => value });"),
187
- entry("BRM197", "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", "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.", "const field = $getContext(Field, undefined);\nconst state = field ? $store(field.state) : undefined;"),
188
- entry("BRM198", "The source of $store gives its store at once, so it cannot await or call a server function", "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.", "import { theme } from './theme';\nconst value = $store(theme);"),
189
- entry("BRM199", "$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)))\"", "`$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`.", "const level = $store($getContext(LevelContext));\nconst locale = $store($getContext(LocaleContext, store('en-US')));"),
190
- entry("BRM200", "The value of bridge() must be a module-level export of a script file or of <script module>, as \"export const name = bridge({ … })\"", "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.", "// bears.ts, or the <script module> of a component\nimport { bridge } from 'brumate/store';\nexport const bearStore = bridge({ create, get, subscribe });"),
191
- entry("BRM144", "$get is not supported. Signals cannot leave the file", "`$get` was removed. A signal never leaves its file.", "// Pass the value, or a function that writes it.\nonChange=((next) => (count = next))"),
192
- entry("BRM145", "$set is not supported. Signals cannot leave the file", "`$set` was removed. A signal never leaves its file.", "// Pass the value, or a function that writes it.\nonChange=((next) => (count = next))"),
193
- entry("BRM146", "{name} was renamed to {renamed}. Import {renamed} from '{module}'", "The file imports a name that the compiler knew before it was renamed.", "import { $signal } from 'brumate/signals';"),
194
- entry("BRM147", "Import {name} from '{module}'", "The file calls a compile-time function that it does not import.", "import { $signal } from 'brumate/signals';")
195
- ];
196
- /** Errors about the code that the browser gets, and the markup that the browser renders. */
197
- const OUTPUT = [
198
- entry("BRM148", "\"{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", "A value that cannot be sent to the browser, such as a database client, is read by code that runs there.", "async function list() {\n 'use server';\n return db.all();\n}"),
199
- entry("BRM149", "{what} is read by code that runs in the browser ({site}). Read it in a server function", "Code that runs in the browser reads an environment variable of the server.", "async function key() {\n 'use server';\n return env.API_KEY;\n}"),
200
- entry("BRM150", "\"{name}\" holds {what} and code that runs in the browser reads it. Keep server variables out of values that the browser reads", "A value holds an environment variable of the server, and the browser reads the value.", "async function key() {\n 'use server';\n return env.API_KEY;\n}"),
201
- entry("BRM151", "#defer cannot be inside a #client body", "A `#defer` is in markup that only the browser renders.", "#defer {\n <Comments />\n}"),
202
- entry("BRM152", "#defer cannot be in markup that the browser renders", "A `#defer` is in a body that the browser adds later, such as the body of a changing `#if`.", "#defer {\n <Comments />\n}"),
203
- entry("BRM153", "A value that changes in <{tag}> must be its whole content, such as <{tag}>{`Count ${count}`}</{tag}>", "A `<title>`, `<textarea>`, `<style>` or `<script>` holds a changing value next to other content.", "<textarea>{`Count ${count}`}</textarea>"),
204
- entry("BRM154", "Put <title> in #head, as <meta> and <link>, such as #head { <title>{`${count} left`}</title> }", "A `<title>` is outside `#head`.", "#head {\n <title>{`${count} left`}</title>\n}"),
205
- entry("BRM155", "A dynamic tag that changes on the client is not supported yet", "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.", "<{tag} class=\"title\">Title</>"),
206
- entry("BRM156", "Code that the browser updates can await only a memo. Load the promise in a memo instead", "Code that runs again in the browser awaits something other than a memo.", "const user = $memo(await load(id));"),
207
- entry("BRM157", "Markup that the browser renders can await only a memo. Load the promise in a memo instead", "Markup that the browser renders awaits something other than a memo.", "const user = $memo(await load(id));"),
208
- entry("BRM158", "This attribute cannot change on the client yet", "The name or the value of an attribute with a computed name, as in `[name]=value`, changes in the browser.", "<div class=(open ? \"open\" : \"closed\")></div>"),
209
- entry("BRM159", "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", "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.", "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>"),
210
- entry("BRM160", "Destructuring assignment to a signal is not supported in client code yet", "Code that runs in the browser writes a signal in a destructuring assignment.", "[first, second] = pair;\n// Write each signal on its own:\nfirst = pair[0];\nsecond = pair[1];"),
211
- entry("BRM161", "Assign to \"{name}\" with = instead of {op}", "An optimistic value is changed with `++` or `--`.", "shown = shown + 1;"),
212
- entry("BRM162", "Invalid CSS: {message}", "A `<style>` has CSS that does not parse.", "<style>\n p {\n color: red;\n }\n</style>"),
213
- entry("BRM163", "Module functions call each other too deeply. A module function cannot call itself", "A function of a module of reactive logic calls itself, or a loop of functions call each other.", "function counter(start: number) {\n let count = $signal(start);\n return { count };\n}")
214
- ];
215
- /** Errors about modules of reactive logic, such as `counter.brm.ts`. */
216
- const MODULES = [
217
- entry("BRM164", "Destructure what {name} returns, as in const { value } = {name}(…)", "The result of a module function is kept as one object.", "const { count, increment } = counter(0);"),
218
- entry("BRM165", "Declare what {name} returns with const", "The result of a module function is declared with `let`.", "const { count, increment } = counter(0);"),
219
- entry("BRM166", "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", "A module function is called inside a function, a condition or a loop.", "const { count, increment } = counter(0);"),
220
- entry("BRM167", "Cannot read {specifier}", "The module that the component imports is not on disk.", "import { counter } from './counter.brm.ts';"),
221
- entry("BRM168", "{specifier} does not export a function named {name}", "The import names a function that the module does not export.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
222
- entry("BRM169", "{name} needs a body that ends with return { … }", "A module function is an arrow function with an expression body.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
223
- entry("BRM170", "{name} must end with return { … }, an object of what it gives", "A module function does not end with `return { … }`.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
224
- entry("BRM171", "{name} can return only at its end", "A module function returns in the middle of its body.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
225
- entry("BRM172", "Destructure {name} with plain names, as in const { value, other: renamed } = {name}(…)", "The result of a module function is destructured with a default, a nested pattern or a rest.", "const { count, increment: add } = counter(0);"),
226
- entry("BRM173", "{name} must return an object with plain keys", "The returned object has a computed key, a spread or a method.", "return { count, increment };"),
227
- entry("BRM174", "{name} cannot return getters or setters. Return the values themselves", "The returned object has a getter or a setter.", "return { count, increment };"),
228
- entry("BRM175", "{name} does not return {key}", "The component destructures a name that the module function does not return.", "const { count } = counter(0);"),
229
- entry("BRM176", "{name} returns {local} as {first} and as {key}. Return each local once, and give the other key a function of its own", "A module function returns one local under two keys.", "return { count, increment };"),
230
- entry("BRM177", "{name} is declared twice", "A name of the module function is also a name of the component.", "const { count: first } = counter(0);\nconst { count: second } = counter(10);"),
231
- entry("BRM178", "Parameters of {name} must be plain names", "A module function has a destructured or default parameter.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
232
- entry("BRM179", "{name} reads {local}, which {specifier} does not export. Export it, so the component can import it", "A module function reads a value of its module that is not exported.", "export const STEP = 1;")
233
- ];
234
- const ERRORS = [
235
- ...SYNTAX,
236
- ...SCRIPT,
237
- ...OUTPUT,
238
- ...MODULES
239
- ];
240
- /** True when a message that the compiler reported has the form of an entry. */
241
- function matchesError(error, message) {
242
- const escaped = [];
243
- for (const part of error.message.split(/\{\w+\}/)) escaped.push(part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
244
- const pattern = escaped.join("[\\s\\S]*?");
245
- return new RegExp(`^${pattern}$`).test(message);
246
- }
247
- /**
248
- * The entry for a message that the compiler reported. The place of the
249
- * error, as in `(File.brm:3:7)`, can follow the message.
250
- */
251
- function findError(message) {
252
- const bare = message.replace(/(?:\s\([^()]*:\d+:\d+\))+$/, "").replace(/\s\[BRM\d+\]$/, "");
253
- function fixed(error) {
254
- return error.message.replace(/\{\w+\}/g, "").length;
255
- }
256
- let found;
257
- for (const error of ERRORS) if (matchesError(error, bare) && (!found || fixed(error) > fixed(found))) found = error;
258
- return found;
259
- }
260
- //#endregion
261
8
  //#region src/error.ts
262
9
  function getLocation(source, offset) {
263
10
  let line = 1;
@@ -1896,6 +1643,7 @@ var Analyzer = class {
1896
1643
  visitBodyContent(body, scope) {
1897
1644
  if (body.script) this.declareScript(body.script.program, scope, false);
1898
1645
  for (const template of body.templates) this.declareTemplate(template, scope);
1646
+ for (const style of body.styles) for (const variable of style.variables) this.createExpressionSite("style", scope, variable, "style");
1899
1647
  this.visitNodes(body.children, scope);
1900
1648
  }
1901
1649
  visitNodes(nodes, scope) {
@@ -2681,6 +2429,82 @@ function forEachNode(nodes, visit) {
2681
2429
  forEachNode(getChildren(node), visit);
2682
2430
  }
2683
2431
  }
2432
+ /** Returns the bodies of a block, in source order. */
2433
+ function blockBodies(block) {
2434
+ switch (block.kind) {
2435
+ case "if": {
2436
+ const bodies = [];
2437
+ for (const branch of block.branches) bodies.push(branch.body);
2438
+ if (block.fallback) bodies.push(block.fallback);
2439
+ return bodies;
2440
+ }
2441
+ case "switch": {
2442
+ const bodies = [];
2443
+ for (const branch of block.cases) bodies.push(branch.body);
2444
+ if (block.fallback) bodies.push(block.fallback);
2445
+ return bodies;
2446
+ }
2447
+ case "for":
2448
+ case "repeat":
2449
+ case "loading":
2450
+ case "client":
2451
+ case "defer": return [block.body, ...block.fallback ? [block.fallback] : []];
2452
+ case "try": return [block.body, block.fallback];
2453
+ default: return [block.body];
2454
+ }
2455
+ }
2456
+ /** The place of every body of a file: the bodies of blocks and of templates. */
2457
+ function bodyTree(file) {
2458
+ const tree = /* @__PURE__ */ new Map();
2459
+ function visitBody(body, parent, top, template = false) {
2460
+ tree.set(body, {
2461
+ parent,
2462
+ top,
2463
+ template
2464
+ });
2465
+ for (const declared of body.templates) visitBody(declared.body, body, false, true);
2466
+ visitNodes(body.children, body, true);
2467
+ }
2468
+ function visitNodes(nodes, parent, top) {
2469
+ for (const node of nodes) switch (node.kind) {
2470
+ case "element":
2471
+ visitNodes(node.children, parent, false);
2472
+ break;
2473
+ case "component":
2474
+ case "dynamic":
2475
+ case "fragment":
2476
+ visitNodes(node.children, parent, top);
2477
+ break;
2478
+ case "text":
2479
+ case "insert":
2480
+ case "listener": break;
2481
+ default: for (const body of blockBodies(node)) visitBody(body, parent, top);
2482
+ }
2483
+ }
2484
+ for (const template of file.templates) visitBody(template.body, void 0, false, true);
2485
+ visitNodes(file.children, void 0, true);
2486
+ return tree;
2487
+ }
2488
+ const fileBodies = /* @__PURE__ */ new WeakMap();
2489
+ /**
2490
+ * The body of the file itself, the outermost block: its script, `<style>` elements, templates
2491
+ * and markup. It is not in `bodyTree`, where a body without a parent sits directly in it.
2492
+ */
2493
+ function fileBody(file) {
2494
+ let body = fileBodies.get(file);
2495
+ if (!body) {
2496
+ body = {
2497
+ start: 0,
2498
+ end: file.source.length,
2499
+ script: file.instanceScript,
2500
+ styles: file.styles,
2501
+ templates: file.templates,
2502
+ children: file.children
2503
+ };
2504
+ fileBodies.set(file, body);
2505
+ }
2506
+ return body;
2507
+ }
2684
2508
  //#endregion
2685
2509
  //#region src/graph.ts
2686
2510
  /** Memos that a server function refreshes are live, so they have client code. */
@@ -3444,6 +3268,7 @@ var Parser = class {
3444
3268
  filename,
3445
3269
  source,
3446
3270
  styles: [],
3271
+ blockStyles: [],
3447
3272
  templates: [],
3448
3273
  children: []
3449
3274
  };
@@ -3520,7 +3345,7 @@ var Parser = class {
3520
3345
  if (after === "(" || after === "{") return keyword;
3521
3346
  if (keyword === "else" && this.source.startsWith("if", next)) return keyword;
3522
3347
  }
3523
- parseNodes(mode, templates) {
3348
+ parseNodes(mode, templates, styles) {
3524
3349
  const nodes = [];
3525
3350
  for (;;) {
3526
3351
  if (this.pos >= this.source.length) {
@@ -3542,8 +3367,12 @@ var Parser = class {
3542
3367
  continue;
3543
3368
  }
3544
3369
  if (this.isTagStart("style")) {
3545
- if (mode !== "file") this.fail("<style> must be at the top level", this.pos);
3546
- this.file.styles.push(this.parseStyle());
3370
+ if (mode === "element") this.fail("<style> must be at the top level of the file or of a block", this.pos);
3371
+ const style = this.parseStyle();
3372
+ if (styles) {
3373
+ styles.push(style);
3374
+ this.file.blockStyles.push(style);
3375
+ } else this.file.styles.push(style);
3547
3376
  continue;
3548
3377
  }
3549
3378
  if (this.peek() === "<") {
@@ -3636,6 +3465,7 @@ var Parser = class {
3636
3465
  body: {
3637
3466
  start,
3638
3467
  end: this.pos,
3468
+ styles: [],
3639
3469
  templates: [],
3640
3470
  children: [node]
3641
3471
  }
@@ -4002,6 +3832,7 @@ var Parser = class {
4002
3832
  if (reveal.collapsed && reveal.order !== "sequential") this.fail(`collapsed shows the fallback of the next body to show, so it needs the order 'sequential', not '${reveal.order}'`, header.start);
4003
3833
  const body = this.parseBody("reveal");
4004
3834
  if (body.script) this.fail("#reveal has no script of its own", body.script.start);
3835
+ if (body.styles.length > 0) this.fail("#reveal has no style of its own", body.styles[0].start);
4005
3836
  return {
4006
3837
  kind: "fragment",
4007
3838
  start,
@@ -4034,12 +3865,14 @@ var Parser = class {
4034
3865
  script = parsed.script;
4035
3866
  }
4036
3867
  const templates = [];
4037
- const children = this.parseNodes("body", templates);
3868
+ const styles = [];
3869
+ const children = this.parseNodes("body", templates, styles);
4038
3870
  this.pos++;
4039
3871
  return {
4040
3872
  start,
4041
3873
  end: this.pos,
4042
3874
  script,
3875
+ styles,
4043
3876
  templates,
4044
3877
  children
4045
3878
  };
@@ -5934,15 +5767,247 @@ function keyName(property) {
5934
5767
  if (property.key.type === "Identifier") return property.key.name;
5935
5768
  return property.key.type === "Literal" ? String(property.key.value) : void 0;
5936
5769
  }
5770
+ /** The node types that a walk through code that always runs enters. */
5771
+ const ALWAYS_RUNS = /* @__PURE__ */ new Set([
5772
+ "ExpressionStatement",
5773
+ "VariableDeclaration",
5774
+ "VariableDeclarator",
5775
+ "AssignmentExpression",
5776
+ "MemberExpression",
5777
+ "CallExpression",
5778
+ "NewExpression",
5779
+ "BinaryExpression",
5780
+ "UnaryExpression",
5781
+ "TemplateLiteral",
5782
+ "TaggedTemplateExpression",
5783
+ "ObjectExpression",
5784
+ "Property",
5785
+ "ArrayExpression",
5786
+ "SpreadElement",
5787
+ "ParenthesizedExpression",
5788
+ "SequenceExpression",
5789
+ "TSAsExpression",
5790
+ "TSSatisfiesExpression",
5791
+ "TSNonNullExpression"
5792
+ ]);
5793
+ /**
5794
+ * Adds the start of each name that the code reads whenever it runs. A function, an optional
5795
+ * chain, the branch of a condition and the right side of `&&`, `||` and `??` may not run.
5796
+ */
5797
+ function addAlwaysRead(node, into) {
5798
+ if (node.type === "Identifier") {
5799
+ into.add(node.start);
5800
+ return;
5801
+ }
5802
+ if (node.type === "ConditionalExpression") {
5803
+ addAlwaysRead(node.test, into);
5804
+ return;
5805
+ }
5806
+ if (node.type === "LogicalExpression") {
5807
+ addAlwaysRead(node.left, into);
5808
+ return;
5809
+ }
5810
+ if (node.type === "CallExpression" && (calleeName(node) === "$isPending" || calleeName(node) === "$isBound")) return;
5811
+ if (!ALWAYS_RUNS.has(node.type)) return;
5812
+ for (const [, child] of children(node)) addAlwaysRead(child, into);
5813
+ }
5937
5814
  /**
5938
- * True for a memo expression that the browser render computes in place: it gives no promise, and
5939
- * it cannot throw, so it has no error to hold. A name that reads a memo may throw, as the memo
5940
- * may hold an error.
5815
+ * The expressions of markup that run when the body around them renders: text, and the values of
5816
+ * attributes and props. The children of a component and the bodies of blocks render apart.
5941
5817
  */
5942
- function isPlainMemo(site, node) {
5943
- const memoReads = /* @__PURE__ */ new Set();
5944
- for (const read of site.reads) if (read.declaration.kind === "memo" || read.declaration.kind === "async-memo") memoReads.add(read.range.start);
5945
- return !site.awaits && neverPromise(node) && cannotThrow(node, (name) => !memoReads.has(name.start));
5818
+ function addAlwaysMarkup(nodes, into) {
5819
+ for (const node of nodes) if (node.kind === "insert") into.add(node.expression.ast);
5820
+ else if (node.kind === "element" || node.kind === "dynamic" || node.kind === "component") {
5821
+ for (const attribute of node.attributes) if (attribute.kind === "value") into.add(attribute.value.ast);
5822
+ if (node.kind !== "component") addAlwaysMarkup(node.children, into);
5823
+ } else if (node.kind === "fragment") addAlwaysMarkup(node.children, into);
5824
+ }
5825
+ /** The site kinds whose code does not run when a render runs. */
5826
+ const NOT_RUN = /* @__PURE__ */ new Set([
5827
+ "function",
5828
+ "server-function",
5829
+ "effect",
5830
+ "client",
5831
+ "event"
5832
+ ]);
5833
+ /** The site kinds of markup, which run after the script of their scope. */
5834
+ const MARKUP_SITES$2 = /* @__PURE__ */ new Set([
5835
+ "insert",
5836
+ "attribute",
5837
+ "prop",
5838
+ "spread",
5839
+ "tag",
5840
+ "block",
5841
+ "title",
5842
+ "style"
5843
+ ]);
5844
+ /** The first step of evaluating `node` up to the name at `target` that can throw, if any. */
5845
+ function throwsBefore(node, target, safe) {
5846
+ if (target < node.start || target >= node.end) return;
5847
+ if (node.type === "Identifier") return false;
5848
+ const parts = [];
5849
+ for (const [, child] of children(node)) {
5850
+ if (node.type === "VariableDeclarator" && child === node.id) continue;
5851
+ parts.push(child);
5852
+ }
5853
+ parts.sort((a, b) => a.start - b.start);
5854
+ for (const part of parts) {
5855
+ const found = throwsBefore(part, target, safe);
5856
+ if (found !== void 0) return found;
5857
+ if (part.end <= target && !cannotThrow(part, safe)) return true;
5858
+ }
5859
+ }
5860
+ /** True when the markup holds a component or a dynamic tag, at any depth. */
5861
+ function hasChildren(value) {
5862
+ if (Array.isArray(value)) {
5863
+ for (const item of value) if (hasChildren(item)) return true;
5864
+ return false;
5865
+ }
5866
+ if (value === null || typeof value !== "object") return false;
5867
+ const node = value;
5868
+ if (node.kind === "component" || node.kind === "dynamic") return true;
5869
+ for (const [key, child] of Object.entries(value)) if (key !== "ast" && key !== "script" && key !== "styles" && hasChildren(child)) return true;
5870
+ return false;
5871
+ }
5872
+ /**
5873
+ * The memos that the browser render runs through `renderMemo`, so each holds its error until a
5874
+ * read throws it. The others add to `settled`, since they hold none:
5875
+ * - a memo that cannot throw, such as `{ show: wanted }`, if it reads no memo that holds an error;
5876
+ * - a memo that the render always reads, in code that always runs. It throws at its declaration,
5877
+ * which is the throw of the read to the nearest `#try`, so no read needs a check. A memo of
5878
+ * another memo that always runs counts too. The error must also be the first one: nothing that
5879
+ * can throw runs between the declaration and the first read.
5880
+ * A memo with `await` is a promise at once, and a promise holds its error.
5881
+ */
5882
+ function heldMemos(file, sites, inline, settled) {
5883
+ const candidates = /* @__PURE__ */ new Set();
5884
+ for (const site of sites) if (site.kind === "memo" && site.declaration && !inline.has(site.declaration)) {
5885
+ const node = site.node;
5886
+ const memoReads = /* @__PURE__ */ new Set();
5887
+ for (const read of site.reads) if (read.declaration.kind === "memo" || read.declaration.kind === "async-memo") memoReads.add(read.range.start);
5888
+ if (!site.awaits && (!neverPromise(node) || !cannotThrow(node, (name) => !memoReads.has(name.start)))) candidates.add(site.declaration);
5889
+ }
5890
+ const candidateReads = /* @__PURE__ */ new Set();
5891
+ for (const memo of candidates) for (const read of memo.reads) candidateReads.add(read.range.start);
5892
+ const markup = /* @__PURE__ */ new Set();
5893
+ addAlwaysMarkup(file.children, markup);
5894
+ const bodies = /* @__PURE__ */ new Set();
5895
+ for (const site of sites) {
5896
+ const body = site.scope.body;
5897
+ if (site.scope.kind === "body" && body && !bodies.has(body)) {
5898
+ bodies.add(body);
5899
+ addAlwaysMarkup(body.children, markup);
5900
+ }
5901
+ }
5902
+ const reached = /* @__PURE__ */ new Map();
5903
+ function alwaysReads(site) {
5904
+ let starts = reached.get(site);
5905
+ if (!starts) {
5906
+ starts = /* @__PURE__ */ new Set();
5907
+ if ((site.scope.kind === "component" || site.scope.kind === "body") && (site.kind === "memo" || site.kind === "provide" || site.kind === "setup" && (site.label === "setup" || site.label.startsWith("signal ")) || (site.kind === "insert" || site.kind === "attribute" || site.kind === "prop") && markup.has(site.node))) addAlwaysRead(site.node, starts);
5908
+ reached.set(site, starts);
5909
+ }
5910
+ return starts;
5911
+ }
5912
+ const blocked = /* @__PURE__ */ new Set();
5913
+ let held = /* @__PURE__ */ new Set();
5914
+ let thrown = /* @__PURE__ */ new Map();
5915
+ for (;;) {
5916
+ held = new Set(candidates);
5917
+ thrown = /* @__PURE__ */ new Map();
5918
+ settled.clear();
5919
+ settle();
5920
+ let again = false;
5921
+ for (const [memo, read] of thrown) if (!inOrder(memo, read)) {
5922
+ blocked.add(memo);
5923
+ again = true;
5924
+ }
5925
+ if (!again) return held;
5926
+ }
5927
+ function runsAtOnce(site) {
5928
+ const owner = site.declaration;
5929
+ return !!owner && !held.has(owner) && !site.awaits;
5930
+ }
5931
+ function alwaysRead(memo) {
5932
+ const result = [];
5933
+ for (const read of memo.reads) {
5934
+ const site = read.site;
5935
+ if (site.scope === memo.scope && alwaysReads(site).has(read.range.start) && (site.kind !== "memo" || runsAtOnce(site))) result.push(read);
5936
+ }
5937
+ return result;
5938
+ }
5939
+ function settle() {
5940
+ let changed = true;
5941
+ while (changed) {
5942
+ changed = false;
5943
+ for (const site of sites) {
5944
+ const memo = site.declaration;
5945
+ if (site.kind !== "memo" || !memo || !held.has(memo)) continue;
5946
+ let settles = false;
5947
+ if (!memo.gate && cannotThrow(site.node)) {
5948
+ settles = true;
5949
+ for (const read of site.reads) if (held.has(read.declaration)) settles = false;
5950
+ }
5951
+ if (!settles && !blocked.has(memo)) {
5952
+ const reads = alwaysRead(memo);
5953
+ if (reads.length > 0) {
5954
+ settles = true;
5955
+ thrown.set(memo, reads.toSorted(compareReads)[0]);
5956
+ }
5957
+ }
5958
+ if (settles) {
5959
+ held.delete(memo);
5960
+ settled.add(memo);
5961
+ changed = true;
5962
+ }
5963
+ }
5964
+ }
5965
+ }
5966
+ function phase(site) {
5967
+ return MARKUP_SITES$2.has(site.kind) ? 1 : 0;
5968
+ }
5969
+ function compareReads(a, b) {
5970
+ return phase(a.site) - phase(b.site) || a.range.start - b.range.start;
5971
+ }
5972
+ function mayThrow(site, own) {
5973
+ const owner = site.kind === "memo" ? site.declaration : void 0;
5974
+ if (owner) {
5975
+ if (site.awaits || held.has(owner) && !thrown.has(owner)) return false;
5976
+ if (thrown.has(owner)) return true;
5977
+ }
5978
+ const ownReads = /* @__PURE__ */ new Set();
5979
+ let firstOwn = Infinity;
5980
+ for (const read of own.reads) {
5981
+ ownReads.add(read.range.start);
5982
+ if (read.site === site && alwaysReads(site).has(read.range.start)) firstOwn = Math.min(firstOwn, read.range.start);
5983
+ }
5984
+ const safe = (name) => ownReads.has(name.start) || !candidateReads.has(name.start);
5985
+ if (firstOwn < Infinity && throwsBefore(site.node, firstOwn, safe) === false) return false;
5986
+ return !cannotThrow(site.node, safe);
5987
+ }
5988
+ function isInside(scope, outer) {
5989
+ for (let at = scope?.parent; at; at = at.parent) if (at === outer) return true;
5990
+ return false;
5991
+ }
5992
+ function inOrder(memo, read) {
5993
+ const declared = memo.site;
5994
+ if (!declared) return false;
5995
+ const own = /* @__PURE__ */ new Set();
5996
+ for (const other of memo.reads) own.add(other.range.start);
5997
+ if (throwsBefore(read.site.node, read.range.start, (name) => own.has(name.start) || !candidateReads.has(name.start))) return false;
5998
+ const atMarkup = phase(read.site) === 1;
5999
+ if (atMarkup && hasChildren(memo.scope.kind === "body" ? memo.scope.body?.children : file.children)) return false;
6000
+ for (const site of sites) {
6001
+ if (site === declared || site === read.site || NOT_RUN.has(site.kind)) continue;
6002
+ let between = false;
6003
+ if (site.scope === memo.scope) {
6004
+ if (phase(site) === 0) between = site.node.start > declared.node.start && (atMarkup || site.node.start < read.range.start);
6005
+ else between = atMarkup;
6006
+ } else if (atMarkup && isInside(site.scope, memo.scope)) between = true;
6007
+ if (between && mayThrow(site, memo)) return false;
6008
+ }
6009
+ return true;
6010
+ }
5946
6011
  }
5947
6012
  function addValueEdits(patch, file, sites, mode = "server", inline = /* @__PURE__ */ new Set(), lazy = /* @__PURE__ */ new Set(), component) {
5948
6013
  const sitesByNode = /* @__PURE__ */ new Map();
@@ -6004,11 +6069,10 @@ function addValueEdits(patch, file, sites, mode = "server", inline = /* @__PURE_
6004
6069
  replacedAt.add(range.start);
6005
6070
  }
6006
6071
  }
6072
+ const settled = /* @__PURE__ */ new Set();
6073
+ let held = /* @__PURE__ */ new Set();
6007
6074
  if (mode === "render") {
6008
- const held = /* @__PURE__ */ new Set();
6009
- for (const site of sites) if (site.kind === "memo" && site.declaration && !inline.has(site.declaration)) {
6010
- if (!isPlainMemo(site, site.node)) held.add(site.declaration);
6011
- }
6075
+ held = heldMemos(file, sites, inline, settled);
6012
6076
  for (const site of sites) readMemos(site, site.node, site.declaration, held);
6013
6077
  }
6014
6078
  if (mode === "server") {
@@ -6090,11 +6154,14 @@ function addValueEdits(patch, file, sites, mode = "server", inline = /* @__PURE_
6090
6154
  patch.replace(node.start, argument.start, open);
6091
6155
  patch.replace(argument.end, node.end, `), $$ctx, ${JSON.stringify(declaration.name)})`);
6092
6156
  } else if (mode === "render" && declaration?.gate) {
6093
- patch.replace(node.start, argument.start, "$$b.renderMemo(() => $$b.gateValue(");
6094
- patch.replace(argument.end, node.end, "))");
6095
- } else if (mode === "render" && declaration && !isPlainMemo(site, argument)) {
6096
- patch.replace(node.start, argument.start, site.awaits ? "$$b.renderMemo(async () => (" : "$$b.renderMemo(() => (");
6097
- patch.replace(argument.end, node.end, "))");
6157
+ const open = settled.has(declaration) ? "$$b.gateValue(" : "$$b.renderMemo(() => $$b.gateValue(";
6158
+ patch.replace(node.start, argument.start, open);
6159
+ patch.replace(argument.end, node.end, settled.has(declaration) ? ")" : "))");
6160
+ } else if (mode === "render" && declaration && (site.awaits || !neverPromise(argument) || held.has(declaration))) {
6161
+ let open = site.awaits ? "$$b.renderMemo(async () => (" : "$$b.renderMemo(() => (";
6162
+ if (settled.has(declaration)) open = "$$b.memoNow(";
6163
+ patch.replace(node.start, argument.start, open);
6164
+ patch.replace(argument.end, node.end, settled.has(declaration) ? ")" : "))");
6098
6165
  } else if (site?.awaits) {
6099
6166
  patch.replace(node.start, argument.start, "(async () => (");
6100
6167
  patch.replace(argument.end, node.end, "))()");
@@ -6727,60 +6794,159 @@ function preprocess(lang, source, file, dependencies) {
6727
6794
  if (css === void 0) throw new Error("Less did not finish. Imports that load over the network are not supported");
6728
6795
  return css;
6729
6796
  }
6730
- /** Compiles the `<style>` blocks of a file into scoped CSS. */
6797
+ /**
6798
+ * Compiles one `<style>` into scoped CSS, and adds its interpolations to `state.variables`.
6799
+ * `name` makes the name of a custom property from its index. Returns undefined after an error.
6800
+ */
6801
+ function compileStyle(file, style, attribute, name, state) {
6802
+ const { variables } = state;
6803
+ const contentStart = file.source.indexOf(style.content, style.start);
6804
+ let content = "";
6805
+ let position = 0;
6806
+ for (const expression of style.variables) {
6807
+ const variable = name(variables.length);
6808
+ let start = expression.start - 2 - contentStart;
6809
+ let end = expression.end + 1 - contentStart;
6810
+ const prefixStart = start;
6811
+ while (start > position && /[#\w.%-]/.test(style.content[start - 1])) start--;
6812
+ const prefix = style.content.slice(start, prefixStart);
6813
+ const suffixStart = end;
6814
+ while (end < style.content.length && /[\w.%-]/.test(style.content[end])) end++;
6815
+ const suffix = style.content.slice(suffixStart, end);
6816
+ variables.push({
6817
+ name: variable,
6818
+ expression,
6819
+ prefix,
6820
+ suffix
6821
+ });
6822
+ content += `${style.content.slice(position, start)}var(${variable})`;
6823
+ position = end;
6824
+ }
6825
+ content += style.content.slice(position);
6826
+ try {
6827
+ const root = parse(style.lang === "css" ? content : preprocess(style.lang, content, state.filePath, state.dependencies));
6828
+ scopeRules(root, attribute, state.targets, style.global);
6829
+ return root.toString().trim();
6830
+ } catch (error) {
6831
+ state.diagnostics.push({
6832
+ severity: "error",
6833
+ message: style.lang === "css" ? `Invalid CSS: ${error.message}` : error.message,
6834
+ range: {
6835
+ start: style.start,
6836
+ end: style.end
6837
+ }
6838
+ });
6839
+ return;
6840
+ }
6841
+ }
6842
+ /**
6843
+ * What each body takes from the styles around it. See `BodyStyles`. A body that no style reaches
6844
+ * is left out. The file's own style reaches every body and the file's body. Its variables go on
6845
+ * the top-level elements of the bodies that sit at the top level of the file, and of a template,
6846
+ * which renders anywhere.
6847
+ */
6848
+ function bodyStyles(file, blocks) {
6849
+ const result = /* @__PURE__ */ new Map();
6850
+ if (blocks.length === 0) return result;
6851
+ const root = fileBody(file);
6852
+ const byBody = /* @__PURE__ */ new Map();
6853
+ for (const block of blocks) byBody.set(block.body, block);
6854
+ const tree = bodyTree(file);
6855
+ const outermost = byBody.get(root);
6856
+ if (outermost) result.set(root, {
6857
+ attributes: [outermost],
6858
+ variables: outermost.variables.length > 0 ? [outermost] : []
6859
+ });
6860
+ for (const body of tree.keys()) {
6861
+ const attributes = [];
6862
+ const variables = [];
6863
+ let atTop = true;
6864
+ let atRoot = true;
6865
+ let current = body;
6866
+ while (current) {
6867
+ const block = byBody.get(current);
6868
+ if (block) {
6869
+ attributes.unshift(block);
6870
+ if (atTop && block.variables.length > 0) variables.unshift(block);
6871
+ }
6872
+ const info = tree.get(current);
6873
+ atTop = atTop && info.top;
6874
+ atRoot = atRoot && (info.top || info.template);
6875
+ current = info.parent;
6876
+ }
6877
+ if (outermost) {
6878
+ attributes.unshift(outermost);
6879
+ if (atRoot && outermost.variables.length > 0) variables.unshift(outermost);
6880
+ }
6881
+ if (attributes.length > 0) result.set(body, {
6882
+ attributes,
6883
+ variables
6884
+ });
6885
+ }
6886
+ return result;
6887
+ }
6888
+ /**
6889
+ * Compiles the `<style>` elements of a file into scoped CSS, one style for each body that has
6890
+ * any, each with its own attribute. The file's body comes first.
6891
+ */
6731
6892
  function compileStyles(file, scope, filePath) {
6732
6893
  const attribute = `b-c-${scope}`;
6733
- const diagnostics = [];
6734
- const variables = [];
6735
- const dependencies = [];
6894
+ const state = {
6895
+ filePath,
6896
+ diagnostics: [],
6897
+ dependencies: [],
6898
+ variables: [],
6899
+ targets: []
6900
+ };
6901
+ const root = fileBody(file);
6902
+ const bodies = [root];
6903
+ if (file.blockStyles.length > 0) {
6904
+ const inner = [];
6905
+ for (const body of bodyTree(file).keys()) if (body.styles.length > 0) inner.push(body);
6906
+ inner.sort((a, b) => a.start - b.start);
6907
+ bodies.push(...inner);
6908
+ }
6909
+ const blocks = [];
6736
6910
  const parts = [];
6737
- const targets = [];
6738
- for (const style of file.styles) {
6739
- const contentStart = file.source.indexOf(style.content, style.start);
6740
- let content = "";
6741
- let position = 0;
6742
- for (const expression of style.variables) {
6743
- const name = `--s-${scope}-${variables.length}`;
6744
- let start = expression.start - 2 - contentStart;
6745
- let end = expression.end + 1 - contentStart;
6746
- const prefixStart = start;
6747
- while (start > position && /[#\w.%-]/.test(style.content[start - 1])) start--;
6748
- const prefix = style.content.slice(start, prefixStart);
6749
- const suffixStart = end;
6750
- while (end < style.content.length && /[\w.%-]/.test(style.content[end])) end++;
6751
- const suffix = style.content.slice(suffixStart, end);
6752
- variables.push({
6753
- name,
6754
- expression,
6755
- prefix,
6756
- suffix
6757
- });
6758
- content += `${style.content.slice(position, start)}var(${name})`;
6759
- position = end;
6760
- }
6761
- content += style.content.slice(position);
6762
- try {
6763
- const root = parse(style.lang === "css" ? content : preprocess(style.lang, content, filePath, dependencies));
6764
- scopeRules(root, attribute, targets, style.global);
6765
- parts.push(root.toString().trim());
6766
- } catch (error) {
6767
- diagnostics.push({
6768
- severity: "error",
6769
- message: style.lang === "css" ? `Invalid CSS: ${error.message}` : error.message,
6770
- range: {
6771
- start: style.start,
6772
- end: style.end
6773
- }
6774
- });
6911
+ let rootStyle;
6912
+ for (const body of bodies) {
6913
+ if (body.styles.length === 0) continue;
6914
+ const number = body === root ? void 0 : blocks.length - (rootStyle ? 1 : 0) + 1;
6915
+ const block = body === root ? {
6916
+ body,
6917
+ attribute,
6918
+ variables: state.variables,
6919
+ targets: state.targets
6920
+ } : {
6921
+ body,
6922
+ attribute: `${attribute}-${number}`,
6923
+ variables: [],
6924
+ targets: []
6925
+ };
6926
+ const blockState = {
6927
+ ...state,
6928
+ variables: block.variables,
6929
+ targets: block.targets
6930
+ };
6931
+ const own = [];
6932
+ for (const style of body.styles) {
6933
+ const css = compileStyle(file, style, block.attribute, (index) => number === void 0 ? `--s-${scope}-${index}` : `--s-${scope}-${number}-${index}`, blockState);
6934
+ if (css !== void 0) own.push(css);
6775
6935
  }
6936
+ parts.push(...own);
6937
+ if (body === root) {
6938
+ if (own.join("\n") !== "") {
6939
+ rootStyle = block;
6940
+ blocks.push(block);
6941
+ }
6942
+ } else blocks.push(block);
6776
6943
  }
6777
6944
  return {
6778
6945
  css: parts.join("\n"),
6779
- attribute,
6780
- variables,
6781
- diagnostics,
6782
- dependencies,
6783
- targets
6946
+ diagnostics: state.diagnostics,
6947
+ dependencies: state.dependencies,
6948
+ blocks,
6949
+ bodies: bodyStyles(file, blocks)
6784
6950
  };
6785
6951
  }
6786
6952
  //#endregion
@@ -7220,17 +7386,19 @@ function createPlan(file, graph, path, hideNames = false) {
7220
7386
  }
7221
7387
  }
7222
7388
  const styles = compileStyles(file, hash(file.filename), path);
7223
- let liveStyles = false;
7224
- for (const site of model.sites) if (site.kind === "style" && isLiveSite(site)) {
7225
- liveStyles = true;
7226
- break;
7389
+ const liveBlocks = /* @__PURE__ */ new Set();
7390
+ for (const site of model.sites) {
7391
+ if (site.kind !== "style" || !isLiveSite(site)) continue;
7392
+ liveBlocks.add(site.scope.body ?? fileBody(file));
7393
+ const plan = site.scope.body ? scopes.get(site.scope) : void 0;
7394
+ if (plan) plan.needsId = true;
7227
7395
  }
7228
7396
  return {
7229
7397
  graph,
7230
7398
  name,
7231
7399
  id: `${name}_${hash(file.filename)}`,
7232
7400
  styles,
7233
- liveStyles,
7401
+ liveBlocks,
7234
7402
  hideNames,
7235
7403
  scopes,
7236
7404
  bodyScopes,
@@ -7281,30 +7449,6 @@ function holdsStream(block) {
7281
7449
  });
7282
7450
  return found;
7283
7451
  }
7284
- /** Returns the bodies of a block, in source order. */
7285
- function blockBodies(block) {
7286
- switch (block.kind) {
7287
- case "if": {
7288
- const bodies = [];
7289
- for (const branch of block.branches) bodies.push(branch.body);
7290
- if (block.fallback) bodies.push(block.fallback);
7291
- return bodies;
7292
- }
7293
- case "switch": {
7294
- const bodies = [];
7295
- for (const branch of block.cases) bodies.push(branch.body);
7296
- if (block.fallback) bodies.push(block.fallback);
7297
- return bodies;
7298
- }
7299
- case "for":
7300
- case "repeat":
7301
- case "loading":
7302
- case "client":
7303
- case "defer": return [block.body, ...block.fallback ? [block.fallback] : []];
7304
- case "try": return [block.body, block.fallback];
7305
- default: return [block.body];
7306
- }
7307
- }
7308
7452
  /**
7309
7453
  * The arguments that tell the core which component holds a block in its children: the kind of the
7310
7454
  * scope that renders the component and its anchor. Empty for a block outside children.
@@ -8812,6 +8956,8 @@ var Emitter = class {
8812
8956
  depth = 0;
8813
8957
  /** How many of this component's elements contain the current node. */
8814
8958
  nesting = 0;
8959
+ /** The `nesting` where the body that renders began, so its top-level elements are at this level. */
8960
+ bodyBase = 0;
8815
8961
  /** How many `#head` blocks contain the current node, where a `<title>` sets the title of the page. */
8816
8962
  headBlocks = 0;
8817
8963
  counter = 0;
@@ -9681,6 +9827,12 @@ var Emitter = class {
9681
9827
  * before the markup, after the script.
9682
9828
  */
9683
9829
  emitBody(body, createScope = true, markup) {
9830
+ const base = this.bodyBase;
9831
+ this.bodyBase = this.nesting;
9832
+ this.emitBodyContent(body, createScope, markup);
9833
+ this.bodyBase = base;
9834
+ }
9835
+ emitBodyContent(body, createScope, markup) {
9684
9836
  const scope = this.plan.bodyScopes.get(body);
9685
9837
  if ((this.plan.scopes.get(scope).needsId || this.splitsScript(body, scope)) && createScope) this.createScope(scope);
9686
9838
  if (body.script) this.emitStatements(body.script.program.body, scope);
@@ -9898,16 +10050,16 @@ var Emitter = class {
9898
10050
  }
9899
10051
  /**
9900
10052
  * The style attribute of a top-level element, with the style variables of
9901
- * the component, so the elements inside inherit them. An element with
9902
- * spreads gets them after its attributes merge, so it returns them as code,
9903
- * and the style of a spread does not take the place of the variables.
10053
+ * the component and of the block styles around it, so the elements inside
10054
+ * inherit them. An element with spreads gets them after its attributes
10055
+ * merge, so it returns them as code, and the style of a spread does not
10056
+ * take the place of the variables.
9904
10057
  */
9905
- emitVariables(node) {
9906
- const { variables } = this.plan.styles;
9907
- if (variables.length === 0 || this.nesting > 0) return;
9908
- const values = this.variableValues();
10058
+ emitVariables(node, scope) {
10059
+ const values = this.variableValues(scope);
10060
+ if (values === void 0) return;
9909
10061
  if (hasSpread(node.attributes)) {
9910
- this.emitLiveStyles();
10062
+ this.emitLiveStyles(scope);
9911
10063
  return values;
9912
10064
  }
9913
10065
  const own = findStyleAttribute(node.attributes);
@@ -9915,25 +10067,59 @@ var Emitter = class {
9915
10067
  if (own?.kind === "static") existing = own.value === true ? "undefined" : JSON.stringify(own.value);
9916
10068
  else if (own?.kind === "value") existing = this.expression(own.value);
9917
10069
  this.code(`$$b.attribute("style", $$b.vars(${values}, ${existing}))`);
9918
- this.emitLiveStyles();
10070
+ this.emitLiveStyles(scope);
9919
10071
  return values;
9920
10072
  }
9921
- /** The style variables of the component and their values, as an object in code. */
9922
- variableValues() {
10073
+ /**
10074
+ * The styles that reach the elements written in a scope: those of its body and of the bodies
10075
+ * around it. A scope of no body is the file's.
10076
+ */
10077
+ blockStyles(scope) {
10078
+ return this.plan.styles.bodies.get(scope.body ?? fileBody(this.file));
10079
+ }
10080
+ /**
10081
+ * The style variables of the element that renders now and their values, as an object in code, or
10082
+ * undefined for none. A top-level element of a body has those of the styles that it is at the
10083
+ * top level of.
10084
+ */
10085
+ variableValues(scope) {
9923
10086
  const values = [];
9924
- for (const variable of this.plan.styles.variables) values.push(`${JSON.stringify(variable.name)}: ${variableValue(variable, this.expression(variable.expression))}`);
9925
- return `{ ${values.join(", ")} }`;
10087
+ if (this.nesting === this.bodyBase) for (const block of this.blockStyles(scope)?.variables ?? []) for (const variable of block.variables) values.push(`${JSON.stringify(variable.name)}: ${variableValue(variable, this.expression(variable.expression))}`);
10088
+ return values.length > 0 ? `{ ${values.join(", ")} }` : void 0;
9926
10089
  }
9927
- /** The ID of the component scope, which `b-v` names. */
9928
- componentId() {
9929
- const component = this.plan.graph.model.component;
9930
- const name = this.scopeVar(component);
9931
- return this.isInside(component) ? name : `${name}.id`;
10090
+ /**
10091
+ * The names of the scope attributes of an element: those of the styles of its body and of the
10092
+ * bodies around it. In a build, an attribute is left out when no selector of its style could
10093
+ * match the element. In development, every element gets it, so a change to the styles applies
10094
+ * without rendering the page again.
10095
+ */
10096
+ scopeAttributes(scope, tag, classes) {
10097
+ const names = [];
10098
+ for (const block of this.blockStyles(scope)?.attributes ?? []) if (!this.plan.hideNames || needsScope(block.targets, tag, classes)) names.push(block.attribute);
10099
+ return names;
10100
+ }
10101
+ /**
10102
+ * The scopes whose style variables the element that renders now carries and that change on the
10103
+ * client, as code: the IDs of the instances, or undefined for none. A top-level element of a
10104
+ * body carries the live styles that it is at the top level of.
10105
+ */
10106
+ liveVariableScopes(scope) {
10107
+ const ids = [];
10108
+ if (this.nesting === this.bodyBase) {
10109
+ for (const block of this.blockStyles(scope)?.variables ?? []) if (this.plan.liveBlocks.has(block.body)) {
10110
+ const owner = this.plan.bodyScopes.get(block.body) ?? this.plan.graph.model.component;
10111
+ const name = this.scopeVar(instanceScope(this.plan, owner));
10112
+ ids.push(this.isInside(owner) ? name : `${name}.id`);
10113
+ }
10114
+ }
10115
+ if (ids.length === 0) return;
10116
+ return ids.length === 1 ? ids[0] : `[${ids.join(", ")}].join(" ")`;
9932
10117
  }
9933
- emitLiveStyles() {
9934
- if (this.plan.liveStyles) {
10118
+ emitLiveStyles(scope) {
10119
+ const ids = this.liveVariableScopes(scope);
10120
+ if (ids !== void 0) {
9935
10121
  this.html(" b-v=\"");
9936
- this.code(this.componentId());
10122
+ this.code(ids);
9937
10123
  this.html("\"");
9938
10124
  }
9939
10125
  }
@@ -9978,14 +10164,14 @@ var Emitter = class {
9978
10164
  this.line(`const ${spreadHandlers}: string[] = [];`);
9979
10165
  }
9980
10166
  this.html(`<${node.tag}`);
9981
- if (this.hasScope(node.tag, staticClasses(node.attributes))) this.html(` ${this.plan.styles.attribute}`);
10167
+ for (const name of this.scopeAttributes(scope, node.tag, staticClasses(node.attributes))) this.html(` ${name}`);
9982
10168
  const anchor = this.anchor(scope, node);
9983
10169
  if (anchor && spreadHandlers) {
9984
10170
  this.html(" b-b=\"");
9985
10171
  this.code(anchor.scope);
9986
10172
  this.html(`:${anchor.index}"`);
9987
10173
  }
9988
- const variables = this.emitVariables(node);
10174
+ const variables = this.emitVariables(node, scope);
9989
10175
  const events = [];
9990
10176
  const merged = hasSpread(node.attributes) ? [] : void 0;
9991
10177
  let liveSpread = false;
@@ -10132,17 +10318,6 @@ var Emitter = class {
10132
10318
  this.code(`$$b.classAttribute(${pieces.join(" + ")})`);
10133
10319
  }
10134
10320
  }
10135
- /**
10136
- * True if an element gets the scope attribute. In a build, only elements
10137
- * that a scoped selector could match get it. In development, every
10138
- * element of a component with styles gets it, so a change to the styles
10139
- * applies without rendering the page again.
10140
- */
10141
- hasScope(tag, classes) {
10142
- const { css, targets } = this.plan.styles;
10143
- if (!css) return false;
10144
- return !this.plan.hideNames || needsScope(targets, tag, classes);
10145
- }
10146
10321
  /** Renders the children of a component or a dynamic tag, for their export in the browser. */
10147
10322
  emitChildrenBody(node, scope) {
10148
10323
  this.atTopLevel(() => this.emitNodes(node.children, scope));
@@ -10150,10 +10325,13 @@ var Emitter = class {
10150
10325
  /** Runs a callback for markup that renders outside this component's elements, such as children. */
10151
10326
  atTopLevel(callback) {
10152
10327
  const nesting = this.nesting;
10328
+ const base = this.bodyBase;
10153
10329
  const elements = this.elements.splice(0);
10154
10330
  this.nesting = 0;
10331
+ this.bodyBase = 0;
10155
10332
  callback();
10156
10333
  this.nesting = nesting;
10334
+ this.bodyBase = base;
10157
10335
  this.elements.push(...elements);
10158
10336
  }
10159
10337
  /** Renders children into a variable, for a component or a dynamic tag. */
@@ -10310,7 +10488,7 @@ var Emitter = class {
10310
10488
  emitDynamic(node, scope) {
10311
10489
  const childrenName = this.emitChildren(node, scope);
10312
10490
  const extra = [];
10313
- if (this.hasScope(void 0, staticClasses(node.attributes))) extra.push(`${JSON.stringify(this.plan.styles.attribute)}: $$b.internal(true)`);
10491
+ for (const name of this.scopeAttributes(scope, void 0, staticClasses(node.attributes))) extra.push(`${JSON.stringify(name)}: $$b.internal(true)`);
10314
10492
  const anchor = this.anchor(scope, node);
10315
10493
  if (anchor) extra.push(`"b-b": $$b.internal(\`\${${anchor.scope}}:${anchor.index}\`)`);
10316
10494
  const events = [];
@@ -10324,13 +10502,12 @@ var Emitter = class {
10324
10502
  }
10325
10503
  let attributes = [];
10326
10504
  for (const attribute of node.attributes) if (attribute.kind !== "event") attributes.push(attribute);
10327
- const { variables } = this.plan.styles;
10505
+ const variableCode = this.variableValues(scope);
10328
10506
  let spreadVariables;
10329
- if (variables.length > 0 && this.nesting === 0) {
10330
- if (this.plan.liveStyles) extra.push(`"b-v": $$b.internal(${this.componentId()})`);
10331
- }
10332
- if (variables.length > 0 && this.nesting === 0 && hasSpread(attributes)) spreadVariables = this.variableValues();
10333
- else if (variables.length > 0 && this.nesting === 0) {
10507
+ const liveScopes = this.liveVariableScopes(scope);
10508
+ if (liveScopes !== void 0) extra.push(`"b-v": $$b.internal(${liveScopes})`);
10509
+ if (variableCode !== void 0 && hasSpread(attributes)) spreadVariables = variableCode;
10510
+ else if (variableCode !== void 0) {
10334
10511
  const own = findStyleAttribute(attributes);
10335
10512
  let existing = "undefined";
10336
10513
  if (own?.kind === "static") existing = own.value === true ? "undefined" : JSON.stringify(own.value);
@@ -10338,7 +10515,7 @@ var Emitter = class {
10338
10515
  const rest = [];
10339
10516
  for (const attribute of attributes) if (attribute !== own) rest.push(attribute);
10340
10517
  attributes = rest;
10341
- extra.push(`"style": $$b.vars(${this.variableValues()}, ${existing})`);
10518
+ extra.push(`"style": $$b.vars(${variableCode}, ${existing})`);
10342
10519
  }
10343
10520
  const refs = [];
10344
10521
  for (const attribute of node.attributes) if (attribute.kind === "ref") refs.push(attribute);
@@ -12343,9 +12520,12 @@ var ClientGenerator = class {
12343
12520
  }
12344
12521
  if (site.kind === "style") {
12345
12522
  let variable;
12346
- for (const item of this.plan.styles.variables) if (item.expression.ast === site.node) {
12347
- variable = item;
12348
- break;
12523
+ for (const block of this.plan.styles.blocks) {
12524
+ for (const item of block.variables) if (item.expression.ast === site.node) {
12525
+ variable = item;
12526
+ break;
12527
+ }
12528
+ if (variable) break;
12349
12529
  }
12350
12530
  if (variable) this.emit(`export function ${name("u")}($$s) {\n $$b.setVar($$s, ${JSON.stringify(variable.name)}, ${variableValue(variable, expression())});\n}`);
12351
12531
  return;
@@ -12375,7 +12555,7 @@ var ClientGenerator = class {
12375
12555
  if (attribute.kind === "spread" || attribute.kind === "computed") {
12376
12556
  const own = [];
12377
12557
  for (const item of owner.attributes) if (item.kind === "static" || item.kind === "value") own.push(item.name);
12378
- if (this.plan.styles.css) own.push(this.plan.styles.attribute);
12558
+ for (const block of this.plan.styles.bodies.get(site.scope.body ?? fileBody(this.file))?.attributes ?? []) own.push(block.attribute);
12379
12559
  const spreads = this.spreadCode(owner, attribute);
12380
12560
  for (const item of owner.attributes) {
12381
12561
  if (item.kind !== "computed") continue;
@@ -12922,9 +13102,11 @@ var ClientGenerator = class {
12922
13102
  function isInside(scope) {
12923
13103
  return isWithinAny(scope, inside);
12924
13104
  }
13105
+ const styled = /* @__PURE__ */ new Set();
13106
+ for (const scope of inside) for (const block of this.plan.styles.bodies.get(scope.body ?? fileBody(this.file))?.variables ?? []) styled.add(block.body);
12925
13107
  const declarations = /* @__PURE__ */ new Set();
12926
13108
  for (const site of this.model.sites) {
12927
- if (!(isInside(site.scope) || site.kind === "style") || DEFERRED_SITES.has(site.kind)) continue;
13109
+ if (!(isInside(site.scope) || site.kind === "style" && (!site.scope.body || styled.has(site.scope.body))) || DEFERRED_SITES.has(site.kind)) continue;
12928
13110
  for (const read of site.reads) if (!isInside(read.declaration.scope)) declarations.add(read.declaration);
12929
13111
  }
12930
13112
  const lines = [];
@@ -13497,6 +13679,6 @@ function inspect(source, options = {}) {
13497
13679
  };
13498
13680
  }
13499
13681
  //#endregion
13500
- export { errorLink as $, analyzeProject as A, isWithin as B, isReactiveModule as C, unmarked as D, originalPosition as E, summarize as F, bridgeModuleId as G, resolveMacros as H, parse$1 as I, nameBridges as J, hasBridge as K, buildGraph as L, importSource as M, importedComponents as N, entryClasses as O, resolveRelative as P, getLocation as Q, forEachNode as R, sharedSites as S, builtin as T, walk as U, lookup as V, BRIDGE_EXPORT as W, getPatternNames as X, scriptBridges as Y, BrumateError as Z, functionId as _, scopeLabel as a, SHARED_QUERY as b, DEFAULT_MERGE as c, generateServer as d, findError as et, instanceScope as f, createPlan as g, clientState as h, report as i, analyzeProjectProps as j, refreshedNames as k, generateClient as l, blockBodies as m, formatReport as n, CompileError as o, slotIndex as p, mayHaveBridge as q, inspect as r, compile as s, anchorLabel as t, generateRender as u, getComponentName as v, resolveFromDisk as w, generateShared as x, hash as y, analyze$1 as z };
13682
+ export { analyzeProjectProps as A, isWithin as B, resolveFromDisk as C, entryClasses as D, unmarked as E, parse$1 as F, bridgeModuleId as G, resolveMacros as H, buildGraph as I, nameBridges as J, hasBridge as K, blockBodies as L, importedComponents as M, resolveRelative as N, refreshedNames as O, summarize as P, getLocation as Q, forEachNode as R, isReactiveModule as S, originalPosition as T, walk as U, lookup as V, BRIDGE_EXPORT as W, getPatternNames as X, scriptBridges as Y, BrumateError as Z, getComponentName as _, scopeLabel as a, generateShared as b, DEFAULT_MERGE as c, generateServer as d, instanceScope as f, functionId as g, createPlan as h, report as i, importSource as j, analyzeProject as k, generateClient as l, clientState as m, formatReport as n, CompileError as o, slotIndex as p, mayHaveBridge as q, inspect as r, compile as s, anchorLabel as t, generateRender as u, hash as v, builtin as w, sharedSites as x, SHARED_QUERY as y, analyze$1 as z };
13501
13683
 
13502
- //# sourceMappingURL=inspect-BSHv1_25.js.map
13684
+ //# sourceMappingURL=inspect-CGl5Y8q6.js.map