brumate 0.0.1 → 0.1.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.
- package/README.md +43 -72
- package/dist/boot-DN1ZU8Hg.d.ts +37 -0
- package/dist/cli.js +2 -2
- package/dist/{client-DuDTDePF.d.ts → client-DwJInP_a.d.ts} +133 -44
- package/dist/client-routes-DakuM32C.js +94 -0
- package/dist/client-routes-DakuM32C.js.map +1 -0
- package/dist/{cookies-rgIAc8IE.js → cookies-Av5WFmcf.js} +18 -8
- package/dist/cookies-Av5WFmcf.js.map +1 -0
- package/dist/{devtools-Bm8cS7hX.js → devtools-BKjnHrnv.js} +10 -5
- package/dist/devtools-BKjnHrnv.js.map +1 -0
- package/dist/{devtools-panel-CTbDSBBA.js → devtools-panel-AWOn0VK2.js} +23 -26
- package/dist/devtools-panel-AWOn0VK2.js.map +1 -0
- package/dist/{files-D_JUcSU5.js → files-DdT84mPy.js} +22 -3
- package/dist/{files-D_JUcSU5.js.map → files-DdT84mPy.js.map} +1 -1
- package/dist/{html-CxWpXngy.js → html-DEeoepg3.js} +47 -10
- package/dist/html-DEeoepg3.js.map +1 -0
- package/dist/{html-DV-Tezgq.d.ts → html-Du8jY2Cc.d.ts} +14 -2
- package/dist/index.d.ts +65 -6
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/{inspect-CGCWfaEx.js → inspect-BPchdWbU.js} +887 -172
- package/dist/inspect-BPchdWbU.js.map +1 -0
- package/dist/loader-Dc9OwY5I.js +101 -0
- package/dist/loader-Dc9OwY5I.js.map +1 -0
- package/dist/{navigate-C5dP89YL.js → navigate-CzLjnoPH.js} +112 -59
- package/dist/navigate-CzLjnoPH.js.map +1 -0
- package/dist/{produce-BjQGMpqL.d.ts → produce-CtZ32UGG.d.ts} +13 -3
- package/dist/{rpc-B86KKjzx.js → rpc-9fSqL_YK.js} +57 -12
- package/dist/rpc-9fSqL_YK.js.map +1 -0
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +599 -306
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/devtools.d.ts +3 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/hot.js +9 -5
- 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 +12 -2
- package/dist/runtime/loader.js +3 -1
- package/dist/runtime/server.d.ts +4 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +5 -5
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +3 -0
- package/dist/runtime/static-loader.js +1 -0
- package/dist/runtime/testing.d.ts +21 -2
- package/dist/runtime/testing.js +83 -7
- package/dist/runtime/testing.js.map +1 -1
- package/dist/{server-sQCvduOz.d.ts → server-BxqjLUnV.d.ts} +211 -20
- package/dist/{server-CX3JnPCs.js → server-DZsgnPKS.js} +595 -185
- package/dist/server-DZsgnPKS.js.map +1 -0
- package/dist/shared-CWYOd0H3.js +40 -0
- package/dist/shared-CWYOd0H3.js.map +1 -0
- package/dist/static-loader-BcFh4ebX.d.ts +11 -0
- package/dist/static-loader-ClNkHZGn.js +185 -0
- package/dist/static-loader-ClNkHZGn.js.map +1 -0
- package/dist/stream-bgNCMcaA.js +280 -0
- package/dist/stream-bgNCMcaA.js.map +1 -0
- package/dist/vite.d.ts +30 -5
- package/dist/vite.js +501 -62
- package/dist/vite.js.map +1 -1
- package/package.json +7 -2
- package/types.d.ts +5 -0
- package/dist/cookies-rgIAc8IE.js.map +0 -1
- package/dist/devtools-Bm8cS7hX.js.map +0 -1
- package/dist/devtools-panel-CTbDSBBA.js.map +0 -1
- package/dist/html-CxWpXngy.js.map +0 -1
- package/dist/inspect-CGCWfaEx.js.map +0 -1
- package/dist/loader-BUhNqDHw.d.ts +0 -30
- package/dist/loader-py4qu6tQ.js +0 -215
- package/dist/loader-py4qu6tQ.js.map +0 -1
- package/dist/navigate-C5dP89YL.js.map +0 -1
- package/dist/rpc-B86KKjzx.js.map +0 -1
- package/dist/server-CX3JnPCs.js.map +0 -1
- package/dist/shared-BE_oBSDM.js +0 -176
- package/dist/shared-BE_oBSDM.js.map +0 -1
- package/dist/stream-cvhqOzfs.js +0 -145
- package/dist/stream-cvhqOzfs.js.map +0 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { d as isRaw, p as rawHTML } from "./html-DEeoepg3.js";
|
|
2
|
+
import { i as stateValues, t as ElementReference } from "./shared-CWYOd0H3.js";
|
|
3
|
+
import { Feature, Stream, createPlugin, fromCrossJSON, toCrossJSONStream } from "seroval";
|
|
4
|
+
//#region src/runtime/calls.ts
|
|
5
|
+
/** Server functions that are passed to the client, with their references. */
|
|
6
|
+
const functionReferences = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* A file or a blob in the arguments of a server function call. The call
|
|
9
|
+
* sends it as a part of multipart form data, named `file<index>`, instead
|
|
10
|
+
* of in the JSON of the arguments.
|
|
11
|
+
*/
|
|
12
|
+
var Upload = class {
|
|
13
|
+
index;
|
|
14
|
+
constructor(index) {
|
|
15
|
+
this.index = index;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Replaces each value in arrays and plain objects that `replace` returns a
|
|
20
|
+
* value for. Returns a copy, or the value itself when nothing changed.
|
|
21
|
+
*/
|
|
22
|
+
function replaceDeep(value, replace) {
|
|
23
|
+
const replaced = replace(value);
|
|
24
|
+
if (replaced !== void 0) return replaced;
|
|
25
|
+
if (Array.isArray(value)) return value.map((item) => replaceDeep(item, replace));
|
|
26
|
+
if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, replaceDeep(item, replace)]));
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/runtime/serial.ts
|
|
31
|
+
/**
|
|
32
|
+
* Returns the parse functions of a plugin. `read` returns the values of the
|
|
33
|
+
* node by key, and each mode parses them in that order, so the nodes match.
|
|
34
|
+
*/
|
|
35
|
+
function parsers(read) {
|
|
36
|
+
const parse = (value, ctx) => {
|
|
37
|
+
const node = read(value);
|
|
38
|
+
for (const key in node) node[key] = ctx.parse(node[key]);
|
|
39
|
+
return node;
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
sync: parse,
|
|
43
|
+
stream: parse,
|
|
44
|
+
async: async (value, ctx) => {
|
|
45
|
+
const node = read(value);
|
|
46
|
+
for (const key in node) node[key] = await ctx.parse(node[key]);
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const ElementPlugin = createPlugin({
|
|
52
|
+
tag: "brumate/element",
|
|
53
|
+
skipPlainObjects: true,
|
|
54
|
+
test: (value) => value instanceof ElementReference,
|
|
55
|
+
parse: parsers((value) => ({
|
|
56
|
+
a: value.scope,
|
|
57
|
+
b: value.anchor
|
|
58
|
+
})),
|
|
59
|
+
serialize: (node, ctx) => `$b.e(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,
|
|
60
|
+
deserialize: (node, ctx) => stateValues.e(ctx.deserialize(node.a), ctx.deserialize(node.b))
|
|
61
|
+
});
|
|
62
|
+
const FunctionPlugin = createPlugin({
|
|
63
|
+
tag: "brumate/function",
|
|
64
|
+
skipPlainObjects: true,
|
|
65
|
+
test: (value) => typeof value === "function" && functionReferences.has(value),
|
|
66
|
+
parse: parsers((value) => {
|
|
67
|
+
const reference = functionReferences.get(value);
|
|
68
|
+
return {
|
|
69
|
+
a: reference.ref,
|
|
70
|
+
b: reference.scope
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
serialize: (node, ctx) => `$b.f(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,
|
|
74
|
+
deserialize: (node, ctx) => stateValues.f(ctx.deserialize(node.a), ctx.deserialize(node.b))
|
|
75
|
+
});
|
|
76
|
+
/** HTML, such as the `children` of a component, so the client can insert it again. */
|
|
77
|
+
const RawPlugin = createPlugin({
|
|
78
|
+
tag: "brumate/raw",
|
|
79
|
+
skipPlainObjects: true,
|
|
80
|
+
test: isRaw,
|
|
81
|
+
parse: parsers((value) => ({ h: rawHTML(value) })),
|
|
82
|
+
serialize: (node, ctx) => `$b.r(${ctx.serialize(node.h)})`,
|
|
83
|
+
deserialize: (node, ctx) => stateValues.r(ctx.deserialize(node.h))
|
|
84
|
+
});
|
|
85
|
+
/** A component in the page state, such as the value of a dynamic tag. See `stateValues.c`. */
|
|
86
|
+
const ComponentPlugin = createPlugin({
|
|
87
|
+
tag: "brumate/component",
|
|
88
|
+
skipPlainObjects: true,
|
|
89
|
+
test: (value) => typeof value === "function" && typeof value.brumateId === "string",
|
|
90
|
+
parse: parsers((value) => ({ c: value.brumateId })),
|
|
91
|
+
serialize: (node, ctx) => `$b.c(${ctx.serialize(node.c)})`,
|
|
92
|
+
deserialize: (node, ctx) => stateValues.c(ctx.deserialize(node.c))
|
|
93
|
+
});
|
|
94
|
+
/** A value that its string makes again, such as a `URL` from its `href`. */
|
|
95
|
+
function stringPlugin(tag, type) {
|
|
96
|
+
return createPlugin({
|
|
97
|
+
tag,
|
|
98
|
+
skipPlainObjects: true,
|
|
99
|
+
test: (value) => value instanceof type,
|
|
100
|
+
parse: parsers((value) => ({ v: value.toString() })),
|
|
101
|
+
serialize: (node, ctx) => `new ${type.name}(${ctx.serialize(node.v)})`,
|
|
102
|
+
deserialize: (node, ctx) => new type(ctx.deserialize(node.v))
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const URLPlugin = stringPlugin("brumate/url", URL);
|
|
106
|
+
const SearchParamsPlugin = stringPlugin("brumate/search-params", URLSearchParams);
|
|
107
|
+
const plugins = [
|
|
108
|
+
ElementPlugin,
|
|
109
|
+
FunctionPlugin,
|
|
110
|
+
RawPlugin,
|
|
111
|
+
ComponentPlugin,
|
|
112
|
+
createPlugin({
|
|
113
|
+
tag: "brumate/upload",
|
|
114
|
+
skipPlainObjects: true,
|
|
115
|
+
test: (value) => value instanceof Upload,
|
|
116
|
+
parse: parsers((value) => ({ i: value.index })),
|
|
117
|
+
serialize: () => {
|
|
118
|
+
throw new Error("A file cannot be sent in the page");
|
|
119
|
+
},
|
|
120
|
+
deserialize: (node, ctx) => new Upload(ctx.deserialize(node.i))
|
|
121
|
+
}),
|
|
122
|
+
URLPlugin,
|
|
123
|
+
SearchParamsPlugin
|
|
124
|
+
];
|
|
125
|
+
/**
|
|
126
|
+
* Features that are off in both directions:
|
|
127
|
+
*
|
|
128
|
+
* - Errors keep their name and message only. A stack trace would show the
|
|
129
|
+
* server's files and code to the browser.
|
|
130
|
+
* - Regular expressions are not sent. A pattern from a client could take
|
|
131
|
+
* the server a long time to match, and reading one is refused as well.
|
|
132
|
+
*/
|
|
133
|
+
const disabledFeatures = Feature.ErrorPrototypeStack | Feature.RegExp;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/runtime/stream.ts
|
|
136
|
+
const HEADER_SIZE = 12;
|
|
137
|
+
const encoder = new TextEncoder();
|
|
138
|
+
const decoder = new TextDecoder();
|
|
139
|
+
/** The content type of a stream of chunks. */
|
|
140
|
+
const STREAM_TYPE = "application/x-brumate-stream";
|
|
141
|
+
/** One chunk: its header and its data, in one array. */
|
|
142
|
+
function chunk(text) {
|
|
143
|
+
const data = encoder.encode(text);
|
|
144
|
+
const result = new Uint8Array(HEADER_SIZE + data.length);
|
|
145
|
+
encoder.encodeInto(`;0x${data.length.toString(16).padStart(8, "0")};`, result);
|
|
146
|
+
result.set(data, HEADER_SIZE);
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/** Serializes a value as a stream of chunks. */
|
|
150
|
+
function toChunkStream(value) {
|
|
151
|
+
return new ReadableStream({ start(controller) {
|
|
152
|
+
toCrossJSONStream(value, {
|
|
153
|
+
refs: /* @__PURE__ */ new Map(),
|
|
154
|
+
plugins,
|
|
155
|
+
disabledFeatures,
|
|
156
|
+
onParse(node) {
|
|
157
|
+
controller.enqueue(chunk(JSON.stringify(node)));
|
|
158
|
+
},
|
|
159
|
+
onDone() {
|
|
160
|
+
controller.close();
|
|
161
|
+
},
|
|
162
|
+
onError(error) {
|
|
163
|
+
controller.error(error);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
} });
|
|
167
|
+
}
|
|
168
|
+
/** Reads chunks of a stream, buffering only the bytes of the chunk it waits for. */
|
|
169
|
+
var ChunkReader = class {
|
|
170
|
+
reader;
|
|
171
|
+
pieces = [];
|
|
172
|
+
length = 0;
|
|
173
|
+
done = false;
|
|
174
|
+
constructor(stream) {
|
|
175
|
+
this.reader = stream.getReader();
|
|
176
|
+
}
|
|
177
|
+
async fill(size) {
|
|
178
|
+
while (this.length < size && !this.done) {
|
|
179
|
+
const piece = await this.reader.read();
|
|
180
|
+
if (piece.done) this.done = true;
|
|
181
|
+
else {
|
|
182
|
+
this.pieces.push(piece.value);
|
|
183
|
+
this.length += piece.value.length;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
take(size) {
|
|
188
|
+
const result = new Uint8Array(size);
|
|
189
|
+
let offset = 0;
|
|
190
|
+
while (offset < size) {
|
|
191
|
+
const piece = this.pieces[0];
|
|
192
|
+
const count = Math.min(piece.length, size - offset);
|
|
193
|
+
result.set(piece.subarray(0, count), offset);
|
|
194
|
+
offset += count;
|
|
195
|
+
if (count === piece.length) this.pieces.shift();
|
|
196
|
+
else this.pieces[0] = piece.subarray(count);
|
|
197
|
+
}
|
|
198
|
+
this.length -= size;
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
/** The data of the next chunk, or undefined at the end of the stream. */
|
|
202
|
+
async next() {
|
|
203
|
+
await this.fill(HEADER_SIZE);
|
|
204
|
+
if (this.length === 0) return;
|
|
205
|
+
const head = this.length < HEADER_SIZE ? "" : decoder.decode(this.take(HEADER_SIZE));
|
|
206
|
+
const match = /^;0x([0-9a-f]{8});$/.exec(head);
|
|
207
|
+
if (!match) throw new Error("The answer of a server function is not a stream of chunks");
|
|
208
|
+
const size = Number.parseInt(match[1], 16);
|
|
209
|
+
await this.fill(size);
|
|
210
|
+
if (this.length < size) throw new Error("The answer of a server function ended in the middle of a chunk");
|
|
211
|
+
return decoder.decode(this.take(size));
|
|
212
|
+
}
|
|
213
|
+
cancel(reason) {
|
|
214
|
+
this.done = true;
|
|
215
|
+
this.reader.cancel(reason).catch(() => {});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const ignore = () => {};
|
|
219
|
+
/**
|
|
220
|
+
* The refs of a stream. A promise in the answer can fail with nothing that
|
|
221
|
+
* reads it, such as a field the caller ignores, so its failure is claimed
|
|
222
|
+
* here. Code that awaits it still sees the failure.
|
|
223
|
+
*/
|
|
224
|
+
var Refs = class extends Map {
|
|
225
|
+
set(id, value) {
|
|
226
|
+
if (value instanceof Promise) value.catch(ignore);
|
|
227
|
+
return super.set(id, value);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Fails the promises and async iterables that still wait for a chunk, when
|
|
232
|
+
* the stream ends early. Failing a settled one does nothing.
|
|
233
|
+
*/
|
|
234
|
+
function failPending(refs, error) {
|
|
235
|
+
for (const value of refs.values()) try {
|
|
236
|
+
if (value instanceof Stream) value.throw(error);
|
|
237
|
+
else if (value !== null && typeof value === "object") {
|
|
238
|
+
const resolver = value;
|
|
239
|
+
if (resolver.p instanceof Promise && typeof resolver.f === "function") {
|
|
240
|
+
resolver.p.catch(ignore);
|
|
241
|
+
resolver.f(error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch {}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Reads the first chunk of a stream as the value, and the rest in the
|
|
248
|
+
* background, so the promises and async iterables in it settle as their
|
|
249
|
+
* chunks arrive.
|
|
250
|
+
*/
|
|
251
|
+
async function fromChunkStream(stream) {
|
|
252
|
+
const reader = new ChunkReader(stream);
|
|
253
|
+
const refs = new Refs();
|
|
254
|
+
const read = (data) => fromCrossJSON(JSON.parse(data), {
|
|
255
|
+
refs,
|
|
256
|
+
plugins,
|
|
257
|
+
disabledFeatures
|
|
258
|
+
});
|
|
259
|
+
const first = await reader.next();
|
|
260
|
+
if (first === void 0) throw new Error("The answer of a server function is empty");
|
|
261
|
+
const value = read(first);
|
|
262
|
+
(async () => {
|
|
263
|
+
try {
|
|
264
|
+
for (;;) {
|
|
265
|
+
const data = await reader.next();
|
|
266
|
+
if (data === void 0) break;
|
|
267
|
+
read(data);
|
|
268
|
+
}
|
|
269
|
+
failPending(refs, /* @__PURE__ */ new Error("The answer of a server function ended early"));
|
|
270
|
+
} catch (error) {
|
|
271
|
+
reader.cancel(error);
|
|
272
|
+
failPending(refs, error);
|
|
273
|
+
}
|
|
274
|
+
})();
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { plugins as a, replaceDeep as c, disabledFeatures as i, fromChunkStream as n, Upload as o, toChunkStream as r, functionReferences as s, STREAM_TYPE as t };
|
|
279
|
+
|
|
280
|
+
//# sourceMappingURL=stream-bgNCMcaA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-bgNCMcaA.js","names":[],"sources":["../src/runtime/calls.ts","../src/runtime/serial.ts","../src/runtime/stream.ts"],"sourcesContent":["// Values that only server function calls and their serialization use. They are\n// not in `shared.ts`, which the core imports, so a page's core does not hold them.\n\nimport type { FunctionReference } from './shared.ts';\n\n/** Server functions that are passed to the client, with their references. */\nexport const functionReferences: WeakMap<object, FunctionReference> = new WeakMap();\n\n/**\n * A file or a blob in the arguments of a server function call. The call\n * sends it as a part of multipart form data, named `file<index>`, instead\n * of in the JSON of the arguments.\n */\nexport class Upload {\n readonly index: number;\n\n constructor(index: number) {\n this.index = index;\n }\n}\n\n/**\n * Replaces each value in arrays and plain objects that `replace` returns a\n * value for. Returns a copy, or the value itself when nothing changed.\n */\nexport function replaceDeep(value: unknown, replace: (value: unknown) => unknown): unknown {\n const replaced = replace(value);\n if (replaced !== undefined) {\n return replaced;\n }\n if (Array.isArray(value)) {\n return value.map((item) => replaceDeep(item, replace));\n }\n if (\n value !== null &&\n typeof value === 'object' &&\n Object.getPrototypeOf(value) === Object.prototype\n ) {\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, replaceDeep(item, replace)]),\n );\n }\n return value;\n}\n","// The seroval plugins of brumate's values. The server writes the page state\n// with them as code, and server function calls as JSON, which both sides\n// read with them. The core does not import this module: a state record\n// is code that makes its values with `stateValues`, so seroval loads in the\n// browser only with the first server function call.\n\nimport { Feature, createPlugin } from 'seroval';\nimport type {\n Plugin,\n SerovalNode,\n StreamParsePluginContext,\n SyncParsePluginContext,\n} from 'seroval';\nimport { isRaw, rawHTML } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { Upload, functionReferences } from './calls.ts';\nimport { ElementReference, stateValues } from './shared.ts';\nimport type { ComponentValue } from './shared.ts';\n\ntype ReferenceNode = { a: SerovalNode; b: SerovalNode };\n\n/**\n * Returns the parse functions of a plugin. `read` returns the values of the\n * node by key, and each mode parses them in that order, so the nodes match.\n */\nfunction parsers<T, K extends string>(\n read: (value: T) => Record<K, unknown>,\n): Plugin<T, Record<K, SerovalNode>>['parse'] {\n type N = Record<K, SerovalNode>;\n const parse = (value: T, ctx: SyncParsePluginContext | StreamParsePluginContext): N => {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n node[key] = ctx.parse(node[key]);\n }\n return node as N;\n };\n return {\n sync: parse,\n stream: parse,\n async: async (value, ctx) => {\n const node = read(value) as Record<string, unknown>;\n for (const key in node) {\n // oxlint-disable-next-line no-await-in-loop -- In order, as the other modes parse, so the IDs match.\n node[key] = await ctx.parse(node[key]);\n }\n return node as N;\n },\n };\n}\n\n// In the page state, each value is a call of `stateValues`, which the code of a record gets as `$b`.\n\n// No plugin here matches a plain object, so each one sets skipPlainObjects and seroval\n// does not run its test on object literals. Raw HTML is a class instance for this reason.\nconst ElementPlugin = createPlugin<ElementReference, ReferenceNode>({\n tag: 'brumate/element',\n skipPlainObjects: true,\n test: (value) => value instanceof ElementReference,\n parse: parsers((value) => ({ a: value.scope, b: value.anchor })),\n serialize: (node, ctx) => `$b.e(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.e(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n});\n\nconst FunctionPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/function',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && functionReferences.has(value),\n parse: parsers((value) => {\n const reference = functionReferences.get(value)!;\n return { a: reference.ref, b: reference.scope };\n }),\n serialize: (node, ctx) => `$b.f(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.f(ctx.deserialize<string>(node.a), ctx.deserialize<number>(node.b)),\n});\n\n/** HTML, such as the `children` of a component, so the client can insert it again. */\nconst RawPlugin = createPlugin<Raw, { h: SerovalNode }>({\n tag: 'brumate/raw',\n skipPlainObjects: true,\n test: isRaw,\n parse: parsers((value) => ({ h: rawHTML(value) })),\n serialize: (node, ctx) => `$b.r(${ctx.serialize(node.h)})`,\n deserialize: (node, ctx) => stateValues.r(ctx.deserialize<string>(node.h)),\n});\n\n/** A component in the page state, such as the value of a dynamic tag. See `stateValues.c`. */\nconst ComponentPlugin = createPlugin<ComponentValue, { c: SerovalNode }>({\n tag: 'brumate/component',\n skipPlainObjects: true,\n test: (value) =>\n typeof value === 'function' && typeof (value as Partial<ComponentValue>).brumateId === 'string',\n parse: parsers((value) => ({ c: value.brumateId })),\n serialize: (node, ctx) => `$b.c(${ctx.serialize(node.c)})`,\n deserialize: (node, ctx) => stateValues.c(ctx.deserialize<string>(node.c)),\n});\n\n/** A value that its string makes again, such as a `URL` from its `href`. */\nfunction stringPlugin<T extends { toString(): string }>(\n tag: string,\n type: new (text: string) => T,\n): Plugin<T, { v: SerovalNode }> {\n return createPlugin<T, { v: SerovalNode }>({\n tag,\n skipPlainObjects: true,\n test: (value) => value instanceof type,\n parse: parsers((value) => ({ v: value.toString() })),\n serialize: (node, ctx) => `new ${type.name}(${ctx.serialize(node.v)})`,\n deserialize: (node, ctx) => new type(ctx.deserialize<string>(node.v)),\n });\n}\n\nconst URLPlugin = stringPlugin('brumate/url', URL);\nconst SearchParamsPlugin = stringPlugin('brumate/search-params', URLSearchParams);\n\n/** A file in the arguments of a server function call. It is never in the page state. */\nconst UploadPlugin = createPlugin<Upload, { i: SerovalNode }>({\n tag: 'brumate/upload',\n skipPlainObjects: true,\n test: (value) => value instanceof Upload,\n parse: parsers((value) => ({ i: value.index })),\n serialize: () => {\n throw new Error('A file cannot be sent in the page');\n },\n deserialize: (node, ctx) => new Upload(ctx.deserialize<number>(node.i)),\n});\n\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const plugins: Plugin<any, any>[] = [\n ElementPlugin,\n FunctionPlugin,\n RawPlugin,\n ComponentPlugin,\n UploadPlugin,\n URLPlugin,\n SearchParamsPlugin,\n];\n\n/**\n * Features that are off in both directions:\n *\n * - Errors keep their name and message only. A stack trace would show the\n * server's files and code to the browser.\n * - Regular expressions are not sent. A pattern from a client could take\n * the server a long time to match, and reading one is refused as well.\n */\nexport const disabledFeatures: number = Feature.ErrorPrototypeStack | Feature.RegExp;\n","// The answer of a server function, as a stream of seroval chunks. Promises\n// and async iterables in the answer settle as their chunks arrive.\n//\n// Each chunk is a 12-byte header with the size of its data in bytes, as 8\n// hex digits, and the data: `;0x0000001f;{...}`. The reader knows how many\n// bytes to wait for, and can refuse a chunk that is too large.\n\nimport { Stream, fromCrossJSON, toCrossJSONStream } from 'seroval';\nimport type { SerovalNode } from 'seroval';\nimport { disabledFeatures, plugins } from './serial.ts';\n\nconst HEADER_SIZE = 12;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** The content type of a stream of chunks. */\nexport const STREAM_TYPE = 'application/x-brumate-stream';\n\n/** One chunk: its header and its data, in one array. */\nfunction chunk(text: string): Uint8Array {\n const data = encoder.encode(text);\n const result = new Uint8Array(HEADER_SIZE + data.length);\n encoder.encodeInto(`;0x${data.length.toString(16).padStart(8, '0')};`, result);\n result.set(data, HEADER_SIZE);\n return result;\n}\n\n/** Serializes a value as a stream of chunks. */\nexport function toChunkStream(value: unknown): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n toCrossJSONStream(value, {\n refs: new Map(),\n plugins,\n disabledFeatures,\n onParse(node) {\n controller.enqueue(chunk(JSON.stringify(node)));\n },\n onDone() {\n controller.close();\n },\n onError(error) {\n controller.error(error);\n },\n });\n },\n });\n}\n\n/** Reads chunks of a stream, buffering only the bytes of the chunk it waits for. */\nclass ChunkReader {\n private readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n private pieces: Uint8Array[] = [];\n private length = 0;\n private done = false;\n\n constructor(stream: ReadableStream<Uint8Array>) {\n this.reader = stream.getReader();\n }\n\n private async fill(size: number): Promise<void> {\n while (this.length < size && !this.done) {\n // oxlint-disable-next-line no-await-in-loop -- Pieces arrive in order.\n const piece = await this.reader.read();\n if (piece.done) {\n this.done = true;\n } else {\n this.pieces.push(piece.value);\n this.length += piece.value.length;\n }\n }\n }\n\n private take(size: number): Uint8Array {\n const result = new Uint8Array(size);\n let offset = 0;\n while (offset < size) {\n const piece = this.pieces[0]!;\n const count = Math.min(piece.length, size - offset);\n result.set(piece.subarray(0, count), offset);\n offset += count;\n if (count === piece.length) {\n this.pieces.shift();\n } else {\n this.pieces[0] = piece.subarray(count);\n }\n }\n this.length -= size;\n return result;\n }\n\n /** The data of the next chunk, or undefined at the end of the stream. */\n async next(): Promise<string | undefined> {\n await this.fill(HEADER_SIZE);\n if (this.length === 0) {\n return undefined;\n }\n const head = this.length < HEADER_SIZE ? '' : decoder.decode(this.take(HEADER_SIZE));\n const match = /^;0x([0-9a-f]{8});$/.exec(head);\n if (!match) {\n throw new Error('The answer of a server function is not a stream of chunks');\n }\n const size = Number.parseInt(match[1]!, 16);\n await this.fill(size);\n if (this.length < size) {\n throw new Error('The answer of a server function ended in the middle of a chunk');\n }\n return decoder.decode(this.take(size));\n }\n\n cancel(reason: unknown): void {\n this.done = true;\n void this.reader.cancel(reason).catch(() => {});\n }\n}\n\nconst ignore = (): void => {};\n\n/**\n * The refs of a stream. A promise in the answer can fail with nothing that\n * reads it, such as a field the caller ignores, so its failure is claimed\n * here. Code that awaits it still sees the failure.\n */\nclass Refs extends Map<number, unknown> {\n override set(id: number, value: unknown): this {\n if (value instanceof Promise) {\n value.catch(ignore);\n }\n return super.set(id, value);\n }\n}\n\n/**\n * Fails the promises and async iterables that still wait for a chunk, when\n * the stream ends early. Failing a settled one does nothing.\n */\nfunction failPending(refs: Refs, error: unknown): void {\n for (const value of refs.values()) {\n try {\n // The deserializer makes a Stream. A LiveStream comes only from user code, and its producer fails it.\n if (value instanceof Stream) {\n value.throw(error);\n } else if (value !== null && typeof value === 'object') {\n const resolver = value as { p?: unknown; f?: unknown };\n if (resolver.p instanceof Promise && typeof resolver.f === 'function') {\n resolver.p.catch(ignore);\n (resolver.f as (error: unknown) => void)(error);\n }\n }\n } catch {\n // A value that a plugin made, which has no such methods.\n }\n }\n}\n\n/**\n * Reads the first chunk of a stream as the value, and the rest in the\n * background, so the promises and async iterables in it settle as their\n * chunks arrive.\n */\nexport async function fromChunkStream(stream: ReadableStream<Uint8Array>): Promise<unknown> {\n const reader = new ChunkReader(stream);\n const refs = new Refs();\n const read = (data: string): unknown =>\n fromCrossJSON(JSON.parse(data) as SerovalNode, { refs, plugins, disabledFeatures });\n const first = await reader.next();\n if (first === undefined) {\n throw new Error('The answer of a server function is empty');\n }\n const value = read(first);\n void (async () => {\n try {\n for (;;) {\n // oxlint-disable-next-line no-await-in-loop -- Chunks arrive in order.\n const data = await reader.next();\n if (data === undefined) {\n break;\n }\n read(data);\n }\n failPending(refs, new Error('The answer of a server function ended early'));\n } catch (error) {\n reader.cancel(error);\n failPending(refs, error);\n }\n })();\n return value;\n}\n"],"mappings":";;;;;AAMA,MAAa,qCAAyD,IAAI,QAAQ;;;;;;AAOlF,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,OAAe;EACzB,KAAK,QAAQ;CACf;AACF;;;;;AAMA,SAAgB,YAAY,OAAgB,SAA+C;CACzF,MAAM,WAAW,QAAQ,KAAK;CAC9B,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,SAAS,YAAY,MAAM,OAAO,CAAC;CAEvD,IACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,eAAe,KAAK,MAAM,OAAO,WAExC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,YAAY,MAAM,OAAO,CAAC,CAAC,CAC9E;CAEF,OAAO;AACT;;;;;;;AClBA,SAAS,QACP,MAC4C;CAE5C,MAAM,SAAS,OAAU,QAA8D;EACrF,MAAM,OAAO,KAAK,KAAK;EACvB,KAAK,MAAM,OAAO,MAChB,KAAK,OAAO,IAAI,MAAM,KAAK,IAAI;EAEjC,OAAO;CACT;CACA,OAAO;EACL,MAAM;EACN,QAAQ;EACR,OAAO,OAAO,OAAO,QAAQ;GAC3B,MAAM,OAAO,KAAK,KAAK;GACvB,KAAK,MAAM,OAAO,MAEhB,KAAK,OAAO,MAAM,IAAI,MAAM,KAAK,IAAI;GAEvC,OAAO;EACT;CACF;AACF;AAMA,MAAM,gBAAgB,aAA8C;CAClE,KAAK;CACL,kBAAkB;CAClB,OAAO,UAAU,iBAAiB;CAClC,OAAO,SAAS,WAAW;EAAE,GAAG,MAAM;EAAO,GAAG,MAAM;CAAO,EAAE;CAC/D,YAA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K,IAAI;GACX;GACA,YAAY,sBAAM,IAAI,MAAM,6CAA6C,CAAC;EAC5E,SAAS,OAAO;GACd,OAAO,OAAO,KAAK;GACnB,YAAY,MAAM,KAAK;EACzB;CACF,EAAA,CAAG;CACH,OAAO;AACT"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as NavigateOptions } from "./
|
|
1
|
+
import { n as NavigateOptions } from "./boot-DN1ZU8Hg.js";
|
|
2
2
|
import { Plugin, ViteDevServer } from "vite";
|
|
3
3
|
//#region src/report.d.ts
|
|
4
4
|
/** Sizes in bytes, after gzip. */
|
|
@@ -44,6 +44,23 @@ interface ManifestChunk {
|
|
|
44
44
|
src?: string;
|
|
45
45
|
isEntry?: boolean;
|
|
46
46
|
}
|
|
47
|
+
/** A page that the build wrote, in the prerender manifest. */
|
|
48
|
+
interface PrerenderedPage {
|
|
49
|
+
/** The file of the page, relative to the client build. */
|
|
50
|
+
file: string;
|
|
51
|
+
/**
|
|
52
|
+
* The hashes of the page's inline scripts, as `sha256-<base64>`, for a
|
|
53
|
+
* Content Security Policy: a prerendered page has no nonce.
|
|
54
|
+
*/
|
|
55
|
+
scripts: string[];
|
|
56
|
+
}
|
|
57
|
+
/** The prerender manifest, `.brumate/prerender.json` in the client build. */
|
|
58
|
+
interface PrerenderManifest {
|
|
59
|
+
/** The pages by path. The error page of a missing path is `404`. */
|
|
60
|
+
pages: Record<string, PrerenderedPage>;
|
|
61
|
+
/** The hashes of the inline scripts of every page, once each. */
|
|
62
|
+
scripts: string[];
|
|
63
|
+
}
|
|
47
64
|
//#endregion
|
|
48
65
|
//#region src/dev-error.d.ts
|
|
49
66
|
/**
|
|
@@ -86,9 +103,17 @@ export interface BrumateOptions {
|
|
|
86
103
|
*/
|
|
87
104
|
navigate?: boolean | NavigateOptions;
|
|
88
105
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
106
|
+
* After the page loads, while the browser is idle, the loader loads the
|
|
107
|
+
* core and the code of the handlers of elements in or near the viewport,
|
|
108
|
+
* so the first event needs no request. It skips elements with
|
|
109
|
+
* `prefetch="none"`, and loads nothing when the browser asks to save data
|
|
110
|
+
* or the connection is 2G. Defaults to true.
|
|
111
|
+
*/
|
|
112
|
+
preload?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Client parts of a component smaller than this many bytes in all, after
|
|
115
|
+
* minifying, become one module, so its first event loads one file. 0
|
|
116
|
+
* keeps one module per part. Defaults to 4096.
|
|
92
117
|
*/
|
|
93
118
|
merge?: number;
|
|
94
119
|
/**
|
|
@@ -117,5 +142,5 @@ export interface BrumateOptions {
|
|
|
117
142
|
/** The Vite plugin for `.brm` files. */
|
|
118
143
|
export default function brumate(options?: BrumateOptions): Plugin;
|
|
119
144
|
//#endregion
|
|
120
|
-
export type { Budget, BuildReport, ManifestChunk, PrerenderOptions };
|
|
145
|
+
export type { Budget, BuildReport, ManifestChunk, PrerenderManifest, PrerenderOptions, PrerenderedPage };
|
|
121
146
|
//# sourceMappingURL=vite.d.ts.map
|