@weapp-vite/web 1.3.36 → 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 +56 -7
  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 +245 -74
  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 +48 -36
  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 +46 -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
@@ -6,9 +6,28 @@ const styleTargets = /* @__PURE__ */ new WeakSet();
6
6
  let sharedSheet;
7
7
  const BUTTON_STYLE = `
8
8
  weapp-button {
9
+ appearance: none;
10
+ -webkit-appearance: none;
11
+ position: relative;
9
12
  display: block;
10
- width: 100%;
13
+ width: 184px;
14
+ max-width: 100%;
15
+ min-width: 0;
16
+ margin-right: auto;
17
+ margin-left: auto;
11
18
  box-sizing: border-box;
19
+ border: 1px solid #d9d9d9;
20
+ border-radius: 5px;
21
+ padding: 0 16px;
22
+ line-height: calc(2.55555556em - 1px);
23
+ font-size: 18px;
24
+ font-weight: 400;
25
+ background-color: #f8f8f8;
26
+ color: #000000;
27
+ cursor: pointer;
28
+ outline: none;
29
+ user-select: none;
30
+ -webkit-tap-highlight-color: transparent;
12
31
  }
13
32
 
14
33
  weapp-button.weapp-btn--mini {
@@ -20,84 +39,89 @@ weapp-button .weapp-btn {
20
39
  appearance: none;
21
40
  -webkit-appearance: none;
22
41
  box-sizing: border-box;
42
+ display: block;
23
43
  width: 100%;
24
- border-radius: 5px;
25
- border: 1px solid #d9d9d9;
26
- padding: 0 16px;
27
- height: 44px;
28
- line-height: 44px;
29
- font-size: 17px;
30
- font-weight: 400;
31
- background-color: #f8f8f8;
32
- color: #000000;
33
- cursor: pointer;
44
+ height: 100%;
45
+ min-height: inherit;
46
+ margin: 0;
47
+ border: 0;
48
+ border-radius: inherit;
49
+ padding: 0;
50
+ line-height: inherit;
51
+ font: inherit;
52
+ background: transparent;
53
+ color: inherit;
54
+ cursor: inherit;
34
55
  outline: none;
35
56
  user-select: none;
36
57
  -webkit-tap-highlight-color: transparent;
37
58
  }
38
59
 
39
- weapp-button.weapp-btn--primary .weapp-btn {
60
+ weapp-button.weapp-btn--primary {
40
61
  background-color: #07c160;
41
62
  border-color: #07c160;
42
63
  color: #ffffff;
43
64
  }
44
65
 
45
- weapp-button.weapp-btn--warn .weapp-btn {
66
+ weapp-button.weapp-btn--warn {
46
67
  background-color: #e64340;
47
68
  border-color: #e64340;
48
69
  color: #ffffff;
49
70
  }
50
71
 
51
- weapp-button.weapp-btn--plain .weapp-btn {
72
+ weapp-button.weapp-btn--plain {
52
73
  background-color: transparent;
53
74
  }
54
75
 
55
- weapp-button.weapp-btn--plain.weapp-btn--default .weapp-btn {
56
- border-color: #b2b2b2;
76
+ weapp-button.weapp-btn--plain.weapp-btn--default {
77
+ border-color: #a1a1a1;
57
78
  color: #353535;
58
79
  }
59
80
 
60
- weapp-button.weapp-btn--plain.weapp-btn--primary .weapp-btn {
81
+ weapp-button.weapp-btn--plain.weapp-btn--primary {
61
82
  border-color: #07c160;
62
83
  color: #07c160;
63
84
  }
64
85
 
65
- weapp-button.weapp-btn--plain.weapp-btn--warn .weapp-btn {
86
+ weapp-button.weapp-btn--plain.weapp-btn--warn {
66
87
  border-color: #e64340;
67
88
  color: #e64340;
68
89
  }
69
90
 
70
- weapp-button.weapp-btn--loading .weapp-btn,
71
- weapp-button.weapp-btn--disabled .weapp-btn {
91
+ weapp-button.weapp-btn--loading,
92
+ weapp-button.weapp-btn--disabled {
72
93
  background-color: #f7f7f7;
73
94
  border-color: #d9d9d9;
74
- color: #9b9b9b;
95
+ color: #bbbbbb;
75
96
  cursor: not-allowed;
76
97
  }
77
98
 
78
- weapp-button.button-hover .weapp-btn {
99
+ weapp-button.button-hover {
79
100
  background-color: #ededed;
80
101
  border-color: #d2d2d2;
81
102
  }
82
103
 
83
- weapp-button.button-hover.weapp-btn--primary .weapp-btn {
104
+ weapp-button.button-hover.weapp-btn--primary {
84
105
  background-color: #06ad56;
85
106
  border-color: #06ad56;
86
107
  }
87
108
 
88
- weapp-button.button-hover.weapp-btn--warn .weapp-btn {
109
+ weapp-button.button-hover.weapp-btn--warn {
89
110
  background-color: #d93c37;
90
111
  border-color: #d93c37;
91
112
  }
92
113
 
93
- weapp-button.button-hover.weapp-btn--plain .weapp-btn {
114
+ weapp-button.button-hover.weapp-btn--plain {
94
115
  background-color: rgba(0, 0, 0, 0.06);
95
116
  }
96
117
 
97
- weapp-button.weapp-btn--mini .weapp-btn {
118
+ weapp-button.weapp-btn--mini {
119
+ font-size: 13px;
120
+ }
121
+
122
+ weapp-button.weapp-btn--mini {
98
123
  height: 32px;
99
124
  line-height: 32px;
100
- font-size: 13px;
101
125
  padding: 0 12px;
102
126
  border-radius: 4px;
103
127
  }
@@ -108,6 +132,7 @@ weapp-button .weapp-btn__content {
108
132
  justify-content: center;
109
133
  gap: 6px;
110
134
  width: 100%;
135
+ height: 100%;
111
136
  }
112
137
 
113
138
  weapp-button .weapp-btn__loading {
@@ -164,5 +189,5 @@ function ensureButtonStyle(root) {
164
189
  }
165
190
 
166
191
  //#endregion
167
- export { ensureButtonStyle };
192
+ export { BUTTON_STYLE, ensureButtonStyle };
168
193
  //# sourceMappingURL=style.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.mjs","names":[],"sources":["../../../src/runtime/button/style.ts"],"sourcesContent":["import { injectStyle } from '../style'\n\nconst BUTTON_STYLE_ID = 'weapp-web-button-style'\nconst styleTargets = new WeakSet<ParentNode>()\nlet sharedSheet: CSSStyleSheet | undefined\n\nconst BUTTON_STYLE = `\nweapp-button {\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\nweapp-button.weapp-btn--mini {\n display: inline-block;\n width: auto;\n}\n\nweapp-button .weapp-btn {\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n width: 100%;\n border-radius: 5px;\n border: 1px solid #d9d9d9;\n padding: 0 16px;\n height: 44px;\n line-height: 44px;\n font-size: 17px;\n font-weight: 400;\n background-color: #f8f8f8;\n color: #000000;\n cursor: pointer;\n outline: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n\nweapp-button.weapp-btn--primary .weapp-btn {\n background-color: #07c160;\n border-color: #07c160;\n color: #ffffff;\n}\n\nweapp-button.weapp-btn--warn .weapp-btn {\n background-color: #e64340;\n border-color: #e64340;\n color: #ffffff;\n}\n\nweapp-button.weapp-btn--plain .weapp-btn {\n background-color: transparent;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--default .weapp-btn {\n border-color: #b2b2b2;\n color: #353535;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--primary .weapp-btn {\n border-color: #07c160;\n color: #07c160;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--warn .weapp-btn {\n border-color: #e64340;\n color: #e64340;\n}\n\nweapp-button.weapp-btn--loading .weapp-btn,\nweapp-button.weapp-btn--disabled .weapp-btn {\n background-color: #f7f7f7;\n border-color: #d9d9d9;\n color: #9b9b9b;\n cursor: not-allowed;\n}\n\nweapp-button.button-hover .weapp-btn {\n background-color: #ededed;\n border-color: #d2d2d2;\n}\n\nweapp-button.button-hover.weapp-btn--primary .weapp-btn {\n background-color: #06ad56;\n border-color: #06ad56;\n}\n\nweapp-button.button-hover.weapp-btn--warn .weapp-btn {\n background-color: #d93c37;\n border-color: #d93c37;\n}\n\nweapp-button.button-hover.weapp-btn--plain .weapp-btn {\n background-color: rgba(0, 0, 0, 0.06);\n}\n\nweapp-button.weapp-btn--mini .weapp-btn {\n height: 32px;\n line-height: 32px;\n font-size: 13px;\n padding: 0 12px;\n border-radius: 4px;\n}\n\nweapp-button .weapp-btn__content {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n width: 100%;\n}\n\nweapp-button .weapp-btn__loading {\n width: 14px;\n height: 14px;\n border-radius: 50%;\n border: 2px solid currentColor;\n border-top-color: transparent;\n animation: weapp-btn-spin 0.8s linear infinite;\n}\n\nweapp-button .weapp-btn__loading[hidden] {\n display: none;\n}\n\n@keyframes weapp-btn-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n`\n\nfunction resolveAdoptedStyleSheets(root: ShadowRoot) {\n const doc = root.ownerDocument ?? document\n if (!doc || typeof doc.createElement !== 'function') {\n return undefined\n }\n if (!('adoptedStyleSheets' in doc)) {\n return undefined\n }\n if (!sharedSheet && 'replaceSync' in CSSStyleSheet.prototype) {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(BUTTON_STYLE)\n sharedSheet = sheet\n }\n return sharedSheet\n}\n\nexport function ensureButtonStyle(root?: ShadowRoot) {\n if (typeof document === 'undefined') {\n return\n }\n if (root && styleTargets.has(root)) {\n return\n }\n if (!root) {\n const target = document.head\n if (!target || styleTargets.has(target)) {\n return\n }\n injectStyle(BUTTON_STYLE, BUTTON_STYLE_ID)\n styleTargets.add(target)\n return\n }\n const sheet = resolveAdoptedStyleSheets(root)\n if (sheet) {\n const existing = root.adoptedStyleSheets ?? []\n if (!existing.includes(sheet)) {\n root.adoptedStyleSheets = [...existing, sheet]\n }\n styleTargets.add(root)\n return\n }\n const style = document.createElement('style')\n style.id = BUTTON_STYLE_ID\n style.textContent = BUTTON_STYLE\n root.appendChild(style)\n styleTargets.add(root)\n}\n"],"mappings":";;;AAEA,MAAM,kBAAkB;AACxB,MAAM,+BAAe,IAAI,QAAoB;AAC7C,IAAI;AAEJ,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HrB,SAAS,0BAA0B,MAAkB;CACnD,MAAM,MAAM,KAAK,iBAAiB;CAClC,IAAI,CAAC,OAAO,OAAO,IAAI,kBAAkB,YACvC;CAEF,IAAI,EAAE,wBAAwB,MAC5B;CAEF,IAAI,CAAC,eAAe,iBAAiB,cAAc,WAAW;EAC5D,MAAM,QAAQ,IAAI,cAAc;EAChC,MAAM,YAAY,YAAY;EAC9B,cAAc;CAChB;CACA,OAAO;AACT;AAEA,SAAgB,kBAAkB,MAAmB;CACnD,IAAI,OAAO,aAAa,aACtB;CAEF,IAAI,QAAQ,aAAa,IAAI,IAAI,GAC/B;CAEF,IAAI,CAAC,MAAM;EACT,MAAM,SAAS,SAAS;EACxB,IAAI,CAAC,UAAU,aAAa,IAAI,MAAM,GACpC;EAEF,YAAY,cAAc,eAAe;EACzC,aAAa,IAAI,MAAM;EACvB;CACF;CACA,MAAM,QAAQ,0BAA0B,IAAI;CAC5C,IAAI,OAAO;EACT,MAAM,WAAW,KAAK,sBAAsB,CAAC;EAC7C,IAAI,CAAC,SAAS,SAAS,KAAK,GAC1B,KAAK,qBAAqB,CAAC,GAAG,UAAU,KAAK;EAE/C,aAAa,IAAI,IAAI;EACrB;CACF;CACA,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,KAAK;CACX,MAAM,cAAc;CACpB,KAAK,YAAY,KAAK;CACtB,aAAa,IAAI,IAAI;AACvB"}
1
+ {"version":3,"file":"style.mjs","names":[],"sources":["../../../src/runtime/button/style.ts"],"sourcesContent":["import { injectStyle } from '../style'\n\nconst BUTTON_STYLE_ID = 'weapp-web-button-style'\nconst styleTargets = new WeakSet<ParentNode>()\nlet sharedSheet: CSSStyleSheet | undefined\n\nexport const BUTTON_STYLE = `\nweapp-button {\n appearance: none;\n -webkit-appearance: none;\n position: relative;\n display: block;\n width: 184px;\n max-width: 100%;\n min-width: 0;\n margin-right: auto;\n margin-left: auto;\n box-sizing: border-box;\n border: 1px solid #d9d9d9;\n border-radius: 5px;\n padding: 0 16px;\n line-height: calc(2.55555556em - 1px);\n font-size: 18px;\n font-weight: 400;\n background-color: #f8f8f8;\n color: #000000;\n cursor: pointer;\n outline: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n\nweapp-button.weapp-btn--mini {\n display: inline-block;\n width: auto;\n}\n\nweapp-button .weapp-btn {\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n min-height: inherit;\n margin: 0;\n border: 0;\n border-radius: inherit;\n padding: 0;\n line-height: inherit;\n font: inherit;\n background: transparent;\n color: inherit;\n cursor: inherit;\n outline: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n\nweapp-button.weapp-btn--primary {\n background-color: #07c160;\n border-color: #07c160;\n color: #ffffff;\n}\n\nweapp-button.weapp-btn--warn {\n background-color: #e64340;\n border-color: #e64340;\n color: #ffffff;\n}\n\nweapp-button.weapp-btn--plain {\n background-color: transparent;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--default {\n border-color: #a1a1a1;\n color: #353535;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--primary {\n border-color: #07c160;\n color: #07c160;\n}\n\nweapp-button.weapp-btn--plain.weapp-btn--warn {\n border-color: #e64340;\n color: #e64340;\n}\n\nweapp-button.weapp-btn--loading,\nweapp-button.weapp-btn--disabled {\n background-color: #f7f7f7;\n border-color: #d9d9d9;\n color: #bbbbbb;\n cursor: not-allowed;\n}\n\nweapp-button.button-hover {\n background-color: #ededed;\n border-color: #d2d2d2;\n}\n\nweapp-button.button-hover.weapp-btn--primary {\n background-color: #06ad56;\n border-color: #06ad56;\n}\n\nweapp-button.button-hover.weapp-btn--warn {\n background-color: #d93c37;\n border-color: #d93c37;\n}\n\nweapp-button.button-hover.weapp-btn--plain {\n background-color: rgba(0, 0, 0, 0.06);\n}\n\nweapp-button.weapp-btn--mini {\n font-size: 13px;\n}\n\nweapp-button.weapp-btn--mini {\n height: 32px;\n line-height: 32px;\n padding: 0 12px;\n border-radius: 4px;\n}\n\nweapp-button .weapp-btn__content {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n width: 100%;\n height: 100%;\n}\n\nweapp-button .weapp-btn__loading {\n width: 14px;\n height: 14px;\n border-radius: 50%;\n border: 2px solid currentColor;\n border-top-color: transparent;\n animation: weapp-btn-spin 0.8s linear infinite;\n}\n\nweapp-button .weapp-btn__loading[hidden] {\n display: none;\n}\n\n@keyframes weapp-btn-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n`\n\nfunction resolveAdoptedStyleSheets(root: ShadowRoot) {\n const doc = root.ownerDocument ?? document\n if (!doc || typeof doc.createElement !== 'function') {\n return undefined\n }\n if (!('adoptedStyleSheets' in doc)) {\n return undefined\n }\n if (!sharedSheet && 'replaceSync' in CSSStyleSheet.prototype) {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(BUTTON_STYLE)\n sharedSheet = sheet\n }\n return sharedSheet\n}\n\nexport function ensureButtonStyle(root?: ShadowRoot) {\n if (typeof document === 'undefined') {\n return\n }\n if (root && styleTargets.has(root)) {\n return\n }\n if (!root) {\n const target = document.head\n if (!target || styleTargets.has(target)) {\n return\n }\n injectStyle(BUTTON_STYLE, BUTTON_STYLE_ID)\n styleTargets.add(target)\n return\n }\n const sheet = resolveAdoptedStyleSheets(root)\n if (sheet) {\n const existing = root.adoptedStyleSheets ?? []\n if (!existing.includes(sheet)) {\n root.adoptedStyleSheets = [...existing, sheet]\n }\n styleTargets.add(root)\n return\n }\n const style = document.createElement('style')\n style.id = BUTTON_STYLE_ID\n style.textContent = BUTTON_STYLE\n root.appendChild(style)\n styleTargets.add(root)\n}\n"],"mappings":";;;AAEA,MAAM,kBAAkB;AACxB,MAAM,+BAAe,IAAI,QAAoB;AAC7C,IAAI;AAEJ,MAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsJ5B,SAAS,0BAA0B,MAAkB;CACnD,MAAM,MAAM,KAAK,iBAAiB;CAClC,IAAI,CAAC,OAAO,OAAO,IAAI,kBAAkB,YACvC;CAEF,IAAI,EAAE,wBAAwB,MAC5B;CAEF,IAAI,CAAC,eAAe,iBAAiB,cAAc,WAAW;EAC5D,MAAM,QAAQ,IAAI,cAAc;EAChC,MAAM,YAAY,YAAY;EAC9B,cAAc;CAChB;CACA,OAAO;AACT;AAEA,SAAgB,kBAAkB,MAAmB;CACnD,IAAI,OAAO,aAAa,aACtB;CAEF,IAAI,QAAQ,aAAa,IAAI,IAAI,GAC/B;CAEF,IAAI,CAAC,MAAM;EACT,MAAM,SAAS,SAAS;EACxB,IAAI,CAAC,UAAU,aAAa,IAAI,MAAM,GACpC;EAEF,YAAY,cAAc,eAAe;EACzC,aAAa,IAAI,MAAM;EACvB;CACF;CACA,MAAM,QAAQ,0BAA0B,IAAI;CAC5C,IAAI,OAAO;EACT,MAAM,WAAW,KAAK,sBAAsB,CAAC;EAC7C,IAAI,CAAC,SAAS,SAAS,KAAK,GAC1B,KAAK,qBAAqB,CAAC,GAAG,UAAU,KAAK;EAE/C,aAAa,IAAI,IAAI;EACrB;CACF;CACA,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,KAAK;CACX,MAAM,cAAc;CACpB,KAAK,YAAY,KAAK;CACtB,aAAa,IAAI,IAAI;AACvB"}
@@ -3,7 +3,6 @@ function isPlainObject(value) {
3
3
  return typeof value === "object" && value !== null && !Array.isArray(value);
4
4
  }
5
5
  function mergeLifetimes(target, source) {
6
- if (!source) return;
7
6
  for (const key of [
8
7
  "created",
9
8
  "attached",
@@ -20,7 +19,6 @@ function mergeLifetimes(target, source) {
20
19
  }
21
20
  }
22
21
  function mergePageLifetimes(target, source) {
23
- if (!source) return;
24
22
  for (const key of [
25
23
  "show",
26
24
  "hide",
@@ -35,6 +33,15 @@ function mergePageLifetimes(target, source) {
35
33
  } : next;
36
34
  }
37
35
  }
36
+ function resolveNativeLifetimes(source) {
37
+ const native = source;
38
+ return {
39
+ created: native.created,
40
+ attached: native.attached,
41
+ ready: native.ready,
42
+ detached: native.detached
43
+ };
44
+ }
38
45
  function normalizeBehaviors(component) {
39
46
  if (!component) return {
40
47
  component: void 0,
@@ -59,6 +66,14 @@ function normalizeBehaviors(component) {
59
66
  ...merged.methods ?? {},
60
67
  ...source.methods
61
68
  };
69
+ if (source.observers) merged.observers = {
70
+ ...merged.observers ?? {},
71
+ ...source.observers
72
+ };
73
+ if (source.options) merged.options = {
74
+ ...merged.options ?? {},
75
+ ...source.options
76
+ };
62
77
  if (source.lifetimes) {
63
78
  merged.lifetimes = merged.lifetimes ?? {};
64
79
  mergeLifetimes(merged.lifetimes, source.lifetimes);
@@ -67,6 +82,15 @@ function normalizeBehaviors(component) {
67
82
  merged.pageLifetimes = merged.pageLifetimes ?? {};
68
83
  mergePageLifetimes(merged.pageLifetimes, source.pageLifetimes);
69
84
  }
85
+ const nativeLifetimes = resolveNativeLifetimes(source);
86
+ if (Object.values(nativeLifetimes).some(Boolean)) {
87
+ merged.lifetimes = merged.lifetimes ?? {};
88
+ mergeLifetimes(merged.lifetimes, nativeLifetimes);
89
+ }
90
+ if (source.relations) merged.relations = {
91
+ ...merged.relations ?? {},
92
+ ...source.relations
93
+ };
70
94
  };
71
95
  const walk = (source) => {
72
96
  if (visited.has(source)) {
@@ -1 +1 @@
1
- {"version":3,"file":"behavior.mjs","names":[],"sources":["../../../src/runtime/component/behavior.ts"],"sourcesContent":["import type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n LifeTimeHooks,\n PageLifeTimeHooks,\n} from './types'\n\nfunction isPlainObject(value: unknown): value is Record<string, any> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction mergeLifetimes(target: LifeTimeHooks, source?: LifeTimeHooks) {\n if (!source) {\n return\n }\n const keys: Array<keyof LifeTimeHooks> = ['created', 'attached', 'ready', 'detached']\n for (const key of keys) {\n const next = source[key]\n if (!next) {\n continue\n }\n const current = target[key]\n target[key] = current\n ? function merged(this: ComponentPublicInstance) {\n current.call(this)\n next.call(this)\n }\n : next\n }\n}\n\nfunction mergePageLifetimes(target: PageLifeTimeHooks, source?: PageLifeTimeHooks) {\n if (!source) {\n return\n }\n const keys: Array<keyof PageLifeTimeHooks> = ['show', 'hide', 'resize']\n for (const key of keys) {\n const next = source[key]\n if (!next) {\n continue\n }\n const current = target[key]\n target[key] = current\n ? function merged(this: ComponentPublicInstance) {\n current.call(this)\n next.call(this)\n }\n : next\n }\n}\n\nexport function normalizeBehaviors(component: ComponentOptions | undefined) {\n if (!component) {\n return { component: undefined, warnings: [] as string[] }\n }\n const warnings: string[] = []\n const visited = new Set<ComponentOptions>()\n const merged: ComponentOptions = {}\n\n const mergeComponent = (source: ComponentOptions) => {\n if (source.properties) {\n merged.properties = { ...(merged.properties ?? {}), ...source.properties }\n }\n if (source.data) {\n const nextData = typeof source.data === 'function'\n ? source.data()\n : source.data\n if (isPlainObject(nextData)) {\n merged.data = { ...((merged.data as DataRecord) ?? {}), ...nextData }\n }\n }\n if (source.methods) {\n merged.methods = { ...(merged.methods ?? {}), ...source.methods }\n }\n if (source.lifetimes) {\n merged.lifetimes = merged.lifetimes ?? {}\n mergeLifetimes(merged.lifetimes, source.lifetimes)\n }\n if (source.pageLifetimes) {\n merged.pageLifetimes = merged.pageLifetimes ?? {}\n mergePageLifetimes(merged.pageLifetimes, source.pageLifetimes)\n }\n }\n\n const walk = (source: ComponentOptions) => {\n if (visited.has(source)) {\n warnings.push('[@weapp-vite/web] behaviors 存在循环引用,已跳过。')\n return\n }\n visited.add(source)\n const behaviors = source.behaviors ?? []\n if (Array.isArray(behaviors)) {\n for (const behavior of behaviors) {\n if (!behavior || !isPlainObject(behavior)) {\n warnings.push('[@weapp-vite/web] behaviors 仅支持对象,已忽略非对象条目。')\n continue\n }\n walk(behavior as ComponentOptions)\n mergeComponent(behavior as ComponentOptions)\n }\n }\n else if (behaviors) {\n warnings.push('[@weapp-vite/web] behaviors 仅支持数组,已忽略。')\n }\n }\n\n walk(component)\n mergeComponent(component)\n\n return {\n component: merged,\n warnings,\n }\n}\n"],"mappings":";AAQA,SAAS,cAAc,OAA8C;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eAAe,QAAuB,QAAwB;CACrE,IAAI,CAAC,QACH;CAGF,KAAK,MAAM,OAAO;EADwB;EAAW;EAAY;EAAS;CACrD,GAAG;EACtB,MAAM,OAAO,OAAO;EACpB,IAAI,CAAC,MACH;EAEF,MAAM,UAAU,OAAO;EACvB,OAAO,OAAO,UACV,SAAS,SAAsC;GAC/C,QAAQ,KAAK,IAAI;GACjB,KAAK,KAAK,IAAI;EAChB,IACE;CACN;AACF;AAEA,SAAS,mBAAmB,QAA2B,QAA4B;CACjF,IAAI,CAAC,QACH;CAGF,KAAK,MAAM,OAAO;EAD4B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CAAC,YAAY,CAAC,cAAc,QAAQ,GAAG;IACzC,SAAS,KAAK,6CAA6C;IAC3D;GACF;GACA,KAAK,QAA4B;GACjC,eAAe,QAA4B;EAC7C;OAEG,IAAI,WACP,SAAS,KAAK,wCAAwC;CAE1D;CAEA,KAAK,SAAS;CACd,eAAe,SAAS;CAExB,OAAO;EACL,WAAW;EACX;CACF;AACF"}
1
+ {"version":3,"file":"behavior.mjs","names":[],"sources":["../../../src/runtime/component/behavior.ts"],"sourcesContent":["import type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n LifeTimeHooks,\n PageLifeTimeHooks,\n} from './types'\n\nfunction isPlainObject(value: unknown): value is Record<string, any> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction mergeLifetimes(target: LifeTimeHooks, source: LifeTimeHooks) {\n const keys: Array<keyof LifeTimeHooks> = ['created', 'attached', 'ready', 'detached']\n for (const key of keys) {\n const next = source[key]\n if (!next) {\n continue\n }\n const current = target[key]\n target[key] = current\n ? function merged(this: ComponentPublicInstance) {\n current.call(this)\n next.call(this)\n }\n : next\n }\n}\n\nfunction mergePageLifetimes(target: PageLifeTimeHooks, source: PageLifeTimeHooks) {\n const keys: Array<keyof PageLifeTimeHooks> = ['show', 'hide', 'resize']\n for (const key of keys) {\n const next = source[key]\n if (!next) {\n continue\n }\n const current = target[key]\n target[key] = current\n ? function merged(this: ComponentPublicInstance) {\n current.call(this)\n next.call(this)\n }\n : next\n }\n}\n\nfunction resolveNativeLifetimes(source: ComponentOptions) {\n const native = source as ComponentOptions & LifeTimeHooks\n return {\n created: native.created,\n attached: native.attached,\n ready: native.ready,\n detached: native.detached,\n }\n}\n\nexport function normalizeBehaviors(component: ComponentOptions | undefined) {\n if (!component) {\n return { component: undefined, warnings: [] as string[] }\n }\n const warnings: string[] = []\n const visited = new Set<ComponentOptions>()\n const merged: ComponentOptions = {}\n\n const mergeComponent = (source: ComponentOptions) => {\n if (source.properties) {\n merged.properties = { ...(merged.properties ?? {}), ...source.properties }\n }\n if (source.data) {\n const nextData = typeof source.data === 'function'\n ? source.data()\n : source.data\n if (isPlainObject(nextData)) {\n merged.data = { ...((merged.data as DataRecord) ?? {}), ...nextData }\n }\n }\n if (source.methods) {\n merged.methods = { ...(merged.methods ?? {}), ...source.methods }\n }\n if (source.observers) {\n merged.observers = { ...(merged.observers ?? {}), ...source.observers }\n }\n if (source.options) {\n merged.options = { ...(merged.options ?? {}), ...source.options }\n }\n if (source.lifetimes) {\n merged.lifetimes = merged.lifetimes ?? {}\n mergeLifetimes(merged.lifetimes, source.lifetimes)\n }\n if (source.pageLifetimes) {\n merged.pageLifetimes = merged.pageLifetimes ?? {}\n mergePageLifetimes(merged.pageLifetimes, source.pageLifetimes)\n }\n const nativeLifetimes = resolveNativeLifetimes(source)\n if (Object.values(nativeLifetimes).some(Boolean)) {\n merged.lifetimes = merged.lifetimes ?? {}\n mergeLifetimes(merged.lifetimes, nativeLifetimes)\n }\n if (source.relations) {\n merged.relations = { ...(merged.relations ?? {}), ...source.relations }\n }\n }\n\n const walk = (source: ComponentOptions) => {\n if (visited.has(source)) {\n warnings.push('[@weapp-vite/web] behaviors 存在循环引用,已跳过。')\n return\n }\n visited.add(source)\n const behaviors = source.behaviors ?? []\n if (Array.isArray(behaviors)) {\n for (const behavior of behaviors) {\n if (!behavior || !isPlainObject(behavior)) {\n warnings.push('[@weapp-vite/web] behaviors 仅支持对象,已忽略非对象条目。')\n continue\n }\n walk(behavior as ComponentOptions)\n mergeComponent(behavior as ComponentOptions)\n }\n }\n else if (behaviors) {\n warnings.push('[@weapp-vite/web] behaviors 仅支持数组,已忽略。')\n }\n }\n\n walk(component)\n mergeComponent(component)\n\n return {\n component: merged,\n warnings,\n }\n}\n"],"mappings":";AAQA,SAAS,cAAc,OAA8C;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eAAe,QAAuB,QAAuB;CAEpE,KAA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ACT,OAAO,YAAY;GAAE,GAAI,OAAO,aAAa,CAAC;GAAI,GAAG,OAAO;EAAU;EAExE,IAAI,OAAO,SACT,OAAO,UAAU;GAAE,GAAI,OAAO,WAAW,CAAC;GAAI,GAAG,OAAO;EAAQ;EAElE,IAAI,OAAO,WAAW;GACpB,OAAO,YAAY,OAAO,aAAa,CAAC;GACxC,eAAe,OAAO,WAAW,OAAO,SAAS;EACnD;EACA,IAAI,OAAO,eAAe;GACxB,OAAO,gBAAgB,OAAO,iBAAiB,CAAC;GAChD,mBAAmB,OAAO,eAAe,OAAO,aAAa;EAC/D;EACA,MAAM,kBAAkB,uBAAuB,MAAM;EACrD,IAAI,OAAO,OAAO,eAAe,CAAC,CAAC,KAAK,OAAO,GAAG;GAChD,OAAO,YAAY,OAAO,aAAa,CAAC;GACxC,eAAe,OAAO,WAAW,eAAe;EAClD;EACA,IAAI,OAAO,WACT,OAAO,YAAY;GAAE,GAAI,OAAO,aAAa,CAAC;GAAI,GAAG,OAAO;EAAU;CAE1E;CAEA,MAAM,QAAQ,WAA6B;EACzC,IAAI,QAAQ,IAAI,MAAM,GAAG;GACvB,SAAS,KAAK,yCAAyC;GACvD;EACF;EACA,QAAQ,IAAI,MAAM;EAClB,MAAM,YAAY,OAAO,aAAa,CAAC;EACvC,IAAI,MAAM,QAAQ,SAAS,GACzB,KAAK,MAAM,YAAY,WAAW;GAChC,IAAI,CAAC,YAAY,CAAC,cAAc,QAAQ,GAAG;IACzC,SAAS,KAAK,6CAA6C;IAC3D;GACF;GACA,KAAK,QAA4B;GACjC,eAAe,QAA4B;EAC7C;OAEG,IAAI,WACP,SAAS,KAAK,wCAAwC;CAE1D;CAEA,KAAK,SAAS;CACd,eAAe,SAAS;CAExB,OAAO;EACL,WAAW;EACX;CACF;AACF"}
@@ -3,35 +3,62 @@ import { createRenderContext } from "../renderContext.mjs";
3
3
  import { hasOwn } from "../utils/object.mjs";
4
4
  import { createScopedSelectorQuery, resolveRenderRoot, selectRuntimeComponent, selectRuntimeComponents } from "./dom.mjs";
5
5
  import { bindRuntimeEvents } from "./events.mjs";
6
+ import { runComponentObservers } from "./observers.mjs";
7
+ import { createComponentPublicInstance } from "./publicInstance.mjs";
8
+ import { resolveRelationNodes } from "./relations.mjs";
9
+ import { createWebSlotsProxy } from "./slots.mjs";
6
10
  import { cloneValue, coerceValue, toCamelCase } from "./utils.mjs";
11
+ import { clearVirtualHostClasses, clearVirtualHostParts, syncVirtualHostClasses, syncVirtualHostParts } from "./virtualHost.mjs";
7
12
  import { html } from "lit";
8
13
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
9
14
 
10
15
  //#region src/runtime/component/element.ts
16
+ function resolveComposedParent(node) {
17
+ const assignedSlot = node.assignedSlot;
18
+ if (assignedSlot) return assignedSlot;
19
+ if (node.parentNode) return node.parentNode;
20
+ const root = node.getRootNode?.();
21
+ return root instanceof ShadowRoot ? root.host : void 0;
22
+ }
23
+ function isWeappComponentInstance(value) {
24
+ return Boolean(value && typeof value === "object" && typeof value.__weappSync === "function");
25
+ }
11
26
  function createComponentElementClass({ BaseElement, runtimeState, instances }) {
12
- class WeappWebComponent extends BaseElement {
13
- static observedAttributes = runtimeState.observedAttributes;
27
+ const RuntimeBaseElement = BaseElement;
28
+ class WeappWebComponent extends RuntimeBaseElement {
29
+ static get observedAttributes() {
30
+ const inherited = super.observedAttributes ?? [];
31
+ return Array.from(/* @__PURE__ */ new Set([...inherited, ...runtimeState.observedAttributes]));
32
+ }
14
33
  #state;
15
34
  #properties;
16
- #methods;
35
+ #methods = {};
36
+ #publicInstance;
37
+ #exposedMethodNames = /* @__PURE__ */ new Set();
17
38
  #isMounted = false;
18
39
  #renderContext = createRenderContext(this, {});
19
40
  #usesLegacyTemplate = false;
20
41
  #readyFired = false;
21
42
  #observerInitDone = false;
22
43
  #observedKeys = /* @__PURE__ */ new Set();
44
+ #virtualHostClassTokens = /* @__PURE__ */ new Set();
45
+ #virtualHostPartTokens = /* @__PURE__ */ new Set();
46
+ #virtualHostRootElement;
23
47
  data;
24
48
  properties;
25
49
  constructor() {
26
50
  super();
27
- const dataOption = typeof runtimeState.componentRef.data === "function" ? runtimeState.componentRef.data() : runtimeState.componentRef.data ?? {};
51
+ const dataOption = runtimeState.componentRef.data ?? {};
28
52
  this.#properties = { ...runtimeState.defaultPropertyValues };
29
53
  this.#state = {
30
54
  ...cloneValue(this.#properties),
31
55
  ...cloneValue(dataOption)
32
56
  };
33
- this.#methods = {};
34
- this.#syncMethods(runtimeState.componentRef.methods ?? {});
57
+ Object.defineProperty(this.#state, "$slots", {
58
+ configurable: true,
59
+ enumerable: true,
60
+ value: createWebSlotsProxy(() => this.#state.vueSlots)
61
+ });
35
62
  Object.defineProperties(this, {
36
63
  data: {
37
64
  configurable: true,
@@ -44,28 +71,34 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
44
71
  get: () => this.#properties
45
72
  }
46
73
  });
74
+ this.#publicInstance = createComponentPublicInstance(this, WeappWebComponent.prototype, (key) => typeof key === "string" ? this.#methods[key] : void 0);
47
75
  for (const [propName] of runtimeState.propertyEntries) Object.defineProperty(this, propName, {
48
76
  configurable: true,
49
77
  enumerable: true,
50
78
  get: () => this.#state[propName],
51
79
  set: (value) => this.#setProperty(propName, value)
52
80
  });
81
+ this.#syncMethods(runtimeState.componentRef.methods ?? {});
53
82
  if (!supportsLit) {
54
83
  const host = this;
55
84
  if (!host.shadowRoot && typeof host.attachShadow === "function") host.attachShadow({ mode: "open" });
56
85
  this.renderRoot = host.shadowRoot ?? host;
57
86
  }
58
87
  instances.add(this);
59
- runtimeState.lifetimes.created?.call(this);
88
+ runtimeState.lifetimes.created?.call(this.#publicInstance);
60
89
  }
61
- setData(patch) {
62
- this.#applyDataPatch(patch);
90
+ setData(patch, callback) {
91
+ const changed = this.#applyDataPatch(patch);
92
+ if (supportsLit && changed) return this.updateComplete.then(() => {
93
+ callback?.();
94
+ });
95
+ callback?.();
63
96
  }
64
- triggerEvent(name, detail) {
97
+ triggerEvent(name, detail, options = {}) {
65
98
  this.dispatchEvent(new CustomEvent(name, {
66
99
  detail,
67
- bubbles: true,
68
- composed: true
100
+ bubbles: options.bubbles ?? false,
101
+ composed: options.composed ?? false
69
102
  }));
70
103
  }
71
104
  createSelectorQuery() {
@@ -77,12 +110,23 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
77
110
  selectAllComponents(selector) {
78
111
  return selectRuntimeComponents(this, selector);
79
112
  }
113
+ getRelationNodes(relationPath) {
114
+ const relation = runtimeState.componentRef.relations?.[relationPath];
115
+ return relation ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type) : [];
116
+ }
117
+ selectOwnerComponent() {
118
+ let current = resolveComposedParent(this);
119
+ while (current) {
120
+ if (isWeappComponentInstance(current)) return current;
121
+ current = resolveComposedParent(current);
122
+ }
123
+ }
80
124
  connectedCallback() {
81
125
  const superConnected = BaseElement.prototype.connectedCallback;
82
126
  if (supportsLit && typeof superConnected === "function") superConnected.call(this);
83
127
  this.#applyAttributes();
84
128
  if (runtimeState.observerInitEnabled) this.#runInitialObservers();
85
- runtimeState.lifetimes.attached?.call(this);
129
+ runtimeState.lifetimes.attached?.call(this.#publicInstance);
86
130
  this.#isMounted = true;
87
131
  if (!supportsLit) this.#renderLegacy();
88
132
  }
@@ -91,7 +135,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
91
135
  if (supportsLit && typeof superDisconnected === "function") superDisconnected.call(this);
92
136
  this.#isMounted = false;
93
137
  instances.delete(this);
94
- runtimeState.lifetimes.detached?.call(this);
138
+ runtimeState.lifetimes.detached?.call(this.#publicInstance);
95
139
  }
96
140
  attributeChangedCallback(attrName, oldValue, newValue) {
97
141
  const superAttributeChanged = BaseElement.prototype.attributeChangedCallback;
@@ -102,10 +146,11 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
102
146
  this.#setProperty(propName, coerceValue(newValue, propOption?.type));
103
147
  }
104
148
  firstUpdated() {
105
- runtimeState.lifetimes.ready?.call(this);
149
+ runtimeState.lifetimes.ready?.call(this.#publicInstance);
106
150
  this.#readyFired = true;
107
151
  }
108
152
  updated() {
153
+ this.#syncVirtualHostClasses();
109
154
  if (this.#usesLegacyTemplate) bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this);
110
155
  }
111
156
  render() {
@@ -129,23 +174,27 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
129
174
  for (const attr of this.attributes) this.attributeChangedCallback(attr.name, null, attr.value);
130
175
  }
131
176
  #applyDataPatch(patch) {
132
- if (!patch || typeof patch !== "object") return;
177
+ if (!patch || typeof patch !== "object") return false;
133
178
  let changed = false;
179
+ const changedKeys = [];
180
+ const previousProperties = {};
134
181
  for (const [key, value] of Object.entries(patch)) {
135
182
  if (this.#state[key] === value) continue;
136
183
  const oldValue = this.#state[key];
137
184
  this.#state[key] = value;
138
185
  if (hasOwn(this.#properties, key)) {
186
+ previousProperties[key] = oldValue;
139
187
  this.#properties[key] = value;
140
- const propOption = runtimeState.componentRef.properties?.[key];
141
- if (propOption?.observer) {
142
- propOption.observer.call(this, value, oldValue);
143
- this.#observedKeys.add(key);
144
- }
145
188
  }
189
+ changedKeys.push(key);
146
190
  changed = true;
147
191
  }
148
- if (changed) this.requestUpdate();
192
+ if (changed) {
193
+ this.requestUpdate();
194
+ runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties);
195
+ for (const key of changedKeys) if (runtimeState.componentRef.properties?.[key]?.observer) this.#observedKeys.add(key);
196
+ }
197
+ return changed;
149
198
  }
150
199
  #setProperty(name, value) {
151
200
  const propOption = runtimeState.componentRef.properties?.[name];
@@ -155,10 +204,8 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
155
204
  this.#properties[name] = coerced;
156
205
  this.#state[name] = coerced;
157
206
  if (this.#isMounted) this.requestUpdate();
158
- if (propOption?.observer) {
159
- propOption.observer.call(this, coerced, oldValue);
160
- this.#observedKeys.add(name);
161
- }
207
+ runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue });
208
+ if (propOption?.observer) this.#observedKeys.add(name);
162
209
  }
163
210
  #runInitialObservers() {
164
211
  if (this.#observerInitDone) return;
@@ -166,16 +213,32 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
166
213
  for (const [propName, propOption] of runtimeState.propertyEntries) {
167
214
  if (!propOption.observer || this.#observedKeys.has(propName)) continue;
168
215
  const value = this.#state[propName];
169
- propOption.observer.call(this, value, void 0);
216
+ propOption.observer.call(this.#publicInstance, value, void 0);
170
217
  this.#observedKeys.add(propName);
171
218
  }
172
219
  }
173
220
  #syncMethods(nextMethods) {
174
221
  const resolved = nextMethods ?? {};
175
222
  const bound = {};
176
- for (const [name, fn] of Object.entries(resolved)) if (typeof fn === "function") bound[name] = fn.bind(this);
223
+ for (const [name, fn] of Object.entries(resolved)) if (typeof fn === "function") bound[name] = fn.bind(this.#publicInstance);
224
+ for (const name of this.#exposedMethodNames) {
225
+ if (name in bound) continue;
226
+ const descriptor = Object.getOwnPropertyDescriptor(this, name);
227
+ if (descriptor?.configurable && descriptor.value === this.#methods[name]) delete this[name];
228
+ this.#exposedMethodNames.delete(name);
229
+ }
177
230
  for (const key of Object.keys(this.#methods)) if (!(key in bound)) delete this.#methods[key];
178
- for (const [key, fn] of Object.entries(bound)) this.#methods[key] = fn;
231
+ for (const [key, fn] of Object.entries(bound)) {
232
+ this.#methods[key] = fn;
233
+ if (!this.#exposedMethodNames.has(key) && key in this) continue;
234
+ Object.defineProperty(this, key, {
235
+ configurable: true,
236
+ enumerable: false,
237
+ writable: true,
238
+ value: fn
239
+ });
240
+ this.#exposedMethodNames.add(key);
241
+ }
179
242
  this.#renderContext = createRenderContext(this, this.#methods);
180
243
  }
181
244
  __weappSync(nextMethods) {
@@ -184,7 +247,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
184
247
  }
185
248
  __weappInvokePageLifetime(type) {
186
249
  const hook = runtimeState.pageLifetimes[type];
187
- if (typeof hook === "function") hook.call(this);
250
+ if (typeof hook === "function") hook.call(this.#publicInstance);
188
251
  }
189
252
  #renderLegacy() {
190
253
  const result = runtimeState.templateRef(this.#state, this.#renderContext);
@@ -195,11 +258,24 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
195
258
  bindRuntimeEvents(root, this.#methods, this);
196
259
  } else if (result == null) root.innerHTML = styleMarkup;
197
260
  else root.innerHTML = `${styleMarkup}${String(result)}`;
261
+ this.#syncVirtualHostClasses();
198
262
  if (!this.#readyFired) {
199
- runtimeState.lifetimes.ready?.call(this);
263
+ runtimeState.lifetimes.ready?.call(this.#publicInstance);
200
264
  this.#readyFired = true;
201
265
  }
202
266
  }
267
+ #syncVirtualHostClasses() {
268
+ const host = this;
269
+ if (!runtimeState.componentRef.options?.virtualHost) {
270
+ clearVirtualHostClasses(host, this.#virtualHostClassTokens);
271
+ clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens);
272
+ this.#virtualHostRootElement = void 0;
273
+ return;
274
+ }
275
+ const root = resolveRenderRoot(this);
276
+ syncVirtualHostClasses(host, root, this.#virtualHostClassTokens);
277
+ this.#virtualHostRootElement = syncVirtualHostParts(root, this.#virtualHostRootElement, this.#virtualHostPartTokens);
278
+ }
203
279
  }
204
280
  return WeappWebComponent;
205
281
  }
@@ -1 +1 @@
1
- {"version":3,"file":"element.mjs","names":["#properties","#state","#methods","#syncMethods","#setProperty","#applyDataPatch","#applyAttributes","#runInitialObservers","#isMounted","#renderLegacy","#readyFired","#usesLegacyTemplate","#renderContext","#observedKeys","#observerInitDone"],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n DataRecord,\n PageLifeTimeHooks,\n} from './types'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { cloneValue, coerceValue, toCamelCase } from './utils'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n class WeappWebComponent extends BaseElement implements WeappComponentInstance {\n static observedAttributes = runtimeState.observedAttributes\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any>\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = typeof runtimeState.componentRef.data === 'function'\n ? (runtimeState.componentRef.data as () => DataRecord)()\n : (runtimeState.componentRef.data ?? {})\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n this.#methods = {}\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this)\n }\n\n setData(patch: DataRecord) {\n this.#applyDataPatch(patch)\n }\n\n triggerEvent(name: string, detail?: any) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: true,\n composed: true,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this)\n this.#readyFired = true\n }\n\n updated() {\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return\n }\n let changed = false\n for (const [key, value] of Object.entries(patch)) {\n if (this.#state[key] === value) {\n continue\n }\n const oldValue = this.#state[key]\n this.#state[key] = value\n if (hasOwn(this.#properties, key)) {\n this.#properties[key] = value\n const propOption = runtimeState.componentRef.properties?.[key]\n if (propOption?.observer) {\n propOption.observer.call(this, value, oldValue)\n this.#observedKeys.add(key)\n }\n }\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n }\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n if (propOption?.observer) {\n propOption.observer.call(this, coerced, oldValue)\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this)\n }\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this)\n this.#readyFired = true\n }\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;AA4BA,SAAgB,4BAA4B,EAC1C,aACA,cACA,aACiE;CACjE,MAAM,0BAA0B,YAA8C;EAC5E,OAAO,qBAAqB,aAAa;EAEzC;EACA;EACA;EACA,aAAa;EACb,iBAAiB,oBAAoB,MAAM,CAAC,CAAC;EAC7C,sBAAsB;EACtB,cAAc;EACd,oBAAoB;EACpB,gCAAgB,IAAI,IAAY;EAChC,AAAS;EACT,AAAS;EAET,cAAc;GACZ,MAAM;GACN,MAAM,aAAa,OAAO,aAAa,aAAa,SAAS,aACxD,aAAa,aAAa,KAA0B,IACpD,aAAa,aAAa,QAAQ,CAAC;GACxC,KAAKA,cA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,KAAKA,cAAc;GACrB;EACF;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"element.mjs","names":["#properties","#state","#publicInstance","#methods","#setProperty","#syncMethods","#applyDataPatch","#applyAttributes","#runInitialObservers","#isMounted","#renderLegacy","#readyFired","#syncVirtualHostClasses","#usesLegacyTemplate","#renderContext","#observedKeys","#observerInitDone","#exposedMethodNames","#virtualHostClassTokens","#virtualHostRootElement","#virtualHostPartTokens"],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n PageLifeTimeHooks,\n TriggerEventOptions,\n} from './types'\nimport type { ClassAttributeElement } from './virtualHost'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { runComponentObservers } from './observers'\nimport { createComponentPublicInstance } from './publicInstance'\nimport { resolveRelationNodes } from './relations'\nimport { createWebSlotsProxy } from './slots'\nimport { cloneValue, coerceValue, toCamelCase } from './utils'\nimport {\n clearVirtualHostClasses,\n clearVirtualHostParts,\n syncVirtualHostClasses,\n syncVirtualHostParts,\n} from './virtualHost'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nfunction resolveComposedParent(node: Node): Node | undefined {\n const assignedSlot = (node as Element).assignedSlot\n if (assignedSlot) {\n return assignedSlot\n }\n if (node.parentNode) {\n return node.parentNode\n }\n const root = node.getRootNode?.()\n return root instanceof ShadowRoot ? root.host : undefined\n}\n\nfunction isWeappComponentInstance(value: unknown): value is WeappComponentInstance {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as WeappComponentInstance).__weappSync === 'function',\n )\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n const RuntimeBaseElement = BaseElement as typeof HTMLElement & {\n readonly observedAttributes?: string[]\n }\n class WeappWebComponent extends RuntimeBaseElement implements WeappComponentInstance {\n static get observedAttributes() {\n const inherited = super.observedAttributes ?? []\n return Array.from(new Set([...inherited, ...runtimeState.observedAttributes]))\n }\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any> = {}\n #publicInstance: ComponentPublicInstance\n #exposedMethodNames = new Set<string>()\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n #virtualHostClassTokens = new Set<string>()\n #virtualHostPartTokens = new Set<string>()\n #virtualHostRootElement: ClassAttributeElement | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = runtimeState.componentRef.data ?? {}\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n Object.defineProperty(this.#state, '$slots', {\n configurable: true,\n enumerable: true,\n value: createWebSlotsProxy(() => this.#state.vueSlots),\n })\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n this.#publicInstance = createComponentPublicInstance(\n this,\n WeappWebComponent.prototype,\n key => typeof key === 'string' ? this.#methods[key] : undefined,\n )\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this.#publicInstance)\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && changed) {\n const updateComplete = (this as unknown as { updateComplete: Promise<boolean> }).updateComplete\n return updateComplete.then(() => {\n callback?.()\n })\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n getRelationNodes(relationPath: string) {\n const relation = runtimeState.componentRef.relations?.[relationPath]\n return relation\n ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type)\n : []\n }\n\n selectOwnerComponent() {\n let current = resolveComposedParent(this)\n while (current) {\n if (isWeappComponentInstance(current)) {\n return current\n }\n current = resolveComposedParent(current)\n }\n return undefined\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this.#publicInstance)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this.#publicInstance)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n\n updated() {\n this.#syncVirtualHostClasses()\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return false\n }\n let changed = false\n const changedKeys: string[] = []\n const previousProperties: DataRecord = {}\n for (const [key, value] of Object.entries(patch)) {\n if (this.#state[key] === value) {\n continue\n }\n const oldValue = this.#state[key]\n this.#state[key] = value\n if (hasOwn(this.#properties, key)) {\n previousProperties[key] = oldValue\n this.#properties[key] = value\n }\n changedKeys.push(key)\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties)\n for (const key of changedKeys) {\n if (runtimeState.componentRef.properties?.[key]?.observer) {\n this.#observedKeys.add(key)\n }\n }\n }\n return changed\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue })\n if (propOption?.observer) {\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this.#publicInstance, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this.#publicInstance)\n }\n }\n for (const name of this.#exposedMethodNames) {\n if (name in bound) {\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(this, name)\n if (descriptor?.configurable && descriptor.value === this.#methods[name]) {\n delete (this as unknown as Record<string, unknown>)[name]\n }\n this.#exposedMethodNames.delete(name)\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n if (!this.#exposedMethodNames.has(key) && key in this) {\n continue\n }\n Object.defineProperty(this, key, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: fn,\n })\n this.#exposedMethodNames.add(key)\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this.#publicInstance)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n this.#syncVirtualHostClasses()\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n }\n\n #syncVirtualHostClasses() {\n const host = this as unknown as ClassAttributeElement\n if (!runtimeState.componentRef.options?.virtualHost) {\n clearVirtualHostClasses(host, this.#virtualHostClassTokens)\n clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens)\n this.#virtualHostRootElement = undefined\n return\n }\n const root = resolveRenderRoot(this)\n syncVirtualHostClasses(host, root, this.#virtualHostClassTokens)\n this.#virtualHostRootElement = syncVirtualHostParts(\n root,\n this.#virtualHostRootElement,\n this.#virtualHostPartTokens,\n )\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAS,sBAAsB,MAA8B;CAC3D,MAAM,eAAgB,KAAiB;CACvC,IAAI,cACF,OAAO;CAET,IAAI,KAAK,YACP,OAAO,KAAK;CAEd,MAAM,OAAO,KAAK,cAAc;CAChC,OAAO,gBAAgB,aAAa,KAAK,O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