@teyik0/furin 0.5.0-alpha.2 → 0.7.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/dist/adapter/runtime-build.d.ts +3 -1
- package/dist/build/client.d.ts +4 -1
- package/dist/build/entry-template.d.ts +5 -0
- package/dist/build/entry-template.ts +9 -0
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.js +9589 -6685
- package/dist/build/preload-manifest.d.ts +17 -0
- package/dist/build/request-keys.d.ts +4 -0
- package/dist/build/types.d.ts +6 -0
- package/dist/cli/index.js +9539 -6644
- package/dist/client/browser-events-runtime.d.ts +2 -1
- package/dist/client/client-module.d.ts +26 -0
- package/dist/client/define-route.d.ts +9 -1
- package/dist/client/dev-error-overlay.ts +1 -0
- package/dist/client/document.d.ts +3 -0
- package/dist/client/hmr.d.ts +1 -1
- package/dist/client/internal/runtime-types.d.ts +2 -0
- package/dist/client/link.js +1011 -157
- package/dist/client/mutation.d.ts +38 -0
- package/dist/client/query-store.d.ts +85 -0
- package/dist/client/query.d.ts +14 -0
- package/dist/client/route-api.d.ts +11 -0
- package/dist/client/router/context.d.ts +3 -2
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +8 -1
- package/dist/client/router/navigation.d.ts +2 -9
- package/dist/client/router/optimistic.d.ts +41 -0
- package/dist/client/router/search/index.d.ts +3 -3
- package/dist/client/router/search-store.d.ts +1 -0
- package/dist/client/router/sync-catch-up.d.ts +3 -0
- package/dist/client/router/types.d.ts +49 -7
- package/dist/client/sync.d.ts +39 -22
- package/dist/client.d.ts +11 -33
- package/dist/client.js +1222 -57
- package/dist/config.d.ts +7 -0
- package/dist/config.js +1 -0
- package/dist/define-route.d.ts +231 -123
- package/dist/env.d.ts +2 -2
- package/dist/furin.d.ts +4 -2
- package/dist/furin.js +9717 -6796
- package/dist/plugin/hmr-dependencies.d.ts +2 -0
- package/dist/plugin/index.js +811 -145
- package/dist/plugin/transform-client-module.d.ts +16 -0
- package/dist/plugin/transform-client.d.ts +2 -0
- package/dist/plugin/transform-dev-page.d.ts +7 -0
- package/dist/plugin/transform-isomorphic.d.ts +1 -1
- package/dist/routes.d.ts +6 -0
- package/dist/rsc-client.js +87 -16
- package/dist/rsc.js +87 -16
- package/dist/server/auto-invalidate/registry.d.ts +5 -2
- package/dist/server/auto-invalidate/types.d.ts +2 -0
- package/dist/server/browser-events/plugin.d.ts +3 -0
- package/dist/server/cache/isr.d.ts +2 -4
- package/dist/server/cache/route-cache.d.ts +5 -0
- package/dist/server/dev/graph.d.ts +1 -0
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +6 -19
- package/dist/server/internal.d.ts +5 -0
- package/dist/server/internal.js +105 -57
- package/dist/server/production-server.js +104 -56
- package/dist/server/render/assemble.d.ts +6 -6
- package/dist/server/render/document.d.ts +1 -1
- package/dist/server/render/element.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +15 -5
- package/dist/server/render/mixed-cache.d.ts +6 -0
- package/dist/server/render/react-stream.d.ts +3 -0
- package/dist/server/render/ssr.d.ts +5 -4
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +2 -0
- package/dist/server/router/discovery.d.ts +1 -0
- package/dist/server/router/hmr.d.ts +1 -1
- package/dist/server/router/patterns.d.ts +3 -0
- package/dist/server/router/plugin.d.ts +3 -0
- package/dist/server/router/types.d.ts +4 -0
- package/dist/server/security/csp.d.ts +12 -0
- package/dist/server/sync/adapter.d.ts +25 -4
- package/dist/server/sync/atomic.d.ts +25 -0
- package/dist/server/sync/drizzle/index.d.ts +45 -0
- package/dist/server/sync/drizzle/index.js +540 -0
- package/dist/server/sync/execution-error.d.ts +2 -0
- package/dist/server/sync/index.d.ts +2 -1
- package/dist/server/sync/index.js +580 -124
- package/dist/server/sync/mutation-handler.d.ts +4 -0
- package/dist/server/sync/plugin.d.ts +34 -11
- package/dist/server/sync/postgres/execute.d.ts +3 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +42 -13
- package/dist/server/sync/postgres/sql.d.ts +8 -0
- package/dist/server/sync/prisma/index.d.ts +24 -0
- package/dist/server/sync/prisma/index.js +340 -0
- package/dist/server/sync/queries.d.ts +21 -0
- package/dist/server/sync/query-context.d.ts +5 -0
- package/dist/server/sync/redis/index.js +3 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/response.d.ts +1 -0
- package/dist/server/sync/sqlite/index.d.ts +3 -0
- package/dist/server/sync/sqlite/index.js +10 -4
- package/dist/server/sync/stream.d.ts +2 -5
- package/dist/server/sync/validation.d.ts +4 -0
- package/dist/shared/defer.d.ts +31 -0
- package/dist/shared/error.d.ts +2 -2
- package/dist/shared/page-key.d.ts +7 -0
- package/dist/shared/query-bindings.d.ts +12 -0
- package/dist/shared/route-frame.d.ts +1 -0
- package/dist/shared/sync-query.d.ts +40 -0
- package/package.json +40 -16
- package/src/adapter/README.md +3 -0
- package/src/adapter/bun.ts +3 -0
- package/src/adapter/package.ts +16 -2
- package/src/adapter/runtime-build.ts +99 -14
- package/src/adapter/static.ts +17 -6
- package/src/adapter/vercel.ts +33 -23
- package/src/build/client.ts +23 -5
- package/src/build/entry-template.ts +9 -0
- package/src/build/hydrate.ts +18 -3
- package/src/build/preload-manifest.ts +100 -0
- package/src/build/production-instrumentation.ts +6 -3
- package/src/build/request-keys.ts +93 -0
- package/src/build/ssg-cache.ts +9 -4
- package/src/build/types.ts +4 -0
- package/src/cli/index.ts +1 -0
- package/src/client/boundaries.tsx +1 -1
- package/src/client/browser-events-runtime.ts +73 -16
- package/src/client/client-module.ts +57 -0
- package/src/client/define-route.ts +11 -2
- package/src/client/dev-error-overlay.ts +1 -0
- package/src/client/document.tsx +47 -20
- package/src/client/hmr.ts +4 -2
- package/src/client/internal/runtime-types.ts +2 -0
- package/src/client/link.tsx +8 -8
- package/src/client/mutation.ts +136 -0
- package/src/client/query-store.ts +418 -0
- package/src/client/query.tsx +67 -0
- package/src/client/route-api.tsx +75 -0
- package/src/client/router/boundary-tree.tsx +10 -6
- package/src/client/router/context.ts +57 -4
- package/src/client/router/index.ts +3 -0
- package/src/client/router/link-utils.ts +29 -1
- package/src/client/router/navigation.ts +3 -50
- package/src/client/router/optimistic.ts +233 -0
- package/src/client/router/provider.tsx +404 -96
- package/src/client/router/search/index.ts +37 -17
- package/src/client/router/search-store.ts +4 -0
- package/src/client/router/sync-catch-up.ts +7 -0
- package/src/client/router/types.ts +71 -9
- package/src/client/sync.ts +438 -65
- package/src/client.ts +20 -60
- package/src/config.ts +5 -0
- package/src/define-route.ts +442 -155
- package/src/env.d.ts +2 -2
- package/src/furin.ts +213 -38
- package/src/plugin/hmr-dependencies.ts +58 -0
- package/src/plugin/index.ts +38 -2
- package/src/plugin/route-config-autofix.ts +2 -2
- package/src/plugin/routes.ts +19 -8
- package/src/plugin/transform-client-module.ts +123 -0
- package/src/plugin/transform-client.ts +293 -13
- package/src/plugin/transform-dev-page.ts +231 -0
- package/src/plugin/transform-isomorphic.ts +11 -5
- package/src/routes.ts +8 -0
- package/src/rsc/shared.tsx +104 -18
- package/src/rsc/version.ts +5 -0
- package/src/server/auto-invalidate/registry.ts +56 -24
- package/src/server/auto-invalidate/runtime.ts +17 -0
- package/src/server/auto-invalidate/types.ts +6 -0
- package/src/server/browser-events/plugin.ts +112 -1
- package/src/server/cache/dev-loader.ts +1 -1
- package/src/server/cache/invalidation.ts +2 -0
- package/src/server/cache/isr-ssg.ts +1 -1
- package/src/server/cache/isr.ts +6 -34
- package/src/server/cache/route-cache.ts +40 -4
- package/src/server/cache/ssg.ts +1 -1
- package/src/server/dev/diagnostics.ts +4 -2
- package/src/server/dev/error.ts +2 -1
- package/src/server/dev/graph.ts +70 -7
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev/symbolicate.ts +2 -0
- package/src/server/dev-page-plugin.ts +160 -63
- package/src/server/evlog.ts +1 -1
- package/src/server/internal.ts +5 -0
- package/src/server/render/assemble.ts +15 -11
- package/src/server/render/document.tsx +13 -2
- package/src/server/render/element.tsx +11 -6
- package/src/server/render/isr.ts +71 -33
- package/src/server/render/loaders.ts +328 -70
- package/src/server/render/mixed-cache.ts +327 -0
- package/src/server/render/not-found.ts +14 -11
- package/src/server/render/ppr-document.ts +47 -11
- package/src/server/render/ppr-route.ts +54 -20
- package/src/server/render/react-stream.ts +17 -0
- package/src/server/render/route-frame-transport.ts +3 -0
- package/src/server/render/ssg.ts +53 -19
- package/src/server/render/ssr.ts +105 -36
- package/src/server/render/static-params.ts +1 -1
- package/src/server/render/template.ts +23 -0
- package/src/server/router/defined-route.ts +3 -0
- package/src/server/router/discovery.ts +14 -0
- package/src/server/router/hmr.ts +109 -18
- package/src/server/router/patterns.ts +27 -0
- package/src/server/router/plugin.ts +94 -19
- package/src/server/router/source-version.ts +20 -2
- package/src/server/router/types.ts +4 -0
- package/src/server/security/csp.ts +44 -0
- package/src/server/sync/adapter.ts +41 -4
- package/src/server/sync/atomic.ts +303 -0
- package/src/server/sync/drizzle/index.ts +145 -0
- package/src/server/sync/execution-error.ts +1 -0
- package/src/server/sync/fingerprint.ts +2 -6
- package/src/server/sync/index.ts +6 -0
- package/src/server/sync/mutation-handler.ts +69 -0
- package/src/server/sync/plugin.ts +177 -60
- package/src/server/sync/postgres/execute.ts +20 -0
- package/src/server/sync/postgres/index.ts +60 -16
- package/src/server/sync/postgres/sql.ts +20 -0
- package/src/server/sync/prisma/index.ts +70 -0
- package/src/server/sync/queries.ts +75 -0
- package/src/server/sync/query-context.ts +85 -0
- package/src/server/sync/redis/index.ts +7 -3
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/response.ts +21 -0
- package/src/server/sync/sqlite/index.ts +19 -8
- package/src/server/sync/stream.ts +14 -22
- package/src/server/sync/validation.ts +34 -0
- package/src/shared/defer.ts +48 -0
- package/src/shared/error.ts +2 -2
- package/src/shared/page-key.ts +36 -0
- package/src/shared/query-bindings.ts +138 -0
- package/src/shared/route-frame.ts +13 -1
- package/src/shared/route-map.ts +12 -2
- package/src/shared/sync-query.ts +138 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const BEGIN_MUTATION_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif raw then\n local value = cjson.decode(raw)\n if value.fingerprint ~= ARGV[1] then\n return {'conflict', 'payload-mismatch'}\n end\n if value.state == 'succeeded' then\n return {'replay', raw}\n end\n if value.leaseUntil > now then\n return {'conflict', 'in-progress'}\n end\nend\nlocal value = {\n fingerprint = ARGV[1],\n id = ARGV[2],\n leaseUntil = now + tonumber(ARGV[3]),\n state = 'in-progress'\n}\nredis.call('SET', KEYS[1], cjson.encode(value), 'PX', ARGV[4])\nreturn {'execute', ARGV[2]}\n";
|
|
2
2
|
export declare const RENEW_MUTATION_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return 'lost' end\nlocal value = cjson.decode(raw)\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif value.state ~= 'in-progress' or value.id ~= ARGV[1] or value.leaseUntil <= now then\n return 'lost'\nend\nvalue.leaseUntil = now + tonumber(ARGV[2])\nredis.call('SET', KEYS[1], cjson.encode(value), 'PX', ARGV[3])\nreturn 'renewed'\n";
|
|
3
|
-
export declare const COMPLETE_MUTATION_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return {'lost'} end\nlocal value = cjson.decode(raw)\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif value.state ~= 'in-progress' or value.id ~= ARGV[1] or value.leaseUntil <= now then\n return {'lost'}\nend\nvalue.state = 'succeeded'\nvalue.response =
|
|
3
|
+
export declare const COMPLETE_MUTATION_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return {'lost'} end\nlocal value = cjson.decode(raw)\nlocal now_parts = redis.call('TIME')\nlocal now = tonumber(now_parts[1]) * 1000 + math.floor(tonumber(now_parts[2]) / 1000)\nif value.state ~= 'in-progress' or value.id ~= ARGV[1] or value.leaseUntil <= now then\n return {'lost'}\nend\nvalue.state = 'succeeded'\nvalue.response = ARGV[2]\nvalue.leaseUntil = nil\nlocal cursor = ''\nif ARGV[3] ~= '[]' then\n local length = redis.call('XLEN', KEYS[2])\n if length >= tonumber(ARGV[5]) then\n local oldest = redis.call('XRANGE', KEYS[2], '-', '+', 'COUNT', 1)\n if oldest[1] then redis.call('SET', KEYS[3], oldest[1][1]) end\n end\n cursor = redis.call('XADD', KEYS[2], 'MAXLEN', '=', ARGV[5], '*', 'data', ARGV[3])\nend\nredis.call('SET', KEYS[1], cjson.encode(value), 'PX', ARGV[4])\nreturn {'committed', cursor}\n";
|
|
4
4
|
export declare const ABORT_MUTATION_SCRIPT = "\nlocal raw = redis.call('GET', KEYS[1])\nif not raw then return 0 end\nlocal value = cjson.decode(raw)\nif value.state == 'in-progress' and value.id == ARGV[1] then\n return redis.call('DEL', KEYS[1])\nend\nreturn 0\n";
|
|
@@ -10,4 +10,5 @@ export type StoreResponseResult = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare function mergeStoredResponseHeaders(storedResponse: StoredResponse, headers: Context["set"]["headers"]): StoredResponse;
|
|
12
12
|
export declare function storeResponse(responseValue: unknown, set: Context["set"]): Promise<StoreResponseResult>;
|
|
13
|
+
export declare function storeResponseSync(responseValue: unknown, set: Context["set"]): StoreResponseResult;
|
|
13
14
|
export declare function replayResponse(stored: StoredResponse): Response;
|
|
@@ -11,7 +11,10 @@ export declare class SqliteSyncAdapter implements SyncAdapter {
|
|
|
11
11
|
private readonly namespace;
|
|
12
12
|
constructor(options: SqliteSyncAdapterOptions);
|
|
13
13
|
beginMutation(input: BeginMutationInput): Promise<BeginMutationResult>;
|
|
14
|
+
protected beginMutationSync(input: BeginMutationInput): BeginMutationResult;
|
|
14
15
|
completeMutation(input: CompleteMutationInput): Promise<CompleteMutationResult>;
|
|
16
|
+
protected completeMutationSync(input: CompleteMutationInput): CompleteMutationResult;
|
|
17
|
+
protected hasMutationLeaseSync(lease: MutationLease): boolean;
|
|
15
18
|
abortMutation(lease: MutationLease): Promise<void>;
|
|
16
19
|
currentCursor(): Promise<string>;
|
|
17
20
|
readChanges(input: ReadChangesInput): Promise<ChangePage>;
|
|
@@ -107,6 +107,9 @@ class SqliteSyncAdapter {
|
|
|
107
107
|
this.scope = options.database.filename === "" || options.database.filename === ":memory:" ? "process-local" : "host-local";
|
|
108
108
|
}
|
|
109
109
|
async beginMutation(input) {
|
|
110
|
+
return this.beginMutationSync(input);
|
|
111
|
+
}
|
|
112
|
+
beginMutationSync(input) {
|
|
110
113
|
const transaction = this.database.transaction((mutation) => {
|
|
111
114
|
const now = Date.now();
|
|
112
115
|
const key = mutationKey(mutation);
|
|
@@ -156,13 +159,13 @@ class SqliteSyncAdapter {
|
|
|
156
159
|
return transaction.immediate(input);
|
|
157
160
|
}
|
|
158
161
|
async completeMutation(input) {
|
|
162
|
+
return this.completeMutationSync(input);
|
|
163
|
+
}
|
|
164
|
+
completeMutationSync(input) {
|
|
159
165
|
const transaction = this.database.transaction((completion) => {
|
|
160
166
|
const now = Date.now();
|
|
161
167
|
const key = mutationKey(completion.lease);
|
|
162
|
-
|
|
163
|
-
WHERE namespace = ? AND mutation_key = ? AND mutation_id = ?
|
|
164
|
-
AND state = 'in-progress' AND lease_expires_at > ?`).get(this.namespace, key, completion.lease.id, now);
|
|
165
|
-
if (!active) {
|
|
168
|
+
if (!this.hasMutationLeaseSync(completion.lease)) {
|
|
166
169
|
return { kind: "lost" };
|
|
167
170
|
}
|
|
168
171
|
let cursor;
|
|
@@ -195,6 +198,9 @@ class SqliteSyncAdapter {
|
|
|
195
198
|
});
|
|
196
199
|
return transaction.immediate(input);
|
|
197
200
|
}
|
|
201
|
+
hasMutationLeaseSync(lease) {
|
|
202
|
+
return this.database.query(`SELECT mutation_id FROM furin_sync_mutations WHERE namespace = ? AND mutation_key = ? AND mutation_id = ? AND state = 'in-progress' AND lease_expires_at > ?`).get(this.namespace, mutationKey(lease), lease.id, Date.now()) !== null;
|
|
203
|
+
}
|
|
198
204
|
async abortMutation(lease) {
|
|
199
205
|
this.database.query(`DELETE FROM furin_sync_mutations
|
|
200
206
|
WHERE namespace = ? AND mutation_key = ? AND mutation_id = ? AND state = 'in-progress'`).run(this.namespace, mutationKey(lease), lease.id);
|
|
@@ -6,7 +6,7 @@ export declare function subscribeSyncCursor(options: FurinSyncOptions, listener:
|
|
|
6
6
|
export declare function createSyncChangesPlugin(options: FurinSyncOptions): import("elysia/types").AddRoute<"", "local", import("elysia").DefaultSingleton, {
|
|
7
7
|
typebox: {};
|
|
8
8
|
error: [];
|
|
9
|
-
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, "get", `${string}/changes`, import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{}, {}, `/${string}/changes`>, import("elysia/types").MergeScopedSchemas<{}, {}, {}>>, {}, (
|
|
9
|
+
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, "get", `${string}/changes`, import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{}, {}, `/${string}/changes`>, import("elysia/types").MergeScopedSchemas<{}, {}, {}>>, {}, (context: {
|
|
10
10
|
server: import("elysia").Server | null;
|
|
11
11
|
redirect: import("elysia").redirect;
|
|
12
12
|
set: {
|
|
@@ -31,13 +31,10 @@ export declare function createSyncChangesPlugin(options: FurinSyncOptions): impo
|
|
|
31
31
|
headers: Record<string, string | undefined>;
|
|
32
32
|
cookie: Record<string, import("elysia").Cookie<unknown>>;
|
|
33
33
|
}) => Promise<Response | {
|
|
34
|
+
changes: never[];
|
|
34
35
|
cursor: string;
|
|
35
36
|
hasMore: boolean;
|
|
36
37
|
reset: boolean;
|
|
37
|
-
changes: {
|
|
38
|
-
cursor: string;
|
|
39
|
-
invalidations: string[];
|
|
40
|
-
}[];
|
|
41
38
|
}>>;
|
|
42
39
|
/** @internal — closes process-local stream state between tests. */
|
|
43
40
|
export declare function __resetSyncState(): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context, Elysia } from "elysia";
|
|
2
|
+
/** Bind the final application's models, guards and normalization to native request contexts. */
|
|
3
|
+
export declare function bindSyncValidation(app: Elysia): void;
|
|
4
|
+
export declare function syncValidationApp(context: Context): Elysia;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const DEFERRED_BRAND: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A loader return value that contains a mix of synchronous scalar fields and
|
|
4
|
+
* lazy `Promise<T>` fields. Scalar fields are serialised into the initial HTML
|
|
5
|
+
* shell; Promise fields are streamed as late `<script>` resolution chunks.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* loader: () => defer({
|
|
9
|
+
* title: "My Board", // synchronous — available immediately
|
|
10
|
+
* stats: fetchStats(), // Promise — streamed when it resolves
|
|
11
|
+
* })
|
|
12
|
+
*/
|
|
13
|
+
export type DeferredData<T extends object> = T & {
|
|
14
|
+
readonly [DEFERRED_BRAND]: true;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wraps loader data so that Promise-valued fields are streamed lazily while
|
|
18
|
+
* scalar fields are embedded in the initial HTML shell immediately.
|
|
19
|
+
*
|
|
20
|
+
* Use in any `defineRoute().loader()`. Promise-valued fields are streamed lazily;
|
|
21
|
+
* scalar fields are embedded in the initial HTML shell.
|
|
22
|
+
*/
|
|
23
|
+
export declare function defer<T extends object>(data: T & {
|
|
24
|
+
readonly [DEFERRED_BRAND]?: never;
|
|
25
|
+
}): DeferredData<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard for DeferredData. Used by the render pipeline to distinguish a
|
|
28
|
+
* plain loader return from a deferred one.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isDeferred(value: unknown): value is DeferredData<object>;
|
|
31
|
+
export {};
|
package/dist/shared/error.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export interface ErrorProps {
|
|
|
12
12
|
digest: string;
|
|
13
13
|
/**
|
|
14
14
|
* HTTP status associated with the error.
|
|
15
|
-
* - For thrown `Response` objects
|
|
15
|
+
* - For thrown `Response` objects and Eden problem errors: their HTTP
|
|
16
16
|
* status (e.g. 401, 403, 404, 500).
|
|
17
|
-
* - For
|
|
17
|
+
* - For other errors (thrown `Error`, non-Error throws, shell-render
|
|
18
18
|
* crashes): always `500`.
|
|
19
19
|
*
|
|
20
20
|
* Always present so consumers never need a `?? 500` fallback. Note that
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RemountDependency = string | number | boolean | null | undefined;
|
|
2
|
+
export type RemountDeps<Params, Query> = (context: {
|
|
3
|
+
readonly params: Params;
|
|
4
|
+
readonly query: Query;
|
|
5
|
+
}) => readonly RemountDependency[];
|
|
6
|
+
/** Shared by SSR and navigation; loader data never participates in page identity. */
|
|
7
|
+
export declare function pageKey(pattern: string, data: object, remountDeps: RemountDeps<object, object> | undefined): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { QuerySeed } from "./sync-query.ts";
|
|
2
|
+
export interface DeferredQueryValue {
|
|
3
|
+
projection?: {
|
|
4
|
+
value: unknown;
|
|
5
|
+
promise: Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
value: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Track returned objects by reference; computed scalars have no reliable provenance. */
|
|
10
|
+
export declare function bindQueryData(data: object, seeds: readonly QuerySeed[]): QuerySeed[];
|
|
11
|
+
export declare function projectQueryData<Data extends object>(data: Data, seeds: readonly QuerySeed[], read: (seed: QuerySeed) => unknown): Data;
|
|
12
|
+
export declare function projectDeferredQueryData<Data extends object>(data: Data, seeds: readonly QuerySeed[], read: (seed: QuerySeed) => unknown, resolved: WeakMap<Promise<unknown>, DeferredQueryValue>): Data;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface QueryScope {
|
|
2
|
+
readonly [key: string]: string | number | boolean | null | undefined;
|
|
3
|
+
}
|
|
4
|
+
export interface QueryIdentity {
|
|
5
|
+
id: string;
|
|
6
|
+
scope: QueryScope;
|
|
7
|
+
}
|
|
8
|
+
type RegisteredScope<Id extends keyof SyncQueryMap> = keyof SyncQueryMap[Id] extends never ? {
|
|
9
|
+
readonly [key: string]: never;
|
|
10
|
+
} : {
|
|
11
|
+
readonly [Key in keyof SyncQueryMap[Id]]: Extract<SyncQueryMap[Id][Key], QueryScope[string]>;
|
|
12
|
+
};
|
|
13
|
+
export type SyncQueryIdentity = keyof SyncQueryMap extends never ? QueryIdentity : {
|
|
14
|
+
[Id in keyof SyncQueryMap & string]: {
|
|
15
|
+
id: Id;
|
|
16
|
+
scope: RegisteredScope<Id>;
|
|
17
|
+
};
|
|
18
|
+
}[keyof SyncQueryMap & string];
|
|
19
|
+
export interface QueryReadIdentity extends QueryIdentity {
|
|
20
|
+
session: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function serializeQueryHeader(identity: QueryIdentity | readonly QueryIdentity[]): string;
|
|
23
|
+
export interface QuerySeed {
|
|
24
|
+
bindings?: QueryBinding[];
|
|
25
|
+
data: unknown;
|
|
26
|
+
identity: QueryReadIdentity;
|
|
27
|
+
local?: boolean;
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
export interface QueryBinding {
|
|
31
|
+
source: string[];
|
|
32
|
+
target: string[];
|
|
33
|
+
}
|
|
34
|
+
export declare function mergeQuerySeeds(target: QuerySeed[], incoming: readonly QuerySeed[]): void;
|
|
35
|
+
export declare function queryTagsFromData(data: object): string[];
|
|
36
|
+
export declare function queryTag(identity: QueryIdentity): string;
|
|
37
|
+
export declare function queryFromTag(tag: string): QueryIdentity | undefined;
|
|
38
|
+
export declare function queryUrl(url: string, origin: string | undefined): string;
|
|
39
|
+
import type { SyncQueryMap } from "@teyik0/furin/routes";
|
|
40
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.1",
|
|
4
4
|
"description": "React meta-framework powered by Elysia and Bun with file-based routing, SSR, SSG, and ISR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -127,6 +127,16 @@
|
|
|
127
127
|
"types": "./dist/client-only.d.ts",
|
|
128
128
|
"bun": "./src/client-only.ts",
|
|
129
129
|
"import": "./dist/client-only.js"
|
|
130
|
+
},
|
|
131
|
+
"./sync/drizzle": {
|
|
132
|
+
"types": "./dist/server/sync/drizzle/index.d.ts",
|
|
133
|
+
"bun": "./src/server/sync/drizzle/index.ts",
|
|
134
|
+
"import": "./dist/server/sync/drizzle/index.js"
|
|
135
|
+
},
|
|
136
|
+
"./sync/prisma": {
|
|
137
|
+
"types": "./dist/server/sync/prisma/index.d.ts",
|
|
138
|
+
"bun": "./src/server/sync/prisma/index.ts",
|
|
139
|
+
"import": "./dist/server/sync/prisma/index.js"
|
|
130
140
|
}
|
|
131
141
|
},
|
|
132
142
|
"main": "./dist/furin.js",
|
|
@@ -147,36 +157,50 @@
|
|
|
147
157
|
"benchmark:rsc": "bun scripts/benchmark-rsc-transport.ts",
|
|
148
158
|
"build": "bun run build.ts",
|
|
149
159
|
"fix": "ultracite fix",
|
|
150
|
-
"
|
|
151
|
-
"test
|
|
160
|
+
"generate:sync-prisma": "bun --bun node_modules/prisma/build/index.js generate --schema tests/fixtures/sync-prisma/schema.prisma",
|
|
161
|
+
"test": "bun run generate:sync-prisma && bun test --parallel=2 --isolate --max-concurrency 4 --bail --timeout 15000",
|
|
162
|
+
"test:dev": "bun run generate:sync-prisma && bun test --changed --parallel --isolate --max-concurrency 4 --bail --timeout 15000",
|
|
152
163
|
"test:hmr:soak": "FURIN_WEBVIEW_TESTS=1 FURIN_HMR_SOAK_TESTS=1 bun test tests/browser/hmr-conformance.webview.test.ts -t 'tracks memory' --timeout 3600000",
|
|
153
164
|
"test:webview": "FURIN_WEBVIEW_TESTS=1 bun test tests/browser/hmr-conformance.webview.test.ts --timeout 60000",
|
|
154
|
-
"tscheck": "tsc --noEmit"
|
|
165
|
+
"tscheck": "bun run generate:sync-prisma && tsc --noEmit"
|
|
155
166
|
},
|
|
156
167
|
"dependencies": {
|
|
168
|
+
"@elysia/eden": "^2.0.0-beta.5",
|
|
157
169
|
"@elysia/static": "2.0.0-beta.2",
|
|
158
170
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
159
|
-
"@vercel/functions": "^3.9.
|
|
160
|
-
"@yuku-toolchain/types": "0.
|
|
171
|
+
"@vercel/functions": "^3.9.9",
|
|
172
|
+
"@yuku-toolchain/types": "0.12.0",
|
|
161
173
|
"exact-mirror": "1.2.6",
|
|
162
|
-
"magic-string": "^1.2
|
|
163
|
-
"react-server-dom-webpack": "19.
|
|
174
|
+
"magic-string": "^1.4.2",
|
|
175
|
+
"react-server-dom-webpack": "19.3.0",
|
|
164
176
|
"seroval": "^1.6.7",
|
|
165
|
-
"
|
|
166
|
-
"yuku-
|
|
177
|
+
"typescript": "7.0.2",
|
|
178
|
+
"yuku-ast": "0.12.0",
|
|
179
|
+
"yuku-parser": "0.12.0"
|
|
167
180
|
},
|
|
168
181
|
"devDependencies": {
|
|
169
|
-
"@
|
|
170
|
-
"@
|
|
171
|
-
"
|
|
182
|
+
"@prisma/adapter-pg": "7.10.0",
|
|
183
|
+
"@prisma/client": "7.10.0",
|
|
184
|
+
"@prisma/client-runtime-utils": "7.10.0",
|
|
185
|
+
"@types/react": "^19.3.0",
|
|
186
|
+
"@types/react-dom": "^19.3.0",
|
|
187
|
+
"drizzle-orm": "0.45.3",
|
|
188
|
+
"expect-type": "^1.4.0",
|
|
189
|
+
"prisma": "7.10.0"
|
|
172
190
|
},
|
|
173
191
|
"peerDependencies": {
|
|
174
|
-
"
|
|
192
|
+
"drizzle-orm": "^0.45.3",
|
|
193
|
+
"elysia": "2.0.0-beta.21",
|
|
175
194
|
"evlog": "^2.29.0",
|
|
176
|
-
"react": "19.
|
|
177
|
-
"react-dom": "19.
|
|
195
|
+
"react": "19.3.0",
|
|
196
|
+
"react-dom": "19.3.0",
|
|
178
197
|
"typebox": "1.3.34"
|
|
179
198
|
},
|
|
199
|
+
"peerDependenciesMeta": {
|
|
200
|
+
"drizzle-orm": {
|
|
201
|
+
"optional": true
|
|
202
|
+
}
|
|
203
|
+
},
|
|
180
204
|
"engines": {
|
|
181
205
|
"bun": ">=1.4.0"
|
|
182
206
|
}
|
package/src/adapter/README.md
CHANGED
|
@@ -33,6 +33,9 @@ and keeps background ISR work alive with `waitUntil`.
|
|
|
33
33
|
The Function bundle uses the same Elysia AOT capture path with the Bun target.
|
|
34
34
|
No custom Elysia runtime adapter is needed: Vercel invokes the application's
|
|
35
35
|
Web-standard `handle(Request)` API inside its Bun runtime.
|
|
36
|
+
For Furin Sync, the Vercel target streams browser cursor notifications through
|
|
37
|
+
Server-Sent Events at `/_furin/events`. Bun servers keep the WebSocket transport.
|
|
38
|
+
Both transports use the durable sync recovery endpoint after reconnects (`/_furin/sync/changes` by default, configurable with `sync.path`).
|
|
36
39
|
|
|
37
40
|
Vercel Prerender Function invocations bypass Furin's process-local SSG/ISR
|
|
38
41
|
cache. The CDN owns freshness and each regeneration returns newly rendered
|
package/src/adapter/bun.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { environmentGuardPlugin } from "../rsc/build/environment.ts";
|
|
|
17
17
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
18
18
|
import {
|
|
19
19
|
buildRuntimeAppsSequentially,
|
|
20
|
+
mixedRuntimePlugin,
|
|
20
21
|
pprRuntimePlugin,
|
|
21
22
|
type RuntimeTargetApp,
|
|
22
23
|
} from "./runtime-build.ts";
|
|
@@ -223,6 +224,7 @@ export async function buildBunTarget(
|
|
|
223
224
|
entry.plugin,
|
|
224
225
|
productionInstrumentationPlugin(),
|
|
225
226
|
pprRuntimePlugin(apps),
|
|
227
|
+
mixedRuntimePlugin(apps),
|
|
226
228
|
...(options.plugins ?? []),
|
|
227
229
|
createRoutesPlugin({ instances: apps, target: "server" }),
|
|
228
230
|
isomorphicTransformPlugin("server"),
|
|
@@ -257,6 +259,7 @@ export async function buildBunTarget(
|
|
|
257
259
|
entry.plugin,
|
|
258
260
|
productionInstrumentationPlugin(),
|
|
259
261
|
pprRuntimePlugin(apps),
|
|
262
|
+
mixedRuntimePlugin(apps),
|
|
260
263
|
...(options.plugins ?? []),
|
|
261
264
|
createRoutesPlugin({ instances: apps, target: "server" }),
|
|
262
265
|
isomorphicTransformPlugin("server"),
|
package/src/adapter/package.ts
CHANGED
|
@@ -13,9 +13,14 @@ import {
|
|
|
13
13
|
createRoutesPlugin,
|
|
14
14
|
routeSourcePaths,
|
|
15
15
|
} from "../plugin/routes.ts";
|
|
16
|
+
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
17
|
+
import { environmentGuardPlugin } from "../rsc/build/environment.ts";
|
|
16
18
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
19
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
18
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
setProductionPreloadManifest,
|
|
22
|
+
setProductionTemplateContent,
|
|
23
|
+
} from "../server/render/template.ts";
|
|
19
24
|
|
|
20
25
|
/**
|
|
21
26
|
* `--target package` — builds a furin app as a PUBLISHABLE Elysia plugin
|
|
@@ -53,7 +58,7 @@ export async function buildPackageTarget(
|
|
|
53
58
|
rmSync(targetDir, { force: true, recursive: true });
|
|
54
59
|
ensureDir(targetDir);
|
|
55
60
|
|
|
56
|
-
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
61
|
+
const { entryChunk, cssChunks, preloadManifest } = await buildClient(routes, {
|
|
57
62
|
basePath: prefix,
|
|
58
63
|
clientLogging: options.clientLogging ?? false,
|
|
59
64
|
metafilePath: options.analyze ? join(buildRoot, "analysis", "package-client.json") : undefined,
|
|
@@ -61,6 +66,7 @@ export async function buildPackageTarget(
|
|
|
61
66
|
outDir: targetDir,
|
|
62
67
|
pagesDir,
|
|
63
68
|
plugins: options.plugins,
|
|
69
|
+
preloadRouteChunks: options.preload?.routeChunks,
|
|
64
70
|
publicPath: `${prefix}/_client/`,
|
|
65
71
|
reactCompiler: options.reactCompiler,
|
|
66
72
|
rootLayout: root.path,
|
|
@@ -97,6 +103,7 @@ export async function buildPackageTarget(
|
|
|
97
103
|
// SSG snapshot renders through the build-time default state bucket. The
|
|
98
104
|
// mount prefix is passed explicitly — no instance scope exists at build time.
|
|
99
105
|
setProductionTemplateContent(indexHtml);
|
|
106
|
+
setProductionPreloadManifest(preloadManifest);
|
|
100
107
|
ssgRouteCache().clear();
|
|
101
108
|
const ssgCache = await buildSSGCacheSnapshot(routes, root, "http://localhost", prefix);
|
|
102
109
|
|
|
@@ -110,6 +117,8 @@ export async function buildPackageTarget(
|
|
|
110
117
|
const routeMetadata: Record<
|
|
111
118
|
string,
|
|
112
119
|
{
|
|
120
|
+
requestKeys?: string[];
|
|
121
|
+
requestKeysByLoader?: string[][];
|
|
113
122
|
segmentBoundaries: Array<{
|
|
114
123
|
depth: number;
|
|
115
124
|
path: string;
|
|
@@ -120,6 +129,8 @@ export async function buildPackageTarget(
|
|
|
120
129
|
> = {};
|
|
121
130
|
for (const route of routes) {
|
|
122
131
|
routeMetadata[toPosixPath(route.path)] = {
|
|
132
|
+
requestKeys: route.requestKeys,
|
|
133
|
+
requestKeysByLoader: route.requestKeysByLoader,
|
|
123
134
|
segmentBoundaries: route.segmentBoundaries.map((b) => ({
|
|
124
135
|
depth: b.depth,
|
|
125
136
|
errorPath: b.errorPath ? toPosixPath(b.errorPath) : undefined,
|
|
@@ -138,6 +149,7 @@ export async function buildPackageTarget(
|
|
|
138
149
|
modulePaths,
|
|
139
150
|
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
140
151
|
prefix,
|
|
152
|
+
preloadManifest,
|
|
141
153
|
rootConventions,
|
|
142
154
|
rootPath: root.path,
|
|
143
155
|
routeMetadata,
|
|
@@ -165,6 +177,8 @@ export async function buildPackageTarget(
|
|
|
165
177
|
register.plugin,
|
|
166
178
|
...(options.plugins ?? []),
|
|
167
179
|
createRoutesPlugin({ instances: [app], target: "server" }),
|
|
180
|
+
isomorphicTransformPlugin("server"),
|
|
181
|
+
environmentGuardPlugin("ssr"),
|
|
168
182
|
],
|
|
169
183
|
sourcemap: "none",
|
|
170
184
|
target: "bun",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { buildClient } from "../build/client.ts";
|
|
@@ -14,9 +14,13 @@ import type { BuildAppOptions } from "../build/types.ts";
|
|
|
14
14
|
import { composableRouteModuleSpecifier, routeSourcePaths } from "../plugin/routes.ts";
|
|
15
15
|
import { buildRscGraph } from "../rsc/build/index.ts";
|
|
16
16
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
|
-
import { hasRequestLoader } from "../server/render/loaders.ts";
|
|
17
|
+
import { hasMixedLoaderModes, hasRequestLoader } from "../server/render/loaders.ts";
|
|
18
18
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
setProductionPreloadManifest,
|
|
21
|
+
setProductionTemplateContent,
|
|
22
|
+
} from "../server/render/template.ts";
|
|
23
|
+
import { resolveDocumentMode } from "../server/router/patterns.ts";
|
|
20
24
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
21
25
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
22
26
|
|
|
@@ -35,18 +39,22 @@ const _pkgSrcDir = existsSync(join(_pkgRoot, "src", "furin.ts"))
|
|
|
35
39
|
// copy would point at files that don't exist and silently weaken the build ID.
|
|
36
40
|
const _ext = ".ts";
|
|
37
41
|
const PPR_ROUTE_IMPORT_RE = /ppr-route(?:\.ts)?$/;
|
|
42
|
+
const MIXED_CACHE_IMPORT_RE = /mixed-cache(?:\.ts)?$/;
|
|
38
43
|
const ANY_MODULE_RE = /.*/;
|
|
39
44
|
const REACT_SERVER_IMPORT_RE = /^react-dom\/server(?:\.edge)?$/;
|
|
40
45
|
const REACT_STATIC_IMPORT_RE = /^react-dom\/static\.edge$/;
|
|
46
|
+
const SCRIPT_FILE_RE = /\.[cm]?[jt]sx?$/;
|
|
41
47
|
const BUILD_ID_INPUT_PATHS = [
|
|
42
48
|
`${_pkgSrcDir}/build/compile-entry${_ext}`,
|
|
43
49
|
`${_pkgSrcDir}/build/entry-template${_ext}`,
|
|
50
|
+
`${_pkgSrcDir}/build/request-keys${_ext}`,
|
|
44
51
|
`${_pkgSrcDir}/plugin/routes${_ext}`,
|
|
45
52
|
`${_pkgSrcDir}/server/render/document.tsx`,
|
|
46
53
|
`${_pkgSrcDir}/server/render/element.tsx`,
|
|
47
54
|
`${_pkgSrcDir}/server/render/index${_ext}`,
|
|
48
55
|
`${_pkgSrcDir}/server/render/isr${_ext}`,
|
|
49
56
|
`${_pkgSrcDir}/server/render/loaders${_ext}`,
|
|
57
|
+
`${_pkgSrcDir}/server/render/mixed-cache${_ext}`,
|
|
50
58
|
`${_pkgSrcDir}/server/render/not-found${_ext}`,
|
|
51
59
|
`${_pkgSrcDir}/server/render/ppr-route${_ext}`,
|
|
52
60
|
`${_pkgSrcDir}/server/render/ppr-document${_ext}`,
|
|
@@ -71,7 +79,7 @@ function compareCodeUnits(a: string, b: string): number {
|
|
|
71
79
|
/**
|
|
72
80
|
* Deterministic build-ID input covering everything that can change rendered
|
|
73
81
|
* output: client chunks, route shape, route/root/error/not-found source
|
|
74
|
-
* contents and the framework's own render pipeline sources.
|
|
82
|
+
* contents, their application dependencies and the framework's own render pipeline sources.
|
|
75
83
|
*/
|
|
76
84
|
export async function createBuildFingerprint(
|
|
77
85
|
entryChunk: string,
|
|
@@ -106,6 +114,47 @@ export async function createBuildFingerprint(
|
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
}
|
|
117
|
+
const sources = new Map<string, string>();
|
|
118
|
+
const visit = async (inputPath: string): Promise<void> => {
|
|
119
|
+
const path = existsSync(inputPath) ? realpathSync(inputPath) : inputPath;
|
|
120
|
+
fingerprintPaths.delete(inputPath);
|
|
121
|
+
fingerprintPaths.add(path);
|
|
122
|
+
if (sources.has(path)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
sources.set(path, "");
|
|
126
|
+
const content = existsSync(path) ? await Bun.file(path).text() : "";
|
|
127
|
+
sources.set(path, content);
|
|
128
|
+
if (!SCRIPT_FILE_RE.test(path)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const transpiler = new Bun.Transpiler({ loader: path.endsWith("x") ? "tsx" : "ts" });
|
|
132
|
+
await Promise.all(
|
|
133
|
+
transpiler.scanImports(content).flatMap(({ path: specifier }) => {
|
|
134
|
+
if (
|
|
135
|
+
specifier === "furin" ||
|
|
136
|
+
specifier.startsWith("furin/") ||
|
|
137
|
+
specifier === "@teyik0/furin" ||
|
|
138
|
+
specifier.startsWith("@teyik0/furin/")
|
|
139
|
+
) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
let dependency: string;
|
|
143
|
+
try {
|
|
144
|
+
dependency = Bun.resolveSync(specifier, dirname(path));
|
|
145
|
+
} catch {
|
|
146
|
+
// Build plugins can supply imports that have no filesystem path.
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
if (!isAbsolute(dependency) || toPosixPath(dependency).includes("/node_modules/")) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
fingerprintPaths.add(dependency);
|
|
153
|
+
return [visit(dependency)];
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
await Promise.all([...fingerprintPaths].map(visit));
|
|
109
158
|
for (const path of BUILD_ID_INPUT_PATHS) {
|
|
110
159
|
if (!existsSync(path)) {
|
|
111
160
|
console.warn(
|
|
@@ -116,12 +165,14 @@ export async function createBuildFingerprint(
|
|
|
116
165
|
fingerprintPaths.add(path);
|
|
117
166
|
}
|
|
118
167
|
|
|
119
|
-
const fileParts =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
168
|
+
const fileParts = (
|
|
169
|
+
await Promise.all(
|
|
170
|
+
[...fingerprintPaths].map(async (path) => {
|
|
171
|
+
const content = sources.get(path) ?? (existsSync(path) ? await Bun.file(path).text() : "");
|
|
172
|
+
return `${stableFingerprintPath(path, projectRoot)}:${content}`;
|
|
173
|
+
})
|
|
174
|
+
)
|
|
175
|
+
).sort(compareCodeUnits);
|
|
125
176
|
|
|
126
177
|
const routeParts = routes
|
|
127
178
|
.map((route) =>
|
|
@@ -129,6 +180,8 @@ export async function createBuildFingerprint(
|
|
|
129
180
|
mode: route.mode,
|
|
130
181
|
path: stableFingerprintPath(route.path, projectRoot),
|
|
131
182
|
pattern: route.pattern,
|
|
183
|
+
requestKeys: route.requestKeys?.toSorted(),
|
|
184
|
+
requestKeysByLoader: route.requestKeysByLoader?.map((keys) => keys.toSorted()),
|
|
132
185
|
})
|
|
133
186
|
)
|
|
134
187
|
.sort(compareCodeUnits);
|
|
@@ -137,7 +190,8 @@ export async function createBuildFingerprint(
|
|
|
137
190
|
}
|
|
138
191
|
|
|
139
192
|
function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
140
|
-
const
|
|
193
|
+
const absolutePath = existsSync(path) ? realpathSync(path) : path;
|
|
194
|
+
const projectPath = relative(realpathSync(projectRoot), absolutePath);
|
|
141
195
|
if (
|
|
142
196
|
!isAbsolute(projectPath) &&
|
|
143
197
|
projectPath !== ".." &&
|
|
@@ -146,7 +200,7 @@ function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
|
146
200
|
) {
|
|
147
201
|
return `app/${toPosixPath(projectPath)}`;
|
|
148
202
|
}
|
|
149
|
-
const frameworkPath = relative(_pkgRoot,
|
|
203
|
+
const frameworkPath = relative(_pkgRoot, absolutePath);
|
|
150
204
|
if (
|
|
151
205
|
!isAbsolute(frameworkPath) &&
|
|
152
206
|
frameworkPath !== ".." &&
|
|
@@ -170,6 +224,8 @@ function buildCompileMetadata(root: RootLayout, routes: ResolvedRoute[]) {
|
|
|
170
224
|
const routeMetadata: NonNullable<EntryAppContext["routeMetadata"]> = {};
|
|
171
225
|
for (const route of routes) {
|
|
172
226
|
routeMetadata[toPosixPath(route.path)] = {
|
|
227
|
+
requestKeys: route.requestKeys,
|
|
228
|
+
requestKeysByLoader: route.requestKeysByLoader,
|
|
173
229
|
segmentBoundaries: route.segmentBoundaries.map((boundary) => ({
|
|
174
230
|
depth: boundary.depth,
|
|
175
231
|
errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
|
|
@@ -195,7 +251,7 @@ export function pprRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
|
195
251
|
const enabled = apps.some((app) =>
|
|
196
252
|
app.routes.some(
|
|
197
253
|
(route) =>
|
|
198
|
-
route
|
|
254
|
+
resolveDocumentMode(route) !== "ssr" &&
|
|
199
255
|
(app.root.route.requestLoader !== undefined || hasRequestLoader(route))
|
|
200
256
|
)
|
|
201
257
|
);
|
|
@@ -236,6 +292,32 @@ export const runPprPublicLoaders = renderPprRoute;`,
|
|
|
236
292
|
};
|
|
237
293
|
}
|
|
238
294
|
|
|
295
|
+
/** Keep mixed-mode cache code out of builds whose route graph cannot use it. */
|
|
296
|
+
export function mixedRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
297
|
+
const enabled = apps.some((app) => app.routes.some(hasMixedLoaderModes));
|
|
298
|
+
const mixedPath = resolve(_pkgSrcDir, "server/render/mixed-cache.ts");
|
|
299
|
+
return {
|
|
300
|
+
name: "furin-mixed-runtime",
|
|
301
|
+
setup(build) {
|
|
302
|
+
if (enabled) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
build.onResolve({ filter: MIXED_CACHE_IMPORT_RE }, ({ path, importer }) => {
|
|
306
|
+
const absolute = resolve(dirname(importer.split("?")[0] as string), path);
|
|
307
|
+
if (absolute !== mixedPath && `${absolute}.ts` !== mixedPath) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
return { namespace: "furin-no-mixed", path: "mixed" };
|
|
311
|
+
});
|
|
312
|
+
build.onLoad({ filter: ANY_MODULE_RE, namespace: "furin-no-mixed" }, () => ({
|
|
313
|
+
contents: `export function clearMixedPublicCache() {}
|
|
314
|
+
export function cacheMixedPublicLoader() { throw new Error("[furin] Mixed route missing from the build manifest."); }`,
|
|
315
|
+
loader: "js",
|
|
316
|
+
}));
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
239
321
|
function isFrameworkRuntimeImporter(importer: string): boolean {
|
|
240
322
|
if (importer === "") {
|
|
241
323
|
return false;
|
|
@@ -270,7 +352,7 @@ export async function buildRuntimeApp(
|
|
|
270
352
|
const clientDirName = clientDirNameForPrefix(prefix);
|
|
271
353
|
const label = prefix === "" ? "root app" : `app "${prefix}"`;
|
|
272
354
|
|
|
273
|
-
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
355
|
+
const { entryChunk, cssChunks, preloadManifest } = await buildClient(routes, {
|
|
274
356
|
basePath: prefix,
|
|
275
357
|
clientDirName,
|
|
276
358
|
clientLogging: options.clientLogging ?? false,
|
|
@@ -281,6 +363,7 @@ export async function buildRuntimeApp(
|
|
|
281
363
|
outDir: targetDir,
|
|
282
364
|
pagesDir: app.pagesDir,
|
|
283
365
|
plugins: options.plugins,
|
|
366
|
+
preloadRouteChunks: options.preload?.routeChunks,
|
|
284
367
|
publicPath: `${prefix}/_client/`,
|
|
285
368
|
reactCompiler: options.reactCompiler,
|
|
286
369
|
rootLayout: root.path,
|
|
@@ -302,6 +385,7 @@ export async function buildRuntimeApp(
|
|
|
302
385
|
writeFileSync(join(clientDir, "index.html"), indexHtml);
|
|
303
386
|
|
|
304
387
|
setProductionTemplateContent(indexHtml);
|
|
388
|
+
setProductionPreloadManifest(preloadManifest);
|
|
305
389
|
ssgRouteCache().clear();
|
|
306
390
|
let ssgCache: SSGCacheSnapshot | undefined;
|
|
307
391
|
let prerenders: RoutePrerender[] = [];
|
|
@@ -327,6 +411,7 @@ export async function buildRuntimeApp(
|
|
|
327
411
|
modulePaths,
|
|
328
412
|
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
329
413
|
prefix,
|
|
414
|
+
preloadManifest,
|
|
330
415
|
rootConventions,
|
|
331
416
|
rootPath: root.path,
|
|
332
417
|
routeMetadata,
|