@stacksjs/stx 0.2.94 → 0.2.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y.js +598 -2
- package/dist/analytics.js +159 -2
- package/dist/analyzer.js +240 -2
- package/dist/animation.js +688 -2
- package/dist/app-shell.js +220 -2
- package/dist/app.js +79 -2
- package/dist/assets.js +155 -2
- package/dist/ast.js +630 -2
- package/dist/async-components.js +428 -2
- package/dist/auth.js +12 -2
- package/dist/broadcasting.js +102 -2
- package/dist/browser-composables.js +565 -2
- package/dist/build-assets.js +29 -2
- package/dist/build-mode-detector.js +50 -2
- package/dist/build-optimizer.js +433 -2
- package/dist/build-views.js +180 -2
- package/dist/build.js +33 -2
- package/dist/builtins/drawer.js +37 -2
- package/dist/builtins/escape.js +3 -2
- package/dist/builtins/icon.js +83 -2
- package/dist/builtins/index.js +34 -2
- package/dist/builtins/modal.js +38 -2
- package/dist/builtins/safe-image.js +51 -2
- package/dist/builtins/stx-image.js +200 -2
- package/dist/builtins/stx-link.js +41 -2
- package/dist/builtins/stx-loading-indicator.js +35 -2
- package/dist/builtins/suspense.js +24 -2
- package/dist/builtins/toast.js +42 -2
- package/dist/builtins/tooltip.js +106 -2
- package/dist/builtins/transition-group.js +22 -2
- package/dist/bundle-analyzer/collector.js +233 -2
- package/dist/bundle-analyzer/index.js +82 -2
- package/dist/bundle-analyzer/report.js +318 -2
- package/dist/bundle-analyzer/treemap.js +594 -2
- package/dist/caching.js +131 -2
- package/dist/cli.js +11317 -10982
- package/dist/client/directive.js +14 -2
- package/dist/client/index.js +2 -2
- package/dist/client-helpers.js +312 -2
- package/dist/client-script-bundler.js +216 -6
- package/dist/client-script.js +754 -2
- package/dist/client.js +73 -4
- package/dist/component-hmr.js +585 -2
- package/dist/component-library.d.ts +6 -0
- package/dist/component-library.js +683 -0
- package/dist/component-processing.js +613 -2
- package/dist/component-registry.js +90 -2
- package/dist/component-renderer.js +660 -2
- package/dist/components.js +213 -2
- package/dist/composables/index.js +220 -2
- package/dist/composables/use-battery.js +101 -2
- package/dist/composables/use-broadcast-channel.js +80 -2
- package/dist/composables/use-channel.js +124 -2
- package/dist/composables/use-clipboard.js +79 -2
- package/dist/composables/use-color-mode.js +131 -2
- package/dist/composables/use-cookie.js +86 -2
- package/dist/composables/use-device-orientation.js +181 -2
- package/dist/composables/use-event-listener.js +27 -2
- package/dist/composables/use-event-source.js +166 -2
- package/dist/composables/use-eye-dropper.js +142 -2
- package/dist/composables/use-fetch.js +223 -2
- package/dist/composables/use-fullscreen.js +110 -2
- package/dist/composables/use-geolocation.js +101 -2
- package/dist/composables/use-idle.js +182 -2
- package/dist/composables/use-intersection-observer.js +168 -2
- package/dist/composables/use-keyboard.js +224 -2
- package/dist/composables/use-media-query.js +62 -2
- package/dist/composables/use-meta.js +48 -2
- package/dist/composables/use-mouse.js +286 -2
- package/dist/composables/use-mutation-observer.js +129 -2
- package/dist/composables/use-network.js +85 -2
- package/dist/composables/use-notification.js +94 -2
- package/dist/composables/use-permissions.js +132 -2
- package/dist/composables/use-query.js +0 -1
- package/dist/composables/use-resize-observer.js +157 -2
- package/dist/composables/use-router.js +51 -2
- package/dist/composables/use-share.js +104 -2
- package/dist/composables/use-speech.js +294 -2
- package/dist/composables/use-storage.js +130 -2
- package/dist/composables/use-text-selection.js +205 -4
- package/dist/composables/use-timer.js +183 -2
- package/dist/composables/use-utilities.js +176 -2
- package/dist/composables/use-wake-lock.js +122 -2
- package/dist/composables/use-websocket.js +165 -2
- package/dist/composables/use-window.js +163 -2
- package/dist/composables.js +552 -2
- package/dist/composition-api.js +190 -2
- package/dist/computed.js +376 -8
- package/dist/conditionals.js +599 -2
- package/dist/config.js +751 -2
- package/dist/craft-bridge.js +432 -2
- package/dist/craft-compiler.js +810 -2
- package/dist/craft-components.js +945 -2
- package/dist/craft-entry.js +5 -2
- package/dist/craft-ssr.js +559 -2
- package/dist/csp.js +220 -2
- package/dist/csrf.js +38 -2
- package/dist/custom-directives.js +136 -2
- package/dist/defer.js +156 -2
- package/dist/deploy/config-generators.js +214 -2
- package/dist/deploy/index.js +203 -2
- package/dist/deploy/netlify.js +167 -2
- package/dist/dev-server/crosswind.js +379 -2
- package/dist/dev-server/index.js +7 -2
- package/dist/dev-server/keyboard-shortcuts.js +81 -2
- package/dist/dev-server/native-window.js +91 -2
- package/dist/dev-server/port-utils.js +40 -2
- package/dist/dev-server/serve-app.js +682 -7
- package/dist/dev-server/serve-file.js +439 -7
- package/dist/dev-server/serve-markdown.js +281 -2
- package/dist/dev-server/serve-multi.js +424 -17
- package/dist/dev-server/terminal-colors.js +45 -2
- package/dist/dev-server/theme-selector.js +111 -2
- package/dist/dev-server/types.js +43 -2
- package/dist/dev-server.js +4 -2
- package/dist/devtools.js +462 -18
- package/dist/directive-api.js +355 -2
- package/dist/docs.js +567 -2
- package/dist/doctor.js +123 -2
- package/dist/document-shell.js +105 -2
- package/dist/dynamic-components.js +78 -2
- package/dist/edge-runtime.js +539 -2
- package/dist/env.js +9 -2
- package/dist/error-boundaries.js +62 -12
- package/dist/error-handling.js +1 -2
- package/dist/errors/codes.js +97 -2
- package/dist/errors/formatter.js +196 -2
- package/dist/errors/index.js +44 -2
- package/dist/errors/logger.js +250 -2
- package/dist/errors/sanitizer.js +181 -2
- package/dist/errors/types.js +86 -2
- package/dist/events.js +382 -2
- package/dist/expressions.js +650 -2
- package/dist/formatter.js +265 -2
- package/dist/forms-validation.js +510 -4
- package/dist/forms.js +709 -2
- package/dist/head.js +224 -2
- package/dist/heatmap.js +566 -2
- package/dist/hot-reload.js +367 -2
- package/dist/html-masking.js +73 -2
- package/dist/hydration-runtime.js +195 -2
- package/dist/hydration.js +654 -2
- package/dist/i18n.js +633 -2
- package/dist/image-optimization/auto-sibling.js +88 -2
- package/dist/image-optimization/build-plugin.js +241 -2
- package/dist/image-optimization/component.js +244 -2
- package/dist/image-optimization/directive.js +203 -2
- package/dist/image-optimization/index.js +54 -2
- package/dist/image-optimization/processor.js +262 -2
- package/dist/image-optimization/serve.js +102 -2
- package/dist/includes.js +733 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +134 -2
- package/dist/init.js +505 -2
- package/dist/inline-assets.js +82 -2
- package/dist/interactive.js +383 -2
- package/dist/internal-markdown.js +141 -2
- package/dist/island-chunking.js +52 -2
- package/dist/js-ts.js +57 -2
- package/dist/jsx-runtime.js +289 -2
- package/dist/keep-alive.js +421 -2
- package/dist/lazy-loader.js +245 -2
- package/dist/loading-indicator.js +322 -2
- package/dist/loops.js +643 -2
- package/dist/manifest.js +31 -2
- package/dist/markdown.js +68 -2
- package/dist/media/client/blur-up.js +217 -2
- package/dist/media/client/index.js +53 -2
- package/dist/media/client/lazy-load.js +283 -2
- package/dist/media/client/upload-handler.js +354 -2
- package/dist/media/image/component.js +574 -2
- package/dist/media/image/directive.js +160 -2
- package/dist/media/image/editing.js +193 -2
- package/dist/media/image/index.js +80 -2
- package/dist/media/image/placeholder.js +188 -2
- package/dist/media/image/processor/cache.js +51 -2
- package/dist/media/image/processor/index.js +3 -2
- package/dist/media/image/processor/optimizer.js +202 -2
- package/dist/media/image/processor/responsive.js +162 -2
- package/dist/media/image/srcset.js +194 -2
- package/dist/media/index.js +198 -2
- package/dist/media/manager/embed.js +253 -2
- package/dist/media/protected/component.js +235 -2
- package/dist/media/protected/index.js +20 -2
- package/dist/media/protected/signature.js +205 -2
- package/dist/media/shared/cache.js +132 -2
- package/dist/media/shared/hash.js +35 -2
- package/dist/media/shared/index.js +2 -2
- package/dist/media/types.js +0 -1
- package/dist/media/upload/component.js +320 -2
- package/dist/media/upload/index.js +1 -2
- package/dist/media/video/directive.js +142 -2
- package/dist/media/video/index.js +583 -2
- package/dist/media/video/processor/cache.js +52 -2
- package/dist/media/video/processor/index.js +4 -2
- package/dist/media/video/processor/streaming.js +197 -2
- package/dist/media/video/processor/thumbnail.js +134 -2
- package/dist/media/video/processor/transcoder.js +283 -2
- package/dist/method-spoofing.js +17 -2
- package/dist/middleware.js +40 -2
- package/dist/misc-directives.js +222 -2
- package/dist/native-build.js +511 -2
- package/dist/parser/directive-parser.js +239 -2
- package/dist/parser/expression-parser.js +358 -2
- package/dist/parser/index.js +23 -2
- package/dist/parser/tokenizer.js +534 -2
- package/dist/partial-hydration.js +427 -2
- package/dist/performance-utils.js +430 -2
- package/dist/placeholder.js +35 -2
- package/dist/plugin-system.js +214 -2
- package/dist/plugin.js +173 -2
- package/dist/precompiler.js +660 -81
- package/dist/process.js +711 -2
- package/dist/production-build.js +596 -2
- package/dist/production-builder.js +132 -2
- package/dist/production-server.js +188 -2
- package/dist/props.js +224 -2
- package/dist/public-env.js +19 -2
- package/dist/pwa/audit.js +255 -2
- package/dist/pwa/directives.js +332 -2
- package/dist/pwa/icons.js +109 -2
- package/dist/pwa/index.js +47 -2
- package/dist/pwa/inject.js +102 -2
- package/dist/pwa/manifest.js +186 -2
- package/dist/pwa/offline.js +259 -2
- package/dist/pwa/precache.js +116 -2
- package/dist/pwa/service-worker.js +860 -2
- package/dist/pwa/workbox-strategies.js +167 -2
- package/dist/pwa/workbox.js +382 -2
- package/dist/pwa.js +427 -427
- package/dist/reactive-bindings.js +266 -2
- package/dist/reactive.js +569 -2
- package/dist/reactivity.js +559 -2
- package/dist/release.js +1 -2
- package/dist/render.js +165 -2
- package/dist/route-middleware.js +17 -2
- package/dist/router.js +9 -2
- package/dist/routes.js +14 -2
- package/dist/runtime-injection.js +120 -2
- package/dist/runtime.js +94 -2
- package/dist/safe-evaluator.js +444 -2
- package/dist/scaffolding.js +897 -2
- package/dist/screenshot.js +87 -2
- package/dist/script-classifier.js +32 -2
- package/dist/script-validation.js +158 -2
- package/dist/seo.js +457 -2
- package/dist/serve.js +237 -2
- package/dist/server-bindings.js +108 -2
- package/dist/server-components.js +338 -11
- package/dist/signal-processing.js +946 -2
- package/dist/signals-api.js +154 -2
- package/dist/signals.js +5287 -2
- package/dist/site-builder/build.js +224 -2
- package/dist/site-builder/i18n.js +140 -2
- package/dist/site-builder/index.js +15 -2
- package/dist/site-builder/robots.js +26 -2
- package/dist/site-builder/router.js +27 -2
- package/dist/site-builder/seo.js +36 -2
- package/dist/site-builder/sitemap.js +26 -2
- package/dist/site-builder/theme.js +33 -2
- package/dist/site-builder/types.js +0 -1
- package/dist/slots.js +201 -2
- package/dist/source-maps.js +350 -2
- package/dist/spa-shell.js +34 -2
- package/dist/ssg.js +389 -389
- package/dist/ssr.js +355 -2
- package/dist/state-management.js +533 -2
- package/dist/store-imports.js +13 -2
- package/dist/store-loader.js +72 -5
- package/dist/stores-client.js +132 -2
- package/dist/story/addons.js +261 -2
- package/dist/story/analytics.js +235 -2
- package/dist/story/auto-stories.js +158 -2
- package/dist/story/bookmarks.js +277 -2
- package/dist/story/bun-test.js +102 -2
- package/dist/story/cli.js +155 -2
- package/dist/story/collect/analyzer.js +305 -2
- package/dist/story/collect/index.js +27 -2
- package/dist/story/collect/parser.js +129 -2
- package/dist/story/collect/scanner.js +101 -2
- package/dist/story/collect/tree.js +110 -2
- package/dist/story/commands/build.js +172 -2
- package/dist/story/commands/dev.js +78 -2
- package/dist/story/commands/index.js +3 -2
- package/dist/story/commands/preview.js +56 -2
- package/dist/story/compiled-output.js +151 -2
- package/dist/story/composition.js +261 -2
- package/dist/story/config-watcher.js +67 -2
- package/dist/story/config.js +64 -2
- package/dist/story/context.js +27 -2
- package/dist/story/controls/index.js +320 -2
- package/dist/story/crosswind.js +189 -2
- package/dist/story/desktop-preview.js +105 -2
- package/dist/story/docs-generator.js +186 -2
- package/dist/story/errors.js +239 -2
- package/dist/story/figma-export.js +224 -2
- package/dist/story/generator.js +165 -2
- package/dist/story/hmr.js +131 -2
- package/dist/story/hot-swap.js +207 -2
- package/dist/story/index.js +49 -2
- package/dist/story/interactions.js +225 -2
- package/dist/story/keyboard-shortcuts.js +345 -2
- package/dist/story/output.js +153 -2
- package/dist/story/performance.js +252 -2
- package/dist/story/presets.js +289 -2
- package/dist/story/props-validation.js +215 -2
- package/dist/story/renderer.js +209 -2
- package/dist/story/search-index.js +106 -2
- package/dist/story/search.js +140 -2
- package/dist/story/server.js +965 -2
- package/dist/story/setup.js +78 -2
- package/dist/story/snapshots.js +170 -2
- package/dist/story/testing.js +163 -2
- package/dist/story/theme.js +170 -2
- package/dist/story/types.js +0 -2
- package/dist/story/ui/code-panel.js +175 -2
- package/dist/story/ui/controls-panel.js +168 -2
- package/dist/story/ui/index.js +4 -2
- package/dist/story/ui/navigation.js +250 -2
- package/dist/story/ui/preview.js +251 -2
- package/dist/story/visual-testing.js +247 -2
- package/dist/streaming.js +537 -2
- package/dist/strict-lint.js +288 -2
- package/dist/style-scoping.js +50 -2
- package/dist/suspense.js +398 -2
- package/dist/teleport.js +109 -2
- package/dist/template-compiler.js +63 -2
- package/dist/template-hydrator.js +82 -2
- package/dist/template-tag-balance.js +93 -2
- package/dist/testing.js +581 -2
- package/dist/transitions.js +443 -2
- package/dist/type-checker.js +581 -2
- package/dist/types/component-types.d.ts +54 -0
- package/dist/types/component-types.js +0 -1
- package/dist/types/config-types.js +0 -1
- package/dist/types/context-types.js +0 -1
- package/dist/types/csp-types.js +0 -1
- package/dist/types/directive-types.js +3 -2
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +1 -2
- package/dist/types/pwa-types.js +0 -1
- package/dist/types.js +1 -2
- package/dist/typescript-templates.js +386 -4
- package/dist/utils.js +942 -2
- package/dist/validator.js +171 -2
- package/dist/variable-extractor.js +1094 -2
- package/dist/view-composers.js +29 -2
- package/dist/virtual-scrolling.js +454 -2
- package/dist/visual-editor.js +688 -28
- package/dist/vue-template.js +475 -2
- package/dist/web-components/css-scoping.js +177 -2
- package/dist/web-components/index.js +13 -2
- package/dist/web-components/reactive-generator.js +121 -56
- package/dist/web-components.js +1447 -2
- package/dist/x-element.js +17 -5
- package/package.json +6 -7
- package/dist/chunk-03c26pjz.js +0 -3
- package/dist/chunk-04mvcmcr.js +0 -106
- package/dist/chunk-05hgyyqc.js +0 -4
- package/dist/chunk-095s3972.js +0 -99
- package/dist/chunk-0b9w2w1y.js +0 -1
- package/dist/chunk-0dz85jrp.js +0 -3
- package/dist/chunk-0g4gece6.js +0 -4
- package/dist/chunk-0jd0pndq.js +0 -3
- package/dist/chunk-0jkwrcwj.js +0 -3
- package/dist/chunk-0m9tdm7t.js +0 -71
- package/dist/chunk-0qakwen3.js +0 -1
- package/dist/chunk-0qnz93q2.js +0 -3
- package/dist/chunk-0tatqxj2.js +0 -57
- package/dist/chunk-0wdar532.js +0 -102
- package/dist/chunk-13yz561y.js +0 -3
- package/dist/chunk-174z0cd0.js +0 -3
- package/dist/chunk-1mmykse5.js +0 -81
- package/dist/chunk-1z2yq9em.js +0 -3
- package/dist/chunk-1z5nhbjt.js +0 -90
- package/dist/chunk-1zgsgk4b.js +0 -1
- package/dist/chunk-25s7bckb.js +0 -171
- package/dist/chunk-268adc7r.js +0 -2230
- package/dist/chunk-26r6zh3t.js +0 -194
- package/dist/chunk-2w3302dh.js +0 -3
- package/dist/chunk-2xen423s.js +0 -3
- package/dist/chunk-39gm08bn.js +0 -39
- package/dist/chunk-3bjtemm6.js +0 -128
- package/dist/chunk-3jm3snz8.js +0 -3
- package/dist/chunk-3ngm57nt.js +0 -12
- package/dist/chunk-3rh7va1z.js +0 -3
- package/dist/chunk-3yg9hbmb.js +0 -4
- package/dist/chunk-44hd3kab.js +0 -1
- package/dist/chunk-46mkpbkk.js +0 -12
- package/dist/chunk-48cw2nde.js +0 -2
- package/dist/chunk-48r3qe0k.js +0 -3
- package/dist/chunk-4aj7ftqb.js +0 -1
- package/dist/chunk-4bt81cg3.js +0 -61
- package/dist/chunk-4j188175.js +0 -3
- package/dist/chunk-4k7d8p8d.js +0 -188
- package/dist/chunk-4qq8ffke.js +0 -28
- package/dist/chunk-50vqeesm.js +0 -142
- package/dist/chunk-52agge4n.js +0 -38
- package/dist/chunk-55yp0q8t.js +0 -201
- package/dist/chunk-57p201gb.js +0 -83
- package/dist/chunk-5ggw1dyv.js +0 -3
- package/dist/chunk-5kt3ay7x.js +0 -10
- package/dist/chunk-5p568px4.js +0 -1166
- package/dist/chunk-5ppkfyn2.js +0 -3
- package/dist/chunk-5q87fgkk.js +0 -3
- package/dist/chunk-5qb761h2.js +0 -3
- package/dist/chunk-5xvbq2gs.js +0 -30
- package/dist/chunk-647849kf.js +0 -34
- package/dist/chunk-6b5k6w2q.js +0 -7
- package/dist/chunk-6cr3eeh4.js +0 -23
- package/dist/chunk-6djgb0hr.js +0 -3
- package/dist/chunk-6dqzky7x.js +0 -35
- package/dist/chunk-6e4c6g46.js +0 -3
- package/dist/chunk-6w03t7h6.js +0 -3
- package/dist/chunk-6wn85hn6.js +0 -4
- package/dist/chunk-6y4gqs1q.js +0 -169
- package/dist/chunk-75rndzbd.js +0 -6
- package/dist/chunk-77tga15w.js +0 -3
- package/dist/chunk-7a51hkpf.js +0 -3
- package/dist/chunk-7b0xdy5h.js +0 -386
- package/dist/chunk-7cgmq685.js +0 -33
- package/dist/chunk-7dy588as.js +0 -6
- package/dist/chunk-7rvh2wwv.js +0 -721
- package/dist/chunk-7sm05m0j.js +0 -351
- package/dist/chunk-7sqdeqsw.js +0 -1
- package/dist/chunk-7xcfy2fn.js +0 -4
- package/dist/chunk-82t27pvd.js +0 -5
- package/dist/chunk-87kx8byz.js +0 -1115
- package/dist/chunk-8fgwhhb8.js +0 -6
- package/dist/chunk-8qbax8xn.js +0 -347
- package/dist/chunk-91s2hres.js +0 -8
- package/dist/chunk-94g3cahw.js +0 -11
- package/dist/chunk-957amb71.js +0 -8
- package/dist/chunk-95w08s8v.js +0 -3
- package/dist/chunk-9agvhp1x.js +0 -93
- package/dist/chunk-9tmbrwwx.js +0 -219
- package/dist/chunk-9yz5d003.js +0 -51
- package/dist/chunk-a3hyn4we.js +0 -79
- package/dist/chunk-a69tvya5.js +0 -53
- package/dist/chunk-adjcg6wa.js +0 -498
- package/dist/chunk-adqh2m9z.js +0 -45
- package/dist/chunk-asarebzq.js +0 -292
- package/dist/chunk-aw3rp9ac.js +0 -24
- package/dist/chunk-b0cyc09a.js +0 -109
- package/dist/chunk-b3kkjcdh.js +0 -3
- package/dist/chunk-b3prs7y0.js +0 -5
- package/dist/chunk-b5zc9y0y.js +0 -90
- package/dist/chunk-baa7h4yz.js +0 -3
- package/dist/chunk-bgec9r1v.js +0 -5224
- package/dist/chunk-bjnjpsgn.js +0 -3
- package/dist/chunk-bk8ew8ze.js +0 -24
- package/dist/chunk-bn08k7yy.js +0 -3
- package/dist/chunk-bpgg59wa.js +0 -3
- package/dist/chunk-bwxda6n1.js +0 -3
- package/dist/chunk-bykjk6vj.js +0 -4
- package/dist/chunk-c53hyw5c.js +0 -477
- package/dist/chunk-c7jg8w13.js +0 -3
- package/dist/chunk-ca6qd1dx.js +0 -3
- package/dist/chunk-cdbwprfv.js +0 -6
- package/dist/chunk-ceg2c2q2.js +0 -11
- package/dist/chunk-cn409b69.js +0 -3
- package/dist/chunk-cn8az1b4.js +0 -1
- package/dist/chunk-cp3kwv17.js +0 -8
- package/dist/chunk-cpcc11vp.js +0 -5
- package/dist/chunk-cr3wbrcr.js +0 -10
- package/dist/chunk-cygfdk1n.js +0 -3
- package/dist/chunk-cyp4m0vh.js +0 -16
- package/dist/chunk-cz25azze.js +0 -4
- package/dist/chunk-d77yxcds.js +0 -3
- package/dist/chunk-dvfs1h3c.js +0 -117
- package/dist/chunk-dyjnn5k8.js +0 -262
- package/dist/chunk-dzw95th7.js +0 -3
- package/dist/chunk-e0zytzdh.js +0 -179
- package/dist/chunk-e53h9qhd.js +0 -84
- package/dist/chunk-eds0f8f1.js +0 -3
- package/dist/chunk-eh8hact1.js +0 -5
- package/dist/chunk-epj957jf.js +0 -4
- package/dist/chunk-eqeyaq6g.js +0 -77
- package/dist/chunk-fbxt2mrx.js +0 -5
- package/dist/chunk-fch9tk1k.js +0 -3
- package/dist/chunk-fe7r1mq1.js +0 -9
- package/dist/chunk-fhawx87n.js +0 -8
- package/dist/chunk-fk51yyrw.js +0 -3
- package/dist/chunk-fms20x0n.js +0 -21
- package/dist/chunk-fs0qezn5.js +0 -341
- package/dist/chunk-fzm3y0r3.js +0 -267
- package/dist/chunk-g2hekckm.js +0 -161
- package/dist/chunk-g4ps1dj8.js +0 -140
- package/dist/chunk-g8b81pzc.js +0 -3
- package/dist/chunk-ganag9dm.js +0 -3
- package/dist/chunk-gc84b1d2.js +0 -58
- package/dist/chunk-gcf5v18y.js +0 -60
- package/dist/chunk-ghrx0hn1.js +0 -4
- package/dist/chunk-gqpkp459.js +0 -3
- package/dist/chunk-h45py5w5.js +0 -2
- package/dist/chunk-h5wa62ek.js +0 -145
- package/dist/chunk-h82kjdr4.js +0 -83
- package/dist/chunk-haecq01c.js +0 -3
- package/dist/chunk-hepg894w.js +0 -3
- package/dist/chunk-hjdc99kb.js +0 -3
- package/dist/chunk-hje9v2zh.js +0 -3
- package/dist/chunk-hjv76kcw.js +0 -1
- package/dist/chunk-hke99a0v.js +0 -3
- package/dist/chunk-hpqr9e3x.js +0 -3
- package/dist/chunk-hq5cem49.js +0 -236
- package/dist/chunk-hrampcrj.js +0 -3
- package/dist/chunk-ht4j68cs.js +0 -3
- package/dist/chunk-hxx3za24.js +0 -62
- package/dist/chunk-j4s5qwd7.js +0 -4
- package/dist/chunk-jbejwejg.js +0 -8
- package/dist/chunk-jc0fc4ht.js +0 -11
- package/dist/chunk-jcs0ymw7.js +0 -3
- package/dist/chunk-jfm69keq.js +0 -231
- package/dist/chunk-jfrn43vh.js +0 -2
- package/dist/chunk-jjamhxpm.js +0 -139
- package/dist/chunk-jjvp4t5w.js +0 -27
- package/dist/chunk-jt44av4j.js +0 -3
- package/dist/chunk-jt98jhpt.js +0 -10
- package/dist/chunk-k8440jxh.js +0 -6
- package/dist/chunk-kdxa9epn.js +0 -21
- package/dist/chunk-kfd2hf6f.js +0 -3
- package/dist/chunk-kgym7ch9.js +0 -8
- package/dist/chunk-kh6rfz2v.js +0 -4
- package/dist/chunk-kkp6rs2n.js +0 -36
- package/dist/chunk-ktkmvaa8.js +0 -1
- package/dist/chunk-m59y310j.js +0 -3
- package/dist/chunk-mgmyr1b9.js +0 -6
- package/dist/chunk-mqwbpamc.js +0 -3
- package/dist/chunk-mrehzhxv.js +0 -5
- package/dist/chunk-mv03qb75.js +0 -3
- package/dist/chunk-mv4fb50w.js +0 -1
- package/dist/chunk-mwbng54r.js +0 -2
- package/dist/chunk-n46a5g1g.js +0 -3
- package/dist/chunk-n944baxp.js +0 -3
- package/dist/chunk-nanw7yhz.js +0 -14
- package/dist/chunk-nap11ntr.js +0 -21
- package/dist/chunk-ncnfa8ae.js +0 -29
- package/dist/chunk-ngxfwzq3.js +0 -3
- package/dist/chunk-nvwb4x04.js +0 -3
- package/dist/chunk-nw34xajc.js +0 -8
- package/dist/chunk-payfb24w.js +0 -207
- package/dist/chunk-pc31m5x5.js +0 -398
- package/dist/chunk-pg1fvqb9.js +0 -167
- package/dist/chunk-q60knhjf.js +0 -3
- package/dist/chunk-q6h6yvzb.js +0 -10
- package/dist/chunk-qd5461tt.js +0 -3
- package/dist/chunk-qdc3aav1.js +0 -3
- package/dist/chunk-qfwzdffx.js +0 -3
- package/dist/chunk-qgxwmagw.js +0 -134
- package/dist/chunk-qhdtssn1.js +0 -19
- package/dist/chunk-qk584whs.js +0 -3
- package/dist/chunk-qm4yppj5.js +0 -57
- package/dist/chunk-qwyd9a1d.js +0 -2
- package/dist/chunk-qxs6et76.js +0 -196
- package/dist/chunk-rb1e4cnb.js +0 -3
- package/dist/chunk-rh80q1nd.js +0 -1
- package/dist/chunk-rkffm9sy.js +0 -128
- package/dist/chunk-rv002yn0.js +0 -14
- package/dist/chunk-s6ja2bdg.js +0 -66
- package/dist/chunk-sjagg9qz.js +0 -66
- package/dist/chunk-sn07azv3.js +0 -3
- package/dist/chunk-svahbw0w.js +0 -12
- package/dist/chunk-svhtdb0s.js +0 -6
- package/dist/chunk-t37dp99j.js +0 -3
- package/dist/chunk-tj6zfxeb.js +0 -64
- package/dist/chunk-tmgz5t2g.js +0 -3
- package/dist/chunk-tr0z0e1g.js +0 -3
- package/dist/chunk-tx6br9r4.js +0 -274
- package/dist/chunk-v97390pe.js +0 -1
- package/dist/chunk-vcr5pzpx.js +0 -233
- package/dist/chunk-vdfwv0fp.js +0 -6
- package/dist/chunk-vp2395eb.js +0 -3
- package/dist/chunk-vpe6napb.js +0 -28
- package/dist/chunk-vv9wfz1c.js +0 -12
- package/dist/chunk-vw6ejgmy.js +0 -21
- package/dist/chunk-vx22he47.js +0 -1
- package/dist/chunk-w01y57f5.js +0 -1539
- package/dist/chunk-w21mwxdd.js +0 -4
- package/dist/chunk-w4n8fqp7.js +0 -216
- package/dist/chunk-w959hm8j.js +0 -358
- package/dist/chunk-wf7zrjsw.js +0 -138
- package/dist/chunk-wk07pwtd.js +0 -321
- package/dist/chunk-wvef3ngh.js +0 -127
- package/dist/chunk-wxvyj65q.js +0 -2
- package/dist/chunk-x1hjv24z.js +0 -11
- package/dist/chunk-x39sfpvm.js +0 -302
- package/dist/chunk-x4fze3q2.js +0 -314
- package/dist/chunk-x64kb787.js +0 -15
- package/dist/chunk-xcb0pbr6.js +0 -4
- package/dist/chunk-xhkjhxsp.js +0 -3
- package/dist/chunk-xhnpsngj.js +0 -5
- package/dist/chunk-xsqbk4yk.js +0 -3
- package/dist/chunk-xygc53vr.js +0 -68
- package/dist/chunk-y0qg6rrv.js +0 -3
- package/dist/chunk-y25pr13j.js +0 -19
- package/dist/chunk-y4c744dk.js +0 -3
- package/dist/chunk-y4md9hp0.js +0 -3
- package/dist/chunk-y5wazw6j.js +0 -7
- package/dist/chunk-y5xz0jc4.js +0 -141
- package/dist/chunk-y86m1wr4.js +0 -4
- package/dist/chunk-yaan98dd.js +0 -3
- package/dist/chunk-yach037f.js +0 -32
- package/dist/chunk-yexjrg9d.js +0 -7
- package/dist/chunk-ygvyc6wv.js +0 -90
- package/dist/chunk-yj560gp8.js +0 -8
- package/dist/chunk-yn38c15w.js +0 -4
- package/dist/chunk-yr1gdceh.js +0 -3
- package/dist/chunk-yw2fzq86.js +0 -3
- package/dist/chunk-ywkrxp2h.js +0 -147
- package/dist/chunk-z37xq5rx.js +0 -3
- package/dist/chunk-z4djtgt0.js +0 -71
- package/dist/chunk-z8cjr9n9.js +0 -7
- package/dist/chunk-znxp3zha.js +0 -71
- package/dist/chunk-zt2yag10.js +0 -429
|
@@ -1,7 +1,682 @@
|
|
|
1
|
-
|
|
2
|
-
import{qf as lG}from"../chunk-sjagg9qz.js";import"../chunk-48r3qe0k.js";import"../chunk-w4n8fqp7.js";import"../chunk-mgmyr1b9.js";import"../chunk-vx22he47.js";import"../chunk-jfrn43vh.js";import"../chunk-fs0qezn5.js";import"../chunk-0m9tdm7t.js";import"../chunk-wk07pwtd.js";import"../chunk-26r6zh3t.js";import"../chunk-epj957jf.js";import"../chunk-hjdc99kb.js";import"../chunk-6cr3eeh4.js";import"../chunk-xsqbk4yk.js";import"../chunk-6dqzky7x.js";import"../chunk-h45py5w5.js";import"../chunk-yexjrg9d.js";import"../chunk-y5wazw6j.js";import"../chunk-b3prs7y0.js";import"../chunk-jbejwejg.js";import"../chunk-k8440jxh.js";import"../chunk-yj560gp8.js";import"../chunk-7dy588as.js";import"../chunk-cr3wbrcr.js";import{mh as AG,oh as vG,ph as xG,uh as DG,wh as SG,zh as RG}from"../chunk-fk51yyrw.js";import"../chunk-5qb761h2.js";import"../chunk-c53hyw5c.js";import"../chunk-qk584whs.js";import"../chunk-e0zytzdh.js";import"../chunk-7a51hkpf.js";import"../chunk-qhdtssn1.js";import"../chunk-a69tvya5.js";import"../chunk-y86m1wr4.js";import"../chunk-bjnjpsgn.js";import{Di as WG,Fi as CG,Gi as bG,Ji as FG}from"../chunk-2w3302dh.js";import"../chunk-174z0cd0.js";import"../chunk-qfwzdffx.js";import"../chunk-z8cjr9n9.js";import"../chunk-jfm69keq.js";import"../chunk-mqwbpamc.js";import"../chunk-hje9v2zh.js";import"../chunk-ktkmvaa8.js";import"../chunk-v97390pe.js";import"../chunk-asarebzq.js";import"../chunk-0b9w2w1y.js";import"../chunk-d77yxcds.js";import"../chunk-5xvbq2gs.js";import"../chunk-z37xq5rx.js";import"../chunk-bn08k7yy.js";import"../chunk-9tmbrwwx.js";import"../chunk-hjv76kcw.js";import"../chunk-qm4yppj5.js";import"../chunk-eqeyaq6g.js";import"../chunk-mv4fb50w.js";import"../chunk-tmgz5t2g.js";import"../chunk-7sqdeqsw.js";import"../chunk-sn07azv3.js";import"../chunk-5q87fgkk.js";import"../chunk-gqpkp459.js";import"../chunk-1z2yq9em.js";import"../chunk-5ggw1dyv.js";import"../chunk-cn409b69.js";import"../chunk-xhnpsngj.js";import"../chunk-0wdar532.js";import"../chunk-9agvhp1x.js";import"../chunk-znxp3zha.js";import"../chunk-bk8ew8ze.js";import"../chunk-jt44av4j.js";import"../chunk-7sm05m0j.js";import"../chunk-3bjtemm6.js";import"../chunk-y4md9hp0.js";import"../chunk-svahbw0w.js";import"../chunk-vp2395eb.js";import"../chunk-zt2yag10.js";import{gm as m,hm as PG,im as fG,jm as gG,km as hG,lm as qG}from"../chunk-qxs6et76.js";import"../chunk-6y4gqs1q.js";import"../chunk-qgxwmagw.js";import"../chunk-n944baxp.js";import"../chunk-kfd2hf6f.js";import"../chunk-647849kf.js";import"../chunk-cygfdk1n.js";import"../chunk-kkp6rs2n.js";import"../chunk-50vqeesm.js";import"../chunk-xcb0pbr6.js";import"../chunk-b3kkjcdh.js";import"../chunk-e53h9qhd.js";import"../chunk-vpe6napb.js";import"../chunk-eh8hact1.js";import"../chunk-xhkjhxsp.js";import"../chunk-qwyd9a1d.js";import"../chunk-4aj7ftqb.js";import"../chunk-ca6qd1dx.js";import{go as iG,io as sG}from"../chunk-cdbwprfv.js";import{ko as uG}from"../chunk-mv03qb75.js";import"../chunk-57p201gb.js";import{wo as nG}from"../chunk-cpcc11vp.js";import"../chunk-tx6br9r4.js";import"../chunk-hepg894w.js";import"../chunk-m59y310j.js";import"../chunk-x4fze3q2.js";import"../chunk-0jkwrcwj.js";import"../chunk-6w03t7h6.js";import"../chunk-w959hm8j.js";import"../chunk-haecq01c.js";import"../chunk-y4c744dk.js";import"../chunk-bgec9r1v.js";import"../chunk-5ppkfyn2.js";import"../chunk-bwxda6n1.js";import"../chunk-cyp4m0vh.js";import"../chunk-3ngm57nt.js";import"../chunk-vdfwv0fp.js";import{Jq as mG,Kq as EG,Lq as JG,Mq as QG,Nq as dG,Oq as pG,Pq as cG}from"../chunk-ncnfa8ae.js";import"../chunk-6djgb0hr.js";import"../chunk-ganag9dm.js";import"../chunk-xygc53vr.js";import{Ws as TG,qs as BG}from"../chunk-w01y57f5.js";import"../chunk-x1hjv24z.js";import"../chunk-0g4gece6.js";import"../chunk-nap11ntr.js";import"../chunk-03c26pjz.js";import"../chunk-13yz561y.js";import"../chunk-nanw7yhz.js";import"../chunk-ghrx0hn1.js";import"../chunk-82t27pvd.js";import"../chunk-fhawx87n.js";import"../chunk-gc84b1d2.js";import"../chunk-yr1gdceh.js";import"../chunk-baa7h4yz.js";import"../chunk-kdxa9epn.js";import"../chunk-g2hekckm.js";import"../chunk-x39sfpvm.js";import"../chunk-tr0z0e1g.js";import"../chunk-4j188175.js";import"../chunk-eds0f8f1.js";import"../chunk-dyjnn5k8.js";import"../chunk-8fgwhhb8.js";import"../chunk-tj6zfxeb.js";import"../chunk-7xcfy2fn.js";import"../chunk-9yz5d003.js";import"../chunk-fms20x0n.js";import"../chunk-fe7r1mq1.js";import"../chunk-rb1e4cnb.js";import"../chunk-j4s5qwd7.js";import"../chunk-b0cyc09a.js";import"../chunk-0tatqxj2.js";import{bw as wG}from"../chunk-bykjk6vj.js";import"../chunk-7b0xdy5h.js";import"../chunk-ywkrxp2h.js";import"../chunk-y25pr13j.js";import{Nw as jG,Ow as MG,Sw as g}from"../chunk-q6h6yvzb.js";import{Tw as G}from"../chunk-qdc3aav1.js";import"../chunk-6wn85hn6.js";import"../chunk-qd5461tt.js";import"../chunk-77tga15w.js";import"../chunk-rv002yn0.js";import"../chunk-hke99a0v.js";import"../chunk-mwbng54r.js";import"../chunk-wxvyj65q.js";import"../chunk-yw2fzq86.js";import"../chunk-mrehzhxv.js";import"../chunk-1zgsgk4b.js";import"../chunk-48cw2nde.js";import"../chunk-jjvp4t5w.js";import"../chunk-94g3cahw.js";import"../chunk-ht4j68cs.js";import"../chunk-fch9tk1k.js";import"../chunk-cz25azze.js";import"../chunk-q60knhjf.js";import"../chunk-hrampcrj.js";import"../chunk-t37dp99j.js";import"../chunk-5kt3ay7x.js";import"../chunk-95w08s8v.js";import"../chunk-ceg2c2q2.js";import"../chunk-04mvcmcr.js";import"../chunk-n46a5g1g.js";import"../chunk-vv9wfz1c.js";import"../chunk-dzw95th7.js";import"../chunk-46mkpbkk.js";import"../chunk-3rh7va1z.js";import"../chunk-2xen423s.js";import"../chunk-cp3kwv17.js";import"../chunk-hpqr9e3x.js";import"../chunk-adqh2m9z.js";import"../chunk-8qbax8xn.js";import"../chunk-x64kb787.js";import"../chunk-gcf5v18y.js";import"../chunk-pc31m5x5.js";import{rB as N}from"../chunk-3jm3snz8.js";var{serve:tG}=globalThis.Bun;import q from"fs";import Y from"path";function UG(n){let I=Bun.file(n),S=Y.extname(n).toLowerCase(),l={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},W=[".js",".css",".json"].includes(S)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(I,{headers:{"Content-Type":l[S]||"application/octet-stream",...W}})}async function OJ(n=".",I={}){let S=I.port||3000,l=I.watch!==!1,E=I.hotReload!==!1&&l,W=null,R=I.hmrPort||S+1,V=Y.resolve(n),{loadStxConfig:aG}=await import("../index.js"),D=await aG(V),XG=D.root&&D.root!=="."?Y.join(V,D.root):V,a=D.pagesDir||"pages",r=Y.join(XG,a);if(!q.existsSync(r))return console.error(`${G.red}Error: No '${a}' directory found in ${G.bright}${XG}${G.reset}`),console.log(`${G.dim}Create a ${a}/ directory with .stx files to define your routes.${G.reset}`),console.log(`${G.dim}Example: ${a}/index.stx for the homepage.${G.reset}`),!1;let d=WG(XG);if(d.length===0)return console.error(`${G.red}Error: No page files found in ${G.bright}${r}${G.reset}`),!1;console.log(`${G.blue}Found ${G.bright}${d.length}${G.blue} routes${G.reset}`);let yG=D?._pluginPageDirs||[],p=[];for(let{dir:J,prefix:X}of yG)if(q.existsSync(J)){let $=WG(Y.dirname(J),{pagesDir:Y.basename(J)});for(let K of $){let z=X==="/"?K.pattern:`${X}${K.pattern==="/"?"":K.pattern}`;p.push({route:{...K,pattern:z},prefix:X})}if($.length>0)console.log(`${G.blue}Plugin pages: ${G.bright}${$.length}${G.blue} routes at ${G.cyan}${X}${G.reset}`)}let u=new Map,F=null,C=null;if(I.stxOptions?.shell!==!1){if(C=await mG(V,I.stxOptions?.shell),C){if(F=await EG(C,I.stxOptions||{}),F)console.log(`${G.blue}Using app shell: ${G.bright}${Y.relative(V,C)}${G.reset} ${G.dim}(deprecated: use layouts/default.stx instead)${G.reset}`)}}AG(),await SG(V);let ZG=DG();if(ZG.length>0)console.log(`${G.blue}Loaded ${G.bright}${ZG.length}${G.blue} middleware: ${G.dim}${ZG.join(", ")}${G.reset}`);let o={},$G=null;try{let{loadStxConfig:J}=await import("../index.js"),X=await J(V);if(X?.apiRouter)$G=X?.apiRouter,console.log(`${G.blue}Using custom router for API handling${G.reset}`);if(X?.apiRoutes){o=X.apiRoutes;let $=Object.keys(o).length;if($>0)console.log(`${G.blue}Loaded ${G.bright}${$} API route${$>1?"s":""}${G.reset}`)}if(X?.broadcasting?.enabled)try{let{startBroadcasting:$,loadChannels:K}=await import("../broadcasting.js"),z=X.broadcasting;await $(z);let H=z.port??6001;console.log(`${G.magenta}Broadcasting on ${G.cyan}ws://localhost:${H}/ws${G.reset}`);let y=Y.join(process.cwd(),"channels.ts");if(q.existsSync(y))try{let b=await K(y);console.log(`${G.blue}Loaded ${G.bright}${b} broadcast channel${b!==1?"s":""}${G.blue} from channels.ts${G.reset}`)}catch(b){console.warn(`${G.yellow}Failed to load channels.ts: ${b.message}${G.reset}`)}}catch($){console.warn(`${G.yellow}Broadcasting failed to start: ${$.message}${G.reset}`)}}catch{}let zG=Y.join(V,".stx/output");q.mkdirSync(zG,{recursive:!0});let i=new Map,NG=new Set,KG=async(J)=>{let X=CG(r,J);if(!X)return null;try{let $=await Bun.build({entrypoints:[X],outdir:zG,plugins:[lG],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...I.stxOptions});if(!$.success)return null;let K=$.outputs.find((z)=>z.path.endsWith(".html"));if(!K)return null;return await Bun.file(K.path).text()}catch{return null}},VG=async(J,X)=>{try{let{processDirectives:$,extractVariables:K,defaultConfig:z,loadStxConfig:H,injectRouterScript:y}=await import("../index.js"),{checkCache:b,cacheTemplate:IG,readFileCached:B,templateCache:e}=await import("../caching.js"),GG=await H(V),Z=(_)=>{if(!_)return _;if(Y.isAbsolute(_))return _;return Y.resolve(V,_)},k={...z,...GG,...I.stxOptions,autoShell:!0};if(I.debugDirectives)k.debug=!0;k.partialsDir=Z(k.partialsDir),k.componentsDir=Z(k.componentsDir),k.layoutsDir=Z(k.layoutsDir),k.storesDir=Z(k.storesDir||"stores"),k.cachePath=Z(k.cachePath||".stx/cache");let L=!X&&!I.profile,Q=k.cache!==!1;if(Q&&L){let _=e.get(J.filePath);if(_)try{if((await q.promises.stat(J.filePath)).mtime.getTime()<=_.mtime){let f=!0;for(let T of _.dependencies){if(!q.existsSync(T)){f=!1;break}if((await q.promises.stat(T)).mtime.getTime()>_.mtime){f=!1;break}}if(f){let T=_.output;if(F)T=QG(T,{preserveHead:!0});return{route:J,content:T}}}}catch{}let A=await b(J.filePath,k);if(A){let v=A;if(F)v=QG(v,{preserveHead:!0});return{route:J,content:v}}}let O=Q?await B(J.filePath):await Bun.file(J.filePath).text(),{classifyAllScripts:j}=await import("../index.js"),U=j(O),M=U.server.map((_)=>_.content),P=O;for(let _ of U.server)P=P.replace(_.fullTag,"");let w={__filename:J.filePath,__dirname:Y.dirname(J.filePath),params:X??{}},{resetHead:rG}=await import("../head.js");rG();for(let _ of M)try{await K(_,w,J.filePath)}catch(A){if(I.stxOptions?.debug)console.error("[stx] variable extraction error",J.filePath,A?.message||A)}let OG=new Set,x;if(I.profile){let _=performance.now();x=await $(P,w,J.filePath,k,OG);let A=performance.now()-_,v=Y.relative(V,J.filePath)||J.filePath;console.log(`[stx:profile] ${v} \u2192 ${A.toFixed(2)}ms`)}else x=await $(P,w,J.filePath,k,OG);if(!F)x=await y(x);{let{interpolateScriptExpressions:_}=await import("../expressions.js");x=x.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A,v,f)=>{if(!/function\s+__stx_setup_/.test(f))return A;return`<script${v}>${_(f,w)}</script>`})}if(F)x=QG(x,{preserveHead:!0});if(Q&&L)await IG(J.filePath,x,OG,k);let{extractStreamBoundaries:oG}=await import("../streaming.js"),c=oG(w),s=w.__streamTemplates;if(s&&typeof s==="object"&&Object.keys(s).length>0){let _=w.streamBoundaries||{},A={...k,autoShell:!1},v=Object.keys(s).map((T)=>({id:T,render:async()=>{let HG=typeof _[T]==="function"?await _[T]():void 0;return $(s[T],{...w,$boundary:HG},J.filePath,A,new Set)}})),f=new Set(v.map((T)=>T.id));c=[...(c||[]).filter((T)=>!f.has(T.id)),...v]}if(c&&c.length>0)NG.add(J.pattern);else c=void 0;return{route:J,content:x,boundaries:c}}catch($){return console.error(`${G.red}Error building ${G.bright}${J.pattern}${G.reset}:`,$),null}},t=8,kG=async()=>{i.clear(),u.clear();for(let J=0;J<d.length;J+=t){let X=d.slice(J,J+t),$=await Promise.all(X.map((K)=>VG(K)));for(let K of $)if(K)i.set(K.route.pattern,K)}for(let J=0;J<p.length;J+=t){let X=p.slice(J,J+t),$=await Promise.all(X.map(({route:K})=>VG(K)));for(let K of $)if(K)u.set(K.route.pattern,K)}return i.size>0};if(console.log(`${G.blue}Building pages...${G.reset}`),!await kG())return console.error(`${G.red}No pages were successfully built${G.reset}`),!1;await jG(V);let h=S;try{if(h=await uG(S),h!==S)console.log(`${G.yellow}Port ${S} is busy, using port ${h} instead${G.reset}`)}catch{return console.error(`${G.red}Could not find an available port${G.reset}`),!1}if(E){let J=I.hmrPort||h+1;W=hG({wsPort:J,verbose:!1}),R=W.start(J)}let YG=(J,X)=>{let $=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(X)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(J.includes("</head>"))return J.replace("</head>",`${$}</head>`);if(J.includes("<body"))return J.replace(/<body([^>]*)>/,`<body$1>${$}`);return $+J};console.log(`${G.blue}Starting server...${G.reset}`);let _G=tG({port:h,async fetch(J){let X=new URL(J.url),$=D?.publicDir||"public",K=Y.join(V,$,X.pathname),z=Y.join(V,X.pathname),H=Y.join(zG,X.pathname),[y,b,IG]=await Promise.all([q.promises.stat(K).catch(()=>null),q.promises.stat(z).catch(()=>null),q.promises.stat(H).catch(()=>null)]);if(y?.isFile())return UG(K);if(b?.isFile())return UG(z);if(IG?.isFile())return UG(H);if(X.pathname.startsWith("/_stx/component/")){let Z=decodeURIComponent(X.pathname.slice(16));if(Z)try{let k=`<${Z} />`,L={...buildConfig,autoShell:!1},Q=await processDirectives(k,{},Y.join(V,"components",`${Z}.stx`),L,new Set);return new Response(Q,{headers:{"Content-Type":"text/html"}})}catch(k){return new Response(`<div class="stx-async-error">${k.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(X.pathname==="/_stx/img"){let{handleImageRequest:Z}=await import("../image-optimization/serve.js"),k=await Z(J,{publicDir:Y.join(V,$),cacheDir:Y.join(V,".stx/cache/img")});if(k)return k}if($G)try{let Z=await $G.handleRequest(J);if(Z.status!==404)return Z}catch{}if(o[X.pathname])try{return await o[X.pathname](J)}catch(Z){return new Response(JSON.stringify({error:Z.message}),{status:500,headers:{"Content-Type":"application/json"}})}let B=FG(X.pathname,d);if(B){let Z=i.get(B.route.pattern),k=NG.has(B.route.pattern);if(B.route.isDynamic&&Object.keys(B.params).length>0||k){let L=await VG(B.route,B.params);if(L)Z=L}if(Z){let L=wG();if(L.validate){if(!await L.validate({params:B.params})){let j=await KG(404);if(j){let U=j;if(U=await g(U,V),E)U=m(U,R);return new Response(U,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(L.middleware){let O=xG(X.pathname,B.params,L,X.search),j=vG(O,null,J),U=await RG(L.middleware,j);if(U.redirect){let M=U.redirect.path,P=U.redirect.options.redirectCode||302,w=new Headers(U.responseHeaders);return w.set("Location",M),new Response(null,{status:P,headers:w})}if(U.abort){let{statusCode:M,message:P}=U.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${M}</title></head><body><h1>Error ${M}</h1><p>${P}</p></body></html>`,{status:M,headers:{"Content-Type":"text/html"}})}if(Object.keys(U.state).length>0){let M=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(U.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;Z.content=Z.content.replace("</head>",`${M}</head>`)}}let Q=Z.content;if(F&&dG(J)){let O=cG(Q),j=Q.match(/<title[^>]*>([\s\S]*?)<\/title>/i),U=j?j[1].trim():"";if(Object.keys(B.params).length>0)Q=YG(Q,B.params);Q=await g(Q,V);let M=D?.router?.container||"main";return Q=pG(Q,M),new Response(Q,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":O.layout,"X-STX-Layout-Group":O.group,...U&&{"X-STX-Title":encodeURIComponent(U)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)Q=JG(F,Q);if(Object.keys(B.params).length>0)Q=YG(Q,B.params);if(Q=await g(Q,V),E)Q=m(Q,R);if(I.native)if(Q.includes("<head>"))Q=Q.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Q="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Q;if(I.titlebarHidden)if(Q.includes("<head>"))Q=Q.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Q=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Q}`;if(Z.boundaries&&Z.boundaries.length>0){let{renderStreamingPage:O,streamToResponse:j}=await import("../streaming.js");return j(O(Q,Z.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Q,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(p.length>0){let Z=p.map((L)=>L.route),k=FG(X.pathname,Z);if(k){let L=u.get(k.route.pattern);if(L){let Q=L.content;if(F)Q=JG(F,Q);if(Object.keys(k.params).length>0)Q=YG(Q,k.params);if(Q=await g(Q,V),E)Q=m(Q,R);return new Response(Q,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:L}of yG)if(L!=="/"&&X.pathname.startsWith(L)){let Q=u.get(L)||u.get(L+"/");if(Q){let O=Q.content;if(F)O=JG(F,O);if(O=await g(O,V),E)O=m(O,R);return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let e=i.get("/");if(e){let Z=e.content;if(Z=await g(Z,V),E)Z=m(Z,R);if(I.native)if(Z.includes("<head>"))Z=Z.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Z;return new Response(Z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let GG=await KG(404);if(GG){let Z=GG;if(Z=await g(Z,V),E)Z=m(Z,R);return new Response(Z,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(J){let X=await KG(500);if(X)return new Response(X,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${J}
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { serve } from "bun";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { detectShell, processShell, composeShellWithPage, stripDocumentWrapper, isSpaNavigation, extractContainerContent, extractLayoutMetadata } from "../app-shell.js";
|
|
5
|
+
import {
|
|
6
|
+
getHmrServer,
|
|
7
|
+
injectHotReload,
|
|
8
|
+
isCssOnlyChange,
|
|
9
|
+
shouldIgnoreFile,
|
|
10
|
+
shouldReloadOnChange,
|
|
11
|
+
stopHmrServer
|
|
12
|
+
} from "../hot-reload.js";
|
|
13
|
+
import { partialsCache } from "../includes.js";
|
|
14
|
+
import { plugin as stxPlugin } from "../plugin.js";
|
|
15
|
+
import { createRouter, matchRoute, formatRoutes, findErrorPage } from "../router.js";
|
|
16
|
+
import {
|
|
17
|
+
loadMiddlewareFromDirectory,
|
|
18
|
+
runMiddleware,
|
|
19
|
+
createMiddlewareContext,
|
|
20
|
+
createRouteLocation,
|
|
21
|
+
clearMiddleware,
|
|
22
|
+
getMiddlewareNames
|
|
23
|
+
} from "../route-middleware.js";
|
|
24
|
+
import { getPageMeta, resetHead } from "../head.js";
|
|
25
|
+
import { clearComponentCache } from "../utils.js";
|
|
26
|
+
import {
|
|
27
|
+
buildCrosswindCSS,
|
|
28
|
+
colors,
|
|
29
|
+
extractSidebarConfig,
|
|
30
|
+
findAvailablePort,
|
|
31
|
+
injectCrosswindCSS,
|
|
32
|
+
openNativeWindow,
|
|
33
|
+
rebuildCrosswindCSS,
|
|
34
|
+
setupKeyboardShortcuts
|
|
35
|
+
} from "./index.js";
|
|
36
|
+
function serveStaticFile(filePath) {
|
|
37
|
+
const file = Bun.file(filePath), ext = path.extname(filePath).toLowerCase(), contentTypes = {
|
|
38
|
+
".html": "text/html",
|
|
39
|
+
".css": "text/css",
|
|
40
|
+
".js": "text/javascript",
|
|
41
|
+
".json": "application/json",
|
|
42
|
+
".png": "image/png",
|
|
43
|
+
".jpg": "image/jpeg",
|
|
44
|
+
".jpeg": "image/jpeg",
|
|
45
|
+
".gif": "image/gif",
|
|
46
|
+
".svg": "image/svg+xml",
|
|
47
|
+
".ico": "image/x-icon",
|
|
48
|
+
".woff": "font/woff",
|
|
49
|
+
".woff2": "font/woff2",
|
|
50
|
+
".ttf": "font/ttf",
|
|
51
|
+
".otf": "font/otf",
|
|
52
|
+
".eot": "application/vnd.ms-fontobject"
|
|
53
|
+
}, cacheHeaders = [".js", ".css", ".json"].includes(ext) ? {
|
|
54
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
55
|
+
Pragma: "no-cache",
|
|
56
|
+
Expires: "0"
|
|
57
|
+
} : {};
|
|
58
|
+
return new Response(file, {
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": contentTypes[ext] || "application/octet-stream",
|
|
61
|
+
...cacheHeaders
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export async function serveApp(appDir = ".", options = {}) {
|
|
66
|
+
const port = options.port || 3000, watch = options.watch !== !1, hotReload = options.hotReload !== !1 && watch;
|
|
67
|
+
let hmrServer = null, actualHmrPort = options.hmrPort || port + 1;
|
|
68
|
+
const absoluteAppDir = path.resolve(appDir), { loadStxConfig } = await import("../index.js"), projectConfig = await loadStxConfig(absoluteAppDir), stxRoot = projectConfig.root && projectConfig.root !== "." ? path.join(absoluteAppDir, projectConfig.root) : absoluteAppDir, pagesDirName = projectConfig.pagesDir || "pages", pagesDir = path.join(stxRoot, pagesDirName);
|
|
69
|
+
if (!fs.existsSync(pagesDir)) {
|
|
70
|
+
console.error(`${colors.red}Error: No '${pagesDirName}' directory found in ${colors.bright}${stxRoot}${colors.reset}`);
|
|
71
|
+
console.log(`${colors.dim}Create a ${pagesDirName}/ directory with .stx files to define your routes.${colors.reset}`);
|
|
72
|
+
console.log(`${colors.dim}Example: ${pagesDirName}/index.stx for the homepage.${colors.reset}`);
|
|
73
|
+
return !1;
|
|
74
|
+
}
|
|
75
|
+
const routes = createRouter(stxRoot);
|
|
76
|
+
if (routes.length === 0) {
|
|
77
|
+
console.error(`${colors.red}Error: No page files found in ${colors.bright}${pagesDir}${colors.reset}`);
|
|
78
|
+
return !1;
|
|
79
|
+
}
|
|
80
|
+
console.log(`${colors.blue}Found ${colors.bright}${routes.length}${colors.blue} routes${colors.reset}`);
|
|
81
|
+
const pluginPageDirs = projectConfig?._pluginPageDirs || [], pluginRoutes = [];
|
|
82
|
+
for (const { dir: pluginDir, prefix: pluginPrefix } of pluginPageDirs)
|
|
83
|
+
if (fs.existsSync(pluginDir)) {
|
|
84
|
+
const pRoutes = createRouter(path.dirname(pluginDir), { pagesDir: path.basename(pluginDir) });
|
|
85
|
+
for (const route of pRoutes) {
|
|
86
|
+
const prefixedPattern = pluginPrefix === "/" ? route.pattern : `${pluginPrefix}${route.pattern === "/" ? "" : route.pattern}`;
|
|
87
|
+
pluginRoutes.push({
|
|
88
|
+
route: { ...route, pattern: prefixedPattern },
|
|
89
|
+
prefix: pluginPrefix
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (pRoutes.length > 0)
|
|
93
|
+
console.log(`${colors.blue}Plugin pages: ${colors.bright}${pRoutes.length}${colors.blue} routes at ${colors.cyan}${pluginPrefix}${colors.reset}`);
|
|
94
|
+
}
|
|
95
|
+
const builtPluginPages = new Map;
|
|
96
|
+
let shell = null, shellPath = null;
|
|
97
|
+
if (options.stxOptions?.shell !== !1) {
|
|
98
|
+
shellPath = await detectShell(absoluteAppDir, options.stxOptions?.shell);
|
|
99
|
+
if (shellPath) {
|
|
100
|
+
shell = await processShell(shellPath, options.stxOptions || {});
|
|
101
|
+
if (shell)
|
|
102
|
+
console.log(`${colors.blue}Using app shell: ${colors.bright}${path.relative(absoluteAppDir, shellPath)}${colors.reset} ${colors.dim}(deprecated: use layouts/default.stx instead)${colors.reset}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
clearMiddleware();
|
|
106
|
+
await loadMiddlewareFromDirectory(absoluteAppDir);
|
|
107
|
+
const loadedMiddleware = getMiddlewareNames();
|
|
108
|
+
if (loadedMiddleware.length > 0)
|
|
109
|
+
console.log(`${colors.blue}Loaded ${colors.bright}${loadedMiddleware.length}${colors.blue} middleware: ${colors.dim}${loadedMiddleware.join(", ")}${colors.reset}`);
|
|
110
|
+
let apiRoutes = {}, customRouter = null;
|
|
111
|
+
try {
|
|
112
|
+
const { loadStxConfig } = await import("../index.js"), projectConfig = await loadStxConfig(absoluteAppDir);
|
|
113
|
+
if (projectConfig?.apiRouter) {
|
|
114
|
+
customRouter = projectConfig?.apiRouter;
|
|
115
|
+
console.log(`${colors.blue}Using custom router for API handling${colors.reset}`);
|
|
116
|
+
}
|
|
117
|
+
if (projectConfig?.apiRoutes) {
|
|
118
|
+
apiRoutes = projectConfig.apiRoutes;
|
|
119
|
+
const routeCount = Object.keys(apiRoutes).length;
|
|
120
|
+
if (routeCount > 0)
|
|
121
|
+
console.log(`${colors.blue}Loaded ${colors.bright}${routeCount} API route${routeCount > 1 ? "s" : ""}${colors.reset}`);
|
|
122
|
+
}
|
|
123
|
+
if (projectConfig?.broadcasting?.enabled)
|
|
124
|
+
try {
|
|
125
|
+
const { startBroadcasting, loadChannels } = await import("../broadcasting.js"), bcConfig = projectConfig.broadcasting;
|
|
126
|
+
await startBroadcasting(bcConfig);
|
|
127
|
+
const bcPort = bcConfig.port ?? 6001;
|
|
128
|
+
console.log(`${colors.magenta}Broadcasting on ${colors.cyan}ws://localhost:${bcPort}/ws${colors.reset}`);
|
|
129
|
+
const channelsFile = path.join(process.cwd(), "channels.ts");
|
|
130
|
+
if (fs.existsSync(channelsFile))
|
|
131
|
+
try {
|
|
132
|
+
const count = await loadChannels(channelsFile);
|
|
133
|
+
console.log(`${colors.blue}Loaded ${colors.bright}${count} broadcast channel${count !== 1 ? "s" : ""}${colors.blue} from channels.ts${colors.reset}`);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
console.warn(`${colors.yellow}Failed to load channels.ts: ${err.message}${colors.reset}`);
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
console.warn(`${colors.yellow}Broadcasting failed to start: ${err.message}${colors.reset}`);
|
|
139
|
+
}
|
|
140
|
+
} catch {}
|
|
141
|
+
const outputDir = path.join(absoluteAppDir, ".stx/output");
|
|
142
|
+
fs.mkdirSync(outputDir, { recursive: !0 });
|
|
143
|
+
const builtPages = new Map, streamingRoutes = new Set, renderErrorPage = async (statusCode) => {
|
|
144
|
+
const errorPagePath = findErrorPage(pagesDir, statusCode);
|
|
145
|
+
if (!errorPagePath)
|
|
146
|
+
return null;
|
|
147
|
+
try {
|
|
148
|
+
const result = await Bun.build({
|
|
149
|
+
entrypoints: [errorPagePath],
|
|
150
|
+
outdir: outputDir,
|
|
151
|
+
plugins: [stxPlugin],
|
|
152
|
+
publicPath: "/",
|
|
153
|
+
define: {
|
|
154
|
+
"process.env.NODE_ENV": '"development"'
|
|
155
|
+
},
|
|
156
|
+
...options.stxOptions
|
|
157
|
+
});
|
|
158
|
+
if (!result.success)
|
|
159
|
+
return null;
|
|
160
|
+
const htmlOutput = result.outputs.find((o) => o.path.endsWith(".html"));
|
|
161
|
+
if (!htmlOutput)
|
|
162
|
+
return null;
|
|
163
|
+
return await Bun.file(htmlOutput.path).text();
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}, buildPage = async (route, requestParams) => {
|
|
168
|
+
try {
|
|
169
|
+
const { processDirectives, extractVariables, defaultConfig, loadStxConfig, injectRouterScript } = await import("../index.js"), { checkCache, cacheTemplate, readFileCached, templateCache } = await import("../caching.js"), projectConfig = await loadStxConfig(absoluteAppDir), resolveRel = (dir) => {
|
|
170
|
+
if (!dir)
|
|
171
|
+
return dir;
|
|
172
|
+
if (path.isAbsolute(dir))
|
|
173
|
+
return dir;
|
|
174
|
+
return path.resolve(absoluteAppDir, dir);
|
|
175
|
+
}, merged = {
|
|
176
|
+
...defaultConfig,
|
|
177
|
+
...projectConfig,
|
|
178
|
+
...options.stxOptions,
|
|
179
|
+
autoShell: !0
|
|
180
|
+
};
|
|
181
|
+
if (options.debugDirectives)
|
|
182
|
+
merged.debug = !0;
|
|
183
|
+
merged.partialsDir = resolveRel(merged.partialsDir);
|
|
184
|
+
merged.componentsDir = resolveRel(merged.componentsDir);
|
|
185
|
+
merged.layoutsDir = resolveRel(merged.layoutsDir);
|
|
186
|
+
merged.storesDir = resolveRel(merged.storesDir || "stores");
|
|
187
|
+
merged.cachePath = resolveRel(merged.cachePath || ".stx/cache");
|
|
188
|
+
const isStaticBuild = !requestParams && !options.profile, cacheEnabled = merged.cache !== !1;
|
|
189
|
+
if (cacheEnabled && isStaticBuild) {
|
|
190
|
+
const memEntry = templateCache.get(route.filePath);
|
|
191
|
+
if (memEntry)
|
|
192
|
+
try {
|
|
193
|
+
if ((await fs.promises.stat(route.filePath)).mtime.getTime() <= memEntry.mtime) {
|
|
194
|
+
let valid = !0;
|
|
195
|
+
for (const dep of memEntry.dependencies) {
|
|
196
|
+
if (!fs.existsSync(dep)) {
|
|
197
|
+
valid = !1;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
if ((await fs.promises.stat(dep)).mtime.getTime() > memEntry.mtime) {
|
|
201
|
+
valid = !1;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (valid) {
|
|
206
|
+
let output = memEntry.output;
|
|
207
|
+
if (shell)
|
|
208
|
+
output = stripDocumentWrapper(output, { preserveHead: !0 });
|
|
209
|
+
return { route, content: output };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} catch {}
|
|
213
|
+
const cached = await checkCache(route.filePath, merged);
|
|
214
|
+
if (cached) {
|
|
215
|
+
let output = cached;
|
|
216
|
+
if (shell)
|
|
217
|
+
output = stripDocumentWrapper(output, { preserveHead: !0 });
|
|
218
|
+
return { route, content: output };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const content = cacheEnabled ? await readFileCached(route.filePath) : await Bun.file(route.filePath).text(), { classifyAllScripts } = await import("../index.js"), classified = classifyAllScripts(content), serverScripts = classified.server.map((s) => s.content);
|
|
222
|
+
let templateContent = content;
|
|
223
|
+
for (const s of classified.server)
|
|
224
|
+
templateContent = templateContent.replace(s.fullTag, "");
|
|
225
|
+
const context = {
|
|
226
|
+
__filename: route.filePath,
|
|
227
|
+
__dirname: path.dirname(route.filePath),
|
|
228
|
+
params: requestParams ?? {}
|
|
229
|
+
}, { resetHead } = await import("../head.js");
|
|
230
|
+
resetHead();
|
|
231
|
+
for (const scriptBody of serverScripts)
|
|
232
|
+
try {
|
|
233
|
+
await extractVariables(scriptBody, context, route.filePath);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
if (options.stxOptions?.debug)
|
|
236
|
+
console.error("[stx] variable extraction error", route.filePath, e?.message || e);
|
|
237
|
+
}
|
|
238
|
+
const dependencies = new Set;
|
|
239
|
+
let output;
|
|
240
|
+
if (options.profile) {
|
|
241
|
+
const t0 = performance.now();
|
|
242
|
+
output = await processDirectives(templateContent, context, route.filePath, merged, dependencies);
|
|
243
|
+
const ms = performance.now() - t0, rel = path.relative(absoluteAppDir, route.filePath) || route.filePath;
|
|
244
|
+
console.log(`[stx:profile] ${rel} \u2192 ${ms.toFixed(2)}ms`);
|
|
245
|
+
} else
|
|
246
|
+
output = await processDirectives(templateContent, context, route.filePath, merged, dependencies);
|
|
247
|
+
if (!shell)
|
|
248
|
+
output = await injectRouterScript(output);
|
|
249
|
+
{
|
|
250
|
+
const { interpolateScriptExpressions } = await import("../expressions.js");
|
|
251
|
+
output = output.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g, (full, attrs, body) => {
|
|
252
|
+
if (!/function\s+__stx_setup_/.test(body))
|
|
253
|
+
return full;
|
|
254
|
+
return `<script${attrs}>${interpolateScriptExpressions(body, context)}</script>`;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
if (shell)
|
|
258
|
+
output = stripDocumentWrapper(output, { preserveHead: !0 });
|
|
259
|
+
if (cacheEnabled && isStaticBuild)
|
|
260
|
+
await cacheTemplate(route.filePath, output, dependencies, merged);
|
|
261
|
+
const { extractStreamBoundaries } = await import("../streaming.js");
|
|
262
|
+
let boundaries = extractStreamBoundaries(context);
|
|
263
|
+
const streamTemplates = context.__streamTemplates;
|
|
264
|
+
if (streamTemplates && typeof streamTemplates === "object" && Object.keys(streamTemplates).length > 0) {
|
|
265
|
+
const dataFns = context.streamBoundaries || {}, fragmentConfig = { ...merged, autoShell: !1 }, tplBoundaries = Object.keys(streamTemplates).map((id) => ({
|
|
266
|
+
id,
|
|
267
|
+
render: async () => {
|
|
268
|
+
const data = typeof dataFns[id] === "function" ? await dataFns[id]() : void 0;
|
|
269
|
+
return processDirectives(streamTemplates[id], { ...context, $boundary: data }, route.filePath, fragmentConfig, new Set);
|
|
270
|
+
}
|
|
271
|
+
})), tplIds = new Set(tplBoundaries.map((b) => b.id));
|
|
272
|
+
boundaries = [...(boundaries || []).filter((b) => !tplIds.has(b.id)), ...tplBoundaries];
|
|
273
|
+
}
|
|
274
|
+
if (boundaries && boundaries.length > 0)
|
|
275
|
+
streamingRoutes.add(route.pattern);
|
|
276
|
+
else
|
|
277
|
+
boundaries = void 0;
|
|
278
|
+
return { route, content: output, boundaries };
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.error(`${colors.red}Error building ${colors.bright}${route.pattern}${colors.reset}:`, error);
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
}, BUILD_CONCURRENCY = 8, buildAllPages = async () => {
|
|
284
|
+
builtPages.clear();
|
|
285
|
+
builtPluginPages.clear();
|
|
286
|
+
for (let i = 0;i < routes.length; i += BUILD_CONCURRENCY) {
|
|
287
|
+
const chunk = routes.slice(i, i + BUILD_CONCURRENCY), results = await Promise.all(chunk.map((route) => buildPage(route)));
|
|
288
|
+
for (const built of results)
|
|
289
|
+
if (built)
|
|
290
|
+
builtPages.set(built.route.pattern, built);
|
|
291
|
+
}
|
|
292
|
+
for (let i = 0;i < pluginRoutes.length; i += BUILD_CONCURRENCY) {
|
|
293
|
+
const chunk = pluginRoutes.slice(i, i + BUILD_CONCURRENCY), results = await Promise.all(chunk.map(({ route }) => buildPage(route)));
|
|
294
|
+
for (const built of results)
|
|
295
|
+
if (built)
|
|
296
|
+
builtPluginPages.set(built.route.pattern, built);
|
|
297
|
+
}
|
|
298
|
+
return builtPages.size > 0;
|
|
299
|
+
};
|
|
300
|
+
console.log(`${colors.blue}Building pages...${colors.reset}`);
|
|
301
|
+
if (!await buildAllPages()) {
|
|
302
|
+
console.error(`${colors.red}No pages were successfully built${colors.reset}`);
|
|
303
|
+
return !1;
|
|
304
|
+
}
|
|
305
|
+
await buildCrosswindCSS(absoluteAppDir);
|
|
306
|
+
let actualPort = port;
|
|
307
|
+
try {
|
|
308
|
+
actualPort = await findAvailablePort(port);
|
|
309
|
+
if (actualPort !== port)
|
|
310
|
+
console.log(`${colors.yellow}Port ${port} is busy, using port ${actualPort} instead${colors.reset}`);
|
|
311
|
+
} catch {
|
|
312
|
+
console.error(`${colors.red}Could not find an available port${colors.reset}`);
|
|
313
|
+
return !1;
|
|
314
|
+
}
|
|
315
|
+
if (hotReload) {
|
|
316
|
+
const desiredHmrPort = options.hmrPort || actualPort + 1;
|
|
317
|
+
hmrServer = getHmrServer({ wsPort: desiredHmrPort, verbose: !1 });
|
|
318
|
+
actualHmrPort = hmrServer.start(desiredHmrPort);
|
|
319
|
+
}
|
|
320
|
+
const injectRouteParams = (content, params) => {
|
|
321
|
+
const paramsScript = `<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(params)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;
|
|
322
|
+
if (content.includes("</head>"))
|
|
323
|
+
return content.replace("</head>", `${paramsScript}</head>`);
|
|
324
|
+
if (content.includes("<body"))
|
|
325
|
+
return content.replace(/<body([^>]*)>/, `<body$1>${paramsScript}`);
|
|
326
|
+
return paramsScript + content;
|
|
327
|
+
};
|
|
328
|
+
console.log(`${colors.blue}Starting server...${colors.reset}`);
|
|
329
|
+
const server = serve({
|
|
330
|
+
port: actualPort,
|
|
331
|
+
async fetch(request) {
|
|
332
|
+
const url = new URL(request.url), publicDirName = projectConfig?.publicDir || "public", publicPath = path.join(absoluteAppDir, publicDirName, url.pathname), distPath = path.join(absoluteAppDir, url.pathname), outputPath = path.join(outputDir, url.pathname), [publicStat, distStat, outputStat] = await Promise.all([
|
|
333
|
+
fs.promises.stat(publicPath).catch(() => null),
|
|
334
|
+
fs.promises.stat(distPath).catch(() => null),
|
|
335
|
+
fs.promises.stat(outputPath).catch(() => null)
|
|
336
|
+
]);
|
|
337
|
+
if (publicStat?.isFile())
|
|
338
|
+
return serveStaticFile(publicPath);
|
|
339
|
+
if (distStat?.isFile())
|
|
340
|
+
return serveStaticFile(distPath);
|
|
341
|
+
if (outputStat?.isFile())
|
|
342
|
+
return serveStaticFile(outputPath);
|
|
343
|
+
if (url.pathname.startsWith("/_stx/component/")) {
|
|
344
|
+
const componentName = decodeURIComponent(url.pathname.slice(16));
|
|
345
|
+
if (componentName)
|
|
346
|
+
try {
|
|
347
|
+
const componentTemplate = `<${componentName} />`, componentOpts = { ...buildConfig, autoShell: !1 }, html = await processDirectives(componentTemplate, {}, path.join(absoluteAppDir, "components", `${componentName}.stx`), componentOpts, new Set);
|
|
348
|
+
return new Response(html, { headers: { "Content-Type": "text/html" } });
|
|
349
|
+
} catch (e) {
|
|
350
|
+
return new Response(`<div class="stx-async-error">${e.message}</div>`, { status: 500, headers: { "Content-Type": "text/html" } });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (url.pathname === "/_stx/img") {
|
|
354
|
+
const { handleImageRequest } = await import("../image-optimization/serve.js"), imgResponse = await handleImageRequest(request, {
|
|
355
|
+
publicDir: path.join(absoluteAppDir, publicDirName),
|
|
356
|
+
cacheDir: path.join(absoluteAppDir, ".stx/cache/img")
|
|
357
|
+
});
|
|
358
|
+
if (imgResponse)
|
|
359
|
+
return imgResponse;
|
|
360
|
+
}
|
|
361
|
+
if (customRouter)
|
|
362
|
+
try {
|
|
363
|
+
const routerResponse = await customRouter.handleRequest(request);
|
|
364
|
+
if (routerResponse.status !== 404)
|
|
365
|
+
return routerResponse;
|
|
366
|
+
} catch {}
|
|
367
|
+
if (apiRoutes[url.pathname])
|
|
368
|
+
try {
|
|
369
|
+
return await apiRoutes[url.pathname](request);
|
|
370
|
+
} catch (err) {
|
|
371
|
+
return new Response(JSON.stringify({ error: err.message }), {
|
|
372
|
+
status: 500,
|
|
373
|
+
headers: { "Content-Type": "application/json" }
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const routeMatch = matchRoute(url.pathname, routes);
|
|
377
|
+
if (routeMatch) {
|
|
378
|
+
let builtPage = builtPages.get(routeMatch.route.pattern);
|
|
379
|
+
const isStreamingRoute = streamingRoutes.has(routeMatch.route.pattern);
|
|
380
|
+
if (routeMatch.route.isDynamic && Object.keys(routeMatch.params).length > 0 || isStreamingRoute) {
|
|
381
|
+
const rebuilt = await buildPage(routeMatch.route, routeMatch.params);
|
|
382
|
+
if (rebuilt)
|
|
383
|
+
builtPage = rebuilt;
|
|
384
|
+
}
|
|
385
|
+
if (builtPage) {
|
|
386
|
+
const pageMeta = getPageMeta();
|
|
387
|
+
if (pageMeta.validate) {
|
|
388
|
+
if (!await pageMeta.validate({ params: routeMatch.params })) {
|
|
389
|
+
const custom404 = await renderErrorPage(404);
|
|
390
|
+
if (custom404) {
|
|
391
|
+
let content = custom404;
|
|
392
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
393
|
+
if (hotReload)
|
|
394
|
+
content = injectHotReload(content, actualHmrPort);
|
|
395
|
+
return new Response(content, {
|
|
396
|
+
status: 404,
|
|
397
|
+
headers: { "Content-Type": "text/html" }
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
return new Response("Not Found", { status: 404 });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (pageMeta.middleware) {
|
|
404
|
+
const toRoute = createRouteLocation(url.pathname, routeMatch.params, pageMeta, url.search), middlewareContext = createMiddlewareContext(toRoute, null, request), middlewareResult = await runMiddleware(pageMeta.middleware, middlewareContext);
|
|
405
|
+
if (middlewareResult.redirect) {
|
|
406
|
+
const redirectUrl = middlewareResult.redirect.path, statusCode = middlewareResult.redirect.options.redirectCode || 302, headers = new Headers(middlewareResult.responseHeaders);
|
|
407
|
+
headers.set("Location", redirectUrl);
|
|
408
|
+
return new Response(null, {
|
|
409
|
+
status: statusCode,
|
|
410
|
+
headers
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
if (middlewareResult.abort) {
|
|
414
|
+
const { statusCode, message } = middlewareResult.abort.error;
|
|
415
|
+
return new Response(`<!DOCTYPE html><html><head><title>Error ${statusCode}</title></head><body><h1>Error ${statusCode}</h1><p>${message}</p></body></html>`, {
|
|
416
|
+
status: statusCode,
|
|
417
|
+
headers: { "Content-Type": "text/html" }
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (Object.keys(middlewareResult.state).length > 0) {
|
|
421
|
+
const stateScript = `<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(middlewareResult.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;
|
|
422
|
+
builtPage.content = builtPage.content.replace("</head>", `${stateScript}</head>`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
let content = builtPage.content;
|
|
426
|
+
if (shell && isSpaNavigation(request)) {
|
|
427
|
+
const layoutMetadata = extractLayoutMetadata(content), titleMatch = content.match(/<title[^>]*>([\s\S]*?)<\/title>/i), pageTitle = titleMatch ? titleMatch[1].trim() : "";
|
|
428
|
+
if (Object.keys(routeMatch.params).length > 0)
|
|
429
|
+
content = injectRouteParams(content, routeMatch.params);
|
|
430
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
431
|
+
const routerContainer = projectConfig?.router?.container || "main";
|
|
432
|
+
content = extractContainerContent(content, routerContainer);
|
|
433
|
+
return new Response(content, {
|
|
434
|
+
headers: {
|
|
435
|
+
"Content-Type": "text/html",
|
|
436
|
+
"X-STX-Fragment": "true",
|
|
437
|
+
"X-STX-Layout": layoutMetadata.layout,
|
|
438
|
+
"X-STX-Layout-Group": layoutMetadata.group,
|
|
439
|
+
...pageTitle && { "X-STX-Title": encodeURIComponent(pageTitle) },
|
|
440
|
+
"Cache-Control": "no-store, no-cache, must-revalidate"
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
if (shell)
|
|
445
|
+
content = composeShellWithPage(shell, content);
|
|
446
|
+
if (Object.keys(routeMatch.params).length > 0)
|
|
447
|
+
content = injectRouteParams(content, routeMatch.params);
|
|
448
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
449
|
+
if (hotReload)
|
|
450
|
+
content = injectHotReload(content, actualHmrPort);
|
|
451
|
+
if (options.native) {
|
|
452
|
+
const nativeSidebarInjection = "<style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>";
|
|
453
|
+
if (content.includes("<head>"))
|
|
454
|
+
content = content.replace("<head>", `<head>${nativeSidebarInjection}`);
|
|
455
|
+
else
|
|
456
|
+
content = `<head>${nativeSidebarInjection}</head>` + content;
|
|
457
|
+
}
|
|
458
|
+
if (options.titlebarHidden) {
|
|
459
|
+
const tbInjection = "<style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>";
|
|
460
|
+
if (content.includes("<head>"))
|
|
461
|
+
content = content.replace("<head>", `<head>${tbInjection}`);
|
|
462
|
+
else
|
|
463
|
+
content = `<head>${tbInjection}</head>${content}`;
|
|
464
|
+
}
|
|
465
|
+
if (builtPage.boundaries && builtPage.boundaries.length > 0) {
|
|
466
|
+
const { renderStreamingPage, streamToResponse } = await import("../streaming.js");
|
|
467
|
+
return streamToResponse(renderStreamingPage(content, builtPage.boundaries, { timeoutMs: 30000 }), {
|
|
468
|
+
headers: {
|
|
469
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
470
|
+
Pragma: "no-cache",
|
|
471
|
+
Expires: "0"
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return new Response(content, {
|
|
476
|
+
headers: {
|
|
477
|
+
"Content-Type": "text/html",
|
|
478
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
479
|
+
Pragma: "no-cache",
|
|
480
|
+
Expires: "0"
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (pluginRoutes.length > 0) {
|
|
486
|
+
const allPluginPatterns = pluginRoutes.map((pr) => pr.route), pluginMatch = matchRoute(url.pathname, allPluginPatterns);
|
|
487
|
+
if (pluginMatch) {
|
|
488
|
+
const builtPage = builtPluginPages.get(pluginMatch.route.pattern);
|
|
489
|
+
if (builtPage) {
|
|
490
|
+
let content = builtPage.content;
|
|
491
|
+
if (shell)
|
|
492
|
+
content = composeShellWithPage(shell, content);
|
|
493
|
+
if (Object.keys(pluginMatch.params).length > 0)
|
|
494
|
+
content = injectRouteParams(content, pluginMatch.params);
|
|
495
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
496
|
+
if (hotReload)
|
|
497
|
+
content = injectHotReload(content, actualHmrPort);
|
|
498
|
+
return new Response(content, {
|
|
499
|
+
headers: {
|
|
500
|
+
"Content-Type": "text/html",
|
|
501
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
502
|
+
Pragma: "no-cache",
|
|
503
|
+
Expires: "0"
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
for (const { prefix: pluginPrefix } of pluginPageDirs)
|
|
509
|
+
if (pluginPrefix !== "/" && url.pathname.startsWith(pluginPrefix)) {
|
|
510
|
+
const pluginIndex = builtPluginPages.get(pluginPrefix) || builtPluginPages.get(pluginPrefix + "/");
|
|
511
|
+
if (pluginIndex) {
|
|
512
|
+
let content = pluginIndex.content;
|
|
513
|
+
if (shell)
|
|
514
|
+
content = composeShellWithPage(shell, content);
|
|
515
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
516
|
+
if (hotReload)
|
|
517
|
+
content = injectHotReload(content, actualHmrPort);
|
|
518
|
+
return new Response(content, {
|
|
519
|
+
headers: {
|
|
520
|
+
"Content-Type": "text/html",
|
|
521
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
522
|
+
Pragma: "no-cache",
|
|
523
|
+
Expires: "0"
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const indexPage = builtPages.get("/");
|
|
530
|
+
if (indexPage) {
|
|
531
|
+
let content = indexPage.content;
|
|
532
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
533
|
+
if (hotReload)
|
|
534
|
+
content = injectHotReload(content, actualHmrPort);
|
|
535
|
+
if (options.native) {
|
|
536
|
+
const nativeSidebarInjection = "<style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>";
|
|
537
|
+
if (content.includes("<head>"))
|
|
538
|
+
content = content.replace("<head>", `<head>${nativeSidebarInjection}`);
|
|
539
|
+
else
|
|
540
|
+
content = `<head>${nativeSidebarInjection}</head>` + content;
|
|
541
|
+
}
|
|
542
|
+
return new Response(content, {
|
|
543
|
+
headers: {
|
|
544
|
+
"Content-Type": "text/html",
|
|
545
|
+
"Cache-Control": "no-store, no-cache, must-revalidate",
|
|
546
|
+
Pragma: "no-cache",
|
|
547
|
+
Expires: "0"
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
const custom404 = await renderErrorPage(404);
|
|
552
|
+
if (custom404) {
|
|
553
|
+
let content = custom404;
|
|
554
|
+
content = await injectCrosswindCSS(content, absoluteAppDir);
|
|
555
|
+
if (hotReload)
|
|
556
|
+
content = injectHotReload(content, actualHmrPort);
|
|
557
|
+
return new Response(content, {
|
|
558
|
+
status: 404,
|
|
559
|
+
headers: { "Content-Type": "text/html" }
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
return new Response("Not Found", { status: 404 });
|
|
563
|
+
},
|
|
564
|
+
async error(error) {
|
|
565
|
+
const custom500 = await renderErrorPage(500);
|
|
566
|
+
if (custom500)
|
|
567
|
+
return new Response(custom500, {
|
|
568
|
+
status: 500,
|
|
569
|
+
headers: { "Content-Type": "text/html" }
|
|
570
|
+
});
|
|
571
|
+
return new Response(`<pre>${error}
|
|
572
|
+
${error.stack}</pre>`, {
|
|
573
|
+
headers: { "Content-Type": "text/html" }
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
console.clear();
|
|
578
|
+
console.log(`
|
|
579
|
+
${colors.blue}stx${colors.reset} ${colors.green}${process.env.stx_VERSION || "v0.0.10"}${colors.reset} ${colors.dim}ready in ${Math.random() * 10 + 5 | 0}.${Math.random() * 90 + 10 | 0} ms${colors.reset}`);
|
|
580
|
+
console.log(`
|
|
581
|
+
${colors.bright}\u2192 ${colors.cyan}http://localhost:${actualPort}/${colors.reset}`);
|
|
582
|
+
if (hotReload)
|
|
583
|
+
console.log(`${colors.dim} HMR: ws://localhost:${actualHmrPort}${colors.reset}`);
|
|
584
|
+
console.log(`
|
|
585
|
+
${colors.yellow}Routes:${colors.reset}`);
|
|
586
|
+
const allRouteStrings = [...formatRoutes(routes, absoluteAppDir)];
|
|
587
|
+
for (const { route: pluginRoute } of pluginRoutes)
|
|
588
|
+
allRouteStrings.push(`${pluginRoute.pattern}`);
|
|
589
|
+
allRouteStrings.forEach((str, i) => {
|
|
590
|
+
const prefix = i === allRouteStrings.length - 1 ? "\u2514\u2500 " : "\u251C\u2500 ";
|
|
591
|
+
console.log(` ${colors.green}${prefix}${colors.reset}${str}`);
|
|
592
|
+
});
|
|
593
|
+
console.log(`
|
|
594
|
+
Press ${colors.cyan}h${colors.reset} + ${colors.cyan}Enter${colors.reset} to show shortcuts`);
|
|
595
|
+
setupKeyboardShortcuts(server.url.toString(), () => {
|
|
596
|
+
if (hmrServer)
|
|
597
|
+
stopHmrServer();
|
|
598
|
+
server.stop();
|
|
599
|
+
});
|
|
600
|
+
if (options.native) {
|
|
601
|
+
let sidebarConfig;
|
|
602
|
+
const indexPath = path.join(pagesDir, "index.stx");
|
|
603
|
+
if (fs.existsSync(indexPath)) {
|
|
604
|
+
const templateContent = await Bun.file(indexPath).text();
|
|
605
|
+
sidebarConfig = extractSidebarConfig(templateContent);
|
|
606
|
+
}
|
|
607
|
+
const appWindow = projectConfig?.app?.window ?? {};
|
|
608
|
+
await openNativeWindow(actualPort, {
|
|
609
|
+
title: projectConfig?.app?.head?.title || path.basename(absoluteAppDir) || "stx App",
|
|
610
|
+
width: appWindow.width,
|
|
611
|
+
height: appWindow.height,
|
|
612
|
+
darkMode: appWindow.darkMode,
|
|
613
|
+
hotReload: appWindow.hotReload,
|
|
614
|
+
titlebarHidden: appWindow.titlebarHidden ?? options.titlebarHidden === !0,
|
|
615
|
+
nativeSidebar: !!sidebarConfig,
|
|
616
|
+
sidebarConfig
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
if (watch) {
|
|
620
|
+
console.log(`${colors.blue}Watching for changes...${colors.reset}`);
|
|
621
|
+
const isStaticAsset = (filename) => {
|
|
622
|
+
return filename.startsWith("public/") || filename.startsWith("public\\");
|
|
623
|
+
}, isTemplateFile = (filename) => {
|
|
624
|
+
const ext = filename.toLowerCase();
|
|
625
|
+
return ext.endsWith(".stx") || ext.endsWith(".html") || ext.endsWith(".md");
|
|
626
|
+
}, watcher = fs.watch(absoluteAppDir, { recursive: !0 }, async (eventType, filename) => {
|
|
627
|
+
if (!filename || shouldIgnoreFile(filename))
|
|
628
|
+
return;
|
|
629
|
+
if (shouldReloadOnChange(filename))
|
|
630
|
+
if (isStaticAsset(filename)) {
|
|
631
|
+
console.log(`${colors.cyan}${filename} changed${colors.reset}`);
|
|
632
|
+
if (hotReload && hmrServer)
|
|
633
|
+
hmrServer.reload(filename);
|
|
634
|
+
} else if (isTemplateFile(filename)) {
|
|
635
|
+
console.log(`${colors.yellow}${filename} changed, rebuilding...${colors.reset}`);
|
|
636
|
+
partialsCache.clear();
|
|
637
|
+
clearComponentCache();
|
|
638
|
+
try {
|
|
639
|
+
const { invalidateFileCache, templateCache } = await import("../caching.js");
|
|
640
|
+
invalidateFileCache(path.resolve(absoluteAppDir, filename));
|
|
641
|
+
templateCache.delete(path.resolve(absoluteAppDir, filename));
|
|
642
|
+
} catch {}
|
|
643
|
+
if (shellPath && filename) {
|
|
644
|
+
if (path.resolve(absoluteAppDir, filename) === shellPath || path.basename(shellPath) === filename) {
|
|
645
|
+
const newShell = await processShell(shellPath, options.stxOptions || {});
|
|
646
|
+
if (newShell)
|
|
647
|
+
shell = newShell;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
await buildAllPages();
|
|
651
|
+
await rebuildCrosswindCSS(absoluteAppDir);
|
|
652
|
+
if (hotReload && hmrServer)
|
|
653
|
+
hmrServer.reload(filename);
|
|
654
|
+
} else {
|
|
655
|
+
console.log(`${colors.yellow}${filename} changed, rebuilding...${colors.reset}`);
|
|
656
|
+
partialsCache.clear();
|
|
657
|
+
clearComponentCache();
|
|
658
|
+
try {
|
|
659
|
+
const { invalidateFileCache, templateCache } = await import("../caching.js");
|
|
660
|
+
invalidateFileCache(path.resolve(absoluteAppDir, filename));
|
|
661
|
+
templateCache.delete(path.resolve(absoluteAppDir, filename));
|
|
662
|
+
} catch {}
|
|
663
|
+
await buildAllPages();
|
|
664
|
+
if (hotReload && hmrServer)
|
|
665
|
+
hmrServer.reload(filename);
|
|
666
|
+
}
|
|
667
|
+
else if (isCssOnlyChange(filename)) {
|
|
668
|
+
console.log(`${colors.cyan}CSS ${filename} changed${colors.reset}`);
|
|
669
|
+
if (hotReload && hmrServer)
|
|
670
|
+
hmrServer.updateCss(filename);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
process.on("SIGINT", () => {
|
|
674
|
+
watcher.close();
|
|
675
|
+
if (hmrServer)
|
|
676
|
+
stopHmrServer();
|
|
677
|
+
server.stop();
|
|
678
|
+
process.exit(0);
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
return !0;
|
|
682
|
+
}
|