@weapp-vite/web 1.3.37 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) 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 +13 -12
  14. package/dist/compiler/wxml/renderer.mjs.map +1 -1
  15. package/dist/compiler/wxml/specialNodes.mjs +6 -1
  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 +29 -6
  24. package/dist/index.mjs +197 -4
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/plugin/assets.d.mts +7 -0
  27. package/dist/plugin/assets.mjs +122 -0
  28. package/dist/plugin/assets.mjs.map +1 -0
  29. package/dist/plugin/constants.mjs +10 -1
  30. package/dist/plugin/constants.mjs.map +1 -1
  31. package/dist/plugin/dependencyScan.mjs +41 -0
  32. package/dist/plugin/dependencyScan.mjs.map +1 -0
  33. package/dist/plugin/entry.mjs +55 -6
  34. package/dist/plugin/entry.mjs.map +1 -1
  35. package/dist/plugin/files.mjs +1 -1
  36. package/dist/plugin/files.mjs.map +1 -1
  37. package/dist/plugin/index.d.mts +37 -3
  38. package/dist/plugin/index.mjs +240 -73
  39. package/dist/plugin/index.mjs.map +1 -1
  40. package/dist/plugin/layout.mjs +24 -0
  41. package/dist/plugin/layout.mjs.map +1 -0
  42. package/dist/plugin/path.mjs +4 -1
  43. package/dist/plugin/path.mjs.map +1 -1
  44. package/dist/plugin/register.mjs +45 -33
  45. package/dist/plugin/register.mjs.map +1 -1
  46. package/dist/plugin/scan.mjs +206 -94
  47. package/dist/plugin/scan.mjs.map +1 -1
  48. package/dist/plugin/scanSfc.mjs +65 -0
  49. package/dist/plugin/scanSfc.mjs.map +1 -0
  50. package/dist/plugin/state.mjs +3 -2
  51. package/dist/plugin/state.mjs.map +1 -1
  52. package/dist/plugin/styleModule.mjs +52 -0
  53. package/dist/plugin/styleModule.mjs.map +1 -0
  54. package/dist/plugin/types.d.mts +37 -1
  55. package/dist/plugin/vueSfc.mjs +149 -0
  56. package/dist/plugin/vueSfc.mjs.map +1 -0
  57. package/dist/runtime/appShell/container.mjs +25 -0
  58. package/dist/runtime/appShell/container.mjs.map +1 -0
  59. package/dist/runtime/appShell/tabBar/index.mjs +192 -0
  60. package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
  61. package/dist/runtime/appShell/tabBar/style.mjs +127 -0
  62. package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
  63. package/dist/runtime/button/helpers.mjs +1 -58
  64. package/dist/runtime/button/helpers.mjs.map +1 -1
  65. package/dist/runtime/button/index.d.mts +4 -5
  66. package/dist/runtime/button/index.mjs +6 -28
  67. package/dist/runtime/button/index.mjs.map +1 -1
  68. package/dist/runtime/button/style.mjs +53 -28
  69. package/dist/runtime/button/style.mjs.map +1 -1
  70. package/dist/runtime/component/behavior.mjs +26 -2
  71. package/dist/runtime/component/behavior.mjs.map +1 -1
  72. package/dist/runtime/component/element.mjs +107 -31
  73. package/dist/runtime/component/element.mjs.map +1 -1
  74. package/dist/runtime/component/observers.mjs +36 -0
  75. package/dist/runtime/component/observers.mjs.map +1 -0
  76. package/dist/runtime/component/publicInstance.mjs +48 -0
  77. package/dist/runtime/component/publicInstance.mjs.map +1 -0
  78. package/dist/runtime/component/relations.mjs +35 -0
  79. package/dist/runtime/component/relations.mjs.map +1 -0
  80. package/dist/runtime/component/slots.mjs +24 -0
  81. package/dist/runtime/component/slots.mjs.map +1 -0
  82. package/dist/runtime/component/state.mjs +13 -3
  83. package/dist/runtime/component/state.mjs.map +1 -1
  84. package/dist/runtime/component/types.d.mts +29 -4
  85. package/dist/runtime/component/virtualHost.mjs +83 -0
  86. package/dist/runtime/component/virtualHost.mjs.map +1 -0
  87. package/dist/runtime/host/index.d.mts +13 -0
  88. package/dist/runtime/host/index.mjs +47 -0
  89. package/dist/runtime/host/index.mjs.map +1 -0
  90. package/dist/runtime/host/types.d.mts +28 -0
  91. package/dist/runtime/hostGlobals.d.mts +9 -0
  92. package/dist/runtime/hostGlobals.mjs +39 -0
  93. package/dist/runtime/hostGlobals.mjs.map +1 -0
  94. package/dist/runtime/index.d.mts +21 -3
  95. package/dist/runtime/index.mjs +26 -4
  96. package/dist/runtime/index.mjs.map +1 -0
  97. package/dist/runtime/legacyTemplate/dom.mjs +3 -3
  98. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  99. package/dist/runtime/legacyTemplate/expression.mjs +9 -9
  100. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
  101. package/dist/runtime/legacyTemplate/index.mjs +6 -6
  102. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  103. package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
  104. package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
  105. package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
  106. package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
  107. package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
  108. package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
  109. package/dist/runtime/nativeComponents/form.d.mts +7 -0
  110. package/dist/runtime/nativeComponents/form.mjs +50 -0
  111. package/dist/runtime/nativeComponents/form.mjs.map +1 -0
  112. package/dist/runtime/nativeComponents/formControl.mjs +61 -0
  113. package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
  114. package/dist/runtime/nativeComponents/helpers.mjs +25 -0
  115. package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
  116. package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
  117. package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
  118. package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
  119. package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
  120. package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
  121. package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
  122. package/dist/runtime/nativeComponents/image.d.mts +8 -0
  123. package/dist/runtime/nativeComponents/image.mjs +121 -0
  124. package/dist/runtime/nativeComponents/image.mjs.map +1 -0
  125. package/dist/runtime/nativeComponents/index.d.mts +11 -0
  126. package/dist/runtime/nativeComponents/index.mjs +83 -0
  127. package/dist/runtime/nativeComponents/index.mjs.map +1 -0
  128. package/dist/runtime/nativeComponents/input.d.mts +8 -0
  129. package/dist/runtime/nativeComponents/input.mjs +131 -0
  130. package/dist/runtime/nativeComponents/input.mjs.map +1 -0
  131. package/dist/runtime/nativeComponents/label.mjs +36 -0
  132. package/dist/runtime/nativeComponents/label.mjs.map +1 -0
  133. package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
  134. package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
  135. package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
  136. package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
  137. package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
  138. package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
  139. package/dist/runtime/nativeComponents/navigator.mjs +200 -0
  140. package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
  141. package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
  142. package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
  143. package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
  144. package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
  145. package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
  146. package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
  147. package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
  148. package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
  149. package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
  150. package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
  151. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
  152. package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
  153. package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
  154. package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
  155. package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
  156. package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
  157. package/dist/runtime/nativeComponents/primitives.mjs +16 -0
  158. package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
  159. package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
  160. package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
  161. package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
  162. package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
  163. package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
  164. package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
  165. package/dist/runtime/nativeComponents/radio.mjs +147 -0
  166. package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
  167. package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
  168. package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
  169. package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
  170. package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
  171. package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
  172. package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
  173. package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
  174. package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
  175. package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
  176. package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
  177. package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
  178. package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
  179. package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
  180. package/dist/runtime/nativeComponents/style.mjs +41 -0
  181. package/dist/runtime/nativeComponents/style.mjs.map +1 -0
  182. package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
  183. package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
  184. package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
  185. package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
  186. package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
  187. package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
  188. package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
  189. package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
  190. package/dist/runtime/nativeComponents/switch.d.mts +7 -0
  191. package/dist/runtime/nativeComponents/switch.mjs +132 -0
  192. package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
  193. package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
  194. package/dist/runtime/nativeComponents/textarea.mjs +144 -0
  195. package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
  196. package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
  197. package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
  198. package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
  199. package/dist/runtime/nativeComponents/video/index.mjs +124 -0
  200. package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
  201. package/dist/runtime/nativeComponents/video/style.mjs +14 -0
  202. package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
  203. package/dist/runtime/navigationBar/index.mjs +1 -3
  204. package/dist/runtime/navigationBar/index.mjs.map +1 -1
  205. package/dist/runtime/pageLayout.d.mts +9 -0
  206. package/dist/runtime/pageLayout.mjs +16 -0
  207. package/dist/runtime/pageLayout.mjs.map +1 -0
  208. package/dist/runtime/polyfill/animation.mjs +120 -0
  209. package/dist/runtime/polyfill/animation.mjs.map +1 -0
  210. package/dist/runtime/polyfill/appState.mjs +1 -1
  211. package/dist/runtime/polyfill/appState.mjs.map +1 -1
  212. package/dist/runtime/polyfill/async.d.mts +7 -0
  213. package/dist/runtime/polyfill/async.mjs.map +1 -1
  214. package/dist/runtime/polyfill/canvasContext.mjs +41 -0
  215. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
  216. package/dist/runtime/polyfill/device.mjs +1 -1
  217. package/dist/runtime/polyfill/device.mjs.map +1 -1
  218. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
  219. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
  220. package/dist/runtime/polyfill/eventBus.mjs +56 -0
  221. package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
  222. package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
  223. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
  224. package/dist/runtime/polyfill/files.mjs +10 -10
  225. package/dist/runtime/polyfill/files.mjs.map +1 -1
  226. package/dist/runtime/polyfill/font.mjs +32 -0
  227. package/dist/runtime/polyfill/font.mjs.map +1 -0
  228. package/dist/runtime/polyfill/index.d.mts +2 -2
  229. package/dist/runtime/polyfill/index.mjs +49 -45
  230. package/dist/runtime/polyfill/index.mjs.map +1 -1
  231. package/dist/runtime/polyfill/interaction.mjs +7 -6
  232. package/dist/runtime/polyfill/interaction.mjs.map +1 -1
  233. package/dist/runtime/polyfill/interactionApi.mjs +3 -2
  234. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
  235. package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
  236. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
  237. package/dist/runtime/polyfill/locale.mjs +14 -0
  238. package/dist/runtime/polyfill/locale.mjs.map +1 -0
  239. package/dist/runtime/polyfill/locationApi.mjs +7 -4
  240. package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
  241. package/dist/runtime/polyfill/mediaActions.mjs +2 -2
  242. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
  243. package/dist/runtime/polyfill/mediaApi/file.mjs +1 -1
  244. package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
  245. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
  246. package/dist/runtime/polyfill/menuApi.mjs +38 -4
  247. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  248. package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
  249. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
  250. package/dist/runtime/polyfill/network/request.mjs +2 -2
  251. package/dist/runtime/polyfill/network/request.mjs.map +1 -1
  252. package/dist/runtime/polyfill/platformApi.mjs +1 -1
  253. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
  254. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
  255. package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
  256. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  257. package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
  258. package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
  259. package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
  260. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
  261. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  262. package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
  263. package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
  264. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  265. package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
  266. package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
  267. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
  268. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
  269. package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
  270. package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
  271. package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
  272. package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
  273. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  274. package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
  275. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
  276. package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
  277. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
  278. package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
  279. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  280. package/dist/runtime/polyfill/storage.mjs +5 -2
  281. package/dist/runtime/polyfill/storage.mjs.map +1 -1
  282. package/dist/runtime/polyfill/system.mjs +30 -3
  283. package/dist/runtime/polyfill/system.mjs.map +1 -1
  284. package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
  285. package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
  286. package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
  287. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
  288. package/dist/runtime/polyfill/ui.mjs +2 -6
  289. package/dist/runtime/polyfill/ui.mjs.map +1 -1
  290. package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
  291. package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
  292. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  293. package/dist/runtime/polyfill/videoContext.mjs +4 -0
  294. package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
  295. package/dist/runtime/polyfill/vkSession.mjs +4 -14
  296. package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
  297. package/dist/runtime/polyfill.d.mts +2 -2
  298. package/dist/runtime/renderContext.mjs +1 -1
  299. package/dist/runtime/renderContext.mjs.map +1 -1
  300. package/dist/runtime/rpx.mjs +17 -8
  301. package/dist/runtime/rpx.mjs.map +1 -1
  302. package/dist/runtime/seo/index.d.mts +31 -0
  303. package/dist/runtime/seo/index.mjs +94 -0
  304. package/dist/runtime/seo/index.mjs.map +1 -0
  305. package/dist/runtime/viewport/index.d.mts +12 -0
  306. package/dist/runtime/viewport/index.mjs +44 -0
  307. package/dist/runtime/viewport/index.mjs.map +1 -0
  308. package/dist/runtime/viewport/style.mjs +62 -0
  309. package/dist/runtime/viewport/style.mjs.map +1 -0
  310. package/dist/runtime/viewport/types.d.mts +14 -0
  311. package/dist/runtime/wevu.d.mts +20 -0
  312. package/dist/runtime/wevu.mjs +73 -0
  313. package/dist/runtime/wevu.mjs.map +1 -0
  314. package/dist/shared/nativeComponents.mjs +401 -0
  315. package/dist/shared/nativeComponents.mjs.map +1 -0
  316. package/dist/shared/tabBar.d.mts +19 -0
  317. package/dist/shared/tabBar.mjs +37 -0
  318. package/dist/shared/tabBar.mjs.map +1 -0
  319. package/dist/shared/wxml.mjs +3 -20
  320. package/dist/shared/wxml.mjs.map +1 -1
  321. package/package.json +13 -5
