@rsc-kit/core 0.1.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 +95 -0
- package/SECURITY.md +60 -0
- package/dist/action.d.ts +90 -0
- package/dist/action.d.ts.map +1 -0
- package/dist/action.js +137 -0
- package/dist/action.js.map +1 -0
- package/dist/build-rsc-vite.d.ts +39 -0
- package/dist/build-rsc-vite.d.ts.map +1 -0
- package/dist/build-rsc-vite.js +172 -0
- package/dist/build-rsc-vite.js.map +1 -0
- package/dist/cache.d.ts +25 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +108 -0
- package/dist/cache.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +85 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile.d.ts +55 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +141 -0
- package/dist/compile.js.map +1 -0
- package/dist/devServer.d.ts +18 -0
- package/dist/devServer.d.ts.map +1 -0
- package/dist/devServer.js +70 -0
- package/dist/devServer.js.map +1 -0
- package/dist/devUrls.d.ts +11 -0
- package/dist/devUrls.d.ts.map +1 -0
- package/dist/devUrls.js +68 -0
- package/dist/devUrls.js.map +1 -0
- package/dist/embed.d.ts +21 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +119 -0
- package/dist/embed.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/export.d.ts +41 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +100 -0
- package/dist/export.js.map +1 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +146 -0
- package/dist/files.js.map +1 -0
- package/dist/headers.d.ts +81 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +96 -0
- package/dist/headers.js.map +1 -0
- package/dist/host.d.ts +86 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +590 -0
- package/dist/host.js.map +1 -0
- package/dist/js/ActivityRouter.d.ts +47 -0
- package/dist/js/ActivityRouter.d.ts.map +1 -0
- package/dist/js/ActivityRouter.js +87 -0
- package/dist/js/ActivityRouter.js.map +1 -0
- package/dist/js/DocumentTitle.d.ts +22 -0
- package/dist/js/DocumentTitle.d.ts.map +1 -0
- package/dist/js/DocumentTitle.js +28 -0
- package/dist/js/DocumentTitle.js.map +1 -0
- package/dist/js/Form.d.ts +54 -0
- package/dist/js/Form.d.ts.map +1 -0
- package/dist/js/Form.js +225 -0
- package/dist/js/Form.js.map +1 -0
- package/dist/js/Link.d.ts +29 -0
- package/dist/js/Link.d.ts.map +1 -0
- package/dist/js/Link.js +112 -0
- package/dist/js/Link.js.map +1 -0
- package/dist/js/PathnameProvider.d.ts +8 -0
- package/dist/js/PathnameProvider.d.ts.map +1 -0
- package/dist/js/PathnameProvider.js +24 -0
- package/dist/js/PathnameProvider.js.map +1 -0
- package/dist/js/RedirectBoundary.d.ts +18 -0
- package/dist/js/RedirectBoundary.d.ts.map +1 -0
- package/dist/js/RedirectBoundary.js +34 -0
- package/dist/js/RedirectBoundary.js.map +1 -0
- package/dist/js/SegmentBoundary.d.ts +8 -0
- package/dist/js/SegmentBoundary.d.ts.map +1 -0
- package/dist/js/SegmentBoundary.js +38 -0
- package/dist/js/SegmentBoundary.js.map +1 -0
- package/dist/js/SlotBoundary.d.ts +15 -0
- package/dist/js/SlotBoundary.d.ts.map +1 -0
- package/dist/js/SlotBoundary.js +17 -0
- package/dist/js/SlotBoundary.js.map +1 -0
- package/dist/js/createViteRscApp.d.ts +8 -0
- package/dist/js/createViteRscApp.d.ts.map +1 -0
- package/dist/js/createViteRscApp.js +185 -0
- package/dist/js/createViteRscApp.js.map +1 -0
- package/dist/js/errors.d.ts +51 -0
- package/dist/js/errors.d.ts.map +1 -0
- package/dist/js/errors.js +93 -0
- package/dist/js/errors.js.map +1 -0
- package/dist/js/navigate.d.ts +118 -0
- package/dist/js/navigate.d.ts.map +1 -0
- package/dist/js/navigate.js +780 -0
- package/dist/js/navigate.js.map +1 -0
- package/dist/js/onlineStore.d.ts +23 -0
- package/dist/js/onlineStore.d.ts.map +1 -0
- package/dist/js/onlineStore.js +42 -0
- package/dist/js/onlineStore.js.map +1 -0
- package/dist/js/pagePayload.d.ts +15 -0
- package/dist/js/pagePayload.d.ts.map +1 -0
- package/dist/js/pagePayload.js +39 -0
- package/dist/js/pagePayload.js.map +1 -0
- package/dist/js/router.d.ts +29 -0
- package/dist/js/router.d.ts.map +1 -0
- package/dist/js/router.js +40 -0
- package/dist/js/router.js.map +1 -0
- package/dist/js/section.d.ts +16 -0
- package/dist/js/section.d.ts.map +1 -0
- package/dist/js/section.js +55 -0
- package/dist/js/section.js.map +1 -0
- package/dist/js/segmentStore.d.ts +69 -0
- package/dist/js/segmentStore.d.ts.map +1 -0
- package/dist/js/segmentStore.js +127 -0
- package/dist/js/segmentStore.js.map +1 -0
- package/dist/js/slotStore.d.ts +35 -0
- package/dist/js/slotStore.d.ts.map +1 -0
- package/dist/js/slotStore.js +46 -0
- package/dist/js/slotStore.js.map +1 -0
- package/dist/js/standardSchema.d.ts +47 -0
- package/dist/js/standardSchema.d.ts.map +1 -0
- package/dist/js/standardSchema.js +41 -0
- package/dist/js/standardSchema.js.map +1 -0
- package/dist/js/useForm.d.ts +43 -0
- package/dist/js/useForm.d.ts.map +1 -0
- package/dist/js/useForm.js +164 -0
- package/dist/js/useForm.js.map +1 -0
- package/dist/js/useLinkStatus.d.ts +2 -0
- package/dist/js/useLinkStatus.d.ts.map +1 -0
- package/dist/js/useLinkStatus.js +3 -0
- package/dist/js/useLinkStatus.js.map +1 -0
- package/dist/js/useOnline.d.ts +8 -0
- package/dist/js/useOnline.d.ts.map +1 -0
- package/dist/js/useOnline.js +20 -0
- package/dist/js/useOnline.js.map +1 -0
- package/dist/js/usePathname.d.ts +9 -0
- package/dist/js/usePathname.d.ts.map +1 -0
- package/dist/js/usePathname.js +32 -0
- package/dist/js/usePathname.js.map +1 -0
- package/dist/js/useSearchParams.d.ts +2 -0
- package/dist/js/useSearchParams.d.ts.map +1 -0
- package/dist/js/useSearchParams.js +60 -0
- package/dist/js/useSearchParams.js.map +1 -0
- package/dist/manifest.d.ts +66 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +13 -0
- package/dist/manifest.js.map +1 -0
- package/dist/prerender.d.ts +138 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +387 -0
- package/dist/prerender.js.map +1 -0
- package/dist/redirect.d.ts +34 -0
- package/dist/redirect.d.ts.map +1 -0
- package/dist/redirect.js +108 -0
- package/dist/redirect.js.map +1 -0
- package/dist/redirectDigest.d.ts +20 -0
- package/dist/redirectDigest.d.ts.map +1 -0
- package/dist/redirectDigest.js +66 -0
- package/dist/redirectDigest.js.map +1 -0
- package/dist/request.d.ts +93 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +308 -0
- package/dist/request.js.map +1 -0
- package/dist/revalidate.d.ts +43 -0
- package/dist/revalidate.d.ts.map +1 -0
- package/dist/revalidate.js +99 -0
- package/dist/revalidate.js.map +1 -0
- package/dist/routes.d.ts +37 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +28 -0
- package/dist/routes.js.map +1 -0
- package/dist/routing.d.ts +52 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +146 -0
- package/dist/routing.js.map +1 -0
- package/dist/runtime.d.ts +36 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +86 -0
- package/dist/runtime.js.map +1 -0
- package/dist/safeUrl.d.ts +10 -0
- package/dist/safeUrl.d.ts.map +1 -0
- package/dist/safeUrl.js +40 -0
- package/dist/safeUrl.js.map +1 -0
- package/dist/streaming.d.ts +62 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +108 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/vite.d.ts +109 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +1909 -0
- package/dist/vite.js.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +863 -0
- package/dist/worker.js.map +1 -0
- package/package.json +223 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core SPA navigation engine for RSC.
|
|
3
|
+
*
|
|
4
|
+
* Uses module-level state (singleton in the browser bundle).
|
|
5
|
+
* The Flight deserializer is injected by createViteRscApp to avoid
|
|
6
|
+
* duplicate bundling of react-server-dom-webpack.
|
|
7
|
+
*/
|
|
8
|
+
import type { Href } from '../routes.js';
|
|
9
|
+
import type { ManifestRoute } from "../manifest";
|
|
10
|
+
type ReactNode = unknown;
|
|
11
|
+
type Deserializer = (stream: ReadableStream, options: Record<string, unknown>) => Promise<ReactNode>;
|
|
12
|
+
type CallServerFn = (id: string, args: unknown[]) => Promise<unknown>;
|
|
13
|
+
interface InterceptEntry {
|
|
14
|
+
urlPattern: string;
|
|
15
|
+
slot: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function setStaticRoutes(routes: ManifestRoute[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* The layout chain of the page loaded from a file, since no header said.
|
|
20
|
+
*
|
|
21
|
+
* Without this the client believes it holds nothing, every navigation asks
|
|
22
|
+
* for a whole document, and the depth variants sitting beside it are never
|
|
23
|
+
* requested — the export looks correct and retention silently never happens.
|
|
24
|
+
*/
|
|
25
|
+
export declare function seedStaticChain(url: string): boolean;
|
|
26
|
+
export declare function setStaticPayloads(suffix: string | null): void;
|
|
27
|
+
/** The url to request a payload from, which is the page's own unless exported. */
|
|
28
|
+
export declare function payloadUrl(url: string, held?: string[]): string;
|
|
29
|
+
export declare function setVersion(v: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* The layout chain the client is holding.
|
|
32
|
+
*
|
|
33
|
+
* Seeded from the initial page's response and updated on every navigation, so
|
|
34
|
+
* the next request can say what is already mounted.
|
|
35
|
+
*/
|
|
36
|
+
export declare function setHeldLayouts(chain: string[]): void;
|
|
37
|
+
export declare function getHeldLayouts(): string[];
|
|
38
|
+
export declare function setNavigateHandler(fn: (tree: ReactNode, key: string, segmentDepth: number) => void): void;
|
|
39
|
+
/**
|
|
40
|
+
* How the router reveals a page that is still mounted behind the current one.
|
|
41
|
+
*
|
|
42
|
+
* Returning true means the page was restored with its client state intact and
|
|
43
|
+
* no request was made.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setRestoreHandler(fn: (key: string) => boolean): void;
|
|
46
|
+
export declare function setDeserializer(fn: Deserializer): void;
|
|
47
|
+
export declare function setCallServer(fn: CallServerFn): void;
|
|
48
|
+
export declare function setInterceptManifest(entries: InterceptEntry[]): void;
|
|
49
|
+
export declare function renderTree(tree: ReactNode): void;
|
|
50
|
+
/**
|
|
51
|
+
* Identity of a page for retention purposes.
|
|
52
|
+
*
|
|
53
|
+
* Path and query only: a hash is a position within the same page, and an
|
|
54
|
+
* intercepted route is a different rendering of the same URL, so it retains
|
|
55
|
+
* separately from the full page.
|
|
56
|
+
*/
|
|
57
|
+
export declare function retentionKey(url: string, interceptSlot: string | null): string;
|
|
58
|
+
export declare function getCallServer(): CallServerFn;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a navigation to this url would be served from the prefetch cache.
|
|
61
|
+
*
|
|
62
|
+
* Lets a caller decide whether showing an already-fetched page is free. A form
|
|
63
|
+
* uses it to put its target route's shell on screen while the real query runs:
|
|
64
|
+
* worth doing when the shell is in hand, never worth an extra request.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isPrefetched(url: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Go to a url, the way a Link does.
|
|
69
|
+
*
|
|
70
|
+
* `url` is typed to the routes the build found; cast with `as Href` when the
|
|
71
|
+
* destination is computed rather than written.
|
|
72
|
+
*/
|
|
73
|
+
export declare function navigate(url: Href, opts?: {
|
|
74
|
+
replace?: boolean;
|
|
75
|
+
preserveScroll?: boolean;
|
|
76
|
+
restore?: boolean;
|
|
77
|
+
/** Internal: how many redirects led here. */
|
|
78
|
+
redirectsFollowed?: number;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Put something the server re-rendered on screen.
|
|
82
|
+
*
|
|
83
|
+
* The trees arrive with an action's answer rather than being fetched, so this
|
|
84
|
+
* is the same apply path a navigation uses — without a request, a url change
|
|
85
|
+
* or a history entry.
|
|
86
|
+
*/
|
|
87
|
+
export declare function applyRevalidated(target: string, tree: ReactNode): void;
|
|
88
|
+
/**
|
|
89
|
+
* Ask the server for part of this page again.
|
|
90
|
+
*
|
|
91
|
+
* refresh() the page, leaving the layouts mounted
|
|
92
|
+
* refresh('all') the whole document, layouts included
|
|
93
|
+
* refresh('orders') one parallel slot, by the name its directory gave it
|
|
94
|
+
*
|
|
95
|
+
* The same words an action uses, so a thing can be invalidated from either
|
|
96
|
+
* side. This is the path for a refresh nobody mutated anything to earn — a
|
|
97
|
+
* button, a poll, a message saying that table has moved; what an action
|
|
98
|
+
* invalidated travels back inside the action's own answer instead.
|
|
99
|
+
*
|
|
100
|
+
* A slot is the only region smaller than a page the server can name, so two
|
|
101
|
+
* tables refresh apart from each other only if they are two slots. The page
|
|
102
|
+
* form leaves the layouts alone, which is what makes it cheap and also why a
|
|
103
|
+
* count living in a layout will not move until you ask for 'all'.
|
|
104
|
+
*/
|
|
105
|
+
export declare function refresh(target?: string): Promise<void>;
|
|
106
|
+
export declare function prefetch(url: string, cacheForMs?: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Drop a prefetch that is still in flight — the pointer left the link.
|
|
109
|
+
*
|
|
110
|
+
* The cache entry goes synchronously rather than in the abort's catch: the
|
|
111
|
+
* rejection lands a tick later, and a click in between would find an entry
|
|
112
|
+
* whose tree resolves to null and navigate to a blank page. A prefetch that
|
|
113
|
+
* has already completed is kept; there is no request left to cancel and the
|
|
114
|
+
* payload is still good.
|
|
115
|
+
*/
|
|
116
|
+
export declare function cancelPrefetch(url: string): void;
|
|
117
|
+
export {};
|
|
118
|
+
//# sourceMappingURL=navigate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/js/navigate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAMxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,SAAS,GAAG,OAAO,CAAC;AACzB,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AACrG,KAAK,YAAY,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AA8BtE,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AA+DD,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQpD;AA8BD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAgB,GAAG,MAAM,CAgB5E;AAYD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAEpD;AA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