wevu 6.16.5 → 6.16.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { d as reactive } from "./ref-BTTXccLL.mjs";
2
- import { A as onLoad, Q as getCurrentSetupContext, U as onShow, a as resolveCurrentRoute, c as normalizeRouteParams, d as createAbsoluteRoutePath, f as isDynamicRoutePath, g as injectGlobal, i as parsePathInput, l as parseQuery, n as useNativeRouter$1, o as normalizeHash, p as resolvePath, r as createRouteLocation, s as normalizeQuery, t as useNativePageRouter$1, u as stringifyQuery, ut as readonly, v as provideGlobal, z as onRouteDone } from "./router-BZZnIx32.mjs";
1
+ import { d as reactive } from "./ref-oJCdOWf7.mjs";
2
+ import { K as onRouteDone, L as onLoad, W as onReady, X as onShow, _t as readonly, a as resolveCurrentRoute, at as getCurrentSetupContext, c as normalizeRouteParams, d as createAbsoluteRoutePath, f as isDynamicRoutePath, g as injectGlobal, i as parsePathInput, l as parseQuery, n as useNativeRouter$1, o as normalizeHash, p as resolvePath, r as createRouteLocation, s as normalizeQuery, t as useNativePageRouter$1, u as stringifyQuery, v as provideGlobal } from "./router-CXNNN43P.mjs";
3
3
 
4
4
  //#region src/routerInternal/params.ts
5
5
  const PATH_PARAM_TOKEN_RE = /^:(\w+)(?:\([^)]*\))?([+*?])?$/;
