@shadow-js/core 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/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/chunk-6Y3CCWOY.js +887 -0
- package/dist/chunk-6Y3CCWOY.js.map +1 -0
- package/dist/chunk-B5FTYDUG.js +3 -0
- package/dist/chunk-B5FTYDUG.js.map +1 -0
- package/dist/index.cjs +2000 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +609 -0
- package/dist/index.d.ts +609 -0
- package/dist/index.js +1094 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-Bugil6CJ.d.cts +151 -0
- package/dist/jsx-Bugil6CJ.d.ts +151 -0
- package/dist/jsx-dev-runtime.cjs +742 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.cts +2 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +4 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +742 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.cts +36 -0
- package/dist/jsx-runtime.d.ts +36 -0
- package/dist/jsx-runtime.js +4 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
// src/runtime/lifecycle.ts
|
|
2
|
+
var scopeStack = [];
|
|
3
|
+
var compStartMap = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function pushComponentScope() {
|
|
5
|
+
const s = { cleanups: [] };
|
|
6
|
+
scopeStack.push(s);
|
|
7
|
+
return s;
|
|
8
|
+
}
|
|
9
|
+
function popComponentScope() {
|
|
10
|
+
return scopeStack.pop() || null;
|
|
11
|
+
}
|
|
12
|
+
function getCurrentScope() {
|
|
13
|
+
return scopeStack.length ? scopeStack[scopeStack.length - 1] : null;
|
|
14
|
+
}
|
|
15
|
+
function registerCleanup(fn) {
|
|
16
|
+
const s = getCurrentScope();
|
|
17
|
+
if (s) s.cleanups.push(fn);
|
|
18
|
+
}
|
|
19
|
+
function runCleanups(scope) {
|
|
20
|
+
for (let i = scope.cleanups.length - 1; i >= 0; i--) {
|
|
21
|
+
try {
|
|
22
|
+
scope.cleanups[i]();
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
scope.cleanups.length = 0;
|
|
27
|
+
}
|
|
28
|
+
function markComponentBoundary(start, end, scope) {
|
|
29
|
+
compStartMap.set(start, { end, scope });
|
|
30
|
+
}
|
|
31
|
+
function disposeIfComponentStart(node) {
|
|
32
|
+
if (!node || node.nodeType !== Node.COMMENT_NODE) return;
|
|
33
|
+
const start = node;
|
|
34
|
+
const entry = compStartMap.get(start);
|
|
35
|
+
if (!entry) return;
|
|
36
|
+
runCleanups(entry.scope);
|
|
37
|
+
compStartMap.delete(start);
|
|
38
|
+
}
|
|
39
|
+
function deepDisposeNode(node) {
|
|
40
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
41
|
+
disposeIfComponentStart(node);
|
|
42
|
+
}
|
|
43
|
+
let child = node.firstChild || null;
|
|
44
|
+
while (child) {
|
|
45
|
+
const next = child.nextSibling;
|
|
46
|
+
deepDisposeNode(child);
|
|
47
|
+
child = next;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function disposeBetween(start, end) {
|
|
51
|
+
const parent = start.parentNode;
|
|
52
|
+
if (!parent) return;
|
|
53
|
+
let cur = start.nextSibling;
|
|
54
|
+
while (cur && cur !== end) {
|
|
55
|
+
const next = cur.nextSibling;
|
|
56
|
+
deepDisposeNode(cur);
|
|
57
|
+
parent.removeChild(cur);
|
|
58
|
+
cur = next;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function disposeAllChildren(parent) {
|
|
62
|
+
let cur = parent.firstChild;
|
|
63
|
+
while (cur) {
|
|
64
|
+
const next = cur.nextSibling;
|
|
65
|
+
deepDisposeNode(cur);
|
|
66
|
+
parent.removeChild(cur);
|
|
67
|
+
cur = next;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function runInScope(scope, fn) {
|
|
71
|
+
scopeStack.push(scope);
|
|
72
|
+
try {
|
|
73
|
+
return fn();
|
|
74
|
+
} finally {
|
|
75
|
+
scopeStack.pop();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/errors.ts
|
|
80
|
+
var ERRORS = {
|
|
81
|
+
// --- render ---
|
|
82
|
+
RENDER_CONTAINER_REQUIRED: () => new Error("Container element is required for rendering"),
|
|
83
|
+
RENDER_INVALID_COMPONENT: () => new Error("Invalid component type. Must be a function or DOM element"),
|
|
84
|
+
RENDER_INVALID_RETURN: () => new Error("Component must return a valid DOM element"),
|
|
85
|
+
// --- portal ---
|
|
86
|
+
PORTAL_MOUNT_REQUIRED: () => new Error("Portal: 'mount' element is required"),
|
|
87
|
+
// --- for (each-only) ---
|
|
88
|
+
FOR_CHILDREN_MUST_BE_FUNCTION: () => new Error("<For> requires function children."),
|
|
89
|
+
FOR_EACH_REQUIRES_ARRAY: () => new Error("<For each> expects an array (or function returning an array)."),
|
|
90
|
+
// --- show ---
|
|
91
|
+
SHOW_INVALID_WHEN: () => new Error(
|
|
92
|
+
"<Show> 'when' must be a boolean or a function returning a boolean."
|
|
93
|
+
),
|
|
94
|
+
// --- switch ---
|
|
95
|
+
SWITCH_NO_CHILDREN_OR_FALLBACK: () => new Error(
|
|
96
|
+
"<Switch> requires at least one <Match when> child or a 'fallback'."
|
|
97
|
+
),
|
|
98
|
+
// --- jsx ---
|
|
99
|
+
JSX_INVALID_TAG: (tag) => new Error(
|
|
100
|
+
`Invalid JSX tag: expected a string (intrinsic) or function component, received ${typeof tag}`
|
|
101
|
+
),
|
|
102
|
+
// --- lazy ---
|
|
103
|
+
LAZY_INVALID_EXPORT: () => new Error("Lazy component must have a default export or be a function"),
|
|
104
|
+
LAZY_FAILED_AFTER_ATTEMPTS: (retries, reason) => {
|
|
105
|
+
const msg = reason instanceof Error ? reason.message : String(reason);
|
|
106
|
+
return new Error(
|
|
107
|
+
`Failed to load lazy component after ${retries} attempts: ${msg}`
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
// --- hooks ---
|
|
111
|
+
HOOK_OUTSIDE_COMPONENT: (name) => new Error(`${name} must be called during a component's execution`),
|
|
112
|
+
HOOK_INVALID_DEPS: (name) => new Error(`${name}: 'deps' must be an array of functions`),
|
|
113
|
+
HOOK_INVALID_REDUCER: (name) => new Error(`${name}: 'reducer' must be a function`),
|
|
114
|
+
HOOK_INVALID_ARGUMENT: (hook, argName, expected) => new Error(`${hook}: '${argName}' must be a ${expected}`)
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/reactivity/hooks/useEffect.ts
|
|
118
|
+
var __currentEffect = null;
|
|
119
|
+
var __currentEffectDeps = null;
|
|
120
|
+
var __effectStack = [];
|
|
121
|
+
function useEffect(fn, deps) {
|
|
122
|
+
if (typeof fn !== "function") {
|
|
123
|
+
throw ERRORS.HOOK_INVALID_ARGUMENT("useEffect", "fn", "function");
|
|
124
|
+
}
|
|
125
|
+
if (deps !== void 0) {
|
|
126
|
+
if (!Array.isArray(deps) || deps.some((d) => typeof d !== "function")) {
|
|
127
|
+
throw ERRORS.HOOK_INVALID_DEPS("useEffect");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let lastDepsValues = [];
|
|
131
|
+
let isInitialized = false;
|
|
132
|
+
let userCleanup = null;
|
|
133
|
+
const runUserCleanup = () => {
|
|
134
|
+
if (userCleanup) {
|
|
135
|
+
try {
|
|
136
|
+
userCleanup();
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
userCleanup = null;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
function hasDepChanged() {
|
|
143
|
+
if (!deps) return true;
|
|
144
|
+
const current = deps.map((dep) => dep());
|
|
145
|
+
if (lastDepsValues.length !== current.length) {
|
|
146
|
+
lastDepsValues = current;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
for (let i = 0; i < current.length; i++) {
|
|
150
|
+
if (current[i] !== lastDepsValues[i]) {
|
|
151
|
+
lastDepsValues = current;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
let latestDepsSetsForAuto = /* @__PURE__ */ new Set();
|
|
158
|
+
let latestDepsSetsForDep = /* @__PURE__ */ new Set();
|
|
159
|
+
const unsubscribeSets = (sets, effectFn) => {
|
|
160
|
+
sets.forEach((s) => s.delete(effectFn));
|
|
161
|
+
};
|
|
162
|
+
const execute = () => {
|
|
163
|
+
if (!deps) {
|
|
164
|
+
unsubscribeSets(latestDepsSetsForAuto, execute);
|
|
165
|
+
}
|
|
166
|
+
if (deps) {
|
|
167
|
+
if (!isInitialized) {
|
|
168
|
+
isInitialized = true;
|
|
169
|
+
lastDepsValues = deps.map((dep) => dep());
|
|
170
|
+
const ret = fn();
|
|
171
|
+
if (typeof ret === "function") userCleanup = ret;
|
|
172
|
+
} else if (hasDepChanged()) {
|
|
173
|
+
runUserCleanup();
|
|
174
|
+
const ret = fn();
|
|
175
|
+
if (typeof ret === "function") userCleanup = ret;
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
runUserCleanup();
|
|
179
|
+
__currentEffect = execute;
|
|
180
|
+
__effectStack.push(execute);
|
|
181
|
+
__currentEffectDeps = /* @__PURE__ */ new Set();
|
|
182
|
+
try {
|
|
183
|
+
const ret = fn();
|
|
184
|
+
if (typeof ret === "function") userCleanup = ret;
|
|
185
|
+
} finally {
|
|
186
|
+
latestDepsSetsForAuto = __currentEffectDeps;
|
|
187
|
+
__currentEffectDeps = null;
|
|
188
|
+
__effectStack.pop();
|
|
189
|
+
__currentEffect = __effectStack[__effectStack.length - 1] || null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
if (deps) {
|
|
194
|
+
const depEffect = () => {
|
|
195
|
+
unsubscribeSets(latestDepsSetsForDep, depEffect);
|
|
196
|
+
__currentEffect = depEffect;
|
|
197
|
+
__effectStack.push(depEffect);
|
|
198
|
+
__currentEffectDeps = /* @__PURE__ */ new Set();
|
|
199
|
+
try {
|
|
200
|
+
deps.forEach((dep) => dep());
|
|
201
|
+
latestDepsSetsForDep = __currentEffectDeps;
|
|
202
|
+
if (!isInitialized || hasDepChanged()) {
|
|
203
|
+
execute();
|
|
204
|
+
}
|
|
205
|
+
} finally {
|
|
206
|
+
__currentEffectDeps = null;
|
|
207
|
+
__effectStack.pop();
|
|
208
|
+
__currentEffect = __effectStack[__effectStack.length - 1] || null;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
depEffect();
|
|
212
|
+
registerCleanup(() => {
|
|
213
|
+
unsubscribeSets(latestDepsSetsForDep, depEffect);
|
|
214
|
+
runUserCleanup();
|
|
215
|
+
});
|
|
216
|
+
return depEffect;
|
|
217
|
+
} else {
|
|
218
|
+
execute();
|
|
219
|
+
registerCleanup(() => {
|
|
220
|
+
unsubscribeSets(latestDepsSetsForAuto, execute);
|
|
221
|
+
runUserCleanup();
|
|
222
|
+
});
|
|
223
|
+
return execute;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function untrack(fn) {
|
|
227
|
+
const prevEffect = __currentEffect;
|
|
228
|
+
const prevDeps = __currentEffectDeps;
|
|
229
|
+
__currentEffect = null;
|
|
230
|
+
__currentEffectDeps = null;
|
|
231
|
+
try {
|
|
232
|
+
return fn();
|
|
233
|
+
} finally {
|
|
234
|
+
__currentEffect = prevEffect;
|
|
235
|
+
__currentEffectDeps = prevDeps;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/reactivity/hooks/onCleanup.ts
|
|
240
|
+
function onCleanup(fn) {
|
|
241
|
+
if (typeof fn !== "function") {
|
|
242
|
+
throw ERRORS.HOOK_INVALID_ARGUMENT("onCleanup", "fn", "function");
|
|
243
|
+
}
|
|
244
|
+
if (!getCurrentScope()) {
|
|
245
|
+
throw ERRORS.HOOK_OUTSIDE_COMPONENT("onCleanup");
|
|
246
|
+
}
|
|
247
|
+
registerCleanup(fn);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/runtime/shared/isComponentThunk.ts
|
|
251
|
+
function isComponentThunk(v) {
|
|
252
|
+
return typeof v === "function" && v.__isComponent === true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/runtime/Fragment.ts
|
|
256
|
+
function createReactiveSection(parent, valueOrFunction) {
|
|
257
|
+
const startComment = document.createComment("f-r-s");
|
|
258
|
+
const endComment = document.createComment("f-r-e");
|
|
259
|
+
parent.appendChild(startComment);
|
|
260
|
+
parent.appendChild(endComment);
|
|
261
|
+
const scope = pushComponentScope();
|
|
262
|
+
markComponentBoundary(startComment, endComment, scope);
|
|
263
|
+
const insertBeforeEnd = (end, content) => {
|
|
264
|
+
const parentNode = startComment.parentNode;
|
|
265
|
+
if (!parentNode) return;
|
|
266
|
+
const insert = (v) => {
|
|
267
|
+
if (v === null || v === void 0 || typeof v === "boolean") return;
|
|
268
|
+
if (typeof v === "function") {
|
|
269
|
+
try {
|
|
270
|
+
if (isComponentThunk(v)) {
|
|
271
|
+
parentNode.insertBefore(v(), end);
|
|
272
|
+
} else {
|
|
273
|
+
insert(v());
|
|
274
|
+
}
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (typeof v === "string" || typeof v === "number") {
|
|
280
|
+
parentNode.insertBefore(document.createTextNode(String(v)), end);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (Array.isArray(v)) {
|
|
284
|
+
v.forEach((x) => insert(x));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (typeof v === "object" && v !== null && "nodeType" in v) {
|
|
288
|
+
parentNode.insertBefore(v, end);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
parentNode.insertBefore(document.createTextNode(String(v)), end);
|
|
292
|
+
};
|
|
293
|
+
insert(content);
|
|
294
|
+
};
|
|
295
|
+
const update = () => {
|
|
296
|
+
const parentNode = startComment.parentNode;
|
|
297
|
+
if (!parentNode) return;
|
|
298
|
+
const newContent = untrack(() => {
|
|
299
|
+
let v = typeof valueOrFunction === "function" ? valueOrFunction() : valueOrFunction;
|
|
300
|
+
try {
|
|
301
|
+
if (typeof v === "function") v = v();
|
|
302
|
+
} catch {
|
|
303
|
+
}
|
|
304
|
+
return v;
|
|
305
|
+
});
|
|
306
|
+
disposeBetween(startComment, endComment);
|
|
307
|
+
insertBeforeEnd(endComment, newContent);
|
|
308
|
+
};
|
|
309
|
+
update();
|
|
310
|
+
useEffect(update);
|
|
311
|
+
popComponentScope();
|
|
312
|
+
}
|
|
313
|
+
function addToParent(parent, child) {
|
|
314
|
+
if (child === null || child === void 0) return;
|
|
315
|
+
if (typeof child === "object" && child !== null && "nodeType" in child) {
|
|
316
|
+
parent.appendChild(child);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (typeof child === "function") {
|
|
320
|
+
createReactiveSection(parent, child);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
324
|
+
parent.appendChild(document.createTextNode(String(child)));
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (typeof child === "boolean") return;
|
|
328
|
+
const textNode = document.createTextNode(String(child));
|
|
329
|
+
parent.appendChild(textNode);
|
|
330
|
+
}
|
|
331
|
+
function appendChild(parent, child) {
|
|
332
|
+
if (Array.isArray(child)) {
|
|
333
|
+
child.forEach((nested) => appendChild(parent, nested));
|
|
334
|
+
} else {
|
|
335
|
+
addToParent(parent, child);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function Fragment({ children }) {
|
|
339
|
+
const fragment = document.createDocumentFragment();
|
|
340
|
+
if (children !== void 0) {
|
|
341
|
+
appendChild(fragment, children);
|
|
342
|
+
}
|
|
343
|
+
return fragment;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/runtime/Switch.ts
|
|
347
|
+
function Match() {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
function Switch(props) {
|
|
351
|
+
const fragment = document.createDocumentFragment();
|
|
352
|
+
const start = document.createComment("switch-s");
|
|
353
|
+
const end = document.createComment("switch-e");
|
|
354
|
+
fragment.appendChild(start);
|
|
355
|
+
fragment.appendChild(end);
|
|
356
|
+
const getParent = () => start.parentNode;
|
|
357
|
+
const toNode = (value) => {
|
|
358
|
+
if (typeof value === "function") {
|
|
359
|
+
try {
|
|
360
|
+
if (isComponentThunk(value)) {
|
|
361
|
+
return value();
|
|
362
|
+
}
|
|
363
|
+
return toNode(value());
|
|
364
|
+
} catch {
|
|
365
|
+
return document.createComment("error");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (value === null || value === void 0 || typeof value === "boolean") {
|
|
369
|
+
return document.createComment("");
|
|
370
|
+
}
|
|
371
|
+
if (typeof value === "object" && value !== null && "nodeType" in value)
|
|
372
|
+
return value;
|
|
373
|
+
if (Array.isArray(value)) {
|
|
374
|
+
const df = document.createDocumentFragment();
|
|
375
|
+
value.forEach((v) => df.appendChild(toNode(v)));
|
|
376
|
+
return df;
|
|
377
|
+
}
|
|
378
|
+
return document.createTextNode(String(value));
|
|
379
|
+
};
|
|
380
|
+
const flatten = (children) => {
|
|
381
|
+
if (children === null || children === void 0) return [];
|
|
382
|
+
return Array.isArray(children) ? children.flatMap((c) => flatten(c)) : [children];
|
|
383
|
+
};
|
|
384
|
+
const isMatchMarker = (child) => child !== null && typeof child === "object" && ("__isMatch" in child && child.__isMatch === true || "type" in child && child.type === Match || "$$typeof" in child && "type" in child && child.type === Match);
|
|
385
|
+
const update = () => {
|
|
386
|
+
const parent = getParent();
|
|
387
|
+
if (!parent) return;
|
|
388
|
+
disposeBetween(start, end);
|
|
389
|
+
const all = flatten(props.children);
|
|
390
|
+
const hasMatch = all.some((c) => isMatchMarker(c));
|
|
391
|
+
if (!hasMatch && props.fallback === void 0) {
|
|
392
|
+
throw ERRORS.SWITCH_NO_CHILDREN_OR_FALLBACK();
|
|
393
|
+
}
|
|
394
|
+
for (const child of all) {
|
|
395
|
+
if (isMatchMarker(child)) {
|
|
396
|
+
let cond = false;
|
|
397
|
+
try {
|
|
398
|
+
const whenProp = child?.props?.when;
|
|
399
|
+
cond = typeof whenProp === "function" ? whenProp() : Boolean(whenProp);
|
|
400
|
+
} catch {
|
|
401
|
+
cond = false;
|
|
402
|
+
}
|
|
403
|
+
if (cond) {
|
|
404
|
+
const node = untrack(
|
|
405
|
+
() => toNode(
|
|
406
|
+
child?.props?.children
|
|
407
|
+
)
|
|
408
|
+
);
|
|
409
|
+
parent.insertBefore(node, end);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (props.fallback !== void 0) {
|
|
415
|
+
const node = untrack(() => toNode(props.fallback));
|
|
416
|
+
parent.insertBefore(node, end);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
update();
|
|
420
|
+
useEffect(update);
|
|
421
|
+
return fragment;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// src/runtime/shared/warn.ts
|
|
425
|
+
var DEV = typeof import.meta !== "undefined" && import.meta.env && import.meta.env?.DEV || typeof process !== "undefined" && process.env && true;
|
|
426
|
+
function warn(condition, message) {
|
|
427
|
+
if (DEV && !condition) {
|
|
428
|
+
console.warn(`[ShadowJS] ${message}`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/runtime/jsx.ts
|
|
433
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
434
|
+
var XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
435
|
+
var SVG_ONLY_TAGS = /* @__PURE__ */ new Set([
|
|
436
|
+
"svg",
|
|
437
|
+
"g",
|
|
438
|
+
"path",
|
|
439
|
+
"rect",
|
|
440
|
+
"circle",
|
|
441
|
+
"ellipse",
|
|
442
|
+
"line",
|
|
443
|
+
"polyline",
|
|
444
|
+
"polygon",
|
|
445
|
+
"text",
|
|
446
|
+
"tspan",
|
|
447
|
+
"textPath",
|
|
448
|
+
"marker",
|
|
449
|
+
"defs",
|
|
450
|
+
"clipPath",
|
|
451
|
+
"mask",
|
|
452
|
+
"linearGradient",
|
|
453
|
+
"radialGradient",
|
|
454
|
+
"pattern",
|
|
455
|
+
"stop",
|
|
456
|
+
"filter",
|
|
457
|
+
"feBlend",
|
|
458
|
+
"feColorMatrix",
|
|
459
|
+
"feComponentTransfer",
|
|
460
|
+
"feComposite",
|
|
461
|
+
"feConvolveMatrix",
|
|
462
|
+
"feDiffuseLighting",
|
|
463
|
+
"feDisplacementMap",
|
|
464
|
+
"feDistantLight",
|
|
465
|
+
"feDropShadow",
|
|
466
|
+
"feFlood",
|
|
467
|
+
"feFuncA",
|
|
468
|
+
"feFuncB",
|
|
469
|
+
"feFuncG",
|
|
470
|
+
"feFuncR",
|
|
471
|
+
"feGaussianBlur",
|
|
472
|
+
"feImage",
|
|
473
|
+
"feMerge",
|
|
474
|
+
"feMergeNode",
|
|
475
|
+
"feMorphology",
|
|
476
|
+
"feOffset",
|
|
477
|
+
"fePointLight",
|
|
478
|
+
"feSpecularLighting",
|
|
479
|
+
"feSpotLight",
|
|
480
|
+
"feTile",
|
|
481
|
+
"feTurbulence",
|
|
482
|
+
"foreignObject",
|
|
483
|
+
"symbol",
|
|
484
|
+
"use",
|
|
485
|
+
"view",
|
|
486
|
+
"image",
|
|
487
|
+
"animate",
|
|
488
|
+
"animateTransform",
|
|
489
|
+
"animateMotion",
|
|
490
|
+
"mpath"
|
|
491
|
+
]);
|
|
492
|
+
var BOOLEAN_ATTRS = /* @__PURE__ */ new Set([
|
|
493
|
+
"checked",
|
|
494
|
+
"disabled",
|
|
495
|
+
"selected",
|
|
496
|
+
"readonly",
|
|
497
|
+
"required",
|
|
498
|
+
"hidden",
|
|
499
|
+
"multiple",
|
|
500
|
+
"autofocus",
|
|
501
|
+
"autoplay",
|
|
502
|
+
"controls",
|
|
503
|
+
"loop",
|
|
504
|
+
"muted",
|
|
505
|
+
"open",
|
|
506
|
+
"playsinline",
|
|
507
|
+
"inert"
|
|
508
|
+
]);
|
|
509
|
+
function appendContent(parent, before, value) {
|
|
510
|
+
const insert = (val) => {
|
|
511
|
+
if (val === null || val === void 0 || typeof val === "boolean") return;
|
|
512
|
+
if (typeof val === "function" && isComponentThunk(val)) {
|
|
513
|
+
try {
|
|
514
|
+
const node = val();
|
|
515
|
+
parent.insertBefore(node, before);
|
|
516
|
+
} catch {
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (typeof val === "function") {
|
|
521
|
+
try {
|
|
522
|
+
insert(val());
|
|
523
|
+
} catch {
|
|
524
|
+
}
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (typeof val === "object" && val !== null && "nodeType" in val) {
|
|
528
|
+
parent.insertBefore(val, before);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (Array.isArray(val)) {
|
|
532
|
+
val.forEach((x) => insert(x));
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
parent.insertBefore(document.createTextNode(String(val)), before);
|
|
536
|
+
};
|
|
537
|
+
insert(value);
|
|
538
|
+
}
|
|
539
|
+
function createComponentThunk(tag, props, children) {
|
|
540
|
+
const thunk = /* @__PURE__ */ (() => {
|
|
541
|
+
return () => {
|
|
542
|
+
const scope = pushComponentScope();
|
|
543
|
+
const frag = document.createDocumentFragment();
|
|
544
|
+
const start = document.createComment("comp-s");
|
|
545
|
+
const end = document.createComment("comp-e");
|
|
546
|
+
frag.appendChild(start);
|
|
547
|
+
frag.appendChild(end);
|
|
548
|
+
markComponentBoundary(start, end, scope);
|
|
549
|
+
let result;
|
|
550
|
+
let threwThenable = null;
|
|
551
|
+
try {
|
|
552
|
+
result = tag({
|
|
553
|
+
...props,
|
|
554
|
+
children
|
|
555
|
+
});
|
|
556
|
+
} catch (err) {
|
|
557
|
+
if (err && typeof err.then === "function") {
|
|
558
|
+
threwThenable = err;
|
|
559
|
+
} else {
|
|
560
|
+
popComponentScope();
|
|
561
|
+
throw err;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const parentAppendResolved = (resolved) => {
|
|
565
|
+
const parent2 = start.parentNode;
|
|
566
|
+
if (!parent2) return;
|
|
567
|
+
let nodeOrValue = resolved;
|
|
568
|
+
if (typeof resolved === "function" && !isComponentThunk(resolved)) {
|
|
569
|
+
nodeOrValue = runInScope(
|
|
570
|
+
scope,
|
|
571
|
+
() => resolved({
|
|
572
|
+
...props,
|
|
573
|
+
children
|
|
574
|
+
})
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
appendContent(parent2, end, nodeOrValue);
|
|
578
|
+
};
|
|
579
|
+
if (result && typeof result.then === "function") {
|
|
580
|
+
result.then(
|
|
581
|
+
(r) => parentAppendResolved(r),
|
|
582
|
+
() => {
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
popComponentScope();
|
|
586
|
+
return frag;
|
|
587
|
+
}
|
|
588
|
+
if (threwThenable) {
|
|
589
|
+
threwThenable.then(
|
|
590
|
+
(r) => parentAppendResolved(r),
|
|
591
|
+
() => {
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
popComponentScope();
|
|
595
|
+
return frag;
|
|
596
|
+
}
|
|
597
|
+
const parent = frag;
|
|
598
|
+
appendContent(parent, end, result);
|
|
599
|
+
popComponentScope();
|
|
600
|
+
return frag;
|
|
601
|
+
};
|
|
602
|
+
})();
|
|
603
|
+
thunk.__isComponent = true;
|
|
604
|
+
return thunk;
|
|
605
|
+
}
|
|
606
|
+
var __collectingDeps = false;
|
|
607
|
+
function createReactiveSection2(parent, valueOrFunction) {
|
|
608
|
+
const start = document.createComment("r-s");
|
|
609
|
+
const end = document.createComment("r-e");
|
|
610
|
+
parent.appendChild(start);
|
|
611
|
+
parent.appendChild(end);
|
|
612
|
+
const regionScope = pushComponentScope();
|
|
613
|
+
markComponentBoundary(start, end, regionScope);
|
|
614
|
+
const update = () => {
|
|
615
|
+
const p = start.parentNode;
|
|
616
|
+
if (!p) return;
|
|
617
|
+
if (typeof valueOrFunction === "function") {
|
|
618
|
+
try {
|
|
619
|
+
__collectingDeps = true;
|
|
620
|
+
valueOrFunction();
|
|
621
|
+
} catch (err) {
|
|
622
|
+
if (!err || typeof err.then !== "function") ;
|
|
623
|
+
} finally {
|
|
624
|
+
__collectingDeps = false;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const next = untrack(() => {
|
|
628
|
+
let v = typeof valueOrFunction === "function" ? valueOrFunction() : valueOrFunction;
|
|
629
|
+
try {
|
|
630
|
+
if (typeof v === "function") v = v();
|
|
631
|
+
} catch {
|
|
632
|
+
}
|
|
633
|
+
return v;
|
|
634
|
+
});
|
|
635
|
+
disposeBetween(start, end);
|
|
636
|
+
untrack(() => appendContent(p, end, next));
|
|
637
|
+
};
|
|
638
|
+
update();
|
|
639
|
+
useEffect(update);
|
|
640
|
+
popComponentScope();
|
|
641
|
+
}
|
|
642
|
+
function applyProp(el, rawName, value, isSvg) {
|
|
643
|
+
if (rawName === "ref") return;
|
|
644
|
+
if (rawName.startsWith("on")) return;
|
|
645
|
+
const name = rawName === "className" ? "class" : rawName === "htmlFor" ? "for" : rawName;
|
|
646
|
+
if (typeof value === "function" && !value.__isStore) {
|
|
647
|
+
useEffect(() => {
|
|
648
|
+
setProp(el, name, value(), isSvg);
|
|
649
|
+
});
|
|
650
|
+
} else if (typeof value === "function" && value.__isStore) {
|
|
651
|
+
useEffect(() => {
|
|
652
|
+
setProp(el, name, value(), isSvg);
|
|
653
|
+
});
|
|
654
|
+
} else {
|
|
655
|
+
setProp(el, name, value, isSvg);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function setProp(el, name, value, isSvg) {
|
|
659
|
+
if (name === "dangerouslySetInnerHTML") {
|
|
660
|
+
const html = value && typeof value === "object" && value !== null ? String(value.__html ?? "") : "";
|
|
661
|
+
el.innerHTML = html;
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (name === "class") {
|
|
665
|
+
if (value == null || value === false) {
|
|
666
|
+
if (isSvg) el.removeAttribute("class");
|
|
667
|
+
else el.className = "";
|
|
668
|
+
} else {
|
|
669
|
+
const next = Array.isArray(value) || value instanceof Set ? Array.from(value).join(" ") : String(value);
|
|
670
|
+
if (isSvg) el.setAttribute("class", next);
|
|
671
|
+
else el.className = next;
|
|
672
|
+
}
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (name === "style") {
|
|
676
|
+
const style = el.style;
|
|
677
|
+
if (value == null || value === false) {
|
|
678
|
+
el.removeAttribute("style");
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (typeof value === "string") {
|
|
682
|
+
style.cssText = value;
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
if (typeof value === "object") {
|
|
686
|
+
for (const [k, v] of Object.entries(value)) {
|
|
687
|
+
style[k] = String(v);
|
|
688
|
+
}
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
el.setAttribute("style", String(value));
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (name === "value" && "value" in el) {
|
|
695
|
+
if (el.value !== (value ?? "")) {
|
|
696
|
+
el.value = String(value ?? "");
|
|
697
|
+
}
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
if (name === "checked" && "checked" in el) {
|
|
701
|
+
el.checked = !!value;
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
if (name === "selected" && "selected" in el) {
|
|
705
|
+
el.selected = !!value;
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if (name === "muted" && "muted" in el) {
|
|
709
|
+
el.muted = !!value;
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (BOOLEAN_ATTRS.has(name)) {
|
|
713
|
+
if (value) {
|
|
714
|
+
el.setAttribute(name, "");
|
|
715
|
+
} else {
|
|
716
|
+
el.removeAttribute(name);
|
|
717
|
+
}
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (name.startsWith("data-") || name.startsWith("aria-")) {
|
|
721
|
+
if (value == null || value === false) el.removeAttribute(name);
|
|
722
|
+
else el.setAttribute(name, String(value));
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (name.startsWith("xlink:")) {
|
|
726
|
+
const local = name.slice(6);
|
|
727
|
+
if (value == null || value === false)
|
|
728
|
+
el.removeAttributeNS(XLINK_NS, local);
|
|
729
|
+
else el.setAttributeNS(XLINK_NS, name, String(value));
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (value == null || value === false) {
|
|
733
|
+
el.removeAttribute(name);
|
|
734
|
+
} else {
|
|
735
|
+
el.setAttribute(name, String(value));
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function createDomElement(tag) {
|
|
739
|
+
let t = tag;
|
|
740
|
+
let forceSvg = false;
|
|
741
|
+
if (t.startsWith("svg:")) {
|
|
742
|
+
forceSvg = true;
|
|
743
|
+
t = t.slice(4);
|
|
744
|
+
}
|
|
745
|
+
const isSvgTag = t === "svg" || SVG_ONLY_TAGS.has(t);
|
|
746
|
+
if (forceSvg || isSvgTag) {
|
|
747
|
+
return document.createElementNS(SVG_NS, t);
|
|
748
|
+
}
|
|
749
|
+
return document.createElement(t);
|
|
750
|
+
}
|
|
751
|
+
var __eventMap = /* @__PURE__ */ new WeakMap();
|
|
752
|
+
function getEventMap(el) {
|
|
753
|
+
let m = __eventMap.get(el);
|
|
754
|
+
if (!m) {
|
|
755
|
+
m = /* @__PURE__ */ new Map();
|
|
756
|
+
__eventMap.set(el, m);
|
|
757
|
+
}
|
|
758
|
+
return m;
|
|
759
|
+
}
|
|
760
|
+
function bindEvent(el, rawName, value) {
|
|
761
|
+
const eventName = rawName.toLowerCase().slice(2);
|
|
762
|
+
const map = getEventMap(el);
|
|
763
|
+
let binding = map.get(eventName);
|
|
764
|
+
if (!binding) {
|
|
765
|
+
const state = {
|
|
766
|
+
listener: (e) => {
|
|
767
|
+
if (state.handler) {
|
|
768
|
+
try {
|
|
769
|
+
state.handler(e);
|
|
770
|
+
} catch {
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
handler: null
|
|
775
|
+
};
|
|
776
|
+
el.addEventListener(eventName, state.listener);
|
|
777
|
+
map.set(eventName, state);
|
|
778
|
+
binding = state;
|
|
779
|
+
onCleanup(() => {
|
|
780
|
+
try {
|
|
781
|
+
el.removeEventListener(eventName, state.listener);
|
|
782
|
+
} catch {
|
|
783
|
+
}
|
|
784
|
+
map.delete(eventName);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
if (typeof value === "function" && value.__isStore) {
|
|
788
|
+
useEffect(() => {
|
|
789
|
+
const next = value();
|
|
790
|
+
const rec = map.get(eventName);
|
|
791
|
+
rec.handler = typeof next === "function" ? next : null;
|
|
792
|
+
});
|
|
793
|
+
} else {
|
|
794
|
+
binding.handler = typeof value === "function" ? value : null;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
var jsx = (tag, props = {}) => {
|
|
798
|
+
const { children, ...otherProps } = props || {};
|
|
799
|
+
if (tag === Match) {
|
|
800
|
+
return {
|
|
801
|
+
__isMatch: true,
|
|
802
|
+
type: Match,
|
|
803
|
+
props: { ...otherProps, children }
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (typeof tag === "function") {
|
|
807
|
+
if (__collectingDeps) {
|
|
808
|
+
const noop = (() => document.createComment("collect"));
|
|
809
|
+
noop.__isComponent = true;
|
|
810
|
+
return noop;
|
|
811
|
+
}
|
|
812
|
+
return createComponentThunk(
|
|
813
|
+
tag,
|
|
814
|
+
otherProps,
|
|
815
|
+
children
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
if (typeof tag !== "string") {
|
|
819
|
+
throw ERRORS.JSX_INVALID_TAG(tag);
|
|
820
|
+
}
|
|
821
|
+
const element = createDomElement(tag);
|
|
822
|
+
const isSvg = element.namespaceURI === SVG_NS;
|
|
823
|
+
Object.entries(otherProps).forEach(
|
|
824
|
+
([rawName, rawValue]) => {
|
|
825
|
+
if (rawName === "ref") {
|
|
826
|
+
if (typeof rawValue === "function") {
|
|
827
|
+
try {
|
|
828
|
+
rawValue(element);
|
|
829
|
+
} catch {
|
|
830
|
+
}
|
|
831
|
+
} else if (rawValue && typeof rawValue === "object" && "current" in rawValue) {
|
|
832
|
+
try {
|
|
833
|
+
rawValue.current = element;
|
|
834
|
+
} catch {
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
if (rawName.startsWith("on")) {
|
|
840
|
+
bindEvent(element, rawName, rawValue);
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
applyProp(element, rawName, rawValue, isSvg);
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
if ("dangerouslySetInnerHTML" in otherProps && children !== void 0) {
|
|
847
|
+
warn(
|
|
848
|
+
false,
|
|
849
|
+
"Both children and dangerouslySetInnerHTML were provided. dangerouslySetInnerHTML will be used and children are ignored."
|
|
850
|
+
);
|
|
851
|
+
return element;
|
|
852
|
+
}
|
|
853
|
+
if (children !== void 0) {
|
|
854
|
+
if (typeof children === "function") {
|
|
855
|
+
createReactiveSection2(element, children);
|
|
856
|
+
} else if (Array.isArray(children)) {
|
|
857
|
+
children.forEach((c) => {
|
|
858
|
+
if (typeof c === "function") {
|
|
859
|
+
if (isComponentThunk(c)) {
|
|
860
|
+
try {
|
|
861
|
+
const node = c();
|
|
862
|
+
element.appendChild(node);
|
|
863
|
+
} catch {
|
|
864
|
+
}
|
|
865
|
+
} else {
|
|
866
|
+
createReactiveSection2(element, c);
|
|
867
|
+
}
|
|
868
|
+
} else if (c?.nodeType) {
|
|
869
|
+
element.appendChild(c);
|
|
870
|
+
} else if (c != null) {
|
|
871
|
+
element.appendChild(document.createTextNode(String(c)));
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
} else if (typeof children === "object" && children !== null && "nodeType" in children) {
|
|
875
|
+
element.appendChild(children);
|
|
876
|
+
} else if (children != null) {
|
|
877
|
+
element.appendChild(document.createTextNode(String(children)));
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return element;
|
|
881
|
+
};
|
|
882
|
+
var jsxs = jsx;
|
|
883
|
+
var jsxDEV = jsx;
|
|
884
|
+
|
|
885
|
+
export { ERRORS, Fragment, Match, Switch, __currentEffect, __currentEffectDeps, disposeAllChildren, disposeBetween, getCurrentScope, isComponentThunk, jsx, jsxDEV, jsxs, onCleanup, untrack, useEffect, warn };
|
|
886
|
+
//# sourceMappingURL=chunk-6Y3CCWOY.js.map
|
|
887
|
+
//# sourceMappingURL=chunk-6Y3CCWOY.js.map
|