@weapp-vite/web 1.3.37 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/README.md +144 -5
  2. package/dist/_virtual/_rolldown/runtime.mjs +19 -1
  3. package/dist/compiler/wxml/attributes.mjs +1 -1
  4. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  5. package/dist/compiler/wxml/compile.mjs +6 -3
  6. package/dist/compiler/wxml/compile.mjs.map +1 -1
  7. package/dist/compiler/wxml/interpolation.mjs +1 -2
  8. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  9. package/dist/compiler/wxml/navigation.mjs +5 -7
  10. package/dist/compiler/wxml/navigation.mjs.map +1 -1
  11. package/dist/compiler/wxml/parser.mjs +5 -5
  12. package/dist/compiler/wxml/parser.mjs.map +1 -1
  13. package/dist/compiler/wxml/renderer.mjs +16 -12
  14. package/dist/compiler/wxml/renderer.mjs.map +1 -1
  15. package/dist/compiler/wxml/specialNodes.mjs +8 -2
  16. package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
  17. package/dist/compiler/wxml/types.d.mts +12 -0
  18. package/dist/compiler/wxs.mjs +5 -5
  19. package/dist/compiler/wxs.mjs.map +1 -1
  20. package/dist/css/wxss.d.mts +1 -0
  21. package/dist/css/wxss.mjs +110 -9
  22. package/dist/css/wxss.mjs.map +1 -1
  23. package/dist/index.d.mts +24 -6
  24. package/dist/index.mjs +21 -4
  25. package/dist/plugin/assets.d.mts +7 -0
  26. package/dist/plugin/assets.mjs +122 -0
  27. package/dist/plugin/assets.mjs.map +1 -0
  28. package/dist/plugin/constants.mjs +10 -1
  29. package/dist/plugin/constants.mjs.map +1 -1
  30. package/dist/plugin/dependencyScan.mjs +41 -0
  31. package/dist/plugin/dependencyScan.mjs.map +1 -0
  32. package/dist/plugin/entry.mjs +55 -6
  33. package/dist/plugin/entry.mjs.map +1 -1
  34. package/dist/plugin/files.mjs +1 -1
  35. package/dist/plugin/files.mjs.map +1 -1
  36. package/dist/plugin/index.d.mts +37 -3
  37. package/dist/plugin/index.mjs +244 -73
  38. package/dist/plugin/index.mjs.map +1 -1
  39. package/dist/plugin/layout.mjs +24 -0
  40. package/dist/plugin/layout.mjs.map +1 -0
  41. package/dist/plugin/path.mjs +6 -2
  42. package/dist/plugin/path.mjs.map +1 -1
  43. package/dist/plugin/register.mjs +45 -33
  44. package/dist/plugin/register.mjs.map +1 -1
  45. package/dist/plugin/scan.mjs +211 -92
  46. package/dist/plugin/scan.mjs.map +1 -1
  47. package/dist/plugin/scanSfc.mjs +65 -0
  48. package/dist/plugin/scanSfc.mjs.map +1 -0
  49. package/dist/plugin/state.mjs +3 -2
  50. package/dist/plugin/state.mjs.map +1 -1
  51. package/dist/plugin/styleModule.mjs +52 -0
  52. package/dist/plugin/styleModule.mjs.map +1 -0
  53. package/dist/plugin/types.d.mts +37 -1
  54. package/dist/plugin/vueSfc.mjs +150 -0
  55. package/dist/plugin/vueSfc.mjs.map +1 -0
  56. package/dist/runtime/appShell/container.mjs +25 -0
  57. package/dist/runtime/appShell/container.mjs.map +1 -0
  58. package/dist/runtime/appShell/tabBar/index.mjs +192 -0
  59. package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
  60. package/dist/runtime/appShell/tabBar/style.mjs +127 -0
  61. package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
  62. package/dist/runtime/button/helpers.mjs +1 -58
  63. package/dist/runtime/button/helpers.mjs.map +1 -1
  64. package/dist/runtime/button/index.d.mts +4 -5
  65. package/dist/runtime/button/index.mjs +6 -28
  66. package/dist/runtime/button/index.mjs.map +1 -1
  67. package/dist/runtime/button/style.mjs +53 -28
  68. package/dist/runtime/button/style.mjs.map +1 -1
  69. package/dist/runtime/component/behavior.mjs +26 -2
  70. package/dist/runtime/component/behavior.mjs.map +1 -1
  71. package/dist/runtime/component/element.mjs +107 -31
  72. package/dist/runtime/component/element.mjs.map +1 -1
  73. package/dist/runtime/component/observers.mjs +36 -0
  74. package/dist/runtime/component/observers.mjs.map +1 -0
  75. package/dist/runtime/component/publicInstance.mjs +48 -0
  76. package/dist/runtime/component/publicInstance.mjs.map +1 -0
  77. package/dist/runtime/component/relations.mjs +36 -0
  78. package/dist/runtime/component/relations.mjs.map +1 -0
  79. package/dist/runtime/component/slots.mjs +24 -0
  80. package/dist/runtime/component/slots.mjs.map +1 -0
  81. package/dist/runtime/component/state.mjs +13 -3
  82. package/dist/runtime/component/state.mjs.map +1 -1
  83. package/dist/runtime/component/types.d.mts +29 -4
  84. package/dist/runtime/component/virtualHost.mjs +83 -0
  85. package/dist/runtime/component/virtualHost.mjs.map +1 -0
  86. package/dist/runtime/host/index.d.mts +13 -0
  87. package/dist/runtime/host/index.mjs +47 -0
  88. package/dist/runtime/host/index.mjs.map +1 -0
  89. package/dist/runtime/host/types.d.mts +28 -0
  90. package/dist/runtime/hostGlobals.d.mts +9 -0
  91. package/dist/runtime/hostGlobals.mjs +39 -0
  92. package/dist/runtime/hostGlobals.mjs.map +1 -0
  93. package/dist/runtime/index.d.mts +21 -3
  94. package/dist/runtime/index.mjs +26 -4
  95. package/dist/runtime/index.mjs.map +1 -0
  96. package/dist/runtime/legacyTemplate/dom.mjs +3 -3
  97. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  98. package/dist/runtime/legacyTemplate/expression.mjs +9 -9
  99. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
  100. package/dist/runtime/legacyTemplate/index.mjs +6 -6
  101. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  102. package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
  103. package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
  104. package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
  105. package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
  106. package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
  107. package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
  108. package/dist/runtime/nativeComponents/form.d.mts +7 -0
  109. package/dist/runtime/nativeComponents/form.mjs +50 -0
  110. package/dist/runtime/nativeComponents/form.mjs.map +1 -0
  111. package/dist/runtime/nativeComponents/formControl.mjs +61 -0
  112. package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
  113. package/dist/runtime/nativeComponents/helpers.mjs +25 -0
  114. package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
  115. package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
  116. package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
  117. package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
  118. package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
  119. package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
  120. package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
  121. package/dist/runtime/nativeComponents/image.d.mts +8 -0
  122. package/dist/runtime/nativeComponents/image.mjs +121 -0
  123. package/dist/runtime/nativeComponents/image.mjs.map +1 -0
  124. package/dist/runtime/nativeComponents/index.d.mts +11 -0
  125. package/dist/runtime/nativeComponents/index.mjs +83 -0
  126. package/dist/runtime/nativeComponents/index.mjs.map +1 -0
  127. package/dist/runtime/nativeComponents/input.d.mts +8 -0
  128. package/dist/runtime/nativeComponents/input.mjs +131 -0
  129. package/dist/runtime/nativeComponents/input.mjs.map +1 -0
  130. package/dist/runtime/nativeComponents/label.mjs +36 -0
  131. package/dist/runtime/nativeComponents/label.mjs.map +1 -0
  132. package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
  133. package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
  134. package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
  135. package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
  136. package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
  137. package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
  138. package/dist/runtime/nativeComponents/navigator.mjs +200 -0
  139. package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
  140. package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
  141. package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
  142. package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
  143. package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
  144. package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
  145. package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
  146. package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
  147. package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
  148. package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
  149. package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
  150. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
  151. package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
  152. package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
  153. package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
  154. package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
  155. package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
  156. package/dist/runtime/nativeComponents/primitives.mjs +16 -0
  157. package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
  158. package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
  159. package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
  160. package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
  161. package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
  162. package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
  163. package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
  164. package/dist/runtime/nativeComponents/radio.mjs +147 -0
  165. package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
  166. package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
  167. package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
  168. package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
  169. package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
  170. package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
  171. package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
  172. package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
  173. package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
  174. package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
  175. package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
  176. package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
  177. package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
  178. package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
  179. package/dist/runtime/nativeComponents/style.mjs +41 -0
  180. package/dist/runtime/nativeComponents/style.mjs.map +1 -0
  181. package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
  182. package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
  183. package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
  184. package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
  185. package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
  186. package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
  187. package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
  188. package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
  189. package/dist/runtime/nativeComponents/switch.d.mts +7 -0
  190. package/dist/runtime/nativeComponents/switch.mjs +132 -0
  191. package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
  192. package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
  193. package/dist/runtime/nativeComponents/textarea.mjs +144 -0
  194. package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
  195. package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
  196. package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
  197. package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
  198. package/dist/runtime/nativeComponents/video/index.mjs +124 -0
  199. package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
  200. package/dist/runtime/nativeComponents/video/style.mjs +14 -0
  201. package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
  202. package/dist/runtime/navigationBar/index.mjs +1 -3
  203. package/dist/runtime/navigationBar/index.mjs.map +1 -1
  204. package/dist/runtime/pageLayout.d.mts +9 -0
  205. package/dist/runtime/pageLayout.mjs +16 -0
  206. package/dist/runtime/pageLayout.mjs.map +1 -0
  207. package/dist/runtime/polyfill/animation.mjs +120 -0
  208. package/dist/runtime/polyfill/animation.mjs.map +1 -0
  209. package/dist/runtime/polyfill/appState.mjs +1 -1
  210. package/dist/runtime/polyfill/appState.mjs.map +1 -1
  211. package/dist/runtime/polyfill/async.d.mts +7 -0
  212. package/dist/runtime/polyfill/async.mjs.map +1 -1
  213. package/dist/runtime/polyfill/canvasContext.mjs +41 -0
  214. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
  215. package/dist/runtime/polyfill/device.mjs +1 -1
  216. package/dist/runtime/polyfill/device.mjs.map +1 -1
  217. package/dist/runtime/polyfill/deviceApi.mjs +6 -3
  218. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
  219. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
  220. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
  221. package/dist/runtime/polyfill/eventBus.mjs +56 -0
  222. package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
  223. package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
  224. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
  225. package/dist/runtime/polyfill/files.mjs +10 -10
  226. package/dist/runtime/polyfill/files.mjs.map +1 -1
  227. package/dist/runtime/polyfill/font.mjs +33 -0
  228. package/dist/runtime/polyfill/font.mjs.map +1 -0
  229. package/dist/runtime/polyfill/index.d.mts +2 -2
  230. package/dist/runtime/polyfill/index.mjs +49 -45
  231. package/dist/runtime/polyfill/index.mjs.map +1 -1
  232. package/dist/runtime/polyfill/interaction.mjs +7 -6
  233. package/dist/runtime/polyfill/interaction.mjs.map +1 -1
  234. package/dist/runtime/polyfill/interactionApi.mjs +9 -5
  235. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
  236. package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
  237. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
  238. package/dist/runtime/polyfill/locale.mjs +14 -0
  239. package/dist/runtime/polyfill/locale.mjs.map +1 -0
  240. package/dist/runtime/polyfill/locationApi.mjs +11 -6
  241. package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
  242. package/dist/runtime/polyfill/mediaActions.mjs +2 -2
  243. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
  244. package/dist/runtime/polyfill/mediaApi/file.mjs +3 -2
  245. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
  246. package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
  247. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
  248. package/dist/runtime/polyfill/mediaApi/picker.mjs +16 -8
  249. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
  250. package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
  251. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
  252. package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
  253. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
  254. package/dist/runtime/polyfill/menuApi.mjs +39 -4
  255. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  256. package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
  257. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
  258. package/dist/runtime/polyfill/network/request.mjs +2 -2
  259. package/dist/runtime/polyfill/network/request.mjs.map +1 -1
  260. package/dist/runtime/polyfill/platformApi.mjs +3 -2
  261. package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
  262. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
  263. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
  264. package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
  265. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  266. package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
  267. package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
  268. package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
  269. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
  270. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  271. package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
  272. package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
  273. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  274. package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
  275. package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
  276. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
  277. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
  278. package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
  279. package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
  280. package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
  281. package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
  282. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  283. package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
  284. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
  285. package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
  286. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
  287. package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
  288. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  289. package/dist/runtime/polyfill/storage.mjs +5 -2
  290. package/dist/runtime/polyfill/storage.mjs.map +1 -1
  291. package/dist/runtime/polyfill/storageAsync.mjs +4 -2
  292. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
  293. package/dist/runtime/polyfill/system.mjs +31 -4
  294. package/dist/runtime/polyfill/system.mjs.map +1 -1
  295. package/dist/runtime/polyfill/systemApi.mjs +2 -1
  296. package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
  297. package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
  298. package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
  299. package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
  300. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
  301. package/dist/runtime/polyfill/ui.mjs +2 -6
  302. package/dist/runtime/polyfill/ui.mjs.map +1 -1
  303. package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
  304. package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
  305. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  306. package/dist/runtime/polyfill/videoContext.mjs +4 -0
  307. package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
  308. package/dist/runtime/polyfill/vkSession.mjs +4 -14
  309. package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
  310. package/dist/runtime/polyfill.d.mts +2 -2
  311. package/dist/runtime/renderContext.mjs +1 -1
  312. package/dist/runtime/renderContext.mjs.map +1 -1
  313. package/dist/runtime/rpx.mjs +17 -8
  314. package/dist/runtime/rpx.mjs.map +1 -1
  315. package/dist/runtime/seo/index.d.mts +31 -0
  316. package/dist/runtime/seo/index.mjs +94 -0
  317. package/dist/runtime/seo/index.mjs.map +1 -0
  318. package/dist/runtime/viewport/index.d.mts +12 -0
  319. package/dist/runtime/viewport/index.mjs +44 -0
  320. package/dist/runtime/viewport/index.mjs.map +1 -0
  321. package/dist/runtime/viewport/style.mjs +62 -0
  322. package/dist/runtime/viewport/style.mjs.map +1 -0
  323. package/dist/runtime/viewport/types.d.mts +14 -0
  324. package/dist/runtime/wevu.d.mts +20 -0
  325. package/dist/runtime/wevu.mjs +73 -0
  326. package/dist/runtime/wevu.mjs.map +1 -0
  327. package/dist/shared/nativeComponents.mjs +401 -0
  328. package/dist/shared/nativeComponents.mjs.map +1 -0
  329. package/dist/shared/tabBar.d.mts +19 -0
  330. package/dist/shared/tabBar.mjs +37 -0
  331. package/dist/shared/tabBar.mjs.map +1 -0
  332. package/dist/shared/wxml.mjs +3 -20
  333. package/dist/shared/wxml.mjs.map +1 -1
  334. package/package.json +14 -6
