wevu 6.18.7 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (585) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.mjs +1 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.mjs +1 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.mjs +1 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.mjs +1 -0
  5. package/dist/{rolldown-runtime-CenpyGzJ.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
  6. package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.mjs +14 -0
  7. package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.mjs +16 -0
  8. package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.mjs +11 -0
  9. package/dist/dev/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.mjs +12 -0
  10. package/dist/dev/{rolldown-runtime-BUUfjzRC.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
  11. package/dist/dev/index.mjs +49 -10
  12. package/dist/dev/internal-reactivity.mjs +15 -5
  13. package/dist/dev/internal-runtime.mjs +32 -4
  14. package/dist/dev/internal-template.mjs +1 -1
  15. package/dist/dev/package.mjs +6 -0
  16. package/dist/dev/package.mjs.map +1 -0
  17. package/dist/dev/reactivity/computed.mjs +49 -0
  18. package/dist/dev/reactivity/computed.mjs.map +1 -0
  19. package/dist/dev/reactivity/core.mjs +184 -0
  20. package/dist/dev/reactivity/core.mjs.map +1 -0
  21. package/dist/dev/reactivity/reactive/mutation.mjs +12 -0
  22. package/dist/dev/reactivity/reactive/mutation.mjs.map +1 -0
  23. package/dist/dev/{computed-BxRsUJgi.mjs → reactivity/reactive/patch.mjs} +6 -48
  24. package/dist/dev/reactivity/reactive/patch.mjs.map +1 -0
  25. package/dist/dev/reactivity/reactive/patchState.mjs +138 -0
  26. package/dist/dev/reactivity/reactive/patchState.mjs.map +1 -0
  27. package/dist/dev/reactivity/reactive/shallow.mjs +77 -0
  28. package/dist/dev/reactivity/reactive/shallow.mjs.map +1 -0
  29. package/dist/dev/reactivity/reactive/shared.mjs +40 -0
  30. package/dist/dev/reactivity/reactive/shared.mjs.map +1 -0
  31. package/dist/dev/reactivity/reactive/state.mjs +8 -0
  32. package/dist/dev/reactivity/reactive/state.mjs.map +1 -0
  33. package/dist/dev/reactivity/reactive.mjs +212 -0
  34. package/dist/dev/reactivity/reactive.mjs.map +1 -0
  35. package/dist/dev/reactivity/readonly.mjs +69 -0
  36. package/dist/dev/reactivity/readonly.mjs.map +1 -0
  37. package/dist/dev/reactivity/ref.mjs +97 -0
  38. package/dist/dev/reactivity/ref.mjs.map +1 -0
  39. package/dist/dev/reactivity/shallowRef.mjs +71 -0
  40. package/dist/dev/reactivity/shallowRef.mjs.map +1 -0
  41. package/dist/dev/{toRefs-D06VmFK2.mjs → reactivity/toRefs.mjs} +4 -3
  42. package/dist/dev/reactivity/toRefs.mjs.map +1 -0
  43. package/dist/dev/reactivity/traverse.mjs +40 -0
  44. package/dist/dev/reactivity/traverse.mjs.map +1 -0
  45. package/dist/dev/reactivity/watch/helpers.mjs +78 -0
  46. package/dist/dev/reactivity/watch/helpers.mjs.map +1 -0
  47. package/dist/dev/reactivity/watch/types.mjs +20 -0
  48. package/dist/dev/reactivity/watch/types.mjs.map +1 -0
  49. package/dist/dev/reactivity/watch.mjs +167 -0
  50. package/dist/dev/reactivity/watch.mjs.map +1 -0
  51. package/dist/dev/router/backNavigation.mjs +32 -0
  52. package/dist/dev/router/backNavigation.mjs.map +1 -0
  53. package/dist/dev/router/createRouter.mjs +176 -0
  54. package/dist/dev/router/createRouter.mjs.map +1 -0
  55. package/dist/dev/router/instance.mjs +17 -0
  56. package/dist/dev/router/instance.mjs.map +1 -0
  57. package/dist/dev/router/navigationApi.mjs +94 -0
  58. package/dist/dev/router/navigationApi.mjs.map +1 -0
  59. package/dist/dev/router/navigationCore.mjs +139 -0
  60. package/dist/dev/router/navigationCore.mjs.map +1 -0
  61. package/dist/dev/router/navigationResult.mjs +54 -0
  62. package/dist/dev/router/navigationResult.mjs.map +1 -0
  63. package/dist/dev/router/navigationTarget.mjs +121 -0
  64. package/dist/dev/router/navigationTarget.mjs.map +1 -0
  65. package/dist/dev/router/navigationTargetHelpers.mjs +38 -0
  66. package/dist/dev/router/navigationTargetHelpers.mjs.map +1 -0
  67. package/dist/dev/router/resolve.mjs +22 -0
  68. package/dist/dev/router/resolve.mjs.map +1 -0
  69. package/dist/dev/router/routeRegistry.mjs +78 -0
  70. package/dist/dev/router/routeRegistry.mjs.map +1 -0
  71. package/dist/dev/router/routeSync.mjs +72 -0
  72. package/dist/dev/router/routeSync.mjs.map +1 -0
  73. package/dist/dev/router/types.mjs +11 -0
  74. package/dist/dev/router/types.mjs.map +1 -0
  75. package/dist/dev/router/useRoute.mjs +106 -0
  76. package/dist/dev/router/useRoute.mjs.map +1 -0
  77. package/dist/dev/router/useRouter.mjs +15 -0
  78. package/dist/dev/router/useRouter.mjs.map +1 -0
  79. package/dist/dev/router.mjs +9 -1378
  80. package/dist/dev/routerInternal/location.mjs +66 -0
  81. package/dist/dev/routerInternal/location.mjs.map +1 -0
  82. package/dist/dev/routerInternal/matching.mjs +149 -0
  83. package/dist/dev/routerInternal/matching.mjs.map +1 -0
  84. package/dist/dev/routerInternal/params.mjs +95 -0
  85. package/dist/dev/routerInternal/params.mjs.map +1 -0
  86. package/dist/dev/routerInternal/path.mjs +42 -0
  87. package/dist/dev/routerInternal/path.mjs.map +1 -0
  88. package/dist/dev/routerInternal/query.mjs +113 -0
  89. package/dist/dev/routerInternal/query.mjs.map +1 -0
  90. package/dist/dev/routerInternal/records.mjs +172 -0
  91. package/dist/dev/routerInternal/records.mjs.map +1 -0
  92. package/dist/dev/routerInternal/recordsWarnings.mjs +49 -0
  93. package/dist/dev/routerInternal/recordsWarnings.mjs.map +1 -0
  94. package/dist/dev/routerInternal/snapshots.mjs +126 -0
  95. package/dist/dev/routerInternal/snapshots.mjs.map +1 -0
  96. package/dist/dev/runtime/app/computed.mjs +68 -0
  97. package/dist/dev/runtime/app/computed.mjs.map +1 -0
  98. package/dist/dev/runtime/app/context.mjs +275 -0
  99. package/dist/dev/runtime/app/context.mjs.map +1 -0
  100. package/dist/dev/runtime/app/diagnostics.mjs +34 -0
  101. package/dist/dev/runtime/app/diagnostics.mjs.map +1 -0
  102. package/dist/dev/runtime/app/mount.mjs +269 -0
  103. package/dist/dev/runtime/app/mount.mjs.map +1 -0
  104. package/dist/dev/runtime/app/pending.mjs +14 -0
  105. package/dist/dev/runtime/app/pending.mjs.map +1 -0
  106. package/dist/dev/runtime/app/setData/patchScheduler.mjs +158 -0
  107. package/dist/dev/runtime/app/setData/patchScheduler.mjs.map +1 -0
  108. package/dist/dev/runtime/app/setData/payload.mjs +161 -0
  109. package/dist/dev/runtime/app/setData/payload.mjs.map +1 -0
  110. package/dist/dev/runtime/app/setData/scheduler.mjs +313 -0
  111. package/dist/dev/runtime/app/setData/scheduler.mjs.map +1 -0
  112. package/dist/dev/runtime/app/setData/snapshot.mjs +129 -0
  113. package/dist/dev/runtime/app/setData/snapshot.mjs.map +1 -0
  114. package/dist/dev/runtime/app/setDataOptions.mjs +73 -0
  115. package/dist/dev/runtime/app/setDataOptions.mjs.map +1 -0
  116. package/dist/dev/runtime/app.mjs +93 -0
  117. package/dist/dev/runtime/app.mjs.map +1 -0
  118. package/dist/dev/runtime/bindModel.mjs +92 -0
  119. package/dist/dev/runtime/bindModel.mjs.map +1 -0
  120. package/dist/dev/runtime/defaults.mjs +61 -0
  121. package/dist/dev/runtime/defaults.mjs.map +1 -0
  122. package/dist/dev/runtime/define/initialComputed.mjs +125 -0
  123. package/dist/dev/runtime/define/initialComputed.mjs.map +1 -0
  124. package/dist/dev/runtime/define/options.mjs +169 -0
  125. package/dist/dev/runtime/define/options.mjs.map +1 -0
  126. package/dist/dev/runtime/define/optionsApi.mjs +48 -0
  127. package/dist/dev/runtime/define/optionsApi.mjs.map +1 -0
  128. package/dist/dev/runtime/define/props.mjs +194 -0
  129. package/dist/dev/runtime/define/props.mjs.map +1 -0
  130. package/dist/dev/runtime/define/scopedSlotOptions.mjs +313 -0
  131. package/dist/dev/runtime/define/scopedSlotOptions.mjs.map +1 -0
  132. package/dist/dev/runtime/define/setupResult.mjs +78 -0
  133. package/dist/dev/runtime/define/setupResult.mjs.map +1 -0
  134. package/dist/dev/runtime/define.mjs +140 -0
  135. package/dist/dev/runtime/define.mjs.map +1 -0
  136. package/dist/dev/runtime/diff.mjs +193 -0
  137. package/dist/dev/runtime/diff.mjs.map +1 -0
  138. package/dist/dev/runtime/disposables.mjs +81 -0
  139. package/dist/dev/runtime/disposables.mjs.map +1 -0
  140. package/dist/dev/runtime/elementIntersectionObserver.mjs +80 -0
  141. package/dist/dev/runtime/elementIntersectionObserver.mjs.map +1 -0
  142. package/dist/dev/runtime/emit.mjs +36 -0
  143. package/dist/dev/runtime/emit.mjs.map +1 -0
  144. package/dist/dev/{base-CYkvI7w8.mjs → runtime/hooks/base.mjs} +3 -140
  145. package/dist/dev/runtime/hooks/base.mjs.map +1 -0
  146. package/dist/dev/runtime/hooks/register.mjs +92 -0
  147. package/dist/dev/runtime/hooks/register.mjs.map +1 -0
  148. package/dist/dev/runtime/hooks/vue.mjs +81 -0
  149. package/dist/dev/runtime/hooks/vue.mjs.map +1 -0
  150. package/dist/dev/runtime/internal.mjs +18 -0
  151. package/dist/dev/runtime/internal.mjs.map +1 -0
  152. package/dist/dev/runtime/intersectionObserver.mjs +46 -0
  153. package/dist/dev/runtime/intersectionObserver.mjs.map +1 -0
  154. package/dist/dev/runtime/layoutBridge.mjs +303 -0
  155. package/dist/dev/runtime/layoutBridge.mjs.map +1 -0
  156. package/dist/dev/runtime/layoutComponentMatcher.mjs +11 -0
  157. package/dist/dev/runtime/layoutComponentMatcher.mjs.map +1 -0
  158. package/dist/dev/runtime/nativeBridge.mjs +21 -0
  159. package/dist/dev/runtime/nativeBridge.mjs.map +1 -0
  160. package/dist/dev/runtime/noSetData.mjs +18 -0
  161. package/dist/dev/runtime/noSetData.mjs.map +1 -0
  162. package/dist/dev/runtime/pageEnvironment.mjs +100 -0
  163. package/dist/dev/runtime/pageEnvironment.mjs.map +1 -0
  164. package/dist/dev/runtime/pageLayout.mjs +71 -0
  165. package/dist/dev/runtime/pageLayout.mjs.map +1 -0
  166. package/dist/dev/runtime/pageScroll.mjs +110 -0
  167. package/dist/dev/runtime/pageScroll.mjs.map +1 -0
  168. package/dist/dev/runtime/platform.mjs +77 -0
  169. package/dist/dev/runtime/platform.mjs.map +1 -0
  170. package/dist/dev/runtime/provide.mjs +71 -0
  171. package/dist/dev/runtime/provide.mjs.map +1 -0
  172. package/dist/dev/runtime/provideContext.mjs +101 -0
  173. package/dist/dev/runtime/provideContext.mjs.map +1 -0
  174. package/dist/dev/runtime/provideStore.mjs +18 -0
  175. package/dist/dev/runtime/provideStore.mjs.map +1 -0
  176. package/dist/dev/runtime/pullDownRefresh.mjs +24 -0
  177. package/dist/dev/runtime/pullDownRefresh.mjs.map +1 -0
  178. package/dist/dev/runtime/register/app.mjs +159 -0
  179. package/dist/dev/runtime/register/app.mjs.map +1 -0
  180. package/dist/dev/runtime/register/component/features.mjs +43 -0
  181. package/dist/dev/runtime/register/component/features.mjs.map +1 -0
  182. package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +64 -0
  183. package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs.map +1 -0
  184. package/dist/dev/runtime/register/component/lifecycle/platform.mjs +95 -0
  185. package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -0
  186. package/dist/dev/runtime/register/component/lifecycle.mjs +122 -0
  187. package/dist/dev/runtime/register/component/lifecycle.mjs.map +1 -0
  188. package/dist/dev/runtime/register/component/methods.mjs +80 -0
  189. package/dist/dev/runtime/register/component/methods.mjs.map +1 -0
  190. package/dist/dev/runtime/register/component/options.mjs +204 -0
  191. package/dist/dev/runtime/register/component/options.mjs.map +1 -0
  192. package/dist/dev/runtime/register/component/props.mjs +218 -0
  193. package/dist/dev/runtime/register/component/props.mjs.map +1 -0
  194. package/dist/dev/runtime/register/component/registerDefinition.mjs +290 -0
  195. package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -0
  196. package/dist/dev/runtime/register/component.mjs +128 -0
  197. package/dist/dev/runtime/register/component.mjs.map +1 -0
  198. package/dist/dev/runtime/register/inline.mjs +145 -0
  199. package/dist/dev/runtime/register/inline.mjs.map +1 -0
  200. package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs +53 -0
  201. package/dist/dev/runtime/register/runtimeInstance/methodBridge.mjs.map +1 -0
  202. package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs +34 -0
  203. package/dist/dev/runtime/register/runtimeInstance/provideContext.mjs.map +1 -0
  204. package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs +230 -0
  205. package/dist/dev/runtime/register/runtimeInstance/setupContext.mjs.map +1 -0
  206. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +164 -0
  207. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -0
  208. package/dist/dev/runtime/register/runtimeInstance/utils.mjs +122 -0
  209. package/dist/dev/runtime/register/runtimeInstance/utils.mjs.map +1 -0
  210. package/dist/dev/runtime/register/runtimeInstance.mjs +438 -0
  211. package/dist/dev/runtime/register/runtimeInstance.mjs.map +1 -0
  212. package/dist/dev/runtime/register/setDataFrequencyWarning.mjs +95 -0
  213. package/dist/dev/runtime/register/setDataFrequencyWarning.mjs.map +1 -0
  214. package/dist/dev/runtime/register/setup.mjs +22 -0
  215. package/dist/dev/runtime/register/setup.mjs.map +1 -0
  216. package/dist/dev/runtime/register/snapshot.mjs +17 -0
  217. package/dist/dev/runtime/register/snapshot.mjs.map +1 -0
  218. package/dist/dev/runtime/register/watch.mjs +57 -0
  219. package/dist/dev/runtime/register/watch.mjs.map +1 -0
  220. package/dist/dev/runtime/scopedSlots.mjs +115 -0
  221. package/dist/dev/runtime/scopedSlots.mjs.map +1 -0
  222. package/dist/dev/runtime/selectorQuery.mjs +49 -0
  223. package/dist/dev/runtime/selectorQuery.mjs.map +1 -0
  224. package/dist/dev/runtime/setupTracking.mjs +59 -0
  225. package/dist/dev/runtime/setupTracking.mjs.map +1 -0
  226. package/dist/dev/{template-n_iVr0ey.mjs → runtime/template.mjs} +7 -4
  227. package/dist/dev/runtime/template.mjs.map +1 -0
  228. package/dist/dev/runtime/templateRefs/helpers.mjs +254 -0
  229. package/dist/dev/runtime/templateRefs/helpers.mjs.map +1 -0
  230. package/dist/dev/runtime/templateRefs.mjs +162 -0
  231. package/dist/dev/runtime/templateRefs.mjs.map +1 -0
  232. package/dist/dev/runtime/uniAppHost.mjs +119 -0
  233. package/dist/dev/runtime/uniAppHost.mjs.map +1 -0
  234. package/dist/dev/runtime/updatePerformance.mjs +41 -0
  235. package/dist/dev/runtime/updatePerformance.mjs.map +1 -0
  236. package/dist/dev/runtime/use.mjs +25 -0
  237. package/dist/dev/runtime/use.mjs.map +1 -0
  238. package/dist/dev/runtime/vueCompat/context.mjs +25 -0
  239. package/dist/dev/runtime/vueCompat/context.mjs.map +1 -0
  240. package/dist/dev/runtime/vueCompat/model.mjs +118 -0
  241. package/dist/dev/runtime/vueCompat/model.mjs.map +1 -0
  242. package/dist/dev/runtime/vueCompat/router.mjs +124 -0
  243. package/dist/dev/runtime/vueCompat/router.mjs.map +1 -0
  244. package/dist/dev/runtime/vueCompat/templateRef.mjs +37 -0
  245. package/dist/dev/runtime/vueCompat/templateRef.mjs.map +1 -0
  246. package/dist/dev/scheduler.mjs +75 -0
  247. package/dist/dev/scheduler.mjs.map +1 -0
  248. package/dist/dev/store/actions.mjs +40 -0
  249. package/dist/dev/store/actions.mjs.map +1 -0
  250. package/dist/dev/store/base.mjs +56 -0
  251. package/dist/dev/store/base.mjs.map +1 -0
  252. package/dist/dev/store/define/optionsStyle.mjs +125 -0
  253. package/dist/dev/store/define/optionsStyle.mjs.map +1 -0
  254. package/dist/dev/store/define/setupStyle.mjs +145 -0
  255. package/dist/dev/store/define/setupStyle.mjs.map +1 -0
  256. package/dist/dev/store/define/shared.mjs +38 -0
  257. package/dist/dev/store/define/shared.mjs.map +1 -0
  258. package/dist/dev/store/define.mjs +23 -0
  259. package/dist/dev/store/define.mjs.map +1 -0
  260. package/dist/dev/store/manager.mjs +21 -0
  261. package/dist/dev/store/manager.mjs.map +1 -0
  262. package/dist/dev/store/storeToRefs.mjs +29 -0
  263. package/dist/dev/store/storeToRefs.mjs.map +1 -0
  264. package/dist/dev/store/utils.mjs +49 -0
  265. package/dist/dev/store/utils.mjs.map +1 -0
  266. package/dist/dev/store.mjs +3 -1
  267. package/dist/dev/utils.mjs +16 -0
  268. package/dist/dev/utils.mjs.map +1 -0
  269. package/dist/dev/version.mjs +8 -0
  270. package/dist/dev/version.mjs.map +1 -0
  271. package/dist/dev/vue-demi.mjs +49 -11
  272. package/dist/dev/vue-demi.mjs.map +1 -1
  273. package/dist/index.d.mts +71 -7
  274. package/dist/index.mjs +1 -1
  275. package/dist/internal-reactivity.d.mts +16 -2
  276. package/dist/internal-reactivity.mjs +1 -1
  277. package/dist/internal-runtime.d.mts +35 -2
  278. package/dist/internal-runtime.mjs +1 -1
  279. package/dist/internal-template.d.mts +1 -1
  280. package/dist/internal-template.mjs +1 -1
  281. package/dist/jsx-runtime.d.mts +1 -1
  282. package/dist/macros/shared.d.mts +81 -0
  283. package/dist/macros.d.mts +70 -0
  284. package/dist/package.mjs +1 -0
  285. package/dist/reactivity/computed.d.mts +21 -0
  286. package/dist/reactivity/computed.mjs +1 -0
  287. package/dist/reactivity/core.d.mts +34 -0
  288. package/dist/reactivity/core.mjs +1 -0
  289. package/dist/reactivity/index.d.mts +15 -0
  290. package/dist/reactivity/reactive/mutation.d.mts +21 -0
  291. package/dist/reactivity/reactive/mutation.mjs +1 -0
  292. package/dist/reactivity/reactive/patch.d.mts +18 -0
  293. package/dist/reactivity/reactive/patch.mjs +1 -0
  294. package/dist/reactivity/reactive/patchState.mjs +1 -0
  295. package/dist/reactivity/reactive/shallow.d.mts +22 -0
  296. package/dist/reactivity/reactive/shallow.mjs +1 -0
  297. package/dist/reactivity/reactive/shared.d.mts +4 -0
  298. package/dist/reactivity/reactive/shared.mjs +1 -0
  299. package/dist/reactivity/reactive/state.mjs +1 -0
  300. package/dist/reactivity/reactive.d.mts +41 -0
  301. package/dist/reactivity/reactive.mjs +1 -0
  302. package/dist/reactivity/readonly.d.mts +27 -0
  303. package/dist/reactivity/readonly.mjs +1 -0
  304. package/dist/reactivity/ref.d.mts +27 -0
  305. package/dist/reactivity/ref.mjs +1 -0
  306. package/dist/reactivity/shallowRef.d.mts +19 -0
  307. package/dist/reactivity/shallowRef.mjs +1 -0
  308. package/dist/reactivity/toRefs.d.mts +43 -0
  309. package/dist/reactivity/toRefs.mjs +1 -0
  310. package/dist/reactivity/traverse.d.mts +8 -0
  311. package/dist/reactivity/traverse.mjs +1 -0
  312. package/dist/reactivity/watch/helpers.mjs +1 -0
  313. package/dist/reactivity/watch/types.d.mts +43 -0
  314. package/dist/reactivity/watch/types.mjs +1 -0
  315. package/dist/reactivity/watch.d.mts +21 -0
  316. package/dist/reactivity/watch.mjs +1 -0
  317. package/dist/router/backNavigation.mjs +1 -0
  318. package/dist/router/createRouter.d.mts +8 -0
  319. package/dist/router/createRouter.mjs +1 -0
  320. package/dist/router/instance.mjs +1 -0
  321. package/dist/router/navigationApi.mjs +1 -0
  322. package/dist/router/navigationCore.d.mts +6 -0
  323. package/dist/router/navigationCore.mjs +1 -0
  324. package/dist/router/navigationResult.mjs +1 -0
  325. package/dist/router/navigationTarget.mjs +1 -0
  326. package/dist/router/navigationTargetHelpers.mjs +1 -0
  327. package/dist/router/resolve.d.mts +6 -0
  328. package/dist/router/resolve.mjs +1 -0
  329. package/dist/router/routeRegistry.mjs +1 -0
  330. package/dist/router/routeSync.d.mts +1 -0
  331. package/dist/router/routeSync.mjs +1 -0
  332. package/dist/router/types.d.mts +163 -0
  333. package/dist/router/types.mjs +1 -0
  334. package/dist/router/useRoute.d.mts +19 -0
  335. package/dist/router/useRoute.mjs +1 -0
  336. package/dist/router/useRouter.d.mts +8 -0
  337. package/dist/router/useRouter.mjs +1 -0
  338. package/dist/router.d.mts +9 -204
  339. package/dist/router.mjs +1 -1
  340. package/dist/routerInternal/location.mjs +1 -0
  341. package/dist/routerInternal/matching.mjs +1 -0
  342. package/dist/routerInternal/params.mjs +1 -0
  343. package/dist/routerInternal/path.mjs +1 -0
  344. package/dist/routerInternal/query.d.mts +7 -0
  345. package/dist/routerInternal/query.mjs +1 -0
  346. package/dist/routerInternal/records.mjs +1 -0
  347. package/dist/routerInternal/recordsWarnings.mjs +1 -0
  348. package/dist/routerInternal/snapshots.mjs +1 -0
  349. package/dist/routerInternal/types.d.mts +9 -0
  350. package/dist/runtime/app/computed.mjs +1 -0
  351. package/dist/runtime/app/context.mjs +1 -0
  352. package/dist/runtime/app/diagnostics.mjs +1 -0
  353. package/dist/runtime/app/mount.mjs +1 -0
  354. package/dist/runtime/app/pending.d.mts +10 -0
  355. package/dist/runtime/app/pending.mjs +1 -0
  356. package/dist/runtime/app/setData/patchScheduler.mjs +1 -0
  357. package/dist/runtime/app/setData/payload.mjs +1 -0
  358. package/dist/runtime/app/setData/scheduler.mjs +1 -0
  359. package/dist/runtime/app/setData/snapshot.mjs +1 -0
  360. package/dist/runtime/app/setDataOptions.mjs +1 -0
  361. package/dist/runtime/app.d.mts +8 -0
  362. package/dist/runtime/app.mjs +1 -0
  363. package/dist/runtime/bindModel.mjs +1 -0
  364. package/dist/runtime/defaults.d.mts +11 -0
  365. package/dist/runtime/defaults.mjs +1 -0
  366. package/dist/runtime/define/initialComputed.mjs +1 -0
  367. package/dist/runtime/define/options.mjs +1 -0
  368. package/dist/runtime/define/optionsApi.mjs +1 -0
  369. package/dist/runtime/define/props.mjs +1 -0
  370. package/dist/runtime/define/scopedSlotOptions.mjs +1 -0
  371. package/dist/runtime/define/setupResult.mjs +1 -0
  372. package/dist/runtime/define.d.mts +105 -0
  373. package/dist/runtime/define.mjs +1 -0
  374. package/dist/runtime/diff.mjs +1 -0
  375. package/dist/runtime/disposables.d.mts +31 -0
  376. package/dist/runtime/disposables.mjs +1 -0
  377. package/dist/runtime/elementIntersectionObserver.d.mts +26 -0
  378. package/dist/runtime/elementIntersectionObserver.mjs +1 -0
  379. package/dist/runtime/emit.mjs +1 -0
  380. package/dist/runtime/hooks/base.d.mts +27 -0
  381. package/dist/runtime/hooks/base.mjs +1 -0
  382. package/dist/runtime/hooks/register.d.mts +30 -0
  383. package/dist/runtime/hooks/register.mjs +1 -0
  384. package/dist/runtime/hooks/vue.d.mts +53 -0
  385. package/dist/runtime/hooks/vue.mjs +1 -0
  386. package/dist/runtime/hooks.d.mts +4 -0
  387. package/dist/runtime/index.d.mts +47 -0
  388. package/dist/runtime/internal.mjs +1 -0
  389. package/dist/runtime/intersectionObserver.d.mts +14 -0
  390. package/dist/runtime/intersectionObserver.mjs +1 -0
  391. package/dist/runtime/layoutBridge.d.mts +59 -0
  392. package/dist/runtime/layoutBridge.mjs +1 -0
  393. package/dist/runtime/layoutComponentMatcher.mjs +1 -0
  394. package/dist/runtime/nativeBridge.mjs +1 -0
  395. package/dist/runtime/noSetData.d.mts +5 -0
  396. package/dist/runtime/noSetData.mjs +1 -0
  397. package/dist/runtime/pageEnvironment.d.mts +50 -0
  398. package/dist/runtime/pageEnvironment.mjs +1 -0
  399. package/dist/runtime/pageLayout.d.mts +26 -0
  400. package/dist/runtime/pageLayout.mjs +1 -0
  401. package/dist/runtime/pageScroll.d.mts +29 -0
  402. package/dist/runtime/pageScroll.mjs +1 -0
  403. package/dist/runtime/platform.mjs +1 -0
  404. package/dist/runtime/provide.d.mts +59 -0
  405. package/dist/runtime/provide.mjs +1 -0
  406. package/dist/runtime/provideContext.mjs +1 -0
  407. package/dist/runtime/provideStore.d.mts +7 -0
  408. package/dist/runtime/provideStore.mjs +1 -0
  409. package/dist/runtime/pullDownRefresh.d.mts +12 -0
  410. package/dist/runtime/pullDownRefresh.mjs +1 -0
  411. package/dist/runtime/register/app.d.mts +14 -0
  412. package/dist/runtime/register/app.mjs +1 -0
  413. package/dist/runtime/register/component/features.mjs +1 -0
  414. package/dist/runtime/register/component/lifecycle/optionalHooks.mjs +1 -0
  415. package/dist/runtime/register/component/lifecycle/platform.mjs +1 -0
  416. package/dist/runtime/register/component/lifecycle.mjs +1 -0
  417. package/dist/runtime/register/component/methods.mjs +1 -0
  418. package/dist/runtime/register/component/options.mjs +1 -0
  419. package/dist/runtime/register/component/props.mjs +1 -0
  420. package/dist/runtime/register/component/registerDefinition.mjs +1 -0
  421. package/dist/runtime/register/component.d.mts +15 -0
  422. package/dist/runtime/register/component.mjs +1 -0
  423. package/dist/runtime/register/inline.d.mts +15 -0
  424. package/dist/runtime/register/inline.mjs +1 -0
  425. package/dist/runtime/register/runtimeInstance/methodBridge.mjs +1 -0
  426. package/dist/runtime/register/runtimeInstance/provideContext.mjs +1 -0
  427. package/dist/runtime/register/runtimeInstance/setupContext.mjs +1 -0
  428. package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -0
  429. package/dist/runtime/register/runtimeInstance/utils.mjs +1 -0
  430. package/dist/runtime/register/runtimeInstance.d.mts +26 -0
  431. package/dist/runtime/register/runtimeInstance.mjs +1 -0
  432. package/dist/runtime/register/setDataFrequencyWarning.mjs +1 -0
  433. package/dist/runtime/register/setup.d.mts +11 -0
  434. package/dist/runtime/register/setup.mjs +1 -0
  435. package/dist/runtime/register/snapshot.mjs +1 -0
  436. package/dist/runtime/register/watch.d.mts +12 -0
  437. package/dist/runtime/register/watch.mjs +1 -0
  438. package/dist/runtime/register.d.mts +5 -0
  439. package/dist/runtime/scopedSlots.mjs +1 -0
  440. package/dist/runtime/selectorQuery.d.mts +54 -0
  441. package/dist/runtime/selectorQuery.mjs +1 -0
  442. package/dist/runtime/setupTracking.mjs +1 -0
  443. package/dist/{template-DE8e5dj_.d.mts → runtime/template.d.mts} +1 -1
  444. package/dist/runtime/template.mjs +1 -0
  445. package/dist/runtime/templateRefTypes.d.mts +7 -0
  446. package/dist/runtime/templateRefs/helpers.mjs +1 -0
  447. package/dist/runtime/templateRefs.d.mts +11 -0
  448. package/dist/runtime/templateRefs.mjs +1 -0
  449. package/dist/runtime/types/core.d.mts +35 -0
  450. package/dist/runtime/types/miniprogram.d.mts +80 -0
  451. package/dist/runtime/types/miniprogramHost.d.mts +44 -0
  452. package/dist/runtime/types/miniprogramHostSources.d.mts +112 -0
  453. package/dist/runtime/types/options.d.mts +136 -0
  454. package/dist/runtime/types/props/propTypes.d.mts +79 -0
  455. package/dist/runtime/types/props/router.d.mts +51 -0
  456. package/dist/runtime/types/props/setup.d.mts +96 -0
  457. package/dist/runtime/types/props.d.mts +4 -0
  458. package/dist/runtime/types/runtime.d.mts +59 -0
  459. package/dist/runtime/types/setData.d.mts +220 -0
  460. package/dist/runtime/types.d.mts +28 -0
  461. package/dist/runtime/uniAppHost.d.mts +8 -0
  462. package/dist/runtime/uniAppHost.mjs +1 -0
  463. package/dist/runtime/updatePerformance.d.mts +13 -0
  464. package/dist/runtime/updatePerformance.mjs +1 -0
  465. package/dist/runtime/use.d.mts +13 -0
  466. package/dist/runtime/use.mjs +1 -0
  467. package/dist/runtime/vueCompat/context.d.mts +8 -0
  468. package/dist/runtime/vueCompat/context.mjs +1 -0
  469. package/dist/runtime/vueCompat/model.d.mts +30 -0
  470. package/dist/runtime/vueCompat/model.mjs +1 -0
  471. package/dist/runtime/vueCompat/router.d.mts +28 -0
  472. package/dist/runtime/vueCompat/router.mjs +1 -0
  473. package/dist/runtime/vueCompat/templateRef.d.mts +9 -0
  474. package/dist/runtime/vueCompat/templateRef.mjs +1 -0
  475. package/dist/runtime/vueCompat.d.mts +5 -0
  476. package/dist/scheduler.d.mts +4 -0
  477. package/dist/scheduler.mjs +1 -0
  478. package/dist/store/actions.mjs +1 -0
  479. package/dist/store/base.mjs +1 -0
  480. package/dist/store/define/optionsStyle.mjs +1 -0
  481. package/dist/store/define/setupStyle.mjs +1 -0
  482. package/dist/store/define/shared.mjs +1 -0
  483. package/dist/store/define.d.mts +26 -0
  484. package/dist/store/define.mjs +1 -0
  485. package/dist/store/manager.d.mts +8 -0
  486. package/dist/store/manager.mjs +1 -0
  487. package/dist/store/storeToRefs.d.mts +13 -0
  488. package/dist/store/storeToRefs.mjs +1 -0
  489. package/dist/store/types.d.mts +70 -0
  490. package/dist/store/utils.mjs +1 -0
  491. package/dist/store.d.mts +4 -1
  492. package/dist/store.mjs +1 -1
  493. package/dist/utils.mjs +1 -0
  494. package/dist/version.d.mts +4 -0
  495. package/dist/version.mjs +1 -0
  496. package/dist/vue-augment.d.mts +6 -0
  497. package/dist/vue-demi.d.mts +67 -7
  498. package/dist/vue-demi.mjs +1 -1
  499. package/dist/vue-types.d.mts +18 -0
  500. package/dist/weappIntrinsicElements/base.d.mts +22 -0
  501. package/dist/weappIntrinsicElements/elements/ad-custom.d.mts +13 -0
  502. package/dist/weappIntrinsicElements/elements/ad.d.mts +16 -0
  503. package/dist/weappIntrinsicElements/elements/audio.d.mts +20 -0
  504. package/dist/weappIntrinsicElements/elements/block.d.mts +8 -0
  505. package/dist/weappIntrinsicElements/elements/button.d.mts +40 -0
  506. package/dist/weappIntrinsicElements/elements/camera.d.mts +18 -0
  507. package/dist/weappIntrinsicElements/elements/canvas.d.mts +18 -0
  508. package/dist/weappIntrinsicElements/elements/checkbox-group.d.mts +13 -0
  509. package/dist/weappIntrinsicElements/elements/checkbox.d.mts +13 -0
  510. package/dist/weappIntrinsicElements/elements/cover-image.d.mts +10 -0
  511. package/dist/weappIntrinsicElements/elements/cover-view.d.mts +10 -0
  512. package/dist/weappIntrinsicElements/elements/editor.d.mts +22 -0
  513. package/dist/weappIntrinsicElements/elements/form.d.mts +16 -0
  514. package/dist/weappIntrinsicElements/elements/functional-page-navigator.d.mts +15 -0
  515. package/dist/weappIntrinsicElements/elements/icon.d.mts +12 -0
  516. package/dist/weappIntrinsicElements/elements/image.d.mts +18 -0
  517. package/dist/weappIntrinsicElements/elements/import.d.mts +10 -0
  518. package/dist/weappIntrinsicElements/elements/include.d.mts +10 -0
  519. package/dist/weappIntrinsicElements/elements/input.d.mts +47 -0
  520. package/dist/weappIntrinsicElements/elements/keyboard-accessory.d.mts +8 -0
  521. package/dist/weappIntrinsicElements/elements/label.d.mts +10 -0
  522. package/dist/weappIntrinsicElements/elements/live-player.d.mts +35 -0
  523. package/dist/weappIntrinsicElements/elements/live-pusher.d.mts +57 -0
  524. package/dist/weappIntrinsicElements/elements/map.d.mts +105 -0
  525. package/dist/weappIntrinsicElements/elements/match-media.d.mts +16 -0
  526. package/dist/weappIntrinsicElements/elements/movable-area.d.mts +26 -0
  527. package/dist/weappIntrinsicElements/elements/movable-view.d.mts +26 -0
  528. package/dist/weappIntrinsicElements/elements/navigation-bar.d.mts +15 -0
  529. package/dist/weappIntrinsicElements/elements/navigator.d.mts +25 -0
  530. package/dist/weappIntrinsicElements/elements/official-account.d.mts +13 -0
  531. package/dist/weappIntrinsicElements/elements/open-data.d.mts +15 -0
  532. package/dist/weappIntrinsicElements/elements/page-container.d.mts +25 -0
  533. package/dist/weappIntrinsicElements/elements/page-meta.d.mts +23 -0
  534. package/dist/weappIntrinsicElements/elements/picker-view-column.d.mts +18 -0
  535. package/dist/weappIntrinsicElements/elements/picker-view.d.mts +18 -0
  536. package/dist/weappIntrinsicElements/elements/picker.d.mts +23 -0
  537. package/dist/weappIntrinsicElements/elements/progress.d.mts +21 -0
  538. package/dist/weappIntrinsicElements/elements/radio-group.d.mts +13 -0
  539. package/dist/weappIntrinsicElements/elements/radio.d.mts +13 -0
  540. package/dist/weappIntrinsicElements/elements/rich-text.d.mts +17 -0
  541. package/dist/weappIntrinsicElements/elements/scroll-view.d.mts +68 -0
  542. package/dist/weappIntrinsicElements/elements/share-element.d.mts +18 -0
  543. package/dist/weappIntrinsicElements/elements/slider.d.mts +23 -0
  544. package/dist/weappIntrinsicElements/elements/slot.d.mts +10 -0
  545. package/dist/weappIntrinsicElements/elements/swiper-item.d.mts +42 -0
  546. package/dist/weappIntrinsicElements/elements/swiper.d.mts +42 -0
  547. package/dist/weappIntrinsicElements/elements/switch.d.mts +14 -0
  548. package/dist/weappIntrinsicElements/elements/template.d.mts +12 -0
  549. package/dist/weappIntrinsicElements/elements/text.d.mts +15 -0
  550. package/dist/weappIntrinsicElements/elements/textarea.d.mts +40 -0
  551. package/dist/weappIntrinsicElements/elements/video.d.mts +71 -0
  552. package/dist/weappIntrinsicElements/elements/view.d.mts +13 -0
  553. package/dist/weappIntrinsicElements/elements/voip-room.d.mts +14 -0
  554. package/dist/weappIntrinsicElements/elements/web-view.d.mts +13 -0
  555. package/dist/weappIntrinsicElements.d.mts +153 -0
  556. package/package.json +6 -6
  557. package/dist/base-BxKbbKVO.mjs +0 -1
  558. package/dist/computed-Xoi9XEUx.mjs +0 -1
  559. package/dist/dev/base-CYkvI7w8.mjs.map +0 -1
  560. package/dist/dev/computed-BxRsUJgi.mjs.map +0 -1
  561. package/dist/dev/ref-DRZC3Kc5.mjs +0 -695
  562. package/dist/dev/ref-DRZC3Kc5.mjs.map +0 -1
  563. package/dist/dev/router-D0JQfgyN.mjs +0 -754
  564. package/dist/dev/router-D0JQfgyN.mjs.map +0 -1
  565. package/dist/dev/router.mjs.map +0 -1
  566. package/dist/dev/store-HNsiQJ4d.mjs +0 -479
  567. package/dist/dev/store-HNsiQJ4d.mjs.map +0 -1
  568. package/dist/dev/template-n_iVr0ey.mjs.map +0 -1
  569. package/dist/dev/templateRef-BLnYcEH0.mjs +0 -6439
  570. package/dist/dev/templateRef-BLnYcEH0.mjs.map +0 -1
  571. package/dist/dev/toRefs-D06VmFK2.mjs.map +0 -1
  572. package/dist/dev/watch-jrgL5ald.mjs +0 -445
  573. package/dist/dev/watch-jrgL5ald.mjs.map +0 -1
  574. package/dist/index-BiHILcmb.d.mts +0 -1215
  575. package/dist/index-CCET_bCY.d.mts +0 -111
  576. package/dist/ref-D37CknuD.mjs +0 -1
  577. package/dist/router-D4W4lEXM.mjs +0 -1
  578. package/dist/store-eHrHBQiv.mjs +0 -1
  579. package/dist/template-CNzlwH-E.mjs +0 -1
  580. package/dist/templateRef-DOTHWzZ5.mjs +0 -1
  581. package/dist/toRefs-CoytPyo0.mjs +0 -1
  582. package/dist/traverse-B4Ez44Gd.d.mts +0 -108
  583. package/dist/vue-types-B3N60cGV.d.mts +0 -757
  584. package/dist/watch-Bbd-gmEg.mjs +0 -1
  585. package/dist/weappIntrinsicElements-BgDtC53_.d.mts +0 -1257
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.mjs","names":[],"sources":["../../../../src/runtime/register/app.ts"],"sourcesContent":["import type {\n ComputedDefinitions,\n DefineAppOptions,\n InternalRuntimeState,\n MethodDefinitions,\n MiniProgramAppOptions,\n MiniProgramMemoryWarningResult,\n RuntimeApp,\n} from '../types'\nimport type { WatchMap } from './watch'\nimport {\n WEVU_HOOKS_KEY,\n WEVU_INLINE_HANDLER,\n WEVU_INLINE_MAP_KEY,\n WEVU_IS_APP_INSTANCE_KEY,\n} from '@weapp-core/constants'\nimport { callHookList } from '../hooks'\nimport { getMiniProgramGlobalObject, supportsCurrentMiniProgramRuntimeCapability } from '../platform'\nimport { runInlineExpression } from './inline'\nimport { mountRuntimeInstance } from './runtimeInstance'\n\nconst APP_GLOBAL_LISTENER_STORE_KEY = '__wevuAppGlobalListeners'\nconst MEMORY_WARNING_LISTENER_KEY = '__wevuOnMemoryWarningListener'\n\nfunction bindMemoryWarningListener(target: InternalRuntimeState) {\n const hooks = target[WEVU_HOOKS_KEY] as Record<string, any> | undefined\n const hasMemoryWarningHook = Boolean(hooks?.onMemoryWarning)\n if (!supportsCurrentMiniProgramRuntimeCapability('appMemoryWarningListener')) {\n delete (target as any)[MEMORY_WARNING_LISTENER_KEY]\n return\n }\n const miniProgramGlobal = getMiniProgramGlobalObject()\n const onMemoryWarning = miniProgramGlobal?.onMemoryWarning\n const offMemoryWarning = miniProgramGlobal?.offMemoryWarning\n if (typeof onMemoryWarning !== 'function') {\n return\n }\n\n const existing = (target as any)[MEMORY_WARNING_LISTENER_KEY]\n if (typeof existing === 'function' && typeof offMemoryWarning === 'function') {\n try {\n offMemoryWarning(existing)\n }\n catch {\n // 忽略平台差异导致的取消监听异常\n }\n }\n\n if (!hasMemoryWarningHook) {\n delete (target as any)[MEMORY_WARNING_LISTENER_KEY]\n return\n }\n\n const listener = (result: MiniProgramMemoryWarningResult) => {\n callHookList(target, 'onMemoryWarning', [result])\n }\n ;(target as any)[MEMORY_WARNING_LISTENER_KEY] = listener\n onMemoryWarning(listener)\n}\n\nfunction bindAppGlobalListener(target: InternalRuntimeState, options: {\n hookName: 'onError' | 'onPageNotFound' | 'onUnhandledRejection' | 'onThemeChange'\n onApiName: 'onError' | 'onPageNotFound' | 'onUnhandledRejection' | 'onThemeChange'\n offApiName: 'offError' | 'offPageNotFound' | 'offUnhandledRejection' | 'offThemeChange'\n capabilityName: 'appErrorListener' | 'appPageNotFoundListener' | 'appUnhandledRejectionListener' | 'appThemeChangeListener'\n userHandler?: ((...args: any[]) => any) | undefined\n}) {\n const { hookName, onApiName, offApiName, capabilityName, userHandler } = options\n const hooks = target[WEVU_HOOKS_KEY] as Record<string, any> | undefined\n const hasHook = Boolean(hooks?.[hookName])\n const store = ((target as any)[APP_GLOBAL_LISTENER_STORE_KEY] ??= Object.create(null)) as Record<string, ((...args: any[]) => void) | undefined>\n const existing = store[hookName]\n if (!supportsCurrentMiniProgramRuntimeCapability(capabilityName)) {\n delete store[hookName]\n delete (target as any)[hookName]\n return\n }\n const miniProgramGlobal = getMiniProgramGlobalObject()\n const onApi = miniProgramGlobal?.[onApiName]\n const offApi = miniProgramGlobal?.[offApiName]\n\n if (typeof existing === 'function' && typeof offApi === 'function') {\n try {\n offApi(existing)\n }\n catch {\n // 忽略平台差异导致的取消监听异常\n }\n }\n\n if (!hasHook && typeof userHandler !== 'function') {\n delete store[hookName]\n return\n }\n\n const dispatch = (...args: any[]) => {\n callHookList(target, hookName, args)\n if (typeof userHandler === 'function') {\n userHandler.apply(target, args)\n }\n }\n\n ;(target as any)[hookName] = dispatch\n store[hookName] = dispatch\n\n if (typeof onApi === 'function') {\n onApi(dispatch)\n }\n}\n\nfunction bindAppGlobalListeners(\n target: InternalRuntimeState,\n handlers: {\n onError?: ((...args: any[]) => any) | undefined\n onPageNotFound?: ((...args: any[]) => any) | undefined\n onUnhandledRejection?: ((...args: any[]) => any) | undefined\n onThemeChange?: ((...args: any[]) => any) | undefined\n },\n) {\n bindAppGlobalListener(target, {\n hookName: 'onError',\n onApiName: 'onError',\n offApiName: 'offError',\n capabilityName: 'appErrorListener',\n userHandler: handlers.onError,\n })\n bindAppGlobalListener(target, {\n hookName: 'onPageNotFound',\n onApiName: 'onPageNotFound',\n offApiName: 'offPageNotFound',\n capabilityName: 'appPageNotFoundListener',\n userHandler: handlers.onPageNotFound,\n })\n bindAppGlobalListener(target, {\n hookName: 'onUnhandledRejection',\n onApiName: 'onUnhandledRejection',\n offApiName: 'offUnhandledRejection',\n capabilityName: 'appUnhandledRejectionListener',\n userHandler: handlers.onUnhandledRejection,\n })\n bindAppGlobalListener(target, {\n hookName: 'onThemeChange',\n onApiName: 'onThemeChange',\n offApiName: 'offThemeChange',\n capabilityName: 'appThemeChangeListener',\n userHandler: handlers.onThemeChange,\n })\n}\n\n/**\n * 注册 App 入口(框架内部使用)。\n * @internal\n */\nexport function registerApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(\n runtimeApp: RuntimeApp<D, C, M>,\n methods: MethodDefinitions,\n watch: WatchMap | undefined,\n setup: DefineAppOptions<D, C, M>['setup'],\n mpOptions: MiniProgramAppOptions,\n) {\n if (typeof App !== 'function') {\n throw new TypeError('createApp 需要全局 App 构造器可用')\n }\n\n const methodNames = Object.keys(methods ?? {})\n const appOptions: Record<string, any> = {\n ...mpOptions,\n }\n\n appOptions.globalData = appOptions.globalData ?? {}\n\n if (!appOptions[WEVU_INLINE_HANDLER]) {\n appOptions[WEVU_INLINE_HANDLER] = function __weapp_vite_inline(this: InternalRuntimeState, event: any) {\n const runtime = (this as any).__wevu\n const ctx = runtime?.proxy ?? this\n const inlineMap = runtime?.methods?.[WEVU_INLINE_MAP_KEY]\n return runInlineExpression(ctx, undefined, event, inlineMap)\n }\n }\n\n const userOnLaunch = appOptions.onLaunch\n const userOnError = appOptions.onError\n const userOnPageNotFound = (appOptions as any).onPageNotFound\n const userOnUnhandledRejection = (appOptions as any).onUnhandledRejection\n const userOnThemeChange = (appOptions as any).onThemeChange\n appOptions.onLaunch = function onLaunch(this: InternalRuntimeState, ...args: any[]) {\n this[WEVU_IS_APP_INSTANCE_KEY] = true\n mountRuntimeInstance(this, runtimeApp, watch, setup)\n bindMemoryWarningListener(this)\n bindAppGlobalListeners(this, {\n onError: userOnError,\n onPageNotFound: userOnPageNotFound,\n onUnhandledRejection: userOnUnhandledRejection,\n onThemeChange: userOnThemeChange,\n })\n callHookList(this, 'onLaunch', args)\n if (typeof userOnLaunch === 'function') {\n userOnLaunch.apply(this, args)\n }\n }\n\n const userOnShow = appOptions.onShow\n appOptions.onShow = function onShow(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onShow', args)\n if (typeof userOnShow === 'function') {\n userOnShow.apply(this, args)\n }\n }\n\n const userOnHide = appOptions.onHide\n appOptions.onHide = function onHide(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onHide', args)\n if (typeof userOnHide === 'function') {\n userOnHide.apply(this, args)\n }\n }\n\n delete appOptions.onError\n delete (appOptions as any).onPageNotFound\n delete (appOptions as any).onUnhandledRejection\n delete (appOptions as any).onThemeChange\n\n for (const methodName of methodNames) {\n const userMethod = appOptions[methodName]\n appOptions[methodName] = function runtimeMethod(this: InternalRuntimeState, ...args: any[]) {\n const runtime = this.__wevu\n let result: unknown\n const bound = runtime?.methods?.[methodName]\n if (bound) {\n result = bound.apply(runtime.proxy, args)\n }\n if (typeof userMethod === 'function') {\n return userMethod.apply(this, args)\n }\n return result\n }\n }\n\n App(appOptions)\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,gCAAgC;AACtC,MAAM,8BAA8B;AAEpC,SAAS,0BAA0B,QAA8B;CAC/D,MAAM,QAAQ,OAAO;CACrB,MAAM,uBAAuB,sDAAQ,MAAO,eAAe;CAC3D,IAAI,CAAC,4CAA4C,0BAA0B,GAAG;EAC5E,OAAQ,OAAe;EACvB;CACF;CACA,MAAM,oBAAoB,2BAA2B;CACrD,MAAM,wFAAkB,kBAAmB;CAC3C,MAAM,yFAAmB,kBAAmB;CAC5C,IAAI,OAAO,oBAAoB,YAC7B;CAGF,MAAM,WAAY,OAAe;CACjC,IAAI,OAAO,aAAa,cAAc,OAAO,qBAAqB,YAChE,IAAI;EACF,iBAAiB,QAAQ;CAC3B,kBACM,CAEN;CAGF,IAAI,CAAC,sBAAsB;EACzB,OAAQ,OAAe;EACvB;CACF;CAEA,MAAM,YAAY,WAA2C;EAC3D,aAAa,QAAQ,mBAAmB,CAAC,MAAM,CAAC;CAClD;CACC,AAAC,OAAe,+BAA+B;CAChD,gBAAgB,QAAQ;AAC1B;AAEA,SAAS,sBAAsB,QAA8B,SAM1D;;CACD,MAAM,EAAE,UAAU,WAAW,YAAY,gBAAgB,gBAAgB;CACzE,MAAM,QAAQ,OAAO;CACrB,MAAM,UAAU,sDAAQ,MAAQ,SAAS;CACzC,MAAM,yCAAU,QAAe,6IAAmC,OAAO,OAAO,IAAI;CACpF,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,4CAA4C,cAAc,GAAG;EAChE,OAAO,MAAM;EACb,OAAQ,OAAe;EACvB;CACF;CACA,MAAM,oBAAoB,2BAA2B;CACrD,MAAM,8EAAQ,kBAAoB;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features.ts
2
+ function resolveComponentFeatures(options) {
3
+ const { features, userOnSaveExitState, userOnPullDownRefresh, userOnReachBottom, userOnPageScroll, userOnRouteDone, userOnTabItemTap, userOnResize, userOnShareAppMessage, userOnShareTimeline, userOnAddToFavorites } = options;
4
+ const enableOnPullDownRefresh = typeof userOnPullDownRefresh === "function" || Boolean(features.enableOnPullDownRefresh);
5
+ const enableOnReachBottom = typeof userOnReachBottom === "function" || Boolean(features.enableOnReachBottom);
6
+ const enableOnPageScroll = typeof userOnPageScroll === "function" || Boolean(features.enableOnPageScroll);
7
+ const enableOnRouteDone = typeof userOnRouteDone === "function" || Boolean(features.enableOnRouteDone);
8
+ const enableOnRouteDoneFallback = Boolean(features.enableOnRouteDoneFallback);
9
+ const enableOnTabItemTap = typeof userOnTabItemTap === "function" || Boolean(features.enableOnTabItemTap);
10
+ const enableOnResize = typeof userOnResize === "function" || Boolean(features.enableOnResize);
11
+ const enableOnShareTimeline = typeof userOnShareTimeline === "function" || Boolean(features.enableOnShareTimeline);
12
+ const enableOnShareAppMessage = typeof userOnShareAppMessage === "function" || Boolean(features.enableOnShareAppMessage);
13
+ const enableOnAddToFavorites = typeof userOnAddToFavorites === "function" || Boolean(features.enableOnAddToFavorites);
14
+ const enableOnSaveExitState = typeof userOnSaveExitState === "function" || Boolean(features.enableOnSaveExitState);
15
+ const fallbackNoop = () => {};
16
+ return {
17
+ enableOnPullDownRefresh,
18
+ enableOnReachBottom,
19
+ enableOnPageScroll,
20
+ enableOnRouteDone,
21
+ enableOnRouteDoneFallback,
22
+ enableOnTabItemTap,
23
+ enableOnResize,
24
+ enableOnShareAppMessage,
25
+ enableOnShareTimeline,
26
+ enableOnAddToFavorites,
27
+ enableOnSaveExitState,
28
+ effectiveOnSaveExitState: typeof userOnSaveExitState === "function" ? userOnSaveExitState : (() => ({ data: void 0 })),
29
+ effectiveOnPullDownRefresh: typeof userOnPullDownRefresh === "function" ? userOnPullDownRefresh : fallbackNoop,
30
+ effectiveOnReachBottom: typeof userOnReachBottom === "function" ? userOnReachBottom : fallbackNoop,
31
+ effectiveOnPageScroll: typeof userOnPageScroll === "function" ? userOnPageScroll : fallbackNoop,
32
+ effectiveOnRouteDone: typeof userOnRouteDone === "function" ? userOnRouteDone : fallbackNoop,
33
+ effectiveOnTabItemTap: typeof userOnTabItemTap === "function" ? userOnTabItemTap : fallbackNoop,
34
+ effectiveOnResize: typeof userOnResize === "function" ? userOnResize : fallbackNoop,
35
+ effectiveOnShareAppMessage: typeof userOnShareAppMessage === "function" ? userOnShareAppMessage : fallbackNoop,
36
+ effectiveOnShareTimeline: typeof userOnShareTimeline === "function" ? userOnShareTimeline : fallbackNoop,
37
+ effectiveOnAddToFavorites: typeof userOnAddToFavorites === "function" ? userOnAddToFavorites : (() => ({}))
38
+ };
39
+ }
40
+
41
+ //#endregion
42
+ export { resolveComponentFeatures };
43
+ //# sourceMappingURL=features.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.mjs","names":[],"sources":["../../../../../src/runtime/register/component/features.ts"],"sourcesContent":["import type { PageFeatures } from '../../types'\n\nexport function resolveComponentFeatures(options: {\n features: PageFeatures\n userOnSaveExitState?: any\n userOnPullDownRefresh?: any\n userOnReachBottom?: any\n userOnPageScroll?: any\n userOnRouteDone?: any\n userOnTabItemTap?: any\n userOnResize?: any\n userOnShareAppMessage?: any\n userOnShareTimeline?: any\n userOnAddToFavorites?: any\n}) {\n const {\n features,\n userOnSaveExitState,\n userOnPullDownRefresh,\n userOnReachBottom,\n userOnPageScroll,\n userOnRouteDone,\n userOnTabItemTap,\n userOnResize,\n userOnShareAppMessage,\n userOnShareTimeline,\n userOnAddToFavorites,\n } = options\n\n const enableOnPullDownRefresh = typeof userOnPullDownRefresh === 'function' || Boolean(features.enableOnPullDownRefresh)\n const enableOnReachBottom = typeof userOnReachBottom === 'function' || Boolean(features.enableOnReachBottom)\n const enableOnPageScroll = typeof userOnPageScroll === 'function' || Boolean(features.enableOnPageScroll)\n const enableOnRouteDone = typeof userOnRouteDone === 'function' || Boolean(features.enableOnRouteDone)\n const enableOnRouteDoneFallback = Boolean(features.enableOnRouteDoneFallback)\n const enableOnTabItemTap = typeof userOnTabItemTap === 'function' || Boolean(features.enableOnTabItemTap)\n const enableOnResize = typeof userOnResize === 'function' || Boolean(features.enableOnResize)\n const enableOnShareTimeline = typeof userOnShareTimeline === 'function' || Boolean(features.enableOnShareTimeline)\n const enableOnShareAppMessage = typeof userOnShareAppMessage === 'function' || Boolean(features.enableOnShareAppMessage)\n const enableOnAddToFavorites = typeof userOnAddToFavorites === 'function' || Boolean(features.enableOnAddToFavorites)\n const enableOnSaveExitState = typeof userOnSaveExitState === 'function' || Boolean(features.enableOnSaveExitState)\n\n const fallbackNoop = () => {}\n\n const effectiveOnSaveExitState = (typeof userOnSaveExitState === 'function'\n ? userOnSaveExitState\n : (() => ({ data: undefined })) as any)\n const effectiveOnPullDownRefresh = typeof userOnPullDownRefresh === 'function' ? userOnPullDownRefresh : fallbackNoop\n const effectiveOnReachBottom = typeof userOnReachBottom === 'function' ? userOnReachBottom : fallbackNoop\n const effectiveOnPageScroll = typeof userOnPageScroll === 'function' ? userOnPageScroll : fallbackNoop\n const effectiveOnRouteDone = typeof userOnRouteDone === 'function' ? userOnRouteDone : fallbackNoop\n const effectiveOnTabItemTap = typeof userOnTabItemTap === 'function' ? userOnTabItemTap : fallbackNoop\n const effectiveOnResize = typeof userOnResize === 'function' ? userOnResize : fallbackNoop\n const effectiveOnShareAppMessage = typeof userOnShareAppMessage === 'function' ? userOnShareAppMessage : (fallbackNoop as any)\n const effectiveOnShareTimeline = typeof userOnShareTimeline === 'function' ? userOnShareTimeline : (fallbackNoop as any)\n const effectiveOnAddToFavorites = (typeof userOnAddToFavorites === 'function' ? userOnAddToFavorites : (() => ({})) as any)\n\n return {\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n enableOnSaveExitState,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n }\n}\n"],"mappings":";AAEA,SAAgB,yBAAyB,SAYtC;CACD,MAAM,EACJ,UACA,qBACA,uBACA,mBACA,kBACA,iBACA,kBACA,cACA,uBACA,qBACA,yBACE;CAEJ,MAAM,0BAA0B,OAAO,0BAA0B,cAAc,QAAQ,SAAS,uBAAuB;CACvH,MAAM,sBAAsB,OAAO,sBAAsB,cAAc,QAAQ,SAAS,mBAAmB;CAC3G,MAAM,qBAAqB,OAAO,qBAAqB,cAAc,QAAQ,SAAS,kBAAkB;CACxG,MAAM,oBAAoB,OAAO,oBAAoB,cAAc,QAAQ,SAAS,iBAAiB;CACrG,MAAM,4BAA4B,QAAQ,SAAS,yBAAyB;CAC5E,MAAM,qBAAqB,OAAO,qBAAqB,cAAc,QAAQ,SAAS,kBAAkB;CACxG,MAAM,iBAAiB,OAAO,iBAAiB,cAAc,QAAQ,SAAS,cAAc;CAC5F,MAAM,wBAAwB,OAAO,wBAAwB,cAAc,QAAQ,SAAS,qBAAqB;CACjH,MAAM,0BAA0B,OAAO,0BAA0B,cAAc,QAAQ,SAAS,uBAAuB;CACvH,MAAM,yBAAyB,OAAO,yBAAyB,cAAc,QAAQ,SAAS,sBAAsB;CACpH,MAAM,wBAAwB,OAAO,wBAAwB,cAAc,QAAQ,SAAS,qBAAqB;CAEjH,MAAM,qBAAqB,CAAC;CAe5B,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,0BAzBgC,OAAO,wBAAwB,aAC7D,8BACQ,EAAE,MAAM,OAAU;EAwB5B,4BAvBiC,OAAO,0BAA0B,aAAa,wBAAwB;EAwBvG,wBAvB6B,OAAO,sBAAsB,aAAa,oBAAoB;EAwB3F,uBAvB4B,OAAO,qBAAqB,aAAa,mBAAmB;EAwBxF,sBAvB2B,OAAO,oBAAoB,aAAa,kBAAkB;EAwBrF,uBAvB4B,OAAO,qBAAqB,aAAa,mBAAmB;EAwBxF,mBAvBwB,OAAO,iBAAiB,aAAa,eAAe;EAwB5E,4BAvBiC,OAAO,0BAA0B,aAAa,wBAAyB;EAwBxG,0BAvB+B,OAAO,wBAAwB,aAAa,sBAAuB;EAwBlG,2BAvBiC,OAAO,yBAAyB,aAAa,+BAA+B,CAAC;CAwBhH;AACF"}
@@ -0,0 +1,64 @@
1
+ import { callHookList, callHookReturn } from "../../../hooks/base.mjs";
2
+ import { runInPageScrollHook } from "./platform.mjs";
3
+ import { WEVU_ROUTE_DONE_CALLED_KEY, WEVU_ROUTE_DONE_IN_TICK_KEY } from "@weapp-core/constants";
4
+
5
+ //#region src/runtime/register/component/lifecycle/optionalHooks.ts
6
+ function attachOptionalPageLifecycleHooks(pageLifecycleHooks, options) {
7
+ const { enableOnSaveExitState, enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites, hasHook } = options;
8
+ if (enableOnSaveExitState) pageLifecycleHooks.onSaveExitState = function onSaveExitState(...args) {
9
+ const ret = callHookReturn(this, "onSaveExitState", args);
10
+ if (ret !== void 0) return ret;
11
+ return effectiveOnSaveExitState.apply(this, args);
12
+ };
13
+ if (enableOnPullDownRefresh) pageLifecycleHooks.onPullDownRefresh = function onPullDownRefresh(...args) {
14
+ callHookList(this, "onPullDownRefresh", args);
15
+ if (!hasHook(this, "onPullDownRefresh")) return effectiveOnPullDownRefresh.apply(this, args);
16
+ };
17
+ if (enableOnReachBottom) pageLifecycleHooks.onReachBottom = function onReachBottom(...args) {
18
+ callHookList(this, "onReachBottom", args);
19
+ if (!hasHook(this, "onReachBottom")) return effectiveOnReachBottom.apply(this, args);
20
+ };
21
+ if (enableOnPageScroll) pageLifecycleHooks.onPageScroll = function onPageScroll(...args) {
22
+ return runInPageScrollHook(this, () => {
23
+ callHookList(this, "onPageScroll", args);
24
+ if (!hasHook(this, "onPageScroll")) return effectiveOnPageScroll.apply(this, args);
25
+ });
26
+ };
27
+ if (enableOnRouteDone) pageLifecycleHooks.onRouteDone = function onRouteDone(...args) {
28
+ if (this[WEVU_ROUTE_DONE_IN_TICK_KEY]) return;
29
+ this[WEVU_ROUTE_DONE_IN_TICK_KEY] = true;
30
+ Promise.resolve().then(() => {
31
+ this[WEVU_ROUTE_DONE_IN_TICK_KEY] = false;
32
+ });
33
+ this[WEVU_ROUTE_DONE_CALLED_KEY] = true;
34
+ callHookList(this, "onRouteDone", args);
35
+ if (!hasHook(this, "onRouteDone")) return effectiveOnRouteDone.apply(this, args);
36
+ };
37
+ if (enableOnTabItemTap) pageLifecycleHooks.onTabItemTap = function onTabItemTap(...args) {
38
+ callHookList(this, "onTabItemTap", args);
39
+ if (!hasHook(this, "onTabItemTap")) return effectiveOnTabItemTap.apply(this, args);
40
+ };
41
+ if (enableOnResize) pageLifecycleHooks.onResize = function onResize(...args) {
42
+ callHookList(this, "onResize", args);
43
+ if (!hasHook(this, "onResize")) return effectiveOnResize.apply(this, args);
44
+ };
45
+ if (enableOnShareAppMessage) pageLifecycleHooks.onShareAppMessage = function onShareAppMessage(...args) {
46
+ const ret = callHookReturn(this, "onShareAppMessage", args);
47
+ if (ret !== void 0) return ret;
48
+ return effectiveOnShareAppMessage.apply(this, args);
49
+ };
50
+ if (enableOnShareTimeline) pageLifecycleHooks.onShareTimeline = function onShareTimeline(...args) {
51
+ const ret = callHookReturn(this, "onShareTimeline", args);
52
+ if (ret !== void 0) return ret;
53
+ return effectiveOnShareTimeline.apply(this, args);
54
+ };
55
+ if (enableOnAddToFavorites) pageLifecycleHooks.onAddToFavorites = function onAddToFavorites(...args) {
56
+ const ret = callHookReturn(this, "onAddToFavorites", args);
57
+ if (ret !== void 0) return ret;
58
+ return effectiveOnAddToFavorites.apply(this, args);
59
+ };
60
+ }
61
+
62
+ //#endregion
63
+ export { attachOptionalPageLifecycleHooks };
64
+ //# sourceMappingURL=optionalHooks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionalHooks.mjs","names":[],"sources":["../../../../../../src/runtime/register/component/lifecycle/optionalHooks.ts"],"sourcesContent":["import type { InternalRuntimeState } from '../../../types'\nimport {\n WEVU_ROUTE_DONE_CALLED_KEY,\n WEVU_ROUTE_DONE_IN_TICK_KEY,\n} from '@weapp-core/constants'\nimport { callHookList, callHookReturn } from '../../../hooks'\nimport { runInPageScrollHook } from './platform'\n\nexport interface OptionalPageLifecycleHookOptions {\n enableOnSaveExitState: boolean\n enableOnPullDownRefresh: boolean\n enableOnReachBottom: boolean\n enableOnPageScroll: boolean\n enableOnRouteDone: boolean\n enableOnTabItemTap: boolean\n enableOnResize: boolean\n enableOnShareAppMessage: boolean\n enableOnShareTimeline: boolean\n enableOnAddToFavorites: boolean\n effectiveOnSaveExitState: (...args: any[]) => any\n effectiveOnPullDownRefresh: (...args: any[]) => any\n effectiveOnReachBottom: (...args: any[]) => any\n effectiveOnPageScroll: (...args: any[]) => any\n effectiveOnRouteDone: (...args: any[]) => any\n effectiveOnTabItemTap: (...args: any[]) => any\n effectiveOnResize: (...args: any[]) => any\n effectiveOnShareAppMessage: (...args: any[]) => any\n effectiveOnShareTimeline: (...args: any[]) => any\n effectiveOnAddToFavorites: (...args: any[]) => any\n hasHook: (target: InternalRuntimeState, name: string) => boolean\n}\n\nexport function attachOptionalPageLifecycleHooks(\n pageLifecycleHooks: Record<string, any>,\n options: OptionalPageLifecycleHookOptions,\n) {\n const {\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n } = options\n\n if (enableOnSaveExitState) {\n pageLifecycleHooks.onSaveExitState = function onSaveExitState(this: InternalRuntimeState, ...args: any[]) {\n const ret = callHookReturn(this, 'onSaveExitState', args)\n if (ret !== undefined) {\n return ret\n }\n return effectiveOnSaveExitState.apply(this, args)\n }\n }\n if (enableOnPullDownRefresh) {\n pageLifecycleHooks.onPullDownRefresh = function onPullDownRefresh(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onPullDownRefresh', args)\n if (!hasHook(this, 'onPullDownRefresh')) {\n return effectiveOnPullDownRefresh.apply(this, args)\n }\n }\n }\n if (enableOnReachBottom) {\n pageLifecycleHooks.onReachBottom = function onReachBottom(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onReachBottom', args)\n if (!hasHook(this, 'onReachBottom')) {\n return effectiveOnReachBottom.apply(this, args)\n }\n }\n }\n if (enableOnPageScroll) {\n pageLifecycleHooks.onPageScroll = function onPageScroll(this: InternalRuntimeState, ...args: any[]) {\n return runInPageScrollHook(this, () => {\n callHookList(this, 'onPageScroll', args)\n if (!hasHook(this, 'onPageScroll')) {\n return effectiveOnPageScroll.apply(this, args)\n }\n })\n }\n }\n if (enableOnRouteDone) {\n pageLifecycleHooks.onRouteDone = function onRouteDone(this: InternalRuntimeState, ...args: any[]) {\n if ((this as any)[WEVU_ROUTE_DONE_IN_TICK_KEY]) {\n return\n }\n ;(this as any)[WEVU_ROUTE_DONE_IN_TICK_KEY] = true\n Promise.resolve().then(() => {\n ;(this as any)[WEVU_ROUTE_DONE_IN_TICK_KEY] = false\n })\n ;(this as any)[WEVU_ROUTE_DONE_CALLED_KEY] = true\n callHookList(this, 'onRouteDone', args)\n if (!hasHook(this, 'onRouteDone')) {\n return effectiveOnRouteDone.apply(this, args)\n }\n }\n }\n if (enableOnTabItemTap) {\n pageLifecycleHooks.onTabItemTap = function onTabItemTap(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onTabItemTap', args)\n if (!hasHook(this, 'onTabItemTap')) {\n return effectiveOnTabItemTap.apply(this, args)\n }\n }\n }\n if (enableOnResize) {\n pageLifecycleHooks.onResize = function onResize(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onResize', args)\n if (!hasHook(this, 'onResize')) {\n return effectiveOnResize.apply(this, args)\n }\n }\n }\n if (enableOnShareAppMessage) {\n pageLifecycleHooks.onShareAppMessage = function onShareAppMessage(this: InternalRuntimeState, ...args: any[]) {\n const ret = callHookReturn(this, 'onShareAppMessage', args)\n if (ret !== undefined) {\n return ret\n }\n return effectiveOnShareAppMessage.apply(this, args)\n }\n }\n if (enableOnShareTimeline) {\n pageLifecycleHooks.onShareTimeline = function onShareTimeline(this: InternalRuntimeState, ...args: any[]) {\n const ret = callHookReturn(this, 'onShareTimeline', args)\n if (ret !== undefined) {\n return ret\n }\n return effectiveOnShareTimeline.apply(this, args)\n }\n }\n if (enableOnAddToFavorites) {\n pageLifecycleHooks.onAddToFavorites = function onAddToFavorites(this: InternalRuntimeState, ...args: any[]) {\n const ret = callHookReturn(this, 'onAddToFavorites', args)\n if (ret !== undefined) {\n return ret\n }\n return effectiveOnAddToFavorites.apply(this, args)\n }\n }\n}\n"],"mappings":";;;;;AAgCA,SAAgB,iCACd,oBACA,SACA;CACA,MAAM,EACJ,uBACA,yBACA,qBACA,oBACA,mBACA,oBACA,gBACA,yBACA,uBACA,wBACA,0BACA,4BACA,wBACA,uBACA,sBACA,uBACA,m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GAC/B,OAAO,sBAAsB,MAAM,MAAM,IAAI;CAEjD;CAEF,IAAI,gBACF,mBAAmB,WAAW,SAAS,SAAqC,GAAG,MAAa;EAC1F,aAAa,MAAM,YAAY,IAAI;EACnC,IAAI,CAAC,QAAQ,MAAM,UAAU,GAC3B,OAAO,kBAAkB,MAAM,MAAM,IAAI;CAE7C;CAEF,IAAI,yBACF,mBAAmB,oBAAoB,SAAS,kBAA8C,GAAG,MAAa;EAC5G,MAAM,MAAM,eAAe,MAAM,qBAAqB,IAAI;EAC1D,IAAI,QAAQ,QACV,OAAO;EAET,OAAO,2BAA2B,MAAM,MAAM,IAAI;CACpD;CAEF,IAAI,uBACF,mBAAmB,kBAAkB,SAAS,gBAA4C,GAAG,MAAa;EACxG,MAAM,MAAM,eAAe,MAAM,mBAAmB,IAAI;EACxD,IAAI,QAAQ,QACV,OAAO;EAET,OAAO,yBAAyB,MAAM,MAAM,IAAI;CAClD;CAEF,IAAI,wBACF,mBAAmB,mBAAmB,SAAS,iBAA6C,GAAG,MAAa;EAC1G,MAAM,MAAM,eAAe,MAAM,oBAAoB,IAAI;EACzD,IAAI,QAAQ,QACV,OAAO;EAET,OAAO,0BAA0B,MAAM,MAAM,IAAI;CACnD;AAEJ"}
@@ -0,0 +1,95 @@
1
+ import { getCurrentMiniProgramPages, getCurrentMiniProgramRuntimeCapabilities, getMiniProgramGlobalObject, supportsCurrentMiniProgramRuntimeCapability } from "../../../platform.mjs";
2
+ import { callHookList } from "../../../hooks/base.mjs";
3
+ import { WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY } from "@weapp-core/constants";
4
+
5
+ //#region src/runtime/register/component/lifecycle/platform.ts
6
+ let miniProgramGlobalPatched = false;
7
+ let currentPageInstance;
8
+ function getCurrentPageInstance() {
9
+ return currentPageInstance;
10
+ }
11
+ function bindCurrentPageInstance(target) {
12
+ currentPageInstance = target;
13
+ }
14
+ function releaseCurrentPageInstance(target) {
15
+ if (currentPageInstance === target) currentPageInstance = void 0;
16
+ }
17
+ function runInPageScrollHook(target, task) {
18
+ var _WEVU_PAGE_SCROLL_HOO;
19
+ target[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] = Number((_WEVU_PAGE_SCROLL_HOO = target[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY]) !== null && _WEVU_PAGE_SCROLL_HOO !== void 0 ? _WEVU_PAGE_SCROLL_HOO : 0) + 1;
20
+ try {
21
+ return task();
22
+ } finally {
23
+ var _WEVU_PAGE_SCROLL_HOO2;
24
+ const nextDepth = Number((_WEVU_PAGE_SCROLL_HOO2 = target[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY]) !== null && _WEVU_PAGE_SCROLL_HOO2 !== void 0 ? _WEVU_PAGE_SCROLL_HOO2 : 1) - 1;
25
+ if (nextDepth <= 0) delete target[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY];
26
+ else target[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] = nextDepth;
27
+ }
28
+ }
29
+ function resolvePageOptions(target) {
30
+ const direct = target.options;
31
+ if (direct && typeof direct === "object") return direct;
32
+ const pages = getCurrentMiniProgramPages();
33
+ const page = pages[pages.length - 1];
34
+ const options = page && typeof page === "object" ? page.options : void 0;
35
+ if (options && typeof options === "object") return options;
36
+ return {};
37
+ }
38
+ function ensureMiniProgramGlobalPatched() {
39
+ if (miniProgramGlobalPatched) return;
40
+ miniProgramGlobalPatched = true;
41
+ const miniProgramGlobal = getMiniProgramGlobalObject();
42
+ if (!miniProgramGlobal || typeof miniProgramGlobal !== "object") return;
43
+ if (supportsCurrentMiniProgramRuntimeCapability("pullDownRefreshApi")) {
44
+ const rawStartPullDownRefresh = miniProgramGlobal.startPullDownRefresh;
45
+ if (typeof rawStartPullDownRefresh === "function") miniProgramGlobal.startPullDownRefresh = function startPullDownRefreshPatched(...args) {
46
+ const result = rawStartPullDownRefresh.apply(this, args);
47
+ if (currentPageInstance) callHookList(currentPageInstance, "onPullDownRefresh", []);
48
+ return result;
49
+ };
50
+ }
51
+ if (supportsCurrentMiniProgramRuntimeCapability("pageScrollApi")) {
52
+ const rawPageScrollTo = miniProgramGlobal.pageScrollTo;
53
+ if (typeof rawPageScrollTo === "function") miniProgramGlobal.pageScrollTo = function pageScrollToPatched(options, ...rest) {
54
+ const result = rawPageScrollTo.apply(this, [options, ...rest]);
55
+ if (currentPageInstance) {
56
+ const pageInstance = currentPageInstance;
57
+ runInPageScrollHook(pageInstance, () => {
58
+ callHookList(pageInstance, "onPageScroll", [options !== null && options !== void 0 ? options : {}]);
59
+ });
60
+ }
61
+ return result;
62
+ };
63
+ }
64
+ }
65
+ function ensurePageShareMenus(options) {
66
+ const { enableOnShareAppMessage, enableOnShareTimeline } = options;
67
+ if (!enableOnShareAppMessage && !enableOnShareTimeline) return;
68
+ if (!supportsCurrentMiniProgramRuntimeCapability("pageShareMenu")) return;
69
+ const miniProgramGlobal = getMiniProgramGlobalObject();
70
+ if (!miniProgramGlobal || typeof miniProgramGlobal.showShareMenu !== "function") return;
71
+ const shouldShowShareAppMessage = getCurrentMiniProgramRuntimeCapabilities().shareTimelineRequiresShareAppMessage ? enableOnShareAppMessage || enableOnShareTimeline : enableOnShareAppMessage;
72
+ if (!shouldShowShareAppMessage && !enableOnShareTimeline) return;
73
+ const menus = [];
74
+ if (shouldShowShareAppMessage) menus.push("shareAppMessage");
75
+ if (enableOnShareTimeline) menus.push("shareTimeline");
76
+ const payloads = [
77
+ {
78
+ withShareTicket: true,
79
+ menus
80
+ },
81
+ { menus },
82
+ enableOnShareTimeline ? { withShareTicket: true } : void 0,
83
+ enableOnShareTimeline ? {} : void 0,
84
+ void 0
85
+ ];
86
+ for (const payload of payloads) try {
87
+ if (payload === void 0) miniProgramGlobal.showShareMenu();
88
+ else miniProgramGlobal.showShareMenu(payload);
89
+ break;
90
+ } catch (_unused) {}
91
+ }
92
+
93
+ //#endregion
94
+ export { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, getCurrentPageInstance, releaseCurrentPageInstance, resolvePageOptions, runInPageScrollHook };
95
+ //# sourceMappingURL=platform.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.mjs","names":[],"sources":["../../../../../../src/runtime/register/component/lifecycle/platform.ts"],"sourcesContent":["import type { InternalRuntimeState } from '../../../types'\nimport { WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY } from '@weapp-core/constants'\nimport { callHookList } from '../../../hooks'\nimport {\n getCurrentMiniProgramPages,\n getCurrentMiniProgramRuntimeCapabilities,\n getMiniProgramGlobalObject,\n supportsCurrentMiniProgramRuntimeCapability,\n} from '../../../platform'\n\nlet miniProgramGlobalPatched = false\nlet currentPageInstance: InternalRuntimeState | undefined\ntype ShareMenuName = 'shareAppMessage' | 'shareTimeline'\nexport function getCurrentPageInstance() {\n return currentPageInstance\n}\n\nexport function bindCurrentPageInstance(target: InternalRuntimeState) {\n currentPageInstance = target\n}\n\nexport function releaseCurrentPageInstance(target: InternalRuntimeState) {\n if (currentPageInstance === target) {\n currentPageInstance = undefined\n }\n}\n\nexport function runInPageScrollHook<T>(\n target: InternalRuntimeState,\n task: () => T,\n): T {\n const currentDepth = Number((target as any)[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] ?? 0)\n ;(target as any)[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] = currentDepth + 1\n try {\n return task()\n }\n finally {\n const nextDepth = Number((target as any)[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] ?? 1) - 1\n if (nextDepth <= 0) {\n delete (target as any)[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY]\n }\n else {\n ;(target as any)[WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY] = nextDepth\n }\n }\n}\n\nexport function resolvePageOptions(target: InternalRuntimeState) {\n const direct = (target as any).options\n if (direct && typeof direct === 'object') {\n return direct\n }\n const pages = getCurrentMiniProgramPages()\n const page = pages[pages.length - 1]\n const options = page && typeof page === 'object' ? (page as any).options : undefined\n if (options && typeof options === 'object') {\n return options\n }\n return {}\n}\n\nexport function ensureMiniProgramGlobalPatched() {\n if (miniProgramGlobalPatched) {\n return\n }\n miniProgramGlobalPatched = true\n const miniProgramGlobal = getMiniProgramGlobalObject()\n if (!miniProgramGlobal || typeof miniProgramGlobal !== 'object') {\n return\n }\n if (supportsCurrentMiniProgramRuntimeCapability('pullDownRefreshApi')) {\n const rawStartPullDownRefresh = miniProgramGlobal.startPullDownRefresh as ((...args: any[]) => any) | undefined\n if (typeof rawStartPullDownRefresh === 'function') {\n miniProgramGlobal.startPullDownRefresh = function startPullDownRefreshPatched(...args: any[]) {\n const result = rawStartPullDownRefresh.apply(this, args)\n if (currentPageInstance) {\n callHookList(currentPageInstance, 'onPullDownRefresh', [])\n }\n return result\n }\n }\n }\n if (supportsCurrentMiniProgramRuntimeCapability('pageScrollApi')) {\n const rawPageScrollTo = miniProgramGlobal.pageScrollTo as ((...args: any[]) => any) | undefined\n if (typeof rawPageScrollTo === 'function') {\n miniProgramGlobal.pageScrollTo = function pageScrollToPatched(options: any, ...rest: any[]) {\n const result = rawPageScrollTo.apply(this, [options, ...rest])\n if (currentPageInstance) {\n const pageInstance = currentPageInstance\n runInPageScrollHook(pageInstance, () => {\n callHookList(pageInstance, 'onPageScroll', [options ?? {}])\n })\n }\n return result\n }\n }\n }\n}\n\nexport function ensurePageShareMenus(options: {\n enableOnShareAppMessage: boolean\n enableOnShareTimeline: boolean\n}) {\n const { enableOnShareAppMessage, enableOnShareTimeline } = options\n if (!enableOnShareAppMessage && !enableOnShareTimeline) {\n return\n }\n\n if (!supportsCurrentMiniProgramRuntimeCapability('pageShareMenu')) {\n return\n }\n\n const miniProgramGlobal = getMiniProgramGlobalObject()\n if (!miniProgramGlobal || typeof miniProgramGlobal.showShareMenu !== 'function') {\n return\n }\n\n const runtimeCapabilities = getCurrentMiniProgramRuntimeCapabilities()\n const shouldShowShareAppMessage = runtimeCapabilities.shareTimelineRequiresShareAppMessage\n ? (enableOnShareAppMessage || enableOnShareTimeline)\n : enableOnShareAppMessage\n\n if (!shouldShowShareAppMessage && !enableOnShareTimeline) {\n return\n }\n\n const menus: ShareMenuName[] = []\n if (shouldShowShareAppMessage) {\n menus.push('shareAppMessage')\n }\n if (enableOnShareTimeline) {\n menus.push('shareTimeline')\n }\n\n const payloads = [\n { withShareTicket: true, menus },\n { menus },\n enableOnShareTimeline ? { withShareTicket: true } : undefined,\n enableOnShareTimeline ? {} : undefined,\n undefined,\n ]\n\n for (const payload of payloads) {\n try {\n if (payload === undefined) {\n miniProgramGlobal.showShareMenu()\n }\n else {\n miniProgramGlobal.showShareMenu(payload as any)\n }\n break\n }\n catch {\n // 继续尝试更保守的 payload,兼容不同宿主的 showShareMenu 参数形态。\n }\n }\n}\n"],"mappings":";;;;;AAUA,IAAI,2BAA2B;AAC/B,IAAI;AAEJ,SAAgB,yBAAyB;CACvC,OAAO;AACT;AAEA,SAAgB,wBAAwB,QAA8B;CACpE,sBAAsB;AACxB;AAEA,SAAgB,2BAA2B,QAA8B;CACvE,IAAI,wBAAwB,QAC1B,sBAAsB;AAE1B;AAEA,SAAgB,oBACd,QACA,MACG;;CAEF,AAAC,OAAe,mCADI,gCAAQ,OAAe,yGAAoC,CACjB,IAAI;CACnE,IAAI;EACF,OAAO,KAAK;CACd,UACQ;;EACN,MAAM,YAAY,iCAAQ,OAAe,2GAAoC,CAAC,IAAI;EAClF,IAAI,aAAa,GACf,OAAQ,OAAe;OAGtB,AAAC,OAAe,mCAAmC;CAExD;AACF;AAEA,SAAgB,mBAAmB,QAA8B;CAC/D,MAAM,SAAU,OAAe;CAC/B,IAAI,UAAU,OAAO,WAAW,UAC9B,OAAO;CAET,MAAM,QAAQ,2BAA2B;CACzC,MAAM,OAAO,MAAM,MAAM,SAAS;CAClC,MAAM,UAAU,QAAQ,OAAO,SAAS,WAAY,KAAa,UAAU;CAC3E,IAAI,WAAW,OAAO,YAAY,UAChC,OAAO;CAET,OAAO,CAAC;AACV;AAEA,SAAgB,iCAAiC;CAC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EAC/B,EAAE,MAAM;EACR,wBAAwB,EAAE,iBAAiB,KAAK,IAAI;EACpD,wBAAwB,CAAC,IAAI;EAC7B;CACF;CAEA,KAAK,MAAM,WAAW,UACpB,IAAI;EACF,IAAI,YAAY,QACd,kBAAkB,cAAc;OAGhC,kBAAkB,cAAc,OAAc;EAEhD;CACF,kBACM,CAEN;AAEJ"}
@@ -0,0 +1,122 @@
1
+ import { callHookList } from "../../hooks/base.mjs";
2
+ import { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, releaseCurrentPageInstance, resolvePageOptions } from "./lifecycle/platform.mjs";
3
+ import { scheduleTemplateRefUpdate } from "../../templateRefs.mjs";
4
+ import { enableDeferredSetData, mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from "../runtimeInstance.mjs";
5
+ import { notifyRouteStateSync } from "../../../router/routeSync.mjs";
6
+ import { attachOptionalPageLifecycleHooks } from "./lifecycle/optionalHooks.mjs";
7
+ import { WEVU_ON_LOAD_CALLED_KEY, WEVU_READY_CALLED_KEY, WEVU_ROUTE_DONE_CALLED_KEY } from "@weapp-core/constants";
8
+
9
+ //#region src/runtime/register/component/lifecycle.ts
10
+ function createPageLifecycleHooks(options) {
11
+ const { runtimeApp, watch, setup, userOnLoad, userOnUnload, userOnShow, userOnHide, userOnReady, isPage, enableOnSaveExitState, enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnRouteDoneFallback, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, syncWevuPropsFromValues, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites, hasHook } = options;
12
+ const flushPageSnapshotIfPossible = (target) => {
13
+ var _wevu, _wevu$__wevu_flushSet;
14
+ (_wevu = target.__wevu) === null || _wevu === void 0 || (_wevu$__wevu_flushSet = _wevu.__wevu_flushSetupSnapshotSync) === null || _wevu$__wevu_flushSet === void 0 || _wevu$__wevu_flushSet.call(_wevu);
15
+ };
16
+ const pageLifecycleHooks = {
17
+ onLoad(...args) {
18
+ if (this[WEVU_ON_LOAD_CALLED_KEY]) return;
19
+ this[WEVU_ON_LOAD_CALLED_KEY] = true;
20
+ mountRuntimeInstance(this, runtimeApp, watch, setup);
21
+ const pageOptions = args[0] && typeof args[0] === "object" ? args[0] : resolvePageOptions(this);
22
+ syncWevuPropsFromValues === null || syncWevuPropsFromValues === void 0 || syncWevuPropsFromValues(this, pageOptions);
23
+ flushPageSnapshotIfPossible(this);
24
+ enableDeferredSetData(this);
25
+ if (isPage) ensurePageShareMenus({
26
+ enableOnShareAppMessage,
27
+ enableOnShareTimeline
28
+ });
29
+ callHookList(this, "onLoad", args);
30
+ if (typeof userOnLoad === "function") return userOnLoad.apply(this, args.length ? args : [pageOptions]);
31
+ },
32
+ onUnload(...args) {
33
+ if (isPage) releaseCurrentPageInstance(this);
34
+ teardownRuntimeInstance(this);
35
+ if (typeof userOnUnload === "function") return userOnUnload.apply(this, args);
36
+ },
37
+ onShow(...args) {
38
+ if (isPage) {
39
+ ensureMiniProgramGlobalPatched();
40
+ bindCurrentPageInstance(this);
41
+ if (!this[WEVU_ON_LOAD_CALLED_KEY]) pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this));
42
+ syncWevuPropsFromValues === null || syncWevuPropsFromValues === void 0 || syncWevuPropsFromValues(this, resolvePageOptions(this));
43
+ flushPageSnapshotIfPossible(this);
44
+ ensurePageShareMenus({
45
+ enableOnShareAppMessage,
46
+ enableOnShareTimeline
47
+ });
48
+ this[WEVU_ROUTE_DONE_CALLED_KEY] = false;
49
+ }
50
+ setRuntimeSetDataVisibility(this, true);
51
+ if (isPage) notifyRouteStateSync({
52
+ page: this,
53
+ source: "page"
54
+ });
55
+ callHookList(this, "onShow", args);
56
+ if (typeof userOnShow === "function") return userOnShow.apply(this, args);
57
+ },
58
+ onHide(...args) {
59
+ if (isPage) releaseCurrentPageInstance(this);
60
+ setRuntimeSetDataVisibility(this, false);
61
+ callHookList(this, "onHide", args);
62
+ if (typeof userOnHide === "function") return userOnHide.apply(this, args);
63
+ },
64
+ onReady(...args) {
65
+ if (isPage) {
66
+ if (!this[WEVU_ON_LOAD_CALLED_KEY]) pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this));
67
+ syncWevuPropsFromValues === null || syncWevuPropsFromValues === void 0 || syncWevuPropsFromValues(this, resolvePageOptions(this));
68
+ flushPageSnapshotIfPossible(this);
69
+ ensurePageShareMenus({
70
+ enableOnShareAppMessage,
71
+ enableOnShareTimeline
72
+ });
73
+ }
74
+ if (!this[WEVU_READY_CALLED_KEY]) {
75
+ this[WEVU_READY_CALLED_KEY] = true;
76
+ if (isPage && enableOnRouteDone && enableOnRouteDoneFallback) {
77
+ const current = this;
78
+ setTimeout(() => {
79
+ if (!current[WEVU_ROUTE_DONE_CALLED_KEY]) {
80
+ var _pageLifecycleHooks$o;
81
+ (_pageLifecycleHooks$o = pageLifecycleHooks.onRouteDone) === null || _pageLifecycleHooks$o === void 0 || _pageLifecycleHooks$o.call(current);
82
+ }
83
+ }, 0);
84
+ }
85
+ scheduleTemplateRefUpdate(this, () => {
86
+ callHookList(this, "onReady", args);
87
+ if (typeof userOnReady === "function") userOnReady.apply(this, args);
88
+ });
89
+ return;
90
+ }
91
+ if (typeof userOnReady === "function") return userOnReady.apply(this, args);
92
+ }
93
+ };
94
+ attachOptionalPageLifecycleHooks(pageLifecycleHooks, {
95
+ enableOnSaveExitState,
96
+ enableOnPullDownRefresh,
97
+ enableOnReachBottom,
98
+ enableOnPageScroll,
99
+ enableOnRouteDone,
100
+ enableOnTabItemTap,
101
+ enableOnResize,
102
+ enableOnShareAppMessage,
103
+ enableOnShareTimeline,
104
+ enableOnAddToFavorites,
105
+ effectiveOnSaveExitState,
106
+ effectiveOnPullDownRefresh,
107
+ effectiveOnReachBottom,
108
+ effectiveOnPageScroll,
109
+ effectiveOnRouteDone,
110
+ effectiveOnTabItemTap,
111
+ effectiveOnResize,
112
+ effectiveOnShareAppMessage,
113
+ effectiveOnShareTimeline,
114
+ effectiveOnAddToFavorites,
115
+ hasHook
116
+ });
117
+ return pageLifecycleHooks;
118
+ }
119
+
120
+ //#endregion
121
+ export { createPageLifecycleHooks };
122
+ //# sourceMappingURL=lifecycle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.mjs","names":[],"sources":["../../../../../src/runtime/register/component/lifecycle.ts"],"sourcesContent":["import type { MiniProgramPageLike } from '../../../routerInternal/shared'\nimport type { ComponentPropsOptions, ComputedDefinitions, DefineComponentOptions, InternalRuntimeState, MethodDefinitions, RuntimeApp } from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEVU_ON_LOAD_CALLED_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_ROUTE_DONE_CALLED_KEY,\n} from '@weapp-core/constants'\nimport { notifyRouteStateSync } from '../../../router/routeSync'\nimport { callHookList } from '../../hooks'\nimport { scheduleTemplateRefUpdate } from '../../templateRefs'\nimport { enableDeferredSetData, mountRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { attachOptionalPageLifecycleHooks } from './lifecycle/optionalHooks'\nimport { bindCurrentPageInstance, ensureMiniProgramGlobalPatched, ensurePageShareMenus, releaseCurrentPageInstance, resolvePageOptions } from './lifecycle/platform'\n\nexport function createPageLifecycleHooks<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n userOnLoad?: any\n userOnUnload?: any\n userOnShow?: any\n userOnHide?: any\n userOnReady?: any\n isPage: boolean\n enableOnSaveExitState: boolean\n enableOnPullDownRefresh: boolean\n enableOnReachBottom: boolean\n enableOnPageScroll: boolean\n enableOnRouteDone: boolean\n enableOnRouteDoneFallback: boolean\n enableOnTabItemTap: boolean\n enableOnResize: boolean\n enableOnShareAppMessage: boolean\n enableOnShareTimeline: boolean\n enableOnAddToFavorites: boolean\n syncWevuPropsFromValues?: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n effectiveOnSaveExitState: (...args: any[]) => any\n effectiveOnPullDownRefresh: (...args: any[]) => any\n effectiveOnReachBottom: (...args: any[]) => any\n effectiveOnPageScroll: (...args: any[]) => any\n effectiveOnRouteDone: (...args: any[]) => any\n effectiveOnTabItemTap: (...args: any[]) => any\n effectiveOnResize: (...args: any[]) => any\n effectiveOnShareAppMessage: (...args: any[]) => any\n effectiveOnShareTimeline: (...args: any[]) => any\n effectiveOnAddToFavorites: (...args: any[]) => any\n hasHook: (target: InternalRuntimeState, name: string) => boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n userOnLoad,\n userOnUnload,\n userOnShow,\n userOnHide,\n userOnReady,\n isPage,\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnRouteDoneFallback,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n syncWevuPropsFromValues,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n } = options\n const flushPageSnapshotIfPossible = (target: InternalRuntimeState) => {\n ;(target as any).__wevu?.__wevu_flushSetupSnapshotSync?.()\n }\n\n const pageLifecycleHooks: Record<string, any> = {\n onLoad(this: InternalRuntimeState, ...args: any[]) {\n if ((this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n return\n }\n ;(this as any)[WEVU_ON_LOAD_CALLED_KEY] = true\n mountRuntimeInstance(this, runtimeApp, watch, setup)\n const pageOptions = args[0] && typeof args[0] === 'object'\n ? args[0]\n : resolvePageOptions(this)\n syncWevuPropsFromValues?.(this, pageOptions)\n flushPageSnapshotIfPossible(this)\n enableDeferredSetData(this)\n if (isPage) {\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n callHookList(this, 'onLoad', args)\n if (typeof userOnLoad === 'function') {\n return userOnLoad.apply(this, args.length ? args : [pageOptions])\n }\n },\n onUnload(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n teardownRuntimeInstance(this)\n if (typeof userOnUnload === 'function') {\n return userOnUnload.apply(this, args)\n }\n },\n onShow(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n ensureMiniProgramGlobalPatched()\n bindCurrentPageInstance(this)\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n ;(this as any)[WEVU_ROUTE_DONE_CALLED_KEY] = false\n }\n setRuntimeSetDataVisibility(this, true)\n if (isPage) {\n notifyRouteStateSync({\n page: this as MiniProgramPageLike,\n source: 'page',\n })\n }\n callHookList(this, 'onShow', args)\n if (typeof userOnShow === 'function') {\n return userOnShow.apply(this, args)\n }\n },\n onHide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n releaseCurrentPageInstance(this)\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof userOnHide === 'function') {\n return userOnHide.apply(this, args)\n }\n },\n onReady(this: InternalRuntimeState, ...args: any[]) {\n if (isPage) {\n if (!(this as any)[WEVU_ON_LOAD_CALLED_KEY]) {\n pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this))\n }\n syncWevuPropsFromValues?.(this, resolvePageOptions(this))\n flushPageSnapshotIfPossible(this)\n ensurePageShareMenus({\n enableOnShareAppMessage,\n enableOnShareTimeline,\n })\n }\n // 兼容:部分平台/模式可能触发 Page.onReady,而非 Component lifetimes.ready\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n // 部分 IDE/基础库在首屏场景可能不派发 routeDone,这里做一次延迟兜底。\n // 若平台随后派发了真实 routeDone,会因为 __wevuRouteDoneCalled 判定而跳过补发。\n if (isPage && enableOnRouteDone && enableOnRouteDoneFallback) {\n // eslint-disable-next-line ts/no-this-alias\n const current = this\n setTimeout(() => {\n if (!(current as any)[WEVU_ROUTE_DONE_CALLED_KEY]) {\n pageLifecycleHooks.onRouteDone?.call(current)\n }\n }, 0)\n }\n scheduleTemplateRefUpdate(this, () => {\n callHookList(this, 'onReady', args)\n if (typeof userOnReady === 'function') {\n userOnReady.apply(this, args)\n }\n })\n return\n }\n if (typeof userOnReady === 'function') {\n return userOnReady.apply(this, args)\n }\n },\n }\n\n attachOptionalPageLifecycleHooks(pageLifecycleHooks, {\n enableOnSaveExitState,\n enableOnPullDownRefresh,\n enableOnReachBottom,\n enableOnPageScroll,\n enableOnRouteDone,\n enableOnTabItemTap,\n enableOnResize,\n enableOnShareAppMessage,\n enableOnShareTimeline,\n enableOnAddToFavorites,\n effectiveOnSaveExitState,\n effectiveOnPullDownRefresh,\n effectiveOnReachBottom,\n effectiveOnPageScroll,\n effectiveOnRouteDone,\n effectiveOnTabItemTap,\n effectiveOnResize,\n effectiveOnShareAppMessage,\n effectiveOnShareTimeline,\n effectiveOnAddToFavorites,\n hasHook,\n })\n\n return pageLifecycleHooks\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,yBAAuG,SAiCpH;CACD,MAAM,EACJ,YACA,OACA,OACA,YACA,cACA,YACA,YACA,aACA,QACA,uBACA,yBACA,qBACA,oBACA,mBACA,2BACA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AAM,MAAM,IAAI;EAEtC;EACA,OAAmC,GAAG,MAAa;GACjD,IAAI,QACF,2BAA2B,IAAI;GAEjC,4BAA4B,MAAM,KAAK;GACvC,aAAa,MAAM,UAAU,IAAI;GACjC,IAAI,OAAO,eAAe,YACxB,OAAO,WAAW,MAAM,MAAM,IAAI;EAEtC;EACA,QAAoC,GAAG,MAAa;GAClD,IAAI,QAAQ;IACV,IAAI,CAAE,KAAa,0BACjB,mBAAmB,OAAO,KAAK,MAAM,mBAAmB,IAAI,CAAC;IAE/D,kGAA0B,MAAM,mBAAmB,IAAI,CAAC;IACxD,4BAA4B,IAAI;IAChC,qBAAqB;KACnB;KACA;IACF,CAAC;GACH;GAEA,IAAI,CAAE,KAAa,wBAAwB;IACxC,AAAC,KAAa,yBAAyB;IAGxC,IAAI,UAAU,qBAAqB,2BAA2B;KAE5D,MAAM,UAAU;KAChB,iBAAiB;MACf,IAAI,CAAE,QAAgB,6BAA6B;;OACjD,4CAAmB,mFAAa,KAAK,OAAO;MAC9C;KACF,GAAG,CAAC;IACN;IACA,0BAA0B,YAAY;KACpC,aAAa,MAAM,WAAW,IAAI;KAClC,IAAI,OAAO,gBAAgB,YACzB,YAAY,MAAM,MAAM,IAAI;IAEhC,CAAC;IACD;GACF;GACA,IAAI,OAAO,gBAAgB,YACzB,OAAO,YAAY,MAAM,MAAM,IAAI;EAEvC;CACF;CAEA,iCAAiC,oBAAoB;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO;AACT"}
@@ -0,0 +1,80 @@
1
+ import { parseModelEventValue } from "../../internal.mjs";
2
+ import { runInlineExpression } from "../inline.mjs";
3
+ import { WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_MODEL_HANDLER, WEVU_NATIVE_INSTANCE_KEY, WEVU_OWNER_HANDLER, WEVU_RESERVED_METHOD_PREFIX, WEVU_RUNTIME_KEY } from "@weapp-core/constants";
4
+
5
+ //#region src/runtime/register/component/methods.ts
6
+ function createComponentMethods(options) {
7
+ const { userMethods, runtimeMethods } = options;
8
+ const finalMethods = { ...userMethods };
9
+ if (!finalMethods[WEVU_INLINE_HANDLER]) finalMethods[WEVU_INLINE_HANDLER] = function __weapp_vite_inline(event) {
10
+ var _runtime$proxy, _runtime$methods;
11
+ const runtime = this.__wevu;
12
+ return runInlineExpression((_runtime$proxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy) !== null && _runtime$proxy !== void 0 ? _runtime$proxy : this, void 0, event, runtime === null || runtime === void 0 || (_runtime$methods = runtime.methods) === null || _runtime$methods === void 0 ? void 0 : _runtime$methods[WEVU_INLINE_MAP_KEY]);
13
+ };
14
+ if (!finalMethods[WEVU_MODEL_HANDLER]) finalMethods[WEVU_MODEL_HANDLER] = function __weapp_vite_model(event) {
15
+ var _event$currentTarget$, _event$currentTarget, _event$target;
16
+ const path = (_event$currentTarget$ = event === null || event === void 0 || (_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || (_event$currentTarget = _event$currentTarget.dataset) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.wvModel) !== null && _event$currentTarget$ !== void 0 ? _event$currentTarget$ : event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 || (_event$target = _event$target.dataset) === null || _event$target === void 0 ? void 0 : _event$target.wvModel;
17
+ if (typeof path !== "string" || !path) return;
18
+ const runtime = this.__wevu;
19
+ if (!runtime || typeof runtime.bindModel !== "function") return;
20
+ const value = parseModelEventValue(event);
21
+ try {
22
+ runtime.bindModel(path).update(value);
23
+ } catch (_unused) {}
24
+ };
25
+ if (!finalMethods[WEVU_OWNER_HANDLER] && typeof (runtimeMethods === null || runtimeMethods === void 0 ? void 0 : runtimeMethods[WEVU_OWNER_HANDLER]) === "function") finalMethods[WEVU_OWNER_HANDLER] = runtimeMethods[WEVU_OWNER_HANDLER];
26
+ const methodNames = Object.keys(runtimeMethods !== null && runtimeMethods !== void 0 ? runtimeMethods : {});
27
+ function resolveRuntime(instance) {
28
+ const directRuntime = instance.__wevu;
29
+ if (directRuntime) return directRuntime;
30
+ const runtimeState = instance.$state;
31
+ if (runtimeState && typeof runtimeState === "object") return runtimeState[WEVU_RUNTIME_KEY];
32
+ }
33
+ function syncRuntimeNativeInstance(runtime, instance) {
34
+ if ((runtime === null || runtime === void 0 ? void 0 : runtime.proxy) === instance) return;
35
+ const runtimeProxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy;
36
+ const isBridgeMethod = (methodName) => {
37
+ const instanceMethod = instance[methodName];
38
+ if (typeof instanceMethod !== "function") return false;
39
+ const proxyMethod = runtimeProxy === null || runtimeProxy === void 0 ? void 0 : runtimeProxy[methodName];
40
+ return typeof proxyMethod === "function" && instanceMethod === proxyMethod;
41
+ };
42
+ if (isBridgeMethod("triggerEvent") || isBridgeMethod("createSelectorQuery") || isBridgeMethod("createIntersectionObserver") || isBridgeMethod("setData")) return;
43
+ if (!(typeof instance.triggerEvent === "function" || typeof instance.createSelectorQuery === "function" || typeof instance.createIntersectionObserver === "function" || typeof instance.setData === "function")) return;
44
+ const runtimeState = runtime === null || runtime === void 0 ? void 0 : runtime.state;
45
+ if (!runtimeState || typeof runtimeState !== "object") return;
46
+ if (instance.$state === runtimeState) return;
47
+ try {
48
+ Object.defineProperty(runtimeState, WEVU_NATIVE_INSTANCE_KEY, {
49
+ value: instance,
50
+ configurable: true,
51
+ enumerable: false,
52
+ writable: true
53
+ });
54
+ } catch (_unused2) {
55
+ runtimeState[WEVU_NATIVE_INSTANCE_KEY] = instance;
56
+ }
57
+ }
58
+ for (const methodName of methodNames) {
59
+ if (methodName === WEVU_INLINE_MAP_KEY || methodName.startsWith(WEVU_RESERVED_METHOD_PREFIX)) continue;
60
+ const userMethod = finalMethods[methodName];
61
+ finalMethods[methodName] = function componentMethod(...args) {
62
+ var _runtime$methods2;
63
+ const runtime = resolveRuntime(this);
64
+ syncRuntimeNativeInstance(runtime, this);
65
+ let result;
66
+ const bound = runtime === null || runtime === void 0 || (_runtime$methods2 = runtime.methods) === null || _runtime$methods2 === void 0 ? void 0 : _runtime$methods2[methodName];
67
+ if (bound) result = bound.apply(runtime.proxy, args);
68
+ if (typeof userMethod === "function") {
69
+ const userResult = userMethod.apply(this, args);
70
+ return userResult === void 0 ? result : userResult;
71
+ }
72
+ return result;
73
+ };
74
+ }
75
+ return { finalMethods };
76
+ }
77
+
78
+ //#endregion
79
+ export { createComponentMethods };
80
+ //# sourceMappingURL=methods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.mjs","names":[],"sources":["../../../../../src/runtime/register/component/methods.ts"],"sourcesContent":["import type { InternalRuntimeState, MethodDefinitions } from '../../types'\nimport {\n WEVU_INLINE_HANDLER,\n WEVU_INLINE_MAP_KEY,\n WEVU_MODEL_HANDLER,\n WEVU_NATIVE_INSTANCE_KEY,\n WEVU_OWNER_HANDLER,\n WEVU_RESERVED_METHOD_PREFIX,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport { parseModelEventValue } from '../../internal'\nimport { runInlineExpression } from '../inline'\n\nexport function createComponentMethods(options: {\n userMethods: Record<string, (...args: any[]) => any>\n runtimeMethods: MethodDefinitions\n}) {\n const { userMethods, runtimeMethods } = options\n const finalMethods: Record<string, (...args: any[]) => any> = {\n ...userMethods,\n }\n\n if (!finalMethods[WEVU_INLINE_HANDLER]) {\n finalMethods[WEVU_INLINE_HANDLER] = function __weapp_vite_inline(this: InternalRuntimeState, event: any) {\n const runtime = (this as any).__wevu\n const ctx = runtime?.proxy ?? this\n const inlineMap = runtime?.methods?.[WEVU_INLINE_MAP_KEY]\n return runInlineExpression(ctx, undefined, event, inlineMap)\n }\n }\n\n if (!finalMethods[WEVU_MODEL_HANDLER]) {\n finalMethods[WEVU_MODEL_HANDLER] = function __weapp_vite_model(this: InternalRuntimeState, event: any) {\n const path = event?.currentTarget?.dataset?.wvModel ?? event?.target?.dataset?.wvModel\n if (typeof path !== 'string' || !path) {\n return undefined\n }\n const runtime = (this as any).__wevu\n if (!runtime || typeof runtime.bindModel !== 'function') {\n return undefined\n }\n const value = parseModelEventValue(event)\n try {\n runtime.bindModel(path).update(value)\n }\n catch {\n // 忽略异常\n }\n return undefined\n }\n }\n\n if (!finalMethods[WEVU_OWNER_HANDLER] && typeof (runtimeMethods as any)?.[WEVU_OWNER_HANDLER] === 'function') {\n finalMethods[WEVU_OWNER_HANDLER] = (runtimeMethods as any)[WEVU_OWNER_HANDLER]\n }\n\n const methodNames = Object.keys(runtimeMethods ?? {})\n\n function resolveRuntime(instance: InternalRuntimeState) {\n const directRuntime = (instance as any).__wevu\n if (directRuntime) {\n return directRuntime\n }\n const runtimeState = (instance as any).$state\n if (runtimeState && typeof runtimeState === 'object') {\n return (runtimeState as any)[WEVU_RUNTIME_KEY]\n }\n return undefined\n }\n\n function syncRuntimeNativeInstance(runtime: any, instance: InternalRuntimeState) {\n if (runtime?.proxy === instance) {\n return\n }\n const runtimeProxy = runtime?.proxy as Record<string, any> | undefined\n const isBridgeMethod = (\n methodName: 'triggerEvent' | 'createSelectorQuery' | 'createIntersectionObserver' | 'setData',\n ) => {\n const instanceMethod = (instance as any)[methodName]\n if (typeof instanceMethod !== 'function') {\n return false\n }\n const proxyMethod = runtimeProxy?.[methodName]\n return typeof proxyMethod === 'function' && instanceMethod === proxyMethod\n }\n if (\n isBridgeMethod('triggerEvent')\n || isBridgeMethod('createSelectorQuery')\n || isBridgeMethod('createIntersectionObserver')\n || isBridgeMethod('setData')\n ) {\n return\n }\n const hasNativeApis = typeof (instance as any).triggerEvent === 'function'\n || typeof (instance as any).createSelectorQuery === 'function'\n || typeof (instance as any).createIntersectionObserver === 'function'\n || typeof (instance as any).setData === 'function'\n if (!hasNativeApis) {\n return\n }\n const runtimeState = runtime?.state\n if (!runtimeState || typeof runtimeState !== 'object') {\n return\n }\n if ((instance as any).$state === runtimeState) {\n return\n }\n try {\n Object.defineProperty(runtimeState, WEVU_NATIVE_INSTANCE_KEY, {\n value: instance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(runtimeState as any)[WEVU_NATIVE_INSTANCE_KEY] = instance\n }\n }\n\n for (const methodName of methodNames) {\n if (\n methodName === WEVU_INLINE_MAP_KEY\n || methodName.startsWith(WEVU_RESERVED_METHOD_PREFIX)\n ) {\n continue\n }\n const userMethod = finalMethods[methodName]\n finalMethods[methodName] = function componentMethod(this: InternalRuntimeState, ...args: any[]) {\n const runtime = resolveRuntime(this)\n // 事件/方法实际调用时 this 可能是 DevTools 或平台包装后的实例,\n // 这里实时同步,避免 mounted 时缓存的实例与当前调用实例不一致。\n syncRuntimeNativeInstance(runtime, this)\n let result: unknown\n const bound = runtime?.methods?.[methodName]\n if (bound) {\n result = bound.apply(runtime.proxy, args)\n }\n if (typeof userMethod === 'function') {\n const userResult = userMethod.apply(this, args)\n return userResult === undefined ? result : userResult\n }\n return result\n }\n }\n\n return {\n finalMethods,\n }\n}\n"],"mappings":";;;;;AAaA,SAAgB,uBAAuB,SAGpC;CACD,MAAM,EAAE,aAAa,mBAAmB;CACxC,MAAM,eAAwD,EAC5D,GAAG,YACL;CAEA,IAAI,CAAC,aAAa,sBAChB,aAAa,uBAAuB,SAAS,oBAAgD,OAAY;;EACvG,MAAM,UAAW,KAAa;EAG9B,OAAO,wFAFK,QAAS,gEAAS,MAEE,QAAW,qEADzB,QAAS,6EAAU,oBACsB;CAC7D;CAGF,IAAI,CAAC,aAAa,qBAChB,aAAa,sBAAsB,SAAS,mBAA+C,OAAY;;EACrG,MAAM,8FAAO,MAAO,2GAAe,qFAAS,uIAAW,MAAO,+EAAQ,uEAAS;EAC/E,IAAI,OAAO,SAAS,YAAY,CAAC,MAC/B;EAEF,MAAM,UAAW,KAAa;EAC9B,IAAI,CAAC,WAAW,OAAO,QAAQ,cAAc,YAC3C;EAEF,MAAM,QAAQ,qBAAqB,KAAK;EACxC,IAAI;GACF,QAAQ,U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