@stacksjs/stx 0.2.572 → 0.2.574
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/a11y.d.ts +51 -111
- package/dist/animation.d.ts +131 -74
- package/dist/api-client.d.ts +11 -21
- package/dist/api-handler.d.ts +4 -4
- package/dist/appearance-bootstrap.d.ts +16 -77
- package/dist/application-layers.d.ts +11 -20
- package/dist/asset-roots.d.ts +7 -27
- package/dist/assets.d.ts +7 -9
- package/dist/async-components.d.ts +56 -78
- package/dist/auth.d.ts +0 -3
- package/dist/browser-core-imports.d.ts +2 -2
- package/dist/build-externalize-repeated.d.ts +0 -25
- package/dist/build-externalize.d.ts +18 -53
- package/dist/build-id.d.ts +40 -28
- package/dist/build-message.d.ts +20 -44
- package/dist/builtins/attrs.d.ts +0 -14
- package/dist/builtins/drawer.d.ts +3 -22
- package/dist/builtins/icon.d.ts +17 -19
- package/dist/builtins/image-alpha.d.ts +8 -8
- package/dist/builtins/image-delivery.d.ts +38 -40
- package/dist/builtins/image-placeholder.d.ts +12 -50
- package/dist/builtins/image-warmup-worker.d.ts +1 -1
- package/dist/builtins/image-worker.d.ts +6 -32
- package/dist/builtins/index.d.ts +16 -6
- package/dist/builtins/modal.d.ts +13 -23
- package/dist/builtins/safe-image.d.ts +2 -42
- package/dist/builtins/stx-image.d.ts +44 -24
- package/dist/builtins/stx-link.d.ts +5 -8
- package/dist/builtins/stx-loading-indicator.d.ts +11 -10
- package/dist/builtins/suspense.d.ts +6 -27
- package/dist/builtins/toast.d.ts +15 -16
- package/dist/builtins/transition-group.d.ts +1 -25
- package/dist/caching.d.ts +24 -21
- package/dist/{chunk-a6jq7hex.js → chunk-06hx32h4.js} +3 -3
- package/dist/{chunk-cyg9w31a.js → chunk-0gt7e1ns.js} +1 -1
- package/dist/{chunk-15g5sc0p.js → chunk-0ppzstqj.js} +2 -2
- package/dist/{chunk-qcymqscj.js → chunk-0px2ab3m.js} +9 -9
- package/dist/chunk-0q5s55km.js +2 -0
- package/dist/{chunk-7t3ykgsm.js → chunk-1c8sdf9a.js} +3 -3
- package/dist/chunk-1m5pagp3.js +2 -0
- package/dist/{chunk-mzqyv7s5.js → chunk-1n9bxdnh.js} +3 -3
- package/dist/{chunk-58tz7tmf.js → chunk-1swmxkdt.js} +2 -2
- package/dist/{chunk-4easd8da.js → chunk-1x2x3xgc.js} +4 -4
- package/dist/chunk-27ja2rpd.js +2 -0
- package/dist/chunk-2b0p7am3.js +2 -0
- package/dist/{chunk-qj4j547f.js → chunk-30acme5g.js} +2 -2
- package/dist/{chunk-1n64749x.js → chunk-32pxa1r0.js} +1 -1
- package/dist/{chunk-g66m3g2r.js → chunk-37d52q0d.js} +1 -1
- package/dist/{chunk-sfwprq8q.js → chunk-3dr757vb.js} +9 -9
- package/dist/chunk-3k6q1481.js +2 -0
- package/dist/{chunk-2z0trbbm.js → chunk-3kc7af8c.js} +2 -2
- package/dist/chunk-3pr388w5.js +2 -0
- package/dist/chunk-42h0kvng.js +2 -0
- package/dist/chunk-4eff1v2p.js +2 -0
- package/dist/{chunk-gzgc8zk5.js → chunk-4k6cb5fg.js} +5 -5
- package/dist/{chunk-s12b57m9.js → chunk-4xvbc0mb.js} +2 -2
- package/dist/{chunk-83fdt4yj.js → chunk-501h1mer.js} +4 -4
- package/dist/{chunk-tv784gv0.js → chunk-550q827h.js} +2 -2
- package/dist/chunk-5n2v9g2c.js +2 -0
- package/dist/{chunk-q79kmad5.js → chunk-5xwmkxkk.js} +1 -1
- package/dist/chunk-68ygpbta.js +2 -0
- package/dist/{chunk-0bt0fbs1.js → chunk-69k5t6pj.js} +52 -52
- package/dist/{chunk-232jswfm.js → chunk-6c2y9h5h.js} +1 -1
- package/dist/chunk-6gjfres0.js +2 -0
- package/dist/chunk-6z57saf5.js +2 -0
- package/dist/chunk-71zwgxws.js +2 -0
- package/dist/{chunk-b9r88ysg.js → chunk-76437eb4.js} +2 -2
- package/dist/{chunk-beqkrwt1.js → chunk-7a0ewpz0.js} +2 -2
- package/dist/chunk-7debnvz9.js +2 -0
- package/dist/{chunk-jwvzvapp.js → chunk-7gxn7mvd.js} +2 -2
- package/dist/{chunk-vp31ff54.js → chunk-7hr63cp5.js} +2 -2
- package/dist/{chunk-5t1whxxt.js → chunk-825m59jr.js} +5 -5
- package/dist/{chunk-74xwzxwz.js → chunk-8efe5vpm.js} +2 -2
- package/dist/{chunk-jqefcghh.js → chunk-8hp6722y.js} +5 -5
- package/dist/{chunk-kgj852hx.js → chunk-9yht5n7g.js} +2 -2
- package/dist/{chunk-kzjrgh0b.js → chunk-a3w3jc0t.js} +6 -6
- package/dist/chunk-a77gbp9x.js +2 -0
- package/dist/chunk-ampr3fpv.js +2 -0
- package/dist/{chunk-2ads8rw5.js → chunk-b10n7cpe.js} +2 -2
- package/dist/{chunk-0q6n3by0.js → chunk-bb5a8adb.js} +3 -3
- package/dist/chunk-bgbz0wzq.js +2 -0
- package/dist/chunk-bgr7fqhs.js +2 -0
- package/dist/chunk-bjfrwcfh.js +2 -0
- package/dist/{chunk-9k7bq97t.js → chunk-byhsfnkc.js} +1 -1
- package/dist/{chunk-zyk12484.js → chunk-c0ewddb3.js} +2 -2
- package/dist/{chunk-b2q8bk8p.js → chunk-c6jyp7ss.js} +2 -2
- package/dist/chunk-cdt5pg28.js +2 -0
- package/dist/chunk-cfh798k7.js +2 -0
- package/dist/{chunk-pnag11c4.js → chunk-cp5903cg.js} +2 -2
- package/dist/{chunk-4bgfpkwx.js → chunk-crj0yqc6.js} +1 -1
- package/dist/chunk-dax3zkmm.js +2 -0
- package/dist/chunk-dn676tdp.js +2 -0
- package/dist/chunk-dtbj816p.js +2 -0
- package/dist/chunk-e23cg45k.js +2 -0
- package/dist/{chunk-qzbzn1yf.js → chunk-e27njk86.js} +12 -12
- package/dist/{chunk-vr36s2en.js → chunk-e40qpeg5.js} +2 -2
- package/dist/{chunk-q83w8edy.js → chunk-e7pjsrfc.js} +2 -2
- package/dist/chunk-ecwpsjpd.js +2 -0
- package/dist/{chunk-pqcvh9pp.js → chunk-f0mbj8w9.js} +1 -1
- package/dist/chunk-f1zyc84x.js +2 -0
- package/dist/{chunk-f4jh9vrj.js → chunk-g8dx2jew.js} +246 -243
- package/dist/{chunk-phzs239m.js → chunk-gdxhe7ae.js} +4 -4
- package/dist/{chunk-5dmkkvs7.js → chunk-gh0q6jrm.js} +2 -2
- package/dist/chunk-h8vk3q9n.js +2 -0
- package/dist/{chunk-k7ht6tqe.js → chunk-hq8vxds5.js} +2 -2
- package/dist/{chunk-zd01r00t.js → chunk-hqda3vcw.js} +1 -1
- package/dist/chunk-j8pamkbh.js +2 -0
- package/dist/{chunk-2jjff8kv.js → chunk-jwe7yq8m.js} +5 -5
- package/dist/chunk-k5rrp1bt.js +2 -0
- package/dist/{chunk-yk3wh2xv.js → chunk-kcq2ed1d.js} +2 -2
- package/dist/{chunk-9yar9rfq.js → chunk-ktc1ecsm.js} +1 -1
- package/dist/chunk-mfm7ezh6.js +2 -0
- package/dist/chunk-mp16jxcg.js +2 -0
- package/dist/chunk-myhh1zsm.js +2 -0
- package/dist/chunk-n1c9j5qv.js +2 -0
- package/dist/{chunk-dcpf6kas.js → chunk-n8hnrgen.js} +6 -6
- package/dist/{chunk-36agnyhe.js → chunk-nc0ba89b.js} +6 -6
- package/dist/chunk-nf63pk4s.js +2 -0
- package/dist/{chunk-1edvsndv.js → chunk-nxw03sy9.js} +2 -2
- package/dist/{chunk-jze68d0z.js → chunk-p3xkj7pm.js} +2 -2
- package/dist/chunk-p5cry5s7.js +2 -0
- package/dist/{chunk-0dz1b6a1.js → chunk-pxk0tpw2.js} +3 -3
- package/dist/chunk-qd4snptd.js +2 -0
- package/dist/{chunk-h4k3hyny.js → chunk-r5ce7mkg.js} +2 -2
- package/dist/chunk-r8qhex33.js +2 -0
- package/dist/chunk-rqvn1s52.js +2 -0
- package/dist/{chunk-79vdkvhf.js → chunk-sej3ng5k.js} +5 -5
- package/dist/chunk-sjsant53.js +2 -0
- package/dist/chunk-snzh9z3g.js +3 -0
- package/dist/{chunk-ymawe0y5.js → chunk-ss4h5ch3.js} +1 -1
- package/dist/{chunk-2crxkm7j.js → chunk-svvavwp2.js} +4 -4
- package/dist/{chunk-qt3x1sh3.js → chunk-t79xnvzr.js} +3 -3
- package/dist/{chunk-rrj5m9xv.js → chunk-ta50ym5j.js} +2 -2
- package/dist/chunk-ty8g61y9.js +2 -0
- package/dist/chunk-v1k6w4z5.js +2 -0
- package/dist/{chunk-rfnr4xz6.js → chunk-vde4mtfr.js} +2 -2
- package/dist/chunk-vm7zv0gc.js +2 -0
- package/dist/{chunk-xckzvbvn.js → chunk-vnh550b5.js} +1 -1
- package/dist/chunk-vnxc48en.js +2 -0
- package/dist/chunk-y7vbwhh7.js +2 -0
- package/dist/{chunk-ydx3mfpp.js → chunk-yf90vn5t.js} +6 -6
- package/dist/{chunk-6wc2t6cd.js → chunk-yhqhv8mp.js} +13 -13
- package/dist/{chunk-s34g3awk.js → chunk-ytf3qkaw.js} +3 -3
- package/dist/chunk-yvyypd92.js +2 -0
- package/dist/{chunk-c4zpzxex.js → chunk-z33z3rr4.js} +4 -4
- package/dist/chunk-zfw39q56.js +2 -0
- package/dist/chunk-zpm02e15.js +2 -0
- package/dist/chunk-zzr0p4bb.js +2 -0
- package/dist/cli.js +18 -18
- package/dist/client/directive.d.ts +0 -7
- package/dist/client/index.d.ts +1 -0
- package/dist/client/signals-appearance-runtime.d.ts +1 -1
- package/dist/client/signals-binding-utils-runtime.d.ts +1 -1
- package/dist/client/signals-bootstrap-runtime.d.ts +2 -2
- package/dist/client/signals-class-runtime.d.ts +1 -1
- package/dist/client/signals-component-api-runtime.d.ts +1 -1
- package/dist/client/signals-component-hydration-runtime.d.ts +1 -1
- package/dist/client/signals-component-props-runtime.d.ts +1 -1
- package/dist/client/signals-conditional-chain-runtime.d.ts +1 -1
- package/dist/client/signals-conditional-component-runtime.d.ts +1 -1
- package/dist/client/signals-container-cleanup-runtime.d.ts +1 -1
- package/dist/client/signals-context-runtime.d.ts +1 -1
- package/dist/client/signals-cookie-runtime.d.ts +1 -1
- package/dist/client/signals-devtools-runtime.d.ts +1 -1
- package/dist/client/signals-dialog-runtime.d.ts +1 -1
- package/dist/client/signals-dom-ready-runtime.d.ts +1 -1
- package/dist/client/signals-drawer-runtime.d.ts +1 -1
- package/dist/client/signals-effect-runtime.d.ts +1 -1
- package/dist/client/signals-event-shorthand-runtime.d.ts +1 -1
- package/dist/client/signals-expression-compiler-runtime.d.ts +1 -1
- package/dist/client/signals-expression-runtime.d.ts +1 -1
- package/dist/client/signals-fetch-transport-runtime.d.ts +1 -1
- package/dist/client/signals-for-runtime.d.ts +1 -1
- package/dist/client/signals-globals-runtime.d.ts +1 -1
- package/dist/client/signals-handler-runtime.d.ts +1 -1
- package/dist/client/signals-head-runtime.d.ts +1 -1
- package/dist/client/signals-helpers-runtime.d.ts +1 -1
- package/dist/client/signals-host-runtime.d.ts +1 -1
- package/dist/client/signals-hydration-audit-runtime.d.ts +1 -1
- package/dist/client/signals-hydration-runtime.d.ts +1 -1
- package/dist/client/signals-if-chain-runtime.d.ts +1 -1
- package/dist/client/signals-if-runtime.d.ts +1 -1
- package/dist/client/signals-lazy-hydration-runtime.d.ts +1 -1
- package/dist/client/signals-lifecycle-runtime.d.ts +1 -1
- package/dist/client/signals-loop-component-remap-runtime.d.ts +1 -1
- package/dist/client/signals-loop-conditional-runtime.d.ts +1 -1
- package/dist/client/signals-loop-row-runtime.d.ts +1 -1
- package/dist/client/signals-manifest-hydration-runtime.d.ts +1 -1
- package/dist/client/signals-model-runtime.d.ts +1 -1
- package/dist/client/signals-mount-runtime.d.ts +1 -1
- package/dist/client/signals-navigation-runtime.d.ts +1 -1
- package/dist/client/signals-notify-runtime.d.ts +1 -1
- package/dist/client/signals-optimistic-runtime.d.ts +1 -1
- package/dist/client/signals-overlay-runtime.d.ts +1 -1
- package/dist/client/signals-pipe-runtime.d.ts +1 -1
- package/dist/client/signals-proxy-runtime.d.ts +1 -1
- package/dist/client/signals-query-runtime.d.ts +1 -1
- package/dist/client/signals-reactive-runtime.d.ts +1 -1
- package/dist/client/signals-ref-runtime.d.ts +1 -1
- package/dist/client/signals-scope-disposal-runtime.d.ts +1 -1
- package/dist/client/signals-scope-traversal-runtime.d.ts +1 -1
- package/dist/client/signals-show-runtime.d.ts +1 -1
- package/dist/client/signals-spa-load-control-runtime.d.ts +1 -1
- package/dist/client/signals-spa-load-runtime.d.ts +1 -1
- package/dist/client/signals-state-runtime.d.ts +1 -1
- package/dist/client/signals-storage-runtime.d.ts +1 -1
- package/dist/client/signals-store-registry-runtime.d.ts +1 -1
- package/dist/client/signals-style-runtime.d.ts +1 -1
- package/dist/client/signals-suspense-runtime.d.ts +1 -1
- package/dist/client/signals-timer-runtime.d.ts +1 -1
- package/dist/client/signals-toast-runtime.d.ts +1 -1
- package/dist/client/signals-tooltip-runtime.d.ts +1 -1
- package/dist/client/signals-transition-group-runtime.d.ts +1 -1
- package/dist/client/signals-websocket-runtime.d.ts +1 -1
- package/dist/client-helpers.d.ts +1 -312
- package/dist/client-module-registry.d.ts +4 -27
- package/dist/client-parameter-bindings.d.ts +4 -9
- package/dist/client-parameter-bindings.js +30 -10
- package/dist/client-script-bundler.d.ts +55 -103
- package/dist/client-script.d.ts +69 -127
- package/dist/client-script.js +4 -7
- package/dist/color-mode-boot.d.ts +21 -58
- package/dist/component-client-factories.d.ts +8 -9
- package/dist/component-contract-checks.d.ts +15 -18
- package/dist/component-contract.d.ts +6 -6
- package/dist/component-hmr.d.ts +8 -7
- package/dist/component-model.d.ts +14 -20
- package/dist/component-processing.d.ts +51 -59
- package/dist/component-registry.d.ts +28 -99
- package/dist/component-renderer.d.ts +19 -16
- package/dist/component-resolution.d.ts +8 -8
- package/dist/component-tags.d.ts +1 -1
- package/dist/composable-loader.d.ts +6 -41
- package/dist/composables/use-fetch.d.ts +45 -114
- package/dist/composables/use-form.d.ts +2 -56
- package/dist/composables/use-intersection-observer.d.ts +1 -1
- package/dist/composables.d.ts +75 -74
- package/dist/composition-api.d.ts +19 -43
- package/dist/computed.d.ts +93 -86
- package/dist/conditionals.d.ts +0 -24
- package/dist/config.d.ts +30 -24
- package/dist/config.js +3 -0
- package/dist/craft-bridge.d.ts +1 -467
- package/dist/craft-components.d.ts +234 -680
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/csp.d.ts +41 -107
- package/dist/database.d.ts +1 -1
- package/dist/defer.d.ts +0 -24
- package/dist/dev-server/terminal-colors.d.ts +32 -32
- package/dist/dev-server/ts-css.d.ts +26 -35
- package/dist/dev-server/types.d.ts +33 -29
- package/dist/directive-api.d.ts +42 -85
- package/dist/directive-arguments.d.ts +14 -39
- package/dist/document-shell.d.ts +49 -81
- package/dist/dynamic-components.d.ts +0 -9
- package/dist/engine-bindings.d.ts +1 -1
- package/dist/env.d.ts +26 -0
- package/dist/error-boundaries.d.ts +36 -43
- package/dist/error-handling.d.ts +1 -1
- package/dist/errors/codes.d.ts +43 -51
- package/dist/errors/formatter.d.ts +38 -58
- package/dist/errors/index.d.ts +61 -5
- package/dist/errors/logger.d.ts +40 -114
- package/dist/errors/sanitizer.d.ts +28 -53
- package/dist/errors/types.d.ts +31 -44
- package/dist/events.d.ts +32 -94
- package/dist/expressions.d.ts +57 -62
- package/dist/find-body-tag.d.ts +5 -34
- package/dist/first-script-tag.d.ts +0 -23
- package/dist/forms-validation.d.ts +117 -149
- package/dist/forms.d.ts +161 -120
- package/dist/framework-composables.d.ts +0 -32
- package/dist/head-injection.d.ts +30 -32
- package/dist/head-keys.d.ts +12 -15
- package/dist/head.d.ts +110 -139
- package/dist/heatmap.d.ts +76 -152
- package/dist/html-masking.d.ts +38 -62
- package/dist/hydration-runtime.d.ts +24 -20
- package/dist/hydration.d.ts +11 -10
- package/dist/i18n.d.ts +34 -95
- package/dist/image-optimization/auto-sibling.d.ts +4 -32
- package/dist/imported-signals.d.ts +0 -36
- package/dist/includes.d.ts +6 -69
- package/dist/index.d.ts +2 -1
- package/dist/init.d.ts +12 -20
- package/dist/internal-markdown.d.ts +8 -12
- package/dist/interpolation-context.d.ts +15 -15
- package/dist/island-chunking.d.ts +13 -30
- package/dist/keep-alive.d.ts +52 -72
- package/dist/layout-types.d.ts +2 -27
- package/dist/lazy-module.d.ts +0 -10
- package/dist/loading-indicator.d.ts +8 -5
- package/dist/loop-binding.d.ts +4 -7
- package/dist/loops.d.ts +25 -67
- package/dist/markdown.d.ts +1 -0
- package/dist/media/image/component.d.ts +9 -25
- package/dist/media/image/directive.d.ts +1 -15
- package/dist/media/image/placeholder.d.ts +9 -20
- package/dist/media/image/processor/cache.d.ts +18 -40
- package/dist/media/image/processor/index.d.ts +10 -1
- package/dist/media/image/processor/optimizer.d.ts +1 -12
- package/dist/media/image/processor/responsive.d.ts +6 -16
- package/dist/media/image/srcset.d.ts +49 -47
- package/dist/media/shared/cache.d.ts +31 -51
- package/dist/media/shared/hash.d.ts +0 -7
- package/dist/media/types.d.ts +754 -1235
- package/dist/media/video/directive.d.ts +1 -15
- package/dist/media/video/index.d.ts +17 -39
- package/dist/media/video/processor/cache.d.ts +19 -42
- package/dist/media/video/processor/index.d.ts +18 -1
- package/dist/media/video/processor/streaming.d.ts +10 -17
- package/dist/media/video/processor/thumbnail.d.ts +15 -21
- package/dist/media/video/processor/transcoder.d.ts +1 -11
- package/dist/meta-arguments.d.ts +14 -39
- package/dist/method-spoofing.d.ts +0 -7
- package/dist/middleware.d.ts +0 -60
- package/dist/native/bridge/protocol.d.ts +2 -1
- package/dist/native/compiler/headwind-to-style.d.ts +383 -359
- package/dist/native/compiler/icons.d.ts +249 -243
- package/dist/native/compiler/svg.d.ts +35 -24
- package/dist/native/runtime/jsc-globals.d.ts +1 -1
- package/dist/native/runtime/native-host.d.ts +1 -1
- package/dist/native/runtime/native-host.js +3 -0
- package/dist/offline/app-service-worker.d.ts +50 -114
- package/dist/offline/kept-store.d.ts +23 -37
- package/dist/offline/query-cache.d.ts +55 -126
- package/dist/owned-routes.d.ts +0 -31
- package/dist/page-response.d.ts +8 -39
- package/dist/parser/directive-parser.d.ts +45 -57
- package/dist/parser/expression-parser.d.ts +35 -33
- package/dist/parser/index.d.ts +39 -4
- package/dist/parser/tokenizer.d.ts +49 -61
- package/dist/partial-hydration.d.ts +51 -82
- package/dist/performance-utils.d.ts +115 -255
- package/dist/placeholder.d.ts +9 -18
- package/dist/plugin-system.d.ts +115 -264
- package/dist/process.d.ts +4 -9
- package/dist/process.js +6 -4
- package/dist/prop-sentinels.d.ts +11 -11
- package/dist/public-env.d.ts +0 -14
- package/dist/pwa/directives.d.ts +20 -12
- package/dist/pwa/inject.d.ts +0 -10
- package/dist/pwa/precache.d.ts +16 -22
- package/dist/pwa/service-worker.d.ts +0 -12
- package/dist/pwa.js +3 -3
- package/dist/reactive-bindings.d.ts +11 -34
- package/dist/reactive-tracking.d.ts +0 -36
- package/dist/reactive.d.ts +41 -58
- package/dist/render-memo.d.ts +5 -23
- package/dist/resolve-stx-targets.d.ts +6 -44
- package/dist/route-middleware.d.ts +35 -2
- package/dist/route-rules.d.ts +10 -13
- package/dist/router.d.ts +9 -8
- package/dist/routes.d.ts +3 -1
- package/dist/runtime-config-server.d.ts +14 -17
- package/dist/runtime-config.d.ts +2 -3
- package/dist/runtime-globals.d.ts +90 -122
- package/dist/runtime-injection.d.ts +0 -8
- package/dist/scaffolding.d.ts +30 -26
- package/dist/script-emit.d.ts +0 -30
- package/dist/script-validation.d.ts +6 -12
- package/dist/seo.d.ts +75 -153
- package/dist/server-api.d.ts +9 -12
- package/dist/server-bindings.d.ts +1 -26
- package/dist/server-data.d.ts +4 -5
- package/dist/sfc-template.d.ts +8 -8
- package/dist/signal-processing.d.ts +37 -53
- package/dist/signals-api.d.ts +58 -135
- package/dist/signals.d.ts +18 -24
- package/dist/site-url.d.ts +31 -28
- package/dist/slots.d.ts +20 -86
- package/dist/source-signature.d.ts +5 -28
- package/dist/ssg.d.ts +158 -337
- package/dist/ssg.js +4 -4
- package/dist/state-dir.d.ts +4 -4
- package/dist/store-loader.d.ts +0 -10
- package/dist/story/analytics.d.ts +60 -138
- package/dist/story/bookmarks.d.ts +34 -87
- package/dist/story/cli.d.ts +69 -123
- package/dist/story/collect/scanner.d.ts +0 -4
- package/dist/story/collect/tree.d.ts +1 -8
- package/dist/story/commands/build.d.ts +6 -11
- package/dist/story/commands/dev.d.ts +8 -15
- package/dist/story/commands/preview.d.ts +7 -13
- package/dist/story/config-watcher.d.ts +13 -20
- package/dist/story/config.d.ts +8 -11
- package/dist/story/context.d.ts +8 -14
- package/dist/story/hmr.d.ts +26 -24
- package/dist/story/hot-swap.d.ts +23 -34
- package/dist/story/keyboard-shortcuts.d.ts +18 -23
- package/dist/story/output.d.ts +44 -46
- package/dist/story/performance.d.ts +45 -107
- package/dist/story/presets.d.ts +41 -107
- package/dist/story/renderer.d.ts +27 -41
- package/dist/story/search.d.ts +12 -23
- package/dist/story/server.d.ts +11 -21
- package/dist/story/setup.d.ts +15 -23
- package/dist/story/testing.d.ts +40 -65
- package/dist/story/types.d.ts +160 -262
- package/dist/streaming.d.ts +57 -119
- package/dist/strip-literals.d.ts +1 -25
- package/dist/stx-module-imports.d.ts +7 -0
- package/dist/stx-virtual-ts.d.ts +102 -253
- package/dist/stx-virtual-ts.js +5 -4
- package/dist/style-scoping.d.ts +8 -21
- package/dist/suspense.d.ts +52 -67
- package/dist/teleport.d.ts +0 -22
- package/dist/template-syntax-escape.d.ts +8 -8
- package/dist/template-tag-balance.d.ts +6 -22
- package/dist/testing.d.ts +26 -11
- package/dist/theme-tokens.d.ts +388 -134
- package/dist/transitions.d.ts +55 -66
- package/dist/ts-css-config.d.ts +12 -70
- package/dist/types/component-types.d.ts +122 -187
- package/dist/types/config-types.d.ts +341 -956
- package/dist/types/context-types.d.ts +24 -46
- package/dist/types/csp-types.d.ts +66 -70
- package/dist/types/directive-types.d.ts +156 -223
- package/dist/types/index.d.ts +110 -6
- package/dist/types/pwa-types.d.ts +148 -273
- package/dist/types.d.ts +1 -0
- package/dist/unresolved-identifiers.d.ts +22 -24
- package/dist/url-safety.d.ts +32 -32
- package/dist/utils.d.ts +21 -36
- package/dist/utils.js +6 -2
- package/dist/validator.d.ts +26 -28
- package/dist/variable-extractor.d.ts +19 -49
- package/dist/view-composers.d.ts +81 -80
- package/dist/virtual-scrolling.d.ts +82 -101
- package/dist/visual-testing.d.ts +10 -9
- package/dist/vue-template.d.ts +0 -23
- package/dist/web-components/css-scoping.d.ts +11 -21
- package/dist/web-components.d.ts +58 -81
- package/dist/x-element.d.ts +1 -0
- package/package.json +6 -6
- package/stx.d.ts +2 -2
- package/dist/app-service-worker.d.ts +0 -165
- package/dist/chunk-01mxer9s.js +0 -2
- package/dist/chunk-09gtbb1w.js +0 -2
- package/dist/chunk-0g2ybnht.js +0 -3
- package/dist/chunk-15erabm6.js +0 -2
- package/dist/chunk-1z6c6dyk.js +0 -2
- package/dist/chunk-1zfg1kd5.js +0 -2
- package/dist/chunk-279jv0yf.js +0 -2
- package/dist/chunk-2a1q5y6r.js +0 -2
- package/dist/chunk-2cqbyb8w.js +0 -2
- package/dist/chunk-2jsnrfc8.js +0 -2
- package/dist/chunk-3gft8zng.js +0 -2
- package/dist/chunk-49gwmcrn.js +0 -2
- package/dist/chunk-4wfr074d.js +0 -2
- package/dist/chunk-5afw7z6v.js +0 -2
- package/dist/chunk-5fv4g4et.js +0 -2
- package/dist/chunk-604rs9sq.js +0 -2
- package/dist/chunk-636sfxyj.js +0 -2
- package/dist/chunk-6f4qrd0s.js +0 -2
- package/dist/chunk-6va5pe2m.js +0 -2
- package/dist/chunk-8k61b4ae.js +0 -2
- package/dist/chunk-asbq9cgs.js +0 -2
- package/dist/chunk-b7t8jejd.js +0 -2
- package/dist/chunk-b894fxfc.js +0 -2
- package/dist/chunk-bm2q1srp.js +0 -2
- package/dist/chunk-cgwyd9aq.js +0 -2
- package/dist/chunk-cvswrbzw.js +0 -2
- package/dist/chunk-d8206zbp.js +0 -2
- package/dist/chunk-f10299sf.js +0 -2
- package/dist/chunk-f1apaqfk.js +0 -2
- package/dist/chunk-g6zeqvvb.js +0 -2
- package/dist/chunk-ghy82tsc.js +0 -2
- package/dist/chunk-jw33eys8.js +0 -2
- package/dist/chunk-k6wgh598.js +0 -2
- package/dist/chunk-m2a1fxpb.js +0 -2
- package/dist/chunk-m6mxqepz.js +0 -2
- package/dist/chunk-n6qp05t9.js +0 -2
- package/dist/chunk-nn174xjh.js +0 -2
- package/dist/chunk-ntgy4e1q.js +0 -2
- package/dist/chunk-nw4axkpx.js +0 -2
- package/dist/chunk-p5chk3s9.js +0 -2
- package/dist/chunk-pw9verqx.js +0 -2
- package/dist/chunk-ta8bhz27.js +0 -2
- package/dist/chunk-tc5r2vmw.js +0 -2
- package/dist/chunk-ts80ktq7.js +0 -2
- package/dist/chunk-vyg8bvkt.js +0 -2
- package/dist/chunk-xq2ck69k.js +0 -2
- package/dist/chunk-y4ajd836.js +0 -2
- package/dist/chunk-zddzjd60.js +0 -2
- package/dist/chunk-zgxj1q7w.js +0 -2
- package/dist/chunk-zs7qhh40.js +0 -2
- package/dist/signals-context-runtime.d.ts +0 -2
- package/dist/signals-drawer-runtime.d.ts +0 -2
- package/dist/signals-host-runtime.d.ts +0 -9
- package/dist/signals-loop-conditional-runtime.d.ts +0 -2
- package/dist/signals-manifest-hydration-runtime.d.ts +0 -2
- package/dist/signals-notify-runtime.d.ts +0 -2
- package/dist/signals-optimistic-runtime.d.ts +0 -2
- package/dist/signals-overlay-runtime.d.ts +0 -2
- package/dist/signals-scope-disposal-runtime.d.ts +0 -2
- package/dist/signals-spa-load-control-runtime.d.ts +0 -2
- package/dist/signals-storage-runtime.d.ts +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Alert and confirm dialog helpers used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DIALOG_RUNTIME = " // \u2500\u2500 Alert & Confirm dialogs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Styled replacements for window.alert() and window.confirm().\n // Both return Promises and render into a temporary modal overlay.\n\n var _dialogId = 0;\n\n // Modality - the scroll lock, the inert page behind, the one Escape and the\n // one Tab trap - comes from the overlay stack above, which these dialogs\n // share with every other overlay on the page (#1998, stacksjs/stx#2057).\n\n /** Dialogs animate unless the reader asked them not to (#1998 item 5). */\n function _dialogReducedMotion() {\n try {\n return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);\n }\n catch (_e) {\n return false;\n }\n }\n var _dialogIcons = {\n info: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"/></svg>',\n warning: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#d97706\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>',\n error: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>',\n success: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#16a34a\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>',\n question: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#6366f1\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>'\n };\n\n function _createDialog(message, options, isConfirm) {\n var opts = options || {};\n var type = opts.type || (isConfirm ? 'question' : 'info');\n var title = opts.title || '';\n var confirmText = opts.confirmText || 'OK';\n var cancelText = opts.cancelText || 'Cancel';\n var id = 'stx-dialog-' + (++_dialogId);\n // Resolve dark from what the APP decided, not only from the OS. stx's own\n // color-mode boot writes a class (default 'dark') and/or an attribute\n // (e.g. data-theme) onto <html>, so an app pinned to light on a dark OS used\n // to get a dark dialog over a light page. An explicit opts.dark wins over\n // both, and the media query stays as the last resort. See #1875.\n var isDark = _resolveDark(opts.dark);\n var bg = isDark ? '#1f2937' : '#ffffff';\n var textColor = isDark ? '#f3f4f6' : '#1f2937';\n var subColor = isDark ? '#9ca3af' : '#6b7280';\n var icon = _dialogIcons[type] || _dialogIcons.info;\n\n return new Promise(function(resolve) {\n // Inline transitions cannot be reached by a stylesheet media query, so the\n // preference is read here instead (#1998 item 5). One matchMedia probe\n // rather than usePreferredReducedMotion(): that returns a signal with a\n // change listener, and an imperative dialog that reads the value once at\n // open time would leak one listener per call.\n var still = _dialogReducedMotion();\n var fade = still ? '' : 'transition:opacity 0.2s ease;';\n var scale = still ? '' : 'transition:transform 0.2s ease;';\n\n var backdrop = document.createElement('div');\n backdrop.id = id;\n backdrop.style.cssText = 'position:fixed;inset:0;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:' + (still ? '1' : '0') + ';' + fade + 'font-family:system-ui,-apple-system,sans-serif';\n backdrop.setAttribute('role', 'alertdialog');\n backdrop.setAttribute('aria-modal', 'true');\n\n var panel = document.createElement('div');\n panel.style.cssText = 'max-width:24rem;width:calc(100% - 2rem);border-radius:0.75rem;padding:1.5rem;background:' + bg + ';color:' + textColor + ';box-shadow:0 20px 60px rgba(0,0,0,0.3);transform:scale(' + (still ? '1' : '0.95') + ');' + scale + 'text-align:center';\n\n var iconDiv = document.createElement('div');\n iconDiv.style.cssText = 'display:flex;justify-content:center;margin-bottom:1rem';\n iconDiv.innerHTML = icon;\n panel.appendChild(iconDiv);\n\n if (title) {\n var titleEl = document.createElement('h3');\n titleEl.id = id + '-title';\n titleEl.style.cssText = 'margin:0 0 0.5rem;font-size:1.125rem;font-weight:600';\n titleEl.textContent = title;\n panel.appendChild(titleEl);\n // role=alertdialog was announced with no accessible name at all.\n backdrop.setAttribute('aria-labelledby', titleEl.id);\n }\n\n var msgEl = document.createElement('p');\n msgEl.id = id + '-message';\n msgEl.style.cssText = 'margin:0 0 1.25rem;font-size:0.875rem;line-height:1.5;color:' + subColor;\n msgEl.textContent = message;\n panel.appendChild(msgEl);\n backdrop.setAttribute('aria-describedby', msgEl.id);\n if (!title)\n backdrop.setAttribute('aria-label', message);\n\n var btnRow = document.createElement('div');\n btnRow.style.cssText = 'display:flex;gap:0.75rem;justify-content:center';\n\n // Captured before the dialog steals focus, so it can be handed back on\n // close. Without this a keyboard or screen-reader user is dropped at the\n // top of the document every time a dialog closes.\n var previouslyFocused = document.activeElement;\n var closed = false;\n\n function cleanup(result) {\n // Guarded: the escape handler used to be able to fire after a button had\n // already closed the dialog, because the listener outlived it.\n if (closed) return;\n closed = true;\n\n // The fade is 200ms and resolve() is immediate, so for those 200ms a\n // full-viewport element at z-index 999999 was still hit-testing at the\n // centre of the screen - after the caller's await had already returned\n // (#1998 item 6). Fading out is right; swallowing clicks is not.\n backdrop.style.pointerEvents = 'none';\n backdrop.style.opacity = '0';\n if (!still) panel.style.transform = 'scale(0.95)';\n setTimeout(function() { backdrop.remove(); }, still ? 0 : 200);\n\n // Out of the stack BEFORE resolving, so a caller that opens another\n // dialog the moment this one answers does not land under a backdrop\n // that is still fading. That also unlocks the page and clears inert\n // when this was the last overlay, hands modality back to the one\n // underneath when it was not, and gives focus back to the opener.\n overlays.close(id);\n resolve(result);\n }\n\n // Declared out here rather than inside the branch: the focus decision\n // below needs to know whether a Cancel button exists at all.\n var cancelBtn = null;\n if (isConfirm) {\n cancelBtn = document.createElement('button');\n cancelBtn.textContent = cancelText;\n cancelBtn.style.cssText = 'padding:0.5rem 1.25rem;border-radius:0.5rem;font-size:0.875rem;font-weight:500;cursor:pointer;border:1px solid ' + (isDark ? '#374151' : '#d1d5db') + ';background:transparent;color:' + textColor + ';transition:background 0.15s';\n cancelBtn.onmouseover = function() { this.style.background = isDark ? '#374151' : '#f3f4f6'; };\n cancelBtn.onmouseout = function() { this.style.background = 'transparent'; };\n cancelBtn.onclick = function() { cleanup(false); };\n btnRow.appendChild(cancelBtn);\n }\n\n var okBtn = document.createElement('button');\n okBtn.textContent = confirmText;\n var btnColor = type === 'error' ? '#dc2626' : type === 'warning' ? '#d97706' : '#5672cd';\n okBtn.style.cssText = 'padding:0.5rem 1.25rem;border-radius:0.5rem;font-size:0.875rem;font-weight:500;cursor:pointer;border:none;background:' + btnColor + ';color:#fff;transition:opacity 0.15s';\n okBtn.onmouseover = function() { this.style.opacity = '0.9'; };\n okBtn.onmouseout = function() { this.style.opacity = '1'; };\n okBtn.onclick = function() { cleanup(isConfirm ? true : undefined); };\n btnRow.appendChild(okBtn);\n\n panel.appendChild(btnRow);\n backdrop.appendChild(panel);\n document.body.appendChild(backdrop);\n\n // Animate in\n if (!still) {\n void backdrop.offsetHeight;\n backdrop.style.opacity = '1';\n panel.style.transform = 'scale(1)';\n }\n\n\n /*\n * Initial focus, which was an unconditional okBtn.focus() (#1998 item 3).\n *\n * type: 'error' already paints that button red, so the API knows the\n * action is destructive - and still handed it the keyboard, where a stray\n * Enter or Space confirmed the delete. An error-type confirm now defaults\n * to Cancel, and defaultFocus overrides either way.\n *\n * An alert has only one button, so it keeps it: there is nothing\n * destructive to land on and focus has to go somewhere inside the trap.\n */\n var focusTarget = okBtn;\n if (isConfirm && cancelBtn) {\n var want = opts.defaultFocus;\n if (want === 'cancel' || (!want && type === 'error')) focusTarget = cancelBtn;\n else if (want === 'confirm') focusTarget = okBtn;\n }\n\n // Onto the overlay stack, which locks the page, makes it inert behind\n // this backdrop, traps Tab inside the panel and answers Escape for\n // whichever dialog is on top - so one Escape answers one dialog\n // (#1998 item 4) and a component Dialog underneath stays open.\n overlays.open(id, {\n panel: panel,\n root: backdrop,\n initialFocus: focusTarget,\n opener: previouslyFocused,\n onEscape: function() { cleanup(isConfirm ? false : undefined); }\n });\n });\n }\n\n function stxAlert(message, options) {\n return _createDialog(message, options, false);\n }\n\n function stxConfirm(message, options) {\n return _createDialog(message, options, true);\n }\n";
|
|
2
|
+
export declare const SIGNALS_DIALOG_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** DOM-ready initialization used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DOM_READY_RUNTIME = " // ==========================================================================\n // Auto-initialization\n // ==========================================================================\n\n // A dev runtime may be evaluated again by HMR, an embed, or a test harness.\n // Replace the previous listener so only the latest runtime closure can own\n // componentScope and reactive subscriptions.\n if (window.__stxDomReadyHandler) {\n document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);\n }\n const stxDomReadyHandler = () => {\n console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');\n // Track which scoped elements have been processed\n const processedScopes = new Set();\n\n // Layout expansion can remove the data-stx marker from a page's first\n // element while leaving markers owned by the layout itself. The generated\n // page setup is still queued explicitly, so adopt it when its own marker\n // did not survive.\n const latestSetup = window.stx._latestSetup;\n const latestSetupName = typeof latestSetup === 'function' ? latestSetup.name : '';\n const hasLatestSetupMarker = latestSetupName && Array.from(document.querySelectorAll('[data-stx]'))\n .some(el => el.getAttribute('data-stx') === latestSetupName);\n if (latestSetup && !hasLatestSetupMarker) {\n try {\n const result = latestSetup();\n if (typeof result === 'object' && result !== null)\n Object.assign(componentScope, result);\n }\n catch (e) {\n console.error('[stx] initial setup error:', e);\n }\n }\n\n // Register page setup before mounting child components. Projected slot\n // content belongs to the caller, so child mounts need the caller's signals\n // available when they walk their own rendered roots.\n document.querySelectorAll('[data-stx]').forEach(el => {\n const setupName = el.getAttribute('data-stx');\n console.log('[DOMContentLoaded] data-stx:', setupName, 'el:', el.tagName, 'fn exists:', !!(setupName && window[setupName]));\n if (setupName && window[setupName]) {\n // Contained, like the two sibling setup call sites. An uncaught throw\n // here aborted the whole forEach and everything after it in this\n // handler, so ONE bad name in ONE page's setup left every root on the\n // page unhydrated \u2014 the user sees raw {{ }}, and the console names the\n // identifier without saying it cost them the document (#1805).\n try {\n const result = window[setupName]();\n console.log('[DOMContentLoaded] setup returned:', result ? Object.keys(result).slice(0, 10) : 'null');\n if (typeof result === 'object' && result !== null) {\n Object.assign(componentScope, result);\n }\n }\n catch (e) {\n console.error('[stx] page setup \"' + setupName + '\" threw; this root will not hydrate:', e);\n }\n }\n });\n var pageScopeSnapshot = { ...componentScope };\n\n /*\n * Any x-data scope the reactive bridge did not reach, initialized here.\n *\n * The bridge script addresses each scope by a selector it generated, and\n * that numbering restarts per render - so a page carrying three component\n * islands emits three scripts all looking for the same scope id, and two of\n * the three scopes are never initialized at all. The symptom is the\n * quietest one available: the markup is there, every binding shows its\n * initial value, and whatever x-init was meant to start never starts.\n *\n * Registered scopes are skipped, so the bridge stays authoritative where it\n * did run and this only picks up what it missed. The init expression is\n * read from data-stx-xinit, which the server preserves for exactly this.\n *\n * No backticks in this comment, deliberately: it lives inside the runtime\n * source that is embedded as a template literal, and one would end the\n * literal and take the whole file's syntax with it.\n */\n if (window.__stx_reactive && window.__stx_reactive.initScope) {\n document.querySelectorAll('[data-stx-xdata]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n if (scopeId && window.stx._scopes && window.stx._scopes[scopeId]) return;\n if (el.__stx_scope_initialized) return;\n\n var xdata = el.getAttribute('data-stx-xdata');\n if (!xdata) return;\n\n if (!scopeId) {\n scopeId = '__stx_scope_island_' + (++window.stx._scopeCounter);\n el.setAttribute('data-stx-scope', scopeId);\n }\n\n el.__stx_scope_initialized = true;\n\n try {\n window.__stx_reactive.initScope(el, xdata, [], {}, el.getAttribute('data-stx-xinit') || null);\n }\n catch (e) {\n console.error('[stx] island scope init error:', e);\n }\n });\n }\n\n // Process mount queue (from stx.mount() calls during loading) only after\n // caller setup is available for Vue-style projected slot ownership.\n mountQueue.forEach(function(fn) { fn(); });\n mountQueue = [];\n\n // A queued layout mount owns a separate $refs map and merges it into the\n // compatibility scope. Page useRef accessors already captured the page's\n // map during setup; bind its DOM back into that same map before onMount.\n // Keep the layout's other exposed names available for legacy bindings.\n componentScope.$refs = pageScopeSnapshot.$refs;\n\n // Bind page roots after child components have registered their local scope.\n document.querySelectorAll('[data-stx]').forEach(el => {\n console.log('[DOMContentLoaded] processElement on:', el.tagName, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n var disposeEffects = trackEffects(function() {\n // The server's list when the page shipped one, the walk otherwise.\n if (!processFromManifest(el, componentScope, window.__stx_bindings)) processElement(el);\n });\n el.__stx_disposers = disposeEffects;\n\n // Remove x-cloak after bindings are applied (prevents FOUC)\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n });\n\n // Multi-root fragment fix: a no-body> setup page tags only the FIRST\n // top-level element with data-stx (signal-processing.ts marks one element),\n // so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text\n // never hydrated, which read as \"{{ }} doesn't work under :if/:for\". The\n // setup(s) above already populated the shared global componentScope, so\n // process each un-hydrated sibling root under that same scope \u2014 same signals,\n // so cross-root state stays coupled.\n var stxRoots = document.querySelectorAll('[data-stx]');\n if (stxRoots.length && Object.keys(componentScope).length) {\n var rootParent = stxRoots[0].parentNode;\n if (rootParent && rootParent.children) {\n Array.prototype.slice.call(rootParent.children).forEach(function(sib) {\n if (sib.nodeType !== 1) return;\n if (sib.hasAttribute('data-stx') || sib.hasAttribute('data-stx-scope')) return;\n if (sib.tagName === 'SCRIPT' || sib.tagName === 'STYLE') return;\n if (sib.__stx_disposers) return; // already processed\n var disposeSib = trackEffects(function() { processElement(sib); });\n sib.__stx_disposers = disposeSib;\n sib.removeAttribute('x-cloak');\n sib.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n }\n }\n\n // Process scoped components FIRST (their scripts have already registered scope variables)\n var allScopes = document.querySelectorAll('[data-stx-scope]');\n console.log('[stx] found', allScopes.length, 'data-stx-scope elements');\n allScopes.forEach(el => {\n const scopeId = el.getAttribute('data-stx-scope');\n console.log('[stx] scope:', scopeId, 'registered:', !!(window.stx._scopes && window.stx._scopes[scopeId]), 'el:', el.tagName);\n processedScopes.add(el);\n\n const scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n // Record the element this scope is bound to so cleanupContainer can tell a\n // dead registry entry (element replaced by an SPA swap) from a live one.\n // See sweepOrphanedScopes / #1775.\n if (scopeVars) scopeVars.__el = el;\n\n // Deferred island (#1746): its setup script (type=\"stx/island\") hasn't run\n // yet, so the scope isn't registered. Arm the hydration trigger anyway \u2014\n // processElement sees stx-hydrate and defers; deferHydration's run()\n // executes the script (registering the scope + running side-effectful\n // setup like fetches) and binds on the trigger. Reveal the HTML now.\n var isDeferredIsland = !scopeVars && el.hasAttribute && el.hasAttribute('stx-hydrate')\n && !!document.querySelector('script[data-stx-island=\"' + scopeId + '\"]');\n if (isDeferredIsland) {\n processElement(el);\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n return;\n }\n\n if (!scopeVars) return;\n\n // Forwarded props and events belong to the caller. Capture its scope\n // before this component's locals are merged, so identical child names\n // cannot shadow expressions such as :total-items=\"totalItems\".\n el.__stx_parent_scope = el.__stx_parent_scope\n || resolveComponentCallerScope(el, pageScopeSnapshot);\n bindParentComponentProps(el, el.__stx_parent_scope);\n\n // Merge component scope vars into componentScope (don't restore - keep for head elements)\n // This ensures expressions can access component variables even for elements\n // where findElementScope might not work (e.g., cloned elements not yet in DOM)\n if (scopeVars) {\n componentScope = { ...componentScope, ...scopeVars };\n }\n\n console.log('[stx] calling processElement on scope:', scopeId, 'componentScope keys:', Object.keys(componentScope).length, 'scopeVars keys:', Object.keys(scopeVars).length);\n var disposeEffects = trackEffects(function() { processElement(el); });\n el.__stx_disposers = disposeEffects;\n console.log('[stx] scope processed OK:', scopeId);\n\n // Remove x-cloak after bindings are applied\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n // Run scope-specific mount callbacks (mark mounted so _handleStxLoad\n // doesn't re-fire onMount on persistent layout scopes \u2014 see #1697).\n // EXCEPT when this scope's hydration is deferred (stx-hydrate, e.g. a\n // client=visible|idle island, #1746): processElement above only SCHEDULED\n // the work, so onMount must fire when the trigger actually hydrates the\n // scope, not now. deferHydration's run() flushes it then.\n var scopeDeferred = el.hasAttribute && el.hasAttribute('stx-hydrate') && !el.__stx_hydrated;\n // A component behind a false :if is in the document's MARKUP but not in\n // the document: bindIf detached the subtree before this walk reached it,\n // while the component's own setup script already ran and queued its\n // onMount. Mounting it from here anyway is what made being mounted\n // unusable as an open state (stacksjs/stx#2036) -- three gated modal\n // shells each locked body scroll and registered an Escape handler before\n // anything had been opened, so the page could not be scrolled and Escape\n // reached whichever instance registered last.\n //\n // Left unmounted rather than mounted-and-torn-down, so hydrateComponentScopes\n // flushes it when bindIf shows the subtree -- the same deferral\n // stx-hydrate uses above, and the same flush an island gets.\n var scopeDetached = el.isConnected === false;\n if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted && !scopeDeferred && !scopeDetached) {\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n });\n\n // Run global mount callbacks (from partial <script client> blocks that call onMount)\n // These are pushed during script execution, before DOMContentLoaded\n console.log('[stx] running global mountCallbacks:', mountCallbacks.length);\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n mountCallbacks.length = 0;\n\n // Auto-process elements with data-stx-auto (skip already processed scoped elements)\n document.querySelectorAll('[data-stx-auto]').forEach(el => {\n // Process element but skip children that are in scoped containers\n processElementSkipScopes(el, processedScopes);\n\n // Remove x-cloak after bindings are applied\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n\n // Process head> elements (title, meta) that may contain {{ }} expressions\n // Use componentScope which now contains variables from processed components\n const headElements = document.querySelectorAll('head title, head meta[content]');\n headElements.forEach(el => {\n if (el.tagName === 'TITLE') {\n const text = el.textContent;\n if (text && text.includes('{{')) {\n effect(() => {\n try {\n let result = text;\n const matches = text.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);\n if (matches) {\n matches.forEach(match => {\n const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');\n const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);\n const value = fn(...__stxArgs(fn, componentScope));\n result = result.replace(match, value != null ? value : '');\n });\n }\n el.textContent = result;\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Title expression error:', e);\n }\n });\n }\n }\nelse if (el.tagName === 'META') {\n const content = el.getAttribute('content');\n if (content && content.includes('{{')) {\n // Skip build-time placeholders like {{__TITLE__}}\n const hasOnlyPlaceholders = !content.replace(/\\{\\{\\s*__[A-Z_]+__\\s*\\}\\}/g, '').includes('{{');\n if (hasOnlyPlaceholders) return;\n effect(() => {\n try {\n let result = content;\n const matches = content.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);\n if (matches) {\n matches.forEach(match => {\n const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');\n if (/^__[A-Z_]+__$/.test(expr.trim())) return;\n const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);\n const value = fn(...__stxArgs(fn, componentScope));\n result = result.replace(match, value != null ? value : '');\n });\n }\n el.setAttribute('content', result);\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Meta expression error:', e);\n }\n });\n }\n }\n });\n\n // Everything that should have hydrated has now had its chance (#1773).\n auditHydration(document.body, 'DOMContentLoaded');\n };\n window.__stxDomReadyHandler = stxDomReadyHandler;\n console.log('[stx] registering DOMContentLoaded handler');\n document.addEventListener('DOMContentLoaded', stxDomReadyHandler);\n";
|
|
2
|
+
export declare const SIGNALS_DOM_READY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Drawer controls used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DRAWER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_DRAWER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Effects, batching, tracking, and signal utility helpers for the client runtime. */
|
|
2
|
-
export declare const SIGNALS_EFFECT_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EFFECT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Event-expression shorthand parser used by the client runtime. */
|
|
2
|
-
export declare const SIGNALS_EVENT_SHORTHAND_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EVENT_SHORTHAND_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Cached expression compilation helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_EXPRESSION_COMPILER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EXPRESSION_COMPILER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Scope lookup and expression evaluation for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_EXPRESSION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EXPRESSION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Shared HTTP transport, hooks, errors, and CSRF support for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_FETCH_TRANSPORT_RUNTIME = " // Short, ref-free repr of a value for the mutation log (so the buffer holds no\n // live references and big objects don't bloat it).\n function __stxShort(v) {\n try {\n if (typeof v === 'string') return v.length > 40 ? (v.slice(0, 40) + '\u2026') : v;\n if (v === null || typeof v !== 'object') return v;\n var s = JSON.stringify(v);\n return s.length > 60 ? (s.slice(0, 60) + '\u2026') : s;\n } catch (e) { return '[unserializable]'; }\n }\n // Wraps fetch with timing + a timeline record (the data layer's queries).\n // Turn a non-ok Response into an Error, reading the body FIRST.\n //\n // Every data primitive threw a synthesized 'HTTP nnn: statusText' before\n // touching the body, so whatever the server actually said \u2014 a validation\n // map, a rate-limit reason, an auth message \u2014 was unreachable from any stx\n // primitive, with no escape hatch (stacksjs/stx#1848). That is the single\n // most cited reason an app keeps writing raw fetch() calls.\n //\n // The body is attached rather than only interpolated: err.data is what a\n // caller needs to render field errors, and err.status is what it needs to\n // tell 401 from 500 without parsing the message.\n function __stxRawBody(body) {\n return (typeof FormData !== 'undefined' && body instanceof FormData)\n || (typeof Blob !== 'undefined' && body instanceof Blob)\n || (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams)\n || (typeof ArrayBuffer !== 'undefined' && (body instanceof ArrayBuffer || ArrayBuffer.isView(body)));\n }\n\n async function __stxHttpError(response) {\n var body = null;\n var text = '';\n try { text = await response.text(); } catch (e) { text = ''; }\n if (text) {\n try { body = JSON.parse(text); } catch (e) { body = text; }\n }\n var detail = '';\n if (body && typeof body === 'object') detail = body.message || body.error || '';\n else if (typeof body === 'string') detail = body.slice(0, 200);\n var message = 'HTTP ' + response.status;\n if (response.statusText) message += ': ' + response.statusText;\n if (detail) message += ' - ' + detail;\n var err = new Error(message);\n err.status = response.status;\n err.statusText = response.statusText;\n err.data = body;\n err.response = response;\n return err;\n }\n\n // One place an app can reach the data layer. Every stx data primitive goes\n // through __stxFetch, the only fetch call in this runtime, so a single pair\n // of hooks covers useFetch, useQuery and useMutation (#1855).\n //\n // Without it there is no way to attach an Authorization header or notice a\n // 401 in one place, which is the reason an app keeps hand-written fetch\n // calls sitting next to the primitives that were meant to replace them.\n //\n // Hooks mutate the context they are handed and their return value is\n // ignored \u2014 the ofetch shape most people will already know. Throwing from a\n // hook fails the request, which is what a token-refresh flow wants.\n var __stxFetchHooks = { onRequest: null, onResponse: null, onResponseError: null };\n\n // Double-submit CSRF, echoed for every same-origin unsafe request. A server\n // using the pattern (Stacks does, by default, on every POST/PUT/PATCH/DELETE)\n // plants a readable cookie and rejects any unsafe request whose header does\n // not repeat it. Nothing here repeated it, so a form posting through\n // useMutation - or the framework's own CMS form block - got 403 \"CSRF token\n // mismatch\" on a stock install. The same thing axios does for XSRF-TOKEN.\n // Only same-origin: the token must never leave for another host.\n var __stxCsrf = { cookie: 'X-CSRF-Token', header: 'X-CSRF-Token' };\n\n function __stxCookie(name) {\n if (typeof document === 'undefined' || !document.cookie) return null;\n var parts = document.cookie.split(';');\n for (var i = 0; i < parts.length; i++) {\n var at = parts[i].indexOf('=');\n if (at === -1) continue;\n if (parts[i].slice(0, at).trim() !== name) continue;\n var value = parts[i].slice(at + 1).trim();\n try { return value ? decodeURIComponent(value) : null; } catch (e) { return value || null; }\n }\n return null;\n }\n\n // Whether this request should carry the token: unsafe, and same-origin.\n function __stxWantsCsrf(url, opts) {\n if (!__stxCsrf) return false;\n var method = String((opts && opts.method) || 'GET').toUpperCase();\n if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS') return false;\n // A path is same-origin by definition; only an absolute URL needs its\n // origin compared, and one that cannot be parsed is not trusted.\n var target = String(url);\n if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.slice(0, 2) === '//') {\n if (typeof location === 'undefined') return false;\n try {\n if (new URL(target).origin !== location.origin) return false;\n } catch (e) { return false; }\n }\n return true;\n }\n\n // Fetch the cookie before the first unsafe request, when the page did not\n // bring one. A page served from a CDN cache cannot: the edge strips\n // Set-Cookie from a cached response, or it would hand one visitor's token to\n // everyone. So the only pages that could post a form were the ones nobody\n // cached. `csrf.prime` names a same-origin GET that sets the cookie (any\n // safe Stacks route does); one request, shared by concurrent callers, and\n // only when the cookie is missing.\n var __stxCsrfPriming = null;\n async function __stxPrimeCsrf(url, opts) {\n if (!__stxCsrf || !__stxCsrf.prime || !__stxWantsCsrf(url, opts)) return;\n if (__stxCookie(__stxCsrf.cookie)) return;\n if (!__stxCsrfPriming) {\n __stxCsrfPriming = fetch(__stxCsrf.prime, { credentials: 'same-origin', headers: { Accept: 'application/json' } })\n .then(function () {}, function () {})\n .then(function () { __stxCsrfPriming = null; });\n }\n await __stxCsrfPriming;\n }\n\n function __stxApplyCsrf(url, opts) {\n if (!__stxWantsCsrf(url, opts)) return;\n var token = __stxCookie(__stxCsrf.cookie);\n if (!token) return;\n var headers = __stxHeaders(opts.headers);\n var wanted = __stxCsrf.header.toLowerCase();\n for (var key in headers) {\n // A token the caller set on purpose wins.\n if (key.toLowerCase() === wanted) return;\n }\n headers[__stxCsrf.header] = token;\n opts.headers = headers;\n }\n\n function configureFetch(cfg) {\n cfg = cfg || {};\n // Unlike the hooks below, CSRF settings persist unless named: an app that\n // installs an Authorization hook has not asked to stop sending the token.\n // `csrf: false` turns it off; `{ cookie, header }` renames either side.\n if (Object.prototype.hasOwnProperty.call(cfg, 'csrf')) {\n __stxCsrf = cfg.csrf === false || cfg.csrf === null\n ? null\n : { cookie: (cfg.csrf && cfg.csrf.cookie) || 'X-CSRF-Token', header: (cfg.csrf && (cfg.csrf.header || cfg.csrf.cookie)) || 'X-CSRF-Token', prime: (cfg.csrf && typeof cfg.csrf.prime === 'string' && cfg.csrf.prime) || null };\n }\n // Replace rather than stack: a module re-evaluated by hot reload or by a\n // SPA script re-run must not end up with the same interceptor installed\n // twice, sending two Authorization headers or counting a 401 twice.\n __stxFetchHooks.onRequest = typeof cfg.onRequest === 'function' ? cfg.onRequest : null;\n __stxFetchHooks.onResponse = typeof cfg.onResponse === 'function' ? cfg.onResponse : null;\n // Fires for a non-ok response and for a thrown fetch (network error). If it\n // returns a Response, that Response replaces the original \u2014 this is how a\n // 401 -> refresh -> retry is expressed once instead of per call site. The\n // retry itself belongs to the hook: it should refresh the token and re-issue\n // the request with a plain fetch() (not this data layer) so it does not\n // re-enter the hook and loop. Returning nothing lets the error stand.\n __stxFetchHooks.onResponseError = typeof cfg.onResponseError === 'function' ? cfg.onResponseError : null;\n }\n\n // headers may be a function, so it can be evaluated per request rather than\n // captured once \u2014 a token that changes between calls. Object spread over a\n // function copies no own enumerable properties, so passing one used to\n // contribute nothing at all, in silence.\n function __stxHeaders(h) {\n return (typeof h === 'function' ? h() : h) || {};\n }\n\n async function __stxFetch(source, url, opts) {\n var t0 = __stxDevtoolsNow();\n opts = opts || {};\n // Before the hooks, so an onRequest hook sees (and may override) it.\n await __stxPrimeCsrf(url, opts);\n __stxApplyCsrf(url, opts);\n if (__stxFetchHooks.onRequest) {\n // Normalised first so a hook can write ctx.options.headers.Authorization\n // without having to create the bag itself.\n opts.headers = __stxHeaders(opts.headers);\n var reqCtx = { source: source, url: String(url), options: opts };\n await __stxFetchHooks.onRequest(reqCtx);\n // Reassignable, so a hook can prefix a baseURL or swap the options\n // wholesale instead of only mutating them.\n if (reqCtx.url) url = reqCtx.url;\n opts = reqCtx.options || opts;\n }\n var method = (opts && opts.method) || 'GET';\n // A hook may hand back a Response to use in place of the original. Anything\n // else (a truthy non-Response, undefined) leaves the outcome unchanged.\n function __stxIsResponse(v) { return !!v && typeof v.ok === 'boolean'; }\n try {\n var r = await fetch(url, opts);\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: r.status, ok: r.ok, ms: __stxDevtoolsNow() - t0 });\n if (__stxFetchHooks.onResponse) {\n await __stxFetchHooks.onResponse({ source: source, url: String(url), options: opts, response: r });\n }\n if (!r.ok && __stxFetchHooks.onResponseError) {\n var recovered = await __stxFetchHooks.onResponseError({ source: source, url: String(url), options: opts, response: r, error: null });\n if (__stxIsResponse(recovered)) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: recovered.status, ok: recovered.ok, retried: true, ms: __stxDevtoolsNow() - t0 });\n return recovered;\n }\n }\n return r;\n } catch (e) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: 0, ok: false, error: String((e && e.message) || e), ms: __stxDevtoolsNow() - t0 });\n // A network-level failure (no Response) also reaches the hook, so a retry\n // can cover a dropped connection, not only an auth status.\n if (__stxFetchHooks.onResponseError) {\n var recoveredErr = await __stxFetchHooks.onResponseError({ source: source, url: String(url), options: opts, response: null, error: e });\n if (__stxIsResponse(recoveredErr)) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: recoveredErr.status, ok: recoveredErr.ok, retried: true, ms: __stxDevtoolsNow() - t0 });\n return recoveredErr;\n }\n }\n throw e;\n }\n }";
|
|
2
|
+
export declare const SIGNALS_FETCH_TRANSPORT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Reactive list binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_FOR_RUNTIME = " function bindFor(el, passedScope = componentScope, attrName = '@for') {\n if (el.__stx_for_bound) return;\n el.__stx_for_bound = true;\n const expr = el.getAttribute(attrName);\n // Support: \"item in list\", \"item, index in list\", \"(item, index) in list\"\n const match = expr.match(/^\\s*\\(?\\s*(\\w+)(?:\\s*,\\s*(\\w+))?\\s*\\)?\\s+(?:in|of)\\s+(.+)\\s*$/);\n\n if (!match) {\n console.warn('[STX] Invalid ' + attrName + ':', expr);\n return;\n }\n\n const [, itemName, indexName, listExpr] = match;\n let parent = el.parentNode;\n\n // Guard: if element has no parent, it's detached - skip processing\n if (!parent) {\n console.warn('[STX] bindFor: element has no parent, skipping');\n return;\n }\n\n const placeholder = stxHost.anchor('stx-for');\n const isTemplate = el.tagName === 'TEMPLATE';\n const componentSetupTemplates = [];\n if (!isTemplate && el.hasAttribute('data-stx-scope')) {\n const componentScopeId = el.getAttribute('data-stx-scope');\n const componentTemplateScopeId = el.getAttribute('data-stx-template-scope') || componentScopeId;\n let setupSibling = el.nextSibling;\n while (setupSibling) {\n const nextSetupSibling = setupSibling.nextSibling;\n if (setupSibling.nodeType === Node.TEXT_NODE && !(setupSibling.textContent || '').trim()) {\n setupSibling = nextSetupSibling;\n continue;\n }\n if (setupSibling.nodeType === Node.COMMENT_NODE) {\n setupSibling = nextSetupSibling;\n continue;\n }\n if (setupSibling.nodeType === Node.ELEMENT_NODE\n && setupSibling.tagName === 'SCRIPT'\n && setupSibling.hasAttribute('data-stx-scoped')\n && ((setupSibling.textContent || '').indexOf(componentScopeId) !== -1\n || (componentTemplateScopeId && (setupSibling.textContent || '').indexOf(componentTemplateScopeId) !== -1))) {\n componentSetupTemplates.push(stxHost.clone(setupSibling));\n stxHost.remove(setupSibling);\n setupSibling = nextSetupSibling;\n continue;\n }\n break;\n }\n }\n\n // Check if element also has @if / :if - need to handle together\n const ifExpr = el.getAttribute('@if') || el.getAttribute(':if');\n\n // Feature #3: Check for @loading and @empty siblings/content\n const loadingExpr = el.getAttribute('@loading');\n const emptyExpr = el.getAttribute('@empty');\n\n // Look for sibling elements with @for-loading or @for-empty\n let loadingTemplate = null;\n let emptyTemplate = null;\n\n // Check next siblings for @for-loading and @for-empty\n let sibling = el.nextElementSibling;\n while (sibling) {\n if (sibling.hasAttribute('@for-loading')) {\n loadingTemplate = stxHost.clone(sibling);\n loadingTemplate.removeAttribute('@for-loading');\n stxHost.remove(sibling);\n sibling = el.nextElementSibling;\n continue;\n }\n if (sibling.hasAttribute('@for-empty')) {\n emptyTemplate = stxHost.clone(sibling);\n emptyTemplate.removeAttribute('@for-empty');\n stxHost.remove(sibling);\n sibling = el.nextElementSibling;\n continue;\n }\n break;\n }\n\n // Capture the scope NOW before element is removed from DOM\n const capturedScope = findElementScope(el) || findElementScope(parent);\n\n stxHost.insert(parent, placeholder, el);\n // Component setup scripts execute while the server-rendered loop source is\n // still in the document. That source becomes a template, not a live\n // instance, so reclaim all registered scopes before removing it. Every\n // rendered iteration receives remapped setup scripts and fresh scopes.\n disposeSubtreeScopes(el);\n stxHost.remove(el);\n\n // Capture :key expression BEFORE removing the attribute\n const keyExpr = el.getAttribute(':key') || el.getAttribute('x-bind:key');\n\n // For <template> elements, use the content; otherwise clone the element\n let templateContent;\n if (isTemplate) {\n templateContent = el.content;\n deferRowConditionals(templateContent);\n }\nelse {\n // Before the source is cloned into the row template, so that clone does\n // not build the conditional elements either.\n deferRowConditionals(el);\n const wrapper = stxHost.clone(el);\n wrapper.removeAttribute('@for');\n wrapper.removeAttribute(':for');\n wrapper.removeAttribute('x-for');\n wrapper.removeAttribute('@loading');\n wrapper.removeAttribute('@empty');\n wrapper.removeAttribute(':key');\n wrapper.removeAttribute('x-bind:key');\n // Also remove @if / :if / x-if - we'll handle it inline\n if (ifExpr) { wrapper.removeAttribute('@if'); wrapper.removeAttribute(':if'); wrapper.removeAttribute('x-if'); }\n templateContent = wrapper;\n }\n\n let currentElements = [];\n // One entry per list item, each holding EVERY node that item rendered.\n // currentElements stays flat for transition snapshots, but the keyed\n // diff below must pair a key with all of its nodes: a template row\n // routinely yields several (an element plus its surrounding text nodes),\n // and indexing a flat list by key position then paired the wrong node\n // with each key, leaving the list rotated after an update.\n let currentGroups = [];\n let currentKeys = [];\n let loadingElement = null;\n let emptyElement = null;\n\n // A <template :for> can contain another structural directive. That\n // nested directive replaces its source node with a placeholder and owns\n // additional live siblings around that placeholder. Track an explicit\n // boundary for every template iteration so keyed reuse moves the complete\n // live range, including nodes created by nested :for / :if bindings.\n // Moving only the original cloned nodes pulled static siblings past the\n // nested range on the next outer update (header, then rows became rows,\n // then header).\n const liveGroupNodes = (group) => {\n if (!isTemplate || !group || group.length < 2) return group || [];\n const start = group[0];\n const end = group[group.length - 1];\n if (!start || !end || start.parentNode !== parent || end.parentNode !== parent)\n return group.filter(groupNode => groupNode && groupNode.parentNode === parent);\n\n const nodes = [];\n let currentNode = start;\n while (currentNode) {\n nodes.push(currentNode);\n if (currentNode === end) break;\n currentNode = currentNode.nextSibling;\n }\n return nodes;\n };\n\n const removeGroup = (group) => {\n const liveNodes = liveGroupNodes(group);\n const liveSet = new Set(liveNodes);\n liveNodes.forEach(e => { disposeSubtreeEffects(e); disposeSubtreeScopes(e); stxHost.remove(e); });\n group.forEach(groupNode => {\n if (liveSet.has(groupNode)) return;\n disposeSubtreeEffects(groupNode);\n disposeSubtreeScopes(groupNode);\n stxHost.remove(groupNode);\n });\n };\n\n const clearRenderedItems = () => {\n currentGroups.forEach(removeGroup);\n currentElements = [];\n currentGroups = [];\n currentKeys = [];\n };\n\n // Helper to evaluate with captured scope (auto-unwraps signals)\n // NOTE: This eagerly reads ALL signals in scope \u2014 use evalLazy inside effects\n // to avoid over-broad dependency tracking.\n const evalExpr = (expression, extraScope = {}) => {\n try {\n // Skip placeholder expressions like __TITLE__ (build-time placeholders)\n if (/^__[A-Z_]+__$/.test(expression.trim())) {\n return expression;\n }\n // Use passedScope instead of componentScope to preserve context through nested processing\n const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };\n const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {\n if (typeof prop !== 'string') return false;\n return expressionCallsSignal(expression, prop)\n || expressionUsesSignalApi(expression, prop);\n });\n const fn = __stxCompileScoped(scope, [], 'return ' + expression);\n return fn(...__stxArgs(fn, unwrapScope));\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);\n return '';\n }\n };\n\n // Lazy eval: uses with() so only variables ACTUALLY ACCESSED by the expression\n // trigger signal reads. This prevents unrelated signals (like modalOpen) from\n // being tracked as dependencies when we only care about the list signal.\n const evalLazy = (expression, extraScope = {}) => {\n try {\n if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;\n const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };\n const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {\n if (typeof prop !== 'string') return false;\n return expressionCallsSignal(expression, prop)\n || expressionUsesSignalApi(expression, prop);\n });\n // Compiled over the names the expression mentions (__stxCompileScoped),\n // so only those are read and register as dependencies. It used with()\n // over the proxy, which JavaScriptCore resolves through proxy traps on\n // every identifier - 36x slower than V8 for a list of message rows.\n const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');\n return fn(...__stxArgs(fn, unwrapScope));\n } catch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);\n return '';\n }\n };\n\n // Helper to show loading state\n const showLoading = () => {\n hideLoading();\n hideEmpty();\n if (loadingTemplate) {\n loadingElement = stxHost.clone(loadingTemplate);\n stxHost.insert(parent, loadingElement, placeholder);\n }\n };\n\n // Helper to hide loading state\n const hideLoading = () => {\n if (loadingElement) {\n stxHost.remove(loadingElement);\n loadingElement = null;\n }\n };\n\n // Helper to show empty state\n const showEmpty = () => {\n hideLoading();\n hideEmpty();\n if (emptyTemplate) {\n emptyElement = stxHost.clone(emptyTemplate);\n stxHost.insert(parent, emptyElement, placeholder);\n const shownEmpty = emptyElement;\n shownEmpty.__stx_effect_disposers = trackEffects(function() { processElement(shownEmpty); });\n }\n };\n\n // Helper to hide empty state\n const hideEmpty = () => {\n if (emptyElement) {\n // A string @empty renders a text node, which has no subtree to dispose.\n if (emptyElement.nodeType === 1) disposeSubtreeEffects(emptyElement);\n stxHost.remove(emptyElement);\n emptyElement = null;\n }\n };\n\n // Helper: create DOM element(s) for a single list item.\n // The item is wrapped in a signal so bindings track it reactively. The pair\n // rides on the returned group, so reuse always reaches the signals the\n // bindings of THAT row actually read. A Map from key to signals could not:\n // two rows sharing a key overwrote each other in it, and the row that\n // reused the surviving entry was then bound to a signal nothing updated.\n const createItemElements = (item, index, key) => {\n const itemSignal = state(item);\n itemSignal._isStxLoopItem = true;\n const indexSignal = state(index);\n\n const itemScope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };\n itemScope[itemName] = itemSignal;\n if (indexName) itemScope[indexName] = indexSignal;\n\n const elements = [];\n if (isTemplate) {\n elements.push(stxHost.anchor('stx-for-item-start'));\n Array.from(templateContent.childNodes).forEach(node => {\n const clone = stxHost.clone(node);\n if (clone.nodeType === 1) {\n // Structural directives need a live parent. Keep the iteration\n // scope on the clone until the keyed diff inserts it, then bind.\n clone.__stx_for_scope = itemScope;\n markLoopRow(clone, itemName, itemSignal);\n }\n elements.push(clone);\n });\n elements.push(stxHost.anchor('stx-for-item-end'));\n } else {\n const clone = stxHost.clone(templateContent);\n clone.__stx_for_scope = itemScope;\n markLoopRow(clone, itemName, itemSignal);\n elements.push(clone);\n componentSetupTemplates.forEach(function(setupTemplate) {\n elements.push(stxHost.clone(setupTemplate));\n });\n }\n remapForComponentScopes(elements);\n elements.__stx_signals = { item: itemSignal, index: indexSignal };\n return elements;\n };\n\n // Helper: compute key for an item\n const getItemKey = (item, index) => {\n if (!keyExpr) return String(index);\n try {\n const scope = { [itemName]: item };\n if (indexName) scope[indexName] = index;\n const fn = __stxCompile([itemName, indexName || '_idx'], 'return ' + keyExpr);\n return String(fn(item, index));\n } catch (e) {\n return String(index);\n }\n };\n\n effect(() => {\n parent = followPlaceholder(placeholder, parent);\n // Use evalLazy for the list expression \u2014 only tracks the list signal,\n // not every signal in the component scope. This prevents unrelated\n // signals (modalOpen, menuOpen, etc.) from triggering a full rebuild.\n // Check loading state if @loading attribute provided (Feature #3)\n if (loadingExpr) {\n const isLoading = evalLazy(loadingExpr);\n if (isLoading) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n showLoading();\n return;\n }\n }\n\n hideLoading();\n\n // Evaluate list with LAZY tracking \u2014 only the list signal is tracked\n let list = evalLazy(listExpr);\n\n // Tolerate parens-on-signal in the list expression.\n // :for=\"x in store.signal\" --> works (bare-ref, auto-unwrapped)\n // :for=\"x in store.signal()\" --> silently iterated zero, because\n // the proxy unwraps the signal to\n // the array on access, then the\n // trailing call throws TypeError\n // which evalLazy's catch swallows.\n // Retry without the trailing parens so both forms succeed.\n //\n // This runtime is emitted as a TEMPLATE LITERAL, so every backslash here\n // must be DOUBLED to survive into the shipped string. A regex literal\n // crosses only that one layer (doubled escapes ship intact). A\n // new RegExp('...') string crosses a SECOND layer too \u2014 the browser's\n // string-literal parse strips the escapes again \u2014 collapsing the pattern\n // to a bare-letter match that never fires (stacksjs/stx#1748). So use a\n // regex literal, not new RegExp(string), for patterns with backslashes.\n var trailingParens = /\\(\\s*\\)\\s*$/;\n if (!Array.isArray(list) && trailingParens.test(listExpr)) {\n list = evalLazy(listExpr.replace(trailingParens, ''));\n }\n // Second-chance fallback: if the retry returned a signal /\n // derived function (the proxy failed to auto-unwrap, which\n // can happen when the resolved owning object lacks the\n // _isStxStore marker \u2014 e.g. ad-hoc objects, locally-imported\n // shapes), call it manually. Defensive: cheap when it would\n // already be an array, useful when the proxy missed.\n if (!Array.isArray(list) && typeof list === 'function' && (list._isSignal || list._isDerived)) {\n try { list = list(); } catch { /* swallow - the warning below surfaces it */ }\n }\n\n // If there's an @if condition, check it\n if (ifExpr) {\n const ifValue = evalLazy(ifExpr);\n if (!ifValue) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n hideEmpty();\n return;\n }\n }\n\n if (!Array.isArray(list)) {\n // Silent return here used to mask a class of real misuse:\n // most often a signal call that threw mid-expression, or a\n // :for over undefined from a typo. One warn line saves a lot\n // of \"list rendered no rows despite the data being there\"\n // debugging cycles.\n //\n // Diagnostic: dump the scope identifiers so the caller can see\n // whether the expression's root identifier was in scope at all\n // (and if so, what type it was and whether it carried the\n // _isStxStore marker). Only fires on the warn path, which is\n // rare, so the extra Object.keys / spread cost is negligible.\n var diagScope;\n var rootName = '?';\n var rootInScope = true;\n var rootVal;\n try {\n var diagMerged = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };\n var firstIdent = listExpr.match(/^[A-Za-z_$][\\w$]*/);\n rootName = firstIdent ? firstIdent[0] : '?';\n rootInScope = Object.prototype.hasOwnProperty.call(diagMerged, rootName);\n rootVal = rootInScope ? diagMerged[rootName] : '<NOT-IN-SCOPE>';\n var rootKeys = (rootVal && typeof rootVal === 'object')\n ? Object.keys(rootVal).slice(0, 8).join(',')\n : '-';\n diagScope = '[root=' + rootName + ' inScope=' + rootInScope + ' type=' + (typeof rootVal) + ' isStxStore=' + !!(rootVal && rootVal._isStxStore) + ' keys=' + rootKeys + ']';\n }\n catch (_e) { diagScope = '[diag-error]'; rootInScope = true; }\n\n /*\n * Name the cause rather than guessing at it (stacksjs/stx#2051).\n *\n * This used to end with \"If this is a signal call, try the bare\n * reference\" every single time. In the most common failure the\n * identifier is not a signal at all -- it is a bare name the client\n * scope has never heard of, usually a declaration from a\n * script-server block, which :for cannot see because it is expanded\n * on the client. The hint sent people to the wrong layer: one app\n * read it, concluded the signals-and-:for pattern was unreliable, and\n * was rebuilt on hand-written getElementById wiring.\n *\n * The scope dump already answered the question -- inScope=false was\n * right there, ahead of the guess -- so lead with it, and keep the\n * signal advice for when the value really is a signal, which is the\n * one case where it applies.\n */\n var advice;\n if (!rootInScope) {\n advice = 'Nothing named ' + rootName + ' is in the client scope. A script-server declaration is not available here: :for is expanded on the client. '\n + 'Either wrap it in state() inside a script-client block, or iterate it with the server-side @foreach(' + rootName + ' as item).';\n }\n else if (typeof rootVal === 'function' && (rootVal._isSignal || rootVal._isDerived)) {\n advice = rootName + ' is a signal, so try the bare reference: ' + rootName + ' instead of ' + rootName + '().';\n }\n else {\n advice = rootName + ' resolved to a ' + (typeof rootVal) + ', not an array.';\n }\n console.warn('[STX] :for expected an array; got ' + (list === '' ? 'empty/error' : typeof list) + ' for expression \"' + listExpr + '\". ' + diagScope + ' ' + advice);\n return;\n }\n\n // Check empty state (Feature #3)\n if (list.length === 0) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n if (emptyExpr) {\n const emptyContent = evalLazy(emptyExpr);\n // Held in the same slot the @for-empty template uses, so hideEmpty\n // takes it away when the list fills and a second empty render\n // replaces it instead of stacking another one. It used to go into\n // currentElements, which teardown does not walk -- it walks\n // currentGroups -- so the text stayed in the document forever: an\n // empty list that filled read \"Nothing herea\".\n hideEmpty();\n if (emptyContent && typeof emptyContent === 'string') {\n emptyElement = document.createTextNode(emptyContent);\n stxHost.insert(parent, emptyElement, placeholder);\n }\n } else if (emptyTemplate) {\n showEmpty();\n }\n return;\n }\n\n hideEmpty();\n\n // \u2500\u2500 <TransitionGroup> detection (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Active only when the list's parent is a [data-stx-transition-group]\n // AND it has already rendered once (no enter animation on first mount).\n // tgReady gates ALL animation work, so plain :for lists are untouched.\n var tgIsGroup = !!(parent && parent.hasAttribute && parent.hasAttribute('data-stx-transition-group'));\n var tgName = tgIsGroup ? (parent.getAttribute('data-stx-transition-group') || 'v') : null;\n var tgReady = tgIsGroup && !!parent.__stx_tg_init;\n var tgFirst = tgReady ? tgSnapshot(currentElements) : null;\n\n // \u2500\u2500 Key-based diffing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Build new key list\n const newKeys = list.map((item, i) => getItemKey(item, i));\n\n // Build old key \u2192 element(s) map\n const oldKeyMap = new Map();\n for (let i = 0; i < currentKeys.length; i++) {\n const k = currentKeys[i];\n if (!oldKeyMap.has(k)) oldKeyMap.set(k, []);\n oldKeyMap.get(k).push(currentGroups[i] || []);\n }\n\n // Build new element list, reusing existing DOM nodes by key\n const newElements = [];\n const newGroups = [];\n // Keys seen in THIS pass, for the duplicate warning only. Reuse is decided\n // by whether a group under the key is still unconsumed, not by whether the\n // key has been seen: gating it on the key made every duplicate occurrence\n // build a NEW group, while the removal pass below skipped the key as used\n // and left the old ones in the document. The list grew by one row on every\n // update, without bound, and the first duplicate stayed bound to a signal\n // the reconciliation never wrote to.\n const seenKeys = new Set();\n let warnedDuplicateKey = false;\n\n // Minimal-move reconciliation.\n //\n // Every reused row used to be round-tripped through a DocumentFragment,\n // and appendChild into a fragment DETACHES the node from the document\n // first. Removing a focused node blurs it and resets activeElement, so a\n // list could not contain a field the user was typing in: any write to the\n // backing array kicked them out of it, losing caret, selection and undo\n // history. It happened for every row unconditionally, including rows that\n // had not moved, and unkeyed loops took the same path because getItemKey\n // falls back to the index (#1882).\n //\n // The cursor walks the existing rendering in order. A node already at the\n // cursor is left ENTIRELY alone \u2014 an unchanged list now performs zero DOM\n // operations \u2014 and a node that genuinely has to move is moved with\n // insertBefore, which relocates it without a detach/reattach cycle.\n let cursor = null;\n for (let ci = 0; ci < currentGroups.length && !cursor; ci++) {\n const seed = liveGroupNodes(currentGroups[ci] || []);\n if (seed.length) cursor = seed[0];\n }\n\n for (let i = 0; i < list.length; i++) {\n const key = newKeys[i];\n const existing = oldKeyMap.get(key);\n\n if (seenKeys.has(key) && !warnedDuplicateKey) {\n warnedDuplicateKey = true;\n console.warn('[STX] :for has more than one item with the key ' + key + '. Rows are matched in order, so give each item a key of its own.');\n }\n seenKeys.add(key);\n\n if (existing && existing.length > 0) {\n // Reuse this item's nodes \u2014 move the whole group into position, in\n // order, so a multi-node row stays contiguous and correctly ordered.\n // A structural directive may intentionally have detached one of the\n // group's nodes. Its own placeholder owns reinsertion, so keyed reuse\n // must not resurrect that hidden node.\n const group = existing.shift();\n const liveNodes = liveGroupNodes(group);\n for (let li = 0; li < liveNodes.length; li++) {\n const groupNode = liveNodes[li];\n if (groupNode === cursor) {\n // Already exactly where it belongs. Touching it here is what\n // used to blur it, so the correct action is to do nothing.\n cursor = cursor.nextSibling;\n }\n else {\n // Moves without detaching. The cursor does not advance: this node\n // is now behind it, and the cursor still marks the next position\n // to fill.\n stxHost.insert(parent, groupNode, cursor || placeholder);\n }\n }\n newElements.push(...group);\n newGroups.push(group);\n // Update the item signal so bindings re-evaluate with new data.\n // This is the fix for #1669 \u2014 without this, reused elements show\n // stale data because the old bindings captured the old item via closure.\n const signals = group.__stx_signals;\n if (signals) {\n signals.item.set(list[i]);\n signals.index.set(i);\n }\n } else {\n // New item \u2014 create DOM elements with a fresh item signal\n const elements = createItemElements(list[i], i, key);\n elements.forEach(el => {\n // Before the cursor, not before the placeholder: a new row inserted\n // in the MIDDLE of the list must land at its own position, without\n // forcing every row after it to be moved to get back in order.\n stxHost.insert(parent, el, cursor || placeholder);\n if (tgReady && el.isConnected) tgEnter(el, tgName);\n });\n hydrateComponentScopes(elements, elements.find(function(node) {\n return node && node.__stx_for_scope;\n })?.__stx_for_scope || passedScope);\n elements.forEach(el => {\n if (el.nodeType === 1) {\n var itemScope = el.__stx_for_scope || passedScope;\n delete el.__stx_for_scope;\n // Tracked so removeGroup can dispose the row's effects (#1954). Kept\n // off __stx_disposers, which marks a hydrated component root here\n // and in the deferred :if pass.\n if (!el.__stx_disposers && el.tagName !== 'SCRIPT')\n el.__stx_effect_disposers = trackEffects(function() { processElement(el, itemScope); });\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));\n }\n });\n newElements.push(...elements);\n newGroups.push(elements);\n }\n }\n\n // Remove old elements whose keys are no longer in the list.\n // Dispose any scopes registered inside removed items before the\n // remove() call (#1727).\n // Whatever is still in here was not consumed above -- either the key left\n // the list, or the list now has fewer rows under that key than it did.\n // The test used to be \"this key was never used\", which could not see the\n // second case, so a duplicate key's leftover rows stayed on screen.\n for (const groups of oldKeyMap.values()) {\n if (groups.length > 0) {\n // In a transition group, run the leave animation and let it remove the\n // node; otherwise remove immediately. Scopes are disposed up-front\n // either way (their destroy hooks shouldn't wait on a CSS transition).\n groups.forEach((group) => {\n if (tgReady) {\n const liveNodes = liveGroupNodes(group);\n const transitioned = new Set();\n liveNodes.forEach((el) => {\n disposeSubtreeEffects(el);\n disposeSubtreeScopes(el);\n if (tgLeave(el, tgName)) transitioned.add(el);\n else stxHost.remove(el);\n });\n group.forEach((el) => {\n if (transitioned.has(el) || liveNodes.includes(el)) return;\n disposeSubtreeEffects(el);\n disposeSubtreeScopes(el);\n stxHost.remove(el);\n });\n }\n else {\n removeGroup(group);\n }\n });\n // The row's signals went with its group, so there is no key-indexed\n // map left to prune here.\n }\n }\n\n currentElements = newElements;\n currentGroups = newGroups;\n currentKeys = newKeys;\n\n // \u2500\u2500 <TransitionGroup> play (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // FLIP the surviving elements from their snapshotted positions, then mark\n // the group rendered so the next update animates.\n if (tgReady && tgFirst) tgFlip(newElements, tgFirst, tgName);\n if (tgIsGroup) parent.__stx_tg_init = true;\n });\n }\n";
|
|
2
|
+
export declare const SIGNALS_FOR_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Browser-global aliases used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_GLOBALS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_GLOBALS_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Signal-aware event expression handling for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_HANDLER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HANDLER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Client-side document head and SEO helpers. */
|
|
2
|
-
export declare const SIGNALS_HEAD_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HEAD_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Formatting helpers and object dependency tracking used by client bindings. */
|
|
2
|
-
export declare const SIGNALS_HELPERS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HELPERS_RUNTIME: string;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* DOM. The leading indentation and trailing blank line are intentional: this
|
|
7
7
|
* fragment is interpolated directly into the generated runtime.
|
|
8
8
|
*/
|
|
9
|
-
export declare const SIGNALS_HOST_RUNTIME
|
|
9
|
+
export declare const SIGNALS_HOST_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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";
|
|
2
|
+
export declare const SIGNALS_HYDRATION_AUDIT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Dynamic subtree hydration used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_HYDRATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HYDRATION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Reactive if/else-if/else chain binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_IF_CHAIN_RUNTIME = " // Reactive if/else-if/else chain. A single effect drives mutual exclusion:\n // on each run it picks the first branch whose condition is truthy (the\n // trailing x-else always matches), inserts that branch, and removes\n // whichever branch was previously shown. One effect for the whole chain\n // means branches can't transiently both render or both vanish in a tick,\n // and a single source signal isn't subscribed N times. See #1734.\n function bindIfChain(chain, passedScope = componentScope) {\n var head = chain[0].el;\n if (head.__stx_if_bound) { console.log('[stx] bindIfChain SKIPPED (head already bound):', head.tagName, chain.map(function(c) { return c.attr; }).join(',')); return; }\n console.log('[stx] bindIfChain entry:', head.tagName, 'branches:', chain.map(function(c) { return c.attr; }).join(','));\n\n var parent = head.parentNode;\n if (!parent) { console.warn('[STX] bindIfChain: head element has no parent, skipping'); return; }\n\n var capturedComponentScope = { ...passedScope };\n\n // Detach every branch up-front, leaving a positional placeholder comment\n // so reinsertion preserves source order. Mark each as a chain member so\n // the parent's snapshot child-iteration skips the detached (non-active)\n // branches instead of bringing their content to life. The active branch\n // is re-inserted below and IS connected, so it processes normally.\n chain.forEach(function(b) {\n preserveConditionalComponentScopes(b.el, capturedComponentScope);\n b.el.__stx_if_bound = true;\n b.el.__stx_chain_member = true;\n b.el.__stx_chain_active = false;\n b.el.__stx_if_visible = state(false);\n b.capturedElementScope = findElementScope(b.el);\n b.placeholder = stxHost.anchor('stx-if-chain');\n stxHost.insert(parent, b.placeholder, b.el);\n b.el.removeAttribute(b.attr);\n // A <template> branch (the wrapper convertSignalDirectivesToAttributes\n // emits for a multi-child / text branch) is INERT \u2014 inserting the element\n // renders nothing, its content lives in a document fragment. Clone that\n // content ONCE into a stable node set we toggle in and out, exactly as\n // bindIf/bindFor already do for template elements. An element branch is\n // its own single node. Without this, a multi-element @else / @else-if\n // branch rendered blank the moment the markup was well-formed enough to\n // survive as a real <template> (the #1784 markup fix). See #1784.\n b.isTemplate = b.el.tagName === 'TEMPLATE';\n // A template branch renders CLONES, re-cloned on every show, and marks\n // where they end -- the same contract the single-template :if got in\n // #1955. Its content was cloned once here and that one node set was\n // toggled in and out, which broke two ways as soon as the branch held a\n // structural directive: a :for inside it replaces its own source element\n // with a placeholder comment and renders rows as SIBLINGS, so hiding\n // removed neither (the rows were never in this list, and the source node\n // it did hold was already detached, so the parentNode guard skipped it)\n // and both branches stayed on screen at once. Re-showing then re-inserted\n // that source element, painting the literal text of its interpolations.\n // An element branch still owns exactly the node it was bound to: whatever\n // a directive inside it renders is inside that element.\n // Snapshot the content BEFORE anything processes it, and clone each show\n // from the snapshot rather than from the live template. A nested :for\n // does not leave content pristine -- processing moves its row source out\n // and the attributes it consumed (x-model, :id) do not come back -- so a\n // second clone taken from the element would arrive already stripped, with\n // no binding and no way to acquire one.\n b.pristine = b.isTemplate ? stxHost.clone(b.el.content) : null;\n b.nodes = b.isTemplate ? [] : [b.el];\n b.endMarker = null;\n stxHost.remove(b.el);\n b.childrenProcessed = false;\n });\n\n // Per-branch evaluator. Evaluated inside the chain effect via with()\n // (like evalLazy) so ONLY the signals the expression actually references\n // register as dependencies \u2014 not every signal in scope. The old form\n // (new Function(...Object.keys(scope)) called with ...Object.values of\n // the unwrap proxy) read every scope value through the proxy to build the\n // positional args, subscribing the effect to ALL scope signals, so it\n // re-ran on every unrelated mutation (#1738). with() only triggers the\n // proxy's get-trap for identifiers the expression names.\n //\n // Two passes, same as bindIf (#1733): proxy pass first (so bare-ref\n // comparisons like count === 0 read the signal as a value), raw-scope\n // retry second (so call-syntax like count() === 0 works \u2014 the proxy\n // would have unwrapped count to a value, making count() throw).\n function evalBranch(b) {\n var expression = b.expr;\n if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;\n var scope = { ...globalHelpers, ...capturedComponentScope, ...(b.capturedElementScope || {}) };\n try {\n var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);\n // Compiled over the names the expression mentions (see __stxCompileScoped).\n var fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');\n return fn(...__stxArgs(fn, unwrapScope));\n }\ncatch (e1) {\n try {\n var fn2 = __stxCompileScoped(scope, [], 'return ' + expression + '');\n return fn2(...__stxArgs(fn2, scope));\n }\ncatch (e2) {\n if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);\n return '';\n }\n }\n }\n\n var currentIdx = -1;\n\n effect(function() {\n // Evaluate EVERY branch's condition each run (not for-break) so the\n // reactive tracker registers dependencies on exactly the signals the\n // branch expressions reference \u2014 and on ALL of them, so a transition\n // from a later branch back to an earlier one still re-fires. Then pick\n // the first truthy branch (terminal x-else always matches).\n //\n // Pre-fix (#1738) this used a for-break picker, which only subscribed\n // to signals up to the first truthy branch; to stay correct it then\n // eagerly read EVERY signal in scope \u2014 a sledgehammer that re-ran this\n // effect on every unrelated signal mutation in the scope (50+ no-op\n // runs per page load on real apps). Evaluating all branches subscribes\n // narrowly to just the branch signals instead.\n var pickedIdx = -1;\n for (var i = 0; i < chain.length; i++) {\n var b = chain[i];\n var matched = b.terminal ? true : !!evalBranch(b);\n if (matched && pickedIdx === -1) pickedIdx = i;\n }\n\n console.log('[stx] bindIfChain pick:', pickedIdx, 'of', chain.length, '(', pickedIdx >= 0 ? chain[pickedIdx].attr : 'none', ') prev:', currentIdx);\n if (__stxDevtoolsTracking) {\n var __ifScope = null;\n try { __ifScope = stxHost.scopeOf(head); } catch (e) { __ifScope = null; }\n __stxDevtoolsRecordIf({\n scopeId: __ifScope ? __ifScope.getAttribute('data-stx-scope') : null,\n branches: chain.map(function(c) { return c.attr; }),\n picked: pickedIdx,\n pickedAttr: pickedIdx >= 0 ? chain[pickedIdx].attr : null,\n prev: currentIdx\n });\n }\n if (pickedIdx === currentIdx) return;\n\n // Remove the previously-shown branch. Do NOT disposeSubtreeScopes here:\n // a chain branch is a TOGGLE (re-shown when its condition matches again),\n // not a permanent unmount, and a nested data-stx-scope inside it can't be\n // recreated once deleted from window.stx._scopes (its setup IIFE ran\n // once at page load). Deleting it broke re-show of nested scoped\n // components under reactive conditionals (#1737). Permanent disposal is\n // still handled by bindFor (item removal) and cleanupContainer (SPA nav).\n if (currentIdx !== -1) {\n var gone = chain[currentIdx];\n gone.el.__stx_chain_active = false;\n gone.el.__stx_if_visible.set(false);\n // Unmount what the branch held, as a single :if does, before any of\n // it leaves the page.\n var leavingNodes = gone.nodes.filter(function (n) { return n.parentNode; });\n if (gone.isTemplate && gone.endMarker && gone.endMarker.parentNode) {\n leavingNodes = [];\n for (var walk = gone.placeholder.nextSibling; walk && walk !== gone.endMarker; walk = walk.nextSibling) leavingNodes.push(walk);\n }\n suspendSubtreeScopes(leavingNodes);\n\n if (gone.isTemplate) {\n // Everything this branch rendered goes, not just the clones it owns:\n // a nested :for or :if renders siblings of its own that no clone list\n // contains. The marker bounds the range, so a sibling that belongs to\n // a later branch or to ordinary markup is never touched.\n if (gone.endMarker && gone.endMarker.parentNode) {\n var doomed = gone.placeholder.nextSibling;\n while (doomed && doomed !== gone.endMarker) {\n var nextDoomed = doomed.nextSibling;\n disposeSubtreeEffects(doomed);\n stxHost.remove(doomed);\n doomed = nextDoomed;\n }\n stxHost.remove(gone.endMarker);\n gone.endMarker = null;\n }\n gone.nodes.forEach(function (n) {\n if (!n.parentNode) return;\n disposeSubtreeEffects(n);\n stxHost.remove(n);\n });\n // The next show clones afresh and processes again, so these effects\n // are finished with; leaving them bound only accumulates work (#1954).\n if (typeof gone.el.__stx_chain_disposers === 'function') {\n try { gone.el.__stx_chain_disposers(); }\ncatch (e) { /* a disposer of its own is not this branch's problem */ }\n gone.el.__stx_chain_disposers = null;\n }\n gone.nodes = [];\n gone.childrenProcessed = false;\n }\n else {\n gone.nodes.forEach(function (n) {\n if (!n.parentNode) return;\n // Detached nodes are out of reach of a DOM walk, so a row removed\n // while this branch is hidden could not dispose the effects it was\n // processed with (#1954). Same registry the single-element :if uses.\n var parentEl = n.parentNode;\n if (!parentEl.__stx_detached_if) parentEl.__stx_detached_if = new Set();\n parentEl.__stx_detached_if.add(n);\n stxHost.remove(n);\n });\n }\n }\n\n // Insert + process the newly-picked branch.\n if (pickedIdx !== -1) {\n var pick = chain[pickedIdx];\n pick.el.__stx_chain_active = true;\n // Insert this branch's node(s) before the placeholder's next sibling.\n // The anchor is captured once so the nodes stack in source order.\n var anchor = pick.placeholder.nextSibling;\n var pickHost = pick.placeholder.parentNode;\n if (pick.isTemplate && pick.nodes.length === 0)\n pick.nodes = Array.prototype.slice.call(stxHost.clone(pick.pristine).childNodes);\n pick.nodes.forEach(function (n) {\n if (pickHost.__stx_detached_if) pickHost.__stx_detached_if.delete(n);\n stxHost.insert(pickHost, n, anchor);\n });\n pick.el.__stx_if_visible.set(true);\n // Bound AFTER the clones, so hiding can remove whatever a structural\n // directive inside the branch renders as their sibling.\n if (pick.isTemplate) {\n if (!pick.endMarker) pick.endMarker = stxHost.anchor('stx-if-chain-end');\n stxHost.insert(pickHost, pick.endMarker, anchor);\n }\n pick.el.__stx_shown_at = performance.now();\n // An element branch shown before keeps its bindings and its scopes;\n // the components in it mount again (a template branch is cloned afresh\n // and mounts through hydrateComponentScopes below).\n if (pick.childrenProcessed) {\n var shownNodes = pick.nodes;\n queueMicrotask(function () {\n if (pick.el.__stx_chain_active) peek(function () { resumeSubtreeScopes(shownNodes); });\n });\n }\n if (!pick.childrenProcessed) {\n pick.childrenProcessed = true;\n // Hydrate before the outer scope walk can see the inserted branch.\n // Chromium executes scripts cloned from template.content as soon as\n // they are connected, so deferring this pass allowed the global walk\n // to process projected slot expressions without the loop caller\n // scope. peek() keeps this synchronous pass from subscribing child\n // reads to the current chain effect.\n // Tracked on the branch element: this runs inside the chain effect,\n // where no tracker is active, so without a handle the effects of a\n // branch picked after render survive their row's removal (#1954).\n pick.el.__stx_chain_disposers = trackEffects(function () {\n peek(function () {\n var childScope = { ...globalHelpers, ...capturedComponentScope, ...(pick.capturedElementScope || {}) };\n // Components compiled inside any branch of an if/else-if/else\n // chain carry scoped setup scripts with them. Branch nodes are\n // detached before those scripts can execute, so simply\n // re-inserting the selected branch leaves component props,\n // events, directives, and projected slot expressions inert.\n // Hydrate those scopes before the normal subtree walk, matching\n // the single-template :if and :for insertion paths.\n var previouslyTrackedNodes = new Set();\n pick.nodes.forEach(function (n) {\n if (n && n.__stx_disposers) previouslyTrackedNodes.add(n);\n });\n hydrateComponentScopes(pick.nodes, childScope);\n pick.nodes.forEach(function (n) {\n if (n.nodeType !== 1) return; // whitespace/text between template children\n // A scoped component receives its disposer in the outer scope\n // walk immediately after processElement returns from binding\n // this conditional. That first pass intentionally stops at\n // :if, so a disposer does not mean its children were hydrated.\n if (previouslyTrackedNodes.has(n) || !n.__stx_disposers)\n processElement(n, childScope);\n n.removeAttribute('x-cloak');\n n.querySelectorAll('[x-cloak]').forEach(function (c) { c.removeAttribute('x-cloak'); });\n });\n resumeDetachedBranches();\n });\n });\n }\n }\n\n currentIdx = pickedIdx;\n });\n }\n\n // Shown branches whose deferred bind found them off the page: an enclosing\n // :if, bound later in the same pass, hid them between the queue and the run.\n // Their own condition has not changed, so their effect never runs again to\n // retry; each resumes here when an enclosing branch puts it back.";
|
|
2
|
+
export declare const SIGNALS_IF_CHAIN_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Single-branch conditional binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_IF_RUNTIME = " const detachedBranches = new Set();\n function resumeDetachedBranches() {\n if (!detachedBranches.size) return;\n Array.from(detachedBranches).forEach(function(resume) {\n if (!resume.el.isConnected) return;\n detachedBranches.delete(resume);\n resume();\n });\n }\n\n function bindIf(el, passedScope = componentScope, attrName = '@if') {\n // Guard: prevent double-binding on the same element\n if (el.__stx_if_bound) { console.log('[stx] bindIf SKIPPED (already bound):', el.getAttribute(attrName) || '(attr removed)', 'on', el.tagName); return; }\n el.__stx_if_bound = true;\n\n const expr = el.getAttribute(attrName);\n let parent = el.parentNode;\n\n // Guard: if element has no parent, it's detached - skip processing\n if (!parent) {\n console.warn('[STX] bindIf: element has no parent, skipping');\n return;\n }\n\n const placeholder = stxHost.anchor('stx-if');\n // Marks where this branch's rendered content ENDS (stacksjs/stx#1955).\n // Hiding used to remove only the cloned nodes, but a structural directive\n // directly inside the template renders its own output as siblings that are\n // not among those clones -- a <template :for> at the top level of a\n // <template :if> left every row on screen after the branch went false.\n // Only the template branch needs it; the single-element branch owns exactly\n // the node it was bound to.\n let endMarker = null;\n let isInserted = true;\n\n // Handle <template> elements specially - clone their content\n const isTemplate = el.tagName === 'TEMPLATE';\n if (!isTemplate) el.__stx_if_visible = state(true);\n const componentSetupSiblings = isTemplate ? [] : findConditionalComponentSetupSiblings(el);\n let currentNodes = isTemplate ? [] : [el, ...componentSetupSiblings];\n\n // Capture BOTH element scope AND passedScope NOW before anything changes\n // passedScope may contain @for iteration variables or parent component signals\n const capturedElementScope = findElementScope(el);\n const capturedComponentScope = { ...passedScope };\n\n preserveConditionalComponentScopes(el, capturedComponentScope);\n stxHost.insert(parent, placeholder, el);\n el.removeAttribute(attrName);\n\n if (isTemplate) {\n // Nothing is cloned until the condition holds: the effect below clones\n // template.content on the first true and binds it then. Every branch\n // used to be cloned and inserted up front and the false ones removed, so\n // a false branch still built its elements - in WebKit a <video> or\n // <audio> sets up a media player as it is created.\n isInserted = false;\n stxHost.remove(el); // Remove the template element itself\n }\n\n // Helper to evaluate with captured scope (auto-unwraps signals).\n // A with-scope resolves only identifiers the expression actually references,\n // so the conditional subscribes narrowly instead of reading every signal\n // in a component scope. That broad subscription made an unrelated ref\n // update re-enter structural removal while the real condition was already\n // removing the same subtree. First try the auto-unwrap proxy (so a bare\n // comparison like count > 5 reads the signal value), then retry with the\n // raw scope so call syntax like count() === 0 still works (#1733).\n const evalExpr = (expression) => {\n // Skip placeholder expressions like __TITLE__ (build-time placeholders)\n if (/^__[A-Z_]+__$/.test(expression.trim())) {\n return expression;\n }\n try {\n const scope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);\n const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');\n return fn(...__stxArgs(fn, unwrapScope));\n }\ncatch (e1) {\n try {\n // Retry without the unwrap proxy so call-syntax (signal()) works.\n const scope2 = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n const fn2 = __stxCompileScoped(scope2, [], 'return ' + expression + '');\n return fn2(...__stxArgs(fn2, scope2));\n }\ncatch (e2) {\n if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);\n return '';\n }\n }\n };\n\n // Track if children have been processed\n let childrenProcessed = false;\n\n // Helper to process children with captured scope\n const processChildrenWithScope = () => {\n // Build the combined scope for children - no need to modify global componentScope\n // Just pass the scope explicitly to processElement\n const childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n\n\n Array.from(el.childNodes).forEach(child => processElement(child, childScope));\n\n childrenProcessed = true;\n };\n\n // A <template :if> inserts clones of template.content rather than the\n // template element itself. Those clones still need the normal directive\n // and interpolation pass. Previously the initially-visible branch was\n // inserted and left inert, so bindings such as :text and {{ expression }}\n // leaked into the rendered UI until the condition toggled.\n const processTemplateNodes = (nodes) => {\n const childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n // Components compiled inside a <template :if> carry setup scripts in the\n // template content. Browser-cloned scripts are inert, so register their\n // scopes and forwarded props before walking the inserted branch. This is\n // the same component hydration path used by <template :for>.\n hydrateComponentScopes(nodes, childScope);\n nodes.forEach(node => {\n if (!node.__stx_disposers && node.tagName !== 'SCRIPT')\n node.__stx_effect_disposers = trackEffects(function() { processElement(node, childScope); });\n if (node.nodeType === 1) {\n node.removeAttribute('x-cloak');\n node.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));\n }\n });\n resumeDetachedBranches();\n };\n\n // Evaluate the :if expression \u2014 use direct signal read for simple refs,\n // falling back to evalExpr for complex expressions\n const fullScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n const directSignal = fullScope[expr];\n\n effect(() => {\n parent = followPlaceholder(placeholder, parent, currentNodes);\n var value;\n if (directSignal && (directSignal._isSignal || directSignal._isDerived)) {\n value = directSignal();\n console.log('[stx] bindIf effect (direct):', expr, '\u2192', value, 'isInserted:', isInserted);\n } else {\n value = evalExpr(expr);\n }\n\n if (isTemplate) {\n if (value && !isInserted) {\n // Re-insert cloned content\n currentNodes = Array.from(el.content.childNodes).map(n => stxHost.clone(n));\n const insertionAnchor = placeholder.nextSibling;\n currentNodes.forEach(node => stxHost.insert(parent, node, insertionAnchor));\n // Bound AFTER the clones, so hiding can remove whatever a nested\n // structural directive rendered as their sibling (#1955).\n if (!endMarker) endMarker = stxHost.anchor('stx-if-end');\n stxHost.insert(parent, endMarker, insertionAnchor);\n processTemplateNodes(currentNodes);\n childrenProcessed = true;\n // Stamp insertion time for click propagation guard\n currentNodes.forEach(function(n) { if (n.nodeType === 1) n.__stx_shown_at = performance.now(); });\n isInserted = true;\n }\nelse if (!value && isInserted) {\n // Remove all current nodes. Do NOT disposeSubtreeScopes \u2014 :if is a\n // toggle, not a permanent unmount; see the single-element branch\n // below and #1737. Effects are disposed, though: these clones are never\n // reused, and a re-show clones afresh, so leaving them bound only\n // accumulates work (#1954).\n //\n // Everything between the placeholder and the end marker goes, not\n // just the clones: a nested :for or :if renders siblings of its own\n // that no clone list contains (#1955).\n // Only walk the range when THIS binding inserted the content and\n // left its marker. Without that guard the walk ran to the end of the\n // parent and took a sibling <template :if> with it -- the initial\n // server-rendered state has no marker to stop at.\n if (endMarker && endMarker.parentNode === parent) {\n var leaving = [];\n for (var cursor = placeholder.nextSibling; cursor && cursor !== endMarker; cursor = cursor.nextSibling) leaving.push(cursor);\n suspendSubtreeScopes(leaving);\n var doomed = placeholder.nextSibling;\n while (doomed && doomed !== endMarker) {\n var nextDoomed = doomed.nextSibling;\n disposeSubtreeEffects(doomed);\n stxHost.remove(doomed);\n doomed = nextDoomed;\n }\n stxHost.remove(endMarker);\n }\n suspendSubtreeScopes(currentNodes.filter(node => node.parentNode));\n currentNodes.forEach(node => { disposeSubtreeEffects(node); stxHost.remove(node); });\n currentNodes = [];\n isInserted = false;\n childrenProcessed = false;\n }\n else if (value && isInserted && !childrenProcessed) {\n // Initial template content is cloned before the effect runs. Process\n // it after the condition is confirmed so hidden branches stay inert.\n // Keep hydration synchronous so the outer scope walk cannot bind\n // caller-owned slot expressions first, while peek() prevents child\n // reads from subscribing to this conditional effect.\n childrenProcessed = true;\n peek(function() {\n if (isInserted) processTemplateNodes(currentNodes);\n });\n }\n }\nelse {\n // Native hosts keep a view hierarchy rather than a DOM subtree. Route\n // the conditional through the same visibility contract as :show so a\n // false branch is hidden in the first render and in every loop row;\n // the structural remove/insert below still preserves browser and\n // native lifecycle behaviour when the branch changes.\n if (stxHost.isNative) stxHost.setVisible(el, !!value);\n if (value && !isInserted) {\n console.log('[stx] bindIf INSERTING element for :if=' + expr);\n const insertionAnchor = placeholder.nextSibling;\n currentNodes.forEach(node => stxHost.insert(parent, node, insertionAnchor));\n if (parent && parent.__stx_detached_if) currentNodes.forEach(node => parent.__stx_detached_if.delete(node));\n el.__stx_if_visible.set(true);\n el.__stx_shown_at = performance.now();\n isInserted = true;\n // A previously hydrated parent skips hydrateShownBranch on re-show.\n // Its children may have become visible while it was detached, so\n // resume their pending bindings now that the subtree is connected.\n peek(resumeDetachedBranches);\n // Shown before, so the components in it mounted and were suspended\n // when it hid. They mount again now -- in a microtask, the same\n // moment their first mount ran, and only if still shown by then.\n if (childrenProcessed) {\n queueMicrotask(function() {\n if (isInserted) peek(function() { resumeSubtreeScopes(currentNodes); });\n });\n }\n }\nelse if (!value && isInserted) {\n console.log('[stx] bindIf REMOVING element for :if=' + expr, 'el.isConnected:', el.isConnected, 'parent:', parent.tagName);\n el.__stx_if_visible.set(false);\n // Unmounted, not disposed: the components in it release what they\n // hold while their markup is still on the page, and keep their scopes.\n suspendSubtreeScopes(currentNodes);\n // Do NOT disposeSubtreeScopes here. :if is a TOGGLE \u2014 the element is\n // re-shown when the condition flips back \u2014 not a permanent unmount.\n // A nested data-stx-scope inside this subtree is created once by its\n // setup IIFE at page load and stored in window.stx._scopes; deleting\n // it on hide left re-show unable to recreate it, so nested scoped\n // components under reactive conditionals rendered all branches at\n // once (#1737). Permanent disposal stays in bindFor (item removal)\n // and cleanupContainer (SPA navigation). The double-bind guards make\n // re-show idempotent, so toggling doesn't leak.\n currentNodes.forEach(node => stxHost.remove(node));\n // Detached nodes are out of reach of a DOM walk, so an ancestor row or\n // branch removed while this is hidden could not dispose their effects\n // (#1954). Record them on the parent that keeps the placeholder.\n if (parent) {\n if (!parent.__stx_detached_if) parent.__stx_detached_if = new Set();\n currentNodes.forEach(node => parent.__stx_detached_if.add(node));\n }\n isInserted = false;\n console.log('[stx] bindIf REMOVED, el.isConnected:', el.isConnected);\n }\n // Process the entire subtree when element is visible and not yet processed.\n // peek() keeps child effects from subscribing to this bindIf's tracked\n // signals. Use capturedComponentScope (not global componentScope) so\n // iteration variables from an enclosing for-loop remain in scope.\n // Process the element itself, not just children, so sibling directives\n // on the same element (e.g. text binding alongside if) fire too. The if\n // attribute was already removed, so no recursion.\n //\n // Synchronously when the branch is on the page, as the template and\n // if/else-chain branches already are. This pass used to wait for a\n // timer, so every :if (and each :for inside one) filled in a frame\n // after the rest of the page was bound: a screen opened from a tab bar\n // showed its sections arriving one after another.\n if (value && isInserted && !childrenProcessed) {\n childrenProcessed = true;\n // Until this pass runs, the shown subtree still holds literal {{ }}.\n // Flag it so the hydration audit doesn't report those as a binding\n // miss when the pass is deferred (#1773).\n el.__stx_if_pending = true;\n var hydrateShownBranch = function() {\n // Removed with its row, or hidden again, before this ran. Hydrating\n // a detached element now creates effects nothing will dispose\n // (#1954). Leave it unprocessed so the next show schedules the pass.\n if (!el.isConnected) {\n childrenProcessed = false;\n el.__stx_if_pending = false;\n // Hidden by an ancestor rather than by this condition (a page :if\n // around a component whose own :if queued this pass), the branch\n // comes back without this effect running, and a component shown\n // again kept its :for rows as raw markup.\n var resume = function() {\n if (!isInserted || childrenProcessed) return;\n childrenProcessed = true;\n el.__stx_if_pending = true;\n peek(hydrateShownBranch);\n };\n resume.el = el;\n detachedBranches.add(resume);\n return;\n }\n var childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };\n // A false single-element conditional is detached before the\n // DOMContentLoaded component-scope pass. When it becomes visible,\n // hydrate any component roots in the restored subtree first so\n // projected slot bindings and component-local directives receive\n // the same lifecycle as components inserted by template :if.\n var wasTrackedBeforeConditionalHydration = !!el.__stx_disposers;\n hydrateComponentScopes(currentNodes, childScope);\n // Tracked on its own property so an ancestor row or branch removal\n // reaches these effects too (#1954). This runs after the enclosing\n // tracker has closed, so nothing else would collect them.\n if (wasTrackedBeforeConditionalHydration || !el.__stx_disposers)\n el.__stx_if_disposers = trackEffects(function() { processElement(el, childScope); });\n // Remove x-cloak from the inserted subtree \u2014 the initial\n // cloak removal (after processElement on the root) already\n // ran before this deferred processing, so newly-inserted\n // :if children still have x-cloak and stay hidden.\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n // Deferred bind complete \u2014 the audit may inspect this subtree now.\n el.__stx_if_pending = false;\n // Branches inside this one that were hidden with it can bind now.\n resumeDetachedBranches();\n };\n // In a microtask, not inside this effect's own run: child effects\n // created while it is running saw the data mid-change (a screen\n // swapping workouts) and recorded expressions that had never\n // evaluated. A microtask still runs before the browser paints, so\n // the branch is bound in the first frame all the same. A branch\n // shown while detached (inside content not on the page yet) waits a\n // macrotask, when it has been placed.\n if (el.isConnected) {\n // A native host sends the insertion as soon as its current\n // mutation turn ends. Hydrating in a later microtask would put the\n // handler registration in a second batch, leaving a same-turn tap\n // with the source expression instead of a native handler id.\n if (stxHost.isNative) peek(hydrateShownBranch);\n else queueMicrotask(function() { peek(hydrateShownBranch); });\n }\n else setTimeout(hydrateShownBranch, 0);\n }\n }\n });\n }\n";
|
|
2
|
+
export declare const SIGNALS_IF_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Deferred island hydration scheduling for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_LAZY_HYDRATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_LAZY_HYDRATION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Lifecycle queues and scope-aware hook ownership for the client runtime. */
|
|
2
|
-
export declare const SIGNALS_LIFECYCLE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_LIFECYCLE_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Loop component scope remapping helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_LOOP_COMPONENT_REMAP_RUNTIME
|
|
2
|
+
export declare const SIGNALS_LOOP_COMPONENT_REMAP_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Loop-row conditional deferral for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_LOOP_CONDITIONAL_RUNTIME
|
|
2
|
+
export declare const SIGNALS_LOOP_CONDITIONAL_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Loop-row ownership and placeholder helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_LOOP_ROW_RUNTIME
|
|
2
|
+
export declare const SIGNALS_LOOP_ROW_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Manifest-driven browser and native hydration for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_MANIFEST_HYDRATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_MANIFEST_HYDRATION_RUNTIME: string;
|