@@ -1 +1 @@
1
- {"version":3,"file":"file.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/file.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeFilePath,\n resolveOpenDocumentUrl,\n resolveSaveFilePath,\n saveMemoryFile,\n} from '../files'\nimport {\n openTargetInNewWindow,\n triggerDownload,\n} from '../mediaActions'\n\nexport function saveImageToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveImageToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveImageToPhotosAlbum:ok' }))\n}\n\nexport function saveVideoToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveVideoToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveVideoToPhotosAlbum:ok' }))\n}\n\nexport function saveFileBridge(options?: any) {\n const tempFilePath = typeof options?.tempFilePath === 'string' ? options.tempFilePath.trim() : ''\n if (!tempFilePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFile:fail invalid tempFilePath')\n return Promise.reject(failure)\n }\n const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath)\n saveMemoryFile(tempFilePath, savedFilePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'saveFile:ok',\n savedFilePath,\n }))\n}\n\nexport function saveFileToDiskBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFileToDisk:fail invalid filePath')\n return Promise.reject(failure)\n }\n const fileName = typeof options?.fileName === 'string' ? options.fileName.trim() : ''\n triggerDownload(filePath, fileName)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveFileToDisk:ok' }))\n}\n\nexport function openDocumentBridge(options?: any) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail invalid filePath')\n return Promise.reject(failure)\n }\n const target = resolveOpenDocumentUrl(filePath)\n if (!target) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail document url is unavailable')\n return Promise.reject(failure)\n }\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'openDocument:ok' }))\n}\n"],"mappings":";;;;;AAeA,SAAgB,6BAA6B,SAAe;CAC1D,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,IAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,8CAA8C;EACnG,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,gBAAgB,QAAQ;CACxB,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,4BAA4B,CAAC,CAAC;AACtG;AAEA,SAAgB,6BAA6B,SAAe;CAC1D,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,IAAI,CAAC,UAAU;EACb,MAAM,UA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BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F"}
1
+ {"version":3,"file":"file.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/file.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeFilePath,\n resolveOpenDocumentUrl,\n resolveSaveFilePath,\n saveMemoryFile,\n} from '../files'\nimport {\n openTargetInNewWindow,\n triggerDownload,\n} from '../mediaActions'\n\nexport function saveImageToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveImageToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveImageToPhotosAlbum:ok' }))\n}\n\nexport function saveVideoToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveVideoToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveVideoToPhotosAlbum:ok' }))\n}\n\nexport function saveFileBridge(options?: any) {\n const tempFilePath = typeof options?.tempFilePath === 'string' ? options.tempFilePath.trim() : ''\n if (!tempFilePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFile:fail invalid tempFilePath')\n return Promise.reject(failure)\n }\n const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath)\n saveMemoryFile(tempFilePath, savedFilePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'saveFile:ok',\n savedFilePath,\n }))\n}\n\nexport function saveFileToDiskBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFileToDisk:fail invalid filePath')\n return Promise.reject(failure)\n }\n const fileName = typeof options?.fileName === 'string' ? options.fileName.trim() : ''\n triggerDownload(filePath, fileName)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveFileToDisk:ok' }))\n}\n\nexport function openDocumentBridge(options?: any) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail invalid filePath')\n return Promise.reject(failure)\n }\n const target = resolveOpenDocumentUrl(filePath)\n if (!target) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail document url is unavailable')\n return Promise.reject(failure)\n }\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'openDocument:ok' }))\n}\n"],"mappings":";;;;;AAeA,SAAgB,6BAA6B,SAAe;CAC1D,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,IAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,8CAA8C;EACnG,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,gBAAgB,QAAQ;CACxB,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,4BAA4B,CAAC,CAAC;AACtG;AAEA,SAAgB,6BAA6B,SAAe;CAC1D,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,IAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,8CAA8C;EACnG,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,gBAAgB,QAAQ;CACxB,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,4BAA4B,CAAC,CAAC;AACtG;AAEA,SAAgB,eAAe,SAAe;CAC5C,MAAM,eAAe,OAAO,SAAS,iBAAiB,WAAW,QAAQ,aAAa,KAAK,IAAI;CAC/F,IAAI,CAAC,cAAc;EACjB,MAAM,UAAU,4BAA4B,SAAS,oCAAoC;EACzF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,gBAAgB,oBAAoB,cAAc,SAAS,QAAQ;CACzE,eAAe,cAAc,aAAa;CAC1C,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR;CACF,CAAC,CAAC;AACJ;AAEA,SAAgB,qBAAqB,SAAe;CAClD,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,IAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,sCAAsC;EAC3F,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,KAAK,IAAI;CACnF,gBAAgB,UAAU,QAAQ;CAClC,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,oBAAoB,CAAC,CAAC;AAC9F;AAEA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,WAAW,kBAAkB,SAAS,QAAQ;CACpD,IAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,oCAAoC;EACzF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,SAAS,uBAAuB,QAAQ;CAC9C,IAAI,CAAC,QAAQ;EACX,MAAM,UAAU,4BAA4B,SAAS,+CAA+C;EACpG,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,sBAAsB,MAAM;CAC5B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F"}
@@ -6,7 +6,7 @@ function getImageInfoBridge(options) {
6
6
  const src = typeof options?.src === "string" ? options.src.trim() : "";
7
7
  if (!src) {
8
8
  const failure = callMiniProgramAsyncFailure(options, "getImageInfo:fail invalid src");
9
- return Promise.reject(failure);
9
+ return typeof options?.fail === "function" ? Promise.resolve(failure) : Promise.reject(failure);
10
10
  }
11
11
  return readImageInfoFromSource(src).then(({ width, height }) => callMiniProgramAsyncSuccess(options, {
12
12
  errMsg: "getImageInfo:ok",
@@ -16,8 +16,9 @@ function getImageInfoBridge(options) {
16
16
  type: inferImageTypeFromPath(src),
17
17
  orientation: "up"
18
18
  })).catch((error) => {
19
- const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${error instanceof Error ? error.message : String(error)}`);
20
- return Promise.reject(failure);
19
+ const message = error.message;
20
+ const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${message}`);
21
+ return typeof options?.fail === "function" ? failure : Promise.reject(failure);
21
22
  });
22
23
  }
23
24
  function getVideoInfoBridge(options) {
@@ -49,7 +50,8 @@ function getVideoInfoBridge(options) {
49
50
  fps
50
51
  });
51
52
  }).catch((error) => {
52
- const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${error instanceof Error ? error.message : String(error)}`);
53
+ const message = error.message;
54
+ const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${message}`);
53
55
  return Promise.reject(failure);
54
56
  });
55
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"info.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/info.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n inferImageTypeFromPath,\n inferVideoTypeFromPath,\n normalizeVideoInfoNumber,\n readImageInfoFromSource,\n readPresetVideoInfo,\n readVideoInfoFromSource,\n} from '../mediaInfo'\n\nexport function getImageInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getImageInfo:fail invalid src')\n return Promise.reject(failure)\n }\n return readImageInfoFromSource(src)\n .then(({ width, height }) => callMiniProgramAsyncSuccess(options, {\n errMsg: 'getImageInfo:ok',\n width,\n height,\n path: src,\n type: inferImageTypeFromPath(src),\n orientation: 'up',\n }))\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n\nexport function getVideoInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getVideoInfo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetVideoInfo(src)\n const resolveResult = async () => {\n if (preset) {\n return preset\n }\n return readVideoInfoFromSource(src)\n }\n return resolveResult()\n .then((result) => {\n const duration = normalizeVideoInfoNumber(result.duration)\n const width = normalizeVideoInfoNumber(result.width)\n const height = normalizeVideoInfoNumber(result.height)\n const bitrate = normalizeVideoInfoNumber((result as Record<string, unknown>).bitrate)\n const fps = normalizeVideoInfoNumber((result as Record<string, unknown>).fps)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getVideoInfo:ok',\n orientation: 'up',\n type: inferVideoTypeFromPath(src),\n duration,\n size: normalizeVideoInfoNumber((result as Record<string, unknown>).size),\n width,\n height,\n bitrate,\n fps,\n })\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n"],"mappings":";;;;AAaA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,+BAA+B;EACpF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,OAAO,wBAAwB,GAAG,CAAC,CAChC,MAAM,EAAE,OAAO,aAAa,4BAA4B,SAAS;EAChE,QAAQ;EACR;EACA;EACA,MAAM;EACN,MAAM,uBAAuB,GAAG;EAChC,aAAa;CACf,CAAC,CAAC,CAAC,CACF,OAAO,UAAU;EAEhB,MAAM,UAAU,4BAA4B,SAAS,qBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACc;EACnF,OAAO,QAAQ,OAAO,OAAO;CAC/B,CAAC;AACL;AAEA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,+BAA+B;EACpF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,SAAS,oBAAoB,GAAG;CACtC,MAAM,gBAAgB,YAAY;EAChC,IAAI,QACF,OAAO;EAET,OAAO,wBAAwB,GAAG;CACpC;CACA,OAAO,cAAc,CAAC,CACnB,MAAM,WAAW;EAChB,MAAM,WAAW,yBAAyB,OAAO,QAAQ;EACzD,MAAM,QAAQ,yBAAyB,OAAO,KAAK;EACnD,MAAM,SAAS,yBAAyB,OAAO,MAAM;EACrD,MAAM,UAAU,yBAA0B,OAAmC,OAAO;EACpF,MAAM,MAAM,yBAA0B,OAAmC,GAAG;EAC5E,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,aAAa;GACb,MAAM,uBAAuB,GAAG;GAChC;GACA,MAAM,yBAA0B,OAAmC,IAAI;GACvE;GACA;GACA;GACA;EACF,CAAC;CACH,CAAC,CAAC,CACD,OAAO,UAAU;EAEhB,MAAM,UAAU,4BAA4B,SAAS,qBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACc;EACnF,OAAO,QAAQ,OAAO,OAAO;CAC/B,CAAC;AACL"}
1
+ {"version":3,"file":"info.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/info.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n inferImageTypeFromPath,\n inferVideoTypeFromPath,\n normalizeVideoInfoNumber,\n readImageInfoFromSource,\n readPresetVideoInfo,\n readVideoInfoFromSource,\n} from '../mediaInfo'\n\nexport function getImageInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getImageInfo:fail invalid src')\n return typeof options?.fail === 'function' ? Promise.resolve(failure) : Promise.reject(failure)\n }\n return readImageInfoFromSource(src)\n .then(({ width, height }) => callMiniProgramAsyncSuccess(options, {\n errMsg: 'getImageInfo:ok',\n width,\n height,\n path: src,\n type: inferImageTypeFromPath(src),\n orientation: 'up',\n }))\n .catch((error) => {\n const message = (error as Error).message\n const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${message}`)\n return typeof options?.fail === 'function' ? failure : Promise.reject(failure)\n })\n}\n\nexport function getVideoInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getVideoInfo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetVideoInfo(src)\n const resolveResult = async () => {\n if (preset) {\n return preset\n }\n return readVideoInfoFromSource(src)\n }\n return resolveResult()\n .then((result) => {\n const duration = normalizeVideoInfoNumber(result.duration)\n const width = normalizeVideoInfoNumber(result.width)\n const height = normalizeVideoInfoNumber(result.height)\n const bitrate = normalizeVideoInfoNumber((result as Record<string, unknown>).bitrate)\n const fps = normalizeVideoInfoNumber((result as Record<string, unknown>).fps)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getVideoInfo:ok',\n orientation: 'up',\n type: inferVideoTypeFromPath(src),\n duration,\n size: normalizeVideoInfoNumber((result as Record<string, unknown>).size),\n width,\n height,\n bitrate,\n fps,\n })\n })\n .catch((error) => {\n const message = (error as Error).message\n const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n"],"mappings":";;;;AAaA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,U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4B,SAAS,qBAAqB,SAAS;EACnF,OAAO,QAAQ,OAAO,OAAO;CAC/B,CAAC;AACL"}
@@ -8,13 +8,15 @@ async function chooseImageBridge(options) {
8
8
  const count = normalizeChooseImageCount(options?.count);
9
9
  try {
10
10
  const tempFiles = (await pickChooseImageFiles(count)).map((file) => normalizeChooseImageFile(file));
11
+ const tempFilePaths = tempFiles.map((item) => item.path);
11
12
  return callMiniProgramAsyncSuccess(options, {
12
13
  errMsg: "chooseImage:ok",
13
- tempFilePaths: tempFiles.map((item) => item.path),
14
+ tempFilePaths,
14
15
  tempFiles
15
16
  });
16
17
  } catch (error) {
17
- const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${error instanceof Error ? error.message : String(error)}`);
18
+ const message = error instanceof Error ? error.message : String(error);
19
+ const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${message}`);
18
20
  return Promise.reject(failure);
19
21
  }
