wevu 6.18.7 → 6.19.1
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/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/defineProperty.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/toPrimitive.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/toPropertyKey.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/typeof.mjs +1 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/defineProperty.mjs +14 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/toPrimitive.mjs +16 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/toPropertyKey.mjs +11 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/typeof.mjs +12 -0
- package/dist/dev/index.mjs +48 -10
- package/dist/dev/internal-reactivity.mjs +15 -5
- package/dist/dev/internal-runtime.mjs +32 -4
- package/dist/dev/internal-template.mjs +1 -1
- package/dist/dev/package.mjs +6 -0
- package/dist/dev/package.mjs.map +1 -0
- package/dist/dev/reactivity/computed.mjs +49 -0
- package/dist/dev/reactivity/computed.mjs.map +1 -0
- package/dist/dev/reactivity/core.mjs +184 -0
- package/dist/dev/reactivity/core.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/mutation.mjs +12 -0
- package/dist/dev/reactivity/reactive/mutation.mjs.map +1 -0
- package/dist/dev/{computed-BxRsUJgi.mjs → reactivity/reactive/patch.mjs} +8 -49
- package/dist/dev/reactivity/reactive/patch.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/patchState.mjs +138 -0
- package/dist/dev/reactivity/reactive/patchState.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/shallow.mjs +77 -0
- package/dist/dev/reactivity/reactive/shallow.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/shared.mjs +40 -0
- package/dist/dev/reactivity/reactive/shared.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/state.mjs +8 -0
- package/dist/dev/reactivity/reactive/state.mjs.map +1 -0
- package/dist/dev/reactivity/reactive.mjs +213 -0
- package/dist/dev/reactivity/reactive.mjs.map +1 -0
- package/dist/dev/reactivity/readonly.mjs +69 -0
- package/dist/dev/reactivity/readonly.mjs.map +1 -0
- package/dist/dev/reactivity/ref.mjs +97 -0
- package/dist/dev/reactivity/ref.mjs.map +1 -0
- package/dist/dev/reactivity/shallowRef.mjs +71 -0
- package/dist/dev/reactivity/shallowRef.mjs.map +1 -0
- package/dist/dev/{toRefs-D06VmFK2.mjs → reactivity/toRefs.mjs} +4 -3
- package/dist/dev/reactivity/toRefs.mjs.map +1 -0
- package/dist/dev/reactivity/traverse.mjs +40 -0
- package/dist/dev/reactivity/traverse.mjs.map +1 -0
- package/dist/dev/reactivity/watch/helpers.mjs +78 -0
- package/dist/dev/reactivity/watch/helpers.mjs.map +1 -0
- package/dist/dev/reactivity/watch/types.mjs +20 -0
- package/dist/dev/reactivity/watch/types.mjs.map +1 -0
- package/dist/dev/reactivity/watch.mjs +167 -0
- package/dist/dev/reactivity/watch.mjs.map +1 -0
- package/dist/dev/router/backNavigation.mjs +32 -0
- package/dist/dev/router/backNavigation.mjs.map +1 -0
- package/dist/dev/router/createRouter.mjs +179 -0
- package/dist/dev/router/createRouter.mjs.map +1 -0
- package/dist/dev/router/instance.mjs +17 -0
- package/dist/dev/router/instance.mjs.map +1 -0
- package/dist/dev/router/navigationApi.mjs +94 -0
- package/dist/dev/router/navigationApi.mjs.map +1 -0
- package/dist/dev/router/navigationCore.mjs +139 -0
- package/dist/dev/router/navigationCore.mjs.map +1 -0
- package/dist/dev/router/navigationResult.mjs +54 -0
- package/dist/dev/router/navigationResult.mjs.map +1 -0
- package/dist/dev/router/navigationTarget.mjs +122 -0
- package/dist/dev/router/navigationTarget.mjs.map +1 -0
- package/dist/dev/router/navigationTargetHelpers.mjs +38 -0
- package/dist/dev/router/navigationTargetHelpers.mjs.map +1 -0
- package/dist/dev/router/resolve.mjs +29 -0
- package/dist/dev/router/resolve.mjs.map +1 -0
- package/dist/dev/router/routeRegistry.mjs +78 -0
- package/dist/dev/router/routeRegistry.mjs.map +1 -0
- package/dist/dev/router/routeSync.mjs +72 -0
- package/dist/dev/router/routeSync.mjs.map +1 -0
- package/dist/dev/router/types.mjs +11 -0
- package/dist/dev/router/types.mjs.map +1 -0
- package/dist/dev/router/useRoute.mjs +106 -0
- package/dist/dev/router/useRoute.mjs.map +1 -0
- package/dist/dev/router/useRouter.mjs +15 -0
- package/dist/dev/router/useRouter.mjs.map +1 -0
- package/dist/dev/router.mjs +9 -1378
- package/dist/dev/routerInternal/location.mjs +68 -0
- package/dist/dev/routerInternal/location.mjs.map +1 -0
- package/dist/dev/routerInternal/matching.mjs +149 -0
- package/dist/dev/routerInternal/matching.mjs.map +1 -0
- package/dist/dev/routerInternal/params.mjs +95 -0
- package/dist/dev/routerInternal/params.mjs.map +1 -0
- package/dist/dev/routerInternal/path.mjs +42 -0
- package/dist/dev/routerInternal/path.mjs.map +1 -0
- package/dist/dev/routerInternal/query.mjs +113 -0
- package/dist/dev/routerInternal/query.mjs.map +1 -0
- package/dist/dev/routerInternal/records.mjs +173 -0
- package/dist/dev/routerInternal/records.mjs.map +1 -0
- package/dist/dev/routerInternal/recordsWarnings.mjs +49 -0
- package/dist/dev/routerInternal/recordsWarnings.mjs.map +1 -0
- package/dist/dev/routerInternal/snapshots.mjs +126 -0
- package/dist/dev/routerInternal/snapshots.mjs.map +1 -0
- package/dist/dev/runtime/app/computed.mjs +68 -0
- package/dist/dev/runtime/app/computed.mjs.map +1 -0
- package/dist/dev/runtime/app/context.mjs +275 -0
- package/dist/dev/runtime/app/context.mjs.map +1 -0
- package/dist/dev/runtime/app/diagnostics.mjs +34 -0
- package/dist/dev/runtime/app/diagnostics.mjs.map +1 -0
- package/dist/dev/runtime/app/mount.mjs +270 -0
- package/dist/dev/runtime/app/mount.mjs.map +1 -0
- package/dist/dev/runtime/app/pending.mjs +14 -0
- package/dist/dev/runtime/app/pending.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +158 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/payload.mjs +161 -0
- package/dist/dev/runtime/app/setData/payload.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs +313 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/snapshot.mjs +129 -0
- package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -0
- package/dist/dev/runtime/app/setDataOptions.mjs +73 -0
- package/dist/dev/runtime/app/setDataOptions.mjs.map +1 -0
- package/dist/dev/runtime/app.mjs +93 -0
- package/dist/dev/runtime/app.mjs.map +1 -0
- package/dist/dev/runtime/bindModel.mjs +92 -0
- package/dist/dev/runtime/bindModel.mjs.map +1 -0
- package/dist/dev/runtime/defaults.mjs +61 -0
- package/dist/dev/runtime/defaults.mjs.map +1 -0
- package/dist/dev/runtime/define/initialComputed.mjs +125 -0
- package/dist/dev/runtime/define/initialComputed.mjs.map +1 -0
- package/dist/dev/runtime/define/options.mjs +169 -0
- package/dist/dev/runtime/define/options.mjs.map +1 -0
- package/dist/dev/runtime/define/optionsApi.mjs +48 -0
- package/dist/dev/runtime/define/optionsApi.mjs.map +1 -0
- package/dist/dev/runtime/define/props.mjs +194 -0
- package/dist/dev/runtime/define/props.mjs.map +1 -0
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +316 -0
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -0
- package/dist/dev/runtime/define/setupResult.mjs +78 -0
- package/dist/dev/runtime/define/setupResult.mjs.map +1 -0
- package/dist/dev/runtime/define.mjs +142 -0
- package/dist/dev/runtime/define.mjs.map +1 -0
- package/dist/dev/runtime/diff.mjs +193 -0
- package/dist/dev/runtime/diff.mjs.map +1 -0
- package/dist/dev/runtime/disposables.mjs +81 -0
- package/dist/dev/runtime/disposables.mjs.map +1 -0
- package/dist/dev/runtime/elementIntersectionObserver.mjs +80 -0
- package/dist/dev/runtime/elementIntersectionObserver.mjs.map +1 -0
- package/dist/dev/runtime/emit.mjs +36 -0
- package/dist/dev/runtime/emit.mjs.map +1 -0
- package/dist/dev/{base-CYkvI7w8.mjs → runtime/hooks/base.mjs} +3 -140
- package/dist/dev/runtime/hooks/base.mjs.map +1 -0
- package/dist/dev/runtime/hooks/register.mjs +92 -0
- package/dist/dev/runtime/hooks/register.mjs.map +1 -0
- package/dist/dev/runtime/hooks/vue.mjs +81 -0
- package/dist/dev/runtime/hooks/vue.mjs.map +1 -0
- package/dist/dev/runtime/internal.mjs +18 -0
- package/dist/dev/runtime/internal.mjs.map +1 -0
- package/dist/dev/runtime/intersectionObserver.mjs +46 -0
- package/dist/dev/runtime/intersectionObserver.mjs.map +1 -0
- package/dist/dev/runtime/layoutBridge.mjs +303 -0
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -0
- package/dist/dev/runtime/layoutComponentMatcher.mjs +11 -0
- package/dist/dev/runtime/layoutComponentMatcher.mjs.map +1 -0
- package/dist/dev/runtime/nativeBridge.mjs +21 -0
- package/dist/dev/runtime/nativeBridge.mjs.map +1 -0
- package/dist/dev/runtime/noSetData.mjs +18 -0
- package/dist/dev/runtime/noSetData.mjs.map +1 -0
- package/dist/dev/runtime/pageEnvironment.mjs +100 -0
- package/dist/dev/runtime/pageEnvironment.mjs.map +1 -0
- package/dist/dev/runtime/pageLayout.mjs +71 -0
- package/dist/dev/runtime/pageLayout.mjs.map +1 -0
- package/dist/dev/runtime/pageScroll.mjs +110 -0
- package/dist/dev/runtime/pageScroll.mjs.map +1 -0
- package/dist/dev/runtime/platform.mjs +79 -0
- package/dist/dev/runtime/platform.mjs.map +1 -0
- package/dist/dev/runtime/provide.mjs +71 -0
- package/dist/dev/runtime/provide.mjs.map +1 -0
- package/dist/dev/runtime/provideContext.mjs +101 -0
- package/dist/dev/runtime/provideContext.mjs.map +1 -0
- package/dist/dev/runtime/provideStore.mjs +18 -0
- package/dist/dev/runtime/provideStore.mjs.map +1 -0
- package/dist/dev/runtime/pullDownRefresh.mjs +24 -0
- package/dist/dev/runtime/pullDownRefresh.mjs.map +1 -0
- package/dist/dev/runtime/register/app.mjs +161 -0
- package/dist/dev/runtime/register/app.mjs.map +1 -0
- package/dist/dev/runtime/register/component/features.mjs +43 -0
- package/dist/dev/runtime/register/component/features.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +64 -0
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +96 -0
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle.mjs +122 -0
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -0
- package/dist/dev/runtime/register/component/methods.mjs +82 -0
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -0
- package/dist/dev/runtime/register/component/options.mjs +204 -0
- package/dist/dev/runtime/register/component/options.mjs.map +1 -0
- package/dist/dev/runtime/register/component/props.mjs +218 -0
- package/dist/dev/runtime/register/component/props.mjs.map +1 -0
- package/dist/dev/runtime/register/component/registerDefinition.mjs +290 -0
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -0
- package/dist/dev/runtime/register/component.mjs +129 -0
- package/dist/dev/runtime/register/component.mjs.map +1 -0
- package/dist/dev/runtime/register/inline.mjs +145 -0
- package/dist/dev/runtime/register/inline.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +53 -0
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +34 -0
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +230 -0
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +166 -0
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs +122 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs +441 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -0
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +95 -0
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -0
- package/dist/dev/runtime/register/setup.mjs +22 -0
- package/dist/dev/runtime/register/setup.mjs.map +1 -0
- package/dist/dev/runtime/register/snapshot.mjs +18 -0
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -0
- package/dist/dev/runtime/register/watch.mjs +57 -0
- package/dist/dev/runtime/register/watch.mjs.map +1 -0
- package/dist/dev/runtime/scopedSlots.mjs +115 -0
- package/dist/dev/runtime/scopedSlots.mjs.map +1 -0
- package/dist/dev/runtime/selectorQuery.mjs +49 -0
- package/dist/dev/runtime/selectorQuery.mjs.map +1 -0
- package/dist/dev/runtime/setupTracking.mjs +59 -0
- package/dist/dev/runtime/setupTracking.mjs.map +1 -0
- package/dist/dev/{template-n_iVr0ey.mjs → runtime/template.mjs} +7 -4
- package/dist/dev/runtime/template.mjs.map +1 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs +259 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -0
- package/dist/dev/runtime/templateRefs.mjs +162 -0
- package/dist/dev/runtime/templateRefs.mjs.map +1 -0
- package/dist/dev/runtime/uniAppHost.mjs +119 -0
- package/dist/dev/runtime/uniAppHost.mjs.map +1 -0
- package/dist/dev/runtime/updatePerformance.mjs +41 -0
- package/dist/dev/runtime/updatePerformance.mjs.map +1 -0
- package/dist/dev/runtime/use.mjs +25 -0
- package/dist/dev/runtime/use.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/context.mjs +25 -0
- package/dist/dev/runtime/vueCompat/context.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/model.mjs +119 -0
- package/dist/dev/runtime/vueCompat/model.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/router.mjs +124 -0
- package/dist/dev/runtime/vueCompat/router.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs +37 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -0
- package/dist/dev/scheduler.mjs +75 -0
- package/dist/dev/scheduler.mjs.map +1 -0
- package/dist/dev/store/actions.mjs +40 -0
- package/dist/dev/store/actions.mjs.map +1 -0
- package/dist/dev/store/base.mjs +56 -0
- package/dist/dev/store/base.mjs.map +1 -0
- package/dist/dev/store/define/optionsStyle.mjs +125 -0
- package/dist/dev/store/define/optionsStyle.mjs.map +1 -0
- package/dist/dev/store/define/setupStyle.mjs +145 -0
- package/dist/dev/store/define/setupStyle.mjs.map +1 -0
- package/dist/dev/store/define/shared.mjs +38 -0
- package/dist/dev/store/define/shared.mjs.map +1 -0
- package/dist/dev/store/define.mjs +23 -0
- package/dist/dev/store/define.mjs.map +1 -0
- package/dist/dev/store/manager.mjs +21 -0
- package/dist/dev/store/manager.mjs.map +1 -0
- package/dist/dev/store/storeToRefs.mjs +29 -0
- package/dist/dev/store/storeToRefs.mjs.map +1 -0
- package/dist/dev/store/utils.mjs +49 -0
- package/dist/dev/store/utils.mjs.map +1 -0
- package/dist/dev/store.mjs +3 -1
- package/dist/dev/utils.mjs +16 -0
- package/dist/dev/utils.mjs.map +1 -0
- package/dist/dev/version.mjs +8 -0
- package/dist/dev/version.mjs.map +1 -0
- package/dist/dev/vue-demi.mjs +48 -168
- package/dist/dev/vue-demi.mjs.map +1 -1
- package/dist/index.d.mts +71 -7
- package/dist/index.mjs +1 -1
- package/dist/internal-reactivity.d.mts +16 -2
- package/dist/internal-reactivity.mjs +1 -1
- package/dist/internal-runtime.d.mts +35 -2
- package/dist/internal-runtime.mjs +1 -1
- package/dist/internal-template.d.mts +1 -1
- package/dist/internal-template.mjs +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/macros/shared.d.mts +81 -0
- package/dist/macros.d.mts +70 -0
- package/dist/package.mjs +1 -0
- package/dist/reactivity/computed.d.mts +21 -0
- package/dist/reactivity/computed.mjs +1 -0
- package/dist/reactivity/core.d.mts +34 -0
- package/dist/reactivity/core.mjs +1 -0
- package/dist/reactivity/index.d.mts +15 -0
- package/dist/reactivity/reactive/mutation.d.mts +21 -0
- package/dist/reactivity/reactive/mutation.mjs +1 -0
- package/dist/reactivity/reactive/patch.d.mts +18 -0
- package/dist/reactivity/reactive/patch.mjs +1 -0
- package/dist/reactivity/reactive/patchState.mjs +1 -0
- package/dist/reactivity/reactive/shallow.d.mts +22 -0
- package/dist/reactivity/reactive/shallow.mjs +1 -0
- package/dist/reactivity/reactive/shared.d.mts +4 -0
- package/dist/reactivity/reactive/shared.mjs +1 -0
- package/dist/reactivity/reactive/state.mjs +1 -0
- package/dist/reactivity/reactive.d.mts +41 -0
- package/dist/reactivity/reactive.mjs +1 -0
- package/dist/reactivity/readonly.d.mts +27 -0
- package/dist/reactivity/readonly.mjs +1 -0
- package/dist/reactivity/ref.d.mts +27 -0
- package/dist/reactivity/ref.mjs +1 -0
- package/dist/reactivity/shallowRef.d.mts +19 -0
- package/dist/reactivity/shallowRef.mjs +1 -0
- package/dist/reactivity/toRefs.d.mts +43 -0
- package/dist/reactivity/toRefs.mjs +1 -0
- package/dist/reactivity/traverse.d.mts +8 -0
- package/dist/reactivity/traverse.mjs +1 -0
- package/dist/reactivity/watch/helpers.mjs +1 -0
- package/dist/reactivity/watch/types.d.mts +43 -0
- package/dist/reactivity/watch/types.mjs +1 -0
- package/dist/reactivity/watch.d.mts +21 -0
- package/dist/reactivity/watch.mjs +1 -0
- package/dist/router/backNavigation.mjs +1 -0
- package/dist/router/createRouter.d.mts +8 -0
- package/dist/router/createRouter.mjs +1 -0
- package/dist/router/instance.mjs +1 -0
- package/dist/router/navigationApi.mjs +1 -0
- package/dist/router/navigationCore.d.mts +6 -0
- package/dist/router/navigationCore.mjs +1 -0
- package/dist/router/navigationResult.mjs +1 -0
- package/dist/router/navigationTarget.mjs +1 -0
- package/dist/router/navigationTargetHelpers.mjs +1 -0
- package/dist/router/resolve.d.mts +6 -0
- package/dist/router/resolve.mjs +1 -0
- package/dist/router/routeRegistry.mjs +1 -0
- package/dist/router/routeSync.d.mts +1 -0
- package/dist/router/routeSync.mjs +1 -0
- package/dist/router/types.d.mts +163 -0
- package/dist/router/types.mjs +1 -0
- package/dist/router/useRoute.d.mts +19 -0
- package/dist/router/useRoute.mjs +1 -0
- package/dist/router/useRouter.d.mts +8 -0
- package/dist/router/useRouter.mjs +1 -0
- package/dist/router.d.mts +9 -204
- package/dist/router.mjs +1 -1
- package/dist/routerInternal/location.mjs +1 -0
- package/dist/routerInternal/matching.mjs +1 -0
- package/dist/routerInternal/params.mjs +1 -0
- package/dist/routerInternal/path.mjs +1 -0
- package/dist/routerInternal/query.d.mts +7 -0
- package/dist/routerInternal/query.mjs +1 -0
- package/dist/routerInternal/records.mjs +1 -0
- package/dist/routerInternal/recordsWarnings.mjs +1 -0
- package/dist/routerInternal/snapshots.mjs +1 -0
- package/dist/routerInternal/types.d.mts +9 -0
- package/dist/runtime/app/computed.mjs +1 -0
- package/dist/runtime/app/context.mjs +1 -0
- package/dist/runtime/app/diagnostics.mjs +1 -0
- package/dist/runtime/app/mount.mjs +1 -0
- package/dist/runtime/app/pending.d.mts +10 -0
- package/dist/runtime/app/pending.mjs +1 -0
- package/dist/runtime/app/setData/patchScheduler.mjs +1 -0
- package/dist/runtime/app/setData/payload.mjs +1 -0
- package/dist/runtime/app/setData/scheduler.mjs +1 -0
- package/dist/runtime/app/setData/snapshot.mjs +1 -0
- package/dist/runtime/app/setDataOptions.mjs +1 -0
- package/dist/runtime/app.d.mts +8 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/bindModel.mjs +1 -0
- package/dist/runtime/defaults.d.mts +11 -0
- package/dist/runtime/defaults.mjs +1 -0
- package/dist/runtime/define/initialComputed.mjs +1 -0
- package/dist/runtime/define/options.mjs +1 -0
- package/dist/runtime/define/optionsApi.mjs +1 -0
- package/dist/runtime/define/props.mjs +1 -0
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -0
- package/dist/runtime/define/setupResult.mjs +1 -0
- package/dist/runtime/define.d.mts +105 -0
- package/dist/runtime/define.mjs +1 -0
- package/dist/runtime/diff.mjs +1 -0
- package/dist/runtime/disposables.d.mts +31 -0
- package/dist/runtime/disposables.mjs +1 -0
- package/dist/runtime/elementIntersectionObserver.d.mts +26 -0
- package/dist/runtime/elementIntersectionObserver.mjs +1 -0
- package/dist/runtime/emit.mjs +1 -0
- package/dist/runtime/hooks/base.d.mts +27 -0
- package/dist/runtime/hooks/base.mjs +1 -0
- package/dist/runtime/hooks/register.d.mts +30 -0
- package/dist/runtime/hooks/register.mjs +1 -0
- package/dist/runtime/hooks/vue.d.mts +53 -0
- package/dist/runtime/hooks/vue.mjs +1 -0
- package/dist/runtime/hooks.d.mts +4 -0
- package/dist/runtime/index.d.mts +47 -0
- package/dist/runtime/internal.mjs +1 -0
- package/dist/runtime/intersectionObserver.d.mts +14 -0
- package/dist/runtime/intersectionObserver.mjs +1 -0
- package/dist/runtime/layoutBridge.d.mts +59 -0
- package/dist/runtime/layoutBridge.mjs +1 -0
- package/dist/runtime/layoutComponentMatcher.mjs +1 -0
- package/dist/runtime/nativeBridge.mjs +1 -0
- package/dist/runtime/noSetData.d.mts +5 -0
- package/dist/runtime/noSetData.mjs +1 -0
- package/dist/runtime/pageEnvironment.d.mts +50 -0
- package/dist/runtime/pageEnvironment.mjs +1 -0
- package/dist/runtime/pageLayout.d.mts +26 -0
- package/dist/runtime/pageLayout.mjs +1 -0
- package/dist/runtime/pageScroll.d.mts +29 -0
- package/dist/runtime/pageScroll.mjs +1 -0
- package/dist/runtime/platform.mjs +1 -0
- package/dist/runtime/provide.d.mts +59 -0
- package/dist/runtime/provide.mjs +1 -0
- package/dist/runtime/provideContext.mjs +1 -0
- package/dist/runtime/provideStore.d.mts +7 -0
- package/dist/runtime/provideStore.mjs +1 -0
- package/dist/runtime/pullDownRefresh.d.mts +12 -0
- package/dist/runtime/pullDownRefresh.mjs +1 -0
- package/dist/runtime/register/app.d.mts +14 -0
- package/dist/runtime/register/app.mjs +1 -0
- package/dist/runtime/register/component/features.mjs +1 -0
- package/dist/runtime/register/component/lifecycle/optionalHooks.mjs +1 -0
- package/dist/runtime/register/component/lifecycle/platform.mjs +1 -0
- package/dist/runtime/register/component/lifecycle.mjs +1 -0
- package/dist/runtime/register/component/methods.mjs +1 -0
- package/dist/runtime/register/component/options.mjs +1 -0
- package/dist/runtime/register/component/props.mjs +1 -0
- package/dist/runtime/register/component/registerDefinition.mjs +1 -0
- package/dist/runtime/register/component.d.mts +15 -0
- package/dist/runtime/register/component.mjs +1 -0
- package/dist/runtime/register/inline.d.mts +15 -0
- package/dist/runtime/register/inline.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/methodBridge.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/provideContext.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/utils.mjs +1 -0
- package/dist/runtime/register/runtimeInstance.d.mts +26 -0
- package/dist/runtime/register/runtimeInstance.mjs +1 -0
- package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -0
- package/dist/runtime/register/setup.d.mts +11 -0
- package/dist/runtime/register/setup.mjs +1 -0
- package/dist/runtime/register/snapshot.mjs +1 -0
- package/dist/runtime/register/watch.d.mts +12 -0
- package/dist/runtime/register/watch.mjs +1 -0
- package/dist/runtime/register.d.mts +5 -0
- package/dist/runtime/scopedSlots.mjs +1 -0
- package/dist/runtime/selectorQuery.d.mts +54 -0
- package/dist/runtime/selectorQuery.mjs +1 -0
- package/dist/runtime/setupTracking.mjs +1 -0
- package/dist/{template-DE8e5dj_.d.mts → runtime/template.d.mts} +1 -1
- package/dist/runtime/template.mjs +1 -0
- package/dist/runtime/templateRefTypes.d.mts +7 -0
- package/dist/runtime/templateRefs/helpers.mjs +1 -0
- package/dist/runtime/templateRefs.d.mts +11 -0
- package/dist/runtime/templateRefs.mjs +1 -0
- package/dist/runtime/types/core.d.mts +35 -0
- package/dist/runtime/types/miniprogram.d.mts +80 -0
- package/dist/runtime/types/miniprogramHost.d.mts +44 -0
- package/dist/runtime/types/miniprogramHostSources.d.mts +112 -0
- package/dist/runtime/types/options.d.mts +136 -0
- package/dist/runtime/types/props/propTypes.d.mts +79 -0
- package/dist/runtime/types/props/router.d.mts +51 -0
- package/dist/runtime/types/props/setup.d.mts +96 -0
- package/dist/runtime/types/props.d.mts +4 -0
- package/dist/runtime/types/runtime.d.mts +59 -0
- package/dist/runtime/types/setData.d.mts +220 -0
- package/dist/runtime/types.d.mts +28 -0
- package/dist/runtime/uniAppHost.d.mts +8 -0
- package/dist/runtime/uniAppHost.mjs +1 -0
- package/dist/runtime/updatePerformance.d.mts +13 -0
- package/dist/runtime/updatePerformance.mjs +1 -0
- package/dist/runtime/use.d.mts +13 -0
- package/dist/runtime/use.mjs +1 -0
- package/dist/runtime/vueCompat/context.d.mts +8 -0
- package/dist/runtime/vueCompat/context.mjs +1 -0
- package/dist/runtime/vueCompat/model.d.mts +30 -0
- package/dist/runtime/vueCompat/model.mjs +1 -0
- package/dist/runtime/vueCompat/router.d.mts +28 -0
- package/dist/runtime/vueCompat/router.mjs +1 -0
- package/dist/runtime/vueCompat/templateRef.d.mts +9 -0
- package/dist/runtime/vueCompat/templateRef.mjs +1 -0
- package/dist/runtime/vueCompat.d.mts +5 -0
- package/dist/scheduler.d.mts +4 -0
- package/dist/scheduler.mjs +1 -0
- package/dist/store/actions.mjs +1 -0
- package/dist/store/base.mjs +1 -0
- package/dist/store/define/optionsStyle.mjs +1 -0
- package/dist/store/define/setupStyle.mjs +1 -0
- package/dist/store/define/shared.mjs +1 -0
- package/dist/store/define.d.mts +26 -0
- package/dist/store/define.mjs +1 -0
- package/dist/store/manager.d.mts +8 -0
- package/dist/store/manager.mjs +1 -0
- package/dist/store/storeToRefs.d.mts +13 -0
- package/dist/store/storeToRefs.mjs +1 -0
- package/dist/store/types.d.mts +70 -0
- package/dist/store/utils.mjs +1 -0
- package/dist/store.d.mts +4 -1
- package/dist/store.mjs +1 -1
- package/dist/utils.mjs +1 -0
- package/dist/version.d.mts +4 -0
- package/dist/version.mjs +1 -0
- package/dist/vue-augment.d.mts +6 -0
- package/dist/vue-demi.d.mts +68 -10
- package/dist/vue-demi.mjs +1 -1
- package/dist/vue-types.d.mts +18 -0
- package/dist/weappIntrinsicElements/base.d.mts +22 -0
- package/dist/weappIntrinsicElements/elements/ad-custom.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/ad.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/audio.d.mts +20 -0
- package/dist/weappIntrinsicElements/elements/block.d.mts +8 -0
- package/dist/weappIntrinsicElements/elements/button.d.mts +40 -0
- package/dist/weappIntrinsicElements/elements/camera.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/canvas.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/checkbox-group.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/checkbox.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/cover-image.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/cover-view.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/editor.d.mts +22 -0
- package/dist/weappIntrinsicElements/elements/form.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/functional-page-navigator.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/icon.d.mts +12 -0
- package/dist/weappIntrinsicElements/elements/image.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/import.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/include.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/input.d.mts +47 -0
- package/dist/weappIntrinsicElements/elements/keyboard-accessory.d.mts +8 -0
- package/dist/weappIntrinsicElements/elements/label.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/live-player.d.mts +35 -0
- package/dist/weappIntrinsicElements/elements/live-pusher.d.mts +57 -0
- package/dist/weappIntrinsicElements/elements/map.d.mts +105 -0
- package/dist/weappIntrinsicElements/elements/match-media.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/movable-area.d.mts +26 -0
- package/dist/weappIntrinsicElements/elements/movable-view.d.mts +26 -0
- package/dist/weappIntrinsicElements/elements/navigation-bar.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/navigator.d.mts +25 -0
- package/dist/weappIntrinsicElements/elements/official-account.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/open-data.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/page-container.d.mts +25 -0
- package/dist/weappIntrinsicElements/elements/page-meta.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/picker-view-column.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/picker-view.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/picker.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/progress.d.mts +21 -0
- package/dist/weappIntrinsicElements/elements/radio-group.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/radio.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/rich-text.d.mts +17 -0
- package/dist/weappIntrinsicElements/elements/scroll-view.d.mts +68 -0
- package/dist/weappIntrinsicElements/elements/share-element.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/slider.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/slot.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/swiper-item.d.mts +42 -0
- package/dist/weappIntrinsicElements/elements/swiper.d.mts +42 -0
- package/dist/weappIntrinsicElements/elements/switch.d.mts +14 -0
- package/dist/weappIntrinsicElements/elements/template.d.mts +12 -0
- package/dist/weappIntrinsicElements/elements/text.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/textarea.d.mts +40 -0
- package/dist/weappIntrinsicElements/elements/video.d.mts +71 -0
- package/dist/weappIntrinsicElements/elements/view.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/voip-room.d.mts +14 -0
- package/dist/weappIntrinsicElements/elements/web-view.d.mts +13 -0
- package/dist/weappIntrinsicElements.d.mts +153 -0
- package/package.json +6 -6
- package/dist/base-BxKbbKVO.mjs +0 -1
- package/dist/computed-Xoi9XEUx.mjs +0 -1
- package/dist/dev/base-CYkvI7w8.mjs.map +0 -1
- package/dist/dev/computed-BxRsUJgi.mjs.map +0 -1
- package/dist/dev/ref-DRZC3Kc5.mjs +0 -695
- package/dist/dev/ref-DRZC3Kc5.mjs.map +0 -1
- package/dist/dev/rolldown-runtime-BUUfjzRC.mjs +0 -36
- package/dist/dev/router-D0JQfgyN.mjs +0 -754
- package/dist/dev/router-D0JQfgyN.mjs.map +0 -1
- package/dist/dev/router.mjs.map +0 -1
- package/dist/dev/store-HNsiQJ4d.mjs +0 -479
- package/dist/dev/store-HNsiQJ4d.mjs.map +0 -1
- package/dist/dev/template-n_iVr0ey.mjs.map +0 -1
- package/dist/dev/templateRef-BLnYcEH0.mjs +0 -6439
- package/dist/dev/templateRef-BLnYcEH0.mjs.map +0 -1
- package/dist/dev/toRefs-D06VmFK2.mjs.map +0 -1
- package/dist/dev/watch-jrgL5ald.mjs +0 -445
- package/dist/dev/watch-jrgL5ald.mjs.map +0 -1
- package/dist/index-BiHILcmb.d.mts +0 -1215
- package/dist/index-CCET_bCY.d.mts +0 -111
- package/dist/ref-D37CknuD.mjs +0 -1
- package/dist/rolldown-runtime-CenpyGzJ.mjs +0 -1
- package/dist/router-D4W4lEXM.mjs +0 -1
- package/dist/store-eHrHBQiv.mjs +0 -1
- package/dist/template-CNzlwH-E.mjs +0 -1
- package/dist/templateRef-DOTHWzZ5.mjs +0 -1
- package/dist/toRefs-CoytPyo0.mjs +0 -1
- package/dist/traverse-B4Ez44Gd.d.mts +0 -108
- package/dist/vue-types-B3N60cGV.d.mts +0 -757
- package/dist/watch-Bbd-gmEg.mjs +0 -1
- package/dist/weappIntrinsicElements-BgDtC53_.d.mts +0 -1257
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getCurrentMiniProgramPages } from "../runtime/platform.mjs";
|
|
2
|
+
import { getCurrentPageInstance } from "../runtime/register/component/lifecycle/platform.mjs";
|
|
3
|
+
import { createAbsoluteRoutePath, resolvePath } from "./path.mjs";
|
|
4
|
+
import { normalizeHash, normalizeQuery, parseQuery, stringifyQuery } from "./query.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/routerInternal/location.ts
|
|
7
|
+
const DEFAULT_ROUTE_RESOLVE_CODEC = {
|
|
8
|
+
parseQuery,
|
|
9
|
+
stringifyQuery
|
|
10
|
+
};
|
|
11
|
+
function parsePathInput(input, codec = DEFAULT_ROUTE_RESOLVE_CODEC) {
|
|
12
|
+
const hashIndex = input.indexOf("#");
|
|
13
|
+
const withoutHash = hashIndex >= 0 ? input.slice(0, hashIndex) : input;
|
|
14
|
+
const hash = hashIndex >= 0 ? normalizeHash(input.slice(hashIndex + 1)) : "";
|
|
15
|
+
const queryIndex = withoutHash.indexOf("?");
|
|
16
|
+
if (queryIndex < 0) return {
|
|
17
|
+
path: withoutHash,
|
|
18
|
+
query: {},
|
|
19
|
+
hash
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
path: withoutHash.slice(0, queryIndex),
|
|
23
|
+
query: normalizeQuery(codec.parseQuery(withoutHash.slice(queryIndex + 1))),
|
|
24
|
+
hash
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createRouteLocation(path, query, hash = "", name, params = {}, queryStringifier = stringifyQuery) {
|
|
28
|
+
const normalizedPath = resolvePath(path, "");
|
|
29
|
+
const queryString = queryStringifier(query);
|
|
30
|
+
const fullPathBase = createAbsoluteRoutePath(normalizedPath);
|
|
31
|
+
const normalizedHash = normalizeHash(hash);
|
|
32
|
+
const fullPath = queryString ? `${fullPathBase}?${queryString}` : fullPathBase;
|
|
33
|
+
const location = {
|
|
34
|
+
path: normalizedPath,
|
|
35
|
+
fullPath: normalizedHash ? `${fullPath}${normalizedHash}` : fullPath,
|
|
36
|
+
query,
|
|
37
|
+
hash: normalizedHash,
|
|
38
|
+
params
|
|
39
|
+
};
|
|
40
|
+
if (name !== void 0) location.name = name;
|
|
41
|
+
return location;
|
|
42
|
+
}
|
|
43
|
+
function hasPageRoute(page) {
|
|
44
|
+
return typeof (page === null || page === void 0 ? void 0 : page.route) === "string" && page.route.length > 0 || typeof (page === null || page === void 0 ? void 0 : page.__route__) === "string" && page.__route__.length > 0;
|
|
45
|
+
}
|
|
46
|
+
function getCurrentMiniProgramPage(fallbackPage) {
|
|
47
|
+
const pages = getCurrentMiniProgramPages();
|
|
48
|
+
if (Array.isArray(pages) && pages.length > 0) {
|
|
49
|
+
const currentPage = pages[pages.length - 1];
|
|
50
|
+
if (hasPageRoute(currentPage)) return currentPage;
|
|
51
|
+
}
|
|
52
|
+
const currentPageInstance = getCurrentPageInstance();
|
|
53
|
+
return hasPageRoute(currentPageInstance) ? currentPageInstance : fallbackPage;
|
|
54
|
+
}
|
|
55
|
+
function resolvePageRoute(page, queryOverride) {
|
|
56
|
+
var _page$options;
|
|
57
|
+
if (!page) return createRouteLocation("", {});
|
|
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, {});
|
|
61
|
+
}
|
|
62
|
+
function resolveCurrentRoute(queryOverride, fallbackPage) {
|
|
63
|
+
return resolvePageRoute(getCurrentMiniProgramPage(fallbackPage), queryOverride);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { createRouteLocation, parsePathInput, resolveCurrentRoute, resolvePageRoute };
|
|
68
|
+
//# sourceMappingURL=location.mjs.map
|
|
@@ -0,0 +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,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C+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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { isDynamicRoutePath } from "./path.mjs";
|
|
2
|
+
import { decodeRouteParamSegment, parsePathParamToken } from "./params.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/routerInternal/matching.ts
|
|
5
|
+
function splitRoutePathSegments(path) {
|
|
6
|
+
return path.split("/").filter(Boolean);
|
|
7
|
+
}
|
|
8
|
+
function listRouteRecordMatchPaths(record) {
|
|
9
|
+
return [record.path, ...record.aliasPaths];
|
|
10
|
+
}
|
|
11
|
+
function resolveMatchedRouteRecordChain(record, lookup) {
|
|
12
|
+
const matchedRecords = [];
|
|
13
|
+
const visitedNames = /* @__PURE__ */ new Set();
|
|
14
|
+
let currentRecord = record;
|
|
15
|
+
while (currentRecord) {
|
|
16
|
+
if (visitedNames.has(currentRecord.name)) break;
|
|
17
|
+
visitedNames.add(currentRecord.name);
|
|
18
|
+
matchedRecords.unshift(currentRecord);
|
|
19
|
+
if (!currentRecord.parentName) break;
|
|
20
|
+
currentRecord = lookup.recordByName.get(currentRecord.parentName);
|
|
21
|
+
}
|
|
22
|
+
return matchedRecords;
|
|
23
|
+
}
|
|
24
|
+
function mergeMatchedRouteMeta(matchedRecords) {
|
|
25
|
+
let mergedRouteMeta;
|
|
26
|
+
for (const matchedRecord of matchedRecords) {
|
|
27
|
+
if (!matchedRecord.meta) continue;
|
|
28
|
+
if (!mergedRouteMeta) mergedRouteMeta = {};
|
|
29
|
+
Object.assign(mergedRouteMeta, matchedRecord.meta);
|
|
30
|
+
}
|
|
31
|
+
return mergedRouteMeta;
|
|
32
|
+
}
|
|
33
|
+
function collectRouteNamesForRemoval(routeName, recordByName) {
|
|
34
|
+
const namesToRemove = /* @__PURE__ */ new Set();
|
|
35
|
+
if (!recordByName.has(routeName)) return namesToRemove;
|
|
36
|
+
namesToRemove.add(routeName);
|
|
37
|
+
let expanded = true;
|
|
38
|
+
while (expanded) {
|
|
39
|
+
expanded = false;
|
|
40
|
+
for (const [name, record] of recordByName.entries()) {
|
|
41
|
+
if (!record.parentName || namesToRemove.has(name)) continue;
|
|
42
|
+
if (namesToRemove.has(record.parentName)) {
|
|
43
|
+
namesToRemove.add(name);
|
|
44
|
+
expanded = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return namesToRemove;
|
|
49
|
+
}
|
|
50
|
+
function buildRouteParamsFromMatch(matchValues) {
|
|
51
|
+
const params = {};
|
|
52
|
+
for (const [key, values] of matchValues.entries()) {
|
|
53
|
+
if (values.length === 0) continue;
|
|
54
|
+
params[key] = values.length === 1 ? values[0] : values;
|
|
55
|
+
}
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
function matchRoutePathParams(pathTemplate, targetPath) {
|
|
59
|
+
const templateSegments = splitRoutePathSegments(pathTemplate);
|
|
60
|
+
const targetSegments = splitRoutePathSegments(targetPath);
|
|
61
|
+
const matchedValues = /* @__PURE__ */ new Map();
|
|
62
|
+
const pushValue = (key, value) => {
|
|
63
|
+
const previous = matchedValues.get(key);
|
|
64
|
+
if (previous) {
|
|
65
|
+
previous.push(value);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
matchedValues.set(key, [value]);
|
|
69
|
+
};
|
|
70
|
+
const popValue = (key) => {
|
|
71
|
+
const previous = matchedValues.get(key);
|
|
72
|
+
if (!previous || previous.length === 0) return;
|
|
73
|
+
previous.pop();
|
|
74
|
+
if (previous.length === 0) matchedValues.delete(key);
|
|
75
|
+
};
|
|
76
|
+
const consumeRepeatableToken = (key, startIndex, count) => {
|
|
77
|
+
for (let index = 0; index < count; index += 1) pushValue(key, decodeRouteParamSegment(targetSegments[startIndex + index]));
|
|
78
|
+
return () => {
|
|
79
|
+
for (let index = 0; index < count; index += 1) popValue(key);
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const matchRecursively = (templateIndex, targetIndex) => {
|
|
83
|
+
if (templateIndex >= templateSegments.length) return targetIndex >= targetSegments.length;
|
|
84
|
+
const templateSegment = templateSegments[templateIndex];
|
|
85
|
+
const token = parsePathParamToken(templateSegment);
|
|
86
|
+
if (!token) {
|
|
87
|
+
if (targetIndex >= targetSegments.length || templateSegment !== targetSegments[targetIndex]) return false;
|
|
88
|
+
return matchRecursively(templateIndex + 1, targetIndex + 1);
|
|
89
|
+
}
|
|
90
|
+
if (token.modifier === "") {
|
|
91
|
+
if (targetIndex >= targetSegments.length) return false;
|
|
92
|
+
pushValue(token.key, decodeRouteParamSegment(targetSegments[targetIndex]));
|
|
93
|
+
const matched = matchRecursively(templateIndex + 1, targetIndex + 1);
|
|
94
|
+
if (!matched) popValue(token.key);
|
|
95
|
+
return matched;
|
|
96
|
+
}
|
|
97
|
+
if (token.modifier === "?") {
|
|
98
|
+
if (targetIndex < targetSegments.length) {
|
|
99
|
+
pushValue(token.key, decodeRouteParamSegment(targetSegments[targetIndex]));
|
|
100
|
+
if (matchRecursively(templateIndex + 1, targetIndex + 1)) return true;
|
|
101
|
+
popValue(token.key);
|
|
102
|
+
}
|
|
103
|
+
return matchRecursively(templateIndex + 1, targetIndex);
|
|
104
|
+
}
|
|
105
|
+
const minimumCount = token.modifier === "+" ? 1 : 0;
|
|
106
|
+
const maximumCount = targetSegments.length - targetIndex;
|
|
107
|
+
for (let count = maximumCount; count >= minimumCount; count -= 1) {
|
|
108
|
+
const rollback = consumeRepeatableToken(token.key, targetIndex, count);
|
|
109
|
+
if (matchRecursively(templateIndex + 1, targetIndex + count)) return true;
|
|
110
|
+
rollback();
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
if (!matchRecursively(0, 0)) return;
|
|
115
|
+
return buildRouteParamsFromMatch(matchedValues);
|
|
116
|
+
}
|
|
117
|
+
function resolveMatchedRouteRecord(target, lookup) {
|
|
118
|
+
if (target.name) {
|
|
119
|
+
const byName = lookup.recordByName.get(target.name);
|
|
120
|
+
if (byName) return {
|
|
121
|
+
record: byName,
|
|
122
|
+
matchedRecords: resolveMatchedRouteRecordChain(byName, lookup)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const staticNamedRoute = lookup.nameByStaticPath.get(target.path);
|
|
126
|
+
if (staticNamedRoute) {
|
|
127
|
+
const record = lookup.recordByName.get(staticNamedRoute);
|
|
128
|
+
if (record) return {
|
|
129
|
+
record,
|
|
130
|
+
matchedRecords: resolveMatchedRouteRecordChain(record, lookup),
|
|
131
|
+
matchedPath: target.path
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
for (const record of lookup.recordByName.values()) for (const routePath of listRouteRecordMatchPaths(record)) {
|
|
135
|
+
if (!isDynamicRoutePath(routePath)) continue;
|
|
136
|
+
const matchedParams = matchRoutePathParams(routePath, target.path);
|
|
137
|
+
if (!matchedParams) continue;
|
|
138
|
+
return {
|
|
139
|
+
record,
|
|
140
|
+
matchedRecords: resolveMatchedRouteRecordChain(record, lookup),
|
|
141
|
+
matchedPath: routePath,
|
|
142
|
+
params: matchedParams
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { collectRouteNamesForRemoval, mergeMatchedRouteMeta, resolveMatchedRouteRecord };
|
|
149
|
+
//# sourceMappingURL=matching.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matching.mjs","names":[],"sources":["../../../src/routerInternal/matching.ts"],"sourcesContent":["import type {\n RouteLocationNormalizedLoaded,\n RouteMeta,\n RouteParams,\n} from '../router'\nimport type {\n MatchedRouteRecordResolveResult,\n NamedRouteLookup,\n RouteRecordNormalized,\n} from './types'\nimport { decodeRouteParamSegment, parsePathParamToken } from './params'\nimport { isDynamicRoutePath } from './path'\n\nfunction splitRoutePathSegments(path: string): string[] {\n return path.split('/').filter(Boolean)\n}\n\nfunction listRouteRecordMatchPaths(record: RouteRecordNormalized): readonly string[] {\n return [record.path, ...record.aliasPaths]\n}\n\nfunction resolveMatchedRouteRecordChain(\n record: RouteRecordNormalized,\n lookup: NamedRouteLookup,\n): RouteRecordNormalized[] {\n const matchedRecords: RouteRecordNormalized[] = []\n const visitedNames = new Set<string>()\n let currentRecord: RouteRecordNormalized | undefined = record\n\n while (currentRecord) {\n if (visitedNames.has(currentRecord.name)) {\n break\n }\n visitedNames.add(currentRecord.name)\n matchedRecords.unshift(currentRecord)\n if (!currentRecord.parentName) {\n break\n }\n currentRecord = lookup.recordByName.get(currentRecord.parentName)\n }\n\n return matchedRecords\n}\n\nexport function mergeMatchedRouteMeta(matchedRecords: readonly RouteRecordNormalized[]): RouteMeta | undefined {\n let mergedRouteMeta: RouteMeta | undefined\n for (const matchedRecord of matchedRecords) {\n if (!matchedRecord.meta) {\n continue\n }\n if (!mergedRouteMeta) {\n mergedRouteMeta = {}\n }\n Object.assign(mergedRouteMeta, matchedRecord.meta)\n }\n return mergedRouteMeta\n}\n\nexport function collectRouteNamesForRemoval(\n routeName: string,\n recordByName: ReadonlyMap<string, RouteRecordNormalized>,\n): Set<string> {\n const namesToRemove = new Set<string>()\n if (!recordByName.has(routeName)) {\n return namesToRemove\n }\n\n namesToRemove.add(routeName)\n let expanded = true\n while (expanded) {\n expanded = false\n for (const [name, record] of recordByName.entries()) {\n if (!record.parentName || namesToRemove.has(name)) {\n continue\n }\n if (namesToRemove.has(record.parentName)) {\n namesToRemove.add(name)\n expanded = true\n }\n }\n }\n\n return namesToRemove\n}\n\nfunction buildRouteParamsFromMatch(matchValues: ReadonlyMap<string, string[]>): RouteParams {\n const params: RouteParams = {}\n for (const [key, values] of matchValues.entries()) {\n if (values.length === 0) {\n continue\n }\n params[key] = values.length === 1 ? values[0] : values\n }\n return params\n}\n\nfunction matchRoutePathParams(pathTemplate: string, targetPath: string): RouteParams | undefined {\n const templateSegments = splitRoutePathSegments(pathTemplate)\n const targetSegments = splitRoutePathSegments(targetPath)\n const matchedValues = new Map<string, string[]>()\n\n const pushValue = (key: string, value: string) => {\n const previous = matchedValues.get(key)\n if (previous) {\n previous.push(value)\n return\n }\n matchedValues.set(key, [value])\n }\n\n const popValue = (key: string) => {\n const previous = matchedValues.get(key)\n if (!previous || previous.length === 0) {\n return\n }\n previous.pop()\n if (previous.length === 0) {\n matchedValues.delete(key)\n }\n }\n\n const consumeRepeatableToken = (key: string, startIndex: number, count: number): () => void => {\n for (let index = 0; index < count; index += 1) {\n pushValue(key, decodeRouteParamSegment(targetSegments[startIndex + index]))\n }\n return () => {\n for (let index = 0; index < count; index += 1) {\n popValue(key)\n }\n }\n }\n\n const matchRecursively = (templateIndex: number, targetIndex: number): boolean => {\n if (templateIndex >= templateSegments.length) {\n return targetIndex >= targetSegments.length\n }\n\n const templateSegment = templateSegments[templateIndex]\n const token = parsePathParamToken(templateSegment)\n if (!token) {\n if (targetIndex >= targetSegments.length || templateSegment !== targetSegments[targetIndex]) {\n return false\n }\n return matchRecursively(templateIndex + 1, targetIndex + 1)\n }\n\n if (token.modifier === '') {\n if (targetIndex >= targetSegments.length) {\n return false\n }\n pushValue(token.key, decodeRouteParamSegment(targetSegments[targetIndex]))\n const matched = matchRecursively(templateIndex + 1, targetIndex + 1)\n if (!matched) {\n popValue(token.key)\n }\n return matched\n }\n\n if (token.modifier === '?') {\n if (targetIndex < targetSegments.length) {\n pushValue(token.key, decodeRouteParamSegment(targetSegments[targetIndex]))\n const consumeMatched = matchRecursively(templateIndex + 1, targetIndex + 1)\n if (consumeMatched) {\n return true\n }\n popValue(token.key)\n }\n return matchRecursively(templateIndex + 1, targetIndex)\n }\n\n const minimumCount = token.modifier === '+' ? 1 : 0\n const maximumCount = targetSegments.length - targetIndex\n\n for (let count = maximumCount; count >= minimumCount; count -= 1) {\n const rollback = consumeRepeatableToken(token.key, targetIndex, count)\n const matched = matchRecursively(templateIndex + 1, targetIndex + count)\n if (matched) {\n return true\n }\n rollback()\n }\n\n return false\n }\n\n if (!matchRecursively(0, 0)) {\n return undefined\n }\n\n return buildRouteParamsFromMatch(matchedValues)\n}\n\nexport function resolveMatchedRouteRecord(\n target: RouteLocationNormalizedLoaded,\n lookup: NamedRouteLookup,\n): MatchedRouteRecordResolveResult | undefined {\n if (target.name) {\n const byName = lookup.recordByName.get(target.name)\n if (byName) {\n return {\n record: byName,\n matchedRecords: resolveMatchedRouteRecordChain(byName, lookup),\n }\n }\n }\n\n const staticNamedRoute = lookup.nameByStaticPath.get(target.path)\n if (staticNamedRoute) {\n const record = lookup.recordByName.get(staticNamedRoute)\n if (record) {\n return {\n record,\n matchedRecords: resolveMatchedRouteRecordChain(record, lookup),\n matchedPath: target.path,\n }\n }\n }\n\n for (const record of lookup.recordByName.values()) {\n for (const routePath of listRouteRecordMatchPaths(record)) {\n if (!isDynamicRoutePath(routePath)) {\n continue\n }\n const matchedParams = matchRoutePathParams(routePath, target.path)\n if (!matchedParams) {\n continue\n }\n return {\n record,\n matchedRecords: resolveMatchedRouteRecordChain(record, lookup),\n matchedPath: routePath,\n params: matchedParams,\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;AAaA,SAAS,uBAAuB,MAAwB;CACtD,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;AACvC;AAEA,SAAS,0BAA0B,QAAkD;CACnF,OAAO,CAAC,OAAO,MAAM,GAAG,OAAO,UAAU;AAC3C;AAEA,SAAS,+BACP,QACA,QACyB;CACzB,MAAM,iBAA0C,CAAC;CACjD,MAAM,+BAAe,IAAI,IAAY;CACrC,IAAI,gBAA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EN_RE = /^:(\w+)(?:\([^)]*\))?([+*?])?$/;
|
|
5
|
+
function parsePathParamToken(segment) {
|
|
6
|
+
var _match$;
|
|
7
|
+
const match = PATH_PARAM_TOKEN_RE.exec(segment);
|
|
8
|
+
if (!match) return;
|
|
9
|
+
return {
|
|
10
|
+
key: match[1],
|
|
11
|
+
modifier: (_match$ = match[2]) !== null && _match$ !== void 0 ? _match$ : ""
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function normalizePathParamValues(value) {
|
|
15
|
+
if (value === void 0) return [];
|
|
16
|
+
if (Array.isArray(value)) return value;
|
|
17
|
+
return [value];
|
|
18
|
+
}
|
|
19
|
+
function stringifyPathParamSegment(value) {
|
|
20
|
+
return encodeURIComponent(value);
|
|
21
|
+
}
|
|
22
|
+
function decodeRouteParamSegment(value) {
|
|
23
|
+
try {
|
|
24
|
+
return decodeURIComponent(value);
|
|
25
|
+
} catch (_unused) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function resolveNamedRoutePath(pathTemplate, params, routeName) {
|
|
30
|
+
const resolvedSegments = [];
|
|
31
|
+
const consumedKeys = /* @__PURE__ */ new Set();
|
|
32
|
+
for (const rawSegment of pathTemplate.split("/")) {
|
|
33
|
+
if (!rawSegment) continue;
|
|
34
|
+
const token = parsePathParamToken(rawSegment);
|
|
35
|
+
if (!token) {
|
|
36
|
+
resolvedSegments.push(rawSegment);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const values = normalizePathParamValues(params[token.key]);
|
|
40
|
+
if (token.modifier === "") {
|
|
41
|
+
if (values.length !== 1) throw new Error(`Missing required param "${token.key}" for named route "${routeName}"`);
|
|
42
|
+
consumedKeys.add(token.key);
|
|
43
|
+
resolvedSegments.push(stringifyPathParamSegment(values[0]));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (token.modifier === "?") {
|
|
47
|
+
if (values.length === 0) continue;
|
|
48
|
+
if (values.length > 1) throw new Error(`Param "${token.key}" for named route "${routeName}" must be a single value`);
|
|
49
|
+
consumedKeys.add(token.key);
|
|
50
|
+
resolvedSegments.push(stringifyPathParamSegment(values[0]));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (token.modifier === "+") {
|
|
54
|
+
if (values.length === 0) throw new Error(`Missing required repeatable param "${token.key}" for named route "${routeName}"`);
|
|
55
|
+
consumedKeys.add(token.key);
|
|
56
|
+
for (const value of values) resolvedSegments.push(stringifyPathParamSegment(value));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (values.length > 0) consumedKeys.add(token.key);
|
|
60
|
+
for (const value of values) resolvedSegments.push(stringifyPathParamSegment(value));
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
path: resolvedSegments.join("/"),
|
|
64
|
+
consumedKeys
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function hasNonEmptyRouteParamValue(value) {
|
|
68
|
+
if (value === void 0) return false;
|
|
69
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
function assertNoUnexpectedNamedRouteParams(params, consumedKeys, routeName) {
|
|
73
|
+
const unexpectedKeys = Object.keys(params).filter((key) => !consumedKeys.has(key)).filter((key) => hasNonEmptyRouteParamValue(params[key]));
|
|
74
|
+
if (unexpectedKeys.length === 0) return;
|
|
75
|
+
throw new Error(`Unexpected params for named route "${routeName}": ${unexpectedKeys.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
function resolveNamedRouteLocation(to, lookup, paramsMode) {
|
|
78
|
+
const routeName = to.name;
|
|
79
|
+
if (typeof routeName !== "string" || !routeName) return to;
|
|
80
|
+
if (to.path !== void 0 || to.fullPath !== void 0) return to;
|
|
81
|
+
const routeRecord = lookup.recordByName.get(routeName);
|
|
82
|
+
if (!routeRecord) throw new Error(`Named route "${routeName}" is not defined in createRouter({ routes | namedRoutes })`);
|
|
83
|
+
const params = to.params ? normalizeRouteParams(to.params) : {};
|
|
84
|
+
const resolvedResult = resolveNamedRoutePath(routeRecord.path, params, routeName);
|
|
85
|
+
if (paramsMode === "strict") assertNoUnexpectedNamedRouteParams(params, resolvedResult.consumedKeys, routeName);
|
|
86
|
+
return {
|
|
87
|
+
...to,
|
|
88
|
+
path: resolvedResult.path ? `/${resolvedResult.path}` : "/",
|
|
89
|
+
params
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { decodeRouteParamSegment, parsePathParamToken, resolveNamedRouteLocation };
|
|
95
|
+
//# sourceMappingURL=params.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.mjs","names":[],"sources":["../../../src/routerInternal/params.ts"],"sourcesContent":["import type {\n RouteLocationRaw,\n RouteParams,\n RouteParamsMode,\n RouteParamValue,\n} from '../router'\nimport type {\n NamedRouteLookup,\n NamedRoutePathResolveResult,\n PathParamToken,\n} from './types'\nimport { normalizeRouteParams } from './query'\n\nconst PATH_PARAM_TOKEN_RE = /^:(\\w+)(?:\\([^)]*\\))?([+*?])?$/\n\nexport function parsePathParamToken(segment: string): PathParamToken | undefined {\n const match = PATH_PARAM_TOKEN_RE.exec(segment)\n if (!match) {\n return undefined\n }\n\n return {\n key: match[1],\n modifier: (match[2] ?? '') as PathParamToken['modifier'],\n }\n}\n\nfunction normalizePathParamValues(value: RouteParamValue | RouteParamValue[] | undefined): RouteParamValue[] {\n if (value === undefined) {\n return []\n }\n if (Array.isArray(value)) {\n return value\n }\n return [value]\n}\n\nfunction stringifyPathParamSegment(value: RouteParamValue): string {\n return encodeURIComponent(value)\n}\n\nexport function decodeRouteParamSegment(value: string): string {\n try {\n return decodeURIComponent(value)\n }\n catch {\n return value\n }\n}\n\nfunction resolveNamedRoutePath(pathTemplate: string, params: RouteParams, routeName: string): NamedRoutePathResolveResult {\n const resolvedSegments: string[] = []\n const consumedKeys = new Set<string>()\n for (const rawSegment of pathTemplate.split('/')) {\n if (!rawSegment) {\n continue\n }\n\n const token = parsePathParamToken(rawSegment)\n if (!token) {\n resolvedSegments.push(rawSegment)\n continue\n }\n\n const values = normalizePathParamValues(params[token.key])\n if (token.modifier === '') {\n if (values.length !== 1) {\n throw new Error(`Missing required param \"${token.key}\" for named route \"${routeName}\"`)\n }\n consumedKeys.add(token.key)\n resolvedSegments.push(stringifyPathParamSegment(values[0]))\n continue\n }\n\n if (token.modifier === '?') {\n if (values.length === 0) {\n continue\n }\n if (values.length > 1) {\n throw new Error(`Param \"${token.key}\" for named route \"${routeName}\" must be a single value`)\n }\n consumedKeys.add(token.key)\n resolvedSegments.push(stringifyPathParamSegment(values[0]))\n continue\n }\n\n if (token.modifier === '+') {\n if (values.length === 0) {\n throw new Error(`Missing required repeatable param \"${token.key}\" for named route \"${routeName}\"`)\n }\n consumedKeys.add(token.key)\n for (const value of values) {\n resolvedSegments.push(stringifyPathParamSegment(value))\n }\n continue\n }\n\n if (values.length > 0) {\n consumedKeys.add(token.key)\n }\n for (const value of values) {\n resolvedSegments.push(stringifyPathParamSegment(value))\n }\n }\n\n return {\n path: resolvedSegments.join('/'),\n consumedKeys,\n }\n}\n\nfunction hasNonEmptyRouteParamValue(value: RouteParamValue | RouteParamValue[] | undefined): boolean {\n if (value === undefined) {\n return false\n }\n if (Array.isArray(value)) {\n return value.length > 0\n }\n return true\n}\n\nfunction assertNoUnexpectedNamedRouteParams(\n params: RouteParams,\n consumedKeys: ReadonlySet<string>,\n routeName: string,\n) {\n const unexpectedKeys = Object.keys(params)\n .filter(key => !consumedKeys.has(key))\n .filter(key => hasNonEmptyRouteParamValue(params[key]))\n\n if (unexpectedKeys.length === 0) {\n return\n }\n\n throw new Error(`Unexpected params for named route \"${routeName}\": ${unexpectedKeys.join(', ')}`)\n}\n\nexport function resolveNamedRouteLocation(\n to: Extract<RouteLocationRaw, Record<string, unknown>>,\n lookup: NamedRouteLookup,\n paramsMode: RouteParamsMode,\n): Extract<RouteLocationRaw, Record<string, unknown>> {\n const routeName = to.name\n if (typeof routeName !== 'string' || !routeName) {\n return to\n }\n if (to.path !== undefined || to.fullPath !== undefined) {\n return to\n }\n\n const routeRecord = lookup.recordByName.get(routeName)\n if (!routeRecord) {\n throw new Error(`Named route \"${routeName}\" is not defined in createRouter({ routes | namedRoutes })`)\n }\n\n const params = to.params\n ? normalizeRouteParams(to.params)\n : {}\n const resolvedResult = resolveNamedRoutePath(routeRecord.path, params, routeName)\n if (paramsMode === 'strict') {\n assertNoUnexpectedNamedRouteParams(params, resolvedResult.consumedKeys, routeName)\n }\n\n return {\n ...to,\n path: resolvedResult.path ? `/${resolvedResult.path}` : '/',\n params,\n }\n}\n"],"mappings":";;;AAaA,MAAM,sBAAsB;AAE5B,SAAgB,oBAAoB,SAA6C;;CAC/E,MAAM,QAAQ,oBAAoB,KAAK,OAAO;CAC9C,IAAI,CAAC,OACH;CAGF,OAAO;EACL,KAAK,MAAM;EACX,qBAAW,MAAM,+CAAM;CACzB;AACF;AAEA,SAAS,yBAAyB,OAA2E;CAC3G,IAAI,UAAU,QACZ,OAAO,CAAC;CAEV,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAET,OAAO,CAAC,KAAK;AACf;AAEA,SAAS,0BAA0B,OAAgC;CACjE,OAAO,mBAAmB,KAAK;AACjC;AAEA,SAAgB,wBAAwB,OAAuB;CAC7D,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,kBACM;EACJ,OAAO;CACT;AACF;AAEA,SAAS,sBAAsB,cAAsB,QAAqB,WAAgD;CACxH,MAAM,mBAA6B,CAAC;CACpC,MAAM,+BAAe,IAAI,IAAY;CACrC,KAAK,MAAM,cAAc,aAAa,MAAM,GAAG,GAAG;EAChD,IAAI,CAAC,YACH;EAGF,MAAM,QAAQ,oBAAoB,UAAU;EAC5C,IAAI,CAAC,OAAO;GACV,iBAAiB,KAAK,UAAU;GAChC;EACF;EAEA,MAAM,SAAS,yBAAyB,OAAO,MAAM,IAAI;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C,UAAU,KAAK,eAAe,KAAK,IAAI,GAAG;AAClG;AAEA,SAAgB,0BACd,IACA,QACA,YACoD;CACpD,MAAM,YAAY,GAAG;CACrB,IAAI,OAAO,cAAc,YAAY,CAAC,WACpC,OAAO;CAET,IAAI,GAAG,SAAS,UAAa,GAAG,aAAa,QAC3C,OAAO;CAGT,MAAM,cAAc,OAAO,aAAa,IAAI,SAAS;CACrD,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,gBAAgB,UAAU,2DAA2D;CAGvG,MAAM,SAAS,GAAG,SACd,qBAAqB,GAAG,MAAM,IAC9B,CAAC;CACL,MAAM,iBAAiB,sBAAsB,YAAY,MAAM,QAAQ,SAAS;CAChF,IAAI,eAAe,UACjB,mCAAmC,QAAQ,eAAe,cAAc,SAAS;CAGnF,OAAO;EACL,GAAG;EACH,MAAM,eAAe,OAAO,IAAI,eAAe,SAAS;EACxD;CACF;AACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/routerInternal/path.ts
|
|
2
|
+
function normalizePathSegments(path) {
|
|
3
|
+
const segments = [];
|
|
4
|
+
for (const segment of path.split("/")) {
|
|
5
|
+
if (!segment || segment === ".") continue;
|
|
6
|
+
if (segment === "..") {
|
|
7
|
+
if (segments.length > 0) segments.pop();
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
segments.push(segment);
|
|
11
|
+
}
|
|
12
|
+
return segments;
|
|
13
|
+
}
|
|
14
|
+
function resolvePath(path, currentPath) {
|
|
15
|
+
if (!path) return normalizePathSegments(currentPath).join("/");
|
|
16
|
+
if (path.startsWith("/")) return normalizePathSegments(path).join("/");
|
|
17
|
+
if (path.startsWith("./") || path.startsWith("../")) {
|
|
18
|
+
const baseSegments = normalizePathSegments(currentPath);
|
|
19
|
+
if (baseSegments.length > 0) baseSegments.pop();
|
|
20
|
+
for (const segment of path.split("/")) {
|
|
21
|
+
if (!segment || segment === ".") continue;
|
|
22
|
+
if (segment === "..") {
|
|
23
|
+
if (baseSegments.length > 0) baseSegments.pop();
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
baseSegments.push(segment);
|
|
27
|
+
}
|
|
28
|
+
return baseSegments.join("/");
|
|
29
|
+
}
|
|
30
|
+
return normalizePathSegments(path).join("/");
|
|
31
|
+
}
|
|
32
|
+
function createAbsoluteRoutePath(path) {
|
|
33
|
+
return path ? `/${path}` : "/";
|
|
34
|
+
}
|
|
35
|
+
const DYNAMIC_ROUTE_RE = /(?:^|\/):/;
|
|
36
|
+
function isDynamicRoutePath(path) {
|
|
37
|
+
return DYNAMIC_ROUTE_RE.test(path);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createAbsoluteRoutePath, isDynamicRoutePath, resolvePath };
|
|
42
|
+
//# sourceMappingURL=path.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.mjs","names":[],"sources":["../../../src/routerInternal/path.ts"],"sourcesContent":["function normalizePathSegments(path: string): string[] {\n const segments: string[] = []\n for (const segment of path.split('/')) {\n if (!segment || segment === '.') {\n continue\n }\n if (segment === '..') {\n if (segments.length > 0) {\n segments.pop()\n }\n continue\n }\n segments.push(segment)\n }\n return segments\n}\n\nexport function resolvePath(path: string, currentPath: string): string {\n if (!path) {\n return normalizePathSegments(currentPath).join('/')\n }\n\n if (path.startsWith('/')) {\n return normalizePathSegments(path).join('/')\n }\n\n if (path.startsWith('./') || path.startsWith('../')) {\n const baseSegments = normalizePathSegments(currentPath)\n if (baseSegments.length > 0) {\n baseSegments.pop()\n }\n\n for (const segment of path.split('/')) {\n if (!segment || segment === '.') {\n continue\n }\n if (segment === '..') {\n if (baseSegments.length > 0) {\n baseSegments.pop()\n }\n continue\n }\n baseSegments.push(segment)\n }\n\n return baseSegments.join('/')\n }\n\n return normalizePathSegments(path).join('/')\n}\n\nexport function createAbsoluteRoutePath(path: string): string {\n return path ? `/${path}` : '/'\n}\n\nconst DYNAMIC_ROUTE_RE = /(?:^|\\/):/\n\nexport function isDynamicRoutePath(path: string): boolean {\n return DYNAMIC_ROUTE_RE.test(path)\n}\n"],"mappings":";AAAA,SAAS,sBAAsB,MAAwB;CACrD,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,WAAW,KAAK,MAAM,GAAG,GAAG;EACrC,IAAI,CAAC,WAAW,YAAY,KAC1B;EAEF,IAAI,YAAY,MAAM;GACpB,IAAI,SAAS,SAAS,GACpB,SAAS,IAAI;GAEf;EACF;EACA,SAAS,KAAK,OAAO;CACvB;CACA,OAAO;AACT;AAEA,SAAgB,YAAY,MAAc,aAA6B;CACrE,IAAI,CAAC,MACH,OAAO,sBAAsB,WAAW,CAAC,CAAC,KAAK,GAAG;CAGpD,IAAI,KAAK,WAAW,GAAG,GACrB,OAAO,sBAAsB,IAAI,CAAC,CAAC,KAAK,GAAG;CAG7C,IAAI,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK,GAAG;EACnD,MAAM,eAAe,sBAAsB,WAAW;EACtD,IAAI,aAAa,SAAS,GACxB,aAAa,IAAI;EAGnB,KAAK,MAAM,WAAW,KAAK,MAAM,GAAG,GAAG;GACrC,IAAI,CAAC,WAAW,YAAY,KAC1B;GAEF,IAAI,YAAY,MAAM;IACpB,IAAI,aAAa,SAAS,GACxB,aAAa,IAAI;IAEnB;GACF;GACA,aAAa,KAAK,OAAO;EAC3B;EAEA,OAAO,aAAa,KAAK,GAAG;CAC9B;CAEA,OAAO,sBAAsB,IAAI,CAAC,CAAC,KAAK,GAAG;AAC7C;AAEA,SAAgB,wBAAwB,MAAsB;CAC5D,OAAO,OAAO,IAAI,SAAS;AAC7B;AAEA,MAAM,mBAAmB;AAEzB,SAAgB,mBAAmB,MAAuB;CACxD,OAAO,iBAAiB,KAAK,IAAI;AACnC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//#region src/routerInternal/query.ts
|
|
2
|
+
const PLUS_RE = /\+/g;
|
|
3
|
+
function decodeQuerySegment(value) {
|
|
4
|
+
return decodeURIComponent(value.replace(PLUS_RE, " "));
|
|
5
|
+
}
|
|
6
|
+
function encodeQuerySegment(value) {
|
|
7
|
+
return encodeURIComponent(value);
|
|
8
|
+
}
|
|
9
|
+
function pushQueryValue(target, key, value) {
|
|
10
|
+
const previous = target[key];
|
|
11
|
+
if (previous === void 0) {
|
|
12
|
+
target[key] = value;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(previous)) {
|
|
16
|
+
previous.push(value);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
target[key] = [previous, value];
|
|
20
|
+
}
|
|
21
|
+
function pushRouteParamValue(target, key, value) {
|
|
22
|
+
const previous = target[key];
|
|
23
|
+
if (previous === void 0) {
|
|
24
|
+
target[key] = value;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(previous)) {
|
|
28
|
+
previous.push(value);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
target[key] = [previous, value];
|
|
32
|
+
}
|
|
33
|
+
function normalizeQueryValue(value) {
|
|
34
|
+
if (value === void 0) return;
|
|
35
|
+
if (value === null) return null;
|
|
36
|
+
return String(value);
|
|
37
|
+
}
|
|
38
|
+
function normalizeQuery(query) {
|
|
39
|
+
const normalized = {};
|
|
40
|
+
for (const key of Object.keys(query)) {
|
|
41
|
+
const rawValue = query[key];
|
|
42
|
+
if (Array.isArray(rawValue)) {
|
|
43
|
+
for (const item of rawValue) {
|
|
44
|
+
const next = normalizeQueryValue(item);
|
|
45
|
+
if (next !== void 0) pushQueryValue(normalized, key, next);
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const next = normalizeQueryValue(rawValue);
|
|
50
|
+
if (next !== void 0) pushQueryValue(normalized, key, next);
|
|
51
|
+
}
|
|
52
|
+
return normalized;
|
|
53
|
+
}
|
|
54
|
+
function normalizeRouteParamValue(value) {
|
|
55
|
+
if (value === void 0 || value === null) return;
|
|
56
|
+
return String(value);
|
|
57
|
+
}
|
|
58
|
+
function normalizeRouteParams(params) {
|
|
59
|
+
const normalized = {};
|
|
60
|
+
for (const key of Object.keys(params)) {
|
|
61
|
+
const rawValue = params[key];
|
|
62
|
+
if (Array.isArray(rawValue)) {
|
|
63
|
+
for (const item of rawValue) {
|
|
64
|
+
const next = normalizeRouteParamValue(item);
|
|
65
|
+
if (next !== void 0) pushRouteParamValue(normalized, key, next);
|
|
66
|
+
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const next = normalizeRouteParamValue(rawValue);
|
|
70
|
+
if (next !== void 0) pushRouteParamValue(normalized, key, next);
|
|
71
|
+
}
|
|
72
|
+
return normalized;
|
|
73
|
+
}
|
|
74
|
+
function normalizeHash(rawHash) {
|
|
75
|
+
if (!rawHash) return "";
|
|
76
|
+
return rawHash.startsWith("#") ? rawHash : `#${rawHash}`;
|
|
77
|
+
}
|
|
78
|
+
function parseQuery(search) {
|
|
79
|
+
const normalizedSearch = search.startsWith("?") ? search.slice(1) : search;
|
|
80
|
+
const query = {};
|
|
81
|
+
if (!normalizedSearch) return query;
|
|
82
|
+
for (const segment of normalizedSearch.split("&")) {
|
|
83
|
+
if (!segment) continue;
|
|
84
|
+
const equalIndex = segment.indexOf("=");
|
|
85
|
+
const rawKey = equalIndex >= 0 ? segment.slice(0, equalIndex) : segment;
|
|
86
|
+
if (!rawKey) continue;
|
|
87
|
+
pushQueryValue(query, decodeQuerySegment(rawKey), equalIndex >= 0 ? decodeQuerySegment(segment.slice(equalIndex + 1)) : null);
|
|
88
|
+
}
|
|
89
|
+
return query;
|
|
90
|
+
}
|
|
91
|
+
function stringifyQuery(query = {}) {
|
|
92
|
+
const normalizedQuery = normalizeQuery(query);
|
|
93
|
+
const segments = [];
|
|
94
|
+
for (const key of Object.keys(normalizedQuery)) {
|
|
95
|
+
const encodedKey = encodeQuerySegment(key);
|
|
96
|
+
const rawValue = normalizedQuery[key];
|
|
97
|
+
if (Array.isArray(rawValue)) {
|
|
98
|
+
for (const item of rawValue) if (item === null) segments.push(encodedKey);
|
|
99
|
+
else segments.push(`${encodedKey}=${encodeQuerySegment(item)}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (rawValue === null) {
|
|
103
|
+
segments.push(encodedKey);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
segments.push(`${encodedKey}=${encodeQuerySegment(rawValue)}`);
|
|
107
|
+
}
|
|
108
|
+
return segments.join("&");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { normalizeHash, normalizeQuery, normalizeRouteParams, parseQuery, stringifyQuery };
|
|
113
|
+
//# sourceMappingURL=query.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.mjs","names":[],"sources":["../../../src/routerInternal/query.ts"],"sourcesContent":["import type {\n LocationQuery,\n LocationQueryRaw,\n LocationQueryValue,\n LocationQueryValueRaw,\n RouteParams,\n RouteParamsRaw,\n RouteParamValue,\n RouteParamValueRaw,\n} from '../router'\n\nconst PLUS_RE = /\\+/g\n\nfunction decodeQuerySegment(value: string): string {\n return decodeURIComponent(value.replace(PLUS_RE, ' '))\n}\n\nfunction encodeQuerySegment(value: string): string {\n return encodeURIComponent(value)\n}\n\nfunction pushQueryValue(target: LocationQuery, key: string, value: LocationQueryValue) {\n const previous = target[key]\n if (previous === undefined) {\n target[key] = value\n return\n }\n if (Array.isArray(previous)) {\n previous.push(value)\n return\n }\n target[key] = [previous, value]\n}\n\nfunction pushRouteParamValue(target: RouteParams, key: string, value: RouteParamValue) {\n const previous = target[key]\n if (previous === undefined) {\n target[key] = value\n return\n }\n if (Array.isArray(previous)) {\n previous.push(value)\n return\n }\n target[key] = [previous, value]\n}\n\nfunction normalizeQueryValue(value: LocationQueryValueRaw): LocationQueryValue | undefined {\n if (value === undefined) {\n return undefined\n }\n if (value === null) {\n return null\n }\n return String(value)\n}\n\nexport function normalizeQuery(query: LocationQueryRaw | LocationQuery): LocationQuery {\n const normalized: LocationQuery = {}\n for (const key of Object.keys(query)) {\n const rawValue = (query as Record<string, LocationQueryValueRaw | LocationQueryValueRaw[]>)[key]\n if (Array.isArray(rawValue)) {\n for (const item of rawValue) {\n const next = normalizeQueryValue(item)\n if (next !== undefined) {\n pushQueryValue(normalized, key, next)\n }\n }\n continue\n }\n const next = normalizeQueryValue(rawValue)\n if (next !== undefined) {\n pushQueryValue(normalized, key, next)\n }\n }\n return normalized\n}\n\nfunction normalizeRouteParamValue(value: RouteParamValueRaw): RouteParamValue | undefined {\n if (value === undefined || value === null) {\n return undefined\n }\n return String(value)\n}\n\nexport function normalizeRouteParams(params: RouteParamsRaw | RouteParams): RouteParams {\n const normalized: RouteParams = {}\n for (const key of Object.keys(params)) {\n const rawValue = (params as Record<string, RouteParamValueRaw | RouteParamValueRaw[]>)[key]\n if (Array.isArray(rawValue)) {\n for (const item of rawValue) {\n const next = normalizeRouteParamValue(item)\n if (next !== undefined) {\n pushRouteParamValue(normalized, key, next)\n }\n }\n continue\n }\n const next = normalizeRouteParamValue(rawValue)\n if (next !== undefined) {\n pushRouteParamValue(normalized, key, next)\n }\n }\n return normalized\n}\n\nexport function normalizeHash(rawHash?: string): string {\n if (!rawHash) {\n return ''\n }\n return rawHash.startsWith('#') ? rawHash : `#${rawHash}`\n}\n\nexport function parseQuery(search: string): LocationQuery {\n const normalizedSearch = search.startsWith('?') ? search.slice(1) : search\n const query: LocationQuery = {}\n\n if (!normalizedSearch) {\n return query\n }\n\n for (const segment of normalizedSearch.split('&')) {\n if (!segment) {\n continue\n }\n\n const equalIndex = segment.indexOf('=')\n const rawKey = equalIndex >= 0 ? segment.slice(0, equalIndex) : segment\n if (!rawKey) {\n continue\n }\n\n const key = decodeQuerySegment(rawKey)\n const value = equalIndex >= 0\n ? decodeQuerySegment(segment.slice(equalIndex + 1))\n : null\n\n pushQueryValue(query, key, value)\n }\n\n return query\n}\n\nexport function stringifyQuery(query: LocationQueryRaw | LocationQuery = {}): string {\n const normalizedQuery = normalizeQuery(query)\n const segments: string[] = []\n\n for (const key of Object.keys(normalizedQuery)) {\n const encodedKey = encodeQuerySegment(key)\n const rawValue = normalizedQuery[key]\n\n if (Array.isArray(rawValue)) {\n for (const item of rawValue) {\n if (item === null) {\n segments.push(encodedKey)\n }\n else {\n segments.push(`${encodedKey}=${encodeQuerySegment(item)}`)\n }\n }\n continue\n }\n\n if (rawValue === null) {\n segments.push(encodedKey)\n continue\n }\n\n segments.push(`${encodedKey}=${encodeQuerySegment(rawValue)}`)\n }\n\n return segments.join('&')\n}\n"],"mappings":";AAWA,MAAM,UAAU;AAEhB,SAAS,mBAAmB,OAAuB;CACjD,OAAO,mBAAmB,MAAM,QAAQ,SAAS,GAAG,CAAC;AACvD;AAEA,SAAS,mBAAmB,OAAuB;CACjD,OAAO,mBAAmB,KAAK;AACjC;AAEA,SAAS,eAAe,QAAuB,KAAa,OAA2B;CACrF,MAAM,WAAW,OAAO;CACxB,IAAI,aAAa,QAAW;EAC1B,OAAO,OAAO;EACd;CACF;CACA,IAAI,MAAM,QAAQ,QAAQ,GAAG;EAC3B,SAAS,KAAK,KAAK;EACnB;CACF;CACA,OAAO,OAAO,CAAC,UAAU,KAAK;AAChC;AAEA,SAAS,oBAAoB,QAAqB,KAAa,OAAwB;CACrF,MAAM,WAAW,OAAO;CACxB,IAAI,aAAa,QAAW;EAC1B,OAAO,OAAO;EACd;CACF;CACA,IAAI,MAAM,QAAQ,QAAQ,GAAG;EAC3B,SAAS,KAAK,KAAK;EACnB;CACF;CACA,OAAO,OAAO,CAAC,UAAU,KAAK;AAChC;AAEA,SAAS,oBAAoB,OAA8D;CACzF,IAAI,UAAU,QACZ;CAEF,IAAI,UAAU,MACZ,OAAO;CAET,OAAO,OAAO,KAAK;AACrB;AAEA,SAAgB,eAAe,OAAwD;CACrF,MAAM,aAA4B,CAAC;CACnC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,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