wevu 6.25.0 → 7.0.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/dev/index.mjs +1 -1
- package/dist/dev/internal-runtime.mjs +1 -1
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/router/backNavigation.mjs +1 -1
- package/dist/dev/router/createRouter.mjs +28 -1
- package/dist/dev/router/createRouter.mjs.map +1 -1
- package/dist/dev/router/initialNavigation.mjs +15 -0
- package/dist/dev/router/initialNavigation.mjs.map +1 -0
- package/dist/dev/router/navigationApi.mjs +1 -1
- package/dist/dev/router/navigationResult.mjs +1 -1
- package/dist/dev/router/navigationTarget.mjs +5 -4
- package/dist/dev/router/navigationTarget.mjs.map +1 -1
- package/dist/dev/router/navigationTargetHelpers.mjs +1 -1
- package/dist/dev/router/useRoute.mjs +1 -1
- package/dist/dev/router.mjs +1 -1
- package/dist/dev/runtime/register/component/lifecycle.mjs +72 -14
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +71 -32
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/vue-demi.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal-runtime.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/router/backNavigation.mjs +1 -1
- package/dist/router/createRouter.mjs +1 -1
- package/dist/router/initialNavigation.mjs +1 -0
- package/dist/router/navigationApi.mjs +1 -1
- package/dist/router/navigationResult.mjs +1 -1
- package/dist/router/navigationTarget.mjs +1 -1
- package/dist/router/navigationTargetHelpers.mjs +1 -1
- package/dist/router/useRoute.mjs +1 -1
- package/dist/router.mjs +1 -1
- package/dist/runtime/register/component/lifecycle.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/vue-demi.mjs +1 -1
- package/package.json +5 -5
package/dist/dev/index.mjs
CHANGED
|
@@ -24,11 +24,11 @@ import { resolveRuntimePageLayoutName, setPageLayout, syncRuntimePageLayoutState
|
|
|
24
24
|
import { runSetupFunction } from "./runtime/register/setup.mjs";
|
|
25
25
|
import { mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from "./runtime/register/runtimeInstance.mjs";
|
|
26
26
|
import { registerApp } from "./runtime/register/app.mjs";
|
|
27
|
+
import { hasInjectionContext, inject, injectGlobal, provide, provideGlobal } from "./runtime/provide.mjs";
|
|
27
28
|
import { registerPageLayoutBridge, registerRuntimeLayoutHosts, resolveLayoutBridge, resolveLayoutHost, unregisterPageLayoutBridge, unregisterRuntimeLayoutHosts, useLayoutBridge, useLayoutHosts, waitForLayoutHost } from "./runtime/layoutBridge.mjs";
|
|
28
29
|
import { registerComponent } from "./runtime/register/component.mjs";
|
|
29
30
|
import { createApp } from "./runtime/app.mjs";
|
|
30
31
|
import { useCssModule } from "./runtime/css.mjs";
|
|
31
|
-
import { hasInjectionContext, inject, injectGlobal, provide, provideGlobal } from "./runtime/provide.mjs";
|
|
32
32
|
import { createWevuComponent, createWevuScopedSlotComponent, defineComponent } from "./runtime/define.mjs";
|
|
33
33
|
import { useDisposables } from "./runtime/disposables.mjs";
|
|
34
34
|
import { useElementIntersectionObserver } from "./runtime/elementIntersectionObserver.mjs";
|
|
@@ -10,12 +10,12 @@ import { resolveRuntimePageLayoutName, setPageLayout, syncRuntimePageLayoutState
|
|
|
10
10
|
import { runSetupFunction } from "./runtime/register/setup.mjs";
|
|
11
11
|
import { mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from "./runtime/register/runtimeInstance.mjs";
|
|
12
12
|
import { registerApp } from "./runtime/register/app.mjs";
|
|
13
|
+
import { hasInjectionContext, inject, injectGlobal, provide, provideGlobal } from "./runtime/provide.mjs";
|
|
13
14
|
import { Fragment, createTextVNode, createVNode, isVNode, mergeProps, normalizeJsxIsland, resolveComponent, resolveDirective, transformOn, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, withDirectives } from "./runtime/jsxIsland.mjs";
|
|
14
15
|
import { resolveLayoutBridge, resolveLayoutHost, useLayoutBridge, useLayoutHosts, waitForLayoutHost } from "./runtime/layoutBridge.mjs";
|
|
15
16
|
import { registerComponent } from "./runtime/register/component.mjs";
|
|
16
17
|
import { createApp } from "./runtime/app.mjs";
|
|
17
18
|
import { useCssModule, useCssVars } from "./runtime/css.mjs";
|
|
18
|
-
import { hasInjectionContext, inject, injectGlobal, provide, provideGlobal } from "./runtime/provide.mjs";
|
|
19
19
|
import { createIsolatedWevuComponentDefinition, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition } from "./runtime/define.mjs";
|
|
20
20
|
import { useDisposables } from "./runtime/disposables.mjs";
|
|
21
21
|
import { useElementIntersectionObserver } from "./runtime/elementIntersectionObserver.mjs";
|
package/dist/dev/package.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getCurrentMiniProgramPages } from "../runtime/platform.mjs";
|
|
2
|
-
import { resolvePageRoute } from "../routerInternal/location.mjs";
|
|
3
2
|
import { NavigationFailureType } from "./types.mjs";
|
|
4
3
|
import { createNavigationFailure, runNavigationGuards } from "./navigationCore.mjs";
|
|
4
|
+
import { resolvePageRoute } from "../routerInternal/location.mjs";
|
|
5
5
|
import { createNavigationRunResult } from "./navigationResult.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/router/backNavigation.ts
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { getMiniProgramGlobalObject } from "../runtime/platform.mjs";
|
|
2
|
+
import { setActiveRouter } from "./instance.mjs";
|
|
3
|
+
import { registerInitialNavigationRunner } from "./initialNavigation.mjs";
|
|
2
4
|
import { installRouteStateSyncOnNativeRouter } from "./routeSync.mjs";
|
|
3
5
|
import { resolvePath } from "../routerInternal/path.mjs";
|
|
4
6
|
import { parseQuery, stringifyQuery } from "../routerInternal/query.mjs";
|
|
7
|
+
import { resolveCurrentRoute } from "../routerInternal/location.mjs";
|
|
5
8
|
import { resolveNamedRouteLocation } from "../routerInternal/params.mjs";
|
|
6
9
|
import { mergeMatchedRouteMeta, resolveMatchedRouteRecord } from "../routerInternal/matching.mjs";
|
|
7
10
|
import { warnDuplicateRouteEntries } from "../routerInternal/recordsWarnings.mjs";
|
|
@@ -9,7 +12,7 @@ import { createNamedRouteLookup, resolveRouteOptionEntries } from "../routerInte
|
|
|
9
12
|
import { cloneRouteMeta, cloneRouteParams, createRouterOptionsSnapshot, normalizeRouteRecordMatched, snapshotRouteLocation } from "../routerInternal/snapshots.mjs";
|
|
10
13
|
import { createNavigationResultController } from "./navigationResult.mjs";
|
|
11
14
|
import { runBackNavigationGuards } from "./backNavigation.mjs";
|
|
12
|
-
import {
|
|
15
|
+
import { navigateWithTarget } from "./navigationTarget.mjs";
|
|
13
16
|
import { createNavigationApi } from "./navigationApi.mjs";
|
|
14
17
|
import { resolveRouteLocation } from "./resolve.mjs";
|
|
15
18
|
import { createRouteRegistry } from "./routeRegistry.mjs";
|
|
@@ -117,6 +120,29 @@ function createRouter(options = {}) {
|
|
|
117
120
|
managedNavigationCount -= 1;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
123
|
+
async function runInitialNavigation(page, query) {
|
|
124
|
+
return runManagedNavigation(async () => {
|
|
125
|
+
const from = snapshotRouteLocation(route);
|
|
126
|
+
const target = enrichRouteRecordState(resolveCurrentRoute(query, page));
|
|
127
|
+
if (!target.path) return;
|
|
128
|
+
const result = await navigateWithTarget({
|
|
129
|
+
mode: "push",
|
|
130
|
+
target,
|
|
131
|
+
from,
|
|
132
|
+
nativeRouter,
|
|
133
|
+
routeResolveCodec,
|
|
134
|
+
namedRouteLookup,
|
|
135
|
+
beforeEachGuards,
|
|
136
|
+
beforeResolveGuards,
|
|
137
|
+
maxRedirects,
|
|
138
|
+
tabBarPathSet,
|
|
139
|
+
resolveWithCodec,
|
|
140
|
+
executeNative: false,
|
|
141
|
+
allowSameLocation: true
|
|
142
|
+
});
|
|
143
|
+
return navigationResultController.settleNavigationResult(result);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
120
146
|
function beforeEach(guard) {
|
|
121
147
|
beforeEachGuards.add(guard);
|
|
122
148
|
return () => {
|
|
@@ -171,6 +197,7 @@ function createRouter(options = {}) {
|
|
|
171
197
|
onError
|
|
172
198
|
};
|
|
173
199
|
setActiveRouter(router);
|
|
200
|
+
registerInitialNavigationRunner(router, runInitialNavigation);
|
|
174
201
|
return router;
|
|
175
202
|
}
|
|
176
203
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouter.mjs","names":[],"sources":["../../../src/router/createRouter.ts"],"sourcesContent":["import type { RouteResolveCodec } from '../routerInternal/shared'\nimport type { NavigationRunResult } from './navigationResult'\nimport type { RouteStateSyncPayload } from './routeSync'\nimport type {\n NavigationAfterEach,\n NavigationErrorHandler,\n NavigationGuard,\n RouteLocationNormalizedLoaded,\n RouteLocationRaw,\n RouterNavigation,\n UseRouterOptions,\n} from './types'\nimport {\n cloneRouteMeta,\n cloneRouteParams,\n createNamedRouteLookup,\n createRouterOptionsSnapshot,\n mergeMatchedRouteMeta,\n normalizeRouteRecordMatched,\n parseQuery,\n resolveMatchedRouteRecord,\n resolveNamedRouteLocation,\n resolvePath,\n resolveRouteOptionEntries,\n snapshotRouteLocation,\n stringifyQuery,\n warnDuplicateRouteEntries,\n} from '../routerInternal/shared'\nimport { getMiniProgramGlobalObject } from '../runtime/platform'\nimport { runBackNavigationGuards } from './backNavigation'\nimport { setActiveRouter } from './instance'\nimport { createNavigationApi } from './navigationApi'\nimport { createNavigationResultController } from './navigationResult'\nimport { resolveRouteLocation } from './resolve'\nimport { createRouteRegistry } from './routeRegistry'\nimport { installRouteStateSyncOnNativeRouter } from './routeSync'\nimport { createRouteStateController, useNativeRouter } from './useRoute'\n\n/**\n * @description 创建高阶路由导航器(对齐 Vue Router 的 createRouter 心智)\n */\nexport function createRouter(options: UseRouterOptions = {}): RouterNavigation {\n const nativeRouter = useNativeRouter()\n installRouteStateSyncOnNativeRouter(getMiniProgramGlobalObject())\n const beforeEachGuards = new Set<NavigationGuard>()\n const beforeResolveGuards = new Set<NavigationGuard>()\n const afterEachHooks = new Set<NavigationAfterEach>()\n const errorHandlers = new Set<NavigationErrorHandler>()\n const maxRedirects = options.maxRedirects ?? 10\n const paramsMode = options.paramsMode ?? 'loose'\n const rejectOnError = options.rejectOnError ?? true\n const routeResolveCodec: RouteResolveCodec = {\n parseQuery: options.parseQuery ?? parseQuery,\n stringifyQuery: options.stringifyQuery ?? stringifyQuery,\n }\n const readyPromise = Promise.resolve()\n const routeEntries = resolveRouteOptionEntries(options)\n warnDuplicateRouteEntries(routeEntries)\n const namedRouteLookup = createNamedRouteLookup(routeEntries)\n const normalizedTabBarEntries = (options.tabBarEntries ?? [])\n .map(path => resolvePath(path, ''))\n .filter(Boolean)\n const tabBarPathSet = new Set(normalizedTabBarEntries)\n const routeRegistry = createRouteRegistry(namedRouteLookup)\n let managedNavigationCount = 0\n const routerOptions = createRouterOptionsSnapshot(\n normalizedTabBarEntries,\n routeRegistry.getRoutes(),\n paramsMode,\n maxRedirects,\n routeResolveCodec,\n rejectOnError,\n )\n\n function enrichRouteRecordState(routeLocation: RouteLocationNormalizedLoaded): RouteLocationNormalizedLoaded {\n const resolved = { ...routeLocation }\n resolved.href = resolved.fullPath\n const matchedResult = resolveMatchedRouteRecord(resolved, namedRouteLookup)\n if (matchedResult) {\n const matchedRecord = matchedResult.record\n if (resolved.name === undefined) {\n resolved.name = matchedRecord.name\n }\n const mergedRouteMeta = mergeMatchedRouteMeta(matchedResult.matchedRecords)\n if (mergedRouteMeta !== undefined) {\n resolved.meta = cloneRouteMeta(mergedRouteMeta)\n }\n if (matchedResult.params && Object.keys(resolved.params).length === 0) {\n resolved.params = cloneRouteParams(matchedResult.params)\n }\n resolved.matched = matchedResult.matchedRecords.map((record, index, records) => {\n const leafMatchedPath = index === records.length - 1\n ? matchedResult.matchedPath\n : undefined\n return normalizeRouteRecordMatched(record, leafMatchedPath)\n })\n }\n else {\n resolved.matched = []\n }\n return resolved\n }\n\n function resolveWithCodec(to: RouteLocationRaw, currentPath: string): RouteLocationNormalizedLoaded {\n const rawTo = typeof to === 'string'\n ? to\n : resolveNamedRouteLocation(to, namedRouteLookup, paramsMode)\n return enrichRouteRecordState(resolveRouteLocation(rawTo, currentPath, routeResolveCodec))\n }\n\n let route: Readonly<RouteLocationNormalizedLoaded>\n let emitObservedNavigationAfterEach: ((result: NavigationRunResult) => Promise<void>) | undefined\n\n function isExternalBackSync(payload: RouteStateSyncPayload): boolean {\n return payload.source === 'page'\n || (payload.source === 'native' && payload.method === 'navigateBack')\n }\n\n function beforeRouteStateSync(\n nextRoute: RouteLocationNormalizedLoaded,\n payload: RouteStateSyncPayload,\n ) {\n if (\n managedNavigationCount > 0\n || !isExternalBackSync(payload)\n || nextRoute.fullPath === route.fullPath\n ) {\n return\n }\n\n const from = snapshotRouteLocation(route)\n void runBackNavigationGuards({\n target: nextRoute,\n from,\n nativeRouter,\n beforeEachGuards,\n beforeResolveGuards,\n resolveWithCodec,\n }).then((result) => {\n return emitObservedNavigationAfterEach?.(result)\n })\n }\n\n const routeController = createRouteStateController({\n beforeRouteStateSync,\n resolveRoute: enrichRouteRecordState,\n })\n route = routeController.route\n\n function resolve(to: RouteLocationRaw): RouteLocationNormalizedLoaded {\n return resolveWithCodec(to, route.path)\n }\n\n const navigationResultController = createNavigationResultController({\n afterEachHooks,\n errorHandlers,\n nativeRouter,\n rejectOnError,\n })\n emitObservedNavigationAfterEach = navigationResultController.emitNavigationAfterEach\n\n const navigationApi = createNavigationApi({\n nativeRouter,\n route,\n routeResolveCodec,\n namedRouteLookup,\n beforeEachGuards,\n beforeResolveGuards,\n maxRedirects,\n tabBarPathSet,\n resolveWithCodec,\n settleNavigationResult: navigationResultController.settleNavigationResult,\n })\n\n async function runManagedNavigation<T>(navigation: () => Promise<T>): Promise<T> {\n managedNavigationCount += 1\n try {\n return await navigation()\n }\n finally {\n managedNavigationCount -= 1\n }\n }\n\n function beforeEach(guard: NavigationGuard): () => void {\n beforeEachGuards.add(guard)\n return () => {\n beforeEachGuards.delete(guard)\n }\n }\n\n function beforeResolve(guard: NavigationGuard): () => void {\n beforeResolveGuards.add(guard)\n return () => {\n beforeResolveGuards.delete(guard)\n }\n }\n\n function afterEach(hook: NavigationAfterEach): () => void {\n afterEachHooks.add(hook)\n return () => {\n afterEachHooks.delete(hook)\n }\n }\n\n function onError(handler: NavigationErrorHandler): () => void {\n errorHandlers.add(handler)\n return () => {\n errorHandlers.delete(handler)\n }\n }\n\n const router: RouterNavigation = {\n nativeRouter,\n options: routerOptions,\n currentRoute: route,\n install(app?: unknown): void {\n setActiveRouter(router)\n const globalProperties = (app as { config?: { globalProperties?: Record<string, unknown> } } | undefined)?.config?.globalProperties\n if (globalProperties) {\n globalProperties.$router = router\n }\n },\n resolve,\n isReady(): Promise<void> {\n return readyPromise\n },\n push: to => runManagedNavigation(() => navigationApi.push(to)),\n replace: to => runManagedNavigation(() => navigationApi.replace(to)),\n back: delta => runManagedNavigation(() => navigationApi.back(delta)),\n go: delta => runManagedNavigation(() => navigationApi.go(delta)),\n forward: () => runManagedNavigation(() => navigationApi.forward()),\n hasRoute: routeRegistry.hasRoute,\n getRoutes: routeRegistry.getRoutes,\n addRoute: routeRegistry.addRoute,\n removeRoute: routeRegistry.removeRoute,\n clearRoutes: routeRegistry.clearRoutes,\n beforeEach,\n beforeResolve,\n afterEach,\n onError,\n }\n\n setActiveRouter(router)\n return router\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,aAAa,UAA4B,CAAC,GAAqB;;CAC7E,MAAM,eAAe,gBAAgB;CACrC,oCAAoC,2BAA2B,CAAC;CAChE,MAAM,mCAAmB,IAAI,IAAqB;CAClD,MAAM,sCAAsB,IAAI,IAAqB;CACrD,MAAM,iCAAiB,IAAI,IAAyB;CACpD,MAAM,gCAAgB,IAAI,IAA4B;CACtD,M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AuC;EACxD,eAAe,IAAI,IAAI;EACvB,aAAa;GACX,eAAe,OAAO,IAAI;EAC5B;CACF;CAEA,SAAS,QAAQ,SAA6C;EAC5D,cAAc,IAAI,OAAO;EACzB,aAAa;GACX,cAAc,OAAO,OAAO;EAC9B;CACF;CAEA,MAAM,SAA2B;EAC/B;EACA,SAAS;EACT,cAAc;EACd,QAAQ,KAAqB;;GAC3B,gBAAgB,MAAM;GACtB,MAAM,gEAAoB,IAAiF,0DAAQ;GACnH,IAAI,kBACF,iBAAiB,UAAU;EAE/B;EACA;EACA,UAAyB;GACvB,OAAO;EACT;EACA,OAAM,OAAM,2BAA2B,cAAc,KAAK,EAAE,CAAC;EAC7D,UAAS,OAAM,2BAA2B,cAAc,QAAQ,EAAE,CAAC;EACnE,OAAM,UAAS,2BAA2B,cAAc,KAAK,KAAK,CAAC;EACnE,KAAI,UAAS,2BAA2B,cAAc,GAAG,KAAK,CAAC;EAC/D,eAAe,2BAA2B,cAAc,QAAQ,CAAC;EACjE,UAAU,cAAc;EACxB,WAAW,cAAc;EACzB,UAAU,cAAc;EACxB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B;EACA;EACA;EACA;CACF;CAEA,gBAAgB,MAAM;CACtB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"createRouter.mjs","names":[],"sources":["../../../src/router/createRouter.ts"],"sourcesContent":["import type { RouteResolveCodec } from '../routerInternal/shared'\nimport type { NavigationRunResult } from './navigationResult'\nimport type { RouteStateSyncPayload } from './routeSync'\nimport type {\n LocationQueryRaw,\n NavigationAfterEach,\n NavigationErrorHandler,\n NavigationGuard,\n RouteLocationNormalizedLoaded,\n RouteLocationRaw,\n RouterNavigation,\n UseRouterOptions,\n} from './types'\nimport {\n cloneRouteMeta,\n cloneRouteParams,\n createNamedRouteLookup,\n createRouterOptionsSnapshot,\n mergeMatchedRouteMeta,\n normalizeRouteRecordMatched,\n parseQuery,\n resolveCurrentRoute,\n resolveMatchedRouteRecord,\n resolveNamedRouteLocation,\n resolvePath,\n resolveRouteOptionEntries,\n snapshotRouteLocation,\n stringifyQuery,\n warnDuplicateRouteEntries,\n} from '../routerInternal/shared'\nimport { getMiniProgramGlobalObject } from '../runtime/platform'\nimport { runBackNavigationGuards } from './backNavigation'\nimport { registerInitialNavigationRunner } from './initialNavigation'\nimport { setActiveRouter } from './instance'\nimport { createNavigationApi } from './navigationApi'\nimport { createNavigationResultController } from './navigationResult'\nimport { navigateWithTarget } from './navigationTarget'\nimport { resolveRouteLocation } from './resolve'\nimport { createRouteRegistry } from './routeRegistry'\nimport { installRouteStateSyncOnNativeRouter } from './routeSync'\nimport { createRouteStateController, useNativeRouter } from './useRoute'\n\n/**\n * @description 创建高阶路由导航器(对齐 Vue Router 的 createRouter 心智)\n */\nexport function createRouter(options: UseRouterOptions = {}): RouterNavigation {\n const nativeRouter = useNativeRouter()\n installRouteStateSyncOnNativeRouter(getMiniProgramGlobalObject())\n const beforeEachGuards = new Set<NavigationGuard>()\n const beforeResolveGuards = new Set<NavigationGuard>()\n const afterEachHooks = new Set<NavigationAfterEach>()\n const errorHandlers = new Set<NavigationErrorHandler>()\n const maxRedirects = options.maxRedirects ?? 10\n const paramsMode = options.paramsMode ?? 'loose'\n const rejectOnError = options.rejectOnError ?? true\n const routeResolveCodec: RouteResolveCodec = {\n parseQuery: options.parseQuery ?? parseQuery,\n stringifyQuery: options.stringifyQuery ?? stringifyQuery,\n }\n const readyPromise = Promise.resolve()\n const routeEntries = resolveRouteOptionEntries(options)\n warnDuplicateRouteEntries(routeEntries)\n const namedRouteLookup = createNamedRouteLookup(routeEntries)\n const normalizedTabBarEntries = (options.tabBarEntries ?? [])\n .map(path => resolvePath(path, ''))\n .filter(Boolean)\n const tabBarPathSet = new Set(normalizedTabBarEntries)\n const routeRegistry = createRouteRegistry(namedRouteLookup)\n let managedNavigationCount = 0\n const routerOptions = createRouterOptionsSnapshot(\n normalizedTabBarEntries,\n routeRegistry.getRoutes(),\n paramsMode,\n maxRedirects,\n routeResolveCodec,\n rejectOnError,\n )\n\n function enrichRouteRecordState(routeLocation: RouteLocationNormalizedLoaded): RouteLocationNormalizedLoaded {\n const resolved = { ...routeLocation }\n resolved.href = resolved.fullPath\n const matchedResult = resolveMatchedRouteRecord(resolved, namedRouteLookup)\n if (matchedResult) {\n const matchedRecord = matchedResult.record\n if (resolved.name === undefined) {\n resolved.name = matchedRecord.name\n }\n const mergedRouteMeta = mergeMatchedRouteMeta(matchedResult.matchedRecords)\n if (mergedRouteMeta !== undefined) {\n resolved.meta = cloneRouteMeta(mergedRouteMeta)\n }\n if (matchedResult.params && Object.keys(resolved.params).length === 0) {\n resolved.params = cloneRouteParams(matchedResult.params)\n }\n resolved.matched = matchedResult.matchedRecords.map((record, index, records) => {\n const leafMatchedPath = index === records.length - 1\n ? matchedResult.matchedPath\n : undefined\n return normalizeRouteRecordMatched(record, leafMatchedPath)\n })\n }\n else {\n resolved.matched = []\n }\n return resolved\n }\n\n function resolveWithCodec(to: RouteLocationRaw, currentPath: string): RouteLocationNormalizedLoaded {\n const rawTo = typeof to === 'string'\n ? to\n : resolveNamedRouteLocation(to, namedRouteLookup, paramsMode)\n return enrichRouteRecordState(resolveRouteLocation(rawTo, currentPath, routeResolveCodec))\n }\n\n let route: Readonly<RouteLocationNormalizedLoaded>\n let emitObservedNavigationAfterEach: ((result: NavigationRunResult) => Promise<void>) | undefined\n\n function isExternalBackSync(payload: RouteStateSyncPayload): boolean {\n return payload.source === 'page'\n || (payload.source === 'native' && payload.method === 'navigateBack')\n }\n\n function beforeRouteStateSync(\n nextRoute: RouteLocationNormalizedLoaded,\n payload: RouteStateSyncPayload,\n ) {\n if (\n managedNavigationCount > 0\n || !isExternalBackSync(payload)\n || nextRoute.fullPath === route.fullPath\n ) {\n return\n }\n\n const from = snapshotRouteLocation(route)\n void runBackNavigationGuards({\n target: nextRoute,\n from,\n nativeRouter,\n beforeEachGuards,\n beforeResolveGuards,\n resolveWithCodec,\n }).then((result) => {\n return emitObservedNavigationAfterEach?.(result)\n })\n }\n\n const routeController = createRouteStateController({\n beforeRouteStateSync,\n resolveRoute: enrichRouteRecordState,\n })\n route = routeController.route\n\n function resolve(to: RouteLocationRaw): RouteLocationNormalizedLoaded {\n return resolveWithCodec(to, route.path)\n }\n\n const navigationResultController = createNavigationResultController({\n afterEachHooks,\n errorHandlers,\n nativeRouter,\n rejectOnError,\n })\n emitObservedNavigationAfterEach = navigationResultController.emitNavigationAfterEach\n\n const navigationApi = createNavigationApi({\n nativeRouter,\n route,\n routeResolveCodec,\n namedRouteLookup,\n beforeEachGuards,\n beforeResolveGuards,\n maxRedirects,\n tabBarPathSet,\n resolveWithCodec,\n settleNavigationResult: navigationResultController.settleNavigationResult,\n })\n\n async function runManagedNavigation<T>(navigation: () => Promise<T>): Promise<T> {\n managedNavigationCount += 1\n try {\n return await navigation()\n }\n finally {\n managedNavigationCount -= 1\n }\n }\n\n async function runInitialNavigation(page: Parameters<typeof resolveCurrentRoute>[1], query?: LocationQueryRaw) {\n return runManagedNavigation(async () => {\n const from = snapshotRouteLocation(route)\n const target = enrichRouteRecordState(resolveCurrentRoute(query, page))\n if (!target.path) {\n return undefined\n }\n const result = await navigateWithTarget({\n mode: 'push',\n target,\n from,\n nativeRouter,\n routeResolveCodec,\n namedRouteLookup,\n beforeEachGuards,\n beforeResolveGuards,\n maxRedirects,\n tabBarPathSet,\n resolveWithCodec,\n executeNative: false,\n allowSameLocation: true,\n })\n return navigationResultController.settleNavigationResult(result)\n })\n }\n\n function beforeEach(guard: NavigationGuard): () => void {\n beforeEachGuards.add(guard)\n return () => {\n beforeEachGuards.delete(guard)\n }\n }\n\n function beforeResolve(guard: NavigationGuard): () => void {\n beforeResolveGuards.add(guard)\n return () => {\n beforeResolveGuards.delete(guard)\n }\n }\n\n function afterEach(hook: NavigationAfterEach): () => void {\n afterEachHooks.add(hook)\n return () => {\n afterEachHooks.delete(hook)\n }\n }\n\n function onError(handler: NavigationErrorHandler): () => void {\n errorHandlers.add(handler)\n return () => {\n errorHandlers.delete(handler)\n }\n }\n\n const router: RouterNavigation = {\n nativeRouter,\n options: routerOptions,\n currentRoute: route,\n install(app?: unknown): void {\n setActiveRouter(router)\n const globalProperties = (app as { config?: { globalProperties?: Record<string, unknown> } } | undefined)?.config?.globalProperties\n if (globalProperties) {\n globalProperties.$router = router\n }\n },\n resolve,\n isReady(): Promise<void> {\n return readyPromise\n },\n push: to => runManagedNavigation(() => navigationApi.push(to)),\n replace: to => runManagedNavigation(() => navigationApi.replace(to)),\n back: delta => runManagedNavigation(() => navigationApi.back(delta)),\n go: delta => runManagedNavigation(() => navigationApi.go(delta)),\n forward: () => runManagedNavigation(() => navigationApi.forward()),\n hasRoute: routeRegistry.hasRoute,\n getRoutes: routeRegistry.getRoutes,\n addRoute: routeRegistry.addRoute,\n removeRoute: routeRegistry.removeRoute,\n clearRoutes: routeRegistry.clearRoutes,\n beforeEach,\n beforeResolve,\n afterEach,\n onError,\n }\n\n setActiveRouter(router)\n registerInitialNavigationRunner(router, runInitialNavigation)\n return router\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,aAAa,UAA4B,CAAC,GAAqB;;CAC7E,MAAM,eAAe,gBAAgB;CACrC,oCAAoC,2BAA2B,CAAC;CAChE,MAAM,mCAAmB,IAAI,IAAqB;CAClD,MAAM,sCAAsB,IAAI,IAAqB;CACrD,MAAM,iCAAiB,IAAI,IAAyB;CACpD,MAAM,gCAAgB,IAAI,IAA4B;CACtD,MAAM,wCAAe,QAAQ,qFAAgB;CAC7C,MAAM,oCAAa,QAAQ,+EAAc;CACzC,MAAM,yCAAgB,QAAQ,sFAAiB;CAC/C,MAAM,oBAAuC;EAC3C,mCAAY,QAAQ,+EAAc;EAClC,yCAAgB,QAAQ,uFAAkB;CAC5C;CACA,MAAM,eAAe,QAAQ,QAAQ;CACrC,MAAM,eAAe,0BAA0B,OAAO;CACtD,0BAA0B,YAAY;CACtC,MAAM,mBAAmB,uBAAuB,YAAY;C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AAoB,OAAO,KAAK;EAClC;CACF;CAEA,SAAS,UAAU,MAAuC;EACxD,eAAe,IAAI,IAAI;EACvB,aAAa;GACX,eAAe,OAAO,IAAI;EAC5B;CACF;CAEA,SAAS,QAAQ,SAA6C;EAC5D,cAAc,IAAI,OAAO;EACzB,aAAa;GACX,cAAc,OAAO,OAAO;EAC9B;CACF;CAEA,MAAM,SAA2B;EAC/B;EACA,SAAS;EACT,cAAc;EACd,QAAQ,KAAqB;;GAC3B,gBAAgB,MAAM;GACtB,MAAM,gEAAoB,IAAiF,0DAAQ;GACnH,IAAI,kBACF,iBAAiB,UAAU;EAE/B;EACA;EACA,UAAyB;GACvB,OAAO;EACT;EACA,OAAM,OAAM,2BAA2B,cAAc,KAAK,EAAE,CAAC;EAC7D,UAAS,OAAM,2BAA2B,cAAc,QAAQ,EAAE,CAAC;EACnE,OAAM,UAAS,2BAA2B,cAAc,KAAK,KAAK,CAAC;EACnE,KAAI,UAAS,2BAA2B,cAAc,GAAG,KAAK,CAAC;EAC/D,eAAe,2BAA2B,cAAc,QAAQ,CAAC;EACjE,UAAU,cAAc;EACxB,WAAW,cAAc;EACzB,UAAU,cAAc;EACxB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B;EACA;EACA;EACA;CACF;CAEA,gBAAgB,MAAM;CACtB,gCAAgC,QAAQ,oBAAoB;CAC5D,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getActiveRouter } from "./instance.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/router/initialNavigation.ts
|
|
4
|
+
const initialNavigationRunners = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function registerInitialNavigationRunner(router, runner) {
|
|
6
|
+
initialNavigationRunners.set(router, runner);
|
|
7
|
+
}
|
|
8
|
+
function getInitialNavigationRunner() {
|
|
9
|
+
const router = getActiveRouter();
|
|
10
|
+
return router ? initialNavigationRunners.get(router) : void 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getInitialNavigationRunner, registerInitialNavigationRunner };
|
|
15
|
+
//# sourceMappingURL=initialNavigation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialNavigation.mjs","names":[],"sources":["../../../src/router/initialNavigation.ts"],"sourcesContent":["import type { MiniProgramPageLike } from '../routerInternal/shared'\nimport type { LocationQueryRaw, NavigationFailure } from './types'\nimport { getActiveRouter } from './instance'\n\nexport type InitialNavigationRunner = (\n page: MiniProgramPageLike,\n query?: LocationQueryRaw,\n) => Promise<void | NavigationFailure>\n\nconst initialNavigationRunners = new WeakMap<object, InitialNavigationRunner>()\n\nexport function registerInitialNavigationRunner(\n router: object,\n runner: InitialNavigationRunner,\n) {\n initialNavigationRunners.set(router, runner)\n}\n\nexport function getInitialNavigationRunner(): InitialNavigationRunner | undefined {\n const router = getActiveRouter()\n return router ? initialNavigationRunners.get(router) : undefined\n}\n"],"mappings":";;;AASA,MAAM,2CAA2B,IAAI,QAAyC;AAE9E,SAAgB,gCACd,QACA,QACA;CACA,yBAAyB,IAAI,QAAQ,MAAM;AAC7C;AAEA,SAAgB,6BAAkE;CAChF,MAAM,SAAS,gBAAgB;CAC/B,OAAO,SAAS,yBAAyB,IAAI,MAAM,IAAI;AACzD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { snapshotRouteLocation } from "../routerInternal/snapshots.mjs";
|
|
2
1
|
import { NavigationFailureType } from "./types.mjs";
|
|
3
2
|
import { createNavigationFailure, executeNavigationMethod, isNavigationFailure } from "./navigationCore.mjs";
|
|
3
|
+
import { snapshotRouteLocation } from "../routerInternal/snapshots.mjs";
|
|
4
4
|
import { createNavigationRunResult } from "./navigationResult.mjs";
|
|
5
5
|
import { resolveBackNavigationTarget, runBackNavigationGuards } from "./backNavigation.mjs";
|
|
6
6
|
import { createForwardNotSupportedFailure } from "./navigationTargetHelpers.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { notifyRouteStateSync } from "./routeSync.mjs";
|
|
2
1
|
import { runAfterEachHooks, runNavigationErrorHooks, shouldEmitNavigationError } from "./navigationCore.mjs";
|
|
2
|
+
import { notifyRouteStateSync } from "./routeSync.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/router/navigationResult.ts
|
|
5
5
|
function createNavigationRunResult(mode, from, to, failure) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { NavigationFailureType } from "./types.mjs";
|
|
2
|
+
import { createNavigationFailure, executeNavigationMethod, isNavigationFailure, runNavigationGuards } from "./navigationCore.mjs";
|
|
1
3
|
import { createAbsoluteRoutePath } from "../routerInternal/path.mjs";
|
|
2
4
|
import { resolveMatchedRouteRecord } from "../routerInternal/matching.mjs";
|
|
3
5
|
import { createNativeRouteUrl, hasLocationQuery } from "../routerInternal/snapshots.mjs";
|
|
4
|
-
import { NavigationFailureType } from "./types.mjs";
|
|
5
|
-
import { createNavigationFailure, executeNavigationMethod, isNavigationFailure, runNavigationGuards } from "./navigationCore.mjs";
|
|
6
6
|
import { createNavigationRunResult } from "./navigationResult.mjs";
|
|
7
7
|
import { applyRedirectedFrom, createDuplicatedFailure, createHashOnlyNavigationFailure, createTabBarQueryFailure, createTooManyRedirectsFailure, resolveRouteRecordRedirect } from "./navigationTargetHelpers.mjs";
|
|
8
8
|
|
|
9
9
|
//#region src/router/navigationTarget.ts
|
|
10
10
|
async function navigateWithTarget(options) {
|
|
11
|
-
const { mode, target, from, nativeRouter, routeResolveCodec, namedRouteLookup, beforeEachGuards, beforeResolveGuards, maxRedirects, tabBarPathSet, resolveWithCodec } = options;
|
|
11
|
+
const { mode, target, from, nativeRouter, routeResolveCodec, namedRouteLookup, beforeEachGuards, beforeResolveGuards, maxRedirects, tabBarPathSet, resolveWithCodec, executeNative = true, allowSameLocation = false } = options;
|
|
12
12
|
let currentTarget = target;
|
|
13
13
|
let currentMode = mode;
|
|
14
14
|
let redirectCount = 0;
|
|
@@ -16,7 +16,7 @@ async function navigateWithTarget(options) {
|
|
|
16
16
|
var _matchedRouteResult$m;
|
|
17
17
|
const tabBarTarget = tabBarPathSet.has(currentTarget.path);
|
|
18
18
|
if (createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery) === createNativeRouteUrl(from, routeResolveCodec.stringifyQuery) && currentTarget.hash !== from.hash) return createNavigationRunResult(currentMode, from, currentTarget, createHashOnlyNavigationFailure(currentTarget, from));
|
|
19
|
-
if (tabBarTarget ? currentTarget.path === from.path : currentTarget.fullPath === from.fullPath) return createNavigationRunResult(currentMode, from, currentTarget, createDuplicatedFailure(currentTarget, from));
|
|
19
|
+
if (!allowSameLocation && (tabBarTarget ? currentTarget.path === from.path : currentTarget.fullPath === from.fullPath)) return createNavigationRunResult(currentMode, from, currentTarget, createDuplicatedFailure(currentTarget, from));
|
|
20
20
|
if (tabBarTarget && hasLocationQuery(currentTarget.query)) return createNavigationRunResult(currentMode, from, currentTarget, createTabBarQueryFailure(currentTarget, from));
|
|
21
21
|
const beforeEachResult = await runNavigationGuards(beforeEachGuards, {
|
|
22
22
|
mode: currentMode,
|
|
@@ -105,6 +105,7 @@ async function navigateWithTarget(options) {
|
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
if (!executeNative) return createNavigationRunResult(currentMode, from, currentTarget);
|
|
108
109
|
if (tabBarTarget) {
|
|
109
110
|
const result = await executeNavigationMethod(nativeRouter.switchTab, { url: createAbsoluteRoutePath(currentTarget.path) }, currentTarget, from);
|
|
110
111
|
if (isNavigationFailure(result)) return createNavigationRunResult(currentMode, from, currentTarget, result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationTarget.mjs","names":[],"sources":["../../../src/router/navigationTarget.ts"],"sourcesContent":["import type {\n NamedRouteLookup,\n RouteResolveCodec,\n} from '../routerInternal/shared'\nimport type { NavigationRunResult } from './navigationResult'\nimport type {\n NavigationGuard,\n NavigationMode,\n RouteLocationNormalizedLoaded,\n RouteLocationRaw,\n} from './types'\nimport {\n createAbsoluteRoutePath,\n createNativeRouteUrl,\n hasLocationQuery,\n resolveMatchedRouteRecord,\n} from '../routerInternal/shared'\nimport {\n createNavigationFailure,\n executeNavigationMethod,\n isNavigationFailure,\n runNavigationGuards,\n} from './navigationCore'\nimport { createNavigationRunResult } from './navigationResult'\nimport {\n applyRedirectedFrom,\n createDuplicatedFailure,\n createHashOnlyNavigationFailure,\n createTabBarQueryFailure,\n createTooManyRedirectsFailure,\n resolveRouteRecordRedirect,\n} from './navigationTargetHelpers'\nimport { NavigationFailureType } from './types'\n\ninterface NavigateWithTargetOptions {\n mode: Exclude<NavigationMode, 'back'>\n target: RouteLocationNormalizedLoaded\n from: RouteLocationNormalizedLoaded\n nativeRouter: Record<string, any>\n routeResolveCodec: RouteResolveCodec\n namedRouteLookup: NamedRouteLookup\n beforeEachGuards: ReadonlySet<NavigationGuard>\n beforeResolveGuards: ReadonlySet<NavigationGuard>\n maxRedirects: number\n tabBarPathSet: ReadonlySet<string>\n resolveWithCodec: (to: RouteLocationRaw, currentPath: string) => RouteLocationNormalizedLoaded\n}\n\nexport async function navigateWithTarget(options: NavigateWithTargetOptions): Promise<NavigationRunResult> {\n const {\n mode,\n target,\n from,\n nativeRouter,\n routeResolveCodec,\n namedRouteLookup,\n beforeEachGuards,\n beforeResolveGuards,\n maxRedirects,\n tabBarPathSet,\n resolveWithCodec,\n } = options\n let currentTarget = target\n let currentMode: Exclude<NavigationMode, 'back'> = mode\n let redirectCount = 0\n\n while (true) {\n const tabBarTarget = tabBarPathSet.has(currentTarget.path)\n const sameNativeLocation = createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery)\n === createNativeRouteUrl(from, routeResolveCodec.stringifyQuery)\n if (sameNativeLocation && currentTarget.hash !== from.hash) {\n return createNavigationRunResult(currentMode, from, currentTarget, createHashOnlyNavigationFailure(currentTarget, from))\n }\n\n const duplicated = tabBarTarget\n ? currentTarget.path === from.path\n : currentTarget.fullPath === from.fullPath\n if (duplicated) {\n return createNavigationRunResult(currentMode, from, currentTarget, createDuplicatedFailure(currentTarget, from))\n }\n\n if (tabBarTarget && hasLocationQuery(currentTarget.query)) {\n return createNavigationRunResult(currentMode, from, currentTarget, createTabBarQueryFailure(currentTarget, from))\n }\n\n const beforeEachResult = await runNavigationGuards(beforeEachGuards, {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeEachResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeEachResult.failure)\n }\n if (beforeEachResult.status === 'redirect') {\n const redirectedTarget = beforeEachResult.target\n const redirectedMode = beforeEachResult.replace === true\n ? 'replace'\n : beforeEachResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n continue\n }\n }\n\n const matchedRouteResult = resolveMatchedRouteRecord(currentTarget, namedRouteLookup)\n const matchedRouteRecords = matchedRouteResult?.matchedRecords ?? []\n let redirectedByRouteRecord = false\n for (const matchedRouteRecord of matchedRouteRecords) {\n if (matchedRouteRecord.redirect === undefined) {\n continue\n }\n let redirectedByRecord: { target: RouteLocationNormalizedLoaded, replace?: boolean }\n try {\n redirectedByRecord = await resolveRouteRecordRedirect(\n matchedRouteRecord.redirect,\n currentTarget,\n from,\n resolveWithCodec,\n )\n }\n catch (error) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createNavigationFailure(NavigationFailureType.aborted, currentTarget, from, error),\n )\n }\n\n const redirectedMode = redirectedByRecord.replace === false ? 'push' : 'replace'\n const redirectedTarget = redirectedByRecord.target\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n redirectedByRouteRecord = true\n break\n }\n }\n if (redirectedByRouteRecord) {\n continue\n }\n\n let redirectedByBeforeEnter = false\n for (const matchedRouteRecord of matchedRouteRecords) {\n if (matchedRouteRecord.beforeEnterGuards.length === 0) {\n continue\n }\n const beforeEnterResult = await runNavigationGuards(new Set(matchedRouteRecord.beforeEnterGuards), {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeEnterResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeEnterResult.failure)\n }\n if (beforeEnterResult.status === 'redirect') {\n const redirectedTarget = beforeEnterResult.target\n const redirectedMode = beforeEnterResult.replace === true\n ? 'replace'\n : beforeEnterResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n redirectedByBeforeEnter = true\n break\n }\n }\n }\n if (redirectedByBeforeEnter) {\n continue\n }\n\n const beforeResolveResult = await runNavigationGuards(beforeResolveGuards, {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeResolveResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeResolveResult.failure)\n }\n if (beforeResolveResult.status === 'redirect') {\n const redirectedTarget = beforeResolveResult.target\n const redirectedMode = beforeResolveResult.replace === true\n ? 'replace'\n : beforeResolveResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n continue\n }\n }\n\n if (tabBarTarget) {\n const result = await executeNavigationMethod(\n nativeRouter.switchTab as (options: Record<string, any>) => unknown,\n { url: createAbsoluteRoutePath(currentTarget.path) },\n currentTarget,\n from,\n )\n if (isNavigationFailure(result)) {\n return createNavigationRunResult(currentMode, from, currentTarget, result)\n }\n return createNavigationRunResult(currentMode, from, currentTarget)\n }\n\n const nativeMethod = currentMode === 'push'\n ? nativeRouter.navigateTo\n : nativeRouter.redirectTo\n const result = await executeNavigationMethod(\n nativeMethod as (options: Record<string, any>) => unknown,\n { url: createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery) },\n currentTarget,\n from,\n )\n if (isNavigationFailure(result)) {\n return createNavigationRunResult(currentMode, from, currentTarget, result)\n }\n return createNavigationRunResult(currentMode, from, currentTarget)\n }\n}\n"],"mappings":";;;;;;;;;AAgDA,eAAsB,mBAAmB,SAAkE;CACzG,MAAM,EACJ,MACA,QACA,MACA,cACA,mBACA,kBACA,kBACA,qBACA,cACA,eACA,qBACE;CACJ,IAAI,gBAAgB;CACpB,IAAI,cAA+C;CACnD,IAAI,gBAAgB;CAEpB,OAAO,MAAM;;EACX,MAAM,eAAe,cAAc,IAAI,cAAc,IAAI;EAGzD,IAF2B,qBAAqB,eAAe,kBAAkB,cAAc,MACzF,qBAAqB,MAAM,kBAAkB,cAAc,KACvC,cAAc,SAAS,KAAK,MACpD,OAAO,0BAA0B,aAAa,MAAM,eAAe,gCAAgC,eAAe,IAAI,CAAC;EAMzH,IAHm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SACA;GACN,IAAI,iBAAiB,aAAa,cAAc,YAAY,mBAAmB,aAAa;IAC1F,oBAAoB,kBAAkB,aAAa;IACnD,gBAAgB;IAChB,cAAc;IACd,iBAAiB;IACjB,IAAI,gBAAgB,cAClB,OAAO,0BACL,aACA,MACA,eACA,8BAA8B,eAAe,MAAM,YAAY,CACjE;IAEF;GACF;EACF;EAEA,IAAI,cAAc;GAChB,MAAM,SAAS,MAAM,wBACnB,aAAa,WACb,EAAE,KAAK,wBAAwB,cAAc,IAAI,EAAE,GACnD,eACA,IACF;GACA,IAAI,oBAAoB,MAAM,GAC5B,OAAO,0BAA0B,aAAa,MAAM,eAAe,MAAM;GAE3E,OAAO,0BAA0B,aAAa,MAAM,aAAa;EACnE;EAEA,MAAM,eAAe,gBAAgB,SACjC,aAAa,aACb,aAAa;EACjB,MAAM,SAAS,MAAM,wBACnB,cACA,EAAE,KAAK,qBAAqB,eAAe,kBAAkB,cAAc,EAAE,GAC7E,eACA,IACF;EACA,IAAI,oBAAoB,MAAM,GAC5B,OAAO,0BAA0B,aAAa,MAAM,eAAe,MAAM;EAE3E,OAAO,0BAA0B,aAAa,MAAM,aAAa;CACnE;AACF"}
|
|
1
|
+
{"version":3,"file":"navigationTarget.mjs","names":[],"sources":["../../../src/router/navigationTarget.ts"],"sourcesContent":["import type {\n NamedRouteLookup,\n RouteResolveCodec,\n} from '../routerInternal/shared'\nimport type { NavigationRunResult } from './navigationResult'\nimport type {\n NavigationGuard,\n NavigationMode,\n RouteLocationNormalizedLoaded,\n RouteLocationRaw,\n} from './types'\nimport {\n createAbsoluteRoutePath,\n createNativeRouteUrl,\n hasLocationQuery,\n resolveMatchedRouteRecord,\n} from '../routerInternal/shared'\nimport {\n createNavigationFailure,\n executeNavigationMethod,\n isNavigationFailure,\n runNavigationGuards,\n} from './navigationCore'\nimport { createNavigationRunResult } from './navigationResult'\nimport {\n applyRedirectedFrom,\n createDuplicatedFailure,\n createHashOnlyNavigationFailure,\n createTabBarQueryFailure,\n createTooManyRedirectsFailure,\n resolveRouteRecordRedirect,\n} from './navigationTargetHelpers'\nimport { NavigationFailureType } from './types'\n\ninterface NavigateWithTargetOptions {\n mode: Exclude<NavigationMode, 'back'>\n target: RouteLocationNormalizedLoaded\n from: RouteLocationNormalizedLoaded\n nativeRouter: Record<string, any>\n routeResolveCodec: RouteResolveCodec\n namedRouteLookup: NamedRouteLookup\n beforeEachGuards: ReadonlySet<NavigationGuard>\n beforeResolveGuards: ReadonlySet<NavigationGuard>\n maxRedirects: number\n tabBarPathSet: ReadonlySet<string>\n resolveWithCodec: (to: RouteLocationRaw, currentPath: string) => RouteLocationNormalizedLoaded\n executeNative?: boolean\n allowSameLocation?: boolean\n}\n\nexport async function navigateWithTarget(options: NavigateWithTargetOptions): Promise<NavigationRunResult> {\n const {\n mode,\n target,\n from,\n nativeRouter,\n routeResolveCodec,\n namedRouteLookup,\n beforeEachGuards,\n beforeResolveGuards,\n maxRedirects,\n tabBarPathSet,\n resolveWithCodec,\n executeNative = true,\n allowSameLocation = false,\n } = options\n let currentTarget = target\n let currentMode: Exclude<NavigationMode, 'back'> = mode\n let redirectCount = 0\n\n while (true) {\n const tabBarTarget = tabBarPathSet.has(currentTarget.path)\n const sameNativeLocation = createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery)\n === createNativeRouteUrl(from, routeResolveCodec.stringifyQuery)\n if (sameNativeLocation && currentTarget.hash !== from.hash) {\n return createNavigationRunResult(currentMode, from, currentTarget, createHashOnlyNavigationFailure(currentTarget, from))\n }\n\n const duplicated = !allowSameLocation && (tabBarTarget\n ? currentTarget.path === from.path\n : currentTarget.fullPath === from.fullPath)\n if (duplicated) {\n return createNavigationRunResult(currentMode, from, currentTarget, createDuplicatedFailure(currentTarget, from))\n }\n\n if (tabBarTarget && hasLocationQuery(currentTarget.query)) {\n return createNavigationRunResult(currentMode, from, currentTarget, createTabBarQueryFailure(currentTarget, from))\n }\n\n const beforeEachResult = await runNavigationGuards(beforeEachGuards, {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeEachResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeEachResult.failure)\n }\n if (beforeEachResult.status === 'redirect') {\n const redirectedTarget = beforeEachResult.target\n const redirectedMode = beforeEachResult.replace === true\n ? 'replace'\n : beforeEachResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n continue\n }\n }\n\n const matchedRouteResult = resolveMatchedRouteRecord(currentTarget, namedRouteLookup)\n const matchedRouteRecords = matchedRouteResult?.matchedRecords ?? []\n let redirectedByRouteRecord = false\n for (const matchedRouteRecord of matchedRouteRecords) {\n if (matchedRouteRecord.redirect === undefined) {\n continue\n }\n let redirectedByRecord: { target: RouteLocationNormalizedLoaded, replace?: boolean }\n try {\n redirectedByRecord = await resolveRouteRecordRedirect(\n matchedRouteRecord.redirect,\n currentTarget,\n from,\n resolveWithCodec,\n )\n }\n catch (error) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createNavigationFailure(NavigationFailureType.aborted, currentTarget, from, error),\n )\n }\n\n const redirectedMode = redirectedByRecord.replace === false ? 'push' : 'replace'\n const redirectedTarget = redirectedByRecord.target\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n redirectedByRouteRecord = true\n break\n }\n }\n if (redirectedByRouteRecord) {\n continue\n }\n\n let redirectedByBeforeEnter = false\n for (const matchedRouteRecord of matchedRouteRecords) {\n if (matchedRouteRecord.beforeEnterGuards.length === 0) {\n continue\n }\n const beforeEnterResult = await runNavigationGuards(new Set(matchedRouteRecord.beforeEnterGuards), {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeEnterResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeEnterResult.failure)\n }\n if (beforeEnterResult.status === 'redirect') {\n const redirectedTarget = beforeEnterResult.target\n const redirectedMode = beforeEnterResult.replace === true\n ? 'replace'\n : beforeEnterResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n redirectedByBeforeEnter = true\n break\n }\n }\n }\n if (redirectedByBeforeEnter) {\n continue\n }\n\n const beforeResolveResult = await runNavigationGuards(beforeResolveGuards, {\n mode: currentMode,\n to: currentTarget,\n from,\n nativeRouter: nativeRouter as any,\n }, resolveWithCodec)\n\n if (beforeResolveResult.status === 'failure') {\n return createNavigationRunResult(currentMode, from, currentTarget, beforeResolveResult.failure)\n }\n if (beforeResolveResult.status === 'redirect') {\n const redirectedTarget = beforeResolveResult.target\n const redirectedMode = beforeResolveResult.replace === true\n ? 'replace'\n : beforeResolveResult.replace === false\n ? 'push'\n : currentMode\n if (redirectedTarget.fullPath !== currentTarget.fullPath || redirectedMode !== currentMode) {\n applyRedirectedFrom(redirectedTarget, currentTarget)\n currentTarget = redirectedTarget\n currentMode = redirectedMode\n redirectCount += 1\n if (redirectCount > maxRedirects) {\n return createNavigationRunResult(\n currentMode,\n from,\n currentTarget,\n createTooManyRedirectsFailure(currentTarget, from, maxRedirects),\n )\n }\n continue\n }\n }\n\n if (!executeNative) {\n return createNavigationRunResult(currentMode, from, currentTarget)\n }\n\n if (tabBarTarget) {\n const result = await executeNavigationMethod(\n nativeRouter.switchTab as (options: Record<string, any>) => unknown,\n { url: createAbsoluteRoutePath(currentTarget.path) },\n currentTarget,\n from,\n )\n if (isNavigationFailure(result)) {\n return createNavigationRunResult(currentMode, from, currentTarget, result)\n }\n return createNavigationRunResult(currentMode, from, currentTarget)\n }\n\n const nativeMethod = currentMode === 'push'\n ? nativeRouter.navigateTo\n : nativeRouter.redirectTo\n const result = await executeNavigationMethod(\n nativeMethod as (options: Record<string, any>) => unknown,\n { url: createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery) },\n currentTarget,\n from,\n )\n if (isNavigationFailure(result)) {\n return createNavigationRunResult(currentMode, from, currentTarget, result)\n }\n return createNavigationRunResult(currentMode, from, currentTarget)\n }\n}\n"],"mappings":";;;;;;;;;AAkDA,eAAsB,mBAAmB,SAAkE;CACzG,MAAM,EACJ,MACA,QACA,MACA,cACA,mBACA,kBACA,kBACA,qBACA,cACA,eACA,kBACA,gBAAgB,MAChB,oBAAoB,UAClB;CACJ,IAAI,gBAAgB;CACpB,IAAI,cAA+C;CACnD,IAAI,gBAAgB;CAEpB,OAAO,MAAM;;EACX,MAAM,eAAe,cAAc,IAAI,cAAc,IAAI;EAGzD,IAF2B,qBAAqB,eAAe,kBAAkB,cAAc,MACzF,qBAAqB,MAAM,kBAAkB,cAAc,KACvC,cAAc,SAAS,KAAK,MACpD,OAAO,0BAA0B,aAAa,MAAM,eAAe,gCAAgC,eAAe,IAAI,CAAC;EAMzH,IAHmB,CAAC,sBAAsB,eACtC,cAAc,SAAS,KAAK,OAC5B,cAAc,aAAa,KAAK,WAElC,OAAO,0BAA0B,aAAa,MAAM,eAAe,wBAAwB,eAAe,IAAI,CAAC;EA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iBAAiB;IACjB,IAAI,gBAAgB,cAClB,OAAO,0BACL,aACA,MACA,eACA,8BAA8B,eAAe,MAAM,YAAY,CACjE;IAEF;GACF;EACF;EAEA,IAAI,CAAC,eACH,OAAO,0BAA0B,aAAa,MAAM,aAAa;EAGnE,IAAI,cAAc;GAChB,MAAM,SAAS,MAAM,wBACnB,aAAa,WACb,EAAE,KAAK,wBAAwB,cAAc,IAAI,EAAE,GACnD,eACA,IACF;GACA,IAAI,oBAAoB,MAAM,GAC5B,OAAO,0BAA0B,aAAa,MAAM,eAAe,MAAM;GAE3E,OAAO,0BAA0B,aAAa,MAAM,aAAa;EACnE;EAEA,MAAM,eAAe,gBAAgB,SACjC,aAAa,aACb,aAAa;EACjB,MAAM,SAAS,MAAM,wBACnB,cACA,EAAE,KAAK,qBAAqB,eAAe,kBAAkB,cAAc,EAAE,GAC7E,eACA,IACF;EACA,IAAI,oBAAoB,MAAM,GAC5B,OAAO,0BAA0B,aAAa,MAAM,eAAe,MAAM;EAE3E,OAAO,0BAA0B,aAAa,MAAM,aAAa;CACnE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { cloneRouteLocationRedirectedFrom, createRedirectedFromSnapshot } from "../routerInternal/snapshots.mjs";
|
|
2
1
|
import { NavigationFailureType } from "./types.mjs";
|
|
3
2
|
import { createNavigationFailure, isNavigationRedirectCandidate } from "./navigationCore.mjs";
|
|
3
|
+
import { cloneRouteLocationRedirectedFrom, createRedirectedFromSnapshot } from "../routerInternal/snapshots.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/router/navigationTargetHelpers.ts
|
|
6
6
|
function createDuplicatedFailure(target, from) {
|
|
@@ -2,11 +2,11 @@ import { reactive } from "../reactivity/reactive.mjs";
|
|
|
2
2
|
import { readonly } from "../reactivity/readonly.mjs";
|
|
3
3
|
import { getCurrentSetupContext } from "../runtime/hooks/base.mjs";
|
|
4
4
|
import { onLoad, onReady, onRouteDone, onShow, onUnload } from "../runtime/hooks/register.mjs";
|
|
5
|
+
import { getActiveRouter } from "./instance.mjs";
|
|
5
6
|
import { registerRouteStateSyncHandler } from "./routeSync.mjs";
|
|
6
7
|
import { resolveCurrentRoute, resolvePageRoute } from "../routerInternal/location.mjs";
|
|
7
8
|
import { cloneLocationQuery, cloneRouteLocationRedirectedFrom, cloneRouteMeta, cloneRouteParams, cloneRouteRecordMatchedList } from "../routerInternal/snapshots.mjs";
|
|
8
9
|
import { useNativePageRouter as useNativePageRouter$1, useNativeRouter as useNativeRouter$1 } from "../runtime/vueCompat/router.mjs";
|
|
9
|
-
import { getActiveRouter } from "./instance.mjs";
|
|
10
10
|
import { resolveRouteLocation } from "./resolve.mjs";
|
|
11
11
|
|
|
12
12
|
//#region src/router/useRoute.ts
|
package/dist/dev/router.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { parseQuery, stringifyQuery } from "./routerInternal/query.mjs";
|
|
2
1
|
import { NavigationFailureType } from "./router/types.mjs";
|
|
3
2
|
import { createNavigationFailure, isNavigationFailure } from "./router/navigationCore.mjs";
|
|
3
|
+
import { parseQuery, stringifyQuery } from "./routerInternal/query.mjs";
|
|
4
4
|
import { resolveRouteLocation } from "./router/resolve.mjs";
|
|
5
5
|
import { useNativePageRouter, useNativeRouter, useRoute } from "./router/useRoute.mjs";
|
|
6
6
|
import { createRouter } from "./router/createRouter.mjs";
|
|
@@ -2,11 +2,48 @@ import { callHookList } from "../../hooks/base.mjs";
|
|
|
2
2
|
import { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, releaseCurrentPageInstance, resolvePageOptions } from "./lifecycle/platform.mjs";
|
|
3
3
|
import { scheduleTemplateRefUpdate } from "../../templateRefs.mjs";
|
|
4
4
|
import { enableDeferredSetData, mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from "../runtimeInstance.mjs";
|
|
5
|
+
import { getInitialNavigationRunner } from "../../../router/initialNavigation.mjs";
|
|
6
|
+
import { isNavigationFailure } from "../../../router/navigationCore.mjs";
|
|
5
7
|
import { notifyRouteStateSync } from "../../../router/routeSync.mjs";
|
|
6
8
|
import { attachOptionalPageLifecycleHooks } from "./lifecycle/optionalHooks.mjs";
|
|
7
9
|
import { WEVU_ON_LOAD_CALLED_KEY, WEVU_READY_CALLED_KEY, WEVU_ROUTE_DONE_CALLED_KEY } from "@weapp-core/constants";
|
|
8
10
|
|
|
9
11
|
//#region src/runtime/register/component/lifecycle.ts
|
|
12
|
+
const INITIAL_NAVIGATION_PROMISE_KEY = Symbol("wevu.initialNavigationPromise");
|
|
13
|
+
const INITIAL_NAVIGATION_START_KEY = Symbol("wevu.startInitialNavigation");
|
|
14
|
+
function getInitialNavigationPromise(instance) {
|
|
15
|
+
return instance[INITIAL_NAVIGATION_PROMISE_KEY];
|
|
16
|
+
}
|
|
17
|
+
function ensureInitialNavigation(instance, query, options = {}) {
|
|
18
|
+
const existing = getInitialNavigationPromise(instance);
|
|
19
|
+
if (existing) {
|
|
20
|
+
if (options.start !== false) {
|
|
21
|
+
var _INITIAL_NAVIGATION_S;
|
|
22
|
+
(_INITIAL_NAVIGATION_S = instance[INITIAL_NAVIGATION_START_KEY]) === null || _INITIAL_NAVIGATION_S === void 0 || _INITIAL_NAVIGATION_S.call(instance, query);
|
|
23
|
+
}
|
|
24
|
+
return existing;
|
|
25
|
+
}
|
|
26
|
+
const initialNavigationRunner = getInitialNavigationRunner();
|
|
27
|
+
if (!initialNavigationRunner) return;
|
|
28
|
+
let resolveInitialNavigation;
|
|
29
|
+
let rejectInitialNavigation;
|
|
30
|
+
const initialNavigationPromise = new Promise((resolve, reject) => {
|
|
31
|
+
resolveInitialNavigation = resolve;
|
|
32
|
+
rejectInitialNavigation = reject;
|
|
33
|
+
});
|
|
34
|
+
instance[INITIAL_NAVIGATION_PROMISE_KEY] = initialNavigationPromise;
|
|
35
|
+
let started = false;
|
|
36
|
+
instance[INITIAL_NAVIGATION_START_KEY] = (startQuery) => {
|
|
37
|
+
if (started) return;
|
|
38
|
+
started = true;
|
|
39
|
+
initialNavigationRunner(instance, startQuery !== null && startQuery !== void 0 ? startQuery : query).then((result) => {
|
|
40
|
+
const shouldMount = !isNavigationFailure(result);
|
|
41
|
+
resolveInitialNavigation(shouldMount);
|
|
42
|
+
}, rejectInitialNavigation);
|
|
43
|
+
};
|
|
44
|
+
if (options.start !== false) instance[INITIAL_NAVIGATION_START_KEY](query);
|
|
45
|
+
return initialNavigationPromise;
|
|
46
|
+
}
|
|
10
47
|
function createPageLifecycleHooks(options) {
|
|
11
48
|
const { runtimeApp, watch, setup, userOnLoad, userOnUnload, userOnShow, userOnHide, userOnReady, isPage, enableOnSaveExitState, enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnRouteDoneFallback, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, syncWevuPropsFromValues, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites, hasHook } = options;
|
|
12
49
|
const flushPageSnapshotIfPossible = (target) => {
|
|
@@ -17,17 +54,27 @@ function createPageLifecycleHooks(options) {
|
|
|
17
54
|
onLoad(...args) {
|
|
18
55
|
if (this[WEVU_ON_LOAD_CALLED_KEY]) return;
|
|
19
56
|
this[WEVU_ON_LOAD_CALLED_KEY] = true;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
const mountPage = () => {
|
|
58
|
+
mountRuntimeInstance(this, runtimeApp, watch, setup);
|
|
59
|
+
const pageOptions = args[0] && typeof args[0] === "object" ? args[0] : resolvePageOptions(this);
|
|
60
|
+
syncWevuPropsFromValues === null || syncWevuPropsFromValues === void 0 || syncWevuPropsFromValues(this, pageOptions);
|
|
61
|
+
flushPageSnapshotIfPossible(this);
|
|
62
|
+
enableDeferredSetData(this);
|
|
63
|
+
if (isPage) ensurePageShareMenus({
|
|
64
|
+
enableOnShareAppMessage,
|
|
65
|
+
enableOnShareTimeline
|
|
66
|
+
});
|
|
67
|
+
callHookList(this, "onLoad", args);
|
|
68
|
+
if (typeof userOnLoad === "function") return userOnLoad.apply(this, args.length ? args : [pageOptions]);
|
|
69
|
+
};
|
|
70
|
+
const initialNavigationPromise = isPage ? ensureInitialNavigation(this, args[0]) : void 0;
|
|
71
|
+
if (initialNavigationPromise) {
|
|
72
|
+
initialNavigationPromise.then((shouldMount) => {
|
|
73
|
+
if (shouldMount) mountPage();
|
|
74
|
+
}, () => {});
|
|
75
|
+
return initialNavigationPromise;
|
|
76
|
+
}
|
|
77
|
+
return mountPage();
|
|
31
78
|
},
|
|
32
79
|
onUnload(...args) {
|
|
33
80
|
if (isPage) releaseCurrentPageInstance(this);
|
|
@@ -82,10 +129,21 @@ function createPageLifecycleHooks(options) {
|
|
|
82
129
|
}
|
|
83
130
|
}, 0);
|
|
84
131
|
}
|
|
85
|
-
|
|
132
|
+
const callReadyHooks = () => {
|
|
86
133
|
callHookList(this, "onReady", args);
|
|
87
134
|
if (typeof userOnReady === "function") userOnReady.apply(this, args);
|
|
88
|
-
}
|
|
135
|
+
};
|
|
136
|
+
const initialNavigationPromise = getInitialNavigationPromise(this);
|
|
137
|
+
const callReadyHooksAfterInitialNavigation = () => {
|
|
138
|
+
if (initialNavigationPromise) {
|
|
139
|
+
initialNavigationPromise.then((shouldMount) => {
|
|
140
|
+
if (shouldMount) callReadyHooks();
|
|
141
|
+
}, () => {});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
callReadyHooks();
|
|
145
|
+
};
|
|
146
|
+
scheduleTemplateRefUpdate(this, callReadyHooksAfterInitialNavigation);
|
|
89
147
|
return;
|
|
90
148
|
}
|
|
91
149
|
if (typeof userOnReady === "function") return userOnReady.apply(this, args);
|
|
@@ -118,5 +176,5 @@ function createPageLifecycleHooks(options) {
|
|
|
118
176
|
}
|
|
119
177
|
|
|
120
178
|
//#endregion
|
|
121
|
-
export { createPageLifecycleHooks };
|
|
179
|
+
export { createPageLifecycleHooks, ensureInitialNavigation, getInitialNavigationPromise };
|
|
122
180
|
//# sourceMappingURL=lifecycle.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.mjs","names":[],"sources":["../../../../../src/runtime/register/component/lifecycle.ts"],"sourcesContent":["import type { MiniProgramPageLike } from '../../../routerInternal/shared'\nimport type { ComponentPropsOptions, ComputedDefinitions, DefineComponentOptions, InternalRuntimeState, MethodDefinitions, RuntimeApp } from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEVU_ON_LOAD_CALLED_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_ROUTE_DONE_CALLED_KEY,\n} from '@weapp-core/constants'\nimport { notifyRouteStateSync } from '../../../router/routeSync'\nimport { callHookList } from '../../hooks'\nimport { scheduleTemplateRefUpdate } from '../../templateRefs'\nimport { enableDeferredSetData, mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { attachOptionalPageLifecycleHooks } from './lifecycle/optionalHooks'\nimport { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, releaseCurrentPageInstance, resolvePageOptions } from './lifecycle/platform'\n\nexport function createPageLifecycleHooks<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n userOnLoad?: any\n userOnUnload?: any\n userOnShow?: any\n userOnHide?: any\n userOnReady?: any\n isPage: boolean\n enableOnSaveExitState: boolean\n enableOnPullDownRefresh: boolean\n enableOnReachBottom: boolean\n enableOnPageScroll: boolean\n enableOnRouteDone: boolean\n enableOnRouteDoneFallback: boolean\n enableOnTabItemTap: boolean\n enableOnResize: boolean\n enableOnShareAppMessage: boolean\n enableOnShareTimeline: boolean\n enableOnAddToFavorites: boolean\n syncWevuPropsFromValues?: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n effectiveOnSaveExitState: (...args: any[]) => any\n effectiveOnPullDownRefresh: (...args: any[]) => any\n effectiveOnReachBottom: (...args: any[]) => any\n effectiveOnPageScroll: (...args: any[]) => any\n effectiveOnRouteDone: (...args: any[]) => any\n effectiveOnTabItemTap: (...args: any[]) => any\n effectiveOnResize: (...args: any[]) => any\n effectiveOnShareAppMessage: (...args: any[]) => any\n effectiveOnShareTimeline: (...args: any[]) => any\n effectiveOnAddToFavorites: (...args: any[]) => any\n hasHook: (target: InternalRuntimeState, name: string) => boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n isPage,\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n syncWevuPropsFromValues,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n } = options\n const flushPageSnapshotIfPossible = (target: InternalRuntimeState) => {\n ;(target as any).__wevu?.__wevu_flushSetupSnapshotSync?.()\n }\n\n const pageLifecycleHooks: Record<string, any> = {\n onLoad(this: InternalRuntimeState, ...args: any[]) {\n if ((this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n return\n }\n ;(this as any)[WEVU_ON_LOAD_CALLED_KEY] = true\n mountRuntimeInstance(this, runtimeApp, watch, setup)\n const pageOptions = args[0] && typeof args[0] === 'object'\n ? args[0]\n : resolvePageOptions(this)\n syncWevuPropsFromValues?.(this, pageOptions)\n flushPageSnapshotIfPossible(this)\n enableDeferredSetData(this)\n if (isPage) {\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n callHookList(this, 'onLoad', args)\n if (typeof userOnLoad === 'function') {\n return userOnLoad.apply(this, args.length ? args : [pageOptions])\n }\n },\n onUnload(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n teardownRuntimeInstance(this)\n if (typeof userOnUnload === 'function') {\n return userOnUnload.apply(this, args)\n }\n },\n onShow(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n ensureMiniProgramGlobalPatched()\n bindCurrentPageInstance(this)\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n ;(this as any)[WEVU_ROUTE_DONE_CALLED_KEY] = false\n }\n setRuntimeSetDataVisibility(this, true)\n if (isPage) {\n notifyRouteStateSync({\n page: this as MiniProgramPageLike,\n source: 'page',\n })\n }\n callHookList(this, 'onShow', args)\n if (typeof userOnShow === 'function') {\n return userOnShow.apply(this, args)\n }\n },\n onHide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof userOnHide === 'function') {\n return userOnHide.apply(this, args)\n }\n },\n onReady(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n // 兼容:部分平台/模式可能触发 Page.onReady,而非 Component lifetimes.ready\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n // 部分 IDE/基础库在首屏场景可能不派发 routeDone,这里做一次延迟兜底。\n // 若平台随后派发了真实 routeDone,会因为 __wevuRouteDoneCalled 判定而跳过补发。\n if (isPage && enableOnRouteDone && enableOnRouteDoneFallback) {\n // eslint-disable-next-line ts/no-this-alias\n const current = this\n setTimeout(() => {\n if (!(current as any)[WEVU_ROUTE_DONE_CALLED_KEY]) {\n pageLifecycleHooks.onRouteDone?.call(current)\n }\n }, 0)\n }\n scheduleTemplateRefUpdate(this, () => {\n callHookList(this, 'onReady', args)\n if (typeof userOnReady === 'function') {\n userOnReady.apply(this, args)\n }\n })\n return\n }\n if (typeof userOnReady === 'function') {\n return userOnReady.apply(this, args)\n }\n },\n }\n\n attachOptionalPageLifecycleHooks(pageLifecycleHooks, {\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n })\n\n return pageLifecycleHooks\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,yBAAuG,SAiCpH;CACD,MAAM,EACJ,YACA,OACA,OACA,YACA,cACA,YACA,YACA,aACA,QACA,uBACA,yBACA,qBACA,oBACA,mBACA,2BACA,oBACA,gBACA,yBACA,uBAC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;EACA,OAAmC,GAAG,MAAa;GACjD,IAAI,QACF,2BAA2B,IAAI;GAEjC,4BAA4B,MAAM,KAAK;GACvC,aAAa,MAAM,UAAU,IAAI;GACjC,IAAI,OAAO,eAAe,YACxB,OAAO,WAAW,MAAM,MAAM,IAAI;EAEtC;EACA,QAAoC,GAAG,MAAa;GAClD,IAAI,QAAQ;IACV,IAAI,CAAE,KAAa,0BACjB,mBAAmB,OAAO,KAAK,MAAM,mBAAmB,IAAI,CAAC;IAE/D,kGAA0B,MAAM,mBAAmB,IAAI,CAAC;IACxD,4BAA4B,IAAI;IAChC,qBAAqB;KACnB;KACA;IACF,CAAC;GACH;GAEA,IAAI,CAAE,KAAa,wBAAwB;IACxC,AAAC,KAAa,yBAAyB;IAGxC,IAAI,UAAU,qBAAqB,2BAA2B;KAE5D,MAAM,UAAU;KAChB,iBAAiB;MACf,IAAI,CAAE,QAAgB,6BAA6B;;OACjD,4CAAmB,mFAAa,KAAK,OAAO;MAC9C;KACF,GAAG,CAAC;IACN;IACA,0BAA0B,YAAY;KACpC,aAAa,MAAM,WAAW,IAAI;KAClC,IAAI,OAAO,gBAAgB,YACzB,YAAY,MAAM,MAAM,IAAI;IAEhC,CAAC;IACD;GACF;GACA,IAAI,OAAO,gBAAgB,YACzB,OAAO,YAAY,MAAM,MAAM,IAAI;EAEvC;CACF;CAEA,iCAAiC,oBAAoB;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"lifecycle.mjs","names":[],"sources":["../../../../../src/runtime/register/component/lifecycle.ts"],"sourcesContent":["import type { LocationQueryRaw } from '../../../router/types'\nimport type { MiniProgramPageLike } from '../../../routerInternal/shared'\nimport type { ComponentPropsOptions, ComputedDefinitions, DefineComponentOptions, InternalRuntimeState, MethodDefinitions, RuntimeApp } from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEVU_ON_LOAD_CALLED_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_ROUTE_DONE_CALLED_KEY,\n} from '@weapp-core/constants'\nimport { getInitialNavigationRunner } from '../../../router/initialNavigation'\nimport { isNavigationFailure } from '../../../router/navigationCore'\nimport { notifyRouteStateSync } from '../../../router/routeSync'\nimport { callHookList } from '../../hooks'\nimport { scheduleTemplateRefUpdate } from '../../templateRefs'\nimport { enableDeferredSetData, mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { attachOptionalPageLifecycleHooks } from './lifecycle/optionalHooks'\nimport { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, releaseCurrentPageInstance, resolvePageOptions } from './lifecycle/platform'\n\nconst INITIAL_NAVIGATION_PROMISE_KEY = Symbol('wevu.initialNavigationPromise')\nconst INITIAL_NAVIGATION_START_KEY = Symbol('wevu.startInitialNavigation')\n\nexport function getInitialNavigationPromise(instance: InternalRuntimeState) {\n return (instance as any)[INITIAL_NAVIGATION_PROMISE_KEY] as Promise<boolean> | undefined\n}\n\nexport function ensureInitialNavigation(\n instance: InternalRuntimeState,\n query?: LocationQueryRaw,\n options: { start?: boolean } = {},\n) {\n const existing = getInitialNavigationPromise(instance)\n if (existing) {\n if (options.start !== false) {\n ;(instance as any)[INITIAL_NAVIGATION_START_KEY]?.(query)\n }\n return existing\n }\n const initialNavigationRunner = getInitialNavigationRunner()\n if (!initialNavigationRunner) {\n return undefined\n }\n let resolveInitialNavigation!: (shouldMount: boolean) => void\n let rejectInitialNavigation!: (error: unknown) => void\n const initialNavigationPromise = new Promise<boolean>((resolve, reject) => {\n resolveInitialNavigation = resolve\n rejectInitialNavigation = reject\n })\n ;(instance as any)[INITIAL_NAVIGATION_PROMISE_KEY] = initialNavigationPromise\n let started = false\n ;(instance as any)[INITIAL_NAVIGATION_START_KEY] = (startQuery?: LocationQueryRaw) => {\n if (started) {\n return\n }\n started = true\n void initialNavigationRunner(instance as MiniProgramPageLike, startQuery ?? query)\n .then((result) => {\n const shouldMount = !isNavigationFailure(result)\n resolveInitialNavigation(shouldMount)\n }, rejectInitialNavigation)\n }\n if (options.start !== false) {\n ;(instance as any)[INITIAL_NAVIGATION_START_KEY](query)\n }\n return initialNavigationPromise\n}\n\nexport function createPageLifecycleHooks<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n userOnLoad?: any\n userOnUnload?: any\n userOnShow?: any\n userOnHide?: any\n userOnReady?: any\n isPage: boolean\n enableOnSaveExitState: boolean\n enableOnPullDownRefresh: boolean\n enableOnReachBottom: boolean\n enableOnPageScroll: boolean\n enableOnRouteDone: boolean\n enableOnRouteDoneFallback: boolean\n enableOnTabItemTap: boolean\n enableOnResize: boolean\n enableOnShareAppMessage: boolean\n enableOnShareTimeline: boolean\n enableOnAddToFavorites: boolean\n syncWevuPropsFromValues?: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n effectiveOnSaveExitState: (...args: any[]) => any\n effectiveOnPullDownRefresh: (...args: any[]) => any\n effectiveOnReachBottom: (...args: any[]) => any\n effectiveOnPageScroll: (...args: any[]) => any\n effectiveOnRouteDone: (...args: any[]) => any\n effectiveOnTabItemTap: (...args: any[]) => any\n effectiveOnResize: (...args: any[]) => any\n effectiveOnShareAppMessage: (...args: any[]) => any\n effectiveOnShareTimeline: (...args: any[]) => any\n effectiveOnAddToFavorites: (...args: any[]) => any\n hasHook: (target: InternalRuntimeState, name: string) => boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n isPage,\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n syncWevuPropsFromValues,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n } = options\n const flushPageSnapshotIfPossible = (target: InternalRuntimeState) => {\n ;(target as any).__wevu?.__wevu_flushSetupSnapshotSync?.()\n }\n\n const pageLifecycleHooks: Record<string, any> = {\n onLoad(this: InternalRuntimeState, ...args: any[]) {\n if ((this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n return\n }\n ;(this as any)[WEVU_ON_LOAD_CALLED_KEY] = true\n const mountPage = () => {\n mountRuntimeInstance(this, runtimeApp, watch, setup)\n const pageOptions = args[0] && typeof args[0] === 'object'\n ? args[0]\n : resolvePageOptions(this)\n syncWevuPropsFromValues?.(this, pageOptions)\n flushPageSnapshotIfPossible(this)\n enableDeferredSetData(this)\n if (isPage) {\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n callHookList(this, 'onLoad', args)\n if (typeof userOnLoad === 'function') {\n return userOnLoad.apply(this, args.length ? args : [pageOptions])\n }\n }\n\n const initialNavigationPromise = isPage\n ? ensureInitialNavigation(this, args[0])\n : undefined\n if (initialNavigationPromise) {\n void initialNavigationPromise.then((shouldMount) => {\n if (shouldMount) {\n mountPage()\n }\n }, () => {})\n return initialNavigationPromise\n }\n return mountPage()\n },\n onUnload(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n teardownRuntimeInstance(this)\n if (typeof userOnUnload === 'function') {\n return userOnUnload.apply(this, args)\n }\n },\n onShow(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n ensureMiniProgramGlobalPatched()\n bindCurrentPageInstance(this)\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n ;(this as any)[WEVU_ROUTE_DONE_CALLED_KEY] = false\n }\n setRuntimeSetDataVisibility(this, true)\n if (isPage) {\n notifyRouteStateSync({\n page: this as MiniProgramPageLike,\n source: 'page',\n })\n }\n callHookList(this, 'onShow', args)\n if (typeof userOnShow === 'function') {\n return userOnShow.apply(this, args)\n }\n },\n onHide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof userOnHide === 'function') {\n return userOnHide.apply(this, args)\n }\n },\n onReady(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n // 兼容:部分平台/模式可能触发 Page.onReady,而非 Component lifetimes.ready\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n // 部分 IDE/基础库在首屏场景可能不派发 routeDone,这里做一次延迟兜底。\n // 若平台随后派发了真实 routeDone,会因为 __wevuRouteDoneCalled 判定而跳过补发。\n if (isPage && enableOnRouteDone && enableOnRouteDoneFallback) {\n // eslint-disable-next-line ts/no-this-alias\n const current = this\n setTimeout(() => {\n if (!(current as any)[WEVU_ROUTE_DONE_CALLED_KEY]) {\n pageLifecycleHooks.onRouteDone?.call(current)\n }\n }, 0)\n }\n const callReadyHooks = () => {\n callHookList(this, 'onReady', args)\n if (typeof userOnReady === 'function') {\n userOnReady.apply(this, args)\n }\n }\n const initialNavigationPromise = getInitialNavigationPromise(this)\n const callReadyHooksAfterInitialNavigation = () => {\n if (initialNavigationPromise) {\n void initialNavigationPromise.then((shouldMount) => {\n if (shouldMount) {\n callReadyHooks()\n }\n }, () => {})\n return\n }\n callReadyHooks()\n }\n scheduleTemplateRefUpdate(this, callReadyHooksAfterInitialNavigation)\n return\n }\n if (typeof userOnReady === 'function') {\n return userOnReady.apply(this, args)\n }\n },\n }\n\n attachOptionalPageLifecycleHooks(pageLifecycleHooks, {\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n })\n\n return pageLifecycleHooks\n}\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,iCAAiC,OAAO,+BAA+B;AAC7E,MAAM,+BAA+B,OAAO,6BAA6B;AAEzE,SAAgB,4BAA4B,UAAgC;CAC1E,OAAQ,SAAiB;AAC3B;AAEA,SAAgB,wBACd,UACA,OACA,UAA+B,CAAC,GAChC;CACA,MAAM,WAAW,4BAA4B,QAAQ;CACrD,IAAI,UAAU;EACZ,IAAI,QAAQ,UAAU,OAAO;;GAC1B,yBAAC,SAAiB,oHAAgC,KAAK;EAC1D;EACA,OAAO;CACT;CACA,MAAM,0BAA0B,2BAA2B;CAC3D,IAAI,CAAC,yBACH;CAEF,IAAI;CACJ,IAAI;CACJ,MAAM,2BAA2B,IAAI,SAAkB,SAAS,WAAW;EACzE,2BAA2B;EAC3B,0BAA0B;CA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