wevu 7.0.4 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/alipay/jsx-runtime.d.mts +12 -0
- package/dist/alipay/jsx-runtime.mjs +1 -0
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/defineProperty.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPrimitive.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPropertyKey.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/typeof.mjs +1 -1
- package/dist/dev/api/vitest/setup.d.mts +1 -0
- package/dist/dev/api/vitest.d.mts +1 -0
- package/dist/dev/api.d.mts +1 -0
- package/dist/dev/compiler.d.mts +1 -0
- package/dist/dev/fetch.d.mts +9 -0
- package/dist/dev/index.d.mts +72 -0
- package/dist/dev/index.mjs +12 -15
- package/dist/dev/internal-reactivity.d.mts +18 -0
- package/dist/dev/internal-reactivity.mjs +3 -2
- package/dist/dev/internal-runtime.d.mts +44 -0
- package/dist/dev/internal-runtime.mjs +19 -14
- package/dist/dev/internal-template.d.mts +2 -0
- package/dist/dev/jsxTypes.d.mts +9 -0
- package/dist/dev/macros/shared.d.mts +81 -0
- package/dist/dev/macros.d.mts +71 -0
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/reactivity/asyncDerivation.d.mts +41 -0
- package/dist/dev/reactivity/asyncDerivation.mjs +130 -0
- package/dist/dev/reactivity/asyncDerivation.mjs.map +1 -0
- package/dist/dev/reactivity/computed.d.mts +21 -0
- package/dist/dev/reactivity/computed.mjs +2 -2
- package/dist/dev/reactivity/computed.mjs.map +1 -1
- package/dist/dev/reactivity/core.d.mts +35 -0
- package/dist/dev/reactivity/core.mjs +156 -32
- package/dist/dev/reactivity/core.mjs.map +1 -1
- package/dist/dev/reactivity/index.d.mts +16 -0
- package/dist/dev/reactivity/reactive/mutation.d.mts +21 -0
- package/dist/dev/reactivity/reactive/patch.d.mts +18 -0
- package/dist/dev/reactivity/reactive/shallow.d.mts +22 -0
- package/dist/dev/reactivity/reactive/shared.d.mts +4 -0
- package/dist/dev/reactivity/reactive.d.mts +42 -0
- package/dist/dev/reactivity/readonly.d.mts +27 -0
- package/dist/dev/reactivity/readonly.mjs.map +1 -1
- package/dist/dev/reactivity/ref.d.mts +27 -0
- package/dist/dev/reactivity/ref.mjs +1 -1
- package/dist/dev/reactivity/shallowRef.d.mts +19 -0
- package/dist/dev/reactivity/toRefs.d.mts +43 -0
- package/dist/dev/reactivity/traverse.d.mts +8 -0
- package/dist/dev/reactivity/watch/types.d.mts +43 -0
- package/dist/dev/reactivity/watch.d.mts +22 -0
- package/dist/dev/router/createRouter.d.mts +8 -0
- package/dist/dev/router/createRouter.mjs +16 -3
- package/dist/dev/router/createRouter.mjs.map +1 -1
- package/dist/dev/router/navigationCore.d.mts +6 -0
- package/dist/dev/router/resolve.d.mts +6 -0
- package/dist/dev/router/routeSync.d.mts +1 -0
- package/dist/dev/router/types.d.mts +172 -0
- package/dist/dev/router/useRoute.d.mts +19 -0
- package/dist/dev/router/useRoute.mjs +23 -5
- package/dist/dev/router/useRoute.mjs.map +1 -1
- package/dist/dev/router/useRouter.d.mts +8 -0
- package/dist/dev/router.d.mts +10 -0
- package/dist/dev/routerInternal/query.d.mts +7 -0
- package/dist/dev/routerInternal/types.d.mts +9 -0
- package/dist/dev/runtime/app/computed.mjs +2 -2
- package/dist/dev/runtime/app/computed.mjs.map +1 -1
- package/dist/dev/runtime/app/context.mjs +8 -2
- package/dist/dev/runtime/app/context.mjs.map +1 -1
- package/dist/dev/runtime/app/diagnostics.mjs +12 -0
- package/dist/dev/runtime/app/diagnostics.mjs.map +1 -1
- package/dist/dev/runtime/app/mount.mjs +31 -28
- package/dist/dev/runtime/app/mount.mjs.map +1 -1
- package/dist/dev/runtime/app/pending.d.mts +10 -0
- package/dist/dev/runtime/app/setData/commitTracker.d.mts +13 -0
- package/dist/dev/runtime/app/setData/commitTracker.mjs +265 -0
- package/dist/dev/runtime/app/setData/commitTracker.mjs.map +1 -0
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +47 -51
- package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/scheduler.d.mts +51 -0
- package/dist/dev/runtime/app/setData/scheduler.mjs +98 -111
- package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/snapshot.mjs +11 -1
- package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/app.d.mts +8 -0
- package/dist/dev/runtime/app.mjs +18 -6
- package/dist/dev/runtime/app.mjs.map +1 -1
- package/dist/dev/runtime/bindingManifest.mjs +105 -0
- package/dist/dev/runtime/bindingManifest.mjs.map +1 -0
- package/dist/dev/runtime/capabilities.d.mts +75 -0
- package/dist/dev/runtime/capabilities.mjs +40 -0
- package/dist/dev/runtime/capabilities.mjs.map +1 -0
- package/dist/dev/runtime/css.d.mts +14 -0
- package/dist/dev/runtime/defaults.d.mts +12 -0
- package/dist/dev/runtime/define/componentDefinition.mjs +3 -0
- package/dist/dev/runtime/define/componentDefinition.mjs.map +1 -1
- package/dist/dev/runtime/define/optionsApi.mjs +1 -1
- package/dist/dev/runtime/define/props.mjs +30 -60
- package/dist/dev/runtime/define/props.mjs.map +1 -1
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +37 -21
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -1
- package/dist/dev/runtime/define.d.mts +118 -0
- package/dist/dev/runtime/define.mjs +32 -44
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/diff.mjs +1 -1
- package/dist/dev/runtime/disposables.d.mts +31 -0
- package/dist/dev/runtime/elementIntersectionObserver.d.mts +26 -0
- package/dist/dev/runtime/features/inlineEvents.d.mts +7 -0
- package/dist/dev/runtime/features/inlineEvents.mjs +25 -0
- package/dist/dev/runtime/features/inlineEvents.mjs.map +1 -0
- package/dist/dev/runtime/features/layout.d.mts +7 -0
- package/dist/dev/runtime/features/layout.mjs +44 -0
- package/dist/dev/runtime/features/layout.mjs.map +1 -0
- package/dist/dev/runtime/features/patchStrategy.d.mts +7 -0
- package/dist/dev/runtime/features/patchStrategy.mjs +129 -0
- package/dist/dev/runtime/features/patchStrategy.mjs.map +1 -0
- package/dist/dev/runtime/features/publicLayout.d.mts +24 -0
- package/dist/dev/runtime/features/publicLayout.mjs +81 -0
- package/dist/dev/runtime/features/publicLayout.mjs.map +1 -0
- package/dist/dev/runtime/features/scopedSlots.d.mts +23 -0
- package/dist/dev/runtime/features/scopedSlots.mjs +88 -0
- package/dist/dev/runtime/features/scopedSlots.mjs.map +1 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.d.mts +7 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.mjs +15 -0
- package/dist/dev/runtime/features/setDataHighFrequencyWarning.mjs.map +1 -0
- package/dist/dev/runtime/features/templateRefs.d.mts +7 -0
- package/dist/dev/runtime/features/templateRefs.mjs +39 -0
- package/dist/dev/runtime/features/templateRefs.mjs.map +1 -0
- package/dist/dev/runtime/hooks/base.d.mts +27 -0
- package/dist/dev/runtime/hooks/register.d.mts +30 -0
- package/dist/dev/runtime/hooks/vue.d.mts +52 -0
- package/dist/dev/runtime/hooks/vue.mjs +3 -5
- package/dist/dev/runtime/hooks/vue.mjs.map +1 -1
- package/dist/dev/runtime/hooks.d.mts +4 -0
- package/dist/dev/runtime/index.d.mts +46 -0
- package/dist/dev/runtime/inlineDataset.mjs +75 -0
- package/dist/dev/runtime/inlineDataset.mjs.map +1 -0
- package/dist/dev/runtime/intersectionObserver.d.mts +14 -0
- package/dist/dev/runtime/jsxIsland.d.mts +37 -0
- package/dist/dev/runtime/jsxIsland.mjs.map +1 -1
- package/dist/dev/runtime/layoutBridge.d.mts +55 -0
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -1
- package/dist/dev/runtime/noSetData.d.mts +5 -0
- package/dist/dev/runtime/pageEnvironment.d.mts +50 -0
- package/dist/dev/runtime/pageLayout.d.mts +25 -0
- package/dist/dev/runtime/pageLayout.mjs.map +1 -1
- package/dist/dev/runtime/pageScroll.d.mts +29 -0
- package/dist/dev/runtime/platform.mjs +18 -1
- package/dist/dev/runtime/platform.mjs.map +1 -1
- package/dist/dev/runtime/provide.d.mts +60 -0
- package/dist/dev/runtime/provideStore.d.mts +7 -0
- package/dist/dev/runtime/publicRuntime.d.mts +22 -0
- package/dist/dev/runtime/publicRuntime.mjs +91 -0
- package/dist/dev/runtime/publicRuntime.mjs.map +1 -0
- package/dist/dev/runtime/pullDownRefresh.d.mts +12 -0
- package/dist/dev/runtime/register/app.d.mts +14 -0
- package/dist/dev/runtime/register/app.mjs +7 -10
- package/dist/dev/runtime/register/app.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle.mjs +22 -6
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -1
- package/dist/dev/runtime/register/component/methods.mjs +7 -10
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -1
- package/dist/dev/runtime/register/component/options.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +64 -69
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/component.d.mts +17 -0
- package/dist/dev/runtime/register/inline.d.mts +15 -0
- package/dist/dev/runtime/register/inline.mjs +4 -64
- package/dist/dev/runtime/register/inline.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +4 -6
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs +26 -0
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs.map +1 -0
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance.d.mts +26 -0
- package/dist/dev/runtime/register/runtimeInstance.mjs +402 -160
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -1
- package/dist/dev/runtime/register/setup.d.mts +11 -0
- package/dist/dev/runtime/register/snapshot.mjs +6 -10
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/register/watch.d.mts +12 -0
- package/dist/dev/runtime/register.d.mts +5 -0
- package/dist/dev/runtime/scopedSlots.mjs +1 -1
- package/dist/dev/runtime/scopedSlots.mjs.map +1 -1
- package/dist/dev/runtime/selectorQuery.d.mts +54 -0
- package/dist/dev/runtime/selectorQuery.mjs +5 -0
- package/dist/dev/runtime/selectorQuery.mjs.map +1 -1
- package/dist/dev/runtime/teardown.mjs +18 -0
- package/dist/dev/runtime/teardown.mjs.map +1 -0
- package/dist/dev/runtime/template.d.mts +6 -0
- package/dist/dev/runtime/templateRefTypes.d.mts +12 -0
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs.mjs +187 -118
- package/dist/dev/runtime/templateRefs.mjs.map +1 -1
- package/dist/dev/runtime/types/core.d.mts +35 -0
- package/dist/dev/runtime/types/miniprogram.d.mts +84 -0
- package/dist/dev/runtime/types/miniprogramHost.d.mts +45 -0
- package/dist/dev/runtime/types/miniprogramHostSources.d.mts +112 -0
- package/dist/dev/runtime/types/options.d.mts +136 -0
- package/dist/dev/runtime/types/props/propTypes.d.mts +79 -0
- package/dist/dev/runtime/types/props/router.d.mts +51 -0
- package/dist/dev/runtime/types/props/setup.d.mts +96 -0
- package/dist/dev/runtime/types/props.d.mts +4 -0
- package/dist/dev/runtime/types/runtime.d.mts +59 -0
- package/dist/dev/runtime/types/setData.d.mts +237 -0
- package/dist/dev/runtime/types.d.mts +29 -0
- package/dist/dev/runtime/uniAppHost.d.mts +8 -0
- package/dist/dev/runtime/updatePerformance.d.mts +13 -0
- package/dist/dev/runtime/use.d.mts +13 -0
- package/dist/dev/runtime/vueCompat/context.d.mts +8 -0
- package/dist/dev/runtime/vueCompat/model.d.mts +30 -0
- package/dist/dev/runtime/vueCompat/router.d.mts +29 -0
- package/dist/dev/runtime/vueCompat/router.mjs +18 -13
- package/dist/dev/runtime/vueCompat/router.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/templateRef.d.mts +9 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs +2 -0
- package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat.d.mts +5 -0
- package/dist/dev/scheduler.d.mts +4 -0
- package/dist/dev/store/base.mjs +12 -18
- package/dist/dev/store/base.mjs.map +1 -1
- package/dist/dev/store/define/optionsStyle.mjs +13 -23
- package/dist/dev/store/define/optionsStyle.mjs.map +1 -1
- package/dist/dev/store/define/setupStyle.mjs +14 -24
- package/dist/dev/store/define/setupStyle.mjs.map +1 -1
- package/dist/dev/store/define/shared.mjs +44 -1
- package/dist/dev/store/define/shared.mjs.map +1 -1
- package/dist/dev/store/define.d.mts +28 -0
- package/dist/dev/store/define.mjs.map +1 -1
- package/dist/dev/store/manager.d.mts +8 -0
- package/dist/dev/store/storeToRefs.d.mts +13 -0
- package/dist/dev/store/types.d.mts +70 -0
- package/dist/dev/store.d.mts +5 -0
- package/dist/dev/version.d.mts +4 -0
- package/dist/dev/vue-augment.d.mts +8 -0
- package/dist/dev/vue-demi.d.mts +87 -0
- package/dist/dev/vue-demi.mjs +12 -15
- package/dist/dev/vue-demi.mjs.map +1 -1
- package/dist/dev/vue-types.d.mts +19 -0
- package/dist/dev/web-apis.d.mts +3 -0
- package/dist/index.d.mts +13 -14
- package/dist/index.mjs +1 -1
- package/dist/internal-reactivity.d.mts +2 -1
- package/dist/internal-reactivity.mjs +1 -1
- package/dist/internal-runtime.d.mts +13 -6
- package/dist/internal-runtime.mjs +1 -1
- package/dist/jsx-runtime.d.mts +47 -9
- package/dist/jsxTypes.d.mts +8 -0
- package/dist/miniprogram/jsx-runtime.d.mts +12 -0
- package/dist/miniprogram/jsx-runtime.mjs +1 -0
- package/dist/package.mjs +1 -1
- package/dist/reactivity/asyncDerivation.d.mts +40 -0
- package/dist/reactivity/asyncDerivation.mjs +1 -0
- package/dist/reactivity/computed.mjs +1 -1
- package/dist/reactivity/core.d.mts +1 -0
- package/dist/reactivity/core.mjs +1 -1
- package/dist/reactivity/index.d.mts +2 -1
- package/dist/reactivity/readonly.d.mts +1 -1
- package/dist/reactivity/ref.mjs +1 -1
- package/dist/router/createRouter.mjs +1 -1
- package/dist/router/useRoute.mjs +1 -1
- package/dist/runtime/app/computed.mjs +1 -1
- package/dist/runtime/app/context.mjs +1 -1
- package/dist/runtime/app/diagnostics.mjs +1 -1
- package/dist/runtime/app/mount.mjs +1 -1
- package/dist/runtime/app/setData/commitTracker.d.mts +12 -0
- package/dist/runtime/app/setData/commitTracker.mjs +1 -0
- package/dist/runtime/app/setData/patchScheduler.mjs +1 -1
- package/dist/runtime/app/setData/scheduler.d.mts +50 -0
- package/dist/runtime/app/setData/scheduler.mjs +1 -1
- package/dist/runtime/app/setData/snapshot.mjs +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/bindingManifest.mjs +1 -0
- package/dist/runtime/capabilities.d.mts +74 -0
- package/dist/runtime/capabilities.mjs +1 -0
- package/dist/runtime/define/componentDefinition.mjs +1 -1
- package/dist/runtime/define/optionsApi.mjs +1 -1
- package/dist/runtime/define/props.mjs +1 -1
- package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
- package/dist/runtime/define.d.mts +5 -13
- package/dist/runtime/define.mjs +1 -1
- package/dist/runtime/diff.mjs +1 -1
- package/dist/runtime/features/inlineEvents.d.mts +6 -0
- package/dist/runtime/features/inlineEvents.mjs +1 -0
- package/dist/runtime/features/layout.d.mts +6 -0
- package/dist/runtime/features/layout.mjs +1 -0
- package/dist/runtime/features/patchStrategy.d.mts +6 -0
- package/dist/runtime/features/patchStrategy.mjs +1 -0
- package/dist/runtime/features/publicLayout.d.mts +23 -0
- package/dist/runtime/features/publicLayout.mjs +1 -0
- package/dist/runtime/features/scopedSlots.d.mts +22 -0
- package/dist/runtime/features/scopedSlots.mjs +1 -0
- package/dist/runtime/features/setDataHighFrequencyWarning.d.mts +6 -0
- package/dist/runtime/features/setDataHighFrequencyWarning.mjs +1 -0
- package/dist/runtime/features/templateRefs.d.mts +6 -0
- package/dist/runtime/features/templateRefs.mjs +1 -0
- package/dist/runtime/hooks/vue.d.mts +1 -2
- package/dist/runtime/hooks/vue.mjs +1 -1
- package/dist/runtime/index.d.mts +12 -14
- package/dist/runtime/inlineDataset.mjs +1 -0
- package/dist/runtime/jsxIsland.d.mts +2 -6
- package/dist/runtime/layoutBridge.d.mts +5 -9
- package/dist/runtime/pageLayout.d.mts +3 -4
- package/dist/runtime/platform.mjs +1 -1
- package/dist/runtime/publicRuntime.d.mts +21 -0
- package/dist/runtime/publicRuntime.mjs +1 -0
- package/dist/runtime/register/app.mjs +1 -1
- package/dist/runtime/register/component/lifecycle.mjs +1 -1
- package/dist/runtime/register/component/methods.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/runtime/register/inline.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupSnapshot.mjs +1 -0
- package/dist/runtime/register/runtimeInstance.mjs +1 -1
- package/dist/runtime/register/snapshot.mjs +1 -1
- package/dist/runtime/scopedSlots.mjs +1 -1
- package/dist/runtime/selectorQuery.mjs +1 -1
- package/dist/runtime/teardown.mjs +1 -0
- package/dist/runtime/templateRefTypes.d.mts +5 -2
- package/dist/runtime/templateRefs.mjs +1 -1
- package/dist/runtime/types/miniprogram.d.mts +3 -0
- package/dist/runtime/types/options.d.mts +2 -2
- package/dist/runtime/types/props.d.mts +1 -1
- package/dist/runtime/types/setData.d.mts +18 -1
- package/dist/runtime/types.d.mts +3 -3
- package/dist/runtime/vueCompat/router.d.mts +5 -4
- package/dist/runtime/vueCompat/router.mjs +1 -1
- package/dist/runtime/vueCompat/templateRef.mjs +1 -1
- package/dist/store/base.mjs +1 -1
- package/dist/store/define/optionsStyle.mjs +1 -1
- package/dist/store/define/setupStyle.mjs +1 -1
- package/dist/store/define/shared.mjs +1 -1
- package/dist/store/define.d.mts +10 -8
- package/dist/store/types.d.mts +4 -4
- package/dist/tt/jsx-runtime.d.mts +12 -0
- package/dist/tt/jsx-runtime.mjs +1 -0
- package/dist/vue-demi.d.mts +13 -14
- package/dist/vue-demi.mjs +1 -1
- package/dist/weapp/jsx-runtime.d.mts +12 -0
- package/dist/weapp/jsx-runtime.mjs +1 -0
- package/package.json +26 -22
- package/dist/dev/jsx-runtime.mjs +0 -1
- package/dist/runtime/templateRefs.d.mts +0 -10
- package/dist/weappIntrinsicElements/base.d.mts +0 -21
- package/dist/weappIntrinsicElements/elements/ad-custom.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/ad.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/audio.d.mts +0 -19
- package/dist/weappIntrinsicElements/elements/block.d.mts +0 -7
- package/dist/weappIntrinsicElements/elements/button.d.mts +0 -39
- package/dist/weappIntrinsicElements/elements/camera.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/canvas.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/checkbox-group.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/checkbox.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/cover-image.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/cover-view.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/editor.d.mts +0 -21
- package/dist/weappIntrinsicElements/elements/form.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/functional-page-navigator.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/icon.d.mts +0 -11
- package/dist/weappIntrinsicElements/elements/image.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/import.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/include.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/input.d.mts +0 -46
- package/dist/weappIntrinsicElements/elements/keyboard-accessory.d.mts +0 -7
- package/dist/weappIntrinsicElements/elements/label.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/live-player.d.mts +0 -34
- package/dist/weappIntrinsicElements/elements/live-pusher.d.mts +0 -56
- package/dist/weappIntrinsicElements/elements/map.d.mts +0 -104
- package/dist/weappIntrinsicElements/elements/match-media.d.mts +0 -15
- package/dist/weappIntrinsicElements/elements/movable-area.d.mts +0 -25
- package/dist/weappIntrinsicElements/elements/movable-view.d.mts +0 -25
- package/dist/weappIntrinsicElements/elements/navigation-bar.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/navigator.d.mts +0 -24
- package/dist/weappIntrinsicElements/elements/official-account.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/open-data.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/page-container.d.mts +0 -24
- package/dist/weappIntrinsicElements/elements/page-meta.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/picker-view-column.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/picker-view.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/picker.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/progress.d.mts +0 -20
- package/dist/weappIntrinsicElements/elements/radio-group.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/radio.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/rich-text.d.mts +0 -16
- package/dist/weappIntrinsicElements/elements/scroll-view.d.mts +0 -67
- package/dist/weappIntrinsicElements/elements/share-element.d.mts +0 -17
- package/dist/weappIntrinsicElements/elements/slider.d.mts +0 -22
- package/dist/weappIntrinsicElements/elements/slot.d.mts +0 -9
- package/dist/weappIntrinsicElements/elements/swiper-item.d.mts +0 -41
- package/dist/weappIntrinsicElements/elements/swiper.d.mts +0 -41
- package/dist/weappIntrinsicElements/elements/switch.d.mts +0 -13
- package/dist/weappIntrinsicElements/elements/template.d.mts +0 -11
- package/dist/weappIntrinsicElements/elements/text.d.mts +0 -14
- package/dist/weappIntrinsicElements/elements/textarea.d.mts +0 -39
- package/dist/weappIntrinsicElements/elements/video.d.mts +0 -70
- package/dist/weappIntrinsicElements/elements/view.d.mts +0 -12
- package/dist/weappIntrinsicElements/elements/voip-room.d.mts +0 -13
- package/dist/weappIntrinsicElements/elements/web-view.d.mts +0 -12
- package/dist/weappIntrinsicElements.d.mts +0 -153
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/defineProperty.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPrimitive.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPropertyKey.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/typeof.mjs +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { HostMiniProgramComponentPropertyOption } from "./runtime/types/miniprogramHost.mjs";
|
|
2
|
+
import { ComponentPropsOptions } from "./runtime/types/props/propTypes.mjs";
|
|
3
|
+
import { Ref } from "./reactivity/ref.mjs";
|
|
4
|
+
import "./reactivity/index.mjs";
|
|
5
|
+
import { ComputedDefinitions, MethodDefinitions } from "./runtime/types/core.mjs";
|
|
6
|
+
import "./runtime/index.mjs";
|
|
7
|
+
import { BooleanKey, ComponentTypeEmits, DefineProps, DefinePropsFromArray, DefinePropsFromOptions, EmitFn, EmitsOptions, InferDefaults, PropsWithDefaults, ScriptSetupDefineOptions, ShortEmits } from "./macros/shared.mjs";
|
|
8
|
+
//#region src/macros.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* defineProps 声明(类型层宏)。
|
|
11
|
+
*/
|
|
12
|
+
export declare function defineProps<PropNames extends string = string>(props: PropNames[]): DefinePropsFromArray<PropNames>;
|
|
13
|
+
export declare function defineProps<PP extends ComponentPropsOptions = ComponentPropsOptions>(props: PP): DefinePropsFromOptions<PP>;
|
|
14
|
+
export declare function defineProps<TypeProps>(): DefineProps<TypeProps, BooleanKey<TypeProps>>;
|
|
15
|
+
/**
|
|
16
|
+
* withDefaults 为 defineProps 声明默认值(类型层)。
|
|
17
|
+
*/
|
|
18
|
+
export declare function withDefaults<T, BKeys extends keyof T, Defaults extends InferDefaults<T>>(props: DefineProps<T, BKeys>, defaults: Defaults): PropsWithDefaults<T, Defaults, BKeys>;
|
|
19
|
+
/**
|
|
20
|
+
* defineEmits 声明(类型层宏)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function defineEmits<EE extends string = string>(emits?: EE[]): EmitFn<EE[]>;
|
|
23
|
+
export declare function defineEmits<E extends EmitsOptions = EmitsOptions>(emits?: E): EmitFn<E>;
|
|
24
|
+
export declare function defineEmits<T extends ComponentTypeEmits>(): T extends ((...args: any[]) => any) ? T : ShortEmits<T>;
|
|
25
|
+
/**
|
|
26
|
+
* defineExpose 向父级 ref 暴露成员(仅类型层)。
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineExpose<T extends Record<string, any> = Record<string, any>>(exposed?: T): void;
|
|
29
|
+
/**
|
|
30
|
+
* defineOptions 设置 `<script setup>` 组件选项(仅类型层)。
|
|
31
|
+
*/
|
|
32
|
+
export declare function defineOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions, P extends HostMiniProgramComponentPropertyOption = HostMiniProgramComponentPropertyOption>(options?: ScriptSetupDefineOptions<D, C, M, P>): void;
|
|
33
|
+
export declare function defineOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions, P extends HostMiniProgramComponentPropertyOption = HostMiniProgramComponentPropertyOption>(options?: () => ScriptSetupDefineOptions<D, C, M, P> | Promise<ScriptSetupDefineOptions<D, C, M, P>>): void;
|
|
34
|
+
/**
|
|
35
|
+
* defineSlots 声明 slots 类型(仅类型层)。
|
|
36
|
+
*/
|
|
37
|
+
export declare function defineSlots<T extends Record<string, any> = Record<string, any>>(): T;
|
|
38
|
+
export type PageLayoutMeta = string | false | {
|
|
39
|
+
name: string;
|
|
40
|
+
props?: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
export interface PageMeta {
|
|
43
|
+
layout?: PageLayoutMeta;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* definePageMeta 声明页面级元信息(仅类型层)。
|
|
48
|
+
*/
|
|
49
|
+
export declare function definePageMeta(meta: PageMeta): void;
|
|
50
|
+
/**
|
|
51
|
+
* defineModel 声明 v-model 绑定(类型层宏)。
|
|
52
|
+
*/
|
|
53
|
+
export type DefineModelModifiers<M extends PropertyKey = string> = Record<M, true | undefined>;
|
|
54
|
+
export type ModelRef<T, M extends PropertyKey = string, G = T, S = T> = Ref<G, S> & [ModelRef<T, M, G, S>, DefineModelModifiers<M>];
|
|
55
|
+
export interface DefineModelTransformOptions<T, M extends PropertyKey = string, G = T, S = T> {
|
|
56
|
+
get?: (value: T, modifiers: DefineModelModifiers<M>) => G;
|
|
57
|
+
set?: (value: S, modifiers: DefineModelModifiers<M>) => T;
|
|
58
|
+
}
|
|
59
|
+
type DefineModelBaseOptions<T, M extends PropertyKey = string, G = T, S = T> = Record<string, any> & DefineModelTransformOptions<T, M, G, S>;
|
|
60
|
+
type DefineModelRequiredOptions<T> = {
|
|
61
|
+
default: T | (() => T);
|
|
62
|
+
} | {
|
|
63
|
+
required: true;
|
|
64
|
+
};
|
|
65
|
+
export declare function defineModel<T = any, M extends PropertyKey = string, G = T, S = T>(options: DefineModelBaseOptions<T, M, G, S> & DefineModelRequiredOptions<T>): ModelRef<T, M, G, S>;
|
|
66
|
+
export declare function defineModel<T = any, M extends PropertyKey = string, G = T, S = T>(name: string, options: DefineModelBaseOptions<T, M, G, S> & DefineModelRequiredOptions<T>): ModelRef<T, M, G, S>;
|
|
67
|
+
export declare function defineModel<T = any, M extends PropertyKey = string, G = T, S = T>(options?: DefineModelBaseOptions<T | undefined, M, G | undefined, S | undefined>): ModelRef<T | undefined, M, G | undefined, S | undefined>;
|
|
68
|
+
export declare function defineModel<T = any, M extends PropertyKey = string, G = T, S = T>(name?: string, options?: DefineModelBaseOptions<T | undefined, M, G | undefined, S | undefined>): ModelRef<T | undefined, M, G | undefined, S | undefined>;
|
|
69
|
+
//#endregion
|
|
70
|
+
export type { ComponentTypeEmits, EmitFn, EmitsOptions };
|
|
71
|
+
//# sourceMappingURL=macros.d.mts.map
|
package/dist/dev/package.mjs
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/reactivity/asyncDerivation.d.ts
|
|
2
|
+
/** 异步派生状态的生命周期阶段。 */
|
|
3
|
+
export type AsyncDerivationStatus = 'idle' | 'initial-pending' | 'ready' | 'refreshing' | 'error' | 'disposed';
|
|
4
|
+
/** 传给异步加载函数的当前任务上下文。 */
|
|
5
|
+
export interface AsyncDerivationContext {
|
|
6
|
+
readonly signal: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
/** `useAsyncDerivation()` 的配置。 */
|
|
9
|
+
export interface UseAsyncDerivationOptions {
|
|
10
|
+
immediate?: boolean;
|
|
11
|
+
}
|
|
12
|
+
type AsyncDerivationIdleState<TStatus extends 'idle' | 'initial-pending' | 'disposed'> = Readonly<{
|
|
13
|
+
status: TStatus;
|
|
14
|
+
value: undefined;
|
|
15
|
+
error: undefined;
|
|
16
|
+
}>;
|
|
17
|
+
type AsyncDerivationReadyState<T, TStatus extends 'ready' | 'refreshing'> = Readonly<{
|
|
18
|
+
status: TStatus;
|
|
19
|
+
value: T;
|
|
20
|
+
error: undefined;
|
|
21
|
+
}>;
|
|
22
|
+
type AsyncDerivationErrorState<T> = Readonly<{
|
|
23
|
+
status: 'error';
|
|
24
|
+
value: T | undefined;
|
|
25
|
+
error: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
/** 模板可观察的只读异步派生状态。 */
|
|
28
|
+
export type AsyncDerivationState<T> = AsyncDerivationIdleState<'idle'> | AsyncDerivationIdleState<'initial-pending'> | AsyncDerivationIdleState<'disposed'> | AsyncDerivationReadyState<T, 'ready'> | AsyncDerivationReadyState<T, 'refreshing'> | AsyncDerivationErrorState<T>;
|
|
29
|
+
type AsyncDerivationControls = Readonly<{
|
|
30
|
+
refresh: () => Promise<void>;
|
|
31
|
+
dispose: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
/** 异步派生状态及其非枚举控制方法。 */
|
|
34
|
+
export type AsyncDerivation<T> = AsyncDerivationState<T> & AsyncDerivationControls;
|
|
35
|
+
/**
|
|
36
|
+
* 创建面向静态 WXML 数据绑定的异步派生状态。
|
|
37
|
+
* 加载错误通过 `status` 与 `error` 暴露,`refresh()` 始终正常完成。
|
|
38
|
+
*/
|
|
39
|
+
export declare function useAsyncDerivation<T>(loader: (context: AsyncDerivationContext) => T | PromiseLike<T>, options?: UseAsyncDerivationOptions): AsyncDerivation<T>;
|
|
40
|
+
//#endregion
|
|
41
|
+
//# sourceMappingURL=asyncDerivation.d.mts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { batch, onScopeDispose, runWithoutTracking } from "./core.mjs";
|
|
2
|
+
import { reactive } from "./reactive.mjs";
|
|
3
|
+
import { readonly } from "./readonly.mjs";
|
|
4
|
+
import { AbortControllerPolyfill } from "@wevu/web-apis/abort";
|
|
5
|
+
|
|
6
|
+
//#region src/reactivity/asyncDerivation.ts
|
|
7
|
+
const RESOLVED_PROMISE = Promise.resolve();
|
|
8
|
+
function createAsyncDerivationCycle() {
|
|
9
|
+
let resolve;
|
|
10
|
+
return {
|
|
11
|
+
promise: new Promise((settle) => {
|
|
12
|
+
resolve = settle;
|
|
13
|
+
}),
|
|
14
|
+
resolve
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 创建面向静态 WXML 数据绑定的异步派生状态。
|
|
19
|
+
* 加载错误通过 `status` 与 `error` 暴露,`refresh()` 始终正常完成。
|
|
20
|
+
*/
|
|
21
|
+
function useAsyncDerivation(loader, options = {}) {
|
|
22
|
+
var _options$immediate;
|
|
23
|
+
const storage = {
|
|
24
|
+
status: "idle",
|
|
25
|
+
value: void 0,
|
|
26
|
+
error: void 0
|
|
27
|
+
};
|
|
28
|
+
const state = reactive(storage);
|
|
29
|
+
let activeController;
|
|
30
|
+
let activeCycle;
|
|
31
|
+
let generation = 0;
|
|
32
|
+
let hasValue = false;
|
|
33
|
+
let disposed = false;
|
|
34
|
+
function settleLatestCycle(completedGeneration) {
|
|
35
|
+
if (disposed || completedGeneration !== generation) return;
|
|
36
|
+
const cycle = activeCycle;
|
|
37
|
+
activeCycle = void 0;
|
|
38
|
+
cycle === null || cycle === void 0 || cycle.resolve();
|
|
39
|
+
}
|
|
40
|
+
function commitValue(completedGeneration, value) {
|
|
41
|
+
if (disposed || completedGeneration !== generation) return;
|
|
42
|
+
activeController = void 0;
|
|
43
|
+
hasValue = true;
|
|
44
|
+
try {
|
|
45
|
+
batch(() => {
|
|
46
|
+
state.status = "ready";
|
|
47
|
+
state.value = value;
|
|
48
|
+
state.error = void 0;
|
|
49
|
+
});
|
|
50
|
+
} finally {
|
|
51
|
+
settleLatestCycle(completedGeneration);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function commitError(completedGeneration, error) {
|
|
55
|
+
if (disposed || completedGeneration !== generation) return;
|
|
56
|
+
activeController = void 0;
|
|
57
|
+
try {
|
|
58
|
+
batch(() => {
|
|
59
|
+
state.status = "error";
|
|
60
|
+
state.error = error;
|
|
61
|
+
if (!hasValue) state.value = void 0;
|
|
62
|
+
});
|
|
63
|
+
} finally {
|
|
64
|
+
settleLatestCycle(completedGeneration);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function refresh() {
|
|
68
|
+
var _activeCycle;
|
|
69
|
+
if (disposed) return RESOLVED_PROMISE;
|
|
70
|
+
const cycle = (_activeCycle = activeCycle) !== null && _activeCycle !== void 0 ? _activeCycle : createAsyncDerivationCycle();
|
|
71
|
+
activeCycle = cycle;
|
|
72
|
+
const currentGeneration = ++generation;
|
|
73
|
+
const previousController = activeController;
|
|
74
|
+
const controller = new (typeof AbortController === "function" ? AbortController : AbortControllerPolyfill)();
|
|
75
|
+
activeController = controller;
|
|
76
|
+
try {
|
|
77
|
+
previousController === null || previousController === void 0 || previousController.abort();
|
|
78
|
+
} catch (_unused) {}
|
|
79
|
+
if (disposed || currentGeneration !== generation) return cycle.promise;
|
|
80
|
+
batch(() => {
|
|
81
|
+
state.status = hasValue ? "refreshing" : "initial-pending";
|
|
82
|
+
state.error = void 0;
|
|
83
|
+
});
|
|
84
|
+
if (disposed || currentGeneration !== generation) return cycle.promise;
|
|
85
|
+
runWithoutTracking(() => {
|
|
86
|
+
new Promise((resolve) => {
|
|
87
|
+
resolve(loader({ signal: controller.signal }));
|
|
88
|
+
}).then((value) => commitValue(currentGeneration, value), (error) => commitError(currentGeneration, error)).catch((error) => {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
throw error;
|
|
91
|
+
}, 0);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
return cycle.promise;
|
|
95
|
+
}
|
|
96
|
+
function dispose() {
|
|
97
|
+
if (disposed) return;
|
|
98
|
+
disposed = true;
|
|
99
|
+
generation += 1;
|
|
100
|
+
const controller = activeController;
|
|
101
|
+
activeController = void 0;
|
|
102
|
+
try {
|
|
103
|
+
controller === null || controller === void 0 || controller.abort();
|
|
104
|
+
} catch (_unused2) {}
|
|
105
|
+
try {
|
|
106
|
+
batch(() => {
|
|
107
|
+
state.status = "disposed";
|
|
108
|
+
state.value = void 0;
|
|
109
|
+
state.error = void 0;
|
|
110
|
+
});
|
|
111
|
+
} finally {
|
|
112
|
+
hasValue = false;
|
|
113
|
+
const cycle = activeCycle;
|
|
114
|
+
activeCycle = void 0;
|
|
115
|
+
cycle === null || cycle === void 0 || cycle.resolve();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
Object.defineProperties(storage, {
|
|
119
|
+
refresh: { value: refresh },
|
|
120
|
+
dispose: { value: dispose }
|
|
121
|
+
});
|
|
122
|
+
const result = readonly(state);
|
|
123
|
+
onScopeDispose(dispose);
|
|
124
|
+
if ((_options$immediate = options.immediate) !== null && _options$immediate !== void 0 ? _options$immediate : true) refresh();
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { useAsyncDerivation };
|
|
130
|
+
//# sourceMappingURL=asyncDerivation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncDerivation.mjs","names":[],"sources":["../../../src/reactivity/asyncDerivation.ts"],"sourcesContent":["import { AbortControllerPolyfill } from '@wevu/web-apis/abort'\nimport { batch, onScopeDispose, runWithoutTracking } from './core'\nimport { reactive } from './reactive'\nimport { readonly } from './readonly'\n\n/** 异步派生状态的生命周期阶段。 */\nexport type AsyncDerivationStatus\n = | 'idle'\n | 'initial-pending'\n | 'ready'\n | 'refreshing'\n | 'error'\n | 'disposed'\n\n/** 传给异步加载函数的当前任务上下文。 */\nexport interface AsyncDerivationContext {\n readonly signal: AbortSignal\n}\n\n/** `useAsyncDerivation()` 的配置。 */\nexport interface UseAsyncDerivationOptions {\n immediate?: boolean\n}\n\ntype AsyncDerivationIdleState<TStatus extends 'idle' | 'initial-pending' | 'disposed'> = Readonly<{\n status: TStatus\n value: undefined\n error: undefined\n}>\n\ntype AsyncDerivationReadyState<T, TStatus extends 'ready' | 'refreshing'> = Readonly<{\n status: TStatus\n value: T\n error: undefined\n}>\n\ntype AsyncDerivationErrorState<T> = Readonly<{\n status: 'error'\n value: T | undefined\n error: unknown\n}>\n\n/** 模板可观察的只读异步派生状态。 */\nexport type AsyncDerivationState<T>\n = | AsyncDerivationIdleState<'idle'>\n | AsyncDerivationIdleState<'initial-pending'>\n | AsyncDerivationIdleState<'disposed'>\n | AsyncDerivationReadyState<T, 'ready'>\n | AsyncDerivationReadyState<T, 'refreshing'>\n | AsyncDerivationErrorState<T>\n\ntype AsyncDerivationControls = Readonly<{\n refresh: () => Promise<void>\n dispose: () => void\n}>\n\n/** 异步派生状态及其非枚举控制方法。 */\nexport type AsyncDerivation<T> = AsyncDerivationState<T> & AsyncDerivationControls\n\ninterface MutableAsyncDerivationState<T> {\n status: AsyncDerivationStatus\n value: T | undefined\n error: unknown\n}\n\ninterface AsyncDerivationCycle {\n readonly promise: Promise<void>\n readonly resolve: () => void\n}\n\nconst RESOLVED_PROMISE: Promise<void> = Promise.resolve()\n\nfunction createAsyncDerivationCycle(): AsyncDerivationCycle {\n let resolve!: () => void\n const promise = new Promise<void>((settle) => {\n resolve = settle\n })\n return { promise, resolve }\n}\n\n/**\n * 创建面向静态 WXML 数据绑定的异步派生状态。\n * 加载错误通过 `status` 与 `error` 暴露,`refresh()` 始终正常完成。\n */\nexport function useAsyncDerivation<T>(\n loader: (context: AsyncDerivationContext) => T | PromiseLike<T>,\n options: UseAsyncDerivationOptions = {},\n): AsyncDerivation<T> {\n const storage: MutableAsyncDerivationState<T> = {\n status: 'idle',\n value: undefined,\n error: undefined,\n }\n const state = reactive(storage)\n let activeController: AbortController | undefined\n let activeCycle: AsyncDerivationCycle | undefined\n let generation = 0\n let hasValue = false\n let disposed = false\n\n function settleLatestCycle(completedGeneration: number) {\n if (disposed || completedGeneration !== generation) {\n return\n }\n const cycle = activeCycle\n activeCycle = undefined\n cycle?.resolve()\n }\n\n function commitValue(completedGeneration: number, value: T) {\n if (disposed || completedGeneration !== generation) {\n return\n }\n activeController = undefined\n hasValue = true\n try {\n batch(() => {\n state.status = 'ready'\n state.value = value\n state.error = undefined\n })\n }\n finally {\n settleLatestCycle(completedGeneration)\n }\n }\n\n function commitError(completedGeneration: number, error: unknown) {\n if (disposed || completedGeneration !== generation) {\n return\n }\n activeController = undefined\n try {\n batch(() => {\n state.status = 'error'\n state.error = error\n if (!hasValue) {\n state.value = undefined\n }\n })\n }\n finally {\n settleLatestCycle(completedGeneration)\n }\n }\n\n function refresh(): Promise<void> {\n if (disposed) {\n return RESOLVED_PROMISE\n }\n\n const cycle = activeCycle ?? createAsyncDerivationCycle()\n activeCycle = cycle\n const currentGeneration = ++generation\n const previousController = activeController\n // eslint-disable-next-line mini-program/no-implicit-runtime-polyfill -- 缺失宿主实现时显式回退兼容层。\n const Controller = typeof AbortController === 'function' ? AbortController : AbortControllerPolyfill\n const controller = new Controller() as unknown as AbortController\n activeController = controller\n try {\n previousController?.abort()\n }\n catch {\n // 原生 EventTarget 不把 abort listener 异常传播给调用者,兼容实现保持相同控制流。\n }\n\n if (disposed || currentGeneration !== generation) {\n return cycle.promise\n }\n\n batch(() => {\n state.status = hasValue ? 'refreshing' : 'initial-pending'\n state.error = undefined\n })\n\n if (disposed || currentGeneration !== generation) {\n return cycle.promise\n }\n\n runWithoutTracking(() => {\n // 自有 Promise 避免原生 Promise 的身份快路径把 then 访问移出收养边界。\n const task = new Promise<T>((resolve) => {\n resolve(loader({ signal: controller.signal }))\n })\n void task.then(\n value => commitValue(currentGeneration, value),\n error => commitError(currentGeneration, error),\n ).catch((error) => {\n // 观察者异常交给宿主报告,不改写加载结果,也不阻塞 refresh 的完成。\n setTimeout(() => {\n throw error\n }, 0)\n })\n })\n return cycle.promise\n }\n\n function dispose() {\n if (disposed) {\n return\n }\n disposed = true\n generation += 1\n const controller = activeController\n activeController = undefined\n try {\n controller?.abort()\n }\n catch {\n // dispose 必须完成状态清理和 waiter 结算,不能被 listener 异常中断。\n }\n try {\n batch(() => {\n state.status = 'disposed'\n state.value = undefined\n state.error = undefined\n })\n }\n finally {\n hasValue = false\n const cycle = activeCycle\n activeCycle = undefined\n cycle?.resolve()\n }\n }\n\n Object.defineProperties(storage, {\n refresh: {\n value: refresh,\n },\n dispose: {\n value: dispose,\n },\n })\n\n const result = readonly(state) as AsyncDerivation<T>\n onScopeDispose(dispose)\n if (options.immediate ?? true) {\n void refresh()\n }\n return result\n}\n"],"mappings":";;;;;;AAsEA,MAAM,mBAAkC,QAAQ,QAAQ;AAExD,SAAS,6BAAmD;CAC1D,IAAI;CAIJ,OAAO;EAAE,aAHW,SAAe,WAAW;GAC5C,UAAU;EACZ,CACe;EAAG;CAAQ;AAC5B;;;;;AAMA,SAAgB,mBACd,QACA,UAAqC,CAAC,GAClB;;CACpB,MAAM,UAA0C;EAC9C,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,MAAM,QAAQ,SAAS,OAAO;CAC9B,IAAI;CACJ,IAAI;CACJ,IAAI,aAAa;CACjB,IAAI,WAAW;CACf,IAAI,WAAW;CAEf,SAAS,kBAAkB,qBAA6B;EACtD,IAAI,YAAY,wBAAwB,YACtC;EAEF,MAAM,QAAQ;EACd,cAAc;EACd,4CAAO,QAAQ;CACjB;CAEA,SAAS,YAAY,qBAA6B,OAAU;EAC1D,IAAI,YAAY,wBAAwB,YACtC;EAEF,mBAAmB;EACnB,WAAW;EACX,IAAI;GACF,YAAY;IACV,MAAM,SAAS;IACf,MAAM,QAAQ;IACd,MAAM,QAAQ;GAChB,CAAC;EACH,UACQ;GACN,kBAAkB,mBAAmB;EACvC;CACF;CAEA,SAAS,YAAY,qBAA6B,OAAgB;EAChE,IAAI,YAAY,wBAAwB,YACtC;EAEF,mBAAmB;EACnB,IAAI;GACF,YAAY;IACV,MAAM,SAAS;IACf,MAAM,QAAQ;IACd,IAAI,CAAC,UACH,MAAM,QAAQ;GAElB,CAAC;EACH,UACQ;GACN,kBAAkB,mBAAmB;EACvC;CACF;CAEA,SAAS,UAAyB;;EAChC,IAAI,UACF,OAAO;EAGT,MAAM,wBAAQ,kEAAe,2BAA2B;EACxD,cAAc;EACd,MAAM,oBAAoB,EAAE;EAC5B,MAAM,qBAAqB;EAG3B,MAAM,aAAa,KADA,OAAO,oBAAoB,aAAa,kBAAkB,yBAC3C;EAClC,mBAAmB;EACnB,IAAI;GACF,mFAAoB,MAAM;EAC5B,kBACM,CAEN;EAEA,IAAI,YAAY,sBAAsB,YACpC,OAAO,MAAM;EAGf,YAAY;GACV,MAAM,SAAS,WAAW,eAAe;GACzC,MAAM,QAAQ;EAChB,CAAC;EAED,IAAI,YAAY,sBAAsB,YACpC,OAAO,MAAM;EAGf,yBAAyB;GAKvB,AAAK,IAHY,SAAY,YAAY;IACvC,QAAQ,OAAO,EAAE,QAAQ,WAAW,OAAO,CAAC,CAAC;GAC/C,CACQ,CAAC,CAAC,MACR,UAAS,YAAY,mBAAmB,KAAK,IAC7C,UAAS,YAAY,mBAAmB,KAAK,CAC/C,CAAC,CAAC,OAAO,UAAU;IAEjB,iBAAiB;KACf,MAAM;IACR,GAAG,CAAC;GACN,CAAC;EACH,CAAC;EACD,OAAO,MAAM;CACf;CAEA,SAAS,UAAU;EACjB,IAAI,UACF;EAEF,WAAW;EACX,cAAc;EACd,MAAM,aAAa;EACnB,mBAAmB;EACnB,IAAI;GACF,2DAAY,MAAM;EACpB,mBACM,CAEN;EACA,IAAI;GACF,YAAY;IACV,MAAM,SAAS;IACf,MAAM,QAAQ;IACd,MAAM,QAAQ;GAChB,CAAC;EACH,UACQ;GACN,WAAW;GACX,MAAM,QAAQ;GACd,cAAc;GACd,4CAAO,QAAQ;EACjB;CACF;CAEA,OAAO,iBAAiB,SAAS;EAC/B,SAAS,EACP,OAAO,QACT;EACA,SAAS,EACP,OAAO,QACT;CACF,CAAC;CAED,MAAM,SAAS,SAAS,KAAK;CAC7B,eAAe,OAAO;CACtB,0BAAI,QAAQ,4EAAa,MACvB,AAAK,QAAQ;CAEf,OAAO;AACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ref } from "./ref.mjs";
|
|
2
|
+
//#region src/reactivity/computed.d.ts
|
|
3
|
+
export type ComputedGetter<T> = () => T;
|
|
4
|
+
export type ComputedSetter<T> = (value: T) => void;
|
|
5
|
+
interface BaseComputedRef<T, S = T> extends Ref<T, S> {
|
|
6
|
+
[key: symbol]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface ComputedRef<T = any> extends BaseComputedRef<T> {
|
|
9
|
+
readonly value: T;
|
|
10
|
+
}
|
|
11
|
+
export interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
|
|
12
|
+
value: T;
|
|
13
|
+
}
|
|
14
|
+
export interface WritableComputedOptions<T> {
|
|
15
|
+
get: ComputedGetter<T>;
|
|
16
|
+
set: ComputedSetter<T>;
|
|
17
|
+
}
|
|
18
|
+
export declare function computed<T>(getter: ComputedGetter<T>): ComputedRef<T>;
|
|
19
|
+
export declare function computed<T>(options: WritableComputedOptions<T>): WritableComputedRef<T>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//# sourceMappingURL=computed.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createComputedEffect, track, trigger } from "./core.mjs";
|
|
2
2
|
import { markAsRef } from "./ref.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/reactivity/computed.ts
|
|
@@ -32,7 +32,7 @@ function computed(getterOrOptions) {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
markAsRef(obj);
|
|
35
|
-
runner =
|
|
35
|
+
runner = createComputedEffect(getter, {
|
|
36
36
|
lazy: true,
|
|
37
37
|
scheduler: () => {
|
|
38
38
|
if (!dirty) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.mjs","names":[],"sources":["../../../src/reactivity/computed.ts"],"sourcesContent":["import type { ReactiveEffect } from './core'\nimport type { Ref } from './ref'\nimport {
|
|
1
|
+
{"version":3,"file":"computed.mjs","names":[],"sources":["../../../src/reactivity/computed.ts"],"sourcesContent":["import type { ReactiveEffect } from './core'\nimport type { Ref } from './ref'\nimport { createComputedEffect, track, trigger } from './core'\nimport { markAsRef } from './ref'\n\nexport type ComputedGetter<T> = () => T\nexport type ComputedSetter<T> = (value: T) => void\n\ninterface BaseComputedRef<T, S = T> extends Ref<T, S> {\n [key: symbol]: any\n}\n\nexport interface ComputedRef<T = any> extends BaseComputedRef<T> {\n readonly value: T\n}\n\nexport interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {\n value: T\n}\n\nexport interface WritableComputedOptions<T> {\n get: ComputedGetter<T>\n set: ComputedSetter<T>\n}\n\nexport function computed<T>(getter: ComputedGetter<T>): ComputedRef<T>\nexport function computed<T>(options: WritableComputedOptions<T>): WritableComputedRef<T>\nexport function computed<T>(\n getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>,\n): ComputedRef<T> | WritableComputedRef<T> {\n let getter: ComputedGetter<T>\n let setter: ComputedSetter<T>\n const onlyGetter = typeof getterOrOptions === 'function'\n if (onlyGetter) {\n getter = getterOrOptions as ComputedGetter<T>\n setter = () => {\n throw new Error('计算属性是只读的')\n }\n }\n else {\n getter = (getterOrOptions as WritableComputedOptions<T>).get\n setter = (getterOrOptions as WritableComputedOptions<T>).set\n }\n let value: T\n let dirty = true\n let runner: ReactiveEffect<T>\n const obj: any = {\n get value() {\n if (dirty) {\n value = runner()\n dirty = false\n }\n track(obj, 'value')\n return value\n },\n set value(newValue: T) {\n setter(newValue)\n },\n }\n markAsRef(obj)\n runner = createComputedEffect(getter, {\n lazy: true,\n scheduler: () => {\n if (!dirty) {\n dirty = true\n trigger(obj, 'value')\n }\n },\n })\n return (onlyGetter ? obj as ComputedRef<T> : obj as WritableComputedRef<T>)\n}\n"],"mappings":";;;;AA2BA,SAAgB,SACd,iBACyC;CACzC,IAAI;CACJ,IAAI;CACJ,MAAM,aAAa,OAAO,oBAAoB;CAC9C,IAAI,YAAY;EACd,SAAS;EACT,eAAe;GACb,MAAM,IAAI,MAAM,UAAU;EAC5B;CACF,OACK;EACH,SAAU,gBAA+C;EACzD,SAAU,gBAA+C;CAC3D;CACA,IAAI;CACJ,IAAI,QAAQ;CACZ,IAAI;CACJ,MAAM,MAAW;EACf,IAAI,QAAQ;GACV,IAAI,OAAO;IACT,QAAQ,OAAO;IACf,QAAQ;GACV;GACA,MAAM,KAAK,OAAO;GAClB,OAAO;EACT;EACA,IAAI,MAAM,UAAa;GACrB,OAAO,QAAQ;EACjB;CACF;CACA,UAAU,GAAG;CACb,SAAS,qBAAqB,QAAQ;EACpC,MAAM;EACN,iBAAiB;GACf,IAAI,CAAC,OAAO;IACV,QAAQ;IACR,QAAQ,KAAK,OAAO;GACtB;EACF;CACF,CAAC;CACD,OAAQ,aAAa,MAAwB;AAC/C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/reactivity/core.d.ts
|
|
2
|
+
export type EffectScheduler = () => void;
|
|
3
|
+
export type Dep = Set<ReactiveEffect>;
|
|
4
|
+
export interface ReactiveEffect<T = any> {
|
|
5
|
+
(): T;
|
|
6
|
+
deps: Dep[];
|
|
7
|
+
scheduler?: EffectScheduler;
|
|
8
|
+
active: boolean;
|
|
9
|
+
_running: boolean;
|
|
10
|
+
_fn: () => T;
|
|
11
|
+
_computed?: boolean;
|
|
12
|
+
onStop?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function startBatch(): void;
|
|
15
|
+
export declare function endBatch(): void;
|
|
16
|
+
export declare function batch<T>(fn: () => T): T;
|
|
17
|
+
export declare function stop(runner: ReactiveEffect): void;
|
|
18
|
+
export interface EffectScope {
|
|
19
|
+
active: boolean;
|
|
20
|
+
effects: ReactiveEffect[];
|
|
21
|
+
cleanups: (() => void)[];
|
|
22
|
+
run: <T>(fn: () => T) => T | undefined;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function effectScope(detached?: boolean): EffectScope;
|
|
26
|
+
export declare function getCurrentScope(): EffectScope | undefined;
|
|
27
|
+
export declare function onScopeDispose(fn: () => void): void;
|
|
28
|
+
export interface EffectOptions {
|
|
29
|
+
scheduler?: EffectScheduler;
|
|
30
|
+
lazy?: boolean;
|
|
31
|
+
onStop?: () => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function effect<T = any>(fn: () => T, options?: EffectOptions): ReactiveEffect<T>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//# sourceMappingURL=core.d.mts.map
|
|
@@ -1,26 +1,86 @@
|
|
|
1
1
|
import { queueJob } from "../scheduler.mjs";
|
|
2
|
-
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
+
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/defineProperty.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/reactivity/core.ts
|
|
5
5
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
let activeEffect = null;
|
|
7
7
|
const effectStack = [];
|
|
8
|
+
let shouldTrack = true;
|
|
9
|
+
let activeEffectScope;
|
|
8
10
|
let batchDepth = 0;
|
|
11
|
+
let isFlushingBatch = false;
|
|
9
12
|
const batchedEffects = /* @__PURE__ */ new Set();
|
|
13
|
+
const batchedCallbacks = /* @__PURE__ */ new Set();
|
|
14
|
+
function runScheduledEffect(ef) {
|
|
15
|
+
if (!ef.active) return;
|
|
16
|
+
if (ef.scheduler) {
|
|
17
|
+
const previousScope = activeEffectScope;
|
|
18
|
+
activeEffectScope = ef._scope;
|
|
19
|
+
try {
|
|
20
|
+
ef.scheduler();
|
|
21
|
+
} finally {
|
|
22
|
+
activeEffectScope = previousScope;
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
ef();
|
|
27
|
+
}
|
|
28
|
+
/** 在当前批次的同步副作用全部完成后执行包内通知。 */
|
|
29
|
+
function queueBatchCallback(callback) {
|
|
30
|
+
if (batchDepth > 0 || isFlushingBatch) {
|
|
31
|
+
batchedCallbacks.add(callback);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
batchedCallbacks.delete(callback);
|
|
35
|
+
callback();
|
|
36
|
+
}
|
|
10
37
|
function startBatch() {
|
|
11
38
|
batchDepth++;
|
|
12
39
|
}
|
|
40
|
+
function takeBatchedEffect(effects) {
|
|
41
|
+
const next = effects.values().next();
|
|
42
|
+
if (next.done) return;
|
|
43
|
+
effects.delete(next.value);
|
|
44
|
+
return next.value;
|
|
45
|
+
}
|
|
13
46
|
function flushBatchedEffects() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
47
|
+
let firstError;
|
|
48
|
+
let hasError = false;
|
|
49
|
+
isFlushingBatch = true;
|
|
50
|
+
try {
|
|
51
|
+
while (batchedEffects.size) {
|
|
52
|
+
const effect = takeBatchedEffect(batchedEffects);
|
|
53
|
+
if (!effect) continue;
|
|
54
|
+
try {
|
|
55
|
+
runScheduledEffect(effect);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (!hasError) {
|
|
58
|
+
firstError = error;
|
|
59
|
+
hasError = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} finally {
|
|
64
|
+
isFlushingBatch = false;
|
|
65
|
+
}
|
|
66
|
+
while (batchedCallbacks.size) {
|
|
67
|
+
const callback = batchedCallbacks.values().next().value;
|
|
68
|
+
batchedCallbacks.delete(callback);
|
|
69
|
+
try {
|
|
70
|
+
callback();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (!hasError) {
|
|
73
|
+
firstError = error;
|
|
74
|
+
hasError = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
18
77
|
}
|
|
78
|
+
if (hasError) throw firstError;
|
|
19
79
|
}
|
|
20
80
|
function endBatch() {
|
|
21
81
|
if (batchDepth === 0) return;
|
|
22
82
|
batchDepth--;
|
|
23
|
-
if (batchDepth === 0) flushBatchedEffects();
|
|
83
|
+
if (batchDepth === 0 && !isFlushingBatch) flushBatchedEffects();
|
|
24
84
|
}
|
|
25
85
|
function batch(fn) {
|
|
26
86
|
startBatch();
|
|
@@ -42,7 +102,6 @@ function stop(runner) {
|
|
|
42
102
|
cleanupEffect(runner);
|
|
43
103
|
(_runner$onStop = runner.onStop) === null || _runner$onStop === void 0 || _runner$onStop.call(runner);
|
|
44
104
|
}
|
|
45
|
-
let activeEffectScope;
|
|
46
105
|
var EffectScopeImpl = class {
|
|
47
106
|
constructor(detached = false) {
|
|
48
107
|
this.detached = detached;
|
|
@@ -53,6 +112,10 @@ var EffectScopeImpl = class {
|
|
|
53
112
|
_defineProperty(this, "scopes", void 0);
|
|
54
113
|
if (!detached && activeEffectScope) {
|
|
55
114
|
var _activeEffectScope;
|
|
115
|
+
if (!activeEffectScope.active) {
|
|
116
|
+
this.active = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
56
119
|
this.parent = activeEffectScope;
|
|
57
120
|
((_activeEffectScope = activeEffectScope).scopes || (_activeEffectScope.scopes = [])).push(this);
|
|
58
121
|
}
|
|
@@ -68,22 +131,50 @@ var EffectScopeImpl = class {
|
|
|
68
131
|
}
|
|
69
132
|
}
|
|
70
133
|
stop() {
|
|
71
|
-
var _this$parent;
|
|
72
134
|
if (!this.active) return;
|
|
73
135
|
this.active = false;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
const prev = activeEffectScope;
|
|
137
|
+
activeEffectScope = this;
|
|
138
|
+
let firstError;
|
|
139
|
+
let hasError = false;
|
|
140
|
+
const recordError = (error) => {
|
|
141
|
+
if (hasError) return;
|
|
142
|
+
firstError = error;
|
|
143
|
+
hasError = true;
|
|
144
|
+
};
|
|
145
|
+
try {
|
|
146
|
+
const effects = this.effects.splice(0);
|
|
147
|
+
for (const effect of effects) try {
|
|
148
|
+
stop(effect);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
recordError(error);
|
|
151
|
+
}
|
|
152
|
+
const cleanups = this.cleanups.splice(0);
|
|
153
|
+
for (const cleanup of cleanups) try {
|
|
154
|
+
cleanup();
|
|
155
|
+
} catch (error) {
|
|
156
|
+
recordError(error);
|
|
157
|
+
}
|
|
158
|
+
const scopes = this.scopes;
|
|
159
|
+
this.scopes = void 0;
|
|
160
|
+
if (scopes) {
|
|
161
|
+
for (const scope of scopes) try {
|
|
162
|
+
scope.stop();
|
|
163
|
+
} catch (error) {
|
|
164
|
+
recordError(error);
|
|
165
|
+
}
|
|
166
|
+
scopes.length = 0;
|
|
167
|
+
}
|
|
168
|
+
} finally {
|
|
169
|
+
var _this$parent;
|
|
170
|
+
if ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.scopes) {
|
|
171
|
+
const index = this.parent.scopes.indexOf(this);
|
|
172
|
+
if (index >= 0) this.parent.scopes.splice(index, 1);
|
|
173
|
+
}
|
|
174
|
+
this.parent = void 0;
|
|
175
|
+
activeEffectScope = prev;
|
|
85
176
|
}
|
|
86
|
-
|
|
177
|
+
if (hasError) throw firstError;
|
|
87
178
|
}
|
|
88
179
|
};
|
|
89
180
|
function effectScope(detached = false) {
|
|
@@ -95,15 +186,37 @@ function getCurrentScope() {
|
|
|
95
186
|
function onScopeDispose(fn) {
|
|
96
187
|
if (activeEffectScope === null || activeEffectScope === void 0 ? void 0 : activeEffectScope.active) activeEffectScope.cleanups.push(fn);
|
|
97
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* 在不把读取记录到当前副作用的情况下执行函数。
|
|
191
|
+
* 函数内部主动运行的新副作用仍会正常收集自己的依赖。
|
|
192
|
+
*/
|
|
193
|
+
function runWithoutTracking(fn) {
|
|
194
|
+
const previousShouldTrack = shouldTrack;
|
|
195
|
+
shouldTrack = false;
|
|
196
|
+
try {
|
|
197
|
+
return fn();
|
|
198
|
+
} finally {
|
|
199
|
+
shouldTrack = previousShouldTrack;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
98
202
|
function recordEffectScope(effect) {
|
|
99
|
-
if (activeEffectScope
|
|
203
|
+
if (!activeEffectScope) return;
|
|
204
|
+
if (activeEffectScope.active) {
|
|
205
|
+
activeEffectScope.effects.push(effect);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
stop(effect);
|
|
100
209
|
}
|
|
101
210
|
function createReactiveEffect(fn, options = {}) {
|
|
102
211
|
const effect = function reactiveEffect() {
|
|
103
212
|
if (!effect.active) return fn();
|
|
104
213
|
if (effect._running) return fn();
|
|
105
214
|
cleanupEffect(effect);
|
|
215
|
+
const previousScope = activeEffectScope;
|
|
216
|
+
activeEffectScope = effect._scope;
|
|
217
|
+
const previousShouldTrack = shouldTrack;
|
|
106
218
|
try {
|
|
219
|
+
shouldTrack = true;
|
|
107
220
|
effect._running = true;
|
|
108
221
|
effectStack.push(effect);
|
|
109
222
|
activeEffect = effect;
|
|
@@ -113,6 +226,8 @@ function createReactiveEffect(fn, options = {}) {
|
|
|
113
226
|
effectStack.pop();
|
|
114
227
|
activeEffect = (_effectStack = effectStack[effectStack.length - 1]) !== null && _effectStack !== void 0 ? _effectStack : null;
|
|
115
228
|
effect._running = false;
|
|
229
|
+
activeEffectScope = previousScope;
|
|
230
|
+
shouldTrack = previousShouldTrack;
|
|
116
231
|
}
|
|
117
232
|
};
|
|
118
233
|
effect.deps = [];
|
|
@@ -121,16 +236,24 @@ function createReactiveEffect(fn, options = {}) {
|
|
|
121
236
|
effect.active = true;
|
|
122
237
|
effect._running = false;
|
|
123
238
|
effect._fn = fn;
|
|
239
|
+
effect._scope = activeEffectScope;
|
|
124
240
|
return effect;
|
|
125
241
|
}
|
|
242
|
+
function createEffect(fn, options, computed) {
|
|
243
|
+
const runner = createReactiveEffect(fn, options);
|
|
244
|
+
runner._computed = computed;
|
|
245
|
+
recordEffectScope(runner);
|
|
246
|
+
if (!options.lazy) runner();
|
|
247
|
+
return runner;
|
|
248
|
+
}
|
|
126
249
|
function effect(fn, options = {}) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
250
|
+
return createEffect(fn, options, false);
|
|
251
|
+
}
|
|
252
|
+
function createComputedEffect(fn, options = {}) {
|
|
253
|
+
return createEffect(fn, options, true);
|
|
131
254
|
}
|
|
132
255
|
function track(target, key) {
|
|
133
|
-
if (!activeEffect) return;
|
|
256
|
+
if (!shouldTrack || !activeEffect) return;
|
|
134
257
|
let depsMap = targetMap.get(target);
|
|
135
258
|
if (!depsMap) {
|
|
136
259
|
depsMap = /* @__PURE__ */ new Map();
|
|
@@ -147,15 +270,16 @@ function track(target, key) {
|
|
|
147
270
|
}
|
|
148
271
|
}
|
|
149
272
|
function scheduleEffect(ef) {
|
|
150
|
-
if (ef.
|
|
151
|
-
|
|
273
|
+
if (ef._running) return;
|
|
274
|
+
if (ef._computed) {
|
|
275
|
+
runScheduledEffect(ef);
|
|
152
276
|
return;
|
|
153
277
|
}
|
|
154
|
-
if (batchDepth > 0) {
|
|
278
|
+
if (batchDepth > 0 || isFlushingBatch) {
|
|
155
279
|
batchedEffects.add(ef);
|
|
156
280
|
return;
|
|
157
281
|
}
|
|
158
|
-
ef
|
|
282
|
+
runScheduledEffect(ef);
|
|
159
283
|
}
|
|
160
284
|
function trigger(target, key) {
|
|
161
285
|
const depsMap = targetMap.get(target);
|
|
@@ -169,7 +293,7 @@ function trigger(target, key) {
|
|
|
169
293
|
effectsToRun.forEach(scheduleEffect);
|
|
170
294
|
}
|
|
171
295
|
function trackEffects(dep) {
|
|
172
|
-
if (!activeEffect) return;
|
|
296
|
+
if (!shouldTrack || !activeEffect) return;
|
|
173
297
|
if (!dep.has(activeEffect)) {
|
|
174
298
|
dep.add(activeEffect);
|
|
175
299
|
activeEffect.deps.push(dep);
|
|
@@ -180,5 +304,5 @@ function triggerEffects(dep) {
|
|
|
180
304
|
}
|
|
181
305
|
|
|
182
306
|
//#endregion
|
|
183
|
-
export { batch, createReactiveEffect, effect, effectScope, endBatch, getCurrentScope, onScopeDispose, queueJob, startBatch, stop, track, trackEffects, trigger, triggerEffects };
|
|
307
|
+
export { batch, createComputedEffect, createReactiveEffect, effect, effectScope, endBatch, getCurrentScope, onScopeDispose, queueBatchCallback, queueJob, runWithoutTracking, startBatch, stop, track, trackEffects, trigger, triggerEffects };
|
|
184
308
|
//# sourceMappingURL=core.mjs.map
|