quiz-mcp 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/_app/immutable/assets/0.BdUfdP7M.css +1 -0
- package/dist/client/_app/immutable/assets/0.BdUfdP7M.css.br +0 -0
- package/dist/client/_app/immutable/assets/0.BdUfdP7M.css.gz +0 -0
- package/dist/client/_app/immutable/chunks/BBbVH-DX.js +2 -0
- package/dist/client/_app/immutable/chunks/BBbVH-DX.js.br +0 -0
- package/dist/client/_app/immutable/chunks/BBbVH-DX.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/BCs3MiOV.js +3 -0
- package/dist/client/_app/immutable/chunks/BCs3MiOV.js.br +0 -0
- package/dist/client/_app/immutable/chunks/BCs3MiOV.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/BYAtt_Gu.js +1 -0
- package/dist/client/_app/immutable/chunks/BYAtt_Gu.js.br +0 -0
- package/dist/client/_app/immutable/chunks/BYAtt_Gu.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/BiUDuxdv.js +1 -0
- package/dist/client/_app/immutable/chunks/BiUDuxdv.js.br +0 -0
- package/dist/client/_app/immutable/chunks/BiUDuxdv.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/C9b1VZtB.js +1 -0
- package/dist/client/_app/immutable/chunks/C9b1VZtB.js.br +0 -0
- package/dist/client/_app/immutable/chunks/C9b1VZtB.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/DnSqigra.js +1 -0
- package/dist/client/_app/immutable/chunks/DnSqigra.js.br +0 -0
- package/dist/client/_app/immutable/chunks/DnSqigra.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/hqRb622q.js +1 -0
- package/dist/client/_app/immutable/chunks/hqRb622q.js.br +0 -0
- package/dist/client/_app/immutable/chunks/hqRb622q.js.gz +0 -0
- package/dist/client/_app/immutable/chunks/qgn7L4n5.js +1 -0
- package/dist/client/_app/immutable/chunks/qgn7L4n5.js.br +0 -0
- package/dist/client/_app/immutable/chunks/qgn7L4n5.js.gz +0 -0
- package/dist/client/_app/immutable/entry/app.bYAeQTs6.js +2 -0
- package/dist/client/_app/immutable/entry/app.bYAeQTs6.js.br +0 -0
- package/dist/client/_app/immutable/entry/app.bYAeQTs6.js.gz +0 -0
- package/dist/client/_app/immutable/entry/start.Cmx5TBy8.js +1 -0
- package/dist/client/_app/immutable/entry/start.Cmx5TBy8.js.br +2 -0
- package/dist/client/_app/immutable/entry/start.Cmx5TBy8.js.gz +0 -0
- package/dist/client/_app/immutable/nodes/0.dFwzZb2p.js +9 -0
- package/dist/client/_app/immutable/nodes/0.dFwzZb2p.js.br +0 -0
- package/dist/client/_app/immutable/nodes/0.dFwzZb2p.js.gz +0 -0
- package/dist/client/_app/immutable/nodes/1.B4bc-Osb.js +1 -0
- package/dist/client/_app/immutable/nodes/1.B4bc-Osb.js.br +0 -0
- package/dist/client/_app/immutable/nodes/1.B4bc-Osb.js.gz +0 -0
- package/dist/client/_app/immutable/nodes/2.B9MLTE_H.js +2 -0
- package/dist/client/_app/immutable/nodes/2.B9MLTE_H.js.br +0 -0
- package/dist/client/_app/immutable/nodes/2.B9MLTE_H.js.gz +0 -0
- package/dist/client/_app/immutable/nodes/3.w4AbulQF.js +1 -0
- package/dist/client/_app/immutable/nodes/3.w4AbulQF.js.br +0 -0
- package/dist/client/_app/immutable/nodes/3.w4AbulQF.js.gz +0 -0
- package/dist/client/_app/immutable/nodes/4.Cn3HnTfP.js +4 -0
- package/dist/client/_app/immutable/nodes/4.Cn3HnTfP.js.br +0 -0
- package/dist/client/_app/immutable/nodes/4.Cn3HnTfP.js.gz +0 -0
- package/dist/client/_app/version.json +1 -0
- package/dist/client/_app/version.json.br +0 -0
- package/dist/client/_app/version.json.gz +0 -0
- package/dist/client/robots.txt +3 -0
- package/dist/env.js +94 -0
- package/dist/handler.js +1435 -0
- package/dist/index.js +345 -0
- package/dist/server/chunks/0-DV3MS3Jq.js +44 -0
- package/dist/server/chunks/0-DV3MS3Jq.js.map +1 -0
- package/dist/server/chunks/1-D5q3RfmV.js +9 -0
- package/dist/server/chunks/1-D5q3RfmV.js.map +1 -0
- package/dist/server/chunks/2-NzZFDUaQ.js +60 -0
- package/dist/server/chunks/2-NzZFDUaQ.js.map +1 -0
- package/dist/server/chunks/3-mMAf4OfT.js +37 -0
- package/dist/server/chunks/3-mMAf4OfT.js.map +1 -0
- package/dist/server/chunks/4-BszN7YH6.js +37 -0
- package/dist/server/chunks/4-BszN7YH6.js.map +1 -0
- package/dist/server/chunks/_error.svelte-DdU-RsvI.js +82 -0
- package/dist/server/chunks/_error.svelte-DdU-RsvI.js.map +1 -0
- package/dist/server/chunks/_layout.svelte-ByxFsgXH.js +106 -0
- package/dist/server/chunks/_layout.svelte-ByxFsgXH.js.map +1 -0
- package/dist/server/chunks/_page.svelte-CRU5jaGZ.js +653 -0
- package/dist/server/chunks/_page.svelte-CRU5jaGZ.js.map +1 -0
- package/dist/server/chunks/_page.svelte-Cm8ocLsi.js +572 -0
- package/dist/server/chunks/_page.svelte-Cm8ocLsi.js.map +1 -0
- package/dist/server/chunks/_page.svelte-DkIV_2wP.js +73 -0
- package/dist/server/chunks/_page.svelte-DkIV_2wP.js.map +1 -0
- package/dist/server/chunks/_server.ts-D6J6LtvY.js +39 -0
- package/dist/server/chunks/_server.ts-D6J6LtvY.js.map +1 -0
- package/dist/server/chunks/_server.ts-DCk3MOtj.js +35 -0
- package/dist/server/chunks/_server.ts-DCk3MOtj.js.map +1 -0
- package/dist/server/chunks/_server.ts-DLmpRTXg.js +101 -0
- package/dist/server/chunks/_server.ts-DLmpRTXg.js.map +1 -0
- package/dist/server/chunks/_server.ts-DSbw8FX3.js +219 -0
- package/dist/server/chunks/_server.ts-DSbw8FX3.js.map +1 -0
- package/dist/server/chunks/_server.ts-Dhx3VnxA.js +51 -0
- package/dist/server/chunks/_server.ts-Dhx3VnxA.js.map +1 -0
- package/dist/server/chunks/client-Bik_FcIp.js +27 -0
- package/dist/server/chunks/client-Bik_FcIp.js.map +1 -0
- package/dist/server/chunks/exports-zEtqeh3Y.js +286 -0
- package/dist/server/chunks/exports-zEtqeh3Y.js.map +1 -0
- package/dist/server/chunks/hooks.server-B6FrjICA.js +66 -0
- package/dist/server/chunks/hooks.server-B6FrjICA.js.map +1 -0
- package/dist/server/chunks/hooks.universal-B3lncnqn.js +6 -0
- package/dist/server/chunks/hooks.universal-B3lncnqn.js.map +1 -0
- package/dist/server/chunks/html-FW6Ia4bL.js +8 -0
- package/dist/server/chunks/html-FW6Ia4bL.js.map +1 -0
- package/dist/server/chunks/index-Ch5Bqlgz.js +1411 -0
- package/dist/server/chunks/index-Ch5Bqlgz.js.map +1 -0
- package/dist/server/chunks/runtime-Bf5HkYyl.js +318 -0
- package/dist/server/chunks/runtime-Bf5HkYyl.js.map +1 -0
- package/dist/server/chunks/sessions-CEbRx2vt.js +169 -0
- package/dist/server/chunks/sessions-CEbRx2vt.js.map +1 -0
- package/dist/server/index.js +7595 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/manifest.js +97 -0
- package/dist/server/manifest.js.map +1 -0
- package/dist/shims.js +32 -0
- package/package.json +11 -15
- package/bin/quiz +0 -16
- package/bin/quiz-runner +0 -18
- package/bin/quiz-runner-mcp +0 -18
|
@@ -0,0 +1,1411 @@
|
|
|
1
|
+
const escaped = {
|
|
2
|
+
"<": "\\u003C",
|
|
3
|
+
"\\": "\\\\",
|
|
4
|
+
"\b": "\\b",
|
|
5
|
+
"\f": "\\f",
|
|
6
|
+
"\n": "\\n",
|
|
7
|
+
"\r": "\\r",
|
|
8
|
+
" ": "\\t",
|
|
9
|
+
"\u2028": "\\u2028",
|
|
10
|
+
"\u2029": "\\u2029"
|
|
11
|
+
};
|
|
12
|
+
class DevalueError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} message
|
|
15
|
+
* @param {string[]} keys
|
|
16
|
+
* @param {any} [value] - The value that failed to be serialized
|
|
17
|
+
* @param {any} [root] - The root value being serialized
|
|
18
|
+
*/
|
|
19
|
+
constructor(message, keys, value, root) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "DevalueError";
|
|
22
|
+
this.path = keys.join("");
|
|
23
|
+
this.value = value;
|
|
24
|
+
this.root = root;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function is_primitive(thing) {
|
|
28
|
+
return Object(thing) !== thing;
|
|
29
|
+
}
|
|
30
|
+
const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
|
|
31
|
+
Object.prototype
|
|
32
|
+
).sort().join("\0");
|
|
33
|
+
function is_plain_object(thing) {
|
|
34
|
+
const proto = Object.getPrototypeOf(thing);
|
|
35
|
+
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
|
|
36
|
+
}
|
|
37
|
+
function get_type(thing) {
|
|
38
|
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
|
39
|
+
}
|
|
40
|
+
function get_escaped_char(char) {
|
|
41
|
+
switch (char) {
|
|
42
|
+
case '"':
|
|
43
|
+
return '\\"';
|
|
44
|
+
case "<":
|
|
45
|
+
return "\\u003C";
|
|
46
|
+
case "\\":
|
|
47
|
+
return "\\\\";
|
|
48
|
+
case "\n":
|
|
49
|
+
return "\\n";
|
|
50
|
+
case "\r":
|
|
51
|
+
return "\\r";
|
|
52
|
+
case " ":
|
|
53
|
+
return "\\t";
|
|
54
|
+
case "\b":
|
|
55
|
+
return "\\b";
|
|
56
|
+
case "\f":
|
|
57
|
+
return "\\f";
|
|
58
|
+
case "\u2028":
|
|
59
|
+
return "\\u2028";
|
|
60
|
+
case "\u2029":
|
|
61
|
+
return "\\u2029";
|
|
62
|
+
default:
|
|
63
|
+
return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function stringify_string(str) {
|
|
67
|
+
let result = "";
|
|
68
|
+
let last_pos = 0;
|
|
69
|
+
const len = str.length;
|
|
70
|
+
for (let i = 0; i < len; i += 1) {
|
|
71
|
+
const char = str[i];
|
|
72
|
+
const replacement = get_escaped_char(char);
|
|
73
|
+
if (replacement) {
|
|
74
|
+
result += str.slice(last_pos, i) + replacement;
|
|
75
|
+
last_pos = i + 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
|
|
79
|
+
}
|
|
80
|
+
function enumerable_symbols(object) {
|
|
81
|
+
return Object.getOwnPropertySymbols(object).filter(
|
|
82
|
+
(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
|
|
86
|
+
function stringify_key(key) {
|
|
87
|
+
return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
|
|
91
|
+
const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
|
|
92
|
+
const reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
|
93
|
+
function uneval(value, replacer) {
|
|
94
|
+
const counts = /* @__PURE__ */ new Map();
|
|
95
|
+
const keys = [];
|
|
96
|
+
const custom = /* @__PURE__ */ new Map();
|
|
97
|
+
function walk(thing) {
|
|
98
|
+
if (!is_primitive(thing)) {
|
|
99
|
+
if (counts.has(thing)) {
|
|
100
|
+
counts.set(thing, counts.get(thing) + 1);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
counts.set(thing, 1);
|
|
104
|
+
if (replacer) {
|
|
105
|
+
const str2 = replacer(thing, (value2) => uneval(value2, replacer));
|
|
106
|
+
if (typeof str2 === "string") {
|
|
107
|
+
custom.set(thing, str2);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (typeof thing === "function") {
|
|
112
|
+
throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
|
|
113
|
+
}
|
|
114
|
+
const type = get_type(thing);
|
|
115
|
+
switch (type) {
|
|
116
|
+
case "Number":
|
|
117
|
+
case "BigInt":
|
|
118
|
+
case "String":
|
|
119
|
+
case "Boolean":
|
|
120
|
+
case "Date":
|
|
121
|
+
case "RegExp":
|
|
122
|
+
case "URL":
|
|
123
|
+
case "URLSearchParams":
|
|
124
|
+
return;
|
|
125
|
+
case "Array":
|
|
126
|
+
thing.forEach((value2, i) => {
|
|
127
|
+
keys.push(`[${i}]`);
|
|
128
|
+
walk(value2);
|
|
129
|
+
keys.pop();
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
case "Set":
|
|
133
|
+
Array.from(thing).forEach(walk);
|
|
134
|
+
break;
|
|
135
|
+
case "Map":
|
|
136
|
+
for (const [key, value2] of thing) {
|
|
137
|
+
keys.push(
|
|
138
|
+
`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
|
|
139
|
+
);
|
|
140
|
+
walk(value2);
|
|
141
|
+
keys.pop();
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case "Int8Array":
|
|
145
|
+
case "Uint8Array":
|
|
146
|
+
case "Uint8ClampedArray":
|
|
147
|
+
case "Int16Array":
|
|
148
|
+
case "Uint16Array":
|
|
149
|
+
case "Int32Array":
|
|
150
|
+
case "Uint32Array":
|
|
151
|
+
case "Float32Array":
|
|
152
|
+
case "Float64Array":
|
|
153
|
+
case "BigInt64Array":
|
|
154
|
+
case "BigUint64Array":
|
|
155
|
+
walk(thing.buffer);
|
|
156
|
+
return;
|
|
157
|
+
case "ArrayBuffer":
|
|
158
|
+
return;
|
|
159
|
+
case "Temporal.Duration":
|
|
160
|
+
case "Temporal.Instant":
|
|
161
|
+
case "Temporal.PlainDate":
|
|
162
|
+
case "Temporal.PlainTime":
|
|
163
|
+
case "Temporal.PlainDateTime":
|
|
164
|
+
case "Temporal.PlainMonthDay":
|
|
165
|
+
case "Temporal.PlainYearMonth":
|
|
166
|
+
case "Temporal.ZonedDateTime":
|
|
167
|
+
return;
|
|
168
|
+
default:
|
|
169
|
+
if (!is_plain_object(thing)) {
|
|
170
|
+
throw new DevalueError(
|
|
171
|
+
`Cannot stringify arbitrary non-POJOs`,
|
|
172
|
+
keys,
|
|
173
|
+
thing,
|
|
174
|
+
value
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if (enumerable_symbols(thing).length > 0) {
|
|
178
|
+
throw new DevalueError(
|
|
179
|
+
`Cannot stringify POJOs with symbolic keys`,
|
|
180
|
+
keys,
|
|
181
|
+
thing,
|
|
182
|
+
value
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
for (const key in thing) {
|
|
186
|
+
keys.push(stringify_key(key));
|
|
187
|
+
walk(thing[key]);
|
|
188
|
+
keys.pop();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
walk(value);
|
|
194
|
+
const names = /* @__PURE__ */ new Map();
|
|
195
|
+
Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
|
|
196
|
+
names.set(entry[0], get_name(i));
|
|
197
|
+
});
|
|
198
|
+
function stringify2(thing) {
|
|
199
|
+
if (names.has(thing)) {
|
|
200
|
+
return names.get(thing);
|
|
201
|
+
}
|
|
202
|
+
if (is_primitive(thing)) {
|
|
203
|
+
return stringify_primitive(thing);
|
|
204
|
+
}
|
|
205
|
+
if (custom.has(thing)) {
|
|
206
|
+
return custom.get(thing);
|
|
207
|
+
}
|
|
208
|
+
const type = get_type(thing);
|
|
209
|
+
switch (type) {
|
|
210
|
+
case "Number":
|
|
211
|
+
case "String":
|
|
212
|
+
case "Boolean":
|
|
213
|
+
return `Object(${stringify2(thing.valueOf())})`;
|
|
214
|
+
case "RegExp":
|
|
215
|
+
return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`;
|
|
216
|
+
case "Date":
|
|
217
|
+
return `new Date(${thing.getTime()})`;
|
|
218
|
+
case "URL":
|
|
219
|
+
return `new URL(${stringify_string(thing.toString())})`;
|
|
220
|
+
case "URLSearchParams":
|
|
221
|
+
return `new URLSearchParams(${stringify_string(thing.toString())})`;
|
|
222
|
+
case "Array":
|
|
223
|
+
const members = (
|
|
224
|
+
/** @type {any[]} */
|
|
225
|
+
thing.map(
|
|
226
|
+
(v, i) => i in thing ? stringify2(v) : ""
|
|
227
|
+
)
|
|
228
|
+
);
|
|
229
|
+
const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
|
|
230
|
+
return `[${members.join(",")}${tail}]`;
|
|
231
|
+
case "Set":
|
|
232
|
+
case "Map":
|
|
233
|
+
return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`;
|
|
234
|
+
case "Int8Array":
|
|
235
|
+
case "Uint8Array":
|
|
236
|
+
case "Uint8ClampedArray":
|
|
237
|
+
case "Int16Array":
|
|
238
|
+
case "Uint16Array":
|
|
239
|
+
case "Int32Array":
|
|
240
|
+
case "Uint32Array":
|
|
241
|
+
case "Float32Array":
|
|
242
|
+
case "Float64Array":
|
|
243
|
+
case "BigInt64Array":
|
|
244
|
+
case "BigUint64Array": {
|
|
245
|
+
let str2 = `new ${type}`;
|
|
246
|
+
if (counts.get(thing.buffer) === 1) {
|
|
247
|
+
const array = new thing.constructor(thing.buffer);
|
|
248
|
+
str2 += `([${array}])`;
|
|
249
|
+
} else {
|
|
250
|
+
str2 += `([${stringify2(thing.buffer)}])`;
|
|
251
|
+
}
|
|
252
|
+
const a = thing.byteOffset;
|
|
253
|
+
const b = a + thing.byteLength;
|
|
254
|
+
if (a > 0 || b !== thing.buffer.byteLength) {
|
|
255
|
+
const m = +/(\d+)/.exec(type)[1] / 8;
|
|
256
|
+
str2 += `.subarray(${a / m},${b / m})`;
|
|
257
|
+
}
|
|
258
|
+
return str2;
|
|
259
|
+
}
|
|
260
|
+
case "ArrayBuffer": {
|
|
261
|
+
const ui8 = new Uint8Array(thing);
|
|
262
|
+
return `new Uint8Array([${ui8.toString()}]).buffer`;
|
|
263
|
+
}
|
|
264
|
+
case "Temporal.Duration":
|
|
265
|
+
case "Temporal.Instant":
|
|
266
|
+
case "Temporal.PlainDate":
|
|
267
|
+
case "Temporal.PlainTime":
|
|
268
|
+
case "Temporal.PlainDateTime":
|
|
269
|
+
case "Temporal.PlainMonthDay":
|
|
270
|
+
case "Temporal.PlainYearMonth":
|
|
271
|
+
case "Temporal.ZonedDateTime":
|
|
272
|
+
return `${type}.from(${stringify_string(thing.toString())})`;
|
|
273
|
+
default:
|
|
274
|
+
const keys2 = Object.keys(thing);
|
|
275
|
+
const obj = keys2.map((key) => `${safe_key(key)}:${stringify2(thing[key])}`).join(",");
|
|
276
|
+
const proto = Object.getPrototypeOf(thing);
|
|
277
|
+
if (proto === null) {
|
|
278
|
+
return keys2.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
|
|
279
|
+
}
|
|
280
|
+
return `{${obj}}`;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const str = stringify2(value);
|
|
284
|
+
if (names.size) {
|
|
285
|
+
const params = [];
|
|
286
|
+
const statements = [];
|
|
287
|
+
const values = [];
|
|
288
|
+
names.forEach((name, thing) => {
|
|
289
|
+
params.push(name);
|
|
290
|
+
if (custom.has(thing)) {
|
|
291
|
+
values.push(
|
|
292
|
+
/** @type {string} */
|
|
293
|
+
custom.get(thing)
|
|
294
|
+
);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (is_primitive(thing)) {
|
|
298
|
+
values.push(stringify_primitive(thing));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const type = get_type(thing);
|
|
302
|
+
switch (type) {
|
|
303
|
+
case "Number":
|
|
304
|
+
case "String":
|
|
305
|
+
case "Boolean":
|
|
306
|
+
values.push(`Object(${stringify2(thing.valueOf())})`);
|
|
307
|
+
break;
|
|
308
|
+
case "RegExp":
|
|
309
|
+
values.push(thing.toString());
|
|
310
|
+
break;
|
|
311
|
+
case "Date":
|
|
312
|
+
values.push(`new Date(${thing.getTime()})`);
|
|
313
|
+
break;
|
|
314
|
+
case "Array":
|
|
315
|
+
values.push(`Array(${thing.length})`);
|
|
316
|
+
thing.forEach((v, i) => {
|
|
317
|
+
statements.push(`${name}[${i}]=${stringify2(v)}`);
|
|
318
|
+
});
|
|
319
|
+
break;
|
|
320
|
+
case "Set":
|
|
321
|
+
values.push(`new Set`);
|
|
322
|
+
statements.push(
|
|
323
|
+
`${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}`
|
|
324
|
+
);
|
|
325
|
+
break;
|
|
326
|
+
case "Map":
|
|
327
|
+
values.push(`new Map`);
|
|
328
|
+
statements.push(
|
|
329
|
+
`${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}`
|
|
330
|
+
);
|
|
331
|
+
break;
|
|
332
|
+
case "ArrayBuffer":
|
|
333
|
+
values.push(
|
|
334
|
+
`new Uint8Array([${new Uint8Array(thing).join(",")}]).buffer`
|
|
335
|
+
);
|
|
336
|
+
break;
|
|
337
|
+
default:
|
|
338
|
+
values.push(
|
|
339
|
+
Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}"
|
|
340
|
+
);
|
|
341
|
+
Object.keys(thing).forEach((key) => {
|
|
342
|
+
statements.push(
|
|
343
|
+
`${name}${safe_prop(key)}=${stringify2(thing[key])}`
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
statements.push(`return ${str}`);
|
|
349
|
+
return `(function(${params.join(",")}){${statements.join(
|
|
350
|
+
";"
|
|
351
|
+
)}}(${values.join(",")}))`;
|
|
352
|
+
} else {
|
|
353
|
+
return str;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function get_name(num) {
|
|
357
|
+
let name = "";
|
|
358
|
+
do {
|
|
359
|
+
name = chars[num % chars.length] + name;
|
|
360
|
+
num = ~~(num / chars.length) - 1;
|
|
361
|
+
} while (num >= 0);
|
|
362
|
+
return reserved.test(name) ? `${name}0` : name;
|
|
363
|
+
}
|
|
364
|
+
function escape_unsafe_char(c) {
|
|
365
|
+
return escaped[c] || c;
|
|
366
|
+
}
|
|
367
|
+
function escape_unsafe_chars(str) {
|
|
368
|
+
return str.replace(unsafe_chars, escape_unsafe_char);
|
|
369
|
+
}
|
|
370
|
+
function safe_key(key) {
|
|
371
|
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
|
|
372
|
+
}
|
|
373
|
+
function safe_prop(key) {
|
|
374
|
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
|
|
375
|
+
}
|
|
376
|
+
function stringify_primitive(thing) {
|
|
377
|
+
if (typeof thing === "string") return stringify_string(thing);
|
|
378
|
+
if (thing === void 0) return "void 0";
|
|
379
|
+
if (thing === 0 && 1 / thing < 0) return "-0";
|
|
380
|
+
const str = String(thing);
|
|
381
|
+
if (typeof thing === "number") return str.replace(/^(-)?0\./, "$1.");
|
|
382
|
+
if (typeof thing === "bigint") return thing + "n";
|
|
383
|
+
return str;
|
|
384
|
+
}
|
|
385
|
+
const DERIVED = 1 << 1;
|
|
386
|
+
const EFFECT = 1 << 2;
|
|
387
|
+
const RENDER_EFFECT = 1 << 3;
|
|
388
|
+
const MANAGED_EFFECT = 1 << 24;
|
|
389
|
+
const BLOCK_EFFECT = 1 << 4;
|
|
390
|
+
const BRANCH_EFFECT = 1 << 5;
|
|
391
|
+
const ROOT_EFFECT = 1 << 6;
|
|
392
|
+
const BOUNDARY_EFFECT = 1 << 7;
|
|
393
|
+
const CONNECTED = 1 << 9;
|
|
394
|
+
const CLEAN = 1 << 10;
|
|
395
|
+
const DIRTY = 1 << 11;
|
|
396
|
+
const MAYBE_DIRTY = 1 << 12;
|
|
397
|
+
const INERT = 1 << 13;
|
|
398
|
+
const DESTROYED = 1 << 14;
|
|
399
|
+
const EFFECT_RAN = 1 << 15;
|
|
400
|
+
const EFFECT_TRANSPARENT = 1 << 16;
|
|
401
|
+
const EAGER_EFFECT = 1 << 17;
|
|
402
|
+
const HEAD_EFFECT = 1 << 18;
|
|
403
|
+
const EFFECT_PRESERVED = 1 << 19;
|
|
404
|
+
const USER_EFFECT = 1 << 20;
|
|
405
|
+
const WAS_MARKED = 1 << 15;
|
|
406
|
+
const REACTION_IS_UPDATING = 1 << 21;
|
|
407
|
+
const ASYNC = 1 << 22;
|
|
408
|
+
const ERROR_VALUE = 1 << 23;
|
|
409
|
+
const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
|
|
410
|
+
const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
|
|
411
|
+
const STALE_REACTION = new class StaleReactionError extends Error {
|
|
412
|
+
name = "StaleReactionError";
|
|
413
|
+
message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
|
|
414
|
+
}();
|
|
415
|
+
const COMMENT_NODE = 8;
|
|
416
|
+
function lifecycle_outside_component(name) {
|
|
417
|
+
{
|
|
418
|
+
throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const HYDRATION_START = "[";
|
|
422
|
+
const HYDRATION_START_ELSE = "[!";
|
|
423
|
+
const HYDRATION_END = "]";
|
|
424
|
+
const HYDRATION_ERROR = {};
|
|
425
|
+
const ELEMENT_IS_NAMESPACED = 1;
|
|
426
|
+
const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
|
|
427
|
+
const ELEMENT_IS_INPUT = 1 << 2;
|
|
428
|
+
const UNINITIALIZED = /* @__PURE__ */ Symbol();
|
|
429
|
+
const DOM_BOOLEAN_ATTRIBUTES = [
|
|
430
|
+
"allowfullscreen",
|
|
431
|
+
"async",
|
|
432
|
+
"autofocus",
|
|
433
|
+
"autoplay",
|
|
434
|
+
"checked",
|
|
435
|
+
"controls",
|
|
436
|
+
"default",
|
|
437
|
+
"disabled",
|
|
438
|
+
"formnovalidate",
|
|
439
|
+
"indeterminate",
|
|
440
|
+
"inert",
|
|
441
|
+
"ismap",
|
|
442
|
+
"loop",
|
|
443
|
+
"multiple",
|
|
444
|
+
"muted",
|
|
445
|
+
"nomodule",
|
|
446
|
+
"novalidate",
|
|
447
|
+
"open",
|
|
448
|
+
"playsinline",
|
|
449
|
+
"readonly",
|
|
450
|
+
"required",
|
|
451
|
+
"reversed",
|
|
452
|
+
"seamless",
|
|
453
|
+
"selected",
|
|
454
|
+
"webkitdirectory",
|
|
455
|
+
"defer",
|
|
456
|
+
"disablepictureinpicture",
|
|
457
|
+
"disableremoteplayback"
|
|
458
|
+
];
|
|
459
|
+
function is_boolean_attribute(name) {
|
|
460
|
+
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
|
|
461
|
+
}
|
|
462
|
+
const PASSIVE_EVENTS = ["touchstart", "touchmove"];
|
|
463
|
+
function is_passive_event(name) {
|
|
464
|
+
return PASSIVE_EVENTS.includes(name);
|
|
465
|
+
}
|
|
466
|
+
const ATTR_REGEX = /[&"<]/g;
|
|
467
|
+
const CONTENT_REGEX = /[&<]/g;
|
|
468
|
+
function escape_html(value, is_attr) {
|
|
469
|
+
const str = String(value ?? "");
|
|
470
|
+
const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
|
|
471
|
+
pattern.lastIndex = 0;
|
|
472
|
+
let escaped2 = "";
|
|
473
|
+
let last = 0;
|
|
474
|
+
while (pattern.test(str)) {
|
|
475
|
+
const i = pattern.lastIndex - 1;
|
|
476
|
+
const ch = str[i];
|
|
477
|
+
escaped2 += str.substring(last, i) + (ch === "&" ? "&" : ch === '"' ? """ : "<");
|
|
478
|
+
last = i + 1;
|
|
479
|
+
}
|
|
480
|
+
return escaped2 + str.substring(last);
|
|
481
|
+
}
|
|
482
|
+
function r(e) {
|
|
483
|
+
var t, f, n = "";
|
|
484
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
485
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
486
|
+
var o = e.length;
|
|
487
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
488
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
489
|
+
return n;
|
|
490
|
+
}
|
|
491
|
+
function clsx$1() {
|
|
492
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
493
|
+
return n;
|
|
494
|
+
}
|
|
495
|
+
const replacements = {
|
|
496
|
+
translate: /* @__PURE__ */ new Map([
|
|
497
|
+
[true, "yes"],
|
|
498
|
+
[false, "no"]
|
|
499
|
+
])
|
|
500
|
+
};
|
|
501
|
+
function attr(name, value, is_boolean = false) {
|
|
502
|
+
if (name === "hidden" && value !== "until-found") {
|
|
503
|
+
is_boolean = true;
|
|
504
|
+
}
|
|
505
|
+
if (value == null || !value && is_boolean) return "";
|
|
506
|
+
const normalized = name in replacements && replacements[name].get(value) || value;
|
|
507
|
+
const assignment = is_boolean ? "" : `="${escape_html(normalized, true)}"`;
|
|
508
|
+
return ` ${name}${assignment}`;
|
|
509
|
+
}
|
|
510
|
+
function clsx(value) {
|
|
511
|
+
if (typeof value === "object") {
|
|
512
|
+
return clsx$1(value);
|
|
513
|
+
} else {
|
|
514
|
+
return value ?? "";
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const whitespace = [..." \n\r\f \v\uFEFF"];
|
|
518
|
+
function to_class(value, hash, directives) {
|
|
519
|
+
var classname = value == null ? "" : "" + value;
|
|
520
|
+
if (hash) {
|
|
521
|
+
classname = classname ? classname + " " + hash : hash;
|
|
522
|
+
}
|
|
523
|
+
if (directives) {
|
|
524
|
+
for (var key in directives) {
|
|
525
|
+
if (directives[key]) {
|
|
526
|
+
classname = classname ? classname + " " + key : key;
|
|
527
|
+
} else if (classname.length) {
|
|
528
|
+
var len = key.length;
|
|
529
|
+
var a = 0;
|
|
530
|
+
while ((a = classname.indexOf(key, a)) >= 0) {
|
|
531
|
+
var b = a + len;
|
|
532
|
+
if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
|
|
533
|
+
classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
|
|
534
|
+
} else {
|
|
535
|
+
a = b;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return classname === "" ? null : classname;
|
|
542
|
+
}
|
|
543
|
+
function append_styles(styles, important = false) {
|
|
544
|
+
var separator = important ? " !important;" : ";";
|
|
545
|
+
var css = "";
|
|
546
|
+
for (var key in styles) {
|
|
547
|
+
var value = styles[key];
|
|
548
|
+
if (value != null && value !== "") {
|
|
549
|
+
css += " " + key + ": " + value + separator;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return css;
|
|
553
|
+
}
|
|
554
|
+
function to_css_name(name) {
|
|
555
|
+
if (name[0] !== "-" || name[1] !== "-") {
|
|
556
|
+
return name.toLowerCase();
|
|
557
|
+
}
|
|
558
|
+
return name;
|
|
559
|
+
}
|
|
560
|
+
function to_style(value, styles) {
|
|
561
|
+
if (styles) {
|
|
562
|
+
var new_style = "";
|
|
563
|
+
var normal_styles;
|
|
564
|
+
var important_styles;
|
|
565
|
+
if (Array.isArray(styles)) {
|
|
566
|
+
normal_styles = styles[0];
|
|
567
|
+
important_styles = styles[1];
|
|
568
|
+
} else {
|
|
569
|
+
normal_styles = styles;
|
|
570
|
+
}
|
|
571
|
+
if (value) {
|
|
572
|
+
value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
|
|
573
|
+
var in_str = false;
|
|
574
|
+
var in_apo = 0;
|
|
575
|
+
var in_comment = false;
|
|
576
|
+
var reserved_names = [];
|
|
577
|
+
if (normal_styles) {
|
|
578
|
+
reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
|
|
579
|
+
}
|
|
580
|
+
if (important_styles) {
|
|
581
|
+
reserved_names.push(...Object.keys(important_styles).map(to_css_name));
|
|
582
|
+
}
|
|
583
|
+
var start_index = 0;
|
|
584
|
+
var name_index = -1;
|
|
585
|
+
const len = value.length;
|
|
586
|
+
for (var i = 0; i < len; i++) {
|
|
587
|
+
var c = value[i];
|
|
588
|
+
if (in_comment) {
|
|
589
|
+
if (c === "/" && value[i - 1] === "*") {
|
|
590
|
+
in_comment = false;
|
|
591
|
+
}
|
|
592
|
+
} else if (in_str) {
|
|
593
|
+
if (in_str === c) {
|
|
594
|
+
in_str = false;
|
|
595
|
+
}
|
|
596
|
+
} else if (c === "/" && value[i + 1] === "*") {
|
|
597
|
+
in_comment = true;
|
|
598
|
+
} else if (c === '"' || c === "'") {
|
|
599
|
+
in_str = c;
|
|
600
|
+
} else if (c === "(") {
|
|
601
|
+
in_apo++;
|
|
602
|
+
} else if (c === ")") {
|
|
603
|
+
in_apo--;
|
|
604
|
+
}
|
|
605
|
+
if (!in_comment && in_str === false && in_apo === 0) {
|
|
606
|
+
if (c === ":" && name_index === -1) {
|
|
607
|
+
name_index = i;
|
|
608
|
+
} else if (c === ";" || i === len - 1) {
|
|
609
|
+
if (name_index !== -1) {
|
|
610
|
+
var name = to_css_name(value.substring(start_index, name_index).trim());
|
|
611
|
+
if (!reserved_names.includes(name)) {
|
|
612
|
+
if (c !== ";") {
|
|
613
|
+
i++;
|
|
614
|
+
}
|
|
615
|
+
var property = value.substring(start_index, i).trim();
|
|
616
|
+
new_style += " " + property + ";";
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
start_index = i + 1;
|
|
620
|
+
name_index = -1;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (normal_styles) {
|
|
626
|
+
new_style += append_styles(normal_styles);
|
|
627
|
+
}
|
|
628
|
+
if (important_styles) {
|
|
629
|
+
new_style += append_styles(important_styles, true);
|
|
630
|
+
}
|
|
631
|
+
new_style = new_style.trim();
|
|
632
|
+
return new_style === "" ? null : new_style;
|
|
633
|
+
}
|
|
634
|
+
return value == null ? null : String(value);
|
|
635
|
+
}
|
|
636
|
+
const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
|
|
637
|
+
const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
|
|
638
|
+
const EMPTY_COMMENT = `<!---->`;
|
|
639
|
+
let controller = null;
|
|
640
|
+
function abort() {
|
|
641
|
+
controller?.abort(STALE_REACTION);
|
|
642
|
+
controller = null;
|
|
643
|
+
}
|
|
644
|
+
function await_invalid() {
|
|
645
|
+
const error = new Error(`await_invalid
|
|
646
|
+
Encountered asynchronous work while rendering synchronously.
|
|
647
|
+
https://svelte.dev/e/await_invalid`);
|
|
648
|
+
error.name = "Svelte error";
|
|
649
|
+
throw error;
|
|
650
|
+
}
|
|
651
|
+
function invalid_csp() {
|
|
652
|
+
const error = new Error(`invalid_csp
|
|
653
|
+
\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
|
|
654
|
+
https://svelte.dev/e/invalid_csp`);
|
|
655
|
+
error.name = "Svelte error";
|
|
656
|
+
throw error;
|
|
657
|
+
}
|
|
658
|
+
function server_context_required() {
|
|
659
|
+
const error = new Error(`server_context_required
|
|
660
|
+
Could not resolve \`render\` context.
|
|
661
|
+
https://svelte.dev/e/server_context_required`);
|
|
662
|
+
error.name = "Svelte error";
|
|
663
|
+
throw error;
|
|
664
|
+
}
|
|
665
|
+
var ssr_context = null;
|
|
666
|
+
function set_ssr_context(v) {
|
|
667
|
+
ssr_context = v;
|
|
668
|
+
}
|
|
669
|
+
function getContext(key) {
|
|
670
|
+
const context_map = get_or_init_context_map();
|
|
671
|
+
const result = (
|
|
672
|
+
/** @type {T} */
|
|
673
|
+
context_map.get(key)
|
|
674
|
+
);
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
function setContext(key, context) {
|
|
678
|
+
get_or_init_context_map().set(key, context);
|
|
679
|
+
return context;
|
|
680
|
+
}
|
|
681
|
+
function get_or_init_context_map(name) {
|
|
682
|
+
if (ssr_context === null) {
|
|
683
|
+
lifecycle_outside_component();
|
|
684
|
+
}
|
|
685
|
+
return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
|
|
686
|
+
}
|
|
687
|
+
function push(fn) {
|
|
688
|
+
ssr_context = { p: ssr_context, c: null, r: null };
|
|
689
|
+
}
|
|
690
|
+
function pop() {
|
|
691
|
+
ssr_context = /** @type {SSRContext} */
|
|
692
|
+
ssr_context.p;
|
|
693
|
+
}
|
|
694
|
+
function get_parent_context(ssr_context2) {
|
|
695
|
+
let parent = ssr_context2.p;
|
|
696
|
+
while (parent !== null) {
|
|
697
|
+
const context_map = parent.c;
|
|
698
|
+
if (context_map !== null) {
|
|
699
|
+
return context_map;
|
|
700
|
+
}
|
|
701
|
+
parent = parent.p;
|
|
702
|
+
}
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
function unresolved_hydratable(key, stack) {
|
|
706
|
+
{
|
|
707
|
+
console.warn(`https://svelte.dev/e/unresolved_hydratable`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function get_render_context() {
|
|
711
|
+
const store = als?.getStore();
|
|
712
|
+
{
|
|
713
|
+
server_context_required();
|
|
714
|
+
}
|
|
715
|
+
return store;
|
|
716
|
+
}
|
|
717
|
+
let als = null;
|
|
718
|
+
let text_encoder;
|
|
719
|
+
let crypto;
|
|
720
|
+
async function sha256(data) {
|
|
721
|
+
text_encoder ??= new TextEncoder();
|
|
722
|
+
crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
|
|
723
|
+
// @ts-ignore - we don't install node types in the prod build
|
|
724
|
+
(await import('node:crypto')).webcrypto
|
|
725
|
+
);
|
|
726
|
+
const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
|
|
727
|
+
return base64_encode(hash_buffer);
|
|
728
|
+
}
|
|
729
|
+
function base64_encode(bytes) {
|
|
730
|
+
if (globalThis.Buffer) {
|
|
731
|
+
return globalThis.Buffer.from(bytes).toString("base64");
|
|
732
|
+
}
|
|
733
|
+
let binary = "";
|
|
734
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
735
|
+
binary += String.fromCharCode(bytes[i]);
|
|
736
|
+
}
|
|
737
|
+
return btoa(binary);
|
|
738
|
+
}
|
|
739
|
+
class Renderer {
|
|
740
|
+
/**
|
|
741
|
+
* The contents of the renderer.
|
|
742
|
+
* @type {RendererItem[]}
|
|
743
|
+
*/
|
|
744
|
+
#out = [];
|
|
745
|
+
/**
|
|
746
|
+
* Any `onDestroy` callbacks registered during execution of this renderer.
|
|
747
|
+
* @type {(() => void)[] | undefined}
|
|
748
|
+
*/
|
|
749
|
+
#on_destroy = void 0;
|
|
750
|
+
/**
|
|
751
|
+
* Whether this renderer is a component body.
|
|
752
|
+
* @type {boolean}
|
|
753
|
+
*/
|
|
754
|
+
#is_component_body = false;
|
|
755
|
+
/**
|
|
756
|
+
* The type of string content that this renderer is accumulating.
|
|
757
|
+
* @type {RendererType}
|
|
758
|
+
*/
|
|
759
|
+
type;
|
|
760
|
+
/** @type {Renderer | undefined} */
|
|
761
|
+
#parent;
|
|
762
|
+
/**
|
|
763
|
+
* Asynchronous work associated with this renderer
|
|
764
|
+
* @type {Promise<void> | undefined}
|
|
765
|
+
*/
|
|
766
|
+
promise = void 0;
|
|
767
|
+
/**
|
|
768
|
+
* State which is associated with the content tree as a whole.
|
|
769
|
+
* It will be re-exposed, uncopied, on all children.
|
|
770
|
+
* @type {SSRState}
|
|
771
|
+
* @readonly
|
|
772
|
+
*/
|
|
773
|
+
global;
|
|
774
|
+
/**
|
|
775
|
+
* State that is local to the branch it is declared in.
|
|
776
|
+
* It will be shallow-copied to all children.
|
|
777
|
+
*
|
|
778
|
+
* @type {{ select_value: string | undefined }}
|
|
779
|
+
*/
|
|
780
|
+
local;
|
|
781
|
+
/**
|
|
782
|
+
* @param {SSRState} global
|
|
783
|
+
* @param {Renderer | undefined} [parent]
|
|
784
|
+
*/
|
|
785
|
+
constructor(global, parent) {
|
|
786
|
+
this.#parent = parent;
|
|
787
|
+
this.global = global;
|
|
788
|
+
this.local = parent ? { ...parent.local } : { select_value: void 0 };
|
|
789
|
+
this.type = parent ? parent.type : "body";
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* @param {(renderer: Renderer) => void} fn
|
|
793
|
+
*/
|
|
794
|
+
head(fn) {
|
|
795
|
+
const head2 = new Renderer(this.global, this);
|
|
796
|
+
head2.type = "head";
|
|
797
|
+
this.#out.push(head2);
|
|
798
|
+
head2.child(fn);
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* @param {Array<Promise<void>>} blockers
|
|
802
|
+
* @param {(renderer: Renderer) => void} fn
|
|
803
|
+
*/
|
|
804
|
+
async_block(blockers, fn) {
|
|
805
|
+
this.#out.push(BLOCK_OPEN);
|
|
806
|
+
this.async(blockers, fn);
|
|
807
|
+
this.#out.push(BLOCK_CLOSE);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* @param {Array<Promise<void>>} blockers
|
|
811
|
+
* @param {(renderer: Renderer) => void} fn
|
|
812
|
+
*/
|
|
813
|
+
async(blockers, fn) {
|
|
814
|
+
let callback = fn;
|
|
815
|
+
if (blockers.length > 0) {
|
|
816
|
+
const context = ssr_context;
|
|
817
|
+
callback = (renderer) => {
|
|
818
|
+
return Promise.all(blockers).then(() => {
|
|
819
|
+
const previous_context = ssr_context;
|
|
820
|
+
try {
|
|
821
|
+
set_ssr_context(context);
|
|
822
|
+
return fn(renderer);
|
|
823
|
+
} finally {
|
|
824
|
+
set_ssr_context(previous_context);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
this.child(callback);
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* @param {Array<() => void>} thunks
|
|
833
|
+
*/
|
|
834
|
+
run(thunks) {
|
|
835
|
+
const context = ssr_context;
|
|
836
|
+
let promise = Promise.resolve(thunks[0]());
|
|
837
|
+
const promises = [promise];
|
|
838
|
+
for (const fn of thunks.slice(1)) {
|
|
839
|
+
promise = promise.then(() => {
|
|
840
|
+
const previous_context = ssr_context;
|
|
841
|
+
set_ssr_context(context);
|
|
842
|
+
try {
|
|
843
|
+
return fn();
|
|
844
|
+
} finally {
|
|
845
|
+
set_ssr_context(previous_context);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
promises.push(promise);
|
|
849
|
+
}
|
|
850
|
+
return promises;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Create a child renderer. The child renderer inherits the state from the parent,
|
|
854
|
+
* but has its own content.
|
|
855
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} fn
|
|
856
|
+
*/
|
|
857
|
+
child(fn) {
|
|
858
|
+
const child = new Renderer(this.global, this);
|
|
859
|
+
this.#out.push(child);
|
|
860
|
+
const parent = ssr_context;
|
|
861
|
+
set_ssr_context({
|
|
862
|
+
...ssr_context,
|
|
863
|
+
p: parent,
|
|
864
|
+
c: null,
|
|
865
|
+
r: child
|
|
866
|
+
});
|
|
867
|
+
const result = fn(child);
|
|
868
|
+
set_ssr_context(parent);
|
|
869
|
+
if (result instanceof Promise) {
|
|
870
|
+
if (child.global.mode === "sync") {
|
|
871
|
+
await_invalid();
|
|
872
|
+
}
|
|
873
|
+
result.catch(() => {
|
|
874
|
+
});
|
|
875
|
+
child.promise = result;
|
|
876
|
+
}
|
|
877
|
+
return child;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Create a component renderer. The component renderer inherits the state from the parent,
|
|
881
|
+
* but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
|
|
882
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} fn
|
|
883
|
+
* @param {Function} [component_fn]
|
|
884
|
+
* @returns {void}
|
|
885
|
+
*/
|
|
886
|
+
component(fn, component_fn) {
|
|
887
|
+
push();
|
|
888
|
+
const child = this.child(fn);
|
|
889
|
+
child.#is_component_body = true;
|
|
890
|
+
pop();
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* @param {Record<string, any>} attrs
|
|
894
|
+
* @param {(renderer: Renderer) => void} fn
|
|
895
|
+
* @param {string | undefined} [css_hash]
|
|
896
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
897
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
898
|
+
* @param {number | undefined} [flags]
|
|
899
|
+
* @param {boolean | undefined} [is_rich]
|
|
900
|
+
* @returns {void}
|
|
901
|
+
*/
|
|
902
|
+
select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
|
|
903
|
+
const { value, ...select_attrs } = attrs;
|
|
904
|
+
this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
|
|
905
|
+
this.child((renderer) => {
|
|
906
|
+
renderer.local.select_value = value;
|
|
907
|
+
fn(renderer);
|
|
908
|
+
});
|
|
909
|
+
this.push(`${is_rich ? "<!>" : ""}</select>`);
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* @param {Record<string, any>} attrs
|
|
913
|
+
* @param {string | number | boolean | ((renderer: Renderer) => void)} body
|
|
914
|
+
* @param {string | undefined} [css_hash]
|
|
915
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
916
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
917
|
+
* @param {number | undefined} [flags]
|
|
918
|
+
* @param {boolean | undefined} [is_rich]
|
|
919
|
+
*/
|
|
920
|
+
option(attrs, body, css_hash, classes, styles, flags, is_rich) {
|
|
921
|
+
this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
|
|
922
|
+
const close = (renderer, value, { head: head2, body: body2 }) => {
|
|
923
|
+
if ("value" in attrs) {
|
|
924
|
+
value = attrs.value;
|
|
925
|
+
}
|
|
926
|
+
if (value === this.local.select_value) {
|
|
927
|
+
renderer.#out.push(" selected");
|
|
928
|
+
}
|
|
929
|
+
renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
|
|
930
|
+
if (head2) {
|
|
931
|
+
renderer.head((child) => child.push(head2));
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
if (typeof body === "function") {
|
|
935
|
+
this.child((renderer) => {
|
|
936
|
+
const r2 = new Renderer(this.global, this);
|
|
937
|
+
body(r2);
|
|
938
|
+
if (this.global.mode === "async") {
|
|
939
|
+
return r2.#collect_content_async().then((content) => {
|
|
940
|
+
close(renderer, content.body.replaceAll("<!---->", ""), content);
|
|
941
|
+
});
|
|
942
|
+
} else {
|
|
943
|
+
const content = r2.#collect_content();
|
|
944
|
+
close(renderer, content.body.replaceAll("<!---->", ""), content);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
} else {
|
|
948
|
+
close(this, body, { body });
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* @param {(renderer: Renderer) => void} fn
|
|
953
|
+
*/
|
|
954
|
+
title(fn) {
|
|
955
|
+
const path = this.get_path();
|
|
956
|
+
const close = (head2) => {
|
|
957
|
+
this.global.set_title(head2, path);
|
|
958
|
+
};
|
|
959
|
+
this.child((renderer) => {
|
|
960
|
+
const r2 = new Renderer(renderer.global, renderer);
|
|
961
|
+
fn(r2);
|
|
962
|
+
if (renderer.global.mode === "async") {
|
|
963
|
+
return r2.#collect_content_async().then((content) => {
|
|
964
|
+
close(content.head);
|
|
965
|
+
});
|
|
966
|
+
} else {
|
|
967
|
+
const content = r2.#collect_content();
|
|
968
|
+
close(content.head);
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* @param {string | (() => Promise<string>)} content
|
|
974
|
+
*/
|
|
975
|
+
push(content) {
|
|
976
|
+
if (typeof content === "function") {
|
|
977
|
+
this.child(async (renderer) => renderer.push(await content()));
|
|
978
|
+
} else {
|
|
979
|
+
this.#out.push(content);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* @param {() => void} fn
|
|
984
|
+
*/
|
|
985
|
+
on_destroy(fn) {
|
|
986
|
+
(this.#on_destroy ??= []).push(fn);
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* @returns {number[]}
|
|
990
|
+
*/
|
|
991
|
+
get_path() {
|
|
992
|
+
return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* @deprecated this is needed for legacy component bindings
|
|
996
|
+
*/
|
|
997
|
+
copy() {
|
|
998
|
+
const copy = new Renderer(this.global, this.#parent);
|
|
999
|
+
copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
|
|
1000
|
+
copy.promise = this.promise;
|
|
1001
|
+
return copy;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* @param {Renderer} other
|
|
1005
|
+
* @deprecated this is needed for legacy component bindings
|
|
1006
|
+
*/
|
|
1007
|
+
subsume(other) {
|
|
1008
|
+
if (this.global.mode !== other.global.mode) {
|
|
1009
|
+
throw new Error(
|
|
1010
|
+
"invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
this.local = other.local;
|
|
1014
|
+
this.#out = other.#out.map((item) => {
|
|
1015
|
+
if (item instanceof Renderer) {
|
|
1016
|
+
item.subsume(item);
|
|
1017
|
+
}
|
|
1018
|
+
return item;
|
|
1019
|
+
});
|
|
1020
|
+
this.promise = other.promise;
|
|
1021
|
+
this.type = other.type;
|
|
1022
|
+
}
|
|
1023
|
+
get length() {
|
|
1024
|
+
return this.#out.length;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Only available on the server and when compiling with the `server` option.
|
|
1028
|
+
* Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
|
|
1029
|
+
* @template {Record<string, any>} Props
|
|
1030
|
+
* @param {Component<Props>} component
|
|
1031
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
|
|
1032
|
+
* @returns {RenderOutput}
|
|
1033
|
+
*/
|
|
1034
|
+
static render(component, options = {}) {
|
|
1035
|
+
let sync;
|
|
1036
|
+
const result = (
|
|
1037
|
+
/** @type {RenderOutput} */
|
|
1038
|
+
{}
|
|
1039
|
+
);
|
|
1040
|
+
Object.defineProperties(result, {
|
|
1041
|
+
html: {
|
|
1042
|
+
get: () => {
|
|
1043
|
+
return (sync ??= Renderer.#render(component, options)).body;
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
head: {
|
|
1047
|
+
get: () => {
|
|
1048
|
+
return (sync ??= Renderer.#render(component, options)).head;
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
body: {
|
|
1052
|
+
get: () => {
|
|
1053
|
+
return (sync ??= Renderer.#render(component, options)).body;
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
hashes: {
|
|
1057
|
+
value: {
|
|
1058
|
+
script: ""
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
then: {
|
|
1062
|
+
value: (
|
|
1063
|
+
/**
|
|
1064
|
+
* this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
|
|
1065
|
+
*
|
|
1066
|
+
* @template TResult1
|
|
1067
|
+
* @template [TResult2=never]
|
|
1068
|
+
* @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
|
|
1069
|
+
* @param { (reason: unknown) => TResult2 } onrejected
|
|
1070
|
+
*/
|
|
1071
|
+
(onfulfilled, onrejected) => {
|
|
1072
|
+
{
|
|
1073
|
+
const result2 = sync ??= Renderer.#render(component, options);
|
|
1074
|
+
const user_result = onfulfilled({
|
|
1075
|
+
head: result2.head,
|
|
1076
|
+
body: result2.body,
|
|
1077
|
+
html: result2.body,
|
|
1078
|
+
hashes: { script: [] }
|
|
1079
|
+
});
|
|
1080
|
+
return Promise.resolve(user_result);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
)
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
return result;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
|
|
1090
|
+
* after awaiting `collect_async`.
|
|
1091
|
+
*
|
|
1092
|
+
* Child renderers are "porous" and don't affect execution order, but component body renderers
|
|
1093
|
+
* create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
|
|
1094
|
+
* @returns {Iterable<() => void>}
|
|
1095
|
+
*/
|
|
1096
|
+
*#collect_on_destroy() {
|
|
1097
|
+
for (const component of this.#traverse_components()) {
|
|
1098
|
+
yield* component.#collect_ondestroy();
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
|
|
1103
|
+
* @returns {Iterable<Renderer>}
|
|
1104
|
+
*/
|
|
1105
|
+
*#traverse_components() {
|
|
1106
|
+
for (const child of this.#out) {
|
|
1107
|
+
if (typeof child !== "string") {
|
|
1108
|
+
yield* child.#traverse_components();
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
if (this.#is_component_body) {
|
|
1112
|
+
yield this;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* @returns {Iterable<() => void>}
|
|
1117
|
+
*/
|
|
1118
|
+
*#collect_ondestroy() {
|
|
1119
|
+
if (this.#on_destroy) {
|
|
1120
|
+
for (const fn of this.#on_destroy) {
|
|
1121
|
+
yield fn;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
for (const child of this.#out) {
|
|
1125
|
+
if (child instanceof Renderer && !child.#is_component_body) {
|
|
1126
|
+
yield* child.#collect_ondestroy();
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Render a component. Throws if any of the children are performing asynchronous work.
|
|
1132
|
+
*
|
|
1133
|
+
* @template {Record<string, any>} Props
|
|
1134
|
+
* @param {Component<Props>} component
|
|
1135
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
|
|
1136
|
+
* @returns {AccumulatedContent}
|
|
1137
|
+
*/
|
|
1138
|
+
static #render(component, options) {
|
|
1139
|
+
var previous_context = ssr_context;
|
|
1140
|
+
try {
|
|
1141
|
+
const renderer = Renderer.#open_render("sync", component, options);
|
|
1142
|
+
const content = renderer.#collect_content();
|
|
1143
|
+
return Renderer.#close_render(content, renderer);
|
|
1144
|
+
} finally {
|
|
1145
|
+
abort();
|
|
1146
|
+
set_ssr_context(previous_context);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Render a component.
|
|
1151
|
+
*
|
|
1152
|
+
* @template {Record<string, any>} Props
|
|
1153
|
+
* @param {Component<Props>} component
|
|
1154
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
|
|
1155
|
+
* @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
|
|
1156
|
+
*/
|
|
1157
|
+
static async #render_async(component, options) {
|
|
1158
|
+
const previous_context = ssr_context;
|
|
1159
|
+
try {
|
|
1160
|
+
const renderer = Renderer.#open_render("async", component, options);
|
|
1161
|
+
const content = await renderer.#collect_content_async();
|
|
1162
|
+
const hydratables = await renderer.#collect_hydratables();
|
|
1163
|
+
if (hydratables !== null) {
|
|
1164
|
+
content.head = hydratables + content.head;
|
|
1165
|
+
}
|
|
1166
|
+
return Renderer.#close_render(content, renderer);
|
|
1167
|
+
} finally {
|
|
1168
|
+
set_ssr_context(previous_context);
|
|
1169
|
+
abort();
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
|
|
1174
|
+
* @param {AccumulatedContent} content
|
|
1175
|
+
* @returns {AccumulatedContent}
|
|
1176
|
+
*/
|
|
1177
|
+
#collect_content(content = { head: "", body: "" }) {
|
|
1178
|
+
for (const item of this.#out) {
|
|
1179
|
+
if (typeof item === "string") {
|
|
1180
|
+
content[this.type] += item;
|
|
1181
|
+
} else if (item instanceof Renderer) {
|
|
1182
|
+
item.#collect_content(content);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return content;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Collect all of the code from the `out` array and return it as a string.
|
|
1189
|
+
* @param {AccumulatedContent} content
|
|
1190
|
+
* @returns {Promise<AccumulatedContent>}
|
|
1191
|
+
*/
|
|
1192
|
+
async #collect_content_async(content = { head: "", body: "" }) {
|
|
1193
|
+
await this.promise;
|
|
1194
|
+
for (const item of this.#out) {
|
|
1195
|
+
if (typeof item === "string") {
|
|
1196
|
+
content[this.type] += item;
|
|
1197
|
+
} else if (item instanceof Renderer) {
|
|
1198
|
+
await item.#collect_content_async(content);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
return content;
|
|
1202
|
+
}
|
|
1203
|
+
async #collect_hydratables() {
|
|
1204
|
+
const ctx = get_render_context().hydratable;
|
|
1205
|
+
for (const [_, key] of ctx.unresolved_promises) {
|
|
1206
|
+
unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
|
|
1207
|
+
}
|
|
1208
|
+
for (const comparison of ctx.comparisons) {
|
|
1209
|
+
await comparison;
|
|
1210
|
+
}
|
|
1211
|
+
return await this.#hydratable_block(ctx);
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* @template {Record<string, any>} Props
|
|
1215
|
+
* @param {'sync' | 'async'} mode
|
|
1216
|
+
* @param {import('svelte').Component<Props>} component
|
|
1217
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
|
|
1218
|
+
* @returns {Renderer}
|
|
1219
|
+
*/
|
|
1220
|
+
static #open_render(mode, component, options) {
|
|
1221
|
+
const renderer = new Renderer(
|
|
1222
|
+
new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp)
|
|
1223
|
+
);
|
|
1224
|
+
renderer.push(BLOCK_OPEN);
|
|
1225
|
+
if (options.context) {
|
|
1226
|
+
push();
|
|
1227
|
+
ssr_context.c = options.context;
|
|
1228
|
+
ssr_context.r = renderer;
|
|
1229
|
+
}
|
|
1230
|
+
component(renderer, options.props ?? {});
|
|
1231
|
+
if (options.context) {
|
|
1232
|
+
pop();
|
|
1233
|
+
}
|
|
1234
|
+
renderer.push(BLOCK_CLOSE);
|
|
1235
|
+
return renderer;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* @param {AccumulatedContent} content
|
|
1239
|
+
* @param {Renderer} renderer
|
|
1240
|
+
* @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
|
|
1241
|
+
*/
|
|
1242
|
+
static #close_render(content, renderer) {
|
|
1243
|
+
for (const cleanup of renderer.#collect_on_destroy()) {
|
|
1244
|
+
cleanup();
|
|
1245
|
+
}
|
|
1246
|
+
let head2 = content.head + renderer.global.get_title();
|
|
1247
|
+
let body = content.body;
|
|
1248
|
+
for (const { hash, code } of renderer.global.css) {
|
|
1249
|
+
head2 += `<style id="${hash}">${code}</style>`;
|
|
1250
|
+
}
|
|
1251
|
+
return {
|
|
1252
|
+
head: head2,
|
|
1253
|
+
body,
|
|
1254
|
+
hashes: {
|
|
1255
|
+
script: renderer.global.csp.script_hashes
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* @param {HydratableContext} ctx
|
|
1261
|
+
*/
|
|
1262
|
+
async #hydratable_block(ctx) {
|
|
1263
|
+
if (ctx.lookup.size === 0) {
|
|
1264
|
+
return null;
|
|
1265
|
+
}
|
|
1266
|
+
let entries = [];
|
|
1267
|
+
let has_promises = false;
|
|
1268
|
+
for (const [k, v] of ctx.lookup) {
|
|
1269
|
+
if (v.promises) {
|
|
1270
|
+
has_promises = true;
|
|
1271
|
+
for (const p of v.promises) await p;
|
|
1272
|
+
}
|
|
1273
|
+
entries.push(`[${uneval(k)},${v.serialized}]`);
|
|
1274
|
+
}
|
|
1275
|
+
let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
|
|
1276
|
+
if (has_promises) {
|
|
1277
|
+
prelude = `const r = (v) => Promise.resolve(v);
|
|
1278
|
+
${prelude}`;
|
|
1279
|
+
}
|
|
1280
|
+
const body = `
|
|
1281
|
+
{
|
|
1282
|
+
${prelude}
|
|
1283
|
+
|
|
1284
|
+
for (const [k, v] of [
|
|
1285
|
+
${entries.join(",\n ")}
|
|
1286
|
+
]) {
|
|
1287
|
+
h.set(k, v);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
`;
|
|
1291
|
+
let csp_attr = "";
|
|
1292
|
+
if (this.global.csp.nonce) {
|
|
1293
|
+
csp_attr = ` nonce="${this.global.csp.nonce}"`;
|
|
1294
|
+
} else if (this.global.csp.hash) {
|
|
1295
|
+
const hash = await sha256(body);
|
|
1296
|
+
this.global.csp.script_hashes.push(`sha256-${hash}`);
|
|
1297
|
+
}
|
|
1298
|
+
return `
|
|
1299
|
+
<script${csp_attr}>${body}<\/script>`;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
class SSRState {
|
|
1303
|
+
/** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
|
|
1304
|
+
csp;
|
|
1305
|
+
/** @readonly @type {'sync' | 'async'} */
|
|
1306
|
+
mode;
|
|
1307
|
+
/** @readonly @type {() => string} */
|
|
1308
|
+
uid;
|
|
1309
|
+
/** @readonly @type {Set<{ hash: string; code: string }>} */
|
|
1310
|
+
css = /* @__PURE__ */ new Set();
|
|
1311
|
+
/** @type {{ path: number[], value: string }} */
|
|
1312
|
+
#title = { path: [], value: "" };
|
|
1313
|
+
/**
|
|
1314
|
+
* @param {'sync' | 'async'} mode
|
|
1315
|
+
* @param {string} id_prefix
|
|
1316
|
+
* @param {Csp} csp
|
|
1317
|
+
*/
|
|
1318
|
+
constructor(mode, id_prefix = "", csp = { hash: false }) {
|
|
1319
|
+
this.mode = mode;
|
|
1320
|
+
this.csp = { ...csp, script_hashes: [] };
|
|
1321
|
+
let uid = 1;
|
|
1322
|
+
this.uid = () => `${id_prefix}s${uid++}`;
|
|
1323
|
+
}
|
|
1324
|
+
get_title() {
|
|
1325
|
+
return this.#title.value;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Performs a depth-first (lexicographic) comparison using the path. Rejects sets
|
|
1329
|
+
* from earlier than or equal to the current value.
|
|
1330
|
+
* @param {string} value
|
|
1331
|
+
* @param {number[]} path
|
|
1332
|
+
*/
|
|
1333
|
+
set_title(value, path) {
|
|
1334
|
+
const current = this.#title.path;
|
|
1335
|
+
let i = 0;
|
|
1336
|
+
let l = Math.min(path.length, current.length);
|
|
1337
|
+
while (i < l && path[i] === current[i]) i += 1;
|
|
1338
|
+
if (path[i] === void 0) return;
|
|
1339
|
+
if (current[i] === void 0 || path[i] > current[i]) {
|
|
1340
|
+
this.#title.path = path;
|
|
1341
|
+
this.#title.value = value;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
|
|
1346
|
+
function render(component, options = {}) {
|
|
1347
|
+
if (options.csp?.hash && options.csp.nonce) {
|
|
1348
|
+
invalid_csp();
|
|
1349
|
+
}
|
|
1350
|
+
return Renderer.render(
|
|
1351
|
+
/** @type {Component<Props>} */
|
|
1352
|
+
component,
|
|
1353
|
+
options
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
function head(hash, renderer, fn) {
|
|
1357
|
+
renderer.head((renderer2) => {
|
|
1358
|
+
renderer2.push(`<!--${hash}-->`);
|
|
1359
|
+
renderer2.child(fn);
|
|
1360
|
+
renderer2.push(EMPTY_COMMENT);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
function attributes(attrs, css_hash, classes, styles, flags = 0) {
|
|
1364
|
+
if (styles) {
|
|
1365
|
+
attrs.style = to_style(attrs.style, styles);
|
|
1366
|
+
}
|
|
1367
|
+
if (attrs.class) {
|
|
1368
|
+
attrs.class = clsx(attrs.class);
|
|
1369
|
+
}
|
|
1370
|
+
if (css_hash || classes) {
|
|
1371
|
+
attrs.class = to_class(attrs.class, css_hash, classes);
|
|
1372
|
+
}
|
|
1373
|
+
let attr_str = "";
|
|
1374
|
+
let name;
|
|
1375
|
+
const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
|
|
1376
|
+
const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
|
|
1377
|
+
const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
|
|
1378
|
+
for (name in attrs) {
|
|
1379
|
+
if (typeof attrs[name] === "function") continue;
|
|
1380
|
+
if (name[0] === "$" && name[1] === "$") continue;
|
|
1381
|
+
if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
|
|
1382
|
+
var value = attrs[name];
|
|
1383
|
+
if (lowercase) {
|
|
1384
|
+
name = name.toLowerCase();
|
|
1385
|
+
}
|
|
1386
|
+
if (is_input) {
|
|
1387
|
+
if (name === "defaultvalue" || name === "defaultchecked") {
|
|
1388
|
+
name = name === "defaultvalue" ? "value" : "checked";
|
|
1389
|
+
if (attrs[name]) continue;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
attr_str += attr(name, value, is_html && is_boolean_attribute(name));
|
|
1393
|
+
}
|
|
1394
|
+
return attr_str;
|
|
1395
|
+
}
|
|
1396
|
+
function stringify(value) {
|
|
1397
|
+
return typeof value === "string" ? value : value == null ? "" : value + "";
|
|
1398
|
+
}
|
|
1399
|
+
function attr_class(value, hash, directives) {
|
|
1400
|
+
var result = to_class(value, hash, directives);
|
|
1401
|
+
return result ? ` class="${escape_html(result, true)}"` : "";
|
|
1402
|
+
}
|
|
1403
|
+
function ensure_array_like(array_like_or_iterator) {
|
|
1404
|
+
if (array_like_or_iterator) {
|
|
1405
|
+
return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
|
1406
|
+
}
|
|
1407
|
+
return [];
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
export { ASYNC as A, BLOCK_EFFECT as B, CONNECTED as C, DevalueError as D, ERROR_VALUE as E, setContext as F, HYDRATION_END as G, HYDRATION_START as H, INERT as I, HYDRATION_START_ELSE as J, USER_EFFECT as K, LEGACY_PROPS as L, MAYBE_DIRTY as M, uneval as N, head as O, attr as P, escape_html as Q, ROOT_EFFECT as R, STATE_SYMBOL as S, attr_class as T, UNINITIALIZED as U, stringify as V, WAS_MARKED as W, getContext as X, ensure_array_like as Y, is_plain_object as a, stringify_string as b, COMMENT_NODE as c, HYDRATION_ERROR as d, enumerable_symbols as e, DERIVED as f, get_type as g, DIRTY as h, is_primitive as i, CLEAN as j, EFFECT as k, BRANCH_EFFECT as l, RENDER_EFFECT as m, MANAGED_EFFECT as n, DESTROYED as o, HEAD_EFFECT as p, REACTION_IS_UPDATING as q, render as r, stringify_key as s, EFFECT_RAN as t, EFFECT_PRESERVED as u, EFFECT_TRANSPARENT as v, BOUNDARY_EFFECT as w, EAGER_EFFECT as x, STALE_REACTION as y, is_passive_event as z };
|
|
1411
|
+
//# sourceMappingURL=index-Ch5Bqlgz.js.map
|