@weapp-vite/web 1.3.37 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/README.md +144 -5
  2. package/dist/_virtual/_rolldown/runtime.mjs +19 -1
  3. package/dist/compiler/wxml/attributes.mjs +1 -1
  4. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  5. package/dist/compiler/wxml/compile.mjs +6 -3
  6. package/dist/compiler/wxml/compile.mjs.map +1 -1
  7. package/dist/compiler/wxml/interpolation.mjs +1 -2
  8. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  9. package/dist/compiler/wxml/navigation.mjs +5 -7
  10. package/dist/compiler/wxml/navigation.mjs.map +1 -1
  11. package/dist/compiler/wxml/parser.mjs +5 -5
  12. package/dist/compiler/wxml/parser.mjs.map +1 -1
  13. package/dist/compiler/wxml/renderer.mjs +16 -12
  14. package/dist/compiler/wxml/renderer.mjs.map +1 -1
  15. package/dist/compiler/wxml/specialNodes.mjs +8 -2
  16. package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
  17. package/dist/compiler/wxml/types.d.mts +12 -0
  18. package/dist/compiler/wxs.mjs +5 -5
  19. package/dist/compiler/wxs.mjs.map +1 -1
  20. package/dist/css/wxss.d.mts +1 -0
  21. package/dist/css/wxss.mjs +110 -9
  22. package/dist/css/wxss.mjs.map +1 -1
  23. package/dist/index.d.mts +24 -6
  24. package/dist/index.mjs +21 -4
  25. package/dist/plugin/assets.d.mts +7 -0
  26. package/dist/plugin/assets.mjs +122 -0
  27. package/dist/plugin/assets.mjs.map +1 -0
  28. package/dist/plugin/constants.mjs +10 -1
  29. package/dist/plugin/constants.mjs.map +1 -1
  30. package/dist/plugin/dependencyScan.mjs +41 -0
  31. package/dist/plugin/dependencyScan.mjs.map +1 -0
  32. package/dist/plugin/entry.mjs +55 -6
  33. package/dist/plugin/entry.mjs.map +1 -1
  34. package/dist/plugin/files.mjs +1 -1
  35. package/dist/plugin/files.mjs.map +1 -1
  36. package/dist/plugin/index.d.mts +37 -3
  37. package/dist/plugin/index.mjs +244 -73
  38. package/dist/plugin/index.mjs.map +1 -1
  39. package/dist/plugin/layout.mjs +24 -0
  40. package/dist/plugin/layout.mjs.map +1 -0
  41. package/dist/plugin/path.mjs +6 -2
  42. package/dist/plugin/path.mjs.map +1 -1
  43. package/dist/plugin/register.mjs +45 -33
  44. package/dist/plugin/register.mjs.map +1 -1
  45. package/dist/plugin/scan.mjs +211 -92
  46. package/dist/plugin/scan.mjs.map +1 -1
  47. package/dist/plugin/scanSfc.mjs +65 -0
  48. package/dist/plugin/scanSfc.mjs.map +1 -0
  49. package/dist/plugin/state.mjs +3 -2
  50. package/dist/plugin/state.mjs.map +1 -1
  51. package/dist/plugin/styleModule.mjs +52 -0
  52. package/dist/plugin/styleModule.mjs.map +1 -0
  53. package/dist/plugin/types.d.mts +37 -1
  54. package/dist/plugin/vueSfc.mjs +150 -0
  55. package/dist/plugin/vueSfc.mjs.map +1 -0
  56. package/dist/runtime/appShell/container.mjs +25 -0
  57. package/dist/runtime/appShell/container.mjs.map +1 -0
  58. package/dist/runtime/appShell/tabBar/index.mjs +192 -0
  59. package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
  60. package/dist/runtime/appShell/tabBar/style.mjs +127 -0
  61. package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
  62. package/dist/runtime/button/helpers.mjs +1 -58
  63. package/dist/runtime/button/helpers.mjs.map +1 -1
  64. package/dist/runtime/button/index.d.mts +4 -5
  65. package/dist/runtime/button/index.mjs +6 -28
  66. package/dist/runtime/button/index.mjs.map +1 -1
  67. package/dist/runtime/button/style.mjs +53 -28
  68. package/dist/runtime/button/style.mjs.map +1 -1
  69. package/dist/runtime/component/behavior.mjs +26 -2
  70. package/dist/runtime/component/behavior.mjs.map +1 -1
  71. package/dist/runtime/component/element.mjs +107 -31
  72. package/dist/runtime/component/element.mjs.map +1 -1
  73. package/dist/runtime/component/observers.mjs +36 -0
  74. package/dist/runtime/component/observers.mjs.map +1 -0
  75. package/dist/runtime/component/publicInstance.mjs +48 -0
  76. package/dist/runtime/component/publicInstance.mjs.map +1 -0
  77. package/dist/runtime/component/relations.mjs +36 -0
  78. package/dist/runtime/component/relations.mjs.map +1 -0
  79. package/dist/runtime/component/slots.mjs +24 -0
  80. package/dist/runtime/component/slots.mjs.map +1 -0
  81. package/dist/runtime/component/state.mjs +13 -3
  82. package/dist/runtime/component/state.mjs.map +1 -1
  83. package/dist/runtime/component/types.d.mts +29 -4
  84. package/dist/runtime/component/virtualHost.mjs +83 -0
  85. package/dist/runtime/component/virtualHost.mjs.map +1 -0
  86. package/dist/runtime/host/index.d.mts +13 -0
  87. package/dist/runtime/host/index.mjs +47 -0
  88. package/dist/runtime/host/index.mjs.map +1 -0
  89. package/dist/runtime/host/types.d.mts +28 -0
  90. package/dist/runtime/hostGlobals.d.mts +9 -0
  91. package/dist/runtime/hostGlobals.mjs +39 -0
  92. package/dist/runtime/hostGlobals.mjs.map +1 -0
  93. package/dist/runtime/index.d.mts +21 -3
  94. package/dist/runtime/index.mjs +26 -4
  95. package/dist/runtime/index.mjs.map +1 -0
  96. package/dist/runtime/legacyTemplate/dom.mjs +3 -3
  97. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  98. package/dist/runtime/legacyTemplate/expression.mjs +9 -9
  99. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
  100. package/dist/runtime/legacyTemplate/index.mjs +6 -6
  101. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  102. package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
  103. package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
  104. package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
  105. package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
  106. package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
  107. package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
  108. package/dist/runtime/nativeComponents/form.d.mts +7 -0
  109. package/dist/runtime/nativeComponents/form.mjs +50 -0
  110. package/dist/runtime/nativeComponents/form.mjs.map +1 -0
  111. package/dist/runtime/nativeComponents/formControl.mjs +61 -0
  112. package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
  113. package/dist/runtime/nativeComponents/helpers.mjs +25 -0
  114. package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
  115. package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
  116. package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
  117. package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
  118. package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
  119. package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
  120. package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
  121. package/dist/runtime/nativeComponents/image.d.mts +8 -0
  122. package/dist/runtime/nativeComponents/image.mjs +121 -0
  123. package/dist/runtime/nativeComponents/image.mjs.map +1 -0
  124. package/dist/runtime/nativeComponents/index.d.mts +11 -0
  125. package/dist/runtime/nativeComponents/index.mjs +83 -0
  126. package/dist/runtime/nativeComponents/index.mjs.map +1 -0
  127. package/dist/runtime/nativeComponents/input.d.mts +8 -0
  128. package/dist/runtime/nativeComponents/input.mjs +131 -0
  129. package/dist/runtime/nativeComponents/input.mjs.map +1 -0
  130. package/dist/runtime/nativeComponents/label.mjs +36 -0
  131. package/dist/runtime/nativeComponents/label.mjs.map +1 -0
  132. package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
  133. package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
  134. package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
  135. package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
  136. package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
  137. package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
  138. package/dist/runtime/nativeComponents/navigator.mjs +200 -0
  139. package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
  140. package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
  141. package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
  142. package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
  143. package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
  144. package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
  145. package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
  146. package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
  147. package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
  148. package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
  149. package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
  150. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
  151. package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
  152. package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
  153. package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
  154. package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
  155. package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
  156. package/dist/runtime/nativeComponents/primitives.mjs +16 -0
  157. package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
  158. package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
  159. package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
  160. package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
  161. package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
  162. package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
  163. package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
  164. package/dist/runtime/nativeComponents/radio.mjs +147 -0
  165. package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
  166. package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
  167. package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
  168. package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
  169. package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
  170. package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
  171. package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
  172. package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
  173. package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
  174. package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
  175. package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
  176. package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
  177. package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
  178. package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
  179. package/dist/runtime/nativeComponents/style.mjs +41 -0
  180. package/dist/runtime/nativeComponents/style.mjs.map +1 -0
  181. package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
  182. package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
  183. package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
  184. package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
  185. package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
  186. package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
  187. package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
  188. package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
  189. package/dist/runtime/nativeComponents/switch.d.mts +7 -0
  190. package/dist/runtime/nativeComponents/switch.mjs +132 -0
  191. package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
  192. package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
  193. package/dist/runtime/nativeComponents/textarea.mjs +144 -0
  194. package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
  195. package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
  196. package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
  197. package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
  198. package/dist/runtime/nativeComponents/video/index.mjs +124 -0
  199. package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
  200. package/dist/runtime/nativeComponents/video/style.mjs +14 -0
  201. package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
  202. package/dist/runtime/navigationBar/index.mjs +1 -3
  203. package/dist/runtime/navigationBar/index.mjs.map +1 -1
  204. package/dist/runtime/pageLayout.d.mts +9 -0
  205. package/dist/runtime/pageLayout.mjs +16 -0
  206. package/dist/runtime/pageLayout.mjs.map +1 -0
  207. package/dist/runtime/polyfill/animation.mjs +120 -0
  208. package/dist/runtime/polyfill/animation.mjs.map +1 -0
  209. package/dist/runtime/polyfill/appState.mjs +1 -1
  210. package/dist/runtime/polyfill/appState.mjs.map +1 -1
  211. package/dist/runtime/polyfill/async.d.mts +7 -0
  212. package/dist/runtime/polyfill/async.mjs.map +1 -1
  213. package/dist/runtime/polyfill/canvasContext.mjs +41 -0
  214. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
  215. package/dist/runtime/polyfill/device.mjs +1 -1
  216. package/dist/runtime/polyfill/device.mjs.map +1 -1
  217. package/dist/runtime/polyfill/deviceApi.mjs +6 -3
  218. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
  219. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
  220. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
  221. package/dist/runtime/polyfill/eventBus.mjs +56 -0
  222. package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
  223. package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
  224. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
  225. package/dist/runtime/polyfill/files.mjs +10 -10
  226. package/dist/runtime/polyfill/files.mjs.map +1 -1
  227. package/dist/runtime/polyfill/font.mjs +33 -0
  228. package/dist/runtime/polyfill/font.mjs.map +1 -0
  229. package/dist/runtime/polyfill/index.d.mts +2 -2
  230. package/dist/runtime/polyfill/index.mjs +49 -45
  231. package/dist/runtime/polyfill/index.mjs.map +1 -1
  232. package/dist/runtime/polyfill/interaction.mjs +7 -6
  233. package/dist/runtime/polyfill/interaction.mjs.map +1 -1
  234. package/dist/runtime/polyfill/interactionApi.mjs +9 -5
  235. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
  236. package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
  237. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
  238. package/dist/runtime/polyfill/locale.mjs +14 -0
  239. package/dist/runtime/polyfill/locale.mjs.map +1 -0
  240. package/dist/runtime/polyfill/locationApi.mjs +11 -6
  241. package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
  242. package/dist/runtime/polyfill/mediaActions.mjs +2 -2
  243. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
  244. package/dist/runtime/polyfill/mediaApi/file.mjs +3 -2
  245. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
  246. package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
  247. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
  248. package/dist/runtime/polyfill/mediaApi/picker.mjs +16 -8
  249. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
  250. package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
  251. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
  252. package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
  253. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
  254. package/dist/runtime/polyfill/menuApi.mjs +39 -4
  255. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  256. package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
  257. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
  258. package/dist/runtime/polyfill/network/request.mjs +2 -2
  259. package/dist/runtime/polyfill/network/request.mjs.map +1 -1
  260. package/dist/runtime/polyfill/platformApi.mjs +3 -2
  261. package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
  262. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
  263. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
  264. package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
  265. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  266. package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
  267. package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
  268. package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
  269. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
  270. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  271. package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
  272. package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
  273. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  274. package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
  275. package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
  276. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
  277. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
  278. package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
  279. package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
  280. package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
  281. package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
  282. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  283. package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
  284. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
  285. package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
  286. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
  287. package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
  288. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  289. package/dist/runtime/polyfill/storage.mjs +5 -2
  290. package/dist/runtime/polyfill/storage.mjs.map +1 -1
  291. package/dist/runtime/polyfill/storageAsync.mjs +4 -2
  292. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
  293. package/dist/runtime/polyfill/system.mjs +31 -4
  294. package/dist/runtime/polyfill/system.mjs.map +1 -1
  295. package/dist/runtime/polyfill/systemApi.mjs +2 -1
  296. package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
  297. package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
  298. package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
  299. package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
  300. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
  301. package/dist/runtime/polyfill/ui.mjs +2 -6
  302. package/dist/runtime/polyfill/ui.mjs.map +1 -1
  303. package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
  304. package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
  305. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  306. package/dist/runtime/polyfill/videoContext.mjs +4 -0
  307. package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
  308. package/dist/runtime/polyfill/vkSession.mjs +4 -14
  309. package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
  310. package/dist/runtime/polyfill.d.mts +2 -2
  311. package/dist/runtime/renderContext.mjs +1 -1
  312. package/dist/runtime/renderContext.mjs.map +1 -1
  313. package/dist/runtime/rpx.mjs +17 -8
  314. package/dist/runtime/rpx.mjs.map +1 -1
  315. package/dist/runtime/seo/index.d.mts +31 -0
  316. package/dist/runtime/seo/index.mjs +94 -0
  317. package/dist/runtime/seo/index.mjs.map +1 -0
  318. package/dist/runtime/viewport/index.d.mts +12 -0
  319. package/dist/runtime/viewport/index.mjs +44 -0
  320. package/dist/runtime/viewport/index.mjs.map +1 -0
  321. package/dist/runtime/viewport/style.mjs +62 -0
  322. package/dist/runtime/viewport/style.mjs.map +1 -0
  323. package/dist/runtime/viewport/types.d.mts +14 -0
  324. package/dist/runtime/wevu.d.mts +20 -0
  325. package/dist/runtime/wevu.mjs +73 -0
  326. package/dist/runtime/wevu.mjs.map +1 -0
  327. package/dist/shared/nativeComponents.mjs +401 -0
  328. package/dist/shared/nativeComponents.mjs.map +1 -0
  329. package/dist/shared/tabBar.d.mts +19 -0
  330. package/dist/shared/tabBar.mjs +37 -0
  331. package/dist/shared/tabBar.mjs.map +1 -0
  332. package/dist/shared/wxml.mjs +3 -20
  333. package/dist/shared/wxml.mjs.map +1 -1
  334. package/package.json +14 -6
