brumate 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/{boot-CMy0f_iC.d.ts → boot-DQuAhAd5.d.ts} +2 -2
  2. package/dist/cli.js +3 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{client-DnFF9_lv.d.ts → client-4eabQtYJ.d.ts} +38 -12
  5. package/dist/{client-COm1iA6w.js → client-CwVcmymi.js} +145 -28
  6. package/dist/client-CwVcmymi.js.map +1 -0
  7. package/dist/{defer-Cesb-k2Q.js → defer-BaXWydb0.js} +2 -2
  8. package/dist/{defer-Cesb-k2Q.js.map → defer-BaXWydb0.js.map} +1 -1
  9. package/dist/{devtools-C9IEkgc1.js → devtools-CMuj12yR.js} +257 -118
  10. package/dist/devtools-CMuj12yR.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-Cq8LpsyW.js +3978 -0
  14. package/dist/devtools-panel-Cq8LpsyW.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-DXS8RAtZ.js} +2 -2
  19. package/dist/{files-BuQvpBwF.js.map → files-DXS8RAtZ.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-B5AoHh5O.js} +639 -412
  24. package/dist/inspect-B5AoHh5O.js.map +1 -0
  25. package/dist/{loader-CLKrJMqw.js → loader-CTeT6ie9.js} +4 -4
  26. package/dist/{loader-CLKrJMqw.js.map → loader-CTeT6ie9.js.map} +1 -1
  27. package/dist/{navigate-OHb0Uw1P.js → navigate-Bj73X4ZS.js} +22 -8
  28. package/dist/navigate-Bj73X4ZS.js.map +1 -0
  29. package/dist/{rpc-BAKbRWOT.js → rpc-kVB0Ujdx.js} +5 -4
  30. package/dist/rpc-kVB0Ujdx.js.map +1 -0
  31. package/dist/runtime/bundles.d.ts +3 -2
  32. package/dist/runtime/bundles.js +14 -3
  33. package/dist/runtime/bundles.js.map +1 -1
  34. package/dist/runtime/client.d.ts +2 -2
  35. package/dist/runtime/client.js +4 -3
  36. package/dist/runtime/devtools.d.ts +59 -1
  37. package/dist/runtime/devtools.js +1 -1
  38. package/dist/runtime/hot.d.ts +1 -1
  39. package/dist/runtime/hot.js +6 -2
  40. package/dist/runtime/hot.js.map +1 -1
  41. package/dist/runtime/loader.d.ts +2 -2
  42. package/dist/runtime/loader.js +2 -2
  43. package/dist/runtime/server.d.ts +1 -1
  44. package/dist/runtime/server.js +3 -2
  45. package/dist/runtime/signals.d.ts +1 -1
  46. package/dist/runtime/static-loader.d.ts +2 -2
  47. package/dist/runtime/static-loader.js +1 -1
  48. package/dist/runtime/store.d.ts +2 -2
  49. package/dist/runtime/store.js +1 -1
  50. package/dist/runtime/testing.d.ts +2 -2
  51. package/dist/runtime/testing.js +2 -2
  52. package/dist/search-params-Wg-0FsMj.js +148 -0
  53. package/dist/search-params-Wg-0FsMj.js.map +1 -0
  54. package/dist/{stream-RXLadXx1.js → serial-ioa17MuY.js} +67 -168
  55. package/dist/serial-ioa17MuY.js.map +1 -0
  56. package/dist/serial-ribg9NAj.js +1 -0
  57. package/dist/{server-BVObWh-w.js → server-BUuf7XPZ.js} +61 -16
  58. package/dist/server-BUuf7XPZ.js.map +1 -0
  59. package/dist/{server-0rS5vUW1.d.ts → server-DesBZv5g.d.ts} +8 -3
  60. package/dist/{search-params-C64liRBj.js → shared-CX_YacDm.js} +3 -148
  61. package/dist/shared-CX_YacDm.js.map +1 -0
  62. package/dist/{signals-DBnq9QRW.d.ts → signals-7VVD9C_H.d.ts} +2 -2
  63. package/dist/{static-loader-CxANokZ4.js → static-loader-BM0-wdIc.js} +2 -2
  64. package/dist/{static-loader-CxANokZ4.js.map → static-loader-BM0-wdIc.js.map} +1 -1
  65. package/dist/{static-loader-BYbXVJDY.d.ts → static-loader-BSAyFqG0.d.ts} +2 -2
  66. package/dist/{store-xlTzAM_r.d.ts → store-9_oa0HG1.d.ts} +15 -2
  67. package/dist/{store-BIBAYZo-.js → store-Cy4EEyZ7.js} +148 -2
  68. package/dist/store-Cy4EEyZ7.js.map +1 -0
  69. package/dist/stream-read-BTsYstJY.js +22 -0
  70. package/dist/stream-read-BTsYstJY.js.map +1 -0
  71. package/dist/stream-read-Dek3HnqO.js +1 -0
  72. package/dist/vite.d.ts +1 -1
  73. package/dist/vite.js +37 -5
  74. package/dist/vite.js.map +1 -1
  75. package/package.json +7 -4
  76. package/skills/brumate/SKILL.md +6 -2
  77. package/skills/brumate/references/errors.md +21 -2
  78. package/skills/brumate/references/state.md +31 -0
  79. package/skills/brumate/references/syntax.md +45 -1
  80. package/dist/client-COm1iA6w.js.map +0 -1
  81. package/dist/devtools-C9IEkgc1.js.map +0 -1
  82. package/dist/devtools-panel-Doit__YG.js +0 -2018
  83. package/dist/devtools-panel-Doit__YG.js.map +0 -1
  84. package/dist/inspect-BSHv1_25.js.map +0 -1
  85. package/dist/navigate-OHb0Uw1P.js.map +0 -1
  86. package/dist/rpc-BAKbRWOT.js.map +0 -1
  87. package/dist/search-params-C64liRBj.js.map +0 -1
  88. package/dist/server-BVObWh-w.js.map +0 -1
  89. package/dist/store-BIBAYZo-.js.map +0 -1
  90. package/dist/stream-RXLadXx1.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { r as SerialEntry } from "./values-B8C7CLvG.js";
2
- import { qt as ClientModule } from "./client-DnFF9_lv.js";
2
+ import { Yt as ClientModule } from "./client-4eabQtYJ.js";
3
3
  //#region src/runtime/boot.d.ts
