@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,4 +1,4 @@
1
- //#region src/runtime/polyfill/routeRuntime/options.ts
1
+ // src/runtime/polyfill/routeRuntime/options.ts
2
2
  const RESERVED_PAGE_METHOD_KEYS = /* @__PURE__ */ new Set([
3
3
  "data",
4
4
  "methods",
@@ -70,6 +70,5 @@ function normalizeComponentOptions(raw) {
70
70
  return component;
71
71
  }
72
72
 
73
- //#endregion
74
73
  export { isRecord, normalizeComponentOptions, normalizePageOptions };
75
74
  //# sourceMappingURL=options.mjs.map
@@ -1,12 +1,11 @@
1
1
  import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "../async.mjs";
2
2
 
3
- //#region src/runtime/polyfill/routeRuntime/result.ts
3
+ // src/runtime/polyfill/routeRuntime/result.ts
4
4
  function resolveRouteAction(action, options, succeeded, failureReason = "page not found") {
5
5
  if (succeeded) return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: `${action}:ok` }));
6
6
  const failure = callMiniProgramAsyncFailure(options, `${action}:fail ${failureReason}`);
7
7
  return Promise.reject(failure);
8
8
  }
9
9
 
10
- //#endregion
11
10
  export { resolveRouteAction };
12
11
  //# sourceMappingURL=result.mjs.map
@@ -1,10 +1,13 @@
1
1
  import { getAppContainer } from "../../appShell/container.mjs";
2
2
 
3
- //#region src/runtime/polyfill/routeRuntime/scroll.ts
3
+ // src/runtime/polyfill/routeRuntime/scroll.ts
4
+ /** 与 page.json 的 onReachBottomDistance 默认值一致。 */
5
+ const DEFAULT_REACH_BOTTOM_DISTANCE = 50;
4
6
  let activeEntry;
5
7
  let boundContainer;
6
8
  let scrollHandler;
7
9
  const restorationClaims = /* @__PURE__ */ new WeakMap();
10
+ const reachBottomStates = /* @__PURE__ */ new WeakMap();
8
11
  /** 仅认领新页面首次恢复;保留页面的容器位置仍由宿主维护,显式 pageScrollTo 不受影响。 */