@@ -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 }\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AClB,KAAK,KAAK,IAAI;EAElB;EAEA,gBAAgB;GACd,MAAM,SAAS,aAAa,YAAY,KAAKF,QAAQ,KAAKW,cAAc;GACxE,MAAM,OAAO,kBAAkB,IAAI;GACnC,MAAM,cAAc,aAAa,WAAW,UAAU,aAAa,SAAS,YAAY;GACxF,IAAI,OAAO,WAAW,UAAU;IAC9B,KAAK,YAAY,GAAG,cAAc;IAClC,kBAAkB,MAAoB,KAAKV,UAAU,IAAI;GAC3D,OACK,IAAI,UAAU,MACjB,KAAK,YAAY;QAGjB,KAAK,YAAY,GAAG,cAAc,OAAO,MAAM;GAEjD,IAAI,CAAC,KAAKQ,aAAa;IACrB,aAAa,UAAU,OAAO,KAAK,IAAI;IACvC,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,OAAO;AAClD;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAiC,gBAAgB,UAC9D;AACF;AAEA,SAAgB,4BAA4B,EAC1C,aACA,cACA,aACiE;CACjE,MAAM,qBAAqB;CAG3B,MAAM,0BAA0B,mBAAqD;EACnF,WAAW,qBAAqB;GAC9B,MAAM,YAAY,MAAM,sBAAsB,CAAC;GAC/C,OAAO,MAAM,qBAAK,IAAI,IAAI,CAAC,GAAG,WAAW,GAAG,aAAa,kBAAkB,CAAC,CAAC;EAC/E;EAEA;EACA;EACA,WAAgD,CAAC;EACjD;EACA,sCAAsB,IAAI,IAAY;EACtC,aAAa;EACb,iBAAiB,oBAAoB,MAAM,CAAC,CAAC;EAC7C,sBAAsB;EACtB,cAAc;EACd,oBAAoB;EACpB,gCAAgB,IAAI,IAAY;EAChC,0CAA0B,IAAI,IAAY;EAC1C,yCAAyB,IAAI,IAAY;EACzC;EACA,AAAS;EACT,AAAS;EAET,cAAc;GACZ,MAAM;GACN,MAAM,aAAa,aAAa,aAAa,QAAQ,CAAC;GACtD,KAAKA,cAAc,EAAE,GAAG,aAAa,sBAAsB;GAC3D,KAAKC,SAAS;IAAE,GAAG,WAAW,KAAKD,W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,KAAKS,cAAc;GACrB;EACF;EAEA,0BAA0B;GACxB,MAAM,OAAO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAKO,uBAAuB;IAC1D,sBAAsB,KAAKC,yBAAyB,KAAKC,sBAAsB;IAC/E,KAAKD,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAKD,uBAAuB;GAC/D,KAAKC,0BAA0B,qBAC7B,MACA,KAAKA,yBACL,KAAKC,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
@@ -0,0 +1,36 @@
1
+ //#region src/runtime/component/observers.ts
2
+ function normalizeObserverPattern(pattern) {
3
+ return pattern.split(",").map((item) => item.trim()).filter(Boolean);
4
+ }
5
+ function hasOwn(value, key) {
6
+ return Object.prototype.hasOwnProperty.call(value, key);
7
+ }
8
+ function resolveObservedValue(instance, pattern) {
9
+ if (pattern === "**") return {
10
+ ...instance.properties,
11
+ ...instance.data
12
+ };
13
+ const [root, ...rest] = pattern.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
14
+ let current = hasOwn(instance.properties, root) ? instance.properties[root] : instance.data[root];
15
+ for (const segment of rest) current = current?.[segment];
16
+ return current;
17
+ }
18
+ function matchesObserverPattern(pattern, changedKeys) {
19
+ if (pattern === "**") return changedKeys.length > 0;
20
+ return normalizeObserverPattern(pattern).some((observedKey) => {
21
+ if (observedKey === "**") return true;
22
+ return changedKeys.some((changedKey) => changedKey === observedKey || changedKey.startsWith(`${observedKey}.`) || changedKey.startsWith(`${observedKey}[`));
23
+ });
24
+ }
25
+ function runComponentObservers(component, instance, changedKeys, previousProperties = {}) {
26
+ if (!changedKeys.length) return;
27
+ for (const changedKey of changedKeys) (component.properties?.[changedKey])?.observer?.call(instance, instance.properties[changedKey], previousProperties[changedKey]);
28
+ for (const [pattern, observer] of Object.entries(component.observers ?? {})) {
29
+ if (typeof observer !== "function" || !matchesObserverPattern(pattern, changedKeys)) continue;
30
+ observer.call(instance, ...normalizeObserverPattern(pattern).map((item) => resolveObservedValue(instance, item)));
31
+ }
32
+ }
33
+
34
+ //#endregion
35
+ export { runComponentObservers };
36
+ //# sourceMappingURL=observers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observers.mjs","names":[],"sources":["../../../src/runtime/component/observers.ts"],"sourcesContent":["import type {\n ComponentPublicInstance,\n DataRecord,\n NormalizedComponentOptions,\n} from './types'\n\nfunction normalizeObserverPattern(pattern: string) {\n return pattern.split(',').map(item => item.trim()).filter(Boolean)\n}\n\nfunction hasOwn(value: object, key: PropertyKey) {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction resolveObservedValue(instance: ComponentPublicInstance, pattern: string) {\n if (pattern === '**') {\n return {\n ...instance.properties,\n ...instance.data,\n }\n }\n\n const segments = pattern\n .replace(/\\[(\\d+)\\]/g, '.$1')\n .split('.')\n .filter(Boolean)\n const [root, ...rest] = segments as [string, ...string[]]\n let current = hasOwn(instance.properties, root)\n ? instance.properties[root]\n : instance.data[root]\n for (const segment of rest) {\n current = current?.[segment]\n }\n return current\n}\n\nfunction matchesObserverPattern(pattern: string, changedKeys: string[]) {\n if (pattern === '**') {\n return changedKeys.length > 0\n }\n return normalizeObserverPattern(pattern).some((observedKey) => {\n if (observedKey === '**') {\n return true\n }\n return changedKeys.some(changedKey => (\n changedKey === observedKey\n || changedKey.startsWith(`${observedKey}.`)\n || changedKey.startsWith(`${observedKey}[`)\n ))\n })\n}\n\nexport function runComponentObservers(\n component: NormalizedComponentOptions,\n instance: ComponentPublicInstance,\n changedKeys: string[],\n previousProperties: DataRecord = {},\n) {\n if (!changedKeys.length) {\n return\n }\n\n for (const changedKey of changedKeys) {\n const option = component.properties?.[changedKey]\n option?.observer?.call(\n instance,\n instance.properties[changedKey],\n previousProperties[changedKey],\n )\n }\n\n for (const [pattern, observer] of Object.entries(component.observers ?? {})) {\n if (typeof observer !== 'function' || !matchesObserverPattern(pattern, changedKeys)) {\n continue\n }\n observer.call(\n instance,\n ...normalizeObserverPattern(pattern).map(item => resolveObservedValue(instance, item)),\n )\n }\n}\n"],"mappings":";AAMA,SAAS,yBAAyB,SAAiB;CACjD,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAI,SAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO;AACnE;AAEA,SAAS,OAAO,OAAe,KAAkB;CAC/C,OAAO,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG;AACxD;AAEA,SAAS,qBAAqB,UAAmC,SAAiB;CAChF,IAAI,YAAY,MACd,OAAO;EACL,GAAG,SAAS;EACZ,GAAG,SAAS;CACd;CAOF,MAAM,CAAC,MAAM,GAAG,QAJC,QACd,QAAQ,cAAc,KAAK,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAO,OACqB;CAC/B,IAAI,UAAU,OAAO,SAAS,YAAY,IAAI,IAC1C,SAAS,WAAW,QACpB,SAAS,KAAK;CAClB,KAAK,MAAM,WAAW,MACpB,UAAU,UAAU;CAEtB,OAAO;AACT;AAEA,SAAS,uBAAuB,SAAiB,aAAuB;CACtE,IAAI,YAAY,MACd,OAAO,YAAY,SAAS;CAE9B,OAAO,yBAAyB,OAAO,CAAC,CAAC,MAAM,gBAAgB;EAC7D,IAAI,gBAAgB,MAClB,OAAO;EAET,OAAO,YAAY,MAAK,eACtB,eAAe,eACZ,WAAW,WAAW,GAAG,YAAY,EAAE,KACvC,WAAW,WAAW,GAAG,YAAY,EAAE,CAC3C;CACH,CAAC;AACH;AAEA,SAAgB,sBACd,WACA,UACA,aACA,qBAAiC,CAAC,GAClC;CACA,IAAI,CAAC,YAAY,QACf;CAGF,KAAK,MAAM,cAAc,aAEvB,CADe,UAAU,aAAa,YAChC,EAAE,UAAU,KAChB,UACA,SAAS,WAAW,aACpB,mBAAmB,WACrB;CAGF,KAAK,MAAM,CAAC,SAAS,aAAa,OAAO,QAAQ,UAAU,aAAa,CAAC,CAAC,GAAG;EAC3E,IAAI,OAAO,aAAa,cAAc,CAAC,uBAAuB,SAAS,WAAW,GAChF;EAEF,SAAS,KACP,UACA,GAAG,yBAAyB,OAAO,CAAC,CAAC,KAAI,SAAQ,qBAAqB,UAAU,IAAI,CAAC,CACvF;CACF;AACF"}
@@ -0,0 +1,48 @@
1
+ //#region src/runtime/component/publicInstance.ts
2
+ const componentPublicInstanceTargets = /* @__PURE__ */ new WeakMap();
3
+ function resolveComponentPublicInstanceTarget(value) {
4
+ if (!value || typeof value !== "object") return;
5
+ return componentPublicInstanceTargets.get(value);
6
+ }
7
+ function createComponentPublicInstance(target, runtimePrototype, resolveComponentMethod) {
8
+ const runtimeMethods = /* @__PURE__ */ new Map();
9
+ const publicInstance = new Proxy(target, {
10
+ get(instance, key) {
11
+ if (Reflect.getOwnPropertyDescriptor(instance, key)) return Reflect.get(instance, key, instance);
12
+ if (Reflect.getOwnPropertyDescriptor(runtimePrototype, key)) {
13
+ const value = Reflect.get(instance, key, instance);
14
+ if (typeof value !== "function") return value;
15
+ const cached = runtimeMethods.get(key);
16
+ if (cached && cached.source === value) return cached.bound;
17
+ const bound = value.bind(instance);
18
+ runtimeMethods.set(key, {
19
+ source: value,
20
+ bound
21
+ });
22
+ return bound;
23
+ }
24
+ const componentMethod = resolveComponentMethod?.(key);
25
+ if (typeof componentMethod === "function") return componentMethod;
26
+ return typeof key === "symbol" ? Reflect.get(instance, key, instance) : void 0;
27
+ },
28
+ set(instance, key, value) {
29
+ if (Reflect.getOwnPropertyDescriptor(instance, key) || typeof key === "symbol") return Reflect.set(instance, key, value, instance);
30
+ Reflect.defineProperty(instance, key, {
31
+ configurable: true,
32
+ enumerable: true,
33
+ writable: true,
34
+ value
35
+ });
36
+ return true;
37
+ },
38
+ has(instance, key) {
39
+ return Reflect.getOwnPropertyDescriptor(instance, key) !== void 0 || Reflect.getOwnPropertyDescriptor(runtimePrototype, key) !== void 0 || typeof resolveComponentMethod?.(key) === "function" || typeof key === "symbol" && Reflect.has(instance, key);
40
+ }
41
+ });
42
+ componentPublicInstanceTargets.set(publicInstance, target);
43
+ return publicInstance;
44
+ }
45
+
46
+ //#endregion
47
+ export { createComponentPublicInstance, resolveComponentPublicInstanceTarget };
48
+ //# sourceMappingURL=publicInstance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicInstance.mjs","names":[],"sources":["../../../src/runtime/component/publicInstance.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './types'\n\nconst componentPublicInstanceTargets = new WeakMap<object, ComponentPublicInstance>()\n\nexport function resolveComponentPublicInstanceTarget(value: unknown) {\n if (!value || typeof value !== 'object') {\n return undefined\n }\n return componentPublicInstanceTargets.get(value)\n}\n\nexport function createComponentPublicInstance(\n target: ComponentPublicInstance,\n runtimePrototype: object,\n resolveComponentMethod?: (key: PropertyKey) => unknown,\n): ComponentPublicInstance {\n type RuntimeMethod = (...args: any[]) => unknown\n const runtimeMethods = new Map<PropertyKey, { source: RuntimeMethod, bound: RuntimeMethod }>()\n\n const publicInstance = new Proxy(target, {\n get(instance, key) {\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(instance, key)\n if (ownDescriptor) {\n return Reflect.get(instance, key, instance)\n }\n const runtimeDescriptor = Reflect.getOwnPropertyDescriptor(runtimePrototype, key)\n if (runtimeDescriptor) {\n const value = Reflect.get(instance, key, instance)\n if (typeof value !== 'function') {\n return value\n }\n const cached = runtimeMethods.get(key)\n if (cached && cached.source === value) {\n return cached.bound\n }\n const bound = value.bind(instance)\n runtimeMethods.set(key, { source: value, bound })\n return bound\n }\n const componentMethod = resolveComponentMethod?.(key)\n if (typeof componentMethod === 'function') {\n return componentMethod\n }\n return typeof key === 'symbol' ? Reflect.get(instance, key, instance) : undefined\n },\n set(instance, key, value) {\n if (Reflect.getOwnPropertyDescriptor(instance, key) || typeof key === 'symbol') {\n return Reflect.set(instance, key, value, instance)\n }\n Reflect.defineProperty(instance, key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value,\n })\n return true\n },\n has(instance, key) {\n return Reflect.getOwnPropertyDescriptor(instance, key) !== undefined\n || Reflect.getOwnPropertyDescriptor(runtimePrototype, key) !== undefined\n || typeof resolveComponentMethod?.(key) === 'function'\n || (typeof key === 'symbol' && Reflect.has(instance, key))\n },\n })\n componentPublicInstanceTargets.set(publicInstance, target)\n return publicInstance\n}\n"],"mappings":";AAEA,MAAM,iDAAiC,IAAI,QAAyC;AAEpF,SAAgB,qCAAqC,OAAgB;CACnE,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B;CAEF,OAAO,+BAA+B,IAAI,KAAK;AACjD;AAEA,SAAgB,8BACd,QACA,kBACA,wBACyB;CAEzB,MAAM,iCAAiB,IAAI,IAAkE;CAE7F,MAAM,iBAAiB,IAAI,MAAM,QAAQ;EACvC,IAAI,UAAU,KAAK;GAEjB,IADsB,QAAQ,yBAAyB,UAAU,GACjD,GACd,OAAO,QAAQ,IAAI,UAAU,KAAK,QAAQ;GAG5C,IAD0B,QAAQ,yBAAyB,kBAAkB,GACzD,GAAG;IACrB,MAAM,QAAQ,QAAQ,IAAI,UAAU,KAAK,QAAQ;IACjD,IAAI,OAAO,UAAU,YACnB,OAAO;IAET,MAAM,SAAS,eAAe,IAAI,GAAG;IACrC,IAAI,UAAU,OAAO,WAAW,OAC9B,OAAO,OAAO;IAEhB,MAAM,QAAQ,MAAM,KAAK,QAAQ;IACjC,eAAe,IAAI,KAAK;KAAE,QAAQ;KAAO;IAAM,CAAC;IAChD,OAAO;GACT;GACA,MAAM,kBAAkB,yBAAyB,GAAG;GACpD,IAAI,OAAO,oBAAoB,YAC7B,OAAO;GAET,OAAO,OAAO,QAAQ,WAAW,QAAQ,IAAI,UAAU,KAAK,QAAQ,IAAI;EAC1E;EACA,IAAI,UAAU,KAAK,OAAO;GACxB,IAAI,QAAQ,yBAAyB,UAAU,GAAG,KAAK,OAAO,QAAQ,UACpE,OAAO,QAAQ,IAAI,UAAU,KAAK,OAAO,QAAQ;GAEnD,QAAQ,eAAe,UAAU,KAAK;IACpC,cAAc;IACd,YAAY;IACZ,UAAU;IACV;GACF,CAAC;GACD,OAAO;EACT;EACA,IAAI,UAAU,KAAK;GACjB,OAAO,QAAQ,yBAAyB,UAAU,GAAG,MAAM,UACtD,QAAQ,yBAAyB,kBAAkB,GAAG,MAAM,UAC5D,OAAO,yBAAyB,GAAG,MAAM,cACxC,OAAO,QAAQ,YAAY,QAAQ,IAAI,UAAU,GAAG;EAC5D;CACF,CAAC;CACD,+BAA+B,IAAI,gBAAgB,MAAM;CACzD,OAAO;AACT"}
@@ -0,0 +1,36 @@
1
+ import { slugify } from "../../shared/slugify.mjs";
2
+ import { posix } from "pathe";
3
+
4
+ //#region src/runtime/component/relations.ts
5
+ function resolveComposedParent(node) {
6
+ const assignedSlot = node.assignedSlot;
7
+ if (assignedSlot) return assignedSlot;
8
+ if (node.parentNode) return node.parentNode;
9
+ const root = node.getRootNode?.();
10
+ return root instanceof ShadowRoot ? root.host : void 0;
11
+ }
12
+ function resolveRelationTag(componentId, relationPath) {
13
+ if (!relationPath.startsWith(".")) return;
14
+ const targetId = posix.normalize(posix.join(posix.dirname(componentId), relationPath));
15
+ return slugify(targetId, "wv-component");
16
+ }
17
+ function resolveRelationNodes(instance, componentId, relationPath, type) {
18
+ if (!componentId) return [];
19
+ const tag = resolveRelationTag(componentId, relationPath);
20
+ if (!tag) return [];
21
+ if (type === "child" || type === "descendant") {
22
+ const matches = Array.from(instance.querySelectorAll(tag));
23
+ return type === "descendant" ? matches : matches.filter((node) => resolveComposedParent(node) === instance);
24
+ }
25
+ let current = resolveComposedParent(instance);
26
+ while (current) {
27
+ if (current.tagName?.toLowerCase() === tag) return [current];
28
+ if (type === "parent") return [];
29
+ current = resolveComposedParent(current);
30
+ }
31
+ return [];
32
+ }
33
+
34
+ //#endregion
35
+ export { resolveRelationNodes };
36
+ //# sourceMappingURL=relations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations.mjs","names":[],"sources":["../../../src/runtime/component/relations.ts"],"sourcesContent":["import type { ComponentPublicInstance, RelationType } from './types'\nimport { posix } from 'pathe'\nimport { slugify } from '../../shared/slugify'\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 resolveRelationTag(componentId: string, relationPath: string) {\n if (!relationPath.startsWith('.')) {\n return undefined\n }\n const targetId = posix.normalize(posix.join(posix.dirname(componentId), relationPath))\n return slugify(targetId, 'wv-component')\n}\n\nexport function resolveRelationNodes(\n instance: ComponentPublicInstance,\n componentId: string | undefined,\n relationPath: string,\n type: RelationType,\n): ComponentPublicInstance[] {\n if (!componentId) {\n return []\n }\n const tag = resolveRelationTag(componentId, relationPath)\n if (!tag) {\n return []\n }\n if (type === 'child' || type === 'descendant') {\n const matches = Array.from(instance.querySelectorAll(tag)) as ComponentPublicInstance[]\n return type === 'descendant'\n ? matches\n : matches.filter(node => resolveComposedParent(node) === instance)\n }\n\n let current = resolveComposedParent(instance)\n while (current) {\n if ((current as Element).tagName?.toLowerCase() === tag) {\n return [current as ComponentPublicInstance]\n }\n if (type === 'parent') {\n return []\n }\n current = resolveComposedParent(current)\n }\n return []\n}\n"],"mappings":";;;;AAIA,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,OAAO;AAClD;AAEA,SAAS,mBAAmB,aAAqB,cAAsB;CACrE,IAAI,CAAC,aAAa,WAAW,GAAG,GAC9B;CAEF,MAAM,WAAW,MAAM,UAAU,MAAM,KAAK,MAAM,QAAQ,WAAW,GAAG,YAAY,CAAC;CACrF,OAAO,QAAQ,UAAU,cAAc;AACzC;AAEA,SAAgB,qBACd,UACA,aACA,cACA,MAC2B;CAC3B,IAAI,CAAC,aACH,OAAO,CAAC;CAEV,MAAM,MAAM,mBAAmB,aAAa,YAAY;CACxD,IAAI,CAAC,KACH,OAAO,CAAC;CAEV,IAAI,SAAS,WAAW,SAAS,cAAc;EAC7C,MAAM,UAAU,MAAM,KAAK,SAAS,iBAAiB,GAAG,CAAC;EACzD,OAAO,SAAS,eACZ,UACA,QAAQ,QAAO,SAAQ,sBAAsB,IAAI,MAAM,QAAQ;CACrE;CAEA,IAAI,UAAU,sBAAsB,QAAQ;CAC5C,OAAO,SAAS;EACd,IAAK,QAAoB,SAAS,YAAY,MAAM,KAClD,OAAO,CAAC,OAAkC;EAE5C,IAAI,SAAS,UACX,OAAO,CAAC;EAEV,UAAU,sBAAsB,OAAO;CACzC;CACA,OAAO,CAAC;AACV"}
@@ -0,0 +1,24 @@
1
+ //#region src/runtime/component/slots.ts
2
+ function resolveSlotNames(value) {
3
+ if (Array.isArray(value)) return new Set(value.filter((name) => typeof name === "string" && name.length > 0));
4
+ if (!value || typeof value !== "object") return /* @__PURE__ */ new Set();
5
+ return new Set(Object.entries(value).filter(([, enabled]) => Boolean(enabled)).map(([name]) => name));
6
+ }
7
+ function createWebSlotsProxy(resolveValue) {
8
+ const hasSlot = (key) => typeof key === "string" && resolveSlotNames(resolveValue()).has(key);
9
+ return new Proxy(Object.create(null), {
10
+ get: (_target, key) => hasSlot(key) ? true : void 0,
11
+ has: (_target, key) => hasSlot(key),
12
+ ownKeys: () => Array.from(resolveSlotNames(resolveValue())),
13
+ getOwnPropertyDescriptor: (_target, key) => hasSlot(key) ? {
14
+ configurable: true,
15
+ enumerable: true,
16
+ value: true
17
+ } : void 0,
18
+ set: () => false
19
+ });
20
+ }
21
+
22
+ //#endregion
23
+ export { createWebSlotsProxy };
24
+ //# sourceMappingURL=slots.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slots.mjs","names":[],"sources":["../../../src/runtime/component/slots.ts"],"sourcesContent":["function resolveSlotNames(value: unknown) {\n if (Array.isArray(value)) {\n return new Set(value.filter((name): name is string => typeof name === 'string' && name.length > 0))\n }\n if (!value || typeof value !== 'object') {\n return new Set<string>()\n }\n return new Set(\n Object.entries(value)\n .filter(([, enabled]) => Boolean(enabled))\n .map(([name]) => name),\n )\n}\n\nexport function createWebSlotsProxy(resolveValue: () => unknown) {\n const hasSlot = (key: PropertyKey) => typeof key === 'string' && resolveSlotNames(resolveValue()).has(key)\n return new Proxy(Object.create(null) as Record<string, true>, {\n get: (_target, key) => hasSlot(key) ? true : undefined,\n has: (_target, key) => hasSlot(key),\n ownKeys: () => Array.from(resolveSlotNames(resolveValue())),\n getOwnPropertyDescriptor: (_target, key) => hasSlot(key)\n ? { configurable: true, enumerable: true, value: true }\n : undefined,\n set: () => false,\n })\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,OAAgB;CACxC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,IAAI,IAAI,MAAM,QAAQ,SAAyB,OAAO,SAAS,YAAY,KAAK,SAAS,CAAC,CAAC;CAEpG,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,uBAAO,IAAI,IAAY;CAEzB,OAAO,IAAI,IACT,OAAO,QAAQ,KAAK,CAAC,CAClB,QAAQ,GAAG,aAAa,QAAQ,OAAO,CAAC,CAAC,CACzC,KAAK,CAAC,UAAU,IAAI,CACzB;AACF;AAEA,SAAgB,oBAAoB,cAA6B;CAC/D,MAAM,WAAW,QAAqB,OAAO,QAAQ,YAAY,iBAAiB,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG;CACzG,OAAO,IAAI,MAAM,OAAO,OAAO,IAAI,GAA2B;EAC5D,MAAM,SAAS,QAAQ,QAAQ,GAAG,IAAI,OAAO;EAC7C,MAAM,SAAS,QAAQ,QAAQ,GAAG;EAClC,eAAe,MAAM,KAAK,iBAAiB,aAAa,CAAC,CAAC;EAC1D,2BAA2B,SAAS,QAAQ,QAAQ,GAAG,IACnD;GAAE,cAAc;GAAM,YAAY;GAAM,OAAO;EAAK,IACpD;EACJ,WAAW;CACb,CAAC;AACH"}
@@ -3,22 +3,30 @@ import { cloneValue, hyphenate } from "./utils.mjs";
3
3
  import { normalizeBehaviors } from "./behavior.mjs";
