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,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 { qt as ClientModule } from "./client-Cq6aTiDs.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-BkUdiYOF.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-CGl5Y8q6.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-D5GtxwEQ.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":";;;;;;;;;;;AAuDA,SAAgB,WAAW,SAAgC;CACzD,IAAI,QAAQ;CACZ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,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,WAAW,MAAM,OAAO,OAAO,MAAM;CAG5D,OAAO;EACL;EACA,OAAO;GA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QAAQ,KAAK,MAAM,CAAC,CAAC"}
@@ -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";
@@ -2194,12 +2195,12 @@ function action(name, id, method, result) {
2194
2195
  * call loads, so the core holds only this.
2195
2196
  */
2196
2197
  function submitAction(form, submitter) {
2197
- import("./rpc-BAKbRWOT.js").then((module) => module.sendAction(form, submitter));
2198
+ import("./rpc-C1jYVNAe.js").then((module) => module.sendAction(form, submitter));
2198
2199
  }
2199
2200
  /** Calls a server function. */
2200
2201
  async function rpc(id, args) {
2201
2202
  const signal = memoSignal();
2202
- return track(import("./rpc-BAKbRWOT.js").then((module) => module.call(rpcPrefix, id, args, signal)));
2203
+ return track(import("./rpc-C1jYVNAe.js").then((module) => module.call(rpcPrefix, id, args, signal)));
2203
2204
  }
2204
2205
  /** A function prop rendered on the client calls the parent's exported handler. */
2205
2206
  function handlerProp(value, ref, scope, bound = [], modifiers) {
@@ -2906,19 +2907,23 @@ function dynamic(tag, attributes, inner, _ctx, scope, ref) {
2906
2907
  /** The promises and streams that `renderMemo` made, which `setSlots` loads as memos. */
2907
2908
  const memoLoads = /* @__PURE__ */ new WeakMap();
2908
2909
  /**
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
2910
+ * Marks the value of a memo of a render that cannot hold an error: a promise or a stream is
2911
+ * loaded by `setSlots` once the scope is in the page.
2912
+ */
2913
+ function memoNow(value) {
2914
+ if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
2915
+ return value;
2916
+ }
2917
+ /**
2918
+ * Computes a memo of a render. A throw is held in a `MemoError`, as the server holds the error
2911
2919
  * of a memo until a read.
2912
2920
  */
2913
2921
  function renderMemo(compute) {
2914
- let value;
2915
2922
  try {
2916
- value = compute();
2923
+ return memoNow(compute());
2917
2924
  } catch (error) {
2918
2925
  return new MemoError(error);
2919
2926
  }
2920
- if (isThenable(value) || isAsyncIterable(value)) memoLoads.set(value, (memoLoads.get(value) ?? 0) + 1);
2921
- return value;
2922
2927
  }
2923
2928
  /** Reads a memo of a render: the error that a throw held is thrown at the read. */
2924
2929
  function readMemo(value) {
@@ -4436,10 +4441,39 @@ function markInPlace(kept) {
4436
4441
  }
4437
4442
  //#endregion
4438
4443
  //#region src/runtime/client/page.ts
4439
- /** Sets a style variable on the top-level elements of a component instance. */
4444
+ /** The elements that carry each ID in `b-v`, built from one pass over the page. */
4445
+ let carriers;
4446
+ let watcher;
4447
+ /** The elements of a scope. The index is rebuilt after the page adds, removes or marks elements. */
4448
+ function carriersOf(id) {
4449
+ watcher ??= new MutationObserver(() => {
4450
+ carriers = void 0;
4451
+ });
4452
+ if (!carriers || watcher.takeRecords().length > 0) {
4453
+ carriers = /* @__PURE__ */ new Map();
4454
+ watcher.disconnect();
4455
+ watcher.observe(document, {
4456
+ subtree: true,
4457
+ childList: true,
4458
+ attributes: true,
4459
+ attributeFilter: ["b-v"]
4460
+ });
4461
+ for (const element of document.querySelectorAll("[b-v]")) for (const token of element.getAttribute("b-v").split(" ")) {
4462
+ const list = carriers.get(token);
4463
+ if (list) list.push(element);
4464
+ else carriers.set(token, [element]);
4465
+ }
4466
+ }
4467
+ return carriers.get(String(id)) ?? [];
4468
+ }
4469
+ /**
4470
+ * Sets a style variable on the top-level elements of a component or block instance. `b-v` lists
4471
+ * the IDs of the instances whose variables an element carries, since an element at the top level
4472
+ * of a block inside another carries both.
4473
+ */
4440
4474
  function setVar(scope, name, value) {
4441
4475
  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);
4476
+ for (const element of carriersOf(scope.id)) if (element.style.getPropertyValue(name) !== css) element.style.setProperty(name, css);
4443
4477
  }
4444
4478
  /**
4445
4479
  * Warns in development that the browser renders a `#defer` block of a
@@ -4622,6 +4656,6 @@ const loader = {
4622
4656
  };
4623
4657
  function noop() {}
4624
4658
  //#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 };
4659
+ export { appendText as $, updated as $t, started as A, track as At, spreadProps as B, bindings as Bt, fillAttrs as C, action as Ct, keepValue as D, spread as Dt, fillValue as E, rpc as Et, portalTo as F, storeUpdate as Ft, elementAt as G, isBound as Gt, componentNodes as H, effect as Ht, restRef as I, toStore as It, place as J, resolve as Jt, foreignNodes as K, memo as Kt, text as L, updateRoute as Lt, attr as M, consumeStore as Mt, attrs as N, provideValue as Nt, loading as O, submitAction as Ot, content as P, setGlobal as Pt, setSlots as Q, update as Qt, writeText as R, asyncMemo as Rt, countLoads as S, removeRoot as St, fillSpread as T, handlerProp as Tt, dynamic as U, gate as Ut, component as V, cells as Vt, dynamicNodes as W, get as Wt, renderMemo as X, timed as Xt, readMemo as Y, set as Yt, setItem as Z, unreadMemo as Zt, rekey as _, hooks as _n, forget as _t, addPortal as a, afterInsert as an, keepText as at, after as b, skew as bn, leaveRoutes as bt, setVar as c, getScope as cn, nodes as ct, windowList as d, setOwner as dn, setAttrText as dt, fail as en, branchNodes as et, windowStart as f, sink as fn, setContent as ft, offscreen as g, build as gn, dispose as gt, held as h, DEVTOOLS as hn, template as ht, addHead as i, title as in, keep as it, wait as j, consumeContext as jt, reveal as k, guess as kt, list as l, makeId as ln, putText as lt, fill as m, loadModule as mn, setSpread as mt, paramEffect as n, insert as nn, fillBranch as nt, addStyle as o, createScope as on, listNodes as ot, branch as p, nameComment as pn, setOn as pt, memoNow as q, pending as qt, searchParam as r, templateCall as rn, fillList as rt, deferInBrowser as s, descendants as sn, markBlock as st, loader as t, children as tn, clone as tt, toList as u, removeScope as un, setAttr as ut, reset as v, rpcPrefix as vn, init as vt, fillSettled as w, handle as wt, attempt as x, remount as xt, retag as y, scopes as yn, leavePage as yt, prop as z, binding as zt };
4626
4660
 
4627
- //# sourceMappingURL=client-COm1iA6w.js.map
4661
+ //# sourceMappingURL=client-B0FXW5Kw.js.map