@weapp-vite/web 2.0.1 → 2.1.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 (303) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +1 -2
  2. package/dist/compiler/wxml/attributes.mjs +12 -4
  3. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  4. package/dist/compiler/wxml/compile.mjs +26 -8
  5. package/dist/compiler/wxml/compile.mjs.map +1 -1
  6. package/dist/compiler/wxml/dependency.mjs +1 -2
  7. package/dist/compiler/wxml/interpolation.mjs +13 -3
  8. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  9. package/dist/compiler/wxml/nativeTags.mjs +60 -0
  10. package/dist/compiler/wxml/nativeTags.mjs.map +1 -0
  11. package/dist/compiler/wxml/navigation.mjs +1 -2
  12. package/dist/compiler/wxml/parser.mjs +1 -2
  13. package/dist/compiler/wxml/prepare.mjs +1 -2
  14. package/dist/compiler/wxml/renderer.mjs +1 -2
  15. package/dist/compiler/wxml/specialNodes.mjs +1 -2
  16. package/dist/compiler/wxml/types.d.mts +0 -2
  17. package/dist/compiler/wxml/unknownTags.mjs +33 -0
  18. package/dist/compiler/wxml/unknownTags.mjs.map +1 -0
  19. package/dist/compiler/wxs.mjs +1 -2
  20. package/dist/css/wxss.d.mts +2 -19
  21. package/dist/css/wxss.mjs +5 -12
  22. package/dist/css/wxss.mjs.map +1 -1
  23. package/dist/index.d.mts +8 -3
  24. package/dist/index.mjs +8 -5
  25. package/dist/plugin/assets.d.mts +0 -2
  26. package/dist/plugin/assets.mjs +1 -2
  27. package/dist/plugin/constants.mjs +1 -2
  28. package/dist/plugin/dependencyScan.mjs +1 -2
  29. package/dist/plugin/entry.mjs +6 -4
  30. package/dist/plugin/entry.mjs.map +1 -1
  31. package/dist/plugin/files.mjs +1 -2
  32. package/dist/plugin/hostTypes.d.mts +0 -2
  33. package/dist/plugin/index.d.mts +0 -2
  34. package/dist/plugin/index.mjs +5 -5
  35. package/dist/plugin/index.mjs.map +1 -1
  36. package/dist/plugin/layout.mjs +1 -2
  37. package/dist/plugin/navigation.mjs +1 -2
  38. package/dist/plugin/packageResolution.mjs +1 -2
  39. package/dist/plugin/path.mjs +1 -2
  40. package/dist/plugin/register.mjs +1 -2
  41. package/dist/plugin/scan.mjs +1 -2
  42. package/dist/plugin/scanConfig.mjs +1 -2
  43. package/dist/plugin/scanSfc.mjs +1 -2
  44. package/dist/plugin/sfcHmr.mjs +1 -2
  45. package/dist/plugin/state.mjs +1 -2
  46. package/dist/plugin/styleModule.mjs +1 -2
  47. package/dist/plugin/types.d.mts +2 -3
  48. package/dist/plugin/vueSfc.mjs +1 -2
  49. package/dist/runtime/appShell/container.mjs +1 -2
  50. package/dist/runtime/appShell/tabBar/index.mjs +1 -2
  51. package/dist/runtime/appShell/tabBar/style.mjs +1 -2
  52. package/dist/runtime/appStyle.mjs +1 -2
  53. package/dist/runtime/button/helpers.mjs +1 -2
  54. package/dist/runtime/button/index.d.mts +0 -2
  55. package/dist/runtime/button/index.mjs +1 -2
  56. package/dist/runtime/button/style.mjs +1 -2
  57. package/dist/runtime/component/behavior.mjs +1 -2
  58. package/dist/runtime/component/constants.mjs +1 -2
  59. package/dist/runtime/component/dom.mjs +1 -2
  60. package/dist/runtime/component/element.mjs +9 -2
  61. package/dist/runtime/component/element.mjs.map +1 -1
  62. package/dist/runtime/component/events.mjs +4 -4
  63. package/dist/runtime/component/events.mjs.map +1 -1
  64. package/dist/runtime/component/index.d.mts +0 -2
  65. package/dist/runtime/component/index.mjs +1 -2
  66. package/dist/runtime/component/observers.mjs +1 -2
  67. package/dist/runtime/component/publicInstance.mjs +1 -2
  68. package/dist/runtime/component/relations.mjs +1 -2
  69. package/dist/runtime/component/slots.mjs +1 -2
  70. package/dist/runtime/component/state.mjs +1 -2
  71. package/dist/runtime/component/types.d.mts +0 -2
  72. package/dist/runtime/component/utils.mjs +1 -2
  73. package/dist/runtime/component/virtualHost.mjs +1 -2
  74. package/dist/runtime/componentEvents.mjs +1 -2
  75. package/dist/runtime/dataset.mjs +49 -0
  76. package/dist/runtime/dataset.mjs.map +1 -0
  77. package/dist/runtime/datasetBinding.d.mts +13 -0
  78. package/dist/runtime/datasetBinding.mjs +40 -0
  79. package/dist/runtime/datasetBinding.mjs.map +1 -0
  80. package/dist/runtime/eventBinding.d.mts +0 -2
  81. package/dist/runtime/eventBinding.mjs +1 -2
  82. package/dist/runtime/execution.d.mts +0 -2
  83. package/dist/runtime/execution.mjs +1 -2
  84. package/dist/runtime/host/index.d.mts +0 -2
  85. package/dist/runtime/host/index.mjs +1 -2
  86. package/dist/runtime/host/types.d.mts +0 -2
  87. package/dist/runtime/hostGlobals.d.mts +0 -2
  88. package/dist/runtime/hostGlobals.mjs +1 -2
  89. package/dist/runtime/index.d.mts +8 -3
  90. package/dist/runtime/index.mjs +9 -7
  91. package/dist/runtime/index.mjs.map +1 -1
  92. package/dist/runtime/inlineStyle.d.mts +5 -0
  93. package/dist/runtime/inlineStyle.mjs +21 -0
  94. package/dist/runtime/inlineStyle.mjs.map +1 -0
  95. package/dist/runtime/inputHandlerResult.mjs +1 -2
  96. package/dist/runtime/legacyTemplate/dataset.mjs +53 -0
  97. package/dist/runtime/legacyTemplate/dataset.mjs.map +1 -0
  98. package/dist/runtime/legacyTemplate/dom.mjs +20 -5
  99. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  100. package/dist/runtime/legacyTemplate/expression.mjs +1 -2
  101. package/dist/runtime/legacyTemplate/index.d.mts +0 -2
  102. package/dist/runtime/legacyTemplate/index.mjs +23 -16
  103. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  104. package/dist/runtime/legacyTemplate/types.d.mts +0 -2
  105. package/dist/runtime/nativeComponents/canvas/index.mjs +1 -2
  106. package/dist/runtime/nativeComponents/checkbox.mjs +1 -2
  107. package/dist/runtime/nativeComponents/cover/index.mjs +1 -2
  108. package/dist/runtime/nativeComponents/form.d.mts +0 -2
  109. package/dist/runtime/nativeComponents/form.mjs +1 -2
  110. package/dist/runtime/nativeComponents/formControl.mjs +1 -2
  111. package/dist/runtime/nativeComponents/helpers.mjs +1 -2
  112. package/dist/runtime/nativeComponents/icon/helpers.mjs +1 -2
  113. package/dist/runtime/nativeComponents/icon/index.mjs +1 -2
  114. package/dist/runtime/nativeComponents/icon/style.mjs +1 -2
  115. package/dist/runtime/nativeComponents/image.d.mts +0 -2
  116. package/dist/runtime/nativeComponents/image.mjs +1 -2
  117. package/dist/runtime/nativeComponents/index.d.mts +1 -3
  118. package/dist/runtime/nativeComponents/index.mjs +3 -3
  119. package/dist/runtime/nativeComponents/index.mjs.map +1 -1
  120. package/dist/runtime/nativeComponents/input.d.mts +0 -2
  121. package/dist/runtime/nativeComponents/input.mjs +1 -2
  122. package/dist/runtime/nativeComponents/label.mjs +1 -2
  123. package/dist/runtime/nativeComponents/mediaRegistry.mjs +1 -2
  124. package/dist/runtime/nativeComponents/movable/helpers.mjs +1 -2
  125. package/dist/runtime/nativeComponents/movable/index.mjs +1 -2
  126. package/dist/runtime/nativeComponents/navigator.mjs +1 -2
  127. package/dist/runtime/nativeComponents/picker/editors.mjs +1 -2
  128. package/dist/runtime/nativeComponents/picker/helpers.mjs +1 -2
  129. package/dist/runtime/nativeComponents/picker/index.mjs +1 -2
  130. package/dist/runtime/nativeComponents/picker/style.mjs +1 -2
  131. package/dist/runtime/nativeComponents/pickerView/column.mjs +1 -2
  132. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +1 -2
  133. package/dist/runtime/nativeComponents/pickerView/index.mjs +1 -2
  134. package/dist/runtime/nativeComponents/pickerView/style.mjs +1 -2
  135. package/dist/runtime/nativeComponents/primitives.mjs +1 -2
  136. package/dist/runtime/nativeComponents/progress/helpers.mjs +1 -2
  137. package/dist/runtime/nativeComponents/progress/index.mjs +1 -2
  138. package/dist/runtime/nativeComponents/progress/style.mjs +1 -2
  139. package/dist/runtime/nativeComponents/radio.mjs +1 -2
  140. package/dist/runtime/nativeComponents/richText/index.mjs +1 -2
  141. package/dist/runtime/nativeComponents/scrollView/boundaries.mjs +62 -0
  142. package/dist/runtime/nativeComponents/scrollView/boundaries.mjs.map +1 -0
  143. package/dist/runtime/nativeComponents/{scrollView.d.mts → scrollView/helpers.d.mts} +4 -5
  144. package/dist/runtime/nativeComponents/scrollView/helpers.mjs +14 -0
  145. package/dist/runtime/nativeComponents/scrollView/helpers.mjs.map +1 -0
  146. package/dist/runtime/nativeComponents/scrollView/index.mjs +193 -0
  147. package/dist/runtime/nativeComponents/scrollView/index.mjs.map +1 -0
  148. package/dist/runtime/nativeComponents/scrollView/position.mjs +43 -0
  149. package/dist/runtime/nativeComponents/scrollView/position.mjs.map +1 -0
  150. package/dist/runtime/nativeComponents/slider/helpers.mjs +1 -2
  151. package/dist/runtime/nativeComponents/slider/index.mjs +1 -2
  152. package/dist/runtime/nativeComponents/slider/style.mjs +1 -2
  153. package/dist/runtime/nativeComponents/style.mjs +1 -2
  154. package/dist/runtime/nativeComponents/swiper/helpers.mjs +1 -2
  155. package/dist/runtime/nativeComponents/swiper/index.mjs +1 -2
  156. package/dist/runtime/nativeComponents/swiper/item.mjs +1 -2
  157. package/dist/runtime/nativeComponents/swiper/style.mjs +1 -2
  158. package/dist/runtime/nativeComponents/switch.d.mts +0 -2
  159. package/dist/runtime/nativeComponents/switch.mjs +1 -2
  160. package/dist/runtime/nativeComponents/textarea.d.mts +0 -2
  161. package/dist/runtime/nativeComponents/textarea.mjs +1 -2
  162. package/dist/runtime/nativeComponents/video/helpers.d.mts +0 -2
  163. package/dist/runtime/nativeComponents/video/helpers.mjs +1 -2
  164. package/dist/runtime/nativeComponents/video/index.mjs +1 -2
  165. package/dist/runtime/nativeComponents/video/style.mjs +1 -2
  166. package/dist/runtime/navigationBar/index.d.mts +0 -2
  167. package/dist/runtime/navigationBar/index.mjs +1 -2
  168. package/dist/runtime/navigationBar/style.mjs +1 -2
  169. package/dist/runtime/pageLayout.d.mts +0 -2
  170. package/dist/runtime/pageLayout.mjs +1 -2
  171. package/dist/runtime/polyfill/ad.mjs +1 -2
  172. package/dist/runtime/polyfill/animation.mjs +1 -2
  173. package/dist/runtime/polyfill/appState.mjs +1 -2
  174. package/dist/runtime/polyfill/async.d.mts +0 -2
  175. package/dist/runtime/polyfill/async.mjs +1 -2
  176. package/dist/runtime/polyfill/auth.mjs +1 -2
  177. package/dist/runtime/polyfill/authApi.mjs +1 -2
  178. package/dist/runtime/polyfill/background.mjs +1 -2
  179. package/dist/runtime/polyfill/canvasContext.mjs +1 -2
  180. package/dist/runtime/polyfill/capability.mjs +1 -2
  181. package/dist/runtime/polyfill/cloud.mjs +1 -2
  182. package/dist/runtime/polyfill/device.mjs +1 -2
  183. package/dist/runtime/polyfill/deviceApi.mjs +1 -2
  184. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +0 -2
  185. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +1 -2
  186. package/dist/runtime/polyfill/eventBus.mjs +1 -2
  187. package/dist/runtime/polyfill/filePicker.mjs +1 -2
  188. package/dist/runtime/polyfill/fileSystemManager.mjs +1 -2
  189. package/dist/runtime/polyfill/files.mjs +1 -2
  190. package/dist/runtime/polyfill/font.mjs +1 -2
  191. package/dist/runtime/polyfill/index.d.mts +4 -4
  192. package/dist/runtime/polyfill/index.mjs +11 -4
  193. package/dist/runtime/polyfill/index.mjs.map +1 -1
  194. package/dist/runtime/polyfill/interaction.mjs +1 -2
  195. package/dist/runtime/polyfill/interactionApi.mjs +1 -2
  196. package/dist/runtime/polyfill/intersectionObserver.mjs +4 -4
  197. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -1
  198. package/dist/runtime/polyfill/lifecycleEvents.d.mts +12 -0
  199. package/dist/runtime/polyfill/lifecycleEvents.mjs +67 -0
  200. package/dist/runtime/polyfill/lifecycleEvents.mjs.map +1 -0
  201. package/dist/runtime/polyfill/locale.mjs +1 -2
  202. package/dist/runtime/polyfill/location.mjs +1 -2
  203. package/dist/runtime/polyfill/locationApi.mjs +1 -2
  204. package/dist/runtime/polyfill/mediaActions.mjs +1 -2
  205. package/dist/runtime/polyfill/mediaApi/file.mjs +1 -2
  206. package/dist/runtime/polyfill/mediaApi/info.mjs +1 -2
  207. package/dist/runtime/polyfill/mediaApi/picker.mjs +1 -2
  208. package/dist/runtime/polyfill/mediaApi/preview.mjs +1 -2
  209. package/dist/runtime/polyfill/mediaApi/process.mjs +1 -2
  210. package/dist/runtime/polyfill/mediaInfo.mjs +1 -2
  211. package/dist/runtime/polyfill/mediaPicker.mjs +1 -2
  212. package/dist/runtime/polyfill/mediaProcess.mjs +1 -2
  213. package/dist/runtime/polyfill/menuApi.mjs +5 -3
  214. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  215. package/dist/runtime/polyfill/navigationBarRuntime.mjs +1 -2
  216. package/dist/runtime/polyfill/network/request.mjs +1 -2
  217. package/dist/runtime/polyfill/network/requestBridge.mjs +1 -2
  218. package/dist/runtime/polyfill/network/status.mjs +1 -2
  219. package/dist/runtime/polyfill/platformApi.mjs +1 -2
  220. package/dist/runtime/polyfill/platformRuntime.mjs +1 -2
  221. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +1 -2
  222. package/dist/runtime/polyfill/routeRuntime/dom.mjs +1 -2
  223. package/dist/runtime/polyfill/routeRuntime/events.d.mts +0 -2
  224. package/dist/runtime/polyfill/routeRuntime/events.mjs +1 -2
  225. package/dist/runtime/polyfill/routeRuntime/history.d.mts +0 -2
  226. package/dist/runtime/polyfill/routeRuntime/history.mjs +1 -2
  227. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +1 -2
  228. package/dist/runtime/polyfill/routeRuntime/options.d.mts +0 -2
  229. package/dist/runtime/polyfill/routeRuntime/options.mjs +1 -2
  230. package/dist/runtime/polyfill/routeRuntime/result.mjs +1 -2
  231. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +37 -6
  232. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -1
  233. package/dist/runtime/polyfill/routeRuntime/stack.mjs +1 -2
  234. package/dist/runtime/polyfill/routeRuntime/url.mjs +1 -2
  235. package/dist/runtime/polyfill/routeRuntime.d.mts +2 -2
  236. package/dist/runtime/polyfill/routeRuntime.mjs +14 -5
  237. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  238. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +1 -2
  239. package/dist/runtime/polyfill/runtimeDataApi.d.mts +0 -2
  240. package/dist/runtime/polyfill/runtimeDataApi.mjs +1 -2
  241. package/dist/runtime/polyfill/runtimeInfra.mjs +1 -2
  242. package/dist/runtime/polyfill/runtimeOps.mjs +1 -2
  243. package/dist/runtime/polyfill/selectorQuery.mjs +3 -3
  244. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  245. package/dist/runtime/polyfill/storage.mjs +1 -2
  246. package/dist/runtime/polyfill/storageAsync.mjs +1 -2
  247. package/dist/runtime/polyfill/subscribe.mjs +1 -2
  248. package/dist/runtime/polyfill/system.mjs +1 -2
  249. package/dist/runtime/polyfill/systemApi.mjs +1 -2
  250. package/dist/runtime/polyfill/types/base.d.mts +0 -2
  251. package/dist/runtime/polyfill/types/common.d.mts +0 -2
  252. package/dist/runtime/polyfill/types/lifecycle.d.mts +12 -0
  253. package/dist/runtime/polyfill/types/locationRuntime.d.mts +0 -2
  254. package/dist/runtime/polyfill/types/mediaAuth.d.mts +0 -2
  255. package/dist/runtime/polyfill/types/platformRuntime.d.mts +0 -2
  256. package/dist/runtime/polyfill/types/systemAuth.d.mts +0 -2
  257. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +0 -2
  258. package/dist/runtime/polyfill/ui.mjs +1 -2
  259. package/dist/runtime/polyfill/uiFeedback.mjs +19 -5
  260. package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -1
  261. package/dist/runtime/polyfill/uiMediaApi.d.mts +8 -2
  262. package/dist/runtime/polyfill/uiMediaApi.mjs +20 -5
  263. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  264. package/dist/runtime/polyfill/videoContext.mjs +1 -2
  265. package/dist/runtime/polyfill/vkSession.mjs +1 -2
  266. package/dist/runtime/polyfill/windowResize.mjs +1 -2
  267. package/dist/runtime/polyfill/worker.mjs +1 -2
  268. package/dist/runtime/polyfill.d.mts +4 -2
  269. package/dist/runtime/renderContext.d.mts +0 -2
  270. package/dist/runtime/renderContext.mjs +5 -4
  271. package/dist/runtime/renderContext.mjs.map +1 -1
  272. package/dist/runtime/rpx.d.mts +0 -2
  273. package/dist/runtime/rpx.mjs +6 -6
  274. package/dist/runtime/rpx.mjs.map +1 -1
  275. package/dist/runtime/seo/index.d.mts +0 -2
  276. package/dist/runtime/seo/index.mjs +1 -2
  277. package/dist/runtime/style.d.mts +0 -2
  278. package/dist/runtime/style.mjs +1 -2
  279. package/dist/runtime/template.d.mts +0 -2
  280. package/dist/runtime/utils/object.mjs +1 -2
  281. package/dist/runtime/viewport/index.d.mts +0 -2
  282. package/dist/runtime/viewport/index.mjs +1 -2
  283. package/dist/runtime/viewport/style.mjs +2 -2
  284. package/dist/runtime/viewport/style.mjs.map +1 -1
  285. package/dist/runtime/viewport/types.d.mts +0 -2
  286. package/dist/runtime/warning.d.mts +0 -2
  287. package/dist/runtime/warning.mjs +1 -2
  288. package/dist/runtime/wevu.d.mts +0 -2
  289. package/dist/runtime/wevu.mjs +1 -2
  290. package/dist/shared/nativeComponents.mjs +10 -3
  291. package/dist/shared/nativeComponents.mjs.map +1 -1
  292. package/dist/shared/slugify.mjs +1 -2
  293. package/dist/shared/styleUnits/options.d.mts +24 -0
  294. package/dist/shared/styleUnits/options.mjs +13 -0
  295. package/dist/shared/styleUnits/options.mjs.map +1 -0
  296. package/dist/shared/styleUnits/value.mjs +63 -0
  297. package/dist/shared/styleUnits/value.mjs.map +1 -0
  298. package/dist/shared/tabBar.d.mts +0 -2
  299. package/dist/shared/tabBar.mjs +1 -2
  300. package/dist/shared/wxml.mjs +1 -2
  301. package/package.json +15 -13
  302. package/dist/runtime/nativeComponents/scrollView.mjs +0 -88
  303. package/dist/runtime/nativeComponents/scrollView.mjs.map +0 -1
