@celsoft/coordinator 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +107 -0
- package/THIRD_PARTY_NOTICES.md +2005 -0
- package/agents/console.md +20 -0
- package/agents/free.md +110 -0
- package/build/0-JP6XL6LB.js +17 -0
- package/build/1-A52YZWNS.js +17 -0
- package/build/2-CLH2NM6F.js +32 -0
- package/build/3-4N467IB6.js +45 -0
- package/build/4-WL5H4LUW.js +29 -0
- package/build/_layout.svelte-KPUSX7LQ.js +27 -0
- package/build/_page.svelte-22H56UR6.js +7972 -0
- package/build/_page.svelte-CVWUNRQC.js +135 -0
- package/build/_page.svelte-LTZXBHMT.js +57 -0
- package/build/_server.ts-3KVBYN6P.js +20 -0
- package/build/_server.ts-3POPKVEM.js +47 -0
- package/build/_server.ts-5735T2V5.js +31 -0
- package/build/_server.ts-5VXGNWV2.js +38 -0
- package/build/_server.ts-645KP7WP.js +42 -0
- package/build/_server.ts-A3AA24Z2.js +28 -0
- package/build/_server.ts-CITUOEM6.js +58 -0
- package/build/_server.ts-I7HMTPOA.js +25 -0
- package/build/_server.ts-M5BQ4LLX.js +30 -0
- package/build/_server.ts-OB4O27HF.js +683 -0
- package/build/_server.ts-OJT7HE7M.js +15 -0
- package/build/_server.ts-OYGWVLZM.js +12 -0
- package/build/_server.ts-T75UVMQP.js +38 -0
- package/build/_server.ts-WYZYNHUZ.js +28 -0
- package/build/_server.ts-Z26EB47B.js +486 -0
- package/build/chunk-4CIG53L5.js +33 -0
- package/build/chunk-BJTJS3XY.js +338 -0
- package/build/chunk-F2CNWJZM.js +14 -0
- package/build/chunk-HGYE3UTU.js +416 -0
- package/build/chunk-KAYW2W7H.js +1311 -0
- package/build/chunk-LFP3UPCM.js +10 -0
- package/build/chunk-M44JEFEH.js +62 -0
- package/build/chunk-MC5AGLMY.js +39 -0
- package/build/chunk-NCZ77J5E.js +19798 -0
- package/build/chunk-NVNLDPUJ.js +2122 -0
- package/build/chunk-PDCON4KS.js +494 -0
- package/build/chunk-Q4OQNY5M.js +25 -0
- package/build/chunk-QCUOR2U5.js +75 -0
- package/build/chunk-R6RYZZWA.js +46 -0
- package/build/chunk-SOJTASZC.js +51 -0
- package/build/chunk-SU26PJVX.js +410 -0
- package/build/chunk-U5BSBG4R.js +506 -0
- package/build/chunk-UEKOZGRO.js +37 -0
- package/build/chunk-W6EFUWJ2.js +9 -0
- package/build/chunk-WOPREK6Q.js +117 -0
- package/build/chunk-WWJ3F4QS.js +127 -0
- package/build/chunk-ZGZJEEE3.js +1091 -0
- package/build/client/_app/immutable/assets/0.BGa5ZNDM.css +1 -0
- package/build/client/_app/immutable/chunks/BUrrLYDt.js +2 -0
- package/build/client/_app/immutable/chunks/BgFr_EyZ.js +4 -0
- package/build/client/_app/immutable/chunks/Bjy-W4x2.js +82 -0
- package/build/client/_app/immutable/chunks/C8qZab0y.js +56 -0
- package/build/client/_app/immutable/chunks/C90fLsA5.js +4 -0
- package/build/client/_app/immutable/chunks/CRzLMJPS.js +1 -0
- package/build/client/_app/immutable/chunks/DLT1iIlz.js +2 -0
- package/build/client/_app/immutable/chunks/pIrVVOVY.js +2 -0
- package/build/client/_app/immutable/entry/app.0DERehLW.js +3 -0
- package/build/client/_app/immutable/entry/payload.DSmR2FwN.js +2 -0
- package/build/client/_app/immutable/entry/start.B7srFiqh.js +3 -0
- package/build/client/_app/immutable/nodes/0.aD9vJoxR.js +2 -0
- package/build/client/_app/immutable/nodes/1.Br4FL91i.js +2 -0
- package/build/client/_app/immutable/nodes/2.vl6OYfu3.js +8 -0
- package/build/client/_app/immutable/nodes/3.VYqJOLAF.js +2 -0
- package/build/client/_app/immutable/nodes/4.jF9UVlFN.js +2 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/apple-touch-icon.png +0 -0
- package/build/client/favicon.ico +0 -0
- package/build/client/favicon.svg +48 -0
- package/build/client/icon-192.png +0 -0
- package/build/client/icon-512.png +0 -0
- package/build/client/icon-maskable-512.png +0 -0
- package/build/client/icon.svg +44 -0
- package/build/client/manifest.webmanifest +15 -0
- package/build/error.svelte-JXZDY65F.js +51 -0
- package/build/handler.js +716 -0
- package/build/hooks.server-34IMHRKC.js +43 -0
- package/build/instance-NP3FJIWW.js +2967 -0
- package/client/client.mjs +28 -0
- package/client/hooks.mjs +7 -0
- package/client/register.mjs +5 -0
- package/dist/cli.js +62826 -0
- package/dist/port.js +36691 -0
- package/package.json +20 -1
- package/skills/agents/.claude-plugin/plugin.json +5 -0
- package/skills/agents/hooks/hooks.json +1 -0
- package/skills/agents/hooks/register.ts +57 -0
- package/skills/agents/skills/bus-work/SKILL.md +66 -0
- package/skills/agents/skills/plan/SKILL.md +98 -0
- package/skills/console/.claude-plugin/plugin.json +5 -0
- package/skills/console/hooks/hooks.json +1 -0
- package/skills/console/hooks/register.ts +10 -0
- package/skills/console/skills/bus/SKILL.md +61 -0
- package/skills/default/.claude-plugin/plugin.json +5 -0
- package/skills/default/skills/git-workflow/SKILL.md +294 -0
- package/skills/default/skills/git-workflow/mise-tasks/_lib.sh +107 -0
- package/skills/default/skills/git-workflow/mise-tasks/clone +36 -0
- package/skills/default/skills/git-workflow/mise-tasks/repo-list +8 -0
- package/skills/default/skills/git-workflow/mise-tasks/unpushed +26 -0
- package/skills/default/skills/git-workflow/mise-tasks/worktree-add +60 -0
- package/skills/default/skills/github/SKILL.md +208 -0
- package/skills/default/skills/github/scripts/gh-org +196 -0
- package/skills/default/skills/plan-page/SKILL.md +300 -0
- package/skills/default/skills/plan-page/assets/index.html +854 -0
- package/skills/default/skills/plan-page/scripts/inline +46 -0
- package/skills/default/skills/plan-page/scripts/stage +26 -0
- package/skills/default/skills/secrets/SKILL.md +134 -0
- package/skills/default/skills/secrets/scripts/secrets-check +87 -0
- package/skills/default/skills/writing-style/SKILL.md +45 -0
- package/skills/extra/.claude-plugin/plugin.json +5 -0
- package/skills/extra/skills/artifacts/SKILL.md +52 -0
- package/skills/extra/skills/github-actions/SKILL.md +78 -0
- package/skills/extra/skills/github-actions/scan +32 -0
- package/skills/extra/skills/markdown-review/SKILL.md +70 -0
- package/skills/extra/skills/markdown-review/assets/index.html +201 -0
- package/skills/extra/skills/markdown-review/scripts/stage +36 -0
- package/skills/extra/skills/mise-usage/SKILL.md +155 -0
- package/skills/extra/skills/plugin-authoring/SKILL.md +317 -0
- package/skills/extra/skills/project-conventions/SKILL.md +64 -0
- package/skills/extra/skills/questions/SKILL.md +156 -0
- package/skills/extra/skills/questions/assets/index.html +376 -0
- package/skills/extra/skills/questions/scripts/stage +26 -0
- package/skills/extra/skills/serve/SKILL.md +165 -0
- package/skills/extra/skills/serve/scripts/serve +268 -0
- package/skills/extra/skills/serve/scripts/server.py +345 -0
- package/skills/extra/skills/skill-dependencies/SKILL.md +65 -0
- package/skills/extra/skills/skill-maintenance/SKILL.md +101 -0
- package/skills/extra/skills/ticketing/SKILL.md +125 -0
|
@@ -0,0 +1,1311 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
uneval
|
|
4
|
+
} from "./chunk-U5BSBG4R.js";
|
|
5
|
+
|
|
6
|
+
// build/server/chunks/server2.js
|
|
7
|
+
var UNINITIALIZED = Symbol("uninitialized");
|
|
8
|
+
var ATTR_REGEX = /[&"<]/g;
|
|
9
|
+
var CONTENT_REGEX = /[&<]/g;
|
|
10
|
+
function escape_html(value, is_attr) {
|
|
11
|
+
const str = String(value ?? "");
|
|
12
|
+
const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
|
|
13
|
+
pattern.lastIndex = 0;
|
|
14
|
+
let escaped = "";
|
|
15
|
+
let last = 0;
|
|
16
|
+
while (pattern.test(str)) {
|
|
17
|
+
const i = pattern.lastIndex - 1;
|
|
18
|
+
const ch = str[i];
|
|
19
|
+
escaped += str.substring(last, i) + (ch === "&" ? "&" : ch === '"' ? """ : "<");
|
|
20
|
+
last = i + 1;
|
|
21
|
+
}
|
|
22
|
+
return escaped + str.substring(last);
|
|
23
|
+
}
|
|
24
|
+
function r(e) {
|
|
25
|
+
var t, f, n = "";
|
|
26
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
27
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
28
|
+
var o = e.length;
|
|
29
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
30
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
function clsx$1() {
|
|
34
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
35
|
+
return n;
|
|
36
|
+
}
|
|
37
|
+
var is_array = Array.isArray;
|
|
38
|
+
Array.prototype.indexOf;
|
|
39
|
+
Array.prototype.includes;
|
|
40
|
+
Array.from;
|
|
41
|
+
Array.prototype;
|
|
42
|
+
var has_own_property = Object.prototype.hasOwnProperty;
|
|
43
|
+
var noop = () => {
|
|
44
|
+
};
|
|
45
|
+
function run(fn) {
|
|
46
|
+
return fn();
|
|
47
|
+
}
|
|
48
|
+
function deferred() {
|
|
49
|
+
var resolve;
|
|
50
|
+
var reject;
|
|
51
|
+
return {
|
|
52
|
+
promise: new Promise((res, rej) => {
|
|
53
|
+
resolve = res;
|
|
54
|
+
reject = rej;
|
|
55
|
+
}),
|
|
56
|
+
resolve,
|
|
57
|
+
reject
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function fallback(value, fallback2, lazy = false) {
|
|
61
|
+
return value === void 0 ? lazy ? fallback2() : fallback2 : value;
|
|
62
|
+
}
|
|
63
|
+
function to_array(value, n) {
|
|
64
|
+
if (Array.isArray(value)) return value;
|
|
65
|
+
if (n === void 0 || !(Symbol.iterator in value)) return Array.from(value);
|
|
66
|
+
const array = [];
|
|
67
|
+
for (const element2 of value) {
|
|
68
|
+
array.push(element2);
|
|
69
|
+
if (array.length === n) break;
|
|
70
|
+
}
|
|
71
|
+
return array;
|
|
72
|
+
}
|
|
73
|
+
var replacements = { translate: /* @__PURE__ */ new Map([[true, "yes"], [false, "no"]]) };
|
|
74
|
+
function attr(name, value, is_boolean = false) {
|
|
75
|
+
if (name === "hidden" && value !== "until-found") is_boolean = true;
|
|
76
|
+
if (value == null || is_boolean && !value && value !== "") return "";
|
|
77
|
+
const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
|
|
78
|
+
return ` ${name}${is_boolean ? `=""` : `="${escape_html(normalized, true)}"`}`;
|
|
79
|
+
}
|
|
80
|
+
function clsx(value) {
|
|
81
|
+
if (typeof value === "object") return clsx$1(value);
|
|
82
|
+
else return value ?? "";
|
|
83
|
+
}
|
|
84
|
+
var whitespace = [..." \n\r\f\xA0\v\uFEFF"];
|
|
85
|
+
function to_class(value, hash, directives) {
|
|
86
|
+
var classname = value == null ? "" : "" + value;
|
|
87
|
+
if (hash) classname = classname ? classname + " " + hash : hash;
|
|
88
|
+
if (directives) {
|
|
89
|
+
for (var key of Object.keys(directives)) if (directives[key]) classname = classname ? classname + " " + key : key;
|
|
90
|
+
else if (classname.length) {
|
|
91
|
+
var len = key.length;
|
|
92
|
+
var a = 0;
|
|
93
|
+
while ((a = classname.indexOf(key, a)) >= 0) {
|
|
94
|
+
var b = a + len;
|
|
95
|
+
if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
|
|
96
|
+
else a = b;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return classname === "" ? null : classname;
|
|
101
|
+
}
|
|
102
|
+
function append_styles(styles, important = false) {
|
|
103
|
+
var separator = important ? " !important;" : ";";
|
|
104
|
+
var css = "";
|
|
105
|
+
for (var key of Object.keys(styles)) {
|
|
106
|
+
var value = styles[key];
|
|
107
|
+
if (value != null && value !== "") css += " " + key + ": " + value + separator;
|
|
108
|
+
}
|
|
109
|
+
return css;
|
|
110
|
+
}
|
|
111
|
+
function to_css_name(name) {
|
|
112
|
+
if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
|
|
113
|
+
return name;
|
|
114
|
+
}
|
|
115
|
+
function to_style(value, styles) {
|
|
116
|
+
if (styles) {
|
|
117
|
+
var new_style = "";
|
|
118
|
+
var normal_styles;
|
|
119
|
+
var important_styles;
|
|
120
|
+
if (Array.isArray(styles)) {
|
|
121
|
+
normal_styles = styles[0];
|
|
122
|
+
important_styles = styles[1];
|
|
123
|
+
} else normal_styles = styles;
|
|
124
|
+
if (value) {
|
|
125
|
+
value = String(value).replaceAll(/\/\*.*?\*\//g, "").trim();
|
|
126
|
+
var in_str = false;
|
|
127
|
+
var in_apo = 0;
|
|
128
|
+
var in_comment = false;
|
|
129
|
+
var reserved_names = [];
|
|
130
|
+
if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
|
|
131
|
+
if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
|
|
132
|
+
var start_index = 0;
|
|
133
|
+
var name_index = -1;
|
|
134
|
+
const len = value.length;
|
|
135
|
+
for (var i = 0; i < len; i++) {
|
|
136
|
+
var c = value[i];
|
|
137
|
+
if (in_comment) {
|
|
138
|
+
if (c === "/" && value[i - 1] === "*") in_comment = false;
|
|
139
|
+
} else if (in_str) {
|
|
140
|
+
if (in_str === c) in_str = false;
|
|
141
|
+
} else if (c === "/" && value[i + 1] === "*") in_comment = true;
|
|
142
|
+
else if (c === '"' || c === "'") in_str = c;
|
|
143
|
+
else if (c === "(") in_apo++;
|
|
144
|
+
else if (c === ")") in_apo--;
|
|
145
|
+
if (!in_comment && in_str === false && in_apo === 0) {
|
|
146
|
+
if (c === ":" && name_index === -1) name_index = i;
|
|
147
|
+
else if (c === ";" || i === len - 1) {
|
|
148
|
+
if (name_index !== -1) {
|
|
149
|
+
var name = to_css_name(value.substring(start_index, name_index).trim());
|
|
150
|
+
if (!reserved_names.includes(name)) {
|
|
151
|
+
if (c !== ";") i++;
|
|
152
|
+
var property = value.substring(start_index, i).trim();
|
|
153
|
+
new_style += " " + property + ";";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
start_index = i + 1;
|
|
157
|
+
name_index = -1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (normal_styles) new_style += append_styles(normal_styles);
|
|
163
|
+
if (important_styles) new_style += append_styles(important_styles, true);
|
|
164
|
+
new_style = new_style.trim();
|
|
165
|
+
return new_style === "" ? null : new_style;
|
|
166
|
+
}
|
|
167
|
+
return value == null ? null : String(value);
|
|
168
|
+
}
|
|
169
|
+
var STALE_REACTION = new class StaleReactionError extends Error {
|
|
170
|
+
name = "StaleReactionError";
|
|
171
|
+
message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
|
|
172
|
+
}();
|
|
173
|
+
globalThis.document?.contentType;
|
|
174
|
+
function lifecycle_outside_component(name) {
|
|
175
|
+
throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
|
|
176
|
+
}
|
|
177
|
+
function set_context_after_init() {
|
|
178
|
+
throw new Error(`https://svelte.dev/e/set_context_after_init`);
|
|
179
|
+
}
|
|
180
|
+
var async_mode_flag = false;
|
|
181
|
+
function get_parent_context(context2) {
|
|
182
|
+
let parent = context2.p;
|
|
183
|
+
while (parent !== null && parent.c === null) parent = parent.p;
|
|
184
|
+
return parent?.c ?? null;
|
|
185
|
+
}
|
|
186
|
+
function get_or_init_context_map(context2, name) {
|
|
187
|
+
if (context2 === null) lifecycle_outside_component(name);
|
|
188
|
+
return context2.c ??= new Map(get_parent_context(context2) || void 0);
|
|
189
|
+
}
|
|
190
|
+
var BLOCK_OPEN = `<!--[-->`;
|
|
191
|
+
var BLOCK_CLOSE = `<!--]-->`;
|
|
192
|
+
var EMPTY_COMMENT = `<!---->`;
|
|
193
|
+
var VOID_ELEMENT_NAMES = [
|
|
194
|
+
"area",
|
|
195
|
+
"base",
|
|
196
|
+
"br",
|
|
197
|
+
"col",
|
|
198
|
+
"command",
|
|
199
|
+
"embed",
|
|
200
|
+
"hr",
|
|
201
|
+
"img",
|
|
202
|
+
"input",
|
|
203
|
+
"keygen",
|
|
204
|
+
"link",
|
|
205
|
+
"meta",
|
|
206
|
+
"param",
|
|
207
|
+
"source",
|
|
208
|
+
"track",
|
|
209
|
+
"wbr"
|
|
210
|
+
];
|
|
211
|
+
function is_void(name) {
|
|
212
|
+
return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
|
|
213
|
+
}
|
|
214
|
+
var DOM_BOOLEAN_ATTRIBUTES = [
|
|
215
|
+
"allowfullscreen",
|
|
216
|
+
"async",
|
|
217
|
+
"autofocus",
|
|
218
|
+
"autoplay",
|
|
219
|
+
"checked",
|
|
220
|
+
"controls",
|
|
221
|
+
"default",
|
|
222
|
+
"disabled",
|
|
223
|
+
"formnovalidate",
|
|
224
|
+
"indeterminate",
|
|
225
|
+
"inert",
|
|
226
|
+
"ismap",
|
|
227
|
+
"loop",
|
|
228
|
+
"multiple",
|
|
229
|
+
"muted",
|
|
230
|
+
"nomodule",
|
|
231
|
+
"novalidate",
|
|
232
|
+
"open",
|
|
233
|
+
"playsinline",
|
|
234
|
+
"readonly",
|
|
235
|
+
"required",
|
|
236
|
+
"reversed",
|
|
237
|
+
"seamless",
|
|
238
|
+
"selected",
|
|
239
|
+
"webkitdirectory",
|
|
240
|
+
"defer",
|
|
241
|
+
"disablepictureinpicture",
|
|
242
|
+
"disableremoteplayback"
|
|
243
|
+
];
|
|
244
|
+
function is_boolean_attribute(name) {
|
|
245
|
+
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
|
|
246
|
+
}
|
|
247
|
+
[...DOM_BOOLEAN_ATTRIBUTES];
|
|
248
|
+
var RAW_TEXT_ELEMENTS = [
|
|
249
|
+
"textarea",
|
|
250
|
+
"script",
|
|
251
|
+
"style",
|
|
252
|
+
"title"
|
|
253
|
+
];
|
|
254
|
+
function is_raw_text_element(name) {
|
|
255
|
+
return RAW_TEXT_ELEMENTS.includes(name);
|
|
256
|
+
}
|
|
257
|
+
var REGEX_VALID_TAG_NAME = /^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*)?$/u;
|
|
258
|
+
function async_local_storage_unavailable() {
|
|
259
|
+
const error = /* @__PURE__ */ new Error(`async_local_storage_unavailable
|
|
260
|
+
The node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.
|
|
261
|
+
https://svelte.dev/e/async_local_storage_unavailable`);
|
|
262
|
+
error.name = "Svelte error";
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
function await_invalid() {
|
|
266
|
+
const error = /* @__PURE__ */ new Error(`await_invalid
|
|
267
|
+
Encountered asynchronous work while rendering synchronously.
|
|
268
|
+
https://svelte.dev/e/await_invalid`);
|
|
269
|
+
error.name = "Svelte error";
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
function dynamic_element_invalid_tag(tag) {
|
|
273
|
+
const error = /* @__PURE__ */ new Error(`dynamic_element_invalid_tag
|
|
274
|
+
\`<svelte:element this="${tag}">\` is not a valid element name \u2014 the element will not be rendered
|
|
275
|
+
https://svelte.dev/e/dynamic_element_invalid_tag`);
|
|
276
|
+
error.name = "Svelte error";
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
function html_deprecated() {
|
|
280
|
+
const error = /* @__PURE__ */ new Error(`html_deprecated
|
|
281
|
+
The \`html\` property of server render results has been deprecated. Use \`body\` instead.
|
|
282
|
+
https://svelte.dev/e/html_deprecated`);
|
|
283
|
+
error.name = "Svelte error";
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
286
|
+
function invalid_csp() {
|
|
287
|
+
const error = /* @__PURE__ */ new Error(`invalid_csp
|
|
288
|
+
\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
|
|
289
|
+
https://svelte.dev/e/invalid_csp`);
|
|
290
|
+
error.name = "Svelte error";
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
function invalid_id_prefix() {
|
|
294
|
+
const error = /* @__PURE__ */ new Error(`invalid_id_prefix
|
|
295
|
+
The \`idPrefix\` option cannot include \`--\`.
|
|
296
|
+
https://svelte.dev/e/invalid_id_prefix`);
|
|
297
|
+
error.name = "Svelte error";
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
function server_context_required() {
|
|
301
|
+
const error = /* @__PURE__ */ new Error(`server_context_required
|
|
302
|
+
Could not resolve \`render\` context.
|
|
303
|
+
https://svelte.dev/e/server_context_required`);
|
|
304
|
+
error.name = "Svelte error";
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
var ssr_context = null;
|
|
308
|
+
function set_ssr_context(v) {
|
|
309
|
+
ssr_context = v;
|
|
310
|
+
}
|
|
311
|
+
function getContext(key) {
|
|
312
|
+
return get_or_init_context_map(ssr_context, "getContext").get(key);
|
|
313
|
+
}
|
|
314
|
+
function setContext(key, context2) {
|
|
315
|
+
const context_map = get_or_init_context_map(ssr_context, "setContext");
|
|
316
|
+
if (ssr_context.i) set_context_after_init();
|
|
317
|
+
context_map.set(key, context2);
|
|
318
|
+
return context2;
|
|
319
|
+
}
|
|
320
|
+
function push(fn) {
|
|
321
|
+
ssr_context = {
|
|
322
|
+
p: ssr_context,
|
|
323
|
+
c: null,
|
|
324
|
+
r: null,
|
|
325
|
+
i: false
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function pop() {
|
|
329
|
+
ssr_context = ssr_context.p;
|
|
330
|
+
}
|
|
331
|
+
function unresolved_hydratable(key, stack) {
|
|
332
|
+
console.warn(`https://svelte.dev/e/unresolved_hydratable`);
|
|
333
|
+
}
|
|
334
|
+
var current_render = null;
|
|
335
|
+
var context = null;
|
|
336
|
+
function get_render_context() {
|
|
337
|
+
const store = context ?? als?.getStore();
|
|
338
|
+
if (!store) server_context_required();
|
|
339
|
+
return store;
|
|
340
|
+
}
|
|
341
|
+
async function with_render_context(fn) {
|
|
342
|
+
context = { hydratable: {
|
|
343
|
+
lookup: /* @__PURE__ */ new Map(),
|
|
344
|
+
comparisons: [],
|
|
345
|
+
unresolved_promises: /* @__PURE__ */ new Map()
|
|
346
|
+
} };
|
|
347
|
+
if (in_webcontainer()) {
|
|
348
|
+
const { promise, resolve } = deferred();
|
|
349
|
+
const previous_render = current_render;
|
|
350
|
+
current_render = promise;
|
|
351
|
+
await previous_render;
|
|
352
|
+
return fn().finally(resolve);
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
if (als === null) async_local_storage_unavailable();
|
|
356
|
+
return als.run(context, fn);
|
|
357
|
+
} finally {
|
|
358
|
+
context = null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
var als = null;
|
|
362
|
+
var als_import = null;
|
|
363
|
+
function init_render_context() {
|
|
364
|
+
als_import ??= import("node:async_hooks").then((hooks) => {
|
|
365
|
+
als = new hooks.AsyncLocalStorage();
|
|
366
|
+
}).then(noop, noop);
|
|
367
|
+
return als_import;
|
|
368
|
+
}
|
|
369
|
+
function in_webcontainer() {
|
|
370
|
+
return !!globalThis.process?.versions?.webcontainer;
|
|
371
|
+
}
|
|
372
|
+
var text_encoder;
|
|
373
|
+
var crypto;
|
|
374
|
+
var obfuscated_import = (module_name) => import(
|
|
375
|
+
/* @vite-ignore */
|
|
376
|
+
module_name
|
|
377
|
+
);
|
|
378
|
+
async function sha256(data) {
|
|
379
|
+
text_encoder ??= new TextEncoder();
|
|
380
|
+
crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (await obfuscated_import("node:crypto")).webcrypto;
|
|
381
|
+
return base64_encode(await crypto.subtle.digest("SHA-256", text_encoder.encode(data)));
|
|
382
|
+
}
|
|
383
|
+
function base64_encode(bytes) {
|
|
384
|
+
if (globalThis.Buffer) return globalThis.Buffer.from(bytes).toString("base64");
|
|
385
|
+
let binary = "";
|
|
386
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
387
|
+
return btoa(binary);
|
|
388
|
+
}
|
|
389
|
+
var RenderResult = class {
|
|
390
|
+
/** @type {() => AccumulatedContent} */
|
|
391
|
+
#render;
|
|
392
|
+
/** @type {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} */
|
|
393
|
+
#render_async;
|
|
394
|
+
/** @type {AccumulatedContent | undefined} */
|
|
395
|
+
#sync;
|
|
396
|
+
/** @type {{ script: '' }} */
|
|
397
|
+
#hashes = { script: "" };
|
|
398
|
+
/** @type {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }> | undefined} */
|
|
399
|
+
#promise;
|
|
400
|
+
/**
|
|
401
|
+
* @param {() => AccumulatedContent} render
|
|
402
|
+
* @param {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} render_async
|
|
403
|
+
*/
|
|
404
|
+
constructor(render2, render_async) {
|
|
405
|
+
this.#render = render2;
|
|
406
|
+
this.#render_async = render_async;
|
|
407
|
+
}
|
|
408
|
+
#get() {
|
|
409
|
+
return this.#sync ??= this.#render();
|
|
410
|
+
}
|
|
411
|
+
get html() {
|
|
412
|
+
return this.#get().body;
|
|
413
|
+
}
|
|
414
|
+
get head() {
|
|
415
|
+
return this.#get().head;
|
|
416
|
+
}
|
|
417
|
+
get body() {
|
|
418
|
+
return this.#get().body;
|
|
419
|
+
}
|
|
420
|
+
get hashes() {
|
|
421
|
+
return this.#hashes;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* This is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
|
|
425
|
+
*
|
|
426
|
+
* @template TResult1
|
|
427
|
+
* @template [TResult2=never]
|
|
428
|
+
* @param {(value: SyncRenderOutput) => TResult1} onfulfilled
|
|
429
|
+
* @param {(reason: unknown) => TResult2} onrejected
|
|
430
|
+
*/
|
|
431
|
+
then(onfulfilled, onrejected) {
|
|
432
|
+
if (!async_mode_flag) {
|
|
433
|
+
const result = this.#get();
|
|
434
|
+
const user_result = onfulfilled({
|
|
435
|
+
head: result.head,
|
|
436
|
+
body: result.body,
|
|
437
|
+
html: result.body,
|
|
438
|
+
hashes: { script: [] }
|
|
439
|
+
});
|
|
440
|
+
return Promise.resolve(user_result);
|
|
441
|
+
}
|
|
442
|
+
this.#promise ??= this.#render_async().then((result) => {
|
|
443
|
+
Object.defineProperty(result, "html", { get: () => {
|
|
444
|
+
html_deprecated();
|
|
445
|
+
} });
|
|
446
|
+
return result;
|
|
447
|
+
});
|
|
448
|
+
return this.#promise.then((result) => onfulfilled(result), onrejected);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
var Renderer = class Renderer2 {
|
|
452
|
+
/**
|
|
453
|
+
* The contents of the renderer.
|
|
454
|
+
* @type {RendererItem[]}
|
|
455
|
+
*/
|
|
456
|
+
#out = [];
|
|
457
|
+
/**
|
|
458
|
+
* Any `onDestroy` callbacks registered during execution of this renderer.
|
|
459
|
+
* @type {(() => void)[] | undefined}
|
|
460
|
+
*/
|
|
461
|
+
#on_destroy = void 0;
|
|
462
|
+
/**
|
|
463
|
+
* Whether this renderer is a component body.
|
|
464
|
+
* @type {boolean}
|
|
465
|
+
*/
|
|
466
|
+
#is_component_body = false;
|
|
467
|
+
/**
|
|
468
|
+
* If set, this renderer is an error boundary. When async collection
|
|
469
|
+
* of the children fails, the failed snippet is rendered instead.
|
|
470
|
+
* @type {{
|
|
471
|
+
* failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
|
|
472
|
+
* transformError: (error: unknown) => unknown;
|
|
473
|
+
* context: SSRContext | null;
|
|
474
|
+
* } | null}
|
|
475
|
+
*/
|
|
476
|
+
#boundary = null;
|
|
477
|
+
/**
|
|
478
|
+
* The type of string content that this renderer is accumulating.
|
|
479
|
+
* @type {RendererType}
|
|
480
|
+
*/
|
|
481
|
+
type;
|
|
482
|
+
/** @type {Renderer | undefined} */
|
|
483
|
+
#parent;
|
|
484
|
+
/**
|
|
485
|
+
* Asynchronous work associated with this renderer
|
|
486
|
+
* @type {Promise<void> | undefined}
|
|
487
|
+
*/
|
|
488
|
+
promise = void 0;
|
|
489
|
+
/**
|
|
490
|
+
* State which is associated with the content tree as a whole.
|
|
491
|
+
* It will be re-exposed, uncopied, on all children.
|
|
492
|
+
* @type {SSRState}
|
|
493
|
+
* @readonly
|
|
494
|
+
*/
|
|
495
|
+
global;
|
|
496
|
+
/**
|
|
497
|
+
* State that is local to the branch it is declared in.
|
|
498
|
+
* It will be shallow-copied to all children.
|
|
499
|
+
*
|
|
500
|
+
* @type {{ select_value: any, multiple: boolean }}
|
|
501
|
+
*/
|
|
502
|
+
local;
|
|
503
|
+
/**
|
|
504
|
+
* @param {SSRState} global
|
|
505
|
+
* @param {Renderer | undefined} [parent]
|
|
506
|
+
*/
|
|
507
|
+
constructor(global, parent) {
|
|
508
|
+
this.#parent = parent;
|
|
509
|
+
this.global = global;
|
|
510
|
+
this.local = parent ? { ...parent.local } : {
|
|
511
|
+
select_value: void 0,
|
|
512
|
+
multiple: false
|
|
513
|
+
};
|
|
514
|
+
this.type = parent ? parent.type : "body";
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* @param {(renderer: Renderer) => void} fn
|
|
518
|
+
*/
|
|
519
|
+
head(fn) {
|
|
520
|
+
const head2 = new Renderer2(this.global, this);
|
|
521
|
+
head2.type = "head";
|
|
522
|
+
this.#out.push(head2);
|
|
523
|
+
head2.child(fn);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* @param {Array<Promise<void>>} blockers
|
|
527
|
+
* @param {(renderer: Renderer) => void} fn
|
|
528
|
+
*/
|
|
529
|
+
async_block(blockers, fn) {
|
|
530
|
+
this.#out.push(BLOCK_OPEN);
|
|
531
|
+
this.async(blockers, fn);
|
|
532
|
+
this.#out.push(BLOCK_CLOSE);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* @param {Array<Promise<void>>} blockers
|
|
536
|
+
* @param {(renderer: Renderer) => void} fn
|
|
537
|
+
*/
|
|
538
|
+
async(blockers, fn) {
|
|
539
|
+
let callback = fn;
|
|
540
|
+
if (blockers.length > 0) {
|
|
541
|
+
const context2 = ssr_context;
|
|
542
|
+
callback = (renderer) => {
|
|
543
|
+
return Promise.all(blockers).then(() => {
|
|
544
|
+
const previous_context = ssr_context;
|
|
545
|
+
try {
|
|
546
|
+
set_ssr_context(context2);
|
|
547
|
+
return fn(renderer);
|
|
548
|
+
} finally {
|
|
549
|
+
set_ssr_context(previous_context);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
this.child(callback);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* @param {Array<() => void>} thunks
|
|
558
|
+
*/
|
|
559
|
+
run(thunks) {
|
|
560
|
+
const context2 = ssr_context;
|
|
561
|
+
let promise = Promise.resolve(thunks[0]());
|
|
562
|
+
const promises = [promise];
|
|
563
|
+
if (context2 !== null && thunks.length > 1) context2.i = true;
|
|
564
|
+
for (const fn of thunks.slice(1)) {
|
|
565
|
+
promise = promise.then(() => {
|
|
566
|
+
const previous_context = ssr_context;
|
|
567
|
+
set_ssr_context(context2);
|
|
568
|
+
try {
|
|
569
|
+
return fn();
|
|
570
|
+
} finally {
|
|
571
|
+
set_ssr_context(previous_context);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
promises.push(promise);
|
|
575
|
+
}
|
|
576
|
+
promise.catch(noop);
|
|
577
|
+
this.promise = this.global.track(promise);
|
|
578
|
+
return promises;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} fn
|
|
582
|
+
*/
|
|
583
|
+
child_block(fn) {
|
|
584
|
+
this.#out.push(BLOCK_OPEN);
|
|
585
|
+
this.child(fn);
|
|
586
|
+
this.#out.push(BLOCK_CLOSE);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Create a child renderer. The child renderer inherits the state from the parent,
|
|
590
|
+
* but has its own content.
|
|
591
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} fn
|
|
592
|
+
*/
|
|
593
|
+
child(fn) {
|
|
594
|
+
const child = new Renderer2(this.global, this);
|
|
595
|
+
this.#out.push(child);
|
|
596
|
+
const parent = ssr_context;
|
|
597
|
+
set_ssr_context({
|
|
598
|
+
...ssr_context,
|
|
599
|
+
p: parent,
|
|
600
|
+
c: null,
|
|
601
|
+
r: child,
|
|
602
|
+
i: ssr_context?.i ?? false
|
|
603
|
+
});
|
|
604
|
+
const result = fn(child);
|
|
605
|
+
set_ssr_context(parent);
|
|
606
|
+
if (result instanceof Promise) {
|
|
607
|
+
result.catch(noop);
|
|
608
|
+
result.finally(() => set_ssr_context(null)).catch(noop);
|
|
609
|
+
if (child.global.mode === "sync") await_invalid();
|
|
610
|
+
child.promise = child.global.track(result);
|
|
611
|
+
}
|
|
612
|
+
return child;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Render children inside an error boundary. If the children throw and the API-level
|
|
616
|
+
* `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
|
|
617
|
+
* rendered instead. Otherwise the error propagates.
|
|
618
|
+
*
|
|
619
|
+
* @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
|
|
620
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} children_fn
|
|
621
|
+
*/
|
|
622
|
+
boundary(props, children_fn) {
|
|
623
|
+
const child = new Renderer2(this.global, this);
|
|
624
|
+
this.#out.push(child);
|
|
625
|
+
const parent_context = ssr_context;
|
|
626
|
+
if (props.failed) child.#boundary = {
|
|
627
|
+
failed: props.failed,
|
|
628
|
+
transformError: this.global.transformError,
|
|
629
|
+
context: parent_context
|
|
630
|
+
};
|
|
631
|
+
set_ssr_context({
|
|
632
|
+
...ssr_context,
|
|
633
|
+
p: parent_context,
|
|
634
|
+
c: null,
|
|
635
|
+
r: child,
|
|
636
|
+
i: ssr_context?.i ?? false
|
|
637
|
+
});
|
|
638
|
+
try {
|
|
639
|
+
const result = children_fn(child);
|
|
640
|
+
set_ssr_context(parent_context);
|
|
641
|
+
if (result instanceof Promise) {
|
|
642
|
+
if (child.global.mode === "sync") await_invalid();
|
|
643
|
+
result.catch(noop);
|
|
644
|
+
child.promise = child.global.track(result);
|
|
645
|
+
}
|
|
646
|
+
} catch (error) {
|
|
647
|
+
set_ssr_context(parent_context);
|
|
648
|
+
const failed_snippet = props.failed;
|
|
649
|
+
if (!failed_snippet) throw error;
|
|
650
|
+
const result = this.global.transformError(error);
|
|
651
|
+
child.#out.length = 0;
|
|
652
|
+
child.#boundary = null;
|
|
653
|
+
if (result instanceof Promise) {
|
|
654
|
+
if (this.global.mode === "sync") await_invalid();
|
|
655
|
+
child.promise = child.global.track(
|
|
656
|
+
/** @type {Promise<unknown>} */
|
|
657
|
+
result.then((transformed) => {
|
|
658
|
+
set_ssr_context(parent_context);
|
|
659
|
+
child.#out.push(Renderer2.#serialize_failed_boundary(transformed));
|
|
660
|
+
failed_snippet(child, transformed, noop);
|
|
661
|
+
child.#out.push(BLOCK_CLOSE);
|
|
662
|
+
})
|
|
663
|
+
);
|
|
664
|
+
child.promise.catch(noop);
|
|
665
|
+
} else {
|
|
666
|
+
child.#out.push(Renderer2.#serialize_failed_boundary(result));
|
|
667
|
+
failed_snippet(child, result, noop);
|
|
668
|
+
child.#out.push(BLOCK_CLOSE);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Create a component renderer. The component renderer inherits the state from the parent,
|
|
674
|
+
* but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
|
|
675
|
+
* @param {(renderer: Renderer) => MaybePromise<void>} fn
|
|
676
|
+
* @param {Function} [component_fn]
|
|
677
|
+
* @returns {void}
|
|
678
|
+
*/
|
|
679
|
+
component(fn, component_fn) {
|
|
680
|
+
push(component_fn);
|
|
681
|
+
this.child((renderer) => {
|
|
682
|
+
renderer.#is_component_body = true;
|
|
683
|
+
return fn(renderer);
|
|
684
|
+
});
|
|
685
|
+
pop();
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* @param {Record<string, any>} attrs
|
|
689
|
+
* @param {(renderer: Renderer) => void} fn
|
|
690
|
+
* @param {string | undefined} [css_hash]
|
|
691
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
692
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
693
|
+
* @param {number | undefined} [flags]
|
|
694
|
+
* @param {boolean | undefined} [is_rich]
|
|
695
|
+
* @returns {void}
|
|
696
|
+
*/
|
|
697
|
+
select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
|
|
698
|
+
const { value, defaultValue, ...select_attrs } = attrs;
|
|
699
|
+
if (select_attrs.multiple === "") select_attrs.multiple = true;
|
|
700
|
+
this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
|
|
701
|
+
this.child((renderer) => {
|
|
702
|
+
renderer.local.select_value = value === void 0 ? defaultValue : value;
|
|
703
|
+
renderer.local.multiple = !!select_attrs.multiple;
|
|
704
|
+
fn(renderer);
|
|
705
|
+
});
|
|
706
|
+
this.push(`${is_rich ? "<!>" : ""}</select>`);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* @param {Record<string, any>} attrs
|
|
710
|
+
* @param {string | number | boolean | ((renderer: Renderer) => void)} body
|
|
711
|
+
* @param {string | undefined} [css_hash]
|
|
712
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
713
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
714
|
+
* @param {number | undefined} [flags]
|
|
715
|
+
* @param {boolean | undefined} [is_rich]
|
|
716
|
+
*/
|
|
717
|
+
option(attrs, body, css_hash, classes, styles, flags, is_rich) {
|
|
718
|
+
this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
|
|
719
|
+
const close = (renderer, value, { head: head2, body: body2 }) => {
|
|
720
|
+
if (has_own_property.call(attrs, "value")) value = attrs.value;
|
|
721
|
+
var select_value = this.local.select_value;
|
|
722
|
+
if (this.local.multiple && is_array(select_value) ? select_value.includes(value) : value === select_value) renderer.#out.push(' selected=""');
|
|
723
|
+
renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
|
|
724
|
+
if (head2) renderer.head((child) => child.push(head2));
|
|
725
|
+
};
|
|
726
|
+
if (typeof body === "function") this.child((renderer) => {
|
|
727
|
+
const r2 = new Renderer2(this.global, this);
|
|
728
|
+
body(r2);
|
|
729
|
+
if (this.global.mode === "async") return r2.#collect_content_async().then((content) => {
|
|
730
|
+
close(renderer, content.body.replaceAll("<!---->", ""), content);
|
|
731
|
+
});
|
|
732
|
+
else {
|
|
733
|
+
const content = r2.#collect_content();
|
|
734
|
+
close(renderer, content.body.replaceAll("<!---->", ""), content);
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
else close(this, body, { body: escape_html(body) });
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* @param {(renderer: Renderer) => void} fn
|
|
741
|
+
*/
|
|
742
|
+
title(fn) {
|
|
743
|
+
const path = this.get_path();
|
|
744
|
+
const close = (head2) => {
|
|
745
|
+
this.global.set_title(head2, path);
|
|
746
|
+
};
|
|
747
|
+
this.child((renderer) => {
|
|
748
|
+
const r2 = new Renderer2(renderer.global, renderer);
|
|
749
|
+
fn(r2);
|
|
750
|
+
if (renderer.global.mode === "async") return r2.#collect_content_async().then((content) => {
|
|
751
|
+
close(content.head);
|
|
752
|
+
});
|
|
753
|
+
else {
|
|
754
|
+
const content = r2.#collect_content();
|
|
755
|
+
close(content.head);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* @param {string | (() => Promise<string>)} content
|
|
761
|
+
*/
|
|
762
|
+
push(content) {
|
|
763
|
+
if (typeof content === "function") this.child(async (renderer) => renderer.push(await content()));
|
|
764
|
+
else this.#out.push(content);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* @param {() => void} fn
|
|
768
|
+
*/
|
|
769
|
+
on_destroy(fn) {
|
|
770
|
+
(this.#on_destroy ??= []).push(fn);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* @returns {number[]}
|
|
774
|
+
*/
|
|
775
|
+
get_path() {
|
|
776
|
+
return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* @deprecated this is needed for legacy component bindings
|
|
780
|
+
*/
|
|
781
|
+
copy() {
|
|
782
|
+
const copy = new Renderer2(this.global, this.#parent);
|
|
783
|
+
copy.type = this.type;
|
|
784
|
+
copy.#out = this.#out.map((item) => item instanceof Renderer2 ? item.copy() : item);
|
|
785
|
+
copy.promise = this.promise;
|
|
786
|
+
return copy;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* @param {Renderer} other
|
|
790
|
+
* @deprecated this is needed for legacy component bindings
|
|
791
|
+
*/
|
|
792
|
+
subsume(other) {
|
|
793
|
+
if (this.global.mode !== other.global.mode) throw new Error("invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!");
|
|
794
|
+
this.local = other.local;
|
|
795
|
+
this.#out = other.#out.map((item, i) => {
|
|
796
|
+
const current = this.#out[i];
|
|
797
|
+
if (current instanceof Renderer2 && item instanceof Renderer2) {
|
|
798
|
+
current.subsume(item);
|
|
799
|
+
return current;
|
|
800
|
+
}
|
|
801
|
+
return item;
|
|
802
|
+
});
|
|
803
|
+
this.promise = other.promise;
|
|
804
|
+
this.type = other.type;
|
|
805
|
+
}
|
|
806
|
+
get length() {
|
|
807
|
+
return this.#out.length;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Creates the hydration comment that marks the start of a failed boundary.
|
|
811
|
+
* The error is JSON-serialized and embedded inside an HTML comment for the client
|
|
812
|
+
* to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
|
|
813
|
+
* from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
|
|
814
|
+
* handles transparently.
|
|
815
|
+
* @param {unknown} error
|
|
816
|
+
* @returns {string}
|
|
817
|
+
*/
|
|
818
|
+
static #serialize_failed_boundary(error) {
|
|
819
|
+
return `<!--[?${JSON.stringify(error).replace(/>/g, "\\u003e").replace(/</g, "\\u003c")}-->`;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Only available on the server and when compiling with the `server` option.
|
|
823
|
+
* 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.
|
|
824
|
+
* @template {Record<string, any>} Props
|
|
825
|
+
* @param {Component<Props>} component
|
|
826
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
|
|
827
|
+
* @returns {RenderOutput}
|
|
828
|
+
*/
|
|
829
|
+
static render(component, options = {}) {
|
|
830
|
+
return new RenderResult(() => Renderer2.#render(component, options), () => init_render_context().then(() => with_render_context(() => Renderer2.#render_async(component, options))));
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
|
|
834
|
+
* after awaiting `collect_async`.
|
|
835
|
+
*
|
|
836
|
+
* Child renderers are "porous" and don't affect execution order, but component body renderers
|
|
837
|
+
* create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
|
|
838
|
+
* @returns {Iterable<() => void>}
|
|
839
|
+
*/
|
|
840
|
+
*#collect_on_destroy() {
|
|
841
|
+
for (const component of this.#traverse_components()) yield* component.#collect_ondestroy();
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
|
|
845
|
+
* @returns {Iterable<Renderer>}
|
|
846
|
+
*/
|
|
847
|
+
*#traverse_components() {
|
|
848
|
+
for (const child of this.#out) if (typeof child !== "string") yield* child.#traverse_components();
|
|
849
|
+
if (this.#is_component_body) yield this;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* @returns {Iterable<() => void>}
|
|
853
|
+
*/
|
|
854
|
+
*#collect_ondestroy() {
|
|
855
|
+
if (this.#on_destroy) for (const fn of this.#on_destroy) yield fn;
|
|
856
|
+
for (const child of this.#out) if (child instanceof Renderer2 && !child.#is_component_body) yield* child.#collect_ondestroy();
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Runs every `onDestroy` callback in this renderer tree. On a failed render,
|
|
860
|
+
* cleanup errors are suppressed so they do not mask the render error.
|
|
861
|
+
* @param {boolean} suppress_errors
|
|
862
|
+
*/
|
|
863
|
+
#run_on_destroy(suppress_errors) {
|
|
864
|
+
let first_error;
|
|
865
|
+
let has_error = false;
|
|
866
|
+
for (const cleanup of this.#collect_on_destroy()) try {
|
|
867
|
+
cleanup();
|
|
868
|
+
} catch (error) {
|
|
869
|
+
if (!suppress_errors && !has_error) {
|
|
870
|
+
first_error = error;
|
|
871
|
+
has_error = true;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (has_error) throw first_error;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* @param {'sync' | 'async'} mode
|
|
878
|
+
* @param {{ idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
|
|
879
|
+
* @returns {Renderer}
|
|
880
|
+
*/
|
|
881
|
+
static #create(mode, options) {
|
|
882
|
+
if (options.idPrefix?.includes("--")) invalid_id_prefix();
|
|
883
|
+
return new Renderer2(new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp, options.transformError));
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Render a component. Throws if any of the children are performing asynchronous work.
|
|
887
|
+
*
|
|
888
|
+
* @template {Record<string, any>} Props
|
|
889
|
+
* @param {Component<Props>} component
|
|
890
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
|
|
891
|
+
* @returns {AccumulatedContent}
|
|
892
|
+
*/
|
|
893
|
+
static #render(component, options) {
|
|
894
|
+
var previous_context = ssr_context;
|
|
895
|
+
const renderer = Renderer2.#create("sync", options);
|
|
896
|
+
let result;
|
|
897
|
+
let render_error;
|
|
898
|
+
let failed = false;
|
|
899
|
+
try {
|
|
900
|
+
try {
|
|
901
|
+
Renderer2.#open_render(renderer, component, options);
|
|
902
|
+
result = Renderer2.#close_render(renderer.#collect_content(), renderer);
|
|
903
|
+
} catch (error) {
|
|
904
|
+
render_error = error;
|
|
905
|
+
failed = true;
|
|
906
|
+
}
|
|
907
|
+
renderer.#run_on_destroy(failed);
|
|
908
|
+
if (failed) throw render_error;
|
|
909
|
+
return result;
|
|
910
|
+
} finally {
|
|
911
|
+
renderer.global.abort();
|
|
912
|
+
set_ssr_context(previous_context);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Render a component.
|
|
917
|
+
*
|
|
918
|
+
* @template {Record<string, any>} Props
|
|
919
|
+
* @param {Component<Props>} component
|
|
920
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
|
|
921
|
+
* @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
|
|
922
|
+
*/
|
|
923
|
+
static async #render_async(component, options) {
|
|
924
|
+
const previous_context = ssr_context;
|
|
925
|
+
const renderer = Renderer2.#create("async", options);
|
|
926
|
+
let result;
|
|
927
|
+
let render_error;
|
|
928
|
+
let failed = false;
|
|
929
|
+
try {
|
|
930
|
+
try {
|
|
931
|
+
Renderer2.#open_render(renderer, component, options);
|
|
932
|
+
const content = await renderer.#collect_content_async();
|
|
933
|
+
const hydratables = await renderer.#collect_hydratables();
|
|
934
|
+
if (hydratables !== null) content.head = hydratables + content.head;
|
|
935
|
+
result = Renderer2.#close_render(content, renderer);
|
|
936
|
+
} catch (error) {
|
|
937
|
+
render_error = error;
|
|
938
|
+
failed = true;
|
|
939
|
+
renderer.global.abort();
|
|
940
|
+
await renderer.global.settle();
|
|
941
|
+
}
|
|
942
|
+
renderer.#run_on_destroy(failed);
|
|
943
|
+
if (failed) throw render_error;
|
|
944
|
+
return result;
|
|
945
|
+
} finally {
|
|
946
|
+
set_ssr_context(previous_context);
|
|
947
|
+
renderer.global.abort();
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
|
|
952
|
+
* @param {AccumulatedContent} content
|
|
953
|
+
* @returns {AccumulatedContent}
|
|
954
|
+
*/
|
|
955
|
+
#collect_content(content = {
|
|
956
|
+
head: "",
|
|
957
|
+
body: ""
|
|
958
|
+
}) {
|
|
959
|
+
for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
|
|
960
|
+
else if (item instanceof Renderer2) item.#collect_content(content);
|
|
961
|
+
return content;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Collect all of the code from the `out` array and return it as a string.
|
|
965
|
+
* @param {AccumulatedContent} content
|
|
966
|
+
* @returns {Promise<AccumulatedContent>}
|
|
967
|
+
*/
|
|
968
|
+
async #collect_content_async(content = {
|
|
969
|
+
head: "",
|
|
970
|
+
body: ""
|
|
971
|
+
}) {
|
|
972
|
+
await this.promise;
|
|
973
|
+
for (const item of this.#out) if (typeof item === "string") content[this.type] += item;
|
|
974
|
+
else if (item instanceof Renderer2) {
|
|
975
|
+
if (item.#boundary) {
|
|
976
|
+
const boundary_content = {
|
|
977
|
+
head: "",
|
|
978
|
+
body: ""
|
|
979
|
+
};
|
|
980
|
+
try {
|
|
981
|
+
await item.#collect_content_async(boundary_content);
|
|
982
|
+
content.head += boundary_content.head;
|
|
983
|
+
content.body += boundary_content.body;
|
|
984
|
+
} catch (error) {
|
|
985
|
+
const { context: context2, failed, transformError } = item.#boundary;
|
|
986
|
+
set_ssr_context(context2);
|
|
987
|
+
let promise = transformError(error);
|
|
988
|
+
set_ssr_context(null);
|
|
989
|
+
let transformed = await promise;
|
|
990
|
+
set_ssr_context(context2);
|
|
991
|
+
const failed_renderer = new Renderer2(item.global, item);
|
|
992
|
+
failed_renderer.type = item.type;
|
|
993
|
+
failed_renderer.#out.push(Renderer2.#serialize_failed_boundary(transformed));
|
|
994
|
+
failed(failed_renderer, transformed, noop);
|
|
995
|
+
failed_renderer.#out.push(BLOCK_CLOSE);
|
|
996
|
+
await failed_renderer.#collect_content_async(content);
|
|
997
|
+
}
|
|
998
|
+
} else await item.#collect_content_async(content);
|
|
999
|
+
}
|
|
1000
|
+
return content;
|
|
1001
|
+
}
|
|
1002
|
+
async #collect_hydratables() {
|
|
1003
|
+
const ctx = get_render_context().hydratable;
|
|
1004
|
+
for (const [_, key] of ctx.unresolved_promises) unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
|
|
1005
|
+
for (const comparison of ctx.comparisons) await comparison;
|
|
1006
|
+
return await this.#hydratable_block(ctx);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* @template {Record<string, any>} Props
|
|
1010
|
+
* @param {Renderer} renderer
|
|
1011
|
+
* @param {import('svelte').Component<Props>} component
|
|
1012
|
+
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
|
|
1013
|
+
* @returns {void}
|
|
1014
|
+
*/
|
|
1015
|
+
static #open_render(renderer, component, options) {
|
|
1016
|
+
var previous_context = ssr_context;
|
|
1017
|
+
try {
|
|
1018
|
+
set_ssr_context({
|
|
1019
|
+
p: null,
|
|
1020
|
+
c: options.context ?? null,
|
|
1021
|
+
r: renderer,
|
|
1022
|
+
i: false
|
|
1023
|
+
});
|
|
1024
|
+
renderer.push(BLOCK_OPEN);
|
|
1025
|
+
component(renderer, options.props ?? {});
|
|
1026
|
+
renderer.push(BLOCK_CLOSE);
|
|
1027
|
+
} finally {
|
|
1028
|
+
set_ssr_context(previous_context);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* @param {AccumulatedContent} content
|
|
1033
|
+
* @param {Renderer} renderer
|
|
1034
|
+
* @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
|
|
1035
|
+
*/
|
|
1036
|
+
static #close_render(content, renderer) {
|
|
1037
|
+
let head2 = content.head + renderer.global.get_title();
|
|
1038
|
+
let body = content.body;
|
|
1039
|
+
for (const { hash, code } of renderer.global.css) head2 += `<style id="${hash}">${code}</style>`;
|
|
1040
|
+
return {
|
|
1041
|
+
head: head2,
|
|
1042
|
+
body,
|
|
1043
|
+
hashes: { script: renderer.global.csp.script_hashes }
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* @param {HydratableContext} ctx
|
|
1048
|
+
*/
|
|
1049
|
+
async #hydratable_block(ctx) {
|
|
1050
|
+
if (ctx.lookup.size === 0) return null;
|
|
1051
|
+
let entries = [];
|
|
1052
|
+
let has_promises = false;
|
|
1053
|
+
for (const [k, v] of ctx.lookup) {
|
|
1054
|
+
if (v.promises) {
|
|
1055
|
+
has_promises = true;
|
|
1056
|
+
for (const p of v.promises) await p;
|
|
1057
|
+
}
|
|
1058
|
+
entries.push(`[${uneval(k)},${v.serialized}]`);
|
|
1059
|
+
}
|
|
1060
|
+
let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
|
|
1061
|
+
if (has_promises) prelude = `const r = (v) => Promise.resolve(v);
|
|
1062
|
+
${prelude}`;
|
|
1063
|
+
const body = `
|
|
1064
|
+
{
|
|
1065
|
+
${prelude}
|
|
1066
|
+
|
|
1067
|
+
for (const [k, v] of [
|
|
1068
|
+
${entries.join(",\n ")}
|
|
1069
|
+
]) {
|
|
1070
|
+
h.set(k, v);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
`;
|
|
1074
|
+
let csp_attr = "";
|
|
1075
|
+
if (this.global.csp.nonce) csp_attr = ` nonce="${this.global.csp.nonce}"`;
|
|
1076
|
+
else if (this.global.csp.hash) {
|
|
1077
|
+
const hash = await sha256(body);
|
|
1078
|
+
this.global.csp.script_hashes.push(`sha256-${hash}`);
|
|
1079
|
+
}
|
|
1080
|
+
return `
|
|
1081
|
+
<script${csp_attr}>${body}</script>`;
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
var SSRState = class {
|
|
1085
|
+
/** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
|
|
1086
|
+
csp;
|
|
1087
|
+
/** @readonly @type {'sync' | 'async'} */
|
|
1088
|
+
mode;
|
|
1089
|
+
/** @readonly @type {() => string} */
|
|
1090
|
+
uid;
|
|
1091
|
+
/** @readonly @type {Set<{ hash: string; code: string }>} */
|
|
1092
|
+
css = /* @__PURE__ */ new Set();
|
|
1093
|
+
/** @type {Set<Promise<unknown>>} */
|
|
1094
|
+
#pending = /* @__PURE__ */ new Set();
|
|
1095
|
+
/** @type {AbortController | null} */
|
|
1096
|
+
#controller = null;
|
|
1097
|
+
#aborted = false;
|
|
1098
|
+
/**
|
|
1099
|
+
* `transformError` passed to `render`. Called when an error boundary catches an error.
|
|
1100
|
+
* Throws by default if unset in `render`.
|
|
1101
|
+
* @type {(error: unknown) => unknown}
|
|
1102
|
+
*/
|
|
1103
|
+
transformError;
|
|
1104
|
+
/** @type {{ path: number[], value: string }} */
|
|
1105
|
+
#title = {
|
|
1106
|
+
path: [],
|
|
1107
|
+
value: ""
|
|
1108
|
+
};
|
|
1109
|
+
/**
|
|
1110
|
+
* @param {'sync' | 'async'} mode
|
|
1111
|
+
* @param {string} id_prefix
|
|
1112
|
+
* @param {Csp} csp
|
|
1113
|
+
* @param {((error: unknown) => unknown) | undefined} [transformError]
|
|
1114
|
+
*/
|
|
1115
|
+
constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
|
|
1116
|
+
this.mode = mode;
|
|
1117
|
+
this.csp = {
|
|
1118
|
+
...csp,
|
|
1119
|
+
script_hashes: []
|
|
1120
|
+
};
|
|
1121
|
+
this.transformError = transformError ?? ((error) => {
|
|
1122
|
+
throw error;
|
|
1123
|
+
});
|
|
1124
|
+
let uid = 1;
|
|
1125
|
+
this.uid = () => `${id_prefix}s${uid++}`;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* @template T
|
|
1129
|
+
* @param {Promise<T>} promise
|
|
1130
|
+
* @returns {Promise<T>}
|
|
1131
|
+
*/
|
|
1132
|
+
track(promise) {
|
|
1133
|
+
this.#pending.add(promise);
|
|
1134
|
+
promise.then(() => this.#pending.delete(promise), () => this.#pending.delete(promise));
|
|
1135
|
+
return promise;
|
|
1136
|
+
}
|
|
1137
|
+
async settle() {
|
|
1138
|
+
while (this.#pending.size > 0) await Promise.allSettled([...this.#pending]);
|
|
1139
|
+
}
|
|
1140
|
+
abort() {
|
|
1141
|
+
if (this.#aborted) return;
|
|
1142
|
+
this.#aborted = true;
|
|
1143
|
+
this.#controller?.abort(STALE_REACTION);
|
|
1144
|
+
}
|
|
1145
|
+
get_abort_signal() {
|
|
1146
|
+
const controller = this.#controller ??= new AbortController();
|
|
1147
|
+
if (this.#aborted) controller.abort(STALE_REACTION);
|
|
1148
|
+
return controller.signal;
|
|
1149
|
+
}
|
|
1150
|
+
get_title() {
|
|
1151
|
+
return this.#title.value;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Performs a depth-first (lexicographic) comparison using the path. Rejects sets
|
|
1155
|
+
* from earlier than or equal to the current value.
|
|
1156
|
+
* @param {string} value
|
|
1157
|
+
* @param {number[]} path
|
|
1158
|
+
*/
|
|
1159
|
+
set_title(value, path) {
|
|
1160
|
+
const current = this.#title.path;
|
|
1161
|
+
let i = 0;
|
|
1162
|
+
let l = Math.min(path.length, current.length);
|
|
1163
|
+
while (i < l && path[i] === current[i]) i += 1;
|
|
1164
|
+
if (path[i] === void 0) return;
|
|
1165
|
+
if (current[i] === void 0 || path[i] > current[i]) {
|
|
1166
|
+
this.#title.path = path;
|
|
1167
|
+
this.#title.value = value;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
function html(value) {
|
|
1172
|
+
return "<!---->" + String(value ?? "") + "<!---->";
|
|
1173
|
+
}
|
|
1174
|
+
var 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;
|
|
1175
|
+
function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
|
|
1176
|
+
renderer.push("<!---->");
|
|
1177
|
+
if (tag) {
|
|
1178
|
+
if (!REGEX_VALID_TAG_NAME.test(tag)) dynamic_element_invalid_tag(tag);
|
|
1179
|
+
renderer.push(`<${tag}`);
|
|
1180
|
+
attributes_fn();
|
|
1181
|
+
renderer.push(`>`);
|
|
1182
|
+
if (!is_void(tag)) {
|
|
1183
|
+
children_fn();
|
|
1184
|
+
if (!is_raw_text_element(tag)) renderer.push(EMPTY_COMMENT);
|
|
1185
|
+
renderer.push(`</${tag}>`);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
renderer.push("<!---->");
|
|
1189
|
+
}
|
|
1190
|
+
function render(component, options = {}) {
|
|
1191
|
+
if (options.csp?.hash && options.csp.nonce) invalid_csp();
|
|
1192
|
+
return Renderer.render(component, options);
|
|
1193
|
+
}
|
|
1194
|
+
function head(hash, renderer, fn) {
|
|
1195
|
+
renderer.head((renderer2) => {
|
|
1196
|
+
renderer2.push(`<!--${hash}-->`);
|
|
1197
|
+
renderer2.child(fn);
|
|
1198
|
+
renderer2.push(EMPTY_COMMENT);
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
function attributes(attrs, css_hash, classes, styles, flags = 0) {
|
|
1202
|
+
if (styles) attrs.style = to_style(attrs.style, styles);
|
|
1203
|
+
if (attrs.class) attrs.class = clsx(attrs.class);
|
|
1204
|
+
if (css_hash || classes) attrs.class = to_class(attrs.class, css_hash, classes);
|
|
1205
|
+
let attr_str = "";
|
|
1206
|
+
let name;
|
|
1207
|
+
const is_html = (flags & 1) === 0;
|
|
1208
|
+
const lowercase = (flags & 2) === 0;
|
|
1209
|
+
const is_input = (flags & 4) !== 0;
|
|
1210
|
+
const names = Object.keys(attrs);
|
|
1211
|
+
outer: for (let i = 0; i < names.length; i++) {
|
|
1212
|
+
name = names[i];
|
|
1213
|
+
if (typeof attrs[name] === "function") continue;
|
|
1214
|
+
if (name[0] === "$" && name[1] === "$") continue;
|
|
1215
|
+
if (name === "" || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
|
|
1216
|
+
var value = attrs[name];
|
|
1217
|
+
var lower = name.toLowerCase();
|
|
1218
|
+
if (lowercase) name = lower;
|
|
1219
|
+
if (lower.length > 2 && lower.startsWith("on")) continue;
|
|
1220
|
+
if (is_input) {
|
|
1221
|
+
if (name === "defaultvalue" || name === "defaultchecked") {
|
|
1222
|
+
name = name === "defaultvalue" ? "value" : "checked";
|
|
1223
|
+
if (name in attrs) continue;
|
|
1224
|
+
for (let j = 0; j < names.length; j++) if (names[j].toLowerCase() === name) continue outer;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
attr_str += attr(name, value, is_html && is_boolean_attribute(name));
|
|
1228
|
+
}
|
|
1229
|
+
return attr_str;
|
|
1230
|
+
}
|
|
1231
|
+
function spread_props(props) {
|
|
1232
|
+
const merged_props = {};
|
|
1233
|
+
let key;
|
|
1234
|
+
for (let i = 0; i < props.length; i++) {
|
|
1235
|
+
const obj = props[i];
|
|
1236
|
+
if (obj == null) continue;
|
|
1237
|
+
for (key of Object.keys(obj)) {
|
|
1238
|
+
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
1239
|
+
if (desc) Object.defineProperty(merged_props, key, desc);
|
|
1240
|
+
else merged_props[key] = obj[key];
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
return merged_props;
|
|
1244
|
+
}
|
|
1245
|
+
function stringify(value) {
|
|
1246
|
+
return typeof value === "string" ? value : value == null ? "" : value + "";
|
|
1247
|
+
}
|
|
1248
|
+
function attr_class(value, hash, directives) {
|
|
1249
|
+
var result = to_class(value, hash, directives);
|
|
1250
|
+
return result ? ` class="${escape_html(result, true)}"` : "";
|
|
1251
|
+
}
|
|
1252
|
+
function attr_style(value, directives) {
|
|
1253
|
+
var result = to_style(value, directives);
|
|
1254
|
+
return result ? ` style="${escape_html(result, true)}"` : "";
|
|
1255
|
+
}
|
|
1256
|
+
function bind_props(props_parent, props_now) {
|
|
1257
|
+
for (const key of Object.keys(props_now)) {
|
|
1258
|
+
const initial_value = props_parent[key];
|
|
1259
|
+
const value = props_now[key];
|
|
1260
|
+
if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) props_parent[key] = value;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function ensure_array_like(array_like_or_iterator) {
|
|
1264
|
+
if (array_like_or_iterator) return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
|
1265
|
+
return [];
|
|
1266
|
+
}
|
|
1267
|
+
function once(get_value) {
|
|
1268
|
+
let value = UNINITIALIZED;
|
|
1269
|
+
return () => {
|
|
1270
|
+
if (value === UNINITIALIZED) value = get_value();
|
|
1271
|
+
return value;
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function props_id(renderer) {
|
|
1275
|
+
const uid = renderer.global.uid();
|
|
1276
|
+
renderer.push("<!--$" + uid + "-->");
|
|
1277
|
+
return uid;
|
|
1278
|
+
}
|
|
1279
|
+
function derived(fn) {
|
|
1280
|
+
const get_value = ssr_context === null ? fn : once(fn);
|
|
1281
|
+
let updated_value;
|
|
1282
|
+
return function(new_value) {
|
|
1283
|
+
if (arguments.length === 0) return updated_value ?? get_value();
|
|
1284
|
+
updated_value = new_value;
|
|
1285
|
+
return updated_value;
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
export {
|
|
1290
|
+
escape_html,
|
|
1291
|
+
run,
|
|
1292
|
+
fallback,
|
|
1293
|
+
to_array,
|
|
1294
|
+
attr,
|
|
1295
|
+
clsx,
|
|
1296
|
+
getContext,
|
|
1297
|
+
setContext,
|
|
1298
|
+
html,
|
|
1299
|
+
element,
|
|
1300
|
+
render,
|
|
1301
|
+
head,
|
|
1302
|
+
attributes,
|
|
1303
|
+
spread_props,
|
|
1304
|
+
stringify,
|
|
1305
|
+
attr_class,
|
|
1306
|
+
attr_style,
|
|
1307
|
+
bind_props,
|
|
1308
|
+
ensure_array_like,
|
|
1309
|
+
props_id,
|
|
1310
|
+
derived
|
|
1311
|
+
};
|