@mateosuarezdev/flash 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +897 -0
- package/dist/index.js +62 -62
- package/dist/server.cjs +4 -4
- package/dist/server.js +90 -86
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { n as L, s as w, g as
|
|
11
|
+
import { n as L, s as w, g as H, c as m } from "./jsx-dev-runtime-dAReTOgq.js";
|
|
12
12
|
import { F as $e } from "./jsx-dev-runtime-dAReTOgq.js";
|
|
13
13
|
var R = Symbol.for("preact-signals");
|
|
14
14
|
function T() {
|
|
@@ -19,7 +19,7 @@ function T() {
|
|
|
19
19
|
var i = S;
|
|
20
20
|
for (S = void 0, A++; i !== void 0; ) {
|
|
21
21
|
var n = i.o;
|
|
22
|
-
if (i.o = void 0, i.f &= -3, !(8 & i.f) &&
|
|
22
|
+
if (i.o = void 0, i.f &= -3, !(8 & i.f) && G(i)) try {
|
|
23
23
|
i.c();
|
|
24
24
|
} catch (r) {
|
|
25
25
|
e || (t = r, e = !0);
|
|
@@ -40,7 +40,7 @@ function Ce(t) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
var c = void 0;
|
|
43
|
-
function
|
|
43
|
+
function I(t) {
|
|
44
44
|
var e = c;
|
|
45
45
|
c = void 0;
|
|
46
46
|
try {
|
|
@@ -50,7 +50,7 @@ function K(t) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
var S = void 0, p = 0, A = 0, E = 0;
|
|
53
|
-
function
|
|
53
|
+
function K(t) {
|
|
54
54
|
if (c !== void 0) {
|
|
55
55
|
var e = t.n;
|
|
56
56
|
if (e === void 0 || e.t !== c)
|
|
@@ -68,7 +68,7 @@ u.prototype.h = function() {
|
|
|
68
68
|
};
|
|
69
69
|
u.prototype.S = function(t) {
|
|
70
70
|
var e = this, i = this.t;
|
|
71
|
-
i !== t && t.e === void 0 && (t.x = i, this.t = t, i !== void 0 ? i.e = t :
|
|
71
|
+
i !== t && t.e === void 0 && (t.x = i, this.t = t, i !== void 0 ? i.e = t : I(function() {
|
|
72
72
|
var n;
|
|
73
73
|
(n = e.W) == null || n.call(e);
|
|
74
74
|
}));
|
|
@@ -77,7 +77,7 @@ u.prototype.U = function(t) {
|
|
|
77
77
|
var e = this;
|
|
78
78
|
if (this.t !== void 0) {
|
|
79
79
|
var i = t.e, n = t.x;
|
|
80
|
-
i !== void 0 && (i.x = n, t.e = void 0), n !== void 0 && (n.e = i, t.x = void 0), t === this.t && (this.t = n, n === void 0 &&
|
|
80
|
+
i !== void 0 && (i.x = n, t.e = void 0), n !== void 0 && (n.e = i, t.x = void 0), t === this.t && (this.t = n, n === void 0 && I(function() {
|
|
81
81
|
var r;
|
|
82
82
|
(r = e.Z) == null || r.call(e);
|
|
83
83
|
}));
|
|
@@ -85,7 +85,7 @@ u.prototype.U = function(t) {
|
|
|
85
85
|
};
|
|
86
86
|
u.prototype.subscribe = function(t) {
|
|
87
87
|
var e = this;
|
|
88
|
-
return
|
|
88
|
+
return v(function() {
|
|
89
89
|
var i = e.value, n = c;
|
|
90
90
|
c = void 0;
|
|
91
91
|
try {
|
|
@@ -114,7 +114,7 @@ u.prototype.peek = function() {
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
117
|
-
var t =
|
|
117
|
+
var t = K(this);
|
|
118
118
|
return t !== void 0 && (t.i = this.i), this.v;
|
|
119
119
|
}, set: function(t) {
|
|
120
120
|
if (t !== this.v) {
|
|
@@ -130,11 +130,11 @@ Object.defineProperty(u.prototype, "value", { get: function() {
|
|
|
130
130
|
function we(t, e) {
|
|
131
131
|
return new u(t, e);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function G(t) {
|
|
134
134
|
for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
|
|
135
135
|
return !1;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function j(t) {
|
|
138
138
|
for (var e = t.s; e !== void 0; e = e.n) {
|
|
139
139
|
var i = e.S.n;
|
|
140
140
|
if (i !== void 0 && (e.r = i), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
@@ -143,7 +143,7 @@ function X(t) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function X(t) {
|
|
147
147
|
for (var e = t.s, i = void 0; e !== void 0; ) {
|
|
148
148
|
var n = e.p;
|
|
149
149
|
e.i === -1 ? (e.S.U(e), n !== void 0 && (n.n = e.n), e.n !== void 0 && (e.n.p = n)) : i = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = n;
|
|
@@ -157,17 +157,17 @@ y.prototype = new u();
|
|
|
157
157
|
y.prototype.h = function() {
|
|
158
158
|
if (this.f &= -3, 1 & this.f) return !1;
|
|
159
159
|
if ((36 & this.f) == 32 || (this.f &= -5, this.g === E)) return !0;
|
|
160
|
-
if (this.g = E, this.f |= 1, this.i > 0 && !
|
|
160
|
+
if (this.g = E, this.f |= 1, this.i > 0 && !G(this))
|
|
161
161
|
return this.f &= -2, !0;
|
|
162
162
|
var t = c;
|
|
163
163
|
try {
|
|
164
|
-
|
|
164
|
+
j(this), c = this;
|
|
165
165
|
var e = this.x();
|
|
166
166
|
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
167
167
|
} catch (i) {
|
|
168
168
|
this.v = i, this.f |= 16, this.i++;
|
|
169
169
|
}
|
|
170
|
-
return c = t,
|
|
170
|
+
return c = t, X(this), this.f &= -2, !0;
|
|
171
171
|
};
|
|
172
172
|
y.prototype.S = function(t) {
|
|
173
173
|
if (this.t === void 0) {
|
|
@@ -190,7 +190,7 @@ y.prototype.N = function() {
|
|
|
190
190
|
};
|
|
191
191
|
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
192
192
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
193
|
-
var t =
|
|
193
|
+
var t = K(this);
|
|
194
194
|
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
195
195
|
return this.v;
|
|
196
196
|
} });
|
|
@@ -206,24 +206,24 @@ function Y(t) {
|
|
|
206
206
|
try {
|
|
207
207
|
e();
|
|
208
208
|
} catch (n) {
|
|
209
|
-
throw t.f &= -2, t.f |= 8,
|
|
209
|
+
throw t.f &= -2, t.f |= 8, M(t), n;
|
|
210
210
|
} finally {
|
|
211
211
|
c = i, T();
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function M(t) {
|
|
216
216
|
for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
|
|
217
217
|
t.x = void 0, t.s = void 0, Y(t);
|
|
218
218
|
}
|
|
219
219
|
function q(t) {
|
|
220
220
|
if (c !== this) throw new Error("Out-of-order effect");
|
|
221
|
-
|
|
221
|
+
X(this), c = t, this.f &= -2, 8 & this.f && M(this), T();
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function g(t, e) {
|
|
224
224
|
this.x = t, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = e?.name;
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
g.prototype.c = function() {
|
|
227
227
|
var t = this.S();
|
|
228
228
|
try {
|
|
229
229
|
if (8 & this.f || this.x === void 0) return;
|
|
@@ -233,23 +233,23 @@ v.prototype.c = function() {
|
|
|
233
233
|
t();
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
|
-
|
|
236
|
+
g.prototype.S = function() {
|
|
237
237
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
238
|
-
this.f |= 1, this.f &= -9, Y(this),
|
|
238
|
+
this.f |= 1, this.f &= -9, Y(this), j(this), p++;
|
|
239
239
|
var t = c;
|
|
240
240
|
return c = this, q.bind(this, t);
|
|
241
241
|
};
|
|
242
|
-
|
|
242
|
+
g.prototype.N = function() {
|
|
243
243
|
2 & this.f || (this.f |= 2, this.o = S, S = this);
|
|
244
244
|
};
|
|
245
|
-
|
|
246
|
-
this.f |= 8, 1 & this.f ||
|
|
245
|
+
g.prototype.d = function() {
|
|
246
|
+
this.f |= 8, 1 & this.f || M(this);
|
|
247
247
|
};
|
|
248
|
-
|
|
248
|
+
g.prototype.dispose = function() {
|
|
249
249
|
this.d();
|
|
250
250
|
};
|
|
251
|
-
function
|
|
252
|
-
var i = new
|
|
251
|
+
function v(t, e) {
|
|
252
|
+
var i = new g(t, e);
|
|
253
253
|
try {
|
|
254
254
|
i.c();
|
|
255
255
|
} catch (r) {
|
|
@@ -267,15 +267,15 @@ function Ne(t) {
|
|
|
267
267
|
function Ae(t, e) {
|
|
268
268
|
typeof e == "function" ? t.value = e() : t.value = e;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function Me(t) {
|
|
271
271
|
return t instanceof u ? () => t.value : t;
|
|
272
272
|
}
|
|
273
273
|
function Z(t, e, i = !1) {
|
|
274
274
|
const n = [];
|
|
275
275
|
for (const [r, s] of Object.entries(e))
|
|
276
|
-
if (s != null && !(r === "children" || r === "key" || r === "autoanimate")) {
|
|
276
|
+
if (s != null && !(r === "children" || r === "key" || r === "autoanimate" || r === "innerHTML")) {
|
|
277
277
|
if (typeof s == "function" && r !== "ref" && !r.startsWith("on") && r !== "viewTransitionName") {
|
|
278
|
-
const o =
|
|
278
|
+
const o = v(() => {
|
|
279
279
|
const a = s();
|
|
280
280
|
D(t, r, a, i);
|
|
281
281
|
});
|
|
@@ -348,7 +348,7 @@ function k(t, e) {
|
|
|
348
348
|
}
|
|
349
349
|
return { vnode: null, dom: null };
|
|
350
350
|
}
|
|
351
|
-
class
|
|
351
|
+
class x {
|
|
352
352
|
_cancelled = !1;
|
|
353
353
|
_cancelCallbacks = [];
|
|
354
354
|
get cancelled() {
|
|
@@ -373,7 +373,7 @@ class M {
|
|
|
373
373
|
}
|
|
374
374
|
async function U(t, e) {
|
|
375
375
|
if (!t) return;
|
|
376
|
-
const i = t, n = e || new
|
|
376
|
+
const i = t, n = e || new x();
|
|
377
377
|
if ("_onBeforeExitCallbacks" in i && i._onBeforeExitCallbacks.length > 0)
|
|
378
378
|
for (const r of i._onBeforeExitCallbacks)
|
|
379
379
|
try {
|
|
@@ -399,7 +399,7 @@ async function U(t, e) {
|
|
|
399
399
|
}
|
|
400
400
|
function $(t) {
|
|
401
401
|
if (!t) return;
|
|
402
|
-
const e = t, i = new
|
|
402
|
+
const e = t, i = new x();
|
|
403
403
|
if (i.cancel(), "_onBeforeExitCallbacks" in e && e._onBeforeExitCallbacks.length > 0 && e._onBeforeExitCallbacks.forEach((n) => {
|
|
404
404
|
try {
|
|
405
405
|
const r = n(i);
|
|
@@ -438,7 +438,7 @@ async function O(t, e, i) {
|
|
|
438
438
|
}
|
|
439
439
|
const o = ++Q, a = h.get(t);
|
|
440
440
|
a && a.token.cancel();
|
|
441
|
-
const l = new
|
|
441
|
+
const l = new x();
|
|
442
442
|
if (h.set(t, { id: o, token: l }), r && "_lifecycleState" in r && (r._lifecycleState = "exiting"), r)
|
|
443
443
|
try {
|
|
444
444
|
await U(r, l);
|
|
@@ -523,7 +523,7 @@ function B(t, e, i = null, n = !1) {
|
|
|
523
523
|
o._parent = i, i && i._renderedChildren.push(o);
|
|
524
524
|
const a = document.createComment("reactive");
|
|
525
525
|
t.appendChild(a), o._placeholder = a;
|
|
526
|
-
const l =
|
|
526
|
+
const l = v(() => {
|
|
527
527
|
const d = s();
|
|
528
528
|
if (Array.isArray(d))
|
|
529
529
|
te(o, d);
|
|
@@ -549,7 +549,7 @@ function W(t, e = !1) {
|
|
|
549
549
|
if (t._dom)
|
|
550
550
|
return t._dom;
|
|
551
551
|
const i = e || t.type === "svg", n = i ? document.createElementNS(ae, t.type) : document.createElement(t.type), r = Z(n, t.props, i);
|
|
552
|
-
return t._onUnmountCallbacks.push(r), t.props.children && B(n, t.props.children, t, i), t._dom = n, t._lifecycleState = "mounted", t._onMountCallbacks.length > 0 && t._onMountCallbacks.forEach((s) => s()), n;
|
|
552
|
+
return t._onUnmountCallbacks.push(r), t.props.innerHTML !== void 0 ? n.innerHTML = typeof t.props.innerHTML == "object" ? JSON.stringify(t.props.innerHTML) : t.props.innerHTML : t.props.children && B(n, t.props.children, t, i), t._dom = n, t._lifecycleState = "mounted", t._onMountCallbacks.length > 0 && t._onMountCallbacks.forEach((s) => s()), n;
|
|
553
553
|
}
|
|
554
554
|
function _(t, e = !1) {
|
|
555
555
|
if ("type" in t && t.type === "reactive")
|
|
@@ -575,7 +575,7 @@ function _(t, e = !1) {
|
|
|
575
575
|
s();
|
|
576
576
|
}), r && (i._lifecycleState = "mounted"), r;
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function xe(t, e) {
|
|
579
579
|
const i = t instanceof Node ? t : _(t);
|
|
580
580
|
i && e.append(i);
|
|
581
581
|
}
|
|
@@ -628,7 +628,7 @@ function fe(t, e, i = !1, n) {
|
|
|
628
628
|
}
|
|
629
629
|
if (typeof o == "function" && s !== "ref" && s !== "viewTransitionName") {
|
|
630
630
|
n && console.log(`→ Reactive prop: ${s}`);
|
|
631
|
-
const a =
|
|
631
|
+
const a = v(() => {
|
|
632
632
|
const l = o();
|
|
633
633
|
ue(t, s, l, i);
|
|
634
634
|
});
|
|
@@ -673,7 +673,7 @@ function he(t, e, i, n) {
|
|
|
673
673
|
r._currentDom
|
|
674
674
|
), r._placeholder = a;
|
|
675
675
|
let l = !0;
|
|
676
|
-
const d =
|
|
676
|
+
const d = v(() => {
|
|
677
677
|
const f = t();
|
|
678
678
|
if (l) {
|
|
679
679
|
l = !1;
|
|
@@ -759,7 +759,7 @@ function me(t, e) {
|
|
|
759
759
|
b(a, e), t._currentChild = a, t._currentDom = a._dom ?? a._element;
|
|
760
760
|
} else (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && (t._currentDom = n), e.walker.nextSibling();
|
|
761
761
|
let s = !0;
|
|
762
|
-
const o =
|
|
762
|
+
const o = v(() => {
|
|
763
763
|
const a = t.fn();
|
|
764
764
|
if (s) {
|
|
765
765
|
s = !1, e.debug && console.log("→ Reactive effect setup (skipping initial)");
|
|
@@ -832,7 +832,7 @@ function De(t) {
|
|
|
832
832
|
_defaultValue: t,
|
|
833
833
|
provide(i) {
|
|
834
834
|
if (typeof document > "u") return;
|
|
835
|
-
const n =
|
|
835
|
+
const n = H();
|
|
836
836
|
if (!n)
|
|
837
837
|
throw new Error("context.provide() called outside of component render");
|
|
838
838
|
n._contextMap || (n._contextMap = /* @__PURE__ */ new Map()), n._contextMap.set(e, i);
|
|
@@ -841,7 +841,7 @@ function De(t) {
|
|
|
841
841
|
}
|
|
842
842
|
function Fe(t) {
|
|
843
843
|
if (typeof document > "u") return t._defaultValue;
|
|
844
|
-
const e =
|
|
844
|
+
const e = H();
|
|
845
845
|
if (!e)
|
|
846
846
|
throw new Error("useContext called outside of component render");
|
|
847
847
|
let i = e;
|
|
@@ -859,7 +859,7 @@ function Le(t) {
|
|
|
859
859
|
m._onMountCallbacks.push(t);
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function He(t) {
|
|
863
863
|
if (!(typeof document > "u")) {
|
|
864
864
|
if (m === null)
|
|
865
865
|
throw new Error(
|
|
@@ -868,7 +868,7 @@ function Ie(t) {
|
|
|
868
868
|
m._onUnmountCallbacks.push(t);
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
|
-
function
|
|
871
|
+
function Ie(t) {
|
|
872
872
|
if (!(typeof document > "u")) {
|
|
873
873
|
if (m === null)
|
|
874
874
|
throw new Error(
|
|
@@ -877,7 +877,7 @@ function Ke(t) {
|
|
|
877
877
|
m._onBeforeExitCallbacks.push(t);
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
function
|
|
880
|
+
function Ke(t) {
|
|
881
881
|
if (!(typeof document > "u"))
|
|
882
882
|
try {
|
|
883
883
|
t();
|
|
@@ -885,7 +885,7 @@ function Ge(t) {
|
|
|
885
885
|
console.error(e);
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
|
-
class
|
|
888
|
+
class Ge {
|
|
889
889
|
// One-time callbacks
|
|
890
890
|
readCallbacks = /* @__PURE__ */ new Set();
|
|
891
891
|
updateCallbacks = /* @__PURE__ */ new Set();
|
|
@@ -1066,7 +1066,7 @@ class He {
|
|
|
1066
1066
|
return e === this.readKeepAlive || e === this.updateKeepAlive || e === this.renderKeepAlive;
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
|
-
class
|
|
1069
|
+
class ge {
|
|
1070
1070
|
gestureId = 0;
|
|
1071
1071
|
activeGestures = /* @__PURE__ */ new Map();
|
|
1072
1072
|
disabledGestures = /* @__PURE__ */ new Map();
|
|
@@ -1138,7 +1138,7 @@ class ve {
|
|
|
1138
1138
|
return new _e(this, n, e, r, s, i);
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
const
|
|
1141
|
+
const ve = new ge();
|
|
1142
1142
|
class _e {
|
|
1143
1143
|
// Private members
|
|
1144
1144
|
el;
|
|
@@ -1275,10 +1275,10 @@ class _e {
|
|
|
1275
1275
|
this.el && (this.el.removeEventListener("touchstart", this.boundOnStart), document.removeEventListener("touchmove", this.boundOnMove), document.removeEventListener("touchend", this.boundOnEnd), document.removeEventListener("touchcancel", this.boundOnEnd), this.el.removeEventListener("mousedown", this.boundOnStart), document.removeEventListener("mousemove", this.boundOnMove), document.removeEventListener("mouseup", this.boundOnEnd), document.removeEventListener("mouseleave", this.boundOnEnd), this.controller.release(this.id));
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
|
-
function
|
|
1279
|
-
return
|
|
1278
|
+
function je(t, e) {
|
|
1279
|
+
return ve.createGesture(t, e);
|
|
1280
1280
|
}
|
|
1281
|
-
function
|
|
1281
|
+
function Xe(t) {
|
|
1282
1282
|
typeof document > "u" || (document.startViewTransition ? document.startViewTransition(t) : t());
|
|
1283
1283
|
}
|
|
1284
1284
|
let Se = 0;
|
|
@@ -1308,27 +1308,27 @@ function Ye(t, e = [], i = {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
export {
|
|
1310
1310
|
y as Computed,
|
|
1311
|
-
|
|
1311
|
+
g as Effect,
|
|
1312
1312
|
$e as Fragment,
|
|
1313
|
-
|
|
1313
|
+
Ge as FrameScheduler,
|
|
1314
1314
|
u as Signal,
|
|
1315
1315
|
Ce as batch,
|
|
1316
1316
|
Ee as computed,
|
|
1317
1317
|
De as createContext,
|
|
1318
|
-
|
|
1319
|
-
|
|
1318
|
+
je as createGesture,
|
|
1319
|
+
v as effect,
|
|
1320
1320
|
Ne as get,
|
|
1321
1321
|
Oe as hydrate,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1322
|
+
Me as link,
|
|
1323
|
+
Ie as onBeforeExit,
|
|
1324
|
+
Ke as onLoad,
|
|
1325
1325
|
Le as onMount,
|
|
1326
|
-
|
|
1326
|
+
He as onUnmount,
|
|
1327
1327
|
Te as peek,
|
|
1328
|
-
|
|
1328
|
+
xe as render,
|
|
1329
1329
|
Ae as set,
|
|
1330
1330
|
we as signal,
|
|
1331
|
-
|
|
1331
|
+
Xe as startViewTransition,
|
|
1332
1332
|
Pe as suspend,
|
|
1333
1333
|
Fe as useContext,
|
|
1334
1334
|
Ye as withViewTransition
|
package/dist/server.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:fs/promises"),m=require("node:path");function A(
|
|
11
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:fs/promises"),m=require("node:path");function A(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function b(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}const v=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function H(t){return/^on[A-Z]/.test(t)}function j(t){return Object.entries(t).map(([r,o])=>`${r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}:${o}`).join(";")}function E(t,r=!0){const o=Object.entries(t).filter(([e,n])=>!(n==null||r&&e==="children"||e==="innerHTML"||H(e))).map(([e,n])=>(e==="className"&&(e="class"),e==="style"&&typeof n=="object"&&(n=j(n)),typeof n=="boolean"?n?e:"":`${e}="${b(String(n))}"`)).filter(Boolean).join(" ");return o?` ${o}`:""}function $(t){return t?Array.isArray(t)?t:[t]:[]}function T(t){return t&&typeof t.then=="function"}function h(t,r){return`<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`}const l=new Map;let d=0;function w(t){return l.clear(),d=0,s(t)}async function D(t){l.clear(),d=0;let r=s(t);for(;l.size>0;){console.log(`🔄 Resolving ${l.size} async components in parallel...`);const o=Array.from(l.entries());l.clear();const e=await Promise.allSettled(o.map(([n,{promise:i}])=>i));for(let n=0;n<o.length;n++){const i=o[n];if(!i)continue;const[a,{componentName:c,errorFallback:u}]=i,p=e[n];if(!p)continue;const y=h(a,c);if(p.status==="fulfilled")try{console.log(`✅ Resolved: ${c} (${a})`);const f=s(p.value);r=r.replace(y,f)}catch(f){console.error(`❌ Error rendering ${c}:`,f);const S=u?s(typeof u=="function"?u(f):u):`<div class="error">Error rendering ${c}</div>`;r=r.replace(y,S)}else{console.error(`❌ Error resolving ${c}:`,p.reason);const f=u?s(typeof u=="function"?u(p.reason):u):`<div class="error">Error loading ${c}</div>`;r=r.replace(y,f)}}}return console.log("✅ All async components resolved!"),r}async function*P(t){for(l.clear(),d=0,yield s(t);l.size>0;){const o=Array.from(l.entries());l.clear();const e=o.map(async([n,{promise:i}])=>{try{const a=await i,c=s(a);return`<script>
|
|
12
12
|
(function() {
|
|
13
13
|
const el = document.getElementById('${n}');
|
|
14
14
|
if (el) {
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
el.innerHTML = '<div class="error">Error loading component</div>';
|
|
23
23
|
}
|
|
24
24
|
})();
|
|
25
|
-
<\/script>`}});for(const n of e)yield await n}}function s(
|
|
26
|
-
Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${i} (${n})`),
|
|
27
|
-
<html${e}>${i}</html>`:`<${
|
|
25
|
+
<\/script>`}});for(const n of e)yield await n}}function s(t){if(typeof t=="function"){const e=t();return Array.isArray(e)?`<!--reactive-list-->${e.map(i=>s(i)).join("")}`:s(e)}if(typeof t=="string")return A(t);if(typeof t=="number")return String(t);if(Array.isArray(t))return t.map(e=>s(e)).join("");if(!t||typeof t!="object")return"";const{type:r,props:o}=t;if(r===Symbol.for("jsx.fragment"))return $(o.children).map(n=>s(n)).join("");if(typeof r=="string"&&r==="suspended"){const e=t,n=`async-${d++}`;return console.log(`⏳ Suspending: ${e._componentName} (${n})`),l.set(n,{id:n,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback}),h(n,e._componentName)}if(typeof r=="function"){const e=r(o);if(T(e)){const n=`async-${d++}`,i=r.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${i}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
|
|
26
|
+
Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${i} (${n})`),l.set(n,{id:n,promise:e,componentName:i}),h(n,i)}return s(e)}if(typeof r=="string"){const e=E(o);if(v.has(r))return`<${r}${e} />`;if(o.innerHTML!==void 0){const a=typeof o.innerHTML=="object"?JSON.stringify(o.innerHTML):o.innerHTML;return`<${r}${e}>${a}</${r}>`}const i=$(o.children).map(a=>{if(Array.isArray(a))return a.map(c=>s(c)).join("");if(typeof a=="function"){const c=a();return Array.isArray(c)?`<!--reactive-list-->${c.map(p=>s(p)).join("")}`:`<!--reactive-->${s(c)}`}return s(a)}).join("");return r==="html"?`<!DOCTYPE html>
|
|
27
|
+
<html${e}>${i}</html>`:`<${r}${e}>${i}</${r}>`}return""}class L{cacheDir;useDirectoryStructure;constructor(r={}){this.cacheDir=r.cacheDir||"./cache/html",this.useDirectoryStructure=r.useDirectoryStructure??!1}async save(r,o){const e=this.getFilepath(r);return await g.mkdir(m.dirname(e),{recursive:!0}),await Bun.write(e,o),console.log(`✅ Pre-rendered: ${r} → ${e}`),e}async load(r){const o=this.getFilepath(r),e=Bun.file(o);return await e.exists()?e:null}async clear(){await g.rm(this.cacheDir,{recursive:!0,force:!0}),await g.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(r){const o=this.getFilepath(r);return await Bun.file(o).exists()}getFilepath(r){const o=r.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return o===""?m.join(this.cacheDir,"index.html"):m.join(this.cacheDir,o,"index.html");{const e=o===""?"index.html":`${o.replace(/\//g,"-")}.html`;return m.join(this.cacheDir,e)}}}exports.PreRenderer=L;exports.renderToStream=P;exports.renderToString=w;exports.renderToStringAsync=D;
|