@stacksjs/stx 0.2.572 → 0.2.573
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-f4jh9vrj.js → chunk-0s647d0b.js} +53 -53
- package/dist/{chunk-09gtbb1w.js → chunk-1bsafdnt.js} +1 -1
- package/dist/{chunk-m6mxqepz.js → chunk-1btr5tme.js} +1 -1
- package/dist/{chunk-01mxer9s.js → chunk-2g6wcnna.js} +1 -1
- package/dist/{chunk-rrj5m9xv.js → chunk-2hg2bqtj.js} +1 -1
- package/dist/{chunk-xckzvbvn.js → chunk-4f0fh2a9.js} +1 -1
- package/dist/chunk-557wtdps.js +2 -0
- package/dist/{chunk-vr36s2en.js → chunk-58vrf6kh.js} +1 -1
- package/dist/{chunk-qzbzn1yf.js → chunk-6tsnz28m.js} +1 -1
- package/dist/{chunk-cvswrbzw.js → chunk-6x8cwscv.js} +1 -1
- package/dist/{chunk-1n64749x.js → chunk-74ew8ajw.js} +1 -1
- package/dist/{chunk-jqefcghh.js → chunk-78d6yyxz.js} +2 -2
- package/dist/{chunk-83fdt4yj.js → chunk-824cnbac.js} +1 -1
- package/dist/{chunk-ntgy4e1q.js → chunk-864xm0jy.js} +1 -1
- package/dist/{chunk-nn174xjh.js → chunk-9fbkdrm8.js} +1 -1
- package/dist/{chunk-kzjrgh0b.js → chunk-a3gvw1q2.js} +1 -1
- package/dist/{chunk-pqcvh9pp.js → chunk-amtrg7pn.js} +1 -1
- package/dist/{chunk-pw9verqx.js → chunk-b5fpsp5n.js} +1 -1
- package/dist/{chunk-5afw7z6v.js → chunk-bcjr3fw7.js} +1 -1
- package/dist/{chunk-n6qp05t9.js → chunk-bkj0j5se.js} +1 -1
- package/dist/{chunk-mzqyv7s5.js → chunk-cf97xdqa.js} +1 -1
- package/dist/{chunk-cgwyd9aq.js → chunk-cr67dpx4.js} +1 -1
- package/dist/{chunk-f1apaqfk.js → chunk-dpqvacd1.js} +1 -1
- package/dist/{chunk-ghy82tsc.js → chunk-et8726at.js} +1 -1
- package/dist/{chunk-4bgfpkwx.js → chunk-ev8t5cxk.js} +1 -1
- package/dist/{chunk-s34g3awk.js → chunk-fynh3bkq.js} +1 -1
- package/dist/{chunk-gzgc8zk5.js → chunk-g8757f97.js} +2 -2
- package/dist/{chunk-3gft8zng.js → chunk-hm4j4d8q.js} +1 -1
- package/dist/{chunk-0bt0fbs1.js → chunk-j9qy9t3t.js} +5 -5
- package/dist/{chunk-2a1q5y6r.js → chunk-jhc47xzj.js} +1 -1
- package/dist/{chunk-79vdkvhf.js → chunk-kns5m52j.js} +1 -1
- package/dist/{chunk-2cqbyb8w.js → chunk-mjpewk4r.js} +1 -1
- package/dist/{chunk-2jjff8kv.js → chunk-nj488tj2.js} +2 -2
- package/dist/{chunk-dcpf6kas.js → chunk-q9chv68c.js} +1 -1
- package/dist/{chunk-xq2ck69k.js → chunk-qm280dp3.js} +1 -1
- package/dist/{chunk-ymawe0y5.js → chunk-sjcstv33.js} +1 -1
- package/dist/{chunk-tc5r2vmw.js → chunk-t0zdz8kd.js} +1 -1
- package/dist/{chunk-jwvzvapp.js → chunk-t3dnak1j.js} +1 -1
- package/dist/{chunk-2jsnrfc8.js → chunk-t64nnmmj.js} +1 -1
- package/dist/{chunk-m2a1fxpb.js → chunk-tvb8p7c0.js} +1 -1
- package/dist/{chunk-6f4qrd0s.js → chunk-tyhgq6rw.js} +1 -1
- package/dist/{chunk-4wfr074d.js → chunk-vn7tc8hm.js} +1 -1
- package/dist/{chunk-y4ajd836.js → chunk-xy6g8zb9.js} +1 -1
- package/dist/{chunk-zddzjd60.js → chunk-ya7xks9t.js} +1 -1
- package/dist/chunk-zpz6q2fh.js +2 -0
- package/dist/chunk-zxt94g45.js +2 -0
- package/dist/{chunk-cyg9w31a.js → chunk-zz7tw07b.js} +1 -1
- package/dist/{chunk-ta8bhz27.js → chunk-zzcxacjf.js} +1 -1
- package/dist/cli.js +7 -7
- 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 +1 -4
- package/dist/client-script-bundler.d.ts +55 -103
- package/dist/client-script.d.ts +69 -127
- 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 +1 -1
- package/dist/craft.js +1 -1
- 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 +1 -1
- 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 +2 -2
- 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/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/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-49gwmcrn.js +0 -2
- package/dist/chunk-6va5pe2m.js +0 -2
- package/dist/chunk-bm2q1srp.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
|
/** 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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Two-way form model binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_MODEL_RUNTIME
|
|
2
|
+
export declare const SIGNALS_MODEL_RUNTIME: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SIGNALS_MOUNT_RUNTIME = " mountEl: function(selector, setupFn) {\n function doMount() {\n var root = document.querySelector(selector);\n if (!root) { console.warn('[stx] mountEl: element not found:', selector); return; }\n\n // Set component context for defineProps/defineEmits (Phase 4)\n var prevProps = window.__STX_CURRENT_PROPS__;\n var prevEl = window.__STX_CURRENT_ELEMENT__;\n var propsAttr = root.getAttribute && root.getAttribute('data-stx-props');\n window.__STX_CURRENT_PROPS__ = root.__stx_props || (propsAttr ? JSON.parse(propsAttr) : {});\n window.__STX_CURRENT_ELEMENT__ = root;\n\n var mountStart = mountCallbacks.length;\n var destroyStart = destroyCallbacks.length;\n\n // The setup's hooks are collected off the global queues below, so an\n // outer flush's destroy sink must not catch them first (see mount).\n var outerSink = activeDestroySink;\n activeDestroySink = null;\n var scope;\n try { scope = setupFn(); }\n finally { activeDestroySink = outerSink; }\n\n // Restore previous context (supports nested components)\n window.__STX_CURRENT_PROPS__ = prevProps;\n window.__STX_CURRENT_ELEMENT__ = prevEl;\n\n var localMountHooks = mountCallbacks.splice(mountStart);\n var localDestroyHooks = destroyCallbacks.splice(destroyStart);\n\n if (typeof scope === 'object' && scope !== null) {\n scope.$el = root;\n scope.$refs = scope.$refs || {};\n root.__stx_scope = scope;\n }\n\n var disposeEffects = trackEffects(function() {\n processElement(root, { ...componentScope, ...(scope || {}) });\n });\n root.__stx_disposers = disposeEffects;\n\n root.removeAttribute('x-cloak');\n root.querySelectorAll('[x-cloak]').forEach(function(el) { el.removeAttribute('x-cloak'); });\n\n // Through runMountCallbacks, so an onDestroy called inside one of\n // them lands here too rather than on the global queue (#1958).\n runMountCallbacks(localMountHooks, localDestroyHooks);\n\n root.__stx_destroy = localDestroyHooks;\n }\n\n if (document.readyState === 'loading') {\n mountQueue.push(doMount);\n }\nelse {\n doMount();\n }\n },\n mount: function(setupFn) {\n console.log('[mount] called');\n // Capture script reference synchronously (only valid during execution)\n var scriptEl = document.currentScript;\n\n function doMount() {\n // Auto-mount scripts are emitted after their component template. Other\n // generated helper scripts can sit between the rendered root and this\n // script, so walk past script/style siblings before selecting the root.\n // Router-injected page scripts are marked data-stx-page and must use the\n // content-container fallback below instead.\n var isSpaPageScript = scriptEl && scriptEl.hasAttribute\n && scriptEl.hasAttribute('data-stx-page')\n && !scriptEl.hasAttribute('data-stx-positioned');\n var root = null;\n if (scriptEl && !isSpaPageScript) {\n var previous = scriptEl.previousElementSibling;\n while (previous && (previous.tagName === 'SCRIPT' || previous.tagName === 'STYLE'))\n previous = previous.previousElementSibling;\n\n var next = scriptEl.nextElementSibling;\n while (next && (next.tagName === 'SCRIPT' || next.tagName === 'STYLE'))\n next = next.nextElementSibling;\n\n root = previous || next || scriptEl.parentElement;\n }\n\n // SPA fallback: during router navigation, script is appended to body>\n // (not inside the content container), so nextElementSibling won't find the page content.\n // Only use fallback when we genuinely couldn't find a suitable root element.\n // Do NOT fallback just because the script is in body> \u2014 layout scripts in body>\n // with valid siblings (e.g. sidebar <aside>) should use those siblings as root.\n\n // An x-data root that initScope has not claimed yet is not ours to mount.\n //\n // The element carries its own state expression and the reactive runtime\n // owns it; data-stx-scope is on it from the server, but the id is not\n // in stx._scopes until initScope runs, which on a navigation happens\n // later in the stx:load handler. Mounting it in the meantime binds its\n // whole subtree against whatever scope the mounting script brought.\n //\n // That is what a layout script did after every SPA navigation. Its own\n // re-executed script now lands inside the content container next to the\n // incoming page, so previousElementSibling resolved to the *page's*\n // x-data root; mount() adopted it and ran processElement over it with the\n // sidebar's scope. Every :for template inside was consumed against a\n // scope holding none of the page's data, and bindFor replaces each\n // template with its stx-for anchor on that single pass \u2014 so the markup a\n // retry needed was gone, and the effect had read no signal to re-run on.\n // The list stayed empty for the life of the page while its state sat\n // fully populated beside it. Cold loads never hit it: there the page's\n // own script mounts first, with the right scope.\n //\n // Registered scopes are left alone, so an element the reactive runtime\n // has already initialised keeps whatever behaviour it had.\n function awaitingReactiveInit(el) {\n if (!el || !el.hasAttribute || !el.hasAttribute('data-stx-xdata'))\n return false;\n var id = el.getAttribute('data-stx-scope');\n return !(id && window.stx && window.stx._scopes && window.stx._scopes[id]);\n }\n\n var needsFallback = !root || root === document.body\n || (root && root.tagName === 'SCRIPT')\n || awaitingReactiveInit(root);\n if (needsFallback) {\n var routerOpts = window.STX_ROUTER_OPTIONS || window.__stxRouterConfig || {};\n var container = document.querySelector('[data-stx-content]')\n || document.querySelector('[data-stx-router-container]')\n || (routerOpts.container ? document.querySelector(routerOpts.container) : null)\n || document.querySelector('main')\n || document.querySelector('#content');\n if (container) {\n // Use the container itself as root \u2014 process ALL content inside it\n root = container;\n // But if a specific child is already mounted, find first unmounted one instead\n var hasMount = false;\n var children = container.children;\n for (var ci = 0; ci < children.length; ci++) {\n if (children[ci].__stx_scope) { hasMount = true; break; }\n }\n if (hasMount) for (var ci = 0; ci < children.length; ci++) {\n var candidate = children[ci];\n if (candidate.__stx_scope || candidate.tagName === 'SCRIPT') continue;\n if (awaitingReactiveInit(candidate)) continue;\n root = candidate;\n break;\n }\n }\n }\n\n // The fallback can still land on one (a container whose only unmounted\n // child is the incoming page). Processing the container instead is safe:\n // processElement skips [data-stx-scope] children, so the reactive\n // runtime keeps its subtree and binds it with the right scope.\n if (awaitingReactiveInit(root)) {\n var reactiveOwnerParent = root.parentElement;\n root = reactiveOwnerParent && reactiveOwnerParent !== document.body ? reactiveOwnerParent : null;\n }\n\n if (!root) { console.warn('[stx] mount: no root element found'); return; }\n\n // Set component context for defineProps/defineEmits (Phase 4)\n var prevProps = window.__STX_CURRENT_PROPS__;\n var prevEl = window.__STX_CURRENT_ELEMENT__;\n var propsAttr = root.getAttribute && root.getAttribute('data-stx-props');\n window.__STX_CURRENT_PROPS__ = root.__stx_props || (propsAttr ? JSON.parse(propsAttr) : {});\n window.__STX_CURRENT_ELEMENT__ = root;\n\n // Track lifecycle hooks registered during setup\n var mountStart = mountCallbacks.length;\n var destroyStart = destroyCallbacks.length;\n\n // Run setup function \u2014 returns scope object with declarations\n //\n // With no outer destroy sink (#1958). This can run inside another\n // component's onMount, where runMountCallbacks has pointed onDestroy at\n // THAT component's queue. The setup's own teardown (a composable such\n // as useEventListener registers its removal with onDestroy) must land\n // on the global queue, where the splice below collects it for this\n // root. Otherwise it belonged to the outer component and outlived this\n // root: mounted on a :for row, removing the row left its listener in.\n var outerSink = activeDestroySink;\n activeDestroySink = null;\n var scope;\n try { scope = setupFn(); }\n finally { activeDestroySink = outerSink; }\n console.log('[mount] root:', root.tagName, 'scope keys:', scope ? Object.keys(scope).slice(0, 10) : 'null');\n\n // Restore previous context (supports nested components)\n window.__STX_CURRENT_PROPS__ = prevProps;\n window.__STX_CURRENT_ELEMENT__ = prevEl;\n\n // Capture mount/destroy hooks added during setup\n var localMountHooks = mountCallbacks.splice(mountStart);\n var localDestroyHooks = destroyCallbacks.splice(destroyStart);\n\n // Register scope\n if (typeof scope === 'object' && scope !== null) {\n scope.$el = root;\n scope.$refs = scope.$refs || {};\n root.__stx_scope = scope; // Store isolated scope on element\n Object.assign(componentScope, scope); // Keep for backwards compat\n }\n\n // Walk DOM and bind directives, tracking effects for cleanup\n var disposeEffects = trackEffects(function() {\n processElement(root, { ...componentScope, ...(scope || {}) });\n });\n root.__stx_disposers = disposeEffects;\n\n // Remove x-cloak after bindings are applied (prevents FOUC)\n root.removeAttribute('x-cloak');\n root.querySelectorAll('[x-cloak]').forEach(function(el) { el.removeAttribute('x-cloak'); });\n\n // Fire mount hooks\n // Through runMountCallbacks, so an onDestroy called inside one of\n // them lands here too rather than on the global queue (#1958).\n runMountCallbacks(localMountHooks, localDestroyHooks);\n\n // Store cleanup on element for auto-destroy\n root.__stx_destroy = localDestroyHooks;\n }\n\n var isRoutedMount = scriptEl && scriptEl.hasAttribute\n && scriptEl.hasAttribute('data-stx-page');\n if (document.readyState === 'loading' || isRoutedMount) {\n mountQueue.push(doMount);\n }\nelse {\n doMount();\n }\n }";
|
|
1
|
+
export declare const SIGNALS_MOUNT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Client-side navigation, route params, and search params runtime. */
|
|
2
|
-
export declare const SIGNALS_NAVIGATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_NAVIGATION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Change notification shared by state, derived and reactive objects in the client runtime. */
|
|
2
|
-
export declare const SIGNALS_NOTIFY_RUNTIME
|
|
2
|
+
export declare const SIGNALS_NOTIFY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Optimistic state overlay used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_OPTIMISTIC_RUNTIME
|
|
2
|
+
export declare const SIGNALS_OPTIMISTIC_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Shared overlay stack and modal facade used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_OVERLAY_RUNTIME = " // \u2500\u2500 Overlay stack \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n //\n // One stack for everything that takes over the page: stxAlert/stxConfirm,\n // the runtime modal and drawer, @stacksjs/components' Dialog and Drawer, and\n // anything an app draws itself (window.stx.overlays). Each of those used to\n // keep its own listener, its own scroll lock and its own idea of whether it\n // was on top, so with one open over another a single Escape closed both, two\n // Tab traps fought over focus, and the first to close unlocked the page under\n // the one still open (stacksjs/stx#2057; #1998 fixed the same thing for the\n // confirm dialogs alone).\n //\n // Only the topmost overlay answers Escape and owns Tab. The page is locked\n // from the first open to the last close. Focus moves into an overlay when it\n // opens and back to whatever opened it when it closes.\n //\n // A popup - a menu, a listbox, a popover - goes on the same stack as a\n // non-modal layer (modal: false). It takes Escape while it is on top, so one\n // Escape inside a dialog closes the menu and leaves the dialog, but it does\n // not lock the page, trap Tab or move focus: those follow the topmost MODAL\n // layer. Each popup used to listen for Escape on the document itself, and\n // whichever listener was registered first won.\n var _overlays = [];\n var _overlayScroll = null;\n var _overlayInerted = [];\n var _overlayListening = false;\n var _OVERLAY_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n function _overlayTop() {\n return _overlays.length ? _overlays[_overlays.length - 1] : null;\n }\n\n // The layer that owns Tab and the page lock: the topmost modal one.\n function _overlayTopModal() {\n for (var i = _overlays.length - 1; i >= 0; i--) {\n if (_overlays[i].modal) return _overlays[i];\n }\n return null;\n }\n\n function _overlayIndex(id) {\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i].id === id) return i;\n }\n return -1;\n }\n\n // The panel is asked for, not held: a component's panel may not be rendered\n // yet on the frame it opens, and may be replaced while open.\n function _overlayPanel(entry) {\n var panel = entry && entry.panel;\n try {\n // A selector is looked up each time, like a function: the element it\n // names may be rendered after the overlay opens, or replaced while open.\n if (typeof panel === 'string') panel = document.querySelector(panel);\n else if (typeof panel === 'function') panel = panel();\n }\n catch (_e) { panel = null; }\n return panel || entry.root || null;\n }\n\n function _overlayShown(nodes) {\n return Array.prototype.filter.call(nodes, function(el) {\n return el.offsetParent !== null || el === document.activeElement;\n });\n }\n\n function _overlayFocusable(panel) {\n return _overlayShown(panel.querySelectorAll(_OVERLAY_FOCUSABLE));\n }\n\n // One listener for every overlay, in the bubble phase: a widget inside an\n // overlay that consumes Escape (a menu closing itself) calls preventDefault\n // and the overlay leaves it alone.\n function _overlayKey(e) {\n var top = _overlayTop();\n if (!top) return;\n if (e.key === 'Escape') {\n if (e.defaultPrevented || !top.onEscape) return;\n e.preventDefault();\n top.onEscape();\n return;\n }\n if (e.key !== 'Tab') return;\n var trap = _overlayTopModal();\n if (!trap) return;\n var panel = _overlayPanel(trap);\n if (!panel) return;\n var items = _overlayFocusable(panel);\n if (!items.length) {\n e.preventDefault();\n if (panel.focus) panel.focus();\n return;\n }\n var first = items[0];\n var last = items[items.length - 1];\n var active = document.activeElement;\n if (!panel.contains(active)) {\n e.preventDefault();\n (e.shiftKey ? last : first).focus();\n return;\n }\n if (e.shiftKey && active === first) {\n e.preventDefault();\n last.focus();\n }\n else if (!e.shiftKey && active === last) {\n e.preventDefault();\n first.focus();\n }\n }\n\n // Lock, listen and inert to match the stack after any change.\n function _overlaySync() {\n for (var i = 0; i < _overlayInerted.length; i++) {\n try { _overlayInerted[i].inert = false; }\n catch (_e) { /* element may be gone */ }\n }\n _overlayInerted = [];\n\n var top = _overlayTop();\n var modal = _overlayTopModal();\n if (!modal && _overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (!top) {\n if (_overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (_overlayListening) {\n document.removeEventListener('keydown', _overlayKey);\n _overlayListening = false;\n }\n return;\n }\n\n if (modal && !_overlayScroll) {\n _overlayScroll = {\n body: document.body.style.overflow,\n html: document.documentElement.style.overflow,\n pad: document.body.style.paddingRight\n };\n // The scrollbar's width comes back as padding, so the page does not jump\n // sideways when it disappears.\n var gap = window.innerWidth - document.documentElement.clientWidth;\n if (gap > 0) {\n var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;\n document.body.style.paddingRight = (existing + gap) + 'px';\n }\n document.body.style.overflow = 'hidden';\n document.documentElement.style.overflow = 'hidden';\n }\n if (!_overlayListening) {\n document.addEventListener('keydown', _overlayKey);\n _overlayListening = true;\n }\n\n // An overlay given a z-index stacks by the order it opened in, not by\n // where it sits in the document: one lifted into the body early (a sheet\n // mounted before the sheet it later opens over) drew underneath. Set on\n // every change, so what stays open closes up when one under it closes. A\n // closed overlay keeps its last value, so it slides away above the one\n // it was over.\n for (var z = 0; z < _overlays.length; z++) {\n var layer = _overlays[z];\n if (typeof layer.zIndex === 'number' && layer.root && layer.root.style) layer.root.style.zIndex = String(layer.zIndex + z);\n }\n\n // inert, rather than aria-hidden, takes the page behind out of the tab\n // order and the accessibility tree together (#1998). Only behind an\n // overlay that is a child of the body element - one the runtime appended,\n // or one an app lifted there - or one opened inside such an overlay (a\n // dialog in a sheet's content). An overlay rendered inside the page's own\n // markup would go inert with the page; its Tab trap is what holds it.\n var root = _overlayInertRoot(modal);\n if (root) {\n var kids = document.body.children;\n for (var k = 0; k < kids.length; k++) {\n var kid = kids[k];\n if (kid === root || kid.inert) continue;\n try {\n kid.inert = true;\n _overlayInerted.push(kid);\n }\n catch (_e) { /* inert unsupported; the Tab trap still holds */ }\n }\n }\n }\n\n // The child of the body that keeps the rest of the page inert while this\n // modal layer is on top: its own root when that is in the body, or the\n // root of the open overlay it sits inside. A dialog opened from a sheet's\n // content is not itself in the body, and the page behind the sheet used to\n // come back to the keyboard and screen readers while it was up.\n function _overlayInertRoot(modal) {\n if (!modal) return null;\n var el = modal.root || _overlayPanel(modal);\n while (el && el.parentNode && el.parentNode !== document.body) el = el.parentNode;\n if (!el || el.parentNode !== document.body) return null;\n if (el === modal.root) return el;\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i] !== modal && _overlays[i].root === el) return el;\n }\n return null;\n }\n\n // The next chance to act, whichever comes first: rAF is suspended in a\n // background tab, so a timer races it.\n function _overlaySoon(callback) {\n var done = false;\n var once = function() {\n if (done) return;\n done = true;\n callback();\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(once);\n setTimeout(once, 32);\n }\n\n // Retried, because focus() on an element that is not displayed yet is a\n // silent no-op. Stops once the overlay has closed.\n function _overlayFocusIn(entry, attempts) {\n if (_overlayIndex(entry.id) === -1) return;\n var target = null;\n try { target = typeof entry.initialFocus === 'function' ? entry.initialFocus() : entry.initialFocus; }\n catch (_e) { target = null; }\n var panel = _overlayPanel(entry);\n // An [autofocus] that is not shown (behind a :show, a player in a\n // dialog that is showing something else) cannot take focus: skipped, or\n // focus went nowhere and the panel's first control never got it.\n if (!target && panel) target = _overlayShown(panel.querySelectorAll('[autofocus]'))[0] || _overlayFocusable(panel)[0] || panel;\n if (target && target.focus) target.focus();\n if (target && document.activeElement === target) return;\n if (attempts > 0) _overlaySoon(function() { _overlayFocusIn(entry, attempts - 1); });\n }\n\n var overlays = {\n /**\n * Put an overlay on top. Calling it again for an open id updates its\n * options and nothing else, so it is safe from an effect that re-runs.\n *\n * options: modal (default true; false for a popup, which takes Escape\n * while on top but does not lock, trap or move focus), panel (an element,\n * a selector, or a function returning one; focus stays inside it), root (the overlay's outermost element, if it is not the panel),\n * zIndex (a base: the root's z-index becomes it plus the overlay's place\n * in the stack, so a later overlay draws over an earlier one wherever it\n * sits in the document), onEscape (leave out for one that must be answered), initialFocus\n * (element or function; defaults to [autofocus], then the first focusable,\n * then the panel), opener (where focus goes back; defaults to whatever had\n * it), restoreFocus (default true).\n */\n open: function(id, options) {\n var opts = options || {};\n var at = _overlayIndex(id);\n if (at !== -1) {\n var existing = _overlays[at];\n for (var key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];\n }\n _overlaySync();\n return;\n }\n var isModal = opts.modal !== false;\n var entry = {\n id: id,\n modal: isModal,\n panel: opts.panel,\n root: opts.root || null,\n zIndex: typeof opts.zIndex === 'number' ? opts.zIndex : null,\n onEscape: opts.onEscape || null,\n initialFocus: opts.initialFocus || null,\n // A popup hands focus back itself, to its own trigger, and only when\n // focus was inside it; a modal layer always does.\n restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,\n opener: opts.opener !== undefined ? opts.opener : document.activeElement\n };\n _overlays.push(entry);\n _overlaySync();\n // Synchronously first, so a caller that asserts focus straight after\n // opening sees it; then retried for a panel that is not displayed yet.\n // A popup keeps focus where its own keyboard handling puts it.\n if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);\n },\n /** Take an overlay off the stack, wherever it is in it. */\n close: function(id) {\n var at = _overlayIndex(id);\n if (at === -1) return;\n var wasTop = at === _overlays.length - 1;\n var entry = _overlays.splice(at, 1)[0];\n _overlaySync();\n // Only the overlay that had the keyboard gives it back. Closing one\n // underneath (its owner went away) must not pull focus out of the top.\n var opener = entry.opener;\n if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {\n try { opener.focus(); }\n catch (_e) { /* gone; nothing to give focus back to */ }\n }\n },\n /** Whether this overlay is the one that has the keyboard. */\n isTop: function(id) {\n var top = _overlayTop();\n return !!top && top.id === id;\n },\n /** Open overlay ids, outermost first. */\n list: function() {\n return _overlays.map(function(o) { return o.id; });\n }\n };\n\n // \u2500\u2500 Modal system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n var modal = {\n open: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) { console.warn('[stx:modal] Modal \"' + id + '\" not found'); return; }\n el.style.display = 'flex';\n // Force reflow then animate\n void el.offsetHeight;\n el.setAttribute('data-stx-modal-open', '');\n // The lock, Escape for the topmost and the Tab trap come from the\n // overlay stack, shared with every other overlay (stacksjs/stx#2057).\n // Each modal used to bind its own Escape and set body overflow itself,\n // so two open closed together and the first to close unlocked the page.\n overlays.open('stx-modal:' + id, {\n panel: el,\n onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { modal.close(id); } : null\n });\n if (el.getAttribute('data-close-backdrop') !== 'false') {\n el.onclick = function(e) { if (e.target === el) modal.close(id); };\n }\n },\n close: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) return;\n el.removeAttribute('data-stx-modal-open');\n el.onclick = null;\n overlays.close('stx-modal:' + id);\n setTimeout(function() {\n if (!el.hasAttribute('data-stx-modal-open')) el.style.display = 'none';\n }, 200);\n },\n toggle: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (el && el.hasAttribute('data-stx-modal-open')) modal.close(id);\n else modal.open(id);\n }\n };\n";
|
|
2
|
+
export declare const SIGNALS_OVERLAY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Pipe expression parsing and execution for client template bindings. */
|
|
2
|
-
export declare const SIGNALS_PIPE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_PIPE_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Read and write proxies that preserve signal semantics in template scopes. */
|
|
2
|
-
export declare const SIGNALS_PROXY_RUNTIME
|
|
2
|
+
export declare const SIGNALS_PROXY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Query and mutation composables used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_QUERY_RUNTIME = " // ==========================================================================\n // Advanced Data Fetching (useQuery / useMutation)\n // ==========================================================================\n\n var _queryCache = {};\n // Requests currently in flight, keyed exactly like _queryCache. _queryCache\n // is written only after the body parses, so the whole in-flight window was a\n // cache miss and N components mounting together issued N identical requests\n // (#1869). Refcounted: a caller that loses interest must not cancel a\n // response another caller is still waiting on.\n var _queryInflight = {};\n var __stxQueryInstance = 0;\n\n // Suspense registry (#1742). A query created with { suspense: true } pushes\n // { el, loading, error } here at creation time (which runs during partial-scope\n // script execution, BEFORE the <Suspense> boundary inits on content-load).\n // Each boundary then CLAIMS the descendant entries for which it is the nearest\n // [data-stx-suspense] ancestor, and aggregates their loading/error signals.\n // Kept on the window (one registry per page) rather than a per-instance\n // closure so a boundary and the queries it claims agree even if the page\n // somehow has more than one runtime instance (e.g. across test files).\n function suspenseRegistry() {\n if (typeof window === 'undefined') return [];\n return window.__stx_suspense_registry || (window.__stx_suspense_registry = []);\n }\n function registerSuspense(loading, error) {\n var el = (typeof window !== 'undefined' && window.__STX_CURRENT_ELEMENT__) || null;\n suspenseRegistry().push({ el: el, loading: loading, error: error });\n }\n\n function useQuery(url, options) {\n options = options || {};\n var staleTime = options.staleTime || 0;\n var cacheTime = options.cacheTime || 300000; // 5 min default\n var cacheKey = options.cacheKey || (typeof url === 'function' ? null : url);\n // keep: the answer is kept on the device per account (setKeptScope, or\n // options.scope) and seeds the next visit synchronously, refreshed behind.\n // true keeps it under the query's key; a string names it.\n var keepKey = options.keep ? (typeof options.keep === 'string' ? options.keep : cacheKey) : null;\n var queryTarget = function() {\n var resolved = null;\n try { resolved = typeof url === 'function' ? url() : url; } catch (e) {}\n return { key: cacheKey || keepKey || resolved || '', url: resolved };\n };\n // What is shown is the last answer with the outbox's waiting writes on\n // top, so a change made offline is not undone by a refetch.\n var base = options.initialData || null;\n var seeded = keepKey ? __stxQueries.seed(keepKey, options.scope) : undefined;\n if (seeded) base = seeded.data;\n var data = state(seeded ? __stxQueries.overlay(queryTarget(), base) : base);\n var show = function(value) {\n base = value;\n data.set(__stxQueries.overlay(queryTarget(), value));\n };\n var answered = false;\n var loading = state(!seeded);\n // See useFetch: loading means \"nothing to show yet\", isFetching means \"a\n // request is open\" \u2014 including a background refresh, which is the case that\n // makes the distinction necessary (#1929).\n var isFetching = state(true);\n var error = state(null);\n var isStale = state(!!seeded);\n if (options.suspense) registerSuspense(loading, error);\n // Kept too large for a synchronous read: it arrives a moment later, and\n // shows unless an answer came first.\n if (keepKey && !seeded) {\n __stxQueries.restore(keepKey, options.scope).then(function(found) {\n if (!found || answered) return;\n show(found.data);\n loading.set(false);\n isStale.set(true);\n });\n }\n\n // Per-run AbortController: a newer run aborts the previous in-flight one and\n // onDestroy aborts the last, so a resolved request can't write into a\n // torn-down scope (#1871).\n var __stxAbort = null;\n // Identity, so dedup can tell \"another component wants this key\" from\n // \"this component asked again\". They must behave differently: joining is\n // right for the first, and wrong for the second \u2014 refetch() after a\n // mutation has to hit the network, not adopt the pre-mutation request that\n // happens to still be open (#1869).\n var __instanceId = ++__stxQueryInstance;\n // The shared entry this instance is currently attached to, so superseding\n // can release its claim without cancelling a request someone else joined.\n var __joined = null;\n\n // runOptions: { background: true } refreshes without touching loading or\n // clearing the current error. A poll must not flash a spinner over data\n // that is already on screen (#1929).\n var fetchData = async function(runOptions) {\n var background = !!(runOptions && runOptions.background);\n var resolvedUrl = typeof url === 'function' ? url() : url;\n if (!resolvedUrl) { if (!background) loading.set(false); isFetching.set(false); return; }\n var key = cacheKey || resolvedUrl;\n\n // Check cache\n var cached = _queryCache[key];\n if (cached && (Date.now() - cached.timestamp < staleTime)) {\n answered = true;\n show(cached.data);\n if (!background) loading.set(false);\n isFetching.set(false);\n isStale.set(false);\n if (options.onSuccess) options.onSuccess(cached.data);\n return;\n }\n\n // Stale-while-revalidate\n if (cached) {\n show(cached.data);\n isStale.set(true);\n }\n\n // Join a request ANOTHER instance already has open for this key. Not one\n // of our own: this instance calling refetch() means \"I want fresh data\",\n // and adopting its own pre-mutation request would silently return stale\n // data \u2014 so an own-instance run still supersedes, exactly as #1871 says.\n var shared = _queryInflight[key];\n if (shared && shared.owner !== __instanceId) {\n shared.refs++;\n __joined = shared;\n if (!background) loading.set(true);\n isFetching.set(true);\n if (!background) error.set(null);\n try {\n var joinedResult = await shared.promise;\n var joinedTransformed = options.transform ? options.transform(joinedResult) : joinedResult;\n answered = true;\n show(joinedTransformed);\n if (keepKey) __stxQueries.persist(keepKey, joinedTransformed, options.scope);\n if (background) error.set(null);\n isStale.set(false);\n if (options.onSuccess) options.onSuccess(joinedTransformed);\n }\n catch (e) {\n if (e && e.name === 'AbortError') return;\n error.set(e.message || 'Query failed');\n if (options.onError) options.onError(e);\n }\n finally {\n shared.refs--;\n if (__joined === shared) __joined = null;\n if (!background) loading.set(false);\n isFetching.set(false);\n }\n return;\n }\n\n // Superseding this instance's own run. Abort ONLY if nobody joined it \u2014\n // cancelling a request another component is waiting on would leave it\n // loading forever, which would turn #1871's fix into a worse bug.\n if (__stxAbort) {\n if (__joined && __joined.refs > 1) __joined.refs--;\n else __stxAbort.abort();\n }\n __joined = null;\n __stxAbort = (typeof AbortController !== 'undefined') ? new AbortController() : null;\n var __signal = __stxAbort ? __stxAbort.signal : undefined;\n if (!background) loading.set(true);\n isFetching.set(true);\n if (!background) error.set(null);\n try {\n var fetchOpts = { method: 'GET', headers: { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) }, signal: __signal };\n // Published BEFORE it is awaited, so a caller starting in the same tick\n // finds it. The network part only \u2014 transform, cache write and\n // onSuccess stay per-caller, since each may transform differently.\n var netPromise = (async function() {\n var response = await __stxFetch('useQuery', resolvedUrl, fetchOpts);\n if (!response.ok) throw await __stxHttpError(response);\n return await response.json();\n })();\n var entry = { owner: __instanceId, refs: 1, controller: __stxAbort, promise: netPromise };\n _queryInflight[key] = entry;\n __joined = entry;\n // Cleared on settle, both ways. A settled entry left behind would turn\n // dedup into a permanent cache and no request for this key would ever\n // be issued again.\n var releaseEntry = function() { if (_queryInflight[key] === entry) delete _queryInflight[key]; };\n netPromise.then(releaseEntry, releaseEntry);\n\n var result = await netPromise;\n if (__signal && __signal.aborted) return;\n var transformed = options.transform ? options.transform(result) : result;\n answered = true;\n show(transformed);\n if (keepKey) __stxQueries.persist(keepKey, transformed, options.scope);\n if (background) error.set(null);\n isStale.set(false);\n _queryCache[key] = { data: transformed, timestamp: Date.now() };\n if (options.onSuccess) options.onSuccess(transformed);\n // Schedule cache eviction\n setTimeout(function() { delete _queryCache[key]; }, cacheTime);\n }\ncatch (e) {\n // A superseded/unmounted request rejects with AbortError \u2014 expected;\n // the run that superseded it owns the state (#1871).\n if (e && e.name === 'AbortError') return;\n error.set(e.message || 'Query failed');\n if (options.onError) options.onError(e);\n }\nfinally {\n if (!__signal || !__signal.aborted) {\n if (!background) loading.set(false);\n isFetching.set(false);\n }\n }\n };\n\n // A refetch nobody asked for does not set loading (see backgroundRun below).\n var backgroundRun = { background: true };\n\n if (options.immediate !== false) {\n // Seeded from the device: the kept copy is on screen, so the first\n // fetch refreshes it behind rather than putting a spinner over it.\n onMount(function() { return seeded ? fetchData(backgroundRun) : fetchData(); });\n }\n\n // The worker has a newer answer for this URL, or the outbox changed: a\n // write waiting on it is shown on top, and one that reached the server\n // stays shown until the refetch it triggers includes it.\n var unwatch = __stxQueries.watch({\n target: queryTarget,\n updated: function() {\n delete _queryCache[cacheKey || queryTarget().url];\n fetchData(backgroundRun);\n },\n outbox: function(sent) {\n if (sent) {\n base = __stxQueries.overlay(queryTarget(), base, sent.id);\n delete _queryCache[cacheKey || queryTarget().url];\n fetchData(backgroundRun);\n }\n show(base);\n }\n });\n onDestroy(unwatch);\n\n // A refetch nobody asked for does not set loading. Both of these refresh\n // data that is ALREADY on screen, so driving the first-load state from them\n // put a spinner over a populated view once a minute, forever \u2014 the reason a\n // polling view could not use this composable at all (#1929). Bind\n // isFetching for a subtle in-flight indicator.\n\n // refetchOnFocus \u2014 removed on destroy, like refetchInterval right below.\n // It used to add a listener and never remove it, so every instance leaked\n // one for the life of the page and each SPA navigation added more; every\n // stale listener still fired, refetching for components long gone (#1818).\n if (options.refetchOnFocus) {\n var onVisibility = function() {\n if (!document.hidden) fetchData(backgroundRun);\n };\n document.addEventListener('visibilitychange', onVisibility);\n onDestroy(function() { document.removeEventListener('visibilitychange', onVisibility); });\n }\n\n // refetchInterval: poll only while the tab is visible and (if given)\n // enabled holds; optionally stop after an error so a broken endpoint is\n // not hammered every interval in a backgrounded tab (#1870).\n if (options.refetchInterval) {\n var intervalId = setInterval(function() {\n if (typeof document !== 'undefined' && document.hidden) return;\n var en = options.enabled;\n if (typeof en === 'function' ? !en() : en === false) return;\n var p = fetchData(backgroundRun);\n if (options.stopOnError && p && typeof p.then === 'function') {\n p.then(function() { if (error()) clearInterval(intervalId); });\n }\n }, options.refetchInterval);\n onDestroy(function() { clearInterval(intervalId); });\n }\n\n // Abort an in-flight request when the owning scope is destroyed (#1871).\n onDestroy(function() { if (__stxAbort) __stxAbort.abort(); });\n\n return {\n data: data,\n loading: loading,\n isFetching: isFetching,\n error: error,\n isStale: isStale,\n refetch: fetchData,\n invalidate: function(runOptions) {\n var key = cacheKey || (typeof url === 'function' ? url() : url);\n delete _queryCache[key];\n return fetchData(runOptions);\n }\n };\n }\n\n function useMutation(url, options) {\n options = options || {};\n var data = state(null);\n var loading = state(false);\n var error = state(null);\n\n var mutate = async function(body) {\n loading.set(true);\n error.set(null);\n var previousData = data();\n\n // Optimistic update\n if (options.optimisticData) {\n var optimistic = typeof options.optimisticData === 'function' ? options.optimisticData(body) : options.optimisticData;\n data.set(optimistic);\n }\n\n try {\n var resolvedUrl = typeof url === 'function' ? url() : url;\n var fetchOpts = {\n method: options.method || 'POST',\n // A file upload is a FormData body. Stringifying it sent \"{}\", and\n // the browser has to write its own multipart Content-Type (the\n // boundary lives there), so raw bodies pass through untouched.\n headers: __stxRawBody(body) ? __stxHeaders(options.headers) : { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) },\n body: typeof body === 'string' || __stxRawBody(body) ? body : JSON.stringify(body)\n };\n var response = await __stxFetch('useMutation', resolvedUrl, fetchOpts);\n if (!response.ok) throw await __stxHttpError(response);\n var result = await response.json();\n var transformed = options.transform ? options.transform(result) : result;\n data.set(transformed);\n if (options.onSuccess) options.onSuccess(transformed);\n // Invalidate related queries\n if (options.invalidateQueries) {\n options.invalidateQueries.forEach(function(key) { delete _queryCache[key]; });\n }\n return transformed;\n }\ncatch (e) {\n error.set(e.message || 'Mutation failed');\n // Rollback optimistic update\n if (options.optimisticData) data.set(previousData);\n if (options.onError) options.onError(e);\n throw e;\n }\nfinally {\n loading.set(false);\n }\n };\n\n return {\n data: data,\n loading: loading,\n error: error,\n mutate: mutate,\n reset: function() { data.set(null); error.set(null); loading.set(false); }\n };\n }\n";
|
|
2
|
+
export declare const SIGNALS_QUERY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Vue-compatible reactive helpers used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_REACTIVE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_REACTIVE_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Template ref accessor used by page and component scopes. */
|
|
2
|
-
export declare const SIGNALS_REF_RUNTIME
|
|
2
|
+
export declare const SIGNALS_REF_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Scope and effect disposal used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SCOPE_DISPOSAL_RUNTIME
|
|
2
|
+
export declare const SIGNALS_SCOPE_DISPOSAL_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Scoped-tree traversal used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SCOPE_TRAVERSAL_RUNTIME
|
|
2
|
+
export declare const SIGNALS_SCOPE_TRAVERSAL_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Reactive visibility binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SHOW_RUNTIME
|
|
2
|
+
export declare const SIGNALS_SHOW_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** SPA load scheduling and teardown boundaries for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SPA_LOAD_CONTROL_RUNTIME
|
|
2
|
+
export declare const SIGNALS_SPA_LOAD_CONTROL_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** SPA content rehydration used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SPA_LOAD_RUNTIME = " function _handleStxLoad() {\n _stxLoadTimer = null;\n console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);\n\n // Run the outgoing page's destroy callbacks before re-initializing. Taken\n // out of their queue first, so one that registers another lands in the\n // next generation instead of being cleared unrun.\n var departing = departingDestroys !== null ? departingDestroys : destroyCallbacks.splice(0);\n departingDestroys = null;\n departing.forEach(function(fn) {\n try { fn(); }\ncatch (e) { console.warn('[stx] destroy callback error:', e); }\n });\n\n // Re-process scoped components in new content\n var routerOpts = window.STX_ROUTER_OPTIONS || window.__stxRouterConfig || {};\n var container = document.querySelector('[data-stx-content]')\n || (routerOpts.container ? document.querySelector(routerOpts.container) : null)\n || document.querySelector('main')\n || document.querySelector('#main-content')\n || document.body;\n\n // Apply new page's SFC setup function. During SPA navigation, re-executed page\n // scripts set window.stx._latestSetup to the new setup function. This takes priority\n // over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).\n var usedLatestSetup = false;\n if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {\n try {\n var setupResult = window.stx._latestSetup();\n // Keep _latestSetup for re-fires (HMR, auto-refresh re-navigation)\n // It will be overwritten when a NEW page's script sets it\n usedLatestSetup = true;\n if (typeof setupResult === 'object' && setupResult !== null) {\n console.log('[stx:load] _latestSetup keys:', Object.keys(setupResult).slice(0, 10));\n Object.assign(componentScope, setupResult);\n }\n } catch (e) {\n console.error('[stx:load] _latestSetup error:', e);\n usedLatestSetup = true; // Don't fall back to stale data-stx\n }\n }\n console.log('[stx:load] usedLatestSetup:', usedLatestSetup, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n\n // Only fall back to [data-stx] attribute lookup if _latestSetup wasn't available.\n // This handles the initial DOMContentLoaded-like case and pages that don't use _latestSetup.\n if (!usedLatestSetup) {\n document.querySelectorAll('[data-stx]').forEach(function(el) {\n var setupName = el.getAttribute('data-stx');\n if (setupName && window[setupName]) {\n var result = window[setupName]();\n if (typeof result === 'object') Object.assign(componentScope, result);\n }\n });\n }\n var spaPageScopeSnapshot = { ...componentScope };\n\n // Routed component mount scripts execute after DOMContentLoaded. Queue them\n // until the destination page setup is active so projected props and parent\n // event handlers resolve against the caller, matching initial hydration.\n mountQueue.forEach(function(fn) { fn(); });\n mountQueue = [];\n\n // Initialize x-data scopes after SPA fragment swap.\n // On full page load, the reactive bridge <script> calls initScope(). But after SPA\n // navigation, only the HTML fragment is swapped \u2014 the bridge script isn't re-executed.\n // The server renames x-data \u2192 data-stx-xdata so we can read the state expression here.\n if (window.__stx_reactive && window.__stx_reactive.initScope) {\n container.querySelectorAll('[data-stx-xdata]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n // Skip if scope already registered (e.g. nav scope that persists across navigations)\n if (scopeId && window.stx._scopes && window.stx._scopes[scopeId]) return;\n var xdata = el.getAttribute('data-stx-xdata');\n if (!xdata) return;\n // Assign a scope ID if not already present\n if (!scopeId) {\n scopeId = '__stx_scope_spa_' + (++window.stx._scopeCounter);\n el.setAttribute('data-stx-scope', scopeId);\n }\n // The init expression, which used to be dropped here. A scope\n // re-initialized with its data and none of its setup renders every\n // binding at its initial value and starts nothing - a live region\n // showing its empty state forever, which is indistinguishable from one\n // where nothing has happened yet.\n var xinit = el.getAttribute('data-stx-xinit');\n console.log('[stx:load] initializing x-data scope:', scopeId, xdata.substring(0, 40));\n window.__stx_reactive.initScope(el, xdata, [], {}, xinit || null);\n });\n }\n\n // Apply scope from [data-stx-scope] elements and process them.\n // Walk document.body (not just container) so layout-level scopes dropped\n // by a full-body-swap SPA nav (e.g. nav/header/footer when the layout\n // group changes) get bound. The __stx_disposers guard makes the walk\n // idempotent \u2014 persistent layout scopes across same-layout navs are\n // skipped instead of double-disposed. See stacksjs/stx#1697.\n document.body.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n var scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n // Record the bound element for the orphan sweep (#1775) \u2014 see the\n // DOMContentLoaded walk above for the rationale.\n if (scopeVars) scopeVars.__el = el;\n // Deferred island reached via SPA navigation (#1746): its setup script is\n // inert (type=\"stx/island\"), so the scope isn't registered yet. Arm the\n // hydration trigger (deferHydration) instead of skipping it \u2014 mirrors the\n // initial-load DOMContentLoaded path, which has the same guard. Without\n // this, a client=\"visible|idle|\u2026\" island on a page reached by SPA nav\n // (inline OR chunked) never hydrates.\n if (!scopeVars && el.hasAttribute && el.hasAttribute('stx-hydrate')\n && !el.__stx_hydration_scheduled\n && document.querySelector('script[data-stx-island=\"' + scopeId + '\"]')) {\n processElement(el, componentScope);\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n return;\n }\n if (!scopeVars) return;\n el.__stx_parent_scope = el.__stx_parent_scope\n || resolveComponentCallerScope(el, spaPageScopeSnapshot);\n bindParentComponentProps(el, el.__stx_parent_scope);\n // Already bound: a layout component that stayed on the page. Its\n // bindings are live and read its own scope, so there is nothing to\n // merge \u2014 and merging it AFTER the destination page's setup let a name\n // the two share take the component's value for the page. The offline\n // banner's connected flag read as a Settings card's \"Connected\".\n if (el.__stx_disposers) return;\n Object.assign(componentScope, scopeVars);\n var disposeEffects = trackEffects(function() { processElement(el, componentScope); });\n el.__stx_disposers = disposeEffects;\n // A replacement layout's scope can live outside the router container.\n // Reveal it after binding, matching the initial hydration and mount paths.\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n\n // The page's own names win over its components' locals. The walk above\n // merges each component's locals into the scope the container is bound\n // with, so a component declaring a name the page also declares took it\n // over for the whole page: HQ's coach dashboard aliases store signals as\n // loading and roster, a card further down declares its own loading and\n // roster, and reached by the router the page's\n // :if=\"loading && !roster.length\" read the card's and never cleared. A\n // full load binds the page before any component, so it never saw this.\n // A component's own bindings resolve its locals through its scope element,\n // and a name only a component declares stays reachable as before.\n Object.assign(componentScope, spaPageScopeSnapshot);\n\n // Process the container content \u2014 bind {{ }}, :attr, @event directives.\n // Run synchronously (not in setTimeout) so componentScope is captured correctly.\n // The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.\n console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n if (!container.__stx_scope) {\n // Dispose previous effects on the container (from prior navigation)\n if (container.__stx_disposers && typeof container.__stx_disposers === 'function') {\n container.__stx_disposers();\n }\n console.log('[stx:load] processElement on container');\n var disposeEffects = trackEffects(function() { processElement(container, componentScope); });\n container.__stx_disposers = disposeEffects;\n } else {\n console.log('[stx:load] SKIPPED processElement \u2014 container has __stx_scope');\n }\n\n // Remove x-cloak\n container.removeAttribute('x-cloak');\n container.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n // Fire mount callbacks from scoped components. Walk document.body so\n // layout-level scopes added by a full-body swap mount; __mounted guard\n // prevents persistent layout scopes from re-firing their onMount on\n // every same-layout SPA nav. See stacksjs/stx#1697.\n document.body.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n var scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted) {\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n });\n\n // Flush global mountCallbacks (from scripts re-executed after SPA content swap)\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n mountCallbacks.length = 0;\n\n // Everything that should have hydrated has now had its chance (#1773).\n auditHydration(container, 'stx:load');\n }\n";
|
|
2
|
+
export declare const SIGNALS_SPA_LOAD_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** State and derived primitives embedded in the browser signals runtime. */
|
|
2
|
-
export declare const SIGNALS_STATE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_STATE_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Browser storage composables used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_STORAGE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_STORAGE_RUNTIME: string;
|