@teyik0/furin 0.1.0-alpha.13 → 0.1.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -232
- package/dist/auto-invalidate/index.d.ts +4 -0
- package/dist/auto-invalidate/plugin.d.ts +38 -0
- package/dist/auto-invalidate/registry.d.ts +9 -0
- package/dist/auto-invalidate/runtime.d.ts +9 -0
- package/dist/auto-invalidate/types.d.ts +12 -0
- package/dist/await.d.ts +67 -0
- package/dist/build/index.js +2095 -185
- package/dist/cli/index.js +2070 -182
- package/dist/client.d.ts +51 -4
- package/dist/client.js +65 -1
- package/dist/deferred-ndjson.d.ts +32 -0
- package/dist/error.d.ts +14 -0
- package/dist/furin.d.ts +8 -0
- package/dist/furin.js +2927 -319
- package/dist/lang-detect.d.ts +5 -0
- package/dist/link.d.ts +1 -0
- package/dist/link.js +1453 -95
- package/dist/plugin/index.js +96 -25
- package/dist/plugin/transform-client.d.ts +2 -1
- package/dist/render/assemble.d.ts +32 -0
- package/dist/render/cache.d.ts +7 -0
- package/dist/render/element.d.ts +17 -1
- package/dist/render/index.d.ts +10 -1
- package/dist/render/index.ts +250 -44
- package/dist/render/loaders.d.ts +46 -3
- package/dist/render/shell.d.ts +16 -6
- package/dist/render/shell.ts +27 -12
- package/dist/router-provider.d.ts +86 -18
- package/dist/router.d.ts +66 -0
- package/dist/router.js +2909 -374
- package/dist/router.ts +586 -54
- package/dist/server-error.d.ts +12 -0
- package/dist/utils.d.ts +7 -0
- package/package.json +8 -7
- package/src/adapter/bun.ts +3 -3
- package/src/adapter/static.ts +73 -31
- package/src/auto-invalidate/index.ts +10 -0
- package/src/auto-invalidate/plugin.ts +25 -0
- package/src/auto-invalidate/registry.ts +60 -0
- package/src/auto-invalidate/runtime.ts +133 -0
- package/src/auto-invalidate/types.ts +16 -0
- package/src/await.tsx +175 -0
- package/src/build/client.ts +4 -8
- package/src/build/hydrate.ts +67 -1
- package/src/build/route-types.ts +29 -3
- package/src/build/scan-server.ts +6 -23
- package/src/client.ts +80 -3
- package/src/deferred-ndjson.ts +212 -0
- package/src/dev-page-plugin.ts +2 -0
- package/src/error.ts +18 -1
- package/src/furin.ts +19 -2
- package/src/lang-detect.ts +46 -0
- package/src/link.tsx +16 -3
- package/src/plugin/index.ts +7 -8
- package/src/plugin/transform-client.ts +108 -39
- package/src/render/assemble.ts +67 -0
- package/src/render/boundaries.tsx +23 -5
- package/src/render/cache.ts +14 -0
- package/src/render/default-screens.tsx +4 -11
- package/src/render/dev-cache.ts +5 -0
- package/src/render/element.tsx +26 -3
- package/src/render/index.ts +250 -44
- package/src/render/loaders.ts +219 -18
- package/src/render/shell.ts +27 -12
- package/src/router-provider.tsx +414 -122
- package/src/router.ts +586 -54
- package/src/server-error.ts +47 -0
- package/src/utils.ts +31 -0
package/dist/router.js
CHANGED
|
@@ -5,155 +5,1529 @@ import { readdir } from "fs/promises";
|
|
|
5
5
|
import { join, parse } from "path";
|
|
6
6
|
import { Elysia as Elysia2, t } from "elysia";
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// ../../node_modules/.bun/seroval@1.5.4/node_modules/seroval/dist/esm/development/index.mjs
|
|
9
|
+
var ALL_ENABLED = 1 | 2 | 4 | 8 | 16 | 32;
|
|
10
|
+
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
11
|
+
var SYM_HAS_INSTANCE = Symbol.hasInstance;
|
|
12
|
+
var SYM_IS_CONCAT_SPREADABLE = Symbol.isConcatSpreadable;
|
|
13
|
+
var SYM_ITERATOR = Symbol.iterator;
|
|
14
|
+
var SYM_MATCH = Symbol.match;
|
|
15
|
+
var SYM_MATCH_ALL = Symbol.matchAll;
|
|
16
|
+
var SYM_REPLACE = Symbol.replace;
|
|
17
|
+
var SYM_SEARCH = Symbol.search;
|
|
18
|
+
var SYM_SPECIES = Symbol.species;
|
|
19
|
+
var SYM_SPLIT = Symbol.split;
|
|
20
|
+
var SYM_TO_PRIMITIVE = Symbol.toPrimitive;
|
|
21
|
+
var SYM_TO_STRING_TAG = Symbol.toStringTag;
|
|
22
|
+
var SYM_UNSCOPABLES = Symbol.unscopables;
|
|
23
|
+
var INV_SYMBOL_REF = {
|
|
24
|
+
[SYM_ASYNC_ITERATOR]: 0,
|
|
25
|
+
[SYM_HAS_INSTANCE]: 1,
|
|
26
|
+
[SYM_IS_CONCAT_SPREADABLE]: 2,
|
|
27
|
+
[SYM_ITERATOR]: 3,
|
|
28
|
+
[SYM_MATCH]: 4,
|
|
29
|
+
[SYM_MATCH_ALL]: 5,
|
|
30
|
+
[SYM_REPLACE]: 6,
|
|
31
|
+
[SYM_SEARCH]: 7,
|
|
32
|
+
[SYM_SPECIES]: 8,
|
|
33
|
+
[SYM_SPLIT]: 9,
|
|
34
|
+
[SYM_TO_PRIMITIVE]: 10,
|
|
35
|
+
[SYM_TO_STRING_TAG]: 11,
|
|
36
|
+
[SYM_UNSCOPABLES]: 12
|
|
37
|
+
};
|
|
38
|
+
var NIL = undefined;
|
|
39
|
+
var CONSTANT_VAL = {
|
|
40
|
+
[2]: true,
|
|
41
|
+
[3]: false,
|
|
42
|
+
[1]: NIL,
|
|
43
|
+
[0]: null,
|
|
44
|
+
[4]: -0,
|
|
45
|
+
[5]: Number.POSITIVE_INFINITY,
|
|
46
|
+
[6]: Number.NEGATIVE_INFINITY,
|
|
47
|
+
[7]: Number.NaN
|
|
48
|
+
};
|
|
49
|
+
var ERROR_CONSTRUCTOR_STRING = {
|
|
50
|
+
[0]: "Error",
|
|
51
|
+
[1]: "EvalError",
|
|
52
|
+
[2]: "RangeError",
|
|
53
|
+
[3]: "ReferenceError",
|
|
54
|
+
[4]: "SyntaxError",
|
|
55
|
+
[5]: "TypeError",
|
|
56
|
+
[6]: "URIError"
|
|
57
|
+
};
|
|
58
|
+
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
59
|
+
return {
|
|
60
|
+
t,
|
|
61
|
+
i,
|
|
62
|
+
s,
|
|
63
|
+
c,
|
|
64
|
+
m,
|
|
65
|
+
p,
|
|
66
|
+
e,
|
|
67
|
+
a,
|
|
68
|
+
f,
|
|
69
|
+
b,
|
|
70
|
+
o,
|
|
71
|
+
l
|
|
72
|
+
};
|
|
12
73
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
74
|
+
function createConstantNode(value) {
|
|
75
|
+
return createSerovalNode(2, NIL, value, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
76
|
+
}
|
|
77
|
+
var TRUE_NODE = /* @__PURE__ */ createConstantNode(2);
|
|
78
|
+
var FALSE_NODE = /* @__PURE__ */ createConstantNode(3);
|
|
79
|
+
var UNDEFINED_NODE = /* @__PURE__ */ createConstantNode(1);
|
|
80
|
+
var NULL_NODE = /* @__PURE__ */ createConstantNode(0);
|
|
81
|
+
var NEG_ZERO_NODE = /* @__PURE__ */ createConstantNode(4);
|
|
82
|
+
var INFINITY_NODE = /* @__PURE__ */ createConstantNode(5);
|
|
83
|
+
var NEG_INFINITY_NODE = /* @__PURE__ */ createConstantNode(6);
|
|
84
|
+
var NAN_NODE = /* @__PURE__ */ createConstantNode(7);
|
|
85
|
+
function serializeChar(str) {
|
|
86
|
+
switch (str) {
|
|
87
|
+
case '"':
|
|
88
|
+
return "\\\"";
|
|
89
|
+
case "\\":
|
|
90
|
+
return "\\\\";
|
|
91
|
+
case `
|
|
92
|
+
`:
|
|
93
|
+
return "\\n";
|
|
94
|
+
case "\r":
|
|
95
|
+
return "\\r";
|
|
96
|
+
case "\b":
|
|
97
|
+
return "\\b";
|
|
98
|
+
case "\t":
|
|
99
|
+
return "\\t";
|
|
100
|
+
case "\f":
|
|
101
|
+
return "\\f";
|
|
102
|
+
case "<":
|
|
103
|
+
return "\\x3C";
|
|
104
|
+
case "\u2028":
|
|
105
|
+
return "\\u2028";
|
|
106
|
+
case "\u2029":
|
|
107
|
+
return "\\u2029";
|
|
108
|
+
default:
|
|
109
|
+
return NIL;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function serializeString(str) {
|
|
113
|
+
let result = "";
|
|
114
|
+
let lastPos = 0;
|
|
115
|
+
let replacement;
|
|
116
|
+
for (let i = 0, len = str.length;i < len; i++) {
|
|
117
|
+
replacement = serializeChar(str[i]);
|
|
118
|
+
if (replacement) {
|
|
119
|
+
result += str.slice(lastPos, i) + replacement;
|
|
120
|
+
lastPos = i + 1;
|
|
121
|
+
}
|
|
18
122
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
123
|
+
if (lastPos === 0) {
|
|
124
|
+
result = str;
|
|
125
|
+
} else {
|
|
126
|
+
result += str.slice(lastPos);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
131
|
+
var GLOBAL_CONTEXT_REFERENCES = "$R";
|
|
132
|
+
var GLOBAL_CONTEXT_R = `self.${GLOBAL_CONTEXT_REFERENCES}`;
|
|
133
|
+
var REFERENCE = /* @__PURE__ */ new Map;
|
|
134
|
+
var INV_REFERENCE = /* @__PURE__ */ new Map;
|
|
135
|
+
function hasReferenceID(value) {
|
|
136
|
+
return REFERENCE.has(value);
|
|
137
|
+
}
|
|
138
|
+
function getReferenceID(value) {
|
|
139
|
+
if (hasReferenceID(value)) {
|
|
140
|
+
return REFERENCE.get(value);
|
|
141
|
+
}
|
|
142
|
+
throw new SerovalMissingReferenceError(value);
|
|
143
|
+
}
|
|
144
|
+
if (typeof globalThis !== "undefined") {
|
|
145
|
+
Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
146
|
+
value: INV_REFERENCE,
|
|
147
|
+
configurable: true,
|
|
148
|
+
writable: false,
|
|
149
|
+
enumerable: false
|
|
150
|
+
});
|
|
151
|
+
} else if (typeof window !== "undefined") {
|
|
152
|
+
Object.defineProperty(window, REFERENCES_KEY, {
|
|
153
|
+
value: INV_REFERENCE,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: false,
|
|
156
|
+
enumerable: false
|
|
157
|
+
});
|
|
158
|
+
} else if (typeof self !== "undefined") {
|
|
159
|
+
Object.defineProperty(self, REFERENCES_KEY, {
|
|
160
|
+
value: INV_REFERENCE,
|
|
161
|
+
configurable: true,
|
|
162
|
+
writable: false,
|
|
163
|
+
enumerable: false
|
|
164
|
+
});
|
|
165
|
+
} else if (typeof global !== "undefined") {
|
|
166
|
+
Object.defineProperty(global, REFERENCES_KEY, {
|
|
167
|
+
value: INV_REFERENCE,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: false,
|
|
170
|
+
enumerable: false
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function getErrorConstructor(error) {
|
|
174
|
+
if (error instanceof EvalError) {
|
|
175
|
+
return 1;
|
|
176
|
+
}
|
|
177
|
+
if (error instanceof RangeError) {
|
|
178
|
+
return 2;
|
|
179
|
+
}
|
|
180
|
+
if (error instanceof ReferenceError) {
|
|
181
|
+
return 3;
|
|
182
|
+
}
|
|
183
|
+
if (error instanceof SyntaxError) {
|
|
184
|
+
return 4;
|
|
185
|
+
}
|
|
186
|
+
if (error instanceof TypeError) {
|
|
187
|
+
return 5;
|
|
188
|
+
}
|
|
189
|
+
if (error instanceof URIError) {
|
|
190
|
+
return 6;
|
|
191
|
+
}
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
function getInitialErrorOptions(error) {
|
|
195
|
+
const construct = ERROR_CONSTRUCTOR_STRING[getErrorConstructor(error)];
|
|
196
|
+
if (error.name !== construct) {
|
|
197
|
+
return { name: error.name };
|
|
198
|
+
}
|
|
199
|
+
if (error.constructor.name !== construct) {
|
|
200
|
+
return { name: error.constructor.name };
|
|
201
|
+
}
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
function getErrorOptions(error, features) {
|
|
205
|
+
let options = getInitialErrorOptions(error);
|
|
206
|
+
const names = Object.getOwnPropertyNames(error);
|
|
207
|
+
for (let i = 0, len = names.length, name;i < len; i++) {
|
|
208
|
+
name = names[i];
|
|
209
|
+
if (name !== "name" && name !== "message") {
|
|
210
|
+
if (name === "stack") {
|
|
211
|
+
if (features & 4) {
|
|
212
|
+
options = options || {};
|
|
213
|
+
options[name] = error[name];
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
options = options || {};
|
|
217
|
+
options[name] = error[name];
|
|
218
|
+
}
|
|
22
219
|
}
|
|
23
220
|
}
|
|
24
|
-
return;
|
|
221
|
+
return options;
|
|
25
222
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
223
|
+
function getObjectFlag(obj) {
|
|
224
|
+
if (Object.isFrozen(obj)) {
|
|
225
|
+
return 3;
|
|
226
|
+
}
|
|
227
|
+
if (Object.isSealed(obj)) {
|
|
228
|
+
return 2;
|
|
229
|
+
}
|
|
230
|
+
if (Object.isExtensible(obj)) {
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
return 1;
|
|
28
234
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
235
|
+
function createNumberNode(value) {
|
|
236
|
+
switch (value) {
|
|
237
|
+
case Number.POSITIVE_INFINITY:
|
|
238
|
+
return INFINITY_NODE;
|
|
239
|
+
case Number.NEGATIVE_INFINITY:
|
|
240
|
+
return NEG_INFINITY_NODE;
|
|
241
|
+
}
|
|
242
|
+
if (value !== value) {
|
|
243
|
+
return NAN_NODE;
|
|
244
|
+
}
|
|
245
|
+
if (Object.is(value, -0)) {
|
|
246
|
+
return NEG_ZERO_NODE;
|
|
247
|
+
}
|
|
248
|
+
return createSerovalNode(0, NIL, value, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
31
249
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
250
|
+
function createStringNode(value) {
|
|
251
|
+
return createSerovalNode(1, NIL, serializeString(value), NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
34
252
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
253
|
+
function createBigIntNode(current) {
|
|
254
|
+
return createSerovalNode(3, NIL, "" + current, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
37
255
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
256
|
+
function createIndexedValueNode(id) {
|
|
257
|
+
return createSerovalNode(4, id, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
258
|
+
}
|
|
259
|
+
function createDateNode(id, current) {
|
|
260
|
+
const timestamp = current.valueOf();
|
|
261
|
+
return createSerovalNode(5, id, timestamp !== timestamp ? "" : current.toISOString(), NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
262
|
+
}
|
|
263
|
+
function createRegExpNode(id, current) {
|
|
264
|
+
return createSerovalNode(6, id, NIL, serializeString(current.source), current.flags, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
265
|
+
}
|
|
266
|
+
function createWKSymbolNode(id, current) {
|
|
267
|
+
return createSerovalNode(17, id, INV_SYMBOL_REF[current], NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
268
|
+
}
|
|
269
|
+
function createReferenceNode(id, ref) {
|
|
270
|
+
return createSerovalNode(18, id, serializeString(getReferenceID(ref)), NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
271
|
+
}
|
|
272
|
+
function createPluginNode(id, tag, value) {
|
|
273
|
+
return createSerovalNode(25, id, value, serializeString(tag), NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
274
|
+
}
|
|
275
|
+
function createArrayNode(id, current, parsedItems) {
|
|
276
|
+
return createSerovalNode(9, id, NIL, NIL, NIL, NIL, NIL, parsedItems, NIL, NIL, getObjectFlag(current), NIL);
|
|
277
|
+
}
|
|
278
|
+
function createBoxedNode(id, boxed) {
|
|
279
|
+
return createSerovalNode(21, id, NIL, NIL, NIL, NIL, NIL, NIL, boxed, NIL, NIL, NIL);
|
|
280
|
+
}
|
|
281
|
+
function createTypedArrayNode(id, current, buffer) {
|
|
282
|
+
return createSerovalNode(15, id, NIL, current.constructor.name, NIL, NIL, NIL, NIL, buffer, current.byteOffset, NIL, current.length);
|
|
283
|
+
}
|
|
284
|
+
function createBigIntTypedArrayNode(id, current, buffer) {
|
|
285
|
+
return createSerovalNode(16, id, NIL, current.constructor.name, NIL, NIL, NIL, NIL, buffer, current.byteOffset, NIL, current.byteLength);
|
|
286
|
+
}
|
|
287
|
+
function createDataViewNode(id, current, buffer) {
|
|
288
|
+
return createSerovalNode(20, id, NIL, NIL, NIL, NIL, NIL, NIL, buffer, current.byteOffset, NIL, current.byteLength);
|
|
289
|
+
}
|
|
290
|
+
function createErrorNode(id, current, options) {
|
|
291
|
+
return createSerovalNode(13, id, getErrorConstructor(current), NIL, serializeString(current.message), options, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
292
|
+
}
|
|
293
|
+
function createAggregateErrorNode(id, current, options) {
|
|
294
|
+
return createSerovalNode(14, id, getErrorConstructor(current), NIL, serializeString(current.message), options, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
295
|
+
}
|
|
296
|
+
function createSetNode(id, items) {
|
|
297
|
+
return createSerovalNode(7, id, NIL, NIL, NIL, NIL, NIL, items, NIL, NIL, NIL, NIL);
|
|
298
|
+
}
|
|
299
|
+
function createIteratorFactoryInstanceNode(factory, items) {
|
|
300
|
+
return createSerovalNode(28, NIL, NIL, NIL, NIL, NIL, NIL, [factory, items], NIL, NIL, NIL, NIL);
|
|
301
|
+
}
|
|
302
|
+
function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
303
|
+
return createSerovalNode(30, NIL, NIL, NIL, NIL, NIL, NIL, [factory, items], NIL, NIL, NIL, NIL);
|
|
304
|
+
}
|
|
305
|
+
function createStreamConstructorNode(id, factory, sequence) {
|
|
306
|
+
return createSerovalNode(31, id, NIL, NIL, NIL, NIL, NIL, sequence, factory, NIL, NIL, NIL);
|
|
307
|
+
}
|
|
308
|
+
function createStreamNextNode(id, parsed) {
|
|
309
|
+
return createSerovalNode(32, id, NIL, NIL, NIL, NIL, NIL, NIL, parsed, NIL, NIL, NIL);
|
|
310
|
+
}
|
|
311
|
+
function createStreamThrowNode(id, parsed) {
|
|
312
|
+
return createSerovalNode(33, id, NIL, NIL, NIL, NIL, NIL, NIL, parsed, NIL, NIL, NIL);
|
|
313
|
+
}
|
|
314
|
+
function createStreamReturnNode(id, parsed) {
|
|
315
|
+
return createSerovalNode(34, id, NIL, NIL, NIL, NIL, NIL, NIL, parsed, NIL, NIL, NIL);
|
|
316
|
+
}
|
|
317
|
+
function createSequenceNode(id, sequence, throwAt, doneAt) {
|
|
318
|
+
return createSerovalNode(35, id, throwAt, NIL, NIL, NIL, NIL, sequence, NIL, NIL, NIL, doneAt);
|
|
319
|
+
}
|
|
320
|
+
var { toString: objectToString } = Object.prototype;
|
|
321
|
+
function getErrorMessageDev(type, cause) {
|
|
322
|
+
if (cause instanceof Error) {
|
|
323
|
+
return `Seroval caught an error during the ${type} process.
|
|
324
|
+
|
|
325
|
+
${cause.name}
|
|
326
|
+
${cause.message}
|
|
327
|
+
|
|
328
|
+
- For more information, please check the "cause" property of this error.
|
|
329
|
+
- If you believe this is an error in Seroval, please submit an issue at https://github.com/lxsmnsyc/seroval/issues/new`;
|
|
43
330
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
331
|
+
return `Seroval caught an error during the ${type} process.
|
|
332
|
+
|
|
333
|
+
"${objectToString.call(cause)}"
|
|
334
|
+
|
|
335
|
+
For more information, please check the "cause" property of this error.`;
|
|
336
|
+
}
|
|
337
|
+
var getErrorMessage = (type, cause) => getErrorMessageDev(type, cause);
|
|
338
|
+
var SerovalError = class extends Error {
|
|
339
|
+
constructor(type, cause) {
|
|
340
|
+
super(getErrorMessage(type, cause));
|
|
341
|
+
this.cause = cause;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
var SerovalParserError = class extends SerovalError {
|
|
345
|
+
constructor(cause) {
|
|
346
|
+
super("parsing", cause);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var SerovalUnsupportedTypeError = class extends Error {
|
|
350
|
+
constructor(value) {
|
|
351
|
+
super(`The value ${objectToString.call(value)} of type "${typeof value}" cannot be parsed/serialized.
|
|
352
|
+
|
|
353
|
+
There are few workarounds for this problem:
|
|
354
|
+
- Transform the value in a way that it can be serialized.
|
|
355
|
+
- If the reference is present on multiple runtimes (isomorphic), you can use the Reference API to map the references.`);
|
|
356
|
+
this.value = value;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var SerovalMissingReferenceError = class extends Error {
|
|
360
|
+
constructor(value) {
|
|
361
|
+
super('Missing reference for the value "' + objectToString.call(value) + '" of type "' + typeof value + '"');
|
|
362
|
+
this.value = value;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var SerovalDepthLimitError = class extends Error {
|
|
366
|
+
constructor(limit) {
|
|
367
|
+
super("Depth limit of " + limit + " reached");
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
var OpaqueReference = class {
|
|
371
|
+
constructor(value, replacement) {
|
|
372
|
+
this.value = value;
|
|
373
|
+
this.replacement = replacement;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var PROMISE_CONSTRUCTOR = () => {
|
|
377
|
+
const resolver = {
|
|
378
|
+
p: 0,
|
|
379
|
+
s: 0,
|
|
380
|
+
f: 0
|
|
381
|
+
};
|
|
382
|
+
resolver.p = new Promise((resolve, reject) => {
|
|
383
|
+
resolver.s = resolve;
|
|
384
|
+
resolver.f = reject;
|
|
385
|
+
});
|
|
386
|
+
return resolver;
|
|
387
|
+
};
|
|
388
|
+
var STREAM_CONSTRUCTOR = () => {
|
|
389
|
+
const buffer = [];
|
|
390
|
+
const listeners = [];
|
|
391
|
+
let alive = true;
|
|
392
|
+
let success = false;
|
|
393
|
+
let count = 0;
|
|
394
|
+
const flush = (value, mode, x) => {
|
|
395
|
+
for (x = 0;x < count; x++) {
|
|
396
|
+
if (listeners[x]) {
|
|
397
|
+
listeners[x][mode](value);
|
|
398
|
+
}
|
|
47
399
|
}
|
|
48
|
-
|
|
49
|
-
|
|
400
|
+
};
|
|
401
|
+
const up = (listener, x, z, current) => {
|
|
402
|
+
for (x = 0, z = buffer.length;x < z; x++) {
|
|
403
|
+
current = buffer[x];
|
|
404
|
+
if (!alive && x === z - 1) {
|
|
405
|
+
listener[success ? "return" : "throw"](current);
|
|
406
|
+
} else {
|
|
407
|
+
listener.next(current);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
const on = (listener, temp) => {
|
|
412
|
+
if (alive) {
|
|
413
|
+
temp = count++;
|
|
414
|
+
listeners[temp] = listener;
|
|
415
|
+
}
|
|
416
|
+
up(listener);
|
|
417
|
+
return () => {
|
|
418
|
+
if (alive) {
|
|
419
|
+
listeners[temp] = listeners[count];
|
|
420
|
+
listeners[count--] = undefined;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
__SEROVAL_STREAM__: true,
|
|
426
|
+
on: (listener) => on(listener),
|
|
427
|
+
next: (value) => {
|
|
428
|
+
if (alive) {
|
|
429
|
+
buffer.push(value);
|
|
430
|
+
flush(value, "next");
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
throw: (value) => {
|
|
434
|
+
if (alive) {
|
|
435
|
+
buffer.push(value);
|
|
436
|
+
flush(value, "throw");
|
|
437
|
+
alive = false;
|
|
438
|
+
success = false;
|
|
439
|
+
listeners.length = 0;
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
return: (value) => {
|
|
443
|
+
if (alive) {
|
|
444
|
+
buffer.push(value);
|
|
445
|
+
flush(value, "return");
|
|
446
|
+
alive = false;
|
|
447
|
+
success = true;
|
|
448
|
+
listeners.length = 0;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
var ITERATOR_CONSTRUCTOR = (symbol) => (sequence) => () => {
|
|
454
|
+
let index = 0;
|
|
455
|
+
const instance = {
|
|
456
|
+
[symbol]: () => instance,
|
|
457
|
+
next: () => {
|
|
458
|
+
if (index > sequence.d) {
|
|
459
|
+
return {
|
|
460
|
+
done: true,
|
|
461
|
+
value: undefined
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
const currentIndex = index++;
|
|
465
|
+
const data = sequence.v[currentIndex];
|
|
466
|
+
if (currentIndex === sequence.t) {
|
|
467
|
+
throw data;
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
done: currentIndex === sequence.d,
|
|
471
|
+
value: data
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
return instance;
|
|
476
|
+
};
|
|
477
|
+
var ASYNC_ITERATOR_CONSTRUCTOR = (symbol, createPromise) => (stream) => () => {
|
|
478
|
+
let count = 0;
|
|
479
|
+
let doneAt = -1;
|
|
480
|
+
let isThrow = false;
|
|
481
|
+
const buffer = [];
|
|
482
|
+
const pending = [];
|
|
483
|
+
const finalize = (i = 0, len = pending.length) => {
|
|
484
|
+
for (;i < len; i++) {
|
|
485
|
+
pending[i].s({
|
|
486
|
+
done: true,
|
|
487
|
+
value: undefined
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
stream.on({
|
|
492
|
+
next: (value) => {
|
|
493
|
+
const temp = pending.shift();
|
|
494
|
+
if (temp) {
|
|
495
|
+
temp.s({ done: false, value });
|
|
496
|
+
}
|
|
497
|
+
buffer.push(value);
|
|
498
|
+
},
|
|
499
|
+
throw: (value) => {
|
|
500
|
+
const temp = pending.shift();
|
|
501
|
+
if (temp) {
|
|
502
|
+
temp.f(value);
|
|
503
|
+
}
|
|
504
|
+
finalize();
|
|
505
|
+
doneAt = buffer.length;
|
|
506
|
+
isThrow = true;
|
|
507
|
+
buffer.push(value);
|
|
508
|
+
},
|
|
509
|
+
return: (value) => {
|
|
510
|
+
const temp = pending.shift();
|
|
511
|
+
if (temp) {
|
|
512
|
+
temp.s({ done: true, value });
|
|
513
|
+
}
|
|
514
|
+
finalize();
|
|
515
|
+
doneAt = buffer.length;
|
|
516
|
+
buffer.push(value);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
const instance = {
|
|
520
|
+
[symbol]: () => instance,
|
|
521
|
+
next: () => {
|
|
522
|
+
if (doneAt === -1) {
|
|
523
|
+
const index2 = count++;
|
|
524
|
+
if (index2 >= buffer.length) {
|
|
525
|
+
const temp = createPromise();
|
|
526
|
+
pending.push(temp);
|
|
527
|
+
return temp.p;
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
done: false,
|
|
531
|
+
value: buffer[index2]
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
if (count > doneAt) {
|
|
535
|
+
return {
|
|
536
|
+
done: true,
|
|
537
|
+
value: undefined
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
const index = count++;
|
|
541
|
+
const value = buffer[index];
|
|
542
|
+
if (index !== doneAt) {
|
|
543
|
+
return {
|
|
544
|
+
done: false,
|
|
545
|
+
value
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
if (isThrow) {
|
|
549
|
+
throw value;
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
done: true,
|
|
553
|
+
value
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
return instance;
|
|
558
|
+
};
|
|
559
|
+
function isSequence(value) {
|
|
560
|
+
return "__SEROVAL_SEQUENCE__" in value;
|
|
561
|
+
}
|
|
562
|
+
function createSequence(values, throwAt, doneAt) {
|
|
563
|
+
return {
|
|
564
|
+
__SEROVAL_SEQUENCE__: true,
|
|
565
|
+
v: values,
|
|
566
|
+
t: throwAt,
|
|
567
|
+
d: doneAt
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function createSequenceFromIterable(source) {
|
|
571
|
+
const values = [];
|
|
572
|
+
let throwsAt = -1;
|
|
573
|
+
let doneAt = -1;
|
|
574
|
+
const iterator = source[SYM_ITERATOR]();
|
|
575
|
+
while (true) {
|
|
576
|
+
try {
|
|
577
|
+
const value = iterator.next();
|
|
578
|
+
values.push(value.value);
|
|
579
|
+
if (value.done) {
|
|
580
|
+
doneAt = values.length - 1;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
} catch (error) {
|
|
584
|
+
throwsAt = values.length;
|
|
585
|
+
values.push(error);
|
|
50
586
|
}
|
|
51
587
|
}
|
|
52
|
-
return
|
|
588
|
+
return createSequence(values, throwsAt, doneAt);
|
|
589
|
+
}
|
|
590
|
+
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
591
|
+
var ITERATOR = {};
|
|
592
|
+
var ASYNC_ITERATOR = {};
|
|
593
|
+
var SPECIAL_REFS = {
|
|
594
|
+
[0]: {},
|
|
595
|
+
[1]: {},
|
|
596
|
+
[2]: {},
|
|
597
|
+
[3]: {},
|
|
598
|
+
[4]: {},
|
|
599
|
+
[5]: {}
|
|
600
|
+
};
|
|
601
|
+
function isStream(value) {
|
|
602
|
+
return "__SEROVAL_STREAM__" in value;
|
|
53
603
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
604
|
+
function createStream() {
|
|
605
|
+
return STREAM_CONSTRUCTOR();
|
|
56
606
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
607
|
+
function createStreamFromAsyncIterable(iterable) {
|
|
608
|
+
const stream = createStream();
|
|
609
|
+
const iterator = iterable[SYM_ASYNC_ITERATOR]();
|
|
610
|
+
async function push() {
|
|
611
|
+
try {
|
|
612
|
+
const value = await iterator.next();
|
|
613
|
+
if (value.done) {
|
|
614
|
+
stream.return(value.value);
|
|
615
|
+
} else {
|
|
616
|
+
stream.next(value.value);
|
|
617
|
+
await push();
|
|
618
|
+
}
|
|
619
|
+
} catch (error) {
|
|
620
|
+
stream.throw(error);
|
|
63
621
|
}
|
|
64
|
-
|
|
65
|
-
});
|
|
622
|
+
}
|
|
623
|
+
push().catch(() => {});
|
|
624
|
+
return stream;
|
|
66
625
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return
|
|
626
|
+
var createAsyncIterable = ASYNC_ITERATOR_CONSTRUCTOR(SYM_ASYNC_ITERATOR, PROMISE_CONSTRUCTOR);
|
|
627
|
+
async function promiseToResult(current) {
|
|
628
|
+
try {
|
|
629
|
+
return [1, await current];
|
|
630
|
+
} catch (e) {
|
|
631
|
+
return [0, e];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function createBaseParserContext(mode, options) {
|
|
635
|
+
return {
|
|
636
|
+
plugins: options.plugins,
|
|
637
|
+
mode,
|
|
638
|
+
marked: /* @__PURE__ */ new Set,
|
|
639
|
+
features: ALL_ENABLED ^ (options.disabledFeatures || 0),
|
|
640
|
+
refs: options.refs || /* @__PURE__ */ new Map,
|
|
641
|
+
depthLimit: options.depthLimit || 1000
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function markParserRef(ctx, id) {
|
|
645
|
+
ctx.marked.add(id);
|
|
646
|
+
}
|
|
647
|
+
function createIndexForValue(ctx, current) {
|
|
648
|
+
const id = ctx.refs.size;
|
|
649
|
+
ctx.refs.set(current, id);
|
|
650
|
+
return id;
|
|
651
|
+
}
|
|
652
|
+
function getNodeForIndexedValue(ctx, current) {
|
|
653
|
+
const registeredId = ctx.refs.get(current);
|
|
654
|
+
if (registeredId != null) {
|
|
655
|
+
markParserRef(ctx, registeredId);
|
|
656
|
+
return {
|
|
657
|
+
type: 1,
|
|
658
|
+
value: createIndexedValueNode(registeredId)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
return {
|
|
662
|
+
type: 0,
|
|
663
|
+
value: createIndexForValue(ctx, current)
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function getReferenceNode(ctx, current) {
|
|
667
|
+
const indexed = getNodeForIndexedValue(ctx, current);
|
|
668
|
+
if (indexed.type === 1) {
|
|
669
|
+
return indexed;
|
|
670
|
+
}
|
|
671
|
+
if (hasReferenceID(current)) {
|
|
672
|
+
return {
|
|
673
|
+
type: 2,
|
|
674
|
+
value: createReferenceNode(indexed.value, current)
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
return indexed;
|
|
678
|
+
}
|
|
679
|
+
function parseWellKnownSymbol(ctx, current) {
|
|
680
|
+
const ref = getReferenceNode(ctx, current);
|
|
681
|
+
if (ref.type !== 0) {
|
|
682
|
+
return ref.value;
|
|
683
|
+
}
|
|
684
|
+
if (current in INV_SYMBOL_REF) {
|
|
685
|
+
return createWKSymbolNode(ref.value, current);
|
|
686
|
+
}
|
|
687
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
688
|
+
}
|
|
689
|
+
function parseSpecialReference(ctx, ref) {
|
|
690
|
+
const result = getNodeForIndexedValue(ctx, SPECIAL_REFS[ref]);
|
|
691
|
+
if (result.type === 1) {
|
|
692
|
+
return result.value;
|
|
693
|
+
}
|
|
694
|
+
return createSerovalNode(26, result.value, ref, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL);
|
|
695
|
+
}
|
|
696
|
+
function parseIteratorFactory(ctx) {
|
|
697
|
+
const result = getNodeForIndexedValue(ctx, ITERATOR);
|
|
698
|
+
if (result.type === 1) {
|
|
699
|
+
return result.value;
|
|
700
|
+
}
|
|
701
|
+
return createSerovalNode(27, result.value, NIL, NIL, NIL, NIL, NIL, NIL, parseWellKnownSymbol(ctx, SYM_ITERATOR), NIL, NIL, NIL);
|
|
702
|
+
}
|
|
703
|
+
function parseAsyncIteratorFactory(ctx) {
|
|
704
|
+
const result = getNodeForIndexedValue(ctx, ASYNC_ITERATOR);
|
|
705
|
+
if (result.type === 1) {
|
|
706
|
+
return result.value;
|
|
707
|
+
}
|
|
708
|
+
return createSerovalNode(29, result.value, NIL, NIL, NIL, NIL, NIL, [
|
|
709
|
+
parseSpecialReference(ctx, 1),
|
|
710
|
+
parseWellKnownSymbol(ctx, SYM_ASYNC_ITERATOR)
|
|
711
|
+
], NIL, NIL, NIL, NIL);
|
|
712
|
+
}
|
|
713
|
+
function createObjectNode(id, current, empty, record) {
|
|
714
|
+
return createSerovalNode(empty ? 11 : 10, id, NIL, NIL, NIL, record, NIL, NIL, NIL, NIL, getObjectFlag(current), NIL);
|
|
715
|
+
}
|
|
716
|
+
function createMapNode(ctx, id, k, v) {
|
|
717
|
+
return createSerovalNode(8, id, NIL, NIL, NIL, NIL, { k, v }, NIL, parseSpecialReference(ctx, 0), NIL, NIL, NIL);
|
|
718
|
+
}
|
|
719
|
+
function createPromiseConstructorNode(ctx, id, resolver) {
|
|
720
|
+
return createSerovalNode(22, id, resolver, NIL, NIL, NIL, NIL, NIL, parseSpecialReference(ctx, 1), NIL, NIL, NIL);
|
|
721
|
+
}
|
|
722
|
+
function createArrayBufferNode(ctx, id, current) {
|
|
723
|
+
const bytes = new Uint8Array(current);
|
|
724
|
+
let result = "";
|
|
725
|
+
for (let i = 0, len = bytes.length;i < len; i++) {
|
|
726
|
+
result += String.fromCharCode(bytes[i]);
|
|
727
|
+
}
|
|
728
|
+
return createSerovalNode(19, id, serializeString(btoa(result)), NIL, NIL, NIL, NIL, NIL, parseSpecialReference(ctx, 5), NIL, NIL, NIL);
|
|
729
|
+
}
|
|
730
|
+
function createAsyncParserContext(mode, options) {
|
|
731
|
+
return {
|
|
732
|
+
base: createBaseParserContext(mode, options),
|
|
733
|
+
child: undefined
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
var AsyncParsePluginContext = class {
|
|
737
|
+
constructor(_p, depth) {
|
|
738
|
+
this._p = _p;
|
|
739
|
+
this.depth = depth;
|
|
740
|
+
}
|
|
741
|
+
parse(current) {
|
|
742
|
+
return parseAsync(this._p, this.depth, current);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
async function parseItems(ctx, depth, current) {
|
|
746
|
+
const nodes = [];
|
|
747
|
+
for (let i = 0, len = current.length;i < len; i++) {
|
|
748
|
+
if (i in current) {
|
|
749
|
+
nodes[i] = await parseAsync(ctx, depth, current[i]);
|
|
750
|
+
} else {
|
|
751
|
+
nodes[i] = 0;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return nodes;
|
|
755
|
+
}
|
|
756
|
+
async function parseArray(ctx, depth, id, current) {
|
|
757
|
+
return createArrayNode(id, current, await parseItems(ctx, depth, current));
|
|
758
|
+
}
|
|
759
|
+
async function parseProperties(ctx, depth, properties) {
|
|
760
|
+
const entries = Object.entries(properties);
|
|
761
|
+
const keyNodes = [];
|
|
762
|
+
const valueNodes = [];
|
|
763
|
+
for (let i = 0, len = entries.length;i < len; i++) {
|
|
764
|
+
keyNodes.push(serializeString(entries[i][0]));
|
|
765
|
+
valueNodes.push(await parseAsync(ctx, depth, entries[i][1]));
|
|
766
|
+
}
|
|
767
|
+
if (SYM_ITERATOR in properties) {
|
|
768
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
769
|
+
valueNodes.push(createIteratorFactoryInstanceNode(parseIteratorFactory(ctx.base), await parseAsync(ctx, depth, createSequenceFromIterable(properties))));
|
|
770
|
+
}
|
|
771
|
+
if (SYM_ASYNC_ITERATOR in properties) {
|
|
772
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
773
|
+
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), await parseAsync(ctx, depth, createStreamFromAsyncIterable(properties))));
|
|
774
|
+
}
|
|
775
|
+
if (SYM_TO_STRING_TAG in properties) {
|
|
776
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
777
|
+
valueNodes.push(createStringNode(properties[SYM_TO_STRING_TAG]));
|
|
778
|
+
}
|
|
779
|
+
if (SYM_IS_CONCAT_SPREADABLE in properties) {
|
|
780
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_IS_CONCAT_SPREADABLE));
|
|
781
|
+
valueNodes.push(properties[SYM_IS_CONCAT_SPREADABLE] ? TRUE_NODE : FALSE_NODE);
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
k: keyNodes,
|
|
785
|
+
v: valueNodes
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
async function parsePlainObject(ctx, depth, id, current, empty) {
|
|
789
|
+
return createObjectNode(id, current, empty, await parseProperties(ctx, depth, current));
|
|
790
|
+
}
|
|
791
|
+
async function parseBoxed(ctx, depth, id, current) {
|
|
792
|
+
return createBoxedNode(id, await parseAsync(ctx, depth, current.valueOf()));
|
|
793
|
+
}
|
|
794
|
+
async function parseTypedArray(ctx, depth, id, current) {
|
|
795
|
+
return createTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
796
|
+
}
|
|
797
|
+
async function parseBigIntTypedArray(ctx, depth, id, current) {
|
|
798
|
+
return createBigIntTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
799
|
+
}
|
|
800
|
+
async function parseDataView(ctx, depth, id, current) {
|
|
801
|
+
return createDataViewNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
802
|
+
}
|
|
803
|
+
async function parseError(ctx, depth, id, current) {
|
|
804
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
805
|
+
return createErrorNode(id, current, options ? await parseProperties(ctx, depth, options) : NIL);
|
|
806
|
+
}
|
|
807
|
+
async function parseAggregateError(ctx, depth, id, current) {
|
|
808
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
809
|
+
return createAggregateErrorNode(id, current, options ? await parseProperties(ctx, depth, options) : NIL);
|
|
810
|
+
}
|
|
811
|
+
async function parseMap(ctx, depth, id, current) {
|
|
812
|
+
const keyNodes = [];
|
|
813
|
+
const valueNodes = [];
|
|
814
|
+
for (const [key, value] of current.entries()) {
|
|
815
|
+
keyNodes.push(await parseAsync(ctx, depth, key));
|
|
816
|
+
valueNodes.push(await parseAsync(ctx, depth, value));
|
|
817
|
+
}
|
|
818
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
819
|
+
}
|
|
820
|
+
async function parseSet(ctx, depth, id, current) {
|
|
821
|
+
const items = [];
|
|
822
|
+
for (const item of current.keys()) {
|
|
823
|
+
items.push(await parseAsync(ctx, depth, item));
|
|
824
|
+
}
|
|
825
|
+
return createSetNode(id, items);
|
|
826
|
+
}
|
|
827
|
+
async function parsePlugin(ctx, depth, id, current) {
|
|
828
|
+
const currentPlugins = ctx.base.plugins;
|
|
829
|
+
if (currentPlugins) {
|
|
830
|
+
for (let i = 0, len = currentPlugins.length;i < len; i++) {
|
|
831
|
+
const plugin = currentPlugins[i];
|
|
832
|
+
if (plugin.parse.async && plugin.test(current)) {
|
|
833
|
+
return createPluginNode(id, plugin.tag, await plugin.parse.async(current, new AsyncParsePluginContext(ctx, depth), {
|
|
834
|
+
id
|
|
835
|
+
}));
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return NIL;
|
|
840
|
+
}
|
|
841
|
+
async function parsePromise(ctx, depth, id, current) {
|
|
842
|
+
const [status, result] = await promiseToResult(current);
|
|
843
|
+
return createSerovalNode(12, id, status, NIL, NIL, NIL, NIL, NIL, await parseAsync(ctx, depth, result), NIL, NIL, NIL);
|
|
844
|
+
}
|
|
845
|
+
function parseStreamHandle(depth, id, current, resolve, reject) {
|
|
846
|
+
const sequence = [];
|
|
847
|
+
const cleanup = current.on({
|
|
848
|
+
next: (value) => {
|
|
849
|
+
markParserRef(this.base, id);
|
|
850
|
+
parseAsync(this, depth, value).then((data) => {
|
|
851
|
+
sequence.push(createStreamNextNode(id, data));
|
|
852
|
+
}, (data) => {
|
|
853
|
+
reject(data);
|
|
854
|
+
cleanup();
|
|
855
|
+
});
|
|
856
|
+
},
|
|
857
|
+
throw: (value) => {
|
|
858
|
+
markParserRef(this.base, id);
|
|
859
|
+
parseAsync(this, depth, value).then((data) => {
|
|
860
|
+
sequence.push(createStreamThrowNode(id, data));
|
|
861
|
+
resolve(sequence);
|
|
862
|
+
cleanup();
|
|
863
|
+
}, (data) => {
|
|
864
|
+
reject(data);
|
|
865
|
+
cleanup();
|
|
866
|
+
});
|
|
867
|
+
},
|
|
868
|
+
return: (value) => {
|
|
869
|
+
markParserRef(this.base, id);
|
|
870
|
+
parseAsync(this, depth, value).then((data) => {
|
|
871
|
+
sequence.push(createStreamReturnNode(id, data));
|
|
872
|
+
resolve(sequence);
|
|
873
|
+
cleanup();
|
|
874
|
+
}, (data) => {
|
|
875
|
+
reject(data);
|
|
876
|
+
cleanup();
|
|
877
|
+
});
|
|
878
|
+
}
|
|
71
879
|
});
|
|
72
880
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
881
|
+
async function parseStream(ctx, depth, id, current) {
|
|
882
|
+
return createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), await new Promise(parseStreamHandle.bind(ctx, depth, id, current)));
|
|
883
|
+
}
|
|
884
|
+
async function parseSequence(ctx, depth, id, current) {
|
|
885
|
+
const nodes = [];
|
|
886
|
+
for (let i = 0, len = current.v.length;i < len; i++) {
|
|
887
|
+
nodes[i] = await parseAsync(ctx, depth, current.v[i]);
|
|
888
|
+
}
|
|
889
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
890
|
+
}
|
|
891
|
+
async function parseObjectAsync(ctx, depth, id, current) {
|
|
892
|
+
if (Array.isArray(current)) {
|
|
893
|
+
return parseArray(ctx, depth, id, current);
|
|
894
|
+
}
|
|
895
|
+
if (isStream(current)) {
|
|
896
|
+
return parseStream(ctx, depth, id, current);
|
|
897
|
+
}
|
|
898
|
+
if (isSequence(current)) {
|
|
899
|
+
return parseSequence(ctx, depth, id, current);
|
|
900
|
+
}
|
|
901
|
+
const currentClass = current.constructor;
|
|
902
|
+
if (currentClass === OpaqueReference) {
|
|
903
|
+
return parseAsync(ctx, depth, current.replacement);
|
|
904
|
+
}
|
|
905
|
+
const parsed = await parsePlugin(ctx, depth, id, current);
|
|
906
|
+
if (parsed) {
|
|
907
|
+
return parsed;
|
|
908
|
+
}
|
|
909
|
+
switch (currentClass) {
|
|
910
|
+
case Object:
|
|
911
|
+
return parsePlainObject(ctx, depth, id, current, false);
|
|
912
|
+
case NIL:
|
|
913
|
+
return parsePlainObject(ctx, depth, id, current, true);
|
|
914
|
+
case Date:
|
|
915
|
+
return createDateNode(id, current);
|
|
916
|
+
case Error:
|
|
917
|
+
case EvalError:
|
|
918
|
+
case RangeError:
|
|
919
|
+
case ReferenceError:
|
|
920
|
+
case SyntaxError:
|
|
921
|
+
case TypeError:
|
|
922
|
+
case URIError:
|
|
923
|
+
return parseError(ctx, depth, id, current);
|
|
924
|
+
case Number:
|
|
925
|
+
case Boolean:
|
|
926
|
+
case String:
|
|
927
|
+
case BigInt:
|
|
928
|
+
return parseBoxed(ctx, depth, id, current);
|
|
929
|
+
case ArrayBuffer:
|
|
930
|
+
return createArrayBufferNode(ctx.base, id, current);
|
|
931
|
+
case Int8Array:
|
|
932
|
+
case Int16Array:
|
|
933
|
+
case Int32Array:
|
|
934
|
+
case Uint8Array:
|
|
935
|
+
case Uint16Array:
|
|
936
|
+
case Uint32Array:
|
|
937
|
+
case Uint8ClampedArray:
|
|
938
|
+
case Float32Array:
|
|
939
|
+
case Float64Array:
|
|
940
|
+
return parseTypedArray(ctx, depth, id, current);
|
|
941
|
+
case DataView:
|
|
942
|
+
return parseDataView(ctx, depth, id, current);
|
|
943
|
+
case Map:
|
|
944
|
+
return parseMap(ctx, depth, id, current);
|
|
945
|
+
case Set:
|
|
946
|
+
return parseSet(ctx, depth, id, current);
|
|
947
|
+
default:
|
|
948
|
+
break;
|
|
77
949
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
950
|
+
if (currentClass === Promise || current instanceof Promise) {
|
|
951
|
+
return parsePromise(ctx, depth, id, current);
|
|
80
952
|
}
|
|
81
|
-
|
|
82
|
-
|
|
953
|
+
const currentFeatures = ctx.base.features;
|
|
954
|
+
if (currentFeatures & 32 && currentClass === RegExp) {
|
|
955
|
+
return createRegExpNode(id, current);
|
|
83
956
|
}
|
|
84
|
-
if (
|
|
85
|
-
|
|
957
|
+
if (currentFeatures & 16) {
|
|
958
|
+
switch (currentClass) {
|
|
959
|
+
case BigInt64Array:
|
|
960
|
+
case BigUint64Array:
|
|
961
|
+
return parseBigIntTypedArray(ctx, depth, id, current);
|
|
962
|
+
default:
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (currentFeatures & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
967
|
+
return parseAggregateError(ctx, depth, id, current);
|
|
968
|
+
}
|
|
969
|
+
if (current instanceof Error) {
|
|
970
|
+
return parseError(ctx, depth, id, current);
|
|
971
|
+
}
|
|
972
|
+
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) {
|
|
973
|
+
return parsePlainObject(ctx, depth, id, current, !!currentClass);
|
|
974
|
+
}
|
|
975
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
976
|
+
}
|
|
977
|
+
async function parseFunctionAsync(ctx, depth, current) {
|
|
978
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
979
|
+
if (ref.type !== 0) {
|
|
980
|
+
return ref.value;
|
|
981
|
+
}
|
|
982
|
+
const plugin = await parsePlugin(ctx, depth, ref.value, current);
|
|
983
|
+
if (plugin) {
|
|
984
|
+
return plugin;
|
|
985
|
+
}
|
|
986
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
987
|
+
}
|
|
988
|
+
async function parseAsync(ctx, depth, current) {
|
|
989
|
+
switch (typeof current) {
|
|
990
|
+
case "boolean":
|
|
991
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
992
|
+
case "undefined":
|
|
993
|
+
return UNDEFINED_NODE;
|
|
994
|
+
case "string":
|
|
995
|
+
return createStringNode(current);
|
|
996
|
+
case "number":
|
|
997
|
+
return createNumberNode(current);
|
|
998
|
+
case "bigint":
|
|
999
|
+
return createBigIntNode(current);
|
|
1000
|
+
case "object": {
|
|
1001
|
+
if (current) {
|
|
1002
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
1003
|
+
return ref.type === 0 ? await parseObjectAsync(ctx, depth + 1, ref.value, current) : ref.value;
|
|
1004
|
+
}
|
|
1005
|
+
return NULL_NODE;
|
|
1006
|
+
}
|
|
1007
|
+
case "symbol":
|
|
1008
|
+
return parseWellKnownSymbol(ctx.base, current);
|
|
1009
|
+
case "function":
|
|
1010
|
+
return parseFunctionAsync(ctx, depth, current);
|
|
1011
|
+
default:
|
|
1012
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
86
1013
|
}
|
|
87
|
-
return parts.length > 0 ? `
|
|
88
|
-
${parts.join(`
|
|
89
|
-
`)}
|
|
90
|
-
` : "";
|
|
91
1014
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1015
|
+
async function parseTopAsync(ctx, current) {
|
|
1016
|
+
try {
|
|
1017
|
+
return await parseAsync(ctx, 0, current);
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function dedupePlugins(deduped, plugins) {
|
|
1023
|
+
for (let i = 0, len = plugins.length;i < len; i++) {
|
|
1024
|
+
const current = plugins[i];
|
|
1025
|
+
if (!deduped.has(current)) {
|
|
1026
|
+
deduped.add(current);
|
|
1027
|
+
if (current.extends) {
|
|
1028
|
+
dedupePlugins(deduped, current.extends);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
108
1032
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
path = path.replace(key === "*" ? "*" : `:${key}`, val);
|
|
1033
|
+
function resolvePlugins(plugins) {
|
|
1034
|
+
if (plugins) {
|
|
1035
|
+
const deduped = /* @__PURE__ */ new Set;
|
|
1036
|
+
dedupePlugins(deduped, plugins);
|
|
1037
|
+
return [...deduped];
|
|
115
1038
|
}
|
|
116
|
-
return
|
|
1039
|
+
return;
|
|
117
1040
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1041
|
+
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
1042
|
+
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
1043
|
+
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
1044
|
+
var REF_CHARS_LEN = REF_CHARS.length;
|
|
1045
|
+
function createSyncParserContext(mode, options) {
|
|
1046
|
+
return {
|
|
1047
|
+
type: 1,
|
|
1048
|
+
base: createBaseParserContext(mode, options),
|
|
1049
|
+
child: NIL
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
var SyncParsePluginContext = class {
|
|
1053
|
+
constructor(_p, depth) {
|
|
1054
|
+
this._p = _p;
|
|
1055
|
+
this.depth = depth;
|
|
1056
|
+
}
|
|
1057
|
+
parse(current) {
|
|
1058
|
+
return parseSOS(this._p, this.depth, current);
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
var StreamParsePluginContext = class {
|
|
1062
|
+
constructor(_p, depth) {
|
|
1063
|
+
this._p = _p;
|
|
1064
|
+
this.depth = depth;
|
|
1065
|
+
}
|
|
1066
|
+
parse(current) {
|
|
1067
|
+
return parseSOS(this._p, this.depth, current);
|
|
1068
|
+
}
|
|
1069
|
+
parseWithError(current) {
|
|
1070
|
+
return parseWithError(this._p, this.depth, current);
|
|
1071
|
+
}
|
|
1072
|
+
isAlive() {
|
|
1073
|
+
return this._p.state.alive;
|
|
1074
|
+
}
|
|
1075
|
+
pushPendingState() {
|
|
1076
|
+
pushPendingState(this._p);
|
|
1077
|
+
}
|
|
1078
|
+
popPendingState() {
|
|
1079
|
+
popPendingState(this._p);
|
|
1080
|
+
}
|
|
1081
|
+
onParse(node) {
|
|
1082
|
+
onParse(this._p, node);
|
|
1083
|
+
}
|
|
1084
|
+
onError(error) {
|
|
1085
|
+
onError(this._p, error);
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
function parseItems2(ctx, depth, current) {
|
|
1089
|
+
const nodes = [];
|
|
1090
|
+
for (let i = 0, len = current.length;i < len; i++) {
|
|
1091
|
+
if (i in current) {
|
|
1092
|
+
nodes[i] = parseSOS(ctx, depth, current[i]);
|
|
1093
|
+
} else {
|
|
1094
|
+
nodes[i] = 0;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return nodes;
|
|
1098
|
+
}
|
|
1099
|
+
function parseArray2(ctx, depth, id, current) {
|
|
1100
|
+
return createArrayNode(id, current, parseItems2(ctx, depth, current));
|
|
1101
|
+
}
|
|
1102
|
+
function parseProperties2(ctx, depth, properties) {
|
|
1103
|
+
const entries = Object.entries(properties);
|
|
1104
|
+
const keyNodes = [];
|
|
1105
|
+
const valueNodes = [];
|
|
1106
|
+
for (let i = 0, len = entries.length;i < len; i++) {
|
|
1107
|
+
keyNodes.push(serializeString(entries[i][0]));
|
|
1108
|
+
valueNodes.push(parseSOS(ctx, depth, entries[i][1]));
|
|
1109
|
+
}
|
|
1110
|
+
if (SYM_ITERATOR in properties) {
|
|
1111
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
1112
|
+
valueNodes.push(createIteratorFactoryInstanceNode(parseIteratorFactory(ctx.base), parseSOS(ctx, depth, createSequenceFromIterable(properties))));
|
|
1113
|
+
}
|
|
1114
|
+
if (SYM_ASYNC_ITERATOR in properties) {
|
|
1115
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
1116
|
+
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), parseSOS(ctx, depth, ctx.type === 1 ? createStream() : createStreamFromAsyncIterable(properties))));
|
|
1117
|
+
}
|
|
1118
|
+
if (SYM_TO_STRING_TAG in properties) {
|
|
1119
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
1120
|
+
valueNodes.push(createStringNode(properties[SYM_TO_STRING_TAG]));
|
|
1121
|
+
}
|
|
1122
|
+
if (SYM_IS_CONCAT_SPREADABLE in properties) {
|
|
1123
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_IS_CONCAT_SPREADABLE));
|
|
1124
|
+
valueNodes.push(properties[SYM_IS_CONCAT_SPREADABLE] ? TRUE_NODE : FALSE_NODE);
|
|
1125
|
+
}
|
|
1126
|
+
return {
|
|
1127
|
+
k: keyNodes,
|
|
1128
|
+
v: valueNodes
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
function parsePlainObject2(ctx, depth, id, current, empty) {
|
|
1132
|
+
return createObjectNode(id, current, empty, parseProperties2(ctx, depth, current));
|
|
1133
|
+
}
|
|
1134
|
+
function parseBoxed2(ctx, depth, id, current) {
|
|
1135
|
+
return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
|
|
1136
|
+
}
|
|
1137
|
+
function parseTypedArray2(ctx, depth, id, current) {
|
|
1138
|
+
return createTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
1139
|
+
}
|
|
1140
|
+
function parseBigIntTypedArray2(ctx, depth, id, current) {
|
|
1141
|
+
return createBigIntTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
1142
|
+
}
|
|
1143
|
+
function parseDataView2(ctx, depth, id, current) {
|
|
1144
|
+
return createDataViewNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
1145
|
+
}
|
|
1146
|
+
function parseError2(ctx, depth, id, current) {
|
|
1147
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
1148
|
+
return createErrorNode(id, current, options ? parseProperties2(ctx, depth, options) : NIL);
|
|
1149
|
+
}
|
|
1150
|
+
function parseAggregateError2(ctx, depth, id, current) {
|
|
1151
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
1152
|
+
return createAggregateErrorNode(id, current, options ? parseProperties2(ctx, depth, options) : NIL);
|
|
1153
|
+
}
|
|
1154
|
+
function parseMap2(ctx, depth, id, current) {
|
|
1155
|
+
const keyNodes = [];
|
|
1156
|
+
const valueNodes = [];
|
|
1157
|
+
for (const [key, value] of current.entries()) {
|
|
1158
|
+
keyNodes.push(parseSOS(ctx, depth, key));
|
|
1159
|
+
valueNodes.push(parseSOS(ctx, depth, value));
|
|
1160
|
+
}
|
|
1161
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
1162
|
+
}
|
|
1163
|
+
function parseSet2(ctx, depth, id, current) {
|
|
1164
|
+
const items = [];
|
|
1165
|
+
for (const item of current.keys()) {
|
|
1166
|
+
items.push(parseSOS(ctx, depth, item));
|
|
1167
|
+
}
|
|
1168
|
+
return createSetNode(id, items);
|
|
1169
|
+
}
|
|
1170
|
+
function parseStream2(ctx, depth, id, current) {
|
|
1171
|
+
const result = createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), []);
|
|
1172
|
+
if (ctx.type === 1) {
|
|
1173
|
+
return result;
|
|
1174
|
+
}
|
|
1175
|
+
pushPendingState(ctx);
|
|
1176
|
+
current.on({
|
|
1177
|
+
next: (value) => {
|
|
1178
|
+
if (ctx.state.alive) {
|
|
1179
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
1180
|
+
if (parsed) {
|
|
1181
|
+
onParse(ctx, createStreamNextNode(id, parsed));
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
throw: (value) => {
|
|
1186
|
+
if (ctx.state.alive) {
|
|
1187
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
1188
|
+
if (parsed) {
|
|
1189
|
+
onParse(ctx, createStreamThrowNode(id, parsed));
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
popPendingState(ctx);
|
|
1193
|
+
},
|
|
1194
|
+
return: (value) => {
|
|
1195
|
+
if (ctx.state.alive) {
|
|
1196
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
1197
|
+
if (parsed) {
|
|
1198
|
+
onParse(ctx, createStreamReturnNode(id, parsed));
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
popPendingState(ctx);
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
return result;
|
|
1205
|
+
}
|
|
1206
|
+
function handlePromiseSuccess(id, depth, data) {
|
|
1207
|
+
if (this.state.alive) {
|
|
1208
|
+
const parsed = parseWithError(this, depth, data);
|
|
1209
|
+
if (parsed) {
|
|
1210
|
+
onParse(this, createSerovalNode(23, id, NIL, NIL, NIL, NIL, NIL, [
|
|
1211
|
+
parseSpecialReference(this.base, 2),
|
|
1212
|
+
parsed
|
|
1213
|
+
], NIL, NIL, NIL, NIL));
|
|
1214
|
+
}
|
|
1215
|
+
popPendingState(this);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function handlePromiseFailure(id, depth, data) {
|
|
1219
|
+
if (this.state.alive) {
|
|
1220
|
+
const parsed = parseWithError(this, depth, data);
|
|
1221
|
+
if (parsed) {
|
|
1222
|
+
onParse(this, createSerovalNode(24, id, NIL, NIL, NIL, NIL, NIL, [
|
|
1223
|
+
parseSpecialReference(this.base, 3),
|
|
1224
|
+
parsed
|
|
1225
|
+
], NIL, NIL, NIL, NIL));
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
popPendingState(this);
|
|
1229
|
+
}
|
|
1230
|
+
function parsePromise2(ctx, depth, id, current) {
|
|
1231
|
+
const resolver = createIndexForValue(ctx.base, {});
|
|
1232
|
+
if (ctx.type === 2) {
|
|
1233
|
+
pushPendingState(ctx);
|
|
1234
|
+
current.then(handlePromiseSuccess.bind(ctx, resolver, depth), handlePromiseFailure.bind(ctx, resolver, depth));
|
|
1235
|
+
}
|
|
1236
|
+
return createPromiseConstructorNode(ctx.base, id, resolver);
|
|
1237
|
+
}
|
|
1238
|
+
function parsePluginSync(ctx, depth, id, current, currentPlugins) {
|
|
1239
|
+
for (let i = 0, len = currentPlugins.length;i < len; i++) {
|
|
1240
|
+
const plugin = currentPlugins[i];
|
|
1241
|
+
if (plugin.parse.sync && plugin.test(current)) {
|
|
1242
|
+
return createPluginNode(id, plugin.tag, plugin.parse.sync(current, new SyncParsePluginContext(ctx, depth), {
|
|
1243
|
+
id
|
|
1244
|
+
}));
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return NIL;
|
|
1248
|
+
}
|
|
1249
|
+
function parsePluginStream(ctx, depth, id, current, currentPlugins) {
|
|
1250
|
+
for (let i = 0, len = currentPlugins.length;i < len; i++) {
|
|
1251
|
+
const plugin = currentPlugins[i];
|
|
1252
|
+
if (plugin.parse.stream && plugin.test(current)) {
|
|
1253
|
+
return createPluginNode(id, plugin.tag, plugin.parse.stream(current, new StreamParsePluginContext(ctx, depth), {
|
|
1254
|
+
id
|
|
1255
|
+
}));
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return NIL;
|
|
1259
|
+
}
|
|
1260
|
+
function parsePlugin2(ctx, depth, id, current) {
|
|
1261
|
+
const currentPlugins = ctx.base.plugins;
|
|
1262
|
+
if (currentPlugins) {
|
|
1263
|
+
return ctx.type === 1 ? parsePluginSync(ctx, depth, id, current, currentPlugins) : parsePluginStream(ctx, depth, id, current, currentPlugins);
|
|
1264
|
+
}
|
|
1265
|
+
return NIL;
|
|
1266
|
+
}
|
|
1267
|
+
function parseSequence2(ctx, depth, id, current) {
|
|
1268
|
+
const nodes = [];
|
|
1269
|
+
for (let i = 0, len = current.v.length;i < len; i++) {
|
|
1270
|
+
nodes[i] = parseSOS(ctx, depth, current.v[i]);
|
|
1271
|
+
}
|
|
1272
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
1273
|
+
}
|
|
1274
|
+
function parseObjectPhase2(ctx, depth, id, current, currentClass) {
|
|
1275
|
+
switch (currentClass) {
|
|
1276
|
+
case Object:
|
|
1277
|
+
return parsePlainObject2(ctx, depth, id, current, false);
|
|
1278
|
+
case NIL:
|
|
1279
|
+
return parsePlainObject2(ctx, depth, id, current, true);
|
|
1280
|
+
case Date:
|
|
1281
|
+
return createDateNode(id, current);
|
|
1282
|
+
case Error:
|
|
1283
|
+
case EvalError:
|
|
1284
|
+
case RangeError:
|
|
1285
|
+
case ReferenceError:
|
|
1286
|
+
case SyntaxError:
|
|
1287
|
+
case TypeError:
|
|
1288
|
+
case URIError:
|
|
1289
|
+
return parseError2(ctx, depth, id, current);
|
|
1290
|
+
case Number:
|
|
1291
|
+
case Boolean:
|
|
1292
|
+
case String:
|
|
1293
|
+
case BigInt:
|
|
1294
|
+
return parseBoxed2(ctx, depth, id, current);
|
|
1295
|
+
case ArrayBuffer:
|
|
1296
|
+
return createArrayBufferNode(ctx.base, id, current);
|
|
1297
|
+
case Int8Array:
|
|
1298
|
+
case Int16Array:
|
|
1299
|
+
case Int32Array:
|
|
1300
|
+
case Uint8Array:
|
|
1301
|
+
case Uint16Array:
|
|
1302
|
+
case Uint32Array:
|
|
1303
|
+
case Uint8ClampedArray:
|
|
1304
|
+
case Float32Array:
|
|
1305
|
+
case Float64Array:
|
|
1306
|
+
return parseTypedArray2(ctx, depth, id, current);
|
|
1307
|
+
case DataView:
|
|
1308
|
+
return parseDataView2(ctx, depth, id, current);
|
|
1309
|
+
case Map:
|
|
1310
|
+
return parseMap2(ctx, depth, id, current);
|
|
1311
|
+
case Set:
|
|
1312
|
+
return parseSet2(ctx, depth, id, current);
|
|
1313
|
+
default:
|
|
125
1314
|
break;
|
|
1315
|
+
}
|
|
1316
|
+
if (currentClass === Promise || current instanceof Promise) {
|
|
1317
|
+
return parsePromise2(ctx, depth, id, current);
|
|
1318
|
+
}
|
|
1319
|
+
const currentFeatures = ctx.base.features;
|
|
1320
|
+
if (currentFeatures & 32 && currentClass === RegExp) {
|
|
1321
|
+
return createRegExpNode(id, current);
|
|
1322
|
+
}
|
|
1323
|
+
if (currentFeatures & 16) {
|
|
1324
|
+
switch (currentClass) {
|
|
1325
|
+
case BigInt64Array:
|
|
1326
|
+
case BigUint64Array:
|
|
1327
|
+
return parseBigIntTypedArray2(ctx, depth, id, current);
|
|
1328
|
+
default:
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (currentFeatures & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
1333
|
+
return parseAggregateError2(ctx, depth, id, current);
|
|
1334
|
+
}
|
|
1335
|
+
if (current instanceof Error) {
|
|
1336
|
+
return parseError2(ctx, depth, id, current);
|
|
1337
|
+
}
|
|
1338
|
+
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) {
|
|
1339
|
+
return parsePlainObject2(ctx, depth, id, current, !!currentClass);
|
|
1340
|
+
}
|
|
1341
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1342
|
+
}
|
|
1343
|
+
function parseObject(ctx, depth, id, current) {
|
|
1344
|
+
if (Array.isArray(current)) {
|
|
1345
|
+
return parseArray2(ctx, depth, id, current);
|
|
1346
|
+
}
|
|
1347
|
+
if (isStream(current)) {
|
|
1348
|
+
return parseStream2(ctx, depth, id, current);
|
|
1349
|
+
}
|
|
1350
|
+
if (isSequence(current)) {
|
|
1351
|
+
return parseSequence2(ctx, depth, id, current);
|
|
1352
|
+
}
|
|
1353
|
+
const currentClass = current.constructor;
|
|
1354
|
+
if (currentClass === OpaqueReference) {
|
|
1355
|
+
return parseSOS(ctx, depth, current.replacement);
|
|
1356
|
+
}
|
|
1357
|
+
const parsed = parsePlugin2(ctx, depth, id, current);
|
|
1358
|
+
if (parsed) {
|
|
1359
|
+
return parsed;
|
|
1360
|
+
}
|
|
1361
|
+
return parseObjectPhase2(ctx, depth, id, current, currentClass);
|
|
1362
|
+
}
|
|
1363
|
+
function parseFunction(ctx, depth, current) {
|
|
1364
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
1365
|
+
if (ref.type !== 0) {
|
|
1366
|
+
return ref.value;
|
|
1367
|
+
}
|
|
1368
|
+
const plugin = parsePlugin2(ctx, depth, ref.value, current);
|
|
1369
|
+
if (plugin) {
|
|
1370
|
+
return plugin;
|
|
1371
|
+
}
|
|
1372
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1373
|
+
}
|
|
1374
|
+
function parseSOS(ctx, depth, current) {
|
|
1375
|
+
if (depth >= ctx.base.depthLimit) {
|
|
1376
|
+
throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
1377
|
+
}
|
|
1378
|
+
switch (typeof current) {
|
|
1379
|
+
case "boolean":
|
|
1380
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
1381
|
+
case "undefined":
|
|
1382
|
+
return UNDEFINED_NODE;
|
|
1383
|
+
case "string":
|
|
1384
|
+
return createStringNode(current);
|
|
1385
|
+
case "number":
|
|
1386
|
+
return createNumberNode(current);
|
|
1387
|
+
case "bigint":
|
|
1388
|
+
return createBigIntNode(current);
|
|
1389
|
+
case "object": {
|
|
1390
|
+
if (current) {
|
|
1391
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
1392
|
+
return ref.type === 0 ? parseObject(ctx, depth + 1, ref.value, current) : ref.value;
|
|
1393
|
+
}
|
|
1394
|
+
return NULL_NODE;
|
|
1395
|
+
}
|
|
1396
|
+
case "symbol":
|
|
1397
|
+
return parseWellKnownSymbol(ctx.base, current);
|
|
1398
|
+
case "function": {
|
|
1399
|
+
return parseFunction(ctx, depth, current);
|
|
1400
|
+
}
|
|
1401
|
+
default:
|
|
1402
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
function parseTop(ctx, current) {
|
|
1406
|
+
try {
|
|
1407
|
+
return parseSOS(ctx, 0, current);
|
|
1408
|
+
} catch (error) {
|
|
1409
|
+
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
function onParse(ctx, node) {
|
|
1413
|
+
if (ctx.state.initial) {
|
|
1414
|
+
ctx.state.buffer.push(node);
|
|
1415
|
+
} else {
|
|
1416
|
+
onParseInternal(ctx, node, false);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
function onError(ctx, error) {
|
|
1420
|
+
if (ctx.state.onError) {
|
|
1421
|
+
ctx.state.onError(error);
|
|
1422
|
+
} else {
|
|
1423
|
+
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function onDone(ctx) {
|
|
1427
|
+
if (ctx.state.onDone) {
|
|
1428
|
+
ctx.state.onDone();
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
function onParseInternal(ctx, node, initial) {
|
|
1432
|
+
try {
|
|
1433
|
+
ctx.state.onParse(node, initial);
|
|
1434
|
+
} catch (error) {
|
|
1435
|
+
onError(ctx, error);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
function pushPendingState(ctx) {
|
|
1439
|
+
ctx.state.pending++;
|
|
1440
|
+
}
|
|
1441
|
+
function popPendingState(ctx) {
|
|
1442
|
+
if (--ctx.state.pending <= 0) {
|
|
1443
|
+
onDone(ctx);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function parseWithError(ctx, depth, current) {
|
|
1447
|
+
try {
|
|
1448
|
+
return parseSOS(ctx, depth, current);
|
|
1449
|
+
} catch (err) {
|
|
1450
|
+
onError(ctx, err);
|
|
1451
|
+
return NIL;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
function toCrossJSON(source, options = {}) {
|
|
1455
|
+
const plugins = resolvePlugins(options.plugins);
|
|
1456
|
+
const ctx = createSyncParserContext(2, {
|
|
1457
|
+
plugins,
|
|
1458
|
+
disabledFeatures: options.disabledFeatures,
|
|
1459
|
+
refs: options.refs
|
|
1460
|
+
});
|
|
1461
|
+
return parseTop(ctx, source);
|
|
1462
|
+
}
|
|
1463
|
+
async function toCrossJSONAsync(source, options = {}) {
|
|
1464
|
+
const plugins = resolvePlugins(options.plugins);
|
|
1465
|
+
const ctx = createAsyncParserContext(2, {
|
|
1466
|
+
plugins,
|
|
1467
|
+
disabledFeatures: options.disabledFeatures,
|
|
1468
|
+
refs: options.refs
|
|
1469
|
+
});
|
|
1470
|
+
return await parseTopAsync(ctx, source);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// src/auto-invalidate/registry.ts
|
|
1474
|
+
class AutoInvalidateRegistry {
|
|
1475
|
+
pathToTags = new Map;
|
|
1476
|
+
tagToPaths = new Map;
|
|
1477
|
+
registerLoaderTags(urlPath, tags) {
|
|
1478
|
+
if (!tags || tags.length === 0) {
|
|
1479
|
+
this.unregisterPath(urlPath);
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
this.unregisterPath(urlPath);
|
|
1483
|
+
const uniqueTags = new Set(tags);
|
|
1484
|
+
this.pathToTags.set(urlPath, uniqueTags);
|
|
1485
|
+
for (const tag of uniqueTags) {
|
|
1486
|
+
let paths = this.tagToPaths.get(tag);
|
|
1487
|
+
if (!paths) {
|
|
1488
|
+
paths = new Set;
|
|
1489
|
+
this.tagToPaths.set(tag, paths);
|
|
1490
|
+
}
|
|
1491
|
+
paths.add(urlPath);
|
|
126
1492
|
}
|
|
127
|
-
html += decoder.decode(value, { stream: true });
|
|
128
1493
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1494
|
+
pathsForTags(tags) {
|
|
1495
|
+
const paths = new Set;
|
|
1496
|
+
for (const tag of tags) {
|
|
1497
|
+
for (const path of this.tagToPaths.get(tag) ?? []) {
|
|
1498
|
+
paths.add(path);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
return [...paths];
|
|
1502
|
+
}
|
|
1503
|
+
unregisterPath(urlPath) {
|
|
1504
|
+
const tags = this.pathToTags.get(urlPath);
|
|
1505
|
+
if (!tags) {
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
for (const tag of tags) {
|
|
1509
|
+
const paths = this.tagToPaths.get(tag);
|
|
1510
|
+
if (!paths) {
|
|
1511
|
+
continue;
|
|
1512
|
+
}
|
|
1513
|
+
paths.delete(urlPath);
|
|
1514
|
+
if (paths.size === 0) {
|
|
1515
|
+
this.tagToPaths.delete(tag);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
this.pathToTags.delete(urlPath);
|
|
1519
|
+
}
|
|
1520
|
+
reset() {
|
|
1521
|
+
this.pathToTags.clear();
|
|
1522
|
+
this.tagToPaths.clear();
|
|
143
1523
|
}
|
|
144
|
-
return headPre + headData + bodyPre + reactHtml + injectedBodyPost;
|
|
145
1524
|
}
|
|
146
|
-
|
|
147
|
-
// src/render/dev-cache.ts
|
|
148
|
-
import { statSync } from "fs";
|
|
149
|
-
|
|
150
|
-
// src/render/cache.ts
|
|
151
|
-
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
1525
|
+
var autoInvalidateRegistry = new AutoInvalidateRegistry;
|
|
152
1526
|
|
|
153
1527
|
// src/context-logger.ts
|
|
154
1528
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
155
1529
|
|
|
156
|
-
// ../../node_modules/.bun/evlog@2.
|
|
1530
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/utils.mjs
|
|
157
1531
|
function formatDuration(ms) {
|
|
158
1532
|
if (ms < 1000)
|
|
159
1533
|
return `${Math.round(ms)}ms`;
|
|
@@ -241,6 +1615,21 @@ function getCssLevelColor(level) {
|
|
|
241
1615
|
function escapeFormatString(str) {
|
|
242
1616
|
return str.replace(/%/g, "%%");
|
|
243
1617
|
}
|
|
1618
|
+
var SENSITIVE_HEADERS = [
|
|
1619
|
+
"authorization",
|
|
1620
|
+
"cookie",
|
|
1621
|
+
"set-cookie",
|
|
1622
|
+
"x-api-key",
|
|
1623
|
+
"x-auth-token",
|
|
1624
|
+
"proxy-authorization"
|
|
1625
|
+
];
|
|
1626
|
+
function filterSafeHeaders(headers) {
|
|
1627
|
+
const safeHeaders = {};
|
|
1628
|
+
for (const [key, value] of Object.entries(headers))
|
|
1629
|
+
if (!SENSITIVE_HEADERS.includes(key.toLowerCase()))
|
|
1630
|
+
safeHeaders[key] = value;
|
|
1631
|
+
return safeHeaders;
|
|
1632
|
+
}
|
|
244
1633
|
var patternCache = /* @__PURE__ */ new Map;
|
|
245
1634
|
function matchesPattern(path, pattern) {
|
|
246
1635
|
let regex = patternCache.get(pattern);
|
|
@@ -252,7 +1641,25 @@ function matchesPattern(path, pattern) {
|
|
|
252
1641
|
return regex.test(path);
|
|
253
1642
|
}
|
|
254
1643
|
|
|
255
|
-
// ../../node_modules/.bun/evlog@2.
|
|
1644
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/headers-CU-QqnYg.mjs
|
|
1645
|
+
function extractSafeHeaders(headers) {
|
|
1646
|
+
const raw = {};
|
|
1647
|
+
headers.forEach((value, key) => {
|
|
1648
|
+
raw[key] = value;
|
|
1649
|
+
});
|
|
1650
|
+
return filterSafeHeaders(raw);
|
|
1651
|
+
}
|
|
1652
|
+
function extractSafeNodeHeaders(headers) {
|
|
1653
|
+
const raw = {};
|
|
1654
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
1655
|
+
if (value === undefined)
|
|
1656
|
+
continue;
|
|
1657
|
+
raw[key] = Array.isArray(value) ? value.join(", ") : value;
|
|
1658
|
+
}
|
|
1659
|
+
return filterSafeHeaders(raw);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/audit-pV5aLGP0.mjs
|
|
256
1663
|
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
257
1664
|
var builtinPatterns = {
|
|
258
1665
|
creditCard: {
|
|
@@ -403,6 +1810,117 @@ function applyMaskers(value, maskers) {
|
|
|
403
1810
|
}
|
|
404
1811
|
return result;
|
|
405
1812
|
}
|
|
1813
|
+
function logPluginError(name, hook, err) {
|
|
1814
|
+
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
1815
|
+
}
|
|
1816
|
+
function createPluginRunner(plugins = []) {
|
|
1817
|
+
const byName = /* @__PURE__ */ new Map;
|
|
1818
|
+
for (const plugin of plugins)
|
|
1819
|
+
byName.set(plugin.name, plugin);
|
|
1820
|
+
const list = Array.from(byName.values());
|
|
1821
|
+
return {
|
|
1822
|
+
plugins: list,
|
|
1823
|
+
hasEnrich: list.some((p) => typeof p.enrich === "function"),
|
|
1824
|
+
hasDrain: list.some((p) => typeof p.drain === "function"),
|
|
1825
|
+
hasKeep: list.some((p) => typeof p.keep === "function"),
|
|
1826
|
+
hasRequestLifecycle: list.some((p) => typeof p.onRequestStart === "function" || typeof p.onRequestFinish === "function"),
|
|
1827
|
+
hasClientLog: list.some((p) => typeof p.onClientLog === "function"),
|
|
1828
|
+
hasExtendLogger: list.some((p) => typeof p.extendLogger === "function"),
|
|
1829
|
+
applyExtendLogger(logger) {
|
|
1830
|
+
for (const plugin of list) {
|
|
1831
|
+
if (!plugin.extendLogger)
|
|
1832
|
+
continue;
|
|
1833
|
+
try {
|
|
1834
|
+
plugin.extendLogger(logger);
|
|
1835
|
+
} catch (err) {
|
|
1836
|
+
logPluginError(plugin.name, "extendLogger", err);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
runOnRequestStart(ctx) {
|
|
1841
|
+
for (const plugin of list) {
|
|
1842
|
+
if (!plugin.onRequestStart)
|
|
1843
|
+
continue;
|
|
1844
|
+
try {
|
|
1845
|
+
plugin.onRequestStart(ctx);
|
|
1846
|
+
} catch (err) {
|
|
1847
|
+
logPluginError(plugin.name, "onRequestStart", err);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
runOnRequestFinish(ctx) {
|
|
1852
|
+
for (const plugin of list) {
|
|
1853
|
+
if (!plugin.onRequestFinish)
|
|
1854
|
+
continue;
|
|
1855
|
+
try {
|
|
1856
|
+
plugin.onRequestFinish(ctx);
|
|
1857
|
+
} catch (err) {
|
|
1858
|
+
logPluginError(plugin.name, "onRequestFinish", err);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
},
|
|
1862
|
+
async runEnrich(ctx) {
|
|
1863
|
+
for (const plugin of list) {
|
|
1864
|
+
if (!plugin.enrich)
|
|
1865
|
+
continue;
|
|
1866
|
+
try {
|
|
1867
|
+
await plugin.enrich(ctx);
|
|
1868
|
+
} catch (err) {
|
|
1869
|
+
logPluginError(plugin.name, "enrich", err);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
},
|
|
1873
|
+
async runDrain(ctx) {
|
|
1874
|
+
const drains = list.filter((p) => typeof p.drain === "function");
|
|
1875
|
+
if (drains.length === 0)
|
|
1876
|
+
return;
|
|
1877
|
+
await Promise.allSettled(drains.map(async (plugin) => {
|
|
1878
|
+
try {
|
|
1879
|
+
await plugin.drain(ctx);
|
|
1880
|
+
} catch (err) {
|
|
1881
|
+
logPluginError(plugin.name, "drain", err);
|
|
1882
|
+
}
|
|
1883
|
+
}));
|
|
1884
|
+
},
|
|
1885
|
+
async runKeep(ctx) {
|
|
1886
|
+
for (const plugin of list) {
|
|
1887
|
+
if (!plugin.keep)
|
|
1888
|
+
continue;
|
|
1889
|
+
try {
|
|
1890
|
+
await plugin.keep(ctx);
|
|
1891
|
+
} catch (err) {
|
|
1892
|
+
logPluginError(plugin.name, "keep", err);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
},
|
|
1896
|
+
runOnClientLog(ctx) {
|
|
1897
|
+
for (const plugin of list) {
|
|
1898
|
+
if (!plugin.onClientLog)
|
|
1899
|
+
continue;
|
|
1900
|
+
try {
|
|
1901
|
+
plugin.onClientLog(ctx);
|
|
1902
|
+
} catch (err) {
|
|
1903
|
+
logPluginError(plugin.name, "onClientLog", err);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
},
|
|
1907
|
+
async runSetup(ctx) {
|
|
1908
|
+
for (const plugin of list) {
|
|
1909
|
+
if (!plugin.setup)
|
|
1910
|
+
continue;
|
|
1911
|
+
try {
|
|
1912
|
+
await plugin.setup(ctx);
|
|
1913
|
+
} catch (err) {
|
|
1914
|
+
logPluginError(plugin.name, "setup", err);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
var emptyRunner = createPluginRunner([]);
|
|
1921
|
+
function getEmptyPluginRunner() {
|
|
1922
|
+
return emptyRunner;
|
|
1923
|
+
}
|
|
406
1924
|
function isPlainObject(val) {
|
|
407
1925
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
408
1926
|
}
|
|
@@ -441,6 +1959,7 @@ var globalRedact;
|
|
|
441
1959
|
var globalEnabled = true;
|
|
442
1960
|
var globalSilent = false;
|
|
443
1961
|
var globalMinLevel = "debug";
|
|
1962
|
+
var globalPluginRunner = getEmptyPluginRunner();
|
|
444
1963
|
function initLogger(config = {}) {
|
|
445
1964
|
globalEnabled = config.enabled ?? true;
|
|
446
1965
|
const detected = detectEnvironment();
|
|
@@ -458,9 +1977,22 @@ function initLogger(config = {}) {
|
|
|
458
1977
|
globalRedact = resolveRedactConfig(config.redact ?? !isDev());
|
|
459
1978
|
globalSilent = config.silent ?? false;
|
|
460
1979
|
globalMinLevel = config.minLevel ?? "debug";
|
|
461
|
-
|
|
1980
|
+
globalPluginRunner = config.plugins?.length ? createPluginRunner(config.plugins) : getEmptyPluginRunner();
|
|
1981
|
+
if (globalPluginRunner.plugins.length > 0)
|
|
1982
|
+
globalPluginRunner.runSetup({ env: { ...globalEnv } });
|
|
1983
|
+
const hasAnyDrain = !!globalDrain || globalPluginRunner.hasDrain;
|
|
1984
|
+
if (globalSilent && !hasAnyDrain && !config._suppressDrainWarning)
|
|
462
1985
|
console.warn("[evlog] silent mode is enabled but no drain is configured. Events will be built and sampled but not output anywhere. Set a drain via initLogger({ drain }) or a framework hook (evlog:drain).");
|
|
463
1986
|
}
|
|
1987
|
+
function getGlobalPluginRunner() {
|
|
1988
|
+
return globalPluginRunner;
|
|
1989
|
+
}
|
|
1990
|
+
function isEnabled() {
|
|
1991
|
+
return globalEnabled;
|
|
1992
|
+
}
|
|
1993
|
+
function getGlobalDrain() {
|
|
1994
|
+
return globalDrain;
|
|
1995
|
+
}
|
|
464
1996
|
function shouldSample(level) {
|
|
465
1997
|
const { rates } = globalSampling;
|
|
466
1998
|
if (!rates)
|
|
@@ -528,12 +2060,20 @@ function emitWideEvent(level, event, options = {}) {
|
|
|
528
2060
|
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
529
2061
|
else
|
|
530
2062
|
console[getConsoleMethod(level)](formatted);
|
|
531
|
-
if (
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
2063
|
+
if (!deferDrain) {
|
|
2064
|
+
const drainPromises = [];
|
|
2065
|
+
if (globalDrain)
|
|
2066
|
+
drainPromises.push((async () => {
|
|
2067
|
+
try {
|
|
2068
|
+
await globalDrain({ event: formatted });
|
|
2069
|
+
} catch (err) {
|
|
2070
|
+
console.error("[evlog] drain failed:", err);
|
|
2071
|
+
}
|
|
2072
|
+
})());
|
|
2073
|
+
if (globalPluginRunner.hasDrain)
|
|
2074
|
+
drainPromises.push(globalPluginRunner.runDrain({ event: formatted }));
|
|
2075
|
+
if (drainPromises.length > 0 && waitUntil)
|
|
2076
|
+
waitUntil(Promise.all(drainPromises));
|
|
537
2077
|
}
|
|
538
2078
|
return formatted;
|
|
539
2079
|
}
|
|
@@ -902,6 +2442,7 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
902
2442
|
};
|
|
903
2443
|
const errRecord = err;
|
|
904
2444
|
for (const k of [
|
|
2445
|
+
"code",
|
|
905
2446
|
"status",
|
|
906
2447
|
"statusText",
|
|
907
2448
|
"statusCode",
|
|
@@ -984,6 +2525,20 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
984
2525
|
}
|
|
985
2526
|
};
|
|
986
2527
|
}
|
|
2528
|
+
function createRequestLogger(options = {}, internalOptions) {
|
|
2529
|
+
const { method, path, requestId, waitUntil: optionsWaitUntil } = options;
|
|
2530
|
+
const initial = {};
|
|
2531
|
+
if (method !== undefined)
|
|
2532
|
+
initial.method = method;
|
|
2533
|
+
if (path !== undefined)
|
|
2534
|
+
initial.path = path;
|
|
2535
|
+
if (requestId !== undefined)
|
|
2536
|
+
initial.requestId = requestId;
|
|
2537
|
+
return createLogger(initial, {
|
|
2538
|
+
...internalOptions,
|
|
2539
|
+
waitUntil: internalOptions?.waitUntil ?? optionsWaitUntil
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
987
2542
|
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
988
2543
|
initLogger(__EVLOG_CONFIG__);
|
|
989
2544
|
function stableStringify(value) {
|
|
@@ -1035,72 +2590,558 @@ function buildAuditFields(input) {
|
|
|
1035
2590
|
version: input.version ?? 1
|
|
1036
2591
|
};
|
|
1037
2592
|
}
|
|
1038
|
-
function decorateAudit(audit, timestamp) {
|
|
1039
|
-
if (audit.idempotencyKey)
|
|
1040
|
-
return audit;
|
|
1041
|
-
return {
|
|
1042
|
-
...audit,
|
|
1043
|
-
idempotencyKey: computeIdempotencyKey(audit, timestamp)
|
|
1044
|
-
};
|
|
2593
|
+
function decorateAudit(audit, timestamp) {
|
|
2594
|
+
if (audit.idempotencyKey)
|
|
2595
|
+
return audit;
|
|
2596
|
+
return {
|
|
2597
|
+
...audit,
|
|
2598
|
+
idempotencyKey: computeIdempotencyKey(audit, timestamp)
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
function consumeAuditForceKeep(context) {
|
|
2602
|
+
if (context._auditForceKeep) {
|
|
2603
|
+
delete context._auditForceKeep;
|
|
2604
|
+
return true;
|
|
2605
|
+
}
|
|
2606
|
+
if (context.audit)
|
|
2607
|
+
return true;
|
|
2608
|
+
return false;
|
|
2609
|
+
}
|
|
2610
|
+
function finalizeAudit(event) {
|
|
2611
|
+
const a = event.audit;
|
|
2612
|
+
if (!a)
|
|
2613
|
+
return;
|
|
2614
|
+
event.audit = decorateAudit(a, String(event.timestamp));
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/errors-BQgyQ9xe.mjs
|
|
2618
|
+
function extractErrorStatus(error) {
|
|
2619
|
+
if (error === null || typeof error !== "object")
|
|
2620
|
+
return 500;
|
|
2621
|
+
const raw = error.status ?? error.statusCode;
|
|
2622
|
+
const status = Number(raw);
|
|
2623
|
+
return Number.isFinite(status) ? status : 500;
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/routes-CnIgYWf8.mjs
|
|
2627
|
+
function shouldLog(path, include, exclude) {
|
|
2628
|
+
if (exclude && exclude.length > 0) {
|
|
2629
|
+
if (exclude.some((pattern) => matchesPattern(path, pattern)))
|
|
2630
|
+
return false;
|
|
2631
|
+
}
|
|
2632
|
+
if (!include || include.length === 0)
|
|
2633
|
+
return true;
|
|
2634
|
+
return include.some((pattern) => matchesPattern(path, pattern));
|
|
2635
|
+
}
|
|
2636
|
+
function getServiceForPath(path, routes) {
|
|
2637
|
+
if (!routes)
|
|
2638
|
+
return;
|
|
2639
|
+
for (const [pattern, config] of Object.entries(routes))
|
|
2640
|
+
if (matchesPattern(path, pattern))
|
|
2641
|
+
return config.service;
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/fork-8u_zFOJq.mjs
|
|
2645
|
+
var noopResult = {
|
|
2646
|
+
logger: {
|
|
2647
|
+
set() {},
|
|
2648
|
+
error() {},
|
|
2649
|
+
info() {},
|
|
2650
|
+
warn() {},
|
|
2651
|
+
emit() {
|
|
2652
|
+
return null;
|
|
2653
|
+
},
|
|
2654
|
+
getContext() {
|
|
2655
|
+
return {};
|
|
2656
|
+
}
|
|
2657
|
+
},
|
|
2658
|
+
finish: () => Promise.resolve(null),
|
|
2659
|
+
skipped: true
|
|
2660
|
+
};
|
|
2661
|
+
var runnerCache = /* @__PURE__ */ new WeakMap;
|
|
2662
|
+
function resolveMiddlewarePluginRunner(options) {
|
|
2663
|
+
const global2 = getGlobalPluginRunner();
|
|
2664
|
+
const local = options.plugins;
|
|
2665
|
+
if (!local || local.length === 0)
|
|
2666
|
+
return global2;
|
|
2667
|
+
const cached = runnerCache.get(local);
|
|
2668
|
+
if (cached && cached.global === global2)
|
|
2669
|
+
return cached.merged;
|
|
2670
|
+
const merged = /* @__PURE__ */ new Map;
|
|
2671
|
+
for (const plugin of global2.plugins)
|
|
2672
|
+
merged.set(plugin.name, plugin);
|
|
2673
|
+
for (const plugin of local)
|
|
2674
|
+
merged.set(plugin.name, plugin);
|
|
2675
|
+
if (merged.size === 0)
|
|
2676
|
+
return getEmptyPluginRunner();
|
|
2677
|
+
const runner = createPluginRunner(Array.from(merged.values()));
|
|
2678
|
+
runnerCache.set(local, {
|
|
2679
|
+
global: global2,
|
|
2680
|
+
merged: runner
|
|
2681
|
+
});
|
|
2682
|
+
return runner;
|
|
2683
|
+
}
|
|
2684
|
+
async function runEnrichAndDrain(emittedEvent, options, requestInfo, responseStatus, plugins) {
|
|
2685
|
+
const runner = plugins ?? resolveMiddlewarePluginRunner(options);
|
|
2686
|
+
const resolvedRedact = resolveRedactConfig(options.redact);
|
|
2687
|
+
if (resolvedRedact)
|
|
2688
|
+
redactEvent(emittedEvent, resolvedRedact);
|
|
2689
|
+
if (options.enrich || runner.hasEnrich) {
|
|
2690
|
+
const enrichCtx = {
|
|
2691
|
+
event: emittedEvent,
|
|
2692
|
+
request: requestInfo,
|
|
2693
|
+
headers: options.headers,
|
|
2694
|
+
response: { status: responseStatus }
|
|
2695
|
+
};
|
|
2696
|
+
if (options.enrich)
|
|
2697
|
+
try {
|
|
2698
|
+
await options.enrich(enrichCtx);
|
|
2699
|
+
} catch (err) {
|
|
2700
|
+
console.error("[evlog] enrich failed:", err);
|
|
2701
|
+
}
|
|
2702
|
+
if (runner.hasEnrich)
|
|
2703
|
+
await runner.runEnrich(enrichCtx);
|
|
2704
|
+
}
|
|
2705
|
+
const drain = options.drain ?? getGlobalDrain();
|
|
2706
|
+
const hasUserDrain = !!drain;
|
|
2707
|
+
const hasPluginDrain = runner.hasDrain;
|
|
2708
|
+
if (hasUserDrain || hasPluginDrain) {
|
|
2709
|
+
const drainCtx = {
|
|
2710
|
+
event: emittedEvent,
|
|
2711
|
+
request: requestInfo,
|
|
2712
|
+
headers: options.headers
|
|
2713
|
+
};
|
|
2714
|
+
const tasks = [];
|
|
2715
|
+
if (hasUserDrain)
|
|
2716
|
+
tasks.push((async () => {
|
|
2717
|
+
try {
|
|
2718
|
+
await drain(drainCtx);
|
|
2719
|
+
} catch (err) {
|
|
2720
|
+
console.error("[evlog] drain failed:", err);
|
|
2721
|
+
}
|
|
2722
|
+
})());
|
|
2723
|
+
if (hasPluginDrain)
|
|
2724
|
+
tasks.push(runner.runDrain(drainCtx));
|
|
2725
|
+
await Promise.all(tasks);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
function createMiddlewareLogger(options) {
|
|
2729
|
+
if (!isEnabled())
|
|
2730
|
+
return noopResult;
|
|
2731
|
+
const { method, path, requestId, include, exclude, routes, keep } = options;
|
|
2732
|
+
if (!shouldLog(path, include, exclude))
|
|
2733
|
+
return noopResult;
|
|
2734
|
+
const resolvedRequestId = requestId || crypto.randomUUID();
|
|
2735
|
+
const logger = createRequestLogger({
|
|
2736
|
+
method,
|
|
2737
|
+
path,
|
|
2738
|
+
requestId: resolvedRequestId
|
|
2739
|
+
}, { _deferDrain: true });
|
|
2740
|
+
const routeService = getServiceForPath(path, routes);
|
|
2741
|
+
if (routeService)
|
|
2742
|
+
logger.set({ service: routeService });
|
|
2743
|
+
const pluginRunner = resolveMiddlewarePluginRunner(options);
|
|
2744
|
+
if (pluginRunner.hasExtendLogger)
|
|
2745
|
+
pluginRunner.applyExtendLogger(logger);
|
|
2746
|
+
const startTime = Date.now();
|
|
2747
|
+
const requestInfo = {
|
|
2748
|
+
method,
|
|
2749
|
+
path,
|
|
2750
|
+
requestId: resolvedRequestId
|
|
2751
|
+
};
|
|
2752
|
+
if (pluginRunner.hasRequestLifecycle)
|
|
2753
|
+
pluginRunner.runOnRequestStart({
|
|
2754
|
+
logger,
|
|
2755
|
+
request: requestInfo,
|
|
2756
|
+
headers: options.headers
|
|
2757
|
+
});
|
|
2758
|
+
const finish = async (opts) => {
|
|
2759
|
+
const { status, error } = opts ?? {};
|
|
2760
|
+
if (error) {
|
|
2761
|
+
logger.error(error);
|
|
2762
|
+
const errorStatus = extractErrorStatus(error);
|
|
2763
|
+
logger.set({ status: errorStatus });
|
|
2764
|
+
} else if (status !== undefined)
|
|
2765
|
+
logger.set({ status });
|
|
2766
|
+
const durationMs = Date.now() - startTime;
|
|
2767
|
+
const resolvedStatus = error ? extractErrorStatus(error) : status ?? logger.getContext().status;
|
|
2768
|
+
const tailCtx = {
|
|
2769
|
+
status: resolvedStatus,
|
|
2770
|
+
duration: durationMs,
|
|
2771
|
+
path,
|
|
2772
|
+
method,
|
|
2773
|
+
context: logger.getContext(),
|
|
2774
|
+
shouldKeep: false
|
|
2775
|
+
};
|
|
2776
|
+
if (keep)
|
|
2777
|
+
await keep(tailCtx);
|
|
2778
|
+
if (pluginRunner.hasKeep)
|
|
2779
|
+
await pluginRunner.runKeep(tailCtx);
|
|
2780
|
+
const forceKeep = tailCtx.shouldKeep || shouldKeep(tailCtx);
|
|
2781
|
+
const emittedEvent = logger.emit({ _forceKeep: forceKeep });
|
|
2782
|
+
if (emittedEvent && (options.enrich || options.drain || pluginRunner.hasEnrich || pluginRunner.hasDrain || getGlobalDrain()))
|
|
2783
|
+
await runEnrichAndDrain(emittedEvent, options, requestInfo, resolvedStatus, pluginRunner);
|
|
2784
|
+
if (pluginRunner.hasRequestLifecycle)
|
|
2785
|
+
pluginRunner.runOnRequestFinish({
|
|
2786
|
+
logger,
|
|
2787
|
+
request: requestInfo,
|
|
2788
|
+
headers: options.headers,
|
|
2789
|
+
event: emittedEvent,
|
|
2790
|
+
status: resolvedStatus,
|
|
2791
|
+
durationMs,
|
|
2792
|
+
error
|
|
2793
|
+
});
|
|
2794
|
+
return emittedEvent;
|
|
2795
|
+
};
|
|
2796
|
+
return {
|
|
2797
|
+
logger,
|
|
2798
|
+
finish,
|
|
2799
|
+
skipped: false
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
function attachForkToLogger(storage, parent, middlewareOptions, lifecycle) {
|
|
2803
|
+
const log = parent;
|
|
2804
|
+
log.fork = (label, fn) => {
|
|
2805
|
+
forkBackgroundLogger({
|
|
2806
|
+
storage,
|
|
2807
|
+
parent,
|
|
2808
|
+
middlewareOptions,
|
|
2809
|
+
label,
|
|
2810
|
+
fn,
|
|
2811
|
+
lifecycle
|
|
2812
|
+
});
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
function forkBackgroundLogger(options) {
|
|
2816
|
+
const { storage, parent, middlewareOptions, label, fn, lifecycle } = options;
|
|
2817
|
+
const parentCtx = parent.getContext();
|
|
2818
|
+
const parentRequestId = parentCtx.requestId;
|
|
2819
|
+
if (typeof parentRequestId !== "string" || parentRequestId.length === 0)
|
|
2820
|
+
throw new Error("[evlog] log.fork() requires the parent logger to have a requestId. Ensure the request was created by evlog middleware.");
|
|
2821
|
+
const method = String(parentCtx.method ?? middlewareOptions.method);
|
|
2822
|
+
const path = String(parentCtx.path ?? middlewareOptions.path);
|
|
2823
|
+
const child = createRequestLogger({
|
|
2824
|
+
method,
|
|
2825
|
+
path,
|
|
2826
|
+
requestId: crypto.randomUUID()
|
|
2827
|
+
}, { _deferDrain: true });
|
|
2828
|
+
child.set({
|
|
2829
|
+
operation: label,
|
|
2830
|
+
_parentRequestId: parentRequestId
|
|
2831
|
+
});
|
|
2832
|
+
const childRequestInfo = {
|
|
2833
|
+
method,
|
|
2834
|
+
path,
|
|
2835
|
+
requestId: child.getContext().requestId
|
|
2836
|
+
};
|
|
2837
|
+
storage.run(child, () => {
|
|
2838
|
+
lifecycle?.onChildEnter?.(child);
|
|
2839
|
+
Promise.resolve().then(() => fn()).then(async () => {
|
|
2840
|
+
const emittedEvent = child.emit();
|
|
2841
|
+
const ctxStatus = child.getContext().status;
|
|
2842
|
+
const status = emittedEvent?.status ?? (typeof ctxStatus === "number" ? ctxStatus : undefined);
|
|
2843
|
+
if (emittedEvent && (middlewareOptions.enrich || middlewareOptions.drain || getGlobalDrain()))
|
|
2844
|
+
await runEnrichAndDrain(emittedEvent, middlewareOptions, childRequestInfo, status);
|
|
2845
|
+
}).catch(async (err) => {
|
|
2846
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2847
|
+
child.error(error);
|
|
2848
|
+
child.set({ status: extractErrorStatus(error) });
|
|
2849
|
+
const emittedEvent = child.emit();
|
|
2850
|
+
const status = extractErrorStatus(error);
|
|
2851
|
+
if (emittedEvent && (middlewareOptions.enrich || middlewareOptions.drain || getGlobalDrain()))
|
|
2852
|
+
await runEnrichAndDrain(emittedEvent, middlewareOptions, childRequestInfo, status);
|
|
2853
|
+
}).finally(() => {
|
|
2854
|
+
lifecycle?.onChildExit?.(child);
|
|
2855
|
+
});
|
|
2856
|
+
});
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/integration-DTZtjSqh.mjs
|
|
2860
|
+
function normalizeHeaders(headers) {
|
|
2861
|
+
if (!headers)
|
|
2862
|
+
return;
|
|
2863
|
+
if (typeof headers.forEach === "function" && typeof headers.get === "function")
|
|
2864
|
+
return extractSafeHeaders(headers);
|
|
2865
|
+
return extractSafeNodeHeaders(headers);
|
|
2866
|
+
}
|
|
2867
|
+
function defineFrameworkIntegration(spec) {
|
|
2868
|
+
return { start(ctx, options = {}) {
|
|
2869
|
+
const extracted = spec.extractRequest(ctx);
|
|
2870
|
+
const headers = normalizeHeaders(extracted.headers);
|
|
2871
|
+
const middlewareOptions = {
|
|
2872
|
+
method: extracted.method,
|
|
2873
|
+
path: extracted.path,
|
|
2874
|
+
requestId: extracted.requestId || crypto.randomUUID(),
|
|
2875
|
+
headers,
|
|
2876
|
+
...options
|
|
2877
|
+
};
|
|
2878
|
+
const result = createMiddlewareLogger(middlewareOptions);
|
|
2879
|
+
if (!result.skipped) {
|
|
2880
|
+
if (spec.storage)
|
|
2881
|
+
attachForkToLogger(spec.storage, result.logger, middlewareOptions, spec.forkLifecycle);
|
|
2882
|
+
spec.attachLogger(ctx, result.logger);
|
|
2883
|
+
}
|
|
2884
|
+
const { storage } = spec;
|
|
2885
|
+
const runWith = async (fn) => {
|
|
2886
|
+
if (!storage || result.skipped)
|
|
2887
|
+
return await fn();
|
|
2888
|
+
return await storage.run(result.logger, fn);
|
|
2889
|
+
};
|
|
2890
|
+
return {
|
|
2891
|
+
...result,
|
|
2892
|
+
middlewareOptions,
|
|
2893
|
+
runWith
|
|
2894
|
+
};
|
|
2895
|
+
} };
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
// ../../node_modules/.bun/evlog@2.17.0+f5a9d28f69418da1/node_modules/evlog/dist/elysia/index.mjs
|
|
2899
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
2900
|
+
import { Elysia } from "elysia";
|
|
2901
|
+
var storage = new AsyncLocalStorage;
|
|
2902
|
+
var activeLoggers = /* @__PURE__ */ new WeakSet;
|
|
2903
|
+
function useLogger() {
|
|
2904
|
+
const logger = storage.getStore();
|
|
2905
|
+
if (!logger || !activeLoggers.has(logger))
|
|
2906
|
+
throw new Error("[evlog] useLogger() was called outside of an evlog plugin context. Make sure app.use(evlog()) is registered before your routes.");
|
|
2907
|
+
return logger;
|
|
2908
|
+
}
|
|
2909
|
+
var integration = defineFrameworkIntegration({
|
|
2910
|
+
name: "elysia",
|
|
2911
|
+
extractRequest: ({ request, path, headers }) => ({
|
|
2912
|
+
method: request.method,
|
|
2913
|
+
path,
|
|
2914
|
+
headers,
|
|
2915
|
+
requestId: headers["x-request-id"]
|
|
2916
|
+
}),
|
|
2917
|
+
attachLogger: ({ request, path, headers }, logger) => {
|
|
2918
|
+
attachForkToLogger(storage, logger, {
|
|
2919
|
+
method: request.method,
|
|
2920
|
+
path,
|
|
2921
|
+
requestId: headers["x-request-id"]
|
|
2922
|
+
}, {
|
|
2923
|
+
onChildEnter: (child) => {
|
|
2924
|
+
activeLoggers.add(child);
|
|
2925
|
+
},
|
|
2926
|
+
onChildExit: (child) => {
|
|
2927
|
+
activeLoggers.delete(child);
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
activeLoggers.add(logger);
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
|
|
2934
|
+
// src/context-logger.ts
|
|
2935
|
+
var noopLogger2 = {
|
|
2936
|
+
set: () => {},
|
|
2937
|
+
error: () => {},
|
|
2938
|
+
info: () => {},
|
|
2939
|
+
warn: () => {},
|
|
2940
|
+
emit: () => null,
|
|
2941
|
+
getContext: () => ({}),
|
|
2942
|
+
fork: (_label, fn) => fn()
|
|
2943
|
+
};
|
|
2944
|
+
var syntheticRenderStorage = new AsyncLocalStorage2;
|
|
2945
|
+
function useLogger2() {
|
|
2946
|
+
try {
|
|
2947
|
+
return useLogger();
|
|
2948
|
+
} catch {
|
|
2949
|
+
return syntheticRenderStorage.getStore() ?? noopLogger2;
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
async function runInSyntheticRenderScope(fn, initialContext) {
|
|
2953
|
+
const logger = createLogger(initialContext);
|
|
2954
|
+
try {
|
|
2955
|
+
const result = await syntheticRenderStorage.run(logger, () => Promise.resolve(fn()));
|
|
2956
|
+
logger.emit();
|
|
2957
|
+
return result;
|
|
2958
|
+
} catch (err) {
|
|
2959
|
+
logger.error(err instanceof Error ? err : new Error(String(err)));
|
|
2960
|
+
logger.emit();
|
|
2961
|
+
throw err;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
// src/internal.ts
|
|
2966
|
+
var _compileCtx = null;
|
|
2967
|
+
function getCompileContext() {
|
|
2968
|
+
return _compileCtx;
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
// src/render/shell.ts
|
|
2972
|
+
function extractTitle(meta) {
|
|
2973
|
+
if (!meta) {
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2976
|
+
for (const entry of meta) {
|
|
2977
|
+
if ("title" in entry) {
|
|
2978
|
+
return entry.title;
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
return;
|
|
2982
|
+
}
|
|
2983
|
+
function isMetaTag(entry) {
|
|
2984
|
+
return !(("title" in entry) || ("charSet" in entry) || ("script:ld+json" in entry) || ("tagName" in entry));
|
|
2985
|
+
}
|
|
2986
|
+
function escapeHtml(str) {
|
|
2987
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2988
|
+
}
|
|
2989
|
+
function safeJson(value) {
|
|
2990
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
2991
|
+
}
|
|
2992
|
+
function renderAttrs(obj) {
|
|
2993
|
+
const parts = [];
|
|
2994
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
2995
|
+
if (v !== undefined) {
|
|
2996
|
+
parts.push(`${k}="${escapeHtml(String(v))}"`);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
return parts.join(" ");
|
|
3000
|
+
}
|
|
3001
|
+
function buildMetaParts(meta) {
|
|
3002
|
+
const parts = [];
|
|
3003
|
+
const title = extractTitle(meta);
|
|
3004
|
+
if (title) {
|
|
3005
|
+
parts.push(`<title>${escapeHtml(title)}</title>`);
|
|
3006
|
+
}
|
|
3007
|
+
for (const m of meta) {
|
|
3008
|
+
if (isMetaTag(m)) {
|
|
3009
|
+
parts.push(`<meta ${renderAttrs(m)} />`);
|
|
3010
|
+
}
|
|
3011
|
+
if ("script:ld+json" in m) {
|
|
3012
|
+
parts.push(`<script type="application/ld+json">${safeJson(m["script:ld+json"])}</script>`);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
return parts;
|
|
3016
|
+
}
|
|
3017
|
+
function buildLinkParts(links) {
|
|
3018
|
+
return links.map((link) => `<link ${renderAttrs(link)} />`);
|
|
3019
|
+
}
|
|
3020
|
+
function buildScriptParts(scripts) {
|
|
3021
|
+
return scripts.map((script) => {
|
|
3022
|
+
const { children, ...rest } = script;
|
|
3023
|
+
const attrs = renderAttrs(rest);
|
|
3024
|
+
if (children) {
|
|
3025
|
+
return `<script ${attrs}>${children}</script>`;
|
|
3026
|
+
}
|
|
3027
|
+
return `<script ${attrs}></script>`;
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
function buildStyleParts(styles) {
|
|
3031
|
+
return styles.map((style) => {
|
|
3032
|
+
const typeAttr = style.type ? ` type="${escapeHtml(style.type)}"` : "";
|
|
3033
|
+
return `<style${typeAttr}>${style.children}</style>`;
|
|
3034
|
+
});
|
|
1045
3035
|
}
|
|
1046
|
-
function
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
3036
|
+
function buildHeadInjection(headData) {
|
|
3037
|
+
const parts = [];
|
|
3038
|
+
if (headData?.meta) {
|
|
3039
|
+
parts.push(...buildMetaParts(headData.meta));
|
|
1050
3040
|
}
|
|
1051
|
-
if (
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1059
|
-
|
|
3041
|
+
if (headData?.links) {
|
|
3042
|
+
parts.push(...buildLinkParts(headData.links));
|
|
3043
|
+
}
|
|
3044
|
+
if (headData?.scripts) {
|
|
3045
|
+
parts.push(...buildScriptParts(headData.scripts));
|
|
3046
|
+
}
|
|
3047
|
+
if (headData?.styles) {
|
|
3048
|
+
parts.push(...buildStyleParts(headData.styles));
|
|
3049
|
+
}
|
|
3050
|
+
return parts.length > 0 ? `
|
|
3051
|
+
${parts.join(`
|
|
3052
|
+
`)}
|
|
3053
|
+
` : "";
|
|
1060
3054
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
3055
|
+
var THEME_INIT_SCRIPT = `<script>try{var __t=localStorage.getItem("furin-theme");` + `document.documentElement.classList.add(__t==="light"?"light":"dark")}` + `catch(e){document.documentElement.classList.add("dark")}</script>`;
|
|
3056
|
+
function generateIndexHtml() {
|
|
3057
|
+
return `<!DOCTYPE html>
|
|
3058
|
+
<html lang="en">
|
|
3059
|
+
<head>
|
|
3060
|
+
<meta charset="UTF-8">
|
|
3061
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
3062
|
+
${THEME_INIT_SCRIPT}
|
|
3063
|
+
<!--ssr-head-->
|
|
3064
|
+
</head>
|
|
3065
|
+
<body>
|
|
3066
|
+
<div id="root"><!--ssr-outlet--></div>
|
|
3067
|
+
<script type="module" src="./_hydrate.tsx"></script>
|
|
3068
|
+
</body>
|
|
3069
|
+
</html>
|
|
3070
|
+
`;
|
|
1071
3071
|
}
|
|
1072
3072
|
|
|
1073
|
-
// src/
|
|
1074
|
-
var
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
3073
|
+
// src/render/assemble.ts
|
|
3074
|
+
var FURIN_DEFERRED_GLOBAL = "__FURIN_DEFERRED__";
|
|
3075
|
+
function buildDeferredScript(deferredKeys) {
|
|
3076
|
+
const keysJson = safeJson(deferredKeys);
|
|
3077
|
+
return `<script id="${FURIN_DEFERRED_GLOBAL}">
|
|
3078
|
+
window.${FURIN_DEFERRED_GLOBAL} = {
|
|
3079
|
+
_deferredKeys: ${keysJson},
|
|
3080
|
+
_chunks: {},
|
|
3081
|
+
_resolvers: {},
|
|
3082
|
+
resolve(key, chunk) {
|
|
3083
|
+
this._chunks[key] = { a: 0, v: chunk };
|
|
3084
|
+
},
|
|
3085
|
+
reject(key, chunk) {
|
|
3086
|
+
this._chunks[key] = { a: 1, v: chunk };
|
|
3087
|
+
},
|
|
3088
|
+
getPromise(key) {
|
|
3089
|
+
if (!this._resolvers[key]) {
|
|
3090
|
+
var res, rej;
|
|
3091
|
+
var p = new Promise(function(resolve, reject) { res = resolve; rej = reject; });
|
|
3092
|
+
this._resolvers[key] = { resolve: res, reject: rej, promise: p };
|
|
3093
|
+
}
|
|
3094
|
+
return this._resolvers[key].promise;
|
|
3095
|
+
}
|
|
1082
3096
|
};
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
3097
|
+
</script>`;
|
|
3098
|
+
}
|
|
3099
|
+
function buildDeferredResolution(key, chunk, action) {
|
|
3100
|
+
const chunkJson = safeJson(chunk);
|
|
3101
|
+
return `<script>window.${FURIN_DEFERRED_GLOBAL}.${action}(${safeJson(key)},${chunkJson})</script>`;
|
|
3102
|
+
}
|
|
3103
|
+
function resolvePath(pattern, params) {
|
|
3104
|
+
let path = pattern;
|
|
3105
|
+
for (const [key, val] of Object.entries(params ?? {})) {
|
|
3106
|
+
path = path.replace(key === "*" ? "*" : `:${key}`, val);
|
|
1089
3107
|
}
|
|
3108
|
+
return path;
|
|
1090
3109
|
}
|
|
1091
|
-
async function
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
3110
|
+
async function streamToString(stream) {
|
|
3111
|
+
const reader = stream.getReader();
|
|
3112
|
+
const decoder = new TextDecoder;
|
|
3113
|
+
let html = "";
|
|
3114
|
+
for (;; ) {
|
|
3115
|
+
const { done, value } = await reader.read();
|
|
3116
|
+
if (done) {
|
|
3117
|
+
break;
|
|
3118
|
+
}
|
|
3119
|
+
html += decoder.decode(value, { stream: true });
|
|
3120
|
+
}
|
|
3121
|
+
html += decoder.decode();
|
|
3122
|
+
return html;
|
|
3123
|
+
}
|
|
3124
|
+
function splitTemplate(template) {
|
|
3125
|
+
const [headPre, afterHead = ""] = template.split("<!--ssr-head-->");
|
|
3126
|
+
const [bodyPre, bodyPost = ""] = afterHead.split("<!--ssr-outlet-->");
|
|
3127
|
+
return { headPre, bodyPre, bodyPost };
|
|
3128
|
+
}
|
|
3129
|
+
function assembleHTML(template, headData, reactHtml, data) {
|
|
3130
|
+
const { headPre, bodyPre, bodyPost } = splitTemplate(template);
|
|
3131
|
+
const dataScript = data ? `<script id="__FURIN_DATA__" type="application/json">${safeJson(data)}</script>` : "";
|
|
3132
|
+
let injectedBodyPost = bodyPost;
|
|
3133
|
+
if (dataScript) {
|
|
3134
|
+
injectedBodyPost = bodyPost.includes("</body>") ? bodyPost.replace("</body>", `${dataScript}</body>`) : bodyPost + dataScript;
|
|
1101
3135
|
}
|
|
3136
|
+
return headPre + headData + bodyPre + reactHtml + injectedBodyPost;
|
|
1102
3137
|
}
|
|
1103
3138
|
|
|
3139
|
+
// src/render/dev-cache.ts
|
|
3140
|
+
import { statSync } from "fs";
|
|
3141
|
+
|
|
3142
|
+
// src/render/cache.ts
|
|
3143
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
3144
|
+
|
|
1104
3145
|
// src/render/route-cache.ts
|
|
1105
3146
|
function defaultPathFromKey(key) {
|
|
1106
3147
|
return key;
|
|
@@ -1196,11 +3237,17 @@ var MAX_ISR_CACHE_SIZE = 1000;
|
|
|
1196
3237
|
var MAX_SSG_CACHE_SIZE = 1000;
|
|
1197
3238
|
var isrRouteCache = createRouteCache({
|
|
1198
3239
|
maxSize: MAX_ISR_CACHE_SIZE,
|
|
1199
|
-
name: "render:isr-html"
|
|
3240
|
+
name: "render:isr-html",
|
|
3241
|
+
onDelete: (key) => {
|
|
3242
|
+
autoInvalidateRegistry.unregisterPath(key);
|
|
3243
|
+
}
|
|
1200
3244
|
});
|
|
1201
3245
|
var ssgRouteCache = createRouteCache({
|
|
1202
3246
|
maxSize: MAX_SSG_CACHE_SIZE,
|
|
1203
|
-
name: "render:ssg-html"
|
|
3247
|
+
name: "render:ssg-html",
|
|
3248
|
+
onDelete: (key) => {
|
|
3249
|
+
autoInvalidateRegistry.unregisterPath(key);
|
|
3250
|
+
}
|
|
1204
3251
|
});
|
|
1205
3252
|
var isrCache = isrRouteCache.store;
|
|
1206
3253
|
var ssgCache = ssgRouteCache.store;
|
|
@@ -1270,6 +3317,10 @@ function createDevLoaderCache(name) {
|
|
|
1270
3317
|
name,
|
|
1271
3318
|
onDelete: (key, entry) => {
|
|
1272
3319
|
unindexEntryDependencies(key, entry.dependencies);
|
|
3320
|
+
const urlPath = urlPathFromCacheKey(key);
|
|
3321
|
+
if (urlPath) {
|
|
3322
|
+
autoInvalidateRegistry.unregisterPath(urlPath);
|
|
3323
|
+
}
|
|
1273
3324
|
},
|
|
1274
3325
|
onSet: (key, entry, previous) => {
|
|
1275
3326
|
if (previous) {
|
|
@@ -1329,6 +3380,41 @@ function isDevLoaderCacheValid(entry) {
|
|
|
1329
3380
|
return true;
|
|
1330
3381
|
}
|
|
1331
3382
|
|
|
3383
|
+
// src/render/digest.ts
|
|
3384
|
+
function computeErrorDigest(err) {
|
|
3385
|
+
let message = "";
|
|
3386
|
+
let stack = "";
|
|
3387
|
+
if (err instanceof Error) {
|
|
3388
|
+
message = err.message;
|
|
3389
|
+
stack = err.stack ?? "";
|
|
3390
|
+
} else if (typeof err === "string") {
|
|
3391
|
+
message = err;
|
|
3392
|
+
} else {
|
|
3393
|
+
try {
|
|
3394
|
+
message = JSON.stringify(err) ?? String(err);
|
|
3395
|
+
} catch {
|
|
3396
|
+
message = String(err);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
const input = `${message}
|
|
3400
|
+
${stack}`;
|
|
3401
|
+
const hash = cyrb53(input);
|
|
3402
|
+
const hex = hash.toString(16).padStart(14, "0");
|
|
3403
|
+
return hex.slice(0, 10);
|
|
3404
|
+
}
|
|
3405
|
+
function cyrb53(input) {
|
|
3406
|
+
let h1 = 3735928559;
|
|
3407
|
+
let h2 = 1103547991;
|
|
3408
|
+
for (let i = 0;i < input.length; i++) {
|
|
3409
|
+
const ch = input.charCodeAt(i);
|
|
3410
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
3411
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
3412
|
+
}
|
|
3413
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
3414
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
3415
|
+
return 4294967296 * (2097151 & h2) + (4294967295 & h1);
|
|
3416
|
+
}
|
|
3417
|
+
|
|
1332
3418
|
// src/render/index.ts
|
|
1333
3419
|
import { createElement as createElement3 } from "react";
|
|
1334
3420
|
import { renderToReadableStream } from "react-dom/server";
|
|
@@ -1367,12 +3453,29 @@ import { Component, Fragment } from "react";
|
|
|
1367
3453
|
// src/error.ts
|
|
1368
3454
|
function getPublicErrorMessage(error) {
|
|
1369
3455
|
const branded = error;
|
|
1370
|
-
if (branded?.__furinBrand === "FURIN_NOT_FOUND") {
|
|
3456
|
+
if (branded?.__furinBrand === "FURIN_NOT_FOUND" || branded?.__furinBrand === "FURIN_SERVER_ERROR") {
|
|
1371
3457
|
return error.message;
|
|
1372
3458
|
}
|
|
1373
3459
|
return "Something went wrong";
|
|
1374
3460
|
}
|
|
1375
3461
|
|
|
3462
|
+
// src/server-error.ts
|
|
3463
|
+
var SERVER_ERROR_BRAND = "FURIN_SERVER_ERROR";
|
|
3464
|
+
|
|
3465
|
+
class FurinServerError extends Error {
|
|
3466
|
+
__furinBrand = SERVER_ERROR_BRAND;
|
|
3467
|
+
digest;
|
|
3468
|
+
status;
|
|
3469
|
+
constructor(args) {
|
|
3470
|
+
super(args.message);
|
|
3471
|
+
this.status = args.status;
|
|
3472
|
+
this.digest = args.digest;
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
function isFurinServerError(err) {
|
|
3476
|
+
return err instanceof FurinServerError || typeof err === "object" && err !== null && err.__furinBrand === SERVER_ERROR_BRAND;
|
|
3477
|
+
}
|
|
3478
|
+
|
|
1376
3479
|
// src/link.tsx
|
|
1377
3480
|
import { createElement, useCallback, useEffect, useRef } from "react";
|
|
1378
3481
|
function computeLinkView({
|
|
@@ -1422,9 +3525,10 @@ function LinkInteractive({
|
|
|
1422
3525
|
const effectivePreload = preload ?? router.defaultPreload;
|
|
1423
3526
|
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
1424
3527
|
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
3528
|
+
const { prefetch } = router;
|
|
1425
3529
|
const triggerPrefetch = useCallback(() => {
|
|
1426
|
-
|
|
1427
|
-
}, [
|
|
3530
|
+
prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
3531
|
+
}, [prefetch, logicalHref, effectiveStaleTime]);
|
|
1428
3532
|
useEffect(() => {
|
|
1429
3533
|
if (effectivePreload === "render") {
|
|
1430
3534
|
triggerPrefetch();
|
|
@@ -1475,6 +3579,10 @@ function LinkInteractive({
|
|
|
1475
3579
|
return;
|
|
1476
3580
|
}
|
|
1477
3581
|
e.preventDefault();
|
|
3582
|
+
if (typeof window !== "undefined" && router.navigate === SSR_FALLBACK_ROUTER.navigate) {
|
|
3583
|
+
window.location.href = href;
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
1478
3586
|
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
1479
3587
|
};
|
|
1480
3588
|
const handleMouseEnter = (e) => {
|
|
@@ -1637,11 +3745,6 @@ var BADGE_STYLE = {
|
|
|
1637
3745
|
marginBottom: "16px",
|
|
1638
3746
|
padding: "12px 36px"
|
|
1639
3747
|
};
|
|
1640
|
-
var NOT_FOUND_BADGE_STYLE = {
|
|
1641
|
-
...BADGE_STYLE,
|
|
1642
|
-
border: 0,
|
|
1643
|
-
padding: 0
|
|
1644
|
-
};
|
|
1645
3748
|
var HEADING_STYLE = {
|
|
1646
3749
|
color: COLOR_TEXT,
|
|
1647
3750
|
fontFamily: FONT_SANS,
|
|
@@ -1729,7 +3832,7 @@ function ScreenFrame({ badge, children }) {
|
|
|
1729
3832
|
style: PAGE_STYLE,
|
|
1730
3833
|
children: [
|
|
1731
3834
|
/* @__PURE__ */ jsxDEV("style", {
|
|
1732
|
-
|
|
3835
|
+
children: RESET_CSS
|
|
1733
3836
|
}, undefined, false, undefined, this),
|
|
1734
3837
|
/* @__PURE__ */ jsxDEV("div", {
|
|
1735
3838
|
style: FRAME_STYLE,
|
|
@@ -1798,75 +3901,40 @@ function DefaultErrorScreen({ message, digest, reset }) {
|
|
|
1798
3901
|
}, undefined, false, undefined, this),
|
|
1799
3902
|
/* @__PURE__ */ jsxDEV("button", {
|
|
1800
3903
|
onClick: reset,
|
|
1801
|
-
style: BUTTON_SECONDARY,
|
|
1802
|
-
type: "button",
|
|
1803
|
-
children: "Try again"
|
|
1804
|
-
}, undefined, false, undefined, this)
|
|
1805
|
-
]
|
|
1806
|
-
}, undefined, true, undefined, this)
|
|
1807
|
-
]
|
|
1808
|
-
}, undefined, true, undefined, this);
|
|
1809
|
-
}
|
|
1810
|
-
function DefaultNotFoundScreen({ message }) {
|
|
1811
|
-
return /* @__PURE__ */ jsxDEV(ScreenFrame, {
|
|
1812
|
-
badge: /* @__PURE__ */ jsxDEV("div", {
|
|
1813
|
-
style:
|
|
1814
|
-
children: "404 \u2014 NOT FOUND"
|
|
1815
|
-
}, undefined, false, undefined, this),
|
|
1816
|
-
children: [
|
|
1817
|
-
/* @__PURE__ */ jsxDEV("h1", {
|
|
1818
|
-
style: HEADING_STYLE,
|
|
1819
|
-
children: "This page does not exist"
|
|
1820
|
-
}, undefined, false, undefined, this),
|
|
1821
|
-
/* @__PURE__ */ jsxDEV("p", {
|
|
1822
|
-
style: DESCRIPTION_WRAPPER_STYLE,
|
|
1823
|
-
children: message ? message : "The page you are looking for could not be found. It may have been moved or removed."
|
|
1824
|
-
}, undefined, false, undefined, this),
|
|
1825
|
-
/* @__PURE__ */ jsxDEV("div", {
|
|
1826
|
-
style: ACTIONS_STYLE,
|
|
1827
|
-
children: /* @__PURE__ */ jsxDEV(Link, {
|
|
1828
|
-
style: BUTTON_PRIMARY,
|
|
1829
|
-
to: "/",
|
|
1830
|
-
children: "Go Home"
|
|
1831
|
-
}, undefined, false, undefined, this)
|
|
1832
|
-
}, undefined, false, undefined, this)
|
|
1833
|
-
]
|
|
1834
|
-
}, undefined, true, undefined, this);
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
// src/render/digest.ts
|
|
1838
|
-
function computeErrorDigest(err) {
|
|
1839
|
-
let message = "";
|
|
1840
|
-
let stack = "";
|
|
1841
|
-
if (err instanceof Error) {
|
|
1842
|
-
message = err.message;
|
|
1843
|
-
stack = err.stack ?? "";
|
|
1844
|
-
} else if (typeof err === "string") {
|
|
1845
|
-
message = err;
|
|
1846
|
-
} else {
|
|
1847
|
-
try {
|
|
1848
|
-
message = JSON.stringify(err) ?? String(err);
|
|
1849
|
-
} catch {
|
|
1850
|
-
message = String(err);
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
const input = `${message}
|
|
1854
|
-
${stack}`;
|
|
1855
|
-
const hash = cyrb53(input);
|
|
1856
|
-
const hex = hash.toString(16).padStart(14, "0");
|
|
1857
|
-
return hex.slice(0, 10);
|
|
1858
|
-
}
|
|
1859
|
-
function cyrb53(input) {
|
|
1860
|
-
let h1 = 3735928559;
|
|
1861
|
-
let h2 = 1103547991;
|
|
1862
|
-
for (let i = 0;i < input.length; i++) {
|
|
1863
|
-
const ch = input.charCodeAt(i);
|
|
1864
|
-
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
1865
|
-
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
1866
|
-
}
|
|
1867
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
1868
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
1869
|
-
return 4294967296 * (2097151 & h2) + (4294967295 & h1);
|
|
3904
|
+
style: BUTTON_SECONDARY,
|
|
3905
|
+
type: "button",
|
|
3906
|
+
children: "Try again"
|
|
3907
|
+
}, undefined, false, undefined, this)
|
|
3908
|
+
]
|
|
3909
|
+
}, undefined, true, undefined, this)
|
|
3910
|
+
]
|
|
3911
|
+
}, undefined, true, undefined, this);
|
|
3912
|
+
}
|
|
3913
|
+
function DefaultNotFoundScreen({ message }) {
|
|
3914
|
+
return /* @__PURE__ */ jsxDEV(ScreenFrame, {
|
|
3915
|
+
badge: /* @__PURE__ */ jsxDEV("div", {
|
|
3916
|
+
style: BADGE_STYLE,
|
|
3917
|
+
children: "404 \u2014 NOT FOUND"
|
|
3918
|
+
}, undefined, false, undefined, this),
|
|
3919
|
+
children: [
|
|
3920
|
+
/* @__PURE__ */ jsxDEV("h1", {
|
|
3921
|
+
style: HEADING_STYLE,
|
|
3922
|
+
children: "This page does not exist"
|
|
3923
|
+
}, undefined, false, undefined, this),
|
|
3924
|
+
/* @__PURE__ */ jsxDEV("p", {
|
|
3925
|
+
style: DESCRIPTION_WRAPPER_STYLE,
|
|
3926
|
+
children: message ? message : "The page you are looking for could not be found. It may have been moved or removed."
|
|
3927
|
+
}, undefined, false, undefined, this),
|
|
3928
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
3929
|
+
style: ACTIONS_STYLE,
|
|
3930
|
+
children: /* @__PURE__ */ jsxDEV(Link, {
|
|
3931
|
+
style: BUTTON_PRIMARY,
|
|
3932
|
+
to: "/",
|
|
3933
|
+
children: "Go Home"
|
|
3934
|
+
}, undefined, false, undefined, this)
|
|
3935
|
+
}, undefined, false, undefined, this)
|
|
3936
|
+
]
|
|
3937
|
+
}, undefined, true, undefined, this);
|
|
1870
3938
|
}
|
|
1871
3939
|
|
|
1872
3940
|
// src/render/boundaries.tsx
|
|
@@ -1876,6 +3944,7 @@ var DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */ jsxDEV2(Default
|
|
|
1876
3944
|
message: error.message,
|
|
1877
3945
|
reset
|
|
1878
3946
|
}, undefined, false, undefined, this);
|
|
3947
|
+
var DEFAULT_ERROR_STATUS = 500;
|
|
1879
3948
|
var DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */ jsxDEV2(DefaultNotFoundScreen, {
|
|
1880
3949
|
message: error.message
|
|
1881
3950
|
}, undefined, false, undefined, this);
|
|
@@ -1907,10 +3976,12 @@ class FurinErrorBoundary extends Component {
|
|
|
1907
3976
|
throw error;
|
|
1908
3977
|
}
|
|
1909
3978
|
const Fallback = this.props.fallback ?? DefaultErrorFallback;
|
|
1910
|
-
const
|
|
3979
|
+
const serverDigest = isFurinServerError(error) ? error.digest : undefined;
|
|
3980
|
+
const finalDigest = serverDigest ?? digest ?? this.props.digest ?? computeErrorDigest(error);
|
|
1911
3981
|
const message = this.props.fallback ? error.message : getPublicErrorMessage(error);
|
|
3982
|
+
const status = isFurinServerError(error) ? error.status : DEFAULT_ERROR_STATUS;
|
|
1912
3983
|
return /* @__PURE__ */ jsxDEV2(Fallback, {
|
|
1913
|
-
error: { message, digest: finalDigest },
|
|
3984
|
+
error: { message, digest: finalDigest, status },
|
|
1914
3985
|
reset: typeof window === "undefined" ? SERVER_RESET_NOOP : this.reset
|
|
1915
3986
|
}, undefined, false, undefined, this);
|
|
1916
3987
|
}
|
|
@@ -1999,6 +4070,65 @@ function normalizeHref(href) {
|
|
|
1999
4070
|
return pathname + url.search + url.hash;
|
|
2000
4071
|
}
|
|
2001
4072
|
|
|
4073
|
+
// src/utils.ts
|
|
4074
|
+
function isFurinPage(value) {
|
|
4075
|
+
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_PAGE";
|
|
4076
|
+
}
|
|
4077
|
+
function isFurinRoute(value) {
|
|
4078
|
+
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_ROUTE";
|
|
4079
|
+
}
|
|
4080
|
+
function collectRouteChainFromRoute(route) {
|
|
4081
|
+
const chain = [];
|
|
4082
|
+
let current = route;
|
|
4083
|
+
while (current) {
|
|
4084
|
+
chain.unshift(current);
|
|
4085
|
+
current = current.parent;
|
|
4086
|
+
}
|
|
4087
|
+
return chain;
|
|
4088
|
+
}
|
|
4089
|
+
function hasCycle(route) {
|
|
4090
|
+
const visited = new Set;
|
|
4091
|
+
let current = route;
|
|
4092
|
+
while (current) {
|
|
4093
|
+
if (visited.has(current)) {
|
|
4094
|
+
return true;
|
|
4095
|
+
}
|
|
4096
|
+
visited.add(current);
|
|
4097
|
+
current = current.parent;
|
|
4098
|
+
}
|
|
4099
|
+
return false;
|
|
4100
|
+
}
|
|
4101
|
+
async function mapWithConcurrency(items, concurrency, fn) {
|
|
4102
|
+
if (items.length === 0) {
|
|
4103
|
+
return [];
|
|
4104
|
+
}
|
|
4105
|
+
const results = new Array(items.length);
|
|
4106
|
+
let cursor = 0;
|
|
4107
|
+
const workerCount = Math.min(Math.max(concurrency, 1), items.length);
|
|
4108
|
+
await Promise.all(Array.from({ length: workerCount }, async () => {
|
|
4109
|
+
while (true) {
|
|
4110
|
+
const index = cursor++;
|
|
4111
|
+
if (index >= items.length) {
|
|
4112
|
+
return;
|
|
4113
|
+
}
|
|
4114
|
+
results[index] = await fn(items[index], index);
|
|
4115
|
+
}
|
|
4116
|
+
}));
|
|
4117
|
+
return results;
|
|
4118
|
+
}
|
|
4119
|
+
function validateRouteChain(chain, root, pagePath) {
|
|
4120
|
+
const hasRoot = chain.some((r) => r === root);
|
|
4121
|
+
if (!hasRoot) {
|
|
4122
|
+
const location = pagePath ? `in ${pagePath}` : "";
|
|
4123
|
+
throw new Error(`[furin] Page ${location} must inherit from root route. ` + 'Add: import { route } from "./root"; and use route.page() or set parent: route');
|
|
4124
|
+
}
|
|
4125
|
+
for (const route of chain) {
|
|
4126
|
+
if (hasCycle(route)) {
|
|
4127
|
+
throw new Error("[furin] Cycle detected in route chain. A route cannot be its own ancestor.");
|
|
4128
|
+
}
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
|
|
2002
4132
|
// src/render/element.tsx
|
|
2003
4133
|
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
2004
4134
|
function wrapInBoundaries(inner, segment) {
|
|
@@ -2074,16 +4204,42 @@ function errorMessageOf(err) {
|
|
|
2074
4204
|
return "";
|
|
2075
4205
|
}
|
|
2076
4206
|
var SERVER_RESET_NOOP2 = () => {};
|
|
2077
|
-
function buildErrorElement(component, error, digest) {
|
|
4207
|
+
function buildErrorElement(component, error, digest, messageOverride, status) {
|
|
2078
4208
|
const ErrorView = component ?? DefaultErrorComponent;
|
|
2079
|
-
|
|
4209
|
+
let message;
|
|
4210
|
+
if (component) {
|
|
4211
|
+
message = messageOverride ?? errorMessageOf(error);
|
|
4212
|
+
} else {
|
|
4213
|
+
message = "An unexpected error occurred.";
|
|
4214
|
+
}
|
|
2080
4215
|
return /* @__PURE__ */ jsxDEV4(ErrorView, {
|
|
2081
|
-
error: { message, digest },
|
|
4216
|
+
error: { message, digest, status },
|
|
2082
4217
|
reset: SERVER_RESET_NOOP2
|
|
2083
4218
|
}, undefined, false, undefined, this);
|
|
2084
4219
|
}
|
|
2085
4220
|
|
|
4221
|
+
// src/client.ts
|
|
4222
|
+
var DEFERRED_BRAND = "__isDeferred";
|
|
4223
|
+
function isDeferred(v) {
|
|
4224
|
+
return typeof v === "object" && v !== null && Object.hasOwn(v, DEFERRED_BRAND) && v[DEFERRED_BRAND] === true;
|
|
4225
|
+
}
|
|
4226
|
+
|
|
2086
4227
|
// src/render/loaders.ts
|
|
4228
|
+
var REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
4229
|
+
function isHttpRedirect(res) {
|
|
4230
|
+
return REDIRECT_STATUSES.has(res.status) && res.headers.has("location");
|
|
4231
|
+
}
|
|
4232
|
+
async function readResponseMessage(res) {
|
|
4233
|
+
if (res.body === null) {
|
|
4234
|
+
return res.statusText;
|
|
4235
|
+
}
|
|
4236
|
+
try {
|
|
4237
|
+
const body = await res.text();
|
|
4238
|
+
return body || res.statusText;
|
|
4239
|
+
} catch {
|
|
4240
|
+
return res.statusText;
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
2087
4243
|
function createLoaderCtx(ctx, accumulatedParentPromise) {
|
|
2088
4244
|
const cache = new Map;
|
|
2089
4245
|
return new Proxy(ctx, {
|
|
@@ -2106,9 +4262,61 @@ function createLoaderCtx(ctx, accumulatedParentPromise) {
|
|
|
2106
4262
|
}
|
|
2107
4263
|
});
|
|
2108
4264
|
}
|
|
2109
|
-
|
|
4265
|
+
function splitOneLoaderResult(result) {
|
|
4266
|
+
const sync = {};
|
|
4267
|
+
const deferred = {};
|
|
4268
|
+
const isDef = isDeferred(result);
|
|
4269
|
+
for (const [key, value] of Object.entries(result)) {
|
|
4270
|
+
if (key === "__isDeferred") {
|
|
4271
|
+
continue;
|
|
4272
|
+
}
|
|
4273
|
+
if (isDef && isPromiseLike(value)) {
|
|
4274
|
+
deferred[key] = Promise.resolve(value);
|
|
4275
|
+
} else {
|
|
4276
|
+
sync[key] = value;
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
return { sync, deferred };
|
|
4280
|
+
}
|
|
4281
|
+
function isPromiseLike(value) {
|
|
4282
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
4283
|
+
}
|
|
4284
|
+
function mergeLoaderResults(results) {
|
|
4285
|
+
const allSync = {};
|
|
4286
|
+
const allDeferred = {};
|
|
4287
|
+
for (const result of results) {
|
|
4288
|
+
const { sync, deferred } = splitOneLoaderResult(result);
|
|
4289
|
+
for (const k of Object.keys(sync)) {
|
|
4290
|
+
delete allDeferred[k];
|
|
4291
|
+
}
|
|
4292
|
+
for (const k of Object.keys(deferred)) {
|
|
4293
|
+
delete allSync[k];
|
|
4294
|
+
}
|
|
4295
|
+
Object.assign(allSync, sync);
|
|
4296
|
+
Object.assign(allDeferred, deferred);
|
|
4297
|
+
}
|
|
4298
|
+
return { allSync, allDeferred };
|
|
4299
|
+
}
|
|
4300
|
+
async function serializeDeferredRejection(err) {
|
|
4301
|
+
if (isNotFoundError(err)) {
|
|
4302
|
+
const wrapped = new Error(err.message);
|
|
4303
|
+
Object.assign(wrapped, { __furinBrand: "FURIN_NOT_FOUND", data: err.data });
|
|
4304
|
+
return wrapped;
|
|
4305
|
+
}
|
|
4306
|
+
if (err instanceof Response) {
|
|
4307
|
+
const body = await readResponseMessage(err);
|
|
4308
|
+
const wrapped = new Error(body || err.statusText || "Something went wrong");
|
|
4309
|
+
Object.assign(wrapped, { __furinStatus: err.status });
|
|
4310
|
+
return wrapped;
|
|
4311
|
+
}
|
|
4312
|
+
if (err instanceof Error) {
|
|
4313
|
+
return err;
|
|
4314
|
+
}
|
|
4315
|
+
return new Error(String(err));
|
|
4316
|
+
}
|
|
4317
|
+
async function runLoaders(route, ctx) {
|
|
2110
4318
|
try {
|
|
2111
|
-
const ctxRecord = { ...ctx, log:
|
|
4319
|
+
const ctxRecord = { ...ctx, log: useLogger2() };
|
|
2112
4320
|
const loaderMap = new Map;
|
|
2113
4321
|
let accumulatedParentPromise = Promise.resolve({});
|
|
2114
4322
|
for (const r of route.routeChain) {
|
|
@@ -2127,22 +4335,39 @@ async function runLoaders(route, ctx, _rootLayout) {
|
|
|
2127
4335
|
const pageCtx = createLoaderCtx(ctxRecord, accumulatedParentPromise);
|
|
2128
4336
|
const pagePromise = route.page?.loader ? Promise.resolve(route.page.loader(pageCtx)).then((r) => r ?? {}) : Promise.resolve({});
|
|
2129
4337
|
const results = await Promise.all([...loaderMap.values(), pagePromise]);
|
|
2130
|
-
const data = Object.assign({}, ...results);
|
|
2131
4338
|
const headers = {};
|
|
2132
4339
|
Object.assign(headers, ctx.set.headers);
|
|
2133
|
-
|
|
4340
|
+
const { allSync, allDeferred } = mergeLoaderResults(results);
|
|
4341
|
+
const routeCtx = { params: ctx.params, query: ctx.query, path: ctx.path };
|
|
4342
|
+
return {
|
|
4343
|
+
type: "data",
|
|
4344
|
+
syncData: { ...allSync, ...routeCtx },
|
|
4345
|
+
deferredPromises: Object.keys(allDeferred).length > 0 ? allDeferred : undefined,
|
|
4346
|
+
headers
|
|
4347
|
+
};
|
|
2134
4348
|
} catch (err) {
|
|
4349
|
+
const headers = {};
|
|
4350
|
+
Object.assign(headers, ctx.set.headers);
|
|
2135
4351
|
if (isNotFoundError(err)) {
|
|
2136
|
-
|
|
2137
|
-
Object.assign(headers2, ctx.set.headers);
|
|
2138
|
-
return { type: "not-found", error: err, headers: headers2 };
|
|
4352
|
+
return { type: "not-found", error: err, headers };
|
|
2139
4353
|
}
|
|
2140
4354
|
if (err instanceof Response) {
|
|
2141
|
-
|
|
4355
|
+
if (isHttpRedirect(err)) {
|
|
4356
|
+
return { type: "redirect", response: err };
|
|
4357
|
+
}
|
|
4358
|
+
const isMalformedRedirect = REDIRECT_STATUSES.has(err.status);
|
|
4359
|
+
const status = isMalformedRedirect ? 500 : err.status;
|
|
4360
|
+
const body = await readResponseMessage(err);
|
|
4361
|
+
const message = body || "Something went wrong";
|
|
4362
|
+
return { type: "error", error: err, status, message, headers };
|
|
2142
4363
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
4364
|
+
return {
|
|
4365
|
+
type: "error",
|
|
4366
|
+
error: err,
|
|
4367
|
+
status: 500,
|
|
4368
|
+
message: "Something went wrong",
|
|
4369
|
+
headers
|
|
4370
|
+
};
|
|
2146
4371
|
}
|
|
2147
4372
|
}
|
|
2148
4373
|
|
|
@@ -2185,9 +4410,14 @@ var IS_DEV = true;
|
|
|
2185
4410
|
function withSSRRouterContext(element, contextValue) {
|
|
2186
4411
|
return createElement3(RouterContext.Provider, { value: contextValue }, element);
|
|
2187
4412
|
}
|
|
4413
|
+
function assertDeferredModeAllowed(route, deferredPromises) {
|
|
4414
|
+
if (deferredPromises !== undefined && route.mode !== "ssr") {
|
|
4415
|
+
throw new Error(`[furin] page "${route.pattern}" returned defer() but the route is rendered in "${route.mode}" mode. ` + "defer() streams data progressively and is only supported in SSR. " + "Return the data directly (await it inside the loader) or switch the route to SSR mode.");
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
2188
4418
|
async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomputedLoaderResult) {
|
|
2189
4419
|
const loaderStart = Date.now();
|
|
2190
|
-
const loaderResult = precomputedLoaderResult ?? await runLoaders(route, ctx
|
|
4420
|
+
const loaderResult = precomputedLoaderResult ?? await runLoaders(route, ctx);
|
|
2191
4421
|
const loader_ms = Date.now() - loaderStart;
|
|
2192
4422
|
if (loaderResult.type === "redirect") {
|
|
2193
4423
|
return loaderResult.response;
|
|
@@ -2198,10 +4428,13 @@ async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomp
|
|
|
2198
4428
|
const isNotFound = loaderResult.type === "not-found";
|
|
2199
4429
|
const isError = loaderResult.type === "error";
|
|
2200
4430
|
const isFallback = isNotFound || isError;
|
|
2201
|
-
const
|
|
4431
|
+
const syncData = isFallback ? {} : loaderResult.syncData;
|
|
4432
|
+
const deferredPromises = !isFallback && loaderResult.type === "data" ? loaderResult.deferredPromises : undefined;
|
|
4433
|
+
assertDeferredModeAllowed(route, deferredPromises);
|
|
2202
4434
|
const headers = loaderResult.headers;
|
|
2203
4435
|
const componentProps = {
|
|
2204
|
-
...
|
|
4436
|
+
...syncData,
|
|
4437
|
+
...deferredPromises ?? {},
|
|
2205
4438
|
params: ctx.params,
|
|
2206
4439
|
query: ctx.query,
|
|
2207
4440
|
path: ctx.path
|
|
@@ -2219,8 +4452,8 @@ async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomp
|
|
|
2219
4452
|
notFoundError = { message: loaderResult.error.message, data: loaderResult.error.data };
|
|
2220
4453
|
} else if (loaderResult.type === "error") {
|
|
2221
4454
|
errorDigest = computeErrorDigest(loaderResult.error);
|
|
2222
|
-
element = buildErrorElement(route.error ?? root.error, loaderResult.error, errorDigest);
|
|
2223
|
-
status =
|
|
4455
|
+
element = buildErrorElement(route.error ?? root.error, loaderResult.error, errorDigest, loaderResult.message, loaderResult.status);
|
|
4456
|
+
status = loaderResult.status;
|
|
2224
4457
|
} else {
|
|
2225
4458
|
element = buildElement(route, componentProps, root.route);
|
|
2226
4459
|
}
|
|
@@ -2239,12 +4472,14 @@ async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomp
|
|
|
2239
4472
|
element = withSSRRouterContext(element, ssrContext);
|
|
2240
4473
|
return {
|
|
2241
4474
|
componentProps,
|
|
4475
|
+
deferredPromises,
|
|
2242
4476
|
element,
|
|
2243
4477
|
errorDigest,
|
|
2244
4478
|
headData,
|
|
2245
4479
|
headers,
|
|
2246
4480
|
loader_ms,
|
|
2247
4481
|
notFoundError,
|
|
4482
|
+
syncData,
|
|
2248
4483
|
ssrContext,
|
|
2249
4484
|
status,
|
|
2250
4485
|
template
|
|
@@ -2267,7 +4502,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
2267
4502
|
if (prepared instanceof Response) {
|
|
2268
4503
|
return prepared;
|
|
2269
4504
|
}
|
|
2270
|
-
|
|
4505
|
+
useLogger2().set({
|
|
2271
4506
|
furin: {
|
|
2272
4507
|
render: mode,
|
|
2273
4508
|
route: route.pattern,
|
|
@@ -2276,17 +4511,27 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
2276
4511
|
...prepared.errorDigest ? { digest: prepared.errorDigest } : {}
|
|
2277
4512
|
}
|
|
2278
4513
|
});
|
|
2279
|
-
const {
|
|
4514
|
+
const { deferredPromises, element, headData, headers, status, syncData, template } = prepared;
|
|
2280
4515
|
const stream = await renderToReadableStream(element);
|
|
2281
4516
|
await stream.allReady;
|
|
2282
4517
|
const reactHtml = await streamToString(stream);
|
|
2283
4518
|
return {
|
|
2284
|
-
html: assembleHTML(template, headData, reactHtml,
|
|
4519
|
+
html: assembleHTML(template, headData, reactHtml, syncData),
|
|
2285
4520
|
headers,
|
|
4521
|
+
ndjson: await serializeLoaderDataNdjson(syncData, deferredPromises),
|
|
2286
4522
|
status
|
|
2287
4523
|
};
|
|
2288
4524
|
}, { route: route.pattern, render: mode });
|
|
2289
4525
|
}
|
|
4526
|
+
async function serializeLoaderDataNdjson(syncData, deferredPromises) {
|
|
4527
|
+
const payload = {
|
|
4528
|
+
...syncData,
|
|
4529
|
+
...deferredPromises ?? {}
|
|
4530
|
+
};
|
|
4531
|
+
const serialized = await toCrossJSONAsync(payload);
|
|
4532
|
+
return `${JSON.stringify(serialized)}
|
|
4533
|
+
`;
|
|
4534
|
+
}
|
|
2290
4535
|
async function prerenderSSG(route, params, root, origin, basePath) {
|
|
2291
4536
|
const resolvedPath = resolvePath(route.pattern, params);
|
|
2292
4537
|
const cached = getSSGCache(resolvedPath);
|
|
@@ -2298,8 +4543,14 @@ async function prerenderSSG(route, params, root, origin, basePath) {
|
|
|
2298
4543
|
return renderResult;
|
|
2299
4544
|
}
|
|
2300
4545
|
const result = renderResult;
|
|
2301
|
-
const entry = {
|
|
4546
|
+
const entry = {
|
|
4547
|
+
cachedAt: Date.now(),
|
|
4548
|
+
html: result.html,
|
|
4549
|
+
ndjson: result.ndjson,
|
|
4550
|
+
status: result.status
|
|
4551
|
+
};
|
|
2302
4552
|
setSSGCache(resolvedPath, entry);
|
|
4553
|
+
autoInvalidateRegistry.registerLoaderTags(resolvedPath, route.tags);
|
|
2303
4554
|
return entry;
|
|
2304
4555
|
}
|
|
2305
4556
|
async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
@@ -2307,7 +4558,7 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2307
4558
|
if (prepared instanceof Response) {
|
|
2308
4559
|
return prepared;
|
|
2309
4560
|
}
|
|
2310
|
-
|
|
4561
|
+
useLogger2().set({
|
|
2311
4562
|
furin: {
|
|
2312
4563
|
render: route.mode,
|
|
2313
4564
|
route: route.pattern,
|
|
@@ -2315,7 +4566,7 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2315
4566
|
...prepared.errorDigest ? { digest: prepared.errorDigest } : {}
|
|
2316
4567
|
}
|
|
2317
4568
|
});
|
|
2318
|
-
const {
|
|
4569
|
+
const { deferredPromises, element, headData, headers, syncData, template } = prepared;
|
|
2319
4570
|
const { headPre, bodyPre, bodyPost } = splitTemplate(template);
|
|
2320
4571
|
let reactStream;
|
|
2321
4572
|
let status = prepared.status;
|
|
@@ -2327,18 +4578,18 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2327
4578
|
shellErrored = true;
|
|
2328
4579
|
status = 500;
|
|
2329
4580
|
finalDigest = computeErrorDigest(shellError);
|
|
2330
|
-
|
|
4581
|
+
useLogger2().set({
|
|
2331
4582
|
furin: { render: route.mode, route: route.pattern, digest: finalDigest, phase: "shell" }
|
|
2332
4583
|
});
|
|
2333
4584
|
try {
|
|
2334
|
-
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(route.error ?? root.error, shellError, finalDigest), prepared.ssrContext));
|
|
4585
|
+
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(route.error ?? root.error, shellError, finalDigest, undefined, 500), prepared.ssrContext));
|
|
2335
4586
|
} catch {
|
|
2336
|
-
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(undefined, shellError, finalDigest), prepared.ssrContext));
|
|
4587
|
+
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(undefined, shellError, finalDigest, undefined, 500), prepared.ssrContext));
|
|
2337
4588
|
}
|
|
2338
4589
|
}
|
|
2339
|
-
const dataPayload = shellErrored ? {} : { ...
|
|
4590
|
+
const dataPayload = shellErrored ? {} : { ...syncData };
|
|
2340
4591
|
if (finalDigest) {
|
|
2341
|
-
dataPayload.__furinError = { digest: finalDigest };
|
|
4592
|
+
dataPayload.__furinError = { digest: finalDigest, status };
|
|
2342
4593
|
}
|
|
2343
4594
|
if (status === 404 && !shellErrored) {
|
|
2344
4595
|
dataPayload.__furinStatus = 404;
|
|
@@ -2346,12 +4597,18 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2346
4597
|
dataPayload.__furinNotFound = prepared.notFoundError;
|
|
2347
4598
|
}
|
|
2348
4599
|
}
|
|
4600
|
+
if (dataPayload.__furinError !== undefined && dataPayload.__furinNotFound !== undefined) {
|
|
4601
|
+
throw new Error("[furin] internal invariant violated: __furinError and __furinNotFound were both set on the same SSR payload. Open a bug \u2014 these signals are mutually exclusive.");
|
|
4602
|
+
}
|
|
4603
|
+
const hasDeferred = !shellErrored && deferredPromises !== undefined;
|
|
4604
|
+
const deferredKeys = hasDeferred ? Object.keys(deferredPromises) : [];
|
|
4605
|
+
const deferredSetupScript = hasDeferred ? buildDeferredScript(deferredKeys) : "";
|
|
2349
4606
|
const dataScript = `<script id="__FURIN_DATA__" type="application/json">${safeJson(dataPayload)}</script>`;
|
|
2350
4607
|
const { readable, writable } = new TransformStream;
|
|
2351
4608
|
const writer = writable.getWriter();
|
|
2352
4609
|
const enc = new TextEncoder;
|
|
2353
4610
|
(async () => {
|
|
2354
|
-
await writer.write(enc.encode(headPre + headData + bodyPre));
|
|
4611
|
+
await writer.write(enc.encode(headPre + headData + deferredSetupScript + bodyPre));
|
|
2355
4612
|
const reader = reactStream.getReader();
|
|
2356
4613
|
for (;; ) {
|
|
2357
4614
|
const { done, value } = await reader.read();
|
|
@@ -2360,7 +4617,22 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2360
4617
|
}
|
|
2361
4618
|
await writer.write(value);
|
|
2362
4619
|
}
|
|
2363
|
-
|
|
4620
|
+
const [earlyBodyPost, finalBodyPost] = hasDeferred ? splitBeforeBodyClose(bodyPost) : ["", bodyPost];
|
|
4621
|
+
await writer.write(enc.encode(dataScript + earlyBodyPost));
|
|
4622
|
+
if (hasDeferred) {
|
|
4623
|
+
await Promise.all(Object.entries(deferredPromises).map(async ([key, promise]) => {
|
|
4624
|
+
try {
|
|
4625
|
+
const resolvedValue = await promise;
|
|
4626
|
+
const chunk = toCrossJSON(resolvedValue);
|
|
4627
|
+
await writer.write(enc.encode(buildDeferredResolution(key, chunk, "resolve")));
|
|
4628
|
+
} catch (err) {
|
|
4629
|
+
const normalized = await serializeDeferredRejection(err);
|
|
4630
|
+
const chunk = toCrossJSON(normalized);
|
|
4631
|
+
await writer.write(enc.encode(buildDeferredResolution(key, chunk, "reject")));
|
|
4632
|
+
}
|
|
4633
|
+
}));
|
|
4634
|
+
}
|
|
4635
|
+
await writer.write(enc.encode(finalBodyPost));
|
|
2364
4636
|
await writer.close();
|
|
2365
4637
|
})().catch((err) => writer.abort(err));
|
|
2366
4638
|
return new Response(readable, {
|
|
@@ -2372,6 +4644,13 @@ async function renderSSR(route, ctx, root, precomputedLoaderResult) {
|
|
|
2372
4644
|
}
|
|
2373
4645
|
});
|
|
2374
4646
|
}
|
|
4647
|
+
function splitBeforeBodyClose(bodyPost) {
|
|
4648
|
+
const index = bodyPost.toLowerCase().lastIndexOf("</body>");
|
|
4649
|
+
if (index === -1) {
|
|
4650
|
+
return [bodyPost, ""];
|
|
4651
|
+
}
|
|
4652
|
+
return [bodyPost.slice(0, index), bodyPost.slice(index)];
|
|
4653
|
+
}
|
|
2375
4654
|
function isrCacheControl(isFresh, revalidate) {
|
|
2376
4655
|
const sMaxAge = isFresh ? revalidate : 0;
|
|
2377
4656
|
return `public, max-age=0, must-revalidate, s-maxage=${sMaxAge}, stale-while-revalidate=${revalidate}`;
|
|
@@ -2393,7 +4672,7 @@ function serveISRCacheHit(cached, ctx, route, params, cacheKey, revalidate, root
|
|
|
2393
4672
|
if (etag) {
|
|
2394
4673
|
ctx.set.headers.etag = etag;
|
|
2395
4674
|
}
|
|
2396
|
-
|
|
4675
|
+
useLogger2().set({
|
|
2397
4676
|
furin: { render: "isr", route: route.pattern, cache: isFresh ? "hit" : "stale" }
|
|
2398
4677
|
});
|
|
2399
4678
|
return cached.html;
|
|
@@ -2415,7 +4694,7 @@ async function renderISRNon200(prepared, route, ctx, root, errorDigest, renderSt
|
|
|
2415
4694
|
} catch (shellError) {
|
|
2416
4695
|
finalStatus = 500;
|
|
2417
4696
|
finalDigest = computeErrorDigest(shellError);
|
|
2418
|
-
|
|
4697
|
+
useLogger2().set({
|
|
2419
4698
|
furin: {
|
|
2420
4699
|
render: "isr",
|
|
2421
4700
|
route: route.pattern,
|
|
@@ -2424,23 +4703,23 @@ async function renderISRNon200(prepared, route, ctx, root, errorDigest, renderSt
|
|
|
2424
4703
|
phase: "shell"
|
|
2425
4704
|
}
|
|
2426
4705
|
});
|
|
2427
|
-
fallbackProps.__furinError = { digest: finalDigest };
|
|
4706
|
+
fallbackProps.__furinError = { digest: finalDigest, status: finalStatus };
|
|
2428
4707
|
fallbackProps.__furinStatus = 500;
|
|
2429
4708
|
try {
|
|
2430
|
-
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(route.error ?? root.error, shellError, finalDigest), prepared.ssrContext));
|
|
4709
|
+
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(route.error ?? root.error, shellError, finalDigest, undefined, 500), prepared.ssrContext));
|
|
2431
4710
|
} catch {
|
|
2432
|
-
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(undefined, shellError, finalDigest), prepared.ssrContext));
|
|
4711
|
+
reactStream = await renderToReadableStream(withSSRRouterContext(buildErrorElement(undefined, shellError, finalDigest, undefined, 500), prepared.ssrContext));
|
|
2433
4712
|
}
|
|
2434
4713
|
}
|
|
2435
4714
|
if (!fallbackProps.__furinError && errorDigest) {
|
|
2436
|
-
fallbackProps.__furinError = { digest: errorDigest };
|
|
4715
|
+
fallbackProps.__furinError = { digest: errorDigest, status };
|
|
2437
4716
|
}
|
|
2438
4717
|
await reactStream.allReady;
|
|
2439
4718
|
const reactHtml = await streamToString(reactStream);
|
|
2440
4719
|
const html = assembleHTML(template, headData, reactHtml, fallbackProps);
|
|
2441
4720
|
const generatedAt = Date.now();
|
|
2442
4721
|
const renderMs = generatedAt - renderStart;
|
|
2443
|
-
|
|
4722
|
+
useLogger2().set({
|
|
2444
4723
|
furin: {
|
|
2445
4724
|
render: "isr",
|
|
2446
4725
|
route: route.pattern,
|
|
@@ -2472,16 +4751,16 @@ async function handleISR(route, ctx, root, buildId = "") {
|
|
|
2472
4751
|
if (prepared instanceof Response) {
|
|
2473
4752
|
return prepared;
|
|
2474
4753
|
}
|
|
2475
|
-
const {
|
|
4754
|
+
const { element, headData, syncData, template, status, errorDigest } = prepared;
|
|
2476
4755
|
if (status !== 200) {
|
|
2477
4756
|
return renderISRNon200(prepared, route, ctx, root, errorDigest, renderStart, buildId);
|
|
2478
4757
|
}
|
|
2479
4758
|
const stream = await renderToReadableStream(element);
|
|
2480
4759
|
await stream.allReady;
|
|
2481
4760
|
const reactHtml = await streamToString(stream);
|
|
2482
|
-
const html = assembleHTML(template, headData, reactHtml,
|
|
4761
|
+
const html = assembleHTML(template, headData, reactHtml, syncData);
|
|
2483
4762
|
const generatedAt = Date.now();
|
|
2484
|
-
|
|
4763
|
+
useLogger2().set({
|
|
2485
4764
|
furin: {
|
|
2486
4765
|
render: "isr",
|
|
2487
4766
|
route: route.pattern,
|
|
@@ -2490,6 +4769,7 @@ async function handleISR(route, ctx, root, buildId = "") {
|
|
|
2490
4769
|
}
|
|
2491
4770
|
});
|
|
2492
4771
|
setISRCache(cacheKey, { html, generatedAt, revalidate });
|
|
4772
|
+
autoInvalidateRegistry.registerLoaderTags(cacheKey, route.tags);
|
|
2493
4773
|
const etag = buildId ? `"${buildId}:${generatedAt}"` : null;
|
|
2494
4774
|
ctx.set.headers["content-type"] = "text/html; charset=utf-8";
|
|
2495
4775
|
ctx.set.headers["cache-control"] = isrCacheControl(true, revalidate);
|
|
@@ -2539,47 +4819,6 @@ function revalidateInBackground(route, params, cacheKey, revalidate, root, origi
|
|
|
2539
4819
|
});
|
|
2540
4820
|
}
|
|
2541
4821
|
|
|
2542
|
-
// src/utils.ts
|
|
2543
|
-
function isFurinPage(value) {
|
|
2544
|
-
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_PAGE";
|
|
2545
|
-
}
|
|
2546
|
-
function isFurinRoute(value) {
|
|
2547
|
-
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_ROUTE";
|
|
2548
|
-
}
|
|
2549
|
-
function collectRouteChainFromRoute(route) {
|
|
2550
|
-
const chain = [];
|
|
2551
|
-
let current = route;
|
|
2552
|
-
while (current) {
|
|
2553
|
-
chain.unshift(current);
|
|
2554
|
-
current = current.parent;
|
|
2555
|
-
}
|
|
2556
|
-
return chain;
|
|
2557
|
-
}
|
|
2558
|
-
function hasCycle(route) {
|
|
2559
|
-
const visited = new Set;
|
|
2560
|
-
let current = route;
|
|
2561
|
-
while (current) {
|
|
2562
|
-
if (visited.has(current)) {
|
|
2563
|
-
return true;
|
|
2564
|
-
}
|
|
2565
|
-
visited.add(current);
|
|
2566
|
-
current = current.parent;
|
|
2567
|
-
}
|
|
2568
|
-
return false;
|
|
2569
|
-
}
|
|
2570
|
-
function validateRouteChain(chain, root, pagePath) {
|
|
2571
|
-
const hasRoot = chain.some((r) => r === root);
|
|
2572
|
-
if (!hasRoot) {
|
|
2573
|
-
const location = pagePath ? `in ${pagePath}` : "";
|
|
2574
|
-
throw new Error(`[furin] Page ${location} must inherit from root route. ` + 'Add: import { route } from "./root"; and use route.page() or set parent: route');
|
|
2575
|
-
}
|
|
2576
|
-
for (const route of chain) {
|
|
2577
|
-
if (hasCycle(route)) {
|
|
2578
|
-
throw new Error("[furin] Cycle detected in route chain. A route cannot be its own ancestor.");
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
4822
|
// src/router.ts
|
|
2584
4823
|
function isModuleNotFoundError(err) {
|
|
2585
4824
|
if (!err || typeof err !== "object" && typeof err !== "string") {
|
|
@@ -2589,6 +4828,18 @@ function isModuleNotFoundError(err) {
|
|
|
2589
4828
|
const code = typeof err === "string" ? undefined : err.code;
|
|
2590
4829
|
return code === "ENOENT" || code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || msg.includes("cannot find module") || msg.includes("module not found") || msg.includes("no such file or directory");
|
|
2591
4830
|
}
|
|
4831
|
+
function collectRouteTags(routeChain, page) {
|
|
4832
|
+
const tags = new Set;
|
|
4833
|
+
for (const route of routeChain) {
|
|
4834
|
+
for (const tag of route.tags ?? []) {
|
|
4835
|
+
tags.add(tag);
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
for (const tag of page?.tags ?? []) {
|
|
4839
|
+
tags.add(tag);
|
|
4840
|
+
}
|
|
4841
|
+
return tags.size > 0 ? [...tags] : undefined;
|
|
4842
|
+
}
|
|
2592
4843
|
function loadProdRoutes(ctx) {
|
|
2593
4844
|
const rootMod = ctx.modules[ctx.rootPath];
|
|
2594
4845
|
const rootExport = rootMod.route ?? rootMod.default;
|
|
@@ -2633,7 +4884,8 @@ function loadProdRoutes(ctx) {
|
|
|
2633
4884
|
mode,
|
|
2634
4885
|
segmentBoundaries: boundaries,
|
|
2635
4886
|
error,
|
|
2636
|
-
notFound
|
|
4887
|
+
notFound,
|
|
4888
|
+
tags: collectRouteTags(routeChain, page)
|
|
2637
4889
|
});
|
|
2638
4890
|
}
|
|
2639
4891
|
return { root, routes };
|
|
@@ -2657,8 +4909,10 @@ async function scanRootLayout(pagesDir) {
|
|
|
2657
4909
|
if (!rootExport.layout) {
|
|
2658
4910
|
throw new Error("[furin] root.tsx: createRoute() has no layout.");
|
|
2659
4911
|
}
|
|
2660
|
-
const notFoundEntry = await
|
|
2661
|
-
|
|
4912
|
+
const [notFoundEntry, errorEntry] = await Promise.all([
|
|
4913
|
+
loadConventionComponent(pagesDir, "not-found"),
|
|
4914
|
+
loadConventionComponent(pagesDir, "error")
|
|
4915
|
+
]);
|
|
2662
4916
|
return {
|
|
2663
4917
|
path: rootPath,
|
|
2664
4918
|
route: rootExport,
|
|
@@ -2701,9 +4955,11 @@ async function scanPageFiles(pagesDir, root) {
|
|
|
2701
4955
|
if (fileName.startsWith("_") || fileName === "root" || isConventionFileName(fileName)) {
|
|
2702
4956
|
continue;
|
|
2703
4957
|
}
|
|
2704
|
-
const notFound
|
|
2705
|
-
|
|
2706
|
-
|
|
4958
|
+
const [notFound, errorComponent, segmentBoundaries] = await Promise.all([
|
|
4959
|
+
resolveNearestConvention(absolutePath, pagesDir, "not-found", notFoundCache, root.notFound),
|
|
4960
|
+
resolveNearestConvention(absolutePath, pagesDir, "error", errorCache, root.error),
|
|
4961
|
+
collectSegmentBoundaries(absolutePath, pagesDir, notFoundCache, errorCache)
|
|
4962
|
+
]);
|
|
2707
4963
|
if (IS_DEV) {
|
|
2708
4964
|
const devRoute = await buildDevRoute(absolutePath, relativePath, root);
|
|
2709
4965
|
devRoute.notFound = notFound;
|
|
@@ -2728,7 +4984,8 @@ async function scanPageFiles(pagesDir, root) {
|
|
|
2728
4984
|
mode: resolveMode(page, routeChain),
|
|
2729
4985
|
notFound,
|
|
2730
4986
|
error: errorComponent,
|
|
2731
|
-
segmentBoundaries
|
|
4987
|
+
segmentBoundaries,
|
|
4988
|
+
tags: collectRouteTags(routeChain, page)
|
|
2732
4989
|
});
|
|
2733
4990
|
}
|
|
2734
4991
|
return routes;
|
|
@@ -2748,14 +5005,16 @@ async function collectSegmentBoundaries(pageAbsolutePath, pagesDir, notFoundCach
|
|
|
2748
5005
|
const boundaries = [];
|
|
2749
5006
|
for (let depth = 0;depth < dirs.length; depth++) {
|
|
2750
5007
|
const dir = dirs[depth];
|
|
2751
|
-
|
|
2752
|
-
errorCache.
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
5008
|
+
const [errorEntry, notFoundEntry] = await Promise.all([
|
|
5009
|
+
errorCache.has(dir) ? Promise.resolve(errorCache.get(dir)) : loadConventionComponent(dir, "error").then((r) => {
|
|
5010
|
+
errorCache.set(dir, r);
|
|
5011
|
+
return r;
|
|
5012
|
+
}),
|
|
5013
|
+
notFoundCache.has(dir) ? Promise.resolve(notFoundCache.get(dir)) : loadConventionComponent(dir, "not-found").then((r) => {
|
|
5014
|
+
notFoundCache.set(dir, r);
|
|
5015
|
+
return r;
|
|
5016
|
+
})
|
|
5017
|
+
]);
|
|
2759
5018
|
if (errorEntry || notFoundEntry) {
|
|
2760
5019
|
boundaries.push({
|
|
2761
5020
|
path: dir,
|
|
@@ -2808,11 +5067,11 @@ async function buildDevRoute(absolutePath, relativePath, root) {
|
|
|
2808
5067
|
mode: page ? resolveMode(page, routeChain) : "ssr",
|
|
2809
5068
|
page: page ?? devStubPage,
|
|
2810
5069
|
routeChain,
|
|
5070
|
+
tags: collectRouteTags(routeChain, page),
|
|
2811
5071
|
segmentBoundaries: []
|
|
2812
5072
|
};
|
|
2813
5073
|
}
|
|
2814
|
-
function
|
|
2815
|
-
const resolvedQuery = query;
|
|
5074
|
+
function detectQueryDefaultRedirect(request, resolvedQuery) {
|
|
2816
5075
|
const queryKeys = Object.keys(resolvedQuery);
|
|
2817
5076
|
if (queryKeys.length === 0) {
|
|
2818
5077
|
return;
|
|
@@ -2834,7 +5093,29 @@ function queryDefaultRedirectHook({ request, query, status, set }) {
|
|
|
2834
5093
|
url.searchParams.set(k, String(v));
|
|
2835
5094
|
}
|
|
2836
5095
|
}
|
|
2837
|
-
|
|
5096
|
+
return url.pathname + url.search;
|
|
5097
|
+
}
|
|
5098
|
+
function parseDataEndpointPath(rawPath) {
|
|
5099
|
+
if (rawPath.includes("://") || rawPath.startsWith("//")) {
|
|
5100
|
+
return;
|
|
5101
|
+
}
|
|
5102
|
+
let url;
|
|
5103
|
+
try {
|
|
5104
|
+
url = new URL(rawPath, "http://localhost");
|
|
5105
|
+
} catch {
|
|
5106
|
+
return;
|
|
5107
|
+
}
|
|
5108
|
+
if (url.origin !== "http://localhost") {
|
|
5109
|
+
return;
|
|
5110
|
+
}
|
|
5111
|
+
return { url, pathname: url.pathname };
|
|
5112
|
+
}
|
|
5113
|
+
function queryDefaultRedirectHook({ request, query, status, set }) {
|
|
5114
|
+
const location = detectQueryDefaultRedirect(request, query);
|
|
5115
|
+
if (!location) {
|
|
5116
|
+
return;
|
|
5117
|
+
}
|
|
5118
|
+
set.headers.location = location;
|
|
2838
5119
|
return status("Found");
|
|
2839
5120
|
}
|
|
2840
5121
|
function collectIntermediateLayoutDirs(pagePath, rootPath) {
|
|
@@ -2891,12 +5172,12 @@ async function refreshLayoutChain(chain, pagePath, rootPath, importFn) {
|
|
|
2891
5172
|
const ctx = getCompileContext();
|
|
2892
5173
|
const timestamp = Date.now();
|
|
2893
5174
|
const layoutDirs = collectIntermediateLayoutDirs(pagePath, rootPath);
|
|
5175
|
+
const freshMods = await Promise.all(layoutDirs.map((layoutDir) => importFreshLayoutRouteModule(layoutDir, timestamp, resolveImport, ctx)));
|
|
2894
5176
|
let chainIdx = 1;
|
|
2895
|
-
for (const
|
|
5177
|
+
for (const freshMod of freshMods) {
|
|
2896
5178
|
if (chainIdx >= chain.length) {
|
|
2897
5179
|
break;
|
|
2898
5180
|
}
|
|
2899
|
-
const freshMod = await importFreshLayoutRouteModule(layoutDir, timestamp, resolveImport, ctx);
|
|
2900
5181
|
if (!freshMod) {
|
|
2901
5182
|
continue;
|
|
2902
5183
|
}
|
|
@@ -2904,6 +5185,15 @@ async function refreshLayoutChain(chain, pagePath, rootPath, importFn) {
|
|
|
2904
5185
|
chainIdx++;
|
|
2905
5186
|
}
|
|
2906
5187
|
}
|
|
5188
|
+
function rebuildDevRoute(base, page, chain) {
|
|
5189
|
+
return {
|
|
5190
|
+
...base,
|
|
5191
|
+
page,
|
|
5192
|
+
routeChain: chain,
|
|
5193
|
+
mode: resolveMode(page, chain),
|
|
5194
|
+
tags: collectRouteTags(chain, page)
|
|
5195
|
+
};
|
|
5196
|
+
}
|
|
2907
5197
|
async function handleDevRequest(route, ctx, root) {
|
|
2908
5198
|
try {
|
|
2909
5199
|
let currentRoot = root;
|
|
@@ -2921,7 +5211,7 @@ async function handleDevRequest(route, ctx, root) {
|
|
|
2921
5211
|
chain[0].layout = currentRoot.route.layout;
|
|
2922
5212
|
chain[0].loader = currentRoot.route.loader;
|
|
2923
5213
|
}
|
|
2924
|
-
const refreshedRoute =
|
|
5214
|
+
const refreshedRoute = rebuildDevRoute(route, page, chain);
|
|
2925
5215
|
if (refreshedRoute.mode === "isr") {
|
|
2926
5216
|
return renderDevISRWithLoaderCache(refreshedRoute, ctx, currentRoot);
|
|
2927
5217
|
}
|
|
@@ -2941,23 +5231,25 @@ async function renderDevISRWithLoaderCache(route, ctx, root) {
|
|
|
2941
5231
|
if (cached && isDevLoaderCacheValid(cached)) {
|
|
2942
5232
|
const precomputed = {
|
|
2943
5233
|
type: "data",
|
|
2944
|
-
|
|
5234
|
+
syncData: cached.loaderData,
|
|
5235
|
+
deferredPromises: undefined,
|
|
2945
5236
|
headers: cached.headers
|
|
2946
5237
|
};
|
|
2947
5238
|
return renderSSR(route, ctx, root, precomputed);
|
|
2948
5239
|
}
|
|
2949
|
-
const result = await runLoaders(route, ctx
|
|
5240
|
+
const result = await runLoaders(route, ctx);
|
|
2950
5241
|
if (result.type === "data") {
|
|
2951
5242
|
const revalidate = route.page._route.revalidate ?? 60;
|
|
2952
5243
|
const entry = {
|
|
2953
5244
|
dependencies: computeRouteDependencies(route.path, root.path),
|
|
2954
5245
|
generatedAt: Date.now(),
|
|
2955
5246
|
headers: result.headers,
|
|
2956
|
-
loaderData: result.
|
|
5247
|
+
loaderData: result.syncData,
|
|
2957
5248
|
mode: "isr",
|
|
2958
5249
|
revalidate
|
|
2959
5250
|
};
|
|
2960
5251
|
setDevISRLoaderCache(cacheKey, entry);
|
|
5252
|
+
autoInvalidateRegistry.registerLoaderTags(resolvePath(route.pattern, ctx.params ?? {}), route.tags);
|
|
2961
5253
|
}
|
|
2962
5254
|
return renderSSR(route, ctx, root, result);
|
|
2963
5255
|
}
|
|
@@ -2967,22 +5259,24 @@ async function renderDevSSGWithLoaderCache(route, ctx, root) {
|
|
|
2967
5259
|
if (cached && isDevLoaderCacheValid(cached)) {
|
|
2968
5260
|
const precomputed = {
|
|
2969
5261
|
type: "data",
|
|
2970
|
-
|
|
5262
|
+
syncData: cached.loaderData,
|
|
5263
|
+
deferredPromises: undefined,
|
|
2971
5264
|
headers: cached.headers
|
|
2972
5265
|
};
|
|
2973
5266
|
return renderSSR(route, ctx, root, precomputed);
|
|
2974
5267
|
}
|
|
2975
|
-
const result = await runLoaders(route, ctx
|
|
5268
|
+
const result = await runLoaders(route, ctx);
|
|
2976
5269
|
if (result.type === "data") {
|
|
2977
5270
|
const entry = {
|
|
2978
5271
|
dependencies: computeRouteDependencies(route.path, root.path),
|
|
2979
5272
|
generatedAt: Date.now(),
|
|
2980
5273
|
headers: result.headers,
|
|
2981
|
-
loaderData: result.
|
|
5274
|
+
loaderData: result.syncData,
|
|
2982
5275
|
mode: "ssg",
|
|
2983
5276
|
revalidate: Number.POSITIVE_INFINITY
|
|
2984
5277
|
};
|
|
2985
5278
|
setDevSSGLoaderCache(cacheKey, entry);
|
|
5279
|
+
autoInvalidateRegistry.registerLoaderTags(resolvePath(route.pattern, ctx.params ?? {}), route.tags);
|
|
2986
5280
|
}
|
|
2987
5281
|
return renderSSR(route, ctx, root, result);
|
|
2988
5282
|
}
|
|
@@ -3019,7 +5313,7 @@ async function handleSSGRequest(route, ctx, root, buildId) {
|
|
|
3019
5313
|
}
|
|
3020
5314
|
var TOBJECT_STRUCTURAL_KEYS = new Set(["type", "properties", "required"]);
|
|
3021
5315
|
function mergeRouteSchemas(routeChain, key) {
|
|
3022
|
-
const schemas = routeChain.
|
|
5316
|
+
const schemas = routeChain.flatMap((r) => r[key] ? [r[key]] : []);
|
|
3023
5317
|
if (schemas.length === 0) {
|
|
3024
5318
|
return;
|
|
3025
5319
|
}
|
|
@@ -3063,18 +5357,22 @@ function createRoutePlugin(route, root, buildId = "") {
|
|
|
3063
5357
|
});
|
|
3064
5358
|
return plugin;
|
|
3065
5359
|
}
|
|
5360
|
+
var DIR_SCAN_CONCURRENCY = 8;
|
|
3066
5361
|
async function collectPageFilePaths(dir) {
|
|
3067
5362
|
const files = [];
|
|
3068
5363
|
const entries = (await readdir(dir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
3069
|
-
|
|
5364
|
+
const resolved = await mapWithConcurrency(entries, DIR_SCAN_CONCURRENCY, async (entry) => {
|
|
3070
5365
|
const absolutePath = join(dir, entry.name);
|
|
3071
5366
|
if (entry.isDirectory()) {
|
|
3072
|
-
|
|
3073
|
-
continue;
|
|
5367
|
+
return await collectPageFilePaths(absolutePath);
|
|
3074
5368
|
}
|
|
3075
5369
|
if (entry.isFile()) {
|
|
3076
|
-
|
|
5370
|
+
return [absolutePath];
|
|
3077
5371
|
}
|
|
5372
|
+
return [];
|
|
5373
|
+
});
|
|
5374
|
+
for (const chunk of resolved) {
|
|
5375
|
+
files.push(...chunk);
|
|
3078
5376
|
}
|
|
3079
5377
|
return files;
|
|
3080
5378
|
}
|
|
@@ -3115,15 +5413,252 @@ function filePathToPattern(path) {
|
|
|
3115
5413
|
}
|
|
3116
5414
|
return `/${segments.join("/")}`;
|
|
3117
5415
|
}
|
|
5416
|
+
var REGEX_META_CHARS_RE = /[.*+?^${}()|[\]\\]/;
|
|
5417
|
+
function escapeRegExpChar(ch) {
|
|
5418
|
+
return REGEX_META_CHARS_RE.test(ch) ? `\\${ch}` : ch;
|
|
5419
|
+
}
|
|
5420
|
+
function routeSpecificity(pattern) {
|
|
5421
|
+
let score = 0;
|
|
5422
|
+
for (const segment of pattern.split("/")) {
|
|
5423
|
+
if (segment.length === 0) {
|
|
5424
|
+
continue;
|
|
5425
|
+
}
|
|
5426
|
+
if (segment === "*") {
|
|
5427
|
+
score += 1;
|
|
5428
|
+
} else if (segment.startsWith(":")) {
|
|
5429
|
+
score += 2;
|
|
5430
|
+
} else {
|
|
5431
|
+
score += 3;
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
return score;
|
|
5435
|
+
}
|
|
5436
|
+
function buildRouteRegex(pattern) {
|
|
5437
|
+
const paramNames = [];
|
|
5438
|
+
let source = "";
|
|
5439
|
+
let i = 0;
|
|
5440
|
+
while (i < pattern.length) {
|
|
5441
|
+
if (pattern[i] === ":") {
|
|
5442
|
+
const start = ++i;
|
|
5443
|
+
while (i < pattern.length && pattern[i] !== "/") {
|
|
5444
|
+
i++;
|
|
5445
|
+
}
|
|
5446
|
+
paramNames.push(pattern.slice(start, i));
|
|
5447
|
+
source += "([^/]+)";
|
|
5448
|
+
} else if (pattern[i] === "*") {
|
|
5449
|
+
paramNames.push("*");
|
|
5450
|
+
source += "(.*)";
|
|
5451
|
+
i++;
|
|
5452
|
+
} else {
|
|
5453
|
+
const ch = pattern[i];
|
|
5454
|
+
if (ch !== undefined) {
|
|
5455
|
+
source += escapeRegExpChar(ch);
|
|
5456
|
+
}
|
|
5457
|
+
i++;
|
|
5458
|
+
}
|
|
5459
|
+
}
|
|
5460
|
+
return { regex: new RegExp(`^${source}$`), paramNames };
|
|
5461
|
+
}
|
|
5462
|
+
function applySchemaDefaults(schema, values) {
|
|
5463
|
+
if (!schema || typeof schema !== "object") {
|
|
5464
|
+
return values;
|
|
5465
|
+
}
|
|
5466
|
+
const s = schema;
|
|
5467
|
+
if (s.type !== "object" || !s.properties || typeof s.properties !== "object") {
|
|
5468
|
+
return values;
|
|
5469
|
+
}
|
|
5470
|
+
const result = { ...values };
|
|
5471
|
+
const properties = s.properties;
|
|
5472
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
5473
|
+
if (!(key in result) && propSchema && typeof propSchema === "object" && "default" in propSchema) {
|
|
5474
|
+
result[key] = propSchema.default;
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
return result;
|
|
5478
|
+
}
|
|
5479
|
+
function createDataEndpoint(routes) {
|
|
5480
|
+
const plugin = new Elysia2;
|
|
5481
|
+
plugin.get("/_furin/data", async (ctx) => {
|
|
5482
|
+
const rawPath = ctx.query.path;
|
|
5483
|
+
if (!rawPath || typeof rawPath !== "string") {
|
|
5484
|
+
return new Response("Missing required query param: path", { status: 400 });
|
|
5485
|
+
}
|
|
5486
|
+
const parsed = parseDataEndpointPath(rawPath);
|
|
5487
|
+
if (!parsed) {
|
|
5488
|
+
return new Response("Invalid path", { status: 400 });
|
|
5489
|
+
}
|
|
5490
|
+
const { url, pathname } = parsed;
|
|
5491
|
+
const wideEventLog = useLogger2();
|
|
5492
|
+
wideEventLog.set({ path: rawPath });
|
|
5493
|
+
const matched = routes.reduce((acc, route) => {
|
|
5494
|
+
const { regex, paramNames } = buildRouteRegex(route.pattern);
|
|
5495
|
+
const m = regex.exec(pathname);
|
|
5496
|
+
if (!m) {
|
|
5497
|
+
return acc;
|
|
5498
|
+
}
|
|
5499
|
+
const score = routeSpecificity(route.pattern);
|
|
5500
|
+
if (acc && acc.score >= score) {
|
|
5501
|
+
return acc;
|
|
5502
|
+
}
|
|
5503
|
+
const params = {};
|
|
5504
|
+
for (let i = 0;i < paramNames.length; i++) {
|
|
5505
|
+
const name = paramNames[i];
|
|
5506
|
+
if (name !== undefined) {
|
|
5507
|
+
params[name] = m[i + 1] ?? "";
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
return { route, params, score };
|
|
5511
|
+
}, null);
|
|
5512
|
+
if (!matched) {
|
|
5513
|
+
return new Response("Route not found", { status: 404 });
|
|
5514
|
+
}
|
|
5515
|
+
wideEventLog.set({ routePattern: matched.route.pattern });
|
|
5516
|
+
const syntheticRequest = new Request(new URL(pathname + url.search, ctx.request.url));
|
|
5517
|
+
const syntheticSet = { headers: {}, status: 200 };
|
|
5518
|
+
const syntheticCtx = {
|
|
5519
|
+
request: syntheticRequest,
|
|
5520
|
+
params: matched.params,
|
|
5521
|
+
query: Object.fromEntries(url.searchParams),
|
|
5522
|
+
set: syntheticSet,
|
|
5523
|
+
headers: ctx.headers,
|
|
5524
|
+
cookie: ctx.cookie,
|
|
5525
|
+
path: pathname,
|
|
5526
|
+
redirect: (location, status) => new Response(null, { status: status ?? 302, headers: { location } }),
|
|
5527
|
+
status: (code) => new Response(null, { status: code })
|
|
5528
|
+
};
|
|
5529
|
+
const mergedParams = mergeRouteSchemas(matched.route.routeChain, "params");
|
|
5530
|
+
const mergedQuery = mergeRouteSchemas(matched.route.routeChain, "query");
|
|
5531
|
+
syntheticCtx.params = applySchemaDefaults(mergedParams, syntheticCtx.params);
|
|
5532
|
+
syntheticCtx.query = applySchemaDefaults(mergedQuery, syntheticCtx.query);
|
|
5533
|
+
if (mergedQuery) {
|
|
5534
|
+
const redirectLocation = detectQueryDefaultRedirect(syntheticRequest, syntheticCtx.query);
|
|
5535
|
+
if (redirectLocation) {
|
|
5536
|
+
const serialized2 = await toCrossJSONAsync({ __furinRedirect: redirectLocation });
|
|
5537
|
+
return new Response(`${JSON.stringify(serialized2)}
|
|
5538
|
+
`, {
|
|
5539
|
+
headers: { "content-type": "application/x-ndjson" }
|
|
5540
|
+
});
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
const result = await runLoaders(matched.route, syntheticCtx);
|
|
5544
|
+
if (result.type === "data") {
|
|
5545
|
+
autoInvalidateRegistry.registerLoaderTags(pathname, matched.route.tags);
|
|
5546
|
+
}
|
|
5547
|
+
if (result.type === "redirect") {
|
|
5548
|
+
const redirectUrl = new URL(result.response.headers.get("location") ?? "/", ctx.request.url);
|
|
5549
|
+
const serialized2 = await toCrossJSONAsync({
|
|
5550
|
+
__furinRedirect: redirectUrl.pathname + redirectUrl.search
|
|
5551
|
+
});
|
|
5552
|
+
return new Response(`${JSON.stringify(serialized2)}
|
|
5553
|
+
`, {
|
|
5554
|
+
headers: { "content-type": "application/x-ndjson" }
|
|
5555
|
+
});
|
|
5556
|
+
}
|
|
5557
|
+
if (result.type === "not-found") {
|
|
5558
|
+
const serialized2 = await toCrossJSONAsync({
|
|
5559
|
+
__furinStatus: 404,
|
|
5560
|
+
__furinNotFound: { message: result.error.message, data: result.error.data }
|
|
5561
|
+
});
|
|
5562
|
+
return new Response(`${JSON.stringify(serialized2)}
|
|
5563
|
+
`, {
|
|
5564
|
+
status: 200,
|
|
5565
|
+
headers: { "content-type": "application/x-ndjson" }
|
|
5566
|
+
});
|
|
5567
|
+
}
|
|
5568
|
+
if (result.type === "error") {
|
|
5569
|
+
const digest = computeErrorDigest(result.error);
|
|
5570
|
+
const serialized2 = await toCrossJSONAsync({
|
|
5571
|
+
__furinError: {
|
|
5572
|
+
digest,
|
|
5573
|
+
message: result.message,
|
|
5574
|
+
status: result.status
|
|
5575
|
+
}
|
|
5576
|
+
});
|
|
5577
|
+
return new Response(`${JSON.stringify(serialized2)}
|
|
5578
|
+
`, {
|
|
5579
|
+
status: result.status,
|
|
5580
|
+
headers: { "content-type": "application/x-ndjson" }
|
|
5581
|
+
});
|
|
5582
|
+
}
|
|
5583
|
+
const syncDataWithTitle = withResolvedTitle(matched.route, result.syncData);
|
|
5584
|
+
if (result.deferredPromises) {
|
|
5585
|
+
return new Response(createDeferredNdjsonStream(syncDataWithTitle, result.deferredPromises), {
|
|
5586
|
+
headers: {
|
|
5587
|
+
"content-type": "application/x-ndjson",
|
|
5588
|
+
...result.headers
|
|
5589
|
+
}
|
|
5590
|
+
});
|
|
5591
|
+
}
|
|
5592
|
+
const serialized = await toCrossJSONAsync(syncDataWithTitle);
|
|
5593
|
+
return new Response(`${JSON.stringify(serialized)}
|
|
5594
|
+
`, {
|
|
5595
|
+
headers: {
|
|
5596
|
+
"content-type": "application/x-ndjson",
|
|
5597
|
+
...result.headers
|
|
5598
|
+
}
|
|
5599
|
+
});
|
|
5600
|
+
}, {
|
|
5601
|
+
query: t.Object({ path: t.Optional(t.String()) })
|
|
5602
|
+
});
|
|
5603
|
+
return plugin;
|
|
5604
|
+
}
|
|
5605
|
+
function withResolvedTitle(route, syncData) {
|
|
5606
|
+
const head = route.page.head;
|
|
5607
|
+
if (!head) {
|
|
5608
|
+
return syncData;
|
|
5609
|
+
}
|
|
5610
|
+
let title;
|
|
5611
|
+
try {
|
|
5612
|
+
title = extractTitle(head(syncData).meta);
|
|
5613
|
+
} catch {
|
|
5614
|
+
return syncData;
|
|
5615
|
+
}
|
|
5616
|
+
if (title === undefined) {
|
|
5617
|
+
return syncData;
|
|
5618
|
+
}
|
|
5619
|
+
return { ...syncData, __furinTitle: title };
|
|
5620
|
+
}
|
|
5621
|
+
function createDeferredNdjsonStream(syncData, deferredPromises) {
|
|
5622
|
+
const enc = new TextEncoder;
|
|
5623
|
+
const entries = Object.entries(deferredPromises);
|
|
5624
|
+
return new ReadableStream({
|
|
5625
|
+
async start(controller) {
|
|
5626
|
+
const initial = toCrossJSON({
|
|
5627
|
+
...syncData,
|
|
5628
|
+
__furinDeferredKeys: entries.map(([key]) => key)
|
|
5629
|
+
});
|
|
5630
|
+
controller.enqueue(enc.encode(`${JSON.stringify(initial)}
|
|
5631
|
+
`));
|
|
5632
|
+
await Promise.all(entries.map(async ([key, promise]) => {
|
|
5633
|
+
try {
|
|
5634
|
+
const value = await promise;
|
|
5635
|
+
controller.enqueue(enc.encode(`${JSON.stringify({ key, action: "resolve", value: toCrossJSON(value) })}
|
|
5636
|
+
`));
|
|
5637
|
+
} catch (err) {
|
|
5638
|
+
const normalized = await serializeDeferredRejection(err);
|
|
5639
|
+
const value = toCrossJSON(normalized);
|
|
5640
|
+
controller.enqueue(enc.encode(`${JSON.stringify({ key, action: "reject", value })}
|
|
5641
|
+
`));
|
|
5642
|
+
}
|
|
5643
|
+
}));
|
|
5644
|
+
controller.close();
|
|
5645
|
+
}
|
|
5646
|
+
});
|
|
5647
|
+
}
|
|
3118
5648
|
export {
|
|
3119
5649
|
scanRootLayout,
|
|
3120
5650
|
scanPages,
|
|
3121
5651
|
resolveMode,
|
|
3122
5652
|
refreshLayoutChain,
|
|
5653
|
+
rebuildDevRoute,
|
|
3123
5654
|
queryDefaultRedirectHook,
|
|
5655
|
+
parseDataEndpointPath,
|
|
3124
5656
|
mergeRouteSchemas,
|
|
3125
5657
|
loadProdRoutes,
|
|
3126
5658
|
filePathToPattern,
|
|
5659
|
+
detectQueryDefaultRedirect,
|
|
3127
5660
|
createRoutePlugin,
|
|
3128
|
-
|
|
5661
|
+
createDataEndpoint,
|
|
5662
|
+
computeRouteDependencies,
|
|
5663
|
+
collectRouteTags
|
|
3129
5664
|
};
|