4
4
 
5
5
  //#region src/runtime/component/state.ts
6
+ function normalizePropertyDeclaration(declaration) {
7
+ if (declaration === null || typeof declaration === "function") return { type: declaration };
8
+ return declaration;
9
+ }
6
10
  function resolveNormalizedComponent(component) {
7
11
  const normalized = normalizeBehaviors(component);
12
+ const resolved = normalized.component;
8
13
  return {
9
14
  warnings: normalized.warnings,
10
- component: normalized.component ?? component ?? {}
15
+ component: {
16
+ ...resolved,
17
+ properties: Object.fromEntries(Object.entries(resolved.properties ?? {}).map(([name, declaration]) => [name, normalizePropertyDeclaration(declaration)]))
18
+ }
11
19
  };
12
20
  }
13
21
  function createDefaultPropertyValues(propertyEntries) {
14
22
  return propertyEntries.reduce((acc, [name, prop]) => {
15
- if (hasOwn(prop, "value")) acc[name] = cloneValue(prop.value);
23
+ if (prop !== null && typeof prop === "object" && hasOwn(prop, "value")) acc[name] = cloneValue(prop.value);
16
24
  else acc[name] = void 0;
17
25
  return acc;
18
26
  }, {});
19
27
  }
20
28
  function createPropertyEntries(component) {
21
- return Object.entries(component.properties ?? {});
29
+ return Object.entries(component.properties);
22
30
  }
