wevu 7.0.4 → 7.1.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/README.md +20 -4
- package/dist/alipay/jsx-runtime.d.mts +12 -0
- package/dist/alipay/jsx-runtime.mjs +1 -0
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/defineProperty.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPrimitive.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPropertyKey.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/typeof.mjs +1 -1
- package/dist/dev/api/vitest/setup.d.mts +1 -0
- package/dist/dev/api/vitest.d.mts +1 -0
- package/dist/dev/api.d.mts +1 -0
- package/dist/dev/compiler.d.mts +1 -0
- package/dist/dev/fetch.d.mts +9 -0
- package/dist/dev/index.d.mts +72 -0
- package/dist/dev/index.mjs +12 -15
- package/dist/dev/internal-reactivity.d.mts +18 -0
- package/dist/dev/internal-reactivity.mjs +3 -2
- package/dist/dev/internal-runtime.d.mts +44 -0
- package/dist/dev/internal-runtime.mjs +19 -14
- package/dist/dev/internal-template.d.mts +2 -0
- package/dist/dev/jsxTypes.d.mts +9 -0
- package/dist/dev/macros/shared.d.mts +81 -0
- package/dist/dev/macros.d.mts +71 -0
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/reactivity/asyncDerivation.d.mts +41 -0
- package/dist/dev/reactivity/asyncDerivation.mjs +130 -0
- package/dist/dev/reactivity/asyncDerivation.mjs.map +1 -0
- package/dist/dev/reactivity/computed.d.mts +21 -0
- package/dist/dev/reactivity/computed.mjs +2 -2
- package/dist/dev/reactivity/computed.mjs.map +1 -1
- package/dist/dev/reactivity/core.d.mts +35 -0
- package/dist/dev/reactivity/core.mjs +156 -32
- package/dist/dev/reactivity/core.mjs.map +1 -1
- package/dist/dev/reactivity/index.d.mts +16 -0
- package/dist/dev/reactivity/reactive/mutation.d.mts +21 -0
- package/dist/dev/reactivity/reactive/patch.d.mts +18 -0
- package/dist/dev/reactivity/reactive/shallow.d.mts +22 -0
- package/dist/dev/reactivity/reactive/shared.d.mts +4 -0
- package/dist/dev/reactivity/reactive.d.mts +42 -0
- package/dist/dev/reactivity/readonly.d.mts +27 -0
- package/dist/dev/reactivity/readonly.mjs.map +1 -1
- package/dist/dev/reactivity/ref.d.mts +27 -0
- package/dist/dev/reactivity/ref.mjs +1 -1
- package/dist/dev/reactivity/shallowRef.d.mts +19 -0
- package/dist/dev/reactivity/toRefs.d.mts +43 -0
- package/dist/dev/reactivity/traverse.d.mts +8 -0
- package/dist/dev/reactivity/watch/types.d.mts +43 -0
- package/dist/dev/reactivity/watch.d.mts +22 -0
- package/dist/dev/router/createRouter.d.mts +8 -0
- package/dist/dev/router/createRouter.mjs +16 -3
- package/dist/dev/router/createRouter.mjs.map +1 -1
- package/dist/dev/router/navigationCore.d.mts +6 -0
- package/dist/dev/router/resolve.d.mts +6 -0
- package/dist/dev/router/routeSync.d.mts +1 -0
- package/dist/dev/router/types.d.mts +172 -0
- package/dist/dev/router/useRoute.d.mts +19 -0
- package/dist/dev/router/useRoute.mjs +23 -5
- package/dist/dev/router/useRoute.mjs.map +1 -1
- package/dist/dev/router/useRouter.d.mts +8 -0
- package/dist/dev/router.d.mts +10 -0
- package/dist/dev/routerInternal/query.d.mts +7 -0
- package/dist/dev/routerInternal/types.d.mts +9 -0
- package/dist/dev/runtime/app/computed.mjs +2 -2
- package/dist/dev/runtime/app/computed.mjs.map +1 -1
- package/dist/dev/runtime/app/context.mjs +8 -2
- package/dist/dev/runtime/app/context.mjs.map +1 -1
- package/dist/dev/runtime/app/diagnostics.mjs +12 -0
- package/dist/dev/runtime/app/diagnostics.mjs.map +1 -1
- package/dist/dev/runtime/app/mount.mjs +31 -28
- package/dist/dev/runtime/app/mount.mjs.map +1 -1
- package/dist/dev/runtime/app/pending.d.mts +10 -0
- package/dist/dev/runtime/app/setData/commitTracker.d.mts +13 -0
- package/dist/dev/runtime/app/setData/commitTracker.mjs +265 -0
- package/dist/dev/runtime/app/setData/commitTracker.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +47 -51
- package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/scheduler.d.mts +51 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs +98 -111
- package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/snapshot.mjs +11 -1
- package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/app.d.mts +8 -0
- package/dist/dev/runtime/app.mjs +18 -6
- package/dist/dev/runtime/app.mjs.map +1 -1
- package/dist/dev/runtime/bindingManifest.mjs +105 -0
- package/dist/dev/runtime/bindingManifest.mjs.map +1 -0
- package/dist/dev/runtime/capabilities.d.mts +75 -0
- package/dist/dev/runtime/capabilities.mjs +40 -0
- package/dist/dev/runtime/capabilities.mjs.map +1 -0
- package/dist/dev/runtime/css.d.mts +14 -0
- package/dist/dev/runtime/defaults.d.mts +12 -0
- package/dist/dev/runtime/define/componentDefinition.mjs +3 -0
- package/dist/dev/runtime/define/componentDefinition.mjs.map +1 -1
- package/dist/dev/runtime/define/optionsApi.mjs +1 -1
- package/dist/dev/runtime/define/props.mjs +30 -60
- package/dist/dev/runtime/define/props.mjs.map +1 -1
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +37 -21
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -1
- package/dist/dev/runtime/define.d.mts +118 -0
- package/dist/dev/runtime/define.mjs +32 -44
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/diff.mjs +1 -1
- package/dist/dev/runtime/disposables.d.mts +31 -0
- package/dist/dev/runtime/elementIntersectionObserver.d.mts +26 -0
- package/dist/dev/runtime/features/inlineEvents.d.mts +7 -0
- package/dist/dev/runtime/features/inlineEvents.mjs +25 -0
- package/dist/dev/runtime/features/inlineEvents.mjs.map +1 -0
- package/dist/dev/runtime/features/layout.d.mts +7 -0
- package/dist/dev/runtime/features/layout.mjs +44 -0
- package/dist/dev/runtime/features/layout.mjs.map +1 -0
- package/dist/dev/runtime/features/patchStrategy.d.mts +7 -0
- package/dist/dev/runtime/features/patchStrategy.mjs +129 -0
- package/dist/dev/runtime/features/patchStrategy.mjs.map +1 -0
- package/dist/dev/runtime/features/publicLayout.d.mts +24 -0
- package/dist/dev/runtime/features/publicLayout.mjs +81 -0
- package/dist/dev/runtime/features/publicLayout.mjs.map +1 -0
- package/dist/dev/runtime/features/scopedSlots.d.mts +23 -0
- package/dist/dev/runtime/features/scopedSlots.mjs +88 -0
- package/dist/dev/runtime/features/scopedSlots.mjs.map +1 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.d.mts +7 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.mjs +15 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.mjs.map +1 -0
- package/dist/dev/runtime/features/templateRefs.d.mts +7 -0
- package/dist/dev/runtime/features/templateRefs.mjs +39 -0
- package/dist/dev/runtime/features/templateRefs.mjs.map +1 -0
- package/dist/dev/runtime/hooks/base.d.mts +27 -0
- package/dist/dev/runtime/hooks/register.d.mts +30 -0
- package/dist/dev/runtime/hooks/vue.d.mts +52 -0
- package/dist/dev/runtime/hooks/vue.mjs +3 -5
- package/dist/dev/runtime/hooks/vue.mjs.map +1 -1
- package/dist/dev/runtime/hooks.d.mts +4 -0
- package/dist/dev/runtime/index.d.mts +46 -0
- package/dist/dev/runtime/inlineDataset.mjs +75 -0
- package/dist/dev/runtime/inlineDataset.mjs.map +1 -0
- package/dist/dev/runtime/intersectionObserver.d.mts +14 -0
- package/dist/dev/runtime/jsxIsland.d.mts +37 -0
- package/dist/dev/runtime/jsxIsland.mjs.map +1 -1
- package/dist/dev/runtime/layoutBridge.d.mts +55 -0
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -1
- package/dist/dev/runtime/noSetData.d.mts +5 -0
- package/dist/dev/runtime/pageEnvironment.d.mts +50 -0
- package/dist/dev/runtime/pageLayout.d.mts +25 -0
- package/dist/dev/runtime/pageLayout.mjs.map +1 -1
- package/dist/dev/runtime/pageScroll.d.mts +29 -0
- package/dist/dev/runtime/platform.mjs +18 -1
- package/dist/dev/runtime/platform.mjs.map +1 -1
- package/dist/dev/runtime/provide.d.mts +60 -0
- package/dist/dev/runtime/provideStore.d.mts +7 -0
- package/dist/dev/runtime/publicRuntime.d.mts +22 -0
- package/dist/dev/runtime/publicRuntime.mjs +91 -0
- package/dist/dev/runtime/publicRuntime.mjs.map +1 -0
- package/dist/dev/runtime/pullDownRefresh.d.mts +12 -0
- package/dist/dev/runtime/register/app.d.mts +14 -0
- package/dist/dev/runtime/register/app.mjs +7 -10
- package/dist/dev/runtime/register/app.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle.mjs +22 -6
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -1
- package/dist/dev/runtime/register/component/methods.mjs +7 -10
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -1
- package/dist/dev/runtime/register/component/options.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +64 -69
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/component.d.mts +17 -0
- package/dist/dev/runtime/register/inline.d.mts +15 -0
- package/dist/dev/runtime/register/inline.mjs +4 -64
- package/dist/dev/runtime/register/inline.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +4 -6
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs +26 -0
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance.d.mts +26 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs +402 -160
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -1
- package/dist/dev/runtime/register/setup.d.mts +11 -0
- package/dist/dev/runtime/register/snapshot.mjs +6 -10
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/register/watch.d.mts +12 -0
- package/dist/dev/runtime/register.d.mts +5 -0
- package/dist/dev/runtime/scopedSlots.mjs +1 -1
- package/dist/dev/runtime/scopedSlots.mjs.map +1 -1
- package/dist/dev/runtime/selectorQuery.d.mts +54 -0
- package/dist/dev/runtime/selectorQuery.mjs +5 -0
- package/dist/dev/runtime/selectorQuery.mjs.map +1 -1
- package/dist/dev/runtime/teardown.mjs +18 -0
- package/dist/dev/runtime/teardown.mjs.map +1 -0
- package/dist/dev/runtime/template.d.mts +6 -0
- package/dist/dev/runtime/templateRefTypes.d.mts +12 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs.mjs +187 -118
- package/dist/dev/runtime/templateRefs.mjs.map +1 -1
- package/dist/dev/runtime/types/core.d.mts +35 -0
- package/dist/dev/runtime/types/miniprogram.d.mts +84 -0
- package/dist/dev/runtime/types/miniprogramHost.d.mts +45 -0
- package/dist/dev/runtime/types/miniprogramHostSources.d.mts +112 -0
- package/dist/dev/runtime/types/options.d.mts +136 -0
- package/dist/dev/runtime/types/props/propTypes.d.mts +79 -0
- package/dist/dev/runtime/types/props/router.d.mts +51 -0
- package/dist/dev/runtime/types/props/setup.d.mts +96 -0
- package/dist/dev/runtime/types/props.d.mts +4 -0
- package/dist/dev/runtime/types/runtime.d.mts +59 -0
- package/dist/dev/runtime/types/setData.d.mts +237 -0
- package/dist/dev/runtime/types.d.mts +29 -0
- package/dist/dev/runtime/uniAppHost.d.mts +8 -0
- package/dist/dev/runtime/updatePerformance.d.mts +13 -0
- package/dist/dev/runtime/use.d.mts +13 -0
- package/dist/dev/runtime/vueCompat/context.d.mts +8 -0
- package/dist/dev/runtime/vueCompat/model.d.mts +30 -0
- package/dist/dev/runtime/vueCompat/router.d.mts +29 -0
- package/dist/dev/runtime/vueCompat/router.mjs +18 -13
- package/dist/dev/runtime/vueCompat/router.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/templateRef.d.mts +9 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs +2 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat.d.mts +5 -0
- package/dist/dev/scheduler.d.mts +4 -0
- package/dist/dev/store/base.mjs +12 -18
- package/dist/dev/store/base.mjs.map +1 -1
- package/dist/dev/store/define/optionsStyle.mjs +13 -23
- package/dist/dev/store/define/optionsStyle.mjs.map +1 -1
- package/dist/dev/store/define/setupStyle.mjs +14 -24
- package/dist/dev/store/define/setupStyle.mjs.map +1 -1
- package/dist/dev/store/define/shared.mjs +44 -1
- package/dist/dev/store/define/shared.mjs.map +1 -1
- package/dist/dev/store/define.d.mts +28 -0
- package/dist/dev/store/define.mjs.map +1 -1
- package/dist/dev/store/manager.d.mts +8 -0
- package/dist/dev/store/storeToRefs.d.mts +13 -0
- package/dist/dev/store/types.d.mts +70 -0
- package/dist/dev/store.d.mts +5 -0
- package/dist/dev/version.d.mts +4 -0
- package/dist/dev/vue-augment.d.mts +8 -0
- package/dist/dev/vue-demi.d.mts +87 -0
- package/dist/dev/vue-demi.mjs +12 -15
- package/dist/dev/vue-demi.mjs.map +1 -1
- package/dist/dev/vue-types.d.mts +19 -0
- package/dist/dev/web-apis.d.mts +3 -0
- package/dist/index.d.mts +13 -14
- package/dist/index.mjs +1 -1
- package/dist/internal-reactivity.d.mts +2 -1
- package/dist/internal-reactivity.mjs +1 -1
- package/dist/internal-runtime.d.mts +13 -6
- package/dist/internal-runtime.mjs +1 -1
- package/dist/jsx-runtime.d.mts +47 -9
- package/dist/jsxTypes.d.mts +8 -0
- package/dist/miniprogram/jsx-runtime.d.mts +12 -0
- package/dist/miniprogram/jsx-runtime.mjs +1 -0
- package/dist/package.mjs +1 -1
- package/dist/reactivity/asyncDerivation.d.mts +40 -0
- package/dist/reactivity/asyncDerivation.mjs +1 -0
- package/dist/reactivity/computed.mjs +1 -1
- package/dist/reactivity/core.d.mts +1 -0
- package/dist/reactivity/core.mjs +1 -1
- package/dist/reactivity/index.d.mts +2 -1
- package/dist/reactivity/readonly.d.mts +1 -1
- package/dist/reactivity/ref.mjs +1 -1
- package/dist/router/createRouter.mjs +1 -1
- package/dist/router/useRoute.mjs +1 -1
- package/dist/runtime/app/computed.mjs +1 -1
- package/dist/runtime/app/context.mjs +1 -1
- package/dist/runtime/app/diagnostics.mjs +1 -1
- package/dist/runtime/app/mount.mjs +1 -1
- package/dist/runtime/app/setData/commitTracker.d.mts +12 -0
- package/dist/runtime/app/setData/commitTracker.mjs +1 -0
- package/dist/runtime/app/setData/patchScheduler.mjs +1 -1
- package/dist/runtime/app/setData/scheduler.d.mts +50 -0
- package/dist/runtime/app/setData/scheduler.mjs +1 -1
- package/dist/runtime/app/setData/snapshot.mjs +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/bindingManifest.mjs +1 -0
- package/dist/runtime/capabilities.d.mts +74 -0
- package/dist/runtime/capabilities.mjs +1 -0
- package/dist/runtime/define/componentDefinition.mjs +1 -1
- package/dist/runtime/define/optionsApi.mjs +1 -1
- package/dist/runtime/define/props.mjs +1 -1
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
- package/dist/runtime/define.d.mts +5 -13
- package/dist/runtime/define.mjs +1 -1
- package/dist/runtime/diff.mjs +1 -1
- package/dist/runtime/features/inlineEvents.d.mts +6 -0
- package/dist/runtime/features/inlineEvents.mjs +1 -0
- package/dist/runtime/features/layout.d.mts +6 -0
- package/dist/runtime/features/layout.mjs +1 -0
- package/dist/runtime/features/patchStrategy.d.mts +6 -0
- package/dist/runtime/features/patchStrategy.mjs +1 -0
- package/dist/runtime/features/publicLayout.d.mts +23 -0
- package/dist/runtime/features/publicLayout.mjs +1 -0
- package/dist/runtime/features/scopedSlots.d.mts +22 -0
- package/dist/runtime/features/scopedSlots.mjs +1 -0
- package/dist/runtime/features/setDataHighFrequencyWarning.d.mts +6 -0
- package/dist/runtime/features/setDataHighFrequencyWarning.mjs +1 -0
- package/dist/runtime/features/templateRefs.d.mts +6 -0
- package/dist/runtime/features/templateRefs.mjs +1 -0
- package/dist/runtime/hooks/vue.d.mts +1 -2
- package/dist/runtime/hooks/vue.mjs +1 -1
- package/dist/runtime/index.d.mts +12 -14
- package/dist/runtime/inlineDataset.mjs +1 -0
- package/dist/runtime/jsxIsland.d.mts +2 -6
- package/dist/runtime/layoutBridge.d.mts +5 -9
- package/dist/runtime/pageLayout.d.mts +3 -4
- package/dist/runtime/platform.mjs +1 -1
- package/dist/runtime/publicRuntime.d.mts +21 -0
- package/dist/runtime/publicRuntime.mjs +1 -0
- package/dist/runtime/register/app.mjs +1 -1
- package/dist/runtime/register/component/lifecycle.mjs +1 -1
- package/dist/runtime/register/component/methods.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/runtime/register/inline.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupSnapshot.mjs +1 -0
- package/dist/runtime/register/runtimeInstance.mjs +1 -1
- package/dist/runtime/register/snapshot.mjs +1 -1
- package/dist/runtime/scopedSlots.mjs +1 -1
- package/dist/runtime/selectorQuery.mjs +1 -1
- package/dist/runtime/teardown.mjs +1 -0
- package/dist/runtime/templateRefTypes.d.mts +5 -2
- package/dist/runtime/templateRefs.mjs +1 -1
- package/dist/runtime/types/miniprogram.d.mts +3 -0
- package/dist/runtime/types/options.d.mts +2 -2
- package/dist/runtime/types/props.d.mts +1 -1
- package/dist/runtime/types/setData.d.mts +18 -1
- package/dist/runtime/types.d.mts +3 -3
- package/dist/runtime/vueCompat/router.d.mts +5 -4
- package/dist/runtime/vueCompat/router.mjs +1 -1
- package/dist/runtime/vueCompat/templateRef.mjs +1 -1
- package/dist/store/base.mjs +1 -1
- package/dist/store/define/optionsStyle.mjs +1 -1
- package/dist/store/define/setupStyle.mjs +1 -1
- package/dist/store/define/shared.mjs +1 -1
- package/dist/store/define.d.mts +10 -8
- package/dist/store/types.d.mts +4 -4
- package/dist/tt/jsx-runtime.d.mts +12 -0
- package/dist/tt/jsx-runtime.mjs +1 -0
- package/dist/vue-demi.d.mts +13 -14
- package/dist/vue-demi.mjs +1 -1
- package/dist/weapp/jsx-runtime.d.mts +12 -0
- package/dist/weapp/jsx-runtime.mjs +1 -0
- package/package.json +26 -22
- package/dist/dev/jsx-runtime.mjs +0 -1
- package/dist/runtime/templateRefs.d.mts +0 -10
- package/dist/weappIntrinsicElements/base.d.mts +0 -21
- package/dist/weappIntrinsicElements/elements/ad-custom.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/ad.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/audio.d.mts +0 -19
- package/dist/weappIntrinsicElements/elements/block.d.mts +0 -7
- package/dist/weappIntrinsicElements/elements/button.d.mts +0 -39
- package/dist/weappIntrinsicElements/elements/camera.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/canvas.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/checkbox-group.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/checkbox.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/cover-image.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/cover-view.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/editor.d.mts +0 -21
- package/dist/weappIntrinsicElements/elements/form.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/functional-page-navigator.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/icon.d.mts +0 -11
- package/dist/weappIntrinsicElements/elements/image.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/import.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/include.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/input.d.mts +0 -46
- package/dist/weappIntrinsicElements/elements/keyboard-accessory.d.mts +0 -7
- package/dist/weappIntrinsicElements/elements/label.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/live-player.d.mts +0 -34
- package/dist/weappIntrinsicElements/elements/live-pusher.d.mts +0 -56
- package/dist/weappIntrinsicElements/elements/map.d.mts +0 -104
- package/dist/weappIntrinsicElements/elements/match-media.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/movable-area.d.mts +0 -25
- package/dist/weappIntrinsicElements/elements/movable-view.d.mts +0 -25
- package/dist/weappIntrinsicElements/elements/navigation-bar.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/navigator.d.mts +0 -24
- package/dist/weappIntrinsicElements/elements/official-account.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/open-data.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/page-container.d.mts +0 -24
- package/dist/weappIntrinsicElements/elements/page-meta.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/picker-view-column.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/picker-view.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/picker.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/progress.d.mts +0 -20
- package/dist/weappIntrinsicElements/elements/radio-group.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/radio.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/rich-text.d.mts +0 -16
- package/dist/weappIntrinsicElements/elements/scroll-view.d.mts +0 -67
- package/dist/weappIntrinsicElements/elements/share-element.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/slider.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/slot.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/swiper-item.d.mts +0 -41
- package/dist/weappIntrinsicElements/elements/swiper.d.mts +0 -41
- package/dist/weappIntrinsicElements/elements/switch.d.mts +0 -13
- package/dist/weappIntrinsicElements/elements/template.d.mts +0 -11
- package/dist/weappIntrinsicElements/elements/text.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/textarea.d.mts +0 -39
- package/dist/weappIntrinsicElements/elements/video.d.mts +0 -70
- package/dist/weappIntrinsicElements/elements/view.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/voip-room.d.mts +0 -13
- package/dist/weappIntrinsicElements/elements/web-view.d.mts +0 -12
- package/dist/weappIntrinsicElements.d.mts +0 -153
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/defineProperty.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPrimitive.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPropertyKey.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/typeof.mjs +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { SetupContextRouter, TypedRouterTabBarUrl } from "../runtime/types/props/router.mjs";
|
|
2
|
+
import "../runtime/types/props.mjs";
|
|
3
|
+
//#region src/router/types.d.ts
|
|
4
|
+
export type LocationQueryValue = string | null;
|
|
5
|
+
export type LocationQueryValueRaw = LocationQueryValue | number | boolean | undefined;
|
|
6
|
+
export type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
|
|
7
|
+
export type LocationQueryRaw = Record<string, LocationQueryValueRaw | LocationQueryValueRaw[]>;
|
|
8
|
+
export type RouteParamValue = string;
|
|
9
|
+
export type RouteParamValueRaw = RouteParamValue | number | boolean | null | undefined;
|
|
10
|
+
export type RouteParams = Record<string, RouteParamValue | RouteParamValue[]>;
|
|
11
|
+
export type RouteParamsRaw = Record<string, RouteParamValueRaw | RouteParamValueRaw[]>;
|
|
12
|
+
export type RouteParamsMode = 'loose' | 'strict';
|
|
13
|
+
export type RouteQueryParser = (search: string) => LocationQueryRaw | LocationQuery;
|
|
14
|
+
export type RouteQueryStringifier = (query: LocationQueryRaw | LocationQuery) => string;
|
|
15
|
+
export type RouteMeta = Record<string, unknown>;
|
|
16
|
+
export interface NamedRouteRecord {
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RouteRecordInput {
|
|
21
|
+
name?: string;
|
|
22
|
+
path: string;
|
|
23
|
+
meta?: RouteMeta;
|
|
24
|
+
alias?: string | readonly string[];
|
|
25
|
+
children?: readonly RouteRecordInput[];
|
|
26
|
+
beforeEnter?: NavigationGuard | readonly NavigationGuard[];
|
|
27
|
+
redirect?: RouteRecordRedirect;
|
|
28
|
+
}
|
|
29
|
+
export type NamedRoutes = Readonly<Record<string, string>> | readonly RouteRecordRaw[];
|
|
30
|
+
export type RouteLocationRaw = string | {
|
|
31
|
+
path?: string;
|
|
32
|
+
fullPath?: string;
|
|
33
|
+
query?: LocationQueryRaw;
|
|
34
|
+
hash?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
params?: RouteParamsRaw;
|
|
37
|
+
};
|
|
38
|
+
export interface RouteLocationNormalizedLoaded {
|
|
39
|
+
path: string;
|
|
40
|
+
fullPath: string;
|
|
41
|
+
query: LocationQuery;
|
|
42
|
+
hash: string;
|
|
43
|
+
name?: string;
|
|
44
|
+
meta?: RouteMeta;
|
|
45
|
+
href?: string;
|
|
46
|
+
matched?: readonly RouteRecordMatched[];
|
|
47
|
+
redirectedFrom?: RouteLocationRedirectedFrom;
|
|
48
|
+
params: RouteParams;
|
|
49
|
+
}
|
|
50
|
+
export declare const NavigationFailureType: {
|
|
51
|
+
readonly unknown: 1;
|
|
52
|
+
readonly aborted: 4;
|
|
53
|
+
readonly cancelled: 8;
|
|
54
|
+
readonly duplicated: 16;
|
|
55
|
+
};
|
|
56
|
+
export type NavigationFailureTypeValue = (typeof NavigationFailureType)[keyof typeof NavigationFailureType];
|
|
57
|
+
export interface NavigationFailure extends Error {
|
|
58
|
+
readonly __wevuNavigationFailure: true;
|
|
59
|
+
readonly type: NavigationFailureTypeValue;
|
|
60
|
+
readonly to?: RouteLocationNormalizedLoaded;
|
|
61
|
+
readonly from?: RouteLocationNormalizedLoaded;
|
|
62
|
+
readonly cause?: unknown;
|
|
63
|
+
}
|
|
64
|
+
export type NavigationMode = 'push' | 'replace' | 'back';
|
|
65
|
+
export type InitialNavigationMode = 'eager' | 'blocking';
|
|
66
|
+
export interface NavigationRedirect {
|
|
67
|
+
to: RouteLocationRaw;
|
|
68
|
+
replace?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export type RouteRecordRedirect = RouteLocationRaw | NavigationRedirect | ((to: RouteLocationNormalizedLoaded, from: RouteLocationNormalizedLoaded) => RouteLocationRaw | NavigationRedirect | Promise<RouteLocationRaw | NavigationRedirect>);
|
|
71
|
+
export interface RouteRecordRaw extends Omit<RouteRecordInput, 'name' | 'children'>, NamedRouteRecord {
|
|
72
|
+
children?: readonly RouteRecordRaw[];
|
|
73
|
+
}
|
|
74
|
+
export interface RouteRecordMatched {
|
|
75
|
+
name: string;
|
|
76
|
+
path: string;
|
|
77
|
+
aliasPath?: string;
|
|
78
|
+
meta?: RouteMeta;
|
|
79
|
+
}
|
|
80
|
+
export interface RouteLocationRedirectedFrom {
|
|
81
|
+
path: string;
|
|
82
|
+
fullPath: string;
|
|
83
|
+
query: LocationQuery;
|
|
84
|
+
hash: string;
|
|
85
|
+
name?: string;
|
|
86
|
+
meta?: RouteMeta;
|
|
87
|
+
href?: string;
|
|
88
|
+
matched?: readonly RouteRecordMatched[];
|
|
89
|
+
params: RouteParams;
|
|
90
|
+
}
|
|
91
|
+
export type NavigationGuardResult = void | boolean | NavigationFailure | RouteLocationRaw | NavigationRedirect;
|
|
92
|
+
export type NavigationGuard = (to: RouteLocationNormalizedLoaded | undefined, from: RouteLocationNormalizedLoaded, context?: NavigationGuardContext) => NavigationGuardResult | Promise<NavigationGuardResult>;
|
|
93
|
+
export type NavigationAfterEach = (to: RouteLocationNormalizedLoaded | undefined, from: RouteLocationNormalizedLoaded, failure?: NavigationFailure, context?: NavigationAfterEachContext) => void | Promise<void>;
|
|
94
|
+
export interface NavigationGuardContext {
|
|
95
|
+
readonly mode: NavigationMode;
|
|
96
|
+
readonly to?: RouteLocationNormalizedLoaded;
|
|
97
|
+
readonly from: RouteLocationNormalizedLoaded;
|
|
98
|
+
readonly nativeRouter: SetupContextRouter;
|
|
99
|
+
}
|
|
100
|
+
export interface NavigationAfterEachContext {
|
|
101
|
+
readonly mode: NavigationMode;
|
|
102
|
+
readonly to?: RouteLocationNormalizedLoaded;
|
|
103
|
+
readonly from: RouteLocationNormalizedLoaded;
|
|
104
|
+
readonly nativeRouter: SetupContextRouter;
|
|
105
|
+
readonly failure?: NavigationFailure;
|
|
106
|
+
}
|
|
107
|
+
export interface NavigationErrorContext {
|
|
108
|
+
readonly mode: NavigationMode;
|
|
109
|
+
readonly to?: RouteLocationNormalizedLoaded;
|
|
110
|
+
readonly from: RouteLocationNormalizedLoaded;
|
|
111
|
+
readonly nativeRouter: SetupContextRouter;
|
|
112
|
+
readonly failure: NavigationFailure;
|
|
113
|
+
}
|
|
114
|
+
export type NavigationErrorHandler = (error: unknown, context: NavigationErrorContext) => void | Promise<void>;
|
|
115
|
+
export interface UseRouterOptions {
|
|
116
|
+
tabBarEntries?: readonly (TypedRouterTabBarUrl | string)[];
|
|
117
|
+
/**
|
|
118
|
+
* Vue Router 对齐入口:推荐使用 `routes`
|
|
119
|
+
*/
|
|
120
|
+
routes?: readonly RouteRecordInput[];
|
|
121
|
+
/**
|
|
122
|
+
* 兼容入口:支持对象 map 或路由记录数组
|
|
123
|
+
*/
|
|
124
|
+
namedRoutes?: NamedRoutes;
|
|
125
|
+
paramsMode?: RouteParamsMode;
|
|
126
|
+
maxRedirects?: number;
|
|
127
|
+
/**
|
|
128
|
+
* 首屏导航守卫模式。默认立即挂载页面,只有明确配置 `blocking` 时才等待守卫完成。
|
|
129
|
+
*/
|
|
130
|
+
initialNavigationMode?: InitialNavigationMode;
|
|
131
|
+
/**
|
|
132
|
+
* blocking 首屏导航守卫的最大等待时间(毫秒),超时后放行页面挂载。
|
|
133
|
+
*/
|
|
134
|
+
initialNavigationTimeout?: number;
|
|
135
|
+
parseQuery?: RouteQueryParser;
|
|
136
|
+
stringifyQuery?: RouteQueryStringifier;
|
|
137
|
+
/**
|
|
138
|
+
* 异常型导航失败时是否以 Promise reject 抛出失败对象。
|
|
139
|
+
*
|
|
140
|
+
* - `true`:更贴近 Vue Router 心智(默认)
|
|
141
|
+
* - `false`:始终以返回值形式携带失败对象
|
|
142
|
+
*/
|
|
143
|
+
rejectOnError?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface RouterNavigation {
|
|
146
|
+
readonly nativeRouter: SetupContextRouter;
|
|
147
|
+
readonly options: Readonly<UseRouterOptions>;
|
|
148
|
+
readonly currentRoute: Readonly<RouteLocationNormalizedLoaded>;
|
|
149
|
+
install: (app?: unknown) => void;
|
|
150
|
+
resolve: (to: RouteLocationRaw) => RouteLocationNormalizedLoaded;
|
|
151
|
+
isReady: () => Promise<void>;
|
|
152
|
+
push: (to: RouteLocationRaw) => Promise<void | NavigationFailure>;
|
|
153
|
+
replace: (to: RouteLocationRaw) => Promise<void | NavigationFailure>;
|
|
154
|
+
back: (delta?: number) => Promise<void | NavigationFailure>;
|
|
155
|
+
go: (delta: number) => Promise<void | NavigationFailure>;
|
|
156
|
+
forward: () => Promise<void | NavigationFailure>;
|
|
157
|
+
hasRoute: (name: string) => boolean;
|
|
158
|
+
getRoutes: () => readonly RouteRecordRaw[];
|
|
159
|
+
addRoute: AddRoute;
|
|
160
|
+
removeRoute: (name: string) => void;
|
|
161
|
+
clearRoutes: () => void;
|
|
162
|
+
beforeEach: (guard: NavigationGuard) => () => void;
|
|
163
|
+
beforeResolve: (guard: NavigationGuard) => () => void;
|
|
164
|
+
afterEach: (hook: NavigationAfterEach) => () => void;
|
|
165
|
+
onError: (handler: NavigationErrorHandler) => () => void;
|
|
166
|
+
}
|
|
167
|
+
export interface AddRoute {
|
|
168
|
+
(route: RouteRecordRaw): () => void;
|
|
169
|
+
(parentName: string, route: RouteRecordRaw): () => void;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SetupContextRouter } from "../runtime/types/props/router.mjs";
|
|
2
|
+
import "../runtime/types/props.mjs";
|
|
3
|
+
import { RouteLocationNormalizedLoaded } from "./types.mjs";
|
|
4
|
+
import "./routeSync.mjs";
|
|
5
|
+
//#region src/router/useRoute.d.ts
|
|
6
|
+
export interface UseRouteOptions {
|
|
7
|
+
resolveRoute?: (route: RouteLocationNormalizedLoaded) => RouteLocationNormalizedLoaded;
|
|
8
|
+
}
|
|
9
|
+
export declare function useRoute(options?: UseRouteOptions): Readonly<RouteLocationNormalizedLoaded>;
|
|
10
|
+
/**
|
|
11
|
+
* @description 获取当前组件路径语义的原生 Router
|
|
12
|
+
*/
|
|
13
|
+
export declare function useNativeRouter(): SetupContextRouter;
|
|
14
|
+
/**
|
|
15
|
+
* @description 获取当前页面路径语义的原生 Page Router
|
|
16
|
+
*/
|
|
17
|
+
export declare function useNativePageRouter(): SetupContextRouter;
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=useRoute.d.mts.map
|
|
@@ -47,15 +47,12 @@ function applyRouteState(routeState, nextRoute) {
|
|
|
47
47
|
function createRouteStateController(options = {}) {
|
|
48
48
|
var _options$resolveRoute;
|
|
49
49
|
const setupContext = getCurrentSetupContext();
|
|
50
|
-
|
|
51
|
-
const fallbackPage = setupContext.instance;
|
|
52
|
-
const initialRouteControllerInstance = resolveRouteControllerInstance(fallbackPage);
|
|
50
|
+
const fallbackPage = (setupContext === null || setupContext === void 0 ? void 0 : setupContext.instance) && typeof setupContext.instance === "object" ? setupContext.instance : void 0;
|
|
53
51
|
const resolveRoute = (_options$resolveRoute = options.resolveRoute) !== null && _options$resolveRoute !== void 0 ? _options$resolveRoute : ((route) => {
|
|
54
52
|
var _getActiveRouter$reso, _getActiveRouter;
|
|
55
53
|
return (_getActiveRouter$reso = (_getActiveRouter = getActiveRouter()) === null || _getActiveRouter === void 0 ? void 0 : _getActiveRouter.resolve(route)) !== null && _getActiveRouter$reso !== void 0 ? _getActiveRouter$reso : route;
|
|
56
54
|
});
|
|
57
55
|
const currentRoute = resolveRoute(resolveCurrentRoute(void 0, fallbackPage));
|
|
58
|
-
const isPageController = isPageLikeInstance(initialRouteControllerInstance) || getCurrentMiniProgramPages().includes(initialRouteControllerInstance);
|
|
59
56
|
const routeState = reactive({
|
|
60
57
|
path: currentRoute.path,
|
|
61
58
|
fullPath: currentRoute.fullPath,
|
|
@@ -72,6 +69,27 @@ function createRouteStateController(options = {}) {
|
|
|
72
69
|
}
|
|
73
70
|
applyRouteState(routeState, nextRoute);
|
|
74
71
|
}
|
|
72
|
+
if (!fallbackPage) {
|
|
73
|
+
registerRouteStateSyncHandler((payload) => {
|
|
74
|
+
if (payload === null || payload === void 0 ? void 0 : payload.route) {
|
|
75
|
+
syncRoute(void 0, payload.route, payload);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (payload === null || payload === void 0 ? void 0 : payload.url) {
|
|
79
|
+
syncRoute(void 0, resolveRouteLocation(payload.url, routeState.path), payload);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (payload === null || payload === void 0 ? void 0 : payload.page) {
|
|
83
|
+
syncRoute(void 0, resolvePageRoute(payload.page), payload);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
syncRoute(void 0, void 0, payload);
|
|
87
|
+
});
|
|
88
|
+
return { route: readonly(routeState) };
|
|
89
|
+
}
|
|
90
|
+
const pageInstance = fallbackPage;
|
|
91
|
+
const initialRouteControllerInstance = resolveRouteControllerInstance(pageInstance);
|
|
92
|
+
const isPageController = isPageLikeInstance(initialRouteControllerInstance) || getCurrentMiniProgramPages().includes(initialRouteControllerInstance);
|
|
75
93
|
onLoad((query) => {
|
|
76
94
|
syncRoute(query);
|
|
77
95
|
});
|
|
@@ -85,7 +103,7 @@ function createRouteStateController(options = {}) {
|
|
|
85
103
|
syncRoute();
|
|
86
104
|
});
|
|
87
105
|
const unregisterRouteStateSync = registerRouteStateSyncHandler((payload) => {
|
|
88
|
-
if (!shouldSyncRouteStateForInstance(
|
|
106
|
+
if (!shouldSyncRouteStateForInstance(pageInstance, isPageController, payload)) return;
|
|
89
107
|
if (payload === null || payload === void 0 ? void 0 : payload.route) {
|
|
90
108
|
syncRoute(void 0, payload.route, payload);
|
|
91
109
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRoute.mjs","names":["useNativeRouterInternal","useNativePageRouterInternal"],"sources":["../../../src/router/useRoute.ts"],"sourcesContent":["import type { MiniProgramPageLifetime } from '../runtime/types'\nimport type { SetupContextRouter } from '../runtime/types/props'\nimport type { RouteStateSyncPayload } from './routeSync'\nimport type { LocationQueryRaw, RouteLocationNormalizedLoaded } from './types'\nimport { WEVU_NATIVE_INSTANCE_KEY } from '@weapp-core/constants'\nimport { reactive, readonly } from '../reactivity'\nimport { cloneLocationQuery, cloneRouteLocationRedirectedFrom, cloneRouteMeta, cloneRouteParams, cloneRouteRecordMatchedList, resolveCurrentRoute, resolvePageRoute } from '../routerInternal/shared'\nimport { getCurrentSetupContext, onLoad, onReady, onRouteDone, onShow, onUnload } from '../runtime/hooks'\nimport { getCurrentMiniProgramPages } from '../runtime/platform'\nimport {\n useNativePageRouter as useNativePageRouterInternal,\n useNativeRouter as useNativeRouterInternal,\n} from '../runtime/vueCompat'\nimport { getActiveRouter } from './instance'\nimport { resolveRouteLocation } from './resolve'\nimport { registerRouteStateSyncHandler } from './routeSync'\n\nexport interface UseRouteOptions {\n resolveRoute?: (route: RouteLocationNormalizedLoaded) => RouteLocationNormalizedLoaded\n}\n\ninterface RouteStateControllerOptions extends UseRouteOptions {\n beforeRouteStateSync?: (\n nextRoute: RouteLocationNormalizedLoaded,\n payload: RouteStateSyncPayload,\n ) => void\n}\n\nexport interface RouteStateController {\n route: Readonly<RouteLocationNormalizedLoaded>\n}\n\nfunction isPageLikeInstance(instance: Record<string, any>): boolean {\n return typeof instance.route === 'string' || typeof instance.__route__ === 'string'\n}\n\nfunction resolveRouteControllerInstance(instance: Record<string, any>): Record<string, any> {\n const nativeInstance = instance[WEVU_NATIVE_INSTANCE_KEY]\n return nativeInstance && typeof nativeInstance === 'object'\n ? nativeInstance\n : instance\n}\n\nfunction shouldSyncRouteStateForInstance(\n instance: Record<string, any>,\n isPageController: boolean,\n payload: RouteStateSyncPayload | undefined,\n): boolean {\n if (payload?.source === 'router') {\n return true\n }\n\n // 页面级 route controller 只处理当前页面的广播,避免 DevTools 在 onUnload/onShow\n // 交错时让隐藏页面重复执行导航守卫。组件级 controller 仍接收全局同步。\n if (!isPageController) {\n return true\n }\n\n const routeControllerInstance = resolveRouteControllerInstance(instance)\n if (payload?.page) {\n return payload.page === routeControllerInstance\n }\n\n const pages = getCurrentMiniProgramPages()\n return pages[pages.length - 1] === routeControllerInstance\n}\n\nfunction applyRouteState(\n routeState: RouteLocationNormalizedLoaded,\n nextRoute: RouteLocationNormalizedLoaded,\n) {\n routeState.path = nextRoute.path\n routeState.fullPath = nextRoute.fullPath\n routeState.query = cloneLocationQuery(nextRoute.query)\n routeState.hash = nextRoute.hash\n routeState.params = cloneRouteParams(nextRoute.params)\n if (nextRoute.name === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).name\n }\n else {\n routeState.name = nextRoute.name\n }\n if (nextRoute.meta === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).meta\n }\n else {\n routeState.meta = cloneRouteMeta(nextRoute.meta)\n }\n if (nextRoute.href === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).href\n }\n else {\n routeState.href = nextRoute.href\n }\n if (nextRoute.matched === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).matched\n }\n else {\n routeState.matched = cloneRouteRecordMatchedList(nextRoute.matched)\n }\n if (nextRoute.redirectedFrom === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).redirectedFrom\n }\n else {\n routeState.redirectedFrom = cloneRouteLocationRedirectedFrom(nextRoute.redirectedFrom)\n }\n}\n\nexport function createRouteStateController(options: RouteStateControllerOptions = {}): RouteStateController {\n const setupContext = getCurrentSetupContext()\n if (!setupContext) {\n throw new Error('useRoute() 必须在 setup() 的同步阶段调用')\n }\n\n const fallbackPage = setupContext.instance\n const initialRouteControllerInstance = resolveRouteControllerInstance(fallbackPage)\n const resolveRoute = options.resolveRoute\n ?? ((route: RouteLocationNormalizedLoaded) => getActiveRouter()?.resolve(route) ?? route)\n const currentRoute = resolveRoute(resolveCurrentRoute(undefined, fallbackPage))\n const isPageController = isPageLikeInstance(initialRouteControllerInstance)\n || getCurrentMiniProgramPages().includes(initialRouteControllerInstance)\n const routeState = reactive<RouteLocationNormalizedLoaded>({\n path: currentRoute.path,\n fullPath: currentRoute.fullPath,\n query: cloneLocationQuery(currentRoute.query),\n hash: currentRoute.hash,\n params: cloneRouteParams(currentRoute.params),\n })\n applyRouteState(routeState, currentRoute)\n\n function syncRoute(\n queryOverride?: LocationQueryRaw,\n routeOverride?: RouteLocationNormalizedLoaded,\n payload?: RouteStateSyncPayload,\n ) {\n const nextRoute = routeOverride\n ? resolveRoute(routeOverride)\n : resolveRoute(resolveCurrentRoute(queryOverride, fallbackPage))\n if (payload) {\n options.beforeRouteStateSync?.(nextRoute, payload)\n }\n applyRouteState(routeState, nextRoute)\n }\n\n onLoad((query: Parameters<NonNullable<MiniProgramPageLifetime['onLoad']>>[0]) => {\n syncRoute(query as unknown as LocationQueryRaw)\n })\n onReady(() => {\n syncRoute()\n })\n onShow(() => {\n syncRoute()\n })\n onRouteDone(() => {\n syncRoute()\n })\n const unregisterRouteStateSync = registerRouteStateSyncHandler((payload) => {\n if (!shouldSyncRouteStateForInstance(fallbackPage, isPageController, payload)) {\n return\n }\n if (payload?.route) {\n syncRoute(undefined, payload.route, payload)\n return\n }\n if (payload?.url) {\n syncRoute(undefined, resolveRouteLocation(payload.url, routeState.path), payload)\n return\n }\n if (payload?.page) {\n syncRoute(undefined, resolvePageRoute(payload.page), payload)\n return\n }\n syncRoute(undefined, undefined, payload)\n })\n onUnload(() => {\n unregisterRouteStateSync()\n })\n\n return {\n route: readonly(routeState) as Readonly<RouteLocationNormalizedLoaded>,\n }\n}\n\nexport function useRoute(options: UseRouteOptions = {}): Readonly<RouteLocationNormalizedLoaded> {\n return createRouteStateController(options).route\n}\n\n/**\n * @description 获取当前组件路径语义的原生 Router\n */\nexport function useNativeRouter(): SetupContextRouter {\n return useNativeRouterInternal()\n}\n\n/**\n * @description 获取当前页面路径语义的原生 Page Router\n */\nexport function useNativePageRouter(): SetupContextRouter {\n return useNativePageRouterInternal()\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAS,mBAAmB,UAAwC;CAClE,OAAO,OAAO,SAAS,UAAU,YAAY,OAAO,SAAS,cAAc;AAC7E;AAEA,SAAS,+BAA+B,UAAoD;CAC1F,MAAM,iBAAiB,SAAS;CAChC,OAAO,kBAAkB,OAAO,mBAAmB,WAC/C,iBACA;AACN;AAEA,SAAS,gCACP,UACA,kBACA,SACS;CACT,uDAAI,QAAS,YAAW,UACtB,OAAO;CAKT,IAAI,CAAC,kBACH,OAAO;CAGT,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M,aAAa;EACnB,QAAQ,iBAAiB,aAAa,MAAM;CAC9C,CAAC;CACD,gBAAgB,YAAY,YAAY;CAExC,SAAS,UACP,eACA,eACA,SACA;EACA,MAAM,YAAY,gBACd,aAAa,aAAa,IAC1B,aAAa,oBAAoB,eAAe,YAAY,CAAC;EACjE,IAAI,SAAS;;GACX,iCAAQ,0GAAuB,WAAW,OAAO;EACnD;EACA,gBAAgB,YAAY,SAAS;CACvC;CAEA,QAAQ,UAAyE;EAC/E,UAAU,KAAoC;CAChD,CAAC;CACD,cAAc;EACZ,UAAU;CACZ,CAAC;CACD,aAAa;EACX,UAAU;CACZ,CAAC;CACD,kBAAkB;EAChB,UAAU;CACZ,CAAC;CACD,MAAM,2BAA2B,+BAA+B,YAAY;EAC1E,IAAI,CAAC,gCAAgC,cAAc,kBAAkB,OAAO,GAC1E;EAEF,sDAAI,QAAS,OAAO;GAClB,UAAU,QAAW,QAAQ,OAAO,OAAO;GAC3C;EACF;EACA,sDAAI,QAAS,KAAK;GAChB,UAAU,QAAW,qBAAqB,QAAQ,KAAK,WAAW,IAAI,GAAG,OAAO;GAChF;EACF;EACA,sDAAI,QAAS,MAAM;GACjB,UAAU,QAAW,iBAAiB,QAAQ,IAAI,GAAG,OAAO;GAC5D;EACF;EACA,UAAU,QAAW,QAAW,OAAO;CACzC,CAAC;CACD,eAAe;EACb,yBAAyB;CAC3B,CAAC;CAED,OAAO,EACL,OAAO,SAAS,UAAU,EAC5B;AACF;AAEA,SAAgB,SAAS,UAA2B,CAAC,GAA4C;CAC/F,OAAO,2BAA2B,OAAO,CAAC,CAAC;AAC7C;;;;AAKA,SAAgB,kBAAsC;CACpD,OAAOA,kBAAwB;AACjC;;;;AAKA,SAAgB,sBAA0C;CACxD,OAAOC,sBAA4B;AACrC"}
|
|
1
|
+
{"version":3,"file":"useRoute.mjs","names":["useNativeRouterInternal","useNativePageRouterInternal"],"sources":["../../../src/router/useRoute.ts"],"sourcesContent":["import type { MiniProgramPageLike } from '../routerInternal/types'\nimport type { MiniProgramPageLifetime } from '../runtime/types'\nimport type { SetupContextRouter } from '../runtime/types/props'\nimport type { RouteStateSyncPayload } from './routeSync'\nimport type { LocationQueryRaw, RouteLocationNormalizedLoaded } from './types'\nimport { WEVU_NATIVE_INSTANCE_KEY } from '@weapp-core/constants'\nimport { reactive, readonly } from '../reactivity'\nimport { cloneLocationQuery, cloneRouteLocationRedirectedFrom, cloneRouteMeta, cloneRouteParams, cloneRouteRecordMatchedList, resolveCurrentRoute, resolvePageRoute } from '../routerInternal/shared'\nimport { getCurrentSetupContext, onLoad, onReady, onRouteDone, onShow, onUnload } from '../runtime/hooks'\nimport { getCurrentMiniProgramPages } from '../runtime/platform'\nimport {\n useNativePageRouter as useNativePageRouterInternal,\n useNativeRouter as useNativeRouterInternal,\n} from '../runtime/vueCompat'\nimport { getActiveRouter } from './instance'\nimport { resolveRouteLocation } from './resolve'\nimport { registerRouteStateSyncHandler } from './routeSync'\n\nexport interface UseRouteOptions {\n resolveRoute?: (route: RouteLocationNormalizedLoaded) => RouteLocationNormalizedLoaded\n}\n\ninterface RouteStateControllerOptions extends UseRouteOptions {\n beforeRouteStateSync?: (\n nextRoute: RouteLocationNormalizedLoaded,\n payload: RouteStateSyncPayload,\n ) => void\n}\n\nexport interface RouteStateController {\n route: Readonly<RouteLocationNormalizedLoaded>\n}\n\nfunction isPageLikeInstance(instance: Record<string, any>): boolean {\n return typeof instance.route === 'string' || typeof instance.__route__ === 'string'\n}\n\nfunction resolveRouteControllerInstance(instance: Record<string, any>): Record<string, any> {\n const nativeInstance = instance[WEVU_NATIVE_INSTANCE_KEY]\n return nativeInstance && typeof nativeInstance === 'object'\n ? nativeInstance\n : instance\n}\n\nfunction shouldSyncRouteStateForInstance(\n instance: Record<string, any>,\n isPageController: boolean,\n payload: RouteStateSyncPayload | undefined,\n): boolean {\n if (payload?.source === 'router') {\n return true\n }\n\n // 页面级 route controller 只处理当前页面的广播,避免 DevTools 在 onUnload/onShow\n // 交错时让隐藏页面重复执行导航守卫。组件级 controller 仍接收全局同步。\n if (!isPageController) {\n return true\n }\n\n const routeControllerInstance = resolveRouteControllerInstance(instance)\n if (payload?.page) {\n return payload.page === routeControllerInstance\n }\n\n const pages = getCurrentMiniProgramPages()\n return pages[pages.length - 1] === routeControllerInstance\n}\n\nfunction applyRouteState(\n routeState: RouteLocationNormalizedLoaded,\n nextRoute: RouteLocationNormalizedLoaded,\n) {\n routeState.path = nextRoute.path\n routeState.fullPath = nextRoute.fullPath\n routeState.query = cloneLocationQuery(nextRoute.query)\n routeState.hash = nextRoute.hash\n routeState.params = cloneRouteParams(nextRoute.params)\n if (nextRoute.name === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).name\n }\n else {\n routeState.name = nextRoute.name\n }\n if (nextRoute.meta === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).meta\n }\n else {\n routeState.meta = cloneRouteMeta(nextRoute.meta)\n }\n if (nextRoute.href === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).href\n }\n else {\n routeState.href = nextRoute.href\n }\n if (nextRoute.matched === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).matched\n }\n else {\n routeState.matched = cloneRouteRecordMatchedList(nextRoute.matched)\n }\n if (nextRoute.redirectedFrom === undefined) {\n delete (routeState as Partial<RouteLocationNormalizedLoaded>).redirectedFrom\n }\n else {\n routeState.redirectedFrom = cloneRouteLocationRedirectedFrom(nextRoute.redirectedFrom)\n }\n}\n\nexport function createRouteStateController(options: RouteStateControllerOptions = {}): RouteStateController {\n const setupContext = getCurrentSetupContext<{ instance?: unknown }>()\n const fallbackPage = setupContext?.instance && typeof setupContext.instance === 'object'\n ? setupContext.instance as MiniProgramPageLike & Record<string, unknown>\n : undefined\n const resolveRoute = options.resolveRoute\n ?? ((route: RouteLocationNormalizedLoaded) => getActiveRouter()?.resolve(route) ?? route)\n const currentRoute = resolveRoute(resolveCurrentRoute(undefined, fallbackPage))\n const routeState = reactive<RouteLocationNormalizedLoaded>({\n path: currentRoute.path,\n fullPath: currentRoute.fullPath,\n query: cloneLocationQuery(currentRoute.query),\n hash: currentRoute.hash,\n params: cloneRouteParams(currentRoute.params),\n })\n applyRouteState(routeState, currentRoute)\n\n function syncRoute(\n queryOverride?: LocationQueryRaw,\n routeOverride?: RouteLocationNormalizedLoaded,\n payload?: RouteStateSyncPayload,\n ) {\n const nextRoute = routeOverride\n ? resolveRoute(routeOverride)\n : resolveRoute(resolveCurrentRoute(queryOverride, fallbackPage))\n if (payload) {\n options.beforeRouteStateSync?.(nextRoute, payload)\n }\n applyRouteState(routeState, nextRoute)\n }\n\n if (!fallbackPage) {\n const unregisterRouteStateSync = registerRouteStateSyncHandler((payload) => {\n if (payload?.route) {\n syncRoute(undefined, payload.route, payload)\n return\n }\n if (payload?.url) {\n syncRoute(undefined, resolveRouteLocation(payload.url, routeState.path), payload)\n return\n }\n if (payload?.page) {\n syncRoute(undefined, resolvePageRoute(payload.page), payload)\n return\n }\n syncRoute(undefined, undefined, payload)\n })\n void unregisterRouteStateSync\n return {\n route: readonly(routeState) as Readonly<RouteLocationNormalizedLoaded>,\n }\n }\n\n const pageInstance = fallbackPage\n const initialRouteControllerInstance = resolveRouteControllerInstance(pageInstance)\n const isPageController = isPageLikeInstance(initialRouteControllerInstance)\n || getCurrentMiniProgramPages().includes(initialRouteControllerInstance)\n\n onLoad((query: Parameters<NonNullable<MiniProgramPageLifetime['onLoad']>>[0]) => {\n syncRoute(query as unknown as LocationQueryRaw)\n })\n onReady(() => {\n syncRoute()\n })\n onShow(() => {\n syncRoute()\n })\n onRouteDone(() => {\n syncRoute()\n })\n const unregisterRouteStateSync = registerRouteStateSyncHandler((payload) => {\n if (!shouldSyncRouteStateForInstance(pageInstance, isPageController, payload)) {\n return\n }\n if (payload?.route) {\n syncRoute(undefined, payload.route, payload)\n return\n }\n if (payload?.url) {\n syncRoute(undefined, resolveRouteLocation(payload.url, routeState.path), payload)\n return\n }\n if (payload?.page) {\n syncRoute(undefined, resolvePageRoute(payload.page), payload)\n return\n }\n syncRoute(undefined, undefined, payload)\n })\n onUnload(() => {\n unregisterRouteStateSync()\n })\n\n return {\n route: readonly(routeState) as Readonly<RouteLocationNormalizedLoaded>,\n }\n}\n\nexport function useRoute(options: UseRouteOptions = {}): Readonly<RouteLocationNormalizedLoaded> {\n return createRouteStateController(options).route\n}\n\n/**\n * @description 获取当前组件路径语义的原生 Router\n */\nexport function useNativeRouter(): SetupContextRouter {\n return useNativeRouterInternal()\n}\n\n/**\n * @description 获取当前页面路径语义的原生 Page Router\n */\nexport function useNativePageRouter(): SetupContextRouter {\n return useNativePageRouterInternal()\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,SAAS,mBAAmB,UAAwC;CAClE,OAAO,OAAO,SAAS,UAAU,YAAY,OAAO,SAAS,cAAc;AAC7E;AAEA,SAAS,+BAA+B,UAAoD;CAC1F,MAAM,iBAAiB,SAAS;CAChC,OAAO,kBAAkB,OAAO,mBAAmB,WAC/C,iBACA;AACN;AAEA,SAAS,gCACP,UACA,kBACA,SACS;CACT,uDAAI,QAAS,YAAW,UACtB,OAAO;CAKT,IAAI,CAAC,kBACH,OAAO;CAGT,MAAM,0BAA0B,+BAA+B,QAAQ;CACvE,sDAAI,QAAS,MACX,OAAO,QAAQ,SAAS;CAG1B,MAAM,QAAQ,2BAA2B;CACzC,OAAO,MAAM,MAAM,SAAS,OAAO;AACrC;AAEA,SAAS,gBACP,YACA,WACA;CACA,WAAW,OAAO,UAAU;CAC5B,WAAW,WAAW,UAAU;CAChC,WAAW,QAAQ,mBAAmB,UAAU,KAAK;CACrD,WAAW,OAAO,UAAU;CAC5B,WAAW,SAAS,iBAAiB,UAAU,MAAM;CACrD,IAAI,UAAU,SAAS,QACrB,OAAQ,WAAsD;MAG9D,WAAW,OAAO,UAAU;CAE9B,IAAI,UAAU,SAAS,QACrB,OAAQ,WAAsD;MAG9D,WAAW,OAAO,eAAe,UAAU,IAAI;CAEjD,IAA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AO;EACzC,CAAC;EAED,OAAO,EACL,OAAO,SAAS,UAAU,EAC5B;CACF;CAEA,MAAM,eAAe;CACrB,MAAM,iCAAiC,+BAA+B,YAAY;CAClF,MAAM,mBAAmB,mBAAmB,8BAA8B,KACrE,2BAA2B,CAAC,CAAC,SAAS,8BAA8B;CAEzE,QAAQ,UAAyE;EAC/E,UAAU,KAAoC;CAChD,CAAC;CACD,cAAc;EACZ,UAAU;CACZ,CAAC;CACD,aAAa;EACX,UAAU;CACZ,CAAC;CACD,kBAAkB;EAChB,UAAU;CACZ,CAAC;CACD,MAAM,2BAA2B,+BAA+B,YAAY;EAC1E,IAAI,CAAC,gCAAgC,cAAc,kBAAkB,OAAO,GAC1E;EAEF,sDAAI,QAAS,OAAO;GAClB,UAAU,QAAW,QAAQ,OAAO,OAAO;GAC3C;EACF;EACA,sDAAI,QAAS,KAAK;GAChB,UAAU,QAAW,qBAAqB,QAAQ,KAAK,WAAW,IAAI,GAAG,OAAO;GAChF;EACF;EACA,sDAAI,QAAS,MAAM;GACjB,UAAU,QAAW,iBAAiB,QAAQ,IAAI,GAAG,OAAO;GAC5D;EACF;EACA,UAAU,QAAW,QAAW,OAAO;CACzC,CAAC;CACD,eAAe;EACb,yBAAyB;CAC3B,CAAC;CAED,OAAO,EACL,OAAO,SAAS,UAAU,EAC5B;AACF;AAEA,SAAgB,SAAS,UAA2B,CAAC,GAA4C;CAC/F,OAAO,2BAA2B,OAAO,CAAC,CAAC;AAC7C;;;;AAKA,SAAgB,kBAAsC;CACpD,OAAOA,kBAAwB;AACjC;;;;AAKA,SAAgB,sBAA0C;CACxD,OAAOC,sBAA4B;AACrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RouterNavigateToOption, RouterReLaunchOption, RouterRedirectToOption, RouterSwitchTabOption, SetupContextRouter, TypedRouterTabBarUrl, TypedRouterUrl, WevuTypedRouterRouteMap } from "./runtime/types/props/router.mjs";
|
|
2
|
+
import "./runtime/types/props.mjs";
|
|
3
|
+
import { parseQuery, stringifyQuery } from "./routerInternal/query.mjs";
|
|
4
|
+
import { AddRoute, InitialNavigationMode, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, NamedRouteRecord, NamedRoutes, NavigationAfterEach, NavigationAfterEachContext, NavigationErrorContext, NavigationErrorHandler, NavigationFailure, NavigationFailureType, NavigationFailureTypeValue, NavigationGuard, NavigationGuardContext, NavigationGuardResult, NavigationMode, NavigationRedirect, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationRedirectedFrom, RouteMeta, RouteParamValue, RouteParamValueRaw, RouteParams, RouteParamsMode, RouteParamsRaw, RouteQueryParser, RouteQueryStringifier, RouteRecordInput, RouteRecordMatched, RouteRecordRaw, RouteRecordRedirect, RouterNavigation, UseRouterOptions } from "./router/types.mjs";
|
|
5
|
+
import { createRouter } from "./router/createRouter.mjs";
|
|
6
|
+
import { createNavigationFailure, isNavigationFailure } from "./router/navigationCore.mjs";
|
|
7
|
+
import { resolveRouteLocation } from "./router/resolve.mjs";
|
|
8
|
+
import { useNativePageRouter, useNativeRouter, useRoute } from "./router/useRoute.mjs";
|
|
9
|
+
import { useRouter } from "./router/useRouter.mjs";
|
|
10
|
+
export { type AddRoute, type InitialNavigationMode, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, type NamedRouteRecord, type NamedRoutes, type NavigationAfterEach, type NavigationAfterEachContext, type NavigationErrorContext, type NavigationErrorHandler, type NavigationFailure, NavigationFailureType, type NavigationFailureTypeValue, type NavigationGuard, type NavigationGuardContext, type NavigationGuardResult, type NavigationMode, type NavigationRedirect, type RouteLocationNormalizedLoaded, type RouteLocationRaw, type RouteLocationRedirectedFrom, type RouteMeta, type RouteParamValue, type RouteParamValueRaw, type RouteParams, type RouteParamsMode, type RouteParamsRaw, type RouteQueryParser, type RouteQueryStringifier, type RouteRecordInput, type RouteRecordMatched, type RouteRecordRaw, type RouteRecordRedirect, type RouterNavigateToOption, type RouterNavigation, type RouterReLaunchOption, type RouterRedirectToOption, type RouterSwitchTabOption, type SetupContextRouter, type TypedRouterTabBarUrl, type TypedRouterUrl, type UseRouterOptions, type WevuTypedRouterRouteMap, createNavigationFailure, createRouter, isNavigationFailure, parseQuery, resolveRouteLocation, stringifyQuery, useNativePageRouter, useNativeRouter, useRoute, useRouter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LocationQuery, LocationQueryRaw } from "../router/types.mjs";
|
|
2
|
+
import "../router.mjs";
|
|
3
|
+
//#region src/routerInternal/query.d.ts
|
|
4
|
+
export declare function parseQuery(search: string): LocationQuery;
|
|
5
|
+
export declare function stringifyQuery(query?: LocationQueryRaw | LocationQuery): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=query.d.mts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RouteQueryParser, RouteQueryStringifier } from "../router/types.mjs";
|
|
2
|
+
import "../router.mjs";
|
|
3
|
+
//#region src/routerInternal/types.d.ts
|
|
4
|
+
export interface RouteResolveCodec {
|
|
5
|
+
parseQuery: RouteQueryParser;
|
|
6
|
+
stringifyQuery: RouteQueryStringifier;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createComputedEffect, track, trigger } from "../../reactivity/core.mjs";
|
|
2
2
|
import { markAsRef } from "../../reactivity/ref.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/app/computed.ts
|
|
@@ -25,7 +25,7 @@ function createComputedAccessors(options) {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
markAsRef(obj);
|
|
28
|
-
runner =
|
|
28
|
+
runner = createComputedEffect(getter, {
|
|
29
29
|
lazy: true,
|
|
30
30
|
scheduler: () => {
|
|
31
31
|
if (!dirty) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.mjs","names":[],"sources":["../../../../src/runtime/app/computed.ts"],"sourcesContent":["import type { ComputedRef } from '../../reactivity'\nimport {
|
|
1
|
+
{"version":3,"file":"computed.mjs","names":[],"sources":["../../../../src/runtime/app/computed.ts"],"sourcesContent":["import type { ComputedRef } from '../../reactivity'\nimport { createComputedEffect, track, trigger } from '../../reactivity/core'\nimport { markAsRef } from '../../reactivity/ref'\n\ninterface ComputedOptions {\n includeComputed: boolean\n setDataStrategy: 'diff' | 'patch'\n}\n\nexport function createComputedAccessors(options: ComputedOptions) {\n const computedRefs: Record<string, ComputedRef<any>> = Object.create(null)\n const computedSetters: Record<string, (value: any) => void> = Object.create(null)\n const dirtyComputedKeys = new Set<string>()\n\n const createTrackedComputed = <T>(\n key: string,\n getter: () => T,\n setter?: (value: T) => void,\n ): ComputedRef<T> => {\n let value: T\n let dirty = true\n let runner!: () => T\n const obj: any = {\n get value() {\n if (dirty) {\n value = runner()\n dirty = false\n }\n track(obj, 'value')\n return value\n },\n set value(nextValue: T) {\n if (!setter) {\n throw new Error('计算属性是只读的')\n }\n setter(nextValue)\n },\n }\n markAsRef(obj)\n runner = createComputedEffect(getter, {\n lazy: true,\n scheduler: () => {\n if (!dirty) {\n dirty = true\n if (options.setDataStrategy === 'patch' && options.includeComputed) {\n dirtyComputedKeys.add(key)\n }\n trigger(obj, 'value')\n }\n },\n })\n return obj as ComputedRef<T>\n }\n\n const computedProxy = new Proxy(\n {},\n {\n get(_target, key: string | symbol) {\n if (typeof key === 'string' && computedRefs[key]) {\n return computedRefs[key].value\n }\n return undefined\n },\n has(_target, key: string | symbol) {\n return typeof key === 'string' && Boolean(computedRefs[key])\n },\n ownKeys() {\n return Object.keys(computedRefs)\n },\n getOwnPropertyDescriptor(_target, key: string | symbol) {\n if (typeof key === 'string' && computedRefs[key]) {\n return {\n configurable: true,\n enumerable: true,\n value: computedRefs[key].value,\n }\n }\n return undefined\n },\n },\n )\n\n return {\n computedRefs,\n computedSetters,\n dirtyComputedKeys,\n createT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
6
|
import { normalizeEmitEventName, normalizeEmitPayload } from "../emit.mjs";
|
|
7
7
|
import { isNativeBridgeMethod, markNativeBridgeMethod } from "../nativeBridge.mjs";
|
|
8
8
|
import { createComputedAccessors } from "./computed.mjs";
|
|
9
|
-
import { WEVU_COMPONENT_NAME_KEY, WEVU_INLINE_MAP_KEY, WEVU_NATIVE_INSTANCE_KEY, WEVU_PARENT_INSTANCE_KEY, WEVU_PROPS_KEY, WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD, WEVU_RUNTIME_APP_KEY, WEVU_RUNTIME_KEY } from "@weapp-core/constants";
|
|
9
|
+
import { WEVU_COMPONENT_NAME_KEY, WEVU_HOST_COMMIT_PROMISE_KEY, WEVU_INLINE_MAP_KEY, WEVU_NATIVE_INSTANCE_KEY, WEVU_PARENT_INSTANCE_KEY, WEVU_PROPS_KEY, WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD, WEVU_RUNTIME_APP_KEY, WEVU_RUNTIME_KEY } from "@weapp-core/constants";
|
|
10
10
|
|
|
11
11
|
//#region src/runtime/app/context.ts
|
|
12
12
|
function createRuntimeContext(options) {
|
|
@@ -118,7 +118,13 @@ function createRuntimeContext(options) {
|
|
|
118
118
|
const { detail, options } = normalizeEmitPayload(args);
|
|
119
119
|
return triggerEvent.call(nativeInstance, normalizeEmitEventName(eventName), detail, options);
|
|
120
120
|
};
|
|
121
|
-
if (key === "$nextTick") return (fn) =>
|
|
121
|
+
if (key === "$nextTick") return async (fn) => {
|
|
122
|
+
await nextTick();
|
|
123
|
+
const nativeInstance = resolveNativeInstance(target, receiver);
|
|
124
|
+
const hostCommit = nativeInstance && Reflect.get(nativeInstance, WEVU_HOST_COMMIT_PROMISE_KEY);
|
|
125
|
+
if (hostCommit && (typeof hostCommit === "object" || typeof hostCommit === "function") && "then" in hostCommit && typeof hostCommit.then === "function") await hostCommit;
|
|
126
|
+
if (fn) return fn.call(publicInstance);
|
|
127
|
+
};
|
|
122
128
|
if (key === "$set") return (object, property, value) => {
|
|
123
129
|
Reflect.set(object, property, value);
|
|
124
130
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":[],"sources":["../../../../src/runtime/app/context.ts"],"sourcesContent":["import type { WritableComputedOptions } from '../../reactivity'\nimport type { AppConfig, ComponentPublicInstance, ComputedDefinitions, ExtractMethods, MethodDefinitions } from '../types'\nimport {\n WEVU_COMPONENT_NAME_KEY,\n WEVU_INLINE_MAP_KEY,\n WEVU_NATIVE_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROPS_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_APP_KEY,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { isRef, ref, toRaw } from '../../reactivity'\nimport { nextTick } from '../../scheduler'\nimport { hasOwn } from '../../utils'\nimport { normalizeEmitEventName, normalizeEmitPayload } from '../emit'\nimport { setComputedValue } from '../internal'\nimport { isNativeBridgeMethod, markNativeBridgeMethod } from '../nativeBridge'\nimport { createComputedAccessors } from './computed'\n\nexport function createRuntimeContext<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n state: D\n setupState: Record<string, any>\n computedDefs: C\n methodDefs: M\n appConfig: AppConfig\n includeComputed: boolean\n setDataStrategy: 'diff' | 'patch'\n}) {\n const {\n state,\n setupState,\n computedDefs,\n methodDefs,\n appConfig,\n includeComputed,\n setDataStrategy,\n } = options\n\n const boundMethods = {} as ExtractMethods<M>\n const {\n computedRefs,\n computedSetters,\n dirtyComputedKeys,\n createTrackedComputed,\n computedProxy,\n } = createComputedAccessors({ includeComputed, setDataStrategy })\n const setupMethodVersion = ref(0)\n const instanceFields = Object.create(null) as Record<PropertyKey, any>\n\n const resolveNativeInstance = (target: object, receiver: object) => {\n const rawTarget = toRaw(target as any) as Record<string, any>\n const runtimeRef = rawTarget[WEVU_RUNTIME_KEY]\n const runtimeProxy = runtimeRef?.proxy as Record<string, any> | undefined\n const isBridgeMethod = (\n candidate: object,\n methodName: 'triggerEvent' | 'createSelectorQuery' | 'createIntersectionObserver' | 'setData',\n ) => {\n const candidateMethod = (candidate as any)[methodName]\n return isNativeBridgeMethod(candidateMethod)\n }\n const isValidNativeCandidate = (candidate: unknown) => {\n if (!candidate || typeof candidate !== 'object') {\n return false\n }\n if (candidate === target || candidate === receiver || candidate === runtimeProxy) {\n return false\n }\n if (\n isBridgeMethod(candidate, 'triggerEvent')\n || isBridgeMethod(candidate, 'createSelectorQuery')\n || isBridgeMethod(candidate, 'createIntersectionObserver')\n || isBridgeMethod(candidate, 'setData')\n ) {\n return false\n }\n return true\n }\n const directNative = rawTarget[WEVU_NATIVE_INSTANCE_KEY]\n if (isValidNativeCandidate(directNative)) {\n return directNative as object\n }\n const runtimeNative = runtimeRef?.instance\n if (isValidNativeCandidate(runtimeNative)) {\n return runtimeNative as object\n }\n return undefined\n }\n\n const installNativeMethodBridge = (methodName: string) => {\n if (hasOwn(boundMethods, methodName)) {\n return\n }\n const bridge = (...args: any[]) => {\n const nativeInstance = resolveNativeInstance(state as object, state as object)\n if (!nativeInstance) {\n return undefined\n }\n const nativeMethod = Reflect.get(nativeInstance, methodName)\n if (typeof nativeMethod === 'function') {\n return nativeMethod.apply(nativeInstance, args)\n }\n return undefined\n }\n markNativeBridgeMethod(bridge)\n ;(boundMethods as any)[methodName] = bridge\n }\n\n const resolveGlobalProperty = (nativeInstance: object | undefined, key: string) => {\n const seen = new Set<object>()\n let current = nativeInstance as Record<string, any> | undefined\n while (current && !seen.has(current)) {\n seen.add(current)\n const globalProperties = current[WEVU_RUNTIME_APP_KEY]?.config?.globalProperties\n if (globalProperties && hasOwn(globalProperties, key)) {\n return { found: true, value: globalProperties[key] }\n }\n current = current[WEVU_PARENT_INSTANCE_KEY]\n }\n\n const getAppFn = typeof globalThis !== 'undefined'\n ? (globalThis as Record<string, any>).getApp\n : undefined\n if (typeof getAppFn === 'function') {\n try {\n const rootAppInstance = getAppFn()\n const globalProperties = rootAppInstance?.[WEVU_RUNTIME_APP_KEY]?.config?.globalProperties\n if (globalProperties && hasOwn(globalProperties, key)) {\n return { found: true, value: globalProperties[key] }\n }\n }\n catch {\n // App 尚未初始化时保持普通属性回退语义。\n }\n }\n return { found: false, value: undefined }\n }\n\n const resolveParentPublicInstance = (nativeInstance: object | undefined) => {\n const selectOwnerComponent = nativeInstance && Reflect.get(nativeInstance, 'selectOwnerComponent')\n if (typeof selectOwnerComponent !== 'function') {\n return undefined\n }\n try {\n const owner = selectOwnerComponent.call(nativeInstance)\n if (!owner || typeof owner !== 'object') {\n return undefined\n }\n const resolvePublicInstance = Reflect.get(owner, WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD)\n if (typeof resolvePublicInstance === 'function') {\n const publicInstance = resolvePublicInstance.call(owner)\n if (publicInstance) {\n return publicInstance\n }\n }\n return owner[WEVU_RUNTIME_KEY]?.proxy ?? owner.__wevu?.proxy ?? owner\n }\n catch {\n return undefined\n }\n }\n\n const publicInstance = new Proxy(state as ComponentPublicInstance<D, C, M>, {\n get(target, key, receiver) {\n if (typeof key === 'string') {\n // setup 返回的方法会在运行时后置注入,读取版本号可确保相关 computed 在方法注入后失效重算。\n void setupMethodVersion.value\n if (hasOwn(setupState, key)) {\n return Reflect.get(setupState, key, receiver)\n }\n if (key === 'props') {\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object') {\n return props\n }\n }\n if (key === '$props') {\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object') {\n return props\n }\n }\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object' && hasOwn(props, key)) {\n return Reflect.get(props, key)\n }\n if (key === 'data') {\n return state\n }\n if (key === '$state') {\n return state\n }\n if (key === '$computed') {\n return computedProxy\n }\n if (key === '$emit') {\n return (eventName: string, ...args: any[]) => {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object)\n const triggerEvent = nativeInstance && Reflect.get(nativeInstance, 'triggerEvent')\n if (typeof triggerEvent !== 'function') {\n return undefined\n }\n const { detail, options } = normalizeEmitPayload(args)\n return triggerEvent.call(nativeInstance, normalizeEmitEventName(eventName), detail, options)\n }\n }\n if (key === '$nextTick') {\n return <T>(fn?: () => T) => fn\n ? nextTick(() => fn.call(publicInstance))\n : nextTick<T>()\n }\n if (key === '$set') {\n return (object: Record<PropertyKey, any>, property: PropertyKey, value: any) => {\n Reflect.set(object, property, value)\n return value\n }\n }\n if (key === '$delete') {\n return (object: Record<PropertyKey, any>, property: PropertyKey) => Reflect.deleteProperty(object, property)\n }\n if (key === '$slots') {\n const rawTarget = toRaw(target as any) as Record<string, any>\n return rawTarget.$slots ?? Object.freeze(Object.create(null))\n }\n if (key === '$refs') {\n const rawTarget = toRaw(target as any) as Record<string, any>\n return rawTarget.$refs ?? Object.create(null)\n }\n if (key === '$parent') {\n return resolveParentPublicInstance(resolveNativeInstance(target as object, receiver as object))\n }\n if (key === '$options') {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object) as Record<string, any> | undefined\n return {\n name: nativeInstance?.[WEVU_COMPONENT_NAME_KEY] ?? nativeInstance?.name ?? nativeInstance?.is,\n }\n }\n if (hasOwn(instanceFields, key)) {\n return Reflect.get(instanceFields, key)\n }\n if (hasOwn(boundMethods, key)) {\n return boundMethods[key as keyof ExtractMethods<M>]\n }\n if ((computedRefs as any)[key]) {\n return (computedRefs as any)[key].value\n }\n if (hasOwn(appConfig.globalProperties, key)) {\n return (appConfig.globalProperties as any)[key]\n }\n const globalProperty = resolveGlobalProperty(\n resolveNativeInstance(target as object, receiver as object),\n key,\n )\n if (globalProperty.found) {\n return globalProperty.value\n }\n }\n if (!Reflect.has(target, key)) {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object)\n if (nativeInstance && Reflect.has(nativeInstance, key)) {\n const nativeValue = Reflect.get(nativeInstance, key)\n if (typeof nativeValue === 'function') {\n return nativeValue.bind(nativeInstance)\n }\n return nativeValue\n }\n }\n const targetValue = Reflect.get(target, key, receiver)\n if (typeof key === 'string' && hasOwn(setupState, key)) {\n return Reflect.get(setupState, key, receiver)\n }\n return targetValue\n },\n set(target, key, value, receiver) {\n if (typeof key === 'string' && (computedRefs as any)[key]) {\n setComputedValue(computedSetters, key, value)\n return true\n }\n if (hasOwn(setupState, key)) {\n const existingValue = Reflect.get(setupState, key, receiver)\n if (isRef(existingValue) && !isRef(value)) {\n existingValue.value = value\n return true\n }\n return Reflect.set(setupState, key, value, receiver)\n }\n if (hasOwn(instanceFields, key)) {\n return Reflect.set(instanceFields, key, value)\n }\n if (Reflect.has(target, key)) {\n const existingValue = Reflect.get(target, key, receiver)\n if (isRef(existingValue) && !isRef(value)) {\n existingValue.value = value\n return true\n }\n if (hasOwn((target as any)[WEVU_PROPS_KEY] ?? {}, key)) {\n return Reflect.set(setupState, key, value, receiver)\n }\n return Reflect.set(target, key, value, receiver)\n }\n return Reflect.set(instanceFields, key, value)\n },\n has(target, key) {\n if (\n key === 'data'\n || key === '$emit'\n || key === '$nextTick'\n || key === '$set'\n || key === '$delete'\n || key === '$slots'\n || key === '$refs'\n || key === '$parent'\n || key === '$options'\n ) {\n return true\n }\n if (typeof key === 'string' && (hasOwn(setupState, key) || (computedRefs as any)[key] || hasOwn(boundMethods, key))) {\n return true\n }\n if (hasOwn(instanceFields, key)) {\n return true\n }\n const nativeInstance = resolveNativeInstance(target as object, target as object)\n if (typeof key === 'string' && resolveGlobalProperty(nativeInstance, key).found) {\n return true\n }\n if (nativeInstance && Reflect.has(nativeInstance, key)) {\n return true\n }\n return Reflect.has(target, key)\n },\n ownKeys(target) {\n const keys = new Set<string | symbol>()\n Reflect.ownKeys(target).forEach((key) => {\n keys.add(key as string | symbol)\n })\n Reflect.ownKeys(setupState).forEach((key) => {\n keys.add(key as string | symbol)\n })\n Reflect.ownKeys(instanceFields).forEach(key => keys.add(key))\n Object.keys(boundMethods).forEach(key => keys.add(key))\n Object.keys(computedRefs).forEach(key => keys.add(key))\n return [...keys]\n },\n getOwnPropertyDescriptor(target, key) {\n if (typeof key === 'string' && hasOwn(setupState, key)) {\n return Object.getOwnPropertyDescriptor(setupState, key)\n }\n if (hasOwn(instanceFields, key)) {\n return Object.getOwnPropertyDescriptor(instanceFields, key)\n }\n if (Reflect.has(target, key)) {\n return Object.getOwnPropertyDescriptor(target, key)\n }\n if (typeof key === 'string') {\n if (key === 'data') {\n return {\n configurable: true,\n enumerable: false,\n get() {\n return state\n },\n }\n }\n if ((computedRefs as any)[key]) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return (computedRefs as any)[key].value\n },\n set(value: any) {\n setComputedValue(computedSetters, key, value)\n },\n }\n }\n if (hasOwn(boundMethods, key)) {\n return {\n configurable: true,\n enumerable: false,\n value: boundMethods[key as keyof ExtractMethods<M>],\n }\n }\n }\n return undefined\n },\n })\n\n Object.keys(methodDefs).forEach((key) => {\n const handler = (methodDefs as any)[key]\n if (typeof handler === 'function') {\n ;(boundMethods as any)[key] = (...args: any[]) => handler.apply(publicInstance, args)\n return\n }\n if (key === WEVU_INLINE_MAP_KEY && handler && typeof handler === 'object') {\n ;(boundMethods as any)[key] = handler\n }\n })\n\n installNativeMethodBridge('triggerEvent')\n installNativeMethodBridge('createSelectorQuery')\n installNativeMethodBridge('createIntersectionObserver')\n installNativeMethodBridge('setData')\n\n Object.keys(computedDefs).forEach((key) => {\n const definition = (computedDefs as any)[key] as ((this: any) => any) | WritableComputedOptions<any>\n if (typeof definition === 'function') {\n computedRefs[key] = createTrackedComputed(key, () => (definition as any).call(publicInstance))\n }\n else {\n const getter = definition.get?.bind(publicInstance)\n if (!getter) {\n throw new Error(`计算属性 \"${key}\" 需要提供 getter`)\n }\n const setter = definition.set?.bind(publicInstance)\n if (setter) {\n computedSetters[key] = setter\n computedRefs[key] = createTrackedComputed(key, getter, setter)\n }\n else {\n computedRefs[key] = createTrackedComputed(key, getter)\n }\n }\n })\n\n return {\n boundMethods,\n computedRefs,\n computedSetters,\n dirtyComputedKeys,\n comput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aAAqB,QAAQ,GAAG,SAAgB,QAAQ,MAAM,gBAAgB,IAAI;GACpF;EACF;EACA,IAAI,QAAQ,uBAAuB,WAAW,OAAO,YAAY,UAC9D,AAAC,aAAqB,OAAO;CAElC,CAAC;CAED,0BAA0B,cAAc;CACxC,0BAA0B,qBAAqB;CAC/C,0BAA0B,4BAA4B;CACtD,0BAA0B,SAAS;CAEnC,OAAO,KAAK,YAAY,CAAC,CAAC,SAAS,QAAQ;EACzC,MAAM,aAAc,aAAqB;EACzC,IAAI,OAAO,eAAe,YACxB,aAAa,OAAO,sBAAsB,WAAY,WAAmB,KAAK,cAAc,CAAC;OAE1F;;GACH,MAAM,4BAAS,WAAW,uEAAK,KAAK,cAAc;GAClD,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,SAAS,IAAI,cAAc;GAE7C,MAAM,4BAAS,WAAW,uEAAK,KAAK,cAAc;GAClD,IAAI,QAAQ;IACV,gBAAgB,OAAO;IACvB,aAAa,OAAO,sBAAsB,KAAK,QAAQ,MAAM;GAC/D,OAEE,aAAa,OAAO,sBAAsB,KAAK,MAAM;EAEzD;CACF,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,2BAA2B;GACzB,mBAAmB,SAAS;EAC9B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"context.mjs","names":[],"sources":["../../../../src/runtime/app/context.ts"],"sourcesContent":["import type { WritableComputedOptions } from '../../reactivity'\nimport type { AppConfig, ComponentPublicInstance, ComputedDefinitions, ExtractMethods, MethodDefinitions } from '../types'\nimport {\n WEVU_COMPONENT_NAME_KEY,\n WEVU_HOST_COMMIT_PROMISE_KEY,\n WEVU_INLINE_MAP_KEY,\n WEVU_NATIVE_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROPS_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_APP_KEY,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { isRef, ref, toRaw } from '../../reactivity'\nimport { nextTick } from '../../scheduler'\nimport { hasOwn } from '../../utils'\nimport { normalizeEmitEventName, normalizeEmitPayload } from '../emit'\nimport { setComputedValue } from '../internal'\nimport { isNativeBridgeMethod, markNativeBridgeMethod } from '../nativeBridge'\nimport { createComputedAccessors } from './computed'\n\nexport function createRuntimeContext<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n state: D\n setupState: Record<string, any>\n computedDefs: C\n methodDefs: M\n appConfig: AppConfig\n includeComputed: boolean\n setDataStrategy: 'diff' | 'patch'\n}) {\n const {\n state,\n setupState,\n computedDefs,\n methodDefs,\n appConfig,\n includeComputed,\n setDataStrategy,\n } = options\n\n const boundMethods = {} as ExtractMethods<M>\n const {\n computedRefs,\n computedSetters,\n dirtyComputedKeys,\n createTrackedComputed,\n computedProxy,\n } = createComputedAccessors({ includeComputed, setDataStrategy })\n const setupMethodVersion = ref(0)\n const instanceFields = Object.create(null) as Record<PropertyKey, any>\n\n const resolveNativeInstance = (target: object, receiver: object) => {\n const rawTarget = toRaw(target as any) as Record<string, any>\n const runtimeRef = rawTarget[WEVU_RUNTIME_KEY]\n const runtimeProxy = runtimeRef?.proxy as Record<string, any> | undefined\n const isBridgeMethod = (\n candidate: object,\n methodName: 'triggerEvent' | 'createSelectorQuery' | 'createIntersectionObserver' | 'setData',\n ) => {\n const candidateMethod = (candidate as any)[methodName]\n return isNativeBridgeMethod(candidateMethod)\n }\n const isValidNativeCandidate = (candidate: unknown) => {\n if (!candidate || typeof candidate !== 'object') {\n return false\n }\n if (candidate === target || candidate === receiver || candidate === runtimeProxy) {\n return false\n }\n if (\n isBridgeMethod(candidate, 'triggerEvent')\n || isBridgeMethod(candidate, 'createSelectorQuery')\n || isBridgeMethod(candidate, 'createIntersectionObserver')\n || isBridgeMethod(candidate, 'setData')\n ) {\n return false\n }\n return true\n }\n const directNative = rawTarget[WEVU_NATIVE_INSTANCE_KEY]\n if (isValidNativeCandidate(directNative)) {\n return directNative as object\n }\n const runtimeNative = runtimeRef?.instance\n if (isValidNativeCandidate(runtimeNative)) {\n return runtimeNative as object\n }\n return undefined\n }\n\n const installNativeMethodBridge = (methodName: string) => {\n if (hasOwn(boundMethods, methodName)) {\n return\n }\n const bridge = (...args: any[]) => {\n const nativeInstance = resolveNativeInstance(state as object, state as object)\n if (!nativeInstance) {\n return undefined\n }\n const nativeMethod = Reflect.get(nativeInstance, methodName)\n if (typeof nativeMethod === 'function') {\n return nativeMethod.apply(nativeInstance, args)\n }\n return undefined\n }\n markNativeBridgeMethod(bridge)\n ;(boundMethods as any)[methodName] = bridge\n }\n\n const resolveGlobalProperty = (nativeInstance: object | undefined, key: string) => {\n const seen = new Set<object>()\n let current = nativeInstance as Record<string, any> | undefined\n while (current && !seen.has(current)) {\n seen.add(current)\n const globalProperties = current[WEVU_RUNTIME_APP_KEY]?.config?.globalProperties\n if (globalProperties && hasOwn(globalProperties, key)) {\n return { found: true, value: globalProperties[key] }\n }\n current = current[WEVU_PARENT_INSTANCE_KEY]\n }\n\n const getAppFn = typeof globalThis !== 'undefined'\n ? (globalThis as Record<string, any>).getApp\n : undefined\n if (typeof getAppFn === 'function') {\n try {\n const rootAppInstance = getAppFn()\n const globalProperties = rootAppInstance?.[WEVU_RUNTIME_APP_KEY]?.config?.globalProperties\n if (globalProperties && hasOwn(globalProperties, key)) {\n return { found: true, value: globalProperties[key] }\n }\n }\n catch {\n // App 尚未初始化时保持普通属性回退语义。\n }\n }\n return { found: false, value: undefined }\n }\n\n const resolveParentPublicInstance = (nativeInstance: object | undefined) => {\n const selectOwnerComponent = nativeInstance && Reflect.get(nativeInstance, 'selectOwnerComponent')\n if (typeof selectOwnerComponent !== 'function') {\n return undefined\n }\n try {\n const owner = selectOwnerComponent.call(nativeInstance)\n if (!owner || typeof owner !== 'object') {\n return undefined\n }\n const resolvePublicInstance = Reflect.get(owner, WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD)\n if (typeof resolvePublicInstance === 'function') {\n const publicInstance = resolvePublicInstance.call(owner)\n if (publicInstance) {\n return publicInstance\n }\n }\n return owner[WEVU_RUNTIME_KEY]?.proxy ?? owner.__wevu?.proxy ?? owner\n }\n catch {\n return undefined\n }\n }\n\n const publicInstance = new Proxy(state as ComponentPublicInstance<D, C, M>, {\n get(target, key, receiver) {\n if (typeof key === 'string') {\n // setup 返回的方法会在运行时后置注入,读取版本号可确保相关 computed 在方法注入后失效重算。\n void setupMethodVersion.value\n if (hasOwn(setupState, key)) {\n return Reflect.get(setupState, key, receiver)\n }\n if (key === 'props') {\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object') {\n return props\n }\n }\n if (key === '$props') {\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object') {\n return props\n }\n }\n const props = (target as any)[WEVU_PROPS_KEY]\n if (props && typeof props === 'object' && hasOwn(props, key)) {\n return Reflect.get(props, key)\n }\n if (key === 'data') {\n return state\n }\n if (key === '$state') {\n return state\n }\n if (key === '$computed') {\n return computedProxy\n }\n if (key === '$emit') {\n return (eventName: string, ...args: any[]) => {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object)\n const triggerEvent = nativeInstance && Reflect.get(nativeInstance, 'triggerEvent')\n if (typeof triggerEvent !== 'function') {\n return undefined\n }\n const { detail, options } = normalizeEmitPayload(args)\n return triggerEvent.call(nativeInstance, normalizeEmitEventName(eventName), detail, options)\n }\n }\n if (key === '$nextTick') {\n return async <T>(fn?: () => T) => {\n await nextTick()\n const nativeInstance = resolveNativeInstance(target as object, receiver as object)\n const hostCommit = nativeInstance && Reflect.get(nativeInstance, WEVU_HOST_COMMIT_PROMISE_KEY)\n if (\n hostCommit\n && (typeof hostCommit === 'object' || typeof hostCommit === 'function')\n && 'then' in hostCommit\n && typeof hostCommit.then === 'function'\n ) {\n await hostCommit\n }\n if (fn) {\n return fn.call(publicInstance)\n }\n }\n }\n if (key === '$set') {\n return (object: Record<PropertyKey, any>, property: PropertyKey, value: any) => {\n Reflect.set(object, property, value)\n return value\n }\n }\n if (key === '$delete') {\n return (object: Record<PropertyKey, any>, property: PropertyKey) => Reflect.deleteProperty(object, property)\n }\n if (key === '$slots') {\n const rawTarget = toRaw(target as any) as Record<string, any>\n return rawTarget.$slots ?? Object.freeze(Object.create(null))\n }\n if (key === '$refs') {\n const rawTarget = toRaw(target as any) as Record<string, any>\n return rawTarget.$refs ?? Object.create(null)\n }\n if (key === '$parent') {\n return resolveParentPublicInstance(resolveNativeInstance(target as object, receiver as object))\n }\n if (key === '$options') {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object) as Record<string, any> | undefined\n return {\n name: nativeInstance?.[WEVU_COMPONENT_NAME_KEY] ?? nativeInstance?.name ?? nativeInstance?.is,\n }\n }\n if (hasOwn(instanceFields, key)) {\n return Reflect.get(instanceFields, key)\n }\n if (hasOwn(boundMethods, key)) {\n return boundMethods[key as keyof ExtractMethods<M>]\n }\n if ((computedRefs as any)[key]) {\n return (computedRefs as any)[key].value\n }\n if (hasOwn(appConfig.globalProperties, key)) {\n return (appConfig.globalProperties as any)[key]\n }\n const globalProperty = resolveGlobalProperty(\n resolveNativeInstance(target as object, receiver as object),\n key,\n )\n if (globalProperty.found) {\n return globalProperty.value\n }\n }\n if (!Reflect.has(target, key)) {\n const nativeInstance = resolveNativeInstance(target as object, receiver as object)\n if (nativeInstance && Reflect.has(nativeInstance, key)) {\n const nativeValue = Reflect.get(nativeInstance, key)\n if (typeof nativeValue === 'function') {\n return nativeValue.bind(nativeInstance)\n }\n return nativeValue\n }\n }\n const targetValue = Reflect.get(target, key, receiver)\n if (typeof key === 'string' && hasOwn(setupState, key)) {\n return Reflect.get(setupState, key, receiver)\n }\n return targetValue\n },\n set(target, key, value, receiver) {\n if (typeof key === 'string' && (computedRefs as any)[key]) {\n setComputedValue(computedSetters, key, value)\n return true\n }\n if (hasOwn(setupState, key)) {\n const existingValue = Reflect.get(setupState, key, receiver)\n if (isRef(existingValue) && !isRef(value)) {\n existingValue.value = value\n return true\n }\n return Reflect.set(setupState, key, value, receiver)\n }\n if (hasOwn(instanceFields, key)) {\n return Reflect.set(instanceFields, key, value)\n }\n if (Reflect.has(target, key)) {\n const existingValue = Reflect.get(target, key, receiver)\n if (isRef(existingValue) && !isRef(value)) {\n existingValue.value = value\n return true\n }\n if (hasOwn((target as any)[WEVU_PROPS_KEY] ?? {}, key)) {\n return Reflect.set(setupState, key, value, receiver)\n }\n return Reflect.set(target, key, value, receiver)\n }\n return Reflect.set(instanceFields, key, value)\n },\n has(target, key) {\n if (\n key === 'data'\n || key === '$emit'\n || key === '$nextTick'\n || key === '$set'\n || key === '$delete'\n || key === '$slots'\n || key === '$refs'\n || key === '$parent'\n || key === '$options'\n ) {\n return true\n }\n if (typeof key === 'string' && (hasOwn(setupState, key) || (computedRefs as any)[key] || hasOwn(boundMethods, key))) {\n return true\n }\n if (hasOwn(instanceFields, key)) {\n return true\n }\n const nativeInstance = resolveNativeInstance(target as object, target as object)\n if (typeof key === 'string' && resolveGlobalProperty(nativeInstance, key).found) {\n return true\n }\n if (nativeInstance && Reflect.has(nativeInstance, key)) {\n return true\n }\n return Reflect.has(target, key)\n },\n ownKeys(target) {\n const keys = new Set<string | symbol>()\n Reflect.ownKeys(target).forEach((key) => {\n keys.add(key as string | symbol)\n })\n Reflect.ownKeys(setupState).forEach((key) => {\n keys.add(key as string | symbol)\n })\n Reflect.ownKeys(instanceFields).forEach(key => keys.add(key))\n Object.keys(boundMethods).forEach(key => keys.add(key))\n Object.keys(computedRefs).forEach(key => keys.add(key))\n return [...keys]\n },\n getOwnPropertyDescriptor(target, key) {\n if (typeof key === 'string' && hasOwn(setupState, key)) {\n return Object.getOwnPropertyDescriptor(setupState, key)\n }\n if (hasOwn(instanceFields, key)) {\n return Object.getOwnPropertyDescriptor(instanceFields, key)\n }\n if (Reflect.has(target, key)) {\n return Object.getOwnPropertyDescriptor(target, key)\n }\n if (typeof key === 'string') {\n if (key === 'data') {\n return {\n configurable: true,\n enumerable: false,\n get() {\n return state\n },\n }\n }\n if ((computedRefs as any)[key]) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return (computedRefs as any)[key].value\n },\n set(value: any) {\n setComputedValue(computedSetters, key, value)\n },\n }\n }\n if (hasOwn(boundMethods, key)) {\n return {\n configurable: true,\n enumerable: false,\n value: boundMethods[key as keyof ExtractMethods<M>],\n }\n }\n }\n return undefined\n },\n })\n\n Object.keys(methodDefs).forEach((key) => {\n const handler = (methodDefs as any)[key]\n if (typeof handler === 'function') {\n ;(boundMethods as any)[key] = (...args: any[]) => handler.apply(publicInstance, args)\n return\n }\n if (key === WEVU_INLINE_MAP_KEY && handler && typeof handler === 'object') {\n ;(boundMethods as any)[key] = handler\n }\n })\n\n installNativeMethodBridge('triggerEvent')\n installNativeMethodBridge('createSelectorQuery')\n installNativeMethodBridge('createIntersectionObserver')\n installNativeMethodBridge('setData')\n\n Object.keys(computedDefs).forEach((key) => {\n const definition = (computedDefs as any)[key] as ((this: any) => any) | WritableComputedOptions<any>\n if (typeof definition === 'function') {\n computedRefs[key] = createTrackedComputed(key, () => (definition as any).call(publicInstance))\n }\n else {\n const getter = definition.get?.bind(publicInstance)\n if (!getter) {\n throw new Error(`计算属性 \"${key}\" 需要提供 getter`)\n }\n const setter = definition.set?.bind(publicInstance)\n if (setter) {\n computedSetters[key] = setter\n computedRefs[key] = createTrackedComputed(key, getter, setter)\n }\n else {\n computedRefs[key] = createTrackedComputed(key, getter)\n }\n }\n })\n\n return {\n boundMethods,\n computedRefs,\n computedSetters,\n dirtyComputedKeys,\n computedProxy,\n publicInstance,\n touchSetupMethodsVersion() {\n setupMethodVersion.value += 1\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,qBAAmG,SAQhH;CACD,MAAM,EACJ,OACA,YACA,cACA,YACA,WACA,iBACA,oBACE;CAEJ,MAAM,eAAe,CAAC;CACtB,MAAM,EACJ,cACA,iBACA,mBACA,uBACA,kBACE,wBAAwB;EAAE;EAAiB;CAAg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I;GACpF;EACF;EACA,IAAI,QAAQ,uBAAuB,WAAW,OAAO,YAAY,UAC9D,AAAC,aAAqB,OAAO;CAElC,CAAC;CAED,0BAA0B,cAAc;CACxC,0BAA0B,qBAAqB;CAC/C,0BAA0B,4BAA4B;CACtD,0BAA0B,SAAS;CAEnC,OAAO,KAAK,YAAY,CAAC,CAAC,SAAS,QAAQ;EACzC,MAAM,aAAc,aAAqB;EACzC,IAAI,OAAO,eAAe,YACxB,aAAa,OAAO,sBAAsB,WAAY,WAAmB,KAAK,cAAc,CAAC;OAE1F;;GACH,MAAM,4BAAS,WAAW,uEAAK,KAAK,cAAc;GAClD,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,SAAS,IAAI,cAAc;GAE7C,MAAM,4BAAS,WAAW,uEAAK,KAAK,cAAc;GAClD,IAAI,QAAQ;IACV,gBAAgB,OAAO;IACvB,aAAa,OAAO,sBAAsB,KAAK,QAAQ,MAAM;GAC/D,OAEE,aAAa,OAAO,sBAAsB,KAAK,MAAM;EAEzD;CACF,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,2BAA2B;GACzB,mBAAmB,SAAS;EAC9B;CACF;AACF"}
|
|
@@ -5,6 +5,7 @@ function isFallbackReason(reason) {
|
|
|
5
5
|
function createDiagnosticsLogger(mode) {
|
|
6
6
|
if (mode === "off") return;
|
|
7
7
|
return (info) => {
|
|
8
|
+
var _info$bindings;
|
|
8
9
|
if (mode === "fallback" && !isFallbackReason(info.reason)) return;
|
|
9
10
|
const bytes = typeof info.bytes === "number" ? info.bytes : info.estimatedBytes;
|
|
10
11
|
const bytesText = typeof bytes === "number" ? `${bytes}B` : "unknown";
|
|
@@ -15,11 +16,22 @@ function createDiagnosticsLogger(mode) {
|
|
|
15
16
|
`keys=${info.payloadKeys}`,
|
|
16
17
|
`bytes=${bytesText}`
|
|
17
18
|
];
|
|
19
|
+
if (typeof info.revision === "number") parts.push(`revision=${info.revision}`);
|
|
20
|
+
if (typeof info.committedRevision === "number") parts.push(`committedRevision=${info.committedRevision}`);
|
|
18
21
|
if (typeof info.mergedSiblingParents === "number") parts.push(`mergedParents=${info.mergedSiblingParents}`);
|
|
19
22
|
if (typeof info.computedDirtyKeys === "number") parts.push(`computedDirty=${info.computedDirtyKeys}`);
|
|
20
23
|
if (typeof info.flushCount === "number") parts.push(`flushes=${info.flushCount}`);
|
|
21
24
|
if (typeof info.windowMs === "number") parts.push(`window=${info.windowMs}ms`);
|
|
22
25
|
if (info.targetLabel) parts.push(`target=${info.targetLabel}`);
|
|
26
|
+
if ((_info$bindings = info.bindings) === null || _info$bindings === void 0 ? void 0 : _info$bindings.length) {
|
|
27
|
+
const bindings = info.bindings.map((binding) => {
|
|
28
|
+
var _binding$sourceLocati;
|
|
29
|
+
const start = (_binding$sourceLocati = binding.sourceLocation) === null || _binding$sourceLocati === void 0 ? void 0 : _binding$sourceLocati.start;
|
|
30
|
+
return start ? `${binding.id}@${binding.sourceFile}:${start.line}:${start.column}` : `${binding.id}@${binding.sourceFile}`;
|
|
31
|
+
});
|
|
32
|
+
parts.push(`bindings=${bindings.join(",")}`);
|
|
33
|
+
}
|
|
34
|
+
if (info.message) parts.push(`message=${info.message}`);
|
|
23
35
|
const message = `[wevu:setData] ${parts.join(" ")}`;
|
|
24
36
|
if (isFallbackReason(info.reason)) {
|
|
25
37
|
console.warn(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.mjs","names":[],"sources":["../../../../src/runtime/app/diagnostics.ts"],"sourcesContent":["import type { SetDataDebugInfo } from '../types'\n\nfunction isFallbackReason(reason: SetDataDebugInfo['reason']) {\n return reason !== 'patch' && reason !== 'diff'\n}\n\nexport function createDiagnosticsLogger(mode: 'off' | 'fallback' | 'always') {\n if (mode === 'off') {\n return undefined\n }\n return (info: SetDataDebugInfo) => {\n if (mode === 'fallback' && !isFallbackReason(info.reason)) {\n return\n }\n const bytes = typeof info.bytes === 'number' ? info.bytes : info.estimatedBytes\n const bytesText = typeof bytes === 'number' ? `${bytes}B` : 'unknown'\n const parts = [\n `mode=${info.mode}`,\n `reason=${info.reason}`,\n `pending=${info.pendingPatchKeys}`,\n `keys=${info.payloadKeys}`,\n `bytes=${bytesText}`,\n ]\n if (typeof info.mergedSiblingParents === 'number') {\n parts.push(`mergedParents=${info.mergedSiblingParents}`)\n }\n if (typeof info.computedDirtyKeys === 'number') {\n parts.push(`computedDirty=${info.computedDirtyKeys}`)\n }\n if (typeof info.flushCount === 'number') {\n parts.push(`flushes=${info.flushCount}`)\n }\n if (typeof info.windowMs === 'number') {\n parts.push(`window=${info.windowMs}ms`)\n }\n if (info.targetLabel) {\n parts.push(`target=${info.targetLabel}`)\n }\n const message = `[wevu:setData] ${parts.join(' ')}`\n if (isFallbackReason(info.reason)) {\n // eslint-disable-next-line no-console\n console.warn(message)\n return\n }\n // eslint-disable-next-line no-console\n console.info(message)\n }\n}\n"],"mappings":";AAEA,SAAS,iBAAiB,QAAoC;CAC5D,OAAO,WAAW,WAAW,WAAW;AAC1C;AAEA,SAAgB,wBAAwB,MAAqC;CAC3E,IAAI,SAAS,OACX;CAEF,QAAQ,SAA2B
|
|
1
|
+
{"version":3,"file":"diagnostics.mjs","names":[],"sources":["../../../../src/runtime/app/diagnostics.ts"],"sourcesContent":["import type { SetDataDebugInfo } from '../types'\n\nfunction isFallbackReason(reason: SetDataDebugInfo['reason']) {\n return reason !== 'patch' && reason !== 'diff'\n}\n\nexport function createDiagnosticsLogger(mode: 'off' | 'fallback' | 'always') {\n if (mode === 'off') {\n return undefined\n }\n return (info: SetDataDebugInfo) => {\n if (mode === 'fallback' && !isFallbackReason(info.reason)) {\n return\n }\n const bytes = typeof info.bytes === 'number' ? info.bytes : info.estimatedBytes\n const bytesText = typeof bytes === 'number' ? `${bytes}B` : 'unknown'\n const parts = [\n `mode=${info.mode}`,\n `reason=${info.reason}`,\n `pending=${info.pendingPatchKeys}`,\n `keys=${info.payloadKeys}`,\n `bytes=${bytesText}`,\n ]\n if (typeof info.revision === 'number') {\n parts.push(`revision=${info.revision}`)\n }\n if (typeof info.committedRevision === 'number') {\n parts.push(`committedRevision=${info.committedRevision}`)\n }\n if (typeof info.mergedSiblingParents === 'number') {\n parts.push(`mergedParents=${info.mergedSiblingParents}`)\n }\n if (typeof info.computedDirtyKeys === 'number') {\n parts.push(`computedDirty=${info.computedDirtyKeys}`)\n }\n if (typeof info.flushCount === 'number') {\n parts.push(`flushes=${info.flushCount}`)\n }\n if (typeof info.windowMs === 'number') {\n parts.push(`window=${info.windowMs}ms`)\n }\n if (info.targetLabel) {\n parts.push(`target=${info.targetLabel}`)\n }\n if (info.bindings?.length) {\n const bindings = info.bindings.map((binding) => {\n const start = binding.sourceLocation?.start\n return start\n ? `${binding.id}@${binding.sourceFile}:${start.line}:${start.column}`\n : `${binding.id}@${binding.sourceFile}`\n })\n parts.push(`bindings=${bindings.join(',')}`)\n }\n if (info.message) {\n parts.push(`message=${info.message}`)\n }\n const message = `[wevu:setData] ${parts.join(' ')}`\n if (isFallbackReason(info.reason)) {\n // eslint-disable-next-line no-console\n console.warn(message)\n return\n }\n // eslint-disable-next-line no-console\n console.info(message)\n }\n}\n"],"mappings":";AAEA,SAAS,iBAAiB,QAAoC;CAC5D,OAAO,WAAW,WAAW,WAAW;AAC1C;AAEA,SAAgB,wBAAwB,MAAqC;CAC3E,IAAI,SAAS,OACX;CAEF,QAAQ,SAA2B;;EACjC,IAAI,SAAS,cAAc,CAAC,iBAAiB,KAAK,MAAM,GACtD;EAEF,MAAM,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,KAAK;EACjE,MAAM,YAAY,OAAO,UAAU,WAAW,GAAG,MAAM,KAAK;EAC5D,MAAM,QAAQ;GACZ,QAAQ,KAAK;GACb,UAAU,KAAK;GACf,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,SAAS;EACX;EACA,IAAI,OAAO,KAAK,aAAa,UAC3B,MAAM,KAAK,YAAY,KAAK,UAAU;EAExC,IAAI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