@stacksjs/stx 0.2.532 → 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-y4qks0bd.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-4gt0r98p.js → chunk-2bvk0qyd.js} +2 -2
- package/dist/{chunk-y7ds4qyb.js → chunk-2h4f37kx.js} +2 -2
- package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
- package/dist/{chunk-xdtz2v5r.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-khwj964t.js → chunk-40hbpz2b.js} +3 -3
- package/dist/chunk-4a7v51vh.js +2 -0
- package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
- package/dist/{chunk-hp1tnxzb.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-0pebjkzx.js → chunk-843y0pfg.js} +4 -4
- package/dist/{chunk-4xxhprts.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-t6769zcy.js → chunk-93n6yv5x.js} +12 -12
- package/dist/chunk-94rg5s6c.js +2 -0
- package/dist/chunk-9674w2gm.js +2 -0
- package/dist/{chunk-gvw8wh29.js → chunk-9p6bt089.js} +3 -3
- package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
- package/dist/{chunk-rs46hksk.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-664503e6.js → chunk-d871008z.js} +4 -4
- package/dist/chunk-dekpf1ry.js +2 -0
- package/dist/chunk-epa1c4q4.js +2 -0
- package/dist/{chunk-xb0785wp.js → chunk-f3q84h7b.js} +2 -2
- package/dist/{chunk-g060jncp.js → chunk-fqfqyn48.js} +4 -4
- package/dist/{chunk-g5t10z04.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-rwn3b21z.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-ee4wwr89.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-j8pacd7m.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-m2v04c6v.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-grb3kfya.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-stbsqy7e.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-1945hk44.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/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-0p9pwd61.js +0 -2
- package/dist/chunk-0zmv31nc.js +0 -2
- package/dist/chunk-28xtazwz.js +0 -2
- package/dist/chunk-2936t942.js +0 -2
- package/dist/chunk-29qwmthc.js +0 -2
- package/dist/chunk-323cxa69.js +0 -2
- package/dist/chunk-375zp0vr.js +0 -2
- package/dist/chunk-3w49r16x.js +0 -2
- package/dist/chunk-8bcvb86w.js +0 -2
- package/dist/chunk-8gmb3k1p.js +0 -2
- package/dist/chunk-a15yzfc6.js +0 -2
- package/dist/chunk-d4155ec5.js +0 -2
- package/dist/chunk-dd31q423.js +0 -2
- package/dist/chunk-f2q5bckn.js +0 -2
- package/dist/chunk-fhx35529.js +0 -2
- package/dist/chunk-h1y5q942.js +0 -2
- package/dist/chunk-h791c7sb.js +0 -2
- package/dist/chunk-h88jcr3k.js +0 -2
- package/dist/chunk-heq5c0gd.js +0 -2
- package/dist/chunk-j3b24e77.js +0 -2
- package/dist/chunk-jpck8nm5.js +0 -2
- package/dist/chunk-m4d99a9r.js +0 -2
- package/dist/chunk-ng2sdph7.js +0 -2
- package/dist/chunk-qs3p7sc6.js +0 -2
- package/dist/chunk-rchwwcxy.js +0 -2
- package/dist/chunk-rk4mttds.js +0 -2
- package/dist/chunk-rma3bv36.js +0 -2
- package/dist/chunk-rp5a91ak.js +0 -2
- package/dist/chunk-sp5x96rn.js +0 -2
- package/dist/chunk-t2mjeezd.js +0 -2
- package/dist/chunk-t61j834x.js +0 -2
- package/dist/chunk-v2vg5jqq.js +0 -2
- package/dist/chunk-vmfw4svt.js +0 -2
- package/dist/chunk-w6ecbk3y.js +0 -2
- package/dist/chunk-wbv6vjhm.js +0 -2
- package/dist/chunk-wfbr3txe.js +0 -2
- package/dist/chunk-wpnv0naj.js +0 -2
- package/dist/chunk-wwny5dk9.js +0 -2
- package/dist/chunk-x55avrcf.js +0 -2
- package/dist/chunk-yts2745t.js +0 -2
- package/dist/chunk-zah67v44.js +0 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const SIGNALS_GLOBALS_RUNTIME = ` // Also expose globally for convenience
|
|
2
|
+
window.state = state;
|
|
3
|
+
window.derived = derived;
|
|
4
|
+
window.effect = effect;
|
|
5
|
+
window.batch = batch;
|
|
6
|
+
window.onMount = onMount;
|
|
7
|
+
window.onDestroy = onDestroy;
|
|
8
|
+
window.useFetch = useFetch;
|
|
9
|
+
window.clearServerData = clearServerData;
|
|
10
|
+
window.useRef = useRef;
|
|
11
|
+
window.navigate = navigate;
|
|
12
|
+
window.goBack = goBack;
|
|
13
|
+
window.goForward = goForward;
|
|
14
|
+
window.useRoute = useRoute;
|
|
15
|
+
window.useSearchParams = useSearchParams;
|
|
16
|
+
window.useQuery = useQuery;
|
|
17
|
+
window.useMutation = useMutation;
|
|
18
|
+
window.provide = provide;
|
|
19
|
+
window.$computed = $computed;
|
|
20
|
+
window.$watch = $watch;
|
|
21
|
+
window.useDebounce = useDebounce;
|
|
22
|
+
window.useDebouncedValue = useDebouncedValue;
|
|
23
|
+
window.useThrottle = useThrottle;
|
|
24
|
+
window.useInterval = useInterval;
|
|
25
|
+
window.useTimeout = useTimeout;
|
|
26
|
+
window.useToggle = useToggle;
|
|
27
|
+
window.useCounter = useCounter;
|
|
28
|
+
window.useClickOutside = useClickOutside;
|
|
29
|
+
window.useFocus = useFocus;
|
|
30
|
+
window.nextTick = nextTick;
|
|
31
|
+
window.useAsync = useAsync;
|
|
32
|
+
window.useLocalStorage = useLocalStorage;
|
|
33
|
+
// Paired with the line above. Both are in STX_RUNTIME_GLOBALS, so a
|
|
34
|
+
// <script client> block gets either via the setup destructure \u2014 but code
|
|
35
|
+
// that reads the bare window global directly (a plain <script>, or a
|
|
36
|
+
// bundled module that wasn't rewritten) found useLocalStorage defined and
|
|
37
|
+
// useSessionStorage undefined.
|
|
38
|
+
window.useSessionStorage = useSessionStorage;
|
|
39
|
+
window.keptState = keptState;
|
|
40
|
+
window.forgetKeptState = forgetKeptState;
|
|
41
|
+
window.setKeptScope = setKeptScope;
|
|
42
|
+
window.flushKeptState = flushKeptState;
|
|
43
|
+
window.cachedQuery = cachedQuery;
|
|
44
|
+
window.useEventListener = useEventListener;
|
|
45
|
+
window.useWebSocket = useWebSocket;
|
|
46
|
+
window.useColorMode = useColorMode;
|
|
47
|
+
window.useDark = useDark;
|
|
48
|
+
window.useHead = useHead;
|
|
49
|
+
window.useSeoMeta = useSeoMeta;
|
|
50
|
+
window.toast = toast;
|
|
51
|
+
window.modal = modal;
|
|
52
|
+
window.drawer = drawer;
|
|
53
|
+
window.stxAlert = stxAlert;
|
|
54
|
+
window.stxConfirm = stxConfirm;
|
|
55
|
+
window.defineStore = window.stx.defineStore;
|
|
56
|
+
window.useStore = window.stx.useStore;
|
|
57
|
+
window.ref = state;
|
|
58
|
+
window.reactive = reactive;
|
|
59
|
+
window.computed = derived;
|
|
60
|
+
window.watch = $watch;
|
|
61
|
+
window.watchEffect = function(fn) { return effect(fn); };
|
|
62
|
+
|
|
63
|
+
// Note: SPA Router and View Transitions CSS are provided by the canonical
|
|
64
|
+
// router script (packages/router/src/client.ts) which is injected alongside
|
|
65
|
+
// the signals runtime or via the @stxRouter directive.
|
|
66
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Signal-aware event expression handling for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_HANDLER_RUNTIME = " function expressionUsesSignalApi(expression, name) {\n var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n return expressionUsesSignalMethod(expression, name)\n || expressionUsesSignalValue(expression, name);\n }\n\n function expressionUsesSignalMethod(expression, name) {\n var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\.\\\\s*(?:set|update|subscribe|toggle|input|change)\\\\s*\\\\(').test(expression);\n }\n\n function expressionUsesSignalValue(expression, name) {\n var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\.\\\\s*value\\\\b').test(expression);\n }\n\n function expressionCallsSignal(expression, name) {\n var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\(').test(expression);\n }\n\n function createExpressionAutoUnwrapProxy(scope, expression) {\n return createAutoUnwrapProxy(scope, function(prop, signal) {\n if (typeof prop !== 'string') return false;\n if (expressionCallsSignal(expression, prop) || expressionUsesSignalMethod(expression, prop))\n return true;\n if (!expressionUsesSignalValue(expression, prop))\n return false;\n\n // A :for item is itself represented by a signal. If that item's value\n // is an object with a real value field, item.value means the field,\n // not the signal wrapper API. Primitive signals still support\n // count.value, matching the explicit ref syntax.\n try {\n var currentValue = signal();\n return !(currentValue && typeof currentValue === 'object'\n && Object.prototype.hasOwnProperty.call(currentValue, 'value'));\n }\n catch (e) {\n return true;\n }\n });\n }\n\n function executeHandler(expr, event, el) {\n try {\n // Skip placeholder expressions like __TITLE__ (build-time placeholders)\n if (/^__[A-Z_]+__$/.test(expr.trim())) {\n return;\n }\n // First try component-level scope\n const elementScope = findElementScope(el || currentElement);\n const scope = { ...globalHelpers, ...componentScope, ...(elementScope || {}) };\n\n // Check for shorthand syntax (Feature #8)\n const shorthandFn = parseEventShorthand(expr, scope);\n if (shorthandFn) {\n shorthandFn(event);\n return;\n }\n\n // Loop items arrive as signals (see createItemElements). Unwrap them for\n // the same reason the inline @event path does: `item.value` in a handler\n // means the item's field, not the signal API.\n const handlerScope = {};\n Object.keys(scope).forEach(function(k) {\n const v = scope[k];\n handlerScope[k] = (v && typeof v === 'function' && v._isStxLoopItem) ? v() : v;\n });\n const fn = __stxCompileScoped(handlerScope, ['$event'], expr);\n fn(...__stxArgs(fn, handlerScope), event);\n }\ncatch (e) {\n // Event handlers fire on user interaction, not reactive re-runs \u2014 there's no\n // async-hydration race to silence. Surfacing TypeError/ReferenceError is what\n // turns \"@click does nothing, no warning\" into a 5-second debug. See #1694.\n console.warn('[STX] Handler error:', expr, e);\n }\n }\n";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export const SIGNALS_HANDLER_RUNTIME = ` function expressionUsesSignalApi(expression, name) {
|
|
2
|
+
var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');
|
|
3
|
+
return expressionUsesSignalMethod(expression, name)
|
|
4
|
+
|| expressionUsesSignalValue(expression, name);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function expressionUsesSignalMethod(expression, name) {
|
|
8
|
+
var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');
|
|
9
|
+
return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\.\\\\s*(?:set|update|subscribe|toggle|input|change)\\\\s*\\\\(').test(expression);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function expressionUsesSignalValue(expression, name) {
|
|
13
|
+
var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');
|
|
14
|
+
return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\.\\\\s*value\\\\b').test(expression);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function expressionCallsSignal(expression, name) {
|
|
18
|
+
var escapedName = name.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');
|
|
19
|
+
return new RegExp('(?:^|[^\\\\w$])' + escapedName + '\\\\s*\\\\(').test(expression);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createExpressionAutoUnwrapProxy(scope, expression) {
|
|
23
|
+
return createAutoUnwrapProxy(scope, function(prop, signal) {
|
|
24
|
+
if (typeof prop !== 'string') return false;
|
|
25
|
+
if (expressionCallsSignal(expression, prop) || expressionUsesSignalMethod(expression, prop))
|
|
26
|
+
return true;
|
|
27
|
+
if (!expressionUsesSignalValue(expression, prop))
|
|
28
|
+
return false;
|
|
29
|
+
|
|
30
|
+
// A :for item is itself represented by a signal. If that item's value
|
|
31
|
+
// is an object with a real value field, item.value means the field,
|
|
32
|
+
// not the signal wrapper API. Primitive signals still support
|
|
33
|
+
// count.value, matching the explicit ref syntax.
|
|
34
|
+
try {
|
|
35
|
+
var currentValue = signal();
|
|
36
|
+
return !(currentValue && typeof currentValue === 'object'
|
|
37
|
+
&& Object.prototype.hasOwnProperty.call(currentValue, 'value'));
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function executeHandler(expr, event, el) {
|
|
46
|
+
try {
|
|
47
|
+
// Skip placeholder expressions like __TITLE__ (build-time placeholders)
|
|
48
|
+
if (/^__[A-Z_]+__$/.test(expr.trim())) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// First try component-level scope
|
|
52
|
+
const elementScope = findElementScope(el || currentElement);
|
|
53
|
+
const scope = { ...globalHelpers, ...componentScope, ...(elementScope || {}) };
|
|
54
|
+
|
|
55
|
+
// Check for shorthand syntax (Feature #8)
|
|
56
|
+
const shorthandFn = parseEventShorthand(expr, scope);
|
|
57
|
+
if (shorthandFn) {
|
|
58
|
+
shorthandFn(event);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Loop items arrive as signals (see createItemElements). Unwrap them for
|
|
63
|
+
// the same reason the inline @event path does: \`item.value\` in a handler
|
|
64
|
+
// means the item's field, not the signal API.
|
|
65
|
+
const handlerScope = {};
|
|
66
|
+
Object.keys(scope).forEach(function(k) {
|
|
67
|
+
const v = scope[k];
|
|
68
|
+
handlerScope[k] = (v && typeof v === 'function' && v._isStxLoopItem) ? v() : v;
|
|
69
|
+
});
|
|
70
|
+
const fn = __stxCompileScoped(handlerScope, ['$event'], expr);
|
|
71
|
+
fn(...__stxArgs(fn, handlerScope), event);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
// Event handlers fire on user interaction, not reactive re-runs \u2014 there's no
|
|
75
|
+
// async-hydration race to silence. Surfacing TypeError/ReferenceError is what
|
|
76
|
+
// turns "@click does nothing, no warning" into a 5-second debug. See #1694.
|
|
77
|
+
console.warn('[STX] Handler error:', expr, e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Client-side document head and SEO helpers. */
|
|
2
|
+
export declare const SIGNALS_HEAD_RUNTIME = " // ==========================================================================\n // Client-side useHead / useSeoMeta\n // ==========================================================================\n\n function useHead(config) {\n function apply() {\n if (config.title) document.title = config.title;\n // Process meta tags\n var metas = config.meta || [];\n for (var i = 0; i < metas.length; i++) {\n var m = metas[i];\n if (!m.name && !m.property) continue;\n var selector = m.name ? 'meta[name=\"' + m.name + '\"]' : 'meta[property=\"' + m.property + '\"]';\n var el = document.querySelector(selector);\n if (el) {\n el.setAttribute('content', m.content || '');\n } else {\n el = document.createElement('meta');\n if (m.name) el.setAttribute('name', m.name);\n if (m.property) el.setAttribute('property', m.property);\n el.setAttribute('content', m.content || '');\n document.head.appendChild(el);\n }\n }\n // Process link tags\n var links = config.link || config.links || [];\n for (var j = 0; j < links.length; j++) {\n var l = links[j];\n if (!l.rel || !l.href) continue;\n var linkSel = 'link[rel=\"' + l.rel + '\"][href=\"' + l.href + '\"]';\n if (!document.querySelector(linkSel)) {\n var le = document.createElement('link');\n for (var k in l) { if (l.hasOwnProperty(k)) le.setAttribute(k, l[k]); }\n document.head.appendChild(le);\n }\n }\n // Script tags\n var scripts = config.script || config.scripts || [];\n for (var si = 0; si < scripts.length; si++) {\n var s = scripts[si];\n var se = document.createElement('script');\n if (s.src) se.src = s.src;\n if (s.innerHTML) se.innerHTML = s.innerHTML;\n if (s.async) se.async = true;\n if (s.defer) se.defer = true;\n document.head.appendChild(se);\n }\n // Body class\n if (config.bodyAttrs && config.bodyAttrs.class) {\n config.bodyAttrs.class.split(' ').forEach(function(cls) { if (cls) document.body.classList.add(cls); });\n }\n // Html attributes. Every key, not just lang \u2014 the module impl\n // (head.ts updateHead) has always applied all of them, and a root-level\n // class is the main reason to reach for htmlAttrs at all (#1798).\n // class merges rather than replaces, matching bodyAttrs.class above:\n // the color-mode boot script owns a class on this same element.\n if (config.htmlAttrs) {\n for (var hk in config.htmlAttrs) {\n if (!config.htmlAttrs.hasOwnProperty(hk)) continue;\n var hv = config.htmlAttrs[hk];\n if (hv == null) continue;\n if (hk === 'class') {\n String(hv).split(' ').forEach(function(cls) { if (cls) document.documentElement.classList.add(cls); });\n } else {\n document.documentElement.setAttribute(hk, hv);\n }\n }\n }\n }\n // Apply immediately if DOM is ready, otherwise on mount\n if (document.readyState !== 'loading') { apply(); }\n else { onMount(apply); }\n }\n\n function useSeoMeta(config) {\n var meta = [];\n if (config.title) meta.push({ name: 'title', content: config.title });\n if (config.description) meta.push({ name: 'description', content: config.description });\n if (config.ogTitle) meta.push({ property: 'og:title', content: config.ogTitle });\n if (config.ogDescription) meta.push({ property: 'og:description', content: config.ogDescription });\n if (config.ogImage) meta.push({ property: 'og:image', content: config.ogImage });\n if (config.ogType) meta.push({ property: 'og:type', content: config.ogType });\n if (config.ogUrl) meta.push({ property: 'og:url', content: config.ogUrl });\n if (config.twitterCard) meta.push({ name: 'twitter:card', content: config.twitterCard });\n if (config.twitterTitle) meta.push({ name: 'twitter:title', content: config.twitterTitle });\n if (config.twitterDescription) meta.push({ name: 'twitter:description', content: config.twitterDescription });\n if (config.twitterImage) meta.push({ name: 'twitter:image', content: config.twitterImage });\n if (config.robots) meta.push({ name: 'robots', content: config.robots });\n if (config.canonical) meta.push({ property: 'og:url', content: config.canonical });\n useHead({ title: config.title || config.ogTitle, meta: meta });\n }\n";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export const SIGNALS_HEAD_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Client-side useHead / useSeoMeta
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
function useHead(config) {
|
|
6
|
+
function apply() {
|
|
7
|
+
if (config.title) document.title = config.title;
|
|
8
|
+
// Process meta tags
|
|
9
|
+
var metas = config.meta || [];
|
|
10
|
+
for (var i = 0; i < metas.length; i++) {
|
|
11
|
+
var m = metas[i];
|
|
12
|
+
if (!m.name && !m.property) continue;
|
|
13
|
+
var selector = m.name ? 'meta[name="' + m.name + '"]' : 'meta[property="' + m.property + '"]';
|
|
14
|
+
var el = document.querySelector(selector);
|
|
15
|
+
if (el) {
|
|
16
|
+
el.setAttribute('content', m.content || '');
|
|
17
|
+
} else {
|
|
18
|
+
el = document.createElement('meta');
|
|
19
|
+
if (m.name) el.setAttribute('name', m.name);
|
|
20
|
+
if (m.property) el.setAttribute('property', m.property);
|
|
21
|
+
el.setAttribute('content', m.content || '');
|
|
22
|
+
document.head.appendChild(el);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Process link tags
|
|
26
|
+
var links = config.link || config.links || [];
|
|
27
|
+
for (var j = 0; j < links.length; j++) {
|
|
28
|
+
var l = links[j];
|
|
29
|
+
if (!l.rel || !l.href) continue;
|
|
30
|
+
var linkSel = 'link[rel="' + l.rel + '"][href="' + l.href + '"]';
|
|
31
|
+
if (!document.querySelector(linkSel)) {
|
|
32
|
+
var le = document.createElement('link');
|
|
33
|
+
for (var k in l) { if (l.hasOwnProperty(k)) le.setAttribute(k, l[k]); }
|
|
34
|
+
document.head.appendChild(le);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Script tags
|
|
38
|
+
var scripts = config.script || config.scripts || [];
|
|
39
|
+
for (var si = 0; si < scripts.length; si++) {
|
|
40
|
+
var s = scripts[si];
|
|
41
|
+
var se = document.createElement('script');
|
|
42
|
+
if (s.src) se.src = s.src;
|
|
43
|
+
if (s.innerHTML) se.innerHTML = s.innerHTML;
|
|
44
|
+
if (s.async) se.async = true;
|
|
45
|
+
if (s.defer) se.defer = true;
|
|
46
|
+
document.head.appendChild(se);
|
|
47
|
+
}
|
|
48
|
+
// Body class
|
|
49
|
+
if (config.bodyAttrs && config.bodyAttrs.class) {
|
|
50
|
+
config.bodyAttrs.class.split(' ').forEach(function(cls) { if (cls) document.body.classList.add(cls); });
|
|
51
|
+
}
|
|
52
|
+
// Html attributes. Every key, not just lang \u2014 the module impl
|
|
53
|
+
// (head.ts updateHead) has always applied all of them, and a root-level
|
|
54
|
+
// class is the main reason to reach for htmlAttrs at all (#1798).
|
|
55
|
+
// class merges rather than replaces, matching bodyAttrs.class above:
|
|
56
|
+
// the color-mode boot script owns a class on this same element.
|
|
57
|
+
if (config.htmlAttrs) {
|
|
58
|
+
for (var hk in config.htmlAttrs) {
|
|
59
|
+
if (!config.htmlAttrs.hasOwnProperty(hk)) continue;
|
|
60
|
+
var hv = config.htmlAttrs[hk];
|
|
61
|
+
if (hv == null) continue;
|
|
62
|
+
if (hk === 'class') {
|
|
63
|
+
String(hv).split(' ').forEach(function(cls) { if (cls) document.documentElement.classList.add(cls); });
|
|
64
|
+
} else {
|
|
65
|
+
document.documentElement.setAttribute(hk, hv);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Apply immediately if DOM is ready, otherwise on mount
|
|
71
|
+
if (document.readyState !== 'loading') { apply(); }
|
|
72
|
+
else { onMount(apply); }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function useSeoMeta(config) {
|
|
76
|
+
var meta = [];
|
|
77
|
+
if (config.title) meta.push({ name: 'title', content: config.title });
|
|
78
|
+
if (config.description) meta.push({ name: 'description', content: config.description });
|
|
79
|
+
if (config.ogTitle) meta.push({ property: 'og:title', content: config.ogTitle });
|
|
80
|
+
if (config.ogDescription) meta.push({ property: 'og:description', content: config.ogDescription });
|
|
81
|
+
if (config.ogImage) meta.push({ property: 'og:image', content: config.ogImage });
|
|
82
|
+
if (config.ogType) meta.push({ property: 'og:type', content: config.ogType });
|
|
83
|
+
if (config.ogUrl) meta.push({ property: 'og:url', content: config.ogUrl });
|
|
84
|
+
if (config.twitterCard) meta.push({ name: 'twitter:card', content: config.twitterCard });
|
|
85
|
+
if (config.twitterTitle) meta.push({ name: 'twitter:title', content: config.twitterTitle });
|
|
86
|
+
if (config.twitterDescription) meta.push({ name: 'twitter:description', content: config.twitterDescription });
|
|
87
|
+
if (config.twitterImage) meta.push({ name: 'twitter:image', content: config.twitterImage });
|
|
88
|
+
if (config.robots) meta.push({ name: 'robots', content: config.robots });
|
|
89
|
+
if (config.canonical) meta.push({ property: 'og:url', content: config.canonical });
|
|
90
|
+
useHead({ title: config.title || config.ogTitle, meta: meta });
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Formatting helpers and object dependency tracking used by client bindings. */
|
|
2
|
+
export declare const SIGNALS_HELPERS_RUNTIME = " // ==========================================================================\n // Global Helpers (Feature #5)\n // ==========================================================================\n\n const globalHelpers = {\n // Number formatting\n fmt(n) {\n if (n == null) return '0';\n n = Number(n);\n if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';\n if (n >= 1000) return (n / 1000).toFixed(1) + 'K';\n return String(n);\n },\n\n // Date formatting\n formatDate(date, format = 'YYYY-MM-DD') {\n if (!date) return '';\n const d = date instanceof Date ? date : new Date(date);\n if (isNaN(d.getTime())) return '';\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n const hours = String(d.getHours()).padStart(2, '0');\n const minutes = String(d.getMinutes()).padStart(2, '0');\n const seconds = String(d.getSeconds()).padStart(2, '0');\n return format\n .replace('YYYY', year)\n .replace('MM', month)\n .replace('DD', day)\n .replace('HH', hours)\n .replace('mm', minutes)\n .replace('ss', seconds);\n },\n\n // Time ago formatting\n timeAgo(date) {\n if (!date) return '';\n const d = date instanceof Date ? date : new Date(date);\n const now = new Date();\n const seconds = Math.floor((now - d) / 1000);\n if (seconds < 60) return 'just now';\n if (seconds < 3600) return Math.floor(seconds / 60) + 'm ago';\n if (seconds < 86400) return Math.floor(seconds / 3600) + 'h ago';\n if (seconds < 604800) return Math.floor(seconds / 86400) + 'd ago';\n return d.toLocaleDateString();\n },\n\n // Debounce function\n debounce(fn, delay = 300) {\n let timeout;\n return function(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => fn.apply(this, args), delay);\n };\n },\n\n // Throttle function\n throttle(fn, limit = 300) {\n let inThrottle;\n return function(...args) {\n if (!inThrottle) {\n fn.apply(this, args);\n inThrottle = true;\n setTimeout(() => inThrottle = false, limit);\n }\n };\n },\n\n // Capitalize first letter\n capitalize(str) {\n if (!str) return '';\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n\n // Truncate string\n truncate(str, length = 50, suffix = '...') {\n if (!str || str.length <= length) return str || '';\n return str.slice(0, length) + suffix;\n },\n\n // JSON stringify (safe)\n json(value, indent = 2) {\n try {\n return JSON.stringify(value, null, indent);\n }\ncatch (e) {\n return String(value);\n }\n },\n\n // Pluralize\n pluralize(count, singular, plural) {\n const p = plural || singular + 's';\n return count === 1 ? singular : p;\n },\n\n // Clamp number\n clamp(value, min, max) {\n return Math.min(Math.max(value, min), max);\n },\n\n // Currency formatting\n currency(value, symbol = '$', decimals = 2) {\n if (value == null) return symbol + '0.00';\n return symbol + Number(value).toFixed(decimals).replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n },\n\n // Percentage formatting\n percent(value, decimals = 0) {\n if (value == null) return '0%';\n return (Number(value) * 100).toFixed(decimals) + '%';\n }\n };\n\n function track(target, key) {\n if (!activeEffect) return;\n let depsMap = targetMap.get(target);\n if (!depsMap) targetMap.set(target, (depsMap = new Map()));\n let deps = depsMap.get(key);\n if (!deps) depsMap.set(key, (deps = new Set()));\n deps.add(activeEffect);\n }\n\n function trigger(target, key) {\n const depsMap = targetMap.get(target);\n if (!depsMap) return;\n const deps = depsMap.get(key);\n if (deps) {\n if (isBatching) {\n deps.forEach(effect => pendingEffects.add(effect));\n }\nelse {\n deps.forEach(effect => effect());\n }\n }\n }\n";
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export const SIGNALS_HELPERS_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Global Helpers (Feature #5)
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
const globalHelpers = {
|
|
6
|
+
// Number formatting
|
|
7
|
+
fmt(n) {
|
|
8
|
+
if (n == null) return '0';
|
|
9
|
+
n = Number(n);
|
|
10
|
+
if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';
|
|
11
|
+
if (n >= 1000) return (n / 1000).toFixed(1) + 'K';
|
|
12
|
+
return String(n);
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// Date formatting
|
|
16
|
+
formatDate(date, format = 'YYYY-MM-DD') {
|
|
17
|
+
if (!date) return '';
|
|
18
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
19
|
+
if (isNaN(d.getTime())) return '';
|
|
20
|
+
const year = d.getFullYear();
|
|
21
|
+
const month = String(d.getMonth() + 1).padStart(2, '0');
|
|
22
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
23
|
+
const hours = String(d.getHours()).padStart(2, '0');
|
|
24
|
+
const minutes = String(d.getMinutes()).padStart(2, '0');
|
|
25
|
+
const seconds = String(d.getSeconds()).padStart(2, '0');
|
|
26
|
+
return format
|
|
27
|
+
.replace('YYYY', year)
|
|
28
|
+
.replace('MM', month)
|
|
29
|
+
.replace('DD', day)
|
|
30
|
+
.replace('HH', hours)
|
|
31
|
+
.replace('mm', minutes)
|
|
32
|
+
.replace('ss', seconds);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Time ago formatting
|
|
36
|
+
timeAgo(date) {
|
|
37
|
+
if (!date) return '';
|
|
38
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
39
|
+
const now = new Date();
|
|
40
|
+
const seconds = Math.floor((now - d) / 1000);
|
|
41
|
+
if (seconds < 60) return 'just now';
|
|
42
|
+
if (seconds < 3600) return Math.floor(seconds / 60) + 'm ago';
|
|
43
|
+
if (seconds < 86400) return Math.floor(seconds / 3600) + 'h ago';
|
|
44
|
+
if (seconds < 604800) return Math.floor(seconds / 86400) + 'd ago';
|
|
45
|
+
return d.toLocaleDateString();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// Debounce function
|
|
49
|
+
debounce(fn, delay = 300) {
|
|
50
|
+
let timeout;
|
|
51
|
+
return function(...args) {
|
|
52
|
+
clearTimeout(timeout);
|
|
53
|
+
timeout = setTimeout(() => fn.apply(this, args), delay);
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// Throttle function
|
|
58
|
+
throttle(fn, limit = 300) {
|
|
59
|
+
let inThrottle;
|
|
60
|
+
return function(...args) {
|
|
61
|
+
if (!inThrottle) {
|
|
62
|
+
fn.apply(this, args);
|
|
63
|
+
inThrottle = true;
|
|
64
|
+
setTimeout(() => inThrottle = false, limit);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Capitalize first letter
|
|
70
|
+
capitalize(str) {
|
|
71
|
+
if (!str) return '';
|
|
72
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// Truncate string
|
|
76
|
+
truncate(str, length = 50, suffix = '...') {
|
|
77
|
+
if (!str || str.length <= length) return str || '';
|
|
78
|
+
return str.slice(0, length) + suffix;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// JSON stringify (safe)
|
|
82
|
+
json(value, indent = 2) {
|
|
83
|
+
try {
|
|
84
|
+
return JSON.stringify(value, null, indent);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
return String(value);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Pluralize
|
|
92
|
+
pluralize(count, singular, plural) {
|
|
93
|
+
const p = plural || singular + 's';
|
|
94
|
+
return count === 1 ? singular : p;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Clamp number
|
|
98
|
+
clamp(value, min, max) {
|
|
99
|
+
return Math.min(Math.max(value, min), max);
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Currency formatting
|
|
103
|
+
currency(value, symbol = '$', decimals = 2) {
|
|
104
|
+
if (value == null) return symbol + '0.00';
|
|
105
|
+
return symbol + Number(value).toFixed(decimals).replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// Percentage formatting
|
|
109
|
+
percent(value, decimals = 0) {
|
|
110
|
+
if (value == null) return '0%';
|
|
111
|
+
return (Number(value) * 100).toFixed(decimals) + '%';
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
function track(target, key) {
|
|
116
|
+
if (!activeEffect) return;
|
|
117
|
+
let depsMap = targetMap.get(target);
|
|
118
|
+
if (!depsMap) targetMap.set(target, (depsMap = new Map()));
|
|
119
|
+
let deps = depsMap.get(key);
|
|
120
|
+
if (!deps) depsMap.set(key, (deps = new Set()));
|
|
121
|
+
deps.add(activeEffect);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function trigger(target, key) {
|
|
125
|
+
const depsMap = targetMap.get(target);
|
|
126
|
+
if (!depsMap) return;
|
|
127
|
+
const deps = depsMap.get(key);
|
|
128
|
+
if (deps) {
|
|
129
|
+
if (isBatching) {
|
|
130
|
+
deps.forEach(effect => pendingEffects.add(effect));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
deps.forEach(effect => effect());
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default browser host used by the generated signals runtime.
|
|
3
|
+
*
|
|
4
|
+
* Keeping this as source text lets the same binding runtime swap in a native
|
|
5
|
+
* host through `window.__stx_host` without coupling reactive primitives to the
|
|
6
|
+
* DOM. The leading indentation and trailing blank line are intentional: this
|
|
7
|
+
* fragment is interpolated directly into the generated runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SIGNALS_HOST_RUNTIME = " // \u2500\u2500 Host \u2500\u2500\n //\n // The tree this runtime mutates. Every write the binding layer makes to a\n // node goes through here, so the same runtime can drive something that is not\n // the document -- native views over a bridge (stacksjs/stx#1984).\n //\n // Signals never touch a node, so nothing above this line needs to change; the\n // coupling is entirely in the bind layer. A host is swapped in by assigning\n // window.__stx_host before the runtime executes. The name is stxHost, not\n // host, because the runtime already calls two local DOM nodes host -- a\n // shadowed adapter fails as node.anchor is not a function, deep inside a\n // branch swap, and nowhere near the line that caused it, which keeps the web path\n // exactly as it was: same calls, one property lookup earlier.\n var stxHost = window.__stx_host || {\n setText: function(node, value) { node.textContent = value; },\n setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },\n setAttribute: function(node, name, value) {\n if (value === false) { node.removeAttribute(name); return; }\n if (value === true) { node.setAttribute(name, ''); return; }\n var next = value;\n if (typeof value === 'object' && value !== null) {\n try { next = JSON.stringify(value); }\n catch (e) { next = String(value); }\n }\n node.setAttribute(name, next);\n },\n removeAttribute: function(node, name) { node.removeAttribute(name); },\n setStyle: function(node, value) {\n if (typeof value === 'object' && value !== null) {\n Object.assign(node.style, value);\n if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';\n }\n else if (typeof value === 'string') {\n node.style.cssText = value;\n node.__stx_display = node.style.display || '';\n }\n // Reactive style updates must not clear the display:none owned by :show.\n // This also keeps the latest explicit display for when the gate opens.\n if (node.__stx_visible === false) node.style.display = 'none';\n },\n\n // Structural operations, for the bindings that build rows rather than\n // update one node (#1984).\n //\n // anchor() is a position in the child list that survives the nodes around\n // it moving -- a comment node here, since the document has one; a native\n // host keeps an index or a zero-size sentinel.\n //\n // clone() is the one that does not carry over as-is: a DOM subtree can be\n // deep-copied, a native view hierarchy cannot. A native host materialises a\n // fresh subtree from the template it was given instead of copying views,\n // which is why the row template is passed rather than a node to duplicate.\n // A native host registers the handler against the view and has the platform\n // call it; nothing about the binding layer changes, which is the point.\n // The options argument carries passive/capture/once. A native host has no use for\n // passive -- there is no scroll thread to block -- but dropping the\n // parameter silently makes every touch listener blocking again, so it stays\n // in the signature and each host decides what to do with it.\n listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },\n\n // Returns the PREVIOUS visibility. bindShow needs to know whether it just\n // revealed something, and asking the node afterwards is the one read-back\n // in the binding layer -- a native host cannot answer what a UIView's\n // display value was, because it has none. A write that reports what it\n // replaced removes the question: the DOM host reads its own style, a native\n // host reads isHidden, and the binder reads neither.\n //\n // Restoring an explicit display (a flex row, an inline-block) is the host's\n // business too; it records it the first time it hides the node.\n // The scope root a node belongs to: nearest ancestor-or-self that owns a\n // scope, or null. Three binding paths need it -- ref ownership, and an\n // if-chain finding the scope its branch belongs to.\n //\n // Not a query method. A host is never handed a selector, because a native\n // view tree has nothing to match one against: the DOM host walks with\n // closest(), a native host reads the node-to-scope map it maintains as it\n // creates views. The from flag skips the node itself, which the ref path needs\n // when it walks outward past a receiver it has already rejected.\n scopeOf: function(node, from) {\n var start = from ? (node && node.parentElement) : node;\n return (start && start.closest) ? start.closest('[data-stx-scope]') : null;\n },\n\n setVisible: function(node, visible) {\n if (node.__stx_display === undefined) {\n var d = node.style.display;\n node.__stx_display = (d && d !== 'none') ? d : '';\n }\n var was = node.style.display !== 'none';\n node.__stx_visible = visible;\n node.style.display = visible ? node.__stx_display : 'none';\n return was;\n },\n\n anchor: function(label) { return document.createComment(label); },\n clone: function(node) { return node.cloneNode(true); },\n insert: function(parent, node, before) { parent.insertBefore(node, before); },\n remove: function(node) { if (node.parentNode) node.parentNode.removeChild(node); },\n\n // Teardown needs to reach a subtree, and both ways of reaching one were\n // selector queries -- the last DOM assumption left in the binding layer\n // (#1984). A view hierarchy has no selectors, and a native host already\n // knows what it built, so being asked is cheaper for it than searching is\n // for the document.\n //\n // descendants() is every node under this one, for the per-node teardown\n // state the runtime hangs off elements. scopesIn() is the scope IDS in the\n // subtree, this node included -- ids and not nodes, because the only thing\n // done with them is a lookup in window.stx._scopes.\n descendants: function(node) {\n var out = [];\n if (!node || !node.querySelectorAll) return out;\n var all = node.querySelectorAll('*');\n for (var i = 0; i < all.length; i++) out.push(all[i]);\n return out;\n },\n scopesIn: function(node) {\n var ids = [];\n if (!node) return ids;\n var own = node.getAttribute && node.getAttribute('data-stx-scope');\n if (own) ids.push(own);\n if (node.querySelectorAll) {\n var matches = node.querySelectorAll('[data-stx-scope]');\n for (var i = 0; i < matches.length; i++) {\n var id = matches[i].getAttribute('data-stx-scope');\n if (id) ids.push(id);\n }\n }\n return ids;\n }\n };\n";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
|
|
2
|
+
//
|
|
3
|
+
// The tree this runtime mutates. Every write the binding layer makes to a
|
|
4
|
+
// node goes through here, so the same runtime can drive something that is not
|
|
5
|
+
// the document -- native views over a bridge (stacksjs/stx#1984).
|
|
6
|
+
//
|
|
7
|
+
// Signals never touch a node, so nothing above this line needs to change; the
|
|
8
|
+
// coupling is entirely in the bind layer. A host is swapped in by assigning
|
|
9
|
+
// window.__stx_host before the runtime executes. The name is stxHost, not
|
|
10
|
+
// host, because the runtime already calls two local DOM nodes host -- a
|
|
11
|
+
// shadowed adapter fails as node.anchor is not a function, deep inside a
|
|
12
|
+
// branch swap, and nowhere near the line that caused it, which keeps the web path
|
|
13
|
+
// exactly as it was: same calls, one property lookup earlier.
|
|
14
|
+
var stxHost = window.__stx_host || {
|
|
15
|
+
setText: function(node, value) { node.textContent = value; },
|
|
16
|
+
setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },
|
|
17
|
+
setAttribute: function(node, name, value) {
|
|
18
|
+
if (value === false) { node.removeAttribute(name); return; }
|
|
19
|
+
if (value === true) { node.setAttribute(name, ''); return; }
|
|
20
|
+
var next = value;
|
|
21
|
+
if (typeof value === 'object' && value !== null) {
|
|
22
|
+
try { next = JSON.stringify(value); }
|
|
23
|
+
catch (e) { next = String(value); }
|
|
24
|
+
}
|
|
25
|
+
node.setAttribute(name, next);
|
|
26
|
+
},
|
|
27
|
+
removeAttribute: function(node, name) { node.removeAttribute(name); },
|
|
28
|
+
setStyle: function(node, value) {
|
|
29
|
+
if (typeof value === 'object' && value !== null) {
|
|
30
|
+
Object.assign(node.style, value);
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';
|
|
32
|
+
}
|
|
33
|
+
else if (typeof value === 'string') {
|
|
34
|
+
node.style.cssText = value;
|
|
35
|
+
node.__stx_display = node.style.display || '';
|
|
36
|
+
}
|
|
37
|
+
// Reactive style updates must not clear the display:none owned by :show.
|
|
38
|
+
// This also keeps the latest explicit display for when the gate opens.
|
|
39
|
+
if (node.__stx_visible === false) node.style.display = 'none';
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Structural operations, for the bindings that build rows rather than
|
|
43
|
+
// update one node (#1984).
|
|
44
|
+
//
|
|
45
|
+
// anchor() is a position in the child list that survives the nodes around
|
|
46
|
+
// it moving -- a comment node here, since the document has one; a native
|
|
47
|
+
// host keeps an index or a zero-size sentinel.
|
|
48
|
+
//
|
|
49
|
+
// clone() is the one that does not carry over as-is: a DOM subtree can be
|
|
50
|
+
// deep-copied, a native view hierarchy cannot. A native host materialises a
|
|
51
|
+
// fresh subtree from the template it was given instead of copying views,
|
|
52
|
+
// which is why the row template is passed rather than a node to duplicate.
|
|
53
|
+
// A native host registers the handler against the view and has the platform
|
|
54
|
+
// call it; nothing about the binding layer changes, which is the point.
|
|
55
|
+
// The options argument carries passive/capture/once. A native host has no use for
|
|
56
|
+
// passive -- there is no scroll thread to block -- but dropping the
|
|
57
|
+
// parameter silently makes every touch listener blocking again, so it stays
|
|
58
|
+
// in the signature and each host decides what to do with it.
|
|
59
|
+
listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },
|
|
60
|
+
|
|
61
|
+
// Returns the PREVIOUS visibility. bindShow needs to know whether it just
|
|
62
|
+
// revealed something, and asking the node afterwards is the one read-back
|
|
63
|
+
// in the binding layer -- a native host cannot answer what a UIView's
|
|
64
|
+
// display value was, because it has none. A write that reports what it
|
|
65
|
+
// replaced removes the question: the DOM host reads its own style, a native
|
|
66
|
+
// host reads isHidden, and the binder reads neither.
|
|
67
|
+
//
|
|
68
|
+
// Restoring an explicit display (a flex row, an inline-block) is the host's
|
|
69
|
+
// business too; it records it the first time it hides the node.
|
|
70
|
+
// The scope root a node belongs to: nearest ancestor-or-self that owns a
|
|
71
|
+
// scope, or null. Three binding paths need it -- ref ownership, and an
|
|
72
|
+
// if-chain finding the scope its branch belongs to.
|
|
73
|
+
//
|
|
74
|
+
// Not a query method. A host is never handed a selector, because a native
|
|
75
|
+
// view tree has nothing to match one against: the DOM host walks with
|
|
76
|
+
// closest(), a native host reads the node-to-scope map it maintains as it
|
|
77
|
+
// creates views. The from flag skips the node itself, which the ref path needs
|
|
78
|
+
// when it walks outward past a receiver it has already rejected.
|
|
79
|
+
scopeOf: function(node, from) {
|
|
80
|
+
var start = from ? (node && node.parentElement) : node;
|
|
81
|
+
return (start && start.closest) ? start.closest('[data-stx-scope]') : null;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
setVisible: function(node, visible) {
|
|
85
|
+
if (node.__stx_display === undefined) {
|
|
86
|
+
var d = node.style.display;
|
|
87
|
+
node.__stx_display = (d && d !== 'none') ? d : '';
|
|
88
|
+
}
|
|
89
|
+
var was = node.style.display !== 'none';
|
|
90
|
+
node.__stx_visible = visible;
|
|
91
|
+
node.style.display = visible ? node.__stx_display : 'none';
|
|
92
|
+
return was;
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
anchor: function(label) { return document.createComment(label); },
|
|
96
|
+
clone: function(node) { return node.cloneNode(true); },
|
|
97
|
+
insert: function(parent, node, before) { parent.insertBefore(node, before); },
|
|
98
|
+
remove: function(node) { if (node.parentNode) node.parentNode.removeChild(node); },
|
|
99
|
+
|
|
100
|
+
// Teardown needs to reach a subtree, and both ways of reaching one were
|
|
101
|
+
// selector queries -- the last DOM assumption left in the binding layer
|
|
102
|
+
// (#1984). A view hierarchy has no selectors, and a native host already
|
|
103
|
+
// knows what it built, so being asked is cheaper for it than searching is
|
|
104
|
+
// for the document.
|
|
105
|
+
//
|
|
106
|
+
// descendants() is every node under this one, for the per-node teardown
|
|
107
|
+
// state the runtime hangs off elements. scopesIn() is the scope IDS in the
|
|
108
|
+
// subtree, this node included -- ids and not nodes, because the only thing
|
|
109
|
+
// done with them is a lookup in window.stx._scopes.
|
|
110
|
+
descendants: function(node) {
|
|
111
|
+
var out = [];
|
|
112
|
+
if (!node || !node.querySelectorAll) return out;
|
|
113
|
+
var all = node.querySelectorAll('*');
|
|
114
|
+
for (var i = 0; i < all.length; i++) out.push(all[i]);
|
|
115
|
+
return out;
|
|
116
|
+
},
|
|
117
|
+
scopesIn: function(node) {
|
|
118
|
+
var ids = [];
|
|
119
|
+
if (!node) return ids;
|
|
120
|
+
var own = node.getAttribute && node.getAttribute('data-stx-scope');
|
|
121
|
+
if (own) ids.push(own);
|
|
122
|
+
if (node.querySelectorAll) {
|
|
123
|
+
var matches = node.querySelectorAll('[data-stx-scope]');
|
|
124
|
+
for (var i = 0; i < matches.length; i++) {
|
|
125
|
+
var id = matches[i].getAttribute('data-stx-scope');
|
|
126
|
+
if (id) ids.push(id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return ids;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Post-hydration diagnostics used by the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_HYDRATION_AUDIT_RUNTIME = " // ==========================================================================\n // Post-hydration invariant sweep (stacksjs/stx#1773)\n // ==========================================================================\n //\n // Preserved moustaches are the framework's de-facto error UI: ANY failure in\n // the detect \u2192 extract \u2192 bundle \u2192 ship \u2192 rebind relay collapses into the same\n // visible symptom, literal {{ }} on screen. Eight separate fixes each patched\n // one site's heuristic, and no invariant anywhere asserted the actual\n // requirement \u2014 zero unhydrated scopes after hydration. So every new upstream\n // miss reached users silently and had to be diagnosed from a screenshot.\n //\n // This is that invariant. It runs at the end of both hydration entry points\n // and turns a silent miss into one loud, self-healing event:\n //\n // - an element carrying data-stx-scope whose id isn't in the registry, or\n // that hydration reached but never processed, is reported AND processed\n // with the ambient scope, which is what the walk would have done had the\n // script arrived. That recovers the D2/D3 shapes (a silent early return\n // in the walk, a stale __stx_scope guard) rather than merely naming them.\n // - leftover {{ }} text is reported. Diagnostic only, never auto-fixed:\n // without a scope there is nothing to interpolate against, and a page may\n // legitimately print moustaches.\n //\n // Deliberately quiet in the normal case: nothing is logged when the page has\n // no signals at all, and containers that legitimately show template syntax\n // (<pre>, <code>, <template>, <script>, <style>, <textarea>, and anything\n // under [data-stx-ignore]) are skipped.\n\n var AUDIT_SKIP_TAGS = { PRE: 1, CODE: 1, SCRIPT: 1, STYLE: 1, TEXTAREA: 1, TEMPLATE: 1 };\n\n // Expressions whose evaluation threw a ReferenceError/TypeError and have not\n // since succeeded. evalAttrExpr swallows those two on purpose \u2014 a signal may\n // not exist yet on an effect's first pass \u2014 which is why a genuinely broken\n // binding produces no diagnostic at all today. The classic case is\n // :if=\"flag()\" where flag is a signal: the auto-unwrap proxy returns the\n // VALUE, calling it throws TypeError, the directive suppresses it, and the\n // element silently stays hidden with no warning anywhere (see CLAUDE.md,\n // \"Signals: scripts call, templates don't\").\n //\n // Recording rather than warning immediately is what keeps this quiet on\n // working pages: a first-pass failure that later succeeds clears itself, so\n // only expressions still broken when hydration finishes are reported.\n var _exprFailures = {};\n var _exprFailureCount = 0;\n\n function noteExprFailure(expr, err) {\n if (_exprFailures[expr] !== undefined) return;\n // Bounded: one runaway loop must not grow this without limit.\n if (_exprFailureCount >= 50) return;\n _exprFailureCount++;\n _exprFailures[expr] = (err && err.message) ? err.message : String(err);\n }\n\n function noteExprSuccess(expr) {\n if (_exprFailures[expr] === undefined) return;\n delete _exprFailures[expr];\n _exprFailureCount--;\n }\n\n function auditSkipped(node) {\n // Not rendered, not audited. Covers <template> content (a detached\n // DocumentFragment \u2014 which some DOM implementations still walk into) and\n // :if branches parked off-document, neither of which the user can see.\n if (node.isConnected === false) return true;\n for (var p = node.parentNode; p; p = p.parentNode) {\n if (p.nodeType === Node.DOCUMENT_FRAGMENT_NODE) return true;\n if (p.nodeType !== Node.ELEMENT_NODE) continue;\n if (AUDIT_SKIP_TAGS[p.tagName]) return true;\n if (p.hasAttribute && p.hasAttribute('data-stx-ignore')) return true;\n // A :if whose deferred child-binding pass hasn't run yet legitimately holds\n // literal {{ }} that binds a macrotask later \u2014 not a hydration miss (#1773).\n if (p.__stx_if_pending) return true;\n // A deferred island (client=visible|idle|\u2026) is unhydrated ON PURPOSE until\n // its trigger fires, so its {{ }} legitimately stay literal in the meantime\n // \u2014 not a miss (#1746). The stranded-scope pass already skips stx-hydrate;\n // the literal sweep must too.\n if (p.hasAttribute && p.hasAttribute('stx-hydrate') && !p.__stx_hydrated) return true;\n }\n return false;\n }\n\n // Whether the element is, or sits inside, a structural directive's source that has\n // not bound yet. Binding replaces the source with a marker and a template,\n // so a :for / :if still on an element in the document has yet to run.\n var UNBOUND_STRUCTURE = [':for', '@for', 'x-for', ':if', '@if', 'x-if', ':else-if', '@else-if', 'x-else-if', ':else', '@else', 'x-else'];\n function inUnboundStructure(el) {\n for (var p = el; p && p.nodeType === Node.ELEMENT_NODE; p = p.parentElement) {\n for (var i = 0; i < UNBOUND_STRUCTURE.length; i++) {\n if (p.hasAttribute(UNBOUND_STRUCTURE[i])) return true;\n }\n }\n return false;\n }\n\n function findLiteralMoustaches(root) {\n var found = [];\n if (!root || typeof document.createTreeWalker !== 'function') return found;\n // Read NodeFilter off window, not the bare global: in a real browser they\n // are the same object, but some DOM implementations used for testing expose\n // it only on window, and a bare reference then throws inside the audit.\n var showText = (window.NodeFilter && window.NodeFilter.SHOW_TEXT) || 4;\n var walker = document.createTreeWalker(root, showText, null);\n var node;\n while ((node = walker.nextNode())) {\n // Browsers expose Text.nodeValue as a string, while lightweight DOM and\n // native embedding shims can preserve an assigned number. Diagnostics\n // must normalize the boundary instead of aborting the entire audit on a\n // missing String#indexOf method.\n var text = node.nodeValue == null ? '' : String(node.nodeValue);\n if (text.indexOf('{{') === -1 || text.indexOf('}}') === -1) continue;\n if (auditSkipped(node)) continue;\n found.push(text.trim().slice(0, 80));\n if (found.length >= 5) break;\n }\n return found;\n }\n\n // A diagnostic that can break hydration is worse than no diagnostic, so the\n // whole sweep is wrapped and every DOM capability it uses is feature-checked.\n // Minimal document stubs (tests, non-browser embeddings) simply skip it.\n function auditHydration(container, phase) {\n try { auditHydrationUnsafe(container, phase); }\n catch (e) { console.warn('[stx] hydration audit skipped:', e && e.message ? e.message : e); }\n }\n\n function auditHydrationUnsafe(container, phase) {\n if (!window.stx || !window.stx._scopes) return;\n var root = container && typeof container.querySelectorAll === 'function' ? container : document.body;\n if (!root || typeof root.querySelectorAll !== 'function') return;\n\n // Unregistered / unprocessed scopes \u2014 the unambiguous failure, and the one\n // worth repairing.\n var stranded = [];\n root.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n if (el.__stx_audit_recovered) return;\n // Deferred islands are unhydrated ON PURPOSE until their trigger fires.\n if (el.hasAttribute('stx-hydrate') || el.__stx_hydration_scheduled) return;\n // Inert markup is not a miss: a component inside a :if branch whose\n // deferred pass has not run, or inside a :for / :if source that has not\n // bound, is set up when it does, under its own clone's id. The literal\n // sweep already allowed for the first; recovering the second ran a\n // loop's source against the page's scope.\n if (auditSkipped(el) || inUnboundStructure(el)) return;\n var scopeId = el.getAttribute('data-stx-scope');\n var registered = window.stx._scopes[scopeId];\n if (registered && el.__stx_disposers) return;\n stranded.push({ el: el, id: scopeId, registered: !!registered });\n });\n\n if (stranded.length) {\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': '\n + stranded.length + ' scope(s) left unhydrated \u2014 '\n + stranded.map(function(s) {\n return s.id + (s.registered ? ' (registered, never processed)' : ' (not registered)');\n }).join(', ')\n + '. Recovering with the ambient scope; please report with the page that produced it (stacksjs/stx#1773).',\n );\n stranded.forEach(function(s) {\n // Once per element: a repair that itself fails must not loop on the\n // next navigation.\n s.el.__stx_audit_recovered = true;\n try {\n var vars = s.registered ? window.stx._scopes[s.id] : null;\n if (vars) Object.assign(componentScope, vars);\n s.el.__stx_disposers = trackEffects(function() { processElement(s.el, componentScope); });\n s.el.removeAttribute('x-cloak');\n s.el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n }\n catch (e) {\n console.error('[stx] hydration recovery failed for scope ' + s.id + ':', e);\n }\n });\n }\n\n var literals = findLiteralMoustaches(root);\n if (literals.length) {\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': literal {{ }} left in the DOM \u2014 '\n + literals.join(' | ')\n + '. An expression did not bind; see stacksjs/stx#1773. Wrap intentional '\n + 'template syntax in <pre>/<code> or [data-stx-ignore] to exclude it.',\n );\n }\n\n // Expressions that threw and never recovered. Reported here rather than at\n // throw time so a first-pass miss that later resolves stays silent.\n var brokenExprs = [];\n for (var expr in _exprFailures) {\n if (Object.prototype.hasOwnProperty.call(_exprFailures, expr))\n brokenExprs.push(expr + ' \u2192 ' + _exprFailures[expr]);\n }\n if (brokenExprs.length) {\n var hint = brokenExprs.some(function(m) { return m.indexOf('is not a function') !== -1; })\n ? ' If one of these calls a signal, drop the parentheses: templates read '\n + 'a signal by bare name (:if=\"flag\"), scripts call it (flag()). Calling '\n + 'the unwrapped value is a TypeError, which directives suppress \u2014 the '\n + 'element just stays hidden.'\n : '';\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': '\n + brokenExprs.length + ' expression(s) never evaluated \u2014 '\n + brokenExprs.slice(0, 5).join(' | ') + '.' + hint,\n );\n _exprFailures = {};\n _exprFailureCount = 0;\n }\n }\n";
|