wevu 6.19.0 → 6.19.2
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/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/defineProperty.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/toPrimitive.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/toPropertyKey.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/typeof.mjs +1 -1
- package/dist/dev/index.mjs +0 -1
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/reactivity/core.mjs +1 -1
- package/dist/dev/reactivity/reactive/patch.mjs +2 -1
- package/dist/dev/reactivity/reactive/patch.mjs.map +1 -1
- package/dist/dev/reactivity/reactive.mjs +2 -1
- package/dist/dev/reactivity/reactive.mjs.map +1 -1
- package/dist/dev/reactivity/ref.mjs +1 -1
- package/dist/dev/router/createRouter.mjs +6 -3
- package/dist/dev/router/createRouter.mjs.map +1 -1
- package/dist/dev/router/navigationTarget.mjs +2 -1
- package/dist/dev/router/navigationTarget.mjs.map +1 -1
- package/dist/dev/router/resolve.mjs +9 -2
- package/dist/dev/router/resolve.mjs.map +1 -1
- package/dist/dev/routerInternal/location.mjs +3 -1
- package/dist/dev/routerInternal/location.mjs.map +1 -1
- package/dist/dev/routerInternal/records.mjs +2 -1
- package/dist/dev/routerInternal/records.mjs.map +1 -1
- package/dist/dev/runtime/app/mount.mjs +2 -1
- package/dist/dev/runtime/app/mount.mjs.map +1 -1
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +6 -3
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -1
- package/dist/dev/runtime/define.mjs +6 -4
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -1
- package/dist/dev/runtime/platform.mjs +4 -2
- package/dist/dev/runtime/platform.mjs.map +1 -1
- package/dist/dev/runtime/register/app.mjs +3 -1
- package/dist/dev/runtime/register/app.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +2 -1
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -1
- package/dist/dev/runtime/register/component/methods.mjs +3 -1
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -1
- package/dist/dev/runtime/register/component.mjs +35 -34
- package/dist/dev/runtime/register/component.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +4 -2
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +4 -2
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance.mjs +6 -3
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
- package/dist/dev/runtime/register/snapshot.mjs +2 -1
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs/helpers.mjs +13 -8
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs.mjs +4 -3
- package/dist/dev/runtime/templateRefs.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/model.mjs +2 -1
- package/dist/dev/runtime/vueCompat/model.mjs.map +1 -1
- package/dist/dev/store/define/optionsStyle.mjs +17 -15
- package/dist/dev/store/define/optionsStyle.mjs.map +1 -1
- package/dist/dev/store/define/setupStyle.mjs +17 -15
- package/dist/dev/store/define/setupStyle.mjs.map +1 -1
- package/dist/dev/vue-demi.mjs +0 -158
- package/dist/dev/vue-demi.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/reactivity/core.mjs +1 -1
- package/dist/reactivity/reactive/patch.mjs +1 -1
- package/dist/reactivity/reactive.mjs +1 -1
- package/dist/reactivity/ref.mjs +1 -1
- package/dist/reactivity/watch/helpers.mjs +1 -1
- package/dist/router/createRouter.mjs +1 -1
- package/dist/router/navigationTarget.mjs +1 -1
- package/dist/router/resolve.mjs +1 -1
- package/dist/routerInternal/location.mjs +1 -1
- package/dist/routerInternal/records.mjs +1 -1
- package/dist/runtime/app/mount.mjs +1 -1
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
- package/dist/runtime/define.mjs +1 -1
- package/dist/runtime/platform.mjs +1 -1
- package/dist/runtime/register/app.mjs +1 -1
- package/dist/runtime/register/component/lifecycle/platform.mjs +1 -1
- package/dist/runtime/register/component/methods.mjs +1 -1
- package/dist/runtime/register/component/props.mjs +1 -1
- package/dist/runtime/register/component.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
- package/dist/runtime/register/runtimeInstance.mjs +1 -1
- package/dist/runtime/register/snapshot.mjs +1 -1
- package/dist/runtime/templateRefs/helpers.mjs +1 -1
- package/dist/runtime/vueCompat/model.mjs +1 -1
- package/dist/store/storeToRefs.mjs +1 -1
- package/dist/vue-demi.d.mts +1 -3
- package/dist/vue-demi.mjs +1 -1
- package/package.json +6 -6
- package/dist/_virtual/_rolldown/runtime.mjs +0 -1
- package/dist/dev/_virtual/_rolldown/runtime.mjs +0 -36
- /package/dist/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/defineProperty.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/toPrimitive.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/toPropertyKey.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.139.0 → _@oxc-project_runtime@0.143.0}/helpers/esm/typeof.mjs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import toPropertyKey from "./toPropertyKey.mjs";
|
|
2
2
|
|
|
3
|
-
//#region \0@oxc-project+runtime@0.
|
|
3
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
4
4
|
function _defineProperty(e, r, t) {
|
|
5
5
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
6
|
value: t,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _typeof from "./typeof.mjs";
|
|
2
2
|
|
|
3
|
-
//#region \0@oxc-project+runtime@0.
|
|
3
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
|
|
4
4
|
function toPrimitive(t, r) {
|
|
5
5
|
if ("object" != _typeof(t) || !t) return t;
|
|
6
6
|
var e = t[Symbol.toPrimitive];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _typeof from "./typeof.mjs";
|
|
2
2
|
import toPrimitive from "./toPrimitive.mjs";
|
|
3
3
|
|
|
4
|
-
//#region \0@oxc-project+runtime@0.
|
|
4
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
5
5
|
function toPropertyKey(t) {
|
|
6
6
|
var i = toPrimitive(t, "string");
|
|
7
7
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.
|
|
1
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
|
|
2
2
|
function _typeof(o) {
|
|
3
3
|
"@babel/helpers - typeof";
|
|
4
4
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
package/dist/dev/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __exportAll, __reExport } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
1
|
import { nextTick } from "./scheduler.mjs";
|
|
3
2
|
import { batch, effect, effectScope, endBatch, getCurrentScope, onScopeDispose, startBatch, stop } from "./reactivity/core.mjs";
|
|
4
3
|
import { addMutationRecorder, removeMutationRecorder } from "./reactivity/reactive/mutation.mjs";
|
package/dist/dev/package.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { queueJob } from "../scheduler.mjs";
|
|
2
|
-
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
+
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/reactivity/core.ts
|
|
5
5
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.mjs","names":[],"sources":["../../../../src/reactivity/reactive/patch.ts"],"sourcesContent":["import { track } from '../core'\nimport {\n adoptReactiveRoot,\n indexPatchNode,\n rawMultiParentSet,\n rawParentMap,\n rawParentsMap,\n rawPathMap,\n rawRootMap,\n rawVersionMap,\n recordParentLink,\n rootPatchNodesMap,\n} from './patchState'\nimport { isObject, ReactiveFlags, toRaw, VERSION_KEY } from './shared'\n\nexport interface PrelinkReactiveTreeOptions {\n shouldIncludeTopKey?: (key: string) => boolean\n maxDepth?: number\n maxKeys?: number\n}\n\n/**\n * 预链接响应式树结构,供运行时差量路径追踪使用。\n * @internal\n */\nexport function prelinkReactiveTree(root: object, options?: PrelinkReactiveTreeOptions) {\n const rootRaw = toRaw(root as any) as object\n rawPathMap.set(rootRaw, '')\n indexPatchNode(rootRaw, rootRaw)\n\n const shouldIncludeTopKey = options?.shouldIncludeTopKey\n const maxDepth = typeof options?.maxDepth === 'number' ? Math.max(0, Math.floor(options!.maxDepth!)) : Number.POSITIVE_INFINITY\n const maxKeys = typeof options?.maxKeys === 'number' ? Math.max(0, Math.floor(options!.maxKeys!)) : Number.POSITIVE_INFINITY\n\n const visited = new WeakSet<object>()\n const stack: Array<{ current: object, path: string, depth: number }> = [{ current: rootRaw, path: '', depth: 0 }]\n let indexed = 0\n\n while (stack.length) {\n const node = stack.pop()!\n if (visited.has(node.current)) {\n continue\n }\n visited.add(node.current)\n rawPathMap.set(node.current, node.path)\n indexPatchNode(rootRaw, node.current)\n indexed += 1\n if (indexed >= maxKeys) {\n continue\n }\n\n if (node.depth >= maxDepth) {\n continue\n }\n if (Array.isArray(node.current)) {\n // 数组不预先展开子元素:大列表场景避免 O(n) 初始化开销。\n continue\n }\n\n const entries = Object.entries(node.current as any)\n for (const [key, value] of entries) {\n if (node.path === '' && shouldIncludeTopKey && !shouldIncludeTopKey(key)) {\n continue\n }\n if (!isObject(value)) {\n continue\n }\n if ((value as any)[ReactiveFlags.SKIP]) {\n continue\n }\n const childRaw = toRaw(value as any) as object\n adoptReactiveRoot(childRaw, node.current)\n recordParentLink(childRaw, node.current, key)\n if (!rawMultiParentSet.has(childRaw)) {\n const childPath = node.path ? `${node.path}.${key}` : key\n rawPathMap.set(childRaw, childPath)\n }\n indexPatchNode(rootRaw, childRaw)\n stack.push({ current: childRaw, path: node.path ? `${node.path}.${key}` : key, depth: node.depth + 1 })\n }\n }\n}\n\n/**\n * 清理预链接阶段建立的路径与父子索引。\n * @internal\n */\nexport function clearPatchIndices(root: object) {\n const rootRaw = toRaw(root as any) as object\n const nodes = rootPatchNodesMap.get(rootRaw)\n if (!nodes) {\n rawPathMap.delete(rootRaw)\n return\n }\n\n for (const node of nodes) {\n rawParentMap.delete(node)\n rawParentsMap.delete(node)\n rawPathMap.delete(node)\n rawMultiParentSet.delete(node)\n rawRootMap.delete(node)\n rawVersionMap.delete(node)\n }\n\n rootPatchNodesMap.delete(rootRaw)\n}\n\n/**\n * 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。\n * @internal\n */\nexport function touchReactive(target: object) {\n const raw = toRaw(target as any) as object\n track(raw, VERSION_KEY)\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,oBAAoB,MAAc,SAAsC;CACtF,MAAM,U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KAAK;IAAE,SAAS;IAAU,MAAM,KAAK,OAAO,GAAG,KAAK,KAAK,GAAG,QAAQ;IAAK,OAAO,KAAK,QAAQ;GAAE,CAAC;EACxG;CACF;AACF;;;;;AAMA,SAAgB,kBAAkB,MAAc;CAC9C,MAAM,UAAU,MAAM,IAAW;CACjC,MAAM,QAAQ,kBAAkB,IAAI,OAAO;CAC3C,IAAI,CAAC,OAAO;EACV,WAAW,OAAO,OAAO;EACzB;CACF;CAEA,KAAK,MAAM,QAAQ,OAAO;EACxB,aAAa,OAAO,IAAI;EACxB,cAAc,OAAO,IAAI;EACzB,WAAW,OAAO,IAAI;EACtB,kBAAkB,OAAO,IAAI;EAC7B,WAAW,OAAO,IAAI;EACtB,cAAc,OAAO,IAAI;CAC3B;CAEA,kBAAkB,OAAO,OAAO;AAClC;;;;;AAMA,SAAgB,cAAc,QAAgB;
|
|
1
|
+
{"version":3,"file":"patch.mjs","names":[],"sources":["../../../../src/reactivity/reactive/patch.ts"],"sourcesContent":["import { track } from '../core'\nimport {\n adoptReactiveRoot,\n indexPatchNode,\n rawMultiParentSet,\n rawParentMap,\n rawParentsMap,\n rawPathMap,\n rawRootMap,\n rawVersionMap,\n recordParentLink,\n rootPatchNodesMap,\n} from './patchState'\nimport { isObject, ReactiveFlags, toRaw, VERSION_KEY } from './shared'\n\nexport interface PrelinkReactiveTreeOptions {\n shouldIncludeTopKey?: (key: string) => boolean\n maxDepth?: number\n maxKeys?: number\n}\n\n/**\n * 预链接响应式树结构,供运行时差量路径追踪使用。\n * @internal\n */\nexport function prelinkReactiveTree(root: object, options?: PrelinkReactiveTreeOptions) {\n const rootRaw = toRaw(root as any) as object\n rawPathMap.set(rootRaw, '')\n indexPatchNode(rootRaw, rootRaw)\n\n const shouldIncludeTopKey = options?.shouldIncludeTopKey\n const maxDepth = typeof options?.maxDepth === 'number' ? Math.max(0, Math.floor(options!.maxDepth!)) : Number.POSITIVE_INFINITY\n const maxKeys = typeof options?.maxKeys === 'number' ? Math.max(0, Math.floor(options!.maxKeys!)) : Number.POSITIVE_INFINITY\n\n const visited = new WeakSet<object>()\n const stack: Array<{ current: object, path: string, depth: number }> = [{ current: rootRaw, path: '', depth: 0 }]\n let indexed = 0\n\n while (stack.length) {\n const node = stack.pop()!\n if (visited.has(node.current)) {\n continue\n }\n visited.add(node.current)\n rawPathMap.set(node.current, node.path)\n indexPatchNode(rootRaw, node.current)\n indexed += 1\n if (indexed >= maxKeys) {\n continue\n }\n\n if (node.depth >= maxDepth) {\n continue\n }\n if (Array.isArray(node.current)) {\n // 数组不预先展开子元素:大列表场景避免 O(n) 初始化开销。\n continue\n }\n\n const entries = Object.entries(node.current as any)\n for (const [key, value] of entries) {\n if (node.path === '' && shouldIncludeTopKey && !shouldIncludeTopKey(key)) {\n continue\n }\n if (!isObject(value)) {\n continue\n }\n if ((value as any)[ReactiveFlags.SKIP]) {\n continue\n }\n const childRaw = toRaw(value as any) as object\n adoptReactiveRoot(childRaw, node.current)\n recordParentLink(childRaw, node.current, key)\n if (!rawMultiParentSet.has(childRaw)) {\n const childPath = node.path ? `${node.path}.${key}` : key\n rawPathMap.set(childRaw, childPath)\n }\n indexPatchNode(rootRaw, childRaw)\n stack.push({ current: childRaw, path: node.path ? `${node.path}.${key}` : key, depth: node.depth + 1 })\n }\n }\n}\n\n/**\n * 清理预链接阶段建立的路径与父子索引。\n * @internal\n */\nexport function clearPatchIndices(root: object) {\n const rootRaw = toRaw(root as any) as object\n const nodes = rootPatchNodesMap.get(rootRaw)\n if (!nodes) {\n rawPathMap.delete(rootRaw)\n return\n }\n\n for (const node of nodes) {\n rawParentMap.delete(node)\n rawParentsMap.delete(node)\n rawPathMap.delete(node)\n rawMultiParentSet.delete(node)\n rawRootMap.delete(node)\n rawVersionMap.delete(node)\n }\n\n rootPatchNodesMap.delete(rootRaw)\n}\n\n/**\n * 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。\n * @internal\n */\nexport function touchReactive(target: object) {\n const raw = toRaw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AAG,KAAK,KAAK,GAAG,QAAQ;IACtD,WAAW,IAAI,UAAU,SAAS;GACpC;GACA,eAAe,SAAS,QAAQ;GAChC,MAAM,KAAK;IAAE,SAAS;IAAU,MAAM,KAAK,OAAO,GAAG,KAAK,KAAK,GAAG,QAAQ;IAAK,OAAO,KAAK,QAAQ;GAAE,CAAC;EACxG;CACF;AACF;;;;;AAMA,SAAgB,kBAAkB,MAAc;CAC9C,MAAM,UAAU,MAAM,IAAW;CACjC,MAAM,QAAQ,kBAAkB,IAAI,OAAO;CAC3C,IAAI,CAAC,OAAO;EACV,WAAW,OAAO,OAAO;EACzB;CACF;CAEA,KAAK,MAAM,QAAQ,OAAO;EACxB,aAAa,OAAO,IAAI;EACxB,cAAc,OAAO,IAAI;EACzB,WAAW,OAAO,IAAI;EACtB,kBAAkB,OAAO,IAAI;EAC7B,WAAW,OAAO,IAAI;EACtB,cAAc,OAAO,IAAI;CAC3B;CAEA,kBAAkB,OAAO,OAAO;AAClC;;;;;AAMA,SAAgB,cAAc,QAAgB;CAC5C,MAAM,MAAM,MAAM,MAAa;CAC/B,MAAM,KAAK,WAAW;AACxB"}
|
|
@@ -12,7 +12,8 @@ import { isShallowReactive, shallowReactive } from "./reactive/shallow.mjs";
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
function getReactiveVersion(target) {
|
|
15
|
-
|
|
15
|
+
const raw = toRaw(target);
|
|
16
|
+
return getRawVersion(raw);
|
|
16
17
|
}
|
|
17
18
|
function emitMutation(target, key, op) {
|
|
18
19
|
var _rawRootMap$get;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.mjs","names":[],"sources":["../../../src/reactivity/reactive.ts"],"sourcesContent":["import type { MutationKind, MutationOp } from './reactive/mutation'\nimport { track, trigger } from './core'\nimport { mutationRecorders } from './reactive/mutation'\nimport {\n adoptReactiveRoot,\n bumpAncestorVersions,\n bumpRawVersion,\n getRawVersion,\n rawMultiParentSet,\n rawParentsMap,\n rawPathMap,\n rawRootMap,\n rawVersionMap,\n recordParentLink,\n removeParentLink,\n resolvePathToTarget,\n} from './reactive/patchState'\nimport { getTargetType, hasOwn, isArrayIndexKey, isObject, ReactiveFlags, TargetType, toRaw, VERSION_KEY } from './reactive/shared'\nimport { rawMap, reactiveMap } from './reactive/state'\n\nexport { addMutationRecorder, removeMutationRecorder } from './reactive/mutation'\nexport type { MutationKind, MutationOp, MutationRecord } from './reactive/mutation'\nexport type { PrelinkReactiveTreeOptions } from './reactive/patch'\nexport { clearPatchIndices, prelinkReactiveTree, touchReactive } from './reactive/patch'\nexport { isShallowReactive, shallowReactive } from './reactive/shallow'\nexport { isObject, ReactiveFlags, toRaw } from './reactive/shared'\n\n/**\n * 读取响应式版本号(框架内部调试能力)。\n * @internal\n */\nexport function getReactiveVersion(target: object) {\n const raw = toRaw(target as any) as object\n return getRawVersion(raw)\n}\n\nfunction emitMutation(target: object, key: PropertyKey, op: MutationOp) {\n if (!mutationRecorders.size) {\n return\n }\n if (typeof key !== 'string') {\n return\n }\n if (key.startsWith('__r_')) {\n return\n }\n const root = rawRootMap.get(target) ?? target\n const isArray = Array.isArray(target)\n const kind: MutationKind = isArray && (key === 'length' || isArrayIndexKey(key)) ? 'array' : 'property'\n\n const baseSegments = resolvePathToTarget(root, target)\n if (!baseSegments) {\n // 路径不唯一/无法解析:尝试从父引用收集可能的顶层 key,供 patch 模式做“局部回退”。\n const fallback = new Set<string>()\n const parents = rawParentsMap.get(target)\n if (parents) {\n for (const [parent, keys] of parents) {\n const parentPath = rawPathMap.get(parent)\n const topFromParentPath = parentPath ? parentPath.split('.', 1)[0] : undefined\n const topFromResolve = !topFromParentPath\n ? (resolvePathToTarget(root, parent)?.[0] as string | undefined)\n : undefined\n for (const k of keys) {\n if (typeof k !== 'string') {\n continue\n }\n fallback.add(topFromParentPath ?? topFromResolve ?? k)\n }\n }\n }\n else {\n // 若目标就是 root 的直接子属性(未记录 parent link),仍可用 key 作为顶层回退\n fallback.add(key)\n }\n for (const recorder of mutationRecorders) {\n recorder({ root, kind, op, path: undefined, fallbackTopKeys: fallback.size ? [...fallback] : undefined })\n }\n return\n }\n\n // 若目标位于数组内部(例如 arr[0].x),直接回退到数组本身的路径,保持“数组整体替换”的策略。\n const arrayIndexPos = baseSegments.findIndex(seg => isArrayIndexKey(seg))\n if (arrayIndexPos !== -1) {\n const arrayPath = baseSegments.slice(0, arrayIndexPos).join('.')\n const path = arrayPath || undefined\n for (const recorder of mutationRecorders) {\n recorder({ root, kind: 'array', op, path })\n }\n return\n }\n\n const basePath = baseSegments.length ? baseSegments.join('.') : ''\n const path = kind === 'array' ? (basePath || undefined) : (basePath ? `${basePath}.${key}` : (key as string))\n\n for (const recorder of mutationRecorders) {\n recorder({\n root,\n kind,\n op,\n path,\n })\n }\n}\n\nconst mutableHandlers: ProxyHandler<any> = {\n get(target, key, receiver) {\n if (key === ReactiveFlags.IS_REACTIVE) {\n return true\n }\n if (key === ReactiveFlags.RAW) {\n return target\n }\n const res = Reflect.get(target, key, receiver)\n track(target, key)\n if (isObject(res)) {\n // 检查返回值是否被 markRaw 标记为跳过响应式\n if ((res as any)[ReactiveFlags.SKIP]) {\n return res\n }\n // 确保子对象的根引用与当前目标一致,便于版本号级联\n const childRaw = ((res as any)?.[ReactiveFlags.RAW] ?? res) as object\n adoptReactiveRoot(childRaw, target)\n recordParentLink(childRaw, target, key)\n const parentPath = rawPathMap.get(target)\n if (mutationRecorders.size && typeof key === 'string' && parentPath != null && !rawMultiParentSet.has(childRaw)) {\n const nextPath = parentPath ? `${parentPath}.${key}` : key\n rawPathMap.set(childRaw, nextPath)\n }\n // eslint-disable-next-line ts/no-use-before-define -- 避免递归调用的顺序警告\n return reactive(res)\n }\n return res\n },\n set(target, key, value, receiver) {\n const isArr = Array.isArray(target)\n const oldLength = isArr ? target.length : 0\n const oldValue = Reflect.get(target, key, receiver)\n const oldRawValue = isObject(oldValue) ? toRaw(oldValue) : oldValue\n const rawValue = isObject(value) ? toRaw(value) : value\n if (Object.is(oldRawValue, rawValue)) {\n return true\n }\n const result = Reflect.set(target, key, value, receiver)\n if (result) {\n const oldRaw = isObject(oldRawValue) ? oldRawValue as object : undefined\n if (oldRaw) {\n removeParentLink(oldRaw, target, key)\n }\n if (isObject(rawValue) && !(rawValue as any)[ReactiveFlags.SKIP]) {\n const childRaw = rawValue as object\n adoptReactiveRoot(childRaw, target)\n recordParentLink(childRaw, target, key)\n const parentPath = rawPathMap.get(target)\n if (mutationRecorders.size && typeof key === 'string' && parentPath != null && !rawMultiParentSet.has(childRaw)) {\n const nextPath = parentPath ? `${parentPath}.${key}` : key\n rawPathMap.set(childRaw, nextPath)\n }\n }\n trigger(target, key)\n if (isArr && typeof key === 'string' && isArrayIndexKey(key) && Number(key) >= oldLength) {\n trigger(target, 'length')\n }\n // 任意写操作都提升通用版本号\n trigger(target, VERSION_KEY)\n bumpRawVersion(target)\n bumpAncestorVersions(target)\n const root = rawRootMap.get(target)\n if (root && root !== target) {\n trigger(root, VERSION_KEY)\n bumpRawVersion(root)\n }\n emitMutation(target, key, 'set')\n }\n return result\n },\n deleteProperty(target, key) {\n const hadKey = hasOwn(target, key)\n const oldValue = hadKey ? (target as any)[key] : undefined\n const result = Reflect.deleteProperty(target, key)\n if (hadKey && result) {\n const oldRaw = isObject(oldValue) ? (((oldValue as any)?.[ReactiveFlags.RAW] ?? oldValue) as object) : undefined\n if (oldRaw) {\n removeParentLink(oldRaw, target, key)\n }\n trigger(target, key)\n // 删除同样提升通用版本号\n trigger(target, VERSION_KEY)\n bumpRawVersion(target)\n bumpAncestorVersions(target)\n const root = rawRootMap.get(target)\n if (root && root !== target) {\n trigger(root, VERSION_KEY)\n bumpRawVersion(root)\n }\n emitMutation(target, key, 'delete')\n }\n return result\n },\n ownKeys(target) {\n track(target, Symbol.iterator)\n // 遍历时也订阅通用版本号,确保新增/删除键可触发\n track(target, VERSION_KEY)\n return Reflect.ownKeys(target)\n },\n}\n\nexport function reactive<T extends object>(target: T): T {\n if (!isObject(target)) {\n return target\n }\n if ((target as any)[ReactiveFlags.IS_REACTIVE]) {\n return target\n }\n const existingProxy = reactiveMap.get(target)\n if (existingProxy) {\n return existingProxy\n }\n if (getTargetType(target) === TargetType.INVALID) {\n return target\n }\n const proxy = new Proxy(target, mutableHandlers)\n reactiveMap.set(target, proxy)\n rawMap.set(proxy, target)\n if (!rawVersionMap.has(target)) {\n rawVersionMap.set(target, 0)\n }\n // 新的原始对象在被观察时初始化根节点映射\n if (!rawRootMap.has(target)) {\n rawRootMap.set(target, target)\n }\n return proxy\n}\n\nexport function isReactive(value: unknown): boolean {\n return Boolean(value && (value as any)[ReactiveFlags.IS_REACTIVE])\n}\n\nexport function convertToReactive<T>(value: T): T {\n return isObject(value) ? reactive(value as any) : value\n}\n\n// ============================================================================\n// 标记对象跳过响应式转换(markRaw)\n// ============================================================================\n\n/**\n * 标记对象为“原始”状态,后续不会被转换为响应式,返回原对象本身。\n *\n * @param value 需要标记的对象\n * @returns 带有跳过标记的原对象\n *\n * @example\n * ```ts\n * const foo = markRaw({\n * nested: {}\n * })\n *\n * const state = reactive({\n * foo\n * })\n *\n * state.foo // 不是响应式对象\n * ```\n */\nexport function markRaw<T extends object>(value: T): T {\n if (!isObject(value)) {\n return value\n }\n Object.defineProperty(value, ReactiveFlags.SKIP, {\n value: true,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n return value\n}\n\n/**\n * 判断某个值是否被标记为原始(即不应转换为响应式)。\n *\n * @param value 待检测的值\n * @returns 若含有跳过标记则返回 true\n */\nexport function isRaw(value: unknown): boolean {\n return isObject(value) && ReactiveFlags.SKIP in (value as object)\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,mBAAmB,QAAgB;CAEjD,OAAO,cADK,MAAM,MACK,CAAC;AAC1B;AAEA,SAAS,aAAa,QAAgB,KAAkB,IAAgB;;CACtE,IAAI,CAAC,kBAAkB,MACrB;CAEF,IAAI,OAAO,QAAQ,UACjB;CAEF,IAAI,IAAI,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,SAA2B,QAAc;CACvD,IAAI,CAAC,SAAS,MAAM,GAClB,OAAO;CAET,IAAK,0BACH,OAAO;CAET,MAAM,gBAAgB,YAAY,IAAI,MAAM;CAC5C,IAAI,eACF,OAAO;CAET,IAAI,cAAc,MAAM,SACtB,OAAO;CAET,MAAM,QAAQ,IAAI,MAAM,QAAQ,eAAe;CAC/C,YAAY,IAAI,QAAQ,KAAK;CAC7B,OAAO,IAAI,OAAO,MAAM;CACxB,IAAI,CAAC,cAAc,IAAI,MAAM,GAC3B,cAAc,IAAI,QAAQ,CAAC;CAG7B,IAAI,CAAC,WAAW,IAAI,MAAM,GACxB,WAAW,IAAI,QAAQ,MAAM;CAE/B,OAAO;AACT;AAEA,SAAgB,WAAW,OAAyB;CAClD,OAAO,QAAQ,SAAU,uBAAwC;AACnE;AAEA,SAAgB,kBAAqB,OAAa;CAChD,OAAO,SAAS,KAAK,IAAI,SAAS,KAAY,IAAI;AACpD;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,QAA0B,OAAa;CACrD,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,OAAO,eAAe,mBAA2B;EAC/C,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;CACZ,CAAC;CACD,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,OAAyB;CAC7C,OAAO,SAAS,KAAK,mBAA4B;AACnD"}
|
|
1
|
+
{"version":3,"file":"reactive.mjs","names":[],"sources":["../../../src/reactivity/reactive.ts"],"sourcesContent":["import type { MutationKind, MutationOp } from './reactive/mutation'\nimport { track, trigger } from './core'\nimport { mutationRecorders } from './reactive/mutation'\nimport {\n adoptReactiveRoot,\n bumpAncestorVersions,\n bumpRawVersion,\n getRawVersion,\n rawMultiParentSet,\n rawParentsMap,\n rawPathMap,\n rawRootMap,\n rawVersionMap,\n recordParentLink,\n removeParentLink,\n resolvePathToTarget,\n} from './reactive/patchState'\nimport { getTargetType, hasOwn, isArrayIndexKey, isObject, ReactiveFlags, TargetType, toRaw, VERSION_KEY } from './reactive/shared'\nimport { rawMap, reactiveMap } from './reactive/state'\n\nexport { addMutationRecorder, removeMutationRecorder } from './reactive/mutation'\nexport type { MutationKind, MutationOp, MutationRecord } from './reactive/mutation'\nexport type { PrelinkReactiveTreeOptions } from './reactive/patch'\nexport { clearPatchIndices, prelinkReactiveTree, touchReactive } from './reactive/patch'\nexport { isShallowReactive, shallowReactive } from './reactive/shallow'\nexport { isObject, ReactiveFlags, toRaw } from './reactive/shared'\n\n/**\n * 读取响应式版本号(框架内部调试能力)。\n * @internal\n */\nexport function getReactiveVersion(target: object) {\n const raw = toRaw(target as any) as object\n return getRawVersion(raw)\n}\n\nfunction emitMutation(target: object, key: PropertyKey, op: MutationOp) {\n if (!mutationRecorders.size) {\n return\n }\n if (typeof key !== 'string') {\n return\n }\n if (key.startsWith('__r_')) {\n return\n }\n const root = rawRootMap.get(target) ?? target\n const isArray = Array.isArray(target)\n const kind: MutationKind = isArray && (key === 'length' || isArrayIndexKey(key)) ? 'array' : 'property'\n\n const baseSegments = resolvePathToTarget(root, target)\n if (!baseSegments) {\n // 路径不唯一/无法解析:尝试从父引用收集可能的顶层 key,供 patch 模式做“局部回退”。\n const fallback = new Set<string>()\n const parents = rawParentsMap.get(target)\n if (parents) {\n for (const [parent, keys] of parents) {\n const parentPath = rawPathMap.get(parent)\n const topFromParentPath = parentPath ? parentPath.split('.', 1)[0] : undefined\n const topFromResolve = !topFromParentPath\n ? (resolvePathToTarget(root, parent)?.[0] as string | undefined)\n : undefined\n for (const k of keys) {\n if (typeof k !== 'string') {\n continue\n }\n fallback.add(topFromParentPath ?? topFromResolve ?? k)\n }\n }\n }\n else {\n // 若目标就是 root 的直接子属性(未记录 parent link),仍可用 key 作为顶层回退\n fallback.add(key)\n }\n for (const recorder of mutationRecorders) {\n recorder({ root, kind, op, path: undefined, fallbackTopKeys: fallback.size ? [...fallback] : undefined })\n }\n return\n }\n\n // 若目标位于数组内部(例如 arr[0].x),直接回退到数组本身的路径,保持“数组整体替换”的策略。\n const arrayIndexPos = baseSegments.findIndex(seg => isArrayIndexKey(seg))\n if (arrayIndexPos !== -1) {\n const arrayPath = baseSegments.slice(0, arrayIndexPos).join('.')\n const path = arrayPath || undefined\n for (const recorder of mutationRecorders) {\n recorder({ root, kind: 'array', op, path })\n }\n return\n }\n\n const basePath = baseSegments.length ? baseSegments.join('.') : ''\n const path = kind === 'array' ? (basePath || undefined) : (basePath ? `${basePath}.${key}` : (key as string))\n\n for (const recorder of mutationRecorders) {\n recorder({\n root,\n kind,\n op,\n path,\n })\n }\n}\n\nconst mutableHandlers: ProxyHandler<any> = {\n get(target, key, receiver) {\n if (key === ReactiveFlags.IS_REACTIVE) {\n return true\n }\n if (key === ReactiveFlags.RAW) {\n return target\n }\n const res = Reflect.get(target, key, receiver)\n track(target, key)\n if (isObject(res)) {\n // 检查返回值是否被 markRaw 标记为跳过响应式\n if ((res as any)[ReactiveFlags.SKIP]) {\n return res\n }\n // 确保子对象的根引用与当前目标一致,便于版本号级联\n const childRaw = ((res as any)?.[ReactiveFlags.RAW] ?? res) as object\n adoptReactiveRoot(childRaw, target)\n recordParentLink(childRaw, target, key)\n const parentPath = rawPathMap.get(target)\n if (mutationRecorders.size && typeof key === 'string' && parentPath != null && !rawMultiParentSet.has(childRaw)) {\n const nextPath = parentPath ? `${parentPath}.${key}` : key\n rawPathMap.set(childRaw, nextPath)\n }\n // eslint-disable-next-line ts/no-use-before-define -- 避免递归调用的顺序警告\n return reactive(res)\n }\n return res\n },\n set(target, key, value, receiver) {\n const isArr = Array.isArray(target)\n const oldLength = isArr ? target.length : 0\n const oldValue = Reflect.get(target, key, receiver)\n const oldRawValue = isObject(oldValue) ? toRaw(oldValue) : oldValue\n const rawValue = isObject(value) ? toRaw(value) : value\n if (Object.is(oldRawValue, rawValue)) {\n return true\n }\n const result = Reflect.set(target, key, value, receiver)\n if (result) {\n const oldRaw = isObject(oldRawValue) ? oldRawValue as object : undefined\n if (oldRaw) {\n removeParentLink(oldRaw, target, key)\n }\n if (isObject(rawValue) && !(rawValue as any)[ReactiveFlags.SKIP]) {\n const childRaw = rawValue as object\n adoptReactiveRoot(childRaw, target)\n recordParentLink(childRaw, target, key)\n const parentPath = rawPathMap.get(target)\n if (mutationRecorders.size && typeof key === 'string' && parentPath != null && !rawMultiParentSet.has(childRaw)) {\n const nextPath = parentPath ? `${parentPath}.${key}` : key\n rawPathMap.set(childRaw, nextPath)\n }\n }\n trigger(target, key)\n if (isArr && typeof key === 'string' && isArrayIndexKey(key) && Number(key) >= oldLength) {\n trigger(target, 'length')\n }\n // 任意写操作都提升通用版本号\n trigger(target, VERSION_KEY)\n bumpRawVersion(target)\n bumpAncestorVersions(target)\n const root = rawRootMap.get(target)\n if (root && root !== target) {\n trigger(root, VERSION_KEY)\n bumpRawVersion(root)\n }\n emitMutation(target, key, 'set')\n }\n return result\n },\n deleteProperty(target, key) {\n const hadKey = hasOwn(target, key)\n const oldValue = hadKey ? (target as any)[key] : undefined\n const result = Reflect.deleteProperty(target, key)\n if (hadKey && result) {\n const oldRaw = isObject(oldValue) ? (((oldValue as any)?.[ReactiveFlags.RAW] ?? oldValue) as object) : undefined\n if (oldRaw) {\n removeParentLink(oldRaw, target, key)\n }\n trigger(target, key)\n // 删除同样提升通用版本号\n trigger(target, VERSION_KEY)\n bumpRawVersion(target)\n bumpAncestorVersions(target)\n const root = rawRootMap.get(target)\n if (root && root !== target) {\n trigger(root, VERSION_KEY)\n bumpRawVersion(root)\n }\n emitMutation(target, key, 'delete')\n }\n return result\n },\n ownKeys(target) {\n track(target, Symbol.iterator)\n // 遍历时也订阅通用版本号,确保新增/删除键可触发\n track(target, VERSION_KEY)\n return Reflect.ownKeys(target)\n },\n}\n\nexport function reactive<T extends object>(target: T): T {\n if (!isObject(target)) {\n return target\n }\n if ((target as any)[ReactiveFlags.IS_REACTIVE]) {\n return target\n }\n const existingProxy = reactiveMap.get(target)\n if (existingProxy) {\n return existingProxy\n }\n if (getTargetType(target) === TargetType.INVALID) {\n return target\n }\n const proxy = new Proxy(target, mutableHandlers)\n reactiveMap.set(target, proxy)\n rawMap.set(proxy, target)\n if (!rawVersionMap.has(target)) {\n rawVersionMap.set(target, 0)\n }\n // 新的原始对象在被观察时初始化根节点映射\n if (!rawRootMap.has(target)) {\n rawRootMap.set(target, target)\n }\n return proxy\n}\n\nexport function isReactive(value: unknown): boolean {\n return Boolean(value && (value as any)[ReactiveFlags.IS_REACTIVE])\n}\n\nexport function convertToReactive<T>(value: T): T {\n return isObject(value) ? reactive(value as any) : value\n}\n\n// ============================================================================\n// 标记对象跳过响应式转换(markRaw)\n// ============================================================================\n\n/**\n * 标记对象为“原始”状态,后续不会被转换为响应式,返回原对象本身。\n *\n * @param value 需要标记的对象\n * @returns 带有跳过标记的原对象\n *\n * @example\n * ```ts\n * const foo = markRaw({\n * nested: {}\n * })\n *\n * const state = reactive({\n * foo\n * })\n *\n * state.foo // 不是响应式对象\n * ```\n */\nexport function markRaw<T extends object>(value: T): T {\n if (!isObject(value)) {\n return value\n }\n Object.defineProperty(value, ReactiveFlags.SKIP, {\n value: true,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n return value\n}\n\n/**\n * 判断某个值是否被标记为原始(即不应转换为响应式)。\n *\n * @param value 待检测的值\n * @returns 若含有跳过标记则返回 true\n */\nexport function isRaw(value: unknown): boolean {\n return isObject(value) && ReactiveFlags.SKIP in (value as object)\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,mBAAmB,QAAgB;CACjD,MAAM,MAAM,MAAM,MAAa;CAC/B,OAAO,cAAc,GAAG;AAC1B;AAEA,SAAS,aAAa,QAAgB,KAAkB,IAAgB;;CACtE,IAAI,CAAC,kBAAkB,MACrB;CAEF,IAAI,OAAO,QAAQ,UACjB;CAEF,IAAI,IAAI,WAAW,MAAM,GACvB;CAEF,MAAM,0BAAO,WAAW,IAAI,MAAM,8DAAK;CAEvC,MAAM,OADU,MAAM,QAAQ,MACG,MAAM,QAAQ,YAAY,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AC5C,IAAI,eACF,OAAO;CAET,IAAI,cAAc,MAAM,SACtB,OAAO;CAET,MAAM,QAAQ,IAAI,MAAM,QAAQ,eAAe;CAC/C,YAAY,IAAI,QAAQ,KAAK;CAC7B,OAAO,IAAI,OAAO,MAAM;CACxB,IAAI,CAAC,cAAc,IAAI,MAAM,GAC3B,cAAc,IAAI,QAAQ,CAAC;CAG7B,IAAI,CAAC,WAAW,IAAI,MAAM,GACxB,WAAW,IAAI,QAAQ,MAAM;CAE/B,OAAO;AACT;AAEA,SAAgB,WAAW,OAAyB;CAClD,OAAO,QAAQ,SAAU,uBAAwC;AACnE;AAEA,SAAgB,kBAAqB,OAAa;CAChD,OAAO,SAAS,KAAK,IAAI,SAAS,KAAY,IAAI;AACpD;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,QAA0B,OAAa;CACrD,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,OAAO,eAAe,mBAA2B;EAC/C,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;CACZ,CAAC;CACD,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,OAAyB;CAC7C,OAAO,SAAS,KAAK,mBAA4B;AACnD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.mjs";
|
|
2
2
|
import { trackEffects, triggerEffects } from "./core.mjs";
|
|
3
3
|
import { convertToReactive, markRaw } from "./reactive.mjs";
|
|
4
4
|
|
|
@@ -54,13 +54,15 @@ function createRouter(options = {}) {
|
|
|
54
54
|
if (mergedRouteMeta !== void 0) resolved.meta = cloneRouteMeta(mergedRouteMeta);
|
|
55
55
|
if (matchedResult.params && Object.keys(resolved.params).length === 0) resolved.params = cloneRouteParams(matchedResult.params);
|
|
56
56
|
resolved.matched = matchedResult.matchedRecords.map((record, index, records) => {
|
|
57
|
-
|
|
57
|
+
const leafMatchedPath = index === records.length - 1 ? matchedResult.matchedPath : void 0;
|
|
58
|
+
return normalizeRouteRecordMatched(record, leafMatchedPath);
|
|
58
59
|
});
|
|
59
60
|
} else resolved.matched = [];
|
|
60
61
|
return resolved;
|
|
61
62
|
}
|
|
62
63
|
function resolveWithCodec(to, currentPath) {
|
|
63
|
-
|
|
64
|
+
const rawTo = typeof to === "string" ? to : resolveNamedRouteLocation(to, namedRouteLookup, paramsMode);
|
|
65
|
+
return enrichRouteRecordState(resolveRouteLocation(rawTo, currentPath, routeResolveCodec));
|
|
64
66
|
}
|
|
65
67
|
let route;
|
|
66
68
|
let emitObservedNavigationAfterEach;
|
|
@@ -69,9 +71,10 @@ function createRouter(options = {}) {
|
|
|
69
71
|
}
|
|
70
72
|
function beforeRouteStateSync(nextRoute, payload) {
|
|
71
73
|
if (managedNavigationCount > 0 || !isExternalBackSync(payload) || nextRoute.fullPath === route.fullPath) return;
|
|
74
|
+
const from = snapshotRouteLocation(route);
|
|
72
75
|
runBackNavigationGuards({
|
|
73
76
|
target: nextRoute,
|
|
74
|
-
from
|
|
77
|
+
from,
|
|
75
78
|
nativeRouter,
|
|
76
79
|
beforeEachGuards,
|
|
77
80
|
beforeResolveGuards,
|
|
@@ -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,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;CAC5D,MAAM,oDAA2B,QAAQ,sFAAiB,CAAC,EAAC,CACzD,KAAI,SAAQ,YAAY,MAAM,EAAE,CAAC,CAAC,CAClC,OAAO,OAAO;CACjB,MAAM,gBAAgB,IAAI,IAAI,uBAAuB;CACrD,MAAM,gBAAgB,oBAAoB,gBAAgB;CAC1D,IAAI,yBAAyB;CAC7B,MAAM,gBAAgB,4BACpB,yBACA,cAAc,UAAU,GACxB,YACA,cACA,mBACA,aACF;CAEA,SAAS,uBAAuB,eAA6E;EAC3G,MAAM,WAAW,EAAE,GAAG,cAAc;EACpC,SAAS,OAAO,SAAS;EACzB,MAAM,gBAAgB,0BAA0B,UAAU,gBAAgB;EAC1E,IAAI,eAAe;GACjB,MAAM,gBAAgB,cAAc;GACpC,IAAI,SA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],"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,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;CAC5D,MAAM,oDAA2B,QAAQ,sFAAiB,CAAC,EAAC,CACzD,KAAI,SAAQ,YAAY,MAAM,EAAE,CAAC,CAAC,CA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AAK,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"}
|
|
@@ -110,7 +110,8 @@ async function navigateWithTarget(options) {
|
|
|
110
110
|
if (isNavigationFailure(result)) return createNavigationRunResult(currentMode, from, currentTarget, result);
|
|
111
111
|
return createNavigationRunResult(currentMode, from, currentTarget);
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const nativeMethod = currentMode === "push" ? nativeRouter.navigateTo : nativeRouter.redirectTo;
|
|
114
|
+
const result = await executeNavigationMethod(nativeMethod, { url: createNativeRouteUrl(currentTarget, routeResolveCodec.stringifyQuery) }, currentTarget, from);
|
|
114
115
|
if (isNavigationFailure(result)) return createNavigationRunResult(currentMode, from, currentTarget, result);
|
|
115
116
|
return createNavigationRunResult(currentMode, from, currentTarget);
|
|
116
117
|
}
|
|
@@ -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,IAHmB,eACf,cAAc,SAAS,KAAK,OAC5B,cAAc,aAAa,KAAK,UAElC,OAAO,0BAA0B,aAAa,MAAM,eAAe,wBAAwB,eAAe,IAAI,CAAC;EAGjH,IAAI,gBAAgB,iBAAiB,cAAc,KAAK,GACtD,OA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ACA,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;EAKA,MAAM,SAAS,MAAM,wBAHA,gBAAgB,SACjC,aAAa,aACb,aAAa,YAGf,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}\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,IAHmB,eACf,cAAc,SAAS,KAAK,OAC5B,cAAc,aAAa,KAAK,UAElC,OAAO,0BAA0B,aAAa,MAAM,eAAe,wBAAwB,eAAe,IAAI,CAAC;EAGjH,IAAI,gBAAgB,iBAAiB,cAAc,KAAK,GACtD,OAAO,0BAA0B,aAAa,MAAM,eAAe,yBAAyB,eAAe,IAAI,CAAC;EAGlH,MAAM,mBAAmB,MAAM,oBAAoB,kBAAkB;GACnE,MAAM;GACN,IAAI;GACJ;GACc;EAChB,GAAG,gBAAgB;EAEnB,IAAI,iBAAiB,WAAW,WAC9B,OAAO,0BAA0B,aAAa,MAAM,eAAe,iBAAiB,OAAO;EAE7F,IAAI,iBAAiB,WAAW,YAAY;GAC1C,MAAM,mBAAmB,iBAAi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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"}
|
|
@@ -11,10 +11,17 @@ function resolveRouteLocation(to, currentPath = "", codec = DEFAULT_ROUTE_RESOLV
|
|
|
11
11
|
var _ref, _to$path, _parsedFromFullPath$q, _to$hash;
|
|
12
12
|
if (typeof to === "string") {
|
|
13
13
|
const parsed = parsePathInput(to, codec);
|
|
14
|
-
|
|
14
|
+
const path = resolvePath(parsed.path, currentPath);
|
|
15
|
+
return createRouteLocation(path, parsed.query, parsed.hash, void 0, {}, codec.stringifyQuery);
|
|
15
16
|
}
|
|
16
17
|
const parsedFromFullPath = typeof to.fullPath === "string" ? parsePathInput(to.fullPath, codec) : void 0;
|
|
17
|
-
|
|
18
|
+
const rawPath = (_ref = (_to$path = to.path) !== null && _to$path !== void 0 ? _to$path : parsedFromFullPath === null || parsedFromFullPath === void 0 ? void 0 : parsedFromFullPath.path) !== null && _ref !== void 0 ? _ref : currentPath;
|
|
19
|
+
const path = resolvePath(rawPath, currentPath);
|
|
20
|
+
const query = to.query ? normalizeQuery(to.query) : (_parsedFromFullPath$q = parsedFromFullPath === null || parsedFromFullPath === void 0 ? void 0 : parsedFromFullPath.query) !== null && _parsedFromFullPath$q !== void 0 ? _parsedFromFullPath$q : {};
|
|
21
|
+
const hash = normalizeHash((_to$hash = to.hash) !== null && _to$hash !== void 0 ? _to$hash : parsedFromFullPath === null || parsedFromFullPath === void 0 ? void 0 : parsedFromFullPath.hash);
|
|
22
|
+
const name = typeof to.name === "string" ? to.name : void 0;
|
|
23
|
+
const params = to.params ? normalizeRouteParams(to.params) : {};
|
|
24
|
+
return createRouteLocation(path, query, hash, name, params, codec.stringifyQuery);
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../../src/router/resolve.ts"],"sourcesContent":["import type { RouteResolveCodec } from '../routerInternal/shared'\nimport type { RouteLocationNormalizedLoaded, RouteLocationRaw } from './types'\nimport {\n createRouteLocation,\n normalizeHash,\n normalizeQuery,\n normalizeRouteParams,\n parsePathInput,\n parseQuery,\n resolvePath,\n stringifyQuery,\n} from '../routerInternal/shared'\n\nexport const DEFAULT_ROUTE_RESOLVE_CODEC: RouteResolveCodec = {\n parseQuery,\n stringifyQuery,\n}\n\nexport function resolveRouteLocation(\n to: RouteLocationRaw,\n currentPath = '',\n codec: RouteResolveCodec = DEFAULT_ROUTE_RESOLVE_CODEC,\n): RouteLocationNormalizedLoaded {\n if (typeof to === 'string') {\n const parsed = parsePathInput(to, codec)\n const path = resolvePath(parsed.path, currentPath)\n return createRouteLocation(path, parsed.query, parsed.hash, undefined, {}, codec.stringifyQuery)\n }\n\n const parsedFromFullPath = typeof to.fullPath === 'string'\n ? parsePathInput(to.fullPath, codec)\n : undefined\n\n const rawPath = to.path ?? parsedFromFullPath?.path ?? currentPath\n const path = resolvePath(rawPath, currentPath)\n const query = to.query\n ? normalizeQuery(to.query)\n : parsedFromFullPath?.query ?? {}\n const hash = normalizeHash(to.hash ?? parsedFromFullPath?.hash)\n const name = typeof to.name === 'string' ? to.name : undefined\n const params = to.params\n ? normalizeRouteParams(to.params)\n : {}\n\n return createRouteLocation(path, query, hash, name, params, codec.stringifyQuery)\n}\n"],"mappings":";;;;;AAaA,MAAa,8BAAiD;CAC5D;CACA;AACF;AAEA,SAAgB,qBACd,IACA,cAAc,IACd,QAA2B,6BACI;;CAC/B,IAAI,OAAO,OAAO,UAAU;EAC1B,MAAM,SAAS,eAAe,IAAI,KAAK;
|
|
1
|
+
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../../src/router/resolve.ts"],"sourcesContent":["import type { RouteResolveCodec } from '../routerInternal/shared'\nimport type { RouteLocationNormalizedLoaded, RouteLocationRaw } from './types'\nimport {\n createRouteLocation,\n normalizeHash,\n normalizeQuery,\n normalizeRouteParams,\n parsePathInput,\n parseQuery,\n resolvePath,\n stringifyQuery,\n} from '../routerInternal/shared'\n\nexport const DEFAULT_ROUTE_RESOLVE_CODEC: RouteResolveCodec = {\n parseQuery,\n stringifyQuery,\n}\n\nexport function resolveRouteLocation(\n to: RouteLocationRaw,\n currentPath = '',\n codec: RouteResolveCodec = DEFAULT_ROUTE_RESOLVE_CODEC,\n): RouteLocationNormalizedLoaded {\n if (typeof to === 'string') {\n const parsed = parsePathInput(to, codec)\n const path = resolvePath(parsed.path, currentPath)\n return createRouteLocation(path, parsed.query, parsed.hash, undefined, {}, codec.stringifyQuery)\n }\n\n const parsedFromFullPath = typeof to.fullPath === 'string'\n ? parsePathInput(to.fullPath, codec)\n : undefined\n\n const rawPath = to.path ?? parsedFromFullPath?.path ?? currentPath\n const path = resolvePath(rawPath, currentPath)\n const query = to.query\n ? normalizeQuery(to.query)\n : parsedFromFullPath?.query ?? {}\n const hash = normalizeHash(to.hash ?? parsedFromFullPath?.hash)\n const name = typeof to.name === 'string' ? to.name : undefined\n const params = to.params\n ? normalizeRouteParams(to.params)\n : {}\n\n return createRouteLocation(path, query, hash, name, params, codec.stringifyQuery)\n}\n"],"mappings":";;;;;AAaA,MAAa,8BAAiD;CAC5D;CACA;AACF;AAEA,SAAgB,qBACd,IACA,cAAc,IACd,QAA2B,6BACI;;CAC/B,IAAI,OAAO,OAAO,UAAU;EAC1B,MAAM,SAAS,eAAe,IAAI,KAAK;EACvC,MAAM,OAAO,YAAY,OAAO,MAAM,WAAW;EACjD,OAAO,oBAAoB,MAAM,OAAO,OAAO,OAAO,MAAM,QAAW,CAAC,GAAG,MAAM,cAAc;CACjG;CAEA,MAAM,qBAAqB,OAAO,GAAG,aAAa,WAC9C,eAAe,GAAG,UAAU,KAAK,IACjC;CAEJ,MAAM,8BAAU,GAAG,2HAAQ,mBAAoB,2CAAQ;CACvD,MAAM,OAAO,YAAY,SAAS,WAAW;CAC7C,MAAM,QAAQ,GAAG,QACb,eAAe,GAAG,KAAK,qGACvB,mBAAoB,8EAAS,CAAC;CAClC,MAAM,OAAO,0BAAc,GAAG,2HAAQ,mBAAoB,IAAI;CAC9D,MAAM,OAAO,OAAO,GAAG,SAAS,WAAW,GAAG,OAAO;CACrD,MAAM,SAAS,GAAG,SACd,qBAAqB,GAAG,MAAM,IAC9B,CAAC;CAEL,OAAO,oBAAoB,MAAM,OAAO,MAAM,MAAM,QAAQ,MAAM,cAAc;AAClF"}
|
|
@@ -55,7 +55,9 @@ function getCurrentMiniProgramPage(fallbackPage) {
|
|
|
55
55
|
function resolvePageRoute(page, queryOverride) {
|
|
56
56
|
var _page$options;
|
|
57
57
|
if (!page) return createRouteLocation("", {});
|
|
58
|
-
|
|
58
|
+
const rawPath = typeof page.route === "string" ? page.route : typeof page.__route__ === "string" ? page.__route__ : "";
|
|
59
|
+
const querySource = queryOverride !== null && queryOverride !== void 0 ? queryOverride : (_page$options = page.options) !== null && _page$options !== void 0 ? _page$options : {};
|
|
60
|
+
return createRouteLocation(rawPath, normalizeQuery(querySource), "", void 0, {});
|
|
59
61
|
}
|
|
60
62
|
function resolveCurrentRoute(queryOverride, fallbackPage) {
|
|
61
63
|
return resolvePageRoute(getCurrentMiniProgramPage(fallbackPage), queryOverride);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.mjs","names":[],"sources":["../../../src/routerInternal/location.ts"],"sourcesContent":["import type {\n LocationQuery,\n LocationQueryRaw,\n RouteLocationNormalizedLoaded,\n RouteParams,\n RouteQueryStringifier,\n} from '../router'\nimport type { MiniProgramPageLike, RouteResolveCodec } from './types'\nimport { getCurrentMiniProgramPages } from '../runtime/platform'\nimport { getCurrentPageInstance } from '../runtime/register/component/lifecycle/platform'\nimport { createAbsoluteRoutePath, resolvePath } from './path'\nimport { normalizeHash, normalizeQuery, parseQuery, stringifyQuery } from './query'\n\nconst DEFAULT_ROUTE_RESOLVE_CODEC: RouteResolveCodec = {\n parseQuery,\n stringifyQuery,\n}\n\nexport function parsePathInput(\n input: string,\n codec: RouteResolveCodec = DEFAULT_ROUTE_RESOLVE_CODEC,\n): { path: string, query: LocationQuery, hash: string } {\n const hashIndex = input.indexOf('#')\n const withoutHash = hashIndex >= 0 ? input.slice(0, hashIndex) : input\n const hash = hashIndex >= 0 ? normalizeHash(input.slice(hashIndex + 1)) : ''\n const queryIndex = withoutHash.indexOf('?')\n\n if (queryIndex < 0) {\n return {\n path: withoutHash,\n query: {},\n hash,\n }\n }\n\n return {\n path: withoutHash.slice(0, queryIndex),\n query: normalizeQuery(codec.parseQuery(withoutHash.slice(queryIndex + 1))),\n hash,\n }\n}\n\nexport function createRouteLocation(\n path: string,\n query: LocationQuery,\n hash = '',\n name?: string,\n params: RouteParams = {},\n queryStringifier: RouteQueryStringifier = stringifyQuery,\n): RouteLocationNormalizedLoaded {\n const normalizedPath = resolvePath(path, '')\n const queryString = queryStringifier(query)\n const fullPathBase = createAbsoluteRoutePath(normalizedPath)\n const normalizedHash = normalizeHash(hash)\n const fullPath = queryString ? `${fullPathBase}?${queryString}` : fullPathBase\n const location: RouteLocationNormalizedLoaded = {\n path: normalizedPath,\n fullPath: normalizedHash ? `${fullPath}${normalizedHash}` : fullPath,\n query,\n hash: normalizedHash,\n params,\n }\n if (name !== undefined) {\n location.name = name\n }\n\n return location\n}\n\nfunction hasPageRoute(page: MiniProgramPageLike | undefined): page is MiniProgramPageLike {\n return (typeof page?.route === 'string' && page.route.length > 0)\n || (typeof page?.__route__ === 'string' && page.__route__.length > 0)\n}\n\nfunction getCurrentMiniProgramPage(fallbackPage?: MiniProgramPageLike): MiniProgramPageLike | undefined {\n const pages = getCurrentMiniProgramPages() as MiniProgramPageLike[]\n if (Array.isArray(pages) && pages.length > 0) {\n const currentPage = pages[pages.length - 1]\n if (hasPageRoute(currentPage)) {\n return currentPage\n }\n }\n\n const currentPageInstance = getCurrentPageInstance() as MiniProgramPageLike | undefined\n return hasPageRoute(currentPageInstance) ? currentPageInstance : fallbackPage\n}\n\nexport function resolvePageRoute(\n page: MiniProgramPageLike | undefined,\n queryOverride?: LocationQueryRaw,\n): RouteLocationNormalizedLoaded {\n if (!page) {\n return createRouteLocation('', {})\n }\n\n const rawPath = typeof page.route === 'string'\n ? page.route\n : typeof page.__route__ === 'string'\n ? page.__route__\n : ''\n\n const querySource = queryOverride ?? ((page.options ?? {}) as LocationQueryRaw)\n const query = normalizeQuery(querySource)\n return createRouteLocation(rawPath, query, '', undefined, {})\n}\n\nexport function resolveCurrentRoute(\n queryOverride?: LocationQueryRaw,\n fallbackPage?: MiniProgramPageLike,\n): RouteLocationNormalizedLoaded {\n const currentPage = getCurrentMiniProgramPage(fallbackPage)\n return resolvePageRoute(currentPage, queryOverride)\n}\n"],"mappings":";;;;;;AAaA,MAAM,8BAAiD;CACrD;CACA;AACF;AAEA,SAAgB,eACd,OACA,QAA2B,6BAC2B;CACtD,MAAM,YAAY,MAAM,QAAQ,GAAG;CACnC,MAAM,cAAc,aAAa,IAAI,MAAM,MAAM,GAAG,SAAS,IAAI;CACjE,MAAM,OAAO,aAAa,IAAI,cAAc,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;CAC1E,MAAM,aAAa,YAAY,QAAQ,GAAG;CAE1C,IAAI,aAAa,GACf,OAAO;EACL,MAAM;EACN,OAAO,CAAC;EACR;CACF;CAGF,OAAO;EACL,MAAM,YAAY,MAAM,GAAG,UAAU;EACrC,OAAO,eAAe,MAAM,WAAW,YAAY,MAAM,aAAa,CAAC,CAAC,CAAC;EACzE;CACF;AACF;AAEA,SAAgB,oBACd,MACA,OACA,OAAO,IACP,MACA,SAAsB,CAAC,GACvB,mBAA0C,gBACX;CAC/B,MAAM,iBAAiB,YAAY,MAAM,EAAE;CAC3C,MAAM,cAAc,iBAAiB,KAAK;CAC1C,MAAM,eAAe,wBAAwB,cAAc;CAC3D,MAAM,iBAAiB,cAAc,IAAI;CACzC,MAAM,WAAW,cAAc,GAAG,aAAa,GAAG,gBAAgB;CAClE,MAAM,WAA0C;EAC9C,MAAM;EACN,UAAU,iBAAiB,GAAG,WAAW,mBAAmB;EAC5D;EACA,MAAM;EACN;CACF;CACA,IAAI,SAAS,QACX,SAAS,OAAO;CAGlB,OAAO;AACT;AAEA,SAAS,aAAa,MAAoE;CACxF,OAAQ,oDAAO,KAAM,WAAU,YAAY,KAAK,MAAM,SAAS,KACzD,oDAAO,KAAM,eAAc,YAAY,KAAK,UAAU,SAAS;AACvE;AAEA,SAAS,0BAA0B,cAAqE;CACtG,MAAM,QAAQ,2BAA2B;CACzC,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,GAAG;EAC5C,MAAM,cAAc,MAAM,MAAM,SAAS;EACzC,IAAI,aAAa,WAAW,GAC1B,OAAO;CAEX;CAEA,MAAM,sBAAsB,uBAAuB;CACnD,OAAO,aAAa,mBAAmB,IAAI,sBAAsB;AACnE;AAEA,SAAgB,iBACd,MACA,eAC+B;;CAC/B,IAAI,CAAC,MACH,OAAO,oBAAoB,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"location.mjs","names":[],"sources":["../../../src/routerInternal/location.ts"],"sourcesContent":["import type {\n LocationQuery,\n LocationQueryRaw,\n RouteLocationNormalizedLoaded,\n RouteParams,\n RouteQueryStringifier,\n} from '../router'\nimport type { MiniProgramPageLike, RouteResolveCodec } from './types'\nimport { getCurrentMiniProgramPages } from '../runtime/platform'\nimport { getCurrentPageInstance } from '../runtime/register/component/lifecycle/platform'\nimport { createAbsoluteRoutePath, resolvePath } from './path'\nimport { normalizeHash, normalizeQuery, parseQuery, stringifyQuery } from './query'\n\nconst DEFAULT_ROUTE_RESOLVE_CODEC: RouteResolveCodec = {\n parseQuery,\n stringifyQuery,\n}\n\nexport function parsePathInput(\n input: string,\n codec: RouteResolveCodec = DEFAULT_ROUTE_RESOLVE_CODEC,\n): { path: string, query: LocationQuery, hash: string } {\n const hashIndex = input.indexOf('#')\n const withoutHash = hashIndex >= 0 ? input.slice(0, hashIndex) : input\n const hash = hashIndex >= 0 ? normalizeHash(input.slice(hashIndex + 1)) : ''\n const queryIndex = withoutHash.indexOf('?')\n\n if (queryIndex < 0) {\n return {\n path: withoutHash,\n query: {},\n hash,\n }\n }\n\n return {\n path: withoutHash.slice(0, queryIndex),\n query: normalizeQuery(codec.parseQuery(withoutHash.slice(queryIndex + 1))),\n hash,\n }\n}\n\nexport function createRouteLocation(\n path: string,\n query: LocationQuery,\n hash = '',\n name?: string,\n params: RouteParams = {},\n queryStringifier: RouteQueryStringifier = stringifyQuery,\n): RouteLocationNormalizedLoaded {\n const normalizedPath = resolvePath(path, '')\n const queryString = queryStringifier(query)\n const fullPathBase = createAbsoluteRoutePath(normalizedPath)\n const normalizedHash = normalizeHash(hash)\n const fullPath = queryString ? `${fullPathBase}?${queryString}` : fullPathBase\n const location: RouteLocationNormalizedLoaded = {\n path: normalizedPath,\n fullPath: normalizedHash ? `${fullPath}${normalizedHash}` : fullPath,\n query,\n hash: normalizedHash,\n params,\n }\n if (name !== undefined) {\n location.name = name\n }\n\n return location\n}\n\nfunction hasPageRoute(page: MiniProgramPageLike | undefined): page is MiniProgramPageLike {\n return (typeof page?.route === 'string' && page.route.length > 0)\n || (typeof page?.__route__ === 'string' && page.__route__.length > 0)\n}\n\nfunction getCurrentMiniProgramPage(fallbackPage?: MiniProgramPageLike): MiniProgramPageLike | undefined {\n const pages = getCurrentMiniProgramPages() as MiniProgramPageLike[]\n if (Array.isArray(pages) && pages.length > 0) {\n const currentPage = pages[pages.length - 1]\n if (hasPageRoute(currentPage)) {\n return currentPage\n }\n }\n\n const currentPageInstance = getCurrentPageInstance() as MiniProgramPageLike | undefined\n return hasPageRoute(currentPageInstance) ? currentPageInstance : fallbackPage\n}\n\nexport function resolvePageRoute(\n page: MiniProgramPageLike | undefined,\n queryOverride?: LocationQueryRaw,\n): RouteLocationNormalizedLoaded {\n if (!page) {\n return createRouteLocation('', {})\n }\n\n const rawPath = typeof page.route === 'string'\n ? page.route\n : typeof page.__route__ === 'string'\n ? page.__route__\n : ''\n\n const querySource = queryOverride ?? ((page.options ?? {}) as LocationQueryRaw)\n const query = normalizeQuery(querySource)\n return createRouteLocation(rawPath, query, '', undefined, {})\n}\n\nexport function resolveCurrentRoute(\n queryOverride?: LocationQueryRaw,\n fallbackPage?: MiniProgramPageLike,\n): RouteLocationNormalizedLoaded {\n const currentPage = getCurrentMiniProgramPage(fallbackPage)\n return resolvePageRoute(currentPage, queryOverride)\n}\n"],"mappings":";;;;;;AAaA,MAAM,8BAAiD;CACrD;CACA;AACF;AAEA,SAAgB,eACd,OACA,QAA2B,6BAC2B;CACtD,MAAM,YAAY,MAAM,QAAQ,GAAG;CACnC,MAAM,cAAc,aAAa,IAAI,MAAM,MAAM,GAAG,SAAS,IAAI;CACjE,MAAM,OAAO,aAAa,IAAI,cAAc,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;CAC1E,MAAM,aAAa,YAAY,QAAQ,GAAG;CAE1C,IAAI,aAAa,GACf,OAAO;EACL,MAAM;EACN,OAAO,CAAC;EACR;CACF;CAGF,OAAO;EACL,MAAM,YAAY,MAAM,GAAG,UAAU;EACrC,OAAO,eAAe,MAAM,WAAW,YAAY,MAAM,aAAa,CAAC,CAAC,CAAC;EACzE;CACF;AACF;AAEA,SAAgB,oBACd,MACA,OACA,OAAO,IACP,MACA,SAAsB,CAAC,GACvB,mBAA0C,gBACX;CAC/B,MAAM,iBAAiB,YAAY,MAAM,EAAE;CAC3C,MAAM,cAAc,iBAAiB,KAAK;CAC1C,MAAM,eAAe,wBAAwB,cAAc;CAC3D,MAAM,iBAAiB,cAAc,IAAI;CACzC,MAAM,WAAW,cAAc,GAAG,aAAa,GAAG,gBAAgB;CAClE,MAAM,WAA0C;EAC9C,MAAM;EACN,UAAU,iBAAiB,GAAG,WAAW,mBAAmB;EAC5D;EACA,MAAM;EACN;CACF;CACA,IAAI,SAAS,QACX,SAAS,OAAO;CAGlB,OAAO;AACT;AAEA,SAAS,aAAa,MAAoE;CACxF,OAAQ,oDAAO,KAAM,WAAU,YAAY,KAAK,MAAM,SAAS,KACzD,oDAAO,KAAM,eAAc,YAAY,KAAK,UAAU,SAAS;AACvE;AAEA,SAAS,0BAA0B,cAAqE;CACtG,MAAM,QAAQ,2BAA2B;CACzC,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,GAAG;EAC5C,MAAM,cAAc,MAAM,MAAM,SAAS;EACzC,IAAI,aAAa,WAAW,GAC1B,OAAO;CAEX;CAEA,MAAM,sBAAsB,uBAAuB;CACnD,OAAO,aAAa,mBAAmB,IAAI,sBAAsB;AACnE;AAEA,SAAgB,iBACd,MACA,eAC+B;;CAC/B,IAAI,CAAC,MACH,OAAO,oBAAoB,IAAI,CAAC,CAAC;CAGnC,MAAM,UAAU,OAAO,KAAK,UAAU,WAClC,KAAK,QACL,OAAO,KAAK,cAAc,WACxB,KAAK,YACL;CAEN,MAAM,cAAc,sFAAmB,KAAK,gEAAW,CAAC;CAExD,OAAO,oBAAoB,SADb,eAAe,WACW,GAAG,IAAI,QAAW,CAAC,CAAC;AAC9D;AAEA,SAAgB,oBACd,eACA,cAC+B;CAE/B,OAAO,iBADa,0BAA0B,YACZ,GAAG,aAAa;AACpD"}
|
|
@@ -70,7 +70,8 @@ function flattenNamedRouteRecords(records, parentPath, parentName, parentAliasPa
|
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
if (typeof record.path !== "string" || !record.path) {
|
|
73
|
-
|
|
73
|
+
const routeName = typeof (record === null || record === void 0 ? void 0 : record.name) === "string" ? record.name.trim() : "";
|
|
74
|
+
warnRouteConfig(`ignored route record "${routeName}" at ${routeConfigPath}: route path is required`);
|
|
74
75
|
continue;
|
|
75
76
|
}
|
|
76
77
|
const normalizedPath = normalizeNestedRoutePath(record.path, parentPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.mjs","names":[],"sources":["../../../src/routerInternal/records.ts"],"sourcesContent":["import type {\n NamedRoutes,\n NavigationGuard,\n RouteRecordInput,\n RouteRecordRaw,\n UseRouterOptions,\n} from '../router'\nimport type {\n FlattenedRouteRecordSeed,\n NamedRouteLookup,\n RouteOptionSource,\n RouteRecordNormalized,\n} from './types'\nimport { createAbsoluteRoutePath, isDynamicRoutePath, resolvePath } from './path'\nimport { warnRouteConfig } from './recordsWarnings'\n\nfunction normalizeBeforeEnterGuards(beforeEnter?: RouteRecordRaw['beforeEnter']): readonly NavigationGuard[] {\n if (!beforeEnter) {\n return []\n }\n if (Array.isArray(beforeEnter)) {\n return beforeEnter as readonly NavigationGuard[]\n }\n return [beforeEnter as NavigationGuard]\n}\n\nfunction resolveRouteRecordName(\n route: RouteRecordInput,\n normalizedPath: string,\n source: RouteOptionSource = 'namedRoutes',\n): string {\n if (typeof route.name === 'string' && route.name.trim()) {\n return route.name.trim()\n }\n\n if (source === 'routes') {\n return normalizedPath || '/'\n }\n\n return ''\n}\n\nfunction normalizeRouteRecordAliasPaths(\n alias: RouteRecordRaw['alias'],\n normalizedPath: string,\n): readonly string[] {\n if (!alias) {\n return []\n }\n const aliasList = Array.isArray(alias)\n ? alias\n : [alias]\n\n const normalizedAliasPaths: string[] = []\n for (const aliasPath of aliasList) {\n if (typeof aliasPath !== 'string') {\n continue\n }\n const normalizedAliasPath = resolvePath(aliasPath, '')\n if (!normalizedAliasPath || normalizedAliasPath === normalizedPath) {\n continue\n }\n if (!normalizedAliasPaths.includes(normalizedAliasPath)) {\n normalizedAliasPaths.push(normalizedAliasPath)\n }\n }\n\n return normalizedAliasPaths\n}\n\nexport function normalizeRouteRecordRaw(\n route: RouteRecordInput,\n parentName?: string,\n source: RouteOptionSource = 'namedRoutes',\n): RouteRecordNormalized | undefined {\n const normalizedPath = resolvePath(route.path, '')\n if (!normalizedPath && route.path !== '/') {\n return undefined\n }\n\n const routeName = resolveRouteRecordName(route, normalizedPath, source)\n if (!routeName) {\n return undefined\n }\n const aliasPaths = normalizeRouteRecordAliasPaths(route.alias, normalizedPath)\n\n return {\n name: routeName,\n path: normalizedPath,\n aliasPaths,\n parentName,\n meta: route.meta,\n beforeEnterGuards: normalizeBeforeEnterGuards(route.beforeEnter),\n redirect: route.redirect,\n }\n}\n\nfunction normalizeNestedRoutePath(path: string, parentPath?: string): string {\n if (!parentPath || path.startsWith('/')) {\n return resolvePath(path, '')\n }\n return resolvePath(`${createAbsoluteRoutePath(parentPath)}/${path}`, '')\n}\n\nfunction normalizeAliasInputList(alias: RouteRecordRaw['alias']): string[] {\n if (!alias) {\n return []\n }\n if (Array.isArray(alias)) {\n return alias.filter((item): item is string => typeof item === 'string' && item.length > 0)\n }\n return typeof alias === 'string' && alias.length > 0\n ? [alias]\n : []\n}\n\nfunction mergeAliasPaths(aliasPaths: readonly string[]): string[] {\n const mergedAliasPaths: string[] = []\n for (const aliasPath of aliasPaths) {\n if (!aliasPath || mergedAliasPaths.includes(aliasPath)) {\n continue\n }\n mergedAliasPaths.push(aliasPath)\n }\n return mergedAliasPaths\n}\n\nexport function createRouteRecordAliasValue(aliasPaths: readonly string[]): RouteRecordRaw['alias'] {\n if (aliasPaths.length === 0) {\n return undefined\n }\n if (aliasPaths.length === 1) {\n return createAbsoluteRoutePath(aliasPaths[0])\n }\n return aliasPaths.map(aliasPath => createAbsoluteRoutePath(aliasPath))\n}\n\nexport function flattenNamedRouteRecords(\n records: readonly RouteRecordInput[],\n parentPath?: string,\n parentName?: string,\n parentAliasPaths: readonly string[] = [],\n source?: RouteOptionSource,\n pathPrefix = 'namedRoutes',\n ancestorRecords: ReadonlySet<RouteRecordInput> = new Set<RouteRecordInput>(),\n): FlattenedRouteRecordSeed[] {\n const flattenedRecords: FlattenedRouteRecordSeed[] = []\n\n for (const [index, record] of records.entries()) {\n const routeConfigPath = `${pathPrefix}[${index}]`\n if (ancestorRecords.has(record)) {\n warnRouteConfig(`ignored route record at ${routeConfigPath}: detected circular children reference`)\n continue\n }\n\n if (typeof record.path !== 'string' || !record.path) {\n const routeName = typeof record?.name === 'string'\n ? record.name.trim()\n : ''\n warnRouteConfig(`ignored route record \"${routeName}\" at ${routeConfigPath}: route path is required`)\n continue\n }\n\n const normalizedPath = normalizeNestedRoutePath(record.path, parentPath)\n const routeName = resolveRouteRecordName(record, normalizedPath, source)\n if (!routeName) {\n warnRouteConfig(`ignored route record at ${routeConfigPath}: route name is required`)\n continue\n }\n const normalizedDirectAliasPaths: string[] = []\n const directAliasByNormalizedPath = new Map<string, string>()\n for (const rawAliasPath of normalizeAliasInputList(record.alias)) {\n const normalizedAliasPath = normalizeNestedRoutePath(rawAliasPath, parentPath)\n if (!normalizedAliasPath) {\n continue\n }\n if (normalizedAliasPath === normalizedPath) {\n warnRouteConfig(`ignored alias \"${createAbsoluteRoutePath(normalizedAliasPath)}\" for route \"${routeName}\" at ${routeConfigPath}: alias is same as route path`)\n continue\n }\n\n const duplicateAliasPath = directAliasByNormalizedPath.get(normalizedAliasPath)\n if (duplicateAliasPath) {\n warnRouteConfig(\n `ignored duplicate alias \"${createAbsoluteRoutePath(normalizedAliasPath)}\" for route \"${routeName}\" at ${routeConfigPath}: already declared by \"${duplicateAliasPath}\"`,\n )\n continue\n }\n\n directAliasByNormalizedPath.set(normalizedAliasPath, rawAliasPath)\n normalizedDirectAliasPaths.push(normalizedAliasPath)\n }\n const normalizedInheritedAliasPaths = record.path.startsWith('/')\n ? []\n : parentAliasPaths\n .map(parentAliasPath => normalizeNestedRoutePath(record.path, parentAliasPath))\n .filter(Boolean)\n .filter(aliasPath => aliasPath !== normalizedPath)\n const normalizedAliasPaths = mergeAliasPaths([\n ...normalizedDirectAliasPaths,\n ...normalizedInheritedAliasPaths,\n ])\n const normalizedRecord: RouteRecordRaw = {\n name: routeName,\n path: normalizedPath ? createAbsoluteRoutePath(normalizedPath) : '/',\n alias: createRouteRecordAliasValue(normalizedAliasPaths),\n meta: record.meta,\n beforeEnter: record.beforeEnter,\n redirect: record.redirect,\n }\n flattenedRecords.push({\n route: normalizedRecord,\n parentName,\n source,\n })\n\n if (Array.isArray(record.children) && record.children.length > 0) {\n const nextAncestorRecords = new Set(ancestorRecords)\n nextAncestorRecords.add(record)\n flattenedRecords.push(\n ...flattenNamedRouteRecords(\n record.children,\n normalizedPath,\n routeName,\n normalizedAliasPaths,\n source,\n `${routeConfigPath}.children`,\n nextAncestorRecords,\n ),\n )\n }\n }\n\n return flattenedRecords\n}\n\nfunction normalizeNamedRouteEntries(\n namedRoutes?: NamedRoutes | readonly RouteRecordInput[],\n source: RouteOptionSource = 'namedRoutes',\n): FlattenedRouteRecordSeed[] {\n if (!namedRoutes) {\n return []\n }\n\n if (Array.isArray(namedRoutes)) {\n return flattenNamedRouteRecords(namedRoutes, undefined, undefined, [], source, source)\n }\n\n const normalizedEntries: FlattenedRouteRecordSeed[] = []\n for (const [rawName, rawPath] of Object.entries(namedRoutes)) {\n const routeName = typeof rawName === 'string'\n ? rawName.trim()\n : ''\n if (!routeName) {\n warnRouteConfig(`ignored route record at ${source}: route name is required`)\n continue\n }\n if (typeof rawPath !== 'string' || !rawPath) {\n warnRouteConfig(`ignored route record \"${routeName}\" at ${source}: route path is required`)\n continue\n }\n normalizedEntries.push({\n route: {\n name: routeName,\n path: rawPath,\n },\n source,\n })\n }\n\n return normalizedEntries\n}\n\nexport function resolveRouteOptionEntries(options: UseRouterOptions): FlattenedRouteRecordSeed[] {\n return [\n ...normalizeNamedRouteEntries(options.routes, 'routes'),\n ...normalizeNamedRouteEntries(options.namedRoutes, 'namedRoutes'),\n ]\n}\n\nexport function createNamedRouteNameByStaticPath(recordByName: ReadonlyMap<string, RouteRecordNormalized>): Map<string, string> {\n const nameByStaticPath = new Map<string, string>()\n for (const [name, record] of recordByName.entries()) {\n if (!isDynamicRoutePath(record.path) && !nameByStaticPath.has(record.path)) {\n nameByStaticPath.set(record.path, name)\n }\n for (const aliasPath of record.aliasPaths) {\n if (!isDynamicRoutePath(aliasPath) && !nameByStaticPath.has(aliasPath)) {\n nameByStaticPath.set(aliasPath, name)\n }\n }\n }\n return nameByStaticPath\n}\n\nexport function createNamedRouteLookup(routeEntries: readonly FlattenedRouteRecordSeed[]): NamedRouteLookup {\n const recordByName = new Map<string, RouteRecordNormalized>()\n\n for (const routeRecord of routeEntries) {\n const normalizedRecord = normalizeRouteRecordRaw(\n routeRecord.route,\n routeRecord.parentName,\n routeRecord.source,\n )\n if (!normalizedRecord) {\n continue\n }\n recordByName.set(normalizedRecord.name, normalizedRecord)\n }\n\n return {\n recordByName,\n nameByStaticPath: createNamedRouteNameByStaticPath(recordByName),\n }\n}\n"],"mappings":";;;;AAgBA,SAAS,2BAA2B,aAAyE;CAC3G,IAAI,CAAC,aACH,OAAO,CAAC;CAEV,IAAI,MAAM,QAAQ,WAAW,GAC3B,OAAO;CAET,OAAO,CAAC,WAA8B;AACxC;AAEA,SAAS,uBACP,OACA,gBACA,SAA4B,eACpB;CACR,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,KAAK,GACpD,OAAO,MAAM,KAAK,KAAK;CAGzB,IAAI,WAAW,UACb,OAAO,kBAAkB;CAG3B,OAAO;AACT;AAEA,SAAS,+BACP,OACA,gBACmB;CACnB,IAAI,CAAC,OACH,OAAO,CAAC;CAEV,MAAM,YAAY,MAAM,QAAQ,KAAK,IACjC,QACA,CAAC,KAAK;CAEV,MAAM,uBAAiC,CAAC;CACxC,KAAK,MAAM,aAAa,WAAW;EACjC,IAAI,OAAO,cAAc,UACvB;EAEF,MAAM,sBAAsB,YAAY,WAAW,EAAE;EACrD,IAAI,CAAC,uBAAuB,wBAAwB,gBAClD;EAEF,IAAI,CAAC,qBAAqB,SAAS,mBAAmB,GACpD,qBAAqB,KAAK,mBAAmB;CAEjD;CAEA,OAAO;AACT;AAEA,SAAgB,wBACd,OACA,YACA,SAA4B,eACO;CACnC,MAAM,iBAAiB,Y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SAAgB,iCAAiC,cAA+E;CAC9H,MAAM,mCAAmB,IAAI,IAAoB;CACjD,KAAK,MAAM,CAAC,MAAM,WAAW,aAAa,QAAQ,GAAG;EACnD,IAAI,CAAC,mBAAmB,OAAO,IAAI,KAAK,CAAC,iBAAiB,IAAI,OAAO,IAAI,GACvE,iBAAiB,IAAI,OAAO,MAAM,IAAI;EAExC,KAAK,MAAM,aAAa,OAAO,YAC7B,IAAI,CAAC,mBAAmB,SAAS,KAAK,CAAC,iBAAiB,IAAI,SAAS,GACnE,iBAAiB,IAAI,WAAW,IAAI;CAG1C;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,cAAqE;CAC1G,MAAM,+BAAe,IAAI,IAAmC;CAE5D,KAAK,MAAM,eAAe,cAAc;EACtC,MAAM,mBAAmB,wBACvB,YAAY,OACZ,YAAY,YACZ,YAAY,MACd;EACA,IAAI,CAAC,kBACH;EAEF,aAAa,IAAI,iBAAiB,MAAM,gBAAgB;CAC1D;CAEA,OAAO;EACL;EACA,kBAAkB,iCAAiC,YAAY;CACjE;AACF"}
|
|
1
|
+
{"version":3,"file":"records.mjs","names":[],"sources":["../../../src/routerInternal/records.ts"],"sourcesContent":["import type {\n NamedRoutes,\n NavigationGuard,\n RouteRecordInput,\n RouteRecordRaw,\n UseRouterOptions,\n} from '../router'\nimport type {\n FlattenedRouteRecordSeed,\n NamedRouteLookup,\n RouteOptionSource,\n RouteRecordNormalized,\n} from './types'\nimport { createAbsoluteRoutePath, isDynamicRoutePath, resolvePath } from './path'\nimport { warnRouteConfig } from './recordsWarnings'\n\nfunction normalizeBeforeEnterGuards(beforeEnter?: RouteRecordRaw['beforeEnter']): readonly NavigationGuard[] {\n if (!beforeEnter) {\n return []\n }\n if (Array.isArray(beforeEnter)) {\n return beforeEnter as readonly NavigationGuard[]\n }\n return [beforeEnter as NavigationGuard]\n}\n\nfunction resolveRouteRecordName(\n route: RouteRecordInput,\n normalizedPath: string,\n source: RouteOptionSource = 'namedRoutes',\n): string {\n if (typeof route.name === 'string' && route.name.trim()) {\n return route.name.trim()\n }\n\n if (source === 'routes') {\n return normalizedPath || '/'\n }\n\n return ''\n}\n\nfunction normalizeRouteRecordAliasPaths(\n alias: RouteRecordRaw['alias'],\n normalizedPath: string,\n): readonly string[] {\n if (!alias) {\n return []\n }\n const aliasList = Array.isArray(alias)\n ? alias\n : [alias]\n\n const normalizedAliasPaths: string[] = []\n for (const aliasPath of aliasList) {\n if (typeof aliasPath !== 'string') {\n continue\n }\n const normalizedAliasPath = resolvePath(aliasPath, '')\n if (!normalizedAliasPath || normalizedAliasPath === normalizedPath) {\n continue\n }\n if (!normalizedAliasPaths.includes(normalizedAliasPath)) {\n normalizedAliasPaths.push(normalizedAliasPath)\n }\n }\n\n return normalizedAliasPaths\n}\n\nexport function normalizeRouteRecordRaw(\n route: RouteRecordInput,\n parentName?: string,\n source: RouteOptionSource = 'namedRoutes',\n): RouteRecordNormalized | undefined {\n const normalizedPath = resolvePath(route.path, '')\n if (!normalizedPath && route.path !== '/') {\n return undefined\n }\n\n const routeName = resolveRouteRecordName(route, normalizedPath, source)\n if (!routeName) {\n return undefined\n }\n const aliasPaths = normalizeRouteRecordAliasPaths(route.alias, normalizedPath)\n\n return {\n name: routeName,\n path: normalizedPath,\n aliasPaths,\n parentName,\n meta: route.meta,\n beforeEnterGuards: normalizeBeforeEnterGuards(route.beforeEnter),\n redirect: route.redirect,\n }\n}\n\nfunction normalizeNestedRoutePath(path: string, parentPath?: string): string {\n if (!parentPath || path.startsWith('/')) {\n return resolvePath(path, '')\n }\n return resolvePath(`${createAbsoluteRoutePath(parentPath)}/${path}`, '')\n}\n\nfunction normalizeAliasInputList(alias: RouteRecordRaw['alias']): string[] {\n if (!alias) {\n return []\n }\n if (Array.isArray(alias)) {\n return alias.filter((item): item is string => typeof item === 'string' && item.length > 0)\n }\n return typeof alias === 'string' && alias.length > 0\n ? [alias]\n : []\n}\n\nfunction mergeAliasPaths(aliasPaths: readonly string[]): string[] {\n const mergedAliasPaths: string[] = []\n for (const aliasPath of aliasPaths) {\n if (!aliasPath || mergedAliasPaths.includes(aliasPath)) {\n continue\n }\n mergedAliasPaths.push(aliasPath)\n }\n return mergedAliasPaths\n}\n\nexport function createRouteRecordAliasValue(aliasPaths: readonly string[]): RouteRecordRaw['alias'] {\n if (aliasPaths.length === 0) {\n return undefined\n }\n if (aliasPaths.length === 1) {\n return createAbsoluteRoutePath(aliasPaths[0])\n }\n return aliasPaths.map(aliasPath => createAbsoluteRoutePath(aliasPath))\n}\n\nexport function flattenNamedRouteRecords(\n records: readonly RouteRecordInput[],\n parentPath?: string,\n parentName?: string,\n parentAliasPaths: readonly string[] = [],\n source?: RouteOptionSource,\n pathPrefix = 'namedRoutes',\n ancestorRecords: ReadonlySet<RouteRecordInput> = new Set<RouteRecordInput>(),\n): FlattenedRouteRecordSeed[] {\n const flattenedRecords: FlattenedRouteRecordSeed[] = []\n\n for (const [index, record] of records.entries()) {\n const routeConfigPath = `${pathPrefix}[${index}]`\n if (ancestorRecords.has(record)) {\n warnRouteConfig(`ignored route record at ${routeConfigPath}: detected circular children reference`)\n continue\n }\n\n if (typeof record.path !== 'string' || !record.path) {\n const routeName = typeof record?.name === 'string'\n ? record.name.trim()\n : ''\n warnRouteConfig(`ignored route record \"${routeName}\" at ${routeConfigPath}: route path is required`)\n continue\n }\n\n const normalizedPath = normalizeNestedRoutePath(record.path, parentPath)\n const routeName = resolveRouteRecordName(record, normalizedPath, source)\n if (!routeName) {\n warnRouteConfig(`ignored route record at ${routeConfigPath}: route name is required`)\n continue\n }\n const normalizedDirectAliasPaths: string[] = []\n const directAliasByNormalizedPath = new Map<string, string>()\n for (const rawAliasPath of normalizeAliasInputList(record.alias)) {\n const normalizedAliasPath = normalizeNestedRoutePath(rawAliasPath, parentPath)\n if (!normalizedAliasPath) {\n continue\n }\n if (normalizedAliasPath === normalizedPath) {\n warnRouteConfig(`ignored alias \"${createAbsoluteRoutePath(normalizedAliasPath)}\" for route \"${routeName}\" at ${routeConfigPath}: alias is same as route path`)\n continue\n }\n\n const duplicateAliasPath = directAliasByNormalizedPath.get(normalizedAliasPath)\n if (duplicateAliasPath) {\n warnRouteConfig(\n `ignored duplicate alias \"${createAbsoluteRoutePath(normalizedAliasPath)}\" for route \"${routeName}\" at ${routeConfigPath}: already declared by \"${duplicateAliasPath}\"`,\n )\n continue\n }\n\n directAliasByNormalizedPath.set(normalizedAliasPath, rawAliasPath)\n normalizedDirectAliasPaths.push(normalizedAliasPath)\n }\n const normalizedInheritedAliasPaths = record.path.startsWith('/')\n ? []\n : parentAliasPaths\n .map(parentAliasPath => normalizeNestedRoutePath(record.path, parentAliasPath))\n .filter(Boolean)\n .filter(aliasPath => aliasPath !== normalizedPath)\n const normalizedAliasPaths = mergeAliasPaths([\n ...normalizedDirectAliasPaths,\n ...normalizedInheritedAliasPaths,\n ])\n const normalizedRecord: RouteRecordRaw = {\n name: routeName,\n path: normalizedPath ? createAbsoluteRoutePath(normalizedPath) : '/',\n alias: createRouteRecordAliasValue(normalizedAliasPaths),\n meta: record.meta,\n beforeEnter: record.beforeEnter,\n redirect: record.redirect,\n }\n flattenedRecords.push({\n route: normalizedRecord,\n parentName,\n source,\n })\n\n if (Array.isArray(record.children) && record.children.length > 0) {\n const nextAncestorRecords = new Set(ancestorRecords)\n nextAncestorRecords.add(record)\n flattenedRecords.push(\n ...flattenNamedRouteRecords(\n record.children,\n normalizedPath,\n routeName,\n normalizedAliasPaths,\n source,\n `${routeConfigPath}.children`,\n nextAncestorRecords,\n ),\n )\n }\n }\n\n return flattenedRecords\n}\n\nfunction normalizeNamedRouteEntries(\n namedRoutes?: NamedRoutes | readonly RouteRecordInput[],\n source: RouteOptionSource = 'namedRoutes',\n): FlattenedRouteRecordSeed[] {\n if (!namedRoutes) {\n return []\n }\n\n if (Array.isArray(namedRoutes)) {\n return flattenNamedRouteRecords(namedRoutes, undefined, undefined, [], source, source)\n }\n\n const normalizedEntries: FlattenedRouteRecordSeed[] = []\n for (const [rawName, rawPath] of Object.entries(namedRoutes)) {\n const routeName = typeof rawName === 'string'\n ? rawName.trim()\n : ''\n if (!routeName) {\n warnRouteConfig(`ignored route record at ${source}: route name is required`)\n continue\n }\n if (typeof rawPath !== 'string' || !rawPath) {\n warnRouteConfig(`ignored route record \"${routeName}\" at ${source}: route path is required`)\n continue\n }\n normalizedEntries.push({\n route: {\n name: routeName,\n path: rawPath,\n },\n source,\n })\n }\n\n return normalizedEntries\n}\n\nexport function resolveRouteOptionEntries(options: UseRouterOptions): FlattenedRouteRecordSeed[] {\n return [\n ...normalizeNamedRouteEntries(options.routes, 'routes'),\n ...normalizeNamedRouteEntries(options.namedRoutes, 'namedRoutes'),\n ]\n}\n\nexport function createNamedRouteNameByStaticPath(recordByName: ReadonlyMap<string, RouteRecordNormalized>): Map<string, string> {\n const nameByStaticPath = new Map<string, string>()\n for (const [name, record] of recordByName.entries()) {\n if (!isDynamicRoutePath(record.path) && !nameByStaticPath.has(record.path)) {\n nameByStaticPath.set(record.path, name)\n }\n for (const aliasPath of record.aliasPaths) {\n if (!isDynamicRoutePath(aliasPath) && !nameByStaticPath.has(aliasPath)) {\n nameByStaticPath.set(aliasPath, name)\n }\n }\n }\n return nameByStaticPath\n}\n\nexport function createNamedRouteLookup(routeEntries: readonly FlattenedRouteRecordSeed[]): NamedRouteLookup {\n const recordByName = new Map<string, RouteRecordNormalized>()\n\n for (const routeRecord of routeEntries) {\n const normalizedRecord = normalizeRouteRecordRaw(\n routeRecord.route,\n routeRecord.parentName,\n routeRecord.source,\n )\n if (!normalizedRecord) {\n continue\n }\n recordByName.set(normalizedRecord.name, normalizedRecord)\n }\n\n return {\n recordByName,\n nameByStaticPath: createNamedRouteNameByStaticPath(recordByName),\n }\n}\n"],"mappings":";;;;AAgBA,SAAS,2BAA2B,aAAyE;CAC3G,IAAI,CAAC,aACH,OAAO,CAAC;CAEV,IAAI,MAAM,QAAQ,WAAW,GAC3B,OAAO;CAET,OAAO,CAAC,WAA8B;AACxC;AAEA,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M,gBAAgB;CAC1D;CAEA,OAAO;EACL;EACA,kBAAkB,iCAAiC,YAAY;CACjE;AACF"}
|
|
@@ -144,7 +144,8 @@ function createRuntimeMount(options) {
|
|
|
144
144
|
if (isReactive(runtimeAttrs)) touchReactive(runtimeAttrs);
|
|
145
145
|
trackedSetupReactiveKeys.forEach((key) => {
|
|
146
146
|
var _key;
|
|
147
|
-
|
|
147
|
+
const v = (_key = setupState[key]) !== null && _key !== void 0 ? _key : state[key];
|
|
148
|
+
touchSetupBinding(v);
|
|
148
149
|
});
|
|
149
150
|
}, {
|
|
150
151
|
lazy: true,
|