@weapp-vite/web 1.3.14 → 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 +2 -2
  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 @@
1
+ {"version":3,"file":"files.mjs","names":[],"sources":["../../../src/runtime/polyfill/files.ts"],"sourcesContent":["export const WEB_USER_DATA_PATH = '/__weapp_vite_web_user_data__'\n\ninterface MemoryFileRecord {\n kind: 'text' | 'binary'\n text?: string\n bytes?: ArrayBuffer\n}\n\nconst memoryFileStorage = new Map<string, MemoryFileRecord>()\n\nexport function normalizeFilePath(filePath: unknown) {\n if (typeof filePath !== 'string') {\n return ''\n }\n return filePath.trim()\n}\n\nfunction normalizeFileEncoding(encoding?: string) {\n if (typeof encoding !== 'string') {\n return ''\n }\n return encoding.trim().toLowerCase()\n}\n\nfunction cloneArrayBuffer(buffer: ArrayBuffer) {\n return buffer.slice(0)\n}\n\nfunction toArrayBuffer(data: ArrayBuffer | ArrayBufferView) {\n if (data instanceof ArrayBuffer) {\n return cloneArrayBuffer(data)\n }\n const view = data as ArrayBufferView\n return new Uint8Array(view.buffer, view.byteOffset, view.byteLength).slice().buffer\n}\n\nfunction decodeArrayBufferToText(buffer: ArrayBuffer, encoding?: string) {\n if (typeof TextDecoder === 'function') {\n try {\n return new TextDecoder(encoding || 'utf-8').decode(new Uint8Array(buffer))\n }\n catch {\n return new TextDecoder().decode(new Uint8Array(buffer))\n }\n }\n return Array.from(new Uint8Array(buffer))\n .map(byte => String.fromCharCode(byte))\n .join('')\n}\n\nexport function writeFileSyncInternal(\n filePath: string,\n data: string | ArrayBuffer | ArrayBufferView,\n) {\n const normalizedPath = normalizeFilePath(filePath)\n if (!normalizedPath) {\n throw new TypeError('writeFileSync:fail invalid filePath')\n }\n if (typeof data === 'string') {\n memoryFileStorage.set(normalizedPath, {\n kind: 'text',\n text: data,\n })\n return\n }\n memoryFileStorage.set(normalizedPath, {\n kind: 'binary',\n bytes: toArrayBuffer(data),\n })\n}\n\nexport function readFileSyncInternal(filePath: string, encoding?: string) {\n const normalizedPath = normalizeFilePath(filePath)\n if (!normalizedPath) {\n throw new TypeError('readFileSync:fail invalid filePath')\n }\n const record = memoryFileStorage.get(normalizedPath)\n if (!record) {\n throw new TypeError(`readFileSync:fail no such file ${normalizedPath}`)\n }\n const normalizedEncoding = normalizeFileEncoding(encoding)\n if (record.kind === 'text') {\n return record.text ?? ''\n }\n const bytes = record.bytes ? cloneArrayBuffer(record.bytes) : new ArrayBuffer(0)\n if (normalizedEncoding) {\n return decodeArrayBufferToText(bytes, normalizedEncoding)\n }\n return bytes\n}\n\nexport function resolveUploadFileName(filePath: string) {\n const normalized = filePath.split(/[?#]/)[0] ?? ''\n const segments = normalized.split('/')\n return segments[segments.length - 1] || 'file'\n}\n\nexport async function resolveUploadFileBlob(\n filePath: string,\n runtimeFetch: typeof fetch | undefined,\n) {\n const record = memoryFileStorage.get(filePath)\n if (record) {\n if (record.kind === 'text') {\n return new Blob([record.text ?? ''], { type: 'text/plain;charset=utf-8' })\n }\n return new Blob([record.bytes ?? new ArrayBuffer(0)])\n }\n if (/^(?:https?:|blob:|data:)/i.test(filePath) && runtimeFetch) {\n try {\n const response = await runtimeFetch(filePath, { method: 'GET' })\n return await response.blob()\n }\n catch {\n // fallback to plain text payload\n }\n }\n return new Blob([filePath], { type: 'text/plain;charset=utf-8' })\n}\n\nfunction cloneMemoryFileRecord(record: MemoryFileRecord): MemoryFileRecord {\n if (record.kind === 'text') {\n return {\n kind: 'text',\n text: record.text ?? '',\n }\n }\n return {\n kind: 'binary',\n bytes: record.bytes ? cloneArrayBuffer(record.bytes) : new ArrayBuffer(0),\n }\n}\n\nexport function resolveSaveFilePath(tempFilePath: string, customPath?: string) {\n const targetPath = typeof customPath === 'string' ? customPath.trim() : ''\n if (targetPath) {\n return targetPath\n }\n return `${WEB_USER_DATA_PATH}/${resolveUploadFileName(tempFilePath)}`\n}\n\nexport function saveMemoryFile(tempFilePath: string, savedFilePath: string) {\n const sourceRecord = memoryFileStorage.get(tempFilePath)\n if (sourceRecord) {\n memoryFileStorage.set(savedFilePath, cloneMemoryFileRecord(sourceRecord))\n return\n }\n memoryFileStorage.set(savedFilePath, {\n kind: 'text',\n text: tempFilePath,\n })\n}\n\nexport function resolveOpenDocumentUrl(filePath: string) {\n const record = memoryFileStorage.get(filePath)\n const runtimeUrl = (globalThis as {\n URL?: {\n createObjectURL?: (value: unknown) => string\n }\n }).URL\n\n if (record) {\n if (record.kind === 'text') {\n const text = record.text ?? ''\n if (typeof Blob === 'function' && runtimeUrl?.createObjectURL) {\n return runtimeUrl.createObjectURL(new Blob([text], { type: 'text/plain;charset=utf-8' }))\n }\n return `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`\n }\n const bytes = record.bytes ?? new ArrayBuffer(0)\n if (typeof Blob === 'function' && runtimeUrl?.createObjectURL) {\n return runtimeUrl.createObjectURL(new Blob([bytes]))\n }\n return ''\n }\n\n if (/^(?:https?:|blob:|data:)/i.test(filePath)) {\n return filePath\n }\n try {\n const runtimeLocation = (typeof location !== 'undefined' ? location : undefined) as { href?: string } | undefined\n if (runtimeLocation?.href) {\n return new URL(filePath, runtimeLocation.href).toString()\n }\n }\n catch {\n // fallback to raw filePath\n }\n return filePath\n}\n"],"mappings":";AAAA,MAAa,qBAAqB;AAQlC,MAAM,oCAAoB,IAAI,KAA+B;AAE7D,SAAgB,kBAAkB,UAAmB;AACnD,KAAI,OAAO,aAAa,SACtB,QAAO;AAET,QAAO,SAAS,MAAM;;AAGxB,SAAS,sBAAsB,UAAmB;AAChD,KAAI,OAAO,aAAa,SACtB,QAAO;AAET,QAAO,SAAS,MAAM,CAAC,aAAa;;AAGtC,SAAS,iBAA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,SAAgB,uBAAuB,UAAkB;CACvD,MAAM,SAAS,kBAAkB,IAAI,SAAS;CAC9C,MAAM,aAAc,WAIjB;AAEH,KAAI,QAAQ;AACV,MAAI,OAAO,SAAS,QAAQ;GAC1B,MAAM,OAAO,OAAO,QAAQ;AAC5B,OAAI,OAAO,SAAS,cAAc,YAAY,gBAC5C,QAAO,WAAW,gBAAgB,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,4BAA4B,CAAC,CAAC;AAE3F,UAAO,iCAAiC,mBAAmB,KAAK;;EAElE,MAAM,QAAQ,OAAO,yBAAS,IAAI,YAAY,EAAE;AAChD,MAAI,OAAO,SAAS,cAAc,YAAY,gBAC5C,QAAO,WAAW,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAEtD,SAAO;;AAGT,KAAI,4BAA4B,KAAK,SAAS,CAC5C,QAAO;AAET,KAAI;EACF,MAAM,kBAAmB,OAAO,aAAa,cAAc,WAAW;AACtE,MAAI,iBAAiB,KACnB,QAAO,IAAI,IAAI,UAAU,gBAAgB,KAAK,CAAC,UAAU;SAGvD;AAGN,QAAO"}
@@ -0,0 +1,40 @@
1
+ import { LogManager, LogManagerOptions, SetBackgroundColorOptions, SetBackgroundTextStyleOptions, UpdateManager } from "./types/locationRuntime.mjs";
2
+ import { AdBaseOptions, GetExtConfigOptions, InterstitialAd, RewardedVideoAd } from "./types/platformRuntime.mjs";
3
+ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./deviceAuthSystemApi.mjs";
4
+ import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
5
+ import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtimeDataApi.mjs";
6
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./uiMediaApi.mjs";
7
+
8
+ //#region src/runtime/polyfill/index.d.ts
9
+ declare function setNavigationBarTitle(options: {
10
+ title: string;
11
+ }): Promise<void>;
12
+ declare function setNavigationBarColor(options: {
13
+ frontColor?: string;
14
+ backgroundColor?: string;
15
+ animation?: {
16
+ duration?: number;
17
+ timingFunction?: string;
18
+ };
19
+ }): Promise<void>;
20
+ declare function showNavigationBarLoading(): Promise<void>;
21
+ declare function hideNavigationBarLoading(): Promise<void>;
22
+ declare function setBackgroundColor(options?: SetBackgroundColorOptions): Promise<{
23
+ errMsg: string;
24
+ }>;
25
+ declare function setBackgroundTextStyle(options?: SetBackgroundTextStyleOptions): Promise<{
26
+ errMsg: string;
27
+ }>;
28
+ declare function canIUse(schema: string): boolean;
29
+ declare function createRewardedVideoAd(options?: AdBaseOptions): RewardedVideoAd;
30
+ declare function createInterstitialAd(options?: AdBaseOptions): InterstitialAd;
31
+ declare function getExtConfigSync(): {
32
+ [x: string]: unknown;
33
+ };
34
+ declare function getExtConfig(options?: GetExtConfigOptions): Promise<any>;
35
+ declare function getUpdateManager(): UpdateManager;
36
+ declare function getLogManager(options?: LogManagerOptions): LogManager;
37
+ declare function reportAnalytics(eventName: string, data?: Record<string, unknown>): void;
38
+ //#endregion
39
+ export { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading };
40
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,99 @@
1
+ import { emitRuntimeWarning } from "../warning.mjs";
2
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "./async.mjs";
3
+ import { setBackgroundColorBridge, setBackgroundTextStyleBridge } from "./background.mjs";
4
+ import { createCloudBridge } from "./cloud.mjs";
5
+ import { WEB_USER_DATA_PATH } from "./files.mjs";
6
+ import { canIUseBridge } from "./runtimeCapabilityApi.mjs";
7
+ import { authorize, checkSession, deviceAuthSystemApi_exports, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./deviceAuthSystemApi.mjs";
8
+ import { createNavigationBarRuntimeBridge } from "./navigationBarRuntime.mjs";
9
+ import { createInterstitialAdBridge, createRewardedVideoAdBridge, getExtConfigBridge, getExtConfigSyncBridge, getLogManagerBridge, getUpdateManagerBridge, reportAnalyticsBridge } from "./platformApi.mjs";
10
+ import { getAppInstance, getCurrentPagesInternal, getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
11
+ import { clearStorage, clearStorageSync, createCanvasContext, 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 } from "./runtimeDataApi.mjs";
12
+ import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, uiMediaApi_exports, updateShareMenu } from "./uiMediaApi.mjs";
13
+
14
+ //#region src/runtime/polyfill/index.ts
15
+ const navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(() => getCurrentPagesInternal(), emitRuntimeWarning);
16
+ function setNavigationBarTitle(options) {
17
+ return navigationBarRuntimeBridge.setNavigationBarTitle(options);
18
+ }
19
+ function setNavigationBarColor(options) {
20
+ return navigationBarRuntimeBridge.setNavigationBarColor(options);
21
+ }
22
+ function showNavigationBarLoading() {
23
+ return navigationBarRuntimeBridge.showNavigationBarLoading();
24
+ }
25
+ function hideNavigationBarLoading() {
26
+ return navigationBarRuntimeBridge.hideNavigationBarLoading();
27
+ }
28
+ function setBackgroundColor(options) {
29
+ return setBackgroundColorBridge(options);
30
+ }
31
+ function setBackgroundTextStyle(options) {
32
+ return setBackgroundTextStyleBridge(options);
33
+ }
34
+ function canIUse(schema) {
35
+ return canIUseBridge(globalTarget.wx, schema);
36
+ }
37
+ const cloudBridge = createCloudBridge((options, result) => callWxAsyncSuccess(options, result), (options, errMsg) => callWxAsyncFailure(options, errMsg));
38
+ function createRewardedVideoAd(options) {
39
+ return createRewardedVideoAdBridge(options);
40
+ }
41
+ function createInterstitialAd(options) {
42
+ return createInterstitialAdBridge(options);
43
+ }
44
+ function getExtConfigSync() {
45
+ return getExtConfigSyncBridge();
46
+ }
47
+ function getExtConfig(options) {
48
+ return getExtConfigBridge(options);
49
+ }
50
+ function getUpdateManager() {
51
+ return getUpdateManagerBridge();
52
+ }
53
+ function getLogManager(options) {
54
+ return getLogManagerBridge(options);
55
+ }
56
+ function reportAnalytics(eventName, data) {
57
+ reportAnalyticsBridge(eventName, data);
58
+ }
59
+ const globalTarget = typeof globalThis !== "undefined" ? globalThis : {};
60
+ if (globalTarget) {
61
+ const wxBridge = globalTarget.wx ?? {};
62
+ Object.assign(wxBridge, {
63
+ navigateTo,
64
+ navigateBack,
65
+ redirectTo,
66
+ switchTab,
67
+ reLaunch,
68
+ getLaunchOptionsSync,
69
+ getEnterOptionsSync,
70
+ ...runtimeDataApi_exports,
71
+ setNavigationBarTitle,
72
+ setNavigationBarColor,
73
+ setBackgroundColor,
74
+ setBackgroundTextStyle,
75
+ showNavigationBarLoading,
76
+ hideNavigationBarLoading,
77
+ ...uiMediaApi_exports,
78
+ ...deviceAuthSystemApi_exports,
79
+ createRewardedVideoAd,
80
+ createInterstitialAd,
81
+ getExtConfigSync,
82
+ getExtConfig,
83
+ getUpdateManager,
84
+ getLogManager,
85
+ reportAnalytics,
86
+ canIUse,
87
+ cloud: cloudBridge
88
+ });
89
+ const wxEnv = wxBridge.env ?? {};
90
+ if (typeof wxEnv.USER_DATA_PATH !== "string" || !wxEnv.USER_DATA_PATH.trim()) wxEnv.USER_DATA_PATH = WEB_USER_DATA_PATH;
91
+ wxBridge.env = wxEnv;
92
+ globalTarget.wx = wxBridge;
93
+ if (typeof globalTarget.getApp !== "function") globalTarget.getApp = getAppInstance;
94
+ if (typeof globalTarget.getCurrentPages !== "function") globalTarget.getCurrentPages = getCurrentPagesInternal;
95
+ }
96
+
97
+ //#endregion
98
+ export { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading };
99
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["runtimeDataApi","uiMediaApi","deviceAuthSystemApi"],"sources":["../../../src/runtime/polyfill/index.ts"],"sourcesContent":["import type {\n AdBaseOptions,\n CloudBridge,\n GetExtConfigOptions,\n InterstitialAd,\n LogManager,\n LogManagerOptions,\n RewardedVideoAd,\n SetBackgroundColorOptions,\n SetBackgroundTextStyleOptions,\n UpdateManager,\n WxAsyncOptions,\n WxBaseResult,\n} from './types'\nimport { emitRuntimeWarning } from '../warning'\nimport {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from './async'\nimport {\n setBackgroundColorBridge,\n setBackgroundTextStyleBridge,\n} from './background'\nimport { createCloudBridge } from './cloud'\nimport * as deviceAuthSystemApi from './deviceAuthSystemApi'\nimport { WEB_USER_DATA_PATH } from './files'\nimport { createNavigationBarRuntimeBridge } from './navigationBarRuntime'\nimport {\n createInterstitialAdBridge,\n createRewardedVideoAdBridge,\n getExtConfigBridge,\n getExtConfigSyncBridge,\n getLogManagerBridge,\n getUpdateManagerBridge,\n reportAnalyticsBridge,\n} from './platformApi'\nimport {\n getAppInstance,\n getCurrentPagesInternal,\n getEnterOptionsSync,\n getLaunchOptionsSync,\n navigateBack,\n navigateTo,\n redirectTo,\n reLaunch,\n switchTab,\n} from './routeRuntime'\nimport {\n canIUseBridge,\n} from './runtimeCapabilityApi'\nimport * as runtimeDataApi from './runtimeDataApi'\nimport * as uiMediaApi from './uiMediaApi'\n\nexport * from './deviceAuthSystemApi'\n\nexport {\n getEnterOptionsSync,\n getLaunchOptionsSync,\n initializePageRoutes,\n navigateBack,\n navigateTo,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n switchTab,\n} from './routeRuntime'\n\nexport * from './runtimeDataApi'\nexport * from './uiMediaApi'\n\nconst navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(\n () => getCurrentPagesInternal() as Array<HTMLElement & { renderRoot?: ShadowRoot | HTMLElement }>,\n emitRuntimeWarning,\n)\n\nexport function setNavigationBarTitle(options: { title: string }) {\n return navigationBarRuntimeBridge.setNavigationBarTitle(options)\n}\n\nexport function setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n}) {\n return navigationBarRuntimeBridge.setNavigationBarColor(options)\n}\n\nexport function showNavigationBarLoading() {\n return navigationBarRuntimeBridge.showNavigationBarLoading()\n}\n\nexport function hideNavigationBarLoading() {\n return navigationBarRuntimeBridge.hideNavigationBarLoading()\n}\n\nexport function setBackgroundColor(options?: SetBackgroundColorOptions) {\n return setBackgroundColorBridge(options)\n}\n\nexport function setBackgroundTextStyle(options?: SetBackgroundTextStyleOptions) {\n return setBackgroundTextStyleBridge(options)\n}\n\nexport function canIUse(schema: string) {\n return canIUseBridge(globalTarget.wx as Record<string, unknown> | undefined, schema)\n}\n\nconst cloudBridge: CloudBridge = createCloudBridge(\n (options, result) => callWxAsyncSuccess(\n options as unknown as WxAsyncOptions<WxBaseResult> | undefined,\n result as WxBaseResult,\n ),\n (options, errMsg) => callWxAsyncFailure(\n options as unknown as WxAsyncOptions<WxBaseResult> | undefined,\n errMsg,\n ),\n) as CloudBridge\n\nexport function createRewardedVideoAd(options?: AdBaseOptions): RewardedVideoAd {\n return createRewardedVideoAdBridge(options)\n}\n\nexport function createInterstitialAd(options?: AdBaseOptions): InterstitialAd {\n return createInterstitialAdBridge(options)\n}\n\nexport function getExtConfigSync() {\n return getExtConfigSyncBridge()\n}\n\nexport function getExtConfig(options?: GetExtConfigOptions) {\n return getExtConfigBridge(options)\n}\n\nexport function getUpdateManager(): UpdateManager {\n return getUpdateManagerBridge()\n}\n\nexport function getLogManager(options?: LogManagerOptions): LogManager {\n return getLogManagerBridge(options)\n}\n\nexport function reportAnalytics(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsBridge(eventName, data)\n}\n\nconst globalTarget = typeof globalThis !== 'undefined' ? (globalThis as Record<string, unknown>) : {}\n\nif (globalTarget) {\n const wxBridge = (globalTarget.wx as Record<string, unknown> | undefined) ?? {}\n Object.assign(wxBridge, {\n navigateTo,\n navigateBack,\n redirectTo,\n switchTab,\n reLaunch,\n getLaunchOptionsSync,\n getEnterOptionsSync,\n ...runtimeDataApi,\n setNavigationBarTitle,\n setNavigationBarColor,\n setBackgroundColor,\n setBackgroundTextStyle,\n showNavigationBarLoading,\n hideNavigationBarLoading,\n ...uiMediaApi,\n ...deviceAuthSystemApi,\n createRewardedVideoAd,\n createInterstitialAd,\n getExtConfigSync,\n getExtConfig,\n getUpdateManager,\n getLogManager,\n reportAnalytics,\n canIUse,\n cloud: cloudBridge,\n })\n const wxEnv = (wxBridge.env as Record<string, unknown> | undefined) ?? {}\n if (typeof wxEnv.USER_DATA_PATH !== 'string' || !wxEnv.USER_DATA_PATH.trim()) {\n wxEnv.USER_DATA_PATH = WEB_USER_DATA_PATH\n }\n wxBridge.env = wxEnv\n globalTarget.wx = wxBridge\n if (typeof globalTarget.getApp !== 'function') {\n globalTarget.getApp = getAppInstance\n }\n if (typeof globalTarget.getCurrentPages !== 'function') {\n globalTarget.getCurrentPages = getCurrentPagesInternal\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAwEA,MAAM,6BAA6B,uCAC3B,yBAAyB,EAC/B,mBACD;AAED,SAAgB,sBAAsB,SAA4B;AAChE,QAAO,2BAA2B,sBAAsB,QAAQ;;AAGlE,SAAgB,sBAAsB,SAInC;AACD,QAAO,2BAA2B,sBAAsB,QAAQ;;AAGlE,SAAgB,2BAA2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WACjC,cAAa,SAAS;AAExB,KAAI,OAAO,aAAa,oBAAoB,WAC1C,cAAa,kBAAkB"}
@@ -0,0 +1,38 @@
1
+ import { WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY } from "@weapp-core/constants";
2
+
3
+ //#region src/runtime/polyfill/interaction.ts
4
+ function resolveScanCodeResult(prompt) {
5
+ let rawResult = globalThis[WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY];
6
+ if (rawResult == null && typeof prompt === "function") rawResult = prompt("请输入二维码/条码内容", "");
7
+ if (rawResult == null) return null;
8
+ if (typeof rawResult === "string") return rawResult;
9
+ return String(rawResult?.result ?? "");
10
+ }
11
+ async function writeClipboardData(data) {
12
+ const runtimeNavigator = typeof navigator !== "undefined" ? navigator : void 0;
13
+ if (runtimeNavigator?.clipboard && typeof runtimeNavigator.clipboard.writeText === "function") {
14
+ await runtimeNavigator.clipboard.writeText(data);
15
+ return;
16
+ }
17
+ if (typeof document === "undefined" || !document.body) throw new Error("Clipboard API is unavailable in current environment.");
18
+ const execCommand = document.execCommand;
19
+ if (typeof execCommand !== "function") throw new TypeError("Clipboard API is unavailable in current environment.");
20
+ const textarea = document.createElement("textarea");
21
+ textarea.value = data;
22
+ textarea.setAttribute("readonly", "true");
23
+ textarea.setAttribute("style", "position: fixed; top: -9999px; left: -9999px; opacity: 0;");
24
+ document.body.append(textarea);
25
+ textarea.select?.();
26
+ const copied = execCommand.call(document, "copy");
27
+ if (textarea.parentNode) textarea.parentNode.removeChild(textarea);
28
+ if (!copied) throw new Error("document.execCommand(\"copy\") returned false.");
29
+ }
30
+ async function readClipboardData() {
31
+ const runtimeNavigator = typeof navigator !== "undefined" ? navigator : void 0;
32
+ if (!runtimeNavigator?.clipboard || typeof runtimeNavigator.clipboard.readText !== "function") throw new Error("Clipboard API is unavailable in current environment.");
33
+ return runtimeNavigator.clipboard.readText();
34
+ }
35
+
36
+ //#endregion
37
+ export { readClipboardData, resolveScanCodeResult, writeClipboardData };
38
+ //# sourceMappingURL=interaction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction.mjs","names":[],"sources":["../../../src/runtime/polyfill/interaction.ts"],"sourcesContent":["import { WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY } from '@weapp-core/constants'\n\nexport function resolveScanCodeResult(prompt?: (message: string, defaultValue: string) => unknown) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n let rawResult: unknown = runtimeGlobal[WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY]\n if (rawResult == null && typeof prompt === 'function') {\n rawResult = prompt('请输入二维码/条码内容', '')\n }\n if (rawResult == null) {\n return null\n }\n if (typeof rawResult === 'string') {\n return rawResult\n }\n return String((rawResult as { result?: unknown })?.result ?? '')\n}\n\nexport async function writeClipboardData(data: string) {\n const runtimeNavigator = typeof navigator !== 'undefined' ? navigator : undefined\n if (runtimeNavigator?.clipboard && typeof runtimeNavigator.clipboard.writeText === 'function') {\n await runtimeNavigator.clipboard.writeText(data)\n return\n }\n\n if (typeof document === 'undefined' || !document.body) {\n throw new Error('Clipboard API is unavailable in current environment.')\n }\n\n const execCommand = (document as Document & { execCommand?: (command: string) => boolean }).execCommand\n if (typeof execCommand !== 'function') {\n throw new TypeError('Clipboard API is unavailable in current environment.')\n }\n\n const textarea = document.createElement('textarea') as HTMLTextAreaElement\n textarea.value = data\n textarea.setAttribute('readonly', 'true')\n textarea.setAttribute('style', 'position: fixed; top: -9999px; left: -9999px; opacity: 0;')\n document.body.append(textarea)\n textarea.select?.()\n const copied = execCommand.call(document, 'copy')\n if (textarea.parentNode) {\n textarea.parentNode.removeChild(textarea)\n }\n if (!copied) {\n throw new Error('document.execCommand(\"copy\") returned false.')\n }\n}\n\nexport async function readClipboardData() {\n const runtimeNavigator = typeof navigator !== 'undefined' ? navigator : undefined\n if (!runtimeNavigator?.clipboard || typeof runtimeNavigator.clipboard.readText !== 'function') {\n throw new Error('Clipboard API is unavailable in current environment.')\n }\n return runtimeNavigator.clipboard.readText()\n}\n"],"mappings":";;;AAEA,SAAgB,sBAAsB,QAA6D;CAEjG,IAAI,YADkB,WACiB;AACvC,KAAI,aAAa,QAAQ,OAAO,WAAW,WACzC,aAAY,OAAO,eAAe,GAAG;AAEvC,KAAI,aAAa,KACf,QAAO;AAET,KAAI,OAAO,cAAc,SACvB,QAAO;AAET,QAAO,OAAQ,WAAoC,UAAU,GAAG;;AAGlE,eAAsB,mBAAmB,MAAc;CACrD,MAAM,mBAAmB,OAAO,cAAc,cAAc,YAAY;AACxE,KAAI,kBAAkB,aAAa,OAAO,iBAAiB,UAAU,cAAc,YAAY;AAC7F,QAAM,iBAAiB,UAAU,UAAU,KAAK;AAChD;;AAGF,KAAI,OAAO,aAAa,eAAe,CAAC,SAAS,KAC/C,OAAM,IAAI,MAAM,uDAAuD;CAGzE,MAAM,cAAe,SAAuE;AAC5F,KAAI,OAAO,gBAAgB,WACzB,OAAM,IAAI,UAAU,uDAAuD;CAG7E,MAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAS,QAAQ;AACjB,UAAS,aAAa,YAAY,OAAO;AACzC,UAAS,aAAa,SAAS,4DAA4D;AAC3F,UAAS,KAAK,OAAO,SAAS;AAC9B,UAAS,UAAU;CACnB,MAAM,SAAS,YAAY,KAAK,UAAU,OAAO;AACjD,KAAI,SAAS,WACX,UAAS,WAAW,YAAY,SAAS;AAE3C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iDAA+C;;AAInE,eAAsB,oBAAoB;CACxC,MAAM,mBAAmB,OAAO,cAAc,cAAc,YAAY;AACxE,KAAI,CAAC,kBAAkB,aAAa,OAAO,iBAAiB,UAAU,aAAa,WACjF,OAAM,IAAI,MAAM,uDAAuD;AAEzE,QAAO,iBAAiB,UAAU,UAAU"}
@@ -0,0 +1,54 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "./async.mjs";
2
+ import { getGlobalDialogHandlers } from "./ui.mjs";
3
+ import { readClipboardData, resolveScanCodeResult, writeClipboardData } from "./interaction.mjs";
4
+
5
+ //#region src/runtime/polyfill/interactionApi.ts
6
+ function openCustomerServiceChatBridge(options) {
7
+ const url = options?.url?.trim() ?? "";
8
+ if (url && typeof window !== "undefined" && typeof window.open === "function") try {
9
+ window.open(url, "_blank", "noopener,noreferrer");
10
+ } catch {}
11
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "openCustomerServiceChat:ok" }));
12
+ }
13
+ function scanCodeBridge(options) {
14
+ const { prompt } = getGlobalDialogHandlers();
15
+ const resultText = resolveScanCodeResult(prompt);
16
+ if (resultText == null) {
17
+ const failure = callWxAsyncFailure(options, "scanCode:fail cancel");
18
+ return Promise.reject(failure);
19
+ }
20
+ const result = callWxAsyncSuccess(options, {
21
+ errMsg: "scanCode:ok",
22
+ result: resultText,
23
+ scanType: "QR_CODE",
24
+ charSet: "utf-8",
25
+ path: resultText,
26
+ rawData: resultText
27
+ });
28
+ return Promise.resolve(result);
29
+ }
30
+ async function setClipboardDataBridge(options) {
31
+ const data = String(options?.data ?? "");
32
+ try {
33
+ await writeClipboardData(data);
34
+ } catch (error) {
35
+ const failure = callWxAsyncFailure(options, `setClipboardData:fail ${error instanceof Error ? error.message : String(error)}`);
36
+ return Promise.reject(failure);
37
+ }
38
+ return callWxAsyncSuccess(options, { errMsg: "setClipboardData:ok" });
39
+ }
40
+ async function getClipboardDataBridge(options) {
41
+ try {
42
+ return callWxAsyncSuccess(options, {
43
+ errMsg: "getClipboardData:ok",
44
+ data: await readClipboardData()
45
+ });
46
+ } catch (error) {
47
+ const failure = callWxAsyncFailure(options, `getClipboardData:fail ${error instanceof Error ? error.message : String(error)}`);
48
+ return Promise.reject(failure);
49
+ }
50
+ }
51
+
52
+ //#endregion
53
+ export { getClipboardDataBridge, openCustomerServiceChatBridge, scanCodeBridge, setClipboardDataBridge };
54
+ //# sourceMappingURL=interactionApi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactionApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/interactionApi.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from './async'\nimport {\n readClipboardData,\n resolveScanCodeResult,\n writeClipboardData,\n} from './interaction'\nimport { getGlobalDialogHandlers } from './ui'\n\nexport function openCustomerServiceChatBridge(options?: any) {\n const url = options?.url?.trim() ?? ''\n if (url && typeof window !== 'undefined' && typeof window.open === 'function') {\n try {\n window.open(url, '_blank', 'noopener,noreferrer')\n }\n catch {\n // ignore browser popup restrictions\n }\n }\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'openCustomerServiceChat:ok' }))\n}\n\nexport function scanCodeBridge(options?: any) {\n const { prompt } = getGlobalDialogHandlers()\n const resultText = resolveScanCodeResult(prompt)\n if (resultText == null) {\n const failure = callWxAsyncFailure(options, 'scanCode:fail cancel')\n return Promise.reject(failure)\n }\n const result = callWxAsyncSuccess(options, {\n errMsg: 'scanCode:ok',\n result: resultText,\n scanType: 'QR_CODE',\n charSet: 'utf-8',\n path: resultText,\n rawData: resultText,\n })\n return Promise.resolve(result)\n}\n\nexport async function setClipboardDataBridge(options?: any) {\n const data = String(options?.data ?? '')\n try {\n await writeClipboardData(data)\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `setClipboardData:fail ${message}`)\n return Promise.reject(failure)\n }\n return callWxAsyncSuccess(options, { errMsg: 'setClipboardData:ok' })\n}\n\nexport async function getClipboardDataBridge(options?: any) {\n try {\n const data = await readClipboardData()\n return callWxAsyncSuccess(options, { errMsg: 'getClipboardData:ok', data })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `getClipboardData:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;AAWA,SAAgB,8BAA8B,SAAe;CAC3D,MAAM,MAAM,SAAS,KAAK,MAAM,IAAI;AACpC,KAAI,OAAO,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,WACjE,KAAI;AACF,SAA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,]/;
5
+ function normalizeGeoNumber(value, fallback = 0) {
6
+ if (typeof value !== "number" || Number.isNaN(value)) return fallback;
7
+ return value;
8
+ }
9
+ function readCurrentLocation(options) {
10
+ const geolocation = (typeof navigator !== "undefined" ? navigator : void 0)?.geolocation;
11
+ if (!geolocation || typeof geolocation.getCurrentPosition !== "function") throw new Error("geolocation is unavailable");
12
+ const timeout = typeof options?.highAccuracyExpireTime === "number" && options.highAccuracyExpireTime > 0 ? options.highAccuracyExpireTime : void 0;
13
+ return new Promise((resolve, reject) => {
14
+ geolocation.getCurrentPosition((position) => {
15
+ const coords = position.coords ?? {};
16
+ const accuracy = normalizeGeoNumber(coords.accuracy, 0);
17
+ resolve({
18
+ latitude: normalizeGeoNumber(coords.latitude, 0),
19
+ longitude: normalizeGeoNumber(coords.longitude, 0),
20
+ speed: normalizeGeoNumber(coords.speed, -1),
21
+ accuracy,
22
+ altitude: normalizeGeoNumber(coords.altitude, 0),
23
+ verticalAccuracy: normalizeGeoNumber(coords.altitudeAccuracy, 0),
24
+ horizontalAccuracy: accuracy
25
+ });
26
+ }, (error) => {
27
+ reject(new Error(error?.message ?? "unknown error"));
28
+ }, {
29
+ enableHighAccuracy: Boolean(options?.isHighAccuracy || options?.altitude),
30
+ timeout
31
+ });
32
+ });
33
+ }
34
+ function normalizeFuzzyCoordinate(value) {
35
+ return Number(value.toFixed(2));
36
+ }
37
+ function readPresetFuzzyLocation() {
38
+ const preset = globalThis[WEAPP_VITE_WEB_FUZZY_LOCATION_KEY];
39
+ if (!preset || typeof preset !== "object") return null;
40
+ const value = preset;
41
+ const latitude = Number(value.latitude);
42
+ const longitude = Number(value.longitude);
43
+ if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
44
+ return {
45
+ latitude: normalizeFuzzyCoordinate(latitude),
46
+ longitude: normalizeFuzzyCoordinate(longitude),
47
+ accuracy: Math.max(1e3, normalizeGeoNumber(value.accuracy, 1e3))
48
+ };
49
+ }
50
+ function readPresetChooseLocation() {
51
+ const preset = globalThis[WEAPP_VITE_WEB_CHOOSE_LOCATION_KEY];
52
+ if (!preset || typeof preset !== "object") return null;
53
+ const value = preset;
54
+ const latitude = Number(value.latitude);
55
+ const longitude = Number(value.longitude);
56
+ if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
57
+ return {
58
+ name: typeof value.name === "string" ? value.name : "",
59
+ address: typeof value.address === "string" ? value.address : "",
60
+ latitude,
61
+ longitude
62
+ };
63
+ }
64
+ function readPresetChooseAddress() {
65
+ const preset = globalThis[WEAPP_VITE_WEB_CHOOSE_ADDRESS_KEY];
66
+ if (!preset || typeof preset !== "object") return null;
67
+ const value = preset;
68
+ return {
69
+ userName: typeof value.userName === "string" ? value.userName : "",
70
+ postalCode: typeof value.postalCode === "string" ? value.postalCode : "",
71
+ provinceName: typeof value.provinceName === "string" ? value.provinceName : "",
72
+ cityName: typeof value.cityName === "string" ? value.cityName : "",
73
+ countyName: typeof value.countyName === "string" ? value.countyName : "",
74
+ detailInfo: typeof value.detailInfo === "string" ? value.detailInfo : "",
75
+ nationalCode: typeof value.nationalCode === "string" ? value.nationalCode : "",
76
+ telNumber: typeof value.telNumber === "string" ? value.telNumber : ""
77
+ };
78
+ }
79
+ function parseChooseAddressPromptInput(input) {
80
+ const [provinceName = "", cityName = "", countyName = "", detailInfo = "", userName = "", telNumber = ""] = String(input).split(ADDRESS_PROMPT_SPLIT_RE).map((item) => item.trim());
81
+ if (!provinceName || !cityName || !countyName || !detailInfo) return null;
82
+ return {
83
+ userName,
84
+ postalCode: "",
85
+ provinceName,
86
+ cityName,
87
+ countyName,
88
+ detailInfo,
89
+ nationalCode: "",
90
+ telNumber
91
+ };
92
+ }
93
+ function parseChooseLocationPromptInput(input) {
94
+ const [latText = "", lonText = ""] = String(input).split(",").map((item) => item.trim());
95
+ const latitude = Number(latText);
96
+ const longitude = Number(lonText);
97
+ if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
98
+ return {
99
+ latitude,
100
+ longitude
101
+ };
102
+ }
103
+
104
+ //#endregion
105
+ export { normalizeFuzzyCoordinate, normalizeGeoNumber, parseChooseAddressPromptInput, parseChooseLocationPromptInput, readCurrentLocation, readPresetChooseAddress, readPresetChooseLocation, readPresetFuzzyLocation };
106
+ //# sourceMappingURL=location.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.mjs","names":[],"sources":["../../../src/runtime/polyfill/location.ts"],"sourcesContent":["import {\n WEAPP_VITE_WEB_CHOOSE_ADDRESS_KEY,\n WEAPP_VITE_WEB_CHOOSE_LOCATION_KEY,\n WEAPP_VITE_WEB_FUZZY_LOCATION_KEY,\n} from '@weapp-core/constants'\n\nconst ADDRESS_PROMPT_SPLIT_RE = /[,,]/\n\nexport function normalizeGeoNumber(value: unknown, fallback = 0) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return fallback\n }\n return value\n}\n\ninterface ReadCurrentLocationOptions {\n isHighAccuracy?: boolean\n altitude?: boolean\n highAccuracyExpireTime?: number\n}\n\ninterface LocationCoordinatesSnapshot {\n latitude: number\n longitude: number\n speed: number\n accuracy: number\n altitude: number\n verticalAccuracy: number\n horizontalAccuracy: number\n}\n\nexport function readCurrentLocation(options?: ReadCurrentLocationOptions) {\n const runtimeNavigator = (typeof navigator !== 'undefined' ? navigator : undefined) as (Navigator & {\n geolocation?: {\n getCurrentPosition?: (\n success: (position: {\n coords: {\n latitude?: number\n longitude?: number\n speed?: number | null\n accuracy?: number\n altitude?: number | null\n altitudeAccuracy?: number | null\n }\n }) => void,\n error?: (err: { message?: string }) => void,\n opts?: {\n enableHighAccuracy?: boolean\n timeout?: number\n },\n ) => void\n }\n }) | undefined\n const geolocation = runtimeNavigator?.geolocation\n if (!geolocation || typeof geolocation.getCurrentPosition !== 'function') {\n throw new Error('geolocation is unavailable')\n }\n const timeout = typeof options?.highAccuracyExpireTime === 'number' && options.highAccuracyExpireTime > 0\n ? options.highAccuracyExpireTime\n : undefined\n return new Promise<LocationCoordinatesSnapshot>((resolve, reject) => {\n geolocation.getCurrentPosition(\n (position) => {\n const coords = position.coords ?? {}\n const accuracy = normalizeGeoNumber(coords.accuracy, 0)\n resolve({\n latitude: normalizeGeoNumber(coords.latitude, 0),\n longitude: normalizeGeoNumber(coords.longitude, 0),\n speed: normalizeGeoNumber(coords.speed, -1),\n accuracy,\n altitude: normalizeGeoNumber(coords.altitude, 0),\n verticalAccuracy: normalizeGeoNumber(coords.altitudeAccuracy, 0),\n horizontalAccuracy: accuracy,\n })\n },\n (error) => {\n reject(new Error(error?.message ?? 'unknown error'))\n },\n {\n enableHighAccuracy: Boolean(options?.isHighAccuracy || options?.altitude),\n timeout,\n },\n )\n })\n}\n\nexport function normalizeFuzzyCoordinate(value: number) {\n return Number(value.toFixed(2))\n}\n\nexport function readPresetFuzzyLocation() {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_FUZZY_LOCATION_KEY]\n if (!preset || typeof preset !== 'object') {\n return null\n }\n const value = preset as Record<string, unknown>\n const latitude = Number(value.latitude)\n const longitude = Number(value.longitude)\n if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) {\n return null\n }\n return {\n latitude: normalizeFuzzyCoordinate(latitude),\n longitude: normalizeFuzzyCoordinate(longitude),\n accuracy: Math.max(1000, normalizeGeoNumber(value.accuracy, 1000)),\n }\n}\n\nexport function readPresetChooseLocation() {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_CHOOSE_LOCATION_KEY]\n if (!preset || typeof preset !== 'object') {\n return null\n }\n const value = preset as Record<string, unknown>\n const latitude = Number(value.latitude)\n const longitude = Number(value.longitude)\n if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) {\n return null\n }\n return {\n name: typeof value.name === 'string' ? value.name : '',\n address: typeof value.address === 'string' ? value.address : '',\n latitude,\n longitude,\n }\n}\n\nexport function readPresetChooseAddress() {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_CHOOSE_ADDRESS_KEY]\n if (!preset || typeof preset !== 'object') {\n return null\n }\n const value = preset as Record<string, unknown>\n return {\n userName: typeof value.userName === 'string' ? value.userName : '',\n postalCode: typeof value.postalCode === 'string' ? value.postalCode : '',\n provinceName: typeof value.provinceName === 'string' ? value.provinceName : '',\n cityName: typeof value.cityName === 'string' ? value.cityName : '',\n countyName: typeof value.countyName === 'string' ? value.countyName : '',\n detailInfo: typeof value.detailInfo === 'string' ? value.detailInfo : '',\n nationalCode: typeof value.nationalCode === 'string' ? value.nationalCode : '',\n telNumber: typeof value.telNumber === 'string' ? value.telNumber : '',\n }\n}\n\nexport function parseChooseAddressPromptInput(input: unknown) {\n const [provinceName = '', cityName = '', countyName = '', detailInfo = '', userName = '', telNumber = '']\n = String(input).split(ADDRESS_PROMPT_SPLIT_RE).map(item => item.trim())\n if (!provinceName || !cityName || !countyName || !detailInfo) {\n return null\n }\n return {\n userName,\n postalCode: '',\n provinceName,\n cityName,\n countyName,\n detailInfo,\n nationalCode: '',\n telNumber,\n }\n}\n\nexport function parseChooseLocationPromptInput(input: unknown) {\n const [latText = '', lonText = ''] = String(input).split(',').map(item => item.trim())\n const latitude = Number(latText)\n const longitude = Number(lonText)\n if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) {\n return null\n }\n return {\n latitude,\n longitude,\n }\n}\n"],"mappings":";;;AAMA,MAAM,0BAA0B;AAEhC,SAAgB,mBAAmB,OAAgB,WAAW,GAAG;AAC/D,KAAI,OAAO,UAAU,YAAY,OAAO,MAAM,MAAM,CAClD,QAAO;AAET,QAAO;;AAmBT,SAAgB,oBAAoB,SAAsC;CAsBxE,MAAM,eArBoB,OAAO,cAAc,cAAc,YAAY,SAqBnC;AACtC,KAAI,CAAC,eAAe,OAAO,YAAY,uBAAuB,WAC5D,OAAM,IAAI,MAAM,6BAA6B;CAE/C,MAAM,UAAU,OAAO,SAAS,2BAA2B,YAAY,QAAQ,yBAAyB,IAC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AAC,OAAO,SAAS,SAAS,IAAI,CAAC,OAAO,SAAS,UAAU,CAC3D,QAAO;AAET,QAAO;EACL;EACA;EACD"}
@@ -0,0 +1,120 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "./async.mjs";
2
+ import { normalizeFuzzyCoordinate, normalizeGeoNumber, parseChooseAddressPromptInput, parseChooseLocationPromptInput, readCurrentLocation, readPresetChooseAddress, readPresetChooseLocation, readPresetFuzzyLocation } from "./location.mjs";
3
+ import { openTargetInNewWindow } from "./mediaActions.mjs";
4
+ import { getGlobalDialogHandlers } from "./ui.mjs";
5
+
6
+ //#region src/runtime/polyfill/locationApi.ts
7
+ function makePhoneCallBridge(options) {
8
+ const phoneNumber = typeof options?.phoneNumber === "string" ? options.phoneNumber.trim() : "";
9
+ if (!phoneNumber) {
10
+ const failure = callWxAsyncFailure(options, "makePhoneCall:fail invalid phoneNumber");
11
+ return Promise.reject(failure);
12
+ }
13
+ if (typeof window !== "undefined" && typeof window.open === "function") try {
14
+ window.open(`tel:${encodeURIComponent(phoneNumber)}`, "_self");
15
+ } catch {}
16
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "makePhoneCall:ok" }));
17
+ }
18
+ function chooseAddressBridge(options) {
19
+ const preset = readPresetChooseAddress();
20
+ if (preset) return Promise.resolve(callWxAsyncSuccess(options, {
21
+ errMsg: "chooseAddress:ok",
22
+ ...preset
23
+ }));
24
+ const { prompt } = getGlobalDialogHandlers();
25
+ if (typeof prompt === "function") {
26
+ const input = prompt("请输入地址(格式:省,市,区,详细地址,姓名,电话)", "");
27
+ if (input == null) {
28
+ const failure = callWxAsyncFailure(options, "chooseAddress:fail cancel");
29
+ return Promise.reject(failure);
30
+ }
31
+ const parsed = parseChooseAddressPromptInput(input);
32
+ if (!parsed) {
33
+ const failure = callWxAsyncFailure(options, "chooseAddress:fail invalid input");
34
+ return Promise.reject(failure);
35
+ }
36
+ return Promise.resolve(callWxAsyncSuccess(options, {
37
+ errMsg: "chooseAddress:ok",
38
+ ...parsed
39
+ }));
40
+ }
41
+ const failure = callWxAsyncFailure(options, "chooseAddress:fail address picker is unavailable");
42
+ return Promise.reject(failure);
43
+ }
44
+ function chooseLocationBridge(options) {
45
+ const preset = readPresetChooseLocation();
46
+ if (preset) return Promise.resolve(callWxAsyncSuccess(options, {
47
+ errMsg: "chooseLocation:ok",
48
+ ...preset
49
+ }));
50
+ const { prompt } = getGlobalDialogHandlers();
51
+ if (typeof prompt === "function") {
52
+ const input = prompt("请输入坐标(格式:latitude,longitude)", "");
53
+ if (input == null) {
54
+ const failure = callWxAsyncFailure(options, "chooseLocation:fail cancel");
55
+ return Promise.reject(failure);
56
+ }
57
+ const parsed = parseChooseLocationPromptInput(input);
58
+ if (!parsed) {
59
+ const failure = callWxAsyncFailure(options, "chooseLocation:fail invalid latitude/longitude");
60
+ return Promise.reject(failure);
61
+ }
62
+ return Promise.resolve(callWxAsyncSuccess(options, {
63
+ errMsg: "chooseLocation:ok",
64
+ name: "",
65
+ address: "",
66
+ latitude: parsed.latitude,
67
+ longitude: parsed.longitude
68
+ }));
69
+ }
70
+ const failure = callWxAsyncFailure(options, "chooseLocation:fail location picker is unavailable");
71
+ return Promise.reject(failure);
72
+ }
73
+ function openLocationBridge(options) {
74
+ const latitude = options?.latitude;
75
+ const longitude = options?.longitude;
76
+ if (typeof latitude !== "number" || Number.isNaN(latitude) || typeof longitude !== "number" || Number.isNaN(longitude)) {
77
+ const failure = callWxAsyncFailure(options, "openLocation:fail invalid latitude/longitude");
78
+ return Promise.reject(failure);
79
+ }
80
+ const query = `${latitude},${longitude}`;
81
+ openTargetInNewWindow(`https://maps.google.com/?q=${encodeURIComponent(query)}`);
82
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "openLocation:ok" }));
83
+ }
84
+ function getLocationBridge(options) {
85
+ try {
86
+ return readCurrentLocation(options).then((location) => callWxAsyncSuccess(options, {
87
+ errMsg: "getLocation:ok",
88
+ ...location
89
+ })).catch((error) => {
90
+ const failure = callWxAsyncFailure(options, `getLocation:fail ${error instanceof Error ? error.message : String(error)}`);
91
+ return Promise.reject(failure);
92
+ });
93
+ } catch (error) {
94
+ const failure = callWxAsyncFailure(options, `getLocation:fail ${error instanceof Error ? error.message : String(error)}`);
95
+ return Promise.reject(failure);
96
+ }
97
+ }
98
+ async function getFuzzyLocationBridge(options) {
99
+ const preset = readPresetFuzzyLocation();
100
+ if (preset) return callWxAsyncSuccess(options, {
101
+ errMsg: "getFuzzyLocation:ok",
102
+ ...preset
103
+ });
104
+ try {
105
+ const location = await getLocationBridge();
106
+ return callWxAsyncSuccess(options, {
107
+ errMsg: "getFuzzyLocation:ok",
108
+ latitude: normalizeFuzzyCoordinate(location.latitude),
109
+ longitude: normalizeFuzzyCoordinate(location.longitude),
110
+ accuracy: Math.max(1e3, normalizeGeoNumber(location.accuracy, 1e3))
111
+ });
112
+ } catch (error) {
113
+ const failure = callWxAsyncFailure(options, `getFuzzyLocation:fail ${typeof error?.errMsg === "string" ? error.errMsg : error instanceof Error ? error.message : String(error)}`);
114
+ return Promise.reject(failure);
115
+ }
116
+ }
117
+
118
+ //#endregion
119
+ export { chooseAddressBridge, chooseLocationBridge, getFuzzyLocationBridge, getLocationBridge, makePhoneCallBridge, openLocationBridge };
120
+ //# sourceMappingURL=locationApi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locationApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/locationApi.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from './async'\nimport {\n normalizeFuzzyCoordinate,\n normalizeGeoNumber,\n parseChooseAddressPromptInput,\n parseChooseLocationPromptInput,\n readCurrentLocation,\n readPresetChooseAddress,\n readPresetChooseLocation,\n readPresetFuzzyLocation,\n} from './location'\nimport { openTargetInNewWindow } from './mediaActions'\nimport { getGlobalDialogHandlers } from './ui'\n\nexport function makePhoneCallBridge(options?: any) {\n const phoneNumber = typeof options?.phoneNumber === 'string' ? options.phoneNumber.trim() : ''\n if (!phoneNumber) {\n const failure = callWxAsyncFailure(options, 'makePhoneCall:fail invalid phoneNumber')\n return Promise.reject(failure)\n }\n if (typeof window !== 'undefined' && typeof window.open === 'function') {\n try {\n window.open(`tel:${encodeURIComponent(phoneNumber)}`, '_self')\n }\n catch {\n // ignore browser restrictions and keep API-level success semantics\n }\n }\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'makePhoneCall:ok' }))\n}\n\nexport function chooseAddressBridge(options?: any) {\n const preset = readPresetChooseAddress()\n if (preset) {\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'chooseAddress:ok',\n ...preset,\n }))\n }\n const { prompt } = getGlobalDialogHandlers()\n if (typeof prompt === 'function') {\n const input = prompt('请输入地址(格式:省,市,区,详细地址,姓名,电话)', '')\n if (input == null) {\n const failure = callWxAsyncFailure(options, 'chooseAddress:fail cancel')\n return Promise.reject(failure)\n }\n const parsed = parseChooseAddressPromptInput(input)\n if (!parsed) {\n const failure = callWxAsyncFailure(options, 'chooseAddress:fail invalid input')\n return Promise.reject(failure)\n }\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'chooseAddress:ok',\n ...parsed,\n }))\n }\n const failure = callWxAsyncFailure(options, 'chooseAddress:fail address picker is unavailable')\n return Promise.reject(failure)\n}\n\nexport function chooseLocationBridge(options?: any) {\n const preset = readPresetChooseLocation()\n if (preset) {\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'chooseLocation:ok',\n ...preset,\n }))\n }\n const { prompt } = getGlobalDialogHandlers()\n if (typeof prompt === 'function') {\n const input = prompt('请输入坐标(格式:latitude,longitude)', '')\n if (input == null) {\n const failure = callWxAsyncFailure(options, 'chooseLocation:fail cancel')\n return Promise.reject(failure)\n }\n const parsed = parseChooseLocationPromptInput(input)\n if (!parsed) {\n const failure = callWxAsyncFailure(options, 'chooseLocation:fail invalid latitude/longitude')\n return Promise.reject(failure)\n }\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'chooseLocation:ok',\n name: '',\n address: '',\n latitude: parsed.latitude,\n longitude: parsed.longitude,\n }))\n }\n const failure = callWxAsyncFailure(options, 'chooseLocation:fail location picker is unavailable')\n return Promise.reject(failure)\n}\n\nexport function openLocationBridge(options?: any) {\n const latitude = options?.latitude\n const longitude = options?.longitude\n if (typeof latitude !== 'number' || Number.isNaN(latitude) || typeof longitude !== 'number' || Number.isNaN(longitude)) {\n const failure = callWxAsyncFailure(options, 'openLocation:fail invalid latitude/longitude')\n return Promise.reject(failure)\n }\n const query = `${latitude},${longitude}`\n const target = `https://maps.google.com/?q=${encodeURIComponent(query)}`\n openTargetInNewWindow(target)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'openLocation:ok' }))\n}\n\nexport function getLocationBridge(options?: any) {\n try {\n return readCurrentLocation(options)\n .then(location => callWxAsyncSuccess(options, {\n errMsg: 'getLocation:ok',\n ...location,\n }))\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `getLocation:fail ${message}`)\n return Promise.reject(failure)\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `getLocation:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function getFuzzyLocationBridge(options?: any) {\n const preset = readPresetFuzzyLocation()\n if (preset) {\n return callWxAsyncSuccess(options, {\n errMsg: 'getFuzzyLocation:ok',\n ...preset,\n })\n }\n try {\n const location = await getLocationBridge()\n return callWxAsyncSuccess(options, {\n errMsg: 'getFuzzyLocation:ok',\n latitude: normalizeFuzzyCoordinate(location.latitude),\n longitude: normalizeFuzzyCoordinate(location.longitude),\n accuracy: Math.max(1000, normalizeGeoNumber(location.accuracy, 1000)),\n })\n }\n catch (error) {\n const message = typeof (error as { errMsg?: unknown })?.errMsg === 'string'\n ? (error as { errMsg: string }).errMsg\n : error instanceof Error\n ? error.message\n : String(error)\n const failure = callWxAsyncFailure(options, `getFuzzyLocation:fail ${message}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;IAC9B;UAEC,OAAO;EAEZ,MAAM,UAAU,mBAAmB,SAAS,oBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACI;AAC1E,SAAO,QAAQ,OAAO,QAAQ;;;AAIlC,eAAsB,uBAAuB,SAAe;CAC1D,MAAM,SAAS,yBAAyB;AACxC,KAAI,OACF,QAAO,mBAAmB,SAAS;EACjC,QAAQ;EACR,GAAG;EACJ,CAAC;AAEJ,KAAI;EACF,MAAM,WAAW,MAAM,mBAAmB;AAC1C,SAAO,mBAAmB,SAAS;GACjC,QAAQ;GACR,UAAU,yBAAyB,SAAS,SAAS;GACrD,WAAW,yBAAyB,SAAS,UAAU;GACvD,UAAU,KAAK,IAAI,KAAM,mBAAmB,SAAS,UAAU,IAAK,CAAC;GACtE,CAAC;UAEG,OAAO;EAMZ,MAAM,UAAU,mBAAmB,SAAS,yBAL5B,OAAQ,OAAgC,WAAW,WAC9D,MAA6B,SAC9B,iBAAiB,QACf,MAAM,UACN,OAAO,MAAM,GAC4D;AAC/E,SAAO,QAAQ,OAAO,QAAQ"}
@@ -0,0 +1,52 @@
1
+ import { WEAPP_VITE_WEB_OPEN_VIDEO_EDITOR_KEY } from "@weapp-core/constants";
2
+
3
+ //#region src/runtime/polyfill/mediaActions.ts
4
+ function openTargetInNewWindow(target) {
5
+ if (typeof window === "undefined" || typeof window.open !== "function") return;
6
+ try {
7
+ window.open(target, "_blank", "noopener,noreferrer");
8
+ } catch {}
9
+ }
10
+ function normalizePreviewMediaSources(sources) {
11
+ if (!Array.isArray(sources)) return [];
12
+ return sources.map((source) => {
13
+ if (!source || typeof source !== "object") return null;
14
+ const sourceRecord = source;
15
+ const url = typeof sourceRecord.url === "string" ? sourceRecord.url.trim() : "";
16
+ if (!url) return null;
17
+ return {
18
+ url,
19
+ type: sourceRecord.type === "video" ? "video" : "image",
20
+ poster: typeof sourceRecord.poster === "string" ? sourceRecord.poster : ""
21
+ };
22
+ }).filter((item) => Boolean(item));
23
+ }
24
+ function readOpenVideoEditorPreset(src) {
25
+ const preset = globalThis[WEAPP_VITE_WEB_OPEN_VIDEO_EDITOR_KEY];
26
+ if (typeof preset === "function") {
27
+ const value = preset(src);
28
+ return typeof value === "string" && value.trim() ? value.trim() : "";
29
+ }
30
+ if (typeof preset === "string" && preset.trim()) return preset.trim();
31
+ if (preset && typeof preset === "object") {
32
+ const value = preset[src];
33
+ return typeof value === "string" && value.trim() ? value.trim() : "";
34
+ }
35
+ return "";
36
+ }
37
+ function triggerDownload(filePath, fileName = "") {
38
+ if (typeof document === "undefined" || !document.body) return;
39
+ try {
40
+ const link = document.createElement("a");
41
+ link.setAttribute("href", filePath);
42
+ link.setAttribute("download", fileName);
43
+ link.setAttribute("style", "display:none");
44
+ document.body.append(link);
45
+ link.click?.();
46
+ if (link.parentNode) link.parentNode.removeChild(link);
47
+ } catch {}
48
+ }
49
+
50
+ //#endregion
51
+ export { normalizePreviewMediaSources, openTargetInNewWindow, readOpenVideoEditorPreset, triggerDownload };
52
+ //# sourceMappingURL=mediaActions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaActions.mjs","names":[],"sources":["../../../src/runtime/polyfill/mediaActions.ts"],"sourcesContent":["import { WEAPP_VITE_WEB_OPEN_VIDEO_EDITOR_KEY } from '@weapp-core/constants'\n\ninterface PreviewMediaSourceRecord {\n url: string\n type: 'image' | 'video'\n poster: string\n}\n\nexport function openTargetInNewWindow(target: string) {\n if (typeof window === 'undefined' || typeof window.open !== 'function') {\n return\n }\n try {\n window.open(target, '_blank', 'noopener,noreferrer')\n }\n catch {\n // ignore browser popup restrictions and keep API-level success semantics\n }\n}\n\nexport function normalizePreviewMediaSources(sources: unknown): PreviewMediaSourceRecord[] {\n if (!Array.isArray(sources)) {\n return []\n }\n return sources\n .map((source) => {\n if (!source || typeof source !== 'object') {\n return null\n }\n const sourceRecord = source as Record<string, unknown>\n const url = typeof sourceRecord.url === 'string' ? sourceRecord.url.trim() : ''\n if (!url) {\n return null\n }\n return {\n url,\n type: sourceRecord.type === 'video' ? 'video' : 'image',\n poster: typeof sourceRecord.poster === 'string' ? sourceRecord.poster : '',\n }\n })\n .filter((item): item is PreviewMediaSourceRecord => Boolean(item))\n}\n\nexport function readOpenVideoEditorPreset(src: string) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_OPEN_VIDEO_EDITOR_KEY]\n if (typeof preset === 'function') {\n const value = (preset as (value: string) => unknown)(src)\n return typeof value === 'string' && value.trim() ? value.trim() : ''\n }\n if (typeof preset === 'string' && preset.trim()) {\n return preset.trim()\n }\n if (preset && typeof preset === 'object') {\n const value = (preset as Record<string, unknown>)[src]\n return typeof value === 'string' && value.trim() ? value.trim() : ''\n }\n return ''\n}\n\nexport function triggerDownload(filePath: string, fileName = '') {\n if (typeof document === 'undefined' || !document.body) {\n return\n }\n try {\n const link = document.createElement('a')\n link.setAttribute('href', filePath)\n link.setAttribute('download', fileName)\n link.setAttribute('style', 'display:none')\n document.body.append(link)\n link.click?.()\n if (link.parentNode) {\n link.parentNode.removeChild(link)\n }\n }\n catch {\n // keep API-level success semantics for browser restrictions\n }\n}\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,QAAgB;AACpD,KAAI,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,WAC1D;AAEF,KAAI;AACF,SAAO,KAAK,QAAQ,UAAU,sBAAsB;SAEhD;;AAKR,SAAgB,6BAA6B,SAA8C;AACzF,KAAI,CAAC,MAAM,QAAQ,QAAQ,CACzB,QAAO,EAAE;AAEX,QAAO,QACJ,KAAK,WAAW;AACf,MAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,QAAO;EAET,MAAM,eAAe;EACrB,MAAM,MAAM,OAAO,aAAa,QAAQ,WAAW,aAAa,IAAI,MAAM,GAAG;AAC7E,MAAI,CAAC,IACH,QAAO;AAET,SAAO;GACL;GACA,MAAM,aAAa,SAAS,UAAU,UAAU;GAChD,QAAQ,OAAO,aAAa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