4
4
  interface LoaderOptions {
5
5
  /**
@@ -51,4 +51,4 @@ interface NavigateOptions {
51
51
  }
52
52
  //#endregion
53
53
  export { NavigateOptions as n, LoaderOptions as t };
54
- //# sourceMappingURL=boot-CMy0f_iC.d.ts.map
54
+ //# sourceMappingURL=boot-DQuAhAd5.d.ts.map
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { Q as getLocation, W as BRIDGE_EXPORT, Y as scriptBridges, Z as BrumateError, et as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk } from "./inspect-BSHv1_25.js";
3
- import { _ as findPackages, a as findScripts, b as resolveComponentPackage, c as findServerImport, n as defaultExclude, s as findPackageServerFile, t as collectSources } from "./files-BuQvpBwF.js";
2
+ import { a as findError } from "./error-catalog-DakxjSgj.js";
3
+ import { A as analyzeProjectProps, C as resolveFromDisk, Q as getLocation, W as BRIDGE_EXPORT, Y as scriptBridges, Z as BrumateError, o as CompileError, r as inspect, s as compile } from "./inspect-B5AoHh5O.js";
4
+ import { _ as findPackages, a as findScripts, b as resolveComponentPackage, c as findServerImport, n as defaultExclude, s as findPackageServerFile, t as collectSources } from "./files-DXS8RAtZ.js";
4
5
  import { createRequire } from "node:module";
5
6
  import { existsSync, readFileSync, statSync } from "node:fs";
6
7
  import { cp, readdir } from "node:fs/promises";
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["toPosix"],"sources":["../src/check-command.ts","../src/cli.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { CompileError, compile } from './compile.ts';\nimport type { Diagnostic } from './model.ts';\nimport { findError } from './error-catalog.ts';\nimport { BrumateError, getLocation } from './error.ts';\nimport { BRIDGE_EXPORT, scriptBridges } from './bridges.ts';\nimport { collectSources, defaultExclude, findScripts } from './files.ts';\nimport { resolveFromDisk } from './modules.ts';\nimport type { BrumatePackage } from './packages.ts';\nimport { findPackages, resolveComponentPackage } from './packages.ts';\nimport { analyzeProjectProps } from './project.ts';\nimport { findPackageServerFile, findServerImport } from './server-files.ts';\n\n/** A place in a file. Lines and columns start at 1. */\nexport interface CheckPosition {\n line: number;\n column: number;\n}\n\n/** One problem, as `brumate check --json` prints it. */\nexport interface CheckRecord {\n /** The file, relative to the current directory. Null for a problem of the whole project. */\n file: string | null;\n /** Where the problem is. The type checker gives a start only, so its end is the start. */\n range: { start: CheckPosition; end: CheckPosition } | null;\n severity: 'error' | 'warning';\n /** The message without its code or its place. */\n message: string;\n /** `BRM012` for an error of the compiler, `TS2322` for one of TypeScript, null for a warning. */\n code: string | null;\n /** The page of the docs that explains the code, null when there is none. */\n link: string | null;\n /** Who found it. */\n source: 'brumate' | 'typescript';\n}\n\nexport interface CheckOptions {\n /** Files or directories to check. Defaults to the root. */\n paths?: string[];\n /** Runs the type checker too. Defaults to true. */\n types?: boolean;\n /** The `brumate-tsc` script to run. Defaults to the one of the installed @brumate/tsc. */\n tscBin?: string;\n}\n\nexport interface CheckResult {\n records: CheckRecord[];\n /** Why the type check did not run, such as a missing package. */\n notes: string[];\n}\n\n/** How many records are errors. Warnings do not count. */\nexport function errorCount(records: CheckRecord[]): number {\n let count = 0;\n for (const record of records) {\n if (record.severity === 'error') {\n count++;\n }\n }\n return count;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction fromDiagnostic(source: string, file: string, diagnostic: Diagnostic): CheckRecord {\n const entry = diagnostic.severity === 'error' ? findError(diagnostic.message) : undefined;\n // A range at the end of the file stays in the file.\n const first = Math.min(diagnostic.range.start, source.length);\n const start = getLocation(source, first);\n const end = getLocation(source, Math.min(Math.max(first, diagnostic.range.end), source.length));\n return {\n file,\n range: { start, end },\n severity: diagnostic.severity === 'error' ? 'error' : 'warning',\n message: diagnostic.message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n };\n}\n\n/** Compiles one file and gives its errors and warnings. */\nfunction checkFile(\n source: string,\n file: string,\n absolute: string,\n liveProps: Set<string> | undefined,\n packages: BrumatePackage[],\n): CheckRecord[] {\n try {\n const result = compile(source, {\n filename: file,\n path: absolute,\n liveProps,\n serverImport: (specifier) =>\n specifier.startsWith('.')\n ? findServerImport(absolute, specifier)\n : findPackageServerFile(packages, absolute, specifier),\n resolveModule: (specifier, importer) => {\n const local = resolveFromDisk(specifier, importer);\n const found =\n local === undefined ? resolveComponentPackage(packages, specifier, importer) : undefined;\n return found ? { path: found, source: readFileSync(found, 'utf8') } : local;\n },\n });\n const records: CheckRecord[] = [];\n for (const warning of result.warnings) {\n records.push(fromDiagnostic(source, file, warning));\n }\n return records;\n } catch (error) {\n if (error instanceof CompileError) {\n const records: CheckRecord[] = [];\n for (const diagnostic of error.diagnostics) {\n records.push(fromDiagnostic(source, file, diagnostic));\n }\n return records;\n }\n if (error instanceof BrumateError) {\n // The message holds the code and the place. The parts are in the entry and the location.\n const message = error.message.replace(/ \\([^()]*:\\d+:\\d+\\)$/, '').replace(/ \\[BRM\\d+\\]$/, '');\n const entry = findError(message);\n const start = error.location;\n return [\n {\n file,\n range: { start, end: getLocation(source, Math.min(error.offset + 1, source.length)) },\n severity: 'error',\n message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n },\n ];\n }\n throw error;\n }\n}\n\nconst TS_LINE = /^(.+?)\\((\\d+),(\\d+)\\): (error|warning) (TS\\d+|BRM\\d*): (.*)$/;\nconst TS_GLOBAL = /^(error|warning) (TS\\d+): (.*)$/;\n\n/** Reads the lines that `tsc` prints without colors. */\nexport function parseTypeOutput(output: string, root: string): CheckRecord[] {\n const records: CheckRecord[] = [];\n let last: CheckRecord | undefined;\n for (const line of output.split('\\n')) {\n const match = TS_LINE.exec(line);\n if (match) {\n last = undefined;\n // Syntax errors of `.brm` files are reported by the compiler, with their codes.\n if (match[5]!.startsWith('BRM')) {\n continue;\n }\n const position = { line: Number(match[2]), column: Number(match[3]) };\n last = {\n file: toPosix(path.relative(root, path.resolve(root, match[1]!))),\n range: { start: position, end: position },\n severity: match[4] === 'warning' ? 'warning' : 'error',\n message: match[6]!,\n code: match[5]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n const global = TS_GLOBAL.exec(line);\n if (global) {\n last = {\n file: null,\n range: null,\n severity: global[1] === 'warning' ? 'warning' : 'error',\n message: global[3]!,\n code: global[2]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n // The lines under a message, indented, belong to it.\n if (last && /^\\s+\\S/.test(line)) {\n last.message += `\\n${line}`;\n }\n }\n return records;\n}\n\n/**\n * Runs `brumate-tsc`, the type checker of `.brm` files. It has no API that\n * gives its errors, so its output is read. Without the package, it gives a\n * note and no records.\n */\nfunction typeCheck(root: string, tscBin?: string): { records: CheckRecord[]; note?: string } {\n if (!existsSync(path.join(root, 'tsconfig.json'))) {\n return {\n records: [],\n note: 'The type check was skipped: there is no tsconfig.json in the current directory.',\n };\n }\n let bin: string;\n try {\n const require = createRequire(path.join(root, 'noop.js'));\n bin =\n tscBin ??\n path.join(path.dirname(require.resolve('@brumate/tsc/package.json')), 'bin/brumate-tsc.js');\n } catch {\n return {\n records: [],\n note: 'The type check was skipped: install @brumate/tsc to run it, or pass --no-types.',\n };\n }\n const result = spawnSync(process.execPath, [bin, '--noEmit', '--pretty', 'false'], {\n cwd: root,\n encoding: 'utf8',\n maxBuffer: 64 * 1024 * 1024,\n });\n const records = parseTypeOutput(`${result.stdout}\\n${result.stderr}`, root);\n function fail(message: string): void {\n records.push({\n file: null,\n range: null,\n severity: 'error',\n message,\n code: null,\n link: null,\n source: 'typescript',\n });\n }\n if (result.error) {\n // The process did not start, ran too long for a timeout, or printed more than maxBuffer.\n fail(`The type check did not finish: ${result.error.message}`);\n } else if (result.signal) {\n fail(`The type check was stopped by ${result.signal}`);\n } else if (result.status !== 0 && errorCount(records) === 0) {\n // A failure that has no error line of TypeScript, such as an unreadable tsconfig.json. A\n // failure of syntax errors only is reported by the compiler.\n const text = `${result.stdout}${result.stderr}`.trim();\n if (!/error BRM\\d*:/.test(text)) {\n fail(text || `The type check ended with status ${result.status}`);\n }\n }\n return { records };\n}\n\n/** Finds the calls of `bridge` in scripts that are not module-level exports. */\nasync function checkScripts(root: string, paths: string[]): Promise<CheckRecord[]> {\n const files = new Set<string>();\n if (paths.length === 0) {\n for (const file of await findScripts(root, defaultExclude)) {\n files.add(file);\n }\n }\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n if (statSync(absolute).isDirectory()) {\n for (const file of await findScripts(absolute, defaultExclude)) {\n files.add(file);\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(absolute)) {\n files.add(toPosix(absolute));\n }\n }\n const entry = findError(BRIDGE_EXPORT);\n const records: CheckRecord[] = [];\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n for (const { call, exported } of scriptBridges(source, file)) {\n if (exported === undefined) {\n const start = getLocation(source, call.start);\n records.push({\n file: toPosix(path.relative(root, file)),\n range: { start, end: getLocation(source, call.end) },\n severity: 'error',\n message: BRIDGE_EXPORT,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n }\n }\n return records;\n}\n\n/** Compiles every `.brm` file under the root, and runs the type checker. */\nexport async function check(root: string, options: CheckOptions = {}): Promise<CheckResult> {\n const records: CheckRecord[] = [];\n // A path that does not exist is a problem of its own. The others are still checked.\n const paths: string[] = [];\n for (const target of options.paths ?? []) {\n if (existsSync(path.resolve(root, target))) {\n paths.push(target);\n } else {\n records.push({\n file: toPosix(target),\n range: null,\n severity: 'error',\n message: 'This file or directory does not exist',\n code: null,\n link: null,\n source: 'brumate',\n });\n }\n }\n const missingOnly = paths.length === 0 && (options.paths?.length ?? 0) > 0;\n const { sources, targets } = missingOnly\n ? { sources: new Map<string, string>(), targets: [] }\n : await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const packages = findPackages(root);\n for (const file of targets) {\n const parents = props.get(file);\n records.push(\n ...checkFile(\n sources.get(file)!,\n toPosix(path.relative(root, file)),\n file,\n parents && new Set(parents.keys()),\n packages,\n ),\n );\n }\n\n if (!missingOnly) {\n records.push(...(await checkScripts(root, paths)));\n }\n\n const notes: string[] = [];\n if (options.types !== false) {\n const types = typeCheck(root, options.tscBin);\n records.push(...types.records);\n if (types.note) {\n notes.push(types.note);\n }\n }\n return { records, notes };\n}\n\n/** One line for a person: `file:line:column: error BRM012: message`. */\nexport function formatRecord(record: CheckRecord): string {\n const place = record.file\n ? `${record.file}${record.range ? `:${record.range.start.line}:${record.range.start.column}` : ''}: `\n : '';\n const code = record.code ? ` ${record.code}` : '';\n const link = record.link ? `\\n ${record.link}` : '';\n return `${place}${record.severity}${code}: ${record.message}${link}`;\n}\n","#!/usr/bin/env node\nimport { cp, readdir } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { check, errorCount, formatRecord } from './check-command.ts';\nimport { CompileError } from './compile.ts';\nimport { collectSources } from './files.ts';\nimport { inspect } from './inspect.ts';\nimport type { InspectReport } from './inspect.ts';\nimport { analyzeProjectProps } from './project.ts';\n\nconst USAGE = `Usage: brumate inspect [--json] [files or directories]\n\nShows what each component ships to the client, and why.\nWithout paths, inspects every .brm file under the current directory.\n\n brumate check [--json] [--no-types] [files or directories]\n\nCompiles every .brm file and type-checks the project with brumate-tsc.\nPrints each problem with its place, its code and a link to the docs.\nWith --json, prints one JSON object per line. Exits with 1 on an error.\n\n brumate skill [folder]\n\nCopies the skill for .brm files into folder/brumate, for coding agents.\nAlso copies each skill in the skills folder of the installed @brumate/*\npackages, such as folder/brumate-ui. The folder defaults to .claude/skills.`;\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\n/** Shows parent files relative to the current directory. */\nfunction relativeParents(\n parents: Map<string, Set<string>>,\n root: string,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [prop, files] of parents) {\n const relative = new Set<string>();\n for (const file of files) {\n relative.add(toPosix(path.relative(root, file)));\n }\n result.set(prop, relative);\n }\n return result;\n}\n\nasync function inspectCommand(args: string[]): Promise<number> {\n const json = args.includes('--json');\n const paths: string[] = [];\n for (const arg of args) {\n if (arg !== '--json') {\n paths.push(arg);\n }\n }\n const root = process.cwd();\n\n // Props are analyzed across every file under the current directory.\n const { sources, targets } = await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const reports: InspectReport[] = [];\n const texts: string[] = [];\n let failed = false;\n for (const file of targets) {\n const source = sources.get(file)!;\n const filename = toPosix(path.relative(root, file));\n try {\n const parents = props.get(file);\n const result = inspect(source, {\n filename,\n liveProps: parents && new Set(parents.keys()),\n parents: parents && relativeParents(parents, root),\n });\n reports.push(result.report);\n texts.push(result.text);\n } catch (error) {\n if (!(error instanceof CompileError)) {\n throw error;\n }\n failed = true;\n console.error(error.message);\n }\n }\n console.log(json ? JSON.stringify(reports, null, 2) : texts.join('\\n\\n'));\n return failed ? 1 : 0;\n}\n\nasync function checkCommand(args: string[]): Promise<number> {\n const flags = new Set(['--json', '--no-types']);\n const paths: string[] = [];\n for (const arg of args) {\n if (!arg.startsWith('-')) {\n paths.push(arg);\n } else if (!flags.has(arg)) {\n console.error(`brumate check does not know ${arg}\\n\\n${USAGE}`);\n return 1;\n }\n }\n const { records, notes } = await check(process.cwd(), {\n paths,\n types: !args.includes('--no-types'),\n });\n const json = args.includes('--json');\n for (const record of records) {\n console.log(json ? JSON.stringify(record) : formatRecord(record));\n }\n for (const note of notes) {\n console.error(note);\n }\n const errors = errorCount(records);\n if (!json) {\n console.log(errors === 0 ? 'No errors.' : `${errors} ${errors === 1 ? 'error' : 'errors'}.`);\n }\n return errors === 0 ? 0 : 1;\n}\n\n/** Lists the skill folders of the @brumate/* packages in node_modules, from the current directory up. */\nasync function findPackageSkills(start: string): Promise<Map<string, string>> {\n // The name brumate is the skill of this package. A package never replaces it.\n const found = new Map<string, string>();\n const warned = new Set<string>();\n let directory = start;\n while (true) {\n const scope = path.join(directory, 'node_modules', '@brumate');\n // oxlint-disable-next-line no-await-in-loop -- The walk goes up in order, so the nearest node_modules wins.\n const packages = await readdir(scope).catch(() => []);\n for (const name of packages) {\n const root = path.join(scope, name, 'skills');\n // oxlint-disable-next-line no-await-in-loop -- Same walk, in order.\n const skills = await readdir(root, { withFileTypes: true }).catch(() => []);\n for (const skill of skills) {\n if (!skill.isDirectory()) {\n continue;\n }\n if (skill.name === 'brumate') {\n if (!warned.has(name)) {\n warned.add(name);\n console.error(`@brumate/${name} has a skill named brumate, which is not copied.`);\n }\n } else if (!found.has(skill.name)) {\n found.set(skill.name, path.join(root, skill.name));\n }\n }\n }\n const parent = path.dirname(directory);\n if (parent === directory) {\n return found;\n }\n directory = parent;\n }\n}\n\nasync function skillCommand(args: string[]): Promise<number> {\n if (args.length > 1 || args[0]?.startsWith('-')) {\n console.error(`brumate skill takes one folder, not ${args.join(' ')}\\n\\n${USAGE}`);\n return 1;\n }\n const folder = path.resolve(args[0] ?? '.claude/skills');\n const target = path.join(folder, 'brumate');\n // The skill is in the package, next to dist and src.\n const source = fileURLToPath(new URL('../skills/brumate', import.meta.url));\n await cp(source, target, { recursive: true, force: true });\n console.log(`Copied the skill to ${path.relative(process.cwd(), target) || '.'}`);\n\n // Each @brumate package that has skills adds them, so they match its version.\n const copies: Promise<void>[] = [];\n for (const [name, from] of await findPackageSkills(process.cwd())) {\n const to = path.join(folder, name);\n // The line prints once the copy is done, so a failed copy shows no success.\n copies.push(\n cp(from, to, { recursive: true, force: true }).then(() => {\n console.log(`Copied the skill to ${path.relative(process.cwd(), to) || '.'}`);\n }),\n );\n }\n await Promise.all(copies);\n return 0;\n}\n\nasync function main(args: string[]): Promise<number> {\n const [command, ...rest] = args;\n if (command === 'skill') {\n return skillCommand(rest);\n }\n if (command === 'check') {\n return checkCommand(rest);\n }\n if (command === 'inspect') {\n return inspectCommand(rest);\n }\n console.log(USAGE);\n return command === undefined || command === '--help' ? 0 : 1;\n}\n\nprocess.exitCode = await main(process.argv.slice(2));\n"],"mappings":";;;;;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AK,SAAS,QAAQ,IAAI,GAAG,EAAE,KAAK,KAAK;EAC9E,CAAC,CACH;CACF;CACA,MAAM,QAAQ,IAAI,MAAM;CACxB,OAAO;AACT;AAEA,eAAe,KAAK,MAAiC;CACnD,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,SACd,OAAO,aAAa,IAAI;CAE1B,IAAI,YAAY,SACd,OAAO,aAAa,IAAI;CAE1B,IAAI,YAAY,WACd,OAAO,eAAe,IAAI;CAE5B,QAAQ,IAAI,KAAK;CACjB,OAAO,YAAY,KAAA,KAAa,YAAY,WAAW,IAAI;AAC7D;AAEA,QAAQ,WAAW,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"cli.js","names":["toPosix"],"sources":["../src/check-command.ts","../src/cli.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { CompileError, compile } from './compile.ts';\nimport type { Diagnostic } from './model.ts';\nimport { findError } from './error-catalog.ts';\nimport { BrumateError, getLocation } from './error.ts';\nimport { BRIDGE_EXPORT, scriptBridges } from './bridges.ts';\nimport { collectSources, defaultExclude, findScripts } from './files.ts';\nimport { resolveFromDisk } from './modules.ts';\nimport type { BrumatePackage } from './packages.ts';\nimport { findPackages, resolveComponentPackage } from './packages.ts';\nimport { analyzeProjectProps } from './project.ts';\nimport { findPackageServerFile, findServerImport } from './server-files.ts';\n\n/** A place in a file. Lines and columns start at 1. */\nexport interface CheckPosition {\n line: number;\n column: number;\n}\n\n/** One problem, as `brumate check --json` prints it. */\nexport interface CheckRecord {\n /** The file, relative to the current directory. Null for a problem of the whole project. */\n file: string | null;\n /** Where the problem is. The type checker gives a start only, so its end is the start. */\n range: { start: CheckPosition; end: CheckPosition } | null;\n severity: 'error' | 'warning';\n /** The message without its code or its place. */\n message: string;\n /** `BRM012` for an error of the compiler, `TS2322` for one of TypeScript, null for a warning. */\n code: string | null;\n /** The page of the docs that explains the code, null when there is none. */\n link: string | null;\n /** Who found it. */\n source: 'brumate' | 'typescript';\n}\n\nexport interface CheckOptions {\n /** Files or directories to check. Defaults to the root. */\n paths?: string[];\n /** Runs the type checker too. Defaults to true. */\n types?: boolean;\n /** The `brumate-tsc` script to run. Defaults to the one of the installed @brumate/tsc. */\n tscBin?: string;\n}\n\nexport interface CheckResult {\n records: CheckRecord[];\n /** Why the type check did not run, such as a missing package. */\n notes: string[];\n}\n\n/** How many records are errors. Warnings do not count. */\nexport function errorCount(records: CheckRecord[]): number {\n let count = 0;\n for (const record of records) {\n if (record.severity === 'error') {\n count++;\n }\n }\n return count;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction fromDiagnostic(source: string, file: string, diagnostic: Diagnostic): CheckRecord {\n const entry = diagnostic.severity === 'error' ? findError(diagnostic.message) : undefined;\n // A range at the end of the file stays in the file.\n const first = Math.min(diagnostic.range.start, source.length);\n const start = getLocation(source, first);\n const end = getLocation(source, Math.min(Math.max(first, diagnostic.range.end), source.length));\n return {\n file,\n range: { start, end },\n severity: diagnostic.severity === 'error' ? 'error' : 'warning',\n message: diagnostic.message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n };\n}\n\n/** Compiles one file and gives its errors and warnings. */\nfunction checkFile(\n source: string,\n file: string,\n absolute: string,\n liveProps: Set<string> | undefined,\n packages: BrumatePackage[],\n): CheckRecord[] {\n try {\n const result = compile(source, {\n filename: file,\n path: absolute,\n liveProps,\n serverImport: (specifier) =>\n specifier.startsWith('.')\n ? findServerImport(absolute, specifier)\n : findPackageServerFile(packages, absolute, specifier),\n resolveModule: (specifier, importer) => {\n const local = resolveFromDisk(specifier, importer);\n const found =\n local === undefined ? resolveComponentPackage(packages, specifier, importer) : undefined;\n return found ? { path: found, source: readFileSync(found, 'utf8') } : local;\n },\n });\n const records: CheckRecord[] = [];\n for (const warning of result.warnings) {\n records.push(fromDiagnostic(source, file, warning));\n }\n return records;\n } catch (error) {\n if (error instanceof CompileError) {\n const records: CheckRecord[] = [];\n for (const diagnostic of error.diagnostics) {\n records.push(fromDiagnostic(source, file, diagnostic));\n }\n return records;\n }\n if (error instanceof BrumateError) {\n // The message holds the code and the place. The parts are in the entry and the location.\n const message = error.message.replace(/ \\([^()]*:\\d+:\\d+\\)$/, '').replace(/ \\[BRM\\d+\\]$/, '');\n const entry = findError(message);\n const start = error.location;\n return [\n {\n file,\n range: { start, end: getLocation(source, Math.min(error.offset + 1, source.length)) },\n severity: 'error',\n message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n },\n ];\n }\n throw error;\n }\n}\n\nconst TS_LINE = /^(.+?)\\((\\d+),(\\d+)\\): (error|warning) (TS\\d+|BRM\\d*): (.*)$/;\nconst TS_GLOBAL = /^(error|warning) (TS\\d+): (.*)$/;\n\n/** Reads the lines that `tsc` prints without colors. */\nexport function parseTypeOutput(output: string, root: string): CheckRecord[] {\n const records: CheckRecord[] = [];\n let last: CheckRecord | undefined;\n for (const line of output.split('\\n')) {\n const match = TS_LINE.exec(line);\n if (match) {\n last = undefined;\n // Syntax errors of `.brm` files are reported by the compiler, with their codes.\n if (match[5]!.startsWith('BRM')) {\n continue;\n }\n const position = { line: Number(match[2]), column: Number(match[3]) };\n last = {\n file: toPosix(path.relative(root, path.resolve(root, match[1]!))),\n range: { start: position, end: position },\n severity: match[4] === 'warning' ? 'warning' : 'error',\n message: match[6]!,\n code: match[5]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n const global = TS_GLOBAL.exec(line);\n if (global) {\n last = {\n file: null,\n range: null,\n severity: global[1] === 'warning' ? 'warning' : 'error',\n message: global[3]!,\n code: global[2]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n // The lines under a message, indented, belong to it.\n if (last && /^\\s+\\S/.test(line)) {\n last.message += `\\n${line}`;\n }\n }\n return records;\n}\n\n/**\n * Runs `brumate-tsc`, the type checker of `.brm` files. It has no API that\n * gives its errors, so its output is read. Without the package, it gives a\n * note and no records.\n */\nfunction typeCheck(root: string, tscBin?: string): { records: CheckRecord[]; note?: string } {\n if (!existsSync(path.join(root, 'tsconfig.json'))) {\n return {\n records: [],\n note: 'The type check was skipped: there is no tsconfig.json in the current directory.',\n };\n }\n let bin: string;\n try {\n const require = createRequire(path.join(root, 'noop.js'));\n bin =\n tscBin ??\n path.join(path.dirname(require.resolve('@brumate/tsc/package.json')), 'bin/brumate-tsc.js');\n } catch {\n return {\n records: [],\n note: 'The type check was skipped: install @brumate/tsc to run it, or pass --no-types.',\n };\n }\n const result = spawnSync(process.execPath, [bin, '--noEmit', '--pretty', 'false'], {\n cwd: root,\n encoding: 'utf8',\n maxBuffer: 64 * 1024 * 1024,\n });\n const records = parseTypeOutput(`${result.stdout}\\n${result.stderr}`, root);\n function fail(message: string): void {\n records.push({\n file: null,\n range: null,\n severity: 'error',\n message,\n code: null,\n link: null,\n source: 'typescript',\n });\n }\n if (result.error) {\n // The process did not start, ran too long for a timeout, or printed more than maxBuffer.\n fail(`The type check did not finish: ${result.error.message}`);\n } else if (result.signal) {\n fail(`The type check was stopped by ${result.signal}`);\n } else if (result.status !== 0 && errorCount(records) === 0) {\n // A failure that has no error line of TypeScript, such as an unreadable tsconfig.json. A\n // failure of syntax errors only is reported by the compiler.\n const text = `${result.stdout}${result.stderr}`.trim();\n if (!/error BRM\\d*:/.test(text)) {\n fail(text || `The type check ended with status ${result.status}`);\n }\n }\n return { records };\n}\n\n/** Finds the calls of `bridge` in scripts that are not module-level exports. */\nasync function checkScripts(root: string, paths: string[]): Promise<CheckRecord[]> {\n const files = new Set<string>();\n if (paths.length === 0) {\n for (const file of await findScripts(root, defaultExclude)) {\n files.add(file);\n }\n }\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n if (statSync(absolute).isDirectory()) {\n for (const file of await findScripts(absolute, defaultExclude)) {\n files.add(file);\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(absolute)) {\n files.add(toPosix(absolute));\n }\n }\n const entry = findError(BRIDGE_EXPORT);\n const records: CheckRecord[] = [];\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n for (const { call, exported } of scriptBridges(source, file)) {\n if (exported === undefined) {\n const start = getLocation(source, call.start);\n records.push({\n file: toPosix(path.relative(root, file)),\n range: { start, end: getLocation(source, call.end) },\n severity: 'error',\n message: BRIDGE_EXPORT,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n }\n }\n return records;\n}\n\n/** Compiles every `.brm` file under the root, and runs the type checker. */\nexport async function check(root: string, options: CheckOptions = {}): Promise<CheckResult> {\n const records: CheckRecord[] = [];\n // A path that does not exist is a problem of its own. The others are still checked.\n const paths: string[] = [];\n for (const target of options.paths ?? []) {\n if (existsSync(path.resolve(root, target))) {\n paths.push(target);\n } else {\n records.push({\n file: toPosix(target),\n range: null,\n severity: 'error',\n message: 'This file or directory does not exist',\n code: null,\n link: null,\n source: 'brumate',\n });\n }\n }\n const missingOnly = paths.length === 0 && (options.paths?.length ?? 0) > 0;\n const { sources, targets } = missingOnly\n ? { sources: new Map<string, string>(), targets: [] }\n : await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const packages = findPackages(root);\n for (const file of targets) {\n const parents = props.get(file);\n records.push(\n ...checkFile(\n sources.get(file)!,\n toPosix(path.relative(root, file)),\n file,\n parents && new Set(parents.keys()),\n packages,\n ),\n );\n }\n\n if (!missingOnly) {\n records.push(...(await checkScripts(root, paths)));\n }\n\n const notes: string[] = [];\n if (options.types !== false) {\n const types = typeCheck(root, options.tscBin);\n records.push(...types.records);\n if (types.note) {\n notes.push(types.note);\n }\n }\n return { records, notes };\n}\n\n/** One line for a person: `file:line:column: error BRM012: message`. */\nexport function formatRecord(record: CheckRecord): string {\n const place = record.file\n ? `${record.file}${record.range ? `:${record.range.start.line}:${record.range.start.column}` : ''}: `\n : '';\n const code = record.code ? ` ${record.code}` : '';\n const link = record.link ? `\\n ${record.link}` : '';\n return `${place}${record.severity}${code}: ${record.message}${link}`;\n}\n","#!/usr/bin/env node\nimport { cp, readdir } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { check, errorCount, formatRecord } from './check-command.ts';\nimport { CompileError } from './compile.ts';\nimport { collectSources } from './files.ts';\nimport { inspect } from './inspect.ts';\nimport type { InspectReport } from './inspect.ts';\nimport { analyzeProjectProps } from './project.ts';\n\nconst USAGE = `Usage: brumate inspect [--json] [files or directories]\n\nShows what each component ships to the client, and why.\nWithout paths, inspects every .brm file under the current directory.\n\n brumate check [--json] [--no-types] [files or directories]\n\nCompiles every .brm file and type-checks the project with brumate-tsc.\nPrints each problem with its place, its code and a link to the docs.\nWith --json, prints one JSON object per line. Exits with 1 on an error.\n\n brumate skill [folder]\n\nCopies the skill for .brm files into folder/brumate, for coding agents.\nAlso copies each skill in the skills folder of the installed @brumate/*\npackages, such as folder/brumate-ui. The folder defaults to .claude/skills.`;\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\n/** Shows parent files relative to the current directory. */\nfunction relativeParents(\n parents: Map<string, Set<string>>,\n root: string,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [prop, files] of parents) {\n const relative = new Set<string>();\n for (const file of files) {\n relative.add(toPosix(path.relative(root, file)));\n }\n result.set(prop, relative);\n }\n return result;\n}\n\nasync function inspectCommand(args: string[]): Promise<number> {\n const json = args.includes('--json');\n const paths: string[] = [];\n for (const arg of args) {\n if (arg !== '--json') {\n paths.push(arg);\n }\n }\n const root = process.cwd();\n\n // Props are analyzed across every file under the current directory.\n const { sources, targets } = await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const reports: InspectReport[] = [];\n const texts: string[] = [];\n let failed = false;\n for (const file of targets) {\n const source = sources.get(file)!;\n const filename = toPosix(path.relative(root, file));\n try {\n const parents = props.get(file);\n const result = inspect(source, {\n filename,\n liveProps: parents && new Set(parents.keys()),\n parents: parents && relativeParents(parents, root),\n });\n reports.push(result.report);\n texts.push(result.text);\n } catch (error) {\n if (!(error instanceof CompileError)) {\n throw error;\n }\n failed = true;\n console.error(error.message);\n }\n }\n console.log(json ? JSON.stringify(reports, null, 2) : texts.join('\\n\\n'));\n return failed ? 1 : 0;\n}\n\nasync function checkCommand(args: string[]): Promise<number> {\n const flags = new Set(['--json', '--no-types']);\n const paths: string[] = [];\n for (const arg of args) {\n if (!arg.startsWith('-')) {\n paths.push(arg);\n } else if (!flags.has(arg)) {\n console.error(`brumate check does not know ${arg}\\n\\n${USAGE}`);\n return 1;\n }\n }\n const { records, notes } = await check(process.cwd(), {\n paths,\n types: !args.includes('--no-types'),\n });\n const json = args.includes('--json');\n for (const record of records) {\n console.log(json ? JSON.stringify(record) : formatRecord(record));\n }\n for (const note of notes) {\n console.error(note);\n }\n const errors = errorCount(records);\n if (!json) {\n console.log(errors === 0 ? 'No errors.' : `${errors} ${errors === 1 ? 'error' : 'errors'}.`);\n }\n return errors === 0 ? 0 : 1;\n}\n\n/** Lists the skill folders of the @brumate/* packages in node_modules, from the current directory up. */\nasync function findPackageSkills(start: string): Promise<Map<string, string>> {\n // The name brumate is the skill of this package. A package never replaces it.\n const found = new Map<string, string>();\n const warned = new Set<string>();\n let directory = start;\n while (true) {\n const scope = path.join(directory, 'node_modules', '@brumate');\n // oxlint-disable-next-line no-await-in-loop -- The walk goes up in order, so the nearest node_modules wins.\n const packages = await readdir(scope).catch(() => []);\n for (const name of packages) {\n const root = path.join(scope, name, 'skills');\n // oxlint-disable-next-line no-await-in-loop -- Same walk, in order.\n const skills = await readdir(root, { withFileTypes: true }).catch(() => []);\n for (const skill of skills) {\n if (!skill.isDirectory()) {\n continue;\n }\n if (skill.name === 'brumate') {\n if (!warned.has(name)) {\n warned.add(name);\n console.error(`@brumate/${name} has a skill named brumate, which is not copied.`);\n }\n } else if (!found.has(skill.name)) {\n found.set(skill.name, path.join(root, skill.name));\n }\n }\n }\n const parent = path.dirname(directory);\n if (parent === directory) {\n return found;\n }\n directory = parent;\n }\n}\n\nasync function skillCommand(args: string[]): Promise<number> {\n if (args.length > 1 || args[0]?.startsWith('-')) {\n console.error(`brumate skill takes one folder, not ${args.join(' ')}\\n\\n${USAGE}`);\n return 1;\n }\n const folder = path.resolve(args[0] ?? '.claude/skills');\n const target = path.join(folder, 'brumate');\n // The skill is in the package, next to dist and src.\n const source = fileURLToPath(new URL('../skills/brumate', import.meta.url));\n await cp(source, target, { recursive: true, force: true });\n console.log(`Copied the skill to ${path.relative(process.cwd(), target) || '.'}`);\n\n // Each @brumate package that has skills adds them, so they match its version.\n const copies: Promise<void>[] = [];\n for (const [name, from] of await findPackageSkills(process.cwd())) {\n const to = path.join(folder, name);\n // The line prints once the copy is done, so a failed copy shows no success.\n copies.push(\n cp(from, to, { recursive: true, force: true }).then(() => {\n console.log(`Copied the skill to ${path.relative(process.cwd(), to) || '.'}`);\n }),\n );\n }\n await Promise.all(copies);\n return 0;\n}\n\nasync function main(args: string[]): Promise<number> {\n const [command, ...rest] = args;\n if (command === 'skill') {\n return skillCommand(rest);\n }\n if (command === 'check') {\n return checkCommand(rest);\n }\n if (command === 'inspect') {\n return inspectCommand(rest);\n }\n console.log(USAGE);\n return command === undefined || command === '--help' ? 0 : 1;\n}\n\nprocess.exitCode = await main(process.argv.slice(2));\n"],"mappings":";;;;;;;;;;;;AAuDA,SAAgB,WAAW,SAAgC;CACzD,IAAI,QAAQ;CACZ,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,aAAa,SACtB;CAGJ,OAAO;AACT;AAEA,SAASA,UAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;AAEA,SAAS,eAAe,QAAgB,MAAc,YAAqC;CACzF,MAAM,QAAQ,WAAW,aAAa,UAAU,UAAU,WAAW,OAAO,IAAI,KAAA;CAEhF,MAAM,QAAQ,KAAK,IAAI,WA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a,YAAY,WAAW,IAAI;AAC7D;AAEA,QAAQ,WAAW,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { t as Context } from "./context-BNgBXVUQ.js";
2
2
  import { a as PageState, c as ScopeId, m as Raw, n as ElementReference, t as Binding } from "./shared-CuJdWifz.js";
3
- import { a as Store } from "./store-xlTzAM_r.js";
3
+ import { a as Store } from "./store-9_oa0HG1.js";
4
4
  import { r as SerialEntry } from "./values-B8C7CLvG.js";
5
- import { M as SearchParamOptions } from "./signals-DBnq9QRW.js";
5
+ import { M as SearchParamOptions } from "./signals-7VVD9C_H.js";
6
6
  //#region src/runtime/navigate.d.ts
7
7
  /** What the devtools learn of a navigation. See `DevtoolsHooks.navigated`. */
8
8
  interface NavigationReport {
@@ -71,9 +71,9 @@ interface HiddenBody {
71
71
  //#region src/runtime/client/children.d.ts
72
72
  /**
73
73
  * A call of a `#template` of the file, which an insert can update in place. `render` is the
74
- * template's code, and `owner` the scope that holds the template. The call finds its contexts
75
- * where the template is written, as the output of a template does, so it does not render as
76
- * children of the owner.
74
+ * template's code, and `owner` the scope that holds the template. The call renders as children
75
+ * of its owner, where the component that gets it inserts it, so it reads the contexts there, as
76
+ * on the server.
77
77
  */
78
78
  declare function templateCall(ref: string, owner: Scope | undefined, render: (...args: unknown[]) => unknown, args: unknown[]): TemplateCall;
79
79
  /** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
@@ -97,7 +97,7 @@ declare class TemplateCall extends Children {
97
97
  /** The scope of the component that wrote the template. */
98
98
  readonly owner: Scope | undefined;
99
99
  readonly args: unknown[];
100
- constructor(ref: string, owner: Scope | undefined, args: unknown[], html: (at?: Scope) => string, lexical?: boolean);
100
+ constructor(ref: string, owner: Scope | undefined, args: unknown[], html: (at?: Scope) => string);
101
101
  }
102
102
  /** The children of a component that the client renders. See `Children`. */
103
103
  declare function children(from: Scope | ScopeId | undefined, html: () => string | DocumentFragment): Children;
@@ -123,12 +123,19 @@ declare function dynamicNodes(tag: unknown, attributes: Record<string, unknown>,
123
123
  declare function foreignNodes(foreign: string, tag: unknown, attributes: Record<string, unknown>, inner: Raw | Children | undefined, ctx?: unknown, scope?: Scope | number, ref?: unknown): string | Node;
124
124
  declare function dynamic(tag: unknown, attributes: Record<string, unknown>, inner: Raw | Children | undefined, _ctx?: unknown, scope?: Scope | number, ref?: unknown): string;
125
125
  /**
126
- * Computes a memo of a render. A promise or a stream is marked, so `setSlots` starts its load
127
- * once the scope is in the page. A throw is held in a `MemoError`, as the server holds the error
126
+ * Marks the value of a memo of a render that cannot hold an error: a promise or a stream is
127
+ * loaded by `setSlots` once the scope is in the page.
128
+ */
129
+ declare function memoNow(value: unknown): unknown;
130
+ /**
131
+ * Computes a memo of a render. A throw is held in a `MemoError`, as the server holds the error
128
132
  * of a memo until a read.
129
133
  */
130
134
  declare function renderMemo(compute: () => unknown): unknown;
131
- /** Reads a memo of a render: the error that a throw held is thrown at the read. */
135
+ /**
136
+ * Reads a memo of a render: the error that a throw held is thrown at the read. A memo that is
137
+ * still loading stops the code that reads it, which waits for the memo.
138
+ */
132
139
  declare function readMemo(value: unknown): unknown;
133
140
  declare function setSlots(id: ScopeId, values: unknown[]): void;
134
141
  declare function setItem(id: ScopeId, value: unknown): void;
@@ -174,6 +181,8 @@ interface Scope {
174
181
  /** The component ID, for a component's root scope. */
175
182
  m?: string;
176
183
  s: unknown[];
184
+ /** True once the scope is removed, so a wait that ends later computes nothing. */
185
+ gone?: boolean;
177
186
  /** The item of a list item scope. */
178
187
  i?: unknown;
179
188
  c?: Record<number, ScopeId>;
@@ -456,6 +465,12 @@ declare function attempt(body: () => Out): DocumentFragment;
456
465
  * A scope that goes during the wait ends it with `leave`.
457
466
  */
458
467
  declare function fillSettled(id: ScopeId | Scope, values: unknown[], write: (...values: unknown[]) => void): void;
468
+ /**
469
+ * A write of cloned markup whose values come from code that can read a memo that is still
470
+ * loading, such as a block header or a prop that calls a function. The write waits for the memo,
471
+ * and runs again with its value. It counts in the boundary of the render, as `fillSettled` does.
472
+ */
473
+ declare function fillPend(id: ScopeId | Scope, write: () => void): void;
459
474
  /**
460
475
  * A value of markup that the browser writes, in text or an attribute, which can be a promise.
461
476
  * A value that is not one is written at once. A promise counts in the boundary of the render, as
@@ -596,7 +611,11 @@ interface Parking {
596
611
  }
597
612
  //#endregion
598
613
  //#region src/runtime/client/page.d.ts
599
- /** Sets a style variable on the top-level elements of a component instance. */
614
+ /**
615
+ * Sets a style variable on the top-level elements of a component or block instance. `b-v` lists
616
+ * the IDs of the instances whose variables an element carries, since an element at the top level
617
+ * of a block inside another carries both.
618
+ */
600
619
  declare function setVar(scope: Scope, name: string, value: unknown): void;
601
620
  /**
602
621
  * Warns in development that the browser renders a `#defer` block of a
@@ -771,6 +790,13 @@ declare function unreadMemo(scope: Scope | ScopeId, value: unknown): void;
771
790
  * keeps its value, and `pending` is true. Only the latest load is written.
772
791
  */
773
792
  declare function asyncMemo(scope: Scope, slot: number, promise: Promise<unknown>): number;
793
+ /**
794
+ * Computes a value of a render that can read a memo that is still loading, as an update does:
795
+ * the value is a promise that computes again once the memo settles, so what reads it waits.
796
+ * A second stop at the same wait is no wait for it, so it throws. A scope that goes, `owner`,
797
+ * computes nothing more. The scopes and the work that a stopped compute started are dropped.
798
+ */
799
+ declare function pend(compute: () => unknown, owner?: Scope | ScopeId, last?: PromiseLike<unknown>): unknown;
774
800
  /**
775
801
  * `$resolve(memo, { timeout, signal })`: resolves with the value of the memo once it is no longer
776
802
  * pending, also after a load that its inputs started. `isLoading` tells whether the memo or a
@@ -825,5 +851,5 @@ declare const loader: {
825
851
  updateRoute: typeof updateRoute;
826
852
  };
827
853
  //#endregion
828
- export { list as $, hooks as $t, nodes as A, leavePage as At, descendants as B, consumeContext as Bt, clone as C, rekey as Cn, wait as Ct, keepText as D, dispose as Dt, keep as E, NavigationReport as En, nameComment as Et, setOn as F, handle as Ft, sink as G, toStore as Gt, makeId as H, provideValue as Ht, setSpread as I, handlerProp as It, addHead as J, CoreOptions as Jt, prop as K, updateRoute as Kt, template as L, rpc as Lt, setAttr as M, remount as Mt, setAttrText as N, removeRoot as Nt, listNodes as O, forget as Ot, setContent as P, action as Pt, setVar as Q, build as Qt, afterInsert as R, spread as Rt, branchNodes as S, offscreen as Sn, started as St, fillList as T, retag as Tn, loadModule as Tt, removeScope as U, setGlobal as Ut, getScope as V, consumeStore as Vt, setOwner as W, storeUpdate as Wt, addStyle as X, DevtoolsHooks as Xt, addPortal as Y, DEVTOOLS as Yt, deferInBrowser as Z, Scope as Zt, updated as _, templateCall as _n, fillSpread as _t, cells as a, componentNodes as an, content as at, searchParam as b, fill as bn, loading as bt, get as c, elementAt as cn, text as ct, pending as d, readMemo as dn, track as dt, rpcPrefix as en, toList as et, resolve as f, renderMemo as fn, after as ft, update as g, insert as gn, fillSettled as gt, unreadMemo as h, children as hn, fillAttrs as ht, bindings as i, component as in, attrs as it, putText as j, leaveRoutes as jt, markBlock as k, init as kt, isBound as l, foreignNodes as ln, writeText as lt, timed as m, setSlots as mn, countLoads as mt, asyncMemo as n, skew as nn, windowStart as nt, effect as o, dynamic as on, portalTo as ot, set as p, setItem as pn, attempt as pt, spreadProps as q, ClientModule as qt, binding as r, Component as rn, attr as rt, gate as s, dynamicNodes as sn, restRef as st, loader as t, scopes as tn, windowList as tt, memo as u, place as un, guess as ut, title as v, HiddenBody as vn, fillValue as vt, fillBranch as w, reset as wn, fail as wt, appendText as x, held as xn, reveal as xt, paramEffect as y, branch as yn, keepValue as yt, createScope as z, submitAction as zt };
829
- //# sourceMappingURL=client-DnFF9_lv.d.ts.map
854
+ export { setVar as $, Scope as $t, markBlock as A, forget as At, createScope as B, spread as Bt, branchNodes as C, fill as Cn, reveal as Ct, keep as D, reset as Dn, loadModule as Dt, fillList as E, rekey as En, fail as Et, setContent as F, removeRoot as Ft, setOwner as G, setGlobal as Gt, getScope as H, consumeContext as Ht, setOn as I, action as It, spreadProps as J, updateRoute as Jt, sink as K, storeUpdate as Kt, setSpread as L, handle as Lt, putText as M, leavePage as Mt, setAttr as N, leaveRoutes as Nt, keepText as O, retag as On, nameComment as Ot, setAttrText as P, remount as Pt, deferInBrowser as Q, DevtoolsHooks as Qt, template as R, handlerProp as Rt, appendText as S, branch as Sn, loading as St, fillBranch as T, offscreen as Tn, wait as Tt, makeId as U, consumeStore as Ut, descendants as V, submitAction as Vt, removeScope as W, provideValue as Wt, addPortal as X, CoreOptions as Xt, addHead as Y, ClientModule as Yt, addStyle as Z, DEVTOOLS as Zt, update as _, setSlots as _n, fillPend as _t, cells as a, Component as an, attrs as at, paramEffect as b, templateCall as bn, fillValue as bt, get as c, dynamic as cn, restRef as ct, pend as d, foreignNodes as dn, guess as dt, build as en, list as et, pending as f, memoNow as fn, track as ft, unreadMemo as g, setItem as gn, fillAttrs as gt, timed as h, renderMemo as hn, countLoads as ht, bindings as i, skew as in, attr as it, nodes as j, init as jt, listNodes as k, NavigationReport as kn, dispose as kt, isBound as l, dynamicNodes as ln, text as lt, set as m, readMemo as mn, attempt as mt, asyncMemo as n, rpcPrefix as nn, windowList as nt, effect as o, component as on, content as ot, resolve as p, place as pn, after as pt, prop as q, toStore as qt, binding as r, scopes as rn, windowStart as rt, gate as s, componentNodes as sn, portalTo as st, loader as t, hooks as tn, toList as tt, memo as u, elementAt as un, writeText as ut, updated as v, children as vn, fillSettled as vt, clone as w, held as wn, started as wt, searchParam as x, HiddenBody as xn, keepValue as xt, title as y, insert as yn, fillSpread as yt, afterInsert as z, rpc as zt };
855
+ //# sourceMappingURL=client-4eabQtYJ.d.ts.map
@@ -1,7 +1,8 @@
1
1
  import { C as spread$1, T as textValue, b as ownValue, f as handlerEntry, g as isRaw, n as VOID_ELEMENTS, o as attributeText, p as insertValue, r as actionAttributes, s as bindEntry, v as onAttribute, y as onValue } from "./html-Cf5uKhLs.js";
2
2
  import { _ as HAS_TITLES, a as HAS_CHILDREN, c as HAS_FIELDS, d as HAS_LOADING, f as HAS_ROOT_WAIT, g as HAS_TEMPLATES, h as HAS_STORES, i as HAS_BRIDGES, l as HAS_LATE_MARKUP, n as HAS_BINDINGS, o as HAS_CLIENT_HTML, p as HAS_ROUTES, s as HAS_DYNAMIC, v as HAS_TRIES, y as HAS_WINDOWS } from "./features-DwMYKBIC.js";
3
- import { a as findStored, f as sameData, h as setBridgeLoader, n as Store, o as isBridged, p as sendStore, u as isStore } from "./store-BIBAYZo-.js";
4
- import { E as stateValues, O as useSerialEntry, S as mergeHandlers, T as parseId, _ as isAsyncIterable, a as Binding, b as isSlotReference, c as ElementReference, d as PARTS, g as gateValue, h as addEntryHandlers, l as FunctionReference, m as SlotReference, r as writeParam, s as ChildrenReference, t as readParam, u as MemoError, v as isBinding, x as madeStores, y as isPropWrapper } from "./search-params-C64liRBj.js";
3
+ import { d as isStore, g as setBridgeLoader, m as sendStore, n as Store, o as findStored, p as sameData, s as isBridged } from "./store-Cy4EEyZ7.js";
4
+ import { S as stateValues, _ as madeStores, a as FunctionReference, d as addEntryHandlers, f as gateValue, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, o as MemoError, p as isAsyncIterable, r as ChildrenReference, s as PARTS, t as Binding, u as SlotReference, v as mergeHandlers, w as useSerialEntry, x as parseId } from "./shared-CX_YacDm.js";
5
+ import { r as writeParam, t as readParam } from "./search-params-Wg-0FsMj.js";
5
6
  import { i as missingContext, n as ROUTE_KEY, t as NAVIGATION_KEY } from "./context-CU4Fpn5a.js";
6
7
  import { t as trustedHTML } from "./trusted-g_zUJbh2.js";
7
8
  import { t as loadOnce } from "./skew-CwmX_GFI.js";
@@ -396,6 +397,7 @@ function removeScope(scope) {
396
397
  }
397
398
  if (scope.h) hiding?.bodies.delete(scope.h);
398
399
  scopes.delete(scope.id);
400
+ scope.gone = true;
399
401
  for (const [check, owner] of waiters) if (owner === scope) check();
400
402
  scope.p?.children?.delete(scope);
401
403
  scope.o?.owned?.delete(scope);
@@ -861,12 +863,12 @@ function templateReference(ref, scope) {
861
863
  }
862
864
  /**
863
865
  * A call of a `#template` of the file, which an insert can update in place. `render` is the
864
- * template's code, and `owner` the scope that holds the template. The call finds its contexts
865
- * where the template is written, as the output of a template does, so it does not render as
866
- * children of the owner.
866
+ * template's code, and `owner` the scope that holds the template. The call renders as children
867
+ * of its owner, where the component that gets it inserts it, so it reads the contexts there, as
868
+ * on the server.
867
869
  */
868
870
  function templateCall(ref, owner, render, args) {
869
- return new TemplateCall(ref, owner, args, (at) => insert(render(...args), void 0, at), true);
871
+ return new TemplateCall(ref, owner, args, (at) => insert(render(...args), void 0, at));
870
872
  }
871
873
  /** Renders a value inserted in markup. Children render here, at `scope`, for their contexts. */
872
874
  function insert(value, _ctx, scope) {
@@ -936,8 +938,8 @@ var TemplateCall = class extends Children {
936
938
  /** The scope of the component that wrote the template. */
937
939
  owner;
938
940
  args;
939
- constructor(ref, owner, args, html, lexical = false) {
940
- super(lexical ? void 0 : owner, html);
941
+ constructor(ref, owner, args, html) {
942
+ super(owner, html);
941
943
  this.ref = ref;
942
944
  this.owner = owner;
943
945
  this.args = args;
@@ -1114,9 +1116,14 @@ async function catchInto(owner, body, module, [, anchor, , fallback, kinds, hold
1114
1116
  function get(scope, slot) {
1115
1117
  if (dirty.size > 0 && !draining) settle(scope);
1116
1118
  const value = scope.s[slot];
1117
- if (value === void 0 && exempt > 0 && !(slot in scope.s)) throw new NotReady(Promise.resolve());
1119
+ if (value === void 0 && (exempt > 0 || reading > 0) && !(slot in scope.s)) throw new NotReady(unreached);
1118
1120
  if (value instanceof Promise && !scope.plain?.has(slot)) {
1119
1121
  if (computing > 0) throw new NotReady(value);
1122
+ if (reading > 0 && loadingValues.has(value)) {
1123
+ const result = memoResults.get(value);
1124
+ if (result) return result.value;
1125
+ throw new NotReady(value);
1126
+ }
1120
1127
  if (loadingValues.has(value)) {
1121
1128
  if (runningEffects > 0) throw new NotReady(value);
1122
1129
  if (exempt === 0) throw new Error("This value is still loading. Wait for it with await $resolve(memo), or check $isPending(memo) first");
@@ -1369,6 +1376,41 @@ var NotReady = class extends Error {
1369
1376
  this.source = source;
1370
1377
  }
1371
1378
  };
1379
+ /** The values of the promises of memos of a render that settled, which a read of the memo gives. */
1380
+ const memoResults = /* @__PURE__ */ new WeakMap();
1381
+ let reading = 0;
1382
+ function isReading() {
1383
+ return reading > 0;
1384
+ }
1385
+ const unreached = Promise.resolve();
1386
+ /**
1387
+ * Computes a value of a render that can read a memo that is still loading, as an update does:
1388
+ * the value is a promise that computes again once the memo settles, so what reads it waits.
1389
+ * A second stop at the same wait is no wait for it, so it throws. A scope that goes, `owner`,
1390
+ * computes nothing more. The scopes and the work that a stopped compute started are dropped.
1391
+ */
1392
+ function pend(compute, owner, last) {
1393
+ const at = owner === void 0 || typeof owner === "object" ? owner : scopes.get(owner) ?? findRendered(owner);
1394
+ const made = rendered.length;
1395
+ const queued = afterInsert.length;
1396
+ reading++;
1397
+ try {
1398
+ return compute();
1399
+ } catch (error) {
1400
+ if (error instanceof NotReady && error.source !== last) {
1401
+ rendered.length = made;
1402
+ afterInsert.length = queued;
1403
+ const source = error.source;
1404
+ return Promise.resolve(source).then(() => at?.gone ? void 0 : pend(compute, at, source));
1405
+ }
1406
+ throw error;
1407
+ } finally {
1408
+ reading--;
1409
+ }
1410
+ }
1411
+ function findRendered(id) {
1412
+ return rendered.find((scope) => scope.id === id);
1413
+ }
1372
1414
  let computing = 0;
1373
1415
  let origin;
1374
1416
  let viaContext = false;
@@ -2194,12 +2236,12 @@ function action(name, id, method, result) {
2194
2236
  * call loads, so the core holds only this.
2195
2237
  */
2196
2238
  function submitAction(form, submitter) {
2197
- import("./rpc-BAKbRWOT.js").then((module) => module.sendAction(form, submitter));
2239
+ import("./rpc-kVB0Ujdx.js").then((module) => module.sendAction(form, submitter));
2198
2240
  }
2199
2241
  /** Calls a server function. */
2200
2242
  async function rpc(id, args) {
2201
2243
  const signal = memoSignal();
2202
- return track(import("./rpc-BAKbRWOT.js").then((module) => module.call(rpcPrefix, id, args, signal)));
2244
+ return track(import("./rpc-kVB0Ujdx.js").then((module) => module.call(rpcPrefix, id, args, signal)));
2203
2245
  }
2204
2246
  /** A function prop rendered on the client calls the parent's exported handler. */
2205
2247
  function handlerProp(value, ref, scope, bound = [], modifiers) {
@@ -2906,23 +2948,36 @@ function dynamic(tag, attributes, inner, _ctx, scope, ref) {
2906
2948
  /** The promises and streams that `renderMemo` made, which `setSlots` loads as memos. */
2907
2949
  const memoLoads = /* @__PURE__ */ new WeakMap();
2908
2950
  /**
2909
- * Computes a memo of a render. A promise or a stream is marked, so `setSlots` starts its load
2910
- * once the scope is in the page. A throw is held in a `MemoError`, as the server holds the error
2951
+ * Marks the value of a memo of a render that cannot hold an error: a promise or a stream is
2952
+ * loaded by `setSlots` once the scope is in the page.
2953
+ */
2954
+ function memoNow(value) {
2955
+ if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
2956
+ if (isThenable(value)) value.then((result) => memoResults.set(value, { value: result }), noop$1);
2957
+ return value;
2958
+ }
2959
+ /**
2960
+ * Computes a memo of a render. A throw is held in a `MemoError`, as the server holds the error
2911
2961
  * of a memo until a read.
2912
2962
  */
2913
2963
  function renderMemo(compute) {
2914
- let value;
2915
2964
  try {
2916
- value = compute();
2965
+ return memoNow(pend(compute, rendered.at(-1)));
2917
2966
  } catch (error) {
2918
2967
  return new MemoError(error);
2919
2968
  }
2920
- if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
2921
- return value;
2922
2969
  }
2923
- /** Reads a memo of a render: the error that a throw held is thrown at the read. */
2970
+ /**
2971
+ * Reads a memo of a render: the error that a throw held is thrown at the read. A memo that is
2972
+ * still loading stops the code that reads it, which waits for the memo.
2973
+ */
2924
2974
  function readMemo(value) {
2925
2975
  if (value instanceof MemoError) throw value.error;
2976
+ if (isThenable(value) && memoLoads.has(value)) {
2977
+ const result = memoResults.get(value);
2978
+ if (result) return result.value;
2979
+ if (isReading()) throw new NotReady(value);
2980
+ }
2926
2981
  return value;
2927
2982
  }
2928
2983
  function setSlots(id, values) {
@@ -3126,7 +3181,7 @@ const writtenInserts = /* @__PURE__ */ new WeakSet();
3126
3181
  function renderedTemplate(call, at, k, first, end) {
3127
3182
  if (k === void 0) return;
3128
3183
  let found;
3129
- for (const scope of scopes.values()) if (call.owner && scope.p === call.owner && scope.k === k && (scope.t === at || scope.l === at && inRange(scope, first, end))) {
3184
+ for (const scope of scopes.values()) if (call.owner && scope.p === call.owner && scope.k === k && (scope.t === at || scope.l === at) && inRange(scope, first, end)) {
3130
3185
  if (found) return;
3131
3186
  found = scope;
3132
3187
  }
@@ -3135,17 +3190,39 @@ function renderedTemplate(call, at, k, first, end) {
3135
3190
  scope: found
3136
3191
  };
3137
3192
  }
3138
- /** True if an anchor of the scope, a comment, an element or a kept node, is in the range. */
3193
+ /**
3194
+ * True if the range holds markup of the scope or of a scope inside it: an anchor, a comment or an
3195
+ * element, or a kept node. A template that only renders a component has no anchor of its own, so
3196
+ * the anchors of the scopes it made count too.
3197
+ */
3139
3198
  function inRange(scope, first, end) {
3140
- const comment = `t${scope.id}:`;
3141
- const element = `${scope.id}:`;
3199
+ const kept = keptNodes(scope, []);
3142
3200
  for (let node = first; node && node !== end; node = node.nextSibling) {
3143
3201
  const walker = document.createTreeWalker(node, 129);
3144
- for (let item = node; item; item = walker.nextNode()) if (item.nodeType === 8 ? item.data.startsWith(comment) : item.nodeType === 1 && item.getAttribute("b-b")?.startsWith(element)) return true;
3145
- for (const kept of scope.n ?? []) if (kept && (kept === node || node.contains(kept))) return true;
3202
+ for (let item = node; item; item = walker.nextNode()) {
3203
+ let id;
3204
+ if (item.nodeType === 8) {
3205
+ const data = item.data;
3206
+ id = MARKER.test(data) ? data.slice(1).split(":")[0] : void 0;
3207
+ } else if (item.nodeType === 1) id = item.getAttribute("b-b")?.split(":")[0];
3208
+ if (id !== void 0 && isInside(scopes.get(parseId(id)), scope)) return true;
3209
+ }
3210
+ for (const item of kept) if (item === node || node.contains(item)) return true;
3146
3211
  }
3147
3212
  return false;
3148
3213
  }
3214
+ /** True if `found` is `scope` or a scope that it made, by its parents and owners. */
3215
+ function isInside(found, scope) {
3216
+ for (let current = found; current; current = current.p ?? current.o) if (current === scope) return true;
3217
+ return false;
3218
+ }
3219
+ /** Adds the nodes that the scope and the scopes inside it keep, of markup the browser cloned. */
3220
+ function keptNodes(scope, nodes) {
3221
+ for (const node of scope.n ?? []) if (node) nodes.push(node);
3222
+ for (const child of scope.children ?? []) keptNodes(child, nodes);
3223
+ for (const child of scope.owned ?? []) keptNodes(child, nodes);
3224
+ return nodes;
3225
+ }
3149
3226
  /** The `value` and `checked` that updates last wrote to each field. */
3150
3227
  const fieldValues = /* @__PURE__ */ new WeakMap();
3151
3228
  function setAttribute(element, name, value, spread = false) {
@@ -3407,6 +3484,17 @@ function fillSettled(id, values, write) {
3407
3484
  }, (error) => failOnce(scope, own, error));
3408
3485
  }
3409
3486
  /**
3487
+ * A write of cloned markup whose values come from code that can read a memo that is still
3488
+ * loading, such as a block header or a prop that calls a function. The write waits for the memo,
3489
+ * and runs again with its value. It counts in the boundary of the render, as `fillSettled` does.
3490
+ */
3491
+ function fillPend(id, write) {
3492
+ const waiting = pend(() => {
3493
+ write();
3494
+ }, id);
3495
+ if (isThenable(waiting)) fillSettled(id, [waiting], noop$1);
3496
+ }
3497
+ /**
3410
3498
  * A value of markup that the browser writes, in text or an attribute, which can be a promise.
3411
3499
  * A value that is not one is written at once. A promise counts in the boundary of the render, as
3412
3500
  * a memo of `fillSettled` does, and `write` gets its value once it settles. The scope keeps the
@@ -4436,10 +4524,39 @@ function markInPlace(kept) {
4436
4524
  }
4437
4525
  //#endregion
4438
4526
  //#region src/runtime/client/page.ts
4439
- /** Sets a style variable on the top-level elements of a component instance. */
4527
+ /** The elements that carry each ID in `b-v`, built from one pass over the page. */
4528
+ let carriers;
4529
+ let watcher;
4530
+ /** The elements of a scope. The index is rebuilt after the page adds, removes or marks elements. */
4531
+ function carriersOf(id) {
4532
+ watcher ??= new MutationObserver(() => {
4533
+ carriers = void 0;
4534
+ });
4535
+ if (!carriers || watcher.takeRecords().length > 0) {
4536
+ carriers = /* @__PURE__ */ new Map();
4537
+ watcher.disconnect();
4538
+ watcher.observe(document, {
4539
+ subtree: true,
4540
+ childList: true,
4541
+ attributes: true,
4542
+ attributeFilter: ["b-v"]
4543
+ });
4544
+ for (const element of document.querySelectorAll("[b-v]")) for (const token of element.getAttribute("b-v").split(" ")) {
4545
+ const list = carriers.get(token);
4546
+ if (list) list.push(element);
4547
+ else carriers.set(token, [element]);
4548
+ }
4549
+ }
4550
+ return carriers.get(String(id)) ?? [];
4551
+ }
4552
+ /**
4553
+ * Sets a style variable on the top-level elements of a component or block instance. `b-v` lists
4554
+ * the IDs of the instances whose variables an element carries, since an element at the top level
4555
+ * of a block inside another carries both.
4556
+ */
4440
4557
  function setVar(scope, name, value) {
4441
4558
  const css = value === null || value === void 0 || value === false ? "" : String(value);
4442
- for (const element of document.querySelectorAll(`[b-v="${scope.id}"]`)) if (element.style.getPropertyValue(name) !== css) element.style.setProperty(name, css);
4559
+ for (const element of carriersOf(scope.id)) if (element.style.getPropertyValue(name) !== css) element.style.setProperty(name, css);
4443
4560
  }
4444
4561
  /**
4445
4562
  * Warns in development that the browser renders a `#defer` block of a
@@ -4622,6 +4739,6 @@ const loader = {
4622
4739
  };
4623
4740
  function noop() {}
4624
4741
  //#endregion
4625
- export { branchNodes as $, fail as $t, started as A, consumeContext as At, spreadProps as B, cells as Bt, fillAttrs as C, handle as Ct, keepValue as D, submitAction as Dt, fillValue as E, spread as Et, portalTo as F, toStore as Ft, elementAt as G, memo as Gt, componentNodes as H, gate as Ht, restRef as I, updateRoute as It, readMemo as J, set as Jt, foreignNodes as K, pending as Kt, text as L, asyncMemo as Lt, attr as M, provideValue as Mt, attrs as N, setGlobal as Nt, loading as O, guess as Ot, content as P, storeUpdate as Pt, appendText as Q, updated as Qt, writeText as R, binding as Rt, countLoads as S, action as St, fillSpread as T, rpc as Tt, dynamic as U, get as Ut, component as V, effect as Vt, dynamicNodes as W, isBound as Wt, setItem as X, unreadMemo as Xt, renderMemo as Y, timed as Yt, setSlots as Z, update as Zt, rekey as _, rpcPrefix as _n, init as _t, addPortal as a, createScope as an, listNodes as at, after as b, remount as bt, setVar as c, makeId as cn, putText as ct, windowList as d, sink as dn, setContent as dt, children as en, clone as et, windowStart as f, nameComment as fn, setOn as ft, offscreen as g, hooks as gn, forget as gt, held as h, build as hn, dispose as ht, addHead as i, afterInsert as in, keepText as it, wait as j, consumeStore as jt, reveal as k, track as kt, list as l, removeScope as ln, setAttr as lt, fill as m, DEVTOOLS as mn, template as mt, paramEffect as n, templateCall as nn, fillList as nt, addStyle as o, descendants as on, markBlock as ot, branch as p, loadModule as pn, setSpread as pt, place as q, resolve as qt, searchParam as r, title as rn, keep as rt, deferInBrowser as s, getScope as sn, nodes as st, loader as t, insert as tn, fillBranch as tt, toList as u, setOwner as un, setAttrText as ut, reset as v, scopes as vn, leavePage as vt, fillSettled as w, handlerProp as wt, attempt as x, removeRoot as xt, retag as y, skew as yn, leaveRoutes as yt, prop as z, bindings as zt };
4742
+ export { setSlots as $, unreadMemo as $t, reveal as A, guess as At, prop as B, binding as Bt, fillAttrs as C, removeRoot as Ct, fillValue as D, rpc as Dt, fillSpread as E, handlerProp as Et, content as F, setGlobal as Ft, dynamicNodes as G, get as Gt, component as H, cells as Ht, portalTo as I, storeUpdate as It, memoNow as J, pend as Jt, elementAt as K, isBound as Kt, restRef as L, toStore as Lt, wait as M, consumeContext as Mt, attr as N, consumeStore as Nt, keepValue as O, spread as Ot, attrs as P, provideValue as Pt, setItem as Q, timed as Qt, text as R, updateRoute as Rt, countLoads as S, skew as Sn, remount as St, fillSettled as T, handle as Tt, componentNodes as U, effect as Ut, spreadProps as V, bindings as Vt, dynamic as W, gate as Wt, readMemo as X, resolve as Xt, place as Y, pending as Yt, renderMemo as Z, set as Zt, rekey as _, DEVTOOLS as _n, dispose as _t, addPortal as a, templateCall as an, keep as at, after as b, rpcPrefix as bn, leavePage as bt, setVar as c, createScope as cn, markBlock as ct, windowList as d, makeId as dn, setAttr as dt, update as en, appendText as et, windowStart as f, removeScope as fn, setAttrText as ft, offscreen as g, loadModule as gn, template as gt, held as h, nameComment as hn, setSpread as ht, addHead as i, insert as in, fillList as it, started as j, track as jt, loading as k, submitAction as kt, list as l, descendants as ln, nodes as lt, fill as m, sink as mn, setOn as mt, paramEffect as n, fail as nn, clone as nt, addStyle as o, title as on, keepText as ot, branch as p, setOwner as pn, setContent as pt, foreignNodes as q, memo as qt, searchParam as r, children as rn, fillBranch as rt, deferInBrowser as s, afterInsert as sn, listNodes as st, loader as t, updated as tn, branchNodes as tt, toList as u, getScope as un, putText as ut, reset as v, build as vn, forget as vt, fillPend as w, action as wt, attempt as x, scopes as xn, leaveRoutes as xt, retag as y, hooks as yn, init as yt, writeText as z, asyncMemo as zt };
4626
4743
 
4627
- //# sourceMappingURL=client-COm1iA6w.js.map
4744
+ //# sourceMappingURL=client-CwVcmymi.js.map