brumate 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +68 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/client-DuDTDePF.d.ts +190 -0
  7. package/dist/context-BG8KCF3v.js +15 -0
  8. package/dist/context-BG8KCF3v.js.map +1 -0
  9. package/dist/context-aeo9esY9.d.ts +16 -0
  10. package/dist/cookies-rgIAc8IE.js +165 -0
  11. package/dist/cookies-rgIAc8IE.js.map +1 -0
  12. package/dist/devtools-Bm8cS7hX.js +108 -0
  13. package/dist/devtools-Bm8cS7hX.js.map +1 -0
  14. package/dist/devtools-panel-CTbDSBBA.js +437 -0
  15. package/dist/devtools-panel-CTbDSBBA.js.map +1 -0
  16. package/dist/files-D_JUcSU5.js +158 -0
  17. package/dist/files-D_JUcSU5.js.map +1 -0
  18. package/dist/html-CxWpXngy.js +115 -0
  19. package/dist/html-CxWpXngy.js.map +1 -0
  20. package/dist/html-DV-Tezgq.d.ts +41 -0
  21. package/dist/index.d.ts +2031 -0
  22. package/dist/index.js +691 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/inspect-CGCWfaEx.js +6346 -0
  25. package/dist/inspect-CGCWfaEx.js.map +1 -0
  26. package/dist/loader-BUhNqDHw.d.ts +30 -0
  27. package/dist/loader-py4qu6tQ.js +215 -0
  28. package/dist/loader-py4qu6tQ.js.map +1 -0
  29. package/dist/navigate-C5dP89YL.js +369 -0
  30. package/dist/navigate-C5dP89YL.js.map +1 -0
  31. package/dist/produce-BRGHP7e0.js +126 -0
  32. package/dist/produce-BRGHP7e0.js.map +1 -0
  33. package/dist/produce-BjQGMpqL.d.ts +50 -0
  34. package/dist/rpc-B86KKjzx.js +83 -0
  35. package/dist/rpc-B86KKjzx.js.map +1 -0
  36. package/dist/runtime/client.d.ts +5 -0
  37. package/dist/runtime/client.js +1052 -0
  38. package/dist/runtime/client.js.map +1 -0
  39. package/dist/runtime/context.d.ts +2 -0
  40. package/dist/runtime/context.js +1 -0
  41. package/dist/runtime/devtools.d.ts +34 -0
  42. package/dist/runtime/devtools.js +1 -0
  43. package/dist/runtime/hot.d.ts +36 -0
  44. package/dist/runtime/hot.js +40 -0
  45. package/dist/runtime/hot.js.map +1 -0
  46. package/dist/runtime/html.d.ts +2 -0
  47. package/dist/runtime/html.js +1 -0
  48. package/dist/runtime/loader.d.ts +2 -0
  49. package/dist/runtime/loader.js +1 -0
  50. package/dist/runtime/routes.d.ts +21 -0
  51. package/dist/runtime/routes.js +18 -0
  52. package/dist/runtime/routes.js.map +1 -0
  53. package/dist/runtime/server.d.ts +5 -0
  54. package/dist/runtime/server.js +7 -0
  55. package/dist/runtime/signals.d.ts +46 -0
  56. package/dist/runtime/signals.js +74 -0
  57. package/dist/runtime/signals.js.map +1 -0
  58. package/dist/runtime/testing.d.ts +36 -0
  59. package/dist/runtime/testing.js +96 -0
  60. package/dist/runtime/testing.js.map +1 -0
  61. package/dist/server-CX3JnPCs.js +1205 -0
  62. package/dist/server-CX3JnPCs.js.map +1 -0
  63. package/dist/server-sQCvduOz.d.ts +562 -0
  64. package/dist/shared-BE_oBSDM.js +176 -0
  65. package/dist/shared-BE_oBSDM.js.map +1 -0
  66. package/dist/stream-cvhqOzfs.js +145 -0
  67. package/dist/stream-cvhqOzfs.js.map +1 -0
  68. package/dist/vite.d.ts +121 -0
  69. package/dist/vite.js +958 -0
  70. package/dist/vite.js.map +1 -0
  71. package/package.json +117 -3
  72. package/types.d.ts +36 -0