@@ -3,9 +3,11 @@ import { TemplateRenderer } from "../template.mjs";
3
3
  type DataRecord = Record<string, any>;
4
4
  interface PropertyOption {
5
5
  type?: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null;
6
+ optionalTypes?: Array<StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor>;
6
7
  value?: any;
7
8
  observer?: (this: ComponentPublicInstance, newValue: any, oldValue: any) => void;
8
9
  }
10
+ type PropertyDeclaration = PropertyOption | StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null;
9
11
  interface LifeTimeHooks {
10
12
  created?: (this: ComponentPublicInstance) => void;
11
13
  attached?: (this: ComponentPublicInstance) => void;
@@ -17,32 +19,55 @@ interface PageLifeTimeHooks {
17
19
  hide?: (this: ComponentPublicInstance) => void;
18
20
  resize?: (this: ComponentPublicInstance) => void;
19
21
  }
22
+ type RelationType = 'parent' | 'child' | 'ancestor' | 'descendant';
23
+ interface RelationOption {
24
+ type: RelationType;
25
+ linked?: (this: ComponentPublicInstance, target: ComponentPublicInstance) => void;
26
+ linkChanged?: (this: ComponentPublicInstance, target: ComponentPublicInstance) => void;
27
+ unlinked?: (this: ComponentPublicInstance, target: ComponentPublicInstance) => void;
28
+ }
29
+ interface ComponentBehaviorOptions {
30
+ addGlobalClass?: boolean;
31
+ styleIsolation?: 'isolated' | 'apply-shared' | 'shared';
32
+ virtualHost?: boolean;
33
+ [key: string]: unknown;
34
+ }
20
35
  interface ComponentOptions {
21
- properties?: Record<string, PropertyOption>;
36
+ properties?: Record<string, PropertyDeclaration>;
22
37
  data?: DataRecord | (() => DataRecord);
23
38
  methods?: Record<string, (this: ComponentPublicInstance, event: any) => any>;
39
+ observers?: Record<string, (this: ComponentPublicInstance, ...values: any[]) => void>;
24
40
  lifetimes?: LifeTimeHooks;
25
41
  pageLifetimes?: PageLifeTimeHooks;
42
+ relations?: Record<string, RelationOption>;
26
43
  behaviors?: ComponentOptions[];
44
+ options?: ComponentBehaviorOptions;
27
45
  }
28
46
  interface DefineComponentOptions {
47
+ id?: string;
29
48
  template: TemplateRenderer;
30
49
  style?: string;
31
50
  component?: ComponentOptions;
32
51
  observerInit?: boolean;
33
52
  }
53
+ interface TriggerEventOptions {
54
+ bubbles?: boolean;
55
+ composed?: boolean;
56
+ capturePhase?: boolean;
57
+ }
34
58
  interface ComponentPublicInstance extends HTMLElement {
35
59
  readonly data: DataRecord;
36
60
  readonly properties: DataRecord;
37
- setData: (patch: DataRecord) => void;
38
- triggerEvent: (name: string, detail?: any) => void;
61
+ setData: (patch: DataRecord, callback?: () => void) => void | Promise<void>;
62
+ triggerEvent: (name: string, detail?: any, options?: TriggerEventOptions) => void;
39
63
  createSelectorQuery: () => any;
40
64
  selectComponent: (selector: string) => ComponentPublicInstance | null;
41
65
  selectAllComponents: (selector: string) => ComponentPublicInstance[];
66
+ getRelationNodes: (relationPath: string) => ComponentPublicInstance[];
42
67
  }
43
68
  type ComponentConstructor = CustomElementConstructor & {
44
69
  __weappUpdate?: (options: DefineComponentOptions) => void;
45
70
  };
46
71
  //#endregion
47
- export { ComponentConstructor, ComponentOptions, ComponentPublicInstance, DataRecord, DefineComponentOptions, LifeTimeHooks, PageLifeTimeHooks, PropertyOption };
72
+ export { ComponentBehaviorOptions, ComponentConstructor, ComponentOptions, ComponentPublicInstance, DataRecord, DefineComponentOptions, LifeTimeHooks, PageLifeTimeHooks, PropertyDeclaration, PropertyOption, RelationOption, RelationType, TriggerEventOptions };
48
73
  //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1,83 @@
1
+ //#region src/runtime/component/virtualHost.ts
2
+ function parseClassTokens(value) {
3
+ return new Set((value ?? "").split(/\s+/).filter(Boolean));
4
+ }
5
+ function writeTokens(element, name, tokens) {
6
+ const value = Array.from(tokens).join(" ");
7
+ if (value) {
8
+ if (element.getAttribute(name) !== value) element.setAttribute(name, value);
9
+ } else if (element.getAttribute(name) !== null) element.removeAttribute(name);
10
+ }
11
+ function isClassAttributeElement(value) {
12
+ return Boolean(value && typeof value === "object" && typeof value.getAttribute === "function" && typeof value.setAttribute === "function");
13
+ }
14
+ function resolveVirtualRootElement(root) {
15
+ for (const child of Array.from(root.childNodes ?? [])) {
16
+ if (!isClassAttributeElement(child)) continue;
17
+ if (child.tagName?.toLowerCase() === "style") continue;
18
+ return child;
19
+ }
20
+ }
21
+ /**
22
+ * 将 virtualHost 根节点的 class 暴露到 Web 自定义元素宿主。
23
+ *
24
+ * 微信的虚拟宿主不会形成样式边界,父组件可以通过 external class
25
+ * 和 deep 选择器命中子组件根节点。Web 仍使用 Shadow DOM 保留 slot
26
+ * 投影,因此需要把根节点的 class token 同步到宿主来还原该选择器语义。
27
+ */
28
+ function syncVirtualHostClasses(host, root, ownedRuntimeTokens) {
29
+ const nextRuntimeTokens = parseClassTokens(resolveVirtualRootElement(root)?.getAttribute("class"));
30
+ const hostTokens = parseClassTokens(host.getAttribute("class"));
31
+ for (const token of ownedRuntimeTokens) hostTokens.delete(token);
32
+ ownedRuntimeTokens.clear();
33
+ for (const token of nextRuntimeTokens) {
34
+ if (!hostTokens.has(token)) ownedRuntimeTokens.add(token);
35
+ hostTokens.add(token);
36
+ }
37
+ writeTokens(host, "class", hostTokens);
38
+ }
39
+ /**
40
+ * 移除 runtime 为 virtualHost 同步的 class,并保留调用方宿主 class。
41
+ */
42
+ function clearVirtualHostClasses(host, ownedRuntimeTokens) {
43
+ if (ownedRuntimeTokens.size === 0) return;
44
+ const hostTokens = parseClassTokens(host.getAttribute("class"));
45
+ for (const token of ownedRuntimeTokens) hostTokens.delete(token);
46
+ writeTokens(host, "class", hostTokens);
47
+ ownedRuntimeTokens.clear();
48
+ }
49
+ /**
50
+ * 清除 runtime 暴露的 CSS part,并保留组件模板声明的 part。
51
+ */
52
+ function clearVirtualHostParts(rootElement, ownedPartTokens) {
53
+ if (!rootElement || ownedPartTokens.size === 0) return;
54
+ const partTokens = parseClassTokens(rootElement.getAttribute("part"));
55
+ for (const token of ownedPartTokens) partTokens.delete(token);
56
+ writeTokens(rootElement, "part", partTokens);
57
+ ownedPartTokens.clear();
58
+ }
59
+ /**
60
+ * 将 virtualHost 根 class 同步为 CSS part,使父组件可以跨 Shadow DOM
61
+ * 对子组件根节点应用 deep 样式。
62
+ */
63
+ function syncVirtualHostParts(root, previousRootElement, ownedPartTokens) {
64
+ const rootElement = resolveVirtualRootElement(root);
65
+ if (previousRootElement && previousRootElement !== rootElement) clearVirtualHostParts(previousRootElement, ownedPartTokens);
66
+ if (!rootElement) {
67
+ ownedPartTokens.clear();
68
+ return;
69
+ }
70
+ const partTokens = parseClassTokens(rootElement.getAttribute("part"));
71
+ for (const token of ownedPartTokens) partTokens.delete(token);
72
+ ownedPartTokens.clear();
73
+ for (const token of parseClassTokens(rootElement.getAttribute("class"))) {
74
+ if (!partTokens.has(token)) ownedPartTokens.add(token);
75
+ partTokens.add(token);
76
+ }
77
+ writeTokens(rootElement, "part", partTokens);
78
+ return rootElement;
79
+ }
80
+
81
+ //#endregion
82
+ export { clearVirtualHostClasses, clearVirtualHostParts, syncVirtualHostClasses, syncVirtualHostParts };
83
+ //# sourceMappingURL=virtualHost.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtualHost.mjs","names":[],"sources":["../../../src/runtime/component/virtualHost.ts"],"sourcesContent":["export interface ClassAttributeElement {\n getAttribute: (name: string) => string | null\n removeAttribute: (name: string) => void\n setAttribute: (name: string, value: string) => void\n}\n\ninterface RenderRootLike {\n childNodes?: ArrayLike<unknown>\n}\n\nfunction parseClassTokens(value: string | null | undefined) {\n return new Set((value ?? '').split(/\\s+/).filter(Boolean))\n}\n\nfunction writeTokens(element: ClassAttributeElement, name: string, tokens: Set<string>) {\n const value = Array.from(tokens).join(' ')\n if (value) {\n if (element.getAttribute(name) !== value) {\n element.setAttribute(name, value)\n }\n }\n else if (element.getAttribute(name) !== null) {\n element.removeAttribute(name)\n }\n}\n\nfunction isClassAttributeElement(value: unknown): value is ClassAttributeElement & { tagName?: string } {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as ClassAttributeElement).getAttribute === 'function'\n && typeof (value as ClassAttributeElement).setAttribute === 'function',\n )\n}\n\nfunction resolveVirtualRootElement(root: RenderRootLike) {\n for (const child of Array.from(root.childNodes ?? [])) {\n if (!isClassAttributeElement(child)) {\n continue\n }\n if (child.tagName?.toLowerCase() === 'style') {\n continue\n }\n return child\n }\n return undefined\n}\n\n/**\n * 将 virtualHost 根节点的 class 暴露到 Web 自定义元素宿主。\n *\n * 微信的虚拟宿主不会形成样式边界,父组件可以通过 external class\n * 和 deep 选择器命中子组件根节点。Web 仍使用 Shadow DOM 保留 slot\n * 投影,因此需要把根节点的 class token 同步到宿主来还原该选择器语义。\n */\nexport function syncVirtualHostClasses(\n host: ClassAttributeElement,\n root: RenderRootLike,\n ownedRuntimeTokens: Set<string>,\n) {\n const rootElement = resolveVirtualRootElement(root)\n const nextRuntimeTokens = parseClassTokens(rootElement?.getAttribute('class'))\n const hostTokens = parseClassTokens(host.getAttribute('class'))\n\n for (const token of ownedRuntimeTokens) {\n hostTokens.delete(token)\n }\n ownedRuntimeTokens.clear()\n for (const token of nextRuntimeTokens) {\n if (!hostTokens.has(token)) {\n ownedRuntimeTokens.add(token)\n }\n hostTokens.add(token)\n }\n\n writeTokens(host, 'class', hostTokens)\n}\n\n/**\n * 移除 runtime 为 virtualHost 同步的 class,并保留调用方宿主 class。\n */\nexport function clearVirtualHostClasses(\n host: ClassAttributeElement,\n ownedRuntimeTokens: Set<string>,\n) {\n if (ownedRuntimeTokens.size === 0) {\n return\n }\n const hostTokens = parseClassTokens(host.getAttribute('class'))\n for (const token of ownedRuntimeTokens) {\n hostTokens.delete(token)\n }\n writeTokens(host, 'class', hostTokens)\n ownedRuntimeTokens.clear()\n}\n\n/**\n * 清除 runtime 暴露的 CSS part,并保留组件模板声明的 part。\n */\nexport function clearVirtualHostParts(\n rootElement: ClassAttributeElement | undefined,\n ownedPartTokens: Set<string>,\n) {\n if (!rootElement || ownedPartTokens.size === 0) {\n return\n }\n const partTokens = parseClassTokens(rootElement.getAttribute('part'))\n for (const token of ownedPartTokens) {\n partTokens.delete(token)\n }\n writeTokens(rootElement, 'part', partTokens)\n ownedPartTokens.clear()\n}\n\n/**\n * 将 virtualHost 根 class 同步为 CSS part,使父组件可以跨 Shadow DOM\n * 对子组件根节点应用 deep 样式。\n */\nexport function syncVirtualHostParts(\n root: RenderRootLike,\n previousRootElement: ClassAttributeElement | undefined,\n ownedPartTokens: Set<string>,\n) {\n const rootElement = resolveVirtualRootElement(root)\n if (previousRootElement && previousRootElement !== rootElement) {\n clearVirtualHostParts(previousRootElement, ownedPartTokens)\n }\n if (!rootElement) {\n ownedPartTokens.clear()\n return undefined\n }\n\n const partTokens = parseClassTokens(rootElement.getAttribute('part'))\n for (const token of ownedPartTokens) {\n partTokens.delete(token)\n }\n ownedPartTokens.clear()\n for (const token of parseClassTokens(rootElement.getAttribute('class'))) {\n if (!partTokens.has(token)) {\n ownedPartTokens.add(token)\n }\n partTokens.add(token)\n }\n writeTokens(rootElement, 'part', partTokens)\n return rootElement\n}\n"],"mappings":";AAUA,SAAS,iBAAiB,OAAkC;CAC1D,OAAO,IAAI,KAAK,SAAS,GAAE,CAAE,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC;AAC3D;AAEA,SAAS,YAAY,SAAgC,MAAc,QAAqB;CACtF,MAAM,QAAQ,MAAM,KAAK,MAAM,CAAC,CAAC,KAAK,GAAG;CACzC,IAAI,OACF;MAAI,QAAQ,aAAa,IAAI,MAAM,OACjC,QAAQ,aAAa,MAAM,KAAK;CAClC,OAEG,IAAI,QAAQ,aAAa,IAAI,MAAM,MACtC,QAAQ,gBAAgB,IAAI;AAEhC;AAEA,SAAS,wBAAwB,OAAuE;CACtG,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAgC,iBAAiB,cACzD,OAAQ,MAAgC,iBAAiB,UAC9D;AACF;AAEA,SAAS,0BAA0B,MAAsB;CACvD,KAAK,MAAM,SAAS,MAAM,KAAK,KAAK,cAAc,CAAC,CAAC,GAAG;EACrD,IAAI,CAAC,wBAAwB,KAAK,GAChC;EAEF,IAAI,MAAM,SAAS,YAAY,MAAM,SACnC;EAEF,OAAO;CACT;AAEF;;;;;;;;AASA,SAAgB,uBACd,MACA,MACA,oBACA;CAEA,MAAM,oBAAoB,iBADN,0BAA0B,IACO,CAAC,EAAE,aAAa,OAAO,CAAC;CAC7E,MAAM,aAAa,iBAAiB,KAAK,aAAa,OAAO,CAAC;CAE9D,KAAK,MAAM,SAAS,oBAClB,WAAW,OAAO,KAAK;CAEzB,mBAAmB,MAAM;CACzB,KAAK,MAAM,SAAS,mBAAmB;EACrC,IAAI,CAAC,WAAW,IAAI,KAAK,GACvB,mBAAmB,IAAI,KAAK;EAE9B,WAAW,IAAI,KAAK;CACtB;CAEA,YAAY,MAAM,SAAS,UAAU;AACvC;;;;AAKA,SAAgB,wBACd,MACA,oBACA;CACA,IAAI,mBAAmB,SAAS,GAC9B;CAEF,MAAM,aAAa,iBAAiB,KAAK,aAAa,OAAO,CAAC;CAC9D,KAAK,MAAM,SAAS,oBAClB,WAAW,OAAO,KAAK;CAEzB,YAAY,MAAM,SAAS,UAAU;CACrC,mBAAmB,MAAM;AAC3B;;;;AAKA,SAAgB,sBACd,aACA,iBACA;CACA,IAAI,CAAC,eAAe,gBAAgB,SAAS,GAC3C;CAEF,MAAM,aAAa,iBAAiB,YAAY,aAAa,MAAM,CAAC;CACpE,KAAK,MAAM,SAAS,iBAClB,WAAW,OAAO,KAAK;CAEzB,YAAY,aAAa,QAAQ,UAAU;CAC3C,gBAAgB,MAAM;AACxB;;;;;AAMA,SAAgB,qBACd,MACA,qBACA,iBACA;CACA,MAAM,cAAc,0BAA0B,IAAI;CAClD,IAAI,uBAAuB,wBAAwB,aACjD,sBAAsB,qBAAqB,eAAe;CAE5D,IAAI,CAAC,aAAa;EAChB,gBAAgB,MAAM;EACtB;CACF;CAEA,MAAM,aAAa,iBAAiB,YAAY,aAAa,MAAM,CAAC;CACpE,KAAK,MAAM,SAAS,iBAClB,WAAW,OAAO,KAAK;CAEzB,gBAAgB,MAAM;CACtB,KAAK,MAAM,SAAS,iBAAiB,YAAY,aAAa,OAAO,CAAC,GAAG;EACvE,IAAI,CAAC,WAAW,IAAI,KAAK,GACvB,gBAAgB,IAAI,KAAK;EAE3B,WAAW,IAAI,KAAK;CACtB;CACA,YAAY,aAAa,QAAQ,UAAU;CAC3C,OAAO;AACT"}
@@ -0,0 +1,13 @@
1
+ import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./types.mjs";
2
+ //#region src/runtime/host/index.d.ts
3
+ declare function getWebRuntimeHost(): Readonly<WebRuntimeHost>;
4
+ declare function setWebRuntimeHost(host?: WebRuntimeHost): void;
5
+ declare function resetWebRuntimeHost(): void;
6
+ declare function getRuntimeFetch(): ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined;
7
+ declare function getRuntimeStorage(): WebRuntimeStorage | undefined;
8
+ declare function getRuntimeClipboard(): WebRuntimeClipboard | undefined;
9
+ declare function getRuntimeDialogs(): WebRuntimeDialogs;
10
+ declare function openRuntimeUrl(url?: string, target?: string, features?: string): unknown;
11
+ //#endregion
12
+ export { type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost };
13
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,47 @@
1
+ //#region src/runtime/host/index.ts
2
+ let runtimeHost = {};
3
+ function getWebRuntimeHost() {
4
+ return runtimeHost;
5
+ }
6
+ function setWebRuntimeHost(host) {
7
+ runtimeHost = host ? { ...host } : {};
8
+ }
9
+ function resetWebRuntimeHost() {
10
+ runtimeHost = {};
11
+ }
12
+ function getRuntimeFetch() {
13
+ if (typeof runtimeHost.fetch === "function") return runtimeHost.fetch;
14
+ const runtimeGlobal = globalThis;
15
+ return typeof runtimeGlobal.fetch === "function" ? runtimeGlobal.fetch : void 0;
16
+ }
17
+ function getRuntimeStorage() {
18
+ if (runtimeHost.storage) return runtimeHost.storage;
19
+ return globalThis.localStorage;
20
+ }
21
+ function getRuntimeClipboard() {
22
+ if (runtimeHost.clipboard) return runtimeHost.clipboard;
23
+ return globalThis.navigator?.clipboard;
24
+ }
25
+ function getRuntimeDialogs() {
26
+ if (runtimeHost.dialogs) return runtimeHost.dialogs;
27
+ const runtimeGlobal = globalThis;
28
+ return {
29
+ alert: runtimeGlobal.alert,
30
+ confirm: runtimeGlobal.confirm,
31
+ prompt: runtimeGlobal.prompt
32
+ };
33
+ }
34
+ function openRuntimeUrl(url, target, features) {
35
+ if (typeof runtimeHost.open === "function") {
36
+ if (features === void 0) return runtimeHost.open(url, target);
37
+ return runtimeHost.open(url, target, features);
38
+ }
39
+ const runtimeGlobal = globalThis;
40
+ const runtimeOpen = runtimeGlobal.window?.open ?? runtimeGlobal.open;
41
+ if (features === void 0) return runtimeOpen?.(url, target);
42
+ return runtimeOpen?.(url, target, features);
43
+ }
44
+
45
+ //#endregion
46
+ export { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost };
47
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["runtimeGlobal"],"sources":["../../../src/runtime/host/index.ts"],"sourcesContent":["import type { WebRuntimeDialogs, WebRuntimeHost } from './types'\n\nlet runtimeHost: WebRuntimeHost = {}\n\nexport function getWebRuntimeHost(): Readonly<WebRuntimeHost> {\n return runtimeHost\n}\n\nexport function setWebRuntimeHost(host?: WebRuntimeHost): void {\n runtimeHost = host ? { ...host } : {}\n}\n\nexport function resetWebRuntimeHost(): void {\n runtimeHost = {}\n}\n\nexport function getRuntimeFetch() {\n if (typeof runtimeHost.fetch === 'function') {\n return runtimeHost.fetch\n }\n const runtimeGlobal = globalThis as { fetch?: WebRuntimeHost['fetch'] }\n return typeof runtimeGlobal.fetch === 'function' ? runtimeGlobal.fetch : undefined\n}\n\nexport function getRuntimeStorage() {\n if (runtimeHost.storage) {\n return runtimeHost.storage\n }\n const runtimeGlobal = globalThis as { localStorage?: WebRuntimeHost['storage'] }\n return runtimeGlobal.localStorage\n}\n\nexport function getRuntimeClipboard() {\n if (runtimeHost.clipboard) {\n return runtimeHost.clipboard\n }\n const runtimeGlobal = globalThis as { navigator?: { clipboard?: WebRuntimeHost['clipboard'] } }\n return runtimeGlobal.navigator?.clipboard\n}\n\nexport function getRuntimeDialogs() {\n if (runtimeHost.dialogs) {\n return runtimeHost.dialogs\n }\n const runtimeGlobal = globalThis as WebRuntimeDialogs\n return {\n alert: runtimeGlobal.alert,\n confirm: runtimeGlobal.confirm,\n prompt: runtimeGlobal.prompt,\n }\n}\n\nexport function openRuntimeUrl(url?: string, target?: string, features?: string) {\n if (typeof runtimeHost.open === 'function') {\n if (features === undefined) {\n return runtimeHost.open(url, target)\n }\n return runtimeHost.open(url, target, features)\n }\n const runtimeGlobal = globalThis as {\n open?: WebRuntimeHost['open']\n window?: { open?: WebRuntimeHost['open'] }\n }\n const runtimeOpen = runtimeGlobal.window?.open ?? runtimeGlobal.open\n if (features === undefined) {\n return runtimeOpen?.(url, target)\n }\n return runtimeOpen?.(url, target, features)\n}\n\nexport type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from './types'\n"],"mappings":";AAEA,IAAI,cAA8B,CAAC;AAEnC,SAAgB,oBAA8C;CAC5D,OAAO;AACT;AAEA,SAAgB,kBAAkB,MAA6B;CAC7D,cAAc,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;AACtC;AAEA,SAAgB,sBAA4B;CAC1C,cAAc,CAAC;AACjB;AAEA,SAAgB,kBAAkB;CAChC,IAAI,OAAO,YAAY,UAAU,YAC/B,OAAO,YAAY;CAErB,MAAM,gBAAgB;CACtB,OAAO,OAAO,cAAc,UAAU,aAAa,cAAc,QAAQ;AAC3E;AAEA,SAAgB,oBAAoB;CAClC,IAAI,YAAY,SACd,OAAO,YAAY;CAGrB,OAAOA,WAAc;AACvB;AAEA,SAAgB,sBAAsB;CACpC,IAAI,YAAY,WACd,OAAO,YAAY;CAGrB,OAAOA,WAAc,WAAW;AAClC;AAEA,SAAgB,oBAAoB;CAClC,IAAI,YAAY,SACd,OAAO,YAAY;CAErB,MAAM,gBAAgB;CACtB,OAAO;EACL,OAAO,cAAc;EACrB,SAAS,cAAc;EACvB,QAAQ,cAAc;CACxB;AACF;AAEA,SAAgB,eAAe,KAAc,QAAiB,UAAmB;CAC/E,IAAI,OAAO,YAAY,SAAS,YAAY;EAC1C,IAAI,aAAa,QACf,OAAO,YAAY,KAAK,KAAK,MAAM;EAErC,OAAO,YAAY,KAAK,KAAK,QAAQ,QAAQ;CAC/C;CACA,MAAM,gBAAgB;CAItB,MAAM,cAAc,cAAc,QAAQ,QAAQ,cAAc;CAChE,IAAI,aAAa,QACf,OAAO,cAAc,KAAK,MAAM;CAElC,OAAO,cAAc,KAAK,QAAQ,QAAQ;AAC5C"}
@@ -0,0 +1,28 @@
1
+ //#region src/runtime/host/types.d.ts
2
+ interface WebRuntimeStorage {
3
+ readonly length: number;
4
+ clear: () => void;
5
+ getItem: (key: string) => string | null;
6
+ key: (index: number) => string | null;
7
+ removeItem: (key: string) => void;
8
+ setItem: (key: string, value: string) => void;
9
+ }
10
+ interface WebRuntimeClipboard {
11
+ readText: () => string | Promise<string>;
12
+ writeText: (value: string) => void | Promise<void>;
13
+ }
14
+ interface WebRuntimeDialogs {
15
+ alert?: (message?: string) => void;
16
+ confirm?: (message?: string) => boolean;
17
+ prompt?: (message?: string, defaultValue?: string) => string | null;
18
+ }
19
+ interface WebRuntimeHost {
20
+ clipboard?: WebRuntimeClipboard;
21
+ dialogs?: WebRuntimeDialogs;
22
+ fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
23
+ open?: (url?: string, target?: string, features?: string) => unknown;
24
+ storage?: WebRuntimeStorage;
25
+ }
26
+ //#endregion
27
+ export { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage };
28
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1,9 @@
1
+ //#region src/runtime/hostGlobals.d.ts
2
+ type HostGlobalsTarget = Record<PropertyKey, any>;
3
+ /**
4
+ * 安装第三方库在模块求值阶段可能读取的小程序宿主全局。
5
+ */
6
+ declare function installWebHostGlobals(target?: HostGlobalsTarget): void;
7
+ //#endregion
8
+ export { installWebHostGlobals };
9
+ //# sourceMappingURL=hostGlobals.d.mts.map
@@ -0,0 +1,39 @@
1
+ import { emitRuntimeWarning } from "./warning.mjs";
2
+
3
+ //#region src/runtime/hostGlobals.ts
4
+ const IDENTITY_CONSTRUCTORS = [
5
+ "App",
6
+ "Page",
7
+ "Component"
8
+ ];
9
+ const COMPILE_TIME_MACROS = [
10
+ "defineAppJson",
11
+ "defineComponentJson",
12
+ "definePageJson",
13
+ "definePageMeta",
14
+ "defineSitemapJson",
15
+ "defineThemeJson"
16
+ ];
17
+ const PLUGIN_METHOD_RE = /^(?:add|can|choose|clear|close|create|delete|get|has|hide|is|load|navigate|off|on|open|remove|request|save|say|set|show|start|stop|update|upload)/i;
18
+ function createUnsupportedPlugin() {
19
+ return new Proxy(Object.create(null), { get(_target, property) {
20
+ if (property === "then") return;
21
+ if (typeof property === "string" && PLUGIN_METHOD_RE.test(property)) return () => void 0;
22
+ } });
23
+ }
24
+ /**
25
+ * 安装第三方库在模块求值阶段可能读取的小程序宿主全局。
26
+ */
27
+ function installWebHostGlobals(target = globalThis) {
28
+ for (const name of IDENTITY_CONSTRUCTORS) if (typeof target[name] !== "function") target[name] = (options) => options;
29
+ for (const name of COMPILE_TIME_MACROS) if (typeof target[name] !== "function") target[name] = (options) => options;
30
+ if (typeof target.Behavior !== "function") target.Behavior = (options) => options;
31
+ if (typeof target.requirePlugin !== "function") target.requirePlugin = (pluginName) => {
32
+ emitRuntimeWarning(`[@weapp-vite/web] 插件 ${JSON.stringify(pluginName)} 暂无 Web 运行时实现,当前使用空代理降级。`, { key: `unsupported-plugin:${pluginName}` });
33
+ return createUnsupportedPlugin();
34
+ };
35
+ }
36
+
37
+ //#endregion
38
+ export { installWebHostGlobals };
39
+ //# sourceMappingURL=hostGlobals.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostGlobals.mjs","names":[],"sources":["../../src/runtime/hostGlobals.ts"],"sourcesContent":["import { emitRuntimeWarning } from './warning'\n\ntype HostGlobalsTarget = Record<PropertyKey, any>\n\nconst IDENTITY_CONSTRUCTORS = ['App', 'Page', 'Component'] as const\nconst COMPILE_TIME_MACROS = [\n 'defineAppJson',\n 'defineComponentJson',\n 'definePageJson',\n 'definePageMeta',\n 'defineSitemapJson',\n 'defineThemeJson',\n] as const\n\nconst PLUGIN_METHOD_RE = /^(?:add|can|choose|clear|close|create|delete|get|has|hide|is|load|navigate|off|on|open|remove|request|save|say|set|show|start|stop|update|upload)/i\n\nfunction createUnsupportedPlugin() {\n return new Proxy(Object.create(null) as Record<PropertyKey, unknown>, {\n get(_target, property) {\n if (property === 'then') {\n return undefined\n }\n if (typeof property === 'string' && PLUGIN_METHOD_RE.test(property)) {\n return () => undefined\n }\n return undefined\n },\n })\n}\n\n/**\n * 安装第三方库在模块求值阶段可能读取的小程序宿主全局。\n */\nexport function installWebHostGlobals(target: HostGlobalsTarget = globalThis): void {\n for (const name of IDENTITY_CONSTRUCTORS) {\n if (typeof target[name] !== 'function') {\n target[name] = (options: Record<string, any>) => options\n }\n }\n for (const name of COMPILE_TIME_MACROS) {\n if (typeof target[name] !== 'function') {\n target[name] = (options: unknown) => options\n }\n }\n if (typeof target.Behavior !== 'function') {\n target.Behavior = (options: Record<string, any>) => options\n }\n if (typeof target.requirePlugin !== 'function') {\n target.requirePlugin = (pluginName: string) => {\n emitRuntimeWarning(`[@weapp-vite/web] 插件 ${JSON.stringify(pluginName)} 暂无 Web 运行时实现,当前使用空代理降级。`, {\n key: `unsupported-plugin:${pluginName}`,\n })\n return createUnsupportedPlugin()\n }\n }\n}\n"],"mappings":";;;AAIA,MAAM,wBAAwB;CAAC;CAAO;CAAQ;AAAW;AACzD,MAAM,sBAAsB;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;AAEzB,SAAS,0BAA0B;CACjC,OAAO,IAAI,MAAM,OAAO,OAAO,IAAI,GAAmC,EACpE,IAAI,SAAS,UAAU;EACrB,IAAI,aAAa,QACf;EAEF,IAAI,OAAO,aAAa,YAAY,iBAAiB,KAAK,QAAQ,GAChE,aAAa;CAGjB,EACF,CAAC;AACH;;;;AAKA,SAAgB,sBAAsB,SAA4B,YAAkB;CAClF,KAAK,MAAM,QAAQ,uBACjB,IAAI,OAAO,OAAO,UAAU,YAC1B,OAAO,SAAS,YAAiC;CAGrD,KAAK,MAAM,QAAQ,qBACjB,IAAI,OAAO,OAAO,UAAU,YAC1B,OAAO,SAAS,YAAqB;CAGzC,IAAI,OAAO,OAAO,aAAa,YAC7B,OAAO,YAAY,YAAiC;CAEtD,IAAI,OAAO,OAAO,kBAAkB,YAClC,OAAO,iBAAiB,eAAuB;EAC7C,mBAAmB,wBAAwB,KAAK,UAAU,UAAU,EAAE,2BAA2B,EAC/F,KAAK,sBAAsB,aAC7B,CAAC;EACD,OAAO,wBAAwB;CACjC;AAEJ"}
@@ -1,17 +1,35 @@
1
- import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
2
1
  import { RenderContext, createRenderContext } from "./renderContext.mjs";
