@weapp-vite/web 2.0.0 → 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 (310) 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 +33 -39
  5. package/dist/compiler/wxml/compile.mjs.map +1 -1
  6. package/dist/compiler/wxml/dependency.mjs +10 -3
  7. package/dist/compiler/wxml/dependency.mjs.map +1 -1
  8. package/dist/compiler/wxml/interpolation.mjs +13 -3
  9. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  10. package/dist/compiler/wxml/nativeTags.mjs +60 -0
  11. package/dist/compiler/wxml/nativeTags.mjs.map +1 -0
  12. package/dist/compiler/wxml/navigation.mjs +1 -2
  13. package/dist/compiler/wxml/parser.mjs +1 -2
  14. package/dist/compiler/wxml/prepare.mjs +42 -0
  15. package/dist/compiler/wxml/prepare.mjs.map +1 -0
  16. package/dist/compiler/wxml/renderer.mjs +1 -2
  17. package/dist/compiler/wxml/specialNodes.mjs +1 -2
  18. package/dist/compiler/wxml/types.d.mts +0 -2
  19. package/dist/compiler/wxml/unknownTags.mjs +33 -0
  20. package/dist/compiler/wxml/unknownTags.mjs.map +1 -0
  21. package/dist/compiler/wxs.mjs +1 -2
  22. package/dist/css/wxss.d.mts +2 -19
  23. package/dist/css/wxss.mjs +5 -12
  24. package/dist/css/wxss.mjs.map +1 -1
  25. package/dist/index.d.mts +8 -3
  26. package/dist/index.mjs +8 -5
  27. package/dist/plugin/assets.d.mts +1 -2
  28. package/dist/plugin/assets.mjs +1 -2
  29. package/dist/plugin/constants.mjs +5 -4
  30. package/dist/plugin/constants.mjs.map +1 -1
  31. package/dist/plugin/dependencyScan.mjs +1 -2
  32. package/dist/plugin/entry.mjs +6 -4
  33. package/dist/plugin/entry.mjs.map +1 -1
  34. package/dist/plugin/files.mjs +1 -2
  35. package/dist/plugin/hostTypes.d.mts +1 -2
  36. package/dist/plugin/index.d.mts +0 -2
  37. package/dist/plugin/index.mjs +29 -24
  38. package/dist/plugin/index.mjs.map +1 -1
  39. package/dist/plugin/layout.mjs +1 -2
  40. package/dist/plugin/navigation.mjs +1 -2
  41. package/dist/plugin/packageResolution.mjs +1 -2
  42. package/dist/plugin/path.mjs +1 -2
  43. package/dist/plugin/register.mjs +1 -2
  44. package/dist/plugin/scan.mjs +1 -2
  45. package/dist/plugin/scanConfig.mjs +1 -2
  46. package/dist/plugin/scanSfc.mjs +1 -2
  47. package/dist/plugin/sfcHmr.mjs +28 -10
  48. package/dist/plugin/sfcHmr.mjs.map +1 -1
  49. package/dist/plugin/state.mjs +1 -2
  50. package/dist/plugin/styleModule.mjs +1 -2
  51. package/dist/plugin/types.d.mts +2 -3
  52. package/dist/plugin/vueSfc.mjs +1 -2
  53. package/dist/runtime/appShell/container.mjs +1 -2
  54. package/dist/runtime/appShell/tabBar/index.mjs +1 -2
  55. package/dist/runtime/appShell/tabBar/style.mjs +1 -2
  56. package/dist/runtime/appStyle.mjs +1 -2
  57. package/dist/runtime/button/helpers.mjs +1 -2
  58. package/dist/runtime/button/index.d.mts +0 -2
  59. package/dist/runtime/button/index.mjs +1 -2
  60. package/dist/runtime/button/style.mjs +1 -2
  61. package/dist/runtime/component/behavior.mjs +1 -2
  62. package/dist/runtime/component/constants.mjs +1 -2
  63. package/dist/runtime/component/dom.mjs +1 -2
  64. package/dist/runtime/component/element.mjs +9 -2
  65. package/dist/runtime/component/element.mjs.map +1 -1
  66. package/dist/runtime/component/events.mjs +4 -4
  67. package/dist/runtime/component/events.mjs.map +1 -1
  68. package/dist/runtime/component/index.d.mts +0 -2
  69. package/dist/runtime/component/index.mjs +1 -2
  70. package/dist/runtime/component/observers.mjs +1 -2
  71. package/dist/runtime/component/publicInstance.mjs +1 -2
  72. package/dist/runtime/component/relations.mjs +1 -2
  73. package/dist/runtime/component/slots.mjs +1 -2
  74. package/dist/runtime/component/state.mjs +1 -2
  75. package/dist/runtime/component/types.d.mts +0 -2
  76. package/dist/runtime/component/utils.mjs +1 -2
  77. package/dist/runtime/component/virtualHost.mjs +1 -2
  78. package/dist/runtime/componentEvents.mjs +1 -2
  79. package/dist/runtime/dataset.mjs +49 -0
  80. package/dist/runtime/dataset.mjs.map +1 -0
  81. package/dist/runtime/datasetBinding.d.mts +13 -0
  82. package/dist/runtime/datasetBinding.mjs +40 -0
  83. package/dist/runtime/datasetBinding.mjs.map +1 -0
  84. package/dist/runtime/eventBinding.d.mts +1 -2
  85. package/dist/runtime/eventBinding.mjs +1 -2
  86. package/dist/runtime/execution.d.mts +0 -2
  87. package/dist/runtime/execution.mjs +1 -2
  88. package/dist/runtime/host/index.d.mts +0 -2
  89. package/dist/runtime/host/index.mjs +1 -2
  90. package/dist/runtime/host/types.d.mts +0 -2
  91. package/dist/runtime/hostGlobals.d.mts +1 -2
  92. package/dist/runtime/hostGlobals.mjs +1 -2
  93. package/dist/runtime/index.d.mts +8 -3
  94. package/dist/runtime/index.mjs +9 -7
  95. package/dist/runtime/index.mjs.map +1 -1
  96. package/dist/runtime/inlineStyle.d.mts +5 -0
  97. package/dist/runtime/inlineStyle.mjs +21 -0
  98. package/dist/runtime/inlineStyle.mjs.map +1 -0
  99. package/dist/runtime/inputHandlerResult.mjs +1 -2
  100. package/dist/runtime/legacyTemplate/dataset.mjs +53 -0
  101. package/dist/runtime/legacyTemplate/dataset.mjs.map +1 -0
  102. package/dist/runtime/legacyTemplate/dom.mjs +20 -5
  103. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  104. package/dist/runtime/legacyTemplate/expression.mjs +1 -2
  105. package/dist/runtime/legacyTemplate/index.d.mts +0 -2
  106. package/dist/runtime/legacyTemplate/index.mjs +23 -16
  107. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  108. package/dist/runtime/legacyTemplate/types.d.mts +0 -2
  109. package/dist/runtime/nativeComponents/canvas/index.mjs +1 -2
  110. package/dist/runtime/nativeComponents/checkbox.mjs +1 -2
  111. package/dist/runtime/nativeComponents/cover/index.mjs +1 -2
  112. package/dist/runtime/nativeComponents/form.d.mts +0 -2
  113. package/dist/runtime/nativeComponents/form.mjs +1 -2
  114. package/dist/runtime/nativeComponents/formControl.mjs +1 -2
  115. package/dist/runtime/nativeComponents/helpers.mjs +1 -2
  116. package/dist/runtime/nativeComponents/icon/helpers.mjs +1 -2
  117. package/dist/runtime/nativeComponents/icon/index.mjs +1 -2
  118. package/dist/runtime/nativeComponents/icon/style.mjs +1 -2
  119. package/dist/runtime/nativeComponents/image.d.mts +0 -2
  120. package/dist/runtime/nativeComponents/image.mjs +1 -2
  121. package/dist/runtime/nativeComponents/index.d.mts +1 -3
  122. package/dist/runtime/nativeComponents/index.mjs +3 -4
  123. package/dist/runtime/nativeComponents/index.mjs.map +1 -1
  124. package/dist/runtime/nativeComponents/input.d.mts +0 -2
  125. package/dist/runtime/nativeComponents/input.mjs +1 -2
  126. package/dist/runtime/nativeComponents/label.mjs +1 -2
  127. package/dist/runtime/nativeComponents/mediaRegistry.mjs +1 -2
  128. package/dist/runtime/nativeComponents/movable/helpers.mjs +1 -2
  129. package/dist/runtime/nativeComponents/movable/index.mjs +1 -2
  130. package/dist/runtime/nativeComponents/navigator.mjs +1 -2
  131. package/dist/runtime/nativeComponents/picker/editors.mjs +1 -2
  132. package/dist/runtime/nativeComponents/picker/helpers.mjs +1 -2
  133. package/dist/runtime/nativeComponents/picker/index.mjs +1 -2
  134. package/dist/runtime/nativeComponents/picker/style.mjs +1 -2
  135. package/dist/runtime/nativeComponents/pickerView/column.mjs +1 -2
  136. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +1 -2
  137. package/dist/runtime/nativeComponents/pickerView/index.mjs +1 -2
  138. package/dist/runtime/nativeComponents/pickerView/style.mjs +1 -2
  139. package/dist/runtime/nativeComponents/primitives.mjs +1 -2
  140. package/dist/runtime/nativeComponents/progress/helpers.mjs +1 -2
  141. package/dist/runtime/nativeComponents/progress/index.mjs +1 -2
  142. package/dist/runtime/nativeComponents/progress/style.mjs +1 -2
  143. package/dist/runtime/nativeComponents/radio.mjs +1 -2
  144. package/dist/runtime/nativeComponents/richText/index.mjs +3 -4
  145. package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -1
  146. package/dist/runtime/nativeComponents/scrollView/boundaries.mjs +62 -0
  147. package/dist/runtime/nativeComponents/scrollView/boundaries.mjs.map +1 -0
  148. package/dist/runtime/nativeComponents/{scrollView.d.mts → scrollView/helpers.d.mts} +4 -5
  149. package/dist/runtime/nativeComponents/scrollView/helpers.mjs +14 -0
  150. package/dist/runtime/nativeComponents/scrollView/helpers.mjs.map +1 -0
  151. package/dist/runtime/nativeComponents/scrollView/index.mjs +193 -0
  152. package/dist/runtime/nativeComponents/scrollView/index.mjs.map +1 -0
  153. package/dist/runtime/nativeComponents/scrollView/position.mjs +43 -0
  154. package/dist/runtime/nativeComponents/scrollView/position.mjs.map +1 -0
  155. package/dist/runtime/nativeComponents/slider/helpers.mjs +1 -2
  156. package/dist/runtime/nativeComponents/slider/index.mjs +1 -2
  157. package/dist/runtime/nativeComponents/slider/style.mjs +1 -2
  158. package/dist/runtime/nativeComponents/style.mjs +1 -2
  159. package/dist/runtime/nativeComponents/swiper/helpers.mjs +1 -2
  160. package/dist/runtime/nativeComponents/swiper/index.mjs +1 -2
  161. package/dist/runtime/nativeComponents/swiper/item.mjs +1 -2
  162. package/dist/runtime/nativeComponents/swiper/style.mjs +1 -2
  163. package/dist/runtime/nativeComponents/switch.d.mts +0 -2
  164. package/dist/runtime/nativeComponents/switch.mjs +1 -2
  165. package/dist/runtime/nativeComponents/textarea.d.mts +0 -2
  166. package/dist/runtime/nativeComponents/textarea.mjs +1 -2
  167. package/dist/runtime/nativeComponents/video/helpers.d.mts +0 -2
  168. package/dist/runtime/nativeComponents/video/helpers.mjs +1 -2
  169. package/dist/runtime/nativeComponents/video/index.mjs +1 -2
  170. package/dist/runtime/nativeComponents/video/style.mjs +1 -2
  171. package/dist/runtime/navigationBar/index.d.mts +0 -2
  172. package/dist/runtime/navigationBar/index.mjs +1 -2
  173. package/dist/runtime/navigationBar/style.mjs +1 -2
  174. package/dist/runtime/pageLayout.d.mts +1 -2
  175. package/dist/runtime/pageLayout.mjs +1 -2
  176. package/dist/runtime/polyfill/ad.mjs +1 -2
  177. package/dist/runtime/polyfill/animation.mjs +1 -2
  178. package/dist/runtime/polyfill/appState.mjs +1 -2
  179. package/dist/runtime/polyfill/async.d.mts +0 -2
  180. package/dist/runtime/polyfill/async.mjs +1 -2
  181. package/dist/runtime/polyfill/auth.mjs +1 -2
  182. package/dist/runtime/polyfill/authApi.mjs +1 -2
  183. package/dist/runtime/polyfill/background.mjs +1 -2
  184. package/dist/runtime/polyfill/canvasContext.mjs +1 -2
  185. package/dist/runtime/polyfill/capability.mjs +1 -2
  186. package/dist/runtime/polyfill/cloud.mjs +1 -2
  187. package/dist/runtime/polyfill/device.mjs +1 -2
  188. package/dist/runtime/polyfill/deviceApi.mjs +1 -2
  189. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +0 -2
  190. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +1 -2
  191. package/dist/runtime/polyfill/eventBus.mjs +1 -2
  192. package/dist/runtime/polyfill/filePicker.mjs +1 -2
  193. package/dist/runtime/polyfill/fileSystemManager.mjs +1 -2
  194. package/dist/runtime/polyfill/files.mjs +1 -2
  195. package/dist/runtime/polyfill/font.mjs +1 -2
  196. package/dist/runtime/polyfill/index.d.mts +4 -4
  197. package/dist/runtime/polyfill/index.mjs +12 -5
  198. package/dist/runtime/polyfill/index.mjs.map +1 -1
  199. package/dist/runtime/polyfill/interaction.mjs +1 -2
  200. package/dist/runtime/polyfill/interactionApi.mjs +1 -2
  201. package/dist/runtime/polyfill/intersectionObserver.mjs +4 -4
  202. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -1
  203. package/dist/runtime/polyfill/lifecycleEvents.d.mts +12 -0
  204. package/dist/runtime/polyfill/lifecycleEvents.mjs +67 -0
  205. package/dist/runtime/polyfill/lifecycleEvents.mjs.map +1 -0
  206. package/dist/runtime/polyfill/locale.mjs +1 -2
  207. package/dist/runtime/polyfill/location.mjs +1 -2
  208. package/dist/runtime/polyfill/locationApi.mjs +1 -2
  209. package/dist/runtime/polyfill/mediaActions.mjs +1 -2
  210. package/dist/runtime/polyfill/mediaApi/file.mjs +1 -2
  211. package/dist/runtime/polyfill/mediaApi/info.mjs +1 -2
  212. package/dist/runtime/polyfill/mediaApi/picker.mjs +1 -2
  213. package/dist/runtime/polyfill/mediaApi/preview.mjs +1 -2
  214. package/dist/runtime/polyfill/mediaApi/process.mjs +1 -2
  215. package/dist/runtime/polyfill/mediaInfo.mjs +1 -2
  216. package/dist/runtime/polyfill/mediaPicker.mjs +1 -2
  217. package/dist/runtime/polyfill/mediaProcess.mjs +1 -2
  218. package/dist/runtime/polyfill/menuApi.mjs +5 -3
  219. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  220. package/dist/runtime/polyfill/navigationBarRuntime.mjs +1 -2
  221. package/dist/runtime/polyfill/network/request.mjs +1 -2
  222. package/dist/runtime/polyfill/network/requestBridge.mjs +1 -2
  223. package/dist/runtime/polyfill/network/status.mjs +1 -2
  224. package/dist/runtime/polyfill/platformApi.mjs +1 -2
  225. package/dist/runtime/polyfill/platformRuntime.mjs +1 -2
  226. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +1 -2
  227. package/dist/runtime/polyfill/routeRuntime/dom.mjs +1 -2
  228. package/dist/runtime/polyfill/routeRuntime/events.d.mts +0 -2
  229. package/dist/runtime/polyfill/routeRuntime/events.mjs +1 -2
  230. package/dist/runtime/polyfill/routeRuntime/history.d.mts +0 -2
  231. package/dist/runtime/polyfill/routeRuntime/history.mjs +1 -2
  232. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +1 -2
  233. package/dist/runtime/polyfill/routeRuntime/options.d.mts +1 -2
  234. package/dist/runtime/polyfill/routeRuntime/options.mjs +1 -2
  235. package/dist/runtime/polyfill/routeRuntime/result.mjs +1 -2
  236. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +37 -6
  237. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -1
  238. package/dist/runtime/polyfill/routeRuntime/stack.mjs +1 -2
  239. package/dist/runtime/polyfill/routeRuntime/url.mjs +1 -2
  240. package/dist/runtime/polyfill/routeRuntime.d.mts +2 -2
  241. package/dist/runtime/polyfill/routeRuntime.mjs +14 -5
  242. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  243. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +1 -2
  244. package/dist/runtime/polyfill/runtimeDataApi.d.mts +0 -2
  245. package/dist/runtime/polyfill/runtimeDataApi.mjs +1 -2
  246. package/dist/runtime/polyfill/runtimeInfra.mjs +1 -2
  247. package/dist/runtime/polyfill/runtimeOps.mjs +1 -2
  248. package/dist/runtime/polyfill/selectorQuery.mjs +3 -3
  249. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  250. package/dist/runtime/polyfill/storage.mjs +1 -2
  251. package/dist/runtime/polyfill/storageAsync.mjs +1 -2
  252. package/dist/runtime/polyfill/subscribe.mjs +1 -2
  253. package/dist/runtime/polyfill/system.mjs +1 -2
  254. package/dist/runtime/polyfill/systemApi.mjs +1 -2
  255. package/dist/runtime/polyfill/types/base.d.mts +0 -2
  256. package/dist/runtime/polyfill/types/common.d.mts +0 -2
  257. package/dist/runtime/polyfill/types/lifecycle.d.mts +12 -0
  258. package/dist/runtime/polyfill/types/locationRuntime.d.mts +0 -2
  259. package/dist/runtime/polyfill/types/mediaAuth.d.mts +0 -2
  260. package/dist/runtime/polyfill/types/platformRuntime.d.mts +0 -2
  261. package/dist/runtime/polyfill/types/systemAuth.d.mts +0 -2
  262. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +0 -2
  263. package/dist/runtime/polyfill/ui.mjs +1 -2
  264. package/dist/runtime/polyfill/uiFeedback.mjs +19 -5
  265. package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -1
  266. package/dist/runtime/polyfill/uiMediaApi.d.mts +8 -2
  267. package/dist/runtime/polyfill/uiMediaApi.mjs +20 -5
  268. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  269. package/dist/runtime/polyfill/videoContext.mjs +1 -2
  270. package/dist/runtime/polyfill/vkSession.mjs +1 -2
  271. package/dist/runtime/polyfill/windowResize.mjs +1 -2
  272. package/dist/runtime/polyfill/worker.mjs +1 -2
  273. package/dist/runtime/polyfill.d.mts +4 -2
  274. package/dist/runtime/renderContext.d.mts +0 -2
  275. package/dist/runtime/renderContext.mjs +5 -4
  276. package/dist/runtime/renderContext.mjs.map +1 -1
  277. package/dist/runtime/rpx.d.mts +0 -2
  278. package/dist/runtime/rpx.mjs +6 -6
  279. package/dist/runtime/rpx.mjs.map +1 -1
  280. package/dist/runtime/seo/index.d.mts +0 -2
  281. package/dist/runtime/seo/index.mjs +1 -2
  282. package/dist/runtime/style.d.mts +0 -2
  283. package/dist/runtime/style.mjs +1 -2
  284. package/dist/runtime/template.d.mts +0 -2
  285. package/dist/runtime/utils/object.mjs +1 -2
  286. package/dist/runtime/viewport/index.d.mts +0 -2
  287. package/dist/runtime/viewport/index.mjs +1 -2
  288. package/dist/runtime/viewport/style.mjs +2 -2
  289. package/dist/runtime/viewport/style.mjs.map +1 -1
  290. package/dist/runtime/viewport/types.d.mts +0 -2
  291. package/dist/runtime/warning.d.mts +0 -2
  292. package/dist/runtime/warning.mjs +1 -2
  293. package/dist/runtime/wevu.d.mts +1 -2
  294. package/dist/runtime/wevu.mjs +1 -2
  295. package/dist/shared/nativeComponents.mjs +10 -3
  296. package/dist/shared/nativeComponents.mjs.map +1 -1
  297. package/dist/shared/slugify.mjs +1 -2
  298. package/dist/shared/styleUnits/options.d.mts +24 -0
  299. package/dist/shared/styleUnits/options.mjs +13 -0
  300. package/dist/shared/styleUnits/options.mjs.map +1 -0
  301. package/dist/shared/styleUnits/value.mjs +63 -0
  302. package/dist/shared/styleUnits/value.mjs.map +1 -0
  303. package/dist/shared/tabBar.d.mts +0 -2
  304. package/dist/shared/tabBar.mjs +1 -2
  305. package/dist/shared/wxml.mjs +1 -2
  306. package/package.json +15 -13
  307. package/dist/runtime/nativeComponents/richText/helpers.mjs +0 -230
  308. package/dist/runtime/nativeComponents/richText/helpers.mjs.map +0 -1
  309. package/dist/runtime/nativeComponents/scrollView.mjs +0 -88
  310. package/dist/runtime/nativeComponents/scrollView.mjs.map +0 -1
