@teyik0/furin 0.8.0-alpha.0 → 0.9.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/adapter/bun/app.d.ts +1 -0
- package/dist/adapter/bun.d.ts +3 -1
- package/dist/adapter/runtime-build.d.ts +8 -5
- package/dist/adapter/vercel.js +8 -8
- package/dist/build/client.d.ts +2 -2
- package/dist/build/discover-mounts-process.d.ts +1 -1
- package/dist/build/discover-pages-process.d.ts +1 -0
- package/dist/build/discover-pages.d.ts +11 -0
- package/dist/build/discovery-module.d.ts +3 -0
- package/dist/build/discovery-plugins.d.ts +34 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.ts +6 -1
- package/dist/build/hydrate.d.ts +3 -2
- package/dist/build/index.js +7688 -8458
- package/dist/build/preload-manifest.d.ts +2 -2
- package/dist/build/route-metadata.d.ts +31 -0
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/shared.d.ts +2 -2
- package/dist/build/types.d.ts +11 -0
- package/dist/cli/dev-worker.d.ts +1 -0
- package/dist/cli/dev-worker.ts +123 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/index.js +7811 -8477
- package/dist/client/browser-events-runtime.d.ts +2 -2
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/chunks/{client-brdfd773.js → client-rjhxgt64.js} +187 -4
- package/dist/client/dev-error-overlay.ts +18 -1
- package/dist/client/link.js +110 -156
- package/dist/client/query-store.d.ts +5 -0
- package/dist/client/router/navigation-controller.d.ts +2 -0
- package/dist/client/router/use-fetch-interception.d.ts +1 -1
- package/dist/client/router/use-sync-stream.d.ts +1 -1
- package/dist/client/{router/sync-catch-up.d.ts → sync-catch-up.d.ts} +5 -3
- package/dist/client/sync-client.d.ts +74 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +533 -145
- package/dist/config.d.ts +6 -1
- package/dist/config.js +3 -1
- package/dist/define-route.d.ts +3 -3
- package/dist/furin.d.ts +2 -1
- package/dist/furin.js +1119 -346
- package/dist/plugin/index.js +5 -5
- package/dist/plugin/route-registry.d.ts +22 -2
- package/dist/rsc/build/index.d.ts +4 -3
- package/dist/server/dev/server-only-module.d.ts +5 -0
- package/dist/server/internal.js +201 -91
- package/dist/server/logging/ingest-plugin.d.ts +1 -2
- package/dist/server/production-server.js +36 -33
- package/dist/server/server-entry.d.ts +5 -0
- package/dist/server/server-entry.js +36 -0
- package/dist/server/static-export.js +201 -91
- package/dist/server/sync/adapter.d.ts +4 -3
- package/dist/server/sync/config.d.ts +7 -0
- package/dist/server/sync/connection.d.ts +13 -0
- package/dist/server/sync/drizzle/index.js +5 -4
- package/dist/server/sync/index.d.ts +3 -0
- package/dist/server/sync/index.js +1361 -243
- package/dist/server/sync/invalidate-sync.d.ts +6 -2
- package/dist/server/sync/local-client.d.ts +9 -0
- package/dist/server/sync/postgres/index.d.ts +1 -1
- package/dist/server/sync/postgres/index.js +2 -2
- package/dist/server/sync/prisma/index.js +2 -2
- package/dist/server/sync/redis/index.d.ts +1 -1
- package/dist/server/sync/redis/index.js +4 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/runtime.d.ts +3 -0
- package/dist/server/sync/sqlite/index.d.ts +1 -1
- package/dist/server/sync/sqlite/index.js +3 -2
- package/dist/shared/browser-events.d.ts +4 -0
- package/dist/sync-client.d.ts +3 -0
- package/dist/sync-client.js +1600 -0
- package/package.json +12 -7
- package/src/adapter/README.md +7 -0
- package/src/adapter/build.ts +34 -33
- package/src/adapter/bun/app.ts +5 -0
- package/src/adapter/bun/server.ts +2 -2
- package/src/adapter/bun.ts +18 -2
- package/src/adapter/furin-app.d.ts +1 -0
- package/src/adapter/package.ts +1 -0
- package/src/adapter/runtime-build.ts +18 -12
- package/src/adapter/static.ts +17 -13
- package/src/build/client.ts +7 -5
- package/src/build/discover-mounts-process.ts +5 -1
- package/src/build/discover-pages-process.ts +151 -0
- package/src/build/discover-pages.ts +69 -0
- package/src/build/discovery-module.ts +70 -0
- package/src/build/discovery-plugins.ts +101 -0
- package/src/build/elysia-aot-worker.ts +9 -8
- package/src/build/elysia-aot.ts +110 -75
- package/src/build/entry-template.ts +6 -1
- package/src/build/hydrate.ts +11 -8
- package/src/build/index.ts +6 -50
- package/src/build/preload-manifest.ts +3 -3
- package/src/build/route-metadata.ts +90 -0
- package/src/build/route-types.ts +1 -1
- package/src/build/shared.ts +6 -8
- package/src/build/types.ts +9 -0
- package/src/cli/config.ts +4 -0
- package/src/cli/dev-worker.ts +123 -0
- package/src/cli/dev.ts +91 -0
- package/src/cli/index.ts +24 -1
- package/src/client/browser-events-runtime.ts +97 -23
- package/src/client/browser-events.ts +8 -0
- package/src/client/dev-error-overlay.ts +18 -1
- package/src/client/query-store.ts +54 -3
- package/src/client/router/navigation-controller.ts +45 -12
- package/src/client/router/provider.tsx +6 -2
- package/src/client/router/use-fetch-interception.ts +1 -1
- package/src/client/router/use-sync-stream.ts +96 -44
- package/src/client/{router/sync-catch-up.ts → sync-catch-up.ts} +28 -12
- package/src/client/sync-client.ts +528 -0
- package/src/client/sync.ts +11 -4
- package/src/client.ts +10 -0
- package/src/config.ts +17 -10
- package/src/furin.ts +5 -0
- package/src/plugin/route-registry.ts +53 -7
- package/src/rsc/build/index.ts +6 -3
- package/src/server/browser-events/plugin.ts +79 -25
- package/src/server/dev/rewrite-module-specifiers.ts +2 -1
- package/src/server/dev/server-only-module.ts +23 -0
- package/src/server/dev/symbolicate.ts +4 -3
- package/src/server/dev-page-imports.ts +3 -1
- package/src/server/dev-page-plugin.ts +18 -1
- package/src/server/logging/ingest-plugin.ts +3 -9
- package/src/server/server-entry.ts +39 -0
- package/src/server/sync/adapter.ts +7 -3
- package/src/server/sync/config.ts +12 -6
- package/src/server/sync/connection.ts +71 -0
- package/src/server/sync/index.ts +3 -0
- package/src/server/sync/invalidate-sync.ts +30 -5
- package/src/server/sync/local-client.ts +84 -0
- package/src/server/sync/plugin.ts +27 -20
- package/src/server/sync/postgres/index.ts +9 -2
- package/src/server/sync/redis/index.ts +5 -1
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/runtime.ts +56 -18
- package/src/server/sync/sqlite/index.ts +6 -2
- package/src/server/sync/stream.ts +17 -5
- package/src/shared/browser-events.ts +1 -1
- package/src/sync-client.ts +14 -0
- package/dist/server/logger.d.ts +0 -10
- package/src/server/logger.ts +0 -34
|
@@ -8,6 +8,7 @@ export interface ReadResult {
|
|
|
8
8
|
response?: Response;
|
|
9
9
|
}
|
|
10
10
|
export interface ReadReference {
|
|
11
|
+
application?: object;
|
|
11
12
|
client: QueryStore;
|
|
12
13
|
load: (options: unknown) => Promise<ReadResult>;
|
|
13
14
|
url: string;
|
|
@@ -75,6 +76,10 @@ export declare class QueryStore {
|
|
|
75
76
|
observe(url: string, result: ReadResult, epoch: number, version?: number): void;
|
|
76
77
|
private setSession;
|
|
77
78
|
generation(): number;
|
|
79
|
+
/** Fence in-flight responses without removing active observers or their loaders. */
|
|
80
|
+
clear(preserveData?: boolean): void;
|
|
81
|
+
dispose(): void;
|
|
82
|
+
setError(url: string, error: unknown): void;
|
|
78
83
|
version(url: string): number;
|
|
79
84
|
snapshot(url: string): QuerySnapshot;
|
|
80
85
|
subscribe(url: string, listener: () => void): () => void;
|
|
@@ -63,6 +63,8 @@ export declare class NavigationController {
|
|
|
63
63
|
readonly prefetch: (href: string, staleTime: number | undefined) => void;
|
|
64
64
|
/** Drops cached pages under `path` and marks in-flight ones stale. */
|
|
65
65
|
readonly invalidatePath: (path: string, type: "page" | "layout") => void;
|
|
66
|
+
/** Access changes must also prevent old navigations and deferred streams from publishing. */
|
|
67
|
+
invalidateContext(): void;
|
|
66
68
|
/** Drops cached pages whose state reads an invalidated query. */
|
|
67
69
|
invalidateQueries(affected: (state: RouterState) => boolean): void;
|
|
68
70
|
/** Republishes the current page so hot-swapped components render. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InvalidationRefresh } from "
|
|
1
|
+
import type { InvalidationRefresh } from "../sync-catch-up.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Processes `X-Furin-Revalidate` headers on every same-origin `window.fetch`
|
|
4
4
|
* response: evicts the named pages and refreshes the current one when
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueryStore } from "../query-store.ts";
|
|
2
|
+
import { type InvalidationRefresh } from "../sync-catch-up.ts";
|
|
2
3
|
import type { NavigationController } from "./navigation-controller.ts";
|
|
3
|
-
import { type InvalidationRefresh } from "./sync-catch-up.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Listens for sync cursor notifications and recovers the changes over HTTP,
|
|
6
6
|
* invalidating cached pages and queries and refreshing the current page when
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SyncInvalidation } from "
|
|
1
|
+
import type { SyncInvalidation } from "../server/sync/adapter.ts";
|
|
2
|
+
import { type QueryIdentity } from "../shared/sync-query.ts";
|
|
2
3
|
interface SyncChangePayload {
|
|
3
4
|
cursor: string;
|
|
4
5
|
invalidations: readonly (string | SyncInvalidation)[];
|
|
5
|
-
queries?: readonly
|
|
6
|
+
queries?: readonly QueryIdentity[];
|
|
6
7
|
}
|
|
7
8
|
export interface SyncChangePagePayload {
|
|
8
9
|
changes: readonly SyncChangePayload[];
|
|
@@ -13,11 +14,12 @@ export interface SyncChangePagePayload {
|
|
|
13
14
|
interface SyncCatchUpOptions {
|
|
14
15
|
fetchPage: (after: string | undefined) => Promise<SyncChangePagePayload>;
|
|
15
16
|
onInvalidations: (invalidations: readonly string[]) => void;
|
|
16
|
-
onQueries?: (identities: readonly
|
|
17
|
+
onQueries?: (identities: readonly QueryIdentity[]) => void;
|
|
17
18
|
onReset?: () => void;
|
|
18
19
|
}
|
|
19
20
|
export interface SyncCatchUp {
|
|
20
21
|
catchUp: () => Promise<void>;
|
|
22
|
+
close: () => void;
|
|
21
23
|
cursor: () => string | undefined;
|
|
22
24
|
seed: (cursor: string) => void;
|
|
23
25
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type LiveQuery, type ReadReference, type ReadResult } from "./query-store.ts";
|
|
2
|
+
interface SyncSocketEvents {
|
|
3
|
+
close: {
|
|
4
|
+
code: number;
|
|
5
|
+
};
|
|
6
|
+
error: unknown;
|
|
7
|
+
message: {
|
|
8
|
+
data: unknown;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** The common event API implemented by native WebSocket and runtime socket adapters. */
|
|
12
|
+
export interface SyncSocket {
|
|
13
|
+
addEventListener: <Event extends keyof SyncSocketEvents>(type: Event, listener: (event: SyncSocketEvents[Event]) => void) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
readonly readyState: number;
|
|
16
|
+
removeEventListener: <Event extends keyof SyncSocketEvents>(type: Event, listener: (event: SyncSocketEvents[Event]) => void) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class SyncClientError extends Error {
|
|
19
|
+
readonly status: number | undefined;
|
|
20
|
+
static [Symbol.hasInstance](error: unknown): boolean;
|
|
21
|
+
constructor(message: string, status: number | undefined, cause?: unknown);
|
|
22
|
+
}
|
|
23
|
+
export interface SyncConnectionState {
|
|
24
|
+
error: SyncClientError | null;
|
|
25
|
+
/** Why a connection is being restarted; absent when idle or connected. */
|
|
26
|
+
reason?: "network" | "credentials" | "context";
|
|
27
|
+
status: "idle" | "connecting" | "connected" | "reconnecting" | "unauthorized" | "closed";
|
|
28
|
+
}
|
|
29
|
+
export interface SyncClientOptions {
|
|
30
|
+
/** Runtime adapter only: Furin handles envelopes, recovery and reconnection. */
|
|
31
|
+
createWebSocket?: (url: string, headers: Headers) => SyncSocket | Promise<SyncSocket>;
|
|
32
|
+
fetch?: Omit<RequestInit, "headers" | "signal" | "method" | "body">;
|
|
33
|
+
fetcher?: typeof fetch;
|
|
34
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
35
|
+
/** Relative to the application URL. Defaults to _furin/sync. */
|
|
36
|
+
syncPath?: string;
|
|
37
|
+
/** Absolute Furin application URL, including its mount path. */
|
|
38
|
+
url: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SyncQueryState<Result extends ReadResult> {
|
|
41
|
+
data: NonNullable<Result["data"]> | undefined;
|
|
42
|
+
error: Result["error"] | SyncClientError | null;
|
|
43
|
+
isFetching: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface SyncClient {
|
|
46
|
+
close: () => void;
|
|
47
|
+
getConnectionState: () => SyncConnectionState;
|
|
48
|
+
/** Reauthenticate and reevaluate reads; clears snapshots and cursor unless preservation is explicit. */
|
|
49
|
+
reconnect: (options?: SyncReconnectOptions) => void;
|
|
50
|
+
subscribe: <Result extends ReadResult>(query: LiveQuery<Result>, listener: (state: SyncQueryState<Result>) => void) => () => void;
|
|
51
|
+
subscribeConnection: (listener: (state: SyncConnectionState) => void) => () => void;
|
|
52
|
+
}
|
|
53
|
+
export interface SyncReconnectOptions {
|
|
54
|
+
/** Only retain snapshots for renewal within the same identity and access scope. */
|
|
55
|
+
preserveCache?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface SyncTransportSubscription {
|
|
58
|
+
headers: Headers;
|
|
59
|
+
onContextChange: () => void;
|
|
60
|
+
onCursor: () => void;
|
|
61
|
+
onError: (error: unknown) => void;
|
|
62
|
+
signal: AbortSignal;
|
|
63
|
+
}
|
|
64
|
+
/** @internal The local and remote adapters share one cache and recovery lifecycle. */
|
|
65
|
+
export interface SyncTransport {
|
|
66
|
+
accepts: (reference: ReadReference) => boolean;
|
|
67
|
+
fetchChanges: (after: string | undefined, headers: Headers, signal: AbortSignal) => Promise<Response>;
|
|
68
|
+
subscribe: (options: SyncTransportSubscription) => Promise<() => void>;
|
|
69
|
+
}
|
|
70
|
+
/** One server and authentication context, with one socket shared by all subscribers. */
|
|
71
|
+
export declare function createSyncClient(options: SyncClientOptions): SyncClient;
|
|
72
|
+
/** @internal Constructed by the public local and remote factories. */
|
|
73
|
+
export declare function createSyncClientRuntime(options: Pick<SyncClientOptions, "headers" | "fetch">, transport: SyncTransport): SyncClient;
|
|
74
|
+
export {};
|
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { useQuery } from "./client/query.tsx";
|
|
|
7
7
|
export type { LiveQuery } from "./client/query-store.ts";
|
|
8
8
|
export { getRouteApi } from "./client/route-api.tsx";
|
|
9
9
|
export { furinSync, type OptimisticCache, type SyncCallOptions } from "./client/sync.ts";
|
|
10
|
+
export { createSyncClient, type SyncClient, SyncClientError, type SyncClientOptions, type SyncConnectionState, type SyncQueryState, type SyncReconnectOptions, type SyncSocket, } from "./client/sync-client.ts";
|
|
10
11
|
export { Await, useAsyncError, useAsyncValue } from "./shared/await.tsx";
|
|
11
12
|
export { type DeferredData, defer, isDeferred } from "./shared/defer.ts";
|
|
12
13
|
export type RenderingMode = "ssr" | "ssg" | "isr";
|