20
22
  }
@@ -30,7 +32,8 @@ async function chooseMediaBridge(options) {
30
32
  tempFiles
31
33
  });
32
34
  } catch (error) {
33
- const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${error instanceof Error ? error.message : String(error)}`);
35
+ const message = error instanceof Error ? error.message : String(error);
36
+ const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${message}`);
34
37
  return Promise.reject(failure);
35
38
  }
36
39
  }
@@ -45,7 +48,8 @@ async function chooseVideoBridge(options) {
45
48
  ...normalized
46
49
  });
47
50
  } catch (error) {
48
- const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${error instanceof Error ? error.message : String(error)}`);
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${message}`);
49
53
  return Promise.reject(failure);
50
54
  }
51
55
  }
@@ -53,12 +57,14 @@ async function chooseMessageFileBridge(options) {
53
57
  const count = normalizeChooseMessageFileCount(options?.count);
54
58
  const type = normalizeChooseMessageFileType(options?.type);
55
59
  try {
60
+ const tempFiles = (await pickChooseMessageFiles(count, type)).map((file) => normalizeChooseMessageFile(file));
56
61
  return callMiniProgramAsyncSuccess(options, {
57
62
  errMsg: "chooseMessageFile:ok",
58
- tempFiles: (await pickChooseMessageFiles(count, type)).map((file) => normalizeChooseMessageFile(file))
63
+ tempFiles
59
64
  });
60
65
  } catch (error) {
61
- const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${error instanceof Error ? error.message : String(error)}`);
66
+ const message = error instanceof Error ? error.message : String(error);
67
+ const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${message}`);
62
68
  return Promise.reject(failure);
63
69
  }
64
70
  }
@@ -67,12 +73,14 @@ async function chooseFileBridge(options) {
67
73
  const type = normalizeChooseMessageFileType(options?.type);
68
74
  const extensions = normalizeChooseFileExtensions(options?.extension);
69
75
  try {
76
+ const tempFiles = (await pickChooseFileFiles(count, type, extensions)).map((file) => normalizeChooseMessageFile(file));
70
77
  return callMiniProgramAsyncSuccess(options, {
71
78
  errMsg: "chooseFile:ok",
72
- tempFiles: (await pickChooseFileFiles(count, type, extensions)).map((file) => normalizeChooseMessageFile(file))
79
+ tempFiles
73
80
  });
74
81
  } catch (error) {
75
- const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${error instanceof Error ? error.message : String(error)}`);
82
+ const message = error instanceof Error ? error.message : String(error);
83
+ const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${message}`);
76
84
  return Promise.reject(failure);
77
85
  }
78
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"picker.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/picker.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeChooseFileExtensions,\n normalizeChooseMessageFile,\n normalizeChooseMessageFileCount,\n normalizeChooseMessageFileType,\n pickChooseFileFiles,\n pickChooseMessageFiles,\n} from '../filePicker'\nimport {\n normalizeChooseImageCount,\n normalizeChooseImageFile,\n normalizeChooseMediaCount,\n normalizeChooseMediaFile,\n normalizeChooseMediaTypes,\n pickChooseImageFiles,\n pickChooseMediaFiles,\n} from '../mediaPicker'\nimport {\n normalizeChooseVideoFile,\n pickChooseVideoFile,\n} from '../mediaProcess'\n\nexport async function chooseImageBridge(options?: any) {\n const count = normalizeChooseImageCount(options?.count)\n try {\n const files = await pickChooseImageFiles(count)\n const tempFiles = files.map(file => normalizeChooseImageFile(file))\n const tempFilePaths = tempFiles.map(item => item.path)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseImage:ok',\n tempFilePaths,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMediaBridge(options?: any) {\n const count = normalizeChooseMediaCount(options?.count)\n const types = normalizeChooseMediaTypes(options?.mediaType)\n try {\n const files = await pickChooseMediaFiles(count, types)\n const tempFiles = files.map(file => normalizeChooseMediaFile(file))\n const defaultType = types.has('video') && !types.has('image') ? 'video' : 'image'\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMedia:ok',\n type: tempFiles[0]?.fileType ?? defaultType,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseVideoBridge(options?: any) {\n try {\n const file = await pickChooseVideoFile()\n if (!file) {\n throw new TypeError('no file selected')\n }\n const normalized = normalizeChooseVideoFile(file)\n if (!normalized) {\n throw new TypeError('selected file is not a video')\n }\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseVideo:ok',\n ...normalized,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMessageFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n try {\n const files = await pickChooseMessageFiles(count, type)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMessageFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n const extensions = normalizeChooseFileExtensions(options?.extension)\n try {\n const files = await pickChooseFileFiles(count, type, extensions)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;;AA0BA,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,KAAK;CACtD,IAAI;EAEF,MAAM,aAAY,MADE,qBAAqB,KAAK,EACvB,CAAC,KAAI,SAAQ,yBAAyB,IAAI,CAAC;EAElE,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,eAHoB,UAAU,KAAI,SAAQ,KAAK,IAGnC;GACZ;EACF,CAAC;CACH,SACO,OAAO;EAEZ,MAAM,UAAU,4BAA4B,SAAS,oBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACa;EAClF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,KAAK;CACtD,MAAM,QAAQ,0BAA0B,SAAS,SAAS;CAC1D,IAAI;EAEF,MAAM,aAA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CACpD,MAAM,QAAQ,gCAAgC,SAAS,KAAK;CAC5D,MAAM,OAAO,+BAA+B,SAAS,IAAI;CACzD,MAAM,aAAa,8BAA8B,SAAS,SAAS;CACnE,IAAI;EAGF,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,YAHgB,MADE,oBAAoB,OAAO,MAAM,UAAU,EACxC,CAAC,KAAI,SAAQ,2BAA2B,IAAI,CAGzD;EACV,CAAC;CACH,SACO,OAAO;EAEZ,MAAM,UAAU,4BAA4B,SAAS,mBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACY;EACjF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF"}
1
+ {"version":3,"file":"picker.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/picker.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeChooseFileExtensions,\n normalizeChooseMessageFile,\n normalizeChooseMessageFileCount,\n normalizeChooseMessageFileType,\n pickChooseFileFiles,\n pickChooseMessageFiles,\n} from '../filePicker'\nimport {\n normalizeChooseImageCount,\n normalizeChooseImageFile,\n normalizeChooseMediaCount,\n normalizeChooseMediaFile,\n normalizeChooseMediaTypes,\n pickChooseImageFiles,\n pickChooseMediaFiles,\n} from '../mediaPicker'\nimport {\n normalizeChooseVideoFile,\n pickChooseVideoFile,\n} from '../mediaProcess'\n\nexport async function chooseImageBridge(options?: any) {\n const count = normalizeChooseImageCount(options?.count)\n try {\n const files = await pickChooseImageFiles(count)\n const tempFiles = files.map(file => normalizeChooseImageFile(file))\n const tempFilePaths = tempFiles.map(item => item.path)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseImage:ok',\n tempFilePaths,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMediaBridge(options?: any) {\n const count = normalizeChooseMediaCount(options?.count)\n const types = normalizeChooseMediaTypes(options?.mediaType)\n try {\n const files = await pickChooseMediaFiles(count, types)\n const tempFiles = files.map(file => normalizeChooseMediaFile(file))\n const defaultType = types.has('video') && !types.has('image') ? 'video' : 'image'\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMedia:ok',\n type: tempFiles[0]?.fileType ?? defaultType,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseVideoBridge(options?: any) {\n try {\n const file = await pickChooseVideoFile()\n if (!file) {\n throw new TypeError('no file selected')\n }\n const normalized = normalizeChooseVideoFile(file)\n if (!normalized) {\n throw new TypeError('selected file is not a video')\n }\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseVideo:ok',\n ...normalized,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMessageFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n try {\n const files = await pickChooseMessageFiles(count, type)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMessageFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n const extensions = normalizeChooseFileExtensions(options?.extension)\n try {\n const files = await pickChooseFileFiles(count, type, extensions)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;;AA0BA,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,KAAK;CACtD,IAAI;EAEF,MAAM,aAAY,MADE,qBAAqB,KAAK,EACvB,CAAC,KAAI,SAAQ,yBAAyB,IAAI,CAAC;EAClE,MAAM,gBAAgB,UAAU,KAAI,SAAQ,KAAK,IAAI;EACrD,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR;GACA;EACF,CAAC;CACH,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,UAAU,4BAA4B,SAAS,oBAAoB,SAAS;EAClF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,KAAK;CACtD,MAAM,QAAQ,0BAA0B,SAAS,SAAS;CAC1D,IAAI;EAEF,MAAM,aAAY,MADE,qBAAqB,OAAO,KAAK,EAC9B,CAAC,KAAI,SAAQ,yBAAyB,IAAI,CAAC;EAClE,MAAM,cAAc,MAAM,IAAI,OAAO,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,UAAU;EAC1E,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,MAAM,UAAU,EAAE,EAAE,YAAY;GAChC;EACF,CAAC;CACH,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,UAAU,4BAA4B,SAAS,oBAAoB,SAAS;EAClF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,eAAsB,kBAAkB,SAAe;CACrD,IAAI;EACF,MAAM,OAAO,MAAM,oBAAo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,QAAQ,OAAO,OAAO;CAC/B;AACF"}
@@ -9,7 +9,8 @@ function previewImageBridge(options) {
9
9
  return Promise.reject(failure);
10
10
  }
11
11
  const current = typeof options?.current === "string" && options.current.trim() ? options.current.trim() : urls[0];
12
- openTargetInNewWindow(urls.includes(current) ? current : urls[0]);
12
+ const target = urls.includes(current) ? current : urls[0];
13
+ openTargetInNewWindow(target);
13
14
  return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "previewImage:ok" }));
14
15
  }
15
16
  function previewMediaBridge(options) {
@@ -18,7 +19,8 @@ function previewMediaBridge(options) {
18
19
  const failure = callMiniProgramAsyncFailure(options, "previewMedia:fail invalid sources");
19
20
  return Promise.reject(failure);
20
21
  }
21
- openTargetInNewWindow(sources[typeof options?.current === "number" && Number.isFinite(options.current) ? Math.max(0, Math.floor(options.current)) : 0]?.url ?? sources[0].url);
22
+ const target = sources[typeof options?.current === "number" && Number.isFinite(options.current) ? Math.max(0, Math.floor(options.current)) : 0]?.url ?? sources[0].url;
23
+ openTargetInNewWindow(target);
22
24
  return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "previewMedia:ok" }));
23
25
  }
