@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,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS Scoping for Web Components
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities for scoping CSS styles to specific components
|
|
5
|
-
* to prevent style leakage in Shadow DOM and for component isolation.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Options for CSS scoping
|
|
9
|
-
*/
|
|
10
|
-
export interface CssScopingOptions {
|
|
11
|
-
/** Prefix to add to selectors */
|
|
12
|
-
prefix?: string;
|
|
13
|
-
/** Whether to preserve :host selectors */
|
|
14
|
-
preserveHost?: boolean;
|
|
15
|
-
/** Whether to scope keyframe names */
|
|
16
|
-
scopeKeyframes?: boolean;
|
|
17
|
-
/** Whether to scope CSS custom properties */
|
|
18
|
-
scopeCustomProperties?: boolean;
|
|
19
|
-
}
|
|
20
1
|
/**
|
|
21
2
|
* Generate a unique component ID based on hash
|
|
22
3
|
*/
|
|
@@ -43,8 +24,8 @@ export declare function scopeCss(css: string, componentId: string, options?: Css
|
|
|
43
24
|
* @returns Object with CSS content and template without style tags
|
|
44
25
|
*/
|
|
45
26
|
export declare function extractStyleFromTemplate(template: string): {
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
css: string
|
|
28
|
+
templateWithoutStyle: string
|
|
48
29
|
};
|
|
49
30
|
/**
|
|
50
31
|
* Inject scoped CSS into a template
|
|
@@ -62,3 +43,12 @@ export declare function injectScopedCss(template: string, scopedCss: string, pos
|
|
|
62
43
|
* @returns CSS suitable for Shadow DOM
|
|
63
44
|
*/
|
|
64
45
|
export declare function generateShadowDomCss(css: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Options for CSS scoping
|
|
48
|
+
*/
|
|
49
|
+
export declare interface CssScopingOptions {
|
|
50
|
+
prefix?: string
|
|
51
|
+
preserveHost?: boolean
|
|
52
|
+
scopeKeyframes?: boolean
|
|
53
|
+
scopeCustomProperties?: boolean
|
|
54
|
+
}
|
package/dist/web-components.d.ts
CHANGED
|
@@ -3,72 +3,6 @@ import type { StxOptions } from './types';
|
|
|
3
3
|
* Builds web components from stx components
|
|
4
4
|
*/
|
|
5
5
|
export declare function buildWebComponents(options: StxOptions, dependencies: Set<string>): Promise<string[]>;
|
|
6
|
-
/**
|
|
7
|
-
* Property definition for reactive web components
|
|
8
|
-
*/
|
|
9
|
-
export interface ReactivePropertyDefinition {
|
|
10
|
-
/** Property type for serialization/deserialization */
|
|
11
|
-
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
12
|
-
/** Default value */
|
|
13
|
-
default?: unknown;
|
|
14
|
-
/** Whether property reflects to attribute */
|
|
15
|
-
reflect?: boolean;
|
|
16
|
-
/** Custom attribute name (defaults to kebab-case of property name) */
|
|
17
|
-
attribute?: string | false;
|
|
18
|
-
/** Observer function name to call when property changes */
|
|
19
|
-
observer?: string;
|
|
20
|
-
/** Whether property changes should trigger re-render */
|
|
21
|
-
render?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Reactive web component configuration
|
|
25
|
-
*/
|
|
26
|
-
export interface ReactiveWebComponentConfig {
|
|
27
|
-
/** Component class name */
|
|
28
|
-
name: string;
|
|
29
|
-
/** Custom element tag name */
|
|
30
|
-
tag: string;
|
|
31
|
-
/** Base element to extend */
|
|
32
|
-
baseElement?: string;
|
|
33
|
-
/** Component template HTML */
|
|
34
|
-
template: string;
|
|
35
|
-
/** Component styles (CSS) */
|
|
36
|
-
styles?: string;
|
|
37
|
-
/** Whether to use Shadow DOM */
|
|
38
|
-
shadowDOM?: boolean;
|
|
39
|
-
/** Reactive property definitions */
|
|
40
|
-
properties?: Record<string, ReactivePropertyDefinition>;
|
|
41
|
-
/** Lifecycle hooks to include */
|
|
42
|
-
lifecycle?: {
|
|
43
|
-
connected?: string;
|
|
44
|
-
disconnected?: string;
|
|
45
|
-
adopted?: string;
|
|
46
|
-
attributeChanged?: string;
|
|
47
|
-
};
|
|
48
|
-
/** Event handlers */
|
|
49
|
-
events?: Record<string, string>;
|
|
50
|
-
/** Methods to include in the component */
|
|
51
|
-
methods?: Record<string, string>;
|
|
52
|
-
/** Initial state */
|
|
53
|
-
state?: Record<string, unknown>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* CSS scoping strategy
|
|
57
|
-
*/
|
|
58
|
-
export type CssScopingStrategy = 'shadow' | 'prefix' | 'attribute' | 'bem';
|
|
59
|
-
/**
|
|
60
|
-
* CSS scoping configuration
|
|
61
|
-
*/
|
|
62
|
-
export interface CssScopingConfig {
|
|
63
|
-
/** Scoping strategy to use */
|
|
64
|
-
strategy: CssScopingStrategy;
|
|
65
|
-
/** Prefix for class-based scoping (strategy: 'prefix') */
|
|
66
|
-
prefix?: string;
|
|
67
|
-
/** Attribute name for attribute-based scoping (strategy: 'attribute') */
|
|
68
|
-
attributeName?: string;
|
|
69
|
-
/** Whether to preserve original class names */
|
|
70
|
-
preserveOriginal?: boolean;
|
|
71
|
-
}
|
|
72
6
|
/**
|
|
73
7
|
* Generate a unique scope ID for a component
|
|
74
8
|
*/
|
|
@@ -116,10 +50,7 @@ export declare function getScopeAttribute(componentTag: string, config?: Partial
|
|
|
116
50
|
* @param config - Scoping configuration
|
|
117
51
|
* @returns Object with scoped HTML and extracted scoped CSS
|
|
118
52
|
*/
|
|
119
|
-
export declare function extractAndScopeStyles(html: string, componentTag: string, config?: Partial<CssScopingConfig>): {
|
|
120
|
-
html: string;
|
|
121
|
-
css: string;
|
|
122
|
-
};
|
|
53
|
+
export declare function extractAndScopeStyles(html: string, componentTag: string, config?: Partial<CssScopingConfig>): { html: string, css: string };
|
|
123
54
|
/**
|
|
124
55
|
* Generate a reactive web component with full lifecycle management.
|
|
125
56
|
*
|
|
@@ -186,17 +117,6 @@ export declare function generateReactiveMixin(): string;
|
|
|
186
117
|
* @returns JavaScript runtime code
|
|
187
118
|
*/
|
|
188
119
|
export declare function generateReactiveRuntime(): string;
|
|
189
|
-
/**
|
|
190
|
-
* Parsed SFC web component structure
|
|
191
|
-
*/
|
|
192
|
-
export interface ParsedSFCComponent {
|
|
193
|
-
tag: string;
|
|
194
|
-
props: string[];
|
|
195
|
-
template: string;
|
|
196
|
-
styles: string;
|
|
197
|
-
script: string;
|
|
198
|
-
shadowDOM: boolean;
|
|
199
|
-
}
|
|
200
120
|
/**
|
|
201
121
|
* Parse an SFC-style web component file
|
|
202
122
|
*
|
|
@@ -250,4 +170,61 @@ export declare function generateSFCWebComponent(parsed: ParsedSFCComponent): str
|
|
|
250
170
|
* </style>
|
|
251
171
|
* ```
|
|
252
172
|
*/
|
|
173
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
253
174
|
export declare function webComponentDirectiveHandler(content: string, params: string[], context: Record<string, any>, filePath: string): Promise<string>;
|
|
175
|
+
/**
|
|
176
|
+
* Property definition for reactive web components
|
|
177
|
+
*/
|
|
178
|
+
export declare interface ReactivePropertyDefinition {
|
|
179
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array'
|
|
180
|
+
default?: unknown
|
|
181
|
+
reflect?: boolean
|
|
182
|
+
attribute?: string | false
|
|
183
|
+
observer?: string
|
|
184
|
+
render?: boolean
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Reactive web component configuration
|
|
188
|
+
*/
|
|
189
|
+
export declare interface ReactiveWebComponentConfig {
|
|
190
|
+
name: string
|
|
191
|
+
tag: string
|
|
192
|
+
baseElement?: string
|
|
193
|
+
template: string
|
|
194
|
+
styles?: string
|
|
195
|
+
shadowDOM?: boolean
|
|
196
|
+
properties?: Record<string, ReactivePropertyDefinition>
|
|
197
|
+
lifecycle?: {
|
|
198
|
+
connected?: string
|
|
199
|
+
disconnected?: string
|
|
200
|
+
adopted?: string
|
|
201
|
+
attributeChanged?: string
|
|
202
|
+
}
|
|
203
|
+
events?: Record<string, string>
|
|
204
|
+
methods?: Record<string, string>
|
|
205
|
+
state?: Record<string, unknown>
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* CSS scoping configuration
|
|
209
|
+
*/
|
|
210
|
+
export declare interface CssScopingConfig {
|
|
211
|
+
strategy: CssScopingStrategy
|
|
212
|
+
prefix?: string
|
|
213
|
+
attributeName?: string
|
|
214
|
+
preserveOriginal?: boolean
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Parsed SFC web component structure
|
|
218
|
+
*/
|
|
219
|
+
export declare interface ParsedSFCComponent {
|
|
220
|
+
tag: string
|
|
221
|
+
props: string[]
|
|
222
|
+
template: string
|
|
223
|
+
styles: string
|
|
224
|
+
script: string
|
|
225
|
+
shadowDOM: boolean
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* CSS scoping strategy
|
|
229
|
+
*/
|
|
230
|
+
export type CssScopingStrategy = 'shadow' | 'prefix' | 'attribute' | 'bem';
|
package/dist/x-element.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.573",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -124,12 +124,12 @@
|
|
|
124
124
|
"dependencies": {
|
|
125
125
|
"@stacksjs/ts-css": "^0.3.11",
|
|
126
126
|
"@stacksjs/clapp": "^0.2.16",
|
|
127
|
-
"@stacksjs/desktop": "0.2.
|
|
128
|
-
"@stacksjs/sanitizer": "0.2.
|
|
127
|
+
"@stacksjs/desktop": "0.2.573",
|
|
128
|
+
"@stacksjs/sanitizer": "0.2.573",
|
|
129
129
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
130
|
-
"bun-plugin-stx": "0.2.
|
|
131
|
-
"bunfig": "^0.15.
|
|
132
|
-
"stx-router": "0.2.
|
|
130
|
+
"bun-plugin-stx": "0.2.573",
|
|
131
|
+
"bunfig": "^0.15.21",
|
|
132
|
+
"stx-router": "0.2.573",
|
|
133
133
|
"ts-broadcasting": "^0.0.11",
|
|
134
134
|
"ts-images": "^0.2.22",
|
|
135
135
|
"ts-syntax-highlighter": "^0.2.1"
|
package/stx.d.ts
CHANGED
|
@@ -73,8 +73,8 @@ declare function effect(_fn: () => void | StxCleanup): StxCleanup
|
|
|
73
73
|
declare function batch(_fn: () => void): void
|
|
74
74
|
declare function untrack<T>(_value: T | StxSignal<T> | StxDerivedSignal<T>): T
|
|
75
75
|
declare function peek<T>(_fn: () => T): T
|
|
76
|
-
declare function isSignal(
|
|
77
|
-
declare function isDerived(
|
|
76
|
+
declare function isSignal(value: unknown): value is StxSignal<unknown>
|
|
77
|
+
declare function isDerived(value: unknown): value is StxDerivedSignal<unknown>
|
|
78
78
|
|
|
79
79
|
// ============================================================================
|
|
80
80
|
// Lifecycle
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An app that keeps working without a network, and opens like a native one.
|
|
3
|
-
*
|
|
4
|
-
* The PWA module (../pwa) builds a service worker for a static site: precache
|
|
5
|
-
* the built files, serve them. A server-rendered stx app is different. Its
|
|
6
|
-
* router swaps fragments (`X-STX-Router: true`) rather than loading
|
|
7
|
-
* documents, its pages talk to an API with a bearer token, and every deploy
|
|
8
|
-
* changes the build its fragments must match. This worker is for that app:
|
|
9
|
-
*
|
|
10
|
-
* - Pages and fragments: the kept copy at once, and the network asked behind
|
|
11
|
-
* it (stale-while-revalidate). When the answer differs from what was shown,
|
|
12
|
-
* the copy is replaced and every open page hears `stx:updated`
|
|
13
|
-
* { url, kind: 'page' }, so a screen can redraw rather than the person
|
|
14
|
-
* waiting on a round trip for every tap. Only a screen never kept waits for
|
|
15
|
-
* the network, and only `networkTimeoutMs` before a dynamic route's kept
|
|
16
|
-
* page stands in. The screens named in `pages` are fetched when the worker
|
|
17
|
-
* installs, so they open offline even before they were visited, with the
|
|
18
|
-
* stylesheets and scripts they link to. Kept per build: a fragment from
|
|
19
|
-
* another build would make the router reload into nothing. A kept copy
|
|
20
|
-
* whose module bundles (`/_stx/modules.<hash>.js`) are not kept too is not
|
|
21
|
-
* answered first, since a later server process cannot answer them and the
|
|
22
|
-
* page would never bind; it stands in only with no network at all.
|
|
23
|
-
* - Dynamic screens named in `routes` (`/m/workout/:id`): one never opened is
|
|
24
|
-
* answered offline with the route's kept page, its params swapped for the
|
|
25
|
-
* ones asked for. For a page drawn on the device from the API, every value
|
|
26
|
-
* shares the page, so a session the phone never showed still opens.
|
|
27
|
-
* - The build's own files (`/_stx/…`) and public assets: the cached copy at
|
|
28
|
-
* once, refreshed behind. Ones no kept page of the current build links to
|
|
29
|
-
* are pruned when a new build takes over.
|
|
30
|
-
* - API reads (`apiPrefix`, GET only): stale-while-revalidate like pages, with
|
|
31
|
-
* `stx:updated` { url, kind: 'api' } when the answer changed. Cached per
|
|
32
|
-
* signed-in token, so one account never reads another's copy on a shared
|
|
33
|
-
* device; `clearOfflineData()` (on sign-out) drops them all. A copy kept
|
|
34
|
-
* before the app's last write is not answered at once (the write would
|
|
35
|
-
* seem not to have happened), nor is one for a request made with
|
|
36
|
-
* `cache: 'no-cache'` (a pull to refresh) or under a `networkFirst` prefix.
|
|
37
|
-
* - Whether the server can be reached: a page whose reads are all answered
|
|
38
|
-
* from kept copies cannot tell that the network behind them is gone (a
|
|
39
|
-
* phone on one bar of gym wifi says it is online). When a request to the
|
|
40
|
-
* server fails for want of a network, or succeeds again, every open page
|
|
41
|
-
* hears `stx:reachability` { reachable, at }, `at` being when the server
|
|
42
|
-
* last answered; `useNetwork()` counts an unreachable server as offline.
|
|
43
|
-
* - Writes are never cached or replayed here. The page queues them itself
|
|
44
|
-
* (`useOutbox`), where it can tell the person what happened.
|
|
45
|
-
* - A new build installs beside the running one and waits. It takes over when
|
|
46
|
-
* no page of the app is on screen, or when the app starts cold, never under
|
|
47
|
-
* a person mid-task; the page can ask for it sooner (`applyOfflineUpdate()`).
|
|
48
|
-
* The running build's kept screens stay until then.
|
|
49
|
-
*/
|
|
50
|
-
export interface OfflineAppConfig {
|
|
51
|
-
/** Turn the worker on. */
|
|
52
|
-
enabled: boolean;
|
|
53
|
-
/** Screens fetched when the worker installs, so they open offline before they were visited. */
|
|
54
|
-
pages?: string[];
|
|
55
|
-
/**
|
|
56
|
-
* Listed pages whose HTML is an account-independent shell. These may be
|
|
57
|
-
* retained despite the server's default no-store header. Never list pages
|
|
58
|
-
* containing server-rendered personal data; API no-store remains enforced.
|
|
59
|
-
*
|
|
60
|
-
* A route of `routes` may be listed too (`/m/go/:id`, as written there):
|
|
61
|
-
* its kept page, the one every value of it stands in with offline, is then
|
|
62
|
-
* refreshed by each visit despite no-store. Without that, a server that
|
|
63
|
-
* marks every page no-store left a route only the copy fetched when the
|
|
64
|
-
* worker installed, and a page in `pages` none at all after its first visit.
|
|
65
|
-
*/
|
|
66
|
-
staticPages?: string[];
|
|
67
|
-
/** Path prefix of the app's API, whose GET answers are kept for offline. Default '/api/'. */
|
|
68
|
-
apiPrefix?: string;
|
|
69
|
-
/**
|
|
70
|
-
* How long a screen or API read that was never kept (or one asked for
|
|
71
|
-
* network first) waits for the network before a kept stand-in is used, ms.
|
|
72
|
-
* Default 1500. A kept copy is answered at once and does not wait at all.
|
|
73
|
-
*/
|
|
74
|
-
networkTimeoutMs?: number;
|
|
75
|
-
/** Deadline for each background precache request and response body, ms. Default 10000. Does not abort foreground reads. */
|
|
76
|
-
precacheTimeoutMs?: number;
|
|
77
|
-
/**
|
|
78
|
-
* Paths (prefixes) answered network first rather than from the kept copy:
|
|
79
|
-
* the kept copy is used only when the network does not answer in
|
|
80
|
-
* `networkTimeoutMs`. For a read whose stale copy would mislead, such as a
|
|
81
|
-
* balance or a live score.
|
|
82
|
-
*/
|
|
83
|
-
networkFirst?: string[];
|
|
84
|
-
/**
|
|
85
|
-
* Whether an app started cold while a new build waits opens on the new
|
|
86
|
-
* build, going to the network for its first screen, rather than on the kept
|
|
87
|
-
* one. Off by default: the app opens at once on the build it has, the way a
|
|
88
|
-
* native app keeps running the version it has while the next downloads,
|
|
89
|
-
* and the new build takes over the next time the app is not on screen. On
|
|
90
|
-
* costs a round trip on the first launch after every deploy.
|
|
91
|
-
*/
|
|
92
|
-
updateOnColdStart?: boolean;
|
|
93
|
-
/** Where a page that was never cached goes offline (one of `pages`). Default: the first of `pages`. */
|
|
94
|
-
fallback?: string;
|
|
95
|
-
/**
|
|
96
|
-
* The paths the fallback stands in for (a prefix). Default: the fallback's
|
|
97
|
-
* own section, its first path segment, so a `/m` fallback answers only for
|
|
98
|
-
* `/m/...`. Outside it a page that was never kept fails as it would without
|
|
99
|
-
* the worker. A phone app's screen is no answer for a page of the website
|
|
100
|
-
* beside it, and a dev server restarting looks offline for a moment.
|
|
101
|
-
*/
|
|
102
|
-
fallbackScope?: string;
|
|
103
|
-
/**
|
|
104
|
-
* Dynamic screens whose page is the same for every value, drawn on the
|
|
105
|
-
* device from the API: `/m/workout/:id` or `/m/workout/[id]`. One that was
|
|
106
|
-
* never opened is answered offline with the route's kept page, its route
|
|
107
|
-
* params replaced by the ones asked for. The route's page is fetched when
|
|
108
|
-
* the worker installs (each param as `0`) and refreshed by every visit.
|
|
109
|
-
* Leave out a route whose server renders the value's own data.
|
|
110
|
-
*/
|
|
111
|
-
routes?: string[];
|
|
112
|
-
/** Paths the worker leaves alone entirely (prefixes). */
|
|
113
|
-
exclude?: string[];
|
|
114
|
-
/**
|
|
115
|
-
* Most bytes of media (videos, audio) the page may ask to keep for offline
|
|
116
|
-
* with `cacheMedia()`. The oldest are dropped past it. Default 600 MB.
|
|
117
|
-
*/
|
|
118
|
-
mediaMaxBytes?: number;
|
|
119
|
-
/**
|
|
120
|
-
* Most files other than stylesheets and scripts (images, fonts) kept in the
|
|
121
|
-
* asset cache. The least recently fetched go first when a new build takes
|
|
122
|
-
* over. Default 500.
|
|
123
|
-
*/
|
|
124
|
-
assetsMaxEntries?: number;
|
|
125
|
-
}
|
|
126
|
-
export declare const OFFLINE_WORKER_PATH = "/_stx/sw.js";
|
|
127
|
-
interface OfflineRoute {
|
|
128
|
-
/** The route as configured, which names its kept page. */
|
|
129
|
-
path: string;
|
|
130
|
-
/** Matches a path of this route, one group per param. */
|
|
131
|
-
re: string;
|
|
132
|
-
names: string[];
|
|
133
|
-
/** The path fetched when the worker installs. */
|
|
134
|
-
sample: string;
|
|
135
|
-
}
|
|
136
|
-
/** `/m/workout/:id` and `/m/workout/[id]` as a matcher the worker can carry. */
|
|
137
|
-
export declare function offlineRoute(path: string): OfflineRoute | null;
|
|
138
|
-
/**
|
|
139
|
-
* What the register tag runs on every page. Closure-free: it is shipped as its
|
|
140
|
-
* own source (`OFFLINE_REGISTER_SCRIPT`), and exported so it can be tested.
|
|
141
|
-
*
|
|
142
|
-
* - Registers the worker after the first frame on a return visit (a cheap
|
|
143
|
-
* update check), and only after `load` on the first one, whose install
|
|
144
|
-
* fetches every kept screen and would compete with the page's own files.
|
|
145
|
-
* It never sits in front of first paint either way.
|
|
146
|
-
* - Turns the worker's `stx:updated` messages into a window event of the same
|
|
147
|
-
* name, { url, kind, fragment }, for the router and for queries to redraw.
|
|
148
|
-
* - A new build waits (see the worker). The page says when it is safe to take
|
|
149
|
-
* over: when it is hidden, or when it loaded with nothing else of the app
|
|
150
|
-
* open; the worker checks that no page of the app is on screen. When one is
|
|
151
|
-
* waiting, `window.stxOffline.updateReady` turns true and the window hears
|
|
152
|
-
* `stx:offline-update-ready`, so an app can offer "Update" and call
|
|
153
|
-
* `window.stxOffline.applyUpdate()`, which takes over now and reloads.
|
|
154
|
-
*/
|
|
155
|
-
export declare function registerOfflineWorker(path: string): void;
|
|
156
|
-
/**
|
|
157
|
-
* The section a fallback screen stands in for: `scope` when given, else the
|
|
158
|
-
* fallback's first path segment (`/m/today` → `/m`, `/` → `/`).
|
|
159
|
-
*/
|
|
160
|
-
export declare function offlineFallbackScope(fallback: string | null, scope?: string): string | null;
|
|
161
|
-
/** The tag every page carries so the worker is installed. */
|
|
162
|
-
export declare const OFFLINE_REGISTER_SCRIPT: string;
|
|
163
|
-
/** The worker itself, for one build. */
|
|
164
|
-
export declare function generateOfflineWorker(config: OfflineAppConfig, buildId: string): string;
|
|
165
|
-
export {};
|
package/dist/chunk-49gwmcrn.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{dd,ud}from"./chunk-jwvzvapp.js";import"./chunk-dcpf6kas.js";import"./chunk-79vdkvhf.js";import"./chunk-2z0trbbm.js";import"./chunk-f4jh9vrj.js";import"./chunk-pnag11c4.js";import"./chunk-vp31ff54.js";import"./chunk-tv784gv0.js";import"./chunk-rrj5m9xv.js";import"./chunk-rfnr4xz6.js";import"./chunk-36agnyhe.js";import"./chunk-sfwprq8q.js";import"./chunk-ydx3mfpp.js";import"./chunk-s12b57m9.js";import"./chunk-k7ht6tqe.js";import"./chunk-phzs239m.js";import"./chunk-1edvsndv.js";export{ud as clearStoreCache,dd as getStoreScript};
|
package/dist/chunk-6va5pe2m.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Qi,ea}from"./chunk-0bt0fbs1.js";import"./chunk-1n64749x.js";import"./chunk-vr36s2en.js";import"./chunk-qcymqscj.js";import"./chunk-4easd8da.js";import"./chunk-kzjrgh0b.js";import"./chunk-r4w1cye7.js";import"./chunk-4bgfpkwx.js";import{fo}from"./chunk-jqefcghh.js";import"./chunk-bpdsdbvg.js";import"./chunk-b9r88ysg.js";import"./chunk-cyg9w31a.js";import"./chunk-g66m3g2r.js";import"./chunk-zyk12484.js";import"./chunk-ymawe0y5.js";import"./chunk-zd01r00t.js";import"./chunk-a6jq7hex.js";import"./chunk-707n4pbz.js";import"./chunk-c4zpzxex.js";import"./chunk-7bwkeake.js";import"./chunk-yk3wh2xv.js";import"./chunk-pveafhzg.js";import"./chunk-mzqyv7s5.js";import"./chunk-mr9c2ej6.js";import"./chunk-5vw8493b.js";import"./chunk-anjm087t.js";import"./chunk-1dg5qxg9.js";import"./chunk-wwhxgvr8.js";import"./chunk-jwvzvapp.js";import"./chunk-6wc2t6cd.js";import"./chunk-83fdt4yj.js";import"./chunk-gzgc8zk5.js";import"./chunk-qt3x1sh3.js";import"./chunk-0dz1b6a1.js";import"./chunk-dcpf6kas.js";import"./chunk-79vdkvhf.js";import"./chunk-2z0trbbm.js";import{be,on,an,J,d,n,er,A,o,pe}from"./chunk-f4jh9vrj.js";import"./chunk-pnag11c4.js";import"./chunk-vp31ff54.js";import"./chunk-tv784gv0.js";import"./chunk-rrj5m9xv.js";import"./chunk-rfnr4xz6.js";import"./chunk-36agnyhe.js";import"./chunk-sfwprq8q.js";import"./chunk-ydx3mfpp.js";import"./chunk-s12b57m9.js";import"./chunk-k7ht6tqe.js";import"./chunk-phzs239m.js";import"./chunk-1edvsndv.js";export{er as buildWebComponents,an as cacheTemplate,on as checkCache,fo as classifyAllScripts,Qi as createMiddleware,ea as createRoute,A as defaultConfig,d as extractVariables,J as injectRouterScript,o as loadStxConfig,be as processClientScript,n as processDirectives,pe as readMarkdownFile};
|
package/dist/chunk-bm2q1srp.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Hr,Ul,Vl}from"./chunk-mzqyv7s5.js";import"./chunk-dcpf6kas.js";import"./chunk-79vdkvhf.js";import"./chunk-2z0trbbm.js";import"./chunk-f4jh9vrj.js";import"./chunk-pnag11c4.js";import"./chunk-vp31ff54.js";import"./chunk-tv784gv0.js";import"./chunk-rrj5m9xv.js";import"./chunk-rfnr4xz6.js";import"./chunk-36agnyhe.js";import"./chunk-sfwprq8q.js";import"./chunk-ydx3mfpp.js";import"./chunk-s12b57m9.js";import"./chunk-k7ht6tqe.js";import"./chunk-phzs239m.js";import"./chunk-1edvsndv.js";export{Vl as clearComposableCache,Ul as getComposableScript,Hr as listComposableModules};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Computed helpers and component value sharing for the client runtime. */
|
|
2
|
-
export declare const SIGNALS_CONTEXT_RUNTIME = " // ==========================================================================\n // Public API\n // ==========================================================================\n\n // ==========================================================================\n // $: Computed Shorthand Support (Feature #7)\n // ==========================================================================\n\n // Helper function for $: reactive declarations (transformed by compiler)\n // Usage: $computed(() => count * 2) is shorthand for derived()\n function $computed(fn) {\n return derived(fn);\n }\n\n // Helper for watching a value with auto-unwrap\n function $watch(deps, fn) {\n effect(() => {\n // Access all dependencies to track them\n const values = Array.isArray(deps) ? deps.map(d => {\n if (typeof d === 'function' && (d._isSignal || d._isDerived)) return d();\n return d;\n }) : (typeof deps === 'function' && (deps._isSignal || deps._isDerived)) ? [deps()] : [deps];\n\n fn(...values);\n });\n }\n\n // provide() \u2014 share values across components (like Vue's provide/inject)\n // Usage: provide('Modal', Modal) \u2014 makes Modal accessible in all components\n //\n // inject() was auto-imported but implemented nowhere, so half of the pair\n // worked: provide() succeeded and the failure surfaced only in the consumer\n // (#1804). Values are recorded in a private registry as well as on window,\n // because the global write collides with native properties \u2014 provide('name',\n // x) lands on window.name, which the browser coerces to a string.\n var __stxProvided = Object.create(null);\n\n function provide(name, value) {\n __stxProvided[name] = value;\n window[name] = value;\n }\n\n function inject(name, defaultValue) {\n if (name in __stxProvided) return __stxProvided[name];\n if (name in window) return window[name];\n return defaultValue;\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Drawer controls used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_DRAWER_RUNTIME = " // \u2500\u2500 Drawer system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Same pattern as modal but slides from a side\n var drawer = {\n open: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (!el) { console.warn('[stx:drawer] Drawer \"' + id + '\" not found'); return; }\n el.style.display = 'flex';\n // Force reflow then animate\n void el.offsetHeight;\n el.setAttribute('data-stx-drawer-open', '');\n // The lock, Escape for the topmost and the Tab trap come from the\n // overlay stack, shared with every other overlay (stacksjs/stx#2057).\n // Each drawer used to bind its own Escape and set body overflow itself,\n // so two open closed together and the first to close unlocked the page.\n overlays.open('stx-drawer:' + id, {\n panel: el,\n onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { drawer.close(id); } : null\n });\n if (el.getAttribute('data-close-backdrop') !== 'false') {\n el.onclick = function(e) { if (e.target === el) drawer.close(id); };\n }\n },\n close: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (!el) return;\n el.removeAttribute('data-stx-drawer-open');\n el.onclick = null;\n overlays.close('stx-drawer:' + id);\n setTimeout(function() {\n if (!el.hasAttribute('data-stx-drawer-open')) el.style.display = 'none';\n }, 300);\n },\n toggle: function(id) {\n var el = document.querySelector('[data-stx-drawer=\"' + id + '\"]');\n if (el && el.hasAttribute('data-stx-drawer-open')) drawer.close(id);\n else drawer.open(id);\n }\n };\n";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default browser host used by the generated signals runtime.
|
|
3
|
-
*
|
|
4
|
-
* Keeping this as source text lets the same binding runtime swap in a native
|
|
5
|
-
* host through `window.__stx_host` without coupling reactive primitives to the
|
|
6
|
-
* DOM. The leading indentation and trailing blank line are intentional: this
|
|
7
|
-
* fragment is interpolated directly into the generated runtime.
|
|
8
|
-
*/
|
|
9
|
-
export declare const SIGNALS_HOST_RUNTIME = " // \u2500\u2500 Host \u2500\u2500\n //\n // The tree this runtime mutates. Every write the binding layer makes to a\n // node goes through here, so the same runtime can drive something that is not\n // the document -- native views over a bridge (stacksjs/stx#1984).\n //\n // Signals never touch a node, so nothing above this line needs to change; the\n // coupling is entirely in the bind layer. A host is swapped in by assigning\n // window.__stx_host before the runtime executes. The name is stxHost, not\n // host, because the runtime already calls two local DOM nodes host -- a\n // shadowed adapter fails as node.anchor is not a function, deep inside a\n // branch swap, and nowhere near the line that caused it, which keeps the web path\n // exactly as it was: same calls, one property lookup earlier.\n var stxHost = window.__stx_host || {\n setText: function(node, value) { node.textContent = value; },\n setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },\n setAttribute: function(node, name, value) {\n if (value === false) { node.removeAttribute(name); return; }\n if (value === true) { node.setAttribute(name, ''); return; }\n var next = value;\n if (typeof value === 'object' && value !== null) {\n try { next = JSON.stringify(value); }\n catch (e) { next = String(value); }\n }\n node.setAttribute(name, next);\n },\n removeAttribute: function(node, name) { node.removeAttribute(name); },\n setStyle: function(node, value) {\n if (typeof value === 'object' && value !== null) {\n Object.assign(node.style, value);\n if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';\n }\n else if (typeof value === 'string') {\n node.style.cssText = value;\n node.__stx_display = node.style.display || '';\n }\n // Reactive style updates must not clear the display:none owned by :show.\n // This also keeps the latest explicit display for when the gate opens.\n if (node.__stx_visible === false) node.style.display = 'none';\n },\n\n // Structural operations, for the bindings that build rows rather than\n // update one node (#1984).\n //\n // anchor() is a position in the child list that survives the nodes around\n // it moving -- a comment node here, since the document has one; a native\n // host keeps an index or a zero-size sentinel.\n //\n // clone() is the one that does not carry over as-is: a DOM subtree can be\n // deep-copied, a native view hierarchy cannot. A native host materialises a\n // fresh subtree from the template it was given instead of copying views,\n // which is why the row template is passed rather than a node to duplicate.\n // A native host registers the handler against the view and has the platform\n // call it; nothing about the binding layer changes, which is the point.\n // The options argument carries passive/capture/once. A native host has no use for\n // passive -- there is no scroll thread to block -- but dropping the\n // parameter silently makes every touch listener blocking again, so it stays\n // in the signature and each host decides what to do with it.\n listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },\n\n // Returns the PREVIOUS visibility. bindShow needs to know whether it just\n // revealed something, and asking the node afterwards is the one read-back\n // in the binding layer -- a native host cannot answer what a UIView's\n // display value was, because it has none. A write that reports what it\n // replaced removes the question: the DOM host reads its own style, a native\n // host reads isHidden, and the binder reads neither.\n //\n // Restoring an explicit display (a flex row, an inline-block) is the host's\n // business too; it records it the first time it hides the node.\n // The scope root a node belongs to: nearest ancestor-or-self that owns a\n // scope, or null. Three binding paths need it -- ref ownership, and an\n // if-chain finding the scope its branch belongs to.\n //\n // Not a query method. A host is never handed a selector, because a native\n // view tree has nothing to match one against: the DOM host walks with\n // closest(), a native host reads the node-to-scope map it maintains as it\n // creates views. The from flag skips the node itself, which the ref path needs\n // when it walks outward past a receiver it has already rejected.\n scopeOf: function(node, from) {\n var start = from ? (node && node.parentElement) : node;\n return (start && start.closest) ? start.closest('[data-stx-scope]') : null;\n },\n\n setVisible: function(node, visible) {\n if (node.__stx_display === undefined) {\n var d = node.style.display;\n node.__stx_display = (d && d !== 'none') ? d : '';\n }\n var was = node.style.display !== 'none';\n node.__stx_visible = visible;\n node.style.display = visible ? node.__stx_display : 'none';\n return was;\n },\n\n anchor: function(label) { return document.createComment(label); },\n clone: function(node) { return node.cloneNode(true); },\n insert: function(parent, node, before) { parent.insertBefore(node, before); },\n remove: function(node) { if (node.parentNode) node.parentNode.removeChild(node); },\n\n // Teardown needs to reach a subtree, and both ways of reaching one were\n // selector queries -- the last DOM assumption left in the binding layer\n // (#1984). A view hierarchy has no selectors, and a native host already\n // knows what it built, so being asked is cheaper for it than searching is\n // for the document.\n //\n // descendants() is every node under this one, for the per-node teardown\n // state the runtime hangs off elements. scopesIn() is the scope IDS in the\n // subtree, this node included -- ids and not nodes, because the only thing\n // done with them is a lookup in window.stx._scopes.\n descendants: function(node) {\n var out = [];\n if (!node || !node.querySelectorAll) return out;\n var all = node.querySelectorAll('*');\n for (var i = 0; i < all.length; i++) out.push(all[i]);\n return out;\n },\n scopesIn: function(node) {\n var ids = [];\n if (!node) return ids;\n var own = node.getAttribute && node.getAttribute('data-stx-scope');\n if (own) ids.push(own);\n if (node.querySelectorAll) {\n var matches = node.querySelectorAll('[data-stx-scope]');\n for (var i = 0; i < matches.length; i++) {\n var id = matches[i].getAttribute('data-stx-scope');\n if (id) ids.push(id);\n }\n }\n return ids;\n }\n };\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Loop-row conditional deferral for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_LOOP_CONDITIONAL_RUNTIME = " // A :for row is a clone of its template, so a conditional element in the row\n // is built for every row whether or not its condition ever holds; :if then\n // parks the false ones. In WebKit a <video> or <audio> sets up a media player\n // as it is created: a message list with one media slot per attachment took\n // 1.8s to render instead of 18ms, and every row paid for elements it never\n // showed. Before any row is cloned, each eligible conditional element in the\n // row template is moved into a <template> carrying its condition. Template\n // content is inert, so a cloned row builds the element only when the\n // condition holds (bindIf clones template content on the first true).\n //\n // Left alone: an if/else chain (its branches must stay siblings), an element\n // that is also a loop, a component (its setup script is a sibling), and\n // anything holding a script.\n var IF_ATTRS = [':if', 'x-if', '@if'];\n var FOR_ATTRS = [':for', 'x-for', '@for'];\n function deferRowConditionals(root) {\n if (stxHost.isNative || !root || !root.querySelectorAll || typeof document === 'undefined' || !document.createElement) return;\n // Inert HTML template content is a DOM allocation optimisation. Native\n // hosts already clone recorded descriptors and bind conditions through\n // their host operations; their document facade has no template content.\n if (!document.createElement('template').content) return;\n // A walk, not a selector: escaping ':' and '@' in an attribute selector\n // through this generated source is easy to get wrong, and wrong throws.\n var candidates = Array.prototype.slice.call(root.querySelectorAll('*'));\n for (var i = 0; i < candidates.length; i++) {\n var el = candidates[i];\n if (el.tagName === 'TEMPLATE' || !el.parentNode) continue;\n var attr = null;\n for (var a = 0; a < IF_ATTRS.length; a++) {\n if (el.hasAttribute(IF_ATTRS[a])) { attr = IF_ATTRS[a]; break; }\n }\n if (!attr) continue;\n var skip = false;\n for (var f = 0; f < FOR_ATTRS.length; f++) {\n if (el.hasAttribute(FOR_ATTRS[f])) skip = true;\n }\n if (skip || getElseAttrInfo(el)) continue;\n var next = el.nextElementSibling;\n if (next && (getElseAttrInfo(next) || next.tagName === 'SCRIPT')) continue;\n if (el.hasAttribute('data-stx-scope') || el.hasAttribute('x-data') || el.querySelector('script')) continue;\n var holder = document.createElement('template');\n holder.setAttribute(attr, el.getAttribute(attr));\n el.removeAttribute(attr);\n el.parentNode.insertBefore(holder, el);\n holder.content.appendChild(el);\n }\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Manifest-driven browser and native hydration for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_MANIFEST_HYDRATION_RUNTIME = " /**\n * Bind what the server said carries a binding, instead of looking for it.\n *\n * The walk exists because the runtime does not know where the bindings are.\n * The server does -- it rendered them -- so when it ships that list the\n * runtime stops searching: resolve each id, bind that element, never touch\n * its children. An element with no bindings is never visited at all.\n *\n * This is the piece a native host needs. A view hierarchy has no attributes\n * to read and no selector to match, so discovery cannot happen there; handed\n * the list, it does not have to. On the DOM the ids resolve by attribute,\n * which is one query per entry rather than a full traversal.\n *\n * Absent a manifest nothing changes: the walk is still the default, and a\n * page that ships no list hydrates exactly as it did.\n */\n function processFromManifest(root, scope, manifest, resolvedNodes) {\n // Arrays have an entries() method too. Prefer the array itself before\n // accepting the compiled document shape { entries: [...] }.\n var entries = Array.isArray(manifest)\n ? manifest\n : (manifest && Array.isArray(manifest.entries) ? manifest.entries : null);\n if (!entries || !entries.length || (!root && !resolvedNodes)) return false;\n for (var i = 0; i < entries.length; i++) {\n var entry = entries[i];\n var id = entry && entry.id;\n if (id === undefined || id === null) continue;\n // Native compilation already has stable handles for every manifest id.\n // Accept those handles directly so a non-DOM host never needs selectors\n // or an attribute walk. The browser keeps its existing lookup fallback.\n var node = resolvedNodes\n ? (typeof resolvedNodes.get === 'function' ? resolvedNodes.get(id) : resolvedNodes[id])\n : null;\n if (!node && root) {\n node = root.getAttribute && root.getAttribute('data-stx-b') === String(id)\n ? root\n : (root.querySelector ? root.querySelector('[data-stx-b=\"' + id + '\"]') : null);\n }\n if (!node) continue;\n // A structural binding can detach its source before a later manifest\n // entry reaches one of that source's children. Native handles expose\n // this state directly; do not register effects or handlers for a view\n // that no longer exists in the host tree. Browser hydration keeps its\n // existing behaviour because it does not pass resolvedNodes here.\n if (resolvedNodes && node.__stxId !== undefined && node.isConnected === false) continue;\n processElement(node, scope, true);\n }\n return true;\n }\n\n // Bind a precompiled host tree without waiting for DOMContentLoaded. Native\n // passes its manifest id to node-handle table; browser hydration continues\n // through the document-ready path below. The same state, effect, expression,\n // event and host implementations are used by both.\n function hydrateHost(root, setup, manifest, resolvedNodes) {\n var mountStart = mountCallbacks.length;\n var destroyStart = destroyCallbacks.length;\n var outerSink = activeDestroySink;\n activeDestroySink = null;\n var values;\n try { values = typeof setup === 'function' ? setup() : setup; }\n finally { activeDestroySink = outerSink; }\n var localMountHooks = mountCallbacks.splice(mountStart);\n var localDestroyHooks = destroyCallbacks.splice(destroyStart);\n var scope = Object.assign({ $refs: {} }, values || {});\n var disposeEffects = trackEffects(function() {\n processFromManifest(root, scope, manifest, resolvedNodes);\n });\n runMountCallbacks(localMountHooks, localDestroyHooks);\n var mounted = true;\n return function disposeHost() {\n if (!mounted) return;\n mounted = false;\n disposeEffects();\n var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);\n for (var i = 0; i < hooks.length; i++) {\n try { hooks[i](); }\n catch (e) { console.warn('[stx] native destroy error:', e); }\n }\n };\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Change notification shared by state, derived and reactive objects in the client runtime. */
|
|
2
|
-
export declare const SIGNALS_NOTIFY_RUNTIME = " // ==========================================================================\n // Notify\n // ==========================================================================\n\n // Gather the effects a change reaches, walking through derived values.\n function collectSubscribers(subscribers, into) {\n subscribers.forEach(function(sub) {\n if (sub._stxCollect) sub._stxCollect(into);\n else into.add(sub);\n });\n }\n\n // Two phases: mark every derived value on the way stale and gather the\n // effects reached, then run each once. Running them as found ran an effect\n // that reads a signal both directly and through a derived twice for one\n // change, the first time against the derived's old value.\n function notifySubscribers(subscribers) {\n if (isBatching) {\n collectSubscribers(subscribers, pendingEffects);\n return;\n }\n const reached = new Set();\n collectSubscribers(subscribers, reached);\n reached.forEach(function(e) { e(); });\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Optimistic state overlay used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_OPTIMISTIC_RUNTIME = " // ==========================================================================\n // Optimistic State (useOptimistic) \u2014 stacksjs/stx#1742\n // ==========================================================================\n // Mirrors signals-api.ts useOptimistic. Shows base + pending actions while an\n // async action is in flight; the overlay is discarded the moment base changes\n // (server confirmed). Returns [optimistic, addOptimistic]. addOptimistic\n // returns a settle() to roll back; pass a promise as the 2nd arg to auto-settle.\n function useOptimistic(base, reducer) {\n var readBase = (typeof base === 'function') ? base : function() { return base; };\n var pending = state([]);\n var optimistic = derived(function() {\n return pending().reduce(function(acc, entry) { return reducer(acc, entry.action); }, readBase());\n });\n var primed = false;\n effect(function() {\n readBase(); // track base only\n if (!primed) { primed = true; return; }\n if (peek(function() { return pending().length; })) pending.set([]);\n });\n function addOptimistic(action, settleWhen) {\n var entry = { action: action };\n pending.set(pending().concat([entry]));\n var settle = function() {\n var next = pending().filter(function(e) { return e !== entry; });\n if (next.length !== pending().length) pending.set(next);\n };\n if (settleWhen && typeof settleWhen.then === 'function') {\n Promise.resolve(settleWhen).then(settle, settle);\n }\n return settle;\n }\n return [optimistic, addOptimistic];\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Shared overlay stack and modal facade used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_OVERLAY_RUNTIME = " // \u2500\u2500 Overlay stack \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n //\n // One stack for everything that takes over the page: stxAlert/stxConfirm,\n // the runtime modal and drawer, @stacksjs/components' Dialog and Drawer, and\n // anything an app draws itself (window.stx.overlays). Each of those used to\n // keep its own listener, its own scroll lock and its own idea of whether it\n // was on top, so with one open over another a single Escape closed both, two\n // Tab traps fought over focus, and the first to close unlocked the page under\n // the one still open (stacksjs/stx#2057; #1998 fixed the same thing for the\n // confirm dialogs alone).\n //\n // Only the topmost overlay answers Escape and owns Tab. The page is locked\n // from the first open to the last close. Focus moves into an overlay when it\n // opens and back to whatever opened it when it closes.\n //\n // A popup - a menu, a listbox, a popover - goes on the same stack as a\n // non-modal layer (modal: false). It takes Escape while it is on top, so one\n // Escape inside a dialog closes the menu and leaves the dialog, but it does\n // not lock the page, trap Tab or move focus: those follow the topmost MODAL\n // layer. Each popup used to listen for Escape on the document itself, and\n // whichever listener was registered first won.\n var _overlays = [];\n var _overlayScroll = null;\n var _overlayInerted = [];\n var _overlayListening = false;\n var _OVERLAY_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n function _overlayTop() {\n return _overlays.length ? _overlays[_overlays.length - 1] : null;\n }\n\n // The layer that owns Tab and the page lock: the topmost modal one.\n function _overlayTopModal() {\n for (var i = _overlays.length - 1; i >= 0; i--) {\n if (_overlays[i].modal) return _overlays[i];\n }\n return null;\n }\n\n function _overlayIndex(id) {\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i].id === id) return i;\n }\n return -1;\n }\n\n // The panel is asked for, not held: a component's panel may not be rendered\n // yet on the frame it opens, and may be replaced while open.\n function _overlayPanel(entry) {\n var panel = entry && entry.panel;\n try {\n // A selector is looked up each time, like a function: the element it\n // names may be rendered after the overlay opens, or replaced while open.\n if (typeof panel === 'string') panel = document.querySelector(panel);\n else if (typeof panel === 'function') panel = panel();\n }\n catch (_e) { panel = null; }\n return panel || entry.root || null;\n }\n\n function _overlayShown(nodes) {\n return Array.prototype.filter.call(nodes, function(el) {\n return el.offsetParent !== null || el === document.activeElement;\n });\n }\n\n function _overlayFocusable(panel) {\n return _overlayShown(panel.querySelectorAll(_OVERLAY_FOCUSABLE));\n }\n\n // One listener for every overlay, in the bubble phase: a widget inside an\n // overlay that consumes Escape (a menu closing itself) calls preventDefault\n // and the overlay leaves it alone.\n function _overlayKey(e) {\n var top = _overlayTop();\n if (!top) return;\n if (e.key === 'Escape') {\n if (e.defaultPrevented || !top.onEscape) return;\n e.preventDefault();\n top.onEscape();\n return;\n }\n if (e.key !== 'Tab') return;\n var trap = _overlayTopModal();\n if (!trap) return;\n var panel = _overlayPanel(trap);\n if (!panel) return;\n var items = _overlayFocusable(panel);\n if (!items.length) {\n e.preventDefault();\n if (panel.focus) panel.focus();\n return;\n }\n var first = items[0];\n var last = items[items.length - 1];\n var active = document.activeElement;\n if (!panel.contains(active)) {\n e.preventDefault();\n (e.shiftKey ? last : first).focus();\n return;\n }\n if (e.shiftKey && active === first) {\n e.preventDefault();\n last.focus();\n }\n else if (!e.shiftKey && active === last) {\n e.preventDefault();\n first.focus();\n }\n }\n\n // Lock, listen and inert to match the stack after any change.\n function _overlaySync() {\n for (var i = 0; i < _overlayInerted.length; i++) {\n try { _overlayInerted[i].inert = false; }\n catch (_e) { /* element may be gone */ }\n }\n _overlayInerted = [];\n\n var top = _overlayTop();\n var modal = _overlayTopModal();\n if (!modal && _overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (!top) {\n if (_overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (_overlayListening) {\n document.removeEventListener('keydown', _overlayKey);\n _overlayListening = false;\n }\n return;\n }\n\n if (modal && !_overlayScroll) {\n _overlayScroll = {\n body: document.body.style.overflow,\n html: document.documentElement.style.overflow,\n pad: document.body.style.paddingRight\n };\n // The scrollbar's width comes back as padding, so the page does not jump\n // sideways when it disappears.\n var gap = window.innerWidth - document.documentElement.clientWidth;\n if (gap > 0) {\n var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;\n document.body.style.paddingRight = (existing + gap) + 'px';\n }\n document.body.style.overflow = 'hidden';\n document.documentElement.style.overflow = 'hidden';\n }\n if (!_overlayListening) {\n document.addEventListener('keydown', _overlayKey);\n _overlayListening = true;\n }\n\n // An overlay given a z-index stacks by the order it opened in, not by\n // where it sits in the document: one lifted into the body early (a sheet\n // mounted before the sheet it later opens over) drew underneath. Set on\n // every change, so what stays open closes up when one under it closes. A\n // closed overlay keeps its last value, so it slides away above the one\n // it was over.\n for (var z = 0; z < _overlays.length; z++) {\n var layer = _overlays[z];\n if (typeof layer.zIndex === 'number' && layer.root && layer.root.style) layer.root.style.zIndex = String(layer.zIndex + z);\n }\n\n // inert, rather than aria-hidden, takes the page behind out of the tab\n // order and the accessibility tree together (#1998). Only behind an\n // overlay that is a child of the body element - one the runtime appended,\n // or one an app lifted there - or one opened inside such an overlay (a\n // dialog in a sheet's content). An overlay rendered inside the page's own\n // markup would go inert with the page; its Tab trap is what holds it.\n var root = _overlayInertRoot(modal);\n if (root) {\n var kids = document.body.children;\n for (var k = 0; k < kids.length; k++) {\n var kid = kids[k];\n if (kid === root || kid.inert) continue;\n try {\n kid.inert = true;\n _overlayInerted.push(kid);\n }\n catch (_e) { /* inert unsupported; the Tab trap still holds */ }\n }\n }\n }\n\n // The child of the body that keeps the rest of the page inert while this\n // modal layer is on top: its own root when that is in the body, or the\n // root of the open overlay it sits inside. A dialog opened from a sheet's\n // content is not itself in the body, and the page behind the sheet used to\n // come back to the keyboard and screen readers while it was up.\n function _overlayInertRoot(modal) {\n if (!modal) return null;\n var el = modal.root || _overlayPanel(modal);\n while (el && el.parentNode && el.parentNode !== document.body) el = el.parentNode;\n if (!el || el.parentNode !== document.body) return null;\n if (el === modal.root) return el;\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i] !== modal && _overlays[i].root === el) return el;\n }\n return null;\n }\n\n // The next chance to act, whichever comes first: rAF is suspended in a\n // background tab, so a timer races it.\n function _overlaySoon(callback) {\n var done = false;\n var once = function() {\n if (done) return;\n done = true;\n callback();\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(once);\n setTimeout(once, 32);\n }\n\n // Retried, because focus() on an element that is not displayed yet is a\n // silent no-op. Stops once the overlay has closed.\n function _overlayFocusIn(entry, attempts) {\n if (_overlayIndex(entry.id) === -1) return;\n var target = null;\n try { target = typeof entry.initialFocus === 'function' ? entry.initialFocus() : entry.initialFocus; }\n catch (_e) { target = null; }\n var panel = _overlayPanel(entry);\n // An [autofocus] that is not shown (behind a :show, a player in a\n // dialog that is showing something else) cannot take focus: skipped, or\n // focus went nowhere and the panel's first control never got it.\n if (!target && panel) target = _overlayShown(panel.querySelectorAll('[autofocus]'))[0] || _overlayFocusable(panel)[0] || panel;\n if (target && target.focus) target.focus();\n if (target && document.activeElement === target) return;\n if (attempts > 0) _overlaySoon(function() { _overlayFocusIn(entry, attempts - 1); });\n }\n\n var overlays = {\n /**\n * Put an overlay on top. Calling it again for an open id updates its\n * options and nothing else, so it is safe from an effect that re-runs.\n *\n * options: modal (default true; false for a popup, which takes Escape\n * while on top but does not lock, trap or move focus), panel (an element,\n * a selector, or a function returning one; focus stays inside it), root (the overlay's outermost element, if it is not the panel),\n * zIndex (a base: the root's z-index becomes it plus the overlay's place\n * in the stack, so a later overlay draws over an earlier one wherever it\n * sits in the document), onEscape (leave out for one that must be answered), initialFocus\n * (element or function; defaults to [autofocus], then the first focusable,\n * then the panel), opener (where focus goes back; defaults to whatever had\n * it), restoreFocus (default true).\n */\n open: function(id, options) {\n var opts = options || {};\n var at = _overlayIndex(id);\n if (at !== -1) {\n var existing = _overlays[at];\n for (var key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];\n }\n _overlaySync();\n return;\n }\n var isModal = opts.modal !== false;\n var entry = {\n id: id,\n modal: isModal,\n panel: opts.panel,\n root: opts.root || null,\n zIndex: typeof opts.zIndex === 'number' ? opts.zIndex : null,\n onEscape: opts.onEscape || null,\n initialFocus: opts.initialFocus || null,\n // A popup hands focus back itself, to its own trigger, and only when\n // focus was inside it; a modal layer always does.\n restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,\n opener: opts.opener !== undefined ? opts.opener : document.activeElement\n };\n _overlays.push(entry);\n _overlaySync();\n // Synchronously first, so a caller that asserts focus straight after\n // opening sees it; then retried for a panel that is not displayed yet.\n // A popup keeps focus where its own keyboard handling puts it.\n if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);\n },\n /** Take an overlay off the stack, wherever it is in it. */\n close: function(id) {\n var at = _overlayIndex(id);\n if (at === -1) return;\n var wasTop = at === _overlays.length - 1;\n var entry = _overlays.splice(at, 1)[0];\n _overlaySync();\n // Only the overlay that had the keyboard gives it back. Closing one\n // underneath (its owner went away) must not pull focus out of the top.\n var opener = entry.opener;\n if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {\n try { opener.focus(); }\n catch (_e) { /* gone; nothing to give focus back to */ }\n }\n },\n /** Whether this overlay is the one that has the keyboard. */\n isTop: function(id) {\n var top = _overlayTop();\n return !!top && top.id === id;\n },\n /** Open overlay ids, outermost first. */\n list: function() {\n return _overlays.map(function(o) { return o.id; });\n }\n };\n\n // \u2500\u2500 Modal system \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n var modal = {\n open: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) { console.warn('[stx:modal] Modal \"' + id + '\" not found'); return; }\n el.style.display = 'flex';\n // Force reflow then animate\n void el.offsetHeight;\n el.setAttribute('data-stx-modal-open', '');\n // The lock, Escape for the topmost and the Tab trap come from the\n // overlay stack, shared with every other overlay (stacksjs/stx#2057).\n // Each modal used to bind its own Escape and set body overflow itself,\n // so two open closed together and the first to close unlocked the page.\n overlays.open('stx-modal:' + id, {\n panel: el,\n onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { modal.close(id); } : null\n });\n if (el.getAttribute('data-close-backdrop') !== 'false') {\n el.onclick = function(e) { if (e.target === el) modal.close(id); };\n }\n },\n close: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) return;\n el.removeAttribute('data-stx-modal-open');\n el.onclick = null;\n overlays.close('stx-modal:' + id);\n setTimeout(function() {\n if (!el.hasAttribute('data-stx-modal-open')) el.style.display = 'none';\n }, 200);\n },\n toggle: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (el && el.hasAttribute('data-stx-modal-open')) modal.close(id);\n else modal.open(id);\n }\n };\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Scope and effect disposal used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SCOPE_DISPOSAL_RUNTIME = " // ==========================================================================\n // Scope Disposal\n // ==========================================================================\n\n // Walk a subtree (root + descendants) and fire each [data-stx-scope]'s\n // destroy callbacks + remove the entry from window.stx._scopes. Pre-fix\n // (stacksjs/stx#1727) only cleanupContainer (called during SPA navigation)\n // ran this walk, so dynamic unmounts driven by :if/:for leaked scopes\n // indefinitely. Now bindIf, bindFor, and cleanupContainer all funnel\n // through this helper so the cleanup is symmetric regardless of who\n // initiated the removal.\n // Dispose the EFFECTS bound inside a subtree leaving the page for good: a\n // removed :for row, a hidden template :if clone, a hidden :for empty\n // placeholder, or a container on SPA navigation (#1954).\n // disposeSubtreeScopes only releases scope registrations. Without this, the\n // effects that bound the subtree stay subscribed to every signal they read\n // and keep running, so work per update grows with every removal.\n // Descendants first, then the root, the order cleanupContainer always used.\n function disposeSubtreeEffects(root) {\n if (!root) return;\n var nodes = stxHost.descendants(root);\n nodes.push(root);\n var owned = ['__stx_disposers', '__stx_effect_disposers', '__stx_if_disposers', '__stx_chain_disposers'];\n for (var n = 0; n < nodes.length; n++) {\n var el = nodes[n];\n if (typeof el.__stx_hydration_cancel === 'function') {\n try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }\n el.__stx_hydration_cancel = null;\n }\n if (Array.isArray(el.__stx_destroy)) {\n var hooks = el.__stx_destroy;\n el.__stx_destroy = null;\n hooks.forEach(function(fn) {\n try { fn(); }\n catch (e) { console.warn('[stx] destroy hook error:', e); }\n });\n }\n if (el.__stx_detached_if) {\n var detached = el.__stx_detached_if;\n el.__stx_detached_if = null;\n detached.forEach(function(node) { disposeSubtreeEffects(node); });\n }\n for (var k = 0; k < owned.length; k++) {\n var disposeOwned = el[owned[k]];\n if (typeof disposeOwned === 'function') {\n el[owned[k]] = null;\n disposeOwned();\n }\n }\n }\n }\n\n // :if is a toggle, and a component inside one lives through every toggle:\n // its scope is registered once and kept (#1737), and showing the branch puts\n // the same markup back. Its LIFECYCLE follows the toggle, though. Hiding runs\n // what the component registered to release -- its onDestroy, and whatever\n // its onMount handed back -- and showing it again runs its onMount again.\n // Each show is a mount and each hide an unmount, which is the pairing every\n // component on a page already gets.\n //\n // Before this, a hidden component never heard about it and a re-shown one\n // was never told it was back (the asymmetry stacksjs/stx#2036 stopped short\n // of). A gated modal shell -- one that traps focus, locks body scroll and\n // claims Escape from onMount, and releases them in onDestroy -- did all of\n // that on its first opening and on no later one: the second time it opened\n // with the page scrolling behind it and Escape doing nothing.\n //\n // Only scopes that actually mounted are suspended, so a component whose\n // first mount is still deferred (behind a false :if, or an stx-hydrate\n // island) keeps waiting for its own flush.\n function suspendSubtreeScopes(nodes) {\n if (!nodes || !window.stx || !window.stx._scopes) return;\n var ids = [];\n for (var i = 0; i < nodes.length; i++) {\n var found = stxHost.scopesIn(nodes[i]);\n for (var k = 0; k < found.length; k++) {\n if (ids.indexOf(found[k]) === -1) ids.push(found[k]);\n }\n }\n // Innermost first, the order a page unmounts in: a child releases what it\n // holds before the component it sits in does.\n for (var n = ids.length - 1; n >= 0; n--) {\n var scopeVars = window.stx._scopes[ids[n]];\n if (!scopeVars || !scopeVars.__mounted) continue;\n scopeVars.__mounted = false;\n scopeVars.__suspended = true;\n var release = scopeVars.__destroyCallbacks || [];\n // What onDestroy registered at setup is owed again at the next hide;\n // a cleanup a mount handed back belonged to that mount alone.\n scopeVars.__destroyCallbacks = (scopeVars.__destroyHooks || []).slice();\n for (var j = 0; j < release.length; j++) {\n try { release[j](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n scopeVars.__mountCallbacks = (scopeVars.__mountHooks || []).slice();\n }\n }\n\n // The other half: a suspended scope whose markup is back on the page mounts\n // again. A scope still off the page (hidden by an :if of its own inside this\n // branch) is left for that :if to resume.\n function resumeSubtreeScopes(nodes) {\n if (!nodes || !window.stx || !window.stx._scopes) return;\n for (var i = 0; i < nodes.length; i++) {\n var ids = stxHost.scopesIn(nodes[i]);\n for (var k = 0; k < ids.length; k++) {\n var scopeVars = window.stx._scopes[ids[k]];\n if (!scopeVars || scopeVars.__mounted || !scopeVars.__suspended) continue;\n if (scopeVars.__el && scopeVars.__el.isConnected === false) continue;\n scopeVars.__suspended = false;\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n }\n }\n\n function disposeSubtreeScopes(root) {\n if (!root || !window.stx || !window.stx._scopes) return;\n // The host reports which scopes live in this subtree: the document finds\n // them with a selector, a native host reads the map it keeps as it builds\n // views (#1984).\n var scopeIds = stxHost.scopesIn(root);\n for (var n = 0; n < scopeIds.length; n++) {\n var scopeId = scopeIds[n];\n if (!scopeId) continue;\n var scopeVars = window.stx._scopes[scopeId];\n if (!scopeVars) continue;\n // Hidden by an :if, it already released everything on the way out;\n // running the hooks again would unmount it twice. (A hidden component's\n // root is detached, so no walk reaches it today; this keeps the next\n // disposal path that does from unmounting it twice.)\n var alreadyReleased = scopeVars.__suspended && !scopeVars.__mounted;\n if (!alreadyReleased && scopeVars.__destroyCallbacks && Array.isArray(scopeVars.__destroyCallbacks)) {\n for (var j = 0; j < scopeVars.__destroyCallbacks.length; j++) {\n try { scopeVars.__destroyCallbacks[j](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n }\n delete window.stx._scopes[scopeId];\n }\n }\n\n // Reclaim registry entries whose element is gone from the document.\n //\n // disposeSubtreeScopes only deletes scopes found UNDER the cleanup container,\n // so two shapes leaked forever across SPA navigation (#1775): components\n // rendered outside the swap container (an @include in the layout, above\n // <main>), and elements already detached by the time cleanup ran its\n // querySelectorAll. Each round-trip re-ran the include scripts under fresh\n // scope ids while the previous ids stayed in window.stx._scopes \u2014 ~4 orphans\n // per hop, unbounded, each retaining that scope's vars, signals and closures.\n // Since #1958 a same-layout navigation no longer re-runs the layout's\n // component scripts, and a layout change cleans up the whole body first, so\n // navigation should no longer produce the first shape; the sweep stays for\n // the second, and as the backstop for anything that still does.\n //\n // The sweep is deliberately CONSERVATIVE \u2014 an over-eager delete is the #1737\n // failure (a scope removed from the registry cannot be recreated: its setup\n // IIFE ran once at page load), which is strictly worse than a leak. An entry\n // is dropped only when all three hold:\n // 1. the runtime actually bound it to an element (__el recorded),\n // 2. that element is no longer connected to the document, and\n // 3. neither it nor any ancestor is retained by a live conditional.\n // Entries with no __el (e.g. a scope whose element still sits inside untouched\n // <template> content, never inserted) are left alone \u2014 we can't prove they're\n // dead, and a later clone re-uses that registration.\n function sweepOrphanedScopes() {\n if (!window.stx || !window.stx._scopes) return;\n var scopes = window.stx._scopes;\n for (var id in scopes) {\n if (!Object.prototype.hasOwnProperty.call(scopes, id)) continue;\n var entry = scopes[id];\n if (!entry) continue;\n var el = entry.__el;\n if (!el || el.isConnected) continue;\n // Detached but RETAINED: :if toggles keep their element (bindIf re-inserts\n // the SAME node) and :if/:else chains keep their branches. Parent links\n // inside a detached subtree stay intact, so walking up from the scope\n // element still finds the conditional that owns it.\n var retained = false;\n for (var p = el; p; p = p.parentNode) {\n if (p.__stx_if_bound || p.__stx_chain_member) { retained = true; break; }\n }\n if (retained) continue;\n // Suspended by an :if: released when it hid, so not again here.\n if (!(entry.__suspended && !entry.__mounted) && entry.__destroyCallbacks && Array.isArray(entry.__destroyCallbacks)) {\n for (var k = 0; k < entry.__destroyCallbacks.length; k++) {\n try { entry.__destroyCallbacks[k](); }\n catch (e) { console.warn('[stx] scope destroy error:', e); }\n }\n }\n delete scopes[id];\n }\n }\n";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** SPA load scheduling and teardown boundaries for the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_SPA_LOAD_CONTROL_RUNTIME = " // Re-initialize components after SPA content swap.\n // Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).\n var _stxLoadTimer = null;\n if (window.__stxLoadHandler) {\n window.removeEventListener('stx:load', window.__stxLoadHandler);\n }\n function stxLoadHandler() {\n if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }\n _stxLoadTimer = setTimeout(_handleStxLoad, 5);\n }\n window.__stxLoadHandler = stxLoadHandler;\n window.addEventListener('stx:load', stxLoadHandler);\n\n // Run a pending stx:load now instead of after the debounce. The router's\n // instant navigation (a tab bar) reveals the new screen in a single frame\n // once the page is bound; waiting out the timer revealed it with its\n // {{ }} still unbound and filled it in a frame later.\n function flushStxLoad() {\n if (!_stxLoadTimer) return false;\n clearTimeout(_stxLoadTimer);\n _handleStxLoad();\n return true;\n }\n // The page-level onDestroy callbacks a navigation is leaving behind.\n //\n // stx:load used to run everything in destroyCallbacks, on the reading that\n // the queue held the outgoing page. It does not by then: the router runs the\n // incoming page's scripts BEFORE it fires stx:load, and a page-level\n // onDestroy registered by one of them (a layout partial's useColorMode, a\n // listener, a stream) joined the same queue and was run at once - its owner\n // still on screen. A tab bar that retains screens made it certain, since\n // that path had already filed the outgoing page's callbacks with its screen,\n // so the queue stx:load drained held only the new page's. The page then\n // stopped following the system theme, among other things, until a reload.\n //\n // The router marks the boundary with _beginSwap just before the incoming\n // scripts run. Null means no boundary was marked since the last stx:load (a\n // re-fire, an older router), and then the queue is drained as before.\n var departingDestroys = null;\n function beginSwap() {\n departingDestroys = (departingDestroys || []).concat(destroyCallbacks.splice(0));\n }";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Browser storage composables used by the generated client runtime. */
|
|
2
|
-
export declare const SIGNALS_STORAGE_RUNTIME = " // Storage access is guarded end to end (stacksjs/stx#1793). Every one of\n // these can throw, and each throw took down the whole client script for the\n // page rather than just the composable:\n //\n // getItem - SecurityError in a sandboxed iframe or with storage disabled\n // parse - any non-JSON value already sitting at the key\n // setItem - QuotaExceededError, Safari private mode\n //\n // The parse fallback is deliberately LENIENT: a value that isn't JSON is\n // returned as the raw string rather than discarded for defaultValue. A key\n // that previously held a bare 'list' keeps reading back 'list' and is\n // rewritten as JSON on the next set, so migrating an existing key onto this\n // composable no longer needs the key to be renamed. This also matches\n // composables/use-storage.ts, whose default serializer already returns the\n // raw string on parse failure \u2014 the two implementations have to agree.\n function stxParseStored(raw, fallback, key, label) {\n if (raw === null || raw === undefined) return fallback;\n try { return JSON.parse(raw); }\n catch (e) {\n console.warn('[stx] ' + label + ': \"' + key + '\" holds a value that is not JSON (' + String(raw).slice(0, 64) + '); using it as a raw string. Write it with the same composable to store it as JSON.');\n return raw;\n }\n }\n function stxStorageRead(store, key, fallback, label) {\n var raw;\n try { raw = store.getItem(key); }\n catch (e) {\n console.warn('[stx] ' + label + ': cannot read \"' + key + '\" (' + (e && e.message ? e.message : e) + '); using the default.');\n return fallback;\n }\n return stxParseStored(raw, fallback, key, label);\n }\n function stxStorageWrite(store, key, value, label) {\n try { store.setItem(key, JSON.stringify(value)); }\n catch (e) {\n console.warn('[stx] ' + label + ': cannot persist \"' + key + '\" (' + (e && e.message ? e.message : e) + '); the value stays in memory only.');\n }\n }\n\n function useLocalStorage(key, defaultValue) {\n var s = state(stxStorageRead(localStorage, key, defaultValue, 'useLocalStorage'));\n effect(function() {\n stxStorageWrite(localStorage, key, s(), 'useLocalStorage');\n });\n var handler = function(e) {\n // Fires from ANOTHER tab at an arbitrary later time, so an unguarded\n // parse here throws inside a window listener with a stack pointing at\n // the runtime rather than at the consumer.\n // storageArea is also matched so a sessionStorage write to the same key\n // name can't clobber this signal \u2014 useSessionStorage already filtered,\n // this side didn't. Synthetic events (tests) leave storageArea null and\n // are still accepted; real browsers always populate it.\n if (e.key === key && (!e.storageArea || e.storageArea === localStorage))\n s.set(stxParseStored(e.newValue, defaultValue, key, 'useLocalStorage'));\n };\n window.addEventListener('storage', handler);\n onDestroy(function() { window.removeEventListener('storage', handler); });\n return s;\n }\n\n // Mirror of useLocalStorage against sessionStorage. Strict-mode lint\n // already suggests this function name as the replacement for raw\n // window.sessionStorage access; this is the implementation that backs\n // that hint. Same JSON serialization, cross-tab sync via the 'storage'\n // event (filtered to sessionStorage's storageArea \u2014 localStorage events\n // share the same listener but fire from a different area).\n function useSessionStorage(key, defaultValue) {\n var s = state(stxStorageRead(sessionStorage, key, defaultValue, 'useSessionStorage'));\n effect(function() {\n stxStorageWrite(sessionStorage, key, s(), 'useSessionStorage');\n });\n var handler = function(e) {\n if (e.key === key && (!e.storageArea || e.storageArea === sessionStorage))\n s.set(stxParseStored(e.newValue, defaultValue, key, 'useSessionStorage'));\n };\n window.addEventListener('storage', handler);\n onDestroy(function() { window.removeEventListener('storage', handler); });\n return s;\n }";
|