@teyik0/furin 0.2.0-alpha.4 → 0.3.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 +17 -1
- package/dist/adapter/package.d.ts +26 -0
- package/dist/adapter/static.d.ts +1 -1
- package/dist/build/bun-build.d.ts +3 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +3 -3
- package/dist/build/compile-entry.ts +88 -83
- package/dist/build/entry-template.d.ts +37 -9
- package/dist/build/entry-template.ts +109 -56
- package/dist/build/hydrate.d.ts +2 -2
- package/dist/build/index.js +6817 -4544
- package/dist/build/production-instrumentation.d.ts +1 -0
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/scan-server.d.ts +10 -4
- package/dist/build/server-routes-entry.d.ts +3 -3
- package/dist/build/server-routes-entry.ts +5 -11
- package/dist/build/ssg-cache.d.ts +1 -1
- package/dist/build/types.d.ts +37 -1
- package/dist/cli/config.d.ts +6 -1
- package/dist/cli/index.js +6854 -4549
- package/dist/client/boundaries.d.ts +4 -4
- package/dist/client/internal/runtime-types.d.ts +30 -0
- package/dist/client/link.d.ts +2 -1
- package/dist/client/link.js +712 -338
- package/dist/client/router/boundary-tree.d.ts +1 -1
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +5 -1
- package/dist/client/router/sync-catch-up.d.ts +4 -4
- package/dist/client/router/types.d.ts +2 -2
- package/dist/client-only.d.ts +1 -0
- package/dist/client-only.js +1 -0
- package/dist/client.d.ts +108 -111
- package/dist/client.js +16 -17
- package/dist/config.d.ts +11 -2
- package/dist/config.js +7 -3
- package/dist/devtools/devtools-element.d.ts +1 -0
- package/dist/devtools/protocol.d.ts +119 -0
- package/dist/furin.d.ts +40 -21
- package/dist/furin.js +7198 -3518
- 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 +933 -423
- package/dist/plugin/transform-client.d.ts +0 -2
- package/dist/plugin/transform-isomorphic.d.ts +9 -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/auto-invalidate/registry.d.ts +8 -1
- package/dist/server/cache/dev-loader.d.ts +3 -2
- package/dist/server/cache/index.d.ts +2 -2
- package/dist/server/cache/invalidation.d.ts +20 -2
- package/dist/server/cache/isr-ssg.d.ts +5 -1
- package/dist/server/cache/isr.d.ts +15 -2
- package/dist/server/cache/registry.d.ts +3 -3
- package/dist/server/cache/route-cache.d.ts +10 -8
- package/dist/server/cache/ssg.d.ts +6 -2
- package/dist/server/cache/store-view.d.ts +11 -0
- package/dist/server/dev-page-plugin.d.ts +4 -0
- 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/instance.d.ts +86 -0
- package/dist/server/internal.d.ts +18 -1
- package/dist/server/internal.js +74 -7
- package/dist/server/lang-detect.d.ts +1 -0
- package/dist/server/render/assemble.d.ts +4 -0
- package/dist/server/render/element.d.ts +1 -1
- package/dist/server/render/index.d.ts +2 -2
- package/dist/server/render/index.ts +6 -2
- package/dist/server/render/loaders.d.ts +8 -0
- package/dist/server/render/not-found.d.ts +1 -1
- 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/ssr.d.ts +2 -3
- package/dist/server/render/template.d.ts +3 -2
- package/dist/server/router/discovery.d.ts +1 -1
- package/dist/server/router/hmr.d.ts +1 -1
- package/dist/server/router/index.d.ts +2 -1
- package/dist/server/router/index.js +23 -23
- package/dist/server/router/index.ts +1 -1
- package/dist/server/router/patterns.d.ts +1 -1
- package/dist/server/router/plugin.d.ts +4 -7
- package/dist/server/router/schema-merge.d.ts +3 -0
- package/dist/server/router/schemas.d.ts +12 -7
- package/dist/server/router/types.d.ts +1 -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 +9 -2
- package/dist/server/sync/fingerprint.d.ts +2 -1
- package/dist/server/sync/index.d.ts +15 -4
- package/dist/server/sync/index.js +2868 -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 +16 -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 -4
- package/dist/server-only.d.ts +1 -0
- package/dist/server-only.js +1 -0
- package/dist/shared/parser.d.ts +2 -0
- package/dist/shared/prefix.d.ts +15 -0
- package/dist/shared/route-frame.d.ts +49 -0
- package/dist/shared/utils/index.d.ts +1 -1
- package/package.json +59 -12
- package/src/adapter/bun.ts +175 -55
- package/src/adapter/package.ts +208 -0
- package/src/adapter/static.ts +94 -48
- package/src/build/bun-build.ts +11 -0
- package/src/build/client.ts +31 -27
- package/src/build/compile-entry.ts +88 -83
- package/src/build/entry-template.ts +109 -56
- package/src/build/hydrate.ts +37 -10
- package/src/build/index.ts +111 -28
- package/src/build/production-instrumentation.ts +14 -0
- package/src/build/route-types.ts +7 -8
- package/src/build/scan-server.ts +26 -9
- package/src/build/server-routes-entry.ts +5 -11
- package/src/build/ssg-cache.ts +13 -4
- package/src/build/types.ts +38 -1
- package/src/cli/config.ts +9 -3
- package/src/cli/index.ts +73 -24
- package/src/client/boundaries.tsx +42 -18
- package/src/client/default-screens.tsx +4 -4
- package/src/client/internal/runtime-types.ts +31 -0
- package/src/client/link.tsx +35 -37
- package/src/client/router/boundary-tree.tsx +2 -2
- package/src/client/router/context.ts +13 -9
- package/src/client/router/index.ts +3 -0
- package/src/client/router/link-utils.ts +66 -3
- package/src/client/router/navigation.ts +9 -15
- package/src/client/router/provider.tsx +74 -52
- package/src/client/router/search/index.ts +5 -7
- 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 +2 -2
- package/src/client/sync.ts +3 -2
- package/src/client-only.ts +1 -0
- package/src/client.ts +221 -174
- package/src/config.ts +14 -1
- package/src/devtools/devtools-element.js +884 -0
- package/src/devtools/protocol.ts +139 -0
- package/src/furin.ts +414 -171
- 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/transform-client.ts +237 -273
- package/src/plugin/transform-isomorphic.ts +464 -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 +23 -1
- package/src/server/auto-invalidate/runtime.ts +58 -7
- package/src/server/cache/dev-loader.ts +143 -44
- package/src/server/cache/index.ts +7 -3
- package/src/server/cache/invalidation.ts +100 -41
- package/src/server/cache/isr-ssg.ts +12 -3
- package/src/server/cache/isr.ts +95 -5
- package/src/server/cache/registry.ts +17 -20
- package/src/server/cache/route-cache.ts +49 -36
- package/src/server/cache/ssg.ts +19 -4
- package/src/server/cache/store-view.ts +30 -0
- package/src/server/context-logger.ts +7 -7
- package/src/server/dev-page-plugin.ts +8 -6
- 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 +267 -0
- package/src/server/devtools/request-context.ts +76 -0
- package/src/server/instance.ts +252 -0
- package/src/server/internal.ts +102 -5
- package/src/server/lang-detect.ts +14 -10
- package/src/server/render/assemble.ts +73 -10
- package/src/server/render/element.tsx +11 -8
- package/src/server/render/index.ts +6 -2
- package/src/server/render/isr.ts +154 -110
- package/src/server/render/loaders.ts +259 -45
- package/src/server/render/not-found.ts +18 -17
- 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 +6 -5
- package/src/server/render/ssr.ts +170 -70
- package/src/server/render/template.ts +59 -25
- package/src/server/router/discovery.ts +39 -22
- package/src/server/router/hmr.ts +15 -13
- package/src/server/router/index.ts +1 -1
- package/src/server/router/patterns.ts +16 -15
- package/src/server/router/plugin.ts +151 -158
- package/src/server/router/schema-merge.ts +52 -0
- package/src/server/router/schemas.ts +55 -73
- package/src/server/router/types.ts +1 -1
- package/src/server/sync/adapter.ts +44 -28
- package/src/server/sync/config.ts +22 -9
- 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 -90
- package/src/server/sync/postgres/index.ts +301 -0
- package/src/server/sync/postgres/migrate.ts +15 -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 +141 -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 +136 -70
- package/src/server-only.ts +1 -0
- package/src/shared/await.tsx +4 -4
- package/src/shared/deferred-ndjson.ts +34 -6
- package/src/shared/digest.ts +2 -2
- package/src/shared/parser.ts +5 -0
- package/src/shared/prefix.ts +38 -0
- package/src/shared/route-frame.ts +429 -0
- package/src/shared/search-params.ts +7 -7
- package/src/shared/utils/index.ts +5 -3
- package/dist/server/dev-inspector.d.ts +0 -89
- package/dist/server/sync/memory-adapter.d.ts +0 -17
- package/src/server/dev-inspector.ts +0 -60
- package/src/server/sync/memory-adapter.ts +0 -196
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export interface FurinInstance {
|
|
2
|
+
buildId: string;
|
|
3
|
+
/** Absolute pagesDir — also the compile-context key. */
|
|
4
|
+
readonly pagesDir: string;
|
|
5
|
+
/** Mount prefix, `""` for the root app or `/admin`-style (no trailing slash). */
|
|
6
|
+
readonly prefix: string;
|
|
7
|
+
/** @internal Traffic epoch at registration time (see registerInstance). */
|
|
8
|
+
registrationEpoch: number;
|
|
9
|
+
/** Generic per-instance state bag backing `instanceSlot()`. */
|
|
10
|
+
readonly state: Map<symbol, unknown>;
|
|
11
|
+
/** Logical sync stream path (unprefixed) injected into HTML, or undefined. */
|
|
12
|
+
syncStreamPath: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function createInstance(prefix: string, pagesDir: string): FurinInstance;
|
|
15
|
+
/** @internal Called by the request wrap for every served request. */
|
|
16
|
+
export declare function markTraffic(): void;
|
|
17
|
+
/**
|
|
18
|
+
* The process-wide fallback bucket. State written outside any instance scope
|
|
19
|
+
* before the first `furin()` registration lands here — config-like readers
|
|
20
|
+
* (e.g. the production template) treat it as a default.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defaultInstanceBucket(): FurinInstance;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes a user-provided mount prefix. Accepts `""`, `"/"` (both → root)
|
|
25
|
+
* or `/segment(/segment)*`. Throws on anything else so misconfiguration fails
|
|
26
|
+
* at startup instead of producing silently unreachable routes.
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizePrefix(prefix: string | undefined): string;
|
|
29
|
+
/**
|
|
30
|
+
* Throws when mounting `pagesDir` under `prefix` would collide with a LIVE
|
|
31
|
+
* registration. Rules:
|
|
32
|
+
* - same pagesDir → idempotent re-mount (mirrors Elysia's name-based dedup);
|
|
33
|
+
* - different pagesDir, NO traffic since the existing registration → two apps
|
|
34
|
+
* composed into one server are claiming the same prefix: hard error;
|
|
35
|
+
* - different pagesDir, traffic flowed since → the existing registration is a
|
|
36
|
+
* leftover from a torn-down server (tests): replacement is allowed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function assertPrefixAvailable(prefix: string, pagesDir: string): void;
|
|
39
|
+
/** Registers an instance under its prefix (see assertPrefixAvailable). */
|
|
40
|
+
export declare function registerInstance(instance: FurinInstance): FurinInstance;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the instance owning `pathname` by longest-prefix match on a path
|
|
43
|
+
* boundary. Falls back to the root (`""`) instance when one is mounted, else
|
|
44
|
+
* the default bucket — never an arbitrary prefixed sibling, whose template/
|
|
45
|
+
* cache/build state would otherwise leak into parent-app routes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveInstanceByPath(pathname: string): FurinInstance;
|
|
48
|
+
/**
|
|
49
|
+
* The instance the current code runs for. Resolution order:
|
|
50
|
+
* 1. request/render ALS scope, 2. sole registered instance, 3. default bucket.
|
|
51
|
+
* With ≥2 instances and no scope, state access is ambiguous — the default
|
|
52
|
+
* bucket keeps out-of-request writes (e.g. build-time template setup)
|
|
53
|
+
* self-consistent instead of leaking into an arbitrary app.
|
|
54
|
+
*/
|
|
55
|
+
export declare function currentInstance(): FurinInstance;
|
|
56
|
+
/** All registered instances (used by cross-instance ops like revalidateTag). */
|
|
57
|
+
export declare function allInstances(): FurinInstance[];
|
|
58
|
+
/**
|
|
59
|
+
* @internal Every live state bucket: registered instances plus the default
|
|
60
|
+
* fallback bucket. Reset helpers iterate this so state written outside any
|
|
61
|
+
* registration (tests, config-before-mount) is covered too.
|
|
62
|
+
*/
|
|
63
|
+
export declare function allStateBuckets(): FurinInstance[];
|
|
64
|
+
/**
|
|
65
|
+
* @internal test-only — forgets registered instances (fresh mounts get a
|
|
66
|
+
* clean registry) while PRESERVING the default bucket, so process-wide
|
|
67
|
+
* defaults installed once (e.g. a test template in `beforeAll`) survive.
|
|
68
|
+
*/
|
|
69
|
+
export declare function __clearInstanceRegistry(): void;
|
|
70
|
+
export declare function hasRequestScope(): boolean;
|
|
71
|
+
/** Pending client-invalidation paths for the current request, if any. */
|
|
72
|
+
export declare function requestPendingInvalidations(): Set<string> | undefined;
|
|
73
|
+
/** Runs `fn` inside a fresh request scope bound to `instance`. */
|
|
74
|
+
export declare function runWithInstanceScope<T>(instance: FurinInstance, fn: () => T): T;
|
|
75
|
+
/**
|
|
76
|
+
* Runs `fn` bound to `instance` for synthetic (non-request) work — SSG cache
|
|
77
|
+
* warming, background ISR revalidation kicked off outside a live request.
|
|
78
|
+
*/
|
|
79
|
+
export declare function withInstance<T>(instance: FurinInstance, fn: () => T): T;
|
|
80
|
+
/**
|
|
81
|
+
* Declares a lazily-initialized per-instance state slot. Returns an accessor
|
|
82
|
+
* that resolves against the current instance (or an explicit one). This is
|
|
83
|
+
* how state modules attach caches/registries to instances without this module
|
|
84
|
+
* importing them (avoids import cycles).
|
|
85
|
+
*/
|
|
86
|
+
export declare function instanceSlot<T>(init: (instance: FurinInstance) => T): (instance?: FurinInstance) => T;
|
|
@@ -10,8 +10,12 @@ export interface CompileContextRoute {
|
|
|
10
10
|
}
|
|
11
11
|
export interface CompileContext {
|
|
12
12
|
buildId?: string;
|
|
13
|
+
/** Whether the emitted hydration client sends browser log batches. */
|
|
14
|
+
clientLogging?: boolean;
|
|
13
15
|
embedded?: EmbeddedAppData;
|
|
14
16
|
modules: Record<string, unknown>;
|
|
17
|
+
/** Mount prefix this app was built for (`""` = root). */
|
|
18
|
+
prefix?: string;
|
|
15
19
|
/** Root-level conventions discovered at compile time. */
|
|
16
20
|
rootConventions?: {
|
|
17
21
|
errorPath?: string;
|
|
@@ -31,5 +35,18 @@ export interface CompileContext {
|
|
|
31
35
|
ssgCache?: Record<string, SsgCacheEntry>;
|
|
32
36
|
}
|
|
33
37
|
export declare function __setCompileContext(ctx: CompileContext): void;
|
|
34
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Looks up the compile context for a (pagesDir, prefix) mount. Resolution
|
|
40
|
+
* order, from most to least specific:
|
|
41
|
+
* 1. exact (pagesDir, prefix) key — distinguishes the same app mounted twice;
|
|
42
|
+
* 2. sole context registered for `pagesDir` — callers that don't pass a
|
|
43
|
+
* prefix, and contexts emitted before the prefix field existed;
|
|
44
|
+
* 3. sole context registered for `prefix` — deployed binaries run from a
|
|
45
|
+
* different cwd than the build, so the absolute pagesDir key misses there,
|
|
46
|
+
* but the mount prefix is stable across machines;
|
|
47
|
+
* 4. the sole registered context (single-app back-compat).
|
|
48
|
+
*/
|
|
49
|
+
export declare function getCompileContext(pagesDir?: string, prefix?: string): CompileContext | null;
|
|
50
|
+
/** All registered contexts, keyed by the composite (pagesDir, prefix) key. */
|
|
51
|
+
export declare function getAllCompileContexts(): ReadonlyMap<string, CompileContext>;
|
|
35
52
|
export declare function __resetCompileContext(): void;
|
package/dist/server/internal.js
CHANGED
|
@@ -1,17 +1,84 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/server/instance.ts
|
|
3
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
4
|
+
var _requestScope = new AsyncLocalStorage;
|
|
5
|
+
var _instances = new Map;
|
|
6
|
+
function __clearInstanceRegistry() {
|
|
7
|
+
_instances.clear();
|
|
8
|
+
}
|
|
9
|
+
|
|
2
10
|
// src/server/internal.ts
|
|
3
|
-
var
|
|
11
|
+
var _compileContexts = new Map;
|
|
12
|
+
function normalizeContextKey(path) {
|
|
13
|
+
return path.replaceAll("\\", "/");
|
|
14
|
+
}
|
|
15
|
+
function pagesDirOf(ctx) {
|
|
16
|
+
const rootPath = normalizeContextKey(ctx.rootPath);
|
|
17
|
+
const lastSlash = rootPath.lastIndexOf("/");
|
|
18
|
+
return lastSlash === -1 ? rootPath : rootPath.slice(0, lastSlash);
|
|
19
|
+
}
|
|
20
|
+
function contextKey(pagesDir, prefix) {
|
|
21
|
+
return `${pagesDir}\x00${prefix}`;
|
|
22
|
+
}
|
|
4
23
|
function __setCompileContext(ctx) {
|
|
5
|
-
|
|
24
|
+
_compileContexts.set(contextKey(pagesDirOf(ctx), ctx.prefix ?? ""), ctx);
|
|
25
|
+
}
|
|
26
|
+
function getCompileContext(pagesDir, prefix) {
|
|
27
|
+
if (pagesDir !== undefined) {
|
|
28
|
+
const dir = normalizeContextKey(pagesDir);
|
|
29
|
+
if (prefix !== undefined) {
|
|
30
|
+
const exact = _compileContexts.get(contextKey(dir, prefix));
|
|
31
|
+
if (exact) {
|
|
32
|
+
return exact;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const dirMatch = soleContextForPagesDir(dir);
|
|
36
|
+
if (dirMatch) {
|
|
37
|
+
return dirMatch;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (prefix !== undefined) {
|
|
41
|
+
const prefixMatch = contextForPrefix(prefix);
|
|
42
|
+
if (prefixMatch) {
|
|
43
|
+
return prefixMatch;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (_compileContexts.size === 1) {
|
|
47
|
+
return _compileContexts.values().next().value ?? null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function soleContextForPagesDir(dir) {
|
|
52
|
+
let match = null;
|
|
53
|
+
for (const ctx of _compileContexts.values()) {
|
|
54
|
+
if (pagesDirOf(ctx) !== dir) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (match) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
match = ctx;
|
|
61
|
+
}
|
|
62
|
+
return match;
|
|
63
|
+
}
|
|
64
|
+
function contextForPrefix(prefix) {
|
|
65
|
+
for (const ctx of _compileContexts.values()) {
|
|
66
|
+
if ((ctx.prefix ?? "") === prefix) {
|
|
67
|
+
return ctx;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
6
71
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
72
|
+
function getAllCompileContexts() {
|
|
73
|
+
return _compileContexts;
|
|
9
74
|
}
|
|
10
75
|
function __resetCompileContext() {
|
|
11
|
-
|
|
76
|
+
_compileContexts.clear();
|
|
77
|
+
__clearInstanceRegistry();
|
|
12
78
|
}
|
|
13
79
|
export {
|
|
14
|
-
|
|
80
|
+
__resetCompileContext,
|
|
15
81
|
__setCompileContext,
|
|
16
|
-
|
|
82
|
+
getAllCompileContexts,
|
|
83
|
+
getCompileContext
|
|
17
84
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SourceLang } from "yuku-parser";
|
|
2
2
|
export declare function detectLangFromPath(filePath: string): SourceLang;
|
|
3
|
+
export declare function detectLoaderFromPath(filePath: string): "js" | "jsx" | "ts" | "tsx";
|
|
3
4
|
export declare function unwrapTSExpression<T extends {
|
|
4
5
|
type: string;
|
|
5
6
|
}>(node: T): T;
|
|
@@ -44,6 +44,10 @@ interface SplitTemplate {
|
|
|
44
44
|
}
|
|
45
45
|
export declare function splitTemplate(template: string): SplitTemplate;
|
|
46
46
|
export declare function assembleHTML(template: string, headData: ReturnType<typeof buildHeadInjection>, reactHtml: string, data: Record<string, unknown> | undefined): string;
|
|
47
|
+
export declare function buildRouteFrameTemplate(payload: string): string;
|
|
48
|
+
export declare function buildRouteFrameStreamScript(): string;
|
|
49
|
+
export declare function buildRouteFramePushScript(payload: string): string;
|
|
50
|
+
export declare function buildRouteFrameCloseScript(): string;
|
|
47
51
|
export declare function buildSyncRuntimeScript(): string;
|
|
48
52
|
export declare function injectSyncRuntimeScript(html: string): string;
|
|
49
53
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { RuntimeRoute } from "../../client.ts";
|
|
2
|
+
import type { RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
3
|
import type { ErrorComponent } from "../../shared/error.ts";
|
|
4
4
|
import type { FurinNotFoundError, NotFoundComponent } from "../../shared/not-found.ts";
|
|
5
5
|
import type { ResolvedRoute } from "../router/index.ts";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type LoaderContext, streamToString } from "./assemble.ts";
|
|
2
2
|
export { buildElement, buildErrorElement } from "./element.tsx";
|
|
3
3
|
export { handleISR } from "./isr.ts";
|
|
4
|
-
export { type LoaderResult, runLoaders, serializeDeferredRejection } from "./loaders.ts";
|
|
4
|
+
export { hasRequestLoader, type LoaderResult, runLoaders, serializeDeferredRejection, } from "./loaders.ts";
|
|
5
5
|
export { renderRootNotFound } from "./not-found.ts";
|
|
6
6
|
export { prerenderSSG, warmSSGCache } from "./ssg.ts";
|
|
7
|
-
export { assertDeferredModeAllowed, type PreparedRender, prepareRender, type RenderResult, renderForPath, renderSSR, renderToHTML,
|
|
7
|
+
export { assertDeferredModeAllowed, type PreparedRender, prepareRender, type RenderResult, renderForPath, renderSSR, renderToHTML, serializeLoaderDataNdjson, splitBeforeBodyClose, withSSRRouterContext, } from "./ssr.ts";
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
export { type LoaderContext, streamToString } from "./assemble.ts";
|
|
4
4
|
export { buildElement, buildErrorElement } from "./element.tsx";
|
|
5
5
|
export { handleISR } from "./isr.ts";
|
|
6
|
-
export {
|
|
6
|
+
export {
|
|
7
|
+
hasRequestLoader,
|
|
8
|
+
type LoaderResult,
|
|
9
|
+
runLoaders,
|
|
10
|
+
serializeDeferredRejection,
|
|
11
|
+
} from "./loaders.ts";
|
|
7
12
|
export { renderRootNotFound } from "./not-found.ts";
|
|
8
13
|
|
|
9
14
|
export { prerenderSSG, warmSSGCache } from "./ssg.ts";
|
|
@@ -15,7 +20,6 @@ export {
|
|
|
15
20
|
renderForPath,
|
|
16
21
|
renderSSR,
|
|
17
22
|
renderToHTML,
|
|
18
|
-
renderToStream,
|
|
19
23
|
serializeLoaderDataNdjson,
|
|
20
24
|
splitBeforeBodyClose,
|
|
21
25
|
withSSRRouterContext,
|
|
@@ -43,6 +43,12 @@ export type LoaderResult = {
|
|
|
43
43
|
message: string;
|
|
44
44
|
headers: Record<string, string>;
|
|
45
45
|
};
|
|
46
|
+
export declare function runRequestLoaderData(route: ResolvedRoute, ctx: Context): Promise<object> | undefined;
|
|
47
|
+
export declare function withRequestLoaderData(route: ResolvedRoute, ctx: Context, publicResult: Extract<LoaderResult, {
|
|
48
|
+
type: "data";
|
|
49
|
+
}>): Extract<LoaderResult, {
|
|
50
|
+
type: "data";
|
|
51
|
+
}>;
|
|
46
52
|
/**
|
|
47
53
|
* Normalises an error thrown inside a deferred Promise into a value that is
|
|
48
54
|
* safe to send through `toCrossJSON` and that preserves the original semantics
|
|
@@ -62,3 +68,5 @@ export type LoaderResult = {
|
|
|
62
68
|
*/
|
|
63
69
|
export declare function serializeDeferredRejection(err: unknown): Promise<unknown>;
|
|
64
70
|
export declare function runLoaders(route: ResolvedRoute, ctx: Context): Promise<LoaderResult>;
|
|
71
|
+
export declare function runPublicLoaders(route: ResolvedRoute, ctx: Context): Promise<LoaderResult>;
|
|
72
|
+
export declare function hasRequestLoader(route: ResolvedRoute): boolean;
|
|
@@ -3,4 +3,4 @@ import type { RootLayout } from "../router/index.ts";
|
|
|
3
3
|
* Renders the root-level not-found component into a complete 404 HTML Response.
|
|
4
4
|
* Used by the Elysia `.onError` catch-all when no route matches the request URL.
|
|
5
5
|
*/
|
|
6
|
-
export declare function renderRootNotFound(root: RootLayout, request: Request | undefined): Promise<Response>;
|
|
6
|
+
export declare function renderRootNotFound(root: RootLayout, request: Request | undefined, listenerOrigin?: string): Promise<Response>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from "elysia";
|
|
2
|
+
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
3
|
+
import { type RevalidateType } from "../cache/route-cache.ts";
|
|
4
|
+
import { type FurinInstance } from "../instance.ts";
|
|
5
|
+
import type { ResolvedRoute, RootLayout } from "../router/index.ts";
|
|
6
|
+
export declare function renderPprRoute(route: ResolvedRoute, ctx: Context, root: RootLayout, _buildId: string, searchRoutes: SearchRouteMetadata[] | undefined): Promise<Response>;
|
|
7
|
+
export declare function clearPprRouteCache(instance?: FurinInstance): void;
|
|
8
|
+
export declare function invalidatePprRoute(path: string, type: RevalidateType): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function serializeDeferredRouteFrame(key: string, promise: Promise<unknown>, idPrefix: string): Promise<string>;
|
|
2
|
+
export declare function createDeferredRouteFrameStream(syncData: Record<string, unknown>, deferredPromises: Record<string, Promise<unknown>>): ReadableStream<Uint8Array>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from "elysia";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { renderToReadableStream } from "react-dom/server";
|
|
4
|
-
import {
|
|
4
|
+
import type { RouterContextValue } from "../../client/router/types.ts";
|
|
5
5
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
6
6
|
import type { ResolvedRoute, RootLayout } from "../router/index.ts";
|
|
7
7
|
import { buildErrorElement } from "./element.tsx";
|
|
@@ -96,13 +96,12 @@ export declare function assertDeferredModeAllowed(route: ResolvedRoute, deferred
|
|
|
96
96
|
* never need try/catch for redirect handling.
|
|
97
97
|
*/
|
|
98
98
|
export declare function prepareRender(route: ResolvedRoute, ctx: Context, root: RootLayout, basePath: string | undefined, throwOnFailure: boolean, precomputedLoaderResult: LoaderResult | undefined, searchRoutes?: SearchRouteMetadata[]): Promise<PreparedRender | Response>;
|
|
99
|
-
export declare function renderForPath(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin: string, mode: "ssg" | "isr", basePath?: string, searchRoutes?: SearchRouteMetadata[]): Promise<RenderResult | Response>;
|
|
99
|
+
export declare function renderForPath(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin: string, mode: "ssg" | "isr", basePath?: string, searchRoutes?: SearchRouteMetadata[], search?: string): Promise<RenderResult | Response>;
|
|
100
100
|
/**
|
|
101
101
|
* Serialises a loader's `syncData` + `deferredPromises` into the same one-line
|
|
102
102
|
* NDJSON shape the live `/_furin/data` endpoint emits.
|
|
103
103
|
*/
|
|
104
104
|
export declare function serializeLoaderDataNdjson(syncData: Record<string, unknown>, deferredPromises: Record<string, Promise<unknown>> | undefined): Promise<string>;
|
|
105
105
|
export declare function renderToHTML(route: ResolvedRoute, ctx: Context, root: RootLayout, searchRoutes?: SearchRouteMetadata[]): Promise<RenderResult>;
|
|
106
|
-
export declare function renderToStream(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<ReadableStream | Response>;
|
|
107
106
|
export declare function renderSSR(route: ResolvedRoute, ctx: Context, root: RootLayout, precomputedLoaderResult: LoaderResult | undefined, searchRoutes?: SearchRouteMetadata[]): Promise<Response>;
|
|
108
107
|
export declare function splitBeforeBodyClose(bodyPost: string): [string, string];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
export declare function getDevTemplate(origin: string): Promise<string>;
|
|
2
|
-
export declare function setProductionTemplatePath(path: string | null): void;
|
|
3
|
-
export declare function setProductionTemplateContent(content: string): void;
|
|
3
|
+
export declare function setProductionTemplatePath(path: string | null, instance?: FurinInstance): void;
|
|
4
|
+
export declare function setProductionTemplateContent(content: string, instance?: FurinInstance): void;
|
|
4
5
|
export declare function getProductionTemplate(): string | null;
|
|
5
6
|
/** @internal test-only — resets all template state */
|
|
6
7
|
export declare function __resetTemplateState(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimePage, RuntimeRoute } from "../../client.ts";
|
|
1
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
2
|
import { type CompileContext } from "../internal.ts";
|
|
3
3
|
import type { ResolvedRoute, RootLayout } from "./types.ts";
|
|
4
4
|
export declare function isModuleNotFoundError(err: unknown): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from "elysia";
|
|
2
|
-
import type { RuntimePage, RuntimeRoute } from "../../client.ts";
|
|
2
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
3
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
4
4
|
import { type CompileContext } from "../internal.ts";
|
|
5
5
|
import type { ResolvedRoute, RootLayout } from "./types.ts";
|
|
@@ -2,5 +2,6 @@ export { collectRouteTags, loadProdRoutes, scanPages, scanRootLayout } from "./d
|
|
|
2
2
|
export { computeRouteDependencies, importFreshRouteModuleCandidate, rebuildDevRoute, refreshLayoutChain, renderDevISRWithLoaderCache, renderDevSSGWithLoaderCache, } from "./hmr.ts";
|
|
3
3
|
export { buildRouteMatcher, buildRouteRegex, collectIntermediateLayoutDirs, compareRouteSpecificity, compareRouteSpecificity as routeSpecificity, escapeRegExpChar, filePathToPattern, resolveMode, } from "./patterns.ts";
|
|
4
4
|
export { createDataEndpoint, createRoutePlugin } from "./plugin.ts";
|
|
5
|
-
export {
|
|
5
|
+
export { mergeRouteSchemas } from "./schema-merge.ts";
|
|
6
|
+
export { applySchemaDefaults, createSearchRouteMetadata, parseDataEndpointPath, } from "./schemas.ts";
|
|
6
7
|
export type { ResolvedRoute, RootLayout, SegmentBoundary } from "./types.ts";
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
scanPages,
|
|
5
|
-
compareRouteSpecificity2 as routeSpecificity,
|
|
6
|
-
resolveMode,
|
|
7
|
-
renderDevSSGWithLoaderCache,
|
|
8
|
-
renderDevISRWithLoaderCache,
|
|
9
|
-
refreshLayoutChain,
|
|
10
|
-
rebuildDevRoute,
|
|
11
|
-
parseDataEndpointPath,
|
|
12
|
-
mergeRouteSchemas,
|
|
13
|
-
loadProdRoutes,
|
|
14
|
-
importFreshRouteModuleCandidate,
|
|
15
|
-
filePathToPattern,
|
|
16
|
-
escapeRegExpChar,
|
|
17
|
-
createSearchRouteMetadata,
|
|
18
|
-
createRoutePlugin,
|
|
19
|
-
createDataEndpoint,
|
|
20
|
-
computeRouteDependencies,
|
|
21
|
-
compareRouteSpecificity,
|
|
22
|
-
collectRouteTags,
|
|
23
|
-
collectIntermediateLayoutDirs,
|
|
24
|
-
buildRouteRegex,
|
|
3
|
+
applySchemaDefaults,
|
|
25
4
|
buildRouteMatcher,
|
|
26
|
-
|
|
5
|
+
buildRouteRegex,
|
|
6
|
+
collectIntermediateLayoutDirs,
|
|
7
|
+
collectRouteTags,
|
|
8
|
+
compareRouteSpecificity,
|
|
9
|
+
computeRouteDependencies,
|
|
10
|
+
createDataEndpoint,
|
|
11
|
+
createRoutePlugin,
|
|
12
|
+
createSearchRouteMetadata,
|
|
13
|
+
escapeRegExpChar,
|
|
14
|
+
filePathToPattern,
|
|
15
|
+
importFreshRouteModuleCandidate,
|
|
16
|
+
loadProdRoutes,
|
|
17
|
+
mergeRouteSchemas,
|
|
18
|
+
parseDataEndpointPath,
|
|
19
|
+
rebuildDevRoute,
|
|
20
|
+
refreshLayoutChain,
|
|
21
|
+
renderDevISRWithLoaderCache,
|
|
22
|
+
renderDevSSGWithLoaderCache,
|
|
23
|
+
resolveMode,
|
|
24
|
+
compareRouteSpecificity2 as routeSpecificity,
|
|
25
|
+
scanPages,
|
|
26
|
+
scanRootLayout
|
|
27
27
|
};
|
|
@@ -19,10 +19,10 @@ export {
|
|
|
19
19
|
resolveMode,
|
|
20
20
|
} from "./patterns.ts";
|
|
21
21
|
export { createDataEndpoint, createRoutePlugin } from "./plugin.ts";
|
|
22
|
+
export { mergeRouteSchemas } from "./schema-merge.ts";
|
|
22
23
|
export {
|
|
23
24
|
applySchemaDefaults,
|
|
24
25
|
createSearchRouteMetadata,
|
|
25
|
-
mergeRouteSchemas,
|
|
26
26
|
parseDataEndpointPath,
|
|
27
27
|
} from "./schemas.ts";
|
|
28
28
|
export type { ResolvedRoute, RootLayout, SegmentBoundary } from "./types.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimePage, RuntimeRoute } from "../../client.ts";
|
|
1
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
2
|
export declare function collectIntermediateLayoutDirs(pagePath: string, rootPath: string): string[];
|
|
3
3
|
export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
|
|
4
4
|
export declare function filePathToPattern(path: string): string;
|
|
@@ -5,13 +5,10 @@ export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout
|
|
|
5
5
|
/**
|
|
6
6
|
* Elysia plugin that handles `GET /_furin/data?path=<logicalHref>`.
|
|
7
7
|
*
|
|
8
|
-
* Returns
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* serialising, so the client receives all data resolved in one round-trip.
|
|
13
|
-
* SPA navigation calls this endpoint via `parseDeferredNdjson` in
|
|
14
|
-
* `router-provider.tsx`.
|
|
8
|
+
* Returns route-frame loader data for successful routes. Deferred routes stream
|
|
9
|
+
* the initial sync frame first, then append one frame batch per settled Promise.
|
|
10
|
+
* SPA navigation calls this endpoint via `parseDeferredNdjson`, which supports
|
|
11
|
+
* both route frames and legacy NDJSON sentinels.
|
|
15
12
|
*
|
|
16
13
|
* Special fields emitted alongside data:
|
|
17
14
|
* - `__furinStatus: 404` — when the loader called `notFound()`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnySchema } from "elysia/types";
|
|
2
|
-
import type { RuntimeRoute } from "../../client.ts";
|
|
2
|
+
import type { RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
3
|
import { type SearchParamsInput, type SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
4
4
|
interface UnknownObject {
|
|
5
5
|
[key: string]: unknown;
|
|
@@ -28,6 +28,13 @@ export type ParseRouteQueryResult = {
|
|
|
28
28
|
errors: unknown;
|
|
29
29
|
ok: false;
|
|
30
30
|
};
|
|
31
|
+
export type ParseRouteParamsResult = {
|
|
32
|
+
ok: true;
|
|
33
|
+
params: UnknownObject;
|
|
34
|
+
} | {
|
|
35
|
+
errors: unknown;
|
|
36
|
+
ok: false;
|
|
37
|
+
};
|
|
31
38
|
/**
|
|
32
39
|
* Parses and validates a logical route URL's search string for the synthetic
|
|
33
40
|
* `/_furin/data` request path. This keeps SPA navigations aligned with the
|
|
@@ -37,15 +44,13 @@ export type ParseRouteQueryResult = {
|
|
|
37
44
|
*/
|
|
38
45
|
export declare function parseRouteQuery(url: URL, schema: AnySchema | undefined): Promise<ParseRouteQueryResult>;
|
|
39
46
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* merged with the same leaf-wins semantics so they are not silently dropped.
|
|
44
|
-
* Returns undefined when no entry in the chain defines the key.
|
|
47
|
+
* Validates and coerces path params for the synthetic `/_furin/data` request
|
|
48
|
+
* path. This mirrors the params schema installed by createRoutePlugin's Elysia
|
|
49
|
+
* guard so SPA loaders receive the same values as full SSR loaders.
|
|
45
50
|
*
|
|
46
51
|
* @internal Exported for unit testing.
|
|
47
52
|
*/
|
|
48
|
-
export declare function
|
|
53
|
+
export declare function parseRouteParams(params: UnknownObject, schema: AnySchema | undefined): Promise<ParseRouteParamsResult>;
|
|
49
54
|
export declare function createSearchRouteMetadata(routes: Array<{
|
|
50
55
|
pattern: string;
|
|
51
56
|
routeChain: RuntimeRoute[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimePage, RuntimeRoute } from "../../client.ts";
|
|
1
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
2
|
import type { ErrorComponent } from "../../shared/error.ts";
|
|
3
3
|
import type { NotFoundComponent } from "../../shared/not-found.ts";
|
|
4
4
|
/**
|
|
@@ -8,40 +8,48 @@ export interface BeginMutationInput {
|
|
|
8
8
|
key: string;
|
|
9
9
|
principal: string;
|
|
10
10
|
}
|
|
11
|
+
export interface MutationLease {
|
|
12
|
+
id: string;
|
|
13
|
+
key: string;
|
|
14
|
+
leaseMs: number;
|
|
15
|
+
principal: string;
|
|
16
|
+
}
|
|
11
17
|
export type BeginMutationResult = {
|
|
12
18
|
kind: "execute";
|
|
13
|
-
|
|
19
|
+
lease: MutationLease;
|
|
14
20
|
} | {
|
|
15
21
|
kind: "replay";
|
|
16
22
|
response: StoredResponse;
|
|
17
23
|
} | {
|
|
18
24
|
kind: "conflict";
|
|
19
25
|
reason: "in-progress" | "payload-mismatch";
|
|
26
|
+
};
|
|
27
|
+
export type SyncInvalidation = {
|
|
28
|
+
kind: "path";
|
|
29
|
+
path: string;
|
|
30
|
+
type: "layout" | "page";
|
|
20
31
|
} | {
|
|
21
|
-
kind: "
|
|
32
|
+
kind: "tags";
|
|
33
|
+
tags: readonly string[];
|
|
22
34
|
};
|
|
23
|
-
export interface
|
|
24
|
-
|
|
35
|
+
export interface CompleteMutationInput {
|
|
36
|
+
invalidations: readonly SyncInvalidation[];
|
|
37
|
+
lease: MutationLease;
|
|
25
38
|
response: StoredResponse;
|
|
26
39
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
export type CompleteMutationResult = {
|
|
41
|
+
cursor: string | undefined;
|
|
42
|
+
kind: "committed";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "lost";
|
|
45
|
+
};
|
|
30
46
|
export interface SyncChange {
|
|
31
47
|
cursor: string;
|
|
32
|
-
invalidations: readonly
|
|
33
|
-
}
|
|
34
|
-
export interface AppendChangesInput {
|
|
35
|
-
invalidations: readonly string[];
|
|
36
|
-
path: string;
|
|
37
|
-
}
|
|
38
|
-
export interface AppendChangesResult {
|
|
39
|
-
change: SyncChange;
|
|
48
|
+
invalidations: readonly SyncInvalidation[];
|
|
40
49
|
}
|
|
41
50
|
export interface ReadChangesInput {
|
|
42
51
|
after: string | undefined;
|
|
43
52
|
limit: number;
|
|
44
|
-
path: string;
|
|
45
53
|
}
|
|
46
54
|
export interface ChangePage {
|
|
47
55
|
changes: readonly SyncChange[];
|
|
@@ -49,14 +57,25 @@ export interface ChangePage {
|
|
|
49
57
|
hasMore: boolean;
|
|
50
58
|
reset: boolean;
|
|
51
59
|
}
|
|
52
|
-
export type SyncChangeListener = (change: SyncChange) => void;
|
|
53
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
54
60
|
export interface SyncAdapter {
|
|
55
|
-
abortMutation(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
readChanges(input: ReadChangesInput)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
abortMutation: (lease: MutationLease) => Promise<void>;
|
|
62
|
+
beginMutation: (input: BeginMutationInput) => Promise<BeginMutationResult>;
|
|
63
|
+
completeMutation: (input: CompleteMutationInput) => Promise<CompleteMutationResult>;
|
|
64
|
+
currentCursor: () => Promise<string>;
|
|
65
|
+
readChanges: (input: ReadChangesInput) => Promise<ChangePage>;
|
|
66
|
+
renewMutation: (lease: MutationLease) => Promise<"lost" | "renewed">;
|
|
67
|
+
readonly scope: "distributed" | "host-local" | "process-local";
|
|
68
|
+
}
|
|
69
|
+
export interface SyncSubscription {
|
|
70
|
+
unsubscribe: () => Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export interface SyncNotifier {
|
|
73
|
+
publish: (cursor: string) => Promise<void>;
|
|
74
|
+
subscribe: (listener: (cursor: string) => void) => Promise<SyncSubscription>;
|
|
75
|
+
}
|
|
76
|
+
export interface SyncRuntimeOptions {
|
|
77
|
+
adapter: SyncAdapter;
|
|
78
|
+
notifier?: SyncNotifier;
|
|
79
|
+
principal: (context: Context) => Promise<string> | string;
|
|
80
|
+
}
|
|
81
|
+
import type { Context } from "elysia";
|