@@ -1083,32 +1083,50 @@ function createRouteRegistry(namedRouteLookup) {
1083
1083
 
1084
1084
  //#endregion
1085
1085
  //#region src/router/useRoute.ts
1086
- function useRoute() {
1087
- if (!getCurrentSetupContext()) throw new Error("useRoute() 必须在 setup() 的同步阶段调用");
1088
- const currentRoute = resolveCurrentRoute();
1086
+ function applyRouteState(routeState, nextRoute) {
1087
+ routeState.path = nextRoute.path;
1088
+ routeState.fullPath = nextRoute.fullPath;
1089
+ routeState.query = cloneLocationQuery(nextRoute.query);
1090
+ routeState.hash = nextRoute.hash;
1091
+ routeState.params = cloneRouteParams(nextRoute.params);
1092
+ if (nextRoute.name === void 0) delete routeState.name;
1093
+ else routeState.name = nextRoute.name;
1094
+ if (nextRoute.meta === void 0) delete routeState.meta;
1095
+ else routeState.meta = cloneRouteMeta(nextRoute.meta);
1096
+ if (nextRoute.href === void 0) delete routeState.href;
1097
+ else routeState.href = nextRoute.href;
1098
+ if (nextRoute.matched === void 0) delete routeState.matched;
1099
+ else routeState.matched = cloneRouteRecordMatchedList(nextRoute.matched);
1100
+ if (nextRoute.redirectedFrom === void 0) delete routeState.redirectedFrom;
1101
+ else routeState.redirectedFrom = cloneRouteLocationRedirectedFrom(nextRoute.redirectedFrom);
1102
+ }
1103
+ function useRoute(options = {}) {
1104
+ var _options$resolveRoute;
1105
+ const setupContext = getCurrentSetupContext();
1106
+ if (!setupContext) throw new Error("useRoute() 必须在 setup() 的同步阶段调用");
1107
+ const fallbackPage = setupContext.instance;
1108
+ const resolveRoute = (_options$resolveRoute = options.resolveRoute) !== null && _options$resolveRoute !== void 0 ? _options$resolveRoute : ((route) => {
1109
+ var _getActiveRouter$reso, _getActiveRouter;
1110
+ return (_getActiveRouter$reso = (_getActiveRouter = getActiveRouter()) === null || _getActiveRouter === void 0 ? void 0 : _getActiveRouter.resolve(route)) !== null && _getActiveRouter$reso !== void 0 ? _getActiveRouter$reso : route;
1111
+ });
1112
+ const currentRoute = resolveRoute(resolveCurrentRoute(void 0, fallbackPage));
1089
1113
  const routeState = reactive({
1090
1114
  path: currentRoute.path,
1091
1115
  fullPath: currentRoute.fullPath,
1092
- query: currentRoute.query,
1116
+ query: cloneLocationQuery(currentRoute.query),
1093
1117
  hash: currentRoute.hash,
1094
- params: currentRoute.params,
1095
- name: currentRoute.name
1118
+ params: cloneRouteParams(currentRoute.params)
1096
1119
  });
1097
- if (currentRoute.meta !== void 0) routeState.meta = currentRoute.meta;
1120
+ applyRouteState(routeState, currentRoute);
1098
1121
  function syncRoute(queryOverride) {
1099
- const nextRoute = resolveCurrentRoute(queryOverride);
1100
- routeState.path = nextRoute.path;
1101
- routeState.fullPath = nextRoute.fullPath;
1102
- routeState.query = nextRoute.query;
1103
- routeState.hash = nextRoute.hash;
1104
- if (nextRoute.meta === void 0) delete routeState.meta;
1105
- else routeState.meta = nextRoute.meta;
1106
- routeState.params = nextRoute.params;
1107
- routeState.name = nextRoute.name;
1122
+ applyRouteState(routeState, resolveRoute(resolveCurrentRoute(queryOverride, fallbackPage)));
1108
1123
  }
1109
1124
  onLoad((query) => {
1110
1125
  syncRoute(query);
1111
1126
  });
1127
+ onReady(() => {
1128
+ syncRoute();
1129
+ });
1112
1130
  onShow(() => {
1113
1131
  syncRoute();
1114
1132
  });
@@ -1138,7 +1156,6 @@ function useNativePageRouter() {
1138
1156
  function createRouter(options = {}) {
1139
1157
  var _options$maxRedirects, _options$paramsMode, _options$rejectOnErro, _options$parseQuery, _options$stringifyQue, _options$tabBarEntrie;
1140
1158
  const nativeRouter = useNativeRouter();
1141
- const route = useRoute();
1142
1159
  const beforeEachGuards = /* @__PURE__ */ new Set();
1143
1160
  const beforeResolveGuards = /* @__PURE__ */ new Set();
1144
1161
  const afterEachHooks = /* @__PURE__ */ new Set();
@@ -1158,8 +1175,8 @@ function createRouter(options = {}) {
1158
1175
  const tabBarPathSet = new Set(normalizedTabBarEntries);
1159
1176
  const routeRegistry = createRouteRegistry(namedRouteLookup);
1160
1177
  const routerOptions = createRouterOptionsSnapshot(normalizedTabBarEntries, routeRegistry.getRoutes(), paramsMode, maxRedirects, routeResolveCodec, rejectOnError);
1161
- function resolveWithCodec(to, currentPath) {
1162
- const resolved = resolveRouteLocation(typeof to === "string" ? to : resolveNamedRouteLocation(to, namedRouteLookup, paramsMode), currentPath, routeResolveCodec);
1178
+ function enrichRouteRecordState(routeLocation) {
1179
+ const resolved = { ...routeLocation };
1163
1180
  resolved.href = resolved.fullPath;
1164
1181
  const matchedResult = resolveMatchedRouteRecord(resolved, namedRouteLookup);
1165
1182
  if (matchedResult) {
@@ -1174,6 +1191,10 @@ function createRouter(options = {}) {
1174
1191
  } else resolved.matched = [];
1175
1192
  return resolved;
1176
1193
  }
1194
+ function resolveWithCodec(to, currentPath) {
1195
+ return enrichRouteRecordState(resolveRouteLocation(typeof to === "string" ? to : resolveNamedRouteLocation(to, namedRouteLookup, paramsMode), currentPath, routeResolveCodec));
1196
+ }
1197
+ const route = useRoute({ resolveRoute: enrichRouteRecordState });
1177
1198
  function resolve(to) {
1178
1199
  return resolveWithCodec(to, route.path);
1179
1200
  }