@teyik0/furin 0.2.0-alpha.4 → 0.2.0-alpha.5
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 +17 -1
- package/dist/adapter/package.d.ts +26 -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 +35 -9
- package/dist/build/entry-template.ts +106 -56
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.js +643 -247
- 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 +36 -1
- package/dist/cli/config.d.ts +6 -1
- package/dist/cli/index.js +662 -260
- package/dist/config.d.ts +11 -2
- package/dist/config.js +5 -1
- package/dist/furin.d.ts +36 -18
- package/dist/furin.js +630 -310
- package/dist/server/auto-invalidate/registry.d.ts +8 -1
- package/dist/server/cache/dev-loader.d.ts +3 -2
- package/dist/server/cache/invalidation.d.ts +19 -0
- package/dist/server/cache/isr.d.ts +6 -2
- package/dist/server/cache/registry.d.ts +3 -3
- package/dist/server/cache/ssg.d.ts +6 -2
- package/dist/server/cache/store-view.d.ts +11 -0
- package/dist/server/instance.d.ts +86 -0
- package/dist/server/internal.d.ts +16 -1
- package/dist/server/internal.js +72 -5
- package/dist/server/render/template.d.ts +3 -2
- package/dist/server/sync/config.d.ts +11 -0
- package/dist/server/sync/stream.d.ts +8 -1
- package/dist/shared/prefix.d.ts +15 -0
- package/package.json +6 -1
- package/src/adapter/bun.ts +113 -50
- package/src/adapter/package.ts +206 -0
- package/src/build/client.ts +9 -3
- package/src/build/compile-entry.ts +88 -83
- package/src/build/entry-template.ts +106 -56
- package/src/build/hydrate.ts +4 -2
- package/src/build/index.ts +99 -28
- package/src/build/scan-server.ts +23 -7
- package/src/build/server-routes-entry.ts +5 -11
- package/src/build/ssg-cache.ts +6 -2
- package/src/build/types.ts +37 -1
- package/src/cli/config.ts +9 -3
- package/src/cli/index.ts +21 -3
- package/src/config.ts +14 -1
- package/src/furin.ts +297 -143
- package/src/server/auto-invalidate/registry.ts +23 -1
- package/src/server/auto-invalidate/runtime.ts +29 -4
- package/src/server/cache/dev-loader.ts +77 -38
- package/src/server/cache/invalidation.ts +71 -30
- package/src/server/cache/isr.ts +20 -5
- package/src/server/cache/registry.ts +17 -20
- package/src/server/cache/ssg.ts +19 -4
- package/src/server/cache/store-view.ts +30 -0
- package/src/server/instance.ts +252 -0
- package/src/server/internal.ts +100 -5
- package/src/server/render/not-found.ts +9 -3
- package/src/server/render/ssr.ts +16 -4
- package/src/server/render/template.ts +57 -24
- package/src/server/sync/config.ts +32 -1
- package/src/server/sync/plugin.ts +4 -5
- package/src/server/sync/stream.ts +19 -9
- package/src/shared/prefix.ts +38 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
export declare class AutoInvalidateRegistry {
|
|
2
3
|
private readonly pathToTags;
|
|
3
4
|
private readonly tagToPaths;
|
|
@@ -6,4 +7,10 @@ export declare class AutoInvalidateRegistry {
|
|
|
6
7
|
unregisterPath(urlPath: string): void;
|
|
7
8
|
reset(): void;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
/** The current furin instance's registry (see server/instance.ts). */
|
|
11
|
+
export declare function getAutoInvalidateRegistry(instance?: FurinInstance): AutoInvalidateRegistry;
|
|
12
|
+
/**
|
|
13
|
+
* Instance-scoped facade kept under the historical singleton name so call
|
|
14
|
+
* sites read the same — every method resolves the current instance's registry.
|
|
15
|
+
*/
|
|
16
|
+
export declare const autoInvalidateRegistry: Pick<AutoInvalidateRegistry, "registerLoaderTags" | "pathsForTags" | "unregisterPath" | "reset">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
import { type RevalidateType } from "./route-cache";
|
|
2
3
|
export interface DevLoaderCacheEntry {
|
|
3
4
|
dependencies: string[];
|
|
@@ -12,8 +13,6 @@ export interface InvalidateOutcome {
|
|
|
12
13
|
isr: number;
|
|
13
14
|
ssg: number;
|
|
14
15
|
}
|
|
15
|
-
export declare const devISRLoaderCache: import("./route-cache").Cache<DevLoaderCacheEntry>;
|
|
16
|
-
export declare const devSSGLoaderCache: import("./route-cache").Cache<DevLoaderCacheEntry>;
|
|
17
16
|
export declare function getDevISRLoaderCache(key: string): DevLoaderCacheEntry | undefined;
|
|
18
17
|
export declare function setDevISRLoaderCache(key: string, entry: DevLoaderCacheEntry): void;
|
|
19
18
|
export declare function getDevSSGLoaderCache(key: string): DevLoaderCacheEntry | undefined;
|
|
@@ -25,4 +24,6 @@ export declare function isDevLoaderCacheFresh(entry: DevLoaderCacheEntry): boole
|
|
|
25
24
|
export declare function isDevLoaderCacheValid(entry: DevLoaderCacheEntry): boolean;
|
|
26
25
|
export declare function getAllDevISRLoaderEntries(): [string, DevLoaderCacheEntry][];
|
|
27
26
|
export declare function getAllDevSSGLoaderEntries(): [string, DevLoaderCacheEntry][];
|
|
27
|
+
/** @internal — clears dev loader caches for `instance` (default: current). */
|
|
28
|
+
export declare function clearDevLoaderCaches(instance?: FurinInstance): void;
|
|
28
29
|
export declare function __resetDevLoaderCacheState(): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
import type { RevalidateType } from "./route-cache";
|
|
2
3
|
export declare function setBuildId(id: string): void;
|
|
3
4
|
export declare function getBuildId(): string;
|
|
@@ -6,7 +7,25 @@ export declare function consumePendingInvalidations(): string[];
|
|
|
6
7
|
type CachePurger = (paths: string[]) => Promise<void>;
|
|
7
8
|
export declare function setCachePurger(fn: CachePurger): void;
|
|
8
9
|
export declare function callCachePurger(paths: string[]): void;
|
|
10
|
+
/**
|
|
11
|
+
* Invalidates `path` across EVERY mounted furin instance — paths are logical
|
|
12
|
+
* (unprefixed), and with shared data two apps can legitimately render the same
|
|
13
|
+
* logical path. This mirrors the historical shared-cache behaviour. Each
|
|
14
|
+
* instance's invalidation runs inside its own scope so cache `onDelete` hooks
|
|
15
|
+
* (auto-invalidate unregistration) hit the owning instance's registry.
|
|
16
|
+
*/
|
|
9
17
|
export declare function revalidatePath(path: string, type: RevalidateType): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Invalidates `path` against a SINGLE instance's caches. `revalidateTag` uses
|
|
20
|
+
* this because it knows which instance registered each path — the cross-app
|
|
21
|
+
* fan-out of `revalidatePath` would also evict a sibling app's unrelated page
|
|
22
|
+
* that merely shares the pathname. Does NOT call the CDN purger; callers
|
|
23
|
+
* batch the returned `purgedPaths` themselves.
|
|
24
|
+
*/
|
|
25
|
+
export declare function revalidatePathForInstance(instance: FurinInstance, path: string, type: RevalidateType): {
|
|
26
|
+
deleted: boolean;
|
|
27
|
+
purgedPaths: string[];
|
|
28
|
+
};
|
|
10
29
|
/** @internal — resets all module state between tests */
|
|
11
30
|
export declare function __resetCacheState(): void;
|
|
12
31
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
import { type ISRCacheEntry } from "./isr-ssg";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
import type { Cache } from "./route-cache";
|
|
4
|
+
import { type StoreView } from "./store-view";
|
|
5
|
+
export declare function isrRouteCache(instance?: FurinInstance): Cache<ISRCacheEntry>;
|
|
6
|
+
/** Raw store view over the current instance's ISR cache. */
|
|
7
|
+
export declare const isrCache: StoreView<ISRCacheEntry>;
|
|
4
8
|
export declare function getISRCache(key: string): ISRCacheEntry | undefined;
|
|
5
9
|
export declare function deleteISRCache(key: string): boolean;
|
|
6
10
|
export declare function setISRCache(key: string, entry: ISRCacheEntry): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
import type { Cache } from "./route-cache";
|
|
2
3
|
export type CacheInvalidator = Pick<Cache<unknown>, "invalidatePath" | "name">;
|
|
3
|
-
export declare function registerCacheInvalidator(invalidator: CacheInvalidator): () => void;
|
|
4
|
-
export declare function getCacheInvalidators(): IterableIterator<CacheInvalidator>;
|
|
5
|
-
export declare function clearCacheInvalidators(): void;
|
|
4
|
+
export declare function registerCacheInvalidator(invalidator: CacheInvalidator, instance?: FurinInstance): () => void;
|
|
5
|
+
export declare function getCacheInvalidators(instance?: FurinInstance): IterableIterator<CacheInvalidator>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
1
2
|
import { type SsgCacheEntry } from "./isr-ssg";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
import type { Cache } from "./route-cache";
|
|
4
|
+
import { type StoreView } from "./store-view";
|
|
5
|
+
export declare function ssgRouteCache(instance?: FurinInstance): Cache<SsgCacheEntry>;
|
|
6
|
+
/** Raw store view over the current instance's SSG cache. */
|
|
7
|
+
export declare const ssgCache: StoreView<SsgCacheEntry>;
|
|
4
8
|
export declare function getSSGCache(key: string): SsgCacheEntry | undefined;
|
|
5
9
|
export declare function setSSGCache(key: string, entry: SsgCacheEntry): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface StoreView<Entry> {
|
|
2
|
+
clear(): void;
|
|
3
|
+
delete(key: string): boolean;
|
|
4
|
+
entries(): IterableIterator<[string, Entry]>;
|
|
5
|
+
get(key: string): Entry | undefined;
|
|
6
|
+
has(key: string): boolean;
|
|
7
|
+
keys(): IterableIterator<string>;
|
|
8
|
+
set(key: string, entry: Entry): void;
|
|
9
|
+
readonly size: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function createStoreView<Entry>(resolve: () => Map<string, Entry>): StoreView<Entry>;
|
|
@@ -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;
|
|
@@ -12,6 +12,8 @@ export interface CompileContext {
|
|
|
12
12
|
buildId?: string;
|
|
13
13
|
embedded?: EmbeddedAppData;
|
|
14
14
|
modules: Record<string, unknown>;
|
|
15
|
+
/** Mount prefix this app was built for (`""` = root). */
|
|
16
|
+
prefix?: string;
|
|
15
17
|
/** Root-level conventions discovered at compile time. */
|
|
16
18
|
rootConventions?: {
|
|
17
19
|
errorPath?: string;
|
|
@@ -31,5 +33,18 @@ export interface CompileContext {
|
|
|
31
33
|
ssgCache?: Record<string, SsgCacheEntry>;
|
|
32
34
|
}
|
|
33
35
|
export declare function __setCompileContext(ctx: CompileContext): void;
|
|
34
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Looks up the compile context for a (pagesDir, prefix) mount. Resolution
|
|
38
|
+
* order, from most to least specific:
|
|
39
|
+
* 1. exact (pagesDir, prefix) key — distinguishes the same app mounted twice;
|
|
40
|
+
* 2. sole context registered for `pagesDir` — callers that don't pass a
|
|
41
|
+
* prefix, and contexts emitted before the prefix field existed;
|
|
42
|
+
* 3. sole context registered for `prefix` — deployed binaries run from a
|
|
43
|
+
* different cwd than the build, so the absolute pagesDir key misses there,
|
|
44
|
+
* but the mount prefix is stable across machines;
|
|
45
|
+
* 4. the sole registered context (single-app back-compat).
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCompileContext(pagesDir?: string, prefix?: string): CompileContext | null;
|
|
48
|
+
/** All registered contexts, keyed by the composite (pagesDir, prefix) key. */
|
|
49
|
+
export declare function getAllCompileContexts(): ReadonlyMap<string, CompileContext>;
|
|
35
50
|
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
|
getCompileContext,
|
|
81
|
+
getAllCompileContexts,
|
|
15
82
|
__setCompileContext,
|
|
16
83
|
__resetCompileContext
|
|
17
84
|
};
|
|
@@ -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;
|
|
@@ -2,5 +2,16 @@ export type FurinSyncOption = boolean | {
|
|
|
2
2
|
streamPath?: string;
|
|
3
3
|
};
|
|
4
4
|
export declare function resolveSyncStreamPath(sync: FurinSyncOption | undefined): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Logical (unprefixed) sync stream path for the current request — injected
|
|
7
|
+
* into rendered HTML; the client prepends its own basePath before connecting.
|
|
8
|
+
*/
|
|
5
9
|
export declare function getSyncStreamPath(): string | undefined;
|
|
6
10
|
export declare function runWithSyncStreamPath<T>(path: string | undefined, fn: () => T): T;
|
|
11
|
+
/**
|
|
12
|
+
* Physical adapter channels a sync publication must reach. An explicit
|
|
13
|
+
* override wins (historical single-channel behaviour); otherwise every
|
|
14
|
+
* sync-enabled instance gets notified — a mutation on a shared API must wake
|
|
15
|
+
* the SSE clients of every mounted app.
|
|
16
|
+
*/
|
|
17
|
+
export declare function syncPublishChannels(): string[];
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
2
|
export type { ChangePage as SyncChangePage, SyncChange } from "./adapter.ts";
|
|
3
3
|
export declare function publishSyncInvalidation(invalidations: readonly string[]): void;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Builds the SSE plugin serving one instance's sync stream. Routes are
|
|
6
|
+
* registered at the logical `path` (the parent instance's Elysia prefix makes
|
|
7
|
+
* them physical); `channel` is the adapter key the stream reads from — pass
|
|
8
|
+
* the PHYSICAL path (`prefix + path`) so two mounted apps never share a
|
|
9
|
+
* cursor sequence.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSyncStreamPlugin(path?: string, channel?: string): Elysia<"", {
|
|
5
12
|
decorator: {};
|
|
6
13
|
store: {};
|
|
7
14
|
derive: {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-disk client dir name for a mounted app: the root instance keeps the
|
|
3
|
+
* historical `client/`, prefixed instances get `client-<slug>/` next to it.
|
|
4
|
+
*/
|
|
5
|
+
export declare function clientDirNameForPrefix(prefix: string): string;
|
|
6
|
+
/** Filesystem-safe slug for a mount prefix (`/admin/v2` → `admin-v2`). */
|
|
7
|
+
export declare function prefixSlug(prefix: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* `prefixSlug` is NOT injective: `/a-b` and `/a/b` both slug to `a-b`, so two
|
|
10
|
+
* distinct prefixes can claim the same client dir and silently overwrite each
|
|
11
|
+
* other's build output. A readable injective encoding is ambiguous anyway
|
|
12
|
+
* (escaping `-` as `--` still confuses `/a-/b` with `/a/-b`), so we detect the
|
|
13
|
+
* collision and fail fast instead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertNoPrefixSlugCollisions(prefixes: string[]): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.5",
|
|
4
4
|
"description": "React meta-framework powered by Elysia and Bun with file-based routing, SSR, SSG, and ISR.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "teyik0",
|
|
@@ -84,6 +84,11 @@
|
|
|
84
84
|
"./env": {
|
|
85
85
|
"types": "./dist/env.d.ts",
|
|
86
86
|
"bun": "./src/env.d.ts"
|
|
87
|
+
},
|
|
88
|
+
"./internal": {
|
|
89
|
+
"types": "./dist/server/internal.d.ts",
|
|
90
|
+
"bun": "./src/server/internal.ts",
|
|
91
|
+
"import": "./dist/server/internal.js"
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
"scripts": {
|