@alepha/react 0.6.10 → 0.7.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/dist/index.browser.cjs +2 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +80 -52
- package/dist/index.js +35 -18
- package/dist/index.js.map +1 -1
- package/dist/{useActive-ClUsghB5.js → useActive-BX41CqY8.js} +96 -98
- package/dist/useActive-BX41CqY8.js.map +1 -0
- package/dist/{useActive-4QlZKGbw.cjs → useActive-DjpZBEuB.cjs} +96 -97
- package/dist/useActive-DjpZBEuB.cjs.map +1 -0
- package/package.json +7 -7
- package/src/components/ErrorBoundary.tsx +72 -0
- package/src/components/Link.tsx +2 -2
- package/src/components/NestedView.tsx +10 -1
- package/src/descriptors/$page.ts +4 -8
- package/src/hooks/RouterHookApi.ts +18 -32
- package/src/hooks/useInject.ts +1 -7
- package/src/hooks/useQueryParams.ts +3 -6
- package/src/index.shared.ts +1 -0
- package/src/index.ts +4 -0
- package/src/providers/BrowserRouterProvider.ts +26 -32
- package/src/providers/PageDescriptorProvider.ts +21 -22
- package/src/providers/ReactBrowserProvider.ts +17 -20
- package/src/providers/ReactServerProvider.ts +37 -16
- package/dist/useActive-4QlZKGbw.cjs.map +0 -1
- package/dist/useActive-ClUsghB5.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $hook, $inject, $logger, Alepha, OPTIONS } from "@alepha/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApiLinksResponse } from "@alepha/server";
|
|
3
3
|
import { type ReactNode, createElement } from "react";
|
|
4
4
|
import NestedView from "../components/NestedView.tsx";
|
|
5
5
|
import { RouterContext } from "../contexts/RouterContext.ts";
|
|
@@ -30,7 +30,7 @@ export class PageDescriptorProvider {
|
|
|
30
30
|
throw new Error(`Page ${name} not found`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public root(state: RouterState, context: PageReactContext
|
|
33
|
+
public root(state: RouterState, context: PageReactContext): ReactNode {
|
|
34
34
|
return createElement(
|
|
35
35
|
RouterContext.Provider,
|
|
36
36
|
{
|
|
@@ -52,6 +52,7 @@ export class PageDescriptorProvider {
|
|
|
52
52
|
const layers: Layer[] = []; // result layers
|
|
53
53
|
let context: Record<string, any> = {}; // all props
|
|
54
54
|
const stack: Array<RouterStackItem> = [{ route }]; // stack of routes
|
|
55
|
+
let onError = this.renderError; // error handler
|
|
55
56
|
|
|
56
57
|
let parent = route.parent;
|
|
57
58
|
while (parent) {
|
|
@@ -147,7 +148,6 @@ export class PageDescriptorProvider {
|
|
|
147
148
|
return {
|
|
148
149
|
layers: [],
|
|
149
150
|
redirect: typeof e.page === "string" ? e.page : this.href(e.page),
|
|
150
|
-
head: request.head,
|
|
151
151
|
pathname,
|
|
152
152
|
search,
|
|
153
153
|
};
|
|
@@ -180,17 +180,14 @@ export class PageDescriptorProvider {
|
|
|
180
180
|
acc += "/";
|
|
181
181
|
acc += it.route.path ? this.compile(it.route.path, params) : "";
|
|
182
182
|
const path = acc.replace(/\/+/, "/");
|
|
183
|
+
const localErrorHandler = this.getErrorHandler(it.route);
|
|
184
|
+
if (localErrorHandler) {
|
|
185
|
+
onError = localErrorHandler;
|
|
186
|
+
}
|
|
183
187
|
|
|
184
188
|
// handler has thrown an error, render an error view
|
|
185
189
|
if (it.error) {
|
|
186
|
-
const
|
|
187
|
-
const element = await (errorHandler
|
|
188
|
-
? errorHandler({
|
|
189
|
-
...it.config,
|
|
190
|
-
error: it.error,
|
|
191
|
-
url: "",
|
|
192
|
-
})
|
|
193
|
-
: this.renderError(it.error));
|
|
190
|
+
const element = await onError(it.error);
|
|
194
191
|
|
|
195
192
|
layers.push({
|
|
196
193
|
props,
|
|
@@ -223,7 +220,7 @@ export class PageDescriptorProvider {
|
|
|
223
220
|
});
|
|
224
221
|
}
|
|
225
222
|
|
|
226
|
-
return { layers,
|
|
223
|
+
return { layers, pathname, search };
|
|
227
224
|
}
|
|
228
225
|
|
|
229
226
|
protected getErrorHandler(route: PageRoute) {
|
|
@@ -471,15 +468,14 @@ export interface Layer {
|
|
|
471
468
|
export type PreviousLayerData = Omit<Layer, "element">;
|
|
472
469
|
|
|
473
470
|
export interface AnchorProps {
|
|
474
|
-
href
|
|
475
|
-
onClick
|
|
471
|
+
href: string;
|
|
472
|
+
onClick: (ev: any) => any;
|
|
476
473
|
}
|
|
477
474
|
|
|
478
475
|
export interface RouterState {
|
|
479
476
|
pathname: string;
|
|
480
477
|
search: string;
|
|
481
478
|
layers: Array<Layer>;
|
|
482
|
-
head: Head;
|
|
483
479
|
}
|
|
484
480
|
|
|
485
481
|
export interface TransitionOptions {
|
|
@@ -496,17 +492,14 @@ export interface RouterStackItem {
|
|
|
496
492
|
}
|
|
497
493
|
|
|
498
494
|
export interface RouterRenderResult {
|
|
495
|
+
state: RouterState;
|
|
496
|
+
context: PageReactContext;
|
|
499
497
|
redirect?: string;
|
|
500
|
-
layers: Layer[];
|
|
501
|
-
head: Head;
|
|
502
|
-
element: ReactNode;
|
|
503
498
|
}
|
|
504
499
|
|
|
505
500
|
export interface PageRequest extends PageReactContext {
|
|
506
|
-
url: URL;
|
|
507
501
|
params: Record<string, any>;
|
|
508
502
|
query: Record<string, string>;
|
|
509
|
-
head: Head;
|
|
510
503
|
|
|
511
504
|
// previous layers (browser history or browser hydration, always null on server)
|
|
512
505
|
previous?: PreviousLayerData[];
|
|
@@ -516,7 +509,13 @@ export interface CreateLayersResult extends RouterState {
|
|
|
516
509
|
redirect?: string;
|
|
517
510
|
}
|
|
518
511
|
|
|
519
|
-
|
|
512
|
+
/**
|
|
513
|
+
* It's like RouterState, but publicly available in React context.
|
|
514
|
+
* This is where we store all plugin data!
|
|
515
|
+
*/
|
|
520
516
|
export interface PageReactContext {
|
|
521
|
-
|
|
517
|
+
url: URL;
|
|
518
|
+
head: Head;
|
|
519
|
+
onError: (error: Error) => ReactNode;
|
|
520
|
+
links?: ApiLinksResponse;
|
|
522
521
|
}
|
|
@@ -2,11 +2,11 @@ import { $hook, $inject, $logger, Alepha, type Static, t } from "@alepha/core";
|
|
|
2
2
|
import { HttpClient, type HttpClientLink } from "@alepha/server";
|
|
3
3
|
import type { Root } from "react-dom/client";
|
|
4
4
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
5
|
-
import type { Head } from "../descriptors/$page.ts";
|
|
6
5
|
import { BrowserHeadProvider } from "./BrowserHeadProvider.ts";
|
|
7
6
|
import { BrowserRouterProvider } from "./BrowserRouterProvider.ts";
|
|
8
7
|
import type {
|
|
9
8
|
PreviousLayerData,
|
|
9
|
+
RouterRenderResult,
|
|
10
10
|
RouterState,
|
|
11
11
|
TransitionOptions,
|
|
12
12
|
} from "./PageDescriptorProvider.ts";
|
|
@@ -36,7 +36,6 @@ export class ReactBrowserProvider {
|
|
|
36
36
|
layers: [],
|
|
37
37
|
pathname: "",
|
|
38
38
|
search: "",
|
|
39
|
-
head: {},
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
public get document() {
|
|
@@ -86,8 +85,10 @@ export class ReactBrowserProvider {
|
|
|
86
85
|
url,
|
|
87
86
|
});
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
// when redirecting in browser
|
|
89
|
+
if (result.context.url.pathname !== url) {
|
|
90
|
+
// TODO: check if losing search params is acceptable?
|
|
91
|
+
this.history.replaceState({}, "", result.context.url.pathname);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -104,7 +105,7 @@ export class ReactBrowserProvider {
|
|
|
104
105
|
url?: string;
|
|
105
106
|
previous?: PreviousLayerData[];
|
|
106
107
|
} = {},
|
|
107
|
-
): Promise<
|
|
108
|
+
): Promise<RouterRenderResult> {
|
|
108
109
|
const previous = options.previous ?? this.state.layers;
|
|
109
110
|
const url = options.url ?? this.url;
|
|
110
111
|
|
|
@@ -124,7 +125,7 @@ export class ReactBrowserProvider {
|
|
|
124
125
|
|
|
125
126
|
this.transitioning = undefined;
|
|
126
127
|
|
|
127
|
-
return
|
|
128
|
+
return result;
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
/**
|
|
@@ -173,17 +174,18 @@ export class ReactBrowserProvider {
|
|
|
173
174
|
const previous = hydration?.layers ?? [];
|
|
174
175
|
|
|
175
176
|
if (hydration?.links) {
|
|
176
|
-
|
|
177
|
+
for (const link of hydration.links) {
|
|
178
|
+
this.client.pushLink(link);
|
|
179
|
+
}
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
const {
|
|
180
|
-
if (head) {
|
|
181
|
-
this.headProvider.renderHead(this.document, head);
|
|
182
|
+
const { context } = await this.render({ previous });
|
|
183
|
+
if (context.head) {
|
|
184
|
+
this.headProvider.renderHead(this.document, context.head);
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
const context = {};
|
|
185
|
-
|
|
186
187
|
await this.alepha.emit("react:browser:render", {
|
|
188
|
+
state: this.state,
|
|
187
189
|
context,
|
|
188
190
|
hydration,
|
|
189
191
|
});
|
|
@@ -202,19 +204,13 @@ export class ReactBrowserProvider {
|
|
|
202
204
|
window.addEventListener("popstate", () => {
|
|
203
205
|
this.render();
|
|
204
206
|
});
|
|
205
|
-
|
|
206
|
-
this.alepha.on("react:transition:end", {
|
|
207
|
-
callback: ({ state }) => {
|
|
208
|
-
this.headProvider.renderHead(this.document, state.head);
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
207
|
},
|
|
212
208
|
});
|
|
213
209
|
|
|
214
210
|
public readonly onTransitionEnd = $hook({
|
|
215
211
|
name: "react:transition:end",
|
|
216
|
-
handler: async ({
|
|
217
|
-
this.headProvider.renderHead(this.document,
|
|
212
|
+
handler: async ({ context }) => {
|
|
213
|
+
this.headProvider.renderHead(this.document, context.head);
|
|
218
214
|
},
|
|
219
215
|
});
|
|
220
216
|
}
|
|
@@ -224,6 +220,7 @@ export class ReactBrowserProvider {
|
|
|
224
220
|
export interface RouterGoOptions {
|
|
225
221
|
replace?: boolean;
|
|
226
222
|
match?: TransitionOptions;
|
|
223
|
+
params?: Record<string, string>;
|
|
227
224
|
}
|
|
228
225
|
|
|
229
226
|
export interface ReactHydrationState {
|
|
@@ -144,6 +144,9 @@ export class ReactServerProvider {
|
|
|
144
144
|
);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* For testing purposes, creates a render function that can be used.
|
|
149
|
+
*/
|
|
147
150
|
protected createRenderFunction(name: string) {
|
|
148
151
|
return async (
|
|
149
152
|
options: {
|
|
@@ -152,15 +155,21 @@ export class ReactServerProvider {
|
|
|
152
155
|
} = {},
|
|
153
156
|
) => {
|
|
154
157
|
const page = this.pageDescriptorProvider.page(name);
|
|
155
|
-
|
|
156
|
-
const state = await this.pageDescriptorProvider.createLayers(page, {
|
|
158
|
+
const context: PageRequest = {
|
|
157
159
|
url: new URL("http://localhost"),
|
|
158
160
|
params: options.params ?? {},
|
|
159
161
|
query: options.query ?? {},
|
|
160
162
|
head: {},
|
|
161
|
-
|
|
163
|
+
onError: () => null,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// for testing
|
|
167
|
+
const state = await this.pageDescriptorProvider.createLayers(
|
|
168
|
+
page,
|
|
169
|
+
context,
|
|
170
|
+
);
|
|
162
171
|
|
|
163
|
-
return renderToString(this.pageDescriptorProvider.root(state));
|
|
172
|
+
return renderToString(this.pageDescriptorProvider.root(state, context));
|
|
164
173
|
};
|
|
165
174
|
}
|
|
166
175
|
|
|
@@ -175,25 +184,32 @@ export class ReactServerProvider {
|
|
|
175
184
|
throw new Error("Template not found");
|
|
176
185
|
}
|
|
177
186
|
|
|
178
|
-
const
|
|
187
|
+
const context: PageRequest = {
|
|
179
188
|
url,
|
|
180
189
|
params,
|
|
181
190
|
query,
|
|
191
|
+
// plugins
|
|
182
192
|
head: {},
|
|
193
|
+
onError: () => null,
|
|
183
194
|
};
|
|
184
195
|
|
|
185
196
|
// -- links
|
|
186
197
|
if (this.alepha.has(ServerLinksProvider)) {
|
|
187
198
|
const srv = this.alepha.get(ServerLinksProvider);
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
|
|
200
|
+
context.links = await srv.getLinks({
|
|
201
|
+
user: serverRequest.user,
|
|
202
|
+
authorization: serverRequest.headers.authorization,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
this.alepha.als.set("links", context.links);
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
await this.alepha.emit(
|
|
193
209
|
"react:server:render",
|
|
194
210
|
{
|
|
195
211
|
request: serverRequest,
|
|
196
|
-
pageRequest:
|
|
212
|
+
pageRequest: context,
|
|
197
213
|
},
|
|
198
214
|
{
|
|
199
215
|
log: false,
|
|
@@ -202,19 +218,18 @@ export class ReactServerProvider {
|
|
|
202
218
|
|
|
203
219
|
const state = await this.pageDescriptorProvider.createLayers(
|
|
204
220
|
page,
|
|
205
|
-
|
|
221
|
+
context,
|
|
206
222
|
);
|
|
207
223
|
|
|
208
224
|
if (state.redirect) {
|
|
209
225
|
return reply.redirect(state.redirect);
|
|
210
226
|
}
|
|
211
227
|
|
|
212
|
-
const element = this.pageDescriptorProvider.root(state,
|
|
228
|
+
const element = this.pageDescriptorProvider.root(state, context);
|
|
213
229
|
const app = renderToString(element);
|
|
214
230
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
links: request.links,
|
|
231
|
+
const hydrationData = {
|
|
232
|
+
links: context.links,
|
|
218
233
|
layers: state.layers.map((it) => ({
|
|
219
234
|
...it,
|
|
220
235
|
error: it.error
|
|
@@ -229,7 +244,10 @@ export class ReactServerProvider {
|
|
|
229
244
|
path: undefined,
|
|
230
245
|
element: undefined,
|
|
231
246
|
})),
|
|
232
|
-
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// create hydration data
|
|
250
|
+
const script = `<script>window.__ssr=${JSON.stringify(hydrationData)}</script>`;
|
|
233
251
|
|
|
234
252
|
const response = {
|
|
235
253
|
html: template,
|
|
@@ -246,8 +264,11 @@ export class ReactServerProvider {
|
|
|
246
264
|
this.fillTemplate(response, app, script);
|
|
247
265
|
|
|
248
266
|
// inject head meta
|
|
249
|
-
if (
|
|
250
|
-
response.html = this.headProvider.renderHead(
|
|
267
|
+
if (context.head) {
|
|
268
|
+
response.html = this.headProvider.renderHead(
|
|
269
|
+
response.html,
|
|
270
|
+
context.head,
|
|
271
|
+
);
|
|
251
272
|
}
|
|
252
273
|
|
|
253
274
|
// TODO: hook for plugins "react:server:template"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useActive-4QlZKGbw.cjs","sources":["../src/descriptors/$page.ts","../src/contexts/RouterContext.ts","../src/contexts/RouterLayerContext.ts","../src/hooks/useRouterEvents.ts","../src/components/NestedView.tsx","../src/errors/RedirectionError.ts","../src/providers/PageDescriptorProvider.ts","../src/providers/BrowserHeadProvider.ts","../src/providers/BrowserRouterProvider.ts","../src/providers/ReactBrowserProvider.ts","../src/hooks/RouterHookApi.ts","../src/hooks/useRouter.ts","../src/components/Link.tsx","../src/hooks/useInject.ts","../src/hooks/useClient.ts","../src/hooks/useQueryParams.ts","../src/hooks/useRouterState.ts","../src/hooks/useActive.ts"],"sourcesContent":["import { type Async, OPTIONS, type Static, type TSchema } from \"@alepha/core\";\nimport { KIND, NotImplementedError, __descriptor } from \"@alepha/core\";\nimport type { FC } from \"react\";\nimport type { RouterHookApi } from \"../hooks/RouterHookApi.ts\";\n\nconst KEY = \"PAGE\";\n\nexport interface PageConfigSchema {\n\tquery?: TSchema;\n\tparams?: TSchema;\n}\n\nexport type TPropsDefault = any;\n\nexport type TPropsParentDefault = object;\n\nexport interface PageDescriptorOptions<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\tname?: string;\n\n\tpath?: string;\n\n\tschema?: TConfig;\n\n\tresolve?: (config: PageResolve<TConfig, TPropsParent>) => Async<TProps>;\n\n\tcomponent?: FC<TProps & TPropsParent>;\n\n\tlazy?: () => Promise<{ default: FC<TProps & TPropsParent> }>;\n\n\tchildren?: Array<{ [OPTIONS]: PageDescriptorOptions }>;\n\n\tparent?: { [OPTIONS]: PageDescriptorOptions<any, TPropsParent> };\n\n\tcan?: () => boolean;\n\n\thead?: Head | ((props: TProps, previous?: Head) => Head);\n\n\terrorHandler?: FC<{ error: Error; url: string }>;\n}\n\nexport interface PageDescriptor<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\t[KIND]: typeof KEY;\n\t[OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;\n\n\trender: (options?: {\n\t\tparams?: Record<string, string>;\n\t\tquery?: Record<string, string>;\n\t}) => Promise<string>;\n\tgo: () => void;\n\tcreateAnchorProps: (routerHook: RouterHookApi) => {\n\t\thref: string;\n\t\tonClick: () => void;\n\t};\n\tcan: () => boolean;\n}\n\nexport const $page = <\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n>(\n\toptions: PageDescriptorOptions<TConfig, TProps, TPropsParent>,\n): PageDescriptor<TConfig, TProps, TPropsParent> => {\n\t__descriptor(KEY);\n\n\tif (options.children) {\n\t\tfor (const child of options.children) {\n\t\t\tchild[OPTIONS].parent = {\n\t\t\t\t[OPTIONS]: options as PageDescriptorOptions<any, any, any>,\n\t\t\t};\n\t\t}\n\t}\n\n\tif (options.parent) {\n\t\toptions.parent[OPTIONS].children ??= [];\n\t\toptions.parent[OPTIONS].children.push({\n\t\t\t[OPTIONS]: options as PageDescriptorOptions<any, any, any>,\n\t\t});\n\t}\n\n\treturn {\n\t\t[KIND]: KEY,\n\t\t[OPTIONS]: options,\n\t\trender: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tgo: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tcreateAnchorProps: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tcan: () => {\n\t\t\tif (options.can) {\n\t\t\t\treturn options.can();\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n};\n\n$page[KIND] = KEY;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Head {\n\ttitle?: string;\n\ttitleSeparator?: string;\n\thtmlAttributes?: Record<string, string>;\n\tbodyAttributes?: Record<string, string>;\n\tmeta?: Array<{ name: string; content: string }>;\n}\n\nexport interface PageRequestConfig<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n> {\n\tparams: TConfig[\"params\"] extends TSchema\n\t\t? Static<TConfig[\"params\"]>\n\t\t: Record<string, string>;\n\n\tquery: TConfig[\"query\"] extends TSchema\n\t\t? Static<TConfig[\"query\"]>\n\t\t: Record<string, string>;\n}\n\nexport type PageResolve<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTPropsParent extends object = TPropsParentDefault,\n> = PageRequestConfig<TConfig> & TPropsParent & PageResolveContext;\n\nexport interface PageResolveContext {\n\turl: URL;\n\thead: Head;\n}\n","import type { Alepha } from \"@alepha/core\";\nimport { createContext } from \"react\";\nimport type {\n\tPageReactContext,\n\tRouterState,\n} from \"../providers/PageDescriptorProvider.ts\";\n\nexport interface RouterContextValue {\n\talepha: Alepha;\n\tstate: RouterState;\n\tcontext: PageReactContext;\n}\n\nexport const RouterContext = createContext<RouterContextValue | undefined>(\n\tundefined,\n);\n","import { createContext } from \"react\";\n\nexport interface RouterLayerContextValue {\n\tindex: number;\n\tpath: string;\n}\n\nexport const RouterLayerContext = createContext<\n\tRouterLayerContextValue | undefined\n>(undefined);\n","import { useContext, useEffect } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport type { RouterState } from \"../providers/PageDescriptorProvider.ts\";\n\nexport const useRouterEvents = (\n\topts: {\n\t\tonBegin?: (ev: { state: RouterState }) => void;\n\t\tonEnd?: (ev: { state: RouterState }) => void;\n\t\tonError?: (ev: { state: RouterState; error: Error }) => void;\n\t} = {},\n\tdeps: any[] = [],\n) => {\n\tconst ctx = useContext(RouterContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\tuseEffect(() => {\n\t\tif (!ctx.alepha.isBrowser()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst subs: Function[] = [];\n\t\tconst onBegin = opts.onBegin;\n\t\tconst onEnd = opts.onEnd;\n\t\tconst onError = opts.onError;\n\n\t\tif (onBegin) {\n\t\t\tsubs.push(\n\t\t\t\tctx.alepha.on(\"react:transition:begin\", {\n\t\t\t\t\tcallback: onBegin,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (onEnd) {\n\t\t\tsubs.push(\n\t\t\t\tctx.alepha.on(\"react:transition:end\", {\n\t\t\t\t\tcallback: onEnd,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (onError) {\n\t\t\tsubs.push(\n\t\t\t\tctx.alepha.on(\"react:transition:error\", {\n\t\t\t\t\tcallback: onError,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor (const sub of subs) {\n\t\t\t\tsub();\n\t\t\t}\n\t\t};\n\t}, deps);\n};\n","import type { ReactNode } from \"react\";\nimport { useContext, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport { useRouterEvents } from \"../hooks/useRouterEvents.ts\";\n\nexport interface NestedViewProps {\n\tchildren?: ReactNode;\n}\n\n/**\n * Nested view component\n *\n * @param props\n * @constructor\n */\nconst NestedView = (props: NestedViewProps) => {\n\tconst app = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tconst index = layer?.index ?? 0;\n\n\tconst [view, setView] = useState<ReactNode | undefined>(\n\t\tapp?.state.layers[index]?.element,\n\t);\n\n\tuseRouterEvents(\n\t\t{\n\t\t\tonEnd: ({ state }) => {\n\t\t\t\tsetView(state.layers[index]?.element);\n\t\t\t},\n\t\t},\n\t\t[app],\n\t);\n\n\treturn view ?? props.children ?? null;\n};\n\nexport default NestedView;\n","import type { HrefLike } from \"../hooks/RouterHookApi.ts\";\n\nexport class RedirectionError extends Error {\n\tconstructor(public readonly page: HrefLike) {\n\t\tsuper(\"Redirection\");\n\t}\n}\n","import { $hook, $inject, $logger, Alepha, OPTIONS } from \"@alepha/core\";\nimport type { HttpClientLink } from \"@alepha/server\";\nimport { type ReactNode, createElement } from \"react\";\nimport NestedView from \"../components/NestedView.tsx\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport {\n\t$page,\n\ttype Head,\n\ttype PageDescriptorOptions,\n} from \"../descriptors/$page.ts\";\nimport { RedirectionError } from \"../errors/RedirectionError.ts\";\n\nexport class PageDescriptorProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pages: PageRoute[] = [];\n\n\tpublic getPages(): PageRoute[] {\n\t\treturn this.pages;\n\t}\n\n\tpublic page(name: string): PageRoute {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === name) {\n\t\t\t\treturn page;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Page ${name} not found`);\n\t}\n\n\tpublic root(state: RouterState, context: PageReactContext = {}): ReactNode {\n\t\treturn createElement(\n\t\t\tRouterContext.Provider,\n\t\t\t{\n\t\t\t\tvalue: {\n\t\t\t\t\talepha: this.alepha,\n\t\t\t\t\tstate,\n\t\t\t\t\tcontext,\n\t\t\t\t},\n\t\t\t},\n\t\t\tcreateElement(NestedView, {}, state.layers[0]?.element),\n\t\t);\n\t}\n\n\tpublic async createLayers(\n\t\troute: PageRoute,\n\t\trequest: PageRequest,\n\t): Promise<CreateLayersResult> {\n\t\tconst { pathname, search } = request.url;\n\t\tconst layers: Layer[] = []; // result layers\n\t\tlet context: Record<string, any> = {}; // all props\n\t\tconst stack: Array<RouterStackItem> = [{ route }]; // stack of routes\n\n\t\tlet parent = route.parent;\n\t\twhile (parent) {\n\t\t\tstack.unshift({ route: parent });\n\t\t\tparent = parent.parent;\n\t\t}\n\n\t\tlet forceRefresh = false;\n\n\t\tfor (let i = 0; i < stack.length; i++) {\n\t\t\tconst it = stack[i];\n\t\t\tconst route = it.route;\n\t\t\tconst config: Record<string, any> = {};\n\n\t\t\ttry {\n\t\t\t\tconfig.query = route.schema?.query\n\t\t\t\t\t? this.alepha.parse(route.schema.query, request.query)\n\t\t\t\t\t: request.query;\n\t\t\t} catch (e) {\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconfig.params = route.schema?.params\n\t\t\t\t\t? this.alepha.parse(route.schema.params, request.params)\n\t\t\t\t\t: request.params;\n\t\t\t} catch (e) {\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// save config\n\t\t\tit.config = {\n\t\t\t\t...config,\n\t\t\t};\n\n\t\t\t// no resolve, render a basic view by default\n\t\t\tif (!route.resolve) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// check if previous layer is the same, reuse if possible\n\t\t\tconst previous = request.previous;\n\t\t\tif (previous?.[i] && !forceRefresh && previous[i].name === route.name) {\n\t\t\t\tconst url = (str?: string) => (str ? str.replace(/\\/\\/+/g, \"/\") : \"/\");\n\n\t\t\t\tconst prev = JSON.stringify({\n\t\t\t\t\tpart: url(previous[i].part),\n\t\t\t\t\tparams: previous[i].config?.params ?? {},\n\t\t\t\t});\n\n\t\t\t\tconst curr = JSON.stringify({\n\t\t\t\t\tpart: url(route.path),\n\t\t\t\t\tparams: config.params ?? {},\n\t\t\t\t});\n\n\t\t\t\tif (prev === curr) {\n\t\t\t\t\t// part is the same, reuse previous layer\n\t\t\t\t\tit.props = previous[i].props;\n\t\t\t\t\tit.error = previous[i].error;\n\t\t\t\t\tcontext = {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\t...it.props,\n\t\t\t\t\t};\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// part is different, force refresh of next layers\n\t\t\t\tforceRefresh = true;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst props =\n\t\t\t\t\t(await route.resolve?.({\n\t\t\t\t\t\t...request, // request\n\t\t\t\t\t\t...config, // params, query\n\t\t\t\t\t\t...context, // previous props\n\t\t\t\t\t} as any)) ?? {};\n\n\t\t\t\t// save props\n\t\t\t\tit.props = {\n\t\t\t\t\t...props,\n\t\t\t\t};\n\n\t\t\t\t// add props to context\n\t\t\t\tcontext = {\n\t\t\t\t\t...context,\n\t\t\t\t\t...props,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\t// check if we need to redirect\n\t\t\t\tif (e instanceof RedirectionError) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlayers: [],\n\t\t\t\t\t\tredirect: typeof e.page === \"string\" ? e.page : this.href(e.page),\n\t\t\t\t\t\thead: request.head,\n\t\t\t\t\t\tpathname,\n\t\t\t\t\t\tsearch,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tthis.log.error(e);\n\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tlet acc = \"\";\n\t\tfor (let i = 0; i < stack.length; i++) {\n\t\t\tconst it = stack[i];\n\t\t\tconst props = it.props ?? {};\n\n\t\t\tconst params = { ...it.config?.params };\n\t\t\tfor (const key of Object.keys(params)) {\n\t\t\t\tparams[key] = String(params[key]);\n\t\t\t}\n\n\t\t\tif (it.route.head && !it.error) {\n\t\t\t\tthis.fillHead(it.route, request, {\n\t\t\t\t\t...props,\n\t\t\t\t\t...context,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tacc += \"/\";\n\t\t\tacc += it.route.path ? this.compile(it.route.path, params) : \"\";\n\t\t\tconst path = acc.replace(/\\/+/, \"/\");\n\n\t\t\t// handler has thrown an error, render an error view\n\t\t\tif (it.error) {\n\t\t\t\tconst errorHandler = this.getErrorHandler(it.route);\n\t\t\t\tconst element = await (errorHandler\n\t\t\t\t\t? errorHandler({\n\t\t\t\t\t\t\t...it.config,\n\t\t\t\t\t\t\terror: it.error,\n\t\t\t\t\t\t\turl: \"\",\n\t\t\t\t\t\t})\n\t\t\t\t\t: this.renderError(it.error));\n\n\t\t\t\tlayers.push({\n\t\t\t\t\tprops,\n\t\t\t\t\terror: it.error,\n\t\t\t\t\tname: it.route.name,\n\t\t\t\t\tpart: it.route.path,\n\t\t\t\t\tconfig: it.config,\n\t\t\t\t\telement: this.renderView(i + 1, path, element),\n\t\t\t\t\tindex: i + 1,\n\t\t\t\t\tpath,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// normal use case\n\n\t\t\tconst layer = await this.createElement(it.route, {\n\t\t\t\t...props,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tlayers.push({\n\t\t\t\tname: it.route.name,\n\t\t\t\tprops,\n\t\t\t\tpart: it.route.path,\n\t\t\t\tconfig: it.config,\n\t\t\t\telement: this.renderView(i + 1, path, layer),\n\t\t\t\tindex: i + 1,\n\t\t\t\tpath,\n\t\t\t});\n\t\t}\n\n\t\treturn { layers, head: request.head, pathname, search };\n\t}\n\n\tprotected getErrorHandler(route: PageRoute) {\n\t\tif (route.errorHandler) return route.errorHandler;\n\t\tlet parent = route.parent;\n\t\twhile (parent) {\n\t\t\tif (parent.errorHandler) return parent.errorHandler;\n\t\t\tparent = parent.parent;\n\t\t}\n\t}\n\n\tprotected async createElement(\n\t\tpage: PageRoute,\n\t\tprops: Record<string, any>,\n\t): Promise<ReactNode> {\n\t\tif (page.lazy) {\n\t\t\tconst component = await page.lazy(); // load component\n\t\t\treturn createElement(component.default, props);\n\t\t}\n\n\t\tif (page.component) {\n\t\t\treturn createElement(page.component, props);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprotected fillHead(\n\t\tpage: PageRoute,\n\t\tctx: PageRequest,\n\t\tprops: Record<string, any>,\n\t): void {\n\t\tif (!page.head) {\n\t\t\treturn;\n\t\t}\n\n\t\tctx.head ??= {};\n\n\t\tconst head =\n\t\t\ttypeof page.head === \"function\" ? page.head(props, ctx.head) : page.head;\n\n\t\tif (head.title) {\n\t\t\tctx.head ??= {};\n\n\t\t\tif (ctx.head.titleSeparator) {\n\t\t\t\tctx.head.title = `${head.title}${ctx.head.titleSeparator}${ctx.head.title}`;\n\t\t\t} else {\n\t\t\t\tctx.head.title = head.title;\n\t\t\t}\n\n\t\t\tctx.head.titleSeparator = head.titleSeparator;\n\t\t}\n\n\t\tif (head.htmlAttributes) {\n\t\t\tctx.head.htmlAttributes = {\n\t\t\t\t...ctx.head.htmlAttributes,\n\t\t\t\t...head.htmlAttributes,\n\t\t\t};\n\t\t}\n\n\t\tif (head.bodyAttributes) {\n\t\t\tctx.head.bodyAttributes = {\n\t\t\t\t...ctx.head.bodyAttributes,\n\t\t\t\t...head.bodyAttributes,\n\t\t\t};\n\t\t}\n\n\t\tif (head.meta) {\n\t\t\tctx.head.meta = [...(ctx.head.meta ?? []), ...(head.meta ?? [])];\n\t\t}\n\t}\n\n\tpublic renderError(e: Error): ReactNode {\n\t\treturn createElement(\"pre\", { style: { overflow: \"auto\" } }, `${e.stack}`);\n\t}\n\n\tpublic renderEmptyView(): ReactNode {\n\t\treturn createElement(NestedView, {});\n\t}\n\n\tpublic href(\n\t\tpage: { options: { name?: string } },\n\t\tparams: Record<string, any> = {},\n\t): string {\n\t\tconst found = this.pages.find((it) => it.name === page.options.name);\n\t\tif (!found) {\n\t\t\tthrow new Error(`Page ${page.options.name} not found`);\n\t\t}\n\n\t\tlet url = found.path ?? \"\";\n\t\tlet parent = found.parent;\n\t\twhile (parent) {\n\t\t\turl = `${parent.path ?? \"\"}/${url}`;\n\t\t\tparent = parent.parent;\n\t\t}\n\n\t\turl = this.compile(url, params);\n\n\t\treturn url.replace(/\\/\\/+/g, \"/\") || \"/\";\n\t}\n\n\tpublic compile(path: string, params: Record<string, string> = {}) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tpath = path.replace(`:${key}`, value);\n\t\t}\n\t\treturn path;\n\t}\n\n\tprotected renderView(\n\t\tindex: number,\n\t\tpath: string,\n\t\tview: ReactNode = this.renderEmptyView(),\n\t): ReactNode {\n\t\treturn createElement(\n\t\t\tRouterLayerContext.Provider,\n\t\t\t{\n\t\t\t\tvalue: {\n\t\t\t\t\tindex,\n\t\t\t\t\tpath,\n\t\t\t\t},\n\t\t\t},\n\t\t\tview,\n\t\t);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\tname: \"configure\",\n\t\thandler: () => {\n\t\t\tconst pages = this.alepha.getDescriptorValues($page);\n\t\t\tfor (const { value, key } of pages) {\n\t\t\t\tvalue[OPTIONS].name ??= key;\n\n\t\t\t\t// skip children, we only want root pages\n\t\t\t\tif (value[OPTIONS].parent) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.add(this.map(pages, value));\n\t\t\t}\n\t\t},\n\t});\n\n\tprotected map(\n\t\tpages: Array<{ value: { [OPTIONS]: PageDescriptorOptions } }>,\n\t\ttarget: { [OPTIONS]: PageDescriptorOptions },\n\t): PageRouteEntry {\n\t\tconst children = target[OPTIONS].children ?? [];\n\n\t\tfor (const it of pages) {\n\t\t\tif (it.value[OPTIONS].parent === target) {\n\t\t\t\tchildren.push(it.value);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...target[OPTIONS],\n\t\t\tparent: undefined,\n\t\t\tchildren: children.map((it) => this.map(pages, it)),\n\t\t} as PageRoute;\n\t}\n\n\tpublic add(entry: PageRouteEntry) {\n\t\tif (this.alepha.isReady()) {\n\t\t\tthrow new Error(\"Router is already initialized\");\n\t\t}\n\n\t\tentry.name ??= this.nextId();\n\t\tconst page = entry as PageRoute;\n\n\t\tpage.match = this.createMatch(page);\n\t\tthis.pages.push(page);\n\n\t\tif (page.children) {\n\t\t\tfor (const child of page.children) {\n\t\t\t\t(child as PageRoute).parent = page;\n\t\t\t\tthis.add(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected createMatch(page: PageRoute): string {\n\t\tlet url = page.path ?? \"/\";\n\t\tlet target = page.parent;\n\t\twhile (target) {\n\t\t\turl = `${target.path ?? \"\"}/${url}`;\n\t\t\ttarget = target.parent;\n\t\t}\n\n\t\tlet path = url.replace(/\\/\\/+/g, \"/\");\n\n\t\tif (path.endsWith(\"/\") && path !== \"/\") {\n\t\t\t// remove trailing slash\n\t\t\tpath = path.slice(0, -1);\n\t\t}\n\n\t\treturn path;\n\t}\n\n\tprotected _next = 0;\n\n\tprotected nextId(): string {\n\t\tthis._next += 1;\n\t\treturn `P${this._next}`;\n\t}\n}\n\nexport const isPageRoute = (it: any): it is PageRoute => {\n\treturn (\n\t\tit &&\n\t\ttypeof it === \"object\" &&\n\t\ttypeof it.path === \"string\" &&\n\t\ttypeof it.page === \"object\"\n\t);\n};\n\nexport interface PageRouteEntry\n\textends Omit<PageDescriptorOptions, \"children\" | \"parent\"> {\n\tchildren?: PageRouteEntry[];\n}\n\nexport interface PageRoute extends PageRouteEntry {\n\ttype: \"page\";\n\tname: string;\n\tparent?: PageRoute;\n\tmatch: string;\n}\n\nexport interface Layer {\n\tconfig?: {\n\t\tquery?: Record<string, any>;\n\t\tparams?: Record<string, any>;\n\t\t// stack of resolved props\n\t\tcontext?: Record<string, any>;\n\t};\n\n\tname: string;\n\tprops?: Record<string, any>;\n\terror?: Error;\n\tpart?: string;\n\telement: ReactNode;\n\tindex: number;\n\tpath: string;\n}\n\nexport type PreviousLayerData = Omit<Layer, \"element\">;\n\nexport interface AnchorProps {\n\thref?: string;\n\tonClick?: (ev: any) => any;\n}\n\nexport interface RouterState {\n\tpathname: string;\n\tsearch: string;\n\tlayers: Array<Layer>;\n\thead: Head;\n}\n\nexport interface TransitionOptions {\n\tstate?: RouterState;\n\tprevious?: PreviousLayerData[];\n\tcontext?: PageReactContext;\n}\n\nexport interface RouterStackItem {\n\troute: PageRoute;\n\tconfig?: Record<string, any>;\n\tprops?: Record<string, any>;\n\terror?: Error;\n}\n\nexport interface RouterRenderResult {\n\tredirect?: string;\n\tlayers: Layer[];\n\thead: Head;\n\telement: ReactNode;\n}\n\nexport interface PageRequest extends PageReactContext {\n\turl: URL;\n\tparams: Record<string, any>;\n\tquery: Record<string, string>;\n\thead: Head;\n\n\t// previous layers (browser history or browser hydration, always null on server)\n\tprevious?: PreviousLayerData[];\n}\n\nexport interface CreateLayersResult extends RouterState {\n\tredirect?: string;\n}\n\n// will be passed to ReactContext\nexport interface PageReactContext {\n\tlinks?: HttpClientLink[];\n}\n","import type { Head } from \"./ServerHeadProvider.ts\";\n\nexport class BrowserHeadProvider {\n\trenderHead(document: Document, head: Head): void {\n\t\tif (head.title) {\n\t\t\tdocument.title = head.title;\n\t\t}\n\n\t\tif (head.bodyAttributes) {\n\t\t\tfor (const [key, value] of Object.entries(head.bodyAttributes)) {\n\t\t\t\tif (value) {\n\t\t\t\t\tdocument.body.setAttribute(key, value);\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.removeAttribute(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (head.htmlAttributes) {\n\t\t\tfor (const [key, value] of Object.entries(head.htmlAttributes)) {\n\t\t\t\tif (value) {\n\t\t\t\t\tdocument.documentElement.setAttribute(key, value);\n\t\t\t\t} else {\n\t\t\t\t\tdocument.documentElement.removeAttribute(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (head.meta) {\n\t\t\tfor (const [key, value] of Object.entries(head.meta)) {\n\t\t\t\tconst meta = document.querySelector(`meta[name=\"${key}\"]`);\n\t\t\t\tif (meta) {\n\t\t\t\t\tmeta.setAttribute(\"content\", value.content);\n\t\t\t\t} else {\n\t\t\t\t\tconst newMeta = document.createElement(\"meta\");\n\t\t\t\t\tnewMeta.setAttribute(\"name\", key);\n\t\t\t\t\tnewMeta.setAttribute(\"content\", value.content);\n\t\t\t\t\tdocument.head.appendChild(newMeta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { $hook, $inject, $logger, Alepha } from \"@alepha/core\";\nimport { type Route, RouterProvider } from \"@alepha/router\";\nimport type { ReactNode } from \"react\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRoute,\n\ttype PageRouteEntry,\n\ttype RouterRenderResult,\n\ttype RouterState,\n\ttype TransitionOptions,\n\tisPageRoute,\n} from \"./PageDescriptorProvider.ts\";\n\nexport interface BrowserRoute extends Route {\n\tpage: PageRoute;\n}\n\nexport class BrowserRouterProvider extends RouterProvider<BrowserRoute> {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pageDescriptorProvider = $inject(PageDescriptorProvider);\n\n\tpublic add(entry: PageRouteEntry) {\n\t\tthis.pageDescriptorProvider.add(entry);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\tname: \"configure\",\n\t\thandler: async () => {\n\t\t\tfor (const page of this.pageDescriptorProvider.getPages()) {\n\t\t\t\t// mount only if a view is provided\n\t\t\t\tif (page.component || page.lazy) {\n\t\t\t\t\tthis.push({\n\t\t\t\t\t\tpath: page.match,\n\t\t\t\t\t\tpage,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\n\tpublic async transition(\n\t\turl: URL,\n\t\toptions: TransitionOptions = {},\n\t): Promise<RouterRenderResult> {\n\t\tconst { pathname, search } = url;\n\t\tconst state: RouterState = {\n\t\t\tpathname,\n\t\t\tsearch,\n\t\t\tlayers: [],\n\t\t\thead: {},\n\t\t};\n\n\t\tawait this.alepha.emit(\"react:transition:begin\", { state });\n\n\t\ttry {\n\t\t\tconst previous = options.previous;\n\t\t\tconst { route, params } = this.match(pathname);\n\n\t\t\tconst query: Record<string, string> = {};\n\t\t\tif (search) {\n\t\t\t\tfor (const [key, value] of new URLSearchParams(search).entries()) {\n\t\t\t\t\tquery[key] = String(value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isPageRoute(route)) {\n\t\t\t\tconst result = await this.pageDescriptorProvider.createLayers(\n\t\t\t\t\troute.page,\n\t\t\t\t\t{\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tparams: params ?? {},\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tprevious,\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\thead: state.head,\n\t\t\t\t\t\t...(options.context ?? {}),\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (result.redirect) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\telement: null,\n\t\t\t\t\t\tlayers: [],\n\t\t\t\t\t\tredirect: result.redirect,\n\t\t\t\t\t\thead: state.head,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstate.layers = result.layers;\n\t\t\t\tstate.head = result.head;\n\t\t\t}\n\n\t\t\tif (state.layers.length === 0) {\n\t\t\t\tstate.layers.push({\n\t\t\t\t\tname: \"not-found\",\n\t\t\t\t\telement: \"Not Found\",\n\t\t\t\t\tindex: 0,\n\t\t\t\t\tpath: \"/\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait this.alepha.emit(\"react:transition:success\", { state });\n\t\t} catch (e) {\n\t\t\tthis.log.error(e);\n\t\t\tstate.layers = [\n\t\t\t\t{\n\t\t\t\t\tname: \"error\",\n\t\t\t\t\telement: this.pageDescriptorProvider.renderError(e as Error),\n\t\t\t\t\tindex: 0,\n\t\t\t\t\tpath: \"/\",\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tawait this.alepha.emit(\"react:transition:error\", {\n\t\t\t\terror: e as Error,\n\t\t\t\tstate,\n\t\t\t});\n\t\t}\n\n\t\tif (!options.state) {\n\t\t\tawait this.alepha.emit(\"react:transition:end\", {\n\t\t\t\tstate,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\telement: this.root(state, options.context),\n\t\t\t\tlayers: state.layers,\n\t\t\t\thead: state.head,\n\t\t\t};\n\t\t}\n\n\t\toptions.state.layers = state.layers;\n\t\toptions.state.pathname = state.pathname;\n\t\toptions.state.search = state.search;\n\t\toptions.state.head = state.head;\n\n\t\tawait this.alepha.emit(\"react:transition:end\", {\n\t\t\tstate: options.state,\n\t\t});\n\n\t\treturn {\n\t\t\telement: this.root(state, options.context),\n\t\t\tlayers: options.state.layers,\n\t\t\thead: state.head,\n\t\t};\n\t}\n\n\tpublic root(state: RouterState, context: PageReactContext = {}): ReactNode {\n\t\treturn this.pageDescriptorProvider.root(state, context);\n\t}\n}\n","import { $hook, $inject, $logger, Alepha, type Static, t } from \"@alepha/core\";\nimport { HttpClient, type HttpClientLink } from \"@alepha/server\";\nimport type { Root } from \"react-dom/client\";\nimport { createRoot, hydrateRoot } from \"react-dom/client\";\nimport type { Head } from \"../descriptors/$page.ts\";\nimport { BrowserHeadProvider } from \"./BrowserHeadProvider.ts\";\nimport { BrowserRouterProvider } from \"./BrowserRouterProvider.ts\";\nimport type {\n\tPreviousLayerData,\n\tRouterState,\n\tTransitionOptions,\n} from \"./PageDescriptorProvider.ts\";\n\nconst envSchema = t.object({\n\tREACT_ROOT_ID: t.string({ default: \"root\" }),\n});\n\ndeclare module \"@alepha/core\" {\n\tinterface Env extends Partial<Static<typeof envSchema>> {}\n}\n\nexport class ReactBrowserProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly client = $inject(HttpClient);\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly router = $inject(BrowserRouterProvider);\n\tprotected readonly headProvider = $inject(BrowserHeadProvider);\n\tprotected readonly env = $inject(envSchema);\n\tprotected root!: Root;\n\n\tpublic transitioning?: {\n\t\tto: string;\n\t};\n\n\tpublic state: RouterState = {\n\t\tlayers: [],\n\t\tpathname: \"\",\n\t\tsearch: \"\",\n\t\thead: {},\n\t};\n\n\tpublic get document() {\n\t\treturn window.document;\n\t}\n\n\tpublic get history() {\n\t\treturn window.history;\n\t}\n\n\tpublic get url(): string {\n\t\treturn window.location.pathname + window.location.search;\n\t}\n\n\tpublic async invalidate(props?: Record<string, any>) {\n\t\tconst previous: PreviousLayerData[] = [];\n\n\t\tif (props) {\n\t\t\tconst [key] = Object.keys(props);\n\t\t\tconst value = props[key];\n\n\t\t\tfor (const layer of this.state.layers) {\n\t\t\t\tif (layer.props?.[key]) {\n\t\t\t\t\tprevious.push({\n\t\t\t\t\t\t...layer,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t...layer.props,\n\t\t\t\t\t\t\t[key]: value,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tprevious.push(layer);\n\t\t\t}\n\t\t}\n\n\t\tawait this.render({ previous });\n\t}\n\n\t/**\n\t *\n\t * @param url\n\t * @param options\n\t */\n\tpublic async go(url: string, options: RouterGoOptions = {}): Promise<void> {\n\t\tconst result = await this.render({\n\t\t\turl,\n\t\t});\n\n\t\tif (result.url !== url) {\n\t\t\tthis.history.replaceState({}, \"\", result.url);\n\t\t\treturn;\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tthis.history.replaceState({}, \"\", url);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.history.pushState({}, \"\", url);\n\t}\n\n\tprotected async render(\n\t\toptions: {\n\t\t\turl?: string;\n\t\t\tprevious?: PreviousLayerData[];\n\t\t} = {},\n\t): Promise<{ url: string; head: Head }> {\n\t\tconst previous = options.previous ?? this.state.layers;\n\t\tconst url = options.url ?? this.url;\n\n\t\tthis.transitioning = { to: url };\n\n\t\tconst result = await this.router.transition(\n\t\t\tnew URL(`http://localhost${url}`),\n\t\t\t{\n\t\t\t\tprevious,\n\t\t\t\tstate: this.state,\n\t\t\t},\n\t\t);\n\n\t\tif (result.redirect) {\n\t\t\treturn await this.render({ url: result.redirect });\n\t\t}\n\n\t\tthis.transitioning = undefined;\n\n\t\treturn { url, head: result.head };\n\t}\n\n\t/**\n\t * Get embedded layers from the server.\n\t *\n\t * @protected\n\t */\n\tprotected getHydrationState(): ReactHydrationState | undefined {\n\t\ttry {\n\t\t\tif (\"__ssr\" in window && typeof window.__ssr === \"object\") {\n\t\t\t\treturn window.__ssr as ReactHydrationState;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @protected\n\t */\n\tprotected getRootElement() {\n\t\tconst root = this.document.getElementById(this.env.REACT_ROOT_ID);\n\t\tif (root) {\n\t\t\treturn root;\n\t\t}\n\n\t\tconst div = this.document.createElement(\"div\");\n\t\tdiv.id = this.env.REACT_ROOT_ID;\n\n\t\tthis.document.body.prepend(div);\n\n\t\treturn div;\n\t}\n\n\t// -------------------------------------------------------------------------------------------------------------------\n\n\t/**\n\t *\n\t * @protected\n\t */\n\tpublic readonly ready = $hook({\n\t\tname: \"ready\",\n\t\thandler: async () => {\n\t\t\tconst hydration = this.getHydrationState();\n\t\t\tconst previous = hydration?.layers ?? [];\n\n\t\t\tif (hydration?.links) {\n\t\t\t\tthis.client.links = hydration.links as HttpClientLink[];\n\t\t\t}\n\n\t\t\tconst { head } = await this.render({ previous });\n\t\t\tif (head) {\n\t\t\t\tthis.headProvider.renderHead(this.document, head);\n\t\t\t}\n\n\t\t\tconst context = {};\n\n\t\t\tawait this.alepha.emit(\"react:browser:render\", {\n\t\t\t\tcontext,\n\t\t\t\thydration,\n\t\t\t});\n\n\t\t\tconst element = this.router.root(this.state, context);\n\n\t\t\tif (previous.length > 0) {\n\t\t\t\tthis.root = hydrateRoot(this.getRootElement(), element);\n\t\t\t\tthis.log.info(\"Hydrated root element\");\n\t\t\t} else {\n\t\t\t\tthis.root ??= createRoot(this.getRootElement());\n\t\t\t\tthis.root.render(element);\n\t\t\t\tthis.log.info(\"Created root element\");\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\t\tthis.render();\n\t\t\t});\n\n\t\t\tthis.alepha.on(\"react:transition:end\", {\n\t\t\t\tcallback: ({ state }) => {\n\t\t\t\t\tthis.headProvider.renderHead(this.document, state.head);\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tpublic readonly onTransitionEnd = $hook({\n\t\tname: \"react:transition:end\",\n\t\thandler: async ({ state }) => {\n\t\t\tthis.headProvider.renderHead(this.document, state.head);\n\t\t},\n\t});\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface RouterGoOptions {\n\treplace?: boolean;\n\tmatch?: TransitionOptions;\n}\n\nexport interface ReactHydrationState {\n\tlayers?: PreviousLayerData[];\n\tlinks?: HttpClientLink[];\n}\n","import type {\n\tAnchorProps,\n\tRouterState,\n} from \"../providers/PageDescriptorProvider.ts\";\nimport type {\n\tReactBrowserProvider,\n\tRouterGoOptions,\n} from \"../providers/ReactBrowserProvider.ts\";\n\nexport class RouterHookApi {\n\tconstructor(\n\t\tprivate readonly state: RouterState,\n\t\tprivate readonly layer: {\n\t\t\tpath: string;\n\t\t},\n\t\tprivate readonly browser?: ReactBrowserProvider,\n\t) {}\n\n\t/**\n\t *\n\t */\n\tpublic get current(): RouterState {\n\t\treturn this.state;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic get pathname(): string {\n\t\treturn this.state.pathname;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic get query(): Record<string, string> {\n\t\tconst query: Record<string, string> = {};\n\n\t\tfor (const [key, value] of new URLSearchParams(\n\t\t\tthis.state.search,\n\t\t).entries()) {\n\t\t\tquery[key] = String(value);\n\t\t}\n\n\t\treturn query;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic async back() {\n\t\tthis.browser?.history.back();\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic async forward() {\n\t\tthis.browser?.history.forward();\n\t}\n\n\t/**\n\t *\n\t * @param props\n\t */\n\tpublic async invalidate(props?: Record<string, any>) {\n\t\tawait this.browser?.invalidate(props);\n\t}\n\n\t/**\n\t * Create a valid href for the given pathname.\n\t *\n\t * @param pathname\n\t * @param layer\n\t */\n\tpublic createHref(pathname: HrefLike, layer: { path: string } = this.layer) {\n\t\tif (typeof pathname === \"object\") {\n\t\t\tpathname = pathname.options.path ?? \"\";\n\t\t}\n\n\t\treturn pathname.startsWith(\"/\")\n\t\t\t? pathname\n\t\t\t: `${layer.path}/${pathname}`.replace(/\\/\\/+/g, \"/\");\n\t}\n\n\t/**\n\t *\n\t * @param path\n\t * @param options\n\t */\n\tpublic async go(\n\t\tpath: HrefLike,\n\t\toptions: RouterGoOptions = {},\n\t): Promise<void> {\n\t\treturn await this.browser?.go(this.createHref(path, this.layer), options);\n\t}\n\n\t/**\n\t *\n\t * @param path\n\t */\n\tpublic createAnchorProps(path: string): AnchorProps {\n\t\tconst href = this.createHref(path, this.layer);\n\t\treturn {\n\t\t\thref,\n\t\t\tonClick: (ev: any) => {\n\t\t\t\tev.stopPropagation();\n\t\t\t\tev.preventDefault();\n\n\t\t\t\tthis.go(path).catch(console.error);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Set query params.\n\t *\n\t * @param record\n\t * @param options\n\t */\n\tpublic setQueryParams(\n\t\trecord: Record<string, any>,\n\t\toptions: {\n\t\t\t/**\n\t\t\t * If true, this will merge current query params with the new ones.\n\t\t\t */\n\t\t\tmerge?: boolean;\n\n\t\t\t/**\n\t\t\t * If true, this will add a new entry to the history stack.\n\t\t\t */\n\t\t\tpush?: boolean;\n\t\t} = {},\n\t) {\n\t\tconst search = new URLSearchParams(\n\t\t\toptions.merge\n\t\t\t\t? {\n\t\t\t\t\t\t...this.query,\n\t\t\t\t\t\t...record,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t...record,\n\t\t\t\t\t},\n\t\t).toString();\n\n\t\tconst state = search ? `${this.pathname}?${search}` : this.pathname;\n\n\t\tif (options.push) {\n\t\t\twindow.history.pushState({}, \"\", state);\n\t\t} else {\n\t\t\twindow.history.replaceState({}, \"\", state);\n\t\t}\n\t}\n}\n\nexport type HrefLike = string | { options: { path?: string; name?: string } };\n","import { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport { ReactBrowserProvider } from \"../providers/ReactBrowserProvider.ts\";\nimport { RouterHookApi } from \"./RouterHookApi.ts\";\n\nexport const useRouter = (): RouterHookApi => {\n\tconst ctx = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tif (!ctx || !layer) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tnew RouterHookApi(\n\t\t\t\tctx.state,\n\t\t\t\tlayer,\n\t\t\t\tctx.alepha.isBrowser()\n\t\t\t\t\t? ctx.alepha.get(ReactBrowserProvider)\n\t\t\t\t\t: undefined,\n\t\t\t),\n\t\t[layer],\n\t);\n};\n","import React from \"react\";\nimport type { AnchorHTMLAttributes } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport { useRouter } from \"../hooks/useRouter.ts\";\nimport { OPTIONS } from \"@alepha/core\";\n\nexport interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {\n\tto: string | PageDescriptor;\n\tchildren?: React.ReactNode;\n}\n\nconst Link = (props: LinkProps) => {\n\tReact.useContext(RouterContext);\n\n\tconst to = typeof props.to === \"string\" ? props.to : props.to[OPTIONS].path;\n\tif (!to) {\n\t\treturn null;\n\t}\n\n\tconst can = typeof props.to === \"string\" ? undefined : props.to[OPTIONS].can;\n\tif (can && !can()) {\n\t\treturn null;\n\t}\n\n\tconst name =\n\t\ttypeof props.to === \"string\" ? undefined : props.to[OPTIONS].name;\n\n\tconst router = useRouter();\n\treturn (\n\t\t<a {...router.createAnchorProps(to)} {...props}>\n\t\t\t{props.children ?? name}\n\t\t</a>\n\t);\n};\n\nexport default Link;\n","import type { Class } from \"@alepha/core\";\nimport { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useInject = <T extends object>(clazz: Class<T>): T => {\n\tconst ctx = useContext(RouterContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useRouter must be used within a <RouterProvider>\");\n\t}\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tctx.alepha.get(clazz, {\n\t\t\t\tskipRegistration: true,\n\t\t\t}),\n\t\t[],\n\t);\n};\n","import { HttpClient } from \"@alepha/server\";\nimport { useInject } from \"./useInject.ts\";\n\nexport const useClient = (): HttpClient => {\n\treturn useInject(HttpClient);\n};\n\nexport const useApi = <T extends object>() => {\n\treturn useInject(HttpClient).of<T>();\n};\n","import type { Alepha, Static, TObject } from \"@alepha/core\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { useRouter } from \"./useRouter.ts\";\n\nexport interface UseQueryParamsHookOptions {\n\tformat?: \"base64\" | \"querystring\";\n\tkey?: string;\n\tpush?: boolean;\n}\n\nexport const useQueryParams = <T extends TObject>(\n\tschema: T,\n\toptions: UseQueryParamsHookOptions = {},\n): [Static<T>, (data: Static<T>) => void] => {\n\tconst ctx = useContext(RouterContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useQueryParams must be used within a RouterProvider\");\n\t}\n\n\tconst key = options.key ?? \"q\";\n\tconst router = useRouter();\n\tconst querystring = router.query[key];\n\n\tconst [queryParams, setQueryParams] = useState(\n\t\tdecode(ctx.alepha, schema, router.query[key]),\n\t);\n\n\tuseEffect(() => {\n\t\tsetQueryParams(decode(ctx.alepha, schema, querystring));\n\t}, [querystring]);\n\n\treturn [\n\t\tqueryParams,\n\t\t(queryParams: Static<T>) => {\n\t\t\tsetQueryParams(queryParams);\n\t\t\trouter.setQueryParams(\n\t\t\t\t{ [key]: encode(ctx.alepha, schema, queryParams) },\n\t\t\t\t{\n\t\t\t\t\tmerge: true,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t];\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nconst encode = (alepha: Alepha, schema: TObject, data: any) => {\n\treturn btoa(JSON.stringify(alepha.parse(schema, data)));\n};\n\nconst decode = (alepha: Alepha, schema: TObject, data: any) => {\n\ttry {\n\t\treturn alepha.parse(schema, JSON.parse(atob(decodeURIComponent(data))));\n\t} catch (error) {\n\t\treturn {};\n\t}\n};\n","import { useContext, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport type { RouterState } from \"../providers/PageDescriptorProvider.ts\";\nimport { useRouterEvents } from \"./useRouterEvents.ts\";\n\nexport const useRouterState = (): RouterState => {\n\tconst ctx = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tif (!ctx || !layer) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\tconst [state, setState] = useState(ctx.state);\n\n\tuseRouterEvents({\n\t\tonEnd: ({ state }) => setState({ ...state }),\n\t});\n\n\treturn state;\n};\n","import { useContext, useMemo, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport type { AnchorProps } from \"../providers/PageDescriptorProvider.ts\";\nimport type { HrefLike } from \"./RouterHookApi.ts\";\nimport { useRouter } from \"./useRouter.ts\";\nimport { useRouterEvents } from \"./useRouterEvents.ts\";\n\nexport const useActive = (path: HrefLike): UseActiveHook => {\n\tconst router = useRouter();\n\tconst ctx = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tif (!ctx || !layer) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\tlet name: string | undefined;\n\tif (typeof path === \"object\" && path.options.name) {\n\t\tname = path.options.name;\n\t}\n\n\tconst [current, setCurrent] = useState(ctx.state.pathname);\n\tconst href = useMemo(() => router.createHref(path, layer), [path, layer]);\n\tconst [isPending, setPending] = useState(false);\n\tconst isActive = current === href;\n\n\tuseRouterEvents({\n\t\tonEnd: ({ state }) => setCurrent(state.pathname),\n\t});\n\n\treturn {\n\t\tname,\n\t\tisPending,\n\t\tisActive,\n\t\tanchorProps: {\n\t\t\thref,\n\t\t\tonClick: (ev: any) => {\n\t\t\t\tev.stopPropagation();\n\t\t\t\tev.preventDefault();\n\t\t\t\tif (isActive) return;\n\t\t\t\tif (isPending) return;\n\n\t\t\t\tsetPending(true);\n\t\t\t\trouter.go(href).then(() => {\n\t\t\t\t\tsetPending(false);\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n};\n\nexport interface UseActiveHook {\n\tisActive: boolean;\n\tanchorProps: AnchorProps;\n\tisPending: boolean;\n\tname?: string;\n}\n"],"names":["__descriptor","OPTIONS","KIND","NotImplementedError","createContext","useContext","useEffect","useState","$logger","$inject","Alepha","createElement","$hook","RouterProvider","t","HttpClient","hydrateRoot","createRoot","useMemo","jsx"],"mappings":";;;;;;;;;AAGA,MAAM,GAAG,GAAG,MAAM;AACN,MAAC,KAAK,GAAG,CAAC,OAAO,KAAK;AAClC,EAAEA,iBAAY,CAAC,GAAG,CAAC;AACnB,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE;AACxB,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE;AAC1C,MAAM,KAAK,CAACC,YAAO,CAAC,CAAC,MAAM,GAAG;AAC9B,QAAQ,CAACA,YAAO,GAAG;AACnB,OAAO;AACP;AACA;AACA,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE;AACtB,IAAI,OAAO,CAAC,MAAM,CAACA,YAAO,CAAC,CAAC,QAAQ,KAAK,EAAE;AAC3C,IAAI,OAAO,CAAC,MAAM,CAACA,YAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1C,MAAM,CAACA,YAAO,GAAG;A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