@teyik0/furin 0.4.0-alpha.1 → 0.4.0-alpha.2
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/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +4 -2
- package/dist/build/entry-template.ts +31 -8
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8596 -6375
- package/dist/build/ssg-cache.d.ts +13 -0
- package/dist/build/types.d.ts +25 -2
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +9099 -6771
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +1 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +9 -8
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +1 -0
- package/dist/client/hmr.d.ts +4 -2
- package/dist/client/link.js +251 -82
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +8 -10
- package/dist/client.js +37 -23
- package/dist/config.d.ts +17 -0
- package/dist/config.js +9 -1
- package/dist/define-route.d.ts +11 -8
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +1 -1
- package/dist/furin.js +12991 -9491
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +4 -3
- package/dist/rsc/build/index.d.ts +5 -1
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +5 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +1 -1
- package/dist/server/devtools/instrumentation.production.d.ts +1 -1
- package/dist/server/devtools/plugin.d.ts +1 -1
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +14 -2
- package/dist/server/internal.js +436 -1
- package/dist/server/render/element.d.ts +1 -0
- package/dist/server/render/index.d.ts +1 -1
- package/dist/server/render/index.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +3 -1
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +2 -0
- package/dist/server/render/ssr.d.ts +17 -6
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +1 -0
- package/dist/server/router/plugin.d.ts +3 -1
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +491 -516
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/stream.d.ts +4 -13
- package/dist/shared/await.d.ts +3 -3
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/prefix.d.ts +2 -0
- package/package.json +16 -7
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +45 -268
- package/src/adapter/package.ts +15 -9
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +79 -2
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +38 -13
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +31 -8
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +19 -5
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +97 -11
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/index.ts +55 -3
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +10 -1
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +7 -17
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +4 -7
- package/src/client/hmr.ts +26 -3
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/provider.tsx +165 -63
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +6 -6
- package/src/config.ts +25 -0
- package/src/define-route.ts +20 -7
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +157 -77
- package/src/plugin/routes.ts +206 -36
- package/src/plugin/transform-client.ts +685 -3
- package/src/react-dom-edge.d.ts +6 -0
- package/src/rsc/build/index.ts +15 -3
- package/src/server/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +24 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +92 -53
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +1 -1
- package/src/server/devtools/instrumentation.ts +12 -6
- package/src/server/devtools/plugin.ts +7 -150
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +39 -2
- package/src/server/render/assemble.ts +4 -4
- package/src/server/render/document.tsx +13 -4
- package/src/server/render/element.tsx +18 -14
- package/src/server/render/index.ts +1 -1
- package/src/server/render/isr.ts +44 -19
- package/src/server/render/loaders.ts +13 -3
- package/src/server/render/not-found.ts +28 -4
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +152 -31
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +38 -20
- package/src/server/render/ssr.ts +211 -83
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +7 -39
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +106 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +124 -35
- package/src/server/router/source-version.ts +3 -10
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +3 -3
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SQL } from "bun";
|
|
2
|
-
import type { BeginMutationInput, BeginMutationResult, ChangePage, CompleteMutationInput, CompleteMutationResult, MutationLease, ReadChangesInput, SyncAdapter } from "../adapter.ts";
|
|
2
|
+
import type { BeginMutationInput, BeginMutationResult, ChangePage, CompleteMutationInput, CompleteMutationResult, MutationLease, ReadChangesInput, SyncAdapter, SyncNotifier, SyncSubscription } from "../adapter.ts";
|
|
3
3
|
export interface PostgresSyncAdapterOptions {
|
|
4
4
|
namespace: string;
|
|
5
5
|
sql: SQL;
|
|
6
6
|
}
|
|
7
7
|
export declare class PostgresSyncAdapter implements SyncAdapter {
|
|
8
|
+
readonly notificationChannel: string;
|
|
8
9
|
readonly scope: "distributed";
|
|
9
10
|
private readonly namespace;
|
|
10
11
|
private readonly sql;
|
|
@@ -17,3 +18,13 @@ export declare class PostgresSyncAdapter implements SyncAdapter {
|
|
|
17
18
|
readChanges(input: ReadChangesInput): Promise<ChangePage>;
|
|
18
19
|
}
|
|
19
20
|
export declare function postgresSyncAdapter(options: PostgresSyncAdapterOptions): PostgresSyncAdapter;
|
|
21
|
+
export declare class PostgresSyncNotifier implements SyncNotifier {
|
|
22
|
+
readonly notificationChannel: string;
|
|
23
|
+
readonly recovery: "self";
|
|
24
|
+
private readonly namespace;
|
|
25
|
+
private readonly sql;
|
|
26
|
+
constructor(options: PostgresSyncAdapterOptions);
|
|
27
|
+
publish(cursor: string): Promise<void>;
|
|
28
|
+
subscribe(listener: (cursor: string) => void): Promise<SyncSubscription>;
|
|
29
|
+
}
|
|
30
|
+
export declare function postgresSyncNotifier(options: PostgresSyncAdapterOptions): PostgresSyncNotifier;
|
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
var CHANGE_RETENTION = 1000;
|
|
4
4
|
var LEASE_MS = 30000;
|
|
5
5
|
var MUTATION_TTL_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
var RECOVERY_RETRY_INITIAL_MS = 250;
|
|
7
|
+
var RECOVERY_RETRY_MAX_MS = 32000;
|
|
6
8
|
var UNSIGNED_INTEGER_PATTERN = /^\d+$/;
|
|
9
|
+
function notificationChannel(namespace) {
|
|
10
|
+
const digest = new Bun.CryptoHasher("sha256").update(namespace).digest("hex");
|
|
11
|
+
return `furin_sync_${digest.slice(0, 52)}`;
|
|
12
|
+
}
|
|
13
|
+
async function readCurrentCursor(sql, namespace) {
|
|
14
|
+
const rows = await sql`
|
|
15
|
+
SELECT current_cursor FROM furin_sync.streams WHERE namespace = ${namespace}
|
|
16
|
+
`;
|
|
17
|
+
return String(rows[0]?.current_cursor ?? 0);
|
|
18
|
+
}
|
|
7
19
|
function mutationKey(input) {
|
|
8
20
|
return new Bun.CryptoHasher("sha256").update(`${input.principal.length}:${input.principal}${input.key}`).digest("hex");
|
|
9
21
|
}
|
|
@@ -19,6 +31,7 @@ function storedResponse(row) {
|
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
class PostgresSyncAdapter {
|
|
34
|
+
notificationChannel;
|
|
22
35
|
scope = "distributed";
|
|
23
36
|
namespace;
|
|
24
37
|
sql;
|
|
@@ -26,6 +39,7 @@ class PostgresSyncAdapter {
|
|
|
26
39
|
if (options.namespace.length === 0) {
|
|
27
40
|
throw new Error("[furin-sync-postgres] namespace must not be empty.");
|
|
28
41
|
}
|
|
42
|
+
this.notificationChannel = notificationChannel(options.namespace);
|
|
29
43
|
this.namespace = options.namespace;
|
|
30
44
|
this.sql = options.sql;
|
|
31
45
|
}
|
|
@@ -172,6 +186,9 @@ class PostgresSyncAdapter {
|
|
|
172
186
|
AND mutation_key = ${key}
|
|
173
187
|
AND mutation_id = ${input.lease.id}
|
|
174
188
|
`;
|
|
189
|
+
if (cursor !== undefined) {
|
|
190
|
+
await tx.notify(this.notificationChannel, cursor);
|
|
191
|
+
}
|
|
175
192
|
return { cursor, kind: "committed" };
|
|
176
193
|
});
|
|
177
194
|
}
|
|
@@ -184,11 +201,8 @@ class PostgresSyncAdapter {
|
|
|
184
201
|
AND state = 'in-progress'
|
|
185
202
|
`;
|
|
186
203
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
SELECT current_cursor FROM furin_sync.streams WHERE namespace = ${this.namespace}
|
|
190
|
-
`;
|
|
191
|
-
return String(rows[0]?.current_cursor ?? 0);
|
|
204
|
+
currentCursor() {
|
|
205
|
+
return readCurrentCursor(this.sql, this.namespace);
|
|
192
206
|
}
|
|
193
207
|
async readChanges(input) {
|
|
194
208
|
const cursorRows = await this.sql`
|
|
@@ -246,7 +260,88 @@ class PostgresSyncAdapter {
|
|
|
246
260
|
function postgresSyncAdapter(options) {
|
|
247
261
|
return new PostgresSyncAdapter(options);
|
|
248
262
|
}
|
|
263
|
+
|
|
264
|
+
class PostgresSyncNotifier {
|
|
265
|
+
notificationChannel;
|
|
266
|
+
recovery = "self";
|
|
267
|
+
namespace;
|
|
268
|
+
sql;
|
|
269
|
+
constructor(options) {
|
|
270
|
+
if (options.namespace.length === 0) {
|
|
271
|
+
throw new Error("[furin-sync-postgres] namespace must not be empty.");
|
|
272
|
+
}
|
|
273
|
+
this.notificationChannel = notificationChannel(options.namespace);
|
|
274
|
+
this.namespace = options.namespace;
|
|
275
|
+
this.sql = options.sql;
|
|
276
|
+
}
|
|
277
|
+
publish(cursor) {
|
|
278
|
+
return this.sql.notify(this.notificationChannel, cursor);
|
|
279
|
+
}
|
|
280
|
+
async subscribe(listener) {
|
|
281
|
+
let active = true;
|
|
282
|
+
let currentCursor;
|
|
283
|
+
let recovery;
|
|
284
|
+
let retry;
|
|
285
|
+
let retryDelayMs = RECOVERY_RETRY_INITIAL_MS;
|
|
286
|
+
const emit = (cursor) => {
|
|
287
|
+
if (!(active && UNSIGNED_INTEGER_PATTERN.test(cursor))) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const nextCursor = BigInt(cursor);
|
|
291
|
+
if (currentCursor !== undefined && nextCursor <= currentCursor) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
currentCursor = nextCursor;
|
|
295
|
+
try {
|
|
296
|
+
listener(cursor);
|
|
297
|
+
} catch {}
|
|
298
|
+
};
|
|
299
|
+
const scheduleRecovery = () => {
|
|
300
|
+
if (!active || retry) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const delayMs = retryDelayMs;
|
|
304
|
+
retryDelayMs = Math.min(retryDelayMs * 2, RECOVERY_RETRY_MAX_MS);
|
|
305
|
+
retry = setTimeout(() => {
|
|
306
|
+
retry = undefined;
|
|
307
|
+
recover();
|
|
308
|
+
}, delayMs);
|
|
309
|
+
retry.unref?.();
|
|
310
|
+
};
|
|
311
|
+
const recover = () => {
|
|
312
|
+
if (!active || recovery) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (retry) {
|
|
316
|
+
clearTimeout(retry);
|
|
317
|
+
retry = undefined;
|
|
318
|
+
}
|
|
319
|
+
recovery = readCurrentCursor(this.sql, this.namespace).then((cursor) => {
|
|
320
|
+
retryDelayMs = RECOVERY_RETRY_INITIAL_MS;
|
|
321
|
+
emit(cursor);
|
|
322
|
+
}).catch(scheduleRecovery).finally(() => {
|
|
323
|
+
recovery = undefined;
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
const subscription = await this.sql.listen(this.notificationChannel, emit, recover);
|
|
327
|
+
return {
|
|
328
|
+
unsubscribe: () => {
|
|
329
|
+
active = false;
|
|
330
|
+
if (retry) {
|
|
331
|
+
clearTimeout(retry);
|
|
332
|
+
retry = undefined;
|
|
333
|
+
}
|
|
334
|
+
return subscription.unlisten();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function postgresSyncNotifier(options) {
|
|
340
|
+
return new PostgresSyncNotifier(options);
|
|
341
|
+
}
|
|
249
342
|
export {
|
|
250
343
|
PostgresSyncAdapter,
|
|
251
|
-
|
|
344
|
+
PostgresSyncNotifier,
|
|
345
|
+
postgresSyncAdapter,
|
|
346
|
+
postgresSyncNotifier
|
|
252
347
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
2
|
import type { FurinSyncOptions } from "./config.ts";
|
|
3
3
|
export type { ChangePage as SyncChangePage, SyncChange } from "./adapter.ts";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function subscribeSyncCursor(options: FurinSyncOptions, listener: (cursor: string) => void): Promise<{
|
|
5
|
+
unsubscribe: () => void;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function createSyncChangesPlugin(options: FurinSyncOptions): Elysia<"", {
|
|
5
8
|
decorator: {};
|
|
6
9
|
store: {};
|
|
7
10
|
derive: {};
|
|
@@ -38,18 +41,6 @@ export declare function createSyncStreamPlugin(options: FurinSyncOptions): Elysi
|
|
|
38
41
|
};
|
|
39
42
|
};
|
|
40
43
|
};
|
|
41
|
-
} & {
|
|
42
|
-
[x: string]: {
|
|
43
|
-
get: {
|
|
44
|
-
body: unknown;
|
|
45
|
-
params: {};
|
|
46
|
-
query: unknown;
|
|
47
|
-
headers: unknown;
|
|
48
|
-
response: {
|
|
49
|
-
200: Response;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
44
|
}, {
|
|
54
45
|
derive: {};
|
|
55
46
|
resolve: {};
|
package/dist/shared/await.d.ts
CHANGED
|
@@ -51,11 +51,11 @@ export interface AwaitProps<T> {
|
|
|
51
51
|
* ```tsx
|
|
52
52
|
* export const route = defineRoute()
|
|
53
53
|
* .loader(() => defer({ board: "x", stats: fetchStats() }))
|
|
54
|
-
* .page(({
|
|
54
|
+
* .page(({ board, stats }) => (
|
|
55
55
|
* <div>
|
|
56
|
-
* <h1>{
|
|
56
|
+
* <h1>{board}</h1>
|
|
57
57
|
* <Suspense fallback={<Spinner />}>
|
|
58
|
-
* <Await resolve={
|
|
58
|
+
* <Await resolve={stats}>
|
|
59
59
|
* {(s) => <StatsBar stats={s} />}
|
|
60
60
|
* </Await>
|
|
61
61
|
* </Suspense>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DevtoolsServerEvent } from "../devtools/protocol.ts";
|
|
2
|
+
import type { DevDiagnosticEvent } from "./dev-diagnostics.ts";
|
|
3
|
+
export declare const BROWSER_EVENT_PROTOCOL_VERSION: 1;
|
|
4
|
+
export type BrowserEventEnvelope = {
|
|
5
|
+
channel: "diagnostic";
|
|
6
|
+
data: DevDiagnosticEvent;
|
|
7
|
+
version: typeof BROWSER_EVENT_PROTOCOL_VERSION;
|
|
8
|
+
} | {
|
|
9
|
+
channel: "devtools";
|
|
10
|
+
data: DevtoolsServerEvent;
|
|
11
|
+
version: typeof BROWSER_EVENT_PROTOCOL_VERSION;
|
|
12
|
+
} | {
|
|
13
|
+
channel: "sync";
|
|
14
|
+
data: {
|
|
15
|
+
cursor: string;
|
|
16
|
+
};
|
|
17
|
+
version: typeof BROWSER_EVENT_PROTOCOL_VERSION;
|
|
18
|
+
};
|
|
19
|
+
export type BrowserEventChannel = BrowserEventEnvelope["channel"];
|
|
20
|
+
export type BrowserEventFor<TChannel extends BrowserEventChannel> = Extract<BrowserEventEnvelope, {
|
|
21
|
+
channel: TChannel;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type JsonScalar = boolean | null | number | string;
|
|
2
|
+
type JsonValue = JsonObject | JsonScalar | JsonValue[];
|
|
3
|
+
interface JsonObject {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
}
|
|
6
|
+
export declare function serializeCompactJsonLine(value: unknown): string | undefined;
|
|
7
|
+
export declare function parseCompactJsonLine(value: unknown): JsonObject | undefined;
|
|
8
|
+
export {};
|
|
@@ -16,12 +16,13 @@ export interface DeferredNdjsonResult {
|
|
|
16
16
|
/**
|
|
17
17
|
* Parses an NDJSON stream produced by `/_furin/data`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Single-line, all-resolved payloads use either a compact JSON envelope for
|
|
20
|
+
* ordinary JSON data or CrossJSON when richer JavaScript semantics must be
|
|
21
|
+
* preserved. Deferred and RSC payloads use Route Frames.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
* Promises (seroval type 12) land in `deferredPromises`; everything else
|
|
24
|
-
*
|
|
23
|
+
* CrossJSON nodes are deserialised with `fromCrossJSON`. Values that are
|
|
24
|
+
* Promises (seroval type 12) land in `deferredPromises`; everything else lands
|
|
25
|
+
* in `syncData`.
|
|
25
26
|
*
|
|
26
27
|
* @param stream - A `ReadableStream<Uint8Array>` from `fetch().body`.
|
|
27
28
|
* @param signal - AbortSignal that, when aborted, cancels the reader and
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const DEV_DIAGNOSTIC_PROTOCOL_VERSION = 1;
|
|
2
|
+
export type DevDiagnosticPhase = "client-render" | "hydrate" | "import" | "loader" | "render" | "transform";
|
|
3
|
+
export interface DevSourceLocation {
|
|
4
|
+
column: number;
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DevStackFrame {
|
|
9
|
+
functionName: string | undefined;
|
|
10
|
+
generated: DevSourceLocation | undefined;
|
|
11
|
+
internal: boolean;
|
|
12
|
+
original: DevSourceLocation | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface DevDiagnostic {
|
|
15
|
+
cause: string | undefined;
|
|
16
|
+
frames: readonly DevStackFrame[];
|
|
17
|
+
importChain: readonly string[];
|
|
18
|
+
location: DevSourceLocation | undefined;
|
|
19
|
+
message: string;
|
|
20
|
+
phase: DevDiagnosticPhase;
|
|
21
|
+
route: string;
|
|
22
|
+
stack: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
interface DevEventBase {
|
|
25
|
+
id: number;
|
|
26
|
+
revision: number;
|
|
27
|
+
serverId: string;
|
|
28
|
+
version: typeof DEV_DIAGNOSTIC_PROTOCOL_VERSION;
|
|
29
|
+
}
|
|
30
|
+
export type DevDiagnosticEvent = (DevEventBase & {
|
|
31
|
+
diagnostic: DevDiagnostic;
|
|
32
|
+
type: "error";
|
|
33
|
+
}) | (DevEventBase & {
|
|
34
|
+
type: "ready";
|
|
35
|
+
});
|
|
36
|
+
export {};
|
package/dist/shared/prefix.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* historical `client/`, prefixed instances get `client-<slug>/` next to it.
|
|
4
4
|
*/
|
|
5
5
|
export declare function clientDirNameForPrefix(prefix: string): string;
|
|
6
|
+
/** Canonical deployed path, shared by routing, PPR state and cache invalidation. */
|
|
7
|
+
export declare function physicalPath(prefix: string, path: string): string;
|
|
6
8
|
/** Filesystem-safe slug for a mount prefix (`/admin/v2` → `admin-v2`). */
|
|
7
9
|
export declare function prefixSlug(prefix: string): string;
|
|
8
10
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.2",
|
|
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",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"bun": "./src/client.ts",
|
|
37
37
|
"import": "./dist/client.js"
|
|
38
38
|
},
|
|
39
|
+
"./cache": {
|
|
40
|
+
"types": "./dist/cache.d.ts",
|
|
41
|
+
"bun": "./src/cache.ts",
|
|
42
|
+
"import": "./dist/cache.js"
|
|
43
|
+
},
|
|
39
44
|
"./routes": {
|
|
40
45
|
"types": "./dist/routes.d.ts",
|
|
41
46
|
"bun": "./src/routes.ts",
|
|
@@ -132,19 +137,23 @@
|
|
|
132
137
|
"benchmark:rsc": "bun scripts/benchmark-rsc-transport.ts",
|
|
133
138
|
"build": "bun run build.ts",
|
|
134
139
|
"fix": "ultracite fix",
|
|
135
|
-
"test": "bun test --parallel --isolate --bail",
|
|
136
|
-
"test:dev": "bun test --changed --parallel --isolate --bail",
|
|
140
|
+
"test": "bun test --parallel --isolate --max-concurrency 8 --bail",
|
|
141
|
+
"test:dev": "bun test --changed --parallel --isolate --max-concurrency 8 --bail",
|
|
142
|
+
"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",
|
|
143
|
+
"test:webview": "FURIN_WEBVIEW_TESTS=1 bun test tests/browser/hmr-conformance.webview.test.ts --timeout 60000",
|
|
137
144
|
"tscheck": "tsc --noEmit"
|
|
138
145
|
},
|
|
139
146
|
"dependencies": {
|
|
140
147
|
"@elysiajs/static": "^1.4.10",
|
|
148
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
141
149
|
"@sinclair/typebox": "0.34.52",
|
|
142
|
-
"@
|
|
150
|
+
"@vercel/functions": "^3.9.7",
|
|
151
|
+
"@yuku-toolchain/types": "0.9.5",
|
|
143
152
|
"magic-string": "^1.2.3",
|
|
144
153
|
"react-server-dom-webpack": "19.2.8",
|
|
145
|
-
"seroval": "^1.6.
|
|
146
|
-
"yuku-ast": "0.9.
|
|
147
|
-
"yuku-parser": "0.9.
|
|
154
|
+
"seroval": "^1.6.7",
|
|
155
|
+
"yuku-ast": "0.9.5",
|
|
156
|
+
"yuku-parser": "0.9.5"
|
|
148
157
|
},
|
|
149
158
|
"devDependencies": {
|
|
150
159
|
"@types/react": "^19.2.18",
|
package/src/adapter/README.md
CHANGED
|
@@ -11,3 +11,48 @@ All should be portable.
|
|
|
11
11
|
## Cloudflare adapter
|
|
12
12
|
|
|
13
13
|
## Vercel adapter
|
|
14
|
+
|
|
15
|
+
The Vercel target emits Build Output API v3 directly to `.vercel/output`:
|
|
16
|
+
|
|
17
|
+
- content-hashed browser assets and `public/` files under `static/`;
|
|
18
|
+
- one bundled `bun1.4.x` Web Handler under `functions/__server.func`;
|
|
19
|
+
- SSG Prerender Functions with no timed expiration and build-time fallbacks
|
|
20
|
+
for known URLs whose route tree has no query-dependent input;
|
|
21
|
+
- ISR Prerender Functions using each route's `revalidate` duration and
|
|
22
|
+
build-time fallbacks for fixed URLs or `staticParams()` values when the route
|
|
23
|
+
tree has no query-dependent input;
|
|
24
|
+
- a filesystem-first route table with a server fallback for SSR, APIs, and
|
|
25
|
+
`/_furin/data`.
|
|
26
|
+
|
|
27
|
+
The generated handler connects Furin cache invalidation to Vercel cache tags
|
|
28
|
+
and keeps background ISR work alive with `waitUntil`.
|
|
29
|
+
|
|
30
|
+
Vercel Prerender Function invocations bypass Furin's process-local SSG/ISR
|
|
31
|
+
cache. The CDN owns freshness and each regeneration returns newly rendered
|
|
32
|
+
HTML; the in-memory cache remains exclusive to development and Bun targets.
|
|
33
|
+
|
|
34
|
+
The generated handler also installs Vercel Runtime Cache as the provider behind
|
|
35
|
+
`@teyik0/furin/cache`. Application code keeps one portable cache API while
|
|
36
|
+
development and Bun targets fall back to the in-memory provider.
|
|
37
|
+
|
|
38
|
+
Application `@elysiajs/static` mounts are rejected during Vercel builds: their
|
|
39
|
+
runtime filesystem mappings are not deployable CDN mappings. Place static files
|
|
40
|
+
under `public/` instead. PPR pages produce a cached public HTML shell, postponed
|
|
41
|
+
React state and public loader snapshot atomically. Vercel's native `chain`
|
|
42
|
+
continuation runs private request loaders and resumes React without caching the
|
|
43
|
+
personalized output. Build-time shells are generated by the production bundle
|
|
44
|
+
itself, ensuring the minified component tree remains compatible with its state.
|
|
45
|
+
|
|
46
|
+
Successful `/_furin/data` responses for SSG/ISR routes share the document's
|
|
47
|
+
cache tag and revalidation window. SSR, request-loader, deferred, and failed
|
|
48
|
+
navigation responses remain `private, no-store`.
|
|
49
|
+
|
|
50
|
+
JSON-only navigation data uses a compact JSON envelope. CrossJSON and Route
|
|
51
|
+
Frames remain the lossless transports for rich values, shared references,
|
|
52
|
+
deferred data, and RSC payloads.
|
|
53
|
+
|
|
54
|
+
The Vercel Function starts through a lightweight `index.js` bootstrap. Its
|
|
55
|
+
first request logs a `vercel_cold_start` event and every dynamic response
|
|
56
|
+
exposes `furin_module_init`, `furin_server_init`, `furin_handler_wait`, and
|
|
57
|
+
`furin_handler` through `Server-Timing`. `--analyze` writes both Vercel client
|
|
58
|
+
and server metafiles under `.furin/build/analysis`.
|