24
26
  function openVideoEditorBridge(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"preview.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/preview.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizePreviewMediaSources,\n openTargetInNewWindow,\n readOpenVideoEditorPreset,\n} from '../mediaActions'\n\nexport function previewImageBridge(options?: any) {\n const urls = Array.isArray(options?.urls)\n ? options.urls.map((url: unknown) => String(url).trim()).filter(Boolean)\n : []\n if (!urls.length) {\n const failure = callMiniProgramAsyncFailure(options, 'previewImage:fail invalid urls')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'string' && options.current.trim()\n ? options.current.trim()\n : urls[0]\n const target = urls.includes(current) ? current : urls[0]\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'previewImage:ok' }))\n}\n\nexport function previewMediaBridge(options?: any) {\n const sources = normalizePreviewMediaSources(options?.sources)\n if (!sources.length) {\n const failure = callMiniProgramAsyncFailure(options, 'previewMedia:fail invalid sources')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'number' && Number.isFinite(options.current)\n ? Math.max(0, Math.floor(options.current))\n : 0\n const target = sources[current]?.url ?? sources[0].url\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'previewMedia:ok' }))\n}\n\nexport function openVideoEditorBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'openVideoEditor:fail invalid src')\n return Promise.reject(failure)\n }\n const tempFilePath = readOpenVideoEditorPreset(src) || src\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'openVideoEditor:ok',\n tempFilePath,\n }))\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,OAAO,MAAM,QAAQ,SAAS,IAAI,IACpC,QAAQ,KAAK,KAAK,QAAiB,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,IACrE,CAAC;CACL,IAAI,CAAC,KAAK,QAAQ;EAChB,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,UAAU,OAAO,SAAS,YAAY,YAAY,QAAQ,QAAQ,KAAK,IACzE,QAAQ,QAAQ,KAAK,IACrB,KAAK;CAET,sBADe,KAAK,SAAS,OAAO,IAAI,UAAU,KAAK,EAC3B;CAC5B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F;AAEA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,UAAU,6BAA6B,SAAS,OAAO;CAC7D,IAAI,CAAC,QAAQ,QAAQ;EACnB,MAAM,UAAU,4BAA4B,SAAS,mCAAmC;EACxF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CAKA,sBADe,QAHC,OAAO,SAAS,YAAY,YAAY,OAAO,SAAS,QAAQ,OAAO,IACnF,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,OAAO,CAAC,IACvC,EAC2B,EAAE,OAAO,QAAQ,EAAE,CAAC,GACvB;CAC5B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F;AAEA,SAAgB,sBAAsB,SAAe;CACnD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,kCAAkC;EACvF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,eAAe,0BAA0B,GAAG,KAAK;CACvD,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR;CACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"preview.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/preview.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizePreviewMediaSources,\n openTargetInNewWindow,\n readOpenVideoEditorPreset,\n} from '../mediaActions'\n\nexport function previewImageBridge(options?: any) {\n const urls = Array.isArray(options?.urls)\n ? options.urls.map((url: unknown) => String(url).trim()).filter(Boolean)\n : []\n if (!urls.length) {\n const failure = callMiniProgramAsyncFailure(options, 'previewImage:fail invalid urls')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'string' && options.current.trim()\n ? options.current.trim()\n : urls[0]\n const target = urls.includes(current) ? current : urls[0]\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'previewImage:ok' }))\n}\n\nexport function previewMediaBridge(options?: any) {\n const sources = normalizePreviewMediaSources(options?.sources)\n if (!sources.length) {\n const failure = callMiniProgramAsyncFailure(options, 'previewMedia:fail invalid sources')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'number' && Number.isFinite(options.current)\n ? Math.max(0, Math.floor(options.current))\n : 0\n const target = sources[current]?.url ?? sources[0].url\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'previewMedia:ok' }))\n}\n\nexport function openVideoEditorBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'openVideoEditor:fail invalid src')\n return Promise.reject(failure)\n }\n const tempFilePath = readOpenVideoEditorPreset(src) || src\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'openVideoEditor:ok',\n tempFilePath,\n }))\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,OAAO,MAAM,QAAQ,SAAS,IAAI,IACpC,QAAQ,KAAK,KAAK,QAAiB,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,IACrE,CAAC;CACL,IAAI,CAAC,KAAK,QAAQ;EAChB,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,UAAU,OAAO,SAAS,YAAY,YAAY,QAAQ,QAAQ,KAAK,IACzE,QAAQ,QAAQ,KAAK,IACrB,KAAK;CACT,MAAM,SAAS,KAAK,SAAS,OAAO,IAAI,UAAU,KAAK;CACvD,sBAAsB,MAAM;CAC5B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F;AAEA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,UAAU,6BAA6B,SAAS,OAAO;CAC7D,IAAI,CAAC,QAAQ,QAAQ;EACnB,MAAM,UAAU,4BAA4B,SAAS,mCAAmC;EACxF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CAIA,MAAM,SAAS,QAHC,OAAO,SAAS,YAAY,YAAY,OAAO,SAAS,QAAQ,OAAO,IACnF,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,OAAO,CAAC,IACvC,EAC2B,EAAE,OAAO,QAAQ,EAAE,CAAC;CACnD,sBAAsB,MAAM;CAC5B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;AAC5F;AAEA,SAAgB,sBAAsB,SAAe;CACnD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,kCAAkC;EACvF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,eAAe,0BAA0B,GAAG,KAAK;CACvD,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR;CACF,CAAC,CAAC;AACJ"}
@@ -11,12 +11,14 @@ async function compressImageBridge(options) {
11
11
  }
12
12
  const quality = normalizeCompressImageQuality(options?.quality);
