@teyik0/furin 0.2.0-alpha.5 → 0.4.0-alpha.1
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 +2 -3
- package/dist/adapter/bun.d.ts +1 -1
- package/dist/adapter/static.d.ts +1 -1
- package/dist/build/bun-build.d.ts +3 -0
- package/dist/build/client.d.ts +2 -2
- package/dist/build/entry-template.d.ts +6 -0
- package/dist/build/entry-template.ts +20 -3
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +9363 -5827
- package/dist/build/production-instrumentation.d.ts +1 -0
- package/dist/build/route-types.d.ts +3 -23
- package/dist/build/shared.d.ts +1 -1
- package/dist/build/ssg-cache.d.ts +1 -1
- package/dist/build/types.d.ts +2 -1
- package/dist/cli/index.js +9467 -5870
- package/dist/client/boundaries.d.ts +6 -4
- package/dist/client/define-route.d.ts +35 -0
- package/dist/client/document.d.ts +26 -0
- package/dist/client/hmr.d.ts +10 -0
- package/dist/client/internal/runtime-types.d.ts +32 -0
- package/dist/client/link.d.ts +2 -1
- package/dist/client/link.js +1884 -1227
- package/dist/client/router/boundary-tree.d.ts +1 -1
- package/dist/client/router/index.d.ts +2 -2
- package/dist/client/router/link-utils.d.ts +14 -1
- package/dist/client/router/search/index.d.ts +3 -7
- package/dist/client/router/sync-catch-up.d.ts +4 -4
- package/dist/client/router/types.d.ts +34 -26
- package/dist/client-only.d.ts +1 -0
- package/dist/client-only.js +1 -0
- package/dist/client.d.ts +11 -169
- package/dist/client.js +197 -36
- package/dist/config.d.ts +8 -8
- package/dist/config.js +10 -10
- package/dist/define-route.d.ts +1355 -0
- package/dist/devtools/devtools-element.d.ts +1 -0
- package/dist/devtools/protocol.d.ts +119 -0
- package/dist/furin.d.ts +24 -39
- package/dist/furin.js +14432 -7929
- package/dist/isomorphic.d.ts +18 -0
- package/dist/plugin/binding-scope.d.ts +2 -0
- package/dist/plugin/dead-code-elimination.d.ts +3 -0
- package/dist/plugin/index.js +1708 -489
- package/dist/plugin/route-config-autofix.d.ts +31 -0
- package/dist/plugin/routes.d.ts +27 -0
- package/dist/plugin/transform-client.d.ts +0 -2
- package/dist/plugin/transform-isomorphic.d.ts +9 -0
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +1 -0
- package/dist/rsc/build/environment.d.ts +2 -0
- package/dist/rsc/build/index.d.ts +15 -0
- package/dist/rsc/client-codec.d.ts +1 -0
- package/dist/rsc/codec.d.ts +4 -0
- package/dist/rsc/flight-drain.d.ts +11 -0
- package/dist/rsc/render-error.d.ts +17 -0
- package/dist/rsc/server-codec.d.ts +2 -0
- package/dist/rsc/server-codec.js +24 -0
- package/dist/rsc/shared.d.ts +30 -0
- package/dist/rsc/symbols.d.ts +2 -0
- package/dist/rsc/transport-benchmark.d.ts +13 -0
- package/dist/rsc/version.d.ts +7 -0
- package/dist/rsc-client.d.ts +4 -0
- package/dist/rsc-client.js +166 -0
- package/dist/rsc-server.d.ts +11 -0
- package/dist/rsc.d.ts +11 -0
- package/dist/rsc.js +353 -0
- package/dist/server/cache/index.d.ts +2 -2
- package/dist/server/cache/invalidation.d.ts +2 -3
- package/dist/server/cache/isr-ssg.d.ts +5 -1
- package/dist/server/cache/isr.d.ts +9 -0
- package/dist/server/cache/route-cache.d.ts +10 -8
- package/dist/server/cache/store-view.d.ts +7 -7
- package/dist/server/dev-page-plugin.d.ts +11 -5
- package/dist/server/devtools/hub.d.ts +11 -0
- package/dist/server/devtools/instrumentation.d.ts +22 -0
- package/dist/server/devtools/instrumentation.production.d.ts +44 -0
- package/dist/server/devtools/plugin.d.ts +3 -0
- package/dist/server/devtools/request-context.d.ts +6 -0
- package/dist/server/internal.d.ts +5 -0
- package/dist/server/internal.js +3 -3
- package/dist/server/lang-detect.d.ts +1 -0
- package/dist/server/logger.d.ts +4 -0
- package/dist/server/render/assemble.d.ts +4 -9
- package/dist/server/render/document.d.ts +4 -0
- package/dist/server/render/element.d.ts +3 -2
- package/dist/server/render/index.d.ts +2 -2
- package/dist/server/render/index.ts +6 -3
- package/dist/server/render/isr.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +9 -1
- package/dist/server/render/not-found.d.ts +2 -2
- package/dist/server/render/ppr-route.d.ts +8 -0
- package/dist/server/render/route-frame-transport.d.ts +2 -0
- package/dist/server/render/shell.ts +0 -1
- package/dist/server/render/ssg.d.ts +1 -1
- package/dist/server/render/ssr.d.ts +9 -9
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +24 -0
- package/dist/server/router/discovery.d.ts +1 -1
- package/dist/server/router/hmr.d.ts +17 -9
- package/dist/server/router/patterns.d.ts +7 -1
- package/dist/server/router/plugin.d.ts +8 -10
- package/dist/server/router/schema-merge.d.ts +3 -0
- package/dist/server/router/schemas.d.ts +14 -9
- package/dist/server/router/source-version.d.ts +2 -0
- package/dist/server/router/types.d.ts +2 -1
- package/dist/server/runtime-env.js +2 -2
- package/dist/server/sync/adapter.d.ts +45 -26
- package/dist/server/sync/config.d.ts +5 -9
- package/dist/server/sync/fingerprint.d.ts +2 -1
- package/dist/server/sync/index.d.ts +15 -4
- package/dist/server/sync/index.js +3023 -0
- package/dist/server/sync/notifier.d.ts +18 -0
- package/dist/server/sync/plugin.d.ts +53 -54
- package/dist/server/sync/postgres/index.d.ts +19 -0
- package/dist/server/sync/postgres/index.js +252 -0
- package/dist/server/sync/postgres/migrate.d.ts +2 -0
- package/dist/server/sync/postgres/migrate.js +17 -0
- package/dist/server/sync/postgres/migration.sql +66 -0
- package/dist/server/sync/redis/index.d.ts +30 -0
- package/dist/server/sync/redis/index.js +336 -0
- package/dist/server/sync/redis/scripts.d.ts +4 -0
- package/dist/server/sync/response.d.ts +10 -1
- package/dist/server/sync/runtime.d.ts +6 -0
- package/dist/server/sync/sqlite/index.d.ts +20 -0
- package/dist/server/sync/sqlite/index.js +250 -0
- package/dist/server/sync/stream.d.ts +12 -11
- package/dist/server-only.d.ts +1 -0
- package/dist/server-only.js +1 -0
- package/dist/shared/await.d.ts +6 -7
- package/dist/shared/elysia-contract.d.ts +41 -0
- package/dist/shared/parser.d.ts +2 -0
- package/dist/shared/route-frame.d.ts +49 -0
- package/dist/shared/route-map.d.ts +5 -0
- package/dist/shared/utils/index.d.ts +1 -3
- package/package.json +86 -41
- package/src/adapter/bun.ts +113 -36
- package/src/adapter/package.ts +23 -15
- package/src/adapter/static.ts +97 -50
- package/src/build/bun-build.ts +11 -0
- package/src/build/client.ts +41 -26
- package/src/build/entry-template.ts +20 -3
- package/src/build/hydrate.ts +128 -33
- package/src/build/index.ts +14 -2
- package/src/build/production-instrumentation.ts +14 -0
- package/src/build/route-types.ts +20 -116
- package/src/build/scan-server.ts +3 -2
- package/src/build/shared.ts +1 -1
- package/src/build/ssg-cache.ts +4 -2
- package/src/build/types.ts +2 -1
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +58 -27
- package/src/client/boundaries.tsx +51 -19
- package/src/client/default-screens.tsx +4 -4
- package/src/client/define-route.ts +48 -0
- package/src/client/document.tsx +165 -0
- package/src/client/hmr.ts +40 -0
- package/src/client/internal/runtime-types.ts +33 -0
- package/src/client/link.tsx +51 -38
- package/src/client/router/boundary-tree.tsx +2 -2
- package/src/client/router/context.ts +13 -9
- package/src/client/router/index.ts +4 -0
- package/src/client/router/link-utils.ts +92 -3
- package/src/client/router/navigation.ts +9 -15
- package/src/client/router/provider.tsx +98 -53
- package/src/client/router/search/index.ts +9 -19
- package/src/client/router/search-store.ts +5 -1
- package/src/client/router/spa-response.ts +3 -4
- package/src/client/router/sync-catch-up.ts +9 -8
- package/src/client/router/types.ts +52 -26
- package/src/client/sync.ts +3 -2
- package/src/client-only.ts +1 -0
- package/src/client.ts +28 -283
- package/src/config.ts +10 -10
- package/src/define-route.ts +959 -0
- package/src/devtools/devtools-element.js +885 -0
- package/src/devtools/protocol.ts +139 -0
- package/src/furin.ts +475 -136
- package/src/isomorphic.ts +66 -0
- package/src/plugin/binding-scope.ts +158 -0
- package/src/plugin/dead-code-elimination.ts +202 -0
- package/src/plugin/index.ts +14 -18
- package/src/plugin/route-config-autofix.ts +1140 -0
- package/src/plugin/routes.ts +891 -0
- package/src/plugin/transform-client.ts +160 -330
- package/src/plugin/transform-isomorphic.ts +464 -0
- package/src/routes.ts +6 -0
- package/src/rsc/build/environment.ts +30 -0
- package/src/rsc/build/index.ts +94 -0
- package/src/rsc/client-codec.ts +11 -0
- package/src/rsc/codec.ts +85 -0
- package/src/rsc/flight-drain.ts +68 -0
- package/src/rsc/react-server-dom-webpack.d.ts +23 -0
- package/src/rsc/render-error.ts +120 -0
- package/src/rsc/server-codec.ts +25 -0
- package/src/rsc/shared.tsx +113 -0
- package/src/rsc/symbols.ts +2 -0
- package/src/rsc/transport-benchmark.ts +73 -0
- package/src/rsc/version.ts +57 -0
- package/src/rsc-client.ts +12 -0
- package/src/rsc-server.tsx +91 -0
- package/src/rsc.tsx +75 -0
- package/src/server/auto-invalidate/registry.ts +2 -2
- package/src/server/auto-invalidate/runtime.ts +32 -6
- package/src/server/cache/dev-loader.ts +70 -10
- package/src/server/cache/index.ts +7 -3
- package/src/server/cache/invalidation.ts +33 -15
- package/src/server/cache/isr-ssg.ts +12 -3
- package/src/server/cache/isr.ts +84 -9
- package/src/server/cache/route-cache.ts +49 -36
- package/src/server/cache/store-view.ts +7 -7
- package/src/server/context-logger.ts +7 -7
- package/src/server/dev-page-plugin.ts +38 -17
- package/src/server/devtools/hub.ts +64 -0
- package/src/server/devtools/instrumentation.production.ts +80 -0
- package/src/server/devtools/instrumentation.ts +72 -0
- package/src/server/devtools/plugin.ts +269 -0
- package/src/server/devtools/request-context.ts +76 -0
- package/src/server/instance.ts +4 -4
- package/src/server/internal.ts +5 -0
- package/src/server/lang-detect.ts +14 -10
- package/src/server/logger.ts +21 -0
- package/src/server/render/assemble.ts +58 -36
- package/src/server/render/document.tsx +25 -0
- package/src/server/render/element.tsx +24 -9
- package/src/server/render/index.ts +6 -3
- package/src/server/render/isr.ts +182 -117
- package/src/server/render/loaders.ts +289 -50
- package/src/server/render/not-found.ts +57 -38
- package/src/server/render/ppr-route.ts +146 -0
- package/src/server/render/route-frame-transport.ts +62 -0
- package/src/server/render/shell.ts +0 -1
- package/src/server/render/ssg.ts +7 -6
- package/src/server/render/ssr.ts +412 -166
- package/src/server/render/template.ts +93 -2
- package/src/server/router/defined-route.ts +110 -0
- package/src/server/router/discovery.ts +165 -48
- package/src/server/router/hmr.ts +126 -53
- package/src/server/router/patterns.ts +56 -27
- package/src/server/router/plugin.ts +210 -200
- package/src/server/router/schema-merge.ts +42 -0
- package/src/server/router/schemas.ts +61 -76
- package/src/server/router/source-version.ts +16 -0
- package/src/server/router/types.ts +3 -1
- package/src/server/sync/adapter.ts +44 -28
- package/src/server/sync/config.ts +9 -27
- package/src/server/sync/fingerprint.ts +8 -3
- package/src/server/sync/index.ts +37 -13
- package/src/server/sync/notifier.ts +109 -0
- package/src/server/sync/plugin.ts +184 -89
- package/src/server/sync/postgres/index.ts +301 -0
- package/src/server/sync/postgres/migrate.ts +16 -0
- package/src/server/sync/postgres/migration.sql +66 -0
- package/src/server/sync/redis/index.ts +342 -0
- package/src/server/sync/redis/scripts.ts +74 -0
- package/src/server/sync/response.ts +145 -16
- package/src/server/sync/runtime.ts +27 -0
- package/src/server/sync/sql.d.ts +4 -0
- package/src/server/sync/sqlite/index.ts +337 -0
- package/src/server/sync/sqlite/migration.sql +70 -0
- package/src/server/sync/stream.ts +137 -81
- package/src/server-only.ts +1 -0
- package/src/shared/await.tsx +10 -11
- package/src/shared/deferred-ndjson.ts +34 -6
- package/src/shared/digest.ts +2 -2
- package/src/shared/elysia-contract.ts +63 -0
- package/src/shared/parser.ts +5 -0
- package/src/shared/route-frame.ts +429 -0
- package/src/shared/route-map.ts +37 -0
- package/src/shared/search-params.ts +7 -7
- package/src/shared/utils/index.ts +6 -22
- package/dist/build/server-routes-entry.d.ts +0 -13
- package/dist/build/server-routes-entry.ts +0 -30
- package/dist/server/dev-inspector.d.ts +0 -89
- package/dist/server/router/index.d.ts +0 -6
- package/dist/server/router/index.js +0 -27
- package/dist/server/router/index.ts +0 -28
- package/dist/server/sync/memory-adapter.d.ts +0 -17
- package/src/build/server-routes-entry.ts +0 -30
- package/src/server/dev-inspector.ts +0 -60
- package/src/server/router/index.ts +0 -28
- package/src/server/sync/memory-adapter.ts +0 -196
package/src/build/hydrate.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { generateIndexHtml } from "../server/render/shell.ts";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
buildRouteRegex,
|
|
6
|
+
compareRouteSpecificity,
|
|
7
|
+
} from "../server/router/patterns.ts";
|
|
8
|
+
import { mergeRouteSchemas } from "../server/router/schema-merge.ts";
|
|
9
|
+
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
7
10
|
import { collectSearchDefaults } from "../shared/search-params.ts";
|
|
8
11
|
import { writeRouteTypes } from "./route-types";
|
|
9
12
|
import type { BuildClientOptions } from "./types";
|
|
@@ -42,12 +45,28 @@ export function generateHydrateEntry(
|
|
|
42
45
|
};
|
|
43
46
|
|
|
44
47
|
const routeEntries: string[] = [];
|
|
48
|
+
const activeHotComponentKeys = new Set<string>();
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
const clientRoutes = [...routes].sort((a, b) =>
|
|
51
|
+
compareRouteSpecificity(b.pattern, a.pattern),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
for (const route of clientRoutes) {
|
|
47
55
|
const resolvedPage = route.path.replace(/\\/g, "/");
|
|
48
56
|
const regexPattern = buildRouteRegex(route.pattern).regex.source;
|
|
49
|
-
const searchDefaults = collectSearchDefaults(
|
|
57
|
+
const searchDefaults = collectSearchDefaults(
|
|
58
|
+
mergeRouteSchemas(route.routeChain ?? [], "query")
|
|
59
|
+
);
|
|
50
60
|
const boundaryIdents = new Map<string, string>();
|
|
61
|
+
const layoutPaths = (route.routeChain ?? [])
|
|
62
|
+
.slice(1)
|
|
63
|
+
.filter((entry) => entry.layout && entry.sourcePath)
|
|
64
|
+
.map((entry) => entry.sourcePath as string);
|
|
65
|
+
activeHotComponentKeys.add(`page:${resolvedPage}`);
|
|
66
|
+
for (const layoutPath of layoutPaths) {
|
|
67
|
+
activeHotComponentKeys.add(`layout:${layoutPath.replace(/\\/g, "/")}`);
|
|
68
|
+
}
|
|
69
|
+
const layoutIdents = layoutPaths.map((_, index) => `__furin_layout_${index}`);
|
|
51
70
|
|
|
52
71
|
// Emit one boundary literal per segment that actually carries a convention
|
|
53
72
|
// file — segments that only declare one of the two are emitted with the
|
|
@@ -71,14 +90,23 @@ export function generateHydrateEntry(
|
|
|
71
90
|
|
|
72
91
|
const lazyImports = [
|
|
73
92
|
`import("${resolvedPage}")`,
|
|
93
|
+
...layoutPaths.map((filePath) => `import("${filePath.replace(/\\/g, "/")}")`),
|
|
74
94
|
...[...boundaryIdents.keys()].map((filePath) => `import("${filePath.replace(/\\/g, "/")}")`),
|
|
75
95
|
];
|
|
76
|
-
const
|
|
96
|
+
const importIdents = ["__furin_page", ...layoutIdents, ...boundaryIdents.values()];
|
|
97
|
+
const layoutAssignments = layoutPaths
|
|
98
|
+
.map((filePath, index) => {
|
|
99
|
+
const ident = layoutIdents[index];
|
|
100
|
+
const componentKey = JSON.stringify(`layout:${filePath.replace(/\\/g, "/")}`);
|
|
101
|
+
return `const __furin_layout_route_${index} = ${ident}.route; __furin_parent = { __type: "FURIN_ROUTE", layout: hotComponent(${componentKey}, __furin_layout_route_${index}.component), parent: __furin_parent };`;
|
|
102
|
+
})
|
|
103
|
+
.join(" ");
|
|
104
|
+
const boundaryResult =
|
|
77
105
|
boundaryLiterals.length > 0
|
|
78
|
-
?
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
106
|
+
? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]`
|
|
107
|
+
: "";
|
|
108
|
+
const pageComponentKey = JSON.stringify(`page:${resolvedPage}`);
|
|
109
|
+
const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
|
|
82
110
|
|
|
83
111
|
const searchDefaultsEntry = searchDefaults
|
|
84
112
|
? `, searchDefaults: ${JSON.stringify(searchDefaults)}`
|
|
@@ -118,15 +146,34 @@ export function generateHydrateEntry(
|
|
|
118
146
|
// RouterProvider receives basePath so navigate() / Link push physical paths.
|
|
119
147
|
const routerProviderDefaults = `\n autoRefresh: true,\n basePath: ${basePathLiteral},\n defaultPreload: "intent",\n defaultPreloadDelay: 50,\n defaultPreloadStaleTime: 30000,\n prefetchCacheSize: 50,\n syncStream,`;
|
|
120
148
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
const resolvedRootLayout = rootLayout.replace(/\\/g, "/");
|
|
150
|
+
const rootComponentKey = JSON.stringify(`root:${resolvedRootLayout}`);
|
|
151
|
+
activeHotComponentKeys.add(`root:${resolvedRootLayout}`);
|
|
152
|
+
const activeHotComponentKeysLiteral = JSON.stringify([...activeHotComponentKeys]);
|
|
153
|
+
|
|
154
|
+
return `import { hydrateRoot } from "react-dom/client";
|
|
155
|
+
import { createElement, type ReactNode } from "react";
|
|
156
|
+
${loggingImports}import { DocumentProvider, type DocumentState, type HotComponentRegistry, reconcileHotComponentRegistry, updateHotComponent } from "@teyik0/furin/client";
|
|
157
|
+
import { RouterProvider } from "@teyik0/furin/link";
|
|
158
|
+
import { fromCrossJSON, parseDeferredNdjson } from "@teyik0/furin/link";
|
|
125
159
|
import type { SerovalNode } from "seroval";
|
|
126
|
-
import { route as
|
|
160
|
+
import { route as __furin_root_route } from "${resolvedRootLayout}";
|
|
127
161
|
|
|
128
162
|
${loggerSetup}
|
|
129
163
|
|
|
164
|
+
const hotComponentRegistry = ((window as unknown as {
|
|
165
|
+
__FURIN_HOT_COMPONENTS__?: HotComponentRegistry;
|
|
166
|
+
}).__FURIN_HOT_COMPONENTS__ ??= new Map());
|
|
167
|
+
reconcileHotComponentRegistry(hotComponentRegistry, new Set(${activeHotComponentKeysLiteral}));
|
|
168
|
+
const hotComponent = <Props,>(key: string, component: (props: Props) => ReactNode) =>
|
|
169
|
+
import.meta.hot ? updateHotComponent(hotComponentRegistry, key, component) : component;
|
|
170
|
+
const __furin_root_component = hotComponent(${rootComponentKey}, __furin_root_route.component);
|
|
171
|
+
const root = {
|
|
172
|
+
...__furin_root_route,
|
|
173
|
+
component: __furin_root_component,
|
|
174
|
+
layout: __furin_root_component,
|
|
175
|
+
};
|
|
176
|
+
|
|
130
177
|
const routes = [
|
|
131
178
|
${routeEntries.join(",\n")}
|
|
132
179
|
];
|
|
@@ -142,10 +189,29 @@ const _match = routes.find((r) => r.regex.test(pathname));
|
|
|
142
189
|
// a matched loader threw notFound(). The latter still has a _match; the
|
|
143
190
|
// former does not — so the two cases fork on _match below.
|
|
144
191
|
const dataEl = document.getElementById("__FURIN_DATA__");
|
|
145
|
-
|
|
192
|
+
let loaderData = dataEl ? JSON.parse(dataEl.textContent || "{}") : {};
|
|
146
193
|
const syncEl = document.getElementById("__FURIN_SYNC__");
|
|
147
194
|
const syncConfig = syncEl ? JSON.parse(syncEl.textContent || "{}") : {};
|
|
148
195
|
const syncStream = typeof syncConfig.stream === "string" ? syncConfig.stream : undefined;
|
|
196
|
+
const headEl = document.getElementById("__FURIN_HEAD__");
|
|
197
|
+
const head = headEl ? JSON.parse(headEl.textContent || "{}") : {};
|
|
198
|
+
const entryEl = document.querySelector("script[data-furin-entry][src]") as HTMLScriptElement | null;
|
|
199
|
+
const buildId = document.querySelector('meta[name="furin-build-id"]')?.getAttribute("content") ?? undefined;
|
|
200
|
+
const faviconHref = document.querySelector('link[rel="icon"]')?.getAttribute("href") ?? undefined;
|
|
201
|
+
const documentState: DocumentState = {
|
|
202
|
+
assets: {
|
|
203
|
+
buildId,
|
|
204
|
+
entryModule: entryEl?.getAttribute("src") ?? undefined,
|
|
205
|
+
faviconHref,
|
|
206
|
+
staticMode: document.querySelector('meta[name="furin-mode"][content="static"]') !== null,
|
|
207
|
+
stylesheets: Array.from(document.querySelectorAll('link[rel="stylesheet"]'))
|
|
208
|
+
.map((link) => link.getAttribute("href") ?? "")
|
|
209
|
+
.filter(Boolean),
|
|
210
|
+
},
|
|
211
|
+
dataJson: dataEl?.textContent ?? undefined,
|
|
212
|
+
head,
|
|
213
|
+
syncJson: syncEl?.textContent ?? undefined,
|
|
214
|
+
};
|
|
149
215
|
|
|
150
216
|
// ── Deferred data hydration ─────────────────────────────────────────────────
|
|
151
217
|
// window.__FURIN_DEFERRED__ is injected by the server when a loader returns
|
|
@@ -166,6 +232,9 @@ interface FurinDeferredRegistry {
|
|
|
166
232
|
reject: (key: string, chunk: SerovalNode) => void;
|
|
167
233
|
resolve: (key: string, chunk: SerovalNode) => void;
|
|
168
234
|
}
|
|
235
|
+
interface FurinRouteFrameStream {
|
|
236
|
+
stream: (initial: string) => ReadableStream<Uint8Array>;
|
|
237
|
+
}
|
|
169
238
|
const __deferred = (window as unknown as { __FURIN_DEFERRED__?: FurinDeferredRegistry })
|
|
170
239
|
.__FURIN_DEFERRED__;
|
|
171
240
|
const deferredData: Record<string, Promise<unknown>> = {};
|
|
@@ -210,13 +279,22 @@ if (__deferred && __deferred._chunks) {
|
|
|
210
279
|
}
|
|
211
280
|
}
|
|
212
281
|
}
|
|
213
|
-
const rootEl = document.getElementById("root") as HTMLElement;
|
|
214
|
-
|
|
215
282
|
// Eagerly load only the current page module for initial hydration.
|
|
216
283
|
// All other pages are loaded on demand when the user navigates to them.
|
|
217
284
|
// Wrapped in an async IIFE to avoid top-level await, which causes Bun's HTML
|
|
218
285
|
// bundler to misidentify which chunk to reference as the entry in index.html.
|
|
219
286
|
(async () => {
|
|
287
|
+
const frameTemplate = document.getElementById("__FURIN_ROUTE_FRAMES__") as HTMLTemplateElement | null;
|
|
288
|
+
if (frameTemplate) {
|
|
289
|
+
const payload = frameTemplate.content.textContent || "";
|
|
290
|
+
const routeFrameStream = (window as unknown as { __FURIN_ROUTE_FRAME_STREAM__?: FurinRouteFrameStream })
|
|
291
|
+
.__FURIN_ROUTE_FRAME_STREAM__;
|
|
292
|
+
const parsed = await parseDeferredNdjson(
|
|
293
|
+
routeFrameStream ? routeFrameStream.stream(payload) : new Blob([payload]).stream(),
|
|
294
|
+
undefined
|
|
295
|
+
);
|
|
296
|
+
loaderData = { ...parsed.syncData, ...parsed.deferredPromises };
|
|
297
|
+
}
|
|
220
298
|
let app;
|
|
221
299
|
if (_match) {
|
|
222
300
|
const _mod = await _match.load();
|
|
@@ -261,12 +339,32 @@ const rootEl = document.getElementById("root") as HTMLElement;
|
|
|
261
339
|
log.error({ action: "hydrate_no_match", pathname });
|
|
262
340
|
return;
|
|
263
341
|
}
|
|
342
|
+
app = createElement(DocumentProvider, { value: documentState }, app);
|
|
264
343
|
|
|
265
344
|
if (import.meta.hot) {
|
|
266
345
|
// Dev mode — preserve root across HMR using a window global.
|
|
267
346
|
// window is the only object that survives Bun's module re-evaluation.
|
|
268
347
|
// biome-ignore lint/suspicious/noExplicitAny: dev-only HMR global
|
|
269
348
|
const existingRoot = (window as any).__FURIN_ROOT__;
|
|
349
|
+
const hmrWindow = window as unknown as {
|
|
350
|
+
__FURIN_HMR_UPDATE__?: (
|
|
351
|
+
sourcePath: string,
|
|
352
|
+
component: (props: never) => ReactNode
|
|
353
|
+
) => void;
|
|
354
|
+
};
|
|
355
|
+
hmrWindow.__FURIN_HMR_UPDATE__ = (sourcePath, component) => {
|
|
356
|
+
const componentKeySuffix = ":" + sourcePath;
|
|
357
|
+
for (const key of hotComponentRegistry.keys()) {
|
|
358
|
+
if (key.endsWith(componentKeySuffix)) {
|
|
359
|
+
updateHotComponent(hotComponentRegistry, key, component);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
(window as any).__FURIN_ROOT__?.render(app);
|
|
363
|
+
const refresh = (window as any).__FURIN_HMR_REFRESH__;
|
|
364
|
+
if (refresh) {
|
|
365
|
+
requestAnimationFrame(() => refresh());
|
|
366
|
+
}
|
|
367
|
+
};
|
|
270
368
|
if (existingRoot) {
|
|
271
369
|
// Already mounted — reconciliation, NOT hydration. React Fast Refresh
|
|
272
370
|
// patched the component in-place, now re-render with the new module.
|
|
@@ -278,22 +376,14 @@ const rootEl = document.getElementById("root") as HTMLElement;
|
|
|
278
376
|
if (hmrRefresh) {
|
|
279
377
|
requestAnimationFrame(() => hmrRefresh());
|
|
280
378
|
}
|
|
281
|
-
} else if (rootEl.innerHTML.trim()) {
|
|
282
|
-
// First load with SSR content — hydrateRoot renders on construction
|
|
283
|
-
const root = hydrateRoot(rootEl, app);
|
|
284
|
-
// biome-ignore lint/suspicious/noExplicitAny: dev-only HMR global
|
|
285
|
-
(window as any).__FURIN_ROOT__ = root;
|
|
286
379
|
} else {
|
|
287
|
-
// First load
|
|
288
|
-
const root =
|
|
289
|
-
root.render(app);
|
|
380
|
+
// First load — the root layout owns the server-rendered document.
|
|
381
|
+
const root = hydrateRoot(document, app);
|
|
290
382
|
// biome-ignore lint/suspicious/noExplicitAny: dev-only HMR global
|
|
291
383
|
(window as any).__FURIN_ROOT__ = root;
|
|
292
384
|
}
|
|
293
|
-
} else if (rootEl.innerHTML.trim()) {
|
|
294
|
-
hydrateRoot(rootEl, app);
|
|
295
385
|
} else {
|
|
296
|
-
|
|
386
|
+
hydrateRoot(document, app);
|
|
297
387
|
}
|
|
298
388
|
|
|
299
389
|
log.info({ action: "hydrate_complete", pathname });
|
|
@@ -321,8 +411,10 @@ export function writeDevFiles(
|
|
|
321
411
|
const hydrateCode = generateHydrateEntry(routes, rootLayout, basePath, clientLogging);
|
|
322
412
|
const hydratePath = join(outDir, "_hydrate.tsx");
|
|
323
413
|
const existingHydrate = existsSync(hydratePath) ? readFileSync(hydratePath, "utf8") : "";
|
|
414
|
+
let changed = false;
|
|
324
415
|
if (hydrateCode !== existingHydrate) {
|
|
325
416
|
writeFileSync(hydratePath, hydrateCode);
|
|
417
|
+
changed = true;
|
|
326
418
|
}
|
|
327
419
|
|
|
328
420
|
const indexHtml = generateIndexHtml();
|
|
@@ -330,13 +422,16 @@ export function writeDevFiles(
|
|
|
330
422
|
const existingIndex = existsSync(indexPath) ? readFileSync(indexPath, "utf8") : "";
|
|
331
423
|
if (indexHtml !== existingIndex) {
|
|
332
424
|
writeFileSync(indexPath, indexHtml);
|
|
425
|
+
changed = true;
|
|
333
426
|
}
|
|
334
427
|
|
|
335
428
|
if (!skipRouteTypes) {
|
|
336
|
-
writeRouteTypes(routes, projectRoot);
|
|
429
|
+
changed = writeRouteTypes(routes, projectRoot) || changed;
|
|
337
430
|
}
|
|
338
431
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
432
|
+
if (changed) {
|
|
433
|
+
console.log(
|
|
434
|
+
"[furin] Dev files written (.furin/_hydrate.tsx + .furin/index.html + furin-env.d.ts)"
|
|
435
|
+
);
|
|
436
|
+
}
|
|
342
437
|
}
|
package/src/build/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
// biome-ignore-all lint/performance/noAwaitInLoops: build phases run in sequence because later phases consume prior artifacts
|
|
1
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { join, relative, resolve } from "node:path";
|
|
3
4
|
import { buildBunTarget, type BunTargetApp } from "../adapter/bun";
|
|
4
5
|
import { buildPackageTarget } from "../adapter/package";
|
|
5
6
|
import { buildStaticTarget } from "../adapter/static";
|
|
6
7
|
import { BUILD_TARGETS, type BuildTarget, type FurinPlugin } from "../config";
|
|
8
|
+
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
7
9
|
import { normalizePrefix } from "../server/instance.ts";
|
|
8
|
-
import { scanPages } from "../server/router/
|
|
10
|
+
import { scanPages } from "../server/router/discovery.ts";
|
|
9
11
|
import { assertNoPrefixSlugCollisions } from "../shared/prefix.ts";
|
|
10
12
|
import { scanFurinInstances } from "./scan-server";
|
|
11
13
|
import { ensureDir, toBuildRouteManifestEntry, toPosixPath } from "./shared";
|
|
@@ -14,7 +16,7 @@ import type { BuildAppOptions, BuildAppResult, BuildManifest } from "./types";
|
|
|
14
16
|
// biome-ignore lint/performance/noBarrelFile: intentional — build/index.ts is the public build API entry
|
|
15
17
|
export { buildClient } from "./client";
|
|
16
18
|
export { writeDevFiles } from "./hydrate";
|
|
17
|
-
export {
|
|
19
|
+
export { writeRouteTypes } from "./route-types";
|
|
18
20
|
export { buildSSGCacheSnapshot, type SSGCacheSnapshot } from "./ssg-cache";
|
|
19
21
|
export type {
|
|
20
22
|
BuildAppOptions,
|
|
@@ -29,6 +31,15 @@ export type {
|
|
|
29
31
|
// alternative packaging of ONE app, not an additional deploy target.
|
|
30
32
|
const IMPLEMENTED_TARGETS = ["bun", "static"] as const satisfies BuildTarget[];
|
|
31
33
|
export const BUILD_OUTPUT_DIR = ".furin/build";
|
|
34
|
+
let isomorphicRuntimePluginRegistered = false;
|
|
35
|
+
|
|
36
|
+
function registerIsomorphicRuntimePlugin(): void {
|
|
37
|
+
if (isomorphicRuntimePluginRegistered) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
Bun.plugin(isomorphicTransformPlugin("server"));
|
|
41
|
+
isomorphicRuntimePluginRegistered = true;
|
|
42
|
+
}
|
|
32
43
|
|
|
33
44
|
/**
|
|
34
45
|
* Resolves the list of apps to build, in priority order:
|
|
@@ -109,6 +120,7 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
109
120
|
console.debug("[furin] Skipped plugin at runtime:", err);
|
|
110
121
|
}
|
|
111
122
|
}
|
|
123
|
+
registerIsomorphicRuntimePlugin();
|
|
112
124
|
|
|
113
125
|
const appSpecs = resolveAppSpecs(options, serverEntry, rootDir);
|
|
114
126
|
const duplicatePrefix = appSpecs.find(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
const INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
|
|
4
|
+
|
|
5
|
+
export function productionInstrumentationPlugin(): Bun.BunPlugin {
|
|
6
|
+
return {
|
|
7
|
+
name: "furin-production-instrumentation",
|
|
8
|
+
setup(build) {
|
|
9
|
+
build.onResolve({ filter: INSTRUMENTATION_IMPORT }, () => ({
|
|
10
|
+
path: resolve(import.meta.dir, "../server/devtools/instrumentation.production.ts"),
|
|
11
|
+
}));
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
package/src/build/route-types.ts
CHANGED
|
@@ -1,122 +1,26 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/** @internal Exported for unit testing only. */
|
|
6
|
-
export function patternToTypeString(pattern: string): string {
|
|
7
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: intentional — generates TS template literal syntax
|
|
8
|
-
const t = pattern.replace(/:[^/]+/g, "${string}").replace(/\*/g, "${string}");
|
|
9
|
-
return t.includes("${") ? `\`${t}\`` : `"${t}"`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Converts a runtime TypeBox/JSON Schema object to a TypeScript type string.
|
|
14
|
-
* Handles the common cases found in Elysia query schemas (string, number, boolean,
|
|
15
|
-
* optional fields, nullable via anyOf).
|
|
16
|
-
*
|
|
17
|
-
* @internal Exported for unit testing only.
|
|
18
|
-
*/
|
|
19
|
-
export function schemaToTypeString(schema: unknown): string {
|
|
20
|
-
return schemaToTypeStringWithDefaults(schema, true);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function schemaToTypeStringWithDefaults(schema: unknown, defaultsAreRequired: boolean): string {
|
|
24
|
-
if (!schema || typeof schema !== "object") {
|
|
25
|
-
return "unknown";
|
|
26
|
-
}
|
|
27
|
-
const s = schema as Record<string, unknown>;
|
|
28
|
-
if (s.anyOf && Array.isArray(s.anyOf)) {
|
|
29
|
-
const parts: string[] = [];
|
|
30
|
-
for (const item of s.anyOf as unknown[]) {
|
|
31
|
-
const t = schemaToTypeStringWithDefaults(item, defaultsAreRequired);
|
|
32
|
-
if (t !== "null") parts.push(t);
|
|
33
|
-
}
|
|
34
|
-
return parts.join(" | ") || "unknown";
|
|
35
|
-
}
|
|
36
|
-
switch (s.type) {
|
|
37
|
-
case "string":
|
|
38
|
-
return "string";
|
|
39
|
-
case "number":
|
|
40
|
-
case "integer":
|
|
41
|
-
return "number";
|
|
42
|
-
case "boolean":
|
|
43
|
-
return "boolean";
|
|
44
|
-
case "null":
|
|
45
|
-
return "null";
|
|
46
|
-
case "array": {
|
|
47
|
-
const inner = schemaToTypeStringWithDefaults(s.items, defaultsAreRequired);
|
|
48
|
-
return inner.includes("|") || inner.includes("&") ? `(${inner})[]` : `${inner}[]`;
|
|
49
|
-
}
|
|
50
|
-
case "object": {
|
|
51
|
-
if (!s.properties || typeof s.properties !== "object") {
|
|
52
|
-
return "Record<string, unknown>";
|
|
53
|
-
}
|
|
54
|
-
const required = new Set<string>(Array.isArray(s.required) ? (s.required as string[]) : []);
|
|
55
|
-
const props = Object.entries(s.properties as Record<string, unknown>)
|
|
56
|
-
.map(([k, v]) => {
|
|
57
|
-
const isPresent =
|
|
58
|
-
required.has(k) || (defaultsAreRequired && hasNonNullSchemaDefault(v));
|
|
59
|
-
return `${k}${isPresent ? "" : "?"}: ${schemaToTypeStringWithDefaults(v, defaultsAreRequired)}`;
|
|
60
|
-
})
|
|
61
|
-
.join("; ");
|
|
62
|
-
return `{ ${props} }`;
|
|
63
|
-
}
|
|
64
|
-
default:
|
|
65
|
-
return "unknown";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @internal Exported for unit testing only. */
|
|
70
|
-
export function schemaToInputTypeString(schema: unknown): string {
|
|
71
|
-
return schemaToTypeStringWithDefaults(schema, false);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function hasNonNullSchemaDefault(schema: unknown): boolean {
|
|
75
|
-
if (!schema || typeof schema !== "object") {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
const s = schema as Record<string, unknown>;
|
|
79
|
-
return (
|
|
80
|
-
"default" in s &&
|
|
81
|
-
s.default != null
|
|
82
|
-
);
|
|
83
|
-
}
|
|
1
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { extname, join, relative } from "node:path";
|
|
3
|
+
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
4
|
+
import { routeMapDeclaration, type RouteMapEntry } from "../shared/route-map.ts";
|
|
84
5
|
|
|
85
6
|
function tagKeyToPropertyName(tag: string): string {
|
|
86
7
|
return /^[$A-Z_a-z][$\w]*$/.test(tag) ? tag : JSON.stringify(tag);
|
|
87
8
|
}
|
|
88
9
|
|
|
89
10
|
function tagToStringLiteral(tag: string): string {
|
|
90
|
-
// Use JSON.stringify for robust escaping of control chars, unicode
|
|
91
|
-
// separators, backslashes and quotes, then convert double quotes to single.
|
|
92
11
|
const json = JSON.stringify(tag);
|
|
93
|
-
// json is double-quoted; convert to single-quoted literal by escaping
|
|
94
|
-
// any contained single quotes and swapping the outer quotes.
|
|
95
12
|
return `'${json.slice(1, -1).replaceAll("'", "\\'")}'`;
|
|
96
13
|
}
|
|
97
14
|
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** @internal Exported for unit testing only. */
|
|
107
|
-
export function writeRouteTypes(routes: ResolvedRoute[], projectRoot: string): void {
|
|
108
|
-
const sortedRoutes = [...routes].sort((a, b) => a.pattern.localeCompare(b.pattern));
|
|
109
|
-
const entries = sortedRoutes.map((r) => {
|
|
110
|
-
const typeKey = patternToTypeString(r.pattern);
|
|
111
|
-
const isDynamic = typeKey.startsWith("`");
|
|
112
|
-
const querySchema = mergeRouteSchemas(r.routeChain ?? [], "query");
|
|
113
|
-
const searchType = querySchema ? schemaToTypeString(querySchema) : "never";
|
|
114
|
-
const searchInputType = querySchema ? schemaToInputTypeString(querySchema) : "never";
|
|
115
|
-
return isDynamic
|
|
116
|
-
? ` [key: ${typeKey}]: { search?: ${searchType}; searchInput?: ${searchInputType} }`
|
|
117
|
-
: ` ${typeKey}: { search?: ${searchType}; searchInput?: ${searchInputType} }`;
|
|
15
|
+
/** @internal Exported for framework build and focused contract tests. */
|
|
16
|
+
export function writeRouteTypes(routes: ResolvedRoute[], projectRoot: string): boolean {
|
|
17
|
+
const entries: RouteMapEntry[] = routes.map((route) => {
|
|
18
|
+
const extension = extname(route.path);
|
|
19
|
+
const sourcePath = extension ? route.path.slice(0, -extension.length) : route.path;
|
|
20
|
+
const relativePath = relative(projectRoot, sourcePath).replaceAll("\\", "/");
|
|
21
|
+
const specifier = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
22
|
+
return { importSpecifier: specifier, pattern: route.pattern };
|
|
118
23
|
});
|
|
119
|
-
const routeManifestEntries = entries.join(";\n");
|
|
120
24
|
|
|
121
25
|
const sortedTags = [...new Set(routes.flatMap((route) => route.tags ?? []))].sort();
|
|
122
26
|
const tagBlock =
|
|
@@ -128,18 +32,18 @@ export function writeRouteTypes(routes: ResolvedRoute[], projectRoot: string): v
|
|
|
128
32
|
|
|
129
33
|
const content = `// Auto-generated by Furin. Do not edit manually.
|
|
130
34
|
/// <reference types="@teyik0/furin/env" />
|
|
131
|
-
import "@teyik0/furin/
|
|
35
|
+
import "@teyik0/furin/routes";
|
|
132
36
|
|
|
133
|
-
|
|
134
|
-
interface RouteManifest {
|
|
135
|
-
${routeManifestEntries};
|
|
136
|
-
}
|
|
137
|
-
}${tagBlock}
|
|
37
|
+
${routeMapDeclaration(entries)}${tagBlock}
|
|
138
38
|
`;
|
|
139
39
|
|
|
140
40
|
const typesPath = join(projectRoot, "furin-env.d.ts");
|
|
141
41
|
const existing = existsSync(typesPath) ? readFileSync(typesPath, "utf8") : "";
|
|
142
|
-
if (content
|
|
143
|
-
|
|
42
|
+
if (content === existing) {
|
|
43
|
+
return false;
|
|
144
44
|
}
|
|
45
|
+
const temporaryPath = `${typesPath}.${process.pid}.${Bun.nanoseconds()}.tmp`;
|
|
46
|
+
writeFileSync(temporaryPath, content);
|
|
47
|
+
renameSync(temporaryPath, typesPath);
|
|
48
|
+
return true;
|
|
145
49
|
}
|
package/src/build/scan-server.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import type { CallExpression, ObjectExpression, ObjectProperty } from "@yuku-toolchain/types";
|
|
3
3
|
import { normalizePrefix } from "../server/instance.ts";
|
|
4
4
|
import { detectLangFromPath, unwrapTSExpression } from "../server/lang-detect.ts";
|
|
5
5
|
import { walkAST } from "../shared/utils/ast-walk.ts";
|
|
6
|
+
import { parseSource } from "../shared/parser.ts";
|
|
6
7
|
|
|
7
8
|
export interface ScannedFurinInstance {
|
|
8
9
|
pagesDir: string;
|
|
@@ -27,7 +28,7 @@ export function scanFurinInstances(serverEntryPath: string): ScannedFurinInstanc
|
|
|
27
28
|
return [];
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
const { program, diagnostics } =
|
|
31
|
+
const { program, diagnostics } = parseSource(code, lang);
|
|
31
32
|
const firstError = diagnostics.find((d) => d.severity === "error");
|
|
32
33
|
if (firstError) {
|
|
33
34
|
console.error("[furin] scan-server: parse error:", firstError.message, "in", serverEntryPath);
|
package/src/build/shared.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import type { BuildTarget } from "../config";
|
|
5
|
-
import type { ResolvedRoute } from "../server/router/
|
|
5
|
+
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
6
6
|
import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
|
|
7
7
|
|
|
8
8
|
// import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
|
package/src/build/ssg-cache.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
// biome-ignore-all lint/performance/noAwaitInLoops: SSG cache generation runs routes sequentially for deterministic cache output
|
|
1
2
|
import type { SsgCacheEntry } from "../server/cache/index.ts";
|
|
2
|
-
import { prerenderSSG } from "../server/render/index.ts";
|
|
3
|
-
import { createSearchRouteMetadata, type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
|
|
4
3
|
import { resolvePath } from "../server/render/assemble.ts";
|
|
4
|
+
import { prerenderSSG } from "../server/render/index.ts";
|
|
5
|
+
import { createSearchRouteMetadata } from "../server/router/schemas.ts";
|
|
6
|
+
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
5
7
|
|
|
6
8
|
export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
|
|
7
9
|
|
package/src/build/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BuildTarget, StaticExportConfig } from "../config";
|
|
2
|
-
import type { ResolvedRoute } from "../server/router/
|
|
2
|
+
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
3
3
|
|
|
4
4
|
export interface BuildClientOptions {
|
|
5
5
|
/**
|
|
@@ -46,6 +46,7 @@ export interface TargetBuildManifest {
|
|
|
46
46
|
buildId: string;
|
|
47
47
|
clientDir: string | null;
|
|
48
48
|
generatedAt: string;
|
|
49
|
+
rscManifestPath?: string;
|
|
49
50
|
serverEntry: string | null;
|
|
50
51
|
serverPath: string | null;
|
|
51
52
|
targetDir: string;
|
package/src/cli/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import { TypeCompiler } from "elysia/type-system";
|
|
5
4
|
import { configSchema, type FurinConfig } from "../config.ts";
|
|
5
|
+
import { TypeCompiler } from "../shared/elysia-contract.ts";
|
|
6
6
|
|
|
7
7
|
const compiledConfigSchema = TypeCompiler.Compile(configSchema);
|
|
8
8
|
|
|
@@ -64,11 +64,11 @@ export async function loadCliConfig(
|
|
|
64
64
|
const resolvedRootDir = resolve(rootDir, configToValidate.rootDir ?? ".");
|
|
65
65
|
return {
|
|
66
66
|
...configToValidate,
|
|
67
|
-
plugins,
|
|
68
67
|
configPath,
|
|
69
|
-
rootDir: resolvedRootDir,
|
|
70
68
|
pagesDir: configToValidate.pagesDir
|
|
71
69
|
? resolve(resolvedRootDir, configToValidate.pagesDir)
|
|
72
70
|
: undefined,
|
|
71
|
+
plugins,
|
|
72
|
+
rootDir: resolvedRootDir,
|
|
73
73
|
};
|
|
74
74
|
}
|