@teyik0/furin 0.2.0-alpha.3 → 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/LICENSE +21 -21
- package/README.md +37 -33
- 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 +114 -109
- package/dist/build/entry-template.d.ts +35 -9
- package/dist/build/entry-template.ts +206 -156
- 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 +30 -36
- 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/client/link.js +163 -16
- package/dist/client/router/abort.d.ts +1 -0
- package/dist/client/router/sync-catch-up.d.ts +29 -0
- package/dist/config.d.ts +11 -2
- package/dist/config.js +5 -1
- package/dist/furin.d.ts +37 -19
- package/dist/furin.js +982 -378
- 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/adapter.d.ts +62 -0
- package/dist/server/sync/config.d.ts +11 -0
- package/dist/server/sync/fingerprint.d.ts +6 -0
- package/dist/server/sync/index.d.ts +2 -2
- package/dist/server/sync/memory-adapter.d.ts +17 -0
- package/dist/server/sync/plugin.d.ts +12 -195
- package/dist/server/sync/response.d.ts +4 -0
- package/dist/server/sync/stream.d.ts +24 -5
- package/dist/shared/prefix.d.ts +15 -0
- package/package.json +6 -1
- package/src/adapter/README.md +13 -13
- package/src/adapter/bun.ts +113 -50
- package/src/adapter/package.ts +206 -0
- package/src/build/client.ts +158 -152
- package/src/build/compile-entry.ts +114 -109
- package/src/build/entry-template.ts +206 -156
- package/src/build/hydrate.ts +342 -340
- package/src/build/index.ts +223 -152
- package/src/build/route-types.ts +145 -145
- package/src/build/scan-server.ts +111 -95
- package/src/build/server-routes-entry.ts +30 -36
- package/src/build/shared.ts +80 -80
- package/src/build/ssg-cache.ts +36 -32
- package/src/build/types.ts +125 -89
- package/src/cli/config.ts +9 -3
- package/src/cli/index.ts +21 -3
- package/src/client/router/abort.ts +5 -0
- package/src/client/router/link-utils.ts +184 -184
- package/src/client/router/provider.tsx +883 -804
- package/src/client/router/sync-catch-up.ts +113 -0
- package/src/client/router/types.ts +276 -276
- package/src/client/sync.ts +98 -98
- package/src/client.ts +369 -369
- package/src/config.ts +14 -1
- package/src/furin.ts +619 -465
- package/src/server/auto-invalidate/registry.ts +23 -1
- package/src/server/auto-invalidate/runtime.ts +159 -134
- 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/dev-page-plugin.ts +454 -454
- package/src/server/instance.ts +252 -0
- package/src/server/internal.ts +100 -5
- package/src/server/render/assemble.ts +160 -160
- package/src/server/render/isr.ts +323 -323
- package/src/server/render/not-found.ts +9 -3
- package/src/server/render/ssr.ts +603 -585
- package/src/server/render/template.ts +57 -24
- package/src/server/router/plugin.ts +384 -384
- package/src/server/sync/adapter.ts +65 -0
- package/src/server/sync/config.ts +60 -29
- package/src/server/sync/fingerprint.ts +44 -0
- package/src/server/sync/index.ts +15 -14
- package/src/server/sync/memory-adapter.ts +196 -0
- package/src/server/sync/plugin.ts +199 -108
- package/src/server/sync/response.ts +77 -0
- package/src/server/sync/stream.ts +162 -144
- package/src/shared/deferred-ndjson.ts +7 -0
- package/src/shared/prefix.ts +38 -0
package/dist/client/link.js
CHANGED
|
@@ -3278,6 +3278,11 @@ async function parseDeferredNdjson(stream, signal) {
|
|
|
3278
3278
|
});
|
|
3279
3279
|
}
|
|
3280
3280
|
}
|
|
3281
|
+
for (const promise of Object.values(deferredPromises)) {
|
|
3282
|
+
promise.catch(() => {
|
|
3283
|
+
return;
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3281
3286
|
if (deferredKeys.length === 0) {
|
|
3282
3287
|
cleanupAbortHandler();
|
|
3283
3288
|
try {
|
|
@@ -3345,6 +3350,11 @@ async function readDeferredLines(readLine, resolvers) {
|
|
|
3345
3350
|
}
|
|
3346
3351
|
}
|
|
3347
3352
|
|
|
3353
|
+
// src/client/router/abort.ts
|
|
3354
|
+
function isAbortError(error) {
|
|
3355
|
+
return error !== null && typeof error === "object" && "name" in error && error.name === "AbortError";
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3348
3358
|
// src/client/router/search-store.ts
|
|
3349
3359
|
import { createContext as createContext2 } from "react";
|
|
3350
3360
|
function searchSnapshotChanged(a, b) {
|
|
@@ -3473,6 +3483,78 @@ function detectStaticMode() {
|
|
|
3473
3483
|
return meta?.content === "static";
|
|
3474
3484
|
}
|
|
3475
3485
|
|
|
3486
|
+
// src/client/router/sync-catch-up.ts
|
|
3487
|
+
function createInvalidationRefresh(options) {
|
|
3488
|
+
let running;
|
|
3489
|
+
let requested = false;
|
|
3490
|
+
const refreshUntilCurrent = async () => {
|
|
3491
|
+
do {
|
|
3492
|
+
requested = false;
|
|
3493
|
+
try {
|
|
3494
|
+
await options.refresh();
|
|
3495
|
+
} catch (error) {
|
|
3496
|
+
if (!isAbortError(error)) {
|
|
3497
|
+
throw error;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
} while (requested);
|
|
3501
|
+
};
|
|
3502
|
+
return {
|
|
3503
|
+
run() {
|
|
3504
|
+
requested = true;
|
|
3505
|
+
if (!running) {
|
|
3506
|
+
running = refreshUntilCurrent().catch((error) => {
|
|
3507
|
+
if (!isAbortError(error)) {
|
|
3508
|
+
options.onError(error);
|
|
3509
|
+
}
|
|
3510
|
+
}).finally(() => {
|
|
3511
|
+
running = undefined;
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
return running;
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
function createSyncCatchUp(options) {
|
|
3519
|
+
let currentCursor;
|
|
3520
|
+
let running;
|
|
3521
|
+
let requested = false;
|
|
3522
|
+
const readUntilCurrent = async () => {
|
|
3523
|
+
do {
|
|
3524
|
+
requested = false;
|
|
3525
|
+
let page;
|
|
3526
|
+
do {
|
|
3527
|
+
page = await options.fetchPage(currentCursor ?? "0");
|
|
3528
|
+
if (page.reset) {
|
|
3529
|
+
options.onInvalidations(["/:layout"]);
|
|
3530
|
+
currentCursor = page.cursor;
|
|
3531
|
+
break;
|
|
3532
|
+
}
|
|
3533
|
+
for (const change of page.changes) {
|
|
3534
|
+
options.onInvalidations(change.invalidations);
|
|
3535
|
+
}
|
|
3536
|
+
currentCursor = page.cursor;
|
|
3537
|
+
} while (page.hasMore);
|
|
3538
|
+
} while (requested);
|
|
3539
|
+
};
|
|
3540
|
+
return {
|
|
3541
|
+
async initialize() {
|
|
3542
|
+
const page = await options.fetchPage(undefined);
|
|
3543
|
+
currentCursor = page.cursor;
|
|
3544
|
+
},
|
|
3545
|
+
catchUp() {
|
|
3546
|
+
requested = true;
|
|
3547
|
+
if (!running) {
|
|
3548
|
+
running = readUntilCurrent().finally(() => {
|
|
3549
|
+
running = undefined;
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
return running;
|
|
3553
|
+
},
|
|
3554
|
+
cursor: () => currentCursor
|
|
3555
|
+
};
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3476
3558
|
// src/client/router/provider.tsx
|
|
3477
3559
|
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
3478
3560
|
var EMPTY_SEARCH = {};
|
|
@@ -3627,7 +3709,13 @@ function RouterProvider({
|
|
|
3627
3709
|
}
|
|
3628
3710
|
return { match: loadedMatch, data, title, finalHref };
|
|
3629
3711
|
} catch (err) {
|
|
3630
|
-
|
|
3712
|
+
if (!isAbortError(err)) {
|
|
3713
|
+
_log.error({
|
|
3714
|
+
action: "navigate_failed",
|
|
3715
|
+
href: basePath + logicalHref,
|
|
3716
|
+
error: String(err)
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3631
3719
|
return null;
|
|
3632
3720
|
}
|
|
3633
3721
|
}, [routes, basePath, resolveNoMatchState]);
|
|
@@ -3773,6 +3861,12 @@ function RouterProvider({
|
|
|
3773
3861
|
invalidatePrefetch(logicalHref, "page");
|
|
3774
3862
|
await navigate(logicalHref, { replace: true, resetScroll: opts?.resetScroll ?? false });
|
|
3775
3863
|
}, [navigate, invalidatePrefetch, basePath]);
|
|
3864
|
+
const invalidationRefresh = useMemo(() => createInvalidationRefresh({
|
|
3865
|
+
onError: (error) => {
|
|
3866
|
+
_log.warn({ action: "sync_refresh_failed", error: String(error) });
|
|
3867
|
+
},
|
|
3868
|
+
refresh: () => refresh(undefined)
|
|
3869
|
+
}), [refresh]);
|
|
3776
3870
|
useEffect(() => {
|
|
3777
3871
|
if (typeof window !== "undefined") {
|
|
3778
3872
|
window.__FURIN_HMR_REFRESH__ = refresh;
|
|
@@ -3927,7 +4021,7 @@ function RouterProvider({
|
|
|
3927
4021
|
if (autoRefresh && invalidated.length > 0) {
|
|
3928
4022
|
const currentLogicalPath = normalizeHref(toLogical(window.location.pathname, basePath)) + window.location.search;
|
|
3929
4023
|
if (shouldAutoRefreshPath(currentLogicalPath, invalidated)) {
|
|
3930
|
-
|
|
4024
|
+
invalidationRefresh.run();
|
|
3931
4025
|
}
|
|
3932
4026
|
}
|
|
3933
4027
|
return response;
|
|
@@ -3937,23 +4031,20 @@ function RouterProvider({
|
|
|
3937
4031
|
return () => {
|
|
3938
4032
|
window.fetch = originalFetch;
|
|
3939
4033
|
};
|
|
3940
|
-
}, [invalidatePrefetch,
|
|
4034
|
+
}, [invalidatePrefetch, invalidationRefresh, autoRefresh, basePath]);
|
|
3941
4035
|
useEffect(() => {
|
|
3942
4036
|
if (!syncStream || typeof window === "undefined" || typeof EventSource === "undefined") {
|
|
3943
4037
|
return;
|
|
3944
4038
|
}
|
|
3945
4039
|
const streamUrl = syncStream.startsWith("/") ? `${basePath}${syncStream}` : `${basePath}/${syncStream}`;
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
payload = JSON.parse(event.data);
|
|
3951
|
-
} catch {
|
|
3952
|
-
_log.warn({ action: "sync_invalid_event", event: "furin.invalidate" });
|
|
4040
|
+
let source;
|
|
4041
|
+
let disposed = false;
|
|
4042
|
+
const applyInvalidations = (entries) => {
|
|
4043
|
+
if (disposed) {
|
|
3953
4044
|
return;
|
|
3954
4045
|
}
|
|
3955
4046
|
const invalidations = [];
|
|
3956
|
-
applyRevalidateEntries(
|
|
4047
|
+
applyRevalidateEntries(entries, (path, type) => {
|
|
3957
4048
|
const resolvedType = type ?? "page";
|
|
3958
4049
|
invalidatePrefetch(path, resolvedType);
|
|
3959
4050
|
invalidations.push({ path, type: resolvedType });
|
|
@@ -3961,16 +4052,72 @@ function RouterProvider({
|
|
|
3961
4052
|
if (autoRefresh && invalidations.length > 0) {
|
|
3962
4053
|
const currentLogicalPath = normalizeHref(toLogical(window.location.pathname, basePath)) + window.location.search;
|
|
3963
4054
|
if (shouldAutoRefreshPath(currentLogicalPath, invalidations)) {
|
|
3964
|
-
|
|
4055
|
+
invalidationRefresh.run();
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
};
|
|
4059
|
+
const catchUp = createSyncCatchUp({
|
|
4060
|
+
fetchPage: async (after) => {
|
|
4061
|
+
const url = new URL(`${streamUrl}/changes`, window.location.origin);
|
|
4062
|
+
if (after !== undefined) {
|
|
4063
|
+
url.searchParams.set("after", after);
|
|
3965
4064
|
}
|
|
4065
|
+
const response = await window.fetch(url);
|
|
4066
|
+
if (!response.ok) {
|
|
4067
|
+
throw new Error(`Sync catch-up failed with status ${response.status}`);
|
|
4068
|
+
}
|
|
4069
|
+
return await response.json();
|
|
4070
|
+
},
|
|
4071
|
+
onInvalidations: applyInvalidations
|
|
4072
|
+
});
|
|
4073
|
+
const recover = () => {
|
|
4074
|
+
if (disposed) {
|
|
4075
|
+
return;
|
|
3966
4076
|
}
|
|
4077
|
+
catchUp.catchUp().catch((error) => {
|
|
4078
|
+
if (!disposed) {
|
|
4079
|
+
_log.warn({ action: "sync_catch_up_failed", error: String(error) });
|
|
4080
|
+
}
|
|
4081
|
+
});
|
|
3967
4082
|
};
|
|
3968
|
-
|
|
4083
|
+
const onSync = (event) => {
|
|
4084
|
+
try {
|
|
4085
|
+
const payload = JSON.parse(event.data);
|
|
4086
|
+
if (typeof payload.cursor !== "string") {
|
|
4087
|
+
throw new Error("Missing sync cursor");
|
|
4088
|
+
}
|
|
4089
|
+
} catch {
|
|
4090
|
+
_log.warn({ action: "sync_invalid_event", event: "furin.sync" });
|
|
4091
|
+
return;
|
|
4092
|
+
}
|
|
4093
|
+
recover();
|
|
4094
|
+
};
|
|
4095
|
+
const connect = () => {
|
|
4096
|
+
if (disposed || source) {
|
|
4097
|
+
return;
|
|
4098
|
+
}
|
|
4099
|
+
source = new EventSource(streamUrl);
|
|
4100
|
+
source.addEventListener("furin.sync", onSync);
|
|
4101
|
+
};
|
|
4102
|
+
catchUp.initialize().then(() => {
|
|
4103
|
+
if (disposed) {
|
|
4104
|
+
return;
|
|
4105
|
+
}
|
|
4106
|
+
connect();
|
|
4107
|
+
recover();
|
|
4108
|
+
}).catch((error) => {
|
|
4109
|
+
if (disposed) {
|
|
4110
|
+
return;
|
|
4111
|
+
}
|
|
4112
|
+
_log.warn({ action: "sync_initialize_failed", error: String(error) });
|
|
4113
|
+
connect();
|
|
4114
|
+
});
|
|
3969
4115
|
return () => {
|
|
3970
|
-
|
|
3971
|
-
source.
|
|
4116
|
+
disposed = true;
|
|
4117
|
+
source?.removeEventListener("furin.sync", onSync);
|
|
4118
|
+
source?.close();
|
|
3972
4119
|
};
|
|
3973
|
-
}, [syncStream, basePath, invalidatePrefetch,
|
|
4120
|
+
}, [syncStream, basePath, invalidatePrefetch, invalidationRefresh, autoRefresh]);
|
|
3974
4121
|
let pageElement;
|
|
3975
4122
|
if (state.notFound || !state.match) {
|
|
3976
4123
|
pageElement = buildNotFoundPageElement(state.notFoundBoundaries ?? state.match?.segmentBoundaries ?? rootBoundaries, state.notFound ?? {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SyncChangePayload {
|
|
2
|
+
cursor: string;
|
|
3
|
+
invalidations: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface SyncChangePagePayload {
|
|
6
|
+
changes: readonly SyncChangePayload[];
|
|
7
|
+
cursor: string;
|
|
8
|
+
hasMore: boolean;
|
|
9
|
+
reset: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface SyncCatchUpOptions {
|
|
12
|
+
fetchPage: (after: string | undefined) => Promise<SyncChangePagePayload>;
|
|
13
|
+
onInvalidations: (invalidations: readonly string[]) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface SyncCatchUp {
|
|
16
|
+
catchUp(): Promise<void>;
|
|
17
|
+
cursor(): string | undefined;
|
|
18
|
+
initialize(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
interface InvalidationRefreshOptions {
|
|
21
|
+
onError: (error: unknown) => void;
|
|
22
|
+
refresh: () => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface InvalidationRefresh {
|
|
25
|
+
run(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createInvalidationRefresh(options: InvalidationRefreshOptions): InvalidationRefresh;
|
|
28
|
+
export declare function createSyncCatchUp(options: SyncCatchUpOptions): SyncCatchUp;
|
|
29
|
+
export {};
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BunPlugin } from "bun";
|
|
2
|
-
export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static"];
|
|
2
|
+
export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static", "package"];
|
|
3
3
|
export type BuildTarget = (typeof BUILD_TARGETS)[number];
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for the `static` build target.
|
|
@@ -29,6 +29,15 @@ export interface StaticExportConfig {
|
|
|
29
29
|
export declare const configSchema: import("@sinclair/typebox").TObject<{
|
|
30
30
|
rootDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
31
|
pagesDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
32
|
+
/**
|
|
33
|
+
* Multi-instance builds: one entry per mounted furin app. Overrides
|
|
34
|
+
* `pagesDir` and server-entry auto-detection. `prefix` must match the
|
|
35
|
+
* `furin({ prefix })` the app is mounted with (`""`/absent = root).
|
|
36
|
+
*/
|
|
37
|
+
apps: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
38
|
+
pagesDir: import("@sinclair/typebox").TString;
|
|
39
|
+
prefix: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
40
|
+
}>>>;
|
|
32
41
|
serverEntry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
42
|
/**
|
|
34
43
|
* Initialize the browser HTTP log drain in the hydration entry. Off by
|
|
@@ -37,7 +46,7 @@ export declare const configSchema: import("@sinclair/typebox").TObject<{
|
|
|
37
46
|
* via the `furin({ logger })` plugin option).
|
|
38
47
|
*/
|
|
39
48
|
clientLogging: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
40
|
-
targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "node" | "vercel" | "cloudflare" | "static">[]>>>;
|
|
49
|
+
targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "node" | "vercel" | "cloudflare" | "static" | "package">[]>>>;
|
|
41
50
|
bun: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
42
51
|
compile: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"server">, import("@sinclair/typebox").TLiteral<"embed">]>>;
|
|
43
52
|
}>>;
|
package/dist/config.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/config.ts
|
|
3
3
|
import { t } from "elysia";
|
|
4
|
-
var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static"];
|
|
4
|
+
var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static", "package"];
|
|
5
5
|
var buildTargetSchema = t.Union(BUILD_TARGETS.map((v) => t.Literal(v)));
|
|
6
6
|
var compileTargetSchema = t.Union([t.Literal("server"), t.Literal("embed")]);
|
|
7
7
|
var configSchema = t.Object({
|
|
8
8
|
rootDir: t.Optional(t.String()),
|
|
9
9
|
pagesDir: t.Optional(t.String()),
|
|
10
|
+
apps: t.Optional(t.Array(t.Object({
|
|
11
|
+
pagesDir: t.String(),
|
|
12
|
+
prefix: t.Optional(t.String())
|
|
13
|
+
}))),
|
|
10
14
|
serverEntry: t.Optional(t.String()),
|
|
11
15
|
clientLogging: t.Optional(t.Boolean()),
|
|
12
16
|
targets: t.Optional(t.Array(buildTargetSchema)),
|
package/dist/furin.d.ts
CHANGED
|
@@ -4,23 +4,16 @@ import { type FurinSyncOption } from "./server/sync/index.ts";
|
|
|
4
4
|
export interface FurinCacheTags {
|
|
5
5
|
}
|
|
6
6
|
export type CacheTag = keyof FurinCacheTags extends never ? string : keyof FurinCacheTags;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* .use(await furin({ ... }))
|
|
18
|
-
* .listen(3000)
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function furin({ pagesDir, logger, clientLogging, sync, }: {
|
|
22
|
-
pagesDir?: string;
|
|
23
|
-
logger?: EvlogElysiaOptions;
|
|
7
|
+
export { clientDirNameForPrefix } from "./shared/prefix.ts";
|
|
8
|
+
/** Options for the {@link furin} plugin. */
|
|
9
|
+
export interface FurinOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Production only: explicit directory holding this app's built client
|
|
12
|
+
* assets (chunks + index.html template). Packaged furin apps pass their own
|
|
13
|
+
* `dist/furin/client` here; when omitted the directory is auto-resolved
|
|
14
|
+
* next to the server artifact.
|
|
15
|
+
*/
|
|
16
|
+
clientDir?: string;
|
|
24
17
|
/**
|
|
25
18
|
* Initialize the browser HTTP log drain in the hydration entry. Off by
|
|
26
19
|
* default — enabling it adds `evlog/http` drain setup and points browser
|
|
@@ -28,13 +21,38 @@ export declare function furin({ pagesDir, logger, clientLogging, sync, }: {
|
|
|
28
21
|
* and unaffected.
|
|
29
22
|
*/
|
|
30
23
|
clientLogging?: boolean;
|
|
24
|
+
logger?: EvlogElysiaOptions;
|
|
25
|
+
pagesDir?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Mount prefix for this app, e.g. `"/admin"`. All pages, framework
|
|
28
|
+
* endpoints (`/_furin/*`) and client assets (`/_client/*`) are served under
|
|
29
|
+
* it, and the client bundle is built with the matching basePath. Defaults
|
|
30
|
+
* to `""` (root). Mounting two furin instances on the same prefix throws.
|
|
31
|
+
*/
|
|
32
|
+
prefix?: string;
|
|
31
33
|
/**
|
|
32
34
|
* Enables Furin's built-in sync event stream. The opinionated default mounts
|
|
33
35
|
* Server-Sent Events at `/_furin/sync`; pass an object only for constrained
|
|
34
36
|
* reverse-proxy deployments that need a custom internal path.
|
|
35
37
|
*/
|
|
36
38
|
sync?: FurinSyncOption;
|
|
37
|
-
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Main Furin plugin.
|
|
42
|
+
*
|
|
43
|
+
* Returns a standalone Elysia instance (async function) so that routes are
|
|
44
|
+
* properly registered in Elysia's router for SPA navigation to work.
|
|
45
|
+
*
|
|
46
|
+
* ## Usage
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* new Elysia()
|
|
50
|
+
* .use(await furin({ pagesDir: "./src/pages" }))
|
|
51
|
+
* .use(await furin({ pagesDir: "./src/admin", prefix: "/admin" }))
|
|
52
|
+
* .listen(3000)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function furin({ pagesDir, prefix: rawPrefix, clientDir: explicitClientDir, logger, clientLogging, sync, }?: FurinOptions): Promise<Elysia<"", {
|
|
38
56
|
decorator: {};
|
|
39
57
|
store: {};
|
|
40
58
|
derive: {};
|
|
@@ -70,7 +88,7 @@ export { furinInvalidate, revalidateTag } from "./server/auto-invalidate/index.t
|
|
|
70
88
|
export { revalidatePath, setCachePurger } from "./server/cache/invalidation.ts";
|
|
71
89
|
export { buildElement, buildErrorElement, renderRootNotFound } from "./server/render/index.ts";
|
|
72
90
|
export type { ResolvedRoute, SegmentBoundary } from "./server/router/index.ts";
|
|
73
|
-
export { furinSync, type SyncInput } from "./server/sync/index.ts";
|
|
91
|
+
export { furinSync, type SyncInput, type SyncRouteOption } from "./server/sync/index.ts";
|
|
74
92
|
export { Await, useAsyncError, useAsyncValue } from "./shared/await.tsx";
|
|
75
93
|
export type { ErrorComponent, ErrorProps } from "./shared/error.ts";
|
|
76
94
|
export type { NotFoundComponent, NotFoundOptions, NotFoundProps, } from "./shared/not-found.ts";
|