@opentf/afw 0.37.0 → 0.39.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/core/route.d.ts +33 -0
- package/core/route.js +12 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/jsx-runtime.d.ts +22 -1
- package/package.json +5 -1
- package/runtime/dom.js +23 -4
- package/runtime/error-boundary.d.ts +1 -1
- package/runtime/error-boundary.js +11 -1
- package/runtime/head.js +10 -1
- package/runtime/hmr.js +29 -0
- package/runtime/index.d.ts +4 -0
- package/runtime/index.js +5 -0
- package/runtime/lazy.d.ts +8 -0
- package/runtime/lazy.js +135 -0
- package/runtime/pending-scope.d.ts +6 -0
- package/runtime/pending-scope.js +39 -0
- package/runtime/pending.d.ts +31 -0
- package/runtime/pending.js +276 -0
- package/runtime/resource.d.ts +6 -0
- package/runtime/resource.js +65 -5
- package/runtime/route-data.js +33 -1
- package/runtime/route-errors.d.ts +3 -0
- package/runtime/route-errors.js +16 -0
- package/runtime/route-match.js +97 -12
- package/runtime/router.d.ts +44 -3
- package/runtime/router.js +470 -49
- package/runtime/scroll.js +130 -0
- package/runtime/transition-hooks.js +10 -0
- package/runtime/transition.d.ts +43 -0
- package/runtime/transition.js +187 -0
- package/server/api.js +3 -3
- package/server/builtins.js +29 -1
- package/server/index.d.ts +20 -1
- package/server/index.js +3 -2
- package/server/loader.js +73 -7
- package/server/middleware.js +9 -5
- package/server/render.js +85 -16
package/runtime/router.d.ts
CHANGED
|
@@ -47,6 +47,30 @@ export function registerLoaderRoutes(paths: any): void;
|
|
|
47
47
|
export function setRouteData(data: any): void;
|
|
48
48
|
/** Layout entries that wrap `route`, outermost (root) first. */
|
|
49
49
|
export function layoutChain(route: any): any[];
|
|
50
|
+
/** The folders of the layouts wrapping `route`, outermost first (aligned with `layoutChain`). */
|
|
51
|
+
export function layoutFolders(route: string | null): string[];
|
|
52
|
+
/** Does the layout at `folder` wrap `route`? */
|
|
53
|
+
export function layoutWraps(folder: string, route: string | null): boolean;
|
|
54
|
+
/** The `error.jsx` for an error: the page's nearest, or for a broken layout the nearest above it. */
|
|
55
|
+
export function routeErrorSite(route: string | null, brokenLayout?: string | null): { entry: unknown };
|
|
56
|
+
/** The nearest `loading.jsx` / `error.jsx` entry for `route`: its folder, then each parent. */
|
|
57
|
+
export function nearestRouteFile(table: Record<string, unknown>, route: string | null): unknown;
|
|
58
|
+
/** How long a navigation waits before showing `loading.jsx` (milliseconds). */
|
|
59
|
+
export const LOADING_DELAY: number;
|
|
60
|
+
/** Props an `error.jsx` receives. */
|
|
61
|
+
export interface RouteErrorProps {
|
|
62
|
+
/** What failed. After a server render, `status` is set and the message is generic in production. */
|
|
63
|
+
error: Error & { status?: number };
|
|
64
|
+
/** Load the page again: rerun its loader and rebuild it. */
|
|
65
|
+
retry: () => void;
|
|
66
|
+
params: Record<string, string | string[]>;
|
|
67
|
+
query: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
/** Props a `loading.jsx` receives. */
|
|
70
|
+
export interface RouteLoadingProps {
|
|
71
|
+
params: Record<string, string | string[]>;
|
|
72
|
+
query: Record<string, string>;
|
|
73
|
+
}
|
|
50
74
|
/** Resolve a route entry (module namespace or lazy loader) to its factory. */
|
|
51
75
|
export function resolveFactory(entry: any): Promise<any>;
|
|
52
76
|
/**
|
|
@@ -55,10 +79,11 @@ export function resolveFactory(entry: any): Promise<any>;
|
|
|
55
79
|
* the ordered `nodes` list (page → … → root) so callers can run lifecycle on each.
|
|
56
80
|
* Each factory owns a reactive scope, disposed with its node on navigation.
|
|
57
81
|
*/
|
|
58
|
-
export function buildRouteNode(match: any, query?: {}): Promise<{
|
|
82
|
+
export function buildRouteNode(match: any, query?: {}, options?: { error?: unknown; loadingShown?: boolean }): Promise<{
|
|
59
83
|
node: any;
|
|
60
84
|
nodes: any[];
|
|
61
85
|
modules: any[];
|
|
86
|
+
region: any;
|
|
62
87
|
}>;
|
|
63
88
|
/**
|
|
64
89
|
* Adopt a matched route's server-rendered DOM (docs/HYDRATION.md §3.4, 2.1c) — the hydrate
|
|
@@ -70,7 +95,7 @@ export function buildRouteNode(match: any, query?: {}): Promise<{
|
|
|
70
95
|
* caller then falls back to a clean CSR build. A thrown `HydrationMismatch` propagates up,
|
|
71
96
|
* disposing each layer's partial wiring on the way (each `hydrateAt` has its own guard).
|
|
72
97
|
*/
|
|
73
|
-
export function hydrateRouteNode(match: any, query: any, rootEl: any): Promise<{
|
|
98
|
+
export function hydrateRouteNode(match: any, query: any, rootEl: any, options?: { error?: unknown }): Promise<{
|
|
74
99
|
nodes: any[];
|
|
75
100
|
} | null>;
|
|
76
101
|
/** Resolve a route entry (lazy loader or module namespace) to its module. */
|
|
@@ -123,17 +148,24 @@ export function refreshHotRoute(factory: any): Promise<void>;
|
|
|
123
148
|
* @param {string[]} [opts.loaders] route patterns that have a server loader
|
|
124
149
|
* (docs/DATA.md) — navigation fetches `<path>/__data.json` for these.
|
|
125
150
|
*/
|
|
126
|
-
export function mountApp({ pages, target, guard: g, i18n, nav, loaders }?: {
|
|
151
|
+
export function mountApp({ pages, target, guard: g, i18n, nav, loaders, viewTransitions }?: {
|
|
127
152
|
i18n?: { locales: string[]; defaultLocale?: string };
|
|
128
153
|
pages: Object;
|
|
129
154
|
target?: Element | undefined;
|
|
130
155
|
guard?: Function | undefined;
|
|
131
156
|
nav?: "spa" | "mpa" | undefined;
|
|
132
157
|
loaders?: string[] | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Run client navigations inside `document.startViewTransition()`. Skipped on the
|
|
160
|
+
* first paint, with `prefers-reduced-motion: reduce`, and where unsupported. Default false.
|
|
161
|
+
*/
|
|
162
|
+
viewTransitions?: boolean | undefined;
|
|
133
163
|
}): Promise<void>;
|
|
134
164
|
export namespace routes {
|
|
135
165
|
let pages: {};
|
|
136
166
|
let layouts: {};
|
|
167
|
+
let loading: {};
|
|
168
|
+
let errors: {};
|
|
137
169
|
let notFound: null;
|
|
138
170
|
let loaderRoutes: Set<any>;
|
|
139
171
|
}
|
|
@@ -151,3 +183,12 @@ export namespace router {
|
|
|
151
183
|
function push(path: any): Promise<void>;
|
|
152
184
|
function replace(path: any): Promise<void>;
|
|
153
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Mark a route-table entry as rendered in the browser (its folder's `_config.js` says
|
|
189
|
+
* `render: "client"`). Used by the generated route tables; `load` is the client's lazy
|
|
190
|
+
* import, omitted on the server, whose bundle never includes the module.
|
|
191
|
+
*/
|
|
192
|
+
export function clientRoute<T extends (() => unknown) | undefined>(load?: T): T extends () => unknown ? T : () => never;
|
|
193
|
+
/** Whether a route-table entry renders in the browser (see `clientRoute`). */
|
|
194
|
+
export function isClientRoute(entry: unknown): boolean;
|