@ohos-ports/stacksjs-stx 0.2.287-beta.0
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/LICENSE.md +21 -0
- package/README.md +1042 -0
- package/dist/a11y.d.ts +256 -0
- package/dist/a11y.js +671 -0
- package/dist/analytics.d.ts +40 -0
- package/dist/analytics.js +159 -0
- package/dist/analyzer.d.ts +68 -0
- package/dist/analyzer.js +240 -0
- package/dist/animation.d.ts +123 -0
- package/dist/animation.js +688 -0
- package/dist/app-shell.d.ts +76 -0
- package/dist/app-shell.js +209 -0
- package/dist/app.d.ts +65 -0
- package/dist/app.js +79 -0
- package/dist/appearance-bootstrap.d.ts +54 -0
- package/dist/appearance-bootstrap.js +92 -0
- package/dist/asset-roots.d.ts +32 -0
- package/dist/asset-roots.js +7 -0
- package/dist/assets.d.ts +21 -0
- package/dist/assets.js +155 -0
- package/dist/ast.d.ts +265 -0
- package/dist/ast.js +630 -0
- package/dist/async-components.d.ts +123 -0
- package/dist/async-components.js +428 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.js +12 -0
- package/dist/broadcasting.d.ts +77 -0
- package/dist/broadcasting.js +103 -0
- package/dist/browser-composables.d.ts +348 -0
- package/dist/browser-composables.js +606 -0
- package/dist/browser-core-imports.d.ts +12 -0
- package/dist/browser-core-imports.js +28 -0
- package/dist/build-assets.d.ts +32 -0
- package/dist/build-assets.js +29 -0
- package/dist/build-externalize-repeated.d.ts +34 -0
- package/dist/build-externalize-repeated.js +101 -0
- package/dist/build-externalize.d.ts +73 -0
- package/dist/build-externalize.js +80 -0
- package/dist/build-id.d.ts +57 -0
- package/dist/build-id.js +25 -0
- package/dist/build-message.d.ts +81 -0
- package/dist/build-message.js +65 -0
- package/dist/build-mode-detector.d.ts +26 -0
- package/dist/build-mode-detector.js +50 -0
- package/dist/build-optimizer.d.ts +101 -0
- package/dist/build-optimizer.js +433 -0
- package/dist/build-views.d.ts +56 -0
- package/dist/build-views.js +180 -0
- package/dist/build.d.ts +31 -0
- package/dist/build.js +34 -0
- package/dist/builtins/attrs.d.ts +49 -0
- package/dist/builtins/attrs.js +39 -0
- package/dist/builtins/drawer.d.ts +24 -0
- package/dist/builtins/drawer.js +37 -0
- package/dist/builtins/escape.d.ts +12 -0
- package/dist/builtins/escape.js +3 -0
- package/dist/builtins/icon.d.ts +45 -0
- package/dist/builtins/icon.js +100 -0
- package/dist/builtins/image-delivery.d.ts +16 -0
- package/dist/builtins/image-delivery.js +115 -0
- package/dist/builtins/image-placeholder.d.ts +78 -0
- package/dist/builtins/image-placeholder.js +137 -0
- package/dist/builtins/index.d.ts +26 -0
- package/dist/builtins/index.js +34 -0
- package/dist/builtins/modal.d.ts +26 -0
- package/dist/builtins/modal.js +38 -0
- package/dist/builtins/safe-image.d.ts +44 -0
- package/dist/builtins/safe-image.js +45 -0
- package/dist/builtins/stx-image.d.ts +29 -0
- package/dist/builtins/stx-image.js +222 -0
- package/dist/builtins/stx-link.d.ts +11 -0
- package/dist/builtins/stx-link.js +35 -0
- package/dist/builtins/stx-loading-indicator.d.ts +13 -0
- package/dist/builtins/stx-loading-indicator.js +35 -0
- package/dist/builtins/suspense.d.ts +30 -0
- package/dist/builtins/suspense.js +24 -0
- package/dist/builtins/toast.d.ts +19 -0
- package/dist/builtins/toast.js +42 -0
- package/dist/builtins/tooltip.d.ts +18 -0
- package/dist/builtins/tooltip.js +106 -0
- package/dist/builtins/transition-group.d.ts +27 -0
- package/dist/builtins/transition-group.js +22 -0
- package/dist/bun-shim.js +496 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/collector.js +233 -0
- package/dist/bundle-analyzer/index.d.ts +98 -0
- package/dist/bundle-analyzer/index.js +82 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/report.js +318 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer/treemap.js +594 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +69 -0
- package/dist/caching.js +135 -0
- package/dist/chunk-0y46fbkx.js +3 -0
- package/dist/chunk-122tyfre.js +2 -0
- package/dist/chunk-19nfvxfw.js +43 -0
- package/dist/chunk-1kah92n2.js +3 -0
- package/dist/chunk-1kms3b9d.js +2 -0
- package/dist/chunk-1q4y74mh.js +1194 -0
- package/dist/chunk-248e84r1.js +4 -0
- package/dist/chunk-24ps8kft.js +2 -0
- package/dist/chunk-2et5hxfv.js +2 -0
- package/dist/chunk-2r1rd8f0.js +2 -0
- package/dist/chunk-2tk1zkrz.js +2 -0
- package/dist/chunk-38ejahd9.js +3 -0
- package/dist/chunk-3zv4wz87.js +2 -0
- package/dist/chunk-4122k1bh.js +2 -0
- package/dist/chunk-45az9zht.js +2 -0
- package/dist/chunk-4qr85f07.js +2 -0
- package/dist/chunk-4ww3znrr.js +15 -0
- package/dist/chunk-54st8g2j.js +397 -0
- package/dist/chunk-58f0mthg.js +3 -0
- package/dist/chunk-5a19dhx5.js +2 -0
- package/dist/chunk-5kk8gsj2.js +3 -0
- package/dist/chunk-5w1e3yxs.js +499 -0
- package/dist/chunk-6gdycmxr.js +2 -0
- package/dist/chunk-6hmnaza7.js +4473 -0
- package/dist/chunk-71t0yan0.js +5 -0
- package/dist/chunk-74cv4ta1.js +3 -0
- package/dist/chunk-74v15e8z.js +2 -0
- package/dist/chunk-7b329e5v.js +3 -0
- package/dist/chunk-7q9mwh4v.js +84 -0
- package/dist/chunk-866y9d8b.js +8169 -0
- package/dist/chunk-8fwerspy.js +2 -0
- package/dist/chunk-8mjdpr94.js +147 -0
- package/dist/chunk-92mj1t26.js +60 -0
- package/dist/chunk-9b22663r.js +2 -0
- package/dist/chunk-9hjdgm4d.js +2 -0
- package/dist/chunk-9n0gvfrg.js +4 -0
- package/dist/chunk-9wr7zcad.js +18 -0
- package/dist/chunk-9y0g8kzt.js +358 -0
- package/dist/chunk-a0nfbmeh.js +3 -0
- package/dist/chunk-acn1b56m.js +1280 -0
- package/dist/chunk-awkq3xfx.js +2 -0
- package/dist/chunk-b6ej2fdf.js +1814 -0
- package/dist/chunk-b8rrnqry.js +2 -0
- package/dist/chunk-bfqfs07m.js +3022 -0
- package/dist/chunk-bs6kapy7.js +2 -0
- package/dist/chunk-btav940g.js +2 -0
- package/dist/chunk-bz820epz.js +3 -0
- package/dist/chunk-ccspd3mc.js +2 -0
- package/dist/chunk-csbgwaa5.js +2 -0
- package/dist/chunk-d8t4sjsp.js +2 -0
- package/dist/chunk-dap191q2.js +2 -0
- package/dist/chunk-de7fye10.js +4 -0
- package/dist/chunk-dgrt76d2.js +2 -0
- package/dist/chunk-dhh5q7qt.js +3 -0
- package/dist/chunk-dsffsqnt.js +2 -0
- package/dist/chunk-dtq7y5ym.js +2 -0
- package/dist/chunk-fed3xsp9.js +3 -0
- package/dist/chunk-ferav3bw.js +19 -0
- package/dist/chunk-fvhm8psm.js +3 -0
- package/dist/chunk-g4vpzv6b.js +2 -0
- package/dist/chunk-g9csmj0s.js +2 -0
- package/dist/chunk-gtcrpmz1.js +2 -0
- package/dist/chunk-h4xh8cms.js +4 -0
- package/dist/chunk-h8yqsz9m.js +2 -0
- package/dist/chunk-hcq5dw7a.js +2 -0
- package/dist/chunk-hm0xha6c.js +12 -0
- package/dist/chunk-hpybjwwf.js +8 -0
- package/dist/chunk-jegt35zh.js +2 -0
- package/dist/chunk-jr3jp3ev.js +8 -0
- package/dist/chunk-k56rjjc0.js +24 -0
- package/dist/chunk-kdh37tp8.js +194 -0
- package/dist/chunk-kxzb4et3.js +29 -0
- package/dist/chunk-mf4n3x1j.js +14 -0
- package/dist/chunk-mkd9kjgb.js +3 -0
- package/dist/chunk-mxfh1nxg.js +2 -0
- package/dist/chunk-n3ggrhb3.js +3 -0
- package/dist/chunk-nkb3scg6.js +8 -0
- package/dist/chunk-nnd4wq8j.js +231 -0
- package/dist/chunk-nsp1cw38.js +11 -0
- package/dist/chunk-nx5qkm8k.js +30 -0
- package/dist/chunk-p3242nck.js +2 -0
- package/dist/chunk-p98kfh94.js +2 -0
- package/dist/chunk-pkaabd8h.js +3 -0
- package/dist/chunk-pzm13sdc.js +3 -0
- package/dist/chunk-q4p5k2p3.js +2 -0
- package/dist/chunk-q9n5swx7.js +3 -0
- package/dist/chunk-qc1f74ek.js +3 -0
- package/dist/chunk-qpyjak7z.js +2 -0
- package/dist/chunk-qr82je1m.js +22 -0
- package/dist/chunk-qy73j6m4.js +288 -0
- package/dist/chunk-qzkhpsam.js +505 -0
- package/dist/chunk-r3ayvdz3.js +2 -0
- package/dist/chunk-r7r66978.js +2 -0
- package/dist/chunk-rbb7dvja.js +30 -0
- package/dist/chunk-refwkt87.js +71 -0
- package/dist/chunk-rj4kajww.js +2 -0
- package/dist/chunk-rp4rjjmf.js +2 -0
- package/dist/chunk-se0p17c2.js +898 -0
- package/dist/chunk-sj9pmene.js +2 -0
- package/dist/chunk-sscwkffs.js +2 -0
- package/dist/chunk-svpqxn2c.js +2 -0
- package/dist/chunk-t6nseeb9.js +351 -0
- package/dist/chunk-t8y1ggdy.js +2 -0
- package/dist/chunk-tndhnk9e.js +2 -0
- package/dist/chunk-v5e1gxwm.js +3 -0
- package/dist/chunk-vqxmxgaj.js +4 -0
- package/dist/chunk-vrrax298.js +2 -0
- package/dist/chunk-w3ycm4na.js +3 -0
- package/dist/chunk-wcm80anz.js +321 -0
- package/dist/chunk-wrzwgkbx.js +22 -0
- package/dist/chunk-x650vjcp.js +302 -0
- package/dist/chunk-xgnc1wy6.js +116 -0
- package/dist/chunk-xpp135ad.js +11 -0
- package/dist/chunk-xttsqmkm.js +216 -0
- package/dist/chunk-y11cxbxd.js +3757 -0
- package/dist/chunk-y7m2dpd3.js +341 -0
- package/dist/chunk-y98jsjqq.js +2 -0
- package/dist/chunk-ya386h70.js +2 -0
- package/dist/chunk-ydrz60kr.js +2 -0
- package/dist/chunk-ypmqf7tm.js +4 -0
- package/dist/chunk-z4jhj5e5.js +28 -0
- package/dist/chunk-zg75gjns.js +2 -0
- package/dist/chunk-zqqx1qaj.js +2 -0
- package/dist/cli-flags.d.ts +34 -0
- package/dist/cli-flags.js +20 -0
- package/dist/cli.js +174 -0
- package/dist/client/directive.d.ts +17 -0
- package/dist/client/directive.js +14 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +2 -0
- package/dist/client-helpers.d.ts +317 -0
- package/dist/client-helpers.js +312 -0
- package/dist/client-script-bundler.d.ts +103 -0
- package/dist/client-script-bundler.js +390 -0
- package/dist/client-script.d.ts +215 -0
- package/dist/client-script.js +865 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.js +73 -0
- package/dist/codemod.d.ts +33 -0
- package/dist/codemod.js +244 -0
- package/dist/color-mode-boot.d.ts +92 -0
- package/dist/color-mode-boot.js +72 -0
- package/dist/component-client-factories.d.ts +33 -0
- package/dist/component-client-factories.js +77 -0
- package/dist/component-hmr.d.ts +107 -0
- package/dist/component-hmr.js +585 -0
- package/dist/component-library.d.ts +38 -0
- package/dist/component-library.js +994 -0
- package/dist/component-processing.d.ts +198 -0
- package/dist/component-processing.js +677 -0
- package/dist/component-registry.d.ts +127 -0
- package/dist/component-registry.js +90 -0
- package/dist/component-renderer.d.ts +52 -0
- package/dist/component-renderer.js +790 -0
- package/dist/components/StxImage.stx +12 -0
- package/dist/components/StxLink.stx +18 -0
- package/dist/components.d.ts +28 -0
- package/dist/components.js +213 -0
- package/dist/composable-loader.d.ts +62 -0
- package/dist/composable-loader.js +190 -0
- package/dist/composables/index.d.ts +417 -0
- package/dist/composables/index.js +222 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-battery.js +101 -0
- package/dist/composables/use-broadcast-channel.d.ts +59 -0
- package/dist/composables/use-broadcast-channel.js +80 -0
- package/dist/composables/use-channel.d.ts +67 -0
- package/dist/composables/use-channel.js +124 -0
- package/dist/composables/use-clipboard.d.ts +30 -0
- package/dist/composables/use-clipboard.js +90 -0
- package/dist/composables/use-color-mode.d.ts +67 -0
- package/dist/composables/use-color-mode.js +152 -0
- package/dist/composables/use-cookie.d.ts +59 -0
- package/dist/composables/use-cookie.js +86 -0
- package/dist/composables/use-device-orientation.d.ts +116 -0
- package/dist/composables/use-device-orientation.js +181 -0
- package/dist/composables/use-event-listener.d.ts +35 -0
- package/dist/composables/use-event-listener.js +27 -0
- package/dist/composables/use-event-source.d.ts +90 -0
- package/dist/composables/use-event-source.js +166 -0
- package/dist/composables/use-eye-dropper.d.ts +117 -0
- package/dist/composables/use-eye-dropper.js +142 -0
- package/dist/composables/use-fetch.d.ts +59 -0
- package/dist/composables/use-fetch.js +273 -0
- package/dist/composables/use-form.d.ts +91 -0
- package/dist/composables/use-form.js +112 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-fullscreen.js +110 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-geolocation.js +101 -0
- package/dist/composables/use-idle.d.ts +102 -0
- package/dist/composables/use-idle.js +182 -0
- package/dist/composables/use-intersection-observer.d.ts +83 -0
- package/dist/composables/use-intersection-observer.js +168 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-keyboard.js +224 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-media-query.js +62 -0
- package/dist/composables/use-meta.d.ts +35 -0
- package/dist/composables/use-meta.js +48 -0
- package/dist/composables/use-mouse.d.ts +65 -0
- package/dist/composables/use-mouse.js +286 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-mutation-observer.js +129 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-network.js +85 -0
- package/dist/composables/use-notification.d.ts +98 -0
- package/dist/composables/use-notification.js +94 -0
- package/dist/composables/use-permissions.d.ts +119 -0
- package/dist/composables/use-permissions.js +132 -0
- package/dist/composables/use-query.d.ts +48 -0
- package/dist/composables/use-query.js +0 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-resize-observer.js +157 -0
- package/dist/composables/use-router.d.ts +80 -0
- package/dist/composables/use-router.js +105 -0
- package/dist/composables/use-scroll-lock.d.ts +13 -0
- package/dist/composables/use-scroll-lock.js +55 -0
- package/dist/composables/use-share.d.ts +74 -0
- package/dist/composables/use-share.js +104 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-speech.js +294 -0
- package/dist/composables/use-storage.d.ts +69 -0
- package/dist/composables/use-storage.js +196 -0
- package/dist/composables/use-text-selection.d.ts +121 -0
- package/dist/composables/use-text-selection.js +205 -0
- package/dist/composables/use-timer.d.ts +92 -0
- package/dist/composables/use-timer.js +193 -0
- package/dist/composables/use-utilities.d.ts +103 -0
- package/dist/composables/use-utilities.js +176 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-wake-lock.js +122 -0
- package/dist/composables/use-websocket.d.ts +70 -0
- package/dist/composables/use-websocket.js +165 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables/use-window.js +163 -0
- package/dist/composables.d.ts +287 -0
- package/dist/composables.js +562 -0
- package/dist/composition-api.d.ts +197 -0
- package/dist/composition-api.js +199 -0
- package/dist/compression.d.ts +30 -0
- package/dist/compression.js +107 -0
- package/dist/computed.d.ts +138 -0
- package/dist/computed.js +382 -0
- package/dist/conditionals.d.ts +48 -0
- package/dist/conditionals.js +626 -0
- package/dist/config.d.ts +77 -0
- package/dist/config.js +828 -0
- package/dist/cookie-serialize.d.ts +40 -0
- package/dist/cookie-serialize.js +18 -0
- package/dist/craft-bridge.d.ts +525 -0
- package/dist/craft-bridge.js +511 -0
- package/dist/craft-compiler.d.ts +245 -0
- package/dist/craft-compiler.js +810 -0
- package/dist/craft-components.d.ts +739 -0
- package/dist/craft-components.js +1074 -0
- package/dist/craft-entry.d.ts +6 -0
- package/dist/craft-entry.js +9 -0
- package/dist/craft-ssr.d.ts +147 -0
- package/dist/craft-ssr.js +559 -0
- package/dist/craft.js +9 -0
- package/dist/csp.d.ts +295 -0
- package/dist/csp.js +220 -0
- package/dist/csrf.d.ts +38 -0
- package/dist/csrf.js +38 -0
- package/dist/custom-directives.d.ts +5 -0
- package/dist/custom-directives.js +136 -0
- package/dist/database.d.ts +391 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +28 -0
- package/dist/defer.js +156 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/config-generators.js +214 -0
- package/dist/deploy/index.d.ts +88 -0
- package/dist/deploy/index.js +203 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/deploy/netlify.js +167 -0
- package/dist/desktop.d.ts +16 -0
- package/dist/desktop.js +1 -0
- package/dist/dev-server/index.d.ts +22 -0
- package/dist/dev-server/index.js +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/keyboard-shortcuts.js +81 -0
- package/dist/dev-server/native-window.d.ts +59 -0
- package/dist/dev-server/native-window.js +91 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/port-utils.js +40 -0
- package/dist/dev-server/serve-app.d.ts +15 -0
- package/dist/dev-server/serve-app.js +727 -0
- package/dist/dev-server/serve-file.d.ts +3 -0
- package/dist/dev-server/serve-file.js +443 -0
- package/dist/dev-server/serve-markdown.d.ts +3 -0
- package/dist/dev-server/serve-markdown.js +284 -0
- package/dist/dev-server/serve-multi.d.ts +5 -0
- package/dist/dev-server/serve-multi.js +596 -0
- package/dist/dev-server/terminal-colors.d.ts +56 -0
- package/dist/dev-server/terminal-colors.js +45 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/theme-selector.js +111 -0
- package/dist/dev-server/ts-css.d.ts +108 -0
- package/dist/dev-server/ts-css.js +438 -0
- package/dist/dev-server/types.d.ts +99 -0
- package/dist/dev-server/types.js +43 -0
- package/dist/dev-server.d.ts +6 -0
- package/dist/dev-server.js +4 -0
- package/dist/devtools.d.ts +182 -0
- package/dist/devtools.js +593 -0
- package/dist/directive-api.d.ts +154 -0
- package/dist/directive-api.js +355 -0
- package/dist/docs.d.ts +56 -0
- package/dist/docs.js +567 -0
- package/dist/doctor.d.ts +29 -0
- package/dist/doctor.js +123 -0
- package/dist/document-shell.d.ts +218 -0
- package/dist/document-shell.js +338 -0
- package/dist/dynamic-components.d.ts +23 -0
- package/dist/dynamic-components.js +197 -0
- package/dist/edge-runtime.d.ts +193 -0
- package/dist/edge-runtime.js +525 -0
- package/dist/env.d.ts +3 -0
- package/dist/env.js +9 -0
- package/dist/error-boundaries.d.ts +78 -0
- package/dist/error-boundaries.js +281 -0
- package/dist/error-handling.d.ts +14 -0
- package/dist/error-handling.js +1 -0
- package/dist/errors/codes.d.ts +92 -0
- package/dist/errors/codes.js +97 -0
- package/dist/errors/formatter.d.ts +84 -0
- package/dist/errors/formatter.js +196 -0
- package/dist/errors/index.d.ts +12 -0
- package/dist/errors/index.js +44 -0
- package/dist/errors/logger.d.ts +135 -0
- package/dist/errors/logger.js +250 -0
- package/dist/errors/sanitizer.d.ts +73 -0
- package/dist/errors/sanitizer.js +181 -0
- package/dist/errors/types.d.ts +92 -0
- package/dist/errors/types.js +86 -0
- package/dist/events.d.ts +145 -0
- package/dist/events.js +396 -0
- package/dist/expressions.d.ts +180 -0
- package/dist/expressions.js +719 -0
- package/dist/find-body-tag.d.ts +50 -0
- package/dist/find-body-tag.js +57 -0
- package/dist/formatter.d.ts +19 -0
- package/dist/formatter.js +265 -0
- package/dist/forms-validation.d.ts +189 -0
- package/dist/forms-validation.js +421 -0
- package/dist/forms.d.ts +224 -0
- package/dist/forms.js +729 -0
- package/dist/fragment-container.d.ts +57 -0
- package/dist/fragment-container.js +123 -0
- package/dist/framework-composables.d.ts +73 -0
- package/dist/framework-composables.js +126 -0
- package/dist/head-injection.d.ts +61 -0
- package/dist/head-injection.js +28 -0
- package/dist/head.d.ts +282 -0
- package/dist/head.js +231 -0
- package/dist/heatmap.d.ts +206 -0
- package/dist/heatmap.js +566 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hot-reload.js +373 -0
- package/dist/html-masking.d.ts +125 -0
- package/dist/html-masking.js +196 -0
- package/dist/hydration-runtime.d.ts +44 -0
- package/dist/hydration-runtime.js +195 -0
- package/dist/hydration.d.ts +135 -0
- package/dist/hydration.js +654 -0
- package/dist/i18n.d.ts +342 -0
- package/dist/i18n.js +678 -0
- package/dist/image-optimization/auto-sibling.d.ts +42 -0
- package/dist/image-optimization/auto-sibling.js +88 -0
- package/dist/image-optimization/build-plugin.d.ts +54 -0
- package/dist/image-optimization/build-plugin.js +241 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/component.js +244 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/directive.js +203 -0
- package/dist/image-optimization/index.d.ts +156 -0
- package/dist/image-optimization/index.js +54 -0
- package/dist/image-optimization/processor.d.ts +140 -0
- package/dist/image-optimization/processor.js +262 -0
- package/dist/image-optimization/serve.d.ts +54 -0
- package/dist/image-optimization/serve.js +102 -0
- package/dist/import-rebase.d.ts +16 -0
- package/dist/import-rebase.js +16 -0
- package/dist/imported-signals.d.ts +43 -0
- package/dist/imported-signals.js +35 -0
- package/dist/includes.d.ts +171 -0
- package/dist/includes.js +764 -0
- package/dist/index.d.ts +365 -0
- package/dist/index.js +202 -0
- package/dist/init.d.ts +39 -0
- package/dist/init.js +505 -0
- package/dist/inline-assets.d.ts +28 -0
- package/dist/inline-assets.js +82 -0
- package/dist/interactive.d.ts +14 -0
- package/dist/interactive.js +383 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/internal-markdown.js +141 -0
- package/dist/island-chunking.d.ts +48 -0
- package/dist/island-chunking.js +52 -0
- package/dist/isolated-build.d.ts +12 -0
- package/dist/isolated-build.js +18 -0
- package/dist/js-ts.d.ts +10 -0
- package/dist/js-ts.js +60 -0
- package/dist/jsx-runtime.d.ts +92 -0
- package/dist/jsx-runtime.js +289 -0
- package/dist/keep-alive.d.ts +108 -0
- package/dist/keep-alive.js +421 -0
- package/dist/layout-types.d.ts +45 -0
- package/dist/layout-types.js +56 -0
- package/dist/lazy-loader.d.ts +90 -0
- package/dist/lazy-loader.js +245 -0
- package/dist/lazy-module.d.ts +11 -0
- package/dist/lazy-module.js +18 -0
- package/dist/loading-indicator.d.ts +50 -0
- package/dist/loading-indicator.js +322 -0
- package/dist/loops.d.ts +91 -0
- package/dist/loops.js +690 -0
- package/dist/manifest.d.ts +41 -0
- package/dist/manifest.js +31 -0
- package/dist/markdown-view.d.ts +25 -0
- package/dist/markdown-view.js +39 -0
- package/dist/markdown.d.ts +10 -0
- package/dist/markdown.js +68 -0
- package/dist/media/client/blur-up.d.ts +66 -0
- package/dist/media/client/blur-up.js +217 -0
- package/dist/media/client/index.d.ts +93 -0
- package/dist/media/client/index.js +53 -0
- package/dist/media/client/lazy-load.d.ts +74 -0
- package/dist/media/client/lazy-load.js +283 -0
- package/dist/media/client/upload-handler.d.ts +80 -0
- package/dist/media/client/upload-handler.js +354 -0
- package/dist/media/image/component.d.ts +60 -0
- package/dist/media/image/component.js +574 -0
- package/dist/media/image/directive.d.ts +23 -0
- package/dist/media/image/directive.js +160 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/editing.js +193 -0
- package/dist/media/image/index.d.ts +142 -0
- package/dist/media/image/index.js +80 -0
- package/dist/media/image/placeholder.d.ts +89 -0
- package/dist/media/image/placeholder.js +188 -0
- package/dist/media/image/processor/cache.d.ts +53 -0
- package/dist/media/image/processor/cache.js +51 -0
- package/dist/media/image/processor/index.d.ts +11 -0
- package/dist/media/image/processor/index.js +3 -0
- package/dist/media/image/processor/optimizer.d.ts +24 -0
- package/dist/media/image/processor/optimizer.js +202 -0
- package/dist/media/image/processor/responsive.d.ts +28 -0
- package/dist/media/image/processor/responsive.js +162 -0
- package/dist/media/image/srcset.d.ts +157 -0
- package/dist/media/image/srcset.js +194 -0
- package/dist/media/index.d.ts +331 -0
- package/dist/media/index.js +198 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/manager/embed.js +253 -0
- package/dist/media/protected/component.d.ts +33 -0
- package/dist/media/protected/component.js +235 -0
- package/dist/media/protected/index.d.ts +47 -0
- package/dist/media/protected/index.js +20 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/protected/signature.js +205 -0
- package/dist/media/shared/cache.d.ts +76 -0
- package/dist/media/shared/cache.js +132 -0
- package/dist/media/shared/hash.d.ts +31 -0
- package/dist/media/shared/hash.js +35 -0
- package/dist/media/shared/index.d.ts +7 -0
- package/dist/media/shared/index.js +2 -0
- package/dist/media/types.d.ts +1477 -0
- package/dist/media/types.js +0 -0
- package/dist/media/upload/component.d.ts +9 -0
- package/dist/media/upload/component.js +320 -0
- package/dist/media/upload/index.d.ts +8 -0
- package/dist/media/upload/index.js +1 -0
- package/dist/media/video/directive.d.ts +23 -0
- package/dist/media/video/directive.js +142 -0
- package/dist/media/video/index.d.ts +76 -0
- package/dist/media/video/index.js +583 -0
- package/dist/media/video/processor/cache.d.ts +55 -0
- package/dist/media/video/processor/cache.js +52 -0
- package/dist/media/video/processor/index.d.ts +12 -0
- package/dist/media/video/processor/index.js +4 -0
- package/dist/media/video/processor/streaming.d.ts +26 -0
- package/dist/media/video/processor/streaming.js +197 -0
- package/dist/media/video/processor/thumbnail.d.ts +35 -0
- package/dist/media/video/processor/thumbnail.js +134 -0
- package/dist/media/video/processor/transcoder.d.ts +19 -0
- package/dist/media/video/processor/transcoder.js +283 -0
- package/dist/menubar.d.ts +65 -0
- package/dist/menubar.js +99 -0
- package/dist/method-spoofing.d.ts +20 -0
- package/dist/method-spoofing.js +17 -0
- package/dist/middleware.d.ts +112 -0
- package/dist/middleware.js +40 -0
- package/dist/misc-directives.d.ts +55 -0
- package/dist/misc-directives.js +328 -0
- package/dist/native-build.d.ts +88 -0
- package/dist/native-build.js +575 -0
- package/dist/owned-routes.d.ts +42 -0
- package/dist/owned-routes.js +26 -0
- package/dist/page-action.d.ts +73 -0
- package/dist/page-action.js +91 -0
- package/dist/page-meta.d.ts +38 -0
- package/dist/page-meta.js +16 -0
- package/dist/page-response.d.ts +120 -0
- package/dist/page-response.js +117 -0
- package/dist/parser/directive-parser.d.ts +119 -0
- package/dist/parser/directive-parser.js +249 -0
- package/dist/parser/expression-parser.d.ts +58 -0
- package/dist/parser/expression-parser.js +358 -0
- package/dist/parser/index.d.ts +13 -0
- package/dist/parser/index.js +23 -0
- package/dist/parser/tokenizer.d.ts +77 -0
- package/dist/parser/tokenizer.js +534 -0
- package/dist/partial-hydration.d.ts +123 -0
- package/dist/partial-hydration.js +427 -0
- package/dist/performance-utils.d.ts +318 -0
- package/dist/performance-utils.js +466 -0
- package/dist/placeholder.d.ts +54 -0
- package/dist/placeholder.js +35 -0
- package/dist/plugin-system.d.ts +301 -0
- package/dist/plugin-system.js +214 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.js +174 -0
- package/dist/precompiler.d.ts +43 -0
- package/dist/precompiler.js +670 -0
- package/dist/process.d.ts +16 -0
- package/dist/process.js +879 -0
- package/dist/production-build.d.ts +163 -0
- package/dist/production-build.js +596 -0
- package/dist/production-builder.d.ts +42 -0
- package/dist/production-builder.js +146 -0
- package/dist/production-server.d.ts +19 -0
- package/dist/production-server.js +208 -0
- package/dist/prop-sentinels.d.ts +31 -0
- package/dist/prop-sentinels.js +7 -0
- package/dist/props.d.ts +216 -0
- package/dist/props.js +224 -0
- package/dist/public-env.d.ts +29 -0
- package/dist/public-env.js +19 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/audit.js +255 -0
- package/dist/pwa/directives.d.ts +38 -0
- package/dist/pwa/directives.js +332 -0
- package/dist/pwa/icons.d.ts +42 -0
- package/dist/pwa/icons.js +109 -0
- package/dist/pwa/index.d.ts +104 -0
- package/dist/pwa/index.js +47 -0
- package/dist/pwa/inject.d.ts +32 -0
- package/dist/pwa/inject.js +102 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/manifest.js +186 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/offline.js +259 -0
- package/dist/pwa/precache.d.ts +35 -0
- package/dist/pwa/precache.js +116 -0
- package/dist/pwa/service-worker.d.ts +33 -0
- package/dist/pwa/service-worker.js +860 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox-strategies.js +167 -0
- package/dist/pwa/workbox.d.ts +51 -0
- package/dist/pwa/workbox.js +382 -0
- package/dist/pwa.d.ts +52 -0
- package/dist/pwa.js +236 -0
- package/dist/reactive-bindings.d.ts +47 -0
- package/dist/reactive-bindings.js +268 -0
- package/dist/reactive-tracking.d.ts +81 -0
- package/dist/reactive-tracking.js +49 -0
- package/dist/reactive.d.ts +117 -0
- package/dist/reactive.js +593 -0
- package/dist/reactivity.d.ts +206 -0
- package/dist/reactivity.js +574 -0
- package/dist/release.d.ts +1 -0
- package/dist/release.js +1 -0
- package/dist/render-memo.d.ts +40 -0
- package/dist/render-memo.js +33 -0
- package/dist/render.d.ts +54 -0
- package/dist/render.js +153 -0
- package/dist/resolve-stx-targets.d.ts +49 -0
- package/dist/resolve-stx-targets.js +38 -0
- package/dist/route-middleware.d.ts +2 -0
- package/dist/route-middleware.js +17 -0
- package/dist/route-types.d.ts +134 -0
- package/dist/route-types.js +24 -0
- package/dist/router.d.ts +9 -0
- package/dist/router.js +9 -0
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +14 -0
- package/dist/runtime-globals.d.ts +236 -0
- package/dist/runtime-globals.js +230 -0
- package/dist/runtime-injection.d.ts +113 -0
- package/dist/runtime-injection.js +156 -0
- package/dist/runtime.d.ts +140 -0
- package/dist/runtime.js +94 -0
- package/dist/safe-evaluator.d.ts +165 -0
- package/dist/safe-evaluator.js +461 -0
- package/dist/scaffolding.d.ts +113 -0
- package/dist/scaffolding.js +897 -0
- package/dist/screenshot.d.ts +22 -0
- package/dist/screenshot.js +100 -0
- package/dist/script-classifier.d.ts +41 -0
- package/dist/script-classifier.js +51 -0
- package/dist/script-emit.d.ts +50 -0
- package/dist/script-emit.js +11 -0
- package/dist/script-json.d.ts +36 -0
- package/dist/script-json.js +6 -0
- package/dist/script-validation.d.ts +26 -0
- package/dist/script-validation.js +179 -0
- package/dist/seo.d.ts +225 -0
- package/dist/seo.js +486 -0
- package/dist/serve.d.ts +44 -0
- package/dist/serve.js +233 -0
- package/dist/server-bindings.d.ts +39 -0
- package/dist/server-bindings.js +171 -0
- package/dist/server-components.d.ts +138 -0
- package/dist/server-components.js +427 -0
- package/dist/sfc-template.d.ts +17 -0
- package/dist/sfc-template.js +32 -0
- package/dist/signal-processing.d.ts +222 -0
- package/dist/signal-processing.js +1081 -0
- package/dist/signals-api.d.ts +459 -0
- package/dist/signals-api.js +172 -0
- package/dist/signals.d.ts +41 -0
- package/dist/signals.js +8233 -0
- package/dist/site-builder/build.d.ts +18 -0
- package/dist/site-builder/build.js +252 -0
- package/dist/site-builder/i18n.d.ts +104 -0
- package/dist/site-builder/i18n.js +150 -0
- package/dist/site-builder/index.d.ts +27 -0
- package/dist/site-builder/index.js +16 -0
- package/dist/site-builder/robots.d.ts +2 -0
- package/dist/site-builder/robots.js +26 -0
- package/dist/site-builder/router.d.ts +10 -0
- package/dist/site-builder/router.js +27 -0
- package/dist/site-builder/seo.d.ts +8 -0
- package/dist/site-builder/seo.js +67 -0
- package/dist/site-builder/sitemap.d.ts +10 -0
- package/dist/site-builder/sitemap.js +26 -0
- package/dist/site-builder/theme.d.ts +12 -0
- package/dist/site-builder/theme.js +38 -0
- package/dist/site-builder/types.d.ts +74 -0
- package/dist/site-builder/types.js +0 -0
- package/dist/site-url.d.ts +46 -0
- package/dist/site-url.js +70 -0
- package/dist/slots.d.ts +129 -0
- package/dist/slots.js +286 -0
- package/dist/source-maps.d.ts +98 -0
- package/dist/source-maps.js +350 -0
- package/dist/source-signature.d.ts +45 -0
- package/dist/source-signature.js +20 -0
- package/dist/spa-nav.d.ts +49 -0
- package/dist/spa-nav.js +12 -0
- package/dist/spa-shell.d.ts +21 -0
- package/dist/spa-shell.js +34 -0
- package/dist/ssg.d.ts +357 -0
- package/dist/ssg.js +94 -0
- package/dist/ssr.d.ts +116 -0
- package/dist/ssr.js +339 -0
- package/dist/state-dir.d.ts +36 -0
- package/dist/state-dir.js +22 -0
- package/dist/state-management.d.ts +299 -0
- package/dist/state-management.js +519 -0
- package/dist/store-imports.d.ts +47 -0
- package/dist/store-imports.js +16 -0
- package/dist/store-loader.d.ts +15 -0
- package/dist/store-loader.js +111 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/stores-client.js +132 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/addons.js +261 -0
- package/dist/story/analytics.d.ts +163 -0
- package/dist/story/analytics.js +235 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/auto-stories.js +158 -0
- package/dist/story/bookmarks.d.ts +102 -0
- package/dist/story/bookmarks.js +277 -0
- package/dist/story/bun-test.d.ts +45 -0
- package/dist/story/bun-test.js +102 -0
- package/dist/story/cli.d.ts +132 -0
- package/dist/story/cli.js +155 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/analyzer.js +305 -0
- package/dist/story/collect/index.d.ts +31 -0
- package/dist/story/collect/index.js +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/parser.js +129 -0
- package/dist/story/collect/scanner.d.ts +17 -0
- package/dist/story/collect/scanner.js +101 -0
- package/dist/story/collect/tree.d.ts +24 -0
- package/dist/story/collect/tree.js +110 -0
- package/dist/story/commands/build.d.ts +19 -0
- package/dist/story/commands/build.js +172 -0
- package/dist/story/commands/dev.d.ts +23 -0
- package/dist/story/commands/dev.js +78 -0
- package/dist/story/commands/index.d.ts +9 -0
- package/dist/story/commands/index.js +3 -0
- package/dist/story/commands/preview.d.ts +21 -0
- package/dist/story/commands/preview.js +56 -0
- package/dist/story/compiled-output.d.ts +27 -0
- package/dist/story/compiled-output.js +151 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/composition.js +261 -0
- package/dist/story/config-watcher.d.ts +33 -0
- package/dist/story/config-watcher.js +67 -0
- package/dist/story/config.d.ts +29 -0
- package/dist/story/config.js +64 -0
- package/dist/story/context.d.ts +27 -0
- package/dist/story/context.js +27 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/controls/index.js +320 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/desktop-preview.js +105 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/docs-generator.js +187 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/errors.js +239 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/figma-export.js +224 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/generator.js +165 -0
- package/dist/story/hmr.d.ts +62 -0
- package/dist/story/hmr.js +131 -0
- package/dist/story/hot-swap.d.ts +46 -0
- package/dist/story/hot-swap.js +207 -0
- package/dist/story/index.d.ts +99 -0
- package/dist/story/index.js +49 -0
- package/dist/story/interactions.d.ts +53 -0
- package/dist/story/interactions.js +225 -0
- package/dist/story/keyboard-shortcuts.d.ts +39 -0
- package/dist/story/keyboard-shortcuts.js +345 -0
- package/dist/story/output.d.ts +115 -0
- package/dist/story/output.js +153 -0
- package/dist/story/performance.d.ts +129 -0
- package/dist/story/performance.js +252 -0
- package/dist/story/presets.d.ts +123 -0
- package/dist/story/presets.js +289 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/props-validation.js +215 -0
- package/dist/story/renderer.d.ts +69 -0
- package/dist/story/renderer.js +209 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search-index.js +106 -0
- package/dist/story/search.d.ts +56 -0
- package/dist/story/search.js +140 -0
- package/dist/story/server.d.ts +31 -0
- package/dist/story/server.js +965 -0
- package/dist/story/setup.d.ts +56 -0
- package/dist/story/setup.js +78 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/snapshots.js +171 -0
- package/dist/story/testing.d.ts +83 -0
- package/dist/story/testing.js +164 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/theme.js +170 -0
- package/dist/story/ts-css.d.ts +29 -0
- package/dist/story/ts-css.js +189 -0
- package/dist/story/types.d.ts +342 -0
- package/dist/story/types.js +0 -0
- package/dist/story/ui/code-panel.d.ts +43 -0
- package/dist/story/ui/code-panel.js +175 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/controls-panel.js +168 -0
- package/dist/story/ui/index.d.ts +8 -0
- package/dist/story/ui/index.js +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/navigation.js +250 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/ui/preview.js +251 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/story/visual-testing.js +248 -0
- package/dist/streaming.d.ts +238 -0
- package/dist/streaming.js +537 -0
- package/dist/strict-lint.d.ts +52 -0
- package/dist/strict-lint.js +269 -0
- package/dist/strip-literals.d.ts +40 -0
- package/dist/strip-literals.js +149 -0
- package/dist/stx-virtual-ts.d.ts +358 -0
- package/dist/stx-virtual-ts.js +670 -0
- package/dist/stx.d.ts +924 -0
- package/dist/style-scoping.d.ts +42 -0
- package/dist/style-scoping.js +82 -0
- package/dist/suspense.d.ts +98 -0
- package/dist/suspense.js +398 -0
- package/dist/teleport.d.ts +31 -0
- package/dist/teleport.js +109 -0
- package/dist/template-compiler.d.ts +33 -0
- package/dist/template-compiler.js +68 -0
- package/dist/template-hydrator.d.ts +28 -0
- package/dist/template-hydrator.js +95 -0
- package/dist/template-tag-balance.d.ts +32 -0
- package/dist/template-tag-balance.js +93 -0
- package/dist/testing.d.ts +330 -0
- package/dist/testing.js +588 -0
- package/dist/theme-tokens.d.ts +88 -0
- package/dist/theme-tokens.js +71 -0
- package/dist/transitions.d.ts +99 -0
- package/dist/transitions.js +443 -0
- package/dist/ts-css-config.d.ts +71 -0
- package/dist/ts-css-config.js +44 -0
- package/dist/type-checker.d.ts +85 -0
- package/dist/type-checker.js +581 -0
- package/dist/typecheck.d.ts +70 -0
- package/dist/typecheck.js +365 -0
- package/dist/types/component-types.d.ts +248 -0
- package/dist/types/component-types.js +0 -0
- package/dist/types/config-types.d.ts +938 -0
- package/dist/types/config-types.js +0 -0
- package/dist/types/context-types.d.ts +122 -0
- package/dist/types/context-types.js +0 -0
- package/dist/types/csp-types.d.ts +83 -0
- package/dist/types/csp-types.js +0 -0
- package/dist/types/directive-types.d.ts +315 -0
- package/dist/types/directive-types.js +3 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +1 -0
- package/dist/types/pwa-types.d.ts +338 -0
- package/dist/types/pwa-types.js +0 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +1 -0
- package/dist/typescript-templates.d.ts +156 -0
- package/dist/typescript-templates.js +386 -0
- package/dist/unresolved-identifiers.d.ts +52 -0
- package/dist/unresolved-identifiers.js +148 -0
- package/dist/utils.d.ts +112 -0
- package/dist/utils.js +1170 -0
- package/dist/validator.d.ts +80 -0
- package/dist/validator.js +171 -0
- package/dist/variable-extractor.d.ts +142 -0
- package/dist/variable-extractor.js +1306 -0
- package/dist/view-composers.d.ts +171 -0
- package/dist/view-composers.js +29 -0
- package/dist/virtual-scrolling.d.ts +127 -0
- package/dist/virtual-scrolling.js +454 -0
- package/dist/visual-editor.d.ts +185 -0
- package/dist/visual-editor.js +735 -0
- package/dist/visual-testing.d.ts +135 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +39 -0
- package/dist/vue-template.js +476 -0
- package/dist/web-components/css-scoping.d.ts +64 -0
- package/dist/web-components/css-scoping.js +210 -0
- package/dist/web-components/index.d.ts +29 -0
- package/dist/web-components/index.js +13 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components/reactive-generator.js +484 -0
- package/dist/web-components.d.ts +253 -0
- package/dist/web-components.js +1466 -0
- package/dist/x-element.d.ts +42 -0
- package/dist/x-element.js +301 -0
- package/package.json +107 -0
- package/stx.d.ts +924 -0
package/dist/utils.js
ADDED
|
@@ -0,0 +1,1170 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { extractAndStripCssImports, extractBridgeData, injectBrowserCoreAutoImports, processClientScript, renderVendorStyleTags } from "./client-script.js";
|
|
4
|
+
import {
|
|
5
|
+
COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY,
|
|
6
|
+
componentClientFactoriesRegisteredSince,
|
|
7
|
+
registerComponentClientFactory,
|
|
8
|
+
replayComponentClientFactories,
|
|
9
|
+
snapshotComponentClientFactoryCounts
|
|
10
|
+
} from "./component-client-factories.js";
|
|
11
|
+
import { interpolateScriptExpressions, processExpressions, usesSignalsInScript } from "./expressions.js";
|
|
12
|
+
import { COMPONENT_SCOPE_LOCAL_GLOBALS, buildRuntimeGlobalsDestructure } from "./runtime-globals.js";
|
|
13
|
+
import { contentKey, depsUnchanged, renderMemo, snapshotDeps } from "./render-memo.js";
|
|
14
|
+
import { transformStoreImports } from "./store-imports.js";
|
|
15
|
+
import { LRUCache } from "./performance-utils.js";
|
|
16
|
+
import { processDirectives } from "./process.js";
|
|
17
|
+
import { getPublicEnvDefine } from "./public-env.js";
|
|
18
|
+
import { isUsableParamName } from "./safe-evaluator.js";
|
|
19
|
+
import { processScopedStyles } from "./style-scoping.js";
|
|
20
|
+
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
21
|
+
import { importOnce } from "./lazy-module.js";
|
|
22
|
+
import { stashScriptElements } from "./html-masking.js";
|
|
23
|
+
export {
|
|
24
|
+
extractDirectiveNames,
|
|
25
|
+
getPositionInfo,
|
|
26
|
+
hasDirectives,
|
|
27
|
+
validateDirective,
|
|
28
|
+
validateTemplate
|
|
29
|
+
} from "./validator.js";
|
|
30
|
+
export {
|
|
31
|
+
convertToCommonJS,
|
|
32
|
+
extractScriptFromTemplate,
|
|
33
|
+
extractVariables,
|
|
34
|
+
hasVariables
|
|
35
|
+
} from "./variable-extractor.js";
|
|
36
|
+
const componentsCache = new LRUCache(500), componentResolutionCache = new LRUCache(1000), COMPONENT_RENDER_CACHE_BYTES = 33554432;
|
|
37
|
+
let appliedComponentRenderCacheBytes = COMPONENT_RENDER_CACHE_BYTES;
|
|
38
|
+
function applyComponentRenderCacheBudget(options) {
|
|
39
|
+
const configured = options.componentRenderCacheBytes;
|
|
40
|
+
if (typeof configured !== "number" || configured < 0 || configured === appliedComponentRenderCacheBytes)
|
|
41
|
+
return;
|
|
42
|
+
appliedComponentRenderCacheBytes = configured;
|
|
43
|
+
componentRenderCache.setMaxBytes(configured);
|
|
44
|
+
}
|
|
45
|
+
const componentRenderCache = new LRUCache(2000, {
|
|
46
|
+
maxBytes: COMPONENT_RENDER_CACHE_BYTES,
|
|
47
|
+
sizeOf: (entry) => entry.output.length
|
|
48
|
+
});
|
|
49
|
+
let scopeIdCounter = 0;
|
|
50
|
+
function serializeComponentRenderInput(value) {
|
|
51
|
+
const seen = new WeakSet;
|
|
52
|
+
try {
|
|
53
|
+
const normalize = (input) => {
|
|
54
|
+
if (input === void 0)
|
|
55
|
+
return { __stxType: "undefined" };
|
|
56
|
+
if (typeof input === "bigint")
|
|
57
|
+
return { __stxType: "bigint", value: input.toString() };
|
|
58
|
+
if (typeof input === "function" || typeof input === "symbol")
|
|
59
|
+
throw TypeError("Non-serializable component input");
|
|
60
|
+
if (input === null || typeof input !== "object")
|
|
61
|
+
return input;
|
|
62
|
+
if (seen.has(input))
|
|
63
|
+
throw TypeError("Circular component input");
|
|
64
|
+
seen.add(input);
|
|
65
|
+
if (input instanceof Date)
|
|
66
|
+
return { __stxType: "date", value: input.toISOString() };
|
|
67
|
+
if (Array.isArray(input))
|
|
68
|
+
return input.map(normalize);
|
|
69
|
+
const normalized = {};
|
|
70
|
+
for (const key of Object.keys(input).sort())
|
|
71
|
+
normalized[key] = normalize(input[key]);
|
|
72
|
+
return normalized;
|
|
73
|
+
};
|
|
74
|
+
return JSON.stringify(normalize(value));
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function escapeAttr(str) {
|
|
80
|
+
return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
81
|
+
}
|
|
82
|
+
export function isJavaScriptScript(attrs) {
|
|
83
|
+
return /\bjs\b/.test(attrs) || /\blang\s*=\s*["']?(js|javascript)["']?/i.test(attrs);
|
|
84
|
+
}
|
|
85
|
+
export function shouldTranspileTypeScript(attrs) {
|
|
86
|
+
return !isJavaScriptScript(attrs);
|
|
87
|
+
}
|
|
88
|
+
const transpilerPool = new Map;
|
|
89
|
+
export function getSharedTranspiler(options) {
|
|
90
|
+
let key;
|
|
91
|
+
try {
|
|
92
|
+
key = JSON.stringify(options);
|
|
93
|
+
} catch {
|
|
94
|
+
return new Bun.Transpiler(options);
|
|
95
|
+
}
|
|
96
|
+
const pooled = transpilerPool.get(key);
|
|
97
|
+
if (pooled)
|
|
98
|
+
return pooled;
|
|
99
|
+
if (transpilerPool.size >= 16)
|
|
100
|
+
transpilerPool.clear();
|
|
101
|
+
const transpiler = new Bun.Transpiler(options);
|
|
102
|
+
transpilerPool.set(key, transpiler);
|
|
103
|
+
return transpiler;
|
|
104
|
+
}
|
|
105
|
+
const transpileResults = new WeakMap, TRANSPILE_RESULTS_MAX_ENTRIES = 256;
|
|
106
|
+
export function transpileTypeScript(code) {
|
|
107
|
+
try {
|
|
108
|
+
const transpiler = getSharedTranspiler({
|
|
109
|
+
loader: "ts",
|
|
110
|
+
target: "browser",
|
|
111
|
+
define: getPublicEnvDefine()
|
|
112
|
+
});
|
|
113
|
+
let results = transpileResults.get(transpiler);
|
|
114
|
+
if (!results) {
|
|
115
|
+
results = new Map;
|
|
116
|
+
transpileResults.set(transpiler, results);
|
|
117
|
+
}
|
|
118
|
+
const cached = results.get(code);
|
|
119
|
+
if (cached !== void 0)
|
|
120
|
+
return cached;
|
|
121
|
+
let processedCode = code.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
122
|
+
processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
123
|
+
const placeholders = [];
|
|
124
|
+
processedCode = processedCode.replace(/\{!![\s\S]*?!!\}/g, (match) => {
|
|
125
|
+
const idx = placeholders.length;
|
|
126
|
+
placeholders.push(match);
|
|
127
|
+
return `"__STX_EXPR_${idx}__"`;
|
|
128
|
+
});
|
|
129
|
+
processedCode = processedCode.replace(/\{\{\{[\s\S]*?\}\}\}/g, (match) => {
|
|
130
|
+
const idx = placeholders.length;
|
|
131
|
+
placeholders.push(match);
|
|
132
|
+
return `"__STX_EXPR_${idx}__"`;
|
|
133
|
+
});
|
|
134
|
+
processedCode = processedCode.replace(/\{\{[\s\S]*?\}\}/g, (match) => {
|
|
135
|
+
const idx = placeholders.length;
|
|
136
|
+
placeholders.push(match);
|
|
137
|
+
return `"__STX_EXPR_${idx}__"`;
|
|
138
|
+
});
|
|
139
|
+
let result = transpiler.transformSync(processedCode);
|
|
140
|
+
for (let i = 0;i < placeholders.length; i++) {
|
|
141
|
+
result = result.replace(`"__STX_EXPR_${i}__"`, placeholders[i]);
|
|
142
|
+
result = result.replace(`'__STX_EXPR_${i}__'`, placeholders[i]);
|
|
143
|
+
}
|
|
144
|
+
if (results.size >= TRANSPILE_RESULTS_MAX_ENTRIES) {
|
|
145
|
+
const oldest = results.keys().next();
|
|
146
|
+
if (!oldest.done)
|
|
147
|
+
results.delete(oldest.value);
|
|
148
|
+
}
|
|
149
|
+
results.set(code, result);
|
|
150
|
+
return result;
|
|
151
|
+
} catch (e) {
|
|
152
|
+
if (process.env.STX_DEBUG_TS)
|
|
153
|
+
console.warn("[STX] TypeScript transpilation error:", e);
|
|
154
|
+
return code;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function extractVariableNames(code) {
|
|
158
|
+
const names = [], seen = new Set;
|
|
159
|
+
let depth = 0, i = 0;
|
|
160
|
+
const len = code.length, skipString = (quote) => {
|
|
161
|
+
i++;
|
|
162
|
+
while (i < len) {
|
|
163
|
+
if (code[i] === "\\") {
|
|
164
|
+
i += 2;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (code[i] === quote) {
|
|
168
|
+
i++;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
i++;
|
|
172
|
+
}
|
|
173
|
+
}, skipTemplateLiteral = () => {
|
|
174
|
+
i++;
|
|
175
|
+
while (i < len) {
|
|
176
|
+
if (code[i] === "\\") {
|
|
177
|
+
i += 2;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (code[i] === "`") {
|
|
181
|
+
i++;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (code[i] === "$" && code[i + 1] === "{") {
|
|
185
|
+
i += 2;
|
|
186
|
+
let templateDepth = 1;
|
|
187
|
+
while (i < len && templateDepth > 0)
|
|
188
|
+
if (code[i] === "{") {
|
|
189
|
+
templateDepth++;
|
|
190
|
+
i++;
|
|
191
|
+
} else if (code[i] === "}") {
|
|
192
|
+
templateDepth--;
|
|
193
|
+
i++;
|
|
194
|
+
} else if (code[i] === "'" || code[i] === '"')
|
|
195
|
+
skipString(code[i]);
|
|
196
|
+
else if (code[i] === "`")
|
|
197
|
+
skipTemplateLiteral();
|
|
198
|
+
else
|
|
199
|
+
i++;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
i++;
|
|
203
|
+
}
|
|
204
|
+
}, skipComment = () => {
|
|
205
|
+
if (code[i] === "/" && code[i + 1] === "/") {
|
|
206
|
+
while (i < len && code[i] !== `
|
|
207
|
+
`)
|
|
208
|
+
i++;
|
|
209
|
+
return !0;
|
|
210
|
+
}
|
|
211
|
+
if (code[i] === "/" && code[i + 1] === "*") {
|
|
212
|
+
i += 2;
|
|
213
|
+
while (i < len - 1 && !(code[i] === "*" && code[i + 1] === "/"))
|
|
214
|
+
i++;
|
|
215
|
+
i += 2;
|
|
216
|
+
return !0;
|
|
217
|
+
}
|
|
218
|
+
return !1;
|
|
219
|
+
}, checkDeclaration = () => {
|
|
220
|
+
if (depth !== 0)
|
|
221
|
+
return;
|
|
222
|
+
const destructMatch = code.slice(i).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);
|
|
223
|
+
if (destructMatch) {
|
|
224
|
+
const vars = destructMatch[2].split(",").map((v) => {
|
|
225
|
+
const parts = v.trim().split(":");
|
|
226
|
+
return parts[parts.length - 1].trim();
|
|
227
|
+
});
|
|
228
|
+
for (const varName of vars)
|
|
229
|
+
if (varName && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(varName) && !seen.has(varName)) {
|
|
230
|
+
names.push(varName);
|
|
231
|
+
seen.add(varName);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const declMatch = code.slice(i).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);
|
|
236
|
+
if (declMatch) {
|
|
237
|
+
const varName = declMatch[2];
|
|
238
|
+
if (!seen.has(varName)) {
|
|
239
|
+
names.push(varName);
|
|
240
|
+
seen.add(varName);
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const funcMatch = code.slice(i).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
|
|
245
|
+
if (funcMatch) {
|
|
246
|
+
const funcName = funcMatch[1];
|
|
247
|
+
if (!seen.has(funcName)) {
|
|
248
|
+
names.push(funcName);
|
|
249
|
+
seen.add(funcName);
|
|
250
|
+
}
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const asyncMatch = code.slice(i).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
|
|
254
|
+
if (asyncMatch) {
|
|
255
|
+
const funcName = asyncMatch[1];
|
|
256
|
+
if (!seen.has(funcName)) {
|
|
257
|
+
names.push(funcName);
|
|
258
|
+
seen.add(funcName);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
while (i < len) {
|
|
263
|
+
if (skipComment())
|
|
264
|
+
continue;
|
|
265
|
+
if (code[i] === "'" || code[i] === '"') {
|
|
266
|
+
skipString(code[i]);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (code[i] === "`") {
|
|
270
|
+
skipTemplateLiteral();
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (code[i] === "{") {
|
|
274
|
+
depth++;
|
|
275
|
+
i++;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (code[i] === "}") {
|
|
279
|
+
depth--;
|
|
280
|
+
i++;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (depth === 0 && /[a-z]/i.test(code[i]) && (i === 0 || /\s|[;{}()]/.test(code[i - 1])))
|
|
284
|
+
checkDeclaration();
|
|
285
|
+
i++;
|
|
286
|
+
}
|
|
287
|
+
return names;
|
|
288
|
+
}
|
|
289
|
+
function splitTopLevelCommas(body) {
|
|
290
|
+
const parts = [];
|
|
291
|
+
let depth = 0, start = 0, quote = null;
|
|
292
|
+
for (let i = 0;i < body.length; i++) {
|
|
293
|
+
const c = body[i];
|
|
294
|
+
if (quote) {
|
|
295
|
+
if (c === "\\") {
|
|
296
|
+
i++;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (c === quote)
|
|
300
|
+
quote = null;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
304
|
+
quote = c;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (c === "(" || c === "[" || c === "{")
|
|
308
|
+
depth++;
|
|
309
|
+
else if (c === ")" || c === "]" || c === "}")
|
|
310
|
+
depth--;
|
|
311
|
+
else if (c === "," && depth === 0) {
|
|
312
|
+
parts.push(body.slice(start, i));
|
|
313
|
+
start = i + 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (start < body.length)
|
|
317
|
+
parts.push(body.slice(start));
|
|
318
|
+
return parts;
|
|
319
|
+
}
|
|
320
|
+
function topLevelDefaultEq(entry) {
|
|
321
|
+
let depth = 0, quote = null;
|
|
322
|
+
for (let i = 0;i < entry.length; i++) {
|
|
323
|
+
const c = entry[i];
|
|
324
|
+
if (quote) {
|
|
325
|
+
if (c === "\\") {
|
|
326
|
+
i++;
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (c === quote)
|
|
330
|
+
quote = null;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
334
|
+
quote = c;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (c === "(" || c === "[" || c === "{")
|
|
338
|
+
depth++;
|
|
339
|
+
else if (c === ")" || c === "]" || c === "}")
|
|
340
|
+
depth--;
|
|
341
|
+
else if (c === "=" && depth === 0) {
|
|
342
|
+
const prev = entry[i - 1], next = entry[i + 1];
|
|
343
|
+
if (prev === "!" || prev === "<" || prev === ">" || prev === "=")
|
|
344
|
+
continue;
|
|
345
|
+
if (next === "=" || next === ">")
|
|
346
|
+
continue;
|
|
347
|
+
return i;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return -1;
|
|
351
|
+
}
|
|
352
|
+
function applyDestructuredPropDefaults(componentContent, ctx) {
|
|
353
|
+
try {
|
|
354
|
+
const m = /=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(componentContent);
|
|
355
|
+
if (!m)
|
|
356
|
+
return;
|
|
357
|
+
let i = m.index - 1;
|
|
358
|
+
while (i >= 0 && /\s/.test(componentContent[i]))
|
|
359
|
+
i--;
|
|
360
|
+
if (componentContent[i] !== "}")
|
|
361
|
+
return;
|
|
362
|
+
const end = i;
|
|
363
|
+
let depth = 0, start = -1;
|
|
364
|
+
for (;i >= 0; i--) {
|
|
365
|
+
const c = componentContent[i];
|
|
366
|
+
if (c === "}")
|
|
367
|
+
depth++;
|
|
368
|
+
else if (c === "{") {
|
|
369
|
+
depth--;
|
|
370
|
+
if (depth === 0) {
|
|
371
|
+
start = i;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (start === -1)
|
|
377
|
+
return;
|
|
378
|
+
const body = componentContent.slice(start + 1, end);
|
|
379
|
+
for (const rawEntry of splitTopLevelCommas(body)) {
|
|
380
|
+
const entry = rawEntry.trim();
|
|
381
|
+
if (!entry || entry.startsWith("..."))
|
|
382
|
+
continue;
|
|
383
|
+
const eq = topLevelDefaultEq(entry);
|
|
384
|
+
if (eq === -1)
|
|
385
|
+
continue;
|
|
386
|
+
const name = entry.slice(0, eq).trim();
|
|
387
|
+
if (!/^[A-Z_$][\w$]*$/i.test(name))
|
|
388
|
+
continue;
|
|
389
|
+
if (ctx[name] !== void 0)
|
|
390
|
+
continue;
|
|
391
|
+
const expr = entry.slice(eq + 1).trim();
|
|
392
|
+
if (!expr)
|
|
393
|
+
continue;
|
|
394
|
+
try {
|
|
395
|
+
const keys = Object.keys(ctx).filter(isUsableParamName), fn = Function(...keys, `"use strict"; return (${expr});`);
|
|
396
|
+
ctx[name] = fn(...keys.map((k) => ctx[k]));
|
|
397
|
+
} catch {}
|
|
398
|
+
}
|
|
399
|
+
} catch {}
|
|
400
|
+
}
|
|
401
|
+
export async function userComponentFileExists(componentPath, componentsDir, parentContext, parentFilePath, options) {
|
|
402
|
+
const baseName = componentPath.endsWith(".stx") ? componentPath.slice(0, -4) : componentPath, kebabToPascal = (str) => str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(""), pascalToKebab = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), importedComponents = parentContext.__importedComponents;
|
|
403
|
+
if (importedComponents) {
|
|
404
|
+
for (const name of [baseName, baseName.toLowerCase(), kebabToPascal(baseName), pascalToKebab(baseName)])
|
|
405
|
+
if (importedComponents.has(name))
|
|
406
|
+
return !0;
|
|
407
|
+
}
|
|
408
|
+
const variants = [...new Set([`${baseName}.stx`, `${kebabToPascal(baseName)}.stx`, `${pascalToKebab(baseName)}.stx`])], configuredRoot = typeof options.root === "string" ? path.resolve(options.root) : void 0, resolveBase = configuredRoot ?? path.dirname(parentFilePath), searchDirs = [], push = (dir) => {
|
|
409
|
+
if (dir && !searchDirs.includes(dir))
|
|
410
|
+
searchDirs.push(dir);
|
|
411
|
+
}, originalFilePath = parentContext.__originalFilePath;
|
|
412
|
+
if (originalFilePath)
|
|
413
|
+
push(path.join(path.dirname(originalFilePath), "components"));
|
|
414
|
+
push(componentsDir);
|
|
415
|
+
push(options._rootComponentsDir);
|
|
416
|
+
push(path.join(path.dirname(parentFilePath), "components"));
|
|
417
|
+
push(options.componentsDir);
|
|
418
|
+
if (configuredRoot) {
|
|
419
|
+
push(path.resolve(configuredRoot, "resources/views/components"));
|
|
420
|
+
push(path.resolve(configuredRoot, "resources/components"));
|
|
421
|
+
push(path.resolve(configuredRoot, "src/components"));
|
|
422
|
+
push(path.resolve(configuredRoot, "components"));
|
|
423
|
+
}
|
|
424
|
+
const pluginDirs = options._pluginComponentDirs;
|
|
425
|
+
if (Array.isArray(pluginDirs))
|
|
426
|
+
for (const dir of pluginDirs)
|
|
427
|
+
push(typeof dir === "string" ? dir : null);
|
|
428
|
+
push(options.fallbackComponentsDir);
|
|
429
|
+
if (baseName.startsWith("./") || baseName.startsWith("../"))
|
|
430
|
+
return fileExists(path.resolve(path.dirname(parentFilePath), `${baseName}.stx`));
|
|
431
|
+
for (const dir of searchDirs) {
|
|
432
|
+
const resolvedDir = path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir);
|
|
433
|
+
for (const variant of variants)
|
|
434
|
+
if (await fileExists(path.join(resolvedDir, variant)))
|
|
435
|
+
return !0;
|
|
436
|
+
}
|
|
437
|
+
return !1;
|
|
438
|
+
}
|
|
439
|
+
export function isHydrateTrigger(trigger) {
|
|
440
|
+
return trigger === "visible" || trigger === "idle" || trigger === "interaction" || trigger.startsWith("media:");
|
|
441
|
+
}
|
|
442
|
+
export function slotContentHasExpressions(slotContent) {
|
|
443
|
+
if (!slotContent)
|
|
444
|
+
return !1;
|
|
445
|
+
const withoutScripts = slotContent.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "");
|
|
446
|
+
return /\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(withoutScripts);
|
|
447
|
+
}
|
|
448
|
+
export function componentClientSignalNames(scripts) {
|
|
449
|
+
const names = new Set, declaration = /\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useReactiveProp|useLocalStorage|useSessionStorage|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;
|
|
450
|
+
for (const script of scripts) {
|
|
451
|
+
let match;
|
|
452
|
+
while ((match = declaration.exec(script)) !== null)
|
|
453
|
+
names.add(match[1]);
|
|
454
|
+
declaration.lastIndex = 0;
|
|
455
|
+
}
|
|
456
|
+
return [...names];
|
|
457
|
+
}
|
|
458
|
+
export async function renderComponentWithSlot(componentPath, props, slotContent, componentsDir, parentContext, parentFilePath, options, processedComponents = new Set, dependencies) {
|
|
459
|
+
const { extractVariables } = await importOnce("stx/variable-extractor", () => import("./variable-extractor.js")), components = processedComponents ?? new Set;
|
|
460
|
+
if (components.has(componentPath))
|
|
461
|
+
return `[Circular component reference: ${componentPath}]`;
|
|
462
|
+
const branchComponents = new Set(components);
|
|
463
|
+
branchComponents.add(componentPath);
|
|
464
|
+
const clientAttr = typeof props.client === "string" ? props.client.trim() : "";
|
|
465
|
+
if ("client" in props)
|
|
466
|
+
delete props.client;
|
|
467
|
+
const hydrateTrigger = clientAttr && clientAttr !== "load" && isHydrateTrigger(clientAttr) ? clientAttr : "";
|
|
468
|
+
try {
|
|
469
|
+
const kebabToPascal = (str) => str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(""), pascalToKebab = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), baseName = componentPath.endsWith(".stx") ? componentPath.slice(0, -4) : componentPath;
|
|
470
|
+
let componentFilePath = null;
|
|
471
|
+
const importedComponents = parentContext.__importedComponents;
|
|
472
|
+
if (importedComponents) {
|
|
473
|
+
const namesToTry = [
|
|
474
|
+
baseName,
|
|
475
|
+
baseName.toLowerCase(),
|
|
476
|
+
kebabToPascal(baseName),
|
|
477
|
+
pascalToKebab(baseName)
|
|
478
|
+
];
|
|
479
|
+
for (const name of namesToTry)
|
|
480
|
+
if (importedComponents.has(name)) {
|
|
481
|
+
componentFilePath = importedComponents.get(name);
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
const triedPaths = [];
|
|
486
|
+
if (!componentFilePath) {
|
|
487
|
+
const fileVariants = [
|
|
488
|
+
`${baseName}.stx`,
|
|
489
|
+
`${kebabToPascal(baseName)}.stx`,
|
|
490
|
+
`${pascalToKebab(baseName)}.stx`
|
|
491
|
+
], uniqueVariants = [...new Set(fileVariants)], originalFilePath = parentContext.__originalFilePath, searchDirs = [];
|
|
492
|
+
if (originalFilePath) {
|
|
493
|
+
const originalDir = path.join(path.dirname(originalFilePath), "components");
|
|
494
|
+
searchDirs.push(originalDir);
|
|
495
|
+
}
|
|
496
|
+
if (componentsDir)
|
|
497
|
+
searchDirs.push(componentsDir);
|
|
498
|
+
const rootComponentsDir = options._rootComponentsDir;
|
|
499
|
+
if (typeof rootComponentsDir === "string" && !searchDirs.includes(rootComponentsDir))
|
|
500
|
+
searchDirs.push(rootComponentsDir);
|
|
501
|
+
const parentRelative = path.join(path.dirname(parentFilePath), "components");
|
|
502
|
+
if (!searchDirs.includes(parentRelative))
|
|
503
|
+
searchDirs.push(parentRelative);
|
|
504
|
+
if (options.componentsDir && options.componentsDir !== componentsDir && !searchDirs.includes(options.componentsDir))
|
|
505
|
+
searchDirs.push(options.componentsDir);
|
|
506
|
+
const configuredRoot = typeof options.root === "string" ? path.resolve(options.root) : void 0, resolveBase = configuredRoot ?? path.dirname(parentFilePath), fallbackDirs = [];
|
|
507
|
+
if (configuredRoot) {
|
|
508
|
+
fallbackDirs.push(path.resolve(configuredRoot, "resources/views/components"));
|
|
509
|
+
fallbackDirs.push(path.resolve(configuredRoot, "resources/components"));
|
|
510
|
+
fallbackDirs.push(path.resolve(configuredRoot, "src/components"));
|
|
511
|
+
fallbackDirs.push(path.resolve(configuredRoot, "components"));
|
|
512
|
+
}
|
|
513
|
+
fallbackDirs.push(path.resolve(import.meta.dir, "components"));
|
|
514
|
+
for (const fallback of fallbackDirs)
|
|
515
|
+
if (!searchDirs.includes(fallback))
|
|
516
|
+
searchDirs.push(fallback);
|
|
517
|
+
const pluginDirs = options._pluginComponentDirs;
|
|
518
|
+
if (Array.isArray(pluginDirs)) {
|
|
519
|
+
for (const dir of pluginDirs)
|
|
520
|
+
if (typeof dir === "string" && !searchDirs.includes(dir))
|
|
521
|
+
searchDirs.push(dir);
|
|
522
|
+
}
|
|
523
|
+
if (options.fallbackComponentsDir && !searchDirs.includes(options.fallbackComponentsDir))
|
|
524
|
+
searchDirs.push(options.fallbackComponentsDir);
|
|
525
|
+
const normalizedSearchDirs = [...new Set(searchDirs.map((dir) => {
|
|
526
|
+
if (!dir)
|
|
527
|
+
return dir;
|
|
528
|
+
return path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir);
|
|
529
|
+
}))];
|
|
530
|
+
searchDirs.length = 0;
|
|
531
|
+
searchDirs.push(...normalizedSearchDirs);
|
|
532
|
+
const resolutionCacheKey = `${baseName}\x00${parentFilePath}\x00${normalizedSearchDirs.join("\x00")}`, cachedResolution = componentResolutionCache.get(resolutionCacheKey);
|
|
533
|
+
if (cachedResolution)
|
|
534
|
+
if (await fileExists(cachedResolution))
|
|
535
|
+
componentFilePath = cachedResolution;
|
|
536
|
+
else
|
|
537
|
+
componentResolutionCache.delete(resolutionCacheKey);
|
|
538
|
+
if (!componentFilePath && (baseName.startsWith("./") || baseName.startsWith("../"))) {
|
|
539
|
+
componentFilePath = path.resolve(path.dirname(parentFilePath), `${baseName}.stx`);
|
|
540
|
+
triedPaths.push(componentFilePath);
|
|
541
|
+
} else if (!componentFilePath)
|
|
542
|
+
for (const dir of searchDirs) {
|
|
543
|
+
if (!dir)
|
|
544
|
+
continue;
|
|
545
|
+
for (const variant of uniqueVariants) {
|
|
546
|
+
const tryPath = path.join(dir, variant);
|
|
547
|
+
triedPaths.push(tryPath);
|
|
548
|
+
if (await fileExists(tryPath)) {
|
|
549
|
+
componentFilePath = tryPath;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (componentFilePath)
|
|
554
|
+
break;
|
|
555
|
+
if (!componentFilePath)
|
|
556
|
+
try {
|
|
557
|
+
const fs = await import("node:fs");
|
|
558
|
+
if (!fs.statSync(dir, { throwIfNoEntry: !1 })?.isDirectory())
|
|
559
|
+
continue;
|
|
560
|
+
const MAX_DEPTH = 8, stack = [{ path: dir, depth: 0 }];
|
|
561
|
+
while (stack.length > 0 && !componentFilePath) {
|
|
562
|
+
const current = stack.pop();
|
|
563
|
+
if (current.depth >= MAX_DEPTH)
|
|
564
|
+
continue;
|
|
565
|
+
let entries;
|
|
566
|
+
try {
|
|
567
|
+
entries = fs.readdirSync(current.path, { withFileTypes: !0 });
|
|
568
|
+
} catch {
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
for (const entry of entries) {
|
|
572
|
+
if (!entry.isDirectory())
|
|
573
|
+
continue;
|
|
574
|
+
if (entry.name === "node_modules" || entry.name.startsWith("."))
|
|
575
|
+
continue;
|
|
576
|
+
const subDir = path.join(current.path, entry.name);
|
|
577
|
+
for (const variant of uniqueVariants) {
|
|
578
|
+
const tryPath = path.join(subDir, variant);
|
|
579
|
+
triedPaths.push(tryPath);
|
|
580
|
+
if (await fileExists(tryPath)) {
|
|
581
|
+
componentFilePath = tryPath;
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (componentFilePath)
|
|
586
|
+
break;
|
|
587
|
+
stack.push({ path: subDir, depth: current.depth + 1 });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
} catch {}
|
|
591
|
+
if (componentFilePath)
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
if (componentFilePath)
|
|
595
|
+
componentResolutionCache.set(resolutionCacheKey, componentFilePath);
|
|
596
|
+
}
|
|
597
|
+
if (!componentFilePath || !await fileExists(componentFilePath)) {
|
|
598
|
+
const searchInfo = triedPaths.length > 0 ? `
|
|
599
|
+
Searched paths:
|
|
600
|
+
${triedPaths.map((p) => ` - ${p}`).join(`
|
|
601
|
+
`)}` : "";
|
|
602
|
+
return `[Error loading component: ENOENT: no such file or directory, open '${componentPath}']${searchInfo}`;
|
|
603
|
+
}
|
|
604
|
+
dependencies.add(componentFilePath);
|
|
605
|
+
let componentContent;
|
|
606
|
+
if (componentsCache.has(componentFilePath))
|
|
607
|
+
componentContent = componentsCache.get(componentFilePath);
|
|
608
|
+
else
|
|
609
|
+
try {
|
|
610
|
+
componentContent = await Bun.file(componentFilePath).text();
|
|
611
|
+
componentsCache.set(componentFilePath, componentContent);
|
|
612
|
+
} catch (error) {
|
|
613
|
+
return `[Error loading component: ${error instanceof Error ? error.message : String(error)}]`;
|
|
614
|
+
}
|
|
615
|
+
const internalKeysToPreserve = new Set([
|
|
616
|
+
"__originalFilePath",
|
|
617
|
+
"__importedComponents",
|
|
618
|
+
COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY,
|
|
619
|
+
"__stx_client_signal_names",
|
|
620
|
+
"__stxServeContext",
|
|
621
|
+
"__stx_scope_seq"
|
|
622
|
+
]), filteredParentContext = {};
|
|
623
|
+
for (const [key, val] of Object.entries(parentContext))
|
|
624
|
+
if (!key.startsWith("__") || internalKeysToPreserve.has(key))
|
|
625
|
+
filteredParentContext[key] = val;
|
|
626
|
+
let callerSlotContent = slotContent;
|
|
627
|
+
if (slotContent.includes("@include")) {
|
|
628
|
+
const { processIncludes } = await importOnce("stx/includes", () => import("./includes.js"));
|
|
629
|
+
callerSlotContent = await processIncludes(slotContent, parentContext, parentFilePath, options, dependencies);
|
|
630
|
+
}
|
|
631
|
+
const stashedCallerScripts = stashScriptElements(callerSlotContent), callerClientScripts = [], componentSlotContent = stashedCallerScripts.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g, (_match, index) => {
|
|
632
|
+
const script = stashedCallerScripts.scripts[Number(index)] || "", attrs = script.match(/^<script\b([^>]*)>/i)?.[1] || "", type = attrs.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(), executable = !type || ["module", "text/javascript", "application/javascript"].includes(type);
|
|
633
|
+
if (!/\bserver\b/i.test(attrs) && executable) {
|
|
634
|
+
callerClientScripts.push(script);
|
|
635
|
+
return "";
|
|
636
|
+
}
|
|
637
|
+
return script;
|
|
638
|
+
}), { extractSlotContent } = await importOnce("stx/slots", () => import("./slots.js")), parsedSlotContent = extractSlotContent(componentSlotContent), $slots = {};
|
|
639
|
+
if (parsedSlotContent.defaultSlot?.trim())
|
|
640
|
+
$slots.default = parsedSlotContent.defaultSlot;
|
|
641
|
+
for (const [slotName, slotDef] of parsedSlotContent.namedSlots)
|
|
642
|
+
$slots[slotName] = slotDef.content;
|
|
643
|
+
const scopeSeq = parentContext.__stx_scope_seq ??= {
|
|
644
|
+
n: 0,
|
|
645
|
+
key: Bun.hash(String(parentContext.__filename ?? parentFilePath)).toString(36).slice(0, 6)
|
|
646
|
+
}, componentUid = `stx_${baseName.replace(/[^a-zA-Z0-9]/g, "_")}_${++scopeSeq.n}_${scopeSeq.key}`, componentContext = {
|
|
647
|
+
...filteredParentContext,
|
|
648
|
+
$uid: componentUid,
|
|
649
|
+
...props,
|
|
650
|
+
props,
|
|
651
|
+
slot: componentSlotContent,
|
|
652
|
+
$slots,
|
|
653
|
+
__processedComponents: branchComponents,
|
|
654
|
+
__sections: {},
|
|
655
|
+
__stx_signals_gate: usesSignalsInScript(componentContent) || slotContentHasExpressions(slotContent)
|
|
656
|
+
};
|
|
657
|
+
applyDestructuredPropDefaults(componentContent, componentContext);
|
|
658
|
+
let workingContent = componentContent;
|
|
659
|
+
const templateBlock = findSfcTemplateBlock(workingContent);
|
|
660
|
+
if (templateBlock)
|
|
661
|
+
workingContent = templateBlock.content.trim();
|
|
662
|
+
const scriptRegex = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi, scriptMatches = [...componentContent.matchAll(scriptRegex)], clientScripts = [], cacheableServerComponent = scriptMatches.some((match) => /\bserver\b/.test(match[1] || "") && /\bcache\b/.test(match[1] || ""));
|
|
663
|
+
let componentRenderCacheKey = null, dependencyBaseline = null, clientFactoryBaseline = null, uidBaseline = 0, preservedExpressionBaseline = null;
|
|
664
|
+
applyComponentRenderCacheBudget(options);
|
|
665
|
+
if (cacheableServerComponent && appliedComponentRenderCacheBytes > 0) {
|
|
666
|
+
const serializedInput = serializeComponentRenderInput({
|
|
667
|
+
props,
|
|
668
|
+
slot: slotContent,
|
|
669
|
+
buildMode: options.buildMode ?? "",
|
|
670
|
+
skipEventDirectives: options.skipEventDirectives === !0,
|
|
671
|
+
uid: componentUid
|
|
672
|
+
});
|
|
673
|
+
if (serializedInput !== null) {
|
|
674
|
+
componentRenderCacheKey = `${componentFilePath}\x00${contentKey(componentContent)}\x00${serializedInput}`;
|
|
675
|
+
const cachedRender = componentRenderCache.get(componentRenderCacheKey);
|
|
676
|
+
if (cachedRender) {
|
|
677
|
+
for (const dependency of cachedRender.dependencies)
|
|
678
|
+
dependencies.add(dependency);
|
|
679
|
+
replayComponentClientFactories(parentContext, cachedRender.clientFactories);
|
|
680
|
+
scopeSeq.n += cachedRender.uidsConsumed;
|
|
681
|
+
if (cachedRender.preservedClientExpressions.length > 0) {
|
|
682
|
+
const preserved = new Set(Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : []);
|
|
683
|
+
for (const expression of cachedRender.preservedClientExpressions)
|
|
684
|
+
preserved.add(expression);
|
|
685
|
+
parentContext.__stx_preserved_client_expressions = [...preserved];
|
|
686
|
+
}
|
|
687
|
+
return cachedRender.output;
|
|
688
|
+
}
|
|
689
|
+
dependencyBaseline = new Set(dependencies);
|
|
690
|
+
clientFactoryBaseline = snapshotComponentClientFactoryCounts(parentContext);
|
|
691
|
+
uidBaseline = scopeSeq.n;
|
|
692
|
+
preservedExpressionBaseline = new Set(Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : []);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
for (const match of scriptMatches) {
|
|
696
|
+
const attrs = match[1] || "";
|
|
697
|
+
let content = match[2] || "";
|
|
698
|
+
const isServerScript = attrs.includes("server");
|
|
699
|
+
if (shouldTranspileTypeScript(attrs) && content.trim())
|
|
700
|
+
content = transpileTypeScript(content);
|
|
701
|
+
if (isServerScript && content)
|
|
702
|
+
try {
|
|
703
|
+
await extractVariables(content, componentContext, componentFilePath);
|
|
704
|
+
} catch (e) {}
|
|
705
|
+
if (!isServerScript) {
|
|
706
|
+
let cleanContent = content.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm, "");
|
|
707
|
+
const hasMustache = cleanContent.includes("{{") && cleanContent.includes("}}"), hasRawMarker = cleanContent.includes("{!!") && cleanContent.includes("!!}");
|
|
708
|
+
if (hasMustache || hasRawMarker)
|
|
709
|
+
cleanContent = interpolateScriptExpressions(cleanContent, componentContext);
|
|
710
|
+
const cleanAttrs = attrs.replace(/\s*\bts\b/g, "").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi, "");
|
|
711
|
+
clientScripts.push(`<script${cleanAttrs}>${cleanContent}</script>`);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const styleMatch = componentContent.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i), styleAttrs = styleMatch ? styleMatch[1] : "", styleContent = styleMatch ? styleMatch[2] : "";
|
|
715
|
+
let preservedStyle = "";
|
|
716
|
+
const hasScopedStyle = styleAttrs && /\bscoped\b/i.test(styleAttrs);
|
|
717
|
+
if (styleMatch)
|
|
718
|
+
preservedStyle = `<style${styleAttrs}>${styleContent}</style>`;
|
|
719
|
+
let templateContent = workingContent;
|
|
720
|
+
templateContent = templateContent.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "");
|
|
721
|
+
if (styleMatch)
|
|
722
|
+
templateContent = templateContent.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "");
|
|
723
|
+
{
|
|
724
|
+
const pushStyleRe = /@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi, collectedStyles = [];
|
|
725
|
+
templateContent = templateContent.replace(pushStyleRe, (_full, inner) => {
|
|
726
|
+
const styleInPush = inner.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);
|
|
727
|
+
if (styleInPush)
|
|
728
|
+
collectedStyles.push(`<style${styleInPush[1]}>${styleInPush[2]}</style>`);
|
|
729
|
+
return "";
|
|
730
|
+
});
|
|
731
|
+
templateContent = templateContent.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi, "");
|
|
732
|
+
if (collectedStyles.length > 0)
|
|
733
|
+
preservedStyle = `${preservedStyle}${collectedStyles.join(`
|
|
734
|
+
`)}`;
|
|
735
|
+
}
|
|
736
|
+
if (slotContent && templateContent.includes("{{ text || slot }}"))
|
|
737
|
+
templateContent = templateContent.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g, () => slotContent);
|
|
738
|
+
const { applySlots } = await importOnce("stx/slots", () => import("./slots.js")), { defaultSlot, namedSlots } = parsedSlotContent;
|
|
739
|
+
templateContent = await applySlots(templateContent, defaultSlot, namedSlots, componentContext);
|
|
740
|
+
const hasSignalScripts = clientScripts.some((s) => /\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(s)), clientSignalNames = componentClientSignalNames(clientScripts), inheritedClientSignalNames = Array.isArray(componentContext.__stx_client_signal_names) ? componentContext.__stx_client_signal_names : [];
|
|
741
|
+
if (clientSignalNames.length > 0 || inheritedClientSignalNames.length > 0)
|
|
742
|
+
componentContext.__stx_client_signal_names = [...new Set([...inheritedClientSignalNames, ...clientSignalNames])];
|
|
743
|
+
const componentOptions = {
|
|
744
|
+
...options,
|
|
745
|
+
_rootComponentsDir: options._rootComponentsDir || options.componentsDir,
|
|
746
|
+
componentsDir: path.dirname(componentFilePath),
|
|
747
|
+
skipSignalsRuntime: !0,
|
|
748
|
+
skipEventDirectives: hasSignalScripts || clientScripts.length === 0,
|
|
749
|
+
defaultLayout: void 0
|
|
750
|
+
};
|
|
751
|
+
componentContext.__stxProcessingDepth = (parentContext.__stxProcessingDepth || 0) + 1;
|
|
752
|
+
const result = await processDirectives(templateContent, componentContext, componentFilePath, componentOptions, dependencies), preservedExpressions = new Set(Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : []);
|
|
753
|
+
for (const match of result.matchAll(/\{\{([\s\S]*?)\}\}/g))
|
|
754
|
+
preservedExpressions.add(match[1].trim());
|
|
755
|
+
if (preservedExpressions.size > 0)
|
|
756
|
+
parentContext.__stx_preserved_client_expressions = [...preservedExpressions];
|
|
757
|
+
const scopeId = componentUid;
|
|
758
|
+
let output = result;
|
|
759
|
+
if (hasSignalScripts) {
|
|
760
|
+
let propsJson = "";
|
|
761
|
+
if (Object.keys(props).length > 0)
|
|
762
|
+
try {
|
|
763
|
+
propsJson = ` data-stx-props="${escapeAttr(JSON.stringify(props))}"`;
|
|
764
|
+
} catch {}
|
|
765
|
+
const hydrateJson = hydrateTrigger ? ` stx-hydrate="${escapeAttr(hydrateTrigger)}"` : "";
|
|
766
|
+
output = `<div data-stx-scope="${scopeId}"${propsJson}${hydrateJson}>${result}</div>`;
|
|
767
|
+
const scopedScripts = await Promise.all(clientScripts.map(async (script) => {
|
|
768
|
+
const scriptMatch = script.match(/<script([^>]*)>([\s\S]*)<\/script>/i);
|
|
769
|
+
if (!scriptMatch)
|
|
770
|
+
return script;
|
|
771
|
+
const [, attrs, rawContent] = scriptMatch, { vendorStyleTags, factoryBody } = await buildComponentIsland(rawContent, componentFilePath, options.buildMode === "compile"), factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
|
|
772
|
+
if (hydrateTrigger)
|
|
773
|
+
return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped${attrs}>${wrappedContent}</script>`;
|
|
774
|
+
return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always"${attrs}>${wrappedContent}</script>`;
|
|
775
|
+
}));
|
|
776
|
+
output = output + `
|
|
777
|
+
` + scopedScripts.join(`
|
|
778
|
+
`);
|
|
779
|
+
if (preservedStyle)
|
|
780
|
+
output += `
|
|
781
|
+
` + preservedStyle;
|
|
782
|
+
} else {
|
|
783
|
+
if (preservedStyle)
|
|
784
|
+
output += `
|
|
785
|
+
` + preservedStyle;
|
|
786
|
+
if (clientScripts.length > 0) {
|
|
787
|
+
const eventBindings = componentContext.__stx_event_bindings || [], serverData = extractBridgeData(componentContext), transformedScripts = await Promise.all(clientScripts.map(async (fullScript) => {
|
|
788
|
+
const contentMatch = fullScript.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);
|
|
789
|
+
if (!contentMatch)
|
|
790
|
+
return fullScript;
|
|
791
|
+
return await processClientScript(contentMatch[1], { eventBindings, templateContent: output, filePath: componentFilePath, projectRoot: process.cwd(), serverData });
|
|
792
|
+
}));
|
|
793
|
+
output += `
|
|
794
|
+
` + transformedScripts.join(`
|
|
795
|
+
`);
|
|
796
|
+
componentContext.__stx_event_bindings = [];
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
if (hasScopedStyle) {
|
|
800
|
+
const scopedStyleResult = processScopedStyles(output, componentFilePath);
|
|
801
|
+
if (scopedStyleResult.hasScoped)
|
|
802
|
+
output = scopedStyleResult.html;
|
|
803
|
+
}
|
|
804
|
+
if (componentRenderCacheKey && dependencyBaseline) {
|
|
805
|
+
const preservedNow = Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : [];
|
|
806
|
+
componentRenderCache.set(componentRenderCacheKey, {
|
|
807
|
+
output,
|
|
808
|
+
dependencies: [...dependencies].filter((dependency) => !dependencyBaseline.has(dependency)),
|
|
809
|
+
clientFactories: clientFactoryBaseline ? componentClientFactoriesRegisteredSince(parentContext, clientFactoryBaseline) : [],
|
|
810
|
+
uidsConsumed: scopeSeq.n - uidBaseline,
|
|
811
|
+
preservedClientExpressions: preservedExpressionBaseline ? preservedNow.filter((expression) => !preservedExpressionBaseline.has(expression)) : []
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
return callerClientScripts.length > 0 ? `${output}
|
|
815
|
+
${callerClientScripts.join(`
|
|
816
|
+
`)}` : output;
|
|
817
|
+
} catch (error) {
|
|
818
|
+
return `[Error processing component: ${error instanceof Error ? error.message : String(error)}]`;
|
|
819
|
+
} finally {
|
|
820
|
+
components.delete(componentPath);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
export async function fileExists(filePath) {
|
|
824
|
+
return Bun.file(filePath).exists();
|
|
825
|
+
}
|
|
826
|
+
function assertInsideRoot(resolvedAbsolute, root) {
|
|
827
|
+
const r = path.resolve(root), p = path.resolve(resolvedAbsolute), rWithSep = r.endsWith(path.sep) ? r : r + path.sep;
|
|
828
|
+
if (p === r || p.startsWith(rWithSep))
|
|
829
|
+
return p;
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
async function findLayoutIn(layoutsDir, templatePath, dependencies, debug) {
|
|
833
|
+
const stripped = templatePath.startsWith("layouts/") ? templatePath.slice(8) : templatePath, base = path.join(layoutsDir, stripped);
|
|
834
|
+
for (const candidate of base.endsWith(".stx") ? [base] : [base, `${base}.stx`])
|
|
835
|
+
if (await fileExists(candidate)) {
|
|
836
|
+
if (debug)
|
|
837
|
+
console.log(`Found layout in ${layoutsDir}: ${candidate}`);
|
|
838
|
+
dependencies?.add(candidate);
|
|
839
|
+
return candidate;
|
|
840
|
+
}
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
export async function resolveTemplatePath(templatePath, currentFilePath, options, dependencies) {
|
|
844
|
+
const result = await resolveTemplatePathInner(templatePath, currentFilePath, options, dependencies);
|
|
845
|
+
if (result === null)
|
|
846
|
+
return null;
|
|
847
|
+
const safeUnderCwd = assertInsideRoot(result, process.cwd());
|
|
848
|
+
if (safeUnderCwd)
|
|
849
|
+
return safeUnderCwd;
|
|
850
|
+
const trustedDirs = [options.root, options.layoutsDir, options.fallbackLayoutsDir, options.componentsDir, options.partialsDir, options.pagesDir].filter((d) => typeof d === "string" && d.length > 0);
|
|
851
|
+
for (const dir of trustedDirs) {
|
|
852
|
+
const resolvedDir = path.isAbsolute(dir) ? dir : path.resolve(process.cwd(), dir);
|
|
853
|
+
if (assertInsideRoot(result, resolvedDir))
|
|
854
|
+
return path.resolve(result);
|
|
855
|
+
}
|
|
856
|
+
console.warn(`[stx] rejected resolved template path that escapes project root: ${result} (template: ${templatePath}, from: ${currentFilePath})`);
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
async function resolveTemplatePathInner(templatePath, currentFilePath, options, dependencies) {
|
|
860
|
+
if (options.debug)
|
|
861
|
+
console.log(`Resolving template path: ${templatePath} from ${currentFilePath}`);
|
|
862
|
+
const dirPath = path.dirname(currentFilePath), projectRoot = process.cwd();
|
|
863
|
+
if (templatePath.startsWith("/")) {
|
|
864
|
+
const absolutePath = path.join(projectRoot, templatePath), safe = assertInsideRoot(absolutePath, projectRoot);
|
|
865
|
+
if (!safe) {
|
|
866
|
+
console.warn(`[stx] rejected template path that escapes project root: ${templatePath} (from ${currentFilePath})`);
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
if (options.debug)
|
|
870
|
+
console.log(`Checking absolute path: ${safe}`);
|
|
871
|
+
if (await fileExists(safe) && dependencies)
|
|
872
|
+
dependencies.add(safe);
|
|
873
|
+
return safe;
|
|
874
|
+
}
|
|
875
|
+
const directPath = path.join(dirPath, templatePath);
|
|
876
|
+
if (await fileExists(directPath)) {
|
|
877
|
+
if (options.debug)
|
|
878
|
+
console.log(`Found direct path: ${directPath}`);
|
|
879
|
+
if (dependencies)
|
|
880
|
+
dependencies.add(directPath);
|
|
881
|
+
return directPath;
|
|
882
|
+
}
|
|
883
|
+
if (!templatePath.endsWith(".stx") && !templatePath.endsWith(".jsx") && !templatePath.endsWith(".tsx"))
|
|
884
|
+
for (const ext of [".stx", ".tsx", ".jsx"]) {
|
|
885
|
+
const pathWithExt = `${directPath}${ext}`;
|
|
886
|
+
if (await fileExists(pathWithExt)) {
|
|
887
|
+
if (options.debug)
|
|
888
|
+
console.log(`Found direct path with extension: ${pathWithExt}`);
|
|
889
|
+
if (dependencies)
|
|
890
|
+
dependencies.add(pathWithExt);
|
|
891
|
+
return pathWithExt;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
const layoutSearchDirs = [];
|
|
895
|
+
if (options.layoutsDir)
|
|
896
|
+
layoutSearchDirs.push(path.isAbsolute(options.layoutsDir) ? options.layoutsDir : path.resolve(process.cwd(), options.layoutsDir));
|
|
897
|
+
let searchDir = path.resolve(dirPath);
|
|
898
|
+
const rootDir = process.cwd();
|
|
899
|
+
for (let i = 0;i < 10; i++) {
|
|
900
|
+
const candidate = path.join(searchDir, "layouts");
|
|
901
|
+
let candidateExists = !1;
|
|
902
|
+
try {
|
|
903
|
+
candidateExists = fs.statSync(candidate, { throwIfNoEntry: !1 })?.isDirectory() ?? !1;
|
|
904
|
+
} catch {}
|
|
905
|
+
if (candidateExists) {
|
|
906
|
+
layoutSearchDirs.push(candidate);
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
const parent = path.dirname(searchDir);
|
|
910
|
+
if (parent === searchDir || parent.length < rootDir.length)
|
|
911
|
+
break;
|
|
912
|
+
searchDir = parent;
|
|
913
|
+
}
|
|
914
|
+
for (const dir of layoutSearchDirs) {
|
|
915
|
+
const found = await findLayoutIn(dir, templatePath, dependencies, options.debug);
|
|
916
|
+
if (found)
|
|
917
|
+
return found;
|
|
918
|
+
}
|
|
919
|
+
if (options.fallbackLayoutsDir) {
|
|
920
|
+
const resolvedFallback = path.isAbsolute(options.fallbackLayoutsDir) ? options.fallbackLayoutsDir : path.resolve(process.cwd(), options.fallbackLayoutsDir), strippedPath = templatePath.startsWith("layouts/") ? templatePath.slice(8) : templatePath, candidates = [path.join(resolvedFallback, strippedPath)];
|
|
921
|
+
if (!templatePath.endsWith(".stx"))
|
|
922
|
+
candidates.push(`${candidates[0]}.stx`);
|
|
923
|
+
for (const candidate of candidates)
|
|
924
|
+
if (await fileExists(candidate)) {
|
|
925
|
+
if (options.debug)
|
|
926
|
+
console.log(`Found in options.fallbackLayoutsDir: ${candidate}`);
|
|
927
|
+
if (dependencies)
|
|
928
|
+
dependencies.add(candidate);
|
|
929
|
+
return candidate;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (templatePath.startsWith("layouts/") || templatePath.includes("/layouts/")) {
|
|
933
|
+
const parts = templatePath.split("layouts/"), layoutsPath = path.join(options.partialsDir || dirPath, "layouts", parts[1]);
|
|
934
|
+
if (await fileExists(layoutsPath)) {
|
|
935
|
+
if (options.debug)
|
|
936
|
+
console.log(`Found in layouts path: ${layoutsPath}`);
|
|
937
|
+
if (dependencies)
|
|
938
|
+
dependencies.add(layoutsPath);
|
|
939
|
+
return layoutsPath;
|
|
940
|
+
}
|
|
941
|
+
if (!layoutsPath.endsWith(".stx")) {
|
|
942
|
+
const layoutsPathWithExt = `${layoutsPath}.stx`;
|
|
943
|
+
if (await fileExists(layoutsPathWithExt)) {
|
|
944
|
+
if (options.debug)
|
|
945
|
+
console.log(`Found in layouts path with extension: ${layoutsPathWithExt}`);
|
|
946
|
+
if (dependencies)
|
|
947
|
+
dependencies.add(layoutsPathWithExt);
|
|
948
|
+
return layoutsPathWithExt;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
if (options.partialsDir) {
|
|
953
|
+
const partialsLayoutsDir = path.join(options.partialsDir, "layouts");
|
|
954
|
+
if (await fileExists(partialsLayoutsDir)) {
|
|
955
|
+
const fromPartialsLayouts = path.join(partialsLayoutsDir, templatePath);
|
|
956
|
+
if (await fileExists(fromPartialsLayouts)) {
|
|
957
|
+
if (options.debug)
|
|
958
|
+
console.log(`Found in partials layouts dir: ${fromPartialsLayouts}`);
|
|
959
|
+
if (dependencies)
|
|
960
|
+
dependencies.add(fromPartialsLayouts);
|
|
961
|
+
return fromPartialsLayouts;
|
|
962
|
+
}
|
|
963
|
+
if (!templatePath.endsWith(".stx")) {
|
|
964
|
+
const fromPartialsLayoutsWithExt = `${fromPartialsLayouts}.stx`;
|
|
965
|
+
if (await fileExists(fromPartialsLayoutsWithExt)) {
|
|
966
|
+
if (options.debug)
|
|
967
|
+
console.log(`Found in partials layouts dir with extension: ${fromPartialsLayoutsWithExt}`);
|
|
968
|
+
if (dependencies)
|
|
969
|
+
dependencies.add(fromPartialsLayoutsWithExt);
|
|
970
|
+
return fromPartialsLayoutsWithExt;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
const viewsPath = options.partialsDir || path.join(process.cwd(), "views"), fromRoot = path.join(viewsPath, templatePath);
|
|
976
|
+
if (await fileExists(fromRoot)) {
|
|
977
|
+
if (options.debug)
|
|
978
|
+
console.log(`Found in views path: ${fromRoot}`);
|
|
979
|
+
if (dependencies)
|
|
980
|
+
dependencies.add(fromRoot);
|
|
981
|
+
return fromRoot;
|
|
982
|
+
}
|
|
983
|
+
if (!templatePath.endsWith(".stx")) {
|
|
984
|
+
const fromRootWithExt = `${fromRoot}.stx`;
|
|
985
|
+
if (await fileExists(fromRootWithExt)) {
|
|
986
|
+
if (options.debug)
|
|
987
|
+
console.log(`Found in views path with extension: ${fromRootWithExt}`);
|
|
988
|
+
if (dependencies)
|
|
989
|
+
dependencies.add(fromRootWithExt);
|
|
990
|
+
return fromRootWithExt;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
if (dirPath.includes("temp")) {
|
|
994
|
+
const tempDirLayouts = path.join(path.dirname(dirPath), "layouts", templatePath);
|
|
995
|
+
if (await fileExists(tempDirLayouts)) {
|
|
996
|
+
if (options.debug)
|
|
997
|
+
console.log(`Found in temp layouts dir: ${tempDirLayouts}`);
|
|
998
|
+
if (dependencies)
|
|
999
|
+
dependencies.add(tempDirLayouts);
|
|
1000
|
+
return tempDirLayouts;
|
|
1001
|
+
}
|
|
1002
|
+
if (!templatePath.endsWith(".stx")) {
|
|
1003
|
+
const tempDirLayoutsWithExt = `${tempDirLayouts}.stx`;
|
|
1004
|
+
if (await fileExists(tempDirLayoutsWithExt)) {
|
|
1005
|
+
if (options.debug)
|
|
1006
|
+
console.log(`Found in temp layouts dir with extension: ${tempDirLayoutsWithExt}`);
|
|
1007
|
+
if (dependencies)
|
|
1008
|
+
dependencies.add(tempDirLayoutsWithExt);
|
|
1009
|
+
return tempDirLayoutsWithExt;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (options.debug)
|
|
1014
|
+
console.warn(`Template not found after trying all paths: ${templatePath} (referenced from ${currentFilePath})`);
|
|
1015
|
+
else
|
|
1016
|
+
console.warn(`Template not found: ${templatePath} (referenced from ${currentFilePath})`);
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
export function getSourceLineInfo(template, errorPosition, errorPattern) {
|
|
1020
|
+
let lineNumber = 0, lineContent = "", context = "";
|
|
1021
|
+
try {
|
|
1022
|
+
if (typeof errorPosition === "number" && errorPosition >= 0) {
|
|
1023
|
+
const lines = template.split(`
|
|
1024
|
+
`);
|
|
1025
|
+
let currentPos = 0;
|
|
1026
|
+
for (let i = 0;i < lines.length; i++) {
|
|
1027
|
+
currentPos += lines[i].length + 1;
|
|
1028
|
+
if (currentPos >= errorPosition) {
|
|
1029
|
+
lineNumber = i + 1;
|
|
1030
|
+
lineContent = lines[i].trim();
|
|
1031
|
+
const start = Math.max(0, i - 2), end = Math.min(lines.length, i + 3);
|
|
1032
|
+
context = lines.slice(start, end).map((line, idx) => {
|
|
1033
|
+
const contextLineNum = start + idx + 1;
|
|
1034
|
+
return `${contextLineNum === lineNumber ? "> " : " "}${contextLineNum}: ${line}`;
|
|
1035
|
+
}).join(`
|
|
1036
|
+
`);
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
} else if (errorPattern) {
|
|
1041
|
+
const patternPos = template.indexOf(errorPattern);
|
|
1042
|
+
if (patternPos >= 0)
|
|
1043
|
+
return getSourceLineInfo(template, patternPos);
|
|
1044
|
+
}
|
|
1045
|
+
} catch {}
|
|
1046
|
+
return { lineNumber, lineContent, context };
|
|
1047
|
+
}
|
|
1048
|
+
const colors = {
|
|
1049
|
+
reset: "\x1B[0m",
|
|
1050
|
+
bold: "\x1B[1m",
|
|
1051
|
+
dim: "\x1B[2m",
|
|
1052
|
+
red: "\x1B[31m",
|
|
1053
|
+
yellow: "\x1B[33m",
|
|
1054
|
+
blue: "\x1B[34m",
|
|
1055
|
+
cyan: "\x1B[36m",
|
|
1056
|
+
gray: "\x1B[90m",
|
|
1057
|
+
bgRed: "\x1B[41m",
|
|
1058
|
+
bgYellow: "\x1B[43m"
|
|
1059
|
+
};
|
|
1060
|
+
export function createDetailedErrorMessage(errorType, errorMessage, filePath, template, errorPosition, errorPattern) {
|
|
1061
|
+
const { lineNumber, context } = getSourceLineInfo(template, errorPosition, errorPattern), fileName = filePath.split("/").pop();
|
|
1062
|
+
let column = 0;
|
|
1063
|
+
if (typeof errorPosition === "number" && errorPosition >= 0 && template) {
|
|
1064
|
+
const lastNl = template.lastIndexOf(`
|
|
1065
|
+
`, Math.max(0, errorPosition - 1));
|
|
1066
|
+
column = errorPosition - (lastNl + 1) + 1;
|
|
1067
|
+
}
|
|
1068
|
+
let detailedMessage = "";
|
|
1069
|
+
if (lineNumber > 0)
|
|
1070
|
+
detailedMessage += `
|
|
1071
|
+
${filePath}:${lineNumber}${column > 0 ? `:${column}` : ""}: ${errorType.toLowerCase()} error: ${errorMessage}
|
|
1072
|
+
`;
|
|
1073
|
+
detailedMessage += `
|
|
1074
|
+
${colors.bold}${colors.red}\u256D\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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${colors.reset}
|
|
1075
|
+
`;
|
|
1076
|
+
detailedMessage += `${colors.bold}${colors.red}\u2502${colors.reset} ${colors.bold}${colors.bgRed} ERROR ${colors.reset} ${colors.red}${errorType} Error${colors.reset}${" ".repeat(Math.max(0, 43 - errorType.length))}${colors.bold}${colors.red}\u2502${colors.reset}
|
|
1077
|
+
`;
|
|
1078
|
+
detailedMessage += `${colors.bold}${colors.red}\u2570\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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${colors.reset}
|
|
1079
|
+
`;
|
|
1080
|
+
detailedMessage += `
|
|
1081
|
+
${colors.cyan}${colors.bold}File:${colors.reset} ${colors.dim}${fileName}${colors.reset}`;
|
|
1082
|
+
if (lineNumber > 0)
|
|
1083
|
+
detailedMessage += ` ${colors.gray}(line ${lineNumber}${column > 0 ? `, col ${column}` : ""})${colors.reset}`;
|
|
1084
|
+
detailedMessage += `
|
|
1085
|
+
${colors.yellow}${colors.bold}Message:${colors.reset} ${errorMessage}
|
|
1086
|
+
`;
|
|
1087
|
+
if (context)
|
|
1088
|
+
detailedMessage += `
|
|
1089
|
+
${colors.blue}${colors.bold}Context:${colors.reset}
|
|
1090
|
+
${colors.dim}${context}${colors.reset}
|
|
1091
|
+
`;
|
|
1092
|
+
return detailedMessage;
|
|
1093
|
+
}
|
|
1094
|
+
export function clearComponentCache() {
|
|
1095
|
+
componentsCache.clear();
|
|
1096
|
+
componentResolutionCache.clear();
|
|
1097
|
+
componentRenderCache.clear();
|
|
1098
|
+
}
|
|
1099
|
+
export function getComponentCacheStats() {
|
|
1100
|
+
return {
|
|
1101
|
+
size: componentsCache.size,
|
|
1102
|
+
maxSize: 500
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
const componentIslands = renderMemo(128);
|
|
1106
|
+
async function buildComponentIsland(rawContent, componentFilePath, minify) {
|
|
1107
|
+
const key = contentKey(rawContent, componentFilePath, minify), remembered = componentIslands.get(key);
|
|
1108
|
+
if (remembered) {
|
|
1109
|
+
if (depsUnchanged(remembered.deps))
|
|
1110
|
+
return remembered;
|
|
1111
|
+
componentIslands.delete(key);
|
|
1112
|
+
}
|
|
1113
|
+
const cssExtraction = extractAndStripCssImports(rawContent, {
|
|
1114
|
+
filePath: componentFilePath,
|
|
1115
|
+
projectRoot: process.cwd()
|
|
1116
|
+
});
|
|
1117
|
+
let bundledContent = cssExtraction.code;
|
|
1118
|
+
const vendorStyleTags = renderVendorStyleTags(cssExtraction.styles);
|
|
1119
|
+
bundledContent = injectBrowserCoreAutoImports(bundledContent).code;
|
|
1120
|
+
const { hasUserImports, bundleClientScript } = await importOnce("stx/client-script-bundler", () => import("./client-script-bundler.js")), bundleInputs = [];
|
|
1121
|
+
let bundleFellBack = !1;
|
|
1122
|
+
if (hasUserImports(bundledContent)) {
|
|
1123
|
+
const unbundled = bundledContent;
|
|
1124
|
+
bundledContent = await bundleClientScript(unbundled, componentFilePath, {
|
|
1125
|
+
projectRoot: process.cwd(),
|
|
1126
|
+
minify,
|
|
1127
|
+
collectInputs: bundleInputs
|
|
1128
|
+
});
|
|
1129
|
+
bundleFellBack = bundledContent === unbundled;
|
|
1130
|
+
}
|
|
1131
|
+
const { stripStxRuntimeImports } = await importOnce("stx/signal-processing", () => import("./signal-processing.js"));
|
|
1132
|
+
bundledContent = stripStxRuntimeImports(bundledContent);
|
|
1133
|
+
const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
|
|
1134
|
+
${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
|
|
1135
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1136
|
+
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
1137
|
+
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
1138
|
+
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
1139
|
+
window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
1140
|
+
|
|
1141
|
+
// Scope-specific lifecycle callbacks
|
|
1142
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
1143
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
1144
|
+
const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
|
|
1145
|
+
const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
|
|
1146
|
+
|
|
1147
|
+
try {
|
|
1148
|
+
${content}
|
|
1149
|
+
|
|
1150
|
+
// Register all defined signals and functions in this scope
|
|
1151
|
+
const __localVars = {};
|
|
1152
|
+
try {
|
|
1153
|
+
${componentLocalNames.map((v) => `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
|
|
1154
|
+
`)}
|
|
1155
|
+
}
|
|
1156
|
+
catch (e) {}
|
|
1157
|
+
Object.assign(__scopeVars, __localVars);
|
|
1158
|
+
}
|
|
1159
|
+
finally {
|
|
1160
|
+
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
1161
|
+
}
|
|
1162
|
+
}`, island = {
|
|
1163
|
+
vendorStyleTags,
|
|
1164
|
+
factoryBody,
|
|
1165
|
+
deps: snapshotDeps([...bundleInputs, ...cssExtraction.styles.map((style) => style.resolvedPath)])
|
|
1166
|
+
};
|
|
1167
|
+
if (!bundleFellBack && cssExtraction.unresolved.length === 0)
|
|
1168
|
+
componentIslands.set(key, island);
|
|
1169
|
+
return island;
|
|
1170
|
+
}
|