@opentf/afw 0.0.0-stage → 0.32.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.
Files changed (72) hide show
  1. package/README.md +66 -2
  2. package/components/Link.d.ts +12 -0
  3. package/components/Link.jsx +54 -0
  4. package/core/context.d.ts +7 -0
  5. package/core/context.js +60 -0
  6. package/core/dev.js +27 -0
  7. package/core/errors.d.ts +14 -0
  8. package/core/errors.js +48 -0
  9. package/core/html.js +10 -0
  10. package/core/metadata.js +184 -0
  11. package/core/reactive.d.ts +5 -0
  12. package/core/reactive.js +190 -0
  13. package/core/render-context.js +11 -0
  14. package/core/signals.d.ts +8 -0
  15. package/core/signals.js +264 -0
  16. package/index.d.ts +5 -0
  17. package/index.js +13 -0
  18. package/jsx-runtime.d.ts +37 -0
  19. package/package.json +60 -4
  20. package/runtime/clipboard.d.ts +7 -0
  21. package/runtime/clipboard.js +47 -0
  22. package/runtime/code-block.d.ts +14 -0
  23. package/runtime/code-block.js +76 -0
  24. package/runtime/context.browser.js +163 -0
  25. package/runtime/context.d.ts +13 -0
  26. package/runtime/context.js +44 -0
  27. package/runtime/dom.browser.js +423 -0
  28. package/runtime/dom.d.ts +142 -0
  29. package/runtime/dom.js +670 -0
  30. package/runtime/error-boundary.browser.js +140 -0
  31. package/runtime/error-boundary.d.ts +19 -0
  32. package/runtime/error-boundary.js +123 -0
  33. package/runtime/events.browser.js +29 -0
  34. package/runtime/events.d.ts +1 -0
  35. package/runtime/events.js +17 -0
  36. package/runtime/head.js +29 -0
  37. package/runtime/hmr.js +170 -0
  38. package/runtime/hydrate.browser.js +144 -0
  39. package/runtime/hydrate.d.ts +173 -0
  40. package/runtime/hydrate.js +536 -0
  41. package/runtime/index.d.ts +14 -0
  42. package/runtime/index.js +24 -0
  43. package/runtime/lifecycle.d.ts +6 -0
  44. package/runtime/lifecycle.js +14 -0
  45. package/runtime/mount.d.ts +20 -0
  46. package/runtime/mount.js +85 -0
  47. package/runtime/portal.browser.js +85 -0
  48. package/runtime/portal.d.ts +12 -0
  49. package/runtime/portal.js +74 -0
  50. package/runtime/raw-html.d.ts +11 -0
  51. package/runtime/raw-html.js +55 -0
  52. package/runtime/resource.d.ts +9 -0
  53. package/runtime/resource.js +139 -0
  54. package/runtime/route-data.d.ts +15 -0
  55. package/runtime/route-data.js +64 -0
  56. package/runtime/router.d.ts +146 -0
  57. package/runtime/router.js +765 -0
  58. package/server/adapters/node.d.ts +28 -0
  59. package/server/adapters/node.js +74 -0
  60. package/server/api.d.ts +175 -0
  61. package/server/api.js +233 -0
  62. package/server/builtins.js +42 -0
  63. package/server/cookies.d.ts +44 -0
  64. package/server/cookies.js +122 -0
  65. package/server/head.js +9 -0
  66. package/server/index.d.ts +151 -0
  67. package/server/index.js +31 -0
  68. package/server/loader.js +201 -0
  69. package/server/middleware.js +119 -0
  70. package/server/render-context.js +30 -0
  71. package/server/render.js +172 -0
  72. package/server/ssg-runtime.js +239 -0
@@ -0,0 +1,146 @@
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 setRouteState({ pathname, search, params, locale, data }?: {
84
+ locale?: string | null;
85
+ data?: unknown;
86
+ pathname?: string | undefined;
87
+ search?: string | undefined;
88
+ params?: {} | undefined;
89
+ }): void;
90
+ /**
91
+ * Match `pathname` against the registered routes, resolving `[param]` segments. A
92
+ * leading non-default locale segment is stripped first (the route table is
93
+ * locale-agnostic; see `resolveLocale`).
94
+ */
95
+ export function matchRoute(pathname: any): {
96
+ entry: any;
97
+ params: any;
98
+ route: string;
99
+ } | null;
100
+ /**
101
+ * Navigate to `path`. Runs an optional route guard, fetches the route's loader
102
+ * data when it has any (docs/DATA.md — fetch *then* commit, like the guard),
103
+ * swaps the rendered page (tearing down the previous one's lifecycle), and
104
+ * updates window.history.
105
+ */
106
+ export function navigate(path: any, replace?: boolean, isPop?: boolean, hydrate?: boolean): Promise<void>;
107
+ export function refreshHotRoute(factory: any): Promise<void>;
108
+ /**
109
+ * Bootstrap the application: register routes, wire history, and render the page
110
+ * for the current URL.
111
+ *
112
+ * @param {Object} opts
113
+ * @param {Object} opts.pages `{ path: module }` route map (from the dev server).
114
+ * @param {Element} [opts.target] the app root (defaults to `#app`).
115
+ * @param {Function} [opts.guard] optional `(to, tools) => …` route guard.
116
+ * @param {"spa"|"mpa"} [opts.nav] navigation mode (default "spa"); "mpa" disables
117
+ * client-side link interception so every navigation is a full page load.
118
+ * @param {string[]} [opts.loaders] route patterns that have a server loader
119
+ * (docs/DATA.md) — navigation fetches `<path>/__data.json` for these.
120
+ */
121
+ export function mountApp({ pages, target, guard: g, i18n, nav, loaders }?: {
122
+ i18n?: { locales: string[]; defaultLocale?: string };
123
+ pages: Object;
124
+ target?: Element | undefined;
125
+ guard?: Function | undefined;
126
+ nav?: "spa" | "mpa" | undefined;
127
+ loaders?: string[] | undefined;
128
+ }): Promise<void>;
129
+ export namespace routes {
130
+ let pages: {};
131
+ let layouts: {};
132
+ let notFound: null;
133
+ let loaderRoutes: Set<any>;
134
+ }
135
+ export namespace router {
136
+ const pathname: any;
137
+ const searchParams: any;
138
+ const query: {
139
+ [k: string]: any;
140
+ };
141
+ const params: any;
142
+ const locale: any;
143
+ const data: any;
144
+ function push(path: any): Promise<void>;
145
+ function replace(path: any): Promise<void>;
146
+ }