@teyik0/furin 0.7.0-alpha.3 → 0.8.0-alpha.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/README.md +1 -1
- package/dist/adapter/build.d.ts +9 -0
- package/dist/adapter/bun/server.d.ts +1 -0
- package/dist/adapter/bun.d.ts +7 -3
- package/dist/adapter/package.d.ts +1 -0
- package/dist/adapter/prerender.d.ts +21 -0
- package/dist/adapter/runtime-build.d.ts +24 -10
- package/dist/adapter/server-bundle.d.ts +20 -0
- package/dist/adapter/static.d.ts +2 -2
- package/dist/adapter/types.d.ts +81 -0
- package/dist/adapter/vercel/bootstrap.d.ts +5 -0
- package/dist/adapter/vercel/data.d.ts +23 -0
- package/dist/adapter/vercel/handler.d.ts +10 -0
- package/dist/adapter/vercel.d.ts +13 -3
- package/dist/adapter/vercel.js +516 -0
- package/dist/build/bun-build.d.ts +4 -0
- package/dist/build/compile-entry.ts +1 -0
- package/dist/build/discover-mounts-process.d.ts +1 -0
- package/dist/build/discover-mounts.d.ts +6 -0
- package/dist/build/elysia-aot-worker.d.ts +4 -0
- package/dist/build/elysia-aot.d.ts +7 -1
- package/dist/build/entry-template.d.ts +14 -7
- package/dist/build/entry-template.ts +33 -18
- package/dist/build/hydrate.d.ts +15 -2
- package/dist/build/index.d.ts +7 -3
- package/dist/build/index.js +8842 -15395
- package/dist/build/private-server-sourcemaps.d.ts +2 -0
- package/dist/build/route-types.d.ts +8 -2
- package/dist/build/server-app-entry.d.ts +2 -2
- package/dist/build/shared.d.ts +3 -5
- package/dist/build/types.d.ts +16 -16
- package/dist/cache.js +117 -32
- package/dist/cli/config.d.ts +2 -2
- package/dist/cli/index.js +8953 -15269
- package/dist/client/chunks/client-brdfd773.js +852 -0
- package/dist/client/chunks/client-k29262a4.js +59 -0
- package/dist/client/chunks/client-k88668k7.js +159 -0
- package/dist/client/chunks/client-xy6g38kx.js +317 -0
- package/dist/client/default-screens.d.ts +0 -11
- package/dist/client/define-route.d.ts +2 -1
- package/dist/client/hmr.d.ts +1 -1
- package/dist/client/internal/runtime-types.d.ts +7 -1
- package/dist/client/link.d.ts +1 -0
- package/dist/client/link.js +1790 -4190
- package/dist/client/mutation.d.ts +5 -0
- package/dist/client/query-store.d.ts +17 -7
- package/dist/client/query.d.ts +6 -8
- package/dist/client/request-id.d.ts +1 -0
- package/dist/client/route-api.d.ts +4 -4
- package/dist/client/route-element.d.ts +51 -0
- package/dist/client/router/boundary-tree.d.ts +1 -9
- package/dist/client/router/cache-generation.d.ts +15 -0
- package/dist/client/router/context.d.ts +13 -2
- package/dist/client/router/fetch-observers.d.ts +9 -0
- package/dist/client/router/hmr-refresh.d.ts +12 -0
- package/dist/client/router/index.d.ts +5 -7
- package/dist/client/router/link-utils.d.ts +0 -2
- package/dist/client/router/navigation-controller.d.ts +76 -0
- package/dist/client/router/navigation.d.ts +1 -0
- package/dist/client/router/page-fetch.d.ts +38 -0
- package/dist/client/router/provider.d.ts +2 -3
- package/dist/client/router/search/index.d.ts +11 -4
- package/dist/client/router/search/index.js +60 -0
- package/dist/client/router/spa-response.d.ts +9 -26
- package/dist/client/router/sync-catch-up.d.ts +3 -2
- package/dist/client/router/transport.d.ts +4 -0
- package/dist/client/router/types.d.ts +120 -46
- package/dist/client/router/use-fetch-interception.d.ts +12 -0
- package/dist/client/router/use-history-sync.d.ts +7 -0
- package/dist/client/router/use-hmr-refresh.d.ts +8 -0
- package/dist/client/router/use-sync-stream.d.ts +16 -0
- package/dist/client/server-error.d.ts +4 -7
- package/dist/client/sync.d.ts +43 -30
- package/dist/client.d.ts +2 -1
- package/dist/client.js +279 -829
- package/dist/config.d.ts +11 -12
- package/dist/config.js +0 -30
- package/dist/define-route.d.ts +262 -517
- package/dist/devtools/protocol.d.ts +4 -3
- package/dist/furin.d.ts +41 -31
- package/dist/furin.js +20560 -18970
- package/dist/plugin/binding-scope.d.ts +15 -2
- package/dist/plugin/client-plugin.d.ts +19 -0
- package/dist/plugin/dead-code-elimination.d.ts +14 -3
- package/dist/plugin/dev-routes.d.ts +22 -0
- package/dist/plugin/hmr-data-signature.d.ts +3 -0
- package/dist/plugin/hmr-hook-signature.d.ts +9 -0
- package/dist/plugin/index.d.ts +1 -6
- package/dist/plugin/index.js +1753 -1214
- package/dist/plugin/module-bindings.d.ts +11 -0
- package/dist/plugin/module-transform.d.ts +29 -0
- package/dist/plugin/preflight.d.ts +8 -0
- package/dist/plugin/route-chains.d.ts +35 -0
- package/dist/plugin/route-config.d.ts +28 -0
- package/dist/plugin/route-modules.d.ts +35 -0
- package/dist/plugin/route-registry.d.ts +12 -0
- package/dist/plugin/route-tree.d.ts +43 -0
- package/dist/plugin/strip-server-stages.d.ts +10 -0
- package/dist/plugin/strip-server.d.ts +10 -0
- package/dist/plugin/transform-client-module.d.ts +3 -0
- package/dist/plugin/transform-client.d.ts +0 -2
- package/dist/plugin/transform-isomorphic.d.ts +3 -2
- package/dist/routes.d.ts +15 -5
- package/dist/rsc/build/client-references.d.ts +8 -0
- package/dist/rsc/build/discover.d.ts +7 -0
- package/dist/rsc/build/flight-loader.d.ts +1 -0
- package/dist/rsc/build/index.d.ts +4 -1
- package/dist/rsc/build/paths.d.ts +2 -0
- package/dist/rsc/bundled-client-codec.d.ts +1 -0
- package/dist/rsc/client-codec.d.ts +3 -0
- package/dist/rsc/client-references.d.ts +22 -0
- package/dist/rsc/server-client-codec.d.ts +1 -0
- package/dist/rsc/server-codec.js +3889 -2
- package/dist/rsc/slot-proxy.d.ts +11 -0
- package/dist/rsc/transport-benchmark.d.ts +2 -1
- package/dist/rsc-client.js +16 -164
- package/dist/rsc-server.d.ts +1 -5
- package/dist/rsc.d.ts +1 -5
- package/dist/rsc.js +233 -73
- package/dist/server/assets/client-dir.d.ts +1 -0
- package/dist/server/auto-invalidate/index.d.ts +2 -2
- package/dist/server/auto-invalidate/plugin.d.ts +21 -15
- package/dist/server/auto-invalidate/types.d.ts +0 -2
- package/dist/server/bounded-body.d.ts +6 -0
- package/dist/server/browser-events/plugin.d.ts +4 -1
- package/dist/server/browser-events/shutdown.d.ts +1 -1
- package/dist/server/cache/dev-loader.d.ts +6 -1
- package/dist/server/cache/index.d.ts +4 -9
- package/dist/server/cache/invalidation.d.ts +7 -2
- package/dist/server/cache/isr-ssg.d.ts +6 -1
- package/dist/server/cache/page-cache.d.ts +5 -0
- package/dist/server/cache/purger.d.ts +14 -4
- package/dist/server/cache/redis/index.d.ts +1 -34
- package/dist/server/cache/redis/index.js +51 -25
- package/dist/server/cache/redis/scripts.d.ts +1 -1
- package/dist/server/cache/route-cache.d.ts +18 -2
- package/dist/server/cache/runtime-cache.d.ts +7 -0
- package/dist/server/context-logger.d.ts +6 -1
- package/dist/server/dev/graph.d.ts +4 -3
- package/dist/server/dev/runtime.d.ts +4 -0
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev/stack-location.d.ts +9 -0
- package/dist/server/dev-page-imports.d.ts +42 -0
- package/dist/server/dev-page-plugin.d.ts +2 -49
- package/dist/server/devtools/instrumentation.d.ts +1 -3
- package/dist/server/devtools/instrumentation.production.d.ts +0 -2
- package/dist/server/devtools/request-context.d.ts +7 -0
- package/dist/server/evlog.d.ts +18 -6
- package/dist/server/instance.d.ts +52 -44
- package/dist/server/internal.d.ts +51 -14
- package/dist/server/internal.js +9749 -2095
- package/dist/server/lang-detect.d.ts +4 -4
- package/dist/server/logger.d.ts +6 -0
- package/dist/server/logging/ingest-plugin.d.ts +32 -0
- package/dist/server/mode.d.ts +17 -0
- package/dist/server/prerender.d.ts +32 -0
- package/dist/server/prod/runtime.d.ts +5 -0
- package/dist/server/production-server.js +992 -726
- package/dist/server/registrations.d.ts +14 -0
- package/dist/server/render/assemble.d.ts +0 -22
- package/dist/server/render/buffered-render.d.ts +20 -0
- package/dist/server/render/document-stream.d.ts +45 -0
- package/dist/server/render/document.d.ts +1 -1
- package/dist/server/render/element.d.ts +2 -5
- package/dist/server/render/index.d.ts +4 -5
- package/dist/server/render/index.ts +4 -21
- package/dist/server/render/isr-revalidation.d.ts +5 -0
- package/dist/server/render/isr-shared-cache.d.ts +23 -0
- package/dist/server/render/isr.d.ts +19 -1
- package/dist/server/render/loader-errors.d.ts +33 -0
- package/dist/server/render/loader-segments.d.ts +40 -0
- package/dist/server/render/loaders.d.ts +16 -32
- package/dist/server/render/mixed-cache.d.ts +2 -2
- package/dist/server/render/navigation-head.d.ts +13 -0
- package/dist/server/render/not-found-plugin.d.ts +18 -0
- package/dist/server/render/observe-loader.d.ts +1 -0
- package/dist/server/render/ppr-document.d.ts +1 -1
- package/dist/server/render/ppr-request.d.ts +0 -2
- package/dist/server/render/ppr-route.d.ts +13 -2
- package/dist/server/render/prepare-render.d.ts +57 -0
- package/dist/server/render/request-loaders.d.ts +19 -0
- package/dist/server/render/route-frame-transport.d.ts +7 -1
- package/dist/server/render/shell.d.ts +1 -1
- package/dist/server/render/shell.ts +1 -1
- package/dist/server/render/ssr-transport.d.ts +11 -0
- package/dist/server/render/ssr.d.ts +1 -116
- package/dist/server/render/static-params.d.ts +15 -0
- package/dist/server/router/discovery.d.ts +1 -0
- package/dist/server/router/dispatch.d.ts +96 -0
- package/dist/server/router/hmr.d.ts +14 -24
- package/dist/server/router/patterns.d.ts +15 -20
- package/dist/server/router/plugin.d.ts +26 -24
- package/dist/server/router/schemas.d.ts +6 -24
- package/dist/server/router/types.d.ts +0 -2
- package/dist/server/runtime-env.d.ts +6 -1
- package/dist/server/static-export.d.ts +38 -0
- package/dist/server/static-export.js +10667 -0
- package/dist/server/sync/adapter.d.ts +11 -0
- package/dist/server/sync/atomic.d.ts +0 -2
- package/dist/server/sync/config.d.ts +0 -1
- package/dist/server/sync/drizzle/index.js +112 -68
- package/dist/server/sync/fingerprint.d.ts +0 -1
- package/dist/server/sync/index.d.ts +2 -6
- package/dist/server/sync/index.js +1689 -1364
- package/dist/server/sync/invalidate-sync.d.ts +10 -0
- package/dist/server/sync/plugin.d.ts +18 -55
- package/dist/server/sync/postgres/execute.d.ts +2 -2
- package/dist/server/sync/postgres/index.d.ts +3 -1
- package/dist/server/sync/postgres/index.js +68 -37
- package/dist/server/sync/postgres/migration.sql +2 -0
- package/dist/server/sync/principal-journal.d.ts +11 -0
- package/dist/server/sync/prisma/index.js +74 -39
- package/dist/server/sync/queries.d.ts +57 -16
- package/dist/server/sync/redis/index.d.ts +2 -1
- package/dist/server/sync/redis/index.js +49 -5
- package/dist/server/sync/redis/scripts.d.ts +2 -1
- package/dist/server/sync/response.d.ts +3 -0
- package/dist/server/sync/runtime.d.ts +5 -1
- package/dist/server/sync/sqlite/index.d.ts +3 -1
- package/dist/server/sync/sqlite/index.js +58 -27
- package/dist/server/sync/stream.d.ts +32 -7
- package/dist/server/weak-registry.d.ts +9 -0
- package/dist/shared/await.d.ts +2 -1
- package/dist/shared/compact-json.d.ts +1 -0
- package/dist/shared/defer.d.ts +1 -1
- package/dist/shared/deferred-ndjson.d.ts +3 -2
- package/dist/shared/elysia-contract.d.ts +2 -0
- package/dist/shared/in-memory-apps.d.ts +7 -0
- package/dist/shared/invalidation-header.d.ts +13 -0
- package/dist/shared/navigation-data.d.ts +7 -0
- package/dist/shared/prefix.d.ts +11 -5
- package/dist/shared/route-frame.d.ts +3 -0
- package/dist/shared/route-map.d.ts +7 -0
- package/dist/shared/route-matches.d.ts +41 -0
- package/dist/shared/route-specificity.d.ts +2 -0
- package/dist/shared/search-params.d.ts +2 -3
- package/dist/shared/sync-query.d.ts +6 -13
- package/dist/shared/utils/ast-walk.d.ts +3 -11
- package/package.json +32 -21
- package/src/adapter/README.md +37 -16
- package/src/adapter/build.ts +269 -0
- package/src/adapter/bun/server.ts +14 -0
- package/src/adapter/bun.ts +89 -265
- package/src/adapter/furin-app.d.ts +14 -0
- package/src/adapter/package.ts +31 -27
- package/src/adapter/prerender.ts +97 -0
- package/src/adapter/runtime-build.ts +83 -93
- package/src/adapter/server-bundle.ts +110 -0
- package/src/adapter/static.ts +259 -247
- package/src/adapter/types.ts +89 -0
- package/src/adapter/vercel/bootstrap.ts +85 -0
- package/src/adapter/vercel/data.ts +21 -0
- package/src/adapter/vercel/handler.ts +132 -0
- package/src/adapter/vercel.ts +329 -659
- package/src/build/bun-build.ts +3 -0
- package/src/build/client.ts +22 -60
- package/src/build/compile-entry.ts +1 -0
- package/src/build/discover-mounts-process.ts +13 -0
- package/src/build/discover-mounts.ts +40 -0
- package/src/build/elysia-aot-worker.ts +84 -2
- package/src/build/elysia-aot.ts +61 -2
- package/src/build/entry-template.ts +33 -18
- package/src/build/hydrate.ts +122 -44
- package/src/build/index.ts +156 -108
- package/src/build/private-server-sourcemaps.ts +5 -0
- package/src/build/production-instrumentation.ts +22 -19
- package/src/build/route-types.ts +93 -11
- package/src/build/server-app-entry.ts +4 -21
- package/src/build/shared.ts +9 -41
- package/src/build/types.ts +14 -20
- package/src/build/virtual-entry.ts +2 -4
- package/src/cli/config.ts +133 -6
- package/src/cli/index.ts +59 -21
- package/src/cli/preview.ts +2 -1
- package/src/client/boundaries.tsx +5 -14
- package/src/client/default-screens.tsx +2 -2
- package/src/client/define-route.ts +3 -2
- package/src/client/hmr.ts +1 -1
- package/src/client/internal/runtime-types.ts +7 -1
- package/src/client/link.tsx +80 -43
- package/src/client/mutation.ts +98 -3
- package/src/client/query-store.ts +160 -29
- package/src/client/query.tsx +12 -29
- package/src/client/request-id.ts +10 -0
- package/src/client/route-api.tsx +6 -6
- package/src/client/route-element.tsx +155 -0
- package/src/client/router/boundary-tree.tsx +2 -93
- package/src/client/router/cache-generation.ts +37 -0
- package/src/client/router/context.ts +40 -4
- package/src/client/router/fetch-observers.ts +46 -0
- package/src/client/router/hmr-refresh.ts +50 -0
- package/src/client/router/index.ts +7 -29
- package/src/client/router/link-utils.ts +19 -31
- package/src/client/router/navigation-controller.ts +547 -0
- package/src/client/router/navigation.ts +3 -2
- package/src/client/router/optimistic.ts +2 -3
- package/src/client/router/page-fetch.ts +272 -0
- package/src/client/router/provider.tsx +223 -1079
- package/src/client/router/search/index.ts +38 -14
- package/src/client/router/spa-response.ts +19 -70
- package/src/client/router/sync-catch-up.ts +65 -7
- package/src/client/router/transport.ts +23 -0
- package/src/client/router/types.ts +203 -61
- package/src/client/router/use-fetch-interception.ts +52 -0
- package/src/client/router/use-history-sync.ts +56 -0
- package/src/client/router/use-hmr-refresh.ts +51 -0
- package/src/client/router/use-sync-stream.ts +129 -0
- package/src/client/server-error.ts +2 -40
- package/src/client/sync.ts +268 -378
- package/src/client.ts +2 -7
- package/src/config.ts +23 -45
- package/src/define-route.ts +487 -882
- package/src/devtools/devtools-element.js +10 -3
- package/src/devtools/protocol.ts +3 -3
- package/src/furin.ts +253 -1086
- package/src/plugin/binding-scope.ts +219 -94
- package/src/plugin/client-plugin.ts +145 -0
- package/src/plugin/dead-code-elimination.ts +390 -111
- package/src/plugin/dev-routes.ts +453 -0
- package/src/plugin/hmr-data-signature.ts +161 -0
- package/src/plugin/hmr-dependencies.ts +2 -4
- package/src/plugin/hmr-hook-signature.ts +252 -0
- package/src/plugin/index.ts +3 -96
- package/src/plugin/module-bindings.ts +216 -0
- package/src/plugin/module-transform.ts +63 -0
- package/src/plugin/preflight.ts +66 -0
- package/src/plugin/route-chains.ts +309 -0
- package/src/plugin/route-config.ts +451 -0
- package/src/plugin/route-modules.ts +209 -0
- package/src/plugin/route-registry.ts +316 -0
- package/src/plugin/route-tree.ts +248 -0
- package/src/plugin/strip-server-stages.ts +197 -0
- package/src/plugin/strip-server.ts +22 -0
- package/src/plugin/transform-client-module.ts +36 -31
- package/src/plugin/transform-client.ts +33 -1114
- package/src/plugin/transform-dev-page.ts +84 -92
- package/src/plugin/transform-isomorphic.ts +396 -185
- package/src/routes.ts +15 -5
- package/src/rsc/build/client-references.ts +267 -0
- package/src/rsc/build/discover.ts +226 -0
- package/src/rsc/build/flight-loader.ts +69 -0
- package/src/rsc/build/index.ts +53 -31
- package/src/rsc/build/paths.ts +7 -0
- package/src/rsc/bundled-client-codec.ts +4 -0
- package/src/rsc/client-codec.ts +12 -3
- package/src/rsc/client-references.ts +138 -0
- package/src/rsc/codec.ts +30 -21
- package/src/rsc/flight-drain.ts +6 -29
- package/src/rsc/react-server-dom-webpack.d.ts +1 -1
- package/src/rsc/server-client-codec.ts +14 -0
- package/src/rsc/server-codec.ts +5 -8
- package/src/rsc/slot-proxy.ts +34 -0
- package/src/rsc/transport-benchmark.ts +1 -1
- package/src/rsc-server.tsx +5 -23
- package/src/rsc.tsx +5 -29
- package/src/server/assets/client-dir.ts +110 -0
- package/src/server/assets/production.ts +1 -1
- package/src/server/auto-invalidate/index.ts +2 -7
- package/src/server/auto-invalidate/plugin.ts +43 -15
- package/src/server/auto-invalidate/registry.ts +6 -6
- package/src/server/auto-invalidate/runtime.ts +16 -98
- package/src/server/auto-invalidate/types.ts +0 -6
- package/src/server/bounded-body.ts +38 -0
- package/src/server/browser-events/plugin.ts +109 -22
- package/src/server/browser-events/shutdown.ts +28 -9
- package/src/server/cache/dev-loader.ts +30 -16
- package/src/server/cache/index.ts +2 -15
- package/src/server/cache/invalidation.ts +27 -46
- package/src/server/cache/isr-ssg.ts +6 -1
- package/src/server/cache/isr.ts +11 -11
- package/src/server/cache/page-cache-state.ts +2 -2
- package/src/server/cache/page-cache.ts +13 -9
- package/src/server/cache/purger.ts +64 -8
- package/src/server/cache/redis/index.ts +17 -27
- package/src/server/cache/redis/scripts.ts +21 -4
- package/src/server/cache/registry.ts +3 -3
- package/src/server/cache/route-cache.ts +47 -13
- package/src/server/cache/runtime-cache.ts +144 -24
- package/src/server/cache/ssg.ts +7 -5
- package/src/server/context-logger.ts +46 -8
- package/src/server/dev/diagnostics.ts +6 -56
- package/src/server/dev/error.ts +3 -34
- package/src/server/dev/graph.ts +35 -22
- package/src/server/dev/rewrite-module-specifiers.ts +15 -19
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev/runtime.ts +404 -0
- package/src/server/dev/stack-location.ts +46 -0
- package/src/server/dev-page-imports.ts +183 -0
- package/src/server/dev-page-plugin.ts +39 -302
- package/src/server/devtools/hub.ts +3 -3
- package/src/server/devtools/instrumentation.production.ts +0 -8
- package/src/server/devtools/instrumentation.ts +6 -8
- package/src/server/devtools/plugin.ts +2 -1
- package/src/server/devtools/request-context.ts +67 -16
- package/src/server/evlog.ts +119 -55
- package/src/server/instance.ts +187 -138
- package/src/server/internal.ts +66 -62
- package/src/server/lang-detect.ts +31 -22
- package/src/server/logger.ts +20 -7
- package/src/server/logging/ingest-plugin.ts +123 -0
- package/src/server/mode.ts +19 -0
- package/src/server/prerender.ts +122 -0
- package/src/server/prod/runtime.ts +181 -0
- package/src/server/production-server.ts +43 -17
- package/src/server/registrations.ts +38 -0
- package/src/server/render/assemble.ts +5 -8
- package/src/server/render/buffered-render.ts +171 -0
- package/src/server/render/document-stream.ts +188 -0
- package/src/server/render/document.tsx +5 -3
- package/src/server/render/element.tsx +6 -73
- package/src/server/render/index.ts +4 -21
- package/src/server/render/isr-revalidation.ts +246 -0
- package/src/server/render/isr-shared-cache.ts +141 -0
- package/src/server/render/isr.ts +212 -516
- package/src/server/render/loader-errors.ts +183 -0
- package/src/server/render/loader-segments.ts +149 -0
- package/src/server/render/loaders.ts +126 -547
- package/src/server/render/mixed-cache.ts +28 -27
- package/src/server/render/navigation-head.ts +33 -0
- package/src/server/render/not-found-plugin.ts +31 -0
- package/src/server/render/not-found.ts +32 -8
- package/src/server/render/observe-loader.ts +46 -0
- package/src/server/render/ppr-document.ts +36 -14
- package/src/server/render/ppr-request.ts +2 -2
- package/src/server/render/ppr-route.ts +79 -18
- package/src/server/render/prepare-render.ts +251 -0
- package/src/server/render/request-loaders.ts +216 -0
- package/src/server/render/route-frame-transport.ts +41 -4
- package/src/server/render/shell.ts +1 -1
- package/src/server/render/ssg.ts +9 -20
- package/src/server/render/ssr-transport.ts +221 -0
- package/src/server/render/ssr.ts +95 -956
- package/src/server/render/static-params.ts +32 -0
- package/src/server/render/template.ts +7 -7
- package/src/server/router/discovery.ts +82 -159
- package/src/server/router/dispatch.ts +337 -0
- package/src/server/router/hmr.ts +177 -190
- package/src/server/router/patterns.ts +39 -65
- package/src/server/router/plugin.ts +234 -359
- package/src/server/router/schemas.ts +6 -39
- package/src/server/router/source-version.ts +5 -4
- package/src/server/router/types.ts +0 -2
- package/src/server/runtime-env.ts +6 -1
- package/src/server/static-export.ts +143 -0
- package/src/server/sync/adapter.ts +11 -0
- package/src/server/sync/atomic.ts +16 -36
- package/src/server/sync/config.ts +6 -14
- package/src/server/sync/drizzle/index.ts +12 -20
- package/src/server/sync/fingerprint.ts +1 -1
- package/src/server/sync/index.ts +2 -10
- package/src/server/sync/invalidate-sync.ts +31 -0
- package/src/server/sync/mutation-handler.ts +6 -0
- package/src/server/sync/plugin.ts +171 -129
- package/src/server/sync/postgres/execute.ts +9 -1
- package/src/server/sync/postgres/index.ts +71 -39
- package/src/server/sync/postgres/migration.sql +2 -0
- package/src/server/sync/principal-journal.ts +78 -0
- package/src/server/sync/prisma/index.ts +1 -0
- package/src/server/sync/queries.ts +133 -40
- package/src/server/sync/query-context.ts +38 -5
- package/src/server/sync/redis/index.ts +34 -6
- package/src/server/sync/redis/scripts.ts +10 -1
- package/src/server/sync/response.ts +47 -67
- package/src/server/sync/runtime.ts +24 -7
- package/src/server/sync/sqlite/index.ts +92 -61
- package/src/server/sync/sqlite/migration.sql +1 -0
- package/src/server/sync/stream.ts +47 -26
- package/src/server/sync/validation.ts +1 -1
- package/src/server/weak-registry.ts +37 -0
- package/src/shared/await.tsx +2 -1
- package/src/shared/compact-json.ts +1 -1
- package/src/shared/defer.ts +1 -1
- package/src/shared/deferred-ndjson.ts +142 -120
- package/src/shared/elysia-contract.ts +7 -0
- package/src/shared/error.ts +1 -4
- package/src/shared/in-memory-apps.ts +24 -0
- package/src/shared/invalidation-header.ts +38 -0
- package/src/shared/navigation-data.ts +29 -0
- package/src/shared/prefix.ts +42 -6
- package/src/shared/route-frame.ts +82 -26
- package/src/shared/route-map.ts +23 -39
- package/src/shared/route-matches.ts +59 -0
- package/src/shared/route-specificity.ts +28 -0
- package/src/shared/search-params.ts +6 -35
- package/src/shared/sync-query.ts +30 -23
- package/src/shared/utils/ast-walk.ts +9 -25
- package/src/shared/utils/index.ts +1 -1
- package/dist/build/scan-server.d.ts +0 -14
- package/dist/build/ssg-cache.d.ts +0 -18
- package/dist/plugin/route-config-autofix.d.ts +0 -31
- package/dist/plugin/routes.d.ts +0 -34
- package/dist/server/router/hmr.production.d.ts +0 -7
- package/src/build/scan-server.ts +0 -112
- package/src/build/ssg-cache.ts +0 -126
- package/src/plugin/route-config-autofix.ts +0 -1149
- package/src/plugin/routes.ts +0 -1140
- package/src/server/router/hmr.production.ts +0 -18
package/src/build/index.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noAwaitInLoops: build phases run in sequence because later phases consume prior artifacts
|
|
2
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { buildAdapterTarget } from "../adapter/build.ts";
|
|
5
|
+
import { bun } from "../adapter/bun.ts";
|
|
5
6
|
import { buildPackageTarget } from "../adapter/package";
|
|
6
7
|
import type { RuntimeTargetApp } from "../adapter/runtime-build";
|
|
7
8
|
import { buildStaticTarget } from "../adapter/static";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import type { FurinAdapter } from "../adapter/types.ts";
|
|
10
|
+
import { vercel } from "../adapter/vercel.ts";
|
|
11
|
+
import { BUILD_TARGETS, type BuildTarget, type FurinPlugin, type FurinTarget } from "../config";
|
|
12
|
+
import { assertValidRouteConfig } from "../plugin/route-config.ts";
|
|
10
13
|
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
11
14
|
import { normalizePrefix } from "../server/instance.ts";
|
|
12
15
|
import { scanPages } from "../server/router/discovery.ts";
|
|
13
|
-
import { assertNoPrefixSlugCollisions } from "../shared/prefix.ts";
|
|
16
|
+
import { assertNoPrefixSlugCollisions, assertOnePagesDirPerMount } from "../shared/prefix.ts";
|
|
14
17
|
import { withProductionBuild } from "../shared/production-build.ts";
|
|
15
|
-
import {
|
|
18
|
+
import { discoverFurinMounts } from "./discover-mounts.ts";
|
|
19
|
+
import { writeRouteTypes } from "./route-types";
|
|
16
20
|
import { ensureDir, toBuildRouteManifestEntry, toPosixPath } from "./shared";
|
|
17
21
|
import type { BuildAppOptions, BuildAppResult, BuildManifest } from "./types";
|
|
18
22
|
|
|
19
23
|
// biome-ignore lint/performance/noBarrelFile: intentional — build/index.ts is the public build API entry
|
|
20
24
|
export { buildClient } from "./client";
|
|
21
|
-
export { writeDevFiles } from "./hydrate";
|
|
22
25
|
export { writeRouteTypes } from "./route-types";
|
|
23
|
-
export { buildSSGCacheSnapshot, type SSGCacheSnapshot } from "./ssg-cache";
|
|
24
26
|
export type {
|
|
25
27
|
BuildAppOptions,
|
|
26
28
|
BuildAppResult,
|
|
@@ -34,7 +36,32 @@ export type {
|
|
|
34
36
|
// "package" is intentionally excluded from `--target all` — it is an
|
|
35
37
|
// alternative packaging of ONE app, not an additional deploy target.
|
|
36
38
|
const IMPLEMENTED_TARGETS = ["bun", "vercel", "static"] as const satisfies BuildTarget[];
|
|
37
|
-
|
|
39
|
+
|
|
40
|
+
/** Targets without a server bundle: static ships none, package leaves it to the host. */
|
|
41
|
+
function isServerless(target: FurinTarget): target is "package" | "static" {
|
|
42
|
+
return target === "static" || target === "package";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function requestedTargets(target: BuildAppOptions["target"]): FurinTarget[] {
|
|
46
|
+
if (target === "all") {
|
|
47
|
+
return [...IMPLEMENTED_TARGETS];
|
|
48
|
+
}
|
|
49
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
50
|
+
for (const entry of targets) {
|
|
51
|
+
if (typeof entry === "string" && !(BUILD_TARGETS as readonly string[]).includes(entry)) {
|
|
52
|
+
throw new Error(`[furin] Unsupported build target "${entry}"`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return targets;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function adapterFor(target: FurinAdapter | "bun" | "vercel", options: BuildAppOptions): FurinAdapter {
|
|
59
|
+
if (typeof target !== "string") {
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
return target === "bun" ? bun(options.compile) : vercel({});
|
|
63
|
+
}
|
|
64
|
+
const BUILD_OUTPUT_DIR = ".furin/build";
|
|
38
65
|
let isomorphicRuntimePluginRegistered = false;
|
|
39
66
|
|
|
40
67
|
function registerIsomorphicRuntimePlugin(): void {
|
|
@@ -49,14 +76,14 @@ function registerIsomorphicRuntimePlugin(): void {
|
|
|
49
76
|
* Resolves the list of apps to build, in priority order:
|
|
50
77
|
* 1. explicit `apps` config (furin.config.ts),
|
|
51
78
|
* 2. explicit single `pagesDir` option (mounted at root),
|
|
52
|
-
* 3. every `furin({ pagesDir, prefix })` call
|
|
79
|
+
* 3. every `furin({ pagesDir, prefix })` call made by evaluating the server entry,
|
|
53
80
|
* 4. the `src/pages` default.
|
|
54
81
|
*/
|
|
55
|
-
function resolveAppSpecs(
|
|
56
|
-
options:
|
|
82
|
+
async function resolveAppSpecs(
|
|
83
|
+
options: RouteTypegenOptions,
|
|
57
84
|
serverEntry: string | null,
|
|
58
85
|
rootDir: string
|
|
59
|
-
): Array<{ pagesDir: string; prefix: string }
|
|
86
|
+
): Promise<Array<{ pagesDir: string; prefix: string }>> {
|
|
60
87
|
if (options.apps && options.apps.length > 0) {
|
|
61
88
|
// normalizePrefix is the choke point for config/CLI-provided prefixes:
|
|
62
89
|
// `"/"` → `""` (otherwise the bun target derives `publicPath: "//_client/"`,
|
|
@@ -71,9 +98,9 @@ function resolveAppSpecs(
|
|
|
71
98
|
return [{ pagesDir: resolve(rootDir, options.pagesDir), prefix: "" }];
|
|
72
99
|
}
|
|
73
100
|
if (serverEntry) {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
101
|
+
const mounted = await discoverFurinMounts(serverEntry, rootDir);
|
|
102
|
+
if (mounted.length > 0) {
|
|
103
|
+
return mounted.map((app) => ({
|
|
77
104
|
pagesDir: resolve(rootDir, app.pagesDir),
|
|
78
105
|
prefix: app.prefix,
|
|
79
106
|
}));
|
|
@@ -82,31 +109,15 @@ function resolveAppSpecs(
|
|
|
82
109
|
return [{ pagesDir: resolve(rootDir, "src/pages"), prefix: "" }];
|
|
83
110
|
}
|
|
84
111
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
async function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (options.target === "static" || options.target === "package") {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
if (options.serverEntry) {
|
|
98
|
-
const resolved = resolve(rootDir, options.serverEntry);
|
|
99
|
-
if (existsSync(resolved)) {
|
|
100
|
-
return resolved;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const entry = resolve(rootDir, "src/server.ts");
|
|
104
|
-
if (!existsSync(entry)) {
|
|
105
|
-
throw new Error("[furin] Entrypoint server.ts not found");
|
|
106
|
-
}
|
|
107
|
-
return entry;
|
|
108
|
-
})();
|
|
109
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Registers runtime plugins, resolves the configured apps and scans their
|
|
114
|
+
* pages. Shared by `buildApp()` and `generateRouteTypes()`.
|
|
115
|
+
*/
|
|
116
|
+
async function scanApps(
|
|
117
|
+
options: RouteTypegenOptions,
|
|
118
|
+
serverEntry: string | null,
|
|
119
|
+
rootDir: string
|
|
120
|
+
): Promise<RuntimeTargetApp[]> {
|
|
110
121
|
// Register user plugins as runtime module loaders BEFORE scanPages.
|
|
111
122
|
//
|
|
112
123
|
// scanPages() calls import() on every page file, which triggers all their
|
|
@@ -114,9 +125,10 @@ async function buildAppInternal(options: BuildAppOptions): Promise<BuildAppResul
|
|
|
114
125
|
// at that point, Bun caches the raw/unprocessed result — and that cached
|
|
115
126
|
// value is reused for every subsequent import(), including prerenderSSG().
|
|
116
127
|
//
|
|
117
|
-
//
|
|
118
|
-
// doesn't exist in the runtime context)
|
|
119
|
-
//
|
|
128
|
+
// Plugins marked `buildOnly` (e.g. bun-plugin-tailwind uses onBeforeParse,
|
|
129
|
+
// which doesn't exist in the runtime context) only affect Bun.build()
|
|
130
|
+
// bundles. Any other registration failure would make route imports differ
|
|
131
|
+
// from the bundle, so it fails the build.
|
|
120
132
|
for (const plugin of options.plugins ?? []) {
|
|
121
133
|
const { buildOnly, ...runtimePlugin } = plugin as FurinPlugin;
|
|
122
134
|
if (buildOnly) {
|
|
@@ -125,12 +137,17 @@ async function buildAppInternal(options: BuildAppOptions): Promise<BuildAppResul
|
|
|
125
137
|
try {
|
|
126
138
|
Bun.plugin(runtimePlugin);
|
|
127
139
|
} catch (err) {
|
|
128
|
-
|
|
140
|
+
throw new Error(
|
|
141
|
+
`[furin] Plugin "${runtimePlugin.name}" could not be registered for server-side route imports: ${err instanceof Error ? err.message : String(err)}\n` +
|
|
142
|
+
"If it only transforms the client bundle (for example bun-plugin-tailwind), mark it build-only in furin.config.ts:\n" +
|
|
143
|
+
" plugins: [{ ...plugin, buildOnly: true }]",
|
|
144
|
+
{ cause: err }
|
|
145
|
+
);
|
|
129
146
|
}
|
|
130
147
|
}
|
|
131
148
|
registerIsomorphicRuntimePlugin();
|
|
132
149
|
|
|
133
|
-
const appSpecs = resolveAppSpecs(options, serverEntry, rootDir);
|
|
150
|
+
const appSpecs = await resolveAppSpecs(options, serverEntry, rootDir);
|
|
134
151
|
const duplicatePrefix = appSpecs.find(
|
|
135
152
|
(spec, index) => appSpecs.findIndex((other) => other.prefix === spec.prefix) !== index
|
|
136
153
|
);
|
|
@@ -139,27 +156,77 @@ async function buildAppInternal(options: BuildAppOptions): Promise<BuildAppResul
|
|
|
139
156
|
`[furin] Two apps are configured with the prefix "${duplicatePrefix.prefix || "/"}" — give each app a unique prefix.`
|
|
140
157
|
);
|
|
141
158
|
}
|
|
159
|
+
assertOnePagesDirPerMount(appSpecs);
|
|
142
160
|
// Distinct prefixes can still slug to the same client dir (`/a-b` vs `/a/b`
|
|
143
161
|
// → `client-a-b`), which would let a later app's assets overwrite an earlier
|
|
144
162
|
// one's — reject before any target writes output.
|
|
145
163
|
assertNoPrefixSlugCollisions(appSpecs.map((spec) => spec.prefix));
|
|
146
164
|
|
|
147
|
-
const requestedTargets =
|
|
148
|
-
options.target === "all"
|
|
149
|
-
? [...IMPLEMENTED_TARGETS]
|
|
150
|
-
: [options.target].map((target) => {
|
|
151
|
-
if (!(BUILD_TARGETS as readonly string[]).includes(target)) {
|
|
152
|
-
throw new Error(`[furin] Unsupported build target "${target}"`);
|
|
153
|
-
}
|
|
154
|
-
return target as BuildTarget;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
165
|
// scanPages throws if root.tsx is missing, so root is always defined per app.
|
|
158
166
|
const apps: RuntimeTargetApp[] = [];
|
|
159
167
|
for (const spec of appSpecs) {
|
|
168
|
+
assertValidRouteConfig(spec);
|
|
160
169
|
const { root, routes } = await scanPages(spec.pagesDir);
|
|
161
170
|
apps.push({ pagesDir: spec.pagesDir, prefix: spec.prefix, root, routes });
|
|
162
171
|
}
|
|
172
|
+
return apps;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** `RouteMap` for the root-mounted app, `FileRoutes` for every app. */
|
|
176
|
+
function writeAppRouteTypes(apps: RuntimeTargetApp[], rootDir: string): void {
|
|
177
|
+
writeRouteTypes(apps.find((app) => app.prefix === "")?.routes ?? [], rootDir, apps);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Options for `generateRouteTypes()`, a subset of the build options. */
|
|
181
|
+
export type RouteTypegenOptions = Pick<
|
|
182
|
+
BuildAppOptions,
|
|
183
|
+
"apps" | "pagesDir" | "plugins" | "rootDir" | "serverEntry"
|
|
184
|
+
>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Writes `furin-env.d.ts` for every mounted app without building, e.g.
|
|
188
|
+
* before `tsc` in CI.
|
|
189
|
+
*/
|
|
190
|
+
export function generateRouteTypes(options: RouteTypegenOptions): Promise<void> {
|
|
191
|
+
return withProductionBuild(async () => {
|
|
192
|
+
const rootDir = resolve(options.rootDir ?? process.cwd());
|
|
193
|
+
const entry = resolve(rootDir, options.serverEntry ?? "src/server.ts");
|
|
194
|
+
const apps = await scanApps(options, existsSync(entry) ? entry : null, rootDir);
|
|
195
|
+
writeAppRouteTypes(apps, rootDir);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult> {
|
|
200
|
+
return withProductionBuild(() => buildAppInternal(options));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function buildAppInternal(options: BuildAppOptions): Promise<BuildAppResult> {
|
|
204
|
+
const rootDir = resolve(options.rootDir ?? process.cwd());
|
|
205
|
+
const buildRoot = join(rootDir, BUILD_OUTPUT_DIR);
|
|
206
|
+
const targets = requestedTargets(options.target);
|
|
207
|
+
const serverEntry = (() => {
|
|
208
|
+
if (targets.every(isServerless)) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
if (options.serverEntry) {
|
|
212
|
+
const resolved = resolve(rootDir, options.serverEntry);
|
|
213
|
+
if (existsSync(resolved)) {
|
|
214
|
+
return resolved;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const entry = resolve(rootDir, "src/server.ts");
|
|
218
|
+
if (!existsSync(entry)) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
"[furin] Server targets need a server entry: src/server.ts not found. Create it or set `serverEntry` in furin.config.ts."
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
return entry;
|
|
224
|
+
})();
|
|
225
|
+
|
|
226
|
+
const apps = await scanApps(options, serverEntry, rootDir);
|
|
227
|
+
// furin-env.d.ts is one file at the project root, owned by the root-mounted
|
|
228
|
+
// app — the same rule as the dev server, so builds keep types current too.
|
|
229
|
+
writeAppRouteTypes(apps, rootDir);
|
|
163
230
|
// The root-mounted app drives single-app manifest fields and the static target.
|
|
164
231
|
const primaryApp = (apps.find((app) => app.prefix === "") ?? apps[0]) as RuntimeTargetApp;
|
|
165
232
|
|
|
@@ -181,63 +248,44 @@ async function buildAppInternal(options: BuildAppOptions): Promise<BuildAppResul
|
|
|
181
248
|
targets: {},
|
|
182
249
|
};
|
|
183
250
|
|
|
184
|
-
for (const target of
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
case "static":
|
|
190
|
-
if (apps.length > 1) {
|
|
191
|
-
console.warn(
|
|
192
|
-
"[furin] `--target static` exports the root-mounted app only — prefixed apps are skipped."
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
// The static adapter only knows about staticConfig.basePath — the mount
|
|
196
|
-
// prefix is a server-side concept it never sees. Exporting a prefixed
|
|
197
|
-
// app without a matching basePath produces root-relative asset URLs.
|
|
198
|
-
if (primaryApp.prefix !== "") {
|
|
199
|
-
console.warn(
|
|
200
|
-
`[furin] \`--target static\` exports an app mounted at "${primaryApp.prefix}", but the ` +
|
|
201
|
-
`static export ignores the mount prefix — set \`static.basePath\` to "${primaryApp.prefix}" ` +
|
|
202
|
-
"(or the sub-path the site is served from) so asset URLs resolve correctly."
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
manifest.targets.static = await buildStaticTarget(
|
|
206
|
-
primaryApp.routes,
|
|
207
|
-
rootDir,
|
|
208
|
-
buildRoot,
|
|
209
|
-
primaryApp.root,
|
|
210
|
-
options
|
|
251
|
+
for (const target of targets) {
|
|
252
|
+
if (target === "static") {
|
|
253
|
+
if (apps.length > 1) {
|
|
254
|
+
console.warn(
|
|
255
|
+
"[furin] `--target static` exports the root-mounted app only — prefixed apps are skipped."
|
|
211
256
|
);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
rootDir,
|
|
222
|
-
buildRoot,
|
|
223
|
-
options
|
|
257
|
+
}
|
|
258
|
+
// The static adapter only knows about staticConfig.basePath — the mount
|
|
259
|
+
// prefix is a server-side concept it never sees. Exporting a prefixed
|
|
260
|
+
// app without a matching basePath produces root-relative asset URLs.
|
|
261
|
+
if (primaryApp.prefix !== "") {
|
|
262
|
+
console.warn(
|
|
263
|
+
`[furin] \`--target static\` exports an app mounted at "${primaryApp.prefix}", but the ` +
|
|
264
|
+
`static export ignores the mount prefix — set \`static.basePath\` to "${primaryApp.prefix}" ` +
|
|
265
|
+
"(or the sub-path the site is served from) so asset URLs resolve correctly."
|
|
224
266
|
);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
buildRoot,
|
|
234
|
-
serverEntry,
|
|
235
|
-
options
|
|
267
|
+
}
|
|
268
|
+
manifest.targets.static = await buildStaticTarget(primaryApp, rootDir, buildRoot, options);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (target === "package") {
|
|
272
|
+
if (apps.length > 1) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
"[furin] `--target package` builds exactly one app — configure a single pagesDir/prefix."
|
|
236
275
|
);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
276
|
+
}
|
|
277
|
+
manifest.targets.package = await buildPackageTarget(primaryApp, rootDir, buildRoot, options);
|
|
278
|
+
continue;
|
|
240
279
|
}
|
|
280
|
+
const adapter = adapterFor(target, options);
|
|
281
|
+
manifest.targets[adapter.name] = await buildAdapterTarget(
|
|
282
|
+
adapter,
|
|
283
|
+
apps,
|
|
284
|
+
rootDir,
|
|
285
|
+
buildRoot,
|
|
286
|
+
serverEntry as string,
|
|
287
|
+
options
|
|
288
|
+
);
|
|
241
289
|
}
|
|
242
290
|
|
|
243
291
|
writeFileSync(join(buildRoot, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
@@ -2,6 +2,11 @@ import { existsSync, renameSync } from "node:fs";
|
|
|
2
2
|
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
3
3
|
import { ensureDir } from "./shared.ts";
|
|
4
4
|
|
|
5
|
+
/** Where an adapter's server source maps are kept, outside its deployable directory. */
|
|
6
|
+
export function privateServerSourceMapDir(buildRoot: string, adapterName: string): string {
|
|
7
|
+
return join(buildRoot, "private", "server-sourcemaps", adapterName);
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
/** Keep server maps out of Bun assets and Vercel's deployment artifact. */
|
|
6
11
|
export function movePrivateServerSourceMaps(
|
|
7
12
|
outputDir: string,
|
|
@@ -3,12 +3,12 @@ import { dirname, relative, resolve } from "node:path";
|
|
|
3
3
|
const INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
|
|
4
4
|
const DEV_PAGE_PLUGIN_IMPORT = /(?:^|[/\\])server[/\\]dev-page-plugin(?:\.ts|\.js)?$/;
|
|
5
5
|
const DEV_RUNTIME_IMPORT =
|
|
6
|
-
/(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|graph|plugin)(?:\.ts|\.js)?$/;
|
|
6
|
+
/(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|graph|plugin|runtime)(?:\.ts|\.js)?$/;
|
|
7
7
|
const DEV_BUILD_IMPORT =
|
|
8
|
-
/(?:^|[/\\])(?:build[/\\]hydrate|plugin[/\\](?:route-config
|
|
9
|
-
const
|
|
8
|
+
/(?:^|[/\\])(?:build[/\\]hydrate|plugin[/\\](?:route-config|transform-client))(?:\.ts|\.js)?$/;
|
|
9
|
+
const DEV_RSC_BUILD_IMPORT = /(?:^|[/\\])rsc[/\\]build[/\\]discover(?:\.ts|\.js)?$/;
|
|
10
10
|
const PRODUCTION_BOUNDARY_IMPORT =
|
|
11
|
-
/(?:browser-events|instrumentation|dev-page-plugin|diagnostics|graph|plugin|
|
|
11
|
+
/(?:browser-events|instrumentation|dev-page-plugin|diagnostics|graph|plugin|runtime|hydrate|route-config|transform-client|discover)(?:\.ts|\.js)?$/;
|
|
12
12
|
const PRODUCTION_STUB_NAMESPACE = "furin-production-runtime-stub";
|
|
13
13
|
const FURIN_RUNTIME_ROOT = resolve(import.meta.dir, "..");
|
|
14
14
|
|
|
@@ -21,11 +21,16 @@ function isFurinRuntimePath(path: string): boolean {
|
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function
|
|
24
|
+
function devBuildExports(path: string): readonly string[] {
|
|
25
|
+
if (DEV_RSC_BUILD_IMPORT.test(path)) {
|
|
26
|
+
return ["discoverClientBoundaries", "registerServerBoundaries"];
|
|
27
|
+
}
|
|
25
28
|
if (path.includes("transform-client")) {
|
|
26
|
-
return "getHmrDataSignature";
|
|
29
|
+
return ["getHmrDataSignature"];
|
|
27
30
|
}
|
|
28
|
-
return path.includes("route-config
|
|
31
|
+
return path.includes("route-config")
|
|
32
|
+
? ["createRouteConfigReporter", "scaffoldEmptyRoutes"]
|
|
33
|
+
: ["releaseDevRouteTypes", "writeDevFiles"];
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export function productionInstrumentationPlugin(): Bun.BunPlugin {
|
|
@@ -48,22 +53,20 @@ export function productionInstrumentationPlugin(): Bun.BunPlugin {
|
|
|
48
53
|
if (DEV_RUNTIME_IMPORT.test(importPath)) {
|
|
49
54
|
return { path: resolve(import.meta.dir, "../server/dev/runtime.production.ts") };
|
|
50
55
|
}
|
|
51
|
-
if (
|
|
52
|
-
return { path: resolve(import.meta.dir, "../server/router/hmr.production.ts") };
|
|
53
|
-
}
|
|
54
|
-
if (DEV_BUILD_IMPORT.test(importPath)) {
|
|
56
|
+
if (DEV_BUILD_IMPORT.test(importPath) || DEV_RSC_BUILD_IMPORT.test(importPath)) {
|
|
55
57
|
return { namespace: PRODUCTION_STUB_NAMESPACE, path: importPath };
|
|
56
58
|
}
|
|
57
59
|
});
|
|
58
|
-
build.onLoad(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
build.onLoad({ filter: /.*/, namespace: PRODUCTION_STUB_NAMESPACE }, ({ path }) => ({
|
|
61
|
+
contents: devBuildExports(path)
|
|
62
|
+
.map(
|
|
63
|
+
(name) => `export function ${name}() {
|
|
62
64
|
throw new Error("[furin] Development-only module reached a production bundle.");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
}`
|
|
66
|
+
)
|
|
67
|
+
.join("\n"),
|
|
68
|
+
loader: "js",
|
|
69
|
+
}));
|
|
67
70
|
},
|
|
68
71
|
};
|
|
69
72
|
}
|
package/src/build/route-types.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { extname, join, relative } from "node:path";
|
|
2
|
+
import { extname, join, relative, resolve } from "node:path";
|
|
3
|
+
import { fileRouteId, type RouteInstanceSpec, routeSourcePaths } from "../plugin/route-tree.ts";
|
|
4
|
+
import { filePathToPattern, parseDynamicRouteSegment } from "../server/router/patterns.ts";
|
|
3
5
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
4
|
-
import { routeMapDeclaration, type RouteMapEntry } from "../shared/route-map.ts";
|
|
6
|
+
import { compareCodeUnits, routeMapDeclaration, type RouteMapEntry } from "../shared/route-map.ts";
|
|
5
7
|
|
|
6
8
|
function tagKeyToPropertyName(tag: string): string {
|
|
7
9
|
return /^[$A-Z_a-z][$\w]*$/.test(tag) ? tag : JSON.stringify(tag);
|
|
@@ -12,15 +14,95 @@ function tagToStringLiteral(tag: string): string {
|
|
|
12
14
|
return `'${json.slice(1, -1).replaceAll("'", "\\'")}'`;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
function importSpecifier(path: string, projectRoot: string): string {
|
|
18
|
+
const extension = extname(path);
|
|
19
|
+
const sourcePath = extension ? path.slice(0, -extension.length) : path;
|
|
20
|
+
const relativePath = relative(projectRoot, sourcePath).replaceAll("\\", "/");
|
|
21
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One `FileRoutes` entry per page and `_route` layout of an app, keyed by the
|
|
26
|
+
* app's prefix and its path under `pagesDir` (brackets and groups kept,
|
|
27
|
+
* `/index` dropped). Read from the tree alone, so the entries stay right while
|
|
28
|
+
* a route module is broken.
|
|
29
|
+
*/
|
|
30
|
+
function fileRouteEntries(
|
|
31
|
+
{ pagesDir, prefix }: RouteInstanceSpec,
|
|
32
|
+
projectRoot: string
|
|
33
|
+
): { id: string; lines: string }[] {
|
|
34
|
+
const pages = resolve(pagesDir);
|
|
35
|
+
const files = routeSourcePaths({ pagesDir: pages, prefix }).map((path) => {
|
|
36
|
+
const relativePath = relative(pages, path).replaceAll("\\", "/");
|
|
37
|
+
const segments = relativePath.split("/");
|
|
38
|
+
const base = (segments.pop() ?? "").slice(0, -extname(path).length);
|
|
39
|
+
return { base, path, relativePath, segments };
|
|
23
40
|
});
|
|
41
|
+
const layouts = new Map(
|
|
42
|
+
files.filter(({ base }) => base === "_route").map((file) => [file.segments.join("/"), file.path])
|
|
43
|
+
);
|
|
44
|
+
return files
|
|
45
|
+
.map(({ base, path, relativePath, segments }) => {
|
|
46
|
+
const isLayout = base === "_route";
|
|
47
|
+
// Nearest `_route` in an enclosing directory, as discovery resolves it.
|
|
48
|
+
let parent = join(pages, "root.tsx");
|
|
49
|
+
for (let depth = isLayout ? segments.length - 1 : segments.length; depth > 0; depth -= 1) {
|
|
50
|
+
const layout = layouts.get(segments.slice(0, depth).join("/"));
|
|
51
|
+
if (layout) {
|
|
52
|
+
parent = layout;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const pathParams = [...segments, base].flatMap((segment) => {
|
|
57
|
+
const dynamic = parseDynamicRouteSegment(segment, path);
|
|
58
|
+
return dynamic ? [dynamic.catchAll ? '"*": string' : `${dynamic.name}: string`] : [];
|
|
59
|
+
});
|
|
60
|
+
const id = fileRouteId({ pagesDir: pages, prefix }, path);
|
|
61
|
+
const pattern = filePathToPattern(
|
|
62
|
+
isLayout ? segments.concat("index").join("/") : relativePath
|
|
63
|
+
);
|
|
64
|
+
return {
|
|
65
|
+
id,
|
|
66
|
+
lines: ` ${JSON.stringify(id)}: {
|
|
67
|
+
kind: "${isLayout ? "layout" : "page"}";
|
|
68
|
+
pattern: ${JSON.stringify(`${prefix}${pattern === "/" ? "" : pattern}` || "/")};
|
|
69
|
+
parent: typeof import(${JSON.stringify(importSpecifier(parent, projectRoot))}).route;
|
|
70
|
+
pathParams: {${pathParams.length > 0 ? ` ${pathParams.join("; ")} ` : ""}};
|
|
71
|
+
};`,
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function fileRoutesDeclaration(apps: readonly RouteInstanceSpec[], projectRoot: string): string {
|
|
77
|
+
const body = apps
|
|
78
|
+
.flatMap((app) => fileRouteEntries(app, projectRoot))
|
|
79
|
+
.toSorted((left, right) => compareCodeUnits(left.id, right.id))
|
|
80
|
+
.map(({ lines }) => lines)
|
|
81
|
+
.join("\n");
|
|
82
|
+
return `declare module "@teyik0/furin/routes" {
|
|
83
|
+
interface FileRoutes {
|
|
84
|
+
${body}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @internal Exported for framework build and focused contract tests. `routes`
|
|
93
|
+
* (the root-mounted app's) feed `RouteMap`; every app in `apps` feeds
|
|
94
|
+
* `FileRoutes`. Without `apps`, `FileRoutes` is not declared and
|
|
95
|
+
* `defineRoute(id)` accepts any id.
|
|
96
|
+
*/
|
|
97
|
+
export function writeRouteTypes(
|
|
98
|
+
routes: ResolvedRoute[],
|
|
99
|
+
projectRoot: string,
|
|
100
|
+
apps?: readonly RouteInstanceSpec[]
|
|
101
|
+
): boolean {
|
|
102
|
+
const entries: RouteMapEntry[] = routes.map((route) => ({
|
|
103
|
+
importSpecifier: importSpecifier(route.path, projectRoot),
|
|
104
|
+
pattern: route.pattern,
|
|
105
|
+
}));
|
|
24
106
|
|
|
25
107
|
const sortedTags = [...new Set(routes.flatMap((route) => route.tags ?? []))].sort();
|
|
26
108
|
const tagBlock =
|
|
@@ -34,7 +116,7 @@ export function writeRouteTypes(routes: ResolvedRoute[], projectRoot: string): b
|
|
|
34
116
|
/// <reference types="@teyik0/furin/env" />
|
|
35
117
|
import "@teyik0/furin/routes";
|
|
36
118
|
|
|
37
|
-
${routeMapDeclaration(entries)}${tagBlock}
|
|
119
|
+
${apps === undefined ? "" : fileRoutesDeclaration(apps, projectRoot)}${routeMapDeclaration(entries)}${tagBlock}
|
|
38
120
|
`;
|
|
39
121
|
|
|
40
122
|
const typesPath = join(projectRoot, "furin-env.d.ts");
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type RouteInstanceSpec,
|
|
6
|
-
} from "../plugin/routes.ts";
|
|
3
|
+
import { materializedRouteModuleSource } from "../plugin/route-registry.ts";
|
|
4
|
+
import type { RouteInstanceSpec } from "../plugin/route-tree.ts";
|
|
7
5
|
import { buildEntrySource, type EntryAppContext } from "./entry-template.ts";
|
|
8
6
|
import { ensureDir, toPosixPath } from "./shared.ts";
|
|
9
7
|
|
|
@@ -12,6 +10,7 @@ interface MaterializeServerAppEntryOptions {
|
|
|
12
10
|
headerComment: string;
|
|
13
11
|
instances: RouteInstanceSpec[];
|
|
14
12
|
outDir: string;
|
|
13
|
+
prerenderSnapshot: boolean;
|
|
15
14
|
serverEntry: string;
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -37,25 +36,9 @@ export async function materializeServerAppEntry(
|
|
|
37
36
|
apps,
|
|
38
37
|
headerComment: options.headerComment,
|
|
39
38
|
mode: "app",
|
|
39
|
+
prerenderSnapshot: options.prerenderSnapshot,
|
|
40
40
|
serverEntry: options.serverEntry,
|
|
41
41
|
})
|
|
42
42
|
);
|
|
43
43
|
return entryPath;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
export function serverBootSource(appEntry: string): string {
|
|
47
|
-
return `// Auto-generated by furin build - do not edit
|
|
48
|
-
import { startProductionServer } from "@teyik0/furin/production-server";
|
|
49
|
-
import app, { idleTimeout, onShutdown, port, startServer } from ${JSON.stringify(toPosixPath(appEntry))};
|
|
50
|
-
|
|
51
|
-
if (typeof startServer === "function") {
|
|
52
|
-
await startServer();
|
|
53
|
-
} else if (app && typeof app.listen === "function" && !app.server) {
|
|
54
|
-
const serverPort = process.env.PORT === undefined
|
|
55
|
-
? typeof port === "number" ? port : 3000
|
|
56
|
-
: Number(process.env.PORT);
|
|
57
|
-
startProductionServer({ app, idleTimeout, onShutdown, port: serverPort });
|
|
58
|
-
console.log(\`[furin] Server running at http://localhost:\${app.server?.port}\`);
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
}
|