@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,230 +0,0 @@
1
- import { parseDocument } from "htmlparser2";
2
-
3
- //#region src/runtime/nativeComponents/richText/helpers.ts
4
- const ALLOWED_TAGS = /* @__PURE__ */ new Set([
5
- "a",
6
- "abbr",
7
- "address",
8
- "article",
9
- "aside",
10
- "b",
11
- "bdi",
12
- "bdo",
13
- "big",
14
- "blockquote",
15
- "br",
16
- "caption",
17
- "center",
18
- "cite",
19
- "code",
20
- "col",
21
- "colgroup",
22
- "dd",
23
- "del",
24
- "div",
25
- "dl",
26
- "dt",
27
- "em",
28
- "fieldset",
29
- "font",
30
- "h1",
31
- "h2",
32
- "h3",
33
- "h4",
34
- "h5",
35
- "h6",
36
- "header",
37
- "hr",
38
- "i",
39
- "img",
40
- "ins",
41
- "label",
42
- "legend",
43
- "li",
44
- "mark",
45
- "ol",
46
- "p",
47
- "pre",
48
- "q",
49
- "rt",
50
- "ruby",
51
- "s",
52
- "section",
53
- "small",
54
- "span",
55
- "strong",
56
- "sub",
57
- "sup",
58
- "table",
59
- "tbody",
60
- "td",
61
- "tfoot",
62
- "th",
63
- "thead",
64
- "tr",
65
- "tt",
66
- "u",
67
- "ul"
68
- ]);
69
- const ALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
70
- "abbr",
71
- "align",
72
- "alt",
73
- "axis",
74
- "bgcolor",
75
- "border",
76
- "cellpadding",
77
- "cellspacing",
78
- "class",
79
- "colspan",
80
- "dir",
81
- "height",
82
- "href",
83
- "id",
84
- "lang",
85
- "rowspan",
86
- "scope",
87
- "span",
88
- "start",
89
- "style",
90
- "summary",
91
- "target",
92
- "title",
93
- "type",
94
- "valign",
95
- "width"
96
- ]);
97
- const URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src"]);
98
- const ALLOWED_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
99
- "background",
100
- "background-color",
101
- "border",
102
- "border-bottom",
103
- "border-color",
104
- "border-left",
105
- "border-radius",
106
- "border-right",
107
- "border-style",
108
- "border-top",
109
- "border-width",
110
- "color",
111
- "display",
112
- "font-family",
113
- "font-size",
114
- "font-style",
115
- "font-weight",
116
- "height",
117
- "letter-spacing",
118
- "line-height",
119
- "margin",
120
- "margin-bottom",
121
- "margin-left",
122
- "margin-right",
123
- "margin-top",
124
- "max-height",
125
- "max-width",
126
- "min-height",
127
- "min-width",
128
- "opacity",
129
- "overflow",
130
- "padding",
131
- "padding-bottom",
132
- "padding-left",
133
- "padding-right",
134
- "padding-top",
135
- "text-align",
136
- "text-decoration",
137
- "text-indent",
138
- "text-overflow",
139
- "text-transform",
140
- "vertical-align",
141
- "white-space",
142
- "width",
143
- "word-break",
144
- "word-wrap"
145
- ]);
146
- function isRecord(value) {
147
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
148
- }
149
- function isSafeUrl(value, attribute) {
150
- const normalized = Array.from(value).filter((character) => character.charCodeAt(0) > 32).join("").toLowerCase();
151
- if (!normalized || normalized.startsWith("#") || normalized.startsWith("/") || normalized.startsWith("./") || normalized.startsWith("../")) return true;
152
- if (/^(?:https?:|mailto:|tel:)/.test(normalized)) return true;
153
- return attribute === "src" && /^data:image\/(?:gif|jpe?g|png|webp);base64,/.test(normalized);
154
- }
155
- function isSafeStyleValue(value) {
156
- const normalized = value.toLowerCase().replace(/\s+/g, "");
157
- return !normalized.includes("url(") && !normalized.includes("expression(") && !normalized.includes("javascript:") && !normalized.includes("behavior:") && !normalized.includes("-moz-binding");
158
- }
159
- function sanitizeRichTextStyle(value) {
160
- const source = isRecord(value) ? Object.entries(value).map(([property, propertyValue]) => `${property}:${String(propertyValue)}`).join(";") : String(value ?? "");
161
- const declarations = [];
162
- for (const declaration of source.split(";")) {
163
- const separator = declaration.indexOf(":");
164
- if (separator <= 0) continue;
165
- const property = declaration.slice(0, separator).trim().toLowerCase();
166
- const propertyValue = declaration.slice(separator + 1).trim();
167
- if (ALLOWED_STYLE_PROPERTIES.has(property) && propertyValue && isSafeStyleValue(propertyValue)) declarations.push(`${property}: ${propertyValue}`);
168
- }
169
- return declarations.join("; ");
170
- }
171
- function sanitizeRichTextAttributes(value, tagName) {
172
- if (!isRecord(value)) return {};
173
- const attributes = {};
174
- for (const [rawName, rawValue] of Object.entries(value)) {
175
- const name = rawName.trim().toLowerCase();
176
- if (name.startsWith("on") || name === "srcdoc") continue;
177
- if (!ALLOWED_ATTRIBUTES.has(name) && name !== "src" && !name.startsWith("aria-") && !name.startsWith("data-")) continue;
178
- if (name === "src" && tagName !== "img") continue;
179
- const serialized = name === "style" ? sanitizeRichTextStyle(rawValue) : String(rawValue ?? "");
180
- if (!serialized || URL_ATTRIBUTES.has(name) && !isSafeUrl(serialized, name)) continue;
181
- attributes[name] = serialized;
182
- }
183
- if (tagName === "a") attributes.rel = "noopener noreferrer";
184
- return attributes;
185
- }
186
- function convertSourceNode(value) {
187
- if (!isRecord(value)) return [];
188
- if (value.type === "text" || !value.name && typeof value.text === "string") return [{
189
- type: "text",
190
- text: String(value.text ?? "")
191
- }];
192
- const children = Array.isArray(value.children) ? value.children.flatMap(convertSourceNode) : [];
193
- const name = String(value.name ?? "").toLowerCase();
194
- if (!ALLOWED_TAGS.has(name)) return children;
195
- return [{
196
- type: "element",
197
- name,
198
- attrs: sanitizeRichTextAttributes(value.attrs, name),
199
- children
200
- }];
201
- }
202
- function convertParsedNode(node) {
203
- if (node.type === "text") return [{
204
- type: "text",
205
- text: node.data
206
- }];
207
- if (node.type !== "tag") return [];
208
- const element = node;
209
- const children = element.children.flatMap(convertParsedNode);
210
- const name = element.name.toLowerCase();
211
- if (!ALLOWED_TAGS.has(name)) return children;
212
- return [{
213
- type: "element",
214
- name,
215
- attrs: sanitizeRichTextAttributes(element.attribs, name),
216
- children
217
- }];
218
- }
219
- function normalizeRichTextNodes(value) {
220
- if (typeof value === "string") return parseDocument(value, {
221
- decodeEntities: true,
222
- lowerCaseAttributeNames: true,
223
- lowerCaseTags: true
224
- }).children.flatMap(convertParsedNode);
225
- return (Array.isArray(value) ? value : [value]).flatMap(convertSourceNode);
226
- }
227
-
228
- //#endregion
229
- export { normalizeRichTextNodes, sanitizeRichTextAttributes, sanitizeRichTextStyle };
230
- //# sourceMappingURL=helpers.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/richText/helpers.ts"],"sourcesContent":["import type { DataNode, Element, Node } from 'domhandler'\nimport { parseDocument } from 'htmlparser2'\n\nexport interface RichTextSourceNode {\n type?: string\n name?: string\n attrs?: Record<string, unknown>\n children?: RichTextSourceNode[]\n text?: string\n}\n\nexport type SafeRichTextNode\n = | { type: 'text', text: string }\n | { type: 'element', name: string, attrs: Record<string, string>, children: SafeRichTextNode[] }\n\nconst ALLOWED_TAGS = new Set([\n 'a',\n 'abbr',\n 'address',\n 'article',\n 'aside',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'br',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'dd',\n 'del',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'fieldset',\n 'font',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hr',\n 'i',\n 'img',\n 'ins',\n 'label',\n 'legend',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'q',\n 'rt',\n 'ruby',\n 's',\n 'section',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n 'tt',\n 'u',\n 'ul',\n])\n\nconst ALLOWED_ATTRIBUTES = new Set([\n 'abbr',\n 'align',\n 'alt',\n 'axis',\n 'bgcolor',\n 'border',\n 'cellpadding',\n 'cellspacing',\n 'class',\n 'colspan',\n 'dir',\n 'height',\n 'href',\n 'id',\n 'lang',\n 'rowspan',\n 'scope',\n 'span',\n 'start',\n 'style',\n 'summary',\n 'target',\n 'title',\n 'type',\n 'valign',\n 'width',\n])\n\nconst URL_ATTRIBUTES = new Set(['href', 'src'])\n\nconst ALLOWED_STYLE_PROPERTIES = new Set([\n 'background',\n 'background-color',\n 'border',\n 'border-bottom',\n 'border-color',\n 'border-left',\n 'border-radius',\n 'border-right',\n 'border-style',\n 'border-top',\n 'border-width',\n 'color',\n 'display',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'height',\n 'letter-spacing',\n 'line-height',\n 'margin',\n 'margin-bottom',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'max-height',\n 'max-width',\n 'min-height',\n 'min-width',\n 'opacity',\n 'overflow',\n 'padding',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'text-align',\n 'text-decoration',\n 'text-indent',\n 'text-overflow',\n 'text-transform',\n 'vertical-align',\n 'white-space',\n 'width',\n 'word-break',\n 'word-wrap',\n])\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction isSafeUrl(value: string, attribute: string) {\n const normalized = Array.from(value)\n .filter(character => character.charCodeAt(0) > 0x20)\n .join('')\n .toLowerCase()\n if (!normalized || normalized.startsWith('#') || normalized.startsWith('/') || normalized.startsWith('./') || normalized.startsWith('../')) {\n return true\n }\n if (/^(?:https?:|mailto:|tel:)/.test(normalized)) {\n return true\n }\n return attribute === 'src' && /^data:image\\/(?:gif|jpe?g|png|webp);base64,/.test(normalized)\n}\n\nfunction isSafeStyleValue(value: string) {\n const normalized = value.toLowerCase().replace(/\\s+/g, '')\n return !normalized.includes('url(')\n && !normalized.includes('expression(')\n && !normalized.includes('javascript:')\n && !normalized.includes('behavior:')\n && !normalized.includes('-moz-binding')\n}\n\nexport function sanitizeRichTextStyle(value: unknown) {\n const source = isRecord(value)\n ? Object.entries(value)\n .map(([property, propertyValue]) => `${property}:${String(propertyValue)}`)\n .join(';')\n : String(value ?? '')\n const declarations: string[] = []\n for (const declaration of source.split(';')) {\n const separator = declaration.indexOf(':')\n if (separator <= 0) {\n continue\n }\n const property = declaration.slice(0, separator).trim().toLowerCase()\n const propertyValue = declaration.slice(separator + 1).trim()\n if (ALLOWED_STYLE_PROPERTIES.has(property) && propertyValue && isSafeStyleValue(propertyValue)) {\n declarations.push(`${property}: ${propertyValue}`)\n }\n }\n return declarations.join('; ')\n}\n\nexport function sanitizeRichTextAttributes(value: unknown, tagName: string) {\n if (!isRecord(value)) {\n return {}\n }\n const attributes: Record<string, string> = {}\n for (const [rawName, rawValue] of Object.entries(value)) {\n const name = rawName.trim().toLowerCase()\n if (name.startsWith('on') || name === 'srcdoc') {\n continue\n }\n if (!ALLOWED_ATTRIBUTES.has(name) && name !== 'src' && !name.startsWith('aria-') && !name.startsWith('data-')) {\n continue\n }\n if (name === 'src' && tagName !== 'img') {\n continue\n }\n const serialized = name === 'style' ? sanitizeRichTextStyle(rawValue) : String(rawValue ?? '')\n if (!serialized || (URL_ATTRIBUTES.has(name) && !isSafeUrl(serialized, name))) {\n continue\n }\n attributes[name] = serialized\n }\n if (tagName === 'a') {\n attributes.rel = 'noopener noreferrer'\n }\n return attributes\n}\n\nfunction convertSourceNode(value: unknown): SafeRichTextNode[] {\n if (!isRecord(value)) {\n return []\n }\n if (value.type === 'text' || (!value.name && typeof value.text === 'string')) {\n return [{ type: 'text', text: String(value.text ?? '') }]\n }\n const children = Array.isArray(value.children)\n ? value.children.flatMap(convertSourceNode)\n : []\n const name = String(value.name ?? '').toLowerCase()\n if (!ALLOWED_TAGS.has(name)) {\n return children\n }\n return [{\n type: 'element',\n name,\n attrs: sanitizeRichTextAttributes(value.attrs, name),\n children,\n }]\n}\n\nfunction convertParsedNode(node: Node): SafeRichTextNode[] {\n if (node.type === 'text') {\n return [{ type: 'text', text: (node as DataNode).data }]\n }\n if (node.type !== 'tag') {\n return []\n }\n const element = node as Element\n const children = element.children.flatMap(convertParsedNode)\n const name = element.name.toLowerCase()\n if (!ALLOWED_TAGS.has(name)) {\n return children\n }\n return [{\n type: 'element',\n name,\n attrs: sanitizeRichTextAttributes(element.attribs, name),\n children,\n }]\n}\n\nexport function normalizeRichTextNodes(value: unknown): SafeRichTextNode[] {\n if (typeof value === 'string') {\n const document = parseDocument(value, {\n decodeEntities: true,\n lowerCaseAttributeNames: true,\n lowerCaseTags: true,\n })\n return document.children.flatMap(convertParsedNode)\n }\n const values = Array.isArray(value) ? value : [value]\n return values.flatMap(convertSourceNode)\n}\n"],"mappings":";;;AAeA,MAAM,+BAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,iCAAiB,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;AAE9C,MAAM,2CAA2B,IAAI,IAAI;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,EAAE;CAAE,CAAC;CAE1D,MAAM,WAAW,MAAM,QAAQ,MAAM,QAAQ,IACzC,MAAM,SAAS,QAAQ,iBAAiB,IACxC,CAAC;CACL,MAAM,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,YAAY;CAClD,IAAI,CAAC,aAAa,IAAI,IAAI,GACxB,OAAO;CAET,OAAO,CAAC;EACN,MAAM;EACN;EACA,OAAO,2BAA2B,MAAM,OAAO,IAAI;EACnD;CACF,CAAC;AACH;AAEA,SAAS,kBAAkB,MAAgC;CACzD,IAAI,KAAK,SAAS,QAChB,OAAO,CAAC;EAAE,MAAM;EAAQ,MAAO,KAAkB;CAAK,CAAC;CAEzD,IAAI,KAAK,SAAS,OAChB,OAAO,CAAC;CAEV,MAAM,UAAU;CAChB,MAAM,WAAW,QAAQ,SAAS,QAAQ,iBAAiB;CAC3D,MAAM,OAAO,QAAQ,KAAK,YAAY;CACtC,IAAI,CAAC,aAAa,IAAI,IAAI,GACxB,OAAO;CAET,OAAO,CAAC;EACN,MAAM;EACN;EACA,OAAO,2BAA2B,QAAQ,SAAS,IAAI;EACvD;CACF,CAAC;AACH;AAEA,SAAgB,uBAAuB,OAAoC;CACzE,IAAI,OAAO,UAAU,UAMnB,OALiB,cAAc,OAAO;EACpC,gBAAgB;EAChB,yBAAyB;EACzB,eAAe;CACjB,CACc,CAAC,CAAC,SAAS,QAAQ,iBAAiB;CAGpD,QADe,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,EACvC,CAAC,QAAQ,iBAAiB;AACzC"}
@@ -1,88 +0,0 @@
1
- import { getNativeComponentDescriptor } from "../../shared/nativeComponents.mjs";
2
- import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "./helpers.mjs";
3
- import { ensureNativeComponentStyle } from "./style.mjs";
4
-
5
- //#region src/runtime/nativeComponents/scrollView.ts
6
- const BaseElement = globalThis.HTMLElement ?? class {};
7
- function createScrollEventDetail(viewport, previous) {
8
- return {
9
- scrollLeft: viewport.scrollLeft,
10
- scrollTop: viewport.scrollTop,
11
- scrollWidth: viewport.scrollWidth,
12
- scrollHeight: viewport.scrollHeight,
13
- deltaX: viewport.scrollLeft - previous.scrollLeft,
14
- deltaY: viewport.scrollTop - previous.scrollTop
15
- };
16
- }
17
- var WeappScrollView = class extends BaseElement {
18
- static observedAttributes = [...getNativeComponentDescriptor("scroll-view").attributes];
19
- #viewport;
20
- #lastScrollLeft = 0;
21
- #lastScrollTop = 0;
22
- get scrollTop() {
23
- return this.#viewport?.scrollTop ?? 0;
24
- }
25
- set scrollTop(value) {
26
- if (this.#viewport) this.#viewport.scrollTop = value;
27
- }
28
- get scrollLeft() {
29
- return this.#viewport?.scrollLeft ?? 0;
30
- }
31
- set scrollLeft(value) {
32
- if (this.#viewport) this.#viewport.scrollLeft = value;
33
- }
34
- connectedCallback() {
35
- ensureNativeComponentStyle(resolveContainingShadowRoot(this));
36
- const initializePosition = !this.#viewport;
37
- this.#ensureStructure();
38
- this.#syncAttributes(void 0, initializePosition);
39
- }
40
- attributeChangedCallback(name, oldValue, newValue) {
41
- if (oldValue !== newValue) this.#syncAttributes(name);
42
- }
43
- #ensureStructure() {
44
- if (this.#viewport || typeof document === "undefined") return;
45
- const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
46
- const style = document.createElement("style");
47
- style.textContent = `
48
- :host { min-width: 0; min-height: 0; }
49
- .viewport { width: 100%; height: 100%; overscroll-behavior: contain; }
50
- `;
51
- const viewport = document.createElement("div");
52
- viewport.className = "viewport";
53
- const slot = document.createElement("slot");
54
- viewport.append(slot);
55
- viewport.addEventListener("scroll", (event) => {
56
- if (event.target !== viewport) return;
57
- const detail = createScrollEventDetail(viewport, {
58
- scrollLeft: this.#lastScrollLeft,
59
- scrollTop: this.#lastScrollTop
60
- });
61
- this.#lastScrollLeft = viewport.scrollLeft;
62
- this.#lastScrollTop = viewport.scrollTop;
63
- dispatchMiniProgramEvent(this, "scroll", detail, {
64
- bubbles: false,
65
- composed: false
66
- });
67
- });
68
- root.append(style, viewport);
69
- this.#viewport = viewport;
70
- }
71
- #syncAttributes(changedName, initializePosition = false) {
72
- if (!this.#viewport) return;
73
- if (!changedName || changedName === "scroll-x") this.#viewport.style.overflowX = readBooleanAttribute(this, "scroll-x") ? "auto" : "hidden";
74
- if (!changedName || changedName === "scroll-y") this.#viewport.style.overflowY = readBooleanAttribute(this, "scroll-y") ? "auto" : "hidden";
75
- if (initializePosition || changedName === "scroll-top") {
76
- const scrollTop = Number(this.getAttribute("scroll-top"));
77
- if (Number.isFinite(scrollTop)) this.#viewport.scrollTop = scrollTop;
78
- }
79
- if (initializePosition || changedName === "scroll-left") {
80
- const scrollLeft = Number(this.getAttribute("scroll-left"));
81
- if (Number.isFinite(scrollLeft)) this.#viewport.scrollLeft = scrollLeft;
82
- }
83
- }
84
- };
85
-
86
- //#endregion
87
- export { WeappScrollView, createScrollEventDetail };
88
- //# sourceMappingURL=scrollView.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scrollView.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/scrollView.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport function createScrollEventDetail(\n viewport: Pick<HTMLDivElement, 'scrollHeight' | 'scrollLeft' | 'scrollTop' | 'scrollWidth'>,\n previous: { scrollLeft: number, scrollTop: number },\n) {\n return {\n scrollLeft: viewport.scrollLeft,\n scrollTop: viewport.scrollTop,\n scrollWidth: viewport.scrollWidth,\n scrollHeight: viewport.scrollHeight,\n deltaX: viewport.scrollLeft - previous.scrollLeft,\n deltaY: viewport.scrollTop - previous.scrollTop,\n }\n}\n\nexport class WeappScrollView extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('scroll-view')!.attributes]\n\n #viewport?: HTMLDivElement\n #lastScrollLeft = 0\n #lastScrollTop = 0\n\n get scrollTop() {\n return this.#viewport?.scrollTop ?? 0\n }\n\n set scrollTop(value: number) {\n if (this.#viewport) {\n this.#viewport.scrollTop = value\n }\n }\n\n get scrollLeft() {\n return this.#viewport?.scrollLeft ?? 0\n }\n\n set scrollLeft(value: number) {\n if (this.#viewport) {\n this.#viewport.scrollLeft = value\n }\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n const initializePosition = !this.#viewport\n this.#ensureStructure()\n this.#syncAttributes(undefined, initializePosition)\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue !== newValue) {\n this.#syncAttributes(name)\n }\n }\n\n #ensureStructure() {\n if (this.#viewport || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { min-width: 0; min-height: 0; }\n .viewport { width: 100%; height: 100%; overscroll-behavior: contain; }\n `\n const viewport = document.createElement('div')\n viewport.className = 'viewport'\n const slot = document.createElement('slot')\n viewport.append(slot)\n viewport.addEventListener('scroll', (event) => {\n if (event.target !== viewport) {\n return\n }\n const detail = createScrollEventDetail(viewport, {\n scrollLeft: this.#lastScrollLeft,\n scrollTop: this.#lastScrollTop,\n })\n this.#lastScrollLeft = viewport.scrollLeft\n this.#lastScrollTop = viewport.scrollTop\n dispatchMiniProgramEvent(this, 'scroll', detail, {\n bubbles: false,\n composed: false,\n })\n })\n root.append(style, viewport)\n this.#viewport = viewport\n }\n\n #syncAttributes(changedName?: string, initializePosition = false) {\n if (!this.#viewport) {\n return\n }\n if (!changedName || changedName === 'scroll-x') {\n this.#viewport.style.overflowX = readBooleanAttribute(this, 'scroll-x') ? 'auto' : 'hidden'\n }\n if (!changedName || changedName === 'scroll-y') {\n this.#viewport.style.overflowY = readBooleanAttribute(this, 'scroll-y') ? 'auto' : 'hidden'\n }\n if (initializePosition || changedName === 'scroll-top') {\n const scrollTop = Number(this.getAttribute('scroll-top'))\n if (Number.isFinite(scrollTop)) {\n this.#viewport.scrollTop = scrollTop\n }\n }\n if (initializePosition || changedName === 'scroll-left') {\n const scrollLeft = Number(this.getAttribute('scroll-left'))\n if (Number.isFinite(scrollLeft)) {\n this.#viewport.scrollLeft = scrollLeft\n }\n }\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAgB,wBACd,UACA,UACA;CACA,OAAO;EACL,YAAY,SAAS;EACrB,WAAW,SAAS;EACpB,aAAa,SAAS;EACtB,cAAc,SAAS;EACvB,QAAQ,SAAS,aAAa,SAAS;EACvC,QAAQ,SAAS,YAAY,SAAS;CACxC;AACF;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAC/C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,aAAa,CAAC,CAAE,UAAU;CAEvF;CACA,kBAAkB;CAClB,iBAAiB;CAEjB,IAAI,YAAY;EACd,OAAO,KAAK,WAAW,aAAa;CACtC;CAEA,IAAI,UAAU,OAAe;EAC3B,IAAI,KAAK,WACP,KAAK,UAAU,YAAY;CAE/B;CAEA,IAAI,aAAa;EACf,OAAO,KAAK,WAAW,cAAc;CACvC;CAEA,IAAI,WAAW,OAAe;EAC5B,IAAI,KAAK,WACP,KAAK,UAAU,aAAa;CAEhC;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,MAAM,qBAAqB,CAAC,KAAK;EACjC,KAAK,iBAAiB;EACtB,KAAK,gBAAgB,QAAW,kBAAkB;CACpD;CAEA,yBAAyB,MAAc,UAAyB,UAAyB;EACvF,IAAI,aAAa,UACf,KAAK,gBAAgB,IAAI;CAE7B;CAEA,mBAAmB;EACjB,IAAI,KAAK,aAAa,OAAO,aAAa,aACxC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MA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