brumate 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-BkUdiYOF.d.ts → boot-ej-9NRT3.d.ts} +20 -2
- package/dist/cli.js +88 -82
- package/dist/cli.js.map +1 -1
- package/dist/{client-B0FXW5Kw.js → client-B-ww-PQ7.js} +402 -63
- package/dist/client-B-ww-PQ7.js.map +1 -0
- package/dist/{client-Cq6aTiDs.d.ts → client-Do6IBIhI.d.ts} +58 -14
- package/dist/{defer-BMIMP4Hq.js → defer-JD2FK9mV.js} +5 -3
- package/dist/defer-JD2FK9mV.js.map +1 -0
- package/dist/{devtools-calls-DGW6nLZ2.js → devtools-calls-DCjuSkim.js} +3 -3
- package/dist/{devtools-calls-DGW6nLZ2.js.map → devtools-calls-DCjuSkim.js.map} +1 -1
- package/dist/{devtools-panel-B1nF1KB7.js → devtools-panel-DLeWTPhU.js} +4 -4
- package/dist/{devtools-panel-B1nF1KB7.js.map → devtools-panel-DLeWTPhU.js.map} +1 -1
- package/dist/{devtools-B4prrxht.js → devtools-tuq7ATGN.js} +10 -7
- package/dist/devtools-tuq7ATGN.js.map +1 -0
- package/dist/{error-catalog-DakxjSgj.js → error-catalog-BBWB7w-E.js} +11 -4
- package/dist/error-catalog-BBWB7w-E.js.map +1 -0
- package/dist/{error-catalog-VxLbz-6p.js → error-catalog-CbmQqfat.js} +1 -1
- package/dist/{events-LgLdp1R7.js → events-BDVITj3P.js} +3 -5
- package/dist/events-BDVITj3P.js.map +1 -0
- package/dist/{features-DwMYKBIC.js → features-Cte5aj20.js} +8 -2
- package/dist/features-Cte5aj20.js.map +1 -0
- package/dist/{files-D5GtxwEQ.js → files-Bz0lAQzD.js} +2 -2
- package/dist/{files-D5GtxwEQ.js.map → files-Bz0lAQzD.js.map} +1 -1
- package/dist/{html-Cf5uKhLs.js → html-BYuHDvxy.js} +10 -3
- package/dist/html-BYuHDvxy.js.map +1 -0
- package/dist/index.d.ts +71 -19
- package/dist/index.js +3 -3
- package/dist/{inspect-CGl5Y8q6.js → inspect-fpaBJ5pm.js} +1305 -75
- package/dist/inspect-fpaBJ5pm.js.map +1 -0
- package/dist/{loader-BsaSuIoG.js → loader-DMxuZ6He.js} +14 -6
- package/dist/loader-DMxuZ6He.js.map +1 -0
- package/dist/{navigate-BlowKvhB.js → navigate-C5PjwYMh.js} +108 -20
- package/dist/navigate-C5PjwYMh.js.map +1 -0
- package/dist/{produce-CLABZ8k2.d.ts → produce-BDkCsGH7.d.ts} +3 -3
- package/dist/{rpc-C1jYVNAe.js → rpc-DOdrekhP.js} +23 -13
- package/dist/rpc-DOdrekhP.js.map +1 -0
- package/dist/runtime/bundles.d.ts +3 -2
- package/dist/runtime/bundles.js +20 -5
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -3
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/devtools.d.ts +3 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/otel.d.ts +18 -0
- package/dist/runtime/otel.js +127 -0
- package/dist/runtime/otel.js.map +1 -0
- package/dist/runtime/server.d.ts +4 -3
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +4 -1
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -2
- package/dist/runtime/store.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/search-params-qGERTLi3.js +382 -0
- package/dist/search-params-qGERTLi3.js.map +1 -0
- package/dist/{serial-ribg9NAj.js → serial-B2AJ9VGx.js} +1 -1
- package/dist/{serial-ioa17MuY.js → serial-Cj6pDGOq.js} +6 -6
- package/dist/{serial-ioa17MuY.js.map → serial-Cj6pDGOq.js.map} +1 -1
- package/dist/{server-DesBZv5g.d.ts → server-2-LS_KFo.d.ts} +125 -9
- package/dist/{server-BUuf7XPZ.js → server-CRGZMWnK.js} +545 -236
- package/dist/server-CRGZMWnK.js.map +1 -0
- package/dist/{shared-CX_YacDm.js → shared-CUBWrbiM.js} +4 -4
- package/dist/{shared-CX_YacDm.js.map → shared-CUBWrbiM.js.map} +1 -1
- package/dist/sheets-B9Zr50mf.js +105 -0
- package/dist/sheets-B9Zr50mf.js.map +1 -0
- package/dist/{signals-7VVD9C_H.d.ts → signals-BgsJK-uT.d.ts} +16 -6
- package/dist/{static-loader-C_en-4v8.js → static-loader-BDBtWsdg.js} +107 -19
- package/dist/static-loader-BDBtWsdg.js.map +1 -0
- package/dist/{static-loader-UKnK11Em.d.ts → static-loader-CAFn6p0l.d.ts} +2 -2
- package/dist/{store-9_oa0HG1.d.ts → store-BwWg-Iei.d.ts} +79 -2
- package/dist/store-DNr24Z8L.js +950 -0
- package/dist/store-DNr24Z8L.js.map +1 -0
- package/dist/{stream-read-BTsYstJY.js → stream-read-CiLDH60b.js} +2 -2
- package/dist/{stream-read-BTsYstJY.js.map → stream-read-CiLDH60b.js.map} +1 -1
- package/dist/{stream-read-Dek3HnqO.js → stream-read-DVoregpA.js} +1 -1
- package/dist/trace-DT7RGRAV.d.ts +52 -0
- package/dist/trace-browser-C7MFMove.js +170 -0
- package/dist/trace-browser-C7MFMove.js.map +1 -0
- package/dist/trace-flag-Dy267snx.js +7 -0
- package/dist/trace-flag-Dy267snx.js.map +1 -0
- package/dist/{trusted-g_zUJbh2.js → trusted-Bmwg4_hf.js} +12 -5
- package/dist/trusted-Bmwg4_hf.js.map +1 -0
- package/dist/view-transitions-BpnVwtS4.js +141 -0
- package/dist/view-transitions-BpnVwtS4.js.map +1 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +356 -46
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +8 -0
- package/package.json +13 -1
- package/skills/brumate/SKILL.md +9 -5
- package/skills/brumate/references/errors.md +95 -14
- package/skills/brumate/references/events.md +27 -1
- package/skills/brumate/references/signals.md +4 -4
- package/skills/brumate/references/state.md +79 -4
- package/skills/brumate/references/syntax.md +58 -9
- package/dist/client-B0FXW5Kw.js.map +0 -1
- package/dist/defer-BMIMP4Hq.js.map +0 -1
- package/dist/devtools-B4prrxht.js.map +0 -1
- package/dist/error-catalog-DakxjSgj.js.map +0 -1
- package/dist/events-LgLdp1R7.js.map +0 -1
- package/dist/features-DwMYKBIC.js.map +0 -1
- package/dist/html-Cf5uKhLs.js.map +0 -1
- package/dist/inspect-CGl5Y8q6.js.map +0 -1
- package/dist/loader-BsaSuIoG.js.map +0 -1
- package/dist/navigate-BlowKvhB.js.map +0 -1
- package/dist/rpc-C1jYVNAe.js.map +0 -1
- package/dist/search-params-Wg-0FsMj.js +0 -148
- package/dist/search-params-Wg-0FsMj.js.map +0 -1
- package/dist/server-BUuf7XPZ.js.map +0 -1
- package/dist/static-loader-C_en-4v8.js.map +0 -1
- package/dist/store-Cy4EEyZ7.js +0 -439
- package/dist/store-Cy4EEyZ7.js.map +0 -1
- package/dist/trusted-g_zUJbh2.js.map +0 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { o as routeContext } from "./context-CU4Fpn5a.js";
|
|
2
|
+
//#region src/runtime/produce-collections.ts
|
|
3
|
+
/** Set by the first draft of a collection. */
|
|
4
|
+
let host = null;
|
|
5
|
+
function latest$1(state) {
|
|
6
|
+
return state.copy ?? state.base;
|
|
7
|
+
}
|
|
8
|
+
function stateOf(draft) {
|
|
9
|
+
return host.getDraftState(draft);
|
|
10
|
+
}
|
|
11
|
+
/** The draft of a value of the base, or the value itself when it is not one. */
|
|
12
|
+
function read(state, key, value) {
|
|
13
|
+
const base = state.base;
|
|
14
|
+
const original = base instanceof Map ? base.get(key) : key;
|
|
15
|
+
if (!host.isDraftable(value) || value !== original || base instanceof Set && !base.has(key)) return value;
|
|
16
|
+
let child = state.children.get(key);
|
|
17
|
+
if (!child) {
|
|
18
|
+
child = host.createDraftOf(value, state);
|
|
19
|
+
state.children.set(key, child);
|
|
20
|
+
}
|
|
21
|
+
return child.proxy;
|
|
22
|
+
}
|
|
23
|
+
/** The entries as they are now. A set gives its value twice, as `Set.prototype.entries` does. */
|
|
24
|
+
function* entriesOf(state) {
|
|
25
|
+
const source = latest$1(state);
|
|
26
|
+
for (const key of Array.from(source.keys())) {
|
|
27
|
+
const current = latest$1(state);
|
|
28
|
+
if (!current.has(key)) continue;
|
|
29
|
+
if (current instanceof Map) yield [key, read(state, key, current.get(key))];
|
|
30
|
+
else {
|
|
31
|
+
const value = read(state, key, key);
|
|
32
|
+
yield [value, value];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** A draft of a value of the set that the recipe got, as its base value. */
|
|
37
|
+
function unwrap(state, value) {
|
|
38
|
+
const draft = host.getDraftState(value);
|
|
39
|
+
return draft && state.children.get(draft.base) === draft ? draft.base : value;
|
|
40
|
+
}
|
|
41
|
+
function has(key) {
|
|
42
|
+
const state = stateOf(this);
|
|
43
|
+
return latest$1(state).has(state.base instanceof Set ? unwrap(state, key) : key);
|
|
44
|
+
}
|
|
45
|
+
function get(key) {
|
|
46
|
+
const state = stateOf(this);
|
|
47
|
+
return read(state, key, latest$1(state).get(key));
|
|
48
|
+
}
|
|
49
|
+
function set(key, value) {
|
|
50
|
+
const state = stateOf(this);
|
|
51
|
+
if (import.meta.env?.DEV && host.getDraftState(key)) throw new TypeError("A draft cannot be a key of a Map in $produce. Use the key of the base value instead.");
|
|
52
|
+
const source = latest$1(state);
|
|
53
|
+
const child = state.children.get(key);
|
|
54
|
+
if (child ? value === child.proxy || value === child.base && !child.modified : source.has(key) && Object.is(source.get(key), value)) return this;
|
|
55
|
+
host.prepare(state).set(key, value);
|
|
56
|
+
state.children.delete(key);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
function add(value) {
|
|
60
|
+
const state = stateOf(this);
|
|
61
|
+
const item = unwrap(state, value);
|
|
62
|
+
if (!latest$1(state).has(item)) host.prepare(state).add(item);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
function remove(key) {
|
|
66
|
+
const state = stateOf(this);
|
|
67
|
+
const item = state.base instanceof Set ? unwrap(state, key) : key;
|
|
68
|
+
if (!latest$1(state).has(item)) return false;
|
|
69
|
+
host.prepare(state);
|
|
70
|
+
state.copy.delete(item);
|
|
71
|
+
if (state.base instanceof Map) state.children.delete(item);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
function clear() {
|
|
75
|
+
const state = stateOf(this);
|
|
76
|
+
if (latest$1(state).size > 0) {
|
|
77
|
+
host.prepare(state).clear();
|
|
78
|
+
if (state.base instanceof Map) state.children.clear();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function* keys() {
|
|
82
|
+
for (const [key] of entriesOf(stateOf(this))) yield key;
|
|
83
|
+
}
|
|
84
|
+
function* values() {
|
|
85
|
+
for (const [, value] of entriesOf(stateOf(this))) yield value;
|
|
86
|
+
}
|
|
87
|
+
function entries() {
|
|
88
|
+
return entriesOf(stateOf(this));
|
|
89
|
+
}
|
|
90
|
+
function forEach(callback, thisArg) {
|
|
91
|
+
for (const [key, value] of entriesOf(stateOf(this))) callback.call(thisArg, value, key, this);
|
|
92
|
+
}
|
|
93
|
+
const mapMethods = {
|
|
94
|
+
get,
|
|
95
|
+
set,
|
|
96
|
+
has,
|
|
97
|
+
delete: remove,
|
|
98
|
+
clear,
|
|
99
|
+
keys,
|
|
100
|
+
values,
|
|
101
|
+
entries,
|
|
102
|
+
forEach,
|
|
103
|
+
[Symbol.iterator]: entries
|
|
104
|
+
};
|
|
105
|
+
const setMethods = {
|
|
106
|
+
add,
|
|
107
|
+
has,
|
|
108
|
+
delete: remove,
|
|
109
|
+
clear,
|
|
110
|
+
keys: values,
|
|
111
|
+
values,
|
|
112
|
+
entries,
|
|
113
|
+
forEach,
|
|
114
|
+
[Symbol.iterator]: values
|
|
115
|
+
};
|
|
116
|
+
/** The methods that take another set, run on the latest set. Older engines do not have them. */
|
|
117
|
+
for (const name of [
|
|
118
|
+
"union",
|
|
119
|
+
"intersection",
|
|
120
|
+
"difference",
|
|
121
|
+
"symmetricDifference",
|
|
122
|
+
"isSubsetOf",
|
|
123
|
+
"isSupersetOf",
|
|
124
|
+
"isDisjointFrom"
|
|
125
|
+
]) {
|
|
126
|
+
const method = Set.prototype[name];
|
|
127
|
+
if (typeof method === "function") setMethods[name] = function(other) {
|
|
128
|
+
return method.call(latest$1(stateOf(this)), other);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** The draft of a `Map` or a `Set`. It copies the collection on the first change. */
|
|
132
|
+
function createCollectionDraft(base, parent, context) {
|
|
133
|
+
host = context;
|
|
134
|
+
const state = {
|
|
135
|
+
base,
|
|
136
|
+
copy: void 0,
|
|
137
|
+
parent,
|
|
138
|
+
children: /* @__PURE__ */ new Map(),
|
|
139
|
+
modified: false,
|
|
140
|
+
final: void 0
|
|
141
|
+
};
|
|
142
|
+
const methods = base instanceof Map ? mapMethods : setMethods;
|
|
143
|
+
const target = base instanceof Map ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
|
|
144
|
+
state.proxy = new Proxy(target, { get(_, key) {
|
|
145
|
+
if (key === host.draft) return state;
|
|
146
|
+
if (key === "size") return latest$1(state).size;
|
|
147
|
+
if (Object.hasOwn(methods, key)) return methods[key];
|
|
148
|
+
return Reflect.get(target, key, target);
|
|
149
|
+
} });
|
|
150
|
+
return state;
|
|
151
|
+
}
|
|
152
|
+
/** The final value of a modified map or set: a copy that has the final values of its drafts. */
|
|
153
|
+
function finalizeCollection(state) {
|
|
154
|
+
const copy = state.copy;
|
|
155
|
+
if (copy instanceof Map) {
|
|
156
|
+
for (const [key, child] of state.children) if (copy.get(key) === child.base) copy.set(key, host.finalize(child));
|
|
157
|
+
for (const [key, value] of copy) {
|
|
158
|
+
const draft = host.getDraftState(value);
|
|
159
|
+
if (draft) copy.set(key, host.finalize(draft));
|
|
160
|
+
}
|
|
161
|
+
return copy;
|
|
162
|
+
}
|
|
163
|
+
const result = /* @__PURE__ */ new Set();
|
|
164
|
+
for (const value of copy) {
|
|
165
|
+
const child = host.getDraftState(value) ?? state.children.get(value);
|
|
166
|
+
result.add(child ? host.finalize(child) : value);
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
/** Finalizes the drafts inside a map or set that the recipe returned. */
|
|
171
|
+
function resolveCollection(value, resolve) {
|
|
172
|
+
if (value instanceof Map) {
|
|
173
|
+
for (const [key, item] of value) value.set(key, resolve(item));
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
const items = [...value];
|
|
177
|
+
let changed = false;
|
|
178
|
+
const resolved = [];
|
|
179
|
+
for (const item of items) {
|
|
180
|
+
const next = resolve(item);
|
|
181
|
+
changed ||= next !== item;
|
|
182
|
+
resolved.push(next);
|
|
183
|
+
}
|
|
184
|
+
if (changed) {
|
|
185
|
+
value.clear();
|
|
186
|
+
for (const item of resolved) value.add(item);
|
|
187
|
+
}
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/runtime/produce.ts
|
|
192
|
+
const DRAFT = Symbol("brumate.draft");
|
|
193
|
+
/**
|
|
194
|
+
* Plain objects, arrays, maps and sets can be drafted. Other values, such as
|
|
195
|
+
* instances of a class, are used as they are.
|
|
196
|
+
*/
|
|
197
|
+
function isDraftable(value) {
|
|
198
|
+
if (typeof value !== "object" || value === null) return false;
|
|
199
|
+
if (Array.isArray(value)) return true;
|
|
200
|
+
const prototype = Object.getPrototypeOf(value);
|
|
201
|
+
return prototype === Object.prototype || prototype === null || prototype === Map.prototype || prototype === Set.prototype;
|
|
202
|
+
}
|
|
203
|
+
function latest(state) {
|
|
204
|
+
return state.copy ?? state.base;
|
|
205
|
+
}
|
|
206
|
+
/** Copies a value and its parents on the first change. */
|
|
207
|
+
function prepare(state) {
|
|
208
|
+
for (let current = state; current && !current.modified; current = current.parent) {
|
|
209
|
+
current.modified = true;
|
|
210
|
+
const base = current.base;
|
|
211
|
+
if (Array.isArray(base)) current.copy = [...base];
|
|
212
|
+
else if (base instanceof Map) current.copy = new Map(base);
|
|
213
|
+
else if (base instanceof Set) current.copy = new Set(base);
|
|
214
|
+
else current.copy = { ...base };
|
|
215
|
+
}
|
|
216
|
+
return state.copy;
|
|
217
|
+
}
|
|
218
|
+
function getDraftState(value) {
|
|
219
|
+
return typeof value === "object" && value !== null ? value[DRAFT] : void 0;
|
|
220
|
+
}
|
|
221
|
+
/** The draft of a value that `isDraftable` accepts. */
|
|
222
|
+
function createDraftOf(base, parent) {
|
|
223
|
+
return base instanceof Map || base instanceof Set ? createCollectionDraft(base, parent, HOST) : createDraft(base, parent);
|
|
224
|
+
}
|
|
225
|
+
const HOST = {
|
|
226
|
+
draft: DRAFT,
|
|
227
|
+
createDraftOf,
|
|
228
|
+
finalize,
|
|
229
|
+
getDraftState,
|
|
230
|
+
isDraftable,
|
|
231
|
+
prepare
|
|
232
|
+
};
|
|
233
|
+
function createDraft(base, parent) {
|
|
234
|
+
const state = {
|
|
235
|
+
base,
|
|
236
|
+
copy: void 0,
|
|
237
|
+
parent,
|
|
238
|
+
children: /* @__PURE__ */ new Map(),
|
|
239
|
+
modified: false,
|
|
240
|
+
final: void 0
|
|
241
|
+
};
|
|
242
|
+
const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));
|
|
243
|
+
state.proxy = new Proxy(target, {
|
|
244
|
+
get(_, key) {
|
|
245
|
+
if (key === DRAFT) return state;
|
|
246
|
+
const source = latest(state);
|
|
247
|
+
const value = source[key];
|
|
248
|
+
if (!Object.hasOwn(source, key) || !isDraftable(value) || value !== state.base[key]) return value;
|
|
249
|
+
let child = state.children.get(key);
|
|
250
|
+
if (!child) {
|
|
251
|
+
child = createDraftOf(value, state);
|
|
252
|
+
state.children.set(key, child);
|
|
253
|
+
}
|
|
254
|
+
return child.proxy;
|
|
255
|
+
},
|
|
256
|
+
set(_, key, value) {
|
|
257
|
+
const source = latest(state);
|
|
258
|
+
const child = state.children.get(key);
|
|
259
|
+
if (child ? value === child.proxy || value === child.base && !child.modified : Object.is(source[key], value) && Object.hasOwn(source, key)) return true;
|
|
260
|
+
prepare(state)[key] = value;
|
|
261
|
+
state.children.delete(key);
|
|
262
|
+
return true;
|
|
263
|
+
},
|
|
264
|
+
deleteProperty(_, key) {
|
|
265
|
+
if (Object.hasOwn(latest(state), key)) {
|
|
266
|
+
delete prepare(state)[key];
|
|
267
|
+
state.children.delete(key);
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
},
|
|
271
|
+
has(_, key) {
|
|
272
|
+
return key in latest(state);
|
|
273
|
+
},
|
|
274
|
+
ownKeys() {
|
|
275
|
+
return Reflect.ownKeys(latest(state));
|
|
276
|
+
},
|
|
277
|
+
getOwnPropertyDescriptor(_, key) {
|
|
278
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);
|
|
279
|
+
if (descriptor && key !== "length") {
|
|
280
|
+
descriptor.configurable = true;
|
|
281
|
+
descriptor.writable = true;
|
|
282
|
+
}
|
|
283
|
+
return descriptor;
|
|
284
|
+
},
|
|
285
|
+
defineProperty(_, key, descriptor) {
|
|
286
|
+
prepare(state);
|
|
287
|
+
return Reflect.defineProperty(state.copy, key, descriptor);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return state;
|
|
291
|
+
}
|
|
292
|
+
/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */
|
|
293
|
+
function finalize(state) {
|
|
294
|
+
if (state.final !== void 0) return state.final;
|
|
295
|
+
if (!state.modified) {
|
|
296
|
+
for (const child of state.children.values()) if (child.modified) {
|
|
297
|
+
prepare(state);
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
if (!state.modified) return state.base;
|
|
301
|
+
}
|
|
302
|
+
if (state.base instanceof Map || state.base instanceof Set) {
|
|
303
|
+
state.final = finalizeCollection(state);
|
|
304
|
+
return state.final;
|
|
305
|
+
}
|
|
306
|
+
const copy = state.copy;
|
|
307
|
+
state.final = copy;
|
|
308
|
+
for (const [key, child] of state.children) if (copy[key] === child.base) copy[key] = finalize(child);
|
|
309
|
+
for (const key of Reflect.ownKeys(copy)) {
|
|
310
|
+
const draft = getDraftState(copy[key]);
|
|
311
|
+
if (draft) copy[key] = finalize(draft);
|
|
312
|
+
}
|
|
313
|
+
return copy;
|
|
314
|
+
}
|
|
315
|
+
/** The signals that `warnUndrafted` has already named. */
|
|
316
|
+
const warned = /* @__PURE__ */ new Set();
|
|
317
|
+
/** In dev, tells that an object the recipe could not draft cannot update anything. */
|
|
318
|
+
function warnUndrafted(base, name) {
|
|
319
|
+
if (!import.meta.env?.DEV) return;
|
|
320
|
+
if (typeof base !== "object" || base === null) return;
|
|
321
|
+
const key = name ?? "";
|
|
322
|
+
if (warned.has(key)) return;
|
|
323
|
+
warned.add(key);
|
|
324
|
+
const kind = base.constructor?.name ?? "object";
|
|
325
|
+
const target = name ?? "value";
|
|
326
|
+
console.warn(`$produce${name === void 0 ? "" : `(${name})`} changed a ${kind} and returned nothing. Nothing updates. Return a new value, such as new ${kind}(${target}).`);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Returns a changed copy of a value. The recipe changes a draft as if it
|
|
330
|
+
* were the value. Objects that it does not change keep their identity, and
|
|
331
|
+
* if it changes nothing, the value itself is returned. A recipe can also
|
|
332
|
+
* return a new value. Plain objects, arrays, maps and sets are drafted.
|
|
333
|
+
*/
|
|
334
|
+
function produce(base, recipe, name) {
|
|
335
|
+
if (!isDraftable(base)) {
|
|
336
|
+
const result = recipe(base);
|
|
337
|
+
if (result === void 0) {
|
|
338
|
+
warnUndrafted(base, name);
|
|
339
|
+
return base;
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
const state = createDraftOf(base, void 0);
|
|
344
|
+
const result = recipe(state.proxy);
|
|
345
|
+
if (result !== void 0 && result !== state.proxy) return resolve(result, /* @__PURE__ */ new Set());
|
|
346
|
+
return finalize(state);
|
|
347
|
+
}
|
|
348
|
+
/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */
|
|
349
|
+
function resolve(value, seen) {
|
|
350
|
+
const draft = getDraftState(value);
|
|
351
|
+
if (draft) return finalize(draft);
|
|
352
|
+
if (!isDraftable(value) || seen.has(value)) return value;
|
|
353
|
+
seen.add(value);
|
|
354
|
+
if (value instanceof Map || value instanceof Set) return resolveCollection(value, (item) => resolve(item, seen));
|
|
355
|
+
for (const key of Reflect.ownKeys(value)) value[key] = resolve(value[key], seen);
|
|
356
|
+
return value;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/runtime/search-params.ts
|
|
360
|
+
/** The value of a parameter in a query string: its text parsed, or the default when it is absent. */
|
|
361
|
+
function readParam(search, name, options) {
|
|
362
|
+
const text = search.get(name);
|
|
363
|
+
if (text === null) return options?.default ?? null;
|
|
364
|
+
return options?.parse ? options.parse(text) : text;
|
|
365
|
+
}
|
|
366
|
+
/** The text of a value in the URL, or null for the default, which leaves the parameter out. */
|
|
367
|
+
function writeParam(value, options) {
|
|
368
|
+
const own = formatParam(value, options);
|
|
369
|
+
return own === formatParam(options?.default, options) ? null : own;
|
|
370
|
+
}
|
|
371
|
+
function formatParam(value, options) {
|
|
372
|
+
if (value === null || value === void 0) return null;
|
|
373
|
+
return options?.serialize ? options.serialize(value) : String(value);
|
|
374
|
+
}
|
|
375
|
+
/** `$searchParam` on the server: the parameter of the request's URL. */
|
|
376
|
+
function searchParam(context, name, options) {
|
|
377
|
+
return readParam(context.consume(routeContext, 0).search, name, options);
|
|
378
|
+
}
|
|
379
|
+
//#endregion
|
|
380
|
+
export { produce as i, searchParam as n, writeParam as r, readParam as t };
|
|
381
|
+
|
|
382
|
+
//# sourceMappingURL=search-params-qGERTLi3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-params-qGERTLi3.js","names":["latest"],"sources":["../src/runtime/produce-collections.ts","../src/runtime/produce.ts","../src/runtime/search-params.ts"],"sourcesContent":["import type { DraftChild, DraftState } from './produce.ts';\n\n/** What the collections need from `produce.ts`, passed in so the two files do not import each other. */\nexport interface Host {\n draft: symbol;\n createDraftOf(base: object, parent: DraftState | undefined): DraftChild;\n finalize(state: DraftState): unknown;\n getDraftState(value: unknown): DraftState | undefined;\n isDraftable(value: unknown): value is object;\n prepare(state: DraftState): object;\n}\n\n/** Set by the first draft of a collection. */\nlet host = null as unknown as Host;\n\ntype Collection = Map<unknown, unknown> | Set<unknown>;\n\nfunction latest(state: DraftState): Collection {\n return (state.copy ?? state.base) as Collection;\n}\n\nfunction stateOf(draft: object): DraftState {\n return host.getDraftState(draft)!;\n}\n\n/** The draft of a value of the base, or the value itself when it is not one. */\nfunction read(state: DraftState, key: unknown, value: unknown): unknown {\n const base = state.base;\n const original = base instanceof Map ? base.get(key) : key;\n if (!host.isDraftable(value) || value !== original || (base instanceof Set && !base.has(key))) {\n return value;\n }\n let child = state.children.get(key);\n if (!child) {\n child = host.createDraftOf(value, state);\n state.children.set(key, child);\n }\n return child.proxy;\n}\n\n/** The entries as they are now. A set gives its value twice, as `Set.prototype.entries` does. */\nfunction* entriesOf(state: DraftState): Generator<[unknown, unknown]> {\n const source = latest(state);\n for (const key of Array.from(source.keys())) {\n const current = latest(state);\n if (!current.has(key)) {\n continue;\n }\n if (current instanceof Map) {\n yield [key, read(state, key, current.get(key))];\n } else {\n const value = read(state, key, key);\n yield [value, value];\n }\n }\n}\n\n/** A draft of a value of the set that the recipe got, as its base value. */\nfunction unwrap(state: DraftState, value: unknown): unknown {\n const draft = host.getDraftState(value);\n return draft && state.children.get(draft.base) === draft ? draft.base : value;\n}\n\nfunction has(this: object, key: unknown): boolean {\n const state = stateOf(this);\n return latest(state).has(state.base instanceof Set ? unwrap(state, key) : key);\n}\n\nfunction get(this: object, key: unknown): unknown {\n const state = stateOf(this);\n const source = latest(state) as Map<unknown, unknown>;\n return read(state, key, source.get(key));\n}\n\nfunction set(this: object, key: unknown, value: unknown): object {\n const state = stateOf(this);\n // @ts-expect-error `ImportMeta` has no `env` without the types of Vite. The literal form is what Vite replaces.\n if (import.meta.env?.DEV && host.getDraftState(key)) {\n throw new TypeError(\n 'A draft cannot be a key of a Map in $produce. Use the key of the base value instead.',\n );\n }\n const source = latest(state) as Map<unknown, unknown>;\n const child = state.children.get(key);\n // A value that replaces a drafted value drops the changes made through the draft.\n if (\n child\n ? value === child.proxy || (value === child.base && !child.modified)\n : source.has(key) && Object.is(source.get(key), value)\n ) {\n return this;\n }\n (host.prepare(state) as Map<unknown, unknown>).set(key, value);\n state.children.delete(key);\n return this;\n}\n\nfunction add(this: object, value: unknown): object {\n const state = stateOf(this);\n const item = unwrap(state, value);\n if (!latest(state).has(item)) {\n (host.prepare(state) as Set<unknown>).add(item);\n }\n return this;\n}\n\nfunction remove(this: object, key: unknown): boolean {\n const state = stateOf(this);\n const item = state.base instanceof Set ? unwrap(state, key) : key;\n if (!latest(state).has(item)) {\n return false;\n }\n host.prepare(state);\n (state.copy as Collection).delete(item);\n if (state.base instanceof Map) {\n state.children.delete(item);\n }\n return true;\n}\n\nfunction clear(this: object): void {\n const state = stateOf(this);\n if (latest(state).size > 0) {\n (host.prepare(state) as Collection).clear();\n if (state.base instanceof Map) {\n state.children.clear();\n }\n }\n}\n\nfunction* keys(this: object): Generator<unknown> {\n for (const [key] of entriesOf(stateOf(this))) {\n yield key;\n }\n}\n\nfunction* values(this: object): Generator<unknown> {\n for (const [, value] of entriesOf(stateOf(this))) {\n yield value;\n }\n}\n\nfunction entries(this: object): Generator<[unknown, unknown]> {\n return entriesOf(stateOf(this));\n}\n\nfunction forEach(\n this: object,\n callback: (value: unknown, key: unknown, collection: object) => void,\n thisArg?: unknown,\n): void {\n for (const [key, value] of entriesOf(stateOf(this))) {\n callback.call(thisArg, value, key, this);\n }\n}\n\nconst mapMethods: Record<PropertyKey, unknown> = {\n get,\n set,\n has,\n delete: remove,\n clear,\n keys,\n values,\n entries,\n forEach,\n [Symbol.iterator]: entries,\n};\n\nconst setMethods: Record<PropertyKey, unknown> = {\n add,\n has,\n delete: remove,\n clear,\n keys: values,\n values,\n entries,\n forEach,\n [Symbol.iterator]: values,\n};\n\n/** The methods that take another set, run on the latest set. Older engines do not have them. */\nfor (const name of [\n 'union',\n 'intersection',\n 'difference',\n 'symmetricDifference',\n 'isSubsetOf',\n 'isSupersetOf',\n 'isDisjointFrom',\n]) {\n const method = (Set.prototype as unknown as Record<string, unknown>)[name];\n if (typeof method === 'function') {\n setMethods[name] = function (this: object, other: unknown): unknown {\n return method.call(latest(stateOf(this)), other);\n };\n }\n}\n\n/** The draft of a `Map` or a `Set`. It copies the collection on the first change. */\nexport function createCollectionDraft(\n base: Collection,\n parent: DraftState | undefined,\n context: Host,\n): DraftChild {\n host = context;\n const state = {\n base,\n copy: undefined,\n parent,\n children: new Map(),\n modified: false,\n final: undefined,\n } as DraftChild;\n const methods = base instanceof Map ? mapMethods : setMethods;\n // An empty target of the same type, so `instanceof` works. The traps answer from the state.\n const target = base instanceof Map ? new Map() : new Set();\n state.proxy = new Proxy(target, {\n get(_, key) {\n if (key === host.draft) {\n return state;\n }\n if (key === 'size') {\n return latest(state).size;\n }\n if (Object.hasOwn(methods, key)) {\n return methods[key];\n }\n return Reflect.get(target, key, target);\n },\n });\n return state;\n}\n\n/** The final value of a modified map or set: a copy that has the final values of its drafts. */\nexport function finalizeCollection(state: DraftState): Collection {\n const copy = state.copy as Collection;\n if (copy instanceof Map) {\n for (const [key, child] of state.children) {\n if (copy.get(key) === child.base) {\n copy.set(key, host.finalize(child));\n }\n }\n // A draft can be at another key than the one it came from.\n for (const [key, value] of copy) {\n const draft = host.getDraftState(value);\n if (draft) {\n copy.set(key, host.finalize(draft));\n }\n }\n return copy;\n }\n // The values of a set cannot change in place, so a set is made again in the same order.\n const result = new Set();\n for (const value of copy) {\n const child = host.getDraftState(value) ?? state.children.get(value);\n result.add(child ? host.finalize(child) : value);\n }\n return result;\n}\n\n/** Finalizes the drafts inside a map or set that the recipe returned. */\nexport function resolveCollection(\n value: Collection,\n resolve: (item: unknown) => unknown,\n): Collection {\n if (value instanceof Map) {\n for (const [key, item] of value) {\n value.set(key, resolve(item));\n }\n return value;\n }\n const items = [...value];\n let changed = false;\n const resolved: unknown[] = [];\n for (const item of items) {\n const next = resolve(item);\n changed ||= next !== item;\n resolved.push(next);\n }\n if (changed) {\n value.clear();\n for (const item of resolved) {\n value.add(item);\n }\n }\n return value;\n}\n","import {\n createCollectionDraft,\n finalizeCollection,\n resolveCollection,\n type Host,\n} from './produce-collections.ts';\n\nconst DRAFT = Symbol('brumate.draft');\n\ntype Plain = Record<PropertyKey, unknown>;\n\nexport interface DraftState {\n /** A plain object, an array, a `Map` or a `Set`. */\n base: object;\n /** A shallow copy, made on the first change. */\n copy: object | undefined;\n parent: DraftState | undefined;\n /** Drafts of the values inside, by key. A set has its values as keys. */\n children: Map<unknown, DraftChild>;\n modified: boolean;\n /** The value that `finalize` returned, so a draft that was moved is finalized once. */\n final: unknown;\n}\n\nexport type DraftChild = DraftState & { proxy: object };\n\n/**\n * Plain objects, arrays, maps and sets can be drafted. Other values, such as\n * instances of a class, are used as they are.\n */\nexport function isDraftable(value: unknown): value is object {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n const prototype = Object.getPrototypeOf(value);\n return (\n prototype === Object.prototype ||\n prototype === null ||\n prototype === Map.prototype ||\n prototype === Set.prototype\n );\n}\n\nfunction latest(state: DraftState): Plain {\n return (state.copy ?? state.base) as Plain;\n}\n\n/** Copies a value and its parents on the first change. */\nexport function prepare(state: DraftState): object {\n for (\n let current: DraftState | undefined = state;\n current && !current.modified;\n current = current.parent\n ) {\n current.modified = true;\n const base = current.base;\n if (Array.isArray(base)) {\n current.copy = [...base];\n } else if (base instanceof Map) {\n current.copy = new Map(base);\n } else if (base instanceof Set) {\n current.copy = new Set(base);\n } else {\n current.copy = { ...base };\n }\n }\n return state.copy!;\n}\n\nexport function getDraftState(value: unknown): DraftState | undefined {\n return typeof value === 'object' && value !== null\n ? ((value as Plain)[DRAFT] as DraftState | undefined)\n : undefined;\n}\n\n/** The draft of a value that `isDraftable` accepts. */\nexport function createDraftOf(base: object, parent: DraftState | undefined): DraftChild {\n return base instanceof Map || base instanceof Set\n ? createCollectionDraft(base, parent, HOST)\n : createDraft(base, parent);\n}\n\nconst HOST: Host = { draft: DRAFT, createDraftOf, finalize, getDraftState, isDraftable, prepare };\n\nfunction createDraft(base: object, parent: DraftState | undefined): DraftChild {\n const state = {\n base,\n copy: undefined,\n parent,\n children: new Map(),\n modified: false,\n final: undefined,\n } as DraftChild;\n // An empty target, so the draft can report the keys of the copy.\n const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));\n state.proxy = new Proxy(target, {\n get(_, key) {\n if (key === DRAFT) {\n return state;\n }\n const source = latest(state);\n const value = source[key];\n if (\n !Object.hasOwn(source, key) ||\n !isDraftable(value) ||\n value !== (state.base as Plain)[key]\n ) {\n return value;\n }\n let child = state.children.get(key);\n if (!child) {\n child = createDraftOf(value, state);\n state.children.set(key, child);\n }\n return child.proxy;\n },\n set(_, key, value) {\n const source = latest(state);\n const child = state.children.get(key);\n if (\n child\n ? value === child.proxy || (value === child.base && !child.modified)\n : Object.is(source[key], value) && Object.hasOwn(source, key)\n ) {\n return true;\n }\n (prepare(state) as Plain)[key] = value;\n state.children.delete(key);\n return true;\n },\n deleteProperty(_, key) {\n if (Object.hasOwn(latest(state), key)) {\n delete (prepare(state) as Plain)[key];\n state.children.delete(key);\n }\n return true;\n },\n has(_, key) {\n return key in latest(state);\n },\n ownKeys() {\n return Reflect.ownKeys(latest(state));\n },\n getOwnPropertyDescriptor(_, key) {\n const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);\n if (descriptor && key !== 'length') {\n descriptor.configurable = true;\n descriptor.writable = true;\n }\n return descriptor;\n },\n defineProperty(_, key, descriptor) {\n prepare(state);\n return Reflect.defineProperty(state.copy!, key, descriptor);\n },\n });\n return state;\n}\n\n/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */\nexport function finalize(state: DraftState): unknown {\n if (state.final !== undefined) {\n return state.final;\n }\n if (!state.modified) {\n // A child can change without its parent being copied yet.\n for (const child of state.children.values()) {\n if (child.modified) {\n prepare(state);\n break;\n }\n }\n if (!state.modified) {\n return state.base;\n }\n }\n if (state.base instanceof Map || state.base instanceof Set) {\n state.final = finalizeCollection(state);\n return state.final;\n }\n const copy = state.copy as Plain;\n state.final = copy;\n for (const [key, child] of state.children) {\n if (copy[key as PropertyKey] === child.base) {\n copy[key as PropertyKey] = finalize(child);\n }\n }\n // Drafts can also be assigned to other keys, such as when an array is reordered.\n for (const key of Reflect.ownKeys(copy)) {\n const draft = getDraftState(copy[key]);\n if (draft) {\n copy[key] = finalize(draft);\n }\n }\n return copy;\n}\n\n/** The signals that `warnUndrafted` has already named. */\nconst warned = new Set<string>();\n\n/** In dev, tells that an object the recipe could not draft cannot update anything. */\nfunction warnUndrafted(base: unknown, name: string | undefined): void {\n // @ts-expect-error `ImportMeta` has no `env` without the types of Vite. The literal form is what Vite replaces.\n if (!import.meta.env?.DEV) {\n return;\n }\n if (typeof base !== 'object' || base === null) {\n return;\n }\n const key = name ?? '';\n if (warned.has(key)) {\n return;\n }\n warned.add(key);\n const kind = (base as object).constructor?.name ?? 'object';\n const target = name ?? 'value';\n console.warn(\n `$produce${name === undefined ? '' : `(${name})`} changed a ${kind} and returned nothing. Nothing updates. Return a new value, such as new ${kind}(${target}).`,\n );\n}\n\n/**\n * Returns a changed copy of a value. The recipe changes a draft as if it\n * were the value. Objects that it does not change keep their identity, and\n * if it changes nothing, the value itself is returned. A recipe can also\n * return a new value. Plain objects, arrays, maps and sets are drafted.\n */\nexport function produce<T>(base: T, recipe: (draft: T) => T | void, name?: string): T {\n if (!isDraftable(base)) {\n const result = recipe(base);\n if (result === undefined) {\n warnUndrafted(base, name);\n return base;\n }\n return result;\n }\n const state = createDraftOf(base, undefined);\n const result = recipe(state.proxy as T);\n if (result !== undefined && result !== state.proxy) {\n return resolve(result, new Set()) as T;\n }\n return finalize(state) as T;\n}\n\n/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */\nfunction resolve(value: unknown, seen: Set<unknown>): unknown {\n const draft = getDraftState(value);\n if (draft) {\n return finalize(draft);\n }\n if (!isDraftable(value) || seen.has(value)) {\n return value;\n }\n seen.add(value);\n if (value instanceof Map || value instanceof Set) {\n return resolveCollection(value, (item) => resolve(item, seen));\n }\n for (const key of Reflect.ownKeys(value)) {\n (value as Plain)[key] = resolve((value as Plain)[key], seen);\n }\n return value;\n}\n","// `$searchParam`: the value of a parameter of the query string. The server and the browser read\n// it the same way, and the browser writes it back with `client/search.ts`.\nimport type { SearchParamOptions } from './signals.ts';\nimport { routeContext } from './context.ts';\nimport type { Context } from './context.ts';\n\n/** The value of a parameter in a query string: its text parsed, or the default when it is absent. */\nexport function readParam(\n search: URLSearchParams,\n name: string,\n options?: SearchParamOptions<unknown>,\n): unknown {\n const text = search.get(name);\n if (text === null) {\n return options?.default ?? null;\n }\n return options?.parse ? options.parse(text) : text;\n}\n\n/** The text of a value in the URL, or null for the default, which leaves the parameter out. */\nexport function writeParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n const own = formatParam(value, options);\n return own === formatParam(options?.default, options) ? null : own;\n}\n\nfunction formatParam(value: unknown, options?: SearchParamOptions<unknown>): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n return options?.serialize ? options.serialize(value) : String(value);\n}\n\n/** `$searchParam` on the server: the parameter of the request's URL. */\nexport function searchParam(\n context: { consume<T>(context: Context<T>, scope: number): T },\n name: string,\n options?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gB,SAAsD;CACzF,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,OAAO;CAET,OAAO,SAAS,YAAY,QAAQ,UAAU,KAAK,IAAI,OAAO,KAAK;AACrE;;AAGA,SAAgB,YACd,SACA,MACA,SACS;CACT,OAAO,UAAU,QAAQ,QAAQ,cAAc,CAAC,CAAC,CAAC,QAAQ,MAAM,OAAO;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as BridgeDataError, n as callPlugins, r as disabledFeatures, i as plugins, a as serialOptions, o as syncPlugins, s as uploadPlugin } from "./serial-
|
|
1
|
+
export { t as BridgeDataError, n as callPlugins, r as disabledFeatures, i as plugins, a as serialOptions, o as syncPlugins, s as uploadPlugin } from "./serial-Cj6pDGOq.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { S as stateValues, b as onValuePlugin, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, n as CHILDREN_REF, s as PARTS, y as onSerialOptions } from "./shared-
|
|
1
|
+
import { i as HAS_BRIDGES } from "./features-Cte5aj20.js";
|
|
2
|
+
import { n as MODIFIERS } from "./events-BDVITj3P.js";
|
|
3
|
+
import { S as rawHTML, g as isRaw, h as isInternal } from "./html-BYuHDvxy.js";
|
|
4
|
+
import { m as isStore, u as isBridged } from "./store-DNr24Z8L.js";
|
|
5
|
+
import { S as stateValues, b as onValuePlugin, g as isSlotReference, h as isPropWrapper, i as ElementReference, m as isBinding, n as CHILDREN_REF, s as PARTS, y as onSerialOptions } from "./shared-CUBWrbiM.js";
|
|
6
6
|
import { Feature, createPlugin } from "seroval/shared";
|
|
7
7
|
import * as v from "seroval/validator";
|
|
8
8
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin } from "seroval-plugins/web";
|
|
@@ -516,4 +516,4 @@ onSerialOptions((options) => {
|
|
|
516
516
|
//#endregion
|
|
517
517
|
export { serialOptions as a, functionReferences as c, plugins as i, callPlugins as n, syncPlugins as o, disabledFeatures as r, uploadPlugin as s, BridgeDataError as t };
|
|
518
518
|
|
|
519
|
-
//# sourceMappingURL=serial-
|
|
519
|
+
//# sourceMappingURL=serial-Cj6pDGOq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serial-ioa17MuY.js","names":[],"sources":["../src/runtime/calls.ts","../src/runtime/serial.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/**\n * Client functions that the server passes on, such as function props, with\n * their references. Kept under a symbol of the registry, so two copies of the\n * runtime, such as a component's and the render context's, share it.\n */\nexport const functionReferences: WeakMap<object, FunctionReference> = ((\n globalThis as Record<symbol, WeakMap<object, FunctionReference> | undefined>\n)[Symbol.for('brumate.functionReferences')] ??= new WeakMap());\n\n/**\n * True for a file or a blob. One from another frame, or another DOM, is an\n * instance of another `Blob` class, so its methods tell instead.\n */\nexport function isBlob(value: unknown): value is Blob {\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n return true;\n }\n const blob = value as Partial<Blob> | null;\n return (\n typeof blob === 'object' &&\n blob !== null &&\n typeof blob.size === 'number' &&\n typeof blob.type === 'string' &&\n typeof blob.arrayBuffer === 'function' &&\n typeof blob.slice === 'function'\n );\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/shared';\nimport * as v from 'seroval/validator';\nimport {\n AbortSignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n RequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n} from 'seroval-plugins/web';\nimport type {\n Plugin,\n SerovalNode,\n StreamParsePluginContext,\n SyncParsePluginContext,\n} from 'seroval/shared';\nimport { type Internal, isInternal, isRaw, rawHTML } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { functionReferences, isBlob } from './calls.ts';\nimport { MODIFIERS } from './events.ts';\nimport { HAS_BRIDGES } from './features.ts';\nimport {\n CHILDREN_REF,\n ElementReference,\n PARTS,\n isBinding,\n isPropWrapper,\n isSlotReference,\n onSerialOptions,\n onValuePlugin,\n stateValues,\n} from './shared.ts';\nimport type { ChildrenReference, MemoError, PropPromise, ScopeId } from './shared.ts';\nimport type { ValuePlugin } from './values.ts';\nimport { isBridged, isStore } from './store.ts';\nimport type { Bridged, Store } from './store.ts';\nimport type { Binding, SlotReference } from './shared.ts';\nimport type { ComponentValue } from './shared.ts';\n\ntype ReferenceNode = { a: SerovalNode; b: SerovalNode; c?: SerovalNode; d?: SerovalNode };\n\n/** Serializes the parts of a node that are set, joined as call arguments. */\nfunction serializeParts(\n parts: (SerovalNode | undefined)[],\n ctx: { serialize(node: SerovalNode): string },\n): string {\n const written: string[] = [];\n for (const part of parts) {\n if (part !== undefined) {\n written.push(ctx.serialize(part));\n }\n }\n return written.join(',');\n}\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 function 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/** A scope ID, which is a number or a string. */\nconst scopeId = v.union(v.string, v.number);\n\n/** The index of a file in the form: a whole number from 0. */\nfunction isIndex(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 0;\n}\n\n/** An array whose items are not checked: the plugin that reads them checks them. */\nfunction isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/** The arguments of a handler: an array, or null when only modifiers follow. */\nfunction isArgs(value: unknown): value is unknown[] | null {\n return value === null || Array.isArray(value);\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 validate: { a: scopeId, b: v.number },\n});\n\nconst SlotPlugin = createPlugin<SlotReference, ReferenceNode>({\n tag: 'brumate/slot',\n skipPlainObjects: true,\n test: (value) => isSlotReference(value),\n parse: parsers((value) => ({ a: value.scope, b: value.slot })),\n serialize: (node, ctx) => `$b.l(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.l(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n validate: { a: scopeId, b: v.number },\n});\n\n/** A binding that a rest prop holds: its value, and the scope and the slot it writes. */\nconst BindingPlugin = createPlugin<Binding, ReferenceNode>({\n tag: 'brumate/binding',\n skipPlainObjects: true,\n test: (value) => isBinding(value),\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.value, b: value.ref.scope, c: value.ref.slot };\n // The setter of `$bind(name, fn)`.\n if (value.set !== undefined) {\n node.d = value.set;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.b(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.b(\n ctx.deserialize(node.a),\n ctx.deserialize<number>(node.b!),\n ctx.deserialize<number>(node.c!),\n node.d === undefined ? undefined : ctx.deserialize(node.d),\n ),\n validate: { b: scopeId, c: v.number },\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 // The arguments of a handler that `$handler` made go with it.\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The modifiers of its wrappers, so a spread in markup that the browser renders writes them.\n const modifiers = (value as { [MODIFIERS]?: string[] })[MODIFIERS];\n if (reference.args !== undefined || modifiers) {\n node.c = reference.args ?? null;\n }\n if (modifiers) {\n node.d = modifiers;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.f(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.f(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<number>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<unknown[] | null>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<string[]>(node.d),\n ),\n validate: { a: v.string, b: scopeId, c: isArgs, d: v.array(v.string) },\n});\n\n/** A handler that merges the handlers of one event, as the parts that refer to client functions. */\nconst MergedPlugin = createPlugin<object, { a: SerovalNode }>({\n tag: 'brumate/merged',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && PARTS in value,\n parse: parsers((value) => {\n const parts: object[] = [];\n for (const part of (value as { [PARTS]: object[] })[PARTS]) {\n if (functionReferences.has(part)) {\n parts.push(part);\n }\n }\n return { a: parts };\n }),\n serialize: (node, ctx) => `$b.m(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a)),\n validate: { a: isArray },\n});\n\n/**\n * A value of an attribute that brumate writes, which a live rest prop can hold. The ones that\n * reach the page state are the scoped style attribute and `b-v`. The error \"holds a Internal\"\n * no longer catches any other, so a new one needs a check of its own.\n */\nconst InternalPlugin = createPlugin<Internal, { a: SerovalNode }>({\n tag: 'brumate/internal',\n skipPlainObjects: true,\n test: (value) => isInternal(value),\n parse: parsers((value) => ({ a: value.value })),\n serialize: (node, ctx) => `$b.i(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.i(ctx.deserialize(node.a)),\n});\n\n/** Children of a component, as the export that renders them in the browser. */\nconst ChildrenPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/children',\n skipPlainObjects: true,\n test: (value) => typeof value === 'object' && value !== null && CHILDREN_REF in value,\n parse: parsers((value) => {\n const reference = (value as { [CHILDREN_REF]: ChildrenReference })[CHILDREN_REF];\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The scope and the anchor of the insert where the server rendered them.\n if (reference.at !== undefined) {\n node.c = reference.at;\n node.d = reference.anchor;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.n(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.n(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<ScopeId>(node.b!),\n node.c === undefined ? undefined : ctx.deserialize<ScopeId>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n validate: { a: v.string, b: scopeId, c: scopeId, d: v.number },\n});\n\n/**\n * A memo that failed on the server. The page state holds its error, so a read in the browser\n * throws it, as a memo that failed there. The server writes the error that is safe to send. See\n * `stateValue`.\n */\nconst MemoErrorPlugin = createPlugin<MemoError, { e: SerovalNode }>({\n tag: 'brumate/memo-error',\n skipPlainObjects: true,\n // The server marks the errors it holds, so the copies of the runtime agree on them.\n test: (value) =>\n typeof value === 'object' && value !== null && Symbol.for('brumate.held') in value,\n parse: parsers((value) => ({ e: value.error })),\n serialize: (node, ctx) => `$b.x(${ctx.serialize(node.e)})`,\n deserialize: (node, ctx) => stateValues.x(ctx.deserialize(node.e)),\n});\n\n/** A promise prop in the page state. See `PropPromise`. */\nconst PropPromisePlugin = createPlugin<PropPromise, { p: SerovalNode }>({\n tag: 'brumate/prop-promise',\n skipPlainObjects: true,\n test: isPropWrapper,\n parse: parsers((value) => ({ p: value.promise })),\n serialize: (node, ctx) => `$b.q(${ctx.serialize(node.p)})`,\n deserialize: (node, ctx) => stateValues.q(ctx.deserialize(node.p)),\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 validate: { h: v.string },\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 validate: { c: v.string },\n});\n\n/**\n * A store of `brumate/store`: only its value crosses, and where `$toStore` made it, so the\n * browser makes a new store that the provider writes. Readers subscribe as their scopes resume.\n */\nconst StorePlugin = createPlugin<Store<unknown>, ReferenceNode>({\n tag: 'brumate/store',\n skipPlainObjects: true,\n test: isStore,\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.v };\n if (value.o) {\n node.b = value.o[0];\n node.c = value.o[1];\n if (value.o[2] !== undefined) {\n node.d = value.o[2];\n }\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.s(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.s(\n ctx.deserialize(node.a),\n node.b === undefined ? undefined : ctx.deserialize<ScopeId>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<number>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n validate: { b: scopeId, c: v.number, d: v.number },\n});\n\n/**\n * The index of a file or a blob, and what a part of multipart form data does\n * not keep: the type (an empty one arrives as `application/octet-stream`),\n * whether the value was a blob or a file (every part arrives as a file), and\n * the name (some characters are escaped) and `lastModified` of a file. Calls\n * from pages before these fields send only the index.\n */\ntype UploadNode = { i: SerovalNode; t?: SerovalNode; n?: SerovalNode; l?: SerovalNode };\n\nfunction isFile(value: Blob): value is File {\n const file = value as Partial<File>;\n return typeof file.name === 'string' && typeof file.lastModified === 'number';\n}\n\n/**\n * Files and blobs, which go only in the arguments of a call, as parts of\n * multipart form data named `file<index>`. The node holds the index. The\n * call passes `sent`, which gets each blob, and the server passes the form\n * that it `received`, whose files the indexes read. Without them, as in the\n * page state and in the answer of a call, a blob throws.\n */\nexport function uploadPlugin(sent?: Blob[], received?: FormData): Plugin<Blob, UploadNode> {\n return createPlugin<Blob, UploadNode>({\n tag: 'brumate/upload',\n skipPlainObjects: true,\n test: isBlob,\n // Only the fields that are set go in the node, so `K` names just the index.\n parse: parsers<Blob, 'i'>((value) => {\n if (!sent) {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n }\n const index = sent.push(value) - 1;\n if (isFile(value)) {\n return { i: index, t: value.type, n: value.name, l: value.lastModified };\n }\n return { i: index, t: value.type };\n }) as Plugin<Blob, UploadNode>['parse'],\n serialize: () => {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n },\n deserialize: (node, ctx) => {\n const file = received?.get(`file${ctx.deserialize<number>(node.i)}`);\n if (!(file instanceof Blob)) {\n throw new TypeError('A file of the call is missing');\n }\n // A page before the metadata fields sends only the index.\n if (node.t === undefined) {\n return file;\n }\n const type = ctx.deserialize<string>(node.t);\n // The new blob or file refers to the bytes of the part instead of copying them.\n if (node.n === undefined) {\n return new Blob([file], { type });\n }\n const name = ctx.deserialize<string>(node.n);\n const lastModified = node.l === undefined ? undefined : ctx.deserialize<number>(node.l);\n return new File([file], name, { type, lastModified });\n },\n validate: { i: isIndex, t: v.string, n: v.string, l: v.number },\n });\n}\n\n/**\n * The plugin of `AbortSignal` from seroval-plugins, which sends whether the\n * signal aborted and its reason. The one of seroval-plugins waits for a live\n * signal to abort, so a call with one would not be sent, and a page or an\n * answer with one would not end.\n */\nconst SignalPlugin: typeof AbortSignalPlugin = {\n ...AbortSignalPlugin,\n parse: {\n sync: AbortSignalPlugin.parse.sync,\n stream: AbortSignalPlugin.parse.sync,\n async: async (value, ctx) => (value.aborted ? { reason: await ctx.parse(value.reason) } : {}),\n },\n};\n\n/**\n * The plugin of `Request` from seroval-plugins, whose body streams in the\n * stream mode. A request with a stream body needs `duplex: 'half'`, or its\n * constructor throws, so the plugin adds it.\n */\nconst BodyRequestPlugin: typeof RequestPlugin = {\n ...RequestPlugin,\n serialize: (node, ctx) =>\n `new Request(${ctx.serialize(node.url)},Object.assign(${ctx.serialize(node.options)},{duplex:\"half\"}))`,\n deserialize: (node, ctx) =>\n new Request(\n ctx.deserialize(node.url) as string,\n {\n ...(ctx.deserialize(node.options) as RequestInit),\n duplex: 'half',\n } as RequestInit,\n ),\n};\n\n/**\n * The error of a store of `bridge()` whose data the page state cannot send. It holds the store as\n * `value`, so the server finds the context or the prop that sends it.\n */\nexport class BridgeDataError extends Error {\n value: Bridged<unknown, unknown>;\n\n constructor(value: Bridged<unknown, unknown>, cause: unknown) {\n super(`get of the bridge \"${value.id}\" gives data that cannot be sent`, { cause });\n this.value = value;\n }\n}\n\n/** Reads the data of a bridged store for the page state. */\nfunction bridgeData(value: Bridged<unknown, unknown>): unknown {\n if (value.id === undefined) {\n throw new BridgeDataError(\n value,\n new Error(\n 'The bridge has no name. Keep bridge() in a module-level export of a script file, as \"export const name = bridge({ … })\", so the compiler names it',\n ),\n );\n }\n return value.get();\n}\n\n/** The node of a bridged store: its data and its name. An error of the data names the store. */\nfunction bridgeNode(\n value: Bridged<unknown, unknown>,\n parse: (data: unknown) => SerovalNode,\n): ReferenceNode {\n try {\n return { a: parse(bridgeData(value)), b: parse(value.id), c: parse(value.set ? 1 : 0) };\n } catch (error) {\n throw error instanceof BridgeDataError ? error : new BridgeDataError(value, error);\n }\n}\n\n/**\n * A store of `bridge()`: only the data that `get` reads crosses, and the name of the bridge, so\n * the browser makes the library's store again from the data at the first subscriber.\n */\nfunction makeBridgePlugin(): Plugin<Bridged<unknown, unknown>, ReferenceNode> {\n return createPlugin<Bridged<unknown, unknown>, ReferenceNode>({\n tag: 'brumate/bridge',\n skipPlainObjects: true,\n test: isBridged,\n parse: {\n sync: (value, ctx) => bridgeNode(value, (data) => ctx.parse(data)),\n stream: (value, ctx) => bridgeNode(value, (data) => ctx.parse(data)),\n async: async (value, ctx) => {\n try {\n const data = bridgeData(value);\n return {\n a: await ctx.parse(data),\n b: await ctx.parse(value.id),\n c: await ctx.parse(value.set ? 1 : 0),\n };\n } catch (error) {\n throw error instanceof BridgeDataError ? error : new BridgeDataError(value, error);\n }\n },\n },\n serialize: (node, ctx) =>\n `$b.g(${ctx.serialize(node.a)},${ctx.serialize(node.b)},${ctx.serialize(node.c!)})`,\n deserialize: (node, ctx) =>\n stateValues.g(\n ctx.deserialize(node.a),\n ctx.deserialize<string>(node.b),\n ctx.deserialize<number>(node.c!),\n ),\n });\n}\n\n/** The plugins after the plugin of uploads, which a call makes for its files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nconst valuePlugins: Plugin<any, any>[] = [\n ElementPlugin,\n SlotPlugin,\n BindingPlugin,\n FunctionPlugin,\n MergedPlugin,\n InternalPlugin,\n MemoErrorPlugin,\n PropPromisePlugin,\n ChildrenPlugin,\n RawPlugin,\n ComponentPlugin,\n StorePlugin,\n ...(HAS_BRIDGES ? [makeBridgePlugin()] : []),\n // The web values of seroval-plugins. Requests and responses need the async or stream modes,\n // so a page state or a call result that holds one streams. The plugin of uploads takes files\n // and blobs, so those of seroval-plugins, which would put their bytes in the JSON, are left out.\n SignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n BodyRequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n];\n\n/**\n * The plugins of a call with files: `sent` gets the files that the call\n * sends, and `received` is the form that the server got them in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport function callPlugins(sent?: Blob[], received?: FormData): Plugin<any, any>[] {\n return [uploadPlugin(sent, received), ...valuePlugins];\n}\n\n/** The plugins of the page state, of answers and of calls without files. */\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>[] = callPlugins();\n\n/**\n * Stops a sync mode at a value that only streams: an async iterable, such\n * as a `ReadableStream`. seroval writes one in a sync mode as a stream that\n * never gets its values, without an error.\n */\nconst StreamGuardPlugin = createPlugin<object, Record<string, never>>({\n tag: 'brumate/stream-guard',\n test: (value) =>\n (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||\n (typeof value === 'object' && value !== null && Symbol.asyncIterator in value),\n parse: {\n sync: () => {\n throw new Error('A stream needs the async or stream mode');\n },\n },\n serialize: () => '',\n deserialize: () => ({}),\n});\n\n/**\n * The plugins for the sync modes, which must throw for a value that only\n * streams, so the page state streams instead, and a call with a stream in\n * its arguments is not shared with another. The guard comes first, so it\n * takes a `ReadableStream` before the plugin of `ReadableStream`, which the\n * plugins of `Request` and `Response` bring in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const syncPlugins: Plugin<any, any>[] = [StreamGuardPlugin, ...plugins];\n\n/**\n * The seroval plugin of a plugin of the app. The page state writes its value\n * as `$b.u(tag, data)`, so the record does not need the class in scope.\n */\nfunction appPlugin(plugin: ValuePlugin): Plugin<unknown, { d: SerovalNode }> {\n return createPlugin<unknown, { d: SerovalNode }>({\n tag: `app:${plugin.tag}`,\n test: plugin.test,\n parse: parsers((value) => ({ d: plugin.toData(value) })),\n serialize: (node, ctx) => `$b.u(${JSON.stringify(plugin.tag)},${ctx.serialize(node.d)})`,\n deserialize: (node, ctx) => plugin.fromData(ctx.deserialize(node.d)),\n });\n}\n\n// The plugins of the app come before brumate's, in each list, as the entry adds them. The\n// plugin of uploads stays first in a call, and the guard of streams first in the sync modes.\nonValuePlugin((plugin) => {\n const added = appPlugin(plugin);\n valuePlugins.unshift(added);\n plugins.splice(1, 0, added);\n syncPlugins.splice(2, 0, added);\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 */\nconst BRUMATE_DISABLED = Feature.ErrorPrototypeStack | Feature.RegExp;\n\nexport let disabledFeatures: number = BRUMATE_DISABLED;\nlet depthLimit: number | undefined;\n\n/** The options of every call of seroval: the features that are off, and the depth limit of the entry. */\nexport function serialOptions(): { disabledFeatures: number; depthLimit?: number } {\n return depthLimit === undefined ? { disabledFeatures } : { disabledFeatures, depthLimit };\n}\n\nonSerialOptions((options) => {\n disabledFeatures = options.disabledFeatures ?? BRUMATE_DISABLED;\n depthLimit = options.depthLimit;\n // oxlint-disable-next-line no-bitwise -- The features are flags.\n const enabled = BRUMATE_DISABLED & ~disabledFeatures;\n if (enabled !== 0) {\n console.warn(\n `The serial entry turns on ${enabled & Feature.RegExp ? 'RegExp' : 'ErrorPrototypeStack'}, which brumate turns off: ${enabled & Feature.RegExp ? 'a pattern from a client can take the server a long time to match' : 'a stack shows the files and code of the server to the browser'}.`,\n );\n }\n});\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,qBAA0D,WAErE,OAAO,IAAI,4BAA4B,uBAAO,IAAI,QAAQ;;;;;AAM5D,SAAgB,OAAO,OAA+B;CACpD,IAAI,OAAO,SAAS,eAAe,iBAAiB,MAClD,OAAO;CAET,MAAM,OAAO;CACb,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,gBAAgB,cAC5B,OAAO,KAAK,UAAU;AAE1B;;;;ACuBA,SAAS,eACP,OACA,KACQ;CACR,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,KAAA,GACX,QAAQ,KAAK,IAAI,UAAU,IAAI,CAAC;CAGpC,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;;AAMA,SAAS,QACP,MAC4C;CAE5C,SAAS,MAAM,OAAU,KAA2D;EAClF,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;;AAGA,MAAM,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;AAG1C,SAAS,QAAQ,OAAiC;CAChD,O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U,OAAO,GAAG,EAAE,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE;EACtF,cAAc,MAAM,QAAQ,OAAO,SAAS,IAAI,YAAY,KAAK,CAAC,CAAC;CACrE,CAAC;AACH;AAIA,eAAe,WAAW;CACxB,MAAM,QAAQ,UAAU,MAAM;CAC9B,aAAa,QAAQ,KAAK;CAC1B,QAAQ,OAAO,GAAG,GAAG,KAAK;CAC1B,YAAY,OAAO,GAAG,GAAG,KAAK;AAChC,CAAC;;;;;;;;;AAUD,MAAM,mBAAmB,QAAQ,sBAAsB,QAAQ;AAE/D,IAAW,mBAA2B;AACtC,IAAI;;AAGJ,SAAgB,gBAAmE;CACjF,OAAO,eAAe,KAAA,IAAY,EAAE,iBAAiB,IAAI;EAAE;EAAkB;CAAW;AAC1F;AAEA,iBAAiB,YAAY;CAC3B,mBAAmB,QAAQ,oBAAoB;CAC/C,aAAa,QAAQ;CAErB,MAAM,UAAU,mBAAmB,CAAC;CACpC,IAAI,YAAY,GACd,QAAQ,KACN,6BAA6B,UAAU,QAAQ,SAAS,WAAW,sBAAsB,6BAA6B,UAAU,QAAQ,SAAS,qEAAqE,gEAAgE,EACxR;AAEJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"serial-Cj6pDGOq.js","names":[],"sources":["../src/runtime/calls.ts","../src/runtime/serial.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/**\n * Client functions that the server passes on, such as function props, with\n * their references. Kept under a symbol of the registry, so two copies of the\n * runtime, such as a component's and the render context's, share it.\n */\nexport const functionReferences: WeakMap<object, FunctionReference> = ((\n globalThis as Record<symbol, WeakMap<object, FunctionReference> | undefined>\n)[Symbol.for('brumate.functionReferences')] ??= new WeakMap());\n\n/**\n * True for a file or a blob. One from another frame, or another DOM, is an\n * instance of another `Blob` class, so its methods tell instead.\n */\nexport function isBlob(value: unknown): value is Blob {\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n return true;\n }\n const blob = value as Partial<Blob> | null;\n return (\n typeof blob === 'object' &&\n blob !== null &&\n typeof blob.size === 'number' &&\n typeof blob.type === 'string' &&\n typeof blob.arrayBuffer === 'function' &&\n typeof blob.slice === 'function'\n );\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/shared';\nimport * as v from 'seroval/validator';\nimport {\n AbortSignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n RequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n} from 'seroval-plugins/web';\nimport type {\n Plugin,\n SerovalNode,\n StreamParsePluginContext,\n SyncParsePluginContext,\n} from 'seroval/shared';\nimport { type Internal, isInternal, isRaw, rawHTML } from './html.ts';\nimport type { Raw } from './html.ts';\nimport { functionReferences, isBlob } from './calls.ts';\nimport { MODIFIERS } from './events.ts';\nimport { HAS_BRIDGES } from './features.ts';\nimport {\n CHILDREN_REF,\n ElementReference,\n PARTS,\n isBinding,\n isPropWrapper,\n isSlotReference,\n onSerialOptions,\n onValuePlugin,\n stateValues,\n} from './shared.ts';\nimport type { ChildrenReference, MemoError, PropPromise, ScopeId } from './shared.ts';\nimport type { ValuePlugin } from './values.ts';\nimport { isBridged, isStore } from './store.ts';\nimport type { Bridged, Store } from './store.ts';\nimport type { Binding, SlotReference } from './shared.ts';\nimport type { ComponentValue } from './shared.ts';\n\ntype ReferenceNode = { a: SerovalNode; b: SerovalNode; c?: SerovalNode; d?: SerovalNode };\n\n/** Serializes the parts of a node that are set, joined as call arguments. */\nfunction serializeParts(\n parts: (SerovalNode | undefined)[],\n ctx: { serialize(node: SerovalNode): string },\n): string {\n const written: string[] = [];\n for (const part of parts) {\n if (part !== undefined) {\n written.push(ctx.serialize(part));\n }\n }\n return written.join(',');\n}\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 function 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/** A scope ID, which is a number or a string. */\nconst scopeId = v.union(v.string, v.number);\n\n/** The index of a file in the form: a whole number from 0. */\nfunction isIndex(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 0;\n}\n\n/** An array whose items are not checked: the plugin that reads them checks them. */\nfunction isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/** The arguments of a handler: an array, or null when only modifiers follow. */\nfunction isArgs(value: unknown): value is unknown[] | null {\n return value === null || Array.isArray(value);\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 validate: { a: scopeId, b: v.number },\n});\n\nconst SlotPlugin = createPlugin<SlotReference, ReferenceNode>({\n tag: 'brumate/slot',\n skipPlainObjects: true,\n test: (value) => isSlotReference(value),\n parse: parsers((value) => ({ a: value.scope, b: value.slot })),\n serialize: (node, ctx) => `$b.l(${ctx.serialize(node.a)},${ctx.serialize(node.b)})`,\n deserialize: (node, ctx) =>\n stateValues.l(ctx.deserialize<number>(node.a), ctx.deserialize<number>(node.b)),\n validate: { a: scopeId, b: v.number },\n});\n\n/** A binding that a rest prop holds: its value, and the scope and the slot it writes. */\nconst BindingPlugin = createPlugin<Binding, ReferenceNode>({\n tag: 'brumate/binding',\n skipPlainObjects: true,\n test: (value) => isBinding(value),\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.value, b: value.ref.scope, c: value.ref.slot };\n // The setter of `$bind(name, fn)`.\n if (value.set !== undefined) {\n node.d = value.set;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.b(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.b(\n ctx.deserialize(node.a),\n ctx.deserialize<number>(node.b!),\n ctx.deserialize<number>(node.c!),\n node.d === undefined ? undefined : ctx.deserialize(node.d),\n ),\n validate: { b: scopeId, c: v.number },\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 // The arguments of a handler that `$handler` made go with it.\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The modifiers of its wrappers, so a spread in markup that the browser renders writes them.\n const modifiers = (value as { [MODIFIERS]?: string[] })[MODIFIERS];\n if (reference.args !== undefined || modifiers) {\n node.c = reference.args ?? null;\n }\n if (modifiers) {\n node.d = modifiers;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.f(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.f(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<number>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<unknown[] | null>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<string[]>(node.d),\n ),\n validate: { a: v.string, b: scopeId, c: isArgs, d: v.array(v.string) },\n});\n\n/** A handler that merges the handlers of one event, as the parts that refer to client functions. */\nconst MergedPlugin = createPlugin<object, { a: SerovalNode }>({\n tag: 'brumate/merged',\n skipPlainObjects: true,\n test: (value) => typeof value === 'function' && PARTS in value,\n parse: parsers((value) => {\n const parts: object[] = [];\n for (const part of (value as { [PARTS]: object[] })[PARTS]) {\n if (functionReferences.has(part)) {\n parts.push(part);\n }\n }\n return { a: parts };\n }),\n serialize: (node, ctx) => `$b.m(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.m(ctx.deserialize(node.a)),\n validate: { a: isArray },\n});\n\n/**\n * A value of an attribute that brumate writes, which a live rest prop can hold. The ones that\n * reach the page state are the scoped style attribute and `b-v`. The error \"holds a Internal\"\n * no longer catches any other, so a new one needs a check of its own.\n */\nconst InternalPlugin = createPlugin<Internal, { a: SerovalNode }>({\n tag: 'brumate/internal',\n skipPlainObjects: true,\n test: (value) => isInternal(value),\n parse: parsers((value) => ({ a: value.value })),\n serialize: (node, ctx) => `$b.i(${ctx.serialize(node.a)})`,\n deserialize: (node, ctx) => stateValues.i(ctx.deserialize(node.a)),\n});\n\n/** Children of a component, as the export that renders them in the browser. */\nconst ChildrenPlugin = createPlugin<object, ReferenceNode>({\n tag: 'brumate/children',\n skipPlainObjects: true,\n test: (value) => typeof value === 'object' && value !== null && CHILDREN_REF in value,\n parse: parsers((value) => {\n const reference = (value as { [CHILDREN_REF]: ChildrenReference })[CHILDREN_REF];\n const node: Record<string, unknown> = { a: reference.ref, b: reference.scope };\n // The scope and the anchor of the insert where the server rendered them.\n if (reference.at !== undefined) {\n node.c = reference.at;\n node.d = reference.anchor;\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.n(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.n(\n ctx.deserialize<string>(node.a),\n ctx.deserialize<ScopeId>(node.b!),\n node.c === undefined ? undefined : ctx.deserialize<ScopeId>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n validate: { a: v.string, b: scopeId, c: scopeId, d: v.number },\n});\n\n/**\n * A memo that failed on the server. The page state holds its error, so a read in the browser\n * throws it, as a memo that failed there. The server writes the error that is safe to send. See\n * `stateValue`.\n */\nconst MemoErrorPlugin = createPlugin<MemoError, { e: SerovalNode }>({\n tag: 'brumate/memo-error',\n skipPlainObjects: true,\n // The server marks the errors it holds, so the copies of the runtime agree on them.\n test: (value) =>\n typeof value === 'object' && value !== null && Symbol.for('brumate.held') in value,\n parse: parsers((value) => ({ e: value.error })),\n serialize: (node, ctx) => `$b.x(${ctx.serialize(node.e)})`,\n deserialize: (node, ctx) => stateValues.x(ctx.deserialize(node.e)),\n});\n\n/** A promise prop in the page state. See `PropPromise`. */\nconst PropPromisePlugin = createPlugin<PropPromise, { p: SerovalNode }>({\n tag: 'brumate/prop-promise',\n skipPlainObjects: true,\n test: isPropWrapper,\n parse: parsers((value) => ({ p: value.promise })),\n serialize: (node, ctx) => `$b.q(${ctx.serialize(node.p)})`,\n deserialize: (node, ctx) => stateValues.q(ctx.deserialize(node.p)),\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 validate: { h: v.string },\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 validate: { c: v.string },\n});\n\n/**\n * A store of `brumate/store`: only its value crosses, and where `$toStore` made it, so the\n * browser makes a new store that the provider writes. Readers subscribe as their scopes resume.\n */\nconst StorePlugin = createPlugin<Store<unknown>, ReferenceNode>({\n tag: 'brumate/store',\n skipPlainObjects: true,\n test: isStore,\n parse: parsers((value) => {\n const node: Record<string, unknown> = { a: value.v };\n if (value.o) {\n node.b = value.o[0];\n node.c = value.o[1];\n if (value.o[2] !== undefined) {\n node.d = value.o[2];\n }\n }\n return node as Record<'a' | 'b' | 'c' | 'd', unknown>;\n }),\n serialize: (node, ctx) => `$b.s(${serializeParts([node.a, node.b, node.c, node.d], ctx)})`,\n deserialize: (node, ctx) =>\n stateValues.s(\n ctx.deserialize(node.a),\n node.b === undefined ? undefined : ctx.deserialize<ScopeId>(node.b),\n node.c === undefined ? undefined : ctx.deserialize<number>(node.c),\n node.d === undefined ? undefined : ctx.deserialize<number>(node.d),\n ),\n validate: { b: scopeId, c: v.number, d: v.number },\n});\n\n/**\n * The index of a file or a blob, and what a part of multipart form data does\n * not keep: the type (an empty one arrives as `application/octet-stream`),\n * whether the value was a blob or a file (every part arrives as a file), and\n * the name (some characters are escaped) and `lastModified` of a file. Calls\n * from pages before these fields send only the index.\n */\ntype UploadNode = { i: SerovalNode; t?: SerovalNode; n?: SerovalNode; l?: SerovalNode };\n\nfunction isFile(value: Blob): value is File {\n const file = value as Partial<File>;\n return typeof file.name === 'string' && typeof file.lastModified === 'number';\n}\n\n/**\n * Files and blobs, which go only in the arguments of a call, as parts of\n * multipart form data named `file<index>`. The node holds the index. The\n * call passes `sent`, which gets each blob, and the server passes the form\n * that it `received`, whose files the indexes read. Without them, as in the\n * page state and in the answer of a call, a blob throws.\n */\nexport function uploadPlugin(sent?: Blob[], received?: FormData): Plugin<Blob, UploadNode> {\n return createPlugin<Blob, UploadNode>({\n tag: 'brumate/upload',\n skipPlainObjects: true,\n test: isBlob,\n // Only the fields that are set go in the node, so `K` names just the index.\n parse: parsers<Blob, 'i'>((value) => {\n if (!sent) {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n }\n const index = sent.push(value) - 1;\n if (isFile(value)) {\n return { i: index, t: value.type, n: value.name, l: value.lastModified };\n }\n return { i: index, t: value.type };\n }) as Plugin<Blob, UploadNode>['parse'],\n serialize: () => {\n throw new Error('A file or a blob can only be sent in the arguments of a server function');\n },\n deserialize: (node, ctx) => {\n const file = received?.get(`file${ctx.deserialize<number>(node.i)}`);\n if (!(file instanceof Blob)) {\n throw new TypeError('A file of the call is missing');\n }\n // A page before the metadata fields sends only the index.\n if (node.t === undefined) {\n return file;\n }\n const type = ctx.deserialize<string>(node.t);\n // The new blob or file refers to the bytes of the part instead of copying them.\n if (node.n === undefined) {\n return new Blob([file], { type });\n }\n const name = ctx.deserialize<string>(node.n);\n const lastModified = node.l === undefined ? undefined : ctx.deserialize<number>(node.l);\n return new File([file], name, { type, lastModified });\n },\n validate: { i: isIndex, t: v.string, n: v.string, l: v.number },\n });\n}\n\n/**\n * The plugin of `AbortSignal` from seroval-plugins, which sends whether the\n * signal aborted and its reason. The one of seroval-plugins waits for a live\n * signal to abort, so a call with one would not be sent, and a page or an\n * answer with one would not end.\n */\nconst SignalPlugin: typeof AbortSignalPlugin = {\n ...AbortSignalPlugin,\n parse: {\n sync: AbortSignalPlugin.parse.sync,\n stream: AbortSignalPlugin.parse.sync,\n async: async (value, ctx) => (value.aborted ? { reason: await ctx.parse(value.reason) } : {}),\n },\n};\n\n/**\n * The plugin of `Request` from seroval-plugins, whose body streams in the\n * stream mode. A request with a stream body needs `duplex: 'half'`, or its\n * constructor throws, so the plugin adds it.\n */\nconst BodyRequestPlugin: typeof RequestPlugin = {\n ...RequestPlugin,\n serialize: (node, ctx) =>\n `new Request(${ctx.serialize(node.url)},Object.assign(${ctx.serialize(node.options)},{duplex:\"half\"}))`,\n deserialize: (node, ctx) =>\n new Request(\n ctx.deserialize(node.url) as string,\n {\n ...(ctx.deserialize(node.options) as RequestInit),\n duplex: 'half',\n } as RequestInit,\n ),\n};\n\n/**\n * The error of a store of `bridge()` whose data the page state cannot send. It holds the store as\n * `value`, so the server finds the context or the prop that sends it.\n */\nexport class BridgeDataError extends Error {\n value: Bridged<unknown, unknown>;\n\n constructor(value: Bridged<unknown, unknown>, cause: unknown) {\n super(`get of the bridge \"${value.id}\" gives data that cannot be sent`, { cause });\n this.value = value;\n }\n}\n\n/** Reads the data of a bridged store for the page state. */\nfunction bridgeData(value: Bridged<unknown, unknown>): unknown {\n if (value.id === undefined) {\n throw new BridgeDataError(\n value,\n new Error(\n 'The bridge has no name. Keep bridge() in a module-level export of a script file, as \"export const name = bridge({ … })\", so the compiler names it',\n ),\n );\n }\n return value.get();\n}\n\n/** The node of a bridged store: its data and its name. An error of the data names the store. */\nfunction bridgeNode(\n value: Bridged<unknown, unknown>,\n parse: (data: unknown) => SerovalNode,\n): ReferenceNode {\n try {\n return { a: parse(bridgeData(value)), b: parse(value.id), c: parse(value.set ? 1 : 0) };\n } catch (error) {\n throw error instanceof BridgeDataError ? error : new BridgeDataError(value, error);\n }\n}\n\n/**\n * A store of `bridge()`: only the data that `get` reads crosses, and the name of the bridge, so\n * the browser makes the library's store again from the data at the first subscriber.\n */\nfunction makeBridgePlugin(): Plugin<Bridged<unknown, unknown>, ReferenceNode> {\n return createPlugin<Bridged<unknown, unknown>, ReferenceNode>({\n tag: 'brumate/bridge',\n skipPlainObjects: true,\n test: isBridged,\n parse: {\n sync: (value, ctx) => bridgeNode(value, (data) => ctx.parse(data)),\n stream: (value, ctx) => bridgeNode(value, (data) => ctx.parse(data)),\n async: async (value, ctx) => {\n try {\n const data = bridgeData(value);\n return {\n a: await ctx.parse(data),\n b: await ctx.parse(value.id),\n c: await ctx.parse(value.set ? 1 : 0),\n };\n } catch (error) {\n throw error instanceof BridgeDataError ? error : new BridgeDataError(value, error);\n }\n },\n },\n serialize: (node, ctx) =>\n `$b.g(${ctx.serialize(node.a)},${ctx.serialize(node.b)},${ctx.serialize(node.c!)})`,\n deserialize: (node, ctx) =>\n stateValues.g(\n ctx.deserialize(node.a),\n ctx.deserialize<string>(node.b),\n ctx.deserialize<number>(node.c!),\n ),\n });\n}\n\n/** The plugins after the plugin of uploads, which a call makes for its files. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nconst valuePlugins: Plugin<any, any>[] = [\n ElementPlugin,\n SlotPlugin,\n BindingPlugin,\n FunctionPlugin,\n MergedPlugin,\n InternalPlugin,\n MemoErrorPlugin,\n PropPromisePlugin,\n ChildrenPlugin,\n RawPlugin,\n ComponentPlugin,\n StorePlugin,\n ...(HAS_BRIDGES ? [makeBridgePlugin()] : []),\n // The web values of seroval-plugins. Requests and responses need the async or stream modes,\n // so a page state or a call result that holds one streams. The plugin of uploads takes files\n // and blobs, so those of seroval-plugins, which would put their bytes in the JSON, are left out.\n SignalPlugin,\n CustomEventPlugin,\n DOMExceptionPlugin,\n EventPlugin,\n FormDataPlugin,\n HeadersPlugin,\n ImageDataPlugin,\n ReadableStreamPlugin,\n BodyRequestPlugin,\n ResponsePlugin,\n URLPlugin,\n URLSearchParamsPlugin,\n];\n\n/**\n * The plugins of a call with files: `sent` gets the files that the call\n * sends, and `received` is the form that the server got them in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport function callPlugins(sent?: Blob[], received?: FormData): Plugin<any, any>[] {\n return [uploadPlugin(sent, received), ...valuePlugins];\n}\n\n/** The plugins of the page state, of answers and of calls without files. */\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>[] = callPlugins();\n\n/**\n * Stops a sync mode at a value that only streams: an async iterable, such\n * as a `ReadableStream`. seroval writes one in a sync mode as a stream that\n * never gets its values, without an error.\n */\nconst StreamGuardPlugin = createPlugin<object, Record<string, never>>({\n tag: 'brumate/stream-guard',\n test: (value) =>\n (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||\n (typeof value === 'object' && value !== null && Symbol.asyncIterator in value),\n parse: {\n sync: () => {\n throw new Error('A stream needs the async or stream mode');\n },\n },\n serialize: () => '',\n deserialize: () => ({}),\n});\n\n/**\n * The plugins for the sync modes, which must throw for a value that only\n * streams, so the page state streams instead, and a call with a stream in\n * its arguments is not shared with another. The guard comes first, so it\n * takes a `ReadableStream` before the plugin of `ReadableStream`, which the\n * plugins of `Request` and `Response` bring in.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- Plugin is invariant, so any is needed to hold every plugin.\nexport const syncPlugins: Plugin<any, any>[] = [StreamGuardPlugin, ...plugins];\n\n/**\n * The seroval plugin of a plugin of the app. The page state writes its value\n * as `$b.u(tag, data)`, so the record does not need the class in scope.\n */\nfunction appPlugin(plugin: ValuePlugin): Plugin<unknown, { d: SerovalNode }> {\n return createPlugin<unknown, { d: SerovalNode }>({\n tag: `app:${plugin.tag}`,\n test: plugin.test,\n parse: parsers((value) => ({ d: plugin.toData(value) })),\n serialize: (node, ctx) => `$b.u(${JSON.stringify(plugin.tag)},${ctx.serialize(node.d)})`,\n deserialize: (node, ctx) => plugin.fromData(ctx.deserialize(node.d)),\n });\n}\n\n// The plugins of the app come before brumate's, in each list, as the entry adds them. The\n// plugin of uploads stays first in a call, and the guard of streams first in the sync modes.\nonValuePlugin((plugin) => {\n const added = appPlugin(plugin);\n valuePlugins.unshift(added);\n plugins.splice(1, 0, added);\n syncPlugins.splice(2, 0, added);\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 */\nconst BRUMATE_DISABLED = Feature.ErrorPrototypeStack | Feature.RegExp;\n\nexport let disabledFeatures: number = BRUMATE_DISABLED;\nlet depthLimit: number | undefined;\n\n/** The options of every call of seroval: the features that are off, and the depth limit of the entry. */\nexport function serialOptions(): { disabledFeatures: number; depthLimit?: number } {\n return depthLimit === undefined ? { disabledFeatures } : { disabledFeatures, depthLimit };\n}\n\nonSerialOptions((options) => {\n disabledFeatures = options.disabledFeatures ?? BRUMATE_DISABLED;\n depthLimit = options.depthLimit;\n // oxlint-disable-next-line no-bitwise -- The features are flags.\n const enabled = BRUMATE_DISABLED & ~disabledFeatures;\n if (enabled !== 0) {\n console.warn(\n `The serial entry turns on ${enabled & Feature.RegExp ? 'RegExp' : 'ErrorPrototypeStack'}, which brumate turns off: ${enabled & Feature.RegExp ? 'a pattern from a client can take the server a long time to match' : 'a stack shows the files and code of the server to the browser'}.`,\n );\n }\n});\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,qBAA0D,WAErE,OAAO,IAAI,4BAA4B,uBAAO,IAAI,QAAQ;;;;;AAM5D,SAAgB,OAAO,OAA+B;CACpD,IAAI,OAAO,SAAS,eAAe,iBAAiB,MAClD,OAAO;CAET,MAAM,OAAO;CACb,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,gBAAgB,cAC5B,OAAO,KAAK,UAAU;AAE1B;;;;ACuBA,SAAS,eACP,OACA,KACQ;CACR,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,KAAA,GACX,QAAQ,KAAK,IAAI,UAAU,IAAI,CAAC;CAGpC,OAAO,QAAQ,KAAK,GAAG;AACzB;;;;;AAMA,SAAS,Q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