13
13
  try {
14
+ const tempFilePath = await compressImageByCanvas(src, quality);
14
15
  return callMiniProgramAsyncSuccess(options, {
15
16
  errMsg: "compressImage:ok",
16
- tempFilePath: await compressImageByCanvas(src, quality)
17
+ tempFilePath
17
18
  });
18
19
  } catch (error) {
19
- const failure = callMiniProgramAsyncFailure(options, `compressImage:fail ${error instanceof Error ? error.message : String(error)}`);
20
+ const message = error instanceof Error ? error.message : String(error);
21
+ const failure = callMiniProgramAsyncFailure(options, `compressImage:fail ${message}`);
20
22
  return Promise.reject(failure);
21
23
  }
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"process.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/process.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport { readPresetCompressVideo } from '../mediaInfo'\nimport {\n compressImageByCanvas,\n normalizeCompressImageQuality,\n} from '../mediaProcess'\n\nexport async function compressImageBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'compressImage:fail invalid src')\n return Promise.reject(failure)\n }\n const quality = normalizeCompressImageQuality(options?.quality)\n try {\n const tempFilePath = await compressImageByCanvas(src, quality)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'compressImage:ok',\n tempFilePath,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `compressImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport function compressVideoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'compressVideo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetCompressVideo(src)\n const result = preset ?? {\n tempFilePath: src,\n size: 0,\n duration: 0,\n width: 0,\n height: 0,\n bitrate: 0,\n fps: 0,\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'compressVideo:ok',\n ...result,\n }))\n}\n"],"mappings":";;;;;AAUA,eAAsB,oBAAoB,SAAe;CACvD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,UAAU,8BAA8B,SAAS,OAAO;CAC9D,IAAI;EAEF,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,oBAHyB,sBAAsB,KAAK,OAAO;EAI7D,CAAC;CACH,SACO,OAAO;EAEZ,MAAM,UAAU,4BAA4B,SAAS,sBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACe;EACpF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,SAAgB,oBAAoB,SAAe;CACjD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CAEA,MAAM,SADS,wBAAwB,GACnB,KAAK;EACvB,cAAc;EACd,MAAM;EACN,UAAU;EACV,OAAO;EACP,QAAQ;EACR,SAAS;EACT,KAAK;CACP;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,GAAG;CACL,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"process.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/process.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport { readPresetCompressVideo } from '../mediaInfo'\nimport {\n compressImageByCanvas,\n normalizeCompressImageQuality,\n} from '../mediaProcess'\n\nexport async function compressImageBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'compressImage:fail invalid src')\n return Promise.reject(failure)\n }\n const quality = normalizeCompressImageQuality(options?.quality)\n try {\n const tempFilePath = await compressImageByCanvas(src, quality)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'compressImage:ok',\n tempFilePath,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `compressImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport function compressVideoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'compressVideo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetCompressVideo(src)\n const result = preset ?? {\n tempFilePath: src,\n size: 0,\n duration: 0,\n width: 0,\n height: 0,\n bitrate: 0,\n fps: 0,\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'compressVideo:ok',\n ...result,\n }))\n}\n"],"mappings":";;;;;AAUA,eAAsB,oBAAoB,SAAe;CACvD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,UAAU,8BAA8B,SAAS,OAAO;CAC9D,IAAI;EACF,MAAM,eAAe,MAAM,sBAAsB,KAAK,OAAO;EAC7D,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR;EACF,CAAC;CACH,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,UAAU,4BAA4B,SAAS,sBAAsB,SAAS;EACpF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,SAAgB,oBAAoB,SAAe;CACjD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,KAAK,IAAI;CACpE,IAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CAEA,MAAM,SADS,wBAAwB,GACnB,KAAK;EACvB,cAAc;EACd,MAAM;EACN,UAAU;EACV,OAAO;EACP,QAAQ;EACR,SAAS;EACT,KAAK;CACP;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,GAAG;CACL,CAAC,CAAC;AACJ"}
@@ -1,6 +1,7 @@
1
+ import { setTabBarBadgeState, setTabBarRedDotState, setTabBarVisible, updateTabBarItem, updateTabBarStyle } from "../appShell/tabBar/index.mjs";
1
2
  import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
2
- import { normalizeActionSheetItems, resolveActionSheetSelection, resolveModalSelection } from "./ui.mjs";
3
3
  import { readNetworkStatusSnapshot } from "./network/status.mjs";
4
+ import { normalizeActionSheetItems, resolveActionSheetSelection, resolveModalSelection } from "./ui.mjs";
4
5
  import { normalizeSubscribeTemplateIds, resolveSubscribeDecisionMap } from "./subscribe.mjs";
5
6
 
6
7
  //#region src/runtime/polyfill/menuApi.ts
@@ -11,11 +12,45 @@ function getNetworkTypeBridge(options) {
11
12
  ...status
12
13
  }));
13
14
  }
15
+ function resolveTabBarMutation(action, options, succeeded, failureReason = "tabBar not configured") {
16
+ if (succeeded) return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: `${action}:ok` }));
17
+ const failure = callMiniProgramAsyncFailure(options, `${action}:fail ${failureReason}`);
18
+ return Promise.reject(failure);
19
+ }
14
20
  function showTabBarBridge(options) {
15
- return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "showTabBar:ok" }));
21
+ return resolveTabBarMutation("showTabBar", options, setTabBarVisible(true, options?.animation === true));
16
22
  }
17
23
  function hideTabBarBridge(options) {
18
- return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "hideTabBar:ok" }));
24
+ return resolveTabBarMutation("hideTabBar", options, setTabBarVisible(false, options?.animation === true));
25
+ }
26
+ function setTabBarItemBridge(options) {
27
+ const patch = {
28
+ ...typeof options?.text === "string" ? { text: options.text } : {},
29
+ ...typeof options?.iconPath === "string" ? { iconPath: options.iconPath } : {},
30
+ ...typeof options?.selectedIconPath === "string" ? { selectedIconPath: options.selectedIconPath } : {}
31
+ };
32
+ return resolveTabBarMutation("setTabBarItem", options, updateTabBarItem(options?.index, patch), "invalid index");
33
+ }
34
+ function setTabBarStyleBridge(options) {
35
+ const patch = {
36
+ ...typeof options?.color === "string" ? { color: options.color } : {},
37
+ ...typeof options?.selectedColor === "string" ? { selectedColor: options.selectedColor } : {},
38
+ ...typeof options?.backgroundColor === "string" ? { backgroundColor: options.backgroundColor } : {},
39
+ ...options?.borderStyle === "black" || options?.borderStyle === "white" ? { borderStyle: options.borderStyle } : {}
40
+ };
41
+ return resolveTabBarMutation("setTabBarStyle", options, updateTabBarStyle(patch));
42
+ }
43
+ function setTabBarBadgeBridge(options) {
44
+ return resolveTabBarMutation("setTabBarBadge", options, typeof options?.text === "string" && setTabBarBadgeState(options?.index, options.text), "invalid index or text");
45
+ }
46
+ function removeTabBarBadgeBridge(options) {
47
+ return resolveTabBarMutation("removeTabBarBadge", options, setTabBarBadgeState(options?.index, void 0), "invalid index");
48
+ }
49
+ function showTabBarRedDotBridge(options) {
50
+ return resolveTabBarMutation("showTabBarRedDot", options, setTabBarRedDotState(options?.index, true), "invalid index");
51
+ }
52
+ function hideTabBarRedDotBridge(options) {
53
+ return resolveTabBarMutation("hideTabBarRedDot", options, setTabBarRedDotState(options?.index, false), "invalid index");
19
54
  }
20
55
  function requestPaymentBridge(options) {
21
56
  return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "requestPayment:ok" }));
@@ -66,5 +101,5 @@ function updateShareMenuBridge(options) {
66
101
  }
67
102
 
68
103
  //#endregion
69
- export { getNetworkTypeBridge, hideTabBarBridge, requestPaymentBridge, requestSubscribeMessageBridge, showActionSheetBridge, showModalBridge, showShareMenuBridge, showTabBarBridge, updateShareMenuBridge };
104
+ export { getNetworkTypeBridge, hideTabBarBridge, hideTabBarRedDotBridge, removeTabBarBadgeBridge, requestPaymentBridge, requestSubscribeMessageBridge, setTabBarBadgeBridge, setTabBarItemBridge, setTabBarStyleBridge, showActionSheetBridge, showModalBridge, showShareMenuBridge, showTabBarBridge, showTabBarRedDotBridge, updateShareMenuBridge };
70
105
  //# sourceMappingURL=menuApi.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"menuApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/menuApi.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport { readNetworkStatusSnapshot } from './network'\nimport {\n normalizeSubscribeTemplateIds,\n resolveSubscribeDecisionMap,\n} from './subscribe'\nimport {\n normalizeActionSheetItems,\n resolveActionSheetSelection,\n resolveModalSelection,\n} from './ui'\n\nexport function getNetworkTypeBridge(options?: any): Promise<any> {\n const status = readNetworkStatusSnapshot()\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'getNetworkType:ok',\n ...status,\n }))\n}\n\nexport function showTabBarBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'showTabBar:ok' }))\n}\n\nexport function hideTabBarBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'hideTabBar:ok' }))\n}\n\nexport function requestPaymentBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'requestPayment:ok' }))\n}\n\nexport function requestSubscribeMessageBridge(options?: any): Promise<any> {\n const tmplIds = normalizeSubscribeTemplateIds(options?.tmplIds)\n if (tmplIds.length === 0) {\n const failure = callMiniProgramAsyncFailure(options, 'requestSubscribeMessage:fail invalid tmplIds')\n return Promise.reject(failure)\n }\n const decisionMap = resolveSubscribeDecisionMap(tmplIds)\n const result: Record<string, any> & { errMsg: string } = tmplIds.reduce<Record<string, any> & { errMsg: string }>((payload, tmplId) => {\n payload[tmplId] = decisionMap[tmplId]\n return payload\n }, { errMsg: 'requestSubscribeMessage:ok' })\n return Promise.resolve(callMiniProgramAsyncSuccess(options, result))\n}\n\nexport function showModalBridge(options?: any): Promise<any> {\n const modalResult = resolveModalSelection(options)\n const result = {\n errMsg: 'showModal:ok',\n confirm: modalResult.confirm,\n cancel: modalResult.cancel,\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, result))\n}\n\nexport function showActionSheetBridge(options?: any): Promise<any> {\n const itemList = normalizeActionSheetItems(options?.itemList)\n if (!itemList.length) {\n const failure = callMiniProgramAsyncFailure(options, 'showActionSheet:fail invalid itemList')\n return Promise.reject(failure)\n }\n const tapIndex = resolveActionSheetSelection(itemList)\n if (tapIndex === null) {\n const failure = callMiniProgramAsyncFailure(options, 'showActionSheet:fail cancel')\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'showActionSheet:ok',\n tapIndex,\n }))\n}\n\nexport function showShareMenuBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'showShareMenu:ok' }))\n}\n\nexport function updateShareMenuBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'updateShareMenu:ok' }))\n}\n"],"mappings":";;;;;;AAeA,SAAgB,qBAAqB,SAA6B;CAChE,MAAM,SAAS,0BAA0B;CACzC,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,GAAG;CACL,CAAC,CAAC;AACJ;AAEA,SAAgB,iBAAiB,SAA6B;CAC5D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,gBAAgB,CAAC,CAAC;AAC1F;AAEA,SAAgB,iBAAiB,SAA6B;CAC5D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,gBAAgB,CAAC,CAAC;AAC1F;AAEA,SAAgB,qBAAqB,SAA6B;CAChE,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,oBAAoB,CAAC,CAAC;AAC9F;AAEA,SAAgB,8BAA8B,SAA6B;CACzE,MAAM,UAAU,8BAA8B,SAAS,OAAO;CAC9D,IAAI,QAAQ,WAAW,GAAG;EACxB,MAAM,UAAU,4BAA4B,SAAS,8CAA8C;EACnG,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,cAAc,4BAA4B,OAAO;CACvD,MAAM,SAAmD,QAAQ,QAAkD,SAAS,WAAW;EACrI,QAAQ,UAAU,YAAY;EAC9B,OAAO;CACT,GAAG,EAAE,QAAQ,6BAA6B,CAAC;CAC3C,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,MAAM,CAAC;AACrE;AAEA,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,cAAc,sBAAsB,OAAO;CACjD,MAAM,SAAS;EACb,QAAQ;EACR,SAAS,YAAY;EACrB,QAAQ,YAAY;CACtB;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,MAAM,CAAC;AACrE;AAEA,SAAgB,sBAAsB,SAA6B;CACjE,MAAM,WAAW,0BAA0B,SAAS,QAAQ;CAC5D,IAAI,CAAC,SAAS,QAAQ;EACpB,MAAM,UAAU,4BAA4B,SAAS,uCAAuC;EAC5F,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,WAAW,4BAA4B,QAAQ;CACrD,IAAI,aAAa,MAAM;EACrB,MAAM,UAAU,4BAA4B,SAAS,6BAA6B;EAClF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR;CACF,CAAC,CAAC;AACJ;AAEA,SAAgB,oBAAoB,SAA6B;CAC/D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,mBAAmB,CAAC,CAAC;AAC7F;AAEA,SAAgB,sBAAsB,SAA6B;CACjE,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,qBAAqB,CAAC,CAAC;AAC/F"}
1
+ {"version":3,"file":"menuApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/menuApi.ts"],"sourcesContent":["import {\n setTabBarBadgeState,\n setTabBarRedDotState,\n setTabBarVisible,\n updateTabBarItem,\n updateTabBarStyle,\n} from '../appShell/tabBar'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport { readNetworkStatusSnapshot } from './network'\nimport {\n normalizeSubscribeTemplateIds,\n resolveSubscribeDecisionMap,\n} from './subscribe'\nimport {\n normalizeActionSheetItems,\n resolveActionSheetSelection,\n resolveModalSelection,\n} from './ui'\n\nexport function getNetworkTypeBridge(options?: any): Promise<any> {\n const status = readNetworkStatusSnapshot()\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'getNetworkType:ok',\n ...status,\n }))\n}\n\nfunction resolveTabBarMutation(action: string, options: any, succeeded: boolean, failureReason = 'tabBar not configured') {\n if (succeeded) {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: `${action}:ok` }))\n }\n const failure = callMiniProgramAsyncFailure(options, `${action}:fail ${failureReason}`)\n return Promise.reject(failure)\n}\n\nexport function showTabBarBridge(options?: any): Promise<any> {\n return resolveTabBarMutation('showTabBar', options, setTabBarVisible(true, options?.animation === true))\n}\n\nexport function hideTabBarBridge(options?: any): Promise<any> {\n return resolveTabBarMutation('hideTabBar', options, setTabBarVisible(false, options?.animation === true))\n}\n\nexport function setTabBarItemBridge(options?: any): Promise<any> {\n const patch = {\n ...(typeof options?.text === 'string' ? { text: options.text } : {}),\n ...(typeof options?.iconPath === 'string' ? { iconPath: options.iconPath } : {}),\n ...(typeof options?.selectedIconPath === 'string' ? { selectedIconPath: options.selectedIconPath } : {}),\n }\n return resolveTabBarMutation('setTabBarItem', options, updateTabBarItem(options?.index, patch), 'invalid index')\n}\n\nexport function setTabBarStyleBridge(options?: any): Promise<any> {\n const patch = {\n ...(typeof options?.color === 'string' ? { color: options.color } : {}),\n ...(typeof options?.selectedColor === 'string' ? { selectedColor: options.selectedColor } : {}),\n ...(typeof options?.backgroundColor === 'string' ? { backgroundColor: options.backgroundColor } : {}),\n ...(options?.borderStyle === 'black' || options?.borderStyle === 'white'\n ? { borderStyle: options.borderStyle }\n : {}),\n }\n return resolveTabBarMutation('setTabBarStyle', options, updateTabBarStyle(patch))\n}\n\nexport function setTabBarBadgeBridge(options?: any): Promise<any> {\n const succeeded = typeof options?.text === 'string'\n && setTabBarBadgeState(options?.index, options.text)\n return resolveTabBarMutation('setTabBarBadge', options, succeeded, 'invalid index or text')\n}\n\nexport function removeTabBarBadgeBridge(options?: any): Promise<any> {\n return resolveTabBarMutation(\n 'removeTabBarBadge',\n options,\n setTabBarBadgeState(options?.index, undefined),\n 'invalid index',\n )\n}\n\nexport function showTabBarRedDotBridge(options?: any): Promise<any> {\n return resolveTabBarMutation('showTabBarRedDot', options, setTabBarRedDotState(options?.index, true), 'invalid index')\n}\n\nexport function hideTabBarRedDotBridge(options?: any): Promise<any> {\n return resolveTabBarMutation('hideTabBarRedDot', options, setTabBarRedDotState(options?.index, false), 'invalid index')\n}\n\nexport function requestPaymentBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'requestPayment:ok' }))\n}\n\nexport function requestSubscribeMessageBridge(options?: any): Promise<any> {\n const tmplIds = normalizeSubscribeTemplateIds(options?.tmplIds)\n if (tmplIds.length === 0) {\n const failure = callMiniProgramAsyncFailure(options, 'requestSubscribeMessage:fail invalid tmplIds')\n return Promise.reject(failure)\n }\n const decisionMap = resolveSubscribeDecisionMap(tmplIds)\n const result: Record<string, any> & { errMsg: string } = tmplIds.reduce<Record<string, any> & { errMsg: string }>((payload, tmplId) => {\n payload[tmplId] = decisionMap[tmplId]\n return payload\n }, { errMsg: 'requestSubscribeMessage:ok' })\n return Promise.resolve(callMiniProgramAsyncSuccess(options, result))\n}\n\nexport function showModalBridge(options?: any): Promise<any> {\n const modalResult = resolveModalSelection(options)\n const result = {\n errMsg: 'showModal:ok',\n confirm: modalResult.confirm,\n cancel: modalResult.cancel,\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, result))\n}\n\nexport function showActionSheetBridge(options?: any): Promise<any> {\n const itemList = normalizeActionSheetItems(options?.itemList)\n if (!itemList.length) {\n const failure = callMiniProgramAsyncFailure(options, 'showActionSheet:fail invalid itemList')\n return Promise.reject(failure)\n }\n const tapIndex = resolveActionSheetSelection(itemList)\n if (tapIndex === null) {\n const failure = callMiniProgramAsyncFailure(options, 'showActionSheet:fail cancel')\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'showActionSheet:ok',\n tapIndex,\n }))\n}\n\nexport function showShareMenuBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'showShareMenu:ok' }))\n}\n\nexport function updateShareMenuBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'updateShareMenu:ok' }))\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,qBAAqB,SAA6B;CAChE,MAAM,SAAS,0BAA0B;CACzC,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,GAAG;CACL,CAAC,CAAC;AACJ;AAEA,SAAS,sBAAsB,QAAgB,SAAc,WAAoB,gBAAgB,yBAAyB;CACxH,IAAI,WACF,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,GAAG,OAAO,KAAK,CAAC,CAAC;CAEzF,MAAM,UAAU,4BAA4B,SAAS,GAAG,OAAO,QAAQ,eAAe;CACtF,OAAO,QAAQ,OAAO,OAAO;AAC/B;AAEA,SAAgB,iBAAiB,SAA6B;CAC5D,OAAO,sBAAsB,cAAc,SAAS,iBAAiB,MAAM,SAAS,cAAc,IAAI,CAAC;AACzG;AAEA,SAAgB,iBAAiB,SAA6B;CAC5D,OAAO,sBAAsB,cAAc,SAAS,iBAAiB,OAAO,SAAS,cAAc,IAAI,CAAC;AAC1G;AAEA,SAAgB,oBAAoB,SAA6B;CAC/D,MAAM,QAAQ;EACZ,GAAI,OAAO,SAAS,SAAS,WAAW,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;EAClE,GAAI,OAAO,SAAS,aAAa,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;EAC9E,GAAI,OAAO,SAAS,qBAAqB,WAAW,EAAE,kBAAkB,QAAQ,iBAAiB,IAAI,CAAC;CACxG;CACA,OAAO,sBAAsB,iBAAiB,SAAS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;CACA,MAAM,cAAc,4BAA4B,OAAO;CACvD,MAAM,SAAmD,QAAQ,QAAkD,SAAS,WAAW;EACrI,QAAQ,UAAU,YAAY;EAC9B,OAAO;CACT,GAAG,EAAE,QAAQ,6BAA6B,CAAC;CAC3C,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,MAAM,CAAC;AACrE;AAEA,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,cAAc,sBAAsB,OAAO;CACjD,MAAM,SAAS;EACb,QAAQ;EACR,SAAS,YAAY;EACrB,QAAQ,YAAY;CACtB;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,MAAM,CAAC;AACrE;AAEA,SAAgB,sBAAsB,SAA6B;CACjE,MAAM,WAAW,0BAA0B,SAAS,QAAQ;CAC5D,IAAI,CAAC,SAAS,QAAQ;EACpB,MAAM,UAAU,4BAA4B,SAAS,uCAAuC;EAC5F,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,MAAM,WAAW,4BAA4B,QAAQ;CACrD,IAAI,aAAa,MAAM;EACrB,MAAM,UAAU,4BAA4B,SAAS,6BAA6B;EAClF,OAAO,QAAQ,OAAO,OAAO;CAC/B;CACA,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR;CACF,CAAC,CAAC;AACJ;AAEA,SAAgB,oBAAoB,SAA6B;CAC/D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,mBAAmB,CAAC,CAAC;AAC7F;AAEA,SAAgB,sBAAsB,SAA6B;CACjE,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,qBAAqB,CAAC,CAAC;AAC/F"}
@@ -1,3 +1,5 @@
1
+ import { updateWebDocumentTitle } from "../seo/index.mjs";
2
+
1
3
  //#region src/runtime/polyfill/navigationBarRuntime.ts
2
4
  function getActiveNavigationBar(pages) {
3
5
  const current = pages[pages.length - 1];
@@ -21,7 +23,10 @@ function createNavigationBarRuntimeBridge(getCurrentPages, emitWarning) {
21
23
  warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}setNavigationBarTitle`);
