wevu 7.2.2 → 7.3.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/README.md +6 -0
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/defineProperty.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPrimitive.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPropertyKey.mjs +1 -1
- package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/typeof.mjs +1 -1
- package/dist/dev/internal-runtime.d.mts +2 -1
- package/dist/dev/internal-runtime.mjs +3 -2
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/reactivity/asyncDerivation.mjs +8 -10
- package/dist/dev/reactivity/asyncDerivation.mjs.map +1 -1
- package/dist/dev/reactivity/core.mjs +5 -8
- package/dist/dev/reactivity/core.mjs.map +1 -1
- package/dist/dev/reactivity/reactive/patch.mjs +3 -3
- package/dist/dev/reactivity/reactive/patch.mjs.map +1 -1
- package/dist/dev/reactivity/reactive/patchState.mjs +4 -8
- package/dist/dev/reactivity/reactive/patchState.mjs.map +1 -1
- package/dist/dev/reactivity/reactive/shared.mjs +1 -2
- package/dist/dev/reactivity/reactive/shared.mjs.map +1 -1
- package/dist/dev/reactivity/reactive.mjs +5 -10
- package/dist/dev/reactivity/reactive.mjs.map +1 -1
- package/dist/dev/reactivity/ref.mjs +2 -2
- package/dist/dev/reactivity/ref.mjs.map +1 -1
- package/dist/dev/reactivity/shallowRef.mjs +1 -1
- package/dist/dev/reactivity/shallowRef.mjs.map +1 -1
- package/dist/dev/reactivity/watch/helpers.mjs +1 -1
- package/dist/dev/reactivity/watch/helpers.mjs.map +1 -1
- package/dist/dev/reactivity/watch.mjs +6 -8
- package/dist/dev/reactivity/watch.mjs.map +1 -1
- package/dist/dev/router/createRouter.mjs +17 -24
- package/dist/dev/router/createRouter.mjs.map +1 -1
- package/dist/dev/router/initialNavigation.mjs +18 -16
- package/dist/dev/router/initialNavigation.mjs.map +1 -1
- package/dist/dev/router/instance.mjs +1 -2
- package/dist/dev/router/instance.mjs.map +1 -1
- package/dist/dev/router/navigationCore.mjs +2 -2
- package/dist/dev/router/navigationCore.mjs.map +1 -1
- package/dist/dev/router/navigationResult.mjs +7 -10
- package/dist/dev/router/navigationResult.mjs.map +1 -1
- package/dist/dev/router/navigationTarget.mjs +1 -3
- package/dist/dev/router/navigationTarget.mjs.map +1 -1
- package/dist/dev/router/resolve.mjs +3 -4
- package/dist/dev/router/resolve.mjs.map +1 -1
- package/dist/dev/router/routeRegistry.mjs +1 -1
- package/dist/dev/router/routeRegistry.mjs.map +1 -1
- package/dist/dev/router/routeSync.mjs +1 -1
- package/dist/dev/router/routeSync.mjs.map +1 -1
- package/dist/dev/router/useRoute.mjs +12 -19
- package/dist/dev/router/useRoute.mjs.map +1 -1
- package/dist/dev/routerInternal/location.mjs +2 -3
- package/dist/dev/routerInternal/location.mjs.map +1 -1
- package/dist/dev/routerInternal/params.mjs +2 -3
- package/dist/dev/routerInternal/params.mjs.map +1 -1
- package/dist/dev/routerInternal/records.mjs +1 -1
- package/dist/dev/routerInternal/records.mjs.map +1 -1
- package/dist/dev/routerInternal/recordsWarnings.mjs +1 -2
- package/dist/dev/routerInternal/recordsWarnings.mjs.map +1 -1
- package/dist/dev/runtime/app/context.mjs +13 -26
- package/dist/dev/runtime/app/context.mjs.map +1 -1
- package/dist/dev/runtime/app/diagnostics.mjs +2 -4
- package/dist/dev/runtime/app/diagnostics.mjs.map +1 -1
- package/dist/dev/runtime/app/mount.mjs +27 -33
- package/dist/dev/runtime/app/mount.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/commitTracker.mjs +5 -9
- package/dist/dev/runtime/app/setData/commitTracker.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/patchScheduler.mjs +2 -4
- package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/payload.mjs +2 -3
- package/dist/dev/runtime/app/setData/payload.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/scheduler.mjs +7 -9
- package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -1
- package/dist/dev/runtime/app/setData/snapshot.mjs +5 -6
- package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/app/setDataOptions.mjs +26 -27
- package/dist/dev/runtime/app/setDataOptions.mjs.map +1 -1
- package/dist/dev/runtime/app.mjs +9 -9
- package/dist/dev/runtime/app.mjs.map +1 -1
- package/dist/dev/runtime/bindingManifest.mjs +6 -14
- package/dist/dev/runtime/bindingManifest.mjs.map +1 -1
- package/dist/dev/runtime/capabilities.d.mts +4 -1
- package/dist/dev/runtime/capabilities.mjs.map +1 -1
- package/dist/dev/runtime/css.mjs +4 -8
- package/dist/dev/runtime/css.mjs.map +1 -1
- package/dist/dev/runtime/defaults.mjs +4 -4
- package/dist/dev/runtime/defaults.mjs.map +1 -1
- package/dist/dev/runtime/define/initialComputed.mjs +5 -5
- package/dist/dev/runtime/define/initialComputed.mjs.map +1 -1
- package/dist/dev/runtime/define/options.mjs +10 -12
- package/dist/dev/runtime/define/options.mjs.map +1 -1
- package/dist/dev/runtime/define/props.mjs +4 -5
- package/dist/dev/runtime/define/props.mjs.map +1 -1
- package/dist/dev/runtime/define/scopedSlotOptions.mjs +43 -61
- package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -1
- package/dist/dev/runtime/define/setupResult.mjs +17 -28
- package/dist/dev/runtime/define/setupResult.mjs.map +1 -1
- package/dist/dev/runtime/define.mjs +9 -12
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/diff.mjs +9 -11
- package/dist/dev/runtime/diff.mjs.map +1 -1
- package/dist/dev/runtime/disposables.mjs +2 -2
- package/dist/dev/runtime/disposables.mjs.map +1 -1
- package/dist/dev/runtime/elementIntersectionObserver.mjs +16 -24
- package/dist/dev/runtime/elementIntersectionObserver.mjs.map +1 -1
- package/dist/dev/runtime/features/inlineEvents.mjs +2 -3
- package/dist/dev/runtime/features/inlineEvents.mjs.map +1 -1
- package/dist/dev/runtime/features/jsxIslands.d.mts +7 -0
- package/dist/dev/runtime/features/jsxIslands.mjs +20 -0
- package/dist/dev/runtime/features/jsxIslands.mjs.map +1 -0
- package/dist/dev/runtime/features/layout.mjs +2 -3
- package/dist/dev/runtime/features/layout.mjs.map +1 -1
- package/dist/dev/runtime/features/publicLayout.mjs +2 -6
- package/dist/dev/runtime/features/publicLayout.mjs.map +1 -1
- package/dist/dev/runtime/features/scopedSlots.mjs +5 -9
- package/dist/dev/runtime/features/scopedSlots.mjs.map +1 -1
- package/dist/dev/runtime/features/templateRefs.mjs +1 -1
- package/dist/dev/runtime/features/templateRefs.mjs.map +1 -1
- package/dist/dev/runtime/hooks/base.mjs +21 -32
- package/dist/dev/runtime/hooks/base.mjs.map +1 -1
- package/dist/dev/runtime/inlineDataset.mjs +1 -2
- package/dist/dev/runtime/inlineDataset.mjs.map +1 -1
- package/dist/dev/runtime/intersectionObserver.mjs +6 -6
- package/dist/dev/runtime/intersectionObserver.mjs.map +1 -1
- package/dist/dev/runtime/jsxIsland.mjs +16 -33
- package/dist/dev/runtime/jsxIsland.mjs.map +1 -1
- package/dist/dev/runtime/layoutBridge.mjs +32 -62
- package/dist/dev/runtime/layoutBridge.mjs.map +1 -1
- package/dist/dev/runtime/nativeBridge.mjs +1 -1
- package/dist/dev/runtime/nativeBridge.mjs.map +1 -1
- package/dist/dev/runtime/navigationLifecycle.mjs +24 -0
- package/dist/dev/runtime/navigationLifecycle.mjs.map +1 -0
- package/dist/dev/runtime/pageEnvironment.mjs +15 -18
- package/dist/dev/runtime/pageEnvironment.mjs.map +1 -1
- package/dist/dev/runtime/pageLayout.mjs +7 -11
- package/dist/dev/runtime/pageLayout.mjs.map +1 -1
- package/dist/dev/runtime/pageScroll.mjs +2 -3
- package/dist/dev/runtime/pageScroll.mjs.map +1 -1
- package/dist/dev/runtime/platform/current.mjs +12 -0
- package/dist/dev/runtime/platform/current.mjs.map +1 -0
- package/dist/dev/runtime/platform/generic.mjs +36 -0
- package/dist/dev/runtime/platform/generic.mjs.map +1 -0
- package/dist/dev/runtime/platform/globals.mjs +29 -0
- package/dist/dev/runtime/platform/globals.mjs.map +1 -0
- package/dist/dev/runtime/platform.mjs +15 -60
- package/dist/dev/runtime/platform.mjs.map +1 -1
- package/dist/dev/runtime/provideContext.mjs +7 -9
- package/dist/dev/runtime/provideContext.mjs.map +1 -1
- package/dist/dev/runtime/publicRuntime.mjs +4 -0
- package/dist/dev/runtime/publicRuntime.mjs.map +1 -1
- package/dist/dev/runtime/pullDownRefresh.mjs +2 -4
- package/dist/dev/runtime/pullDownRefresh.mjs.map +1 -1
- package/dist/dev/runtime/register/app.mjs +18 -19
- package/dist/dev/runtime/register/app.mjs.map +1 -1
- package/dist/dev/runtime/register/component/alipay.mjs +9 -18
- package/dist/dev/runtime/register/component/alipay.mjs.map +1 -1
- package/dist/dev/runtime/register/component/alipayRegistration.mjs +60 -0
- package/dist/dev/runtime/register/component/alipayRegistration.mjs.map +1 -0
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +8 -9
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle.mjs +7 -12
- package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -1
- package/dist/dev/runtime/register/component/methods.mjs +13 -18
- package/dist/dev/runtime/register/component/methods.mjs.map +1 -1
- package/dist/dev/runtime/register/component/options.mjs +3 -4
- package/dist/dev/runtime/register/component/options.mjs.map +1 -1
- package/dist/dev/runtime/register/component/props.mjs +25 -31
- package/dist/dev/runtime/register/component/props.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +18 -40
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerNativeDefinition.mjs +18 -60
- package/dist/dev/runtime/register/component/registerNativeDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/component.mjs +3 -5
- package/dist/dev/runtime/register/component.mjs.map +1 -1
- package/dist/dev/runtime/register/inline.mjs +8 -10
- package/dist/dev/runtime/register/inline.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +7 -8
- package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +1 -1
- package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +25 -34
- package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +6 -13
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs +2 -2
- package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs +9 -9
- package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance.mjs +74 -100
- package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +12 -15
- package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -1
- package/dist/dev/runtime/register/setup.mjs +2 -3
- package/dist/dev/runtime/register/setup.mjs.map +1 -1
- package/dist/dev/runtime/register/snapshot.mjs +1 -4
- package/dist/dev/runtime/register/snapshot.mjs.map +1 -1
- package/dist/dev/runtime/register/watch.mjs +3 -5
- package/dist/dev/runtime/register/watch.mjs.map +1 -1
- package/dist/dev/runtime/scopedSlots.mjs +14 -21
- package/dist/dev/runtime/scopedSlots.mjs.map +1 -1
- package/dist/dev/runtime/selectorQuery.mjs +5 -9
- package/dist/dev/runtime/selectorQuery.mjs.map +1 -1
- package/dist/dev/runtime/template.mjs +1 -1
- package/dist/dev/runtime/template.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs/helpers.mjs +14 -24
- package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -1
- package/dist/dev/runtime/templateRefs.mjs +8 -15
- package/dist/dev/runtime/templateRefs.mjs.map +1 -1
- package/dist/dev/runtime/uniAppHost.mjs +6 -14
- package/dist/dev/runtime/uniAppHost.mjs.map +1 -1
- package/dist/dev/runtime/updatePerformance.mjs +1 -1
- package/dist/dev/runtime/updatePerformance.mjs.map +1 -1
- package/dist/dev/runtime/use.mjs +1 -1
- package/dist/dev/runtime/use.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/context.mjs +3 -5
- package/dist/dev/runtime/vueCompat/context.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/model.mjs +9 -13
- package/dist/dev/runtime/vueCompat/model.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/router.mjs +4 -4
- package/dist/dev/runtime/vueCompat/router.mjs.map +1 -1
- package/dist/dev/runtime/vueCompat/templateRef.mjs +1 -1
- package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -1
- package/dist/dev/scheduler.mjs +3 -4
- package/dist/dev/scheduler.mjs.map +1 -1
- package/dist/dev/store/base.mjs +1 -2
- package/dist/dev/store/base.mjs.map +1 -1
- package/dist/dev/store/define/create.mjs +11 -22
- package/dist/dev/store/define/create.mjs.map +1 -1
- package/dist/dev/store/define.mjs +1 -1
- package/dist/dev/store/define.mjs.map +1 -1
- package/dist/dev/store/view.mjs +1 -1
- package/dist/dev/store/view.mjs.map +1 -1
- package/dist/internal-runtime.d.mts +2 -1
- package/dist/internal-runtime.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/reactivity/asyncDerivation.mjs +1 -1
- package/dist/reactivity/core.mjs +1 -1
- package/dist/reactivity/reactive/patch.mjs +1 -1
- package/dist/reactivity/reactive/patchState.mjs +1 -1
- package/dist/reactivity/reactive/shared.mjs +1 -1
- package/dist/reactivity/reactive.mjs +1 -1
- package/dist/reactivity/ref.mjs +1 -1
- package/dist/reactivity/shallowRef.mjs +1 -1
- package/dist/reactivity/watch/helpers.mjs +1 -1
- package/dist/reactivity/watch.mjs +1 -1
- package/dist/router/createRouter.mjs +1 -1
- package/dist/router/initialNavigation.mjs +1 -1
- package/dist/router/instance.mjs +1 -1
- package/dist/router/navigationCore.mjs +1 -1
- package/dist/router/navigationResult.mjs +1 -1
- package/dist/router/navigationTarget.mjs +1 -1
- package/dist/router/resolve.mjs +1 -1
- package/dist/router/routeRegistry.mjs +1 -1
- package/dist/router/routeSync.mjs +1 -1
- package/dist/router/useRoute.mjs +1 -1
- package/dist/routerInternal/location.mjs +1 -1
- package/dist/routerInternal/params.mjs +1 -1
- package/dist/routerInternal/records.mjs +1 -1
- package/dist/routerInternal/recordsWarnings.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.mjs +1 -1
- package/dist/runtime/app/setData/patchScheduler.mjs +1 -1
- package/dist/runtime/app/setData/payload.mjs +1 -1
- package/dist/runtime/app/setData/scheduler.mjs +1 -1
- package/dist/runtime/app/setData/snapshot.mjs +1 -1
- package/dist/runtime/app/setDataOptions.mjs +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/bindingManifest.mjs +1 -1
- package/dist/runtime/capabilities.d.mts +4 -1
- package/dist/runtime/css.mjs +1 -1
- package/dist/runtime/defaults.mjs +1 -1
- package/dist/runtime/define/initialComputed.mjs +1 -1
- package/dist/runtime/define/options.mjs +1 -1
- 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.mjs +1 -1
- package/dist/runtime/diff.mjs +1 -1
- package/dist/runtime/disposables.mjs +1 -1
- package/dist/runtime/elementIntersectionObserver.mjs +1 -1
- package/dist/runtime/features/inlineEvents.mjs +1 -1
- package/dist/runtime/features/jsxIslands.d.mts +6 -0
- package/dist/runtime/features/jsxIslands.mjs +1 -0
- package/dist/runtime/features/layout.mjs +1 -1
- package/dist/runtime/features/publicLayout.mjs +1 -1
- package/dist/runtime/features/scopedSlots.mjs +1 -1
- package/dist/runtime/features/templateRefs.mjs +1 -1
- package/dist/runtime/hooks/base.mjs +1 -1
- package/dist/runtime/inlineDataset.mjs +1 -1
- package/dist/runtime/intersectionObserver.mjs +1 -1
- package/dist/runtime/jsxIsland.mjs +1 -1
- package/dist/runtime/layoutBridge.mjs +1 -1
- package/dist/runtime/nativeBridge.mjs +1 -1
- package/dist/runtime/navigationLifecycle.mjs +1 -0
- package/dist/runtime/pageEnvironment.mjs +1 -1
- package/dist/runtime/pageLayout.mjs +1 -1
- package/dist/runtime/pageScroll.mjs +1 -1
- package/dist/runtime/platform/current.mjs +1 -0
- package/dist/runtime/platform/generic.mjs +1 -0
- package/dist/runtime/platform/globals.mjs +1 -0
- package/dist/runtime/platform.mjs +1 -1
- package/dist/runtime/provideContext.mjs +1 -1
- package/dist/runtime/publicRuntime.mjs +1 -1
- package/dist/runtime/pullDownRefresh.mjs +1 -1
- package/dist/runtime/register/app.mjs +1 -1
- package/dist/runtime/register/component/alipay.mjs +1 -1
- package/dist/runtime/register/component/alipayRegistration.mjs +1 -0
- package/dist/runtime/register/component/lifecycle/platform.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/options.mjs +1 -1
- package/dist/runtime/register/component/props.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/runtime/register/component/registerNativeDefinition.mjs +1 -1
- package/dist/runtime/register/component.mjs +1 -1
- package/dist/runtime/register/inline.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/methodBridge.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/provideContext.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 -1
- package/dist/runtime/register/runtimeInstance/utils.mjs +1 -1
- package/dist/runtime/register/runtimeInstance.mjs +1 -1
- package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -1
- package/dist/runtime/register/setup.mjs +1 -1
- package/dist/runtime/register/snapshot.mjs +1 -1
- package/dist/runtime/register/watch.mjs +1 -1
- package/dist/runtime/scopedSlots.mjs +1 -1
- package/dist/runtime/selectorQuery.mjs +1 -1
- package/dist/runtime/template.mjs +1 -1
- package/dist/runtime/templateRefs/helpers.mjs +1 -1
- package/dist/runtime/templateRefs.mjs +1 -1
- package/dist/runtime/uniAppHost.mjs +1 -1
- package/dist/runtime/updatePerformance.mjs +1 -1
- package/dist/runtime/use.mjs +1 -1
- package/dist/runtime/vueCompat/context.mjs +1 -1
- package/dist/runtime/vueCompat/model.mjs +1 -1
- package/dist/runtime/vueCompat/router.mjs +1 -1
- package/dist/runtime/vueCompat/templateRef.mjs +1 -1
- package/dist/scheduler.mjs +1 -1
- package/dist/store/base.mjs +1 -1
- package/dist/store/define/create.mjs +1 -1
- package/dist/store/define.mjs +1 -1
- package/dist/store/view.mjs +1 -1
- package/package.json +7 -7
- /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/defineProperty.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPrimitive.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPropertyKey.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/typeof.mjs +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageScroll.mjs","names":[],"sources":["../../../src/runtime/pageScroll.ts"],"sourcesContent":["import type { MiniProgramPageScrollOption } from './types'\nimport { getCurrentInstance, onDetached, onPageScroll, onUnload } from './hooks'\n\nexport interface UsePageScrollThrottleOptions {\n /**\n * 节流间隔(毫秒),默认 80ms。\n */\n interval?: number\n /**\n * 是否在窗口起始边缘立即触发,默认 true。\n */\n leading?: boolean\n /**\n * 是否在窗口结束边缘补一次回调,默认 true。\n */\n trailing?: boolean\n /**\n * 持续滚动时的最大等待时间(毫秒)。\n * 当 trailing 为 false 时,可用于兜底触发一次回调。\n */\n maxWait?: number\n}\n\nexport type UsePageScrollThrottleStopHandle = () => void\n\nfunction resolvePositiveInterval(interval: number | undefined): number {\n if (typeof interval !== 'number' || !Number.isFinite(interval)) {\n return 80\n }\n return Math.max(0, interval)\n}\n\nfunction resolveMaxWait(maxWait: number | undefined): number | undefined {\n if (typeof maxWait !== 'number' || !Number.isFinite(maxWait)) {\n return undefined\n }\n return Math.max(0, maxWait)\n}\n\n/**\n * 在 setup 中注册节流后的 onPageScroll 监听,并在卸载时自动清理。\n */\nexport function usePageScrollThrottle(\n handler: (opt: MiniProgramPageScrollOption) => void,\n options: UsePageScrollThrottleOptions = {},\n): UsePageScrollThrottleStopHandle {\n if (!getCurrentInstance()) {\n throw new Error('usePageScrollThrottle() 必须在 setup() 的同步阶段调用')\n }\n if (typeof handler !== 'function') {\n throw new TypeError('usePageScrollThrottle() 需要传入回调函数')\n }\n\n const interval = resolvePositiveInterval(options.interval)\n const leading = options.leading ?? true\n const trailing = options.trailing ?? true\n const maxWait = resolveMaxWait(options.maxWait)\n\n let trailingTimer: ReturnType<typeof setTimeout> | undefined\n let maxWaitTimer: ReturnType<typeof setTimeout> | undefined\n let stopped = false\n let lastInvokeTime = 0\n let trailingEvent: MiniProgramPageScrollOption | undefined\n\n const clearTrailingTimer = () => {\n if (!trailingTimer) {\n return\n }\n clearTimeout(trailingTimer)\n trailingTimer = undefined\n }\n\n const clearMaxWaitTimer = () => {\n if (!maxWaitTimer) {\n return\n }\n clearTimeout(maxWaitTimer)\n maxWaitTimer = undefined\n }\n\n const invoke = (event: MiniProgramPageScrollOption) => {\n clearTrailingTimer()\n clearMaxWaitTimer()\n trailingEvent = undefined\n lastInvokeTime = Date.now()\n handler(event)\n }\n\n const flushTrailing = () => {\n const event = trailingEvent\n trailingEvent = undefined\n trailingTimer = undefined\n if (!event || stopped) {\n return\n }\n invoke(event)\n }\n\n const flushMaxWait = () => {\n const event = trailingEvent\n maxWaitTimer = undefined\n if (!event || stopped) {\n return\n }\n invoke(event)\n }\n\n const scheduleTrailing = (now: number) => {\n if (!trailing || trailingTimer) {\n return\n }\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n const remaining = Math.max(0, interval - (now - base))\n trailingTimer = setTimeout(flushTrailing, remaining)\n }\n\n const scheduleMaxWait = (now: number) => {\n if (typeof maxWait !== 'number' || maxWaitTimer) {\n return\n }\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n const remaining = maxWait - (now - base)\n if (remaining <= 0) {\n flushMaxWait()\n return\n }\n maxWaitTimer = setTimeout(flushMaxWait, remaining)\n }\n\n const register = (event: MiniProgramPageScrollOption) => {\n if (stopped) {\n return\n }\n\n if (interval === 0) {\n invoke(event)\n return\n }\n\n const now = Date.now()\n trailingEvent = event\n\n if (leading && (lastInvokeTime === 0 || now - lastInvokeTime >= interval)) {\n invoke(event)\n return\n }\n\n if (typeof maxWait === 'number') {\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n if (now - base >= maxWait) {\n invoke(event)\n return\n }\n }\n\n if (!trailing && typeof maxWait !== 'number') {\n return\n }\n\n scheduleTrailing(now)\n scheduleMaxWait(now)\n }\n\n onPageScroll(register)\n\n const stop = () => {\n if (stopped) {\n return\n }\n stopped = true\n trailingEvent = undefined\n clearTrailingTimer()\n clearMaxWaitTimer()\n }\n\n onUnload(stop)\n onDetached(stop)\n\n return stop\n}\n"],"mappings":";;;;AAyBA,SAAS,wBAAwB,UAAsC;CACrE,IAAI,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,QAAQ,GAC3D,OAAO;CAET,OAAO,KAAK,IAAI,GAAG,QAAQ;AAC7B;AAEA,SAAS,eAAe,SAAiD;CACvE,IAAI,OAAO,YAAY,YAAY,CAAC,OAAO,SAAS,OAAO,GACzD;CAEF,OAAO,KAAK,IAAI,GAAG,OAAO;AAC5B;;;;AAKA,SAAgB,sBACd,SACA,UAAwC,CAAC,GACR
|
|
1
|
+
{"version":3,"file":"pageScroll.mjs","names":[],"sources":["../../../src/runtime/pageScroll.ts"],"sourcesContent":["import type { MiniProgramPageScrollOption } from './types'\nimport { getCurrentInstance, onDetached, onPageScroll, onUnload } from './hooks'\n\nexport interface UsePageScrollThrottleOptions {\n /**\n * 节流间隔(毫秒),默认 80ms。\n */\n interval?: number\n /**\n * 是否在窗口起始边缘立即触发,默认 true。\n */\n leading?: boolean\n /**\n * 是否在窗口结束边缘补一次回调,默认 true。\n */\n trailing?: boolean\n /**\n * 持续滚动时的最大等待时间(毫秒)。\n * 当 trailing 为 false 时,可用于兜底触发一次回调。\n */\n maxWait?: number\n}\n\nexport type UsePageScrollThrottleStopHandle = () => void\n\nfunction resolvePositiveInterval(interval: number | undefined): number {\n if (typeof interval !== 'number' || !Number.isFinite(interval)) {\n return 80\n }\n return Math.max(0, interval)\n}\n\nfunction resolveMaxWait(maxWait: number | undefined): number | undefined {\n if (typeof maxWait !== 'number' || !Number.isFinite(maxWait)) {\n return undefined\n }\n return Math.max(0, maxWait)\n}\n\n/**\n * 在 setup 中注册节流后的 onPageScroll 监听,并在卸载时自动清理。\n */\nexport function usePageScrollThrottle(\n handler: (opt: MiniProgramPageScrollOption) => void,\n options: UsePageScrollThrottleOptions = {},\n): UsePageScrollThrottleStopHandle {\n if (!getCurrentInstance()) {\n throw new Error('usePageScrollThrottle() 必须在 setup() 的同步阶段调用')\n }\n if (typeof handler !== 'function') {\n throw new TypeError('usePageScrollThrottle() 需要传入回调函数')\n }\n\n const interval = resolvePositiveInterval(options.interval)\n const leading = options.leading ?? true\n const trailing = options.trailing ?? true\n const maxWait = resolveMaxWait(options.maxWait)\n\n let trailingTimer: ReturnType<typeof setTimeout> | undefined\n let maxWaitTimer: ReturnType<typeof setTimeout> | undefined\n let stopped = false\n let lastInvokeTime = 0\n let trailingEvent: MiniProgramPageScrollOption | undefined\n\n const clearTrailingTimer = () => {\n if (!trailingTimer) {\n return\n }\n clearTimeout(trailingTimer)\n trailingTimer = undefined\n }\n\n const clearMaxWaitTimer = () => {\n if (!maxWaitTimer) {\n return\n }\n clearTimeout(maxWaitTimer)\n maxWaitTimer = undefined\n }\n\n const invoke = (event: MiniProgramPageScrollOption) => {\n clearTrailingTimer()\n clearMaxWaitTimer()\n trailingEvent = undefined\n lastInvokeTime = Date.now()\n handler(event)\n }\n\n const flushTrailing = () => {\n const event = trailingEvent\n trailingEvent = undefined\n trailingTimer = undefined\n if (!event || stopped) {\n return\n }\n invoke(event)\n }\n\n const flushMaxWait = () => {\n const event = trailingEvent\n maxWaitTimer = undefined\n if (!event || stopped) {\n return\n }\n invoke(event)\n }\n\n const scheduleTrailing = (now: number) => {\n if (!trailing || trailingTimer) {\n return\n }\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n const remaining = Math.max(0, interval - (now - base))\n trailingTimer = setTimeout(flushTrailing, remaining)\n }\n\n const scheduleMaxWait = (now: number) => {\n if (typeof maxWait !== 'number' || maxWaitTimer) {\n return\n }\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n const remaining = maxWait - (now - base)\n if (remaining <= 0) {\n flushMaxWait()\n return\n }\n maxWaitTimer = setTimeout(flushMaxWait, remaining)\n }\n\n const register = (event: MiniProgramPageScrollOption) => {\n if (stopped) {\n return\n }\n\n if (interval === 0) {\n invoke(event)\n return\n }\n\n const now = Date.now()\n trailingEvent = event\n\n if (leading && (lastInvokeTime === 0 || now - lastInvokeTime >= interval)) {\n invoke(event)\n return\n }\n\n if (typeof maxWait === 'number') {\n const base = lastInvokeTime === 0 ? now : lastInvokeTime\n if (now - base >= maxWait) {\n invoke(event)\n return\n }\n }\n\n if (!trailing && typeof maxWait !== 'number') {\n return\n }\n\n scheduleTrailing(now)\n scheduleMaxWait(now)\n }\n\n onPageScroll(register)\n\n const stop = () => {\n if (stopped) {\n return\n }\n stopped = true\n trailingEvent = undefined\n clearTrailingTimer()\n clearMaxWaitTimer()\n }\n\n onUnload(stop)\n onDetached(stop)\n\n return stop\n}\n"],"mappings":";;;;AAyBA,SAAS,wBAAwB,UAAsC;CACrE,IAAI,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,QAAQ,GAC3D,OAAO;CAET,OAAO,KAAK,IAAI,GAAG,QAAQ;AAC7B;AAEA,SAAS,eAAe,SAAiD;CACvE,IAAI,OAAO,YAAY,YAAY,CAAC,OAAO,SAAS,OAAO,GACzD;CAEF,OAAO,KAAK,IAAI,GAAG,OAAO;AAC5B;;;;AAKA,SAAgB,sBACd,SACA,UAAwC,CAAC,GACR;CACjC,IAAI,CAAC,mBAAmB,GACtB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,IAAI,OAAO,YAAY,YACrB,MAAM,IAAI,UAAU,kCAAkC;CAGxD,MAAM,WAAW,wBAAwB,QAAQ,QAAQ;CACzD,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,UAAU,eAAe,QAAQ,OAAO;CAE9C,IAAI;CACJ,IAAI;CACJ,IAAI,UAAU;CACd,IAAI,iBAAiB;CACrB,IAAI;CAEJ,MAAM,2BAA2B;EAC/B,IAAI,CAAC,eACH;EAEF,aAAa,aAAa;EAC1B,gBAAgB;CAClB;CAEA,MAAM,0BAA0B;EAC9B,IAAI,CAAC,cACH;EAEF,aAAa,YAAY;EACzB,eAAe;CACjB;CAEA,MAAM,UAAU,UAAuC;EACrD,mBAAmB;EACnB,kBAAkB;EAClB,gBAAgB;EAChB,iBAAiB,KAAK,IAAI;EAC1B,QAAQ,KAAK;CACf;CAEA,MAAM,sBAAsB;EAC1B,MAAM,QAAQ;EACd,gBAAgB;EAChB,gBAAgB;EAChB,IAAI,CAAC,SAAS,SACZ;EAEF,OAAO,KAAK;CACd;CAEA,MAAM,qBAAqB;EACzB,MAAM,QAAQ;EACd,eAAe;EACf,IAAI,CAAC,SAAS,SACZ;EAEF,OAAO,KAAK;CACd;CAEA,MAAM,oBAAoB,QAAgB;EACxC,IAAI,CAAC,YAAY,eACf;EAGF,MAAM,YAAY,KAAK,IAAI,GAAG,YAAY,OAD7B,mBAAmB,IAAI,MAAM,gBACW;EACrD,gBAAgB,WAAW,eAAe,SAAS;CACrD;CAEA,MAAM,mBAAmB,QAAgB;EACvC,IAAI,OAAO,YAAY,YAAY,cACjC;EAGF,MAAM,YAAY,WAAW,OADhB,mBAAmB,IAAI,MAAM;EAE1C,IAAI,aAAa,GAAG;GAClB,aAAa;GACb;EACF;EACA,eAAe,WAAW,cAAc,SAAS;CACnD;CAEA,MAAM,YAAY,UAAuC;EACvD,IAAI,SACF;EAGF,IAAI,aAAa,GAAG;GAClB,OAAO,KAAK;GACZ;EACF;EAEA,MAAM,MAAM,KAAK,IAAI;EACrB,gBAAgB;EAEhB,IAAI,YAAY,mBAAmB,KAAK,MAAM,kBAAkB,WAAW;GACzE,OAAO,KAAK;GACZ;EACF;EAEA,IAAI,OAAO,YAAY,UAErB;OAAI,OADS,mBAAmB,IAAI,MAAM,mBACxB,SAAS;IACzB,OAAO,KAAK;IACZ;GACF;;EAGF,IAAI,CAAC,YAAY,OAAO,YAAY,UAClC;EAGF,iBAAiB,GAAG;EACpB,gBAAgB,GAAG;CACrB;CAEA,aAAa,QAAQ;CAErB,MAAM,aAAa;EACjB,IAAI,SACF;EAEF,UAAU;EACV,gBAAgB;EAChB,mBAAmB;EACnB,kBAAkB;CACpB;CAEA,SAAS,IAAI;CACb,WAAW,IAAI;CAEf,OAAO;AACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getAlipayGlobalObject, getBaiduGlobalObject, getDouyinCompatibleGlobalObject, getJdGlobalObject, getWechatGlobalObject, getXhsGlobalObject } from "./globals.mjs";
|
|
2
|
+
import { getDetectedMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, resolveDetectedMiniProgramPlatform } from "./generic.mjs";
|
|
3
|
+
import { ALIPAY_RUNTIME_DESCRIPTOR, DEFAULT_RUNTIME_CAPABILITIES, TT_RUNTIME_DESCRIPTOR } from "@weapp-core/shared/platforms/runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/platform/current.ts
|
|
6
|
+
const getCurrentMiniProgramGlobalObject = import.meta.env?.PLATFORM === "weapp" || import.meta.env?.PLATFORM === "web" ? getWechatGlobalObject : import.meta.env?.PLATFORM === "alipay" ? getAlipayGlobalObject : import.meta.env?.PLATFORM === "tt" ? getDouyinCompatibleGlobalObject : import.meta.env?.PLATFORM === "swan" ? getBaiduGlobalObject : import.meta.env?.PLATFORM === "jd" ? getJdGlobalObject : import.meta.env?.PLATFORM === "xhs" ? getXhsGlobalObject : getMiniProgramGlobalObject;
|
|
7
|
+
const resolveCurrentMiniProgramPlatform = import.meta.env?.PLATFORM === "weapp" || import.meta.env?.PLATFORM === "web" ? () => "weapp" : import.meta.env?.PLATFORM === "alipay" ? () => "alipay" : import.meta.env?.PLATFORM === "tt" ? () => "tt" : import.meta.env?.PLATFORM === "swan" ? () => "swan" : import.meta.env?.PLATFORM === "jd" ? () => "jd" : import.meta.env?.PLATFORM === "xhs" ? () => "xhs" : resolveDetectedMiniProgramPlatform;
|
|
8
|
+
const getCurrentMiniProgramRuntimeCapabilities = import.meta.env?.PLATFORM === "alipay" ? () => ALIPAY_RUNTIME_DESCRIPTOR.runtime.capabilities : import.meta.env?.PLATFORM === "tt" ? () => TT_RUNTIME_DESCRIPTOR.runtime.capabilities : import.meta.env?.PLATFORM === "weapp" || import.meta.env?.PLATFORM === "swan" || import.meta.env?.PLATFORM === "jd" || import.meta.env?.PLATFORM === "xhs" || import.meta.env?.PLATFORM === "web" ? () => DEFAULT_RUNTIME_CAPABILITIES : getDetectedMiniProgramRuntimeCapabilities;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getCurrentMiniProgramGlobalObject, getCurrentMiniProgramRuntimeCapabilities, resolveCurrentMiniProgramPlatform };
|
|
12
|
+
//# sourceMappingURL=current.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current.mjs","names":[],"sources":["../../../../src/runtime/platform/current.ts"],"sourcesContent":["import type { MiniProgramRuntimeCapabilities, MpPlatform } from '@weapp-core/shared/platforms/runtime'\nimport type { MiniProgramGlobal } from './globals'\nimport { ALIPAY_RUNTIME_DESCRIPTOR, DEFAULT_RUNTIME_CAPABILITIES, TT_RUNTIME_DESCRIPTOR } from '@weapp-core/shared/platforms/runtime'\nimport { getDetectedMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, resolveDetectedMiniProgramPlatform } from './generic'\nimport { getAlipayGlobalObject, getBaiduGlobalObject, getDouyinCompatibleGlobalObject, getJdGlobalObject, getWechatGlobalObject, getXhsGlobalObject } from './globals'\n\ntype ImportMetaWithEnv = ImportMeta & { env?: { PLATFORM?: string } }\n\n// 保持目标判断直接位于函数选择处,发布与应用二次打包均可消除非目标模块。\nexport const getCurrentMiniProgramGlobalObject: () => MiniProgramGlobal | undefined\n = (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp' || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'web'\n ? getWechatGlobalObject\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'alipay'\n ? getAlipayGlobalObject\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'tt'\n ? getDouyinCompatibleGlobalObject\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'swan'\n ? getBaiduGlobalObject\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'jd'\n ? getJdGlobalObject\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'xhs'\n ? getXhsGlobalObject\n : getMiniProgramGlobalObject\n\nexport const resolveCurrentMiniProgramPlatform: () => MpPlatform | undefined\n = (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp' || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'web'\n ? () => 'weapp'\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'alipay'\n ? () => 'alipay'\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'tt'\n ? () => 'tt'\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'swan'\n ? () => 'swan'\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'jd'\n ? () => 'jd'\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'xhs'\n ? () => 'xhs'\n : resolveDetectedMiniProgramPlatform\n\nexport const getCurrentMiniProgramRuntimeCapabilities: () => MiniProgramRuntimeCapabilities\n = (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'alipay'\n ? () => ALIPAY_RUNTIME_DESCRIPTOR.runtime.capabilities\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'tt'\n ? () => TT_RUNTIME_DESCRIPTOR.runtime.capabilities\n : (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'weapp'\n || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'swan'\n || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'jd'\n || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'xhs'\n || (import.meta as ImportMetaWithEnv).env?.PLATFORM === 'web'\n ? () => DEFAULT_RUNTIME_CAPABILITIES\n : getDetectedMiniProgramRuntimeCapabilities\n"],"mappings":";;;;;AASA,MAAa,oCACR,YAAkC,KAAK,aAAa,WAAY,YAAkC,KAAK,aAAa,QACnH,wBACC,YAAkC,KAAK,aAAa,WACjD,wBACC,YAAkC,KAAK,aAAa,OACjD,kCACC,YAAkC,KAAK,aAAa,SACjD,uBACC,YAAkC,KAAK,aAAa,OACjD,oBACC,YAAkC,KAAK,aAAa,QACjD,qBACA;AAE1B,MAAa,oCACR,YAAkC,KAAK,aAAa,WAAY,YAAkC,KAAK,aAAa,cAC7G,UACL,YAAkC,KAAK,aAAa,iBAC3C,WACL,YAAkC,KAAK,aAAa,aAC3C,OACL,YAAkC,KAAK,aAAa,eAC3C,SACL,YAAkC,KAAK,aAAa,aAC3C,OACL,YAAkC,KAAK,aAAa,cAC3C,QACN;AAE1B,MAAa,2CACR,YAAkC,KAAK,aAAa,iBAC7C,0BAA0B,QAAQ,eACvC,YAAkC,KAAK,aAAa,aAC3C,sBAAsB,QAAQ,eACnC,YAAkC,KAAK,aAAa,WACjD,YAAkC,KAAK,aAAa,UACpD,YAAkC,KAAK,aAAa,QACpD,YAAkC,KAAK,aAAa,SACpD,YAAkC,KAAK,aAAa,cAC9C,+BACN"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getAlipayGlobalObject, getBaiduGlobalObject, getDouyinGlobalObject, getJdGlobalObject, getWechatGlobalObject, getXhsGlobalObject } from "./globals.mjs";
|
|
2
|
+
import { getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, resolveMiniProgramPlatform } from "@weapp-core/shared/platforms/runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/platform/generic.ts
|
|
5
|
+
function resolveRuntimeGlobalObject(globalKey) {
|
|
6
|
+
switch (globalKey) {
|
|
7
|
+
case "wx": return getWechatGlobalObject();
|
|
8
|
+
case "my": return getAlipayGlobalObject();
|
|
9
|
+
case "tt": return getDouyinGlobalObject();
|
|
10
|
+
case "swan": return getBaiduGlobalObject();
|
|
11
|
+
case "jd": return getJdGlobalObject();
|
|
12
|
+
case "xhs": return getXhsGlobalObject();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function resolveDetectedMiniProgramPlatform() {
|
|
16
|
+
const compiledPlatform = import.meta.env?.PLATFORM;
|
|
17
|
+
const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform);
|
|
18
|
+
if (resolvedCompiledPlatform) return resolvedCompiledPlatform;
|
|
19
|
+
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) if (resolveRuntimeGlobalObject(globalKey)) return getMiniProgramPlatformByRuntimeGlobalKey(globalKey);
|
|
20
|
+
}
|
|
21
|
+
function getDetectedMiniProgramRuntimeCapabilities() {
|
|
22
|
+
return getMiniProgramRuntimeCapabilities(resolveDetectedMiniProgramPlatform());
|
|
23
|
+
}
|
|
24
|
+
function getMiniProgramGlobalObject(platformInput) {
|
|
25
|
+
const compiledPlatform = platformInput ?? import.meta.env?.PLATFORM;
|
|
26
|
+
const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform);
|
|
27
|
+
if (resolvedCompiledPlatform) return resolveRuntimeGlobalObject(getMiniProgramRuntimeGlobalKey(resolvedCompiledPlatform)) ?? (resolvedCompiledPlatform === "tt" ? resolveRuntimeGlobalObject("wx") : void 0);
|
|
28
|
+
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {
|
|
29
|
+
const candidate = resolveRuntimeGlobalObject(globalKey);
|
|
30
|
+
if (candidate) return candidate;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getDetectedMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, resolveDetectedMiniProgramPlatform };
|
|
36
|
+
//# sourceMappingURL=generic.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.mjs","names":[],"sources":["../../../../src/runtime/platform/generic.ts"],"sourcesContent":["import type { MiniProgramRuntimeCapabilities } from '@weapp-core/shared/platforms/runtime'\nimport type { MiniProgramGlobal } from './globals'\n\nimport {\n getMiniProgramPlatformByRuntimeGlobalKey,\n getMiniProgramRuntimeCapabilities,\n getMiniProgramRuntimeGlobalKey,\n getMiniProgramRuntimeGlobalKeys,\n resolveMiniProgramPlatform,\n} from '@weapp-core/shared/platforms/runtime'\nimport { getAlipayGlobalObject, getBaiduGlobalObject, getDouyinGlobalObject, getJdGlobalObject, getWechatGlobalObject, getXhsGlobalObject } from './globals'\n\ntype ImportMetaWithEnv = ImportMeta & {\n env?: {\n PLATFORM?: string\n }\n}\nfunction resolveRuntimeGlobalObject(globalKey: string): MiniProgramGlobal | undefined {\n switch (globalKey) {\n case 'wx': return getWechatGlobalObject()\n case 'my': return getAlipayGlobalObject()\n case 'tt': return getDouyinGlobalObject()\n case 'swan': return getBaiduGlobalObject()\n case 'jd': return getJdGlobalObject()\n case 'xhs': return getXhsGlobalObject()\n }\n return undefined\n}\n\nexport function resolveDetectedMiniProgramPlatform() {\n const compiledPlatform = (import.meta as ImportMetaWithEnv).env?.PLATFORM\n\n // 兼容未声明目标或使用平台别名的独立构建。\n const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform)\n if (resolvedCompiledPlatform) {\n return resolvedCompiledPlatform\n }\n\n for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {\n if (resolveRuntimeGlobalObject(globalKey)) {\n return getMiniProgramPlatformByRuntimeGlobalKey(globalKey)\n }\n }\n\n return undefined\n}\n\nexport function getDetectedMiniProgramRuntimeCapabilities(): MiniProgramRuntimeCapabilities {\n return getMiniProgramRuntimeCapabilities(resolveDetectedMiniProgramPlatform())\n}\n\nexport function getMiniProgramGlobalObject(platformInput?: string): MiniProgramGlobal | undefined {\n const compiledPlatform = platformInput ?? (import.meta as ImportMetaWithEnv).env?.PLATFORM\n const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform)\n\n if (resolvedCompiledPlatform) {\n const globalKey = getMiniProgramRuntimeGlobalKey(resolvedCompiledPlatform)\n return resolveRuntimeGlobalObject(globalKey)\n ?? (resolvedCompiledPlatform === 'tt' ? resolveRuntimeGlobalObject('wx') : undefined)\n }\n\n for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {\n const candidate = resolveRuntimeGlobalObject(globalKey)\n if (candidate) {\n return candidate as MiniProgramGlobal\n }\n }\n return undefined\n}\n"],"mappings":";;;;AAiBA,SAAS,2BAA2B,WAAkD;CACpF,QAAQ,WAAR;EACE,KAAK,MAAM,OAAO,sBAAsB;EACxC,KAAK,MAAM,OAAO,sBAAsB;EACxC,KAAK,MAAM,OAAO,sBAAsB;EACxC,KAAK,QAAQ,OAAO,qBAAqB;EACzC,KAAK,MAAM,OAAO,kBAAkB;EACpC,KAAK,OAAO,OAAO,mBAAmB;CACxC;AAEF;AAEA,SAAgB,qCAAqC;CACnD,MAAM,mBAAoB,YAAkC,KAAK;CAGjE,MAAM,2BAA2B,2BAA2B,gBAAgB;CAC5E,IAAI,0BACF,OAAO;CAGT,KAAK,MAAM,aAAa,gCAAgC,GACtD,IAAI,2BAA2B,SAAS,GACtC,OAAO,yCAAyC,SAAS;AAK/D;AAEA,SAAgB,4CAA4E;CAC1F,OAAO,kCAAkC,mCAAmC,CAAC;AAC/E;AAEA,SAAgB,2BAA2B,eAAuD;CAChG,MAAM,mBAAmB,iBAAkB,YAAkC,KAAK;CAClF,MAAM,2BAA2B,2BAA2B,gBAAgB;CAE5E,IAAI,0BAEF,OAAO,2BADW,+BAA+B,wBACP,CAAC,MACrC,6BAA6B,OAAO,2BAA2B,IAAI,IAAI;CAG/E,KAAK,MAAM,aAAa,gCAAgC,GAAG;EACzD,MAAM,YAAY,2BAA2B,SAAS;EACtD,IAAI,WACF,OAAO;CAEX;AAEF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/runtime/platform/globals.ts
|
|
2
|
+
function getGlobalRuntime() {
|
|
3
|
+
return typeof globalThis === "undefined" ? void 0 : globalThis;
|
|
4
|
+
}
|
|
5
|
+
function getWechatGlobalObject() {
|
|
6
|
+
return getGlobalRuntime()?.wx ?? (typeof wx === "undefined" ? void 0 : wx);
|
|
7
|
+
}
|
|
8
|
+
function getAlipayGlobalObject() {
|
|
9
|
+
return getGlobalRuntime()?.my ?? (typeof my === "undefined" ? void 0 : my);
|
|
10
|
+
}
|
|
11
|
+
function getDouyinGlobalObject() {
|
|
12
|
+
return getGlobalRuntime()?.tt ?? (typeof tt === "undefined" ? void 0 : tt);
|
|
13
|
+
}
|
|
14
|
+
function getBaiduGlobalObject() {
|
|
15
|
+
return getGlobalRuntime()?.swan ?? (typeof swan === "undefined" ? void 0 : swan);
|
|
16
|
+
}
|
|
17
|
+
function getJdGlobalObject() {
|
|
18
|
+
return getGlobalRuntime()?.jd ?? (typeof jd === "undefined" ? void 0 : jd);
|
|
19
|
+
}
|
|
20
|
+
function getXhsGlobalObject() {
|
|
21
|
+
return getGlobalRuntime()?.xhs ?? (typeof xhs === "undefined" ? void 0 : xhs);
|
|
22
|
+
}
|
|
23
|
+
function getDouyinCompatibleGlobalObject() {
|
|
24
|
+
return getDouyinGlobalObject() ?? getWechatGlobalObject();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getAlipayGlobalObject, getBaiduGlobalObject, getDouyinCompatibleGlobalObject, getDouyinGlobalObject, getGlobalRuntime, getJdGlobalObject, getWechatGlobalObject, getXhsGlobalObject };
|
|
29
|
+
//# sourceMappingURL=globals.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.mjs","names":[],"sources":["../../../../src/runtime/platform/globals.ts"],"sourcesContent":["export type MiniProgramGlobal = Record<string, any>\n\ndeclare const tt: MiniProgramGlobal | undefined\ndeclare const swan: MiniProgramGlobal | undefined\ndeclare const jd: MiniProgramGlobal | undefined\ndeclare const xhs: MiniProgramGlobal | undefined\n\nexport function getGlobalRuntime(): MiniProgramGlobal | undefined {\n return typeof globalThis === 'undefined' ? undefined : globalThis\n}\n\nexport function getWechatGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.wx ?? (typeof wx === 'undefined' ? undefined : wx as MiniProgramGlobal)\n}\n\nexport function getAlipayGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.my ?? (typeof my === 'undefined' ? undefined : my as MiniProgramGlobal)\n}\n\nexport function getDouyinGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.tt ?? (typeof tt === 'undefined' ? undefined : tt as MiniProgramGlobal)\n}\n\nexport function getBaiduGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.swan ?? (typeof swan === 'undefined' ? undefined : swan as MiniProgramGlobal)\n}\n\nexport function getJdGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.jd ?? (typeof jd === 'undefined' ? undefined : jd as MiniProgramGlobal)\n}\n\nexport function getXhsGlobalObject(): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.xhs ?? (typeof xhs === 'undefined' ? undefined : xhs as MiniProgramGlobal)\n}\n\nexport function getDouyinCompatibleGlobalObject(): MiniProgramGlobal | undefined {\n return getDouyinGlobalObject() ?? getWechatGlobalObject()\n}\n"],"mappings":";AAOA,SAAgB,mBAAkD;CAChE,OAAO,OAAO,eAAe,cAAc,SAAY;AACzD;AAEA,SAAgB,wBAAuD;CACrE,OAAO,iBAAiB,CAAC,EAAE,OAAO,OAAO,OAAO,cAAc,SAAY;AAC5E;AAEA,SAAgB,wBAAuD;CACrE,OAAO,iBAAiB,CAAC,EAAE,OAAO,OAAO,OAAO,cAAc,SAAY;AAC5E;AAEA,SAAgB,wBAAuD;CACrE,OAAO,iBAAiB,CAAC,EAAE,OAAO,OAAO,OAAO,cAAc,SAAY;AAC5E;AAEA,SAAgB,uBAAsD;CACpE,OAAO,iBAAiB,CAAC,EAAE,SAAS,OAAO,SAAS,cAAc,SAAY;AAChF;AAEA,SAAgB,oBAAmD;CACjE,OAAO,iBAAiB,CAAC,EAAE,OAAO,OAAO,OAAO,cAAc,SAAY;AAC5E;AAEA,SAAgB,qBAAoD;CAClE,OAAO,iBAAiB,CAAC,EAAE,QAAQ,OAAO,QAAQ,cAAc,SAAY;AAC9E;AAEA,SAAgB,kCAAiE;CAC/E,OAAO,sBAAsB,KAAK,sBAAsB;AAC1D"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getGlobalRuntime } from "./platform/globals.mjs";
|
|
2
|
+
import { getMiniProgramGlobalObject } from "./platform/generic.mjs";
|
|
3
|
+
import { getCurrentMiniProgramGlobalObject, getCurrentMiniProgramRuntimeCapabilities, resolveCurrentMiniProgramPlatform } from "./platform/current.mjs";
|
|
4
|
+
import { DEFAULT_RUNTIME_HOST_CONFIG_KEY } from "@weapp-core/shared/platforms/runtime";
|
|
2
5
|
|
|
3
6
|
//#region src/runtime/platform.ts
|
|
4
7
|
const MINI_PROGRAM_GLOBAL_ROUTER_METHODS = [
|
|
@@ -8,81 +11,35 @@ const MINI_PROGRAM_GLOBAL_ROUTER_METHODS = [
|
|
|
8
11
|
"navigateTo",
|
|
9
12
|
"navigateBack"
|
|
10
13
|
];
|
|
11
|
-
function getGlobalRuntime() {
|
|
12
|
-
if (typeof globalThis === "undefined") return;
|
|
13
|
-
return globalThis;
|
|
14
|
-
}
|
|
15
|
-
function getStaticMiniProgramGlobalObject(globalKey) {
|
|
16
|
-
switch (globalKey) {
|
|
17
|
-
case "wx": return typeof wx !== "undefined" ? wx : void 0;
|
|
18
|
-
case "my": return typeof my !== "undefined" ? my : void 0;
|
|
19
|
-
case "tt": return typeof tt !== "undefined" ? tt : void 0;
|
|
20
|
-
case "swan": return typeof swan !== "undefined" ? swan : void 0;
|
|
21
|
-
case "jd": return typeof jd !== "undefined" ? jd : void 0;
|
|
22
|
-
case "xhs": return typeof xhs !== "undefined" ? xhs : void 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function resolveRuntimeGlobalObject(globalKey) {
|
|
26
|
-
var _getGlobalRuntime$glo, _getGlobalRuntime;
|
|
27
|
-
return (_getGlobalRuntime$glo = (_getGlobalRuntime = getGlobalRuntime()) === null || _getGlobalRuntime === void 0 ? void 0 : _getGlobalRuntime[globalKey]) !== null && _getGlobalRuntime$glo !== void 0 ? _getGlobalRuntime$glo : getStaticMiniProgramGlobalObject(globalKey);
|
|
28
|
-
}
|
|
29
|
-
function resolveCurrentMiniProgramPlatform() {
|
|
30
|
-
var _env;
|
|
31
|
-
const compiledPlatform = (_env = import.meta.env) === null || _env === void 0 ? void 0 : _env.PLATFORM;
|
|
32
|
-
const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform);
|
|
33
|
-
if (resolvedCompiledPlatform) return resolvedCompiledPlatform;
|
|
34
|
-
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) if (resolveRuntimeGlobalObject(globalKey)) return getMiniProgramPlatformByRuntimeGlobalKey(globalKey);
|
|
35
|
-
}
|
|
36
|
-
function getCurrentMiniProgramRuntimeCapabilities() {
|
|
37
|
-
return getMiniProgramRuntimeCapabilities(resolveCurrentMiniProgramPlatform());
|
|
38
|
-
}
|
|
39
14
|
function supportsCurrentMiniProgramRuntimeCapability(capabilityName) {
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
function getMiniProgramGlobalObject(platformInput) {
|
|
43
|
-
var _env2;
|
|
44
|
-
const compiledPlatform = platformInput !== null && platformInput !== void 0 ? platformInput : (_env2 = import.meta.env) === null || _env2 === void 0 ? void 0 : _env2.PLATFORM;
|
|
45
|
-
const resolvedCompiledPlatform = resolveMiniProgramPlatform(compiledPlatform);
|
|
46
|
-
if (resolvedCompiledPlatform) {
|
|
47
|
-
var _resolveRuntimeGlobal;
|
|
48
|
-
return (_resolveRuntimeGlobal = resolveRuntimeGlobalObject(getMiniProgramRuntimeGlobalKey(resolvedCompiledPlatform))) !== null && _resolveRuntimeGlobal !== void 0 ? _resolveRuntimeGlobal : resolvedCompiledPlatform === "tt" ? resolveRuntimeGlobalObject("wx") : void 0;
|
|
49
|
-
}
|
|
50
|
-
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {
|
|
51
|
-
const candidate = resolveRuntimeGlobalObject(globalKey);
|
|
52
|
-
if (candidate) return candidate;
|
|
53
|
-
}
|
|
15
|
+
return getCurrentMiniProgramRuntimeCapabilities()[capabilityName] === true;
|
|
54
16
|
}
|
|
55
17
|
function getCurrentMiniProgramPages() {
|
|
56
|
-
var _ref, _miniProgramGlobal$ge;
|
|
57
18
|
if (!supportsCurrentMiniProgramRuntimeCapability("globalPageStack")) return [];
|
|
58
19
|
const globalRuntime = getGlobalRuntime();
|
|
59
|
-
const miniProgramGlobal =
|
|
60
|
-
const getCurrentPagesFn =
|
|
20
|
+
const miniProgramGlobal = getCurrentMiniProgramGlobalObject();
|
|
21
|
+
const getCurrentPagesFn = miniProgramGlobal?.getCurrentPages ?? globalRuntime?.getCurrentPages ?? (typeof getCurrentPages !== "undefined" ? getCurrentPages : void 0);
|
|
61
22
|
if (typeof getCurrentPagesFn !== "function") return [];
|
|
62
23
|
try {
|
|
63
24
|
const pages = getCurrentPagesFn.call(miniProgramGlobal);
|
|
64
25
|
return Array.isArray(pages) ? pages : [];
|
|
65
|
-
} catch
|
|
26
|
+
} catch {
|
|
66
27
|
return [];
|
|
67
28
|
}
|
|
68
29
|
}
|
|
69
30
|
function getCurrentMiniProgramHostConfig() {
|
|
70
|
-
const
|
|
71
|
-
const hostConfigKey = getMiniProgramRuntimeHostConfigKey(resolveCurrentMiniProgramPlatform());
|
|
72
|
-
const hostConfig = globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime[hostConfigKey];
|
|
31
|
+
const hostConfig = getGlobalRuntime()?.[DEFAULT_RUNTIME_HOST_CONFIG_KEY];
|
|
73
32
|
return hostConfig && typeof hostConfig === "object" ? hostConfig : void 0;
|
|
74
33
|
}
|
|
75
34
|
function getMiniProgramRuntimeGlobalObject() {
|
|
76
|
-
|
|
77
|
-
return (_getMiniProgramGlobal = getMiniProgramGlobalObject()) !== null && _getMiniProgramGlobal !== void 0 ? _getMiniProgramGlobal : getGlobalRuntime();
|
|
35
|
+
return getCurrentMiniProgramGlobalObject() ?? getGlobalRuntime();
|
|
78
36
|
}
|
|
79
37
|
function getMiniProgramRuntimeConsoleWarn() {
|
|
80
|
-
|
|
81
|
-
return (_getMiniProgramRuntim = getMiniProgramRuntimeGlobalObject()) === null || _getMiniProgramRuntim === void 0 || (_getMiniProgramRuntim = _getMiniProgramRuntim.console) === null || _getMiniProgramRuntim === void 0 ? void 0 : _getMiniProgramRuntim.warn;
|
|
38
|
+
return getMiniProgramRuntimeGlobalObject()?.console?.warn;
|
|
82
39
|
}
|
|
83
40
|
function getCurrentMiniProgramGlobalRouter() {
|
|
84
41
|
if (!supportsCurrentMiniProgramRuntimeCapability("globalRouterApi")) return;
|
|
85
|
-
const miniProgramGlobal =
|
|
42
|
+
const miniProgramGlobal = getCurrentMiniProgramGlobalObject();
|
|
86
43
|
if (!miniProgramGlobal) return;
|
|
87
44
|
const routerMethods = Object.create(null);
|
|
88
45
|
for (const methodName of MINI_PROGRAM_GLOBAL_ROUTER_METHODS) {
|
|
@@ -96,8 +53,7 @@ function getCurrentMiniProgramGlobalRouter() {
|
|
|
96
53
|
* @description 读取宿主 app 配置中的 tabBar 页面路径(未带前导 `/`)。
|
|
97
54
|
*/
|
|
98
55
|
function getCurrentMiniProgramTabBarPagePaths() {
|
|
99
|
-
const
|
|
100
|
-
const tabBar = hostConfig === null || hostConfig === void 0 ? void 0 : hostConfig.tabBar;
|
|
56
|
+
const tabBar = getCurrentMiniProgramHostConfig()?.tabBar;
|
|
101
57
|
if (!tabBar || typeof tabBar !== "object") return [];
|
|
102
58
|
if (!("list" in tabBar) || !Array.isArray(tabBar.list)) return [];
|
|
103
59
|
const paths = [];
|
|
@@ -110,10 +66,9 @@ function getCurrentMiniProgramTabBarPagePaths() {
|
|
|
110
66
|
return paths;
|
|
111
67
|
}
|
|
112
68
|
function getScopedSlotHostGlobalObject() {
|
|
113
|
-
|
|
114
|
-
return (_getMiniProgramGlobal2 = getMiniProgramGlobalObject()) !== null && _getMiniProgramGlobal2 !== void 0 ? _getMiniProgramGlobal2 : getGlobalRuntime();
|
|
69
|
+
return getCurrentMiniProgramGlobalObject() ?? getGlobalRuntime();
|
|
115
70
|
}
|
|
116
71
|
|
|
117
72
|
//#endregion
|
|
118
|
-
export { getCurrentMiniProgramGlobalRouter, getCurrentMiniProgramHostConfig, getCurrentMiniProgramPages, getCurrentMiniProgramRuntimeCapabilities, getCurrentMiniProgramTabBarPagePaths,
|
|
73
|
+
export { getCurrentMiniProgramGlobalObject, getCurrentMiniProgramGlobalRouter, getCurrentMiniProgramHostConfig, getCurrentMiniProgramPages, getCurrentMiniProgramRuntimeCapabilities, getCurrentMiniProgramTabBarPagePaths, getMiniProgramRuntimeConsoleWarn, getMiniProgramRuntimeGlobalObject, getScopedSlotHostGlobalObject, resolveCurrentMiniProgramPlatform, supportsCurrentMiniProgramRuntimeCapability };
|
|
119
74
|
//# sourceMappingURL=platform.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.mjs","names":[],"sources":["../../../src/runtime/platform.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"platform.mjs","names":["hostConfigKey"],"sources":["../../../src/runtime/platform.ts"],"sourcesContent":["import type { MiniProgramRuntimeCapabilityName } from '@weapp-core/shared/platforms/runtime'\nimport type { MiniProgramGlobal } from './platform/globals'\nimport { DEFAULT_RUNTIME_HOST_CONFIG_KEY } from '@weapp-core/shared/platforms/runtime'\nimport { getCurrentMiniProgramGlobalObject, getCurrentMiniProgramRuntimeCapabilities } from './platform/current'\nimport { getGlobalRuntime } from './platform/globals'\n\nexport { getCurrentMiniProgramGlobalObject, getCurrentMiniProgramRuntimeCapabilities, resolveCurrentMiniProgramPlatform } from './platform/current'\nexport { getMiniProgramGlobalObject } from './platform/generic'\n\ntype MiniProgramHostConfig = Record<string, any>\ntype MiniProgramGlobalRouterMethodName = 'switchTab' | 'reLaunch' | 'redirectTo' | 'navigateTo' | 'navigateBack'\ntype MiniProgramGlobalRouter = Record<MiniProgramGlobalRouterMethodName, (...args: any[]) => any>\nconst MINI_PROGRAM_GLOBAL_ROUTER_METHODS: readonly MiniProgramGlobalRouterMethodName[] = ['switchTab', 'reLaunch', 'redirectTo', 'navigateTo', 'navigateBack']\n\nexport function supportsCurrentMiniProgramRuntimeCapability(capabilityName: MiniProgramRuntimeCapabilityName): boolean {\n return getCurrentMiniProgramRuntimeCapabilities()[capabilityName] === true\n}\n\nexport function getCurrentMiniProgramPages(): Array<Record<string, any>> {\n if (!supportsCurrentMiniProgramRuntimeCapability('globalPageStack')) {\n return []\n }\n const globalRuntime = getGlobalRuntime()\n const miniProgramGlobal = getCurrentMiniProgramGlobalObject()\n const getCurrentPagesFn = miniProgramGlobal?.getCurrentPages\n ?? globalRuntime?.getCurrentPages\n ?? (typeof getCurrentPages !== 'undefined' ? getCurrentPages : undefined)\n if (typeof getCurrentPagesFn !== 'function') {\n return []\n }\n try {\n const pages = getCurrentPagesFn.call(miniProgramGlobal)\n return Array.isArray(pages) ? pages as Array<Record<string, any>> : []\n }\n catch {\n return []\n }\n}\n\nexport function getCurrentMiniProgramHostConfig(): MiniProgramHostConfig | undefined {\n const globalRuntime = getGlobalRuntime()\n const hostConfigKey = DEFAULT_RUNTIME_HOST_CONFIG_KEY\n const hostConfig = globalRuntime?.[hostConfigKey]\n return hostConfig && typeof hostConfig === 'object' ? hostConfig as MiniProgramHostConfig : undefined\n}\n\nexport function getMiniProgramRuntimeGlobalObject(): MiniProgramGlobal | undefined {\n return getCurrentMiniProgramGlobalObject() ?? getGlobalRuntime()\n}\n\nexport function getMiniProgramRuntimeConsoleWarn(): ((message: string) => void) | undefined {\n return getMiniProgramRuntimeGlobalObject()?.console?.warn\n}\n\nexport function getCurrentMiniProgramGlobalRouter(): MiniProgramGlobalRouter | undefined {\n if (!supportsCurrentMiniProgramRuntimeCapability('globalRouterApi')) {\n return undefined\n }\n const miniProgramGlobal = getCurrentMiniProgramGlobalObject()\n if (!miniProgramGlobal) {\n return undefined\n }\n const routerMethods = Object.create(null) as Partial<MiniProgramGlobalRouter>\n for (const methodName of MINI_PROGRAM_GLOBAL_ROUTER_METHODS) {\n const handler = miniProgramGlobal[methodName]\n if (typeof handler !== 'function') {\n return undefined\n }\n routerMethods[methodName] = (...args: unknown[]) => handler.apply(miniProgramGlobal, args)\n }\n return routerMethods as MiniProgramGlobalRouter\n}\n\n/**\n * @description 读取宿主 app 配置中的 tabBar 页面路径(未带前导 `/`)。\n */\nexport function getCurrentMiniProgramTabBarPagePaths(): string[] {\n const hostConfig = getCurrentMiniProgramHostConfig()\n const tabBar = hostConfig?.tabBar\n if (!tabBar || typeof tabBar !== 'object') {\n return []\n }\n if (!('list' in tabBar) || !Array.isArray(tabBar.list)) {\n return []\n }\n const paths: string[] = []\n for (const item of tabBar.list) {\n if (!item || typeof item !== 'object' || !('pagePath' in item)) {\n continue\n }\n const pagePath = item.pagePath\n if (typeof pagePath !== 'string' || !pagePath) {\n continue\n }\n // 微信开发者工具可能把宿主配置中的页面路径输出为 `.html` 形式,\n // 路由层使用的是不带扩展名的页面路径,读取边界统一归一化。\n paths.push(pagePath.replace(/\\.html$/, ''))\n }\n return paths\n}\n\nexport function getScopedSlotHostGlobalObject(): MiniProgramGlobal | undefined {\n return getCurrentMiniProgramGlobalObject() ?? getGlobalRuntime()\n}\n"],"mappings":";;;;;;AAYA,MAAM,qCAAmF;CAAC;CAAa;CAAY;CAAc;CAAc;AAAc;AAE7J,SAAgB,4CAA4C,gBAA2D;CACrH,OAAO,yCAAyC,CAAC,CAAC,oBAAoB;AACxE;AAEA,SAAgB,6BAAyD;CACvE,IAAI,CAAC,4CAA4C,iBAAiB,GAChE,OAAO,CAAC;CAEV,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,oBAAoB,kCAAkC;CAC5D,MAAM,oBAAoB,mBAAmB,mBACxC,eAAe,oBACd,OAAO,oBAAoB,cAAc,kBAAkB;CACjE,IAAI,OAAO,sBAAsB,YAC/B,OAAO,CAAC;CAEV,IAAI;EACF,MAAM,QAAQ,kBAAkB,KAAK,iBAAiB;EACtD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAsC,CAAC;CACvE,QACM;EACJ,OAAO,CAAC;CACV;AACF;AAEA,SAAgB,kCAAqE;CAGnF,MAAM,aAFgB,iBAES,CAAC,GAAGA;CACnC,OAAO,cAAc,OAAO,eAAe,WAAW,aAAsC;AAC9F;AAEA,SAAgB,oCAAmE;CACjF,OAAO,kCAAkC,KAAK,iBAAiB;AACjE;AAEA,SAAgB,mCAA4E;CAC1F,OAAO,kCAAkC,CAAC,EAAE,SAAS;AACvD;AAEA,SAAgB,oCAAyE;CACvF,IAAI,CAAC,4CAA4C,iBAAiB,GAChE;CAEF,MAAM,oBAAoB,kCAAkC;CAC5D,IAAI,CAAC,mBACH;CAEF,MAAM,gBAAgB,OAAO,OAAO,IAAI;CACxC,KAAK,MAAM,cAAc,oCAAoC;EAC3D,MAAM,UAAU,kBAAkB;EAClC,IAAI,OAAO,YAAY,YACrB;EAEF,cAAc,eAAe,GAAG,SAAoB,QAAQ,MAAM,mBAAmB,IAAI;CAC3F;CACA,OAAO;AACT;;;;AAKA,SAAgB,uCAAiD;CAE/D,MAAM,SADa,gCACK,CAAC,EAAE;CAC3B,IAAI,CAAC,UAAU,OAAO,WAAW,UAC/B,OAAO,CAAC;CAEV,IAAI,EAAE,UAAU,WAAW,CAAC,MAAM,QAAQ,OAAO,IAAI,GACnD,OAAO,CAAC;CAEV,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,OAAO,MAAM;EAC9B,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,cAAc,OACvD;EAEF,MAAM,WAAW,KAAK;EACtB,IAAI,OAAO,aAAa,YAAY,CAAC,UACnC;EAIF,MAAM,KAAK,SAAS,QAAQ,WAAW,EAAE,CAAC;CAC5C;CACA,OAAO;AACT;AAEA,SAAgB,gCAA+D;CAC7E,OAAO,kCAAkC,KAAK,iBAAiB;AACjE"}
|
|
@@ -6,7 +6,7 @@ function isRuntimeAppInstance(instance) {
|
|
|
6
6
|
return Boolean(instance && typeof instance === "object" && instance[WEVU_IS_APP_INSTANCE_KEY] === true);
|
|
7
7
|
}
|
|
8
8
|
function createProvides(parent) {
|
|
9
|
-
return Object.create(parent
|
|
9
|
+
return Object.create(parent ?? null);
|
|
10
10
|
}
|
|
11
11
|
function getRuntimeAppProvides(runtimeApp) {
|
|
12
12
|
if (!runtimeApp) return createProvides();
|
|
@@ -20,7 +20,7 @@ function getRuntimeAppProvides(runtimeApp) {
|
|
|
20
20
|
enumerable: false,
|
|
21
21
|
writable: false
|
|
22
22
|
});
|
|
23
|
-
} catch
|
|
23
|
+
} catch {
|
|
24
24
|
runtimeApp[WEVU_APP_PROVIDES_KEY] = provides;
|
|
25
25
|
}
|
|
26
26
|
return provides;
|
|
@@ -33,16 +33,15 @@ function attachInstanceProvides(instance, provides) {
|
|
|
33
33
|
enumerable: false,
|
|
34
34
|
writable: true
|
|
35
35
|
});
|
|
36
|
-
} catch
|
|
36
|
+
} catch {
|
|
37
37
|
instance[WEVU_PROVIDES_KEY] = provides;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function getInstanceProvides(instance) {
|
|
41
|
-
var _instance$WEVU_PARENT, _instance$WEVU_PARENT2;
|
|
42
41
|
const existing = instance[WEVU_PROVIDES_KEY];
|
|
43
42
|
if (existing && typeof existing === "object") return existing;
|
|
44
43
|
const runtimeApp = instance[WEVU_RUNTIME_APP_KEY];
|
|
45
|
-
const parentProvides =
|
|
44
|
+
const parentProvides = instance[WEVU_PARENT_INSTANCE_KEY]?.[WEVU_PROVIDES_KEY] ?? getRuntimeAppProvides(runtimeApp);
|
|
46
45
|
const provides = isRuntimeAppInstance(instance) ? getRuntimeAppProvides(runtimeApp) : createProvides(parentProvides);
|
|
47
46
|
attachInstanceProvides(instance, provides);
|
|
48
47
|
return provides;
|
|
@@ -55,9 +54,8 @@ function setRuntimeAppProvidedValue(runtimeApp, key, value, options = {}) {
|
|
|
55
54
|
if (options.syncGlobal !== false) setGlobalProvidedValue(key, value);
|
|
56
55
|
}
|
|
57
56
|
function attachRuntimeProvideContext(instance, runtimeApp, parentInstance) {
|
|
58
|
-
var _parentInstance$WEVU_;
|
|
59
57
|
const appProvides = getRuntimeAppProvides(runtimeApp);
|
|
60
|
-
const parentProvides =
|
|
58
|
+
const parentProvides = parentInstance?.[WEVU_PROVIDES_KEY] ?? appProvides;
|
|
61
59
|
const provides = isRuntimeAppInstance(instance) ? appProvides : createProvides(parentProvides);
|
|
62
60
|
if (parentInstance) try {
|
|
63
61
|
Object.defineProperty(instance, WEVU_PARENT_INSTANCE_KEY, {
|
|
@@ -66,7 +64,7 @@ function attachRuntimeProvideContext(instance, runtimeApp, parentInstance) {
|
|
|
66
64
|
enumerable: false,
|
|
67
65
|
writable: true
|
|
68
66
|
});
|
|
69
|
-
} catch
|
|
67
|
+
} catch {
|
|
70
68
|
instance[WEVU_PARENT_INSTANCE_KEY] = parentInstance;
|
|
71
69
|
}
|
|
72
70
|
attachInstanceProvides(instance, provides);
|
|
@@ -91,7 +89,7 @@ function attachRuntimeLayoutProvideContext(layoutInstance, pageInstance) {
|
|
|
91
89
|
enumerable: false,
|
|
92
90
|
writable: true
|
|
93
91
|
});
|
|
94
|
-
} catch
|
|
92
|
+
} catch {
|
|
95
93
|
pageInstance[WEVU_PARENT_INSTANCE_KEY] = layoutInstance;
|
|
96
94
|
}
|
|
97
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provideContext.mjs","names":[],"sources":["../../../src/runtime/provideContext.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeApp } from './types'\nimport {\n WEVU_APP_PROVIDES_KEY,\n WEVU_IS_APP_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROVIDES_KEY,\n WEVU_RUNTIME_APP_KEY,\n} from '@weapp-core/constants'\nimport { setGlobalProvidedValue } from './provideStore'\n\nexport function isRuntimeAppInstance(instance: unknown): boolean {\n return Boolean(\n instance\n && typeof instance === 'object'\n && (instance as { [WEVU_IS_APP_INSTANCE_KEY]?: boolean })[WEVU_IS_APP_INSTANCE_KEY] === true,\n )\n}\n\nfunction createProvides(parent?: Record<PropertyKey, any>) {\n return Object.create(parent ?? null) as Record<PropertyKey, any>\n}\n\nfunction getRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any> | undefined): Record<PropertyKey, any> {\n if (!runtimeApp) {\n return createProvides()\n }\n const existing = runtimeApp[WEVU_APP_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n const provides = createProvides()\n try {\n Object.defineProperty(runtimeApp, WEVU_APP_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any)[WEVU_APP_PROVIDES_KEY] = provides\n }\n return provides\n}\n\nexport function attachInstanceProvides(\n instance: InternalRuntimeState,\n provides: Record<PropertyKey, any>,\n): void {\n try {\n Object.defineProperty(instance, WEVU_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PROVIDES_KEY] = provides\n }\n}\n\nexport function getInstanceProvides(instance: InternalRuntimeState): Record<PropertyKey, any> {\n const existing = instance[WEVU_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n\n const runtimeApp = instance[WEVU_RUNTIME_APP_KEY]\n const parentProvides = instance[WEVU_PARENT_INSTANCE_KEY]?.[WEVU_PROVIDES_KEY]\n ?? getRuntimeAppProvides(runtimeApp)\n const provides = isRuntimeAppInstance(instance)\n ? getRuntimeAppProvides(runtimeApp)\n : createProvides(parentProvides)\n attachInstanceProvides(instance, provides)\n return provides\n}\n\nexport function ensureRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any>): Record<PropertyKey, any> {\n return getRuntimeAppProvides(runtimeApp)\n}\n\nexport function setRuntimeAppProvidedValue<T>(\n runtimeApp: RuntimeApp<any, any, any>,\n key: any,\n value: T,\n options: { syncGlobal?: boolean } = {},\n): void {\n getRuntimeAppProvides(runtimeApp)[key as PropertyKey] = value\n if (options.syncGlobal !== false) {\n setGlobalProvidedValue(key, value)\n }\n}\n\nexport function attachRuntimeProvideContext(\n instance: InternalRuntimeState,\n runtimeApp: RuntimeApp<any, any, any>,\n parentInstance?: InternalRuntimeState,\n): void {\n const appProvides = getRuntimeAppProvides(runtimeApp)\n const parentProvides = parentInstance?.[WEVU_PROVIDES_KEY] ?? appProvides\n const provides = isRuntimeAppInstance(instance)\n ? appProvides\n : createProvides(parentProvides)\n\n if (parentInstance) {\n try {\n Object.defineProperty(instance, WEVU_PARENT_INSTANCE_KEY, {\n value: parentInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PARENT_INSTANCE_KEY] = parentInstance\n }\n }\n\n attachInstanceProvides(instance, provides)\n}\n\nfunction isPrototypeInChain(target: Record<PropertyKey, any>, candidate: Record<PropertyKey, any>) {\n let current = Object.getPrototypeOf(target)\n while (current) {\n if (current === candidate) {\n return true\n }\n current = Object.getPrototypeOf(current)\n }\n return false\n}\n\nexport function attachRuntimeLayoutProvideContext(\n layoutInstance: InternalRuntimeState,\n pageInstance: InternalRuntimeState,\n): void {\n const layoutProvides = getInstanceProvides(layoutInstance)\n const pageProvides = getInstanceProvides(pageInstance)\n if (\n layoutProvides === pageProvides\n || isPrototypeInChain(layoutProvides, pageProvides)\n || isPrototypeInChain(pageProvides, layoutProvides)\n ) {\n return\n }\n\n Object.setPrototypeOf(pageProvides, layoutProvides)\n\n try {\n Object.defineProperty(pageInstance, WEVU_PARENT_INSTANCE_KEY, {\n value: layoutInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(pageInstance as any)[WEVU_PARENT_INSTANCE_KEY] = layoutInstance\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,qBAAqB,UAA4B;CAC/D,OAAO,QACL,YACG,OAAO,aAAa,YACnB,SAAsD,8BAA8B,IAC1F;AACF;AAEA,SAAS,eAAe,QAAmC;CACzD,OAAO,OAAO,OAAO,
|
|
1
|
+
{"version":3,"file":"provideContext.mjs","names":[],"sources":["../../../src/runtime/provideContext.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeApp } from './types'\nimport {\n WEVU_APP_PROVIDES_KEY,\n WEVU_IS_APP_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROVIDES_KEY,\n WEVU_RUNTIME_APP_KEY,\n} from '@weapp-core/constants'\nimport { setGlobalProvidedValue } from './provideStore'\n\nexport function isRuntimeAppInstance(instance: unknown): boolean {\n return Boolean(\n instance\n && typeof instance === 'object'\n && (instance as { [WEVU_IS_APP_INSTANCE_KEY]?: boolean })[WEVU_IS_APP_INSTANCE_KEY] === true,\n )\n}\n\nfunction createProvides(parent?: Record<PropertyKey, any>) {\n return Object.create(parent ?? null) as Record<PropertyKey, any>\n}\n\nfunction getRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any> | undefined): Record<PropertyKey, any> {\n if (!runtimeApp) {\n return createProvides()\n }\n const existing = runtimeApp[WEVU_APP_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n const provides = createProvides()\n try {\n Object.defineProperty(runtimeApp, WEVU_APP_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any)[WEVU_APP_PROVIDES_KEY] = provides\n }\n return provides\n}\n\nexport function attachInstanceProvides(\n instance: InternalRuntimeState,\n provides: Record<PropertyKey, any>,\n): void {\n try {\n Object.defineProperty(instance, WEVU_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PROVIDES_KEY] = provides\n }\n}\n\nexport function getInstanceProvides(instance: InternalRuntimeState): Record<PropertyKey, any> {\n const existing = instance[WEVU_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n\n const runtimeApp = instance[WEVU_RUNTIME_APP_KEY]\n const parentProvides = instance[WEVU_PARENT_INSTANCE_KEY]?.[WEVU_PROVIDES_KEY]\n ?? getRuntimeAppProvides(runtimeApp)\n const provides = isRuntimeAppInstance(instance)\n ? getRuntimeAppProvides(runtimeApp)\n : createProvides(parentProvides)\n attachInstanceProvides(instance, provides)\n return provides\n}\n\nexport function ensureRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any>): Record<PropertyKey, any> {\n return getRuntimeAppProvides(runtimeApp)\n}\n\nexport function setRuntimeAppProvidedValue<T>(\n runtimeApp: RuntimeApp<any, any, any>,\n key: any,\n value: T,\n options: { syncGlobal?: boolean } = {},\n): void {\n getRuntimeAppProvides(runtimeApp)[key as PropertyKey] = value\n if (options.syncGlobal !== false) {\n setGlobalProvidedValue(key, value)\n }\n}\n\nexport function attachRuntimeProvideContext(\n instance: InternalRuntimeState,\n runtimeApp: RuntimeApp<any, any, any>,\n parentInstance?: InternalRuntimeState,\n): void {\n const appProvides = getRuntimeAppProvides(runtimeApp)\n const parentProvides = parentInstance?.[WEVU_PROVIDES_KEY] ?? appProvides\n const provides = isRuntimeAppInstance(instance)\n ? appProvides\n : createProvides(parentProvides)\n\n if (parentInstance) {\n try {\n Object.defineProperty(instance, WEVU_PARENT_INSTANCE_KEY, {\n value: parentInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PARENT_INSTANCE_KEY] = parentInstance\n }\n }\n\n attachInstanceProvides(instance, provides)\n}\n\nfunction isPrototypeInChain(target: Record<PropertyKey, any>, candidate: Record<PropertyKey, any>) {\n let current = Object.getPrototypeOf(target)\n while (current) {\n if (current === candidate) {\n return true\n }\n current = Object.getPrototypeOf(current)\n }\n return false\n}\n\nexport function attachRuntimeLayoutProvideContext(\n layoutInstance: InternalRuntimeState,\n pageInstance: InternalRuntimeState,\n): void {\n const layoutProvides = getInstanceProvides(layoutInstance)\n const pageProvides = getInstanceProvides(pageInstance)\n if (\n layoutProvides === pageProvides\n || isPrototypeInChain(layoutProvides, pageProvides)\n || isPrototypeInChain(pageProvides, layoutProvides)\n ) {\n return\n }\n\n Object.setPrototypeOf(pageProvides, layoutProvides)\n\n try {\n Object.defineProperty(pageInstance, WEVU_PARENT_INSTANCE_KEY, {\n value: layoutInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(pageInstance as any)[WEVU_PARENT_INSTANCE_KEY] = layoutInstance\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,qBAAqB,UAA4B;CAC/D,OAAO,QACL,YACG,OAAO,aAAa,YACnB,SAAsD,8BAA8B,IAC1F;AACF;AAEA,SAAS,eAAe,QAAmC;CACzD,OAAO,OAAO,OAAO,UAAU,IAAI;AACrC;AAEA,SAAS,sBAAsB,YAA6E;CAC1G,IAAI,CAAC,YACH,OAAO,eAAe;CAExB,MAAM,WAAW,WAAW;CAC5B,IAAI,YAAY,OAAO,aAAa,UAClC,OAAO;CAET,MAAM,WAAW,eAAe;CAChC,IAAI;EACF,OAAO,eAAe,YAAY,uBAAuB;GACvD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,QACM;EACH,AAAC,WAAmB,yBAAyB;CAChD;CACA,OAAO;AACT;AAEA,SAAgB,uBACd,UACA,UACM;CACN,IAAI;EACF,OAAO,eAAe,UAAU,mBAAmB;GACjD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,QACM;EACH,AAAC,SAAiB,qBAAqB;CAC1C;AACF;AAEA,SAAgB,oBAAoB,UAA0D;CAC5F,MAAM,WAAW,SAAS;CAC1B,IAAI,YAAY,OAAO,aAAa,UAClC,OAAO;CAGT,MAAM,aAAa,SAAS;CAC5B,MAAM,iBAAiB,SAAS,yBAAyB,GAAG,sBACvD,sBAAsB,UAAU;CACrC,MAAM,WAAW,qBAAqB,QAAQ,IAC1C,sBAAsB,UAAU,IAChC,eAAe,cAAc;CACjC,uBAAuB,UAAU,QAAQ;CACzC,OAAO;AACT;AAEA,SAAgB,yBAAyB,YAAiE;CACxG,OAAO,sBAAsB,UAAU;AACzC;AAEA,SAAgB,2BACd,YACA,KACA,OACA,UAAoC,CAAC,GAC/B;CACN,sBAAsB,UAAU,CAAC,CAAC,OAAsB;CACxD,IAAI,QAAQ,eAAe,OACzB,uBAAuB,KAAK,KAAK;AAErC;AAEA,SAAgB,4BACd,UACA,YACA,gBACM;CACN,MAAM,cAAc,sBAAsB,UAAU;CACpD,MAAM,iBAAiB,iBAAiB,sBAAsB;CAC9D,MAAM,WAAW,qBAAqB,QAAQ,IAC1C,cACA,eAAe,cAAc;CAEjC,IAAI,gBACF,IAAI;EACF,OAAO,eAAe,UAAU,0BAA0B;GACxD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,QACM;EACH,AAAC,SAAiB,4BAA4B;CACjD;CAGF,uBAAuB,UAAU,QAAQ;AAC3C;AAEA,SAAS,mBAAmB,QAAkC,WAAqC;CACjG,IAAI,UAAU,OAAO,eAAe,MAAM;CAC1C,OAAO,SAAS;EACd,IAAI,YAAY,WACd,OAAO;EAET,UAAU,OAAO,eAAe,OAAO;CACzC;CACA,OAAO;AACT;AAEA,SAAgB,kCACd,gBACA,cACM;CACN,MAAM,iBAAiB,oBAAoB,cAAc;CACzD,MAAM,eAAe,oBAAoB,YAAY;CACrD,IACE,mBAAmB,gBAChB,mBAAmB,gBAAgB,YAAY,KAC/C,mBAAmB,cAAc,cAAc,GAElD;CAGF,OAAO,eAAe,cAAc,cAAc;CAElD,IAAI;EACF,OAAO,eAAe,cAAc,0BAA0B;GAC5D,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,QACM;EACH,AAAC,aAAqB,4BAA4B;CACrD;AACF"}
|
|
@@ -7,6 +7,7 @@ import { registerComponent as registerComponent$1 } from "./register/component.m
|
|
|
7
7
|
import { createApp as createApp$1 } from "./app.mjs";
|
|
8
8
|
import { createWevuComponent as createWevuComponent$1, defineComponent as defineComponent$1 } from "./define.mjs";
|
|
9
9
|
import { installInlineEvents } from "./features/inlineEvents.mjs";
|
|
10
|
+
import { installJsxIslands } from "./features/jsxIslands.mjs";
|
|
10
11
|
import { installPatchStrategy } from "./features/patchStrategy.mjs";
|
|
11
12
|
import { createWevuScopedSlotComponent as createWevuScopedSlotComponent$1, installScopedSlots } from "./features/scopedSlots.mjs";
|
|
12
13
|
import { installSetDataHighFrequencyWarning } from "./features/setDataHighFrequencyWarning.mjs";
|
|
@@ -35,6 +36,7 @@ function installPublicMetadataCapabilities(value) {
|
|
|
35
36
|
function installPublicFactoryCapabilities(options) {
|
|
36
37
|
installPublicOptionCapabilities();
|
|
37
38
|
installInlineEvents();
|
|
39
|
+
installJsxIslands();
|
|
38
40
|
installScopedSlots();
|
|
39
41
|
installPublicMetadataCapabilities(options);
|
|
40
42
|
}
|
|
@@ -59,6 +61,7 @@ const registerApp = (runtimeApp, methods, watch, setup, mpOptions) => {
|
|
|
59
61
|
};
|
|
60
62
|
const registerComponent = (runtimeApp, methods, watch, setup, mpOptions, options) => {
|
|
61
63
|
installPublicOptionCapabilities();
|
|
64
|
+
installJsxIslands();
|
|
62
65
|
installPublicMetadataCapabilities(runtimeApp);
|
|
63
66
|
installPublicMetadataCapabilities(methods);
|
|
64
67
|
installPublicMetadataCapabilities(mpOptions);
|
|
@@ -81,6 +84,7 @@ const setWevuDefaults = (defaults) => {
|
|
|
81
84
|
function createWevuScopedSlotComponent(overrides) {
|
|
82
85
|
installTemplateRefs();
|
|
83
86
|
installInlineEvents();
|
|
87
|
+
installJsxIslands();
|
|
84
88
|
installScopedSlots();
|
|
85
89
|
installLayout();
|
|
86
90
|
createWevuScopedSlotComponent$1(overrides);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicRuntime.mjs","names":["createAppCore","defineComponentCore","createWevuComponentCore","registerAppCore","registerComponentCore","mountRuntimeInstanceCore","setWevuDefaultsCore"],"sources":["../../../src/runtime/publicRuntime.ts"],"sourcesContent":["import type { CreateWevuScopedSlotComponentOptions } from './features/scopedSlots'\nimport {\n WEVU_INLINE_MAP_KEY,\n WEVU_SCOPED_SLOT_OWNER_REQUIRED_KEY,\n WEVU_SLOT_OWNER_ID_KEY,\n} from '@weapp-core/constants'\nimport { createApp as createAppCore } from './app'\nimport { setWevuDefaults as setWevuDefaultsCore } from './defaults'\nimport {\n createWevuComponent as createWevuComponentCore,\n defineComponent as defineComponentCore,\n} from './define'\nimport { installInlineEvents } from './features/inlineEvents'\nimport { installLayout } from './features/layout'\nimport { installPatchStrategy } from './features/patchStrategy'\nimport {\n createWevuScopedSlotComponent as createWevuScopedSlotComponentCore,\n installScopedSlots,\n} from './features/scopedSlots'\nimport { installSetDataHighFrequencyWarning } from './features/setDataHighFrequencyWarning'\nimport { installTemplateRefs } from './features/templateRefs'\nimport {\n mountRuntimeInstance as mountRuntimeInstanceCore,\n registerApp as registerAppCore,\n registerComponent as registerComponentCore,\n} from './register'\n\nfunction installPublicOptionCapabilities(): void {\n installPatchStrategy()\n installSetDataHighFrequencyWarning()\n}\n\nfunction installPublicMetadataCapabilities(value: unknown): void {\n if (!value || typeof value !== 'object') {\n return\n }\n const record = value as Record<string, unknown>\n const directInlineMap = record[WEVU_INLINE_MAP_KEY]\n const methods = record.methods\n const nestedInlineMap = methods && typeof methods === 'object'\n ? (methods as Record<string, unknown>)[WEVU_INLINE_MAP_KEY]\n : undefined\n if (\n (directInlineMap && typeof directInlineMap === 'object' && Object.keys(directInlineMap).length)\n || (nestedInlineMap && typeof nestedInlineMap === 'object' && Object.keys(nestedInlineMap).length)\n ) {\n installInlineEvents()\n }\n const templateRefs = record.__wevuTemplateRefs\n if (Array.isArray(templateRefs) && templateRefs.length) {\n installTemplateRefs()\n }\n const layoutHosts = record.__wevuLayoutHosts\n if (Array.isArray(layoutHosts) && layoutHosts.length) {\n installLayout()\n }\n const setData = record.setData\n const pick = setData && typeof setData === 'object'\n ? (setData as Record<string, unknown>).pick\n : undefined\n if (\n record[WEVU_SCOPED_SLOT_OWNER_REQUIRED_KEY] === true\n || record.__wevuHasTemplateRuntimeBindings === true\n || (Array.isArray(pick) && pick.includes(WEVU_SLOT_OWNER_ID_KEY))\n ) {\n installScopedSlots()\n }\n}\n\nfunction installPublicFactoryCapabilities(options: unknown): void {\n installPublicOptionCapabilities()\n installInlineEvents()\n installScopedSlots()\n installPublicMetadataCapabilities(options)\n}\n\nexport const createApp: typeof createAppCore = (options) => {\n installPublicFactoryCapabilities(options)\n return createAppCore(options)\n}\n\nexport const defineComponent = ((options: Parameters<typeof defineComponentCore>[0]) => {\n installPublicFactoryCapabilities(options)\n return defineComponentCore(options)\n}) as typeof defineComponentCore\n\nexport const createWevuComponent: typeof createWevuComponentCore = (options) => {\n installPublicFactoryCapabilities(options)\n return createWevuComponentCore(options)\n}\n\nexport const registerApp: typeof registerAppCore = (runtimeApp, methods, watch, setup, mpOptions) => {\n installPublicOptionCapabilities()\n installPublicMetadataCapabilities(runtimeApp)\n installPublicMetadataCapabilities(methods)\n installPublicMetadataCapabilities(mpOptions)\n return registerAppCore(runtimeApp, methods, watch, setup, mpOptions)\n}\n\nexport const registerComponent: typeof registerComponentCore = (\n runtimeApp,\n methods,\n watch,\n setup,\n mpOptions,\n options,\n) => {\n installPublicOptionCapabilities()\n installPublicMetadataCapabilities(runtimeApp)\n installPublicMetadataCapabilities(methods)\n installPublicMetadataCapabilities(mpOptions)\n return registerComponentCore(runtimeApp, methods, watch, setup, mpOptions, options)\n}\n\nexport const mountRuntimeInstance: typeof mountRuntimeInstanceCore = (\n target,\n runtimeApp,\n watch,\n setup,\n options,\n) => {\n installPublicOptionCapabilities()\n installPublicMetadataCapabilities(target)\n installPublicMetadataCapabilities(runtimeApp)\n return mountRuntimeInstanceCore(target, runtimeApp, watch, setup, options)\n}\n\nexport const setWevuDefaults: typeof setWevuDefaultsCore = (defaults) => {\n installPatchStrategy()\n installSetDataHighFrequencyWarning()\n return setWevuDefaultsCore(defaults)\n}\n\n/**\n * 创建公开入口的作用域插槽组件,并保留历史上的完整能力行为。\n */\nexport function createWevuScopedSlotComponent(\n overrides?: CreateWevuScopedSlotComponentOptions,\n): void {\n installTemplateRefs()\n installInlineEvents()\n installScopedSlots()\n installLayout()\n createWevuScopedSlotComponentCore(overrides)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"publicRuntime.mjs","names":["createAppCore","defineComponentCore","createWevuComponentCore","registerAppCore","registerComponentCore","mountRuntimeInstanceCore","setWevuDefaultsCore"],"sources":["../../../src/runtime/publicRuntime.ts"],"sourcesContent":["import type { CreateWevuScopedSlotComponentOptions } from './features/scopedSlots'\nimport {\n WEVU_INLINE_MAP_KEY,\n WEVU_SCOPED_SLOT_OWNER_REQUIRED_KEY,\n WEVU_SLOT_OWNER_ID_KEY,\n} from '@weapp-core/constants'\nimport { createApp as createAppCore } from './app'\nimport { setWevuDefaults as setWevuDefaultsCore } from './defaults'\nimport {\n createWevuComponent as createWevuComponentCore,\n defineComponent as defineComponentCore,\n} from './define'\nimport { installInlineEvents } from './features/inlineEvents'\nimport { installJsxIslands } from './features/jsxIslands'\nimport { installLayout } from './features/layout'\nimport { installPatchStrategy } from './features/patchStrategy'\nimport {\n createWevuScopedSlotComponent as createWevuScopedSlotComponentCore,\n installScopedSlots,\n} from './features/scopedSlots'\nimport { installSetDataHighFrequencyWarning } from './features/setDataHighFrequencyWarning'\nimport { installTemplateRefs } from './features/templateRefs'\nimport {\n mountRuntimeInstance as mountRuntimeInstanceCore,\n registerApp as registerAppCore,\n registerComponent as registerComponentCore,\n} from './register'\n\nfunction installPublicOptionCapabilities(): void {\n installPatchStrategy()\n installSetDataHighFrequencyWarning()\n}\n\nfunction installPublicMetadataCapabilities(value: unknown): void {\n if (!value || typeof value !== 'object') {\n return\n }\n const record = value as Record<string, unknown>\n const directInlineMap = record[WEVU_INLINE_MAP_KEY]\n const methods = record.methods\n const nestedInlineMap = methods && typeof methods === 'object'\n ? (methods as Record<string, unknown>)[WEVU_INLINE_MAP_KEY]\n : undefined\n if (\n (directInlineMap && typeof directInlineMap === 'object' && Object.keys(directInlineMap).length)\n || (nestedInlineMap && typeof nestedInlineMap === 'object' && Object.keys(nestedInlineMap).length)\n ) {\n installInlineEvents()\n }\n const templateRefs = record.__wevuTemplateRefs\n if (Array.isArray(templateRefs) && templateRefs.length) {\n installTemplateRefs()\n }\n const layoutHosts = record.__wevuLayoutHosts\n if (Array.isArray(layoutHosts) && layoutHosts.length) {\n installLayout()\n }\n const setData = record.setData\n const pick = setData && typeof setData === 'object'\n ? (setData as Record<string, unknown>).pick\n : undefined\n if (\n record[WEVU_SCOPED_SLOT_OWNER_REQUIRED_KEY] === true\n || record.__wevuHasTemplateRuntimeBindings === true\n || (Array.isArray(pick) && pick.includes(WEVU_SLOT_OWNER_ID_KEY))\n ) {\n installScopedSlots()\n }\n}\n\nfunction installPublicFactoryCapabilities(options: unknown): void {\n installPublicOptionCapabilities()\n installInlineEvents()\n installJsxIslands()\n installScopedSlots()\n installPublicMetadataCapabilities(options)\n}\n\nexport const createApp: typeof createAppCore = (options) => {\n installPublicFactoryCapabilities(options)\n return createAppCore(options)\n}\n\nexport const defineComponent = ((options: Parameters<typeof defineComponentCore>[0]) => {\n installPublicFactoryCapabilities(options)\n return defineComponentCore(options)\n}) as typeof defineComponentCore\n\nexport const createWevuComponent: typeof createWevuComponentCore = (options) => {\n installPublicFactoryCapabilities(options)\n return createWevuComponentCore(options)\n}\n\nexport const registerApp: typeof registerAppCore = (runtimeApp, methods, watch, setup, mpOptions) => {\n installPublicOptionCapabilities()\n installPublicMetadataCapabilities(runtimeApp)\n installPublicMetadataCapabilities(methods)\n installPublicMetadataCapabilities(mpOptions)\n return registerAppCore(runtimeApp, methods, watch, setup, mpOptions)\n}\n\nexport const registerComponent: typeof registerComponentCore = (\n runtimeApp,\n methods,\n watch,\n setup,\n mpOptions,\n options,\n) => {\n installPublicOptionCapabilities()\n installJsxIslands()\n installPublicMetadataCapabilities(runtimeApp)\n installPublicMetadataCapabilities(methods)\n installPublicMetadataCapabilities(mpOptions)\n return registerComponentCore(runtimeApp, methods, watch, setup, mpOptions, options)\n}\n\nexport const mountRuntimeInstance: typeof mountRuntimeInstanceCore = (\n target,\n runtimeApp,\n watch,\n setup,\n options,\n) => {\n installPublicOptionCapabilities()\n installPublicMetadataCapabilities(target)\n installPublicMetadataCapabilities(runtimeApp)\n return mountRuntimeInstanceCore(target, runtimeApp, watch, setup, options)\n}\n\nexport const setWevuDefaults: typeof setWevuDefaultsCore = (defaults) => {\n installPatchStrategy()\n installSetDataHighFrequencyWarning()\n return setWevuDefaultsCore(defaults)\n}\n\n/**\n * 创建公开入口的作用域插槽组件,并保留历史上的完整能力行为。\n */\nexport function createWevuScopedSlotComponent(\n overrides?: CreateWevuScopedSlotComponentOptions,\n): void {\n installTemplateRefs()\n installInlineEvents()\n installJsxIslands()\n installScopedSlots()\n installLayout()\n createWevuScopedSlotComponentCore(overrides)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAS,kCAAwC;CAC/C,qBAAqB;CACrB,mCAAmC;AACrC;AAEA,SAAS,kCAAkC,OAAsB;CAC/D,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B;CAEF,MAAM,SAAS;CACf,MAAM,kBAAkB,OAAO;CAC/B,MAAM,UAAU,OAAO;CACvB,MAAM,kBAAkB,WAAW,OAAO,YAAY,WACjD,QAAoC,uBACrC;CACJ,IACG,mBAAmB,OAAO,oBAAoB,YAAY,OAAO,KAAK,eAAe,CAAC,CAAC,UACpF,mBAAmB,OAAO,oBAAoB,YAAY,OAAO,KAAK,eAAe,CAAC,CAAC,QAE3F,oBAAoB;CAEtB,MAAM,eAAe,OAAO;CAC5B,IAAI,MAAM,QAAQ,YAAY,KAAK,aAAa,QAC9C,oBAAoB;CAEtB,MAAM,cAAc,OAAO;CAC3B,IAAI,MAAM,QAAQ,WAAW,KAAK,YAAY,QAC5C,cAAc;CAEhB,MAAM,UAAU,OAAO;CACvB,MAAM,OAAO,WAAW,OAAO,YAAY,WACtC,QAAoC,OACrC;CACJ,IACE,OAAO,yCAAyC,QAC7C,OAAO,qCAAqC,QAC3C,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,sBAAsB,GAE/D,mBAAmB;AAEvB;AAEA,SAAS,iCAAiC,SAAwB;CAChE,gCAAgC;CAChC,oBAAoB;CACpB,kBAAkB;CAClB,mBAAmB;CACnB,kCAAkC,OAAO;AAC3C;AAEA,MAAa,aAAmC,YAAY;CAC1D,iCAAiC,OAAO;CACxC,OAAOA,YAAc,OAAO;AAC9B;AAEA,MAAa,oBAAoB,YAAuD;CACtF,iCAAiC,OAAO;CACxC,OAAOC,kBAAoB,OAAO;AACpC;AAEA,MAAa,uBAAuD,YAAY;CAC9E,iCAAiC,OAAO;CACxC,OAAOC,sBAAwB,OAAO;AACxC;AAEA,MAAa,eAAuC,YAAY,SAAS,OAAO,OAAO,cAAc;CACnG,gCAAgC;CAChC,kCAAkC,UAAU;CAC5C,kCAAkC,OAAO;CACzC,kCAAkC,SAAS;CAC3C,OAAOC,cAAgB,YAAY,SAAS,OAAO,OAAO,SAAS;AACrE;AAEA,MAAa,qBACX,YACA,SACA,OACA,OACA,WACA,YACG;CACH,gCAAgC;CAChC,kBAAkB;CAClB,kCAAkC,UAAU;CAC5C,kCAAkC,OAAO;CACzC,kCAAkC,SAAS;CAC3C,OAAOC,oBAAsB,YAAY,SAAS,OAAO,OAAO,WAAW,OAAO;AACpF;AAEA,MAAa,wBACX,QACA,YACA,OACA,OACA,YACG;CACH,gCAAgC;CAChC,kCAAkC,MAAM;CACxC,kCAAkC,UAAU;CAC5C,OAAOC,uBAAyB,QAAQ,YAAY,OAAO,OAAO,OAAO;AAC3E;AAEA,MAAa,mBAA+C,aAAa;CACvE,qBAAqB;CACrB,mCAAmC;CACnC,OAAOC,kBAAoB,QAAQ;AACrC;;;;AAKA,SAAgB,8BACd,WACM;CACN,oBAAoB;CACpB,oBAAoB;CACpB,kBAAkB;CAClB,mBAAmB;CACnB,cAAc;CACd,gCAAkC,SAAS;AAC7C"}
|
|
@@ -10,11 +10,9 @@ function useAsyncPullDownRefresh(refresh, options = {}) {
|
|
|
10
10
|
try {
|
|
11
11
|
await refresh();
|
|
12
12
|
} catch (error) {
|
|
13
|
-
|
|
14
|
-
await ((_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, error));
|
|
13
|
+
await options.onError?.(error);
|
|
15
14
|
} finally {
|
|
16
|
-
|
|
17
|
-
await ((_options$stopPullDown = options.stopPullDownRefresh) !== null && _options$stopPullDown !== void 0 ? _options$stopPullDown : (() => wpi.stopPullDownRefresh()))();
|
|
15
|
+
await (options.stopPullDownRefresh ?? (() => wpi.stopPullDownRefresh()))();
|
|
18
16
|
}
|
|
19
17
|
});
|
|
20
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullDownRefresh.mjs","names":[],"sources":["../../../src/runtime/pullDownRefresh.ts"],"sourcesContent":["import { wpi } from '@wevu/api'\nimport { onPullDownRefresh } from './hooks'\n\nexport type PullDownRefreshHandler = () => void | Promise<void>\n\nexport interface UseAsyncPullDownRefreshOptions {\n onError?: (error: unknown) => void | Promise<void>\n stopPullDownRefresh?: () => unknown | Promise<unknown>\n}\n\n/**\n * 注册下拉刷新回调,并在回调结束后自动停止宿主下拉刷新状态。\n */\nexport function useAsyncPullDownRefresh(\n refresh: PullDownRefreshHandler,\n options: UseAsyncPullDownRefreshOptions = {},\n) {\n onPullDownRefresh(async () => {\n try {\n await refresh()\n }\n catch (error) {\n await options.onError?.(error)\n }\n finally {\n const stop = options.stopPullDownRefresh ?? (() => wpi.stopPullDownRefresh())\n await stop()\n }\n })\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,wBACd,SACA,UAA0C,CAAC,GAC3C;CACA,kBAAkB,YAAY;EAC5B,IAAI;GACF,MAAM,QAAQ;EAChB,SACO,OAAO
|
|
1
|
+
{"version":3,"file":"pullDownRefresh.mjs","names":[],"sources":["../../../src/runtime/pullDownRefresh.ts"],"sourcesContent":["import { wpi } from '@wevu/api'\nimport { onPullDownRefresh } from './hooks'\n\nexport type PullDownRefreshHandler = () => void | Promise<void>\n\nexport interface UseAsyncPullDownRefreshOptions {\n onError?: (error: unknown) => void | Promise<void>\n stopPullDownRefresh?: () => unknown | Promise<unknown>\n}\n\n/**\n * 注册下拉刷新回调,并在回调结束后自动停止宿主下拉刷新状态。\n */\nexport function useAsyncPullDownRefresh(\n refresh: PullDownRefreshHandler,\n options: UseAsyncPullDownRefreshOptions = {},\n) {\n onPullDownRefresh(async () => {\n try {\n await refresh()\n }\n catch (error) {\n await options.onError?.(error)\n }\n finally {\n const stop = options.stopPullDownRefresh ?? (() => wpi.stopPullDownRefresh())\n await stop()\n }\n })\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,wBACd,SACA,UAA0C,CAAC,GAC3C;CACA,kBAAkB,YAAY;EAC5B,IAAI;GACF,MAAM,QAAQ;EAChB,SACO,OAAO;GACZ,MAAM,QAAQ,UAAU,KAAK;EAC/B,UACQ;GAEN,OADa,QAAQ,8BAA8B,IAAI,oBAAoB,GACjE,CAAC;EACb;CACF,CAAC;AACH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCurrentMiniProgramGlobalObject } from "../platform/current.mjs";
|
|
2
|
+
import { supportsCurrentMiniProgramRuntimeCapability } from "../platform.mjs";
|
|
2
3
|
import { callHookList } from "../hooks/base.mjs";
|
|
3
4
|
import { requireRuntimeCapability } from "../capabilities.mjs";
|
|
4
5
|
import { mountRuntimeInstance } from "./runtimeInstance.mjs";
|
|
@@ -9,19 +10,19 @@ const APP_GLOBAL_LISTENER_STORE_KEY = "__wevuAppGlobalListeners";
|
|
|
9
10
|
const MEMORY_WARNING_LISTENER_KEY = "__wevuOnMemoryWarningListener";
|
|
10
11
|
function bindMemoryWarningListener(target) {
|
|
11
12
|
const hooks = target[WEVU_HOOKS_KEY];
|
|
12
|
-
const hasMemoryWarningHook = Boolean(hooks
|
|
13
|
+
const hasMemoryWarningHook = Boolean(hooks?.onMemoryWarning);
|
|
13
14
|
if (!supportsCurrentMiniProgramRuntimeCapability("appMemoryWarningListener")) {
|
|
14
15
|
delete target[MEMORY_WARNING_LISTENER_KEY];
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
const miniProgramGlobal =
|
|
18
|
-
const onMemoryWarning = miniProgramGlobal
|
|
19
|
-
const offMemoryWarning = miniProgramGlobal
|
|
18
|
+
const miniProgramGlobal = getCurrentMiniProgramGlobalObject();
|
|
19
|
+
const onMemoryWarning = miniProgramGlobal?.onMemoryWarning;
|
|
20
|
+
const offMemoryWarning = miniProgramGlobal?.offMemoryWarning;
|
|
20
21
|
if (typeof onMemoryWarning !== "function") return;
|
|
21
22
|
const existing = target[MEMORY_WARNING_LISTENER_KEY];
|
|
22
23
|
if (typeof existing === "function" && typeof offMemoryWarning === "function") try {
|
|
23
24
|
offMemoryWarning(existing);
|
|
24
|
-
} catch
|
|
25
|
+
} catch {}
|
|
25
26
|
if (!hasMemoryWarningHook) {
|
|
26
27
|
delete target[MEMORY_WARNING_LISTENER_KEY];
|
|
27
28
|
return;
|
|
@@ -33,23 +34,23 @@ function bindMemoryWarningListener(target) {
|
|
|
33
34
|
onMemoryWarning(listener);
|
|
34
35
|
}
|
|
35
36
|
function bindAppGlobalListener(target, options) {
|
|
36
|
-
var _ref
|
|
37
|
+
var _ref;
|
|
37
38
|
const { hookName, onApiName, offApiName, capabilityName, userHandler } = options;
|
|
38
39
|
const hooks = target[WEVU_HOOKS_KEY];
|
|
39
|
-
const hasHook = Boolean(hooks
|
|
40
|
-
const store = (_ref
|
|
40
|
+
const hasHook = Boolean(hooks?.[hookName]);
|
|
41
|
+
const store = (_ref = target)[APP_GLOBAL_LISTENER_STORE_KEY] ?? (_ref[APP_GLOBAL_LISTENER_STORE_KEY] = Object.create(null));
|
|
41
42
|
const existing = store[hookName];
|
|
42
43
|
if (!supportsCurrentMiniProgramRuntimeCapability(capabilityName)) {
|
|
43
44
|
delete store[hookName];
|
|
44
45
|
delete target[hookName];
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
const miniProgramGlobal =
|
|
48
|
-
const onApi = miniProgramGlobal
|
|
49
|
-
const offApi = miniProgramGlobal
|
|
48
|
+
const miniProgramGlobal = getCurrentMiniProgramGlobalObject();
|
|
49
|
+
const onApi = miniProgramGlobal?.[onApiName];
|
|
50
|
+
const offApi = miniProgramGlobal?.[offApiName];
|
|
50
51
|
if (typeof existing === "function" && typeof offApi === "function") try {
|
|
51
52
|
offApi(existing);
|
|
52
|
-
} catch
|
|
53
|
+
} catch {}
|
|
53
54
|
if (!hasHook && typeof userHandler !== "function") {
|
|
54
55
|
delete store[hookName];
|
|
55
56
|
return;
|
|
@@ -97,12 +98,11 @@ function bindAppGlobalListeners(target, handlers) {
|
|
|
97
98
|
* @internal
|
|
98
99
|
*/
|
|
99
100
|
function registerApp(runtimeApp, methods, watch, setup, mpOptions) {
|
|
100
|
-
var _appOptions$globalDat;
|
|
101
101
|
if (typeof App !== "function") throw new TypeError("createApp 需要全局 App 构造器可用");
|
|
102
|
-
const methodNames = Object.keys(methods
|
|
102
|
+
const methodNames = Object.keys(methods ?? {});
|
|
103
103
|
const appOptions = { ...mpOptions };
|
|
104
|
-
appOptions.globalData =
|
|
105
|
-
const methodRecord = methods
|
|
104
|
+
appOptions.globalData = appOptions.globalData ?? {};
|
|
105
|
+
const methodRecord = methods ?? {};
|
|
106
106
|
const inlineMap = methodRecord[WEVU_INLINE_MAP_KEY];
|
|
107
107
|
const requiresInlineEvents = Object.prototype.hasOwnProperty.call(methodRecord, WEVU_INLINE_MAP_KEY) && inlineMap && typeof inlineMap === "object" && Object.keys(inlineMap).length > 0;
|
|
108
108
|
if (!appOptions[WEVU_INLINE_HANDLER] && requiresInlineEvents) appOptions[WEVU_INLINE_HANDLER] = requireRuntimeCapability("inlineEvents", "registerApp(inline event metadata)").handler;
|
|
@@ -141,10 +141,9 @@ function registerApp(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
141
141
|
for (const methodName of methodNames) {
|
|
142
142
|
const userMethod = appOptions[methodName];
|
|
143
143
|
appOptions[methodName] = function runtimeMethod(...args) {
|
|
144
|
-
var _runtime$methods;
|
|
145
144
|
const runtime = this.__wevu;
|
|
146
145
|
let result;
|
|
147
|
-
const bound = runtime
|
|
146
|
+
const bound = runtime?.methods?.[methodName];
|
|
148
147
|
if (bound) result = bound.apply(runtime.proxy, args);
|
|
149
148
|
if (typeof userMethod === "function") return userMethod.apply(this, args);
|
|
150
149
|
return result;
|