loly-jsx 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/README.md +361 -0
- package/dist/dev-runtime-CEyE3QDn.js +207 -0
- package/dist/dev-runtime-CEyE3QDn.js.map +1 -0
- package/dist/dev-runtime-CRAwY4ll.cjs +2 -0
- package/dist/dev-runtime-CRAwY4ll.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1206 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +2 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.js +8 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +2 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/render-manifest.cjs +2 -0
- package/dist/render-manifest.cjs.map +1 -0
- package/dist/render-manifest.js +14 -0
- package/dist/render-manifest.js.map +1 -0
- package/package.json +93 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
import { s as v, g as O, d as z, i as b, a as S, c as dt, n as k, b as C, F as Q, e as ft, j, o as It, f as x } from "./dev-runtime-CEyE3QDn.js";
|
|
2
|
+
import { h as je, k as Re } from "./dev-runtime-CEyE3QDn.js";
|
|
3
|
+
const U = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
let Tt = 0;
|
|
5
|
+
function vt() {
|
|
6
|
+
return `store-${Date.now()}-${Math.random().toString(36).slice(2)}-${Tt++}`;
|
|
7
|
+
}
|
|
8
|
+
const Dt = /* @__PURE__ */ new Map(), it = /* @__PURE__ */ new WeakMap(), R = [], tt = () => R[R.length - 1];
|
|
9
|
+
function Nt() {
|
|
10
|
+
const t = tt(), e = t ? new Map(t) : /* @__PURE__ */ new Map();
|
|
11
|
+
R.push(e);
|
|
12
|
+
}
|
|
13
|
+
function Y() {
|
|
14
|
+
R.pop();
|
|
15
|
+
}
|
|
16
|
+
function kt(t, e) {
|
|
17
|
+
Dt.set(t, e);
|
|
18
|
+
}
|
|
19
|
+
function Ct(t, e, r, n) {
|
|
20
|
+
const s = tt();
|
|
21
|
+
if (s)
|
|
22
|
+
O().enableWarnings && s.has(e) && console.warn("[loly][store] shadowing scoped store detected; consider different store instance"), s.set(e, r);
|
|
23
|
+
else {
|
|
24
|
+
const o = /* @__PURE__ */ new Map();
|
|
25
|
+
o.set(e, r), R.push(o);
|
|
26
|
+
}
|
|
27
|
+
let i = U.get(t);
|
|
28
|
+
i || (i = /* @__PURE__ */ new Map(), U.set(t, i)), i.set(e, r), pt.set(e, t), e.__storeId && n !== void 0 && kt(e.__storeId, n);
|
|
29
|
+
}
|
|
30
|
+
function K(t) {
|
|
31
|
+
const e = tt();
|
|
32
|
+
if (e != null && e.has(t))
|
|
33
|
+
return console.log("[findScopedStore] Found in active stack"), e.get(t);
|
|
34
|
+
const r = pt.get(t);
|
|
35
|
+
if (r) {
|
|
36
|
+
const s = U.get(r);
|
|
37
|
+
if (s != null && s.has(t))
|
|
38
|
+
return console.log("[findScopedStore] Found in vnode context"), s.get(t);
|
|
39
|
+
}
|
|
40
|
+
const n = it.get(t);
|
|
41
|
+
if (n)
|
|
42
|
+
return console.log("[findScopedStore] Found in global registry"), n;
|
|
43
|
+
if (typeof window < "u" && t.__storeId) {
|
|
44
|
+
const s = window.__LOLY_STORE_DATA__;
|
|
45
|
+
if (s && s[t.__storeId]) {
|
|
46
|
+
const i = s[t.__storeId], [o] = v(i);
|
|
47
|
+
return it.set(t, o), delete s[t.__storeId], o;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function yt(t) {
|
|
53
|
+
return K(t);
|
|
54
|
+
}
|
|
55
|
+
function le(t, e) {
|
|
56
|
+
const [r, n] = v(t), s = e || vt();
|
|
57
|
+
return e || console.warn("[loly][store] storeId is required for SSR/client serialization"), {
|
|
58
|
+
__isStore: !0,
|
|
59
|
+
__defaultValue: t,
|
|
60
|
+
__globalSignal: r,
|
|
61
|
+
__storeId: s,
|
|
62
|
+
get() {
|
|
63
|
+
const i = K(this);
|
|
64
|
+
return i ? i() : r();
|
|
65
|
+
},
|
|
66
|
+
set(i) {
|
|
67
|
+
const o = K(this);
|
|
68
|
+
if (o) {
|
|
69
|
+
const a = o.get();
|
|
70
|
+
o.set(i), O().enableDevtools && z("store", "debug", "store:update(scoped)", { prev: a, next: o.get() });
|
|
71
|
+
} else {
|
|
72
|
+
const a = r.get();
|
|
73
|
+
n(i), O().enableDevtools && z("store", "debug", "store:update(global)", { prev: a, next: r.get() });
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
update(i) {
|
|
77
|
+
this.set(i(this.get()));
|
|
78
|
+
},
|
|
79
|
+
reset() {
|
|
80
|
+
this.set(this.__defaultValue);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const et = /* @__PURE__ */ new Map();
|
|
85
|
+
function ue(t, e) {
|
|
86
|
+
return et.set(t, e), e.__islandName = t, e;
|
|
87
|
+
}
|
|
88
|
+
function Ot(t) {
|
|
89
|
+
return et.get(t);
|
|
90
|
+
}
|
|
91
|
+
function de() {
|
|
92
|
+
return Array.from(et.keys());
|
|
93
|
+
}
|
|
94
|
+
function nt(t) {
|
|
95
|
+
return !!t && typeof t == "object" && t.__kind === "for";
|
|
96
|
+
}
|
|
97
|
+
function fe(t) {
|
|
98
|
+
const e = t.key ?? ((s, i) => i), n = Array.isArray(t.children) ? t.children[0] : t.children;
|
|
99
|
+
if (typeof n != "function")
|
|
100
|
+
throw new Error("<For> expects a render function as its child");
|
|
101
|
+
if (!b(t.each) && !S(t.each))
|
|
102
|
+
throw new Error("<For> each prop must be a signal or computed");
|
|
103
|
+
return {
|
|
104
|
+
__kind: "for",
|
|
105
|
+
source: t.each,
|
|
106
|
+
renderItem: n,
|
|
107
|
+
getKey: e
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function pe(t, e, r) {
|
|
111
|
+
if (typeof e != "function")
|
|
112
|
+
throw new Error("forBlock renderItem must be a function");
|
|
113
|
+
return {
|
|
114
|
+
__kind: "for",
|
|
115
|
+
source: t,
|
|
116
|
+
renderItem: e,
|
|
117
|
+
getKey: r
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
let ht = null;
|
|
121
|
+
function T(t) {
|
|
122
|
+
ht = t;
|
|
123
|
+
}
|
|
124
|
+
function q() {
|
|
125
|
+
return ht;
|
|
126
|
+
}
|
|
127
|
+
function P() {
|
|
128
|
+
return {
|
|
129
|
+
id: crypto.randomUUID(),
|
|
130
|
+
onMount: [],
|
|
131
|
+
onUnmount: [],
|
|
132
|
+
cleanup: []
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function N(t, e) {
|
|
136
|
+
t.__instance = e, e.vnode = t;
|
|
137
|
+
}
|
|
138
|
+
function ye(t) {
|
|
139
|
+
return () => t();
|
|
140
|
+
}
|
|
141
|
+
function jt(t) {
|
|
142
|
+
var e;
|
|
143
|
+
(e = q()) == null || e.onMount.push(t);
|
|
144
|
+
}
|
|
145
|
+
function gt(t) {
|
|
146
|
+
var e;
|
|
147
|
+
(e = q()) == null || e.onUnmount.push(t);
|
|
148
|
+
}
|
|
149
|
+
function he(t) {
|
|
150
|
+
var e;
|
|
151
|
+
(e = q()) == null || e.cleanup.push(t);
|
|
152
|
+
}
|
|
153
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
154
|
+
function E(t, e) {
|
|
155
|
+
(Array.isArray(t) ? t : [t]).forEach((n) => {
|
|
156
|
+
const s = V.get(n);
|
|
157
|
+
s ? s.push(e) : V.set(n, [e]);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function Rt(t) {
|
|
161
|
+
const e = V.get(t);
|
|
162
|
+
e && e.length && (V.delete(t), e.forEach((r) => {
|
|
163
|
+
try {
|
|
164
|
+
r();
|
|
165
|
+
} catch (n) {
|
|
166
|
+
console.error("[loly] cleanup error", n);
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
function mt(t) {
|
|
171
|
+
Rt(t), t.childNodes.forEach((e) => mt(e));
|
|
172
|
+
}
|
|
173
|
+
function _t(t, e = !0) {
|
|
174
|
+
t.forEach((r) => {
|
|
175
|
+
var n;
|
|
176
|
+
mt(r), e && ((n = r.parentNode) == null || n.removeChild(r));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function Mt(t, e) {
|
|
180
|
+
const r = [];
|
|
181
|
+
$(t, e, r), r.forEach((n) => n());
|
|
182
|
+
}
|
|
183
|
+
function $(t, e, r) {
|
|
184
|
+
var o, a;
|
|
185
|
+
if (Array.isArray(t)) {
|
|
186
|
+
const l = [];
|
|
187
|
+
return k(t).forEach((c) => {
|
|
188
|
+
l.push(...$(c, e, r));
|
|
189
|
+
}), l;
|
|
190
|
+
}
|
|
191
|
+
if (b(t) || S(t)) {
|
|
192
|
+
const l = document.createComment("loly:signal");
|
|
193
|
+
e.appendChild(l);
|
|
194
|
+
let c = [];
|
|
195
|
+
const u = () => (b(t), t.get()), p = (y) => {
|
|
196
|
+
_t(c), c = [];
|
|
197
|
+
const d = document.createDocumentFragment();
|
|
198
|
+
$(y, d, r);
|
|
199
|
+
const g = Array.from(d.childNodes);
|
|
200
|
+
l.parentNode === e && l.parentNode !== null ? e.insertBefore(d, l) : e.appendChild(d), c = g;
|
|
201
|
+
}, h = () => p(u());
|
|
202
|
+
p(u());
|
|
203
|
+
const f = (b(t), t.subscribe)(h);
|
|
204
|
+
return E(l, f), [l, ...c];
|
|
205
|
+
}
|
|
206
|
+
if (typeof t == "function")
|
|
207
|
+
return $(dt(t), e, r), [];
|
|
208
|
+
if (typeof t == "string" || typeof t == "number") {
|
|
209
|
+
const l = document.createTextNode(String(t));
|
|
210
|
+
return e.appendChild(l), [l];
|
|
211
|
+
}
|
|
212
|
+
if (t == null || t === !1 || t === !0) return [];
|
|
213
|
+
if (nt(t))
|
|
214
|
+
return Ht(t, e, r);
|
|
215
|
+
if (!C(t)) return [];
|
|
216
|
+
if (typeof t.type == "function") {
|
|
217
|
+
Nt();
|
|
218
|
+
const l = t.type.__isErrorBoundary === !0, c = P();
|
|
219
|
+
N(t, c), O().enableDevtools && t.__islandDirective && z("island", "info", "island:activate", { name: (o = t.type) == null ? void 0 : o.name, directive: t.__islandDirective }), T(c);
|
|
220
|
+
let u;
|
|
221
|
+
try {
|
|
222
|
+
u = t.type({
|
|
223
|
+
...t.props,
|
|
224
|
+
children: t.children
|
|
225
|
+
});
|
|
226
|
+
} catch (f) {
|
|
227
|
+
if (T(null), l) {
|
|
228
|
+
const y = t.props, d = f instanceof Error ? f : new Error(String(f));
|
|
229
|
+
(a = y.onError) == null || a.call(y, d, null);
|
|
230
|
+
const g = y.fallback ? y.fallback(d) : null, m = g ? $(g, e, r) : [];
|
|
231
|
+
return Y(), m;
|
|
232
|
+
}
|
|
233
|
+
throw Y(), f;
|
|
234
|
+
}
|
|
235
|
+
T(null);
|
|
236
|
+
const p = (() => {
|
|
237
|
+
var f;
|
|
238
|
+
if (l)
|
|
239
|
+
try {
|
|
240
|
+
return $(u, e, r);
|
|
241
|
+
} catch (y) {
|
|
242
|
+
const d = t.props, g = y instanceof Error ? y : new Error(String(y));
|
|
243
|
+
(f = d.onError) == null || f.call(d, g, null);
|
|
244
|
+
const m = d.fallback ? d.fallback(g) : null;
|
|
245
|
+
return m ? $(m, e, r) : [];
|
|
246
|
+
}
|
|
247
|
+
return $(u, e, r);
|
|
248
|
+
})(), h = p.length ? p : [document.createComment("loly:empty")];
|
|
249
|
+
if (p.length || h.forEach((f) => e.appendChild(f)), c.onMount.length && r.push(...c.onMount), c.onUnmount.length || c.cleanup.length) {
|
|
250
|
+
let f = !1;
|
|
251
|
+
E(h, () => {
|
|
252
|
+
f || (f = !0, c.onUnmount.forEach((d) => {
|
|
253
|
+
try {
|
|
254
|
+
d();
|
|
255
|
+
} catch (g) {
|
|
256
|
+
console.error("[loly] onUnmount error", g);
|
|
257
|
+
}
|
|
258
|
+
}), c.cleanup.forEach((d) => {
|
|
259
|
+
try {
|
|
260
|
+
d();
|
|
261
|
+
} catch (g) {
|
|
262
|
+
console.error("[loly] cleanup error", g);
|
|
263
|
+
}
|
|
264
|
+
}));
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return Y(), h;
|
|
268
|
+
}
|
|
269
|
+
if (t.type === Q) {
|
|
270
|
+
const l = [];
|
|
271
|
+
return k(t.children).forEach((c) => {
|
|
272
|
+
l.push(...$(c, e, r));
|
|
273
|
+
}), l;
|
|
274
|
+
}
|
|
275
|
+
const n = document.createElement(t.type), s = t.props.dangerouslySetInnerHTML;
|
|
276
|
+
return s && s.__html ? n.innerHTML = s.__html : (Vt(n, t.props), k(t.children).forEach((l) => {
|
|
277
|
+
$(l, n, r);
|
|
278
|
+
})), e.appendChild(n), [n];
|
|
279
|
+
}
|
|
280
|
+
function Pt(t) {
|
|
281
|
+
return Object.entries(t).map(([e, r]) => `${e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`)}:${r}`).join(";");
|
|
282
|
+
}
|
|
283
|
+
function Vt(t, e) {
|
|
284
|
+
for (const [r, n] of Object.entries(e)) {
|
|
285
|
+
if (r === "children") continue;
|
|
286
|
+
const s = r === "className" ? "class" : r;
|
|
287
|
+
if (r.startsWith("on") && typeof n == "function") {
|
|
288
|
+
const i = r.slice(2).toLowerCase();
|
|
289
|
+
t.addEventListener(i, n), E(
|
|
290
|
+
t,
|
|
291
|
+
() => t.removeEventListener(i, n)
|
|
292
|
+
);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (r === "value" && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement))
|
|
296
|
+
if (b(n) || S(n)) {
|
|
297
|
+
O().enableWarnings && console.warn("[loly][warn] Passing a signal directly as value=. Usa value={signal()} o bind via onInput");
|
|
298
|
+
const i = () => (b(n), n.get());
|
|
299
|
+
t.value = String(i() ?? "");
|
|
300
|
+
const o = n.subscribe(() => {
|
|
301
|
+
t.value = String(i() ?? "");
|
|
302
|
+
});
|
|
303
|
+
E(t, o);
|
|
304
|
+
continue;
|
|
305
|
+
} else {
|
|
306
|
+
t.value = String(n ?? "");
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (r === "checked" && t instanceof HTMLInputElement)
|
|
310
|
+
if (b(n) || S(n)) {
|
|
311
|
+
const i = () => (b(n), n.get());
|
|
312
|
+
t.checked = !!i();
|
|
313
|
+
const o = n.subscribe(() => {
|
|
314
|
+
t.checked = !!i();
|
|
315
|
+
});
|
|
316
|
+
E(t, o);
|
|
317
|
+
continue;
|
|
318
|
+
} else {
|
|
319
|
+
t.checked = !!n;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (r === "style") {
|
|
323
|
+
const i = (o) => {
|
|
324
|
+
if (typeof o == "object" && o !== null) {
|
|
325
|
+
const a = Pt(
|
|
326
|
+
o
|
|
327
|
+
);
|
|
328
|
+
t.setAttribute("style", a);
|
|
329
|
+
} else o == null ? t.removeAttribute("style") : t.setAttribute("style", String(o));
|
|
330
|
+
};
|
|
331
|
+
if (b(n) || S(n)) {
|
|
332
|
+
const o = () => (b(n), n.get());
|
|
333
|
+
i(o());
|
|
334
|
+
const a = n.subscribe(() => i(o()));
|
|
335
|
+
E(t, a);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (typeof n == "object" && n !== null) {
|
|
339
|
+
const o = n;
|
|
340
|
+
if (Object.values(o).some(
|
|
341
|
+
(l) => typeof l == "function" || b(l) || S(l)
|
|
342
|
+
)) {
|
|
343
|
+
const l = dt(() => {
|
|
344
|
+
const p = {};
|
|
345
|
+
for (const [h, f] of Object.entries(o))
|
|
346
|
+
b(f) || S(f) ? p[h] = f.get() : typeof f == "function" ? p[h] = f() : p[h] = f;
|
|
347
|
+
return p;
|
|
348
|
+
}), c = () => l.get();
|
|
349
|
+
i(c());
|
|
350
|
+
const u = l.subscribe(
|
|
351
|
+
() => i(c())
|
|
352
|
+
);
|
|
353
|
+
E(t, u);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
i(n);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (s === "disabled") {
|
|
361
|
+
const i = (o) => {
|
|
362
|
+
const a = !o || o === "false", l = t;
|
|
363
|
+
a ? (l.disabled = !1, t.removeAttribute("disabled")) : (l.disabled = !0, t.setAttribute("disabled", "true"));
|
|
364
|
+
};
|
|
365
|
+
if (b(n) || S(n)) {
|
|
366
|
+
const o = () => (b(n), n.get());
|
|
367
|
+
i(o());
|
|
368
|
+
const a = n.subscribe(() => i(o()));
|
|
369
|
+
E(t, a);
|
|
370
|
+
continue;
|
|
371
|
+
} else {
|
|
372
|
+
i(n);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (b(n) || S(n)) {
|
|
377
|
+
const i = () => (b(n), n.get());
|
|
378
|
+
t.setAttribute(s, String(i()));
|
|
379
|
+
const o = n.subscribe(
|
|
380
|
+
() => t.setAttribute(s, String(i()))
|
|
381
|
+
);
|
|
382
|
+
E(t, o);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
typeof n != "function" && t.setAttribute(s, String(n));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function Ht(t, e, r) {
|
|
389
|
+
const n = document.createComment("loly:for:start"), s = document.createComment("loly:for:end");
|
|
390
|
+
e.appendChild(n), e.appendChild(s);
|
|
391
|
+
let i = [];
|
|
392
|
+
const o = (c) => {
|
|
393
|
+
const u = /* @__PURE__ */ new Map();
|
|
394
|
+
i.forEach((f) => u.set(f.key, f));
|
|
395
|
+
const p = [];
|
|
396
|
+
let h = s;
|
|
397
|
+
for (let f = c.length - 1; f >= 0; f--) {
|
|
398
|
+
const y = c[f], d = t.getKey(y, f), g = u.get(d);
|
|
399
|
+
let m = [];
|
|
400
|
+
if (g) {
|
|
401
|
+
m = g.nodes, u.delete(d);
|
|
402
|
+
const _ = m[0];
|
|
403
|
+
_ && _.nextSibling !== h && (h.parentNode === e && h.parentNode !== null ? m.forEach((w) => e.insertBefore(w, h)) : m.forEach((w) => e.appendChild(w)));
|
|
404
|
+
} else {
|
|
405
|
+
const _ = document.createDocumentFragment(), w = t.source;
|
|
406
|
+
m = $(
|
|
407
|
+
t.renderItem(y, {
|
|
408
|
+
remove: () => {
|
|
409
|
+
if (b(w)) {
|
|
410
|
+
const A = w.get(), D = A.filter((M, J) => t.getKey(A[J], J) !== d);
|
|
411
|
+
w.set(D);
|
|
412
|
+
} else
|
|
413
|
+
console.warn(
|
|
414
|
+
"ctx.remove() is not supported when <For> uses a computed source. Handle removal manually."
|
|
415
|
+
);
|
|
416
|
+
},
|
|
417
|
+
index: () => w.get().findIndex(
|
|
418
|
+
(D, M) => t.getKey(D, M) === d
|
|
419
|
+
)
|
|
420
|
+
}),
|
|
421
|
+
_,
|
|
422
|
+
r
|
|
423
|
+
), m = m.length ? m : Array.from(_.childNodes), _.childNodes.length && (h.parentNode === e && h.parentNode !== null ? e.insertBefore(_, h) : e.appendChild(_));
|
|
424
|
+
}
|
|
425
|
+
h = m[0] ?? h, p.unshift({ key: d, nodes: m, item: y });
|
|
426
|
+
}
|
|
427
|
+
u.forEach((f) => _t(f.nodes)), i = p;
|
|
428
|
+
}, a = t.source.get();
|
|
429
|
+
o(a);
|
|
430
|
+
const l = t.source.subscribe((c) => {
|
|
431
|
+
o(c);
|
|
432
|
+
});
|
|
433
|
+
return E(s, l), [n, s];
|
|
434
|
+
}
|
|
435
|
+
function qt(t) {
|
|
436
|
+
return t && (t.startsWith("media:") || t === "idle" || t === "visible" || t === "load") ? t : "load";
|
|
437
|
+
}
|
|
438
|
+
function Jt(t, e, r) {
|
|
439
|
+
if (e === "load") {
|
|
440
|
+
r();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (e === "idle") {
|
|
444
|
+
"requestIdleCallback" in window ? window.requestIdleCallback(r) : setTimeout(r, 0);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (e === "visible") {
|
|
448
|
+
const n = new IntersectionObserver((s) => {
|
|
449
|
+
s[0].isIntersecting && (n.disconnect(), r());
|
|
450
|
+
});
|
|
451
|
+
n.observe(t);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (e.startsWith("media:")) {
|
|
455
|
+
const n = e.slice(6), s = window.matchMedia(n), i = () => {
|
|
456
|
+
s.removeEventListener("change", o), r();
|
|
457
|
+
}, o = (a) => {
|
|
458
|
+
a.matches && i();
|
|
459
|
+
};
|
|
460
|
+
s.matches ? i() : s.addEventListener("change", o);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
r();
|
|
464
|
+
}
|
|
465
|
+
function Yt(t = document) {
|
|
466
|
+
t.querySelectorAll("[data-loly-island]").forEach((r) => {
|
|
467
|
+
if (r.hasAttribute("data-loly-booted")) return;
|
|
468
|
+
const n = r.getAttribute("data-loly-island");
|
|
469
|
+
if (!n) return;
|
|
470
|
+
const s = Ot(n);
|
|
471
|
+
if (!s) return;
|
|
472
|
+
r.setAttribute("data-loly-booted", "true");
|
|
473
|
+
const i = r.getAttribute("data-island-id");
|
|
474
|
+
let o = {};
|
|
475
|
+
if (i && typeof window < "u") {
|
|
476
|
+
const c = window.__LOLY_ISLAND_DATA__;
|
|
477
|
+
c && c[i] && (o = c[i], delete c[i]);
|
|
478
|
+
}
|
|
479
|
+
const a = qt(r.getAttribute("data-client"));
|
|
480
|
+
Jt(r, a, () => {
|
|
481
|
+
r.innerHTML = "";
|
|
482
|
+
const c = ft(s, o, []);
|
|
483
|
+
Mt(c, r);
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
const L = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), bt = (t) => typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null || t === void 0;
|
|
488
|
+
let Bt = 0;
|
|
489
|
+
function wt(t) {
|
|
490
|
+
const e = [];
|
|
491
|
+
for (const [r, n] of Object.entries(t)) {
|
|
492
|
+
if (r === "children" || r === "key" || r === "dangerouslySetInnerHTML" || r.startsWith("on") && typeof n == "function") continue;
|
|
493
|
+
const s = b(n) || S(n) ? n.get() : n;
|
|
494
|
+
if (s === !1 || s === null || s === void 0) continue;
|
|
495
|
+
const i = r === "className" ? "class" : r;
|
|
496
|
+
if (i === "style" && typeof s == "object" && s !== null) {
|
|
497
|
+
const o = Object.entries(s).map(([a, l]) => `${a.toString().replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}:${l}`).join(";");
|
|
498
|
+
e.push(`${i}="${L(o)}"`);
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
s === !0 ? e.push(`${i}`) : e.push(`${i}="${L(String(s))}"`);
|
|
502
|
+
}
|
|
503
|
+
return e.length ? ` ${e.join(" ")}` : "";
|
|
504
|
+
}
|
|
505
|
+
async function W(t) {
|
|
506
|
+
return typeof window > "u" ? (await Promise.all(t.map(async (s) => b(s) || S(s) ? I(s.get()) : I(s)))).join("") : (await Promise.all(t.map(I))).join("");
|
|
507
|
+
}
|
|
508
|
+
async function B(t) {
|
|
509
|
+
const e = t.type, r = P();
|
|
510
|
+
N(t, r), T(r);
|
|
511
|
+
const n = e({ ...t.props, children: t.children });
|
|
512
|
+
C(n) && N(n, r), T(null);
|
|
513
|
+
const s = H(n) ? await n : n;
|
|
514
|
+
return I(s);
|
|
515
|
+
}
|
|
516
|
+
function St(t) {
|
|
517
|
+
const e = (n, s) => {
|
|
518
|
+
if (s !== void 0 && typeof s != "function" && typeof s != "symbol")
|
|
519
|
+
return b(s) ? s.get() : s;
|
|
520
|
+
}, r = { ...t };
|
|
521
|
+
delete r.children, delete r.key, delete r.__islandDirective;
|
|
522
|
+
try {
|
|
523
|
+
return JSON.parse(JSON.stringify(r, e));
|
|
524
|
+
} catch {
|
|
525
|
+
return {};
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function At() {
|
|
529
|
+
return `island-${Date.now()}-${Math.random().toString(36).slice(2)}-${Bt++}`;
|
|
530
|
+
}
|
|
531
|
+
function xt(t) {
|
|
532
|
+
return t.__islandName || t.name || "Island";
|
|
533
|
+
}
|
|
534
|
+
async function Ft(t) {
|
|
535
|
+
if (t.type === Q)
|
|
536
|
+
return W(t.children);
|
|
537
|
+
if (typeof t.type == "function") {
|
|
538
|
+
if (t.__islandDirective) {
|
|
539
|
+
const o = xt(t.type), a = St(t.props), l = await B(t), c = t.__islandDirective, u = c ? ` data-client="${L(c)}"` : "", p = At(), h = JSON.stringify(p), f = JSON.stringify(a);
|
|
540
|
+
return `${`<script>window.__LOLY_ISLAND_DATA__=window.__LOLY_ISLAND_DATA__||{};window.__LOLY_ISLAND_DATA__[${h}]=${f};<\/script>`}<div data-loly-island="${L(o)}" data-island-id="${L(
|
|
541
|
+
p
|
|
542
|
+
)}"${u}>${l}</div>`;
|
|
543
|
+
}
|
|
544
|
+
if (t.type.__isStoreComponent) {
|
|
545
|
+
const o = t.props, a = o.store;
|
|
546
|
+
if (a != null && a.__storeId && o.initialData !== void 0) {
|
|
547
|
+
const l = JSON.stringify(a.__storeId), c = JSON.stringify(o.initialData), u = `<script>window.__LOLY_STORE_DATA__=window.__LOLY_STORE_DATA__||{};window.__LOLY_STORE_DATA__[${l}]=${c};<\/script>`, p = await B(t);
|
|
548
|
+
return u + p;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return B(t);
|
|
552
|
+
}
|
|
553
|
+
const e = t.type, r = wt(t.props), n = t.props.dangerouslySetInnerHTML;
|
|
554
|
+
if (n && typeof n.__html == "string")
|
|
555
|
+
return `<${e}${r}>${n.__html}</${e}>`;
|
|
556
|
+
const s = await W(t.children);
|
|
557
|
+
return `<${e}${r}>${s}</${e}>`;
|
|
558
|
+
}
|
|
559
|
+
async function I(t) {
|
|
560
|
+
if (Array.isArray(t))
|
|
561
|
+
return W(t);
|
|
562
|
+
if (typeof t == "function") {
|
|
563
|
+
const e = t(), r = H(e) ? await e : e;
|
|
564
|
+
return I(r);
|
|
565
|
+
}
|
|
566
|
+
if (nt(t)) {
|
|
567
|
+
const e = t.source.get();
|
|
568
|
+
return (await Promise.all(
|
|
569
|
+
e.map((n, s) => I(t.renderItem(n, { remove() {
|
|
570
|
+
}, index: () => s })))
|
|
571
|
+
)).join("");
|
|
572
|
+
}
|
|
573
|
+
return b(t) || S(t) ? I(t.get()) : bt(t) ? t === !1 || t === null || t === void 0 ? "" : L(String(t)) : C(t) ? Ft(t) : "";
|
|
574
|
+
}
|
|
575
|
+
async function Lt(t) {
|
|
576
|
+
return I(t);
|
|
577
|
+
}
|
|
578
|
+
function zt(t, e = {}) {
|
|
579
|
+
const { onAsyncTask: r } = e, n = new TextEncoder();
|
|
580
|
+
let s = 0;
|
|
581
|
+
async function i(o, a, l, c) {
|
|
582
|
+
if (Array.isArray(o)) {
|
|
583
|
+
for (const u of k(o))
|
|
584
|
+
await i(u, a);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (nt(o)) {
|
|
588
|
+
const u = o.source.get();
|
|
589
|
+
for (let p = 0; p < u.length; p++)
|
|
590
|
+
await i(o.renderItem(u[p], { remove() {
|
|
591
|
+
}, index: () => p }), a);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (b(o) || S(o))
|
|
595
|
+
return i(o.get(), a);
|
|
596
|
+
if (bt(o)) {
|
|
597
|
+
if (o === !1 || o === null || o === void 0) return;
|
|
598
|
+
a.enqueue(n.encode(L(String(o))));
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (C(o)) {
|
|
602
|
+
if (o.type === Q || typeof o.type == "symbol") {
|
|
603
|
+
for (const f of k(o.children))
|
|
604
|
+
await i(f, a);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (typeof o.type == "function") {
|
|
608
|
+
if (o.__islandDirective) {
|
|
609
|
+
const g = xt(o.type), m = St(o.props), _ = P();
|
|
610
|
+
N(o, _), T(_);
|
|
611
|
+
const w = o.type({ ...o.props, children: o.children });
|
|
612
|
+
C(w) && N(w, _), T(null);
|
|
613
|
+
const A = At(), D = JSON.stringify(A), M = JSON.stringify(m), st = `${`<script>window.__LOLY_ISLAND_DATA__=window.__LOLY_ISLAND_DATA__||{};window.__LOLY_ISLAND_DATA__[${D}]=${M};<\/script>`}<div data-loly-island="${L(
|
|
614
|
+
g
|
|
615
|
+
)}" data-island-id="${L(A)}"${o.__islandDirective ? ` data-client="${L(o.__islandDirective)}"` : ""}>`;
|
|
616
|
+
a.enqueue(n.encode(st)), await i(w, a), a.enqueue(n.encode("</div>"));
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
if (o.type.__isStoreComponent) {
|
|
620
|
+
const g = o.props, m = g.store;
|
|
621
|
+
if (m != null && m.__storeId && g.initialData !== void 0) {
|
|
622
|
+
const _ = JSON.stringify(m.__storeId), w = JSON.stringify(g.initialData), A = `<script>window.__LOLY_STORE_DATA__=window.__LOLY_STORE_DATA__||{};window.__LOLY_STORE_DATA__[${_}]=${w};<\/script>`;
|
|
623
|
+
a.enqueue(n.encode(A));
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
const y = P();
|
|
627
|
+
N(o, y), T(y);
|
|
628
|
+
const d = o.type({ ...o.props, children: o.children });
|
|
629
|
+
if (C(d) && N(d, y), T(null), H(d)) {
|
|
630
|
+
const g = `async-${s++}`;
|
|
631
|
+
r && r(g, () => d, o.props), a.enqueue(n.encode(`<div data-loly-async="${L(g)}"><!-- placeholder --></div>`));
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
await i(d, a);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const u = o.type, p = wt(o.props), h = o.props.dangerouslySetInnerHTML;
|
|
638
|
+
if (a.enqueue(n.encode(`<${u}${p}>`)), h && typeof h.__html == "string")
|
|
639
|
+
a.enqueue(n.encode(h.__html));
|
|
640
|
+
else {
|
|
641
|
+
const f = k(o.children);
|
|
642
|
+
for (const y of f)
|
|
643
|
+
if (H(y)) {
|
|
644
|
+
const d = `async-${s++}`;
|
|
645
|
+
r && r(d, () => y, void 0), a.enqueue(n.encode(`<div data-loly-async="${L(d)}"><!-- placeholder --></div>`));
|
|
646
|
+
} else
|
|
647
|
+
await i(y, a);
|
|
648
|
+
}
|
|
649
|
+
a.enqueue(n.encode(`</${u}>`));
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return new ReadableStream({
|
|
654
|
+
async start(o) {
|
|
655
|
+
try {
|
|
656
|
+
await i(t, o);
|
|
657
|
+
} catch (a) {
|
|
658
|
+
o.error(a);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
o.close();
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
function H(t) {
|
|
666
|
+
return typeof t == "object" && t !== null && "then" in t && typeof t.then == "function";
|
|
667
|
+
}
|
|
668
|
+
function Ut(t) {
|
|
669
|
+
if (!t) return document;
|
|
670
|
+
if (typeof t == "string") {
|
|
671
|
+
const e = document.querySelector(t);
|
|
672
|
+
if (!e) throw new Error(`initLolyApplication: target not found: ${t}`);
|
|
673
|
+
return e;
|
|
674
|
+
}
|
|
675
|
+
return t;
|
|
676
|
+
}
|
|
677
|
+
function ge(t = {}) {
|
|
678
|
+
const e = Ut(t.target);
|
|
679
|
+
Yt(e);
|
|
680
|
+
}
|
|
681
|
+
async function Kt(t) {
|
|
682
|
+
const e = await t();
|
|
683
|
+
return {
|
|
684
|
+
html: await Lt(e)
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
const Wt = (t) => {
|
|
688
|
+
const e = () => Array.isArray(t.children) ? t.children[0] ?? null : t.children ?? null, r = () => {
|
|
689
|
+
const s = e();
|
|
690
|
+
return typeof s == "function" ? s() : s;
|
|
691
|
+
}, n = () => {
|
|
692
|
+
var s;
|
|
693
|
+
try {
|
|
694
|
+
return r();
|
|
695
|
+
} catch (i) {
|
|
696
|
+
const o = i instanceof Error ? i : new Error(String(i));
|
|
697
|
+
return (s = t.onError) == null || s.call(t, o, null), t.fallback ? t.fallback(o) : null;
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
return () => n();
|
|
701
|
+
};
|
|
702
|
+
Wt.__isErrorBoundary = !0;
|
|
703
|
+
function Gt({ store: t, initialData: e, children: r }) {
|
|
704
|
+
const n = q();
|
|
705
|
+
if (!(n != null && n.vnode))
|
|
706
|
+
throw new Error("Store component must be used inside a component");
|
|
707
|
+
const s = e !== void 0 ? e : (() => {
|
|
708
|
+
const o = yt(t);
|
|
709
|
+
return o ? o() : t.get();
|
|
710
|
+
})(), [i] = v(s);
|
|
711
|
+
return Ct(n.vnode, t, i, e), r ?? null;
|
|
712
|
+
}
|
|
713
|
+
Gt.__isStoreComponent = !0;
|
|
714
|
+
function me(t) {
|
|
715
|
+
const e = yt(t);
|
|
716
|
+
return e ? {
|
|
717
|
+
__isStore: !0,
|
|
718
|
+
__defaultValue: t.__defaultValue,
|
|
719
|
+
__globalSignal: t.__globalSignal,
|
|
720
|
+
get: () => e(),
|
|
721
|
+
set: (r) => e.set(r),
|
|
722
|
+
update: (r) => e.set((n) => r(n)),
|
|
723
|
+
reset: () => e.set(t.__defaultValue)
|
|
724
|
+
} : t;
|
|
725
|
+
}
|
|
726
|
+
const Xt = 50;
|
|
727
|
+
function _e() {
|
|
728
|
+
if (!O().enableDevtools) return null;
|
|
729
|
+
const [e, r] = v(!1), [n, s] = v([]), [i, o] = v(!1);
|
|
730
|
+
jt(() => {
|
|
731
|
+
let u = !1;
|
|
732
|
+
const p = i.subscribe((y) => {
|
|
733
|
+
u = y;
|
|
734
|
+
});
|
|
735
|
+
let h = !1;
|
|
736
|
+
const f = It((y) => {
|
|
737
|
+
if (y.scope !== "overlay") {
|
|
738
|
+
if (y.scope === "signal" && y.message === "signal:update") {
|
|
739
|
+
const d = y.payload;
|
|
740
|
+
if (Array.isArray(d.prev) && Array.isArray(d.next) && (d.prev.length > 0 || d.next.length > 0)) {
|
|
741
|
+
const g = d.prev[0] || d.next[0];
|
|
742
|
+
if (g && typeof g == "object" && "scope" in g && "timestamp" in g)
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (!h && !u) {
|
|
747
|
+
h = !0;
|
|
748
|
+
try {
|
|
749
|
+
s((d) => [...d, y].slice(-Xt));
|
|
750
|
+
} finally {
|
|
751
|
+
setTimeout(() => {
|
|
752
|
+
h = !1;
|
|
753
|
+
}, 0);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
gt(() => {
|
|
759
|
+
f(), p();
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
const a = () => r((u) => !u), l = () => o((u) => !u), c = () => s([]);
|
|
763
|
+
return /* @__PURE__ */ j("div", { style: { position: "fixed", right: "12px", bottom: "12px", zIndex: 9999, fontFamily: "system-ui", fontSize: "12px" }, children: [
|
|
764
|
+
/* @__PURE__ */ x(
|
|
765
|
+
"button",
|
|
766
|
+
{
|
|
767
|
+
onClick: a,
|
|
768
|
+
style: {
|
|
769
|
+
padding: "6px 10px",
|
|
770
|
+
borderRadius: "6px",
|
|
771
|
+
border: "1px solid #cbd5e1",
|
|
772
|
+
background: "#111827",
|
|
773
|
+
color: "#f8fafc",
|
|
774
|
+
cursor: "pointer"
|
|
775
|
+
},
|
|
776
|
+
children: "Devtools"
|
|
777
|
+
}
|
|
778
|
+
),
|
|
779
|
+
() => e() && /* @__PURE__ */ j(
|
|
780
|
+
"div",
|
|
781
|
+
{
|
|
782
|
+
style: {
|
|
783
|
+
marginTop: "8px",
|
|
784
|
+
width: "360px",
|
|
785
|
+
maxHeight: "320px",
|
|
786
|
+
overflow: "hidden",
|
|
787
|
+
border: "1px solid #cbd5e1",
|
|
788
|
+
borderRadius: "8px",
|
|
789
|
+
background: "#0f172a",
|
|
790
|
+
color: "#e2e8f0",
|
|
791
|
+
boxShadow: "0 10px 30px rgba(0,0,0,0.35)"
|
|
792
|
+
},
|
|
793
|
+
children: [
|
|
794
|
+
/* @__PURE__ */ j("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "8px 10px", borderBottom: "1px solid #1f2937" }, children: [
|
|
795
|
+
/* @__PURE__ */ x("strong", { style: { fontSize: "12px" }, children: "Devtools" }),
|
|
796
|
+
/* @__PURE__ */ x("span", { style: { flex: 1 } }),
|
|
797
|
+
/* @__PURE__ */ x("button", { onClick: l, style: ct(i()), children: i() ? "Resume" : "Pause" }),
|
|
798
|
+
/* @__PURE__ */ x("button", { onClick: c, style: ct(!1), children: "Clear" })
|
|
799
|
+
] }),
|
|
800
|
+
/* @__PURE__ */ x("div", { style: { maxHeight: "260px", overflowY: "auto" }, children: () => n().length === 0 ? /* @__PURE__ */ x("div", { style: { padding: "12px", color: "#94a3b8" }, children: "No events" }) : n().slice().reverse().map((u, p) => /* @__PURE__ */ j("div", { style: { padding: "8px 10px", borderBottom: "1px solid #1f2937" }, children: [
|
|
801
|
+
/* @__PURE__ */ j("div", { style: { display: "flex", gap: "6px", alignItems: "center" }, children: [
|
|
802
|
+
/* @__PURE__ */ x("span", { style: Zt(u.level), children: u.level }),
|
|
803
|
+
/* @__PURE__ */ x("span", { style: Qt, children: u.scope }),
|
|
804
|
+
/* @__PURE__ */ x("span", { style: { color: "#9ca3af", fontSize: "11px" }, children: new Date(u.timestamp).toLocaleTimeString() })
|
|
805
|
+
] }),
|
|
806
|
+
/* @__PURE__ */ x("div", { style: { marginTop: "4px", color: "#e5e7eb" }, children: u.message }),
|
|
807
|
+
u.payload ? /* @__PURE__ */ x("pre", { style: { marginTop: "4px", fontSize: "11px", color: "#cbd5e1", whiteSpace: "pre-wrap" }, children: JSON.stringify(u.payload, null, 2) }) : null
|
|
808
|
+
] }, p)) })
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] });
|
|
813
|
+
}
|
|
814
|
+
const ct = (t) => ({
|
|
815
|
+
padding: "4px 8px",
|
|
816
|
+
borderRadius: "6px",
|
|
817
|
+
border: "1px solid #334155",
|
|
818
|
+
background: t ? "#1e293b" : "#111827",
|
|
819
|
+
color: "#e2e8f0",
|
|
820
|
+
cursor: "pointer",
|
|
821
|
+
fontSize: "11px"
|
|
822
|
+
}), Zt = (t) => ({
|
|
823
|
+
fontSize: "10px",
|
|
824
|
+
padding: "2px 6px",
|
|
825
|
+
borderRadius: "999px",
|
|
826
|
+
textTransform: "uppercase",
|
|
827
|
+
background: t === "error" ? "#7f1d1d" : t === "warn" ? "#854d0e" : "#0f172a",
|
|
828
|
+
color: "#e5e7eb"
|
|
829
|
+
}), Qt = {
|
|
830
|
+
fontSize: "10px",
|
|
831
|
+
padding: "2px 6px",
|
|
832
|
+
borderRadius: "999px",
|
|
833
|
+
background: "#1f2937",
|
|
834
|
+
color: "#e5e7eb"
|
|
835
|
+
};
|
|
836
|
+
async function te(t) {
|
|
837
|
+
const {
|
|
838
|
+
view: e,
|
|
839
|
+
head: r = "",
|
|
840
|
+
styles: n = "",
|
|
841
|
+
scripts: s = "",
|
|
842
|
+
beforeApp: i = "",
|
|
843
|
+
afterApp: o = "",
|
|
844
|
+
appId: a = "app"
|
|
845
|
+
} = t, l = typeof e == "function" ? await e() : e, c = await Lt(l);
|
|
846
|
+
return { html: `<!doctype html><html><head>${r}${n}</head><body>${i}<div id="${a}">${c}</div>${o}${s}</body></html>` };
|
|
847
|
+
}
|
|
848
|
+
function be(t) {
|
|
849
|
+
const {
|
|
850
|
+
view: e,
|
|
851
|
+
head: r = "",
|
|
852
|
+
styles: n = "",
|
|
853
|
+
scripts: s = "",
|
|
854
|
+
beforeApp: i = "",
|
|
855
|
+
afterApp: o = "",
|
|
856
|
+
appId: a = "app",
|
|
857
|
+
onAsyncTask: l
|
|
858
|
+
} = t, c = new TextEncoder();
|
|
859
|
+
let u;
|
|
860
|
+
if (typeof e == "function") {
|
|
861
|
+
const p = e();
|
|
862
|
+
u = p instanceof Promise ? p : Promise.resolve(p);
|
|
863
|
+
} else
|
|
864
|
+
u = Promise.resolve(e);
|
|
865
|
+
return new ReadableStream({
|
|
866
|
+
async start(p) {
|
|
867
|
+
try {
|
|
868
|
+
const h = `<!doctype html><html><head>${r}${n}</head><body>${i}<div id="${a}">`;
|
|
869
|
+
p.enqueue(c.encode(h));
|
|
870
|
+
const f = await u, d = zt(f, { onAsyncTask: l }).getReader();
|
|
871
|
+
for (; ; ) {
|
|
872
|
+
const { done: m, value: _ } = await d.read();
|
|
873
|
+
if (m) break;
|
|
874
|
+
_ && p.enqueue(_);
|
|
875
|
+
}
|
|
876
|
+
d.releaseLock();
|
|
877
|
+
const g = `</div>${o}${s}</body></html>`;
|
|
878
|
+
p.enqueue(c.encode(g));
|
|
879
|
+
} catch (h) {
|
|
880
|
+
p.error(h);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
p.close();
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
function ee(t) {
|
|
888
|
+
const e = new URL(t, "http://localhost");
|
|
889
|
+
return { pathname: e.pathname || "/", search: e.search, hash: e.hash };
|
|
890
|
+
}
|
|
891
|
+
function we(t) {
|
|
892
|
+
const {
|
|
893
|
+
routes: e,
|
|
894
|
+
styles: r = "",
|
|
895
|
+
scripts: n = "",
|
|
896
|
+
head: s = "",
|
|
897
|
+
appId: i = "app",
|
|
898
|
+
onNotFound: o
|
|
899
|
+
} = t;
|
|
900
|
+
return async function(l, c, u) {
|
|
901
|
+
var p, h, f, y, d, g, m;
|
|
902
|
+
try {
|
|
903
|
+
const _ = l.path || l.url || "/", w = ee(_), A = ot(w.pathname, e);
|
|
904
|
+
if (!A) {
|
|
905
|
+
if (o) {
|
|
906
|
+
await o(l, c, u);
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
if (typeof u == "function") return u();
|
|
910
|
+
(p = c.status) == null || p.call(c, 404), (h = c.end) == null || h.call(c, "Not found");
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
const { html: D } = await te({
|
|
914
|
+
view: A.route.factory({ params: A.params, location: w }),
|
|
915
|
+
head: s,
|
|
916
|
+
styles: r,
|
|
917
|
+
scripts: n,
|
|
918
|
+
appId: i
|
|
919
|
+
});
|
|
920
|
+
(f = c.setHeader) == null || f.call(c, "Content-Type", "text/html; charset=utf-8"), (y = c.status) == null || y.call(c, 200), c.send ? c.send(D) : (d = c.end) == null || d.call(c, D);
|
|
921
|
+
} catch (_) {
|
|
922
|
+
if (typeof u == "function")
|
|
923
|
+
return u(_);
|
|
924
|
+
(g = c.status) == null || g.call(c, 500), (m = c.end) == null || m.call(c, "Internal Server Error"), console.error("[loly] express handler error", _);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
const [G, X] = v($t()), [ne, Z] = v({});
|
|
929
|
+
let at = !1;
|
|
930
|
+
function $t() {
|
|
931
|
+
if (typeof window > "u")
|
|
932
|
+
return { pathname: "/", search: "", hash: "" };
|
|
933
|
+
const { pathname: t, search: e, hash: r } = window.location;
|
|
934
|
+
return { pathname: t, search: e, hash: r };
|
|
935
|
+
}
|
|
936
|
+
function rt(t) {
|
|
937
|
+
const e = new URL(t, "http://localhost");
|
|
938
|
+
return { pathname: e.pathname || "/", search: e.search, hash: e.hash };
|
|
939
|
+
}
|
|
940
|
+
function re(t) {
|
|
941
|
+
if (t === "*") return { pattern: /^.*$/, keys: [] };
|
|
942
|
+
const e = [], r = t.split("/").filter(Boolean).map((s) => {
|
|
943
|
+
if (s === "*") return "(.*)";
|
|
944
|
+
if (s.startsWith(":")) {
|
|
945
|
+
const i = s.slice(1);
|
|
946
|
+
return e.push(i), "([^/]+)";
|
|
947
|
+
}
|
|
948
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
949
|
+
});
|
|
950
|
+
return { pattern: new RegExp("^/" + r.join("/") + "/?$"), keys: e };
|
|
951
|
+
}
|
|
952
|
+
function Se(t) {
|
|
953
|
+
return { list: Object.entries(t).map(([r, n]) => {
|
|
954
|
+
const { pattern: s, keys: i } = re(r);
|
|
955
|
+
return { path: r, pattern: s, keys: i, factory: n };
|
|
956
|
+
}) };
|
|
957
|
+
}
|
|
958
|
+
function ot(t, e) {
|
|
959
|
+
for (const r of e.list) {
|
|
960
|
+
const n = r.pattern.exec(t);
|
|
961
|
+
if (!n) continue;
|
|
962
|
+
const s = {};
|
|
963
|
+
return r.keys.forEach((i, o) => {
|
|
964
|
+
s[i] = decodeURIComponent(n[o + 1] ?? "");
|
|
965
|
+
}), { route: r, params: s };
|
|
966
|
+
}
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
function Et(t, e) {
|
|
970
|
+
if (!(typeof window > "u") && e !== "preserve") {
|
|
971
|
+
if (t.hash) {
|
|
972
|
+
const r = document.getElementById(t.hash.slice(1));
|
|
973
|
+
if (r) {
|
|
974
|
+
r.scrollIntoView();
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
window.scrollTo({ top: 0 });
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function oe(t, e = {}) {
|
|
982
|
+
if (typeof window > "u") return;
|
|
983
|
+
const r = rt(t);
|
|
984
|
+
e.replace ? window.history.replaceState({}, "", t) : window.history.pushState({}, "", t), X(r), Et(r, e.scroll);
|
|
985
|
+
}
|
|
986
|
+
function Ae() {
|
|
987
|
+
return G;
|
|
988
|
+
}
|
|
989
|
+
function xe() {
|
|
990
|
+
return ne;
|
|
991
|
+
}
|
|
992
|
+
function Le({ routes: t, url: e }) {
|
|
993
|
+
e && typeof window > "u" && X(rt(e)), typeof window < "u" && !at && (at = !0, window.addEventListener("popstate", () => {
|
|
994
|
+
const o = $t();
|
|
995
|
+
X(o), Et(o);
|
|
996
|
+
}));
|
|
997
|
+
const [r, n] = v(null), s = async () => {
|
|
998
|
+
const o = G.get(), a = ot(o.pathname, t);
|
|
999
|
+
if (!a)
|
|
1000
|
+
return Z({}), null;
|
|
1001
|
+
Z(a.params);
|
|
1002
|
+
const l = a.route.factory({ params: a.params, location: o });
|
|
1003
|
+
return l instanceof Promise ? await l : l;
|
|
1004
|
+
};
|
|
1005
|
+
s().then((o) => {
|
|
1006
|
+
o != null && n(o);
|
|
1007
|
+
}).catch((o) => {
|
|
1008
|
+
console.error("[loly-router] Error rendering route:", o), n(null);
|
|
1009
|
+
});
|
|
1010
|
+
const i = G.subscribe(() => {
|
|
1011
|
+
s().then((o) => {
|
|
1012
|
+
o != null && n(o);
|
|
1013
|
+
}).catch((o) => {
|
|
1014
|
+
console.error("[loly-router] Error rendering route:", o), n(null);
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
return gt(() => i()), r;
|
|
1018
|
+
}
|
|
1019
|
+
function $e({
|
|
1020
|
+
to: t,
|
|
1021
|
+
replace: e,
|
|
1022
|
+
children: r,
|
|
1023
|
+
className: n
|
|
1024
|
+
}) {
|
|
1025
|
+
return ft("a", {
|
|
1026
|
+
href: t,
|
|
1027
|
+
onClick: (s) => {
|
|
1028
|
+
s.defaultPrevented || s.button !== 0 || s.metaKey || s.altKey || s.ctrlKey || s.shiftKey || (s.preventDefault(), oe(t, { replace: e }));
|
|
1029
|
+
},
|
|
1030
|
+
className: n
|
|
1031
|
+
}, [r]);
|
|
1032
|
+
}
|
|
1033
|
+
function Ee(t, e) {
|
|
1034
|
+
const r = rt(t), n = ot(r.pathname, e);
|
|
1035
|
+
return n ? (Z(n.params), Kt(() => n.route.factory({ params: n.params, location: r }))) : { html: "" };
|
|
1036
|
+
}
|
|
1037
|
+
function Ie() {
|
|
1038
|
+
const t = [];
|
|
1039
|
+
return { setTitle: (i) => {
|
|
1040
|
+
const o = t.findIndex((a) => a.tag === "title");
|
|
1041
|
+
o >= 0 ? t[o] = { tag: "title", attrs: {}, content: i } : t.push({ tag: "title", attrs: {}, content: i });
|
|
1042
|
+
}, addMeta: (i) => {
|
|
1043
|
+
const o = i.name ?? i.property;
|
|
1044
|
+
if (o) {
|
|
1045
|
+
const a = t.findIndex((l) => l.tag === "meta" && (l.attrs.name === o || l.attrs.property === o));
|
|
1046
|
+
if (a >= 0) {
|
|
1047
|
+
t[a] = { tag: "meta", attrs: i };
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
t.push({ tag: "meta", attrs: i });
|
|
1052
|
+
}, addLink: (i) => {
|
|
1053
|
+
const o = i.rel, a = i.href;
|
|
1054
|
+
if (o && a) {
|
|
1055
|
+
const l = t.findIndex((c) => c.tag === "link" && c.attrs.rel === o && c.attrs.href === a);
|
|
1056
|
+
if (l >= 0) {
|
|
1057
|
+
t[l] = { tag: "link", attrs: i };
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
t.push({ tag: "link", attrs: i });
|
|
1062
|
+
}, toString: () => t.map((i) => {
|
|
1063
|
+
if (i.tag === "title") return `<title>${lt(i.content ?? "")}</title>`;
|
|
1064
|
+
const o = Object.entries(i.attrs).map(([a, l]) => `${a}="${lt(l)}"`).join(" ");
|
|
1065
|
+
return `<${i.tag}${o ? " " + o : ""}>`;
|
|
1066
|
+
}).join(""), entries: t };
|
|
1067
|
+
}
|
|
1068
|
+
function lt(t) {
|
|
1069
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1070
|
+
}
|
|
1071
|
+
function F(t) {
|
|
1072
|
+
var r, n;
|
|
1073
|
+
const e = [];
|
|
1074
|
+
return (r = t.css) == null || r.forEach((s) => {
|
|
1075
|
+
e.push(`<link rel="stylesheet" href="${ut(s)}">`);
|
|
1076
|
+
}), (n = t.js) == null || n.forEach((s) => {
|
|
1077
|
+
e.push(`<script type="module" src="${ut(s)}"><\/script>`);
|
|
1078
|
+
}), e.join("");
|
|
1079
|
+
}
|
|
1080
|
+
function ut(t) {
|
|
1081
|
+
return t.replace(/"/g, """);
|
|
1082
|
+
}
|
|
1083
|
+
function Te(t, e) {
|
|
1084
|
+
if (se(t)) {
|
|
1085
|
+
const s = t[e];
|
|
1086
|
+
if (!s) return { styles: "", scripts: "" };
|
|
1087
|
+
const i = s.css ?? [], o = s.file ? [s.file] : [], a = F({ css: i }), l = F({ js: o });
|
|
1088
|
+
return { styles: a, scripts: l };
|
|
1089
|
+
}
|
|
1090
|
+
const r = t[e];
|
|
1091
|
+
return r ? { styles: "", scripts: F({ js: [r] }) } : { styles: "", scripts: "" };
|
|
1092
|
+
}
|
|
1093
|
+
function se(t) {
|
|
1094
|
+
if (!t || typeof t != "object") return !1;
|
|
1095
|
+
const e = Object.values(t)[0];
|
|
1096
|
+
return !!e && typeof e == "object" && "file" in e;
|
|
1097
|
+
}
|
|
1098
|
+
function ie(t) {
|
|
1099
|
+
try {
|
|
1100
|
+
return JSON.stringify(t);
|
|
1101
|
+
} catch {
|
|
1102
|
+
return "{}";
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
function ve(t, e) {
|
|
1106
|
+
const r = JSON.stringify(t), n = ie(e);
|
|
1107
|
+
return `<script>window.__LOLY_DATA__ = window.__LOLY_DATA__ || {}; window.__LOLY_DATA__[${r}] = ${n};<\/script>`;
|
|
1108
|
+
}
|
|
1109
|
+
function De(t) {
|
|
1110
|
+
if (typeof window > "u") return;
|
|
1111
|
+
const e = window.__LOLY_DATA__;
|
|
1112
|
+
if (e)
|
|
1113
|
+
return e[t];
|
|
1114
|
+
}
|
|
1115
|
+
const ce = /defineIsland\s*\(\s*["'`](.+?)["'`]/g;
|
|
1116
|
+
function Ne(t) {
|
|
1117
|
+
const e = /* @__PURE__ */ new Set();
|
|
1118
|
+
let r;
|
|
1119
|
+
for (; (r = ce.exec(t)) !== null; )
|
|
1120
|
+
r[1] && e.add(r[1]);
|
|
1121
|
+
return Array.from(e);
|
|
1122
|
+
}
|
|
1123
|
+
function ke(t = document) {
|
|
1124
|
+
t.querySelectorAll("[data-loly-async]").forEach((r) => {
|
|
1125
|
+
const n = r.getAttribute("data-loly-async");
|
|
1126
|
+
n && (r.hasAttribute("data-loly-async-activated") || (r.setAttribute("data-loly-async-activated", "true"), fetch(`/__loly/async/${n}`).then((s) => {
|
|
1127
|
+
if (s.status === 404)
|
|
1128
|
+
return r.remove(), null;
|
|
1129
|
+
if (!s.ok)
|
|
1130
|
+
throw new Error(`Failed to fetch async component: ${s.statusText}`);
|
|
1131
|
+
return s.json();
|
|
1132
|
+
}).then((s) => {
|
|
1133
|
+
if (s) {
|
|
1134
|
+
if (s.error)
|
|
1135
|
+
throw new Error(s.error);
|
|
1136
|
+
if (!s.html)
|
|
1137
|
+
throw new Error("No HTML content received");
|
|
1138
|
+
r.innerHTML = s.html, r.removeAttribute("data-loly-async"), r.removeAttribute("data-loly-async-activated");
|
|
1139
|
+
}
|
|
1140
|
+
}).catch((s) => {
|
|
1141
|
+
s instanceof Error && !s.message.includes("404") && !s.message.includes("Not Found") && (console.error(`[loly] Error activating async component ${n}:`, s), r.innerHTML = '<span style="color: red;">Error loading content</span>', r.removeAttribute("data-loly-async"), r.removeAttribute("data-loly-async-activated"));
|
|
1142
|
+
})));
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
export {
|
|
1146
|
+
_e as DevtoolsOverlay,
|
|
1147
|
+
Wt as ErrorBoundary,
|
|
1148
|
+
fe as For,
|
|
1149
|
+
Q as Fragment,
|
|
1150
|
+
$e as Link,
|
|
1151
|
+
Le as Router,
|
|
1152
|
+
Gt as Store,
|
|
1153
|
+
ke as activateAsyncComponents,
|
|
1154
|
+
he as addCleanup,
|
|
1155
|
+
Vt as applyProps,
|
|
1156
|
+
N as attachInstanceToVNode,
|
|
1157
|
+
Yt as bootIslands,
|
|
1158
|
+
F as buildAssetsTags,
|
|
1159
|
+
Te as buildAssetsTagsFromManifest,
|
|
1160
|
+
ye as component,
|
|
1161
|
+
dt as computed,
|
|
1162
|
+
je as configureRuntime,
|
|
1163
|
+
we as createExpressHandler,
|
|
1164
|
+
Ie as createHead,
|
|
1165
|
+
P as createInstance,
|
|
1166
|
+
le as createStore,
|
|
1167
|
+
ft as createVNode,
|
|
1168
|
+
ue as defineIsland,
|
|
1169
|
+
Se as defineRoutes,
|
|
1170
|
+
Ne as extractIslandsFromCode,
|
|
1171
|
+
pe as forBlock,
|
|
1172
|
+
q as getCurrentInstance,
|
|
1173
|
+
Ot as getIsland,
|
|
1174
|
+
O as getRuntimeConfig,
|
|
1175
|
+
Re as h,
|
|
1176
|
+
ge as initLolyApplication,
|
|
1177
|
+
ve as injectData,
|
|
1178
|
+
S as isComputed,
|
|
1179
|
+
nt as isForBlock,
|
|
1180
|
+
b as isSignal,
|
|
1181
|
+
C as isVNode,
|
|
1182
|
+
x as jsx,
|
|
1183
|
+
x as jsxDEV,
|
|
1184
|
+
j as jsxs,
|
|
1185
|
+
de as listRegisteredIslands,
|
|
1186
|
+
ot as matchRoute,
|
|
1187
|
+
Mt as mount,
|
|
1188
|
+
oe as navigate,
|
|
1189
|
+
k as normalizeChildren,
|
|
1190
|
+
jt as onMount,
|
|
1191
|
+
gt as onUnmount,
|
|
1192
|
+
De as readData,
|
|
1193
|
+
Kt as renderApplication,
|
|
1194
|
+
Ee as renderRoute,
|
|
1195
|
+
te as renderToHtml,
|
|
1196
|
+
be as renderToHtmlStream,
|
|
1197
|
+
zt as renderToStream,
|
|
1198
|
+
Lt as renderToString,
|
|
1199
|
+
ie as serializeData,
|
|
1200
|
+
T as setCurrentInstance,
|
|
1201
|
+
v as state,
|
|
1202
|
+
Ae as useLocation,
|
|
1203
|
+
xe as useParams,
|
|
1204
|
+
me as useStore
|
|
1205
|
+
};
|
|
1206
|
+
//# sourceMappingURL=index.js.map
|