@weapp-vite/web 1.3.15 → 1.3.16

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 (242) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +18 -0
  2. package/dist/compiler/wxml/attributes.mjs +93 -0
  3. package/dist/compiler/wxml/attributes.mjs.map +1 -0
  4. package/dist/compiler/wxml/compile.mjs +158 -0
  5. package/dist/compiler/wxml/compile.mjs.map +1 -0
  6. package/dist/compiler/wxml/dependency.mjs +31 -0
  7. package/dist/compiler/wxml/dependency.mjs.map +1 -0
  8. package/dist/compiler/wxml/interpolation.mjs +142 -0
  9. package/dist/compiler/wxml/interpolation.mjs.map +1 -0
  10. package/dist/compiler/wxml/navigation.mjs +85 -0
  11. package/dist/compiler/wxml/navigation.mjs.map +1 -0
  12. package/dist/compiler/wxml/parser.mjs +41 -0
  13. package/dist/compiler/wxml/parser.mjs.map +1 -0
  14. package/dist/compiler/wxml/renderer.mjs +114 -0
  15. package/dist/compiler/wxml/renderer.mjs.map +1 -0
  16. package/dist/compiler/wxml/specialNodes.mjs +84 -0
  17. package/dist/compiler/wxml/specialNodes.mjs.map +1 -0
  18. package/dist/compiler/wxs.mjs +83 -0
  19. package/dist/compiler/wxs.mjs.map +1 -0
  20. package/dist/css/wxss.d.mts +25 -0
  21. package/dist/css/wxss.mjs +17 -0
  22. package/dist/css/wxss.mjs.map +1 -0
  23. package/dist/index.d.mts +18 -2
  24. package/dist/index.mjs +18 -3
  25. package/dist/plugin/constants.mjs +43 -0
  26. package/dist/plugin/constants.mjs.map +1 -0
  27. package/dist/plugin/entry.mjs +29 -0
  28. package/dist/plugin/entry.mjs.map +1 -0
  29. package/dist/plugin/files.mjs +58 -0
  30. package/dist/plugin/files.mjs.map +1 -0
  31. package/dist/plugin/index.d.mts +33 -0
  32. package/dist/plugin/index.mjs +188 -0
  33. package/dist/plugin/index.mjs.map +1 -0
  34. package/dist/plugin/navigation.mjs +20 -0
  35. package/dist/plugin/navigation.mjs.map +1 -0
  36. package/dist/plugin/path.mjs +85 -0
  37. package/dist/plugin/path.mjs.map +1 -0
  38. package/dist/plugin/register.mjs +83 -0
  39. package/dist/plugin/register.mjs.map +1 -0
  40. package/dist/plugin/scan.mjs +195 -0
  41. package/dist/plugin/scan.mjs.map +1 -0
  42. package/dist/plugin/scanConfig.mjs +45 -0
  43. package/dist/plugin/scanConfig.mjs.map +1 -0
  44. package/dist/plugin/state.mjs +22 -0
  45. package/dist/plugin/state.mjs.map +1 -0
  46. package/dist/plugin/types.d.mts +46 -0
  47. package/dist/plugin.d.mts +3 -2
  48. package/dist/plugin.mjs +3 -2
  49. package/dist/runtime/button/helpers.mjs +92 -0
  50. package/dist/runtime/button/helpers.mjs.map +1 -0
  51. package/dist/runtime/button/index.d.mts +9 -0
  52. package/dist/runtime/button/index.mjs +198 -0
  53. package/dist/runtime/button/index.mjs.map +1 -0
  54. package/dist/runtime/button/style.mjs +168 -0
  55. package/dist/runtime/button/style.mjs.map +1 -0
  56. package/dist/runtime/component/behavior.mjs +98 -0
  57. package/dist/runtime/component/behavior.mjs.map +1 -0
  58. package/dist/runtime/component/constants.mjs +8 -0
  59. package/dist/runtime/component/constants.mjs.map +1 -0
  60. package/dist/runtime/component/dom.mjs +26 -0
  61. package/dist/runtime/component/dom.mjs.map +1 -0
  62. package/dist/runtime/component/element.mjs +208 -0
  63. package/dist/runtime/component/element.mjs.map +1 -0
  64. package/dist/runtime/component/events.mjs +48 -0
  65. package/dist/runtime/component/events.mjs.map +1 -0
  66. package/dist/runtime/component/index.d.mts +7 -0
  67. package/dist/runtime/component/index.mjs +44 -0
  68. package/dist/runtime/component/index.mjs.map +1 -0
  69. package/dist/runtime/component/state.mjs +63 -0
  70. package/dist/runtime/component/state.mjs.map +1 -0
  71. package/dist/runtime/component/types.d.mts +49 -0
  72. package/dist/runtime/component/utils.mjs +39 -0
  73. package/dist/runtime/component/utils.mjs.map +1 -0
  74. package/dist/runtime/execution.d.mts +7 -0
  75. package/dist/runtime/execution.mjs +37 -0
  76. package/dist/runtime/execution.mjs.map +1 -0
  77. package/dist/runtime/index.d.mts +16 -2
  78. package/dist/runtime/index.mjs +16 -2
  79. package/dist/runtime/legacyTemplate/dom.mjs +131 -0
  80. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -0
  81. package/dist/runtime/legacyTemplate/expression.mjs +113 -0
  82. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -0
  83. package/dist/runtime/legacyTemplate/index.d.mts +9 -0
  84. package/dist/runtime/legacyTemplate/index.mjs +131 -0
  85. package/dist/runtime/legacyTemplate/index.mjs.map +1 -0
  86. package/dist/runtime/legacyTemplate/types.d.mts +6 -0
  87. package/dist/runtime/navigationBar/index.d.mts +10 -0
  88. package/dist/runtime/navigationBar/index.mjs +162 -0
  89. package/dist/runtime/navigationBar/index.mjs.map +1 -0
  90. package/dist/runtime/navigationBar/style.mjs +108 -0
  91. package/dist/runtime/navigationBar/style.mjs.map +1 -0
  92. package/dist/runtime/polyfill/ad.mjs +150 -0
  93. package/dist/runtime/polyfill/ad.mjs.map +1 -0
  94. package/dist/runtime/polyfill/appState.mjs +31 -0
  95. package/dist/runtime/polyfill/appState.mjs.map +1 -0
  96. package/dist/runtime/polyfill/async.mjs +31 -0
  97. package/dist/runtime/polyfill/async.mjs.map +1 -0
  98. package/dist/runtime/polyfill/auth.mjs +120 -0
  99. package/dist/runtime/polyfill/auth.mjs.map +1 -0
  100. package/dist/runtime/polyfill/authApi.mjs +101 -0
  101. package/dist/runtime/polyfill/authApi.mjs.map +1 -0
  102. package/dist/runtime/polyfill/background.mjs +31 -0
  103. package/dist/runtime/polyfill/background.mjs.map +1 -0
  104. package/dist/runtime/polyfill/canvasContext.mjs +115 -0
  105. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -0
  106. package/dist/runtime/polyfill/capability.mjs +17 -0
  107. package/dist/runtime/polyfill/capability.mjs.map +1 -0
  108. package/dist/runtime/polyfill/cloud.mjs +39 -0
  109. package/dist/runtime/polyfill/cloud.mjs.map +1 -0
  110. package/dist/runtime/polyfill/device.mjs +44 -0
  111. package/dist/runtime/polyfill/device.mjs.map +1 -0
  112. package/dist/runtime/polyfill/deviceApi.mjs +31 -0
  113. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -0
  114. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +102 -0
  115. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +144 -0
  116. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -0
  117. package/dist/runtime/polyfill/filePicker.mjs +158 -0
  118. package/dist/runtime/polyfill/filePicker.mjs.map +1 -0
  119. package/dist/runtime/polyfill/fileSystemManager.mjs +45 -0
  120. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -0
  121. package/dist/runtime/polyfill/files.mjs +118 -0
  122. package/dist/runtime/polyfill/files.mjs.map +1 -0
  123. package/dist/runtime/polyfill/index.d.mts +40 -0
  124. package/dist/runtime/polyfill/index.mjs +99 -0
  125. package/dist/runtime/polyfill/index.mjs.map +1 -0
  126. package/dist/runtime/polyfill/interaction.mjs +38 -0
  127. package/dist/runtime/polyfill/interaction.mjs.map +1 -0
  128. package/dist/runtime/polyfill/interactionApi.mjs +54 -0
  129. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -0
  130. package/dist/runtime/polyfill/location.mjs +106 -0
  131. package/dist/runtime/polyfill/location.mjs.map +1 -0
  132. package/dist/runtime/polyfill/locationApi.mjs +120 -0
  133. package/dist/runtime/polyfill/locationApi.mjs.map +1 -0
  134. package/dist/runtime/polyfill/mediaActions.mjs +52 -0
  135. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -0
  136. package/dist/runtime/polyfill/mediaApi/file.mjs +63 -0
  137. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -0
  138. package/dist/runtime/polyfill/mediaApi/info.mjs +59 -0
  139. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -0
  140. package/dist/runtime/polyfill/mediaApi/picker.mjs +82 -0
  141. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -0
  142. package/dist/runtime/polyfill/mediaApi/preview.mjs +39 -0
  143. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -0
  144. package/dist/runtime/polyfill/mediaApi/process.mjs +46 -0
  145. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -0
  146. package/dist/runtime/polyfill/mediaInfo.mjs +136 -0
  147. package/dist/runtime/polyfill/mediaInfo.mjs.map +1 -0
  148. package/dist/runtime/polyfill/mediaPicker.mjs +213 -0
  149. package/dist/runtime/polyfill/mediaPicker.mjs.map +1 -0
  150. package/dist/runtime/polyfill/mediaProcess.mjs +65 -0
  151. package/dist/runtime/polyfill/mediaProcess.mjs.map +1 -0
  152. package/dist/runtime/polyfill/menuApi.mjs +70 -0
  153. package/dist/runtime/polyfill/menuApi.mjs.map +1 -0
  154. package/dist/runtime/polyfill/navigationBarRuntime.mjs +65 -0
  155. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -0
  156. package/dist/runtime/polyfill/network/request.mjs +162 -0
  157. package/dist/runtime/polyfill/network/request.mjs.map +1 -0
  158. package/dist/runtime/polyfill/network/requestBridge.mjs +49 -0
  159. package/dist/runtime/polyfill/network/requestBridge.mjs.map +1 -0
  160. package/dist/runtime/polyfill/network/status.mjs +55 -0
  161. package/dist/runtime/polyfill/network/status.mjs.map +1 -0
  162. package/dist/runtime/polyfill/platformApi.mjs +33 -0
  163. package/dist/runtime/polyfill/platformApi.mjs.map +1 -0
  164. package/dist/runtime/polyfill/platformRuntime.mjs +120 -0
  165. package/dist/runtime/polyfill/platformRuntime.mjs.map +1 -0
  166. package/dist/runtime/polyfill/routeRuntime/dom.mjs +36 -0
  167. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -0
  168. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +83 -0
  169. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -0
  170. package/dist/runtime/polyfill/routeRuntime/options.d.mts +33 -0
  171. package/dist/runtime/polyfill/routeRuntime/options.mjs +76 -0
  172. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -0
  173. package/dist/runtime/polyfill/routeRuntime/url.mjs +35 -0
  174. package/dist/runtime/polyfill/routeRuntime/url.mjs.map +1 -0
  175. package/dist/runtime/polyfill/routeRuntime.d.mts +43 -0
  176. package/dist/runtime/polyfill/routeRuntime.mjs +202 -0
  177. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -0
  178. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +26 -0
  179. package/dist/runtime/polyfill/runtimeCapabilityApi.mjs.map +1 -0
  180. package/dist/runtime/polyfill/runtimeDataApi.d.mts +79 -0
  181. package/dist/runtime/polyfill/runtimeDataApi.mjs +134 -0
  182. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -0
  183. package/dist/runtime/polyfill/runtimeInfra.mjs +40 -0
  184. package/dist/runtime/polyfill/runtimeInfra.mjs.map +1 -0
  185. package/dist/runtime/polyfill/runtimeOps.mjs +62 -0
  186. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -0
  187. package/dist/runtime/polyfill/selectorQuery.mjs +204 -0
  188. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -0
  189. package/dist/runtime/polyfill/storage.mjs +103 -0
  190. package/dist/runtime/polyfill/storage.mjs.map +1 -0
  191. package/dist/runtime/polyfill/storageAsync.mjs +62 -0
  192. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -0
  193. package/dist/runtime/polyfill/subscribe.mjs +30 -0
  194. package/dist/runtime/polyfill/subscribe.mjs.map +1 -0
  195. package/dist/runtime/polyfill/system.mjs +111 -0
  196. package/dist/runtime/polyfill/system.mjs.map +1 -0
  197. package/dist/runtime/polyfill/systemApi.mjs +65 -0
  198. package/dist/runtime/polyfill/systemApi.mjs.map +1 -0
  199. package/dist/runtime/polyfill/types/base.d.mts +12 -0
  200. package/dist/runtime/polyfill/types/common.d.mts +126 -0
  201. package/dist/runtime/polyfill/types/locationRuntime.d.mts +151 -0
  202. package/dist/runtime/polyfill/types/mediaAuth.d.mts +152 -0
  203. package/dist/runtime/polyfill/types/platformRuntime.d.mts +141 -0
  204. package/dist/runtime/polyfill/types/systemAuth.d.mts +122 -0
  205. package/dist/runtime/polyfill/ui.mjs +135 -0
  206. package/dist/runtime/polyfill/ui.mjs.map +1 -0
  207. package/dist/runtime/polyfill/uiFeedback.mjs +35 -0
  208. package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -0
  209. package/dist/runtime/polyfill/uiMediaApi.d.mts +172 -0
  210. package/dist/runtime/polyfill/uiMediaApi.mjs +162 -0
  211. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -0
  212. package/dist/runtime/polyfill/videoContext.mjs +56 -0
  213. package/dist/runtime/polyfill/videoContext.mjs.map +1 -0
  214. package/dist/runtime/polyfill/vkSession.mjs +58 -0
  215. package/dist/runtime/polyfill/vkSession.mjs.map +1 -0
  216. package/dist/runtime/polyfill/windowResize.mjs +39 -0
  217. package/dist/runtime/polyfill/windowResize.mjs.map +1 -0
  218. package/dist/runtime/polyfill/worker.mjs +77 -0
  219. package/dist/runtime/polyfill/worker.mjs.map +1 -0
  220. package/dist/runtime/polyfill.d.mts +5 -0
  221. package/dist/runtime/renderContext.d.mts +21 -0
  222. package/dist/runtime/renderContext.mjs +147 -0
  223. package/dist/runtime/renderContext.mjs.map +1 -0
  224. package/dist/runtime/rpx.d.mts +9 -0
  225. package/dist/runtime/rpx.mjs +27 -0
  226. package/dist/runtime/rpx.mjs.map +1 -0
  227. package/dist/runtime/style.d.mts +6 -0
  228. package/dist/runtime/style.mjs +37 -0
  229. package/dist/runtime/style.mjs.map +1 -0
  230. package/dist/runtime/template.d.mts +10 -0
  231. package/dist/runtime/warning.d.mts +10 -0
  232. package/dist/runtime/warning.mjs +43 -0
  233. package/dist/runtime/warning.mjs.map +1 -0
  234. package/dist/{slugify-B4l45KNs.mjs → shared/slugify.mjs} +3 -1
  235. package/dist/shared/slugify.mjs.map +1 -0
  236. package/dist/shared/wxml.mjs +64 -0
  237. package/dist/shared/wxml.mjs.map +1 -0
  238. package/package.json +1 -1
  239. package/dist/index-w9xxIH-l.d.mts +0 -1229
  240. package/dist/plugin-BARxSPO8.mjs +0 -1567
  241. package/dist/plugin-DP2iPVmw.d.mts +0 -96
  242. package/dist/runtime-D6j2_x_N.mjs +0 -6251
