@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
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
var {require}=import.meta;import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { getSharedTranspiler } from "./utils.js";
|
|
4
|
+
export const STX_ENGINE_BINDING_NAMES = [
|
|
5
|
+
"module",
|
|
6
|
+
"exports",
|
|
7
|
+
"require",
|
|
8
|
+
"props",
|
|
9
|
+
"$props",
|
|
10
|
+
"defineProps",
|
|
11
|
+
"withDefaults",
|
|
12
|
+
"defineClientPayload",
|
|
13
|
+
"state",
|
|
14
|
+
"derived",
|
|
15
|
+
"effect",
|
|
16
|
+
"batch",
|
|
17
|
+
"onMount",
|
|
18
|
+
"onDestroy",
|
|
19
|
+
"definePageMeta",
|
|
20
|
+
"useRoute",
|
|
21
|
+
"useRouter",
|
|
22
|
+
"useHead",
|
|
23
|
+
"useSeoMeta",
|
|
24
|
+
"setResponseStatus",
|
|
25
|
+
"setResponseHeader",
|
|
26
|
+
"notFound",
|
|
27
|
+
"ref",
|
|
28
|
+
"reactive",
|
|
29
|
+
"computed",
|
|
30
|
+
"watch",
|
|
31
|
+
"onMounted",
|
|
32
|
+
"onUnmounted",
|
|
33
|
+
"nextTick",
|
|
34
|
+
"defineEmits",
|
|
35
|
+
"defineExpose",
|
|
36
|
+
"defineSlots",
|
|
37
|
+
"provide",
|
|
38
|
+
"inject",
|
|
39
|
+
"useColorMode",
|
|
40
|
+
"useDark",
|
|
41
|
+
"useMediaQuery",
|
|
42
|
+
"useScrollLock",
|
|
43
|
+
"usePreferredDark",
|
|
44
|
+
"usePreferredLight",
|
|
45
|
+
"usePreferredReducedMotion",
|
|
46
|
+
"usePreferredContrast",
|
|
47
|
+
"window",
|
|
48
|
+
"document",
|
|
49
|
+
"console",
|
|
50
|
+
"confirm",
|
|
51
|
+
"alert",
|
|
52
|
+
"fetch",
|
|
53
|
+
"params"
|
|
54
|
+
];
|
|
55
|
+
const ENGINE_BINDINGS = new Set(STX_ENGINE_BINDING_NAMES), CONTEXT_RESERVED_BINDINGS = new Set(["props", "$props", "defineProps"]), STX_RUNTIME_SPECIFIERS = new Set(["stx", "@stacksjs/stx"]);
|
|
56
|
+
import { findMatchingDelimiter } from "./parser/tokenizer.js";
|
|
57
|
+
import { mergeHeadConfigs, seoMetaToHeadConfig } from "./head.js";
|
|
58
|
+
import { getPublicEnvDefine } from "./public-env.js";
|
|
59
|
+
import { isUsableParamName, safeEvaluate } from "./safe-evaluator.js";
|
|
60
|
+
import { responseBindings } from "./page-response.js";
|
|
61
|
+
import { contentKey, renderMemo } from "./render-memo.js";
|
|
62
|
+
const transpiledServerScripts = renderMemo(128), compiledServerScripts = renderMemo(64);
|
|
63
|
+
function extractDeclaredVariableNames(script) {
|
|
64
|
+
const names = [];
|
|
65
|
+
let depth = 0;
|
|
66
|
+
const lines = script.split(`
|
|
67
|
+
`);
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
const depthAtLineStart = depth;
|
|
70
|
+
let inString = null, escaped = !1;
|
|
71
|
+
for (let i = 0;i < line.length; i++) {
|
|
72
|
+
const ch = line[i];
|
|
73
|
+
if (escaped) {
|
|
74
|
+
escaped = !1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (ch === "\\") {
|
|
78
|
+
escaped = !0;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (inString) {
|
|
82
|
+
if (ch === inString)
|
|
83
|
+
inString = null;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
87
|
+
inString = ch;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (ch === "/" && i + 1 < line.length && line[i + 1] === "/")
|
|
91
|
+
break;
|
|
92
|
+
if (ch === "{")
|
|
93
|
+
depth++;
|
|
94
|
+
else if (ch === "}")
|
|
95
|
+
depth--;
|
|
96
|
+
}
|
|
97
|
+
if (depthAtLineStart === 0) {
|
|
98
|
+
const match = line.match(/(?:const|let|var)\s+(\w+)\s*=/);
|
|
99
|
+
if (match)
|
|
100
|
+
names.push(match[1]);
|
|
101
|
+
else if (/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(line)) {
|
|
102
|
+
const declOnly = line.match(/(?:const|let|var)\s+(\w+)/);
|
|
103
|
+
if (declOnly)
|
|
104
|
+
names.push(declOnly[1]);
|
|
105
|
+
} else {
|
|
106
|
+
const destructMatch = line.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);
|
|
107
|
+
if (destructMatch) {
|
|
108
|
+
const vars = destructMatch[1].slice(1, -1).split(",").map((v) => {
|
|
109
|
+
const parts = v.split(":");
|
|
110
|
+
return (parts.length > 1 ? parts[1] : parts[0]).trim();
|
|
111
|
+
}).filter((v) => /^\w+$/.test(v));
|
|
112
|
+
names.push(...vars);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return [...new Set(names)];
|
|
118
|
+
}
|
|
119
|
+
export function stripTypeScript(scriptContent) {
|
|
120
|
+
let result = scriptContent;
|
|
121
|
+
result = result.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm, "");
|
|
122
|
+
result = result.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm, "");
|
|
123
|
+
result = result.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm, "");
|
|
124
|
+
result = result.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm, "");
|
|
125
|
+
result = result.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm, "$1$2$3");
|
|
126
|
+
function stripParamTypes(params) {
|
|
127
|
+
if (!params.includes(":"))
|
|
128
|
+
return params;
|
|
129
|
+
const paramParts = [];
|
|
130
|
+
let current = "", angleDepth = 0, parenDepth = 0, inStr = null;
|
|
131
|
+
for (let i = 0;i < params.length; i++) {
|
|
132
|
+
const c = params[i];
|
|
133
|
+
if (inStr) {
|
|
134
|
+
current += c;
|
|
135
|
+
if (c === inStr)
|
|
136
|
+
inStr = null;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
140
|
+
inStr = c;
|
|
141
|
+
current += c;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (c === "<")
|
|
145
|
+
angleDepth++;
|
|
146
|
+
else if (c === ">" && angleDepth > 0)
|
|
147
|
+
angleDepth--;
|
|
148
|
+
else if (c === "(")
|
|
149
|
+
parenDepth++;
|
|
150
|
+
else if (c === ")")
|
|
151
|
+
parenDepth--;
|
|
152
|
+
if (c === "," && angleDepth === 0 && parenDepth === 0) {
|
|
153
|
+
paramParts.push(current);
|
|
154
|
+
current = "";
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
current += c;
|
|
158
|
+
}
|
|
159
|
+
if (current)
|
|
160
|
+
paramParts.push(current);
|
|
161
|
+
return paramParts.map((param) => {
|
|
162
|
+
const trimmedParam = param.trim(), isRest = trimmedParam.startsWith("..."), paramBody = isRest ? trimmedParam.slice(3) : trimmedParam;
|
|
163
|
+
let colonIdx = -1, aDepth = 0;
|
|
164
|
+
for (let i = 0;i < paramBody.length; i++)
|
|
165
|
+
if (paramBody[i] === "<")
|
|
166
|
+
aDepth++;
|
|
167
|
+
else if (paramBody[i] === ">")
|
|
168
|
+
aDepth--;
|
|
169
|
+
else if (paramBody[i] === ":" && aDepth === 0) {
|
|
170
|
+
colonIdx = i;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (colonIdx === -1)
|
|
174
|
+
return param;
|
|
175
|
+
const namePart = paramBody.substring(0, colonIdx).trim().replace(/\?$/, ""), afterColon = paramBody.substring(colonIdx + 1);
|
|
176
|
+
let eqIdx = -1, eqADepth = 0;
|
|
177
|
+
for (let i = 0;i < afterColon.length; i++)
|
|
178
|
+
if (afterColon[i] === "<")
|
|
179
|
+
eqADepth++;
|
|
180
|
+
else if (afterColon[i] === ">")
|
|
181
|
+
eqADepth--;
|
|
182
|
+
else if (afterColon[i] === "=" && eqADepth === 0) {
|
|
183
|
+
eqIdx = i;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
const prefix = isRest ? "..." : "";
|
|
187
|
+
if (eqIdx !== -1)
|
|
188
|
+
return `${prefix}${namePart} = ${afterColon.substring(eqIdx + 1).trim()}`;
|
|
189
|
+
return `${prefix}${namePart}`;
|
|
190
|
+
}).join(", ");
|
|
191
|
+
}
|
|
192
|
+
result = result.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g, (match, prefix, params) => {
|
|
193
|
+
if (!params.includes(":"))
|
|
194
|
+
return match;
|
|
195
|
+
return `${prefix}(${stripParamTypes(params)})`;
|
|
196
|
+
});
|
|
197
|
+
{
|
|
198
|
+
const funcPattern = /\b(function\s+\w*\s*)\(/g;
|
|
199
|
+
let funcMatch;
|
|
200
|
+
const replacements = [];
|
|
201
|
+
while ((funcMatch = funcPattern.exec(result)) !== null) {
|
|
202
|
+
const openParen = funcMatch.index + funcMatch[0].length - 1;
|
|
203
|
+
let depth = 1, pos = openParen + 1, aDepth = 0, inStr = null;
|
|
204
|
+
while (pos < result.length && depth > 0) {
|
|
205
|
+
const ch = result[pos];
|
|
206
|
+
if (inStr) {
|
|
207
|
+
if (ch === inStr)
|
|
208
|
+
inStr = null;
|
|
209
|
+
pos++;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
213
|
+
inStr = ch;
|
|
214
|
+
pos++;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (ch === "<")
|
|
218
|
+
aDepth++;
|
|
219
|
+
else if (ch === ">" && aDepth > 0)
|
|
220
|
+
aDepth--;
|
|
221
|
+
else if (aDepth === 0) {
|
|
222
|
+
if (ch === "(")
|
|
223
|
+
depth++;
|
|
224
|
+
else if (ch === ")")
|
|
225
|
+
depth--;
|
|
226
|
+
}
|
|
227
|
+
if (depth > 0)
|
|
228
|
+
pos++;
|
|
229
|
+
}
|
|
230
|
+
if (depth !== 0)
|
|
231
|
+
continue;
|
|
232
|
+
const params = result.substring(openParen + 1, pos);
|
|
233
|
+
if (!params.includes(":"))
|
|
234
|
+
continue;
|
|
235
|
+
const cleaned = stripParamTypes(params);
|
|
236
|
+
replacements.push({ start: openParen + 1, end: pos, replacement: cleaned });
|
|
237
|
+
}
|
|
238
|
+
for (let i = replacements.length - 1;i >= 0; i--) {
|
|
239
|
+
const { start, end, replacement } = replacements[i];
|
|
240
|
+
result = result.substring(0, start) + replacement + result.substring(end);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
result = result.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g, (match, params) => {
|
|
244
|
+
if (!params.includes(":"))
|
|
245
|
+
return match;
|
|
246
|
+
if (params.includes("{") || params.includes("}"))
|
|
247
|
+
return match;
|
|
248
|
+
return `(${params.split(",").map((param) => {
|
|
249
|
+
const [nameWithType, ...defaultParts] = param.split("="), name = nameWithType.split(":")[0].trim();
|
|
250
|
+
if (defaultParts.length > 0)
|
|
251
|
+
return `${name} = ${defaultParts.join("=").trim()}`;
|
|
252
|
+
return name;
|
|
253
|
+
}).join(", ")}) =>`;
|
|
254
|
+
});
|
|
255
|
+
result = result.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g, "$1$3");
|
|
256
|
+
result = result.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g, "$1");
|
|
257
|
+
result = result.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g, "$1");
|
|
258
|
+
result = result.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g, "$1");
|
|
259
|
+
result = result.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g, "");
|
|
260
|
+
result = result.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g, "");
|
|
261
|
+
result = result.replace(/(\w|\)|\])\s*!(?!=)/g, "$1");
|
|
262
|
+
result = result.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm, "");
|
|
263
|
+
result = result.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g, "");
|
|
264
|
+
result = result.replace(/\n\s*\n\s*\n/g, `
|
|
265
|
+
|
|
266
|
+
`);
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
export function isModuleResolutionFailure(message) {
|
|
270
|
+
return /cannot find module|could not resolve|module not found|failed to resolve/i.test(message);
|
|
271
|
+
}
|
|
272
|
+
export function isMissingBindingFailure(message) {
|
|
273
|
+
if (!/is not defined|can't find variable/i.test(message))
|
|
274
|
+
return !1;
|
|
275
|
+
return !/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(message);
|
|
276
|
+
}
|
|
277
|
+
export async function extractVariables(scriptContent, context, filePath, options = {}) {
|
|
278
|
+
if (!scriptContent.trim())
|
|
279
|
+
return;
|
|
280
|
+
const define = getPublicEnvDefine(), transpileKey = contentKey(scriptContent, JSON.stringify(define));
|
|
281
|
+
let jsContent = transpiledServerScripts.get(transpileKey);
|
|
282
|
+
if (jsContent === void 0) {
|
|
283
|
+
try {
|
|
284
|
+
const transpiler = getSharedTranspiler({ loader: "ts", target: "browser", define });
|
|
285
|
+
let processedCode = scriptContent.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
286
|
+
processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
287
|
+
jsContent = transpiler.transformSync(processedCode);
|
|
288
|
+
} catch {
|
|
289
|
+
jsContent = stripTypeScript(scriptContent);
|
|
290
|
+
}
|
|
291
|
+
transpiledServerScripts.set(transpileKey, jsContent);
|
|
292
|
+
}
|
|
293
|
+
const module = { exports: {} }, exports = module.exports, projectRoot = process.cwd(), preloaded = {}, serverRequires = [...jsContent.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g) || []].map((m) => m[1]).filter((id) => !id.startsWith("node:") && !["fs", "path", "os", "child_process", "crypto", "http", "https", "url", "util", "stream", "events", "buffer", "net", "querystring", "zlib", "tls"].includes(id)), unresolvable = new Map;
|
|
294
|
+
for (const id of serverRequires)
|
|
295
|
+
try {
|
|
296
|
+
if (id.startsWith(".")) {
|
|
297
|
+
preloaded[id] = await import(path.resolve(path.dirname(filePath), id));
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const pkgDir = path.resolve(projectRoot, "node_modules", id), pkgJsonPath = path.join(pkgDir, "package.json"), pkgJson = JSON.parse(require("fs").readFileSync(pkgJsonPath, "utf8"));
|
|
301
|
+
let entry = pkgJson.main || "index.js";
|
|
302
|
+
if (pkgJson.exports) {
|
|
303
|
+
const exp = typeof pkgJson.exports === "string" ? pkgJson.exports : pkgJson.exports["."];
|
|
304
|
+
if (typeof exp === "string")
|
|
305
|
+
entry = exp;
|
|
306
|
+
else if (exp?.bun)
|
|
307
|
+
entry = exp.bun;
|
|
308
|
+
else if (exp?.import)
|
|
309
|
+
entry = exp.import;
|
|
310
|
+
else if (exp?.default)
|
|
311
|
+
entry = exp.default;
|
|
312
|
+
}
|
|
313
|
+
preloaded[id] = await import(path.resolve(pkgDir, entry));
|
|
314
|
+
} catch (error) {
|
|
315
|
+
if (id.startsWith("."))
|
|
316
|
+
unresolvable.set(id, error instanceof Error ? error.message : String(error));
|
|
317
|
+
}
|
|
318
|
+
const requireFn = (id) => {
|
|
319
|
+
if (preloaded[id])
|
|
320
|
+
return preloaded[id];
|
|
321
|
+
const reason = unresolvable.get(id);
|
|
322
|
+
if (reason !== void 0)
|
|
323
|
+
throw Error(`Cannot require '${id}' from ${filePath}: ${reason}`);
|
|
324
|
+
return require(id);
|
|
325
|
+
}, propsObj = context.props || {}, $props = (defaults) => {
|
|
326
|
+
if (!defaults)
|
|
327
|
+
return propsObj;
|
|
328
|
+
const result = {};
|
|
329
|
+
for (const [key, defaultValue] of Object.entries(defaults)) {
|
|
330
|
+
const propValue = propsObj[key];
|
|
331
|
+
if (propValue !== void 0)
|
|
332
|
+
result[key] = propValue;
|
|
333
|
+
else if (typeof defaultValue === "function")
|
|
334
|
+
result[key] = defaultValue();
|
|
335
|
+
else
|
|
336
|
+
result[key] = defaultValue;
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
};
|
|
340
|
+
for (const [key, value] of Object.entries(propsObj))
|
|
341
|
+
Object.defineProperty($props, key, { value, enumerable: !0, configurable: !0, writable: !0 });
|
|
342
|
+
for (const shadowed of ["name", "length", "caller", "arguments"]) {
|
|
343
|
+
if (Object.prototype.hasOwnProperty.call(propsObj, shadowed))
|
|
344
|
+
continue;
|
|
345
|
+
try {
|
|
346
|
+
Object.defineProperty($props, shadowed, { value: void 0, enumerable: !1, configurable: !0, writable: !0 });
|
|
347
|
+
} catch {}
|
|
348
|
+
}
|
|
349
|
+
const defineProps = (definitions) => {
|
|
350
|
+
if (!definitions)
|
|
351
|
+
return propsObj;
|
|
352
|
+
const result = { ...propsObj };
|
|
353
|
+
for (const [key, def] of Object.entries(definitions)) {
|
|
354
|
+
const opts = def && typeof def === "object" && !Array.isArray(def) ? def : { type: def };
|
|
355
|
+
if (result[key] === void 0 && opts.default !== void 0)
|
|
356
|
+
result[key] = typeof opts.default === "function" ? opts.default() : opts.default;
|
|
357
|
+
}
|
|
358
|
+
return result;
|
|
359
|
+
}, defineSlots = () => context.slots || {}, withDefaults = (props, defaults) => {
|
|
360
|
+
const result = { ...props };
|
|
361
|
+
for (const [key, defaultValue] of Object.entries(defaults))
|
|
362
|
+
if (result[key] === void 0)
|
|
363
|
+
if (typeof defaultValue === "function")
|
|
364
|
+
result[key] = defaultValue();
|
|
365
|
+
else
|
|
366
|
+
result[key] = defaultValue;
|
|
367
|
+
return result;
|
|
368
|
+
}, state = (initialValue) => {
|
|
369
|
+
const getter = () => initialValue;
|
|
370
|
+
getter.set = (_v) => {};
|
|
371
|
+
getter.update = (_fn) => {};
|
|
372
|
+
return getter;
|
|
373
|
+
}, derived = (fn) => {
|
|
374
|
+
let cached, computed = !1;
|
|
375
|
+
return () => {
|
|
376
|
+
if (!computed)
|
|
377
|
+
try {
|
|
378
|
+
cached = fn();
|
|
379
|
+
computed = !0;
|
|
380
|
+
} catch {
|
|
381
|
+
cached = void 0;
|
|
382
|
+
}
|
|
383
|
+
return cached;
|
|
384
|
+
};
|
|
385
|
+
}, effect = (_fn) => {}, batch = (fn) => fn(), onMount = (_fn) => {}, onDestroy = (_fn) => {}, responseApi = responseBindings(context);
|
|
386
|
+
function definePageMeta(meta) {
|
|
387
|
+
const config = meta || {};
|
|
388
|
+
if (config.title !== void 0 || config.description !== void 0)
|
|
389
|
+
useSeoMeta({ title: config.title, description: config.description });
|
|
390
|
+
}
|
|
391
|
+
function defineClientPayload(payload) {
|
|
392
|
+
if (!payload || typeof payload !== "object")
|
|
393
|
+
return;
|
|
394
|
+
const declared = context.__stxClientPayload ?? {};
|
|
395
|
+
Object.assign(declared, payload);
|
|
396
|
+
context.__stxClientPayload = declared;
|
|
397
|
+
}
|
|
398
|
+
const useRoute = () => {
|
|
399
|
+
const serveCtx = context.__stxServeContext, search = context.__stxServeSearch ?? serveCtx?.search ?? "", path = serveCtx?.path ?? "", parsed = Object.fromEntries(new URLSearchParams(search)), supplied = context.query, query = Object.keys(parsed).length > 0 ? parsed : supplied ?? {}, suffix = search || (Object.keys(query).length > 0 ? `?${new URLSearchParams(query).toString()}` : "");
|
|
400
|
+
return {
|
|
401
|
+
params: context.params ?? {},
|
|
402
|
+
query,
|
|
403
|
+
path,
|
|
404
|
+
name: "",
|
|
405
|
+
fullPath: path + suffix,
|
|
406
|
+
hash: "",
|
|
407
|
+
matched: []
|
|
408
|
+
};
|
|
409
|
+
}, useRouter = () => ({ push: (_to) => {}, replace: (_to) => {}, back: () => {}, forward: () => {}, go: (_n) => {} }), useHead = (head) => {
|
|
410
|
+
const existing = context.__stx_runtime_head || {};
|
|
411
|
+
context.__stx_runtime_head = mergeHeadConfigs(existing, head || {});
|
|
412
|
+
}, useSeoMeta = (meta) => {
|
|
413
|
+
useHead(seoMetaToHeadConfig(meta || {}));
|
|
414
|
+
}, ref = (val) => ({ value: val }), reactive = (obj) => obj, computed = (fn) => ({ value: typeof fn === "function" ? fn() : fn }), watch = (_source, _cb) => {}, onMounted = (_fn) => {}, onUnmounted = (_fn) => {}, nextTick = (fn) => fn ? fn() : Promise.resolve(), defineEmits = (_events) => (_event, ..._args) => {}, defineExpose = (_exposed) => {}, provide = (_key, _value) => {}, inject = (_key, defaultValue) => defaultValue, useColorMode = () => ({ value: "light" }), useDark = () => state(!1), useMediaQuery = (_query) => state(!1), useScrollLock = () => state(!1), usePreferredDark = () => useMediaQuery("(prefers-color-scheme: dark)"), usePreferredLight = () => useMediaQuery("(prefers-color-scheme: light)"), usePreferredReducedMotion = () => useMediaQuery("(prefers-reduced-motion: reduce)"), usePreferredContrast = () => useMediaQuery("(prefers-contrast: more)"), mockWindow = {
|
|
415
|
+
siteId: void 0,
|
|
416
|
+
API_ENDPOINT: "",
|
|
417
|
+
ANALYTICS_SITE_ID: void 0,
|
|
418
|
+
location: {
|
|
419
|
+
href: "",
|
|
420
|
+
pathname: "",
|
|
421
|
+
search: "",
|
|
422
|
+
hash: "",
|
|
423
|
+
origin: "",
|
|
424
|
+
host: "",
|
|
425
|
+
hostname: "",
|
|
426
|
+
protocol: "https:",
|
|
427
|
+
assign: () => {},
|
|
428
|
+
replace: () => {},
|
|
429
|
+
reload: () => {}
|
|
430
|
+
},
|
|
431
|
+
localStorage: {
|
|
432
|
+
getItem: () => null,
|
|
433
|
+
setItem: () => {},
|
|
434
|
+
removeItem: () => {},
|
|
435
|
+
clear: () => {}
|
|
436
|
+
},
|
|
437
|
+
sessionStorage: {
|
|
438
|
+
getItem: () => null,
|
|
439
|
+
setItem: () => {},
|
|
440
|
+
removeItem: () => {},
|
|
441
|
+
clear: () => {}
|
|
442
|
+
},
|
|
443
|
+
fetch: globalThis.fetch,
|
|
444
|
+
addEventListener: () => {},
|
|
445
|
+
removeEventListener: () => {},
|
|
446
|
+
setTimeout: () => 0,
|
|
447
|
+
clearTimeout: () => {},
|
|
448
|
+
setInterval: () => 0,
|
|
449
|
+
clearInterval: () => {},
|
|
450
|
+
requestAnimationFrame: () => 0,
|
|
451
|
+
cancelAnimationFrame: () => {},
|
|
452
|
+
alert: () => {},
|
|
453
|
+
confirm: () => !1,
|
|
454
|
+
prompt: () => null,
|
|
455
|
+
getComputedStyle: () => ({}),
|
|
456
|
+
matchMedia: () => ({ matches: !1, addListener: () => {}, removeListener: () => {} }),
|
|
457
|
+
getDateRangeParams: () => "",
|
|
458
|
+
stx: {}
|
|
459
|
+
}, windowProxy = new Proxy(mockWindow, {
|
|
460
|
+
get(target, prop) {
|
|
461
|
+
if (prop in target)
|
|
462
|
+
return target[prop];
|
|
463
|
+
return;
|
|
464
|
+
},
|
|
465
|
+
set(target, prop, value) {
|
|
466
|
+
target[prop] = value;
|
|
467
|
+
return !0;
|
|
468
|
+
}
|
|
469
|
+
}), mockDocument = {
|
|
470
|
+
getElementById: () => null,
|
|
471
|
+
querySelector: () => null,
|
|
472
|
+
querySelectorAll: () => [],
|
|
473
|
+
createElement: () => ({}),
|
|
474
|
+
createTextNode: () => ({}),
|
|
475
|
+
body: {},
|
|
476
|
+
head: {},
|
|
477
|
+
documentElement: {},
|
|
478
|
+
addEventListener: () => {},
|
|
479
|
+
removeEventListener: () => {}
|
|
480
|
+
}, mockConsole = console;
|
|
481
|
+
try {
|
|
482
|
+
const convertedScript = convertToCommonJS(jsContent, filePath), propsKeys = new Set(Object.keys(propsObj)), filteredContextKeys = Object.keys(context).filter((key) => !propsKeys.has(key) && !CONTEXT_RESERVED_BINDINGS.has(key) && isUsableParamName(key)), filteredContextValues = filteredContextKeys.map((key) => context[key]);
|
|
483
|
+
if (!filteredContextKeys.includes("__stxServeContext")) {
|
|
484
|
+
filteredContextKeys.push("__stxServeContext");
|
|
485
|
+
filteredContextValues.push(void 0);
|
|
486
|
+
}
|
|
487
|
+
const stxShadowedNames = new Set([
|
|
488
|
+
"async",
|
|
489
|
+
"module",
|
|
490
|
+
"exports",
|
|
491
|
+
"require",
|
|
492
|
+
"params",
|
|
493
|
+
"window",
|
|
494
|
+
"document",
|
|
495
|
+
"console",
|
|
496
|
+
"state",
|
|
497
|
+
"derived",
|
|
498
|
+
"effect"
|
|
499
|
+
]), propArgNames = [], propArgValues = [];
|
|
500
|
+
for (const [key, value] of Object.entries(propsObj)) {
|
|
501
|
+
if (!isUsableParamName(key))
|
|
502
|
+
continue;
|
|
503
|
+
if (stxShadowedNames.has(key))
|
|
504
|
+
continue;
|
|
505
|
+
if (new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${key}\\b`).test(convertedScript))
|
|
506
|
+
continue;
|
|
507
|
+
propArgNames.push(key);
|
|
508
|
+
propArgValues.push(value);
|
|
509
|
+
}
|
|
510
|
+
const reSyncCode = extractDeclaredVariableNames(convertedScript).map((name) => `module.exports.${name} = typeof ${name} !== 'undefined' ? ${name} : module.exports.${name};`).join(`
|
|
511
|
+
`), paramsObj = context.params ?? {}, scriptContextKeys = [], scriptContextValues = [];
|
|
512
|
+
for (let i = 0;i < filteredContextKeys.length; i++) {
|
|
513
|
+
if (filteredContextKeys[i] === "params")
|
|
514
|
+
continue;
|
|
515
|
+
scriptContextKeys.push(filteredContextKeys[i]);
|
|
516
|
+
scriptContextValues.push(filteredContextValues[i]);
|
|
517
|
+
}
|
|
518
|
+
const scriptParams = [...STX_ENGINE_BINDING_NAMES, ...propArgNames, ...scriptContextKeys], scriptBody = `return (async () => {
|
|
519
|
+
${convertedScript}
|
|
520
|
+
${reSyncCode}
|
|
521
|
+
return module.exports
|
|
522
|
+
})()`, compileKey = contentKey(scriptBody, scriptParams.join("\x00"));
|
|
523
|
+
let scriptFn = compiledServerScripts.get(compileKey);
|
|
524
|
+
if (!scriptFn) {
|
|
525
|
+
scriptFn = Function(...scriptParams, scriptBody);
|
|
526
|
+
compiledServerScripts.set(compileKey, scriptFn);
|
|
527
|
+
}
|
|
528
|
+
const result = await scriptFn(module, exports, requireFn, propsObj, $props, defineProps, withDefaults, defineClientPayload, state, derived, effect, batch, onMount, onDestroy, definePageMeta, useRoute, useRouter, useHead, useSeoMeta, responseApi.setResponseStatus, responseApi.setResponseHeader, responseApi.notFound, ref, reactive, computed, watch, onMounted, onUnmounted, nextTick, defineEmits, defineExpose, defineSlots, provide, inject, useColorMode, useDark, useMediaQuery, useScrollLock, usePreferredDark, usePreferredLight, usePreferredReducedMotion, usePreferredContrast, windowProxy, mockDocument, mockConsole, mockWindow.confirm, mockWindow.alert, mockWindow.fetch, paramsObj, ...propArgValues, ...scriptContextValues);
|
|
529
|
+
if (options.preserveExisting) {
|
|
530
|
+
for (const [key, value] of Object.entries(result))
|
|
531
|
+
if (!(key in context) || context[key] === void 0)
|
|
532
|
+
context[key] = value;
|
|
533
|
+
} else
|
|
534
|
+
Object.assign(context, result);
|
|
535
|
+
for (const [key, value] of Object.entries(propsObj))
|
|
536
|
+
if (!(key in context))
|
|
537
|
+
context[key] = value;
|
|
538
|
+
} catch (primaryError) {
|
|
539
|
+
const msg = primaryError instanceof Error ? primaryError.message : String(primaryError);
|
|
540
|
+
if (isModuleResolutionFailure(msg))
|
|
541
|
+
console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${msg}`);
|
|
542
|
+
else if (isMissingBindingFailure(msg))
|
|
543
|
+
console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${msg}`);
|
|
544
|
+
else if (process.env.STX_DEBUG)
|
|
545
|
+
console.warn(`[stx] server <script> did not execute in ${filePath ?? "<unknown>"} \u2014 falling back to static extraction. Cause: ${msg}`);
|
|
546
|
+
try {
|
|
547
|
+
await fallbackVariableExtraction(jsContent, context, filePath);
|
|
548
|
+
} catch (fallbackError) {
|
|
549
|
+
if (process.env.STX_DEBUG) {
|
|
550
|
+
const msg = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
551
|
+
console.warn(`[stx] fallback extraction also failed in ${filePath ?? "<unknown>"}: ${msg}`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
export function isCompleteImport(statement) {
|
|
557
|
+
let braces = 0, quote = null, sawFrom = !1, closedSpecifier = !1;
|
|
558
|
+
for (let index = 0;index < statement.length; index++) {
|
|
559
|
+
const character = statement[index];
|
|
560
|
+
if (quote) {
|
|
561
|
+
if (character === quote) {
|
|
562
|
+
quote = null;
|
|
563
|
+
if (sawFrom || braces === 0)
|
|
564
|
+
closedSpecifier = !0;
|
|
565
|
+
}
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
if (character === "'" || character === '"' || character === "`") {
|
|
569
|
+
quote = character;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (character === "{")
|
|
573
|
+
braces++;
|
|
574
|
+
else if (character === "}")
|
|
575
|
+
braces--;
|
|
576
|
+
else if (statement.startsWith("from", index) && braces === 0)
|
|
577
|
+
sawFrom = !0;
|
|
578
|
+
}
|
|
579
|
+
return quote === null && braces === 0 && closedSpecifier;
|
|
580
|
+
}
|
|
581
|
+
const UNINITIALIZED_DECLARATION = /^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;
|
|
582
|
+
export function convertToCommonJS(scriptContent, filePath) {
|
|
583
|
+
const templateDir = filePath ? path.dirname(filePath) : process.cwd(), projectRoot = process.cwd(), lines = scriptContent.split(`
|
|
584
|
+
`), convertedLines = [];
|
|
585
|
+
let i = 0;
|
|
586
|
+
while (i < lines.length) {
|
|
587
|
+
const line = lines[i].trim();
|
|
588
|
+
if (line.startsWith("interface ") || line.startsWith("export interface ") || line.startsWith("type ") || line.startsWith("export type ")) {
|
|
589
|
+
if (line.includes("{") && !line.includes("}")) {
|
|
590
|
+
let braceDepth = 0;
|
|
591
|
+
for (;i < lines.length; i++) {
|
|
592
|
+
for (const ch of lines[i])
|
|
593
|
+
if (ch === "{")
|
|
594
|
+
braceDepth++;
|
|
595
|
+
else if (ch === "}")
|
|
596
|
+
braceDepth--;
|
|
597
|
+
if (braceDepth <= 0)
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
i++;
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (line.startsWith("definePageMeta(")) {
|
|
605
|
+
let depth = 0, done = !1;
|
|
606
|
+
const callStart = i;
|
|
607
|
+
for (let j = i;j < lines.length && !done; j++) {
|
|
608
|
+
let inString = null, escaped = !1;
|
|
609
|
+
const text = lines[j];
|
|
610
|
+
for (let k = 0;k < text.length; k++) {
|
|
611
|
+
const ch = text[k];
|
|
612
|
+
if (escaped) {
|
|
613
|
+
escaped = !1;
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if (ch === "\\") {
|
|
617
|
+
escaped = !0;
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (inString) {
|
|
621
|
+
if (ch === inString)
|
|
622
|
+
inString = null;
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
626
|
+
inString = ch;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (ch === "(")
|
|
630
|
+
depth++;
|
|
631
|
+
else if (ch === ")") {
|
|
632
|
+
depth--;
|
|
633
|
+
if (depth === 0) {
|
|
634
|
+
i = j + 1;
|
|
635
|
+
done = !0;
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (!done)
|
|
642
|
+
i = lines.length;
|
|
643
|
+
const callText = lines.slice(callStart, i).join(`
|
|
644
|
+
`), lifted = [];
|
|
645
|
+
for (const key of ["title", "description"]) {
|
|
646
|
+
const match = new RegExp(`\\b${key}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(callText);
|
|
647
|
+
if (match)
|
|
648
|
+
lifted.push(`${key}: ${JSON.stringify(match[2])}`);
|
|
649
|
+
}
|
|
650
|
+
if (lifted.length > 0)
|
|
651
|
+
convertedLines.push(`useSeoMeta({ ${lifted.join(", ")} });`);
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
if (line.startsWith("import ") || line === "import" || line.startsWith("import{")) {
|
|
655
|
+
let statement = line, consumed = 0;
|
|
656
|
+
while (!isCompleteImport(statement) && i + consumed + 1 < lines.length) {
|
|
657
|
+
consumed++;
|
|
658
|
+
statement = `${statement} ${lines[i + consumed].trim()}`;
|
|
659
|
+
}
|
|
660
|
+
i += consumed;
|
|
661
|
+
const defaultImportMatch = statement.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/), namedImportMatch = statement.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/), sideEffectMatch = statement.match(/^import\s+['"](.+?)['"]/), line_ = statement, resolveSource = (source) => {
|
|
662
|
+
if (source.startsWith("."))
|
|
663
|
+
return path.resolve(templateDir, source);
|
|
664
|
+
if (source.startsWith("~/") || source.startsWith("@/"))
|
|
665
|
+
return path.resolve(projectRoot, source.slice(2));
|
|
666
|
+
return source;
|
|
667
|
+
};
|
|
668
|
+
if (defaultImportMatch) {
|
|
669
|
+
const [, name, source] = defaultImportMatch, resolved = resolveSource(source);
|
|
670
|
+
convertedLines.push(`const ${name} = (await import('${resolved}')).default`);
|
|
671
|
+
convertedLines.push(`module.exports.${name} = ${name};`);
|
|
672
|
+
} else if (namedImportMatch) {
|
|
673
|
+
const [, names, source] = namedImportMatch, resolved = resolveSource(source), specifiers = [], exported = [], isStxRuntime = STX_RUNTIME_SPECIFIERS.has(source);
|
|
674
|
+
for (const raw of names.split(",")) {
|
|
675
|
+
const specifier = raw.trim();
|
|
676
|
+
if (!specifier)
|
|
677
|
+
continue;
|
|
678
|
+
const aliased = specifier.split(/\s+as\s+/);
|
|
679
|
+
if (aliased.length === 2) {
|
|
680
|
+
const [imported, local] = [aliased[0].trim(), aliased[1].trim()];
|
|
681
|
+
if (isStxRuntime && ENGINE_BINDINGS.has(imported)) {
|
|
682
|
+
convertedLines.push(`const ${local} = ${imported};`);
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
specifiers.push(`${imported}: ${local}`);
|
|
686
|
+
exported.push(local);
|
|
687
|
+
} else {
|
|
688
|
+
if (isStxRuntime && ENGINE_BINDINGS.has(specifier))
|
|
689
|
+
continue;
|
|
690
|
+
specifiers.push(specifier);
|
|
691
|
+
exported.push(specifier);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (specifiers.length > 0)
|
|
695
|
+
convertedLines.push(`const { ${specifiers.join(", ")} } = await import('${resolved}')`);
|
|
696
|
+
for (const local of exported)
|
|
697
|
+
convertedLines.push(`module.exports.${local} = ${local};`);
|
|
698
|
+
} else if (sideEffectMatch) {
|
|
699
|
+
const resolved = resolveSource(sideEffectMatch[1]);
|
|
700
|
+
convertedLines.push(`await import('${resolved}')`);
|
|
701
|
+
} else
|
|
702
|
+
convertedLines.push(line_);
|
|
703
|
+
i++;
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (UNINITIALIZED_DECLARATION.test(line)) {
|
|
707
|
+
convertedLines.push(lines[i]);
|
|
708
|
+
i++;
|
|
709
|
+
} else if (line.startsWith("export const ") || line.startsWith("export let ") || line.startsWith("export var ")) {
|
|
710
|
+
const result = parseVariableDeclaration(lines, i), { type, name, value } = result;
|
|
711
|
+
convertedLines.push(`${type} ${name} = ${value};`);
|
|
712
|
+
convertedLines.push(`module.exports.${name} = ${name};`);
|
|
713
|
+
i = result.nextIndex;
|
|
714
|
+
} else if (line.startsWith("export function ") || line.startsWith("export async function ")) {
|
|
715
|
+
const result = parseFunctionDeclaration(lines, i);
|
|
716
|
+
convertedLines.push(result.functionCode);
|
|
717
|
+
convertedLines.push(`module.exports.${result.name} = ${result.name};`);
|
|
718
|
+
i = result.nextIndex;
|
|
719
|
+
} else if (line.startsWith("const ") || line.startsWith("let ") || line.startsWith("var ")) {
|
|
720
|
+
const result = parseVariableDeclaration(lines, i), { type, name, value } = result;
|
|
721
|
+
convertedLines.push(`${type} ${name} = ${value};`);
|
|
722
|
+
convertedLines.push(`module.exports.${name} = ${name};`);
|
|
723
|
+
i = result.nextIndex;
|
|
724
|
+
} else if (line.startsWith("function ") || line.startsWith("async function ")) {
|
|
725
|
+
const result = parseFunctionDeclaration(lines, i);
|
|
726
|
+
convertedLines.push(result.functionCode);
|
|
727
|
+
convertedLines.push(`module.exports.${result.name} = ${result.name};`);
|
|
728
|
+
i = result.nextIndex;
|
|
729
|
+
} else if (line.startsWith("export default function ") || line.startsWith("export default async function ")) {
|
|
730
|
+
const strippedLine = lines[i].replace(/^(\s*)export\s+default\s+/, "$1"), tempLines = [...lines];
|
|
731
|
+
tempLines[i] = strippedLine;
|
|
732
|
+
const result = parseFunctionDeclaration(tempLines, i);
|
|
733
|
+
convertedLines.push(result.functionCode);
|
|
734
|
+
if (result.name)
|
|
735
|
+
convertedLines.push(`module.exports.default = ${result.name};`);
|
|
736
|
+
i = result.nextIndex;
|
|
737
|
+
} else if (line.startsWith("export default ")) {
|
|
738
|
+
const value = line.replace(/^export\s+default\s+/, "").replace(/;$/, "");
|
|
739
|
+
convertedLines.push(`module.exports.default = ${value};`);
|
|
740
|
+
i++;
|
|
741
|
+
} else if (line.startsWith("class ") || line.startsWith("export class ")) {
|
|
742
|
+
const classMatch = line.match(/(?:export\s+)?class\s+(\w+)/);
|
|
743
|
+
if (classMatch) {
|
|
744
|
+
const className = classMatch[1];
|
|
745
|
+
let classCode = lines[i].replace(/^export\s+/, ""), braceDepth = 0, j = i;
|
|
746
|
+
for (;j < lines.length; j++) {
|
|
747
|
+
const l = lines[j];
|
|
748
|
+
for (const ch of l)
|
|
749
|
+
if (ch === "{")
|
|
750
|
+
braceDepth++;
|
|
751
|
+
else if (ch === "}")
|
|
752
|
+
braceDepth--;
|
|
753
|
+
if (j > i)
|
|
754
|
+
classCode += `
|
|
755
|
+
` + l;
|
|
756
|
+
if (braceDepth <= 0 && j >= i)
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
convertedLines.push(classCode);
|
|
760
|
+
convertedLines.push(`module.exports.${className} = ${className};`);
|
|
761
|
+
i = j + 1;
|
|
762
|
+
} else {
|
|
763
|
+
convertedLines.push(line);
|
|
764
|
+
i++;
|
|
765
|
+
}
|
|
766
|
+
} else if (line.includes("module.exports")) {
|
|
767
|
+
convertedLines.push(line);
|
|
768
|
+
i++;
|
|
769
|
+
} else if (line.trim() && !line.startsWith("//")) {
|
|
770
|
+
convertedLines.push(line);
|
|
771
|
+
i++;
|
|
772
|
+
} else
|
|
773
|
+
i++;
|
|
774
|
+
}
|
|
775
|
+
return resolveDynamicImports(convertedLines.join(`
|
|
776
|
+
`), templateDir, projectRoot);
|
|
777
|
+
}
|
|
778
|
+
function resolveDynamicImports(source, templateDir, projectRoot) {
|
|
779
|
+
const len = source.length;
|
|
780
|
+
let out = "", i = 0, inString = null, inLineComment = !1, inBlockComment = !1, inTemplateExpr = 0;
|
|
781
|
+
while (i < len) {
|
|
782
|
+
const ch = source[i], next = source[i + 1];
|
|
783
|
+
if (inLineComment) {
|
|
784
|
+
out += ch;
|
|
785
|
+
if (ch === `
|
|
786
|
+
`)
|
|
787
|
+
inLineComment = !1;
|
|
788
|
+
i++;
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
if (inBlockComment) {
|
|
792
|
+
out += ch;
|
|
793
|
+
if (ch === "*" && next === "/") {
|
|
794
|
+
out += next;
|
|
795
|
+
i += 2;
|
|
796
|
+
inBlockComment = !1;
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
i++;
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (!inString && ch === "/" && next === "/") {
|
|
803
|
+
inLineComment = !0;
|
|
804
|
+
out += ch;
|
|
805
|
+
i++;
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if (!inString && ch === "/" && next === "*") {
|
|
809
|
+
inBlockComment = !0;
|
|
810
|
+
out += ch;
|
|
811
|
+
i++;
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
if (inString) {
|
|
815
|
+
out += ch;
|
|
816
|
+
if (ch === "\\") {
|
|
817
|
+
out += next;
|
|
818
|
+
i += 2;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (ch === inString && inString !== "`") {
|
|
822
|
+
inString = null;
|
|
823
|
+
i++;
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
if (inString === "`") {
|
|
827
|
+
if (ch === "$" && next === "{") {
|
|
828
|
+
inTemplateExpr++;
|
|
829
|
+
out += next;
|
|
830
|
+
i += 2;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
if (ch === "`") {
|
|
834
|
+
inString = null;
|
|
835
|
+
i++;
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
i++;
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
if (inTemplateExpr > 0) {
|
|
843
|
+
if (ch === "{")
|
|
844
|
+
inTemplateExpr++;
|
|
845
|
+
else if (ch === "}")
|
|
846
|
+
inTemplateExpr--;
|
|
847
|
+
}
|
|
848
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
849
|
+
inString = ch;
|
|
850
|
+
out += ch;
|
|
851
|
+
i++;
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
if (ch === "a" && source.startsWith("await", i)) {
|
|
855
|
+
const match = matchDynamicImportAt(source, i);
|
|
856
|
+
if (match) {
|
|
857
|
+
const { quote, path: importPath, end } = match;
|
|
858
|
+
if (importPath.startsWith(".") || importPath.startsWith("~/") || importPath.startsWith("@/")) {
|
|
859
|
+
const resolved = importPath.startsWith(".") ? path.resolve(templateDir, importPath) : path.resolve(projectRoot, importPath.slice(2));
|
|
860
|
+
out += `await import(${quote}${resolved}${quote})`;
|
|
861
|
+
i = end;
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
out += ch;
|
|
867
|
+
i++;
|
|
868
|
+
}
|
|
869
|
+
return out;
|
|
870
|
+
}
|
|
871
|
+
function matchDynamicImportAt(src, start) {
|
|
872
|
+
let pos = start + 5;
|
|
873
|
+
if (pos >= src.length)
|
|
874
|
+
return null;
|
|
875
|
+
if (!/\s/.test(src[pos]))
|
|
876
|
+
return null;
|
|
877
|
+
while (pos < src.length && /\s/.test(src[pos]))
|
|
878
|
+
pos++;
|
|
879
|
+
if (!src.startsWith("import", pos))
|
|
880
|
+
return null;
|
|
881
|
+
pos += 6;
|
|
882
|
+
while (pos < src.length && /\s/.test(src[pos]))
|
|
883
|
+
pos++;
|
|
884
|
+
if (src[pos] !== "(")
|
|
885
|
+
return null;
|
|
886
|
+
pos++;
|
|
887
|
+
while (pos < src.length && /\s/.test(src[pos]))
|
|
888
|
+
pos++;
|
|
889
|
+
const quote = src[pos];
|
|
890
|
+
if (quote !== "'" && quote !== '"')
|
|
891
|
+
return null;
|
|
892
|
+
pos++;
|
|
893
|
+
const pathStart = pos;
|
|
894
|
+
while (pos < src.length && src[pos] !== quote)
|
|
895
|
+
if (src[pos] === "\\")
|
|
896
|
+
pos += 2;
|
|
897
|
+
else
|
|
898
|
+
pos++;
|
|
899
|
+
if (pos >= src.length)
|
|
900
|
+
return null;
|
|
901
|
+
const importPath = src.slice(pathStart, pos);
|
|
902
|
+
pos++;
|
|
903
|
+
while (pos < src.length && /\s/.test(src[pos]))
|
|
904
|
+
pos++;
|
|
905
|
+
if (src[pos] !== ")")
|
|
906
|
+
return null;
|
|
907
|
+
return { quote, path: importPath, end: pos + 1 };
|
|
908
|
+
}
|
|
909
|
+
function extractDestructuringPattern(str, startPos) {
|
|
910
|
+
const openChar = str[startPos];
|
|
911
|
+
if (openChar !== "{" && openChar !== "[")
|
|
912
|
+
return null;
|
|
913
|
+
const endPos = findMatchingDelimiter(str, openChar, openChar === "{" ? "}" : "]", startPos);
|
|
914
|
+
if (endPos === -1)
|
|
915
|
+
return null;
|
|
916
|
+
return {
|
|
917
|
+
pattern: str.slice(startPos, endPos + 1),
|
|
918
|
+
endPos: endPos + 1
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
function extractDestructuredNames(pattern) {
|
|
922
|
+
const names = [], inner = pattern.slice(1, -1).trim();
|
|
923
|
+
if (!inner)
|
|
924
|
+
return names;
|
|
925
|
+
let i = 0, depth = 0, currentName = "";
|
|
926
|
+
while (i < inner.length) {
|
|
927
|
+
const char = inner[i];
|
|
928
|
+
if (char === "{" || char === "[") {
|
|
929
|
+
const nested = depth === 0 ? extractDestructuringPattern(inner, i) : null;
|
|
930
|
+
if (nested) {
|
|
931
|
+
names.push(...extractDestructuredNames(nested.pattern));
|
|
932
|
+
i = nested.endPos;
|
|
933
|
+
currentName = "";
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
depth++;
|
|
937
|
+
} else if (char === "}" || char === "]")
|
|
938
|
+
depth--;
|
|
939
|
+
if (depth > 0) {
|
|
940
|
+
i++;
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
if (char === ",") {
|
|
944
|
+
if (currentName.trim())
|
|
945
|
+
names.push(currentName.trim());
|
|
946
|
+
currentName = "";
|
|
947
|
+
i++;
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
if (char === ":") {
|
|
951
|
+
currentName = "";
|
|
952
|
+
i++;
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
if (char === "=") {
|
|
956
|
+
if (currentName.trim())
|
|
957
|
+
names.push(currentName.trim());
|
|
958
|
+
currentName = "";
|
|
959
|
+
i++;
|
|
960
|
+
while (i < inner.length && inner[i] !== "," && depth === 0) {
|
|
961
|
+
if (inner[i] === "{" || inner[i] === "[")
|
|
962
|
+
depth++;
|
|
963
|
+
else if (inner[i] === "}" || inner[i] === "]")
|
|
964
|
+
depth--;
|
|
965
|
+
i++;
|
|
966
|
+
}
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
if (/[\w$]/.test(char))
|
|
970
|
+
currentName += char;
|
|
971
|
+
i++;
|
|
972
|
+
}
|
|
973
|
+
if (currentName.trim())
|
|
974
|
+
names.push(currentName.trim());
|
|
975
|
+
return names;
|
|
976
|
+
}
|
|
977
|
+
export function splitDeclaration(line) {
|
|
978
|
+
const head = /^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(line);
|
|
979
|
+
if (!head)
|
|
980
|
+
return null;
|
|
981
|
+
let index = head[0].length;
|
|
982
|
+
const isSpace = (character) => character === " " || character === "\t";
|
|
983
|
+
while (index < line.length && isSpace(line[index]))
|
|
984
|
+
index++;
|
|
985
|
+
if (line[index] === ":") {
|
|
986
|
+
let depth = 0, quote = null;
|
|
987
|
+
index++;
|
|
988
|
+
for (;index < line.length; index++) {
|
|
989
|
+
const character = line[index];
|
|
990
|
+
if (quote) {
|
|
991
|
+
if (character === "\\") {
|
|
992
|
+
index++;
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (character === quote)
|
|
996
|
+
quote = null;
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
if (character === "'" || character === '"' || character === "`") {
|
|
1000
|
+
quote = character;
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
if (character === "(" || character === "[" || character === "{" || character === "<") {
|
|
1004
|
+
depth++;
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
if (character === ")" || character === "]" || character === "}" || character === ">") {
|
|
1008
|
+
depth--;
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
if (character === "=" && depth <= 0) {
|
|
1012
|
+
const next = line[index + 1], previous = line[index - 1];
|
|
1013
|
+
if (next !== "=" && next !== ">" && previous !== "=" && previous !== "!" && previous !== "<" && previous !== ">")
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (line[index] !== "=")
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
while (index < line.length && isSpace(line[index]))
|
|
1021
|
+
index++;
|
|
1022
|
+
if (line[index] !== "=")
|
|
1023
|
+
return null;
|
|
1024
|
+
return {
|
|
1025
|
+
type: head[1],
|
|
1026
|
+
name: head[2],
|
|
1027
|
+
value: line.slice(index + 1).trim()
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
function countPatternDepth(text, openChar, closeChar, depth) {
|
|
1031
|
+
let quote = null, escaped = !1;
|
|
1032
|
+
for (const character of text) {
|
|
1033
|
+
if (escaped) {
|
|
1034
|
+
escaped = !1;
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
if (character === "\\") {
|
|
1038
|
+
escaped = !0;
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
if (quote) {
|
|
1042
|
+
if (character === quote)
|
|
1043
|
+
quote = null;
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
if (character === "'" || character === '"' || character === "`") {
|
|
1047
|
+
quote = character;
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (character === openChar)
|
|
1051
|
+
depth++;
|
|
1052
|
+
else if (character === closeChar)
|
|
1053
|
+
depth--;
|
|
1054
|
+
}
|
|
1055
|
+
return depth;
|
|
1056
|
+
}
|
|
1057
|
+
function parseVariableDeclaration(lines, startIndex) {
|
|
1058
|
+
const firstLine = lines[startIndex].trim(), split = splitDeclaration(firstLine), match = split ? [firstLine, split.type, split.name, split.value] : null;
|
|
1059
|
+
if (!match) {
|
|
1060
|
+
const destructuringPrefix = firstLine.match(/^(?:export\s+)?(const|let|var)\s+/);
|
|
1061
|
+
if (destructuringPrefix) {
|
|
1062
|
+
let afterKeyword = firstLine.slice(destructuringPrefix[0].length), joinedEndIndex = startIndex;
|
|
1063
|
+
if (afterKeyword.startsWith("{") || afterKeyword.startsWith("[")) {
|
|
1064
|
+
const openChar = afterKeyword[0], closeChar = openChar === "{" ? "}" : "]";
|
|
1065
|
+
let depth = countPatternDepth(afterKeyword, openChar, closeChar, 0), joined = afterKeyword;
|
|
1066
|
+
for (let j = startIndex + 1;j < lines.length && depth > 0; j++) {
|
|
1067
|
+
joined += ` ${lines[j].trim()}`;
|
|
1068
|
+
joinedEndIndex = j;
|
|
1069
|
+
depth = countPatternDepth(lines[j], openChar, closeChar, depth);
|
|
1070
|
+
}
|
|
1071
|
+
if (depth > 0) {
|
|
1072
|
+
joined = afterKeyword;
|
|
1073
|
+
joinedEndIndex = startIndex;
|
|
1074
|
+
}
|
|
1075
|
+
afterKeyword = joined;
|
|
1076
|
+
}
|
|
1077
|
+
const patternResult = extractDestructuringPattern(afterKeyword, 0);
|
|
1078
|
+
if (patternResult) {
|
|
1079
|
+
const type = destructuringPrefix[1], destructuringPattern = patternResult.pattern, afterPattern = afterKeyword.slice(patternResult.endPos).trim();
|
|
1080
|
+
if (afterPattern.startsWith("=")) {
|
|
1081
|
+
const initialValue = afterPattern.slice(1).trim();
|
|
1082
|
+
let value = initialValue, currentIndex = Math.max(joinedEndIndex, startIndex);
|
|
1083
|
+
if (needsMultilineReading(initialValue)) {
|
|
1084
|
+
const result = readMultilineValue(lines, currentIndex, initialValue);
|
|
1085
|
+
value = result.value;
|
|
1086
|
+
currentIndex = result.nextIndex;
|
|
1087
|
+
} else
|
|
1088
|
+
currentIndex = currentIndex + 1;
|
|
1089
|
+
value = value.trim().replace(/;$/, "");
|
|
1090
|
+
const destructuredNames = extractDestructuredNames(destructuringPattern), uniqueName = `__stx_src_${startIndex}`, destructuredExports = destructuredNames.map((name) => `module.exports.${name} = ${name};`).join(`
|
|
1091
|
+
`);
|
|
1092
|
+
return {
|
|
1093
|
+
type,
|
|
1094
|
+
name: uniqueName,
|
|
1095
|
+
value: `${value}; ${type} ${destructuringPattern} = ${uniqueName};
|
|
1096
|
+
${destructuredExports}`,
|
|
1097
|
+
nextIndex: currentIndex
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
throw Error(`Failed to parse variable declaration: ${firstLine}`);
|
|
1103
|
+
}
|
|
1104
|
+
const [, type, name, initialValue] = match;
|
|
1105
|
+
let value = initialValue, currentIndex = startIndex;
|
|
1106
|
+
if (needsMultilineReading(initialValue)) {
|
|
1107
|
+
const result = readMultilineValue(lines, startIndex, initialValue);
|
|
1108
|
+
value = result.value;
|
|
1109
|
+
currentIndex = result.nextIndex;
|
|
1110
|
+
} else
|
|
1111
|
+
currentIndex = startIndex + 1;
|
|
1112
|
+
while (currentIndex < lines.length) {
|
|
1113
|
+
const nextLine = lines[currentIndex].trim();
|
|
1114
|
+
if (nextLine.startsWith(".") || nextLine.startsWith("?.")) {
|
|
1115
|
+
value += `
|
|
1116
|
+
${lines[currentIndex]}`;
|
|
1117
|
+
currentIndex++;
|
|
1118
|
+
} else
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
value = value.trim().replace(/;$/, "");
|
|
1122
|
+
return {
|
|
1123
|
+
type,
|
|
1124
|
+
name,
|
|
1125
|
+
value,
|
|
1126
|
+
nextIndex: currentIndex
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
function parseFunctionDeclaration(lines, startIndex) {
|
|
1130
|
+
const firstLine = lines[startIndex].trim(), match = firstLine.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);
|
|
1131
|
+
if (!match)
|
|
1132
|
+
throw Error(`Failed to parse function declaration: ${firstLine}`);
|
|
1133
|
+
const [, name] = match;
|
|
1134
|
+
let functionCode = firstLine.replace(/^export\s+/, ""), currentIndex = startIndex;
|
|
1135
|
+
if (needsMultilineFunctionReading(firstLine)) {
|
|
1136
|
+
const result = readMultilineFunction(lines, startIndex, functionCode);
|
|
1137
|
+
functionCode = result.functionCode;
|
|
1138
|
+
currentIndex = result.nextIndex;
|
|
1139
|
+
} else
|
|
1140
|
+
currentIndex = startIndex + 1;
|
|
1141
|
+
return {
|
|
1142
|
+
name,
|
|
1143
|
+
functionCode,
|
|
1144
|
+
nextIndex: currentIndex
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function needsMultilineReading(value) {
|
|
1148
|
+
const trimmed = value.trim();
|
|
1149
|
+
if (trimmed.startsWith("{"))
|
|
1150
|
+
return findMatchingDelimiter(trimmed, "{", "}", 0) === -1;
|
|
1151
|
+
if (trimmed.startsWith("["))
|
|
1152
|
+
return findMatchingDelimiter(trimmed, "[", "]", 0) === -1;
|
|
1153
|
+
return !isValueComplete(trimmed);
|
|
1154
|
+
}
|
|
1155
|
+
function isValueComplete(value) {
|
|
1156
|
+
const depth = { paren: 0, bracket: 0, brace: 0 };
|
|
1157
|
+
let inString = null, inTemplateExpr = 0;
|
|
1158
|
+
for (let i = 0;i < value.length; i++) {
|
|
1159
|
+
const char = value[i];
|
|
1160
|
+
if ((i > 0 ? value[i - 1] : "") === "\\" && inString)
|
|
1161
|
+
continue;
|
|
1162
|
+
if ((char === '"' || char === "'") && !inString) {
|
|
1163
|
+
inString = char;
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (char === inString && inString !== "`") {
|
|
1167
|
+
inString = null;
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
if (char === "`" && !inString) {
|
|
1171
|
+
inString = "`";
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
if (char === "`" && inString === "`" && inTemplateExpr === 0) {
|
|
1175
|
+
inString = null;
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
if (inString === "`" && char === "$" && value[i + 1] === "{") {
|
|
1179
|
+
inTemplateExpr++;
|
|
1180
|
+
i++;
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (inTemplateExpr > 0 && char === "{") {
|
|
1184
|
+
inTemplateExpr++;
|
|
1185
|
+
continue;
|
|
1186
|
+
}
|
|
1187
|
+
if (inTemplateExpr > 0 && char === "}") {
|
|
1188
|
+
inTemplateExpr--;
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
if (inString)
|
|
1192
|
+
continue;
|
|
1193
|
+
if (char === "(")
|
|
1194
|
+
depth.paren++;
|
|
1195
|
+
else if (char === ")")
|
|
1196
|
+
depth.paren--;
|
|
1197
|
+
else if (char === "[")
|
|
1198
|
+
depth.bracket++;
|
|
1199
|
+
else if (char === "]")
|
|
1200
|
+
depth.bracket--;
|
|
1201
|
+
else if (char === "{")
|
|
1202
|
+
depth.brace++;
|
|
1203
|
+
else if (char === "}")
|
|
1204
|
+
depth.brace--;
|
|
1205
|
+
}
|
|
1206
|
+
return depth.paren === 0 && depth.bracket === 0 && depth.brace === 0 && inString === null;
|
|
1207
|
+
}
|
|
1208
|
+
function findFunctionBodyBrace(functionLine) {
|
|
1209
|
+
const parenPos = functionLine.indexOf("(");
|
|
1210
|
+
if (parenPos === -1)
|
|
1211
|
+
return functionLine.indexOf("{");
|
|
1212
|
+
const paramsEnd = findMatchingDelimiter(functionLine, "(", ")", parenPos);
|
|
1213
|
+
if (paramsEnd === -1)
|
|
1214
|
+
return -1;
|
|
1215
|
+
return functionLine.indexOf("{", paramsEnd);
|
|
1216
|
+
}
|
|
1217
|
+
function needsMultilineFunctionReading(functionLine) {
|
|
1218
|
+
const bracePos = findFunctionBodyBrace(functionLine);
|
|
1219
|
+
if (bracePos === -1)
|
|
1220
|
+
return !0;
|
|
1221
|
+
return findMatchingDelimiter(functionLine, "{", "}", bracePos) === -1;
|
|
1222
|
+
}
|
|
1223
|
+
function readMultilineValue(lines, startIndex, initialValue) {
|
|
1224
|
+
let value = initialValue, i = startIndex + 1;
|
|
1225
|
+
while (i < lines.length && !isValueComplete(value)) {
|
|
1226
|
+
const nextLine = lines[i];
|
|
1227
|
+
value += `
|
|
1228
|
+
${nextLine}`;
|
|
1229
|
+
i++;
|
|
1230
|
+
}
|
|
1231
|
+
while (i < lines.length) {
|
|
1232
|
+
const nextLine = lines[i].trim();
|
|
1233
|
+
if (nextLine.startsWith(".") || nextLine.startsWith("?.")) {
|
|
1234
|
+
value += `
|
|
1235
|
+
${lines[i]}`;
|
|
1236
|
+
i++;
|
|
1237
|
+
} else
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
return { value, nextIndex: i };
|
|
1241
|
+
}
|
|
1242
|
+
function readMultilineFunction(lines, startIndex, initialFunction) {
|
|
1243
|
+
let functionCode = initialFunction, i = startIndex + 1;
|
|
1244
|
+
while (i < lines.length) {
|
|
1245
|
+
const bracePos = findFunctionBodyBrace(functionCode);
|
|
1246
|
+
if (bracePos !== -1) {
|
|
1247
|
+
if (findMatchingDelimiter(functionCode, "{", "}", bracePos) !== -1)
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
const nextLine = lines[i];
|
|
1251
|
+
functionCode += `
|
|
1252
|
+
${nextLine}`;
|
|
1253
|
+
i++;
|
|
1254
|
+
}
|
|
1255
|
+
return { functionCode, nextIndex: i };
|
|
1256
|
+
}
|
|
1257
|
+
function evaluateFallbackExpression(expression, context) {
|
|
1258
|
+
const direct = safeEvaluate(expression, context) ?? safeEvaluate(`(${expression})`, context);
|
|
1259
|
+
if (direct !== void 0)
|
|
1260
|
+
return direct;
|
|
1261
|
+
if (!/\bprocess\b/.test(expression))
|
|
1262
|
+
return;
|
|
1263
|
+
const processEnvContext = { ...context, process: Object.freeze({ env: { ...process.env } }) }, envKeys = Object.keys(processEnvContext).filter(isUsableParamName), envValues = envKeys.map((key) => processEnvContext[key]);
|
|
1264
|
+
try {
|
|
1265
|
+
return Function(...envKeys, `'use strict'; return (${expression});`)(...envValues);
|
|
1266
|
+
} catch {
|
|
1267
|
+
try {
|
|
1268
|
+
return Function(...envKeys, `'use strict'; return ${expression};`)(...envValues);
|
|
1269
|
+
} catch {
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
async function fallbackVariableExtraction(scriptContent, context, _filePath) {
|
|
1275
|
+
const exportMatches = scriptContent.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);
|
|
1276
|
+
for (const match of exportMatches) {
|
|
1277
|
+
const [, , name, value] = match;
|
|
1278
|
+
try {
|
|
1279
|
+
const cleanValue = value.trim().replace(/;$/, ""), evaluated = evaluateFallbackExpression(cleanValue, context);
|
|
1280
|
+
if (evaluated !== void 0)
|
|
1281
|
+
context[name] = evaluated;
|
|
1282
|
+
} catch (e2) {
|
|
1283
|
+
console.warn(`Failed to parse export ${name} in fallback:`, e2);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
const varMatches = scriptContent.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);
|
|
1287
|
+
for (const match of varMatches) {
|
|
1288
|
+
const [, , name, value] = match;
|
|
1289
|
+
if (!(name in context))
|
|
1290
|
+
try {
|
|
1291
|
+
const cleanValue = value.trim().replace(/;$/, ""), evaluated = evaluateFallbackExpression(cleanValue, context);
|
|
1292
|
+
if (evaluated !== void 0)
|
|
1293
|
+
context[name] = evaluated;
|
|
1294
|
+
} catch {}
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
export function extractScriptFromTemplate(template) {
|
|
1298
|
+
const scriptMatch = template.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i), scriptContent = scriptMatch ? scriptMatch[1] : "", templateWithoutScript = scriptMatch ? template.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i, "") : template;
|
|
1299
|
+
return { scriptContent, templateWithoutScript };
|
|
1300
|
+
}
|
|
1301
|
+
export function hasVariables(scriptContent) {
|
|
1302
|
+
const trimmed = scriptContent.trim();
|
|
1303
|
+
if (!trimmed)
|
|
1304
|
+
return !1;
|
|
1305
|
+
return /(?:const|let|var|function)\s+\w+/.test(trimmed);
|
|
1306
|
+
}
|