wevu 7.5.0 → 7.7.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/alipay/jsx-runtime.d.mts +0 -2
- package/dist/config/defaults.d.mts +42 -0
- package/dist/config/pageFeatures.d.mts +49 -0
- package/dist/config.d.mts +4 -0
- package/dist/config.mjs +1 -0
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/defineProperty.mjs +1 -2
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPrimitive.mjs +1 -2
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPropertyKey.mjs +1 -2
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/typeof.mjs +1 -2
- package/dist/dev/api/vitest/setup.mjs +1 -2
- package/dist/dev/package.mjs +2 -3
- package/dist/dev/reactivity/asyncDerivation.mjs +1 -2
- package/dist/dev/reactivity/computed.mjs +1 -2
- package/dist/dev/reactivity/computed.mjs.map +1 -1
- package/dist/dev/reactivity/core.mjs +2 -3
- package/dist/dev/reactivity/reactive/mutation.mjs +1 -2
- package/dist/dev/reactivity/reactive/patch.mjs +1 -2
- package/dist/dev/reactivity/reactive/patchState.mjs +1 -2
- package/dist/dev/reactivity/reactive/shallow.mjs +1 -2
- package/dist/dev/reactivity/reactive/shared.mjs +1 -2
- package/dist/dev/reactivity/reactive/state.mjs +1 -2
- package/dist/dev/reactivity/reactive.mjs +1 -2
- package/dist/dev/reactivity/readonly.mjs +1 -2
- package/dist/dev/reactivity/ref.mjs +2 -3
- package/dist/dev/reactivity/ref.mjs.map +1 -1
- package/dist/dev/reactivity/shallowRef.mjs +1 -2
- package/dist/dev/reactivity/toRefs.mjs +1 -2
- package/dist/dev/reactivity/traverse.mjs +1 -2
- package/dist/dev/reactivity/watch/helpers.mjs +1 -2
- package/dist/dev/reactivity/watch/types.mjs +1 -2
- package/dist/dev/reactivity/watch.mjs +1 -2
- package/dist/dev/router/auto-routes.mjs +1 -2
- package/dist/dev/router/backNavigation.mjs +1 -2
- package/dist/dev/router/createRouter.mjs +1 -2
- package/dist/dev/router/initialNavigation.mjs +1 -2
- package/dist/dev/router/instance.mjs +1 -2
- package/dist/dev/router/navigationApi.mjs +1 -2
- package/dist/dev/router/navigationCore.mjs +1 -2
- package/dist/dev/router/navigationResult.mjs +1 -2
- package/dist/dev/router/navigationTarget.mjs +1 -2
- package/dist/dev/router/navigationTargetHelpers.mjs +1 -2
- package/dist/dev/router/resolve.mjs +1 -2
- package/dist/dev/router/routeRegistry.mjs +1 -2
- package/dist/dev/router/routeSync.mjs +1 -2
- package/dist/dev/router/scrollRestoration/adapters.mjs +1 -2
- package/dist/dev/router/scrollRestoration/controller.mjs +1 -2
- package/dist/dev/router/scrollRestoration/host.mjs +1 -2
- package/dist/dev/router/scrollRestoration/index.mjs +1 -2
- package/dist/dev/router/types.mjs +1 -2
- package/dist/dev/router/useRoute.mjs +1 -2
- package/dist/dev/router/useRouter.mjs +1 -2
- package/dist/dev/routerInternal/location.mjs +1 -2
- package/dist/dev/routerInternal/matching.mjs +1 -2
- package/dist/dev/routerInternal/params.mjs +1 -2
- package/dist/dev/routerInternal/path.mjs +1 -2
- package/dist/dev/routerInternal/query.mjs +1 -2
- package/dist/dev/routerInternal/records.mjs +1 -2
- package/dist/dev/routerInternal/recordsWarnings.mjs +1 -2
- package/dist/dev/routerInternal/snapshots.mjs +1 -2
- package/dist/dev/runtime/app/computed.mjs +1 -2
- package/dist/dev/runtime/app/context.mjs +1 -2
- package/dist/dev/runtime/app/diagnostics.mjs +1 -2
- package/dist/dev/runtime/app/mount.mjs +1 -2
- package/dist/dev/runtime/app/pending.mjs +1 -2
- package/dist/dev/runtime/app/setData/commitTracker.mjs +1 -2
- package/dist/dev/runtime/app/setData/observation.mjs +1 -2
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +1 -2
- package/dist/dev/runtime/app/setData/payload.mjs +1 -2
- package/dist/dev/runtime/app/setData/scheduler.mjs +1 -2
- package/dist/dev/runtime/app/setData/snapshot.mjs +1 -2
- package/dist/dev/runtime/app/setDataOptions.mjs +1 -2
- package/dist/dev/runtime/app.mjs +1 -2
- package/dist/dev/runtime/bindModel.mjs +1 -2
- package/dist/dev/runtime/bindingManifest.mjs +1 -2
- package/dist/dev/runtime/capabilities.mjs +1 -2
- package/dist/dev/runtime/css.mjs +1 -2
- package/dist/dev/runtime/defaults.mjs +1 -2
- package/dist/dev/runtime/define/componentDefinition.mjs +1 -2
- package/dist/dev/runtime/define/initialComputed.mjs +1 -2
- package/dist/dev/runtime/define/options.mjs +1 -2
- package/dist/dev/runtime/define/optionsApi.mjs +1 -2
- package/dist/dev/runtime/define/props.mjs +1 -2
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +1 -2
- package/dist/dev/runtime/define/setupResult.mjs +4 -7
- package/dist/dev/runtime/define/setupResult.mjs.map +1 -1
- package/dist/dev/runtime/define.mjs +3 -9
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/diff.mjs +1 -2
- package/dist/dev/runtime/disposables.mjs +1 -2
- package/dist/dev/runtime/elementIntersectionObserver.mjs +1 -2
- package/dist/dev/runtime/emit.mjs +1 -2
- package/dist/dev/runtime/features/inlineEvents.mjs +1 -2
- package/dist/dev/runtime/features/jsxIslands.mjs +1 -2
- package/dist/dev/runtime/features/layout.mjs +1 -2
- package/dist/dev/runtime/features/patchStrategy.mjs +1 -2
- package/dist/dev/runtime/features/publicLayout.mjs +1 -2
- package/dist/dev/runtime/features/scopedSlots.mjs +1 -2
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.mjs +1 -2
- package/dist/dev/runtime/features/templateRefs.mjs +1 -2
- package/dist/dev/runtime/hooks/base.mjs +1 -2
- package/dist/dev/runtime/hooks/pageScroll.mjs +1 -2
- package/dist/dev/runtime/hooks/register.mjs +1 -2
- package/dist/dev/runtime/hooks/vue.mjs +1 -2
- package/dist/dev/runtime/inlineDataset.mjs +1 -2
- package/dist/dev/runtime/internal.mjs +1 -2
- package/dist/dev/runtime/intersectionObserver.mjs +1 -2
- package/dist/dev/runtime/jsxIsland.mjs +1 -2
- package/dist/dev/runtime/layoutBridge.mjs +1 -2
- package/dist/dev/runtime/layoutComponentMatcher.mjs +1 -2
- package/dist/dev/runtime/nativeBridge.mjs +1 -2
- package/dist/dev/runtime/navigationLifecycle.mjs +1 -2
- package/dist/dev/runtime/noSetData.mjs +1 -2
- package/dist/dev/runtime/pageEnvironment.mjs +1 -2
- package/dist/dev/runtime/pageLayout.mjs +1 -2
- package/dist/dev/runtime/pageLayout.mjs.map +1 -1
- package/dist/dev/runtime/pageScroll.mjs +1 -2
- package/dist/dev/runtime/platform/current.mjs +1 -2
- package/dist/dev/runtime/platform/generic.mjs +1 -2
- package/dist/dev/runtime/platform/globals.mjs +1 -2
- package/dist/dev/runtime/platform.mjs +1 -2
- package/dist/dev/runtime/provide.mjs +1 -2
- package/dist/dev/runtime/provideContext.mjs +1 -2
- package/dist/dev/runtime/provideStore.mjs +1 -2
- package/dist/dev/runtime/publicRuntime.mjs +1 -2
- package/dist/dev/runtime/pullDownRefresh.mjs +1 -2
- package/dist/dev/runtime/register/app.mjs +1 -2
- package/dist/dev/runtime/register/component/alipay.mjs +1 -2
- package/dist/dev/runtime/register/component/alipayRegistration.mjs +1 -2
- package/dist/dev/runtime/register/component/features.mjs +1 -2
- package/dist/dev/runtime/register/component/hmrRegistration.mjs +14 -0
- package/dist/dev/runtime/register/component/hmrRegistration.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +1 -2
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +1 -2
- package/dist/dev/runtime/register/component/lifecycle.mjs +1 -2
- package/dist/dev/runtime/register/component/methods.mjs +1 -2
- package/dist/dev/runtime/register/component/options.mjs +1 -2
- package/dist/dev/runtime/register/component/props.mjs +5 -6
- package/dist/dev/runtime/register/component/props.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +7 -6
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerNativeDefinition.mjs +1 -2
- package/dist/dev/runtime/register/component.mjs +23 -14
- package/dist/dev/runtime/register/component.mjs.map +1 -1
- package/dist/dev/runtime/register/inline.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/nativeDeclaration.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +3 -27
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs +1 -2
- package/dist/dev/runtime/register/runtimeInstance.mjs +12 -14
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +1 -2
- package/dist/dev/runtime/register/setup.mjs +1 -2
- package/dist/dev/runtime/register/snapshot.mjs +1 -2
- package/dist/dev/runtime/register/watch.mjs +2 -5
- package/dist/dev/runtime/register/watch.mjs.map +1 -1
- package/dist/dev/runtime/scopedSlots.mjs +1 -2
- package/dist/dev/runtime/selectorQuery.mjs +1 -2
- package/dist/dev/runtime/setupTracking.mjs +1 -2
- package/dist/dev/runtime/teardown.mjs +1 -2
- package/dist/dev/runtime/template.mjs +1 -2
- package/dist/dev/runtime/templateRefs/helpers.mjs +1 -2
- package/dist/dev/runtime/templateRefs.mjs +1 -2
- package/dist/dev/runtime/uniAppHost.mjs +1 -2
- package/dist/dev/runtime/updatePerformance.mjs +1 -2
- package/dist/dev/runtime/use.mjs +1 -2
- package/dist/dev/runtime/vueCompat/context.mjs +1 -2
- package/dist/dev/runtime/vueCompat/model.mjs +1 -2
- package/dist/dev/runtime/vueCompat/router.mjs +1 -2
- package/dist/dev/runtime/vueCompat/templateRef.mjs +1 -2
- package/dist/dev/scheduler.mjs +1 -2
- package/dist/dev/store/actions.mjs +1 -2
- package/dist/dev/store/base.mjs +1 -2
- package/dist/dev/store/define/create.mjs +1 -2
- package/dist/dev/store/define.mjs +1 -2
- package/dist/dev/store/manager.mjs +1 -2
- package/dist/dev/store/storeToRefs.mjs +1 -2
- package/dist/dev/store/subscriptions.mjs +1 -2
- package/dist/dev/store/types.mjs +1 -2
- package/dist/dev/store/utils.mjs +1 -2
- package/dist/dev/store/view.mjs +1 -2
- package/dist/dev/utils.mjs +1 -2
- package/dist/dev/version.mjs +1 -2
- package/dist/dev/vue-demi.mjs +1 -2
- package/dist/fetch.d.mts +0 -2
- package/dist/index.d.mts +13 -8
- package/dist/internal-reactivity.d.mts +2 -1
- package/dist/jsx-runtime.d.mts +1 -2
- package/dist/jsxTypes.d.mts +1 -3
- package/dist/macros/shared.d.mts +2 -3
- package/dist/macros.d.mts +3 -12
- package/dist/miniprogram/jsx-runtime.d.mts +0 -2
- package/dist/package.mjs +1 -1
- package/dist/reactivity/asyncDerivation.d.mts +1 -2
- package/dist/reactivity/computed.d.mts +2 -8
- package/dist/reactivity/core.d.mts +1 -3
- package/dist/reactivity/core.mjs +1 -1
- package/dist/reactivity/index.d.mts +2 -1
- package/dist/reactivity/reactive/mutation.d.mts +1 -2
- package/dist/reactivity/reactive/patch.d.mts +1 -3
- package/dist/reactivity/reactive/patchState.mjs +1 -1
- package/dist/reactivity/reactive/shallow.d.mts +1 -3
- package/dist/reactivity/reactive/shared.d.mts +1 -3
- package/dist/reactivity/reactive.d.mts +0 -2
- package/dist/reactivity/readonly.d.mts +1 -3
- package/dist/reactivity/ref.d.mts +2 -4
- package/dist/reactivity/ref.mjs +1 -1
- package/dist/reactivity/shallowRef.d.mts +1 -3
- package/dist/reactivity/toRefs.d.mts +1 -2
- package/dist/reactivity/traverse.d.mts +1 -3
- package/dist/reactivity/watch/types.d.mts +1 -2
- package/dist/reactivity/watch.d.mts +0 -2
- package/dist/router/auto-routes.d.mts +0 -2
- package/dist/router/createRouter.d.mts +1 -3
- package/dist/router/navigationCore.d.mts +1 -3
- package/dist/router/resolve.d.mts +1 -3
- package/dist/router/scrollRestoration/adapters.d.mts +1 -3
- package/dist/router/scrollRestoration/controller.d.mts +1 -3
- package/dist/router/scrollRestoration/index.d.mts +0 -2
- package/dist/router/scrollRestoration/index.mjs +1 -1
- package/dist/router/scrollRestoration/types.d.mts +1 -3
- package/dist/router/types.d.mts +1 -2
- package/dist/router/useRoute.d.mts +1 -3
- package/dist/router/useRouter.d.mts +1 -3
- package/dist/router.d.mts +0 -2
- package/dist/routerInternal/query.d.mts +1 -3
- package/dist/routerInternal/types.d.mts +1 -3
- package/dist/runtime/app/pending.d.mts +1 -3
- package/dist/runtime/app/setData/commitTracker.d.mts +1 -3
- package/dist/runtime/app/setData/observation.d.mts +1 -2
- package/dist/runtime/app/setData/scheduler.d.mts +1 -3
- package/dist/runtime/app/setData/scheduler.mjs +1 -1
- package/dist/runtime/app.d.mts +2 -4
- package/dist/runtime/capabilities.d.mts +2 -4
- package/dist/runtime/css.d.mts +1 -3
- package/dist/runtime/defaults.d.mts +1 -3
- package/dist/runtime/define/props.mjs +1 -1
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
- package/dist/runtime/define/setupResult.mjs +1 -1
- package/dist/runtime/define.d.mts +4 -4
- package/dist/runtime/define.mjs +1 -1
- package/dist/runtime/disposables.d.mts +1 -3
- package/dist/runtime/elementIntersectionObserver.d.mts +1 -3
- package/dist/runtime/features/inlineEvents.d.mts +1 -3
- package/dist/runtime/features/jsxIslands.d.mts +1 -3
- package/dist/runtime/features/layout.d.mts +1 -3
- package/dist/runtime/features/patchStrategy.d.mts +1 -3
- package/dist/runtime/features/publicLayout.d.mts +2 -3
- package/dist/runtime/features/scopedSlots.d.mts +2 -4
- package/dist/runtime/features/setDataHighFrequencyWarning.d.mts +1 -3
- package/dist/runtime/features/templateRefs.d.mts +1 -3
- package/dist/runtime/hooks/base.d.mts +1 -3
- package/dist/runtime/hooks/register.d.mts +1 -3
- package/dist/runtime/hooks/vue.d.mts +1 -3
- package/dist/runtime/index.d.mts +7 -4
- package/dist/runtime/intersectionObserver.d.mts +1 -3
- package/dist/runtime/jsxIsland.d.mts +1 -3
- package/dist/runtime/layoutBridge.d.mts +0 -2
- package/dist/runtime/noSetData.d.mts +1 -3
- package/dist/runtime/pageEnvironment.d.mts +1 -3
- package/dist/runtime/pageLayout.d.mts +2 -3
- package/dist/runtime/pageScroll.d.mts +1 -3
- package/dist/runtime/provide.d.mts +0 -2
- package/dist/runtime/provideStore.d.mts +1 -3
- package/dist/runtime/publicRuntime.d.mts +1 -3
- package/dist/runtime/pullDownRefresh.d.mts +1 -3
- package/dist/runtime/register/app.d.mts +2 -4
- package/dist/runtime/register/component/hmrRegistration.mjs +1 -0
- package/dist/runtime/register/component/props.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/runtime/register/component.d.mts +2 -4
- package/dist/runtime/register/component.mjs +1 -1
- package/dist/runtime/register/inline.d.mts +1 -2
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
- package/dist/runtime/register/runtimeInstance.d.mts +2 -3
- package/dist/runtime/register/runtimeInstance.mjs +1 -1
- package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -1
- package/dist/runtime/register/setup.d.mts +1 -2
- package/dist/runtime/register/watch.d.mts +1 -2
- package/dist/runtime/register/watch.mjs +1 -1
- package/dist/runtime/selectorQuery.d.mts +1 -3
- package/dist/runtime/template.d.mts +1 -3
- package/dist/runtime/templateRefTypes.d.mts +2 -6
- package/dist/runtime/types/core.d.mts +2 -8
- package/dist/runtime/types/miniprogram.d.mts +0 -2
- package/dist/runtime/types/miniprogramHost.d.mts +0 -2
- package/dist/runtime/types/miniprogramHostSources.d.mts +2 -3
- package/dist/runtime/types/options.d.mts +5 -53
- package/dist/runtime/types/props/propTypes.d.mts +1 -2
- package/dist/runtime/types/props/router.d.mts +1 -2
- package/dist/runtime/types/props/setup.d.mts +3 -4
- package/dist/runtime/types/runtime.d.mts +3 -4
- package/dist/runtime/types/setData.d.mts +1 -3
- package/dist/runtime/types.d.mts +5 -5
- package/dist/runtime/uniAppHost.d.mts +1 -2
- package/dist/runtime/updatePerformance.d.mts +1 -3
- package/dist/runtime/use.d.mts +1 -3
- package/dist/runtime/vueCompat/context.d.mts +1 -3
- package/dist/runtime/vueCompat/model.d.mts +2 -3
- package/dist/runtime/vueCompat/router.d.mts +1 -2
- package/dist/runtime/vueCompat/templateRef.d.mts +1 -3
- package/dist/scheduler.d.mts +1 -3
- package/dist/store/define.d.mts +1 -3
- package/dist/store/manager.d.mts +1 -3
- package/dist/store/storeToRefs.d.mts +1 -2
- package/dist/store/types.d.mts +3 -4
- package/dist/tt/jsx-runtime.d.mts +0 -2
- package/dist/types/definitions.d.mts +5 -0
- package/dist/types/pageLayout.d.mts +2 -0
- package/dist/types/pageMeta.d.mts +8 -0
- package/dist/types/reactivity.d.mts +11 -0
- package/dist/types.d.mts +5 -0
- package/dist/types.mjs +1 -0
- package/dist/version.d.mts +1 -3
- package/dist/vue-augment.d.mts +1 -3
- package/dist/vue-demi.d.mts +13 -9
- package/dist/vue-types.d.mts +3 -6
- package/dist/weapp/jsx-runtime.d.mts +0 -2
- package/package.json +22 -13
- /package/dist/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/defineProperty.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPrimitive.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPropertyKey.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/typeof.mjs +0 -0
|
@@ -6,12 +6,13 @@ import { receiveNativeDeclaration } from "../runtimeInstance/nativeDeclaration.m
|
|
|
6
6
|
import { receiveNativeSlotParent } from "../runtimeInstance/provideContext.mjs";
|
|
7
7
|
import { enableDeferredSetData, mountRuntimeInstance, refreshRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from "../runtimeInstance.mjs";
|
|
8
8
|
import { ensureInitialNavigation } from "../../navigationLifecycle.mjs";
|
|
9
|
+
import { createStatefulHmrRegistrationContract } from "./hmrRegistration.mjs";
|
|
9
10
|
import { registerNativeComponentDefinition } from "./registerNativeDefinition.mjs";
|
|
10
11
|
import { WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY, WEVU_NATIVE_DECLARATION_METHOD, WEVU_NATIVE_SLOT_PARENT_METHOD, WEVU_PUBLIC_RUNTIME_KEY, WEVU_READY_CALLED_KEY, WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD, WEVU_RUNTIME_KEY } from "@weapp-core/constants";
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
// src/runtime/register/component/registerDefinition.ts
|
|
13
14
|
function registerComponentDefinition(options) {
|
|
14
|
-
const { runtimeApp, watch, setup, restOptions, pageLifecycleHooks, finalObservers, userLifetimes, userPageLifetimes, finalMethods, finalOptions, applyExtraInstanceFields, templateRefs, layoutHosts, attachWevuPropKeys, setupLifecycle, syncWevuPropsFromInstance, directPropsDerivedKeys, isPage, nativeSlotContext, vueLifecycles, getRuntimeOwnerLabel, registerNative = true } = options;
|
|
15
|
+
const { runtimeApp, watch, setup, restOptions, statefulHmrRegistration, pageLifecycleHooks, finalObservers, userLifetimes, userPageLifetimes, finalMethods, finalOptions, applyExtraInstanceFields, templateRefs, layoutHosts, attachWevuPropKeys, setupLifecycle, syncWevuPropsFromInstance, directPropsDerivedKeys, isPage, nativeSlotContext, vueLifecycles, getRuntimeOwnerLabel, registerNative = true } = options;
|
|
15
16
|
const activeTemplateRefs = Array.isArray(templateRefs) && templateRefs.length > 0 ? templateRefs : void 0;
|
|
16
17
|
const pendingAttachment = /* @__PURE__ */ new WeakSet();
|
|
17
18
|
if (activeTemplateRefs) requireRuntimeCapability("templateRefs", "registerComponentDefinition(template refs)");
|
|
@@ -112,9 +113,9 @@ function registerComponentDefinition(options) {
|
|
|
112
113
|
return result.runtime?.proxy;
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
|
-
if (!import.meta.env?.PLATFORM || import.meta.env?.PLATFORM === "weapp") {
|
|
116
|
+
if ((!import.meta.env?.PLATFORM || import.meta.env?.PLATFORM === "weapp") && nativeSlotContext) {
|
|
116
117
|
methods[WEVU_NATIVE_SLOT_PARENT_METHOD] = receiveNativeSlotParent;
|
|
117
|
-
|
|
118
|
+
methods[WEVU_NATIVE_DECLARATION_METHOD] = receiveNativeDeclaration;
|
|
118
119
|
}
|
|
119
120
|
const componentDefinition = {
|
|
120
121
|
...restOptions,
|
|
@@ -302,6 +303,7 @@ function registerComponentDefinition(options) {
|
|
|
302
303
|
if (!registerNative) return componentDefinition;
|
|
303
304
|
const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY];
|
|
304
305
|
if (typeof statefulHmrBridge?.trackWevuComponent === "function") {
|
|
306
|
+
const registrationContract = createStatefulHmrRegistrationContract(statefulHmrBridge, statefulHmrRegistration);
|
|
305
307
|
const definition = statefulHmrBridge.trackWevuComponent(componentDefinition, (instance, stateSnapshot) => {
|
|
306
308
|
refreshRuntimeInstance(instance, runtimeApp, watch, setup, {
|
|
307
309
|
snapshotOmitKeys: directPropsDerivedKeys,
|
|
@@ -314,7 +316,7 @@ function registerComponentDefinition(options) {
|
|
|
314
316
|
enableDeferredSetData(instance, { rehydrateSetupState: true });
|
|
315
317
|
}, (instance) => {
|
|
316
318
|
runTeardownSteps([() => activeLayoutHosts && layoutHooks?.detachHosts(activeLayoutHosts, instance), () => teardownRuntimeInstance(instance, { skipHooks: true })]);
|
|
317
|
-
});
|
|
319
|
+
}, registrationContract);
|
|
318
320
|
if (!statefulHmrBridge.isApplying()) registerNativeComponentDefinition(definition, isPage);
|
|
319
321
|
return definition;
|
|
320
322
|
}
|
|
@@ -322,6 +324,5 @@ function registerComponentDefinition(options) {
|
|
|
322
324
|
return componentDefinition;
|
|
323
325
|
}
|
|
324
326
|
|
|
325
|
-
//#endregion
|
|
326
327
|
export { registerComponentDefinition };
|
|
327
328
|
//# sourceMappingURL=registerDefinition.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerDefinition.mjs","names":[],"sources":["../../../../../src/runtime/register/component/registerDefinition.ts"],"sourcesContent":["import type { LayoutHostBinding, TemplateRefBinding } from '../../capabilities'\nimport type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeApp,\n} from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY,\n WEVU_NATIVE_DECLARATION_METHOD,\n WEVU_NATIVE_SLOT_PARENT_METHOD,\n WEVU_PUBLIC_RUNTIME_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { requireRuntimeCapability, runtimeCapabilityRegistry } from '../../capabilities'\nimport { callHookList } from '../../hooks'\nimport { ensureInitialNavigation } from '../../navigationLifecycle'\nimport { getMiniProgramRuntimeGlobalObject } from '../../platform'\nimport { runTeardownSteps } from '../../teardown'\nimport { enableDeferredSetData, mountRuntimeInstance, refreshRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { receiveNativeDeclaration } from '../runtimeInstance/nativeDeclaration'\nimport { receiveNativeSlotParent } from '../runtimeInstance/provideContext'\nimport { registerNativeComponentDefinition } from './registerNativeDefinition'\n\ntype ImportMetaWithEnv = ImportMeta & { env?: { PLATFORM?: string } }\n\nexport function registerComponentDefinition<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n restOptions: Record<string, any>\n pageLifecycleHooks: Record<string, any>\n finalObservers: Record<string, any>\n userLifetimes: Record<string, any>\n userPageLifetimes: Record<string, any>\n finalMethods: Record<string, (...args: any[]) => any>\n finalOptions: Record<string, any>\n applyExtraInstanceFields: (instance: InternalRuntimeState) => void\n templateRefs: TemplateRefBinding[] | undefined\n layoutHosts: LayoutHostBinding[] | undefined\n attachWevuPropKeys: (instance: InternalRuntimeState) => void\n setupLifecycle: 'created' | 'attached'\n syncWevuPropsFromInstance: (instance: InternalRuntimeState) => void\n syncWevuPropsFromValues: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n directPropsDerivedKeys: string[]\n isPage: boolean\n nativeSlotContext: boolean\n vueLifecycles: Record<string, unknown>\n getRuntimeOwnerLabel: (instance: InternalRuntimeState) => string\n registerNative?: boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n restOptions,\n pageLifecycleHooks,\n finalObservers,\n userLifetimes,\n userPageLifetimes,\n finalMethods,\n finalOptions,\n applyExtraInstanceFields,\n templateRefs,\n layoutHosts,\n attachWevuPropKeys,\n setupLifecycle,\n syncWevuPropsFromInstance,\n directPropsDerivedKeys,\n isPage,\n nativeSlotContext,\n vueLifecycles,\n getRuntimeOwnerLabel,\n registerNative = true,\n } = options\n const activeTemplateRefs = Array.isArray(templateRefs) && templateRefs.length > 0\n ? templateRefs\n : undefined\n const pendingAttachment = new WeakSet<InternalRuntimeState>()\n if (activeTemplateRefs) {\n requireRuntimeCapability('templateRefs', 'registerComponentDefinition(template refs)')\n }\n const activeLayoutHosts = Array.isArray(layoutHosts) && layoutHosts.length > 0\n ? layoutHosts\n : undefined\n const layoutHooks = activeLayoutHosts\n ? requireRuntimeCapability('layout', 'registerComponentDefinition(layout hosts)')\n : undefined\n\n const scheduleTemplateRefs = (instance: InternalRuntimeState, onResolved?: () => void) => {\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.schedule(instance, onResolved)\n return\n }\n onResolved?.()\n }\n\n const resolveRuntime = (instance: InternalRuntimeState) => {\n const directRuntime = (instance as any).__wevu ?? (instance as any)[WEVU_PUBLIC_RUNTIME_KEY]\n if (directRuntime) {\n return directRuntime\n }\n const runtimeState = (instance as any).$state\n if (runtimeState && typeof runtimeState === 'object') {\n return (runtimeState as any)[WEVU_RUNTIME_KEY]\n }\n return undefined\n }\n\n const resolveLifecycleContext = (instance: InternalRuntimeState) => {\n const runtimeProxy = resolveRuntime(instance)?.proxy\n if (runtimeProxy) {\n return runtimeProxy\n }\n return runtimeCapabilityRegistry.scopedSlots?.resolveLifecycleProxy(instance) ?? instance\n }\n\n const mountMissingRuntime = (instance: InternalRuntimeState) => {\n const existing = resolveRuntime(instance)\n if (existing) {\n return { runtime: existing, mounted: false }\n }\n applyExtraInstanceFields(instance)\n attachWevuPropKeys(instance)\n mountRuntimeInstance(instance, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n attached: !pendingAttachment.has(instance),\n })\n syncWevuPropsFromInstance(instance)\n enableDeferredSetData(instance)\n return { runtime: resolveRuntime(instance), mounted: true }\n }\n\n const callVueLifecycle = (instance: InternalRuntimeState, name: string, args: any[]) => {\n const hook = vueLifecycles[name]\n if (typeof hook === 'function') {\n return hook.apply(resolveLifecycleContext(instance), args)\n }\n return undefined\n }\n\n const deferPageUntilNavigation = (instance: InternalRuntimeState, task: () => void) => {\n if (!isPage) {\n task()\n return\n }\n const initialNavigationPromise = ensureInitialNavigation(instance as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n task()\n }\n },\n })\n if (!initialNavigationPromise) {\n task()\n }\n }\n\n const ensureReadyRuntime = (instance: InternalRuntimeState) => {\n if (resolveRuntime(instance) || typeof vueLifecycles.mounted !== 'function') {\n return\n }\n const result = mountMissingRuntime(instance)\n if (result.mounted) {\n callVueLifecycle(instance, 'created', [])\n callVueLifecycle(instance, 'beforeMount', [])\n }\n }\n\n const pageMethodBridges: Record<string, (...args: any[]) => any> = {}\n const attachRuntimeLayoutHosts = (instance: InternalRuntimeState) => {\n if (activeLayoutHosts) {\n layoutHooks?.attachHosts(activeLayoutHosts, instance)\n }\n }\n const attachPageLayoutSetter = (instance: InternalRuntimeState) => {\n if (isPage && layoutHooks) {\n layoutHooks?.attachPageSetter(instance)\n }\n }\n if (isPage) {\n const methodBridgeHookNames = ['onPageScroll', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites']\n for (const hookName of methodBridgeHookNames) {\n const pageHook = (pageLifecycleHooks as any)[hookName]\n if (typeof pageHook !== 'function') {\n continue\n }\n if (typeof (finalMethods as any)[hookName] === 'function') {\n continue\n }\n pageMethodBridges[hookName] = function pageMethodBridge(this: InternalRuntimeState, ...args: any[]) {\n return pageHook.apply(this, args)\n }\n }\n }\n\n const methods: Record<string, (...args: any[]) => any> = {\n ...pageMethodBridges,\n ...finalMethods,\n [WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD]: function resolvePublicInstance(this: InternalRuntimeState) {\n const result = mountMissingRuntime(this)\n if (result.mounted) {\n callVueLifecycle(this, 'created', [])\n callVueLifecycle(this, 'beforeMount', [])\n }\n return result.runtime?.proxy\n },\n }\n if (!(import.meta as ImportMetaWithEnv).env?.PLATFORM || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp') {\n methods[WEVU_NATIVE_SLOT_PARENT_METHOD] = receiveNativeSlotParent\n if (nativeSlotContext) {\n methods[WEVU_NATIVE_DECLARATION_METHOD] = receiveNativeDeclaration\n }\n }\n\n const componentDefinition = {\n ...restOptions,\n ...(isPage ? pageLifecycleHooks : {}),\n observers: finalObservers,\n lifetimes: {\n ...userLifetimes,\n created: function created(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.add(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n const runCreated = () => {\n callVueLifecycle(this, 'beforeCreate', args)\n if (setupLifecycle === 'created') {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in created (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n syncWevuPropsFromInstance(this)\n attachPageLayoutSetter(this)\n }\n if (typeof (userLifetimes as any).created === 'function') {\n ;(userLifetimes as any).created.apply(this, args)\n }\n }\n deferPageUntilNavigation(this, runCreated)\n },\n moved: function moved(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onMoved', args)\n if (typeof (userLifetimes as any).moved === 'function') {\n ;(userLifetimes as any).moved.apply(this, args)\n }\n },\n attached: function attached(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.delete(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs && !runtimeCapabilityRegistry.templateRefs?.hasBindings(this)) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n deferPageUntilNavigation(this, () => {\n if (setupLifecycle !== 'created' || !(this as any).__wevu) {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n attached: true,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in attached (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n syncWevuPropsFromInstance(this)\n callVueLifecycle(this, 'created', args)\n callVueLifecycle(this, 'beforeMount', args)\n attachPageLayoutSetter(this)\n attachRuntimeLayoutHosts(this)\n enableDeferredSetData(this)\n callHookList(this, 'onAttached', args)\n if (typeof (userLifetimes as any).attached === 'function') {\n ;(userLifetimes as any).attached.apply(this, args)\n }\n })\n },\n ready: function ready(this: InternalRuntimeState, ...args: any[]) {\n // 微信可能向初始条件分支中已被替换、从未 attached 的实例发送 ready。\n // 此时保留原生回调,不得将它当作已挂载实例的 wrapper 丢失而补挂载。\n if (pendingAttachment.has(this)) {\n return userLifetimes.ready?.apply(this, args)\n }\n if (isPage && !(this as any)[WEVU_READY_CALLED_KEY]) {\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: true,\n onComplete: (shouldMount) => {\n if (shouldMount && !(this as any).__wevuInitialNavigationReady) {\n ;(this as any).__wevuInitialNavigationReady = true\n componentDefinition.lifetimes.ready.call(this, ...args)\n }\n },\n })\n if (initialNavigationPromise && !(this as any).__wevuInitialNavigationReady) {\n return\n }\n }\n ensureReadyRuntime(this)\n if (isPage && typeof (pageLifecycleHooks as any).onReady === 'function') {\n const wasReadyCalled = Boolean((this as any)[WEVU_READY_CALLED_KEY])\n ;(pageLifecycleHooks as any).onReady.call(this, ...args)\n if (!wasReadyCalled) {\n const callMounted = () => callVueLifecycle(this, 'mounted', args)\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n callMounted()\n }\n },\n })\n if (!initialNavigationPromise) {\n callMounted()\n }\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n return\n }\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n syncWevuPropsFromInstance(this)\n runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this)\n scheduleTemplateRefs(this, () => {\n callHookList(this, 'onReady', args)\n callVueLifecycle(this, 'mounted', args)\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n })\n return\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n },\n detached: function detached(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onUnload === 'function') {\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => (pageLifecycleHooks as any).onUnload.call(this, ...args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n ])\n return\n }\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => {\n if (activeLayoutHosts) {\n layoutHooks?.detachHosts(activeLayoutHosts, this)\n }\n },\n () => teardownRuntimeInstance(this),\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n ])\n },\n error: function error(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onError', args)\n if (typeof (userLifetimes as any).error === 'function') {\n ;(userLifetimes as any).error.apply(this, args)\n }\n },\n },\n pageLifetimes: {\n ...userPageLifetimes,\n show: function show(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onShow === 'function') {\n ;(pageLifecycleHooks as any).onShow.call(this, ...args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, true)\n callHookList(this, 'onShow', args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n },\n hide: function hide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onHide === 'function') {\n ;(pageLifecycleHooks as any).onHide.call(this, ...args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n },\n resize: function resize(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onResize === 'function') {\n ;(pageLifecycleHooks as any).onResize.call(this, ...args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n return\n }\n callHookList(this, 'onResize', args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n },\n routeDone: function routeDone(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onRouteDone === 'function') {\n ;(pageLifecycleHooks as any).onRouteDone.call(this, ...args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n return\n }\n callHookList(this, 'onRouteDone', args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n },\n },\n methods,\n options: finalOptions,\n }\n if (!registerNative) {\n return componentDefinition\n }\n\n const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY]\n if (typeof statefulHmrBridge?.trackWevuComponent === 'function') {\n const definition = statefulHmrBridge.trackWevuComponent(componentDefinition, (\n instance: InternalRuntimeState,\n stateSnapshot?: Record<string, any>,\n ) => {\n refreshRuntimeInstance(instance, runtimeApp, watch, setup, {\n snapshotOmitKeys: directPropsDerivedKeys,\n stateSnapshot,\n attached: !pendingAttachment.has(instance),\n })\n syncWevuPropsFromInstance(instance)\n attachPageLayoutSetter(instance)\n attachRuntimeLayoutHosts(instance)\n enableDeferredSetData(instance, { rehydrateSetupState: true })\n }, (instance: InternalRuntimeState) => {\n // HMR 仅抑制用户卸载钩子;被宿主替换的实例仍须停止响应式任务和原生数据写入。\n runTeardownSteps([\n () => activeLayoutHosts && layoutHooks?.detachHosts(activeLayoutHosts, instance),\n () => teardownRuntimeInstance(instance, { skipHooks: true }),\n ])\n })\n if (!statefulHmrBridge.isApplying()) {\n registerNativeComponentDefinition(definition, isPage)\n }\n return definition\n }\n registerNativeComponentDefinition(componentDefinition, isPage)\n return componentDefinition\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,4BAA0G,SAwBvH;CACD,MAAM,EACJ,YACA,OACA,OACA,aACA,oBACA,gBACA,eACA,mBACA,cACA,cACA,0BACA,cACA,aACA,oBACA,gBACA,2BACA,wBACA,QACA,mBACA,eACA,sBACA,iBAAiB,SACf;CACJ,MAAM,qBAAqB,MAAM,QAAQ,YAAY,KAAK,aAAa,SAAS,IAC5E,eACA;CACJ,MAAM,oCAAoB,IAAI,QAA8B;CAC5D,IAAI,oBACF,yBAAyB,gBAAgB,4CAA4C;CAEvF,MAAM,oBAAoB,MAAM,QAAQ,WAAW,KAAK,YAAY,SAAS,IACzE,cACA;CACJ,MAAM,cAAc,oBAChB,yBAAyB,UAAU,2CAA2C,IAC9E;CAEJ,MAAM,wBAAwB,UAAgC,eAA4B;EACxF,IAAI,oBAAoB;GACtB,0BAA0B,cAAc,SAAS,UAAU,UAAU;GACrE;EACF;EACA,aAAa;CACf;CAEA,MAAM,kBAAkB,aAAmC;EACzD,MAAM,gBAA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;GAE1D;EACF;EACA;EACA,SAAS;CACX;CACA,IAAI,CAAC,gBACH,OAAO;CAGT,MAAM,oBAAoB,kCAAkC,CAAC,GAAG;CAChE,IAAI,OAAO,mBAAmB,uBAAuB,YAAY;EAC/D,MAAM,aAAa,kBAAkB,mBAAmB,sBACtD,UACA,kBACG;GACH,uBAAuB,UAAU,YAAY,OAAO,OAAO;IACzD,kBAAkB;IAClB;IACA,UAAU,CAAC,kBAAkB,IAAI,QAAQ;GAC3C,CAAC;GACD,0BAA0B,QAAQ;GAClC,uBAAuB,QAAQ;GAC/B,yBAAyB,QAAQ;GACjC,sBAAsB,UAAU,EAAE,qBAAqB,KAAK,CAAC;EAC/D,IAAI,aAAmC;GAErC,iBAAiB,OACT,qBAAqB,aAAa,YAAY,mBAAmB,QAAQ,SACzE,wBAAwB,UAAU,EAAE,WAAW,KAAK,CAAC,CAC7D,CAAC;EACH,CAAC;EACD,IAAI,CAAC,kBAAkB,WAAW,GAChC,kCAAkC,YAAY,MAAM;EAEtD,OAAO;CACT;CACA,kCAAkC,qBAAqB,MAAM;CAC7D,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"registerDefinition.mjs","names":[],"sources":["../../../../../src/runtime/register/component/registerDefinition.ts"],"sourcesContent":["import type { LayoutHostBinding, TemplateRefBinding } from '../../capabilities'\nimport type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeApp,\n} from '../../types'\nimport type { WatchMap } from '../watch'\nimport type { StatefulHmrRegistrationInputs } from './hmrRegistration'\nimport {\n WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY,\n WEVU_NATIVE_DECLARATION_METHOD,\n WEVU_NATIVE_SLOT_PARENT_METHOD,\n WEVU_PUBLIC_RUNTIME_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { requireRuntimeCapability, runtimeCapabilityRegistry } from '../../capabilities'\nimport { callHookList } from '../../hooks'\nimport { ensureInitialNavigation } from '../../navigationLifecycle'\nimport { getMiniProgramRuntimeGlobalObject } from '../../platform'\nimport { runTeardownSteps } from '../../teardown'\nimport { enableDeferredSetData, mountRuntimeInstance, refreshRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { receiveNativeDeclaration } from '../runtimeInstance/nativeDeclaration'\nimport { receiveNativeSlotParent } from '../runtimeInstance/provideContext'\nimport { createStatefulHmrRegistrationContract } from './hmrRegistration'\nimport { registerNativeComponentDefinition } from './registerNativeDefinition'\n\ntype ImportMetaWithEnv = ImportMeta & { env?: { PLATFORM?: string } }\n\nexport function registerComponentDefinition<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n restOptions: Record<string, any>\n statefulHmrRegistration: StatefulHmrRegistrationInputs\n pageLifecycleHooks: Record<string, any>\n finalObservers: Record<string, any>\n userLifetimes: Record<string, any>\n userPageLifetimes: Record<string, any>\n finalMethods: Record<string, (...args: any[]) => any>\n finalOptions: Record<string, any>\n applyExtraInstanceFields: (instance: InternalRuntimeState) => void\n templateRefs: TemplateRefBinding[] | undefined\n layoutHosts: LayoutHostBinding[] | undefined\n attachWevuPropKeys: (instance: InternalRuntimeState) => void\n setupLifecycle: 'created' | 'attached'\n syncWevuPropsFromInstance: (instance: InternalRuntimeState) => void\n syncWevuPropsFromValues: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n directPropsDerivedKeys: string[]\n isPage: boolean\n nativeSlotContext: boolean\n vueLifecycles: Record<string, unknown>\n getRuntimeOwnerLabel: (instance: InternalRuntimeState) => string\n registerNative?: boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n restOptions,\n statefulHmrRegistration,\n pageLifecycleHooks,\n finalObservers,\n userLifetimes,\n userPageLifetimes,\n finalMethods,\n finalOptions,\n applyExtraInstanceFields,\n templateRefs,\n layoutHosts,\n attachWevuPropKeys,\n setupLifecycle,\n syncWevuPropsFromInstance,\n directPropsDerivedKeys,\n isPage,\n nativeSlotContext,\n vueLifecycles,\n getRuntimeOwnerLabel,\n registerNative = true,\n } = options\n const activeTemplateRefs = Array.isArray(templateRefs) && templateRefs.length > 0\n ? templateRefs\n : undefined\n const pendingAttachment = new WeakSet<InternalRuntimeState>()\n if (activeTemplateRefs) {\n requireRuntimeCapability('templateRefs', 'registerComponentDefinition(template refs)')\n }\n const activeLayoutHosts = Array.isArray(layoutHosts) && layoutHosts.length > 0\n ? layoutHosts\n : undefined\n const layoutHooks = activeLayoutHosts\n ? requireRuntimeCapability('layout', 'registerComponentDefinition(layout hosts)')\n : undefined\n\n const scheduleTemplateRefs = (instance: InternalRuntimeState, onResolved?: () => void) => {\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.schedule(instance, onResolved)\n return\n }\n onResolved?.()\n }\n\n const resolveRuntime = (instance: InternalRuntimeState) => {\n const directRuntime = (instance as any).__wevu ?? (instance as any)[WEVU_PUBLIC_RUNTIME_KEY]\n if (directRuntime) {\n return directRuntime\n }\n const runtimeState = (instance as any).$state\n if (runtimeState && typeof runtimeState === 'object') {\n return (runtimeState as any)[WEVU_RUNTIME_KEY]\n }\n return undefined\n }\n\n const resolveLifecycleContext = (instance: InternalRuntimeState) => {\n const runtimeProxy = resolveRuntime(instance)?.proxy\n if (runtimeProxy) {\n return runtimeProxy\n }\n return runtimeCapabilityRegistry.scopedSlots?.resolveLifecycleProxy(instance) ?? instance\n }\n\n const mountMissingRuntime = (instance: InternalRuntimeState) => {\n const existing = resolveRuntime(instance)\n if (existing) {\n return { runtime: existing, mounted: false }\n }\n applyExtraInstanceFields(instance)\n attachWevuPropKeys(instance)\n mountRuntimeInstance(instance, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n attached: !pendingAttachment.has(instance),\n })\n syncWevuPropsFromInstance(instance)\n enableDeferredSetData(instance)\n return { runtime: resolveRuntime(instance), mounted: true }\n }\n\n const callVueLifecycle = (instance: InternalRuntimeState, name: string, args: any[]) => {\n const hook = vueLifecycles[name]\n if (typeof hook === 'function') {\n return hook.apply(resolveLifecycleContext(instance), args)\n }\n return undefined\n }\n\n const deferPageUntilNavigation = (instance: InternalRuntimeState, task: () => void) => {\n if (!isPage) {\n task()\n return\n }\n const initialNavigationPromise = ensureInitialNavigation(instance as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n task()\n }\n },\n })\n if (!initialNavigationPromise) {\n task()\n }\n }\n\n const ensureReadyRuntime = (instance: InternalRuntimeState) => {\n if (resolveRuntime(instance) || typeof vueLifecycles.mounted !== 'function') {\n return\n }\n const result = mountMissingRuntime(instance)\n if (result.mounted) {\n callVueLifecycle(instance, 'created', [])\n callVueLifecycle(instance, 'beforeMount', [])\n }\n }\n\n const pageMethodBridges: Record<string, (...args: any[]) => any> = {}\n const attachRuntimeLayoutHosts = (instance: InternalRuntimeState) => {\n if (activeLayoutHosts) {\n layoutHooks?.attachHosts(activeLayoutHosts, instance)\n }\n }\n const attachPageLayoutSetter = (instance: InternalRuntimeState) => {\n if (isPage && layoutHooks) {\n layoutHooks?.attachPageSetter(instance)\n }\n }\n if (isPage) {\n const methodBridgeHookNames = ['onPageScroll', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites']\n for (const hookName of methodBridgeHookNames) {\n const pageHook = (pageLifecycleHooks as any)[hookName]\n if (typeof pageHook !== 'function') {\n continue\n }\n if (typeof (finalMethods as any)[hookName] === 'function') {\n continue\n }\n pageMethodBridges[hookName] = function pageMethodBridge(this: InternalRuntimeState, ...args: any[]) {\n return pageHook.apply(this, args)\n }\n }\n }\n\n const methods: Record<string, (...args: any[]) => any> = {\n ...pageMethodBridges,\n ...finalMethods,\n [WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD]: function resolvePublicInstance(this: InternalRuntimeState) {\n const result = mountMissingRuntime(this)\n if (result.mounted) {\n callVueLifecycle(this, 'created', [])\n callVueLifecycle(this, 'beforeMount', [])\n }\n return result.runtime?.proxy\n },\n }\n if (\n (!(import.meta as ImportMetaWithEnv).env?.PLATFORM || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp')\n && nativeSlotContext\n ) {\n methods[WEVU_NATIVE_SLOT_PARENT_METHOD] = receiveNativeSlotParent\n methods[WEVU_NATIVE_DECLARATION_METHOD] = receiveNativeDeclaration\n }\n\n const componentDefinition = {\n ...restOptions,\n ...(isPage ? pageLifecycleHooks : {}),\n observers: finalObservers,\n lifetimes: {\n ...userLifetimes,\n created: function created(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.add(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n const runCreated = () => {\n callVueLifecycle(this, 'beforeCreate', args)\n if (setupLifecycle === 'created') {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in created (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n syncWevuPropsFromInstance(this)\n attachPageLayoutSetter(this)\n }\n if (typeof (userLifetimes as any).created === 'function') {\n ;(userLifetimes as any).created.apply(this, args)\n }\n }\n deferPageUntilNavigation(this, runCreated)\n },\n moved: function moved(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onMoved', args)\n if (typeof (userLifetimes as any).moved === 'function') {\n ;(userLifetimes as any).moved.apply(this, args)\n }\n },\n attached: function attached(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.delete(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs && !runtimeCapabilityRegistry.templateRefs?.hasBindings(this)) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n deferPageUntilNavigation(this, () => {\n if (setupLifecycle !== 'created' || !(this as any).__wevu) {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n attached: true,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in attached (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n syncWevuPropsFromInstance(this)\n callVueLifecycle(this, 'created', args)\n callVueLifecycle(this, 'beforeMount', args)\n attachPageLayoutSetter(this)\n attachRuntimeLayoutHosts(this)\n enableDeferredSetData(this)\n callHookList(this, 'onAttached', args)\n if (typeof (userLifetimes as any).attached === 'function') {\n ;(userLifetimes as any).attached.apply(this, args)\n }\n })\n },\n ready: function ready(this: InternalRuntimeState, ...args: any[]) {\n // 微信可能向初始条件分支中已被替换、从未 attached 的实例发送 ready。\n // 此时保留原生回调,不得将它当作已挂载实例的 wrapper 丢失而补挂载。\n if (pendingAttachment.has(this)) {\n return userLifetimes.ready?.apply(this, args)\n }\n if (isPage && !(this as any)[WEVU_READY_CALLED_KEY]) {\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: true,\n onComplete: (shouldMount) => {\n if (shouldMount && !(this as any).__wevuInitialNavigationReady) {\n ;(this as any).__wevuInitialNavigationReady = true\n componentDefinition.lifetimes.ready.call(this, ...args)\n }\n },\n })\n if (initialNavigationPromise && !(this as any).__wevuInitialNavigationReady) {\n return\n }\n }\n ensureReadyRuntime(this)\n if (isPage && typeof (pageLifecycleHooks as any).onReady === 'function') {\n const wasReadyCalled = Boolean((this as any)[WEVU_READY_CALLED_KEY])\n ;(pageLifecycleHooks as any).onReady.call(this, ...args)\n if (!wasReadyCalled) {\n const callMounted = () => callVueLifecycle(this, 'mounted', args)\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n callMounted()\n }\n },\n })\n if (!initialNavigationPromise) {\n callMounted()\n }\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n return\n }\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n syncWevuPropsFromInstance(this)\n runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this)\n scheduleTemplateRefs(this, () => {\n callHookList(this, 'onReady', args)\n callVueLifecycle(this, 'mounted', args)\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n })\n return\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n },\n detached: function detached(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onUnload === 'function') {\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => (pageLifecycleHooks as any).onUnload.call(this, ...args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n ])\n return\n }\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => {\n if (activeLayoutHosts) {\n layoutHooks?.detachHosts(activeLayoutHosts, this)\n }\n },\n () => teardownRuntimeInstance(this),\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n ])\n },\n error: function error(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onError', args)\n if (typeof (userLifetimes as any).error === 'function') {\n ;(userLifetimes as any).error.apply(this, args)\n }\n },\n },\n pageLifetimes: {\n ...userPageLifetimes,\n show: function show(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onShow === 'function') {\n ;(pageLifecycleHooks as any).onShow.call(this, ...args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, true)\n callHookList(this, 'onShow', args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n },\n hide: function hide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onHide === 'function') {\n ;(pageLifecycleHooks as any).onHide.call(this, ...args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n },\n resize: function resize(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onResize === 'function') {\n ;(pageLifecycleHooks as any).onResize.call(this, ...args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n return\n }\n callHookList(this, 'onResize', args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n },\n routeDone: function routeDone(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onRouteDone === 'function') {\n ;(pageLifecycleHooks as any).onRouteDone.call(this, ...args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n return\n }\n callHookList(this, 'onRouteDone', args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n },\n },\n methods,\n options: finalOptions,\n }\n if (!registerNative) {\n return componentDefinition\n }\n\n const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY]\n if (typeof statefulHmrBridge?.trackWevuComponent === 'function') {\n const registrationContract = createStatefulHmrRegistrationContract(statefulHmrBridge, statefulHmrRegistration)\n const definition = statefulHmrBridge.trackWevuComponent(componentDefinition, (\n instance: InternalRuntimeState,\n stateSnapshot?: Record<string, any>,\n ) => {\n refreshRuntimeInstance(instance, runtimeApp, watch, setup, {\n snapshotOmitKeys: directPropsDerivedKeys,\n stateSnapshot,\n attached: !pendingAttachment.has(instance),\n })\n syncWevuPropsFromInstance(instance)\n attachPageLayoutSetter(instance)\n attachRuntimeLayoutHosts(instance)\n enableDeferredSetData(instance, { rehydrateSetupState: true })\n }, (instance: InternalRuntimeState) => {\n // HMR 仅抑制用户卸载钩子;被宿主替换的实例仍须停止响应式任务和原生数据写入。\n runTeardownSteps([\n () => activeLayoutHosts && layoutHooks?.detachHosts(activeLayoutHosts, instance),\n () => teardownRuntimeInstance(instance, { skipHooks: true }),\n ])\n }, registrationContract)\n if (!statefulHmrBridge.isApplying()) {\n registerNativeComponentDefinition(definition, isPage)\n }\n return definition\n }\n registerNativeComponentDefinition(componentDefinition, isPage)\n return componentDefinition\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,SAAgB,4BAA0G,SAyBvH;CACD,MAAM,EACJ,YACA,OACA,OACA,aACA,yBACA,oBACA,gBACA,eACA,mBACA,cACA,cACA,0BACA,cACA,aACA,oBACA,gBACA,2BACA,wBACA,QACA,mBACA,eACA,sBACA,iBAA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} from "../../platform.mjs";
|
|
|
3
3
|
import { registerAlipayComponentDefinition } from "./alipayRegistration.mjs";
|
|
4
4
|
import { WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY } from "@weapp-core/constants";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/runtime/register/component/registerNativeDefinition.ts
|
|
7
7
|
function registerWechatCompatibleComponentDefinition(componentDefinition) {
|
|
8
8
|
const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY];
|
|
9
9
|
if (typeof statefulHmrBridge?.Component === "function") {
|
|
@@ -25,6 +25,5 @@ function registerDetectedComponentDefinition(componentDefinition, isPage) {
|
|
|
25
25
|
*/
|
|
26
26
|
const registerNativeComponentDefinition = import.meta.env?.PLATFORM === "alipay" ? registerAlipayComponentDefinition : import.meta.env?.PLATFORM === "weapp" || import.meta.env?.PLATFORM === "tt" || import.meta.env?.PLATFORM === "swan" || import.meta.env?.PLATFORM === "jd" || import.meta.env?.PLATFORM === "xhs" || import.meta.env?.PLATFORM === "web" ? registerWechatCompatibleComponentDefinition : registerDetectedComponentDefinition;
|
|
27
27
|
|
|
28
|
-
//#endregion
|
|
29
28
|
export { registerNativeComponentDefinition };
|
|
30
29
|
//# sourceMappingURL=registerNativeDefinition.mjs.map
|
|
@@ -6,7 +6,7 @@ import { createPropsSync } from "./component/props.mjs";
|
|
|
6
6
|
import { registerComponentDefinition } from "./component/registerDefinition.mjs";
|
|
7
7
|
import { WEVU_EXPOSED_KEY, WEVU_HOOKS_KEY, WEVU_NATIVE_SLOT_CONTEXT_KEY } from "@weapp-core/constants";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/runtime/register/component.ts
|
|
10
10
|
/**
|
|
11
11
|
* 注册组件入口(框架内部使用)。
|
|
12
12
|
* @internal
|
|
@@ -34,24 +34,24 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions, options
|
|
|
34
34
|
if (Array.isArray(entry)) return entry.length > 0;
|
|
35
35
|
return typeof entry === "function";
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
...base
|
|
45
|
-
};
|
|
46
|
-
return base ?? exposed;
|
|
37
|
+
const userExport = restOptions.export;
|
|
38
|
+
restOptions.export = function __wevu_export() {
|
|
39
|
+
const exposed = this[WEVU_EXPOSED_KEY] ?? {};
|
|
40
|
+
const base = typeof userExport === "function" ? userExport.call(this) : {};
|
|
41
|
+
if (base && typeof base === "object" && !Array.isArray(base)) return {
|
|
42
|
+
...exposed,
|
|
43
|
+
...base
|
|
47
44
|
};
|
|
48
|
-
|
|
45
|
+
return base ?? exposed;
|
|
46
|
+
};
|
|
49
47
|
const finalOptions = {
|
|
50
48
|
multipleSlots: userOptions.multipleSlots ?? true,
|
|
51
49
|
...userOptions
|
|
52
50
|
};
|
|
51
|
+
const nativeSlotContext = (!import.meta.env?.PLATFORM || import.meta.env?.PLATFORM === "weapp") && mpOptions[WEVU_NATIVE_SLOT_CONTEXT_KEY] === true;
|
|
53
52
|
const { attachWevuPropKeys, directPropsDerivedKeys, syncWevuPropsFromInstance, syncWevuPropsFromValues, finalObservers } = createPropsSync({
|
|
54
53
|
restOptions,
|
|
54
|
+
nativeSlotContext,
|
|
55
55
|
propsAliases,
|
|
56
56
|
propsDerivedKeys,
|
|
57
57
|
userObservers
|
|
@@ -102,6 +102,16 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions, options
|
|
|
102
102
|
watch,
|
|
103
103
|
setup,
|
|
104
104
|
restOptions,
|
|
105
|
+
statefulHmrRegistration: {
|
|
106
|
+
userObservers,
|
|
107
|
+
userExport,
|
|
108
|
+
propsAliases,
|
|
109
|
+
propsDerivedKeys,
|
|
110
|
+
templateRefs,
|
|
111
|
+
layoutHosts,
|
|
112
|
+
setupLifecycle,
|
|
113
|
+
nativeSlotContext
|
|
114
|
+
},
|
|
105
115
|
pageLifecycleHooks,
|
|
106
116
|
finalObservers,
|
|
107
117
|
userLifetimes,
|
|
@@ -116,7 +126,7 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions, options
|
|
|
116
126
|
syncWevuPropsFromInstance,
|
|
117
127
|
syncWevuPropsFromValues,
|
|
118
128
|
directPropsDerivedKeys,
|
|
119
|
-
nativeSlotContext
|
|
129
|
+
nativeSlotContext,
|
|
120
130
|
isPage,
|
|
121
131
|
vueLifecycles,
|
|
122
132
|
getRuntimeOwnerLabel,
|
|
@@ -124,6 +134,5 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions, options
|
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
//#endregion
|
|
128
137
|
export { registerComponent };
|
|
129
138
|
//# sourceMappingURL=component.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.mjs","names":[],"sources":["../../../../src/runtime/register/component.ts"],"sourcesContent":["import type { ComponentPropsOptions, ComputedDefinitions, DefineComponentOptions, InternalRuntimeState, MethodDefinitions, MiniProgramComponentRawOptions, RuntimeApp } from '../types'\nimport type { WatchMap } from './watch'\nimport { WEVU_EXPOSED_KEY, WEVU_HOOKS_KEY, WEVU_NATIVE_SLOT_CONTEXT_KEY } from '@weapp-core/constants'\nimport { resolveComponentFeatures } from './component/features'\nimport { createPageLifecycleHooks } from './component/lifecycle'\nimport { createComponentMethods } from './component/methods'\nimport { getRuntimeOwnerLabel, prepareComponentOptions } from './component/options'\nimport { createPropsSync } from './component/props'\nimport { registerComponentDefinition } from './component/registerDefinition'\n\ntype ImportMetaWithEnv = ImportMeta & { env?: { PLATFORM?: string } }\n\n/**\n * 注册组件入口(框架内部使用)。\n * @internal\n */\nexport function registerComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(\n runtimeApp: RuntimeApp<D, C, M>,\n methods: MethodDefinitions,\n watch: WatchMap | undefined,\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'],\n mpOptions: MiniProgramComponentRawOptions,\n options: { registerNative?: boolean } = {},\n) {\n const {\n userMethods,\n userLifetimes,\n userPageLifetimes,\n userOptions,\n restOptions,\n topLevelMethods,\n templateRefs,\n layoutHosts,\n propsAliases,\n propsDerivedKeys,\n userObservers,\n setupLifecycle,\n vueLifecycles,\n isPage,\n features,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n userOnSaveExitState,\n userOnPullDownRefresh,\n userOnReachBottom,\n userOnPageScroll,\n userOnRouteDone,\n userOnTabItemTap,\n userOnResize,\n userOnShareAppMessage,\n userOnShareTimeline,\n userOnAddToFavorites,\n applyExtraInstanceFields,\n } = prepareComponentOptions(mpOptions)\n\n const {\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n enableOnSaveExitState,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n } = resolveComponentFeatures({\n features,\n userOnSaveExitState,\n userOnPullDownRefresh,\n userOnReachBottom,\n userOnPageScroll,\n userOnRouteDone,\n userOnTabItemTap,\n userOnResize,\n userOnShareAppMessage,\n userOnShareTimeline,\n userOnAddToFavorites,\n })\n\n const hasHook = (target: InternalRuntimeState, name: string) => {\n const hooks = target[WEVU_HOOKS_KEY]\n if (!hooks) {\n return false\n }\n const entry = (hooks as any)[name]\n if (!entry) {\n return false\n }\n if (Array.isArray(entry)) {\n return entry.length > 0\n }\n return typeof entry === 'function'\n }\n\n // 自动对齐 Vue 3 的 expose:\n // - 若用户未提供 component-export 的 export(),默认返回 setup() 中 expose() 写入的 __wevuExposed\n // - 若用户同时提供 export() 与 expose(),则自动浅合并(export() 优先级更高)\n
|
|
1
|
+
{"version":3,"file":"component.mjs","names":[],"sources":["../../../../src/runtime/register/component.ts"],"sourcesContent":["import type { ComponentPropsOptions, ComputedDefinitions, DefineComponentOptions, InternalRuntimeState, MethodDefinitions, MiniProgramComponentRawOptions, RuntimeApp } from '../types'\nimport type { WatchMap } from './watch'\nimport { WEVU_EXPOSED_KEY, WEVU_HOOKS_KEY, WEVU_NATIVE_SLOT_CONTEXT_KEY } from '@weapp-core/constants'\nimport { resolveComponentFeatures } from './component/features'\nimport { createPageLifecycleHooks } from './component/lifecycle'\nimport { createComponentMethods } from './component/methods'\nimport { getRuntimeOwnerLabel, prepareComponentOptions } from './component/options'\nimport { createPropsSync } from './component/props'\nimport { registerComponentDefinition } from './component/registerDefinition'\n\ntype ImportMetaWithEnv = ImportMeta & { env?: { PLATFORM?: string } }\n\n/**\n * 注册组件入口(框架内部使用)。\n * @internal\n */\nexport function registerComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(\n runtimeApp: RuntimeApp<D, C, M>,\n methods: MethodDefinitions,\n watch: WatchMap | undefined,\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'],\n mpOptions: MiniProgramComponentRawOptions,\n options: { registerNative?: boolean } = {},\n) {\n const {\n userMethods,\n userLifetimes,\n userPageLifetimes,\n userOptions,\n restOptions,\n topLevelMethods,\n templateRefs,\n layoutHosts,\n propsAliases,\n propsDerivedKeys,\n userObservers,\n setupLifecycle,\n vueLifecycles,\n isPage,\n features,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n userOnSaveExitState,\n userOnPullDownRefresh,\n userOnReachBottom,\n userOnPageScroll,\n userOnRouteDone,\n userOnTabItemTap,\n userOnResize,\n userOnShareAppMessage,\n userOnShareTimeline,\n userOnAddToFavorites,\n applyExtraInstanceFields,\n } = prepareComponentOptions(mpOptions)\n\n const {\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n enableOnSaveExitState,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n } = resolveComponentFeatures({\n features,\n userOnSaveExitState,\n userOnPullDownRefresh,\n userOnReachBottom,\n userOnPageScroll,\n userOnRouteDone,\n userOnTabItemTap,\n userOnResize,\n userOnShareAppMessage,\n userOnShareTimeline,\n userOnAddToFavorites,\n })\n\n const hasHook = (target: InternalRuntimeState, name: string) => {\n const hooks = target[WEVU_HOOKS_KEY]\n if (!hooks) {\n return false\n }\n const entry = (hooks as any)[name]\n if (!entry) {\n return false\n }\n if (Array.isArray(entry)) {\n return entry.length > 0\n }\n return typeof entry === 'function'\n }\n\n // 自动对齐 Vue 3 的 expose:\n // - 若用户未提供 component-export 的 export(),默认返回 setup() 中 expose() 写入的 __wevuExposed\n // - 若用户同时提供 export() 与 expose(),则自动浅合并(export() 优先级更高)\n const userExport = (restOptions as any).export\n ;(restOptions as any).export = function __wevu_export(this: InternalRuntimeState) {\n const exposed = (this as any)[WEVU_EXPOSED_KEY] ?? {}\n const base = typeof userExport === 'function' ? userExport.call(this) : {}\n\n if (base && typeof base === 'object' && !Array.isArray(base)) {\n return {\n ...exposed,\n ...base,\n }\n }\n\n // 若用户 export() 返回非对象(理论上不应发生),则保持原返回值;否则回退 exposed\n return base ?? exposed\n }\n\n // 默认启用多 slot 以兼容微信小程序具名插槽写法;用户显式配置时保持原值\n const finalOptions = {\n multipleSlots: (userOptions as any).multipleSlots ?? true,\n ...(userOptions as any),\n }\n\n const nativeSlotContext = (!(import.meta as ImportMetaWithEnv).env?.PLATFORM || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp')\n && (mpOptions as Record<string, unknown>)[WEVU_NATIVE_SLOT_CONTEXT_KEY] === true\n const { attachWevuPropKeys, directPropsDerivedKeys, syncWevuPropsFromInstance, syncWevuPropsFromValues, finalObservers } = createPropsSync({\n restOptions,\n nativeSlotContext,\n propsAliases,\n propsDerivedKeys,\n userObservers,\n })\n\n const { finalMethods } = createComponentMethods({\n userMethods: {\n ...topLevelMethods,\n ...userMethods,\n },\n runtimeMethods: methods,\n })\n\n const pageLifecycleHooks = createPageLifecycleHooks({\n runtimeApp,\n watch,\n setup,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n isPage,\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n syncWevuPropsFromValues,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n })\n\n return registerComponentDefinition({\n runtimeApp,\n watch,\n setup,\n restOptions,\n statefulHmrRegistration: {\n userObservers,\n userExport,\n propsAliases,\n propsDerivedKeys,\n templateRefs,\n layoutHosts,\n setupLifecycle,\n nativeSlotContext,\n },\n pageLifecycleHooks,\n finalObservers,\n userLifetimes,\n userPageLifetimes,\n finalMethods,\n finalOptions,\n applyExtraInstanceFields,\n templateRefs,\n layoutHosts,\n attachWevuPropKeys,\n setupLifecycle,\n syncWevuPropsFromInstance,\n syncWevuPropsFromValues,\n directPropsDerivedKeys,\n nativeSlotContext,\n isPage,\n vueLifecycles,\n getRuntimeOwnerLabel,\n registerNative: options.registerNative,\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,kBACd,YACA,SACA,OACA,OACA,WACA,UAAwC,CAAC,GACzC;CACA,MAAM,EACJ,aACA,eACA,mBACA,aACA,aACA,iBACA,cACA,aACA,cACA,kBACA,eACA,gBACA,eACA,QACA,UACA,YACA,cACA,YACA,YACA,aACA,qBACA,uBACA,mBACA,kBACA,iBACA,kBACA,cACA,uBACA,qBACA,sBACA,6BACE,wBAAwB,SAAS;CAErC,MAAM,EACJ,yBACA,qBACA,oBACA,mBACA,2BACA,oBACA,gBACA,yBACA,uBACA,wBACA,uBACA,0BACA,4BACA,wBACA,uBACA,sBACA,uBACA,mBACA,4BACA,0BACA,8BACE,yBAAyB;EAC3B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,WAAW,QAA8B,SAAiB;EAC9D,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,OACH,OAAO;EAET,MAAM,QAAS,MAAc;EAC7B,IAAI,CAAC,OACH,OAAO;EAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,SAAS;EAExB,OAAO,OAAO,UAAU;CAC1B;CAKA,MAAM,aAAc,YAAoB;CACvC,AAAC,YAAoB,SAAS,SAAS,gBAA0C;EAChF,MAAM,UAAW,KAAa,qBAAqB,CAAC;EACpD,MAAM,OAAO,OAAO,eAAe,aAAa,WAAW,KAAK,IAAI,IAAI,CAAC;EAEzE,IAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GACzD,OAAO;GACL,GAAG;GACH,GAAG;EACL;EAIF,OAAO,QAAQ;CACjB;CAGA,MAAM,eAAe;EACnB,eAAgB,YAAoB,iBAAiB;EACrD,GAAI;CACN;CAEA,MAAM,qBAAqB,CAAE,YAAkC,KAAK,YAAa,YAAkC,KAAK,aAAa,YAC/H,UAAsC,kCAAkC;CAC9E,MAAM,EAAE,oBAAoB,wBAAwB,2BAA2B,yBAAyB,mBAAmB,gBAAgB;EACzI;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,EAAE,iBAAiB,uBAAuB;EAC9C,aAAa;GACX,GAAG;GACH,GAAG;EACL;EACA,gBAAgB;CAClB,CAAC;CAED,MAAM,qBAAqB,yBAAyB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO,4BAA4B;EACjC;EACA;EACA;EACA;EACA,yBAAyB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB,QAAQ;CAC1B,CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isRef } from "../../reactivity/ref.mjs";
|
|
2
2
|
import { decodeWxmlEntities, resolveDatasetEventValue, resolveDatasetIndex } from "../inlineDataset.mjs";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/runtime/register/inline.ts
|
|
5
5
|
function shouldUseDetailPayload(dataset, event) {
|
|
6
6
|
const flag = resolveDatasetEventValue(dataset, "wvEventDetail", event);
|
|
7
7
|
return flag === true || flag === 1 || flag === "1" || flag === "true";
|
|
@@ -85,6 +85,5 @@ function runInlineExpression(ctx, expr, event, inlineMap) {
|
|
|
85
85
|
if (typeof handler === "function") return handler.apply(ctx, resolvedArgs);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
//#endregion
|
|
89
88
|
export { runInlineExpression };
|
|
90
89
|
//# sourceMappingURL=inline.mjs.map
|
|
@@ -2,7 +2,7 @@ import { isNativeBridgeMethod } from "../../nativeBridge.mjs";
|
|
|
2
2
|
import { setupInstanceMethodNames } from "./setupContext.mjs";
|
|
3
3
|
import { WEVU_HOST_INSTALL_METHOD_KEY, WEVU_NATIVE_INSTANCE_KEY, WEVU_PUBLIC_RUNTIME_KEY } from "@weapp-core/constants";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/runtime/register/runtimeInstance/methodBridge.ts
|
|
6
6
|
function hasNativeApis(instance) {
|
|
7
7
|
if (!instance || typeof instance !== "object") return false;
|
|
8
8
|
return typeof instance.triggerEvent === "function" || typeof instance.createSelectorQuery === "function" || typeof instance.createIntersectionObserver === "function" || typeof instance.setData === "function";
|
|
@@ -54,6 +54,5 @@ function bridgeRuntimeMethodsToTarget(target, runtime) {
|
|
|
54
54
|
} catch {}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
//#endregion
|
|
58
57
|
export { bridgeRuntimeMethodsToTarget };
|
|
59
58
|
//# sourceMappingURL=methodBridge.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WEVU_NATIVE_DECLARATION_ADDRESS_PROP, WEVU_NATIVE_DECLARATION_EVENT } from "@weapp-core/constants";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/runtime/register/runtimeInstance/nativeDeclaration.ts
|
|
4
4
|
const addressKey = /* @__PURE__ */ Symbol("address");
|
|
5
5
|
const registrationKey = /* @__PURE__ */ Symbol("registration");
|
|
6
6
|
const indexKey = /* @__PURE__ */ Symbol("index");
|
|
@@ -73,6 +73,5 @@ function releaseNativeDeclaration(target, preserveOwnerIndex = false) {
|
|
|
73
73
|
delete target[addressKey];
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
//#endregion
|
|
77
76
|
export { receiveNativeDeclaration, releaseNativeDeclaration, resolveNativeDeclarationHost, resolveNativeDeclarationParent, updateNativeDeclarationAddress };
|
|
78
77
|
//# sourceMappingURL=nativeDeclaration.mjs.map
|
|
@@ -4,7 +4,7 @@ import { isRuntimeLayoutComponentTarget } from "../../layoutComponentMatcher.mjs
|
|
|
4
4
|
import { resolveNativeDeclarationHost, resolveNativeDeclarationParent } from "./nativeDeclaration.mjs";
|
|
5
5
|
import { WEVU_NATIVE_SLOT_CONTEXT_KEY, WEVU_NATIVE_SLOT_PARENT_DATASET_KEY, WEVU_NATIVE_SLOT_PARENT_EVENT, WEVU_PARENT_INSTANCE_KEY, WEVU_PROVIDES_KEY, WEVU_RUNTIME_APP_KEY } from "@weapp-core/constants";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/runtime/register/runtimeInstance/provideContext.ts
|
|
8
8
|
function isLiveProvideHost(target) {
|
|
9
9
|
return Boolean(target && typeof target === "object" && target.__wevu && target[WEVU_PROVIDES_KEY]);
|
|
10
10
|
}
|
|
@@ -73,6 +73,5 @@ function attachRuntimeProvideParentContext(target, runtimeApp, attached = false,
|
|
|
73
73
|
attachRuntimeLayoutParentContext(target);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
//#endregion
|
|
77
76
|
export { attachRuntimeProvideParentContext, receiveNativeSlotParent };
|
|
78
77
|
//# sourceMappingURL=provideContext.mjs.map
|
|
@@ -7,7 +7,7 @@ import { normalizeEmitPayload } from "../../emit.mjs";
|
|
|
7
7
|
import { isNativeBridgeMethod, markNativeBridgeMethod } from "../../nativeBridge.mjs";
|
|
8
8
|
import { WEVU_NATIVE_INSTANCE_KEY, WEVU_PROPS_KEY, WEVU_SETUP_CONTEXT_INSTANCE_KEY, WEVU_SLOT_NAMES_PROP } from "@weapp-core/constants";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/runtime/register/runtimeInstance/setupContext.ts
|
|
11
11
|
const setupInstanceMethodNames = [
|
|
12
12
|
"triggerEvent",
|
|
13
13
|
"createSelectorQuery",
|
|
@@ -232,6 +232,5 @@ function ensureSetupContextInstance(target, runtime) {
|
|
|
232
232
|
return setupInstance;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
//#endregion
|
|
236
235
|
export { attachRuntimeSlots, createNoopWatchStopHandle, createSetupSlotsFallback, createSetupSlotsProxy, ensureSetupContextInstance, normalizeEmitPayload, safeMarkNoSetData, setupInstanceMethodNames };
|
|
237
236
|
//# sourceMappingURL=setupContext.mjs.map
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { effectScope } from "../../../reactivity/core.mjs";
|
|
2
|
-
import { toRaw } from "../../../reactivity/reactive/shared.mjs";
|
|
3
2
|
import { shallowReactive } from "../../../reactivity/reactive/shallow.mjs";
|
|
4
|
-
import { isReactive } from "../../../reactivity/reactive.mjs";
|
|
5
3
|
import { getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from "../../hooks/base.mjs";
|
|
6
4
|
import { hasOwn } from "../../../utils.mjs";
|
|
7
|
-
import { hasTrackableSetupBinding } from "../../setupTracking.mjs";
|
|
8
5
|
import { normalizeEmitEventName, normalizeEmitPayload } from "../../emit.mjs";
|
|
9
6
|
import { attachRuntimeSlots, ensureSetupContextInstance, safeMarkNoSetData } from "./setupContext.mjs";
|
|
10
|
-
import {
|
|
7
|
+
import { applySetupResult } from "../../define/setupResult.mjs";
|
|
11
8
|
import { runSetupFunction } from "../setup.mjs";
|
|
12
9
|
import { attachRuntimeSetupState, ensureRuntimeProps } from "./utils.mjs";
|
|
13
10
|
import { WEVU_ATTRS_KEY, WEVU_EFFECT_SCOPE_KEY, WEVU_EXPOSED_KEY, WEVU_PROP_KEYS_KEY } from "@weapp-core/constants";
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
// src/runtime/register/runtimeInstance/setupPhase.ts
|
|
16
13
|
let vueCompatInstanceUid = 0;
|
|
17
14
|
function attachVueCompatInstanceView(target, proxy) {
|
|
18
15
|
let exposedView;
|
|
@@ -140,32 +137,11 @@ function runRuntimeSetupPhase(options) {
|
|
|
140
137
|
setCurrentSetupContext(context);
|
|
141
138
|
try {
|
|
142
139
|
const result = instanceScope.run(() => runSetupFunction(setup, props, context));
|
|
143
|
-
|
|
144
|
-
if (result && typeof result === "object") {
|
|
145
|
-
const setupResult = result;
|
|
146
|
-
const runtimeSetupState = runtime.setupState && typeof runtime.setupState === "object" ? isReactive(runtime.setupState) ? toRaw(runtime.setupState) : runtime.setupState : Object.create(null);
|
|
147
|
-
Object.keys(setupResult).forEach((key) => {
|
|
148
|
-
const val = setupResult[key];
|
|
149
|
-
const preservesAccessor = preserveSetupAccessor(runtimeSetupState, setupResult, key);
|
|
150
|
-
if (typeof val === "function" && !preservesAccessor) {
|
|
151
|
-
const bound = (...args) => val.apply(runtime.proxy, args);
|
|
152
|
-
runtime.methods[key] = bound;
|
|
153
|
-
runtime.state[key] = bound;
|
|
154
|
-
runtimeSetupState[key] = bound;
|
|
155
|
-
methodsChanged = true;
|
|
156
|
-
} else {
|
|
157
|
-
if (hasTrackableSetupBinding(val)) runtime.__wevu_trackSetupReactiveKey?.(key);
|
|
158
|
-
runtime.state[key] = val;
|
|
159
|
-
if (!preservesAccessor) runtimeSetupState[key] = val;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
if (methodsChanged) runtime.__wevu_touchSetupMethodsVersion?.();
|
|
140
|
+
if (result && typeof result === "object") applySetupResult(runtimeWithDefaults, target, result);
|
|
164
141
|
} finally {
|
|
165
142
|
restoreSetupContext();
|
|
166
143
|
}
|
|
167
144
|
}
|
|
168
145
|
|
|
169
|
-
//#endregion
|
|
170
146
|
export { runRuntimeSetupPhase };
|
|
171
147
|
//# sourceMappingURL=setupPhase.mjs.map
|
|
@@ -1 +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 { preserveSetupAccessor } from '../../define/setupResult'\nimport { normalizeEmitEventName } from '../../emit'\nimport { getCurrentInstance, getCurrentSetupContext, 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 // 已排队的用户回调可以持有实例;兼容视图与宿主注册表的销毁周期分离。\n let exposedView: Record<string, any> | undefined\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: () => exposedView,\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 return (exposed: Record<string, any>) => {\n exposedView = exposed\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 const updateExposedView = 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 updateExposedView(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 const previousInstance = getCurrentInstance()\n const previousSetupContext = getCurrentSetupContext()\n const restoreSetupContext = () => {\n // 仅当全局上下文仍属于本次 setup 时恢复父级;嵌套或重入 setup\n // 可能已经建立了新的上下文,不能被旧调用覆盖。\n if (getCurrentInstance() !== target || getCurrentSetupContext() !== context) {\n return\n }\n setCurrentSetupContext(previousSetupContext)\n setCurrentInstance(previousInstance)\n }\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 setupResult = result as Record<string, unknown>\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(setupResult).forEach((key) => {\n const val = setupResult[key]\n const preservesAccessor = preserveSetupAccessor(runtimeSetupState, setupResult, key)\n if (typeof val === 'function' && !preservesAccessor) {\n const bound = (...args: any[]) => (val as any).apply((runtime as any).proxy, args)\n ;(runtime.methods as any)[key] = bound\n ;(runtime.state as any)[key] = bound\n ;(runtimeSetupState as any)[key] = bound\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 if (!preservesAccessor) {\n ;(runtimeSetupState as any)[key] = val\n }\n }\n })\n }\n if (methodsChanged) {\n ;(runtime as any).__wevu_touchSetupMethodsVersion?.()\n }\n }\n finally {\n // current instance/context 只属于本次同步 setup 调用;异步 continuation\n // 不能继续占用全局上下文,否则会污染随后挂载的组件。\n restoreSetupContext()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAE7F,IAAI;CACJ,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;EACb;CACF;CACA,KAAK,MAAM,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C9B,IAAI;EACF,MAAM,SAAS,cAAc,UAAU,iBAAiB,OAAO,OAAO,OAAO,CAAC;EAC9E,IAAI,iBAAiB;EACrB,IAAI,UAAU,OAAO,WAAW,UAAU;GACxC,MAAM,cAAc;GACpB,MAAM,oBAAqB,QAAgB,cAAc,OAAQ,QAAgB,eAAe,WAC3F,WAAY,QAAgB,UAAU,IAAI,MAAO,QAAgB,UAAU,IAAK,QAAgB,aACjG,OAAO,OAAO,IAAI;GACtB,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ;IACxC,MAAM,MAAM,YAAY;IACxB,MAAM,oBAAoB,sBAAsB,mBAAmB,aAAa,GAAG;IACnF,IAAI,OAAO,QAAQ,cAAc,CAAC,mBAAmB;KACnD,MAAM,SAAS,GAAG,SAAiB,IAAY,MAAO,QAAgB,OAAO,IAAI;KAChF,AAAC,QAAQ,QAAgB,OAAO;KAChC,AAAC,QAAQ,MAAc,OAAO;KAC9B,AAAC,kBAA0B,OAAO;KACnC,iBAAiB;IACnB,OACK;KACH,IAAI,yBAAyB,GAAG,GAC7B,AAAC,QAAgB,+BAA+B,GAAG;KAErD,AAAC,QAAQ,MAAc,OAAO;KAC/B,IAAI,CAAC,mBACF,AAAC,kBAA0B,OAAO;IAEvC;GACF,CAAC;EACH;EACA,IAAI,gBACD,AAAC,QAAgB,kCAAkC;CAExD,UACQ;EAGN,oBAAoB;CACtB;AACF"}
|
|
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, shallowReactive } from '../../../reactivity'\nimport { hasOwn } from '../../../utils'\nimport { applySetupResult } from '../../define/setupResult'\nimport { normalizeEmitEventName } from '../../emit'\nimport { getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from '../../hooks'\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 // 已排队的用户回调可以持有实例;兼容视图与宿主注册表的销毁周期分离。\n let exposedView: Record<string, any> | undefined\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: () => exposedView,\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 return (exposed: Record<string, any>) => {\n exposedView = exposed\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 const updateExposedView = 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 updateExposedView(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 const previousInstance = getCurrentInstance()\n const previousSetupContext = getCurrentSetupContext()\n const restoreSetupContext = () => {\n // 仅当全局上下文仍属于本次 setup 时恢复父级;嵌套或重入 setup\n // 可能已经建立了新的上下文,不能被旧调用覆盖。\n if (getCurrentInstance() !== target || getCurrentSetupContext() !== context) {\n return\n }\n setCurrentSetupContext(previousSetupContext)\n setCurrentInstance(previousInstance)\n }\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 if (result && typeof result === 'object') {\n applySetupResult(runtimeWithDefaults, target, result)\n }\n }\n finally {\n // current instance/context 只属于本次同步 setup 调用;异步 continuation\n // 不能继续占用全局上下文,否则会污染随后挂载的组件。\n restoreSetupContext()\n }\n}\n"],"mappings":";;;;;;;;;;;;AAoCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAE7F,IAAI;CACJ,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;EACb;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,WAAW,GACxD,IAAI;EACF,OAAO,eAAe,UAAU,KAAK,UAAU;CACjD,QACM;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,QACM;EACJ,MAAM,OAAO,WAAW;CAC1B;CAEF,QAAQ,YAAiC;EACvC,cAAc;CAChB;AACF;AAEA,SAAS,kBAAkB,KAAa;CACtC,OAAO,IAAI,WAAW,OAAO;AAC/B;AAEA,SAAgB,qBAAmG,SAOhH;CACD,MAAM,EACJ,QACA,SACA,qBACA,cACA,cACA,UACE;CAIJ,MAAM,eAAiB,OAAe,cAAc,CA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AAO,QAAQ,MAAM,KAAK,mBAAmB;EAC7C,UAAU;EAGV,OAAO,OAAe,GAAG,SAAgB;GACvC,MAAM,EAAE,QAAQ,YAAY,qBAAqB,IAAI;GACrD,MAAM,YAAY,uBAAuB,KAAK;GAC9C,cAAc,aAAa,WAAW,QAAQ,OAAO;EACvD;EAGA,SAAS,YAAiC;GACxC,OAAO,oBAAoB;GAC3B,kBAAkB,OAAO;EAC3B;EAGA;EAGA;CACF,CAAC;CAGD,MAAM,gBAAgB,YAAY,IAAI;CACtC,MAAM,mBAAmB,mBAAmB;CAC5C,MAAM,uBAAuB,uBAAuB;CACpD,MAAM,4BAA4B;EAGhC,IAAI,mBAAmB,MAAM,UAAU,uBAAuB,MAAM,SAClE;EAEF,uBAAuB,oBAAoB;EAC3C,mBAAmB,gBAAgB;CACrC;CACA,OAAO,yBAAyB;CAChC,mBAAmB,MAAM;CACzB,uBAAuB,OAAO;CAC9B,IAAI;EACF,MAAM,SAAS,cAAc,UAAU,iBAAiB,OAAO,OAAO,OAAO,CAAC;EAC9E,IAAI,UAAU,OAAO,WAAW,UAC9B,iBAAiB,qBAAqB,QAAQ,MAAM;CAExD,UACQ;EAGN,oBAAoB;CACtB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isRef } from "../../../reactivity/ref.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/runtime/register/runtimeInstance/setupSnapshot.ts
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
6
|
}
|
|
@@ -21,6 +21,5 @@ function restoreReactiveSetupSnapshot(target, snapshot, previousInitial) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
//#endregion
|
|
25
24
|
export { restoreReactiveSetupSnapshot };
|
|
26
25
|
//# sourceMappingURL=setupSnapshot.mjs.map
|
|
@@ -3,7 +3,7 @@ import { hasOwn } from "../../../utils.mjs";
|
|
|
3
3
|
import { isNativeBridgeMethod } from "../../nativeBridge.mjs";
|
|
4
4
|
import { WEVU_NATIVE_INSTANCE_KEY, WEVU_PROPS_KEY, WEVU_PROP_KEYS_KEY, WEVU_RUNTIME_KEY, WEVU_SETUP_CONTEXT_INSTANCE_KEY, WEVU_SETUP_STATE_KEY } from "@weapp-core/constants";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/runtime/register/runtimeInstance/utils.ts
|
|
7
7
|
function attachRuntimeProxyProps(state, props) {
|
|
8
8
|
try {
|
|
9
9
|
Object.defineProperty(state, WEVU_PROPS_KEY, {
|
|
@@ -117,6 +117,5 @@ function ensureRuntimeProps(target, runtimeState, mpProperties = target.properti
|
|
|
117
117
|
return props;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
//#endregion
|
|
121
120
|
export { attachNativeInstanceRef, attachRuntimeInstance, attachRuntimeProxyProps, attachRuntimeRef, attachRuntimeSetupState, callNativeSetData, ensureRuntimeProps, resolveNativeSetData, syncRuntimeProps };
|
|
122
121
|
//# sourceMappingURL=utils.mjs.map
|