@stacksjs/stx 0.2.532 → 0.2.534
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,352 @@
|
|
|
1
|
+
export const SIGNALS_OVERLAY_RUNTIME = ` // \u2500\u2500 Overlay stack \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2
|
+
//
|
|
3
|
+
// One stack for everything that takes over the page: stxAlert/stxConfirm,
|
|
4
|
+
// the runtime modal and drawer, @stacksjs/components' Dialog and Drawer, and
|
|
5
|
+
// anything an app draws itself (window.stx.overlays). Each of those used to
|
|
6
|
+
// keep its own listener, its own scroll lock and its own idea of whether it
|
|
7
|
+
// was on top, so with one open over another a single Escape closed both, two
|
|
8
|
+
// Tab traps fought over focus, and the first to close unlocked the page under
|
|
9
|
+
// the one still open (stacksjs/stx#2057; #1998 fixed the same thing for the
|
|
10
|
+
// confirm dialogs alone).
|
|
11
|
+
//
|
|
12
|
+
// Only the topmost overlay answers Escape and owns Tab. The page is locked
|
|
13
|
+
// from the first open to the last close. Focus moves into an overlay when it
|
|
14
|
+
// opens and back to whatever opened it when it closes.
|
|
15
|
+
//
|
|
16
|
+
// A popup - a menu, a listbox, a popover - goes on the same stack as a
|
|
17
|
+
// non-modal layer (modal: false). It takes Escape while it is on top, so one
|
|
18
|
+
// Escape inside a dialog closes the menu and leaves the dialog, but it does
|
|
19
|
+
// not lock the page, trap Tab or move focus: those follow the topmost MODAL
|
|
20
|
+
// layer. Each popup used to listen for Escape on the document itself, and
|
|
21
|
+
// whichever listener was registered first won.
|
|
22
|
+
var _overlays = [];
|
|
23
|
+
var _overlayScroll = null;
|
|
24
|
+
var _overlayInerted = [];
|
|
25
|
+
var _overlayListening = false;
|
|
26
|
+
var _OVERLAY_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
27
|
+
|
|
28
|
+
function _overlayTop() {
|
|
29
|
+
return _overlays.length ? _overlays[_overlays.length - 1] : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The layer that owns Tab and the page lock: the topmost modal one.
|
|
33
|
+
function _overlayTopModal() {
|
|
34
|
+
for (var i = _overlays.length - 1; i >= 0; i--) {
|
|
35
|
+
if (_overlays[i].modal) return _overlays[i];
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _overlayIndex(id) {
|
|
41
|
+
for (var i = 0; i < _overlays.length; i++) {
|
|
42
|
+
if (_overlays[i].id === id) return i;
|
|
43
|
+
}
|
|
44
|
+
return -1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The panel is asked for, not held: a component's panel may not be rendered
|
|
48
|
+
// yet on the frame it opens, and may be replaced while open.
|
|
49
|
+
function _overlayPanel(entry) {
|
|
50
|
+
var panel = entry && entry.panel;
|
|
51
|
+
try {
|
|
52
|
+
// A selector is looked up each time, like a function: the element it
|
|
53
|
+
// names may be rendered after the overlay opens, or replaced while open.
|
|
54
|
+
if (typeof panel === 'string') panel = document.querySelector(panel);
|
|
55
|
+
else if (typeof panel === 'function') panel = panel();
|
|
56
|
+
}
|
|
57
|
+
catch (_e) { panel = null; }
|
|
58
|
+
return panel || entry.root || null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _overlayShown(nodes) {
|
|
62
|
+
return Array.prototype.filter.call(nodes, function(el) {
|
|
63
|
+
return el.offsetParent !== null || el === document.activeElement;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _overlayFocusable(panel) {
|
|
68
|
+
return _overlayShown(panel.querySelectorAll(_OVERLAY_FOCUSABLE));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// One listener for every overlay, in the bubble phase: a widget inside an
|
|
72
|
+
// overlay that consumes Escape (a menu closing itself) calls preventDefault
|
|
73
|
+
// and the overlay leaves it alone.
|
|
74
|
+
function _overlayKey(e) {
|
|
75
|
+
var top = _overlayTop();
|
|
76
|
+
if (!top) return;
|
|
77
|
+
if (e.key === 'Escape') {
|
|
78
|
+
if (e.defaultPrevented || !top.onEscape) return;
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
top.onEscape();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (e.key !== 'Tab') return;
|
|
84
|
+
var trap = _overlayTopModal();
|
|
85
|
+
if (!trap) return;
|
|
86
|
+
var panel = _overlayPanel(trap);
|
|
87
|
+
if (!panel) return;
|
|
88
|
+
var items = _overlayFocusable(panel);
|
|
89
|
+
if (!items.length) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
if (panel.focus) panel.focus();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
var first = items[0];
|
|
95
|
+
var last = items[items.length - 1];
|
|
96
|
+
var active = document.activeElement;
|
|
97
|
+
if (!panel.contains(active)) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
(e.shiftKey ? last : first).focus();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (e.shiftKey && active === first) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
last.focus();
|
|
105
|
+
}
|
|
106
|
+
else if (!e.shiftKey && active === last) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
first.focus();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Lock, listen and inert to match the stack after any change.
|
|
113
|
+
function _overlaySync() {
|
|
114
|
+
for (var i = 0; i < _overlayInerted.length; i++) {
|
|
115
|
+
try { _overlayInerted[i].inert = false; }
|
|
116
|
+
catch (_e) { /* element may be gone */ }
|
|
117
|
+
}
|
|
118
|
+
_overlayInerted = [];
|
|
119
|
+
|
|
120
|
+
var top = _overlayTop();
|
|
121
|
+
var modal = _overlayTopModal();
|
|
122
|
+
if (!modal && _overlayScroll) {
|
|
123
|
+
document.body.style.overflow = _overlayScroll.body;
|
|
124
|
+
document.documentElement.style.overflow = _overlayScroll.html;
|
|
125
|
+
document.body.style.paddingRight = _overlayScroll.pad;
|
|
126
|
+
_overlayScroll = null;
|
|
127
|
+
}
|
|
128
|
+
if (!top) {
|
|
129
|
+
if (_overlayScroll) {
|
|
130
|
+
document.body.style.overflow = _overlayScroll.body;
|
|
131
|
+
document.documentElement.style.overflow = _overlayScroll.html;
|
|
132
|
+
document.body.style.paddingRight = _overlayScroll.pad;
|
|
133
|
+
_overlayScroll = null;
|
|
134
|
+
}
|
|
135
|
+
if (_overlayListening) {
|
|
136
|
+
document.removeEventListener('keydown', _overlayKey);
|
|
137
|
+
_overlayListening = false;
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (modal && !_overlayScroll) {
|
|
143
|
+
_overlayScroll = {
|
|
144
|
+
body: document.body.style.overflow,
|
|
145
|
+
html: document.documentElement.style.overflow,
|
|
146
|
+
pad: document.body.style.paddingRight
|
|
147
|
+
};
|
|
148
|
+
// The scrollbar's width comes back as padding, so the page does not jump
|
|
149
|
+
// sideways when it disappears.
|
|
150
|
+
var gap = window.innerWidth - document.documentElement.clientWidth;
|
|
151
|
+
if (gap > 0) {
|
|
152
|
+
var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;
|
|
153
|
+
document.body.style.paddingRight = (existing + gap) + 'px';
|
|
154
|
+
}
|
|
155
|
+
document.body.style.overflow = 'hidden';
|
|
156
|
+
document.documentElement.style.overflow = 'hidden';
|
|
157
|
+
}
|
|
158
|
+
if (!_overlayListening) {
|
|
159
|
+
document.addEventListener('keydown', _overlayKey);
|
|
160
|
+
_overlayListening = true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// An overlay given a z-index stacks by the order it opened in, not by
|
|
164
|
+
// where it sits in the document: one lifted into the body early (a sheet
|
|
165
|
+
// mounted before the sheet it later opens over) drew underneath. Set on
|
|
166
|
+
// every change, so what stays open closes up when one under it closes. A
|
|
167
|
+
// closed overlay keeps its last value, so it slides away above the one
|
|
168
|
+
// it was over.
|
|
169
|
+
for (var z = 0; z < _overlays.length; z++) {
|
|
170
|
+
var layer = _overlays[z];
|
|
171
|
+
if (typeof layer.zIndex === 'number' && layer.root && layer.root.style) layer.root.style.zIndex = String(layer.zIndex + z);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// inert, rather than aria-hidden, takes the page behind out of the tab
|
|
175
|
+
// order and the accessibility tree together (#1998). Only behind an
|
|
176
|
+
// overlay that is a child of the body element - one the runtime appended,
|
|
177
|
+
// or one an app lifted there - or one opened inside such an overlay (a
|
|
178
|
+
// dialog in a sheet's content). An overlay rendered inside the page's own
|
|
179
|
+
// markup would go inert with the page; its Tab trap is what holds it.
|
|
180
|
+
var root = _overlayInertRoot(modal);
|
|
181
|
+
if (root) {
|
|
182
|
+
var kids = document.body.children;
|
|
183
|
+
for (var k = 0; k < kids.length; k++) {
|
|
184
|
+
var kid = kids[k];
|
|
185
|
+
if (kid === root || kid.inert) continue;
|
|
186
|
+
try {
|
|
187
|
+
kid.inert = true;
|
|
188
|
+
_overlayInerted.push(kid);
|
|
189
|
+
}
|
|
190
|
+
catch (_e) { /* inert unsupported; the Tab trap still holds */ }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// The child of the body that keeps the rest of the page inert while this
|
|
196
|
+
// modal layer is on top: its own root when that is in the body, or the
|
|
197
|
+
// root of the open overlay it sits inside. A dialog opened from a sheet's
|
|
198
|
+
// content is not itself in the body, and the page behind the sheet used to
|
|
199
|
+
// come back to the keyboard and screen readers while it was up.
|
|
200
|
+
function _overlayInertRoot(modal) {
|
|
201
|
+
if (!modal) return null;
|
|
202
|
+
var el = modal.root || _overlayPanel(modal);
|
|
203
|
+
while (el && el.parentNode && el.parentNode !== document.body) el = el.parentNode;
|
|
204
|
+
if (!el || el.parentNode !== document.body) return null;
|
|
205
|
+
if (el === modal.root) return el;
|
|
206
|
+
for (var i = 0; i < _overlays.length; i++) {
|
|
207
|
+
if (_overlays[i] !== modal && _overlays[i].root === el) return el;
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// The next chance to act, whichever comes first: rAF is suspended in a
|
|
213
|
+
// background tab, so a timer races it.
|
|
214
|
+
function _overlaySoon(callback) {
|
|
215
|
+
var done = false;
|
|
216
|
+
var once = function() {
|
|
217
|
+
if (done) return;
|
|
218
|
+
done = true;
|
|
219
|
+
callback();
|
|
220
|
+
};
|
|
221
|
+
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(once);
|
|
222
|
+
setTimeout(once, 32);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Retried, because focus() on an element that is not displayed yet is a
|
|
226
|
+
// silent no-op. Stops once the overlay has closed.
|
|
227
|
+
function _overlayFocusIn(entry, attempts) {
|
|
228
|
+
if (_overlayIndex(entry.id) === -1) return;
|
|
229
|
+
var target = null;
|
|
230
|
+
try { target = typeof entry.initialFocus === 'function' ? entry.initialFocus() : entry.initialFocus; }
|
|
231
|
+
catch (_e) { target = null; }
|
|
232
|
+
var panel = _overlayPanel(entry);
|
|
233
|
+
// An [autofocus] that is not shown (behind a :show, a player in a
|
|
234
|
+
// dialog that is showing something else) cannot take focus: skipped, or
|
|
235
|
+
// focus went nowhere and the panel's first control never got it.
|
|
236
|
+
if (!target && panel) target = _overlayShown(panel.querySelectorAll('[autofocus]'))[0] || _overlayFocusable(panel)[0] || panel;
|
|
237
|
+
if (target && target.focus) target.focus();
|
|
238
|
+
if (target && document.activeElement === target) return;
|
|
239
|
+
if (attempts > 0) _overlaySoon(function() { _overlayFocusIn(entry, attempts - 1); });
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
var overlays = {
|
|
243
|
+
/**
|
|
244
|
+
* Put an overlay on top. Calling it again for an open id updates its
|
|
245
|
+
* options and nothing else, so it is safe from an effect that re-runs.
|
|
246
|
+
*
|
|
247
|
+
* options: modal (default true; false for a popup, which takes Escape
|
|
248
|
+
* while on top but does not lock, trap or move focus), panel (an element,
|
|
249
|
+
* a selector, or a function returning one; focus stays inside it), root (the overlay's outermost element, if it is not the panel),
|
|
250
|
+
* zIndex (a base: the root's z-index becomes it plus the overlay's place
|
|
251
|
+
* in the stack, so a later overlay draws over an earlier one wherever it
|
|
252
|
+
* sits in the document), onEscape (leave out for one that must be answered), initialFocus
|
|
253
|
+
* (element or function; defaults to [autofocus], then the first focusable,
|
|
254
|
+
* then the panel), opener (where focus goes back; defaults to whatever had
|
|
255
|
+
* it), restoreFocus (default true).
|
|
256
|
+
*/
|
|
257
|
+
open: function(id, options) {
|
|
258
|
+
var opts = options || {};
|
|
259
|
+
var at = _overlayIndex(id);
|
|
260
|
+
if (at !== -1) {
|
|
261
|
+
var existing = _overlays[at];
|
|
262
|
+
for (var key in opts) {
|
|
263
|
+
if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];
|
|
264
|
+
}
|
|
265
|
+
_overlaySync();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
var isModal = opts.modal !== false;
|
|
269
|
+
var entry = {
|
|
270
|
+
id: id,
|
|
271
|
+
modal: isModal,
|
|
272
|
+
panel: opts.panel,
|
|
273
|
+
root: opts.root || null,
|
|
274
|
+
zIndex: typeof opts.zIndex === 'number' ? opts.zIndex : null,
|
|
275
|
+
onEscape: opts.onEscape || null,
|
|
276
|
+
initialFocus: opts.initialFocus || null,
|
|
277
|
+
// A popup hands focus back itself, to its own trigger, and only when
|
|
278
|
+
// focus was inside it; a modal layer always does.
|
|
279
|
+
restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,
|
|
280
|
+
opener: opts.opener !== undefined ? opts.opener : document.activeElement
|
|
281
|
+
};
|
|
282
|
+
_overlays.push(entry);
|
|
283
|
+
_overlaySync();
|
|
284
|
+
// Synchronously first, so a caller that asserts focus straight after
|
|
285
|
+
// opening sees it; then retried for a panel that is not displayed yet.
|
|
286
|
+
// A popup keeps focus where its own keyboard handling puts it.
|
|
287
|
+
if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);
|
|
288
|
+
},
|
|
289
|
+
/** Take an overlay off the stack, wherever it is in it. */
|
|
290
|
+
close: function(id) {
|
|
291
|
+
var at = _overlayIndex(id);
|
|
292
|
+
if (at === -1) return;
|
|
293
|
+
var wasTop = at === _overlays.length - 1;
|
|
294
|
+
var entry = _overlays.splice(at, 1)[0];
|
|
295
|
+
_overlaySync();
|
|
296
|
+
// Only the overlay that had the keyboard gives it back. Closing one
|
|
297
|
+
// underneath (its owner went away) must not pull focus out of the top.
|
|
298
|
+
var opener = entry.opener;
|
|
299
|
+
if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {
|
|
300
|
+
try { opener.focus(); }
|
|
301
|
+
catch (_e) { /* gone; nothing to give focus back to */ }
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
/** Whether this overlay is the one that has the keyboard. */
|
|
305
|
+
isTop: function(id) {
|
|
306
|
+
var top = _overlayTop();
|
|
307
|
+
return !!top && top.id === id;
|
|
308
|
+
},
|
|
309
|
+
/** Open overlay ids, outermost first. */
|
|
310
|
+
list: function() {
|
|
311
|
+
return _overlays.map(function(o) { return o.id; });
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// \u2500\u2500 Modal system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
316
|
+
var modal = {
|
|
317
|
+
open: function(id) {
|
|
318
|
+
var el = document.querySelector('[data-stx-modal="' + id + '"]');
|
|
319
|
+
if (!el) { console.warn('[stx:modal] Modal "' + id + '" not found'); return; }
|
|
320
|
+
el.style.display = 'flex';
|
|
321
|
+
// Force reflow then animate
|
|
322
|
+
void el.offsetHeight;
|
|
323
|
+
el.setAttribute('data-stx-modal-open', '');
|
|
324
|
+
// The lock, Escape for the topmost and the Tab trap come from the
|
|
325
|
+
// overlay stack, shared with every other overlay (stacksjs/stx#2057).
|
|
326
|
+
// Each modal used to bind its own Escape and set body overflow itself,
|
|
327
|
+
// so two open closed together and the first to close unlocked the page.
|
|
328
|
+
overlays.open('stx-modal:' + id, {
|
|
329
|
+
panel: el,
|
|
330
|
+
onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { modal.close(id); } : null
|
|
331
|
+
});
|
|
332
|
+
if (el.getAttribute('data-close-backdrop') !== 'false') {
|
|
333
|
+
el.onclick = function(e) { if (e.target === el) modal.close(id); };
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
close: function(id) {
|
|
337
|
+
var el = document.querySelector('[data-stx-modal="' + id + '"]');
|
|
338
|
+
if (!el) return;
|
|
339
|
+
el.removeAttribute('data-stx-modal-open');
|
|
340
|
+
el.onclick = null;
|
|
341
|
+
overlays.close('stx-modal:' + id);
|
|
342
|
+
setTimeout(function() {
|
|
343
|
+
if (!el.hasAttribute('data-stx-modal-open')) el.style.display = 'none';
|
|
344
|
+
}, 200);
|
|
345
|
+
},
|
|
346
|
+
toggle: function(id) {
|
|
347
|
+
var el = document.querySelector('[data-stx-modal="' + id + '"]');
|
|
348
|
+
if (el && el.hasAttribute('data-stx-modal-open')) modal.close(id);
|
|
349
|
+
else modal.open(id);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Pipe expression parsing and execution for client template bindings. */
|
|
2
|
+
export declare const SIGNALS_PIPE_RUNTIME = " // ==========================================================================\n // Pipe Syntax Support (Feature #2)\n // ==========================================================================\n\n // Parse and execute pipe expressions like \"value | fmt\" or \"value | truncate:20\"\n // Must distinguish single | (pipe) from || (logical OR) and ?? (nullish coalescing)\n function parsePipeExpression(expr, scope) {\n // Find pipe operators: single | that's not part of || or preceded by ?\n // We need to find | that is:\n // 1. Not preceded by | or ?\n // 2. Not followed by |\n // Use a manual scan to handle this correctly\n let pipeIndex = -1;\n let inString = false;\n let stringChar = '';\n let depth = 0; // Track parentheses/brackets depth\n\n for (let i = 0; i < expr.length; i++) {\n const char = expr[i];\n const prevChar = i > 0 ? expr[i - 1] : '';\n const nextChar = i < expr.length - 1 ? expr[i + 1] : '';\n\n // Handle string literals\n if ((char === '\"' || char === \"'\" || char === '`') && prevChar !== '\\\\') {\n if (!inString) {\n inString = true;\n stringChar = char;\n }\nelse if (char === stringChar) {\n inString = false;\n }\n continue;\n }\n\n if (inString) continue;\n\n // Track depth for parentheses and brackets\n if (char === '(' || char === '[' || char === '{') depth++;\n if (char === ')' || char === ']' || char === '}') depth--;\n\n // Only look for pipes at top level (depth 0)\n if (depth !== 0) continue;\n\n // Check for single pipe (not || and not ??)\n if (char === '|') {\n // Skip if it's || (logical OR)\n if (nextChar === '|') {\n i++; // Skip next |\n continue;\n }\n // Skip if preceded by | (second part of ||)\n if (prevChar === '|') continue;\n // Skip if preceded by ? (part of ??)\n if (prevChar === '?') continue;\n\n // Found a pipe operator\n pipeIndex = i;\n break;\n }\n }\n\n if (pipeIndex === -1) return null;\n\n const valueExpr = expr.slice(0, pipeIndex).trim();\n const pipeChain = expr.slice(pipeIndex + 1).trim();\n\n // Parse all pipes in the chain, being careful about || and ??\n const pipes = [];\n let currentPipe = '';\n inString = false;\n stringChar = '';\n depth = 0;\n\n for (let i = 0; i < pipeChain.length; i++) {\n const char = pipeChain[i];\n const prevChar = i > 0 ? pipeChain[i - 1] : '';\n const nextChar = i < pipeChain.length - 1 ? pipeChain[i + 1] : '';\n\n // Handle string literals\n if ((char === '\"' || char === \"'\" || char === '`') && prevChar !== '\\\\') {\n if (!inString) {\n inString = true;\n stringChar = char;\n }\nelse if (char === stringChar) {\n inString = false;\n }\n currentPipe += char;\n continue;\n }\n\n if (inString) {\n currentPipe += char;\n continue;\n }\n\n // Track depth\n if (char === '(' || char === '[' || char === '{') depth++;\n if (char === ')' || char === ']' || char === '}') depth--;\n\n // Check for pipe at top level\n if (depth === 0 && char === '|' && nextChar !== '|' && prevChar !== '|' && prevChar !== '?') {\n // End of current pipe, start new one\n if (currentPipe.trim()) {\n const parts = currentPipe.trim().split(':');\n pipes.push({\n name: parts[0].trim(),\n args: parts.slice(1).map(a => a.trim())\n });\n }\n currentPipe = '';\n }\nelse {\n currentPipe += char;\n }\n }\n\n // Add last pipe\n if (currentPipe.trim()) {\n const parts = currentPipe.trim().split(':');\n pipes.push({\n name: parts[0].trim(),\n args: parts.slice(1).map(a => a.trim())\n });\n }\n\n if (pipes.length === 0) return null;\n\n return { valueExpr, pipes };\n }\n\n function executePipeExpression(valueExpr, pipes, scope) {\n // First evaluate the base expression\n let value;\n try {\n const fn = __stxCompileScoped(scope, [], 'return ' + valueExpr);\n value = fn(...__stxArgs(fn, scope));\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Pipe base expression error:', valueExpr, e);\n return '';\n }\n\n // Apply each pipe/filter\n for (const pipe of pipes) {\n const filterFn = scope[pipe.name] || globalHelpers[pipe.name];\n if (typeof filterFn === 'function') {\n try {\n // Parse args - they might be numbers, strings, or expressions\n const parsedArgs = pipe.args.map(arg => {\n // Try to parse as number\n if (/^-?\\d+(\\.\\d+)?$/.test(arg)) return Number(arg);\n // Try to parse as string (quoted)\n if (/^['\"].*['\"]$/.test(arg)) return arg.slice(1, -1);\n // Try to evaluate as expression in scope\n try {\n const fn = __stxCompileScoped(scope, [], 'return ' + arg);\n return fn(...__stxArgs(fn, scope));\n }\ncatch (e) {\n return arg;\n }\n });\n value = filterFn(value, ...parsedArgs);\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Pipe filter error:', pipe.name, e);\n }\n }\nelse {\n console.warn('[STX] Unknown pipe/filter:', pipe.name);\n }\n }\n\n return value;\n }\n";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export const SIGNALS_PIPE_RUNTIME = ` // ==========================================================================
|
|
2
|
+
// Pipe Syntax Support (Feature #2)
|
|
3
|
+
// ==========================================================================
|
|
4
|
+
|
|
5
|
+
// Parse and execute pipe expressions like "value | fmt" or "value | truncate:20"
|
|
6
|
+
// Must distinguish single | (pipe) from || (logical OR) and ?? (nullish coalescing)
|
|
7
|
+
function parsePipeExpression(expr, scope) {
|
|
8
|
+
// Find pipe operators: single | that's not part of || or preceded by ?
|
|
9
|
+
// We need to find | that is:
|
|
10
|
+
// 1. Not preceded by | or ?
|
|
11
|
+
// 2. Not followed by |
|
|
12
|
+
// Use a manual scan to handle this correctly
|
|
13
|
+
let pipeIndex = -1;
|
|
14
|
+
let inString = false;
|
|
15
|
+
let stringChar = '';
|
|
16
|
+
let depth = 0; // Track parentheses/brackets depth
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < expr.length; i++) {
|
|
19
|
+
const char = expr[i];
|
|
20
|
+
const prevChar = i > 0 ? expr[i - 1] : '';
|
|
21
|
+
const nextChar = i < expr.length - 1 ? expr[i + 1] : '';
|
|
22
|
+
|
|
23
|
+
// Handle string literals
|
|
24
|
+
if ((char === '"' || char === "'" || char === '\`') && prevChar !== '\\\\') {
|
|
25
|
+
if (!inString) {
|
|
26
|
+
inString = true;
|
|
27
|
+
stringChar = char;
|
|
28
|
+
}
|
|
29
|
+
else if (char === stringChar) {
|
|
30
|
+
inString = false;
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (inString) continue;
|
|
36
|
+
|
|
37
|
+
// Track depth for parentheses and brackets
|
|
38
|
+
if (char === '(' || char === '[' || char === '{') depth++;
|
|
39
|
+
if (char === ')' || char === ']' || char === '}') depth--;
|
|
40
|
+
|
|
41
|
+
// Only look for pipes at top level (depth 0)
|
|
42
|
+
if (depth !== 0) continue;
|
|
43
|
+
|
|
44
|
+
// Check for single pipe (not || and not ??)
|
|
45
|
+
if (char === '|') {
|
|
46
|
+
// Skip if it's || (logical OR)
|
|
47
|
+
if (nextChar === '|') {
|
|
48
|
+
i++; // Skip next |
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
// Skip if preceded by | (second part of ||)
|
|
52
|
+
if (prevChar === '|') continue;
|
|
53
|
+
// Skip if preceded by ? (part of ??)
|
|
54
|
+
if (prevChar === '?') continue;
|
|
55
|
+
|
|
56
|
+
// Found a pipe operator
|
|
57
|
+
pipeIndex = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (pipeIndex === -1) return null;
|
|
63
|
+
|
|
64
|
+
const valueExpr = expr.slice(0, pipeIndex).trim();
|
|
65
|
+
const pipeChain = expr.slice(pipeIndex + 1).trim();
|
|
66
|
+
|
|
67
|
+
// Parse all pipes in the chain, being careful about || and ??
|
|
68
|
+
const pipes = [];
|
|
69
|
+
let currentPipe = '';
|
|
70
|
+
inString = false;
|
|
71
|
+
stringChar = '';
|
|
72
|
+
depth = 0;
|
|
73
|
+
|
|
74
|
+
for (let i = 0; i < pipeChain.length; i++) {
|
|
75
|
+
const char = pipeChain[i];
|
|
76
|
+
const prevChar = i > 0 ? pipeChain[i - 1] : '';
|
|
77
|
+
const nextChar = i < pipeChain.length - 1 ? pipeChain[i + 1] : '';
|
|
78
|
+
|
|
79
|
+
// Handle string literals
|
|
80
|
+
if ((char === '"' || char === "'" || char === '\`') && prevChar !== '\\\\') {
|
|
81
|
+
if (!inString) {
|
|
82
|
+
inString = true;
|
|
83
|
+
stringChar = char;
|
|
84
|
+
}
|
|
85
|
+
else if (char === stringChar) {
|
|
86
|
+
inString = false;
|
|
87
|
+
}
|
|
88
|
+
currentPipe += char;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (inString) {
|
|
93
|
+
currentPipe += char;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Track depth
|
|
98
|
+
if (char === '(' || char === '[' || char === '{') depth++;
|
|
99
|
+
if (char === ')' || char === ']' || char === '}') depth--;
|
|
100
|
+
|
|
101
|
+
// Check for pipe at top level
|
|
102
|
+
if (depth === 0 && char === '|' && nextChar !== '|' && prevChar !== '|' && prevChar !== '?') {
|
|
103
|
+
// End of current pipe, start new one
|
|
104
|
+
if (currentPipe.trim()) {
|
|
105
|
+
const parts = currentPipe.trim().split(':');
|
|
106
|
+
pipes.push({
|
|
107
|
+
name: parts[0].trim(),
|
|
108
|
+
args: parts.slice(1).map(a => a.trim())
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
currentPipe = '';
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
currentPipe += char;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Add last pipe
|
|
119
|
+
if (currentPipe.trim()) {
|
|
120
|
+
const parts = currentPipe.trim().split(':');
|
|
121
|
+
pipes.push({
|
|
122
|
+
name: parts[0].trim(),
|
|
123
|
+
args: parts.slice(1).map(a => a.trim())
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (pipes.length === 0) return null;
|
|
128
|
+
|
|
129
|
+
return { valueExpr, pipes };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function executePipeExpression(valueExpr, pipes, scope) {
|
|
133
|
+
// First evaluate the base expression
|
|
134
|
+
let value;
|
|
135
|
+
try {
|
|
136
|
+
const fn = __stxCompileScoped(scope, [], 'return ' + valueExpr);
|
|
137
|
+
value = fn(...__stxArgs(fn, scope));
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Pipe base expression error:', valueExpr, e);
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Apply each pipe/filter
|
|
145
|
+
for (const pipe of pipes) {
|
|
146
|
+
const filterFn = scope[pipe.name] || globalHelpers[pipe.name];
|
|
147
|
+
if (typeof filterFn === 'function') {
|
|
148
|
+
try {
|
|
149
|
+
// Parse args - they might be numbers, strings, or expressions
|
|
150
|
+
const parsedArgs = pipe.args.map(arg => {
|
|
151
|
+
// Try to parse as number
|
|
152
|
+
if (/^-?\\d+(\\.\\d+)?$/.test(arg)) return Number(arg);
|
|
153
|
+
// Try to parse as string (quoted)
|
|
154
|
+
if (/^['"].*['"]$/.test(arg)) return arg.slice(1, -1);
|
|
155
|
+
// Try to evaluate as expression in scope
|
|
156
|
+
try {
|
|
157
|
+
const fn = __stxCompileScoped(scope, [], 'return ' + arg);
|
|
158
|
+
return fn(...__stxArgs(fn, scope));
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return arg;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
value = filterFn(value, ...parsedArgs);
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Pipe filter error:', pipe.name, e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
console.warn('[STX] Unknown pipe/filter:', pipe.name);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function signalsProcessElementRuntime(directiveNamesLiteral: string, eventRegexLiteral: string, handledXAttrsLiteral: string): string;
|