@@ -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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AY,GAAG,cAAc,OAAO,MAAM;GAEjD,KAAK,wBAAwB;GAC7B,IAAI,CAAC,KAAK,aAAa;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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FLAG_ATTRIBUTE_PREFIXES, decodeEventAttributeName } from "./constants.mjs";
2
2
  import { listenRuntimeEvent, nameRuntimeEventHandler } 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,OAA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nB,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
+ {"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,OAA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QAAQ;GACxB,IAAI,CAAC,SACH;GAEF,MAAM,mBAAmB,UAAU,MAAM,cAAc,MAAM;GAC7D,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
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/observers.ts
1
+ // src/runtime/component/observers.ts
2
2
  function normalizeObserverPattern(pattern) {
3
3
  return pattern.split(",").map((item) => item.trim()).filter(Boolean);
4
4
  }
@@ -31,6 +31,5 @@ function runComponentObservers(component, instance, changedKeys, previousPropert
31
31
  }
32
32
  }
33
33
 
34
- //#endregion
35
34
  export { runComponentObservers };
36
35
  //# sourceMappingURL=observers.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { hasOwn } from "../utils/object.mjs";
2
2
 
3
- //#region src/runtime/component/publicInstance.ts
3
+ // src/runtime/component/publicInstance.ts
4
4
  const componentPublicInstanceTargets = /* @__PURE__ */ new WeakMap();