9
12
  function claimPageScrollRestoration(page) {
10
13
  restorationClaims.set(page, (restorationClaims.get(page) ?? 0) + 1);
@@ -20,6 +23,10 @@ function claimPageScrollRestoration(page) {
20
23
  function getPageContainer() {
21
24
  return getAppContainer();
22
25
  }
26
+ function isContainerAtBottom(container, scrollTop = container.scrollTop) {
27
+ if (!(container.scrollHeight > container.clientHeight)) return false;
28
+ return scrollTop + container.clientHeight >= container.scrollHeight - DEFAULT_REACH_BOTTOM_DISTANCE;
29
+ }
23
30
  function captureEntryScrollPosition(entry) {
24
31
  if (!entry.active) return;
25
32
  const container = getPageContainer();
@@ -28,7 +35,13 @@ function captureEntryScrollPosition(entry) {
28
35
  function restoreEntryScrollPosition(entry, retained = false) {
29
36
  if (!retained && entry.instance && restorationClaims.has(entry.instance)) return;
30
37
  const container = getPageContainer();
31
- if (container) container.scrollTop = entry.scrollTop ?? 0;
38
+ if (container) {
39
+ container.scrollTop = entry.scrollTop ?? 0;
40
+ reachBottomStates.set(entry, {
41
+ atBottom: isContainerAtBottom(container),
42
+ scrollTop: container.scrollTop
43
+ });
44
+ }
32
45
  }
33
46
  function setEntryScrollOwner(entry, active) {
34
47
  if (active) {
@@ -37,10 +50,29 @@ function setEntryScrollOwner(entry, active) {
37
50
  }
38
51
  if (activeEntry === entry) activeEntry = void 0;
39
52
  }
53
+ /**
54
+ * 真机在滚到底部时触发一次 `onReachBottom`:内容加载后离开底部再滚到底会重新触发,
55
+ * 停在底部继续滚动不会重复调用。
56
+ */
57
+ function notifyEntryReachBottom(entry) {
58
+ const container = getPageContainer();
59
+ if (!container) return;
60
+ const atBottom = isContainerAtBottom(container);
61
+ const previous = reachBottomStates.get(entry);
62
+ const continued = previous?.atBottom && isContainerAtBottom(container, previous.scrollTop);
63
+ reachBottomStates.set(entry, {
64
+ atBottom,
65
+ scrollTop: container.scrollTop
66
+ });
67
+ if (!atBottom || continued) return;
68
+ entry.instance?.onReachBottom?.();
69
+ }
40
70
  function recordActiveEntryScrollPosition() {
41
- if (activeEntry?.active) {
42
- captureEntryScrollPosition(activeEntry);
43
- activeEntry.instance?.onPageScroll?.({ scrollTop: activeEntry.scrollTop ?? 0 });
71
+ const entry = activeEntry;
72
+ if (entry?.active) {
73
+ captureEntryScrollPosition(entry);
74
+ entry.instance?.onPageScroll?.({ scrollTop: entry.scrollTop ?? 0 });
75
+ if (entry === activeEntry && entry.active) notifyEntryReachBottom(entry);
44
76
  }
45
77
  }
46
78
  function bindPageScrollOwner(container) {
@@ -51,6 +83,5 @@ function bindPageScrollOwner(container) {
51
83
  container.addEventListener("scroll", scrollHandler, { passive: true });
52
84
  }
53
85
 
54
- //#endregion
55
86
  export { bindPageScrollOwner, captureEntryScrollPosition, claimPageScrollRestoration, getPageContainer, recordActiveEntryScrollPosition, restoreEntryScrollPosition, setEntryScrollOwner };
56
87
  //# sourceMappingURL=scroll.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll.mjs","names":[],"sources":["../../../../src/runtime/polyfill/routeRuntime/scroll.ts"],"sourcesContent":["import type { PageStackEntry } from './options'\nimport { getAppContainer } from '../../appShell/container'\n\ntype ScrollContainer = HTMLElement & Pick<EventTarget, 'addEventListener' | 'removeEventListener'>\n\nlet activeEntry: PageStackEntry | undefined\nlet boundContainer: ScrollContainer | undefined\nlet scrollHandler: (() => void) | undefined\n\nconst restorationClaims = new WeakMap<object, number>()\n\n/** 仅认领新页面首次恢复;保留页面的容器位置仍由宿主维护,显式 pageScrollTo 不受影响。 */\nexport function claimPageScrollRestoration(page: object): () => void {\n restorationClaims.set(page, (restorationClaims.get(page) ?? 0) + 1)\n let released = false\n return () => {\n if (released) {\n return\n }\n released = true\n const remaining = (restorationClaims.get(page) ?? 1) - 1\n if (remaining > 0) {\n restorationClaims.set(page, remaining)\n }\n else {\n restorationClaims.delete(page)\n }\n }\n}\n\nexport function getPageContainer() {\n return getAppContainer()\n}\n\nexport function captureEntryScrollPosition(entry: PageStackEntry) {\n if (!entry.active) {\n return\n }\n const container = getPageContainer()\n if (container) {\n entry.scrollTop = container.scrollTop\n }\n}\n\nexport function restoreEntryScrollPosition(entry: PageStackEntry, retained = false) {\n if (!retained && entry.instance && restorationClaims.has(entry.instance)) {\n return\n }\n const container = getPageContainer()\n if (container) {\n container.scrollTop = entry.scrollTop ?? 0\n }\n}\n\nexport function setEntryScrollOwner(entry: PageStackEntry, active: boolean) {\n if (active) {\n activeEntry = entry\n return\n }\n if (activeEntry === entry) {\n activeEntry = undefined\n }\n}\n\nexport function recordActiveEntryScrollPosition() {\n if (activeEntry?.active) {\n captureEntryScrollPosition(activeEntry)\n const page = activeEntry.instance as (PageStackEntry['instance'] & {\n onPageScroll?: (event: { scrollTop: number }) => void\n }) | undefined\n page?.onPageScroll?.({ scrollTop: activeEntry.scrollTop ?? 0 })\n }\n}\n\nexport function bindPageScrollOwner(container: ScrollContainer) {\n if (boundContainer === container) {\n return\n }\n if (boundContainer && scrollHandler) {\n boundContainer.removeEventListener('scroll', scrollHandler)\n }\n boundContainer = container\n scrollHandler = recordActiveEntryScrollPosition\n container.addEventListener('scroll', scrollHandler, { passive: true })\n}\n\nexport function disposePageScrollOwner() {\n if (boundContainer && scrollHandler) {\n boundContainer.removeEventListener('scroll', scrollHandler)\n }\n activeEntry = undefined\n boundContainer = undefined\n scrollHandler = undefined\n}\n"],"mappings":";;;AAKA,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,oCAAoB,IAAI,QAAwB;;AAGtD,SAAgB,2BAA2B,MAA0B;CACnE,kBAAkB,IAAI,OAAO,kBAAkB,IAAI,IAAI,KAAK,KAAK,CAAC;CAClE,IAAI,WAAW;CACf,aAAa;EACX,IAAI,UACF;EAEF,WAAW;EACX,MAAM,aAAa,kBAAkB,IAAI,IAAI,KAAK,KAAK;EACvD,IAAI,YAAY,GACd,kBAAkB,IAAI,MAAM,SAAS;OAGrC,kBAAkB,OAAO,IAAI;CAEjC;AACF;AAEA,SAAgB,mBAAmB;CACjC,OAAO,gBAAgB;AACzB;AAEA,SAAgB,2BAA2B,OAAuB;CAChE,IAAI,CAAC,MAAM,QACT;CAEF,MAAM,YAAY,iBAAiB;CACnC,IAAI,WACF,MAAM,YAAY,UAAU;AAEhC;AAEA,SAAgB,2BAA2B,OAAuB,WAAW,OAAO;CAClF,IAAI,CAAC,YAAY,MAAM,YAAY,kBAAkB,IAAI,MAAM,QAAQ,GACrE;CAEF,MAAM,YAAY,iBAAiB;CACnC,IAAI,WACF,UAAU,YAAY,MAAM,aAAa;AAE7C;AAEA,SAAgB,oBAAoB,OAAuB,QAAiB;CAC1E,IAAI,QAAQ;EACV,cAAc;EACd;CACF;CACA,IAAI,gBAAgB,OAClB,cAAc;AAElB;AAEA,SAAgB,kCAAkC;CAChD,IAAI,aAAa,QAAQ;EACvB,2BAA2B,WAAW;EAItC,AAHa,YAAY,UAGnB,eAAe,EAAE,WAAW,YAAY,aAAa,EAAE,CAAC;CAChE;AACF;AAEA,SAAgB,oBAAoB,WAA4B;CAC9D,IAAI,mBAAmB,WACrB;CAEF,IAAI,kBAAkB,eACpB,eAAe,oBAAoB,UAAU,aAAa;CAE5D,iBAAiB;CACjB,gBAAgB;CAChB,UAAU,iBAAiB,UAAU,eAAe,EAAE,SAAS,KAAK,CAAC;AACvE"}
1
+ {"version":3,"file":"scroll.mjs","names":[],"sources":["../../../../src/runtime/polyfill/routeRuntime/scroll.ts"],"sourcesContent":["import type { PageStackEntry } from './options'\nimport { getAppContainer } from '../../appShell/container'\n\ntype ScrollContainer = HTMLElement & Pick<EventTarget, 'addEventListener' | 'removeEventListener'>\n\ninterface ReachBottomState {\n atBottom: boolean\n scrollTop: number\n}\n\n/** 与 page.json 的 onReachBottomDistance 默认值一致。 */\nconst DEFAULT_REACH_BOTTOM_DISTANCE = 50\n\nlet activeEntry: PageStackEntry | undefined\nlet boundContainer: ScrollContainer | undefined\nlet scrollHandler: (() => void) | undefined\n\nconst restorationClaims = new WeakMap<object, number>()\nconst reachBottomStates = new WeakMap<PageStackEntry, ReachBottomState>()\n\n/** 仅认领新页面首次恢复;保留页面的容器位置仍由宿主维护,显式 pageScrollTo 不受影响。 */\nexport function claimPageScrollRestoration(page: object): () => void {\n restorationClaims.set(page, (restorationClaims.get(page) ?? 0) + 1)\n let released = false\n return () => {\n if (released) {\n return\n }\n released = true\n const remaining = (restorationClaims.get(page) ?? 1) - 1\n if (remaining > 0) {\n restorationClaims.set(page, remaining)\n }\n else {\n restorationClaims.delete(page)\n }\n }\n}\n\nexport function getPageContainer() {\n return getAppContainer()\n}\n\nfunction isContainerAtBottom(container: ScrollContainer, scrollTop = container.scrollTop) {\n if (!(container.scrollHeight > container.clientHeight)) {\n return false\n }\n return scrollTop + container.clientHeight >= container.scrollHeight - DEFAULT_REACH_BOTTOM_DISTANCE\n}\n\nexport function captureEntryScrollPosition(entry: PageStackEntry) {\n if (!entry.active) {\n return\n }\n const container = getPageContainer()\n if (container) {\n entry.scrollTop = container.scrollTop\n }\n}\n\nexport function restoreEntryScrollPosition(entry: PageStackEntry, retained = false) {\n if (!retained && entry.instance && restorationClaims.has(entry.instance)) {\n return\n }\n const container = getPageContainer()\n if (container) {\n container.scrollTop = entry.scrollTop ?? 0\n // 恢复位置不算用户触底,同步状态避免随后的 scroll 事件补发一次 onReachBottom。\n reachBottomStates.set(entry, {\n atBottom: isContainerAtBottom(container),\n scrollTop: container.scrollTop,\n })\n }\n}\n\nexport function setEntryScrollOwner(entry: PageStackEntry, active: boolean) {\n if (active) {\n activeEntry = entry\n return\n }\n if (activeEntry === entry) {\n activeEntry = undefined\n }\n}\n\n/**\n * 真机在滚到底部时触发一次 `onReachBottom`:内容加载后离开底部再滚到底会重新触发,\n * 停在底部继续滚动不会重复调用。\n */\nfunction notifyEntryReachBottom(entry: PageStackEntry) {\n const container = getPageContainer()\n if (!container) {\n return\n }\n const atBottom = isContainerAtBottom(container)\n const previous = reachBottomStates.get(entry)\n // 追加内容或缩小视口不会必然触发 scroll;以当前尺寸重判上次位置是否仍在底部区间。\n const continued = previous?.atBottom && isContainerAtBottom(container, previous.scrollTop)\n reachBottomStates.set(entry, { atBottom, scrollTop: container.scrollTop })\n if (!atBottom || continued) {\n return\n }\n const page = entry.instance as (PageStackEntry['instance'] & {\n onReachBottom?: () => void\n }) | undefined\n page?.onReachBottom?.()\n}\n\nexport function recordActiveEntryScrollPosition() {\n const entry = activeEntry\n if (entry?.active) {\n captureEntryScrollPosition(entry)\n const page = entry.instance as (PageStackEntry['instance'] & {\n onPageScroll?: (event: { scrollTop: number }) => void\n }) | undefined\n page?.onPageScroll?.({ scrollTop: entry.scrollTop ?? 0 })\n if (entry === activeEntry && entry.active) {\n notifyEntryReachBottom(entry)\n }\n }\n}\n\nexport function bindPageScrollOwner(container: ScrollContainer) {\n if (boundContainer === container) {\n return\n }\n if (boundContainer && scrollHandler) {\n boundContainer.removeEventListener('scroll', scrollHandler)\n }\n boundContainer = container\n scrollHandler = recordActiveEntryScrollPosition\n container.addEventListener('scroll', scrollHandler, { passive: true })\n}\n\nexport function disposePageScrollOwner() {\n if (boundContainer && scrollHandler) {\n boundContainer.removeEventListener('scroll', scrollHandler)\n }\n activeEntry = undefined\n boundContainer = undefined\n scrollHandler = undefined\n}\n"],"mappings":";;;;AAWA,MAAM,gCAAgC;AAEtC,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,oCAAoB,IAAI,QAAwB;AACtD,MAAM,oCAAoB,IAAI,QAA0C;;AAGxE,SAAgB,2BAA2B,MAA0B;CACnE,kBAAkB,IAAI,OAAO,kBAAkB,IAAI,IAAI,KAAK,KAAK,CAAC;CAClE,IA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;AACxB;AAEA,SAAgB,kCAAkC;CAChD,MAAM,QAAQ;CACd,IAAI,OAAO,QAAQ;EACjB,2BAA2B,KAAK;EAIhC,AAHa,MAAM,UAGb,eAAe,EAAE,WAAW,MAAM,aAAa,EAAE,CAAC;EACxD,IAAI,UAAU,eAAe,MAAM,QACjC,uBAAuB,KAAK;CAEhC;AACF;AAEA,SAAgB,oBAAoB,WAA4B;CAC9D,IAAI,mBAAmB,WACrB;CAEF,IAAI,kBAAkB,eACpB,eAAe,oBAAoB,UAAU,aAAa;CAE5D,iBAAiB;CACjB,gBAAgB;CAChB,UAAU,iBAAiB,UAAU,eAAe,EAAE,SAAS,KAAK,CAAC;AACvE"}
@@ -3,7 +3,7 @@ import { beginAppRoute, cancelEntryRoute, emitBeforePageUnload, finishAppRoute }
3
3
  import { hidePageInstance, showPageInstance } from "./lifecycle.mjs";
4
4
  import { mountEntryToDom, setEntryActiveInDom, unmountEntryFromDom } from "./dom.mjs";
5
5
 
6
- //#region src/runtime/polyfill/routeRuntime/stack.ts
6
+ // src/runtime/polyfill/routeRuntime/stack.ts
7
7
  var PageStackRuntime = class {
8
8
  pageRegistry;
9
9
  onBeforeMount;
@@ -158,6 +158,5 @@ var PageStackRuntime = class {
158
158
  }
159
159
  };
160
160
 
161
- //#endregion
162
161
  export { PageStackRuntime };
163
162
  //# sourceMappingURL=stack.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/polyfill/routeRuntime/url.ts
1
+ // src/runtime/polyfill/routeRuntime/url.ts
2
2
  const PAGE_TEMPLATE_EXTENSIONS = [
3
3
  ".wxml",
4
4
  ".axml",
@@ -30,6 +30,5 @@ function parsePageUrl(url) {
30
30
  };
31
31
  }
32
32
 
33
- //#endregion
34
33
  export { parsePageUrl };
35
34
  //# sourceMappingURL=url.mjs.map
@@ -1,3 +1,4 @@
1
+ import { ResolvedStyleUnitOptions } from "../../shared/styleUnits/options.mjs";
1
2
  import "../component/index.mjs";
2
3
  import { AppHideCallback, AppLaunchOptions, AppRuntime, AppShowCallback, ComponentRawOptions, NavigateBackOptions, PageRawOptions, RegisterMeta, RouteOptions } from "./routeRuntime/options.mjs";
3
4
  import { WebRoutingConfig } from "./routeRuntime/history.mjs";
@@ -7,12 +8,12 @@ import { ButtonFormConfig } from "../button/index.mjs";
7
8
  import { NavigationBarMetrics } from "../navigationBar/index.mjs";
8
9
  import { WebViewportConfig } from "../viewport/types.mjs";
9
10
  import "./index.mjs";
10
- //#region src/runtime/polyfill/routeRuntime.d.ts
11
11
  export declare function initializePageRoutes(ids: string[], options?: {
12
12
  rpx?: {
13
13
  designWidth?: number;
14
14
  varName?: string;
15
15
  };
16
+ styleUnits?: ResolvedStyleUnitOptions;
16
17
  navigationBar?: NavigationBarMetrics;
17
18
  form?: ButtonFormConfig;
18
19
  tabBar?: WebTabBarConfig;
@@ -52,5 +53,4 @@ export declare function navigateBack(options?: NavigateBackOptions): Promise<{
52
53
  }>;
53
54
  export declare function getLaunchOptionsSync(): AppLaunchOptions;
54
55
  export declare function getEnterOptionsSync(): AppLaunchOptions;
55
- //#endregion
56
56
  //# sourceMappingURL=routeRuntime.d.mts.map
@@ -1,3 +1,4 @@
1
+ import { resolveStyleUnitOptions } from "../../shared/styleUnits/options.mjs";
1
2
  import { slugify } from "../../shared/slugify.mjs";
2
3
  import { setRuntimeWarningOptions } from "../warning.mjs";
3
4
  import { configureTabBar, getTabBarPagePaths, syncTabBarRoute } from "../appShell/tabBar/index.mjs";
@@ -6,10 +7,11 @@ import { setAppStyle } from "../appStyle.mjs";
6
7
  import { setButtonFormConfig } from "../button/index.mjs";
7
8
  import { setRuntimeExecutionMode } from "../execution.mjs";
8
9
  import { defineComponent } from "../component/index.mjs";
9
- import { ensureNativeComponentsDefined } from "../nativeComponents/index.mjs";
10
- import { ensureNavigationBarDefined, setNavigationBarMetrics } from "../navigationBar/index.mjs";
10
+ import { configureInlineStyleUnits } from "../inlineStyle.mjs";
11
11
  import { setupWebViewport } from "../viewport/index.mjs";
12
12
  import { setupRpx } from "../rpx.mjs";
13
+ import { ensureNativeComponentsDefined } from "../nativeComponents/index.mjs";
14
+ import { ensureNavigationBarDefined, setNavigationBarMetrics } from "../navigationBar/index.mjs";
13
15
  import { resolveCurrentPages } from "./appState.mjs";
14
16
  import { normalizeComponentOptions, normalizePageOptions } from "./routeRuntime/options.mjs";
15
17
  import { AppLifecycleRuntime } from "./routeRuntime/appLifecycle.mjs";
@@ -20,7 +22,7 @@ import { resolveRouteAction } from "./routeRuntime/result.mjs";
20
22
  import { PageStackRuntime } from "./routeRuntime/stack.mjs";
21
23
  import { parsePageUrl } from "./routeRuntime/url.mjs";
22
24
 
23
- //#region src/runtime/polyfill/routeRuntime.ts
25
+ // src/runtime/polyfill/routeRuntime.ts
24
26
  const pageRegistry = /* @__PURE__ */ new Map();
25
27
  const componentRegistry = /* @__PURE__ */ new Map();
26
28
  let pageOrder = [];
@@ -98,9 +100,18 @@ function bindPageResizeBridge() {
98
100
  });
99
101
  }
100
102
  function initializePageRoutes(ids, options) {
103
+ const styleUnits = options?.styleUnits ?? resolveStyleUnitOptions({
104
+ designWidth: options?.rpx?.designWidth,
105
+ rpxVar: options?.rpx?.varName
106
+ });
107
+ configureInlineStyleUnits(styleUnits);
101
108
  setRuntimeExecutionMode(options?.runtime?.executionMode);
102
109
  setRuntimeWarningOptions(options?.runtime?.warnings);
103
110
  setupWebViewport(options?.runtime?.viewport);
111
+ setupRpx(options?.styleUnits?.useVariable ? {
112
+ designWidth: styleUnits.designWidth,
113
+ varName: styleUnits.rpxVar
114
+ } : options?.rpx);
104
115
  configureWebSeo(options?.runtime?.seo);
105
116
  setupWebResourceHints(options?.runtime?.resourceHints);
106
117
  configureWebRouting(options?.runtime?.routing, ids, reconcileWebRoute);
@@ -111,7 +122,6 @@ function initializePageRoutes(ids, options) {
111
122
  pageStack.configureTabPages(getTabBarPagePaths());
112
123
  if (!pageOrder.length) return;
113
124
  bindPageResizeBridge();
114
- if (options?.rpx) setupRpx(options.rpx);
115
125
  if (options?.navigationBar) setNavigationBarMetrics(options.navigationBar);
116
126
  if (options?.form) setButtonFormConfig(options.form);
117
127
  if (!pageStack.entries.length) {
@@ -254,6 +264,5 @@ function getEnterOptionsSync() {
254
264
  return appLifecycle.getEnterOptions();
255
265
  }
256
266
 
257
- //#endregion
258
267
  export { getAppInstance, getCurrentPageInstance, getCurrentPagesInternal, getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab };
259
268
  //# sourceMappingURL=routeRuntime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"routeRuntime.mjs","names":[],"sources":["../../../src/runtime/polyfill/routeRuntime.ts"],"sourcesContent":["import type { WebTabBarConfig } from '../../shared/tabBar'\nimport type { ButtonFormConfig } from '../button'\nimport type { ComponentPublicInstance } from '../component'\nimport type { NavigationBarMetrics } from '../navigationBar'\nimport type { WebResourceHintsConfig, WebSeoConfig } from '../seo'\nimport type { WebViewportConfig } from '../viewport'\nimport type { WebRouteHistoryState, WebRouteTarget, WebRoutingConfig } from './routeRuntime/history'\nimport type { AppHideCallback, AppRuntime, AppShowCallback, ComponentRawOptions, ComponentRecord, NavigateBackOptions, PageRawOptions, PageRecord, RegisterMeta, RouteOptions } from './routeRuntime/options'\nimport { slugify } from '../../shared/slugify'\nimport {\n configureTabBar,\n getTabBarPagePaths,\n syncTabBarRoute,\n} from '../appShell/tabBar'\nimport { setAppStyle } from '../appStyle'\nimport { setButtonFormConfig } from '../button'\nimport { defineComponent } from '../component'\nimport { setRuntimeExecutionMode } from '../execution'\nimport { ensureNativeComponentsDefined } from '../nativeComponents'\nimport { ensureNavigationBarDefined, setNavigationBarMetrics } from '../navigationBar'\nimport { setupRpx } from '../rpx'\nimport { configureWebSeo, setupWebResourceHints, syncWebDocumentHead } from '../seo'\nimport { setupWebViewport } from '../viewport'\nimport { setRuntimeWarningOptions } from '../warning'\nimport { resolveCurrentPages } from './appState'\nimport { AppLifecycleRuntime } from './routeRuntime/appLifecycle'\nimport { getEntryWebviewId } from './routeRuntime/events'\nimport {\n configureWebRouting,\n getWebHistoryStack,\n readWebRouteTarget,\n syncWebRouting,\n} from './routeRuntime/history'\nimport {\n augmentPageComponentOptions,\n dispatchPageLifetimeToComponents,\n} from './routeRuntime/lifecycle'\nimport {\n normalizeComponentOptions,\n normalizePageOptions,\n} from './routeRuntime/options'\nimport { resolveRouteAction } from './routeRuntime/result'\nimport { PageStackRuntime } from './routeRuntime/stack'\nimport { parsePageUrl } from './routeRuntime/url'\n\nconst pageRegistry = new Map<string, PageRecord>()\nconst componentRegistry = new Map<string, ComponentRecord>()\nlet pageOrder: string[] = []\nlet pageResizeBridgeBound = false\n\nlet pageStack: PageStackRuntime\nconst appLifecycle = new AppLifecycleRuntime(\n () => pageStack?.entries[pageStack.entries.length - 1],\n)\npageStack = new PageStackRuntime(pageRegistry, entry => appLifecycle.ensureLaunched(entry))\n\nfunction syncCurrentWebDocument() {\n const current = pageStack.entries[pageStack.entries.length - 1]\n syncWebDocumentHead({\n route: current?.id,\n title: current ? pageRegistry.get(current.id)?.navigationBar?.title : undefined,\n })\n}\n\nfunction syncCurrentWebRoute(operation: 'push' | 'replace') {\n syncWebRouting(pageStack.entries, operation)\n syncCurrentWebDocument()\n}\n\nfunction reconcileWebRoute(target: WebRouteTarget | undefined, state: WebRouteHistoryState | undefined) {\n const currentEntries = pageStack.entries\n const historyStack = getWebHistoryStack(state)\n if (historyStack?.length) {\n if (historyStack.some(entry => !pageRegistry.has(entry.id))) {\n return\n }\n const sharedLength = Math.min(historyStack.length, currentEntries.length)\n const samePrefix = historyStack.slice(0, sharedLength).every((entry, index) => {\n const current = currentEntries[index]!\n return entry.id === current.id\n && (entry.webviewId === undefined || entry.webviewId === getEntryWebviewId(current))\n && Object.keys(entry.query).length === Object.keys(current.query).length\n && Object.entries(entry.query).every(([key, value]) => current.query[key] === value)\n })\n if (samePrefix && historyStack.length === currentEntries.length) {\n return\n }\n if (samePrefix && historyStack.length < currentEntries.length) {\n pageStack.back(currentEntries.length - historyStack.length)\n }\n else if (samePrefix && historyStack.length > currentEntries.length) {\n const added = historyStack.slice(currentEntries.length)\n if (added.length === 1) {\n pageStack.push(added[0]!.id, { ...added[0]!.query })\n }\n else {\n pageStack.forward(added)\n }\n }\n else {\n const last = historyStack[historyStack.length - 1]!\n if (getTabBarPagePaths().has(last.id)) {\n pageStack.switchTab(last.id, { ...last.query })\n }\n else {\n pageStack.relaunch(last.id, { ...last.query })\n }\n }\n syncWebRouting(pageStack.entries, 'replace')\n syncTabBarRoute(pageStack.entries[pageStack.entries.length - 1]?.id ?? '')\n syncCurrentWebDocument()\n return\n }\n if (target && pageRegistry.has(target.id)) {\n const current = currentEntries[currentEntries.length - 1]\n if (current?.id === target.id\n && Object.keys(current.query).length === Object.keys(target.query).length\n && Object.entries(target.query).every(([key, value]) => current.query[key] === value)) {\n return\n }\n if (getTabBarPagePaths().has(target.id)) {\n pageStack.switchTab(target.id, { ...target.query })\n }\n else {\n pageStack.relaunch(target.id, { ...target.query })\n }\n syncWebRouting(pageStack.entries, 'replace')\n syncTabBarRoute(target.id)\n syncCurrentWebDocument()\n }\n}\n\nfunction performSwitchTab(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const previousLength = pageStack.entries.length\n const previousEntry = pageStack.entries[previousLength - 1]\n const succeeded = pageStack.switchTab(id, query)\n if (succeeded && (pageStack.entries.length !== previousLength || pageStack.entries.at(-1) !== previousEntry)) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('push')\n }\n return resolveRouteAction('switchTab', options, succeeded, 'not a tabBar page')\n}\n\nfunction bindPageResizeBridge() {\n if (pageResizeBridgeBound || typeof window === 'undefined') {\n return\n }\n if (typeof window.addEventListener !== 'function') {\n return\n }\n pageResizeBridgeBound = true\n window.addEventListener('resize', () => {\n const pages = resolveCurrentPages<ComponentPublicInstance>(pageStack.entries)\n const current = pages[pages.length - 1]\n if (!current) {\n return\n }\n dispatchPageLifetimeToComponents(current, 'resize')\n })\n}\n\nexport function initializePageRoutes(\n ids: string[],\n options?: {\n rpx?: { designWidth?: number, varName?: string }\n navigationBar?: NavigationBarMetrics\n form?: ButtonFormConfig\n tabBar?: WebTabBarConfig\n runtime?: {\n executionMode?: 'compat' | 'safe' | 'strict'\n warnings?: {\n level?: 'off' | 'warn' | 'error'\n dedupe?: boolean\n }\n viewport?: WebViewportConfig\n routing?: WebRoutingConfig\n seo?: WebSeoConfig\n resourceHints?: WebResourceHintsConfig\n }\n },\n) {\n setRuntimeExecutionMode(options?.runtime?.executionMode)\n setRuntimeWarningOptions(options?.runtime?.warnings)\n setupWebViewport(options?.runtime?.viewport)\n configureWebSeo(options?.runtime?.seo)\n setupWebResourceHints(options?.runtime?.resourceHints)\n configureWebRouting(options?.runtime?.routing, ids, reconcileWebRoute)\n appLifecycle.bindVisibility()\n ensureNativeComponentsDefined()\n pageOrder = Array.from(new Set(ids))\n configureTabBar(options?.tabBar, url => performSwitchTab({ url }))\n pageStack.configureTabPages(getTabBarPagePaths())\n if (!pageOrder.length) {\n return\n }\n bindPageResizeBridge()\n if (options?.rpx) {\n setupRpx(options.rpx)\n }\n if (options?.navigationBar) {\n setNavigationBarMetrics(options.navigationBar)\n }\n if (options?.form) {\n setButtonFormConfig(options.form)\n }\n if (!pageStack.entries.length) {\n const initialTarget = readWebRouteTarget(pageOrder)\n const initialId = initialTarget?.id ?? pageOrder[0]\n const initialQuery = initialTarget?.query ?? {}\n if (pageStack.push(initialId, initialQuery, 'appLaunch')) {\n syncTabBarRoute(initialId)\n syncCurrentWebRoute('replace')\n }\n }\n}\n\nexport function registerPage<T extends PageRawOptions | undefined>(options: T, meta: RegisterMeta): T {\n ensureNativeComponentsDefined()\n ensureNavigationBarDefined()\n const tag = slugify(meta.id, 'wv-page')\n const template = meta.template ?? (() => '')\n const normalized = normalizePageOptions(options)\n const existing = pageRegistry.get(meta.id)\n if (existing) {\n existing.hooks = normalized.hooks\n existing.navigationBar = meta.navigationBar\n const component = augmentPageComponentOptions(normalized.component, existing)\n defineComponent(tag, {\n id: meta.id,\n kind: 'page',\n template,\n style: meta.style,\n component,\n })\n return options\n }\n const record: PageRecord = {\n tag,\n hooks: normalized.hooks,\n instances: new Set(),\n navigationBar: meta.navigationBar,\n }\n const component = augmentPageComponentOptions(normalized.component, record)\n defineComponent(tag, {\n id: meta.id,\n kind: 'page',\n template,\n style: meta.style,\n component,\n })\n pageRegistry.set(meta.id, record)\n return options\n}\n\nexport function getCurrentPageInstance(): ComponentPublicInstance | undefined {\n return pageStack.entries[pageStack.entries.length - 1]?.instance\n}\n\nexport function registerComponent<T extends ComponentRawOptions | undefined>(options: T, meta: RegisterMeta): T {\n ensureNativeComponentsDefined()\n const tag = slugify(meta.id, 'wv-component')\n const template = meta.template ?? (() => '')\n const component = normalizeComponentOptions(options)\n if (componentRegistry.has(meta.id)) {\n defineComponent(tag, {\n id: meta.id,\n template,\n style: meta.style,\n component,\n })\n return options\n }\n defineComponent(tag, {\n id: meta.id,\n template,\n style: meta.style,\n component,\n })\n componentRegistry.set(meta.id, { tag })\n return options\n}\n\nexport function registerApp<T extends AppRuntime | undefined>(options: T, meta?: RegisterMeta): T {\n setAppStyle(meta?.style ?? '')\n return appLifecycle.register(options)\n}\n\nexport function offAppHide(callback?: AppHideCallback) {\n appLifecycle.offAppHide(callback)\n}\n\nexport function offAppShow(callback?: AppShowCallback) {\n appLifecycle.offAppShow(callback)\n}\n\nexport function onAppHide(callback: AppHideCallback) {\n appLifecycle.onAppHide(callback)\n}\n\nexport function onAppShow(callback: AppShowCallback) {\n appLifecycle.onAppShow(callback)\n}\n\nexport function navigateTo(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.push(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('push')\n }\n return resolveRouteAction('navigateTo', options, succeeded)\n}\n\nexport function redirectTo(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.replace(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('redirectTo', options, succeeded)\n}\n\nexport function reLaunch(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.relaunch(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('reLaunch', options, succeeded)\n}\n\nexport function switchTab(options: RouteOptions) {\n return performSwitchTab(options)\n}\n\nexport function navigateBack(options?: NavigateBackOptions) {\n const succeeded = pageStack.back(options?.delta)\n if (succeeded) {\n syncTabBarRoute(pageStack.entries[pageStack.entries.length - 1]?.id ?? '')\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('navigateBack', options, succeeded)\n}\n\nexport function getCurrentPagesInternal() {\n return resolveCurrentPages<ComponentPublicInstance>(pageStack.entries)\n}\n\nexport function getAppInstance() {\n return appLifecycle.instance\n}\n\nexport function getLaunchOptionsSync() {\n return appLifecycle.getLaunchOptions()\n}\n\nexport function getEnterOptionsSync() {\n return appLifecycle.getEnterOptions()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,+BAAe,IAAI,IAAwB;AACjD,MAAM,oCAAoB,IAAI,IAA6B;AAC3D,IAAI,YAAsB,CAAC;AAC3B,IAAI,wBAAwB;AAE5B,IAAI;AACJ,MAAM,eAAe,IAAI,0BACjB,WAAW,QAAQ,UAAU,QAAQ,SAAS,EACtD;AACA,YAAY,IAAI,iBAAiB,eAAc,UAAS,aAAa,eAAe,KAAK,CAAC;AAE1F,SAAS,yBAAyB;CAChC,MAAM,UAAU,UAAU,QAAQ,UAAU,QAAQ,SAAS;CAC7D,oBAAoB;EAClB,OAAO,SAAS;EAChB,OAAO,UAAU,aAAa,IAAI,QAAQ,EAAE,CAAC,EAAE,eAAe,QAAQ;CACxE,CAAC;A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B;AAEA,SAAgB,uBAAuB;CACrC,OAAO,aAAa,iBAAiB;AACvC;AAEA,SAAgB,sBAAsB;CACpC,OAAO,aAAa,gBAAgB;AACtC"}
1
+ {"version":3,"file":"routeRuntime.mjs","names":[],"sources":["../../../src/runtime/polyfill/routeRuntime.ts"],"sourcesContent":["import type { ResolvedStyleUnitOptions } from '../../shared/styleUnits/options'\nimport type { WebTabBarConfig } from '../../shared/tabBar'\nimport type { ButtonFormConfig } from '../button'\nimport type { ComponentPublicInstance } from '../component'\nimport type { NavigationBarMetrics } from '../navigationBar'\nimport type { WebResourceHintsConfig, WebSeoConfig } from '../seo'\nimport type { WebViewportConfig } from '../viewport'\nimport type { WebRouteHistoryState, WebRouteTarget, WebRoutingConfig } from './routeRuntime/history'\nimport type { AppHideCallback, AppRuntime, AppShowCallback, ComponentRawOptions, ComponentRecord, NavigateBackOptions, PageRawOptions, PageRecord, RegisterMeta, RouteOptions } from './routeRuntime/options'\nimport { slugify } from '../../shared/slugify'\nimport { resolveStyleUnitOptions } from '../../shared/styleUnits/options'\nimport {\n configureTabBar,\n getTabBarPagePaths,\n syncTabBarRoute,\n} from '../appShell/tabBar'\nimport { setAppStyle } from '../appStyle'\nimport { setButtonFormConfig } from '../button'\nimport { defineComponent } from '../component'\nimport { setRuntimeExecutionMode } from '../execution'\nimport { configureInlineStyleUnits } from '../inlineStyle'\nimport { ensureNativeComponentsDefined } from '../nativeComponents'\nimport { ensureNavigationBarDefined, setNavigationBarMetrics } from '../navigationBar'\nimport { setupRpx } from '../rpx'\nimport { configureWebSeo, setupWebResourceHints, syncWebDocumentHead } from '../seo'\nimport { setupWebViewport } from '../viewport'\nimport { setRuntimeWarningOptions } from '../warning'\nimport { resolveCurrentPages } from './appState'\nimport { AppLifecycleRuntime } from './routeRuntime/appLifecycle'\nimport { getEntryWebviewId } from './routeRuntime/events'\nimport {\n configureWebRouting,\n getWebHistoryStack,\n readWebRouteTarget,\n syncWebRouting,\n} from './routeRuntime/history'\nimport {\n augmentPageComponentOptions,\n dispatchPageLifetimeToComponents,\n} from './routeRuntime/lifecycle'\nimport {\n normalizeComponentOptions,\n normalizePageOptions,\n} from './routeRuntime/options'\nimport { resolveRouteAction } from './routeRuntime/result'\nimport { PageStackRuntime } from './routeRuntime/stack'\nimport { parsePageUrl } from './routeRuntime/url'\n\nconst pageRegistry = new Map<string, PageRecord>()\nconst componentRegistry = new Map<string, ComponentRecord>()\nlet pageOrder: string[] = []\nlet pageResizeBridgeBound = false\n\nlet pageStack: PageStackRuntime\nconst appLifecycle = new AppLifecycleRuntime(\n () => pageStack?.entries[pageStack.entries.length - 1],\n)\npageStack = new PageStackRuntime(pageRegistry, entry => appLifecycle.ensureLaunched(entry))\n\nfunction syncCurrentWebDocument() {\n const current = pageStack.entries[pageStack.entries.length - 1]\n syncWebDocumentHead({\n route: current?.id,\n title: current ? pageRegistry.get(current.id)?.navigationBar?.title : undefined,\n })\n}\n\nfunction syncCurrentWebRoute(operation: 'push' | 'replace') {\n syncWebRouting(pageStack.entries, operation)\n syncCurrentWebDocument()\n}\n\nfunction reconcileWebRoute(target: WebRouteTarget | undefined, state: WebRouteHistoryState | undefined) {\n const currentEntries = pageStack.entries\n const historyStack = getWebHistoryStack(state)\n if (historyStack?.length) {\n if (historyStack.some(entry => !pageRegistry.has(entry.id))) {\n return\n }\n const sharedLength = Math.min(historyStack.length, currentEntries.length)\n const samePrefix = historyStack.slice(0, sharedLength).every((entry, index) => {\n const current = currentEntries[index]!\n return entry.id === current.id\n && (entry.webviewId === undefined || entry.webviewId === getEntryWebviewId(current))\n && Object.keys(entry.query).length === Object.keys(current.query).length\n && Object.entries(entry.query).every(([key, value]) => current.query[key] === value)\n })\n if (samePrefix && historyStack.length === currentEntries.length) {\n return\n }\n if (samePrefix && historyStack.length < currentEntries.length) {\n pageStack.back(currentEntries.length - historyStack.length)\n }\n else if (samePrefix && historyStack.length > currentEntries.length) {\n const added = historyStack.slice(currentEntries.length)\n if (added.length === 1) {\n pageStack.push(added[0]!.id, { ...added[0]!.query })\n }\n else {\n pageStack.forward(added)\n }\n }\n else {\n const last = historyStack[historyStack.length - 1]!\n if (getTabBarPagePaths().has(last.id)) {\n pageStack.switchTab(last.id, { ...last.query })\n }\n else {\n pageStack.relaunch(last.id, { ...last.query })\n }\n }\n syncWebRouting(pageStack.entries, 'replace')\n syncTabBarRoute(pageStack.entries[pageStack.entries.length - 1]?.id ?? '')\n syncCurrentWebDocument()\n return\n }\n if (target && pageRegistry.has(target.id)) {\n const current = currentEntries[currentEntries.length - 1]\n if (current?.id === target.id\n && Object.keys(current.query).length === Object.keys(target.query).length\n && Object.entries(target.query).every(([key, value]) => current.query[key] === value)) {\n return\n }\n if (getTabBarPagePaths().has(target.id)) {\n pageStack.switchTab(target.id, { ...target.query })\n }\n else {\n pageStack.relaunch(target.id, { ...target.query })\n }\n syncWebRouting(pageStack.entries, 'replace')\n syncTabBarRoute(target.id)\n syncCurrentWebDocument()\n }\n}\n\nfunction performSwitchTab(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const previousLength = pageStack.entries.length\n const previousEntry = pageStack.entries[previousLength - 1]\n const succeeded = pageStack.switchTab(id, query)\n if (succeeded && (pageStack.entries.length !== previousLength || pageStack.entries.at(-1) !== previousEntry)) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('push')\n }\n return resolveRouteAction('switchTab', options, succeeded, 'not a tabBar page')\n}\n\nfunction bindPageResizeBridge() {\n if (pageResizeBridgeBound || typeof window === 'undefined') {\n return\n }\n if (typeof window.addEventListener !== 'function') {\n return\n }\n pageResizeBridgeBound = true\n window.addEventListener('resize', () => {\n const pages = resolveCurrentPages<ComponentPublicInstance>(pageStack.entries)\n const current = pages[pages.length - 1]\n if (!current) {\n return\n }\n dispatchPageLifetimeToComponents(current, 'resize')\n })\n}\n\nexport function initializePageRoutes(\n ids: string[],\n options?: {\n rpx?: { designWidth?: number, varName?: string }\n styleUnits?: ResolvedStyleUnitOptions\n navigationBar?: NavigationBarMetrics\n form?: ButtonFormConfig\n tabBar?: WebTabBarConfig\n runtime?: {\n executionMode?: 'compat' | 'safe' | 'strict'\n warnings?: {\n level?: 'off' | 'warn' | 'error'\n dedupe?: boolean\n }\n viewport?: WebViewportConfig\n routing?: WebRoutingConfig\n seo?: WebSeoConfig\n resourceHints?: WebResourceHintsConfig\n }\n },\n) {\n const styleUnits = options?.styleUnits ?? resolveStyleUnitOptions({\n designWidth: options?.rpx?.designWidth,\n rpxVar: options?.rpx?.varName,\n })\n configureInlineStyleUnits(styleUnits)\n setRuntimeExecutionMode(options?.runtime?.executionMode)\n setRuntimeWarningOptions(options?.runtime?.warnings)\n setupWebViewport(options?.runtime?.viewport)\n // 空路由也可供旧模板初始化;变量写入与内联转换共享同一优先级和重置语义。\n setupRpx(options?.styleUnits?.useVariable\n ? { designWidth: styleUnits.designWidth, varName: styleUnits.rpxVar }\n : options?.rpx)\n configureWebSeo(options?.runtime?.seo)\n setupWebResourceHints(options?.runtime?.resourceHints)\n configureWebRouting(options?.runtime?.routing, ids, reconcileWebRoute)\n appLifecycle.bindVisibility()\n ensureNativeComponentsDefined()\n pageOrder = Array.from(new Set(ids))\n configureTabBar(options?.tabBar, url => performSwitchTab({ url }))\n pageStack.configureTabPages(getTabBarPagePaths())\n if (!pageOrder.length) {\n return\n }\n bindPageResizeBridge()\n if (options?.navigationBar) {\n setNavigationBarMetrics(options.navigationBar)\n }\n if (options?.form) {\n setButtonFormConfig(options.form)\n }\n if (!pageStack.entries.length) {\n const initialTarget = readWebRouteTarget(pageOrder)\n const initialId = initialTarget?.id ?? pageOrder[0]\n const initialQuery = initialTarget?.query ?? {}\n if (pageStack.push(initialId, initialQuery, 'appLaunch')) {\n syncTabBarRoute(initialId)\n syncCurrentWebRoute('replace')\n }\n }\n}\n\nexport function registerPage<T extends PageRawOptions | undefined>(options: T, meta: RegisterMeta): T {\n ensureNativeComponentsDefined()\n ensureNavigationBarDefined()\n const tag = slugify(meta.id, 'wv-page')\n const template = meta.template ?? (() => '')\n const normalized = normalizePageOptions(options)\n const existing = pageRegistry.get(meta.id)\n if (existing) {\n existing.hooks = normalized.hooks\n existing.navigationBar = meta.navigationBar\n const component = augmentPageComponentOptions(normalized.component, existing)\n defineComponent(tag, {\n id: meta.id,\n kind: 'page',\n template,\n style: meta.style,\n component,\n })\n return options\n }\n const record: PageRecord = {\n tag,\n hooks: normalized.hooks,\n instances: new Set(),\n navigationBar: meta.navigationBar,\n }\n const component = augmentPageComponentOptions(normalized.component, record)\n defineComponent(tag, {\n id: meta.id,\n kind: 'page',\n template,\n style: meta.style,\n component,\n })\n pageRegistry.set(meta.id, record)\n return options\n}\n\nexport function getCurrentPageInstance(): ComponentPublicInstance | undefined {\n return pageStack.entries[pageStack.entries.length - 1]?.instance\n}\n\nexport function registerComponent<T extends ComponentRawOptions | undefined>(options: T, meta: RegisterMeta): T {\n ensureNativeComponentsDefined()\n const tag = slugify(meta.id, 'wv-component')\n const template = meta.template ?? (() => '')\n const component = normalizeComponentOptions(options)\n if (componentRegistry.has(meta.id)) {\n defineComponent(tag, {\n id: meta.id,\n template,\n style: meta.style,\n component,\n })\n return options\n }\n defineComponent(tag, {\n id: meta.id,\n template,\n style: meta.style,\n component,\n })\n componentRegistry.set(meta.id, { tag })\n return options\n}\n\nexport function registerApp<T extends AppRuntime | undefined>(options: T, meta?: RegisterMeta): T {\n setAppStyle(meta?.style ?? '')\n return appLifecycle.register(options)\n}\n\nexport function offAppHide(callback?: AppHideCallback) {\n appLifecycle.offAppHide(callback)\n}\n\nexport function offAppShow(callback?: AppShowCallback) {\n appLifecycle.offAppShow(callback)\n}\n\nexport function onAppHide(callback: AppHideCallback) {\n appLifecycle.onAppHide(callback)\n}\n\nexport function onAppShow(callback: AppShowCallback) {\n appLifecycle.onAppShow(callback)\n}\n\nexport function navigateTo(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.push(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('push')\n }\n return resolveRouteAction('navigateTo', options, succeeded)\n}\n\nexport function redirectTo(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.replace(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('redirectTo', options, succeeded)\n}\n\nexport function reLaunch(options: RouteOptions) {\n const { id, query } = parsePageUrl(options?.url ?? '')\n const succeeded = pageStack.relaunch(id, query)\n if (succeeded) {\n syncTabBarRoute(id)\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('reLaunch', options, succeeded)\n}\n\nexport function switchTab(options: RouteOptions) {\n return performSwitchTab(options)\n}\n\nexport function navigateBack(options?: NavigateBackOptions) {\n const succeeded = pageStack.back(options?.delta)\n if (succeeded) {\n syncTabBarRoute(pageStack.entries[pageStack.entries.length - 1]?.id ?? '')\n syncCurrentWebRoute('replace')\n }\n return resolveRouteAction('navigateBack', options, succeeded)\n}\n\nexport function getCurrentPagesInternal() {\n return resolveCurrentPages<ComponentPublicInstance>(pageStack.entries)\n}\n\nexport function getAppInstance() {\n return appLifecycle.instance\n}\n\nexport function getLaunchOptionsSync() {\n return appLifecycle.getLaunchOptions()\n}\n\nexport function getEnterOptionsSync() {\n return appLifecycle.getEnterOptions()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,+BAAe,IAAI,IAAwB;AACjD,MAAM,oCAAoB,IAAI,IAA6B;AAC3D,IAAI,YAAsB,CAAC;AAC3B,IAAI,wBAAwB;AAE5B,IAAI;AACJ,MAAM,eAAe,IAAI,0BACjB,WAAW,QAAQ,UAAU,QAAQ,SAAS,EACtD;AACA,YAAY,IAAI,iBAAiB,eAAc,UAAS,aAAa,eAAe,KAAK,CAAC;AAE1F,SAAS,yBAAyB;CAChC,MAAM,UAAU,UAAU,QAAQ,UAAU,QAAQ,SAAS;CAC7D,oBAAoB;EAClB,OAAO,SAAS;EAChB,OAAO,UAAU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AU,QAAQ,UAAU,QAAQ,SAAS,EAAE,EAAE,MAAM,EAAE;EACzE,oBAAoB,SAAS;CAC/B;CACA,OAAO,mBAAmB,gBAAgB,SAAS,SAAS;AAC9D;AAEA,SAAgB,0BAA0B;CACxC,OAAO,oBAA6C,UAAU,OAAO;AACvE;AAEA,SAAgB,iBAAiB;CAC/B,OAAO,aAAa;AACtB;AAEA,SAAgB,uBAAuB;CACrC,OAAO,aAAa,iBAAiB;AACvC;AAEA,SAAgB,sBAAsB;CACpC,OAAO,aAAa,gBAAgB;AACtC"}
@@ -2,7 +2,7 @@ import { addNetworkStatusCallback, removeNetworkStatusCallback } from "./network
2
2
  import { checkRuntimeCapability } from "./capability.mjs";
3
3
  import { addWindowResizeCallback, removeWindowResizeCallback } from "./windowResize.mjs";
4
4
 
5
- //#region src/runtime/polyfill/runtimeCapabilityApi.ts
5
+ // src/runtime/polyfill/runtimeCapabilityApi.ts
6
6
  function onNetworkStatusChangeBridge(callback) {
7
7
  if (typeof callback !== "function") return;
8
8
  addNetworkStatusCallback(callback);
@@ -21,6 +21,5 @@ function canIUseBridge(miniProgramBridge, schema) {
21
21
  return checkRuntimeCapability(miniProgramBridge, schema);
22
22
  }
23
23
 
24
- //#endregion
25
24
  export { canIUseBridge, offNetworkStatusChangeBridge, offWindowResizeBridge, onNetworkStatusChangeBridge, onWindowResizeBridge };
26
25
  //# sourceMappingURL=runtimeCapabilityApi.mjs.map
@@ -2,7 +2,6 @@ import { MiniProgramAsyncOptions, MiniProgramBaseResult } from "./types/base.mjs
2
2
  import { DownloadFileOptions, FileSystemManager, GetStorageOptions, RemoveStorageOptions, RequestOptions, SetStorageOptions, StorageInfoResult, UploadFileOptions, WorkerBridge } from "./types/common.mjs";
3
3
  import { LoadSubPackageOptions, NavigateToMiniProgramOptions, PreloadSubpackageOptions } from "./types/locationRuntime.mjs";
4
4
  import { CanvasContext, PageScrollToOptions, SelectorQuery, VideoContext, VkSession } from "./types/platformRuntime.mjs";
5
- //#region src/runtime/polyfill/runtimeDataApi.d.ts
6
5
  export declare function navigateToMiniProgram(options?: NavigateToMiniProgramOptions): Promise<{
7
6
  errMsg: string;
8
7
  }>;
@@ -73,5 +72,4 @@ export declare function uploadFile(options?: UploadFileOptions): Promise<{
73
72
  statusCode: number;
74
73
  header: Record<string, string>;
75
74
  }>;
76
- //#endregion
77
75
  //# sourceMappingURL=runtimeDataApi.d.mts.map
@@ -9,7 +9,7 @@ import { hideKeyboardBridge, loadSubPackageBridge, nextTickBridge, pageScrollToB
9
9
  import { clearStorageBridge, getStorageBridge, getStorageInfoBridge, removeStorageBridge, setStorageBridge } from "./storageAsync.mjs";
10
10
  import { createVideoContextBridge } from "./videoContext.mjs";
11
11
 
12
- //#region src/runtime/polyfill/runtimeDataApi.ts
12
+ // src/runtime/polyfill/runtimeDataApi.ts
13
13
  var runtimeDataApi_exports = /* @__PURE__ */ __exportAll({
14
14
  clearStorage: () => clearStorage,
15
15
  clearStorageSync: () => clearStorageSync,
@@ -134,6 +134,5 @@ async function uploadFile(options) {
134
134
  return uploadFileByFetchBridge(options);
135
135
  }
136
136
 
137
- //#endregion
138
137
  export { clearStorage, clearStorageSync, createCanvasContext, createIntersectionObserver, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, runtimeDataApi_exports, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile };
139
138
  //# sourceMappingURL=runtimeDataApi.mjs.map
@@ -3,7 +3,7 @@ import { clearStorageSyncInternal, getStorageInfoSyncInternal, getStorageSyncInt
3
3
  import { createVkSessionBridge } from "./vkSession.mjs";
4
4
  import { createWorkerBridge } from "./worker.mjs";
5
5
 
6
- //#region src/runtime/polyfill/runtimeInfra.ts
6
+ // src/runtime/polyfill/runtimeInfra.ts
7
7
  function setStorageSyncBridge(key, data) {
8
8
  const normalizedKey = normalizeStorageKey(key);
9
9
  if (!normalizedKey) throw new TypeError("setStorageSync:fail invalid key");
@@ -35,6 +35,5 @@ function createVKSessionBridgeApi() {
35
35
  return createVkSessionBridge();
36
36
  }
37
37
 
38
- //#endregion
39
38
  export { clearStorageSyncBridge, createFileSystemManagerBridgeApi, createVKSessionBridgeApi, createWorkerBridgeApi, getStorageInfoSyncBridge, getStorageSyncBridge, removeStorageSyncBridge, setStorageSyncBridge };
40
39
  //# sourceMappingURL=runtimeInfra.mjs.map
@@ -2,7 +2,7 @@ import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess, normalizeDura
2
2
  import { resolveSubPackageName } from "./platformRuntime.mjs";
3
3
  import { getPageContainer, recordActiveEntryScrollPosition } from "./routeRuntime/scroll.mjs";
4
4
 
5
- //#region src/runtime/polyfill/runtimeOps.ts
5
+ // src/runtime/polyfill/runtimeOps.ts
6
6
  function resolveScrollTop(value) {
7
7
  if (typeof value !== "number" || Number.isNaN(value)) return 0;
8
8
  return Math.max(0, value);
@@ -61,6 +61,5 @@ function pageScrollToBridge(options) {
61
61
  });
62
62
  }
63
63
 
64
- //#endregion
65
64
  export { hideKeyboardBridge, loadSubPackageBridge, nextTickBridge, pageScrollToBridge, preloadSubpackageBridge, startPullDownRefreshBridge, stopPullDownRefreshBridge };
66
65
  //# sourceMappingURL=runtimeOps.mjs.map
@@ -1,6 +1,7 @@
1
+ import { readRuntimeDataset } from "../dataset.mjs";
1
2
  import { resolveComponentPublicInstanceTarget } from "../component/publicInstance.mjs";
2
3
 
3
- //#region src/runtime/polyfill/selectorQuery.ts
4
+ // src/runtime/polyfill/selectorQuery.ts
4
5
  function isQueryRoot(value) {
5
6
  if (!value || typeof value !== "object") return false;
6
7
  const target = value;
@@ -135,7 +136,7 @@ function readNodeFields(node, fields) {
135
136
  const elementWithId = element;
136
137
  result.id = elementWithId.id ?? elementWithId.getAttribute?.("id") ?? "";
137
138
  }
138
- if (fields.dataset) result.dataset = { ...element.dataset ?? {} };
139
+ if (fields.dataset) result.dataset = readRuntimeDataset(element);
139
140
  if (fields.rect || fields.size) {
140
141
  const rect = readNodeRect(node);
141
142
  if (rect) {
@@ -255,6 +256,5 @@ function createSelectorQueryBridge() {
255
256
  return queryApi;
256
257
  }
257
258
 
258
- //#endregion
259
259
  export { createSelectorQueryBridge, resolveSelectorTargets };
260
260
  //# sourceMappingURL=selectorQuery.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectorQuery.mjs","names":[],"sources":["../../../src/runtime/polyfill/selectorQuery.ts"],"sourcesContent":["import type {\n SelectorQuery,\n SelectorQueryNodeCallback,\n SelectorQueryNodeFields,\n SelectorQueryNodesRef,\n SelectorQueryTask,\n SelectorTargetDescriptor,\n} from './selectorQueryTypes'\nimport { resolveComponentPublicInstanceTarget } from '../component/publicInstance'\n\nfunction isQueryRoot(value: unknown): value is ParentNode {\n if (!value || typeof value !== 'object') {\n return false\n }\n const target = value as {\n querySelector?: (selector: string) => unknown\n querySelectorAll?: (selector: string) => ArrayLike<unknown>\n }\n return typeof target.querySelector === 'function' && typeof target.querySelectorAll === 'function'\n}\n\nfunction resolveScopedQueryRoot(scope: unknown): ParentNode | undefined {\n const normalizedScope = resolveComponentPublicInstanceTarget(scope) ?? scope\n const scoped = normalizedScope as {\n renderRoot?: unknown\n shadowRoot?: unknown\n $el?: unknown\n } | undefined\n if (isQueryRoot(scoped?.renderRoot)) {\n return scoped?.renderRoot\n }\n if (isQueryRoot(scoped?.shadowRoot)) {\n return scoped?.shadowRoot\n }\n const publicElement = (resolveComponentPublicInstanceTarget(scoped?.$el) ?? scoped?.$el) as {\n renderRoot?: unknown\n shadowRoot?: unknown\n } | undefined\n if (isQueryRoot(publicElement?.renderRoot)) {\n return publicElement.renderRoot\n }\n if (isQueryRoot(publicElement?.shadowRoot)) {\n return publicElement.shadowRoot\n }\n if (isQueryRoot(scoped?.$el)) {\n return scoped?.$el\n }\n if (isQueryRoot(normalizedScope)) {\n return normalizedScope\n }\n return undefined\n}\n\nfunction resolveCurrentPageQueryRoot() {\n const getCurrentPages = (globalThis as {\n getCurrentPages?: () => unknown[]\n }).getCurrentPages\n const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : []\n return resolveScopedQueryRoot(pages[pages.length - 1])\n}\n\nfunction resolveQueryRoot(scope: unknown): ParentNode | undefined {\n const scopedRoot = resolveScopedQueryRoot(scope)\n if (scopedRoot) {\n return scopedRoot\n }\n if (scope == null) {\n const currentPageRoot = resolveCurrentPageQueryRoot()\n if (currentPageRoot) {\n return currentPageRoot\n }\n }\n if (typeof document !== 'undefined' && isQueryRoot(document)) {\n return document\n }\n return undefined\n}\n\nfunction resolveViewportTarget() {\n if (typeof window !== 'undefined') {\n return window\n }\n return undefined\n}\n\nfunction resolveUpdateComplete(scope: unknown): PromiseLike<unknown> | undefined {\n const normalizedScope = resolveComponentPublicInstanceTarget(scope) ?? scope\n const scoped = normalizedScope as {\n updateComplete?: unknown\n $el?: unknown\n } | undefined\n const publicElement = (resolveComponentPublicInstanceTarget(scoped?.$el) ?? scoped?.$el) as {\n updateComplete?: unknown\n } | undefined\n const candidate = publicElement?.updateComplete ?? scoped?.updateComplete\n if (\n candidate\n && typeof candidate === 'object'\n && typeof (candidate as PromiseLike<unknown>).then === 'function'\n ) {\n return candidate as PromiseLike<unknown>\n }\n return undefined\n}\n\nfunction resolveQueryTargets(scope: unknown, target: SelectorTargetDescriptor): unknown[] {\n if (target.type === 'viewport') {\n const viewport = resolveViewportTarget()\n return viewport ? [viewport] : []\n }\n const root = resolveQueryRoot(scope)\n if (!root || !target.selector) {\n return []\n }\n const query = (queryRoot: ParentNode) => {\n if (target.multiple) {\n return Array.from(queryRoot.querySelectorAll(target.selector!))\n }\n const node = queryRoot.querySelector(target.selector!)\n return node ? [node] : []\n }\n const scopedTargets = query(root)\n if (scopedTargets.length > 0) {\n return scopedTargets\n }\n\n const scopedPublicElement = (scope as { $?: unknown, $el?: unknown } | undefined)?.$el\n const publicElement = (resolveComponentPublicInstanceTarget(scopedPublicElement) ?? scopedPublicElement) as {\n getRootNode?: () => unknown\n } | undefined\n if (!(scope && typeof scope === 'object' && '$' in scope)) {\n return []\n }\n\n if (typeof publicElement?.getRootNode === 'function') {\n let ancestorRoot = publicElement.getRootNode()\n const visited = new Set<unknown>()\n while (isQueryRoot(ancestorRoot) && !visited.has(ancestorRoot)) {\n visited.add(ancestorRoot)\n const ancestorTargets = query(ancestorRoot)\n if (ancestorTargets.length > 0) {\n return ancestorTargets\n }\n const host = (ancestorRoot as { host?: { getRootNode?: () => unknown } }).host\n ancestorRoot = host?.getRootNode?.()\n }\n }\n\n const currentPageRoot = resolveCurrentPageQueryRoot()\n if (currentPageRoot && currentPageRoot !== root) {\n return query(currentPageRoot)\n }\n return []\n}\n\nexport function resolveSelectorTargets(scope: unknown, selector: string, multiple = false) {\n return resolveQueryTargets(scope, { type: 'node', selector, multiple })\n}\n\nfunction normalizeRectValue(value: unknown) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return 0\n }\n return value\n}\n\nfunction getViewportRect() {\n const runtimeWindow = typeof window !== 'undefined' ? window : undefined\n const width = normalizeRectValue(runtimeWindow?.innerWidth)\n const height = normalizeRectValue(runtimeWindow?.innerHeight)\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n }\n}\n\nfunction readNodeRect(node: unknown) {\n if (!node) {\n return null\n }\n if ((typeof window !== 'undefined' && node === window) || node === globalThis) {\n return getViewportRect()\n }\n const target = node as {\n getBoundingClientRect?: () => {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: number\n height?: number\n }\n }\n if (typeof target.getBoundingClientRect !== 'function') {\n return null\n }\n const rect = target.getBoundingClientRect()\n const left = normalizeRectValue(rect.left)\n const top = normalizeRectValue(rect.top)\n const width = normalizeRectValue(rect.width)\n const height = normalizeRectValue(rect.height)\n const right = rect.right == null ? left + width : normalizeRectValue(rect.right)\n const bottom = rect.bottom == null ? top + height : normalizeRectValue(rect.bottom)\n return { left, top, right, bottom, width, height }\n}\n\nfunction readNodeScrollOffset(node: unknown) {\n if ((typeof window !== 'undefined' && node === window) || node === globalThis) {\n const runtimeWindow = (typeof window !== 'undefined'\n ? (window as unknown as Record<string, unknown>)\n : (globalThis as Record<string, unknown>))\n return {\n scrollLeft: normalizeRectValue(\n (runtimeWindow.pageXOffset as number | undefined) ?? (runtimeWindow.scrollX as number | undefined),\n ),\n scrollTop: normalizeRectValue(\n (runtimeWindow.pageYOffset as number | undefined) ?? (runtimeWindow.scrollY as number | undefined),\n ),\n }\n }\n const target = node as {\n scrollLeft?: number\n scrollTop?: number\n }\n return {\n scrollLeft: normalizeRectValue(target?.scrollLeft),\n scrollTop: normalizeRectValue(target?.scrollTop),\n }\n}\n\nfunction readNodeFields(node: unknown, fields: SelectorQueryNodeFields) {\n if (!node) {\n return null\n }\n const result: Record<string, any> = {}\n const element = node as HTMLElement\n\n if (fields.id) {\n const elementWithId = element as { id?: string, getAttribute?: (name: string) => string | null }\n result.id = elementWithId.id ?? elementWithId.getAttribute?.('id') ?? ''\n }\n if (fields.dataset) {\n result.dataset = { ...(element.dataset ?? {}) }\n }\n if (fields.rect || fields.size) {\n const rect = readNodeRect(node)\n if (rect) {\n if (fields.rect) {\n result.left = rect.left\n result.top = rect.top\n result.right = rect.right\n result.bottom = rect.bottom\n }\n if (fields.size) {\n result.width = rect.width\n result.height = rect.height\n }\n }\n }\n if (fields.scrollOffset) {\n Object.assign(result, readNodeScrollOffset(node))\n }\n if (fields.properties?.length) {\n for (const key of fields.properties) {\n result[key] = (node as Record<string, unknown>)[key]\n }\n }\n if (fields.computedStyle?.length && typeof getComputedStyle === 'function' && node instanceof HTMLElement) {\n const style = getComputedStyle(node)\n for (const key of fields.computedStyle) {\n result[key] = style.getPropertyValue(key)\n }\n }\n if (fields.node) {\n result.node = node\n }\n if (fields.context) {\n result.context = node\n }\n return result\n}\n\nfunction mapQueryResult(target: SelectorTargetDescriptor, items: unknown[], mapper: (node: unknown) => any) {\n if (target.type === 'node' && target.multiple) {\n return items.map(item => mapper(item))\n }\n const first = items[0]\n if (!first) {\n return null\n }\n return mapper(first)\n}\n\nfunction runQueryTask(scope: unknown, task: SelectorQueryTask) {\n const targets = resolveQueryTargets(scope, task.target)\n if (task.type === 'boundingClientRect') {\n return mapQueryResult(task.target, targets, node => readNodeRect(node))\n }\n if (task.type === 'scrollOffset') {\n return mapQueryResult(task.target, targets, node => readNodeScrollOffset(node))\n }\n if (task.type === 'fields') {\n return mapQueryResult(task.target, targets, node => readNodeFields(node, task.fields))\n }\n return mapQueryResult(task.target, targets, node => ({ node }))\n}\n\nfunction createNodesRef(\n tasks: SelectorQueryTask[],\n queryApi: SelectorQuery,\n target: SelectorTargetDescriptor,\n): SelectorQueryNodesRef {\n return {\n boundingClientRect(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'boundingClientRect', target, callback })\n return queryApi\n },\n scrollOffset(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'scrollOffset', target, callback })\n return queryApi\n },\n fields(fields: SelectorQueryNodeFields, callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'fields', target, fields, callback })\n return queryApi\n },\n node(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'node', target, callback })\n return queryApi\n },\n }\n}\n\nexport function createSelectorQueryBridge() {\n let scope: unknown\n const tasks: SelectorQueryTask[] = []\n\n const queryApi: SelectorQuery = {\n in(context?: unknown) {\n scope = context\n return queryApi\n },\n select(selector: string) {\n return createNodesRef(tasks, queryApi, { type: 'node', selector, multiple: false })\n },\n selectAll(selector: string) {\n return createNodesRef(tasks, queryApi, { type: 'node', selector, multiple: true })\n },\n selectViewport() {\n return createNodesRef(tasks, queryApi, { type: 'viewport' })\n },\n exec(callback?: (result: any[]) => void) {\n const pendingTasks = tasks.splice(0)\n const run = () => {\n const result = pendingTasks.map((task) => {\n const value = runQueryTask(scope, task)\n task.callback?.(value)\n return value\n })\n callback?.(result)\n }\n const updateComplete = resolveUpdateComplete(scope)\n if (updateComplete) {\n void Promise.resolve(updateComplete).then(run)\n }\n else {\n run()\n }\n return queryApi\n },\n }\n\n return queryApi\n}\n"],"mappings":";;;AAUA,SAAS,YAAY,OAAqC;CACxD,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO;CAET,MAAM,SAAS;CAIf,OAAO,OAAO,OAAO,kBAAkB,cAAc,OAAO,OAAO,qBAAqB;AAC1F;AAEA,SAAS,uBAAuB,OAAwC;CACtE,MAAM,kBAAkB,qCAAqC,KAAK,KAAK;CACvE,MAAM,SAAS;CAKf,IAAI,YAAY,QAAQ,UAAU,GAChC,OAAO,QAAQ;CAEjB,IAAI,YAAY,QAAQ,UAAU,GAChC,OAAO,QAAQ;CAEjB,MAAM,gBAAiB,qCAAqC,QAAQ,GAAG,KAAK,QAAQ;CAIpF,IAAI,YAAY,eAAe,UAAU,GACvC,OAAO,cAAc;CAEvB,IAAI,YAAY,eAAe,UAAU,GACvC,OAAO,cAAc;CAEvB,IAAI,YAAY,QAAQ,GAAG,GACzB,OAAO,QAAQ;CAEjB,IAAI,YAAY,eAAe,GAC7B,OAAO;AAGX;AAEA,SAAS,8BAA8B;CACrC,MAAM,kBAAmB,WAEtB;CACH,MAAM,QAAQ,OAAO,oBAAoB,aAAa,gBAAgB,IAAI,CAAC;CAC3E,OAAO,uBAAuB,MAAM,MAAM,SAAS,EAAE;AACvD;AAEA,SAAS,iBAAiB,OAAwC;CAChE,MAAM,aAAa,uBAAuB,KAAK;CAC/C,IAAI,YACF,OAAO;CAET,IAAI,SAAS,MAAM;EACjB,MAAM,kBAAkB,4BAA4B;EACpD,IAAI,iBACF,OAAO;CAEX;CACA,IAAI,OAAO,aAAa,eAAe,YAAY,QAAQ,GACzD,OAAO;AAGX;AAEA,SAAS,wBAAwB;CAC/B,IAAI,OAAO,WAAW,aACpB,OAAO;AAGX;AAEA,SAAS,sBAAsB,OAAkD;CAE/E,MAAM,SADkB,qCAAqC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A,iBAAiB;GACf,OAAO,eAAe,OAAO,UAAU,EAAE,MAAM,WAAW,CAAC;EAC7D;EACA,KAAK,UAAoC;GACvC,MAAM,eAAe,MAAM,OAAO,CAAC;GACnC,MAAM,YAAY;IAChB,MAAM,SAAS,aAAa,KAAK,SAAS;KACxC,MAAM,QAAQ,aAAa,OAAO,IAAI;KACtC,KAAK,WAAW,KAAK;KACrB,OAAO;IACT,CAAC;IACD,WAAW,MAAM;GACnB;GACA,MAAM,iBAAiB,sBAAsB,KAAK;GAClD,IAAI,gBACF,AAAK,QAAQ,QAAQ,cAAc,CAAC,CAAC,KAAK,GAAG;QAG7C,IAAI;GAEN,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"selectorQuery.mjs","names":[],"sources":["../../../src/runtime/polyfill/selectorQuery.ts"],"sourcesContent":["import type {\n SelectorQuery,\n SelectorQueryNodeCallback,\n SelectorQueryNodeFields,\n SelectorQueryNodesRef,\n SelectorQueryTask,\n SelectorTargetDescriptor,\n} from './selectorQueryTypes'\nimport { resolveComponentPublicInstanceTarget } from '../component/publicInstance'\nimport { readRuntimeDataset } from '../dataset'\n\nfunction isQueryRoot(value: unknown): value is ParentNode {\n if (!value || typeof value !== 'object') {\n return false\n }\n const target = value as {\n querySelector?: (selector: string) => unknown\n querySelectorAll?: (selector: string) => ArrayLike<unknown>\n }\n return typeof target.querySelector === 'function' && typeof target.querySelectorAll === 'function'\n}\n\nfunction resolveScopedQueryRoot(scope: unknown): ParentNode | undefined {\n const normalizedScope = resolveComponentPublicInstanceTarget(scope) ?? scope\n const scoped = normalizedScope as {\n renderRoot?: unknown\n shadowRoot?: unknown\n $el?: unknown\n } | undefined\n if (isQueryRoot(scoped?.renderRoot)) {\n return scoped?.renderRoot\n }\n if (isQueryRoot(scoped?.shadowRoot)) {\n return scoped?.shadowRoot\n }\n const publicElement = (resolveComponentPublicInstanceTarget(scoped?.$el) ?? scoped?.$el) as {\n renderRoot?: unknown\n shadowRoot?: unknown\n } | undefined\n if (isQueryRoot(publicElement?.renderRoot)) {\n return publicElement.renderRoot\n }\n if (isQueryRoot(publicElement?.shadowRoot)) {\n return publicElement.shadowRoot\n }\n if (isQueryRoot(scoped?.$el)) {\n return scoped?.$el\n }\n if (isQueryRoot(normalizedScope)) {\n return normalizedScope\n }\n return undefined\n}\n\nfunction resolveCurrentPageQueryRoot() {\n const getCurrentPages = (globalThis as {\n getCurrentPages?: () => unknown[]\n }).getCurrentPages\n const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : []\n return resolveScopedQueryRoot(pages[pages.length - 1])\n}\n\nfunction resolveQueryRoot(scope: unknown): ParentNode | undefined {\n const scopedRoot = resolveScopedQueryRoot(scope)\n if (scopedRoot) {\n return scopedRoot\n }\n if (scope == null) {\n const currentPageRoot = resolveCurrentPageQueryRoot()\n if (currentPageRoot) {\n return currentPageRoot\n }\n }\n if (typeof document !== 'undefined' && isQueryRoot(document)) {\n return document\n }\n return undefined\n}\n\nfunction resolveViewportTarget() {\n if (typeof window !== 'undefined') {\n return window\n }\n return undefined\n}\n\nfunction resolveUpdateComplete(scope: unknown): PromiseLike<unknown> | undefined {\n const normalizedScope = resolveComponentPublicInstanceTarget(scope) ?? scope\n const scoped = normalizedScope as {\n updateComplete?: unknown\n $el?: unknown\n } | undefined\n const publicElement = (resolveComponentPublicInstanceTarget(scoped?.$el) ?? scoped?.$el) as {\n updateComplete?: unknown\n } | undefined\n const candidate = publicElement?.updateComplete ?? scoped?.updateComplete\n if (\n candidate\n && typeof candidate === 'object'\n && typeof (candidate as PromiseLike<unknown>).then === 'function'\n ) {\n return candidate as PromiseLike<unknown>\n }\n return undefined\n}\n\nfunction resolveQueryTargets(scope: unknown, target: SelectorTargetDescriptor): unknown[] {\n if (target.type === 'viewport') {\n const viewport = resolveViewportTarget()\n return viewport ? [viewport] : []\n }\n const root = resolveQueryRoot(scope)\n if (!root || !target.selector) {\n return []\n }\n const query = (queryRoot: ParentNode) => {\n if (target.multiple) {\n return Array.from(queryRoot.querySelectorAll(target.selector!))\n }\n const node = queryRoot.querySelector(target.selector!)\n return node ? [node] : []\n }\n const scopedTargets = query(root)\n if (scopedTargets.length > 0) {\n return scopedTargets\n }\n\n const scopedPublicElement = (scope as { $?: unknown, $el?: unknown } | undefined)?.$el\n const publicElement = (resolveComponentPublicInstanceTarget(scopedPublicElement) ?? scopedPublicElement) as {\n getRootNode?: () => unknown\n } | undefined\n if (!(scope && typeof scope === 'object' && '$' in scope)) {\n return []\n }\n\n if (typeof publicElement?.getRootNode === 'function') {\n let ancestorRoot = publicElement.getRootNode()\n const visited = new Set<unknown>()\n while (isQueryRoot(ancestorRoot) && !visited.has(ancestorRoot)) {\n visited.add(ancestorRoot)\n const ancestorTargets = query(ancestorRoot)\n if (ancestorTargets.length > 0) {\n return ancestorTargets\n }\n const host = (ancestorRoot as { host?: { getRootNode?: () => unknown } }).host\n ancestorRoot = host?.getRootNode?.()\n }\n }\n\n const currentPageRoot = resolveCurrentPageQueryRoot()\n if (currentPageRoot && currentPageRoot !== root) {\n return query(currentPageRoot)\n }\n return []\n}\n\nexport function resolveSelectorTargets(scope: unknown, selector: string, multiple = false) {\n return resolveQueryTargets(scope, { type: 'node', selector, multiple })\n}\n\nfunction normalizeRectValue(value: unknown) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return 0\n }\n return value\n}\n\nfunction getViewportRect() {\n const runtimeWindow = typeof window !== 'undefined' ? window : undefined\n const width = normalizeRectValue(runtimeWindow?.innerWidth)\n const height = normalizeRectValue(runtimeWindow?.innerHeight)\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n }\n}\n\nfunction readNodeRect(node: unknown) {\n if (!node) {\n return null\n }\n if ((typeof window !== 'undefined' && node === window) || node === globalThis) {\n return getViewportRect()\n }\n const target = node as {\n getBoundingClientRect?: () => {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: number\n height?: number\n }\n }\n if (typeof target.getBoundingClientRect !== 'function') {\n return null\n }\n const rect = target.getBoundingClientRect()\n const left = normalizeRectValue(rect.left)\n const top = normalizeRectValue(rect.top)\n const width = normalizeRectValue(rect.width)\n const height = normalizeRectValue(rect.height)\n const right = rect.right == null ? left + width : normalizeRectValue(rect.right)\n const bottom = rect.bottom == null ? top + height : normalizeRectValue(rect.bottom)\n return { left, top, right, bottom, width, height }\n}\n\nfunction readNodeScrollOffset(node: unknown) {\n if ((typeof window !== 'undefined' && node === window) || node === globalThis) {\n const runtimeWindow = (typeof window !== 'undefined'\n ? (window as unknown as Record<string, unknown>)\n : (globalThis as Record<string, unknown>))\n return {\n scrollLeft: normalizeRectValue(\n (runtimeWindow.pageXOffset as number | undefined) ?? (runtimeWindow.scrollX as number | undefined),\n ),\n scrollTop: normalizeRectValue(\n (runtimeWindow.pageYOffset as number | undefined) ?? (runtimeWindow.scrollY as number | undefined),\n ),\n }\n }\n const target = node as {\n scrollLeft?: number\n scrollTop?: number\n }\n return {\n scrollLeft: normalizeRectValue(target?.scrollLeft),\n scrollTop: normalizeRectValue(target?.scrollTop),\n }\n}\n\nfunction readNodeFields(node: unknown, fields: SelectorQueryNodeFields) {\n if (!node) {\n return null\n }\n const result: Record<string, any> = {}\n const element = node as HTMLElement\n\n if (fields.id) {\n const elementWithId = element as { id?: string, getAttribute?: (name: string) => string | null }\n result.id = elementWithId.id ?? elementWithId.getAttribute?.('id') ?? ''\n }\n if (fields.dataset) {\n result.dataset = readRuntimeDataset(element)\n }\n if (fields.rect || fields.size) {\n const rect = readNodeRect(node)\n if (rect) {\n if (fields.rect) {\n result.left = rect.left\n result.top = rect.top\n result.right = rect.right\n result.bottom = rect.bottom\n }\n if (fields.size) {\n result.width = rect.width\n result.height = rect.height\n }\n }\n }\n if (fields.scrollOffset) {\n Object.assign(result, readNodeScrollOffset(node))\n }\n if (fields.properties?.length) {\n for (const key of fields.properties) {\n result[key] = (node as Record<string, unknown>)[key]\n }\n }\n if (fields.computedStyle?.length && typeof getComputedStyle === 'function' && node instanceof HTMLElement) {\n const style = getComputedStyle(node)\n for (const key of fields.computedStyle) {\n result[key] = style.getPropertyValue(key)\n }\n }\n if (fields.node) {\n result.node = node\n }\n if (fields.context) {\n result.context = node\n }\n return result\n}\n\nfunction mapQueryResult(target: SelectorTargetDescriptor, items: unknown[], mapper: (node: unknown) => any) {\n if (target.type === 'node' && target.multiple) {\n return items.map(item => mapper(item))\n }\n const first = items[0]\n if (!first) {\n return null\n }\n return mapper(first)\n}\n\nfunction runQueryTask(scope: unknown, task: SelectorQueryTask) {\n const targets = resolveQueryTargets(scope, task.target)\n if (task.type === 'boundingClientRect') {\n return mapQueryResult(task.target, targets, node => readNodeRect(node))\n }\n if (task.type === 'scrollOffset') {\n return mapQueryResult(task.target, targets, node => readNodeScrollOffset(node))\n }\n if (task.type === 'fields') {\n return mapQueryResult(task.target, targets, node => readNodeFields(node, task.fields))\n }\n return mapQueryResult(task.target, targets, node => ({ node }))\n}\n\nfunction createNodesRef(\n tasks: SelectorQueryTask[],\n queryApi: SelectorQuery,\n target: SelectorTargetDescriptor,\n): SelectorQueryNodesRef {\n return {\n boundingClientRect(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'boundingClientRect', target, callback })\n return queryApi\n },\n scrollOffset(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'scrollOffset', target, callback })\n return queryApi\n },\n fields(fields: SelectorQueryNodeFields, callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'fields', target, fields, callback })\n return queryApi\n },\n node(callback?: SelectorQueryNodeCallback) {\n tasks.push({ type: 'node', target, callback })\n return queryApi\n },\n }\n}\n\nexport function createSelectorQueryBridge() {\n let scope: unknown\n const tasks: SelectorQueryTask[] = []\n\n const queryApi: SelectorQuery = {\n in(context?: unknown) {\n scope = context\n return queryApi\n },\n select(selector: string) {\n return createNodesRef(tasks, queryApi, { type: 'node', selector, multiple: false })\n },\n selectAll(selector: string) {\n return createNodesRef(tasks, queryApi, { type: 'node', selector, multiple: true })\n },\n selectViewport() {\n return createNodesRef(tasks, queryApi, { type: 'viewport' })\n },\n exec(callback?: (result: any[]) => void) {\n const pendingTasks = tasks.splice(0)\n const run = () => {\n const result = pendingTasks.map((task) => {\n const value = runQueryTask(scope, task)\n task.callback?.(value)\n return value\n })\n callback?.(result)\n }\n const updateComplete = resolveUpdateComplete(scope)\n if (updateComplete) {\n void Promise.resolve(updateComplete).then(run)\n }\n else {\n run()\n }\n return queryApi\n },\n }\n\n return queryApi\n}\n"],"mappings":";;;;AAWA,SAAS,YAAY,OAAqC;CACxD,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO;CAET,MAAM,SAAS;CAIf,OAAO,OAAO,OAAO,kBAAkB,cAAc,OAAO,OAAO,qBAAqB;AAC1F;AAEA,SAAS,uBAAuB,OAAwC;CACtE,MAAM,kBAAkB,qCAAqC,KAAK,KAAK;CACvE,MAAM,SAAS;CAKf,IAAI,YAAY,QAAQ,UAAU,GAChC,OAAO,QAAQ;CAEjB,IAAI,YAAY,QAAQ,UAAU,GAChC,OAAO,QAAQ;CAEjB,MAAM,gBAAiB,qCAAqC,QAAQ,GAAG,KAAK,QAAQ;CAIpF,IAAI,YAAY,eAAe,UAAU,GACvC,OAAO,cAAc;CAEvB,IAAI,YAAY,eAAe,UAAU,GACvC,OAAO,cAAc;CAEvB,IAAI,YAAY,QAAQ,GAAG,GACzB,OAAO,QAAQ;CAEjB,IAAI,YAAY,eAAe,GAC7B,OAAO;AAGX;AAEA,SAAS,8BAA8B;CACrC,MAAM,kBAAmB,WAEtB;CACH,MAAM,QAAQ,OAAO,oBAAoB,aAAa,gBAAgB,IAAI,CAAC;CAC3E,OAAO,uBAAuB,MAAM,MAAM,SAAS,EAAE;AACvD;AAEA,SAAS,iBAAiB,OAAwC;CAChE,MAAM,aAAa,uBAAuB,KAAK;CAC/C,IAAI,YACF,OAAO;CAET,IAAI,SAAS,MAAM;EACjB,MAAM,kBAAkB,4BAA4B;EACpD,IAAI,iBACF,OAAO;CAEX;CACA,IAAI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,MAAM;IAAQ;IAAU,UAAU;GAAM,CAAC;EACpF;EACA,UAAU,UAAkB;GAC1B,OAAO,eAAe,OAAO,UAAU;IAAE,MAAM;IAAQ;IAAU,UAAU;GAAK,CAAC;EACnF;EACA,iBAAiB;GACf,OAAO,eAAe,OAAO,UAAU,EAAE,MAAM,WAAW,CAAC;EAC7D;EACA,KAAK,UAAoC;GACvC,MAAM,eAAe,MAAM,OAAO,CAAC;GACnC,MAAM,YAAY;IAChB,MAAM,SAAS,aAAa,KAAK,SAAS;KACxC,MAAM,QAAQ,aAAa,OAAO,IAAI;KACtC,KAAK,WAAW,KAAK;KACrB,OAAO;IACT,CAAC;IACD,WAAW,MAAM;GACnB;GACA,MAAM,iBAAiB,sBAAsB,KAAK;GAClD,IAAI,gBACF,AAAK,QAAQ,QAAQ,cAAc,CAAC,CAAC,KAAK,GAAG;QAG7C,IAAI;GAEN,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  import { getRuntimeStorage as getRuntimeStorage$1 } from "../host/index.mjs";
2
2
 
3
- //#region src/runtime/polyfill/storage.ts
3
+ // src/runtime/polyfill/storage.ts
4
4
  const WEB_STORAGE_PREFIX = "__weapp_vite_web_storage__:";
5
5
  const WEB_STORAGE_LIMIT_SIZE_KB = 10240;
6
6
  const memoryStorage = /* @__PURE__ */ new Map();
@@ -101,6 +101,5 @@ function getStorageInfoSyncInternal() {
101
101
  };
102
102
  }
103
103
 
104
- //#endregion
105
104
  export { clearStorageSyncInternal, getStorageInfoSyncInternal, getStorageSyncInternal, hasStorageKey, normalizeStorageKey, removeStorageSyncInternal, setStorageSyncInternal };
106
105
  //# sourceMappingURL=storage.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
2
2
  import { clearStorageSyncInternal, getStorageInfoSyncInternal, getStorageSyncInternal, hasStorageKey, normalizeStorageKey, removeStorageSyncInternal, setStorageSyncInternal } from "./storage.mjs";
3
3
 
4
- //#region src/runtime/polyfill/storageAsync.ts
4
+ // src/runtime/polyfill/storageAsync.ts
5
5
  function setStorageBridge(options) {
6
6
  const key = normalizeStorageKey(options?.key);
7
7
  if (!key) {
@@ -59,6 +59,5 @@ function getStorageInfoBridge(options) {
59
59
  }));
60
60
  }
61
61
 
62
- //#endregion
63
62
  export { clearStorageBridge, getStorageBridge, getStorageInfoBridge, removeStorageBridge, setStorageBridge };
64
63
  //# sourceMappingURL=storageAsync.mjs.map
@@ -1,6 +1,6 @@
1
1
  import { WEAPP_VITE_WEB_REQUEST_SUBSCRIBE_MESSAGE_KEY } from "@weapp-core/constants";
2
2
 
3
- //#region src/runtime/polyfill/subscribe.ts
3
+ // src/runtime/polyfill/subscribe.ts
4
4
  function normalizeSubscribeDecision(value) {
5
5
  if (value === "accept" || value === "reject" || value === "ban" || value === "filter") return value;
6
6
  return "accept";
@@ -25,6 +25,5 @@ function resolveSubscribeDecisionMap(tmplIds) {
25
25
  }, {});
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { normalizeSubscribeDecision, normalizeSubscribeTemplateIds, resolveSubscribeDecisionMap };
30
29
  //# sourceMappingURL=subscribe.mjs.map
@@ -1,4 +1,4 @@
1
- //#region src/runtime/polyfill/system.ts
1
+ // src/runtime/polyfill/system.ts
2
2
  function resolveSystemName(userAgent) {
3
3
  if (/android/i.test(userAgent)) return "Android";
4
4
  if (/iphone|ipad|ipod/i.test(userAgent)) return "iOS";
@@ -133,6 +133,5 @@ function buildMenuButtonRect(windowWidth, statusBarHeight) {
133
133
  };
134
134
  }
135
135
 
136
- //#endregion
137
136
  export { buildMenuButtonRect, buildWindowInfoSnapshot, normalizeMemorySize, normalizePositiveNumber, readDeviceMemorySize, readSystemInfoSnapshot, resolveAccountAppId, resolveDeviceOrientation, resolvePlatformName, resolveRuntimeTheme, resolveSystemName, rpx2px };
138
137
  //# sourceMappingURL=system.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
2
2
  import { buildMenuButtonRect, buildWindowInfoSnapshot, readDeviceMemorySize, readSystemInfoSnapshot, resolveAccountAppId, resolveDeviceOrientation, resolveRuntimeTheme } from "./system.mjs";
3
3
 
4
- //#region src/runtime/polyfill/systemApi.ts
4
+ // src/runtime/polyfill/systemApi.ts
5
5
  function getSystemInfoSyncBridge() {
6
6
  return readSystemInfoSnapshot();
7
7
  }
@@ -61,6 +61,5 @@ function getMenuButtonBoundingClientRectBridge() {
61
61
  return buildMenuButtonRect(windowWidth, statusBarHeight);
62
62
  }
63
63
 
64
- //#endregion
65
64
  export { getAccountInfoSyncBridge, getAppBaseInfoBridge, getDeviceInfoBridge, getMenuButtonBoundingClientRectBridge, getSystemInfoBridge, getSystemInfoSyncBridge, getWindowInfoBridge };
66
65
  //# sourceMappingURL=systemApi.mjs.map