wevu 6.18.7 → 6.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.mjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.mjs +1 -0
- package/dist/{rolldown-runtime-CenpyGzJ.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
- package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.mjs +14 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.mjs +16 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.mjs +11 -0
- package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.mjs +12 -0
- package/dist/dev/{rolldown-runtime-BUUfjzRC.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
- package/dist/dev/index.mjs +49 -10
- package/dist/dev/internal-reactivity.mjs +15 -5
- package/dist/dev/internal-runtime.mjs +32 -4
- package/dist/dev/internal-template.mjs +1 -1
- package/dist/dev/package.mjs +6 -0
- package/dist/dev/package.mjs.map +1 -0
- package/dist/dev/reactivity/computed.mjs +49 -0
- package/dist/dev/reactivity/computed.mjs.map +1 -0
- package/dist/dev/reactivity/core.mjs +184 -0
- package/dist/dev/reactivity/core.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/mutation.mjs +12 -0
- package/dist/dev/reactivity/reactive/mutation.mjs.map +1 -0
- package/dist/dev/{computed-BxRsUJgi.mjs → reactivity/reactive/patch.mjs} +6 -48
- package/dist/dev/reactivity/reactive/patch.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/patchState.mjs +138 -0
- package/dist/dev/reactivity/reactive/patchState.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/shallow.mjs +77 -0
- package/dist/dev/reactivity/reactive/shallow.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/shared.mjs +40 -0
- package/dist/dev/reactivity/reactive/shared.mjs.map +1 -0
- package/dist/dev/reactivity/reactive/state.mjs +8 -0
- package/dist/dev/reactivity/reactive/state.mjs.map +1 -0
- package/dist/dev/reactivity/reactive.mjs +212 -0
- package/dist/dev/reactivity/reactive.mjs.map +1 -0
- package/dist/dev/reactivity/readonly.mjs +69 -0
- package/dist/dev/reactivity/readonly.mjs.map +1 -0
- package/dist/dev/reactivity/ref.mjs +97 -0
- package/dist/dev/reactivity/ref.mjs.map +1 -0
- package/dist/dev/reactivity/shallowRef.mjs +71 -0
- package/dist/dev/reactivity/shallowRef.mjs.map +1 -0
- package/dist/dev/{toRefs-D06VmFK2.mjs → reactivity/toRefs.mjs} +4 -3
- package/dist/dev/reactivity/toRefs.mjs.map +1 -0
- package/dist/dev/reactivity/traverse.mjs +40 -0
- package/dist/dev/reactivity/traverse.mjs.map +1 -0
- package/dist/dev/reactivity/watch/helpers.mjs +78 -0
- package/dist/dev/reactivity/watch/helpers.mjs.map +1 -0
- package/dist/dev/reactivity/watch/types.mjs +20 -0
- package/dist/dev/reactivity/watch/types.mjs.map +1 -0
- package/dist/dev/reactivity/watch.mjs +167 -0
- package/dist/dev/reactivity/watch.mjs.map +1 -0
- package/dist/dev/router/backNavigation.mjs +32 -0
- package/dist/dev/router/backNavigation.mjs.map +1 -0
- package/dist/dev/router/createRouter.mjs +176 -0
- package/dist/dev/router/createRouter.mjs.map +1 -0
- package/dist/dev/router/instance.mjs +17 -0
- package/dist/dev/router/instance.mjs.map +1 -0
- package/dist/dev/router/navigationApi.mjs +94 -0
- package/dist/dev/router/navigationApi.mjs.map +1 -0
- package/dist/dev/router/navigationCore.mjs +139 -0
- package/dist/dev/router/navigationCore.mjs.map +1 -0
- package/dist/dev/router/navigationResult.mjs +54 -0
- package/dist/dev/router/navigationResult.mjs.map +1 -0
- package/dist/dev/router/navigationTarget.mjs +121 -0
- package/dist/dev/router/navigationTarget.mjs.map +1 -0
- package/dist/dev/router/navigationTargetHelpers.mjs +38 -0
- package/dist/dev/router/navigationTargetHelpers.mjs.map +1 -0
- package/dist/dev/router/resolve.mjs +22 -0
- package/dist/dev/router/resolve.mjs.map +1 -0
- package/dist/dev/router/routeRegistry.mjs +78 -0
- package/dist/dev/router/routeRegistry.mjs.map +1 -0
- package/dist/dev/router/routeSync.mjs +72 -0
- package/dist/dev/router/routeSync.mjs.map +1 -0
- package/dist/dev/router/types.mjs +11 -0
- package/dist/dev/router/types.mjs.map +1 -0
- package/dist/dev/router/useRoute.mjs +106 -0
- package/dist/dev/router/useRoute.mjs.map +1 -0
- package/dist/dev/router/useRouter.mjs +15 -0
- package/dist/dev/router/useRouter.mjs.map +1 -0
- package/dist/dev/router.mjs +9 -1378
- package/dist/dev/routerInternal/location.mjs +66 -0
- package/dist/dev/routerInternal/location.mjs.map +1 -0
- package/dist/dev/routerInternal/matching.mjs +149 -0
- package/dist/dev/routerInternal/matching.mjs.map +1 -0
- package/dist/dev/routerInternal/params.mjs +95 -0
- package/dist/dev/routerInternal/params.mjs.map +1 -0
- package/dist/dev/routerInternal/path.mjs +42 -0
- package/dist/dev/routerInternal/path.mjs.map +1 -0
- package/dist/dev/routerInternal/query.mjs +113 -0
- package/dist/dev/routerInternal/query.mjs.map +1 -0
- package/dist/dev/routerInternal/records.mjs +172 -0
- package/dist/dev/routerInternal/records.mjs.map +1 -0
- package/dist/dev/routerInternal/recordsWarnings.mjs +49 -0
- package/dist/dev/routerInternal/recordsWarnings.mjs.map +1 -0
- package/dist/dev/routerInternal/snapshots.mjs +126 -0
- package/dist/dev/routerInternal/snapshots.mjs.map +1 -0
- package/dist/dev/runtime/app/computed.mjs +68 -0
- package/dist/dev/runtime/app/computed.mjs.map +1 -0
- package/dist/dev/runtime/app/context.mjs +275 -0
- package/dist/dev/runtime/app/context.mjs.map +1 -0
- package/dist/dev/runtime/app/diagnostics.mjs +34 -0
- package/dist/dev/runtime/app/diagnostics.mjs.map +1 -0
- package/dist/dev/runtime/app/mount.mjs +269 -0
- package/dist/dev/runtime/app/mount.mjs.map +1 -0
- package/dist/dev/runtime/app/pending.mjs +14 -0
- package/dist/dev/runtime/app/pending.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +158 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/payload.mjs +161 -0
- package/dist/dev/runtime/app/setData/payload.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs +313 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/snapshot.mjs +129 -0
- package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -0
- package/dist/dev/runtime/app/setDataOptions.mjs +73 -0
- package/dist/dev/runtime/app/setDataOptions.mjs.map +1 -0
- package/dist/dev/runtime/app.mjs +93 -0
- package/dist/dev/runtime/app.mjs.map +1 -0
- package/dist/dev/runtime/bindModel.mjs +92 -0
- package/dist/dev/runtime/bindModel.mjs.map +1 -0
- package/dist/dev/runtime/defaults.mjs +61 -0
- package/dist/dev/runtime/defaults.mjs.map +1 -0
- package/dist/dev/runtime/define/initialComputed.mjs +125 -0
- package/dist/dev/runtime/define/initialComputed.mjs.map +1 -0
- package/dist/dev/runtime/define/options.mjs +169 -0
- package/dist/dev/runtime/define/options.mjs.map +1 -0
- package/dist/dev/runtime/define/optionsApi.mjs +48 -0
- package/dist/dev/runtime/define/optionsApi.mjs.map +1 -0
- package/dist/dev/runtime/define/props.mjs +194 -0
- package/dist/dev/runtime/define/props.mjs.map +1 -0
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +313 -0
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -0
- package/dist/dev/runtime/define/setupResult.mjs +78 -0
- package/dist/dev/runtime/define/setupResult.mjs.map +1 -0
- package/dist/dev/runtime/define.mjs +140 -0
- package/dist/dev/runtime/define.mjs.map +1 -0
- package/dist/dev/runtime/diff.mjs +193 -0
- package/dist/dev/runtime/diff.mjs.map +1 -0
- package/dist/dev/runtime/disposables.mjs +81 -0
- package/dist/dev/runtime/disposables.mjs.map +1 -0
- package/dist/dev/runtime/elementIntersectionObserver.mjs +80 -0
- package/dist/dev/runtime/elementIntersectionObserver.mjs.map +1 -0
- package/dist/dev/runtime/emit.mjs +36 -0
- package/dist/dev/runtime/emit.mjs.map +1 -0
- package/dist/dev/{base-CYkvI7w8.mjs → runtime/hooks/base.mjs} +3 -140
- package/dist/dev/runtime/hooks/base.mjs.map +1 -0
- package/dist/dev/runtime/hooks/register.mjs +92 -0
- package/dist/dev/runtime/hooks/register.mjs.map +1 -0
- package/dist/dev/runtime/hooks/vue.mjs +81 -0
- package/dist/dev/runtime/hooks/vue.mjs.map +1 -0
- package/dist/dev/runtime/internal.mjs +18 -0
- package/dist/dev/runtime/internal.mjs.map +1 -0
- package/dist/dev/runtime/intersectionObserver.mjs +46 -0
- package/dist/dev/runtime/intersectionObserver.mjs.map +1 -0
- package/dist/dev/runtime/layoutBridge.mjs +303 -0
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -0
- package/dist/dev/runtime/layoutComponentMatcher.mjs +11 -0
- package/dist/dev/runtime/layoutComponentMatcher.mjs.map +1 -0
- package/dist/dev/runtime/nativeBridge.mjs +21 -0
- package/dist/dev/runtime/nativeBridge.mjs.map +1 -0
- package/dist/dev/runtime/noSetData.mjs +18 -0
- package/dist/dev/runtime/noSetData.mjs.map +1 -0
- package/dist/dev/runtime/pageEnvironment.mjs +100 -0
- package/dist/dev/runtime/pageEnvironment.mjs.map +1 -0
- package/dist/dev/runtime/pageLayout.mjs +71 -0
- package/dist/dev/runtime/pageLayout.mjs.map +1 -0
- package/dist/dev/runtime/pageScroll.mjs +110 -0
- package/dist/dev/runtime/pageScroll.mjs.map +1 -0
- package/dist/dev/runtime/platform.mjs +77 -0
- package/dist/dev/runtime/platform.mjs.map +1 -0
- package/dist/dev/runtime/provide.mjs +71 -0
- package/dist/dev/runtime/provide.mjs.map +1 -0
- package/dist/dev/runtime/provideContext.mjs +101 -0
- package/dist/dev/runtime/provideContext.mjs.map +1 -0
- package/dist/dev/runtime/provideStore.mjs +18 -0
- package/dist/dev/runtime/provideStore.mjs.map +1 -0
- package/dist/dev/runtime/pullDownRefresh.mjs +24 -0
- package/dist/dev/runtime/pullDownRefresh.mjs.map +1 -0
- package/dist/dev/runtime/register/app.mjs +159 -0
- package/dist/dev/runtime/register/app.mjs.map +1 -0
- package/dist/dev/runtime/register/component/features.mjs +43 -0
- package/dist/dev/runtime/register/component/features.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +64 -0
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +95 -0
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle.mjs +122 -0
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -0
- package/dist/dev/runtime/register/component/methods.mjs +80 -0
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -0
- package/dist/dev/runtime/register/component/options.mjs +204 -0
- package/dist/dev/runtime/register/component/options.mjs.map +1 -0
- package/dist/dev/runtime/register/component/props.mjs +218 -0
- package/dist/dev/runtime/register/component/props.mjs.map +1 -0
- package/dist/dev/runtime/register/component/registerDefinition.mjs +290 -0
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -0
- package/dist/dev/runtime/register/component.mjs +128 -0
- package/dist/dev/runtime/register/component.mjs.map +1 -0
- package/dist/dev/runtime/register/inline.mjs +145 -0
- package/dist/dev/runtime/register/inline.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +53 -0
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +34 -0
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +230 -0
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +164 -0
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs +122 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs +438 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -0
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +95 -0
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -0
- package/dist/dev/runtime/register/setup.mjs +22 -0
- package/dist/dev/runtime/register/setup.mjs.map +1 -0
- package/dist/dev/runtime/register/snapshot.mjs +17 -0
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -0
- package/dist/dev/runtime/register/watch.mjs +57 -0
- package/dist/dev/runtime/register/watch.mjs.map +1 -0
- package/dist/dev/runtime/scopedSlots.mjs +115 -0
- package/dist/dev/runtime/scopedSlots.mjs.map +1 -0
- package/dist/dev/runtime/selectorQuery.mjs +49 -0
- package/dist/dev/runtime/selectorQuery.mjs.map +1 -0
- package/dist/dev/runtime/setupTracking.mjs +59 -0
- package/dist/dev/runtime/setupTracking.mjs.map +1 -0
- package/dist/dev/{template-n_iVr0ey.mjs → runtime/template.mjs} +7 -4
- package/dist/dev/runtime/template.mjs.map +1 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs +254 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -0
- package/dist/dev/runtime/templateRefs.mjs +162 -0
- package/dist/dev/runtime/templateRefs.mjs.map +1 -0
- package/dist/dev/runtime/uniAppHost.mjs +119 -0
- package/dist/dev/runtime/uniAppHost.mjs.map +1 -0
- package/dist/dev/runtime/updatePerformance.mjs +41 -0
- package/dist/dev/runtime/updatePerformance.mjs.map +1 -0
- package/dist/dev/runtime/use.mjs +25 -0
- package/dist/dev/runtime/use.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/context.mjs +25 -0
- package/dist/dev/runtime/vueCompat/context.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/model.mjs +118 -0
- package/dist/dev/runtime/vueCompat/model.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/router.mjs +124 -0
- package/dist/dev/runtime/vueCompat/router.mjs.map +1 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs +37 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -0
- package/dist/dev/scheduler.mjs +75 -0
- package/dist/dev/scheduler.mjs.map +1 -0
- package/dist/dev/store/actions.mjs +40 -0
- package/dist/dev/store/actions.mjs.map +1 -0
- package/dist/dev/store/base.mjs +56 -0
- package/dist/dev/store/base.mjs.map +1 -0
- package/dist/dev/store/define/optionsStyle.mjs +125 -0
- package/dist/dev/store/define/optionsStyle.mjs.map +1 -0
- package/dist/dev/store/define/setupStyle.mjs +145 -0
- package/dist/dev/store/define/setupStyle.mjs.map +1 -0
- package/dist/dev/store/define/shared.mjs +38 -0
- package/dist/dev/store/define/shared.mjs.map +1 -0
- package/dist/dev/store/define.mjs +23 -0
- package/dist/dev/store/define.mjs.map +1 -0
- package/dist/dev/store/manager.mjs +21 -0
- package/dist/dev/store/manager.mjs.map +1 -0
- package/dist/dev/store/storeToRefs.mjs +29 -0
- package/dist/dev/store/storeToRefs.mjs.map +1 -0
- package/dist/dev/store/utils.mjs +49 -0
- package/dist/dev/store/utils.mjs.map +1 -0
- package/dist/dev/store.mjs +3 -1
- package/dist/dev/utils.mjs +16 -0
- package/dist/dev/utils.mjs.map +1 -0
- package/dist/dev/version.mjs +8 -0
- package/dist/dev/version.mjs.map +1 -0
- package/dist/dev/vue-demi.mjs +49 -11
- package/dist/dev/vue-demi.mjs.map +1 -1
- package/dist/index.d.mts +71 -7
- package/dist/index.mjs +1 -1
- package/dist/internal-reactivity.d.mts +16 -2
- package/dist/internal-reactivity.mjs +1 -1
- package/dist/internal-runtime.d.mts +35 -2
- package/dist/internal-runtime.mjs +1 -1
- package/dist/internal-template.d.mts +1 -1
- package/dist/internal-template.mjs +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/macros/shared.d.mts +81 -0
- package/dist/macros.d.mts +70 -0
- package/dist/package.mjs +1 -0
- package/dist/reactivity/computed.d.mts +21 -0
- package/dist/reactivity/computed.mjs +1 -0
- package/dist/reactivity/core.d.mts +34 -0
- package/dist/reactivity/core.mjs +1 -0
- package/dist/reactivity/index.d.mts +15 -0
- package/dist/reactivity/reactive/mutation.d.mts +21 -0
- package/dist/reactivity/reactive/mutation.mjs +1 -0
- package/dist/reactivity/reactive/patch.d.mts +18 -0
- package/dist/reactivity/reactive/patch.mjs +1 -0
- package/dist/reactivity/reactive/patchState.mjs +1 -0
- package/dist/reactivity/reactive/shallow.d.mts +22 -0
- package/dist/reactivity/reactive/shallow.mjs +1 -0
- package/dist/reactivity/reactive/shared.d.mts +4 -0
- package/dist/reactivity/reactive/shared.mjs +1 -0
- package/dist/reactivity/reactive/state.mjs +1 -0
- package/dist/reactivity/reactive.d.mts +41 -0
- package/dist/reactivity/reactive.mjs +1 -0
- package/dist/reactivity/readonly.d.mts +27 -0
- package/dist/reactivity/readonly.mjs +1 -0
- package/dist/reactivity/ref.d.mts +27 -0
- package/dist/reactivity/ref.mjs +1 -0
- package/dist/reactivity/shallowRef.d.mts +19 -0
- package/dist/reactivity/shallowRef.mjs +1 -0
- package/dist/reactivity/toRefs.d.mts +43 -0
- package/dist/reactivity/toRefs.mjs +1 -0
- package/dist/reactivity/traverse.d.mts +8 -0
- package/dist/reactivity/traverse.mjs +1 -0
- package/dist/reactivity/watch/helpers.mjs +1 -0
- package/dist/reactivity/watch/types.d.mts +43 -0
- package/dist/reactivity/watch/types.mjs +1 -0
- package/dist/reactivity/watch.d.mts +21 -0
- package/dist/reactivity/watch.mjs +1 -0
- package/dist/router/backNavigation.mjs +1 -0
- package/dist/router/createRouter.d.mts +8 -0
- package/dist/router/createRouter.mjs +1 -0
- package/dist/router/instance.mjs +1 -0
- package/dist/router/navigationApi.mjs +1 -0
- package/dist/router/navigationCore.d.mts +6 -0
- package/dist/router/navigationCore.mjs +1 -0
- package/dist/router/navigationResult.mjs +1 -0
- package/dist/router/navigationTarget.mjs +1 -0
- package/dist/router/navigationTargetHelpers.mjs +1 -0
- package/dist/router/resolve.d.mts +6 -0
- package/dist/router/resolve.mjs +1 -0
- package/dist/router/routeRegistry.mjs +1 -0
- package/dist/router/routeSync.d.mts +1 -0
- package/dist/router/routeSync.mjs +1 -0
- package/dist/router/types.d.mts +163 -0
- package/dist/router/types.mjs +1 -0
- package/dist/router/useRoute.d.mts +19 -0
- package/dist/router/useRoute.mjs +1 -0
- package/dist/router/useRouter.d.mts +8 -0
- package/dist/router/useRouter.mjs +1 -0
- package/dist/router.d.mts +9 -204
- package/dist/router.mjs +1 -1
- package/dist/routerInternal/location.mjs +1 -0
- package/dist/routerInternal/matching.mjs +1 -0
- package/dist/routerInternal/params.mjs +1 -0
- package/dist/routerInternal/path.mjs +1 -0
- package/dist/routerInternal/query.d.mts +7 -0
- package/dist/routerInternal/query.mjs +1 -0
- package/dist/routerInternal/records.mjs +1 -0
- package/dist/routerInternal/recordsWarnings.mjs +1 -0
- package/dist/routerInternal/snapshots.mjs +1 -0
- package/dist/routerInternal/types.d.mts +9 -0
- package/dist/runtime/app/computed.mjs +1 -0
- package/dist/runtime/app/context.mjs +1 -0
- package/dist/runtime/app/diagnostics.mjs +1 -0
- package/dist/runtime/app/mount.mjs +1 -0
- package/dist/runtime/app/pending.d.mts +10 -0
- package/dist/runtime/app/pending.mjs +1 -0
- package/dist/runtime/app/setData/patchScheduler.mjs +1 -0
- package/dist/runtime/app/setData/payload.mjs +1 -0
- package/dist/runtime/app/setData/scheduler.mjs +1 -0
- package/dist/runtime/app/setData/snapshot.mjs +1 -0
- package/dist/runtime/app/setDataOptions.mjs +1 -0
- package/dist/runtime/app.d.mts +8 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/bindModel.mjs +1 -0
- package/dist/runtime/defaults.d.mts +11 -0
- package/dist/runtime/defaults.mjs +1 -0
- package/dist/runtime/define/initialComputed.mjs +1 -0
- package/dist/runtime/define/options.mjs +1 -0
- package/dist/runtime/define/optionsApi.mjs +1 -0
- package/dist/runtime/define/props.mjs +1 -0
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -0
- package/dist/runtime/define/setupResult.mjs +1 -0
- package/dist/runtime/define.d.mts +105 -0
- package/dist/runtime/define.mjs +1 -0
- package/dist/runtime/diff.mjs +1 -0
- package/dist/runtime/disposables.d.mts +31 -0
- package/dist/runtime/disposables.mjs +1 -0
- package/dist/runtime/elementIntersectionObserver.d.mts +26 -0
- package/dist/runtime/elementIntersectionObserver.mjs +1 -0
- package/dist/runtime/emit.mjs +1 -0
- package/dist/runtime/hooks/base.d.mts +27 -0
- package/dist/runtime/hooks/base.mjs +1 -0
- package/dist/runtime/hooks/register.d.mts +30 -0
- package/dist/runtime/hooks/register.mjs +1 -0
- package/dist/runtime/hooks/vue.d.mts +53 -0
- package/dist/runtime/hooks/vue.mjs +1 -0
- package/dist/runtime/hooks.d.mts +4 -0
- package/dist/runtime/index.d.mts +47 -0
- package/dist/runtime/internal.mjs +1 -0
- package/dist/runtime/intersectionObserver.d.mts +14 -0
- package/dist/runtime/intersectionObserver.mjs +1 -0
- package/dist/runtime/layoutBridge.d.mts +59 -0
- package/dist/runtime/layoutBridge.mjs +1 -0
- package/dist/runtime/layoutComponentMatcher.mjs +1 -0
- package/dist/runtime/nativeBridge.mjs +1 -0
- package/dist/runtime/noSetData.d.mts +5 -0
- package/dist/runtime/noSetData.mjs +1 -0
- package/dist/runtime/pageEnvironment.d.mts +50 -0
- package/dist/runtime/pageEnvironment.mjs +1 -0
- package/dist/runtime/pageLayout.d.mts +26 -0
- package/dist/runtime/pageLayout.mjs +1 -0
- package/dist/runtime/pageScroll.d.mts +29 -0
- package/dist/runtime/pageScroll.mjs +1 -0
- package/dist/runtime/platform.mjs +1 -0
- package/dist/runtime/provide.d.mts +59 -0
- package/dist/runtime/provide.mjs +1 -0
- package/dist/runtime/provideContext.mjs +1 -0
- package/dist/runtime/provideStore.d.mts +7 -0
- package/dist/runtime/provideStore.mjs +1 -0
- package/dist/runtime/pullDownRefresh.d.mts +12 -0
- package/dist/runtime/pullDownRefresh.mjs +1 -0
- package/dist/runtime/register/app.d.mts +14 -0
- package/dist/runtime/register/app.mjs +1 -0
- package/dist/runtime/register/component/features.mjs +1 -0
- package/dist/runtime/register/component/lifecycle/optionalHooks.mjs +1 -0
- package/dist/runtime/register/component/lifecycle/platform.mjs +1 -0
- package/dist/runtime/register/component/lifecycle.mjs +1 -0
- package/dist/runtime/register/component/methods.mjs +1 -0
- package/dist/runtime/register/component/options.mjs +1 -0
- package/dist/runtime/register/component/props.mjs +1 -0
- package/dist/runtime/register/component/registerDefinition.mjs +1 -0
- package/dist/runtime/register/component.d.mts +15 -0
- package/dist/runtime/register/component.mjs +1 -0
- package/dist/runtime/register/inline.d.mts +15 -0
- package/dist/runtime/register/inline.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/methodBridge.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/provideContext.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -0
- package/dist/runtime/register/runtimeInstance/utils.mjs +1 -0
- package/dist/runtime/register/runtimeInstance.d.mts +26 -0
- package/dist/runtime/register/runtimeInstance.mjs +1 -0
- package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -0
- package/dist/runtime/register/setup.d.mts +11 -0
- package/dist/runtime/register/setup.mjs +1 -0
- package/dist/runtime/register/snapshot.mjs +1 -0
- package/dist/runtime/register/watch.d.mts +12 -0
- package/dist/runtime/register/watch.mjs +1 -0
- package/dist/runtime/register.d.mts +5 -0
- package/dist/runtime/scopedSlots.mjs +1 -0
- package/dist/runtime/selectorQuery.d.mts +54 -0
- package/dist/runtime/selectorQuery.mjs +1 -0
- package/dist/runtime/setupTracking.mjs +1 -0
- package/dist/{template-DE8e5dj_.d.mts → runtime/template.d.mts} +1 -1
- package/dist/runtime/template.mjs +1 -0
- package/dist/runtime/templateRefTypes.d.mts +7 -0
- package/dist/runtime/templateRefs/helpers.mjs +1 -0
- package/dist/runtime/templateRefs.d.mts +11 -0
- package/dist/runtime/templateRefs.mjs +1 -0
- package/dist/runtime/types/core.d.mts +35 -0
- package/dist/runtime/types/miniprogram.d.mts +80 -0
- package/dist/runtime/types/miniprogramHost.d.mts +44 -0
- package/dist/runtime/types/miniprogramHostSources.d.mts +112 -0
- package/dist/runtime/types/options.d.mts +136 -0
- package/dist/runtime/types/props/propTypes.d.mts +79 -0
- package/dist/runtime/types/props/router.d.mts +51 -0
- package/dist/runtime/types/props/setup.d.mts +96 -0
- package/dist/runtime/types/props.d.mts +4 -0
- package/dist/runtime/types/runtime.d.mts +59 -0
- package/dist/runtime/types/setData.d.mts +220 -0
- package/dist/runtime/types.d.mts +28 -0
- package/dist/runtime/uniAppHost.d.mts +8 -0
- package/dist/runtime/uniAppHost.mjs +1 -0
- package/dist/runtime/updatePerformance.d.mts +13 -0
- package/dist/runtime/updatePerformance.mjs +1 -0
- package/dist/runtime/use.d.mts +13 -0
- package/dist/runtime/use.mjs +1 -0
- package/dist/runtime/vueCompat/context.d.mts +8 -0
- package/dist/runtime/vueCompat/context.mjs +1 -0
- package/dist/runtime/vueCompat/model.d.mts +30 -0
- package/dist/runtime/vueCompat/model.mjs +1 -0
- package/dist/runtime/vueCompat/router.d.mts +28 -0
- package/dist/runtime/vueCompat/router.mjs +1 -0
- package/dist/runtime/vueCompat/templateRef.d.mts +9 -0
- package/dist/runtime/vueCompat/templateRef.mjs +1 -0
- package/dist/runtime/vueCompat.d.mts +5 -0
- package/dist/scheduler.d.mts +4 -0
- package/dist/scheduler.mjs +1 -0
- package/dist/store/actions.mjs +1 -0
- package/dist/store/base.mjs +1 -0
- package/dist/store/define/optionsStyle.mjs +1 -0
- package/dist/store/define/setupStyle.mjs +1 -0
- package/dist/store/define/shared.mjs +1 -0
- package/dist/store/define.d.mts +26 -0
- package/dist/store/define.mjs +1 -0
- package/dist/store/manager.d.mts +8 -0
- package/dist/store/manager.mjs +1 -0
- package/dist/store/storeToRefs.d.mts +13 -0
- package/dist/store/storeToRefs.mjs +1 -0
- package/dist/store/types.d.mts +70 -0
- package/dist/store/utils.mjs +1 -0
- package/dist/store.d.mts +4 -1
- package/dist/store.mjs +1 -1
- package/dist/utils.mjs +1 -0
- package/dist/version.d.mts +4 -0
- package/dist/version.mjs +1 -0
- package/dist/vue-augment.d.mts +6 -0
- package/dist/vue-demi.d.mts +67 -7
- package/dist/vue-demi.mjs +1 -1
- package/dist/vue-types.d.mts +18 -0
- package/dist/weappIntrinsicElements/base.d.mts +22 -0
- package/dist/weappIntrinsicElements/elements/ad-custom.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/ad.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/audio.d.mts +20 -0
- package/dist/weappIntrinsicElements/elements/block.d.mts +8 -0
- package/dist/weappIntrinsicElements/elements/button.d.mts +40 -0
- package/dist/weappIntrinsicElements/elements/camera.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/canvas.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/checkbox-group.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/checkbox.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/cover-image.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/cover-view.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/editor.d.mts +22 -0
- package/dist/weappIntrinsicElements/elements/form.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/functional-page-navigator.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/icon.d.mts +12 -0
- package/dist/weappIntrinsicElements/elements/image.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/import.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/include.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/input.d.mts +47 -0
- package/dist/weappIntrinsicElements/elements/keyboard-accessory.d.mts +8 -0
- package/dist/weappIntrinsicElements/elements/label.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/live-player.d.mts +35 -0
- package/dist/weappIntrinsicElements/elements/live-pusher.d.mts +57 -0
- package/dist/weappIntrinsicElements/elements/map.d.mts +105 -0
- package/dist/weappIntrinsicElements/elements/match-media.d.mts +16 -0
- package/dist/weappIntrinsicElements/elements/movable-area.d.mts +26 -0
- package/dist/weappIntrinsicElements/elements/movable-view.d.mts +26 -0
- package/dist/weappIntrinsicElements/elements/navigation-bar.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/navigator.d.mts +25 -0
- package/dist/weappIntrinsicElements/elements/official-account.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/open-data.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/page-container.d.mts +25 -0
- package/dist/weappIntrinsicElements/elements/page-meta.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/picker-view-column.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/picker-view.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/picker.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/progress.d.mts +21 -0
- package/dist/weappIntrinsicElements/elements/radio-group.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/radio.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/rich-text.d.mts +17 -0
- package/dist/weappIntrinsicElements/elements/scroll-view.d.mts +68 -0
- package/dist/weappIntrinsicElements/elements/share-element.d.mts +18 -0
- package/dist/weappIntrinsicElements/elements/slider.d.mts +23 -0
- package/dist/weappIntrinsicElements/elements/slot.d.mts +10 -0
- package/dist/weappIntrinsicElements/elements/swiper-item.d.mts +42 -0
- package/dist/weappIntrinsicElements/elements/swiper.d.mts +42 -0
- package/dist/weappIntrinsicElements/elements/switch.d.mts +14 -0
- package/dist/weappIntrinsicElements/elements/template.d.mts +12 -0
- package/dist/weappIntrinsicElements/elements/text.d.mts +15 -0
- package/dist/weappIntrinsicElements/elements/textarea.d.mts +40 -0
- package/dist/weappIntrinsicElements/elements/video.d.mts +71 -0
- package/dist/weappIntrinsicElements/elements/view.d.mts +13 -0
- package/dist/weappIntrinsicElements/elements/voip-room.d.mts +14 -0
- package/dist/weappIntrinsicElements/elements/web-view.d.mts +13 -0
- package/dist/weappIntrinsicElements.d.mts +153 -0
- package/package.json +6 -6
- package/dist/base-BxKbbKVO.mjs +0 -1
- package/dist/computed-Xoi9XEUx.mjs +0 -1
- package/dist/dev/base-CYkvI7w8.mjs.map +0 -1
- package/dist/dev/computed-BxRsUJgi.mjs.map +0 -1
- package/dist/dev/ref-DRZC3Kc5.mjs +0 -695
- package/dist/dev/ref-DRZC3Kc5.mjs.map +0 -1
- package/dist/dev/router-D0JQfgyN.mjs +0 -754
- package/dist/dev/router-D0JQfgyN.mjs.map +0 -1
- package/dist/dev/router.mjs.map +0 -1
- package/dist/dev/store-HNsiQJ4d.mjs +0 -479
- package/dist/dev/store-HNsiQJ4d.mjs.map +0 -1
- package/dist/dev/template-n_iVr0ey.mjs.map +0 -1
- package/dist/dev/templateRef-BLnYcEH0.mjs +0 -6439
- package/dist/dev/templateRef-BLnYcEH0.mjs.map +0 -1
- package/dist/dev/toRefs-D06VmFK2.mjs.map +0 -1
- package/dist/dev/watch-jrgL5ald.mjs +0 -445
- package/dist/dev/watch-jrgL5ald.mjs.map +0 -1
- package/dist/index-BiHILcmb.d.mts +0 -1215
- package/dist/index-CCET_bCY.d.mts +0 -111
- package/dist/ref-D37CknuD.mjs +0 -1
- package/dist/router-D4W4lEXM.mjs +0 -1
- package/dist/store-eHrHBQiv.mjs +0 -1
- package/dist/template-CNzlwH-E.mjs +0 -1
- package/dist/templateRef-DOTHWzZ5.mjs +0 -1
- package/dist/toRefs-CoytPyo0.mjs +0 -1
- package/dist/traverse-B4Ez44Gd.d.mts +0 -108
- package/dist/vue-types-B3N60cGV.d.mts +0 -757
- package/dist/watch-Bbd-gmEg.mjs +0 -1
- package/dist/weappIntrinsicElements-BgDtC53_.d.mts +0 -1257
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline.mjs","names":[],"sources":["../../../../src/runtime/register/inline.ts"],"sourcesContent":["import { isReactive, isRef, reactive } from '../../reactivity'\n\nexport interface InlineExpressionEntry {\n keys: string[]\n indexKeys?: string[]\n scopeResolvers?: Array<InlineExpressionScopeResolver | ((ctx: any, scope: Record<string, any>, event: any) => any) | undefined>\n fn: (ctx: any, scope: Record<string, any>, event: any) => any\n}\n\ninterface InlineExpressionScopeResolver {\n type: 'for-item'\n path: string\n indexKey: string\n}\n\nexport type InlineExpressionMap = Record<string, InlineExpressionEntry>\n\nconst AMP_RE = /&/g\nconst QUOT_RE = /"/g\nconst NUM_QUOT_RE = /"/g\nconst APOS_RE = /'/g\nconst NUM_APOS_RE = /'/g\nconst LT_RE = /</g\nconst GT_RE = />/g\n\nexport function decodeWxmlEntities(value: string) {\n return value\n .replace(AMP_RE, '&')\n .replace(QUOT_RE, '\"')\n .replace(NUM_QUOT_RE, '\"')\n .replace(APOS_RE, '\\'')\n .replace(NUM_APOS_RE, '\\'')\n .replace(LT_RE, '<')\n .replace(GT_RE, '>')\n}\n\nfunction normalizeDatasetIndex(value: unknown): number | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value\n }\n if (typeof value === 'string' && value.trim()) {\n const parsed = Number(value)\n if (Number.isFinite(parsed)) {\n return parsed\n }\n }\n return undefined\n}\n\nconst NON_ALNUM_RE = /[^a-z0-9]+/gi\nconst LEADING_TRAILING_DASH_RE = /^-+|-+$/g\n\nfunction normalizeEventToken(value: string): string {\n return value\n .trim()\n .replace(NON_ALNUM_RE, '-')\n .replace(LEADING_TRAILING_DASH_RE, '')\n .toLowerCase()\n}\n\nconst DASH_ALNUM_RE = /-([a-z0-9])/g\n\nfunction resolveEventDatasetKey(baseKey: string, event: any): string | undefined {\n const eventType = typeof event?.type === 'string' ? event.type : ''\n const token = normalizeEventToken(eventType)\n if (!token) {\n return undefined\n }\n const camelToken = token.replace(DASH_ALNUM_RE, (_, ch: string) => ch.toUpperCase())\n if (!camelToken) {\n return undefined\n }\n return `${baseKey}${camelToken[0].toUpperCase()}${camelToken.slice(1)}`\n}\n\nconst DATASET_KEY_ALIASES: Record<string, string[]> = {\n wvEventDetail: ['wd', 'wvEventDetail'],\n wvHandler: ['wh', 'wvHandler'],\n wvInlineId: ['wi', 'wvInlineId'],\n}\n\nfunction resolveDatasetValueByBaseKey(\n dataset: Record<string, any>,\n baseKey: string,\n event: any,\n) {\n const aliasKeys = DATASET_KEY_ALIASES[baseKey] ?? [baseKey]\n for (const aliasKey of aliasKeys) {\n const specificKey = resolveEventDatasetKey(aliasKey, event)\n if (specificKey && dataset?.[specificKey] !== undefined) {\n return dataset[specificKey]\n }\n }\n for (const aliasKey of aliasKeys) {\n if (dataset?.[aliasKey] !== undefined) {\n return dataset[aliasKey]\n }\n }\n return undefined\n}\n\nexport function resolveDatasetEventValue(\n dataset: Record<string, any>,\n baseKey: string,\n event: any,\n): any {\n return resolveDatasetValueByBaseKey(dataset, baseKey, event)\n}\n\nfunction shouldUseDetailPayload(dataset: Record<string, any>, event: any): boolean {\n const flag = resolveDatasetEventValue(dataset, 'wvEventDetail', event)\n return flag === true || flag === 1 || flag === '1' || flag === 'true'\n}\n\nfunction resolveInlineEventArg(event: any, dataset: Record<string, any>): any {\n if (!shouldUseDetailPayload(dataset, event)) {\n return event\n }\n if (!event || typeof event !== 'object' || !('detail' in event)) {\n return undefined\n }\n return (event as any).detail\n}\n\nfunction getByPath(target: any, path: string) {\n if (!path) {\n return undefined\n }\n const segments = path.split('.').filter(Boolean)\n let current = isRef(target) ? target.value : target\n for (const segment of segments) {\n if (isRef(current)) {\n current = current.value\n }\n if (current == null) {\n return undefined\n }\n current = current[segment]\n }\n if (isRef(current)) {\n return current.value\n }\n return current\n}\n\nfunction normalizeResolvedScopeValue(value: any) {\n if (value == null || typeof value !== 'object') {\n return value\n }\n if (isRef(value) || isReactive(value)) {\n return value\n }\n try {\n return reactive(value)\n }\n catch {\n return value\n }\n}\n\nexport function runInlineExpression(\n ctx: any,\n expr: unknown,\n event: any,\n inlineMap?: InlineExpressionMap,\n) {\n const dataset = (event?.currentTarget as any)?.dataset ?? (event?.target as any)?.dataset ?? {}\n const inlineEvent = resolveInlineEventArg(event, dataset)\n const inlineId = resolveDatasetEventValue(dataset, 'wvInlineId', event)\n if (inlineId && inlineMap) {\n const entry = inlineMap[inlineId]\n if (entry && typeof entry.fn === 'function') {\n const scope: Record<string, any> = {}\n const keys = Array.isArray(entry.keys) ? entry.keys : []\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i]\n scope[key] = dataset?.[`wvS${i}`]\n }\n const indexKeys = Array.isArray(entry.indexKeys) ? entry.indexKeys : []\n for (let i = 0; i < indexKeys.length; i += 1) {\n const indexKey = indexKeys[i]\n const indexValue = normalizeDatasetIndex(dataset?.[`wvI${i}`])\n if (indexValue !== undefined) {\n scope[indexKey] = indexValue\n }\n }\n const scopeResolvers = Array.isArray(entry.scopeResolvers) ? entry.scopeResolvers : []\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i]\n const resolver = scopeResolvers[i]\n try {\n let resolved: any\n if (typeof resolver === 'function') {\n resolved = resolver(ctx, scope, inlineEvent)\n }\n else if (resolver && typeof resolver === 'object' && resolver.type === 'for-item') {\n const index = scope[resolver.indexKey]\n const list = getByPath(ctx, resolver.path)\n resolved = list?.[index]\n }\n else {\n continue\n }\n if (resolved !== undefined) {\n scope[key] = normalizeResolvedScopeValue(resolved)\n }\n }\n catch {\n // 解析失败时保持 dataset 快照回退。\n }\n }\n const result = entry.fn(ctx, scope, inlineEvent)\n if (typeof result === 'function') {\n return result.call(ctx, inlineEvent)\n }\n return result\n }\n }\n\n const datasetHandler = resolveDatasetEventValue(dataset, 'wvHandler', event)\n const handlerName = typeof expr === 'string' && expr\n ? expr\n : (typeof datasetHandler === 'string' ? datasetHandler : undefined)\n if (!handlerName) {\n return undefined\n }\n const argsRaw = resolveDatasetEventValue(dataset, 'wvArgs', event)\n let args: any[] = []\n if (Array.isArray(argsRaw)) {\n args = argsRaw\n }\n else if (typeof argsRaw === 'string') {\n try {\n args = JSON.parse(argsRaw)\n }\n catch {\n try {\n args = JSON.parse(decodeWxmlEntities(argsRaw))\n }\n catch {\n args = []\n }\n }\n }\n if (!Array.isArray(args)) {\n args = []\n }\n const resolvedArgs = args.map((item: any) => item === '$event' ? inlineEvent : item)\n const handler = (ctx as any)?.[handlerName]\n if (typeof handler === 'function') {\n return handler.apply(ctx, resolvedArgs)\n }\n return undefined\n}\n"],"mappings":";;;;AAiBA,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,cAAc;AACpB,MAAM,UAAU;AAChB,MAAM,cAAc;AACpB,MAAM,QAAQ;AACd,MAAM,QAAQ;AAEd,SAAgB,mBAAmB,OAAe;CAChD,OAAO,MACJ,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,SAAS,IAAG,CAAC,CACrB,QAAQ,aAAa,IAAG,CAAC,CACzB,QAAQ,SAAS,GAAI,CAAC,CACtB,QAAQ,aAAa,GAAI,CAAC,CAC1B,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,OAAO,GAAG;AACvB;AAEA,SAAS,sBAAsB,OAAoC;CACjE,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GACpD,OAAO;CAET,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,GAAG;EAC7C,MAAM,SAAS,OAAO,KAAK;EAC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V;CACF;CAEF,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO,CAAC;CAEV,MAAM,eAAe,KAAK,KAAK,SAAc,SAAS,WAAW,cAAc,IAAI;CACnF,MAAM,oDAAW,IAAc;CAC/B,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ,MAAM,KAAK,YAAY;AAG1C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isNativeBridgeMethod } from "../../nativeBridge.mjs";
|
|
2
|
+
import { setupInstanceMethodNames } from "./setupContext.mjs";
|
|
3
|
+
import { WEVU_NATIVE_INSTANCE_KEY, WEVU_PUBLIC_RUNTIME_KEY } from "@weapp-core/constants";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/register/runtimeInstance/methodBridge.ts
|
|
6
|
+
function hasNativeApis(instance) {
|
|
7
|
+
if (!instance || typeof instance !== "object") return false;
|
|
8
|
+
return typeof instance.triggerEvent === "function" || typeof instance.createSelectorQuery === "function" || typeof instance.createIntersectionObserver === "function" || typeof instance.setData === "function";
|
|
9
|
+
}
|
|
10
|
+
function isBridgeMethod(runtime, instance, methodName) {
|
|
11
|
+
const instanceMethod = instance === null || instance === void 0 ? void 0 : instance[methodName];
|
|
12
|
+
if (typeof instanceMethod !== "function") return false;
|
|
13
|
+
if (isNativeBridgeMethod(instanceMethod)) return true;
|
|
14
|
+
const runtimeProxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy;
|
|
15
|
+
return typeof (runtimeProxy === null || runtimeProxy === void 0 ? void 0 : runtimeProxy[methodName]) === "function" && instanceMethod === runtimeProxy[methodName];
|
|
16
|
+
}
|
|
17
|
+
function syncRuntimeNativeInstance(runtime, instance) {
|
|
18
|
+
if (!runtime || !hasNativeApis(instance)) return;
|
|
19
|
+
if (instance === runtime.proxy) return;
|
|
20
|
+
const nativeCandidate = instance;
|
|
21
|
+
if (isBridgeMethod(runtime, nativeCandidate, "triggerEvent") || isBridgeMethod(runtime, nativeCandidate, "createSelectorQuery") || isBridgeMethod(runtime, nativeCandidate, "createIntersectionObserver") || isBridgeMethod(runtime, nativeCandidate, "setData")) return;
|
|
22
|
+
const runtimeState = runtime.state;
|
|
23
|
+
if (!runtimeState || typeof runtimeState !== "object") return;
|
|
24
|
+
try {
|
|
25
|
+
Object.defineProperty(runtimeState, WEVU_NATIVE_INSTANCE_KEY, {
|
|
26
|
+
value: nativeCandidate,
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} catch (_unused) {
|
|
32
|
+
runtimeState[WEVU_NATIVE_INSTANCE_KEY] = nativeCandidate;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function bridgeRuntimeMethodsToTarget(target, runtime) {
|
|
36
|
+
try {
|
|
37
|
+
const methods = runtime.methods;
|
|
38
|
+
for (const name of Object.keys(methods)) {
|
|
39
|
+
if (setupInstanceMethodNames.includes(name)) continue;
|
|
40
|
+
if (typeof target[name] !== "function") target[name] = function bridged(...args) {
|
|
41
|
+
var _this$WEVU_PUBLIC_RUN, _ref;
|
|
42
|
+
const runtime = (_this$WEVU_PUBLIC_RUN = this[WEVU_PUBLIC_RUNTIME_KEY]) !== null && _this$WEVU_PUBLIC_RUN !== void 0 ? _this$WEVU_PUBLIC_RUN : target[WEVU_PUBLIC_RUNTIME_KEY];
|
|
43
|
+
syncRuntimeNativeInstance(runtime, this);
|
|
44
|
+
const bound = runtime === null || runtime === void 0 || (_ref = runtime.methods) === null || _ref === void 0 ? void 0 : _ref[name];
|
|
45
|
+
if (typeof bound === "function") return bound.apply(runtime.proxy, args);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
} catch (_unused2) {}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { bridgeRuntimeMethodsToTarget };
|
|
53
|
+
//# sourceMappingURL=methodBridge.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methodBridge.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/methodBridge.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeInstance } from '../../types'\nimport type { SetupInstanceMethodName } from './setupContext'\nimport {\n WEVU_NATIVE_INSTANCE_KEY,\n WEVU_PUBLIC_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { isNativeBridgeMethod } from '../../nativeBridge'\nimport { setupInstanceMethodNames } from './setupContext'\n\nfunction hasNativeApis(instance: unknown) {\n if (!instance || typeof instance !== 'object') {\n return false\n }\n return typeof (instance as any).triggerEvent === 'function'\n || typeof (instance as any).createSelectorQuery === 'function'\n || typeof (instance as any).createIntersectionObserver === 'function'\n || typeof (instance as any).setData === 'function'\n}\n\nfunction isBridgeMethod(runtime: RuntimeInstance<any, any, any>, instance: any, methodName: 'triggerEvent' | 'createSelectorQuery' | 'createIntersectionObserver' | 'setData') {\n const instanceMethod = instance?.[methodName]\n if (typeof instanceMethod !== 'function') {\n return false\n }\n if (isNativeBridgeMethod(instanceMethod)) {\n return true\n }\n const runtimeProxy = runtime?.proxy as Record<string, any> | undefined\n return typeof runtimeProxy?.[methodName] === 'function' && instanceMethod === runtimeProxy[methodName]\n}\n\nfunction syncRuntimeNativeInstance(runtime: RuntimeInstance<any, any, any>, instance: unknown) {\n if (!runtime || !hasNativeApis(instance)) {\n return\n }\n if (instance === runtime.proxy) {\n return\n }\n const nativeCandidate = instance as Record<string, any>\n if (\n isBridgeMethod(runtime, nativeCandidate, 'triggerEvent')\n || isBridgeMethod(runtime, nativeCandidate, 'createSelectorQuery')\n || isBridgeMethod(runtime, nativeCandidate, 'createIntersectionObserver')\n || isBridgeMethod(runtime, nativeCandidate, 'setData')\n ) {\n return\n }\n const runtimeState = runtime.state\n if (!runtimeState || typeof runtimeState !== 'object') {\n return\n }\n try {\n Object.defineProperty(runtimeState, WEVU_NATIVE_INSTANCE_KEY, {\n value: nativeCandidate,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(runtimeState as any)[WEVU_NATIVE_INSTANCE_KEY] = nativeCandidate\n }\n}\n\nexport function bridgeRuntimeMethodsToTarget(\n target: InternalRuntimeState,\n runtime: RuntimeInstance<any, any, any>,\n) {\n try {\n const methods = (runtime.methods as unknown) as Record<string, any>\n for (const name of Object.keys(methods)) {\n if (setupInstanceMethodNames.includes(name as SetupInstanceMethodName)) {\n continue\n }\n if (typeof (target as any)[name] !== 'function') {\n ;(target as any)[name] = function bridged(this: any, ...args: any[]) {\n const runtime = this[WEVU_PUBLIC_RUNTIME_KEY] ?? target[WEVU_PUBLIC_RUNTIME_KEY]\n syncRuntimeNativeInstance(runtime, this)\n const bound = (runtime?.methods as any)?.[name]\n if (typeof bound === 'function') {\n return bound.apply(runtime.proxy, args)\n }\n }\n }\n }\n }\n catch {\n // 桥接过程中若发生错误(如目标被封装)则忽略,避免阻断后续流程\n }\n}\n"],"mappings":";;;;;AASA,SAAS,cAAc,UAAmB;CACxC,IAAI,CAAC,YAAY,OAAO,aAAa,UACnC,OAAO;CAET,OAAO,OAAQ,SAAiB,iBAAiB,cAC5C,OAAQ,SAAiB,wBAAwB,cACjD,OAAQ,SAAiB,+BAA+B,cACxD,OAAQ,SAAiB,YAAY;AAC5C;AAEA,SAAS,eAAe,SAAyC,UAAe,YAA+F;CAC7K,MAAM,qEAAiB,SAAW;CAClC,IAAI,OAAO,mBAAmB,YAC5B,OAAO;CAET,IAAI,qBAAqB,cAAc,GACrC,OAAO;CAET,MAAM,iEAAe,QAAS;CAC9B,OAAO,oEAAO,aAAe,iBAAgB,cAAc,mBAAmB,aAAa;AAC7F;AAEA,SAAS,0BAA0B,SAAyC,UAAmB;CAC7F,IAAI,CAAC,WAAW,CAAC,cAAc,QAAQ,GACrC;CAEF,IAAI,aAAa,QAAQ,OACvB;CAEF,MAAM,kBAAkB;CACxB,IACE,eAAe,SAAS,iBAAiB,cAAc,KACpD,eAAe,SAAS,iBAAiB,qBAAqB,KAC9D,eAAe,SAAS,iBAAiB,4BAA4B,KACrE,eAAe,SAAS,iBAAiB,SAAS,GAErD;CAEF,MAAM,eAAe,QAAQ;CAC7B,IAAI,CAAC,gBAAgB,OAAO,iBAAiB,UAC3C;CAEF,IAAI;EACF,OAAO,eAAe,cAAc,0BAA0B;GAC5D,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,kBACM;EACH,AAAC,aAAqB,4BAA4B;CACrD;AACF;AAEA,SAAgB,6BACd,QACA,SACA;CACA,IAAI;EACF,MAAM,UAAW,QAAQ;EACzB,KAAK,MAAM,QAAQ,OAAO,KAAK,OAAO,GAAG;GACvC,IAAI,yBAAyB,SAAS,IAA+B,GACnE;GAEF,IAAI,OAAQ,OAAe,UAAU,YAClC,AAAC,OAAe,QAAQ,SAAS,QAAmB,GAAG,MAAa;;IACnE,MAAM,mCAAU,KAAK,iGAA4B,OAAO;IACxD,0BAA0B,SAAS,IAAI;IACvC,MAAM,0DAAS,QAAS,qDAAkB;IAC1C,IAAI,OAAO,UAAU,YACnB,OAAO,MAAM,MAAM,QAAQ,OAAO,IAAI;GAE1C;EAEJ;CACF,mBACM,CAEN;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getCurrentMiniProgramPages } from "../../platform.mjs";
|
|
2
|
+
import { attachRuntimeLayoutProvideContext, attachRuntimeProvideContext } from "../../provideContext.mjs";
|
|
3
|
+
import { isRuntimeLayoutComponentTarget } from "../../layoutComponentMatcher.mjs";
|
|
4
|
+
import { WEVU_PARENT_INSTANCE_KEY, WEVU_RUNTIME_APP_KEY } from "@weapp-core/constants";
|
|
5
|
+
|
|
6
|
+
//#region src/runtime/register/runtimeInstance/provideContext.ts
|
|
7
|
+
function resolveRuntimeParentInstance(target) {
|
|
8
|
+
if (isRuntimeLayoutComponentTarget(target)) return;
|
|
9
|
+
const cached = target[WEVU_PARENT_INSTANCE_KEY];
|
|
10
|
+
if (cached && typeof cached === "object") return cached;
|
|
11
|
+
const selectOwnerComponent = target.selectOwnerComponent;
|
|
12
|
+
if (typeof selectOwnerComponent === "function") try {
|
|
13
|
+
const owner = selectOwnerComponent.call(target);
|
|
14
|
+
if (owner && owner !== target && typeof owner === "object" && owner.__wevu) return owner;
|
|
15
|
+
} catch (_unused) {}
|
|
16
|
+
const pages = getCurrentMiniProgramPages();
|
|
17
|
+
const currentPage = pages[pages.length - 1];
|
|
18
|
+
if (currentPage && currentPage !== target && typeof currentPage === "object" && currentPage.__wevu) return currentPage;
|
|
19
|
+
}
|
|
20
|
+
function attachRuntimeLayoutParentContext(target) {
|
|
21
|
+
if (!isRuntimeLayoutComponentTarget(target)) return;
|
|
22
|
+
const pages = getCurrentMiniProgramPages();
|
|
23
|
+
const currentPage = pages[pages.length - 1];
|
|
24
|
+
if (currentPage && currentPage !== target && typeof currentPage === "object" && currentPage.__wevu) attachRuntimeLayoutProvideContext(target, currentPage);
|
|
25
|
+
}
|
|
26
|
+
function attachRuntimeProvideParentContext(target, runtimeApp) {
|
|
27
|
+
target[WEVU_RUNTIME_APP_KEY] = runtimeApp;
|
|
28
|
+
attachRuntimeProvideContext(target, runtimeApp, resolveRuntimeParentInstance(target));
|
|
29
|
+
attachRuntimeLayoutParentContext(target);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { attachRuntimeProvideParentContext };
|
|
34
|
+
//# sourceMappingURL=provideContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideContext.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/provideContext.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeApp } from '../../types'\nimport {\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_RUNTIME_APP_KEY,\n} from '@weapp-core/constants'\nimport { isRuntimeLayoutComponentTarget } from '../../layoutComponentMatcher'\nimport { getCurrentMiniProgramPages } from '../../platform'\nimport { attachRuntimeLayoutProvideContext, attachRuntimeProvideContext } from '../../provideContext'\n\nfunction resolveRuntimeParentInstance(target: InternalRuntimeState): InternalRuntimeState | undefined {\n if (isRuntimeLayoutComponentTarget(target)) {\n return undefined\n }\n\n const cached = target[WEVU_PARENT_INSTANCE_KEY]\n if (cached && typeof cached === 'object') {\n return cached\n }\n\n const selectOwnerComponent = (target as any).selectOwnerComponent\n if (typeof selectOwnerComponent === 'function') {\n try {\n const owner = selectOwnerComponent.call(target) as InternalRuntimeState | undefined\n if (owner && owner !== target && typeof owner === 'object' && owner.__wevu) {\n return owner\n }\n }\n catch {\n // 部分宿主或生命周期阶段可能暂不支持 owner 查询,继续使用页面兜底。\n }\n }\n\n const pages = getCurrentMiniProgramPages()\n const currentPage = pages[pages.length - 1] as InternalRuntimeState | undefined\n if (\n currentPage\n && currentPage !== target\n && typeof currentPage === 'object'\n && currentPage.__wevu\n ) {\n return currentPage\n }\n\n return undefined\n}\n\nfunction attachRuntimeLayoutParentContext(target: InternalRuntimeState) {\n if (!isRuntimeLayoutComponentTarget(target)) {\n return\n }\n const pages = getCurrentMiniProgramPages()\n const currentPage = pages[pages.length - 1] as InternalRuntimeState | undefined\n if (\n currentPage\n && currentPage !== target\n && typeof currentPage === 'object'\n && currentPage.__wevu\n ) {\n attachRuntimeLayoutProvideContext(target, currentPage)\n }\n}\n\nexport function attachRuntimeProvideParentContext(\n target: InternalRuntimeState,\n runtimeApp: RuntimeApp<any, any, any>,\n) {\n target[WEVU_RUNTIME_APP_KEY] = runtimeApp\n attachRuntimeProvideContext(target, runtimeApp, resolveRuntimeParentInstance(target))\n attachRuntimeLayoutParentContext(target)\n}\n"],"mappings":";;;;;;AASA,SAAS,6BAA6B,QAAgE;CACpG,IAAI,+BAA+B,MAAM,GACvC;CAGF,MAAM,SAAS,OAAO;CACtB,IAAI,UAAU,OAAO,WAAW,UAC9B,OAAO;CAGT,MAAM,uBAAwB,OAAe;CAC7C,IAAI,OAAO,yBAAyB,YAClC,IAAI;EACF,MAAM,QAAQ,qBAAqB,KAAK,MAAM;EAC9C,IAAI,SAAS,UAAU,UAAU,OAAO,UAAU,YAAY,MAAM,QAClE,OAAO;CAEX,kBACM,CAEN;CAGF,MAAM,QAAQ,2BAA2B;CACzC,MAAM,cAAc,MAAM,MAAM,SAAS;CACzC,IACE,eACG,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,YAAY,QAEf,OAAO;AAIX;AAEA,SAAS,iCAAiC,QAA8B;CACtE,IAAI,CAAC,+BAA+B,MAAM,GACxC;CAEF,MAAM,QAAQ,2BAA2B;CACzC,MAAM,cAAc,MAAM,MAAM,SAAS;CACzC,IACE,eACG,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,YAAY,QAEf,kCAAkC,QAAQ,WAAW;AAEzD;AAEA,SAAgB,kCACd,QACA,YACA;CACA,OAAO,wBAAwB;CAC/B,4BAA4B,QAAQ,YAAY,6BAA6B,MAAM,CAAC;CACpF,iCAAiC,MAAM;AACzC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { toRaw } from "../../../reactivity/reactive/shared.mjs";
|
|
2
|
+
import { getCurrentMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, supportsCurrentMiniProgramRuntimeCapability } from "../../platform.mjs";
|
|
3
|
+
import { hasOwn } from "../../../utils.mjs";
|
|
4
|
+
import { normalizeEmitPayload } from "../../emit.mjs";
|
|
5
|
+
import { isNativeBridgeMethod, markNativeBridgeMethod } from "../../nativeBridge.mjs";
|
|
6
|
+
import { markNoSetData } from "../../noSetData.mjs";
|
|
7
|
+
import { WEVU_NATIVE_INSTANCE_KEY, WEVU_PROPS_KEY, WEVU_SETUP_CONTEXT_INSTANCE_KEY, WEVU_SLOT_NAMES_PROP } from "@weapp-core/constants";
|
|
8
|
+
|
|
9
|
+
//#region src/runtime/register/runtimeInstance/setupContext.ts
|
|
10
|
+
const setupInstanceMethodNames = [
|
|
11
|
+
"triggerEvent",
|
|
12
|
+
"createSelectorQuery",
|
|
13
|
+
"createIntersectionObserver",
|
|
14
|
+
"setData",
|
|
15
|
+
"setUpdatePerformanceListener"
|
|
16
|
+
];
|
|
17
|
+
function createSetupSlotsFallback() {
|
|
18
|
+
return Object.freeze(Object.create(null));
|
|
19
|
+
}
|
|
20
|
+
const SLOT_RENDER_FN = () => [];
|
|
21
|
+
function normalizeSlotNames(value) {
|
|
22
|
+
if (Array.isArray(value)) return [...new Set(value.filter((item) => typeof item === "string" && item.length > 0))];
|
|
23
|
+
if (!value || typeof value !== "object") return [];
|
|
24
|
+
return Object.entries(value).filter(([, enabled]) => Boolean(enabled)).map(([name]) => name);
|
|
25
|
+
}
|
|
26
|
+
function createSetupSlotsProxy(props) {
|
|
27
|
+
if (!hasOwn(props, WEVU_SLOT_NAMES_PROP)) return createSetupSlotsFallback();
|
|
28
|
+
const resolveNames = () => normalizeSlotNames(props[WEVU_SLOT_NAMES_PROP]);
|
|
29
|
+
const isEnabled = (key) => typeof key === "string" && resolveNames().includes(key);
|
|
30
|
+
return new Proxy(Object.create(null), {
|
|
31
|
+
get(_target, key) {
|
|
32
|
+
if (isEnabled(key)) return SLOT_RENDER_FN;
|
|
33
|
+
},
|
|
34
|
+
has(_target, key) {
|
|
35
|
+
return isEnabled(key);
|
|
36
|
+
},
|
|
37
|
+
ownKeys() {
|
|
38
|
+
return resolveNames();
|
|
39
|
+
},
|
|
40
|
+
getOwnPropertyDescriptor(_target, key) {
|
|
41
|
+
if (!isEnabled(key)) return;
|
|
42
|
+
return {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
value: SLOT_RENDER_FN
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
set() {
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
deleteProperty() {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function attachRuntimeSlots(runtimeState, props) {
|
|
57
|
+
const slots = createSetupSlotsProxy(props);
|
|
58
|
+
try {
|
|
59
|
+
Object.defineProperty(runtimeState, "$slots", {
|
|
60
|
+
value: slots,
|
|
61
|
+
configurable: true,
|
|
62
|
+
enumerable: false,
|
|
63
|
+
writable: false
|
|
64
|
+
});
|
|
65
|
+
} catch (_unused) {
|
|
66
|
+
runtimeState.$slots = slots;
|
|
67
|
+
}
|
|
68
|
+
return slots;
|
|
69
|
+
}
|
|
70
|
+
function createNoopWatchStopHandle() {
|
|
71
|
+
const stopHandle = (() => {});
|
|
72
|
+
stopHandle.stop = () => {};
|
|
73
|
+
stopHandle.pause = () => {};
|
|
74
|
+
stopHandle.resume = () => {};
|
|
75
|
+
return stopHandle;
|
|
76
|
+
}
|
|
77
|
+
function safeMarkNoSetData(value) {
|
|
78
|
+
try {
|
|
79
|
+
return markNoSetData(value);
|
|
80
|
+
} catch (_unused2) {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function resolveRuntimeNativeMethodOwner(runtime, target, methodName) {
|
|
85
|
+
const runtimeState = runtime === null || runtime === void 0 ? void 0 : runtime.state;
|
|
86
|
+
const runtimeRawState = runtimeState && typeof runtimeState === "object" ? toRaw(runtimeState) : void 0;
|
|
87
|
+
const runtimeProxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy;
|
|
88
|
+
const isBridgeMethod = (candidate) => {
|
|
89
|
+
const candidateMethod = candidate[methodName];
|
|
90
|
+
if (typeof candidateMethod !== "function") return false;
|
|
91
|
+
if (isNativeBridgeMethod(candidateMethod)) return true;
|
|
92
|
+
const targetMethod = target[methodName];
|
|
93
|
+
return typeof targetMethod === "function" && candidateMethod === targetMethod;
|
|
94
|
+
};
|
|
95
|
+
const isValidNativeCandidate = (candidate) => {
|
|
96
|
+
if (!candidate || typeof candidate !== "object") return false;
|
|
97
|
+
if (candidate === target || candidate === runtimeProxy) return false;
|
|
98
|
+
if (isBridgeMethod(candidate)) return false;
|
|
99
|
+
return typeof candidate[methodName] === "function";
|
|
100
|
+
};
|
|
101
|
+
const nativeFromState = runtimeRawState ? runtimeRawState[WEVU_NATIVE_INSTANCE_KEY] : void 0;
|
|
102
|
+
if (isValidNativeCandidate(nativeFromState)) return nativeFromState;
|
|
103
|
+
const runtimeInstance = runtime === null || runtime === void 0 ? void 0 : runtime.instance;
|
|
104
|
+
if (isValidNativeCandidate(runtimeInstance)) return runtimeInstance;
|
|
105
|
+
}
|
|
106
|
+
function defineSetupInstanceMethod(target, methodName, handler) {
|
|
107
|
+
markNativeBridgeMethod(handler);
|
|
108
|
+
try {
|
|
109
|
+
Object.defineProperty(target, methodName, {
|
|
110
|
+
value: handler,
|
|
111
|
+
configurable: true,
|
|
112
|
+
enumerable: false,
|
|
113
|
+
writable: true
|
|
114
|
+
});
|
|
115
|
+
} catch (_unused3) {
|
|
116
|
+
target[methodName] = handler;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function ensureSetupContextInstance(target, runtime) {
|
|
120
|
+
const maybeCached = target[WEVU_SETUP_CONTEXT_INSTANCE_KEY];
|
|
121
|
+
if (maybeCached && typeof maybeCached === "object") return maybeCached;
|
|
122
|
+
const setupInstanceBridge = Object.create(null);
|
|
123
|
+
const resolvePublicValue = (key) => {
|
|
124
|
+
var _WEVU_PROPS_KEY, _ref;
|
|
125
|
+
const runtimeProxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy;
|
|
126
|
+
if (runtimeProxy && Reflect.has(runtimeProxy, key)) return {
|
|
127
|
+
found: true,
|
|
128
|
+
value: Reflect.get(runtimeProxy, key)
|
|
129
|
+
};
|
|
130
|
+
const runtimeProps = (_WEVU_PROPS_KEY = runtime === null || runtime === void 0 || (_ref = runtime.state) === null || _ref === void 0 ? void 0 : _ref[WEVU_PROPS_KEY]) !== null && _WEVU_PROPS_KEY !== void 0 ? _WEVU_PROPS_KEY : target[WEVU_PROPS_KEY];
|
|
131
|
+
if (runtimeProps && typeof runtimeProps === "object" && hasOwn(runtimeProps, key)) return {
|
|
132
|
+
found: true,
|
|
133
|
+
value: Reflect.get(runtimeProps, key)
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
found: false,
|
|
137
|
+
value: void 0
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const resolveSetupBridgeOwner = (methodName) => {
|
|
141
|
+
const owner = resolveRuntimeNativeMethodOwner(runtime, target, methodName);
|
|
142
|
+
if (owner) return owner;
|
|
143
|
+
const fallbackMethod = target[methodName];
|
|
144
|
+
if (typeof fallbackMethod === "function" && !isNativeBridgeMethod(fallbackMethod)) return target;
|
|
145
|
+
};
|
|
146
|
+
defineSetupInstanceMethod(setupInstanceBridge, "triggerEvent", (...args) => {
|
|
147
|
+
const [eventName, detail, options] = args;
|
|
148
|
+
const nativeOwner = resolveSetupBridgeOwner("triggerEvent");
|
|
149
|
+
if (nativeOwner && typeof nativeOwner.triggerEvent === "function") if (args.length >= 3) nativeOwner.triggerEvent(eventName, detail, options);
|
|
150
|
+
else nativeOwner.triggerEvent(eventName, detail);
|
|
151
|
+
});
|
|
152
|
+
defineSetupInstanceMethod(setupInstanceBridge, "createSelectorQuery", () => {
|
|
153
|
+
var _resolveRuntimeNative;
|
|
154
|
+
const nativeOwner = resolveSetupBridgeOwner("createSelectorQuery");
|
|
155
|
+
if (nativeOwner && typeof nativeOwner.createSelectorQuery === "function") return nativeOwner.createSelectorQuery();
|
|
156
|
+
const miniProgramGlobal = getMiniProgramGlobalObject();
|
|
157
|
+
if (!supportsCurrentMiniProgramRuntimeCapability("globalCreateSelectorQuery") || !miniProgramGlobal || typeof miniProgramGlobal.createSelectorQuery !== "function") return;
|
|
158
|
+
const query = miniProgramGlobal.createSelectorQuery();
|
|
159
|
+
if (!query) return query;
|
|
160
|
+
if (!getCurrentMiniProgramRuntimeCapabilities().selectorQueryScopeByIn || typeof query.in !== "function") return query;
|
|
161
|
+
const scopedOwner = (_resolveRuntimeNative = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative !== void 0 ? _resolveRuntimeNative : target;
|
|
162
|
+
return query.in(scopedOwner);
|
|
163
|
+
});
|
|
164
|
+
defineSetupInstanceMethod(setupInstanceBridge, "createIntersectionObserver", (options) => {
|
|
165
|
+
var _resolveRuntimeNative2;
|
|
166
|
+
const nativeOwner = resolveSetupBridgeOwner("createIntersectionObserver");
|
|
167
|
+
if (nativeOwner && typeof nativeOwner.createIntersectionObserver === "function") return nativeOwner.createIntersectionObserver(options !== null && options !== void 0 ? options : {});
|
|
168
|
+
const miniProgramGlobal = getMiniProgramGlobalObject();
|
|
169
|
+
if (!supportsCurrentMiniProgramRuntimeCapability("globalCreateIntersectionObserver") || !miniProgramGlobal || typeof miniProgramGlobal.createIntersectionObserver !== "function") return;
|
|
170
|
+
const scopedOwner = (_resolveRuntimeNative2 = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative2 !== void 0 ? _resolveRuntimeNative2 : target;
|
|
171
|
+
if (getCurrentMiniProgramRuntimeCapabilities().intersectionObserverScopeByParameter) return miniProgramGlobal.createIntersectionObserver(scopedOwner, options !== null && options !== void 0 ? options : {});
|
|
172
|
+
return miniProgramGlobal.createIntersectionObserver(options !== null && options !== void 0 ? options : {});
|
|
173
|
+
});
|
|
174
|
+
defineSetupInstanceMethod(setupInstanceBridge, "setData", (payload, callback) => {
|
|
175
|
+
const nativeOwner = resolveSetupBridgeOwner("setData");
|
|
176
|
+
if (nativeOwner && typeof nativeOwner.setData === "function") return nativeOwner.setData(payload, callback);
|
|
177
|
+
const adapter = runtime === null || runtime === void 0 ? void 0 : runtime.adapter;
|
|
178
|
+
const result = typeof (adapter === null || adapter === void 0 ? void 0 : adapter.setData) === "function" ? adapter.setData(payload) : void 0;
|
|
179
|
+
if (typeof callback === "function") callback();
|
|
180
|
+
return result;
|
|
181
|
+
});
|
|
182
|
+
defineSetupInstanceMethod(setupInstanceBridge, "setUpdatePerformanceListener", (listener) => {
|
|
183
|
+
const nativeOwner = resolveSetupBridgeOwner("setUpdatePerformanceListener");
|
|
184
|
+
if (nativeOwner && typeof nativeOwner.setUpdatePerformanceListener === "function") return nativeOwner.setUpdatePerformanceListener(listener);
|
|
185
|
+
});
|
|
186
|
+
const setupInstance = safeMarkNoSetData(new Proxy(setupInstanceBridge, {
|
|
187
|
+
get(bridgeTarget, key, receiver) {
|
|
188
|
+
if (Reflect.has(bridgeTarget, key)) return Reflect.get(bridgeTarget, key, receiver);
|
|
189
|
+
if (key === "$el") {
|
|
190
|
+
var _resolveRuntimeNative3;
|
|
191
|
+
return (_resolveRuntimeNative3 = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative3 !== void 0 ? _resolveRuntimeNative3 : target;
|
|
192
|
+
}
|
|
193
|
+
if (key === "renderRoot" || key === "shadowRoot") {
|
|
194
|
+
var _resolveRuntimeNative4;
|
|
195
|
+
return ((_resolveRuntimeNative4 = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative4 !== void 0 ? _resolveRuntimeNative4 : target)[key];
|
|
196
|
+
}
|
|
197
|
+
const publicValue = resolvePublicValue(key);
|
|
198
|
+
if (publicValue.found) return publicValue.value;
|
|
199
|
+
const value = target[key];
|
|
200
|
+
if (typeof value === "function") return value.bind(target);
|
|
201
|
+
return value;
|
|
202
|
+
},
|
|
203
|
+
has(bridgeTarget, key) {
|
|
204
|
+
return Reflect.has(bridgeTarget, key) || resolvePublicValue(key).found || key in target;
|
|
205
|
+
},
|
|
206
|
+
set(bridgeTarget, key, value) {
|
|
207
|
+
if (Reflect.has(bridgeTarget, key)) {
|
|
208
|
+
bridgeTarget[key] = value;
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
target[key] = value;
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
try {
|
|
216
|
+
Object.defineProperty(target, WEVU_SETUP_CONTEXT_INSTANCE_KEY, {
|
|
217
|
+
value: setupInstance,
|
|
218
|
+
configurable: true,
|
|
219
|
+
enumerable: false,
|
|
220
|
+
writable: true
|
|
221
|
+
});
|
|
222
|
+
} catch (_unused4) {
|
|
223
|
+
target[WEVU_SETUP_CONTEXT_INSTANCE_KEY] = setupInstance;
|
|
224
|
+
}
|
|
225
|
+
return setupInstance;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
export { attachRuntimeSlots, createNoopWatchStopHandle, createSetupSlotsFallback, createSetupSlotsProxy, ensureSetupContextInstance, normalizeEmitPayload, safeMarkNoSetData, setupInstanceMethodNames };
|
|
230
|
+
//# sourceMappingURL=setupContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupContext.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/setupContext.ts"],"sourcesContent":["import type { WatchStopHandle } from '../../../reactivity'\nimport type {\n InternalRuntimeState,\n MiniProgramAdapter,\n MiniProgramIntersectionObserverOptions,\n RuntimeInstance,\n SetupContextNativeInstance,\n TriggerEventOptions,\n} from '../../types'\nimport {\n WEVU_NATIVE_INSTANCE_KEY,\n WEVU_PROPS_KEY,\n WEVU_SETUP_CONTEXT_INSTANCE_KEY,\n WEVU_SLOT_NAMES_PROP,\n} from '@weapp-core/constants'\nimport { toRaw } from '../../../reactivity'\nimport { hasOwn } from '../../../utils'\nimport { isNativeBridgeMethod, markNativeBridgeMethod } from '../../nativeBridge'\nimport { markNoSetData } from '../../noSetData'\nimport { getCurrentMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, supportsCurrentMiniProgramRuntimeCapability } from '../../platform'\n\nexport { normalizeEmitPayload } from '../../emit'\n\ntype AdapterWithSetData = Required<MiniProgramAdapter> & {\n __wevu_enableSetData?: () => void\n __wevu_setVisibility?: (visible: boolean) => void\n}\n\nexport type SetupInstanceMethodName = 'triggerEvent' | 'createSelectorQuery' | 'createIntersectionObserver' | 'setData' | 'setUpdatePerformanceListener'\n\nexport const setupInstanceMethodNames: SetupInstanceMethodName[] = [\n 'triggerEvent',\n 'createSelectorQuery',\n 'createIntersectionObserver',\n 'setData',\n 'setUpdatePerformanceListener',\n]\n\nexport function createSetupSlotsFallback() {\n return Object.freeze(Object.create(null)) as Record<string, never>\n}\n\nconst SLOT_RENDER_FN = () => []\n\nfunction normalizeSlotNames(value: unknown): string[] {\n if (Array.isArray(value)) {\n return [...new Set(value.filter((item): item is string => typeof item === 'string' && item.length > 0))]\n }\n if (!value || typeof value !== 'object') {\n return []\n }\n return Object.entries(value as Record<string, unknown>)\n .filter(([, enabled]) => Boolean(enabled))\n .map(([name]) => name)\n}\n\nexport function createSetupSlotsProxy(props: Record<string, any>) {\n if (!hasOwn(props, WEVU_SLOT_NAMES_PROP)) {\n return createSetupSlotsFallback()\n }\n\n const resolveNames = () => normalizeSlotNames(props[WEVU_SLOT_NAMES_PROP])\n const isEnabled = (key: PropertyKey) => typeof key === 'string' && resolveNames().includes(key)\n\n return new Proxy(Object.create(null), {\n get(_target, key) {\n if (isEnabled(key)) {\n return SLOT_RENDER_FN\n }\n return undefined\n },\n has(_target, key) {\n return isEnabled(key)\n },\n ownKeys() {\n return resolveNames()\n },\n getOwnPropertyDescriptor(_target, key) {\n if (!isEnabled(key)) {\n return undefined\n }\n return {\n configurable: true,\n enumerable: true,\n value: SLOT_RENDER_FN,\n }\n },\n set() {\n return false\n },\n deleteProperty() {\n return false\n },\n }) as Record<string, any>\n}\n\nexport function attachRuntimeSlots(runtimeState: Record<string, any>, props: Record<string, any>) {\n const slots = createSetupSlotsProxy(props)\n try {\n Object.defineProperty(runtimeState, '$slots', {\n value: slots,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n runtimeState.$slots = slots\n }\n return slots\n}\n\nexport function createNoopWatchStopHandle(): WatchStopHandle {\n const stopHandle = (() => {}) as WatchStopHandle\n stopHandle.stop = () => {}\n stopHandle.pause = () => {}\n stopHandle.resume = () => {}\n return stopHandle\n}\n\nexport function safeMarkNoSetData<T extends object>(value: T): T {\n try {\n return markNoSetData(value)\n }\n catch {\n return value\n }\n}\n\nfunction resolveRuntimeNativeMethodOwner(\n runtime: RuntimeInstance<any, any, any>,\n target: InternalRuntimeState,\n methodName: SetupInstanceMethodName,\n) {\n const runtimeState = runtime?.state\n const runtimeRawState = runtimeState && typeof runtimeState === 'object'\n ? toRaw(runtimeState as any)\n : undefined\n const runtimeProxy = runtime?.proxy as object | undefined\n const isBridgeMethod = (candidate: object) => {\n const candidateMethod = (candidate as any)[methodName]\n if (typeof candidateMethod !== 'function') {\n return false\n }\n if (isNativeBridgeMethod(candidateMethod)) {\n return true\n }\n const targetMethod = (target as any)[methodName]\n return typeof targetMethod === 'function' && candidateMethod === targetMethod\n }\n const isValidNativeCandidate = (candidate: unknown) => {\n if (!candidate || typeof candidate !== 'object') {\n return false\n }\n if (candidate === target || candidate === runtimeProxy) {\n return false\n }\n if (isBridgeMethod(candidate)) {\n return false\n }\n return typeof (candidate as any)[methodName] === 'function'\n }\n const nativeFromState = runtimeRawState ? (runtimeRawState as any)[WEVU_NATIVE_INSTANCE_KEY] : undefined\n if (isValidNativeCandidate(nativeFromState)) {\n return nativeFromState as InternalRuntimeState\n }\n\n const runtimeInstance = (runtime as any)?.instance\n if (isValidNativeCandidate(runtimeInstance)) {\n return runtimeInstance as InternalRuntimeState\n }\n return undefined\n}\n\nfunction defineSetupInstanceMethod(\n target: Record<string, any>,\n methodName: SetupInstanceMethodName,\n handler: (...args: any[]) => any,\n) {\n markNativeBridgeMethod(handler)\n try {\n Object.defineProperty(target, methodName, {\n value: handler,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(target as any)[methodName] = handler\n }\n}\n\nexport function ensureSetupContextInstance(\n target: InternalRuntimeState,\n runtime: RuntimeInstance<any, any, any>,\n) {\n const maybeCached = (target as any)[WEVU_SETUP_CONTEXT_INSTANCE_KEY]\n if (maybeCached && typeof maybeCached === 'object') {\n return maybeCached as SetupContextNativeInstance\n }\n\n const setupInstanceBridge: Record<string, any> = Object.create(null)\n const resolvePublicValue = (key: PropertyKey) => {\n const runtimeProxy = runtime?.proxy as Record<PropertyKey, any> | undefined\n if (runtimeProxy && Reflect.has(runtimeProxy, key)) {\n return {\n found: true,\n value: Reflect.get(runtimeProxy, key),\n }\n }\n const runtimeProps = (runtime?.state as any)?.[WEVU_PROPS_KEY]\n ?? (target as any)[WEVU_PROPS_KEY]\n if (runtimeProps && typeof runtimeProps === 'object' && hasOwn(runtimeProps, key)) {\n return {\n found: true,\n value: Reflect.get(runtimeProps, key),\n }\n }\n return { found: false, value: undefined }\n }\n const resolveSetupBridgeOwner = (methodName: SetupInstanceMethodName) => {\n const owner = resolveRuntimeNativeMethodOwner(runtime, target, methodName)\n if (owner) {\n return owner\n }\n const fallbackMethod = (target as any)[methodName]\n if (typeof fallbackMethod === 'function' && !isNativeBridgeMethod(fallbackMethod)) {\n return target\n }\n return undefined\n }\n\n defineSetupInstanceMethod(setupInstanceBridge, 'triggerEvent', (...args: [string, any?, TriggerEventOptions?]) => {\n const [eventName, detail, options] = args\n const nativeOwner = resolveSetupBridgeOwner('triggerEvent')\n if (nativeOwner && typeof (nativeOwner as any).triggerEvent === 'function') {\n if (args.length >= 3) {\n ;(nativeOwner as any).triggerEvent(eventName, detail, options)\n }\n else {\n ;(nativeOwner as any).triggerEvent(eventName, detail)\n }\n }\n })\n\n defineSetupInstanceMethod(setupInstanceBridge, 'createSelectorQuery', () => {\n const nativeOwner = resolveSetupBridgeOwner('createSelectorQuery')\n if (nativeOwner && typeof (nativeOwner as any).createSelectorQuery === 'function') {\n return (nativeOwner as any).createSelectorQuery()\n }\n\n const miniProgramGlobal = getMiniProgramGlobalObject()\n if (\n !supportsCurrentMiniProgramRuntimeCapability('globalCreateSelectorQuery')\n || !miniProgramGlobal\n || typeof miniProgramGlobal.createSelectorQuery !== 'function'\n ) {\n return undefined\n }\n\n const query = miniProgramGlobal.createSelectorQuery()\n if (!query) {\n return query\n }\n if (\n !getCurrentMiniProgramRuntimeCapabilities().selectorQueryScopeByIn\n || typeof query.in !== 'function'\n ) {\n return query\n }\n\n const scopedOwner = resolveRuntimeNativeMethodOwner(runtime, target, 'setData') ?? target\n return query.in(scopedOwner as any)\n })\n\n defineSetupInstanceMethod(\n setupInstanceBridge,\n 'createIntersectionObserver',\n (options?: MiniProgramIntersectionObserverOptions) => {\n const nativeOwner = resolveSetupBridgeOwner('createIntersectionObserver')\n if (nativeOwner && typeof (nativeOwner as any).createIntersectionObserver === 'function') {\n return (nativeOwner as any).createIntersectionObserver(options ?? {})\n }\n\n const miniProgramGlobal = getMiniProgramGlobalObject()\n if (\n !supportsCurrentMiniProgramRuntimeCapability('globalCreateIntersectionObserver')\n || !miniProgramGlobal\n || typeof miniProgramGlobal.createIntersectionObserver !== 'function'\n ) {\n return undefined\n }\n\n const scopedOwner = resolveRuntimeNativeMethodOwner(runtime, target, 'setData') ?? target\n if (getCurrentMiniProgramRuntimeCapabilities().intersectionObserverScopeByParameter) {\n return miniProgramGlobal.createIntersectionObserver(scopedOwner as any, options ?? {})\n }\n return miniProgramGlobal.createIntersectionObserver(options ?? {})\n },\n )\n\n defineSetupInstanceMethod(setupInstanceBridge, 'setData', (payload: Record<string, any>, callback?: () => void) => {\n const nativeOwner = resolveSetupBridgeOwner('setData')\n if (nativeOwner && typeof (nativeOwner as any).setData === 'function') {\n return (nativeOwner as any).setData(payload, callback)\n }\n\n const adapter = runtime?.adapter as AdapterWithSetData | undefined\n const result = typeof adapter?.setData === 'function'\n ? adapter.setData(payload)\n : undefined\n if (typeof callback === 'function') {\n callback()\n }\n return result\n })\n\n defineSetupInstanceMethod(\n setupInstanceBridge,\n 'setUpdatePerformanceListener',\n (listener?: ((result: Record<string, any>) => void)) => {\n const nativeOwner = resolveSetupBridgeOwner('setUpdatePerformanceListener')\n if (nativeOwner && typeof (nativeOwner as any).setUpdatePerformanceListener === 'function') {\n return (nativeOwner as any).setUpdatePerformanceListener(listener)\n }\n return undefined\n },\n )\n\n const setupInstance = safeMarkNoSetData(new Proxy(setupInstanceBridge, {\n get(bridgeTarget, key, receiver) {\n if (Reflect.has(bridgeTarget, key)) {\n return Reflect.get(bridgeTarget, key, receiver)\n }\n if (key === '$el') {\n return resolveRuntimeNativeMethodOwner(runtime, target, 'setData') ?? target\n }\n if (key === 'renderRoot' || key === 'shadowRoot') {\n const nativeOwner = resolveRuntimeNativeMethodOwner(runtime, target, 'setData') ?? target\n return (nativeOwner as any)[key]\n }\n const publicValue = resolvePublicValue(key)\n if (publicValue.found) {\n return publicValue.value\n }\n const value = (target as any)[key as any]\n if (typeof value === 'function') {\n return value.bind(target)\n }\n return value\n },\n has(bridgeTarget, key) {\n return Reflect.has(bridgeTarget, key) || resolvePublicValue(key).found || key in (target as any)\n },\n set(bridgeTarget, key, value) {\n if (Reflect.has(bridgeTarget, key)) {\n // 仅覆写 setup 暴露的 bridge 方法,避免回写原生实例引发递归调用。\n ;(bridgeTarget as any)[key as any] = value\n return true\n }\n ;(target as any)[key as any] = value\n return true\n },\n }) as SetupContextNativeInstance)\n\n try {\n Object.defineProperty(target as Record<string, any>, WEVU_SETUP_CONTEXT_INSTANCE_KEY, {\n value: setupInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(target as any)[WEVU_SETUP_CONTEXT_INSTANCE_KEY] = setupInstance\n }\n\n return setupInstance\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAa,2BAAsD;CACjE;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,2BAA2B;CACzC,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,CAAC;AAC1C;AAEA,MAAM,uBAAuB,CAAC;AAE9B,SAAS,mBAAmB,OAA0B;CACpD,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,QAAQ,SAAyB,OAAO,SAAS,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC;CAEzG,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO,CAAC;CAEV,OAAO,OAAO,QAAQ,KAAgC,CAAC,CACpD,QAAQ,GAAG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YACnB,OAAO,MAAM,KAAK,MAAM;GAE1B,OAAO;EACT;EACA,IAAI,cAAc,KAAK;GACrB,OAAO,QAAQ,IAAI,cAAc,GAAG,KAAK,mBAAmB,GAAG,CAAC,CAAC,SAAS,OAAQ;EACpF;EACA,IAAI,cAAc,KAAK,OAAO;GAC5B,IAAI,QAAQ,IAAI,cAAc,GAAG,GAAG;IAEjC,AAAC,aAAqB,OAAc;IACrC,OAAO;GACT;GACC,AAAC,OAAe,OAAc;GAC/B,OAAO;EACT;CACF,CAAC,CAA+B;CAEhC,IAAI;EACF,OAAO,eAAe,QAA+B,iCAAiC;GACpF,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,mBACM;EACH,AAAC,OAAe,mCAAmC;CACtD;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { effectScope } from "../../../reactivity/core.mjs";
|
|
2
|
+
import { toRaw } from "../../../reactivity/reactive/shared.mjs";
|
|
3
|
+
import { shallowReactive } from "../../../reactivity/reactive/shallow.mjs";
|
|
4
|
+
import { isReactive } from "../../../reactivity/reactive.mjs";
|
|
5
|
+
import { setCurrentInstance, setCurrentSetupContext } from "../../hooks/base.mjs";
|
|
6
|
+
import { hasOwn } from "../../../utils.mjs";
|
|
7
|
+
import { hasTrackableSetupBinding } from "../../setupTracking.mjs";
|
|
8
|
+
import { normalizeEmitEventName, normalizeEmitPayload } from "../../emit.mjs";
|
|
9
|
+
import { attachRuntimeSlots, ensureSetupContextInstance, safeMarkNoSetData } from "./setupContext.mjs";
|
|
10
|
+
import { runSetupFunction } from "../setup.mjs";
|
|
11
|
+
import { attachRuntimeSetupState, ensureRuntimeProps } from "./utils.mjs";
|
|
12
|
+
import { WEVU_ATTRS_KEY, WEVU_EFFECT_SCOPE_KEY, WEVU_EXPOSED_KEY, WEVU_PROP_KEYS_KEY } from "@weapp-core/constants";
|
|
13
|
+
|
|
14
|
+
//#region src/runtime/register/runtimeInstance/setupPhase.ts
|
|
15
|
+
let vueCompatInstanceUid = 0;
|
|
16
|
+
function attachVueCompatInstanceView(target, proxy) {
|
|
17
|
+
const internal = target;
|
|
18
|
+
const descriptors = {
|
|
19
|
+
proxy: {
|
|
20
|
+
configurable: true,
|
|
21
|
+
enumerable: false,
|
|
22
|
+
value: proxy,
|
|
23
|
+
writable: false
|
|
24
|
+
},
|
|
25
|
+
$: {
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: false,
|
|
28
|
+
value: target,
|
|
29
|
+
writable: false
|
|
30
|
+
},
|
|
31
|
+
uid: {
|
|
32
|
+
configurable: true,
|
|
33
|
+
enumerable: false,
|
|
34
|
+
value: ++vueCompatInstanceUid,
|
|
35
|
+
writable: false
|
|
36
|
+
},
|
|
37
|
+
exposed: {
|
|
38
|
+
configurable: true,
|
|
39
|
+
enumerable: false,
|
|
40
|
+
get: () => target[WEVU_EXPOSED_KEY]
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
for (const [key, descriptor] of Object.entries(descriptors)) try {
|
|
44
|
+
Object.defineProperty(internal, key, descriptor);
|
|
45
|
+
} catch (_unused) {
|
|
46
|
+
if ("value" in descriptor) internal[key] = descriptor.value;
|
|
47
|
+
}
|
|
48
|
+
const publicDescriptors = {
|
|
49
|
+
$: {
|
|
50
|
+
configurable: true,
|
|
51
|
+
enumerable: false,
|
|
52
|
+
value: target,
|
|
53
|
+
writable: false
|
|
54
|
+
},
|
|
55
|
+
$el: {
|
|
56
|
+
configurable: true,
|
|
57
|
+
enumerable: false,
|
|
58
|
+
value: target,
|
|
59
|
+
writable: false
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
for (const [key, descriptor] of Object.entries(publicDescriptors)) try {
|
|
63
|
+
Object.defineProperty(proxy, key, descriptor);
|
|
64
|
+
} catch (_unused2) {
|
|
65
|
+
proxy[key] = descriptor.value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function isInternalAttrKey(key) {
|
|
69
|
+
return key.startsWith("__wv_");
|
|
70
|
+
}
|
|
71
|
+
function runRuntimeSetupPhase(options) {
|
|
72
|
+
var _runtimeWithDefaults$;
|
|
73
|
+
const { target, runtime, runtimeWithDefaults, runtimeState, runtimeProxy, setup } = options;
|
|
74
|
+
const props = ensureRuntimeProps(target, runtimeState, target.properties || {});
|
|
75
|
+
const attrs = shallowReactive(Object.create(null));
|
|
76
|
+
const declaredPropKeys = new Set(Array.isArray(target[WEVU_PROP_KEYS_KEY]) ? target[WEVU_PROP_KEYS_KEY] : []);
|
|
77
|
+
const hasRuntimeStateKey = (key) => {
|
|
78
|
+
return runtimeState != null && typeof runtimeState === "object" && hasOwn(runtimeState, key);
|
|
79
|
+
};
|
|
80
|
+
const syncAttrsFromProperties = () => {
|
|
81
|
+
const next = target.properties && typeof target.properties === "object" ? target.properties : void 0;
|
|
82
|
+
for (const existingKey of Object.keys(attrs)) if (!next || !hasOwn(next, existingKey) || isInternalAttrKey(existingKey) || declaredPropKeys.has(existingKey) || hasRuntimeStateKey(existingKey)) delete attrs[existingKey];
|
|
83
|
+
if (!next) return;
|
|
84
|
+
for (const [key, value] of Object.entries(next)) {
|
|
85
|
+
if (isInternalAttrKey(key) || declaredPropKeys.has(key) || hasRuntimeStateKey(key)) continue;
|
|
86
|
+
attrs[key] = value;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
syncAttrsFromProperties();
|
|
90
|
+
try {
|
|
91
|
+
Object.defineProperty(target, WEVU_ATTRS_KEY, {
|
|
92
|
+
value: attrs,
|
|
93
|
+
configurable: true,
|
|
94
|
+
enumerable: false,
|
|
95
|
+
writable: false
|
|
96
|
+
});
|
|
97
|
+
} catch (_unused3) {
|
|
98
|
+
target[WEVU_ATTRS_KEY] = attrs;
|
|
99
|
+
}
|
|
100
|
+
const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults);
|
|
101
|
+
attachVueCompatInstanceView(target, setupInstance);
|
|
102
|
+
const slots = attachRuntimeSlots(runtimeState, props);
|
|
103
|
+
attachRuntimeSetupState(runtimeState, (_runtimeWithDefaults$ = runtimeWithDefaults.setupState) !== null && _runtimeWithDefaults$ !== void 0 ? _runtimeWithDefaults$ : Object.create(null));
|
|
104
|
+
const context = safeMarkNoSetData({
|
|
105
|
+
props,
|
|
106
|
+
runtime: runtimeWithDefaults,
|
|
107
|
+
state: runtimeState,
|
|
108
|
+
proxy: runtimeProxy,
|
|
109
|
+
bindModel: runtime.bindModel.bind(runtimeWithDefaults),
|
|
110
|
+
watch: runtime.watch.bind(runtimeWithDefaults),
|
|
111
|
+
instance: setupInstance,
|
|
112
|
+
emit: (event, ...args) => {
|
|
113
|
+
const { detail, options } = normalizeEmitPayload(args);
|
|
114
|
+
const eventName = normalizeEmitEventName(event);
|
|
115
|
+
setupInstance.triggerEvent(eventName, detail, options);
|
|
116
|
+
},
|
|
117
|
+
expose: (exposed) => {
|
|
118
|
+
target[WEVU_EXPOSED_KEY] = exposed;
|
|
119
|
+
},
|
|
120
|
+
attrs,
|
|
121
|
+
slots
|
|
122
|
+
});
|
|
123
|
+
const instanceScope = effectScope(true);
|
|
124
|
+
target[WEVU_EFFECT_SCOPE_KEY] = instanceScope;
|
|
125
|
+
setCurrentInstance(target);
|
|
126
|
+
setCurrentSetupContext(context);
|
|
127
|
+
try {
|
|
128
|
+
const result = instanceScope.run(() => runSetupFunction(setup, props, context));
|
|
129
|
+
let methodsChanged = false;
|
|
130
|
+
if (result && typeof result === "object") {
|
|
131
|
+
const runtimeSetupState = runtime.setupState && typeof runtime.setupState === "object" ? isReactive(runtime.setupState) ? toRaw(runtime.setupState) : runtime.setupState : Object.create(null);
|
|
132
|
+
Object.keys(result).forEach((key) => {
|
|
133
|
+
const val = result[key];
|
|
134
|
+
if (typeof val === "function") {
|
|
135
|
+
runtime.methods[key] = (...args) => val.apply(runtime.proxy, args);
|
|
136
|
+
runtime.state[key] = (...args) => val.apply(runtime.proxy, args);
|
|
137
|
+
methodsChanged = true;
|
|
138
|
+
} else {
|
|
139
|
+
if (hasTrackableSetupBinding(val)) {
|
|
140
|
+
var _wevu_trackSetupReact;
|
|
141
|
+
(_wevu_trackSetupReact = runtime.__wevu_trackSetupReactiveKey) === null || _wevu_trackSetupReact === void 0 || _wevu_trackSetupReact.call(runtime, key);
|
|
142
|
+
}
|
|
143
|
+
runtime.state[key] = val;
|
|
144
|
+
runtimeSetupState[key] = val;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (methodsChanged) {
|
|
149
|
+
var _wevu_touchSetupMetho;
|
|
150
|
+
(_wevu_touchSetupMetho = runtime.__wevu_touchSetupMethodsVersion) === null || _wevu_touchSetupMetho === void 0 || _wevu_touchSetupMetho.call(runtime);
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
instanceScope.stop();
|
|
154
|
+
target[WEVU_EFFECT_SCOPE_KEY] = void 0;
|
|
155
|
+
throw error;
|
|
156
|
+
} finally {
|
|
157
|
+
setCurrentSetupContext(void 0);
|
|
158
|
+
setCurrentInstance(void 0);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
export { runRuntimeSetupPhase };
|
|
164
|
+
//# sourceMappingURL=setupPhase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupPhase.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/setupPhase.ts"],"sourcesContent":["import type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineAppOptions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeInstance,\n} from '../../types'\nimport {\n WEVU_ATTRS_KEY,\n WEVU_EFFECT_SCOPE_KEY,\n WEVU_EXPOSED_KEY,\n WEVU_PROP_KEYS_KEY,\n} from '@weapp-core/constants'\nimport { effectScope, isReactive, shallowReactive, toRaw } from '../../../reactivity'\nimport { hasOwn } from '../../../utils'\nimport { normalizeEmitEventName } from '../../emit'\nimport { setCurrentInstance, setCurrentSetupContext } from '../../hooks'\nimport { hasTrackableSetupBinding } from '../../setupTracking'\nimport { runSetupFunction } from '../setup'\nimport {\n attachRuntimeSlots,\n ensureSetupContextInstance,\n normalizeEmitPayload,\n safeMarkNoSetData,\n} from './setupContext'\nimport { attachRuntimeSetupState, ensureRuntimeProps } from './utils'\n\ntype RuntimeSetupFunction<\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> = DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n | DefineAppOptions<D, C, M>['setup']\n\nlet vueCompatInstanceUid = 0\n\nfunction attachVueCompatInstanceView(target: InternalRuntimeState, proxy: Record<string, any>) {\n const internal = target as Record<string, any>\n const descriptors: PropertyDescriptorMap = {\n proxy: {\n configurable: true,\n enumerable: false,\n value: proxy,\n writable: false,\n },\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n uid: {\n configurable: true,\n enumerable: false,\n value: ++vueCompatInstanceUid,\n writable: false,\n },\n exposed: {\n configurable: true,\n enumerable: false,\n get: () => target[WEVU_EXPOSED_KEY],\n },\n }\n for (const [key, descriptor] of Object.entries(descriptors)) {\n try {\n Object.defineProperty(internal, key, descriptor)\n }\n catch {\n if ('value' in descriptor) {\n internal[key] = descriptor.value\n }\n }\n }\n const publicDescriptors: PropertyDescriptorMap = {\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n $el: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n }\n for (const [key, descriptor] of Object.entries(publicDescriptors)) {\n try {\n Object.defineProperty(proxy, key, descriptor)\n }\n catch {\n proxy[key] = descriptor.value\n }\n }\n}\n\nfunction isInternalAttrKey(key: string) {\n return key.startsWith('__wv_')\n}\n\nexport function runRuntimeSetupPhase<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n target: InternalRuntimeState\n runtime: RuntimeInstance<D, C, M>\n runtimeWithDefaults: RuntimeInstance<any, any, any>\n runtimeState: Record<string, any>\n runtimeProxy: Record<string, any>\n setup: RuntimeSetupFunction<D, C, M>\n}) {\n const {\n target,\n runtime,\n runtimeWithDefaults,\n runtimeState,\n runtimeProxy,\n setup,\n } = options\n\n // 从小程序 properties 提取 props 供 setup 使用,并复用 runtime state 上的 props 容器,\n // 避免 computed 首次求值早于 setup 时丢失依赖。\n const mpProperties = ((target as any).properties || {}) as Record<string, any>\n const props = ensureRuntimeProps(target, runtimeState, mpProperties)\n\n // 与 Vue 3 对齐:attrs = 非 props 的 attributes。\n // 在小程序场景中,attrs 来源于 instance.properties 中“未声明在 props/properties 的字段”。\n const attrs = shallowReactive(Object.create(null)) as Record<string, any>\n const declaredPropKeys = new Set(\n Array.isArray((target as any)[WEVU_PROP_KEYS_KEY])\n ? ((target as any)[WEVU_PROP_KEYS_KEY] as string[])\n : [],\n )\n const hasRuntimeStateKey = (key: string) => {\n return runtimeState != null\n && typeof runtimeState === 'object'\n && hasOwn(runtimeState as Record<string, unknown>, key)\n }\n const syncAttrsFromProperties = () => {\n const next = ((target as any).properties && typeof (target as any).properties === 'object')\n ? ((target as any).properties as Record<string, unknown>)\n : undefined\n\n for (const existingKey of Object.keys(attrs)) {\n if (\n !next\n || !hasOwn(next, existingKey)\n || isInternalAttrKey(existingKey)\n || declaredPropKeys.has(existingKey)\n || hasRuntimeStateKey(existingKey)\n ) {\n delete attrs[existingKey]\n }\n }\n\n if (!next) {\n return\n }\n\n for (const [key, value] of Object.entries(next)) {\n if (isInternalAttrKey(key) || declaredPropKeys.has(key) || hasRuntimeStateKey(key)) {\n continue\n }\n attrs[key] = value\n }\n }\n syncAttrsFromProperties()\n\n try {\n Object.defineProperty(target, WEVU_ATTRS_KEY, {\n value: attrs,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(target as any)[WEVU_ATTRS_KEY] = attrs\n }\n\n const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults)\n attachVueCompatInstanceView(target, setupInstance as Record<string, any>)\n const slots = attachRuntimeSlots(runtimeState, props)\n const setupState = runtimeWithDefaults.setupState ?? Object.create(null)\n attachRuntimeSetupState(runtimeState, setupState)\n\n const context = safeMarkNoSetData({\n // 与 Vue 3 对齐的 ctx.props\n props,\n\n // 现有运行时能力\n runtime: runtimeWithDefaults,\n state: runtimeState,\n proxy: runtimeProxy,\n bindModel: runtime.bindModel.bind(runtimeWithDefaults),\n watch: runtime.watch.bind(runtimeWithDefaults),\n instance: setupInstance,\n\n // 通过小程序 triggerEvent 派发事件,并兼容 Vue 3 的 emit(event, ...args) 形式。\n emit: (event: string, ...args: any[]) => {\n const { detail, options } = normalizeEmitPayload(args)\n const eventName = normalizeEmitEventName(event)\n setupInstance.triggerEvent(eventName, detail, options)\n },\n\n // 与 Vue 3 对齐的 expose\n expose: (exposed: Record<string, any>) => {\n target[WEVU_EXPOSED_KEY] = exposed\n },\n\n // 与 Vue 3 对齐的 attrs(小程序中为非 props 属性集合)\n attrs,\n\n // 与 Vue 3 对齐的 slots(由编译期传入的 slot 名元数据驱动)\n slots,\n }) as any\n\n // 仅在同步 setup 执行期间暴露 current instance\n const instanceScope = effectScope(true)\n target[WEVU_EFFECT_SCOPE_KEY] = instanceScope\n setCurrentInstance(target)\n setCurrentSetupContext(context)\n try {\n const result = instanceScope.run(() => runSetupFunction(setup, props, context))\n let methodsChanged = false\n if (result && typeof result === 'object') {\n const runtimeSetupState = (runtime as any).setupState && typeof (runtime as any).setupState === 'object'\n ? (isReactive((runtime as any).setupState) ? toRaw((runtime as any).setupState) : (runtime as any).setupState)\n : Object.create(null)\n Object.keys(result).forEach((key) => {\n const val = (result as any)[key]\n if (typeof val === 'function') {\n ;(runtime.methods as any)[key] = (...args: any[]) => (val as any).apply((runtime as any).proxy, args)\n ;(runtime.state as any)[key] = (...args: any[]) => (val as any).apply((runtime as any).proxy, args)\n methodsChanged = true\n }\n else {\n if (hasTrackableSetupBinding(val)) {\n ;(runtime as any).__wevu_trackSetupReactiveKey?.(key)\n }\n ;(runtime.state as any)[key] = val\n ;(runtimeSetupState as any)[key] = val\n }\n })\n }\n if (methodsChanged) {\n ;(runtime as any).__wevu_touchSetupMethodsVersion?.()\n }\n }\n catch (error) {\n instanceScope.stop()\n target[WEVU_EFFECT_SCOPE_KEY] = undefined\n throw error\n }\n finally {\n setCurrentSetupContext(undefined)\n setCurrentInstance(undefined)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAC7F,MAAM,WAAW;CACjB,MAAM,cAAqC;EACzC,OAAO;GACL,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,GAAG;GACD,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,KAAK;GACH,cAAc;GACd,YAAY;GACZ,OAAO,EAAE;GACT,UAAU;EACZ;EACA,SAAS;GACP,cAAc;GACd,YAAY;GACZ,WAAW,OAAO;EACpB;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,WAAW,GACxD,IAAI;EACF,OAAO,eAAe,UAAU,KAAK,UAAU;CACjD,kBACM;EACJ,IAAI,WAAW,YACb,SAAS,OAAO,WAAW;CAE/B;CAEF,MAAM,oBAA2C;EAC/C,GAAG;GACD,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,KAAK;GACH,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,iBAAiB,GAC9D,IAAI;EACF,OAAO,eAAe,OAAO,KAAK,UAAU;CAC9C,mBACM;EACJ,MAAM,OAAO,WAAW;CAC1B;AAEJ;AAEA,SAAS,kBAAkB,KAAa;CACtC,OAAO,IAAI,WAAW,OAAO;AAC/B;AAEA,SAAgB,qBAAmG,SAOhH;;CACD,MAAM,EACJ,QACA,SACA,qBACA,cACA,cACA,UACE;CAKJ,MAAM,QAAQ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