brumate 0.8.0 → 0.9.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.
- package/dist/{boot-BkUdiYOF.d.ts → boot-ej-9NRT3.d.ts} +20 -2
- package/dist/cli.js +88 -82
- package/dist/cli.js.map +1 -1
- package/dist/{client-B0FXW5Kw.js → client-B-ww-PQ7.js} +402 -63
- package/dist/client-B-ww-PQ7.js.map +1 -0
- package/dist/{client-Cq6aTiDs.d.ts → client-Do6IBIhI.d.ts} +58 -14
- package/dist/{defer-BMIMP4Hq.js → defer-JD2FK9mV.js} +5 -3
- package/dist/defer-JD2FK9mV.js.map +1 -0
- package/dist/{devtools-calls-DGW6nLZ2.js → devtools-calls-DCjuSkim.js} +3 -3
- package/dist/{devtools-calls-DGW6nLZ2.js.map → devtools-calls-DCjuSkim.js.map} +1 -1
- package/dist/{devtools-panel-B1nF1KB7.js → devtools-panel-DLeWTPhU.js} +4 -4
- package/dist/{devtools-panel-B1nF1KB7.js.map → devtools-panel-DLeWTPhU.js.map} +1 -1
- package/dist/{devtools-B4prrxht.js → devtools-tuq7ATGN.js} +10 -7
- package/dist/devtools-tuq7ATGN.js.map +1 -0
- package/dist/{error-catalog-DakxjSgj.js → error-catalog-BBWB7w-E.js} +11 -4
- package/dist/error-catalog-BBWB7w-E.js.map +1 -0
- package/dist/{error-catalog-VxLbz-6p.js → error-catalog-CbmQqfat.js} +1 -1
- package/dist/{events-LgLdp1R7.js → events-BDVITj3P.js} +3 -5
- package/dist/events-BDVITj3P.js.map +1 -0
- package/dist/{features-DwMYKBIC.js → features-Cte5aj20.js} +8 -2
- package/dist/features-Cte5aj20.js.map +1 -0
- package/dist/{files-D5GtxwEQ.js → files-Bz0lAQzD.js} +2 -2
- package/dist/{files-D5GtxwEQ.js.map → files-Bz0lAQzD.js.map} +1 -1
- package/dist/{html-Cf5uKhLs.js → html-BYuHDvxy.js} +10 -3
- package/dist/html-BYuHDvxy.js.map +1 -0
- package/dist/index.d.ts +71 -19
- package/dist/index.js +3 -3
- package/dist/{inspect-CGl5Y8q6.js → inspect-fpaBJ5pm.js} +1305 -75
- package/dist/inspect-fpaBJ5pm.js.map +1 -0
- package/dist/{loader-BsaSuIoG.js → loader-DMxuZ6He.js} +14 -6
- package/dist/loader-DMxuZ6He.js.map +1 -0
- package/dist/{navigate-BlowKvhB.js → navigate-C5PjwYMh.js} +108 -20
- package/dist/navigate-C5PjwYMh.js.map +1 -0
- package/dist/{produce-CLABZ8k2.d.ts → produce-BDkCsGH7.d.ts} +3 -3
- package/dist/{rpc-C1jYVNAe.js → rpc-DOdrekhP.js} +23 -13
- package/dist/rpc-DOdrekhP.js.map +1 -0
- package/dist/runtime/bundles.d.ts +3 -2
- package/dist/runtime/bundles.js +20 -5
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -3
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/devtools.d.ts +3 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/otel.d.ts +18 -0
- package/dist/runtime/otel.js +127 -0
- package/dist/runtime/otel.js.map +1 -0
- package/dist/runtime/server.d.ts +4 -3
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +4 -1
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -2
- package/dist/runtime/store.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/search-params-qGERTLi3.js +382 -0
- package/dist/search-params-qGERTLi3.js.map +1 -0
- package/dist/{serial-ribg9NAj.js → serial-B2AJ9VGx.js} +1 -1
- package/dist/{serial-ioa17MuY.js → serial-Cj6pDGOq.js} +6 -6
- package/dist/{serial-ioa17MuY.js.map → serial-Cj6pDGOq.js.map} +1 -1
- package/dist/{server-DesBZv5g.d.ts → server-2-LS_KFo.d.ts} +125 -9
- package/dist/{server-BUuf7XPZ.js → server-CRGZMWnK.js} +545 -236
- package/dist/server-CRGZMWnK.js.map +1 -0
- package/dist/{shared-CX_YacDm.js → shared-CUBWrbiM.js} +4 -4
- package/dist/{shared-CX_YacDm.js.map → shared-CUBWrbiM.js.map} +1 -1
- package/dist/sheets-B9Zr50mf.js +105 -0
- package/dist/sheets-B9Zr50mf.js.map +1 -0
- package/dist/{signals-7VVD9C_H.d.ts → signals-BgsJK-uT.d.ts} +16 -6
- package/dist/{static-loader-C_en-4v8.js → static-loader-BDBtWsdg.js} +107 -19
- package/dist/static-loader-BDBtWsdg.js.map +1 -0
- package/dist/{static-loader-UKnK11Em.d.ts → static-loader-CAFn6p0l.d.ts} +2 -2
- package/dist/{store-9_oa0HG1.d.ts → store-BwWg-Iei.d.ts} +79 -2
- package/dist/store-DNr24Z8L.js +950 -0
- package/dist/store-DNr24Z8L.js.map +1 -0
- package/dist/{stream-read-BTsYstJY.js → stream-read-CiLDH60b.js} +2 -2
- package/dist/{stream-read-BTsYstJY.js.map → stream-read-CiLDH60b.js.map} +1 -1
- package/dist/{stream-read-Dek3HnqO.js → stream-read-DVoregpA.js} +1 -1
- package/dist/trace-DT7RGRAV.d.ts +52 -0
- package/dist/trace-browser-C7MFMove.js +170 -0
- package/dist/trace-browser-C7MFMove.js.map +1 -0
- package/dist/trace-flag-Dy267snx.js +7 -0
- package/dist/trace-flag-Dy267snx.js.map +1 -0
- package/dist/{trusted-g_zUJbh2.js → trusted-Bmwg4_hf.js} +12 -5
- package/dist/trusted-Bmwg4_hf.js.map +1 -0
- package/dist/view-transitions-BpnVwtS4.js +141 -0
- package/dist/view-transitions-BpnVwtS4.js.map +1 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +356 -46
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +8 -0
- package/package.json +13 -1
- package/skills/brumate/SKILL.md +9 -5
- package/skills/brumate/references/errors.md +95 -14
- package/skills/brumate/references/events.md +27 -1
- package/skills/brumate/references/signals.md +4 -4
- package/skills/brumate/references/state.md +79 -4
- package/skills/brumate/references/syntax.md +58 -9
- package/dist/client-B0FXW5Kw.js.map +0 -1
- package/dist/defer-BMIMP4Hq.js.map +0 -1
- package/dist/devtools-B4prrxht.js.map +0 -1
- package/dist/error-catalog-DakxjSgj.js.map +0 -1
- package/dist/events-LgLdp1R7.js.map +0 -1
- package/dist/features-DwMYKBIC.js.map +0 -1
- package/dist/html-Cf5uKhLs.js.map +0 -1
- package/dist/inspect-CGl5Y8q6.js.map +0 -1
- package/dist/loader-BsaSuIoG.js.map +0 -1
- package/dist/navigate-BlowKvhB.js.map +0 -1
- package/dist/rpc-C1jYVNAe.js.map +0 -1
- package/dist/search-params-Wg-0FsMj.js +0 -148
- package/dist/search-params-Wg-0FsMj.js.map +0 -1
- package/dist/server-BUuf7XPZ.js.map +0 -1
- package/dist/static-loader-C_en-4v8.js.map +0 -1
- package/dist/store-Cy4EEyZ7.js +0 -439
- package/dist/store-Cy4EEyZ7.js.map +0 -1
- package/dist/trusted-g_zUJbh2.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as trustedHTML } from "./trusted-
|
|
1
|
+
import { t as trustedHTML } from "./trusted-Bmwg4_hf.js";
|
|
2
2
|
import { t as LOGO } from "./logo-DQ_OYhBi.js";
|
|
3
3
|
//#region src/runtime/devtools-flash.ts
|
|
4
4
|
/** Where the choice to outline changed elements is kept. */
|
|
@@ -348,7 +348,7 @@ function reportError(state, payload, source) {
|
|
|
348
348
|
}
|
|
349
349
|
/** The code of the panel, which loads when it opens. */
|
|
350
350
|
function panelModule() {
|
|
351
|
-
return import("./devtools-panel-
|
|
351
|
+
return import("./devtools-panel-DLeWTPhU.js");
|
|
352
352
|
}
|
|
353
353
|
/** True for an error of code that is not of the page, such as of a browser extension. */
|
|
354
354
|
function foreign(stack, file = "") {
|
|
@@ -460,7 +460,10 @@ function installDevtools(endpoint = "/__brumate/inspect", rpc = "/_brumate", met
|
|
|
460
460
|
state.effects.set(key, entry);
|
|
461
461
|
}
|
|
462
462
|
const now = performance.now();
|
|
463
|
-
if (kind === "
|
|
463
|
+
if (kind === "pending") entry.pending = true;
|
|
464
|
+
else if (kind === "skip") entry.pending = false;
|
|
465
|
+
else if (kind === "run") {
|
|
466
|
+
entry.pending = false;
|
|
464
467
|
entry.runs++;
|
|
465
468
|
entry.time += time;
|
|
466
469
|
entry.recent.push(now);
|
|
@@ -539,7 +542,7 @@ function installDevtools(endpoint = "/__brumate/inspect", rpc = "/_brumate", met
|
|
|
539
542
|
if (server) call.server = Number(server[1]);
|
|
540
543
|
const arrived = call.end;
|
|
541
544
|
const copy = response.clone();
|
|
542
|
-
import("./devtools-calls-
|
|
545
|
+
import("./devtools-calls-DCjuSkim.js").then(({ readCall }) => readCall({
|
|
543
546
|
name,
|
|
544
547
|
init,
|
|
545
548
|
response: copy,
|
|
@@ -586,7 +589,7 @@ function installDevtools(endpoint = "/__brumate/inspect", rpc = "/_brumate", met
|
|
|
586
589
|
});
|
|
587
590
|
}
|
|
588
591
|
state.fire = (block) => {
|
|
589
|
-
if (block.kind === "defer" && block.template) deferred(block.template, import("./defer-
|
|
592
|
+
if (block.kind === "defer" && block.template) deferred(block.template, import("./defer-JD2FK9mV.js").then((module) => module.loadDeferred(block.template)));
|
|
590
593
|
else if (block.template && block.ref) state.handle?.(block.template, block.ref);
|
|
591
594
|
};
|
|
592
595
|
if (typeof MutationObserver !== "undefined") {
|
|
@@ -692,7 +695,7 @@ function installDevtools(endpoint = "/__brumate/inspect", rpc = "/_brumate", met
|
|
|
692
695
|
}
|
|
693
696
|
});
|
|
694
697
|
state.open = (tab) => {
|
|
695
|
-
import("./devtools-panel-
|
|
698
|
+
import("./devtools-panel-DLeWTPhU.js").then(({ openPanel }) => openPanel(root, state, tab));
|
|
696
699
|
};
|
|
697
700
|
root.append(style, button);
|
|
698
701
|
installFlash(state, root, host);
|
|
@@ -744,4 +747,4 @@ function installDevtools(endpoint = "/__brumate/inspect", rpc = "/_brumate", met
|
|
|
744
747
|
//#endregion
|
|
745
748
|
export { preview as a, nextBlockState as i, installDevtools as n, reportError as o, moveBlock as r, scanBlocks as s, findRootScope as t };
|
|
746
749
|
|
|
747
|
-
//# sourceMappingURL=devtools-
|
|
750
|
+
//# sourceMappingURL=devtools-tuq7ATGN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools-tuq7ATGN.js","names":[],"sources":["../src/runtime/devtools-flash.ts","../src/runtime/devtools.ts"],"sourcesContent":["import type { DevtoolsState } from './devtools.ts';\n\n/** Where the choice to outline changed elements is kept. */\nconst FLASH_KEY = 'brumate:devtools:flash';\n/** How long an outline shows. */\nexport const FLASH_MS = 700;\n/** The most outlines that one frame draws, so a big change does not stall the page. */\nexport const MAX_FLASHES = 200;\n\n/** The colours of an outline, by how often the element changes. */\nconst HEAT = {\n cool: { line: '#7fd99a', fill: 'rgb(127 217 154 / 0.08)' },\n warm: { line: '#ffd166', fill: 'rgb(255 209 102 / 0.1)' },\n hot: { line: '#ff7a7a', fill: 'rgb(255 122 122 / 0.12)' },\n};\n\nexport type Heat = keyof typeof HEAT;\n\n/** One outline: the element, where it is in the viewport, its colour and when it began. */\nexport interface OutlineBox {\n /** Measured again on scroll and resize while the element is connected. */\n element: Element;\n x: number;\n y: number;\n width: number;\n height: number;\n heat: Heat;\n start: number;\n}\n\nexport interface Outlines {\n /** The boxes that are showing, oldest first. */\n boxes: OutlineBox[];\n canvas: HTMLCanvasElement;\n}\n\n/** The heat of an outline, by how many times the element changed in the last second. */\nfunction pickHeat(count: number): Heat {\n if (count >= 5) {\n return 'hot';\n }\n return count >= 2 ? 'warm' : 'cool';\n}\n\nfunction reducedMotion(): boolean {\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/**\n * Outlines the elements that change, as an update writes them: green for an\n * element that changes now and then, yellow and red for one that changes\n * often. A MutationObserver sees every change of the page, so it needs no\n * hook of the core. The boxes are drawn on one canvas in the shadow root, so\n * the page itself does not change.\n */\nexport function installFlash(state: DevtoolsState, root: ShadowRoot, host: Element): Outlines {\n const canvas = document.createElement('canvas');\n canvas.className = 'flashes';\n canvas.style.cssText =\n 'position:fixed;left:0;top:0;width:100vw;height:100vh;pointer-events:none;z-index:2147483646';\n root.append(canvas);\n const context = canvas.getContext('2d');\n const boxes: OutlineBox[] = [];\n // How many times each element changed lately, for its colour.\n const heat = new WeakMap<Element, { count: number; time: number }>();\n const pending = new Set<Element>();\n let observed = false;\n let mutationFrame = 0;\n let loop = 0;\n\n function fit(): void {\n const ratio = window.devicePixelRatio || 1;\n const width = Math.round(innerWidth * ratio);\n const height = Math.round(innerHeight * ratio);\n // Setting the size clears the canvas, so only do it when it changed.\n if (canvas.width !== width || canvas.height !== height) {\n canvas.width = width;\n canvas.height = height;\n }\n canvas.style.width = `${innerWidth}px`;\n canvas.style.height = `${innerHeight}px`;\n }\n\n function paint(now: number): void {\n if (!context) {\n return;\n }\n const ratio = window.devicePixelRatio || 1;\n context.setTransform(ratio, 0, 0, ratio, 0, 0);\n context.clearRect(0, 0, innerWidth, innerHeight);\n const still = reducedMotion();\n context.lineWidth = 2;\n for (const box of boxes) {\n const colours = HEAT[box.heat];\n context.globalAlpha = still ? 1 : Math.max(0, 1 - (now - box.start) / FLASH_MS);\n context.fillStyle = colours.fill;\n context.strokeStyle = colours.line;\n context.beginPath();\n const x = box.x;\n const y = box.y;\n if (typeof context.roundRect === 'function') {\n context.roundRect(x, y, box.width, box.height, 3);\n } else {\n context.rect(x, y, box.width, box.height);\n }\n context.fill();\n context.stroke();\n }\n context.globalAlpha = 1;\n }\n\n /** One frame of the loop: drops the boxes that ran out, draws the rest and goes on while any is left. */\n function tick(): void {\n loop = 0;\n const now = performance.now();\n let kept = 0;\n for (const box of boxes) {\n if (now - box.start < FLASH_MS) {\n boxes[kept++] = box;\n }\n }\n boxes.length = kept;\n paint(now);\n if (boxes.length > 0) {\n loop = requestAnimationFrame(tick);\n }\n }\n\n /** Measures the boxes again, since a scroll moves the elements but not the fixed ones. */\n function repaint(): void {\n if (boxes.length === 0) {\n return;\n }\n for (const box of boxes) {\n // A box whose element left the page keeps its last rect.\n if (box.element.isConnected) {\n const rect = box.element.getBoundingClientRect();\n box.x = rect.left;\n box.y = rect.top;\n box.width = rect.width;\n box.height = rect.height;\n }\n }\n paint(performance.now());\n }\n\n function resize(): void {\n fit();\n repaint();\n }\n\n function collect(): void {\n mutationFrame = 0;\n let drawn = 0;\n for (const target of pending) {\n if (drawn >= MAX_FLASHES) {\n break;\n }\n const rect = target.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) {\n continue;\n }\n const now = performance.now();\n const last = heat.get(target);\n const count = last && now - last.time < 1000 ? last.count + 1 : 1;\n heat.set(target, { count, time: now });\n boxes.push({\n element: target,\n x: rect.left,\n y: rect.top,\n width: rect.width,\n height: rect.height,\n heat: pickHeat(count),\n start: now,\n });\n drawn++;\n }\n pending.clear();\n if (drawn > 0) {\n fit();\n paint(performance.now());\n if (loop === 0) {\n loop = requestAnimationFrame(tick);\n }\n }\n }\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n let target: Node | null = record.target;\n if (record.type === 'childList') {\n // The elements that came in, or else the element that lost some.\n let added = 0;\n for (const node of record.addedNodes) {\n if (node.nodeType === 1) {\n pending.add(node as Element);\n added++;\n }\n }\n if (added > 0) {\n continue;\n }\n }\n if (target.nodeType !== 1) {\n target = target.parentElement;\n }\n if (\n target &&\n target !== host &&\n target !== document.documentElement &&\n target !== document.body\n ) {\n pending.add(target as Element);\n }\n }\n for (const target of pending) {\n // The devtools change their own markup, and the host carries their styles.\n if (target === host || host.contains(target)) {\n pending.delete(target);\n }\n }\n if (pending.size > 0 && mutationFrame === 0) {\n mutationFrame = requestAnimationFrame(collect);\n }\n });\n\n state.setFlash = (on) => {\n state.flash = on;\n if (on && !observed) {\n observed = true;\n fit();\n observer.observe(document.documentElement, {\n subtree: true,\n childList: true,\n attributes: true,\n characterData: true,\n });\n addEventListener('resize', resize);\n addEventListener('scroll', repaint, { passive: true, capture: true });\n } else if (!on && observed) {\n observed = false;\n observer.disconnect();\n removeEventListener('resize', resize);\n removeEventListener('scroll', repaint, { capture: true });\n pending.clear();\n boxes.length = 0;\n if (loop !== 0) {\n cancelAnimationFrame(loop);\n loop = 0;\n }\n paint(performance.now());\n }\n try {\n localStorage.setItem(FLASH_KEY, on ? '1' : '0');\n } catch {\n // Storage can be off.\n }\n state.changed?.();\n };\n let saved = false;\n try {\n saved = localStorage.getItem(FLASH_KEY) === '1';\n } catch {\n // Storage can be off.\n }\n if (saved) {\n state.setFlash(true);\n }\n return { boxes, canvas };\n}\n","// The devtools overlay of development builds. This module only listens to\n// the core and shows a button. The panel loads when the button is pressed,\n// so the page behaves as in production until then.\n\nimport type { NavigationReport } from './navigate.ts';\nimport type { DevtoolsHooks, Scope } from './client.ts';\nimport type * as Panel from './devtools-panel.ts';\nimport { installFlash } from './devtools-flash.ts';\nimport type { ScopeId } from './shared.ts';\n\n// The same key as the core's, without importing the core.\nconst DEVTOOLS = Symbol.for('brumate.devtools');\n/** The state and the button of the devtools that a page has, so a second install does nothing. */\nconst INSTALLED = Symbol.for('brumate.devtools.installed');\n\n/** What an install leaves on globalThis, so a second call can find it. */\ninterface Installed {\n state: DevtoolsState;\n host: Element;\n /** False until the host is in the page; it waits for DOMContentLoaded while the document loads. */\n appended: boolean;\n /** The fetch that the install wrapped, so a new install wraps it and not the wrapper. */\n fetch: typeof fetch;\n /** The wrapper that the install put on globalThis. */\n wrapper: typeof fetch;\n}\n\n/** Something that happened on the page, for the log of the panel. */\nexport interface DevtoolsEntry {\n time: number;\n kind: 'handler' | 'write' | 'call';\n text: string;\n /** The scope of a write, so the panel can mark it. */\n scope?: ScopeId;\n /** For a write: the component, the scope in the compiled component, and the slot. */\n write?: { component: string; k: number; slot: number };\n /** For a call: its timing and record, which the call detail of the dock shows. */\n call?: CallTiming;\n}\n\n/** What the plugin tells the devtools about the dev server. */\nexport interface DevtoolsMeta {\n version?: string;\n vite?: string;\n}\n\n/** An error for the Errors tab: of a render on the server, of Vite, or of code in the browser. */\nexport interface ErrorEntry {\n time: number;\n source: 'server' | 'compile' | 'browser';\n message: string;\n stack?: string;\n /** The lines around the error, as Vite's overlay shows them. */\n frame?: string;\n /** The place of the error, such as a compile error in a `.brm` file. */\n loc?: { file: string; line: number; column: number };\n /** The plugin that threw it, such as `brumate`. */\n plugin?: string;\n}\n\n/** What Vite's overlay gets, and what `errorPage` sends. */\nexport interface ErrorPayload {\n message: string;\n stack?: string;\n frame?: string;\n plugin?: string;\n id?: string;\n loc?: { file?: string; line: number; column: number };\n}\n\n/** The part of `import.meta.hot` that the devtools listen to. */\ninterface HotContext {\n on(event: string, listener: (payload: never) => void): void;\n}\n\n/** A server function call, for the Timeline tab. */\nexport interface CallTiming {\n name: string;\n start: number;\n end?: number;\n /** The status of the answer, `redirect` for a redirect, or `failed`. */\n status?: number | 'redirect' | 'failed';\n /** How long the function took on the server, from the `Server-Timing` of the dev server. */\n server?: number;\n /** The arguments, the result and what ran on the server. It arrives after the answer. */\n record?: CallRecord;\n /** What was sent, so the dock can run the call again and write it as a `fetch`. Dev only. */\n request?: {\n url: string;\n /** Only `content-type` and the `x-brumate-` headers, never cookies. */\n headers: Record<string, string>;\n body?: string | FormData;\n };\n}\n\n/**\n * What a server call needs for its detail, for the dock. The browser decodes the arguments and the\n * result, and the dev server sends `server` and the stack in the `x-brumate-dev` header, so a\n * production build has none of them. Values are cut at a length, and no cookies or headers are in it.\n */\nexport interface CallRecord {\n name: string;\n /** The decoded arguments, cut. */\n args: unknown[];\n /** The decoded result, cut. Absent for an error or a redirect. */\n result?: unknown;\n /** The error that the server function threw, with the real message and the stack of the server. */\n error?: { message: string; stack?: string };\n /** Milliseconds: `module` before the request left, `network` there and back, `server` in the function, `decode` reading the answer. */\n timing: { module: number; network: number; server: number; decode: number };\n /** What ran on the server. Absent when the answer did not come from the dev server. */\n server?: ServerRecord;\n}\n\n/** What ran on the server during a call. */\nexport interface ServerRecord {\n /** The server functions whose memos the answer asked to load again (`refresh`). */\n reads: string[];\n /** The IDs of the server functions that the function called. */\n calls: string[];\n /** The `console.*` output of the call, in order. */\n logs: { level: string; text: string }[];\n /** True when logs were left out to fit the header. */\n truncated?: boolean;\n}\n\n/** The content of the `x-brumate-dev` header of the dev server. */\nexport interface DevAnswer extends ServerRecord {\n error?: { message: string; stack?: string };\n}\n\n/** A batch of updates that a write ran, with its effects. */\nexport interface UpdateTiming {\n count: number;\n start: number;\n end: number;\n}\n\n/**\n * A handler that ran, for the Timeline tab: when its event came, when its\n * code was ready and the handlers before it had started, when its call\n * returned, and when the promise of an async handler settled. The server\n * calls and the updates that ran meanwhile are its own.\n */\nexport interface Interaction {\n ref: string;\n /** What happened, such as `click on <button>`. */\n label: string;\n begun: number;\n ready: number;\n end: number;\n settled?: number;\n failed?: boolean;\n calls: CallTiming[];\n updates: UpdateTiming[];\n}\n\n/** A block of the page that renders later, for the Blocks tab. */\nexport interface BlockEntry {\n kind: 'loading' | 'defer' | 'client' | '$client';\n /** The boundary of `#loading` and `#defer`, or the `b-b` of the template of the others. */\n id: string;\n /** The trigger of `#defer`, `#client` and `$client`. */\n trigger?: string;\n /** The reference that `#client` and `$client` run. */\n ref?: string;\n /** The template that the loader reads for `#defer`, `#client` and `$client`. */\n template?: Element;\n state: 'waiting' | 'loading' | 'streaming' | 'rendered' | 'failed';\n /** When the panel first saw the block, when its trigger fired, and when it rendered. */\n seen: number;\n fired?: number;\n rendered?: number;\n /** True while the devtools show its fallback in place of its body. */\n fallback?: boolean;\n}\n\n/** An effect or a `$client` callback of a scope, with how it ran. */\nexport interface EffectEntry {\n scope: ScopeId;\n /** The ID of the component of the scope, and the scope's number in it. */\n component: string;\n k: number;\n /** Its name in the update code: `e<n>` for an effect, `c<n>` for a `$client` callback. */\n name: string;\n runs: number;\n /** When its last runs were, the newest last, at most 50. */\n recent: number[];\n /** The time of all its runs, in milliseconds. */\n time: number;\n cleanups: number;\n lastCleanup?: number;\n /** True while a run of an async callback has not settled. */\n pending?: boolean;\n /** False once its cleanup ran and it has not run again, such as in a removed scope. */\n active: boolean;\n}\n\nexport interface DevtoolsState {\n scopes?: Map<ScopeId, Scope>;\n /** Writes a slot, as a handler does, so the page updates. */\n set?: (scope: Scope, slot: number, value: unknown) => void;\n /** Runs a reference for an element, as the loader does for a trigger. */\n handle?: (element: Element, ref: string, event?: Event) => Promise<unknown>;\n log: DevtoolsEntry[];\n /** The blocks of the page, by kind and ID. */\n blocks: Map<string, BlockEntry>;\n /** Asks the server for the body of a `#defer` block now. */\n fire?: (block: BlockEntry) => void;\n /**\n * Shows the fallback of a `#loading` or `#defer` block in place of its\n * body, or its body again. False when the page did not keep its fallback.\n */\n showFallback?: (block: BlockEntry, on: boolean) => boolean;\n /** The scopes written since the panel last drew, by scope ID. */\n written: Set<ScopeId>;\n /** The URL prefix of the inspect endpoint of the dev server. */\n endpoint: string;\n /** The versions of brumate and Vite, from the plugin. */\n meta: DevtoolsMeta;\n /** The errors of the page, oldest first. */\n errors: ErrorEntry[];\n /** The handlers that ran, oldest first, with their calls and updates. */\n timeline: Interaction[];\n /** The effects and `$client` callbacks that ran, by scope and name. */\n effects: Map<string, EffectEntry>;\n /** The client navigations of the page, newest last, at most 20. */\n navigations: NavigationReport[];\n /** Opens the panel on a tab, such as `errors`. */\n open?: (tab: string) => void;\n /** Shows the number of errors on the tab. */\n errorCount?: () => void;\n /** True while the elements that change are outlined on the page. */\n flash: boolean;\n /** Turns the outlines of changed elements on or off, and keeps the choice. */\n setFlash?: (on: boolean) => void;\n /** While the panel is open: sets its top edge to a place of the pointer, and keeps it. */\n resize?: (clientY: number) => void;\n resized?: () => void;\n /** Called after each change, while the panel is open. */\n changed?: () => void;\n}\n\nconst MAX_LOG = 300;\n\nimport { LOGO } from './logo.ts';\nimport { trustedHTML } from './trusted.ts';\n\nexport { LOGO };\n\n/** The root scope of a scope, whose `m` names its component. */\nexport function findRootScope(scope: Scope): Scope {\n let root = scope;\n while (root.p) {\n root = root.p;\n }\n return root;\n}\n\n/** A short text for a value in the log. */\nexport function preview(value: unknown): string {\n if (typeof value === 'string') {\n return JSON.stringify(value.length > 40 ? `${value.slice(0, 40)}…` : value);\n }\n if (typeof value === 'function') {\n return 'function';\n }\n if (Array.isArray(value)) {\n return `Array(${value.length})`;\n }\n if (value instanceof Element) {\n return `<${value.tagName.toLowerCase()}>`;\n }\n if (value !== null && typeof value === 'object') {\n const name = value.constructor?.name;\n return name && name !== 'Object' ? name : `{${Object.keys(value).slice(0, 3).join(', ')}}`;\n }\n return String(value);\n}\n\n/**\n * What happens to a block. `rendered`: the markers of the page show its body. `fired`: its trigger\n * fired. `settled`: the request for the body of a `#defer` settled.\n */\nexport type BlockEvent = 'rendered' | 'fired' | 'settled';\n\n/**\n * The state of a block after an event. A rendered block stays rendered. A `#defer` loads when\n * it fires, and fails when its request settles with the fallback still shown. A `$client`\n * callback has rendered once it fired. A `#client` block waits for its marker.\n */\nexport function nextBlockState(block: BlockEntry, event: BlockEvent): BlockEntry['state'] {\n if (block.state === 'rendered' || event === 'rendered') {\n return 'rendered';\n }\n if (event === 'settled') {\n return block.state === 'loading' ? 'failed' : block.state;\n }\n if (block.kind === 'defer') {\n return 'loading';\n }\n return block.kind === '$client' ? 'rendered' : block.state;\n}\n\n/** Moves a block to its state after an event. Returns true when the state changed. */\nexport function moveBlock(block: BlockEntry, event: BlockEvent, now: number): boolean {\n const next = nextBlockState(block, event);\n if (next === block.state) {\n return false;\n }\n block.state = next;\n if (next === 'rendered') {\n block.rendered = now;\n }\n return true;\n}\n\n/**\n * Reads the blocks of the page from their markers, and updates their state.\n * Returns true when something changed.\n *\n * - `#defer`: a `<template b-defer>`, and `<!--l…-->` around its fallback until its body arrives.\n * - `#loading`: `<!--l…-->` around its fallback until the server streams its body.\n * - `#client`: a `<template b-client>` with a `#k` reference, and a marker that gets `:1` once\n * its body rendered.\n * - `$client`: a `<template b-client>` with a `#c` reference.\n */\nexport function scanBlocks(state: DevtoolsState): boolean {\n const now = performance.now();\n let changed = false;\n const open = new Map<string, Comment>();\n const markers = new Map<string, Comment>();\n const walker = document.createTreeWalker(document, NodeFilter.SHOW_COMMENT);\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n const data = (node as Comment).data;\n if (/^l[\\d.-]+$/.test(data)) {\n open.set(data.slice(1), node as Comment);\n } else if (/^b-?[\\d.]+:\\d+/.test(data)) {\n markers.set(data.slice(1).split(':').slice(0, 2).join(':'), node as Comment);\n }\n }\n const seen = new Set<string>();\n function update(key: string, make: () => BlockEntry, rendered: boolean): void {\n seen.add(key);\n let block = state.blocks.get(key);\n if (!block) {\n block = make();\n state.blocks.set(key, block);\n changed = true;\n }\n if (rendered && moveBlock(block, 'rendered', now)) {\n changed = true;\n }\n }\n const deferBoundaries = new Set<string>();\n for (const template of document.querySelectorAll('template[b-defer]')) {\n const [trigger, boundary] = template.getAttribute('b-defer')!.split(':') as [string, string];\n deferBoundaries.add(boundary);\n update(\n `defer:${boundary}`,\n () => ({ kind: 'defer', id: boundary, trigger, template, state: 'waiting', seen: now }),\n !open.has(boundary),\n );\n }\n for (const boundary of open.keys()) {\n if (!deferBoundaries.has(boundary)) {\n update(\n `loading:${boundary}`,\n () => ({ kind: 'loading', id: boundary, state: 'streaming', seen: now }),\n false,\n );\n }\n }\n for (const template of document.querySelectorAll('template[b-client]')) {\n const [trigger, ref] = template.getAttribute('b-client')!.split('=') as [string, string];\n const id = template.getAttribute('b-b') ?? '';\n const block = /#k\\d+$/.test(ref);\n const marker = markers.get(id);\n update(\n `client:${id}`,\n () => ({\n kind: block ? 'client' : '$client',\n id,\n trigger,\n ref,\n template,\n state: 'waiting',\n seen: now,\n }),\n // A `$client` callback has run once its trigger fired.\n Boolean(\n block\n ? marker && marker.data.split(':').length > 2\n : state.blocks.get(`client:${id}`)?.fired,\n ),\n );\n }\n // A `#loading` block whose markers are gone rendered its body. Other blocks that left the page,\n // such as on navigation, are dropped.\n for (const [key, block] of state.blocks) {\n if (seen.has(key)) {\n continue;\n }\n if (block.kind === 'loading') {\n if (moveBlock(block, 'rendered', now)) {\n changed = true;\n }\n } else if (!block.template?.isConnected) {\n state.blocks.delete(key);\n changed = true;\n }\n }\n return changed;\n}\n\n/**\n * Adds an error to the Errors tab. An error of the server or of Vite opens\n * the panel on it, as Vite's overlay would. An error of the browser only\n * counts on the button.\n */\nexport function reportError(\n state: DevtoolsState,\n payload: ErrorPayload,\n source: ErrorEntry['source'],\n): void {\n const file = payload.loc?.file ?? payload.id;\n const entry: ErrorEntry = {\n time: performance.now(),\n // An error of a plugin, such as a compile error, is one, even when a render met it.\n source: source === 'server' && payload.plugin ? 'compile' : source,\n message: payload.message,\n ...(payload.stack ? { stack: payload.stack } : {}),\n ...(payload.frame ? { frame: payload.frame } : {}),\n ...(payload.plugin ? { plugin: payload.plugin } : {}),\n ...(payload.loc && file\n ? { loc: { file, line: payload.loc.line, column: payload.loc.column } }\n : {}),\n };\n // The same error again, such as on each request for the page, counts once.\n const last = state.errors.at(-1);\n if (last?.message !== entry.message || last.stack !== entry.stack) {\n state.errors.push(entry);\n if (state.errors.length > 50) {\n state.errors.shift();\n }\n }\n state.errorCount?.();\n state.changed?.();\n if (source !== 'browser') {\n state.open?.('errors');\n }\n}\n\n/** The code of the panel, which loads when it opens. */\nfunction panelModule(): Promise<typeof Panel> {\n return import('./devtools-panel.ts');\n}\n\n/** True for an error of code that is not of the page, such as of a browser extension. */\nfunction foreign(stack: string | undefined, file = ''): boolean {\n return (\n /^[a-z-]+-extension:/.test(file) ||\n (stack !== undefined &&\n /[a-z-]+-extension:\\/\\//.test(stack) &&\n !stack.includes(location.origin))\n );\n}\n\n/** Listens to the core, and adds the button that opens the panel. */\nexport function installDevtools(\n endpoint = '/__brumate/inspect',\n rpc = '/_brumate',\n meta: DevtoolsMeta = {},\n hot?: HotContext,\n): DevtoolsState {\n // The plugin installs the devtools on its own, so an entry that does it too must not add a second set.\n const installed = (globalThis as Record<symbol, Installed | undefined>)[INSTALLED];\n // A host that was removed (a test, or the user) lets a new install replace this one.\n if (installed && (installed.host.isConnected || !installed.appended)) {\n return installed.state;\n }\n const state: DevtoolsState = {\n log: [],\n blocks: new Map(),\n written: new Set(),\n endpoint,\n meta,\n errors: [],\n timeline: [],\n effects: new Map(),\n navigations: [],\n flash: false,\n };\n /** The handler that a server call or an update that starts now belongs to. */\n function owner(time: number): Interaction | undefined {\n for (let index = state.timeline.length - 1; index >= 0; index--) {\n const run = state.timeline[index]!;\n // An update of the answer of a call comes a moment after the handler settled.\n if (run.begun <= time && (run.settled === undefined || time <= run.settled + 32)) {\n return run;\n }\n }\n return undefined;\n }\n function add(entry: Omit<DevtoolsEntry, 'time'>): void {\n state.log.push({ ...entry, time: performance.now() });\n if (state.log.length > MAX_LOG) {\n state.log.splice(0, state.log.length - MAX_LOG);\n }\n state.changed?.();\n }\n const hooks: DevtoolsHooks = {\n attach(core) {\n state.scopes = core.scopes;\n state.set = core.set;\n state.handle = core.handle;\n state.changed?.();\n },\n handled(run) {\n const entry: Interaction = {\n ref: run.ref,\n label: `${run.event ?? 'call'} on <${run.element.tagName.toLowerCase()}>`,\n begun: run.begun,\n ready: run.ready,\n end: run.end,\n calls: [],\n updates: [],\n };\n if (run.result instanceof Promise) {\n run.result.then(\n () => {\n entry.settled = performance.now();\n state.changed?.();\n },\n () => {\n entry.settled = performance.now();\n entry.failed = true;\n state.changed?.();\n },\n );\n } else {\n entry.settled = run.end;\n }\n state.timeline.push(entry);\n if (state.timeline.length > 100) {\n state.timeline.shift();\n }\n state.changed?.();\n },\n updated(count, start, end) {\n if (count > 0) {\n owner(start)?.updates.push({ count, start, end });\n }\n },\n defer(template, done) {\n deferred(template, done);\n },\n handler(ref, element, event) {\n if (element.tagName === 'TEMPLATE') {\n let block: BlockEntry | undefined;\n for (const item of state.blocks.values()) {\n if (item.template === element) {\n block = item;\n break;\n }\n }\n if (block && block.fired === undefined) {\n block.fired = performance.now();\n moveBlock(block, 'fired', block.fired);\n }\n }\n add({\n kind: 'handler',\n text: `${event?.type ?? 'call'} on <${element.tagName.toLowerCase()}>: ${ref}`,\n });\n },\n effect(scope, name, kind, time) {\n const key = `${scope.id}:${name}`;\n let entry = state.effects.get(key);\n if (!entry) {\n entry = {\n scope: scope.id,\n component: findRootScope(scope).m ?? '',\n k: scope.k,\n name,\n runs: 0,\n recent: [],\n time: 0,\n cleanups: 0,\n active: false,\n };\n state.effects.set(key, entry);\n }\n const now = performance.now();\n if (kind === 'pending') {\n entry.pending = true;\n } else if (kind === 'skip') {\n entry.pending = false;\n } else if (kind === 'run') {\n entry.pending = false;\n entry.runs++;\n entry.time += time;\n entry.recent.push(now);\n if (entry.recent.length > 50) {\n entry.recent.shift();\n }\n entry.active = true;\n } else {\n entry.cleanups++;\n entry.lastCleanup = now;\n entry.active = false;\n }\n state.changed?.();\n },\n navigated(report) {\n state.navigations.push(report);\n if (state.navigations.length > 20) {\n state.navigations.shift();\n }\n state.changed?.();\n },\n write(scope, slot, value) {\n state.written.add(scope.id);\n const root = findRootScope(scope);\n add({\n kind: 'write',\n text: `scope ${scope.id} slot ${slot} = ${preview(value)}`,\n scope: scope.id,\n write: { component: root.m ?? '', k: scope.k, slot },\n });\n },\n };\n (globalThis as Record<symbol, DevtoolsHooks | undefined>)[DEVTOOLS] = hooks;\n\n // The swap of a body keeps its fallback in development, by boundary, so the fallback can show\n // again. While it shows, the body is out of the page, and updates of its nodes wait there.\n state.showFallback = (block, on) => {\n const kept = (globalThis as { $bD?: Record<string, { f: Node[]; b: Node[] }> }).$bD?.[block.id];\n if (!kept || (block.fallback ?? false) === on) {\n return false;\n }\n const [shown, hidden] = on ? [kept.b, kept.f] : [kept.f, kept.b];\n let anchor: Node | undefined;\n for (const node of shown) {\n if (node.parentNode) {\n anchor = node;\n break;\n }\n }\n if (!anchor) {\n return false;\n }\n for (const node of hidden) {\n anchor.parentNode!.insertBefore(node, anchor);\n }\n for (const node of shown) {\n node.parentNode?.removeChild(node);\n }\n block.fallback = on;\n state.changed?.();\n return true;\n };\n\n // Server function calls, with how long each took and how it answered.\n // Code that replaced fetch since the last install (a test stub) is kept and wrapped.\n const unwrapped =\n installed && globalThis.fetch === installed.wrapper ? installed.fetch : globalThis.fetch;\n const original = unwrapped.bind(globalThis);\n globalThis.fetch = async (input, init) => {\n const url = new URL(input instanceof Request ? input.url : String(input), location.href);\n if (url.origin !== location.origin || !url.pathname.startsWith(`${rpc}/`)) {\n return original(input, init);\n }\n const name = decodeURIComponent(url.pathname.slice(rpc.length + 1));\n const started = performance.now();\n const call: CallTiming = { name, start: started };\n const headers: Record<string, string> = {};\n for (const [header, value] of new Headers(init?.headers)) {\n if (header === 'content-type' || header.startsWith('x-brumate-')) {\n headers[header] = value;\n }\n }\n const body = init?.body;\n call.request = {\n url: url.pathname + url.search,\n headers,\n ...(typeof body === 'string' || body instanceof FormData ? { body } : {}),\n };\n owner(started)?.calls.push(call);\n try {\n const response = await original(input, init);\n const took = Math.round(performance.now() - started);\n const redirect = response.headers.get('x-brumate-redirect');\n call.end = performance.now();\n call.status = redirect ? 'redirect' : response.status;\n const server = /brumate;dur=([\\d.]+)/.exec(response.headers.get('server-timing') ?? '');\n if (server) {\n call.server = Number(server[1]);\n }\n // The record fills in once the arguments and the result are decoded. It reads a clone.\n const arrived = call.end;\n const copy = response.clone();\n void import('./devtools-calls.ts')\n .then(({ readCall }) =>\n readCall({\n name,\n init,\n response: copy,\n started,\n arrived,\n module: Math.max(0, started - (owner(started)?.ready ?? started)),\n }),\n )\n .then((record) => {\n call.record = record;\n state.changed?.();\n })\n .catch(() => {});\n state.changed?.();\n add({\n kind: 'call',\n text: `${name}: ${redirect ? `redirect to ${redirect}` : response.status} in ${took} ms`,\n call,\n });\n return response;\n } catch (error) {\n call.end = performance.now();\n call.status = 'failed';\n add({\n kind: 'call',\n text: `${name}: failed, ${error instanceof Error ? error.message : String(error)}`,\n call,\n });\n throw error;\n }\n };\n\n // Blocks: the markers of the page tell their state, so the panel follows the changes of the DOM.\n function deferred(template: Element, done: Promise<unknown>): void {\n let block: BlockEntry | undefined;\n for (const item of state.blocks.values()) {\n if (item.template === template) {\n block = item;\n break;\n }\n }\n // The loader asks once, so a block that is already loading waits for its first request.\n const asked = block !== undefined && block.state !== 'loading';\n if (block) {\n block.fired ??= performance.now();\n moveBlock(block, 'fired', block.fired);\n }\n void done.finally(() => {\n scanBlocks(state);\n // A body that arrived rendered the block in the scan, so one still loading got none.\n if (block && asked) {\n moveBlock(block, 'settled', performance.now());\n }\n state.changed?.();\n });\n }\n state.fire = (block) => {\n if (block.kind === 'defer' && block.template) {\n deferred(\n block.template,\n import('./defer.ts').then((module) => module.loadDeferred(block.template!)),\n );\n } else if (block.template && block.ref) {\n void state.handle?.(block.template, block.ref);\n }\n };\n if (typeof MutationObserver !== 'undefined') {\n let queued = false;\n new MutationObserver(() => {\n if (!queued) {\n queued = true;\n queueMicrotask(() => {\n queued = false;\n if (scanBlocks(state)) {\n state.changed?.();\n }\n });\n }\n }).observe(document, { childList: true, subtree: true, characterData: true });\n }\n scanBlocks(state);\n\n const host = document.createElement('brumate-devtools');\n (globalThis as Record<symbol, Installed | undefined>)[INSTALLED] = {\n state,\n host,\n appended: false,\n fetch: unwrapped,\n wrapper: globalThis.fetch,\n };\n const mark = (globalThis as Record<symbol, Installed | undefined>)[INSTALLED]!;\n const root = host.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = `\n.open { position: fixed; left: 50%; bottom: 0; z-index: 2147483647; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; height: 6px; max-width: 44px; padding: 0 10px; overflow: hidden; border: 0; border-radius: 7px 7px 0 0; background: #3a373d; color: #ece8e4; font: 500 12px/1 system-ui, -apple-system, sans-serif; white-space: nowrap; cursor: pointer; touch-action: none; outline: none; transition: height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), max-width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s; }\n.open[hidden] { display: none; }\n.open > * { opacity: 0; transition: opacity 0.12s; }\n.open[data-errors] { background: #c94a4a; max-width: 64px; }\n.open:hover, .open:focus-visible { height: 30px; max-width: 320px; background: #1d1c1f; box-shadow: 0 0 0 1px #36333a; }\n.open[data-errors]:hover, .open[data-errors]:focus-visible { box-shadow: 0 0 0 1px #ff6b6b66; }\n.open:hover > *, .open:focus-visible > * { opacity: 1; transition-delay: 0.08s; }\n.mark { display: inline-flex; width: 16px; height: 16px; flex: none; }\n.name { font-weight: 600; }\n.version { color: #a39a92; font: 11px ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace; }\n.count { padding: 0 6px; border-radius: 999px; background: #ff6b6b26; color: #ff6b6b; font: 600 10.5px/17px ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace; }\n.count:empty { display: none; }\n@media (prefers-reduced-motion: reduce) { .open, .open > * { transition: none; } }\n`;\n // The closed panel: a grip on the bottom edge that grows into a pull tab on hover or focus, so\n // it covers almost none of the page. A click, or a drag up, opens the panel.\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'open';\n button.title = 'brumate devtools (Alt+Shift+D)';\n button.innerHTML = trustedHTML(\n `<span class=\"mark\">${LOGO}</span><span class=\"name\">brumate</span><span class=\"version\"></span><span class=\"count\"></span>`,\n );\n // The version of brumate, next to its mark.\n button.querySelector('.version')!.textContent = meta.version ?? '';\n function label(): void {\n const errors = state.errors.length;\n button.setAttribute(\n 'aria-label',\n `Open the brumate devtools${meta.version ? `, version ${meta.version}` : ''}${errors > 0 ? `, ${errors} errors` : ''}`,\n );\n }\n label();\n // The number of errors, in red on the tab, and a red grip, so an error shows while it is closed.\n const count = button.querySelector<HTMLElement>('.count')!;\n state.errorCount = (): void => {\n count.textContent =\n state.errors.length > 0\n ? `${state.errors.length} ${state.errors.length === 1 ? 'issue' : 'issues'}`\n : '';\n button.toggleAttribute('data-errors', state.errors.length > 0);\n label();\n };\n // Dragging the tab up past a few pixels opens the panel under the pointer. A press that does not\n // move is left to the click.\n let dragged = false;\n button.addEventListener('pointerdown', (event) => {\n if (event.button !== 0) {\n return;\n }\n const start = event.clientY;\n let opened = false;\n dragged = false;\n function move(next: PointerEvent): void {\n if (!opened) {\n if (start - next.clientY < 4) {\n return;\n }\n opened = true;\n dragged = true;\n void panelModule().then(({ openPanel }) => {\n openPanel(root, state);\n state.resize?.(next.clientY);\n });\n return;\n }\n state.resize?.(next.clientY);\n }\n // The tab hides as the panel opens, so the pointer is followed on the window.\n function end(): void {\n removeEventListener('pointermove', move);\n removeEventListener('pointerup', end);\n removeEventListener('pointercancel', end);\n if (opened) {\n state.resized?.();\n }\n }\n addEventListener('pointermove', move);\n addEventListener('pointerup', end);\n addEventListener('pointercancel', end);\n });\n button.addEventListener('click', () => {\n if (dragged) {\n dragged = false;\n return;\n }\n void panelModule().then(({ togglePanel }) => togglePanel(root, state));\n });\n // Alt+Shift+D opens and closes the panel. `code`, because Alt changes the key on macOS.\n addEventListener('keydown', (event) => {\n if (event.altKey && event.shiftKey && event.code === 'KeyD') {\n event.preventDefault();\n void panelModule().then(({ togglePanel }) => togglePanel(root, state));\n }\n });\n state.open = (tab) => {\n void import('./devtools-panel.ts').then(({ openPanel }) => openPanel(root, state, tab));\n };\n root.append(style, button);\n installFlash(state, root, host);\n\n // Errors of code of the page in the browser. Errors of other code are left out.\n addEventListener('error', (event) => {\n const stack = (event.error as Error | undefined)?.stack;\n if (foreign(stack, event.filename)) {\n return;\n }\n const error = event.error as Error | undefined;\n // The message of the error, without the `Uncaught` that the browser puts before it.\n reportError(\n state,\n { message: error?.message ?? event.message, stack: error?.stack },\n 'browser',\n );\n });\n addEventListener('unhandledrejection', (event) => {\n const reason = event.reason as Error | undefined;\n if (foreign(reason?.stack)) {\n return;\n }\n reportError(\n state,\n { message: reason?.message ?? String(event.reason), stack: reason?.stack },\n 'browser',\n );\n });\n // Errors of handlers and updates that no `#try` caught. The core catches them, so they do not\n // reach the listeners above.\n addEventListener('brumate:error', (event) => {\n const error = (event as CustomEvent<{ error: unknown }>).detail.error as Error | undefined;\n reportError(\n state,\n { message: error?.message ?? String(error), stack: error?.stack },\n 'browser',\n );\n });\n // Errors of Vite, such as a compile error after an edit, which its overlay would show. A good\n // update after them clears them.\n hot?.on('vite:error', (payload: { err: ErrorPayload }) => {\n reportError(state, payload.err, 'compile');\n });\n hot?.on('vite:afterUpdate', () => {\n const before = state.errors.length;\n const remaining: ErrorEntry[] = [];\n for (const error of state.errors) {\n if (error.source !== 'compile') {\n remaining.push(error);\n }\n }\n state.errors = remaining;\n if (state.errors.length !== before) {\n state.errorCount?.();\n state.changed?.();\n }\n });\n function append(): void {\n // Navigation replaces the body, so the button goes on the document element.\n document.documentElement.append(host);\n mark.appended = true;\n }\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', append);\n } else {\n append();\n }\n return state;\n}\n"],"mappings":";;;;AAGA,MAAM,YAAY;;AAOlB,MAAM,OAAO;CACX,MAAM;EAAE,MAAM;EAAW,MAAM;CAA0B;CACzD,MAAM;EAAE,MAAM;EAAW,MAAM;CAAyB;CACxD,KAAK;EAAE,MAAM;EAAW,MAAM;CAA0B;AAC1D;;AAuBA,SAAS,SAAS,OAAqB;CACrC,IAAI,SAAS,GACX,OAAO;CAET,OAAO,SAAS,IAAI,SAAS;AAC/B;AAEA,SAAS,gBAAyB;CAChC,OAAO,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAC5F;;;;;;;;AASA,SAAgB,aAAa,OAAsB,MAAkB,MAAyB;CAC5F,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,OAAO,YAAY;CACnB,OAAO,MAAM,UACX;CACF,KAAK,OAAO,MAAM;CAClB,MAAM,UAAU,OAAO,WAAW,IAAI;CACtC,MAAM,QAAsB,CAAC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U,KAAK,KAAK;EAGxB,MAAM,SAAS;EACf,IAAI,MAAM,OAAO,WAAW,QAAQ;GAClC,MAAM,aAAa;GACnB,MAAM,UAAU;EAClB;CACF,CAAC;CACD,SAAS,SAAe;EAEtB,SAAS,gBAAgB,OAAO,IAAI;EACpC,KAAK,WAAW;CAClB;CACA,IAAI,SAAS,eAAe,WAC1B,SAAS,iBAAiB,oBAAoB,MAAM;MAEpD,OAAO;CAET,OAAO;AACT"}
|
|
@@ -136,7 +136,6 @@ const SCRIPT = [
|
|
|
136
136
|
entry("BRM093", "{name} does not return a value", "`$effect` or `$client` is assigned to a name.", "$effect(() => {\n document.title = title;\n});"),
|
|
137
137
|
entry("BRM094", "{name} needs a function", "`$effect` or `$client` has no function as its callback.", "$effect(() => {\n document.title = title;\n});"),
|
|
138
138
|
entry("BRM095", "The callback of {name} takes no parameters", "The callback of `$effect` or `$client` has parameters.", "$effect(() => {\n document.title = title;\n});"),
|
|
139
|
-
entry("BRM096", "The callback of {name} cannot be async", "The callback of `$effect` or `$client` is `async`.", "$effect(() => {\n load(id).then((value) => (data = value));\n});"),
|
|
140
139
|
entry("BRM097", "$effect takes one argument", "`$effect` has more than one argument.", "$effect(() => {\n document.title = title;\n});"),
|
|
141
140
|
entry("BRM098", "The trigger of $client must be \"visible\", \"idle\" or \"load\"", "The second argument of `$client` is another string.", "$client(() => {\n measure();\n}, 'idle');"),
|
|
142
141
|
entry("BRM099", "$handler needs a function as its first argument: a function expression, a function of the script, or one of them in a wrapper of brumate/events", "The first argument of `$handler` is not a function.", "onClick: $handler(prevent(removeAt), index),"),
|
|
@@ -157,7 +156,7 @@ const SCRIPT = [
|
|
|
157
156
|
entry("BRM114", "The prop \"{name}\" is not Bindable. Type it as Bindable<HTMLElement>, so a parent can bind it", "A `let` prop is used as a `ref` and its type is not `Bindable`.", "let { ref } = $props<{ ref?: Bindable<HTMLButtonElement> }>();"),
|
|
158
157
|
entry("BRM115", "\"{name}\" is the props object, so read one key at a time, destructure it, or spread it in markup", "The props object or the rest of `$props()` is used as a whole outside a markup spread: spread in code, passed to a function, `$memo`, `$setContext`, a signal or a variable, or given as a value in markup, such as `title=rest` or `<Badge {rest} />`. The copy loses the `ref` and the live props. A spread may hold the rest as a branch of `?:`, `&&`, `||` or `??` next to an object literal, `undefined`, `null` or `false`, such as `{...(open ? rest : {})}`.", "const { class: className, ...rest } = $props();\n<button {...rest} class=className>"),
|
|
159
158
|
entry("BRM116", "\"{name}\" is the props object, and props are read-only. Copy the key to a $signal or a $memo to change it", "Code assigns to, updates or deletes a key of the props object or of the rest of `$props()`.", "let title = $signal('');\ntitle = 'New';"),
|
|
160
|
-
entry("BRM117", "Cannot assign to {kind} \"{name}\"", "Code writes a memo, a const prop or another value that cannot change.", "let count = $signal(0);\ncount = 5;"),
|
|
159
|
+
entry("BRM117", "Cannot assign to {kind} \"{name}\"{hint}", "Code writes a memo, a const prop, a module signal of an import or another value that cannot change.", "let count = $signal(0);\ncount = 5;"),
|
|
161
160
|
entry("BRM118", "Signal \"{name}\" can only be written in event handlers, effects, $client callbacks and functions", "Setup code, which runs on the server, writes a signal.", "let count = $signal(5);"),
|
|
162
161
|
entry("BRM119", "Server function \"{name}\" captures \"{variable}\". Pass it as an argument", "A server function reads a variable of the instance script.", "async function save(user: string) {\n 'use server';\n}"),
|
|
163
162
|
entry("BRM120", "$optimistic follows a memo, an action or a prop, not a signal", "The source of `$optimistic` is a signal.", "let shown = $optimistic(items);"),
|
|
@@ -236,7 +235,15 @@ const MODULES = [
|
|
|
236
235
|
entry("BRM176", "{name} returns {local} as {first} and as {key}. Return each local once, and give the other key a function of its own", "A module function returns one local under two keys.", "return { count, increment };"),
|
|
237
236
|
entry("BRM177", "{name} is declared twice", "A name of the module function is also a name of the component.", "const { count: first } = counter(0);\nconst { count: second } = counter(10);"),
|
|
238
237
|
entry("BRM178", "Parameters of {name} must be plain names", "A module function has a destructured or default parameter.", "export function counter(start: number) {\n let count = $signal(start);\n return { count };\n}"),
|
|
239
|
-
entry("BRM179", "{name} reads {local}, which {specifier} does not export. Export it, so the component can import it", "A module function reads a value of its module that is not exported.", "export const STEP = 1;")
|
|
238
|
+
entry("BRM179", "{name} reads {local}, which {specifier} does not export. Export it, so the component can import it", "A module function reads a value of its module that is not exported.", "export const STEP = 1;"),
|
|
239
|
+
entry("BRM211", "{name} cannot be compiled in a module{reason}. {fix}", "A module uses a form that its top-level values cannot compile: a compile-time function that needs a component, such as `$effect`, at the top level, a gate or timed value that awaits, a memo, gate or timed value that calls a function it cannot follow, a form with the wrong arguments, or a signal in a destructuring write.", "export let count = $signal(0);\nexport const double = $memo(count * 2);"),
|
|
240
|
+
entry("BRM208", "\"{name}\" is a signal of {module}, and a file of plain code gets its store, not its value. {fix}", "A `.ts` or `.js` file imports a signal or a memo that a module declares at its top level. TypeScript types it as its value, and it is a store.", "// cart.brm.ts\nexport let items = $signal<number[]>([]);\nexport function count(): number {\n return items.length;\n}\n\n// plain.ts\nimport { count } from './cart.brm.ts';"),
|
|
241
|
+
entry("BRM209", "\"{name}\" is written only by this effect. Use {form}", "A warning. An `$effect` only assigns signals that nothing else writes, so each signal is a memo written the long way, and the page updates twice for one change. With one assignment and no `if`, the message gives the memo. An effect with a call, an `await`, a cleanup or a signal that a handler, another effect or a `$bind` also writes stays quiet.", "let count = $signal(0);\nconst message = $memo(`Clicked ${count} times`);"),
|
|
242
|
+
entry("BRM212", "A <script> with src is not inline. Give it src or inline, not both", "A `<script>` in markup has both `src` and `inline`. `src` loads a file, and `inline` marks code that is written in the file.", "<script src=\"https://example.com/chat.js\" trigger=\"idle\"><\/script>"),
|
|
243
|
+
entry("BRM213", "A <script> with src has no code inside. Write the code in <script inline>", "A `<script src>` in markup has text inside. The browser ignores it.", "<script inline trigger=\"idle\">\n window.dataLayer = [];\n<\/script>"),
|
|
244
|
+
entry("BRM214", "The trigger of a <script> is a plain string: idle, visible, interaction or load", "The `trigger` of a `<script>` in markup is code in braces, has no value, or names another trigger.", "<script src=\"https://example.com/chat.js\" trigger=\"interaction\"><\/script>"),
|
|
245
|
+
entry("BRM215", "A script in #head cannot wait to be visible, since no element follows it. Use idle or interaction", "A `<script trigger=\"visible\">` is in `#head`. `visible` waits for the element after the script to come into view.", "#head {\n <script src=\"https://example.com/chat.js\" trigger=\"idle\"><\/script>\n}"),
|
|
246
|
+
entry("BRM216", "A script with a trigger runs once per page, so data-rerun does not apply. Remove one of them", "A `<script>` in markup has `trigger` and `data-rerun`. A script with a trigger never runs again after a navigation.", "<script src=\"https://example.com/chat.js\" trigger=\"idle\"><\/script>")
|
|
240
247
|
];
|
|
241
248
|
const ERRORS = [
|
|
242
249
|
...SYNTAX,
|
|
@@ -305,4 +312,4 @@ function fenceLanguage(fix) {
|
|
|
305
312
|
//#endregion
|
|
306
313
|
export { findError as a, renderErrorsPage as c, errorLink as i, ERRORS as n, matchesError as o, ERRORS_PAGE as r, renderErrors as s, DOCS_SITE as t };
|
|
307
314
|
|
|
308
|
-
//# sourceMappingURL=error-catalog-
|
|
315
|
+
//# sourceMappingURL=error-catalog-BBWB7w-E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-catalog-BBWB7w-E.js","names":[],"sources":["../src/error-catalog.ts"],"sourcesContent":["/** One compile error of a `.brm` file. */\nexport interface ErrorEntry {\n /** The message the compiler reports, with `{name}` for the parts that vary. */\n message: string;\n /** What causes it, in one sentence. */\n cause: string;\n /** The form to write instead, as a short `brm` example. */\n fix: string;\n /** A code such as BRM012. It never changes and is never reused. */\n code?: string;\n /** The docs page that explains the code. */\n link?: string;\n}\n\n/**\n * Codes are stable. A new entry takes the next number that was never used,\n * wherever the entry sits in the catalog. Never change the code of an entry,\n * and never reuse a code. When an error is removed, delete its entry and\n * leave its number unused. test/error-codes.json pins each code to its\n * message, so a test fails when a code changes or is reused. Rewording a\n * message needs a hand edit of that file, for the same code. Add the code of\n * a new entry to it with `UPDATE_SKILL=1 npx vitest run test/check-command.test.ts`.\n */\n\n/** The address of the docs site. Change it here when the site moves. */\nexport const DOCS_SITE = 'https://brumate-docs.vercel.app';\n\n/** The page of the docs that explains every code, with one anchor for each. */\nexport const ERRORS_PAGE: string = `${DOCS_SITE}/docs/errors`;\n\n/** The link to the explanation of a code. */\nexport function errorLink(code: string): string {\n return `${ERRORS_PAGE}#${code.toLowerCase()}`;\n}\n\nfunction entry(code: string, message: string, cause: string, fix: string): ErrorEntry {\n return { message, cause, fix, code, link: errorLink(code) };\n}\n\n/** Syntax errors of the parser, in the order of a file. */\nconst SYNTAX: ErrorEntry[] = [\n entry(\n 'BRM001',\n 'Unterminated comment',\n 'A comment starts and never ends.',\n '<!-- A comment ends with -->\\n<script>\\n /* and so does this one */\\n</script>',\n ),\n entry(\n 'BRM002',\n 'Unterminated string',\n 'A string in code starts and never ends.',\n \"const name = 'Ada';\",\n ),\n entry(\n 'BRM003',\n 'Unterminated template literal',\n 'A template string starts and never ends.',\n 'const label = `Hello ${name}`;',\n ),\n entry(\n 'BRM004',\n 'Unterminated regular expression',\n 'A regular expression starts and never ends.',\n 'const digits = /\\\\d+/;',\n ),\n entry(\n 'BRM005',\n 'Unexpected \"{char}\"',\n 'Code has a bracket that closes nothing.',\n 'const list = [1, 2];',\n ),\n entry(\n 'BRM006',\n 'Expected \"{char}\"',\n 'Code opens a bracket and never closes it. The message names the closing one.',\n 'const list = [1, 2];',\n ),\n entry(\n 'BRM007',\n 'Expected \"}\" to close the block',\n 'A `#` block opens with `{` and the file ends before its `}`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM008',\n 'Unexpected end of file, expected a closing tag',\n 'An element is never closed.',\n '<div>\\n <p>Text</p>\\n</div>',\n ),\n entry('BRM009', 'Unexpected closing tag', 'A closing tag has no opening tag.', '<p>Text</p>'),\n entry(\n 'BRM010',\n '<script> must be at the top level or at the start of a block',\n 'A `<script>` is inside an element, or after other markup in a block.',\n '#for (item of items) {\\n <script>\\n let open = $signal(false);\\n </script>\\n <p>{item}</p>\\n}',\n ),\n entry(\n 'BRM011',\n '<style> must be at the top level of the file or of a block',\n 'A `<style>` is inside an element.',\n '<style>\\n p {\\n color: red;\\n }\\n</style>\\n<p>Text</p>',\n ),\n entry(\n 'BRM012',\n '#template must be at the top level or at the start of a block',\n 'A `#template` is inside an element, or after other markup in a block.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n entry(\n 'BRM013',\n '#{branch} must follow its block',\n 'A branch such as `#else` or `#catch` comes without the block that it belongs to.',\n '#if (open) {\\n <p>Open</p>\\n} #else {\\n <p>Closed</p>\\n}',\n ),\n entry('BRM014', 'Expected a tag name', 'A `<` starts a tag with no name.', '<p>1 < 2</p>'),\n entry(\n 'BRM015',\n '<{name}> must end with \"/>\"',\n '`<window>` and `<document>` take no children, so they close with `/>`.',\n '<window onKeyDown=(handler) />',\n ),\n entry('BRM016', 'Expected </{name}>', 'A closing tag is not complete.', '<p>Text</p>'),\n entry(\n 'BRM017',\n 'Unexpected end of file, expected \">\"',\n 'A tag starts and the file ends before its `>`.',\n '<input value=name>',\n ),\n entry(\n 'BRM018',\n 'Expected whitespace between attributes',\n 'Two attributes touch each other.',\n '<input id=name type=\"text\">',\n ),\n entry(\n 'BRM019',\n 'Only event handlers are allowed here',\n '`<window>` and `<document>` take event handlers and nothing else.',\n '<document onKeyDown=(handler) />',\n ),\n entry(\n 'BRM020',\n 'Expected a spread or a shorthand attribute',\n 'A `{` in a tag holds something other than `...rest` or a name.',\n '<a {href} {...rest}>Open</a>',\n ),\n entry(\n 'BRM021',\n 'Expected an attribute name',\n 'A tag has a character where an attribute name belongs.',\n '<input disabled>',\n ),\n entry(\n 'BRM022',\n 'Event modifiers in the attribute name were removed. Write {fix}',\n 'A modifier follows the event name, as in `onSubmit:prevent=send`. Wrappers of `brumate/events` write modifiers now, and `:passive` is the default, since listeners are passive unless a handler prevents.',\n \"import { prevent } from 'brumate/events';\\n\\n<form onSubmit=(prevent(send))></form>\",\n ),\n entry(\n 'BRM180',\n '\"{name}\" is not an event name. Write \"{camel}\"',\n 'An event of more than one word is written in camel case. The lower-case form is an error.',\n '<input onKeyDown=(handle) onFocusOut=(handle) />',\n ),\n entry(\n 'BRM201',\n '\"{name}\" cannot be a handler. {fix}',\n \"The event has capitals in its name, or the browser fires another name for it, and a handler name is lower-cased to the event. `onDOMContentLoaded` would listen to `domcontentloaded`, which the browser never fires, and page code loads after the HTML, mostly after `DOMContentLoaded`. Use the event that the message names, or `$client(fn, 'load')` to run code at load.\",\n \"<script>\\n $client(() => {\\n start();\\n }, 'load');\\n</script>\",\n ),\n entry(\n 'BRM186',\n '\"{name}\" in the #loading header is not a memo that markup in the body reads. Name a $memo of the component or of a block script around the block',\n 'The header of `#loading (…)` names something other than a memo, or a memo that no markup in the body reads, so its loads would not show the fallback for that body.',\n 'const posts = $memo(loadPosts(id));\\n#loading (posts) {\\n <p>{posts.length} posts</p>\\n} #else {\\n <p>Loading</p>\\n}',\n ),\n entry(\n 'BRM182',\n 'The handler reads \"{name}\", a memo that can lack a value. Wait for it with await $resolve({name}), or check $isPending({name}) first',\n 'A handler, a handler prop or a `$client` callback reads an async memo that may still be loading, with no `$isPending` check or `await $resolve` before the read.',\n '<script>\\n const user = $memo(getUser(id));\\n async function save() {\\n await $resolve(user);\\n send(user.name);\\n }\\n</script>',\n ),\n entry(\n 'BRM183',\n '$resolve needs a $memo and, as an option, a timeout or a signal',\n '`$resolve` takes the name of a memo, and one object of options at most.',\n 'async function save() {\\n const profile = await $resolve(user, { timeout: 5000 });\\n}',\n ),\n entry(\n 'BRM184',\n '$resolve cannot run where a memo computes or markup renders. Call it in a handler, an effect or a $client callback',\n '`$resolve` waits, so it is called where an event starts the code, not where a memo computes or markup renders.',\n 'async function save() {\\n await $resolve(user);\\n}',\n ),\n entry(\n 'BRM185',\n '<{tag}> cannot be inside <{parent}>: the HTML parser closes or moves it before the page runs. Move it out of the <{parent}>, or use a <span> or as=\"span\"',\n 'The HTML parser does not keep this nesting. A `<p>` ends at a block element such as `<div>`, an `<a>` or a `<form>` inside the same tag starts again, and a table keeps only table parts. The browser builds a page that differs from the markup, and the start and end markers of a block can land in different parents.',\n '<p>Total: <span>{total}</span></p>\\n<div>\\n <p>Total</p>\\n</div>',\n ),\n entry(\n 'BRM187',\n 'The {kind} {name} of {component} did not settle: it writes a value that it reads, and runs again without end. Wrap the read or the write in $untrack, or write only when the value changes',\n 'In the browser, an effect or an update writes a value that it reads, so each run schedules the next. Past 1000 rounds of effects, or 10000 rounds of updates, in one change, the page stops the loop and sends this error to the nearest `#try` in place of hanging the tab. A production build sends the short form `Update loop {scope}:{name} [BRM187]`.',\n \"<script>\\n import { $effect, $signal, $untrack } from 'brumate/signals';\\n\\n let query = $signal('');\\n let saves = $signal(0);\\n\\n $effect(() => {\\n void query;\\n $untrack(saves++);\\n });\\n</script>\",\n ),\n entry(\n 'BRM188',\n '\"{name}\" gives a promise, and {place} cannot wait for one. Await it in the code that runs, or read its value with $memo',\n 'Markup waits for a promise in text and in attribute values only. An event handler, the key of a `#for`, a `ref` and a `$bind` need the value at once, and the compiler sees that this expression gives a promise: `new Promise(…)`, a call of a server function or of an async function, or a prop typed as a promise.',\n '<button onClick=(() => save(draft))>Save</button>\\n#for (user of users by user.id) {\\n <p>{user.name}</p>\\n}',\n ),\n entry(\n 'BRM024',\n 'Expected an event handler',\n 'An event attribute has no `=` and no value.',\n '<button onClick=(() => count++)>Add</button>',\n ),\n entry(\n 'BRM025',\n 'An event handler must be an expression, not a string',\n 'The value of an event attribute is a quoted string.',\n '<button onClick=(() => count++)>Add</button>',\n ),\n entry(\n 'BRM026',\n 'An attribute name can have one \":\" namespace',\n 'An attribute name has two or more `:`.',\n '<svg xlink:href=\"#icon\"></svg>',\n ),\n entry(\n 'BRM027',\n 'ref takes $bind, as in ref=$bind(name)',\n '`ref` has a value that is not `$bind(name)`.',\n '<input ref=$bind(input)>',\n ),\n entry(\n 'BRM028',\n 'prefetch is removed. The code of the page loads when it starts',\n 'The `prefetch` attribute no longer exists.',\n '<a href=\"/about\">About</a>',\n ),\n entry(\n 'BRM029',\n 'Markup is not allowed in attribute values. Use a #template.',\n 'An attribute value holds an element.',\n '<List item=row />\\n\\n#template row(name: string) {\\n <b>{name}</b>\\n}',\n ),\n entry(\n 'BRM030',\n 'Expected an attribute value',\n 'An attribute has `=` and nothing after it.',\n '<input value=name>',\n ),\n entry(\n 'BRM031',\n 'Wrap this attribute value in parentheses',\n 'An attribute value without quotes has an operator or a space in it.',\n '<button disabled=(count > 3)>Add</button>',\n ),\n entry(\n 'BRM032',\n 'Expected \">\" to end <{name}>',\n 'A tag has text where its `>` belongs.',\n '<input value=name>',\n ),\n entry(\n 'BRM033',\n 'Expected a quoted value',\n 'A `<script>` or `<style>` attribute has `=` without a quoted value.',\n '<script generics=\"T\"></script>',\n ),\n entry(\n 'BRM034',\n 'Expected {close}',\n 'A `<script>` or `<style>` is not closed.',\n '<script>\\n let a = 1;\\n</script>',\n ),\n entry(\n 'BRM035',\n 'Unknown <script> attribute \"{name}\"',\n 'A `<script>` has an attribute other than `module` and `generics`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM036',\n 'A file can have one <script module>',\n 'A file has two module scripts.',\n '<script module>\\n export const MAX = 10;\\n export const MIN = 1;\\n</script>',\n ),\n entry(\n 'BRM037',\n 'A file can have one <script>',\n 'A file has two instance scripts.',\n '<script>\\n let a = $signal(1);\\n let b = $signal(2);\\n</script>',\n ),\n entry(\n 'BRM038',\n 'lang must be \"css\", \"scss\" or \"less\"',\n 'A `<style>` names another language.',\n '<style lang=\"scss\">\\n p {\\n a {\\n color: red;\\n }\\n }\\n</style>',\n ),\n entry(\n 'BRM189',\n 'Unknown <style> attribute \"{name}\"',\n 'A `<style>` has an attribute other than `lang` and `global`.',\n '<style scoped>\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM207',\n '#reveal has no style of its own',\n 'A `<style>` is in the body of a `#reveal`, which only orders the bodies inside it.',\n '<style>\\n p {\\n color: red;\\n }\\n</style>\\n#reveal {\\n #loading {\\n <p>Loaded</p>\\n }\\n}',\n ),\n entry(\n 'BRM190',\n 'global takes no value, as in <style global>',\n 'A `<style global>` gives `global` a value.',\n '<style global=\"true\">\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM039',\n \"#reveal takes an order, 'sequential', 'backwards', 'together' or 'natural', and collapsed, such as #reveal ('sequential', collapsed)\",\n '`#reveal` has an option that it does not know.',\n \"#reveal ('sequential', collapsed) {\\n …\\n}\",\n ),\n entry(\n 'BRM040',\n \"collapsed shows the fallback of the next body to show, so it needs the order 'sequential', not '{order}'\",\n '`collapsed` goes with `sequential` only.',\n \"#reveal ('sequential', collapsed) {\\n …\\n}\",\n ),\n entry(\n 'BRM041',\n '#reveal has no script of its own',\n 'A `#reveal` body starts with a `<script>`.',\n '<script>\\n let open = $signal(false);\\n</script>\\n#reveal {\\n …\\n}',\n ),\n entry(\n 'BRM042',\n 'Expected \"(\" after #{keyword}',\n 'A block that takes a condition or a list has no `(`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM043',\n 'Expected an expression after #{keyword}',\n 'The parentheses of a block are empty.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM044',\n 'Expected \"{\" after #{keyword}',\n 'The header of a block is not followed by `{`.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM045',\n 'Expected \"{\" after #switch',\n '`#switch` has no `{` after it.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n}',\n ),\n entry(\n 'BRM046',\n 'The script of a block takes no attributes',\n 'A `<script>` at the start of a block has attributes such as `module`.',\n '#for (item of items) {\\n <script>\\n let open = $signal(false);\\n </script>\\n <p>{item}</p>\\n}',\n ),\n entry(\n 'BRM047',\n '#try needs a #catch block',\n 'A `#try` body is not followed by `#catch`.',\n '#try {\\n <p>{load()}</p>\\n} #catch (error, reset) {\\n <p>Failed</p>\\n}',\n ),\n entry(\n 'BRM048',\n 'Expected \"(error, reset)\" after #catch',\n 'The header of `#catch` names something other than a plain error name and a plain reset name.',\n '#catch (error, reset) {\\n <p>{String(error)}</p>\\n}',\n ),\n entry(\n 'BRM049',\n 'The trigger of #{keyword} must be \"visible\", \"idle\" or \"load\"',\n 'A `#client` block names another trigger.',\n \"#client ('idle') {\\n <p>In the browser</p>\\n}\",\n ),\n entry(\n 'BRM050',\n 'Unknown block #{keyword}',\n 'A `#` starts a block that does not exist.',\n '#if (open) {\\n <p>Open</p>\\n}',\n ),\n entry(\n 'BRM051',\n 'Expected \"index of count\" after #repeat',\n 'The header of `#repeat` is not `index of count`.',\n '#repeat (star of 5) {\\n <i>{star}</i>\\n}',\n ),\n entry(\n 'BRM052',\n 'Expected \"item of list\" or \"item, index of list\" after #for',\n 'The header of `#for` has no `of`.',\n '#for (item, index of items by item.id) {\\n <li>{item.name}</li>\\n}',\n ),\n entry(\n 'BRM053',\n 'Expected the height of an item in window(height)',\n '`window` after a `#for` header has no height.',\n '#for (row of rows by row.id) window(32) {\\n <tr><td>{row.name}</td></tr>\\n}',\n ),\n entry(\n 'BRM054',\n 'Only #case and #default are allowed in #switch',\n 'A `#switch` holds markup other than its cases.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n #default {\\n <p>Other</p>\\n }\\n}',\n ),\n entry(\n 'BRM055',\n '#default must be the last branch of #switch',\n 'A `#case` comes after the `#default`.',\n '#switch {\\n #case (tab === 1) {\\n <p>One</p>\\n }\\n #default {\\n <p>Other</p>\\n }\\n}',\n ),\n entry(\n 'BRM056',\n 'Expected \"(\" after the name of the template',\n 'A `#template` has no parameter list.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n entry(\n 'BRM057',\n 'Expected an expression',\n 'An attribute or a block has code that is not an expression.',\n '<p>{count + 1}</p>',\n ),\n entry(\n 'BRM058',\n 'Expected a binding pattern',\n 'The name of a `#for` or `#catch` is not a name or a pattern.',\n '#for ({ id, name } of people by id) {\\n <li>{name}</li>\\n}',\n ),\n entry(\n 'BRM059',\n 'Expected parameters',\n 'The parameters of a `#template` are not a parameter list.',\n '#template price(amount: number) {\\n <b>{amount}</b>\\n}',\n ),\n];\n\n/** Errors about `$signal`, `$memo` and the other compile-time functions. */\nconst SCRIPT: ErrorEntry[] = [\n entry(\n 'BRM060',\n '\"{name}\" is already declared',\n 'Two declarations of one scope have the same name.',\n 'let count = $signal(0);\\nlet total = $signal(0);',\n ),\n entry(\n 'BRM061',\n '{name} takes a handler',\n '`prevent`, `stop`, `once`, `capture` or `transition` has no handler, or `stop`, `once` or `capture` has keys.',\n '<form onSubmit=(prevent(send))></form>',\n ),\n entry(\n 'BRM062',\n 'Only prevent of a keyboard event takes keys, such as onKeyDown',\n 'Keys are given to `prevent` of an event that is not `onKeyDown`, `onKeyUp` or `onKeyPress`.',\n \"<ul onKeyDown=(prevent(move, 'ArrowDown'))></ul>\",\n ),\n entry(\n 'BRM063',\n \"Name each key of prevent as a string of its event.key, such as 'ArrowDown', 'Space' or 'a', with a modifier to hold if it needs one, such as 'Mod+ArrowDown'\",\n 'A key of `prevent` is not a string literal of an `event.key`.',\n \"<ul onKeyDown=(prevent(move, 'ArrowDown', 'Mod+ArrowUp'))></ul>\",\n ),\n entry(\n 'BRM064',\n \"Name each key of prevent as a string, such as 'Enter'\",\n 'A key of `prevent` is not a string literal.',\n \"<input onKeyDown=(prevent(submit, 'Enter'))>\",\n ),\n entry(\n 'BRM065',\n 'Server function \"{name}\" must be async',\n \"A function with `'use server'` is not `async`.\",\n \"async function save(list: string[]) {\\n 'use server';\\n await db.save(list);\\n}\",\n ),\n entry(\n 'BRM066',\n 'The module script cannot have a default export',\n '`<script module>` has `export default`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM067',\n 'A script cannot export values. Use <script module>',\n 'The instance script has an `export`.',\n '<script module>\\n export const MAX = 10;\\n</script>',\n ),\n entry(\n 'BRM068',\n '$title takes one argument, the title',\n '`$title` has no argument or more than one.',\n \"$title('Todos');\",\n ),\n entry(\n 'BRM069',\n 'await works with $memo, not {name}',\n 'A declaration awaits a compile-time function other than `$memo`.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM070',\n '$props() can only be called in the component script',\n '`$props()` is in a module script or a function.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM071',\n 'Assign $props() to a const or a let',\n 'The result of `$props()` is not assigned with `const` or `let`.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM072',\n '$props() takes no arguments',\n '`$props()` has an argument.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM073',\n 'Assign $props() to a name or an object pattern',\n '`$props()` is assigned to an array pattern.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM074',\n 'Create an ID with \"const name = $id()\"',\n '`$id()` is not the value of a `const`.',\n 'const field = $id();',\n ),\n entry('BRM075', '$id takes no arguments', '`$id` has an argument.', 'const field = $id();'),\n entry(\n 'BRM076',\n '$isPassed takes a prop that the component destructures, such as $isPassed(value)',\n 'The argument of `$isPassed` is not a prop of the component.',\n 'let { value } = $props<{ value?: Bindable<string> }>();\\nconst passed = $isPassed(value);',\n ),\n entry(\n 'BRM077',\n '$navigation takes no arguments',\n '`$navigation` has an argument.',\n 'const navigation = $navigation();',\n ),\n entry(\n 'BRM078',\n '$route takes at most one argument, the path of the route',\n '`$route` has more than one argument.',\n \"const route = $route('/posts/[id]');\",\n ),\n entry(\n 'BRM079',\n 'Read a context with \"const name = $getContext(Context)\"',\n '`$getContext` is not the value of a `const`.',\n 'const theme = $getContext(ThemeContext);',\n ),\n entry(\n 'BRM080',\n '$getContext takes the context, and a fallback for a read without a provider',\n '`$getContext` has no argument or more than two.',\n 'const theme = $getContext(ThemeContext);\\nconst locale = $getContext(LocaleContext, undefined);',\n ),\n entry(\n 'BRM081',\n '$setContext takes two arguments, the context and the value',\n '`$setContext` has fewer or more than two arguments.',\n '$setContext(ThemeContext, theme);',\n ),\n entry(\n 'BRM082',\n 'Declare the result of a form with \"const name = $action(serverFunction)\"',\n '`$action` is not the value of a `const`.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM083',\n '$action needs a server function of this file as its only argument',\n '`$action` has no argument, or more than one.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM084',\n '$action needs a server function of this file, and {name} is not one',\n \"The argument of `$action` is not a function with `'use server'` in this file.\",\n \"async function save(data: FormData) {\\n 'use server';\\n}\\nconst result = $action(save);\",\n ),\n entry(\n 'BRM085',\n 'Declare {name} with const',\n '`$debounced` or `$throttled` is declared with `let`.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM086',\n '{name} cannot be destructured',\n 'A signal, a memo or another value of a compile-time function is declared with a pattern.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM087',\n '{name} takes a value and a wait in milliseconds',\n '`$debounced` or `$throttled` does not have both arguments.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM088',\n 'The wait of {name} must be a number of milliseconds, such as 300',\n 'The wait of `$debounced` or `$throttled` is not a number literal.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM089',\n 'Declare {name} with {expected}',\n '`$signal` and `$optimistic` need `let`, and `$memo` needs `const`.',\n 'let count = $signal(0);\\nconst double = $memo(count * 2);',\n ),\n entry(\n 'BRM090',\n '{name} takes one argument',\n '`$signal`, `$memo` or `$optimistic` has more than one argument.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM091',\n '{name} needs a value',\n '`$memo` or `$optimistic` has no argument.',\n 'const double = $memo(count * 2);',\n ),\n entry(\n 'BRM092',\n '$optimistic needs the name of a value, such as a memo',\n 'The argument of `$optimistic` is not a name.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM093',\n '{name} does not return a value',\n '`$effect` or `$client` is assigned to a name.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM094',\n '{name} needs a function',\n '`$effect` or `$client` has no function as its callback.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM095',\n 'The callback of {name} takes no parameters',\n 'The callback of `$effect` or `$client` has parameters.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM097',\n '$effect takes one argument',\n '`$effect` has more than one argument.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM098',\n 'The trigger of $client must be \"visible\", \"idle\" or \"load\"',\n 'The second argument of `$client` is another string.',\n \"$client(() => {\\n measure();\\n}, 'idle');\",\n ),\n entry(\n 'BRM099',\n '$handler needs a function as its first argument: a function expression, a function of the script, or one of them in a wrapper of brumate/events',\n 'The first argument of `$handler` is not a function.',\n 'onClick: $handler(prevent(removeAt), index),',\n ),\n entry(\n 'BRM100',\n 'The handler reads \"{name}\", a value of the function around $handler, which the browser does not have. Pass it as an argument: $handler(fn, {name})',\n 'A handler reads a local value of the function that calls `$handler`.',\n 'onClick: $handler(removeAt, index),',\n ),\n entry(\n 'BRM101',\n 'The arguments of $handler cannot be spread',\n '`$handler` has a spread argument.',\n 'onClick: $handler(removeAt, index, kind),',\n ),\n entry(\n 'BRM102',\n 'The second argument of $bind is a function that takes the new value: a function expression, or a function of the script',\n 'The setter of `$bind` is not a function.',\n '<Toggle on=$bind(open, (next) => (open = next)) />',\n ),\n entry(\n 'BRM103',\n 'The setter reads \"{name}\", a value of the function around $bind, which the browser does not have',\n 'The setter of `$bind` reads a local value that is not a value of the component.',\n '<Toggle on=$bind(open, (next) => (open = next)) />',\n ),\n entry(\n 'BRM104',\n 'Pass $bind(name) as the value of a prop of a component, or of value or checked of an input, a select or a textarea',\n '`$bind` is somewhere else, such as on a `class` or a `<div>`.',\n '<input value=$bind(draft)>',\n ),\n entry(\n 'BRM105',\n '$bind takes the name of a signal, and a function that writes it, such as $bind(open) or $bind(open, (next) => (open = next))',\n '`$bind` has no argument, or an argument that is not a name.',\n '<Toggle on=$bind(open) />',\n ),\n entry(\n 'BRM106',\n '$bind takes a signal, or a prop that the component destructures with let, and \"{name}\" is not one',\n 'The name in `$bind` is a memo, a const prop or another value.',\n 'let open = $signal(false);\\n<Toggle on=$bind(open) />',\n ),\n entry(\n 'BRM107',\n '$isBound takes a prop that the component destructures with let, such as $isBound(open)',\n 'The argument of `$isBound` is not a `let` prop.',\n 'let { open } = $props<{ open?: Bindable<boolean> }>();\\nconst bound = () => $isBound(open);',\n ),\n entry(\n 'BRM108',\n '$isPending needs async $memos as its arguments',\n 'An argument of `$isPending` is not a memo that holds a promise, or the call has none.',\n 'const results = $memo(search(query));\\n#if ($isPending(results)) {\\n <p>Searching…</p>\\n}',\n ),\n entry(\n 'BRM109',\n '$produce needs a signal as its first argument',\n 'The first argument of `$produce` is not a signal.',\n '$produce(todos, (draft) => {\\n draft.push(todo);\\n});',\n ),\n entry(\n 'BRM110',\n '$produce needs a recipe function as its second argument',\n 'The second argument of `$produce` is not a function.',\n '$produce(todos, (draft) => {\\n draft.push(todo);\\n});',\n ),\n entry(\n 'BRM111',\n '\"{name}\" is reserved. Brumate writes the attributes that start with \"b-\"',\n 'An attribute starts with `b-`.',\n '<div data-id=id></div>',\n ),\n entry(\n 'BRM112',\n '\"{name}\" is not declared',\n 'The name in `ref=$bind(name)` is not a value of the component.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM113',\n 'ref takes a $signal, or a prop that the component destructures with let, but \"{name}\" is {kind}',\n 'The name in `ref=$bind(name)` is a memo, a const prop or another value.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM114',\n 'The prop \"{name}\" is not Bindable. Type it as Bindable<HTMLElement>, so a parent can bind it',\n 'A `let` prop is used as a `ref` and its type is not `Bindable`.',\n 'let { ref } = $props<{ ref?: Bindable<HTMLButtonElement> }>();',\n ),\n entry(\n 'BRM115',\n '\"{name}\" is the props object, so read one key at a time, destructure it, or spread it in markup',\n 'The props object or the rest of `$props()` is used as a whole outside a markup spread: spread in code, passed to a function, `$memo`, `$setContext`, a signal or a variable, or given as a value in markup, such as `title=rest` or `<Badge {rest} />`. The copy loses the `ref` and the live props. A spread may hold the rest as a branch of `?:`, `&&`, `||` or `??` next to an object literal, `undefined`, `null` or `false`, such as `{...(open ? rest : {})}`.',\n 'const { class: className, ...rest } = $props();\\n<button {...rest} class=className>',\n ),\n entry(\n 'BRM116',\n '\"{name}\" is the props object, and props are read-only. Copy the key to a $signal or a $memo to change it',\n 'Code assigns to, updates or deletes a key of the props object or of the rest of `$props()`.',\n \"let title = $signal('');\\ntitle = 'New';\",\n ),\n entry(\n 'BRM117',\n 'Cannot assign to {kind} \"{name}\"{hint}',\n 'Code writes a memo, a const prop, a module signal of an import or another value that cannot change.',\n 'let count = $signal(0);\\ncount = 5;',\n ),\n entry(\n 'BRM118',\n 'Signal \"{name}\" can only be written in event handlers, effects, $client callbacks and functions',\n 'Setup code, which runs on the server, writes a signal.',\n 'let count = $signal(5);',\n ),\n entry(\n 'BRM119',\n 'Server function \"{name}\" captures \"{variable}\". Pass it as an argument',\n 'A server function reads a variable of the instance script.',\n \"async function save(user: string) {\\n 'use server';\\n}\",\n ),\n entry(\n 'BRM120',\n '$optimistic follows a memo, an action or a prop, not a signal',\n 'The source of `$optimistic` is a signal.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM121',\n 'Declare server functions at the top level of a script',\n \"A function with `'use server'` is inside another function or a block.\",\n \"async function save() {\\n 'use server';\\n}\",\n ),\n entry(\n 'BRM122',\n '{name} cannot be used here',\n 'A compile-time function is used where it is not allowed.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM123',\n 'Call $setContext at the top level of a script',\n '`$setContext` is inside a function or a block of code.',\n '$setContext(ThemeContext, theme);',\n ),\n entry(\n 'BRM124',\n 'Call $title at the top level of a script',\n '`$title` is inside a function or a block of code.',\n \"$title('Todos');\",\n ),\n entry(\n 'BRM125',\n 'Create an ID with \"const name = $id()\" at the top level of a script',\n '`$id` is inside a function or a block of code.',\n 'const field = $id();',\n ),\n entry(\n 'BRM126',\n 'Check a prop with \"const name = $isPassed(prop)\" at the top level of the component script',\n '`$isPassed` is inside a function or a block of code.',\n 'const passed = $isPassed(value);',\n ),\n entry(\n 'BRM127',\n 'Read a context with \"const name = $getContext(Context)\" at the top level of a script',\n '`$getContext` is inside a function or a block of code.',\n 'const theme = $getContext(ThemeContext);',\n ),\n entry(\n 'BRM128',\n 'Read the route with \"const name = $route()\" at the top level of a script',\n '`$route` is inside a function or a block of code.',\n 'const route = $route();',\n ),\n entry(\n 'BRM129',\n 'Read the navigation with \"const name = $navigation()\" at the top level of a script',\n '`$navigation` is inside a function or a block of code.',\n 'const navigation = $navigation();',\n ),\n entry(\n 'BRM130',\n 'Call $props() as the value of a const in the component script',\n '`$props` is used in another place than `const { … } = $props()`.',\n 'const { name } = $props<{ name: string }>();',\n ),\n entry(\n 'BRM131',\n 'Declare a signal with \"let name = $signal(value)\" at the top level of a script',\n '`$signal` is inside a function or a block of code.',\n 'let count = $signal(0);',\n ),\n entry(\n 'BRM132',\n 'Declare a memo with \"const name = $memo(value)\" at the top level of a script',\n '`$memo` is inside a function or a block of code.',\n 'const double = $memo(count * 2);',\n ),\n entry(\n 'BRM202',\n '$gate takes a value and a function, as in $gate(value, (prev, next) => next > prev)',\n '`$gate` does not have a value and a guard function as its two arguments. The guard is an arrow function or a function expression.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM203',\n '$gate takes a value that is ready. Use $memo for a promise or a server function',\n 'The value of `$gate` awaits or calls a server function. The compiler catches these two; any other promise or stream, such as a call of a local async function, throws when the value is computed. A gate holds a value that the guard can compare, so it does not wait for one.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM204',\n 'Declare a gated value with \"const name = $gate(value, (prev, next) => boolean)\" at the top level of a script',\n '`$gate` is inside a function or a block of code.',\n 'const query = $gate(input, (_, next) => next.length >= 2);',\n ),\n entry(\n 'BRM133',\n 'Declare a debounced value with \"const name = $debounced(value, ms)\" at the top level of a script',\n '`$debounced` is inside a function or a block of code.',\n 'const query = $debounced(text, 300);',\n ),\n entry(\n 'BRM134',\n 'Declare a throttled value with \"const name = $throttled(value, ms)\" at the top level of a script',\n '`$throttled` is inside a function or a block of code.',\n 'const position = $throttled(pointer, 100);',\n ),\n entry(\n 'BRM135',\n 'Declare an optimistic value with \"let name = $optimistic(source)\" at the top level of a script',\n '`$optimistic` is inside a function or a block of code.',\n 'let shown = $optimistic(items);',\n ),\n entry(\n 'BRM136',\n 'Declare the result of a form with \"const name = $action(serverFunction)\" at the top level of a script',\n '`$action` is inside a function or a block of code.',\n 'const result = $action(save);',\n ),\n entry(\n 'BRM137',\n 'Call $effect at the top level of a script',\n '`$effect` is inside a function or a block of code.',\n '$effect(() => {\\n document.title = title;\\n});',\n ),\n entry(\n 'BRM138',\n 'Call $client at the top level of a script',\n '`$client` is inside a function or a block of code.',\n \"$client(() => {\\n measure();\\n}, 'idle');\",\n ),\n entry(\n 'BRM139',\n '$ref is not supported. Use a $signal with ref=$bind(name)',\n '`$ref` was removed.',\n 'let input = $signal<HTMLInputElement>();\\n<input ref=$bind(input)>',\n ),\n entry(\n 'BRM140',\n '$watch is not supported. Use $effect',\n '`$watch` was removed.',\n '$effect(() => {\\n save(value);\\n});',\n ),\n entry(\n 'BRM141',\n '$settled is not supported. Use $client',\n '`$settled` was removed.',\n '$client(() => {\\n measure();\\n});',\n ),\n entry(\n 'BRM142',\n '$cleanup is not supported. Return a cleanup function from $effect or $client',\n '`$cleanup` was removed.',\n '$effect(() => {\\n const timer = setInterval(tick, 1000);\\n return () => clearInterval(timer);\\n});',\n ),\n entry(\n 'BRM191',\n 'Read a store with \"const name = $store(source)\" or \"let name = $store(source)\" at the top level of a script',\n '`$store` is not the whole value of a `const` or `let` at the top level of a script.',\n \"import { theme } from './theme';\\nconst value = $store(theme);\",\n ),\n entry(\n 'BRM192',\n '$store takes one argument, a store',\n '`$store` has no argument, or more than one.',\n 'const field = $getContext(Field);\\nconst state = $store(field.state);',\n ),\n entry(\n 'BRM193',\n '$toStore takes one argument, a memo, a signal or a prop, as a value of $setContext',\n '`$toStore` has no argument or more than one, or it is not a value of `$setContext`, alone or as a key of an object or an item of a list.',\n '$setContext(Field, { state: $toStore(state), pick });',\n ),\n entry(\n 'BRM195',\n '$store gives one name, not a pattern such as { a }',\n '`$store` initializes a pattern.',\n 'const value = $store(source);',\n ),\n entry(\n 'BRM196',\n 'The context value reads \"{name}\", which changes, but a context value is read once. Put it in a store with $toStore, or read it inside a function',\n 'The value of `$setContext` reads a signal, a memo, a prop or a `$bind` value that changes in the browser, and a context is read once, so readers would keep the first value. A call or an immediately invoked function in the value that reads such a name is not reported, and freezes the same way.',\n '$setContext(Field, { state: $toStore(state), pick: () => value });',\n ),\n entry(\n 'BRM197',\n 'Read a context that may have no provider with \"const name = $getContext(Context, undefined)\", and a store in it with \"const state = name ? $store(name.key) : undefined\", with const and no other test',\n 'A read of a context that may have no provider has another shape: `$hasContext`, which is removed, `$store(name?.key)`, a `let` or another test in the guard, an `else` that is not `undefined`, a guard on a name that is not the optional value of `$getContext(Context, undefined)`, or a key of that value read without the guard.',\n 'const field = $getContext(Field, undefined);\\nconst state = field ? $store(field.state) : undefined;',\n ),\n entry(\n 'BRM198',\n 'The source of $store gives its store at once, so it cannot await or call a server function',\n 'The source of `$store` awaits, or calls a server function. The browser runs the source again when the page resumes, and links the store in the same pass, so the source must give the store, not a promise of it.',\n \"import { theme } from './theme';\\nconst value = $store(theme);\",\n ),\n entry(\n 'BRM199',\n '$store takes a store. Read the store of a context with \"$store($getContext(Context))\", or give a store as the fallback, \"$store($getContext(Context, store(value)))\"',\n '`$store` reads a context that the file names in `$getContext` or `$setContext`, `undefined`, `null`, or `$getContext` with a literal fallback, which is no store. A context that the file only imports is found when the page renders, as a `TypeError`.',\n \"const level = $store($getContext(LevelContext));\\nconst locale = $store($getContext(LocaleContext, store('en-US')));\",\n ),\n entry(\n 'BRM200',\n 'The value of bridge() must be a module-level export of a script file or of <script module>, as \"export const name = bridge({ … })\"',\n 'A call of `bridge` from `brumate/store` is in the script of a component, or in a function, or is not the value of an exported `const`. The page state names a bridge by its module and its export, so the browser can load it.',\n \"// bears.ts, or the <script module> of a component\\nimport { bridge } from 'brumate/store';\\nexport const bearStore = bridge({ create, get, subscribe });\",\n ),\n entry(\n 'BRM144',\n '$get is not supported. Signals cannot leave the file',\n '`$get` was removed. A signal never leaves its file.',\n '// Pass the value, or a function that writes it.\\nonChange=((next) => (count = next))',\n ),\n entry(\n 'BRM145',\n '$set is not supported. Signals cannot leave the file',\n '`$set` was removed. A signal never leaves its file.',\n '// Pass the value, or a function that writes it.\\nonChange=((next) => (count = next))',\n ),\n entry(\n 'BRM146',\n \"{name} was renamed to {renamed}. Import {renamed} from '{module}'\",\n 'The file imports a name that the compiler knew before it was renamed.',\n \"import { $signal } from 'brumate/signals';\",\n ),\n entry(\n 'BRM147',\n \"Import {name} from '{module}'\",\n 'The file calls a compile-time function that it does not import.',\n \"import { $signal } from 'brumate/signals';\",\n ),\n];\n\n/** Errors about the code that the browser gets, and the markup that the browser renders. */\nconst OUTPUT: ErrorEntry[] = [\n entry(\n 'BRM148',\n '\"{name}\" holds a new {kind}, which cannot be sent to the browser, and code that runs in the browser reads it{reader}. Use it in a server function, or create it in the browser, such as in $client',\n 'A value that cannot be sent to the browser, such as a database client, is read by code that runs there.',\n \"async function list() {\\n 'use server';\\n return db.all();\\n}\",\n ),\n entry(\n 'BRM149',\n '{what} is read by code that runs in the browser ({site}). Read it in a server function',\n 'Code that runs in the browser reads an environment variable of the server.',\n \"async function key() {\\n 'use server';\\n return env.API_KEY;\\n}\",\n ),\n entry(\n 'BRM150',\n '\"{name}\" holds {what} and code that runs in the browser reads it. Keep server variables out of values that the browser reads',\n 'A value holds an environment variable of the server, and the browser reads the value.',\n \"async function key() {\\n 'use server';\\n return env.API_KEY;\\n}\",\n ),\n entry(\n 'BRM151',\n '#defer cannot be inside a #client body',\n 'A `#defer` is in markup that only the browser renders.',\n '#defer {\\n <Comments />\\n}',\n ),\n entry(\n 'BRM152',\n '#defer cannot be in markup that the browser renders',\n 'A `#defer` is in a body that the browser adds later, such as the body of a changing `#if`.',\n '#defer {\\n <Comments />\\n}',\n ),\n entry(\n 'BRM153',\n 'A value that changes in <{tag}> must be its whole content, such as <{tag}>{`Count ${count}`}</{tag}>',\n 'A `<title>`, `<textarea>`, `<style>` or `<script>` holds a changing value next to other content.',\n '<textarea>{`Count ${count}`}</textarea>',\n ),\n entry(\n 'BRM154',\n 'Put <title> in #head, as <meta> and <link>, such as #head { <title>{`${count} left`}</title> }',\n 'A `<title>` is outside `#head`.',\n '#head {\\n <title>{`${count} left`}</title>\\n}',\n ),\n entry(\n 'BRM155',\n 'A dynamic tag that changes on the client is not supported yet',\n 'No `.brm` file reaches it today: the parser keys every dynamic tag, and a `<{tag}>` whose tag a handler changes compiles. It is kept for a tag that the compiler could not update.',\n '<{tag} class=\"title\">Title</>',\n ),\n entry(\n 'BRM156',\n 'Code that the browser updates can await only a memo. Load the promise in a memo instead',\n 'Code that runs again in the browser awaits something other than a memo.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM157',\n 'Markup that the browser renders can await only a memo. Load the promise in a memo instead',\n 'Markup that the browser renders awaits something other than a memo.',\n 'const user = $memo(await load(id));',\n ),\n entry(\n 'BRM158',\n 'This attribute cannot change on the client yet',\n 'The name or the value of an attribute with a computed name, as in `[name]=value`, changes in the browser.',\n '<div class=(open ? \"open\" : \"closed\")></div>',\n ),\n entry(\n 'BRM159',\n 'This computed attribute has a name or value with no code in the browser, so it cannot stay when the attributes of the element update',\n 'An element has a computed attribute, as in `[name]=(value)`, and a spread or another computed attribute that can change. The name or the value is a constant, or a signal that nothing writes, so the browser has no code for it, and an update of the element would remove the attribute. Make both a signal that the page writes, or write the attribute without brackets.',\n \"let name = $signal('data-x');\\nlet value = $signal('on');\\n\\n<button onClick=(() => ((name = 'data-y'), (value = 'off')))>Change</button>\\n<p {...props} [name]=(value)></p>\\n<p {...props} data-x=\\\"on\\\"></p>\",\n ),\n entry(\n 'BRM160',\n 'Destructuring assignment to a signal is not supported in client code yet',\n 'Code that runs in the browser writes a signal in a destructuring assignment.',\n '[first, second] = pair;\\n// Write each signal on its own:\\nfirst = pair[0];\\nsecond = pair[1];',\n ),\n entry(\n 'BRM161',\n 'Assign to \"{name}\" with = instead of {op}',\n 'An optimistic value is changed with `++` or `--`.',\n 'shown = shown + 1;',\n ),\n entry(\n 'BRM162',\n 'Invalid CSS: {message}',\n 'A `<style>` has CSS that does not parse.',\n '<style>\\n p {\\n color: red;\\n }\\n</style>',\n ),\n entry(\n 'BRM163',\n 'Module functions call each other too deeply. A module function cannot call itself',\n 'A function of a module of reactive logic calls itself, or a loop of functions call each other.',\n 'function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n];\n\n/** Errors about modules of reactive logic, such as `counter.brm.ts`. */\nconst MODULES: ErrorEntry[] = [\n entry(\n 'BRM164',\n 'Destructure what {name} returns, as in const { value } = {name}(…)',\n 'The result of a module function is kept as one object.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM165',\n 'Declare what {name} returns with const',\n 'The result of a module function is declared with `let`.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM166',\n 'Call {name} at the top level of a script, as in const { value } = {name}(…). Its signals become values of the component, so it cannot run in a function, a condition or a loop',\n 'A module function is called inside a function, a condition or a loop.',\n 'const { count, increment } = counter(0);',\n ),\n entry(\n 'BRM167',\n 'Cannot read {specifier}',\n 'The module that the component imports is not on disk.',\n \"import { counter } from './counter.brm.ts';\",\n ),\n entry(\n 'BRM168',\n '{specifier} does not export a function named {name}',\n 'The import names a function that the module does not export.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM169',\n '{name} needs a body that ends with return { … }',\n 'A module function is an arrow function with an expression body.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM170',\n '{name} must end with return { … }, an object of what it gives',\n 'A module function does not end with `return { … }`.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM171',\n '{name} can return only at its end',\n 'A module function returns in the middle of its body.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM172',\n 'Destructure {name} with plain names, as in const { value, other: renamed } = {name}(…)',\n 'The result of a module function is destructured with a default, a nested pattern or a rest.',\n 'const { count, increment: add } = counter(0);',\n ),\n entry(\n 'BRM173',\n '{name} must return an object with plain keys',\n 'The returned object has a computed key, a spread or a method.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM174',\n '{name} cannot return getters or setters. Return the values themselves',\n 'The returned object has a getter or a setter.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM175',\n '{name} does not return {key}',\n 'The component destructures a name that the module function does not return.',\n 'const { count } = counter(0);',\n ),\n entry(\n 'BRM176',\n '{name} returns {local} as {first} and as {key}. Return each local once, and give the other key a function of its own',\n 'A module function returns one local under two keys.',\n 'return { count, increment };',\n ),\n entry(\n 'BRM177',\n '{name} is declared twice',\n 'A name of the module function is also a name of the component.',\n 'const { count: first } = counter(0);\\nconst { count: second } = counter(10);',\n ),\n entry(\n 'BRM178',\n 'Parameters of {name} must be plain names',\n 'A module function has a destructured or default parameter.',\n 'export function counter(start: number) {\\n let count = $signal(start);\\n return { count };\\n}',\n ),\n entry(\n 'BRM179',\n '{name} reads {local}, which {specifier} does not export. Export it, so the component can import it',\n 'A module function reads a value of its module that is not exported.',\n 'export const STEP = 1;',\n ),\n entry(\n 'BRM211',\n '{name} cannot be compiled in a module{reason}. {fix}',\n 'A module uses a form that its top-level values cannot compile: a compile-time function that needs a component, such as `$effect`, at the top level, a gate or timed value that awaits, a memo, gate or timed value that calls a function it cannot follow, a form with the wrong arguments, or a signal in a destructuring write.',\n 'export let count = $signal(0);\\nexport const double = $memo(count * 2);',\n ),\n entry(\n 'BRM208',\n '\"{name}\" is a signal of {module}, and a file of plain code gets its store, not its value. {fix}',\n 'A `.ts` or `.js` file imports a signal or a memo that a module declares at its top level. TypeScript types it as its value, and it is a store.',\n \"// cart.brm.ts\\nexport let items = $signal<number[]>([]);\\nexport function count(): number {\\n return items.length;\\n}\\n\\n// plain.ts\\nimport { count } from './cart.brm.ts';\",\n ),\n entry(\n 'BRM209',\n '\"{name}\" is written only by this effect. Use {form}',\n 'A warning. An `$effect` only assigns signals that nothing else writes, so each signal is a memo written the long way, and the page updates twice for one change. With one assignment and no `if`, the message gives the memo. An effect with a call, an `await`, a cleanup or a signal that a handler, another effect or a `$bind` also writes stays quiet.',\n 'let count = $signal(0);\\nconst message = $memo(`Clicked ${count} times`);',\n ),\n entry(\n 'BRM212',\n 'A <script> with src is not inline. Give it src or inline, not both',\n 'A `<script>` in markup has both `src` and `inline`. `src` loads a file, and `inline` marks code that is written in the file.',\n '<script src=\"https://example.com/chat.js\" trigger=\"idle\"></script>',\n ),\n entry(\n 'BRM213',\n 'A <script> with src has no code inside. Write the code in <script inline>',\n 'A `<script src>` in markup has text inside. The browser ignores it.',\n '<script inline trigger=\"idle\">\\n window.dataLayer = [];\\n</script>',\n ),\n entry(\n 'BRM214',\n 'The trigger of a <script> is a plain string: idle, visible, interaction or load',\n 'The `trigger` of a `<script>` in markup is code in braces, has no value, or names another trigger.',\n '<script src=\"https://example.com/chat.js\" trigger=\"interaction\"></script>',\n ),\n entry(\n 'BRM215',\n 'A script in #head cannot wait to be visible, since no element follows it. Use idle or interaction',\n 'A `<script trigger=\"visible\">` is in `#head`. `visible` waits for the element after the script to come into view.',\n '#head {\\n <script src=\"https://example.com/chat.js\" trigger=\"idle\"></script>\\n}',\n ),\n entry(\n 'BRM216',\n 'A script with a trigger runs once per page, so data-rerun does not apply. Remove one of them',\n 'A `<script>` in markup has `trigger` and `data-rerun`. A script with a trigger never runs again after a navigation.',\n '<script src=\"https://example.com/chat.js\" trigger=\"idle\"></script>',\n ),\n];\n\nexport const ERRORS: readonly ErrorEntry[] = [...SYNTAX, ...SCRIPT, ...OUTPUT, ...MODULES];\n\n/** True when a message that the compiler reported has the form of an entry. */\nexport function matchesError(error: ErrorEntry, message: string): boolean {\n const escaped: string[] = [];\n for (const part of error.message.split(/\\{\\w+\\}/)) {\n escaped.push(part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n }\n const pattern = escaped.join('[\\\\s\\\\S]*?');\n return new RegExp(`^${pattern}$`).test(message);\n}\n\n/**\n * The entry for a message that the compiler reported. The place of the\n * error, as in `(File.brm:3:7)`, can follow the message.\n */\nexport function findError(message: string): ErrorEntry | undefined {\n const bare = message.replace(/(?:\\s\\([^()]*:\\d+:\\d+\\))+$/, '').replace(/\\s\\[BRM\\d+\\]$/, '');\n // Of the entries that match, the one with the most fixed text is the most specific.\n function fixed(error: ErrorEntry): number {\n return error.message.replace(/\\{\\w+\\}/g, '').length;\n }\n let found: ErrorEntry | undefined;\n for (const error of ERRORS) {\n if (matchesError(error, bare) && (!found || fixed(error) > fixed(found))) {\n found = error;\n }\n }\n return found;\n}\n\n/** The text of references/errors.md. */\nexport function renderErrors(): string {\n const lines = [\n '# Errors',\n '',\n 'The compiler reports each error with the place in the file, as `message (File.brm:line:column)`. This page lists every message, with its cause and the form to write instead. A `{name}` is a part that varies.',\n '',\n 'It is generated from `src/error-catalog.ts`. Do not edit it by hand.',\n ];\n for (const error of ERRORS) {\n lines.push('', `## ${error.code ? `${error.code}: ` : ''}${error.message}`, '', error.cause);\n if (error.link) {\n lines.push('', error.link);\n }\n lines.push('', '```brm fragment', error.fix, '```');\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/** The text of website/docs/errors.md: one section for each code. */\nexport function renderErrorsPage(): string {\n const lines = [\n '# Compile errors',\n '',\n 'Each compile error of brumate has a code. The code is part of the message, and `brumate check` prints it with a link to its section here. A `{name}` in a message is a part that varies.',\n '',\n 'This page is generated from `packages/brumate/src/error-catalog.ts`. Do not edit it by hand.',\n ];\n for (const error of ERRORS) {\n lines.push('', `## ${error.code}`, '', `\\`${error.message}\\``, '', error.cause);\n lines.push('', `\\`\\`\\`${fenceLanguage(error.fix)}`, error.fix, '```');\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The language of the code block of a fix on the site: `brm` when it has markup, and `ts` when it\n * is only script code, which the `.brm` highlighter would color as text.\n */\nfunction fenceLanguage(fix: string): 'brm' | 'ts' {\n return /^\\s*(?:<[A-Za-z/!]|#[a-z]+\\b|\\{)/m.test(fix) ? 'brm' : 'ts';\n}\n"],"mappings":";;;;;;;;;;;AAyBA,MAAa,YAAY;;AAGzB,MAAa,cAAsB,GAAG,UAAU;;AAGhD,SAAgB,UAAU,MAAsB;CAC9C,OAAO,GAAG,YAAY,GAAG,KAAK,YAAY;AAC5C;AAEA,SAAS,MAAM,MAAc,SAAiB,OAAe,KAAyB;CACpF,OAAO;EAAE;EAAS;EAAO;EAAK;EAAM,MAAM,UAAU,IAAI;CAAE;AAC5D;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,wBACA,oCACA,kFACF;CACA,MACE,UACA,uBACA,2CACA,qBACF;CACA,MACE,UACA,iCACA,4CACA,gCACF;CACA,MACE,UACA,mCACA,+CACA,wBACF;CACA,MACE,UACA,yBACA,2CACA,sBACF;CACA,MACE,UACA,uBACA,gFACA,sBACF;CACA,MACE,UACA,qCACA,gEACA,gCACF;CACA,MACE,UACA,kDACA,+BACA,8BACF;CACA,MAAM,UAAU,0BAA0B,qCAAqC,aAAa;CAC5F,MACE,UACA,gEACA,wEACA,sGACF;CACA,MACE,UACA,8DACA,qCACA,6DACF;CACA,MACE,UACA,iEACA,yEACA,yDACF;CACA,MACE,UACA,mCACA,oFACA,4DACF;CACA,MAAM,UAAU,uBAAuB,oCAAoC,iBAAiB;CAC5F,MACE,UACA,iCACA,0EACA,gCACF;CACA,MAAM,UAAU,sBAAsB,kCAAkC,aAAa;CACrF,MACE,UACA,0CACA,kDACA,oBACF;CACA,MACE,UACA,0CACA,oCACA,+BACF;CACA,MACE,UACA,wCACA,qEACA,kCACF;CACA,MACE,UACA,8CACA,kEACA,8BACF;CACA,MACE,UACA,8BACA,0DACA,kBACF;CACA,MACE,UACA,mEACA,6MACA,qFACF;CACA,MACE,UACA,sDACA,6FACA,kDACF;CACA,MACE,UACA,yCACA,kXACA,sEACF;CACA,MACE,UACA,sJACA,uKACA,wHACF;CACA,MACE,UACA,0IACA,oKACA,2IACF;CACA,MACE,UACA,mEACA,2EACA,wFACF;CACA,MACE,UACA,sHACA,kHACA,qDACF;CACA,MACE,UACA,+JACA,6TACA,mEACF;CACA,MACE,UACA,8LACA,+VACA,qNACF;CACA,MACE,UACA,6HACA,0TACA,+GACF;CACA,MACE,UACA,6BACA,+CACA,8CACF;CACA,MACE,UACA,wDACA,uDACA,8CACF;CACA,MACE,UACA,kDACA,0CACA,kCACF;CACA,MACE,UACA,0CACA,gDACA,0BACF;CACA,MACE,UACA,kEACA,8CACA,8BACF;CACA,MACE,UACA,+DACA,wCACA,wEACF;CACA,MACE,UACA,+BACA,8CACA,oBACF;CACA,MACE,UACA,4CACA,uEACA,2CACF;CACA,MACE,UACA,kCACA,yCACA,oBACF;CACA,MACE,UACA,2BACA,uEACA,mCACF;CACA,MACE,UACA,oBACA,4CACA,oCACF;CACA,MACE,UACA,yCACA,qEACA,uDACF;CACA,MACE,UACA,uCACA,kCACA,gFACF;CACA,MACE,UACA,gCACA,oCACA,oEACF;CACA,MACE,UACA,8CACA,uCACA,gFACF;CACA,MACE,UACA,wCACA,gEACA,uDACF;CACA,MACE,UACA,mCACA,sFACA,oGACF;CACA,MACE,UACA,+CACA,8CACA,gEACF;CACA,MACE,UACA,wIACA,kDACA,6CACF;CACA,MACE,UACA,4GACA,4CACA,6CACF;CACA,MACE,UACA,oCACA,8CACA,uEACF;CACA,MACE,UACA,mCACA,wDACA,gCACF;CACA,MACE,UACA,2CACA,yCACA,gCACF;CACA,MACE,UACA,mCACA,iDACA,gCACF;CACA,MACE,UACA,gCACA,kCACA,0DACF;CACA,MACE,UACA,6CACA,yEACA,sGACF;CACA,MACE,UACA,6BACA,8CACA,0EACF;CACA,MACE,UACA,4CACA,gGACA,sDACF;CACA,MACE,UACA,uEACA,4CACA,gDACF;CACA,MACE,UACA,4BACA,6CACA,gCACF;CACA,MACE,UACA,6CACA,oDACA,2CACF;CACA,MACE,UACA,mEACA,qCACA,qEACF;CACA,MACE,UACA,oDACA,iDACA,8EACF;CACA,MACE,UACA,kDACA,kDACA,+FACF;CACA,MACE,UACA,+CACA,yCACA,+FACF;CACA,MACE,UACA,iDACA,wCACA,yDACF;CACA,MACE,UACA,0BACA,+DACA,oBACF;CACA,MACE,UACA,8BACA,gEACA,6DACF;CACA,MACE,UACA,uBACA,6DACA,yDACF;AACF;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,kCACA,qDACA,kDACF;CACA,MACE,UACA,0BACA,iHACA,wCACF;CACA,MACE,UACA,kEACA,+FACA,kDACF;CACA,MACE,UACA,gKACA,iEACA,iEACF;CACA,MACE,UACA,yDACA,+CACA,8CACF;CACA,MACE,UACA,4CACA,kDACA,mFACF;CACA,MACE,UACA,kDACA,2CACA,uDACF;CACA,MACE,UACA,sDACA,wCACA,uDACF;CACA,MACE,UACA,wCACA,8CACA,kBACF;CACA,MACE,UACA,sCACA,oEACA,qCACF;CACA,MACE,UACA,uDACA,mDACA,8CACF;CACA,MACE,UACA,uCACA,mEACA,8CACF;CACA,MACE,UACA,+BACA,+BACA,8CACF;CACA,MACE,UACA,kDACA,+CACA,8CACF;CACA,MACE,UACA,4CACA,0CACA,sBACF;CACA,MAAM,UAAU,0BAA0B,0BAA0B,sBAAsB;CAC1F,MACE,UACA,oFACA,+DACA,2FACF;CACA,MACE,UACA,kCACA,kCACA,mCACF;CACA,MACE,UACA,4DACA,wCACA,sCACF;CACA,MACE,UACA,6DACA,gDACA,0CACF;CACA,MACE,UACA,+EACA,mDACA,iGACF;CACA,MACE,UACA,8DACA,uDACA,mCACF;CACA,MACE,UACA,8EACA,4CACA,+BACF;CACA,MACE,UACA,qEACA,gDACA,+BACF;CACA,MACE,UACA,uEACA,iFACA,0FACF;CACA,MACE,UACA,6BACA,wDACA,sCACF;CACA,MACE,UACA,iCACA,4FACA,yBACF;CACA,MACE,UACA,mDACA,8DACA,sCACF;CACA,MACE,UACA,oEACA,qEACA,sCACF;CACA,MACE,UACA,kCACA,sEACA,2DACF;CACA,MACE,UACA,6BACA,mEACA,yBACF;CACA,MACE,UACA,wBACA,6CACA,kCACF;CACA,MACE,UACA,yDACA,gDACA,iCACF;CACA,MACE,UACA,kCACA,iDACA,iDACF;CACA,MACE,UACA,2BACA,2DACA,iDACF;CACA,MACE,UACA,8CACA,0DACA,iDACF;CACA,MACE,UACA,8BACA,yCACA,iDACF;CACA,MACE,UACA,oEACA,uDACA,4CACF;CACA,MACE,UACA,mJACA,uDACA,8CACF;CACA,MACE,UACA,wJACA,wEACA,qCACF;CACA,MACE,UACA,8CACA,qCACA,2CACF;CACA,MACE,UACA,2HACA,4CACA,oDACF;CACA,MACE,UACA,sGACA,mFACA,oDACF;CACA,MACE,UACA,sHACA,iEACA,4BACF;CACA,MACE,UACA,gIACA,+DACA,2BACF;CACA,MACE,UACA,uGACA,iEACA,uDACF;CACA,MACE,UACA,0FACA,mDACA,6FACF;CACA,MACE,UACA,kDACA,yFACA,4FACF;CACA,MACE,UACA,iDACA,qDACA,wDACF;CACA,MACE,UACA,2DACA,wDACA,wDACF;CACA,MACE,UACA,gFACA,kCACA,wBACF;CACA,MACE,UACA,8BACA,kEACA,oEACF;CACA,MACE,UACA,qGACA,2EACA,oEACF;CACA,MACE,UACA,kGACA,mEACA,gEACF;CACA,MACE,UACA,qGACA,ycACA,qFACF;CACA,MACE,UACA,8GACA,+FACA,0CACF;CACA,MACE,UACA,4CACA,uGACA,qCACF;CACA,MACE,UACA,qGACA,0DACA,yBACF;CACA,MACE,UACA,8EACA,8DACA,yDACF;CACA,MACE,UACA,iEACA,4CACA,iCACF;CACA,MACE,UACA,yDACA,yEACA,6CACF;CACA,MACE,UACA,8BACA,4DACA,yBACF;CACA,MACE,UACA,iDACA,0DACA,mCACF;CACA,MACE,UACA,4CACA,qDACA,kBACF;CACA,MACE,UACA,yEACA,kDACA,sBACF;CACA,MACE,UACA,+FACA,wDACA,kCACF;CACA,MACE,UACA,0FACA,0DACA,0CACF;CACA,MACE,UACA,8EACA,qDACA,yBACF;CACA,MACE,UACA,wFACA,0DACA,mCACF;CACA,MACE,UACA,iEACA,oEACA,8CACF;CACA,MACE,UACA,oFACA,sDACA,yBACF;CACA,MACE,UACA,kFACA,oDACA,kCACF;CACA,MACE,UACA,uFACA,qIACA,4DACF;CACA,MACE,UACA,mFACA,mRACA,4DACF;CACA,MACE,UACA,kHACA,oDACA,4DACF;CACA,MACE,UACA,sGACA,yDACA,sCACF;CACA,MACE,UACA,sGACA,yDACA,4CACF;CACA,MACE,UACA,oGACA,0DACA,iCACF;CACA,MACE,UACA,2GACA,sDACA,+BACF;CACA,MACE,UACA,6CACA,sDACA,iDACF;CACA,MACE,UACA,6CACA,sDACA,4CACF;CACA,MACE,UACA,6DACA,uBACA,oEACF;CACA,MACE,UACA,wCACA,yBACA,sCACF;CACA,MACE,UACA,0CACA,2BACA,oCACF;CACA,MACE,UACA,gFACA,2BACA,sGACF;CACA,MACE,UACA,mHACA,uFACA,gEACF;CACA,MACE,UACA,sCACA,+CACA,uEACF;CACA,MACE,UACA,sFACA,4IACA,uDACF;CACA,MACE,UACA,sDACA,mCACA,+BACF;CACA,MACE,UACA,sJACA,ySACA,oEACF;CACA,MACE,UACA,8MACA,yUACA,sGACF;CACA,MACE,UACA,8FACA,qNACA,gEACF;CACA,MACE,UACA,4KACA,4PACA,sHACF;CACA,MACE,UACA,wIACA,kOACA,2JACF;CACA,MACE,UACA,wDACA,uDACA,uFACF;CACA,MACE,UACA,wDACA,uDACA,uFACF;CACA,MACE,UACA,qEACA,yEACA,4CACF;CACA,MACE,UACA,iCACA,mEACA,4CACF;AACF;;AAGA,MAAM,SAAuB;CAC3B,MACE,UACA,wMACA,2GACA,iEACF;CACA,MACE,UACA,0FACA,8EACA,mEACF;CACA,MACE,UACA,kIACA,yFACA,mEACF;CACA,MACE,UACA,0CACA,0DACA,6BACF;CACA,MACE,UACA,uDACA,8FACA,6BACF;CACA,MACE,UACA,wGACA,oGACA,yCACF;CACA,MACE,UACA,kGACA,mCACA,gDACF;CACA,MACE,UACA,iEACA,sLACA,iCACF;CACA,MACE,UACA,2FACA,2EACA,qCACF;CACA,MACE,UACA,6FACA,uEACA,qCACF;CACA,MACE,UACA,kDACA,6GACA,kDACF;CACA,MACE,UACA,wIACA,gXACA,gNACF;CACA,MACE,UACA,4EACA,gFACA,gGACF;CACA,MACE,UACA,+CACA,qDACA,oBACF;CACA,MACE,UACA,0BACA,4CACA,gDACF;CACA,MACE,UACA,qFACA,kGACA,0FACF;AACF;;AAGA,MAAM,UAAwB;CAC5B,MACE,UACA,sEACA,0DACA,0CACF;CACA,MACE,UACA,0CACA,2DACA,0CACF;CACA,MACE,UACA,kLACA,yEACA,0CACF;CACA,MACE,UACA,2BACA,yDACA,6CACF;CACA,MACE,UACA,uDACA,gEACA,iGACF;CACA,MACE,UACA,mDACA,mEACA,iGACF;CACA,MACE,UACA,iEACA,uDACA,iGACF;CACA,MACE,UACA,qCACA,wDACA,iGACF;CACA,MACE,UACA,0FACA,+FACA,+CACF;CACA,MACE,UACA,gDACA,iEACA,8BACF;CACA,MACE,UACA,yEACA,iDACA,8BACF;CACA,MACE,UACA,gCACA,+EACA,+BACF;CACA,MACE,UACA,wHACA,uDACA,8BACF;CACA,MACE,UACA,4BACA,kEACA,8EACF;CACA,MACE,UACA,4CACA,8DACA,iGACF;CACA,MACE,UACA,sGACA,uEACA,wBACF;CACA,MACE,UACA,wDACA,qUACA,yEACF;CACA,MACE,UACA,qGACA,kJACA,gLACF;CAC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,MAAM,KAAK,IAAI,EAAE;AAC7B;;AAGA,SAAgB,mBAA2B;CACzC,MAAM,QAAQ;EACZ;EACA;EACA;EACA;EACA;CACF;CACA,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;EAC9E,MAAM,KAAK,IAAI,SAAS,cAAc,MAAM,GAAG,KAAK,MAAM,KAAK,KAAK;CACtE;CACA,OAAO,GAAG,MAAM,KAAK,IAAI,EAAE;AAC7B;;;;;AAMA,SAAS,cAAc,KAA2B;CAChD,OAAO,oCAAoC,KAAK,GAAG,IAAI,QAAQ;AACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DOCS_SITE, n as ERRORS, r as ERRORS_PAGE, i as errorLink, a as findError, o as matchesError, s as renderErrors, c as renderErrorsPage } from "./error-catalog-
|
|
1
|
+
export { t as DOCS_SITE, n as ERRORS, r as ERRORS_PAGE, i as errorLink, a as findError, o as matchesError, s as renderErrors, c as renderErrorsPage } from "./error-catalog-BBWB7w-E.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as startTransition } from "./view-transitions-BpnVwtS4.js";
|
|
1
2
|
//#region src/runtime/events.ts
|
|
2
3
|
/** The keys that `prevent` can name, by their `event.key`. `Space` is the space bar. */
|
|
3
4
|
const KEY_NAMES = [
|
|
@@ -77,10 +78,7 @@ function transition(handler, ...types) {
|
|
|
77
78
|
result = handler(...args);
|
|
78
79
|
return globalThis[UPDATED]?.();
|
|
79
80
|
}
|
|
80
|
-
return (
|
|
81
|
-
update,
|
|
82
|
-
types
|
|
83
|
-
}) : document.startViewTransition(update)).updateCallbackDone.then(() => result);
|
|
81
|
+
return startTransition(update, types).updateCallbackDone.then(() => result);
|
|
84
82
|
});
|
|
85
83
|
const modifiers = handler[MODIFIERS];
|
|
86
84
|
if (modifiers) copy[MODIFIERS] = modifiers;
|
|
@@ -111,4 +109,4 @@ function cancelWhen(element, type, check) {
|
|
|
111
109
|
//#endregion
|
|
112
110
|
export { once as a, transition as c, capture as i, MODIFIERS as n, prevent as o, cancelWhen as r, stop as s, KEY_NAMES as t };
|
|
113
111
|
|
|
114
|
-
//# sourceMappingURL=events-
|
|
112
|
+
//# sourceMappingURL=events-BDVITj3P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events-BDVITj3P.js","names":[],"sources":["../src/runtime/events.ts"],"sourcesContent":["// Wrappers for event handlers that act before the handler's code loads. The\n// compiler reads the calls in markup and writes them into `b-on`, so the\n// loader applies them on the first event. At run time, each returns a copy of\n// the handler that carries its modifiers, so a handler passed on as a prop\n// keeps them.\n\nimport { startTransition } from './view-transitions.ts';\n\n/** The keys that `prevent` can name, by their `event.key`. `Space` is the space bar. */\nexport const KEY_NAMES: readonly string[] = [\n 'Enter',\n 'Escape',\n 'Tab',\n 'Space',\n 'Backspace',\n 'Delete',\n 'Insert',\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'ContextMenu',\n 'F1',\n 'F2',\n 'F3',\n 'F4',\n 'F5',\n 'F6',\n 'F7',\n 'F8',\n 'F9',\n 'F10',\n 'F11',\n 'F12',\n];\n\ntype Letter =\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z';\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\ntype FunctionKey = `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;\n\n/**\n * A key of `prevent`: a key by its `event.key`, or that key with a modifier that must be held,\n * such as `Mod+ArrowDown`. A key alone matches only while Ctrl, Meta and Alt are up, so the\n * shortcuts of the browser, such as Cmd+Left or Alt+Left, keep their default. `Mod` is Ctrl or\n * Meta. A letter after a modifier matches in either case.\n */\nexport type KeyName = Key | `${'Mod' | 'Ctrl' | 'Meta' | 'Alt'}+${Key}`;\n\n/** A key by its `event.key`: a named key, a letter or a digit. */\ntype Key =\n | 'Enter'\n | 'Escape'\n | 'Tab'\n | 'Space'\n | 'Backspace'\n | 'Delete'\n | 'Insert'\n | 'ArrowUp'\n | 'ArrowDown'\n | 'ArrowLeft'\n | 'ArrowRight'\n | 'Home'\n | 'End'\n | 'PageUp'\n | 'PageDown'\n | 'ContextMenu'\n | FunctionKey\n | Letter\n | Uppercase<Letter>\n | Digit;\n\n/** The modifiers of a handler, which `spread` writes into `b-on`. A symbol of the registry. */\nexport const MODIFIERS: unique symbol = Symbol.for('brumate.modifiers');\n\n/** A handler with the modifiers of its wrappers. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Handlers take any event.\ntype Handler = (...args: any[]) => unknown;\n\nfunction tagged<H extends Handler>(handler: H, modifier: string): H {\n const copy = ((...args: unknown[]) => handler(...args)) as H & { [MODIFIERS]?: string[] };\n copy[MODIFIERS] = [...((handler as { [MODIFIERS]?: string[] })[MODIFIERS] ?? []), modifier];\n return copy;\n}\n\n/**\n * Prevents the default action of the event, before the handler's code\n * loads. With keys, on a keyboard event, it prevents only those keys, and\n * the handler still runs for every key.\n */\nexport function prevent<H extends Handler>(handler: H, ...keys: KeyName[]): H {\n return tagged(handler, keys.length > 0 ? `prevent(${keys.join(',')})` : 'prevent');\n}\n\n/** Stops the event at this element, so the handlers of the elements around it do not run. */\nexport function stop<H extends Handler>(handler: H): H {\n return tagged(handler, 'stop');\n}\n\n/** Runs the handler for the first event only. */\nexport function once<H extends Handler>(handler: H): H {\n return tagged(handler, 'once');\n}\n\n/** Waits for the updates that writes started, such as those whose code is loading. A symbol of the registry. */\nconst UPDATED = Symbol.for('brumate.updated');\n\n/**\n * Runs the handler inside a view transition, so the browser animates the\n * change of the page, such as an element that `#if` removes or a list that\n * changes order. CSS styles the animation, with `view-transition-name` and\n * `::view-transition-*`.\n *\n * - The transition holds the writes that the handler makes before its first\n * `await`. Writes after it, such as after a server call, change the page\n * without an animation.\n * - `types` are the types of the transition, which `:active-view-transition-type()`\n * matches in CSS.\n * - Without view transitions, or with `prefers-reduced-motion`, the handler\n * runs as it is.\n */\nexport function transition<H extends Handler>(handler: H, ...types: string[]): H {\n const copy = ((...args: unknown[]): unknown => {\n if (\n typeof document === 'undefined' ||\n typeof document.startViewTransition !== 'function' ||\n matchMedia('(prefers-reduced-motion: reduce)').matches\n ) {\n return handler(...args);\n }\n let result: unknown;\n function update(): unknown {\n result = handler(...args);\n // The page shows the new state once the updates of the writes have run.\n return (globalThis as { [UPDATED]?: () => Promise<void> })[UPDATED]?.();\n }\n const started = startTransition(update, types);\n return started.updateCallbackDone.then(() => result);\n }) as H & { [MODIFIERS]?: string[] };\n const modifiers = (handler as { [MODIFIERS]?: string[] })[MODIFIERS];\n if (modifiers) {\n copy[MODIFIERS] = modifiers;\n }\n return copy;\n}\n\n/** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */\nexport function capture<H extends Handler>(handler: H): H {\n return tagged(handler, 'capture');\n}\n\n/** A symbol of the registry, under which the loader registers `cancelWhen`. */\nconst CANCEL = Symbol.for('brumate.cancel');\n\n/** The events that `cancelWhen` can cancel. Scroll-type events cannot be, for their listeners are passive. */\nexport type CancelableEvent = 'click' | 'submit';\n\n/**\n * Cancels an event of the element, or of an element inside it, before any handler of brumate\n * runs, while `check` returns true. The document listener of brumate calls `preventDefault()` and\n * runs no brumate handler for the event. It does not stop the event, so listeners that were added\n * with `addEventListener` still run, and they can read `event.defaultPrevented`.\n *\n * Returns a function that removes the check.\n *\n * ```ts\n * const stop = cancelWhen(form, 'submit', () => form.hasAttribute('data-pending'));\n * ```\n */\nexport function cancelWhen<T extends CancelableEvent>(\n element: Element,\n type: T,\n check: (event: HTMLElementEventMap[T]) => boolean,\n): () => void {\n const register = (globalThis as { [CANCEL]?: typeof cancelWhen })[CANCEL];\n return register ? register(element, type, check) : () => {};\n}\n"],"mappings":";;;AASA,MAAa,YAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAgEA,MAAa,YAA2B,OAAO,IAAI,mBAAmB;AAMtE,SAAS,OAA0B,SAAY,UAAqB;CAClE,MAAM,SAAS,GAAG,SAAoB,QAAQ,GAAG,IAAI;CACrD,KAAK,aAAa,CAAC,GAAK,QAAuC,cAAc,CAAC,GAAI,QAAQ;CAC1F,OAAO;AACT;;;;;;AAOA,SAAgB,QAA2B,SAAY,GAAG,MAAoB;CAC5E,OAAO,OAAO,SAAS,KAAK,SAAS,IAAI,WAAW,KAAK,KAAK,GAAG,EAAE,KAAK,SAAS;AACnF;;AAGA,SAAgB,KAAwB,SAAe;CACrD,OAAO,OAAO,SAAS,MAAM;AAC/B;;AAGA,SAAgB,KAAwB,SAAe;CACrD,OAAO,OAAO,SAAS,MAAM;AAC/B;;AAGA,MAAM,UAAU,OAAO,IAAI,iBAAiB;;;;;;;;;;;;;;;AAgB5C,SAAgB,WAA8B,SAAY,GAAG,OAAoB;CAC/E,MAAM,SAAS,GAAG,SAA6B;EAC7C,IACE,OAAO,aAAa,eACpB,OAAO,SAAS,wBAAwB,cACxC,WAAW,kCAAkC,CAAC,CAAC,SAE/C,OAAO,QAAQ,GAAG,IAAI;EAExB,IAAI;EACJ,SAAS,SAAkB;GACzB,SAAS,QAAQ,GAAG,IAAI;GAExB,OAAQ,WAAmD,QAAQ,GAAG;EACxE;EAEA,OADgB,gBAAgB,QAAQ,KAC3B,CAAC,CAAC,mBAAmB,WAAW,MAAM;CACrD;CACA,MAAM,YAAa,QAAuC;CAC1D,IAAI,WACF,KAAK,aAAa;CAEpB,OAAO;AACT;;AAGA,SAAgB,QAA2B,SAAe;CACxD,OAAO,OAAO,SAAS,SAAS;AAClC;;AAGA,MAAM,SAAS,OAAO,IAAI,gBAAgB;;;;;;;;;;;;;AAiB1C,SAAgB,WACd,SACA,MACA,OACY;CACZ,MAAM,WAAY,WAAgD;CAClE,OAAO,WAAW,SAAS,SAAS,MAAM,KAAK,UAAU,CAAC;AAC5D"}
|
|
@@ -47,7 +47,13 @@ const HAS_SEARCH_PARAMS = typeof __BRUMATE_HAS_SEARCH_PARAMS__ === "undefined" |
|
|
|
47
47
|
const HAS_STORES = typeof __BRUMATE_HAS_STORES__ === "undefined" || __BRUMATE_HAS_STORES__;
|
|
48
48
|
/** Stores of `bridge()`, which the page state holds. */
|
|
49
49
|
const HAS_BRIDGES = typeof __BRUMATE_HAS_BRIDGES__ === "undefined" || __BRUMATE_HAS_BRIDGES__;
|
|
50
|
+
/** Memos of a module that a component imports, which take the value of the server on resume. */
|
|
51
|
+
const HAS_MODULE_MEMOS = typeof __BRUMATE_HAS_MODULE_MEMOS__ === "undefined" || __BRUMATE_HAS_MODULE_MEMOS__;
|
|
52
|
+
/** `<script>` elements in markup, which the loader starts on their trigger. */
|
|
53
|
+
const HAS_SCRIPTS = typeof __BRUMATE_HAS_SCRIPTS__ === "undefined" || __BRUMATE_HAS_SCRIPTS__;
|
|
54
|
+
/** `viewTransition` and `viewTransitionName` attributes, which get a name while a transition runs. */
|
|
55
|
+
const HAS_VIEW_TRANSITIONS = typeof __BRUMATE_HAS_VIEW_TRANSITIONS__ === "undefined" || __BRUMATE_HAS_VIEW_TRANSITIONS__;
|
|
50
56
|
//#endregion
|
|
51
|
-
export {
|
|
57
|
+
export { HAS_WINDOWS as S, HAS_STORES as _, HAS_CHILDREN as a, HAS_TRIES as b, HAS_FIELDS as c, HAS_LOADING as d, HAS_MODULE_MEMOS as f, HAS_SEARCH_PARAMS as g, HAS_SCRIPTS as h, HAS_BRIDGES as i, HAS_LATE_MARKUP as l, HAS_ROUTES as m, HAS_BINDINGS as n, HAS_CLIENT_HTML as o, HAS_ROOT_WAIT as p, HAS_BLOCKS as r, HAS_DYNAMIC as s, HAS_ACTIONS as t, HAS_LISTENERS as u, HAS_TEMPLATES as v, HAS_VIEW_TRANSITIONS as x, HAS_TITLES as y };
|
|
52
58
|
|
|
53
|
-
//# sourceMappingURL=features-
|
|
59
|
+
//# sourceMappingURL=features-Cte5aj20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features-Cte5aj20.js","names":[],"sources":["../src/runtime/features.ts"],"sourcesContent":["// The features of the core that a build uses. Each is on, unless the build names it. The Vite\n// plugin names them in the client build of an app, and turns off the features that none of its\n// components use, so the bundler leaves out their code. They are globals that the plugin\n// replaces, so the build of this package does not fold them.\n\ndeclare const __BRUMATE_HAS_CHILDREN__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TEMPLATES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TITLES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_BINDINGS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LATE_MARKUP__: boolean | undefined;\ndeclare const __BRUMATE_HAS_BLOCKS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LISTENERS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ACTIONS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_CLIENT_HTML__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TRIES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_FIELDS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_WINDOWS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_DYNAMIC__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ROUTES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LOADING__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ROOT_WAIT__: boolean | undefined;\ndeclare const __BRUMATE_HAS_SEARCH_PARAMS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_STORES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_BRIDGES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_MODULE_MEMOS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_SCRIPTS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_VIEW_TRANSITIONS__: boolean | undefined;\n\n/** Children that the browser renders with an export of their own, each time they are inserted. */\nexport const HAS_CHILDREN: boolean =\n typeof __BRUMATE_HAS_CHILDREN__ === 'undefined' || __BRUMATE_HAS_CHILDREN__;\n\n/** `#template` values that the browser calls, such as a template that a prop holds. */\nexport const HAS_TEMPLATES: boolean =\n typeof __BRUMATE_HAS_TEMPLATES__ === 'undefined' || __BRUMATE_HAS_TEMPLATES__;\n\n/** `<title>` elements in markup, which set the title of the page. */\nexport const HAS_TITLES: boolean =\n typeof __BRUMATE_HAS_TITLES__ === 'undefined' || __BRUMATE_HAS_TITLES__;\n\n/** `$bind` that a component passes to another, which the page state can hold. */\nexport const HAS_BINDINGS: boolean =\n typeof __BRUMATE_HAS_BINDINGS__ === 'undefined' || __BRUMATE_HAS_BINDINGS__;\n\n/**\n * Markup that comes into the page after it loads, from others than the core: the bodies of\n * `#loading` and `#defer`, the items of a list that streams, and the pages of client navigation.\n * Without it, the core finds every marker in the markup that it reads or inserts itself.\n */\nexport const HAS_LATE_MARKUP: boolean =\n typeof __BRUMATE_HAS_LATE_MARKUP__ === 'undefined' || __BRUMATE_HAS_LATE_MARKUP__;\n\n/** `$client` callbacks and `#defer` blocks, which start on a trigger. */\nexport const HAS_BLOCKS: boolean =\n typeof __BRUMATE_HAS_BLOCKS__ === 'undefined' || __BRUMATE_HAS_BLOCKS__;\n\n/** Handlers of the window or the document. */\nexport const HAS_LISTENERS: boolean =\n typeof __BRUMATE_HAS_LISTENERS__ === 'undefined' || __BRUMATE_HAS_LISTENERS__;\n\n/** Forms of an `$action`, which send their data with `fetch`. */\nexport const HAS_ACTIONS: boolean =\n typeof __BRUMATE_HAS_ACTIONS__ === 'undefined' || __BRUMATE_HAS_ACTIONS__;\n\n/**\n * Markup that the browser renders as HTML, not as a clone of a template. Without it, the core\n * indexes each insert at once, and HTML holds no places for clones.\n */\nexport const HAS_CLIENT_HTML: boolean =\n typeof __BRUMATE_HAS_CLIENT_HTML__ === 'undefined' || __BRUMATE_HAS_CLIENT_HTML__;\n\n/** `#try` blocks, whose `#catch` the browser renders. */\nexport const HAS_TRIES: boolean =\n typeof __BRUMATE_HAS_TRIES__ === 'undefined' || __BRUMATE_HAS_TRIES__;\n\n/** Fields of an element `$bind`, which the core reads when the user typed before it loaded. */\nexport const HAS_FIELDS: boolean =\n typeof __BRUMATE_HAS_FIELDS__ === 'undefined' || __BRUMATE_HAS_FIELDS__;\n\n/** `#for` lists with `window`. */\nexport const HAS_WINDOWS: boolean =\n typeof __BRUMATE_HAS_WINDOWS__ === 'undefined' || __BRUMATE_HAS_WINDOWS__;\n\n/** Dynamic tags, which can name a component and pass it props. */\nexport const HAS_DYNAMIC: boolean =\n typeof __BRUMATE_HAS_DYNAMIC__ === 'undefined' || __BRUMATE_HAS_DYNAMIC__;\n\n/** `$route` and `$navigation`, which the runtime provides. */\nexport const HAS_ROUTES: boolean =\n typeof __BRUMATE_HAS_ROUTES__ === 'undefined' || __BRUMATE_HAS_ROUTES__;\n\n/** `#loading` blocks that the browser renders, which show their fallback while memos load. */\nexport const HAS_LOADING: boolean =\n typeof __BRUMATE_HAS_LOADING__ === 'undefined' || __BRUMATE_HAS_LOADING__;\n\n/**\n * A browser render that waits at `await $memo`. A block outside every `#loading` then keeps what\n * it shows until the waits of its new body settle, as the server holds the page.\n */\nexport const HAS_ROOT_WAIT: boolean =\n typeof __BRUMATE_HAS_ROOT_WAIT__ === 'undefined' || __BRUMATE_HAS_ROOT_WAIT__;\n\n/** `$searchParam`, whose changes of the URL the loader leaves to the page. */\nexport const HAS_SEARCH_PARAMS: boolean =\n typeof __BRUMATE_HAS_SEARCH_PARAMS__ === 'undefined' || __BRUMATE_HAS_SEARCH_PARAMS__;\n\n/** Stores of `brumate/store`, which `$toStore` and `$store` use and the page state can hold. */\nexport const HAS_STORES: boolean =\n typeof __BRUMATE_HAS_STORES__ === 'undefined' || __BRUMATE_HAS_STORES__;\n\n/** Stores of `bridge()`, which the page state holds. */\nexport const HAS_BRIDGES: boolean =\n typeof __BRUMATE_HAS_BRIDGES__ === 'undefined' || __BRUMATE_HAS_BRIDGES__;\n\n/** Memos of a module that a component imports, which take the value of the server on resume. */\nexport const HAS_MODULE_MEMOS: boolean =\n typeof __BRUMATE_HAS_MODULE_MEMOS__ === 'undefined' || __BRUMATE_HAS_MODULE_MEMOS__;\n\n/** `<script>` elements in markup, which the loader starts on their trigger. */\nexport const HAS_SCRIPTS: boolean =\n typeof __BRUMATE_HAS_SCRIPTS__ === 'undefined' || __BRUMATE_HAS_SCRIPTS__;\n\n/** `viewTransition` and `viewTransitionName` attributes, which get a name while a transition runs. */\nexport const HAS_VIEW_TRANSITIONS: boolean =\n typeof __BRUMATE_HAS_VIEW_TRANSITIONS__ === 'undefined' || __BRUMATE_HAS_VIEW_TRANSITIONS__;\n"],"mappings":";;AA6BA,MAAa,eACX,OAAO,6BAA6B,eAAe;;AAGrD,MAAa,gBACX,OAAO,8BAA8B,eAAe;;AAGtD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,eACX,OAAO,6BAA6B,eAAe;;;;;;AAOrD,MAAa,kBACX,OAAO,gCAAgC,eAAe;;AAGxD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,gBACX,OAAO,8BAA8B,eAAe;;AAGtD,MAAa,cACX,OAAO,4BAA4B,eAAe;;;;;AAMpD,MAAa,kBACX,OAAO,gCAAgC,eAAe;;AAGxD,MAAa,YACX,OAAO,0BAA0B,eAAe;;AAGlD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,cACX,OAAO,4BAA4B,eAAe;;;;;AAMpD,MAAa,gBACX,OAAO,8BAA8B,eAAe;;AAGtD,MAAa,oBACX,OAAO,kCAAkC,eAAe;;AAG1D,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,mBACX,OAAO,iCAAiC,eAAe;;AAGzD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,uBACX,OAAO,qCAAqC,eAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { X as hasBridge, Z as mayHaveBridge, g as functionId } from "./inspect-fpaBJ5pm.js";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
4
4
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
@@ -594,4 +594,4 @@ async function collectSources(root, paths) {
|
|
|
594
594
|
//#endregion
|
|
595
595
|
export { findPackages as _, findScripts as a, resolveComponentPackage as b, findServerImport as c, isScriptFile as d, serverExports as f, findPackage as g, findBridgePackages as h, findFiles as i, hasServerMiddleware as l, serverStubs as m, defaultExclude as n, findServerFiles as o, serverModule as p, findBridgeFiles as r, findPackageServerFile as s, collectSources as t, hasUseServer as u, packageFileName as v, reachableFiles as y };
|
|
596
596
|
|
|
597
|
-
//# sourceMappingURL=files-
|
|
597
|
+
//# sourceMappingURL=files-Bz0lAQzD.js.map
|