@opentf/afw 0.0.0-stage → 0.33.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/LICENSE +21 -0
- package/README.md +123 -2
- package/components/Link.d.ts +12 -0
- package/components/Link.jsx +54 -0
- package/core/context.d.ts +7 -0
- package/core/context.js +60 -0
- package/core/dev.js +27 -0
- package/core/errors.d.ts +14 -0
- package/core/errors.js +48 -0
- package/core/html.js +10 -0
- package/core/metadata.js +186 -0
- package/core/reactive.d.ts +5 -0
- package/core/reactive.js +190 -0
- package/core/render-context.js +11 -0
- package/core/signals.d.ts +8 -0
- package/core/signals.js +264 -0
- package/index.d.ts +5 -0
- package/index.js +13 -0
- package/jsx-runtime.d.ts +37 -0
- package/package.json +66 -4
- package/runtime/clipboard.d.ts +7 -0
- package/runtime/clipboard.js +47 -0
- package/runtime/code-block.d.ts +14 -0
- package/runtime/code-block.js +76 -0
- package/runtime/context.browser.js +163 -0
- package/runtime/context.d.ts +13 -0
- package/runtime/context.js +44 -0
- package/runtime/dom.browser.js +423 -0
- package/runtime/dom.d.ts +142 -0
- package/runtime/dom.js +670 -0
- package/runtime/error-boundary.browser.js +140 -0
- package/runtime/error-boundary.d.ts +19 -0
- package/runtime/error-boundary.js +123 -0
- package/runtime/events.browser.js +29 -0
- package/runtime/events.d.ts +1 -0
- package/runtime/events.js +17 -0
- package/runtime/head.js +29 -0
- package/runtime/hmr.js +199 -0
- package/runtime/hydrate.browser.js +144 -0
- package/runtime/hydrate.d.ts +179 -0
- package/runtime/hydrate.js +584 -0
- package/runtime/index.d.ts +14 -0
- package/runtime/index.js +24 -0
- package/runtime/lifecycle.d.ts +6 -0
- package/runtime/lifecycle.js +14 -0
- package/runtime/mount.d.ts +20 -0
- package/runtime/mount.js +88 -0
- package/runtime/portal.browser.js +85 -0
- package/runtime/portal.d.ts +12 -0
- package/runtime/portal.js +74 -0
- package/runtime/raw-html.d.ts +11 -0
- package/runtime/raw-html.js +55 -0
- package/runtime/resource.d.ts +9 -0
- package/runtime/resource.js +139 -0
- package/runtime/route-data.d.ts +15 -0
- package/runtime/route-data.js +64 -0
- package/runtime/router.d.ts +149 -0
- package/runtime/router.js +807 -0
- package/server/adapters/node.d.ts +28 -0
- package/server/adapters/node.js +74 -0
- package/server/api.d.ts +175 -0
- package/server/api.js +233 -0
- package/server/builtins.js +42 -0
- package/server/cookies.d.ts +44 -0
- package/server/cookies.js +122 -0
- package/server/head.js +9 -0
- package/server/index.d.ts +155 -0
- package/server/index.js +31 -0
- package/server/loader.js +201 -0
- package/server/middleware.js +119 -0
- package/server/render-context.js +30 -0
- package/server/render.js +175 -0
- package/server/ssg-runtime.js +297 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** Whether the client router should intercept link clicks (SPA) vs. let the browser
|
|
2
|
+
* do a full navigation (MPA). Read by `<Link>`. */
|
|
3
|
+
export function shouldInterceptNav(): boolean;
|
|
4
|
+
/** Register the app's locales (called by `mountApp({ i18n })`). */
|
|
5
|
+
export function configureI18n(cfg: any): void;
|
|
6
|
+
/** The configured locales + default, or null when i18n isn't enabled. */
|
|
7
|
+
export function i18nLocales(): any;
|
|
8
|
+
/**
|
|
9
|
+
* Split a leading non-default locale segment off `pathname`, returning the active
|
|
10
|
+
* `locale` and the locale-agnostic `path` to match against the route table. When
|
|
11
|
+
* i18n is off, or the first segment isn't a configured non-default locale, the
|
|
12
|
+
* path passes through unchanged with the default (or null) locale.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveLocale(pathname: any): {
|
|
15
|
+
locale: any;
|
|
16
|
+
path: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Prefix `path` with `locale` (bare for the default locale). Any locale already on
|
|
20
|
+
* `path` is replaced. Used by `<Link>` and programmatic navigation to keep links
|
|
21
|
+
* in the active locale. Pass-through when i18n is off.
|
|
22
|
+
*/
|
|
23
|
+
export function localizePath(path: any, locale?: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* Set the active locale directly, without navigating. The reactive `router.locale`
|
|
26
|
+
* updates and any `t()`/formatter bindings re-render fine-grained. Intended for
|
|
27
|
+
* previews, tests, and programmatic control — in a routed app the locale is derived
|
|
28
|
+
* from the URL prefix (docs/I18N.md §2), so navigation is the normal path.
|
|
29
|
+
*/
|
|
30
|
+
export function setLocale(locale: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* Register routes from a `{ path: entry }` map. Each `entry` is either a module
|
|
33
|
+
* namespace (eager) or a `() => import(...)` loader (lazy, code-split) — both
|
|
34
|
+
* resolve to a default-export factory at navigation time. `layout.jsx` files
|
|
35
|
+
* register as layouts (wrapping nested pages), `404.jsx` as the fallback.
|
|
36
|
+
*/
|
|
37
|
+
export function registerRoutes(modules: any): void;
|
|
38
|
+
/**
|
|
39
|
+
* Register which route *patterns* (`"/todos"`, `"/items/[id]"`) have a server
|
|
40
|
+
* loader (docs/DATA.md) — the toolchain discovers `loader.{js,ts}` files and
|
|
41
|
+
* passes the list via `mountApp({ loaders })`. `navigate` only fetches
|
|
42
|
+
* `<path>/__data.json` for routes in this set; `matchRoute` returns the same
|
|
43
|
+
* pattern string, so membership is a plain Set lookup.
|
|
44
|
+
*/
|
|
45
|
+
export function registerLoaderRoutes(paths: any): void;
|
|
46
|
+
/** Set the reactive `router.data` directly (server render and tests). */
|
|
47
|
+
export function setRouteData(data: any): void;
|
|
48
|
+
/** Layout entries that wrap `route`, outermost (root) first. */
|
|
49
|
+
export function layoutChain(route: any): any[];
|
|
50
|
+
/** Resolve a route entry (module namespace or lazy loader) to its factory. */
|
|
51
|
+
export function resolveFactory(entry: any): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* Build the DOM node for a matched route: the page factory wrapped by its layout
|
|
54
|
+
* chain (most-specific inward, root outermost). Returns the outermost `node` plus
|
|
55
|
+
* the ordered `nodes` list (page → … → root) so callers can run lifecycle on each.
|
|
56
|
+
* Each factory owns a reactive scope, disposed with its node on navigation.
|
|
57
|
+
*/
|
|
58
|
+
export function buildRouteNode(match: any, query?: {}): Promise<{
|
|
59
|
+
node: any;
|
|
60
|
+
nodes: any[];
|
|
61
|
+
modules: any[];
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Adopt a matched route's server-rendered DOM (docs/HYDRATION.md §3.4, 2.1c) — the hydrate
|
|
65
|
+
* analogue of {@link buildRouteNode}. One cursor threads the whole layout chain: the
|
|
66
|
+
* outermost layout adopts at the container, and each layout hands that cursor to the next at
|
|
67
|
+
* its `{children}` slot (`props.children` is a thunk that claims the nested route's subtree
|
|
68
|
+
* and advances the cursor), down to the page. Returns `{ nodes }` (page → … → root) for
|
|
69
|
+
* lifecycle, or `null` if the page or any layout isn't adoptable (no `hydrateAt` export) — the
|
|
70
|
+
* caller then falls back to a clean CSR build. A thrown `HydrationMismatch` propagates up,
|
|
71
|
+
* disposing each layer's partial wiring on the way (each `hydrateAt` has its own guard).
|
|
72
|
+
*/
|
|
73
|
+
export function hydrateRouteNode(match: any, query: any, rootEl: any): Promise<{
|
|
74
|
+
nodes: any[];
|
|
75
|
+
} | null>;
|
|
76
|
+
/** Resolve a route entry (lazy loader or module namespace) to its module. */
|
|
77
|
+
export function resolveModule(entry: any): Promise<any>;
|
|
78
|
+
/**
|
|
79
|
+
* Set the reactive route state directly (no history/render). Used by server render
|
|
80
|
+
* so a page reading `router.pathname`/`params`/`query` resolves to the route being
|
|
81
|
+
* pre-rendered. The client uses `navigate` instead.
|
|
82
|
+
*/
|
|
83
|
+
export function setRouteToc(pageModule: any): void;
|
|
84
|
+
export function setRouteState({ pathname, search, params, locale, data }?: {
|
|
85
|
+
locale?: string | null;
|
|
86
|
+
data?: unknown;
|
|
87
|
+
pathname?: string | undefined;
|
|
88
|
+
search?: string | undefined;
|
|
89
|
+
params?: {} | undefined;
|
|
90
|
+
}): void;
|
|
91
|
+
/**
|
|
92
|
+
* Match `pathname` against the registered routes, resolving `[param]` segments. A
|
|
93
|
+
* leading non-default locale segment is stripped first (the route table is
|
|
94
|
+
* locale-agnostic; see `resolveLocale`).
|
|
95
|
+
*/
|
|
96
|
+
export function matchRoute(pathname: any): {
|
|
97
|
+
entry: any;
|
|
98
|
+
params: any;
|
|
99
|
+
route: string;
|
|
100
|
+
} | null;
|
|
101
|
+
/**
|
|
102
|
+
* Navigate to `path`. Runs an optional route guard, fetches the route's loader
|
|
103
|
+
* data when it has any (docs/DATA.md — fetch *then* commit, like the guard),
|
|
104
|
+
* swaps the rendered page (tearing down the previous one's lifecycle), and
|
|
105
|
+
* updates window.history.
|
|
106
|
+
*/
|
|
107
|
+
export function navigate(path: any, replace?: boolean, isPop?: boolean, hydrate?: boolean): Promise<void>;
|
|
108
|
+
export function refreshHotRoute(factory: any): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Bootstrap the application: register routes, wire history, and render the page
|
|
111
|
+
* for the current URL.
|
|
112
|
+
*
|
|
113
|
+
* @param {Object} opts
|
|
114
|
+
* @param {Object} opts.pages `{ path: module }` route map (from the dev server).
|
|
115
|
+
* @param {Element} [opts.target] the app root (defaults to `#app`).
|
|
116
|
+
* @param {Function} [opts.guard] optional `(to, tools) => …` route guard.
|
|
117
|
+
* @param {"spa"|"mpa"} [opts.nav] navigation mode (default "spa"); "mpa" disables
|
|
118
|
+
* client-side link interception so every navigation is a full page load.
|
|
119
|
+
* @param {string[]} [opts.loaders] route patterns that have a server loader
|
|
120
|
+
* (docs/DATA.md) — navigation fetches `<path>/__data.json` for these.
|
|
121
|
+
*/
|
|
122
|
+
export function mountApp({ pages, target, guard: g, i18n, nav, loaders }?: {
|
|
123
|
+
i18n?: { locales: string[]; defaultLocale?: string };
|
|
124
|
+
pages: Object;
|
|
125
|
+
target?: Element | undefined;
|
|
126
|
+
guard?: Function | undefined;
|
|
127
|
+
nav?: "spa" | "mpa" | undefined;
|
|
128
|
+
loaders?: string[] | undefined;
|
|
129
|
+
}): Promise<void>;
|
|
130
|
+
export namespace routes {
|
|
131
|
+
let pages: {};
|
|
132
|
+
let layouts: {};
|
|
133
|
+
let notFound: null;
|
|
134
|
+
let loaderRoutes: Set<any>;
|
|
135
|
+
}
|
|
136
|
+
export namespace router {
|
|
137
|
+
const pathname: any;
|
|
138
|
+
const searchParams: any;
|
|
139
|
+
const query: {
|
|
140
|
+
[k: string]: any;
|
|
141
|
+
};
|
|
142
|
+
const params: any;
|
|
143
|
+
const locale: any;
|
|
144
|
+
const data: any;
|
|
145
|
+
/** The current page's headings (MDX `export const toc`), or `[]`. */
|
|
146
|
+
const toc: { depth: number; id: string; text: string }[];
|
|
147
|
+
function push(path: any): Promise<void>;
|
|
148
|
+
function replace(path: any): Promise<void>;
|
|
149
|
+
}
|