@askrjs/askr 0.2.3 → 0.3.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/CHANGELOG.md +11 -0
- package/dist/access-CEA2pOry.js +1046 -0
- package/dist/actions/index.d.ts +16 -2
- package/dist/actions/index.js +5 -5
- package/dist/{activity-ZxJXI9hF.js → activity-oy2YFTFF.js} +22 -16
- package/dist/benchmark.js +8 -9
- package/dist/boot/index.d.ts +21 -9
- package/dist/boot/index.js +1 -1
- package/dist/{boot-D4GaLA0d.js → boot-BMBMWUGI.js} +680 -440
- package/dist/capabilities-Bbf0mlp9.js +42 -0
- package/dist/components/index.d.ts +11 -8
- package/dist/components/index.js +1 -1
- package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
- package/dist/control/index.d.ts +20 -2
- package/dist/control/index.js +1 -1
- package/dist/{control-57x3wa4J.js → control-BR_mrX__.js} +4 -4
- package/dist/core.d.ts +163 -0
- package/dist/csp-nonce-BfFWcd0w.js +173 -0
- package/dist/data/index.d.ts +74 -2
- package/dist/data/index.js +3 -3
- package/dist/{data-B7XCDeC8.js → data-2edW0jhF.js} +133 -138
- package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
- package/dist/{deferred-BELyvMsC.js → deferred-CbgNhf67.js} +5 -5
- package/dist/dom-renderer.d.ts +77 -0
- package/dist/domains/actions.d.ts +70 -0
- package/dist/domains/component.d.ts +119 -0
- package/dist/domains/context.d.ts +73 -0
- package/dist/domains/control.d.ts +328 -0
- package/dist/domains/data.d.ts +461 -0
- package/dist/domains/diagnostics.d.ts +21 -0
- package/dist/domains/lifecycle.d.ts +112 -0
- package/dist/domains/refs.d.ts +18 -0
- package/dist/domains/renderer.d.ts +127 -0
- package/dist/domains/routing.d.ts +501 -0
- package/dist/domains/scheduler.d.ts +79 -0
- package/dist/domains/server.d.ts +112 -0
- package/dist/domains/state.d.ts +129 -0
- package/dist/domains/telemetry.d.ts +29 -0
- package/dist/eager-control.d.ts +8 -0
- package/dist/{effect-4LwBwV58.js → effect-C3Zsc1k6.js} +14 -41
- package/dist/{types-DkVJhVs9.d.ts → elements.d.ts} +84 -42
- package/dist/{for-internal-DeoSg_AV.js → for-state-BDykeOJL.js} +623 -511
- package/dist/foundations/icon/index.d.ts +67 -16
- package/dist/foundations/icon/index.js +1 -1
- package/dist/foundations/index.d.ts +26 -3
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/index.d.ts +73 -34
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +12 -5
- package/dist/foundations/state/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +44 -3
- package/dist/foundations/structures/index.js +1 -1
- package/dist/foundations/utilities/index.d.ts +34 -3
- package/dist/foundations/utilities/index.js +1 -1
- package/dist/fx/index.d.ts +72 -25
- package/dist/fx/index.js +8 -8
- package/dist/index.d.ts +121 -4
- package/dist/index.js +316 -47
- package/dist/{component-internal-Dl02WQKS.js → instance-VAFYVJOa.js} +495 -283
- package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +51 -11
- package/dist/jsx-globals.d.ts +2 -0
- package/dist/jsx-runtime-CPJXAOBF.js +43 -0
- package/dist/jsx-runtime.d.ts +17 -3
- package/dist/jsx-runtime.js +2 -42
- package/dist/jsx.d.ts +108 -0
- package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
- package/dist/{navigate-C46GtScG.js → navigate-prC5V8XV.js} +204 -476
- package/dist/{navigate-wel1e6cU.d.ts → navigation.d.ts} +10 -8
- package/dist/{readable-CEcteIDE.js → notify-DxxuDPeY.js} +96 -34
- package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
- package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
- package/dist/{ssr-BaC5qHEw.js → render-resolved-BC0W7_5b.js} +165 -558
- package/dist/{renderer-BhXofszH.js → renderer-CT0HeY58.js} +6866 -5715
- package/dist/{resolution-t8J0yNaU.js → resolution-3DskUkjG.js} +189 -180
- package/dist/{resource-operation-B8q-QRUx.js → resource-18-sFRl9.js} +98 -58
- package/dist/resources/index.d.ts +64 -46
- package/dist/resources/index.js +215 -9
- package/dist/route-activity.d.ts +21 -0
- package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
- package/dist/router/index.d.ts +378 -79
- package/dist/router/index.js +9 -9
- package/dist/router-internal-7nuNEHfG.js +36 -0
- package/dist/scope-Cq_iYbTR.js +403 -0
- package/dist/{selector-C7rIpOnN.js → selector-BSPVkjKP.js} +41 -41
- package/dist/{shared-CGrx2AOL.js → shared-kU8yvryp.js} +3 -6
- package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
- package/dist/ssg/index.d.ts +51 -15
- package/dist/ssg/index.js +269 -209
- package/dist/ssr/index.d.ts +121 -68
- package/dist/ssr/index.js +2 -1
- package/dist/ssr-CiNm6Vzl.js +393 -0
- package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
- package/dist/{state-BzhOW2TX.js → state-BXJfudq1.js} +10 -15
- package/dist/{structures-BwfeO4Iz.js → structures-CjEzfj4h.js} +37 -57
- package/dist/{index-r5THqzPN.d.ts → structures.d.ts} +57 -36
- package/dist/testing/index.d.ts +125 -24
- package/dist/testing/index.js +26 -62
- package/dist/timer-C7uqnJVt.js +85 -0
- package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
- package/dist/{verify-hydration-_Q6avFp0.js → verify-hydration-ikaxotf7.js} +8 -5
- package/package.json +13 -15
- package/dist/access-Rr7CMa06.js +0 -507
- package/dist/activity-CAJ5eho-.d.ts +0 -14
- package/dist/benchmark.d.ts +0 -26
- package/dist/cleanup-DsrbV-rr.js +0 -535
- package/dist/component-cleanup-DjpwO9WX.js +0 -143
- package/dist/component-scope-4I3yEMkb.js +0 -195
- package/dist/control-DdFw-Caz.d.ts +0 -8
- package/dist/csp-nonce-C9OuML0U.js +0 -72
- package/dist/css-BuPaTOfe.js +0 -70
- package/dist/fastlane-Buz1Rvlr.js +0 -166
- package/dist/index-DSqXWc77.d.ts +0 -1402
- package/dist/jsx-runtime-BTzDdBJ_.d.ts +0 -2
- package/dist/jsx-runtime-Cdd6Gkb0.d.ts +0 -38
- package/dist/lifecycle-batch-Be-CLDjV.js +0 -253
- package/dist/lifecycle-operations-C5m03NQc.js +0 -195
package/dist/router/index.d.ts
CHANGED
|
@@ -1,14 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
RouteSnapshot,
|
|
3
|
+
RouteDefinition,
|
|
4
|
+
RoutePathParams,
|
|
5
|
+
RenderableChild,
|
|
6
|
+
PageScopeRecord,
|
|
7
|
+
RouteAuthResolver,
|
|
8
|
+
RouteAuthOptions,
|
|
9
|
+
RouteMeta,
|
|
10
|
+
RouteRefSearch,
|
|
11
|
+
RouteQuery,
|
|
12
|
+
RouteMetaSource,
|
|
13
|
+
RouteRenderResult,
|
|
14
|
+
RouteRegistry,
|
|
15
|
+
RouteMode,
|
|
16
|
+
RouteHandler,
|
|
17
|
+
RouteManifest,
|
|
18
|
+
RouteComponent,
|
|
19
|
+
RouteMatch,
|
|
20
|
+
RouteSearchValue,
|
|
21
|
+
RouteOptions,
|
|
22
|
+
PageHelperOptions,
|
|
23
|
+
Route,
|
|
24
|
+
RouteRecord,
|
|
25
|
+
RoutePolicy,
|
|
26
|
+
RouteRef,
|
|
27
|
+
RouteRequestResult,
|
|
28
|
+
RouteRequestOptions,
|
|
29
|
+
RouteSearch,
|
|
30
|
+
AccessDenyStatus,
|
|
31
|
+
GroupHelperOptions,
|
|
32
|
+
AccessDenyDecision,
|
|
33
|
+
AccessDecision,
|
|
34
|
+
RouteDestination,
|
|
35
|
+
RouteContext,
|
|
36
|
+
AccessAllowDecision,
|
|
37
|
+
RouteRegistryOptions,
|
|
38
|
+
AccessRedirectDecision,
|
|
39
|
+
ParsedSegment,
|
|
40
|
+
LayoutScopeRecord,
|
|
41
|
+
AccessRedirectStatus,
|
|
42
|
+
RouteParams,
|
|
43
|
+
} from '../core.js';
|
|
44
|
+
import { JSXElement, Props } from '../elements.js';
|
|
45
|
+
import {
|
|
46
|
+
ScrollRestorationOptions,
|
|
47
|
+
NavigationScrollBehavior,
|
|
48
|
+
NavigateOptions,
|
|
49
|
+
HistoryScrollBehavior,
|
|
50
|
+
navigate,
|
|
51
|
+
} from '../navigation.js';
|
|
52
|
+
import {
|
|
53
|
+
onRouteChange,
|
|
54
|
+
RouteChangeOptions,
|
|
55
|
+
currentRoute,
|
|
56
|
+
RouteChangeCleanup,
|
|
57
|
+
} from '../route-activity.js';
|
|
58
|
+
import {
|
|
59
|
+
AuthContext,
|
|
60
|
+
AuthContext as AuthContext$1,
|
|
61
|
+
AuthRequirement,
|
|
62
|
+
AuthRequirement as AuthRequirement$1,
|
|
63
|
+
} from '@askrjs/auth';
|
|
64
|
+
import { ObjectSchema } from '@askrjs/schema';
|
|
8
65
|
/** A single query-string value accepted by {@link updateRouteQuery}. */
|
|
9
66
|
type RouteQueryParamValue = string | number | boolean | null | undefined;
|
|
10
67
|
/** A query-string value, or an array of them for a repeated param. */
|
|
11
|
-
type RouteQueryParamInput =
|
|
68
|
+
type RouteQueryParamInput =
|
|
69
|
+
| RouteQueryParamValue
|
|
70
|
+
| readonly RouteQueryParamValue[];
|
|
12
71
|
/** A map of query param updates for {@link updateRouteQuery}; `null`/`undefined` removes the key. */
|
|
13
72
|
type RouteQueryUpdates = Record<string, RouteQueryParamInput>;
|
|
14
73
|
/** A function that mutates a `URLSearchParams` directly, for {@link updateRouteQuery}. */
|
|
@@ -22,78 +81,191 @@ type UpdateRouteQueryOptions = {
|
|
|
22
81
|
history?: 'push' | 'replace';
|
|
23
82
|
replace?: boolean;
|
|
24
83
|
};
|
|
25
|
-
declare function updateRouteQuery(
|
|
26
|
-
|
|
27
|
-
|
|
84
|
+
declare function updateRouteQuery(
|
|
85
|
+
updates: RouteQueryUpdates | RouteQueryUpdater,
|
|
86
|
+
options?: UpdateRouteQueryOptions
|
|
87
|
+
): void;
|
|
28
88
|
type AnyRouteComponent = (...args: any[]) => RenderableChild;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
89
|
+
type RouteComponentParam<TComponent extends AnyRouteComponent> =
|
|
90
|
+
Parameters<TComponent> extends [] ? unknown : Parameters<TComponent>[0];
|
|
91
|
+
type CompatibleAbsoluteRouteComponent<
|
|
92
|
+
Path extends string,
|
|
93
|
+
TComponent extends AnyRouteComponent,
|
|
94
|
+
> =
|
|
95
|
+
Parameters<TComponent> extends []
|
|
96
|
+
? TComponent
|
|
97
|
+
: RoutePathParams<Path> extends RouteComponentParam<TComponent>
|
|
98
|
+
? TComponent
|
|
99
|
+
: never;
|
|
100
|
+
type CompatibleRelativeRouteComponent<
|
|
101
|
+
Path extends string,
|
|
102
|
+
TComponent extends AnyRouteComponent,
|
|
103
|
+
> =
|
|
104
|
+
Parameters<TComponent> extends []
|
|
105
|
+
? TComponent
|
|
106
|
+
: RouteComponentParam<TComponent> extends Record<
|
|
107
|
+
keyof RoutePathParams<Path>,
|
|
108
|
+
string
|
|
109
|
+
>
|
|
110
|
+
? TComponent
|
|
111
|
+
: never;
|
|
112
|
+
type CompatibleRouteComponent<
|
|
113
|
+
Path extends string,
|
|
114
|
+
TComponent extends AnyRouteComponent,
|
|
115
|
+
> = Path extends `/${string}`
|
|
116
|
+
? CompatibleAbsoluteRouteComponent<Path, TComponent>
|
|
117
|
+
: CompatibleRelativeRouteComponent<Path, TComponent>;
|
|
118
|
+
type RouteOptionsForComponent<
|
|
119
|
+
Path extends string,
|
|
120
|
+
TComponent extends AnyRouteComponent,
|
|
121
|
+
TSearchSchema extends ObjectSchema<RouteSearch> | undefined =
|
|
122
|
+
| ObjectSchema<RouteSearch>
|
|
123
|
+
| undefined,
|
|
124
|
+
TLoaderData = unknown,
|
|
125
|
+
TDehydratedData = TLoaderData,
|
|
126
|
+
> =
|
|
127
|
+
Parameters<TComponent> extends []
|
|
128
|
+
? RouteOptions<
|
|
129
|
+
RoutePathParams<Path>,
|
|
130
|
+
TSearchSchema,
|
|
131
|
+
TLoaderData,
|
|
132
|
+
TDehydratedData
|
|
133
|
+
>
|
|
134
|
+
: RouteComponentParam<TComponent> extends RouteParams
|
|
135
|
+
? RouteOptions<
|
|
136
|
+
RouteComponentParam<TComponent>,
|
|
137
|
+
TSearchSchema,
|
|
138
|
+
TLoaderData,
|
|
139
|
+
TDehydratedData
|
|
140
|
+
>
|
|
141
|
+
: RouteOptions<
|
|
142
|
+
RoutePathParams<Path>,
|
|
143
|
+
TSearchSchema,
|
|
144
|
+
TLoaderData,
|
|
145
|
+
TDehydratedData
|
|
146
|
+
>;
|
|
36
147
|
/** Declare a group of routes sharing `options` (auth, policies, layout, meta). */
|
|
37
148
|
declare function group(options: GroupHelperOptions, fn: RouteDefinition): void;
|
|
38
149
|
/**
|
|
39
150
|
* Declare a route page at `path`, nesting a sub-scope for `index`/`page`/`fallback`
|
|
40
151
|
* declarations and options like `preload`/`meta`/`auth`.
|
|
41
152
|
*/
|
|
42
|
-
declare function page<const TPath extends string>(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
153
|
+
declare function page<const TPath extends string>(
|
|
154
|
+
path: TPath,
|
|
155
|
+
Component: RouteComponent<RoutePathParams<TPath>>,
|
|
156
|
+
fn: RouteDefinition
|
|
157
|
+
): void;
|
|
158
|
+
declare function page<
|
|
159
|
+
const TPath extends string,
|
|
160
|
+
TComponent extends AnyRouteComponent,
|
|
161
|
+
>(
|
|
162
|
+
path: TPath,
|
|
163
|
+
Component: CompatibleRouteComponent<TPath, TComponent>,
|
|
164
|
+
fn: RouteDefinition
|
|
165
|
+
): void;
|
|
166
|
+
declare function page<const TPath extends string>(
|
|
167
|
+
path: TPath,
|
|
168
|
+
Component: RouteComponent<RoutePathParams<TPath>>,
|
|
169
|
+
options: PageHelperOptions,
|
|
170
|
+
fn: RouteDefinition
|
|
171
|
+
): void;
|
|
172
|
+
declare function page<
|
|
173
|
+
const TPath extends string,
|
|
174
|
+
TComponent extends AnyRouteComponent,
|
|
175
|
+
>(
|
|
176
|
+
path: TPath,
|
|
177
|
+
Component: CompatibleRouteComponent<TPath, TComponent>,
|
|
178
|
+
options: PageHelperOptions,
|
|
179
|
+
fn: RouteDefinition
|
|
180
|
+
): void;
|
|
46
181
|
/** Declare the index route for the enclosing `page()` scope. */
|
|
47
182
|
declare function index(Component: RouteComponent, options?: RouteOptions): void;
|
|
48
183
|
/** Declare the catch-all `/*` fallback route for the enclosing scope. */
|
|
49
184
|
declare function fallback(Component: RouteComponent): void;
|
|
50
185
|
/** Declare a route at `path` rendering `Component`, returning a typed {@link RouteRef} for building destinations. */
|
|
51
|
-
declare function route<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
186
|
+
declare function route<
|
|
187
|
+
const TPath extends string,
|
|
188
|
+
const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined,
|
|
189
|
+
TLoaderData = unknown,
|
|
190
|
+
TDehydratedData = TLoaderData,
|
|
191
|
+
>(
|
|
192
|
+
path: TPath,
|
|
193
|
+
Component: RouteComponent<RoutePathParams<TPath>>,
|
|
194
|
+
options?: RouteOptions<
|
|
195
|
+
RoutePathParams<TPath>,
|
|
196
|
+
TSearchSchema,
|
|
197
|
+
TLoaderData,
|
|
198
|
+
TDehydratedData
|
|
199
|
+
>
|
|
200
|
+
): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
|
|
201
|
+
declare function route<
|
|
202
|
+
const TPath extends string,
|
|
203
|
+
TComponent extends AnyRouteComponent,
|
|
204
|
+
const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined,
|
|
205
|
+
TLoaderData = unknown,
|
|
206
|
+
TDehydratedData = TLoaderData,
|
|
207
|
+
>(
|
|
208
|
+
path: TPath,
|
|
209
|
+
Component: CompatibleRouteComponent<TPath, TComponent>,
|
|
210
|
+
options?: RouteOptionsForComponent<
|
|
211
|
+
TPath,
|
|
212
|
+
TComponent,
|
|
213
|
+
TSearchSchema,
|
|
214
|
+
TLoaderData,
|
|
215
|
+
TDehydratedData
|
|
216
|
+
>
|
|
217
|
+
): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
|
|
55
218
|
/** Return the identity resolved for the route currently being rendered. */
|
|
56
219
|
declare function currentAuth(): AuthContext$1;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/router/resolution.d.ts
|
|
59
220
|
/** Resolve `target` against a route registry, applying auth/policies to produce a render/redirect/deny result. */
|
|
60
|
-
declare function resolveRouteRequest(
|
|
61
|
-
|
|
62
|
-
|
|
221
|
+
declare function resolveRouteRequest(
|
|
222
|
+
target: string,
|
|
223
|
+
options: RouteRequestOptions
|
|
224
|
+
): RouteRequestResult | Promise<RouteRequestResult>;
|
|
63
225
|
/**
|
|
64
226
|
* Run `definition` to declare routes (via `route`/`page`/`group`/`fallback`)
|
|
65
227
|
* and build a {@link RouteRegistry} to pass to `createSPA`/`hydrateSPA`.
|
|
66
228
|
*/
|
|
67
|
-
declare function createRouteRegistry(
|
|
68
|
-
|
|
69
|
-
|
|
229
|
+
declare function createRouteRegistry(
|
|
230
|
+
definition: RouteDefinition,
|
|
231
|
+
options?: RouteRegistryOptions
|
|
232
|
+
): RouteRegistry;
|
|
70
233
|
/** A route component loaded on demand via {@link lazy}, with an explicit `preload()`. */
|
|
71
234
|
type LazyRouteComponent<TComponent extends AnyRouteComponent> = TComponent & {
|
|
72
235
|
preload(): Promise<void>;
|
|
73
236
|
};
|
|
74
237
|
/** A route data loader loaded on demand via {@link lazyRouteData}, with an explicit `preload()`. */
|
|
75
|
-
type LazyRouteDataLoader<TModule, TData = TModule> = ((
|
|
76
|
-
|
|
77
|
-
|
|
238
|
+
type LazyRouteDataLoader<TModule, TData = TModule> = ((
|
|
239
|
+
context: RouteContext & {
|
|
240
|
+
request?: Request;
|
|
241
|
+
}
|
|
242
|
+
) => Promise<TData>) & {
|
|
78
243
|
preload(): Promise<void>;
|
|
79
244
|
};
|
|
80
245
|
/** Wrap a dynamic-import factory as a {@link LazyRouteComponent}, loaded on first use. */
|
|
81
|
-
declare function lazy<TComponent extends AnyRouteComponent>(
|
|
82
|
-
|
|
83
|
-
|
|
246
|
+
declare function lazy<TComponent extends AnyRouteComponent>(
|
|
247
|
+
factory: () => Promise<
|
|
248
|
+
| {
|
|
249
|
+
default: TComponent;
|
|
250
|
+
}
|
|
251
|
+
| TComponent
|
|
252
|
+
>
|
|
253
|
+
): LazyRouteComponent<TComponent>;
|
|
84
254
|
/**
|
|
85
255
|
* Create a cached route loader backed by a dynamic import. The module is only
|
|
86
256
|
* requested when the owning route matches, unless preload() is called.
|
|
87
257
|
*/
|
|
88
|
-
declare function lazyRouteData<TModule, TData = TModule>(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
258
|
+
declare function lazyRouteData<TModule, TData = TModule>(
|
|
259
|
+
factory: () => PromiseLike<TModule>,
|
|
260
|
+
select?: (
|
|
261
|
+
module: TModule,
|
|
262
|
+
context: RouteContext & {
|
|
263
|
+
request?: Request;
|
|
264
|
+
}
|
|
265
|
+
) => TData | PromiseLike<TData>
|
|
266
|
+
): LazyRouteDataLoader<TModule, TData>;
|
|
93
267
|
/** Renders the nested route content for the enclosing layout or page scope. */
|
|
94
268
|
declare function Outlet(): JSXElement;
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/router/route-data-loader.d.ts
|
|
97
269
|
/** Which environment a route's data loader ran (or failed) in. */
|
|
98
270
|
type RouteDataLoadPhase = 'client' | 'server' | 'ssg';
|
|
99
271
|
/** Thrown when a route's `loader` rejects; wraps the original `cause`. */
|
|
@@ -103,15 +275,16 @@ declare class RouteDataLoadError extends Error {
|
|
|
103
275
|
readonly cause: unknown;
|
|
104
276
|
constructor(route: string, phase: RouteDataLoadPhase, cause: unknown);
|
|
105
277
|
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/router/policy.d.ts
|
|
108
278
|
/** Policy decision: allow the route to render. */
|
|
109
279
|
declare function allow(): AccessAllowDecision;
|
|
110
280
|
/** Policy decision: redirect the visitor to `to`. */
|
|
111
|
-
declare function redirect(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
281
|
+
declare function redirect(
|
|
282
|
+
to: string,
|
|
283
|
+
init?: {
|
|
284
|
+
status?: AccessRedirectStatus;
|
|
285
|
+
replace?: boolean;
|
|
286
|
+
}
|
|
287
|
+
): AccessRedirectDecision;
|
|
115
288
|
/** Policy decision: deny the request with the given HTTP status. */
|
|
116
289
|
declare function deny(status: AccessDenyStatus): AccessDenyDecision;
|
|
117
290
|
/** Policy decision: deny with 401 Unauthorized. */
|
|
@@ -120,20 +293,27 @@ declare function unauthorized(): AccessDenyDecision;
|
|
|
120
293
|
declare function forbidden(): AccessDenyDecision;
|
|
121
294
|
/** Policy decision: deny with 404 Not Found. */
|
|
122
295
|
declare function notFound(): AccessDenyDecision;
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/router/destination.d.ts
|
|
125
296
|
/** Build a {@link RouteDestination} (with a computed `href`) for a {@link RouteRef} and params/search. */
|
|
126
|
-
declare function to$1<
|
|
127
|
-
|
|
128
|
-
|
|
297
|
+
declare function to$1<
|
|
298
|
+
TParams extends RouteParams,
|
|
299
|
+
TSearch extends RouteSearch = RouteSearch,
|
|
300
|
+
>(
|
|
301
|
+
route: RouteRef<TParams, TSearch>,
|
|
302
|
+
params: TParams,
|
|
303
|
+
search?: TSearch
|
|
304
|
+
): RouteDestination;
|
|
129
305
|
/** Resolve a route's merged {@link RouteMeta} by running its metadata chain against `context`. */
|
|
130
|
-
declare function resolveRouteMeta(
|
|
306
|
+
declare function resolveRouteMeta(
|
|
307
|
+
record: RouteRecord,
|
|
308
|
+
context: RouteContext
|
|
309
|
+
): Promise<Readonly<RouteMeta>>;
|
|
131
310
|
/** Replace only Askr-owned head nodes after a successful client navigation. */
|
|
132
|
-
declare function reconcileRouteMeta(
|
|
311
|
+
declare function reconcileRouteMeta(
|
|
312
|
+
meta: Readonly<RouteMeta>,
|
|
313
|
+
target?: Document
|
|
314
|
+
): void;
|
|
133
315
|
/** Render a {@link RouteMeta} to the `<title>`/`<meta>`/`<link>`/JSON-LD markup for the document `<head>`. */
|
|
134
316
|
declare function serializeRouteMeta(meta: RouteMeta): string;
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/common/deferred-value.d.ts
|
|
137
317
|
declare const DEFERRED_VALUE: unique symbol;
|
|
138
318
|
/** Lifecycle state of a {@link Deferred} value. */
|
|
139
319
|
type DeferredState = 'pending' | 'fulfilled' | 'rejected';
|
|
@@ -149,8 +329,6 @@ interface Deferred<T> {
|
|
|
149
329
|
declare function defer<T>(promise: PromiseLike<T>): Deferred<T>;
|
|
150
330
|
/** Check whether `value` is a {@link Deferred} produced by {@link defer}. */
|
|
151
331
|
declare function isDeferred<T = unknown>(value: unknown): value is Deferred<T>;
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/router/deferred.d.ts
|
|
154
332
|
/** Props for {@link Resolve}. */
|
|
155
333
|
interface ResolveProps<T> {
|
|
156
334
|
value: Deferred<T>;
|
|
@@ -159,14 +337,24 @@ interface ResolveProps<T> {
|
|
|
159
337
|
children: (value: T) => RenderableChild;
|
|
160
338
|
}
|
|
161
339
|
/** Recursively await any {@link Deferred} values nested within `input`, returning it once fully resolved. */
|
|
162
|
-
declare function resolveDeferredValues<T>(
|
|
340
|
+
declare function resolveDeferredValues<T>(
|
|
341
|
+
input: T,
|
|
342
|
+
signal?: AbortSignal
|
|
343
|
+
): Promise<T>;
|
|
163
344
|
/** Read the current route's server loader data during render or hydration. */
|
|
164
345
|
declare function routeData<T>(): T;
|
|
165
346
|
/** Render a {@link Deferred} value's fulfilled state, a pending placeholder, or a rejected fallback. */
|
|
166
347
|
declare function Resolve<T>(props: ResolveProps<T>): JSXElement;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
348
|
+
type LinkBaseProps = Omit<
|
|
349
|
+
Props,
|
|
350
|
+
| 'children'
|
|
351
|
+
| 'href'
|
|
352
|
+
| 'class'
|
|
353
|
+
| 'rel'
|
|
354
|
+
| 'target'
|
|
355
|
+
| 'aria-current'
|
|
356
|
+
| 'aria-label'
|
|
357
|
+
> & {
|
|
170
358
|
class?: string;
|
|
171
359
|
children?: RenderableChild;
|
|
172
360
|
/**
|
|
@@ -183,7 +371,14 @@ type LinkBaseProps = Omit<Props, 'children' | 'href' | 'class' | 'rel' | 'target
|
|
|
183
371
|
* Optional aria-current attribute for indicating current page/location.
|
|
184
372
|
* Use "page" for the current page in navigation.
|
|
185
373
|
*/
|
|
186
|
-
'aria-current'?:
|
|
374
|
+
'aria-current'?:
|
|
375
|
+
| 'page'
|
|
376
|
+
| 'step'
|
|
377
|
+
| 'location'
|
|
378
|
+
| 'date'
|
|
379
|
+
| 'time'
|
|
380
|
+
| 'true'
|
|
381
|
+
| 'false';
|
|
187
382
|
/**
|
|
188
383
|
* Optional aria-label for accessibility when link text isn't descriptive enough.
|
|
189
384
|
*/
|
|
@@ -192,13 +387,17 @@ type LinkBaseProps = Omit<Props, 'children' | 'href' | 'class' | 'rel' | 'target
|
|
|
192
387
|
onClick?: (event: MouseEvent) => void;
|
|
193
388
|
};
|
|
194
389
|
/** Props for {@link Link}: either a raw `href` or a typed route `to` destination. */
|
|
195
|
-
type LinkProps = LinkBaseProps &
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
390
|
+
type LinkProps = LinkBaseProps &
|
|
391
|
+
(
|
|
392
|
+
| {
|
|
393
|
+
href: string;
|
|
394
|
+
to?: never;
|
|
395
|
+
}
|
|
396
|
+
| {
|
|
397
|
+
href?: never;
|
|
398
|
+
to: RouteDestination;
|
|
399
|
+
}
|
|
400
|
+
);
|
|
202
401
|
/**
|
|
203
402
|
* Link component that prevents default navigation and uses navigate()
|
|
204
403
|
* Provides declarative way to navigate between routes
|
|
@@ -228,6 +427,106 @@ type LinkProps = LinkBaseProps & ({
|
|
|
228
427
|
* - Keyboard handling automatic
|
|
229
428
|
* - Composable via mergeProps
|
|
230
429
|
*/
|
|
231
|
-
declare function Link({
|
|
232
|
-
|
|
233
|
-
|
|
430
|
+
declare function Link({
|
|
431
|
+
href: suppliedHref,
|
|
432
|
+
to,
|
|
433
|
+
class: className,
|
|
434
|
+
children,
|
|
435
|
+
rel,
|
|
436
|
+
target,
|
|
437
|
+
'aria-current': ariaCurrent,
|
|
438
|
+
'aria-label': ariaLabel,
|
|
439
|
+
onPress,
|
|
440
|
+
onClick,
|
|
441
|
+
...rest
|
|
442
|
+
}: LinkProps): JSXElement;
|
|
443
|
+
export {
|
|
444
|
+
type AccessDecision,
|
|
445
|
+
type AccessDenyDecision,
|
|
446
|
+
type AccessRedirectDecision,
|
|
447
|
+
type AuthContext,
|
|
448
|
+
type AuthRequirement,
|
|
449
|
+
type Deferred,
|
|
450
|
+
type DeferredState,
|
|
451
|
+
type GroupHelperOptions,
|
|
452
|
+
type HistoryScrollBehavior,
|
|
453
|
+
type LayoutScopeRecord,
|
|
454
|
+
type LazyRouteComponent,
|
|
455
|
+
type LazyRouteDataLoader,
|
|
456
|
+
Link,
|
|
457
|
+
type LinkProps,
|
|
458
|
+
type NavigateOptions,
|
|
459
|
+
type NavigationScrollBehavior,
|
|
460
|
+
Outlet,
|
|
461
|
+
type PageHelperOptions,
|
|
462
|
+
type PageScopeRecord,
|
|
463
|
+
type ParsedSegment,
|
|
464
|
+
Resolve,
|
|
465
|
+
type ResolveProps,
|
|
466
|
+
type Route,
|
|
467
|
+
type RouteAuthOptions,
|
|
468
|
+
type RouteAuthResolver,
|
|
469
|
+
type RouteChangeCleanup,
|
|
470
|
+
type RouteChangeOptions,
|
|
471
|
+
type RouteComponent,
|
|
472
|
+
type RouteContext,
|
|
473
|
+
RouteDataLoadError,
|
|
474
|
+
type RouteDataLoadPhase,
|
|
475
|
+
type RouteDefinition,
|
|
476
|
+
type RouteDestination,
|
|
477
|
+
type RouteHandler,
|
|
478
|
+
type RouteManifest,
|
|
479
|
+
type RouteMatch,
|
|
480
|
+
type RouteMeta,
|
|
481
|
+
type RouteMetaSource,
|
|
482
|
+
type RouteMode,
|
|
483
|
+
type RouteOptions,
|
|
484
|
+
type RouteParams,
|
|
485
|
+
type RoutePathParams,
|
|
486
|
+
type RoutePolicy,
|
|
487
|
+
type RouteQuery,
|
|
488
|
+
type RouteQueryParamInput,
|
|
489
|
+
type RouteQueryParamValue,
|
|
490
|
+
type RouteQueryUpdater,
|
|
491
|
+
type RouteQueryUpdates,
|
|
492
|
+
type RouteRecord,
|
|
493
|
+
type RouteRef,
|
|
494
|
+
type RouteRegistry,
|
|
495
|
+
type RouteRegistryOptions,
|
|
496
|
+
type RouteRenderResult,
|
|
497
|
+
type RouteRequestOptions,
|
|
498
|
+
type RouteRequestResult,
|
|
499
|
+
type RouteSearch,
|
|
500
|
+
type RouteSearchValue,
|
|
501
|
+
type RouteSnapshot,
|
|
502
|
+
type ScrollRestorationOptions,
|
|
503
|
+
type UpdateRouteQueryOptions,
|
|
504
|
+
allow,
|
|
505
|
+
createRouteRegistry,
|
|
506
|
+
currentAuth,
|
|
507
|
+
currentRoute,
|
|
508
|
+
defer,
|
|
509
|
+
deny,
|
|
510
|
+
fallback,
|
|
511
|
+
forbidden,
|
|
512
|
+
group,
|
|
513
|
+
index,
|
|
514
|
+
isDeferred,
|
|
515
|
+
lazy,
|
|
516
|
+
lazyRouteData,
|
|
517
|
+
navigate,
|
|
518
|
+
notFound,
|
|
519
|
+
onRouteChange,
|
|
520
|
+
page,
|
|
521
|
+
reconcileRouteMeta,
|
|
522
|
+
redirect,
|
|
523
|
+
resolveDeferredValues,
|
|
524
|
+
resolveRouteMeta,
|
|
525
|
+
resolveRouteRequest,
|
|
526
|
+
route,
|
|
527
|
+
routeData,
|
|
528
|
+
serializeRouteMeta,
|
|
529
|
+
to$1 as to,
|
|
530
|
+
unauthorized,
|
|
531
|
+
updateRouteQuery,
|
|
532
|
+
};
|
package/dist/router/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { n as createRouteRegistry } from "../manifest-
|
|
2
|
-
import {
|
|
3
|
-
import { jsx } from "../jsx-runtime.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { S as
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
1
|
+
import { n as createRouteRegistry } from "../manifest-D1P3UNWV.js";
|
|
2
|
+
import { n as isSafeHref } from "../router-internal-7nuNEHfG.js";
|
|
3
|
+
import { t as jsx } from "../jsx-runtime-CPJXAOBF.js";
|
|
4
|
+
import { a as serializeRouteMeta, c as getCurrentHref, d as parseTargetUrl, h as syncRegisteredRouteSnapshot, i as resolveRouteMeta, l as getRegisteredAppsSnapshot, m as syncAppRegistrationLocation, n as navigate, p as setCurrentRouteLocation, r as reconcileRouteMeta, s as saveScrollPosition, u as getWindowHref } from "../navigate-prC5V8XV.js";
|
|
5
|
+
import { n as onRouteChange, t as currentRoute } from "../activity-oy2YFTFF.js";
|
|
6
|
+
import { S as isDeferred, a as resolveRouteRequest, c as Outlet, f as lazy, m as RouteDataLoadError, p as lazyRouteData, s as currentAuth, x as defer } from "../resolution-3DskUkjG.js";
|
|
7
|
+
import { b as getActiveRouteBasePath, o as addRouteBasePath } from "../route-matching-CUzZ31gT.js";
|
|
8
|
+
import { a as group, c as route, i as fallback, n as resolveDeferredValues, o as index, r as routeData, s as page, t as Resolve } from "../deferred-CbgNhf67.js";
|
|
9
9
|
import { i as mergeProps } from "../aria-hKjThHcp.js";
|
|
10
|
-
import { t as applyInteractionPolicy } from "../interactions-
|
|
10
|
+
import { t as applyInteractionPolicy } from "../interactions-CTeACdT_.js";
|
|
11
11
|
//#region src/router/route-query.ts
|
|
12
12
|
function getRouteQueryHistoryMode(options) {
|
|
13
13
|
if (options.history) return options.history;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/common/url.ts
|
|
2
|
+
const SAFE_URL_SCHEMES = /* @__PURE__ */ new Set([
|
|
3
|
+
"http",
|
|
4
|
+
"https",
|
|
5
|
+
"mailto",
|
|
6
|
+
"sms",
|
|
7
|
+
"tel"
|
|
8
|
+
]);
|
|
9
|
+
const URL_SCHEME_RE = /^([a-z][a-z0-9+.-]*):/i;
|
|
10
|
+
function isSafeHref(value) {
|
|
11
|
+
const compact = value.trim().replace(/[\u0000-\u0020\u007f-\u009f]/g, "");
|
|
12
|
+
const scheme = URL_SCHEME_RE.exec(compact)?.[1]?.toLowerCase();
|
|
13
|
+
return scheme === void 0 || SAFE_URL_SCHEMES.has(scheme);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Attribute names (lowercased) that can carry a browser-navigable/executable
|
|
17
|
+
* URL and must be checked against isSafeHref. Shared between the client
|
|
18
|
+
* renderer (renderer/attributes.ts) and SSR (ssr/attrs.ts) so their unsafe-
|
|
19
|
+
* URL handling can't drift. Deliberately excludes `src`: it covers a much
|
|
20
|
+
* wider range of legitimate non-navigable values (data: image URIs, blob:
|
|
21
|
+
* URLs, etc.) where the same scheme allowlist would be overly aggressive.
|
|
22
|
+
*/
|
|
23
|
+
const UNSAFE_URL_SCHEME_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
24
|
+
"href",
|
|
25
|
+
"formaction",
|
|
26
|
+
"action",
|
|
27
|
+
"xlink:href"
|
|
28
|
+
]);
|
|
29
|
+
function isUnsafeUrlAttribute(key, value) {
|
|
30
|
+
return UNSAFE_URL_SCHEME_ATTRIBUTES.has(key.toLowerCase()) && !isSafeHref(String(value));
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/common/router-internal.ts
|
|
34
|
+
const ROUTE_ROOT_COMPONENT = Symbol.for("askr.route-root-component");
|
|
35
|
+
//#endregion
|
|
36
|
+
export { isSafeHref as n, isUnsafeUrlAttribute as r, ROUTE_ROOT_COMPONENT as t };
|