@@ -0,0 +1,158 @@
1
+ import { h as functionId } from "./inspect-CGCWfaEx.js";
2
+ import { parseSync } from "oxc-parser";
3
+ import { readFile, readdir } from "node:fs/promises";
4
+ import path from "node:path";
5
+ //#region src/server-files.ts
6
+ /** The import of the stubs, which call server functions with `rpc` of the core. */
7
+ const CLIENT = "brumate/client";
8
+ /** True for a file whose first statement is `'use server'`, after comments. */
9
+ function hasUseServer(source) {
10
+ return /^(?:\s|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*(['"])use server\1/.test(source);
11
+ }
12
+ /** True for a path that can be a file of server functions. */
13
+ function isScriptFile(path) {
14
+ return /\.[cm]?[jt]sx?$/.test(path) && !path.endsWith(".d.ts") && !/\.brm\.[cm]?[jt]s$/.test(path);
15
+ }
16
+ /** True for a function expression or an arrow. */
17
+ function isFunction(node) {
18
+ return node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression";
19
+ }
20
+ /**
21
+ * The names of the functions that a file of server functions exports.
22
+ * Throws for an export that is not a function, because the browser can only
23
+ * call a server function through its stub.
24
+ */
25
+ function serverExports(source, filename) {
26
+ const { program, errors } = parseSync(filename, source, { lang: "ts" });
27
+ if (errors[0]) throw new Error(`${errors[0].message} (${filename})`);
28
+ const functions = /* @__PURE__ */ new Set();
29
+ const values = /* @__PURE__ */ new Set();
30
+ const local = /* @__PURE__ */ new Map();
31
+ for (const statement of program.body) {
32
+ const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
33
+ if (declaration?.type === "FunctionDeclaration" && declaration.id) local.set(declaration.id.name, "function");
34
+ else if (declaration?.type === "VariableDeclaration") {
35
+ for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier") local.set(declarator.id.name, isFunction(declarator.init) ? "function" : "value");
36
+ }
37
+ }
38
+ for (const statement of program.body) if (statement.type === "ExportDefaultDeclaration") {
39
+ const value = statement.declaration;
40
+ if (value.type === "FunctionDeclaration" || isFunction(value)) functions.add("default");
41
+ else values.add("default");
42
+ } else if (statement.type === "ExportNamedDeclaration") {
43
+ if (statement.exportKind === "type") continue;
44
+ const declaration = statement.declaration;
45
+ if (declaration?.type === "FunctionDeclaration" && declaration.id) functions.add(declaration.id.name);
46
+ else if (declaration?.type === "VariableDeclaration") {
47
+ for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier") (isFunction(declarator.init) ? functions : values).add(declarator.id.name);
48
+ } else if (declaration && !declaration.type.startsWith("TS")) values.add("a class");
49
+ for (const specifier of statement.specifiers) {
50
+ if (specifier.exportKind === "type") continue;
51
+ const name = specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value;
52
+ const from = specifier.local.type === "Identifier" ? specifier.local.name : "";
53
+ (local.get(from) === "function" && !statement.source ? functions : values).add(name);
54
+ }
55
+ } else if (statement.type === "ExportAllDeclaration") values.add("*");
56
+ if (values.size > 0) throw new Error(`A 'use server' file exports only functions, because the browser calls them on the server. ${[...values].join(", ")} of ${filename} is not one`);
57
+ return [...functions];
58
+ }
59
+ /** The module that the browser gets in place of a file of server functions. */
60
+ function serverStubs(source, filename, id, hideNames = false) {
61
+ const lines = [`import { rpc } from ${JSON.stringify(CLIENT)};`];
62
+ for (const name of serverExports(source, filename)) {
63
+ const call = `(...args) => rpc(${JSON.stringify(functionId(id, name, hideNames))}, args)`;
64
+ lines.push(name === "default" ? `export default ${call};` : `export const ${name} = ${call};`);
65
+ }
66
+ return `${lines.join("\n")}\n`;
67
+ }
68
+ /**
69
+ * The module that the server runs for a file of server functions: the file,
70
+ * with each exported function wrapped, so its calls while a page renders
71
+ * share a result when their arguments are the same. Offsets stay the same.
72
+ */
73
+ function serverModule(source, filename, id) {
74
+ const { program } = parseSync(filename, source, { lang: "ts" });
75
+ const wrapped = /* @__PURE__ */ new Map();
76
+ const declarations = /* @__PURE__ */ new Map();
77
+ let code = source;
78
+ for (const statement of program.body) {
79
+ const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
80
+ if (declaration?.type === "FunctionDeclaration" && declaration.id) declarations.set(declaration.id.name, "function");
81
+ else if (declaration?.type === "VariableDeclaration") {
82
+ for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier" && isFunction(declarator.init)) declarations.set(declarator.id.name, "const");
83
+ }
84
+ }
85
+ const letOf = (declaration) => {
86
+ if (declaration.kind === "const") code = `${code.slice(0, declaration.start)}let ${code.slice(declaration.start + 5)}`;
87
+ };
88
+ for (const statement of program.body) {
89
+ if (statement.type !== "ExportNamedDeclaration" || statement.source || statement.exportKind === "type") continue;
90
+ const declaration = statement.declaration;
91
+ if (declaration?.type === "FunctionDeclaration" && declaration.id) wrapped.set(declaration.id.name, declaration.id.name);
92
+ else if (declaration?.type === "VariableDeclaration") {
93
+ for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier" && isFunction(declarator.init)) {
94
+ wrapped.set(declarator.id.name, declarator.id.name);
95
+ letOf(declaration);
96
+ }
97
+ }
98
+ for (const specifier of statement.specifiers) {
99
+ const local = specifier.local.type === "Identifier" ? specifier.local.name : "";
100
+ const exported = specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value;
101
+ if (declarations.has(local)) wrapped.set(local, exported);
102
+ }
103
+ }
104
+ for (const statement of program.body) if (statement.type === "VariableDeclaration") {
105
+ for (const declarator of statement.declarations) if (declarator.id.type === "Identifier" && wrapped.has(declarator.id.name)) letOf(statement);
106
+ }
107
+ if (wrapped.size === 0) return source;
108
+ const lines = ["import { dedupe as __brumateDedupe } from 'brumate/server';"];
109
+ for (const [local, exported] of wrapped) lines.push(`${local} = __brumateDedupe(${local}, ${JSON.stringify(`${id}#${exported}`)});`);
110
+ return `${code}\n${lines.join("\n")}\n`;
111
+ }
112
+ //#endregion
113
+ //#region src/files.ts
114
+ /** Skips `node_modules`, `dist` and hidden directories when looking for `.brm` files. */
115
+ function defaultExclude(directory) {
116
+ return directory === "node_modules" || directory === "dist" || directory.startsWith(".");
117
+ }
118
+ /** Finds every `.brm` file under a directory, as absolute paths with forward slashes. */
119
+ async function findFiles(root, exclude) {
120
+ const result = [];
121
+ const visit = async (directory) => {
122
+ const directories = [];
123
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
124
+ const file = path.join(directory, entry.name);
125
+ if (entry.isDirectory()) {
126
+ if (!exclude(entry.name)) directories.push(visit(file));
127
+ } else if (entry.name.endsWith(".brm")) result.push(file.split(path.sep).join("/"));
128
+ }
129
+ await Promise.all(directories);
130
+ };
131
+ await visit(root);
132
+ return result.toSorted();
133
+ }
134
+ /**
135
+ * Finds every file of server functions under a directory: a script whose
136
+ * first statement is `'use server'`.
137
+ */
138
+ async function findServerFiles(root, exclude) {
139
+ const result = [];
140
+ const visit = async (directory) => {
141
+ const pending = [];
142
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
143
+ const file = path.join(directory, entry.name);
144
+ if (entry.isDirectory()) {
145
+ if (!exclude(entry.name)) pending.push(visit(file));
146
+ } else if (isScriptFile(entry.name)) pending.push(readFile(file, "utf8").then((source) => {
147
+ if (hasUseServer(source)) result.push(file.split(path.sep).join("/"));
148
+ }));
149
+ }
150
+ await Promise.all(pending);
151
+ };
152
+ await visit(root);
153
+ return result.toSorted();
154
+ }
155
+ //#endregion
156
+ export { isScriptFile as a, serverStubs as c, hasUseServer as i, findFiles as n, serverExports as o, findServerFiles as r, serverModule as s, defaultExclude as t };
157
+
158
+ //# sourceMappingURL=files-D_JUcSU5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-D_JUcSU5.js","names":[],"sources":["../src/server-files.ts","../src/files.ts"],"sourcesContent":["// Files of server functions. A `.ts` or `.js` file whose first statement is\n// `'use server'` holds functions that only run on the server. Its exports are\n// server functions: the browser gets a stub for each one, which calls the\n// server, and the code of the file never ships.\n\nimport { parseSync } from 'oxc-parser';\nimport { functionId } from './plan.ts';\n\n/** The import of the stubs, which call server functions with `rpc` of the core. */\nconst CLIENT = 'brumate/client';\n\n/** True for a file whose first statement is `'use server'`, after comments. */\nexport function hasUseServer(source: string): boolean {\n return /^(?:\\s|\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/)*(['\"])use server\\1/.test(source);\n}\n\n/** True for a path that can be a file of server functions. */\nexport function isScriptFile(path: string): boolean {\n return (\n /\\.[cm]?[jt]sx?$/.test(path) && !path.endsWith('.d.ts') && !/\\.brm\\.[cm]?[jt]s$/.test(path)\n );\n}\n\n/** True for a function expression or an arrow. */\nfunction isFunction(node: { type: string } | null | undefined): boolean {\n return node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression';\n}\n\n/**\n * The names of the functions that a file of server functions exports.\n * Throws for an export that is not a function, because the browser can only\n * call a server function through its stub.\n */\nexport function serverExports(source: string, filename: string): string[] {\n const { program, errors } = parseSync(filename, source, { lang: 'ts' });\n if (errors[0]) {\n throw new Error(`${errors[0].message} (${filename})`);\n }\n const functions = new Set<string>();\n const values = new Set<string>();\n const local = new Map<string, 'function' | 'value'>();\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n local.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n local.set(declarator.id.name, isFunction(declarator.init) ? 'function' : 'value');\n }\n }\n }\n }\n for (const statement of program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n const value = statement.declaration;\n if (value.type === 'FunctionDeclaration' || isFunction(value)) {\n functions.add('default');\n } else {\n values.add('default');\n }\n } else if (statement.type === 'ExportNamedDeclaration') {\n if (statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n functions.add(declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n (isFunction(declarator.init) ? functions : values).add(declarator.id.name);\n }\n }\n } else if (declaration && !declaration.type.startsWith('TS')) {\n values.add('a class');\n }\n for (const specifier of statement.specifiers) {\n if (specifier.exportKind === 'type') {\n continue;\n }\n const name =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const from = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n (local.get(from) === 'function' && !statement.source ? functions : values).add(name);\n }\n } else if (statement.type === 'ExportAllDeclaration') {\n values.add('*');\n }\n }\n if (values.size > 0) {\n throw new Error(\n `A 'use server' file exports only functions, because the browser calls them on the server. ${[...values].join(', ')} of ${filename} is not one`,\n );\n }\n return [...functions];\n}\n\n/** The module that the browser gets in place of a file of server functions. */\nexport function serverStubs(\n source: string,\n filename: string,\n id: string,\n hideNames = false,\n): string {\n const lines = [`import { rpc } from ${JSON.stringify(CLIENT)};`];\n for (const name of serverExports(source, filename)) {\n const call = `(...args) => rpc(${JSON.stringify(functionId(id, name, hideNames))}, args)`;\n lines.push(name === 'default' ? `export default ${call};` : `export const ${name} = ${call};`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The module that the server runs for a file of server functions: the file,\n * with each exported function wrapped, so its calls while a page renders\n * share a result when their arguments are the same. Offsets stay the same.\n */\nexport function serverModule(source: string, filename: string, id: string): string {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n // Local names of exported functions, with the name that each is exported as.\n const wrapped = new Map<string, string>();\n const declarations = new Map<string, 'function' | 'const'>();\n let code = source;\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n declarations.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n declarations.set(declarator.id.name, 'const');\n }\n }\n }\n }\n const letOf = (declaration: { start: number; kind: string }): void => {\n // `const` becomes `let `, so the function can be wrapped and offsets stay the same.\n if (declaration.kind === 'const') {\n code = `${code.slice(0, declaration.start)}let ${code.slice(declaration.start + 5)}`;\n }\n };\n for (const statement of program.body) {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n statement.source ||\n statement.exportKind === 'type'\n ) {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n wrapped.set(declaration.id.name, declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n wrapped.set(declarator.id.name, declarator.id.name);\n letOf(declaration);\n }\n }\n }\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (declarations.has(local)) {\n wrapped.set(local, exported);\n }\n }\n }\n // A `const` arrow that `export { name }` exports is declared with `let` too.\n for (const statement of program.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n if (declarator.id.type === 'Identifier' && wrapped.has(declarator.id.name)) {\n letOf(statement);\n }\n }\n }\n }\n if (wrapped.size === 0) {\n return source;\n }\n const lines = [\"import { dedupe as __brumateDedupe } from 'brumate/server';\"];\n for (const [local, exported] of wrapped) {\n lines.push(`${local} = __brumateDedupe(${local}, ${JSON.stringify(`${id}#${exported}`)});`);\n }\n return `${code}\\n${lines.join('\\n')}\\n`;\n}\n","import { readFile, readdir } from 'node:fs/promises';\nimport path from 'node:path';\nimport { hasUseServer, isScriptFile } from './server-files.ts';\n\n/** Skips `node_modules`, `dist` and hidden directories when looking for `.brm` files. */\nexport function defaultExclude(directory: string): boolean {\n return directory === 'node_modules' || directory === 'dist' || directory.startsWith('.');\n}\n\n/** Finds every `.brm` file under a directory, as absolute paths with forward slashes. */\nexport async function findFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n const visit = async (directory: string): Promise<void> => {\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n directories.push(visit(file));\n }\n } else if (entry.name.endsWith('.brm')) {\n result.push(file.split(path.sep).join('/'));\n }\n }\n await Promise.all(directories);\n };\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Finds every file of server functions under a directory: a script whose\n * first statement is `'use server'`.\n */\nexport async function findServerFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n const visit = async (directory: string): Promise<void> => {\n const pending: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n pending.push(visit(file));\n }\n } else if (isScriptFile(entry.name)) {\n pending.push(\n readFile(file, 'utf8').then((source) => {\n if (hasUseServer(source)) {\n result.push(file.split(path.sep).join('/'));\n }\n }),\n );\n }\n }\n await Promise.all(pending);\n };\n await visit(root);\n return result.toSorted();\n}\n"],"mappings":";;;;;;AASA,MAAM,SAAS;;AAGf,SAAgB,aAAa,QAAyB;CACpD,OAAO,2DAA2D,KAAK,MAAM;AAC/E;;AAGA,SAAgB,aAAa,MAAuB;CAClD,OACE,kBAAkB,KAAK,IAAI,KAAK,CAAC,KAAK,SAAS,OAAO,KAAK,CAAC,qBAAqB,KAAK,IAAI;AAE9F;;AAGA,SAAS,WAAW,MAAoD;CACtE,OAAO,MAAM,SAAS,6BAA6B,MAAM,SAAS;AACpE;;;;;;AAOA,SAAgB,cAAc,QAAgB,UAA4B;CACxE,MAAM,EAAE,SAAS,WAAW,UAAU,UAAU,QAAQ,EAAE,MAAM,KAAK,CAAC;CACtE,IAAI,OAAO,IACT,MAAM,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC,QAAQ,IAAI,SAAS,EAAE;CAEtD,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,yBAAS,IAAI,IAAY;CAC/B,MAAM,wBAAQ,IAAI,IAAkC;CACpD,KAAK,MAAM,aAAa,QAAQ,MAAM;EACpC,MAAM,cACJ,UAAU,SAAS,2BAA2B,UAAU,cAAc;EACxE,IAAI,aAAa,SAAS,yBAAyB,YAAY,IAC7D,MAAM,IAAI,YAAY,GAAG,MAAM,UAAU;OACpC,IAAI,aAAa,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AAW,EAAE,eAAe,KAAK,CAAC,GAAG;GACrE,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,YAAY,GAChB;QAAA,CAAC,QAAQ,MAAM,IAAI,GACrB,YAAY,KAAK,MAAM,IAAI,CAAC;GAAA,OAEzB,IAAI,MAAM,KAAK,SAAS,MAAM,GACnC,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;EAE9C;EACA,MAAM,QAAQ,IAAI,WAAW;CAC/B;CACA,MAAM,MAAM,IAAI;CAChB,OAAO,OAAO,SAAS;AACzB;;;;;AAMA,eAAsB,gBACpB,MACA,SACmB;CACnB,MAAM,SAAmB,CAAC;CAC1B,MAAM,QAAQ,OAAO,cAAqC;EACxD,MAAM,UAA2B,CAAC;EAClC,KAAK,MAAM,SAAS,MAAM,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;GACrE,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,YAAY,GAChB;QAAA,CAAC,QAAQ,MAAM,IAAI,GACrB,QAAQ,KAAK,MAAM,IAAI,CAAC;GAAA,OAErB,IAAI,aAAa,MAAM,IAAI,GAChC,QAAQ,KACN,SAAS,MAAM,MAAM,CAAC,CAAC,MAAM,WAAW;IACtC,IAAI,aAAa,MAAM,GACrB,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;GAE9C,CAAC,CACH;EAEJ;EACA,MAAM,QAAQ,IAAI,OAAO;CAC3B;CACA,MAAM,MAAM,IAAI;CAChB,OAAO,OAAO,SAAS;AACzB"}
@@ -0,0 +1,115 @@
1
+ //#region src/runtime/html.ts
2
+ const RAW = Symbol.for("brumate.raw");
3
+ function raw(html) {
4
+ return { [RAW]: html };
5
+ }
6
+ function isRaw(value) {
7
+ return typeof value === "object" && value !== null && RAW in value;
8
+ }
9
+ function rawHTML(value) {
10
+ return value[RAW];
11
+ }
12
+ const ESCAPES = {
13
+ "&": "&amp;",
14
+ "<": "&lt;",
15
+ ">": "&gt;",
16
+ "\"": "&quot;"
17
+ };
18
+ function escape(value) {
19
+ return value.replace(/[&<>]/g, (char) => ESCAPES[char]);
20
+ }
21
+ function escapeAttribute(value) {
22
+ return value.replace(/[&<"]/g, (char) => ESCAPES[char]);
23
+ }
24
+ /** Renders a value inserted in markup. Promises are not awaited. */
25
+ function insertValue(value) {
26
+ if (isRaw(value)) return value[RAW];
27
+ if (value === null || value === void 0 || typeof value === "boolean") return "";
28
+ if (Array.isArray(value)) return value.map(insertValue).join("");
29
+ return escape(String(value));
30
+ }
31
+ function toKebabCase(name) {
32
+ return name.startsWith("--") ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
33
+ }
34
+ function classValue(value) {
35
+ if (Array.isArray(value)) return value.map(classValue).filter(Boolean).join(" ");
36
+ if (typeof value === "object" && value !== null) return Object.entries(value).filter(([, enabled]) => enabled).map(([name]) => name).join(" ");
37
+ return value ? String(value) : "";
38
+ }
39
+ function styleValue(value) {
40
+ if (typeof value === "object" && value !== null) return Object.entries(value).filter(([, item]) => item !== null && item !== void 0 && item !== false).map(([name, item]) => `${toKebabCase(name)}:${String(item)}`).join(";");
41
+ return String(value);
42
+ }
43
+ /**
44
+ * Returns the text of an attribute, or undefined if the attribute is not
45
+ * rendered. `true` renders as an empty value.
46
+ */
47
+ function attributeText(name, value) {
48
+ if (value === null || value === void 0 || value === false || typeof value === "function") return;
49
+ if (value === true) return "";
50
+ if (name === "class") {
51
+ const text = classValue(value);
52
+ return text === "" ? void 0 : text;
53
+ }
54
+ return name === "style" ? styleValue(value) : String(value);
55
+ }
56
+ /** Renders one attribute, with a leading space. */
57
+ function attribute(name, value) {
58
+ const text = attributeText(name, value);
59
+ if (text === void 0) return "";
60
+ return value === true ? ` ${name}` : ` ${name}="${escapeAttribute(text)}"`;
61
+ }
62
+ /**
63
+ * Returns the value of a style variable with text around it, such as `12px`
64
+ * for `${size}px`. A value that sets no variable stays as it is.
65
+ */
66
+ function affix(prefix, value, suffix) {
67
+ return value === null || value === void 0 || value === false ? value : `${prefix}${String(value)}${suffix}`;
68
+ }
69
+ /** Returns a style with custom properties before an element's own style. */
70
+ function vars(variables, own) {
71
+ const parts = [];
72
+ for (const [name, value] of Object.entries(variables)) if (value !== null && value !== void 0 && value !== false) parts.push(`${name}:${String(value)}`);
73
+ const rest = own === null || own === void 0 || own === false ? "" : styleValue(own);
74
+ if (rest) parts.push(rest);
75
+ return parts.join(";");
76
+ }
77
+ /** Returns a `<style>` element for a component's stylesheet. */
78
+ function styleElement(id, css) {
79
+ return `<style data-brm="${escapeAttribute(id)}">${css.replace(/<\/style/gi, "<\\/style")}</style>`;
80
+ }
81
+ /** Renders an object of attributes. */
82
+ function spread(attributes) {
83
+ let result = "";
84
+ for (const [name, value] of Object.entries(attributes)) if (name !== "children" && !/^on[A-Z]/.test(name)) result += attribute(name, value);
85
+ return result;
86
+ }
87
+ const VOID_ELEMENTS = /* @__PURE__ */ new Set([
88
+ "area",
89
+ "base",
90
+ "br",
91
+ "col",
92
+ "embed",
93
+ "hr",
94
+ "img",
95
+ "input",
96
+ "link",
97
+ "meta",
98
+ "source",
99
+ "track",
100
+ "wbr"
101
+ ]);
102
+ /**
103
+ * Renders the attributes of a form that posts to a server function, such as
104
+ * ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
105
+ * the method attribute to add, if the element has none.
106
+ */
107
+ function actionAttributes(prefix, name, id, method, result) {
108
+ const methodText = method ? ` ${method}="post"` : "";
109
+ if (result !== void 0) return ` ${name}="?__action=${encodeURIComponent(id)}"${methodText} data-action="${escapeAttribute(id)}" data-result="${escapeAttribute(result)}"`;
110
+ return ` ${name}="${escapeAttribute(`${prefix}/${encodeURIComponent(id)}`)}"${methodText}`;
111
+ }
112
+ //#endregion
113
+ export { attributeText as a, insertValue as c, rawHTML as d, spread as f, attribute as i, isRaw as l, vars as m, actionAttributes as n, escape as o, styleElement as p, affix as r, escapeAttribute as s, VOID_ELEMENTS as t, raw as u };
114
+
115
+ //# sourceMappingURL=html-CxWpXngy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-CxWpXngy.js","names":[],"sources":["../src/runtime/html.ts"],"sourcesContent":["// HTML string helpers that the server and the client both use.\n\nconst RAW: unique symbol = Symbol.for('brumate.raw');\n\n/** HTML that is inserted as it is, such as the output of a template. */\nexport interface Raw {\n [RAW]: string;\n}\n\nexport function raw(html: string): Raw {\n return { [RAW]: html };\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && RAW in value;\n}\n\nexport function rawHTML(value: Raw): string {\n return value[RAW];\n}\n\nconst ESCAPES: Record<string, string> = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;' };\n\nexport function escape(value: string): string {\n return value.replace(/[&<>]/g, (char) => ESCAPES[char]!);\n}\n\nexport function escapeAttribute(value: string): string {\n return value.replace(/[&<\"]/g, (char) => ESCAPES[char]!);\n}\n\n/** Renders a value inserted in markup. Promises are not awaited. */\nexport function insertValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n if (value === null || value === undefined || typeof value === 'boolean') {\n return '';\n }\n if (Array.isArray(value)) {\n return value.map(insertValue).join('');\n }\n return escape(String(value));\n}\n\nfunction toKebabCase(name: string): string {\n return name.startsWith('--') ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nfunction classValue(value: unknown): string {\n if (Array.isArray(value)) {\n return value.map(classValue).filter(Boolean).join(' ');\n }\n if (typeof value === 'object' && value !== null) {\n return Object.entries(value)\n .filter(([, enabled]) => enabled)\n .map(([name]) => name)\n .join(' ');\n }\n return value ? String(value) : '';\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === 'object' && value !== null) {\n return Object.entries(value)\n .filter(([, item]) => item !== null && item !== undefined && item !== false)\n .map(([name, item]) => `${toKebabCase(name)}:${String(item)}`)\n .join(';');\n }\n return String(value);\n}\n\n/**\n * Returns the text of an attribute, or undefined if the attribute is not\n * rendered. `true` renders as an empty value.\n */\nexport function attributeText(name: string, value: unknown): string | undefined {\n if (value === null || value === undefined || value === false || typeof value === 'function') {\n return undefined;\n }\n if (value === true) {\n return '';\n }\n if (name === 'class') {\n const text = classValue(value);\n return text === '' ? undefined : text;\n }\n return name === 'style' ? styleValue(value) : String(value);\n}\n\n/** Renders one attribute, with a leading space. */\nexport function attribute(name: string, value: unknown): string {\n const text = attributeText(name, value);\n if (text === undefined) {\n return '';\n }\n return value === true ? ` ${name}` : ` ${name}=\"${escapeAttribute(text)}\"`;\n}\n\n/**\n * Returns the value of a style variable with text around it, such as `12px`\n * for `${size}px`. A value that sets no variable stays as it is.\n */\nexport function affix(prefix: string, value: unknown, suffix: string): unknown {\n return value === null || value === undefined || value === false\n ? value\n : `${prefix}${String(value)}${suffix}`;\n}\n\n/** Returns a style with custom properties before an element's own style. */\nexport function vars(variables: Record<string, unknown>, own: unknown): string {\n const parts: string[] = [];\n for (const [name, value] of Object.entries(variables)) {\n if (value !== null && value !== undefined && value !== false) {\n parts.push(`${name}:${String(value)}`);\n }\n }\n const rest = own === null || own === undefined || own === false ? '' : styleValue(own);\n if (rest) {\n parts.push(rest);\n }\n return parts.join(';');\n}\n\n/** Returns a `<style>` element for a component's stylesheet. */\nexport function styleElement(id: string, css: string): string {\n return `<style data-brm=\"${escapeAttribute(id)}\">${css.replace(/<\\/style/gi, '<\\\\/style')}</style>`;\n}\n\n/** Renders an object of attributes. */\nexport function spread(attributes: Record<string, unknown>): string {\n let result = '';\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== 'children' && !/^on[A-Z]/.test(name)) {\n result += attribute(name, value);\n }\n }\n return result;\n}\n\nexport const VOID_ELEMENTS: Set<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Renders the attributes of a form that posts to a server function, such as\n * ` action=\"/_brumate/App_1abc%23save\" method=\"post\"`. `method` is the name of\n * the method attribute to add, if the element has none.\n */\nexport function actionAttributes(\n prefix: string,\n name: string,\n id: string,\n method?: string,\n result?: string,\n): string {\n const methodText = method ? ` ${method}=\"post\"` : '';\n if (result !== undefined) {\n // The form posts to its page, which renders with the result. With the\n // loader, the result is written into the `$action` at `result` instead.\n return ` ${name}=\"?__action=${encodeURIComponent(id)}\"${methodText} data-action=\"${escapeAttribute(id)}\" data-result=\"${escapeAttribute(result)}\"`;\n }\n const url = `${prefix}/${encodeURIComponent(id)}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText}`;\n}\n"],"mappings":";AAEA,MAAM,MAAqB,OAAO,IAAI,aAAa;AAOnD,SAAgB,IAAI,MAAmB;CACrC,OAAO,GAAG,MAAM,KAAK;AACvB;AAEA,SAAgB,MAAM,OAA8B;CAClD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO;AAC/D;AAEA,SAAgB,QAAQ,OAAoB;CAC1C,OAAO,MAAM;AACf;AAEA,MAAM,UAAkC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;AAAS;AAEhG,SAAgB,OAAO,OAAuB;CAC5C,OAAO,MAAM,QAAQ,WAAW,SAAS,QAAQ,KAAM;AACzD;AAEA,SAAgB,gBAAgB,OAAuB;CACrD,OAAO,MAAM,QAAQ,WAAW,SAAS,QAAQ,KAAM;AACzD;;AAGA,SAAgB,YAAY,OAAwB;CAClD,IAAI,MAAM,KAAK,GACb,OAAO,MAAM;CAEf,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,OAAO,UAAU,WAC5D,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,WAAW,CAAC,CAAC,KAAK,EAAE;CAEvC,OAAO,OAAO,OAAO,KAAK,CAAC;AAC7B;AAEA,SAAS,YAAY,MAAsB;CACzC,O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,GAAG,mBAAmB,EAAE,GACP,EAAE,GAAG;AAC9C"}
@@ -0,0 +1,41 @@
1
+ //#region src/runtime/html.d.ts
2
+ declare const RAW: unique symbol;
3
+ /** HTML that is inserted as it is, such as the output of a template. */
4
+ interface Raw {
5
+ [RAW]: string;
6
+ }
7
+ declare function raw(html: string): Raw;
8
+ declare function isRaw(value: unknown): value is Raw;
9
+ declare function rawHTML(value: Raw): string;
10
+ declare function escape(value: string): string;
11
+ declare function escapeAttribute(value: string): string;
12
+ /** Renders a value inserted in markup. Promises are not awaited. */
13
+ declare function insertValue(value: unknown): string;
14
+ /**
15
+ * Returns the text of an attribute, or undefined if the attribute is not
16
+ * rendered. `true` renders as an empty value.
17
+ */
18
+ declare function attributeText(name: string, value: unknown): string | undefined;
19
+ /** Renders one attribute, with a leading space. */
20
+ declare function attribute(name: string, value: unknown): string;
21
+ /**
22
+ * Returns the value of a style variable with text around it, such as `12px`
23
+ * for `${size}px`. A value that sets no variable stays as it is.
24
+ */
25
+ declare function affix(prefix: string, value: unknown, suffix: string): unknown;
26
+ /** Returns a style with custom properties before an element's own style. */
27
+ declare function vars(variables: Record<string, unknown>, own: unknown): string;
28
+ /** Returns a `<style>` element for a component's stylesheet. */
29
+ declare function styleElement(id: string, css: string): string;
30
+ /** Renders an object of attributes. */
31
+ declare function spread(attributes: Record<string, unknown>): string;
32
+ declare const VOID_ELEMENTS: Set<string>;
33
+ /**
34
+ * Renders the attributes of a form that posts to a server function, such as
35
+ * ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
36
+ * the method attribute to add, if the element has none.
37
+ */
38
+ declare function actionAttributes(prefix: string, name: string, id: string, method?: string, result?: string): string;
39
+ //#endregion
40
+ export { attribute as a, escapeAttribute as c, raw as d, rawHTML as f, vars as h, affix as i, insertValue as l, styleElement as m, VOID_ELEMENTS as n, attributeText as o, spread as p, actionAttributes as r, escape as s, Raw as t, isRaw as u };
41
+ //# sourceMappingURL=html-DV-Tezgq.d.ts.map