23
31
  function createObservedAttributes(propertyEntries) {
24
32
  return propertyEntries.map(([name]) => hyphenate(name));
@@ -28,6 +36,7 @@ function createComponentRuntimeState(options) {
28
36
  const propertyEntries = createPropertyEntries(component);
29
37
  return {
30
38
  state: {
39
+ id: options.id,
31
40
  templateRef: options.template,
32
41
  styleRef: options.style ?? "",
33
42
  componentRef: component,
@@ -45,6 +54,7 @@ function updateComponentRuntimeState(state, options) {
45
54
  const { component, warnings } = resolveNormalizedComponent(options.component ?? {});
46
55
  const propertyEntries = createPropertyEntries(component);
47
56
  state.templateRef = options.template;
57
+ state.id = options.id;
48
58
  state.styleRef = options.style ?? "";
49
59
  state.componentRef = component;
50
60
  state.observerInitEnabled = Boolean(options.observerInit);
@@ -1 +1 @@
1
- {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/runtime/component/state.ts"],"sourcesContent":["import type {\n ComponentOptions,\n DataRecord,\n DefineComponentOptions,\n LifeTimeHooks,\n PageLifeTimeHooks,\n PropertyOption,\n} from './types'\nimport { hasOwn } from '../utils/object'\nimport { normalizeBehaviors } from './behavior'\nimport { cloneValue, hyphenate } from './utils'\n\ntype PropertyEntry = [string, PropertyOption]\n\nexport interface ComponentRuntimeState {\n templateRef: DefineComponentOptions['template']\n styleRef: string\n componentRef: ComponentOptions\n observerInitEnabled: boolean\n propertyEntries: PropertyEntry[]\n observedAttributes: string[]\n defaultPropertyValues: DataRecord\n lifetimes: LifeTimeHooks\n pageLifetimes: PageLifeTimeHooks\n}\n\nfunction resolveNormalizedComponent(component: ComponentOptions | undefined) {\n const normalized = normalizeBehaviors(component)\n return {\n warnings: normalized.warnings,\n component: normalized.component ?? component ?? {},\n }\n}\n\nfunction createDefaultPropertyValues(propertyEntries: PropertyEntry[]) {\n return propertyEntries.reduce<DataRecord>((acc, [name, prop]) => {\n if (hasOwn(prop, 'value')) {\n acc[name] = cloneValue(prop.value)\n }\n else {\n acc[name] = undefined\n }\n return acc\n }, {})\n}\n\nfunction createPropertyEntries(component: ComponentOptions): PropertyEntry[] {\n return Object.entries(component.properties ?? {})\n}\n\nfunction createObservedAttributes(propertyEntries: PropertyEntry[]) {\n return propertyEntries.map(([name]) => hyphenate(name))\n}\n\nexport function createComponentRuntimeState(options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n const state: ComponentRuntimeState = {\n templateRef: options.template,\n styleRef: options.style ?? '',\n componentRef: component,\n observerInitEnabled: Boolean(options.observerInit),\n propertyEntries,\n observedAttributes: createObservedAttributes(propertyEntries),\n defaultPropertyValues: createDefaultPropertyValues(propertyEntries),\n lifetimes: component.lifetimes ?? {},\n pageLifetimes: component.pageLifetimes ?? {},\n }\n return {\n state,\n warnings,\n }\n}\n\nexport function updateComponentRuntimeState(state: ComponentRuntimeState, options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n state.templateRef = options.template\n state.styleRef = options.style ?? ''\n state.componentRef = component\n state.observerInitEnabled = Boolean(options.observerInit)\n state.lifetimes = component.lifetimes ?? {}\n state.pageLifetimes = component.pageLifetimes ?? {}\n state.propertyEntries = propertyEntries\n state.observedAttributes = createObservedAttributes(propertyEntries)\n state.defaultPropertyValues = createDefaultPropertyValues(propertyEntries)\n return {\n warnings,\n nextMethods: component.methods ?? {},\n }\n}\n"],"mappings":";;;;;AA0BA,SAAS,2BAA2B,WAAyC;CAC3E,MAAM,aAAa,mBAAmB,SAAS;CAC/C,OAAO;EACL,UAAU,WAAW;EACrB,WAAW,WAAW,aAAa,aAAa,CAAC;CACnD;AACF;AAEA,SAAS,4BAA4B,iBAAkC;CACrE,OAAO,gBAAgB,QAAoB,KAAK,CAAC,MAAM,UAAU;EAC/D,IAAI,OAAO,MAAM,OAAO,GACtB,IAAI,QAAQ,WAAW,KAAK,KAAK;OAGjC,IAAI,QAAQ;EAEd,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,sBAAsB,WAA8C;CAC3E,OAAO,OAAO,QAAQ,UAAU,cAAc,CAAC,CAAC;AAClD;AAEA,SAAS,yBAAyB,iBAAkC;CAClE,OAAO,gBAAgB,KAAK,CAAC,UAAU,UAAU,IAAI,CAAC;AACxD;AAEA,SAAgB,4BAA4B,SAAiC;CAC3E,MAAM,EAAE,WAAW,aAAa,2BAA2B,QAAQ,aAAa,CAAC,CAAC;CAClF,MAAM,kBAAkB,sBAAsB,SAAS;CAYvD,OAAO;EACL;GAXA,aAAa,QAAQ;GACrB,UAAU,QAAQ,SAAS;GAC3B,cAAc;GACd,qBAAqB,QAAQ,QAAQ,YAAY;GACjD;GACA,oBAAoB,yBAAyB,eAAe;GAC5D,uBAAuB,4BAA4B,eAAe;GAClE,WAAW,UAAU,aAAa,CAAC;GACnC,eAAe,UAAU,iBAAiB,CAAC;EAGvC;EACJ;CACF;AACF;AAEA,SAAgB,4BAA4B,OAA8B,SAAiC;CACzG,MAAM,EAAE,WAAW,aAAa,2BAA2B,QAAQ,aAAa,CAAC,CAAC;CAClF,MAAM,kBAAkB,sBAAsB,SAAS;CACvD,MAAM,cAAc,QAAQ;CAC5B,MAAM,WAAW,QAAQ,SAAS;CAClC,MAAM,eAAe;CACrB,MAAM,sBAAsB,QAAQ,QAAQ,YAAY;CACxD,MAAM,YAAY,UAAU,aAAa,CAAC;CAC1C,MAAM,gBAAgB,UAAU,iBAAiB,CAAC;CAClD,MAAM,kBAAkB;CACxB,MAAM,qBAAqB,yBAAyB,eAAe;CACnE,MAAM,wBAAwB,4BAA4B,eAAe;CACzE,OAAO;EACL;EACA,aAAa,UAAU,WAAW,CAAC;CACrC;AACF"}
1
+ {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/runtime/component/state.ts"],"sourcesContent":["import type {\n ComponentOptions,\n DataRecord,\n DefineComponentOptions,\n LifeTimeHooks,\n NormalizedComponentOptions,\n PageLifeTimeHooks,\n PropertyDeclaration,\n PropertyOption,\n} from './types'\nimport { hasOwn } from '../utils/object'\nimport { normalizeBehaviors } from './behavior'\nimport { cloneValue, hyphenate } from './utils'\n\ntype PropertyEntry = [string, PropertyOption]\n\nexport interface ComponentRuntimeState {\n id?: string\n templateRef: DefineComponentOptions['template']\n styleRef: string\n componentRef: NormalizedComponentOptions\n observerInitEnabled: boolean\n propertyEntries: PropertyEntry[]\n observedAttributes: string[]\n defaultPropertyValues: DataRecord\n lifetimes: LifeTimeHooks\n pageLifetimes: PageLifeTimeHooks\n}\n\nfunction normalizePropertyDeclaration(declaration: PropertyDeclaration): PropertyOption {\n if (declaration === null || typeof declaration === 'function') {\n return { type: declaration }\n }\n return declaration\n}\n\nfunction resolveNormalizedComponent(component: ComponentOptions) {\n const normalized = normalizeBehaviors(component)\n const resolved = normalized.component!\n return {\n warnings: normalized.warnings,\n component: {\n ...resolved,\n properties: Object.fromEntries(\n Object.entries(resolved.properties ?? {}).map(([name, declaration]) => [\n name,\n normalizePropertyDeclaration(declaration),\n ]),\n ),\n } satisfies NormalizedComponentOptions,\n }\n}\n\nfunction createDefaultPropertyValues(propertyEntries: PropertyEntry[]) {\n return propertyEntries.reduce<DataRecord>((acc, [name, prop]) => {\n if (prop !== null && typeof prop === 'object' && hasOwn(prop, 'value')) {\n acc[name] = cloneValue(prop.value)\n }\n else {\n acc[name] = undefined\n }\n return acc\n }, {})\n}\n\nfunction createPropertyEntries(component: NormalizedComponentOptions): PropertyEntry[] {\n return Object.entries(component.properties)\n}\n\nfunction createObservedAttributes(propertyEntries: PropertyEntry[]) {\n return propertyEntries.map(([name]) => hyphenate(name))\n}\n\nexport function createComponentRuntimeState(options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n const state: ComponentRuntimeState = {\n id: options.id,\n templateRef: options.template,\n styleRef: options.style ?? '',\n componentRef: component,\n observerInitEnabled: Boolean(options.observerInit),\n propertyEntries,\n observedAttributes: createObservedAttributes(propertyEntries),\n defaultPropertyValues: createDefaultPropertyValues(propertyEntries),\n lifetimes: component.lifetimes ?? {},\n pageLifetimes: component.pageLifetimes ?? {},\n }\n return {\n state,\n warnings,\n }\n}\n\nexport function updateComponentRuntimeState(state: ComponentRuntimeState, options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n state.templateRef = options.template\n state.id = options.id\n state.styleRef = options.style ?? ''\n state.componentRef = component\n state.observerInitEnabled = Boolean(options.observerInit)\n state.lifetimes = component.lifetimes ?? {}\n state.pageLifetimes = component.pageLifetimes ?? {}\n state.propertyEntries = propertyEntries\n state.observedAttributes = createObservedAttributes(propertyEntries)\n state.defaultPropertyValues = createDefaultPropertyValues(propertyEntries)\n return {\n warnings,\n nextMethods: component.methods ?? {},\n }\n}\n"],"mappings":";;;;;AA6BA,SAAS,6BAA6B,aAAkD;CACtF,IAAI,gBAAgB,QAAQ,OAAO,gBAAgB,YACjD,OAAO,EAAE,MAAM,YAAY;CAE7B,OAAO;AACT;AAEA,SAAS,2BAA2B,WAA6B;CAC/D,MAAM,aAAa,mBAAmB,SAAS;CAC/C,MAAM,WAAW,WAAW;CAC5B,OAAO;EACL,UAAU,WAAW;EACrB,WAAW;GACT,GAAG;GACH,YAAY,OAAO,YACjB,OAAO,QAAQ,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,iBAAiB,CACrE,MACA,6BAA6B,WAAW,CAC1C,CAAC,CACH;EACF;CACF;AACF;AAEA,SAAS,4BAA4B,iBAAkC;CACrE,OAAO,gBAAgB,QAAoB,KAAK,CAAC,MAAM,UAAU;EAC/D,IAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,GACnE,IAAI,QAAQ,WAAW,KAAK,KAAK;OAGjC,IAAI,QAAQ;EAEd,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,sBAAsB,WAAwD;CACrF,OAAO,OAAO,QAAQ,UAAU,UAAU;AAC5C;AAEA,SAAS,yBAAyB,iBAAkC;CAClE,OAAO,gBAAgB,KAAK,CAAC,UAAU,UAAU,IAAI,CAAC;AACxD;AAEA,SAAgB,4BAA4B,SAAiC;CAC3E,MAAM,EAAE,WAAW,aAAa,2BAA2B,QAAQ,aAAa,CAAC,CAAC;CAClF,MAAM,kBAAkB,sBAAsB,SAAS;CAavD,OAAO;EACL;GAZA,IAAI,QAAQ;GACZ,aAAa,QAAQ;GACrB,UAAU,QAAQ,SAAS;GAC3B,cAAc;GACd,qBAAqB,QAAQ,QAAQ,YAAY;GACjD;GACA,oBAAoB,yBAAyB,eAAe;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