@stacksjs/stx 0.2.531 → 0.2.533
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/{chunk-ktmacsqc.js → chunk-01343ehq.js} +2 -2
- package/dist/chunk-0e5nasyf.js +2 -0
- package/dist/chunk-13zbt9py.js +2 -0
- package/dist/{chunk-9w2vmfha.js → chunk-1c4t7ncb.js} +2 -2
- package/dist/{chunk-gxfnmjzp.js → chunk-1xgs9gd5.js} +2 -2
- package/dist/{chunk-hrrxggpx.js → chunk-2bvk0qyd.js} +63 -12
- package/dist/{chunk-cp8f1pv4.js → chunk-2h4f37kx.js} +2 -2
- package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
- package/dist/{chunk-8n7qsr17.js → chunk-2n4je46m.js} +2 -2
- package/dist/{chunk-xcfhy5bj.js → chunk-33bzhsyw.js} +2 -2
- package/dist/{chunk-7ybgfk0m.js → chunk-3nk8cnrm.js} +2 -2
- package/dist/{chunk-gsxb0ry9.js → chunk-3r1m3tyr.js} +1 -1
- package/dist/chunk-3zs8yxy0.js +2 -0
- package/dist/{chunk-d3mssbgp.js → chunk-40hbpz2b.js} +5 -5
- package/dist/chunk-4a7v51vh.js +2 -0
- package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
- package/dist/{chunk-srcv6wvm.js → chunk-4pxc3r1p.js} +4 -4
- package/dist/chunk-4qts8zk7.js +2 -0
- package/dist/{chunk-587ehsxn.js → chunk-4r7s3862.js} +2 -2
- package/dist/chunk-4y2av4ev.js +2 -0
- package/dist/chunk-5g498pdp.js +2 -0
- package/dist/chunk-5gq8m2m7.js +2 -0
- package/dist/chunk-5wx323bm.js +2 -0
- package/dist/{chunk-d2r8t40y.js → chunk-66s4nhp7.js} +2 -2
- package/dist/{chunk-d7x6n702.js → chunk-6dtmants.js} +3 -3
- package/dist/chunk-6rcxtdh3.js +2 -0
- package/dist/{chunk-st79dqpz.js → chunk-6sd4zdtg.js} +1 -1
- package/dist/{chunk-zpdq0kx1.js → chunk-6tnh3cyq.js} +1 -1
- package/dist/chunk-6va8wt88.js +2 -0
- package/dist/chunk-7v2j9bmc.js +2 -0
- package/dist/chunk-7zgtdap7.js +2 -0
- package/dist/{chunk-rsy1r1t2.js → chunk-843y0pfg.js} +4 -4
- package/dist/{chunk-b0tmg1q1.js → chunk-8chxczpj.js} +3 -3
- package/dist/{chunk-b7xdk1g4.js → chunk-8m1y1kyr.js} +5 -5
- package/dist/chunk-90kzf313.js +2 -0
- package/dist/{chunk-m5c2gts6.js → chunk-93n6yv5x.js} +12 -12
- package/dist/chunk-94rg5s6c.js +2 -0
- package/dist/chunk-9674w2gm.js +2 -0
- package/dist/{chunk-tvssmzc2.js → chunk-9p6bt089.js} +3 -3
- package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
- package/dist/{chunk-v38kqjew.js → chunk-bxsehntq.js} +1 -1
- package/dist/{chunk-vg8thz41.js → chunk-c56qtne1.js} +1 -1
- package/dist/chunk-d1jxmhph.js +2 -0
- package/dist/{chunk-5tj6expd.js → chunk-d7zterbp.js} +2 -2
- package/dist/{chunk-mc5agc81.js → chunk-d871008z.js} +4 -4
- package/dist/chunk-dekpf1ry.js +2 -0
- package/dist/chunk-epa1c4q4.js +2 -0
- package/dist/{chunk-95z7yemm.js → chunk-f3q84h7b.js} +2 -2
- package/dist/{chunk-mwte3cbe.js → chunk-fqfqyn48.js} +4 -4
- package/dist/{chunk-qwpgggkj.js → chunk-gnx0fzne.js} +60 -60
- package/dist/chunk-gsc5t942.js +2 -0
- package/dist/chunk-gsm1y1kb.js +2 -0
- package/dist/chunk-gxedmh17.js +2 -0
- package/dist/{chunk-9xq5yer8.js → chunk-h4crv0by.js} +1 -1
- package/dist/{chunk-pr5q4wev.js → chunk-hp8g2q2n.js} +1 -1
- package/dist/{chunk-38w14qs7.js → chunk-hvpzy98g.js} +1 -1
- package/dist/chunk-j9c0yam7.js +2 -0
- package/dist/{chunk-12e4a0ab.js → chunk-jbfad9cc.js} +2 -2
- package/dist/chunk-jv3jj612.js +2 -0
- package/dist/chunk-jvqas8y2.js +2 -0
- package/dist/{chunk-z14e2qyn.js → chunk-k3v13vfr.js} +2 -2
- package/dist/chunk-kcs7hyep.js +2 -0
- package/dist/chunk-kvp0at16.js +2 -0
- package/dist/{chunk-31c1g3rt.js → chunk-m011s2ha.js} +3 -3
- package/dist/{chunk-2jk0vceh.js → chunk-m56m95gk.js} +2 -2
- package/dist/{chunk-7s14bthq.js → chunk-m5fw8jq1.js} +2 -2
- package/dist/chunk-m7jmpech.js +2 -0
- package/dist/chunk-m8n9wxba.js +2 -0
- package/dist/{chunk-fyxydww2.js → chunk-mjdyyekx.js} +2 -2
- package/dist/{chunk-ennxrn5g.js → chunk-nd8v4xgb.js} +5 -5
- package/dist/chunk-ngma9vzc.js +2 -0
- package/dist/{chunk-rtk6n3vh.js → chunk-ngxqydsg.js} +3 -3
- package/dist/{chunk-cxxcy624.js → chunk-nmy4x6dx.js} +4 -4
- package/dist/chunk-pz1mjgsp.js +2 -0
- package/dist/{chunk-er031j13.js → chunk-qfc912e5.js} +2 -2
- package/dist/chunk-qk3ptn6h.js +2 -0
- package/dist/{chunk-03wggzg8.js → chunk-qmza4327.js} +2 -2
- package/dist/{chunk-w3xs6kb9.js → chunk-qqr4rn9p.js} +4 -4
- package/dist/chunk-rx4hz615.js +2 -0
- package/dist/chunk-shf0hd05.js +2 -0
- package/dist/{chunk-3vvppnws.js → chunk-sqb6gkzf.js} +8374 -8374
- package/dist/chunk-t1g1sp2z.js +2 -0
- package/dist/{chunk-9f3m5ecs.js → chunk-tgc645pa.js} +45 -45
- package/dist/{chunk-2dzd2h15.js → chunk-tkvp3rz0.js} +1 -1
- package/dist/{chunk-458etq5a.js → chunk-tqnh98j7.js} +3 -3
- package/dist/chunk-tr9bjtqx.js +2 -0
- package/dist/{chunk-2y6tzn6d.js → chunk-ty1v368m.js} +2 -2
- package/dist/{chunk-fmp8dmt0.js → chunk-v4r8nzf3.js} +1 -1
- package/dist/{chunk-p8yh7mgr.js → chunk-v9vvzdag.js} +2 -2
- package/dist/{chunk-0wvsfs4s.js → chunk-vb4xxpa6.js} +2 -2
- package/dist/chunk-vfnerp7h.js +2 -0
- package/dist/{chunk-tkeabv04.js → chunk-vhfwnvmc.js} +5 -5
- package/dist/{chunk-15r72kw7.js → chunk-vjdj0ex3.js} +1 -1
- package/dist/{chunk-9pztpvvk.js → chunk-wh7xn313.js} +1 -1
- package/dist/chunk-wjt46tdp.js +2 -0
- package/dist/chunk-wxy9re1a.js +2 -0
- package/dist/{chunk-kwvexxey.js → chunk-x607yxrc.js} +3 -3
- package/dist/{chunk-3zyvhf4p.js → chunk-xey01yna.js} +1 -1
- package/dist/{chunk-7b2hj6nt.js → chunk-xwrbrg1q.js} +1 -1
- package/dist/{chunk-9sqjmd9a.js → chunk-y18yvcjb.js} +5 -5
- package/dist/chunk-ydtnskdv.js +2 -0
- package/dist/{chunk-ky25egh1.js → chunk-yw3cqy43.js} +1 -1
- package/dist/{chunk-tyts58ks.js → chunk-z9r3tqyr.js} +1 -1
- package/dist/chunk-zeve89kw.js +2 -0
- package/dist/cli.js +12 -12
- package/dist/client/signals-appearance-runtime.d.ts +2 -0
- package/dist/client/signals-appearance-runtime.js +283 -0
- package/dist/client/signals-authoring-runtime.d.ts +2 -0
- package/dist/client/signals-authoring-runtime.js +187 -0
- package/dist/client/signals-binding-utils-runtime.d.ts +2 -0
- package/dist/client/signals-binding-utils-runtime.js +130 -0
- package/dist/client/signals-bootstrap-runtime.d.ts +4 -0
- package/dist/client/signals-bootstrap-runtime.js +24 -0
- package/dist/client/signals-class-runtime.d.ts +2 -0
- package/dist/client/signals-class-runtime.js +69 -0
- package/dist/client/signals-component-api-runtime.d.ts +1 -0
- package/dist/client/signals-component-api-runtime.js +57 -0
- package/dist/client/signals-component-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-component-hydration-runtime.js +147 -0
- package/dist/client/signals-component-props-runtime.d.ts +2 -0
- package/dist/client/signals-component-props-runtime.js +90 -0
- package/dist/client/signals-conditional-chain-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-chain-runtime.js +39 -0
- package/dist/client/signals-conditional-component-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-component-runtime.js +82 -0
- package/dist/client/signals-container-cleanup-runtime.d.ts +2 -0
- package/dist/client/signals-container-cleanup-runtime.js +42 -0
- package/dist/client/signals-context-runtime.d.ts +2 -0
- package/dist/client/signals-context-runtime.js +48 -0
- package/dist/client/signals-cookie-runtime.d.ts +2 -0
- package/dist/client/signals-cookie-runtime.js +56 -0
- package/dist/client/signals-devtools-runtime.d.ts +2 -0
- package/dist/client/signals-devtools-runtime.js +136 -0
- package/dist/client/signals-dialog-runtime.d.ts +2 -0
- package/dist/client/signals-dialog-runtime.js +195 -0
- package/dist/client/signals-dom-ready-runtime.d.ts +2 -0
- package/dist/client/signals-dom-ready-runtime.js +306 -0
- package/dist/client/signals-drawer-runtime.d.ts +2 -0
- package/dist/client/signals-drawer-runtime.js +39 -0
- package/dist/client/signals-effect-runtime.d.ts +2 -0
- package/dist/client/signals-effect-runtime.js +157 -0
- package/dist/client/signals-event-shorthand-runtime.d.ts +2 -0
- package/dist/client/signals-event-shorthand-runtime.js +88 -0
- package/dist/client/signals-expression-compiler-runtime.d.ts +2 -0
- package/dist/client/signals-expression-compiler-runtime.js +59 -0
- package/dist/client/signals-expression-runtime.d.ts +2 -0
- package/dist/client/signals-expression-runtime.js +67 -0
- package/dist/client/signals-fetch-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-runtime.js +144 -0
- package/dist/client/signals-fetch-transport-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-transport-runtime.js +216 -0
- package/dist/client/signals-for-runtime.d.ts +2 -0
- package/dist/client/signals-for-runtime.js +647 -0
- package/dist/client/signals-globals-runtime.d.ts +2 -0
- package/dist/client/signals-globals-runtime.js +66 -0
- package/dist/client/signals-handler-runtime.d.ts +2 -0
- package/dist/client/signals-handler-runtime.js +80 -0
- package/dist/client/signals-head-runtime.d.ts +2 -0
- package/dist/client/signals-head-runtime.js +92 -0
- package/dist/client/signals-helpers-runtime.d.ts +2 -0
- package/dist/client/signals-helpers-runtime.js +137 -0
- package/dist/client/signals-host-runtime.d.ts +9 -0
- package/dist/client/signals-host-runtime.js +132 -0
- package/dist/client/signals-hydration-audit-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-audit-runtime.js +209 -0
- package/dist/client/signals-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-runtime.js +52 -0
- package/dist/client/signals-if-chain-runtime.d.ts +2 -0
- package/dist/client/signals-if-chain-runtime.js +283 -0
- package/dist/client/signals-if-runtime.d.ts +2 -0
- package/dist/client/signals-if-runtime.js +346 -0
- package/dist/client/signals-kept-runtime.d.ts +2 -0
- package/dist/client/signals-kept-runtime.js +62 -0
- package/dist/client/signals-lazy-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-lazy-hydration-runtime.js +133 -0
- package/dist/client/signals-lifecycle-runtime.d.ts +2 -0
- package/dist/client/signals-lifecycle-runtime.js +114 -0
- package/dist/client/signals-loop-component-remap-runtime.d.ts +2 -0
- package/dist/client/signals-loop-component-remap-runtime.js +66 -0
- package/dist/client/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/client/signals-loop-conditional-runtime.js +48 -0
- package/dist/client/signals-loop-row-runtime.d.ts +2 -0
- package/dist/client/signals-loop-row-runtime.js +41 -0
- package/dist/client/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-manifest-hydration-runtime.js +82 -0
- package/dist/client/signals-model-runtime.d.ts +2 -0
- package/dist/client/signals-model-runtime.js +156 -0
- package/dist/client/signals-mount-runtime.d.ts +1 -0
- package/dist/client/signals-mount-runtime.js +231 -0
- package/dist/client/signals-navigation-runtime.d.ts +2 -0
- package/dist/client/signals-navigation-runtime.js +198 -0
- package/dist/client/signals-optimistic-runtime.d.ts +2 -0
- package/dist/client/signals-optimistic-runtime.js +34 -0
- package/dist/client/signals-overlay-runtime.d.ts +2 -0
- package/dist/client/signals-overlay-runtime.js +352 -0
- package/dist/client/signals-pipe-runtime.d.ts +2 -0
- package/dist/client/signals-pipe-runtime.js +177 -0
- package/dist/client/signals-process-element-runtime.d.ts +1 -0
- package/dist/client/signals-process-element-runtime.js +696 -0
- package/dist/client/signals-proxy-runtime.d.ts +2 -0
- package/dist/client/signals-proxy-runtime.js +78 -0
- package/dist/client/signals-public-api-runtime.d.ts +1 -0
- package/dist/client/signals-public-api-runtime.js +120 -0
- package/dist/client/signals-query-runtime.d.ts +2 -0
- package/dist/client/signals-query-runtime.js +351 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.d.ts +1 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.js +30 -0
- package/dist/client/signals-reactive-runtime.d.ts +2 -0
- package/dist/client/signals-reactive-runtime.js +67 -0
- package/dist/client/signals-ref-runtime.d.ts +2 -0
- package/dist/client/signals-ref-runtime.js +33 -0
- package/dist/client/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-disposal-runtime.js +195 -0
- package/dist/client/signals-scope-traversal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-traversal-runtime.js +42 -0
- package/dist/client/signals-show-runtime.d.ts +2 -0
- package/dist/client/signals-show-runtime.js +54 -0
- package/dist/client/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-control-runtime.js +42 -0
- package/dist/client/signals-spa-load-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-runtime.js +187 -0
- package/dist/client/signals-state-runtime.d.ts +2 -0
- package/dist/client/signals-state-runtime.js +125 -0
- package/dist/client/signals-storage-runtime.d.ts +2 -0
- package/dist/client/signals-storage-runtime.js +79 -0
- package/dist/client/signals-store-registry-runtime.d.ts +1 -0
- package/dist/client/signals-store-registry-runtime.js +461 -0
- package/dist/client/signals-style-runtime.d.ts +2 -0
- package/dist/client/signals-style-runtime.js +35 -0
- package/dist/client/signals-suspense-runtime.d.ts +2 -0
- package/dist/client/signals-suspense-runtime.js +59 -0
- package/dist/client/signals-timer-runtime.d.ts +2 -0
- package/dist/client/signals-timer-runtime.js +378 -0
- package/dist/client/signals-toast-runtime.d.ts +2 -0
- package/dist/client/signals-toast-runtime.js +206 -0
- package/dist/client/signals-tooltip-runtime.d.ts +2 -0
- package/dist/client/signals-tooltip-runtime.js +40 -0
- package/dist/client/signals-transition-group-runtime.d.ts +2 -0
- package/dist/client/signals-transition-group-runtime.js +92 -0
- package/dist/client/signals-websocket-runtime.d.ts +2 -0
- package/dist/client/signals-websocket-runtime.js +138 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/runtime/native-host.js +4 -1
- package/dist/pwa.js +3 -3
- package/dist/signals-context-runtime.d.ts +2 -0
- package/dist/signals-drawer-runtime.d.ts +2 -0
- package/dist/signals-host-runtime.d.ts +9 -0
- package/dist/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/signals-optimistic-runtime.d.ts +2 -0
- package/dist/signals-overlay-runtime.d.ts +2 -0
- package/dist/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/signals-storage-runtime.d.ts +2 -0
- package/dist/signals.js +141 -9900
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-0zmv31nc.js +0 -2
- package/dist/chunk-1cdanx2v.js +0 -2
- package/dist/chunk-1wt5fagh.js +0 -2
- package/dist/chunk-2936t942.js +0 -2
- package/dist/chunk-3dd5zxbt.js +0 -2
- package/dist/chunk-3v91cb0g.js +0 -2
- package/dist/chunk-4cyjdghc.js +0 -2
- package/dist/chunk-5achv4zv.js +0 -2
- package/dist/chunk-5yg6m30k.js +0 -2
- package/dist/chunk-6qzjyr8e.js +0 -2
- package/dist/chunk-785ckss2.js +0 -2
- package/dist/chunk-88kjwkza.js +0 -2
- package/dist/chunk-8bcvb86w.js +0 -2
- package/dist/chunk-8h1zg44w.js +0 -2
- package/dist/chunk-8jtyra19.js +0 -2
- package/dist/chunk-bnsz09pg.js +0 -2
- package/dist/chunk-c9rwnsk7.js +0 -2
- package/dist/chunk-csjax0ej.js +0 -2
- package/dist/chunk-dd31q423.js +0 -2
- package/dist/chunk-dptjyncv.js +0 -2
- package/dist/chunk-et8ejd7k.js +0 -2
- package/dist/chunk-g1kyy5h1.js +0 -2
- package/dist/chunk-h791c7sb.js +0 -2
- package/dist/chunk-h88jcr3k.js +0 -2
- package/dist/chunk-hvvbppt4.js +0 -2
- package/dist/chunk-j4rb9rxx.js +0 -2
- package/dist/chunk-ka7qdsha.js +0 -2
- package/dist/chunk-m4d99a9r.js +0 -2
- package/dist/chunk-m5gdwq1d.js +0 -2
- package/dist/chunk-nz5ekyxn.js +0 -2
- package/dist/chunk-rchwwcxy.js +0 -2
- package/dist/chunk-s5cb4hkj.js +0 -2
- package/dist/chunk-t2mjeezd.js +0 -2
- package/dist/chunk-vk18649m.js +0 -2
- package/dist/chunk-vmfw4svt.js +0 -2
- package/dist/chunk-wbv6vjhm.js +0 -2
- package/dist/chunk-wpnv0naj.js +0 -2
- package/dist/chunk-wv2crxm6.js +0 -2
- package/dist/chunk-xda69f13.js +0 -2
- package/dist/chunk-ym182eg0.js +0 -2
- package/dist/chunk-zah67v44.js +0 -2
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
export const SIGNALS_DOM_READY_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Auto-initialization
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
6
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
7
|
+
// componentScope and reactive subscriptions.
|
|
8
|
+
if (window.__stxDomReadyHandler) {
|
|
9
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
10
|
+
}
|
|
11
|
+
const stxDomReadyHandler = () => {
|
|
12
|
+
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
13
|
+
// Track which scoped elements have been processed
|
|
14
|
+
const processedScopes = new Set();
|
|
15
|
+
|
|
16
|
+
// Layout expansion can remove the data-stx marker from a page's first
|
|
17
|
+
// element while leaving markers owned by the layout itself. The generated
|
|
18
|
+
// page setup is still queued explicitly, so adopt it when its own marker
|
|
19
|
+
// did not survive.
|
|
20
|
+
const latestSetup = window.stx._latestSetup;
|
|
21
|
+
const latestSetupName = typeof latestSetup === 'function' ? latestSetup.name : '';
|
|
22
|
+
const hasLatestSetupMarker = latestSetupName && Array.from(document.querySelectorAll('[data-stx]'))
|
|
23
|
+
.some(el => el.getAttribute('data-stx') === latestSetupName);
|
|
24
|
+
if (latestSetup && !hasLatestSetupMarker) {
|
|
25
|
+
try {
|
|
26
|
+
const result = latestSetup();
|
|
27
|
+
if (typeof result === 'object' && result !== null)
|
|
28
|
+
Object.assign(componentScope, result);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error('[stx] initial setup error:', e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Register page setup before mounting child components. Projected slot
|
|
36
|
+
// content belongs to the caller, so child mounts need the caller's signals
|
|
37
|
+
// available when they walk their own rendered roots.
|
|
38
|
+
document.querySelectorAll('[data-stx]').forEach(el => {
|
|
39
|
+
const setupName = el.getAttribute('data-stx');
|
|
40
|
+
console.log('[DOMContentLoaded] data-stx:', setupName, 'el:', el.tagName, 'fn exists:', !!(setupName && window[setupName]));
|
|
41
|
+
if (setupName && window[setupName]) {
|
|
42
|
+
// Contained, like the two sibling setup call sites. An uncaught throw
|
|
43
|
+
// here aborted the whole forEach and everything after it in this
|
|
44
|
+
// handler, so ONE bad name in ONE page's setup left every root on the
|
|
45
|
+
// page unhydrated \u2014 the user sees raw {{ }}, and the console names the
|
|
46
|
+
// identifier without saying it cost them the document (#1805).
|
|
47
|
+
try {
|
|
48
|
+
const result = window[setupName]();
|
|
49
|
+
console.log('[DOMContentLoaded] setup returned:', result ? Object.keys(result).slice(0, 10) : 'null');
|
|
50
|
+
if (typeof result === 'object' && result !== null) {
|
|
51
|
+
Object.assign(componentScope, result);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error('[stx] page setup "' + setupName + '" threw; this root will not hydrate:', e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var pageScopeSnapshot = { ...componentScope };
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Any x-data scope the reactive bridge did not reach, initialized here.
|
|
63
|
+
*
|
|
64
|
+
* The bridge script addresses each scope by a selector it generated, and
|
|
65
|
+
* that numbering restarts per render - so a page carrying three component
|
|
66
|
+
* islands emits three scripts all looking for the same scope id, and two of
|
|
67
|
+
* the three scopes are never initialized at all. The symptom is the
|
|
68
|
+
* quietest one available: the markup is there, every binding shows its
|
|
69
|
+
* initial value, and whatever x-init was meant to start never starts.
|
|
70
|
+
*
|
|
71
|
+
* Registered scopes are skipped, so the bridge stays authoritative where it
|
|
72
|
+
* did run and this only picks up what it missed. The init expression is
|
|
73
|
+
* read from data-stx-xinit, which the server preserves for exactly this.
|
|
74
|
+
*
|
|
75
|
+
* No backticks in this comment, deliberately: it lives inside the runtime
|
|
76
|
+
* source that is embedded as a template literal, and one would end the
|
|
77
|
+
* literal and take the whole file's syntax with it.
|
|
78
|
+
*/
|
|
79
|
+
if (window.__stx_reactive && window.__stx_reactive.initScope) {
|
|
80
|
+
document.querySelectorAll('[data-stx-xdata]').forEach(function(el) {
|
|
81
|
+
var scopeId = el.getAttribute('data-stx-scope');
|
|
82
|
+
if (scopeId && window.stx._scopes && window.stx._scopes[scopeId]) return;
|
|
83
|
+
if (el.__stx_scope_initialized) return;
|
|
84
|
+
|
|
85
|
+
var xdata = el.getAttribute('data-stx-xdata');
|
|
86
|
+
if (!xdata) return;
|
|
87
|
+
|
|
88
|
+
if (!scopeId) {
|
|
89
|
+
scopeId = '__stx_scope_island_' + (++window.stx._scopeCounter);
|
|
90
|
+
el.setAttribute('data-stx-scope', scopeId);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
el.__stx_scope_initialized = true;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
window.__stx_reactive.initScope(el, xdata, [], {}, el.getAttribute('data-stx-xinit') || null);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
console.error('[stx] island scope init error:', e);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Process mount queue (from stx.mount() calls during loading) only after
|
|
105
|
+
// caller setup is available for Vue-style projected slot ownership.
|
|
106
|
+
mountQueue.forEach(function(fn) { fn(); });
|
|
107
|
+
mountQueue = [];
|
|
108
|
+
|
|
109
|
+
// Bind page roots after child components have registered their local scope.
|
|
110
|
+
document.querySelectorAll('[data-stx]').forEach(el => {
|
|
111
|
+
console.log('[DOMContentLoaded] processElement on:', el.tagName, 'scope keys:', Object.keys(componentScope).slice(0, 10));
|
|
112
|
+
var disposeEffects = trackEffects(function() {
|
|
113
|
+
// The server's list when the page shipped one, the walk otherwise.
|
|
114
|
+
if (!processFromManifest(el, componentScope, window.__stx_bindings)) processElement(el);
|
|
115
|
+
});
|
|
116
|
+
el.__stx_disposers = disposeEffects;
|
|
117
|
+
|
|
118
|
+
// Remove x-cloak after bindings are applied (prevents FOUC)
|
|
119
|
+
el.removeAttribute('x-cloak');
|
|
120
|
+
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
121
|
+
|
|
122
|
+
runMountCallbacks(mountCallbacks, destroyCallbacks);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Multi-root fragment fix: a no-body> setup page tags only the FIRST
|
|
126
|
+
// top-level element with data-stx (signal-processing.ts marks one element),
|
|
127
|
+
// so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
|
|
128
|
+
// never hydrated, which read as "{{ }} doesn't work under :if/:for". The
|
|
129
|
+
// setup(s) above already populated the shared global componentScope, so
|
|
130
|
+
// process each un-hydrated sibling root under that same scope \u2014 same signals,
|
|
131
|
+
// so cross-root state stays coupled.
|
|
132
|
+
var stxRoots = document.querySelectorAll('[data-stx]');
|
|
133
|
+
if (stxRoots.length && Object.keys(componentScope).length) {
|
|
134
|
+
var rootParent = stxRoots[0].parentNode;
|
|
135
|
+
if (rootParent && rootParent.children) {
|
|
136
|
+
Array.prototype.slice.call(rootParent.children).forEach(function(sib) {
|
|
137
|
+
if (sib.nodeType !== 1) return;
|
|
138
|
+
if (sib.hasAttribute('data-stx') || sib.hasAttribute('data-stx-scope')) return;
|
|
139
|
+
if (sib.tagName === 'SCRIPT' || sib.tagName === 'STYLE') return;
|
|
140
|
+
if (sib.__stx_disposers) return; // already processed
|
|
141
|
+
var disposeSib = trackEffects(function() { processElement(sib); });
|
|
142
|
+
sib.__stx_disposers = disposeSib;
|
|
143
|
+
sib.removeAttribute('x-cloak');
|
|
144
|
+
sib.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Process scoped components FIRST (their scripts have already registered scope variables)
|
|
150
|
+
var allScopes = document.querySelectorAll('[data-stx-scope]');
|
|
151
|
+
console.log('[stx] found', allScopes.length, 'data-stx-scope elements');
|
|
152
|
+
allScopes.forEach(el => {
|
|
153
|
+
const scopeId = el.getAttribute('data-stx-scope');
|
|
154
|
+
console.log('[stx] scope:', scopeId, 'registered:', !!(window.stx._scopes && window.stx._scopes[scopeId]), 'el:', el.tagName);
|
|
155
|
+
processedScopes.add(el);
|
|
156
|
+
|
|
157
|
+
const scopeVars = window.stx._scopes && window.stx._scopes[scopeId];
|
|
158
|
+
// Record the element this scope is bound to so cleanupContainer can tell a
|
|
159
|
+
// dead registry entry (element replaced by an SPA swap) from a live one.
|
|
160
|
+
// See sweepOrphanedScopes / #1775.
|
|
161
|
+
if (scopeVars) scopeVars.__el = el;
|
|
162
|
+
|
|
163
|
+
// Deferred island (#1746): its setup script (type="stx/island") hasn't run
|
|
164
|
+
// yet, so the scope isn't registered. Arm the hydration trigger anyway \u2014
|
|
165
|
+
// processElement sees stx-hydrate and defers; deferHydration's run()
|
|
166
|
+
// executes the script (registering the scope + running side-effectful
|
|
167
|
+
// setup like fetches) and binds on the trigger. Reveal the HTML now.
|
|
168
|
+
var isDeferredIsland = !scopeVars && el.hasAttribute && el.hasAttribute('stx-hydrate')
|
|
169
|
+
&& !!document.querySelector('script[data-stx-island="' + scopeId + '"]');
|
|
170
|
+
if (isDeferredIsland) {
|
|
171
|
+
processElement(el);
|
|
172
|
+
el.removeAttribute('x-cloak');
|
|
173
|
+
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!scopeVars) return;
|
|
178
|
+
|
|
179
|
+
// Forwarded props and events belong to the caller. Capture its scope
|
|
180
|
+
// before this component's locals are merged, so identical child names
|
|
181
|
+
// cannot shadow expressions such as :total-items="totalItems".
|
|
182
|
+
el.__stx_parent_scope = el.__stx_parent_scope
|
|
183
|
+
|| resolveComponentCallerScope(el, pageScopeSnapshot);
|
|
184
|
+
bindParentComponentProps(el, el.__stx_parent_scope);
|
|
185
|
+
|
|
186
|
+
// Merge component scope vars into componentScope (don't restore - keep for head elements)
|
|
187
|
+
// This ensures expressions can access component variables even for elements
|
|
188
|
+
// where findElementScope might not work (e.g., cloned elements not yet in DOM)
|
|
189
|
+
if (scopeVars) {
|
|
190
|
+
componentScope = { ...componentScope, ...scopeVars };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
console.log('[stx] calling processElement on scope:', scopeId, 'componentScope keys:', Object.keys(componentScope).length, 'scopeVars keys:', Object.keys(scopeVars).length);
|
|
194
|
+
var disposeEffects = trackEffects(function() { processElement(el); });
|
|
195
|
+
el.__stx_disposers = disposeEffects;
|
|
196
|
+
console.log('[stx] scope processed OK:', scopeId);
|
|
197
|
+
|
|
198
|
+
// Remove x-cloak after bindings are applied
|
|
199
|
+
el.removeAttribute('x-cloak');
|
|
200
|
+
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
201
|
+
|
|
202
|
+
// Run scope-specific mount callbacks (mark mounted so _handleStxLoad
|
|
203
|
+
// doesn't re-fire onMount on persistent layout scopes \u2014 see #1697).
|
|
204
|
+
// EXCEPT when this scope's hydration is deferred (stx-hydrate, e.g. a
|
|
205
|
+
// client=visible|idle island, #1746): processElement above only SCHEDULED
|
|
206
|
+
// the work, so onMount must fire when the trigger actually hydrates the
|
|
207
|
+
// scope, not now. deferHydration's run() flushes it then.
|
|
208
|
+
var scopeDeferred = el.hasAttribute && el.hasAttribute('stx-hydrate') && !el.__stx_hydrated;
|
|
209
|
+
// A component behind a false :if is in the document's MARKUP but not in
|
|
210
|
+
// the document: bindIf detached the subtree before this walk reached it,
|
|
211
|
+
// while the component's own setup script already ran and queued its
|
|
212
|
+
// onMount. Mounting it from here anyway is what made being mounted
|
|
213
|
+
// unusable as an open state (stacksjs/stx#2036) -- three gated modal
|
|
214
|
+
// shells each locked body scroll and registered an Escape handler before
|
|
215
|
+
// anything had been opened, so the page could not be scrolled and Escape
|
|
216
|
+
// reached whichever instance registered last.
|
|
217
|
+
//
|
|
218
|
+
// Left unmounted rather than mounted-and-torn-down, so hydrateComponentScopes
|
|
219
|
+
// flushes it when bindIf shows the subtree -- the same deferral
|
|
220
|
+
// stx-hydrate uses above, and the same flush an island gets.
|
|
221
|
+
var scopeDetached = el.isConnected === false;
|
|
222
|
+
if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted && !scopeDeferred && !scopeDetached) {
|
|
223
|
+
scopeVars.__mounted = true;
|
|
224
|
+
runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Run global mount callbacks (from partial <script client> blocks that call onMount)
|
|
229
|
+
// These are pushed during script execution, before DOMContentLoaded
|
|
230
|
+
console.log('[stx] running global mountCallbacks:', mountCallbacks.length);
|
|
231
|
+
runMountCallbacks(mountCallbacks, destroyCallbacks);
|
|
232
|
+
mountCallbacks.length = 0;
|
|
233
|
+
|
|
234
|
+
// Auto-process elements with data-stx-auto (skip already processed scoped elements)
|
|
235
|
+
document.querySelectorAll('[data-stx-auto]').forEach(el => {
|
|
236
|
+
// Process element but skip children that are in scoped containers
|
|
237
|
+
processElementSkipScopes(el, processedScopes);
|
|
238
|
+
|
|
239
|
+
// Remove x-cloak after bindings are applied
|
|
240
|
+
el.removeAttribute('x-cloak');
|
|
241
|
+
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// Process head> elements (title, meta) that may contain {{ }} expressions
|
|
245
|
+
// Use componentScope which now contains variables from processed components
|
|
246
|
+
const headElements = document.querySelectorAll('head title, head meta[content]');
|
|
247
|
+
headElements.forEach(el => {
|
|
248
|
+
if (el.tagName === 'TITLE') {
|
|
249
|
+
const text = el.textContent;
|
|
250
|
+
if (text && text.includes('{{')) {
|
|
251
|
+
effect(() => {
|
|
252
|
+
try {
|
|
253
|
+
let result = text;
|
|
254
|
+
const matches = text.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);
|
|
255
|
+
if (matches) {
|
|
256
|
+
matches.forEach(match => {
|
|
257
|
+
const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
|
|
258
|
+
const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);
|
|
259
|
+
const value = fn(...__stxArgs(fn, componentScope));
|
|
260
|
+
result = result.replace(match, value != null ? value : '');
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
el.textContent = result;
|
|
264
|
+
}
|
|
265
|
+
catch (e) {
|
|
266
|
+
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Title expression error:', e);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else if (el.tagName === 'META') {
|
|
272
|
+
const content = el.getAttribute('content');
|
|
273
|
+
if (content && content.includes('{{')) {
|
|
274
|
+
// Skip build-time placeholders like {{__TITLE__}}
|
|
275
|
+
const hasOnlyPlaceholders = !content.replace(/\\{\\{\\s*__[A-Z_]+__\\s*\\}\\}/g, '').includes('{{');
|
|
276
|
+
if (hasOnlyPlaceholders) return;
|
|
277
|
+
effect(() => {
|
|
278
|
+
try {
|
|
279
|
+
let result = content;
|
|
280
|
+
const matches = content.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);
|
|
281
|
+
if (matches) {
|
|
282
|
+
matches.forEach(match => {
|
|
283
|
+
const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
|
|
284
|
+
if (/^__[A-Z_]+__$/.test(expr.trim())) return;
|
|
285
|
+
const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);
|
|
286
|
+
const value = fn(...__stxArgs(fn, componentScope));
|
|
287
|
+
result = result.replace(match, value != null ? value : '');
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
el.setAttribute('content', result);
|
|
291
|
+
}
|
|
292
|
+
catch (e) {
|
|
293
|
+
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Meta expression error:', e);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// Everything that should have hydrated has now had its chance (#1773).
|
|
301
|
+
auditHydration(document.body, 'DOMContentLoaded');
|
|
302
|
+
};
|
|
303
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
304
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
305
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
306
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Drawer controls used by the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_DRAWER_RUNTIME = " // \u2500\u2500 Drawer system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Same pattern as modal but slides from a side\n var drawer = {\n open: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (!el) { console.warn('[stx:drawer] Drawer \"' + id + '\" not found'); return; }\n el.style.display = 'flex';\n // Force reflow then animate\n void el.offsetHeight;\n el.setAttribute('data-stx-drawer-open', '');\n // The lock, Escape for the topmost and the Tab trap come from the\n // overlay stack, shared with every other overlay (stacksjs/stx#2057).\n // Each drawer used to bind its own Escape and set body overflow itself,\n // so two open closed together and the first to close unlocked the page.\n overlays.open('stx-drawer:' + id, {\n panel: el,\n onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { drawer.close(id); } : null\n });\n if (el.getAttribute('data-close-backdrop') !== 'false') {\n el.onclick = function(e) { if (e.target === el) drawer.close(id); };\n }\n },\n close: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (!el) return;\n el.removeAttribute('data-stx-drawer-open');\n el.onclick = null;\n overlays.close('stx-drawer:' + id);\n setTimeout(function() {\n if (!el.hasAttribute('data-stx-drawer-open')) el.style.display = 'none';\n }, 300);\n },\n toggle: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (el && el.hasAttribute('data-stx-drawer-open')) drawer.close(id);\n else drawer.open(id);\n }\n };\n";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const SIGNALS_DRAWER_RUNTIME = ` // \u2500\u2500 Drawer system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2
|
+
// Same pattern as modal but slides from a side
|
|
3
|
+
var drawer = {
|
|
4
|
+
open: function(id) {
|
|
5
|
+
var el = document.querySelector('[data-stx-drawer="' + id + '"]');
|
|
6
|
+
if (!el) { console.warn('[stx:drawer] Drawer "' + id + '" not found'); return; }
|
|
7
|
+
el.style.display = 'flex';
|
|
8
|
+
// Force reflow then animate
|
|
9
|
+
void el.offsetHeight;
|
|
10
|
+
el.setAttribute('data-stx-drawer-open', '');
|
|
11
|
+
// The lock, Escape for the topmost and the Tab trap come from the
|
|
12
|
+
// overlay stack, shared with every other overlay (stacksjs/stx#2057).
|
|
13
|
+
// Each drawer used to bind its own Escape and set body overflow itself,
|
|
14
|
+
// so two open closed together and the first to close unlocked the page.
|
|
15
|
+
overlays.open('stx-drawer:' + id, {
|
|
16
|
+
panel: el,
|
|
17
|
+
onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { drawer.close(id); } : null
|
|
18
|
+
});
|
|
19
|
+
if (el.getAttribute('data-close-backdrop') !== 'false') {
|
|
20
|
+
el.onclick = function(e) { if (e.target === el) drawer.close(id); };
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
close: function(id) {
|
|
24
|
+
var el = document.querySelector('[data-stx-drawer="' + id + '"]');
|
|
25
|
+
if (!el) return;
|
|
26
|
+
el.removeAttribute('data-stx-drawer-open');
|
|
27
|
+
el.onclick = null;
|
|
28
|
+
overlays.close('stx-drawer:' + id);
|
|
29
|
+
setTimeout(function() {
|
|
30
|
+
if (!el.hasAttribute('data-stx-drawer-open')) el.style.display = 'none';
|
|
31
|
+
}, 300);
|
|
32
|
+
},
|
|
33
|
+
toggle: function(id) {
|
|
34
|
+
var el = document.querySelector('[data-stx-drawer="' + id + '"]');
|
|
35
|
+
if (el && el.hasAttribute('data-stx-drawer-open')) drawer.close(id);
|
|
36
|
+
else drawer.open(id);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Effects, batching, tracking, and signal utility helpers for the client runtime. */
|
|
2
|
+
export declare const SIGNALS_EFFECT_RUNTIME = " // ==========================================================================\n // Effect\n // ==========================================================================\n\n function effect(fn, options = {}) {\n let cleanup;\n let isDisposed = false;\n\n const runEffect = () => {\n if (isDisposed) return;\n if (__stxDevtoolsTracking) { runEffect._runCount++; __stxDevtoolsStats.effectRuns++; }\n if (cleanup) {\n const pending = cleanup;\n cleanup = undefined;\n try { pending(); }\n catch (e) { console.error('[stx] effect cleanup error:', e); }\n }\n const prev = activeEffect;\n activeEffect = runEffect;\n effectStack.push(runEffect);\n try {\n // Only a FUNCTION is a cleanup. An effect body is an expression as\n // often as it is a block, and an expression has a value: an effect\n // written as an arrow assigning to textContent returns the assigned\n // string. Storing that and calling it on the next run threw\n // \"cleanup is not a function\" from the line above \u2014 outside this try,\n // so it escaped runEffect entirely and propagated out of whatever\n // .set() triggered the notification, taking unrelated subscribers with\n // it. Only ever on the second run, which is why it read as correct.\n var __result = fn();\n cleanup = typeof __result === 'function' ? __result : undefined;\n }\n catch (e) {\n // Auto-dispose effects that fail \u2014 prevents zombie subscriptions\n // from body-level processElement walking into mount-scoped content.\n isDisposed = true;\n // Only log if this is likely a real error, not a stale SPA effect.\n // Stale effects reference variables from a previous page's scope that no longer exist.\n //\n // Reported, never re-thrown. Re-thrown, it escaped the .set() that ran\n // this effect, and that set() stopped notifying everything after it:\n // a list half-rendered with raw {{ }} and no click handlers, a\n // selection that moved while the view it drives did not, and nothing\n // in the console, because the exception ended inside an event handler\n // or a native callback. One broken effect took the page with it.\n if (e instanceof ReferenceError) {\n // Silently dispose \u2014 this is expected during SPA navigation when\n // old effects fire against the new page's scope.\n } else {\n console.error('[stx] effect error (the effect is disposed):', e);\n }\n }\n finally {\n effectStack.pop();\n activeEffect = prev;\n }\n };\n\n runEffect._isStxEffect = true; // DevTools\n runEffect._stxId = ++__stxEffectId; // DevTools: stable effect id\n runEffect._runCount = 0; // DevTools: times this effect re-ran (when tracking)\n\n if (options.immediate !== false) runEffect();\n const dispose = () => {\n isDisposed = true;\n // Idempotent. A removed :for row is disposed on removal, and the page\n // tracker that collected its effects on first render still holds the\n // same disposer, which cleanupContainer calls on SPA navigation (#1954).\n // Clearing cleanup before calling it stops that second call running it\n // twice.\n if (cleanup) {\n const pending = cleanup;\n cleanup = undefined;\n pending();\n }\n };\n // Auto-register with active tracker\n if (activeDisposers) activeDisposers.push(dispose);\n return dispose;\n }\n\n // ==========================================================================\n // Effect Tracking\n // ==========================================================================\n\n function trackEffects(fn) {\n var parentDisposers = activeDisposers;\n var disposers = [];\n activeDisposers = disposers;\n try {\n fn();\n }\nfinally {\n activeDisposers = parentDisposers;\n if (parentDisposers) {\n disposers.forEach(function(d) { parentDisposers.push(d); });\n }\n }\n return function disposeAll() {\n disposers.forEach(function(d) { try { d(); }\ncatch (e) { console.warn('[stx] dispose error:', e); } });\n disposers.length = 0;\n };\n }\n\n // ==========================================================================\n // Batch\n // ==========================================================================\n\n function batch(fn) {\n if (isBatching) {\n fn();\n return;\n }\n isBatching = true;\n // finally: a throw inside fn left isBatching set for good, and every later\n // update was queued for a flush that never came - the page stopped.\n try {\n fn();\n }\n finally {\n isBatching = false;\n const queued = Array.from(pendingEffects);\n pendingEffects.clear();\n queued.forEach(e => e());\n }\n }\n\n // ==========================================================================\n // Utilities\n // ==========================================================================\n\n function isSignal(v) {\n return typeof v === 'function' && v._isSignal === true;\n }\n\n // The derived brand is set at creation; this predicate was declared and\n // auto-imported for years without ever existing here (#1804).\n function isDerived(v) {\n return typeof v === 'function' && v._isDerived === true;\n }\n\n function untrack(v) {\n return isSignal(v) || (typeof v === 'function' && v._isDerived) ? v() : v;\n }\n\n function peek(fn) {\n const prev = activeEffect;\n activeEffect = null;\n try {\n return fn();\n }\nfinally {\n activeEffect = prev;\n }\n }\n";
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export const SIGNALS_EFFECT_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Effect
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
function effect(fn, options = {}) {
|
|
6
|
+
let cleanup;
|
|
7
|
+
let isDisposed = false;
|
|
8
|
+
|
|
9
|
+
const runEffect = () => {
|
|
10
|
+
if (isDisposed) return;
|
|
11
|
+
if (__stxDevtoolsTracking) { runEffect._runCount++; __stxDevtoolsStats.effectRuns++; }
|
|
12
|
+
if (cleanup) {
|
|
13
|
+
const pending = cleanup;
|
|
14
|
+
cleanup = undefined;
|
|
15
|
+
try { pending(); }
|
|
16
|
+
catch (e) { console.error('[stx] effect cleanup error:', e); }
|
|
17
|
+
}
|
|
18
|
+
const prev = activeEffect;
|
|
19
|
+
activeEffect = runEffect;
|
|
20
|
+
effectStack.push(runEffect);
|
|
21
|
+
try {
|
|
22
|
+
// Only a FUNCTION is a cleanup. An effect body is an expression as
|
|
23
|
+
// often as it is a block, and an expression has a value: an effect
|
|
24
|
+
// written as an arrow assigning to textContent returns the assigned
|
|
25
|
+
// string. Storing that and calling it on the next run threw
|
|
26
|
+
// "cleanup is not a function" from the line above \u2014 outside this try,
|
|
27
|
+
// so it escaped runEffect entirely and propagated out of whatever
|
|
28
|
+
// .set() triggered the notification, taking unrelated subscribers with
|
|
29
|
+
// it. Only ever on the second run, which is why it read as correct.
|
|
30
|
+
var __result = fn();
|
|
31
|
+
cleanup = typeof __result === 'function' ? __result : undefined;
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
// Auto-dispose effects that fail \u2014 prevents zombie subscriptions
|
|
35
|
+
// from body-level processElement walking into mount-scoped content.
|
|
36
|
+
isDisposed = true;
|
|
37
|
+
// Only log if this is likely a real error, not a stale SPA effect.
|
|
38
|
+
// Stale effects reference variables from a previous page's scope that no longer exist.
|
|
39
|
+
//
|
|
40
|
+
// Reported, never re-thrown. Re-thrown, it escaped the .set() that ran
|
|
41
|
+
// this effect, and that set() stopped notifying everything after it:
|
|
42
|
+
// a list half-rendered with raw {{ }} and no click handlers, a
|
|
43
|
+
// selection that moved while the view it drives did not, and nothing
|
|
44
|
+
// in the console, because the exception ended inside an event handler
|
|
45
|
+
// or a native callback. One broken effect took the page with it.
|
|
46
|
+
if (e instanceof ReferenceError) {
|
|
47
|
+
// Silently dispose \u2014 this is expected during SPA navigation when
|
|
48
|
+
// old effects fire against the new page's scope.
|
|
49
|
+
} else {
|
|
50
|
+
console.error('[stx] effect error (the effect is disposed):', e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
effectStack.pop();
|
|
55
|
+
activeEffect = prev;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
runEffect._isStxEffect = true; // DevTools
|
|
60
|
+
runEffect._stxId = ++__stxEffectId; // DevTools: stable effect id
|
|
61
|
+
runEffect._runCount = 0; // DevTools: times this effect re-ran (when tracking)
|
|
62
|
+
|
|
63
|
+
if (options.immediate !== false) runEffect();
|
|
64
|
+
const dispose = () => {
|
|
65
|
+
isDisposed = true;
|
|
66
|
+
// Idempotent. A removed :for row is disposed on removal, and the page
|
|
67
|
+
// tracker that collected its effects on first render still holds the
|
|
68
|
+
// same disposer, which cleanupContainer calls on SPA navigation (#1954).
|
|
69
|
+
// Clearing cleanup before calling it stops that second call running it
|
|
70
|
+
// twice.
|
|
71
|
+
if (cleanup) {
|
|
72
|
+
const pending = cleanup;
|
|
73
|
+
cleanup = undefined;
|
|
74
|
+
pending();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Auto-register with active tracker
|
|
78
|
+
if (activeDisposers) activeDisposers.push(dispose);
|
|
79
|
+
return dispose;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ==========================================================================
|
|
83
|
+
// Effect Tracking
|
|
84
|
+
// ==========================================================================
|
|
85
|
+
|
|
86
|
+
function trackEffects(fn) {
|
|
87
|
+
var parentDisposers = activeDisposers;
|
|
88
|
+
var disposers = [];
|
|
89
|
+
activeDisposers = disposers;
|
|
90
|
+
try {
|
|
91
|
+
fn();
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
activeDisposers = parentDisposers;
|
|
95
|
+
if (parentDisposers) {
|
|
96
|
+
disposers.forEach(function(d) { parentDisposers.push(d); });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return function disposeAll() {
|
|
100
|
+
disposers.forEach(function(d) { try { d(); }
|
|
101
|
+
catch (e) { console.warn('[stx] dispose error:', e); } });
|
|
102
|
+
disposers.length = 0;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ==========================================================================
|
|
107
|
+
// Batch
|
|
108
|
+
// ==========================================================================
|
|
109
|
+
|
|
110
|
+
function batch(fn) {
|
|
111
|
+
if (isBatching) {
|
|
112
|
+
fn();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
isBatching = true;
|
|
116
|
+
// finally: a throw inside fn left isBatching set for good, and every later
|
|
117
|
+
// update was queued for a flush that never came - the page stopped.
|
|
118
|
+
try {
|
|
119
|
+
fn();
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
isBatching = false;
|
|
123
|
+
const queued = Array.from(pendingEffects);
|
|
124
|
+
pendingEffects.clear();
|
|
125
|
+
queued.forEach(e => e());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ==========================================================================
|
|
130
|
+
// Utilities
|
|
131
|
+
// ==========================================================================
|
|
132
|
+
|
|
133
|
+
function isSignal(v) {
|
|
134
|
+
return typeof v === 'function' && v._isSignal === true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The derived brand is set at creation; this predicate was declared and
|
|
138
|
+
// auto-imported for years without ever existing here (#1804).
|
|
139
|
+
function isDerived(v) {
|
|
140
|
+
return typeof v === 'function' && v._isDerived === true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function untrack(v) {
|
|
144
|
+
return isSignal(v) || (typeof v === 'function' && v._isDerived) ? v() : v;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function peek(fn) {
|
|
148
|
+
const prev = activeEffect;
|
|
149
|
+
activeEffect = null;
|
|
150
|
+
try {
|
|
151
|
+
return fn();
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
activeEffect = prev;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Event-expression shorthand parser used by the client runtime. */
|
|
2
|
+
export declare const SIGNALS_EVENT_SHORTHAND_RUNTIME = " // ==========================================================================\n // Event Handler Shorthand (Feature #8)\n // ==========================================================================\n\n function parseEventShorthand(expr, scope) {\n const trimmed = expr.trim();\n\n // Handle !variable toggle: \"!visible\" -> toggle the signal\n if (/^!\\w+$/.test(trimmed)) {\n const varName = trimmed.slice(1);\n const signal = scope[varName];\n if (signal && signal._isSignal) {\n return () => signal.set(!signal());\n }\n return null;\n }\n\n // Handle variable++ increment: \"count++\" -> increment the signal\n if (/^\\w+\\+\\+$/.test(trimmed)) {\n const varName = trimmed.slice(0, -2);\n const signal = scope[varName];\n if (signal && signal._isSignal) {\n return () => signal.update(n => n + 1);\n }\n return null;\n }\n\n // Handle variable-- decrement: \"count--\" -> decrement the signal\n if (/^\\w+--$/.test(trimmed)) {\n const varName = trimmed.slice(0, -2);\n const signal = scope[varName];\n if (signal && signal._isSignal) {\n return () => signal.update(n => n - 1);\n }\n return null;\n }\n\n // Handle += and -= operators: \"count += 5\"\n const assignMatch = trimmed.match(/^(\\w+)\\s*([+\\-*\\/])=\\s*(.+)$/);\n if (assignMatch) {\n const [, varName, op, valueExpr] = assignMatch;\n const signal = scope[varName];\n if (signal && signal._isSignal) {\n return ($event) => {\n const addValue = toValue(valueExpr, null, true, { ...scope, $event: $event });\n signal.update(n => {\n switch (op) {\n case '+': return n + addValue;\n case '-': return n - addValue;\n case '*': return n * addValue;\n case '/': return n / addValue;\n default: return n;\n }\n });\n };\n }\n return null;\n }\n\n // Handle simple assignment: \"count = 5\" or \"visible = false\"\n const simpleAssignMatch = trimmed.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (simpleAssignMatch && !trimmed.includes('==') && !trimmed.includes('=>')) {\n const [, varName, valueExpr] = simpleAssignMatch;\n const signal = scope[varName];\n if (signal && signal._isSignal) {\n return ($event) => {\n const newValue = toValue(valueExpr, null, true, { ...scope, $event: $event });\n signal.set(newValue);\n };\n }\n return null;\n }\n\n // Bare function reference: \"@click=\\\"foo\\\"\" should invoke foo($event),\n // matching Alpine/Vue/Svelte. Without this the expression falls through\n // to the generic new Function() path and is evaluated as a discarded\n // identifier statement \u2014 silently a no-op. See stacksjs/stx#1695.\n const bareIdMatch = trimmed.match(/^([a-zA-Z_$][\\w$]*)$/);\n if (bareIdMatch) {\n const fn = scope[bareIdMatch[1]];\n if (typeof fn === 'function' && !fn._isSignal) {\n return ($event) => fn($event);\n }\n }\n\n return null;\n }\n";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export const SIGNALS_EVENT_SHORTHAND_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Event Handler Shorthand (Feature #8)
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
function parseEventShorthand(expr, scope) {
|
|
6
|
+
const trimmed = expr.trim();
|
|
7
|
+
|
|
8
|
+
// Handle !variable toggle: "!visible" -> toggle the signal
|
|
9
|
+
if (/^!\\w+$/.test(trimmed)) {
|
|
10
|
+
const varName = trimmed.slice(1);
|
|
11
|
+
const signal = scope[varName];
|
|
12
|
+
if (signal && signal._isSignal) {
|
|
13
|
+
return () => signal.set(!signal());
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Handle variable++ increment: "count++" -> increment the signal
|
|
19
|
+
if (/^\\w+\\+\\+$/.test(trimmed)) {
|
|
20
|
+
const varName = trimmed.slice(0, -2);
|
|
21
|
+
const signal = scope[varName];
|
|
22
|
+
if (signal && signal._isSignal) {
|
|
23
|
+
return () => signal.update(n => n + 1);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Handle variable-- decrement: "count--" -> decrement the signal
|
|
29
|
+
if (/^\\w+--$/.test(trimmed)) {
|
|
30
|
+
const varName = trimmed.slice(0, -2);
|
|
31
|
+
const signal = scope[varName];
|
|
32
|
+
if (signal && signal._isSignal) {
|
|
33
|
+
return () => signal.update(n => n - 1);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Handle += and -= operators: "count += 5"
|
|
39
|
+
const assignMatch = trimmed.match(/^(\\w+)\\s*([+\\-*\\/])=\\s*(.+)$/);
|
|
40
|
+
if (assignMatch) {
|
|
41
|
+
const [, varName, op, valueExpr] = assignMatch;
|
|
42
|
+
const signal = scope[varName];
|
|
43
|
+
if (signal && signal._isSignal) {
|
|
44
|
+
return ($event) => {
|
|
45
|
+
const addValue = toValue(valueExpr, null, true, { ...scope, $event: $event });
|
|
46
|
+
signal.update(n => {
|
|
47
|
+
switch (op) {
|
|
48
|
+
case '+': return n + addValue;
|
|
49
|
+
case '-': return n - addValue;
|
|
50
|
+
case '*': return n * addValue;
|
|
51
|
+
case '/': return n / addValue;
|
|
52
|
+
default: return n;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Handle simple assignment: "count = 5" or "visible = false"
|
|
61
|
+
const simpleAssignMatch = trimmed.match(/^(\\w+)\\s*=\\s*(.+)$/);
|
|
62
|
+
if (simpleAssignMatch && !trimmed.includes('==') && !trimmed.includes('=>')) {
|
|
63
|
+
const [, varName, valueExpr] = simpleAssignMatch;
|
|
64
|
+
const signal = scope[varName];
|
|
65
|
+
if (signal && signal._isSignal) {
|
|
66
|
+
return ($event) => {
|
|
67
|
+
const newValue = toValue(valueExpr, null, true, { ...scope, $event: $event });
|
|
68
|
+
signal.set(newValue);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Bare function reference: "@click=\\"foo\\"" should invoke foo($event),
|
|
75
|
+
// matching Alpine/Vue/Svelte. Without this the expression falls through
|
|
76
|
+
// to the generic new Function() path and is evaluated as a discarded
|
|
77
|
+
// identifier statement \u2014 silently a no-op. See stacksjs/stx#1695.
|
|
78
|
+
const bareIdMatch = trimmed.match(/^([a-zA-Z_$][\\w$]*)$/);
|
|
79
|
+
if (bareIdMatch) {
|
|
80
|
+
const fn = scope[bareIdMatch[1]];
|
|
81
|
+
if (typeof fn === 'function' && !fn._isSignal) {
|
|
82
|
+
return ($event) => fn($event);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Cached expression compilation helpers for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_EXPRESSION_COMPILER_RUNTIME = " // Compiled expression functions, by parameter list and body. A binding was\n // compiled with new Function on every evaluation: a page with a few hundred\n // names in scope rebuilt a function of a few hundred parameters for every\n // binding of every row, every time a row re-rendered. Opening a 386-message\n // conversation took seven seconds in WebKit, the window frozen meanwhile.\n // A Function built this way closes over nothing, so one can be reused.\n const __stxCompiled = new Map();\n function __stxCompile(params, body) {\n const key = params.join(',') + '\\x01' + body;\n let fn = __stxCompiled.get(key);\n if (!fn) {\n fn = new Function(...params, body);\n // Bounded: expressions are finite per page, but SPA navigation adds more.\n if (__stxCompiled.size >= 5000) __stxCompiled.clear();\n __stxCompiled.set(key, fn);\n }\n return fn;\n }\n\n // The names an expression mentions, by its text.\n const __stxIdentifiers = new Map();\n function __stxNamesIn(body) {\n let names = __stxIdentifiers.get(body);\n if (!names) {\n names = Array.from(new Set(body.match(/[A-Za-z_$][\\w$]*/g) || []));\n if (__stxIdentifiers.size >= 5000) __stxIdentifiers.clear();\n __stxIdentifiers.set(body, names);\n }\n return names;\n }\n\n // Compile an expression over just the names in scope it mentions.\n //\n // It was compiled over every name in scope and called with every value,\n // read through the auto-unwrap proxy. Reading a signal subscribes the\n // running effect, so every binding depended on every signal on the page:\n // changing one unrelated value re-ran every binding of every row. The proxy\n // also tested each signal against the expression with fresh regexes. Now an\n // expression sees, reads and subscribes to what it names; a mention inside\n // a string only widens that, never narrows it.\n function __stxCompileScoped(scope, extraParams, body) {\n const keys = [];\n const names = __stxNamesIn(body);\n for (let i = 0; i < names.length; i++) {\n if (Object.prototype.propertyIsEnumerable.call(scope, names[i])) keys.push(names[i]);\n }\n const fn = __stxCompile(extraParams.length ? keys.concat(extraParams) : keys, body);\n // The cache keys on the parameter list, so a function always has these keys.\n fn.__stxKeys = keys;\n return fn;\n }\n\n function __stxArgs(fn, scope) {\n const keys = fn.__stxKeys;\n const args = new Array(keys.length);\n for (let i = 0; i < keys.length; i++) args[i] = scope[keys[i]];\n return args;\n }\n";
|