brumate 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/dist/boot-DN1ZU8Hg.d.ts +37 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +68 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/client-DwJInP_a.d.ts +279 -0
  8. package/dist/client-routes-DakuM32C.js +94 -0
  9. package/dist/client-routes-DakuM32C.js.map +1 -0
  10. package/dist/context-BG8KCF3v.js +15 -0
  11. package/dist/context-BG8KCF3v.js.map +1 -0
  12. package/dist/context-aeo9esY9.d.ts +16 -0
  13. package/dist/cookies-Av5WFmcf.js +175 -0
  14. package/dist/cookies-Av5WFmcf.js.map +1 -0
  15. package/dist/devtools-BKjnHrnv.js +113 -0
  16. package/dist/devtools-BKjnHrnv.js.map +1 -0
  17. package/dist/devtools-panel-AWOn0VK2.js +434 -0
  18. package/dist/devtools-panel-AWOn0VK2.js.map +1 -0
  19. package/dist/files-BBLPU9JR.js +177 -0
  20. package/dist/files-BBLPU9JR.js.map +1 -0
  21. package/dist/html-DEeoepg3.js +152 -0
  22. package/dist/html-DEeoepg3.js.map +1 -0
  23. package/dist/html-Du8jY2Cc.d.ts +53 -0
  24. package/dist/index.d.ts +2088 -0
  25. package/dist/index.js +707 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/inspect-CRZlO11T.js +6926 -0
  28. package/dist/inspect-CRZlO11T.js.map +1 -0
  29. package/dist/loader-Dc9OwY5I.js +101 -0
  30. package/dist/loader-Dc9OwY5I.js.map +1 -0
  31. package/dist/navigate-CzLjnoPH.js +422 -0
  32. package/dist/navigate-CzLjnoPH.js.map +1 -0
  33. package/dist/produce-BRGHP7e0.js +126 -0
  34. package/dist/produce-BRGHP7e0.js.map +1 -0
  35. package/dist/produce-CtZ32UGG.d.ts +60 -0
  36. package/dist/rpc-9fSqL_YK.js +128 -0
  37. package/dist/rpc-9fSqL_YK.js.map +1 -0
  38. package/dist/runtime/client.d.ts +5 -0
  39. package/dist/runtime/client.js +1345 -0
  40. package/dist/runtime/client.js.map +1 -0
  41. package/dist/runtime/context.d.ts +2 -0
  42. package/dist/runtime/context.js +1 -0
  43. package/dist/runtime/devtools.d.ts +36 -0
  44. package/dist/runtime/devtools.js +1 -0
  45. package/dist/runtime/hot.d.ts +36 -0
  46. package/dist/runtime/hot.js +44 -0
  47. package/dist/runtime/hot.js.map +1 -0
  48. package/dist/runtime/html.d.ts +2 -0
  49. package/dist/runtime/html.js +1 -0
  50. package/dist/runtime/loader.d.ts +12 -0
  51. package/dist/runtime/loader.js +3 -0
  52. package/dist/runtime/routes.d.ts +21 -0
  53. package/dist/runtime/routes.js +18 -0
  54. package/dist/runtime/routes.js.map +1 -0
  55. package/dist/runtime/server.d.ts +5 -0
  56. package/dist/runtime/server.js +7 -0
  57. package/dist/runtime/signals.d.ts +46 -0
  58. package/dist/runtime/signals.js +74 -0
  59. package/dist/runtime/signals.js.map +1 -0
  60. package/dist/runtime/static-loader.d.ts +3 -0
  61. package/dist/runtime/static-loader.js +1 -0
  62. package/dist/runtime/testing.d.ts +55 -0
  63. package/dist/runtime/testing.js +172 -0
  64. package/dist/runtime/testing.js.map +1 -0
  65. package/dist/server-BxqjLUnV.d.ts +753 -0
  66. package/dist/server-DZsgnPKS.js +1615 -0
  67. package/dist/server-DZsgnPKS.js.map +1 -0
  68. package/dist/shared-CWYOd0H3.js +40 -0
  69. package/dist/shared-CWYOd0H3.js.map +1 -0
  70. package/dist/static-loader-BcFh4ebX.d.ts +11 -0
  71. package/dist/static-loader-ClNkHZGn.js +185 -0
  72. package/dist/static-loader-ClNkHZGn.js.map +1 -0
  73. package/dist/stream-bgNCMcaA.js +280 -0
  74. package/dist/stream-bgNCMcaA.js.map +1 -0
  75. package/dist/vite.d.ts +146 -0
  76. package/dist/vite.js +1397 -0
  77. package/dist/vite.js.map +1 -0
  78. package/package.json +122 -3
  79. package/types.d.ts +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexis Munsayac
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # brumate
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > A component language and compiler for resumable web apps.
4
+
5
+ `brumate` compiles single-file `.brm` components into server-rendered HTML and small client modules. The browser does not hydrate. It reads the state that the server wrote into the page, and loads the code of an event handler only when that event fires.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add brumate
11
+ pnpm add -D vite @brumate/tsc typescript
12
+ ```
13
+
14
+ brumate needs Node 22.18 or newer, and Vite.
15
+
16
+ ```ts
17
+ // vite.config.ts
18
+ import brumate from 'brumate/vite';
19
+ import { defineConfig } from 'vite';
20
+
21
+ export default defineConfig({
22
+ plugins: [brumate()],
23
+ build: {
24
+ manifest: true,
25
+ rolldownOptions: { input: 'src/client.ts' },
26
+ },
27
+ });
28
+ ```
29
+
30
+ ```ts
31
+ // src/client.ts
32
+ import 'virtual:brumate/start';
33
+ ```
34
+
35
+ ## A component
36
+
37
+ ```html
38
+ <script>
39
+ import { $memo, $signal } from 'brumate/signals';
40
+
41
+ let count = $signal(0);
42
+ const double = $memo(count * 2);
43
+ </script>
44
+
45
+ <button onClick=(() => count++)>Clicked {count} times</button>
46
+ <p>Double: {double}</p>
47
+ ```
48
+
49
+ The server renders the button and the text. The browser loads the code of the click handler, and of the updates it causes, the first time the button is clicked.
50
+
51
+ ## What it includes
52
+
53
+ - `brumate/signals`: the compile-time functions, such as `$signal`, `$memo`, `$effect`, `$props`, `$action` and `$optimistic`.
54
+ - `brumate/vite`: the Vite plugin. It compiles `.brm` files, splits client code per handler, serves server function calls in development, and can prerender pages.
55
+ - `brumate/server`: rendering, streaming, routes, server functions, sessions, cookies, and validation with Standard Schema.
56
+ - `brumate/loader` and `brumate/client`: the loader and the core that run in the browser.
57
+ - `brumate/testing`: mounting components in a DOM test, with the real server functions.
58
+
59
+ ## Documentation
60
+
61
+ - [Getting started](https://github.com/lxsmnsyc/brumate/blob/main/website/docs/getting-started.md)
62
+ - [Your first app](https://github.com/lxsmnsyc/brumate/blob/main/website/docs/tutorial.md)
63
+ - [All guides and reference](https://github.com/lxsmnsyc/brumate/tree/main/website/docs)
64
+
65
+ brumate is at 0.x. The page format can change between versions, so the server and the client must come from the same version.
66
+
67
+ ## License
68
+
69
+ MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
@@ -0,0 +1,37 @@
1
+ import { t as ClientModule } from "./client-DwJInP_a.js";
2
+ //#region src/runtime/boot.d.ts
3
+ interface LoaderOptions {
4
+ /**
5
+ * Imports the client module of a component, by component ID. Undefined for
6
+ * a component that has no client code.
7
+ */
8
+ load: (id: string) => Promise<ClientModule> | undefined;
9
+ /** The URL prefix of server function calls. */
10
+ rpc?: string;
11
+ /**
12
+ * Loads pages without a full page load: links to the same origin, the back
13
+ * and forward buttons, forms that post to a server function, and redirects
14
+ * from server functions to the same origin. Defaults to true.
15
+ */
16
+ navigate?: boolean | NavigateOptions;
17
+ /**
18
+ * After the page loads, while the browser is idle, loads the core and the
19
+ * code of the handlers of elements in or near the viewport, so a first
20
+ * event needs no request. Elements with `data-prefetch="none"` are left
21
+ * out, and nothing loads when the browser asks to save data or the
22
+ * connection is 2G. Defaults to true.
23
+ */
24
+ preload?: boolean;
25
+ }
26
+ interface NavigateOptions {
27
+ /**
28
+ * Swaps the page inside a view transition, where the browser has them.
29
+ * CSS can tell links, the back and forward buttons and forms apart with
30
+ * the types `push`, `traverse` and `form`. A redirect from a server
31
+ * function has the type `form`.
32
+ */
33
+ transition?: boolean;
34
+ }
35
+ //#endregion
36
+ export { NavigateOptions as n, LoaderOptions as t };
37
+ //# sourceMappingURL=boot-DN1ZU8Hg.d.ts.map
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import { D as analyzeProjectProps, a as CompileError, n as inspect } from "./inspect-CRZlO11T.js";
3
+ import { n as findFiles, t as defaultExclude } from "./files-BBLPU9JR.js";
4
+ import { readFile, stat } from "node:fs/promises";
5
+ import path from "node:path";
6
+ //#region src/cli.ts
7
+ const USAGE = `Usage: brumate inspect [--json] [files or directories]
8
+
9
+ Shows what each component ships to the client, and why.
10
+ Without paths, inspects every .brm file under the current directory.`;
11
+ function toPosix(file) {
12
+ return file.split(path.sep).join("/");
13
+ }
14
+ /** Shows parent files relative to the current directory. */
15
+ function relativeParents(parents, root) {
16
+ const result = /* @__PURE__ */ new Map();
17
+ for (const [prop, files] of parents) result.set(prop, new Set([...files].map((file) => toPosix(path.relative(root, file)))));
18
+ return result;
19
+ }
20
+ async function inspectCommand(args) {
21
+ const json = args.includes("--json");
22
+ const paths = args.filter((arg) => arg !== "--json");
23
+ const root = process.cwd();
24
+ const project = await findFiles(root, defaultExclude);
25
+ const sources = /* @__PURE__ */ new Map();
26
+ for (const [index, source] of (await Promise.all(project.map((file) => readFile(file, "utf8")))).entries()) sources.set(project[index], source);
27
+ const props = analyzeProjectProps(sources);
28
+ const targets = (await Promise.all((paths.length > 0 ? paths : ["."]).map(async (target) => {
29
+ const absolute = path.resolve(root, target);
30
+ return (await stat(absolute)).isDirectory() ? findFiles(absolute, defaultExclude) : [toPosix(absolute)];
31
+ }))).flat();
32
+ const extra = targets.filter((file) => !sources.has(file));
33
+ for (const [index, source] of (await Promise.all(extra.map((file) => readFile(file, "utf8")))).entries()) sources.set(extra[index], source);
34
+ const reports = [];
35
+ const texts = [];
36
+ let failed = false;
37
+ for (const file of targets) {
38
+ const source = sources.get(file);
39
+ const filename = toPosix(path.relative(root, file));
40
+ try {
41
+ const parents = props.get(file);
42
+ const result = inspect(source, {
43
+ filename,
44
+ liveProps: parents && new Set(parents.keys()),
45
+ parents: parents && relativeParents(parents, root)
46
+ });
47
+ reports.push(result.report);
48
+ texts.push(result.text);
49
+ } catch (error) {
50
+ if (!(error instanceof CompileError)) throw error;
51
+ failed = true;
52
+ console.error(error.message);
53
+ }
54
+ }
55
+ console.log(json ? JSON.stringify(reports, null, 2) : texts.join("\n\n"));
56
+ return failed ? 1 : 0;
57
+ }
58
+ async function main(args) {
59
+ const [command, ...rest] = args;
60
+ if (command === "inspect") return inspectCommand(rest);
61
+ console.log(USAGE);
62
+ return command === void 0 || command === "--help" ? 0 : 1;
63
+ }
64
+ process.exitCode = await main(process.argv.slice(2));
65
+ //#endregion
66
+ export {};
67
+
68
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFile, stat } from 'node:fs/promises';\nimport path from 'node:path';\nimport { CompileError } from './compile.ts';\nimport { defaultExclude, findFiles } from './files.ts';\nimport { inspect } from './inspect.ts';\nimport type { InspectReport } from './inspect.ts';\nimport { analyzeProjectProps } from './project.ts';\n\nconst USAGE = `Usage: brumate inspect [--json] [files or directories]\n\nShows what each component ships to the client, and why.\nWithout paths, inspects every .brm file under the current directory.`;\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\n/** Shows parent files relative to the current directory. */\nfunction relativeParents(\n parents: Map<string, Set<string>>,\n root: string,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [prop, files] of parents) {\n result.set(prop, new Set([...files].map((file) => toPosix(path.relative(root, file)))));\n }\n return result;\n}\n\nasync function inspectCommand(args: string[]): Promise<number> {\n const json = args.includes('--json');\n const paths = args.filter((arg) => arg !== '--json');\n const root = process.cwd();\n\n // Props are analyzed across every file under the current directory.\n const project = await findFiles(root, defaultExclude);\n const sources = new Map<string, string>();\n for (const [index, source] of (\n await Promise.all(project.map((file) => readFile(file, 'utf8')))\n ).entries()) {\n sources.set(project[index]!, source);\n }\n const props = analyzeProjectProps(sources);\n\n const found = await Promise.all(\n (paths.length > 0 ? paths : ['.']).map(async (target) => {\n const absolute = path.resolve(root, target);\n return (await stat(absolute)).isDirectory()\n ? findFiles(absolute, defaultExclude)\n : [toPosix(absolute)];\n }),\n );\n const targets = found.flat();\n // Files outside the current directory are read here.\n const extra = targets.filter((file) => !sources.has(file));\n for (const [index, source] of (\n await Promise.all(extra.map((file) => readFile(file, 'utf8')))\n ).entries()) {\n sources.set(extra[index]!, source);\n }\n\n const reports: InspectReport[] = [];\n const texts: string[] = [];\n let failed = false;\n for (const file of targets) {\n const source = sources.get(file)!;\n const filename = toPosix(path.relative(root, file));\n try {\n const parents = props.get(file);\n const result = inspect(source, {\n filename,\n liveProps: parents && new Set(parents.keys()),\n parents: parents && relativeParents(parents, root),\n });\n reports.push(result.report);\n texts.push(result.text);\n } catch (error) {\n if (!(error instanceof CompileError)) {\n throw error;\n }\n failed = true;\n console.error(error.message);\n }\n }\n console.log(json ? JSON.stringify(reports, null, 2) : texts.join('\\n\\n'));\n return failed ? 1 : 0;\n}\n\nasync function main(args: string[]): Promise<number> {\n const [command, ...rest] = args;\n if (command === 'inspect') {\n return inspectCommand(rest);\n }\n console.log(USAGE);\n return command === undefined || command === '--help' ? 0 : 1;\n}\n\nprocess.exitCode = await main(process.argv.slice(2));\n"],"mappings":";;;;;;AASA,MAAM,QAAQ;;;;AAKd,SAAS,QAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;;AAGA,SAAS,gBACP,SACA,MAC0B;CAC1B,MAAM,yBAAS,IAAI,IAAyB;CAC5C,KAAK,MAAM,CAAC,MAAM,UAAU,SAC1B,OAAO,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,SAAS,QAAQ,KAAK,SAAS,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;CAExF,OAAO;AACT;AAEA,eAAe,eAAe,MAAiC;CAC7D,MAAM,OAAO,KAAK,SAAS,QAAQ;CACnC,MAAM,QAAQ,KAAK,QAAQ,QAAQ,QAAQ,QAAQ;CACnD,MAAM,OAAO,QAAQ,IAAI;CAGzB,MAAM,UAAU,MAAM,UAAU,MAAM,cAAc;CACpD,MAAM,0BAAU,IAAI,IAAoB;CACxC,KAAK,MAAM,CAAC,OAAO,YACjB,MAAM,QAAQ,IAAI,QAAQ,KAAK,SAAS,SAAS,MAAM,MAAM,CAAC,CAAC,EAAA,CAC/D,QAAQ,GACR,QAAQ,IAAI,QAAQ,QAAS,MAAM;CAErC,MAAM,QAAQ,oBAAoB,OAAO;CAUzC,MAAM,WAAU,MARI,QAAQ,KACzB,MAAM,SAAS,IAAI,QAAQ,CAAC,GAAG,EAAA,CAAG,IAAI,OAAO,WAAW;EACvD,MAAM,WAAW,KAAK,QAAQ,MAAM,MAAM;EAC1C,QAAQ,MAAM,KAAK,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,QAAQ,KAAK,MAAM,CAAC,CAAC"}
@@ -0,0 +1,279 @@
1
+ import { t as Raw } from "./html-Du8jY2Cc.js";
2
+ import { a as PageState, n as ElementReference } from "./produce-CtZ32UGG.js";
3
+ import { t as Context } from "./context-aeo9esY9.js";
4
+ //#region src/runtime/client.d.ts
5
+ type Update = [kind: number, name: string];
6
+ /** The entry of a compiled client module. */
7
+ interface ClientModule {
8
+ id: string;
9
+ /** Prop names to slot indices. `*` is the slot of a props object. */
10
+ props: Record<string, number>;
11
+ /** Scope kind, then slot, to the updates that read it. */
12
+ g: Record<number, Record<number, Update[]>>;
13
+ /**
14
+ * Imports a part of the module. A module without it holds every part
15
+ * itself, as a small component's module does.
16
+ */
17
+ load?: (part: string) => Promise<Part>;
18
+ /** Server function ID to the memos that call it, as scope kind and update, for `refresh`. */
19
+ refresh?: Record<string, Update[]>;
20
+ }
21
+ /** A part of a client module: one client root, or the updates. */
22
+ type Part = Record<string, unknown>;
23
+ /** The instance of a scope in the page. */
24
+ interface Scope {
25
+ id: number;
26
+ /** The scope's ID in the compiled component. */
27
+ k: number;
28
+ p?: Scope;
29
+ /** The component ID, for a component's root scope. */
30
+ m?: string;
31
+ s: unknown[];
32
+ /** The item of a list item scope. */
33
+ i?: unknown;
34
+ c?: Record<number, number>;
35
+ /** The scope that rendered a component's root scope. */
36
+ o?: Scope;
37
+ /** The values that the scope provides, by context key. */
38
+ v?: Record<string, unknown>;
39
+ /** The slots that hold the contexts that the scope reads, by context key. */
40
+ x?: Record<string, number>;
41
+ children: Set<Scope>;
42
+ /** The `b-root` of the render that the server rendered the scope in. */
43
+ r?: string;
44
+ cleanups?: Map<string, () => void>;
45
+ keys?: Map<number, unknown>;
46
+ /** Set while the scope is the body of an `#offscreen` block that is hidden. */
47
+ h?: HiddenBody;
48
+ /** Effects and `$client` callbacks to run when the `#offscreen` body around the scope shows. */
49
+ w?: Set<string>;
50
+ }
51
+ interface CoreOptions {
52
+ /**
53
+ * Imports the client module of a component. Undefined for a component that
54
+ * has no client code, which a build leaves out.
55
+ */
56
+ load: (id: string) => Promise<ClientModule> | undefined;
57
+ /** Adds event listeners for the `b-on` attributes in new markup. */
58
+ listen: (root: ParentNode) => void;
59
+ /** The URL prefix of server function calls. Defaults to `/_brumate`. */
60
+ rpc?: string;
61
+ }
62
+ /** The URL prefix of server function calls, from the options. */
63
+ declare let rpcPrefix: string;
64
+ /** The scopes of the page, by ID. */
65
+ declare const scopes: Map<number, Scope>;
66
+ /** What modules of optional features add to the core. See `client-routes.ts` and `hot`. */
67
+ declare const hooks: {
68
+ /** Changes a state record before its scopes are added, such as for a page that navigation added. */
69
+ record?: (script: Element, state: PageState) => PageState;
70
+ /** Runs after the scopes of a state record are added. */
71
+ added?: (added: Scope[]) => void;
72
+ };
73
+ /** What the devtools overlay hears from the core. It is set only in development. */
74
+ interface DevtoolsHooks {
75
+ /** The core started, with the scopes of the page, and a way to write a slot, as a handler does. */
76
+ attach?(core: {
77
+ scopes: Map<number, Scope>;
78
+ set: (scope: Scope, slot: number, value: unknown) => void;
79
+ }): void;
80
+ /** A handler starts for an event. */
81
+ handler?(ref: string, element: Element, event?: Event): void;
82
+ /** A part of a component's client code loaded. */
83
+ part?(component: string, name: string): void;
84
+ /** A slot got a new value. */
85
+ write?(scope: Scope, slot: number, value: unknown): void;
86
+ }
87
+ /** The global key of the devtools hooks. */
88
+ declare const DEVTOOLS: unique symbol;
89
+ /** Stops reading state records and markers that arrive later. Later records wait for `init`. */
90
+ declare function dispose(): void;
91
+ /**
92
+ * Stops reading, before client navigation replaces only some routes. The
93
+ * server renders the new routes with its current values, so only the writes
94
+ * that come after count for the records that stream in later.
95
+ */
96
+ declare function leaveRoutes(): void;
97
+ /**
98
+ * Removes the scopes of a render, by its `b-root`, with the scopes inside
99
+ * them. Their cleanups run, and their memos no longer load. Its markup
100
+ * stays. `brumate/testing` calls it when a mounted component unmounts.
101
+ */
102
+ declare function removeRoot(root: string): void;
103
+ /**
104
+ * Forgets the code of components that changed on the dev server, so the next
105
+ * event or update loads the new code. Their state stays. `brumate/hot` calls it.
106
+ */
107
+ declare function forget(ids: string[]): void;
108
+ /**
109
+ * Keeps the values of the signals of each instance of a component, by
110
+ * name, before the page renders again with its new markup. `brumate/hot` calls it.
111
+ */
112
+ declare function remount(detail: {
113
+ id: string;
114
+ before: Record<number, string[]>;
115
+ after: Record<number, string[]>;
116
+ signals: string[];
117
+ }[]): void;
118
+ /**
119
+ * Forgets the page, before another page replaces it. Cleanups run. Loaded
120
+ * modules and parts stay, so the next page does not load them again. Only
121
+ * client navigation calls it.
122
+ */
123
+ declare function leavePage(): void;
124
+ /** Reads the page state. The loader calls it once, before the first handler. */
125
+ declare function init(value: CoreOptions): void;
126
+ declare function loadModule(id: string): Promise<ClientModule>;
127
+ declare function loadPart(module: ClientModule, name: string): Promise<Part>;
128
+ /**
129
+ * Runs the handler `ref` for an element. The scope comes from the element's
130
+ * `b-b` anchor, or from the nearest element around it that has one, which
131
+ * the compiler checks is in the same scope.
132
+ */
133
+ declare function handle(element: Element, ref: string, event?: Event): Promise<unknown>;
134
+ /** Returns the instance of a scope by its ID. */
135
+ declare function scopeOf(id: number): Scope | undefined;
136
+ declare function get(scope: Scope, slot: number): any;
137
+ declare function set<T>(scope: Scope, slot: number, value: T): T;
138
+ /**
139
+ * The names of a call of a module function, for its shared code. Each ref
140
+ * is a slot of `scope`, `[scope, slot]` for a slot of another scope, or
141
+ * `[value]` for a value that does not change, such as a literal argument.
142
+ */
143
+ declare function cells(scope: Scope, links: unknown[], names: string[]): Record<string, unknown>;
144
+ /**
145
+ * Writes the result of an async memo when it arrives. Until then the slot
146
+ * keeps its value, and `pending` is true. Only the latest load is written.
147
+ */
148
+ declare function asyncMemo(scope: Scope, slot: number, promise: Promise<unknown>): void;
149
+ /**
150
+ * Computes a memo. A promise loads, and the memo keeps its value until it
151
+ * settles. A memo that reads a value that is still loading keeps its value
152
+ * too, and is pending until that value arrives and the memo computes again.
153
+ */
154
+ declare function memo(scope: Scope, slot: number, compute: () => unknown): void;
155
+ /**
156
+ * Writes a guess into an optimistic value. It goes back to its source when
157
+ * the source changes, which computes it again, or when every server call of
158
+ * the page finishes, such as after a post failed.
159
+ */
160
+ declare function guess<T>(scope: Scope, slot: number, ...rest: [value: T] | [sourceScope: Scope, sourceSlot: number, value: T]): T;
161
+ /** Counts a server call, and puts guesses back when the last one finishes. */
162
+ declare function track<T>(request: Promise<T>): Promise<T>;
163
+ /** True while a new value of a memo loads, or while the server still streams its value. */
164
+ declare function pending(scope: Scope, slot: number): boolean;
165
+ /** `x++`, `x--`, `++x` and `--x`. */
166
+ declare function update(scope: Scope, slot: number, delta: number, prefix: boolean): number;
167
+ declare function descendants(scope: Scope, kind: number, result?: Scope[]): Scope[];
168
+ /**
169
+ * Removes a scope from the page: its cleanups run, and its memo state goes,
170
+ * so a load that settles later is not written. Its markup stays.
171
+ */
172
+ declare function removeScope(scope: Scope): void;
173
+ /**
174
+ * Renders a `#portal` body into its target, between markers with its scope
175
+ * ID. `kinds` names the body, so a new target first removes it from the old one.
176
+ */
177
+ declare function portalTo(scope: Scope, target: unknown, render: Render, kinds?: number[]): void;
178
+ /** Writes an inserted value between `<!--t…-->` and `<!--/t-->`. */
179
+ declare function text(scope: Scope, anchor: number, value: unknown): void;
180
+ /** Writes an inserted value that is the whole content of the element with the anchor. */
181
+ declare function content(scope: Scope, anchor: number, value: unknown): void;
182
+ /**
183
+ * Writes the text of an element whose content is text, such as a `<textarea>`
184
+ * or a `<title>`. A `<textarea>` gets the value too, as `value` does on an
185
+ * `<input>`, so a change replaces what the user typed.
186
+ */
187
+ declare function writeText(scope: Scope, anchor: number, value: unknown): void;
188
+ declare function attr(scope: Scope, anchor: number, name: string, value: unknown): void;
189
+ declare function attrs(scope: Scope, anchor: number, values: Record<string, unknown>): void;
190
+ type Render = (parent: Scope, item?: unknown, index?: number) => string;
191
+ /** Shows the branch at `index` of `#if` or `#switch`, or nothing for -1. */
192
+ declare function branch(scope: Scope, anchor: number, index: number, renders: (Render | undefined)[], kinds: number[]): void;
193
+ /** Renders the body of `#key` again when its value changes. */
194
+ declare function rekey(scope: Scope, anchor: number, value: unknown, render: Render, kinds: number[]): void;
195
+ /**
196
+ * Renders the body of a `#try` block again, for its `reset` function. If the
197
+ * body throws, the fallback renders again with the error.
198
+ */
199
+ declare function reset(scope: Scope, anchor: number, id: string, body: string, fallback: string, kinds: number[]): Promise<void>;
200
+ /** Renders the body of a `#client` block once. */
201
+ declare function fill(scope: Scope, anchor: number, render: Render): void;
202
+ /**
203
+ * Shows or hides the body of an `#offscreen` block. A body that the page
204
+ * does not have yet renders the first time it shows. `kind` is the body's
205
+ * scope ID in the compiled component.
206
+ */
207
+ declare function offscreen(scope: Scope, anchor: number, value: unknown, render: Render, kind: number): void;
208
+ /** A hidden `#offscreen` body: its scope, and the ranges of its markup and of its portals. */
209
+ interface HiddenBody {
210
+ scope: Scope;
211
+ ranges: [start: Comment, end: Comment][];
212
+ }
213
+ /** Updates the items of `#for` or `#repeat`, keeping the elements of items whose keys stay. */
214
+ declare function list(scope: Scope, anchor: number, items: unknown[], key: (item: unknown, index: number) => unknown, render: Render, assign: (scope: Scope, item: unknown, index: number) => void, fallback: Render | undefined, fallbackKinds: number[]): void;
215
+ /** Sets a style variable on the top-level elements of a component instance. */
216
+ declare function setVar(scope: Scope, name: string, value: unknown): void;
217
+ /** Writes a provided value, and the slot of every scope that reads it from this provider. */
218
+ declare function updateContext(scope: Scope, context: Context<unknown>, value: unknown): void;
219
+ /** Sets the title of the page. */
220
+ declare function title(value: unknown): void;
221
+ /** Writes a prop of a child component. */
222
+ declare function prop(scope: Scope, anchor: number, name: string, value: unknown): void;
223
+ /** Runs an effect or a `$client` callback, after the cleanup of its previous run. */
224
+ declare function effect(scope: Scope, name: string, callback: () => unknown): void;
225
+ /** Renders the attributes of a form or button that posts to a server function. */
226
+ declare function action(name: string, id: string, method?: string, result?: string): string;
227
+ /**
228
+ * Sends a form of an `$action`. The code is in `rpc.ts`, which every server
229
+ * call loads, so the core holds only this.
230
+ */
231
+ declare function submitAction(form: HTMLFormElement, submitter: HTMLElement | null): void;
232
+ /** Calls a server function. */
233
+ declare function rpc(id: string, args: unknown[]): Promise<unknown>;
234
+ /** Renders a value inserted in markup. */
235
+ declare function insert(value: unknown): string;
236
+ /** A component's client render function, from its `?brumate-render` module. */
237
+ type Component<P = any> = (props: P) => string;
238
+ /**
239
+ * Renders a child component on the client. With `scope` and `anchor`,
240
+ * records the child's scope so the parent can update its props.
241
+ */
242
+ declare function component<P>(Child: Component<P>, props: P, _ctx?: unknown, scope?: Scope | number, anchor?: number): string;
243
+ declare function dynamic(tag: unknown, attributes: Record<string, unknown>, children: Raw | undefined, _ctx?: unknown, scope?: Scope | number): string;
244
+ /** Work that waits until rendered markup is in the page. */
245
+ declare const afterInsert: (() => void)[];
246
+ /** Creates a scope for markup that the client renders, and returns its ID. */
247
+ declare function createScope(kind: number, parent?: Scope | number, module?: string): number;
248
+ /** The ID that `$id()` makes. Client scope IDs are negative, so they differ from the server's. */
249
+ declare function makeId(scope: Scope | number, index: number): string;
250
+ /** Sets the owner of the next component's root scope. */
251
+ declare function setOwner(scope: Scope | number): void;
252
+ /** Provides a value of a context to the scopes inside `scope`. */
253
+ declare function provideValue<T>(context: Context<T>, value: T, scope: Scope | number): void;
254
+ /** Reads a context, and records its slot so that changes to the provided value reach it. */
255
+ declare function consumeContext<T>(context: Context<T>, scope: Scope | number, slot?: number): T;
256
+ declare function setSlots(id: number, values: unknown[]): void;
257
+ declare function setItem(id: number, value: unknown): void;
258
+ declare function elementAt(scope: number, anchor: number): ElementReference;
259
+ /** Adds the markup of a `#head` block to the document's head. */
260
+ declare function addHead(html: string): void;
261
+ /** Adds the markup of a `#portal` block at the end of the page, after the markup around it. */
262
+ declare function addPortal(html: string): void;
263
+ /** Adds a component's stylesheet to the page, if the server did not. */
264
+ declare function addStyle(id: string, css: string): string;
265
+ /** A function prop rendered on the client calls the parent's exported handler. */
266
+ declare function handlerProp(value: unknown, ref: string, scope: Scope | number): unknown;
267
+ /**
268
+ * What the loader calls. It is one export, so the loader's import of the core
269
+ * names one export, and a build keeps the rest only when components call them.
270
+ */
271
+ declare const loader: {
272
+ init: typeof init;
273
+ handle: typeof handle;
274
+ dispose: typeof dispose;
275
+ submitAction: typeof submitAction;
276
+ };
277
+ //#endregion
278
+ export { removeScope as $, get as A, loadModule as B, descendants as C, elementAt as D, effect as E, init as F, offscreen as G, loader as H, insert as I, prop as J, pending as K, leavePage as L, handle as M, handlerProp as N, fill as O, hooks as P, removeRoot as Q, leaveRoutes as R, createScope as S, dynamic as T, makeId as U, loadPart as V, memo as W, rekey as X, provideValue as Y, remount as Z, branch as _, DevtoolsHooks as a, set as at, consumeContext as b, Scope as c, setSlots as ct, addPortal as d, text as dt, reset as et, addStyle as f, title as ft, attrs as g, writeText as gt, attr as h, updateContext as ht, DEVTOOLS as i, scopes as it, guess as j, forget as k, action as l, setVar as lt, asyncMemo as m, update as mt, Component as n, rpcPrefix as nt, HiddenBody as o, setItem as ot, afterInsert as p, track as pt, portalTo as q, CoreOptions as r, scopeOf as rt, Part as s, setOwner as st, ClientModule as t, rpc as tt, addHead as u, submitAction as ut, cells as v, dispose as w, content as x, component as y, list as z };
279
+ //# sourceMappingURL=client-DwJInP_a.d.ts.map
@@ -0,0 +1,94 @@
1
+ //#region src/runtime/client-routes.ts
2
+ /** Adds a number to the scope IDs of a state record. */
3
+ function shiftState(core, state, by) {
4
+ const { ElementReference, FunctionReference } = core;
5
+ const seen = /* @__PURE__ */ new Set();
6
+ const shiftValue = (value) => {
7
+ if (value instanceof ElementReference) return new ElementReference(value.scope + by, value.anchor);
8
+ if (value instanceof FunctionReference) return new FunctionReference(value.ref, value.scope + by);
9
+ if (value instanceof Promise) return value.then(shiftValue);
10
+ if (typeof value === "object" && value !== null && !seen.has(value)) {
11
+ seen.add(value);
12
+ if (Array.isArray(value)) value.forEach((item, index) => {
13
+ value[index] = shiftValue(item);
14
+ });
15
+ else if (Object.getPrototypeOf(value) === Object.prototype) for (const [key, item] of Object.entries(value)) value[key] = shiftValue(item);
16
+ }
17
+ return value;
18
+ };
19
+ const result = {};
20
+ for (const [key, record] of Object.entries(state)) result[Number(key) + by] = {
21
+ ...record,
22
+ p: record.p === void 0 ? void 0 : record.p + by,
23
+ o: record.o === void 0 ? void 0 : record.o + by,
24
+ c: record.c && Object.fromEntries(Object.entries(record.c).map(([anchor, id]) => [anchor, id + by])),
25
+ s: record.s?.map(shiftValue)
26
+ };
27
+ return result;
28
+ }
29
+ /** Removes scopes and the scopes inside them, and runs their cleanups. */
30
+ function dropScopes(core, roots) {
31
+ const inside = (scope) => {
32
+ for (let current = scope; current; current = current.p ?? current.o) if (roots.has(current.id)) return true;
33
+ return false;
34
+ };
35
+ for (const scope of core.scopes.values()) if (inside(scope)) core.removeScope(scope);
36
+ }
37
+ /**
38
+ * Reads the attributes that navigation set on a state record. A page whose
39
+ * IDs started at another number, such as a prerendered file, has them moved
40
+ * with `b-offset`. A page that replaced only some routes of the one before
41
+ * it drops the old routes with `b-drop`, and adds only the scopes inside
42
+ * `b-roots`, with the scopes of the kept layouts in place of the new
43
+ * page's copies of them, by `b-alias`.
44
+ */
45
+ function routeRecord(core, script, state) {
46
+ const offset = Number(script.getAttribute("b-offset") ?? 0);
47
+ const value = offset ? shiftState(core, state, offset) : state;
48
+ const drop = script.getAttribute("b-drop");
49
+ if (drop) dropScopes(core, new Set(drop.split(",").map(Number)));
50
+ const list = script.getAttribute("b-roots");
51
+ if (list === null) return value;
52
+ const roots = new Set(list.split(",").filter(Boolean).map(Number));
53
+ const alias = /* @__PURE__ */ new Map();
54
+ for (const pair of (script.getAttribute("b-alias") ?? "").split(",").filter(Boolean)) {
55
+ const [from, to] = pair.split(":").map(Number);
56
+ alias.set(from, to);
57
+ }
58
+ const kept = (id) => {
59
+ for (let current = id; current !== void 0;) {
60
+ if (roots.has(current)) return true;
61
+ const record = value[current];
62
+ current = record?.p ?? record?.o;
63
+ }
64
+ return false;
65
+ };
66
+ const resolve = (id) => id === void 0 ? void 0 : alias.get(id) ?? id;
67
+ const result = {};
68
+ for (const [key, record] of Object.entries(value)) if (kept(Number(key))) result[Number(key)] = {
69
+ ...record,
70
+ p: resolve(record.p),
71
+ o: resolve(record.o)
72
+ };
73
+ return result;
74
+ }
75
+ /**
76
+ * Settles once the core reads records with this module, with the function
77
+ * that forgets the page before navigation replaces it, or only stops reading
78
+ * when layouts stay.
79
+ */
80
+ const ready = import("./runtime/client.js").then(({ ElementReference, FunctionReference, hooks, leavePage, leaveRoutes, removeScope, scopes }) => {
81
+ const core = {
82
+ ElementReference,
83
+ FunctionReference,
84
+ hooks,
85
+ removeScope,
86
+ scopes
87
+ };
88
+ hooks.record = (script, state) => routeRecord(core, script, state);
89
+ return (partial) => partial ? leaveRoutes() : leavePage();
90
+ });
91
+ //#endregion
92
+ export { ready };
93
+
94
+ //# sourceMappingURL=client-routes-DakuM32C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-routes-DakuM32C.js","names":[],"sources":["../src/runtime/client-routes.ts"],"sourcesContent":["// What the core needs to read the pages that client navigation adds. Only\n// `navigate.ts` writes the attributes that this module reads, so the loader\n// imports it when it navigates or finds such a record, and a page that never\n// navigates does not load it. Importing it sets the core's `record` hook.\n//\n// It reads the core with `import()`, as `rpc.ts` does, and imports nothing\n// else. A static import of the core would make the package build move the\n// core into a chunk behind a module that only re-exports it, and a static\n// import of `shared.ts` would split that module out of the core of a page.\n// The core is loaded already, or loads with this module.\n\nimport type * as Client from './client.ts';\nimport type { Scope } from './client.ts';\nimport type { PageState, ScopeState } from './shared.ts';\n\n/** The parts of the core that this module uses. */\ntype Core = Pick<\n typeof Client,\n 'ElementReference' | 'FunctionReference' | 'hooks' | 'removeScope' | 'scopes'\n>;\n\n/** Adds a number to the scope IDs of a state record. */\nfunction shiftState(core: Core, state: PageState, by: number): PageState {\n const { ElementReference, FunctionReference } = core;\n const seen = new Set<object>();\n // References to elements and client functions name the scope of their markup.\n const shiftValue = (value: unknown): unknown => {\n if (value instanceof ElementReference) {\n return new ElementReference(value.scope + by, value.anchor);\n }\n if (value instanceof FunctionReference) {\n return new FunctionReference(value.ref, value.scope + by);\n }\n // A later record settles it, with a value whose IDs move too.\n if (value instanceof Promise) {\n return value.then(shiftValue);\n }\n if (typeof value === 'object' && value !== null && !seen.has(value)) {\n seen.add(value);\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n value[index] = shiftValue(item);\n });\n } else if (Object.getPrototypeOf(value) === Object.prototype) {\n for (const [key, item] of Object.entries(value)) {\n (value as Record<string, unknown>)[key] = shiftValue(item);\n }\n }\n }\n return value;\n };\n const result: PageState = {};\n for (const [key, record] of Object.entries(state)) {\n result[Number(key) + by] = {\n ...record,\n p: record.p === undefined ? undefined : record.p + by,\n o: record.o === undefined ? undefined : record.o + by,\n c:\n record.c &&\n Object.fromEntries(Object.entries(record.c).map(([anchor, id]) => [anchor, id + by])),\n s: record.s?.map(shiftValue),\n };\n }\n return result;\n}\n\n/** Removes scopes and the scopes inside them, and runs their cleanups. */\nfunction dropScopes(core: Core, roots: Set<number>): void {\n const inside = (scope: Scope): boolean => {\n for (let current: Scope | undefined = scope; current; current = current.p ?? current.o) {\n if (roots.has(current.id)) {\n return true;\n }\n }\n return false;\n };\n // Deleting from a map while iterating it is safe.\n for (const scope of core.scopes.values()) {\n if (inside(scope)) {\n core.removeScope(scope);\n }\n }\n}\n\n/**\n * Reads the attributes that navigation set on a state record. A page whose\n * IDs started at another number, such as a prerendered file, has them moved\n * with `b-offset`. A page that replaced only some routes of the one before\n * it drops the old routes with `b-drop`, and adds only the scopes inside\n * `b-roots`, with the scopes of the kept layouts in place of the new\n * page's copies of them, by `b-alias`.\n */\nfunction routeRecord(core: Core, script: Element, state: PageState): PageState {\n // Only records with scopes hold IDs. Later records settle promises, which `shiftState` wraps.\n const offset = Number(script.getAttribute('b-offset') ?? 0);\n const value = offset ? shiftState(core, state, offset) : state;\n const drop = script.getAttribute('b-drop');\n if (drop) {\n dropScopes(core, new Set(drop.split(',').map(Number)));\n }\n const list = script.getAttribute('b-roots');\n if (list === null) {\n return value;\n }\n const roots = new Set(list.split(',').filter(Boolean).map(Number));\n const alias = new Map<number, number>();\n for (const pair of (script.getAttribute('b-alias') ?? '').split(',').filter(Boolean)) {\n const [from, to] = pair.split(':').map(Number) as [number, number];\n alias.set(from, to);\n }\n const kept = (id: number): boolean => {\n for (let current: number | undefined = id; current !== undefined;) {\n if (roots.has(current)) {\n return true;\n }\n const record: ScopeState | undefined = value[current];\n current = record?.p ?? record?.o;\n }\n return false;\n };\n const resolve = (id: number | undefined): number | undefined =>\n id === undefined ? undefined : (alias.get(id) ?? id);\n const result: PageState = {};\n for (const [key, record] of Object.entries(value)) {\n // The new page renders the kept layouts again. Their scopes are not added.\n if (kept(Number(key))) {\n result[Number(key)] = { ...record, p: resolve(record.p), o: resolve(record.o) };\n }\n }\n return result;\n}\n\n/**\n * Settles once the core reads records with this module, with the function\n * that forgets the page before navigation replaces it, or only stops reading\n * when layouts stay.\n */\nexport const ready: Promise<(partial: boolean) => void> = import('./client.ts').then(\n ({ ElementReference, FunctionReference, hooks, leavePage, leaveRoutes, removeScope, scopes }) => {\n const core = { ElementReference, FunctionReference, hooks, removeScope, scopes };\n hooks.record = (script, state) => routeRecord(core, script, state);\n return (partial) => (partial ? leaveRoutes() : leavePage());\n },\n);\n"],"mappings":";;AAsBA,SAAS,WAAW,MAAY,OAAkB,IAAuB;CACvE,MAAM,EAAE,kBAAkB,sBAAsB;CAChD,MAAM,uBAAO,IAAI,IAAY;CAE7B,MAAM,cAAc,UAA4B;EAC9C,IAAI,iBAAiB,kBACnB,OAAO,IAAI,iBAAiB,MAAM,QAAQ,IAAI,MAAM,MAAM;EAE5D,IAAI,iBAAiB,mBACnB,OAAO,IAAI,kBAAkB,MAAM,KAAK,MAAM,QAAQ,EAAE;EAG1D,IAAI,iBAAiB,SACnB,OAAO,MAAM,KAAK,UAAU;EAE9B,IAAI,OAAO,UA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UAAU,QAAQ,UAAU,YAAY,MAAM,QAAQ,KAAK;CACjE,QAAQ,YAAa,UAAU,YAAY,IAAI,UAAU;AAC3D,CACF"}
@@ -0,0 +1,15 @@
1
+ //#region src/runtime/context.ts
2
+ /**
3
+ * Creates a context. `key` names it in the page state, so it must be unique
4
+ * in the app and the same on the server and the client.
5
+ */
6
+ function createContext(key, defaultValue) {
7
+ return {
8
+ key,
9
+ defaultValue
10
+ };
11
+ }
12
+ //#endregion
13
+ export { createContext as t };
14
+
15
+ //# sourceMappingURL=context-BG8KCF3v.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-BG8KCF3v.js","names":[],"sources":["../src/runtime/context.ts"],"sourcesContent":["/** A value that a component provides to the components inside it. */\nexport interface Context<T> {\n /** The same on the server and the client, so the page state can name the context. */\n readonly key: string;\n /** The value of a component that reads the context without a provider above it. */\n readonly defaultValue: T;\n}\n\n/**\n * Creates a context. `key` names it in the page state, so it must be unique\n * in the app and the same on the server and the client.\n */\nexport function createContext<T>(key: string, defaultValue: T): Context<T> {\n return { key, defaultValue };\n}\n"],"mappings":";;;;;AAYA,SAAgB,cAAiB,KAAa,cAA6B;CACzE,OAAO;EAAE;EAAK;CAAa;AAC7B"}
@@ -0,0 +1,16 @@
1
+ //#region src/runtime/context.d.ts
2
+ /** A value that a component provides to the components inside it. */
3
+ interface Context<T> {
4
+ /** The same on the server and the client, so the page state can name the context. */
5
+ readonly key: string;
6
+ /** The value of a component that reads the context without a provider above it. */
7
+ readonly defaultValue: T;
8
+ }
9
+ /**
10
+ * Creates a context. `key` names it in the page state, so it must be unique
11
+ * in the app and the same on the server and the client.
12
+ */
13
+ declare function createContext<T>(key: string, defaultValue: T): Context<T>;
14
+ //#endregion
15
+ export { createContext as n, Context as t };
16
+ //# sourceMappingURL=context-aeo9esY9.d.ts.map