@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,67 @@
|
|
|
1
|
+
export const SIGNALS_REACTIVE_RUNTIME = ` // Vue-compat aliases
|
|
2
|
+
var ref = state;
|
|
3
|
+
|
|
4
|
+
// reactive() used to be a bare alias of state(), which made it the most
|
|
5
|
+
// dangerous name in the runtime. state({n:0}) returns a SIGNAL, so the Vue
|
|
6
|
+
// shape everyone reaches for silently did nothing:
|
|
7
|
+
//
|
|
8
|
+
// const s = reactive({ count: 0 })
|
|
9
|
+
// s.count // undefined \u2014 a signal has no such property
|
|
10
|
+
// s.count++ // writes an expando onto a function object
|
|
11
|
+
// {{ s.count }} // renders empty, forever, with no warning
|
|
12
|
+
//
|
|
13
|
+
// Backed by one signal PER PROPERTY, created on first touch. That is what
|
|
14
|
+
// makes a read inside an effect track only the field it read, so writing
|
|
15
|
+
// b does not re-run an effect that only read a (#1885).
|
|
16
|
+
var __stxReactiveProxies = new WeakMap();
|
|
17
|
+
|
|
18
|
+
function reactive(target) {
|
|
19
|
+
// Primitives have no properties to track. Returning them unchanged keeps
|
|
20
|
+
// reactive(0) from silently becoming an object.
|
|
21
|
+
if (!target || typeof target !== 'object') return target;
|
|
22
|
+
var existing = __stxReactiveProxies.get(target);
|
|
23
|
+
if (existing) return existing;
|
|
24
|
+
|
|
25
|
+
var propSignals = Object.create(null);
|
|
26
|
+
function signalFor(prop) {
|
|
27
|
+
if (!propSignals[prop]) propSignals[prop] = state(target[prop]);
|
|
28
|
+
return propSignals[prop];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var proxy = new Proxy(target, {
|
|
32
|
+
get: function(t, prop, receiver) {
|
|
33
|
+
// Symbols and inherited members are plumbing \u2014 toJSON, Symbol.iterator,
|
|
34
|
+
// array methods. Tracking them would create a signal per method lookup
|
|
35
|
+
// and make every effect depend on the whole object.
|
|
36
|
+
if (typeof prop === 'symbol' || !Object.prototype.hasOwnProperty.call(t, prop))
|
|
37
|
+
return Reflect.get(t, prop, receiver);
|
|
38
|
+
var value = signalFor(prop)();
|
|
39
|
+
// Nested objects are wrapped too, and cached in the WeakMap, so
|
|
40
|
+
// identity is stable across reads \u2014 a fresh proxy each time would
|
|
41
|
+
// break === comparisons and defeat keyed list reuse.
|
|
42
|
+
return (value && typeof value === 'object') ? reactive(value) : value;
|
|
43
|
+
},
|
|
44
|
+
set: function(t, prop, value) {
|
|
45
|
+
if (typeof prop === 'symbol') return Reflect.set(t, prop, value);
|
|
46
|
+
var had = Object.prototype.hasOwnProperty.call(t, prop);
|
|
47
|
+
t[prop] = value;
|
|
48
|
+
// Write the plain target FIRST so a signal created later reads the
|
|
49
|
+
// current value, then notify anyone already watching this property.
|
|
50
|
+
if (propSignals[prop]) propSignals[prop].set(value);
|
|
51
|
+
else if (had) signalFor(prop);
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
deleteProperty: function(t, prop) {
|
|
55
|
+
var had = Object.prototype.hasOwnProperty.call(t, prop);
|
|
56
|
+
delete t[prop];
|
|
57
|
+
if (had && propSignals[prop]) propSignals[prop].set(undefined);
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
__stxReactiveProxies.set(target, proxy);
|
|
63
|
+
return proxy;
|
|
64
|
+
}
|
|
65
|
+
var computed = derived;
|
|
66
|
+
var watch = $watch;
|
|
67
|
+
var watchEffect = function(fn) { return effect(fn); };`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Template ref accessor used by page and component scopes. */
|
|
2
|
+
export declare const SIGNALS_REF_RUNTIME = " // ==========================================================================\n // Template Refs (useRef)\n // ==========================================================================\n\n function useRef(name) {\n // A ref belongs to the component scope that created it. Capturing that\n // owner now is essential: componentScope is a mutable compatibility\n // fallback and changes while the rest of the page hydrates. Reading it\n // from the getter made an early component resolve refs from whichever\n // component happened to hydrate last.\n var ownerScope = currentLifecycleScope() || componentScope;\n var ownerRefs = ownerScope.$refs || (ownerScope.$refs = {});\n\n // Callable, as well as .current / .value.\n //\n // Every other accessor a script destructures alongside this one is\n // call-style \u2014 state(), derived(), useReactiveProp() \u2014 so myRef() is what\n // a reader reaches for, and it used to throw \"myRef is not a function\".\n // Inside effect()'s first run that throw escaped the effect, escaped the\n // generated setup function, and left the WHOLE page unhydrated: every\n // @click inert, every interpolation unbound, the markup otherwise\n // perfect. Either API alone looked fine, which is what made it hard to\n // see. Same reasoning as useCookie becoming a Signal in #1710.\n //\n // No backticks in here: this whole runtime is a template literal.\n var read = function () {\n return ownerRefs[name] || null;\n };\n Object.defineProperty(read, 'current', { get: read, enumerable: true });\n Object.defineProperty(read, 'value', { get: read, enumerable: true });\n return read;\n }\n";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const SIGNALS_REF_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Template Refs (useRef)
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
function useRef(name) {
|
|
6
|
+
// A ref belongs to the component scope that created it. Capturing that
|
|
7
|
+
// owner now is essential: componentScope is a mutable compatibility
|
|
8
|
+
// fallback and changes while the rest of the page hydrates. Reading it
|
|
9
|
+
// from the getter made an early component resolve refs from whichever
|
|
10
|
+
// component happened to hydrate last.
|
|
11
|
+
var ownerScope = currentLifecycleScope() || componentScope;
|
|
12
|
+
var ownerRefs = ownerScope.$refs || (ownerScope.$refs = {});
|
|
13
|
+
|
|
14
|
+
// Callable, as well as .current / .value.
|
|
15
|
+
//
|
|
16
|
+
// Every other accessor a script destructures alongside this one is
|
|
17
|
+
// call-style \u2014 state(), derived(), useReactiveProp() \u2014 so myRef() is what
|
|
18
|
+
// a reader reaches for, and it used to throw "myRef is not a function".
|
|
19
|
+
// Inside effect()'s first run that throw escaped the effect, escaped the
|
|
20
|
+
// generated setup function, and left the WHOLE page unhydrated: every
|
|
21
|
+
// @click inert, every interpolation unbound, the markup otherwise
|
|
22
|
+
// perfect. Either API alone looked fine, which is what made it hard to
|
|
23
|
+
// see. Same reasoning as useCookie becoming a Signal in #1710.
|
|
24
|
+
//
|
|
25
|
+
// No backticks in here: this whole runtime is a template literal.
|
|
26
|
+
var read = function () {
|
|
27
|
+
return ownerRefs[name] || null;
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(read, 'current', { get: read, enumerable: true });
|
|
30
|
+
Object.defineProperty(read, 'value', { get: read, enumerable: true });
|
|
31
|
+
return read;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Scope and effect disposal used by the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_SCOPE_DISPOSAL_RUNTIME = " // ==========================================================================\n // Scope Disposal\n // ==========================================================================\n\n // Walk a subtree (root + descendants) and fire each [data-stx-scope]'s\n // destroy callbacks + remove the entry from window.stx._scopes. Pre-fix\n // (stacksjs/stx#1727) only cleanupContainer (called during SPA navigation)\n // ran this walk, so dynamic unmounts driven by :if/:for leaked scopes\n // indefinitely. Now bindIf, bindFor, and cleanupContainer all funnel\n // through this helper so the cleanup is symmetric regardless of who\n // initiated the removal.\n // Dispose the EFFECTS bound inside a subtree leaving the page for good: a\n // removed :for row, a hidden template :if clone, a hidden :for empty\n // placeholder, or a container on SPA navigation (#1954).\n // disposeSubtreeScopes only releases scope registrations. Without this, the\n // effects that bound the subtree stay subscribed to every signal they read\n // and keep running, so work per update grows with every removal.\n // Descendants first, then the root, the order cleanupContainer always used.\n function disposeSubtreeEffects(root) {\n if (!root) return;\n var nodes = stxHost.descendants(root);\n nodes.push(root);\n var owned = ['__stx_disposers', '__stx_effect_disposers', '__stx_if_disposers', '__stx_chain_disposers'];\n for (var n = 0; n < nodes.length; n++) {\n var el = nodes[n];\n if (typeof el.__stx_hydration_cancel === 'function') {\n try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }\n el.__stx_hydration_cancel = null;\n }\n if (Array.isArray(el.__stx_destroy)) {\n var hooks = el.__stx_destroy;\n el.__stx_destroy = null;\n hooks.forEach(function(fn) {\n try { fn(); }\n catch (e) { console.warn('[stx] destroy hook error:', e); }\n });\n }\n if (el.__stx_detached_if) {\n var detached = el.__stx_detached_if;\n el.__stx_detached_if = null;\n detached.forEach(function(node) { disposeSubtreeEffects(node); });\n }\n for (var k = 0; k < owned.length; k++) {\n var disposeOwned = el[owned[k]];\n if (typeof disposeOwned === 'function') {\n el[owned[k]] = null;\n disposeOwned();\n }\n }\n }\n }\n\n // :if is a toggle, and a component inside one lives through every toggle:\n // its scope is registered once and kept (#1737), and showing the branch puts\n // the same markup back. Its LIFECYCLE follows the toggle, though. Hiding runs\n // what the component registered to release -- its onDestroy, and whatever\n // its onMount handed back -- and showing it again runs its onMount again.\n // Each show is a mount and each hide an unmount, which is the pairing every\n // component on a page already gets.\n //\n // Before this, a hidden component never heard about it and a re-shown one\n // was never told it was back (the asymmetry stacksjs/stx#2036 stopped short\n // of). A gated modal shell -- one that traps focus, locks body scroll and\n // claims Escape from onMount, and releases them in onDestroy -- did all of\n // that on its first opening and on no later one: the second time it opened\n // with the page scrolling behind it and Escape doing nothing.\n //\n // Only scopes that actually mounted are suspended, so a component whose\n // first mount is still deferred (behind a false :if, or an stx-hydrate\n // island) keeps waiting for its own flush.\n function suspendSubtreeScopes(nodes) {\n if (!nodes || !window.stx || !window.stx._scopes) return;\n var ids = [];\n for (var i = 0; i < nodes.length; i++) {\n var found = stxHost.scopesIn(nodes[i]);\n for (var k = 0; k < found.length; k++) {\n if (ids.indexOf(found[k]) === -1) ids.push(found[k]);\n }\n }\n // Innermost first, the order a page unmounts in: a child releases what it\n // holds before the component it sits in does.\n for (var n = ids.length - 1; n >= 0; n--) {\n var scopeVars = window.stx._scopes[ids[n]];\n if (!scopeVars || !scopeVars.__mounted) continue;\n scopeVars.__mounted = false;\n scopeVars.__suspended = true;\n var release = scopeVars.__destroyCallbacks || [];\n // What onDestroy registered at setup is owed again at the next hide;\n // a cleanup a mount handed back belonged to that mount alone.\n scopeVars.__destroyCallbacks = (scopeVars.__destroyHooks || []).slice();\n for (var j = 0; j < release.length; j++) {\n try { release[j](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n scopeVars.__mountCallbacks = (scopeVars.__mountHooks || []).slice();\n }\n }\n\n // The other half: a suspended scope whose markup is back on the page mounts\n // again. A scope still off the page (hidden by an :if of its own inside this\n // branch) is left for that :if to resume.\n function resumeSubtreeScopes(nodes) {\n if (!nodes || !window.stx || !window.stx._scopes) return;\n for (var i = 0; i < nodes.length; i++) {\n var ids = stxHost.scopesIn(nodes[i]);\n for (var k = 0; k < ids.length; k++) {\n var scopeVars = window.stx._scopes[ids[k]];\n if (!scopeVars || scopeVars.__mounted || !scopeVars.__suspended) continue;\n if (scopeVars.__el && scopeVars.__el.isConnected === false) continue;\n scopeVars.__suspended = false;\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n }\n }\n\n function disposeSubtreeScopes(root) {\n if (!root || !window.stx || !window.stx._scopes) return;\n // The host reports which scopes live in this subtree: the document finds\n // them with a selector, a native host reads the map it keeps as it builds\n // views (#1984).\n var scopeIds = stxHost.scopesIn(root);\n for (var n = 0; n < scopeIds.length; n++) {\n var scopeId = scopeIds[n];\n if (!scopeId) continue;\n var scopeVars = window.stx._scopes[scopeId];\n if (!scopeVars) continue;\n // Hidden by an :if, it already released everything on the way out;\n // running the hooks again would unmount it twice. (A hidden component's\n // root is detached, so no walk reaches it today; this keeps the next\n // disposal path that does from unmounting it twice.)\n var alreadyReleased = scopeVars.__suspended && !scopeVars.__mounted;\n if (!alreadyReleased && scopeVars.__destroyCallbacks && Array.isArray(scopeVars.__destroyCallbacks)) {\n for (var j = 0; j < scopeVars.__destroyCallbacks.length; j++) {\n try { scopeVars.__destroyCallbacks[j](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n }\n delete window.stx._scopes[scopeId];\n }\n }\n\n // Reclaim registry entries whose element is gone from the document.\n //\n // disposeSubtreeScopes only deletes scopes found UNDER the cleanup container,\n // so two shapes leaked forever across SPA navigation (#1775): components\n // rendered outside the swap container (an @include in the layout, above\n // <main>), and elements already detached by the time cleanup ran its\n // querySelectorAll. Each round-trip re-ran the include scripts under fresh\n // scope ids while the previous ids stayed in window.stx._scopes \u2014 ~4 orphans\n // per hop, unbounded, each retaining that scope's vars, signals and closures.\n // Since #1958 a same-layout navigation no longer re-runs the layout's\n // component scripts, and a layout change cleans up the whole body first, so\n // navigation should no longer produce the first shape; the sweep stays for\n // the second, and as the backstop for anything that still does.\n //\n // The sweep is deliberately CONSERVATIVE \u2014 an over-eager delete is the #1737\n // failure (a scope removed from the registry cannot be recreated: its setup\n // IIFE ran once at page load), which is strictly worse than a leak. An entry\n // is dropped only when all three hold:\n // 1. the runtime actually bound it to an element (__el recorded),\n // 2. that element is no longer connected to the document, and\n // 3. neither it nor any ancestor is retained by a live conditional.\n // Entries with no __el (e.g. a scope whose element still sits inside untouched\n // <template> content, never inserted) are left alone \u2014 we can't prove they're\n // dead, and a later clone re-uses that registration.\n function sweepOrphanedScopes() {\n if (!window.stx || !window.stx._scopes) return;\n var scopes = window.stx._scopes;\n for (var id in scopes) {\n if (!Object.prototype.hasOwnProperty.call(scopes, id)) continue;\n var entry = scopes[id];\n if (!entry) continue;\n var el = entry.__el;\n if (!el || el.isConnected) continue;\n // Detached but RETAINED: :if toggles keep their element (bindIf re-inserts\n // the SAME node) and :if/:else chains keep their branches. Parent links\n // inside a detached subtree stay intact, so walking up from the scope\n // element still finds the conditional that owns it.\n var retained = false;\n for (var p = el; p; p = p.parentNode) {\n if (p.__stx_if_bound || p.__stx_chain_member) { retained = true; break; }\n }\n if (retained) continue;\n // Suspended by an :if: released when it hid, so not again here.\n if (!(entry.__suspended && !entry.__mounted) && entry.__destroyCallbacks && Array.isArray(entry.__destroyCallbacks)) {\n for (var k = 0; k < entry.__destroyCallbacks.length; k++) {\n try { entry.__destroyCallbacks[k](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n }\n delete scopes[id];\n }\n }\n";
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export const SIGNALS_SCOPE_DISPOSAL_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Scope Disposal
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
// Walk a subtree (root + descendants) and fire each [data-stx-scope]'s
|
|
6
|
+
// destroy callbacks + remove the entry from window.stx._scopes. Pre-fix
|
|
7
|
+
// (stacksjs/stx#1727) only cleanupContainer (called during SPA navigation)
|
|
8
|
+
// ran this walk, so dynamic unmounts driven by :if/:for leaked scopes
|
|
9
|
+
// indefinitely. Now bindIf, bindFor, and cleanupContainer all funnel
|
|
10
|
+
// through this helper so the cleanup is symmetric regardless of who
|
|
11
|
+
// initiated the removal.
|
|
12
|
+
// Dispose the EFFECTS bound inside a subtree leaving the page for good: a
|
|
13
|
+
// removed :for row, a hidden template :if clone, a hidden :for empty
|
|
14
|
+
// placeholder, or a container on SPA navigation (#1954).
|
|
15
|
+
// disposeSubtreeScopes only releases scope registrations. Without this, the
|
|
16
|
+
// effects that bound the subtree stay subscribed to every signal they read
|
|
17
|
+
// and keep running, so work per update grows with every removal.
|
|
18
|
+
// Descendants first, then the root, the order cleanupContainer always used.
|
|
19
|
+
function disposeSubtreeEffects(root) {
|
|
20
|
+
if (!root) return;
|
|
21
|
+
var nodes = stxHost.descendants(root);
|
|
22
|
+
nodes.push(root);
|
|
23
|
+
var owned = ['__stx_disposers', '__stx_effect_disposers', '__stx_if_disposers', '__stx_chain_disposers'];
|
|
24
|
+
for (var n = 0; n < nodes.length; n++) {
|
|
25
|
+
var el = nodes[n];
|
|
26
|
+
if (typeof el.__stx_hydration_cancel === 'function') {
|
|
27
|
+
try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }
|
|
28
|
+
el.__stx_hydration_cancel = null;
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(el.__stx_destroy)) {
|
|
31
|
+
var hooks = el.__stx_destroy;
|
|
32
|
+
el.__stx_destroy = null;
|
|
33
|
+
hooks.forEach(function(fn) {
|
|
34
|
+
try { fn(); }
|
|
35
|
+
catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (el.__stx_detached_if) {
|
|
39
|
+
var detached = el.__stx_detached_if;
|
|
40
|
+
el.__stx_detached_if = null;
|
|
41
|
+
detached.forEach(function(node) { disposeSubtreeEffects(node); });
|
|
42
|
+
}
|
|
43
|
+
for (var k = 0; k < owned.length; k++) {
|
|
44
|
+
var disposeOwned = el[owned[k]];
|
|
45
|
+
if (typeof disposeOwned === 'function') {
|
|
46
|
+
el[owned[k]] = null;
|
|
47
|
+
disposeOwned();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// :if is a toggle, and a component inside one lives through every toggle:
|
|
54
|
+
// its scope is registered once and kept (#1737), and showing the branch puts
|
|
55
|
+
// the same markup back. Its LIFECYCLE follows the toggle, though. Hiding runs
|
|
56
|
+
// what the component registered to release -- its onDestroy, and whatever
|
|
57
|
+
// its onMount handed back -- and showing it again runs its onMount again.
|
|
58
|
+
// Each show is a mount and each hide an unmount, which is the pairing every
|
|
59
|
+
// component on a page already gets.
|
|
60
|
+
//
|
|
61
|
+
// Before this, a hidden component never heard about it and a re-shown one
|
|
62
|
+
// was never told it was back (the asymmetry stacksjs/stx#2036 stopped short
|
|
63
|
+
// of). A gated modal shell -- one that traps focus, locks body scroll and
|
|
64
|
+
// claims Escape from onMount, and releases them in onDestroy -- did all of
|
|
65
|
+
// that on its first opening and on no later one: the second time it opened
|
|
66
|
+
// with the page scrolling behind it and Escape doing nothing.
|
|
67
|
+
//
|
|
68
|
+
// Only scopes that actually mounted are suspended, so a component whose
|
|
69
|
+
// first mount is still deferred (behind a false :if, or an stx-hydrate
|
|
70
|
+
// island) keeps waiting for its own flush.
|
|
71
|
+
function suspendSubtreeScopes(nodes) {
|
|
72
|
+
if (!nodes || !window.stx || !window.stx._scopes) return;
|
|
73
|
+
var ids = [];
|
|
74
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
75
|
+
var found = stxHost.scopesIn(nodes[i]);
|
|
76
|
+
for (var k = 0; k < found.length; k++) {
|
|
77
|
+
if (ids.indexOf(found[k]) === -1) ids.push(found[k]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Innermost first, the order a page unmounts in: a child releases what it
|
|
81
|
+
// holds before the component it sits in does.
|
|
82
|
+
for (var n = ids.length - 1; n >= 0; n--) {
|
|
83
|
+
var scopeVars = window.stx._scopes[ids[n]];
|
|
84
|
+
if (!scopeVars || !scopeVars.__mounted) continue;
|
|
85
|
+
scopeVars.__mounted = false;
|
|
86
|
+
scopeVars.__suspended = true;
|
|
87
|
+
var release = scopeVars.__destroyCallbacks || [];
|
|
88
|
+
// What onDestroy registered at setup is owed again at the next hide;
|
|
89
|
+
// a cleanup a mount handed back belonged to that mount alone.
|
|
90
|
+
scopeVars.__destroyCallbacks = (scopeVars.__destroyHooks || []).slice();
|
|
91
|
+
for (var j = 0; j < release.length; j++) {
|
|
92
|
+
try { release[j](); }
|
|
93
|
+
catch (e) { console.warn('[stx] scope destroy error:', e); }
|
|
94
|
+
}
|
|
95
|
+
scopeVars.__mountCallbacks = (scopeVars.__mountHooks || []).slice();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The other half: a suspended scope whose markup is back on the page mounts
|
|
100
|
+
// again. A scope still off the page (hidden by an :if of its own inside this
|
|
101
|
+
// branch) is left for that :if to resume.
|
|
102
|
+
function resumeSubtreeScopes(nodes) {
|
|
103
|
+
if (!nodes || !window.stx || !window.stx._scopes) return;
|
|
104
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
105
|
+
var ids = stxHost.scopesIn(nodes[i]);
|
|
106
|
+
for (var k = 0; k < ids.length; k++) {
|
|
107
|
+
var scopeVars = window.stx._scopes[ids[k]];
|
|
108
|
+
if (!scopeVars || scopeVars.__mounted || !scopeVars.__suspended) continue;
|
|
109
|
+
if (scopeVars.__el && scopeVars.__el.isConnected === false) continue;
|
|
110
|
+
scopeVars.__suspended = false;
|
|
111
|
+
scopeVars.__mounted = true;
|
|
112
|
+
runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function disposeSubtreeScopes(root) {
|
|
118
|
+
if (!root || !window.stx || !window.stx._scopes) return;
|
|
119
|
+
// The host reports which scopes live in this subtree: the document finds
|
|
120
|
+
// them with a selector, a native host reads the map it keeps as it builds
|
|
121
|
+
// views (#1984).
|
|
122
|
+
var scopeIds = stxHost.scopesIn(root);
|
|
123
|
+
for (var n = 0; n < scopeIds.length; n++) {
|
|
124
|
+
var scopeId = scopeIds[n];
|
|
125
|
+
if (!scopeId) continue;
|
|
126
|
+
var scopeVars = window.stx._scopes[scopeId];
|
|
127
|
+
if (!scopeVars) continue;
|
|
128
|
+
// Hidden by an :if, it already released everything on the way out;
|
|
129
|
+
// running the hooks again would unmount it twice. (A hidden component's
|
|
130
|
+
// root is detached, so no walk reaches it today; this keeps the next
|
|
131
|
+
// disposal path that does from unmounting it twice.)
|
|
132
|
+
var alreadyReleased = scopeVars.__suspended && !scopeVars.__mounted;
|
|
133
|
+
if (!alreadyReleased && scopeVars.__destroyCallbacks && Array.isArray(scopeVars.__destroyCallbacks)) {
|
|
134
|
+
for (var j = 0; j < scopeVars.__destroyCallbacks.length; j++) {
|
|
135
|
+
try { scopeVars.__destroyCallbacks[j](); }
|
|
136
|
+
catch (e) { console.warn('[stx] scope destroy error:', e); }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
delete window.stx._scopes[scopeId];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Reclaim registry entries whose element is gone from the document.
|
|
144
|
+
//
|
|
145
|
+
// disposeSubtreeScopes only deletes scopes found UNDER the cleanup container,
|
|
146
|
+
// so two shapes leaked forever across SPA navigation (#1775): components
|
|
147
|
+
// rendered outside the swap container (an @include in the layout, above
|
|
148
|
+
// <main>), and elements already detached by the time cleanup ran its
|
|
149
|
+
// querySelectorAll. Each round-trip re-ran the include scripts under fresh
|
|
150
|
+
// scope ids while the previous ids stayed in window.stx._scopes \u2014 ~4 orphans
|
|
151
|
+
// per hop, unbounded, each retaining that scope's vars, signals and closures.
|
|
152
|
+
// Since #1958 a same-layout navigation no longer re-runs the layout's
|
|
153
|
+
// component scripts, and a layout change cleans up the whole body first, so
|
|
154
|
+
// navigation should no longer produce the first shape; the sweep stays for
|
|
155
|
+
// the second, and as the backstop for anything that still does.
|
|
156
|
+
//
|
|
157
|
+
// The sweep is deliberately CONSERVATIVE \u2014 an over-eager delete is the #1737
|
|
158
|
+
// failure (a scope removed from the registry cannot be recreated: its setup
|
|
159
|
+
// IIFE ran once at page load), which is strictly worse than a leak. An entry
|
|
160
|
+
// is dropped only when all three hold:
|
|
161
|
+
// 1. the runtime actually bound it to an element (__el recorded),
|
|
162
|
+
// 2. that element is no longer connected to the document, and
|
|
163
|
+
// 3. neither it nor any ancestor is retained by a live conditional.
|
|
164
|
+
// Entries with no __el (e.g. a scope whose element still sits inside untouched
|
|
165
|
+
// <template> content, never inserted) are left alone \u2014 we can't prove they're
|
|
166
|
+
// dead, and a later clone re-uses that registration.
|
|
167
|
+
function sweepOrphanedScopes() {
|
|
168
|
+
if (!window.stx || !window.stx._scopes) return;
|
|
169
|
+
var scopes = window.stx._scopes;
|
|
170
|
+
for (var id in scopes) {
|
|
171
|
+
if (!Object.prototype.hasOwnProperty.call(scopes, id)) continue;
|
|
172
|
+
var entry = scopes[id];
|
|
173
|
+
if (!entry) continue;
|
|
174
|
+
var el = entry.__el;
|
|
175
|
+
if (!el || el.isConnected) continue;
|
|
176
|
+
// Detached but RETAINED: :if toggles keep their element (bindIf re-inserts
|
|
177
|
+
// the SAME node) and :if/:else chains keep their branches. Parent links
|
|
178
|
+
// inside a detached subtree stay intact, so walking up from the scope
|
|
179
|
+
// element still finds the conditional that owns it.
|
|
180
|
+
var retained = false;
|
|
181
|
+
for (var p = el; p; p = p.parentNode) {
|
|
182
|
+
if (p.__stx_if_bound || p.__stx_chain_member) { retained = true; break; }
|
|
183
|
+
}
|
|
184
|
+
if (retained) continue;
|
|
185
|
+
// Suspended by an :if: released when it hid, so not again here.
|
|
186
|
+
if (!(entry.__suspended && !entry.__mounted) && entry.__destroyCallbacks && Array.isArray(entry.__destroyCallbacks)) {
|
|
187
|
+
for (var k = 0; k < entry.__destroyCallbacks.length; k++) {
|
|
188
|
+
try { entry.__destroyCallbacks[k](); }
|
|
189
|
+
catch (e) { console.warn('[stx] scope destroy error:', e); }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
delete scopes[id];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Scoped-tree traversal used by the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_SCOPE_TRAVERSAL_RUNTIME = " // Helper to process elements while skipping already-processed scoped containers\n function processElementSkipScopes(el, processedScopes) {\n if (processedScopes.has(el)) return;\n if (el.nodeType === Node.TEXT_NODE) {\n processElement(el);\n return;\n }\n if (el.nodeType !== Node.ELEMENT_NODE) return;\n // Skip scoped elements - they were already processed\n if (el.hasAttribute && el.hasAttribute('data-stx-scope')) return;\n // Inactive chain members are owned by bindIfChain. Use explicit branch\n // state because an active nested branch can live under a detached outer\n // conditional while its reactive effects continue to run.\n if (el.__stx_chain_member && !el.__stx_chain_active) return;\n // Process this element's directives without recursing into children\n // (we'll handle children manually to skip scoped ones)\n const hasFor = el.hasAttribute && (el.hasAttribute('@for') || el.hasAttribute(':for') || el.hasAttribute('x-for'));\n const hasIf = el.hasAttribute && (el.hasAttribute('@if') || el.hasAttribute(':if') || el.hasAttribute('x-if'));\n if (hasFor) { var fa = el.hasAttribute(':for') ? ':for' : el.hasAttribute('x-for') ? 'x-for' : '@for'; bindFor(el, componentScope, fa); return; }\n if (hasIf) {\n var ia = el.hasAttribute(':if') ? ':if' : el.hasAttribute('x-if') ? 'x-if' : '@if';\n var ic = findIfChain(el, ia);\n if (ic.length > 1) bindIfChain(ic, componentScope);\n else bindIf(el, componentScope, ia);\n return;\n }\n // Process other attributes...\n var isNativeModal = el.tagName === 'MODAL';\n if (el.hasAttribute && ((el.hasAttribute('@show') && !isNativeModal)\n || el.hasAttribute(':show') || el.hasAttribute('x-show'))) {\n var sa = el.hasAttribute(':show') ? ':show' : el.hasAttribute('x-show') ? 'x-show' : '@show';\n bindShow(el, el.getAttribute(sa), componentScope, sa);\n }\n var mb = getModelBinding(el);\n if (mb) {\n bindModel(el, mb.expression, componentScope, mb.name);\n }\n // Process children, skipping scoped containers and script/style elements\n if (el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {\n Array.from(el.childNodes).forEach(child => processElementSkipScopes(child, processedScopes));\n }\n }";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const SIGNALS_SCOPE_TRAVERSAL_RUNTIME = ` // Helper to process elements while skipping already-processed scoped containers
|
|
2
|
+
function processElementSkipScopes(el, processedScopes) {
|
|
3
|
+
if (processedScopes.has(el)) return;
|
|
4
|
+
if (el.nodeType === Node.TEXT_NODE) {
|
|
5
|
+
processElement(el);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (el.nodeType !== Node.ELEMENT_NODE) return;
|
|
9
|
+
// Skip scoped elements - they were already processed
|
|
10
|
+
if (el.hasAttribute && el.hasAttribute('data-stx-scope')) return;
|
|
11
|
+
// Inactive chain members are owned by bindIfChain. Use explicit branch
|
|
12
|
+
// state because an active nested branch can live under a detached outer
|
|
13
|
+
// conditional while its reactive effects continue to run.
|
|
14
|
+
if (el.__stx_chain_member && !el.__stx_chain_active) return;
|
|
15
|
+
// Process this element's directives without recursing into children
|
|
16
|
+
// (we'll handle children manually to skip scoped ones)
|
|
17
|
+
const hasFor = el.hasAttribute && (el.hasAttribute('@for') || el.hasAttribute(':for') || el.hasAttribute('x-for'));
|
|
18
|
+
const hasIf = el.hasAttribute && (el.hasAttribute('@if') || el.hasAttribute(':if') || el.hasAttribute('x-if'));
|
|
19
|
+
if (hasFor) { var fa = el.hasAttribute(':for') ? ':for' : el.hasAttribute('x-for') ? 'x-for' : '@for'; bindFor(el, componentScope, fa); return; }
|
|
20
|
+
if (hasIf) {
|
|
21
|
+
var ia = el.hasAttribute(':if') ? ':if' : el.hasAttribute('x-if') ? 'x-if' : '@if';
|
|
22
|
+
var ic = findIfChain(el, ia);
|
|
23
|
+
if (ic.length > 1) bindIfChain(ic, componentScope);
|
|
24
|
+
else bindIf(el, componentScope, ia);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Process other attributes...
|
|
28
|
+
var isNativeModal = el.tagName === 'MODAL';
|
|
29
|
+
if (el.hasAttribute && ((el.hasAttribute('@show') && !isNativeModal)
|
|
30
|
+
|| el.hasAttribute(':show') || el.hasAttribute('x-show'))) {
|
|
31
|
+
var sa = el.hasAttribute(':show') ? ':show' : el.hasAttribute('x-show') ? 'x-show' : '@show';
|
|
32
|
+
bindShow(el, el.getAttribute(sa), componentScope, sa);
|
|
33
|
+
}
|
|
34
|
+
var mb = getModelBinding(el);
|
|
35
|
+
if (mb) {
|
|
36
|
+
bindModel(el, mb.expression, componentScope, mb.name);
|
|
37
|
+
}
|
|
38
|
+
// Process children, skipping scoped containers and script/style elements
|
|
39
|
+
if (el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
|
|
40
|
+
Array.from(el.childNodes).forEach(child => processElementSkipScopes(child, processedScopes));
|
|
41
|
+
}
|
|
42
|
+
}`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Reactive visibility binding for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_SHOW_RUNTIME = " function bindShow(el, expr, passedScope = componentScope, attrName = '@show') {\n if (el.__stx_show_bound) return;\n el.__stx_show_bound = true;\n\n const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };\n\n // Check if the expression is a simple signal reference (most common case for :show)\n const directSignal = capturedScope[expr];\n if (directSignal && directSignal._isSignal) {\n // Fast path: directly subscribe to the signal \u2014 guaranteed reactive\n effect(() => {\n const value = directSignal();\n\n stxHost.setVisible(el, !!value);\n });\n } else {\n // Complex expression path \u2014 use createAutoUnwrapProxy with fallback,\n // matching the retry pattern in evalAttrExpr. This ensures call\n // expressions like !recording() work: the proxy auto-unwraps\n // signals on property access, so recording remains a callable\n // signal function (not unwrapped to its boolean value).\n effect(() => {\n var value;\n try {\n var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);\n var fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);\n value = fn(...__stxArgs(fn, unwrapScope));\n } catch (e1) {\n // Retry without unwrapping \u2014 handles edge cases where the proxy\n // interferes with certain expression patterns\n try {\n var fn2 = __stxCompileScoped(capturedScope, [], 'return ' + expr);\n value = fn2(...__stxArgs(fn2, capturedScope));\n } catch (e2) {\n // Suppress ReferenceError/TypeError during async init \u2014 a signal\n // or object may not be ready yet on the first effect run, and\n // the next pass will re-evaluate once data arrives.\n if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Show expression error:', expr, e2);\n stxHost.setVisible(el, false);\n return;\n }\n }\n var wasVisible = stxHost.setVisible(el, !!value);\n // When transitioning from hidden to visible, stamp the element so\n // @click handlers can ignore clicks from the same frame (prevents\n // modal backdrop from catching the click that opened the modal)\n if (value && !wasVisible) {\n el.__stx_shown_at = performance.now();\n }\n });\n }\n el.removeAttribute(attrName);\n }\n";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const SIGNALS_SHOW_RUNTIME = ` function bindShow(el, expr, passedScope = componentScope, attrName = '@show') {
|
|
2
|
+
if (el.__stx_show_bound) return;
|
|
3
|
+
el.__stx_show_bound = true;
|
|
4
|
+
|
|
5
|
+
const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
|
|
6
|
+
|
|
7
|
+
// Check if the expression is a simple signal reference (most common case for :show)
|
|
8
|
+
const directSignal = capturedScope[expr];
|
|
9
|
+
if (directSignal && directSignal._isSignal) {
|
|
10
|
+
// Fast path: directly subscribe to the signal \u2014 guaranteed reactive
|
|
11
|
+
effect(() => {
|
|
12
|
+
const value = directSignal();
|
|
13
|
+
|
|
14
|
+
stxHost.setVisible(el, !!value);
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
// Complex expression path \u2014 use createAutoUnwrapProxy with fallback,
|
|
18
|
+
// matching the retry pattern in evalAttrExpr. This ensures call
|
|
19
|
+
// expressions like !recording() work: the proxy auto-unwraps
|
|
20
|
+
// signals on property access, so recording remains a callable
|
|
21
|
+
// signal function (not unwrapped to its boolean value).
|
|
22
|
+
effect(() => {
|
|
23
|
+
var value;
|
|
24
|
+
try {
|
|
25
|
+
var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
26
|
+
var fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
27
|
+
value = fn(...__stxArgs(fn, unwrapScope));
|
|
28
|
+
} catch (e1) {
|
|
29
|
+
// Retry without unwrapping \u2014 handles edge cases where the proxy
|
|
30
|
+
// interferes with certain expression patterns
|
|
31
|
+
try {
|
|
32
|
+
var fn2 = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
33
|
+
value = fn2(...__stxArgs(fn2, capturedScope));
|
|
34
|
+
} catch (e2) {
|
|
35
|
+
// Suppress ReferenceError/TypeError during async init \u2014 a signal
|
|
36
|
+
// or object may not be ready yet on the first effect run, and
|
|
37
|
+
// the next pass will re-evaluate once data arrives.
|
|
38
|
+
if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Show expression error:', expr, e2);
|
|
39
|
+
stxHost.setVisible(el, false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var wasVisible = stxHost.setVisible(el, !!value);
|
|
44
|
+
// When transitioning from hidden to visible, stamp the element so
|
|
45
|
+
// @click handlers can ignore clicks from the same frame (prevents
|
|
46
|
+
// modal backdrop from catching the click that opened the modal)
|
|
47
|
+
if (value && !wasVisible) {
|
|
48
|
+
el.__stx_shown_at = performance.now();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
el.removeAttribute(attrName);
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** SPA load scheduling and teardown boundaries for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_SPA_LOAD_CONTROL_RUNTIME = " // Re-initialize components after SPA content swap.\n // Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).\n var _stxLoadTimer = null;\n if (window.__stxLoadHandler) {\n window.removeEventListener('stx:load', window.__stxLoadHandler);\n }\n function stxLoadHandler() {\n if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }\n _stxLoadTimer = setTimeout(_handleStxLoad, 5);\n }\n window.__stxLoadHandler = stxLoadHandler;\n window.addEventListener('stx:load', stxLoadHandler);\n\n // Run a pending stx:load now instead of after the debounce. The router's\n // instant navigation (a tab bar) reveals the new screen in a single frame\n // once the page is bound; waiting out the timer revealed it with its\n // {{ }} still unbound and filled it in a frame later.\n function flushStxLoad() {\n if (!_stxLoadTimer) return false;\n clearTimeout(_stxLoadTimer);\n _handleStxLoad();\n return true;\n }\n // The page-level onDestroy callbacks a navigation is leaving behind.\n //\n // stx:load used to run everything in destroyCallbacks, on the reading that\n // the queue held the outgoing page. It does not by then: the router runs the\n // incoming page's scripts BEFORE it fires stx:load, and a page-level\n // onDestroy registered by one of them (a layout partial's useColorMode, a\n // listener, a stream) joined the same queue and was run at once - its owner\n // still on screen. A tab bar that retains screens made it certain, since\n // that path had already filed the outgoing page's callbacks with its screen,\n // so the queue stx:load drained held only the new page's. The page then\n // stopped following the system theme, among other things, until a reload.\n //\n // The router marks the boundary with _beginSwap just before the incoming\n // scripts run. Null means no boundary was marked since the last stx:load (a\n // re-fire, an older router), and then the queue is drained as before.\n var departingDestroys = null;\n function beginSwap() {\n departingDestroys = (departingDestroys || []).concat(destroyCallbacks.splice(0));\n }";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const SIGNALS_SPA_LOAD_CONTROL_RUNTIME = ` // Re-initialize components after SPA content swap.
|
|
2
|
+
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
3
|
+
var _stxLoadTimer = null;
|
|
4
|
+
if (window.__stxLoadHandler) {
|
|
5
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
6
|
+
}
|
|
7
|
+
function stxLoadHandler() {
|
|
8
|
+
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
9
|
+
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
10
|
+
}
|
|
11
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
12
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
13
|
+
|
|
14
|
+
// Run a pending stx:load now instead of after the debounce. The router's
|
|
15
|
+
// instant navigation (a tab bar) reveals the new screen in a single frame
|
|
16
|
+
// once the page is bound; waiting out the timer revealed it with its
|
|
17
|
+
// {{ }} still unbound and filled it in a frame later.
|
|
18
|
+
function flushStxLoad() {
|
|
19
|
+
if (!_stxLoadTimer) return false;
|
|
20
|
+
clearTimeout(_stxLoadTimer);
|
|
21
|
+
_handleStxLoad();
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// The page-level onDestroy callbacks a navigation is leaving behind.
|
|
25
|
+
//
|
|
26
|
+
// stx:load used to run everything in destroyCallbacks, on the reading that
|
|
27
|
+
// the queue held the outgoing page. It does not by then: the router runs the
|
|
28
|
+
// incoming page's scripts BEFORE it fires stx:load, and a page-level
|
|
29
|
+
// onDestroy registered by one of them (a layout partial's useColorMode, a
|
|
30
|
+
// listener, a stream) joined the same queue and was run at once - its owner
|
|
31
|
+
// still on screen. A tab bar that retains screens made it certain, since
|
|
32
|
+
// that path had already filed the outgoing page's callbacks with its screen,
|
|
33
|
+
// so the queue stx:load drained held only the new page's. The page then
|
|
34
|
+
// stopped following the system theme, among other things, until a reload.
|
|
35
|
+
//
|
|
36
|
+
// The router marks the boundary with _beginSwap just before the incoming
|
|
37
|
+
// scripts run. Null means no boundary was marked since the last stx:load (a
|
|
38
|
+
// re-fire, an older router), and then the queue is drained as before.
|
|
39
|
+
var departingDestroys = null;
|
|
40
|
+
function beginSwap() {
|
|
41
|
+
departingDestroys = (departingDestroys || []).concat(destroyCallbacks.splice(0));
|
|
42
|
+
}`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** SPA content rehydration used by the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_SPA_LOAD_RUNTIME = " function _handleStxLoad() {\n _stxLoadTimer = null;\n console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);\n\n // Run the outgoing page's destroy callbacks before re-initializing. Taken\n // out of their queue first, so one that registers another lands in the\n // next generation instead of being cleared unrun.\n var departing = departingDestroys !== null ? departingDestroys : destroyCallbacks.splice(0);\n departingDestroys = null;\n departing.forEach(function(fn) {\n try { fn(); }\ncatch (e) { console.warn('[stx] destroy callback error:', e); }\n });\n\n // Re-process scoped components in new content\n var routerOpts = window.STX_ROUTER_OPTIONS || window.__stxRouterConfig || {};\n var container = document.querySelector('[data-stx-content]')\n || (routerOpts.container ? document.querySelector(routerOpts.container) : null)\n || document.querySelector('main')\n || document.querySelector('#main-content')\n || document.body;\n\n // Apply new page's SFC setup function. During SPA navigation, re-executed page\n // scripts set window.stx._latestSetup to the new setup function. This takes priority\n // over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).\n var usedLatestSetup = false;\n if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {\n try {\n var setupResult = window.stx._latestSetup();\n // Keep _latestSetup for re-fires (HMR, auto-refresh re-navigation)\n // It will be overwritten when a NEW page's script sets it\n usedLatestSetup = true;\n if (typeof setupResult === 'object' && setupResult !== null) {\n console.log('[stx:load] _latestSetup keys:', Object.keys(setupResult).slice(0, 10));\n Object.assign(componentScope, setupResult);\n }\n } catch (e) {\n console.error('[stx:load] _latestSetup error:', e);\n usedLatestSetup = true; // Don't fall back to stale data-stx\n }\n }\n console.log('[stx:load] usedLatestSetup:', usedLatestSetup, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n\n // Only fall back to [data-stx] attribute lookup if _latestSetup wasn't available.\n // This handles the initial DOMContentLoaded-like case and pages that don't use _latestSetup.\n if (!usedLatestSetup) {\n document.querySelectorAll('[data-stx]').forEach(function(el) {\n var setupName = el.getAttribute('data-stx');\n if (setupName && window[setupName]) {\n var result = window[setupName]();\n if (typeof result === 'object') Object.assign(componentScope, result);\n }\n });\n }\n var spaPageScopeSnapshot = { ...componentScope };\n\n // Routed component mount scripts execute after DOMContentLoaded. Queue them\n // until the destination page setup is active so projected props and parent\n // event handlers resolve against the caller, matching initial hydration.\n mountQueue.forEach(function(fn) { fn(); });\n mountQueue = [];\n\n // Initialize x-data scopes after SPA fragment swap.\n // On full page load, the reactive bridge <script> calls initScope(). But after SPA\n // navigation, only the HTML fragment is swapped \u2014 the bridge script isn't re-executed.\n // The server renames x-data \u2192 data-stx-xdata so we can read the state expression here.\n if (window.__stx_reactive && window.__stx_reactive.initScope) {\n container.querySelectorAll('[data-stx-xdata]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n // Skip if scope already registered (e.g. nav scope that persists across navigations)\n if (scopeId && window.stx._scopes && window.stx._scopes[scopeId]) return;\n var xdata = el.getAttribute('data-stx-xdata');\n if (!xdata) return;\n // Assign a scope ID if not already present\n if (!scopeId) {\n scopeId = '__stx_scope_spa_' + (++window.stx._scopeCounter);\n el.setAttribute('data-stx-scope', scopeId);\n }\n // The init expression, which used to be dropped here. A scope\n // re-initialized with its data and none of its setup renders every\n // binding at its initial value and starts nothing - a live region\n // showing its empty state forever, which is indistinguishable from one\n // where nothing has happened yet.\n var xinit = el.getAttribute('data-stx-xinit');\n console.log('[stx:load] initializing x-data scope:', scopeId, xdata.substring(0, 40));\n window.__stx_reactive.initScope(el, xdata, [], {}, xinit || null);\n });\n }\n\n // Apply scope from [data-stx-scope] elements and process them.\n // Walk document.body (not just container) so layout-level scopes dropped\n // by a full-body-swap SPA nav (e.g. nav/header/footer when the layout\n // group changes) get bound. The __stx_disposers guard makes the walk\n // idempotent \u2014 persistent layout scopes across same-layout navs are\n // skipped instead of double-disposed. See stacksjs/stx#1697.\n document.body.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n var scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n // Record the bound element for the orphan sweep (#1775) \u2014 see the\n // DOMContentLoaded walk above for the rationale.\n if (scopeVars) scopeVars.__el = el;\n // Deferred island reached via SPA navigation (#1746): its setup script is\n // inert (type=\"stx/island\"), so the scope isn't registered yet. Arm the\n // hydration trigger (deferHydration) instead of skipping it \u2014 mirrors the\n // initial-load DOMContentLoaded path, which has the same guard. Without\n // this, a client=\"visible|idle|\u2026\" island on a page reached by SPA nav\n // (inline OR chunked) never hydrates.\n if (!scopeVars && el.hasAttribute && el.hasAttribute('stx-hydrate')\n && !el.__stx_hydration_scheduled\n && document.querySelector('script[data-stx-island=\"' + scopeId + '\"]')) {\n processElement(el, componentScope);\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n return;\n }\n if (!scopeVars) return;\n el.__stx_parent_scope = el.__stx_parent_scope\n || resolveComponentCallerScope(el, spaPageScopeSnapshot);\n bindParentComponentProps(el, el.__stx_parent_scope);\n // Already bound: a layout component that stayed on the page. Its\n // bindings are live and read its own scope, so there is nothing to\n // merge \u2014 and merging it AFTER the destination page's setup let a name\n // the two share take the component's value for the page. The offline\n // banner's connected flag read as a Settings card's \"Connected\".\n if (el.__stx_disposers) return;\n Object.assign(componentScope, scopeVars);\n var disposeEffects = trackEffects(function() { processElement(el, componentScope); });\n el.__stx_disposers = disposeEffects;\n // A replacement layout's scope can live outside the router container.\n // Reveal it after binding, matching the initial hydration and mount paths.\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n\n // The page's own names win over its components' locals. The walk above\n // merges each component's locals into the scope the container is bound\n // with, so a component declaring a name the page also declares took it\n // over for the whole page: HQ's coach dashboard aliases store signals as\n // loading and roster, a card further down declares its own loading and\n // roster, and reached by the router the page's\n // :if=\"loading && !roster.length\" read the card's and never cleared. A\n // full load binds the page before any component, so it never saw this.\n // A component's own bindings resolve its locals through its scope element,\n // and a name only a component declares stays reachable as before.\n Object.assign(componentScope, spaPageScopeSnapshot);\n\n // Process the container content \u2014 bind {{ }}, :attr, @event directives.\n // Run synchronously (not in setTimeout) so componentScope is captured correctly.\n // The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.\n console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n if (!container.__stx_scope) {\n // Dispose previous effects on the container (from prior navigation)\n if (container.__stx_disposers && typeof container.__stx_disposers === 'function') {\n container.__stx_disposers();\n }\n console.log('[stx:load] processElement on container');\n var disposeEffects = trackEffects(function() { processElement(container, componentScope); });\n container.__stx_disposers = disposeEffects;\n } else {\n console.log('[stx:load] SKIPPED processElement \u2014 container has __stx_scope');\n }\n\n // Remove x-cloak\n container.removeAttribute('x-cloak');\n container.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n // Fire mount callbacks from scoped components. Walk document.body so\n // layout-level scopes added by a full-body swap mount; __mounted guard\n // prevents persistent layout scopes from re-firing their onMount on\n // every same-layout SPA nav. See stacksjs/stx#1697.\n document.body.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n var scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted) {\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n });\n\n // Flush global mountCallbacks (from scripts re-executed after SPA content swap)\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n mountCallbacks.length = 0;\n\n // Everything that should have hydrated has now had its chance (#1773).\n auditHydration(container, 'stx:load');\n }\n";
|