brumate 0.2.0 → 0.4.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/README.md +2 -2
- package/check.d.ts +49 -0
- package/dist/{boot-D-IdPy7B.d.ts → boot-DLlRmD9z.d.ts} +11 -10
- package/dist/cli.js +275 -15
- package/dist/cli.js.map +1 -1
- package/dist/client-BvDsC6Qr.js +3463 -0
- package/dist/client-BvDsC6Qr.js.map +1 -0
- package/dist/client-DBwL2wKQ.d.ts +669 -0
- package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
- package/dist/client-routes-BtGpYCef.js.map +1 -0
- package/dist/{cookies-Av5WFmcf.js → cookies-Cnbf4w-S.js} +15 -7
- package/dist/cookies-Cnbf4w-S.js.map +1 -0
- package/dist/{defer-D0bo1Gqx.js → defer-CKWZLv2K.js} +8 -4
- package/dist/defer-CKWZLv2K.js.map +1 -0
- package/dist/devtools-4uTPwR_v.js +597 -0
- package/dist/devtools-4uTPwR_v.js.map +1 -0
- package/dist/devtools-panel-Be9pxYgv.js +1994 -0
- package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
- package/dist/events-LgLdp1R7.js +114 -0
- package/dist/events-LgLdp1R7.js.map +1 -0
- package/dist/features-CHY5Ekku.js +30 -0
- package/dist/features-CHY5Ekku.js.map +1 -0
- package/dist/files-WW4RlajL.js +506 -0
- package/dist/files-WW4RlajL.js.map +1 -0
- package/dist/forms-j1xPAR14.d.ts +281 -0
- package/dist/forms-nXK7-Lv_.js +440 -0
- package/dist/forms-nXK7-Lv_.js.map +1 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +278 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-BtKRyi7g.js +305 -0
- package/dist/html-BtKRyi7g.js.map +1 -0
- package/dist/html-Bw9Qwu6F.d.ts +107 -0
- package/dist/index.d.ts +142 -11
- package/dist/index.js +641 -106
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BJtACnQp.js → inspect-Y6y4uNZp.js} +4333 -681
- package/dist/inspect-Y6y4uNZp.js.map +1 -0
- package/dist/{loader-B18i3_-T.js → loader-BjKGJzLN.js} +21 -14
- package/dist/loader-BjKGJzLN.js.map +1 -0
- package/dist/logo-DQ_OYhBi.js +10 -0
- package/dist/logo-DQ_OYhBi.js.map +1 -0
- package/dist/{navigate-BwuZveDF.js → navigate-CfOr-TRF.js} +130 -24
- package/dist/navigate-CfOr-TRF.js.map +1 -0
- package/dist/nesting-DA5vJw9X.js +265 -0
- package/dist/nesting-DA5vJw9X.js.map +1 -0
- package/dist/produce-B7X9ori9.js +402 -0
- package/dist/produce-B7X9ori9.js.map +1 -0
- package/dist/produce-DIgHBVwL.d.ts +148 -0
- package/dist/{rpc-B-Zkn6Ch.js → rpc-Q-XkLwFh.js} +28 -13
- package/dist/rpc-Q-XkLwFh.js.map +1 -0
- package/dist/runtime/batch.js +9 -7
- package/dist/runtime/batch.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +172 -5
- package/dist/runtime/devtools.js +3 -1
- package/dist/runtime/env.js +14 -2
- package/dist/runtime/env.js.map +1 -1
- package/dist/runtime/events.d.ts +38 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/hot.js +5 -2
- package/dist/runtime/hot.js.map +1 -1
- package/dist/runtime/html.d.ts +2 -2
- 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/routes.js +4 -1
- package/dist/runtime/routes.js.map +1 -1
- package/dist/runtime/server.d.ts +5 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +75 -2
- package/dist/runtime/signals.js +44 -2
- 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/testing.d.ts +18 -3
- package/dist/runtime/testing.js +150 -33
- package/dist/runtime/testing.js.map +1 -1
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/{server-BA9SJ2Vm.d.ts → server-BvPIg9pT.d.ts} +363 -32
- package/dist/{server-BqfM95r1.js → server-DjyOVJtJ.js} +1309 -220
- package/dist/server-DjyOVJtJ.js.map +1 -0
- package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
- package/dist/static-loader-BZR17hSw.js +312 -0
- package/dist/static-loader-BZR17hSw.js.map +1 -0
- package/dist/{stream-JaMHMdBD.js → stream-BP5AVmg5.js} +182 -17
- package/dist/stream-BP5AVmg5.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +20 -20
- package/dist/vite.js +2031 -539
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +951 -0
- package/forms/forms.brm.ts +141 -0
- package/package.json +41 -3
- package/skills/brumate/SKILL.md +58 -0
- package/skills/brumate/references/errors.md +2078 -0
- package/skills/brumate/references/events.md +117 -0
- package/skills/brumate/references/signals.md +61 -0
- package/skills/brumate/references/state.md +235 -0
- package/skills/brumate/references/syntax.md +250 -0
- package/types.d.ts +4 -4
- package/dist/client-C0UCNL3J.js +0 -1643
- package/dist/client-C0UCNL3J.js.map +0 -1
- package/dist/client-MD0ZmcFR.d.ts +0 -354
- package/dist/client-routes-JTbGtukf.js.map +0 -1
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/defer-D0bo1Gqx.js.map +0 -1
- package/dist/devtools-C50VH8gZ.js +0 -113
- package/dist/devtools-C50VH8gZ.js.map +0 -1
- package/dist/devtools-panel-AYjfwPhj.js +0 -435
- package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
- package/dist/events-BKWRqtMg.js +0 -52
- package/dist/events-BKWRqtMg.js.map +0 -1
- package/dist/files-Bnn1JqHx.js +0 -192
- package/dist/files-Bnn1JqHx.js.map +0 -1
- package/dist/html-bHZbkK-h.js +0 -170
- package/dist/html-bHZbkK-h.js.map +0 -1
- package/dist/html-y1q7-t7D.d.ts +0 -60
- package/dist/inspect-BJtACnQp.js.map +0 -1
- package/dist/loader-B18i3_-T.js.map +0 -1
- package/dist/navigate-BwuZveDF.js.map +0 -1
- package/dist/produce-CWfJ4byV.js +0 -167
- package/dist/produce-CWfJ4byV.js.map +0 -1
- package/dist/produce-D4K7qpaL.d.ts +0 -72
- package/dist/rpc-B-Zkn6Ch.js.map +0 -1
- package/dist/server-BqfM95r1.js.map +0 -1
- package/dist/static-loader-DOygOFj5.js +0 -216
- package/dist/static-loader-DOygOFj5.js.map +0 -1
- package/dist/stream-JaMHMdBD.js.map +0 -1
package/dist/files-Bnn1JqHx.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { g as functionId } from "./inspect-BJtACnQp.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
|
-
functions.delete(MIDDLEWARE);
|
|
58
|
-
return [...functions];
|
|
59
|
-
}
|
|
60
|
-
/** The export of a file of server functions that runs before each of them. */
|
|
61
|
-
const MIDDLEWARE = "middleware";
|
|
62
|
-
/** True if a file of server functions exports `middleware`. */
|
|
63
|
-
function hasServerMiddleware(source, filename) {
|
|
64
|
-
const { program } = parseSync(filename, source, { lang: "ts" });
|
|
65
|
-
for (const statement of program.body) {
|
|
66
|
-
if (statement.type !== "ExportNamedDeclaration" || statement.exportKind === "type") continue;
|
|
67
|
-
const declaration = statement.declaration;
|
|
68
|
-
if (declaration?.type === "FunctionDeclaration" && declaration.id?.name === "middleware") return true;
|
|
69
|
-
if (declaration?.type === "VariableDeclaration" && declaration.declarations.some((declarator) => declarator.id.type === "Identifier" && declarator.id.name === "middleware")) return true;
|
|
70
|
-
if (statement.specifiers.some((specifier) => specifier.exportKind !== "type" && (specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value) === "middleware")) return true;
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
/** The module that the browser gets in place of a file of server functions. */
|
|
75
|
-
function serverStubs(source, filename, id, hideNames = false) {
|
|
76
|
-
const lines = [`import { rpc } from ${JSON.stringify(CLIENT)};`];
|
|
77
|
-
for (const name of serverExports(source, filename)) {
|
|
78
|
-
const call = `(...args) => rpc(${JSON.stringify(functionId(id, name, hideNames))}, args)`;
|
|
79
|
-
lines.push(name === "default" ? `export default ${call};` : `export const ${name} = ${call};`);
|
|
80
|
-
}
|
|
81
|
-
return `${lines.join("\n")}\n`;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* The module that the server runs for a file of server functions: the file,
|
|
85
|
-
* with each exported function wrapped, so its calls while a page renders
|
|
86
|
-
* share a result when their arguments are the same. Offsets stay the same.
|
|
87
|
-
*/
|
|
88
|
-
function serverModule(source, filename, id) {
|
|
89
|
-
const { program } = parseSync(filename, source, { lang: "ts" });
|
|
90
|
-
const wrapped = /* @__PURE__ */ new Map();
|
|
91
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
92
|
-
let code = source;
|
|
93
|
-
for (const statement of program.body) {
|
|
94
|
-
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
95
|
-
if (declaration?.type === "FunctionDeclaration" && declaration.id) declarations.set(declaration.id.name, "function");
|
|
96
|
-
else if (declaration?.type === "VariableDeclaration") {
|
|
97
|
-
for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier" && isFunction(declarator.init)) declarations.set(declarator.id.name, "const");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const letOf = (declaration) => {
|
|
101
|
-
if (declaration.kind === "const") code = `${code.slice(0, declaration.start)}let ${code.slice(declaration.start + 5)}`;
|
|
102
|
-
};
|
|
103
|
-
for (const statement of program.body) {
|
|
104
|
-
if (statement.type !== "ExportNamedDeclaration" || statement.source || statement.exportKind === "type") continue;
|
|
105
|
-
const declaration = statement.declaration;
|
|
106
|
-
if (declaration?.type === "FunctionDeclaration" && declaration.id) wrapped.set(declaration.id.name, declaration.id.name);
|
|
107
|
-
else if (declaration?.type === "VariableDeclaration") {
|
|
108
|
-
for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier" && isFunction(declarator.init)) {
|
|
109
|
-
wrapped.set(declarator.id.name, declarator.id.name);
|
|
110
|
-
letOf(declaration);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
for (const specifier of statement.specifiers) {
|
|
114
|
-
const local = specifier.local.type === "Identifier" ? specifier.local.name : "";
|
|
115
|
-
const exported = specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value;
|
|
116
|
-
if (declarations.has(local)) wrapped.set(local, exported);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (const statement of program.body) if (statement.type === "VariableDeclaration") {
|
|
120
|
-
for (const declarator of statement.declarations) if (declarator.id.type === "Identifier" && wrapped.has(declarator.id.name)) letOf(statement);
|
|
121
|
-
}
|
|
122
|
-
if (wrapped.size === 0) return source;
|
|
123
|
-
const lines = ["import { dedupe as __brumateDedupe } from 'brumate/server';"];
|
|
124
|
-
for (const [local, exported] of wrapped) lines.push(`${local} = __brumateDedupe(${local}, ${JSON.stringify(`${id}#${exported}`)});`);
|
|
125
|
-
return `${code}\n${lines.join("\n")}\n`;
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/files.ts
|
|
129
|
-
/** Skips `node_modules`, `dist` and hidden directories when looking for `.brm` files. */
|
|
130
|
-
function defaultExclude(directory) {
|
|
131
|
-
return directory === "node_modules" || directory === "dist" || directory.startsWith(".");
|
|
132
|
-
}
|
|
133
|
-
/** Finds every `.brm` file under a directory, as absolute paths with forward slashes. */
|
|
134
|
-
async function findFiles(root, exclude) {
|
|
135
|
-
const result = [];
|
|
136
|
-
const visit = async (directory) => {
|
|
137
|
-
const directories = [];
|
|
138
|
-
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
139
|
-
const file = path.join(directory, entry.name);
|
|
140
|
-
if (entry.isDirectory()) {
|
|
141
|
-
if (!exclude(entry.name)) directories.push(visit(file));
|
|
142
|
-
} else if (entry.name.endsWith(".brm")) result.push(file.split(path.sep).join("/"));
|
|
143
|
-
}
|
|
144
|
-
await Promise.all(directories);
|
|
145
|
-
};
|
|
146
|
-
await visit(root);
|
|
147
|
-
return result.toSorted();
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Finds every file of server functions under a directory: a script whose
|
|
151
|
-
* first statement is `'use server'`.
|
|
152
|
-
*/
|
|
153
|
-
async function findServerFiles(root, exclude) {
|
|
154
|
-
const result = [];
|
|
155
|
-
const visit = async (directory) => {
|
|
156
|
-
const pending = [];
|
|
157
|
-
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
158
|
-
const file = path.join(directory, entry.name);
|
|
159
|
-
if (entry.isDirectory()) {
|
|
160
|
-
if (!exclude(entry.name)) pending.push(visit(file));
|
|
161
|
-
} else if (isScriptFile(entry.name)) pending.push(readFile(file, "utf8").then((source) => {
|
|
162
|
-
if (hasUseServer(source)) result.push(file.split(path.sep).join("/"));
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
await Promise.all(pending);
|
|
166
|
-
};
|
|
167
|
-
await visit(root);
|
|
168
|
-
return result.toSorted();
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Finds every script under a directory, such as `.ts` and `.brm.ts` files, as
|
|
172
|
-
* absolute paths with forward slashes, without reading them.
|
|
173
|
-
*/
|
|
174
|
-
async function findScripts(root, exclude) {
|
|
175
|
-
const result = [];
|
|
176
|
-
const visit = async (directory) => {
|
|
177
|
-
const directories = [];
|
|
178
|
-
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
179
|
-
const file = path.join(directory, entry.name);
|
|
180
|
-
if (entry.isDirectory()) {
|
|
181
|
-
if (!exclude(entry.name)) directories.push(visit(file));
|
|
182
|
-
} else if (/\.[cm]?[jt]sx?$/.test(entry.name) && !entry.name.endsWith(".d.ts")) result.push(file.split(path.sep).join("/"));
|
|
183
|
-
}
|
|
184
|
-
await Promise.all(directories);
|
|
185
|
-
};
|
|
186
|
-
await visit(root);
|
|
187
|
-
return result.toSorted();
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
|
-
export { hasServerMiddleware as a, serverExports as c, findServerFiles as i, serverModule as l, findFiles as n, hasUseServer as o, findScripts as r, isScriptFile as s, defaultExclude as t, serverStubs as u };
|
|
191
|
-
|
|
192
|
-
//# sourceMappingURL=files-Bnn1JqHx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files-Bnn1JqHx.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 // The middleware of the file runs before its functions. The browser cannot call it.\n functions.delete(MIDDLEWARE);\n return [...functions];\n}\n\n/** The export of a file of server functions that runs before each of them. */\nexport const MIDDLEWARE = 'middleware';\n\n/** True if a file of server functions exports `middleware`. */\nexport function hasServerMiddleware(source: string, filename: string): boolean {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n for (const statement of program.body) {\n if (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id?.name === MIDDLEWARE) {\n return true;\n }\n if (\n declaration?.type === 'VariableDeclaration' &&\n declaration.declarations.some(\n (declarator) => declarator.id.type === 'Identifier' && declarator.id.name === MIDDLEWARE,\n )\n ) {\n return true;\n }\n if (\n statement.specifiers.some(\n (specifier) =>\n specifier.exportKind !== 'type' &&\n (specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value) === MIDDLEWARE,\n )\n ) {\n return true;\n }\n }\n return false;\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\n/**\n * Finds every script under a directory, such as `.ts` and `.brm.ts` files, as\n * absolute paths with forward slashes, without reading them.\n */\nexport async function findScripts(\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 (/\\.[cm]?[jt]sx?$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {\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"],"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,K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I;GAC5C,IAAI,MAAM,YAAY,GAChB;QAAA,CAAC,QAAQ,MAAM,IAAI,GACrB,YAAY,KAAK,MAAM,IAAI,CAAC;GAAA,OAEzB,IAAI,kBAAkB,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,OAAO,GAC3E,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"}
|
package/dist/html-bHZbkK-h.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/html.ts
|
|
2
|
-
const RAW = Symbol.for("brumate.raw");
|
|
3
|
-
var RawHTML = class {
|
|
4
|
-
[RAW];
|
|
5
|
-
constructor(html) {
|
|
6
|
-
this[RAW] = html;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
function raw(html) {
|
|
10
|
-
return new RawHTML(html);
|
|
11
|
-
}
|
|
12
|
-
function isRaw(value) {
|
|
13
|
-
return typeof value === "object" && value !== null && RAW in value;
|
|
14
|
-
}
|
|
15
|
-
function rawHTML(value) {
|
|
16
|
-
return value[RAW];
|
|
17
|
-
}
|
|
18
|
-
const ESCAPES = {
|
|
19
|
-
"&": "&",
|
|
20
|
-
"<": "<",
|
|
21
|
-
">": ">",
|
|
22
|
-
"\"": """
|
|
23
|
-
};
|
|
24
|
-
const toEscape = (char) => ESCAPES[char];
|
|
25
|
-
function escape(value) {
|
|
26
|
-
return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;
|
|
27
|
-
}
|
|
28
|
-
function escapeAttribute(value) {
|
|
29
|
-
return /[&<"]/.test(value) ? value.replace(/[&<"]/g, toEscape) : value;
|
|
30
|
-
}
|
|
31
|
-
/** Renders a value inserted in markup. Promises are not awaited. */
|
|
32
|
-
function insertValue(value) {
|
|
33
|
-
if (isRaw(value)) return value[RAW];
|
|
34
|
-
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
35
|
-
if (Array.isArray(value)) return value.map(insertValue).join("");
|
|
36
|
-
return escape(String(value));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Renders a value as the text of an element whose content is text, such as
|
|
40
|
-
* a `<textarea>`, as `insertValue` does but without escaping.
|
|
41
|
-
*/
|
|
42
|
-
function textValue(value) {
|
|
43
|
-
if (isRaw(value)) return value[RAW];
|
|
44
|
-
if (value === null || value === void 0 || typeof value === "boolean") return "";
|
|
45
|
-
if (Array.isArray(value)) return value.map(textValue).join("");
|
|
46
|
-
return String(value);
|
|
47
|
-
}
|
|
48
|
-
function toKebabCase(name) {
|
|
49
|
-
return name.startsWith("--") ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
50
|
-
}
|
|
51
|
-
function classValue(value) {
|
|
52
|
-
if (typeof value !== "object" || value === null) return value ? String(value) : "";
|
|
53
|
-
let text = "";
|
|
54
|
-
if (Array.isArray(value)) {
|
|
55
|
-
for (const item of value) {
|
|
56
|
-
const part = classValue(item);
|
|
57
|
-
if (part !== "") text = text === "" ? part : `${text} ${part}`;
|
|
58
|
-
}
|
|
59
|
-
return text;
|
|
60
|
-
}
|
|
61
|
-
let first = true;
|
|
62
|
-
for (const name in value) if (Object.hasOwn(value, name) && value[name]) {
|
|
63
|
-
text = first ? name : `${text} ${name}`;
|
|
64
|
-
first = false;
|
|
65
|
-
}
|
|
66
|
-
return text;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Renders a `class` attribute from classes that each have a space before
|
|
70
|
-
* them, which the compiler builds from a literal class value. The classes
|
|
71
|
-
* are escaped already. No class renders nothing.
|
|
72
|
-
*/
|
|
73
|
-
function classAttribute(classes) {
|
|
74
|
-
return classes === "" ? "" : ` class="${classes.slice(1)}"`;
|
|
75
|
-
}
|
|
76
|
-
function styleValue(value) {
|
|
77
|
-
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(";");
|
|
78
|
-
return String(value);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the text of an attribute, or undefined if the attribute is not
|
|
82
|
-
* rendered. `true` renders as an empty value.
|
|
83
|
-
*/
|
|
84
|
-
function attributeText(name, value) {
|
|
85
|
-
if (value === null || value === void 0 || value === false || typeof value === "function") return;
|
|
86
|
-
if (value === true) return "";
|
|
87
|
-
if (name === "class") {
|
|
88
|
-
const text = classValue(value);
|
|
89
|
-
return text === "" ? void 0 : text;
|
|
90
|
-
}
|
|
91
|
-
return name === "style" ? styleValue(value) : String(value);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* A name that HTML reads as one attribute. A spread takes its names from
|
|
95
|
-
* data, so a name with a space, a quote, `>`, `/` or `=` could write other
|
|
96
|
-
* attributes or markup.
|
|
97
|
-
*/
|
|
98
|
-
const ATTRIBUTE_NAME = /^[^\s"'>/=\x00-\x1f\x7f]+$/;
|
|
99
|
-
/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */
|
|
100
|
-
function attribute(name, value) {
|
|
101
|
-
const text = attributeText(name, value);
|
|
102
|
-
if (text === void 0 || !ATTRIBUTE_NAME.test(name)) return "";
|
|
103
|
-
return value === true ? ` ${name}` : ` ${name}="${escapeAttribute(text)}"`;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns the value of a style variable with text around it, such as `12px`
|
|
107
|
-
* for `${size}px`. A value that sets no variable stays as it is.
|
|
108
|
-
*/
|
|
109
|
-
function affix(prefix, value, suffix) {
|
|
110
|
-
return value === null || value === void 0 || value === false ? value : `${prefix}${String(value)}${suffix}`;
|
|
111
|
-
}
|
|
112
|
-
/** Returns a style with custom properties before an element's own style. */
|
|
113
|
-
function vars(variables, own) {
|
|
114
|
-
const parts = [];
|
|
115
|
-
for (const [name, value] of Object.entries(variables)) if (value !== null && value !== void 0 && value !== false) parts.push(`${name}:${String(value)}`);
|
|
116
|
-
const rest = own === null || own === void 0 || own === false ? "" : styleValue(own);
|
|
117
|
-
if (rest) parts.push(rest);
|
|
118
|
-
return parts.join(";");
|
|
119
|
-
}
|
|
120
|
-
/** Returns a `<style>` element for a component's stylesheet. */
|
|
121
|
-
function styleElement(id, css) {
|
|
122
|
-
return `<style b-style="${escapeAttribute(id)}">${css.replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Merges the attributes of an element that has spreads, in their order: a
|
|
126
|
-
* later value wins, except `class`, whose values all apply.
|
|
127
|
-
*/
|
|
128
|
-
function mergeAttributes(parts) {
|
|
129
|
-
const result = {};
|
|
130
|
-
for (const part of parts) for (const [name, value] of Object.entries(part ?? {})) result[name] = name === "class" && result.class !== void 0 && value !== void 0 ? [result.class, value] : value;
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
/** Renders an object of attributes. */
|
|
134
|
-
function spread(attributes) {
|
|
135
|
-
let result = "";
|
|
136
|
-
for (const [name, value] of Object.entries(attributes)) if (name !== "children" && !/^on[A-Z]/.test(name)) result += attribute(name, value);
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
const VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
140
|
-
"area",
|
|
141
|
-
"base",
|
|
142
|
-
"br",
|
|
143
|
-
"col",
|
|
144
|
-
"embed",
|
|
145
|
-
"hr",
|
|
146
|
-
"img",
|
|
147
|
-
"input",
|
|
148
|
-
"link",
|
|
149
|
-
"meta",
|
|
150
|
-
"source",
|
|
151
|
-
"track",
|
|
152
|
-
"wbr"
|
|
153
|
-
]);
|
|
154
|
-
/**
|
|
155
|
-
* Renders the attributes of a form that posts to a server function, such as
|
|
156
|
-
* ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
|
|
157
|
-
* the method attribute to add, if the element has none. `build` is the ID
|
|
158
|
-
* of the build of the page, which the URL carries as `__build`, so the
|
|
159
|
-
* server can tell a post from before a deploy without scripts.
|
|
160
|
-
*/
|
|
161
|
-
function actionAttributes(prefix, name, id, method, result, build) {
|
|
162
|
-
const methodText = method ? ` ${method}="post"` : "";
|
|
163
|
-
const query = build === void 0 ? "" : `__build=${encodeURIComponent(build)}`;
|
|
164
|
-
if (result !== void 0) return ` ${name}="${escapeAttribute(`?__action=${encodeURIComponent(id)}${query ? `&${query}` : ""}`)}"${methodText} b-action="${escapeAttribute(id)}" b-result="${escapeAttribute(result)}"`;
|
|
165
|
-
return ` ${name}="${escapeAttribute(`${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ""}`)}"${methodText}`;
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
export { textValue as _, attributeText as a, escape as c, isRaw as d, mergeAttributes as f, styleElement as g, spread as h, attribute as i, escapeAttribute as l, rawHTML as m, actionAttributes as n, classAttribute as o, raw as p, affix as r, classValue as s, VOID_ELEMENTS as t, insertValue as u, vars as v };
|
|
169
|
-
|
|
170
|
-
//# sourceMappingURL=html-bHZbkK-h.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-bHZbkK-h.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\n// A class, not an object literal, so serializers can skip their test for raw HTML on plain objects.\nclass RawHTML implements Raw {\n readonly [RAW]: string;\n\n constructor(html: string) {\n this[RAW] = html;\n }\n}\n\nexport function raw(html: string): Raw {\n return new RawHTML(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> = { '&': '&', '<': '<', '>': '>', '\"': '"' };\n\nconst toEscape = (char: string): string => ESCAPES[char]!;\n\n// Most text has nothing to escape, so a test without the global flag skips the replace.\nexport function escape(value: string): string {\n return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;\n}\n\nexport function escapeAttribute(value: string): string {\n return /[&<\"]/.test(value) ? value.replace(/[&<\"]/g, toEscape) : value;\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\n/**\n * Renders a value as the text of an element whose content is text, such as\n * a `<textarea>`, as `insertValue` does but without escaping.\n */\nexport function textValue(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(textValue).join('');\n }\n return String(value);\n}\n\nfunction toKebabCase(name: string): string {\n return name.startsWith('--') ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nexport function classValue(value: unknown): string {\n if (typeof value !== 'object' || value === null) {\n return value ? String(value) : '';\n }\n let text = '';\n if (Array.isArray(value)) {\n for (const item of value) {\n const part = classValue(item);\n if (part !== '') {\n text = text === '' ? part : `${text} ${part}`;\n }\n }\n return text;\n }\n // An empty name still adds a space between its neighbours, as in a join.\n let first = true;\n for (const name in value) {\n if (Object.hasOwn(value, name) && (value as Record<string, unknown>)[name]) {\n text = first ? name : `${text} ${name}`;\n first = false;\n }\n }\n return text;\n}\n\n/**\n * Renders a `class` attribute from classes that each have a space before\n * them, which the compiler builds from a literal class value. The classes\n * are escaped already. No class renders nothing.\n */\nexport function classAttribute(classes: string): string {\n return classes === '' ? '' : ` class=\"${classes.slice(1)}\"`;\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/**\n * A name that HTML reads as one attribute. A spread takes its names from\n * data, so a name with a space, a quote, `>`, `/` or `=` could write other\n * attributes or markup.\n */\n// oxlint-disable-next-line no-control-regex -- HTML reads no control character in a name.\nconst ATTRIBUTE_NAME = /^[^\\s\"'>/=\\x00-\\x1f\\x7f]+$/;\n\n/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */\nexport function attribute(name: string, value: unknown): string {\n const text = attributeText(name, value);\n if (text === undefined || !ATTRIBUTE_NAME.test(name)) {\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 b-style=\"${escapeAttribute(id)}\">${css.replace(/<\\/style/gi, '<\\\\/style')}</style>`;\n}\n\n/**\n * Merges the attributes of an element that has spreads, in their order: a\n * later value wins, except `class`, whose values all apply.\n */\nexport function mergeAttributes(parts: Record<string, unknown>[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const part of parts) {\n for (const [name, value] of Object.entries(part ?? {})) {\n result[name] =\n name === 'class' && result.class !== undefined && value !== undefined\n ? [result.class, value]\n : value;\n }\n }\n return result;\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. `build` is the ID\n * of the build of the page, which the URL carries as `__build`, so the\n * server can tell a post from before a deploy without scripts.\n */\nexport function actionAttributes(\n prefix: string,\n name: string,\n id: string,\n method?: string,\n result?: string,\n build?: string,\n): string {\n const methodText = method ? ` ${method}=\"post\"` : '';\n const query = build === undefined ? '' : `__build=${encodeURIComponent(build)}`;\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 const url = `?__action=${encodeURIComponent(id)}${query ? `&${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText} b-action=\"${escapeAttribute(id)}\" b-result=\"${escapeAttribute(result)}\"`;\n }\n const url = `${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText}`;\n}\n"],"mappings":";AAEA,MAAM,MAAqB,OAAO,IAAI,aAAa;AAQnD,IAAM,UAAN,MAA6B;CAC3B,CAAU;CA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K,IAAI,GAC9C,UAAU,UAAU,MAAM,KAAK;CAGnC,OAAO;AACT;AAEA,MAAa,gCAA6B,IAAI,IAAI;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;AASD,SAAgB,iBACd,QACA,MACA,IACA,QACA,QACA,OACQ;CACR,MAAM,aAAa,SAAS,IAAI,OAAO,WAAW;CAClD,MAAM,QAAQ,UAAU,KAAA,IAAY,KAAK,WAAW,mBAAmB,KAAK;CAC5E,IAAI,WAAW,KAAA,GAIb,OAAO,IAAI,KAAK,IAAI,gBAAgB,aADX,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG,WAAW,aAAa,gBAAgB,EAAE,EAAE,cAAc,gBAAgB,MAAM,EAAE;CAGhI,OAAO,IAAI,KAAK,IAAI,gBAAgB,GADrB,OAAO,GAAG,mBAAmB,EAAE,IAAI,QAAQ,IAAI,UAAU,IACjC,EAAE,GAAG;AAC9C"}
|
package/dist/html-y1q7-t7D.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
* Renders a value as the text of an element whose content is text, such as
|
|
16
|
-
* a `<textarea>`, as `insertValue` does but without escaping.
|
|
17
|
-
*/
|
|
18
|
-
declare function textValue(value: unknown): string;
|
|
19
|
-
declare function classValue(value: unknown): string;
|
|
20
|
-
/**
|
|
21
|
-
* Renders a `class` attribute from classes that each have a space before
|
|
22
|
-
* them, which the compiler builds from a literal class value. The classes
|
|
23
|
-
* are escaped already. No class renders nothing.
|
|
24
|
-
*/
|
|
25
|
-
declare function classAttribute(classes: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the text of an attribute, or undefined if the attribute is not
|
|
28
|
-
* rendered. `true` renders as an empty value.
|
|
29
|
-
*/
|
|
30
|
-
declare function attributeText(name: string, value: unknown): string | undefined;
|
|
31
|
-
/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */
|
|
32
|
-
declare function attribute(name: string, value: unknown): string;
|
|
33
|
-
/**
|
|
34
|
-
* Returns the value of a style variable with text around it, such as `12px`
|
|
35
|
-
* for `${size}px`. A value that sets no variable stays as it is.
|
|
36
|
-
*/
|
|
37
|
-
declare function affix(prefix: string, value: unknown, suffix: string): unknown;
|
|
38
|
-
/** Returns a style with custom properties before an element's own style. */
|
|
39
|
-
declare function vars(variables: Record<string, unknown>, own: unknown): string;
|
|
40
|
-
/** Returns a `<style>` element for a component's stylesheet. */
|
|
41
|
-
declare function styleElement(id: string, css: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Merges the attributes of an element that has spreads, in their order: a
|
|
44
|
-
* later value wins, except `class`, whose values all apply.
|
|
45
|
-
*/
|
|
46
|
-
declare function mergeAttributes(parts: Record<string, unknown>[]): Record<string, unknown>;
|
|
47
|
-
/** Renders an object of attributes. */
|
|
48
|
-
declare function spread(attributes: Record<string, unknown>): string;
|
|
49
|
-
declare const VOID_ELEMENTS: Set<string>;
|
|
50
|
-
/**
|
|
51
|
-
* Renders the attributes of a form that posts to a server function, such as
|
|
52
|
-
* ` action="/_brumate/App_1abc%23save" method="post"`. `method` is the name of
|
|
53
|
-
* the method attribute to add, if the element has none. `build` is the ID
|
|
54
|
-
* of the build of the page, which the URL carries as `__build`, so the
|
|
55
|
-
* server can tell a post from before a deploy without scripts.
|
|
56
|
-
*/
|
|
57
|
-
declare function actionAttributes(prefix: string, name: string, id: string, method?: string, result?: string, build?: string): string;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { styleElement as _, attribute as a, classValue as c, insertValue as d, isRaw as f, spread as g, rawHTML as h, affix as i, escape as l, raw as m, VOID_ELEMENTS as n, attributeText as o, mergeAttributes as p, actionAttributes as r, classAttribute as s, Raw as t, escapeAttribute as u, textValue as v, vars as y };
|
|
60
|
-
//# sourceMappingURL=html-y1q7-t7D.d.ts.map
|