22
24
  return Promise.resolve();
23
25
  }
24
- if (options?.title !== void 0) bar.setAttribute("title", options.title);
26
+ if (options?.title !== void 0) {
27
+ bar.setAttribute("title", options.title);
28
+ updateWebDocumentTitle(options.title);
29
+ }
25
30
  return Promise.resolve();
26
31
  },
27
32
  setNavigationBarColor(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"navigationBarRuntime.mjs","names":[],"sources":["../../../src/runtime/polyfill/navigationBarRuntime.ts"],"sourcesContent":["interface RuntimeWarningOptions {\n key: string\n context: string\n}\n\ntype RuntimeWarningEmitter = (message: string, options: RuntimeWarningOptions) => void\n\ninterface PageLike extends HTMLElement {\n renderRoot?: ShadowRoot | HTMLElement\n}\n\nfunction getActiveNavigationBar(pages: PageLike[]) {\n const current = pages[pages.length - 1]\n if (!current) {\n return undefined\n }\n const renderRoot = current.renderRoot\n ?? current.shadowRoot\n ?? current\n if (!renderRoot || typeof (renderRoot as ParentNode).querySelector !== 'function') {\n return undefined\n }\n return (renderRoot as ParentNode).querySelector('weapp-navigation-bar') as HTMLElement | null\n}\n\nfunction warnNavigationBarMissing(emitWarning: RuntimeWarningEmitter, action: string) {\n emitWarning(`[@weapp-vite/web] ${action} 需要默认导航栏支持,但当前页面未渲染 weapp-navigation-bar。`, {\n key: 'navigation-bar-missing',\n context: 'runtime:navigation',\n })\n}\n\nexport function createNavigationBarRuntimeBridge(\n getCurrentPages: () => PageLike[],\n emitWarning: RuntimeWarningEmitter,\n) {\n const navigationBarActionPrefix = 'miniProgram.'\n\n return {\n setNavigationBarTitle(options: { title: string }) {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}setNavigationBarTitle`)\n return Promise.resolve()\n }\n if (options?.title !== undefined) {\n bar.setAttribute('title', options.title)\n }\n return Promise.resolve()\n },\n setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n }) {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}setNavigationBarColor`)\n return Promise.resolve()\n }\n if (options?.frontColor) {\n bar.setAttribute('front-color', options.frontColor)\n }\n if (options?.backgroundColor) {\n bar.setAttribute('background-color', options.backgroundColor)\n }\n if (options?.animation) {\n const duration = typeof options.animation.duration === 'number'\n ? `${options.animation.duration}ms`\n : undefined\n const easing = options.animation.timingFunction\n if (duration) {\n bar.style.setProperty('--weapp-nav-transition-duration', duration)\n }\n if (easing) {\n bar.style.setProperty('--weapp-nav-transition-easing', easing)\n }\n }\n return Promise.resolve()\n },\n showNavigationBarLoading() {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}showNavigationBarLoading`)\n return Promise.resolve()\n }\n bar.setAttribute('loading', 'true')\n return Promise.resolve()\n },\n hideNavigationBarLoading() {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}hideNavigationBarLoading`)\n return Promise.resolve()\n }\n bar.removeAttribute('loading')\n return Promise.resolve()\n },\n }\n}\n"],"mappings":";AAWA,SAAS,uBAAuB,OAAmB;CACjD,MAAM,UAAU,MAAM,MAAM,SAAS;CACrC,IAAI,CAAC,SACH;CAEF,MAAM,aAAa,QAAQ,cACtB,QAAQ,cACR;CACL,IAAI,CAAC,cAAc,OAAQ,WAA0B,kBAAkB,YACrE;CAEF,OAAQ,WAA0B,cAAc,sBAAsB;AACxE;AAEA,SAAS,yBAAyB,aAAoC,QAAgB;CACpF,YAAY,qBAAqB,OAAO,4CAA4C;EAClF,KAAK;EACL,SAAS;CACX,CAAC;AACH;AAEA,SAAgB,iCACd,iBACA,aACA;CACA,MAAM,4BAA4B;CAElC,OAAO;EACL,sBAAsB,SAA4B;GAChD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"navigationBarRuntime.mjs","names":[],"sources":["../../../src/runtime/polyfill/navigationBarRuntime.ts"],"sourcesContent":["import { updateWebDocumentTitle } from '../seo'\n\ninterface RuntimeWarningOptions {\n key: string\n context: string\n}\n\ntype RuntimeWarningEmitter = (message: string, options: RuntimeWarningOptions) => void\n\ninterface PageLike extends HTMLElement {\n renderRoot?: ShadowRoot | HTMLElement\n}\n\nfunction getActiveNavigationBar(pages: PageLike[]) {\n const current = pages[pages.length - 1]\n if (!current) {\n return undefined\n }\n const renderRoot = current.renderRoot\n ?? current.shadowRoot\n ?? current\n if (!renderRoot || typeof (renderRoot as ParentNode).querySelector !== 'function') {\n return undefined\n }\n return (renderRoot as ParentNode).querySelector('weapp-navigation-bar') as HTMLElement | null\n}\n\nfunction warnNavigationBarMissing(emitWarning: RuntimeWarningEmitter, action: string) {\n emitWarning(`[@weapp-vite/web] ${action} 需要默认导航栏支持,但当前页面未渲染 weapp-navigation-bar。`, {\n key: 'navigation-bar-missing',\n context: 'runtime:navigation',\n })\n}\n\nexport function createNavigationBarRuntimeBridge(\n getCurrentPages: () => PageLike[],\n emitWarning: RuntimeWarningEmitter,\n) {\n const navigationBarActionPrefix = 'miniProgram.'\n\n return {\n setNavigationBarTitle(options: { title: string }) {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}setNavigationBarTitle`)\n return Promise.resolve()\n }\n if (options?.title !== undefined) {\n bar.setAttribute('title', options.title)\n updateWebDocumentTitle(options.title)\n }\n return Promise.resolve()\n },\n setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n }) {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}setNavigationBarColor`)\n return Promise.resolve()\n }\n if (options?.frontColor) {\n bar.setAttribute('front-color', options.frontColor)\n }\n if (options?.backgroundColor) {\n bar.setAttribute('background-color', options.backgroundColor)\n }\n if (options?.animation) {\n const duration = typeof options.animation.duration === 'number'\n ? `${options.animation.duration}ms`\n : undefined\n const easing = options.animation.timingFunction\n if (duration) {\n bar.style.setProperty('--weapp-nav-transition-duration', duration)\n }\n if (easing) {\n bar.style.setProperty('--weapp-nav-transition-easing', easing)\n }\n }\n return Promise.resolve()\n },\n showNavigationBarLoading() {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}showNavigationBarLoading`)\n return Promise.resolve()\n }\n bar.setAttribute('loading', 'true')\n return Promise.resolve()\n },\n hideNavigationBarLoading() {\n const bar = getActiveNavigationBar(getCurrentPages())\n if (!bar) {\n warnNavigationBarMissing(emitWarning, `${navigationBarActionPrefix}hideNavigationBarLoading`)\n return Promise.resolve()\n }\n bar.removeAttribute('loading')\n return Promise.resolve()\n },\n }\n}\n"],"mappings":";;;AAaA,SAAS,uBAAuB,OAAmB;CACjD,MAAM,UAAU,MAAM,MAAM,SAAS;CACrC,IAAI,CAAC,SACH;CAEF,MAAM,aAAa,QAAQ,cACtB,QAAQ,cACR;CACL,IAAI,CAAC,cAAc,OAAQ,WAA0B,kBAAkB,YACrE;CAEF,OAAQ,WAA0B,cAAc,sBAAsB;AACxE;AAEA,SAAS,yBAAyB,aAAoC,QAAgB;CACpF,YAAY,qBAAqB,OAAO,4CAA4C;EAClF,KAAK;EACL,SAAS;CACX,CAAC;AACH;AAEA,SAAgB,iCACd,iBACA,aACA;CACA,MAAM,4BAA4B;CAElC,OAAO;EACL,sBAAsB,SAA4B;GAChD,MAAM,MAAM,uBAAuB,gBAAgB,CAAC;GACpD,IAAI,CAAC,KAAK;IACR,yBAAyB,aAAa,GAAG,0BAA0B,sBAAsB;IACzF,OAAO,QAAQ,QAAQ;GACzB;GACA,IAAI,SAAS,UAAU,QAAW;IAChC,IAAI,aAAa,SAAS,QAAQ,KAAK;IACvC,uBAAuB,QAAQ,KAAK;GACtC;GACA,OAAO,QAAQ,QAAQ;EACzB;EACA,sBAAsB,SAInB;GACD,MAAM,MAAM,uBAAuB,gBAAgB,CAAC;GACpD,IAAI,CAAC,KAAK;IACR,yBAAyB,aAAa,GAAG,0BAA0B,sBAAsB;IACzF,OAAO,QAAQ,QAAQ;GACzB;GACA,IAAI,SAAS,YACX,IAAI,aAAa,eAAe,QAAQ,UAAU;GAEpD,IAAI,SAAS,iBACX,IAAI,aAAa,oBAAoB,QAAQ,eAAe;GAE9D,IAAI,SAAS,WAAW;IACtB,MAAM,WAAW,OAAO,QAAQ,UAAU,aAAa,WACnD,GAAG,QAAQ,UAAU,SAAS,MAC9B;IACJ,MAAM,SAAS,QAAQ,UAAU;IACjC,IAAI,UACF,IAAI,MAAM,YAAY,mCAAmC,QAAQ;IAEnE,IAAI,QACF,IAAI,MAAM,YAAY,iCAAiC,MAAM;GAEjE;GACA,OAAO,QAAQ,QAAQ;EACzB;EACA,2BAA2B;GACzB,MAAM,MAAM,uBAAuB,gBAAgB,CAAC;GACpD,IAAI,CAAC,KAAK;IACR,yBAAyB,aAAa,GAAG,0BAA0B,yBAAyB;IAC5F,OAAO,QAAQ,QAAQ;GACzB;GACA,IAAI,aAAa,WAAW,MAAM;GAClC,OAAO,QAAQ,QAAQ;EACzB;EACA,2BAA2B;GACzB,MAAM,MAAM,uBAAuB,gBAAgB,CAAC;GACpD,IAAI,CAAC,KAAK;IACR,yBAAyB,aAAa,GAAG,0BAA0B,yBAAyB;IAC5F,OAAO,QAAQ,QAAQ;GACzB;GACA,IAAI,gBAAgB,SAAS;GAC7B,OAAO,QAAQ,QAAQ;EACzB;CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import { getRuntimeFetch as getRuntimeFetch$1 } from "../../host/index.mjs";
1
2
  import { normalizeFilePath, resolveUploadFileBlob, resolveUploadFileName } from "../files.mjs";
2
3
 
3
4
  //#region src/runtime/polyfill/network/request.ts
@@ -13,8 +14,7 @@ function resolveTimeoutSignal(timeout) {
13
14
  };
14
15
  }
15
16
  function getRuntimeFetch() {
16
- const maybeFetch = globalThis.fetch;
17
- if (typeof maybeFetch === "function") return maybeFetch;
17
+ return getRuntimeFetch$1();
18
18
  }
19
19
  function normalizeRequestMethod(method) {
20
20
  return (method || "GET").toUpperCase();
@@ -1 +1 @@
1
- {"version":3,"file":"request.mjs","names":["runtime"],"sources":["../../../../src/runtime/polyfill/network/request.ts"],"sourcesContent":["import {\n normalizeFilePath,\n resolveUploadFileBlob,\n resolveUploadFileName,\n} from '../files'\n\ninterface RequestParseOptions {\n responseType?: 'text' | 'arraybuffer'\n dataType?: 'json' | 'text'\n}\n\ninterface RequestLikeOptions extends RequestParseOptions {\n url?: string\n method?: string\n header?: Record<string, string>\n data?: unknown\n timeout?: number\n}\n\ninterface DownloadLikeOptions {\n url?: string\n header?: Record<string, string>\n timeout?: number\n}\n\ninterface UploadLikeOptions {\n url?: string\n filePath?: string\n header?: Record<string, string>\n formData?: Record<string, unknown>\n name?: string\n timeout?: number\n}\n\nfunction resolveTimeoutSignal(timeout: number) {\n const controller = typeof AbortController === 'function' ? new AbortController() : undefined\n let timeoutTimer: ReturnType<typeof setTimeout> | undefined\n if (timeout > 0 && controller) {\n timeoutTimer = setTimeout(() => controller.abort(), timeout)\n }\n return {\n signal: controller?.signal,\n clear: () => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n }\n },\n }\n}\n\nexport function getRuntimeFetch() {\n const runtime = globalThis as Record<string, unknown>\n const maybeFetch = runtime.fetch\n if (typeof maybeFetch === 'function') {\n return maybeFetch as typeof fetch\n }\n return undefined\n}\n\nexport function normalizeRequestMethod(method?: string) {\n return (method || 'GET').toUpperCase()\n}\n\nexport function normalizeRequestHeaders(header?: Record<string, string>) {\n if (!header) {\n return {}\n }\n return { ...header }\n}\n\nexport function buildRequestUrl(url: string, method: string, data: unknown) {\n if (method !== 'GET' || data == null) {\n return url\n }\n if (typeof data === 'string') {\n if (!data) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${data}`\n }\n if (typeof URLSearchParams !== 'undefined' && data instanceof URLSearchParams) {\n const query = data.toString()\n if (!query) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${query}`\n }\n if (typeof data === 'object') {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(data as Record<string, unknown>)) {\n query.append(key, value == null ? '' : String(value))\n }\n const queryText = query.toString()\n if (!queryText) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${queryText}`\n }\n return url\n}\n\nexport function buildRequestBody(\n method: string,\n data: unknown,\n headers: Record<string, string>,\n) {\n if (method === 'GET' || data == null) {\n return undefined\n }\n if (typeof data === 'string') {\n return data\n }\n if (typeof URLSearchParams !== 'undefined' && data instanceof URLSearchParams) {\n return data\n }\n if (typeof FormData !== 'undefined' && data instanceof FormData) {\n return data\n }\n const contentTypeKey = Object.keys(headers).find(key => key.toLowerCase() === 'content-type')\n const contentType = contentTypeKey ? headers[contentTypeKey] : ''\n if (contentType && !contentType.includes('application/json')) {\n return String(data)\n }\n if (!contentTypeKey) {\n headers['content-type'] = 'application/json'\n }\n return JSON.stringify(data)\n}\n\nexport async function parseRequestResponseData(\n response: Response,\n options?: RequestParseOptions,\n) {\n if (options?.responseType === 'arraybuffer') {\n return response.arrayBuffer()\n }\n const contentType = response.headers.get('content-type') ?? ''\n if (options?.dataType === 'text') {\n return response.text()\n }\n if (options?.dataType === 'json' || contentType.includes('application/json')) {\n return response.json()\n }\n return response.text()\n}\n\nexport function createBlobObjectUrl(blob: Blob) {\n const runtimeUrl = (globalThis as {\n URL?: {\n createObjectURL?: (value: Blob) => string\n }\n }).URL\n if (runtimeUrl && typeof runtimeUrl.createObjectURL === 'function') {\n return runtimeUrl.createObjectURL(blob)\n }\n return ''\n}\n\nexport function collectResponseHeaders(response: {\n headers: {\n forEach: (callback: (value: string, key: string) => void) => void\n }\n}) {\n const headers: Record<string, string> = {}\n response.headers.forEach((value, key) => {\n headers[key] = value\n })\n return headers\n}\n\nexport function stripUploadContentType(headers: Record<string, string>) {\n const normalized = { ...headers }\n for (const key of Object.keys(normalized)) {\n if (key.toLowerCase() === 'content-type') {\n delete normalized[key]\n }\n }\n return normalized\n}\n\nexport async function performRequestByFetch(options?: RequestLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const method = normalizeRequestMethod(options?.method)\n const headers = normalizeRequestHeaders(options?.header)\n const requestUrl = buildRequestUrl(url, method, options?.data)\n const body = buildRequestBody(method, options?.data, headers)\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(requestUrl, {\n method,\n headers,\n body,\n signal: timeoutControl.signal,\n })\n const responseData = await parseRequestResponseData(response, options)\n return {\n data: responseData,\n statusCode: response.status,\n header: collectResponseHeaders(response),\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n\nexport async function performDownloadByFetch(options?: DownloadLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const headers = normalizeRequestHeaders(options?.header)\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(url, {\n method: 'GET',\n headers,\n signal: timeoutControl.signal,\n })\n const blob = await response.blob()\n return {\n tempFilePath: createBlobObjectUrl(blob) || url,\n statusCode: response.status,\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n\nexport async function performUploadByFetch(options?: UploadLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n throw new TypeError('invalid filePath')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const FormDataCtor = (globalThis as { FormData?: typeof FormData }).FormData\n if (typeof FormDataCtor !== 'function') {\n throw new TypeError('FormData is unavailable')\n }\n\n const headers = stripUploadContentType(normalizeRequestHeaders(options?.header))\n const formData = new FormDataCtor()\n for (const [key, value] of Object.entries(options?.formData ?? {})) {\n formData.append(key, value == null ? '' : String(value))\n }\n const blob = await resolveUploadFileBlob(filePath, runtimeFetch)\n formData.append(options?.name?.trim() || 'file', blob, resolveUploadFileName(filePath))\n\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(url, {\n method: 'POST',\n headers,\n body: formData,\n signal: timeoutControl.signal,\n })\n const data = await response.text()\n return {\n data,\n statusCode: response.status,\n header: collectResponseHeaders(response),\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n"],"mappings":";;;AAkCA,SAAS,qBAAqB,SAAiB;CAC7C,MAAM,aAAa,OAAO,oBAAoB,aAAa,IAAI,gBAAgB,IAAI;CACnF,IAAI;CACJ,IAAI,UAAU,KAAK,YACjB,eAAe,iBAAiB,WAAW,MAAM,GAAG,OAAO;CAE7D,OAAO;EACL,QAAQ,YAAY;EACpB,aAAa;GACX,IAAI,cACF,aAAa,YAAY;EAE7B;CACF;AACF;AAEA,SAAgB,kBAAkB;CAEhC,MAAM,aAAaA,WAAQ;CAC3B,IAAI,OAAO,eAAe,YACxB,OAAO;AAGX;AAEA,SAAgB,uBAAuB,QAAiB;CACtD,QAAQ,UAAU,MAAK,CAAE,YAAY;AACvC;AAEA,SAAgB,wBAAwB,QAAiC;CACvE,IAAI,CAAC,QACH,OAAO,CAAC;CAEV,OAAO,EAAE,GAAG,OAAO;AACrB;AAEA,SAAgB,gBAAgB,KAAa,QAAgB,MAAe;CAC1E,IAAI,WAAW,SAAS,QAAQ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OAAO,KAAK,CAAC;CAEzD,MAAM,OAAO,MAAM,sBAAsB,UAAU,YAAY;CAC/D,SAAS,OAAO,SAAS,MAAM,KAAK,KAAK,QAAQ,MAAM,sBAAsB,QAAQ,CAAC;CAGtF,MAAM,iBAAiB,qBADP,OAAO,SAAS,YAAY,YAAY,QAAQ,UAAU,IAAI,QAAQ,UAAU,CAC7C;CAEnD,IAAI;EACF,MAAM,WAAW,MAAM,aAAa,KAAK;GACvC,QAAQ;GACR;GACA,MAAM;GACN,QAAQ,eAAe;EACzB,CAAC;EAED,OAAO;GACL,YAFiB,SAAS,KAAK;GAG/B,YAAY,SAAS;GACrB,QAAQ,uBAAuB,QAAQ;EACzC;CACF,UACQ;EACN,eAAe,MAAM;CACvB;AACF"}
1
+ {"version":3,"file":"request.mjs","names":["getHostRuntimeFetch"],"sources":["../../../../src/runtime/polyfill/network/request.ts"],"sourcesContent":["import { getRuntimeFetch as getHostRuntimeFetch } from '../../host'\nimport {\n normalizeFilePath,\n resolveUploadFileBlob,\n resolveUploadFileName,\n} from '../files'\n\ninterface RequestParseOptions {\n responseType?: 'text' | 'arraybuffer'\n dataType?: 'json' | 'text'\n}\n\ninterface RequestLikeOptions extends RequestParseOptions {\n url?: string\n method?: string\n header?: Record<string, string>\n data?: unknown\n timeout?: number\n}\n\ninterface DownloadLikeOptions {\n url?: string\n header?: Record<string, string>\n timeout?: number\n}\n\ninterface UploadLikeOptions {\n url?: string\n filePath?: string\n header?: Record<string, string>\n formData?: Record<string, unknown>\n name?: string\n timeout?: number\n}\n\nfunction resolveTimeoutSignal(timeout: number) {\n const controller = typeof AbortController === 'function' ? new AbortController() : undefined\n let timeoutTimer: ReturnType<typeof setTimeout> | undefined\n if (timeout > 0 && controller) {\n timeoutTimer = setTimeout(() => controller.abort(), timeout)\n }\n return {\n signal: controller?.signal,\n clear: () => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n }\n },\n }\n}\n\nexport function getRuntimeFetch() {\n return getHostRuntimeFetch()\n}\n\nexport function normalizeRequestMethod(method?: string) {\n return (method || 'GET').toUpperCase()\n}\n\nexport function normalizeRequestHeaders(header?: Record<string, string>) {\n if (!header) {\n return {}\n }\n return { ...header }\n}\n\nexport function buildRequestUrl(url: string, method: string, data: unknown) {\n if (method !== 'GET' || data == null) {\n return url\n }\n if (typeof data === 'string') {\n if (!data) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${data}`\n }\n if (typeof URLSearchParams !== 'undefined' && data instanceof URLSearchParams) {\n const query = data.toString()\n if (!query) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${query}`\n }\n if (typeof data === 'object') {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(data as Record<string, unknown>)) {\n query.append(key, value == null ? '' : String(value))\n }\n const queryText = query.toString()\n if (!queryText) {\n return url\n }\n return `${url}${url.includes('?') ? '&' : '?'}${queryText}`\n }\n return url\n}\n\nexport function buildRequestBody(\n method: string,\n data: unknown,\n headers: Record<string, string>,\n) {\n if (method === 'GET' || data == null) {\n return undefined\n }\n if (typeof data === 'string') {\n return data\n }\n if (typeof URLSearchParams !== 'undefined' && data instanceof URLSearchParams) {\n return data\n }\n if (typeof FormData !== 'undefined' && data instanceof FormData) {\n return data\n }\n const contentTypeKey = Object.keys(headers).find(key => key.toLowerCase() === 'content-type')\n const contentType = contentTypeKey ? headers[contentTypeKey] : ''\n if (contentType && !contentType.includes('application/json')) {\n return String(data)\n }\n if (!contentTypeKey) {\n headers['content-type'] = 'application/json'\n }\n return JSON.stringify(data)\n}\n\nexport async function parseRequestResponseData(\n response: Response,\n options?: RequestParseOptions,\n) {\n if (options?.responseType === 'arraybuffer') {\n return response.arrayBuffer()\n }\n const contentType = response.headers.get('content-type') ?? ''\n if (options?.dataType === 'text') {\n return response.text()\n }\n if (options?.dataType === 'json' || contentType.includes('application/json')) {\n return response.json()\n }\n return response.text()\n}\n\nexport function createBlobObjectUrl(blob: Blob) {\n const runtimeUrl = (globalThis as {\n URL?: {\n createObjectURL?: (value: Blob) => string\n }\n }).URL\n if (runtimeUrl && typeof runtimeUrl.createObjectURL === 'function') {\n return runtimeUrl.createObjectURL(blob)\n }\n return ''\n}\n\nexport function collectResponseHeaders(response: {\n headers: {\n forEach: (callback: (value: string, key: string) => void) => void\n }\n}) {\n const headers: Record<string, string> = {}\n response.headers.forEach((value, key) => {\n headers[key] = value\n })\n return headers\n}\n\nexport function stripUploadContentType(headers: Record<string, string>) {\n const normalized = { ...headers }\n for (const key of Object.keys(normalized)) {\n if (key.toLowerCase() === 'content-type') {\n delete normalized[key]\n }\n }\n return normalized\n}\n\nexport async function performRequestByFetch(options?: RequestLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const method = normalizeRequestMethod(options?.method)\n const headers = normalizeRequestHeaders(options?.header)\n const requestUrl = buildRequestUrl(url, method, options?.data)\n const body = buildRequestBody(method, options?.data, headers)\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(requestUrl, {\n method,\n headers,\n body,\n signal: timeoutControl.signal,\n })\n const responseData = await parseRequestResponseData(response, options)\n return {\n data: responseData,\n statusCode: response.status,\n header: collectResponseHeaders(response),\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n\nexport async function performDownloadByFetch(options?: DownloadLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const headers = normalizeRequestHeaders(options?.header)\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(url, {\n method: 'GET',\n headers,\n signal: timeoutControl.signal,\n })\n const blob = await response.blob()\n return {\n tempFilePath: createBlobObjectUrl(blob) || url,\n statusCode: response.status,\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n\nexport async function performUploadByFetch(options?: UploadLikeOptions) {\n const url = options?.url?.trim() ?? ''\n if (!url) {\n throw new TypeError('invalid url')\n }\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n throw new TypeError('invalid filePath')\n }\n const runtimeFetch = getRuntimeFetch()\n if (!runtimeFetch) {\n throw new TypeError('fetch is unavailable')\n }\n const FormDataCtor = (globalThis as { FormData?: typeof FormData }).FormData\n if (typeof FormDataCtor !== 'function') {\n throw new TypeError('FormData is unavailable')\n }\n\n const headers = stripUploadContentType(normalizeRequestHeaders(options?.header))\n const formData = new FormDataCtor()\n for (const [key, value] of Object.entries(options?.formData ?? {})) {\n formData.append(key, value == null ? '' : String(value))\n }\n const blob = await resolveUploadFileBlob(filePath, runtimeFetch)\n formData.append(options?.name?.trim() || 'file', blob, resolveUploadFileName(filePath))\n\n const timeout = typeof options?.timeout === 'number' && options.timeout > 0 ? options.timeout : 0\n const timeoutControl = resolveTimeoutSignal(timeout)\n\n try {\n const response = await runtimeFetch(url, {\n method: 'POST',\n headers,\n body: formData,\n signal: timeoutControl.signal,\n })\n const data = await response.text()\n return {\n data,\n statusCode: response.status,\n header: collectResponseHeaders(response),\n }\n }\n finally {\n timeoutControl.clear()\n }\n}\n"],"mappings":";;;;AAmCA,SAAS,qBAAqB,SAAiB;CAC7C,MAAM,aAAa,OAAO,oBAAoB,aAAa,IAAI,gBAAgB,IAAI;CACnF,IAAI;CACJ,IAAI,UAAU,KAAK,YACjB,eAAe,iBAAiB,WAAW,MAAM,GAAG,OAAO;CAE7D,OAAO;EACL,QAAQ,YAAY;EACpB,aAAa;GACX,IAAI,cACF,aAAa,YAAY;EAE7B;CACF;AACF;AAEA,SAAgB,kBAAkB;CAChC,OAAOA,kBAAoB;AAC7B;AAEA,SAAgB,uBAAuB,QAAiB;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AU,yBAAyB;CAG/C,MAAM,UAAU,uBAAuB,wBAAwB,SAAS,MAAM,CAAC;CAC/E,MAAM,WAAW,IAAI,aAAa;CAClC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,YAAY,CAAC,CAAC,GAC/D,SAAS,OAAO,KAAK,SAAS,OAAO,KAAK,OAAO,KAAK,CAAC;CAEzD,MAAM,OAAO,MAAM,sBAAsB,UAAU,YAAY;CAC/D,SAAS,OAAO,SAAS,MAAM,KAAK,KAAK,QAAQ,MAAM,sBAAsB,QAAQ,CAAC;CAGtF,MAAM,iBAAiB,qBADP,OAAO,SAAS,YAAY,YAAY,QAAQ,UAAU,IAAI,QAAQ,UAAU,CAC7C;CAEnD,IAAI;EACF,MAAM,WAAW,MAAM,aAAa,KAAK;GACvC,QAAQ;GACR;GACA,MAAM;GACN,QAAQ,eAAe;EACzB,CAAC;EAED,OAAO;GACL,YAFiB,SAAS,KAAK;GAG/B,YAAY,SAAS;GACrB,QAAQ,uBAAuB,QAAQ;EACzC;CACF,UACQ;EACN,eAAe,MAAM;CACvB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { callMiniProgramAsyncSuccess, scheduleMicrotask } from "./async.mjs";
2
- import { createInterstitialAdImpl, createRewardedVideoAdImpl } from "./ad.mjs";
3
2
  import { createLogManagerBridge, createUpdateManagerBridge, readExtConfigValue, readRuntimeConsole, reportAnalyticsEvent, resolveUpdateManagerPreset } from "./platformRuntime.mjs";
3
+ import { createInterstitialAdImpl, createRewardedVideoAdImpl } from "./ad.mjs";
4
4
 
5
5
  //#region src/runtime/polyfill/platformApi.ts
6
6
  function createRewardedVideoAdBridge(options) {
@@ -22,7 +22,8 @@ function getUpdateManagerBridge() {
22
22
  return createUpdateManagerBridge(resolveUpdateManagerPreset, scheduleMicrotask);
23
23
  }
24
24
  function getLogManagerBridge(options) {
25
- return createLogManagerBridge(options?.level === 0 ? 0 : 1, readRuntimeConsole());
25
+ const level = options?.level === 0 ? 0 : 1;
26
+ return createLogManagerBridge(level, readRuntimeConsole());
26
27
  }
27
28
  function reportAnalyticsBridge(eventName, data) {
28
29
  reportAnalyticsEvent(eventName, data);
@@ -1 +1 @@
1
- {"version":3,"file":"platformApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/platformApi.ts"],"sourcesContent":["import {\n createInterstitialAdImpl,\n createRewardedVideoAdImpl,\n} from './ad'\nimport { callMiniProgramAsyncSuccess, scheduleMicrotask } from './async'\nimport {\n createLogManagerBridge,\n createUpdateManagerBridge,\n readExtConfigValue,\n readRuntimeConsole,\n reportAnalyticsEvent,\n resolveUpdateManagerPreset,\n} from './platformRuntime'\n\nexport function createRewardedVideoAdBridge(options?: any): any {\n return createRewardedVideoAdImpl(options)\n}\n\nexport function createInterstitialAdBridge(options?: any): any {\n return createInterstitialAdImpl(options)\n}\n\nexport function getExtConfigSyncBridge() {\n return readExtConfigValue()\n}\n\nexport function getExtConfigBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'getExtConfig:ok',\n extConfig: getExtConfigSyncBridge(),\n }))\n}\n\nexport function getUpdateManagerBridge() {\n return createUpdateManagerBridge(resolveUpdateManagerPreset, scheduleMicrotask)\n}\n\nexport function getLogManagerBridge(options?: any) {\n const level = options?.level === 0 ? 0 : 1\n return createLogManagerBridge(level, readRuntimeConsole())\n}\n\nexport function reportAnalyticsBridge(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsEvent(eventName, data)\n}\n"],"mappings":";;;;;AAcA,SAAgB,4BAA4B,SAAoB;CAC9D,OAAO,0BAA0B,OAAO;AAC1C;AAEA,SAAgB,2BAA2B,SAAoB;CAC7D,OAAO,yBAAyB,OAAO;AACzC;AAEA,SAAgB,yBAAyB;CACvC,OAAO,mBAAmB;AAC5B;AAEA,SAAgB,mBAAmB,SAA6B;CAC9D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,WAAW,uBAAuB;CACpC,CAAC,CAAC;AACJ;AAEA,SAAgB,yBAAyB;CACvC,OAAO,0BAA0B,4BAA4B,iBAAiB;AAChF;AAEA,SAAgB,oBAAoB,SAAe;CAEjD,OAAO,uBADO,SAAS,UAAU,IAAI,IAAI,GACJ,mBAAmB,CAAC;AAC3D;AAEA,SAAgB,sBAAsB,WAAmB,MAAgC;CACvF,qBAAqB,WAAW,IAAI;AACtC"}
1
+ {"version":3,"file":"platformApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/platformApi.ts"],"sourcesContent":["import {\n createInterstitialAdImpl,\n createRewardedVideoAdImpl,\n} from './ad'\nimport { callMiniProgramAsyncSuccess, scheduleMicrotask } from './async'\nimport {\n createLogManagerBridge,\n createUpdateManagerBridge,\n readExtConfigValue,\n readRuntimeConsole,\n reportAnalyticsEvent,\n resolveUpdateManagerPreset,\n} from './platformRuntime'\n\nexport function createRewardedVideoAdBridge(options?: any): any {\n return createRewardedVideoAdImpl(options)\n}\n\nexport function createInterstitialAdBridge(options?: any): any {\n return createInterstitialAdImpl(options)\n}\n\nexport function getExtConfigSyncBridge() {\n return readExtConfigValue()\n}\n\nexport function getExtConfigBridge(options?: any): Promise<any> {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'getExtConfig:ok',\n extConfig: getExtConfigSyncBridge(),\n }))\n}\n\nexport function getUpdateManagerBridge() {\n return createUpdateManagerBridge(resolveUpdateManagerPreset, scheduleMicrotask)\n}\n\nexport function getLogManagerBridge(options?: any) {\n const level = options?.level === 0 ? 0 : 1\n return createLogManagerBridge(level, readRuntimeConsole())\n}\n\nexport function reportAnalyticsBridge(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsEvent(eventName, data)\n}\n"],"mappings":";;;;;AAcA,SAAgB,4BAA4B,SAAoB;CAC9D,OAAO,0BAA0B,OAAO;AAC1C;AAEA,SAAgB,2BAA2B,SAAoB;CAC7D,OAAO,yBAAyB,OAAO;AACzC;AAEA,SAAgB,yBAAyB;CACvC,OAAO,mBAAmB;AAC5B;AAEA,SAAgB,mBAAmB,SAA6B;CAC9D,OAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,WAAW,uBAAuB;CACpC,CAAC,CAAC;AACJ;AAEA,SAAgB,yBAAyB;CACvC,OAAO,0BAA0B,4BAA4B,iBAAiB;AAChF;AAEA,SAAgB,oBAAoB,SAAe;CACjD,MAAM,QAAQ,SAAS,UAAU,IAAI,IAAI;CACzC,OAAO,uBAAuB,OAAO,mBAAmB,CAAC;AAC3D;AAEA,SAAgB,sBAAsB,WAAmB,MAAgC;CACvF,qBAAqB,WAAW,IAAI;AACtC"}
@@ -0,0 +1,88 @@
1
+ import { cloneLaunchOptions, resolveFallbackLaunchOptions } from "../appState.mjs";
2
+ import { isRecord } from "./options.mjs";
3
+
4
+ //#region src/runtime/polyfill/routeRuntime/appLifecycle.ts
5
+ function resolveEntryOptions(entry) {
6
+ return resolveFallbackLaunchOptions(entry ? [entry] : []);
7
+ }
8
+ function isDocumentHidden(target) {
9
+ return target.visibilityState === "hidden" || target.hidden === true;
10
+ }
11
+ var AppLifecycleRuntime = class {
12
+ resolveCurrentEntry;
13
+ #appInstance;
14
+ #foreground = false;
15
+ #lastEnterOptions;
16
+ #launchOptions;
17
+ #launched = false;
18
+ #visibilityDocument;
19
+ #visibilityHandler;
20
+ constructor(resolveCurrentEntry) {
21
+ this.resolveCurrentEntry = resolveCurrentEntry;
22
+ }
23
+ register(options) {
24
+ const resolved = options ?? {};
25
+ if (this.#appInstance) {
26
+ const currentGlobal = this.#appInstance.globalData;
27
+ Object.assign(this.#appInstance, resolved);
28
+ if (isRecord(currentGlobal)) this.#appInstance.globalData = currentGlobal;
29
+ else if (!isRecord(this.#appInstance.globalData)) this.#appInstance.globalData = {};
30
+ return options;
31
+ }
32
+ this.#appInstance = resolved;
33
+ if (!isRecord(this.#appInstance.globalData)) this.#appInstance.globalData = {};
34
+ return options;
35
+ }
36
+ bindVisibility(target = typeof document === "undefined" ? void 0 : document) {
37
+ if (!target || this.#visibilityDocument === target || typeof target.addEventListener !== "function") return;
38
+ this.#unbindVisibility();
39
+ this.#visibilityDocument = target;
40
+ this.#visibilityHandler = () => this.#syncVisibility(target);
41
+ target.addEventListener("visibilitychange", this.#visibilityHandler);
42
+ }
43
+ ensureLaunched(entry) {
44
+ if (!this.#appInstance || this.#launched) return;
45
+ const options = resolveEntryOptions(entry);
46
+ this.#launchOptions = cloneLaunchOptions(options);
47
+ this.#lastEnterOptions = cloneLaunchOptions(options);
48
+ this.#foreground = true;
49
+ this.#launched = true;
50
+ this.#appInstance.onLaunch?.(cloneLaunchOptions(options));
51
+ this.#appInstance.onShow?.(cloneLaunchOptions(options));
52
+ }
53
+ get instance() {
54
+ return this.#appInstance;
55
+ }
56
+ getLaunchOptions() {
57
+ return this.#launchOptions ? cloneLaunchOptions(this.#launchOptions) : resolveEntryOptions(this.resolveCurrentEntry());
58
+ }
59
+ getEnterOptions() {
60
+ return this.#lastEnterOptions ? cloneLaunchOptions(this.#lastEnterOptions) : this.getLaunchOptions();
61
+ }
62
+ dispose() {
63
+ this.#unbindVisibility();
64
+ }
65
+ #syncVisibility(target) {
66
+ if (!this.#appInstance || !this.#launched) return;
67
+ if (isDocumentHidden(target)) {
68
+ if (!this.#foreground) return;
69
+ this.#appInstance.onHide?.();
70
+ this.#foreground = false;
71
+ return;
72
+ }
73
+ if (this.#foreground) return;
74
+ const options = resolveEntryOptions(this.resolveCurrentEntry());
75
+ this.#lastEnterOptions = cloneLaunchOptions(options);
76
+ this.#appInstance.onShow?.(cloneLaunchOptions(options));
77
+ this.#foreground = true;
78
+ }
79
+ #unbindVisibility() {
80
+ if (this.#visibilityDocument && this.#visibilityHandler) this.#visibilityDocument.removeEventListener("visibilitychange", this.#visibilityHandler);
81
+ this.#visibilityDocument = void 0;
82
+ this.#visibilityHandler = void 0;
83
+ }
84
+ };
85
+
86
+ //#endregion
87
+ export { AppLifecycleRuntime };
88
+ //# sourceMappingURL=appLifecycle.mjs.map