@@ -2,7 +2,7 @@ import { resolveScriptFile } from "./files.mjs";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { dirname, resolve } from "pathe";
4
4
 
5
- //#region src/plugin/packageResolution.ts
5
+ // src/plugin/packageResolution.ts
6
6
  function parsePackageSubpath(id, packageRootRelative = false) {
7
7
  const segments = id.split("/");
8
8
  const packageSegmentCount = id.startsWith("@") ? 2 : 1;
@@ -66,6 +66,5 @@ function createMiniProgramPackageResolver(resolvePackage) {
66
66
  };
67
67
  }
68
68
 
69
- //#endregion
70
69
  export { createMiniProgramPackageResolver, getAncestorNodeModulesPaths };
71
70
  //# sourceMappingURL=packageResolution.mjs.map
@@ -3,7 +3,7 @@ import { dirname, extname, normalize, posix, relative, resolve } from "pathe";
3
3
  import { existsSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
- //#region src/plugin/path.ts
6
+ // src/plugin/path.ts
7
7
  function cleanUrl(url) {
8
8
  const queryIndex = url.indexOf("?");
9
9
  if (queryIndex >= 0) return url.slice(0, queryIndex);
@@ -84,6 +84,5 @@ function resolveWxsPathSync(raw, importer, srcRoot) {
84
84
  return resolveFileWithExtensionsSync(base, WXS_RESOLVE_EXTS);
85
85
  }
86
86
 
87
- //#endregion
88
87
  export { appendInlineQuery, appendQuery, cleanUrl, isHtmlEntry, isInsideDir, normalizePath, relativeModuleId, resolveFileWithExtensionsSync, resolveImportBase, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toPosixId, toRelativeImport, toViteFsImport };
89
88
  //# sourceMappingURL=path.mjs.map
@@ -6,7 +6,7 @@ import _babelTraverse from "@babel/traverse";
6
6
  import * as t from "@babel/types";
7
7
  import MagicString from "magic-string";
8
8
 
9
- //#region src/plugin/register.ts
9
+ // src/plugin/register.ts
10
10
  function resolveBabelTraverse(mod) {
11
11
  if (typeof mod === "function") return mod;
12
12
  if (mod?.default && typeof mod.default === "function") return mod.default;
@@ -107,6 +107,5 @@ function transformScriptModule({ code, cleanId, meta, enableHmr, runtimeModuleId
107
107
  };
108
108
  }
109
109
 
110
- //#endregion
111
110
  export { resolveBabelTraverse, transformScriptModule };
112
111
  //# sourceMappingURL=register.mjs.map
@@ -10,7 +10,7 @@ import { readdir } from "node:fs/promises";
10
10
  import process from "node:process";
11
11
  import { dirname, extname, join, posix, relative, resolve } from "pathe";
12
12
 
13
- //#region src/plugin/scan.ts
13
+ // src/plugin/scan.ts
14
14
  function getStableWebComponentId(script, srcRoot) {
15
15
  const normalized = script.replace(/\\/g, "/");
16
16
  const nodeModulesIndex = normalized.lastIndexOf("/node_modules/");
@@ -312,6 +312,5 @@ async function scanProject({ srcRoot, warn, state, resolveId, resolveAutoImportT
312
312
  };
313
313
  }
314
314
 
315
- //#endregion
316
315
  export { getStableWebComponentId, scanProject };
317
316
  //# sourceMappingURL=scan.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { readJsonFile, resolveJsonPath } from "./files.mjs";
2
2
 
3
- //#region src/plugin/scanConfig.ts
3
+ // src/plugin/scanConfig.ts
4
4
  async function collectComponentTagsFromConfig({ json, importerDir, jsonPath, warn, resolveComponentScript, getComponentTag, collectComponent, onResolved }) {
5
5
  const usingComponents = json.usingComponents;
6
6
  if (!usingComponents || typeof usingComponents !== "object") return {};
@@ -40,6 +40,5 @@ function normalizeComponentKey(raw) {
40
40
  return raw.trim().toLowerCase();
41
41
  }
42
42
 
43
- //#endregion
44
43
  export { collectComponentTagsFromConfig, collectComponentTagsFromJson, mergeComponentTags };
45
44
  //# sourceMappingURL=scanConfig.mjs.map
@@ -4,7 +4,7 @@ import { compileWebVueSfc } from "./vueSfc.mjs";
4
4
  import { readFile, readdir } from "node:fs/promises";
5
5
  import path from "pathe";
6
6
 
7
- //#region src/plugin/scanSfc.ts
7
+ // src/plugin/scanSfc.ts
8
8
  const PAGE_SEGMENT = "pages";
9
9
  const EXCLUDED_PAGE_SEGMENTS = /* @__PURE__ */ new Set([
10
10
  "components",
@@ -60,6 +60,5 @@ async function discoverWebPageIds(srcRoot) {
60
60
  return [...pageIds];
61
61
  }
62
62
 
63
- //#endregion
64
63
  export { compileScannedSfc, discoverWebPageIds, parseSfcJsonConfig };
65
64
  //# sourceMappingURL=scanSfc.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { normalizePath } from "./path.mjs";
2
2
  import { resolveWebVueSfcStyleLanguage } from "./vueSfc.mjs";
3
3
 
4
- //#region src/plugin/sfcHmr.ts
4
+ // src/plugin/sfcHmr.ts
5
5
  function reachesSfcOwner(module, owners) {
6
6
  const pending = [module];
7
7
  const visited = /* @__PURE__ */ new Set();
@@ -33,6 +33,5 @@ function collectSfcHmrModules(states, changedFile, graph, modules) {
33
33
  return [...affected];
34
34
  }
35
35
 
36
- //#endregion
37
36
  export { collectSfcHmrModules };
38
37
  //# sourceMappingURL=sfcHmr.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/plugin/state.ts
1
+ // src/plugin/state.ts
2
2
  function createEmptyScanState() {
3
3
  return {
4
4
  moduleMeta: /* @__PURE__ */ new Map(),
@@ -18,6 +18,5 @@ function createEmptyScanState() {
18
18
  };
19
19
  }
20
20
 
21
- //#endregion
22
21
  export { createEmptyScanState };
23
22
  //# sourceMappingURL=state.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/plugin/styleModule.ts
1
+ // src/plugin/styleModule.ts
2
2
  function createInlineStyleModule(css) {
3
3
  return [
4
4
  `const __weapp_injected_styles__ = new Map()`,
@@ -47,6 +47,5 @@ function createInlineStyleModule(css) {
47
47
  ].join("\n");
48
48
  }
49
49
 
50
- //#endregion
51
50
  export { createInlineStyleModule };
52
51
  //# sourceMappingURL=styleModule.mjs.map
@@ -1,8 +1,8 @@
1
- import { WxssTransformOptions } from "../css/wxss.mjs";
1
+ import { WxssTransformOptions } from "../shared/styleUnits/options.mjs";
2
+ import "../css/wxss.mjs";
2
3
  import { WebRoutingConfig } from "../runtime/polyfill/routeRuntime/history.mjs";
3
4
  import { WebResourceHintsConfig, WebRuntimeSeoConfig as WebSeoConfig } from "../runtime/seo/index.mjs";
4
5
  import "wevu/compiler";
5
- //#region src/plugin/types.d.ts
6
6
  export interface WeappWebPluginOptions {
7
7
  wxss?: WxssTransformOptions;
8
8
  /**
@@ -86,5 +86,4 @@ export type WebComponentResolver = {
86
86
  resolve?: (componentName: string, baseName: string) => WebResolvedComponent | void;
87
87
  } | ((componentName: string, baseName: string) => WebResolvedComponent | void);
88
88
  export type ResolveWebModuleId = (source: string, importer?: string) => Promise<string | undefined>;
89
- //#endregion
90
89
  //# sourceMappingURL=types.d.mts.map
@@ -10,7 +10,7 @@ import _babelTraverse from "@babel/traverse";
10
10
  import * as t from "@babel/types";
11
11
  import MagicString from "magic-string";
12
12
 
13
- //#region src/plugin/vueSfc.ts
13
+ // src/plugin/vueSfc.ts
14
14
  const traverse = _babelTraverse;
15
15
  const webTemplatePlatform = {
16
16
  ...getMiniProgramTemplatePlatform("weapp"),
@@ -149,6 +149,5 @@ function generateWebVueSfcStyle(result) {
149
149
  return result.style ?? "";
150
150
  }
151
151
 
152
- //#endregion
153
152
  export { compileWebVueSfc, ensureWebVueSfcResult, generateWebVueSfcStyle, generateWebVueSfcTemplate, resolveWebVueSfcStyleLanguage, transformWebVueSfcScript };
154
153
  //# sourceMappingURL=vueSfc.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/appShell/container.ts
1
+ // src/runtime/appShell/container.ts
2
2
  function onDocumentReady(callback) {
3
3
  if (typeof document === "undefined") return;
4
4
  if (document.readyState === "loading") {
@@ -20,6 +20,5 @@ function ensureAppContainer() {
20
20
  return container;
21
21
  }
22
22
 
23
- //#endregion
24
23
  export { ensureAppContainer, getAppContainer, onDocumentReady };
25
24
  //# sourceMappingURL=container.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { ensureAppContainer, getAppContainer, onDocumentReady } from "../container.mjs";
2
2
  import { TAB_BAR_STYLE } from "./style.mjs";
3
3
 
4
- //#region src/runtime/appShell/tabBar/index.ts
4
+ // src/runtime/appShell/tabBar/index.ts
5
5
  const TAB_BAR_TAG = "weapp-tab-bar";
6
6
  const TAB_BAR_HEIGHT = "50px";
7
7
  const BaseElement = globalThis.HTMLElement ?? class {};
@@ -187,6 +187,5 @@ function setTabBarRedDotState(index, redDot) {
187
187
  return true;
188
188
  }
189
189
 
190
- //#endregion
191
190
  export { configureTabBar, ensureTabBarDefined, getTabBarPagePaths, setTabBarBadgeState, setTabBarRedDotState, setTabBarVisible, syncTabBarRoute, updateTabBarItem, updateTabBarStyle };
192
191
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/appShell/tabBar/style.ts
1
+ // src/runtime/appShell/tabBar/style.ts
2
2
  const TAB_BAR_STYLE = `
3
3
  :host {
4
4
  --weapp-tab-bar-color: #7a7e83;
@@ -122,6 +122,5 @@ const TAB_BAR_STYLE = `
122
122
  }
123
123
  `;
124
124
 
125
- //#endregion
126
125
  export { TAB_BAR_STYLE };
127
126
  //# sourceMappingURL=style.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { injectStyle, removeStyle } from "./style.mjs";
2
2
 
3
- //#region src/runtime/appStyle.ts
3
+ // src/runtime/appStyle.ts
4
4
  const styleId = "weapp-web-app-style";
5
5
  const consumers = /* @__PURE__ */ new Set();
6
6
  let appStyle = "";
@@ -20,6 +20,5 @@ function trackAppStyle(consumer, enabled) {
20
20
  else consumers.delete(consumer);
21
21
  }
22
22
 
23
- //#endregion
24
23
  export { getAppStyle, setAppStyle, trackAppStyle };
25
24
  //# sourceMappingURL=appStyle.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/button/helpers.ts
1
+ // src/runtime/button/helpers.ts
2
2
  const DEFAULT_HOVER_CLASS = "button-hover";
3
3
  function toBoolean(value) {
4
4
  if (value === null) return false;
@@ -30,6 +30,5 @@ function isInternalNode(node) {
30
30
  return node instanceof HTMLElement && node.dataset?.weappInternal === "true";
31
31
  }
32
32
 
33
- //#endregion
34
33
  export { getHoverClass, isDisabled, isInternalNode, normalizeType, parseNumber, toBoolean };
35
34
  //# sourceMappingURL=helpers.mjs.map
@@ -1,7 +1,5 @@
1
1
  import { FormConfig } from "../nativeComponents/form.mjs";
2
- //#region src/runtime/button/index.d.ts
3
2
  export declare function ensureButtonDefined(): void;
4
3
  export declare function setButtonFormConfig(next: FormConfig): void;
5
4
  export type ButtonFormConfig = FormConfig;
6
- //#endregion
7
5
  //# sourceMappingURL=index.d.mts.map
@@ -3,7 +3,7 @@ import { setFormConfig } from "../nativeComponents/form.mjs";
3
3
  import { getHoverClass, isDisabled, isInternalNode, normalizeType, parseNumber, toBoolean } from "./helpers.mjs";
4
4
  import { ensureButtonStyle } from "./style.mjs";
5
5
 
6
- //#region src/runtime/button/index.ts
6
+ // src/runtime/button/index.ts
7
7
  const NAV_BUTTON_TAG = "weapp-button";
8
8
  const BaseElement = globalThis.HTMLElement ?? class {};
9
9
  var WeappButton = class extends BaseElement {
@@ -171,6 +171,5 @@ function setButtonFormConfig(next) {
171
171
  setFormConfig(next);
172
172
  }
173
173
 
174
- //#endregion
175
174
  export { WeappButton, ensureButtonDefined, setButtonFormConfig };
176
175
  //# sourceMappingURL=index.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { injectStyle } from "../style.mjs";
2
2
 
3
- //#region src/runtime/button/style.ts
3
+ // src/runtime/button/style.ts
4
4
  const BUTTON_STYLE_ID = "weapp-web-button-style";
5
5
  const styleTargets = /* @__PURE__ */ new WeakSet();
6
6
  let sharedSheet;
@@ -188,6 +188,5 @@ function ensureButtonStyle(root) {
188
188
  styleTargets.add(root);
189
189
  }
190
190
 
191
- //#endregion
192
191
  export { BUTTON_STYLE, ensureButtonStyle };
193
192
  //# sourceMappingURL=style.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/behavior.ts
1
+ // src/runtime/component/behavior.ts
2
2
  function isPlainObject(value) {
3
3
  return typeof value === "object" && value !== null && !Array.isArray(value);
4
4
  }
@@ -117,6 +117,5 @@ function normalizeBehaviors(component) {
117
117
  };
118
118
  }
119
119
 
120
- //#endregion
121
120
  export { normalizeBehaviors };
122
121
  //# sourceMappingURL=behavior.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/constants.ts
1
+ // src/runtime/component/constants.ts
2
2
  const supportsLit = typeof document !== "undefined" && typeof document.createComment === "function" && typeof document.createTreeWalker === "function";
3
3
  const FallbackElement = class {};
4
4
  const EVENT_ATTRIBUTE_NAME_ESCAPE_RE = /[A-Z_]/g;
@@ -16,6 +16,5 @@ const WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX = "data-wx-on-flags-";
16
16
  const EVENT_ATTRIBUTE_PREFIXES = [MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX, WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX];
17
17
  const EVENT_FLAG_ATTRIBUTE_PREFIXES = [MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX, WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX];
18
18
 
19
- //#endregion
20
19
  export { EVENT_ATTRIBUTE_PREFIXES, EVENT_FLAG_ATTRIBUTE_PREFIXES, FallbackElement, MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX, MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX, WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX, WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX, decodeEventAttributeName, encodeEventAttributeName, supportsLit };
21
20
  //# sourceMappingURL=constants.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { getMiniProgramRuntimeGlobalKeys } from "@weapp-core/shared/platforms/runtime";
2
2
 
3
- //#region src/runtime/component/dom.ts
3
+ // src/runtime/component/dom.ts
4
4
  const MINI_PROGRAM_RUNTIME_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys();
5
5
  function resolveQueryRoot(instance) {
6
6
  return instance.renderRoot ?? instance.shadowRoot ?? instance;
@@ -27,6 +27,5 @@ function selectRuntimeComponents(instance, selector) {
27
27
  return Array.from(root.querySelectorAll(selector));
28
28
  }
29
29
 
30
- //#endregion
31
30
  export { createScopedSelectorQuery, resolveQueryRoot, resolveRenderRoot, selectRuntimeComponent, selectRuntimeComponents };
32
31
  //# sourceMappingURL=dom.mjs.map
@@ -1,6 +1,7 @@
1
1
  import { getAppStyle, trackAppStyle } from "../appStyle.mjs";
2
2
  import { supportsLit } from "./constants.mjs";
3
3
  import { markComponentEvent, registerComponentEventTarget } from "../componentEvents.mjs";
4
+ import { commitLegacyDatasetBindings, releaseLegacyDatasetBindings, resetLegacyDatasetRender } from "../legacyTemplate/dataset.mjs";
4
5
  import { hasOwn } from "../utils/object.mjs";
5
6
  import { createComponentPublicInstance } from "./publicInstance.mjs";
6
7
  import { createIntersectionObserverBridge } from "../polyfill/intersectionObserver.mjs";
@@ -16,7 +17,7 @@ import { WEVU_HOST_COMMIT_PROMISE_KEY, WEVU_HOST_INSTALL_METHOD_KEY } from "@wea
16
17
  import { html } from "lit";
17
18
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
18
19
 
19
- //#region src/runtime/component/element.ts
20
+ // src/runtime/component/element.ts
20
21
  function resolveComposedParent(node) {
21
22
  const assignedSlot = node.assignedSlot;
22
23
  if (assignedSlot) return assignedSlot;
@@ -164,6 +165,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
164
165
  if (runtimeState.observerInitEnabled) this.#runInitialObservers();
165
166
  runtimeState.lifetimes.attached?.call(this.#publicInstance);
166
167
  this.#isMounted = true;
168
+ commitLegacyDatasetBindings(resolveRenderRoot(this), this.#renderContext);
167
169
  trackAppStyle(this, runtimeState.inheritAppStyle);
168
170
  this.requestUpdate();
169
171
  }
@@ -171,6 +173,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
171
173
  const superDisconnected = BaseElement.prototype.disconnectedCallback;
172
174
  if (supportsLit && typeof superDisconnected === "function") superDisconnected.call(this);
173
175
  this.#isMounted = false;
176
+ releaseLegacyDatasetBindings(this.#renderContext);
174
177
  trackAppStyle(this, false);
175
178
  instances.delete(this);
176
179
  runtimeState.lifetimes.detached?.call(this.#publicInstance);
@@ -189,9 +192,11 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
189
192
  }
190
193
  updated() {
191
194
  this.#syncVirtualHostClasses();
195
+ commitLegacyDatasetBindings(resolveRenderRoot(this), this.#renderContext);
192
196
  if (this.#usesLegacyTemplate) bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this);
193
197
  }
194
198
  render() {
199
+ resetLegacyDatasetRender(this.#renderContext);
195
200
  const result = runtimeState.templateRef(this.#state, this.#renderContext);
196
201
  const appStyle = runtimeState.inheritAppStyle ? getAppStyle() : "";
197
202
  this.#usesLegacyTemplate = typeof result === "string";
@@ -281,6 +286,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
281
286
  });
282
287
  this.#exposedMethodNames.add(key);
283
288
  }
289
+ releaseLegacyDatasetBindings(this.#renderContext);
284
290
  this.#renderContext = createRenderContext(this, this.#methods);
285
291
  }
286
292
  __weappSync(nextMethods) {
@@ -293,6 +299,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
293
299
  if (typeof hook === "function") hook.call(this.#publicInstance);
294
300
  }
295
301
  #renderLegacy() {
302
+ resetLegacyDatasetRender(this.#renderContext);
296
303
  const result = runtimeState.templateRef(this.#state, this.#renderContext);
297
304
  const root = resolveRenderRoot(this);
298
305
  const styleMarkup = `<style>${runtimeState.inheritAppStyle ? getAppStyle() : ""}</style><style>${runtimeState.styleRef}</style>`;
@@ -301,6 +308,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
301
308
  bindRuntimeEvents(root, this.#methods, this);
302
309
  } else if (result == null) root.innerHTML = styleMarkup;
303
310
  else root.innerHTML = `${styleMarkup}${String(result)}`;
311
+ commitLegacyDatasetBindings(root, this.#renderContext);
304
312
  this.#syncVirtualHostClasses();
305
313
  if (!this.#readyFired) {
306
314
  runtimeState.lifetimes.ready?.call(this.#publicInstance);
@@ -323,6 +331,5 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
323
331
  return WeappWebComponent;
324
332
  }
325
333
 
326
- //#endregion
327
334
  export { createComponentElementClass };
328
335
  //# sourceMappingURL=element.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.mjs","names":[],"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 { WEVU_HOST_COMMIT_PROMISE_KEY, WEVU_HOST_INSTALL_METHOD_KEY } from '@weapp-core/constants'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { getAppStyle, trackAppStyle } from '../appStyle'\nimport { markComponentEvent, registerComponentEventTarget } from '../componentEvents'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\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 { assignDataPath, cloneCommittedValue, cloneValue, coerceValue, parseDataPath, resolveDataPath, 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 #setupMethods: Record<string, (...args: 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 #needsSetDataRecovery = false\n #hostCommitPromise: Promise<void> | undefined\n #hostCommitUpdate: Promise<boolean> | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n registerComponentEventTarget(this)\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 this.#properties,\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 get [WEVU_HOST_COMMIT_PROMISE_KEY]() {\n // 回调异常属于当前提交;后续属性更新或 HMR 必须等待自己的 Lit 提交。\n if (!supportsLit) {\n return undefined\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n return this.#hostCommitUpdate === update ? this.#hostCommitPromise : update\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && (changed || this.#needsSetDataRecovery)) {\n if (!changed) {\n this.requestUpdate()\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n const commitPromise = update.then(\n () => {\n this.#needsSetDataRecovery = false\n callback?.()\n },\n (cause) => {\n this.#needsSetDataRecovery = true\n throw cause\n },\n )\n this.#hostCommitPromise = commitPromise\n this.#hostCommitUpdate = update\n return commitPromise\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(markComponentEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n })))\n }\n\n [WEVU_HOST_INSTALL_METHOD_KEY](methods: Readonly<Record<string, (...args: any[]) => any>>) {\n const bound: Record<string, (...args: any[]) => any> = {}\n for (const [name, method] of Object.entries(methods)) {\n bound[name] = method.bind(this.#publicInstance)\n }\n this.#setupMethods = bound\n this.#syncMethods(runtimeState.componentRef.methods)\n this.requestUpdate()\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\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 instances.add(this)\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 trackAppStyle(this, runtimeState.inheritAppStyle)\n this.requestUpdate()\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 trackAppStyle(this, 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 appStyle = runtimeState.inheritAppStyle ? getAppStyle() : ''\n this.#usesLegacyTemplate = typeof result === 'string'\n return html`<style>${appStyle}</style><style>${runtimeState.styleRef}</style>${typeof result === 'string' ? unsafeHTML(result) : 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 let copiedContainers: WeakSet<object> | undefined\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || topKey === '$slots') {\n continue\n }\n let nextValue = value\n if (value !== null && typeof value === 'object') {\n // 整体提交需刷新整个子树,新的外层对象也可能复用已原地修改的后代。\n // 快照可保留内部别名,路径更新仍需按分支取得写入所有权。\n nextValue = cloneCommittedValue(value)\n }\n else if (Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n if (segments.length > 1) {\n copiedContainers ??= new WeakSet<object>()\n }\n assignDataPath(this.#state, segments, nextValue, copiedContainers)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\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 Object.assign(bound, this.#setupMethods)\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 const previous = this.#methods[key]\n this.#methods[key] = fn\n if (this.#exposedMethodNames.has(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(this, key)\n if (!descriptor?.configurable || descriptor.value !== previous) {\n continue\n }\n }\n else if (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 trackAppStyle(this, this.#isMounted && runtimeState.inheritAppStyle)\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 appStyle = runtimeState.inheritAppStyle ? getAppStyle() : ''\n const styleMarkup = `<style>${appStyle}</style><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":";;;;;;;;;;;;;;;;;;;AA6CA,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,gBAAyD,CAAC;EAC1D;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,wBAAwB;EACxB;EACA;EACA,AAAS;EACT,AAAS;EAET,cAAc;GACZ,MAAM;GACN,6BAA6B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Aa;IACrB,aAAa,UAAU,OAAO,KAAK,KAAK,eAAe;IACvD,KAAK,cAAc;GACrB;EACF;EAEA,0BAA0B;GACxB,MAAM,OAAO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAK,uBAAuB;IAC1D,sBAAsB,KAAK,yBAAyB,KAAK,sBAAsB;IAC/E,KAAK,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAK,uBAAuB;GAC/D,KAAK,0BAA0B,qBAC7B,MACA,KAAK,yBACL,KAAK,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"element.mjs","names":[],"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 { WEVU_HOST_COMMIT_PROMISE_KEY, WEVU_HOST_INSTALL_METHOD_KEY } from '@weapp-core/constants'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { getAppStyle, trackAppStyle } from '../appStyle'\nimport { markComponentEvent, registerComponentEventTarget } from '../componentEvents'\nimport { commitLegacyDatasetBindings, releaseLegacyDatasetBindings, resetLegacyDatasetRender } from '../legacyTemplate/dataset'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\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 { assignDataPath, cloneCommittedValue, cloneValue, coerceValue, parseDataPath, resolveDataPath, 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 #setupMethods: Record<string, (...args: 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 #needsSetDataRecovery = false\n #hostCommitPromise: Promise<void> | undefined\n #hostCommitUpdate: Promise<boolean> | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n registerComponentEventTarget(this)\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 this.#properties,\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 get [WEVU_HOST_COMMIT_PROMISE_KEY]() {\n // 回调异常属于当前提交;后续属性更新或 HMR 必须等待自己的 Lit 提交。\n if (!supportsLit) {\n return undefined\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n return this.#hostCommitUpdate === update ? this.#hostCommitPromise : update\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && (changed || this.#needsSetDataRecovery)) {\n if (!changed) {\n this.requestUpdate()\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n const commitPromise = update.then(\n () => {\n this.#needsSetDataRecovery = false\n callback?.()\n },\n (cause) => {\n this.#needsSetDataRecovery = true\n throw cause\n },\n )\n this.#hostCommitPromise = commitPromise\n this.#hostCommitUpdate = update\n return commitPromise\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(markComponentEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n })))\n }\n\n [WEVU_HOST_INSTALL_METHOD_KEY](methods: Readonly<Record<string, (...args: any[]) => any>>) {\n const bound: Record<string, (...args: any[]) => any> = {}\n for (const [name, method] of Object.entries(methods)) {\n bound[name] = method.bind(this.#publicInstance)\n }\n this.#setupMethods = bound\n this.#syncMethods(runtimeState.componentRef.methods)\n this.requestUpdate()\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\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 instances.add(this)\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 commitLegacyDatasetBindings(resolveRenderRoot(this), this.#renderContext)\n trackAppStyle(this, runtimeState.inheritAppStyle)\n this.requestUpdate()\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 releaseLegacyDatasetBindings(this.#renderContext)\n trackAppStyle(this, 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 commitLegacyDatasetBindings(resolveRenderRoot(this), this.#renderContext)\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n resetLegacyDatasetRender(this.#renderContext)\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const appStyle = runtimeState.inheritAppStyle ? getAppStyle() : ''\n this.#usesLegacyTemplate = typeof result === 'string'\n return html`<style>${appStyle}</style><style>${runtimeState.styleRef}</style>${typeof result === 'string' ? unsafeHTML(result) : 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 let copiedContainers: WeakSet<object> | undefined\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || topKey === '$slots') {\n continue\n }\n let nextValue = value\n if (value !== null && typeof value === 'object') {\n // 整体提交需刷新整个子树,新的外层对象也可能复用已原地修改的后代。\n // 快照可保留内部别名,路径更新仍需按分支取得写入所有权。\n nextValue = cloneCommittedValue(value)\n }\n else if (Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n if (segments.length > 1) {\n copiedContainers ??= new WeakSet<object>()\n }\n assignDataPath(this.#state, segments, nextValue, copiedContainers)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\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 Object.assign(bound, this.#setupMethods)\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 const previous = this.#methods[key]\n this.#methods[key] = fn\n if (this.#exposedMethodNames.has(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(this, key)\n if (!descriptor?.configurable || descriptor.value !== previous) {\n continue\n }\n }\n else if (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 releaseLegacyDatasetBindings(this.#renderContext)\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n trackAppStyle(this, this.#isMounted && runtimeState.inheritAppStyle)\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 resetLegacyDatasetRender(this.#renderContext)\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const appStyle = runtimeState.inheritAppStyle ? getAppStyle() : ''\n const styleMarkup = `<style>${appStyle}</style><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 commitLegacyDatasetBindings(root, this.#renderContext)\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":";;;;;;;;;;;;;;;;;;;;AA8CA,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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RuntimeEventHandler } from "../componentEvents.mjs";
3
+ import { readRuntimeDataset } from "../dataset.mjs";
3
4
  import { invokeMiniProgramEventHandler } from "../inputHandlerResult.mjs";
4
5
 
5
- //#region src/runtime/component/events.ts
6
+ // src/runtime/component/events.ts
6
7
  function parseEventFlags(value) {
7
8
  if (!value) return {
8
9
  catch: false,
@@ -49,12 +50,12 @@ function bindRuntimeEvents(root, methods, instance) {
49
50
  const flags = parseEventFlags(flagAttributeValue);
50
51
  const listener = nameRuntimeEventHandler((nativeEvent) => {
51
52
  if (flags.catch) nativeEvent.stopPropagation();
52
- const dataset = { ...element.dataset };
53
+ const dataset = { ...readRuntimeDataset(element) };
53
54
  const syntheticEvent = {
54
55
  type: eventName,
55
56
  timeStamp: nativeEvent.timeStamp,
56
57
  detail: nativeEvent.detail ?? nativeEvent.data ?? void 0,
57
- target: { dataset },
58
+ target: { dataset: readRuntimeDataset(nativeEvent.target) },
58
59
  currentTarget: { dataset },
59
60
  originalEvent: nativeEvent
60
61
  };
@@ -77,6 +78,5 @@ function bindRuntimeEvents(root, methods, instance) {
77
78
  }
78
79
  }
79
80
 
80
- //#endregion
81
81
  export { bindRuntimeEvents };
82
82
  //# sourceMappingURL=events.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.mjs","names":[],"sources":["../../../src/runtime/component/events.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './types'\nimport { listenRuntimeEvent, nameRuntimeEventHandler } from '../componentEvents'\nimport { invokeMiniProgramEventHandler } from '../inputHandlerResult'\nimport {\n decodeEventAttributeName,\n EVENT_ATTRIBUTE_PREFIXES,\n EVENT_FLAG_ATTRIBUTE_PREFIXES,\n} from './constants'\n\ninterface RuntimeEventFlags {\n catch: boolean\n capture: boolean\n}\n\nfunction parseEventFlags(value: string | null): RuntimeEventFlags {\n if (!value) {\n return { catch: false, capture: false }\n }\n const tokens = value.split(',').map(token => token.trim()).filter(Boolean)\n const tokenSet = new Set(tokens)\n return {\n catch: tokenSet.has('catch'),\n capture: tokenSet.has('capture'),\n }\n}\n\ninterface RuntimeEventBinding {\n encodedEventName: string\n flagAttributeValue: string | null\n handler: (event: unknown) => unknown\n instance: ComponentPublicInstance\n dispose: () => void\n}\n\nconst runtimeEventBindings = new WeakMap<HTMLElement, Map<string, RuntimeEventBinding>>()\n\nfunction getEventFlagAttributeValue(element: HTMLElement, encodedEventName: string) {\n for (const prefix of EVENT_FLAG_ATTRIBUTE_PREFIXES) {\n const value = element.getAttribute(`${prefix}${encodedEventName}`)\n if (value !== null) {\n return value\n }\n }\n return null\n}\n\nexport function bindRuntimeEvents(\n root: HTMLElement | ShadowRoot,\n methods: Record<string, (event: any) => any>,\n instance: ComponentPublicInstance,\n) {\n if (typeof document === 'undefined') {\n return\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)\n while (walker.nextNode()) {\n const element = walker.currentNode as HTMLElement\n let bindings = runtimeEventBindings.get(element)\n if (bindings) {\n for (const [attribute, binding] of bindings) {\n const handlerName = element.getAttribute(attribute)\n if (\n handlerName\n && methods[handlerName] === binding.handler\n && instance === binding.instance\n && getEventFlagAttributeValue(element, binding.encodedEventName) === binding.flagAttributeValue\n ) {\n continue\n }\n binding.dispose()\n bindings.delete(attribute)\n }\n }\n for (const attribute of element.getAttributeNames()) {\n if (bindings?.has(attribute)) {\n continue\n }\n const matchedPrefix = EVENT_ATTRIBUTE_PREFIXES.find(prefix => attribute.startsWith(prefix))\n if (!matchedPrefix || EVENT_FLAG_ATTRIBUTE_PREFIXES.some(prefix => attribute.startsWith(prefix))) {\n continue\n }\n const handlerName = element.getAttribute(attribute)\n if (!handlerName) {\n continue\n }\n const handler = methods[handlerName]\n if (!handler) {\n continue\n }\n const encodedEventName = attribute.slice(matchedPrefix.length)\n const eventName = decodeEventAttributeName(encodedEventName)\n const flagAttributeValue = getEventFlagAttributeValue(element, encodedEventName)\n const flags = parseEventFlags(flagAttributeValue)\n const listener = nameRuntimeEventHandler((nativeEvent) => {\n if (flags.catch) {\n nativeEvent.stopPropagation()\n }\n const dataset = { ...element.dataset }\n const syntheticEvent = {\n type: eventName,\n timeStamp: nativeEvent.timeStamp,\n detail: (nativeEvent as CustomEvent).detail ?? (nativeEvent as InputEvent).data ?? undefined,\n target: {\n dataset,\n },\n currentTarget: {\n dataset,\n },\n originalEvent: nativeEvent,\n }\n invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent)\n }, eventName)\n const dispose = listenRuntimeEvent(element, eventName, listener, flags.capture)\n if (!bindings) {\n bindings = new Map()\n runtimeEventBindings.set(element, bindings)\n }\n bindings.set(attribute, { encodedEventName, flagAttributeValue, handler, instance, dispose })\n }\n if (bindings?.size === 0) {\n runtimeEventBindings.delete(element)\n }\n }\n}\n"],"mappings":";;;;;AAcA,SAAS,gBAAgB,OAAyC;CAChE,IAAI,CAAC,OACH,OAAO;EAAE,OAAO;EAAO,SAAS;CAAM;CAExC,MAAM,SAAS,MAAM,MAAM,GAAG,CAAC,CAAC,KAAI,UAAS,MAAM,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO;CACzE,MAAM,WAAW,IAAI,IAAI,MAAM;CAC/B,OAAO;EACL,OAAO,SAAS,IAAI,OAAO;EAC3B,SAAS,SAAS,IAAI,SAAS;CACjC;AACF;AAUA,MAAM,uCAAuB,IAAI,QAAuD;AAExF,SAAS,2BAA2B,SAAsB,kBAA0B;CAClF,KAAK,MAAM,UAAU,+BAA+B;EAClD,MAAM,QAAQ,QAAQ,aAAa,GAAG,SAAS,kBAAkB;EACjE,IAAI,UAAU,MACZ,OAAO;CAEX;CACA,OAAO;AACT;AAEA,SAAgB,kBACd,MACA,SACA,UACA;CACA,IAAI,OAAO,aAAa,aACtB;CAEF,MAAM,SAAS,SAAS,iBAAiB,MAAM,WAAW,YAAY;CACtE,OAAO,OAAO,SAAS,GAAG;EACxB,MAAM,UAAU,OAAO;EACvB,IAAI,WAAW,qBAAqB,IAAI,OAAO;EAC/C,IAAI,UACF,KAAK,MAAM,CAAC,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AoB;IAAS;IAAU;GAAQ,CAAC;EAC9F;EACA,IAAI,UAAU,SAAS,GACrB,qBAAqB,OAAO,OAAO;CAEvC;AACF"}
1
+ {"version":3,"file":"events.mjs","names":[],"sources":["../../../src/runtime/component/events.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './types'\nimport { listenRuntimeEvent, nameRuntimeEventHandler } from '../componentEvents'\nimport { readRuntimeDataset } from '../dataset'\nimport { invokeMiniProgramEventHandler } from '../inputHandlerResult'\nimport {\n decodeEventAttributeName,\n EVENT_ATTRIBUTE_PREFIXES,\n EVENT_FLAG_ATTRIBUTE_PREFIXES,\n} from './constants'\n\ninterface RuntimeEventFlags {\n catch: boolean\n capture: boolean\n}\n\nfunction parseEventFlags(value: string | null): RuntimeEventFlags {\n if (!value) {\n return { catch: false, capture: false }\n }\n const tokens = value.split(',').map(token => token.trim()).filter(Boolean)\n const tokenSet = new Set(tokens)\n return {\n catch: tokenSet.has('catch'),\n capture: tokenSet.has('capture'),\n }\n}\n\ninterface RuntimeEventBinding {\n encodedEventName: string\n flagAttributeValue: string | null\n handler: (event: unknown) => unknown\n instance: ComponentPublicInstance\n dispose: () => void\n}\n\nconst runtimeEventBindings = new WeakMap<HTMLElement, Map<string, RuntimeEventBinding>>()\n\nfunction getEventFlagAttributeValue(element: HTMLElement, encodedEventName: string) {\n for (const prefix of EVENT_FLAG_ATTRIBUTE_PREFIXES) {\n const value = element.getAttribute(`${prefix}${encodedEventName}`)\n if (value !== null) {\n return value\n }\n }\n return null\n}\n\nexport function bindRuntimeEvents(\n root: HTMLElement | ShadowRoot,\n methods: Record<string, (event: any) => any>,\n instance: ComponentPublicInstance,\n) {\n if (typeof document === 'undefined') {\n return\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)\n while (walker.nextNode()) {\n const element = walker.currentNode as HTMLElement\n let bindings = runtimeEventBindings.get(element)\n if (bindings) {\n for (const [attribute, binding] of bindings) {\n const handlerName = element.getAttribute(attribute)\n if (\n handlerName\n && methods[handlerName] === binding.handler\n && instance === binding.instance\n && getEventFlagAttributeValue(element, binding.encodedEventName) === binding.flagAttributeValue\n ) {\n continue\n }\n binding.dispose()\n bindings.delete(attribute)\n }\n }\n for (const attribute of element.getAttributeNames()) {\n if (bindings?.has(attribute)) {\n continue\n }\n const matchedPrefix = EVENT_ATTRIBUTE_PREFIXES.find(prefix => attribute.startsWith(prefix))\n if (!matchedPrefix || EVENT_FLAG_ATTRIBUTE_PREFIXES.some(prefix => attribute.startsWith(prefix))) {\n continue\n }\n const handlerName = element.getAttribute(attribute)\n if (!handlerName) {\n continue\n }\n const handler = methods[handlerName]\n if (!handler) {\n continue\n }\n const encodedEventName = attribute.slice(matchedPrefix.length)\n const eventName = decodeEventAttributeName(encodedEventName)\n const flagAttributeValue = getEventFlagAttributeValue(element, encodedEventName)\n const flags = parseEventFlags(flagAttributeValue)\n const listener = nameRuntimeEventHandler((nativeEvent) => {\n if (flags.catch) {\n nativeEvent.stopPropagation()\n }\n const dataset = { ...readRuntimeDataset(element) }\n const syntheticEvent = {\n type: eventName,\n timeStamp: nativeEvent.timeStamp,\n detail: (nativeEvent as CustomEvent).detail ?? (nativeEvent as InputEvent).data ?? undefined,\n target: {\n dataset: readRuntimeDataset(nativeEvent.target as Element | null),\n },\n currentTarget: {\n dataset,\n },\n originalEvent: nativeEvent,\n }\n invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent)\n }, eventName)\n const dispose = listenRuntimeEvent(element, eventName, listener, flags.capture)\n if (!bindings) {\n bindings = new Map()\n runtimeEventBindings.set(element, bindings)\n }\n bindings.set(attribute, { encodedEventName, flagAttributeValue, handler, instance, dispose })\n }\n if (bindings?.size === 0) {\n runtimeEventBindings.delete(element)\n }\n }\n}\n"],"mappings":";;;;;;AAeA,SAAS,gBAAgB,OAAyC;CAChE,IAAI,CAAC,OACH,OAAO;EAAE,OAAO;EAAO,SAAS;CAAM;CAExC,MAAM,SAAS,MAAM,MAAM,GAAG,CAAC,CA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C7D,MAAM,YAAY,yBAAyB,gBAAgB;GAC3D,MAAM,qBAAqB,2BAA2B,SAAS,gBAAgB;GAC/E,MAAM,QAAQ,gBAAgB,kBAAkB;GAChD,MAAM,WAAW,yBAAyB,gBAAgB;IACxD,IAAI,MAAM,OACR,YAAY,gBAAgB;IAE9B,MAAM,UAAU,EAAE,GAAG,mBAAmB,OAAO,EAAE;IACjD,MAAM,iBAAiB;KACrB,MAAM;KACN,WAAW,YAAY;KACvB,QAAS,YAA4B,UAAW,YAA2B,QAAQ;KACnF,QAAQ,EACN,SAAS,mBAAmB,YAAY,MAAwB,EAClE;KACA,eAAe,EACb,QACF;KACA,eAAe;IACjB;IACA,8BAA8B,SAAS,UAAU,gBAAgB,WAAW;GAC9E,GAAG,SAAS;GACZ,MAAM,UAAU,mBAAmB,SAAS,WAAW,UAAU,MAAM,OAAO;GAC9E,IAAI,CAAC,UAAU;IACb,2BAAW,IAAI,IAAI;IACnB,qBAAqB,IAAI,SAAS,QAAQ;GAC5C;GACA,SAAS,IAAI,WAAW;IAAE;IAAkB;IAAoB;IAAS;IAAU;GAAQ,CAAC;EAC9F;EACA,IAAI,UAAU,SAAS,GACrB,qBAAqB,OAAO,OAAO;CAEvC;AACF"}
@@ -1,6 +1,4 @@
1
1
  import { ComponentConstructor, ComponentOptions, ComponentPublicInstance, DefineComponentOptions, PropertyOption } from "./types.mjs";
2
- //#region src/runtime/component/index.d.ts
3
2
  export declare function defineComponent(tagName: string, options: DefineComponentOptions): ComponentConstructor;
4
- //#endregion
5
3
  export type { ComponentOptions, ComponentPublicInstance };
6
4
  //# sourceMappingURL=index.d.mts.map
@@ -4,7 +4,7 @@ import { createComponentElementClass } from "./element.mjs";
4
4
  import { createComponentRuntimeState, updateComponentRuntimeState } from "./state.mjs";
5
5
  import { LitElement } from "lit";
6
6
 
7
- //#region src/runtime/component/index.ts
7
+ // src/runtime/component/index.ts
8
8
  function emitBehaviorWarnings(warnings) {
9
9
  for (const warning of warnings) emitRuntimeWarning(warning, {
10
10
  key: `component-behaviors:${warning}`,
@@ -39,6 +39,5 @@ function defineComponent(tagName, options) {
39
39
  return WeappWebComponent;
40
40
  }
41
41
 
42
- //#endregion
43
42
  export { defineComponent };
44
43
  //# sourceMappingURL=index.mjs.map