3
2
  import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
4
3
  import { TemplateRenderer, TemplateScope } from "./template.mjs";
5
4
  import { defineComponent } from "./component/index.mjs";
5
+ import { ResolvedWebRoutingConfig, WebRouteHistoryState, WebRouteTarget, WebRoutingConfig, WebRoutingMode, disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
6
+ import { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebRuntimeSeoConfig as WebSeoConfig, configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
7
+ import { WebTabBarConfig, WebTabBarItem } from "../shared/tabBar.mjs";
8
+ import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
6
9
  import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
10
+ import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./host/types.mjs";
11
+ import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
12
+ import { installWebHostGlobals } from "./hostGlobals.mjs";
13
+ import { resolveImageModeStyle } from "./nativeComponents/image.mjs";
14
+ import { createInputEventDetail } from "./nativeComponents/input.mjs";
15
+ import { createScrollEventDetail } from "./nativeComponents/scrollView.mjs";
16
+ import { createSwitchEventDetail } from "./nativeComponents/switch.mjs";
17
+ import { createTextareaLineChangeDetail } from "./nativeComponents/textarea.mjs";
18
+ import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./nativeComponents/video/helpers.mjs";
19
+ import { ensureNativeComponentsDefined } from "./nativeComponents/index.mjs";
7
20
  import { NavigationBarMetrics, setNavigationBarMetrics } from "./navigationBar/index.mjs";
21
+ import { setPageLayout } from "./pageLayout.mjs";
8
22
  import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
23
+ import { ResolvedWebViewportConfig, WebViewportConfig } from "./viewport/types.mjs";
24
+ import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
9
25
  import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
10
26
  import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
11
- import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
27
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
12
28
  import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
13
29
  import "./polyfill.mjs";
14
30
  import { RpxConfig, setupRpx } from "./rpx.mjs";
15
31
  import { injectStyle, removeStyle } from "./style.mjs";
16
32
  import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions } from "./warning.mjs";
17
- export { type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRenderContext, createRewardedVideoAd, createSelectorQuery, createTemplate, createVKSession, createVideoContext, createWorker, defineComponent, downloadFile, ensureButtonDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeExecutionMode, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, injectStyle, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeStyle, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setupRpx, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
33
+ import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
34
+ export * from "wevu/internal-runtime";
35
+ export { type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
@@ -1,16 +1,38 @@
1
+ import { __exportAll, __reExport } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { setRuntimeWarningOptions } from "./warning.mjs";
3
+ import { installWebHostGlobals } from "./hostGlobals.mjs";
1
4
  import { injectStyle, removeStyle } from "./style.mjs";
2
5
  import { ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
3
- import { setRuntimeWarningOptions } from "./warning.mjs";
4
6
  import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
5
7
  import { createRenderContext } from "./renderContext.mjs";
6
8
  import { defineComponent } from "./component/index.mjs";
9
+ import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
10
+ import { resolveImageModeStyle } from "./nativeComponents/image.mjs";
11
+ import { createInputEventDetail } from "./nativeComponents/input.mjs";
7
12
  import { setNavigationBarMetrics } from "./navigationBar/index.mjs";
8
- import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
13
+ import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
9
14
  import { setupRpx } from "./rpx.mjs";
15
+ import { configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
16
+ import { disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
10
17
  import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
11
18
  import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
12
- import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
19
+ import { createScrollEventDetail } from "./nativeComponents/scrollView.mjs";
20
+ import { createSwitchEventDetail } from "./nativeComponents/switch.mjs";
21
+ import { createTextareaLineChangeDetail } from "./nativeComponents/textarea.mjs";
22
+ import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./nativeComponents/video/helpers.mjs";
23
+ import { ensureNativeComponentsDefined } from "./nativeComponents/index.mjs";
24
+ import { setPageLayout } from "./pageLayout.mjs";
25
+ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
26
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
13
27
  import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
14
28
  import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
29
+ import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
30
+
31
+ export * from "wevu/internal-runtime"
32
+
33
+ //#region src/runtime/index.ts
34
+ installWebHostGlobals();
15
35
 
16
- export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRenderContext, createRewardedVideoAd, createSelectorQuery, createTemplate, createVKSession, createVideoContext, createWorker, defineComponent, downloadFile, ensureButtonDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeExecutionMode, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, injectStyle, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeStyle, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setupRpx, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
36
+ //#endregion
37
+ export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
38
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\n\ninstallWebHostGlobals()\n\nexport type { WebTabBarConfig, WebTabBarItem } from './appShell/tabBar'\nexport { ensureButtonDefined, setButtonFormConfig } from './button'\nexport type { ButtonFormConfig } from './button'\nexport { defineComponent } from './component'\nexport { getRuntimeExecutionMode, setRuntimeExecutionMode } from './execution'\nexport {\n getRuntimeClipboard,\n getRuntimeDialogs,\n getRuntimeFetch,\n getRuntimeStorage,\n getWebRuntimeHost,\n openRuntimeUrl,\n resetWebRuntimeHost,\n setWebRuntimeHost,\n} from './host'\nexport type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from './host'\nexport { installWebHostGlobals } from './hostGlobals'\nexport {\n createInputEventDetail,\n createScrollEventDetail,\n createSwitchEventDetail,\n createTextareaLineChangeDetail,\n createVideoProgressDetail,\n createVideoTimeUpdateDetail,\n ensureNativeComponentsDefined,\n resolveImageModeStyle,\n resolveVideoObjectFit,\n} from './nativeComponents'\nexport { setNavigationBarMetrics } from './navigationBar'\nexport type { NavigationBarMetrics } from './navigationBar'\nexport { setPageLayout } from './pageLayout'\nexport {\n authorize,\n canIUse,\n checkSession,\n chooseAddress,\n chooseFile,\n chooseImage,\n chooseLocation,\n chooseMedia,\n chooseMessageFile,\n chooseVideo,\n clearStorage,\n clearStorageSync,\n compressImage,\n compressVideo,\n createCanvasContext,\n createInterstitialAd,\n createRewardedVideoAd,\n createSelectorQuery,\n createVideoContext,\n createVKSession,\n createWorker,\n downloadFile,\n exitMiniProgram,\n getAccountInfoSync,\n getAppAuthorizeSetting,\n getAppBaseInfo,\n getBatteryInfo,\n getBatteryInfoSync,\n getClipboardData,\n getDeviceInfo,\n getEnterOptionsSync,\n getExtConfig,\n getExtConfigSync,\n getFileSystemManager,\n getFuzzyLocation,\n getImageInfo,\n getLaunchOptionsSync,\n getLocation,\n getLogManager,\n getMenuButtonBoundingClientRect,\n getNetworkType,\n getSetting,\n getStorage,\n getStorageInfo,\n getStorageInfoSync,\n getStorageSync,\n getSystemInfo,\n getSystemInfoSync,\n getSystemSetting,\n getUpdateManager,\n getUserInfo,\n getUserProfile,\n getVideoInfo,\n getWindowInfo,\n hideKeyboard,\n hideLoading,\n hideNavigationBarLoading,\n hideTabBar,\n hideTabBarRedDot,\n initializePageRoutes,\n loadSubPackage,\n login,\n makePhoneCall,\n navigateBack,\n navigateTo,\n navigateToMiniProgram,\n nextTick,\n offNetworkStatusChange,\n offWindowResize,\n onNetworkStatusChange,\n onWindowResize,\n openAppAuthorizeSetting,\n openCustomerServiceChat,\n openDocument,\n openLocation,\n openSetting,\n openVideoEditor,\n pageScrollTo,\n preloadSubpackage,\n previewImage,\n previewMedia,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n removeStorage,\n removeStorageSync,\n removeTabBarBadge,\n reportAnalytics,\n request,\n requestPayment,\n requestSubscribeMessage,\n saveFile,\n saveFileToDisk,\n saveImageToPhotosAlbum,\n saveVideoToPhotosAlbum,\n scanCode,\n setBackgroundColor,\n setBackgroundTextStyle,\n setClipboardData,\n setNavigationBarColor,\n setNavigationBarTitle,\n setStorage,\n setStorageSync,\n setTabBarBadge,\n setTabBarItem,\n setTabBarStyle,\n showActionSheet,\n showLoading,\n showModal,\n showNavigationBarLoading,\n showShareMenu,\n showTabBar,\n showTabBarRedDot,\n showToast,\n startPullDownRefresh,\n stopPullDownRefresh,\n switchTab,\n updateShareMenu,\n uploadFile,\n vibrateShort,\n} from './polyfill'\nexport {\n disposeWebRouting,\n getWebRoutingConfig,\n resolveWebRoutingConfig,\n} from './polyfill/routeRuntime/history'\nexport type {\n ResolvedWebRoutingConfig,\n WebRouteHistoryState,\n WebRouteTarget,\n WebRoutingConfig,\n WebRoutingMode,\n} from './polyfill/routeRuntime/history'\nexport { createRenderContext } from './renderContext'\nexport type { RenderContext } from './renderContext'\nexport { setupRpx } from './rpx'\nexport type { RpxConfig } from './rpx'\nexport {\n configureWebSeo,\n resetWebDocumentHead,\n setupWebResourceHints,\n syncWebDocumentHead,\n updateWebDocumentTitle,\n} from './seo'\nexport type { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebSeoConfig } from './seo'\nexport { injectStyle, removeStyle } from './style'\nexport { createTemplate, renderTemplate } from './template'\nexport type { TemplateRenderer, TemplateScope } from './template'\nexport { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from './viewport'\nexport type { ResolvedWebViewportConfig, WebViewportConfig } from './viewport'\nexport { setRuntimeWarningOptions } from './warning'\nexport type { RuntimeWarningLevel, RuntimeWarningOptions } from './warning'\nexport { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from './wevu'\nexport * from 'wevu/internal-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sBAAsB"}
@@ -46,8 +46,8 @@ function buildAttributeString(attribs, scope) {
46
46
  const event = rawEvent.toLowerCase();
47
47
  const handlerName = resolveAttributeValue(rawValue, scope).trim();
48
48
  if (!handlerName) continue;
49
- const runtimeEvent = EVENT_KIND_ALIAS[event] ?? event;
50
- const flags = EVENT_PREFIX_FLAGS[prefix] ?? {};
49
+ const runtimeEvent = EVENT_KIND_ALIAS[event] || event;
50
+ const flags = EVENT_PREFIX_FLAGS[prefix];
51
51
  result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}="${escapeAttribute(handlerName)}"`;
52
52
  const flagTokens = [flags.capture ? "capture" : "", flags.catch ? "catch" : ""].filter(Boolean);
53
53
  if (flagTokens.length) result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${runtimeEvent}="${flagTokens.join(",")}"`;
@@ -67,7 +67,7 @@ function stripControlAttributes(attribs) {
67
67
  }
68
68
  function isConditionalElement(node) {
69
69
  if (node.type !== "tag") return false;
70
- const attribs = node.attribs ?? {};
70
+ const attribs = node.attribs;
71
71
  return hasControlAttribute(attribs, "if") || hasControlAttribute(attribs, "elif") || hasControlAttribute(attribs, "else");
72
72
  }
73
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_KIND_ALIAS: Record<string, string> = {\n tap: 'click',\n longtap: 'contextmenu',\n longpress: 'contextmenu',\n}\n\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventMatch = EVENT_PREFIX_RE.exec(name)\n if (eventMatch) {\n const [, prefix, rawEvent] = eventMatch\n const event = rawEvent.toLowerCase()\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const runtimeEvent = EVENT_KIND_ALIAS[event] ?? event\n const flags = EVENT_PREFIX_FLAGS[prefix] ?? {}\n result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${escapeAttribute(handlerName)}\"`\n const flagTokens = [\n flags.capture ? 'capture' : '',\n flags.catch ? 'catch' : '',\n ].filter(Boolean)\n if (flagTokens.length) {\n result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${flagTokens.join(',')}\"`\n }\n continue\n }\n\n const value = resolveAttributeValue(rawValue, scope)\n if (value === '') {\n continue\n }\n const normalizedName = normalizeAttributeName(name)\n result += ` ${normalizedName}=\"${escapeAttribute(value)}\"`\n }\n return result\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nexport function isConditionalElement(node: Node): node is Element {\n if (node.type !== 'tag') {\n return false\n }\n const attribs = (node as Element).attribs ?? {}\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AACxB,MAAM,mBAA2C;CAC/C,KAAK;CACL,SAAS;CACT,WAAW;AACb;AAEA,MAAM,qBAA6E;CACjF,QAAQ,CAAC;CACT,SAAS,EAAE,OAAO,KAAK;CACvB,YAAY,CAAC;CACb,gBAAgB,EAAE,SAAS,KAAK;CAChC,iBAAiB;EAAE,SAAS;EAAM,OAAO;CAAK;AAChD;AAEA,SAAgB,WAAW,SAAmD;CAC5E,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,cAAsC,CAAC;CAC7C,MAAM,WAAW,6BAA6B,SAAS,UAAU,CAAC,EAAE,KAAK,KAAK;CAC9E,IAAI,YAAY,6BAA6B,SAAS,WAAW,CAAC,EAAE,KAAK,KAAK;CAE9E,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,OAAO,GAAG;EAChD,IAAI,cAAc,IAAI,GAAG,GACvB;EAEF,YAAY,OAAO;CACrB;CAEA,IAAI,aAAa,WACf,YAAY,GAAG,UAAU;CAG3B,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,qBACd,SACA,OACA;CACA,IAAI,SAAS;CACb,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,OAAO,GAAG;EACtD,IAAI,cAAc,IAAI,IAAI,GACxB;EAGF,MAAM,aAAa,gBAAgB,KAAK,IAAI;EAC5C,IAAI,YAAY;GACd,MAAM,GAAG,QAAQ,YAAY;GAC7B,MAAM,QAAQ,SAAS,YAAY;GACnC,MAAM,cAAc,sBAAsB,UAAU,KAAK,CAAC,CAAC,KAAK;GAChE,IAAI,CAAC,aACH;GAEF,MAAM,eAAe,iBAAiB,UAAU;GAChD,MAAM,QAAQ,mBAAmB,WAAW,CAAC;GAC7C,UAAU,IAAI,sCAAsC,aAAa,IAAI,gBAAgB,WAAW,EAAE;GAClG,MAAM,aAAa,CACjB,MAAM,UAAU,YAAY,IAC5B,MAAM,QAAQ,UAAU,EAC1B,CAAC,CAAC,OAAO,OAAO;GAChB,IAAI,WAAW,QACb,UAAU,IAAI,2CAA2C,aAAa,IAAI,WAAW,KAAK,GAAG,EAAE;GAEjG;EACF;EAEA,MAAM,QAAQ,sBAAsB,UAAU,KAAK;EACnD,IAAI,UAAU,IACZ;EAEF,MAAM,iBAAiB,uBAAuB,IAAI;EAClD,UAAU,IAAI,eAAe,IAAI,gBAAgB,KAAK,EAAE;CAC1D;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,SAAiC;CACtE,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,cAAc,IAAI,IAAI,GACzB,OAAO,QAAQ;CAGnB,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAA6B;CAChE,IAAI,KAAK,SAAS,OAChB,OAAO;CAET,MAAM,UAAW,KAAiB,WAAW,CAAC;CAC9C,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C"}
1
+ {"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_KIND_ALIAS: Record<string, string> = {\n tap: 'click',\n longtap: 'contextmenu',\n longpress: 'contextmenu',\n}\n\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventMatch = EVENT_PREFIX_RE.exec(name)\n if (eventMatch) {\n const [, prefix, rawEvent] = eventMatch\n const event = rawEvent.toLowerCase()\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const runtimeEvent = EVENT_KIND_ALIAS[event] || event\n const flags = EVENT_PREFIX_FLAGS[prefix]!\n result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${escapeAttribute(handlerName)}\"`\n const flagTokens = [\n flags.capture ? 'capture' : '',\n flags.catch ? 'catch' : '',\n ].filter(Boolean)\n if (flagTokens.length) {\n result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${flagTokens.join(',')}\"`\n }\n continue\n }\n\n const value = resolveAttributeValue(rawValue, scope)\n if (value === '') {\n continue\n }\n const normalizedName = normalizeAttributeName(name)\n result += ` ${normalizedName}=\"${escapeAttribute(value)}\"`\n }\n return result\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nexport function isConditionalElement(node: Node): node is Element {\n if (node.type !== 'tag') {\n return false\n }\n const attribs = (node as Element).attribs\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AACxB,MAAM,mBAA2C;CAC/C,KAAK;CACL,SAAS;CACT,WAAW;AACb;AAEA,MAAM,qBAA6E;CACjF,QAAQ,CAAC;CACT,SAAS,EAAE,OAAO,KAAK;CACvB,YAAY,CAAC;CACb,gBAAgB,EAAE,SAAS,KAAK;CAChC,iBAAiB;EAAE,SAAS;EAAM,OAAO;CAAK;AAChD;AAEA,SAAgB,WAAW,SAAmD;CAC5E,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,cAAsC,CAAC;CAC7C,MAAM,WAAW,6BAA6B,SAAS,UAAU,CAAC,EAAE,KAAK,KAAK;CAC9E,IAAI,YAAY,6BAA6B,SAAS,WAAW,CAAC,EAAE,KAAK,KAAK;CAE9E,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,OAAO,GAAG;EAChD,IAAI,cAAc,IAAI,GAAG,GACvB;EAEF,YAAY,OAAO;CACrB;CAEA,IAAI,aAAa,WACf,YAAY,GAAG,UAAU;CAG3B,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,qBACd,SACA,OACA;CACA,IAAI,SAAS;CACb,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,OAAO,GAAG;EACtD,IAAI,cAAc,IAAI,IAAI,GACxB;EAGF,MAAM,aAAa,gBAAgB,KAAK,IAAI;EAC5C,IAAI,YAAY;GACd,MAAM,GAAG,QAAQ,YAAY;GAC7B,MAAM,QAAQ,SAAS,YAAY;GACnC,MAAM,cAAc,sBAAsB,UAAU,KAAK,CAAC,CAAC,KAAK;GAChE,IAAI,CAAC,aACH;GAEF,MAAM,eAAe,iBAAiB,UAAU;GAChD,MAAM,QAAQ,mBAAmB;GACjC,UAAU,IAAI,sCAAsC,aAAa,IAAI,gBAAgB,WAAW,EAAE;GAClG,MAAM,aAAa,CACjB,MAAM,UAAU,YAAY,IAC5B,MAAM,QAAQ,UAAU,EAC1B,CAAC,CAAC,OAAO,OAAO;GAChB,IAAI,WAAW,QACb,UAAU,IAAI,2CAA2C,aAAa,IAAI,WAAW,KAAK,GAAG,EAAE;GAEjG;EACF;EAEA,MAAM,QAAQ,sBAAsB,UAAU,KAAK;EACnD,IAAI,UAAU,IACZ;EAEF,MAAM,iBAAiB,uBAAuB,IAAI;EAClD,UAAU,IAAI,eAAe,IAAI,gBAAgB,KAAK,EAAE;CAC1D;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,SAAiC;CACtE,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,cAAc,IAAI,IAAI,GACzB,OAAO,QAAQ;CAGnB,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAA6B;CAChE,IAAI,KAAK,SAAS,OAChB,OAAO;CAET,MAAM,UAAW,KAAiB;CAClC,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C"}
@@ -19,15 +19,15 @@ function normalizeList(value) {
19
19
  return [];
20
20
  }
21
21
  function escapeHtml(value) {
22
+ const entities = {
23
+ "&": "&amp;",
24
+ "<": "&lt;",
25
+ ">": "&gt;",
26
+ "\"": "&quot;",
27
+ "'": "&#39;"
28
+ };
22
29
  return value.replace(/[&<>"']/g, (match) => {
23
- switch (match) {
24
- case "&": return "&amp;";
25
- case "<": return "&lt;";
26
- case ">": return "&gt;";
27
- case "\"": return "&quot;";
28
- case "'": return "&#39;";
29
- default: return match;
30
- }
30
+ return entities[match];
31
31
  });
32
32
  }
33
33
  function escapeAttribute(value) {
@@ -65,7 +65,7 @@ function evaluateExpression(expression, scope) {
65
65
  evaluator = () => void 0;
66
66
  } else throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 "${trimmed}": ${reason}`);
67
67
  }
68
- if (evaluator) expressionCache.set(trimmed, evaluator);
68
+ expressionCache.set(trimmed, evaluator);
69
69
  }
70
70
  try {
71
71
  return evaluator?.(scope);
@@ -1 +1 @@
1
- {"version":3,"file":"expression.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/expression.ts"],"sourcesContent":["import type { LegacyTemplateScope } from './types'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from '../execution'\n\nconst expressionCache = new Map<string, (scope: LegacyTemplateScope) => any>()\n\nexport function createScope(initial?: LegacyTemplateScope) {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nexport function createChildScope(parent: LegacyTemplateScope) {\n return Object.assign(Object.create(parent), {})\n}\n\nexport function normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nexport function escapeHtml(value: string) {\n return value.replace(/[&<>\"']/g, (match) => {\n switch (match) {\n case '&':\n return '&amp;'\n case '<':\n return '&lt;'\n case '>':\n return '&gt;'\n case '\"':\n return '&quot;'\n case '\\'':\n return '&#39;'\n default:\n return match\n }\n })\n}\n\nexport function escapeAttribute(value: string) {\n return escapeHtml(value)\n}\n\nfunction toDisplayString(value: any) {\n if (value == null) {\n return ''\n }\n if (typeof value === 'object') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n try {\n return JSON.stringify(value)\n }\n catch {\n return String(value)\n }\n }\n return String(value)\n}\n\nfunction unwrapExpression(expression: string) {\n const trimmed = expression.trim()\n if (trimmed.startsWith('{{') && trimmed.endsWith('}}')) {\n return trimmed.slice(2, -2).trim()\n }\n return trimmed\n}\n\nexport function evaluateExpression(expression: string, scope: LegacyTemplateScope) {\n if (!expression) {\n return undefined\n }\n const trimmed = unwrapExpression(expression)\n if (!trimmed) {\n return undefined\n }\n let evaluator = expressionCache.get(trimmed)\n if (!evaluator) {\n try {\n // eslint-disable-next-line no-new-func -- dynamic expressions are required for template evaluation\n evaluator = new Function('scope', `with(scope){ return (${trimmed}); }`) as (scope: LegacyTemplateScope) => any\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-parse:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式解析错误 \"${trimmed}\": ${reason}`,\n )\n evaluator = () => undefined\n }\n else {\n throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 \"${trimmed}\": ${reason}`)\n }\n }\n if (evaluator) {\n expressionCache.set(trimmed, evaluator)\n }\n }\n try {\n return evaluator?.(scope)\n }\n catch (error) {\n const mode = getRuntimeExecutionMode()\n if (mode === 'strict') {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`[@weapp-vite/web] strict 模式下表达式执行失败 \"${trimmed}\": ${reason}`)\n }\n if (mode === 'safe') {\n const reason = error instanceof Error ? error.message : String(error)\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-runtime:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式执行错误 \"${trimmed}\": ${reason}`,\n )\n }\n return undefined\n }\n}\n\nexport function interpolateText(source: string, scope: LegacyTemplateScope, escapeResult: boolean) {\n if (!source.includes('{{')) {\n return escapeResult ? escapeHtml(source) : source\n }\n\n let cursor = 0\n let buffer = ''\n\n while (cursor < source.length) {\n const start = source.indexOf('{{', cursor)\n if (start === -1) {\n buffer += source.slice(cursor)\n break\n }\n\n buffer += source.slice(cursor, start)\n\n const end = source.indexOf('}}', start + 2)\n if (end === -1) {\n buffer += source.slice(start)\n break\n }\n\n const expression = source.slice(start + 2, end).trim()\n const evaluated = toDisplayString(evaluateExpression(expression, scope))\n buffer += evaluated\n cursor = end + 2\n }\n\n return escapeResult ? escapeHtml(buffer) : buffer\n}\n\nexport function resolveAttributeValue(value: string, scope: LegacyTemplateScope) {\n return interpolateText(value ?? '', scope, false)\n}\n"],"mappings":";;;AAGA,MAAM,kCAAkB,IAAI,IAAiD;AAE7E,SAAgB,YAAY,SAA+B;CACzD,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,WAAW,CAAC,CAAC;AACzD;AAEA,SAAgB,iBAAiB,QAA6B;CAC5D,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAChD;AAEA,SAAgB,cAAc,OAAmB;CAC/C,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAET,IAAI,SAAS,MACX,OAAO,CAAC;CAEV,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;EACvD,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;EAC5C,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,UAAU,KAAK;CACnD;CACA,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,OAAO,KAAK;CAE5B,OAAO,CAAC;AACV;AAEA,SAAgB,WAAW,OAAe;CACxC,OAAO,MAAM,QAAQ,aAAa,UAAU;EAC1C,QAAQ,OAAR;GACE,KAAK,KACH,OAAO;GACT,KAAK,KACH,OAAO;GACT,KAAK,KACH,OAAO;GACT,KAAK,MACH,OAAO;GACT,KAAK,KACH,OAAO;GACT,SACE,OAAO;EACX;CACF,CAAC;AACH;AAEA,SAAgB,gBAAgB,OAAe;CAC7C,OAAO,WAAW,KAAK;AACzB;AAEA,SAAS,gBAAgB,OAAY;CACnC,IAAI,SAAS,MACX,OAAO;CAET,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;EAE3B,IAAI;GACF,OAAO,KAAK,UAAU,KAAK;EAC7B,QACM;GACJ,OAAO,OAAO,KAAK;EACrB;CACF;CACA,OAAO,OAAO,KAAK;AACrB;AAEA,SAAS,iBAAiB,YAAoB;CAC5C,MAAM,UAAU,WAAW,KAAK;CAChC,IAAI,QAAQ,WAAW,IAAI,KAAK,QAAQ,SAAS,IAAI,GACnD,OAAO,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;CAEnC,OAAO;AACT;AAEA,SAAgB,mBAAmB,YAAoB,OAA4B;CACjF,IAAI,CAAC,YACH;CAEF,MAAM,UAAU,iBAAiB,UAAU;CAC3C,IAAI,CAAC,SACH;CAEF,IAAI,YAAY,gBAAgB,IAAI,OAAO;CAC3C,IAAI,CAAC,WAAW;EACd,IAAI;GAEF,YAAY,IAAI,SAAS,SAAS,wBAAwB,QAAQ,KAAK;EACzE,SACO,OAAO;GACZ,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAEpE,IADa,wBACN,MAAM,QAAQ;IACnB,yBACE,gCAAgC,WAChC,wCAAwC,QAAQ,KAAK,QACvD;IACA,kBAAkB;GACpB,OAEE,MAAM,IAAI,YAAY,8BAA8B,QAAQ,KAAK,QAAQ;EAE7E;EACA,IAAI,WACF,gBAAgB,IAAI,SAAS,SAAS;CAE1C;CACA,IAAI;EACF,OAAO,YAAY,KAAK;CAC1B,SACO,OAAO;EACZ,MAAM,OAAO,wBAAwB;EACrC,IAAI,SAAS,UAAU;GACrB,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACpE,MAAM,IAAI,MAAM,wCAAwC,QAAQ,KAAK,QAAQ;EAC/E;EACA,IAAI,SAAS,QAAQ;GACnB,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACpE,yBACE,kCAAkC,WAClC,wCAAwC,QAAQ,KAAK,QACvD;EACF;EACA;CACF;AACF;AAEA,SAAgB,gBAAgB,QAAgB,OAA4B,cAAuB;CACjG,IAAI,CAAC,OAAO,SAAS,IAAI,GACvB,OAAO,eAAe,WAAW,MAAM,IAAI;CAG7C,IAAI,SAAS;CACb,IAAI,SAAS;CAEb,OAAO,SAAS,OAAO,QAAQ;EAC7B,MAAM,QAAQ,OAAO,QAAQ,MAAM,MAAM;EACzC,IAAI,UAAU,IAAI;GAChB,UAAU,OAAO,MAAM,MAAM;GAC7B;EACF;EAEA,UAAU,OAAO,MAAM,QAAQ,KAAK;EAEpC,MAAM,MAAM,OAAO,QAAQ,MAAM,QAAQ,CAAC;EAC1C,IAAI,QAAQ,IAAI;GACd,UAAU,OAAO,MAAM,KAAK;GAC5B;EACF;EAGA,MAAM,YAAY,gBAAgB,mBADf,OAAO,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,KACc,GAAG,KAAK,CAAC;EACvE,UAAU;EACV,SAAS,MAAM;CACjB;CAEA,OAAO,eAAe,WAAW,MAAM,IAAI;AAC7C;AAEA,SAAgB,sBAAsB,OAAe,OAA4B;CAC/E,OAAO,gBAAgB,SAAS,IAAI,OAAO,KAAK;AAClD"}
1
+ {"version":3,"file":"expression.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/expression.ts"],"sourcesContent":["import type { LegacyTemplateScope } from './types'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from '../execution'\n\nconst expressionCache = new Map<string, (scope: LegacyTemplateScope) => any>()\n\nexport function createScope(initial?: LegacyTemplateScope) {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nexport function createChildScope(parent: LegacyTemplateScope) {\n return Object.assign(Object.create(parent), {})\n}\n\nexport function normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nexport function escapeHtml(value: string) {\n const entities: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n '\\'': '&#39;',\n }\n return value.replace(/[&<>\"']/g, (match) => {\n return entities[match]\n })\n}\n\nexport function escapeAttribute(value: string) {\n return escapeHtml(value)\n}\n\nfunction toDisplayString(value: any) {\n if (value == null) {\n return ''\n }\n if (typeof value === 'object') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n try {\n return JSON.stringify(value)\n }\n catch {\n return String(value)\n }\n }\n return String(value)\n}\n\nfunction unwrapExpression(expression: string) {\n const trimmed = expression.trim()\n if (trimmed.startsWith('{{') && trimmed.endsWith('}}')) {\n return trimmed.slice(2, -2).trim()\n }\n return trimmed\n}\n\nexport function evaluateExpression(expression: string, scope: LegacyTemplateScope) {\n if (!expression) {\n return undefined\n }\n const trimmed = unwrapExpression(expression)\n if (!trimmed) {\n return undefined\n }\n let evaluator = expressionCache.get(trimmed)\n if (!evaluator) {\n try {\n // eslint-disable-next-line no-new-func -- dynamic expressions are required for template evaluation\n evaluator = new Function('scope', `with(scope){ return (${trimmed}); }`) as (scope: LegacyTemplateScope) => any\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-parse:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式解析错误 \"${trimmed}\": ${reason}`,\n )\n evaluator = () => undefined\n }\n else {\n throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 \"${trimmed}\": ${reason}`)\n }\n }\n expressionCache.set(trimmed, evaluator)\n }\n try {\n return evaluator?.(scope)\n }\n catch (error) {\n const mode = getRuntimeExecutionMode()\n if (mode === 'strict') {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`[@weapp-vite/web] strict 模式下表达式执行失败 \"${trimmed}\": ${reason}`)\n }\n if (mode === 'safe') {\n const reason = error instanceof Error ? error.message : String(error)\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-runtime:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式执行错误 \"${trimmed}\": ${reason}`,\n )\n }\n return undefined\n }\n}\n\nexport function interpolateText(source: string, scope: LegacyTemplateScope, escapeResult: boolean) {\n if (!source.includes('{{')) {\n return escapeResult ? escapeHtml(source) : source\n }\n\n let cursor = 0\n let buffer = ''\n\n while (cursor < source.length) {\n const start = source.indexOf('{{', cursor)\n if (start === -1) {\n buffer += source.slice(cursor)\n break\n }\n\n buffer += source.slice(cursor, start)\n\n const end = source.indexOf('}}', start + 2)\n if (end === -1) {\n buffer += source.slice(start)\n break\n }\n\n const expression = source.slice(start + 2, end).trim()\n const evaluated = toDisplayString(evaluateExpression(expression, scope))\n buffer += evaluated\n cursor = end + 2\n }\n\n return escapeResult ? escapeHtml(buffer) : buffer\n}\n\nexport function resolveAttributeValue(value: string, scope: LegacyTemplateScope) {\n return interpolateText(value ?? '', scope, false)\n}\n"],"mappings":"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"}