@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
|
/** DOM binding helpers shared by generated client directives. */
|
|
2
|
-
export declare const SIGNALS_BINDING_UTILS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_BINDING_UTILS_RUNTIME: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Runtime preamble installed before any reactive APIs are created. */
|
|
2
|
-
export declare const SIGNALS_PREAMBLE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_PREAMBLE_RUNTIME: string;
|
|
3
3
|
/** Browser-only setup that must run after the host adapter is selected. */
|
|
4
|
-
export declare const SIGNALS_CLOAK_RUNTIME
|
|
4
|
+
export declare const SIGNALS_CLOAK_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Reactive class binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_CLASS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_CLASS_RUNTIME: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SIGNALS_COMPONENT_API_RUNTIME
|
|
1
|
+
export declare const SIGNALS_COMPONENT_API_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Component-scope hydration helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_COMPONENT_HYDRATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_COMPONENT_HYDRATION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Parent-to-component reactive prop bindings for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_COMPONENT_PROPS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_COMPONENT_PROPS_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Conditional-chain discovery helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_CONDITIONAL_CHAIN_RUNTIME
|
|
2
|
+
export declare const SIGNALS_CONDITIONAL_CHAIN_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Conditional component scope preservation for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_CONDITIONAL_COMPONENT_RUNTIME
|
|
2
|
+
export declare const SIGNALS_CONDITIONAL_COMPONENT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** SPA container cleanup used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_CONTAINER_CLEANUP_RUNTIME
|
|
2
|
+
export declare const SIGNALS_CONTAINER_CLEANUP_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Computed helpers and component value sharing for the client runtime. */
|
|
2
|
-
export declare const SIGNALS_CONTEXT_RUNTIME
|
|
2
|
+
export declare const SIGNALS_CONTEXT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Cookie signal composable used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_COOKIE_RUNTIME
|
|
2
|
+
export declare const SIGNALS_COOKIE_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** DevTools introspection used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DEVTOOLS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_DEVTOOLS_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Alert and confirm dialog helpers used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DIALOG_RUNTIME = " // \u2500\u2500 Alert & Confirm dialogs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Styled replacements for window.alert() and window.confirm().\n // Both return Promises and render into a temporary modal overlay.\n\n var _dialogId = 0;\n\n // Modality - the scroll lock, the inert page behind, the one Escape and the\n // one Tab trap - comes from the overlay stack above, which these dialogs\n // share with every other overlay on the page (#1998, stacksjs/stx#2057).\n\n /** Dialogs animate unless the reader asked them not to (#1998 item 5). */\n function _dialogReducedMotion() {\n try {\n return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);\n }\n catch (_e) {\n return false;\n }\n }\n var _dialogIcons = {\n info: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"/></svg>',\n warning: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#d97706\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>',\n error: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>',\n success: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#16a34a\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>',\n question: '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#6366f1\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>'\n };\n\n function _createDialog(message, options, isConfirm) {\n var opts = options || {};\n var type = opts.type || (isConfirm ? 'question' : 'info');\n var title = opts.title || '';\n var confirmText = opts.confirmText || 'OK';\n var cancelText = opts.cancelText || 'Cancel';\n var id = 'stx-dialog-' + (++_dialogId);\n // Resolve dark from what the APP decided, not only from the OS. stx's own\n // color-mode boot writes a class (default 'dark') and/or an attribute\n // (e.g. data-theme) onto <html>, so an app pinned to light on a dark OS used\n // to get a dark dialog over a light page. An explicit opts.dark wins over\n // both, and the media query stays as the last resort. See #1875.\n var isDark = _resolveDark(opts.dark);\n var bg = isDark ? '#1f2937' : '#ffffff';\n var textColor = isDark ? '#f3f4f6' : '#1f2937';\n var subColor = isDark ? '#9ca3af' : '#6b7280';\n var icon = _dialogIcons[type] || _dialogIcons.info;\n\n return new Promise(function(resolve) {\n // Inline transitions cannot be reached by a stylesheet media query, so the\n // preference is read here instead (#1998 item 5). One matchMedia probe\n // rather than usePreferredReducedMotion(): that returns a signal with a\n // change listener, and an imperative dialog that reads the value once at\n // open time would leak one listener per call.\n var still = _dialogReducedMotion();\n var fade = still ? '' : 'transition:opacity 0.2s ease;';\n var scale = still ? '' : 'transition:transform 0.2s ease;';\n\n var backdrop = document.createElement('div');\n backdrop.id = id;\n backdrop.style.cssText = 'position:fixed;inset:0;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:' + (still ? '1' : '0') + ';' + fade + 'font-family:system-ui,-apple-system,sans-serif';\n backdrop.setAttribute('role', 'alertdialog');\n backdrop.setAttribute('aria-modal', 'true');\n\n var panel = document.createElement('div');\n panel.style.cssText = 'max-width:24rem;width:calc(100% - 2rem);border-radius:0.75rem;padding:1.5rem;background:' + bg + ';color:' + textColor + ';box-shadow:0 20px 60px rgba(0,0,0,0.3);transform:scale(' + (still ? '1' : '0.95') + ');' + scale + 'text-align:center';\n\n var iconDiv = document.createElement('div');\n iconDiv.style.cssText = 'display:flex;justify-content:center;margin-bottom:1rem';\n iconDiv.innerHTML = icon;\n panel.appendChild(iconDiv);\n\n if (title) {\n var titleEl = document.createElement('h3');\n titleEl.id = id + '-title';\n titleEl.style.cssText = 'margin:0 0 0.5rem;font-size:1.125rem;font-weight:600';\n titleEl.textContent = title;\n panel.appendChild(titleEl);\n // role=alertdialog was announced with no accessible name at all.\n backdrop.setAttribute('aria-labelledby', titleEl.id);\n }\n\n var msgEl = document.createElement('p');\n msgEl.id = id + '-message';\n msgEl.style.cssText = 'margin:0 0 1.25rem;font-size:0.875rem;line-height:1.5;color:' + subColor;\n msgEl.textContent = message;\n panel.appendChild(msgEl);\n backdrop.setAttribute('aria-describedby', msgEl.id);\n if (!title)\n backdrop.setAttribute('aria-label', message);\n\n var btnRow = document.createElement('div');\n btnRow.style.cssText = 'display:flex;gap:0.75rem;justify-content:center';\n\n // Captured before the dialog steals focus, so it can be handed back on\n // close. Without this a keyboard or screen-reader user is dropped at the\n // top of the document every time a dialog closes.\n var previouslyFocused = document.activeElement;\n var closed = false;\n\n function cleanup(result) {\n // Guarded: the escape handler used to be able to fire after a button had\n // already closed the dialog, because the listener outlived it.\n if (closed) return;\n closed = true;\n\n // The fade is 200ms and resolve() is immediate, so for those 200ms a\n // full-viewport element at z-index 999999 was still hit-testing at the\n // centre of the screen - after the caller's await had already returned\n // (#1998 item 6). Fading out is right; swallowing clicks is not.\n backdrop.style.pointerEvents = 'none';\n backdrop.style.opacity = '0';\n if (!still) panel.style.transform = 'scale(0.95)';\n setTimeout(function() { backdrop.remove(); }, still ? 0 : 200);\n\n // Out of the stack BEFORE resolving, so a caller that opens another\n // dialog the moment this one answers does not land under a backdrop\n // that is still fading. That also unlocks the page and clears inert\n // when this was the last overlay, hands modality back to the one\n // underneath when it was not, and gives focus back to the opener.\n overlays.close(id);\n resolve(result);\n }\n\n // Declared out here rather than inside the branch: the focus decision\n // below needs to know whether a Cancel button exists at all.\n var cancelBtn = null;\n if (isConfirm) {\n cancelBtn = document.createElement('button');\n cancelBtn.textContent = cancelText;\n cancelBtn.style.cssText = 'padding:0.5rem 1.25rem;border-radius:0.5rem;font-size:0.875rem;font-weight:500;cursor:pointer;border:1px solid ' + (isDark ? '#374151' : '#d1d5db') + ';background:transparent;color:' + textColor + ';transition:background 0.15s';\n cancelBtn.onmouseover = function() { this.style.background = isDark ? '#374151' : '#f3f4f6'; };\n cancelBtn.onmouseout = function() { this.style.background = 'transparent'; };\n cancelBtn.onclick = function() { cleanup(false); };\n btnRow.appendChild(cancelBtn);\n }\n\n var okBtn = document.createElement('button');\n okBtn.textContent = confirmText;\n var btnColor = type === 'error' ? '#dc2626' : type === 'warning' ? '#d97706' : '#5672cd';\n okBtn.style.cssText = 'padding:0.5rem 1.25rem;border-radius:0.5rem;font-size:0.875rem;font-weight:500;cursor:pointer;border:none;background:' + btnColor + ';color:#fff;transition:opacity 0.15s';\n okBtn.onmouseover = function() { this.style.opacity = '0.9'; };\n okBtn.onmouseout = function() { this.style.opacity = '1'; };\n okBtn.onclick = function() { cleanup(isConfirm ? true : undefined); };\n btnRow.appendChild(okBtn);\n\n panel.appendChild(btnRow);\n backdrop.appendChild(panel);\n document.body.appendChild(backdrop);\n\n // Animate in\n if (!still) {\n void backdrop.offsetHeight;\n backdrop.style.opacity = '1';\n panel.style.transform = 'scale(1)';\n }\n\n\n /*\n * Initial focus, which was an unconditional okBtn.focus() (#1998 item 3).\n *\n * type: 'error' already paints that button red, so the API knows the\n * action is destructive - and still handed it the keyboard, where a stray\n * Enter or Space confirmed the delete. An error-type confirm now defaults\n * to Cancel, and defaultFocus overrides either way.\n *\n * An alert has only one button, so it keeps it: there is nothing\n * destructive to land on and focus has to go somewhere inside the trap.\n */\n var focusTarget = okBtn;\n if (isConfirm && cancelBtn) {\n var want = opts.defaultFocus;\n if (want === 'cancel' || (!want && type === 'error')) focusTarget = cancelBtn;\n else if (want === 'confirm') focusTarget = okBtn;\n }\n\n // Onto the overlay stack, which locks the page, makes it inert behind\n // this backdrop, traps Tab inside the panel and answers Escape for\n // whichever dialog is on top - so one Escape answers one dialog\n // (#1998 item 4) and a component Dialog underneath stays open.\n overlays.open(id, {\n panel: panel,\n root: backdrop,\n initialFocus: focusTarget,\n opener: previouslyFocused,\n onEscape: function() { cleanup(isConfirm ? false : undefined); }\n });\n });\n }\n\n function stxAlert(message, options) {\n return _createDialog(message, options, false);\n }\n\n function stxConfirm(message, options) {\n return _createDialog(message, options, true);\n }\n";
|
|
2
|
+
export declare const SIGNALS_DIALOG_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** DOM-ready initialization used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DOM_READY_RUNTIME = " // ==========================================================================\n // Auto-initialization\n // ==========================================================================\n\n // A dev runtime may be evaluated again by HMR, an embed, or a test harness.\n // Replace the previous listener so only the latest runtime closure can own\n // componentScope and reactive subscriptions.\n if (window.__stxDomReadyHandler) {\n document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);\n }\n const stxDomReadyHandler = () => {\n console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');\n // Track which scoped elements have been processed\n const processedScopes = new Set();\n\n // Layout expansion can remove the data-stx marker from a page's first\n // element while leaving markers owned by the layout itself. The generated\n // page setup is still queued explicitly, so adopt it when its own marker\n // did not survive.\n const latestSetup = window.stx._latestSetup;\n const latestSetupName = typeof latestSetup === 'function' ? latestSetup.name : '';\n const hasLatestSetupMarker = latestSetupName && Array.from(document.querySelectorAll('[data-stx]'))\n .some(el => el.getAttribute('data-stx') === latestSetupName);\n if (latestSetup && !hasLatestSetupMarker) {\n try {\n const result = latestSetup();\n if (typeof result === 'object' && result !== null)\n Object.assign(componentScope, result);\n }\n catch (e) {\n console.error('[stx] initial setup error:', e);\n }\n }\n\n // Register page setup before mounting child components. Projected slot\n // content belongs to the caller, so child mounts need the caller's signals\n // available when they walk their own rendered roots.\n document.querySelectorAll('[data-stx]').forEach(el => {\n const setupName = el.getAttribute('data-stx');\n console.log('[DOMContentLoaded] data-stx:', setupName, 'el:', el.tagName, 'fn exists:', !!(setupName && window[setupName]));\n if (setupName && window[setupName]) {\n // Contained, like the two sibling setup call sites. An uncaught throw\n // here aborted the whole forEach and everything after it in this\n // handler, so ONE bad name in ONE page's setup left every root on the\n // page unhydrated \u2014 the user sees raw {{ }}, and the console names the\n // identifier without saying it cost them the document (#1805).\n try {\n const result = window[setupName]();\n console.log('[DOMContentLoaded] setup returned:', result ? Object.keys(result).slice(0, 10) : 'null');\n if (typeof result === 'object' && result !== null) {\n Object.assign(componentScope, result);\n }\n }\n catch (e) {\n console.error('[stx] page setup \"' + setupName + '\" threw; this root will not hydrate:', e);\n }\n }\n });\n var pageScopeSnapshot = { ...componentScope };\n\n /*\n * Any x-data scope the reactive bridge did not reach, initialized here.\n *\n * The bridge script addresses each scope by a selector it generated, and\n * that numbering restarts per render - so a page carrying three component\n * islands emits three scripts all looking for the same scope id, and two of\n * the three scopes are never initialized at all. The symptom is the\n * quietest one available: the markup is there, every binding shows its\n * initial value, and whatever x-init was meant to start never starts.\n *\n * Registered scopes are skipped, so the bridge stays authoritative where it\n * did run and this only picks up what it missed. The init expression is\n * read from data-stx-xinit, which the server preserves for exactly this.\n *\n * No backticks in this comment, deliberately: it lives inside the runtime\n * source that is embedded as a template literal, and one would end the\n * literal and take the whole file's syntax with it.\n */\n if (window.__stx_reactive && window.__stx_reactive.initScope) {\n document.querySelectorAll('[data-stx-xdata]').forEach(function(el) {\n var scopeId = el.getAttribute('data-stx-scope');\n if (scopeId && window.stx._scopes && window.stx._scopes[scopeId]) return;\n if (el.__stx_scope_initialized) return;\n\n var xdata = el.getAttribute('data-stx-xdata');\n if (!xdata) return;\n\n if (!scopeId) {\n scopeId = '__stx_scope_island_' + (++window.stx._scopeCounter);\n el.setAttribute('data-stx-scope', scopeId);\n }\n\n el.__stx_scope_initialized = true;\n\n try {\n window.__stx_reactive.initScope(el, xdata, [], {}, el.getAttribute('data-stx-xinit') || null);\n }\n catch (e) {\n console.error('[stx] island scope init error:', e);\n }\n });\n }\n\n // Process mount queue (from stx.mount() calls during loading) only after\n // caller setup is available for Vue-style projected slot ownership.\n mountQueue.forEach(function(fn) { fn(); });\n mountQueue = [];\n\n // A queued layout mount owns a separate $refs map and merges it into the\n // compatibility scope. Page useRef accessors already captured the page's\n // map during setup; bind its DOM back into that same map before onMount.\n // Keep the layout's other exposed names available for legacy bindings.\n componentScope.$refs = pageScopeSnapshot.$refs;\n\n // Bind page roots after child components have registered their local scope.\n document.querySelectorAll('[data-stx]').forEach(el => {\n console.log('[DOMContentLoaded] processElement on:', el.tagName, 'scope keys:', Object.keys(componentScope).slice(0, 10));\n var disposeEffects = trackEffects(function() {\n // The server's list when the page shipped one, the walk otherwise.\n if (!processFromManifest(el, componentScope, window.__stx_bindings)) processElement(el);\n });\n el.__stx_disposers = disposeEffects;\n\n // Remove x-cloak after bindings are applied (prevents FOUC)\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n });\n\n // Multi-root fragment fix: a no-body> setup page tags only the FIRST\n // top-level element with data-stx (signal-processing.ts marks one element),\n // so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text\n // never hydrated, which read as \"{{ }} doesn't work under :if/:for\". The\n // setup(s) above already populated the shared global componentScope, so\n // process each un-hydrated sibling root under that same scope \u2014 same signals,\n // so cross-root state stays coupled.\n var stxRoots = document.querySelectorAll('[data-stx]');\n if (stxRoots.length && Object.keys(componentScope).length) {\n var rootParent = stxRoots[0].parentNode;\n if (rootParent && rootParent.children) {\n Array.prototype.slice.call(rootParent.children).forEach(function(sib) {\n if (sib.nodeType !== 1) return;\n if (sib.hasAttribute('data-stx') || sib.hasAttribute('data-stx-scope')) return;\n if (sib.tagName === 'SCRIPT' || sib.tagName === 'STYLE') return;\n if (sib.__stx_disposers) return; // already processed\n var disposeSib = trackEffects(function() { processElement(sib); });\n sib.__stx_disposers = disposeSib;\n sib.removeAttribute('x-cloak');\n sib.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n }\n }\n\n // Process scoped components FIRST (their scripts have already registered scope variables)\n var allScopes = document.querySelectorAll('[data-stx-scope]');\n console.log('[stx] found', allScopes.length, 'data-stx-scope elements');\n allScopes.forEach(el => {\n const scopeId = el.getAttribute('data-stx-scope');\n console.log('[stx] scope:', scopeId, 'registered:', !!(window.stx._scopes && window.stx._scopes[scopeId]), 'el:', el.tagName);\n processedScopes.add(el);\n\n const scopeVars = window.stx._scopes && window.stx._scopes[scopeId];\n // Record the element this scope is bound to so cleanupContainer can tell a\n // dead registry entry (element replaced by an SPA swap) from a live one.\n // See sweepOrphanedScopes / #1775.\n if (scopeVars) scopeVars.__el = el;\n\n // Deferred island (#1746): its setup script (type=\"stx/island\") hasn't run\n // yet, so the scope isn't registered. Arm the hydration trigger anyway \u2014\n // processElement sees stx-hydrate and defers; deferHydration's run()\n // executes the script (registering the scope + running side-effectful\n // setup like fetches) and binds on the trigger. Reveal the HTML now.\n var isDeferredIsland = !scopeVars && el.hasAttribute && el.hasAttribute('stx-hydrate')\n && !!document.querySelector('script[data-stx-island=\"' + scopeId + '\"]');\n if (isDeferredIsland) {\n processElement(el);\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n return;\n }\n\n if (!scopeVars) return;\n\n // Forwarded props and events belong to the caller. Capture its scope\n // before this component's locals are merged, so identical child names\n // cannot shadow expressions such as :total-items=\"totalItems\".\n el.__stx_parent_scope = el.__stx_parent_scope\n || resolveComponentCallerScope(el, pageScopeSnapshot);\n bindParentComponentProps(el, el.__stx_parent_scope);\n\n // Merge component scope vars into componentScope (don't restore - keep for head elements)\n // This ensures expressions can access component variables even for elements\n // where findElementScope might not work (e.g., cloned elements not yet in DOM)\n if (scopeVars) {\n componentScope = { ...componentScope, ...scopeVars };\n }\n\n console.log('[stx] calling processElement on scope:', scopeId, 'componentScope keys:', Object.keys(componentScope).length, 'scopeVars keys:', Object.keys(scopeVars).length);\n var disposeEffects = trackEffects(function() { processElement(el); });\n el.__stx_disposers = disposeEffects;\n console.log('[stx] scope processed OK:', scopeId);\n\n // Remove x-cloak after bindings are applied\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n\n // Run scope-specific mount callbacks (mark mounted so _handleStxLoad\n // doesn't re-fire onMount on persistent layout scopes \u2014 see #1697).\n // EXCEPT when this scope's hydration is deferred (stx-hydrate, e.g. a\n // client=visible|idle island, #1746): processElement above only SCHEDULED\n // the work, so onMount must fire when the trigger actually hydrates the\n // scope, not now. deferHydration's run() flushes it then.\n var scopeDeferred = el.hasAttribute && el.hasAttribute('stx-hydrate') && !el.__stx_hydrated;\n // A component behind a false :if is in the document's MARKUP but not in\n // the document: bindIf detached the subtree before this walk reached it,\n // while the component's own setup script already ran and queued its\n // onMount. Mounting it from here anyway is what made being mounted\n // unusable as an open state (stacksjs/stx#2036) -- three gated modal\n // shells each locked body scroll and registered an Escape handler before\n // anything had been opened, so the page could not be scrolled and Escape\n // reached whichever instance registered last.\n //\n // Left unmounted rather than mounted-and-torn-down, so hydrateComponentScopes\n // flushes it when bindIf shows the subtree -- the same deferral\n // stx-hydrate uses above, and the same flush an island gets.\n var scopeDetached = el.isConnected === false;\n if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted && !scopeDeferred && !scopeDetached) {\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n });\n\n // Run global mount callbacks (from partial <script client> blocks that call onMount)\n // These are pushed during script execution, before DOMContentLoaded\n console.log('[stx] running global mountCallbacks:', mountCallbacks.length);\n runMountCallbacks(mountCallbacks, destroyCallbacks);\n mountCallbacks.length = 0;\n\n // Auto-process elements with data-stx-auto (skip already processed scoped elements)\n document.querySelectorAll('[data-stx-auto]').forEach(el => {\n // Process element but skip children that are in scoped containers\n processElementSkipScopes(el, processedScopes);\n\n // Remove x-cloak after bindings are applied\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n });\n\n // Process head> elements (title, meta) that may contain {{ }} expressions\n // Use componentScope which now contains variables from processed components\n const headElements = document.querySelectorAll('head title, head meta[content]');\n headElements.forEach(el => {\n if (el.tagName === 'TITLE') {\n const text = el.textContent;\n if (text && text.includes('{{')) {\n effect(() => {\n try {\n let result = text;\n const matches = text.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);\n if (matches) {\n matches.forEach(match => {\n const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');\n const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);\n const value = fn(...__stxArgs(fn, componentScope));\n result = result.replace(match, value != null ? value : '');\n });\n }\n el.textContent = result;\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Title expression error:', e);\n }\n });\n }\n }\nelse if (el.tagName === 'META') {\n const content = el.getAttribute('content');\n if (content && content.includes('{{')) {\n // Skip build-time placeholders like {{__TITLE__}}\n const hasOnlyPlaceholders = !content.replace(/\\{\\{\\s*__[A-Z_]+__\\s*\\}\\}/g, '').includes('{{');\n if (hasOnlyPlaceholders) return;\n effect(() => {\n try {\n let result = content;\n const matches = content.match(/\\{\\{\\s*(.+?)\\s*\\}\\}/g);\n if (matches) {\n matches.forEach(match => {\n const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');\n if (/^__[A-Z_]+__$/.test(expr.trim())) return;\n const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);\n const value = fn(...__stxArgs(fn, componentScope));\n result = result.replace(match, value != null ? value : '');\n });\n }\n el.setAttribute('content', result);\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Meta expression error:', e);\n }\n });\n }\n }\n });\n\n // Everything that should have hydrated has now had its chance (#1773).\n auditHydration(document.body, 'DOMContentLoaded');\n };\n window.__stxDomReadyHandler = stxDomReadyHandler;\n console.log('[stx] registering DOMContentLoaded handler');\n document.addEventListener('DOMContentLoaded', stxDomReadyHandler);\n";
|
|
2
|
+
export declare const SIGNALS_DOM_READY_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Drawer controls used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DRAWER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_DRAWER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Effects, batching, tracking, and signal utility helpers for the client runtime. */
|
|
2
|
-
export declare const SIGNALS_EFFECT_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EFFECT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Event-expression shorthand parser used by the client runtime. */
|
|
2
|
-
export declare const SIGNALS_EVENT_SHORTHAND_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EVENT_SHORTHAND_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Cached expression compilation helpers for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_EXPRESSION_COMPILER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EXPRESSION_COMPILER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Scope lookup and expression evaluation for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_EXPRESSION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_EXPRESSION_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Shared HTTP transport, hooks, errors, and CSRF support for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_FETCH_TRANSPORT_RUNTIME = " // Short, ref-free repr of a value for the mutation log (so the buffer holds no\n // live references and big objects don't bloat it).\n function __stxShort(v) {\n try {\n if (typeof v === 'string') return v.length > 40 ? (v.slice(0, 40) + '\u2026') : v;\n if (v === null || typeof v !== 'object') return v;\n var s = JSON.stringify(v);\n return s.length > 60 ? (s.slice(0, 60) + '\u2026') : s;\n } catch (e) { return '[unserializable]'; }\n }\n // Wraps fetch with timing + a timeline record (the data layer's queries).\n // Turn a non-ok Response into an Error, reading the body FIRST.\n //\n // Every data primitive threw a synthesized 'HTTP nnn: statusText' before\n // touching the body, so whatever the server actually said \u2014 a validation\n // map, a rate-limit reason, an auth message \u2014 was unreachable from any stx\n // primitive, with no escape hatch (stacksjs/stx#1848). That is the single\n // most cited reason an app keeps writing raw fetch() calls.\n //\n // The body is attached rather than only interpolated: err.data is what a\n // caller needs to render field errors, and err.status is what it needs to\n // tell 401 from 500 without parsing the message.\n function __stxRawBody(body) {\n return (typeof FormData !== 'undefined' && body instanceof FormData)\n || (typeof Blob !== 'undefined' && body instanceof Blob)\n || (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams)\n || (typeof ArrayBuffer !== 'undefined' && (body instanceof ArrayBuffer || ArrayBuffer.isView(body)));\n }\n\n async function __stxHttpError(response) {\n var body = null;\n var text = '';\n try { text = await response.text(); } catch (e) { text = ''; }\n if (text) {\n try { body = JSON.parse(text); } catch (e) { body = text; }\n }\n var detail = '';\n if (body && typeof body === 'object') detail = body.message || body.error || '';\n else if (typeof body === 'string') detail = body.slice(0, 200);\n var message = 'HTTP ' + response.status;\n if (response.statusText) message += ': ' + response.statusText;\n if (detail) message += ' - ' + detail;\n var err = new Error(message);\n err.status = response.status;\n err.statusText = response.statusText;\n err.data = body;\n err.response = response;\n return err;\n }\n\n // One place an app can reach the data layer. Every stx data primitive goes\n // through __stxFetch, the only fetch call in this runtime, so a single pair\n // of hooks covers useFetch, useQuery and useMutation (#1855).\n //\n // Without it there is no way to attach an Authorization header or notice a\n // 401 in one place, which is the reason an app keeps hand-written fetch\n // calls sitting next to the primitives that were meant to replace them.\n //\n // Hooks mutate the context they are handed and their return value is\n // ignored \u2014 the ofetch shape most people will already know. Throwing from a\n // hook fails the request, which is what a token-refresh flow wants.\n var __stxFetchHooks = { onRequest: null, onResponse: null, onResponseError: null };\n\n // Double-submit CSRF, echoed for every same-origin unsafe request. A server\n // using the pattern (Stacks does, by default, on every POST/PUT/PATCH/DELETE)\n // plants a readable cookie and rejects any unsafe request whose header does\n // not repeat it. Nothing here repeated it, so a form posting through\n // useMutation - or the framework's own CMS form block - got 403 \"CSRF token\n // mismatch\" on a stock install. The same thing axios does for XSRF-TOKEN.\n // Only same-origin: the token must never leave for another host.\n var __stxCsrf = { cookie: 'X-CSRF-Token', header: 'X-CSRF-Token' };\n\n function __stxCookie(name) {\n if (typeof document === 'undefined' || !document.cookie) return null;\n var parts = document.cookie.split(';');\n for (var i = 0; i < parts.length; i++) {\n var at = parts[i].indexOf('=');\n if (at === -1) continue;\n if (parts[i].slice(0, at).trim() !== name) continue;\n var value = parts[i].slice(at + 1).trim();\n try { return value ? decodeURIComponent(value) : null; } catch (e) { return value || null; }\n }\n return null;\n }\n\n // Whether this request should carry the token: unsafe, and same-origin.\n function __stxWantsCsrf(url, opts) {\n if (!__stxCsrf) return false;\n var method = String((opts && opts.method) || 'GET').toUpperCase();\n if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS') return false;\n // A path is same-origin by definition; only an absolute URL needs its\n // origin compared, and one that cannot be parsed is not trusted.\n var target = String(url);\n if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.slice(0, 2) === '//') {\n if (typeof location === 'undefined') return false;\n try {\n if (new URL(target).origin !== location.origin) return false;\n } catch (e) { return false; }\n }\n return true;\n }\n\n // Fetch the cookie before the first unsafe request, when the page did not\n // bring one. A page served from a CDN cache cannot: the edge strips\n // Set-Cookie from a cached response, or it would hand one visitor's token to\n // everyone. So the only pages that could post a form were the ones nobody\n // cached. `csrf.prime` names a same-origin GET that sets the cookie (any\n // safe Stacks route does); one request, shared by concurrent callers, and\n // only when the cookie is missing.\n var __stxCsrfPriming = null;\n async function __stxPrimeCsrf(url, opts) {\n if (!__stxCsrf || !__stxCsrf.prime || !__stxWantsCsrf(url, opts)) return;\n if (__stxCookie(__stxCsrf.cookie)) return;\n if (!__stxCsrfPriming) {\n __stxCsrfPriming = fetch(__stxCsrf.prime, { credentials: 'same-origin', headers: { Accept: 'application/json' } })\n .then(function () {}, function () {})\n .then(function () { __stxCsrfPriming = null; });\n }\n await __stxCsrfPriming;\n }\n\n function __stxApplyCsrf(url, opts) {\n if (!__stxWantsCsrf(url, opts)) return;\n var token = __stxCookie(__stxCsrf.cookie);\n if (!token) return;\n var headers = __stxHeaders(opts.headers);\n var wanted = __stxCsrf.header.toLowerCase();\n for (var key in headers) {\n // A token the caller set on purpose wins.\n if (key.toLowerCase() === wanted) return;\n }\n headers[__stxCsrf.header] = token;\n opts.headers = headers;\n }\n\n function configureFetch(cfg) {\n cfg = cfg || {};\n // Unlike the hooks below, CSRF settings persist unless named: an app that\n // installs an Authorization hook has not asked to stop sending the token.\n // `csrf: false` turns it off; `{ cookie, header }` renames either side.\n if (Object.prototype.hasOwnProperty.call(cfg, 'csrf')) {\n __stxCsrf = cfg.csrf === false || cfg.csrf === null\n ? null\n : { cookie: (cfg.csrf && cfg.csrf.cookie) || 'X-CSRF-Token', header: (cfg.csrf && (cfg.csrf.header || cfg.csrf.cookie)) || 'X-CSRF-Token', prime: (cfg.csrf && typeof cfg.csrf.prime === 'string' && cfg.csrf.prime) || null };\n }\n // Replace rather than stack: a module re-evaluated by hot reload or by a\n // SPA script re-run must not end up with the same interceptor installed\n // twice, sending two Authorization headers or counting a 401 twice.\n __stxFetchHooks.onRequest = typeof cfg.onRequest === 'function' ? cfg.onRequest : null;\n __stxFetchHooks.onResponse = typeof cfg.onResponse === 'function' ? cfg.onResponse : null;\n // Fires for a non-ok response and for a thrown fetch (network error). If it\n // returns a Response, that Response replaces the original \u2014 this is how a\n // 401 -> refresh -> retry is expressed once instead of per call site. The\n // retry itself belongs to the hook: it should refresh the token and re-issue\n // the request with a plain fetch() (not this data layer) so it does not\n // re-enter the hook and loop. Returning nothing lets the error stand.\n __stxFetchHooks.onResponseError = typeof cfg.onResponseError === 'function' ? cfg.onResponseError : null;\n }\n\n // headers may be a function, so it can be evaluated per request rather than\n // captured once \u2014 a token that changes between calls. Object spread over a\n // function copies no own enumerable properties, so passing one used to\n // contribute nothing at all, in silence.\n function __stxHeaders(h) {\n return (typeof h === 'function' ? h() : h) || {};\n }\n\n async function __stxFetch(source, url, opts) {\n var t0 = __stxDevtoolsNow();\n opts = opts || {};\n // Before the hooks, so an onRequest hook sees (and may override) it.\n await __stxPrimeCsrf(url, opts);\n __stxApplyCsrf(url, opts);\n if (__stxFetchHooks.onRequest) {\n // Normalised first so a hook can write ctx.options.headers.Authorization\n // without having to create the bag itself.\n opts.headers = __stxHeaders(opts.headers);\n var reqCtx = { source: source, url: String(url), options: opts };\n await __stxFetchHooks.onRequest(reqCtx);\n // Reassignable, so a hook can prefix a baseURL or swap the options\n // wholesale instead of only mutating them.\n if (reqCtx.url) url = reqCtx.url;\n opts = reqCtx.options || opts;\n }\n var method = (opts && opts.method) || 'GET';\n // A hook may hand back a Response to use in place of the original. Anything\n // else (a truthy non-Response, undefined) leaves the outcome unchanged.\n function __stxIsResponse(v) { return !!v && typeof v.ok === 'boolean'; }\n try {\n var r = await fetch(url, opts);\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: r.status, ok: r.ok, ms: __stxDevtoolsNow() - t0 });\n if (__stxFetchHooks.onResponse) {\n await __stxFetchHooks.onResponse({ source: source, url: String(url), options: opts, response: r });\n }\n if (!r.ok && __stxFetchHooks.onResponseError) {\n var recovered = await __stxFetchHooks.onResponseError({ source: source, url: String(url), options: opts, response: r, error: null });\n if (__stxIsResponse(recovered)) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: recovered.status, ok: recovered.ok, retried: true, ms: __stxDevtoolsNow() - t0 });\n return recovered;\n }\n }\n return r;\n } catch (e) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: 0, ok: false, error: String((e && e.message) || e), ms: __stxDevtoolsNow() - t0 });\n // A network-level failure (no Response) also reaches the hook, so a retry\n // can cover a dropped connection, not only an auth status.\n if (__stxFetchHooks.onResponseError) {\n var recoveredErr = await __stxFetchHooks.onResponseError({ source: source, url: String(url), options: opts, response: null, error: e });\n if (__stxIsResponse(recoveredErr)) {\n __stxDevtoolsRecordQuery({ source: source, url: String(url), method: method, status: recoveredErr.status, ok: recoveredErr.ok, retried: true, ms: __stxDevtoolsNow() - t0 });\n return recoveredErr;\n }\n }\n throw e;\n }\n }";
|
|
2
|
+
export declare const SIGNALS_FETCH_TRANSPORT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Reactive list binding for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_FOR_RUNTIME = " function bindFor(el, passedScope = componentScope, attrName = '@for') {\n if (el.__stx_for_bound) return;\n el.__stx_for_bound = true;\n const expr = el.getAttribute(attrName);\n // Support: \"item in list\", \"item, index in list\", \"(item, index) in list\"\n const match = expr.match(/^\\s*\\(?\\s*(\\w+)(?:\\s*,\\s*(\\w+))?\\s*\\)?\\s+(?:in|of)\\s+(.+)\\s*$/);\n\n if (!match) {\n console.warn('[STX] Invalid ' + attrName + ':', expr);\n return;\n }\n\n const [, itemName, indexName, listExpr] = match;\n let parent = el.parentNode;\n\n // Guard: if element has no parent, it's detached - skip processing\n if (!parent) {\n console.warn('[STX] bindFor: element has no parent, skipping');\n return;\n }\n\n const placeholder = stxHost.anchor('stx-for');\n const isTemplate = el.tagName === 'TEMPLATE';\n const componentSetupTemplates = [];\n if (!isTemplate && el.hasAttribute('data-stx-scope')) {\n const componentScopeId = el.getAttribute('data-stx-scope');\n const componentTemplateScopeId = el.getAttribute('data-stx-template-scope') || componentScopeId;\n let setupSibling = el.nextSibling;\n while (setupSibling) {\n const nextSetupSibling = setupSibling.nextSibling;\n if (setupSibling.nodeType === Node.TEXT_NODE && !(setupSibling.textContent || '').trim()) {\n setupSibling = nextSetupSibling;\n continue;\n }\n if (setupSibling.nodeType === Node.COMMENT_NODE) {\n setupSibling = nextSetupSibling;\n continue;\n }\n if (setupSibling.nodeType === Node.ELEMENT_NODE\n && setupSibling.tagName === 'SCRIPT'\n && setupSibling.hasAttribute('data-stx-scoped')\n && ((setupSibling.textContent || '').indexOf(componentScopeId) !== -1\n || (componentTemplateScopeId && (setupSibling.textContent || '').indexOf(componentTemplateScopeId) !== -1))) {\n componentSetupTemplates.push(stxHost.clone(setupSibling));\n stxHost.remove(setupSibling);\n setupSibling = nextSetupSibling;\n continue;\n }\n break;\n }\n }\n\n // Check if element also has @if / :if - need to handle together\n const ifExpr = el.getAttribute('@if') || el.getAttribute(':if');\n\n // Feature #3: Check for @loading and @empty siblings/content\n const loadingExpr = el.getAttribute('@loading');\n const emptyExpr = el.getAttribute('@empty');\n\n // Look for sibling elements with @for-loading or @for-empty\n let loadingTemplate = null;\n let emptyTemplate = null;\n\n // Check next siblings for @for-loading and @for-empty\n let sibling = el.nextElementSibling;\n while (sibling) {\n if (sibling.hasAttribute('@for-loading')) {\n loadingTemplate = stxHost.clone(sibling);\n loadingTemplate.removeAttribute('@for-loading');\n stxHost.remove(sibling);\n sibling = el.nextElementSibling;\n continue;\n }\n if (sibling.hasAttribute('@for-empty')) {\n emptyTemplate = stxHost.clone(sibling);\n emptyTemplate.removeAttribute('@for-empty');\n stxHost.remove(sibling);\n sibling = el.nextElementSibling;\n continue;\n }\n break;\n }\n\n // Capture the scope NOW before element is removed from DOM\n const capturedScope = findElementScope(el) || findElementScope(parent);\n\n stxHost.insert(parent, placeholder, el);\n // Component setup scripts execute while the server-rendered loop source is\n // still in the document. That source becomes a template, not a live\n // instance, so reclaim all registered scopes before removing it. Every\n // rendered iteration receives remapped setup scripts and fresh scopes.\n disposeSubtreeScopes(el);\n stxHost.remove(el);\n\n // Capture :key expression BEFORE removing the attribute\n const keyExpr = el.getAttribute(':key') || el.getAttribute('x-bind:key');\n\n // For <template> elements, use the content; otherwise clone the element\n let templateContent;\n if (isTemplate) {\n templateContent = el.content;\n deferRowConditionals(templateContent);\n }\nelse {\n // Before the source is cloned into the row template, so that clone does\n // not build the conditional elements either.\n deferRowConditionals(el);\n const wrapper = stxHost.clone(el);\n wrapper.removeAttribute('@for');\n wrapper.removeAttribute(':for');\n wrapper.removeAttribute('x-for');\n wrapper.removeAttribute('@loading');\n wrapper.removeAttribute('@empty');\n wrapper.removeAttribute(':key');\n wrapper.removeAttribute('x-bind:key');\n // Also remove @if / :if / x-if - we'll handle it inline\n if (ifExpr) { wrapper.removeAttribute('@if'); wrapper.removeAttribute(':if'); wrapper.removeAttribute('x-if'); }\n templateContent = wrapper;\n }\n\n let currentElements = [];\n // One entry per list item, each holding EVERY node that item rendered.\n // currentElements stays flat for transition snapshots, but the keyed\n // diff below must pair a key with all of its nodes: a template row\n // routinely yields several (an element plus its surrounding text nodes),\n // and indexing a flat list by key position then paired the wrong node\n // with each key, leaving the list rotated after an update.\n let currentGroups = [];\n let currentKeys = [];\n let loadingElement = null;\n let emptyElement = null;\n\n // A <template :for> can contain another structural directive. That\n // nested directive replaces its source node with a placeholder and owns\n // additional live siblings around that placeholder. Track an explicit\n // boundary for every template iteration so keyed reuse moves the complete\n // live range, including nodes created by nested :for / :if bindings.\n // Moving only the original cloned nodes pulled static siblings past the\n // nested range on the next outer update (header, then rows became rows,\n // then header).\n const liveGroupNodes = (group) => {\n if (!isTemplate || !group || group.length < 2) return group || [];\n const start = group[0];\n const end = group[group.length - 1];\n if (!start || !end || start.parentNode !== parent || end.parentNode !== parent)\n return group.filter(groupNode => groupNode && groupNode.parentNode === parent);\n\n const nodes = [];\n let currentNode = start;\n while (currentNode) {\n nodes.push(currentNode);\n if (currentNode === end) break;\n currentNode = currentNode.nextSibling;\n }\n return nodes;\n };\n\n const removeGroup = (group) => {\n const liveNodes = liveGroupNodes(group);\n const liveSet = new Set(liveNodes);\n liveNodes.forEach(e => { disposeSubtreeEffects(e); disposeSubtreeScopes(e); stxHost.remove(e); });\n group.forEach(groupNode => {\n if (liveSet.has(groupNode)) return;\n disposeSubtreeEffects(groupNode);\n disposeSubtreeScopes(groupNode);\n stxHost.remove(groupNode);\n });\n };\n\n const clearRenderedItems = () => {\n currentGroups.forEach(removeGroup);\n currentElements = [];\n currentGroups = [];\n currentKeys = [];\n };\n\n // Helper to evaluate with captured scope (auto-unwraps signals)\n // NOTE: This eagerly reads ALL signals in scope \u2014 use evalLazy inside effects\n // to avoid over-broad dependency tracking.\n const evalExpr = (expression, extraScope = {}) => {\n try {\n // Skip placeholder expressions like __TITLE__ (build-time placeholders)\n if (/^__[A-Z_]+__$/.test(expression.trim())) {\n return expression;\n }\n // Use passedScope instead of componentScope to preserve context through nested processing\n const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };\n const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {\n if (typeof prop !== 'string') return false;\n return expressionCallsSignal(expression, prop)\n || expressionUsesSignalApi(expression, prop);\n });\n const fn = __stxCompileScoped(scope, [], 'return ' + expression);\n return fn(...__stxArgs(fn, unwrapScope));\n }\ncatch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);\n return '';\n }\n };\n\n // Lazy eval: uses with() so only variables ACTUALLY ACCESSED by the expression\n // trigger signal reads. This prevents unrelated signals (like modalOpen) from\n // being tracked as dependencies when we only care about the list signal.\n const evalLazy = (expression, extraScope = {}) => {\n try {\n if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;\n const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };\n const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {\n if (typeof prop !== 'string') return false;\n return expressionCallsSignal(expression, prop)\n || expressionUsesSignalApi(expression, prop);\n });\n // Compiled over the names the expression mentions (__stxCompileScoped),\n // so only those are read and register as dependencies. It used with()\n // over the proxy, which JavaScriptCore resolves through proxy traps on\n // every identifier - 36x slower than V8 for a list of message rows.\n const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');\n return fn(...__stxArgs(fn, unwrapScope));\n } catch (e) {\n if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);\n return '';\n }\n };\n\n // Helper to show loading state\n const showLoading = () => {\n hideLoading();\n hideEmpty();\n if (loadingTemplate) {\n loadingElement = stxHost.clone(loadingTemplate);\n stxHost.insert(parent, loadingElement, placeholder);\n }\n };\n\n // Helper to hide loading state\n const hideLoading = () => {\n if (loadingElement) {\n stxHost.remove(loadingElement);\n loadingElement = null;\n }\n };\n\n // Helper to show empty state\n const showEmpty = () => {\n hideLoading();\n hideEmpty();\n if (emptyTemplate) {\n emptyElement = stxHost.clone(emptyTemplate);\n stxHost.insert(parent, emptyElement, placeholder);\n const shownEmpty = emptyElement;\n shownEmpty.__stx_effect_disposers = trackEffects(function() { processElement(shownEmpty); });\n }\n };\n\n // Helper to hide empty state\n const hideEmpty = () => {\n if (emptyElement) {\n // A string @empty renders a text node, which has no subtree to dispose.\n if (emptyElement.nodeType === 1) disposeSubtreeEffects(emptyElement);\n stxHost.remove(emptyElement);\n emptyElement = null;\n }\n };\n\n // Helper: create DOM element(s) for a single list item.\n // The item is wrapped in a signal so bindings track it reactively. The pair\n // rides on the returned group, so reuse always reaches the signals the\n // bindings of THAT row actually read. A Map from key to signals could not:\n // two rows sharing a key overwrote each other in it, and the row that\n // reused the surviving entry was then bound to a signal nothing updated.\n const createItemElements = (item, index, key) => {\n const itemSignal = state(item);\n itemSignal._isStxLoopItem = true;\n const indexSignal = state(index);\n\n const itemScope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };\n itemScope[itemName] = itemSignal;\n if (indexName) itemScope[indexName] = indexSignal;\n\n const elements = [];\n if (isTemplate) {\n elements.push(stxHost.anchor('stx-for-item-start'));\n Array.from(templateContent.childNodes).forEach(node => {\n const clone = stxHost.clone(node);\n if (clone.nodeType === 1) {\n // Structural directives need a live parent. Keep the iteration\n // scope on the clone until the keyed diff inserts it, then bind.\n clone.__stx_for_scope = itemScope;\n markLoopRow(clone, itemName, itemSignal);\n }\n elements.push(clone);\n });\n elements.push(stxHost.anchor('stx-for-item-end'));\n } else {\n const clone = stxHost.clone(templateContent);\n clone.__stx_for_scope = itemScope;\n markLoopRow(clone, itemName, itemSignal);\n elements.push(clone);\n componentSetupTemplates.forEach(function(setupTemplate) {\n elements.push(stxHost.clone(setupTemplate));\n });\n }\n remapForComponentScopes(elements);\n elements.__stx_signals = { item: itemSignal, index: indexSignal };\n return elements;\n };\n\n // Helper: compute key for an item\n const getItemKey = (item, index) => {\n if (!keyExpr) return String(index);\n try {\n const scope = { [itemName]: item };\n if (indexName) scope[indexName] = index;\n const fn = __stxCompile([itemName, indexName || '_idx'], 'return ' + keyExpr);\n return String(fn(item, index));\n } catch (e) {\n return String(index);\n }\n };\n\n effect(() => {\n parent = followPlaceholder(placeholder, parent);\n // Use evalLazy for the list expression \u2014 only tracks the list signal,\n // not every signal in the component scope. This prevents unrelated\n // signals (modalOpen, menuOpen, etc.) from triggering a full rebuild.\n // Check loading state if @loading attribute provided (Feature #3)\n if (loadingExpr) {\n const isLoading = evalLazy(loadingExpr);\n if (isLoading) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n showLoading();\n return;\n }\n }\n\n hideLoading();\n\n // Evaluate list with LAZY tracking \u2014 only the list signal is tracked\n let list = evalLazy(listExpr);\n\n // Tolerate parens-on-signal in the list expression.\n // :for=\"x in store.signal\" --> works (bare-ref, auto-unwrapped)\n // :for=\"x in store.signal()\" --> silently iterated zero, because\n // the proxy unwraps the signal to\n // the array on access, then the\n // trailing call throws TypeError\n // which evalLazy's catch swallows.\n // Retry without the trailing parens so both forms succeed.\n //\n // This runtime is emitted as a TEMPLATE LITERAL, so every backslash here\n // must be DOUBLED to survive into the shipped string. A regex literal\n // crosses only that one layer (doubled escapes ship intact). A\n // new RegExp('...') string crosses a SECOND layer too \u2014 the browser's\n // string-literal parse strips the escapes again \u2014 collapsing the pattern\n // to a bare-letter match that never fires (stacksjs/stx#1748). So use a\n // regex literal, not new RegExp(string), for patterns with backslashes.\n var trailingParens = /\\(\\s*\\)\\s*$/;\n if (!Array.isArray(list) && trailingParens.test(listExpr)) {\n list = evalLazy(listExpr.replace(trailingParens, ''));\n }\n // Second-chance fallback: if the retry returned a signal /\n // derived function (the proxy failed to auto-unwrap, which\n // can happen when the resolved owning object lacks the\n // _isStxStore marker \u2014 e.g. ad-hoc objects, locally-imported\n // shapes), call it manually. Defensive: cheap when it would\n // already be an array, useful when the proxy missed.\n if (!Array.isArray(list) && typeof list === 'function' && (list._isSignal || list._isDerived)) {\n try { list = list(); } catch { /* swallow - the warning below surfaces it */ }\n }\n\n // If there's an @if condition, check it\n if (ifExpr) {\n const ifValue = evalLazy(ifExpr);\n if (!ifValue) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n hideEmpty();\n return;\n }\n }\n\n if (!Array.isArray(list)) {\n // Silent return here used to mask a class of real misuse:\n // most often a signal call that threw mid-expression, or a\n // :for over undefined from a typo. One warn line saves a lot\n // of \"list rendered no rows despite the data being there\"\n // debugging cycles.\n //\n // Diagnostic: dump the scope identifiers so the caller can see\n // whether the expression's root identifier was in scope at all\n // (and if so, what type it was and whether it carried the\n // _isStxStore marker). Only fires on the warn path, which is\n // rare, so the extra Object.keys / spread cost is negligible.\n var diagScope;\n var rootName = '?';\n var rootInScope = true;\n var rootVal;\n try {\n var diagMerged = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };\n var firstIdent = listExpr.match(/^[A-Za-z_$][\\w$]*/);\n rootName = firstIdent ? firstIdent[0] : '?';\n rootInScope = Object.prototype.hasOwnProperty.call(diagMerged, rootName);\n rootVal = rootInScope ? diagMerged[rootName] : '<NOT-IN-SCOPE>';\n var rootKeys = (rootVal && typeof rootVal === 'object')\n ? Object.keys(rootVal).slice(0, 8).join(',')\n : '-';\n diagScope = '[root=' + rootName + ' inScope=' + rootInScope + ' type=' + (typeof rootVal) + ' isStxStore=' + !!(rootVal && rootVal._isStxStore) + ' keys=' + rootKeys + ']';\n }\n catch (_e) { diagScope = '[diag-error]'; rootInScope = true; }\n\n /*\n * Name the cause rather than guessing at it (stacksjs/stx#2051).\n *\n * This used to end with \"If this is a signal call, try the bare\n * reference\" every single time. In the most common failure the\n * identifier is not a signal at all -- it is a bare name the client\n * scope has never heard of, usually a declaration from a\n * script-server block, which :for cannot see because it is expanded\n * on the client. The hint sent people to the wrong layer: one app\n * read it, concluded the signals-and-:for pattern was unreliable, and\n * was rebuilt on hand-written getElementById wiring.\n *\n * The scope dump already answered the question -- inScope=false was\n * right there, ahead of the guess -- so lead with it, and keep the\n * signal advice for when the value really is a signal, which is the\n * one case where it applies.\n */\n var advice;\n if (!rootInScope) {\n advice = 'Nothing named ' + rootName + ' is in the client scope. A script-server declaration is not available here: :for is expanded on the client. '\n + 'Either wrap it in state() inside a script-client block, or iterate it with the server-side @foreach(' + rootName + ' as item).';\n }\n else if (typeof rootVal === 'function' && (rootVal._isSignal || rootVal._isDerived)) {\n advice = rootName + ' is a signal, so try the bare reference: ' + rootName + ' instead of ' + rootName + '().';\n }\n else {\n advice = rootName + ' resolved to a ' + (typeof rootVal) + ', not an array.';\n }\n console.warn('[STX] :for expected an array; got ' + (list === '' ? 'empty/error' : typeof list) + ' for expression \"' + listExpr + '\". ' + diagScope + ' ' + advice);\n return;\n }\n\n // Check empty state (Feature #3)\n if (list.length === 0) {\n // Dispose scopes registered by items before they leave the DOM (#1727).\n clearRenderedItems();\n if (emptyExpr) {\n const emptyContent = evalLazy(emptyExpr);\n // Held in the same slot the @for-empty template uses, so hideEmpty\n // takes it away when the list fills and a second empty render\n // replaces it instead of stacking another one. It used to go into\n // currentElements, which teardown does not walk -- it walks\n // currentGroups -- so the text stayed in the document forever: an\n // empty list that filled read \"Nothing herea\".\n hideEmpty();\n if (emptyContent && typeof emptyContent === 'string') {\n emptyElement = document.createTextNode(emptyContent);\n stxHost.insert(parent, emptyElement, placeholder);\n }\n } else if (emptyTemplate) {\n showEmpty();\n }\n return;\n }\n\n hideEmpty();\n\n // \u2500\u2500 <TransitionGroup> detection (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Active only when the list's parent is a [data-stx-transition-group]\n // AND it has already rendered once (no enter animation on first mount).\n // tgReady gates ALL animation work, so plain :for lists are untouched.\n var tgIsGroup = !!(parent && parent.hasAttribute && parent.hasAttribute('data-stx-transition-group'));\n var tgName = tgIsGroup ? (parent.getAttribute('data-stx-transition-group') || 'v') : null;\n var tgReady = tgIsGroup && !!parent.__stx_tg_init;\n var tgFirst = tgReady ? tgSnapshot(currentElements) : null;\n\n // \u2500\u2500 Key-based diffing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Build new key list\n const newKeys = list.map((item, i) => getItemKey(item, i));\n\n // Build old key \u2192 element(s) map\n const oldKeyMap = new Map();\n for (let i = 0; i < currentKeys.length; i++) {\n const k = currentKeys[i];\n if (!oldKeyMap.has(k)) oldKeyMap.set(k, []);\n oldKeyMap.get(k).push(currentGroups[i] || []);\n }\n\n // Build new element list, reusing existing DOM nodes by key\n const newElements = [];\n const newGroups = [];\n // Keys seen in THIS pass, for the duplicate warning only. Reuse is decided\n // by whether a group under the key is still unconsumed, not by whether the\n // key has been seen: gating it on the key made every duplicate occurrence\n // build a NEW group, while the removal pass below skipped the key as used\n // and left the old ones in the document. The list grew by one row on every\n // update, without bound, and the first duplicate stayed bound to a signal\n // the reconciliation never wrote to.\n const seenKeys = new Set();\n let warnedDuplicateKey = false;\n\n // Minimal-move reconciliation.\n //\n // Every reused row used to be round-tripped through a DocumentFragment,\n // and appendChild into a fragment DETACHES the node from the document\n // first. Removing a focused node blurs it and resets activeElement, so a\n // list could not contain a field the user was typing in: any write to the\n // backing array kicked them out of it, losing caret, selection and undo\n // history. It happened for every row unconditionally, including rows that\n // had not moved, and unkeyed loops took the same path because getItemKey\n // falls back to the index (#1882).\n //\n // The cursor walks the existing rendering in order. A node already at the\n // cursor is left ENTIRELY alone \u2014 an unchanged list now performs zero DOM\n // operations \u2014 and a node that genuinely has to move is moved with\n // insertBefore, which relocates it without a detach/reattach cycle.\n let cursor = null;\n for (let ci = 0; ci < currentGroups.length && !cursor; ci++) {\n const seed = liveGroupNodes(currentGroups[ci] || []);\n if (seed.length) cursor = seed[0];\n }\n\n for (let i = 0; i < list.length; i++) {\n const key = newKeys[i];\n const existing = oldKeyMap.get(key);\n\n if (seenKeys.has(key) && !warnedDuplicateKey) {\n warnedDuplicateKey = true;\n console.warn('[STX] :for has more than one item with the key ' + key + '. Rows are matched in order, so give each item a key of its own.');\n }\n seenKeys.add(key);\n\n if (existing && existing.length > 0) {\n // Reuse this item's nodes \u2014 move the whole group into position, in\n // order, so a multi-node row stays contiguous and correctly ordered.\n // A structural directive may intentionally have detached one of the\n // group's nodes. Its own placeholder owns reinsertion, so keyed reuse\n // must not resurrect that hidden node.\n const group = existing.shift();\n const liveNodes = liveGroupNodes(group);\n for (let li = 0; li < liveNodes.length; li++) {\n const groupNode = liveNodes[li];\n if (groupNode === cursor) {\n // Already exactly where it belongs. Touching it here is what\n // used to blur it, so the correct action is to do nothing.\n cursor = cursor.nextSibling;\n }\n else {\n // Moves without detaching. The cursor does not advance: this node\n // is now behind it, and the cursor still marks the next position\n // to fill.\n stxHost.insert(parent, groupNode, cursor || placeholder);\n }\n }\n newElements.push(...group);\n newGroups.push(group);\n // Update the item signal so bindings re-evaluate with new data.\n // This is the fix for #1669 \u2014 without this, reused elements show\n // stale data because the old bindings captured the old item via closure.\n const signals = group.__stx_signals;\n if (signals) {\n signals.item.set(list[i]);\n signals.index.set(i);\n }\n } else {\n // New item \u2014 create DOM elements with a fresh item signal\n const elements = createItemElements(list[i], i, key);\n elements.forEach(el => {\n // Before the cursor, not before the placeholder: a new row inserted\n // in the MIDDLE of the list must land at its own position, without\n // forcing every row after it to be moved to get back in order.\n stxHost.insert(parent, el, cursor || placeholder);\n if (tgReady && el.isConnected) tgEnter(el, tgName);\n });\n hydrateComponentScopes(elements, elements.find(function(node) {\n return node && node.__stx_for_scope;\n })?.__stx_for_scope || passedScope);\n elements.forEach(el => {\n if (el.nodeType === 1) {\n var itemScope = el.__stx_for_scope || passedScope;\n delete el.__stx_for_scope;\n // Tracked so removeGroup can dispose the row's effects (#1954). Kept\n // off __stx_disposers, which marks a hydrated component root here\n // and in the deferred :if pass.\n if (!el.__stx_disposers && el.tagName !== 'SCRIPT')\n el.__stx_effect_disposers = trackEffects(function() { processElement(el, itemScope); });\n el.removeAttribute('x-cloak');\n el.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));\n }\n });\n newElements.push(...elements);\n newGroups.push(elements);\n }\n }\n\n // Remove old elements whose keys are no longer in the list.\n // Dispose any scopes registered inside removed items before the\n // remove() call (#1727).\n // Whatever is still in here was not consumed above -- either the key left\n // the list, or the list now has fewer rows under that key than it did.\n // The test used to be \"this key was never used\", which could not see the\n // second case, so a duplicate key's leftover rows stayed on screen.\n for (const groups of oldKeyMap.values()) {\n if (groups.length > 0) {\n // In a transition group, run the leave animation and let it remove the\n // node; otherwise remove immediately. Scopes are disposed up-front\n // either way (their destroy hooks shouldn't wait on a CSS transition).\n groups.forEach((group) => {\n if (tgReady) {\n const liveNodes = liveGroupNodes(group);\n const transitioned = new Set();\n liveNodes.forEach((el) => {\n disposeSubtreeEffects(el);\n disposeSubtreeScopes(el);\n if (tgLeave(el, tgName)) transitioned.add(el);\n else stxHost.remove(el);\n });\n group.forEach((el) => {\n if (transitioned.has(el) || liveNodes.includes(el)) return;\n disposeSubtreeEffects(el);\n disposeSubtreeScopes(el);\n stxHost.remove(el);\n });\n }\n else {\n removeGroup(group);\n }\n });\n // The row's signals went with its group, so there is no key-indexed\n // map left to prune here.\n }\n }\n\n currentElements = newElements;\n currentGroups = newGroups;\n currentKeys = newKeys;\n\n // \u2500\u2500 <TransitionGroup> play (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // FLIP the surviving elements from their snapshotted positions, then mark\n // the group rendered so the next update animates.\n if (tgReady && tgFirst) tgFlip(newElements, tgFirst, tgName);\n if (tgIsGroup) parent.__stx_tg_init = true;\n });\n }\n";
|
|
2
|
+
export declare const SIGNALS_FOR_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Browser-global aliases used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_GLOBALS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_GLOBALS_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Signal-aware event expression handling for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_HANDLER_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HANDLER_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Client-side document head and SEO helpers. */
|
|
2
|
-
export declare const SIGNALS_HEAD_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HEAD_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Formatting helpers and object dependency tracking used by client bindings. */
|
|
2
|
-
export declare const SIGNALS_HELPERS_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HELPERS_RUNTIME: string;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* DOM. The leading indentation and trailing blank line are intentional: this
|
|
7
7
|
* fragment is interpolated directly into the generated runtime.
|
|
8
8
|
*/
|
|
9
|
-
export declare const SIGNALS_HOST_RUNTIME
|
|
9
|
+
export declare const SIGNALS_HOST_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Post-hydration diagnostics used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_HYDRATION_AUDIT_RUNTIME = " // ==========================================================================\n // Post-hydration invariant sweep (stacksjs/stx#1773)\n // ==========================================================================\n //\n // Preserved moustaches are the framework's de-facto error UI: ANY failure in\n // the detect \u2192 extract \u2192 bundle \u2192 ship \u2192 rebind relay collapses into the same\n // visible symptom, literal {{ }} on screen. Eight separate fixes each patched\n // one site's heuristic, and no invariant anywhere asserted the actual\n // requirement \u2014 zero unhydrated scopes after hydration. So every new upstream\n // miss reached users silently and had to be diagnosed from a screenshot.\n //\n // This is that invariant. It runs at the end of both hydration entry points\n // and turns a silent miss into one loud, self-healing event:\n //\n // - an element carrying data-stx-scope whose id isn't in the registry, or\n // that hydration reached but never processed, is reported AND processed\n // with the ambient scope, which is what the walk would have done had the\n // script arrived. That recovers the D2/D3 shapes (a silent early return\n // in the walk, a stale __stx_scope guard) rather than merely naming them.\n // - leftover {{ }} text is reported. Diagnostic only, never auto-fixed:\n // without a scope there is nothing to interpolate against, and a page may\n // legitimately print moustaches.\n //\n // Deliberately quiet in the normal case: nothing is logged when the page has\n // no signals at all, and containers that legitimately show template syntax\n // (<pre>, <code>, <template>, <script>, <style>, <textarea>, and anything\n // under [data-stx-ignore]) are skipped.\n\n var AUDIT_SKIP_TAGS = { PRE: 1, CODE: 1, SCRIPT: 1, STYLE: 1, TEXTAREA: 1, TEMPLATE: 1 };\n\n // Expressions whose evaluation threw a ReferenceError/TypeError and have not\n // since succeeded. evalAttrExpr swallows those two on purpose \u2014 a signal may\n // not exist yet on an effect's first pass \u2014 which is why a genuinely broken\n // binding produces no diagnostic at all today. The classic case is\n // :if=\"flag()\" where flag is a signal: the auto-unwrap proxy returns the\n // VALUE, calling it throws TypeError, the directive suppresses it, and the\n // element silently stays hidden with no warning anywhere (see CLAUDE.md,\n // \"Signals: scripts call, templates don't\").\n //\n // Recording rather than warning immediately is what keeps this quiet on\n // working pages: a first-pass failure that later succeeds clears itself, so\n // only expressions still broken when hydration finishes are reported.\n var _exprFailures = {};\n var _exprFailureCount = 0;\n\n function noteExprFailure(expr, err) {\n if (_exprFailures[expr] !== undefined) return;\n // Bounded: one runaway loop must not grow this without limit.\n if (_exprFailureCount >= 50) return;\n _exprFailureCount++;\n _exprFailures[expr] = (err && err.message) ? err.message : String(err);\n }\n\n function noteExprSuccess(expr) {\n if (_exprFailures[expr] === undefined) return;\n delete _exprFailures[expr];\n _exprFailureCount--;\n }\n\n function auditSkipped(node) {\n // Not rendered, not audited. Covers <template> content (a detached\n // DocumentFragment \u2014 which some DOM implementations still walk into) and\n // :if branches parked off-document, neither of which the user can see.\n if (node.isConnected === false) return true;\n for (var p = node.parentNode; p; p = p.parentNode) {\n if (p.nodeType === Node.DOCUMENT_FRAGMENT_NODE) return true;\n if (p.nodeType !== Node.ELEMENT_NODE) continue;\n if (AUDIT_SKIP_TAGS[p.tagName]) return true;\n if (p.hasAttribute && p.hasAttribute('data-stx-ignore')) return true;\n // A :if whose deferred child-binding pass hasn't run yet legitimately holds\n // literal {{ }} that binds a macrotask later \u2014 not a hydration miss (#1773).\n if (p.__stx_if_pending) return true;\n // A deferred island (client=visible|idle|\u2026) is unhydrated ON PURPOSE until\n // its trigger fires, so its {{ }} legitimately stay literal in the meantime\n // \u2014 not a miss (#1746). The stranded-scope pass already skips stx-hydrate;\n // the literal sweep must too.\n if (p.hasAttribute && p.hasAttribute('stx-hydrate') && !p.__stx_hydrated) return true;\n }\n return false;\n }\n\n // Whether the element is, or sits inside, a structural directive's source that has\n // not bound yet. Binding replaces the source with a marker and a template,\n // so a :for / :if still on an element in the document has yet to run.\n var UNBOUND_STRUCTURE = [':for', '@for', 'x-for', ':if', '@if', 'x-if', ':else-if', '@else-if', 'x-else-if', ':else', '@else', 'x-else'];\n function inUnboundStructure(el) {\n for (var p = el; p && p.nodeType === Node.ELEMENT_NODE; p = p.parentElement) {\n for (var i = 0; i < UNBOUND_STRUCTURE.length; i++) {\n if (p.hasAttribute(UNBOUND_STRUCTURE[i])) return true;\n }\n }\n return false;\n }\n\n function findLiteralMoustaches(root) {\n var found = [];\n if (!root || typeof document.createTreeWalker !== 'function') return found;\n // Read NodeFilter off window, not the bare global: in a real browser they\n // are the same object, but some DOM implementations used for testing expose\n // it only on window, and a bare reference then throws inside the audit.\n var showText = (window.NodeFilter && window.NodeFilter.SHOW_TEXT) || 4;\n var walker = document.createTreeWalker(root, showText, null);\n var node;\n while ((node = walker.nextNode())) {\n // Browsers expose Text.nodeValue as a string, while lightweight DOM and\n // native embedding shims can preserve an assigned number. Diagnostics\n // must normalize the boundary instead of aborting the entire audit on a\n // missing String#indexOf method.\n var text = node.nodeValue == null ? '' : String(node.nodeValue);\n if (text.indexOf('{{') === -1 || text.indexOf('}}') === -1) continue;\n if (auditSkipped(node)) continue;\n found.push(text.trim().slice(0, 80));\n if (found.length >= 5) break;\n }\n return found;\n }\n\n // A diagnostic that can break hydration is worse than no diagnostic, so the\n // whole sweep is wrapped and every DOM capability it uses is feature-checked.\n // Minimal document stubs (tests, non-browser embeddings) simply skip it.\n function auditHydration(container, phase) {\n try { auditHydrationUnsafe(container, phase); }\n catch (e) { console.warn('[stx] hydration audit skipped:', e && e.message ? e.message : e); }\n }\n\n function auditHydrationUnsafe(container, phase) {\n if (!window.stx || !window.stx._scopes) return;\n var root = container && typeof container.querySelectorAll === 'function' ? container : document.body;\n if (!root || typeof root.querySelectorAll !== 'function') return;\n\n // Unregistered / unprocessed scopes \u2014 the unambiguous failure, and the one\n // worth repairing.\n var stranded = [];\n root.querySelectorAll('[data-stx-scope]').forEach(function(el) {\n if (el.__stx_audit_recovered) return;\n // Deferred islands are unhydrated ON PURPOSE until their trigger fires.\n if (el.hasAttribute('stx-hydrate') || el.__stx_hydration_scheduled) return;\n // Inert markup is not a miss: a component inside a :if branch whose\n // deferred pass has not run, or inside a :for / :if source that has not\n // bound, is set up when it does, under its own clone's id. The literal\n // sweep already allowed for the first; recovering the second ran a\n // loop's source against the page's scope.\n if (auditSkipped(el) || inUnboundStructure(el)) return;\n var scopeId = el.getAttribute('data-stx-scope');\n var registered = window.stx._scopes[scopeId];\n if (registered && el.__stx_disposers) return;\n stranded.push({ el: el, id: scopeId, registered: !!registered });\n });\n\n if (stranded.length) {\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': '\n + stranded.length + ' scope(s) left unhydrated \u2014 '\n + stranded.map(function(s) {\n return s.id + (s.registered ? ' (registered, never processed)' : ' (not registered)');\n }).join(', ')\n + '. Recovering with the ambient scope; please report with the page that produced it (stacksjs/stx#1773).',\n );\n stranded.forEach(function(s) {\n // Once per element: a repair that itself fails must not loop on the\n // next navigation.\n s.el.__stx_audit_recovered = true;\n try {\n var vars = s.registered ? window.stx._scopes[s.id] : null;\n if (vars) Object.assign(componentScope, vars);\n s.el.__stx_disposers = trackEffects(function() { processElement(s.el, componentScope); });\n s.el.removeAttribute('x-cloak');\n s.el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });\n }\n catch (e) {\n console.error('[stx] hydration recovery failed for scope ' + s.id + ':', e);\n }\n });\n }\n\n var literals = findLiteralMoustaches(root);\n if (literals.length) {\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': literal {{ }} left in the DOM \u2014 '\n + literals.join(' | ')\n + '. An expression did not bind; see stacksjs/stx#1773. Wrap intentional '\n + 'template syntax in <pre>/<code> or [data-stx-ignore] to exclude it.',\n );\n }\n\n // Expressions that threw and never recovered. Reported here rather than at\n // throw time so a first-pass miss that later resolves stays silent.\n var brokenExprs = [];\n for (var expr in _exprFailures) {\n if (Object.prototype.hasOwnProperty.call(_exprFailures, expr))\n brokenExprs.push(expr + ' \u2192 ' + _exprFailures[expr]);\n }\n if (brokenExprs.length) {\n var hint = brokenExprs.some(function(m) { return m.indexOf('is not a function') !== -1; })\n ? ' If one of these calls a signal, drop the parentheses: templates read '\n + 'a signal by bare name (:if=\"flag\"), scripts call it (flag()). Calling '\n + 'the unwrapped value is a TypeError, which directives suppress \u2014 the '\n + 'element just stays hidden.'\n : '';\n console.error(\n '[stx] hydration invariant failed after ' + phase + ': '\n + brokenExprs.length + ' expression(s) never evaluated \u2014 '\n + brokenExprs.slice(0, 5).join(' | ') + '.' + hint,\n );\n _exprFailures = {};\n _exprFailureCount = 0;\n }\n }\n";
|
|
2
|
+
export declare const SIGNALS_HYDRATION_AUDIT_RUNTIME: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Dynamic subtree hydration used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_HYDRATION_RUNTIME
|
|
2
|
+
export declare const SIGNALS_HYDRATION_RUNTIME: string;
|