@alepha/react 0.6.4 → 0.6.6

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import React, { createContext, useContext, useState, useEffect, createElement, useMemo } from 'react';
2
+ import React, { createContext, useContext, useEffect, useState, createElement, useMemo } from 'react';
3
+ import { __descriptor, OPTIONS, NotImplementedError, KIND, $logger, $inject, Alepha, $hook, t } from '@alepha/core';
3
4
  import { HttpClient } from '@alepha/server';
4
- import { __descriptor, NotImplementedError, KIND, $logger, $inject, Alepha, EventEmitter, $hook, t } from '@alepha/core';
5
5
  import { hydrateRoot, createRoot } from 'react-dom/client';
6
6
  import { RouterProvider } from '@alepha/router';
7
7
 
@@ -10,20 +10,20 @@ const $page = (options) => {
10
10
  __descriptor(KEY);
11
11
  if (options.children) {
12
12
  for (const child of options.children) {
13
- child.options.parent = {
14
- options
13
+ child[OPTIONS].parent = {
14
+ [OPTIONS]: options
15
15
  };
16
16
  }
17
17
  }
18
18
  if (options.parent) {
19
- options.parent.options.children ??= [];
20
- options.parent.options.children.push({
21
- options
19
+ options.parent[OPTIONS].children ??= [];
20
+ options.parent[OPTIONS].children.push({
21
+ [OPTIONS]: options
22
22
  });
23
23
  }
24
24
  return {
25
25
  [KIND]: KEY,
26
- options,
26
+ [OPTIONS]: options,
27
27
  render: () => {
28
28
  throw new NotImplementedError(KEY);
29
29
  },
@@ -49,6 +49,48 @@ const RouterContext = createContext(
49
49
 
50
50
  const RouterLayerContext = createContext(void 0);
51
51
 
52
+ const useRouterEvents = (opts = {}, deps = []) => {
53
+ const ctx = useContext(RouterContext);
54
+ if (!ctx) {
55
+ throw new Error("useRouter must be used within a RouterProvider");
56
+ }
57
+ useEffect(() => {
58
+ if (!ctx.alepha.isBrowser()) {
59
+ return;
60
+ }
61
+ const subs = [];
62
+ const onBegin = opts.onBegin;
63
+ const onEnd = opts.onEnd;
64
+ const onError = opts.onError;
65
+ if (onBegin) {
66
+ subs.push(
67
+ ctx.alepha.on("react:transition:begin", {
68
+ callback: onBegin
69
+ })
70
+ );
71
+ }
72
+ if (onEnd) {
73
+ subs.push(
74
+ ctx.alepha.on("react:transition:end", {
75
+ callback: onEnd
76
+ })
77
+ );
78
+ }
79
+ if (onError) {
80
+ subs.push(
81
+ ctx.alepha.on("react:transition:error", {
82
+ callback: onError
83
+ })
84
+ );
85
+ }
86
+ return () => {
87
+ for (const sub of subs) {
88
+ sub();
89
+ }
90
+ };
91
+ }, deps);
92
+ };
93
+
52
94
  const NestedView = (props) => {
53
95
  const app = useContext(RouterContext);
54
96
  const layer = useContext(RouterLayerContext);
@@ -56,13 +98,14 @@ const NestedView = (props) => {
56
98
  const [view, setView] = useState(
57
99
  app?.state.layers[index]?.element
58
100
  );
59
- useEffect(() => {
60
- if (app?.alepha.isBrowser()) {
61
- return app?.events.on("end", (state) => {
101
+ useRouterEvents(
102
+ {
103
+ onEnd: ({ state }) => {
62
104
  setView(state.layers[index]?.element);
63
- });
64
- }
65
- }, [app]);
105
+ }
106
+ },
107
+ [app]
108
+ );
66
109
  return view ?? props.children ?? null;
67
110
  };
68
111
 
@@ -88,15 +131,14 @@ class PageDescriptorProvider {
88
131
  }
89
132
  throw new Error(`Page ${name} not found`);
90
133
  }
91
- root(state, context = {}, events) {
134
+ root(state, context = {}) {
92
135
  return createElement(
93
136
  RouterContext.Provider,
94
137
  {
95
138
  value: {
96
139
  alepha: this.alepha,
97
140
  state,
98
- context,
99
- events: events ?? new EventEmitter()
141
+ context
100
142
  }
101
143
  },
102
144
  createElement(NestedView, {}, state.layers[0]?.element)
@@ -332,8 +374,8 @@ class PageDescriptorProvider {
332
374
  handler: () => {
333
375
  const pages = this.alepha.getDescriptorValues($page);
334
376
  for (const { value, key } of pages) {
335
- value.options.name ??= key;
336
- if (value.options.parent) {
377
+ value[OPTIONS].name ??= key;
378
+ if (value[OPTIONS].parent) {
337
379
  continue;
338
380
  }
339
381
  this.add(this.map(pages, value));
@@ -341,14 +383,14 @@ class PageDescriptorProvider {
341
383
  }
342
384
  });
343
385
  map(pages, target) {
344
- const children = target.options.children ?? [];
386
+ const children = target[OPTIONS].children ?? [];
345
387
  for (const it of pages) {
346
- if (it.value.options.parent === target) {
388
+ if (it.value[OPTIONS].parent === target) {
347
389
  children.push(it.value);
348
390
  }
349
391
  }
350
392
  return {
351
- ...target.options,
393
+ ...target[OPTIONS],
352
394
  parent: void 0,
353
395
  children: children.map((it) => this.map(pages, it))
354
396
  };
@@ -434,7 +476,6 @@ class BrowserRouterProvider extends RouterProvider {
434
476
  log = $logger();
435
477
  alepha = $inject(Alepha);
436
478
  pageDescriptorProvider = $inject(PageDescriptorProvider);
437
- events = new EventEmitter();
438
479
  add(entry) {
439
480
  this.pageDescriptorProvider.add(entry);
440
481
  }
@@ -459,7 +500,7 @@ class BrowserRouterProvider extends RouterProvider {
459
500
  layers: [],
460
501
  head: {}
461
502
  };
462
- await this.events.emit("begin", void 0);
503
+ await this.alepha.emit("react:transition:begin", { state });
463
504
  try {
464
505
  const previous = options.previous;
465
506
  const { route, params } = this.match(pathname);
@@ -501,7 +542,7 @@ class BrowserRouterProvider extends RouterProvider {
501
542
  path: "/"
502
543
  });
503
544
  }
504
- await this.events.emit("success", void 0);
545
+ await this.alepha.emit("react:transition:success", { state });
505
546
  } catch (e) {
506
547
  this.log.error(e);
507
548
  state.layers = [
@@ -512,10 +553,15 @@ class BrowserRouterProvider extends RouterProvider {
512
553
  path: "/"
513
554
  }
514
555
  ];
515
- await this.events.emit("error", e);
556
+ await this.alepha.emit("react:transition:error", {
557
+ error: e,
558
+ state
559
+ });
516
560
  }
517
561
  if (!options.state) {
518
- await this.events.emit("end", state);
562
+ await this.alepha.emit("react:transition:end", {
563
+ state
564
+ });
519
565
  return {
520
566
  element: this.root(state, options.context),
521
567
  layers: state.layers,
@@ -526,7 +572,9 @@ class BrowserRouterProvider extends RouterProvider {
526
572
  options.state.pathname = state.pathname;
527
573
  options.state.search = state.search;
528
574
  options.state.head = state.head;
529
- await this.events.emit("end", options.state);
575
+ await this.alepha.emit("react:transition:end", {
576
+ state: options.state
577
+ });
530
578
  return {
531
579
  element: this.root(state, options.context),
532
580
  layers: options.state.layers,
@@ -534,7 +582,7 @@ class BrowserRouterProvider extends RouterProvider {
534
582
  };
535
583
  }
536
584
  root(state, context = {}) {
537
- return this.pageDescriptorProvider.root(state, context, this.events);
585
+ return this.pageDescriptorProvider.root(state, context);
538
586
  }
539
587
  }
540
588
 
@@ -684,11 +732,19 @@ class ReactBrowserProvider {
684
732
  window.addEventListener("popstate", () => {
685
733
  this.render();
686
734
  });
687
- this.router.events.on("end", ({ head: head2 }) => {
688
- this.headProvider.renderHead(this.document, head2);
735
+ this.alepha.on("react:transition:end", {
736
+ callback: ({ state }) => {
737
+ this.headProvider.renderHead(this.document, state.head);
738
+ }
689
739
  });
690
740
  }
691
741
  });
742
+ onTransitionEnd = $hook({
743
+ name: "react:transition:end",
744
+ handler: async ({ state }) => {
745
+ this.headProvider.renderHead(this.document, state.head);
746
+ }
747
+ });
692
748
  }
693
749
 
694
750
  class RouterHookApi {
@@ -817,15 +873,15 @@ const useRouter = () => {
817
873
 
818
874
  const Link = (props) => {
819
875
  React.useContext(RouterContext);
820
- const to = typeof props.to === "string" ? props.to : props.to.options.path;
876
+ const to = typeof props.to === "string" ? props.to : props.to[OPTIONS].path;
821
877
  if (!to) {
822
878
  return null;
823
879
  }
824
- const can = typeof props.to === "string" ? void 0 : props.to.options.can;
880
+ const can = typeof props.to === "string" ? void 0 : props.to[OPTIONS].can;
825
881
  if (can && !can()) {
826
882
  return null;
827
883
  }
828
- const name = typeof props.to === "string" ? void 0 : props.to.options.name;
884
+ const name = typeof props.to === "string" ? void 0 : props.to[OPTIONS].name;
829
885
  const router = useRouter();
830
886
  return /* @__PURE__ */ jsx("a", { ...router.createAnchorProps(to), ...props, children: props.children ?? name });
831
887
  };
@@ -882,34 +938,6 @@ const decode = (alepha, schema, data) => {
882
938
  }
883
939
  };
884
940
 
885
- const useRouterEvents = (opts = {}) => {
886
- const ctx = useContext(RouterContext);
887
- const layer = useContext(RouterLayerContext);
888
- if (!ctx || !layer) {
889
- throw new Error("useRouter must be used within a RouterProvider");
890
- }
891
- useEffect(() => {
892
- const subs = [];
893
- const onBegin = opts.onBegin;
894
- const onEnd = opts.onEnd;
895
- const onError = opts.onError;
896
- if (onBegin) {
897
- subs.push(ctx.events.on("begin", onBegin));
898
- }
899
- if (onEnd) {
900
- subs.push(ctx.events.on("end", onEnd));
901
- }
902
- if (onError) {
903
- subs.push(ctx.events.on("error", onError));
904
- }
905
- return () => {
906
- for (const sub of subs) {
907
- sub();
908
- }
909
- };
910
- }, []);
911
- };
912
-
913
941
  const useRouterState = () => {
914
942
  const ctx = useContext(RouterContext);
915
943
  const layer = useContext(RouterLayerContext);
@@ -917,12 +945,9 @@ const useRouterState = () => {
917
945
  throw new Error("useRouter must be used within a RouterProvider");
918
946
  }
919
947
  const [state, setState] = useState(ctx.state);
920
- useEffect(
921
- () => ctx.events.on("end", (it) => {
922
- setState({ ...it });
923
- }),
924
- []
925
- );
948
+ useRouterEvents({
949
+ onEnd: ({ state: state2 }) => setState({ ...state2 })
950
+ });
926
951
  return state;
927
952
  };
928
953
 
@@ -941,10 +966,9 @@ const useActive = (path) => {
941
966
  const href = useMemo(() => router.createHref(path, layer), [path, layer]);
942
967
  const [isPending, setPending] = useState(false);
943
968
  const isActive = current === href;
944
- useEffect(
945
- () => ctx.events.on("end", ({ pathname }) => setCurrent(pathname)),
946
- []
947
- );
969
+ useRouterEvents({
970
+ onEnd: ({ state }) => setCurrent(state.pathname)
971
+ });
948
972
  return {
949
973
  name,
950
974
  isPending,
@@ -966,4 +990,4 @@ const useActive = (path) => {
966
990
  };
967
991
 
968
992
  export { $page as $, BrowserRouterProvider as B, Link as L, NestedView as N, PageDescriptorProvider as P, RouterContext as R, RouterLayerContext as a, RouterHookApi as b, useClient as c, useQueryParams as d, useRouter as e, useRouterEvents as f, useRouterState as g, useActive as h, RedirectionError as i, isPageRoute as j, ReactBrowserProvider as k, useInject as u };
969
- //# sourceMappingURL=useActive-QkvcaSmu.js.map
993
+ //# sourceMappingURL=useActive-BzjLwZjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActive-BzjLwZjs.js","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 } 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 ctx.alepha.get(clazz, {\n\t\tskipRegistration: true,\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","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":[],"mappings":";;;;;;;AAGA,MAAM,GAAG,GAAG,MAAM;AACN,MAAC,KAAK,GAAG,CAAC,OAAO,KAAK;AAClC,EAAE,YAAY,CAAC,GAAG,CAAC;AACnB,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE;AACxB,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE;AAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG;AAC9B,QAAQ,CAAC,OAAO,GAAG;AACnB,OAAO;AACP;AACA;AACA,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE;AACtB,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,EAAE;AAC3C,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1C,MAAM,CAAC,OAAO,GAAG;AACjB,KAAK,CAAC;AACN;AACA,EAAE,OAAO;AACT,IAAI,CAAC,IAAI,GAAG,GAAG;AACf,IAAI,CAAC,OAAO,GAAG,OAAO;AACtB,IAAI,MAAM,EAAE,MAAM;AAClB,MAAM,MAAM,IAAI,mBAAmB,CAAC,GAAG,CAAC;AACxC,KAAK;AACL,IAAI,EAAE,EAAE,MAAM;AACd,MAAM,MAAM,IAAI,mBAAmB,CAAC,GAAG,CAAC;AACxC,KAAK;AACL,IAAI,iBAAiB,EAAE,MAAM;AAC7B,MAAM,MAAM,IAAI,mBAAmB,CAAC,GAAG,CAAC;AACxC,KAAK;AACL,IAAI,GAAG,EAAE,MAAM;AACf,MAAM,IAAI,OA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