@vobs/router 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -588,7 +588,9 @@ function RouterView(props = {}) {
588
588
  const route = router.currentRoute.value;
589
589
  const view = router.getViewState(route);
590
590
  routeRetry = view.retry;
591
- if (view.status === "loading") return props.loading?.() ?? null;
591
+ if (view.status === "loading") {
592
+ return (typeof props.loading === "function" ? props.loading() : props.loading) ?? null;
593
+ }
592
594
  if (view.status === "not-found") return props.notFound?.(route) ?? null;
593
595
  if (view.status === "error") {
594
596
  throw view.error ?? new Error("\u8DEF\u7531\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/debug.ts"],"sourcesContent":["import { state, type Signal } from '@vobs/reactivity'\nimport {\n createComponent,\n createFragment,\n createInjectionKey,\n inject,\n insertBoundary,\n type InjectionKey,\n type VobsNode,\n type VobsPlugin\n} from '@vobs/vobs'\nimport {\n createRouterDebugId,\n emitRouterDebug\n} from './debug'\nimport {\n getRuntimeDebugContext,\n runWithRuntimeDebugContext,\n type RuntimeDebugContext\n} from '@vobs/runtime'\n\nexport { createRouterDebugId, emitRouterDebug, subscribeRouterDebug } from './debug'\nexport type { RouterDebugEvent, RouterDebugEventType } from './debug'\n\nexport type RouteParams = Readonly<Record<string, string>>\nexport type RouteQueryValue = string | readonly string[]\nexport type RouteQuery = Readonly<Record<string, RouteQueryValue>>\nexport type RouteMeta = Readonly<Record<string, unknown>>\n\nexport interface RouteLocation {\n readonly path: string\n readonly fullPath: string\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly hash: string\n readonly name: string | undefined\n readonly meta: RouteMeta\n readonly record: RouteRecord | null\n readonly matched: readonly RouteRecord[]\n readonly state?: unknown\n}\n\nexport interface RouteComponentProps {\n readonly route: RouteLocation\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly children?: VobsNode\n}\n\nexport type RouteComponent = (props: RouteComponentProps) => VobsNode\nexport type RouteComponentModule = RouteComponent | { default: RouteComponent }\nexport type RouteComponentLoader = () => PromiseLike<RouteComponentModule>\n\nexport interface LazyRouteComponent {\n readonly kind: 'vobs-lazy-route'\n readonly load: RouteComponentLoader\n}\n\nexport type RouteComponentDefinition = RouteComponent | LazyRouteComponent\n\nexport interface RouteLoaderContext {\n readonly route: RouteLocation\n readonly navigationId?: number\n readonly dataRequestId?: number\n}\n\nexport type RouteLoader = (context: RouteLoaderContext) => unknown | PromiseLike<unknown>\n\nexport interface RouteRecord {\n readonly path?: string\n readonly component?: RouteComponentDefinition\n readonly source?: string\n readonly name?: string\n readonly meta?: Record<string, unknown>\n readonly loader?: RouteLoader\n readonly action?: RouteLoader\n readonly children?: readonly RouteRecord[]\n}\n\nexport type RouteQueryInput = Record<string, unknown> | URLSearchParams\n\nexport interface RouteLocationRaw {\n readonly path?: string\n readonly name?: string\n readonly params?: Record<string, unknown>\n readonly query?: RouteQueryInput\n readonly hash?: string\n readonly state?: unknown\n}\n\nexport type RouteTarget = string | RouteLocationRaw\n\nexport type NavigationGuardResult = void | boolean | RouteTarget\nexport type NavigationGuard = (\n to: RouteLocation,\n from: RouteLocation\n) => NavigationGuardResult | PromiseLike<NavigationGuardResult>\n\nexport class NavigationCancelledError extends Error {\n readonly code = 'NAVIGATION_CANCELLED'\n\n constructor() {\n super('Vobs Router: 导航已被更新的导航取消')\n this.name = 'NavigationCancelledError'\n }\n}\n\nexport class NavigationRedirectError extends Error {\n readonly code = 'NAVIGATION_REDIRECT_LIMIT'\n\n constructor() {\n super('Vobs Router: 导航重定向超过最大次数')\n this.name = 'NavigationRedirectError'\n }\n}\n\nexport interface RouterHistory {\n readonly location: string\n /** 当前 history 条目携带的导航 state(push/replace 时写入,popstate/初始启动时回读)。 */\n readonly state?: unknown\n push(path: string, state?: unknown): void\n replace(path: string, state?: unknown): void\n back(): void\n listen(listener: (path: string, state: unknown) => void): () => void\n}\n\nexport interface RouterOptions {\n readonly routes: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport interface RouterViewState {\n readonly status: 'ready' | 'loading' | 'error' | 'not-found'\n readonly component?: RouteComponent\n readonly layouts?: readonly RouteComponent[]\n readonly error?: Error\n readonly retry: () => void\n}\n\nexport interface RouteDebugNode {\n readonly id: string\n readonly path: string\n readonly name?: string\n readonly component: string\n readonly lazy: boolean\n readonly loader: boolean\n readonly action: boolean\n readonly status: 'ready' | 'loading' | 'error'\n readonly meta: RouteMeta\n readonly source?: string\n readonly children: readonly RouteDebugNode[]\n}\n\nexport interface RouteErrorTrace {\n readonly id: number\n readonly phase: 'navigation' | 'render' | 'lazy' | 'loader' | 'action' | 'fetcher'\n readonly route: string\n readonly message: string\n readonly stack?: string\n readonly timestamp: number\n readonly requestId?: number\n readonly navigationId?: number\n}\n\nexport interface NavigationTrace {\n readonly id: number\n readonly from: string\n readonly to: string\n readonly status: 'success' | 'redirected' | 'cancelled' | 'error'\n readonly source: 'push' | 'replace' | 'history'\n readonly startedAt: number\n readonly endedAt: number\n readonly duration: number\n readonly redirect?: string\n readonly error?: string\n}\n\nexport interface NavigationState {\n readonly status: 'idle' | 'loading' | 'error'\n readonly from: string\n readonly to: string\n readonly traceId?: number\n readonly error?: string\n}\n\nexport interface RouterPerformanceMetrics {\n readonly navigationCount: number\n readonly averageNavigationDuration: number\n readonly slowNavigationCount: number\n}\n\nexport type RouterDataRequestKind = 'loader' | 'action' | 'fetcher'\n\nexport interface RouterDataRequestTrace {\n readonly id: number\n readonly kind: RouterDataRequestKind\n readonly key: string\n readonly route?: string\n readonly status: 'loading' | 'success' | 'error' | 'cancelled'\n readonly startedAt: number\n readonly endedAt?: number\n readonly duration?: number\n readonly result?: unknown\n readonly error?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport interface RouterDataRequestOptions {\n readonly route?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport type RouterDevToolsEvent = 'navigation:start' | 'navigation:end' | 'route:update' | 'data-request' | 'error'\n\nexport interface RouterDevToolsAPI {\n getRouteTree(): readonly RouteDebugNode[]\n getCurrentRoute(): RouteLocation\n getNavigationState(): NavigationState\n getNavigationHistory(): readonly NavigationTrace[]\n getPerformanceMetrics(): RouterPerformanceMetrics\n getDataRequests(): readonly RouterDataRequestTrace[]\n getErrors(): readonly RouteErrorTrace[]\n trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: () => T | PromiseLike<T>,\n options?: RouterDataRequestOptions | string\n ): Promise<T>\n runAction<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n runFetcher<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n reportError(phase: RouteErrorTrace['phase'], error: unknown, route?: string, context?: { readonly requestId?: number; readonly navigationId?: number }): void\n revalidate(route?: string): Promise<void>\n subscribe(event: RouterDevToolsEvent, callback: (payload: unknown) => void): () => void\n}\n\nexport interface Router {\n readonly currentRoute: Signal<RouteLocation>\n readonly history: RouterHistory\n resolve(to: RouteTarget): RouteLocation\n push(to: RouteTarget): Promise<RouteLocation | false>\n replace(to: RouteTarget): Promise<RouteLocation | false>\n back(): void\n beforeEach(guard: NavigationGuard): () => void\n getViewState(route: RouteLocation): RouterViewState\n readonly devtools: RouterDevToolsAPI\n destroy(): void\n}\n\nexport interface RouterViewProps {\n readonly router?: Router\n readonly loading?: () => VobsNode | null | undefined\n readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined\n readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined\n}\n\nexport interface RouterPluginOptions {\n readonly router?: Router\n readonly routes?: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport const ROUTER_KEY: InjectionKey<Router> = createInjectionKey<Router>('vobs.router')\n\nexport function lazy(loader: RouteComponentLoader): LazyRouteComponent {\n return {\n kind: 'vobs-lazy-route',\n load: loader\n }\n}\n\nexport function createMemoryHistory(initial = '/'): RouterHistory {\n let entries = [{ path: normalizeHistoryPath(initial), state: undefined as unknown }]\n let index = 0\n const listeners = new Set<(path: string, state: unknown) => void>()\n\n return {\n get location(): string {\n return entries[index]!.path\n },\n\n get state(): unknown {\n return entries[index]!.state\n },\n\n push(path: string, state?: unknown): void {\n const next = normalizeHistoryPath(path)\n entries = entries.slice(0, index + 1)\n entries.push({ path: next, state })\n index++\n },\n\n replace(path: string, state?: unknown): void {\n entries[index] = { path: normalizeHistoryPath(path), state }\n },\n\n back(): void {\n if (index === 0) return\n index--\n notifyListeners(listeners, entries[index]!.path, entries[index]!.state)\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }\n }\n}\n\nexport function createBrowserHistory(base = ''): RouterHistory {\n if (typeof window === 'undefined') {\n throw new Error('Vobs Router: createBrowserHistory 需要浏览器环境')\n }\n\n const normalizedBase = normalizeBase(base)\n const listeners = new Set<(path: string, state: unknown) => void>()\n const onPopState = (event: PopStateEvent): void => {\n notifyListeners(listeners, readBrowserLocation(normalizedBase), event.state)\n }\n\n return {\n get location(): string {\n return readBrowserLocation(normalizedBase)\n },\n\n get state(): unknown {\n return window.history.state\n },\n\n push(path: string, state?: unknown): void {\n window.history.pushState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n replace(path: string, state?: unknown): void {\n window.history.replaceState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n back(): void {\n window.history.back()\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n if (listeners.size === 0) window.addEventListener('popstate', onPopState)\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n if (listeners.size === 0) window.removeEventListener('popstate', onPopState)\n }\n }\n }\n}\n\nexport function createRouter(options: RouterOptions): Router {\n const matchers = normalizeRoutes(options.routes)\n const history = options.history ?? defaultHistory()\n const routerDebugId = createRouterDebugId()\n matchers.sort(compareMatchers)\n const currentRoute = state<RouteLocation>(resolvePath(history.location))\n const lazyStates = new Map<RouteRecord, LazyState>()\n const guards: NavigationGuard[] = []\n const navigationHistory: NavigationTrace[] = []\n const dataRequests: RouterDataRequestTrace[] = []\n const errors: RouteErrorTrace[] = []\n const dataLoaders = new Map<string, { kind: RouterDataRequestKind; route: string; task: () => unknown | PromiseLike<unknown> }>()\n const dataRequestContexts = new Map<number, RuntimeDebugContext>()\n const routerListeners = new Map<RouterDevToolsEvent, Set<(payload: unknown) => void>>()\n let navigationState: NavigationState = { status: 'idle', from: currentRoute.value.fullPath, to: currentRoute.value.fullPath }\n let navigationCount = 0\n let totalNavigationDuration = 0\n let slowNavigationCount = 0\n let nextDataRequestId = 1\n let nextErrorId = 1\n let navigationId = 0\n let destroyed = false\n const viewRevision = state(0)\n\n function resolve(to: RouteTarget): RouteLocation {\n ensureActive()\n const target = typeof to === 'string' ? parseTargetString(to) : normalizeTarget(to, matchers)\n return resolvePath(buildTargetPath(target.path, target.query, target.hash), target.state)\n }\n\n function resolvePath(rawPath: string, state?: unknown): RouteLocation {\n const parsed = parseTargetString(rawPath)\n const matched = matchers.find(matcher => matcher.regex.exec(parsed.path))\n const params = matched ? extractParams(matched, parsed.path) : {}\n const record = matched?.record ?? null\n const query = parsed.query\n const hash = parsed.hash\n return {\n path: parsed.path,\n fullPath: buildTargetPath(parsed.path, query, hash),\n params,\n query,\n hash,\n name: record?.name,\n meta: matched?.meta ?? {},\n record,\n matched: matched?.chain ?? EMPTY_MATCHED,\n state\n }\n }\n\n async function navigate(\n to: RouteTarget,\n replaceHistory: boolean,\n fromHistory: boolean,\n historyState?: unknown\n ): Promise<RouteLocation | false> {\n ensureActive()\n const id = ++navigationId\n const from = currentRoute.value\n let target = resolve(to)\n // popstate 回读的 state 保存在 history 条目上,不在目标描述里,这里回填。\n if (fromHistory && historyState !== undefined) target = { ...target, state: historyState }\n const source: NavigationTrace['source'] = fromHistory ? 'history' : replaceHistory ? 'replace' : 'push'\n const startedAt = now()\n const initialTarget = target.fullPath\n let terminalRecorded = false\n navigationState = { status: 'loading', from: from.fullPath, to: target.fullPath, traceId: id }\n emitRouter('navigation:start', navigationState)\n if (target.fullPath === from.fullPath && !fromHistory) {\n navigationState = { status: 'idle', from: from.fullPath, to: target.fullPath }\n return from\n }\n\n try {\n for (let redirectCount = 0; ; redirectCount++) {\n ensureNavigationIsCurrent(id)\n let redirect: RouteTarget | undefined\n for (const guard of [...guards]) {\n let result: NavigationGuardResult\n try {\n result = await guard(target, from)\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) throw reason\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw reason\n }\n ensureNavigationIsCurrent(id)\n if (result === false) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n return false\n }\n if (typeof result === 'string' || isRouteLocationRaw(result)) {\n redirect = result\n break\n }\n }\n\n for (const record of target.matched) {\n if (!record.loader) continue\n // 上一 loader 期间被新导航抢占时立即取消,跳过剩余 loader。\n ensureNavigationIsCurrent(id)\n await trackDataRequest(\n 'loader',\n `${target.fullPath}#${record.path ?? record.name ?? 'route'}`,\n context => record.loader!({ route: target, navigationId: id, dataRequestId: context.dataRequestId }),\n { route: target.fullPath, navigationId: id, trigger: 'navigation' }\n )\n }\n\n // loader 完成后、提交前必须重新校验:飞行期间被抢占的导航不允许覆盖 currentRoute 与 history。\n ensureNavigationIsCurrent(id)\n\n if (redirect !== undefined) {\n if (redirectCount >= 10) {\n const error = new NavigationRedirectError()\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw error\n }\n const redirected = resolve(redirect)\n if (redirected.fullPath === target.fullPath) return false\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'redirected', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: redirected.fullPath })\n target = redirected\n continue\n }\n\n if (target.fullPath === from.fullPath) return from\n if (!fromHistory) {\n if (replaceHistory) history.replace(target.fullPath, target.state)\n else history.push(target.fullPath, target.state)\n }\n currentRoute.value = target\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'success', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: target.fullPath !== initialTarget ? target.fullPath : undefined })\n terminalRecorded = true\n return target\n }\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n } else if (!terminalRecorded) {\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n }\n throw reason\n }\n }\n\n function now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n }\n\n function emitRouter(event: RouterDevToolsEvent, payload: unknown): void {\n for (const callback of routerListeners.get(event) ?? []) {\n try { callback(payload) } catch { /* diagnostics must not affect navigation */ }\n }\n emitRouterDebug(routerDebugId, event, payload, getRuntimeDebugContext() ?? undefined)\n }\n\n function recordNavigation(trace: NavigationTrace): void {\n navigationHistory.push(Object.freeze(trace))\n if (navigationHistory.length > 100) navigationHistory.shift()\n navigationCount++\n totalNavigationDuration += trace.duration\n if (trace.duration >= 16) slowNavigationCount++\n if (trace.id === navigationId) {\n navigationState = trace.status === 'error'\n ? { status: 'error', from: trace.from, to: trace.to, traceId: trace.id, error: trace.error }\n : { status: 'idle', from: trace.from, to: trace.to, traceId: trace.id }\n }\n emitRouter('navigation:end', trace)\n emitRouter('route:update', currentRoute.value)\n }\n\n async function trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: ((context: { readonly dataRequestId: number }) => T | PromiseLike<T>) | (() => T | PromiseLike<T>),\n optionsOrRoute: RouterDataRequestOptions | string = {}\n ): Promise<T> {\n ensureActive()\n const options = typeof optionsOrRoute === 'string' ? { route: optionsOrRoute } : optionsOrRoute\n const id = nextDataRequestId++\n const startedAt = now()\n const context = getRuntimeDebugContext()\n const route = options.route ?? currentRoute.value.fullPath\n const requestContext: RuntimeDebugContext = {\n ...context,\n environment: options.environment ?? context?.environment,\n route,\n navigationId: options.navigationId ?? context?.navigationId,\n dataRequestId: id,\n source: kind\n }\n const loading: RouterDataRequestTrace = {\n id,\n kind,\n key,\n route,\n status: 'loading',\n startedAt,\n navigationId: requestContext.navigationId,\n trigger: options.trigger,\n environment: requestContext.environment\n }\n dataRequests.push(loading)\n if (dataRequests.length > 100) dataRequests.shift()\n dataRequestContexts.set(id, requestContext)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', loading)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'start', trace: loading }, requestContext)\n dataLoaders.set(key, { kind, route, task: task as () => unknown | PromiseLike<unknown> })\n try {\n const result = await runWithRuntimeDebugContext(requestContext, () => (task as (context: { readonly dataRequestId: number }) => T | PromiseLike<T>)({ dataRequestId: id }))\n const endedAt = now()\n replaceDataRequest(id, { ...loading, status: 'success', endedAt, duration: endedAt - startedAt, result })\n return result\n } catch (reason) {\n const endedAt = now()\n const error = toError(reason)\n const status = isAbortError(reason) ? 'cancelled' : 'error'\n if (status === 'error') reportError(kind, error, route, { requestId: id, navigationId: requestContext.navigationId })\n replaceDataRequest(id, { ...loading, status, endedAt, duration: endedAt - startedAt, error: status === 'error' ? error.message : undefined })\n throw reason\n }\n }\n\n function replaceDataRequest(id: number, trace: RouterDataRequestTrace): void {\n const index = dataRequests.findIndex(item => item.id === id)\n if (index >= 0) dataRequests[index] = Object.freeze(trace)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', trace)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'end', trace }, dataRequestContexts.get(id))\n dataRequestContexts.delete(id)\n }\n\n function reportError(\n phase: RouteErrorTrace['phase'],\n reason: unknown,\n route = currentRoute.value.fullPath,\n context: { readonly requestId?: number; readonly navigationId?: number } = {}\n ): void {\n const error = toError(reason)\n errors.push(Object.freeze({\n id: nextErrorId++,\n phase,\n route,\n message: error.message,\n stack: error.stack,\n timestamp: now(),\n requestId: context.requestId,\n navigationId: context.navigationId\n }))\n if (errors.length > 100) errors.shift()\n emitRouter('error', errors[errors.length - 1]!)\n emitRouter('route:update', currentRoute.value)\n }\n\n function routeTree(): readonly RouteDebugNode[] {\n const statuses = new Map<string, LazyState['status']>()\n for (const matcher of matchers) {\n for (const record of matcher.chain) {\n if (record.component && isLazyRouteComponent(record.component)) {\n const debugId = routeDebugIds.get(record)\n if (debugId) statuses.set(debugId, lazyStates.get(record)?.status ?? 'loading')\n }\n }\n }\n return buildRouteDebugTree(options.routes, statuses)\n }\n\n function handleHistoryNavigation(path: string, state: unknown): void {\n void navigate(path, false, true, state).then(result => {\n if (destroyed) return\n if (result === false) {\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n } else if (result.fullPath !== normalizeHistoryPath(path)) {\n history.replace(result.fullPath, result.state)\n }\n }).catch(error => {\n if (!(error instanceof NavigationCancelledError) && !destroyed) {\n const current = currentRoute.value.fullPath\n const failed = toError(error)\n reportError('navigation', failed, normalizeHistoryPath(path))\n navigationState = { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message }\n emitRouter('navigation:end', { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message })\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n }\n })\n }\n\n const stopHistory = history.listen(handleHistoryNavigation)\n\n const router: Router = {\n currentRoute,\n history,\n\n resolve,\n\n push(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, false, false)\n },\n\n replace(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, true, false)\n },\n\n back(): void {\n ensureActive()\n history.back()\n },\n\n beforeEach(guard: NavigationGuard): () => void {\n ensureActive()\n guards.push(guard)\n return () => {\n const index = guards.indexOf(guard)\n if (index >= 0) guards.splice(index, 1)\n }\n },\n\n getViewState(route: RouteLocation): RouterViewState {\n viewRevision.value\n const records = route.matched.length > 0 ? route.matched : route.record ? [route.record] : []\n const entries = records\n .map(record => ({ record, definition: record.component }))\n .filter((entry): entry is { record: RouteRecord; definition: RouteComponentDefinition } =>\n isRouteComponentDefinition(entry.definition))\n if (!route.record || entries.length === 0) return { status: 'not-found', retry: () => undefined }\n\n const loaded: RouteComponent[] = []\n const lazyRecords: RouteRecord[] = []\n for (const entry of entries) {\n const { record, definition } = entry\n if (!isLazyRouteComponent(definition)) {\n loaded.push(definition)\n continue\n }\n lazyRecords.push(record)\n const lazyState = ensureLazyState(record, definition)\n if (lazyState.status === 'loading') return { status: 'loading', retry: () => retryLazyRoutes(lazyRecords) }\n if (lazyState.status === 'error') {\n return { status: 'error', error: lazyState.error, retry: () => retryLazyRoutes(lazyRecords) }\n }\n if (lazyState.component) loaded.push(lazyState.component)\n }\n\n const component = loaded[loaded.length - 1]\n if (!component) return { status: 'not-found', retry: () => undefined }\n return {\n status: 'ready',\n component,\n layouts: loaded.slice(0, -1),\n retry: () => retryLazyRoutes(lazyRecords)\n }\n },\n\n devtools: {\n getRouteTree: routeTree,\n getCurrentRoute: () => currentRoute.value,\n getNavigationState: () => navigationState,\n getNavigationHistory: () => [...navigationHistory],\n getPerformanceMetrics: () => ({\n navigationCount,\n averageNavigationDuration: navigationCount === 0 ? 0 : totalNavigationDuration / navigationCount,\n slowNavigationCount\n }),\n getDataRequests: () => [...dataRequests],\n getErrors: () => [...errors],\n trackDataRequest,\n runAction: (key, task) => trackDataRequest('action', key, task, { trigger: 'manual' }),\n runFetcher: (key, task) => trackDataRequest('fetcher', key, task, { trigger: 'manual' }),\n reportError,\n revalidate: async (route) => {\n await Promise.all([...dataLoaders.entries()]\n .filter(([, loader]) => loader.kind === 'loader' && (route === undefined || loader.route === route))\n .map(([key, loader]) => trackDataRequest(loader.kind, key, loader.task, { route: loader.route, trigger: 'revalidate' })))\n },\n subscribe(event, callback) {\n let listeners = routerListeners.get(event)\n if (!listeners) { listeners = new Set(); routerListeners.set(event, listeners) }\n listeners.add(callback)\n return () => listeners?.delete(callback)\n }\n },\n\n destroy(): void {\n if (destroyed) return\n destroyed = true\n navigationId++\n stopHistory()\n guards.length = 0\n routerListeners.clear()\n lazyStates.clear()\n errors.length = 0\n dataRequestContexts.clear()\n currentRoute.dispose()\n viewRevision.dispose()\n }\n }\n\n function ensureLazyState(record: RouteRecord, definition: LazyRouteComponent): LazyState {\n let lazyState = lazyStates.get(record)\n if (!lazyState) {\n lazyState = { status: 'loading' }\n lazyStates.set(record, lazyState)\n void loadRouteComponent(definition).then(component => {\n if (destroyed) return\n lazyState!.status = 'ready'\n lazyState!.component = component\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n }).catch(reason => {\n if (destroyed) return\n lazyState!.status = 'error'\n lazyState!.error = toError(reason)\n reportError('lazy', reason, currentRoute.value.fullPath)\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n })\n }\n return lazyState\n }\n\n function retryLazyRoutes(records: readonly RouteRecord[]): void {\n for (const record of records) lazyStates.delete(record)\n viewRevision.value++\n }\n\n function ensureActive(): void {\n if (destroyed) throw new Error('Vobs Router: 已销毁的 Router 不能继续使用')\n }\n\n function ensureNavigationIsCurrent(id: number): void {\n if (id !== navigationId) throw new NavigationCancelledError()\n }\n\n return router\n}\n\nexport function RouterView(props: RouterViewProps = {}): VobsNode {\n const router = props.router ?? inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: RouterView 找不到 Router,请安装 routerPlugin')\n\n return createFragment((parent, anchor) => {\n let routeRetry: () => void = () => undefined\n insertBoundary(parent, anchor, {\n resetKey: () => router.currentRoute.value.fullPath,\n onRetry: () => routeRetry(),\n fallback: (error, retry) => {\n router.devtools.reportError('render', error, router.currentRoute.value.fullPath)\n return props.error?.(error, () => { void retry() }) ?? null\n },\n children: () => {\n const route = router.currentRoute.value\n const view = router.getViewState(route)\n routeRetry = view.retry\n if (view.status === 'loading') return props.loading?.() ?? null\n if (view.status === 'not-found') return props.notFound?.(route) ?? null\n if (view.status === 'error') {\n throw view.error ?? new Error('路由组件加载失败')\n }\n if (!view.component) return null\n let node = createComponent(view.component, {\n route,\n params: route.params,\n query: route.query\n })\n for (let index = (view.layouts?.length ?? 0) - 1; index >= 0; index--) {\n node = createComponent(view.layouts![index]!, {\n route,\n params: route.params,\n query: route.query,\n children: node\n })\n }\n return node\n }})\n })\n}\n\nexport function useRouter(): Router {\n const router = inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: useRouter 找不到 Router,请安装 routerPlugin')\n return router\n}\n\nexport function useRoute(): Signal<RouteLocation> {\n return useRouter().currentRoute\n}\n\nexport function routerPlugin(options: RouterPluginOptions = {}): VobsPlugin {\n return {\n name: '@vobs/router',\n version: '0.1.0',\n install(context) {\n const ownedRouter = options.router ? undefined : createRouter({\n routes: options.routes ?? [],\n history: options.history\n })\n const router = options.router ?? ownedRouter!\n context.provide(ROUTER_KEY, router)\n return () => ownedRouter?.destroy()\n }\n }\n}\n\ninterface RouteMatcher {\n readonly record: RouteRecord\n readonly debugId: string\n readonly chain: readonly RouteRecord[]\n readonly meta: RouteMeta\n readonly regex: RegExp\n readonly keys: readonly string[]\n readonly score: number\n readonly order: number\n}\n\ninterface LazyState {\n status: 'loading' | 'ready' | 'error'\n component?: RouteComponent\n error?: Error\n}\n\ninterface ParsedTarget {\n readonly path: string\n readonly query: RouteQuery\n readonly hash: string\n readonly state?: unknown\n}\n\nfunction defaultHistory(): RouterHistory {\n return typeof window === 'undefined' ? createMemoryHistory('/') : createBrowserHistory()\n}\n\nconst EMPTY_MATCHED: readonly RouteRecord[] = Object.freeze([])\nconst routeDebugIds = new WeakMap<RouteRecord, string>()\n\nfunction buildRouteDebugTree(routes: readonly RouteRecord[], lazyStatuses: ReadonlyMap<string, LazyState['status']> = new Map()): readonly RouteDebugNode[] {\n const visit = (records: readonly RouteRecord[], parentPath: string, parentId: string): RouteDebugNode[] => records.map((record, index) => {\n const path = record.path === undefined ? parentPath || '/' : resolveChildPath(parentPath, record.path)\n const id = `${parentId}.${index}`\n const definition = record.component\n const lazyDefinition = definition !== undefined && isLazyRouteComponent(definition)\n const componentName = definition === undefined\n ? 'Route'\n : lazyDefinition\n ? 'lazy(...)'\n : typeof definition === 'function'\n ? definition.name || 'Anonymous'\n : 'Route'\n return {\n id,\n path,\n name: record.name,\n component: componentName,\n source: record.source,\n lazy: lazyDefinition,\n loader: record.loader !== undefined,\n action: record.action !== undefined,\n status: lazyDefinition ? (lazyStatuses.get(id) ?? 'loading') : 'ready',\n meta: Object.freeze({ ...(record.meta ?? {}) }),\n children: visit(record.children ?? [], path, id)\n }\n })\n return Object.freeze(visit(routes, '', 'route'))\n}\n\nfunction normalizeRoutes(routes: readonly RouteRecord[]): RouteMatcher[] {\n const matchers: RouteMatcher[] = []\n let order = 0\n\n function visit(records: readonly RouteRecord[], parentPath: string, parentChain: readonly RouteRecord[], parentMeta: RouteMeta, parentId = 'route'): void {\n records.forEach((record, index) => {\n const debugId = `${parentId}.${index}`\n const children = record.children ?? []\n const path = record.path === undefined\n ? parentPath\n : resolveChildPath(parentPath, record.path)\n const normalized: RouteRecord = {\n ...record,\n path: record.path === undefined\n ? (children.length > 0 ? undefined : (path || '/'))\n : path,\n meta: record.meta ? { ...record.meta } : {}\n }\n routeDebugIds.set(normalized, debugId)\n const chain = [...parentChain, normalized]\n const meta = Object.freeze({ ...parentMeta, ...(normalized.meta ?? {}) })\n if (children.length > 0) {\n visit(children, path, chain, meta, debugId)\n } else if (normalized.component) {\n matchers.push(createMatcher(normalized, chain, meta, order++, debugId))\n } else if (normalized.path === undefined) {\n throw new Error(`Vobs Router: 第 ${index + 1} 个路由缺少 path 或 children`)\n }\n })\n }\n\n visit(routes, '', [], {})\n return matchers\n}\n\nfunction resolveChildPath(parentPath: string, childPath: string): string {\n const normalizedChild = normalizePath(childPath)\n if (!parentPath || normalizedChild === '/') return normalizedChild === '/' ? (parentPath || '/') : normalizedChild\n if (childPath.startsWith('/')) return normalizedChild\n return normalizePath(`${parentPath}/${childPath}`)\n}\n\nfunction createMatcher(record: RouteRecord, chain: readonly RouteRecord[], meta: RouteMeta, order: number, debugId: string): RouteMatcher {\n const path = record.path ?? '/'\n const segments = path === '/' ? [] : path.slice(1).split('/')\n const keys: string[] = []\n let score = 0\n const pattern = segments.map(segment => {\n if (segment === '*') {\n keys.push('pathMatch')\n return '(.*)'\n }\n if (segment.startsWith(':')) {\n const key = segment.slice(1)\n if (!key) throw new Error(`Vobs Router: 路由 ${path} 的参数名不能为空`)\n if (keys.includes(key)) throw new Error(`Vobs Router: 路由 ${path} 存在重复参数 ${key}`)\n keys.push(key)\n score += 1\n return '([^/]+)'\n }\n score += 3\n return escapeRegExp(segment)\n }).join('/')\n\n return {\n record,\n debugId,\n chain: Object.freeze([...chain]),\n meta,\n regex: new RegExp(segments.length === 0 ? '^/?$' : `^/${pattern}/?$`),\n keys,\n score,\n order\n }\n}\n\nfunction compareMatchers(left: RouteMatcher, right: RouteMatcher): number {\n return right.score - left.score || left.order - right.order\n}\n\nfunction extractParams(matcher: RouteMatcher, path: string): RouteParams {\n const match = matcher.regex.exec(path)\n if (!match) return {}\n const params: Record<string, string> = {}\n matcher.keys.forEach((key, index) => {\n params[key] = decodeRoutePart(match[index + 1] ?? '')\n })\n return Object.freeze(params)\n}\n\nfunction parseTargetString(raw: string): ParsedTarget {\n const hashIndex = raw.indexOf('#')\n const hash = hashIndex >= 0 ? normalizeHash(raw.slice(hashIndex + 1)) : ''\n const withoutHash = hashIndex >= 0 ? raw.slice(0, hashIndex) : raw\n const queryIndex = withoutHash.indexOf('?')\n const path = normalizePath(queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash)\n const query = queryIndex >= 0 ? parseQuery(withoutHash.slice(queryIndex + 1)) : {}\n return { path, query, hash }\n}\n\nfunction normalizeTarget(target: RouteLocationRaw, matchers: readonly RouteMatcher[]): ParsedTarget {\n let path = target.path\n if (!path && target.name) {\n const matcher = matchers.find(candidate => candidate.record.name === target.name)\n if (!matcher) throw new Error(`Vobs Router: 找不到名为 ${target.name} 的路由`)\n path = fillRouteParams(matcher.record.path ?? '/', target.params ?? {})\n }\n if (!path) throw new Error('Vobs Router: 导航目标必须提供 path 或 name')\n\n const parsed = parseTargetString(path)\n const filledPath = fillRouteParams(parsed.path, target.params ?? {})\n const query = target.query === undefined ? parsed.query : normalizeQuery(target.query)\n const hash = target.hash === undefined ? parsed.hash : normalizeHash(target.hash)\n return { path: filledPath, query, hash, state: target.state }\n}\n\nfunction fillRouteParams(path: string, params: Record<string, unknown>): string {\n return path.replace(/:([A-Za-z0-9_]+)|\\*/g, (token, key: string | undefined) => {\n const value = key ? params[key] : params.pathMatch\n if (value === undefined || value === null) return token\n return encodeURIComponent(String(value))\n })\n}\n\nfunction buildTargetPath(path: string, query: RouteQuery, hash: string): string {\n const params = new URLSearchParams()\n for (const key of Object.keys(query).sort()) {\n const value = query[key]\n if (typeof value === 'string') {\n params.set(key, value)\n } else {\n for (const item of value) params.append(key, item)\n }\n }\n const serialized = params.toString()\n return `${path}${serialized ? `?${serialized}` : ''}${hash}`\n}\n\nfunction parseQuery(raw: string): RouteQuery {\n const params = new URLSearchParams(raw)\n const result: Record<string, RouteQueryValue> = {}\n params.forEach((value, key) => {\n const previous = result[key]\n if (previous === undefined) result[key] = value\n else if (typeof previous === 'string') result[key] = [previous, value]\n else result[key] = [...previous, value]\n })\n for (const key of Object.keys(result)) {\n if (Array.isArray(result[key])) result[key] = Object.freeze(result[key] as string[])\n }\n return Object.freeze(result)\n}\n\nfunction normalizeQuery(input: RouteQueryInput): RouteQuery {\n if (input instanceof URLSearchParams) return parseQuery(input.toString())\n const result: Record<string, RouteQueryValue> = {}\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null) continue\n if (Array.isArray(value)) result[key] = Object.freeze(value.map(item => String(item)))\n else result[key] = String(value)\n }\n return Object.freeze(result)\n}\n\nfunction normalizePath(path: string): string {\n if (!path) return '/'\n const withoutQuery = path.split(/[?#]/, 1)[0] || '/'\n const withLeadingSlash = withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}`\n if (withLeadingSlash === '/*' || withLeadingSlash === '/') return withLeadingSlash\n return withLeadingSlash.replace(/\\/+/g, '/').replace(/\\/$/, '') || '/'\n}\n\nfunction normalizeHistoryPath(path: string): string {\n const parsed = parseTargetString(path)\n return buildTargetPath(parsed.path, parsed.query, parsed.hash)\n}\n\nfunction normalizeHash(hash: string): string {\n if (!hash) return ''\n return hash.startsWith('#') ? hash : `#${hash}`\n}\n\nfunction normalizeBase(base: string): string {\n if (!base || base === '/') return ''\n return `/${base.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nfunction readBrowserLocation(base: string): string {\n const pathname = window.location.pathname\n const path = base && (pathname === base || pathname.startsWith(`${base}/`))\n ? pathname.slice(base.length) || '/'\n : pathname\n return normalizeHistoryPath(`${path}${window.location.search}${window.location.hash}`)\n}\n\nfunction withBase(path: string, base: string): string {\n return `${base}${path === '/' ? '/' : path}` || '/'\n}\n\nfunction notifyListeners(listeners: Set<(path: string, state: unknown) => void>, path: string, state: unknown): void {\n for (const listener of [...listeners]) listener(path, state)\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction decodeRoutePart(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\nfunction isLazyRouteComponent(value: RouteComponentDefinition): value is LazyRouteComponent {\n return typeof value === 'object' && value !== null && value.kind === 'vobs-lazy-route'\n}\n\nfunction isRouteComponentDefinition(value: unknown): value is RouteComponentDefinition {\n return typeof value === 'function' || isLazyRouteComponent(value as RouteComponentDefinition)\n}\n\nasync function loadRouteComponent(loader: LazyRouteComponent): Promise<RouteComponent> {\n const module = await loader.load()\n const component = typeof module === 'function' ? module : module.default\n if (typeof component !== 'function') throw new Error('Vobs Router: 懒加载模块没有默认组件导出')\n return component\n}\n\nfunction isRouteLocationRaw(value: unknown): value is RouteLocationRaw {\n return Boolean(value) && typeof value === 'object'\n}\n\nfunction toError(reason: unknown): Error {\n return reason instanceof Error ? reason : new Error(String(reason))\n}\n\nfunction isAbortError(reason: unknown): boolean {\n return Boolean(reason) && typeof reason === 'object'\n && ((reason as { readonly name?: unknown }).name === 'AbortError'\n || (reason as { readonly code?: unknown }).code === 'ERR_CANCELED')\n}\n","import type { RuntimeDebugContext } from '@vobs/runtime'\n\nexport type RouterDebugEventType =\n | 'navigation:start'\n | 'navigation:end'\n | 'route:update'\n | 'data-request'\n | 'error'\n\nexport interface RouterDebugEvent {\n readonly routerId: string\n readonly type: RouterDebugEventType\n readonly payload: unknown\n readonly context?: RuntimeDebugContext\n}\n\ntype RouterDebugListener = (event: RouterDebugEvent) => void\n\nconst listeners = new Set<RouterDebugListener>()\nlet nextRouterId = 1\n\nexport function createRouterDebugId(): string {\n return `router-${nextRouterId++}`\n}\n\nexport function subscribeRouterDebug(listener: RouterDebugListener): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nexport function emitRouterDebug(\n routerId: string,\n type: RouterDebugEventType,\n payload: unknown,\n context?: RuntimeDebugContext\n): void {\n const event: RouterDebugEvent = { routerId, type, payload, context }\n for (const listener of [...listeners]) {\n try { listener(event) } catch { /* diagnostics must not affect navigation */ }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAmC;AACnC,kBASO;;;ACQP,IAAM,YAAY,oBAAI,IAAyB;AAC/C,IAAI,eAAe;AAEZ,SAAS,sBAA8B;A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AM,CAAC;AACpE;AAFS;AAIT,SAAS,aAAa,QAA0B;AAC9C,SAAO,QAAQ,MAAM,KAAK,OAAO,WAAW,aACrC,OAAuC,SAAS,gBAC/C,OAAuC,SAAS;AAC1D;AAJS;","names":["import_runtime","listeners","state","options","module"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/debug.ts"],"sourcesContent":["import { state, type Signal } from '@vobs/reactivity'\nimport {\n createComponent,\n createFragment,\n createInjectionKey,\n inject,\n insertBoundary,\n type InjectionKey,\n type VobsNode,\n type VobsPlugin\n} from '@vobs/vobs'\nimport {\n createRouterDebugId,\n emitRouterDebug\n} from './debug'\nimport {\n getRuntimeDebugContext,\n runWithRuntimeDebugContext,\n type RuntimeDebugContext\n} from '@vobs/runtime'\n\nexport { createRouterDebugId, emitRouterDebug, subscribeRouterDebug } from './debug'\nexport type { RouterDebugEvent, RouterDebugEventType } from './debug'\n\nexport type RouteParams = Readonly<Record<string, string>>\nexport type RouteQueryValue = string | readonly string[]\nexport type RouteQuery = Readonly<Record<string, RouteQueryValue>>\nexport type RouteMeta = Readonly<Record<string, unknown>>\n\nexport interface RouteLocation {\n readonly path: string\n readonly fullPath: string\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly hash: string\n readonly name: string | undefined\n readonly meta: RouteMeta\n readonly record: RouteRecord | null\n readonly matched: readonly RouteRecord[]\n readonly state?: unknown\n}\n\nexport interface RouteComponentProps {\n readonly route: RouteLocation\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly children?: VobsNode\n}\n\nexport type RouteComponent = (props: RouteComponentProps) => VobsNode\nexport type RouteComponentModule = RouteComponent | { default: RouteComponent }\nexport type RouteComponentLoader = () => PromiseLike<RouteComponentModule>\n\nexport interface LazyRouteComponent {\n readonly kind: 'vobs-lazy-route'\n readonly load: RouteComponentLoader\n}\n\nexport type RouteComponentDefinition = RouteComponent | LazyRouteComponent\n\nexport interface RouteLoaderContext {\n readonly route: RouteLocation\n readonly navigationId?: number\n readonly dataRequestId?: number\n}\n\nexport type RouteLoader = (context: RouteLoaderContext) => unknown | PromiseLike<unknown>\n\nexport interface RouteRecord {\n readonly path?: string\n readonly component?: RouteComponentDefinition\n readonly source?: string\n readonly name?: string\n readonly meta?: Record<string, unknown>\n readonly loader?: RouteLoader\n readonly action?: RouteLoader\n readonly children?: readonly RouteRecord[]\n}\n\nexport type RouteQueryInput = Record<string, unknown> | URLSearchParams\n\nexport interface RouteLocationRaw {\n readonly path?: string\n readonly name?: string\n readonly params?: Record<string, unknown>\n readonly query?: RouteQueryInput\n readonly hash?: string\n readonly state?: unknown\n}\n\nexport type RouteTarget = string | RouteLocationRaw\n\nexport type NavigationGuardResult = void | boolean | RouteTarget\nexport type NavigationGuard = (\n to: RouteLocation,\n from: RouteLocation\n) => NavigationGuardResult | PromiseLike<NavigationGuardResult>\n\nexport class NavigationCancelledError extends Error {\n readonly code = 'NAVIGATION_CANCELLED'\n\n constructor() {\n super('Vobs Router: 导航已被更新的导航取消')\n this.name = 'NavigationCancelledError'\n }\n}\n\nexport class NavigationRedirectError extends Error {\n readonly code = 'NAVIGATION_REDIRECT_LIMIT'\n\n constructor() {\n super('Vobs Router: 导航重定向超过最大次数')\n this.name = 'NavigationRedirectError'\n }\n}\n\nexport interface RouterHistory {\n readonly location: string\n /** 当前 history 条目携带的导航 state(push/replace 时写入,popstate/初始启动时回读)。 */\n readonly state?: unknown\n push(path: string, state?: unknown): void\n replace(path: string, state?: unknown): void\n back(): void\n listen(listener: (path: string, state: unknown) => void): () => void\n}\n\nexport interface RouterOptions {\n readonly routes: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport interface RouterViewState {\n readonly status: 'ready' | 'loading' | 'error' | 'not-found'\n readonly component?: RouteComponent\n readonly layouts?: readonly RouteComponent[]\n readonly error?: Error\n readonly retry: () => void\n}\n\nexport interface RouteDebugNode {\n readonly id: string\n readonly path: string\n readonly name?: string\n readonly component: string\n readonly lazy: boolean\n readonly loader: boolean\n readonly action: boolean\n readonly status: 'ready' | 'loading' | 'error'\n readonly meta: RouteMeta\n readonly source?: string\n readonly children: readonly RouteDebugNode[]\n}\n\nexport interface RouteErrorTrace {\n readonly id: number\n readonly phase: 'navigation' | 'render' | 'lazy' | 'loader' | 'action' | 'fetcher'\n readonly route: string\n readonly message: string\n readonly stack?: string\n readonly timestamp: number\n readonly requestId?: number\n readonly navigationId?: number\n}\n\nexport interface NavigationTrace {\n readonly id: number\n readonly from: string\n readonly to: string\n readonly status: 'success' | 'redirected' | 'cancelled' | 'error'\n readonly source: 'push' | 'replace' | 'history'\n readonly startedAt: number\n readonly endedAt: number\n readonly duration: number\n readonly redirect?: string\n readonly error?: string\n}\n\nexport interface NavigationState {\n readonly status: 'idle' | 'loading' | 'error'\n readonly from: string\n readonly to: string\n readonly traceId?: number\n readonly error?: string\n}\n\nexport interface RouterPerformanceMetrics {\n readonly navigationCount: number\n readonly averageNavigationDuration: number\n readonly slowNavigationCount: number\n}\n\nexport type RouterDataRequestKind = 'loader' | 'action' | 'fetcher'\n\nexport interface RouterDataRequestTrace {\n readonly id: number\n readonly kind: RouterDataRequestKind\n readonly key: string\n readonly route?: string\n readonly status: 'loading' | 'success' | 'error' | 'cancelled'\n readonly startedAt: number\n readonly endedAt?: number\n readonly duration?: number\n readonly result?: unknown\n readonly error?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport interface RouterDataRequestOptions {\n readonly route?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport type RouterDevToolsEvent = 'navigation:start' | 'navigation:end' | 'route:update' | 'data-request' | 'error'\n\nexport interface RouterDevToolsAPI {\n getRouteTree(): readonly RouteDebugNode[]\n getCurrentRoute(): RouteLocation\n getNavigationState(): NavigationState\n getNavigationHistory(): readonly NavigationTrace[]\n getPerformanceMetrics(): RouterPerformanceMetrics\n getDataRequests(): readonly RouterDataRequestTrace[]\n getErrors(): readonly RouteErrorTrace[]\n trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: () => T | PromiseLike<T>,\n options?: RouterDataRequestOptions | string\n ): Promise<T>\n runAction<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n runFetcher<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n reportError(phase: RouteErrorTrace['phase'], error: unknown, route?: string, context?: { readonly requestId?: number; readonly navigationId?: number }): void\n revalidate(route?: string): Promise<void>\n subscribe(event: RouterDevToolsEvent, callback: (payload: unknown) => void): () => void\n}\n\nexport interface Router {\n readonly currentRoute: Signal<RouteLocation>\n readonly history: RouterHistory\n resolve(to: RouteTarget): RouteLocation\n push(to: RouteTarget): Promise<RouteLocation | false>\n replace(to: RouteTarget): Promise<RouteLocation | false>\n back(): void\n beforeEach(guard: NavigationGuard): () => void\n getViewState(route: RouteLocation): RouterViewState\n readonly devtools: RouterDevToolsAPI\n destroy(): void\n}\n\nexport interface RouterViewProps {\n readonly router?: Router\n /** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */\n readonly loading?: VobsNode | (() => VobsNode | null | undefined)\n readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined\n readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined\n}\n\nexport interface RouterPluginOptions {\n readonly router?: Router\n readonly routes?: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport const ROUTER_KEY: InjectionKey<Router> = createInjectionKey<Router>('vobs.router')\n\nexport function lazy(loader: RouteComponentLoader): LazyRouteComponent {\n return {\n kind: 'vobs-lazy-route',\n load: loader\n }\n}\n\nexport function createMemoryHistory(initial = '/'): RouterHistory {\n let entries = [{ path: normalizeHistoryPath(initial), state: undefined as unknown }]\n let index = 0\n const listeners = new Set<(path: string, state: unknown) => void>()\n\n return {\n get location(): string {\n return entries[index]!.path\n },\n\n get state(): unknown {\n return entries[index]!.state\n },\n\n push(path: string, state?: unknown): void {\n const next = normalizeHistoryPath(path)\n entries = entries.slice(0, index + 1)\n entries.push({ path: next, state })\n index++\n },\n\n replace(path: string, state?: unknown): void {\n entries[index] = { path: normalizeHistoryPath(path), state }\n },\n\n back(): void {\n if (index === 0) return\n index--\n notifyListeners(listeners, entries[index]!.path, entries[index]!.state)\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }\n }\n}\n\nexport function createBrowserHistory(base = ''): RouterHistory {\n if (typeof window === 'undefined') {\n throw new Error('Vobs Router: createBrowserHistory 需要浏览器环境')\n }\n\n const normalizedBase = normalizeBase(base)\n const listeners = new Set<(path: string, state: unknown) => void>()\n const onPopState = (event: PopStateEvent): void => {\n notifyListeners(listeners, readBrowserLocation(normalizedBase), event.state)\n }\n\n return {\n get location(): string {\n return readBrowserLocation(normalizedBase)\n },\n\n get state(): unknown {\n return window.history.state\n },\n\n push(path: string, state?: unknown): void {\n window.history.pushState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n replace(path: string, state?: unknown): void {\n window.history.replaceState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n back(): void {\n window.history.back()\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n if (listeners.size === 0) window.addEventListener('popstate', onPopState)\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n if (listeners.size === 0) window.removeEventListener('popstate', onPopState)\n }\n }\n }\n}\n\nexport function createRouter(options: RouterOptions): Router {\n const matchers = normalizeRoutes(options.routes)\n const history = options.history ?? defaultHistory()\n const routerDebugId = createRouterDebugId()\n matchers.sort(compareMatchers)\n const currentRoute = state<RouteLocation>(resolvePath(history.location))\n const lazyStates = new Map<RouteRecord, LazyState>()\n const guards: NavigationGuard[] = []\n const navigationHistory: NavigationTrace[] = []\n const dataRequests: RouterDataRequestTrace[] = []\n const errors: RouteErrorTrace[] = []\n const dataLoaders = new Map<string, { kind: RouterDataRequestKind; route: string; task: () => unknown | PromiseLike<unknown> }>()\n const dataRequestContexts = new Map<number, RuntimeDebugContext>()\n const routerListeners = new Map<RouterDevToolsEvent, Set<(payload: unknown) => void>>()\n let navigationState: NavigationState = { status: 'idle', from: currentRoute.value.fullPath, to: currentRoute.value.fullPath }\n let navigationCount = 0\n let totalNavigationDuration = 0\n let slowNavigationCount = 0\n let nextDataRequestId = 1\n let nextErrorId = 1\n let navigationId = 0\n let destroyed = false\n const viewRevision = state(0)\n\n function resolve(to: RouteTarget): RouteLocation {\n ensureActive()\n const target = typeof to === 'string' ? parseTargetString(to) : normalizeTarget(to, matchers)\n return resolvePath(buildTargetPath(target.path, target.query, target.hash), target.state)\n }\n\n function resolvePath(rawPath: string, state?: unknown): RouteLocation {\n const parsed = parseTargetString(rawPath)\n const matched = matchers.find(matcher => matcher.regex.exec(parsed.path))\n const params = matched ? extractParams(matched, parsed.path) : {}\n const record = matched?.record ?? null\n const query = parsed.query\n const hash = parsed.hash\n return {\n path: parsed.path,\n fullPath: buildTargetPath(parsed.path, query, hash),\n params,\n query,\n hash,\n name: record?.name,\n meta: matched?.meta ?? {},\n record,\n matched: matched?.chain ?? EMPTY_MATCHED,\n state\n }\n }\n\n async function navigate(\n to: RouteTarget,\n replaceHistory: boolean,\n fromHistory: boolean,\n historyState?: unknown\n ): Promise<RouteLocation | false> {\n ensureActive()\n const id = ++navigationId\n const from = currentRoute.value\n let target = resolve(to)\n // popstate 回读的 state 保存在 history 条目上,不在目标描述里,这里回填。\n if (fromHistory && historyState !== undefined) target = { ...target, state: historyState }\n const source: NavigationTrace['source'] = fromHistory ? 'history' : replaceHistory ? 'replace' : 'push'\n const startedAt = now()\n const initialTarget = target.fullPath\n let terminalRecorded = false\n navigationState = { status: 'loading', from: from.fullPath, to: target.fullPath, traceId: id }\n emitRouter('navigation:start', navigationState)\n if (target.fullPath === from.fullPath && !fromHistory) {\n navigationState = { status: 'idle', from: from.fullPath, to: target.fullPath }\n return from\n }\n\n try {\n for (let redirectCount = 0; ; redirectCount++) {\n ensureNavigationIsCurrent(id)\n let redirect: RouteTarget | undefined\n for (const guard of [...guards]) {\n let result: NavigationGuardResult\n try {\n result = await guard(target, from)\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) throw reason\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw reason\n }\n ensureNavigationIsCurrent(id)\n if (result === false) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n return false\n }\n if (typeof result === 'string' || isRouteLocationRaw(result)) {\n redirect = result\n break\n }\n }\n\n for (const record of target.matched) {\n if (!record.loader) continue\n // 上一 loader 期间被新导航抢占时立即取消,跳过剩余 loader。\n ensureNavigationIsCurrent(id)\n await trackDataRequest(\n 'loader',\n `${target.fullPath}#${record.path ?? record.name ?? 'route'}`,\n context => record.loader!({ route: target, navigationId: id, dataRequestId: context.dataRequestId }),\n { route: target.fullPath, navigationId: id, trigger: 'navigation' }\n )\n }\n\n // loader 完成后、提交前必须重新校验:飞行期间被抢占的导航不允许覆盖 currentRoute 与 history。\n ensureNavigationIsCurrent(id)\n\n if (redirect !== undefined) {\n if (redirectCount >= 10) {\n const error = new NavigationRedirectError()\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw error\n }\n const redirected = resolve(redirect)\n if (redirected.fullPath === target.fullPath) return false\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'redirected', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: redirected.fullPath })\n target = redirected\n continue\n }\n\n if (target.fullPath === from.fullPath) return from\n if (!fromHistory) {\n if (replaceHistory) history.replace(target.fullPath, target.state)\n else history.push(target.fullPath, target.state)\n }\n currentRoute.value = target\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'success', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: target.fullPath !== initialTarget ? target.fullPath : undefined })\n terminalRecorded = true\n return target\n }\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n } else if (!terminalRecorded) {\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n }\n throw reason\n }\n }\n\n function now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n }\n\n function emitRouter(event: RouterDevToolsEvent, payload: unknown): void {\n for (const callback of routerListeners.get(event) ?? []) {\n try { callback(payload) } catch { /* diagnostics must not affect navigation */ }\n }\n emitRouterDebug(routerDebugId, event, payload, getRuntimeDebugContext() ?? undefined)\n }\n\n function recordNavigation(trace: NavigationTrace): void {\n navigationHistory.push(Object.freeze(trace))\n if (navigationHistory.length > 100) navigationHistory.shift()\n navigationCount++\n totalNavigationDuration += trace.duration\n if (trace.duration >= 16) slowNavigationCount++\n if (trace.id === navigationId) {\n navigationState = trace.status === 'error'\n ? { status: 'error', from: trace.from, to: trace.to, traceId: trace.id, error: trace.error }\n : { status: 'idle', from: trace.from, to: trace.to, traceId: trace.id }\n }\n emitRouter('navigation:end', trace)\n emitRouter('route:update', currentRoute.value)\n }\n\n async function trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: ((context: { readonly dataRequestId: number }) => T | PromiseLike<T>) | (() => T | PromiseLike<T>),\n optionsOrRoute: RouterDataRequestOptions | string = {}\n ): Promise<T> {\n ensureActive()\n const options = typeof optionsOrRoute === 'string' ? { route: optionsOrRoute } : optionsOrRoute\n const id = nextDataRequestId++\n const startedAt = now()\n const context = getRuntimeDebugContext()\n const route = options.route ?? currentRoute.value.fullPath\n const requestContext: RuntimeDebugContext = {\n ...context,\n environment: options.environment ?? context?.environment,\n route,\n navigationId: options.navigationId ?? context?.navigationId,\n dataRequestId: id,\n source: kind\n }\n const loading: RouterDataRequestTrace = {\n id,\n kind,\n key,\n route,\n status: 'loading',\n startedAt,\n navigationId: requestContext.navigationId,\n trigger: options.trigger,\n environment: requestContext.environment\n }\n dataRequests.push(loading)\n if (dataRequests.length > 100) dataRequests.shift()\n dataRequestContexts.set(id, requestContext)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', loading)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'start', trace: loading }, requestContext)\n dataLoaders.set(key, { kind, route, task: task as () => unknown | PromiseLike<unknown> })\n try {\n const result = await runWithRuntimeDebugContext(requestContext, () => (task as (context: { readonly dataRequestId: number }) => T | PromiseLike<T>)({ dataRequestId: id }))\n const endedAt = now()\n replaceDataRequest(id, { ...loading, status: 'success', endedAt, duration: endedAt - startedAt, result })\n return result\n } catch (reason) {\n const endedAt = now()\n const error = toError(reason)\n const status = isAbortError(reason) ? 'cancelled' : 'error'\n if (status === 'error') reportError(kind, error, route, { requestId: id, navigationId: requestContext.navigationId })\n replaceDataRequest(id, { ...loading, status, endedAt, duration: endedAt - startedAt, error: status === 'error' ? error.message : undefined })\n throw reason\n }\n }\n\n function replaceDataRequest(id: number, trace: RouterDataRequestTrace): void {\n const index = dataRequests.findIndex(item => item.id === id)\n if (index >= 0) dataRequests[index] = Object.freeze(trace)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', trace)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'end', trace }, dataRequestContexts.get(id))\n dataRequestContexts.delete(id)\n }\n\n function reportError(\n phase: RouteErrorTrace['phase'],\n reason: unknown,\n route = currentRoute.value.fullPath,\n context: { readonly requestId?: number; readonly navigationId?: number } = {}\n ): void {\n const error = toError(reason)\n errors.push(Object.freeze({\n id: nextErrorId++,\n phase,\n route,\n message: error.message,\n stack: error.stack,\n timestamp: now(),\n requestId: context.requestId,\n navigationId: context.navigationId\n }))\n if (errors.length > 100) errors.shift()\n emitRouter('error', errors[errors.length - 1]!)\n emitRouter('route:update', currentRoute.value)\n }\n\n function routeTree(): readonly RouteDebugNode[] {\n const statuses = new Map<string, LazyState['status']>()\n for (const matcher of matchers) {\n for (const record of matcher.chain) {\n if (record.component && isLazyRouteComponent(record.component)) {\n const debugId = routeDebugIds.get(record)\n if (debugId) statuses.set(debugId, lazyStates.get(record)?.status ?? 'loading')\n }\n }\n }\n return buildRouteDebugTree(options.routes, statuses)\n }\n\n function handleHistoryNavigation(path: string, state: unknown): void {\n void navigate(path, false, true, state).then(result => {\n if (destroyed) return\n if (result === false) {\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n } else if (result.fullPath !== normalizeHistoryPath(path)) {\n history.replace(result.fullPath, result.state)\n }\n }).catch(error => {\n if (!(error instanceof NavigationCancelledError) && !destroyed) {\n const current = currentRoute.value.fullPath\n const failed = toError(error)\n reportError('navigation', failed, normalizeHistoryPath(path))\n navigationState = { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message }\n emitRouter('navigation:end', { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message })\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n }\n })\n }\n\n const stopHistory = history.listen(handleHistoryNavigation)\n\n const router: Router = {\n currentRoute,\n history,\n\n resolve,\n\n push(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, false, false)\n },\n\n replace(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, true, false)\n },\n\n back(): void {\n ensureActive()\n history.back()\n },\n\n beforeEach(guard: NavigationGuard): () => void {\n ensureActive()\n guards.push(guard)\n return () => {\n const index = guards.indexOf(guard)\n if (index >= 0) guards.splice(index, 1)\n }\n },\n\n getViewState(route: RouteLocation): RouterViewState {\n viewRevision.value\n const records = route.matched.length > 0 ? route.matched : route.record ? [route.record] : []\n const entries = records\n .map(record => ({ record, definition: record.component }))\n .filter((entry): entry is { record: RouteRecord; definition: RouteComponentDefinition } =>\n isRouteComponentDefinition(entry.definition))\n if (!route.record || entries.length === 0) return { status: 'not-found', retry: () => undefined }\n\n const loaded: RouteComponent[] = []\n const lazyRecords: RouteRecord[] = []\n for (const entry of entries) {\n const { record, definition } = entry\n if (!isLazyRouteComponent(definition)) {\n loaded.push(definition)\n continue\n }\n lazyRecords.push(record)\n const lazyState = ensureLazyState(record, definition)\n if (lazyState.status === 'loading') return { status: 'loading', retry: () => retryLazyRoutes(lazyRecords) }\n if (lazyState.status === 'error') {\n return { status: 'error', error: lazyState.error, retry: () => retryLazyRoutes(lazyRecords) }\n }\n if (lazyState.component) loaded.push(lazyState.component)\n }\n\n const component = loaded[loaded.length - 1]\n if (!component) return { status: 'not-found', retry: () => undefined }\n return {\n status: 'ready',\n component,\n layouts: loaded.slice(0, -1),\n retry: () => retryLazyRoutes(lazyRecords)\n }\n },\n\n devtools: {\n getRouteTree: routeTree,\n getCurrentRoute: () => currentRoute.value,\n getNavigationState: () => navigationState,\n getNavigationHistory: () => [...navigationHistory],\n getPerformanceMetrics: () => ({\n navigationCount,\n averageNavigationDuration: navigationCount === 0 ? 0 : totalNavigationDuration / navigationCount,\n slowNavigationCount\n }),\n getDataRequests: () => [...dataRequests],\n getErrors: () => [...errors],\n trackDataRequest,\n runAction: (key, task) => trackDataRequest('action', key, task, { trigger: 'manual' }),\n runFetcher: (key, task) => trackDataRequest('fetcher', key, task, { trigger: 'manual' }),\n reportError,\n revalidate: async (route) => {\n await Promise.all([...dataLoaders.entries()]\n .filter(([, loader]) => loader.kind === 'loader' && (route === undefined || loader.route === route))\n .map(([key, loader]) => trackDataRequest(loader.kind, key, loader.task, { route: loader.route, trigger: 'revalidate' })))\n },\n subscribe(event, callback) {\n let listeners = routerListeners.get(event)\n if (!listeners) { listeners = new Set(); routerListeners.set(event, listeners) }\n listeners.add(callback)\n return () => listeners?.delete(callback)\n }\n },\n\n destroy(): void {\n if (destroyed) return\n destroyed = true\n navigationId++\n stopHistory()\n guards.length = 0\n routerListeners.clear()\n lazyStates.clear()\n errors.length = 0\n dataRequestContexts.clear()\n currentRoute.dispose()\n viewRevision.dispose()\n }\n }\n\n function ensureLazyState(record: RouteRecord, definition: LazyRouteComponent): LazyState {\n let lazyState = lazyStates.get(record)\n if (!lazyState) {\n lazyState = { status: 'loading' }\n lazyStates.set(record, lazyState)\n void loadRouteComponent(definition).then(component => {\n if (destroyed) return\n lazyState!.status = 'ready'\n lazyState!.component = component\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n }).catch(reason => {\n if (destroyed) return\n lazyState!.status = 'error'\n lazyState!.error = toError(reason)\n reportError('lazy', reason, currentRoute.value.fullPath)\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n })\n }\n return lazyState\n }\n\n function retryLazyRoutes(records: readonly RouteRecord[]): void {\n for (const record of records) lazyStates.delete(record)\n viewRevision.value++\n }\n\n function ensureActive(): void {\n if (destroyed) throw new Error('Vobs Router: 已销毁的 Router 不能继续使用')\n }\n\n function ensureNavigationIsCurrent(id: number): void {\n if (id !== navigationId) throw new NavigationCancelledError()\n }\n\n return router\n}\n\nexport function RouterView(props: RouterViewProps = {}): VobsNode {\n const router = props.router ?? inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: RouterView 找不到 Router,请安装 routerPlugin')\n\n return createFragment((parent, anchor) => {\n let routeRetry: () => void = () => undefined\n insertBoundary(parent, anchor, {\n resetKey: () => router.currentRoute.value.fullPath,\n onRetry: () => routeRetry(),\n fallback: (error, retry) => {\n router.devtools.reportError('render', error, router.currentRoute.value.fullPath)\n return props.error?.(error, () => { void retry() }) ?? null\n },\n children: () => {\n const route = router.currentRoute.value\n const view = router.getViewState(route)\n routeRetry = view.retry\n if (view.status === 'loading') {\n return (typeof props.loading === 'function' ? props.loading() : props.loading) ?? null\n }\n if (view.status === 'not-found') return props.notFound?.(route) ?? null\n if (view.status === 'error') {\n throw view.error ?? new Error('路由组件加载失败')\n }\n if (!view.component) return null\n let node = createComponent(view.component, {\n route,\n params: route.params,\n query: route.query\n })\n for (let index = (view.layouts?.length ?? 0) - 1; index >= 0; index--) {\n node = createComponent(view.layouts![index]!, {\n route,\n params: route.params,\n query: route.query,\n children: node\n })\n }\n return node\n }})\n })\n}\n\nexport function useRouter(): Router {\n const router = inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: useRouter 找不到 Router,请安装 routerPlugin')\n return router\n}\n\nexport function useRoute(): Signal<RouteLocation> {\n return useRouter().currentRoute\n}\n\nexport function routerPlugin(options: RouterPluginOptions = {}): VobsPlugin {\n return {\n name: '@vobs/router',\n version: '0.1.0',\n install(context) {\n const ownedRouter = options.router ? undefined : createRouter({\n routes: options.routes ?? [],\n history: options.history\n })\n const router = options.router ?? ownedRouter!\n context.provide(ROUTER_KEY, router)\n return () => ownedRouter?.destroy()\n }\n }\n}\n\ninterface RouteMatcher {\n readonly record: RouteRecord\n readonly debugId: string\n readonly chain: readonly RouteRecord[]\n readonly meta: RouteMeta\n readonly regex: RegExp\n readonly keys: readonly string[]\n readonly score: number\n readonly order: number\n}\n\ninterface LazyState {\n status: 'loading' | 'ready' | 'error'\n component?: RouteComponent\n error?: Error\n}\n\ninterface ParsedTarget {\n readonly path: string\n readonly query: RouteQuery\n readonly hash: string\n readonly state?: unknown\n}\n\nfunction defaultHistory(): RouterHistory {\n return typeof window === 'undefined' ? createMemoryHistory('/') : createBrowserHistory()\n}\n\nconst EMPTY_MATCHED: readonly RouteRecord[] = Object.freeze([])\nconst routeDebugIds = new WeakMap<RouteRecord, string>()\n\nfunction buildRouteDebugTree(routes: readonly RouteRecord[], lazyStatuses: ReadonlyMap<string, LazyState['status']> = new Map()): readonly RouteDebugNode[] {\n const visit = (records: readonly RouteRecord[], parentPath: string, parentId: string): RouteDebugNode[] => records.map((record, index) => {\n const path = record.path === undefined ? parentPath || '/' : resolveChildPath(parentPath, record.path)\n const id = `${parentId}.${index}`\n const definition = record.component\n const lazyDefinition = definition !== undefined && isLazyRouteComponent(definition)\n const componentName = definition === undefined\n ? 'Route'\n : lazyDefinition\n ? 'lazy(...)'\n : typeof definition === 'function'\n ? definition.name || 'Anonymous'\n : 'Route'\n return {\n id,\n path,\n name: record.name,\n component: componentName,\n source: record.source,\n lazy: lazyDefinition,\n loader: record.loader !== undefined,\n action: record.action !== undefined,\n status: lazyDefinition ? (lazyStatuses.get(id) ?? 'loading') : 'ready',\n meta: Object.freeze({ ...(record.meta ?? {}) }),\n children: visit(record.children ?? [], path, id)\n }\n })\n return Object.freeze(visit(routes, '', 'route'))\n}\n\nfunction normalizeRoutes(routes: readonly RouteRecord[]): RouteMatcher[] {\n const matchers: RouteMatcher[] = []\n let order = 0\n\n function visit(records: readonly RouteRecord[], parentPath: string, parentChain: readonly RouteRecord[], parentMeta: RouteMeta, parentId = 'route'): void {\n records.forEach((record, index) => {\n const debugId = `${parentId}.${index}`\n const children = record.children ?? []\n const path = record.path === undefined\n ? parentPath\n : resolveChildPath(parentPath, record.path)\n const normalized: RouteRecord = {\n ...record,\n path: record.path === undefined\n ? (children.length > 0 ? undefined : (path || '/'))\n : path,\n meta: record.meta ? { ...record.meta } : {}\n }\n routeDebugIds.set(normalized, debugId)\n const chain = [...parentChain, normalized]\n const meta = Object.freeze({ ...parentMeta, ...(normalized.meta ?? {}) })\n if (children.length > 0) {\n visit(children, path, chain, meta, debugId)\n } else if (normalized.component) {\n matchers.push(createMatcher(normalized, chain, meta, order++, debugId))\n } else if (normalized.path === undefined) {\n throw new Error(`Vobs Router: 第 ${index + 1} 个路由缺少 path 或 children`)\n }\n })\n }\n\n visit(routes, '', [], {})\n return matchers\n}\n\nfunction resolveChildPath(parentPath: string, childPath: string): string {\n const normalizedChild = normalizePath(childPath)\n if (!parentPath || normalizedChild === '/') return normalizedChild === '/' ? (parentPath || '/') : normalizedChild\n if (childPath.startsWith('/')) return normalizedChild\n return normalizePath(`${parentPath}/${childPath}`)\n}\n\nfunction createMatcher(record: RouteRecord, chain: readonly RouteRecord[], meta: RouteMeta, order: number, debugId: string): RouteMatcher {\n const path = record.path ?? '/'\n const segments = path === '/' ? [] : path.slice(1).split('/')\n const keys: string[] = []\n let score = 0\n const pattern = segments.map(segment => {\n if (segment === '*') {\n keys.push('pathMatch')\n return '(.*)'\n }\n if (segment.startsWith(':')) {\n const key = segment.slice(1)\n if (!key) throw new Error(`Vobs Router: 路由 ${path} 的参数名不能为空`)\n if (keys.includes(key)) throw new Error(`Vobs Router: 路由 ${path} 存在重复参数 ${key}`)\n keys.push(key)\n score += 1\n return '([^/]+)'\n }\n score += 3\n return escapeRegExp(segment)\n }).join('/')\n\n return {\n record,\n debugId,\n chain: Object.freeze([...chain]),\n meta,\n regex: new RegExp(segments.length === 0 ? '^/?$' : `^/${pattern}/?$`),\n keys,\n score,\n order\n }\n}\n\nfunction compareMatchers(left: RouteMatcher, right: RouteMatcher): number {\n return right.score - left.score || left.order - right.order\n}\n\nfunction extractParams(matcher: RouteMatcher, path: string): RouteParams {\n const match = matcher.regex.exec(path)\n if (!match) return {}\n const params: Record<string, string> = {}\n matcher.keys.forEach((key, index) => {\n params[key] = decodeRoutePart(match[index + 1] ?? '')\n })\n return Object.freeze(params)\n}\n\nfunction parseTargetString(raw: string): ParsedTarget {\n const hashIndex = raw.indexOf('#')\n const hash = hashIndex >= 0 ? normalizeHash(raw.slice(hashIndex + 1)) : ''\n const withoutHash = hashIndex >= 0 ? raw.slice(0, hashIndex) : raw\n const queryIndex = withoutHash.indexOf('?')\n const path = normalizePath(queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash)\n const query = queryIndex >= 0 ? parseQuery(withoutHash.slice(queryIndex + 1)) : {}\n return { path, query, hash }\n}\n\nfunction normalizeTarget(target: RouteLocationRaw, matchers: readonly RouteMatcher[]): ParsedTarget {\n let path = target.path\n if (!path && target.name) {\n const matcher = matchers.find(candidate => candidate.record.name === target.name)\n if (!matcher) throw new Error(`Vobs Router: 找不到名为 ${target.name} 的路由`)\n path = fillRouteParams(matcher.record.path ?? '/', target.params ?? {})\n }\n if (!path) throw new Error('Vobs Router: 导航目标必须提供 path 或 name')\n\n const parsed = parseTargetString(path)\n const filledPath = fillRouteParams(parsed.path, target.params ?? {})\n const query = target.query === undefined ? parsed.query : normalizeQuery(target.query)\n const hash = target.hash === undefined ? parsed.hash : normalizeHash(target.hash)\n return { path: filledPath, query, hash, state: target.state }\n}\n\nfunction fillRouteParams(path: string, params: Record<string, unknown>): string {\n return path.replace(/:([A-Za-z0-9_]+)|\\*/g, (token, key: string | undefined) => {\n const value = key ? params[key] : params.pathMatch\n if (value === undefined || value === null) return token\n return encodeURIComponent(String(value))\n })\n}\n\nfunction buildTargetPath(path: string, query: RouteQuery, hash: string): string {\n const params = new URLSearchParams()\n for (const key of Object.keys(query).sort()) {\n const value = query[key]\n if (typeof value === 'string') {\n params.set(key, value)\n } else {\n for (const item of value) params.append(key, item)\n }\n }\n const serialized = params.toString()\n return `${path}${serialized ? `?${serialized}` : ''}${hash}`\n}\n\nfunction parseQuery(raw: string): RouteQuery {\n const params = new URLSearchParams(raw)\n const result: Record<string, RouteQueryValue> = {}\n params.forEach((value, key) => {\n const previous = result[key]\n if (previous === undefined) result[key] = value\n else if (typeof previous === 'string') result[key] = [previous, value]\n else result[key] = [...previous, value]\n })\n for (const key of Object.keys(result)) {\n if (Array.isArray(result[key])) result[key] = Object.freeze(result[key] as string[])\n }\n return Object.freeze(result)\n}\n\nfunction normalizeQuery(input: RouteQueryInput): RouteQuery {\n if (input instanceof URLSearchParams) return parseQuery(input.toString())\n const result: Record<string, RouteQueryValue> = {}\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null) continue\n if (Array.isArray(value)) result[key] = Object.freeze(value.map(item => String(item)))\n else result[key] = String(value)\n }\n return Object.freeze(result)\n}\n\nfunction normalizePath(path: string): string {\n if (!path) return '/'\n const withoutQuery = path.split(/[?#]/, 1)[0] || '/'\n const withLeadingSlash = withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}`\n if (withLeadingSlash === '/*' || withLeadingSlash === '/') return withLeadingSlash\n return withLeadingSlash.replace(/\\/+/g, '/').replace(/\\/$/, '') || '/'\n}\n\nfunction normalizeHistoryPath(path: string): string {\n const parsed = parseTargetString(path)\n return buildTargetPath(parsed.path, parsed.query, parsed.hash)\n}\n\nfunction normalizeHash(hash: string): string {\n if (!hash) return ''\n return hash.startsWith('#') ? hash : `#${hash}`\n}\n\nfunction normalizeBase(base: string): string {\n if (!base || base === '/') return ''\n return `/${base.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nfunction readBrowserLocation(base: string): string {\n const pathname = window.location.pathname\n const path = base && (pathname === base || pathname.startsWith(`${base}/`))\n ? pathname.slice(base.length) || '/'\n : pathname\n return normalizeHistoryPath(`${path}${window.location.search}${window.location.hash}`)\n}\n\nfunction withBase(path: string, base: string): string {\n return `${base}${path === '/' ? '/' : path}` || '/'\n}\n\nfunction notifyListeners(listeners: Set<(path: string, state: unknown) => void>, path: string, state: unknown): void {\n for (const listener of [...listeners]) listener(path, state)\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction decodeRoutePart(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\nfunction isLazyRouteComponent(value: RouteComponentDefinition): value is LazyRouteComponent {\n return typeof value === 'object' && value !== null && value.kind === 'vobs-lazy-route'\n}\n\nfunction isRouteComponentDefinition(value: unknown): value is RouteComponentDefinition {\n return typeof value === 'function' || isLazyRouteComponent(value as RouteComponentDefinition)\n}\n\nasync function loadRouteComponent(loader: LazyRouteComponent): Promise<RouteComponent> {\n const module = await loader.load()\n const component = typeof module === 'function' ? module : module.default\n if (typeof component !== 'function') throw new Error('Vobs Router: 懒加载模块没有默认组件导出')\n return component\n}\n\nfunction isRouteLocationRaw(value: unknown): value is RouteLocationRaw {\n return Boolean(value) && typeof value === 'object'\n}\n\nfunction toError(reason: unknown): Error {\n return reason instanceof Error ? reason : new Error(String(reason))\n}\n\nfunction isAbortError(reason: unknown): boolean {\n return Boolean(reason) && typeof reason === 'object'\n && ((reason as { readonly name?: unknown }).name === 'AbortError'\n || (reason as { readonly code?: unknown }).code === 'ERR_CANCELED')\n}\n","import type { RuntimeDebugContext } from '@vobs/runtime'\n\nexport type RouterDebugEventType =\n | 'navigation:start'\n | 'navigation:end'\n | 'route:update'\n | 'data-request'\n | 'error'\n\nexport interface RouterDebugEvent {\n readonly routerId: string\n readonly type: RouterDebugEventType\n readonly payload: unknown\n readonly context?: RuntimeDebugContext\n}\n\ntype RouterDebugListener = (event: RouterDebugEvent) => void\n\nconst listeners = new Set<RouterDebugListener>()\nlet nextRouterId = 1\n\nexport function createRouterDebugId(): string {\n return `router-${nextRouterId++}`\n}\n\nexport function subscribeRouterDebug(listener: RouterDebugListener): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nexport function emitRouterDebug(\n routerId: string,\n type: RouterDebugEventType,\n payload: unknown,\n context?: RuntimeDebugContext\n): void {\n const event: RouterDebugEvent = { routerId, type, payload, context }\n for (const listener of [...listeners]) {\n try { listener(event) } catch { /* diagnostics must not affect navigation */ }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAmC;AACnC,kBASO;;;ACQP,IAAM,YAAY,oBAAI,IAAyB;AAC/C,IAAI,eAAe;AAEZ,SAAS,sBAA8B;AAC5C,SAAO,UAAU,cAAc;AACjC;AAFgB;AAIT,SAAS,qBAAqB,UAA2C;AAC9E,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAHgB;AAKT,SAAS,gBACd,UACA,MACA,SACA,SACM;AACN,QAAM,QAA0B,EAAE,U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":["import_runtime","listeners","state","options","module"]}
package/dist/index.d.cts CHANGED
@@ -193,7 +193,8 @@ interface Router {
193
193
  }
194
194
  interface RouterViewProps {
195
195
  readonly router?: Router;
196
- readonly loading?: () => VobsNode | null | undefined;
196
+ /** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */
197
+ readonly loading?: VobsNode | (() => VobsNode | null | undefined);
197
198
  readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined;
198
199
  readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined;
199
200
  }
package/dist/index.d.ts CHANGED
@@ -193,7 +193,8 @@ interface Router {
193
193
  }
194
194
  interface RouterViewProps {
195
195
  readonly router?: Router;
196
- readonly loading?: () => VobsNode | null | undefined;
196
+ /** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */
197
+ readonly loading?: VobsNode | (() => VobsNode | null | undefined);
197
198
  readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined;
198
199
  readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined;
199
200
  }
package/dist/index.js CHANGED
@@ -561,7 +561,9 @@ function RouterView(props = {}) {
561
561
  const route = router.currentRoute.value;
562
562
  const view = router.getViewState(route);
563
563
  routeRetry = view.retry;
564
- if (view.status === "loading") return props.loading?.() ?? null;
564
+ if (view.status === "loading") {
565
+ return (typeof props.loading === "function" ? props.loading() : props.loading) ?? null;
566
+ }
565
567
  if (view.status === "not-found") return props.notFound?.(route) ?? null;
566
568
  if (view.status === "error") {
567
569
  throw view.error ?? new Error("\u8DEF\u7531\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/debug.ts"],"sourcesContent":["import { state, type Signal } from '@vobs/reactivity'\nimport {\n createComponent,\n createFragment,\n createInjectionKey,\n inject,\n insertBoundary,\n type InjectionKey,\n type VobsNode,\n type VobsPlugin\n} from '@vobs/vobs'\nimport {\n createRouterDebugId,\n emitRouterDebug\n} from './debug'\nimport {\n getRuntimeDebugContext,\n runWithRuntimeDebugContext,\n type RuntimeDebugContext\n} from '@vobs/runtime'\n\nexport { createRouterDebugId, emitRouterDebug, subscribeRouterDebug } from './debug'\nexport type { RouterDebugEvent, RouterDebugEventType } from './debug'\n\nexport type RouteParams = Readonly<Record<string, string>>\nexport type RouteQueryValue = string | readonly string[]\nexport type RouteQuery = Readonly<Record<string, RouteQueryValue>>\nexport type RouteMeta = Readonly<Record<string, unknown>>\n\nexport interface RouteLocation {\n readonly path: string\n readonly fullPath: string\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly hash: string\n readonly name: string | undefined\n readonly meta: RouteMeta\n readonly record: RouteRecord | null\n readonly matched: readonly RouteRecord[]\n readonly state?: unknown\n}\n\nexport interface RouteComponentProps {\n readonly route: RouteLocation\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly children?: VobsNode\n}\n\nexport type RouteComponent = (props: RouteComponentProps) => VobsNode\nexport type RouteComponentModule = RouteComponent | { default: RouteComponent }\nexport type RouteComponentLoader = () => PromiseLike<RouteComponentModule>\n\nexport interface LazyRouteComponent {\n readonly kind: 'vobs-lazy-route'\n readonly load: RouteComponentLoader\n}\n\nexport type RouteComponentDefinition = RouteComponent | LazyRouteComponent\n\nexport interface RouteLoaderContext {\n readonly route: RouteLocation\n readonly navigationId?: number\n readonly dataRequestId?: number\n}\n\nexport type RouteLoader = (context: RouteLoaderContext) => unknown | PromiseLike<unknown>\n\nexport interface RouteRecord {\n readonly path?: string\n readonly component?: RouteComponentDefinition\n readonly source?: string\n readonly name?: string\n readonly meta?: Record<string, unknown>\n readonly loader?: RouteLoader\n readonly action?: RouteLoader\n readonly children?: readonly RouteRecord[]\n}\n\nexport type RouteQueryInput = Record<string, unknown> | URLSearchParams\n\nexport interface RouteLocationRaw {\n readonly path?: string\n readonly name?: string\n readonly params?: Record<string, unknown>\n readonly query?: RouteQueryInput\n readonly hash?: string\n readonly state?: unknown\n}\n\nexport type RouteTarget = string | RouteLocationRaw\n\nexport type NavigationGuardResult = void | boolean | RouteTarget\nexport type NavigationGuard = (\n to: RouteLocation,\n from: RouteLocation\n) => NavigationGuardResult | PromiseLike<NavigationGuardResult>\n\nexport class NavigationCancelledError extends Error {\n readonly code = 'NAVIGATION_CANCELLED'\n\n constructor() {\n super('Vobs Router: 导航已被更新的导航取消')\n this.name = 'NavigationCancelledError'\n }\n}\n\nexport class NavigationRedirectError extends Error {\n readonly code = 'NAVIGATION_REDIRECT_LIMIT'\n\n constructor() {\n super('Vobs Router: 导航重定向超过最大次数')\n this.name = 'NavigationRedirectError'\n }\n}\n\nexport interface RouterHistory {\n readonly location: string\n /** 当前 history 条目携带的导航 state(push/replace 时写入,popstate/初始启动时回读)。 */\n readonly state?: unknown\n push(path: string, state?: unknown): void\n replace(path: string, state?: unknown): void\n back(): void\n listen(listener: (path: string, state: unknown) => void): () => void\n}\n\nexport interface RouterOptions {\n readonly routes: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport interface RouterViewState {\n readonly status: 'ready' | 'loading' | 'error' | 'not-found'\n readonly component?: RouteComponent\n readonly layouts?: readonly RouteComponent[]\n readonly error?: Error\n readonly retry: () => void\n}\n\nexport interface RouteDebugNode {\n readonly id: string\n readonly path: string\n readonly name?: string\n readonly component: string\n readonly lazy: boolean\n readonly loader: boolean\n readonly action: boolean\n readonly status: 'ready' | 'loading' | 'error'\n readonly meta: RouteMeta\n readonly source?: string\n readonly children: readonly RouteDebugNode[]\n}\n\nexport interface RouteErrorTrace {\n readonly id: number\n readonly phase: 'navigation' | 'render' | 'lazy' | 'loader' | 'action' | 'fetcher'\n readonly route: string\n readonly message: string\n readonly stack?: string\n readonly timestamp: number\n readonly requestId?: number\n readonly navigationId?: number\n}\n\nexport interface NavigationTrace {\n readonly id: number\n readonly from: string\n readonly to: string\n readonly status: 'success' | 'redirected' | 'cancelled' | 'error'\n readonly source: 'push' | 'replace' | 'history'\n readonly startedAt: number\n readonly endedAt: number\n readonly duration: number\n readonly redirect?: string\n readonly error?: string\n}\n\nexport interface NavigationState {\n readonly status: 'idle' | 'loading' | 'error'\n readonly from: string\n readonly to: string\n readonly traceId?: number\n readonly error?: string\n}\n\nexport interface RouterPerformanceMetrics {\n readonly navigationCount: number\n readonly averageNavigationDuration: number\n readonly slowNavigationCount: number\n}\n\nexport type RouterDataRequestKind = 'loader' | 'action' | 'fetcher'\n\nexport interface RouterDataRequestTrace {\n readonly id: number\n readonly kind: RouterDataRequestKind\n readonly key: string\n readonly route?: string\n readonly status: 'loading' | 'success' | 'error' | 'cancelled'\n readonly startedAt: number\n readonly endedAt?: number\n readonly duration?: number\n readonly result?: unknown\n readonly error?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport interface RouterDataRequestOptions {\n readonly route?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport type RouterDevToolsEvent = 'navigation:start' | 'navigation:end' | 'route:update' | 'data-request' | 'error'\n\nexport interface RouterDevToolsAPI {\n getRouteTree(): readonly RouteDebugNode[]\n getCurrentRoute(): RouteLocation\n getNavigationState(): NavigationState\n getNavigationHistory(): readonly NavigationTrace[]\n getPerformanceMetrics(): RouterPerformanceMetrics\n getDataRequests(): readonly RouterDataRequestTrace[]\n getErrors(): readonly RouteErrorTrace[]\n trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: () => T | PromiseLike<T>,\n options?: RouterDataRequestOptions | string\n ): Promise<T>\n runAction<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n runFetcher<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n reportError(phase: RouteErrorTrace['phase'], error: unknown, route?: string, context?: { readonly requestId?: number; readonly navigationId?: number }): void\n revalidate(route?: string): Promise<void>\n subscribe(event: RouterDevToolsEvent, callback: (payload: unknown) => void): () => void\n}\n\nexport interface Router {\n readonly currentRoute: Signal<RouteLocation>\n readonly history: RouterHistory\n resolve(to: RouteTarget): RouteLocation\n push(to: RouteTarget): Promise<RouteLocation | false>\n replace(to: RouteTarget): Promise<RouteLocation | false>\n back(): void\n beforeEach(guard: NavigationGuard): () => void\n getViewState(route: RouteLocation): RouterViewState\n readonly devtools: RouterDevToolsAPI\n destroy(): void\n}\n\nexport interface RouterViewProps {\n readonly router?: Router\n readonly loading?: () => VobsNode | null | undefined\n readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined\n readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined\n}\n\nexport interface RouterPluginOptions {\n readonly router?: Router\n readonly routes?: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport const ROUTER_KEY: InjectionKey<Router> = createInjectionKey<Router>('vobs.router')\n\nexport function lazy(loader: RouteComponentLoader): LazyRouteComponent {\n return {\n kind: 'vobs-lazy-route',\n load: loader\n }\n}\n\nexport function createMemoryHistory(initial = '/'): RouterHistory {\n let entries = [{ path: normalizeHistoryPath(initial), state: undefined as unknown }]\n let index = 0\n const listeners = new Set<(path: string, state: unknown) => void>()\n\n return {\n get location(): string {\n return entries[index]!.path\n },\n\n get state(): unknown {\n return entries[index]!.state\n },\n\n push(path: string, state?: unknown): void {\n const next = normalizeHistoryPath(path)\n entries = entries.slice(0, index + 1)\n entries.push({ path: next, state })\n index++\n },\n\n replace(path: string, state?: unknown): void {\n entries[index] = { path: normalizeHistoryPath(path), state }\n },\n\n back(): void {\n if (index === 0) return\n index--\n notifyListeners(listeners, entries[index]!.path, entries[index]!.state)\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }\n }\n}\n\nexport function createBrowserHistory(base = ''): RouterHistory {\n if (typeof window === 'undefined') {\n throw new Error('Vobs Router: createBrowserHistory 需要浏览器环境')\n }\n\n const normalizedBase = normalizeBase(base)\n const listeners = new Set<(path: string, state: unknown) => void>()\n const onPopState = (event: PopStateEvent): void => {\n notifyListeners(listeners, readBrowserLocation(normalizedBase), event.state)\n }\n\n return {\n get location(): string {\n return readBrowserLocation(normalizedBase)\n },\n\n get state(): unknown {\n return window.history.state\n },\n\n push(path: string, state?: unknown): void {\n window.history.pushState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n replace(path: string, state?: unknown): void {\n window.history.replaceState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n back(): void {\n window.history.back()\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n if (listeners.size === 0) window.addEventListener('popstate', onPopState)\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n if (listeners.size === 0) window.removeEventListener('popstate', onPopState)\n }\n }\n }\n}\n\nexport function createRouter(options: RouterOptions): Router {\n const matchers = normalizeRoutes(options.routes)\n const history = options.history ?? defaultHistory()\n const routerDebugId = createRouterDebugId()\n matchers.sort(compareMatchers)\n const currentRoute = state<RouteLocation>(resolvePath(history.location))\n const lazyStates = new Map<RouteRecord, LazyState>()\n const guards: NavigationGuard[] = []\n const navigationHistory: NavigationTrace[] = []\n const dataRequests: RouterDataRequestTrace[] = []\n const errors: RouteErrorTrace[] = []\n const dataLoaders = new Map<string, { kind: RouterDataRequestKind; route: string; task: () => unknown | PromiseLike<unknown> }>()\n const dataRequestContexts = new Map<number, RuntimeDebugContext>()\n const routerListeners = new Map<RouterDevToolsEvent, Set<(payload: unknown) => void>>()\n let navigationState: NavigationState = { status: 'idle', from: currentRoute.value.fullPath, to: currentRoute.value.fullPath }\n let navigationCount = 0\n let totalNavigationDuration = 0\n let slowNavigationCount = 0\n let nextDataRequestId = 1\n let nextErrorId = 1\n let navigationId = 0\n let destroyed = false\n const viewRevision = state(0)\n\n function resolve(to: RouteTarget): RouteLocation {\n ensureActive()\n const target = typeof to === 'string' ? parseTargetString(to) : normalizeTarget(to, matchers)\n return resolvePath(buildTargetPath(target.path, target.query, target.hash), target.state)\n }\n\n function resolvePath(rawPath: string, state?: unknown): RouteLocation {\n const parsed = parseTargetString(rawPath)\n const matched = matchers.find(matcher => matcher.regex.exec(parsed.path))\n const params = matched ? extractParams(matched, parsed.path) : {}\n const record = matched?.record ?? null\n const query = parsed.query\n const hash = parsed.hash\n return {\n path: parsed.path,\n fullPath: buildTargetPath(parsed.path, query, hash),\n params,\n query,\n hash,\n name: record?.name,\n meta: matched?.meta ?? {},\n record,\n matched: matched?.chain ?? EMPTY_MATCHED,\n state\n }\n }\n\n async function navigate(\n to: RouteTarget,\n replaceHistory: boolean,\n fromHistory: boolean,\n historyState?: unknown\n ): Promise<RouteLocation | false> {\n ensureActive()\n const id = ++navigationId\n const from = currentRoute.value\n let target = resolve(to)\n // popstate 回读的 state 保存在 history 条目上,不在目标描述里,这里回填。\n if (fromHistory && historyState !== undefined) target = { ...target, state: historyState }\n const source: NavigationTrace['source'] = fromHistory ? 'history' : replaceHistory ? 'replace' : 'push'\n const startedAt = now()\n const initialTarget = target.fullPath\n let terminalRecorded = false\n navigationState = { status: 'loading', from: from.fullPath, to: target.fullPath, traceId: id }\n emitRouter('navigation:start', navigationState)\n if (target.fullPath === from.fullPath && !fromHistory) {\n navigationState = { status: 'idle', from: from.fullPath, to: target.fullPath }\n return from\n }\n\n try {\n for (let redirectCount = 0; ; redirectCount++) {\n ensureNavigationIsCurrent(id)\n let redirect: RouteTarget | undefined\n for (const guard of [...guards]) {\n let result: NavigationGuardResult\n try {\n result = await guard(target, from)\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) throw reason\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw reason\n }\n ensureNavigationIsCurrent(id)\n if (result === false) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n return false\n }\n if (typeof result === 'string' || isRouteLocationRaw(result)) {\n redirect = result\n break\n }\n }\n\n for (const record of target.matched) {\n if (!record.loader) continue\n // 上一 loader 期间被新导航抢占时立即取消,跳过剩余 loader。\n ensureNavigationIsCurrent(id)\n await trackDataRequest(\n 'loader',\n `${target.fullPath}#${record.path ?? record.name ?? 'route'}`,\n context => record.loader!({ route: target, navigationId: id, dataRequestId: context.dataRequestId }),\n { route: target.fullPath, navigationId: id, trigger: 'navigation' }\n )\n }\n\n // loader 完成后、提交前必须重新校验:飞行期间被抢占的导航不允许覆盖 currentRoute 与 history。\n ensureNavigationIsCurrent(id)\n\n if (redirect !== undefined) {\n if (redirectCount >= 10) {\n const error = new NavigationRedirectError()\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw error\n }\n const redirected = resolve(redirect)\n if (redirected.fullPath === target.fullPath) return false\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'redirected', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: redirected.fullPath })\n target = redirected\n continue\n }\n\n if (target.fullPath === from.fullPath) return from\n if (!fromHistory) {\n if (replaceHistory) history.replace(target.fullPath, target.state)\n else history.push(target.fullPath, target.state)\n }\n currentRoute.value = target\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'success', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: target.fullPath !== initialTarget ? target.fullPath : undefined })\n terminalRecorded = true\n return target\n }\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n } else if (!terminalRecorded) {\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n }\n throw reason\n }\n }\n\n function now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n }\n\n function emitRouter(event: RouterDevToolsEvent, payload: unknown): void {\n for (const callback of routerListeners.get(event) ?? []) {\n try { callback(payload) } catch { /* diagnostics must not affect navigation */ }\n }\n emitRouterDebug(routerDebugId, event, payload, getRuntimeDebugContext() ?? undefined)\n }\n\n function recordNavigation(trace: NavigationTrace): void {\n navigationHistory.push(Object.freeze(trace))\n if (navigationHistory.length > 100) navigationHistory.shift()\n navigationCount++\n totalNavigationDuration += trace.duration\n if (trace.duration >= 16) slowNavigationCount++\n if (trace.id === navigationId) {\n navigationState = trace.status === 'error'\n ? { status: 'error', from: trace.from, to: trace.to, traceId: trace.id, error: trace.error }\n : { status: 'idle', from: trace.from, to: trace.to, traceId: trace.id }\n }\n emitRouter('navigation:end', trace)\n emitRouter('route:update', currentRoute.value)\n }\n\n async function trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: ((context: { readonly dataRequestId: number }) => T | PromiseLike<T>) | (() => T | PromiseLike<T>),\n optionsOrRoute: RouterDataRequestOptions | string = {}\n ): Promise<T> {\n ensureActive()\n const options = typeof optionsOrRoute === 'string' ? { route: optionsOrRoute } : optionsOrRoute\n const id = nextDataRequestId++\n const startedAt = now()\n const context = getRuntimeDebugContext()\n const route = options.route ?? currentRoute.value.fullPath\n const requestContext: RuntimeDebugContext = {\n ...context,\n environment: options.environment ?? context?.environment,\n route,\n navigationId: options.navigationId ?? context?.navigationId,\n dataRequestId: id,\n source: kind\n }\n const loading: RouterDataRequestTrace = {\n id,\n kind,\n key,\n route,\n status: 'loading',\n startedAt,\n navigationId: requestContext.navigationId,\n trigger: options.trigger,\n environment: requestContext.environment\n }\n dataRequests.push(loading)\n if (dataRequests.length > 100) dataRequests.shift()\n dataRequestContexts.set(id, requestContext)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', loading)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'start', trace: loading }, requestContext)\n dataLoaders.set(key, { kind, route, task: task as () => unknown | PromiseLike<unknown> })\n try {\n const result = await runWithRuntimeDebugContext(requestContext, () => (task as (context: { readonly dataRequestId: number }) => T | PromiseLike<T>)({ dataRequestId: id }))\n const endedAt = now()\n replaceDataRequest(id, { ...loading, status: 'success', endedAt, duration: endedAt - startedAt, result })\n return result\n } catch (reason) {\n const endedAt = now()\n const error = toError(reason)\n const status = isAbortError(reason) ? 'cancelled' : 'error'\n if (status === 'error') reportError(kind, error, route, { requestId: id, navigationId: requestContext.navigationId })\n replaceDataRequest(id, { ...loading, status, endedAt, duration: endedAt - startedAt, error: status === 'error' ? error.message : undefined })\n throw reason\n }\n }\n\n function replaceDataRequest(id: number, trace: RouterDataRequestTrace): void {\n const index = dataRequests.findIndex(item => item.id === id)\n if (index >= 0) dataRequests[index] = Object.freeze(trace)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', trace)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'end', trace }, dataRequestContexts.get(id))\n dataRequestContexts.delete(id)\n }\n\n function reportError(\n phase: RouteErrorTrace['phase'],\n reason: unknown,\n route = currentRoute.value.fullPath,\n context: { readonly requestId?: number; readonly navigationId?: number } = {}\n ): void {\n const error = toError(reason)\n errors.push(Object.freeze({\n id: nextErrorId++,\n phase,\n route,\n message: error.message,\n stack: error.stack,\n timestamp: now(),\n requestId: context.requestId,\n navigationId: context.navigationId\n }))\n if (errors.length > 100) errors.shift()\n emitRouter('error', errors[errors.length - 1]!)\n emitRouter('route:update', currentRoute.value)\n }\n\n function routeTree(): readonly RouteDebugNode[] {\n const statuses = new Map<string, LazyState['status']>()\n for (const matcher of matchers) {\n for (const record of matcher.chain) {\n if (record.component && isLazyRouteComponent(record.component)) {\n const debugId = routeDebugIds.get(record)\n if (debugId) statuses.set(debugId, lazyStates.get(record)?.status ?? 'loading')\n }\n }\n }\n return buildRouteDebugTree(options.routes, statuses)\n }\n\n function handleHistoryNavigation(path: string, state: unknown): void {\n void navigate(path, false, true, state).then(result => {\n if (destroyed) return\n if (result === false) {\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n } else if (result.fullPath !== normalizeHistoryPath(path)) {\n history.replace(result.fullPath, result.state)\n }\n }).catch(error => {\n if (!(error instanceof NavigationCancelledError) && !destroyed) {\n const current = currentRoute.value.fullPath\n const failed = toError(error)\n reportError('navigation', failed, normalizeHistoryPath(path))\n navigationState = { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message }\n emitRouter('navigation:end', { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message })\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n }\n })\n }\n\n const stopHistory = history.listen(handleHistoryNavigation)\n\n const router: Router = {\n currentRoute,\n history,\n\n resolve,\n\n push(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, false, false)\n },\n\n replace(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, true, false)\n },\n\n back(): void {\n ensureActive()\n history.back()\n },\n\n beforeEach(guard: NavigationGuard): () => void {\n ensureActive()\n guards.push(guard)\n return () => {\n const index = guards.indexOf(guard)\n if (index >= 0) guards.splice(index, 1)\n }\n },\n\n getViewState(route: RouteLocation): RouterViewState {\n viewRevision.value\n const records = route.matched.length > 0 ? route.matched : route.record ? [route.record] : []\n const entries = records\n .map(record => ({ record, definition: record.component }))\n .filter((entry): entry is { record: RouteRecord; definition: RouteComponentDefinition } =>\n isRouteComponentDefinition(entry.definition))\n if (!route.record || entries.length === 0) return { status: 'not-found', retry: () => undefined }\n\n const loaded: RouteComponent[] = []\n const lazyRecords: RouteRecord[] = []\n for (const entry of entries) {\n const { record, definition } = entry\n if (!isLazyRouteComponent(definition)) {\n loaded.push(definition)\n continue\n }\n lazyRecords.push(record)\n const lazyState = ensureLazyState(record, definition)\n if (lazyState.status === 'loading') return { status: 'loading', retry: () => retryLazyRoutes(lazyRecords) }\n if (lazyState.status === 'error') {\n return { status: 'error', error: lazyState.error, retry: () => retryLazyRoutes(lazyRecords) }\n }\n if (lazyState.component) loaded.push(lazyState.component)\n }\n\n const component = loaded[loaded.length - 1]\n if (!component) return { status: 'not-found', retry: () => undefined }\n return {\n status: 'ready',\n component,\n layouts: loaded.slice(0, -1),\n retry: () => retryLazyRoutes(lazyRecords)\n }\n },\n\n devtools: {\n getRouteTree: routeTree,\n getCurrentRoute: () => currentRoute.value,\n getNavigationState: () => navigationState,\n getNavigationHistory: () => [...navigationHistory],\n getPerformanceMetrics: () => ({\n navigationCount,\n averageNavigationDuration: navigationCount === 0 ? 0 : totalNavigationDuration / navigationCount,\n slowNavigationCount\n }),\n getDataRequests: () => [...dataRequests],\n getErrors: () => [...errors],\n trackDataRequest,\n runAction: (key, task) => trackDataRequest('action', key, task, { trigger: 'manual' }),\n runFetcher: (key, task) => trackDataRequest('fetcher', key, task, { trigger: 'manual' }),\n reportError,\n revalidate: async (route) => {\n await Promise.all([...dataLoaders.entries()]\n .filter(([, loader]) => loader.kind === 'loader' && (route === undefined || loader.route === route))\n .map(([key, loader]) => trackDataRequest(loader.kind, key, loader.task, { route: loader.route, trigger: 'revalidate' })))\n },\n subscribe(event, callback) {\n let listeners = routerListeners.get(event)\n if (!listeners) { listeners = new Set(); routerListeners.set(event, listeners) }\n listeners.add(callback)\n return () => listeners?.delete(callback)\n }\n },\n\n destroy(): void {\n if (destroyed) return\n destroyed = true\n navigationId++\n stopHistory()\n guards.length = 0\n routerListeners.clear()\n lazyStates.clear()\n errors.length = 0\n dataRequestContexts.clear()\n currentRoute.dispose()\n viewRevision.dispose()\n }\n }\n\n function ensureLazyState(record: RouteRecord, definition: LazyRouteComponent): LazyState {\n let lazyState = lazyStates.get(record)\n if (!lazyState) {\n lazyState = { status: 'loading' }\n lazyStates.set(record, lazyState)\n void loadRouteComponent(definition).then(component => {\n if (destroyed) return\n lazyState!.status = 'ready'\n lazyState!.component = component\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n }).catch(reason => {\n if (destroyed) return\n lazyState!.status = 'error'\n lazyState!.error = toError(reason)\n reportError('lazy', reason, currentRoute.value.fullPath)\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n })\n }\n return lazyState\n }\n\n function retryLazyRoutes(records: readonly RouteRecord[]): void {\n for (const record of records) lazyStates.delete(record)\n viewRevision.value++\n }\n\n function ensureActive(): void {\n if (destroyed) throw new Error('Vobs Router: 已销毁的 Router 不能继续使用')\n }\n\n function ensureNavigationIsCurrent(id: number): void {\n if (id !== navigationId) throw new NavigationCancelledError()\n }\n\n return router\n}\n\nexport function RouterView(props: RouterViewProps = {}): VobsNode {\n const router = props.router ?? inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: RouterView 找不到 Router,请安装 routerPlugin')\n\n return createFragment((parent, anchor) => {\n let routeRetry: () => void = () => undefined\n insertBoundary(parent, anchor, {\n resetKey: () => router.currentRoute.value.fullPath,\n onRetry: () => routeRetry(),\n fallback: (error, retry) => {\n router.devtools.reportError('render', error, router.currentRoute.value.fullPath)\n return props.error?.(error, () => { void retry() }) ?? null\n },\n children: () => {\n const route = router.currentRoute.value\n const view = router.getViewState(route)\n routeRetry = view.retry\n if (view.status === 'loading') return props.loading?.() ?? null\n if (view.status === 'not-found') return props.notFound?.(route) ?? null\n if (view.status === 'error') {\n throw view.error ?? new Error('路由组件加载失败')\n }\n if (!view.component) return null\n let node = createComponent(view.component, {\n route,\n params: route.params,\n query: route.query\n })\n for (let index = (view.layouts?.length ?? 0) - 1; index >= 0; index--) {\n node = createComponent(view.layouts![index]!, {\n route,\n params: route.params,\n query: route.query,\n children: node\n })\n }\n return node\n }})\n })\n}\n\nexport function useRouter(): Router {\n const router = inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: useRouter 找不到 Router,请安装 routerPlugin')\n return router\n}\n\nexport function useRoute(): Signal<RouteLocation> {\n return useRouter().currentRoute\n}\n\nexport function routerPlugin(options: RouterPluginOptions = {}): VobsPlugin {\n return {\n name: '@vobs/router',\n version: '0.1.0',\n install(context) {\n const ownedRouter = options.router ? undefined : createRouter({\n routes: options.routes ?? [],\n history: options.history\n })\n const router = options.router ?? ownedRouter!\n context.provide(ROUTER_KEY, router)\n return () => ownedRouter?.destroy()\n }\n }\n}\n\ninterface RouteMatcher {\n readonly record: RouteRecord\n readonly debugId: string\n readonly chain: readonly RouteRecord[]\n readonly meta: RouteMeta\n readonly regex: RegExp\n readonly keys: readonly string[]\n readonly score: number\n readonly order: number\n}\n\ninterface LazyState {\n status: 'loading' | 'ready' | 'error'\n component?: RouteComponent\n error?: Error\n}\n\ninterface ParsedTarget {\n readonly path: string\n readonly query: RouteQuery\n readonly hash: string\n readonly state?: unknown\n}\n\nfunction defaultHistory(): RouterHistory {\n return typeof window === 'undefined' ? createMemoryHistory('/') : createBrowserHistory()\n}\n\nconst EMPTY_MATCHED: readonly RouteRecord[] = Object.freeze([])\nconst routeDebugIds = new WeakMap<RouteRecord, string>()\n\nfunction buildRouteDebugTree(routes: readonly RouteRecord[], lazyStatuses: ReadonlyMap<string, LazyState['status']> = new Map()): readonly RouteDebugNode[] {\n const visit = (records: readonly RouteRecord[], parentPath: string, parentId: string): RouteDebugNode[] => records.map((record, index) => {\n const path = record.path === undefined ? parentPath || '/' : resolveChildPath(parentPath, record.path)\n const id = `${parentId}.${index}`\n const definition = record.component\n const lazyDefinition = definition !== undefined && isLazyRouteComponent(definition)\n const componentName = definition === undefined\n ? 'Route'\n : lazyDefinition\n ? 'lazy(...)'\n : typeof definition === 'function'\n ? definition.name || 'Anonymous'\n : 'Route'\n return {\n id,\n path,\n name: record.name,\n component: componentName,\n source: record.source,\n lazy: lazyDefinition,\n loader: record.loader !== undefined,\n action: record.action !== undefined,\n status: lazyDefinition ? (lazyStatuses.get(id) ?? 'loading') : 'ready',\n meta: Object.freeze({ ...(record.meta ?? {}) }),\n children: visit(record.children ?? [], path, id)\n }\n })\n return Object.freeze(visit(routes, '', 'route'))\n}\n\nfunction normalizeRoutes(routes: readonly RouteRecord[]): RouteMatcher[] {\n const matchers: RouteMatcher[] = []\n let order = 0\n\n function visit(records: readonly RouteRecord[], parentPath: string, parentChain: readonly RouteRecord[], parentMeta: RouteMeta, parentId = 'route'): void {\n records.forEach((record, index) => {\n const debugId = `${parentId}.${index}`\n const children = record.children ?? []\n const path = record.path === undefined\n ? parentPath\n : resolveChildPath(parentPath, record.path)\n const normalized: RouteRecord = {\n ...record,\n path: record.path === undefined\n ? (children.length > 0 ? undefined : (path || '/'))\n : path,\n meta: record.meta ? { ...record.meta } : {}\n }\n routeDebugIds.set(normalized, debugId)\n const chain = [...parentChain, normalized]\n const meta = Object.freeze({ ...parentMeta, ...(normalized.meta ?? {}) })\n if (children.length > 0) {\n visit(children, path, chain, meta, debugId)\n } else if (normalized.component) {\n matchers.push(createMatcher(normalized, chain, meta, order++, debugId))\n } else if (normalized.path === undefined) {\n throw new Error(`Vobs Router: 第 ${index + 1} 个路由缺少 path 或 children`)\n }\n })\n }\n\n visit(routes, '', [], {})\n return matchers\n}\n\nfunction resolveChildPath(parentPath: string, childPath: string): string {\n const normalizedChild = normalizePath(childPath)\n if (!parentPath || normalizedChild === '/') return normalizedChild === '/' ? (parentPath || '/') : normalizedChild\n if (childPath.startsWith('/')) return normalizedChild\n return normalizePath(`${parentPath}/${childPath}`)\n}\n\nfunction createMatcher(record: RouteRecord, chain: readonly RouteRecord[], meta: RouteMeta, order: number, debugId: string): RouteMatcher {\n const path = record.path ?? '/'\n const segments = path === '/' ? [] : path.slice(1).split('/')\n const keys: string[] = []\n let score = 0\n const pattern = segments.map(segment => {\n if (segment === '*') {\n keys.push('pathMatch')\n return '(.*)'\n }\n if (segment.startsWith(':')) {\n const key = segment.slice(1)\n if (!key) throw new Error(`Vobs Router: 路由 ${path} 的参数名不能为空`)\n if (keys.includes(key)) throw new Error(`Vobs Router: 路由 ${path} 存在重复参数 ${key}`)\n keys.push(key)\n score += 1\n return '([^/]+)'\n }\n score += 3\n return escapeRegExp(segment)\n }).join('/')\n\n return {\n record,\n debugId,\n chain: Object.freeze([...chain]),\n meta,\n regex: new RegExp(segments.length === 0 ? '^/?$' : `^/${pattern}/?$`),\n keys,\n score,\n order\n }\n}\n\nfunction compareMatchers(left: RouteMatcher, right: RouteMatcher): number {\n return right.score - left.score || left.order - right.order\n}\n\nfunction extractParams(matcher: RouteMatcher, path: string): RouteParams {\n const match = matcher.regex.exec(path)\n if (!match) return {}\n const params: Record<string, string> = {}\n matcher.keys.forEach((key, index) => {\n params[key] = decodeRoutePart(match[index + 1] ?? '')\n })\n return Object.freeze(params)\n}\n\nfunction parseTargetString(raw: string): ParsedTarget {\n const hashIndex = raw.indexOf('#')\n const hash = hashIndex >= 0 ? normalizeHash(raw.slice(hashIndex + 1)) : ''\n const withoutHash = hashIndex >= 0 ? raw.slice(0, hashIndex) : raw\n const queryIndex = withoutHash.indexOf('?')\n const path = normalizePath(queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash)\n const query = queryIndex >= 0 ? parseQuery(withoutHash.slice(queryIndex + 1)) : {}\n return { path, query, hash }\n}\n\nfunction normalizeTarget(target: RouteLocationRaw, matchers: readonly RouteMatcher[]): ParsedTarget {\n let path = target.path\n if (!path && target.name) {\n const matcher = matchers.find(candidate => candidate.record.name === target.name)\n if (!matcher) throw new Error(`Vobs Router: 找不到名为 ${target.name} 的路由`)\n path = fillRouteParams(matcher.record.path ?? '/', target.params ?? {})\n }\n if (!path) throw new Error('Vobs Router: 导航目标必须提供 path 或 name')\n\n const parsed = parseTargetString(path)\n const filledPath = fillRouteParams(parsed.path, target.params ?? {})\n const query = target.query === undefined ? parsed.query : normalizeQuery(target.query)\n const hash = target.hash === undefined ? parsed.hash : normalizeHash(target.hash)\n return { path: filledPath, query, hash, state: target.state }\n}\n\nfunction fillRouteParams(path: string, params: Record<string, unknown>): string {\n return path.replace(/:([A-Za-z0-9_]+)|\\*/g, (token, key: string | undefined) => {\n const value = key ? params[key] : params.pathMatch\n if (value === undefined || value === null) return token\n return encodeURIComponent(String(value))\n })\n}\n\nfunction buildTargetPath(path: string, query: RouteQuery, hash: string): string {\n const params = new URLSearchParams()\n for (const key of Object.keys(query).sort()) {\n const value = query[key]\n if (typeof value === 'string') {\n params.set(key, value)\n } else {\n for (const item of value) params.append(key, item)\n }\n }\n const serialized = params.toString()\n return `${path}${serialized ? `?${serialized}` : ''}${hash}`\n}\n\nfunction parseQuery(raw: string): RouteQuery {\n const params = new URLSearchParams(raw)\n const result: Record<string, RouteQueryValue> = {}\n params.forEach((value, key) => {\n const previous = result[key]\n if (previous === undefined) result[key] = value\n else if (typeof previous === 'string') result[key] = [previous, value]\n else result[key] = [...previous, value]\n })\n for (const key of Object.keys(result)) {\n if (Array.isArray(result[key])) result[key] = Object.freeze(result[key] as string[])\n }\n return Object.freeze(result)\n}\n\nfunction normalizeQuery(input: RouteQueryInput): RouteQuery {\n if (input instanceof URLSearchParams) return parseQuery(input.toString())\n const result: Record<string, RouteQueryValue> = {}\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null) continue\n if (Array.isArray(value)) result[key] = Object.freeze(value.map(item => String(item)))\n else result[key] = String(value)\n }\n return Object.freeze(result)\n}\n\nfunction normalizePath(path: string): string {\n if (!path) return '/'\n const withoutQuery = path.split(/[?#]/, 1)[0] || '/'\n const withLeadingSlash = withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}`\n if (withLeadingSlash === '/*' || withLeadingSlash === '/') return withLeadingSlash\n return withLeadingSlash.replace(/\\/+/g, '/').replace(/\\/$/, '') || '/'\n}\n\nfunction normalizeHistoryPath(path: string): string {\n const parsed = parseTargetString(path)\n return buildTargetPath(parsed.path, parsed.query, parsed.hash)\n}\n\nfunction normalizeHash(hash: string): string {\n if (!hash) return ''\n return hash.startsWith('#') ? hash : `#${hash}`\n}\n\nfunction normalizeBase(base: string): string {\n if (!base || base === '/') return ''\n return `/${base.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nfunction readBrowserLocation(base: string): string {\n const pathname = window.location.pathname\n const path = base && (pathname === base || pathname.startsWith(`${base}/`))\n ? pathname.slice(base.length) || '/'\n : pathname\n return normalizeHistoryPath(`${path}${window.location.search}${window.location.hash}`)\n}\n\nfunction withBase(path: string, base: string): string {\n return `${base}${path === '/' ? '/' : path}` || '/'\n}\n\nfunction notifyListeners(listeners: Set<(path: string, state: unknown) => void>, path: string, state: unknown): void {\n for (const listener of [...listeners]) listener(path, state)\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction decodeRoutePart(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\nfunction isLazyRouteComponent(value: RouteComponentDefinition): value is LazyRouteComponent {\n return typeof value === 'object' && value !== null && value.kind === 'vobs-lazy-route'\n}\n\nfunction isRouteComponentDefinition(value: unknown): value is RouteComponentDefinition {\n return typeof value === 'function' || isLazyRouteComponent(value as RouteComponentDefinition)\n}\n\nasync function loadRouteComponent(loader: LazyRouteComponent): Promise<RouteComponent> {\n const module = await loader.load()\n const component = typeof module === 'function' ? module : module.default\n if (typeof component !== 'function') throw new Error('Vobs Router: 懒加载模块没有默认组件导出')\n return component\n}\n\nfunction isRouteLocationRaw(value: unknown): value is RouteLocationRaw {\n return Boolean(value) && typeof value === 'object'\n}\n\nfunction toError(reason: unknown): Error {\n return reason instanceof Error ? reason : new Error(String(reason))\n}\n\nfunction isAbortError(reason: unknown): boolean {\n return Boolean(reason) && typeof reason === 'object'\n && ((reason as { readonly name?: unknown }).name === 'AbortError'\n || (reason as { readonly code?: unknown }).code === 'ERR_CANCELED')\n}\n","import type { RuntimeDebugContext } from '@vobs/runtime'\n\nexport type RouterDebugEventType =\n | 'navigation:start'\n | 'navigation:end'\n | 'route:update'\n | 'data-request'\n | 'error'\n\nexport interface RouterDebugEvent {\n readonly routerId: string\n readonly type: RouterDebugEventType\n readonly payload: unknown\n readonly context?: RuntimeDebugContext\n}\n\ntype RouterDebugListener = (event: RouterDebugEvent) => void\n\nconst listeners = new Set<RouterDebugListener>()\nlet nextRouterId = 1\n\nexport function createRouterDebugId(): string {\n return `router-${nextRouterId++}`\n}\n\nexport function subscribeRouterDebug(listener: RouterDebugListener): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nexport function emitRouterDebug(\n routerId: string,\n type: RouterDebugEventType,\n payload: unknown,\n context?: RuntimeDebugContext\n): void {\n const event: RouterDebugEvent = { routerId, type, payload, context }\n for (const listener of [...listeners]) {\n try { listener(event) } catch { /* diagnostics must not affect navigation */ }\n }\n}\n"],"mappings":";;;;AAAA,SAAS,aAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;ACQP,IAAM,YAAY,oBAAI,IAAyB;AAC/C,IAAI,eAAe;AAEZ,SAAS,sBAA8B;AAC5C,SAAO,UAAU,cAAc;AACjC;AAFgB;AAIT,SAAS,qBAAqB,UAA2C;AAC9E,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAHgB;AAKT,SAAS,gBACd,UACA,MACA,SACA,SACM;AACN,QAAM,QAA0B,EAAE,UAAU,MAAM,SAAS,QAAQ;AACnE,aAAW,YAAY,CAAC,GAAG,SAAS,GAAG;AACrC,QAAI;AAAE,eAAS,KAAK;AAAA,IAAE,QAAQ;AAAA,IAA+C;AAAA,EAC/E;AACF;AAVgB;;;ADfhB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA+EA,IAAM,4BAAN,MAAM,kCAAiC,MAAM;AAAA,EAGlD,cAAc;AACZ,UAAM,iFAA0B;AAHlC,SAAS,OAAO;AAId,SAAK,OAAO;AAAA,EACd;AACF;AAPoD;AAA7C,IAAM,2BAAN;AASA,IAAM,2BAAN,MAAM,iCAAgC,MAAM;AAAA,EAGjD,cAAc;AACZ,UAAM,iFAA0B;AAHlC,SAAS,OAAO;AAId,SAAK,OAAO;AAAA,EACd;AACF;AAPmD;AAA5C,IAAM,0BAAN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qB,OAA8D;AAC1F,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,SAAS;AACvE;AAFS;AAIT,SAAS,2BAA2B,OAAmD;AACrF,SAAO,OAAO,UAAU,cAAc,qBAAqB,KAAiC;AAC9F;AAFS;AAIT,eAAe,mBAAmB,QAAqD;AACrF,QAAM,SAAS,MAAM,OAAO,KAAK;AACjC,QAAM,YAAY,OAAO,WAAW,aAAa,SAAS,OAAO;AACjE,MAAI,OAAO,cAAc,WAAY,OAAM,IAAI,MAAM,6FAA4B;AACjF,SAAO;AACT;AALe;AAOf,SAAS,mBAAmB,OAA2C;AACrE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU;AAC5C;AAFS;AAIT,SAAS,QAAQ,QAAwB;AACvC,SAAO,kBAAkB,QAAQ,SAAS,IAAI,MAAM,OAAO,MAAM,CAAC;AACpE;AAFS;AAIT,SAAS,aAAa,QAA0B;AAC9C,SAAO,QAAQ,MAAM,KAAK,OAAO,WAAW,aACrC,OAAuC,SAAS,gBAC/C,OAAuC,SAAS;AAC1D;AAJS;","names":["listeners","state","options"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/debug.ts"],"sourcesContent":["import { state, type Signal } from '@vobs/reactivity'\nimport {\n createComponent,\n createFragment,\n createInjectionKey,\n inject,\n insertBoundary,\n type InjectionKey,\n type VobsNode,\n type VobsPlugin\n} from '@vobs/vobs'\nimport {\n createRouterDebugId,\n emitRouterDebug\n} from './debug'\nimport {\n getRuntimeDebugContext,\n runWithRuntimeDebugContext,\n type RuntimeDebugContext\n} from '@vobs/runtime'\n\nexport { createRouterDebugId, emitRouterDebug, subscribeRouterDebug } from './debug'\nexport type { RouterDebugEvent, RouterDebugEventType } from './debug'\n\nexport type RouteParams = Readonly<Record<string, string>>\nexport type RouteQueryValue = string | readonly string[]\nexport type RouteQuery = Readonly<Record<string, RouteQueryValue>>\nexport type RouteMeta = Readonly<Record<string, unknown>>\n\nexport interface RouteLocation {\n readonly path: string\n readonly fullPath: string\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly hash: string\n readonly name: string | undefined\n readonly meta: RouteMeta\n readonly record: RouteRecord | null\n readonly matched: readonly RouteRecord[]\n readonly state?: unknown\n}\n\nexport interface RouteComponentProps {\n readonly route: RouteLocation\n readonly params: RouteParams\n readonly query: RouteQuery\n readonly children?: VobsNode\n}\n\nexport type RouteComponent = (props: RouteComponentProps) => VobsNode\nexport type RouteComponentModule = RouteComponent | { default: RouteComponent }\nexport type RouteComponentLoader = () => PromiseLike<RouteComponentModule>\n\nexport interface LazyRouteComponent {\n readonly kind: 'vobs-lazy-route'\n readonly load: RouteComponentLoader\n}\n\nexport type RouteComponentDefinition = RouteComponent | LazyRouteComponent\n\nexport interface RouteLoaderContext {\n readonly route: RouteLocation\n readonly navigationId?: number\n readonly dataRequestId?: number\n}\n\nexport type RouteLoader = (context: RouteLoaderContext) => unknown | PromiseLike<unknown>\n\nexport interface RouteRecord {\n readonly path?: string\n readonly component?: RouteComponentDefinition\n readonly source?: string\n readonly name?: string\n readonly meta?: Record<string, unknown>\n readonly loader?: RouteLoader\n readonly action?: RouteLoader\n readonly children?: readonly RouteRecord[]\n}\n\nexport type RouteQueryInput = Record<string, unknown> | URLSearchParams\n\nexport interface RouteLocationRaw {\n readonly path?: string\n readonly name?: string\n readonly params?: Record<string, unknown>\n readonly query?: RouteQueryInput\n readonly hash?: string\n readonly state?: unknown\n}\n\nexport type RouteTarget = string | RouteLocationRaw\n\nexport type NavigationGuardResult = void | boolean | RouteTarget\nexport type NavigationGuard = (\n to: RouteLocation,\n from: RouteLocation\n) => NavigationGuardResult | PromiseLike<NavigationGuardResult>\n\nexport class NavigationCancelledError extends Error {\n readonly code = 'NAVIGATION_CANCELLED'\n\n constructor() {\n super('Vobs Router: 导航已被更新的导航取消')\n this.name = 'NavigationCancelledError'\n }\n}\n\nexport class NavigationRedirectError extends Error {\n readonly code = 'NAVIGATION_REDIRECT_LIMIT'\n\n constructor() {\n super('Vobs Router: 导航重定向超过最大次数')\n this.name = 'NavigationRedirectError'\n }\n}\n\nexport interface RouterHistory {\n readonly location: string\n /** 当前 history 条目携带的导航 state(push/replace 时写入,popstate/初始启动时回读)。 */\n readonly state?: unknown\n push(path: string, state?: unknown): void\n replace(path: string, state?: unknown): void\n back(): void\n listen(listener: (path: string, state: unknown) => void): () => void\n}\n\nexport interface RouterOptions {\n readonly routes: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport interface RouterViewState {\n readonly status: 'ready' | 'loading' | 'error' | 'not-found'\n readonly component?: RouteComponent\n readonly layouts?: readonly RouteComponent[]\n readonly error?: Error\n readonly retry: () => void\n}\n\nexport interface RouteDebugNode {\n readonly id: string\n readonly path: string\n readonly name?: string\n readonly component: string\n readonly lazy: boolean\n readonly loader: boolean\n readonly action: boolean\n readonly status: 'ready' | 'loading' | 'error'\n readonly meta: RouteMeta\n readonly source?: string\n readonly children: readonly RouteDebugNode[]\n}\n\nexport interface RouteErrorTrace {\n readonly id: number\n readonly phase: 'navigation' | 'render' | 'lazy' | 'loader' | 'action' | 'fetcher'\n readonly route: string\n readonly message: string\n readonly stack?: string\n readonly timestamp: number\n readonly requestId?: number\n readonly navigationId?: number\n}\n\nexport interface NavigationTrace {\n readonly id: number\n readonly from: string\n readonly to: string\n readonly status: 'success' | 'redirected' | 'cancelled' | 'error'\n readonly source: 'push' | 'replace' | 'history'\n readonly startedAt: number\n readonly endedAt: number\n readonly duration: number\n readonly redirect?: string\n readonly error?: string\n}\n\nexport interface NavigationState {\n readonly status: 'idle' | 'loading' | 'error'\n readonly from: string\n readonly to: string\n readonly traceId?: number\n readonly error?: string\n}\n\nexport interface RouterPerformanceMetrics {\n readonly navigationCount: number\n readonly averageNavigationDuration: number\n readonly slowNavigationCount: number\n}\n\nexport type RouterDataRequestKind = 'loader' | 'action' | 'fetcher'\n\nexport interface RouterDataRequestTrace {\n readonly id: number\n readonly kind: RouterDataRequestKind\n readonly key: string\n readonly route?: string\n readonly status: 'loading' | 'success' | 'error' | 'cancelled'\n readonly startedAt: number\n readonly endedAt?: number\n readonly duration?: number\n readonly result?: unknown\n readonly error?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport interface RouterDataRequestOptions {\n readonly route?: string\n readonly navigationId?: number\n readonly trigger?: 'navigation' | 'revalidate' | 'manual' | 'resource'\n readonly environment?: 'client' | 'server'\n}\n\nexport type RouterDevToolsEvent = 'navigation:start' | 'navigation:end' | 'route:update' | 'data-request' | 'error'\n\nexport interface RouterDevToolsAPI {\n getRouteTree(): readonly RouteDebugNode[]\n getCurrentRoute(): RouteLocation\n getNavigationState(): NavigationState\n getNavigationHistory(): readonly NavigationTrace[]\n getPerformanceMetrics(): RouterPerformanceMetrics\n getDataRequests(): readonly RouterDataRequestTrace[]\n getErrors(): readonly RouteErrorTrace[]\n trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: () => T | PromiseLike<T>,\n options?: RouterDataRequestOptions | string\n ): Promise<T>\n runAction<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n runFetcher<T>(key: string, task: () => T | PromiseLike<T>): Promise<T>\n reportError(phase: RouteErrorTrace['phase'], error: unknown, route?: string, context?: { readonly requestId?: number; readonly navigationId?: number }): void\n revalidate(route?: string): Promise<void>\n subscribe(event: RouterDevToolsEvent, callback: (payload: unknown) => void): () => void\n}\n\nexport interface Router {\n readonly currentRoute: Signal<RouteLocation>\n readonly history: RouterHistory\n resolve(to: RouteTarget): RouteLocation\n push(to: RouteTarget): Promise<RouteLocation | false>\n replace(to: RouteTarget): Promise<RouteLocation | false>\n back(): void\n beforeEach(guard: NavigationGuard): () => void\n getViewState(route: RouteLocation): RouterViewState\n readonly devtools: RouterDevToolsAPI\n destroy(): void\n}\n\nexport interface RouterViewProps {\n readonly router?: Router\n /** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */\n readonly loading?: VobsNode | (() => VobsNode | null | undefined)\n readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined\n readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined\n}\n\nexport interface RouterPluginOptions {\n readonly router?: Router\n readonly routes?: readonly RouteRecord[]\n readonly history?: RouterHistory\n}\n\nexport const ROUTER_KEY: InjectionKey<Router> = createInjectionKey<Router>('vobs.router')\n\nexport function lazy(loader: RouteComponentLoader): LazyRouteComponent {\n return {\n kind: 'vobs-lazy-route',\n load: loader\n }\n}\n\nexport function createMemoryHistory(initial = '/'): RouterHistory {\n let entries = [{ path: normalizeHistoryPath(initial), state: undefined as unknown }]\n let index = 0\n const listeners = new Set<(path: string, state: unknown) => void>()\n\n return {\n get location(): string {\n return entries[index]!.path\n },\n\n get state(): unknown {\n return entries[index]!.state\n },\n\n push(path: string, state?: unknown): void {\n const next = normalizeHistoryPath(path)\n entries = entries.slice(0, index + 1)\n entries.push({ path: next, state })\n index++\n },\n\n replace(path: string, state?: unknown): void {\n entries[index] = { path: normalizeHistoryPath(path), state }\n },\n\n back(): void {\n if (index === 0) return\n index--\n notifyListeners(listeners, entries[index]!.path, entries[index]!.state)\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }\n }\n}\n\nexport function createBrowserHistory(base = ''): RouterHistory {\n if (typeof window === 'undefined') {\n throw new Error('Vobs Router: createBrowserHistory 需要浏览器环境')\n }\n\n const normalizedBase = normalizeBase(base)\n const listeners = new Set<(path: string, state: unknown) => void>()\n const onPopState = (event: PopStateEvent): void => {\n notifyListeners(listeners, readBrowserLocation(normalizedBase), event.state)\n }\n\n return {\n get location(): string {\n return readBrowserLocation(normalizedBase)\n },\n\n get state(): unknown {\n return window.history.state\n },\n\n push(path: string, state?: unknown): void {\n window.history.pushState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n replace(path: string, state?: unknown): void {\n window.history.replaceState(state ?? null, '', withBase(normalizeHistoryPath(path), normalizedBase))\n },\n\n back(): void {\n window.history.back()\n },\n\n listen(listener: (path: string, state: unknown) => void): () => void {\n if (listeners.size === 0) window.addEventListener('popstate', onPopState)\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n if (listeners.size === 0) window.removeEventListener('popstate', onPopState)\n }\n }\n }\n}\n\nexport function createRouter(options: RouterOptions): Router {\n const matchers = normalizeRoutes(options.routes)\n const history = options.history ?? defaultHistory()\n const routerDebugId = createRouterDebugId()\n matchers.sort(compareMatchers)\n const currentRoute = state<RouteLocation>(resolvePath(history.location))\n const lazyStates = new Map<RouteRecord, LazyState>()\n const guards: NavigationGuard[] = []\n const navigationHistory: NavigationTrace[] = []\n const dataRequests: RouterDataRequestTrace[] = []\n const errors: RouteErrorTrace[] = []\n const dataLoaders = new Map<string, { kind: RouterDataRequestKind; route: string; task: () => unknown | PromiseLike<unknown> }>()\n const dataRequestContexts = new Map<number, RuntimeDebugContext>()\n const routerListeners = new Map<RouterDevToolsEvent, Set<(payload: unknown) => void>>()\n let navigationState: NavigationState = { status: 'idle', from: currentRoute.value.fullPath, to: currentRoute.value.fullPath }\n let navigationCount = 0\n let totalNavigationDuration = 0\n let slowNavigationCount = 0\n let nextDataRequestId = 1\n let nextErrorId = 1\n let navigationId = 0\n let destroyed = false\n const viewRevision = state(0)\n\n function resolve(to: RouteTarget): RouteLocation {\n ensureActive()\n const target = typeof to === 'string' ? parseTargetString(to) : normalizeTarget(to, matchers)\n return resolvePath(buildTargetPath(target.path, target.query, target.hash), target.state)\n }\n\n function resolvePath(rawPath: string, state?: unknown): RouteLocation {\n const parsed = parseTargetString(rawPath)\n const matched = matchers.find(matcher => matcher.regex.exec(parsed.path))\n const params = matched ? extractParams(matched, parsed.path) : {}\n const record = matched?.record ?? null\n const query = parsed.query\n const hash = parsed.hash\n return {\n path: parsed.path,\n fullPath: buildTargetPath(parsed.path, query, hash),\n params,\n query,\n hash,\n name: record?.name,\n meta: matched?.meta ?? {},\n record,\n matched: matched?.chain ?? EMPTY_MATCHED,\n state\n }\n }\n\n async function navigate(\n to: RouteTarget,\n replaceHistory: boolean,\n fromHistory: boolean,\n historyState?: unknown\n ): Promise<RouteLocation | false> {\n ensureActive()\n const id = ++navigationId\n const from = currentRoute.value\n let target = resolve(to)\n // popstate 回读的 state 保存在 history 条目上,不在目标描述里,这里回填。\n if (fromHistory && historyState !== undefined) target = { ...target, state: historyState }\n const source: NavigationTrace['source'] = fromHistory ? 'history' : replaceHistory ? 'replace' : 'push'\n const startedAt = now()\n const initialTarget = target.fullPath\n let terminalRecorded = false\n navigationState = { status: 'loading', from: from.fullPath, to: target.fullPath, traceId: id }\n emitRouter('navigation:start', navigationState)\n if (target.fullPath === from.fullPath && !fromHistory) {\n navigationState = { status: 'idle', from: from.fullPath, to: target.fullPath }\n return from\n }\n\n try {\n for (let redirectCount = 0; ; redirectCount++) {\n ensureNavigationIsCurrent(id)\n let redirect: RouteTarget | undefined\n for (const guard of [...guards]) {\n let result: NavigationGuardResult\n try {\n result = await guard(target, from)\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) throw reason\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw reason\n }\n ensureNavigationIsCurrent(id)\n if (result === false) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n return false\n }\n if (typeof result === 'string' || isRouteLocationRaw(result)) {\n redirect = result\n break\n }\n }\n\n for (const record of target.matched) {\n if (!record.loader) continue\n // 上一 loader 期间被新导航抢占时立即取消,跳过剩余 loader。\n ensureNavigationIsCurrent(id)\n await trackDataRequest(\n 'loader',\n `${target.fullPath}#${record.path ?? record.name ?? 'route'}`,\n context => record.loader!({ route: target, navigationId: id, dataRequestId: context.dataRequestId }),\n { route: target.fullPath, navigationId: id, trigger: 'navigation' }\n )\n }\n\n // loader 完成后、提交前必须重新校验:飞行期间被抢占的导航不允许覆盖 currentRoute 与 history。\n ensureNavigationIsCurrent(id)\n\n if (redirect !== undefined) {\n if (redirectCount >= 10) {\n const error = new NavigationRedirectError()\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n throw error\n }\n const redirected = resolve(redirect)\n if (redirected.fullPath === target.fullPath) return false\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'redirected', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: redirected.fullPath })\n target = redirected\n continue\n }\n\n if (target.fullPath === from.fullPath) return from\n if (!fromHistory) {\n if (replaceHistory) history.replace(target.fullPath, target.state)\n else history.push(target.fullPath, target.state)\n }\n currentRoute.value = target\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'success', source, startedAt, endedAt: now(), duration: now() - startedAt, redirect: target.fullPath !== initialTarget ? target.fullPath : undefined })\n terminalRecorded = true\n return target\n }\n } catch (reason) {\n if (reason instanceof NavigationCancelledError) {\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'cancelled', source, startedAt, endedAt: now(), duration: now() - startedAt })\n terminalRecorded = true\n } else if (!terminalRecorded) {\n const error = toError(reason)\n reportError('navigation', error, target.fullPath)\n recordNavigation({ id, from: from.fullPath, to: target.fullPath, status: 'error', source, startedAt, endedAt: now(), duration: now() - startedAt, error: error.message })\n terminalRecorded = true\n }\n throw reason\n }\n }\n\n function now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n }\n\n function emitRouter(event: RouterDevToolsEvent, payload: unknown): void {\n for (const callback of routerListeners.get(event) ?? []) {\n try { callback(payload) } catch { /* diagnostics must not affect navigation */ }\n }\n emitRouterDebug(routerDebugId, event, payload, getRuntimeDebugContext() ?? undefined)\n }\n\n function recordNavigation(trace: NavigationTrace): void {\n navigationHistory.push(Object.freeze(trace))\n if (navigationHistory.length > 100) navigationHistory.shift()\n navigationCount++\n totalNavigationDuration += trace.duration\n if (trace.duration >= 16) slowNavigationCount++\n if (trace.id === navigationId) {\n navigationState = trace.status === 'error'\n ? { status: 'error', from: trace.from, to: trace.to, traceId: trace.id, error: trace.error }\n : { status: 'idle', from: trace.from, to: trace.to, traceId: trace.id }\n }\n emitRouter('navigation:end', trace)\n emitRouter('route:update', currentRoute.value)\n }\n\n async function trackDataRequest<T>(\n kind: RouterDataRequestKind,\n key: string,\n task: ((context: { readonly dataRequestId: number }) => T | PromiseLike<T>) | (() => T | PromiseLike<T>),\n optionsOrRoute: RouterDataRequestOptions | string = {}\n ): Promise<T> {\n ensureActive()\n const options = typeof optionsOrRoute === 'string' ? { route: optionsOrRoute } : optionsOrRoute\n const id = nextDataRequestId++\n const startedAt = now()\n const context = getRuntimeDebugContext()\n const route = options.route ?? currentRoute.value.fullPath\n const requestContext: RuntimeDebugContext = {\n ...context,\n environment: options.environment ?? context?.environment,\n route,\n navigationId: options.navigationId ?? context?.navigationId,\n dataRequestId: id,\n source: kind\n }\n const loading: RouterDataRequestTrace = {\n id,\n kind,\n key,\n route,\n status: 'loading',\n startedAt,\n navigationId: requestContext.navigationId,\n trigger: options.trigger,\n environment: requestContext.environment\n }\n dataRequests.push(loading)\n if (dataRequests.length > 100) dataRequests.shift()\n dataRequestContexts.set(id, requestContext)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', loading)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'start', trace: loading }, requestContext)\n dataLoaders.set(key, { kind, route, task: task as () => unknown | PromiseLike<unknown> })\n try {\n const result = await runWithRuntimeDebugContext(requestContext, () => (task as (context: { readonly dataRequestId: number }) => T | PromiseLike<T>)({ dataRequestId: id }))\n const endedAt = now()\n replaceDataRequest(id, { ...loading, status: 'success', endedAt, duration: endedAt - startedAt, result })\n return result\n } catch (reason) {\n const endedAt = now()\n const error = toError(reason)\n const status = isAbortError(reason) ? 'cancelled' : 'error'\n if (status === 'error') reportError(kind, error, route, { requestId: id, navigationId: requestContext.navigationId })\n replaceDataRequest(id, { ...loading, status, endedAt, duration: endedAt - startedAt, error: status === 'error' ? error.message : undefined })\n throw reason\n }\n }\n\n function replaceDataRequest(id: number, trace: RouterDataRequestTrace): void {\n const index = dataRequests.findIndex(item => item.id === id)\n if (index >= 0) dataRequests[index] = Object.freeze(trace)\n emitRouter('route:update', currentRoute.value)\n emitRouter('data-request', trace)\n emitRouterDebug(routerDebugId, 'data-request', { phase: 'end', trace }, dataRequestContexts.get(id))\n dataRequestContexts.delete(id)\n }\n\n function reportError(\n phase: RouteErrorTrace['phase'],\n reason: unknown,\n route = currentRoute.value.fullPath,\n context: { readonly requestId?: number; readonly navigationId?: number } = {}\n ): void {\n const error = toError(reason)\n errors.push(Object.freeze({\n id: nextErrorId++,\n phase,\n route,\n message: error.message,\n stack: error.stack,\n timestamp: now(),\n requestId: context.requestId,\n navigationId: context.navigationId\n }))\n if (errors.length > 100) errors.shift()\n emitRouter('error', errors[errors.length - 1]!)\n emitRouter('route:update', currentRoute.value)\n }\n\n function routeTree(): readonly RouteDebugNode[] {\n const statuses = new Map<string, LazyState['status']>()\n for (const matcher of matchers) {\n for (const record of matcher.chain) {\n if (record.component && isLazyRouteComponent(record.component)) {\n const debugId = routeDebugIds.get(record)\n if (debugId) statuses.set(debugId, lazyStates.get(record)?.status ?? 'loading')\n }\n }\n }\n return buildRouteDebugTree(options.routes, statuses)\n }\n\n function handleHistoryNavigation(path: string, state: unknown): void {\n void navigate(path, false, true, state).then(result => {\n if (destroyed) return\n if (result === false) {\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n } else if (result.fullPath !== normalizeHistoryPath(path)) {\n history.replace(result.fullPath, result.state)\n }\n }).catch(error => {\n if (!(error instanceof NavigationCancelledError) && !destroyed) {\n const current = currentRoute.value.fullPath\n const failed = toError(error)\n reportError('navigation', failed, normalizeHistoryPath(path))\n navigationState = { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message }\n emitRouter('navigation:end', { status: 'error', from: current, to: normalizeHistoryPath(path), error: failed.message })\n history.replace(currentRoute.value.fullPath, currentRoute.value.state)\n }\n })\n }\n\n const stopHistory = history.listen(handleHistoryNavigation)\n\n const router: Router = {\n currentRoute,\n history,\n\n resolve,\n\n push(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, false, false)\n },\n\n replace(to: RouteTarget): Promise<RouteLocation | false> {\n return navigate(to, true, false)\n },\n\n back(): void {\n ensureActive()\n history.back()\n },\n\n beforeEach(guard: NavigationGuard): () => void {\n ensureActive()\n guards.push(guard)\n return () => {\n const index = guards.indexOf(guard)\n if (index >= 0) guards.splice(index, 1)\n }\n },\n\n getViewState(route: RouteLocation): RouterViewState {\n viewRevision.value\n const records = route.matched.length > 0 ? route.matched : route.record ? [route.record] : []\n const entries = records\n .map(record => ({ record, definition: record.component }))\n .filter((entry): entry is { record: RouteRecord; definition: RouteComponentDefinition } =>\n isRouteComponentDefinition(entry.definition))\n if (!route.record || entries.length === 0) return { status: 'not-found', retry: () => undefined }\n\n const loaded: RouteComponent[] = []\n const lazyRecords: RouteRecord[] = []\n for (const entry of entries) {\n const { record, definition } = entry\n if (!isLazyRouteComponent(definition)) {\n loaded.push(definition)\n continue\n }\n lazyRecords.push(record)\n const lazyState = ensureLazyState(record, definition)\n if (lazyState.status === 'loading') return { status: 'loading', retry: () => retryLazyRoutes(lazyRecords) }\n if (lazyState.status === 'error') {\n return { status: 'error', error: lazyState.error, retry: () => retryLazyRoutes(lazyRecords) }\n }\n if (lazyState.component) loaded.push(lazyState.component)\n }\n\n const component = loaded[loaded.length - 1]\n if (!component) return { status: 'not-found', retry: () => undefined }\n return {\n status: 'ready',\n component,\n layouts: loaded.slice(0, -1),\n retry: () => retryLazyRoutes(lazyRecords)\n }\n },\n\n devtools: {\n getRouteTree: routeTree,\n getCurrentRoute: () => currentRoute.value,\n getNavigationState: () => navigationState,\n getNavigationHistory: () => [...navigationHistory],\n getPerformanceMetrics: () => ({\n navigationCount,\n averageNavigationDuration: navigationCount === 0 ? 0 : totalNavigationDuration / navigationCount,\n slowNavigationCount\n }),\n getDataRequests: () => [...dataRequests],\n getErrors: () => [...errors],\n trackDataRequest,\n runAction: (key, task) => trackDataRequest('action', key, task, { trigger: 'manual' }),\n runFetcher: (key, task) => trackDataRequest('fetcher', key, task, { trigger: 'manual' }),\n reportError,\n revalidate: async (route) => {\n await Promise.all([...dataLoaders.entries()]\n .filter(([, loader]) => loader.kind === 'loader' && (route === undefined || loader.route === route))\n .map(([key, loader]) => trackDataRequest(loader.kind, key, loader.task, { route: loader.route, trigger: 'revalidate' })))\n },\n subscribe(event, callback) {\n let listeners = routerListeners.get(event)\n if (!listeners) { listeners = new Set(); routerListeners.set(event, listeners) }\n listeners.add(callback)\n return () => listeners?.delete(callback)\n }\n },\n\n destroy(): void {\n if (destroyed) return\n destroyed = true\n navigationId++\n stopHistory()\n guards.length = 0\n routerListeners.clear()\n lazyStates.clear()\n errors.length = 0\n dataRequestContexts.clear()\n currentRoute.dispose()\n viewRevision.dispose()\n }\n }\n\n function ensureLazyState(record: RouteRecord, definition: LazyRouteComponent): LazyState {\n let lazyState = lazyStates.get(record)\n if (!lazyState) {\n lazyState = { status: 'loading' }\n lazyStates.set(record, lazyState)\n void loadRouteComponent(definition).then(component => {\n if (destroyed) return\n lazyState!.status = 'ready'\n lazyState!.component = component\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n }).catch(reason => {\n if (destroyed) return\n lazyState!.status = 'error'\n lazyState!.error = toError(reason)\n reportError('lazy', reason, currentRoute.value.fullPath)\n viewRevision.value++\n emitRouter('route:update', currentRoute.value)\n })\n }\n return lazyState\n }\n\n function retryLazyRoutes(records: readonly RouteRecord[]): void {\n for (const record of records) lazyStates.delete(record)\n viewRevision.value++\n }\n\n function ensureActive(): void {\n if (destroyed) throw new Error('Vobs Router: 已销毁的 Router 不能继续使用')\n }\n\n function ensureNavigationIsCurrent(id: number): void {\n if (id !== navigationId) throw new NavigationCancelledError()\n }\n\n return router\n}\n\nexport function RouterView(props: RouterViewProps = {}): VobsNode {\n const router = props.router ?? inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: RouterView 找不到 Router,请安装 routerPlugin')\n\n return createFragment((parent, anchor) => {\n let routeRetry: () => void = () => undefined\n insertBoundary(parent, anchor, {\n resetKey: () => router.currentRoute.value.fullPath,\n onRetry: () => routeRetry(),\n fallback: (error, retry) => {\n router.devtools.reportError('render', error, router.currentRoute.value.fullPath)\n return props.error?.(error, () => { void retry() }) ?? null\n },\n children: () => {\n const route = router.currentRoute.value\n const view = router.getViewState(route)\n routeRetry = view.retry\n if (view.status === 'loading') {\n return (typeof props.loading === 'function' ? props.loading() : props.loading) ?? null\n }\n if (view.status === 'not-found') return props.notFound?.(route) ?? null\n if (view.status === 'error') {\n throw view.error ?? new Error('路由组件加载失败')\n }\n if (!view.component) return null\n let node = createComponent(view.component, {\n route,\n params: route.params,\n query: route.query\n })\n for (let index = (view.layouts?.length ?? 0) - 1; index >= 0; index--) {\n node = createComponent(view.layouts![index]!, {\n route,\n params: route.params,\n query: route.query,\n children: node\n })\n }\n return node\n }})\n })\n}\n\nexport function useRouter(): Router {\n const router = inject(ROUTER_KEY)\n if (!router) throw new Error('Vobs Router: useRouter 找不到 Router,请安装 routerPlugin')\n return router\n}\n\nexport function useRoute(): Signal<RouteLocation> {\n return useRouter().currentRoute\n}\n\nexport function routerPlugin(options: RouterPluginOptions = {}): VobsPlugin {\n return {\n name: '@vobs/router',\n version: '0.1.0',\n install(context) {\n const ownedRouter = options.router ? undefined : createRouter({\n routes: options.routes ?? [],\n history: options.history\n })\n const router = options.router ?? ownedRouter!\n context.provide(ROUTER_KEY, router)\n return () => ownedRouter?.destroy()\n }\n }\n}\n\ninterface RouteMatcher {\n readonly record: RouteRecord\n readonly debugId: string\n readonly chain: readonly RouteRecord[]\n readonly meta: RouteMeta\n readonly regex: RegExp\n readonly keys: readonly string[]\n readonly score: number\n readonly order: number\n}\n\ninterface LazyState {\n status: 'loading' | 'ready' | 'error'\n component?: RouteComponent\n error?: Error\n}\n\ninterface ParsedTarget {\n readonly path: string\n readonly query: RouteQuery\n readonly hash: string\n readonly state?: unknown\n}\n\nfunction defaultHistory(): RouterHistory {\n return typeof window === 'undefined' ? createMemoryHistory('/') : createBrowserHistory()\n}\n\nconst EMPTY_MATCHED: readonly RouteRecord[] = Object.freeze([])\nconst routeDebugIds = new WeakMap<RouteRecord, string>()\n\nfunction buildRouteDebugTree(routes: readonly RouteRecord[], lazyStatuses: ReadonlyMap<string, LazyState['status']> = new Map()): readonly RouteDebugNode[] {\n const visit = (records: readonly RouteRecord[], parentPath: string, parentId: string): RouteDebugNode[] => records.map((record, index) => {\n const path = record.path === undefined ? parentPath || '/' : resolveChildPath(parentPath, record.path)\n const id = `${parentId}.${index}`\n const definition = record.component\n const lazyDefinition = definition !== undefined && isLazyRouteComponent(definition)\n const componentName = definition === undefined\n ? 'Route'\n : lazyDefinition\n ? 'lazy(...)'\n : typeof definition === 'function'\n ? definition.name || 'Anonymous'\n : 'Route'\n return {\n id,\n path,\n name: record.name,\n component: componentName,\n source: record.source,\n lazy: lazyDefinition,\n loader: record.loader !== undefined,\n action: record.action !== undefined,\n status: lazyDefinition ? (lazyStatuses.get(id) ?? 'loading') : 'ready',\n meta: Object.freeze({ ...(record.meta ?? {}) }),\n children: visit(record.children ?? [], path, id)\n }\n })\n return Object.freeze(visit(routes, '', 'route'))\n}\n\nfunction normalizeRoutes(routes: readonly RouteRecord[]): RouteMatcher[] {\n const matchers: RouteMatcher[] = []\n let order = 0\n\n function visit(records: readonly RouteRecord[], parentPath: string, parentChain: readonly RouteRecord[], parentMeta: RouteMeta, parentId = 'route'): void {\n records.forEach((record, index) => {\n const debugId = `${parentId}.${index}`\n const children = record.children ?? []\n const path = record.path === undefined\n ? parentPath\n : resolveChildPath(parentPath, record.path)\n const normalized: RouteRecord = {\n ...record,\n path: record.path === undefined\n ? (children.length > 0 ? undefined : (path || '/'))\n : path,\n meta: record.meta ? { ...record.meta } : {}\n }\n routeDebugIds.set(normalized, debugId)\n const chain = [...parentChain, normalized]\n const meta = Object.freeze({ ...parentMeta, ...(normalized.meta ?? {}) })\n if (children.length > 0) {\n visit(children, path, chain, meta, debugId)\n } else if (normalized.component) {\n matchers.push(createMatcher(normalized, chain, meta, order++, debugId))\n } else if (normalized.path === undefined) {\n throw new Error(`Vobs Router: 第 ${index + 1} 个路由缺少 path 或 children`)\n }\n })\n }\n\n visit(routes, '', [], {})\n return matchers\n}\n\nfunction resolveChildPath(parentPath: string, childPath: string): string {\n const normalizedChild = normalizePath(childPath)\n if (!parentPath || normalizedChild === '/') return normalizedChild === '/' ? (parentPath || '/') : normalizedChild\n if (childPath.startsWith('/')) return normalizedChild\n return normalizePath(`${parentPath}/${childPath}`)\n}\n\nfunction createMatcher(record: RouteRecord, chain: readonly RouteRecord[], meta: RouteMeta, order: number, debugId: string): RouteMatcher {\n const path = record.path ?? '/'\n const segments = path === '/' ? [] : path.slice(1).split('/')\n const keys: string[] = []\n let score = 0\n const pattern = segments.map(segment => {\n if (segment === '*') {\n keys.push('pathMatch')\n return '(.*)'\n }\n if (segment.startsWith(':')) {\n const key = segment.slice(1)\n if (!key) throw new Error(`Vobs Router: 路由 ${path} 的参数名不能为空`)\n if (keys.includes(key)) throw new Error(`Vobs Router: 路由 ${path} 存在重复参数 ${key}`)\n keys.push(key)\n score += 1\n return '([^/]+)'\n }\n score += 3\n return escapeRegExp(segment)\n }).join('/')\n\n return {\n record,\n debugId,\n chain: Object.freeze([...chain]),\n meta,\n regex: new RegExp(segments.length === 0 ? '^/?$' : `^/${pattern}/?$`),\n keys,\n score,\n order\n }\n}\n\nfunction compareMatchers(left: RouteMatcher, right: RouteMatcher): number {\n return right.score - left.score || left.order - right.order\n}\n\nfunction extractParams(matcher: RouteMatcher, path: string): RouteParams {\n const match = matcher.regex.exec(path)\n if (!match) return {}\n const params: Record<string, string> = {}\n matcher.keys.forEach((key, index) => {\n params[key] = decodeRoutePart(match[index + 1] ?? '')\n })\n return Object.freeze(params)\n}\n\nfunction parseTargetString(raw: string): ParsedTarget {\n const hashIndex = raw.indexOf('#')\n const hash = hashIndex >= 0 ? normalizeHash(raw.slice(hashIndex + 1)) : ''\n const withoutHash = hashIndex >= 0 ? raw.slice(0, hashIndex) : raw\n const queryIndex = withoutHash.indexOf('?')\n const path = normalizePath(queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash)\n const query = queryIndex >= 0 ? parseQuery(withoutHash.slice(queryIndex + 1)) : {}\n return { path, query, hash }\n}\n\nfunction normalizeTarget(target: RouteLocationRaw, matchers: readonly RouteMatcher[]): ParsedTarget {\n let path = target.path\n if (!path && target.name) {\n const matcher = matchers.find(candidate => candidate.record.name === target.name)\n if (!matcher) throw new Error(`Vobs Router: 找不到名为 ${target.name} 的路由`)\n path = fillRouteParams(matcher.record.path ?? '/', target.params ?? {})\n }\n if (!path) throw new Error('Vobs Router: 导航目标必须提供 path 或 name')\n\n const parsed = parseTargetString(path)\n const filledPath = fillRouteParams(parsed.path, target.params ?? {})\n const query = target.query === undefined ? parsed.query : normalizeQuery(target.query)\n const hash = target.hash === undefined ? parsed.hash : normalizeHash(target.hash)\n return { path: filledPath, query, hash, state: target.state }\n}\n\nfunction fillRouteParams(path: string, params: Record<string, unknown>): string {\n return path.replace(/:([A-Za-z0-9_]+)|\\*/g, (token, key: string | undefined) => {\n const value = key ? params[key] : params.pathMatch\n if (value === undefined || value === null) return token\n return encodeURIComponent(String(value))\n })\n}\n\nfunction buildTargetPath(path: string, query: RouteQuery, hash: string): string {\n const params = new URLSearchParams()\n for (const key of Object.keys(query).sort()) {\n const value = query[key]\n if (typeof value === 'string') {\n params.set(key, value)\n } else {\n for (const item of value) params.append(key, item)\n }\n }\n const serialized = params.toString()\n return `${path}${serialized ? `?${serialized}` : ''}${hash}`\n}\n\nfunction parseQuery(raw: string): RouteQuery {\n const params = new URLSearchParams(raw)\n const result: Record<string, RouteQueryValue> = {}\n params.forEach((value, key) => {\n const previous = result[key]\n if (previous === undefined) result[key] = value\n else if (typeof previous === 'string') result[key] = [previous, value]\n else result[key] = [...previous, value]\n })\n for (const key of Object.keys(result)) {\n if (Array.isArray(result[key])) result[key] = Object.freeze(result[key] as string[])\n }\n return Object.freeze(result)\n}\n\nfunction normalizeQuery(input: RouteQueryInput): RouteQuery {\n if (input instanceof URLSearchParams) return parseQuery(input.toString())\n const result: Record<string, RouteQueryValue> = {}\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null) continue\n if (Array.isArray(value)) result[key] = Object.freeze(value.map(item => String(item)))\n else result[key] = String(value)\n }\n return Object.freeze(result)\n}\n\nfunction normalizePath(path: string): string {\n if (!path) return '/'\n const withoutQuery = path.split(/[?#]/, 1)[0] || '/'\n const withLeadingSlash = withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}`\n if (withLeadingSlash === '/*' || withLeadingSlash === '/') return withLeadingSlash\n return withLeadingSlash.replace(/\\/+/g, '/').replace(/\\/$/, '') || '/'\n}\n\nfunction normalizeHistoryPath(path: string): string {\n const parsed = parseTargetString(path)\n return buildTargetPath(parsed.path, parsed.query, parsed.hash)\n}\n\nfunction normalizeHash(hash: string): string {\n if (!hash) return ''\n return hash.startsWith('#') ? hash : `#${hash}`\n}\n\nfunction normalizeBase(base: string): string {\n if (!base || base === '/') return ''\n return `/${base.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nfunction readBrowserLocation(base: string): string {\n const pathname = window.location.pathname\n const path = base && (pathname === base || pathname.startsWith(`${base}/`))\n ? pathname.slice(base.length) || '/'\n : pathname\n return normalizeHistoryPath(`${path}${window.location.search}${window.location.hash}`)\n}\n\nfunction withBase(path: string, base: string): string {\n return `${base}${path === '/' ? '/' : path}` || '/'\n}\n\nfunction notifyListeners(listeners: Set<(path: string, state: unknown) => void>, path: string, state: unknown): void {\n for (const listener of [...listeners]) listener(path, state)\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction decodeRoutePart(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\nfunction isLazyRouteComponent(value: RouteComponentDefinition): value is LazyRouteComponent {\n return typeof value === 'object' && value !== null && value.kind === 'vobs-lazy-route'\n}\n\nfunction isRouteComponentDefinition(value: unknown): value is RouteComponentDefinition {\n return typeof value === 'function' || isLazyRouteComponent(value as RouteComponentDefinition)\n}\n\nasync function loadRouteComponent(loader: LazyRouteComponent): Promise<RouteComponent> {\n const module = await loader.load()\n const component = typeof module === 'function' ? module : module.default\n if (typeof component !== 'function') throw new Error('Vobs Router: 懒加载模块没有默认组件导出')\n return component\n}\n\nfunction isRouteLocationRaw(value: unknown): value is RouteLocationRaw {\n return Boolean(value) && typeof value === 'object'\n}\n\nfunction toError(reason: unknown): Error {\n return reason instanceof Error ? reason : new Error(String(reason))\n}\n\nfunction isAbortError(reason: unknown): boolean {\n return Boolean(reason) && typeof reason === 'object'\n && ((reason as { readonly name?: unknown }).name === 'AbortError'\n || (reason as { readonly code?: unknown }).code === 'ERR_CANCELED')\n}\n","import type { RuntimeDebugContext } from '@vobs/runtime'\n\nexport type RouterDebugEventType =\n | 'navigation:start'\n | 'navigation:end'\n | 'route:update'\n | 'data-request'\n | 'error'\n\nexport interface RouterDebugEvent {\n readonly routerId: string\n readonly type: RouterDebugEventType\n readonly payload: unknown\n readonly context?: RuntimeDebugContext\n}\n\ntype RouterDebugListener = (event: RouterDebugEvent) => void\n\nconst listeners = new Set<RouterDebugListener>()\nlet nextRouterId = 1\n\nexport function createRouterDebugId(): string {\n return `router-${nextRouterId++}`\n}\n\nexport function subscribeRouterDebug(listener: RouterDebugListener): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nexport function emitRouterDebug(\n routerId: string,\n type: RouterDebugEventType,\n payload: unknown,\n context?: RuntimeDebugContext\n): void {\n const event: RouterDebugEvent = { routerId, type, payload, context }\n for (const listener of [...listeners]) {\n try { listener(event) } catch { /* diagnostics must not affect navigation */ }\n }\n}\n"],"mappings":";;;;AAAA,SAAS,aAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;ACQP,IAAM,YAAY,oBAAI,IAAyB;AAC/C,IAAI,eAAe;AAEZ,SAAS,sBAA8B;AAC5C,SAAO,UAAU,cAAc;AACjC;AAFgB;AAIT,SAAS,qBAAqB,UAA2C;AAC9E,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM,UAAU,OAAO,QAAQ;AACxC;AAHgB;AAKT,SAAS,gBACd,UACA,MACA,SACA,SACM;AACN,QAAM,QAA0B,EAAE,UAAU,MAAM,SAAS,QAAQ;AACnE,aAAW,YAAY,CAAC,GAAG,SAAS,GAAG;AACrC,QAAI;AAAE,eAAS,KAAK;AAAA,IAAE,QAAQ;AAAA,IAA+C;AAAA,EAC/E;AACF;AAVgB;;;ADfhB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA+EA,IAAM,4BAAN,MAAM,kCAAiC,MAAM;AAAA,EAGlD,cAAc;AACZ,UAAM,iFAA0B;AAHlC,SAAS,OAAO;AAId,SAAK,OAAO;AAAA,EACd;AACF;AAPoD;AAA7C,IAAM,2BAAN;AASA,IAAM,2BAAN,MAAM,iCAAgC,MAAM;AAAA,EAGjD,cAAc;AACZ,UAAM,iFAA0B;AAHlC,SAAS,OAAO;AAId,SAAK,OAAO;AAAA,EACd;AACF;AAPmD;AAA5C,IAAM,0BAAN;AA+JA,IAAM,aAAmC,mBAA2B,aAAa;AAEjF,SAAS,KAAK,QAAkD;AACrE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AALgB;AAOT,SAAS,oBAAoB,UAAU,KAAoB;AAChE,MAAI,UAAU,CAAC,EAAE,MAAM,qBAAqB,OAAO,GAAG,OAAO,OAAqB,CAAC;AACnF,MAAI,QAAQ;AACZ,QAAMA,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M,OAAO,KAAK;AACjC,QAAM,YAAY,OAAO,WAAW,aAAa,SAAS,OAAO;AACjE,MAAI,OAAO,cAAc,WAAY,OAAM,IAAI,MAAM,6FAA4B;AACjF,SAAO;AACT;AALe;AAOf,SAAS,mBAAmB,OAA2C;AACrE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU;AAC5C;AAFS;AAIT,SAAS,QAAQ,QAAwB;AACvC,SAAO,kBAAkB,QAAQ,SAAS,IAAI,MAAM,OAAO,MAAM,CAAC;AACpE;AAFS;AAIT,SAAS,aAAa,QAA0B;AAC9C,SAAO,QAAQ,MAAM,KAAK,OAAO,WAAW,aACrC,OAAuC,SAAS,gBAC/C,OAAuC,SAAS;AAC1D;AAJS;","names":["listeners","state","options"]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/vobsjs/vobs.git"
13
13
  },
14
- "version": "1.2.2",
14
+ "version": "1.3.0",
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
@@ -33,8 +33,8 @@
33
33
  "./source/*": "./src/*"
34
34
  },
35
35
  "dependencies": {
36
- "@vobs/reactivity": "1.2.2",
37
- "@vobs/runtime": "1.2.2",
38
- "@vobs/vobs": "1.2.2"
36
+ "@vobs/runtime": "1.3.0",
37
+ "@vobs/reactivity": "1.3.0",
38
+ "@vobs/vobs": "1.3.0"
39
39
  }
40
40
  }
package/src/index.ts CHANGED
@@ -252,7 +252,8 @@ export interface Router {
252
252
 
253
253
  export interface RouterViewProps {
254
254
  readonly router?: Router
255
- readonly loading?: () => VobsNode | null | undefined
255
+ /** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */
256
+ readonly loading?: VobsNode | (() => VobsNode | null | undefined)
256
257
  readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined
257
258
  readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined
258
259
  }
@@ -817,7 +818,9 @@ export function RouterView(props: RouterViewProps = {}): VobsNode {
817
818
  const route = router.currentRoute.value
818
819
  const view = router.getViewState(route)
819
820
  routeRetry = view.retry
820
- if (view.status === 'loading') return props.loading?.() ?? null
821
+ if (view.status === 'loading') {
822
+ return (typeof props.loading === 'function' ? props.loading() : props.loading) ?? null
823
+ }
821
824
  if (view.status === 'not-found') return props.notFound?.(route) ?? null
822
825
  if (view.status === 'error') {
823
826
  throw view.error ?? new Error('路由组件加载失败')