@@ -0,0 +1,204 @@
1
+ //#region src/runtime/polyfill/selectorQuery.ts
2
+ function isQueryRoot(value) {
3
+ if (!value || typeof value !== "object") return false;
4
+ const target = value;
5
+ return typeof target.querySelector === "function" && typeof target.querySelectorAll === "function";
6
+ }
7
+ function resolveQueryRoot(scope) {
8
+ const scoped = scope;
9
+ if (isQueryRoot(scoped?.renderRoot)) return scoped?.renderRoot;
10
+ if (isQueryRoot(scoped?.shadowRoot)) return scoped?.shadowRoot;
11
+ if (isQueryRoot(scoped?.$el)) return scoped?.$el;
12
+ if (isQueryRoot(scope)) return scope;
13
+ if (typeof document !== "undefined" && isQueryRoot(document)) return document;
14
+ }
15
+ function resolveViewportTarget() {
16
+ if (typeof window !== "undefined") return window;
17
+ }
18
+ function resolveQueryTargets(scope, target) {
19
+ if (target.type === "viewport") {
20
+ const viewport = resolveViewportTarget();
21
+ return viewport ? [viewport] : [];
22
+ }
23
+ const root = resolveQueryRoot(scope);
24
+ if (!root || !target.selector) return [];
25
+ if (target.multiple) return Array.from(root.querySelectorAll(target.selector));
26
+ const node = root.querySelector(target.selector);
27
+ return node ? [node] : [];
28
+ }
29
+ function normalizeRectValue(value) {
30
+ if (typeof value !== "number" || Number.isNaN(value)) return 0;
31
+ return value;
32
+ }
33
+ function getViewportRect() {
34
+ const runtimeWindow = typeof window !== "undefined" ? window : void 0;
35
+ const width = normalizeRectValue(runtimeWindow?.innerWidth);
36
+ const height = normalizeRectValue(runtimeWindow?.innerHeight);
37
+ return {
38
+ left: 0,
39
+ top: 0,
40
+ right: width,
41
+ bottom: height,
42
+ width,
43
+ height
44
+ };
45
+ }
46
+ function readNodeRect(node) {
47
+ if (!node) return null;
48
+ if (typeof window !== "undefined" && node === window || node === globalThis) return getViewportRect();
49
+ const target = node;
50
+ if (typeof target.getBoundingClientRect !== "function") return null;
51
+ const rect = target.getBoundingClientRect();
52
+ const left = normalizeRectValue(rect.left);
53
+ const top = normalizeRectValue(rect.top);
54
+ const width = normalizeRectValue(rect.width);
55
+ const height = normalizeRectValue(rect.height);
56
+ return {
57
+ left,
58
+ top,
59
+ right: rect.right == null ? left + width : normalizeRectValue(rect.right),
60
+ bottom: rect.bottom == null ? top + height : normalizeRectValue(rect.bottom),
61
+ width,
62
+ height
63
+ };
64
+ }
65
+ function readNodeScrollOffset(node) {
66
+ if (typeof window !== "undefined" && node === window || node === globalThis) {
67
+ const runtimeWindow = typeof window !== "undefined" ? window : globalThis;
68
+ return {
69
+ scrollLeft: normalizeRectValue(runtimeWindow.pageXOffset ?? runtimeWindow.scrollX),
70
+ scrollTop: normalizeRectValue(runtimeWindow.pageYOffset ?? runtimeWindow.scrollY)
71
+ };
72
+ }
73
+ const target = node;
74
+ return {
75
+ scrollLeft: normalizeRectValue(target?.scrollLeft),
76
+ scrollTop: normalizeRectValue(target?.scrollTop)
77
+ };
78
+ }
79
+ function readNodeFields(node, fields) {
80
+ if (!node) return null;
81
+ const result = {};
82
+ const element = node;
83
+ if (fields.id) {
84
+ const elementWithId = element;
85
+ result.id = elementWithId.id ?? elementWithId.getAttribute?.("id") ?? "";
86
+ }
87
+ if (fields.dataset) result.dataset = { ...element.dataset ?? {} };
88
+ if (fields.rect || fields.size) {
89
+ const rect = readNodeRect(node);
90
+ if (rect) {
91
+ if (fields.rect) {
92
+ result.left = rect.left;
93
+ result.top = rect.top;
94
+ result.right = rect.right;
95
+ result.bottom = rect.bottom;
96
+ }
97
+ if (fields.size) {
98
+ result.width = rect.width;
99
+ result.height = rect.height;
100
+ }
101
+ }
102
+ }
103
+ if (fields.scrollOffset) Object.assign(result, readNodeScrollOffset(node));
104
+ if (fields.properties?.length) for (const key of fields.properties) result[key] = node[key];
105
+ if (fields.computedStyle?.length && typeof getComputedStyle === "function" && node instanceof HTMLElement) {
106
+ const style = getComputedStyle(node);
107
+ for (const key of fields.computedStyle) result[key] = style.getPropertyValue(key);
108
+ }
109
+ if (fields.node) result.node = node;
110
+ if (fields.context) result.context = node;
111
+ return result;
112
+ }
113
+ function mapQueryResult(target, items, mapper) {
114
+ if (target.type === "node" && target.multiple) return items.map((item) => mapper(item));
115
+ const first = items[0];
116
+ if (!first) return null;
117
+ return mapper(first);
118
+ }
119
+ function runQueryTask(scope, task) {
120
+ const targets = resolveQueryTargets(scope, task.target);
121
+ if (task.type === "boundingClientRect") return mapQueryResult(task.target, targets, (node) => readNodeRect(node));
122
+ if (task.type === "scrollOffset") return mapQueryResult(task.target, targets, (node) => readNodeScrollOffset(node));
123
+ if (task.type === "fields") return mapQueryResult(task.target, targets, (node) => readNodeFields(node, task.fields));
124
+ return mapQueryResult(task.target, targets, (node) => ({ node }));
125
+ }
126
+ function createNodesRef(tasks, queryApi, target) {
127
+ return {
128
+ boundingClientRect(callback) {
129
+ tasks.push({
130
+ type: "boundingClientRect",
131
+ target,
132
+ callback
133
+ });
134
+ return queryApi;
135
+ },
136
+ scrollOffset(callback) {
137
+ tasks.push({
138
+ type: "scrollOffset",
139
+ target,
140
+ callback
141
+ });
142
+ return queryApi;
143
+ },
144
+ fields(fields, callback) {
145
+ tasks.push({
146
+ type: "fields",
147
+ target,
148
+ fields,
149
+ callback
150
+ });
151
+ return queryApi;
152
+ },
153
+ node(callback) {
154
+ tasks.push({
155
+ type: "node",
156
+ target,
157
+ callback
158
+ });
159
+ return queryApi;
160
+ }
161
+ };
162
+ }
163
+ function createSelectorQueryBridge() {
164
+ let scope;
165
+ const tasks = [];
166
+ const queryApi = {
167
+ in(context) {
168
+ scope = context;
169
+ return queryApi;
170
+ },
171
+ select(selector) {
172
+ return createNodesRef(tasks, queryApi, {
173
+ type: "node",
174
+ selector,
175
+ multiple: false
176
+ });
177
+ },
178
+ selectAll(selector) {
179
+ return createNodesRef(tasks, queryApi, {
180
+ type: "node",
181
+ selector,
182
+ multiple: true
183
+ });
184
+ },
185
+ selectViewport() {
186
+ return createNodesRef(tasks, queryApi, { type: "viewport" });
187
+ },
188
+ exec(callback) {
189
+ const result = tasks.map((task) => {
190
+ const value = runQueryTask(scope, task);
191
+ task.callback?.(value);
192
+ return value;
193
+ });
194
+ callback?.(result);
195
+ tasks.length = 0;
196
+ return queryApi;
197
+ }
198
+ };
199
+ return queryApi;
200
+ }
201
+
202
+ //#endregion
203
+ export { createSelectorQueryBridge };
204
+ //# sourceMappingURL=selectorQuery.mjs.map
@@ -0,0 +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'\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 resolveQueryRoot(scope: unknown): ParentNode | undefined {\n const scoped = scope 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 if (isQueryRoot(scoped?.$el)) {\n return scoped?.$el\n }\n if (isQueryRoot(scope)) {\n return scope\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 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 if (target.multiple) {\n return Array.from(root.querySelectorAll(target.selector))\n }\n const node = root.querySelector(target.selector)\n return node ? [node] : []\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 result = tasks.map((task) => {\n const value = runQueryTask(scope, task)\n task.callback?.(value)\n return value\n })\n callback?.(result)\n tasks.length = 0\n return queryApi\n },\n }\n\n return queryApi\n}\n"],"mappings":";AASA,SAAS,YAAY,OAAqC;AACxD,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO;CAET,MAAM,SAAS;AAIf,QAAO,OAAO,OAAO,kBAAkB,cAAc,OAAO,OAAO,qBAAqB;;AAG1F,SAAS,iBAAiB,OAAwC;CAChE,MAAM,SAAS;AAKf,KAAI,YAAY,QAAQ,WAAW,CACjC,QAAO,QAAQ;AAEjB,KAAI,YAAY,QAAQ,WAAW,CACjC,QAAO,QA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AACxD,UAAO;;EAET,KAAK,UAAsC;AACzC,SAAM,KAAK;IAAE,MAAM;IAAQ;IAAQ;IAAU,CAAC;AAC9C,UAAO;;EAEV;;AAGH,SAAgB,4BAA4B;CAC1C,IAAI;CACJ,MAAM,QAA6B,EAAE;CAErC,MAAM,WAA0B;EAC9B,GAAG,SAAmB;AACpB,WAAQ;AACR,UAAO;;EAET,OAAO,UAAkB;AACvB,UAAO,eAAe,OAAO,UAAU;IAAE,MAAM;IAAQ;IAAU,UAAU;IAAO,CAAC;;EAErF,UAAU,UAAkB;AAC1B,UAAO,eAAe,OAAO,UAAU;IAAE,MAAM;IAAQ;IAAU,UAAU;IAAM,CAAC;;EAEpF,iBAAiB;AACf,UAAO,eAAe,OAAO,UAAU,EAAE,MAAM,YAAY,CAAC;;EAE9D,KAAK,UAAoC;GACvC,MAAM,SAAS,MAAM,KAAK,SAAS;IACjC,MAAM,QAAQ,aAAa,OAAO,KAAK;AACvC,SAAK,WAAW,MAAM;AACtB,WAAO;KACP;AACF,cAAW,OAAO;AAClB,SAAM,SAAS;AACf,UAAO;;EAEV;AAED,QAAO"}
@@ -0,0 +1,103 @@
1
+ //#region src/runtime/polyfill/storage.ts
2
+ const WEB_STORAGE_PREFIX = "__weapp_vite_web_storage__:";
3
+ const WEB_STORAGE_LIMIT_SIZE_KB = 10240;
4
+ const memoryStorage = /* @__PURE__ */ new Map();
5
+ function isRuntimeStorageLike(value) {
6
+ return !!value && typeof value === "object" && typeof value.getItem === "function" && typeof value.setItem === "function" && typeof value.removeItem === "function" && typeof value.key === "function";
7
+ }
8
+ function getRuntimeStorage() {
9
+ if (typeof localStorage === "undefined" || !isRuntimeStorageLike(localStorage)) return;
10
+ return localStorage;
11
+ }
12
+ function storageKeyWithPrefix(key) {
13
+ return `${WEB_STORAGE_PREFIX}${key}`;
14
+ }
15
+ function encodeStorageValue(value) {
16
+ if (value === void 0) return JSON.stringify({ type: "undefined" });
17
+ return JSON.stringify({
18
+ type: "json",
19
+ value
20
+ });
21
+ }
22
+ function decodeStorageValue(value) {
23
+ try {
24
+ const parsed = JSON.parse(value);
25
+ if (parsed?.type === "undefined") return;
26
+ if (parsed?.type === "json") return parsed.value;
27
+ return parsed;
28
+ } catch {
29
+ return value;
30
+ }
31
+ }
32
+ function normalizeStorageKey(key) {
33
+ if (typeof key !== "string") return "";
34
+ return key.trim();
35
+ }
36
+ function hasStorageKey(key) {
37
+ if (memoryStorage.has(key)) return true;
38
+ const storage = getRuntimeStorage();
39
+ if (!storage) return false;
40
+ return storage.getItem(storageKeyWithPrefix(key)) !== null;
41
+ }
42
+ function listStorageKeys() {
43
+ const keySet = new Set(memoryStorage.keys());
44
+ const storage = getRuntimeStorage();
45
+ if (!storage) return Array.from(keySet);
46
+ for (let index = 0; index < storage.length; index += 1) {
47
+ const key = storage.key(index);
48
+ if (key?.startsWith(WEB_STORAGE_PREFIX)) keySet.add(key.slice(27));
49
+ }
50
+ return Array.from(keySet);
51
+ }
52
+ function setStorageSyncInternal(key, data) {
53
+ memoryStorage.set(key, data);
54
+ const storage = getRuntimeStorage();
55
+ if (storage) storage.setItem(storageKeyWithPrefix(key), encodeStorageValue(data));
56
+ }
57
+ function getStorageSyncInternal(key) {
58
+ if (memoryStorage.has(key)) return memoryStorage.get(key);
59
+ const storage = getRuntimeStorage();
60
+ if (!storage) return "";
61
+ const raw = storage.getItem(storageKeyWithPrefix(key));
62
+ if (raw == null) return "";
63
+ const decoded = decodeStorageValue(raw);
64
+ memoryStorage.set(key, decoded);
65
+ return decoded;
66
+ }
67
+ function removeStorageSyncInternal(key) {
68
+ memoryStorage.delete(key);
69
+ const storage = getRuntimeStorage();
70
+ if (storage) storage.removeItem(storageKeyWithPrefix(key));
71
+ }
72
+ function clearStorageSyncInternal() {
73
+ memoryStorage.clear();
74
+ const storage = getRuntimeStorage();
75
+ if (!storage) return;
76
+ const removeKeys = [];
77
+ for (let index = 0; index < storage.length; index += 1) {
78
+ const key = storage.key(index);
79
+ if (key?.startsWith(WEB_STORAGE_PREFIX)) removeKeys.push(key);
80
+ }
81
+ for (const key of removeKeys) storage.removeItem(key);
82
+ }
83
+ function calculateStorageCurrentSize(keys) {
84
+ let bytes = 0;
85
+ for (const key of keys) {
86
+ const encoded = encodeStorageValue(getStorageSyncInternal(key));
87
+ bytes += encoded.length;
88
+ }
89
+ return Math.ceil(bytes / 1024);
90
+ }
91
+ function getStorageInfoSyncInternal() {
92
+ const keys = listStorageKeys();
93
+ return {
94
+ errMsg: "getStorageInfoSync:ok",
95
+ keys,
96
+ currentSize: calculateStorageCurrentSize(keys),
97
+ limitSize: WEB_STORAGE_LIMIT_SIZE_KB
98
+ };
99
+ }
100
+
101
+ //#endregion
102
+ export { clearStorageSyncInternal, getStorageInfoSyncInternal, getStorageSyncInternal, hasStorageKey, normalizeStorageKey, removeStorageSyncInternal, setStorageSyncInternal };
103
+ //# sourceMappingURL=storage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.mjs","names":[],"sources":["../../../src/runtime/polyfill/storage.ts"],"sourcesContent":["const WEB_STORAGE_PREFIX = '__weapp_vite_web_storage__:'\nconst WEB_STORAGE_LIMIT_SIZE_KB = 10240\nconst memoryStorage = new Map<string, any>()\n\nfunction isRuntimeStorageLike(value: unknown): value is Storage {\n return !!value\n && typeof value === 'object'\n && typeof (value as Storage).getItem === 'function'\n && typeof (value as Storage).setItem === 'function'\n && typeof (value as Storage).removeItem === 'function'\n && typeof (value as Storage).key === 'function'\n}\n\nfunction getRuntimeStorage() {\n if (typeof localStorage === 'undefined' || !isRuntimeStorageLike(localStorage)) {\n return undefined\n }\n return localStorage\n}\n\nfunction storageKeyWithPrefix(key: string) {\n return `${WEB_STORAGE_PREFIX}${key}`\n}\n\nfunction encodeStorageValue(value: any) {\n if (value === undefined) {\n return JSON.stringify({ type: 'undefined' })\n }\n return JSON.stringify({ type: 'json', value })\n}\n\nfunction decodeStorageValue(value: string) {\n try {\n const parsed = JSON.parse(value) as { type?: string, value?: any }\n if (parsed?.type === 'undefined') {\n return undefined\n }\n if (parsed?.type === 'json') {\n return parsed.value\n }\n return parsed\n }\n catch {\n return value\n }\n}\n\nexport function normalizeStorageKey(key: unknown) {\n if (typeof key !== 'string') {\n return ''\n }\n return key.trim()\n}\n\nexport function hasStorageKey(key: string) {\n if (memoryStorage.has(key)) {\n return true\n }\n const storage = getRuntimeStorage()\n if (!storage) {\n return false\n }\n return storage.getItem(storageKeyWithPrefix(key)) !== null\n}\n\nfunction listStorageKeys() {\n const keySet = new Set<string>(memoryStorage.keys())\n const storage = getRuntimeStorage()\n if (!storage) {\n return Array.from(keySet)\n }\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (key?.startsWith(WEB_STORAGE_PREFIX)) {\n keySet.add(key.slice(WEB_STORAGE_PREFIX.length))\n }\n }\n return Array.from(keySet)\n}\n\nexport function setStorageSyncInternal(key: string, data: any) {\n memoryStorage.set(key, data)\n const storage = getRuntimeStorage()\n if (storage) {\n storage.setItem(storageKeyWithPrefix(key), encodeStorageValue(data))\n }\n}\n\nexport function getStorageSyncInternal(key: string) {\n if (memoryStorage.has(key)) {\n return memoryStorage.get(key)\n }\n const storage = getRuntimeStorage()\n if (!storage) {\n return ''\n }\n const raw = storage.getItem(storageKeyWithPrefix(key))\n if (raw == null) {\n return ''\n }\n const decoded = decodeStorageValue(raw)\n memoryStorage.set(key, decoded)\n return decoded\n}\n\nexport function removeStorageSyncInternal(key: string) {\n memoryStorage.delete(key)\n const storage = getRuntimeStorage()\n if (storage) {\n storage.removeItem(storageKeyWithPrefix(key))\n }\n}\n\nexport function clearStorageSyncInternal() {\n memoryStorage.clear()\n const storage = getRuntimeStorage()\n if (!storage) {\n return\n }\n const removeKeys: string[] = []\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (key?.startsWith(WEB_STORAGE_PREFIX)) {\n removeKeys.push(key)\n }\n }\n for (const key of removeKeys) {\n storage.removeItem(key)\n }\n}\n\nfunction calculateStorageCurrentSize(keys: string[]) {\n let bytes = 0\n for (const key of keys) {\n const value = getStorageSyncInternal(key)\n const encoded = encodeStorageValue(value)\n bytes += encoded.length\n }\n return Math.ceil(bytes / 1024)\n}\n\nexport function getStorageInfoSyncInternal() {\n const keys = listStorageKeys()\n return {\n errMsg: 'getStorageInfoSync:ok',\n keys,\n currentSize: calculateStorageCurrentSize(keys),\n limitSize: WEB_STORAGE_LIMIT_SIZE_KB,\n }\n}\n"],"mappings":";AAAA,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AAClC,MAAM,gCAAgB,IAAI,KAAkB;AAE5C,SAAS,qBAAqB,OAAkC;AAC9D,QAAO,CAAC,CAAC,SACJ,OAAO,UAAU,YACjB,OAAQ,MAAkB,YAAY,cACtC,OAAQ,MAAkB,YAAY,cACtC,OAAQ,MAAkB,eAAe,cACzC,OAAQ,MAAkB,QAAQ;;AAGzC,SAAS,oBAAoB;AAC3B,KAAI,OAAO,iBAAiB,eAAe,CAAC,qBAAqB,aAAa,CAC5E;AAEF,QAAO;;AAGT,SAAS,qBAAqB,KAAa;AACzC,QAAO,GAAG,qBAAqB;;AAGjC,SAAS,mBAAmB,OAAY;AACtC,KAAI,UAAU,OACZ,QAAO,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,QAAO,KAAK,UAAU;EAAE,MAAM;EAAQ;EAAO,CAAC;;AAGhD,SAAS,mBAAmB,OAAe;AACzC,KAAI;EACF,MAAM,SAAS,KAAK,MAAM,MAAM;AAChC,MAAI,QAAQ,SAAS,YACnB;AAEF,MAAI,QAAQ,SAAS,OACnB,QAAO,OAAO;AAEhB,SAAO;SAEH;AACJ,SAAO;;;AAIX,SAAgB,oBAAoB,KAAc;AAChD,KAAI,OAAO,QAAQ,SACjB,QAAO;AAET,QAAO,IAAI,MAAM;;AAGnB,SAAgB,cAAc,KAAa;AACzC,KAAI,cAAc,IAAI,IAAI,CACxB,QAAO;CAET,MAAM,UAAU,mBAAmB;AACnC,KAAI,CAAC,QACH,QAA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AAC9B,MAAI,KAAK,WAAW,mBAAmB,CACrC,YAAW,KAAK,IAAI;;AAGxB,MAAK,MAAM,OAAO,WAChB,SAAQ,WAAW,IAAI;;AAI3B,SAAS,4BAA4B,MAAgB;CACnD,IAAI,QAAQ;AACZ,MAAK,MAAM,OAAO,MAAM;EAEtB,MAAM,UAAU,mBADF,uBAAuB,IAAI,CACA;AACzC,WAAS,QAAQ;;AAEnB,QAAO,KAAK,KAAK,QAAQ,KAAK;;AAGhC,SAAgB,6BAA6B;CAC3C,MAAM,OAAO,iBAAiB;AAC9B,QAAO;EACL,QAAQ;EACR;EACA,aAAa,4BAA4B,KAAK;EAC9C,WAAW;EACZ"}
@@ -0,0 +1,62 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "./async.mjs";
2
+ import { clearStorageSyncInternal, getStorageInfoSyncInternal, getStorageSyncInternal, hasStorageKey, normalizeStorageKey, removeStorageSyncInternal, setStorageSyncInternal } from "./storage.mjs";
3
+
4
+ //#region src/runtime/polyfill/storageAsync.ts
5
+ function setStorageBridge(options) {
6
+ const key = normalizeStorageKey(options?.key);
7
+ if (!key) {
8
+ const failure = callWxAsyncFailure(options, "setStorage:fail invalid key");
9
+ return Promise.reject(failure);
10
+ }
11
+ try {
12
+ setStorageSyncInternal(key, options?.data);
13
+ } catch (error) {
14
+ const failure = callWxAsyncFailure(options, `setStorage:fail ${error instanceof Error ? error.message : String(error)}`);
15
+ return Promise.reject(failure);
16
+ }
17
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "setStorage:ok" }));
18
+ }
19
+ function getStorageBridge(options) {
20
+ const key = normalizeStorageKey(options?.key);
21
+ if (!key) {
22
+ const failure = callWxAsyncFailure(options, "getStorage:fail invalid key");
23
+ return Promise.reject(failure);
24
+ }
25
+ if (!hasStorageKey(key)) {
26
+ const failure = callWxAsyncFailure(options, `getStorage:fail data not found for key ${key}`);
27
+ return Promise.reject(failure);
28
+ }
29
+ const data = getStorageSyncInternal(key);
30
+ return Promise.resolve(callWxAsyncSuccess(options, {
31
+ errMsg: "getStorage:ok",
32
+ data
33
+ }));
34
+ }
35
+ function removeStorageBridge(options) {
36
+ const key = normalizeStorageKey(options?.key);
37
+ if (!key) {
38
+ const failure = callWxAsyncFailure(options, "removeStorage:fail invalid key");
39
+ return Promise.reject(failure);
40
+ }
41
+ try {
42
+ removeStorageSyncInternal(key);
43
+ } catch (error) {
44
+ const failure = callWxAsyncFailure(options, `removeStorage:fail ${error instanceof Error ? error.message : String(error)}`);
45
+ return Promise.reject(failure);
46
+ }
47
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "removeStorage:ok" }));
48
+ }
49
+ function clearStorageBridge(options) {
50
+ clearStorageSyncInternal();
51
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "clearStorage:ok" }));
52
+ }
53
+ function getStorageInfoBridge(options) {
54
+ return Promise.resolve(callWxAsyncSuccess(options, {
55
+ ...getStorageInfoSyncInternal(),
56
+ errMsg: "getStorageInfo:ok"
57
+ }));
58
+ }
59
+
60
+ //#endregion
61
+ export { clearStorageBridge, getStorageBridge, getStorageInfoBridge, removeStorageBridge, setStorageBridge };
62
+ //# sourceMappingURL=storageAsync.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageAsync.mjs","names":[],"sources":["../../../src/runtime/polyfill/storageAsync.ts"],"sourcesContent":["import type { WxAsyncOptions, WxBaseResult } from './types/base'\nimport type { GetStorageOptions, RemoveStorageOptions, SetStorageOptions, StorageInfoResult } from './types/common'\nimport {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from './async'\nimport {\n clearStorageSyncInternal,\n getStorageInfoSyncInternal,\n getStorageSyncInternal,\n hasStorageKey,\n normalizeStorageKey,\n removeStorageSyncInternal,\n setStorageSyncInternal,\n} from './storage'\n\nexport function setStorageBridge(options?: SetStorageOptions) {\n const key = normalizeStorageKey(options?.key)\n if (!key) {\n const failure = callWxAsyncFailure(options, 'setStorage:fail invalid key')\n return Promise.reject(failure)\n }\n try {\n setStorageSyncInternal(key, options?.data)\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `setStorage:fail ${message}`)\n return Promise.reject(failure)\n }\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'setStorage:ok' }))\n}\n\nexport function getStorageBridge(options?: GetStorageOptions) {\n const key = normalizeStorageKey(options?.key)\n if (!key) {\n const failure = callWxAsyncFailure(options, 'getStorage:fail invalid key')\n return Promise.reject(failure)\n }\n if (!hasStorageKey(key)) {\n const failure = callWxAsyncFailure(options, `getStorage:fail data not found for key ${key}`)\n return Promise.reject(failure)\n }\n const data = getStorageSyncInternal(key)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'getStorage:ok', data }))\n}\n\nexport function removeStorageBridge(options?: RemoveStorageOptions) {\n const key = normalizeStorageKey(options?.key)\n if (!key) {\n const failure = callWxAsyncFailure(options, 'removeStorage:fail invalid key')\n return Promise.reject(failure)\n }\n try {\n removeStorageSyncInternal(key)\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `removeStorage:fail ${message}`)\n return Promise.reject(failure)\n }\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'removeStorage:ok' }))\n}\n\nexport function clearStorageBridge(options?: WxAsyncOptions<WxBaseResult>) {\n clearStorageSyncInternal()\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'clearStorage:ok' }))\n}\n\nexport function getStorageInfoBridge(options?: WxAsyncOptions<StorageInfoResult>) {\n return Promise.resolve(callWxAsyncSuccess(options, {\n ...getStorageInfoSyncInternal(),\n errMsg: 'getStorageInfo:ok',\n }))\n}\n"],"mappings":";;;;AAgBA,SAAgB,iBAAiB,SAA6B;CAC5D,MAAM,MAAM,oBAAoB,SAAS,IAAI;AAC7C,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,mBAAmB,SAAS,8BAA8B;AAC1E,SAAO,QAAQ,OAAO,QAAQ;;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,QAAQ,QAAQ,mBAAmB,SAAS;EACjD,GAAG,4BAA4B;EAC/B,QAAQ;EACT,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { WEAPP_VITE_WEB_REQUEST_SUBSCRIBE_MESSAGE_KEY } from "@weapp-core/constants";
2
+
3
+ //#region src/runtime/polyfill/subscribe.ts
4
+ function normalizeSubscribeDecision(value) {
5
+ if (value === "accept" || value === "reject" || value === "ban" || value === "filter") return value;
6
+ return "accept";
7
+ }
8
+ function normalizeSubscribeTemplateIds(value) {
9
+ if (!Array.isArray(value)) return [];
10
+ return value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
11
+ }
12
+ function resolveSubscribeDecisionMap(tmplIds) {
13
+ const preset = globalThis[WEAPP_VITE_WEB_REQUEST_SUBSCRIBE_MESSAGE_KEY];
14
+ const presetValue = typeof preset === "function" ? preset(tmplIds) : preset;
15
+ if (presetValue && typeof presetValue === "object") {
16
+ const output = {};
17
+ const source = presetValue;
18
+ for (const tmplId of tmplIds) output[tmplId] = normalizeSubscribeDecision(source[tmplId]);
19
+ return output;
20
+ }
21
+ const sharedDecision = normalizeSubscribeDecision(presetValue);
22
+ return tmplIds.reduce((result, tmplId) => {
23
+ result[tmplId] = sharedDecision;
24
+ return result;
25
+ }, {});
26
+ }
27
+
28
+ //#endregion
29
+ export { normalizeSubscribeTemplateIds, resolveSubscribeDecisionMap };
30
+ //# sourceMappingURL=subscribe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe.mjs","names":[],"sources":["../../../src/runtime/polyfill/subscribe.ts"],"sourcesContent":["import { WEAPP_VITE_WEB_REQUEST_SUBSCRIBE_MESSAGE_KEY } from '@weapp-core/constants'\n\nexport type SubscribeMessageDecision = 'accept' | 'reject' | 'ban' | 'filter'\n\nexport function normalizeSubscribeDecision(value: unknown): SubscribeMessageDecision {\n if (value === 'accept' || value === 'reject' || value === 'ban' || value === 'filter') {\n return value\n }\n return 'accept'\n}\n\nexport function normalizeSubscribeTemplateIds(value: unknown) {\n if (!Array.isArray(value)) {\n return []\n }\n return value\n .filter((item): item is string => typeof item === 'string')\n .map(item => item.trim())\n .filter(Boolean)\n}\n\nexport function resolveSubscribeDecisionMap(tmplIds: string[]) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_REQUEST_SUBSCRIBE_MESSAGE_KEY]\n const presetValue = typeof preset === 'function'\n ? (preset as (ids: string[]) => unknown)(tmplIds)\n : preset\n if (presetValue && typeof presetValue === 'object') {\n const output: Record<string, SubscribeMessageDecision> = {}\n const source = presetValue as Record<string, unknown>\n for (const tmplId of tmplIds) {\n output[tmplId] = normalizeSubscribeDecision(source[tmplId])\n }\n return output\n }\n const sharedDecision = normalizeSubscribeDecision(presetValue)\n return tmplIds.reduce<Record<string, SubscribeMessageDecision>>((result, tmplId) => {\n result[tmplId] = sharedDecision\n return result\n }, {})\n}\n"],"mappings":";;;AAIA,SAAgB,2BAA2B,OAA0C;AACnF,KAAI,UAAU,YAAY,UAAU,YAAY,UAAU,SAAS,UAAU,SAC3E,QAAO;AAET,QAAO;;AAGT,SAAgB,8BAA8B,OAAgB;AAC5D,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,QAAO,EAAE;AAEX,QAAO,MACJ,QAAQ,SAAyB,OAAO,SAAS,SAAS,CAC1D,KAAI,SAAQ,KAAK,MAAM,CAAC,CACxB,OAAO,QAAQ;;AAGpB,SAAgB,4BAA4B,SAAmB;CAE7D,MAAM,SADgB,WACO;CAC7B,MAAM,cAAc,OAAO,WAAW,aACjC,OAAsC,QAAQ,GAC/C;AACJ,KAAI,eAAe,OAAO,gBAAgB,UAAU;EAClD,MAAM,SAAmD,EAAE;EAC3D,MAAM,SAAS;AACf,OAAK,MAAM,UAAU,QACnB,QAAO,UAAU,2BAA2B,OAAO,QAAQ;AAE7D,SAAO;;CAET,MAAM,iBAAiB,2BAA2B,YAAY;AAC9D,QAAO,QAAQ,QAAkD,QAAQ,WAAW;AAClF,SAAO,UAAU;AACjB,SAAO;IACN,EAAE,CAAC"}
@@ -0,0 +1,111 @@
1
+ //#region src/runtime/polyfill/system.ts
2
+ function resolveSystemName(userAgent) {
3
+ if (/android/i.test(userAgent)) return "Android";
4
+ if (/iphone|ipad|ipod/i.test(userAgent)) return "iOS";
5
+ if (/windows/i.test(userAgent)) return "Windows";
6
+ if (/mac os x/i.test(userAgent)) return "macOS";
7
+ if (/linux/i.test(userAgent)) return "Linux";
8
+ return "Unknown";
9
+ }
10
+ function resolvePlatformName(userAgent, runtimeNavigator) {
11
+ const normalized = (runtimeNavigator?.userAgentData?.platform ?? runtimeNavigator?.platform ?? resolveSystemName(userAgent)).toLowerCase();
12
+ if (normalized.includes("android")) return "android";
13
+ if (normalized.includes("iphone") || normalized.includes("ipad") || normalized.includes("ios")) return "ios";
14
+ if (normalized.includes("win")) return "windows";
15
+ if (normalized.includes("mac")) return "mac";
16
+ if (normalized.includes("linux")) return "linux";
17
+ return normalized || "web";
18
+ }
19
+ function normalizePositiveNumber(value, fallback) {
20
+ if (typeof value !== "number" || Number.isNaN(value) || value <= 0) return fallback;
21
+ return value;
22
+ }
23
+ function resolveDeviceOrientation() {
24
+ const runtimeWindow = typeof window !== "undefined" ? window : globalThis;
25
+ const width = normalizePositiveNumber(runtimeWindow.innerWidth, 0);
26
+ const height = normalizePositiveNumber(runtimeWindow.innerHeight, 0);
27
+ if (width > 0 && height > 0 && width > height) return "landscape";
28
+ return "portrait";
29
+ }
30
+ function normalizeMemorySize(memory) {
31
+ if (typeof memory !== "number" || Number.isNaN(memory) || memory <= 0) return 0;
32
+ return Math.round(memory * 1024);
33
+ }
34
+ function resolveRuntimeTheme() {
35
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "light";
36
+ try {
37
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
38
+ } catch {
39
+ return "light";
40
+ }
41
+ }
42
+ function readSystemInfoSnapshot() {
43
+ const runtimeWindow = typeof window !== "undefined" ? window : globalThis;
44
+ const runtimeScreen = typeof screen !== "undefined" ? screen : globalThis;
45
+ const runtimeNavigator = typeof navigator !== "undefined" ? navigator : void 0;
46
+ const userAgent = runtimeNavigator?.userAgent ?? "";
47
+ const windowWidth = normalizePositiveNumber(runtimeWindow.innerWidth, normalizePositiveNumber(runtimeScreen.width, 0));
48
+ const windowHeight = normalizePositiveNumber(runtimeWindow.innerHeight, normalizePositiveNumber(runtimeScreen.height, 0));
49
+ const screenWidth = normalizePositiveNumber(runtimeScreen.width, windowWidth);
50
+ const screenHeight = normalizePositiveNumber(runtimeScreen.height, windowHeight);
51
+ return {
52
+ brand: "web",
53
+ model: runtimeNavigator?.platform ?? "web",
54
+ pixelRatio: normalizePositiveNumber(runtimeWindow.devicePixelRatio, 1),
55
+ screenWidth,
56
+ screenHeight,
57
+ windowWidth,
58
+ windowHeight,
59
+ statusBarHeight: 0,
60
+ language: runtimeNavigator?.language ?? "en",
61
+ version: runtimeNavigator?.appVersion ?? userAgent,
62
+ system: resolveSystemName(userAgent),
63
+ platform: resolvePlatformName(userAgent, runtimeNavigator)
64
+ };
65
+ }
66
+ function buildWindowInfoSnapshot(systemInfo) {
67
+ const safeArea = {
68
+ left: 0,
69
+ right: systemInfo.windowWidth,
70
+ top: systemInfo.statusBarHeight,
71
+ bottom: systemInfo.windowHeight,
72
+ width: systemInfo.windowWidth,
73
+ height: Math.max(0, systemInfo.windowHeight - systemInfo.statusBarHeight)
74
+ };
75
+ return {
76
+ pixelRatio: systemInfo.pixelRatio,
77
+ screenWidth: systemInfo.screenWidth,
78
+ screenHeight: systemInfo.screenHeight,
79
+ windowWidth: systemInfo.windowWidth,
80
+ windowHeight: systemInfo.windowHeight,
81
+ statusBarHeight: systemInfo.statusBarHeight,
82
+ screenTop: systemInfo.statusBarHeight,
83
+ safeArea
84
+ };
85
+ }
86
+ function readDeviceMemorySize() {
87
+ return normalizeMemorySize((typeof navigator !== "undefined" ? navigator : void 0)?.deviceMemory);
88
+ }
89
+ function resolveAccountAppId() {
90
+ const host = (typeof location !== "undefined" ? location : void 0)?.hostname?.trim();
91
+ return host ? `web:${host}` : "web";
92
+ }
93
+ function buildMenuButtonRect(windowWidth, statusBarHeight) {
94
+ const width = 88;
95
+ const height = 32;
96
+ const right = Math.max(width, windowWidth - 8);
97
+ const top = Math.max(0, statusBarHeight + (44 - height) / 2);
98
+ const left = Math.max(0, right - width);
99
+ return {
100
+ width,
101
+ height,
102
+ top,
103
+ right,
104
+ bottom: top + height,
105
+ left
106
+ };
107
+ }
108
+
109
+ //#endregion
110
+ export { buildMenuButtonRect, buildWindowInfoSnapshot, readDeviceMemorySize, readSystemInfoSnapshot, resolveAccountAppId, resolveDeviceOrientation, resolveRuntimeTheme };
111
+ //# sourceMappingURL=system.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.mjs","names":[],"sources":["../../../src/runtime/polyfill/system.ts"],"sourcesContent":["export function resolveSystemName(userAgent: string) {\n if (/android/i.test(userAgent)) {\n return 'Android'\n }\n if (/iphone|ipad|ipod/i.test(userAgent)) {\n return 'iOS'\n }\n if (/windows/i.test(userAgent)) {\n return 'Windows'\n }\n if (/mac os x/i.test(userAgent)) {\n return 'macOS'\n }\n if (/linux/i.test(userAgent)) {\n return 'Linux'\n }\n return 'Unknown'\n}\n\nexport function resolvePlatformName(\n userAgent: string,\n runtimeNavigator: Navigator | undefined,\n) {\n const navigatorWithUAData = runtimeNavigator as Navigator & {\n userAgentData?: { platform?: string }\n }\n const raw = navigatorWithUAData?.userAgentData?.platform\n ?? runtimeNavigator?.platform\n ?? resolveSystemName(userAgent)\n const normalized = raw.toLowerCase()\n if (normalized.includes('android')) {\n return 'android'\n }\n if (normalized.includes('iphone') || normalized.includes('ipad') || normalized.includes('ios')) {\n return 'ios'\n }\n if (normalized.includes('win')) {\n return 'windows'\n }\n if (normalized.includes('mac')) {\n return 'mac'\n }\n if (normalized.includes('linux')) {\n return 'linux'\n }\n return normalized || 'web'\n}\n\nexport function normalizePositiveNumber(value: number | undefined, fallback: number) {\n if (typeof value !== 'number' || Number.isNaN(value) || value <= 0) {\n return fallback\n }\n return value\n}\n\nexport function resolveDeviceOrientation(): 'portrait' | 'landscape' {\n const runtimeWindow = (typeof window !== 'undefined'\n ? window\n : globalThis) as {\n innerWidth?: number\n innerHeight?: number\n }\n const width = normalizePositiveNumber(runtimeWindow.innerWidth, 0)\n const height = normalizePositiveNumber(runtimeWindow.innerHeight, 0)\n if (width > 0 && height > 0 && width > height) {\n return 'landscape'\n }\n return 'portrait'\n}\n\nexport function normalizeMemorySize(memory: unknown) {\n if (typeof memory !== 'number' || Number.isNaN(memory) || memory <= 0) {\n return 0\n }\n return Math.round(memory * 1024)\n}\n\nexport function resolveRuntimeTheme(): 'light' | 'dark' {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return 'light'\n }\n try {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'\n }\n catch {\n return 'light'\n }\n}\n\nexport function readSystemInfoSnapshot() {\n const runtimeWindow = (typeof window !== 'undefined'\n ? window\n : globalThis) as {\n innerWidth?: number\n innerHeight?: number\n devicePixelRatio?: number\n }\n const runtimeScreen = (typeof screen !== 'undefined'\n ? screen\n : globalThis) as {\n width?: number\n height?: number\n }\n const runtimeNavigator = typeof navigator !== 'undefined' ? navigator : undefined\n const userAgent = runtimeNavigator?.userAgent ?? ''\n const windowWidth = normalizePositiveNumber(\n runtimeWindow.innerWidth,\n normalizePositiveNumber(runtimeScreen.width, 0),\n )\n const windowHeight = normalizePositiveNumber(\n runtimeWindow.innerHeight,\n normalizePositiveNumber(runtimeScreen.height, 0),\n )\n const screenWidth = normalizePositiveNumber(runtimeScreen.width, windowWidth)\n const screenHeight = normalizePositiveNumber(runtimeScreen.height, windowHeight)\n\n return {\n brand: 'web',\n model: runtimeNavigator?.platform ?? 'web',\n pixelRatio: normalizePositiveNumber(runtimeWindow.devicePixelRatio, 1),\n screenWidth,\n screenHeight,\n windowWidth,\n windowHeight,\n statusBarHeight: 0,\n language: runtimeNavigator?.language ?? 'en',\n version: runtimeNavigator?.appVersion ?? userAgent,\n system: resolveSystemName(userAgent),\n platform: resolvePlatformName(userAgent, runtimeNavigator),\n }\n}\n\nexport function buildWindowInfoSnapshot(systemInfo: {\n pixelRatio: number\n screenWidth: number\n screenHeight: number\n windowWidth: number\n windowHeight: number\n statusBarHeight: number\n}) {\n const safeArea = {\n left: 0,\n right: systemInfo.windowWidth,\n top: systemInfo.statusBarHeight,\n bottom: systemInfo.windowHeight,\n width: systemInfo.windowWidth,\n height: Math.max(0, systemInfo.windowHeight - systemInfo.statusBarHeight),\n }\n return {\n pixelRatio: systemInfo.pixelRatio,\n screenWidth: systemInfo.screenWidth,\n screenHeight: systemInfo.screenHeight,\n windowWidth: systemInfo.windowWidth,\n windowHeight: systemInfo.windowHeight,\n statusBarHeight: systemInfo.statusBarHeight,\n screenTop: systemInfo.statusBarHeight,\n safeArea,\n }\n}\n\nexport function readDeviceMemorySize() {\n const runtimeNavigator = (typeof navigator !== 'undefined' ? navigator : undefined) as (Navigator & {\n deviceMemory?: number\n }) | undefined\n return normalizeMemorySize(runtimeNavigator?.deviceMemory)\n}\n\nexport function resolveAccountAppId() {\n const runtimeLocation = (typeof location !== 'undefined' ? location : undefined) as {\n hostname?: string\n } | undefined\n const host = runtimeLocation?.hostname?.trim()\n return host ? `web:${host}` : 'web'\n}\n\nexport function buildMenuButtonRect(windowWidth: number, statusBarHeight: number) {\n const width = 88\n const height = 32\n const right = Math.max(width, windowWidth - 8)\n const top = Math.max(0, statusBarHeight + (44 - height) / 2)\n const left = Math.max(0, right - width)\n return {\n width,\n height,\n top,\n right,\n bottom: top + height,\n left,\n }\n}\n"],"mappings":";AAAA,SAAgB,kBAAkB,WAAmB;AACnD,KAAI,WAAW,KAAK,UAAU,CAC5B,QAAO;AAET,KAAI,oBAAoB,KAAK,UAAU,CACrC,QAAO;AAET,KAAI,WAAW,KAAK,UAAU,CAC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c,EAAE;CAC9C,MAAM,MAAM,KAAK,IAAI,GAAG,mBAAmB,KAAK,UAAU,EAAE;CAC5D,MAAM,OAAO,KAAK,IAAI,GAAG,QAAQ,MAAM;AACvC,QAAO;EACL;EACA;EACA;EACA;EACA,QAAQ,MAAM;EACd;EACD"}
@@ -0,0 +1,65 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "./async.mjs";
2
+ import { buildMenuButtonRect, buildWindowInfoSnapshot, readDeviceMemorySize, readSystemInfoSnapshot, resolveAccountAppId, resolveDeviceOrientation, resolveRuntimeTheme } from "./system.mjs";
3
+
4
+ //#region src/runtime/polyfill/systemApi.ts
5
+ function getSystemInfoSyncBridge() {
6
+ return readSystemInfoSnapshot();
7
+ }
8
+ function getSystemInfoBridge(options) {
9
+ try {
10
+ const info = getSystemInfoSyncBridge();
11
+ return Promise.resolve(callWxAsyncSuccess(options, {
12
+ errMsg: "getSystemInfo:ok",
13
+ ...info
14
+ }));
15
+ } catch (error) {
16
+ const failure = callWxAsyncFailure(options, `getSystemInfo:fail ${error instanceof Error ? error.message : String(error)}`);
17
+ return Promise.reject(failure);
18
+ }
19
+ }
20
+ function getWindowInfoBridge() {
21
+ return buildWindowInfoSnapshot(getSystemInfoSyncBridge());
22
+ }
23
+ function getDeviceInfoBridge() {
24
+ const systemInfo = getSystemInfoSyncBridge();
25
+ return {
26
+ brand: systemInfo.brand,
27
+ model: systemInfo.model,
28
+ system: systemInfo.system,
29
+ platform: systemInfo.platform,
30
+ memorySize: readDeviceMemorySize(),
31
+ benchmarkLevel: -1,
32
+ abi: "web",
33
+ deviceOrientation: resolveDeviceOrientation()
34
+ };
35
+ }
36
+ function getAccountInfoSyncBridge() {
37
+ return {
38
+ miniProgram: {
39
+ appId: resolveAccountAppId(),
40
+ envVersion: "develop",
41
+ version: "0.0.0-web"
42
+ },
43
+ plugin: {}
44
+ };
45
+ }
46
+ function getAppBaseInfoBridge() {
47
+ const systemInfo = getSystemInfoSyncBridge();
48
+ const runtimeNavigator = typeof navigator !== "undefined" ? navigator : void 0;
49
+ return {
50
+ SDKVersion: "web",
51
+ language: runtimeNavigator?.language ?? "en",
52
+ version: runtimeNavigator?.appVersion ?? runtimeNavigator?.userAgent ?? "web",
53
+ platform: systemInfo.platform,
54
+ enableDebug: false,
55
+ theme: resolveRuntimeTheme()
56
+ };
57
+ }
58
+ function getMenuButtonBoundingClientRectBridge() {
59
+ const { windowWidth, statusBarHeight } = getSystemInfoSyncBridge();
60
+ return buildMenuButtonRect(windowWidth, statusBarHeight);
61
+ }
62
+
63
+ //#endregion
64
+ export { getAccountInfoSyncBridge, getAppBaseInfoBridge, getDeviceInfoBridge, getMenuButtonBoundingClientRectBridge, getSystemInfoBridge, getSystemInfoSyncBridge, getWindowInfoBridge };
65
+ //# sourceMappingURL=systemApi.mjs.map