@alepha/react 0.9.0 → 0.9.1
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.js +19 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +22 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -14
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +16 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -18
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/ErrorViewer.tsx +4 -3
- package/src/providers/PageDescriptorProvider.ts +1 -1
- package/src/providers/ReactBrowserProvider.ts +1 -1
- package/src/providers/ReactServerProvider.ts +6 -2
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["options: PageDescriptorOptions<TConfig, TProps, TPropsParent>","Descriptor","options?: PageDescriptorRenderOptions","NotImplementedError","KIND","props: PropsWithChildren<ClientOnlyProps>","text: string","opts: {\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}","deps: any[]","subs: Function[]","React","props: ErrorBoundaryProps","error: Error","info: ErrorInfo","props: NestedViewProps","ErrorBoundary","page: HrefLike","envSchema","Alepha","name: string","options: { params?: Record<string, string>; base?: string }","state: RouterState","context: PageReactContext","NestedView","StrictMode","route: PageRoute","request: PageRequest","layers: Layer[]","context: Record<string, any>","stack: Array<RouterStackItem>","route","config: Record<string, any>","str?: string","element: ReactNode","element","page: PageRoute","props: Record<string, any>","error: Error","ErrorViewer","page: { options: { name?: string } }","params: Record<string, any>","path: string","params: Record<string, string>","index: number","view: ReactNode | undefined","ClientOnly","it: PageDescriptor","pages: Array<PageDescriptor>","target: PageDescriptor","entry: PageRouteEntry","it: any","RouterProvider","Alepha","entry: PageRouteEntry","url: URL","options: TransitionOptions","state: RouterState","query: Record<string, string>","context: PageReactContext","LinkProvider","Alepha","url: string","replace?: boolean","props?: Record<string, any>","previous: PreviousLayerData[]","options: RouterGoOptions","options: { url?: string; previous?: PreviousLayerData[] }","Alepha","ServerStaticProvider","ServerRouterProvider","ServerTimingProvider","templateLoader: TemplateLoader","root: string","ssrEnabled: boolean","name: string","options: PageDescriptorRenderOptions","context: PageRequest","page: PageRoute","ServerLinksProvider","apiLinksResponseSchema","target: PageRoute | undefined","template: string","state: RouterState","context: PageReactContext","hydrationData: ReactHydrationState","response: { html: string }","app: string","script: string","pages: PageRoute[]","context: PageReactContext","state: RouterState","layer: {\n\t\t\tpath: string;\n\t\t}","browser?: ReactBrowserProvider","query: Record<string, string>","props?: Record<string, any>","pathname: HrefLike","layer: { path: string }","options: { params?: Record<string, any> }","path: string","options?: RouterGoOptions","ev: any","record:\n\t\t\t| Record<string, any>\n\t\t\t| ((queryParams: Record<string, any>) => Record<string, any>)","options: {\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}","props: LinkProps","path: HrefLike","name: string | undefined","ev: any","clazz: Service<T>","_scope?: ClientScope","LinkProvider","schema: T","options: UseQueryParamsHookOptions","queryParams: Static<T>","queryParams","alepha: Alepha","schema: TObject","data: any","state","AlephaServer","AlephaServerCache","AlephaServerLinks"],"sources":["../src/descriptors/$page.ts","../src/components/ClientOnly.tsx","../src/contexts/RouterContext.ts","../src/hooks/useAlepha.ts","../src/components/ErrorViewer.tsx","../src/contexts/RouterLayerContext.ts","../src/hooks/useRouterEvents.ts","../src/components/ErrorBoundary.tsx","../src/components/NestedView.tsx","../src/components/NotFound.tsx","../src/errors/RedirectionError.ts","../src/providers/PageDescriptorProvider.ts","../src/providers/BrowserRouterProvider.ts","../src/providers/ReactBrowserProvider.ts","../src/providers/ReactServerProvider.ts","../src/hooks/RouterHookApi.ts","../src/hooks/useRouter.ts","../src/components/Link.tsx","../src/hooks/useActive.ts","../src/hooks/useInject.ts","../src/hooks/useClient.ts","../src/hooks/useQueryParams.ts","../src/hooks/useRouterState.ts","../src/index.ts"],"sourcesContent":["import {\n\ttype Async,\n\tcreateDescriptor,\n\tDescriptor,\n\tKIND,\n\tNotImplementedError,\n\ttype Static,\n\ttype TSchema,\n} from \"@alepha/core\";\nimport type { ServerRequest } from \"@alepha/server\";\nimport type { ServerRouteCache } from \"@alepha/server-cache\";\nimport type { FC, ReactNode } from \"react\";\nimport type { ClientOnlyProps } from \"../components/ClientOnly.tsx\";\nimport type { PageReactContext } from \"../providers/PageDescriptorProvider.ts\";\n\n/**\n * Main descriptor for defining a React route in the application.\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\treturn createDescriptor(\n\t\tPageDescriptor<TConfig, TProps, TPropsParent>,\n\t\toptions,\n\t);\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface PageDescriptorOptions<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\t/**\n\t * Name your page.\n\t *\n\t * @default Descriptor key\n\t */\n\tname?: string;\n\n\t/**\n\t * Optional description of the page.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Add a pathname to the page.\n\t *\n\t * Pathname can contain parameters, like `/post/:slug`.\n\t *\n\t * @default \"\"\n\t */\n\tpath?: string;\n\n\t/**\n\t * Add an input schema to define:\n\t * - `params`: parameters from the pathname.\n\t * - `query`: query parameters from the URL.\n\t */\n\tschema?: TConfig;\n\n\t/**\n\t * Load data before rendering the page.\n\t *\n\t * This function receives\n\t * - the request context and\n\t * - the parent props (if page has a parent)\n\t *\n\t * In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.\n\t *\n\t * Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.\n\t * It's common to throw a `NotFoundError` to display a 404 page.\n\t *\n\t * RedirectError can be thrown to redirect the user to another page.\n\t */\n\tresolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;\n\n\t/**\n\t * The component to render when the page is loaded.\n\t *\n\t * If `lazy` is defined, this will be ignored.\n\t * Prefer using `lazy` to improve the initial loading time.\n\t */\n\tcomponent?: FC<TProps & TPropsParent>;\n\n\t/**\n\t * Lazy load the component when the page is loaded.\n\t *\n\t * It's recommended to use this for components to improve the initial loading time\n\t * and enable code-splitting.\n\t */\n\tlazy?: () => Promise<{ default: FC<TProps & TPropsParent> }>;\n\n\t/**\n\t * Set some children pages and make the page a parent page.\n\t *\n\t * /!\\ Parent page can't be rendered directly. /!\\\n\t *\n\t * If you still want to render at this pathname, add a child page with an empty path.\n\t */\n\tchildren?: Array<PageDescriptor> | (() => Array<PageDescriptor>);\n\n\tparent?: PageDescriptor<PageConfigSchema, TPropsParent>;\n\n\tcan?: () => boolean;\n\n\terrorHandler?: (error: Error) => ReactNode;\n\n\t/**\n\t * If true, the page will be rendered on the build time.\n\t * Works only with viteAlepha plugin.\n\t *\n\t * Replace boolean by an object to define static entries. (e.g. list of params/query)\n\t */\n\tstatic?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tentries?: Array<Partial<PageRequestConfig<TConfig>>>;\n\t\t };\n\n\t/**\n\t * If true, the page will be rendered on the client-side.\n\t */\n\tclient?: boolean | ClientOnlyProps;\n\n\tafterHandler?: (request: ServerRequest) => any;\n\n\tcache?: ServerRouteCache;\n}\n\nexport class PageDescriptor<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {\n\tpublic get name(): string {\n\t\treturn this.options.name ?? this.config.propertyKey;\n\t}\n\n\t/**\n\t * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.\n\t * Only valid for server-side rendering, it will throw an error if called on the client-side.\n\t */\n\tpublic async render(\n\t\toptions?: PageDescriptorRenderOptions,\n\t): Promise<PageDescriptorRenderResult> {\n\t\tthrow new NotImplementedError(\"\");\n\t}\n}\n\n$page[KIND] = PageDescriptor;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface PageConfigSchema {\n\tquery?: TSchema;\n\tparams?: TSchema;\n}\n\nexport type TPropsDefault = any;\n\nexport type TPropsParentDefault = {};\n\nexport interface PageDescriptorRenderOptions {\n\tparams?: Record<string, string>;\n\tquery?: Record<string, string>;\n\thtml?: boolean;\n\thydration?: boolean;\n}\n\nexport interface PageDescriptorRenderResult {\n\thtml: string;\n\tcontext: PageReactContext;\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 & PageReactContext;\n","import {\n\ttype PropsWithChildren,\n\ttype ReactNode,\n\tuseEffect,\n\tuseState,\n} from \"react\";\n\nexport interface ClientOnlyProps {\n\tfallback?: ReactNode;\n\tdisabled?: boolean;\n}\n\n/**\n * A small utility component that renders its children only on the client side.\n *\n * Optionally, you can provide a fallback React node that will be rendered.\n *\n * You should use this component when\n * - you have code that relies on browser-specific APIs\n * - you want to avoid server-side rendering for a specific part of your application\n * - you want to prevent pre-rendering of a component\n */\nconst ClientOnly = (props: PropsWithChildren<ClientOnlyProps>) => {\n\tconst [mounted, setMounted] = useState(false);\n\n\tuseEffect(() => setMounted(true), []);\n\n\tif (props.disabled) {\n\t\treturn props.children;\n\t}\n\n\treturn mounted ? props.children : props.fallback;\n};\n\nexport default ClientOnly;\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 type { Alepha } from \"@alepha/core\";\nimport { useContext } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useAlepha = (): Alepha => {\n\tconst routerContext = useContext(RouterContext);\n\tif (!routerContext) {\n\t\tthrow new Error(\"useAlepha must be used within a RouterProvider\");\n\t}\n\n\treturn routerContext.alepha;\n};\n","import { useState } from \"react\";\nimport { useAlepha } from \"../hooks/useAlepha.ts\";\n\ninterface ErrorViewerProps {\n\terror: Error;\n}\n\n// TODO: design this better\n\nconst ErrorViewer = ({ error }: ErrorViewerProps) => {\n\tconst [expanded, setExpanded] = useState(false);\n\tconst isProduction = useAlepha().isProduction();\n\t// const status = isHttpError(error) ? error.status : 500;\n\n\tif (isProduction) {\n\t\treturn <ErrorViewerProduction />;\n\t}\n\n\tconst stackLines = error.stack?.split(\"\\n\") ?? [];\n\tconst previewLines = stackLines.slice(0, 5);\n\tconst hiddenLineCount = stackLines.length - previewLines.length;\n\n\tconst copyToClipboard = (text: string) => {\n\t\tnavigator.clipboard.writeText(text).catch((err) => {\n\t\t\tconsole.error(\"Clipboard error:\", err);\n\t\t});\n\t};\n\n\tconst styles = {\n\t\tcontainer: {\n\t\t\tpadding: \"24px\",\n\t\t\tbackgroundColor: \"#FEF2F2\",\n\t\t\tcolor: \"#7F1D1D\",\n\t\t\tborder: \"1px solid #FECACA\",\n\t\t\tborderRadius: \"16px\",\n\t\t\tboxShadow: \"0 8px 24px rgba(0,0,0,0.05)\",\n\t\t\tfontFamily: \"monospace\",\n\t\t\tmaxWidth: \"768px\",\n\t\t\tmargin: \"40px auto\",\n\t\t},\n\t\theading: {\n\t\t\tfontSize: \"20px\",\n\t\t\tfontWeight: \"bold\",\n\t\t\tmarginBottom: \"4px\",\n\t\t},\n\t\tname: {\n\t\t\tfontSize: \"16px\",\n\t\t\tfontWeight: 600,\n\t\t},\n\t\tmessage: {\n\t\t\tfontSize: \"14px\",\n\t\t\tmarginBottom: \"16px\",\n\t\t},\n\t\tsectionHeader: {\n\t\t\tdisplay: \"flex\",\n\t\t\tjustifyContent: \"space-between\",\n\t\t\talignItems: \"center\",\n\t\t\tfontSize: \"12px\",\n\t\t\tmarginBottom: \"4px\",\n\t\t\tcolor: \"#991B1B\",\n\t\t},\n\t\tcopyButton: {\n\t\t\tfontSize: \"12px\",\n\t\t\tcolor: \"#DC2626\",\n\t\t\tbackground: \"none\",\n\t\t\tborder: \"none\",\n\t\t\tcursor: \"pointer\",\n\t\t\ttextDecoration: \"underline\",\n\t\t},\n\t\tstackContainer: {\n\t\t\tbackgroundColor: \"#FEE2E2\",\n\t\t\tpadding: \"12px\",\n\t\t\tborderRadius: \"8px\",\n\t\t\tfontSize: \"13px\",\n\t\t\tlineHeight: \"1.4\",\n\t\t\toverflowX: \"auto\" as const,\n\t\t\twhiteSpace: \"pre-wrap\" as const,\n\t\t},\n\t\texpandLine: {\n\t\t\tcolor: \"#F87171\",\n\t\t\tcursor: \"pointer\",\n\t\t\tmarginTop: \"8px\",\n\t\t},\n\t};\n\n\treturn (\n\t\t<div style={styles.container}>\n\t\t\t<div>\n\t\t\t\t<div style={styles.heading}>🔥 Error</div>\n\t\t\t\t<div style={styles.name}>{error.name}</div>\n\t\t\t\t<div style={styles.message}>{error.message}</div>\n\t\t\t</div>\n\n\t\t\t{stackLines.length > 0 && (\n\t\t\t\t<div>\n\t\t\t\t\t<div style={styles.sectionHeader}>\n\t\t\t\t\t\t<span>Stack trace</span>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonClick={() => copyToClipboard(error.stack!)}\n\t\t\t\t\t\t\tstyle={styles.copyButton}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tCopy all\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t\t<pre style={styles.stackContainer}>\n\t\t\t\t\t\t{(expanded ? stackLines : previewLines).map((line, i) => (\n\t\t\t\t\t\t\t<div key={i}>{line}</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{!expanded && hiddenLineCount > 0 && (\n\t\t\t\t\t\t\t<div style={styles.expandLine} onClick={() => setExpanded(true)}>\n\t\t\t\t\t\t\t\t+ {hiddenLineCount} more lines...\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</pre>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default ErrorViewer;\n\nconst ErrorViewerProduction = () => {\n\tconst styles = {\n\t\tcontainer: {\n\t\t\tpadding: \"24px\",\n\t\t\tbackgroundColor: \"#FEF2F2\",\n\t\t\tcolor: \"#7F1D1D\",\n\t\t\tborder: \"1px solid #FECACA\",\n\t\t\tborderRadius: \"16px\",\n\t\t\tboxShadow: \"0 8px 24px rgba(0,0,0,0.05)\",\n\t\t\tfontFamily: \"monospace\",\n\t\t\tmaxWidth: \"768px\",\n\t\t\tmargin: \"40px auto\",\n\t\t\ttextAlign: \"center\" as const,\n\t\t},\n\t\theading: {\n\t\t\tfontSize: \"20px\",\n\t\t\tfontWeight: \"bold\",\n\t\t\tmarginBottom: \"8px\",\n\t\t},\n\t\tname: {\n\t\t\tfontSize: \"16px\",\n\t\t\tfontWeight: 600,\n\t\t\tmarginBottom: \"4px\",\n\t\t},\n\t\tmessage: {\n\t\t\tfontSize: \"14px\",\n\t\t\topacity: 0.85,\n\t\t},\n\t};\n\n\treturn (\n\t\t<div style={styles.container}>\n\t\t\t<div style={styles.heading}>🚨 An error occurred</div>\n\t\t\t<div style={styles.message}>\n\t\t\t\tSomething went wrong. Please try again later.\n\t\t\t</div>\n\t\t</div>\n\t);\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 React, {\n\ttype ErrorInfo,\n\ttype PropsWithChildren,\n\ttype ReactNode,\n} from \"react\";\n\n/**\n * Props for the ErrorBoundary component.\n */\nexport interface ErrorBoundaryProps {\n\t/**\n\t * Fallback React node to render when an error is caught.\n\t * If not provided, a default error message will be shown.\n\t */\n\tfallback: (error: Error) => ReactNode;\n\n\t/**\n\t * Optional callback that receives the error and error info.\n\t * Use this to log errors to a monitoring service.\n\t */\n\tonError?: (error: Error, info: ErrorInfo) => void;\n}\n\n/**\n * State of the ErrorBoundary component.\n */\ninterface ErrorBoundaryState {\n\terror?: Error;\n}\n\n/**\n * A reusable error boundary for catching rendering errors\n * in any part of the React component tree.\n */\nexport class ErrorBoundary extends React.Component<\n\tPropsWithChildren<ErrorBoundaryProps>,\n\tErrorBoundaryState\n> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\t\tthis.state = {};\n\t}\n\n\t/**\n\t * Update state so the next render shows the fallback UI.\n\t */\n\tstatic getDerivedStateFromError(error: Error): ErrorBoundaryState {\n\t\treturn {\n\t\t\terror,\n\t\t};\n\t}\n\n\t/**\n\t * Lifecycle method called when an error is caught.\n\t * You can log the error or perform side effects here.\n\t */\n\tcomponentDidCatch(error: Error, info: ErrorInfo): void {\n\t\tif (this.props.onError) {\n\t\t\tthis.props.onError(error, info);\n\t\t}\n\t}\n\n\trender(): ReactNode {\n\t\tif (this.state.error) {\n\t\t\treturn this.props.fallback(this.state.error);\n\t\t}\n\n\t\treturn this.props.children;\n\t}\n}\n\nexport default ErrorBoundary;\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\";\nimport ErrorBoundary from \"./ErrorBoundary.tsx\";\n\nexport interface NestedViewProps {\n\tchildren?: ReactNode;\n}\n\n/**\n * A component that renders the current view of the nested router layer.\n *\n * To be simple, it renders the `element` of the current child page of a parent page.\n *\n * @example\n * ```tsx\n * import { NestedView } from \"@alepha/react\";\n *\n * class App {\n * parent = $page({\n * component: () => <NestedView />,\n * });\n *\n * child = $page({\n * parent: this.root,\n * component: () => <div>Child Page</div>,\n * });\n * }\n * ```\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\tif (!state.layers[index]?.cache) {\n\t\t\t\t\tsetView(state.layers[index]?.element);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[app],\n\t);\n\n\tif (!app) {\n\t\tthrow new Error(\"NestedView must be used within a RouterContext.\");\n\t}\n\n\tconst element = view ?? props.children ?? null;\n\n\treturn (\n\t\t<ErrorBoundary fallback={app.context.onError!}>{element}</ErrorBoundary>\n\t);\n};\n\nexport default NestedView;\n","export default function NotFoundPage() {\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\theight: \"100vh\",\n\t\t\t\tdisplay: \"flex\",\n\t\t\t\tflexDirection: \"column\",\n\t\t\t\tjustifyContent: \"center\",\n\t\t\t\talignItems: \"center\",\n\t\t\t\ttextAlign: \"center\",\n\t\t\t\tfontFamily: \"sans-serif\",\n\t\t\t\tpadding: \"1rem\",\n\t\t\t}}\n\t\t>\n\t\t\t<h1 style={{ fontSize: \"1rem\", marginBottom: \"0.5rem\" }}>\n\t\t\t\tThis page does not exist\n\t\t\t</h1>\n\t\t</div>\n\t);\n}\n","import type { HrefLike } from \"../hooks/RouterHookApi.ts\";\n\nexport class RedirectionError extends Error {\n\tpublic readonly page: HrefLike;\n\n\tconstructor(page: HrefLike) {\n\t\tsuper(\"Redirection\");\n\t\tthis.page = page;\n\t}\n}\n","import {\n\t$env,\n\t$hook,\n\t$inject,\n\t$logger,\n\tAlepha,\n\ttype Static,\n\tt,\n} from \"@alepha/core\";\nimport type { ApiLinksResponse } from \"@alepha/server\";\nimport { createElement, type ReactNode, StrictMode } from \"react\";\nimport ClientOnly from \"../components/ClientOnly.tsx\";\nimport ErrorViewer from \"../components/ErrorViewer.tsx\";\nimport NestedView from \"../components/NestedView.tsx\";\nimport NotFoundPage from \"../components/NotFound.tsx\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport {\n\t$page,\n\ttype PageDescriptor,\n\ttype PageDescriptorOptions,\n} from \"../descriptors/$page.ts\";\nimport { RedirectionError } from \"../errors/RedirectionError.ts\";\n\nconst envSchema = t.object({\n\tREACT_STRICT_MODE: t.boolean({ default: true }),\n});\n\ndeclare module \"@alepha/core\" {\n\texport interface Env extends Partial<Static<typeof envSchema>> {}\n}\n\nexport class PageDescriptorProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly env = $env(envSchema);\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 url(\n\t\tname: string,\n\t\toptions: { params?: Record<string, string>; base?: string } = {},\n\t): URL {\n\t\tconst page = this.page(name);\n\t\tif (!page) {\n\t\t\tthrow new Error(`Page ${name} not found`);\n\t\t}\n\n\t\tlet url = page.path ?? \"\";\n\t\tlet parent = page.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, options.params ?? {});\n\n\t\treturn new URL(\n\t\t\turl.replace(/\\/\\/+/g, \"/\") || \"/\",\n\t\t\toptions.base ?? `http://localhost`,\n\t\t);\n\t}\n\n\tpublic root(state: RouterState, context: PageReactContext): ReactNode {\n\t\tconst root = 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\n\t\tif (this.env.REACT_STRICT_MODE) {\n\t\t\treturn createElement(StrictMode, {}, root);\n\t\t}\n\n\t\treturn root;\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\t\trequest.onError = (error) => this.renderError(error); // error handler\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: {};\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: {};\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// 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\tit.cache = true;\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\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\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\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\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\tacc += \"/\";\n\t\t\tacc += it.route.path ? this.compile(it.route.path, params) : \"\";\n\t\t\tconst path = acc.replace(/\\/+/, \"/\");\n\t\t\tconst localErrorHandler = this.getErrorHandler(it.route);\n\t\t\tif (localErrorHandler) {\n\t\t\t\trequest.onError = localErrorHandler;\n\t\t\t}\n\n\t\t\t// handler has thrown an error, render an error view\n\t\t\tif (it.error) {\n\t\t\t\tlet element: ReactNode = await request.onError(it.error);\n\t\t\t\tif (element === null) {\n\t\t\t\t\telement = this.renderError(it.error);\n\t\t\t\t}\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, it.route),\n\t\t\t\t\tindex: i + 1,\n\t\t\t\t\tpath,\n\t\t\t\t\troute: it.route,\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 element = 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, element, it.route),\n\t\t\t\tindex: i + 1,\n\t\t\t\tpath,\n\t\t\t\troute: it.route,\n\t\t\t\tcache: it.cache,\n\t\t\t});\n\t\t}\n\n\t\treturn { layers, 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\tpublic renderError(error: Error): ReactNode {\n\t\treturn createElement(ErrorViewer, { error });\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 | undefined,\n\t\tpage: PageRoute,\n\t): ReactNode {\n\t\tview ??= this.renderEmptyView();\n\n\t\tconst element = page.client\n\t\t\t? createElement(\n\t\t\t\t\tClientOnly,\n\t\t\t\t\ttypeof page.client === \"object\" ? page.client : {},\n\t\t\t\t\tview,\n\t\t\t\t)\n\t\t\t: view;\n\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\telement,\n\t\t);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\ton: \"configure\",\n\t\thandler: () => {\n\t\t\tlet hasNotFoundHandler = false;\n\t\t\tconst pages = this.alepha.descriptors($page);\n\n\t\t\tconst hasParent = (it: PageDescriptor) => {\n\t\t\t\tfor (const page of pages) {\n\t\t\t\t\tconst children = page.options.children\n\t\t\t\t\t\t? Array.isArray(page.options.children)\n\t\t\t\t\t\t\t? page.options.children\n\t\t\t\t\t\t\t: page.options.children()\n\t\t\t\t\t\t: [];\n\t\t\t\t\tif (children.includes(it)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfor (const page of pages) {\n\t\t\t\tif (page.options.path === \"/*\") {\n\t\t\t\t\thasNotFoundHandler = true;\n\t\t\t\t}\n\n\t\t\t\t// skip children, we only want root pages\n\t\t\t\tif (hasParent(page)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.add(this.map(pages, page));\n\t\t\t}\n\n\t\t\tif (!hasNotFoundHandler && pages.length > 0) {\n\t\t\t\t// add a default 404 page if not already defined\n\t\t\t\tthis.add({\n\t\t\t\t\tpath: \"/*\",\n\t\t\t\t\tname: \"notFound\",\n\t\t\t\t\tcache: true,\n\t\t\t\t\tcomponent: NotFoundPage,\n\t\t\t\t\tafterHandler: ({ reply }) => {\n\t\t\t\t\t\treply.status = 404;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t});\n\n\tprotected map(\n\t\tpages: Array<PageDescriptor>,\n\t\ttarget: PageDescriptor,\n\t): PageRouteEntry {\n\t\tconst children = target.options.children\n\t\t\t? Array.isArray(target.options.children)\n\t\t\t\t? target.options.children\n\t\t\t\t: target.options.children()\n\t\t\t: [];\n\n\t\treturn {\n\t\t\t...target.options,\n\t\t\tname: target.name,\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\troute?: PageRoute;\n\tcache?: boolean;\n}\n\nexport type PreviousLayerData = Omit<Layer, \"element\" | \"index\" | \"path\">;\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}\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\tcache?: boolean;\n}\n\nexport interface RouterRenderResult {\n\tstate: RouterState;\n\tcontext: PageReactContext;\n\tredirect?: string;\n}\n\nexport interface PageRequest extends PageReactContext {\n\tparams: Record<string, any>;\n\tquery: Record<string, string>;\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/**\n * It's like RouterState, but publicly available in React context.\n * This is where we store all plugin data!\n */\nexport interface PageReactContext {\n\turl: URL;\n\tonError: (error: Error) => ReactNode;\n\tlinks?: ApiLinksResponse;\n}\n","import { $hook, $inject, $logger, Alepha } from \"@alepha/core\";\nimport { type Route, RouterProvider } from \"@alepha/router\";\nimport { createElement, type ReactNode } from \"react\";\nimport NotFoundPage from \"../components/NotFound.tsx\";\nimport {\n\tisPageRoute,\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype PageRoute,\n\ttype PageRouteEntry,\n\ttype RouterRenderResult,\n\ttype RouterState,\n\ttype TransitionOptions,\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\ton: \"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};\n\n\t\tconst context = {\n\t\t\turl,\n\t\t\tquery: {},\n\t\t\tparams: {},\n\t\t\tonError: () => null,\n\t\t\t...(options.context ?? {}),\n\t\t} as PageRequest;\n\n\t\tawait this.alepha.emit(\"react:transition:begin\", { state, context });\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\tcontext.query = query;\n\t\t\tcontext.params = params ?? {};\n\t\t\tcontext.previous = previous;\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\tcontext,\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\tredirect: result.redirect,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstate.layers = result.layers;\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: createElement(NotFoundPage),\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, context });\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\tcontext,\n\t\t\t});\n\t\t}\n\n\t\tif (options.state) {\n\t\t\toptions.state.layers = state.layers;\n\t\t\toptions.state.pathname = state.pathname;\n\t\t\toptions.state.search = state.search;\n\t\t}\n\n\t\tawait this.alepha.emit(\"react:transition:end\", {\n\t\t\tstate: options.state,\n\t\t\tcontext,\n\t\t});\n\n\t\treturn {\n\t\t\tcontext,\n\t\t\tstate,\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 } from \"@alepha/core\";\nimport type { ApiLinksResponse } from \"@alepha/server\";\nimport { LinkProvider } from \"@alepha/server-links\";\nimport type { Root } from \"react-dom/client\";\nimport { BrowserRouterProvider } from \"./BrowserRouterProvider.ts\";\nimport type {\n\tPreviousLayerData,\n\tRouterRenderResult,\n\tRouterState,\n\tTransitionOptions,\n} from \"./PageDescriptorProvider.ts\";\n\nexport class ReactBrowserProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly client = $inject(LinkProvider);\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly router = $inject(BrowserRouterProvider);\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};\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 location() {\n\t\treturn window.location;\n\t}\n\n\tpublic get url(): string {\n\t\tlet url = this.location.pathname + this.location.search;\n\n\t\tif (import.meta?.env?.BASE_URL) {\n\t\t\turl = url.replace(import.meta.env?.BASE_URL, \"\");\n\t\t\tif (!url.startsWith(\"/\")) {\n\t\t\t\turl = `/${url}`;\n\t\t\t}\n\t\t}\n\n\t\treturn url;\n\t}\n\n\tpublic pushState(url: string, replace?: boolean) {\n\t\tlet path = url;\n\n\t\tif (import.meta?.env?.BASE_URL) {\n\t\t\tpath = (import.meta.env?.BASE_URL + path).replaceAll(\"//\", \"/\");\n\t\t}\n\n\t\tif (replace) {\n\t\t\tthis.history.replaceState({}, \"\", path);\n\t\t} else {\n\t\t\tthis.history.pushState({}, \"\", path);\n\t\t}\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\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\t// when redirecting in browser\n\t\tif (result.context.url.pathname !== url) {\n\t\t\t// TODO: check if losing search params is acceptable?\n\t\t\tthis.pushState(result.context.url.pathname);\n\t\t\treturn;\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tthis.pushState(url);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pushState(url);\n\t}\n\n\tprotected async render(\n\t\toptions: { url?: string; previous?: PreviousLayerData[] } = {},\n\t): Promise<RouterRenderResult> {\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 result;\n\t}\n\n\t/**\n\t * Get embedded layers from the server.\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\n\tpublic readonly ready = $hook({\n\t\ton: \"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\tfor (const link of hydration.links.links) {\n\t\t\t\t\tthis.client.pushLink(link);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { context } = await this.render({ previous });\n\n\t\t\tawait this.alepha.emit(\"react:browser:render\", {\n\t\t\t\tstate: this.state,\n\t\t\t\tcontext,\n\t\t\t\thydration,\n\t\t\t});\n\n\t\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\t\t// when you update silently queryparams or hash, skip rendering\n\t\t\t\t// if you want to force a rendering, use #go()\n\t\t\t\tif (this.state.pathname === location.pathname) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.render();\n\t\t\t});\n\t\t},\n\t});\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface RouterGoOptions {\n\treplace?: boolean;\n\tmatch?: TransitionOptions;\n\tparams?: Record<string, string>;\n}\n\nexport interface ReactHydrationState {\n\tlayers?: Array<PreviousLayerData>;\n\tlinks?: ApiLinksResponse;\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n\t$env,\n\t$hook,\n\t$inject,\n\t$logger,\n\tAlepha,\n\ttype Static,\n\tt,\n} from \"@alepha/core\";\nimport {\n\tapiLinksResponseSchema,\n\ttype ServerHandler,\n\tServerRouterProvider,\n\tServerTimingProvider,\n} from \"@alepha/server\";\nimport { ServerLinksProvider } from \"@alepha/server-links\";\nimport { ServerStaticProvider } from \"@alepha/server-static\";\nimport { renderToString } from \"react-dom/server\";\nimport {\n\t$page,\n\ttype PageDescriptorRenderOptions,\n} from \"../descriptors/$page.ts\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype PageRoute,\n\ttype RouterState,\n} from \"./PageDescriptorProvider.ts\";\nimport type { ReactHydrationState } from \"./ReactBrowserProvider.ts\";\n\nconst envSchema = t.object({\n\tREACT_SERVER_DIST: t.string({ default: \"public\" }),\n\tREACT_SERVER_PREFIX: t.string({ default: \"\" }),\n\tREACT_SSR_ENABLED: t.optional(t.boolean()),\n\tREACT_ROOT_ID: t.string({ default: \"root\" }),\n});\n\ndeclare module \"@alepha/core\" {\n\tinterface Env extends Partial<Static<typeof envSchema>> {}\n\tinterface State {\n\t\t\"react.server.template\"?: string;\n\t\t\"react.server.ssr\"?: boolean;\n\t}\n}\n\nexport class ReactServerProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pageDescriptorProvider = $inject(PageDescriptorProvider);\n\tprotected readonly serverStaticProvider = $inject(ServerStaticProvider);\n\tprotected readonly serverRouterProvider = $inject(ServerRouterProvider);\n\tprotected readonly serverTimingProvider = $inject(ServerTimingProvider);\n\tprotected readonly env = $env(envSchema);\n\tprotected readonly ROOT_DIV_REGEX = new RegExp(\n\t\t`<div([^>]*)\\\\s+id=[\"']${this.env.REACT_ROOT_ID}[\"']([^>]*)>(.*?)<\\\\/div>`,\n\t\t\"is\",\n\t);\n\n\tpublic readonly onConfigure = $hook({\n\t\ton: \"configure\",\n\t\thandler: async () => {\n\t\t\tconst pages = this.alepha.descriptors($page);\n\n\t\t\tconst ssrEnabled =\n\t\t\t\tpages.length > 0 && this.env.REACT_SSR_ENABLED !== false;\n\n\t\t\tthis.alepha.state(\"react.server.ssr\", ssrEnabled);\n\n\t\t\tfor (const page of pages) {\n\t\t\t\tpage.render = this.createRenderFunction(page.name);\n\t\t\t}\n\n\t\t\t// development mode\n\t\t\tif (this.alepha.isServerless() === \"vite\") {\n\t\t\t\tawait this.configureVite(ssrEnabled);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// production mode\n\t\t\tlet root = \"\";\n\n\t\t\t// non-serverless mode only -> serve static files\n\t\t\tif (!this.alepha.isServerless()) {\n\t\t\t\troot = this.getPublicDirectory();\n\t\t\t\tif (!root) {\n\t\t\t\t\tthis.log.warn(\n\t\t\t\t\t\t\"Missing static files, static file server will be disabled\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.log.debug(`Using static files from: ${root}`);\n\t\t\t\t\tawait this.configureStaticServer(root);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ssrEnabled) {\n\t\t\t\tawait this.registerPages(async () => this.template);\n\t\t\t\tthis.log.info(\"SSR OK\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// no SSR enabled, serve index.html for all unmatched routes\n\t\t\tthis.log.info(\"SSR is disabled, use History API fallback\");\n\t\t\tthis.serverRouterProvider.createRoute({\n\t\t\t\tpath: \"*\",\n\t\t\t\thandler: async ({ url, reply }) => {\n\t\t\t\t\tif (url.pathname.includes(\".\")) {\n\t\t\t\t\t\t// If the request is for a file (e.g., /style.css), do not fallback\n\t\t\t\t\t\treply.headers[\"content-type\"] = \"text/plain\";\n\t\t\t\t\t\treply.body = \"Not Found\";\n\t\t\t\t\t\treply.status = 404;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\treply.headers[\"content-type\"] = \"text/html\";\n\n\t\t\t\t\t// serve index.html for all unmatched routes\n\t\t\t\t\treturn this.template;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tpublic get template() {\n\t\treturn (\n\t\t\tthis.alepha.state(\"react.server.template\") ??\n\t\t\t\"<!DOCTYPE html><html lang='en'><head></head><body></body></html>\"\n\t\t);\n\t}\n\n\tprotected async registerPages(templateLoader: TemplateLoader) {\n\t\tfor (const page of this.pageDescriptorProvider.getPages()) {\n\t\t\tif (page.children?.length) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.log.debug(`+ ${page.match} -> ${page.name}`);\n\n\t\t\tthis.serverRouterProvider.createRoute({\n\t\t\t\t...page,\n\t\t\t\tschema: undefined, // schema is handled by the page descriptor provider for now (shared by browser and server)\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: page.match,\n\t\t\t\thandler: this.createHandler(page, templateLoader),\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected getPublicDirectory(): string {\n\t\tconst maybe = [\n\t\t\tjoin(process.cwd(), `dist/${this.env.REACT_SERVER_DIST}`),\n\t\t\tjoin(process.cwd(), this.env.REACT_SERVER_DIST),\n\t\t];\n\n\t\tfor (const it of maybe) {\n\t\t\tif (existsSync(it)) {\n\t\t\t\treturn it;\n\t\t\t}\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\tprotected async configureStaticServer(root: string) {\n\t\tawait this.serverStaticProvider.createStaticServer({\n\t\t\troot,\n\t\t\tpath: this.env.REACT_SERVER_PREFIX,\n\t\t});\n\t}\n\n\tprotected async configureVite(ssrEnabled: boolean) {\n\t\tif (!ssrEnabled) {\n\t\t\t// do nothing, vite will handle everything for us\n\t\t\treturn;\n\t\t}\n\n\t\tthis.log.info(\"SSR (vite) OK\");\n\n\t\tconst url = `http://${process.env.SERVER_HOST}:${process.env.SERVER_PORT}`;\n\n\t\tawait this.registerPages(() =>\n\t\t\tfetch(`${url}/index.html`)\n\t\t\t\t.then((it) => it.text())\n\t\t\t\t.catch(() => undefined),\n\t\t);\n\t}\n\n\t/**\n\t * For testing purposes, creates a render function that can be used.\n\t */\n\tprotected createRenderFunction(name: string, withIndex = false) {\n\t\treturn async (options: PageDescriptorRenderOptions = {}) => {\n\t\t\tconst page = this.pageDescriptorProvider.page(name);\n\t\t\tconst url = new URL(this.pageDescriptorProvider.url(name, options));\n\t\t\tconst context: PageRequest = {\n\t\t\t\turl,\n\t\t\t\tparams: options.params ?? {},\n\t\t\t\tquery: options.query ?? {},\n\t\t\t\thead: {},\n\t\t\t\tonError: () => null,\n\t\t\t};\n\n\t\t\tawait this.alepha.emit(\"react:server:render:begin\", {\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\tconst state = await this.pageDescriptorProvider.createLayers(\n\t\t\t\tpage,\n\t\t\t\tcontext,\n\t\t\t);\n\n\t\t\tif (!withIndex && !options.html) {\n\t\t\t\treturn {\n\t\t\t\t\tcontext,\n\t\t\t\t\thtml: renderToString(\n\t\t\t\t\t\tthis.pageDescriptorProvider.root(state, context),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst html = this.renderToHtml(\n\t\t\t\tthis.template ?? \"\",\n\t\t\t\tstate,\n\t\t\t\tcontext,\n\t\t\t\toptions.hydration,\n\t\t\t);\n\n\t\t\tconst result = {\n\t\t\t\tcontext,\n\t\t\t\tstate,\n\t\t\t\thtml,\n\t\t\t};\n\n\t\t\tawait this.alepha.emit(\"react:server:render:end\", result);\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected createHandler(\n\t\tpage: PageRoute,\n\t\ttemplateLoader: TemplateLoader,\n\t): ServerHandler {\n\t\treturn async (serverRequest) => {\n\t\t\tconst { url, reply, query, params } = serverRequest;\n\t\t\tconst template = await templateLoader();\n\t\t\tif (!template) {\n\t\t\t\tthrow new Error(\"Template not found\");\n\t\t\t}\n\n\t\t\tconst context: PageRequest = {\n\t\t\t\turl,\n\t\t\t\tparams,\n\t\t\t\tquery,\n\t\t\t\t// plugins\n\t\t\t\thead: {},\n\t\t\t\tonError: () => null,\n\t\t\t};\n\n\t\t\tif (this.alepha.has(ServerLinksProvider)) {\n\t\t\t\tconst srv = this.alepha.inject(ServerLinksProvider);\n\t\t\t\tconst schema = apiLinksResponseSchema as any;\n\n\t\t\t\tcontext.links = this.alepha.parse(\n\t\t\t\t\tschema,\n\t\t\t\t\tawait srv.getLinks({\n\t\t\t\t\t\tuser: serverRequest.user,\n\t\t\t\t\t\tauthorization: serverRequest.headers.authorization,\n\t\t\t\t\t}),\n\t\t\t\t) as any;\n\n\t\t\t\tthis.alepha.context.set(\"links\", context.links);\n\t\t\t}\n\n\t\t\tlet target: PageRoute | undefined = page; // TODO: move to PageDescriptorProvider\n\t\t\twhile (target) {\n\t\t\t\tif (page.can && !page.can()) {\n\t\t\t\t\t// if the page is not accessible, return 403\n\t\t\t\t\treply.status = 403;\n\t\t\t\t\treply.headers[\"content-type\"] = \"text/plain\";\n\t\t\t\t\treturn \"Forbidden\";\n\t\t\t\t}\n\t\t\t\ttarget = target.parent;\n\t\t\t}\n\n\t\t\t// TODO: SSR strategies\n\t\t\t// - only when googlebot\n\t\t\t// - only child pages\n\t\t\t// if (page.client) {\n\t\t\t// \t// if the page is a client-only page, return 404\n\t\t\t// \treply.status = 200;\n\t\t\t// \treply.headers[\"content-type\"] = \"text/html\";\n\t\t\t// \treply.body = template;\n\t\t\t// \treturn;\n\t\t\t// }\n\n\t\t\tawait this.alepha.emit(\"react:server:render:begin\", {\n\t\t\t\trequest: serverRequest,\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\tthis.serverTimingProvider.beginTiming(\"createLayers\");\n\n\t\t\tconst state = await this.pageDescriptorProvider.createLayers(\n\t\t\t\tpage,\n\t\t\t\tcontext,\n\t\t\t);\n\n\t\t\tthis.serverTimingProvider.endTiming(\"createLayers\");\n\n\t\t\tif (state.redirect) {\n\t\t\t\treturn reply.redirect(state.redirect);\n\t\t\t}\n\n\t\t\treply.headers[\"content-type\"] = \"text/html\";\n\n\t\t\t// by default, disable caching for SSR responses\n\t\t\t// some plugins may override this\n\t\t\treply.headers[\"cache-control\"] =\n\t\t\t\t\"no-store, no-cache, must-revalidate, proxy-revalidate\";\n\t\t\treply.headers.pragma = \"no-cache\";\n\t\t\treply.headers.expires = \"0\";\n\n\t\t\t// don't cache user links\n\t\t\tif (page.cache && serverRequest.user) {\n\t\t\t\tdelete context.links;\n\t\t\t}\n\n\t\t\tconst html = this.renderToHtml(template, state, context);\n\n\t\t\tawait this.alepha.emit(\"react:server:render:end\", {\n\t\t\t\trequest: serverRequest,\n\t\t\t\tcontext,\n\t\t\t\tstate,\n\t\t\t\thtml,\n\t\t\t});\n\n\t\t\tpage.afterHandler?.(serverRequest);\n\n\t\t\treturn html;\n\t\t};\n\t}\n\n\tpublic renderToHtml(\n\t\ttemplate: string,\n\t\tstate: RouterState,\n\t\tcontext: PageReactContext,\n\t\thydration = true,\n\t) {\n\t\tconst element = this.pageDescriptorProvider.root(state, context);\n\n\t\tthis.serverTimingProvider.beginTiming(\"renderToString\");\n\n\t\tlet app = \"\";\n\t\ttry {\n\t\t\tapp = renderToString(element);\n\t\t} catch (error) {\n\t\t\tthis.log.error(\"Error during SSR\", error);\n\t\t\tapp = renderToString(context.onError(error as Error));\n\t\t}\n\n\t\tthis.serverTimingProvider.endTiming(\"renderToString\");\n\n\t\tconst response = {\n\t\t\thtml: template,\n\t\t};\n\n\t\tif (hydration) {\n\t\t\tconst hydrationData: ReactHydrationState = {\n\t\t\t\tlinks: context.links,\n\t\t\t\tlayers: state.layers.map((it) => ({\n\t\t\t\t\t...it,\n\t\t\t\t\terror: it.error\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...it.error,\n\t\t\t\t\t\t\t\tname: it.error.name,\n\t\t\t\t\t\t\t\tmessage: it.error.message,\n\t\t\t\t\t\t\t\tstack: it.error.stack, // TODO: Hide stack in production ?\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tindex: undefined,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t\telement: undefined,\n\t\t\t\t\troute: undefined,\n\t\t\t\t})),\n\t\t\t};\n\n\t\t\t// create hydration data\n\t\t\tconst script = `<script>window.__ssr=${JSON.stringify(hydrationData)}</script>`;\n\n\t\t\t// inject app into template\n\t\t\tthis.fillTemplate(response, app, script);\n\t\t}\n\n\t\treturn response.html;\n\t}\n\n\tprotected fillTemplate(\n\t\tresponse: { html: string },\n\t\tapp: string,\n\t\tscript: string,\n\t) {\n\t\tif (this.ROOT_DIV_REGEX.test(response.html)) {\n\t\t\t// replace contents of the existing <div id=\"root\">\n\t\t\tresponse.html = response.html.replace(\n\t\t\t\tthis.ROOT_DIV_REGEX,\n\t\t\t\t(_match, beforeId, afterId) => {\n\t\t\t\t\treturn `<div${beforeId} id=\"${this.env.REACT_ROOT_ID}\"${afterId}>${app}</div>`;\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tconst bodyOpenTag = /<body([^>]*)>/i;\n\t\t\tif (bodyOpenTag.test(response.html)) {\n\t\t\t\tresponse.html = response.html.replace(bodyOpenTag, (match) => {\n\t\t\t\t\treturn `${match}\\n<div id=\"${this.env.REACT_ROOT_ID}\">${app}</div>`;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst bodyCloseTagRegex = /<\\/body>/i;\n\t\tif (bodyCloseTagRegex.test(response.html)) {\n\t\t\tresponse.html = response.html.replace(\n\t\t\t\tbodyCloseTagRegex,\n\t\t\t\t`${script}\\n</body>`,\n\t\t\t);\n\t\t}\n\t}\n}\n\ntype TemplateLoader = () => Promise<string | undefined>;\n","import type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport type {\n\tAnchorProps,\n\tPageReactContext,\n\tPageRoute,\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 pages: PageRoute[],\n\t\tprivate readonly context: PageReactContext,\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\tpublic getURL(): URL {\n\t\tif (!this.browser) {\n\t\t\treturn this.context.url;\n\t\t}\n\t\treturn new URL(this.location.href);\n\t}\n\n\tpublic get location(): Location {\n\t\tif (!this.browser) {\n\t\t\tthrow new Error(\"Browser is required\");\n\t\t}\n\n\t\treturn this.browser.location;\n\t}\n\n\tpublic get current(): RouterState {\n\t\treturn this.state;\n\t}\n\n\tpublic get pathname(): string {\n\t\treturn this.state.pathname;\n\t}\n\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\tpublic async back() {\n\t\tthis.browser?.history.back();\n\t}\n\n\tpublic async forward() {\n\t\tthis.browser?.history.forward();\n\t}\n\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(\n\t\tpathname: HrefLike,\n\t\tlayer: { path: string } = this.layer,\n\t\toptions: { params?: Record<string, any> } = {},\n\t) {\n\t\tif (typeof pathname === \"object\") {\n\t\t\tpathname = pathname.options.path ?? \"\";\n\t\t}\n\n\t\tif (options.params) {\n\t\t\tfor (const [key, value] of Object.entries(options.params)) {\n\t\t\t\tpathname = pathname.replace(`:${key}`, String(value));\n\t\t\t}\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\tpublic async go(path: string, options?: RouterGoOptions): Promise<void>;\n\tpublic async go<T extends object>(\n\t\tpath: keyof VirtualRouter<T>,\n\t\toptions?: RouterGoOptions,\n\t): Promise<void>;\n\tpublic async go(path: string, options?: RouterGoOptions): Promise<void> {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === path) {\n\t\t\t\tpath = page.path ?? \"\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tawait this.browser?.go(this.createHref(path, this.layer, options), options);\n\t}\n\n\tpublic anchor(\n\t\tpath: string,\n\t\toptions?: { params?: Record<string, any> },\n\t): AnchorProps;\n\tpublic anchor<T extends object>(\n\t\tpath: keyof VirtualRouter<T>,\n\t\toptions?: { params?: Record<string, any> },\n\t): AnchorProps;\n\tpublic anchor(\n\t\tpath: string,\n\t\toptions: { params?: Record<string, any> } = {},\n\t): AnchorProps {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === path) {\n\t\t\t\tpath = page.path ?? \"\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst href = this.createHref(path, this.layer, options);\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, options).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:\n\t\t\t| Record<string, any>\n\t\t\t| ((queryParams: Record<string, any>) => Record<string, any>),\n\t\toptions: {\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 func = typeof record === \"function\" ? record : () => record;\n\t\tconst search = new URLSearchParams(func(this.query)).toString();\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\nexport type VirtualRouter<T> = {\n\t[K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K];\n};\n","import { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport { PageDescriptorProvider } from \"../providers/PageDescriptorProvider.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\tconst pages = useMemo(() => {\n\t\treturn ctx.alepha.inject(PageDescriptorProvider).getPages();\n\t}, []);\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tnew RouterHookApi(\n\t\t\t\tpages,\n\t\t\t\tctx.context,\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.inject(ReactBrowserProvider)\n\t\t\t\t\t: undefined,\n\t\t\t),\n\t\t[layer],\n\t);\n};\n","import type { AnchorHTMLAttributes } from \"react\";\nimport React from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport { useRouter } from \"../hooks/useRouter.ts\";\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 router = useRouter();\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 = typeof props.to === \"string\" ? undefined : props.to.options.name;\n\n\tconst anchorProps = {\n\t\t...props,\n\t\tto: undefined,\n\t};\n\n\treturn (\n\t\t<a {...router.anchor(to)} {...anchorProps}>\n\t\t\t{props.children ?? name}\n\t\t</a>\n\t);\n};\n\nexport default Link;\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","import type { Service } from \"@alepha/core\";\nimport { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useInject = <T extends object>(clazz: Service<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(() => ctx.alepha.inject(clazz), []);\n};\n","import {\n\ttype ClientScope,\n\ttype HttpVirtualClient,\n\tLinkProvider,\n} from \"@alepha/server-links\";\nimport { useInject } from \"./useInject.ts\";\n\nexport const useClient = <T extends object>(\n\t_scope?: ClientScope,\n): HttpVirtualClient<T> => {\n\treturn useInject(LinkProvider).client<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((data) => {\n\t\t\t\treturn { ...data, [key]: encode(ctx.alepha, schema, queryParams) };\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 { $module } from \"@alepha/core\";\nimport { AlephaServer, type ServerRequest } from \"@alepha/server\";\nimport { AlephaServerCache } from \"@alepha/server-cache\";\nimport { AlephaServerLinks } from \"@alepha/server-links\";\nimport { $page } from \"./descriptors/$page.ts\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype RouterState,\n} from \"./providers/PageDescriptorProvider.ts\";\nimport {\n\tReactBrowserProvider,\n\ttype ReactHydrationState,\n} from \"./providers/ReactBrowserProvider.ts\";\nimport { ReactServerProvider } from \"./providers/ReactServerProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./index.shared.ts\";\nexport * from \"./providers/PageDescriptorProvider.ts\";\nexport * from \"./providers/ReactBrowserProvider.ts\";\nexport * from \"./providers/ReactServerProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\ndeclare module \"@alepha/core\" {\n\tinterface Hooks {\n\t\t\"react:router:createLayers\": {\n\t\t\trequest: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t\tlayers: PageRequest[];\n\t\t};\n\t\t\"react:server:render:begin\": {\n\t\t\trequest?: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t};\n\t\t\"react:server:render:end\": {\n\t\t\trequest?: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t\tstate: RouterState;\n\t\t\thtml: string;\n\t\t};\n\t\t\"react:browser:render\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t\thydration?: ReactHydrationState;\n\t\t};\n\t\t\"react:transition:begin\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:success\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:error\": {\n\t\t\terror: Error;\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:end\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t}\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.\n *\n * The React module enables building modern React applications using the `$page` descriptor on class properties.\n * It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full\n * type safety and schema validation for route parameters and data.\n *\n * @see {@link $page}\n * @module alepha.react\n */\nexport const AlephaReact = $module({\n\tname: \"alepha.react\",\n\tdescriptors: [$page],\n\tservices: [ReactServerProvider, PageDescriptorProvider, ReactBrowserProvider],\n\tregister: (alepha) =>\n\t\talepha\n\t\t\t.with(AlephaServer)\n\t\t\t.with(AlephaServerCache)\n\t\t\t.with(AlephaServerLinks)\n\t\t\t.with(ReactServerProvider)\n\t\t\t.with(PageDescriptorProvider),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,QAAQ,CAKpBA,YACmD;AACnD,QAAO,oCACN,gBACA,QACA;AACD;AA0GD,IAAa,iBAAb,cAIUC,yBAAiE;CAC1E,IAAW,OAAe;AACzB,SAAO,KAAK,QAAQ,QAAQ,KAAK,OAAO;CACxC;;;;;CAMD,MAAa,OACZC,SACsC;AACtC,QAAM,IAAIC,kCAAoB;CAC9B;AACD;AAED,MAAMC,sBAAQ;;;;;;;;;;;;;;ACrId,MAAM,aAAa,CAACC,UAA8C;CACjE,MAAM,CAAC,SAAS,WAAW,GAAG,oBAAS,MAAM;AAE7C,sBAAU,MAAM,WAAW,KAAK,EAAE,CAAE,EAAC;AAErC,KAAI,MAAM,SACT,QAAO,MAAM;AAGd,QAAO,UAAU,MAAM,WAAW,MAAM;AACxC;AAED,yBAAe;;;;ACrBf,MAAa,gBAAgB,gCAE5B;;;;ACXD,MAAa,YAAY,MAAc;CACtC,MAAM,gBAAgB,sBAAW,cAAc;AAC/C,MAAK,cACJ,OAAM,IAAI,MAAM;AAGjB,QAAO,cAAc;AACrB;;;;ACFD,MAAM,cAAc,CAAC,EAAE,OAAyB,KAAK;CACpD,MAAM,CAAC,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AeC,cAAY;AAC3B,SAAO,eAAe,CAAC,SAAS;AAC/B,UAAO;IAAE,GAAG;KAAO,MAAM,OAAO,IAAI,QAAQ,QAAQA,cAAY;GAAE;EAClE,EAAC;CACF,CACD;AACD;AAID,MAAM,SAAS,CAACC,QAAgBC,QAAiBC,SAAc;AAC9D,QAAO,KAAK,KAAK,UAAU,OAAO,MAAM,QAAQ,KAAK,CAAC,CAAC;AACvD;AAED,MAAM,SAAS,CAACF,QAAgBC,QAAiBC,SAAc;AAC9D,KAAI;AACH,SAAO,OAAO,MAAM,QAAQ,KAAK,MAAM,KAAK,mBAAmB,KAAK,CAAC,CAAC,CAAC;CACvE,SAAQ,QAAQ;AAChB,SAAO,CAAE;CACT;AACD;;;;ACjDD,MAAa,iBAAiB,MAAmB;CAChD,MAAM,MAAM,sBAAW,cAAc;CACrC,MAAM,QAAQ,sBAAW,mBAAmB;AAC5C,MAAK,QAAQ,MACZ,OAAM,IAAI,MAAM;CAGjB,MAAM,CAAC,OAAO,SAAS,GAAG,oBAAS,IAAI,MAAM;AAE7C,iBAAgB,EACf,OAAO,CAAC,EAAE,gBAAO,KAAK,SAAS,EAAE,GAAGC,QAAO,EAAC,CAC5C,EAAC;AAEF,QAAO;AACP;;;;;;;;;;;;;;AC4DD,MAAa,cAAc,2BAAQ;CAClC,MAAM;CACN,aAAa,CAAC,KAAM;CACpB,UAAU;EAAC;EAAqB;EAAwB;CAAqB;CAC7E,UAAU,CAAC,WACV,OACE,KAAKC,6BAAa,CAClB,KAAKC,wCAAkB,CACvB,KAAKC,wCAAkB,CACvB,KAAK,oBAAoB,CACzB,KAAK,uBAAuB;AAC/B,EAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["options: PageDescriptorOptions<TConfig, TProps, TPropsParent>","Descriptor","options?: PageDescriptorRenderOptions","NotImplementedError","KIND","props: PropsWithChildren<ClientOnlyProps>","text: string","opts: {\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}","deps: any[]","subs: Function[]","React","props: ErrorBoundaryProps","error: Error","info: ErrorInfo","props: NestedViewProps","ErrorBoundary","page: HrefLike","envSchema","Alepha","name: string","options: { params?: Record<string, string>; base?: string }","state: RouterState","context: PageReactContext","NestedView","StrictMode","route: PageRoute","request: PageRequest","layers: Layer[]","context: Record<string, any>","stack: Array<RouterStackItem>","route","config: Record<string, any>","str?: string","element: ReactNode","element","page: PageRoute","props: Record<string, any>","error: Error","ErrorViewer","page: { options: { name?: string } }","params: Record<string, any>","path: string","params: Record<string, string>","index: number","view: ReactNode | undefined","ClientOnly","it: PageDescriptor","pages: Array<PageDescriptor>","target: PageDescriptor","entry: PageRouteEntry","it: any","RouterProvider","Alepha","entry: PageRouteEntry","url: URL","options: TransitionOptions","state: RouterState","query: Record<string, string>","context: PageReactContext","LinkProvider","Alepha","url: string","replace?: boolean","props?: Record<string, any>","previous: PreviousLayerData[]","options: RouterGoOptions","options: { url?: string; previous?: PreviousLayerData[] }","Alepha","ServerStaticProvider","ServerRouterProvider","ServerTimingProvider","templateLoader: TemplateLoader","root: string","ssrEnabled: boolean","name: string","options: PageDescriptorRenderOptions","context: PageRequest","page: PageRoute","ServerLinksProvider","apiLinksResponseSchema","target: PageRoute | undefined","template: string","state: RouterState","context: PageReactContext","hydrationData: ReactHydrationState","response: { html: string }","app: string","script: string","pages: PageRoute[]","context: PageReactContext","state: RouterState","layer: {\n\t\t\tpath: string;\n\t\t}","browser?: ReactBrowserProvider","query: Record<string, string>","props?: Record<string, any>","pathname: HrefLike","layer: { path: string }","options: { params?: Record<string, any> }","path: string","options?: RouterGoOptions","ev: any","record:\n\t\t\t| Record<string, any>\n\t\t\t| ((queryParams: Record<string, any>) => Record<string, any>)","options: {\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}","props: LinkProps","path: HrefLike","name: string | undefined","ev: any","clazz: Service<T>","_scope?: ClientScope","LinkProvider","schema: T","options: UseQueryParamsHookOptions","queryParams: Static<T>","queryParams","alepha: Alepha","schema: TObject","data: any","state","AlephaServer","AlephaServerCache","AlephaServerLinks"],"sources":["../src/descriptors/$page.ts","../src/components/ClientOnly.tsx","../src/components/ErrorViewer.tsx","../src/contexts/RouterContext.ts","../src/contexts/RouterLayerContext.ts","../src/hooks/useRouterEvents.ts","../src/components/ErrorBoundary.tsx","../src/components/NestedView.tsx","../src/components/NotFound.tsx","../src/errors/RedirectionError.ts","../src/providers/PageDescriptorProvider.ts","../src/providers/BrowserRouterProvider.ts","../src/providers/ReactBrowserProvider.ts","../src/providers/ReactServerProvider.ts","../src/hooks/RouterHookApi.ts","../src/hooks/useRouter.ts","../src/components/Link.tsx","../src/hooks/useActive.ts","../src/hooks/useAlepha.ts","../src/hooks/useInject.ts","../src/hooks/useClient.ts","../src/hooks/useQueryParams.ts","../src/hooks/useRouterState.ts","../src/index.ts"],"sourcesContent":["import {\n\ttype Async,\n\tcreateDescriptor,\n\tDescriptor,\n\tKIND,\n\tNotImplementedError,\n\ttype Static,\n\ttype TSchema,\n} from \"@alepha/core\";\nimport type { ServerRequest } from \"@alepha/server\";\nimport type { ServerRouteCache } from \"@alepha/server-cache\";\nimport type { FC, ReactNode } from \"react\";\nimport type { ClientOnlyProps } from \"../components/ClientOnly.tsx\";\nimport type { PageReactContext } from \"../providers/PageDescriptorProvider.ts\";\n\n/**\n * Main descriptor for defining a React route in the application.\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\treturn createDescriptor(\n\t\tPageDescriptor<TConfig, TProps, TPropsParent>,\n\t\toptions,\n\t);\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface PageDescriptorOptions<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\t/**\n\t * Name your page.\n\t *\n\t * @default Descriptor key\n\t */\n\tname?: string;\n\n\t/**\n\t * Optional description of the page.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Add a pathname to the page.\n\t *\n\t * Pathname can contain parameters, like `/post/:slug`.\n\t *\n\t * @default \"\"\n\t */\n\tpath?: string;\n\n\t/**\n\t * Add an input schema to define:\n\t * - `params`: parameters from the pathname.\n\t * - `query`: query parameters from the URL.\n\t */\n\tschema?: TConfig;\n\n\t/**\n\t * Load data before rendering the page.\n\t *\n\t * This function receives\n\t * - the request context and\n\t * - the parent props (if page has a parent)\n\t *\n\t * In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.\n\t *\n\t * Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.\n\t * It's common to throw a `NotFoundError` to display a 404 page.\n\t *\n\t * RedirectError can be thrown to redirect the user to another page.\n\t */\n\tresolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;\n\n\t/**\n\t * The component to render when the page is loaded.\n\t *\n\t * If `lazy` is defined, this will be ignored.\n\t * Prefer using `lazy` to improve the initial loading time.\n\t */\n\tcomponent?: FC<TProps & TPropsParent>;\n\n\t/**\n\t * Lazy load the component when the page is loaded.\n\t *\n\t * It's recommended to use this for components to improve the initial loading time\n\t * and enable code-splitting.\n\t */\n\tlazy?: () => Promise<{ default: FC<TProps & TPropsParent> }>;\n\n\t/**\n\t * Set some children pages and make the page a parent page.\n\t *\n\t * /!\\ Parent page can't be rendered directly. /!\\\n\t *\n\t * If you still want to render at this pathname, add a child page with an empty path.\n\t */\n\tchildren?: Array<PageDescriptor> | (() => Array<PageDescriptor>);\n\n\tparent?: PageDescriptor<PageConfigSchema, TPropsParent>;\n\n\tcan?: () => boolean;\n\n\terrorHandler?: (error: Error) => ReactNode;\n\n\t/**\n\t * If true, the page will be rendered on the build time.\n\t * Works only with viteAlepha plugin.\n\t *\n\t * Replace boolean by an object to define static entries. (e.g. list of params/query)\n\t */\n\tstatic?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tentries?: Array<Partial<PageRequestConfig<TConfig>>>;\n\t\t };\n\n\t/**\n\t * If true, the page will be rendered on the client-side.\n\t */\n\tclient?: boolean | ClientOnlyProps;\n\n\tafterHandler?: (request: ServerRequest) => any;\n\n\tcache?: ServerRouteCache;\n}\n\nexport class PageDescriptor<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {\n\tpublic get name(): string {\n\t\treturn this.options.name ?? this.config.propertyKey;\n\t}\n\n\t/**\n\t * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.\n\t * Only valid for server-side rendering, it will throw an error if called on the client-side.\n\t */\n\tpublic async render(\n\t\toptions?: PageDescriptorRenderOptions,\n\t): Promise<PageDescriptorRenderResult> {\n\t\tthrow new NotImplementedError(\"\");\n\t}\n}\n\n$page[KIND] = PageDescriptor;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface PageConfigSchema {\n\tquery?: TSchema;\n\tparams?: TSchema;\n}\n\nexport type TPropsDefault = any;\n\nexport type TPropsParentDefault = {};\n\nexport interface PageDescriptorRenderOptions {\n\tparams?: Record<string, string>;\n\tquery?: Record<string, string>;\n\thtml?: boolean;\n\thydration?: boolean;\n}\n\nexport interface PageDescriptorRenderResult {\n\thtml: string;\n\tcontext: PageReactContext;\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 & PageReactContext;\n","import {\n\ttype PropsWithChildren,\n\ttype ReactNode,\n\tuseEffect,\n\tuseState,\n} from \"react\";\n\nexport interface ClientOnlyProps {\n\tfallback?: ReactNode;\n\tdisabled?: boolean;\n}\n\n/**\n * A small utility component that renders its children only on the client side.\n *\n * Optionally, you can provide a fallback React node that will be rendered.\n *\n * You should use this component when\n * - you have code that relies on browser-specific APIs\n * - you want to avoid server-side rendering for a specific part of your application\n * - you want to prevent pre-rendering of a component\n */\nconst ClientOnly = (props: PropsWithChildren<ClientOnlyProps>) => {\n\tconst [mounted, setMounted] = useState(false);\n\n\tuseEffect(() => setMounted(true), []);\n\n\tif (props.disabled) {\n\t\treturn props.children;\n\t}\n\n\treturn mounted ? props.children : props.fallback;\n};\n\nexport default ClientOnly;\n","import type { Alepha } from \"@alepha/core\";\nimport { useState } from \"react\";\n\ninterface ErrorViewerProps {\n\terror: Error;\n\talepha: Alepha;\n}\n\n// TODO: design this better\n\nconst ErrorViewer = ({ error, alepha }: ErrorViewerProps) => {\n\tconst [expanded, setExpanded] = useState(false);\n\tconst isProduction = alepha.isProduction();\n\t// const status = isHttpError(error) ? error.status : 500;\n\n\tif (isProduction) {\n\t\treturn <ErrorViewerProduction />;\n\t}\n\n\tconst stackLines = error.stack?.split(\"\\n\") ?? [];\n\tconst previewLines = stackLines.slice(0, 5);\n\tconst hiddenLineCount = stackLines.length - previewLines.length;\n\n\tconst copyToClipboard = (text: string) => {\n\t\tnavigator.clipboard.writeText(text).catch((err) => {\n\t\t\tconsole.error(\"Clipboard error:\", err);\n\t\t});\n\t};\n\n\tconst styles = {\n\t\tcontainer: {\n\t\t\tpadding: \"24px\",\n\t\t\tbackgroundColor: \"#FEF2F2\",\n\t\t\tcolor: \"#7F1D1D\",\n\t\t\tborder: \"1px solid #FECACA\",\n\t\t\tborderRadius: \"16px\",\n\t\t\tboxShadow: \"0 8px 24px rgba(0,0,0,0.05)\",\n\t\t\tfontFamily: \"monospace\",\n\t\t\tmaxWidth: \"768px\",\n\t\t\tmargin: \"40px auto\",\n\t\t},\n\t\theading: {\n\t\t\tfontSize: \"20px\",\n\t\t\tfontWeight: \"bold\",\n\t\t\tmarginBottom: \"4px\",\n\t\t},\n\t\tname: {\n\t\t\tfontSize: \"16px\",\n\t\t\tfontWeight: 600,\n\t\t},\n\t\tmessage: {\n\t\t\tfontSize: \"14px\",\n\t\t\tmarginBottom: \"16px\",\n\t\t},\n\t\tsectionHeader: {\n\t\t\tdisplay: \"flex\",\n\t\t\tjustifyContent: \"space-between\",\n\t\t\talignItems: \"center\",\n\t\t\tfontSize: \"12px\",\n\t\t\tmarginBottom: \"4px\",\n\t\t\tcolor: \"#991B1B\",\n\t\t},\n\t\tcopyButton: {\n\t\t\tfontSize: \"12px\",\n\t\t\tcolor: \"#DC2626\",\n\t\t\tbackground: \"none\",\n\t\t\tborder: \"none\",\n\t\t\tcursor: \"pointer\",\n\t\t\ttextDecoration: \"underline\",\n\t\t},\n\t\tstackContainer: {\n\t\t\tbackgroundColor: \"#FEE2E2\",\n\t\t\tpadding: \"12px\",\n\t\t\tborderRadius: \"8px\",\n\t\t\tfontSize: \"13px\",\n\t\t\tlineHeight: \"1.4\",\n\t\t\toverflowX: \"auto\" as const,\n\t\t\twhiteSpace: \"pre-wrap\" as const,\n\t\t},\n\t\texpandLine: {\n\t\t\tcolor: \"#F87171\",\n\t\t\tcursor: \"pointer\",\n\t\t\tmarginTop: \"8px\",\n\t\t},\n\t};\n\n\treturn (\n\t\t<div style={styles.container}>\n\t\t\t<div>\n\t\t\t\t<div style={styles.heading}>🔥 Error</div>\n\t\t\t\t<div style={styles.name}>{error.name}</div>\n\t\t\t\t<div style={styles.message}>{error.message}</div>\n\t\t\t</div>\n\n\t\t\t{stackLines.length > 0 && (\n\t\t\t\t<div>\n\t\t\t\t\t<div style={styles.sectionHeader}>\n\t\t\t\t\t\t<span>Stack trace</span>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonClick={() => copyToClipboard(error.stack!)}\n\t\t\t\t\t\t\tstyle={styles.copyButton}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tCopy all\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t\t<pre style={styles.stackContainer}>\n\t\t\t\t\t\t{(expanded ? stackLines : previewLines).map((line, i) => (\n\t\t\t\t\t\t\t<div key={i}>{line}</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{!expanded && hiddenLineCount > 0 && (\n\t\t\t\t\t\t\t<div style={styles.expandLine} onClick={() => setExpanded(true)}>\n\t\t\t\t\t\t\t\t+ {hiddenLineCount} more lines...\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</pre>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default ErrorViewer;\n\nconst ErrorViewerProduction = () => {\n\tconst styles = {\n\t\tcontainer: {\n\t\t\tpadding: \"24px\",\n\t\t\tbackgroundColor: \"#FEF2F2\",\n\t\t\tcolor: \"#7F1D1D\",\n\t\t\tborder: \"1px solid #FECACA\",\n\t\t\tborderRadius: \"16px\",\n\t\t\tboxShadow: \"0 8px 24px rgba(0,0,0,0.05)\",\n\t\t\tfontFamily: \"monospace\",\n\t\t\tmaxWidth: \"768px\",\n\t\t\tmargin: \"40px auto\",\n\t\t\ttextAlign: \"center\" as const,\n\t\t},\n\t\theading: {\n\t\t\tfontSize: \"20px\",\n\t\t\tfontWeight: \"bold\",\n\t\t\tmarginBottom: \"8px\",\n\t\t},\n\t\tname: {\n\t\t\tfontSize: \"16px\",\n\t\t\tfontWeight: 600,\n\t\t\tmarginBottom: \"4px\",\n\t\t},\n\t\tmessage: {\n\t\t\tfontSize: \"14px\",\n\t\t\topacity: 0.85,\n\t\t},\n\t};\n\n\treturn (\n\t\t<div style={styles.container}>\n\t\t\t<div style={styles.heading}>🚨 An error occurred</div>\n\t\t\t<div style={styles.message}>\n\t\t\t\tSomething went wrong. Please try again later.\n\t\t\t</div>\n\t\t</div>\n\t);\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 React, {\n\ttype ErrorInfo,\n\ttype PropsWithChildren,\n\ttype ReactNode,\n} from \"react\";\n\n/**\n * Props for the ErrorBoundary component.\n */\nexport interface ErrorBoundaryProps {\n\t/**\n\t * Fallback React node to render when an error is caught.\n\t * If not provided, a default error message will be shown.\n\t */\n\tfallback: (error: Error) => ReactNode;\n\n\t/**\n\t * Optional callback that receives the error and error info.\n\t * Use this to log errors to a monitoring service.\n\t */\n\tonError?: (error: Error, info: ErrorInfo) => void;\n}\n\n/**\n * State of the ErrorBoundary component.\n */\ninterface ErrorBoundaryState {\n\terror?: Error;\n}\n\n/**\n * A reusable error boundary for catching rendering errors\n * in any part of the React component tree.\n */\nexport class ErrorBoundary extends React.Component<\n\tPropsWithChildren<ErrorBoundaryProps>,\n\tErrorBoundaryState\n> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\t\tthis.state = {};\n\t}\n\n\t/**\n\t * Update state so the next render shows the fallback UI.\n\t */\n\tstatic getDerivedStateFromError(error: Error): ErrorBoundaryState {\n\t\treturn {\n\t\t\terror,\n\t\t};\n\t}\n\n\t/**\n\t * Lifecycle method called when an error is caught.\n\t * You can log the error or perform side effects here.\n\t */\n\tcomponentDidCatch(error: Error, info: ErrorInfo): void {\n\t\tif (this.props.onError) {\n\t\t\tthis.props.onError(error, info);\n\t\t}\n\t}\n\n\trender(): ReactNode {\n\t\tif (this.state.error) {\n\t\t\treturn this.props.fallback(this.state.error);\n\t\t}\n\n\t\treturn this.props.children;\n\t}\n}\n\nexport default ErrorBoundary;\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\";\nimport ErrorBoundary from \"./ErrorBoundary.tsx\";\n\nexport interface NestedViewProps {\n\tchildren?: ReactNode;\n}\n\n/**\n * A component that renders the current view of the nested router layer.\n *\n * To be simple, it renders the `element` of the current child page of a parent page.\n *\n * @example\n * ```tsx\n * import { NestedView } from \"@alepha/react\";\n *\n * class App {\n * parent = $page({\n * component: () => <NestedView />,\n * });\n *\n * child = $page({\n * parent: this.root,\n * component: () => <div>Child Page</div>,\n * });\n * }\n * ```\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\tif (!state.layers[index]?.cache) {\n\t\t\t\t\tsetView(state.layers[index]?.element);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t[app],\n\t);\n\n\tif (!app) {\n\t\tthrow new Error(\"NestedView must be used within a RouterContext.\");\n\t}\n\n\tconst element = view ?? props.children ?? null;\n\n\treturn (\n\t\t<ErrorBoundary fallback={app.context.onError!}>{element}</ErrorBoundary>\n\t);\n};\n\nexport default NestedView;\n","export default function NotFoundPage() {\n\treturn (\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\theight: \"100vh\",\n\t\t\t\tdisplay: \"flex\",\n\t\t\t\tflexDirection: \"column\",\n\t\t\t\tjustifyContent: \"center\",\n\t\t\t\talignItems: \"center\",\n\t\t\t\ttextAlign: \"center\",\n\t\t\t\tfontFamily: \"sans-serif\",\n\t\t\t\tpadding: \"1rem\",\n\t\t\t}}\n\t\t>\n\t\t\t<h1 style={{ fontSize: \"1rem\", marginBottom: \"0.5rem\" }}>\n\t\t\t\tThis page does not exist\n\t\t\t</h1>\n\t\t</div>\n\t);\n}\n","import type { HrefLike } from \"../hooks/RouterHookApi.ts\";\n\nexport class RedirectionError extends Error {\n\tpublic readonly page: HrefLike;\n\n\tconstructor(page: HrefLike) {\n\t\tsuper(\"Redirection\");\n\t\tthis.page = page;\n\t}\n}\n","import {\n\t$env,\n\t$hook,\n\t$inject,\n\t$logger,\n\tAlepha,\n\ttype Static,\n\tt,\n} from \"@alepha/core\";\nimport type { ApiLinksResponse } from \"@alepha/server\";\nimport { createElement, type ReactNode, StrictMode } from \"react\";\nimport ClientOnly from \"../components/ClientOnly.tsx\";\nimport ErrorViewer from \"../components/ErrorViewer.tsx\";\nimport NestedView from \"../components/NestedView.tsx\";\nimport NotFoundPage from \"../components/NotFound.tsx\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport {\n\t$page,\n\ttype PageDescriptor,\n\ttype PageDescriptorOptions,\n} from \"../descriptors/$page.ts\";\nimport { RedirectionError } from \"../errors/RedirectionError.ts\";\n\nconst envSchema = t.object({\n\tREACT_STRICT_MODE: t.boolean({ default: true }),\n});\n\ndeclare module \"@alepha/core\" {\n\texport interface Env extends Partial<Static<typeof envSchema>> {}\n}\n\nexport class PageDescriptorProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly env = $env(envSchema);\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 url(\n\t\tname: string,\n\t\toptions: { params?: Record<string, string>; base?: string } = {},\n\t): URL {\n\t\tconst page = this.page(name);\n\t\tif (!page) {\n\t\t\tthrow new Error(`Page ${name} not found`);\n\t\t}\n\n\t\tlet url = page.path ?? \"\";\n\t\tlet parent = page.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, options.params ?? {});\n\n\t\treturn new URL(\n\t\t\turl.replace(/\\/\\/+/g, \"/\") || \"/\",\n\t\t\toptions.base ?? `http://localhost`,\n\t\t);\n\t}\n\n\tpublic root(state: RouterState, context: PageReactContext): ReactNode {\n\t\tconst root = 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\n\t\tif (this.env.REACT_STRICT_MODE) {\n\t\t\treturn createElement(StrictMode, {}, root);\n\t\t}\n\n\t\treturn root;\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\t\trequest.onError = (error) => this.renderError(error); // error handler\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: {};\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: {};\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// 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\tit.cache = true;\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\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\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\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\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\tacc += \"/\";\n\t\t\tacc += it.route.path ? this.compile(it.route.path, params) : \"\";\n\t\t\tconst path = acc.replace(/\\/+/, \"/\");\n\t\t\tconst localErrorHandler = this.getErrorHandler(it.route);\n\t\t\tif (localErrorHandler) {\n\t\t\t\trequest.onError = localErrorHandler;\n\t\t\t}\n\n\t\t\t// handler has thrown an error, render an error view\n\t\t\tif (it.error) {\n\t\t\t\tlet element: ReactNode = await request.onError(it.error);\n\t\t\t\tif (element === null) {\n\t\t\t\t\telement = this.renderError(it.error);\n\t\t\t\t}\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, it.route),\n\t\t\t\t\tindex: i + 1,\n\t\t\t\t\tpath,\n\t\t\t\t\troute: it.route,\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 element = 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, element, it.route),\n\t\t\t\tindex: i + 1,\n\t\t\t\tpath,\n\t\t\t\troute: it.route,\n\t\t\t\tcache: it.cache,\n\t\t\t});\n\t\t}\n\n\t\treturn { layers, 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\tpublic renderError(error: Error): ReactNode {\n\t\treturn createElement(ErrorViewer, { error, alepha: this.alepha });\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 | undefined,\n\t\tpage: PageRoute,\n\t): ReactNode {\n\t\tview ??= this.renderEmptyView();\n\n\t\tconst element = page.client\n\t\t\t? createElement(\n\t\t\t\t\tClientOnly,\n\t\t\t\t\ttypeof page.client === \"object\" ? page.client : {},\n\t\t\t\t\tview,\n\t\t\t\t)\n\t\t\t: view;\n\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\telement,\n\t\t);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\ton: \"configure\",\n\t\thandler: () => {\n\t\t\tlet hasNotFoundHandler = false;\n\t\t\tconst pages = this.alepha.descriptors($page);\n\n\t\t\tconst hasParent = (it: PageDescriptor) => {\n\t\t\t\tfor (const page of pages) {\n\t\t\t\t\tconst children = page.options.children\n\t\t\t\t\t\t? Array.isArray(page.options.children)\n\t\t\t\t\t\t\t? page.options.children\n\t\t\t\t\t\t\t: page.options.children()\n\t\t\t\t\t\t: [];\n\t\t\t\t\tif (children.includes(it)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfor (const page of pages) {\n\t\t\t\tif (page.options.path === \"/*\") {\n\t\t\t\t\thasNotFoundHandler = true;\n\t\t\t\t}\n\n\t\t\t\t// skip children, we only want root pages\n\t\t\t\tif (hasParent(page)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.add(this.map(pages, page));\n\t\t\t}\n\n\t\t\tif (!hasNotFoundHandler && pages.length > 0) {\n\t\t\t\t// add a default 404 page if not already defined\n\t\t\t\tthis.add({\n\t\t\t\t\tpath: \"/*\",\n\t\t\t\t\tname: \"notFound\",\n\t\t\t\t\tcache: true,\n\t\t\t\t\tcomponent: NotFoundPage,\n\t\t\t\t\tafterHandler: ({ reply }) => {\n\t\t\t\t\t\treply.status = 404;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t});\n\n\tprotected map(\n\t\tpages: Array<PageDescriptor>,\n\t\ttarget: PageDescriptor,\n\t): PageRouteEntry {\n\t\tconst children = target.options.children\n\t\t\t? Array.isArray(target.options.children)\n\t\t\t\t? target.options.children\n\t\t\t\t: target.options.children()\n\t\t\t: [];\n\n\t\treturn {\n\t\t\t...target.options,\n\t\t\tname: target.name,\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\troute?: PageRoute;\n\tcache?: boolean;\n}\n\nexport type PreviousLayerData = Omit<Layer, \"element\" | \"index\" | \"path\">;\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}\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\tcache?: boolean;\n}\n\nexport interface RouterRenderResult {\n\tstate: RouterState;\n\tcontext: PageReactContext;\n\tredirect?: string;\n}\n\nexport interface PageRequest extends PageReactContext {\n\tparams: Record<string, any>;\n\tquery: Record<string, string>;\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/**\n * It's like RouterState, but publicly available in React context.\n * This is where we store all plugin data!\n */\nexport interface PageReactContext {\n\turl: URL;\n\tonError: (error: Error) => ReactNode;\n\tlinks?: ApiLinksResponse;\n}\n","import { $hook, $inject, $logger, Alepha } from \"@alepha/core\";\nimport { type Route, RouterProvider } from \"@alepha/router\";\nimport { createElement, type ReactNode } from \"react\";\nimport NotFoundPage from \"../components/NotFound.tsx\";\nimport {\n\tisPageRoute,\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype PageRoute,\n\ttype PageRouteEntry,\n\ttype RouterRenderResult,\n\ttype RouterState,\n\ttype TransitionOptions,\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\ton: \"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};\n\n\t\tconst context = {\n\t\t\turl,\n\t\t\tquery: {},\n\t\t\tparams: {},\n\t\t\tonError: () => null,\n\t\t\t...(options.context ?? {}),\n\t\t} as PageRequest;\n\n\t\tawait this.alepha.emit(\"react:transition:begin\", { state, context });\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\tcontext.query = query;\n\t\t\tcontext.params = params ?? {};\n\t\t\tcontext.previous = previous;\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\tcontext,\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\tredirect: result.redirect,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstate.layers = result.layers;\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: createElement(NotFoundPage),\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, context });\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\tcontext,\n\t\t\t});\n\t\t}\n\n\t\tif (options.state) {\n\t\t\toptions.state.layers = state.layers;\n\t\t\toptions.state.pathname = state.pathname;\n\t\t\toptions.state.search = state.search;\n\t\t}\n\n\t\tawait this.alepha.emit(\"react:transition:end\", {\n\t\t\tstate: options.state,\n\t\t\tcontext,\n\t\t});\n\n\t\treturn {\n\t\t\tcontext,\n\t\t\tstate,\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 } from \"@alepha/core\";\nimport type { ApiLinksResponse } from \"@alepha/server\";\nimport { LinkProvider } from \"@alepha/server-links\";\nimport type { Root } from \"react-dom/client\";\nimport { BrowserRouterProvider } from \"./BrowserRouterProvider.ts\";\nimport type {\n\tPreviousLayerData,\n\tRouterRenderResult,\n\tRouterState,\n\tTransitionOptions,\n} from \"./PageDescriptorProvider.ts\";\n\nexport class ReactBrowserProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly client = $inject(LinkProvider);\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly router = $inject(BrowserRouterProvider);\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};\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 location() {\n\t\treturn window.location;\n\t}\n\n\tpublic get url(): string {\n\t\tlet url = this.location.pathname + this.location.search;\n\n\t\tif (import.meta?.env?.BASE_URL) {\n\t\t\turl = url.replace(import.meta.env?.BASE_URL, \"\");\n\t\t\tif (!url.startsWith(\"/\")) {\n\t\t\t\turl = `/${url}`;\n\t\t\t}\n\t\t}\n\n\t\treturn url;\n\t}\n\n\tpublic pushState(url: string, replace?: boolean) {\n\t\tlet path = url;\n\n\t\tif (import.meta?.env?.BASE_URL) {\n\t\t\tpath = (import.meta.env?.BASE_URL + path).replaceAll(\"//\", \"/\");\n\t\t}\n\n\t\tif (replace) {\n\t\t\tthis.history.replaceState({}, \"\", path);\n\t\t} else {\n\t\t\tthis.history.pushState({}, \"\", path);\n\t\t}\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\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\t// when redirecting in browser\n\t\tif (result.context.url.pathname !== url) {\n\t\t\t// TODO: check if losing search params is acceptable?\n\t\t\tthis.pushState(result.context.url.pathname);\n\t\t\treturn;\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tthis.pushState(url);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pushState(url);\n\t}\n\n\tprotected async render(\n\t\toptions: { url?: string; previous?: PreviousLayerData[] } = {},\n\t): Promise<RouterRenderResult> {\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 result;\n\t}\n\n\t/**\n\t * Get embedded layers from the server.\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\n\tpublic readonly ready = $hook({\n\t\ton: \"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\tfor (const link of hydration.links.links) {\n\t\t\t\t\tthis.client.pushLink(link);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { context } = await this.render({ previous });\n\n\t\t\tawait this.alepha.emit(\"react:browser:render\", {\n\t\t\t\tstate: this.state,\n\t\t\t\tcontext,\n\t\t\t\thydration,\n\t\t\t});\n\n\t\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\t\t// when you update silently queryparams or hash, skip rendering\n\t\t\t\t// if you want to force a rendering, use #go()\n\t\t\t\tif (this.state.pathname === this.url) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.render();\n\t\t\t});\n\t\t},\n\t});\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface RouterGoOptions {\n\treplace?: boolean;\n\tmatch?: TransitionOptions;\n\tparams?: Record<string, string>;\n}\n\nexport interface ReactHydrationState {\n\tlayers?: Array<PreviousLayerData>;\n\tlinks?: ApiLinksResponse;\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n\t$env,\n\t$hook,\n\t$inject,\n\t$logger,\n\tAlepha,\n\ttype Static,\n\tt,\n} from \"@alepha/core\";\nimport {\n\tapiLinksResponseSchema,\n\ttype ServerHandler,\n\tServerRouterProvider,\n\tServerTimingProvider,\n} from \"@alepha/server\";\nimport { ServerLinksProvider } from \"@alepha/server-links\";\nimport { ServerStaticProvider } from \"@alepha/server-static\";\nimport { renderToString } from \"react-dom/server\";\nimport {\n\t$page,\n\ttype PageDescriptorRenderOptions,\n} from \"../descriptors/$page.ts\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype PageRoute,\n\ttype RouterState,\n} from \"./PageDescriptorProvider.ts\";\nimport type { ReactHydrationState } from \"./ReactBrowserProvider.ts\";\n\nconst envSchema = t.object({\n\tREACT_SERVER_DIST: t.string({ default: \"public\" }),\n\tREACT_SERVER_PREFIX: t.string({ default: \"\" }),\n\tREACT_SSR_ENABLED: t.optional(t.boolean()),\n\tREACT_ROOT_ID: t.string({ default: \"root\" }),\n\tREACT_SERVER_TEMPLATE: t.optional(\n\t\tt.string({\n\t\t\tsize: \"rich\",\n\t\t}),\n\t),\n});\n\ndeclare module \"@alepha/core\" {\n\tinterface Env extends Partial<Static<typeof envSchema>> {}\n\tinterface State {\n\t\t\"react.server.ssr\"?: boolean;\n\t}\n}\n\nexport class ReactServerProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pageDescriptorProvider = $inject(PageDescriptorProvider);\n\tprotected readonly serverStaticProvider = $inject(ServerStaticProvider);\n\tprotected readonly serverRouterProvider = $inject(ServerRouterProvider);\n\tprotected readonly serverTimingProvider = $inject(ServerTimingProvider);\n\tprotected readonly env = $env(envSchema);\n\tprotected readonly ROOT_DIV_REGEX = new RegExp(\n\t\t`<div([^>]*)\\\\s+id=[\"']${this.env.REACT_ROOT_ID}[\"']([^>]*)>(.*?)<\\\\/div>`,\n\t\t\"is\",\n\t);\n\n\tpublic readonly onConfigure = $hook({\n\t\ton: \"configure\",\n\t\thandler: async () => {\n\t\t\tconst pages = this.alepha.descriptors($page);\n\n\t\t\tconst ssrEnabled =\n\t\t\t\tpages.length > 0 && this.env.REACT_SSR_ENABLED !== false;\n\n\t\t\tthis.alepha.state(\"react.server.ssr\", ssrEnabled);\n\n\t\t\tfor (const page of pages) {\n\t\t\t\tpage.render = this.createRenderFunction(page.name);\n\t\t\t}\n\n\t\t\t// development mode\n\t\t\tif (this.alepha.isServerless() === \"vite\") {\n\t\t\t\tawait this.configureVite(ssrEnabled);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// production mode\n\t\t\tlet root = \"\";\n\n\t\t\t// non-serverless mode only -> serve static files\n\t\t\tif (!this.alepha.isServerless()) {\n\t\t\t\troot = this.getPublicDirectory();\n\t\t\t\tif (!root) {\n\t\t\t\t\tthis.log.warn(\n\t\t\t\t\t\t\"Missing static files, static file server will be disabled\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.log.debug(`Using static files from: ${root}`);\n\t\t\t\t\tawait this.configureStaticServer(root);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ssrEnabled) {\n\t\t\t\tawait this.registerPages(async () => this.template);\n\t\t\t\tthis.log.info(\"SSR OK\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// no SSR enabled, serve index.html for all unmatched routes\n\t\t\tthis.log.info(\"SSR is disabled, use History API fallback\");\n\t\t\tthis.serverRouterProvider.createRoute({\n\t\t\t\tpath: \"*\",\n\t\t\t\thandler: async ({ url, reply }) => {\n\t\t\t\t\tif (url.pathname.includes(\".\")) {\n\t\t\t\t\t\t// If the request is for a file (e.g., /style.css), do not fallback\n\t\t\t\t\t\treply.headers[\"content-type\"] = \"text/plain\";\n\t\t\t\t\t\treply.body = \"Not Found\";\n\t\t\t\t\t\treply.status = 404;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\treply.headers[\"content-type\"] = \"text/html\";\n\n\t\t\t\t\t// serve index.html for all unmatched routes\n\t\t\t\t\treturn this.template;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tpublic get template() {\n\t\treturn (\n\t\t\tthis.alepha.env.REACT_SERVER_TEMPLATE ??\n\t\t\t\"<!DOCTYPE html><html lang='en'><head></head><body></body></html>\"\n\t\t);\n\t}\n\n\tprotected async registerPages(templateLoader: TemplateLoader) {\n\t\tfor (const page of this.pageDescriptorProvider.getPages()) {\n\t\t\tif (page.children?.length) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.log.debug(`+ ${page.match} -> ${page.name}`);\n\n\t\t\tthis.serverRouterProvider.createRoute({\n\t\t\t\t...page,\n\t\t\t\tschema: undefined, // schema is handled by the page descriptor provider for now (shared by browser and server)\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: page.match,\n\t\t\t\thandler: this.createHandler(page, templateLoader),\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected getPublicDirectory(): string {\n\t\tconst maybe = [\n\t\t\tjoin(process.cwd(), `dist/${this.env.REACT_SERVER_DIST}`),\n\t\t\tjoin(process.cwd(), this.env.REACT_SERVER_DIST),\n\t\t];\n\n\t\tfor (const it of maybe) {\n\t\t\tif (existsSync(it)) {\n\t\t\t\treturn it;\n\t\t\t}\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\tprotected async configureStaticServer(root: string) {\n\t\tawait this.serverStaticProvider.createStaticServer({\n\t\t\troot,\n\t\t\tpath: this.env.REACT_SERVER_PREFIX,\n\t\t});\n\t}\n\n\tprotected async configureVite(ssrEnabled: boolean) {\n\t\tif (!ssrEnabled) {\n\t\t\t// do nothing, vite will handle everything for us\n\t\t\treturn;\n\t\t}\n\n\t\tthis.log.info(\"SSR (vite) OK\");\n\n\t\tconst url = `http://${process.env.SERVER_HOST}:${process.env.SERVER_PORT}`;\n\n\t\tawait this.registerPages(() =>\n\t\t\tfetch(`${url}/index.html`)\n\t\t\t\t.then((it) => it.text())\n\t\t\t\t.catch(() => undefined),\n\t\t);\n\t}\n\n\t/**\n\t * For testing purposes, creates a render function that can be used.\n\t */\n\tprotected createRenderFunction(name: string, withIndex = false) {\n\t\treturn async (options: PageDescriptorRenderOptions = {}) => {\n\t\t\tconst page = this.pageDescriptorProvider.page(name);\n\t\t\tconst url = new URL(this.pageDescriptorProvider.url(name, options));\n\t\t\tconst context: PageRequest = {\n\t\t\t\turl,\n\t\t\t\tparams: options.params ?? {},\n\t\t\t\tquery: options.query ?? {},\n\t\t\t\thead: {},\n\t\t\t\tonError: () => null,\n\t\t\t};\n\n\t\t\tawait this.alepha.emit(\"react:server:render:begin\", {\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\tconst state = await this.pageDescriptorProvider.createLayers(\n\t\t\t\tpage,\n\t\t\t\tcontext,\n\t\t\t);\n\n\t\t\tif (!withIndex && !options.html) {\n\t\t\t\treturn {\n\t\t\t\t\tcontext,\n\t\t\t\t\thtml: renderToString(\n\t\t\t\t\t\tthis.pageDescriptorProvider.root(state, context),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst html = this.renderToHtml(\n\t\t\t\tthis.template ?? \"\",\n\t\t\t\tstate,\n\t\t\t\tcontext,\n\t\t\t\toptions.hydration,\n\t\t\t);\n\n\t\t\tconst result = {\n\t\t\t\tcontext,\n\t\t\t\tstate,\n\t\t\t\thtml,\n\t\t\t};\n\n\t\t\tawait this.alepha.emit(\"react:server:render:end\", result);\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tprotected createHandler(\n\t\tpage: PageRoute,\n\t\ttemplateLoader: TemplateLoader,\n\t): ServerHandler {\n\t\treturn async (serverRequest) => {\n\t\t\tconst { url, reply, query, params } = serverRequest;\n\t\t\tconst template = await templateLoader();\n\t\t\tif (!template) {\n\t\t\t\tthrow new Error(\"Template not found\");\n\t\t\t}\n\n\t\t\tconst context: PageRequest = {\n\t\t\t\turl,\n\t\t\t\tparams,\n\t\t\t\tquery,\n\t\t\t\t// plugins\n\t\t\t\thead: {},\n\t\t\t\tonError: () => null,\n\t\t\t};\n\n\t\t\tif (this.alepha.has(ServerLinksProvider)) {\n\t\t\t\tconst srv = this.alepha.inject(ServerLinksProvider);\n\t\t\t\tconst schema = apiLinksResponseSchema as any;\n\n\t\t\t\tcontext.links = this.alepha.parse(\n\t\t\t\t\tschema,\n\t\t\t\t\tawait srv.getLinks({\n\t\t\t\t\t\tuser: serverRequest.user,\n\t\t\t\t\t\tauthorization: serverRequest.headers.authorization,\n\t\t\t\t\t}),\n\t\t\t\t) as any;\n\n\t\t\t\tthis.alepha.context.set(\"links\", context.links);\n\t\t\t}\n\n\t\t\tlet target: PageRoute | undefined = page; // TODO: move to PageDescriptorProvider\n\t\t\twhile (target) {\n\t\t\t\tif (page.can && !page.can()) {\n\t\t\t\t\t// if the page is not accessible, return 403\n\t\t\t\t\treply.status = 403;\n\t\t\t\t\treply.headers[\"content-type\"] = \"text/plain\";\n\t\t\t\t\treturn \"Forbidden\";\n\t\t\t\t}\n\t\t\t\ttarget = target.parent;\n\t\t\t}\n\n\t\t\t// TODO: SSR strategies\n\t\t\t// - only when googlebot\n\t\t\t// - only child pages\n\t\t\t// if (page.client) {\n\t\t\t// \t// if the page is a client-only page, return 404\n\t\t\t// \treply.status = 200;\n\t\t\t// \treply.headers[\"content-type\"] = \"text/html\";\n\t\t\t// \treply.body = template;\n\t\t\t// \treturn;\n\t\t\t// }\n\n\t\t\tawait this.alepha.emit(\"react:server:render:begin\", {\n\t\t\t\trequest: serverRequest,\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\tthis.serverTimingProvider.beginTiming(\"createLayers\");\n\n\t\t\tconst state = await this.pageDescriptorProvider.createLayers(\n\t\t\t\tpage,\n\t\t\t\tcontext,\n\t\t\t);\n\n\t\t\tthis.serverTimingProvider.endTiming(\"createLayers\");\n\n\t\t\tif (state.redirect) {\n\t\t\t\treturn reply.redirect(state.redirect);\n\t\t\t}\n\n\t\t\treply.headers[\"content-type\"] = \"text/html\";\n\n\t\t\t// by default, disable caching for SSR responses\n\t\t\t// some plugins may override this\n\t\t\treply.headers[\"cache-control\"] =\n\t\t\t\t\"no-store, no-cache, must-revalidate, proxy-revalidate\";\n\t\t\treply.headers.pragma = \"no-cache\";\n\t\t\treply.headers.expires = \"0\";\n\n\t\t\t// don't cache user links\n\t\t\tif (page.cache && serverRequest.user) {\n\t\t\t\tdelete context.links;\n\t\t\t}\n\n\t\t\tconst html = this.renderToHtml(template, state, context);\n\n\t\t\tawait this.alepha.emit(\"react:server:render:end\", {\n\t\t\t\trequest: serverRequest,\n\t\t\t\tcontext,\n\t\t\t\tstate,\n\t\t\t\thtml,\n\t\t\t});\n\n\t\t\tpage.afterHandler?.(serverRequest);\n\n\t\t\treturn html;\n\t\t};\n\t}\n\n\tpublic renderToHtml(\n\t\ttemplate: string,\n\t\tstate: RouterState,\n\t\tcontext: PageReactContext,\n\t\thydration = true,\n\t) {\n\t\tconst element = this.pageDescriptorProvider.root(state, context);\n\n\t\tthis.serverTimingProvider.beginTiming(\"renderToString\");\n\n\t\tlet app = \"\";\n\t\ttry {\n\t\t\tapp = renderToString(element);\n\t\t} catch (error) {\n\t\t\tthis.log.error(\"Error during SSR\", error);\n\t\t\tapp = renderToString(context.onError(error as Error));\n\t\t}\n\n\t\tthis.serverTimingProvider.endTiming(\"renderToString\");\n\n\t\tconst response = {\n\t\t\thtml: template,\n\t\t};\n\n\t\tif (hydration) {\n\t\t\tconst hydrationData: ReactHydrationState = {\n\t\t\t\tlinks: context.links,\n\t\t\t\tlayers: state.layers.map((it) => ({\n\t\t\t\t\t...it,\n\t\t\t\t\terror: it.error\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...it.error,\n\t\t\t\t\t\t\t\tname: it.error.name,\n\t\t\t\t\t\t\t\tmessage: it.error.message,\n\t\t\t\t\t\t\t\tstack: it.error.stack, // TODO: Hide stack in production ?\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tindex: undefined,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t\telement: undefined,\n\t\t\t\t\troute: undefined,\n\t\t\t\t})),\n\t\t\t};\n\n\t\t\t// create hydration data\n\t\t\tconst script = `<script>window.__ssr=${JSON.stringify(hydrationData)}</script>`;\n\n\t\t\t// inject app into template\n\t\t\tthis.fillTemplate(response, app, script);\n\t\t}\n\n\t\treturn response.html;\n\t}\n\n\tprotected fillTemplate(\n\t\tresponse: { html: string },\n\t\tapp: string,\n\t\tscript: string,\n\t) {\n\t\tif (this.ROOT_DIV_REGEX.test(response.html)) {\n\t\t\t// replace contents of the existing <div id=\"root\">\n\t\t\tresponse.html = response.html.replace(\n\t\t\t\tthis.ROOT_DIV_REGEX,\n\t\t\t\t(_match, beforeId, afterId) => {\n\t\t\t\t\treturn `<div${beforeId} id=\"${this.env.REACT_ROOT_ID}\"${afterId}>${app}</div>`;\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tconst bodyOpenTag = /<body([^>]*)>/i;\n\t\t\tif (bodyOpenTag.test(response.html)) {\n\t\t\t\tresponse.html = response.html.replace(bodyOpenTag, (match) => {\n\t\t\t\t\treturn `${match}\\n<div id=\"${this.env.REACT_ROOT_ID}\">${app}</div>`;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst bodyCloseTagRegex = /<\\/body>/i;\n\t\tif (bodyCloseTagRegex.test(response.html)) {\n\t\t\tresponse.html = response.html.replace(\n\t\t\t\tbodyCloseTagRegex,\n\t\t\t\t`${script}\\n</body>`,\n\t\t\t);\n\t\t}\n\t}\n}\n\ntype TemplateLoader = () => Promise<string | undefined>;\n","import type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport type {\n\tAnchorProps,\n\tPageReactContext,\n\tPageRoute,\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 pages: PageRoute[],\n\t\tprivate readonly context: PageReactContext,\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\tpublic getURL(): URL {\n\t\tif (!this.browser) {\n\t\t\treturn this.context.url;\n\t\t}\n\t\treturn new URL(this.location.href);\n\t}\n\n\tpublic get location(): Location {\n\t\tif (!this.browser) {\n\t\t\tthrow new Error(\"Browser is required\");\n\t\t}\n\n\t\treturn this.browser.location;\n\t}\n\n\tpublic get current(): RouterState {\n\t\treturn this.state;\n\t}\n\n\tpublic get pathname(): string {\n\t\treturn this.state.pathname;\n\t}\n\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\tpublic async back() {\n\t\tthis.browser?.history.back();\n\t}\n\n\tpublic async forward() {\n\t\tthis.browser?.history.forward();\n\t}\n\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(\n\t\tpathname: HrefLike,\n\t\tlayer: { path: string } = this.layer,\n\t\toptions: { params?: Record<string, any> } = {},\n\t) {\n\t\tif (typeof pathname === \"object\") {\n\t\t\tpathname = pathname.options.path ?? \"\";\n\t\t}\n\n\t\tif (options.params) {\n\t\t\tfor (const [key, value] of Object.entries(options.params)) {\n\t\t\t\tpathname = pathname.replace(`:${key}`, String(value));\n\t\t\t}\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\tpublic async go(path: string, options?: RouterGoOptions): Promise<void>;\n\tpublic async go<T extends object>(\n\t\tpath: keyof VirtualRouter<T>,\n\t\toptions?: RouterGoOptions,\n\t): Promise<void>;\n\tpublic async go(path: string, options?: RouterGoOptions): Promise<void> {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === path) {\n\t\t\t\tpath = page.path ?? \"\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tawait this.browser?.go(this.createHref(path, this.layer, options), options);\n\t}\n\n\tpublic anchor(\n\t\tpath: string,\n\t\toptions?: { params?: Record<string, any> },\n\t): AnchorProps;\n\tpublic anchor<T extends object>(\n\t\tpath: keyof VirtualRouter<T>,\n\t\toptions?: { params?: Record<string, any> },\n\t): AnchorProps;\n\tpublic anchor(\n\t\tpath: string,\n\t\toptions: { params?: Record<string, any> } = {},\n\t): AnchorProps {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === path) {\n\t\t\t\tpath = page.path ?? \"\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst href = this.createHref(path, this.layer, options);\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, options).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:\n\t\t\t| Record<string, any>\n\t\t\t| ((queryParams: Record<string, any>) => Record<string, any>),\n\t\toptions: {\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 func = typeof record === \"function\" ? record : () => record;\n\t\tconst search = new URLSearchParams(func(this.query)).toString();\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\nexport type VirtualRouter<T> = {\n\t[K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K];\n};\n","import { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport { PageDescriptorProvider } from \"../providers/PageDescriptorProvider.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\tconst pages = useMemo(() => {\n\t\treturn ctx.alepha.inject(PageDescriptorProvider).getPages();\n\t}, []);\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tnew RouterHookApi(\n\t\t\t\tpages,\n\t\t\t\tctx.context,\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.inject(ReactBrowserProvider)\n\t\t\t\t\t: undefined,\n\t\t\t),\n\t\t[layer],\n\t);\n};\n","import type { AnchorHTMLAttributes } from \"react\";\nimport React from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport { useRouter } from \"../hooks/useRouter.ts\";\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 router = useRouter();\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 = typeof props.to === \"string\" ? undefined : props.to.options.name;\n\n\tconst anchorProps = {\n\t\t...props,\n\t\tto: undefined,\n\t};\n\n\treturn (\n\t\t<a {...router.anchor(to)} {...anchorProps}>\n\t\t\t{props.children ?? name}\n\t\t</a>\n\t);\n};\n\nexport default Link;\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","import type { Alepha } from \"@alepha/core\";\nimport { useContext } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useAlepha = (): Alepha => {\n\tconst routerContext = useContext(RouterContext);\n\tif (!routerContext) {\n\t\tthrow new Error(\"useAlepha must be used within a RouterProvider\");\n\t}\n\n\treturn routerContext.alepha;\n};\n","import type { Service } from \"@alepha/core\";\nimport { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useInject = <T extends object>(clazz: Service<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(() => ctx.alepha.inject(clazz), []);\n};\n","import {\n\ttype ClientScope,\n\ttype HttpVirtualClient,\n\tLinkProvider,\n} from \"@alepha/server-links\";\nimport { useInject } from \"./useInject.ts\";\n\nexport const useClient = <T extends object>(\n\t_scope?: ClientScope,\n): HttpVirtualClient<T> => {\n\treturn useInject(LinkProvider).client<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((data) => {\n\t\t\t\treturn { ...data, [key]: encode(ctx.alepha, schema, queryParams) };\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 { $module } from \"@alepha/core\";\nimport { AlephaServer, type ServerRequest } from \"@alepha/server\";\nimport { AlephaServerCache } from \"@alepha/server-cache\";\nimport { AlephaServerLinks } from \"@alepha/server-links\";\nimport { $page } from \"./descriptors/$page.ts\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype RouterState,\n} from \"./providers/PageDescriptorProvider.ts\";\nimport {\n\tReactBrowserProvider,\n\ttype ReactHydrationState,\n} from \"./providers/ReactBrowserProvider.ts\";\nimport { ReactServerProvider } from \"./providers/ReactServerProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./index.shared.ts\";\nexport * from \"./providers/PageDescriptorProvider.ts\";\nexport * from \"./providers/ReactBrowserProvider.ts\";\nexport * from \"./providers/ReactServerProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\ndeclare module \"@alepha/core\" {\n\tinterface Hooks {\n\t\t\"react:router:createLayers\": {\n\t\t\trequest: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t\tlayers: PageRequest[];\n\t\t};\n\t\t\"react:server:render:begin\": {\n\t\t\trequest?: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t};\n\t\t\"react:server:render:end\": {\n\t\t\trequest?: ServerRequest;\n\t\t\tcontext: PageRequest;\n\t\t\tstate: RouterState;\n\t\t\thtml: string;\n\t\t};\n\t\t\"react:browser:render\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t\thydration?: ReactHydrationState;\n\t\t};\n\t\t\"react:transition:begin\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:success\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:error\": {\n\t\t\terror: Error;\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t\t\"react:transition:end\": {\n\t\t\tstate: RouterState;\n\t\t\tcontext: PageReactContext;\n\t\t};\n\t}\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.\n *\n * The React module enables building modern React applications using the `$page` descriptor on class properties.\n * It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full\n * type safety and schema validation for route parameters and data.\n *\n * @see {@link $page}\n * @module alepha.react\n */\nexport const AlephaReact = $module({\n\tname: \"alepha.react\",\n\tdescriptors: [$page],\n\tservices: [ReactServerProvider, PageDescriptorProvider, ReactBrowserProvider],\n\tregister: (alepha) =>\n\t\talepha\n\t\t\t.with(AlephaServer)\n\t\t\t.with(AlephaServerCache)\n\t\t\t.with(AlephaServerLinks)\n\t\t\t.with(ReactServerProvider)\n\t\t\t.with(PageDescriptorProvider),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,QAAQ,CAKpBA,YACmD;AACnD,QAAO,oCACN,gBACA,QACA;AACD;AA0GD,IAAa,iBAAb,cAIUC,yBAAiE;CAC1E,IAAW,OA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5C,MAAK,QAAQ,MACZ,OAAM,IAAI,MAAM;CAGjB,MAAM,CAAC,OAAO,SAAS,GAAG,oBAAS,IAAI,MAAM;AAE7C,iBAAgB,EACf,OAAO,CAAC,EAAE,gBAAO,KAAK,SAAS,EAAE,GAAGC,QAAO,EAAC,CAC5C,EAAC;AAEF,QAAO;AACP;;;;;;;;;;;;;;AC4DD,MAAa,cAAc,2BAAQ;CAClC,MAAM;CACN,aAAa,CAAC,KAAM;CACpB,UAAU;EAAC;EAAqB;EAAwB;CAAqB;CAC7E,UAAU,CAAC,WACV,OACE,KAAKC,6BAAa,CAClB,KAAKC,wCAAkB,CACvB,KAAKC,wCAAkB,CACvB,KAAK,oBAAoB,CACzB,KAAK,uBAAuB;AAC/B,EAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _alepha_core8 from "@alepha/core";
|
|
2
|
-
import * as _alepha_core14 from "@alepha/core";
|
|
3
1
|
import * as _alepha_core12 from "@alepha/core";
|
|
2
|
+
import * as _alepha_core16 from "@alepha/core";
|
|
3
|
+
import * as _alepha_core10 from "@alepha/core";
|
|
4
4
|
import * as _alepha_core0$1 from "@alepha/core";
|
|
5
5
|
import * as _alepha_core0 from "@alepha/core";
|
|
6
6
|
import { Alepha, Async, Descriptor, KIND, Service, Static, TObject, TSchema } from "@alepha/core";
|
|
@@ -13,8 +13,8 @@ import { ClientScope, HttpVirtualClient, LinkProvider } from "@alepha/server-lin
|
|
|
13
13
|
import { Root } from "react-dom/client";
|
|
14
14
|
import { Route, RouterProvider } from "@alepha/router";
|
|
15
15
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
16
|
-
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
17
16
|
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
17
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
18
18
|
import { ServerStaticProvider } from "@alepha/server-static";
|
|
19
19
|
|
|
20
20
|
//#region src/components/ClientOnly.d.ts
|
|
@@ -157,14 +157,14 @@ type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsPare
|
|
|
157
157
|
//# sourceMappingURL=$page.d.ts.map
|
|
158
158
|
//#endregion
|
|
159
159
|
//#region src/providers/PageDescriptorProvider.d.ts
|
|
160
|
-
declare const envSchema$1:
|
|
161
|
-
REACT_STRICT_MODE:
|
|
160
|
+
declare const envSchema$1: _alepha_core12.TObject<{
|
|
161
|
+
REACT_STRICT_MODE: _alepha_core12.TBoolean;
|
|
162
162
|
}>;
|
|
163
163
|
declare module "@alepha/core" {
|
|
164
164
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
165
165
|
}
|
|
166
166
|
declare class PageDescriptorProvider {
|
|
167
|
-
protected readonly log:
|
|
167
|
+
protected readonly log: _alepha_core12.Logger;
|
|
168
168
|
protected readonly env: {
|
|
169
169
|
REACT_STRICT_MODE: boolean;
|
|
170
170
|
};
|
|
@@ -189,7 +189,7 @@ declare class PageDescriptorProvider {
|
|
|
189
189
|
}, params?: Record<string, any>): string;
|
|
190
190
|
compile(path: string, params?: Record<string, string>): string;
|
|
191
191
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
192
|
-
protected readonly configure:
|
|
192
|
+
protected readonly configure: _alepha_core12.HookDescriptor<"configure">;
|
|
193
193
|
protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
|
|
194
194
|
add(entry: PageRouteEntry): void;
|
|
195
195
|
protected createMatch(page: PageRoute): string;
|
|
@@ -272,11 +272,11 @@ interface BrowserRoute extends Route {
|
|
|
272
272
|
page: PageRoute;
|
|
273
273
|
}
|
|
274
274
|
declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
275
|
-
protected readonly log:
|
|
275
|
+
protected readonly log: _alepha_core16.Logger;
|
|
276
276
|
protected readonly alepha: Alepha;
|
|
277
277
|
protected readonly pageDescriptorProvider: PageDescriptorProvider;
|
|
278
278
|
add(entry: PageRouteEntry): void;
|
|
279
|
-
protected readonly configure:
|
|
279
|
+
protected readonly configure: _alepha_core16.HookDescriptor<"configure">;
|
|
280
280
|
transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
|
|
281
281
|
root(state: RouterState, context: PageReactContext): ReactNode;
|
|
282
282
|
}
|
|
@@ -284,7 +284,7 @@ declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
|
284
284
|
//#endregion
|
|
285
285
|
//#region src/providers/ReactBrowserProvider.d.ts
|
|
286
286
|
declare class ReactBrowserProvider {
|
|
287
|
-
protected readonly log:
|
|
287
|
+
protected readonly log: _alepha_core10.Logger;
|
|
288
288
|
protected readonly client: LinkProvider;
|
|
289
289
|
protected readonly alepha: Alepha;
|
|
290
290
|
protected readonly router: BrowserRouterProvider;
|
|
@@ -308,7 +308,7 @@ declare class ReactBrowserProvider {
|
|
|
308
308
|
* Get embedded layers from the server.
|
|
309
309
|
*/
|
|
310
310
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
311
|
-
readonly ready:
|
|
311
|
+
readonly ready: _alepha_core10.HookDescriptor<"ready">;
|
|
312
312
|
}
|
|
313
313
|
interface RouterGoOptions {
|
|
314
314
|
replace?: boolean;
|
|
@@ -393,10 +393,10 @@ interface NestedViewProps {
|
|
|
393
393
|
* }
|
|
394
394
|
* ```
|
|
395
395
|
*/
|
|
396
|
-
declare const NestedView: (props: NestedViewProps) =>
|
|
396
|
+
declare const NestedView: (props: NestedViewProps) => react_jsx_runtime2.JSX.Element;
|
|
397
397
|
//#endregion
|
|
398
398
|
//#region src/components/NotFound.d.ts
|
|
399
|
-
declare function NotFoundPage():
|
|
399
|
+
declare function NotFoundPage(): react_jsx_runtime1.JSX.Element;
|
|
400
400
|
//# sourceMappingURL=NotFound.d.ts.map
|
|
401
401
|
//#endregion
|
|
402
402
|
//#region src/contexts/RouterContext.d.ts
|
|
@@ -543,11 +543,11 @@ declare const envSchema: _alepha_core0$1.TObject<{
|
|
|
543
543
|
REACT_SERVER_PREFIX: _alepha_core0$1.TString;
|
|
544
544
|
REACT_SSR_ENABLED: _alepha_core0$1.TOptional<_alepha_core0$1.TBoolean>;
|
|
545
545
|
REACT_ROOT_ID: _alepha_core0$1.TString;
|
|
546
|
+
REACT_SERVER_TEMPLATE: _alepha_core0$1.TOptional<_alepha_core0$1.TString>;
|
|
546
547
|
}>;
|
|
547
548
|
declare module "@alepha/core" {
|
|
548
549
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
549
550
|
interface State {
|
|
550
|
-
"react.server.template"?: string;
|
|
551
551
|
"react.server.ssr"?: boolean;
|
|
552
552
|
}
|
|
553
553
|
}
|
|
@@ -560,6 +560,7 @@ declare class ReactServerProvider {
|
|
|
560
560
|
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
561
561
|
protected readonly env: {
|
|
562
562
|
REACT_SSR_ENABLED?: boolean | undefined;
|
|
563
|
+
REACT_SERVER_TEMPLATE?: string | undefined;
|
|
563
564
|
REACT_SERVER_DIST: string;
|
|
564
565
|
REACT_SERVER_PREFIX: string;
|
|
565
566
|
REACT_ROOT_ID: string;
|