@alepha/react 0.6.10 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +2 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +80 -52
- package/dist/index.js +35 -18
- package/dist/index.js.map +1 -1
- package/dist/{useActive-ClUsghB5.js → useActive-BX41CqY8.js} +96 -98
- package/dist/useActive-BX41CqY8.js.map +1 -0
- package/dist/{useActive-4QlZKGbw.cjs → useActive-DjpZBEuB.cjs} +96 -97
- package/dist/useActive-DjpZBEuB.cjs.map +1 -0
- package/package.json +7 -7
- package/src/components/ErrorBoundary.tsx +72 -0
- package/src/components/Link.tsx +2 -2
- package/src/components/NestedView.tsx +10 -1
- package/src/descriptors/$page.ts +4 -8
- package/src/hooks/RouterHookApi.ts +18 -32
- package/src/hooks/useInject.ts +1 -7
- package/src/hooks/useQueryParams.ts +3 -6
- package/src/index.shared.ts +1 -0
- package/src/index.ts +4 -0
- package/src/providers/BrowserRouterProvider.ts +26 -32
- package/src/providers/PageDescriptorProvider.ts +21 -22
- package/src/providers/ReactBrowserProvider.ts +17 -20
- package/src/providers/ReactServerProvider.ts +37 -16
- package/dist/useActive-4QlZKGbw.cjs.map +0 -1
- package/dist/useActive-ClUsghB5.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActive-BX41CqY8.js","sources":["../src/descriptors/$page.ts","../src/contexts/RouterContext.ts","../src/contexts/RouterLayerContext.ts","../src/hooks/useRouterEvents.ts","../src/components/ErrorBoundary.tsx","../src/components/NestedView.tsx","../src/errors/RedirectionError.ts","../src/providers/PageDescriptorProvider.ts","../src/providers/BrowserHeadProvider.ts","../src/providers/BrowserRouterProvider.ts","../src/providers/ReactBrowserProvider.ts","../src/hooks/RouterHookApi.ts","../src/hooks/useRouter.ts","../src/components/Link.tsx","../src/hooks/useInject.ts","../src/hooks/useClient.ts","../src/hooks/useQueryParams.ts","../src/hooks/useRouterState.ts","../src/hooks/useActive.ts"],"sourcesContent":["import { type Async, OPTIONS, type Static, type TSchema } from \"@alepha/core\";\nimport { KIND, NotImplementedError, __descriptor } from \"@alepha/core\";\nimport type { FC, ReactNode } from \"react\";\nimport type { RouterHookApi } from \"../hooks/RouterHookApi.ts\";\nimport type { PageReactContext } from \"../providers/PageDescriptorProvider.ts\";\n\nconst KEY = \"PAGE\";\n\nexport interface PageConfigSchema {\n\tquery?: TSchema;\n\tparams?: TSchema;\n}\n\nexport type TPropsDefault = any;\n\nexport type TPropsParentDefault = object;\n\nexport interface PageDescriptorOptions<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\tname?: string;\n\n\tpath?: string;\n\n\tschema?: TConfig;\n\n\tresolve?: (config: PageResolve<TConfig, TPropsParent>) => Async<TProps>;\n\n\tcomponent?: FC<TProps & TPropsParent>;\n\n\tlazy?: () => Promise<{ default: FC<TProps & TPropsParent> }>;\n\n\tchildren?: Array<{ [OPTIONS]: PageDescriptorOptions }>;\n\n\tparent?: { [OPTIONS]: PageDescriptorOptions<any, TPropsParent> };\n\n\tcan?: () => boolean;\n\n\thead?: Head | ((props: TProps, previous?: Head) => Head);\n\n\terrorHandler?: (error: Error) => ReactNode;\n}\n\nexport interface PageDescriptor<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n> {\n\t[KIND]: typeof KEY;\n\t[OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;\n\n\trender: (options?: {\n\t\tparams?: Record<string, string>;\n\t\tquery?: Record<string, string>;\n\t}) => Promise<string>;\n\tgo: () => void;\n\tcreateAnchorProps: (routerHook: RouterHookApi) => {\n\t\thref: string;\n\t\tonClick: () => void;\n\t};\n\tcan: () => boolean;\n}\n\nexport const $page = <\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTProps extends object = TPropsDefault,\n\tTPropsParent extends object = TPropsParentDefault,\n>(\n\toptions: PageDescriptorOptions<TConfig, TProps, TPropsParent>,\n): PageDescriptor<TConfig, TProps, TPropsParent> => {\n\t__descriptor(KEY);\n\n\tif (options.children) {\n\t\tfor (const child of options.children) {\n\t\t\tchild[OPTIONS].parent = {\n\t\t\t\t[OPTIONS]: options as PageDescriptorOptions<any, any, any>,\n\t\t\t};\n\t\t}\n\t}\n\n\tif (options.parent) {\n\t\toptions.parent[OPTIONS].children ??= [];\n\t\toptions.parent[OPTIONS].children.push({\n\t\t\t[OPTIONS]: options as PageDescriptorOptions<any, any, any>,\n\t\t});\n\t}\n\n\treturn {\n\t\t[KIND]: KEY,\n\t\t[OPTIONS]: options,\n\t\trender: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tgo: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tcreateAnchorProps: () => {\n\t\t\tthrow new NotImplementedError(KEY);\n\t\t},\n\t\tcan: () => {\n\t\t\tif (options.can) {\n\t\t\t\treturn options.can();\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n};\n\n$page[KIND] = KEY;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Head {\n\ttitle?: string;\n\ttitleSeparator?: string;\n\thtmlAttributes?: Record<string, string>;\n\tbodyAttributes?: Record<string, string>;\n\tmeta?: Array<{ name: string; content: string }>;\n}\n\nexport interface PageRequestConfig<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n> {\n\tparams: TConfig[\"params\"] extends TSchema\n\t\t? Static<TConfig[\"params\"]>\n\t\t: Record<string, string>;\n\n\tquery: TConfig[\"query\"] extends TSchema\n\t\t? Static<TConfig[\"query\"]>\n\t\t: Record<string, string>;\n}\n\nexport type PageResolve<\n\tTConfig extends PageConfigSchema = PageConfigSchema,\n\tTPropsParent extends object = TPropsParentDefault,\n> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;\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 ReactNode,\n\ttype ErrorInfo,\n\ttype PropsWithChildren,\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 * Nested view component\n *\n * @param props\n * @constructor\n */\nconst NestedView = (props: NestedViewProps) => {\n\tconst app = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tconst index = layer?.index ?? 0;\n\n\tconst [view, setView] = useState<ReactNode | undefined>(\n\t\tapp?.state.layers[index]?.element,\n\t);\n\n\tuseRouterEvents(\n\t\t{\n\t\t\tonEnd: ({ state }) => {\n\t\t\t\tsetView(state.layers[index]?.element);\n\t\t\t},\n\t\t},\n\t\t[app],\n\t);\n\n\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","import type { HrefLike } from \"../hooks/RouterHookApi.ts\";\n\nexport class RedirectionError extends Error {\n\tconstructor(public readonly page: HrefLike) {\n\t\tsuper(\"Redirection\");\n\t}\n}\n","import { $hook, $inject, $logger, Alepha, OPTIONS } from \"@alepha/core\";\nimport type { ApiLinksResponse } from \"@alepha/server\";\nimport { type ReactNode, createElement } from \"react\";\nimport NestedView from \"../components/NestedView.tsx\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport {\n\t$page,\n\ttype Head,\n\ttype PageDescriptorOptions,\n} from \"../descriptors/$page.ts\";\nimport { RedirectionError } from \"../errors/RedirectionError.ts\";\n\nexport class PageDescriptorProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pages: PageRoute[] = [];\n\n\tpublic getPages(): PageRoute[] {\n\t\treturn this.pages;\n\t}\n\n\tpublic page(name: string): PageRoute {\n\t\tfor (const page of this.pages) {\n\t\t\tif (page.name === name) {\n\t\t\t\treturn page;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Page ${name} not found`);\n\t}\n\n\tpublic root(state: RouterState, context: PageReactContext): ReactNode {\n\t\treturn createElement(\n\t\t\tRouterContext.Provider,\n\t\t\t{\n\t\t\t\tvalue: {\n\t\t\t\t\talepha: this.alepha,\n\t\t\t\t\tstate,\n\t\t\t\t\tcontext,\n\t\t\t\t},\n\t\t\t},\n\t\t\tcreateElement(NestedView, {}, state.layers[0]?.element),\n\t\t);\n\t}\n\n\tpublic async createLayers(\n\t\troute: PageRoute,\n\t\trequest: PageRequest,\n\t): Promise<CreateLayersResult> {\n\t\tconst { pathname, search } = request.url;\n\t\tconst layers: Layer[] = []; // result layers\n\t\tlet context: Record<string, any> = {}; // all props\n\t\tconst stack: Array<RouterStackItem> = [{ route }]; // stack of routes\n\t\tlet onError = this.renderError; // 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: request.query;\n\t\t\t} catch (e) {\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconfig.params = route.schema?.params\n\t\t\t\t\t? this.alepha.parse(route.schema.params, request.params)\n\t\t\t\t\t: request.params;\n\t\t\t} catch (e) {\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// save config\n\t\t\tit.config = {\n\t\t\t\t...config,\n\t\t\t};\n\n\t\t\t// no resolve, render a basic view by default\n\t\t\tif (!route.resolve) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// check if previous layer is the same, reuse if possible\n\t\t\tconst previous = request.previous;\n\t\t\tif (previous?.[i] && !forceRefresh && previous[i].name === route.name) {\n\t\t\t\tconst url = (str?: string) => (str ? str.replace(/\\/\\/+/g, \"/\") : \"/\");\n\n\t\t\t\tconst prev = JSON.stringify({\n\t\t\t\t\tpart: url(previous[i].part),\n\t\t\t\t\tparams: previous[i].config?.params ?? {},\n\t\t\t\t});\n\n\t\t\t\tconst curr = JSON.stringify({\n\t\t\t\t\tpart: url(route.path),\n\t\t\t\t\tparams: config.params ?? {},\n\t\t\t\t});\n\n\t\t\t\tif (prev === curr) {\n\t\t\t\t\t// part is the same, reuse previous layer\n\t\t\t\t\tit.props = previous[i].props;\n\t\t\t\t\tit.error = previous[i].error;\n\t\t\t\t\tcontext = {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\t...it.props,\n\t\t\t\t\t};\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// part is different, force refresh of next layers\n\t\t\t\tforceRefresh = true;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst props =\n\t\t\t\t\t(await route.resolve?.({\n\t\t\t\t\t\t...request, // request\n\t\t\t\t\t\t...config, // params, query\n\t\t\t\t\t\t...context, // previous props\n\t\t\t\t\t} as any)) ?? {};\n\n\t\t\t\t// save props\n\t\t\t\tit.props = {\n\t\t\t\t\t...props,\n\t\t\t\t};\n\n\t\t\t\t// add props to context\n\t\t\t\tcontext = {\n\t\t\t\t\t...context,\n\t\t\t\t\t...props,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\t// check if we need to redirect\n\t\t\t\tif (e instanceof RedirectionError) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlayers: [],\n\t\t\t\t\t\tredirect: typeof e.page === \"string\" ? e.page : this.href(e.page),\n\t\t\t\t\t\tpathname,\n\t\t\t\t\t\tsearch,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tthis.log.error(e);\n\n\t\t\t\tit.error = e as Error;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tlet acc = \"\";\n\t\tfor (let i = 0; i < stack.length; i++) {\n\t\t\tconst it = stack[i];\n\t\t\tconst props = it.props ?? {};\n\n\t\t\tconst params = { ...it.config?.params };\n\t\t\tfor (const key of Object.keys(params)) {\n\t\t\t\tparams[key] = String(params[key]);\n\t\t\t}\n\n\t\t\tif (it.route.head && !it.error) {\n\t\t\t\tthis.fillHead(it.route, request, {\n\t\t\t\t\t...props,\n\t\t\t\t\t...context,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tacc += \"/\";\n\t\t\tacc += it.route.path ? this.compile(it.route.path, params) : \"\";\n\t\t\tconst path = acc.replace(/\\/+/, \"/\");\n\t\t\tconst localErrorHandler = this.getErrorHandler(it.route);\n\t\t\tif (localErrorHandler) {\n\t\t\t\tonError = 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\tconst element = await onError(it.error);\n\n\t\t\t\tlayers.push({\n\t\t\t\t\tprops,\n\t\t\t\t\terror: it.error,\n\t\t\t\t\tname: it.route.name,\n\t\t\t\t\tpart: it.route.path,\n\t\t\t\t\tconfig: it.config,\n\t\t\t\t\telement: this.renderView(i + 1, path, element),\n\t\t\t\t\tindex: i + 1,\n\t\t\t\t\tpath,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// normal use case\n\n\t\t\tconst layer = await this.createElement(it.route, {\n\t\t\t\t...props,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tlayers.push({\n\t\t\t\tname: it.route.name,\n\t\t\t\tprops,\n\t\t\t\tpart: it.route.path,\n\t\t\t\tconfig: it.config,\n\t\t\t\telement: this.renderView(i + 1, path, layer),\n\t\t\t\tindex: i + 1,\n\t\t\t\tpath,\n\t\t\t});\n\t\t}\n\n\t\treturn { layers, pathname, search };\n\t}\n\n\tprotected getErrorHandler(route: PageRoute) {\n\t\tif (route.errorHandler) return route.errorHandler;\n\t\tlet parent = route.parent;\n\t\twhile (parent) {\n\t\t\tif (parent.errorHandler) return parent.errorHandler;\n\t\t\tparent = parent.parent;\n\t\t}\n\t}\n\n\tprotected async createElement(\n\t\tpage: PageRoute,\n\t\tprops: Record<string, any>,\n\t): Promise<ReactNode> {\n\t\tif (page.lazy) {\n\t\t\tconst component = await page.lazy(); // load component\n\t\t\treturn createElement(component.default, props);\n\t\t}\n\n\t\tif (page.component) {\n\t\t\treturn createElement(page.component, props);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprotected fillHead(\n\t\tpage: PageRoute,\n\t\tctx: PageRequest,\n\t\tprops: Record<string, any>,\n\t): void {\n\t\tif (!page.head) {\n\t\t\treturn;\n\t\t}\n\n\t\tctx.head ??= {};\n\n\t\tconst head =\n\t\t\ttypeof page.head === \"function\" ? page.head(props, ctx.head) : page.head;\n\n\t\tif (head.title) {\n\t\t\tctx.head ??= {};\n\n\t\t\tif (ctx.head.titleSeparator) {\n\t\t\t\tctx.head.title = `${head.title}${ctx.head.titleSeparator}${ctx.head.title}`;\n\t\t\t} else {\n\t\t\t\tctx.head.title = head.title;\n\t\t\t}\n\n\t\t\tctx.head.titleSeparator = head.titleSeparator;\n\t\t}\n\n\t\tif (head.htmlAttributes) {\n\t\t\tctx.head.htmlAttributes = {\n\t\t\t\t...ctx.head.htmlAttributes,\n\t\t\t\t...head.htmlAttributes,\n\t\t\t};\n\t\t}\n\n\t\tif (head.bodyAttributes) {\n\t\t\tctx.head.bodyAttributes = {\n\t\t\t\t...ctx.head.bodyAttributes,\n\t\t\t\t...head.bodyAttributes,\n\t\t\t};\n\t\t}\n\n\t\tif (head.meta) {\n\t\t\tctx.head.meta = [...(ctx.head.meta ?? []), ...(head.meta ?? [])];\n\t\t}\n\t}\n\n\tpublic renderError(e: Error): ReactNode {\n\t\treturn createElement(\"pre\", { style: { overflow: \"auto\" } }, `${e.stack}`);\n\t}\n\n\tpublic renderEmptyView(): ReactNode {\n\t\treturn createElement(NestedView, {});\n\t}\n\n\tpublic href(\n\t\tpage: { options: { name?: string } },\n\t\tparams: Record<string, any> = {},\n\t): string {\n\t\tconst found = this.pages.find((it) => it.name === page.options.name);\n\t\tif (!found) {\n\t\t\tthrow new Error(`Page ${page.options.name} not found`);\n\t\t}\n\n\t\tlet url = found.path ?? \"\";\n\t\tlet parent = found.parent;\n\t\twhile (parent) {\n\t\t\turl = `${parent.path ?? \"\"}/${url}`;\n\t\t\tparent = parent.parent;\n\t\t}\n\n\t\turl = this.compile(url, params);\n\n\t\treturn url.replace(/\\/\\/+/g, \"/\") || \"/\";\n\t}\n\n\tpublic compile(path: string, params: Record<string, string> = {}) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tpath = path.replace(`:${key}`, value);\n\t\t}\n\t\treturn path;\n\t}\n\n\tprotected renderView(\n\t\tindex: number,\n\t\tpath: string,\n\t\tview: ReactNode = this.renderEmptyView(),\n\t): ReactNode {\n\t\treturn createElement(\n\t\t\tRouterLayerContext.Provider,\n\t\t\t{\n\t\t\t\tvalue: {\n\t\t\t\t\tindex,\n\t\t\t\t\tpath,\n\t\t\t\t},\n\t\t\t},\n\t\t\tview,\n\t\t);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\tname: \"configure\",\n\t\thandler: () => {\n\t\t\tconst pages = this.alepha.getDescriptorValues($page);\n\t\t\tfor (const { value, key } of pages) {\n\t\t\t\tvalue[OPTIONS].name ??= key;\n\n\t\t\t\t// skip children, we only want root pages\n\t\t\t\tif (value[OPTIONS].parent) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.add(this.map(pages, value));\n\t\t\t}\n\t\t},\n\t});\n\n\tprotected map(\n\t\tpages: Array<{ value: { [OPTIONS]: PageDescriptorOptions } }>,\n\t\ttarget: { [OPTIONS]: PageDescriptorOptions },\n\t): PageRouteEntry {\n\t\tconst children = target[OPTIONS].children ?? [];\n\n\t\tfor (const it of pages) {\n\t\t\tif (it.value[OPTIONS].parent === target) {\n\t\t\t\tchildren.push(it.value);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...target[OPTIONS],\n\t\t\tparent: undefined,\n\t\t\tchildren: children.map((it) => this.map(pages, it)),\n\t\t} as PageRoute;\n\t}\n\n\tpublic add(entry: PageRouteEntry) {\n\t\tif (this.alepha.isReady()) {\n\t\t\tthrow new Error(\"Router is already initialized\");\n\t\t}\n\n\t\tentry.name ??= this.nextId();\n\t\tconst page = entry as PageRoute;\n\n\t\tpage.match = this.createMatch(page);\n\t\tthis.pages.push(page);\n\n\t\tif (page.children) {\n\t\t\tfor (const child of page.children) {\n\t\t\t\t(child as PageRoute).parent = page;\n\t\t\t\tthis.add(child);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected createMatch(page: PageRoute): string {\n\t\tlet url = page.path ?? \"/\";\n\t\tlet target = page.parent;\n\t\twhile (target) {\n\t\t\turl = `${target.path ?? \"\"}/${url}`;\n\t\t\ttarget = target.parent;\n\t\t}\n\n\t\tlet path = url.replace(/\\/\\/+/g, \"/\");\n\n\t\tif (path.endsWith(\"/\") && path !== \"/\") {\n\t\t\t// remove trailing slash\n\t\t\tpath = path.slice(0, -1);\n\t\t}\n\n\t\treturn path;\n\t}\n\n\tprotected _next = 0;\n\n\tprotected nextId(): string {\n\t\tthis._next += 1;\n\t\treturn `P${this._next}`;\n\t}\n}\n\nexport const isPageRoute = (it: any): it is PageRoute => {\n\treturn (\n\t\tit &&\n\t\ttypeof it === \"object\" &&\n\t\ttypeof it.path === \"string\" &&\n\t\ttypeof it.page === \"object\"\n\t);\n};\n\nexport interface PageRouteEntry\n\textends Omit<PageDescriptorOptions, \"children\" | \"parent\"> {\n\tchildren?: PageRouteEntry[];\n}\n\nexport interface PageRoute extends PageRouteEntry {\n\ttype: \"page\";\n\tname: string;\n\tparent?: PageRoute;\n\tmatch: string;\n}\n\nexport interface Layer {\n\tconfig?: {\n\t\tquery?: Record<string, any>;\n\t\tparams?: Record<string, any>;\n\t\t// stack of resolved props\n\t\tcontext?: Record<string, any>;\n\t};\n\n\tname: string;\n\tprops?: Record<string, any>;\n\terror?: Error;\n\tpart?: string;\n\telement: ReactNode;\n\tindex: number;\n\tpath: string;\n}\n\nexport type PreviousLayerData = Omit<Layer, \"element\">;\n\nexport interface AnchorProps {\n\thref: string;\n\tonClick: (ev: any) => any;\n}\n\nexport interface RouterState {\n\tpathname: string;\n\tsearch: string;\n\tlayers: Array<Layer>;\n}\n\nexport interface TransitionOptions {\n\tstate?: RouterState;\n\tprevious?: PreviousLayerData[];\n\tcontext?: PageReactContext;\n}\n\nexport interface RouterStackItem {\n\troute: PageRoute;\n\tconfig?: Record<string, any>;\n\tprops?: Record<string, any>;\n\terror?: Error;\n}\n\nexport interface RouterRenderResult {\n\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\thead: Head;\n\tonError: (error: Error) => ReactNode;\n\tlinks?: ApiLinksResponse;\n}\n","import type { Head } from \"./ServerHeadProvider.ts\";\n\nexport class BrowserHeadProvider {\n\trenderHead(document: Document, head: Head): void {\n\t\tif (head.title) {\n\t\t\tdocument.title = head.title;\n\t\t}\n\n\t\tif (head.bodyAttributes) {\n\t\t\tfor (const [key, value] of Object.entries(head.bodyAttributes)) {\n\t\t\t\tif (value) {\n\t\t\t\t\tdocument.body.setAttribute(key, value);\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.removeAttribute(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (head.htmlAttributes) {\n\t\t\tfor (const [key, value] of Object.entries(head.htmlAttributes)) {\n\t\t\t\tif (value) {\n\t\t\t\t\tdocument.documentElement.setAttribute(key, value);\n\t\t\t\t} else {\n\t\t\t\t\tdocument.documentElement.removeAttribute(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (head.meta) {\n\t\t\tfor (const [key, value] of Object.entries(head.meta)) {\n\t\t\t\tconst meta = document.querySelector(`meta[name=\"${key}\"]`);\n\t\t\t\tif (meta) {\n\t\t\t\t\tmeta.setAttribute(\"content\", value.content);\n\t\t\t\t} else {\n\t\t\t\t\tconst newMeta = document.createElement(\"meta\");\n\t\t\t\t\tnewMeta.setAttribute(\"name\", key);\n\t\t\t\t\tnewMeta.setAttribute(\"content\", value.content);\n\t\t\t\t\tdocument.head.appendChild(newMeta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { $hook, $inject, $logger, Alepha } from \"@alepha/core\";\nimport { type Route, RouterProvider } from \"@alepha/router\";\nimport type { ReactNode } from \"react\";\nimport {\n\tPageDescriptorProvider,\n\ttype PageReactContext,\n\ttype PageRequest,\n\ttype PageRoute,\n\ttype PageRouteEntry,\n\ttype RouterRenderResult,\n\ttype RouterState,\n\ttype TransitionOptions,\n\tisPageRoute,\n} from \"./PageDescriptorProvider.ts\";\n\nexport interface BrowserRoute extends Route {\n\tpage: PageRoute;\n}\n\nexport class BrowserRouterProvider extends RouterProvider<BrowserRoute> {\n\tprotected readonly log = $logger();\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly pageDescriptorProvider = $inject(PageDescriptorProvider);\n\n\tpublic add(entry: PageRouteEntry) {\n\t\tthis.pageDescriptorProvider.add(entry);\n\t}\n\n\tprotected readonly configure = $hook({\n\t\tname: \"configure\",\n\t\thandler: async () => {\n\t\t\tfor (const page of this.pageDescriptorProvider.getPages()) {\n\t\t\t\t// mount only if a view is provided\n\t\t\t\tif (page.component || page.lazy) {\n\t\t\t\t\tthis.push({\n\t\t\t\t\t\tpath: page.match,\n\t\t\t\t\t\tpage,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\n\tpublic async transition(\n\t\turl: URL,\n\t\toptions: TransitionOptions = {},\n\t): Promise<RouterRenderResult> {\n\t\tconst { pathname, search } = url;\n\t\tconst state: RouterState = {\n\t\t\tpathname,\n\t\t\tsearch,\n\t\t\tlayers: [],\n\t\t};\n\n\t\tconst context: PageRequest = {\n\t\t\turl,\n\t\t\tquery: {},\n\t\t\tparams: {},\n\t\t\thead: {},\n\t\t\tonError: () => null,\n\t\t\t...(options.context ?? {}),\n\t\t};\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: \"Not Found\",\n\t\t\t\t\tindex: 0,\n\t\t\t\t\tpath: \"/\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait this.alepha.emit(\"react:transition:success\", { state });\n\t\t} catch (e) {\n\t\t\tthis.log.error(e);\n\t\t\tstate.layers = [\n\t\t\t\t{\n\t\t\t\t\tname: \"error\",\n\t\t\t\t\telement: this.pageDescriptorProvider.renderError(e as Error),\n\t\t\t\t\tindex: 0,\n\t\t\t\t\tpath: \"/\",\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tawait this.alepha.emit(\"react:transition:error\", {\n\t\t\t\terror: e as Error,\n\t\t\t\tstate,\n\t\t\t\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, type Static, t } from \"@alepha/core\";\nimport { HttpClient, type HttpClientLink } from \"@alepha/server\";\nimport type { Root } from \"react-dom/client\";\nimport { createRoot, hydrateRoot } from \"react-dom/client\";\nimport { BrowserHeadProvider } from \"./BrowserHeadProvider.ts\";\nimport { BrowserRouterProvider } from \"./BrowserRouterProvider.ts\";\nimport type {\n\tPreviousLayerData,\n\tRouterRenderResult,\n\tRouterState,\n\tTransitionOptions,\n} from \"./PageDescriptorProvider.ts\";\n\nconst envSchema = t.object({\n\tREACT_ROOT_ID: t.string({ default: \"root\" }),\n});\n\ndeclare module \"@alepha/core\" {\n\tinterface Env extends Partial<Static<typeof envSchema>> {}\n}\n\nexport class ReactBrowserProvider {\n\tprotected readonly log = $logger();\n\tprotected readonly client = $inject(HttpClient);\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly router = $inject(BrowserRouterProvider);\n\tprotected readonly headProvider = $inject(BrowserHeadProvider);\n\tprotected readonly env = $inject(envSchema);\n\tprotected root!: Root;\n\n\tpublic transitioning?: {\n\t\tto: string;\n\t};\n\n\tpublic state: RouterState = {\n\t\tlayers: [],\n\t\tpathname: \"\",\n\t\tsearch: \"\",\n\t};\n\n\tpublic get document() {\n\t\treturn window.document;\n\t}\n\n\tpublic get history() {\n\t\treturn window.history;\n\t}\n\n\tpublic get url(): string {\n\t\treturn window.location.pathname + window.location.search;\n\t}\n\n\tpublic async invalidate(props?: Record<string, any>) {\n\t\tconst previous: PreviousLayerData[] = [];\n\n\t\tif (props) {\n\t\t\tconst [key] = Object.keys(props);\n\t\t\tconst value = props[key];\n\n\t\t\tfor (const layer of this.state.layers) {\n\t\t\t\tif (layer.props?.[key]) {\n\t\t\t\t\tprevious.push({\n\t\t\t\t\t\t...layer,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t...layer.props,\n\t\t\t\t\t\t\t[key]: value,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tprevious.push(layer);\n\t\t\t}\n\t\t}\n\n\t\tawait this.render({ previous });\n\t}\n\n\t/**\n\t *\n\t * @param url\n\t * @param options\n\t */\n\tpublic async go(url: string, options: RouterGoOptions = {}): Promise<void> {\n\t\tconst result = await this.render({\n\t\t\turl,\n\t\t});\n\n\t\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.history.replaceState({}, \"\", result.context.url.pathname);\n\t\t\treturn;\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tthis.history.replaceState({}, \"\", url);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.history.pushState({}, \"\", url);\n\t}\n\n\tprotected async render(\n\t\toptions: {\n\t\t\turl?: string;\n\t\t\tprevious?: PreviousLayerData[];\n\t\t} = {},\n\t): Promise<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\t * @protected\n\t */\n\tprotected getHydrationState(): ReactHydrationState | undefined {\n\t\ttry {\n\t\t\tif (\"__ssr\" in window && typeof window.__ssr === \"object\") {\n\t\t\t\treturn window.__ssr as ReactHydrationState;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @protected\n\t */\n\tprotected getRootElement() {\n\t\tconst root = this.document.getElementById(this.env.REACT_ROOT_ID);\n\t\tif (root) {\n\t\t\treturn root;\n\t\t}\n\n\t\tconst div = this.document.createElement(\"div\");\n\t\tdiv.id = this.env.REACT_ROOT_ID;\n\n\t\tthis.document.body.prepend(div);\n\n\t\treturn div;\n\t}\n\n\t// -------------------------------------------------------------------------------------------------------------------\n\n\t/**\n\t *\n\t * @protected\n\t */\n\tpublic readonly ready = $hook({\n\t\tname: \"ready\",\n\t\thandler: async () => {\n\t\t\tconst hydration = this.getHydrationState();\n\t\t\tconst previous = hydration?.layers ?? [];\n\n\t\t\tif (hydration?.links) {\n\t\t\t\tfor (const link of hydration.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\t\t\tif (context.head) {\n\t\t\t\tthis.headProvider.renderHead(this.document, context.head);\n\t\t\t}\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\tconst element = this.router.root(this.state, context);\n\n\t\t\tif (previous.length > 0) {\n\t\t\t\tthis.root = hydrateRoot(this.getRootElement(), element);\n\t\t\t\tthis.log.info(\"Hydrated root element\");\n\t\t\t} else {\n\t\t\t\tthis.root ??= createRoot(this.getRootElement());\n\t\t\t\tthis.root.render(element);\n\t\t\t\tthis.log.info(\"Created root element\");\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\t\tthis.render();\n\t\t\t});\n\t\t},\n\t});\n\n\tpublic readonly onTransitionEnd = $hook({\n\t\tname: \"react:transition:end\",\n\t\thandler: async ({ context }) => {\n\t\t\tthis.headProvider.renderHead(this.document, context.head);\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?: PreviousLayerData[];\n\tlinks?: HttpClientLink[];\n}\n","import type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport type {\n\tAnchorProps,\n\tRouterState,\n} from \"../providers/PageDescriptorProvider.ts\";\nimport type {\n\tReactBrowserProvider,\n\tRouterGoOptions,\n} from \"../providers/ReactBrowserProvider.ts\";\n\nexport class RouterHookApi {\n\tconstructor(\n\t\tprivate readonly state: RouterState,\n\t\tprivate readonly layer: {\n\t\t\tpath: string;\n\t\t},\n\t\tprivate readonly browser?: ReactBrowserProvider,\n\t) {}\n\n\t/**\n\t *\n\t */\n\tpublic get current(): RouterState {\n\t\treturn this.state;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic get pathname(): string {\n\t\treturn this.state.pathname;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic get query(): Record<string, string> {\n\t\tconst query: Record<string, string> = {};\n\n\t\tfor (const [key, value] of new URLSearchParams(\n\t\t\tthis.state.search,\n\t\t).entries()) {\n\t\t\tquery[key] = String(value);\n\t\t}\n\n\t\treturn query;\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic async back() {\n\t\tthis.browser?.history.back();\n\t}\n\n\t/**\n\t *\n\t */\n\tpublic async forward() {\n\t\tthis.browser?.history.forward();\n\t}\n\n\t/**\n\t *\n\t * @param props\n\t */\n\tpublic async invalidate(props?: Record<string, any>) {\n\t\tawait this.browser?.invalidate(props);\n\t}\n\n\t/**\n\t * Create a valid href for the given pathname.\n\t *\n\t * @param pathname\n\t * @param layer\n\t */\n\tpublic createHref(pathname: HrefLike, layer: { path: string } = this.layer) {\n\t\tif (typeof pathname === \"object\") {\n\t\t\tpathname = pathname.options.path ?? \"\";\n\t\t}\n\n\t\treturn pathname.startsWith(\"/\")\n\t\t\t? pathname\n\t\t\t: `${layer.path}/${pathname}`.replace(/\\/\\/+/g, \"/\");\n\t}\n\n\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\tawait this.browser?.go(this.createHref(path, this.layer), options);\n\t}\n\n\tpublic anchor(path: string): AnchorProps {\n\t\tconst href = this.createHref(path, this.layer);\n\t\treturn {\n\t\t\thref,\n\t\t\tonClick: (ev: any) => {\n\t\t\t\tev.stopPropagation();\n\t\t\t\tev.preventDefault();\n\n\t\t\t\tthis.go(path).catch(console.error);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Set query params.\n\t *\n\t * @param record\n\t * @param options\n\t */\n\tpublic setQueryParams(\n\t\trecord:\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 { ReactBrowserProvider } from \"../providers/ReactBrowserProvider.ts\";\nimport { RouterHookApi } from \"./RouterHookApi.ts\";\n\nexport const useRouter = (): RouterHookApi => {\n\tconst ctx = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tif (!ctx || !layer) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tnew RouterHookApi(\n\t\t\t\tctx.state,\n\t\t\t\tlayer,\n\t\t\t\tctx.alepha.isBrowser()\n\t\t\t\t\t? ctx.alepha.get(ReactBrowserProvider)\n\t\t\t\t\t: undefined,\n\t\t\t),\n\t\t[layer],\n\t);\n};\n","import { OPTIONS } from \"@alepha/core\";\nimport React from \"react\";\nimport type { AnchorHTMLAttributes } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport type { PageDescriptor } from \"../descriptors/$page.ts\";\nimport { useRouter } from \"../hooks/useRouter.ts\";\n\nexport interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {\n\tto: string | PageDescriptor;\n\tchildren?: React.ReactNode;\n}\n\nconst Link = (props: LinkProps) => {\n\tReact.useContext(RouterContext);\n\n\tconst to = typeof props.to === \"string\" ? props.to : props.to[OPTIONS].path;\n\tif (!to) {\n\t\treturn null;\n\t}\n\n\tconst can = typeof props.to === \"string\" ? undefined : props.to[OPTIONS].can;\n\tif (can && !can()) {\n\t\treturn null;\n\t}\n\n\tconst name =\n\t\ttypeof props.to === \"string\" ? undefined : props.to[OPTIONS].name;\n\n\tconst router = useRouter();\n\treturn (\n\t\t<a {...router.anchor(to)} {...props}>\n\t\t\t{props.children ?? name}\n\t\t</a>\n\t);\n};\n\nexport default Link;\n","import type { Class } from \"@alepha/core\";\nimport { useContext, useMemo } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\n\nexport const useInject = <T extends object>(clazz: Class<T>): T => {\n\tconst ctx = useContext(RouterContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useRouter must be used within a <RouterProvider>\");\n\t}\n\n\treturn useMemo(() => ctx.alepha.get(clazz), []);\n};\n","import { HttpClient } from \"@alepha/server\";\nimport { useInject } from \"./useInject.ts\";\n\nexport const useClient = (): HttpClient => {\n\treturn useInject(HttpClient);\n};\n\nexport const useApi = <T extends object>() => {\n\treturn useInject(HttpClient).of<T>();\n};\n","import type { Alepha, Static, TObject } from \"@alepha/core\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { useRouter } from \"./useRouter.ts\";\n\nexport interface UseQueryParamsHookOptions {\n\tformat?: \"base64\" | \"querystring\";\n\tkey?: string;\n\tpush?: boolean;\n}\n\nexport const useQueryParams = <T extends TObject>(\n\tschema: T,\n\toptions: UseQueryParamsHookOptions = {},\n): [Static<T>, (data: Static<T>) => void] => {\n\tconst ctx = useContext(RouterContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useQueryParams must be used within a RouterProvider\");\n\t}\n\n\tconst key = options.key ?? \"q\";\n\tconst router = useRouter();\n\tconst querystring = router.query[key];\n\n\tconst [queryParams, setQueryParams] = useState(\n\t\tdecode(ctx.alepha, schema, router.query[key]),\n\t);\n\n\tuseEffect(() => {\n\t\tsetQueryParams(decode(ctx.alepha, schema, querystring));\n\t}, [querystring]);\n\n\treturn [\n\t\tqueryParams,\n\t\t(queryParams: Static<T>) => {\n\t\t\tsetQueryParams(queryParams);\n\t\t\trouter.setQueryParams((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 { useContext, useMemo, useState } from \"react\";\nimport { RouterContext } from \"../contexts/RouterContext.ts\";\nimport { RouterLayerContext } from \"../contexts/RouterLayerContext.ts\";\nimport type { AnchorProps } from \"../providers/PageDescriptorProvider.ts\";\nimport type { HrefLike } from \"./RouterHookApi.ts\";\nimport { useRouter } from \"./useRouter.ts\";\nimport { useRouterEvents } from \"./useRouterEvents.ts\";\n\nexport const useActive = (path: HrefLike): UseActiveHook => {\n\tconst router = useRouter();\n\tconst ctx = useContext(RouterContext);\n\tconst layer = useContext(RouterLayerContext);\n\tif (!ctx || !layer) {\n\t\tthrow new Error(\"useRouter must be used within a RouterProvider\");\n\t}\n\n\tlet name: string | undefined;\n\tif (typeof path === \"object\" && path.options.name) {\n\t\tname = path.options.name;\n\t}\n\n\tconst [current, setCurrent] = useState(ctx.state.pathname);\n\tconst href = useMemo(() => router.createHref(path, layer), [path, layer]);\n\tconst [isPending, setPending] = useState(false);\n\tconst isActive = current === href;\n\n\tuseRouterEvents({\n\t\tonEnd: ({ state }) => setCurrent(state.pathname),\n\t});\n\n\treturn {\n\t\tname,\n\t\tisPending,\n\t\tisActive,\n\t\tanchorProps: {\n\t\t\thref,\n\t\t\tonClick: (ev: any) => {\n\t\t\t\tev.stopPropagation();\n\t\t\t\tev.preventDefault();\n\t\t\t\tif (isActive) return;\n\t\t\t\tif (isPending) return;\n\n\t\t\t\tsetPending(true);\n\t\t\t\trouter.go(href).then(() => {\n\t\t\t\t\tsetPending(false);\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t};\n};\n\nexport interface UseActiveHook {\n\tisActive: boolean;\n\tanchorProps: AnchorProps;\n\tisPending: boolean;\n\tname?: string;\n}\n"],"names":[],"mappings":";;;;;;;AAGA,MAAM,GAAG,GAAG,MAAM;AACN,MAAC,KAAK,GAAG,CAAC,OAAO,KAAK;AAClC,EAAE,YAAY,CAAC,GAAG,CAAC;AACnB,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE;AACxB,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE;AAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG;AAC9B,QAAQ,CAAC,OAAO,GAAG;AACnB,OAAO;AACP;AACA;AACA,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE;AACtB,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,EAAE;AAC3C,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1C,MAAM,CAAC,OAAO,GAAG;AACjB,KAAK,CAAC;AACN;AACA,EAAE,OAAO;AACT,IAAI,CAAC,IAAI,GAAG,GAAG;AACf,IAAI,C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,CAAC,QAAQ;AACnD,GAAG,CAAC;AACJ,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,WAAW,EAAE;AACjB,MAAM,IAAI;AACV,MAAM,OAAO,EAAE,CAAC,EAAE,KAAK;AACvB,QAAQ,EAAE,CAAC,eAAe,EAAE;AAC5B,QAAQ,EAAE,CAAC,cAAc,EAAE;AAC3B,QAAQ,IAAI,QAAQ,EAAE;AACtB,QAAQ,IAAI,SAAS,EAAE;AACvB,QAAQ,UAAU,CAAC,IAAI,CAAC;AACxB,QAAQ,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM;AACnC,UAAU,UAAU,CAAC,KAAK,CAAC;AAC3B,SAAS,CAAC;AACV;AACA;AACA,GAAG;AACH;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var React = require('react');
|
|
5
4
|
var core = require('@alepha/core');
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var server = require('@alepha/server');
|
|
7
7
|
var client = require('react-dom/client');
|
|
8
8
|
var router = require('@alepha/router');
|
|
@@ -93,6 +93,36 @@ const useRouterEvents = (opts = {}, deps = []) => {
|
|
|
93
93
|
}, deps);
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
class ErrorBoundary extends React.Component {
|
|
97
|
+
constructor(props) {
|
|
98
|
+
super(props);
|
|
99
|
+
this.state = {};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update state so the next render shows the fallback UI.
|
|
103
|
+
*/
|
|
104
|
+
static getDerivedStateFromError(error) {
|
|
105
|
+
return {
|
|
106
|
+
error
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Lifecycle method called when an error is caught.
|
|
111
|
+
* You can log the error or perform side effects here.
|
|
112
|
+
*/
|
|
113
|
+
componentDidCatch(error, info) {
|
|
114
|
+
if (this.props.onError) {
|
|
115
|
+
this.props.onError(error, info);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
if (this.state.error) {
|
|
120
|
+
return this.props.fallback(this.state.error);
|
|
121
|
+
}
|
|
122
|
+
return this.props.children;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
96
126
|
const NestedView = (props) => {
|
|
97
127
|
const app = React.useContext(RouterContext);
|
|
98
128
|
const layer = React.useContext(RouterLayerContext);
|
|
@@ -108,7 +138,11 @@ const NestedView = (props) => {
|
|
|
108
138
|
},
|
|
109
139
|
[app]
|
|
110
140
|
);
|
|
111
|
-
|
|
141
|
+
if (!app) {
|
|
142
|
+
throw new Error("NestedView must be used within a RouterContext.");
|
|
143
|
+
}
|
|
144
|
+
const element = view ?? props.children ?? null;
|
|
145
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { fallback: app.context.onError, children: element });
|
|
112
146
|
};
|
|
113
147
|
|
|
114
148
|
class RedirectionError extends Error {
|
|
@@ -133,7 +167,7 @@ class PageDescriptorProvider {
|
|
|
133
167
|
}
|
|
134
168
|
throw new Error(`Page ${name} not found`);
|
|
135
169
|
}
|
|
136
|
-
root(state, context
|
|
170
|
+
root(state, context) {
|
|
137
171
|
return React.createElement(
|
|
138
172
|
RouterContext.Provider,
|
|
139
173
|
{
|
|
@@ -151,6 +185,7 @@ class PageDescriptorProvider {
|
|
|
151
185
|
const layers = [];
|
|
152
186
|
let context = {};
|
|
153
187
|
const stack = [{ route }];
|
|
188
|
+
let onError = this.renderError;
|
|
154
189
|
let parent = route.parent;
|
|
155
190
|
while (parent) {
|
|
156
191
|
stack.unshift({ route: parent });
|
|
@@ -222,7 +257,6 @@ class PageDescriptorProvider {
|
|
|
222
257
|
return {
|
|
223
258
|
layers: [],
|
|
224
259
|
redirect: typeof e.page === "string" ? e.page : this.href(e.page),
|
|
225
|
-
head: request.head,
|
|
226
260
|
pathname,
|
|
227
261
|
search
|
|
228
262
|
};
|
|
@@ -249,13 +283,12 @@ class PageDescriptorProvider {
|
|
|
249
283
|
acc += "/";
|
|
250
284
|
acc += it.route.path ? this.compile(it.route.path, params) : "";
|
|
251
285
|
const path = acc.replace(/\/+/, "/");
|
|
286
|
+
const localErrorHandler = this.getErrorHandler(it.route);
|
|
287
|
+
if (localErrorHandler) {
|
|
288
|
+
onError = localErrorHandler;
|
|
289
|
+
}
|
|
252
290
|
if (it.error) {
|
|
253
|
-
const
|
|
254
|
-
const element = await (errorHandler ? errorHandler({
|
|
255
|
-
...it.config,
|
|
256
|
-
error: it.error,
|
|
257
|
-
url: ""
|
|
258
|
-
}) : this.renderError(it.error));
|
|
291
|
+
const element = await onError(it.error);
|
|
259
292
|
layers.push({
|
|
260
293
|
props,
|
|
261
294
|
error: it.error,
|
|
@@ -282,7 +315,7 @@ class PageDescriptorProvider {
|
|
|
282
315
|
path
|
|
283
316
|
});
|
|
284
317
|
}
|
|
285
|
-
return { layers,
|
|
318
|
+
return { layers, pathname, search };
|
|
286
319
|
}
|
|
287
320
|
getErrorHandler(route) {
|
|
288
321
|
if (route.errorHandler) return route.errorHandler;
|
|
@@ -499,10 +532,17 @@ class BrowserRouterProvider extends router.RouterProvider {
|
|
|
499
532
|
const state = {
|
|
500
533
|
pathname,
|
|
501
534
|
search,
|
|
502
|
-
layers: []
|
|
503
|
-
|
|
535
|
+
layers: []
|
|
536
|
+
};
|
|
537
|
+
const context = {
|
|
538
|
+
url,
|
|
539
|
+
query: {},
|
|
540
|
+
params: {},
|
|
541
|
+
head: {},
|
|
542
|
+
onError: () => null,
|
|
543
|
+
...options.context ?? {}
|
|
504
544
|
};
|
|
505
|
-
await this.alepha.emit("react:transition:begin", { state });
|
|
545
|
+
await this.alepha.emit("react:transition:begin", { state, context });
|
|
506
546
|
try {
|
|
507
547
|
const previous = options.previous;
|
|
508
548
|
const { route, params } = this.match(pathname);
|
|
@@ -512,29 +552,22 @@ class BrowserRouterProvider extends router.RouterProvider {
|
|
|
512
552
|
query[key] = String(value);
|
|
513
553
|
}
|
|
514
554
|
}
|
|
555
|
+
context.query = query;
|
|
556
|
+
context.params = params ?? {};
|
|
557
|
+
context.previous = previous;
|
|
515
558
|
if (isPageRoute(route)) {
|
|
516
559
|
const result = await this.pageDescriptorProvider.createLayers(
|
|
517
560
|
route.page,
|
|
518
|
-
|
|
519
|
-
url,
|
|
520
|
-
params: params ?? {},
|
|
521
|
-
query,
|
|
522
|
-
previous,
|
|
523
|
-
...state,
|
|
524
|
-
head: state.head,
|
|
525
|
-
...options.context ?? {}
|
|
526
|
-
}
|
|
561
|
+
context
|
|
527
562
|
);
|
|
528
563
|
if (result.redirect) {
|
|
529
564
|
return {
|
|
530
|
-
element: null,
|
|
531
|
-
layers: [],
|
|
532
565
|
redirect: result.redirect,
|
|
533
|
-
|
|
566
|
+
state,
|
|
567
|
+
context
|
|
534
568
|
};
|
|
535
569
|
}
|
|
536
570
|
state.layers = result.layers;
|
|
537
|
-
state.head = result.head;
|
|
538
571
|
}
|
|
539
572
|
if (state.layers.length === 0) {
|
|
540
573
|
state.layers.push({
|
|
@@ -557,33 +590,25 @@ class BrowserRouterProvider extends router.RouterProvider {
|
|
|
557
590
|
];
|
|
558
591
|
await this.alepha.emit("react:transition:error", {
|
|
559
592
|
error: e,
|
|
560
|
-
state
|
|
593
|
+
state,
|
|
594
|
+
context
|
|
561
595
|
});
|
|
562
596
|
}
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
return {
|
|
568
|
-
element: this.root(state, options.context),
|
|
569
|
-
layers: state.layers,
|
|
570
|
-
head: state.head
|
|
571
|
-
};
|
|
597
|
+
if (options.state) {
|
|
598
|
+
options.state.layers = state.layers;
|
|
599
|
+
options.state.pathname = state.pathname;
|
|
600
|
+
options.state.search = state.search;
|
|
572
601
|
}
|
|
573
|
-
options.state.layers = state.layers;
|
|
574
|
-
options.state.pathname = state.pathname;
|
|
575
|
-
options.state.search = state.search;
|
|
576
|
-
options.state.head = state.head;
|
|
577
602
|
await this.alepha.emit("react:transition:end", {
|
|
578
|
-
state: options.state
|
|
603
|
+
state: options.state,
|
|
604
|
+
context
|
|
579
605
|
});
|
|
580
606
|
return {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
head: state.head
|
|
607
|
+
context,
|
|
608
|
+
state
|
|
584
609
|
};
|
|
585
610
|
}
|
|
586
|
-
root(state, context
|
|
611
|
+
root(state, context) {
|
|
587
612
|
return this.pageDescriptorProvider.root(state, context);
|
|
588
613
|
}
|
|
589
614
|
}
|
|
@@ -603,8 +628,7 @@ class ReactBrowserProvider {
|
|
|
603
628
|
state = {
|
|
604
629
|
layers: [],
|
|
605
630
|
pathname: "",
|
|
606
|
-
search: ""
|
|
607
|
-
head: {}
|
|
631
|
+
search: ""
|
|
608
632
|
};
|
|
609
633
|
get document() {
|
|
610
634
|
return window.document;
|
|
@@ -645,8 +669,8 @@ class ReactBrowserProvider {
|
|
|
645
669
|
const result = await this.render({
|
|
646
670
|
url
|
|
647
671
|
});
|
|
648
|
-
if (result.url !== url) {
|
|
649
|
-
this.history.replaceState({}, "", result.url);
|
|
672
|
+
if (result.context.url.pathname !== url) {
|
|
673
|
+
this.history.replaceState({}, "", result.context.url.pathname);
|
|
650
674
|
return;
|
|
651
675
|
}
|
|
652
676
|
if (options.replace) {
|
|
@@ -670,7 +694,7 @@ class ReactBrowserProvider {
|
|
|
670
694
|
return await this.render({ url: result.redirect });
|
|
671
695
|
}
|
|
672
696
|
this.transitioning = void 0;
|
|
673
|
-
return
|
|
697
|
+
return result;
|
|
674
698
|
}
|
|
675
699
|
/**
|
|
676
700
|
* Get embedded layers from the server.
|
|
@@ -711,14 +735,16 @@ class ReactBrowserProvider {
|
|
|
711
735
|
const hydration = this.getHydrationState();
|
|
712
736
|
const previous = hydration?.layers ?? [];
|
|
713
737
|
if (hydration?.links) {
|
|
714
|
-
|
|
738
|
+
for (const link of hydration.links) {
|
|
739
|
+
this.client.pushLink(link);
|
|
740
|
+
}
|
|
715
741
|
}
|
|
716
|
-
const {
|
|
717
|
-
if (head) {
|
|
718
|
-
this.headProvider.renderHead(this.document, head);
|
|
742
|
+
const { context } = await this.render({ previous });
|
|
743
|
+
if (context.head) {
|
|
744
|
+
this.headProvider.renderHead(this.document, context.head);
|
|
719
745
|
}
|
|
720
|
-
const context = {};
|
|
721
746
|
await this.alepha.emit("react:browser:render", {
|
|
747
|
+
state: this.state,
|
|
722
748
|
context,
|
|
723
749
|
hydration
|
|
724
750
|
});
|
|
@@ -734,17 +760,12 @@ class ReactBrowserProvider {
|
|
|
734
760
|
window.addEventListener("popstate", () => {
|
|
735
761
|
this.render();
|
|
736
762
|
});
|
|
737
|
-
this.alepha.on("react:transition:end", {
|
|
738
|
-
callback: ({ state }) => {
|
|
739
|
-
this.headProvider.renderHead(this.document, state.head);
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
763
|
}
|
|
743
764
|
});
|
|
744
765
|
onTransitionEnd = core.$hook({
|
|
745
766
|
name: "react:transition:end",
|
|
746
|
-
handler: async ({
|
|
747
|
-
this.headProvider.renderHead(this.document,
|
|
767
|
+
handler: async ({ context }) => {
|
|
768
|
+
this.headProvider.renderHead(this.document, context.head);
|
|
748
769
|
}
|
|
749
770
|
});
|
|
750
771
|
}
|
|
@@ -810,19 +831,10 @@ class RouterHookApi {
|
|
|
810
831
|
}
|
|
811
832
|
return pathname.startsWith("/") ? pathname : `${layer.path}/${pathname}`.replace(/\/\/+/g, "/");
|
|
812
833
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
* @param path
|
|
816
|
-
* @param options
|
|
817
|
-
*/
|
|
818
|
-
async go(path, options = {}) {
|
|
819
|
-
return await this.browser?.go(this.createHref(path, this.layer), options);
|
|
834
|
+
async go(path, options) {
|
|
835
|
+
await this.browser?.go(this.createHref(path, this.layer), options);
|
|
820
836
|
}
|
|
821
|
-
|
|
822
|
-
*
|
|
823
|
-
* @param path
|
|
824
|
-
*/
|
|
825
|
-
createAnchorProps(path) {
|
|
837
|
+
anchor(path) {
|
|
826
838
|
const href = this.createHref(path, this.layer);
|
|
827
839
|
return {
|
|
828
840
|
href,
|
|
@@ -840,14 +852,8 @@ class RouterHookApi {
|
|
|
840
852
|
* @param options
|
|
841
853
|
*/
|
|
842
854
|
setQueryParams(record, options = {}) {
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
...this.query,
|
|
846
|
-
...record
|
|
847
|
-
} : {
|
|
848
|
-
...record
|
|
849
|
-
}
|
|
850
|
-
).toString();
|
|
855
|
+
const func = typeof record === "function" ? record : () => record;
|
|
856
|
+
const search = new URLSearchParams(func(this.query)).toString();
|
|
851
857
|
const state = search ? `${this.pathname}?${search}` : this.pathname;
|
|
852
858
|
if (options.push) {
|
|
853
859
|
window.history.pushState({}, "", state);
|
|
@@ -885,7 +891,7 @@ const Link = (props) => {
|
|
|
885
891
|
}
|
|
886
892
|
const name = typeof props.to === "string" ? void 0 : props.to[core.OPTIONS].name;
|
|
887
893
|
const router = useRouter();
|
|
888
|
-
return /* @__PURE__ */ jsxRuntime.jsx("a", { ...router.
|
|
894
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { ...router.anchor(to), ...props, children: props.children ?? name });
|
|
889
895
|
};
|
|
890
896
|
|
|
891
897
|
const useInject = (clazz) => {
|
|
@@ -893,12 +899,7 @@ const useInject = (clazz) => {
|
|
|
893
899
|
if (!ctx) {
|
|
894
900
|
throw new Error("useRouter must be used within a <RouterProvider>");
|
|
895
901
|
}
|
|
896
|
-
return React.useMemo(
|
|
897
|
-
() => ctx.alepha.get(clazz, {
|
|
898
|
-
skipRegistration: true
|
|
899
|
-
}),
|
|
900
|
-
[]
|
|
901
|
-
);
|
|
902
|
+
return React.useMemo(() => ctx.alepha.get(clazz), []);
|
|
902
903
|
};
|
|
903
904
|
|
|
904
905
|
const useClient = () => {
|
|
@@ -926,12 +927,9 @@ const useQueryParams = (schema, options = {}) => {
|
|
|
926
927
|
queryParams,
|
|
927
928
|
(queryParams2) => {
|
|
928
929
|
setQueryParams(queryParams2);
|
|
929
|
-
router.setQueryParams(
|
|
930
|
-
{ [key]: encode(ctx.alepha, schema, queryParams2) }
|
|
931
|
-
|
|
932
|
-
merge: true
|
|
933
|
-
}
|
|
934
|
-
);
|
|
930
|
+
router.setQueryParams((data) => {
|
|
931
|
+
return { ...data, [key]: encode(ctx.alepha, schema, queryParams2) };
|
|
932
|
+
});
|
|
935
933
|
}
|
|
936
934
|
];
|
|
937
935
|
};
|
|
@@ -999,6 +997,7 @@ const useActive = (path) => {
|
|
|
999
997
|
|
|
1000
998
|
exports.$page = $page;
|
|
1001
999
|
exports.BrowserRouterProvider = BrowserRouterProvider;
|
|
1000
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
1002
1001
|
exports.Link = Link;
|
|
1003
1002
|
exports.NestedView = NestedView;
|
|
1004
1003
|
exports.PageDescriptorProvider = PageDescriptorProvider;
|
|
@@ -1016,4 +1015,4 @@ exports.useQueryParams = useQueryParams;
|
|
|
1016
1015
|
exports.useRouter = useRouter;
|
|
1017
1016
|
exports.useRouterEvents = useRouterEvents;
|
|
1018
1017
|
exports.useRouterState = useRouterState;
|
|
1019
|
-
//# sourceMappingURL=useActive-
|
|
1018
|
+
//# sourceMappingURL=useActive-DjpZBEuB.cjs.map
|