wevu 7.2.2 → 7.4.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.
Files changed (383) hide show
  1. package/README.md +6 -0
  2. package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/defineProperty.mjs +1 -1
  3. package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPrimitive.mjs +1 -1
  4. package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPropertyKey.mjs +1 -1
  5. package/dist/dev/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/typeof.mjs +1 -1
  6. package/dist/dev/internal-runtime.d.mts +2 -1
  7. package/dist/dev/internal-runtime.mjs +3 -2
  8. package/dist/dev/package.mjs +1 -1
  9. package/dist/dev/reactivity/asyncDerivation.mjs +8 -10
  10. package/dist/dev/reactivity/asyncDerivation.mjs.map +1 -1
  11. package/dist/dev/reactivity/core.mjs +5 -8
  12. package/dist/dev/reactivity/core.mjs.map +1 -1
  13. package/dist/dev/reactivity/reactive/patch.mjs +3 -3
  14. package/dist/dev/reactivity/reactive/patch.mjs.map +1 -1
  15. package/dist/dev/reactivity/reactive/patchState.mjs +4 -8
  16. package/dist/dev/reactivity/reactive/patchState.mjs.map +1 -1
  17. package/dist/dev/reactivity/reactive/shared.mjs +1 -2
  18. package/dist/dev/reactivity/reactive/shared.mjs.map +1 -1
  19. package/dist/dev/reactivity/reactive.mjs +5 -10
  20. package/dist/dev/reactivity/reactive.mjs.map +1 -1
  21. package/dist/dev/reactivity/ref.mjs +2 -2
  22. package/dist/dev/reactivity/ref.mjs.map +1 -1
  23. package/dist/dev/reactivity/shallowRef.mjs +1 -1
  24. package/dist/dev/reactivity/shallowRef.mjs.map +1 -1
  25. package/dist/dev/reactivity/watch/helpers.mjs +1 -1
  26. package/dist/dev/reactivity/watch/helpers.mjs.map +1 -1
  27. package/dist/dev/reactivity/watch.mjs +6 -8
  28. package/dist/dev/reactivity/watch.mjs.map +1 -1
  29. package/dist/dev/router/createRouter.mjs +17 -24
  30. package/dist/dev/router/createRouter.mjs.map +1 -1
  31. package/dist/dev/router/initialNavigation.mjs +22 -17
  32. package/dist/dev/router/initialNavigation.mjs.map +1 -1
  33. package/dist/dev/router/instance.mjs +1 -2
  34. package/dist/dev/router/instance.mjs.map +1 -1
  35. package/dist/dev/router/navigationCore.mjs +2 -2
  36. package/dist/dev/router/navigationCore.mjs.map +1 -1
  37. package/dist/dev/router/navigationResult.mjs +7 -10
  38. package/dist/dev/router/navigationResult.mjs.map +1 -1
  39. package/dist/dev/router/navigationTarget.mjs +1 -3
  40. package/dist/dev/router/navigationTarget.mjs.map +1 -1
  41. package/dist/dev/router/resolve.mjs +3 -4
  42. package/dist/dev/router/resolve.mjs.map +1 -1
  43. package/dist/dev/router/routeRegistry.mjs +1 -1
  44. package/dist/dev/router/routeRegistry.mjs.map +1 -1
  45. package/dist/dev/router/routeSync.mjs +1 -1
  46. package/dist/dev/router/routeSync.mjs.map +1 -1
  47. package/dist/dev/router/scrollRestoration/adapters.d.mts +8 -0
  48. package/dist/dev/router/scrollRestoration/adapters.mjs +86 -0
  49. package/dist/dev/router/scrollRestoration/adapters.mjs.map +1 -0
  50. package/dist/dev/router/scrollRestoration/controller.d.mts +8 -0
  51. package/dist/dev/router/scrollRestoration/controller.mjs +148 -0
  52. package/dist/dev/router/scrollRestoration/controller.mjs.map +1 -0
  53. package/dist/dev/router/scrollRestoration/host.d.mts +3 -0
  54. package/dist/dev/router/scrollRestoration/host.mjs +76 -0
  55. package/dist/dev/router/scrollRestoration/host.mjs.map +1 -0
  56. package/dist/dev/router/scrollRestoration/index.d.mts +9 -0
  57. package/dist/dev/router/scrollRestoration/index.mjs +156 -0
  58. package/dist/dev/router/scrollRestoration/index.mjs.map +1 -0
  59. package/dist/dev/router/scrollRestoration/types.d.mts +61 -0
  60. package/dist/dev/router/useRoute.mjs +12 -19
  61. package/dist/dev/router/useRoute.mjs.map +1 -1
  62. package/dist/dev/router.d.mts +5 -1
  63. package/dist/dev/router.mjs +4 -1
  64. package/dist/dev/routerInternal/location.mjs +2 -3
  65. package/dist/dev/routerInternal/location.mjs.map +1 -1
  66. package/dist/dev/routerInternal/params.mjs +2 -3
  67. package/dist/dev/routerInternal/params.mjs.map +1 -1
  68. package/dist/dev/routerInternal/records.mjs +1 -1
  69. package/dist/dev/routerInternal/records.mjs.map +1 -1
  70. package/dist/dev/routerInternal/recordsWarnings.mjs +1 -2
  71. package/dist/dev/routerInternal/recordsWarnings.mjs.map +1 -1
  72. package/dist/dev/runtime/app/context.mjs +13 -26
  73. package/dist/dev/runtime/app/context.mjs.map +1 -1
  74. package/dist/dev/runtime/app/diagnostics.mjs +2 -4
  75. package/dist/dev/runtime/app/diagnostics.mjs.map +1 -1
  76. package/dist/dev/runtime/app/mount.mjs +27 -33
  77. package/dist/dev/runtime/app/mount.mjs.map +1 -1
  78. package/dist/dev/runtime/app/setData/commitTracker.mjs +5 -9
  79. package/dist/dev/runtime/app/setData/commitTracker.mjs.map +1 -1
  80. package/dist/dev/runtime/app/setData/patchScheduler.mjs +2 -4
  81. package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -1
  82. package/dist/dev/runtime/app/setData/payload.mjs +2 -3
  83. package/dist/dev/runtime/app/setData/payload.mjs.map +1 -1
  84. package/dist/dev/runtime/app/setData/scheduler.mjs +7 -9
  85. package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -1
  86. package/dist/dev/runtime/app/setData/snapshot.mjs +5 -6
  87. package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -1
  88. package/dist/dev/runtime/app/setDataOptions.mjs +26 -27
  89. package/dist/dev/runtime/app/setDataOptions.mjs.map +1 -1
  90. package/dist/dev/runtime/app.mjs +9 -9
  91. package/dist/dev/runtime/app.mjs.map +1 -1
  92. package/dist/dev/runtime/bindingManifest.mjs +6 -14
  93. package/dist/dev/runtime/bindingManifest.mjs.map +1 -1
  94. package/dist/dev/runtime/capabilities.d.mts +4 -1
  95. package/dist/dev/runtime/capabilities.mjs.map +1 -1
  96. package/dist/dev/runtime/css.mjs +4 -8
  97. package/dist/dev/runtime/css.mjs.map +1 -1
  98. package/dist/dev/runtime/defaults.mjs +4 -4
  99. package/dist/dev/runtime/defaults.mjs.map +1 -1
  100. package/dist/dev/runtime/define/initialComputed.mjs +5 -5
  101. package/dist/dev/runtime/define/initialComputed.mjs.map +1 -1
  102. package/dist/dev/runtime/define/options.mjs +10 -12
  103. package/dist/dev/runtime/define/options.mjs.map +1 -1
  104. package/dist/dev/runtime/define/props.mjs +4 -5
  105. package/dist/dev/runtime/define/props.mjs.map +1 -1
  106. package/dist/dev/runtime/define/scopedSlotOptions.mjs +43 -61
  107. package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -1
  108. package/dist/dev/runtime/define/setupResult.mjs +17 -28
  109. package/dist/dev/runtime/define/setupResult.mjs.map +1 -1
  110. package/dist/dev/runtime/define.mjs +9 -12
  111. package/dist/dev/runtime/define.mjs.map +1 -1
  112. package/dist/dev/runtime/diff.mjs +9 -11
  113. package/dist/dev/runtime/diff.mjs.map +1 -1
  114. package/dist/dev/runtime/disposables.mjs +2 -2
  115. package/dist/dev/runtime/disposables.mjs.map +1 -1
  116. package/dist/dev/runtime/elementIntersectionObserver.mjs +16 -24
  117. package/dist/dev/runtime/elementIntersectionObserver.mjs.map +1 -1
  118. package/dist/dev/runtime/features/inlineEvents.mjs +2 -3
  119. package/dist/dev/runtime/features/inlineEvents.mjs.map +1 -1
  120. package/dist/dev/runtime/features/jsxIslands.d.mts +7 -0
  121. package/dist/dev/runtime/features/jsxIslands.mjs +20 -0
  122. package/dist/dev/runtime/features/jsxIslands.mjs.map +1 -0
  123. package/dist/dev/runtime/features/layout.mjs +2 -3
  124. package/dist/dev/runtime/features/layout.mjs.map +1 -1
  125. package/dist/dev/runtime/features/publicLayout.mjs +2 -6
  126. package/dist/dev/runtime/features/publicLayout.mjs.map +1 -1
  127. package/dist/dev/runtime/features/scopedSlots.mjs +5 -9
  128. package/dist/dev/runtime/features/scopedSlots.mjs.map +1 -1
  129. package/dist/dev/runtime/features/templateRefs.mjs +1 -1
  130. package/dist/dev/runtime/features/templateRefs.mjs.map +1 -1
  131. package/dist/dev/runtime/hooks/base.mjs +20 -43
  132. package/dist/dev/runtime/hooks/base.mjs.map +1 -1
  133. package/dist/dev/runtime/hooks/pageScroll.mjs +41 -0
  134. package/dist/dev/runtime/hooks/pageScroll.mjs.map +1 -0
  135. package/dist/dev/runtime/hooks/register.mjs +2 -1
  136. package/dist/dev/runtime/hooks/register.mjs.map +1 -1
  137. package/dist/dev/runtime/inlineDataset.mjs +1 -2
  138. package/dist/dev/runtime/inlineDataset.mjs.map +1 -1
  139. package/dist/dev/runtime/intersectionObserver.mjs +6 -6
  140. package/dist/dev/runtime/intersectionObserver.mjs.map +1 -1
  141. package/dist/dev/runtime/jsxIsland.mjs +16 -33
  142. package/dist/dev/runtime/jsxIsland.mjs.map +1 -1
  143. package/dist/dev/runtime/layoutBridge.mjs +32 -62
  144. package/dist/dev/runtime/layoutBridge.mjs.map +1 -1
  145. package/dist/dev/runtime/nativeBridge.mjs +1 -1
  146. package/dist/dev/runtime/nativeBridge.mjs.map +1 -1
  147. package/dist/dev/runtime/navigationLifecycle.mjs +24 -0
  148. package/dist/dev/runtime/navigationLifecycle.mjs.map +1 -0
  149. package/dist/dev/runtime/pageEnvironment.mjs +15 -18
  150. package/dist/dev/runtime/pageEnvironment.mjs.map +1 -1
  151. package/dist/dev/runtime/pageLayout.mjs +7 -11
  152. package/dist/dev/runtime/pageLayout.mjs.map +1 -1
  153. package/dist/dev/runtime/pageScroll.mjs +2 -3
  154. package/dist/dev/runtime/pageScroll.mjs.map +1 -1
  155. package/dist/dev/runtime/platform/current.mjs +12 -0
  156. package/dist/dev/runtime/platform/current.mjs.map +1 -0
  157. package/dist/dev/runtime/platform/generic.mjs +36 -0
  158. package/dist/dev/runtime/platform/generic.mjs.map +1 -0
  159. package/dist/dev/runtime/platform/globals.mjs +29 -0
  160. package/dist/dev/runtime/platform/globals.mjs.map +1 -0
  161. package/dist/dev/runtime/platform.mjs +15 -60
  162. package/dist/dev/runtime/platform.mjs.map +1 -1
  163. package/dist/dev/runtime/provideContext.mjs +7 -9
  164. package/dist/dev/runtime/provideContext.mjs.map +1 -1
  165. package/dist/dev/runtime/publicRuntime.mjs +4 -0
  166. package/dist/dev/runtime/publicRuntime.mjs.map +1 -1
  167. package/dist/dev/runtime/pullDownRefresh.mjs +2 -4
  168. package/dist/dev/runtime/pullDownRefresh.mjs.map +1 -1
  169. package/dist/dev/runtime/register/app.mjs +18 -19
  170. package/dist/dev/runtime/register/app.mjs.map +1 -1
  171. package/dist/dev/runtime/register/component/alipay.mjs +9 -18
  172. package/dist/dev/runtime/register/component/alipay.mjs.map +1 -1
  173. package/dist/dev/runtime/register/component/alipayRegistration.mjs +60 -0
  174. package/dist/dev/runtime/register/component/alipayRegistration.mjs.map +1 -0
  175. package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +2 -5
  176. package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs.map +1 -1
  177. package/dist/dev/runtime/register/component/lifecycle/platform.mjs +13 -26
  178. package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -1
  179. package/dist/dev/runtime/register/component/lifecycle.mjs +7 -12
  180. package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -1
  181. package/dist/dev/runtime/register/component/methods.mjs +13 -18
  182. package/dist/dev/runtime/register/component/methods.mjs.map +1 -1
  183. package/dist/dev/runtime/register/component/options.mjs +3 -4
  184. package/dist/dev/runtime/register/component/options.mjs.map +1 -1
  185. package/dist/dev/runtime/register/component/props.mjs +25 -31
  186. package/dist/dev/runtime/register/component/props.mjs.map +1 -1
  187. package/dist/dev/runtime/register/component/registerDefinition.mjs +21 -40
  188. package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
  189. package/dist/dev/runtime/register/component/registerNativeDefinition.mjs +18 -60
  190. package/dist/dev/runtime/register/component/registerNativeDefinition.mjs.map +1 -1
  191. package/dist/dev/runtime/register/component.mjs +3 -5
  192. package/dist/dev/runtime/register/component.mjs.map +1 -1
  193. package/dist/dev/runtime/register/inline.mjs +8 -10
  194. package/dist/dev/runtime/register/inline.mjs.map +1 -1
  195. package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +7 -8
  196. package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs.map +1 -1
  197. package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +1 -1
  198. package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs.map +1 -1
  199. package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +25 -34
  200. package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -1
  201. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +13 -15
  202. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
  203. package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs +2 -2
  204. package/dist/dev/runtime/register/runtimeInstance/setupSnapshot.mjs.map +1 -1
  205. package/dist/dev/runtime/register/runtimeInstance/utils.mjs +9 -9
  206. package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -1
  207. package/dist/dev/runtime/register/runtimeInstance.mjs +74 -100
  208. package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -1
  209. package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +12 -15
  210. package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -1
  211. package/dist/dev/runtime/register/setup.mjs +2 -3
  212. package/dist/dev/runtime/register/setup.mjs.map +1 -1
  213. package/dist/dev/runtime/register/snapshot.mjs +1 -4
  214. package/dist/dev/runtime/register/snapshot.mjs.map +1 -1
  215. package/dist/dev/runtime/register/watch.mjs +3 -5
  216. package/dist/dev/runtime/register/watch.mjs.map +1 -1
  217. package/dist/dev/runtime/scopedSlots.mjs +14 -21
  218. package/dist/dev/runtime/scopedSlots.mjs.map +1 -1
  219. package/dist/dev/runtime/selectorQuery.mjs +5 -9
  220. package/dist/dev/runtime/selectorQuery.mjs.map +1 -1
  221. package/dist/dev/runtime/template.mjs +1 -1
  222. package/dist/dev/runtime/template.mjs.map +1 -1
  223. package/dist/dev/runtime/templateRefs/helpers.mjs +14 -24
  224. package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -1
  225. package/dist/dev/runtime/templateRefs.mjs +8 -15
  226. package/dist/dev/runtime/templateRefs.mjs.map +1 -1
  227. package/dist/dev/runtime/uniAppHost.mjs +6 -14
  228. package/dist/dev/runtime/uniAppHost.mjs.map +1 -1
  229. package/dist/dev/runtime/updatePerformance.mjs +1 -1
  230. package/dist/dev/runtime/updatePerformance.mjs.map +1 -1
  231. package/dist/dev/runtime/use.mjs +1 -1
  232. package/dist/dev/runtime/use.mjs.map +1 -1
  233. package/dist/dev/runtime/vueCompat/context.mjs +3 -5
  234. package/dist/dev/runtime/vueCompat/context.mjs.map +1 -1
  235. package/dist/dev/runtime/vueCompat/model.mjs +9 -13
  236. package/dist/dev/runtime/vueCompat/model.mjs.map +1 -1
  237. package/dist/dev/runtime/vueCompat/router.mjs +4 -4
  238. package/dist/dev/runtime/vueCompat/router.mjs.map +1 -1
  239. package/dist/dev/runtime/vueCompat/templateRef.mjs +1 -1
  240. package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -1
  241. package/dist/dev/scheduler.mjs +3 -4
  242. package/dist/dev/scheduler.mjs.map +1 -1
  243. package/dist/dev/store/base.mjs +1 -2
  244. package/dist/dev/store/base.mjs.map +1 -1
  245. package/dist/dev/store/define/create.mjs +11 -22
  246. package/dist/dev/store/define/create.mjs.map +1 -1
  247. package/dist/dev/store/define.mjs +1 -1
  248. package/dist/dev/store/define.mjs.map +1 -1
  249. package/dist/dev/store/view.mjs +1 -1
  250. package/dist/dev/store/view.mjs.map +1 -1
  251. package/dist/internal-runtime.d.mts +2 -1
  252. package/dist/internal-runtime.mjs +1 -1
  253. package/dist/package.mjs +1 -1
  254. package/dist/reactivity/asyncDerivation.mjs +1 -1
  255. package/dist/reactivity/core.mjs +1 -1
  256. package/dist/reactivity/reactive/patch.mjs +1 -1
  257. package/dist/reactivity/reactive/patchState.mjs +1 -1
  258. package/dist/reactivity/reactive/shared.mjs +1 -1
  259. package/dist/reactivity/reactive.mjs +1 -1
  260. package/dist/reactivity/ref.mjs +1 -1
  261. package/dist/reactivity/shallowRef.mjs +1 -1
  262. package/dist/reactivity/watch/helpers.mjs +1 -1
  263. package/dist/reactivity/watch.mjs +1 -1
  264. package/dist/router/createRouter.mjs +1 -1
  265. package/dist/router/initialNavigation.mjs +1 -1
  266. package/dist/router/instance.mjs +1 -1
  267. package/dist/router/navigationCore.mjs +1 -1
  268. package/dist/router/navigationResult.mjs +1 -1
  269. package/dist/router/navigationTarget.mjs +1 -1
  270. package/dist/router/resolve.mjs +1 -1
  271. package/dist/router/routeRegistry.mjs +1 -1
  272. package/dist/router/routeSync.mjs +1 -1
  273. package/dist/router/scrollRestoration/adapters.d.mts +7 -0
  274. package/dist/router/scrollRestoration/adapters.mjs +1 -0
  275. package/dist/router/scrollRestoration/controller.d.mts +7 -0
  276. package/dist/router/scrollRestoration/controller.mjs +1 -0
  277. package/dist/router/scrollRestoration/host.d.mts +3 -0
  278. package/dist/router/scrollRestoration/host.mjs +1 -0
  279. package/dist/router/scrollRestoration/index.d.mts +8 -0
  280. package/dist/router/scrollRestoration/index.mjs +1 -0
  281. package/dist/router/scrollRestoration/types.d.mts +60 -0
  282. package/dist/router/useRoute.mjs +1 -1
  283. package/dist/router.d.mts +5 -1
  284. package/dist/router.mjs +1 -1
  285. package/dist/routerInternal/location.mjs +1 -1
  286. package/dist/routerInternal/params.mjs +1 -1
  287. package/dist/routerInternal/records.mjs +1 -1
  288. package/dist/routerInternal/recordsWarnings.mjs +1 -1
  289. package/dist/runtime/app/context.mjs +1 -1
  290. package/dist/runtime/app/diagnostics.mjs +1 -1
  291. package/dist/runtime/app/mount.mjs +1 -1
  292. package/dist/runtime/app/setData/commitTracker.mjs +1 -1
  293. package/dist/runtime/app/setData/patchScheduler.mjs +1 -1
  294. package/dist/runtime/app/setData/payload.mjs +1 -1
  295. package/dist/runtime/app/setData/scheduler.mjs +1 -1
  296. package/dist/runtime/app/setData/snapshot.mjs +1 -1
  297. package/dist/runtime/app/setDataOptions.mjs +1 -1
  298. package/dist/runtime/app.mjs +1 -1
  299. package/dist/runtime/bindingManifest.mjs +1 -1
  300. package/dist/runtime/capabilities.d.mts +4 -1
  301. package/dist/runtime/css.mjs +1 -1
  302. package/dist/runtime/defaults.mjs +1 -1
  303. package/dist/runtime/define/initialComputed.mjs +1 -1
  304. package/dist/runtime/define/options.mjs +1 -1
  305. package/dist/runtime/define/props.mjs +1 -1
  306. package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
  307. package/dist/runtime/define/setupResult.mjs +1 -1
  308. package/dist/runtime/define.mjs +1 -1
  309. package/dist/runtime/diff.mjs +1 -1
  310. package/dist/runtime/disposables.mjs +1 -1
  311. package/dist/runtime/elementIntersectionObserver.mjs +1 -1
  312. package/dist/runtime/features/inlineEvents.mjs +1 -1
  313. package/dist/runtime/features/jsxIslands.d.mts +6 -0
  314. package/dist/runtime/features/jsxIslands.mjs +1 -0
  315. package/dist/runtime/features/layout.mjs +1 -1
  316. package/dist/runtime/features/publicLayout.mjs +1 -1
  317. package/dist/runtime/features/scopedSlots.mjs +1 -1
  318. package/dist/runtime/features/templateRefs.mjs +1 -1
  319. package/dist/runtime/hooks/base.mjs +1 -1
  320. package/dist/runtime/hooks/pageScroll.mjs +1 -0
  321. package/dist/runtime/hooks/register.mjs +1 -1
  322. package/dist/runtime/inlineDataset.mjs +1 -1
  323. package/dist/runtime/intersectionObserver.mjs +1 -1
  324. package/dist/runtime/jsxIsland.mjs +1 -1
  325. package/dist/runtime/layoutBridge.mjs +1 -1
  326. package/dist/runtime/nativeBridge.mjs +1 -1
  327. package/dist/runtime/navigationLifecycle.mjs +1 -0
  328. package/dist/runtime/pageEnvironment.mjs +1 -1
  329. package/dist/runtime/pageLayout.mjs +1 -1
  330. package/dist/runtime/pageScroll.mjs +1 -1
  331. package/dist/runtime/platform/current.mjs +1 -0
  332. package/dist/runtime/platform/generic.mjs +1 -0
  333. package/dist/runtime/platform/globals.mjs +1 -0
  334. package/dist/runtime/platform.mjs +1 -1
  335. package/dist/runtime/provideContext.mjs +1 -1
  336. package/dist/runtime/publicRuntime.mjs +1 -1
  337. package/dist/runtime/pullDownRefresh.mjs +1 -1
  338. package/dist/runtime/register/app.mjs +1 -1
  339. package/dist/runtime/register/component/alipay.mjs +1 -1
  340. package/dist/runtime/register/component/alipayRegistration.mjs +1 -0
  341. package/dist/runtime/register/component/lifecycle/optionalHooks.mjs +1 -1
  342. package/dist/runtime/register/component/lifecycle/platform.mjs +1 -1
  343. package/dist/runtime/register/component/lifecycle.mjs +1 -1
  344. package/dist/runtime/register/component/methods.mjs +1 -1
  345. package/dist/runtime/register/component/options.mjs +1 -1
  346. package/dist/runtime/register/component/props.mjs +1 -1
  347. package/dist/runtime/register/component/registerDefinition.mjs +1 -1
  348. package/dist/runtime/register/component/registerNativeDefinition.mjs +1 -1
  349. package/dist/runtime/register/component.mjs +1 -1
  350. package/dist/runtime/register/inline.mjs +1 -1
  351. package/dist/runtime/register/runtimeInstance/methodBridge.mjs +1 -1
  352. package/dist/runtime/register/runtimeInstance/provideContext.mjs +1 -1
  353. package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -1
  354. package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
  355. package/dist/runtime/register/runtimeInstance/setupSnapshot.mjs +1 -1
  356. package/dist/runtime/register/runtimeInstance/utils.mjs +1 -1
  357. package/dist/runtime/register/runtimeInstance.mjs +1 -1
  358. package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -1
  359. package/dist/runtime/register/setup.mjs +1 -1
  360. package/dist/runtime/register/snapshot.mjs +1 -1
  361. package/dist/runtime/register/watch.mjs +1 -1
  362. package/dist/runtime/scopedSlots.mjs +1 -1
  363. package/dist/runtime/selectorQuery.mjs +1 -1
  364. package/dist/runtime/template.mjs +1 -1
  365. package/dist/runtime/templateRefs/helpers.mjs +1 -1
  366. package/dist/runtime/templateRefs.mjs +1 -1
  367. package/dist/runtime/uniAppHost.mjs +1 -1
  368. package/dist/runtime/updatePerformance.mjs +1 -1
  369. package/dist/runtime/use.mjs +1 -1
  370. package/dist/runtime/vueCompat/context.mjs +1 -1
  371. package/dist/runtime/vueCompat/model.mjs +1 -1
  372. package/dist/runtime/vueCompat/router.mjs +1 -1
  373. package/dist/runtime/vueCompat/templateRef.mjs +1 -1
  374. package/dist/scheduler.mjs +1 -1
  375. package/dist/store/base.mjs +1 -1
  376. package/dist/store/define/create.mjs +1 -1
  377. package/dist/store/define.mjs +1 -1
  378. package/dist/store/view.mjs +1 -1
  379. package/package.json +7 -7
  380. /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/defineProperty.mjs +0 -0
  381. /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPrimitive.mjs +0 -0
  382. /package/dist/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPropertyKey.mjs +0 -0
  383. /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":"pageLayout.mjs","names":[],"sources":["../../../src/runtime/pageLayout.ts"],"sourcesContent":["import {\n WEVU_PAGE_LAYOUT_NAME_KEY,\n WEVU_PAGE_LAYOUT_NONE,\n WEVU_PAGE_LAYOUT_PROPS_KEY,\n WEVU_PAGE_LAYOUT_SETTER_KEY,\n} from '@weapp-core/constants'\nimport { reactive, readonly } from '../reactivity'\nimport { getCurrentInstance, getCurrentSetupContext } from './hooks'\nimport { getCurrentMiniProgramPages } from './platform'\nimport { getCurrentPageInstance } from './register/component/lifecycle/platform'\n\ntype PageLayoutProps = object\n\ntype PageLayoutSetter = (layout: string | false, props?: PageLayoutProps) => void\n\nexport interface WevuPageLayoutMap {}\n\ntype ResolveTypedPageLayoutName = keyof WevuPageLayoutMap extends never\n ? string\n : Extract<keyof WevuPageLayoutMap, string>\n\ntype ResolveTypedPageLayoutProps<Name extends string> = Name extends keyof WevuPageLayoutMap\n ? WevuPageLayoutMap[Name]\n : PageLayoutProps\n\ntype PageLayoutNamedState = {\n [Name in ResolveTypedPageLayoutName]: {\n name: Name\n props: ResolveTypedPageLayoutProps<Name>\n }\n}[ResolveTypedPageLayoutName]\n\nexport type PageLayoutState\n = | PageLayoutNamedState\n | {\n name: false\n props: Record<string, any>\n }\n | {\n name: undefined\n props: Record<string, any>\n }\n\ninterface MutablePageLayoutState {\n name: string | false | undefined\n props: Record<string, any>\n}\n\nfunction resolveCurrentPageInstance() {\n const runtimeCurrentPage = getCurrentPageInstance()\n if (runtimeCurrentPage) {\n return runtimeCurrentPage\n }\n const pages = getCurrentMiniProgramPages()\n return pages[pages.length - 1]\n}\n\nfunction normalizeRuntimePageLayoutName(layout: string | undefined) {\n return layout === WEVU_PAGE_LAYOUT_NONE ? false : layout\n}\n\n/**\n * 获取当前页面 layout 状态。\n */\nexport function usePageLayout(): Readonly<PageLayoutState> {\n if (!getCurrentSetupContext()) {\n throw new Error('usePageLayout() 必须在 setup() 的同步阶段调用')\n }\n\n const currentInstance = getCurrentInstance() as Record<string, any> | undefined\n const runtimeState = currentInstance?.__wevu?.state as Record<string, any> | undefined\n const pageLayoutState = reactive<MutablePageLayoutState>({\n name: normalizeRuntimePageLayoutName(runtimeState?.[WEVU_PAGE_LAYOUT_NAME_KEY]) as string | false | undefined,\n props: { ...(runtimeState?.[WEVU_PAGE_LAYOUT_PROPS_KEY] ?? {}) },\n })\n\n if (currentInstance) {\n currentInstance.__wevuPageLayoutState = pageLayoutState\n }\n\n return readonly(pageLayoutState) as Readonly<PageLayoutState>\n}\n\nexport function syncRuntimePageLayoutState(target: Record<string, any>, layout: string | false, props: PageLayoutProps) {\n const state = target.__wevuPageLayoutState as MutablePageLayoutState | undefined\n if (!state) {\n return\n }\n state.name = layout\n state.props = { ...props }\n}\n\nexport function syncRuntimePageLayoutStateFromRuntime(target: Record<string, any>) {\n const state = target.__wevuPageLayoutState as MutablePageLayoutState | undefined\n const runtimeState = target.__wevu?.state as Record<string, any> | undefined\n if (!state || !runtimeState) {\n return\n }\n state.name = normalizeRuntimePageLayoutName(runtimeState[WEVU_PAGE_LAYOUT_NAME_KEY]) as string | false | undefined\n state.props = { ...(runtimeState[WEVU_PAGE_LAYOUT_PROPS_KEY] ?? {}) }\n}\n\nexport function setPageLayout(layout: false): void\nexport function setPageLayout<Name extends ResolveTypedPageLayoutName>(layout: Name, props?: ResolveTypedPageLayoutProps<Name>): void\n\n/**\n * 显式切换当前页面使用的 layout。\n */\nexport function setPageLayout(layout: string | false, props?: PageLayoutProps): void {\n const currentInstance = getCurrentInstance() as Record<string, any> | undefined\n const directSetter = currentInstance?.[WEVU_PAGE_LAYOUT_SETTER_KEY] as PageLayoutSetter | undefined\n if (typeof directSetter === 'function') {\n directSetter(layout, props)\n return\n }\n\n const currentPage = resolveCurrentPageInstance()\n const pageSetter = currentPage?.[WEVU_PAGE_LAYOUT_SETTER_KEY] as PageLayoutSetter | undefined\n if (typeof pageSetter === 'function') {\n pageSetter(layout, props)\n return\n }\n\n throw new Error('setPageLayout() 未找到当前页面实例。请在页面 setup()、事件回调或当前页面上下文中调用。')\n}\n\nexport function resolveRuntimePageLayoutName(layout: string | false) {\n return layout === false ? WEVU_PAGE_LAYOUT_NONE : layout\n}\n"],"mappings":";;;;;;;;AAgDA,SAAS,6BAA6B;CACpC,MAAM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,SAAgB,6BAA6B,QAAwB;CACnE,OAAO,WAAW,QAAQ,wBAAwB;AACpD"}
