@stacksjs/stx 0.2.286 → 0.2.288
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/builtins/index.d.ts +4 -3
- package/dist/builtins/index.js +11 -11
- package/dist/{chunk-3bv8h4r6.js → chunk-02af607x.js} +1 -1
- package/dist/chunk-06706a9a.js +2 -0
- package/dist/chunk-0896td83.js +2 -0
- package/dist/chunk-08yja60e.js +2 -0
- package/dist/{chunk-e2w23g2r.js → chunk-13tawjw8.js} +10 -10
- package/dist/{chunk-zn5jgmqw.js → chunk-1e83cj7k.js} +1 -1
- package/dist/chunk-1g6pvs7k.js +11 -0
- package/dist/chunk-1gvebxh4.js +2 -0
- package/dist/{chunk-jbfpc4z7.js → chunk-1t9g3mhg.js} +2 -2
- package/dist/{chunk-0f1kz0x2.js → chunk-2e6xafcm.js} +1 -1
- package/dist/chunk-2rfxs7zm.js +2 -0
- package/dist/{chunk-sskbegsz.js → chunk-2vza9m2x.js} +1 -1
- package/dist/{chunk-pbk8jxe2.js → chunk-2wtn443n.js} +1 -1
- package/dist/{chunk-6cye5m9f.js → chunk-34qkshwh.js} +2 -2
- package/dist/{chunk-2g9jwgs7.js → chunk-3br3pt6k.js} +1 -1
- package/dist/{chunk-kmhr1z0m.js → chunk-3p0n9ryv.js} +1 -1
- package/dist/chunk-437n7hyx.js +2 -0
- package/dist/{chunk-ayrjwkyw.js → chunk-461br5nn.js} +1 -1
- package/dist/chunk-4tr92e0v.js +2 -0
- package/dist/{chunk-t6nseeb9.js → chunk-4vpsvh6x.js} +1 -1
- package/dist/{chunk-nh21517m.js → chunk-5j9tvhpq.js} +2 -2
- package/dist/{chunk-mb518a4n.js → chunk-5yp3vt00.js} +1 -1
- package/dist/{chunk-e4hhz9j3.js → chunk-5zcg61j9.js} +2 -2
- package/dist/{chunk-snknv47x.js → chunk-6085vha7.js} +1 -1
- package/dist/{chunk-9th1wd1d.js → chunk-72c7gyqc.js} +3 -3
- package/dist/chunk-811cxzn4.js +2 -0
- package/dist/{chunk-bz2gytfs.js → chunk-8883pgj8.js} +1 -1
- package/dist/{chunk-vqxmxgaj.js → chunk-8bxtvsgm.js} +1 -1
- package/dist/{chunk-a63y3aa0.js → chunk-8daczchh.js} +1 -1
- package/dist/chunk-91ffbzmh.js +2 -0
- package/dist/chunk-96cqevhm.js +2 -0
- package/dist/chunk-978faewt.js +2 -0
- package/dist/{chunk-g3fy0tw8.js → chunk-9veqmqb6.js} +154 -48
- package/dist/{chunk-7q9mwh4v.js → chunk-a668m28h.js} +1 -1
- package/dist/{chunk-xg57nax9.js → chunk-a9fxxwrv.js} +2 -2
- package/dist/chunk-adkjxvy6.js +2 -0
- package/dist/{chunk-a2qghr2x.js → chunk-agx0620p.js} +1 -1
- package/dist/chunk-ak06mywr.js +2 -0
- package/dist/chunk-ayaz0wcj.js +2 -0
- package/dist/{chunk-ah4e6e09.js → chunk-bphx7ngb.js} +2 -2
- package/dist/chunk-bw48gj8j.js +2 -0
- package/dist/{chunk-7rxtra1g.js → chunk-byq2xpgb.js} +1 -1
- package/dist/chunk-bzsjhyet.js +2 -0
- package/dist/{chunk-rhs51nmz.js → chunk-ch31zddx.js} +2 -2
- package/dist/chunk-cqzqfm7m.js +2 -0
- package/dist/{chunk-9zndrzb3.js → chunk-d0f60jrg.js} +2 -2
- package/dist/{chunk-c0an64km.js → chunk-dcxtrqfy.js} +1 -1
- package/dist/{chunk-bf8wf3r2.js → chunk-drbbt69f.js} +35 -10
- package/dist/chunk-e0aybavh.js +2 -0
- package/dist/chunk-e63a220e.js +28 -0
- package/dist/chunk-e67w1bge.js +2 -0
- package/dist/chunk-e7kd0ny8.js +2 -0
- package/dist/{chunk-y8n174xq.js → chunk-ee2tfpec.js} +2 -2
- package/dist/{chunk-9n0gvfrg.js → chunk-efr3ejqt.js} +1 -1
- package/dist/chunk-evfct6hb.js +2 -0
- package/dist/{chunk-kzyhvrp8.js → chunk-favq46aa.js} +1 -1
- package/dist/{chunk-0fgcnv6y.js → chunk-fcfphfpw.js} +2 -2
- package/dist/{chunk-w95sp0k9.js → chunk-fed3xsp9.js} +2 -2
- package/dist/{chunk-e7jfpyqy.js → chunk-ffmtamm2.js} +1 -1
- package/dist/{chunk-39f40yc4.js → chunk-fv923f7g.js} +1 -1
- package/dist/{chunk-jr3jp3ev.js → chunk-fvh9ca47.js} +1 -1
- package/dist/chunk-fxk9j0rm.js +2 -0
- package/dist/{chunk-fskfes13.js → chunk-gy933rct.js} +1 -1
- package/dist/{chunk-f3hfk78e.js → chunk-h61qt916.js} +1 -1
- package/dist/{chunk-c6fw33zh.js → chunk-h7v70dbp.js} +2 -2
- package/dist/{chunk-bz820epz.js → chunk-hmf9z4jx.js} +1 -1
- package/dist/{chunk-j9g11dzx.js → chunk-hqh7x9h5.js} +2 -2
- package/dist/{chunk-hs0387tm.js → chunk-hv5v6vc2.js} +2 -2
- package/dist/{chunk-xttsqmkm.js → chunk-jem20v5k.js} +1 -1
- package/dist/{chunk-t1k5dpbr.js → chunk-jj6yp7gm.js} +1 -1
- package/dist/{chunk-90qr4f9m.js → chunk-jv91rkhx.js} +1 -1
- package/dist/{chunk-qbeffw17.js → chunk-jyc9eha6.js} +1 -1
- package/dist/{chunk-w3ycm4na.js → chunk-k0y7ta0d.js} +1 -1
- package/dist/chunk-k4jt9t4p.js +2 -0
- package/dist/{chunk-9y0g8kzt.js → chunk-k70fgb2f.js} +1 -1
- package/dist/{chunk-74cv4ta1.js → chunk-k78gvm0g.js} +1 -1
- package/dist/{chunk-jn6m8zf7.js → chunk-kb5j08tq.js} +1 -1
- package/dist/{chunk-a54n1r1q.js → chunk-kf8t2wq7.js} +1 -1
- package/dist/chunk-kfy1jh6p.js +2 -0
- package/dist/chunk-kws4rewx.js +17 -0
- package/dist/{chunk-s67mgegv.js → chunk-mc58fhgm.js} +1 -1
- package/dist/{chunk-n3ggrhb3.js → chunk-mjpqz66q.js} +1 -1
- package/dist/{chunk-mjkfc2v6.js → chunk-mmnqd035.js} +1 -1
- package/dist/{chunk-54st8g2j.js → chunk-mywp77gt.js} +1 -1
- package/dist/{chunk-p396xrew.js → chunk-n0j85038.js} +1 -1
- package/dist/{chunk-gjemavhx.js → chunk-n5y9gh1q.js} +1 -1
- package/dist/{chunk-qd8ggjdx.js → chunk-n9kk3jz1.js} +1 -1
- package/dist/{chunk-49kk0s96.js → chunk-nmkra8q5.js} +2 -2
- package/dist/{chunk-s2284nbk.js → chunk-np5dc1q1.js} +1 -1
- package/dist/chunk-nygtwffe.js +5 -0
- package/dist/{chunk-y6kw0wb7.js → chunk-p0zq5ckb.js} +1 -1
- package/dist/chunk-pb16azfa.js +4 -0
- package/dist/{chunk-nx5qkm8k.js → chunk-ps20v1ah.js} +1 -1
- package/dist/chunk-pv9apyrr.js +2 -0
- package/dist/chunk-qj2s3r1w.js +3756 -0
- package/dist/chunk-qjkzpd68.js +11 -0
- package/dist/chunk-qww39be9.js +2 -0
- package/dist/chunk-r90w3x6h.js +2 -0
- package/dist/chunk-rb87b7kr.js +2 -0
- package/dist/{chunk-an2539bs.js → chunk-rjqfa3g8.js} +2 -2
- package/dist/{chunk-2q630fj4.js → chunk-sag55qv7.js} +1 -1
- package/dist/chunk-srcbkg7g.js +2 -0
- package/dist/chunk-sxderfaa.js +12 -0
- package/dist/{chunk-ysnk7x79.js → chunk-t5c7rk0h.js} +1 -1
- package/dist/chunk-v2z3creg.js +2 -0
- package/dist/chunk-vtjfv7kg.js +2 -0
- package/dist/{chunk-5aq35j2e.js → chunk-vvqe2gaz.js} +2 -2
- package/dist/{chunk-s7pc68jf.js → chunk-vwzqg4fh.js} +2 -2
- package/dist/{chunk-7p9ns60j.js → chunk-vxxxczmn.js} +1 -1
- package/dist/chunk-vzzkhjw7.js +2 -0
- package/dist/{chunk-wcm80anz.js → chunk-wvq1g6gr.js} +1 -1
- package/dist/{chunk-y7m2dpd3.js → chunk-wyxw61az.js} +1 -1
- package/dist/{chunk-kdrpx9ft.js → chunk-xpct12p7.js} +1 -1
- package/dist/chunk-xvndd7h6.js +2 -0
- package/dist/{chunk-d0c3v7ax.js → chunk-y5jjrnfa.js} +1 -1
- package/dist/{chunk-vbdca0k1.js → chunk-ym4ggcpy.js} +1 -1
- package/dist/{chunk-q68xmak4.js → chunk-ymc99r5x.js} +18 -18
- package/dist/{chunk-refwkt87.js → chunk-ynt7y2n5.js} +1 -1
- package/dist/chunk-z6azwfb4.js +2 -0
- package/dist/chunk-zfnabevq.js +2 -0
- package/dist/{chunk-cvnh7dma.js → chunk-zqwmy0av.js} +1 -1
- package/dist/{chunk-phhzfeh9.js → chunk-zvw2qgwt.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/client-module-registry.d.ts +36 -0
- package/dist/client-module-registry.js +55 -0
- package/dist/client-script-bundler.d.ts +39 -0
- package/dist/client-script-bundler.js +89 -12
- package/dist/client-script.js +15 -8
- package/dist/component-client-factories.js +10 -5
- package/dist/component-processing.d.ts +13 -0
- package/dist/component-processing.js +37 -1
- package/dist/component-renderer.js +34 -15
- package/dist/conditionals.js +14 -3
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/document-shell.d.ts +1 -34
- package/dist/document-shell.js +19 -11
- package/dist/html-masking.d.ts +65 -9
- package/dist/html-masking.js +103 -15
- package/dist/misc-directives.d.ts +1 -1
- package/dist/misc-directives.js +48 -13
- package/dist/process.js +38 -7
- package/dist/pwa.js +2 -2
- package/dist/reactive-bindings.js +2 -0
- package/dist/runtime-globals.d.ts +7 -20
- package/dist/runtime-globals.js +28 -3
- package/dist/safe-evaluator.d.ts +15 -0
- package/dist/safe-evaluator.js +16 -12
- package/dist/server-bindings.js +21 -5
- package/dist/signal-processing.d.ts +17 -7
- package/dist/signal-processing.js +116 -46
- package/dist/signals-api.js +5 -2
- package/dist/signals.js +153 -47
- package/dist/ssg.js +2 -2
- package/dist/store-loader.js +1 -1
- package/dist/strip-literals.d.ts +20 -0
- package/dist/strip-literals.js +16 -0
- package/dist/utils.js +24 -7
- package/dist/variable-extractor.js +17 -47
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-3ehv1by2.js +0 -2
- package/dist/chunk-4cqgbcy7.js +0 -3756
- package/dist/chunk-52mh63sp.js +0 -11
- package/dist/chunk-56ywtaff.js +0 -2
- package/dist/chunk-61sj52qh.js +0 -2
- package/dist/chunk-7ej1d910.js +0 -2
- package/dist/chunk-829pcte9.js +0 -2
- package/dist/chunk-8emkx9ja.js +0 -2
- package/dist/chunk-ajbfeey7.js +0 -2
- package/dist/chunk-areethga.js +0 -2
- package/dist/chunk-b29wbjs5.js +0 -2
- package/dist/chunk-b7tjq91c.js +0 -2
- package/dist/chunk-ba6tthsm.js +0 -2
- package/dist/chunk-e4akvata.js +0 -2
- package/dist/chunk-f4k2a7vs.js +0 -2
- package/dist/chunk-f80wwn5x.js +0 -2
- package/dist/chunk-fjkstnz3.js +0 -2
- package/dist/chunk-j03bare5.js +0 -2
- package/dist/chunk-jg0axas8.js +0 -2
- package/dist/chunk-jrk8rhwt.js +0 -28
- package/dist/chunk-kawk5ve9.js +0 -2
- package/dist/chunk-m3yaa0v5.js +0 -15
- package/dist/chunk-m7xnzt2t.js +0 -2
- package/dist/chunk-mkn6qqc7.js +0 -2
- package/dist/chunk-n3jyv9z6.js +0 -2
- package/dist/chunk-nvgxjvnb.js +0 -2
- package/dist/chunk-qk8tbcwk.js +0 -2
- package/dist/chunk-qp97dx7x.js +0 -2
- package/dist/chunk-qsr3bqav.js +0 -12
- package/dist/chunk-vb10qph4.js +0 -2
- package/dist/chunk-vrvehb01.js +0 -2
- package/dist/chunk-vy8v5xdb.js +0 -2
- package/dist/chunk-w0sqz3cb.js +0 -11
- package/dist/chunk-w8smn72c.js +0 -2
- package/dist/chunk-wxk2pbrh.js +0 -2
- package/dist/chunk-x1nw1p8z.js +0 -2
- package/dist/chunk-xz55q3gr.js +0 -2
- package/dist/chunk-yq1d9hb3.js +0 -2
- package/dist/chunk-ytgnzeeb.js +0 -2
- package/dist/chunk-zfr4d08r.js +0 -2
package/dist/signals.js
CHANGED
|
@@ -781,7 +781,16 @@ finally {
|
|
|
781
781
|
if (options.immediate !== false) runEffect();
|
|
782
782
|
const dispose = () => {
|
|
783
783
|
isDisposed = true;
|
|
784
|
-
|
|
784
|
+
// Idempotent. A removed :for row is disposed on removal, and the page
|
|
785
|
+
// tracker that collected its effects on first render still holds the
|
|
786
|
+
// same disposer, which cleanupContainer calls on SPA navigation (#1954).
|
|
787
|
+
// Clearing cleanup before calling it stops that second call running it
|
|
788
|
+
// twice.
|
|
789
|
+
if (cleanup) {
|
|
790
|
+
const pending = cleanup;
|
|
791
|
+
cleanup = undefined;
|
|
792
|
+
pending();
|
|
793
|
+
}
|
|
785
794
|
};
|
|
786
795
|
// Auto-register with active tracker
|
|
787
796
|
if (activeDisposers) activeDisposers.push(dispose);
|
|
@@ -3778,9 +3787,10 @@ else {
|
|
|
3778
3787
|
const removeGroup = (group) => {
|
|
3779
3788
|
const liveNodes = liveGroupNodes(group);
|
|
3780
3789
|
const liveSet = new Set(liveNodes);
|
|
3781
|
-
liveNodes.forEach(e => { disposeSubtreeScopes(e); e.remove(); });
|
|
3790
|
+
liveNodes.forEach(e => { disposeSubtreeEffects(e); disposeSubtreeScopes(e); e.remove(); });
|
|
3782
3791
|
group.forEach(groupNode => {
|
|
3783
3792
|
if (liveSet.has(groupNode)) return;
|
|
3793
|
+
disposeSubtreeEffects(groupNode);
|
|
3784
3794
|
disposeSubtreeScopes(groupNode);
|
|
3785
3795
|
groupNode.remove();
|
|
3786
3796
|
});
|
|
@@ -3865,13 +3875,15 @@ catch (e) {
|
|
|
3865
3875
|
if (emptyTemplate) {
|
|
3866
3876
|
emptyElement = emptyTemplate.cloneNode(true);
|
|
3867
3877
|
parent.insertBefore(emptyElement, placeholder);
|
|
3868
|
-
|
|
3878
|
+
const shownEmpty = emptyElement;
|
|
3879
|
+
shownEmpty.__stx_effect_disposers = trackEffects(function() { processElement(shownEmpty); });
|
|
3869
3880
|
}
|
|
3870
3881
|
};
|
|
3871
3882
|
|
|
3872
3883
|
// Helper to hide empty state
|
|
3873
3884
|
const hideEmpty = () => {
|
|
3874
3885
|
if (emptyElement) {
|
|
3886
|
+
disposeSubtreeEffects(emptyElement);
|
|
3875
3887
|
emptyElement.remove();
|
|
3876
3888
|
emptyElement = null;
|
|
3877
3889
|
}
|
|
@@ -4142,8 +4154,11 @@ catch (e) {
|
|
|
4142
4154
|
if (el.nodeType === 1) {
|
|
4143
4155
|
var itemScope = el.__stx_for_scope || passedScope;
|
|
4144
4156
|
delete el.__stx_for_scope;
|
|
4157
|
+
// Tracked so removeGroup can dispose the row's effects (#1954). Kept
|
|
4158
|
+
// off __stx_disposers, which marks a hydrated component root here
|
|
4159
|
+
// and in the deferred :if pass.
|
|
4145
4160
|
if (!el.__stx_disposers && el.tagName !== 'SCRIPT')
|
|
4146
|
-
processElement(el, itemScope);
|
|
4161
|
+
el.__stx_effect_disposers = trackEffects(function() { processElement(el, itemScope); });
|
|
4147
4162
|
el.removeAttribute('x-cloak');
|
|
4148
4163
|
el.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));
|
|
4149
4164
|
}
|
|
@@ -4166,12 +4181,14 @@ catch (e) {
|
|
|
4166
4181
|
const liveNodes = liveGroupNodes(group);
|
|
4167
4182
|
const transitioned = new Set();
|
|
4168
4183
|
liveNodes.forEach((el) => {
|
|
4184
|
+
disposeSubtreeEffects(el);
|
|
4169
4185
|
disposeSubtreeScopes(el);
|
|
4170
4186
|
if (tgLeave(el, tgName)) transitioned.add(el);
|
|
4171
4187
|
else el.remove();
|
|
4172
4188
|
});
|
|
4173
4189
|
group.forEach((el) => {
|
|
4174
4190
|
if (transitioned.has(el) || liveNodes.includes(el)) return;
|
|
4191
|
+
disposeSubtreeEffects(el);
|
|
4175
4192
|
disposeSubtreeScopes(el);
|
|
4176
4193
|
el.remove();
|
|
4177
4194
|
});
|
|
@@ -4361,7 +4378,16 @@ catch (e2) {
|
|
|
4361
4378
|
// still handled by bindFor (item removal) and cleanupContainer (SPA nav).
|
|
4362
4379
|
if (currentIdx !== -1) {
|
|
4363
4380
|
chain[currentIdx].el.__stx_chain_active = false;
|
|
4364
|
-
chain[currentIdx].nodes.forEach(function (n) {
|
|
4381
|
+
chain[currentIdx].nodes.forEach(function (n) {
|
|
4382
|
+
if (!n.parentNode) return;
|
|
4383
|
+
// Detached nodes are out of reach of a DOM walk, so a row removed
|
|
4384
|
+
// while this branch is hidden could not dispose the effects it was
|
|
4385
|
+
// processed with (#1954). Same registry the single-element :if uses.
|
|
4386
|
+
var host = n.parentNode;
|
|
4387
|
+
if (!host.__stx_detached_if) host.__stx_detached_if = new Set();
|
|
4388
|
+
host.__stx_detached_if.add(n);
|
|
4389
|
+
host.removeChild(n);
|
|
4390
|
+
});
|
|
4365
4391
|
}
|
|
4366
4392
|
|
|
4367
4393
|
// Insert + process the newly-picked branch.
|
|
@@ -4371,7 +4397,11 @@ catch (e2) {
|
|
|
4371
4397
|
// Insert this branch's node(s) before the placeholder's next sibling.
|
|
4372
4398
|
// The anchor is captured once so the nodes stack in source order.
|
|
4373
4399
|
var anchor = pick.placeholder.nextSibling;
|
|
4374
|
-
pick.nodes.forEach(function (n) {
|
|
4400
|
+
pick.nodes.forEach(function (n) {
|
|
4401
|
+
var host = pick.placeholder.parentNode;
|
|
4402
|
+
if (host.__stx_detached_if) host.__stx_detached_if.delete(n);
|
|
4403
|
+
host.insertBefore(n, anchor);
|
|
4404
|
+
});
|
|
4375
4405
|
pick.el.__stx_shown_at = performance.now();
|
|
4376
4406
|
if (!pick.childrenProcessed) {
|
|
4377
4407
|
pick.childrenProcessed = true;
|
|
@@ -4381,6 +4411,10 @@ catch (e2) {
|
|
|
4381
4411
|
// to process projected slot expressions without the loop caller
|
|
4382
4412
|
// scope. peek() keeps this synchronous pass from subscribing child
|
|
4383
4413
|
// reads to the current chain effect.
|
|
4414
|
+
// Tracked on the branch element: this runs inside the chain effect,
|
|
4415
|
+
// where no tracker is active, so without a handle the effects of a
|
|
4416
|
+
// branch picked after render survive their row's removal (#1954).
|
|
4417
|
+
pick.el.__stx_chain_disposers = trackEffects(function () {
|
|
4384
4418
|
peek(function () {
|
|
4385
4419
|
var childScope = { ...globalHelpers, ...capturedComponentScope, ...(pick.capturedElementScope || {}) };
|
|
4386
4420
|
// Components compiled inside any branch of an if/else-if/else
|
|
@@ -4407,6 +4441,7 @@ catch (e2) {
|
|
|
4407
4441
|
n.querySelectorAll('[x-cloak]').forEach(function (c) { c.removeAttribute('x-cloak'); });
|
|
4408
4442
|
});
|
|
4409
4443
|
});
|
|
4444
|
+
});
|
|
4410
4445
|
}
|
|
4411
4446
|
}
|
|
4412
4447
|
|
|
@@ -4429,6 +4464,14 @@ catch (e2) {
|
|
|
4429
4464
|
}
|
|
4430
4465
|
|
|
4431
4466
|
const placeholder = document.createComment('stx-if');
|
|
4467
|
+
// Marks where this branch's rendered content ENDS (stacksjs/stx#1955).
|
|
4468
|
+
// Hiding used to remove only the cloned nodes, but a structural directive
|
|
4469
|
+
// directly inside the template renders its own output as siblings that are
|
|
4470
|
+
// not among those clones -- a <template :for> at the top level of a
|
|
4471
|
+
// <template :if> left every row on screen after the branch went false.
|
|
4472
|
+
// Only the template branch needs it; the single-element branch owns exactly
|
|
4473
|
+
// the node it was bound to.
|
|
4474
|
+
let endMarker = null;
|
|
4432
4475
|
let isInserted = true;
|
|
4433
4476
|
|
|
4434
4477
|
// Handle <template> elements specially - clone their content
|
|
@@ -4455,6 +4498,13 @@ catch (e2) {
|
|
|
4455
4498
|
// multi-root template branch.
|
|
4456
4499
|
const initialAnchor = placeholder.nextSibling;
|
|
4457
4500
|
currentNodes.forEach(node => parent.insertBefore(node, initialAnchor));
|
|
4501
|
+
// The end of this branch's range, bound at the same time as the content
|
|
4502
|
+
// it closes (#1955). Needed here too, not only on re-show: the first
|
|
4503
|
+
// hide of a branch that was never toggled removes THIS content, and a
|
|
4504
|
+
// nested :for renders rows that are siblings of these clones rather than
|
|
4505
|
+
// among them.
|
|
4506
|
+
endMarker = document.createComment('stx-if-end');
|
|
4507
|
+
parent.insertBefore(endMarker, initialAnchor);
|
|
4458
4508
|
el.remove(); // Remove the template element itself
|
|
4459
4509
|
}
|
|
4460
4510
|
|
|
@@ -4520,7 +4570,7 @@ catch (e2) {
|
|
|
4520
4570
|
hydrateComponentScopes(nodes, childScope);
|
|
4521
4571
|
nodes.forEach(node => {
|
|
4522
4572
|
if (!node.__stx_disposers && node.tagName !== 'SCRIPT')
|
|
4523
|
-
processElement(node, childScope);
|
|
4573
|
+
node.__stx_effect_disposers = trackEffects(function() { processElement(node, childScope); });
|
|
4524
4574
|
if (node.nodeType === 1) {
|
|
4525
4575
|
node.removeAttribute('x-cloak');
|
|
4526
4576
|
node.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));
|
|
@@ -4548,6 +4598,10 @@ catch (e2) {
|
|
|
4548
4598
|
currentNodes = Array.from(el.content.childNodes).map(n => n.cloneNode(true));
|
|
4549
4599
|
const insertionAnchor = placeholder.nextSibling;
|
|
4550
4600
|
currentNodes.forEach(node => parent.insertBefore(node, insertionAnchor));
|
|
4601
|
+
// Bound AFTER the clones, so hiding can remove whatever a nested
|
|
4602
|
+
// structural directive rendered as their sibling (#1955).
|
|
4603
|
+
if (!endMarker) endMarker = document.createComment('stx-if-end');
|
|
4604
|
+
parent.insertBefore(endMarker, insertionAnchor);
|
|
4551
4605
|
processTemplateNodes(currentNodes);
|
|
4552
4606
|
childrenProcessed = true;
|
|
4553
4607
|
// Stamp insertion time for click propagation guard
|
|
@@ -4557,8 +4611,28 @@ catch (e2) {
|
|
|
4557
4611
|
else if (!value && isInserted) {
|
|
4558
4612
|
// Remove all current nodes. Do NOT disposeSubtreeScopes \u2014 :if is a
|
|
4559
4613
|
// toggle, not a permanent unmount; see the single-element branch
|
|
4560
|
-
// below and #1737.
|
|
4561
|
-
|
|
4614
|
+
// below and #1737. Effects are disposed, though: these clones are never
|
|
4615
|
+
// reused, and a re-show clones afresh, so leaving them bound only
|
|
4616
|
+
// accumulates work (#1954).
|
|
4617
|
+
//
|
|
4618
|
+
// Everything between the placeholder and the end marker goes, not
|
|
4619
|
+
// just the clones: a nested :for or :if renders siblings of its own
|
|
4620
|
+
// that no clone list contains (#1955).
|
|
4621
|
+
// Only walk the range when THIS binding inserted the content and
|
|
4622
|
+
// left its marker. Without that guard the walk ran to the end of the
|
|
4623
|
+
// parent and took a sibling <template :if> with it -- the initial
|
|
4624
|
+
// server-rendered state has no marker to stop at.
|
|
4625
|
+
if (endMarker && endMarker.parentNode === parent) {
|
|
4626
|
+
var doomed = placeholder.nextSibling;
|
|
4627
|
+
while (doomed && doomed !== endMarker) {
|
|
4628
|
+
var nextDoomed = doomed.nextSibling;
|
|
4629
|
+
disposeSubtreeEffects(doomed);
|
|
4630
|
+
doomed.remove();
|
|
4631
|
+
doomed = nextDoomed;
|
|
4632
|
+
}
|
|
4633
|
+
endMarker.remove();
|
|
4634
|
+
}
|
|
4635
|
+
currentNodes.forEach(node => { disposeSubtreeEffects(node); node.remove(); });
|
|
4562
4636
|
currentNodes = [];
|
|
4563
4637
|
isInserted = false;
|
|
4564
4638
|
childrenProcessed = false;
|
|
@@ -4580,6 +4654,7 @@ else {
|
|
|
4580
4654
|
console.log('[stx] bindIf INSERTING element for :if=' + expr);
|
|
4581
4655
|
const insertionAnchor = placeholder.nextSibling;
|
|
4582
4656
|
currentNodes.forEach(node => parent.insertBefore(node, insertionAnchor));
|
|
4657
|
+
if (parent && parent.__stx_detached_if) currentNodes.forEach(node => parent.__stx_detached_if.delete(node));
|
|
4583
4658
|
el.__stx_shown_at = performance.now();
|
|
4584
4659
|
isInserted = true;
|
|
4585
4660
|
}
|
|
@@ -4595,6 +4670,13 @@ else if (!value && isInserted) {
|
|
|
4595
4670
|
// and cleanupContainer (SPA navigation). The double-bind guards make
|
|
4596
4671
|
// re-show idempotent, so toggling doesn't leak.
|
|
4597
4672
|
currentNodes.forEach(node => node.remove());
|
|
4673
|
+
// Detached nodes are out of reach of a DOM walk, so an ancestor row or
|
|
4674
|
+
// branch removed while this is hidden could not dispose their effects
|
|
4675
|
+
// (#1954). Record them on the parent that keeps the placeholder.
|
|
4676
|
+
if (parent) {
|
|
4677
|
+
if (!parent.__stx_detached_if) parent.__stx_detached_if = new Set();
|
|
4678
|
+
currentNodes.forEach(node => parent.__stx_detached_if.add(node));
|
|
4679
|
+
}
|
|
4598
4680
|
isInserted = false;
|
|
4599
4681
|
console.log('[stx] bindIf REMOVED, el.isConnected:', el.isConnected);
|
|
4600
4682
|
}
|
|
@@ -4613,6 +4695,14 @@ else if (!value && isInserted) {
|
|
|
4613
4695
|
// in a :if binds a macrotask after the synchronous stx:load audit (#1773).
|
|
4614
4696
|
el.__stx_if_pending = true;
|
|
4615
4697
|
setTimeout(function() {
|
|
4698
|
+
// Removed with its row, or hidden again, before this ran. Hydrating
|
|
4699
|
+
// a detached element now creates effects nothing will dispose
|
|
4700
|
+
// (#1954). Leave it unprocessed so the next show schedules the pass.
|
|
4701
|
+
if (!el.isConnected) {
|
|
4702
|
+
childrenProcessed = false;
|
|
4703
|
+
el.__stx_if_pending = false;
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4616
4706
|
var childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
|
|
4617
4707
|
// A false single-element conditional is detached before the
|
|
4618
4708
|
// DOMContentLoaded component-scope pass. When it becomes visible,
|
|
@@ -4621,8 +4711,11 @@ else if (!value && isInserted) {
|
|
|
4621
4711
|
// the same lifecycle as components inserted by template :if.
|
|
4622
4712
|
var wasTrackedBeforeConditionalHydration = !!el.__stx_disposers;
|
|
4623
4713
|
hydrateComponentScopes(currentNodes, childScope);
|
|
4714
|
+
// Tracked on its own property so an ancestor row or branch removal
|
|
4715
|
+
// reaches these effects too (#1954). This runs after the enclosing
|
|
4716
|
+
// tracker has closed, so nothing else would collect them.
|
|
4624
4717
|
if (wasTrackedBeforeConditionalHydration || !el.__stx_disposers)
|
|
4625
|
-
processElement(el, childScope);
|
|
4718
|
+
el.__stx_if_disposers = trackEffects(function() { processElement(el, childScope); });
|
|
4626
4719
|
// Remove x-cloak from the inserted subtree \u2014 the initial
|
|
4627
4720
|
// cloak removal (after processElement on the root) already
|
|
4628
4721
|
// ran before this deferred processing, so newly-inserted
|
|
@@ -7554,6 +7647,51 @@ catch (e) {
|
|
|
7554
7647
|
// indefinitely. Now bindIf, bindFor, and cleanupContainer all funnel
|
|
7555
7648
|
// through this helper so the cleanup is symmetric regardless of who
|
|
7556
7649
|
// initiated the removal.
|
|
7650
|
+
// Dispose the EFFECTS bound inside a subtree leaving the page for good: a
|
|
7651
|
+
// removed :for row, a hidden template :if clone, a hidden :for empty
|
|
7652
|
+
// placeholder, or a container on SPA navigation (#1954).
|
|
7653
|
+
// disposeSubtreeScopes only releases scope registrations. Without this, the
|
|
7654
|
+
// effects that bound the subtree stay subscribed to every signal they read
|
|
7655
|
+
// and keep running, so work per update grows with every removal.
|
|
7656
|
+
// Descendants first, then the root, the order cleanupContainer always used.
|
|
7657
|
+
function disposeSubtreeEffects(root) {
|
|
7658
|
+
if (!root) return;
|
|
7659
|
+
var nodes = [];
|
|
7660
|
+
if (root.querySelectorAll) {
|
|
7661
|
+
var all = root.querySelectorAll('*');
|
|
7662
|
+
for (var i = 0; i < all.length; i++) nodes.push(all[i]);
|
|
7663
|
+
}
|
|
7664
|
+
nodes.push(root);
|
|
7665
|
+
var owned = ['__stx_disposers', '__stx_effect_disposers', '__stx_if_disposers', '__stx_chain_disposers'];
|
|
7666
|
+
for (var n = 0; n < nodes.length; n++) {
|
|
7667
|
+
var el = nodes[n];
|
|
7668
|
+
if (typeof el.__stx_hydration_cancel === 'function') {
|
|
7669
|
+
try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }
|
|
7670
|
+
el.__stx_hydration_cancel = null;
|
|
7671
|
+
}
|
|
7672
|
+
if (Array.isArray(el.__stx_destroy)) {
|
|
7673
|
+
var hooks = el.__stx_destroy;
|
|
7674
|
+
el.__stx_destroy = null;
|
|
7675
|
+
hooks.forEach(function(fn) {
|
|
7676
|
+
try { fn(); }
|
|
7677
|
+
catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
7678
|
+
});
|
|
7679
|
+
}
|
|
7680
|
+
if (el.__stx_detached_if) {
|
|
7681
|
+
var detached = el.__stx_detached_if;
|
|
7682
|
+
el.__stx_detached_if = null;
|
|
7683
|
+
detached.forEach(function(node) { disposeSubtreeEffects(node); });
|
|
7684
|
+
}
|
|
7685
|
+
for (var k = 0; k < owned.length; k++) {
|
|
7686
|
+
var disposeOwned = el[owned[k]];
|
|
7687
|
+
if (typeof disposeOwned === 'function') {
|
|
7688
|
+
el[owned[k]] = null;
|
|
7689
|
+
disposeOwned();
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
7694
|
+
|
|
7557
7695
|
function disposeSubtreeScopes(root) {
|
|
7558
7696
|
if (!root || !window.stx || !window.stx._scopes) return;
|
|
7559
7697
|
// Build the list of nodes to inspect: root + descendants with the
|
|
@@ -7842,43 +7980,11 @@ catch (e) {
|
|
|
7842
7980
|
if (el.__stx_scope) Object.assign(componentScope, el.__stx_scope);
|
|
7843
7981
|
});
|
|
7844
7982
|
|
|
7845
|
-
// 1.
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }
|
|
7851
|
-
el.__stx_hydration_cancel = null;
|
|
7852
|
-
}
|
|
7853
|
-
if (el.__stx_destroy && Array.isArray(el.__stx_destroy)) {
|
|
7854
|
-
el.__stx_destroy.forEach(function(fn) {
|
|
7855
|
-
try { fn(); }
|
|
7856
|
-
catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
7857
|
-
});
|
|
7858
|
-
el.__stx_destroy = null;
|
|
7859
|
-
}
|
|
7860
|
-
if (el.__stx_disposers && typeof el.__stx_disposers === 'function') {
|
|
7861
|
-
el.__stx_disposers();
|
|
7862
|
-
el.__stx_disposers = null;
|
|
7863
|
-
}
|
|
7864
|
-
});
|
|
7865
|
-
|
|
7866
|
-
// 2. Check container itself
|
|
7867
|
-
if (typeof container.__stx_hydration_cancel === 'function') {
|
|
7868
|
-
try { container.__stx_hydration_cancel(); } catch (e) { /* noop */ }
|
|
7869
|
-
container.__stx_hydration_cancel = null;
|
|
7870
|
-
}
|
|
7871
|
-
if (container.__stx_destroy) {
|
|
7872
|
-
container.__stx_destroy.forEach(function(fn) {
|
|
7873
|
-
try { fn(); }
|
|
7874
|
-
catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
7875
|
-
});
|
|
7876
|
-
container.__stx_destroy = null;
|
|
7877
|
-
}
|
|
7878
|
-
if (container.__stx_disposers) {
|
|
7879
|
-
container.__stx_disposers();
|
|
7880
|
-
container.__stx_disposers = null;
|
|
7881
|
-
}
|
|
7983
|
+
// 1-2. Every descendant, then the container: cancel pending island
|
|
7984
|
+
// hydration (#1746), fire destroy hooks, dispose effects. Shared with
|
|
7985
|
+
// :for row removal and template :if hide so all three release the same
|
|
7986
|
+
// trackers, including the row and branch ones added for #1954.
|
|
7987
|
+
disposeSubtreeEffects(container);
|
|
7882
7988
|
// Clear __stx_scope so _handleStxLoad's processElement guard doesn't skip it
|
|
7883
7989
|
container.__stx_scope = null;
|
|
7884
7990
|
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Dk as Fq,yk as Uq,zk as Iq}from"./chunk-
|
|
2
|
+
import{Dk as Fq,yk as Uq,zk as Iq}from"./chunk-1e83cj7k.js";import{Ek as Eq,Fk as Tq,Gk as Dq}from"./chunk-58f0mthg.js";import{$k as _q,cl as zq,dl as Aq}from"./chunk-kws4rewx.js";import{$n as l,Gm as Oq,Hp as P,Uo as Bq,co as Hq,er as n}from"./chunk-qj2s3r1w.js";import"./chunk-ymc99r5x.js";import"./chunk-dcxtrqfy.js";import"./chunk-jj6yp7gm.js";import"./chunk-qjkzpd68.js";import"./chunk-t5c7rk0h.js";import{yt as Xq}from"./chunk-72c7gyqc.js";import{Dt as d}from"./chunk-fv923f7g.js";import"./chunk-2e6xafcm.js";import"./chunk-nygtwffe.js";import"./chunk-461br5nn.js";import"./chunk-h7v70dbp.js";import{Ru as Yq,Su as Vq,Tu as jq,Uu as Gq,Vu as Lq,Wu as Nq}from"./chunk-drbbt69f.js";import"./chunk-kb5j08tq.js";import{kv as y}from"./chunk-2vza9m2x.js";import O from"fs";import j from"path";import{createHash as xq}from"crypto";function yq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var Pq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Cq(q){return Bun.hash(q).toString(16)}function Qq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(Pq,(J,W,z,A)=>{let G=A.trim();if(!G)return J;if(/\bdata-stx-src=/.test(z))return J;if(Z.minify)G=yq(G);let X=Cq(G);if(!$.has(X))$.set(X,G);let B=Z.integrity?` data-stx-integrity="sha384-${xq("sha384").update(G).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${X}.js"${B}${z}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var gq=new Set(["visible","idle"]);function Zq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(gq.has(Z.get(W[1])||""))K.add(W[2]);let z=q.lastIndexOf("</head>");if(K.size===0||z===-1)return q;let A=Array.from(K).filter((G)=>!q.includes(`rel="prefetch" href="${G}"`)).map((G)=>`<link rel="prefetch" href="${G}" as="script">`).join("");if(!A)return q;return q.slice(0,z)+A+q.slice(z)}var fq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function h(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function mq(q){for(let Z of fq){let $=q[Z];if(!$)continue;let Q=h($);if(Q)return{url:Q,source:"env",via:Z}}return null}function $q(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?h($):null}async function dq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=$q(J.default??J);if(W)return W}catch{}}return null}async function Kq(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=h(q.explicit);if(W)return{url:W,source:"option"}}let Q=$q(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await dq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=mq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Wq(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class wq{cacheDir;cache=new Map;loaded=!1;salt;constructor(q,Z=""){this.cacheDir=q,this.salt=Z}async load(){if(this.loaded)return;let q=j.join(this.cacheDir,"build-cache.json");if(await Bun.file(q).exists())try{let Z=JSON.parse(await Bun.file(q).text());for(let[$,Q]of Object.entries(Z))this.cache.set($,Q)}catch{}this.loaded=!0}async save(){await O.promises.mkdir(this.cacheDir,{recursive:!0});let q=j.join(this.cacheDir,"build-cache.json"),Z={};for(let[$,Q]of this.cache)Z[$]=Q;await Bun.write(q,JSON.stringify(Z))}getHash(q,Z){let $=O.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(O.existsSync(J)){let W=O.statSync(J);Q+=`:${J}:${W.mtimeMs}`}let K=0;for(let J=0;J<Q.length;J++){let W=Q.charCodeAt(J);K=(K<<5)-K+W,K=K&K}return Math.abs(K).toString(36)}get(q,Z){let $=this.cache.get(q);if(!$)return null;let Q=this.getHash(Z,$.dependencies??[]);if($.hash!==Q)return this.cache.delete(q),null;return $.html}set(q,Z,$,Q){let K=this.getHash(Z,$);this.cache.set(q,{hash:K,html:Q,generatedAt:Date.now(),dependencies:$})}}class Rq{cacheDir;constructor(q){this.cacheDir=q}getFilePath(q){let Z=q.replace(/[^a-zA-Z0-9]/g,"_")+".json";return j.join(this.cacheDir,"isr",Z)}async get(q){let Z=this.getFilePath(q);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set(q,Z){let $=this.getFilePath(q);await O.promises.mkdir(j.dirname($),{recursive:!0}),await Bun.write($,JSON.stringify(Z))}async invalidate(q){let Z=this.getFilePath(q);if(await Bun.file(Z).exists())await O.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!O.existsSync(Z))return;let $=await O.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await O.promises.unlink(j.join(Z,Q))}}async needsRevalidation(q){let Z=await this.get(q);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function pq(q){try{let $=(await Bun.file(q).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!$)return null;let Q=$[1];if(!Q.includes("getStaticPaths"))return null;let K=Q.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!K)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${K[1]}
|
|
@@ -41,7 +41,7 @@ ${q.map((Q)=>{let K=new URL(Q.loc,Z).href,J=` <url>
|
|
|
41
41
|
${$.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function aq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,A=0,G={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let L=J.cacheSalt;if(!L){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-
|
|
44
|
+
</rss>`}async function aq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,A=0,G={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let L=J.cacheSalt;if(!L){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-sag55qv7.js");try{L=N(await Y(process.cwd()))}catch{}}let{prepareImageDelivery:_}=await import("./chunk-96cqevhm.js"),F=await _(J.publicDir,J.outputDir);if(F.count>0)console.log(`Optimized ${F.count} image(s) for responsive delivery`),L=[L,F.fingerprint].filter(Boolean).join(":");let C=new wq(J.cacheDir,L);if(J.cache)await C.load();try{let{generateCss:Y}=await import("./chunk-sag55qv7.js");await Y('<div class="bg-black"></div>')}catch{}Yq();let kq=$?.routeMiddleware?.dir||"middleware";await jq(process.cwd(),kq);let p=Vq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let bq=$?.routeMiddleware?.global||[];Fq($?.layoutsDir,d(process.cwd()));let i=l(".",{pagesDir:J.pagesDir});console.log(`Found ${i.length} routes`);let g=[];for(let Y of i){let N=await uq(Y);for(let H of N)g.push({route:Y,url:H.url,params:H.params,props:H.props,revalidate:H.revalidate??J.revalidate})}W.totalPages=g.length,console.log(`Generating ${W.totalPages} pages...`);let b=[],s=[];for(let Y=0;Y<g.length;Y+=J.concurrency)s.push(g.slice(Y,Y+J.concurrency));for(let Y of s)await Promise.all(Y.map(async(N)=>{let{route:H,url:V,params:S,props:Sq,revalidate:a}=N;try{await J.hooks.onPageStart?.(V);let w=await Bun.file(H.filePath).text(),R=JJ(w),vq=R?.middleware?Array.isArray(R.middleware)?R.middleware:[R.middleware]:[],t=[...bq,...vq];if(t.length>0){let D=Gq(V,S,R||{}),M=Lq(D,null,void 0,{isServer:!0}),E=await Nq(t,M);if(E.redirect){let U=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,x=QJ(String(U),V),k=ZJ(V,J);await O.promises.mkdir(j.dirname(k),{recursive:!0}),await Bun.write(k,x),W.successCount++,W.pages.push({route:V,outputPath:k,size:Buffer.byteLength(x),cached:!1}),b.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${U}`);return}if(E.abort){let U=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${U}`);return}}let e=w.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(e)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${e[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:S})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let I=null,qq=!1;if(J.cache){if(I=C.get(V,H.filePath),I)qq=!0,W.cachedCount++}if(!I){let D=await Mq(H,S,Sq,J,$);if(I=D.html,J.failOnIncludeError&&D.includeFailures.length>0)throw Error(`${D.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
package/dist/store-loader.js
CHANGED
|
@@ -79,7 +79,7 @@ export async function getStoreScript(storesDir) {
|
|
|
79
79
|
const storeName = path.basename(file, ".ts");
|
|
80
80
|
collectDeclaredNames(code, declaredNames);
|
|
81
81
|
if (hasUserImports(code))
|
|
82
|
-
code = await bundleClientScript(code, file, { projectRoot: process.cwd() });
|
|
82
|
+
code = await bundleClientScript(code, file, { projectRoot: process.cwd(), externalizeUserModules: !1 });
|
|
83
83
|
code = stripStxRuntimeImports(code);
|
|
84
84
|
code = transformStoreImports(code);
|
|
85
85
|
code = stripModuleImports(code);
|
package/dist/strip-literals.d.ts
CHANGED
|
@@ -38,3 +38,23 @@ export declare function findInterpolationEnd(code: string, start: number): numbe
|
|
|
38
38
|
* undefined name.
|
|
39
39
|
*/
|
|
40
40
|
export declare function stripCommentsAndLiterals(code: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Bracket nesting at each index of already-stripped source, so a declaration
|
|
43
|
+
* can be told apart from one nested inside a function, block or loop head.
|
|
44
|
+
* Parens and square brackets count too: `for (const x of rows)` is scoped to
|
|
45
|
+
* the loop, not the file.
|
|
46
|
+
*
|
|
47
|
+
* `balanced` is false when the brackets do not close out cleanly -- they go
|
|
48
|
+
* negative, or end above zero. stripCommentsAndLiterals does not recognise
|
|
49
|
+
* regex literals, so `/\\{/` leaves a brace behind, and every depth after it is
|
|
50
|
+
* off by one. A caller must not trust `depths` then, and should fall back to
|
|
51
|
+
* whatever it did before it knew about nesting: acting on a wrong depth can
|
|
52
|
+
* hide a real top-level binding, which is worse than the bug depth fixes.
|
|
53
|
+
*
|
|
54
|
+
* Shared by the payload bridge (#1953) and the bundler's export scan (#1959),
|
|
55
|
+
* which asked the same question with the same blind spot.
|
|
56
|
+
*/
|
|
57
|
+
export declare function bracketDepths(stripped: string): {
|
|
58
|
+
depths: Uint16Array;
|
|
59
|
+
balanced: boolean;
|
|
60
|
+
};
|
package/dist/strip-literals.js
CHANGED
|
@@ -147,3 +147,19 @@ export function stripCommentsAndLiterals(code) {
|
|
|
147
147
|
}
|
|
148
148
|
return out;
|
|
149
149
|
}
|
|
150
|
+
export function bracketDepths(stripped) {
|
|
151
|
+
const depths = new Uint16Array(stripped.length);
|
|
152
|
+
let depth = 0, balanced = !0;
|
|
153
|
+
for (let i = 0;i < stripped.length; i++) {
|
|
154
|
+
const char = stripped[i];
|
|
155
|
+
if (char === ")" || char === "]" || char === "}")
|
|
156
|
+
if (depth === 0)
|
|
157
|
+
balanced = !1;
|
|
158
|
+
else
|
|
159
|
+
depth--;
|
|
160
|
+
depths[i] = depth;
|
|
161
|
+
if (char === "(" || char === "[" || char === "{")
|
|
162
|
+
depth++;
|
|
163
|
+
}
|
|
164
|
+
return { depths, balanced: balanced && depth === 0 };
|
|
165
|
+
}
|
package/dist/utils.js
CHANGED
|
@@ -15,6 +15,7 @@ import { transformStoreImports } from "./store-imports.js";
|
|
|
15
15
|
import { LRUCache } from "./performance-utils.js";
|
|
16
16
|
import { processDirectives } from "./process.js";
|
|
17
17
|
import { getPublicEnvDefine } from "./public-env.js";
|
|
18
|
+
import { isUsableParamName } from "./safe-evaluator.js";
|
|
18
19
|
import { processScopedStyles } from "./style-scoping.js";
|
|
19
20
|
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
20
21
|
import { importOnce } from "./lazy-module.js";
|
|
@@ -101,8 +102,22 @@ export function getSharedTranspiler(options) {
|
|
|
101
102
|
transpilerPool.set(key, transpiler);
|
|
102
103
|
return transpiler;
|
|
103
104
|
}
|
|
105
|
+
const transpileResults = new WeakMap, TRANSPILE_RESULTS_MAX_ENTRIES = 256;
|
|
104
106
|
export function transpileTypeScript(code) {
|
|
105
107
|
try {
|
|
108
|
+
const transpiler = getSharedTranspiler({
|
|
109
|
+
loader: "ts",
|
|
110
|
+
target: "browser",
|
|
111
|
+
define: getPublicEnvDefine()
|
|
112
|
+
});
|
|
113
|
+
let results = transpileResults.get(transpiler);
|
|
114
|
+
if (!results) {
|
|
115
|
+
results = new Map;
|
|
116
|
+
transpileResults.set(transpiler, results);
|
|
117
|
+
}
|
|
118
|
+
const cached = results.get(code);
|
|
119
|
+
if (cached !== void 0)
|
|
120
|
+
return cached;
|
|
106
121
|
let processedCode = code.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
107
122
|
processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
108
123
|
const placeholders = [];
|
|
@@ -121,15 +136,17 @@ export function transpileTypeScript(code) {
|
|
|
121
136
|
placeholders.push(match);
|
|
122
137
|
return `"__STX_EXPR_${idx}__"`;
|
|
123
138
|
});
|
|
124
|
-
let result =
|
|
125
|
-
loader: "ts",
|
|
126
|
-
target: "browser",
|
|
127
|
-
define: getPublicEnvDefine()
|
|
128
|
-
}).transformSync(processedCode);
|
|
139
|
+
let result = transpiler.transformSync(processedCode);
|
|
129
140
|
for (let i = 0;i < placeholders.length; i++) {
|
|
130
141
|
result = result.replace(`"__STX_EXPR_${i}__"`, placeholders[i]);
|
|
131
142
|
result = result.replace(`'__STX_EXPR_${i}__'`, placeholders[i]);
|
|
132
143
|
}
|
|
144
|
+
if (results.size >= TRANSPILE_RESULTS_MAX_ENTRIES) {
|
|
145
|
+
const oldest = results.keys().next();
|
|
146
|
+
if (!oldest.done)
|
|
147
|
+
results.delete(oldest.value);
|
|
148
|
+
}
|
|
149
|
+
results.set(code, result);
|
|
133
150
|
return result;
|
|
134
151
|
} catch (e) {
|
|
135
152
|
if (process.env.STX_DEBUG_TS)
|
|
@@ -375,7 +392,7 @@ function applyDestructuredPropDefaults(componentContent, ctx) {
|
|
|
375
392
|
if (!expr)
|
|
376
393
|
continue;
|
|
377
394
|
try {
|
|
378
|
-
const keys = Object.keys(ctx), fn = Function(...keys, `"use strict"; return (${expr});`);
|
|
395
|
+
const keys = Object.keys(ctx).filter(isUsableParamName), fn = Function(...keys, `"use strict"; return (${expr});`);
|
|
379
396
|
ctx[name] = fn(...keys.map((k) => ctx[k]));
|
|
380
397
|
} catch {}
|
|
381
398
|
}
|
|
@@ -754,7 +771,7 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
|
|
|
754
771
|
const [, attrs, rawContent] = scriptMatch, { vendorStyleTags, factoryBody } = await buildComponentIsland(rawContent, componentFilePath, options.buildMode === "compile"), factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
|
|
755
772
|
if (hydrateTrigger)
|
|
756
773
|
return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped${attrs}>${wrappedContent}</script>`;
|
|
757
|
-
return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always"${attrs}>${wrappedContent}</script>`;
|
|
774
|
+
return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${scopeId}"${attrs}>${wrappedContent}</script>`;
|
|
758
775
|
}));
|
|
759
776
|
output = output + `
|
|
760
777
|
` + scopedScripts.join(`
|
|
@@ -56,10 +56,10 @@ const ENGINE_BINDINGS = new Set(STX_ENGINE_BINDING_NAMES), CONTEXT_RESERVED_BIND
|
|
|
56
56
|
import { findMatchingDelimiter } from "./parser/tokenizer.js";
|
|
57
57
|
import { mergeHeadConfigs, seoMetaToHeadConfig } from "./head.js";
|
|
58
58
|
import { getPublicEnvDefine } from "./public-env.js";
|
|
59
|
-
import { safeEvaluate } from "./safe-evaluator.js";
|
|
59
|
+
import { isUsableParamName, safeEvaluate } from "./safe-evaluator.js";
|
|
60
60
|
import { responseBindings } from "./page-response.js";
|
|
61
61
|
import { contentKey, renderMemo } from "./render-memo.js";
|
|
62
|
-
const transpiledServerScripts = renderMemo(128);
|
|
62
|
+
const transpiledServerScripts = renderMemo(128), compiledServerScripts = renderMemo(64);
|
|
63
63
|
function extractDeclaredVariableNames(script) {
|
|
64
64
|
const names = [];
|
|
65
65
|
let depth = 0;
|
|
@@ -479,48 +479,12 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
479
479
|
removeEventListener: () => {}
|
|
480
480
|
}, mockConsole = console;
|
|
481
481
|
try {
|
|
482
|
-
const convertedScript = convertToCommonJS(jsContent, filePath), propsKeys = new Set(Object.keys(propsObj)),
|
|
482
|
+
const convertedScript = convertToCommonJS(jsContent, filePath), propsKeys = new Set(Object.keys(propsObj)), filteredContextKeys = Object.keys(context).filter((key) => !propsKeys.has(key) && !CONTEXT_RESERVED_BINDINGS.has(key) && isUsableParamName(key)), filteredContextValues = filteredContextKeys.map((key) => context[key]);
|
|
483
483
|
if (!filteredContextKeys.includes("__stxServeContext")) {
|
|
484
484
|
filteredContextKeys.push("__stxServeContext");
|
|
485
485
|
filteredContextValues.push(void 0);
|
|
486
486
|
}
|
|
487
|
-
const
|
|
488
|
-
"break",
|
|
489
|
-
"case",
|
|
490
|
-
"catch",
|
|
491
|
-
"class",
|
|
492
|
-
"const",
|
|
493
|
-
"continue",
|
|
494
|
-
"debugger",
|
|
495
|
-
"default",
|
|
496
|
-
"delete",
|
|
497
|
-
"do",
|
|
498
|
-
"else",
|
|
499
|
-
"export",
|
|
500
|
-
"extends",
|
|
501
|
-
"finally",
|
|
502
|
-
"for",
|
|
503
|
-
"function",
|
|
504
|
-
"if",
|
|
505
|
-
"import",
|
|
506
|
-
"in",
|
|
507
|
-
"instanceof",
|
|
508
|
-
"let",
|
|
509
|
-
"new",
|
|
510
|
-
"return",
|
|
511
|
-
"super",
|
|
512
|
-
"switch",
|
|
513
|
-
"this",
|
|
514
|
-
"throw",
|
|
515
|
-
"try",
|
|
516
|
-
"typeof",
|
|
517
|
-
"var",
|
|
518
|
-
"void",
|
|
519
|
-
"while",
|
|
520
|
-
"with",
|
|
521
|
-
"yield",
|
|
522
|
-
"enum",
|
|
523
|
-
"await",
|
|
487
|
+
const stxShadowedNames = new Set([
|
|
524
488
|
"async",
|
|
525
489
|
"module",
|
|
526
490
|
"exports",
|
|
@@ -534,9 +498,9 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
534
498
|
"effect"
|
|
535
499
|
]), propArgNames = [], propArgValues = [];
|
|
536
500
|
for (const [key, value] of Object.entries(propsObj)) {
|
|
537
|
-
if (
|
|
501
|
+
if (!isUsableParamName(key))
|
|
538
502
|
continue;
|
|
539
|
-
if (
|
|
503
|
+
if (stxShadowedNames.has(key))
|
|
540
504
|
continue;
|
|
541
505
|
if (new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${key}\\b`).test(convertedScript))
|
|
542
506
|
continue;
|
|
@@ -551,11 +515,17 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
551
515
|
scriptContextKeys.push(filteredContextKeys[i]);
|
|
552
516
|
scriptContextValues.push(filteredContextValues[i]);
|
|
553
517
|
}
|
|
554
|
-
const
|
|
518
|
+
const scriptParams = [...STX_ENGINE_BINDING_NAMES, ...propArgNames, ...scriptContextKeys], scriptBody = `return (async () => {
|
|
555
519
|
${convertedScript}
|
|
556
520
|
${reSyncCode}
|
|
557
521
|
return module.exports
|
|
558
|
-
})()
|
|
522
|
+
})()`, compileKey = contentKey(scriptBody, scriptParams.join("\x00"));
|
|
523
|
+
let scriptFn = compiledServerScripts.get(compileKey);
|
|
524
|
+
if (!scriptFn) {
|
|
525
|
+
scriptFn = Function(...scriptParams, scriptBody);
|
|
526
|
+
compiledServerScripts.set(compileKey, scriptFn);
|
|
527
|
+
}
|
|
528
|
+
const result = await scriptFn(module, exports, requireFn, propsObj, $props, defineProps, withDefaults, defineClientPayload, state, derived, effect, batch, onMount, onDestroy, definePageMeta, useRoute, useRouter, useHead, useSeoMeta, responseApi.setResponseStatus, responseApi.setResponseHeader, responseApi.notFound, ref, reactive, computed, watch, onMounted, onUnmounted, nextTick, defineEmits, defineExpose, defineSlots, provide, inject, useColorMode, useDark, useMediaQuery, useScrollLock, usePreferredDark, usePreferredLight, usePreferredReducedMotion, usePreferredContrast, windowProxy, mockDocument, mockConsole, mockWindow.confirm, mockWindow.alert, mockWindow.fetch, paramsObj, ...propArgValues, ...scriptContextValues);
|
|
559
529
|
if (options.preserveExisting) {
|
|
560
530
|
for (const [key, value] of Object.entries(result))
|
|
561
531
|
if (!(key in context) || context[key] === void 0)
|
|
@@ -1290,12 +1260,12 @@ function evaluateFallbackExpression(expression, context) {
|
|
|
1290
1260
|
return direct;
|
|
1291
1261
|
if (!/\bprocess\b/.test(expression))
|
|
1292
1262
|
return;
|
|
1293
|
-
const processEnvContext = { ...context, process: Object.freeze({ env: { ...process.env } }) };
|
|
1263
|
+
const processEnvContext = { ...context, process: Object.freeze({ env: { ...process.env } }) }, envKeys = Object.keys(processEnvContext).filter(isUsableParamName), envValues = envKeys.map((key) => processEnvContext[key]);
|
|
1294
1264
|
try {
|
|
1295
|
-
return Function(...
|
|
1265
|
+
return Function(...envKeys, `'use strict'; return (${expression});`)(...envValues);
|
|
1296
1266
|
} catch {
|
|
1297
1267
|
try {
|
|
1298
|
-
return Function(...
|
|
1268
|
+
return Function(...envKeys, `'use strict'; return ${expression};`)(...envValues);
|
|
1299
1269
|
} catch {
|
|
1300
1270
|
return;
|
|
1301
1271
|
}
|