5
5
  function resolveComponentPublicInstanceTarget(value) {
6
6
  if (!value || typeof value !== "object") return;
@@ -47,6 +47,5 @@ function createComponentPublicInstance(target, runtimePrototype, resolveComponen
47
47
  return publicInstance;
48
48
  }
49
49
 
50
- //#endregion
51
50
  export { createComponentPublicInstance, resolveComponentPublicInstanceTarget };
52
51
  //# sourceMappingURL=publicInstance.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { slugify } from "../../shared/slugify.mjs";
2
2
  import { posix } from "pathe";
3
3
 
4
- //#region src/runtime/component/relations.ts
4
+ // src/runtime/component/relations.ts
5
5
  function resolveComposedParent(node) {
6
6
  const assignedSlot = node.assignedSlot;
7
7
  if (assignedSlot) return assignedSlot;
@@ -31,6 +31,5 @@ function resolveRelationNodes(instance, componentId, relationPath, type) {
31
31
  return [];
32
32
  }
33
33
 
34
- //#endregion
35
34
  export { resolveRelationNodes };
36
35
  //# sourceMappingURL=relations.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/slots.ts
1
+ // src/runtime/component/slots.ts
2
2
  function resolveSlotNames(value) {
3
3
  if (Array.isArray(value)) return new Set(value.filter((name) => typeof name === "string" && name.length > 0));
4
4
  if (!value || typeof value !== "object") return /* @__PURE__ */ new Set();
@@ -19,6 +19,5 @@ function createWebSlotsProxy(resolveValue) {
19
19
  });
20
20
  }
21
21
 
22
- //#endregion
23
22
  export { createWebSlotsProxy };
24
23
  //# sourceMappingURL=slots.mjs.map
@@ -2,7 +2,7 @@ import { hasOwn } from "../utils/object.mjs";
2
2
  import { cloneValue, hyphenate } from "./utils.mjs";
3
3
  import { normalizeBehaviors } from "./behavior.mjs";
4
4
 
5
- //#region src/runtime/component/state.ts
5
+ // src/runtime/component/state.ts
6
6
  function normalizePropertyDeclaration(declaration) {
7
7
  if (declaration === null || typeof declaration === "function") return { type: declaration };
8
8
  return declaration;
@@ -76,6 +76,5 @@ function updateComponentRuntimeState(state, options) {
76
76
  };
77
77
  }
78
78
 
79
- //#endregion
80
79
  export { createComponentRuntimeState, updateComponentRuntimeState };
81
80
  //# sourceMappingURL=state.mjs.map
@@ -1,5 +1,4 @@
1
1
  import { TemplateRenderer } from "../template.mjs";
2
- //#region src/runtime/component/types.d.ts
3
2
  export type DataRecord = Record<string, any>;
4
3
  export interface PropertyOption {
5
4
  type?: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null;
@@ -75,5 +74,4 @@ export interface ComponentPublicInstance extends HTMLElement {
75
74
  export type ComponentConstructor = CustomElementConstructor & {
76
75
  __weappUpdate?: (options: DefineComponentOptions) => void;
77
76
  };
78
- //#endregion
79
77
  //# sourceMappingURL=types.d.mts.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/utils.ts
1
+ // src/runtime/component/utils.ts
2
2
  const ARRAY_INDEX_PATH_RE = /\[(\d+)\]/g;
3
3
  const ARRAY_INDEX_SEGMENT_RE = /^\d+$/;
4
4
  const UNSAFE_PATH_SEGMENTS = /* @__PURE__ */ new Set([
@@ -89,6 +89,5 @@ function coerceValue(value, type) {
89
89
  return value;
90
90
  }
91
91
 
92
- //#endregion
93
92
  export { assignDataPath, cloneCommittedValue, cloneValue, coerceValue, hyphenate, parseDataPath, resolveDataPath, toCamelCase };
94
93
  //# sourceMappingURL=utils.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/component/virtualHost.ts
1
+ // src/runtime/component/virtualHost.ts
2
2
  function parseClassTokens(value) {
3
3
  return new Set((value ?? "").split(/\s+/).filter(Boolean));
4
4
  }
@@ -78,6 +78,5 @@ function syncVirtualHostParts(root, previousRootElement, ownedPartTokens) {
78
78
  return rootElement;
79
79
  }
80
80
 
81
- //#endregion
82
81
  export { clearVirtualHostClasses, clearVirtualHostParts, syncVirtualHostClasses, syncVirtualHostParts };
83
82
  //# sourceMappingURL=virtualHost.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { EVENT_KIND_ALIAS } from "../shared/wxml.mjs";
2
2
 
3
- //#region src/runtime/componentEvents.ts
3
+ // src/runtime/componentEvents.ts
4
4
  const componentElements = /* @__PURE__ */ new WeakSet();
5
5
  const componentEvents = /* @__PURE__ */ new WeakSet();
6
6
  const handlerNames = /* @__PURE__ */ new WeakMap();
@@ -32,6 +32,5 @@ function listenRuntimeEvent(element, name, listener, capture = false) {
32
32
  };
33
33
  }
34
34
 
35
- //#endregion
36
35
  export { listenRuntimeEvent, markComponentEvent, nameRuntimeEventHandler, registerComponentEventTarget };
37
36
  //# sourceMappingURL=componentEvents.mjs.map
@@ -0,0 +1,49 @@
1
+ // src/runtime/dataset.ts
2
+ /** DOM 属性用于字符串查询,运行时 dataset 保留完整绑定表达式的值类型。 */
3
+ const runtimeDatasetValues = /* @__PURE__ */ new WeakMap();
4
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
5
+ const ASCII_UPPERCASE_RE = /[A-Z]/g;
6
+ const DATASET_ATTRIBUTE_RE = /^data-[^A-Z]*$/;
7
+ /** 与 setAttribute 保持一致,仅折叠 HTML 文档中 HTML 元素的 ASCII 大写。 */
8
+ function normalizeDatasetAttributeName(element, attributeName) {
9
+ return element.namespaceURI === HTML_NAMESPACE && element.ownerDocument.contentType === "text/html" ? attributeName.replace(ASCII_UPPERCASE_RE, (character) => character.toLowerCase()) : attributeName;
10
+ }
11
+ /** 只转换连字符后的 ASCII 小写字母,与 DOMStringMap 和小程序命名规则一致。 */
12
+ function toDatasetKey(attributeName) {
13
+ return attributeName.slice(5).replace(/-([a-z])/g, (_, char) => char.toUpperCase());
14
+ }
15
+ /** 保存本次绑定值,包括数字、布尔值及 null / undefined。 */
16
+ function storeRuntimeDataset(element, attributeName, value) {
17
+ const name = normalizeDatasetAttributeName(element, attributeName);
18
+ if (!DATASET_ATTRIBUTE_RE.test(name)) return;
19
+ const values = runtimeDatasetValues.get(element) ?? /* @__PURE__ */ new Map();
20
+ values.set(name, value);
21
+ runtimeDatasetValues.set(element, values);
22
+ }
23
+ /** 释放指定绑定,不影响同一元素上其他拥有者的值。 */
24
+ function clearRuntimeDataset(element, attributeName) {
25
+ const values = runtimeDatasetValues.get(element);
26
+ values?.delete(normalizeDatasetAttributeName(element, attributeName));
27
+ if (values?.size === 0) runtimeDatasetValues.delete(element);
28
+ }
29
+ /** 返回独立的 dataset 容器,对象和数组仍使用当前 Web 绑定值。 */
30
+ function readRuntimeDataset(element) {
31
+ const result = { ...element?.dataset };
32
+ const values = element ? runtimeDatasetValues.get(element) : void 0;
33
+ if (element && values) for (const [attributeName, value] of values) {
34
+ if (element.getAttribute(attributeName) !== String(value ?? "")) {
35
+ clearRuntimeDataset(element, attributeName);
36
+ continue;
37
+ }
38
+ Object.defineProperty(result, toDatasetKey(attributeName), {
39
+ configurable: true,
40
+ enumerable: true,
41
+ value,
42
+ writable: true
43
+ });
44
+ }
45
+ return result;
46
+ }
47
+
48
+ export { clearRuntimeDataset, readRuntimeDataset, storeRuntimeDataset, toDatasetKey };
49
+ //# sourceMappingURL=dataset.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataset.mjs","names":[],"sources":["../../src/runtime/dataset.ts"],"sourcesContent":["/** DOM 属性用于字符串查询,运行时 dataset 保留完整绑定表达式的值类型。 */\nconst runtimeDatasetValues = new WeakMap<Element, Map<string, unknown>>()\nconst HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'\nconst ASCII_UPPERCASE_RE = /[A-Z]/g\nconst DATASET_ATTRIBUTE_RE = /^data-[^A-Z]*$/\n\n/** 与 setAttribute 保持一致,仅折叠 HTML 文档中 HTML 元素的 ASCII 大写。 */\nfunction normalizeDatasetAttributeName(element: Element, attributeName: string) {\n return element.namespaceURI === HTML_NAMESPACE && element.ownerDocument.contentType === 'text/html'\n ? attributeName.replace(ASCII_UPPERCASE_RE, character => character.toLowerCase())\n : attributeName\n}\n\n/** 只转换连字符后的 ASCII 小写字母,与 DOMStringMap 和小程序命名规则一致。 */\nexport function toDatasetKey(attributeName: string) {\n return attributeName.slice(5).replace(/-([a-z])/g, (_, char: string) => char.toUpperCase())\n}\n\n/** 保存本次绑定值,包括数字、布尔值及 null / undefined。 */\nexport function storeRuntimeDataset(element: Element, attributeName: string, value: unknown) {\n const name = normalizeDatasetAttributeName(element, attributeName)\n // SVG/XML 保留属性大小写;含 ASCII 大写的 data-* 不属于 DOMStringMap。\n if (!DATASET_ATTRIBUTE_RE.test(name)) {\n return\n }\n const values = runtimeDatasetValues.get(element) ?? new Map<string, unknown>()\n values.set(name, value)\n runtimeDatasetValues.set(element, values)\n}\n\n/** 释放指定绑定,不影响同一元素上其他拥有者的值。 */\nexport function clearRuntimeDataset(element: Element, attributeName: string) {\n const values = runtimeDatasetValues.get(element)\n values?.delete(normalizeDatasetAttributeName(element, attributeName))\n if (values?.size === 0) {\n runtimeDatasetValues.delete(element)\n }\n}\n\n/** 返回独立的 dataset 容器,对象和数组仍使用当前 Web 绑定值。 */\nexport function readRuntimeDataset(element: Element | null | undefined): Record<string, unknown> {\n const result: Record<string, unknown> = { ...(element as HTMLElement | null | undefined)?.dataset }\n const values = element ? runtimeDatasetValues.get(element) : undefined\n if (element && values) {\n for (const [attributeName, value] of values) {\n // 显式 DOM 修改优先,避免旁路值遮蔽业务直接更新或移除的属性。\n if (element.getAttribute(attributeName) !== String(value ?? '')) {\n clearRuntimeDataset(element, attributeName)\n continue\n }\n Object.defineProperty(result, toDatasetKey(attributeName), {\n configurable: true,\n enumerable: true,\n value,\n writable: true,\n })\n }\n }\n return result\n}\n"],"mappings":";;AACA,MAAM,uCAAuB,IAAI,QAAuC;AACxE,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;;AAG7B,SAAS,8BAA8B,SAAkB,eAAuB;CAC9E,OAAO,QAAQ,iBAAiB,kBAAkB,QAAQ,cAAc,gBAAgB,cACpF,cAAc,QAAQ,qBAAoB,cAAa,UAAU,YAAY,CAAC,IAC9E;AACN;;AAGA,SAAgB,aAAa,eAAuB;CAClD,OAAO,cAAc,MAAM,CAAC,CAAC,CAAC,QAAQ,cAAc,GAAG,SAAiB,KAAK,YAAY,CAAC;AAC5F;;AAGA,SAAgB,oBAAoB,SAAkB,eAAuB,OAAgB;CAC3F,MAAM,OAAO,8BAA8B,SAAS,aAAa;CAEjE,IAAI,CAAC,qBAAqB,KAAK,IAAI,GACjC;CAEF,MAAM,SAAS,qBAAqB,IAAI,OAAO,qBAAK,IAAI,IAAqB;CAC7E,OAAO,IAAI,MAAM,KAAK;CACtB,qBAAqB,IAAI,SAAS,MAAM;AAC1C;;AAGA,SAAgB,oBAAoB,SAAkB,eAAuB;CAC3E,MAAM,SAAS,qBAAqB,IAAI,OAAO;CAC/C,QAAQ,OAAO,8BAA8B,SAAS,aAAa,CAAC;CACpE,IAAI,QAAQ,SAAS,GACnB,qBAAqB,OAAO,OAAO;AAEvC;;AAGA,SAAgB,mBAAmB,SAA8D;CAC/F,MAAM,SAAkC,EAAE,GAAI,SAA4C,QAAQ;CAClG,MAAM,SAAS,UAAU,qBAAqB,IAAI,OAAO,IAAI;CAC7D,IAAI,WAAW,QACb,KAAK,MAAM,CAAC,eAAe,UAAU,QAAQ;EAE3C,IAAI,QAAQ,aAAa,aAAa,MAAM,OAAO,SAAS,EAAE,GAAG;GAC/D,oBAAoB,SAAS,aAAa;GAC1C;EACF;EACA,OAAO,eAAe,QAAQ,aAAa,aAAa,GAAG;GACzD,cAAc;GACd,YAAY;GACZ;GACA,UAAU;EACZ,CAAC;CACH;CAEF,OAAO;AACT"}
@@ -0,0 +1,13 @@
1
+ import { AsyncDirective, ElementPart, PartInfo } from "lit/async-directive.js";
2
+ /** ElementPart 不提交返回值,绑定指令显式维护属性与对应的运行时值。 */
3
+ declare class RuntimeDatasetBindingDirective extends AsyncDirective {
4
+ #private;
5
+ constructor(partInfo: PartInfo);
6
+ render(_attributeName: string, _value: unknown): symbol;
7
+ update(part: ElementPart, [attributeName, value]: Parameters<this['render']>): symbol;
8
+ protected disconnected(): void;
9
+ protected reconnected(): void;
10
+ }
11
+ export declare const bindRuntimeDataset: (_attributeName: string, _value: unknown) => import("lit/async-directive.js").DirectiveResult<typeof RuntimeDatasetBindingDirective>;
12
+ export {};
13
+ //# sourceMappingURL=datasetBinding.d.mts.map
@@ -0,0 +1,40 @@
1
+ import { clearRuntimeDataset, storeRuntimeDataset } from "./dataset.mjs";
2
+ import { noChange } from "lit";
3
+ import { AsyncDirective, PartType, directive } from "lit/async-directive.js";
4
+
5
+ // src/runtime/datasetBinding.ts
6
+ /** ElementPart 不提交返回值,绑定指令显式维护属性与对应的运行时值。 */
7
+ var RuntimeDatasetBindingDirective = class extends AsyncDirective {
8
+ #element;
9
+ #attributeName;
10
+ #value;
11
+ constructor(partInfo) {
12
+ super(partInfo);
13
+ if (partInfo.type !== PartType.ELEMENT) throw new TypeError("Runtime dataset bindings must be used in an element expression.");
14
+ }
15
+ render(_attributeName, _value) {
16
+ return noChange;
17
+ }
18
+ update(part, [attributeName, value]) {
19
+ if (this.#element && this.#attributeName && (part.element !== this.#element || attributeName !== this.#attributeName)) {
20
+ clearRuntimeDataset(this.#element, this.#attributeName);
21
+ this.#element.removeAttribute(this.#attributeName);
22
+ }
23
+ this.#element = part.element;
24
+ this.#attributeName = attributeName;
25
+ this.#value = value;
26
+ part.element.setAttribute(attributeName, String(value ?? ""));
27
+ if (this.isConnected) storeRuntimeDataset(part.element, attributeName, value);
28
+ return noChange;
29
+ }
30
+ disconnected() {
31
+ if (this.#element && this.#attributeName) clearRuntimeDataset(this.#element, this.#attributeName);
32
+ }
33
+ reconnected() {
34
+ if (this.#element && this.#attributeName) storeRuntimeDataset(this.#element, this.#attributeName, this.#value);
35
+ }
36
+ };
37
+ const bindRuntimeDataset = directive(RuntimeDatasetBindingDirective);
38
+
39
+ export { bindRuntimeDataset };
40
+ //# sourceMappingURL=datasetBinding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasetBinding.mjs","names":[],"sources":["../../src/runtime/datasetBinding.ts"],"sourcesContent":["import type { ElementPart, PartInfo } from 'lit/async-directive.js'\nimport { noChange } from 'lit'\nimport { AsyncDirective, directive, PartType } from 'lit/async-directive.js'\nimport { clearRuntimeDataset, storeRuntimeDataset } from './dataset'\n\n/** ElementPart 不提交返回值,绑定指令显式维护属性与对应的运行时值。 */\nclass RuntimeDatasetBindingDirective extends AsyncDirective {\n #element?: Element\n #attributeName?: string\n #value: unknown\n\n constructor(partInfo: PartInfo) {\n super(partInfo)\n if (partInfo.type !== PartType.ELEMENT) {\n throw new TypeError('Runtime dataset bindings must be used in an element expression.')\n }\n }\n\n render(_attributeName: string, _value: unknown) {\n return noChange\n }\n\n update(part: ElementPart, [attributeName, value]: Parameters<this['render']>) {\n if (this.#element && this.#attributeName && (part.element !== this.#element || attributeName !== this.#attributeName)) {\n clearRuntimeDataset(this.#element, this.#attributeName)\n this.#element.removeAttribute(this.#attributeName)\n }\n this.#element = part.element\n this.#attributeName = attributeName\n this.#value = value\n part.element.setAttribute(attributeName, String(value ?? ''))\n if (this.isConnected) {\n storeRuntimeDataset(part.element, attributeName, value)\n }\n return noChange\n }\n\n protected disconnected() {\n if (this.#element && this.#attributeName) {\n clearRuntimeDataset(this.#element, this.#attributeName)\n }\n }\n\n protected reconnected() {\n if (this.#element && this.#attributeName) {\n storeRuntimeDataset(this.#element, this.#attributeName, this.#value)\n }\n }\n}\n\nexport const bindRuntimeDataset = directive(RuntimeDatasetBindingDirective)\n"],"mappings":";;;;;;AAMA,IAAM,iCAAN,cAA6C,eAAe;CAC1D;CACA;CACA;CAEA,YAAY,UAAoB;EAC9B,MAAM,QAAQ;EACd,IAAI,SAAS,SAAS,SAAS,SAC7B,MAAM,IAAI,UAAU,iEAAiE;CAEzF;CAEA,OAAO,gBAAwB,QAAiB;EAC9C,OAAO;CACT;CAEA,OAAO,MAAmB,CAAC,eAAe,QAAoC;EAC5E,IAAI,KAAK,YAAY,KAAK,mBAAmB,KAAK,YAAY,KAAK,YAAY,kBAAkB,KAAK,iBAAiB;GACrH,oBAAoB,KAAK,UAAU,KAAK,cAAc;GACtD,KAAK,SAAS,gBAAgB,KAAK,cAAc;EACnD;EACA,KAAK,WAAW,KAAK;EACrB,KAAK,iBAAiB;EACtB,KAAK,SAAS;EACd,KAAK,QAAQ,aAAa,eAAe,OAAO,SAAS,EAAE,CAAC;EAC5D,IAAI,KAAK,aACP,oBAAoB,KAAK,SAAS,eAAe,KAAK;EAExD,OAAO;CACT;CAEA,AAAU,eAAe;EACvB,IAAI,KAAK,YAAY,KAAK,gBACxB,oBAAoB,KAAK,UAAU,KAAK,cAAc;CAE1D;CAEA,AAAU,cAAc;EACtB,IAAI,KAAK,YAAY,KAAK,gBACxB,oBAAoB,KAAK,UAAU,KAAK,gBAAgB,KAAK,MAAM;CAEvE;AACF;AAEA,MAAa,qBAAqB,UAAU,8BAA8B"}
@@ -1,5 +1,4 @@
1
1
  import { AsyncDirective, ElementPart, PartInfo } from "lit/async-directive.js";
2
- //#region src/runtime/eventBinding.d.ts
3
2
  interface RuntimeEventFlags {
4
3
  capture?: boolean;
5
4
  }
@@ -12,5 +11,5 @@ declare class RuntimeEventBindingDirective extends AsyncDirective {
12
11
  protected reconnected(): void;
13
12
  }
14
13
  export declare const bindRuntimeEvent: (_eventName: string, _listener: EventListener, _flags?: RuntimeEventFlags | undefined) => import("lit/async-directive.js").DirectiveResult<typeof RuntimeEventBindingDirective>;
15
- //#endregion
14
+ export {};
16
15
  //# sourceMappingURL=eventBinding.d.mts.map
@@ -2,7 +2,7 @@ import { listenRuntimeEvent } from "./componentEvents.mjs";
2
2
  import { nothing } from "lit";
3
3
  import { AsyncDirective, PartType, directive } from "lit/async-directive.js";
4
4
 
5
- //#region src/runtime/eventBinding.ts
5
+ // src/runtime/eventBinding.ts
6
6
  var RuntimeEventBindingDirective = class extends AsyncDirective {
7
7
  #capture = false;
8
8
  #element;
@@ -49,6 +49,5 @@ var RuntimeEventBindingDirective = class extends AsyncDirective {
49
49
  };
50
50
  const bindRuntimeEvent = directive(RuntimeEventBindingDirective);
51
51
 
52
- //#endregion
53
52
  export { bindRuntimeEvent };
54
53
  //# sourceMappingURL=eventBinding.mjs.map
@@ -1,6 +1,4 @@
1
- //#region src/runtime/execution.d.ts
2
1
  export type RuntimeExecutionMode = 'compat' | 'safe' | 'strict';
3
2
  export declare function getRuntimeExecutionMode(): RuntimeExecutionMode;
4
3
  export declare function setRuntimeExecutionMode(mode?: RuntimeExecutionMode | string): void;
5
- //#endregion
6
4
  //# sourceMappingURL=execution.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { emitRuntimeWarning } from "./warning.mjs";
2
2
 
3
- //#region src/runtime/execution.ts
3
+ // src/runtime/execution.ts
4
4
  let currentRuntimeExecutionMode = "compat";
5
5
  const warnedMessages = /* @__PURE__ */ new Set();
6
6
  function isRuntimeExecutionMode(value) {
@@ -32,6 +32,5 @@ function setRuntimeExecutionMode(mode) {
32
32
  currentRuntimeExecutionMode = "compat";
33
33
  }
34
34
 
35
- //#endregion
36
35
  export { getRuntimeExecutionMode, setRuntimeExecutionMode, warnRuntimeExecutionOnce };
37
36
  //# sourceMappingURL=execution.mjs.map
@@ -1,5 +1,4 @@
1
1
  import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./types.mjs";
2
- //#region src/runtime/host/index.d.ts
3
2
  export declare function getWebRuntimeHost(): Readonly<WebRuntimeHost>;
4
3
  export declare function setWebRuntimeHost(host?: WebRuntimeHost): void;
5
4
  export declare function resetWebRuntimeHost(): void;
@@ -8,6 +7,5 @@ export declare function getRuntimeStorage(): WebRuntimeStorage | undefined;
8
7
  export declare function getRuntimeClipboard(): WebRuntimeClipboard | undefined;
9
8
  export declare function getRuntimeDialogs(): WebRuntimeDialogs;
10
9
  export declare function openRuntimeUrl(url?: string, target?: string, features?: string): unknown;
11
- //#endregion
12
10
  export type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage };
13
11
  //# sourceMappingURL=index.d.mts.map