1
+ {"version":3,"file":"pageLayout.mjs","names":[],"sources":["../../../src/runtime/pageLayout.ts"],"sourcesContent":["import {\n WEVU_PAGE_LAYOUT_NAME_KEY,\n WEVU_PAGE_LAYOUT_NONE,\n WEVU_PAGE_LAYOUT_PROPS_KEY,\n WEVU_PAGE_LAYOUT_SETTER_KEY,\n} from '@weapp-core/constants'\nimport { reactive, readonly } from '../reactivity'\nimport { getCurrentInstance, getCurrentSetupContext } from './hooks'\nimport { getCurrentMiniProgramPages } from './platform'\nimport { getCurrentPageInstance } from './register/component/lifecycle/platform'\n\ntype PageLayoutProps = object\n\ntype PageLayoutSetter = (layout: string | false, props?: PageLayoutProps) => void\n\nexport interface WevuPageLayoutMap {}\n\ntype ResolveTypedPageLayoutName = keyof WevuPageLayoutMap extends never\n ? string\n : Extract<keyof WevuPageLayoutMap, string>\n\ntype ResolveTypedPageLayoutProps<Name extends string> = Name extends keyof WevuPageLayoutMap\n ? WevuPageLayoutMap[Name]\n : PageLayoutProps\n\ntype PageLayoutNamedState = {\n [Name in ResolveTypedPageLayoutName]: {\n name: Name\n props: ResolveTypedPageLayoutProps<Name>\n }\n}[ResolveTypedPageLayoutName]\n\nexport type PageLayoutState\n = | PageLayoutNamedState\n | {\n name: false\n props: Record<string, any>\n }\n | {\n name: undefined\n props: Record<string, any>\n }\n\ninterface MutablePageLayoutState {\n name: string | false | undefined\n props: Record<string, any>\n}\n\nfunction resolveCurrentPageInstance() {\n const runtimeCurrentPage = getCurrentPageInstance()\n if (runtimeCurrentPage) {\n return runtimeCurrentPage\n }\n const pages = getCurrentMiniProgramPages()\n return pages[pages.length - 1]\n}\n\nfunction normalizeRuntimePageLayoutName(layout: string | undefined) {\n return layout === WEVU_PAGE_LAYOUT_NONE ? false : layout\n}\n\n/**\n * 获取当前页面 layout 状态。\n */\nexport function usePageLayout(): Readonly<PageLayoutState> {\n if (!getCurrentSetupContext()) {\n throw new Error('usePageLayout() 必须在 setup() 的同步阶段调用')\n }\n\n const currentInstance = getCurrentInstance() as Record<string, any> | undefined\n const runtimeState = currentInstance?.__wevu?.state as Record<string, any> | undefined\n const pageLayoutState = reactive<MutablePageLayoutState>({\n name: normalizeRuntimePageLayoutName(runtimeState?.[WEVU_PAGE_LAYOUT_NAME_KEY]) as string | false | undefined,\n props: { ...(runtimeState?.[WEVU_PAGE_LAYOUT_PROPS_KEY] ?? {}) },\n })\n\n if (currentInstance) {\n currentInstance.__wevuPageLayoutState = pageLayoutState\n }\n\n return readonly(pageLayoutState) as Readonly<PageLayoutState>\n}\n\nexport function syncRuntimePageLayoutState(target: Record<string, any>, layout: string | false, props: PageLayoutProps) {\n const state = target.__wevuPageLayoutState as MutablePageLayoutState | undefined\n if (!state) {\n return\n }\n state.name = layout\n state.props = { ...props }\n}\n\nexport function syncRuntimePageLayoutStateFromRuntime(target: Record<string, any>) {\n const state = target.__wevuPageLayoutState as MutablePageLayoutState | undefined\n const runtimeState = target.__wevu?.state as Record<string, any> | undefined\n if (!state || !runtimeState) {\n return\n }\n state.name = normalizeRuntimePageLayoutName(runtimeState[WEVU_PAGE_LAYOUT_NAME_KEY]) as string | false | undefined\n state.props = { ...(runtimeState[WEVU_PAGE_LAYOUT_PROPS_KEY] ?? {}) }\n}\n\nexport function setPageLayout(layout: false): void\nexport function setPageLayout<Name extends ResolveTypedPageLayoutName>(layout: Name, props?: ResolveTypedPageLayoutProps<Name>): void\n\n/**\n * 显式切换当前页面使用的 layout。\n */\nexport function setPageLayout(layout: string | false, props?: PageLayoutProps): void {\n const currentInstance = getCurrentInstance() as Record<string, any> | undefined\n const directSetter = currentInstance?.[WEVU_PAGE_LAYOUT_SETTER_KEY] as PageLayoutSetter | undefined\n if (typeof directSetter === 'function') {\n directSetter(layout, props)\n return\n }\n\n const currentPage = resolveCurrentPageInstance()\n const pageSetter = currentPage?.[WEVU_PAGE_LAYOUT_SETTER_KEY] as PageLayoutSetter | undefined\n if (typeof pageSetter === 'function') {\n pageSetter(layout, props)\n return\n }\n\n throw new Error('setPageLayout() 未找到当前页面实例。请在页面 setup()、事件回调或当前页面上下文中调用。')\n}\n\nexport function resolveRuntimePageLayoutName(layout: string | false) {\n return layout === false ? WEVU_PAGE_LAYOUT_NONE : layout\n}\n"],"mappings":";;;;;;;;AAgDA,SAAS,6BAA6B;CACpC,MAAM,qBAAqB,uBAAuB;CAClD,IAAI,oBACF,OAAO;CAET,MAAM,QAAQ,2BAA2B;CACzC,OAAO,MAAM,MAAM,SAAS;AAC9B;AAEA,SAAS,+BAA+B,QAA4B;CAClE,OAAO,WAAW,wBAAwB,QAAQ;AACpD;;;;AAKA,SAAgB,gBAA2C;CACzD,IAAI,CAAC,uBAAuB,GAC1B,MAAM,IAAI,MAAM,qCAAqC;CAGvD,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,eAAe,iBAAiB,QAAQ;CAC9C,MAAM,kBAAkB,SAAiC;EACvD,MAAM,+BAA+B,eAAe,0BAA0B;EAC9E,OAAO,EAAE,GAAI,eAAe,+BAA+B,CAAC,EAAG;CACjE,CAAC;CAED,IAAI,iBACF,gBAAgB,wBAAwB;CAG1C,OAAO,SAAS,eAAe;AACjC;AAEA,SAAgB,2BAA2B,QAA6B,QAAwB,OAAwB;CACtH,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,OACH;CAEF,MAAM,OAAO;CACb,MAAM,QAAQ,EAAE,GAAG,MAAM;AAC3B;AAEA,SAAgB,sCAAsC,QAA6B;CACjF,MAAM,QAAQ,OAAO;CACrB,MAAM,eAAe,OAAO,QAAQ;CACpC,IAAI,CAAC,SAAS,CAAC,cACb;CAEF,MAAM,OAAO,+BAA+B,aAAa,0BAA0B;CACnF,MAAM,QAAQ,EAAE,GAAI,aAAa,+BAA+B,CAAC,EAAG;AACtE;;;;AAQA,SAAgB,cAAc,QAAwB,OAA+B;CAEnF,MAAM,eADkB,mBACW,CAAC,GAAG;CACvC,IAAI,OAAO,iBAAiB,YAAY;EACtC,aAAa,QAAQ,KAAK;EAC1B;CACF;CAGA,MAAM,aADc,2BACS,CAAC,GAAG;CACjC,IAAI,OAAO,eAAe,YAAY;EACpC,WAAW,QAAQ,KAAK;EACxB;CACF;CAEA,MAAM,IAAI,MAAM,yDAAyD;AAC3E;AAEA,SAAgB,6BAA6B,QAAwB;CACnE,OAAO,WAAW,QAAQ,wBAAwB;AACpD"}
@@ -14,12 +14,11 @@ function resolveMaxWait(maxWait) {
14
14
  * 在 setup 中注册节流后的 onPageScroll 监听,并在卸载时自动清理。
15
15
  */
16
16
  function usePageScrollThrottle(handler, options = {}) {
17
- var _options$leading, _options$trailing;
18
17
  if (!getCurrentInstance()) throw new Error("usePageScrollThrottle() 必须在 setup() 的同步阶段调用");
19
18
  if (typeof handler !== "function") throw new TypeError("usePageScrollThrottle() 需要传入回调函数");
20
19
  const interval = resolvePositiveInterval(options.interval);
21
- const leading = (_options$leading = options.leading) !== null && _options$leading !== void 0 ? _options$leading : true;
22
- const trailing = (_options$trailing = options.trailing) !== null && _options$trailing !== void 0 ? _options$trailing : true;
20
+ const leading = options.leading ?? true;
21
+ const trailing = options.trailing ?? true;
23
22
  const maxWait = resolveMaxWait(options.maxWait);
24
23
  let trailingTimer;
25
24
  let maxWaitTimer;
@@ -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;;CACjC,IAAI,CAAC,mBAAmB,GACtB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,IAAI,OAAO,YAAY,YACrB,MAA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M,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"}
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,0BAA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B,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 { getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeHostConfigKey, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "@weapp-core/shared/platforms";
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 supportsMiniProgramRuntimeCapability(resolveCurrentMiniProgramPlatform(), capabilityName);
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 = getMiniProgramGlobalObject();
60
- const getCurrentPagesFn = (_ref = (_miniProgramGlobal$ge = miniProgramGlobal === null || miniProgramGlobal === void 0 ? void 0 : miniProgramGlobal.getCurrentPages) !== null && _miniProgramGlobal$ge !== void 0 ? _miniProgramGlobal$ge : globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.getCurrentPages) !== null && _ref !== void 0 ? _ref : typeof getCurrentPages !== "undefined" ? getCurrentPages : void 0;
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 (_unused) {
26
+ } catch {
66
27
  return [];
67
28
  }
68
29
  }
69
30
  function getCurrentMiniProgramHostConfig() {
70
- const globalRuntime = getGlobalRuntime();
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
- var _getMiniProgramGlobal;
77
- return (_getMiniProgramGlobal = getMiniProgramGlobalObject()) !== null && _getMiniProgramGlobal !== void 0 ? _getMiniProgramGlobal : getGlobalRuntime();
35
+ return getCurrentMiniProgramGlobalObject() ?? getGlobalRuntime();
78
36
  }
79
37
  function getMiniProgramRuntimeConsoleWarn() {
80
- var _getMiniProgramRuntim;
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 = getMiniProgramGlobalObject();
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 hostConfig = getCurrentMiniProgramHostConfig();
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
- var _getMiniProgramGlobal2;
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, getMiniProgramGlobalObject, getMiniProgramRuntimeConsoleWarn, getMiniProgramRuntimeGlobalObject, getScopedSlotHostGlobalObject, resolveCurrentMiniProgramPlatform, supportsCurrentMiniProgramRuntimeCapability };
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 { MiniProgramRuntimeCapabilities, MiniProgramRuntimeCapabilityName } from '@weapp-core/shared/platforms'\nimport {\n getMiniProgramPlatformByRuntimeGlobalKey,\n getMiniProgramRuntimeCapabilities,\n getMiniProgramRuntimeGlobalKey,\n getMiniProgramRuntimeGlobalKeys,\n getMiniProgramRuntimeHostConfigKey,\n resolveMiniProgramPlatform,\n supportsMiniProgramRuntimeCapability,\n} from '@weapp-core/shared/platforms'\n\ntype MiniProgramGlobal = Record<string, any>\ndeclare const tt: MiniProgramGlobal | undefined\ndeclare const swan: MiniProgramGlobal | undefined\ndeclare const jd: MiniProgramGlobal | undefined\ndeclare const xhs: MiniProgramGlobal | undefined\ntype MiniProgramHostConfig = Record<string, any>\ntype MiniProgramGlobalRouterMethodName = 'switchTab' | 'reLaunch' | 'redirectTo' | 'navigateTo' | 'navigateBack'\ntype MiniProgramGlobalRouter = Record<MiniProgramGlobalRouterMethodName, (...args: any[]) => any>\ntype ImportMetaWithEnv = ImportMeta & {\n env?: {\n PLATFORM?: string\n }\n}\nconst MINI_PROGRAM_GLOBAL_ROUTER_METHODS: readonly MiniProgramGlobalRouterMethodName[] = [\n 'switchTab',\n 'reLaunch',\n 'redirectTo',\n 'navigateTo',\n 'navigateBack',\n]\n\nfunction getGlobalRuntime() {\n if (typeof globalThis === 'undefined') {\n return undefined\n }\n return globalThis as MiniProgramGlobal\n}\n\nfunction getStaticMiniProgramGlobalObject(globalKey: string): MiniProgramGlobal | undefined {\n switch (globalKey) {\n case 'wx':\n return typeof wx !== 'undefined' ? wx as MiniProgramGlobal : undefined\n case 'my':\n return typeof my !== 'undefined' ? my as MiniProgramGlobal : undefined\n case 'tt':\n return typeof tt !== 'undefined' ? tt : undefined\n case 'swan':\n return typeof swan !== 'undefined' ? swan : undefined\n case 'jd':\n return typeof jd !== 'undefined' ? jd : undefined\n case 'xhs':\n return typeof xhs !== 'undefined' ? xhs : undefined\n }\n return undefined\n}\n\nfunction resolveRuntimeGlobalObject(globalKey: string): MiniProgramGlobal | undefined {\n return getGlobalRuntime()?.[globalKey] ?? getStaticMiniProgramGlobalObject(globalKey)\n}\n\nexport function resolveCurrentMiniProgramPlatform() {\n const compiledPlatform = (import.meta as ImportMetaWithEnv).env?.PLATFORM\n\n // 优先命中编译期平台分支,便于构建阶段做 dead-code elimination。\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 getCurrentMiniProgramRuntimeCapabilities(): MiniProgramRuntimeCapabilities {\n return getMiniProgramRuntimeCapabilities(resolveCurrentMiniProgramPlatform())\n}\n\nexport function supportsCurrentMiniProgramRuntimeCapability(capabilityName: MiniProgramRuntimeCapabilityName): boolean {\n return supportsMiniProgramRuntimeCapability(resolveCurrentMiniProgramPlatform(), capabilityName)\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\nexport function getCurrentMiniProgramPages(): Array<Record<string, any>> {\n if (!supportsCurrentMiniProgramRuntimeCapability('globalPageStack')) {\n return []\n }\n const globalRuntime = getGlobalRuntime()\n const miniProgramGlobal = getMiniProgramGlobalObject()\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 = getMiniProgramRuntimeHostConfigKey(resolveCurrentMiniProgramPlatform())\n const hostConfig = globalRuntime?.[hostConfigKey]\n return hostConfig && typeof hostConfig === 'object' ? hostConfig as MiniProgramHostConfig : undefined\n}\n\nexport function getMiniProgramRuntimeGlobalObject(): MiniProgramGlobal | undefined {\n return getMiniProgramGlobalObject() ?? 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 = getMiniProgramGlobalObject()\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 getMiniProgramGlobalObject() ?? getGlobalRuntime()\n}\n"],"mappings":";;;AAwBA,MAAM,qCAAmF;CACvF;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,mBAAmB;CAC1B,IAAI,OAAO,eAAe,aACxB;CAEF,OAAO;AACT;AAEA,SAAS,iCAAiC,WAAkD;CAC1F,QAAQ,WAAR;EACE,KAAK,MACH,OAAO,OAAO,OAAO,cAAc,KAA0B;EAC/D,KAAK,MACH,OAAO,OAAO,OAAO,cAAc,KAA0B;EAC/D,KAAK,MACH,OAAO,OAAO,OAAO,cAAc,KAAK;EAC1C,KAAK,QACH,OAAO,OAAO,SAAS,cAAc,OAAO;EAC9C,KAAK,MACH,OAAO,OAAO,OAAO,cAAc,KAAK;EAC1C,KAAK,OACH,OAAO,OAAO,QAAQ,cAAc,MAAM;CAC9C;AAEF;AAEA,SAAS,2BAA2B,WAAkD;;CACpF,qDAAO,iBAAiB,yEAAI,mFAAc,iCAAiC,SAAS;AACtF;AAEA,SAAgB,oCAAoC;;CAClD,MAAM,2BAAoB,YAAkC,iDAAK;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,2CAA2E;CACzF,OAAO,kCAAkC,kCAAkC,CAAC;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H;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;CAC/D,MAAM,aAAa,gCAAgC;CACnD,MAAM,iEAAS,WAAY;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,iCAAO,2BAA2B,4EAAK,iBAAiB;AAC1D"}
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,oB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C;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 !== null && parent !== void 0 ? parent : null);
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 (_unused) {
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 (_unused2) {
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 = (_instance$WEVU_PARENT = (_instance$WEVU_PARENT2 = instance[WEVU_PARENT_INSTANCE_KEY]) === null || _instance$WEVU_PARENT2 === void 0 ? void 0 : _instance$WEVU_PARENT2[WEVU_PROVIDES_KEY]) !== null && _instance$WEVU_PARENT !== void 0 ? _instance$WEVU_PARENT : getRuntimeAppProvides(runtimeApp);
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 = (_parentInstance$WEVU_ = parentInstance === null || parentInstance === void 0 ? void 0 : parentInstance[WEVU_PROVIDES_KEY]) !== null && _parentInstance$WEVU_ !== void 0 ? _parentInstance$WEVU_ : appProvides;
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 (_unused3) {
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 (_unused4) {
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,SA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,MAAM,0GAAiB,eAAiB,2FAAsB;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,mBACM;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,mBACM;EACH,AAAC,aAAqB,4BAA4B;CACrD;AACF"}
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;AA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;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":";;;;;;;;;;;;;;;AA2BA,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,MAA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,qBAAqB;CACrB,mCAAmC;CACnC,OAAOC,kBAAoB,QAAQ;AACrC;;;;AAKA,SAAgB,8BACd,WACM;CACN,oBAAoB;CACpB,oBAAoB;CACpB,mBAAmB;CACnB,cAAc;CACd,gCAAkC,SAAS;AAC7C"}
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,QA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,SAAS;AAC7C"}
@@ -10,11 +10,9 @@ function useAsyncPullDownRefresh(refresh, options = {}) {
10
10
  try {
11
11
  await refresh();
12
12
  } catch (error) {
13
- var _options$onError;
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
- var _options$stopPullDown;
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;;GACZ,2BAAM,QAAQ,2FAAU,KAAK;EAC/B,UACQ;;GAEN,gCADa,QAAQ,mGAA8B,IAAI,oBAAoB,GACjE,CAAC;EACb;CACF,CAAC;AACH"}
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"}