@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,63 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "../async.mjs";
2
+ import { openTargetInNewWindow, triggerDownload } from "../mediaActions.mjs";
3
+ import { normalizeFilePath, resolveOpenDocumentUrl, resolveSaveFilePath, saveMemoryFile } from "../files.mjs";
4
+
5
+ //#region src/runtime/polyfill/mediaApi/file.ts
6
+ function saveImageToPhotosAlbumBridge(options) {
7
+ const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
8
+ if (!filePath) {
9
+ const failure = callWxAsyncFailure(options, "saveImageToPhotosAlbum:fail invalid filePath");
10
+ return Promise.reject(failure);
11
+ }
12
+ triggerDownload(filePath);
13
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "saveImageToPhotosAlbum:ok" }));
14
+ }
15
+ function saveVideoToPhotosAlbumBridge(options) {
16
+ const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
17
+ if (!filePath) {
18
+ const failure = callWxAsyncFailure(options, "saveVideoToPhotosAlbum:fail invalid filePath");
19
+ return Promise.reject(failure);
20
+ }
21
+ triggerDownload(filePath);
22
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "saveVideoToPhotosAlbum:ok" }));
23
+ }
24
+ function saveFileBridge(options) {
25
+ const tempFilePath = typeof options?.tempFilePath === "string" ? options.tempFilePath.trim() : "";
26
+ if (!tempFilePath) {
27
+ const failure = callWxAsyncFailure(options, "saveFile:fail invalid tempFilePath");
28
+ return Promise.reject(failure);
29
+ }
30
+ const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath);
31
+ saveMemoryFile(tempFilePath, savedFilePath);
32
+ return Promise.resolve(callWxAsyncSuccess(options, {
33
+ errMsg: "saveFile:ok",
34
+ savedFilePath
35
+ }));
36
+ }
37
+ function saveFileToDiskBridge(options) {
38
+ const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
39
+ if (!filePath) {
40
+ const failure = callWxAsyncFailure(options, "saveFileToDisk:fail invalid filePath");
41
+ return Promise.reject(failure);
42
+ }
43
+ triggerDownload(filePath, typeof options?.fileName === "string" ? options.fileName.trim() : "");
44
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "saveFileToDisk:ok" }));
45
+ }
46
+ function openDocumentBridge(options) {
47
+ const filePath = normalizeFilePath(options?.filePath);
48
+ if (!filePath) {
49
+ const failure = callWxAsyncFailure(options, "openDocument:fail invalid filePath");
50
+ return Promise.reject(failure);
51
+ }
52
+ const target = resolveOpenDocumentUrl(filePath);
53
+ if (!target) {
54
+ const failure = callWxAsyncFailure(options, "openDocument:fail document url is unavailable");
55
+ return Promise.reject(failure);
56
+ }
57
+ openTargetInNewWindow(target);
58
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "openDocument:ok" }));
59
+ }
60
+
61
+ //#endregion
62
+ export { openDocumentBridge, saveFileBridge, saveFileToDiskBridge, saveImageToPhotosAlbumBridge, saveVideoToPhotosAlbumBridge };
63
+ //# sourceMappingURL=file.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/file.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from '../async'\nimport {\n normalizeFilePath,\n resolveOpenDocumentUrl,\n resolveSaveFilePath,\n saveMemoryFile,\n} from '../files'\nimport {\n openTargetInNewWindow,\n triggerDownload,\n} from '../mediaActions'\n\nexport function saveImageToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callWxAsyncFailure(options, 'saveImageToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'saveImageToPhotosAlbum:ok' }))\n}\n\nexport function saveVideoToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callWxAsyncFailure(options, 'saveVideoToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'saveVideoToPhotosAlbum:ok' }))\n}\n\nexport function saveFileBridge(options?: any) {\n const tempFilePath = typeof options?.tempFilePath === 'string' ? options.tempFilePath.trim() : ''\n if (!tempFilePath) {\n const failure = callWxAsyncFailure(options, 'saveFile:fail invalid tempFilePath')\n return Promise.reject(failure)\n }\n const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath)\n saveMemoryFile(tempFilePath, savedFilePath)\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'saveFile:ok',\n savedFilePath,\n }))\n}\n\nexport function saveFileToDiskBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callWxAsyncFailure(options, 'saveFileToDisk:fail invalid filePath')\n return Promise.reject(failure)\n }\n const fileName = typeof options?.fileName === 'string' ? options.fileName.trim() : ''\n triggerDownload(filePath, fileName)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'saveFileToDisk:ok' }))\n}\n\nexport function openDocumentBridge(options?: any) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n const failure = callWxAsyncFailure(options, 'openDocument:fail invalid filePath')\n return Promise.reject(failure)\n }\n const target = resolveOpenDocumentUrl(filePath)\n if (!target) {\n const failure = callWxAsyncFailure(options, 'openDocument:fail document url is unavailable')\n return Promise.reject(failure)\n }\n openTarg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,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,MAAM,GAAG,GAChD;AACnC,QAAO,QAAQ,QAAQ,mBAAmB,SAAS,EAAE,QAAQ,qBAAqB,CAAC,CAAC;;AAGtF,SAAgB,mBAAmB,SAAe;CAChD,MAAM,WAAW,kBAAkB,SAAS,SAAS;AACrD,KAAI,CAAC,UAAU;EACb,MAAM,UAAU,mBAAmB,SAAS,qCAAqC;AACjF,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,SAAS,uBAAuB,SAAS;AAC/C,KAAI,CAAC,QAAQ;EACX,MAAM,UAAU,mBAAmB,SAAS,gDAAgD;AAC5F,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,uBAAsB,OAAO;AAC7B,QAAO,QAAQ,QAAQ,mBAAmB,SAAS,EAAE,QAAQ,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "../async.mjs";
2
+ import { inferImageTypeFromPath, inferVideoTypeFromPath, normalizeVideoInfoNumber, readImageInfoFromSource, readPresetVideoInfo, readVideoInfoFromSource } from "../mediaInfo.mjs";
3
+
4
+ //#region src/runtime/polyfill/mediaApi/info.ts
5
+ function getImageInfoBridge(options) {
6
+ const src = typeof options?.src === "string" ? options.src.trim() : "";
7
+ if (!src) {
8
+ const failure = callWxAsyncFailure(options, "getImageInfo:fail invalid src");
9
+ return Promise.reject(failure);
10
+ }
11
+ return readImageInfoFromSource(src).then(({ width, height }) => callWxAsyncSuccess(options, {
12
+ errMsg: "getImageInfo:ok",
13
+ width,
14
+ height,
15
+ path: src,
16
+ type: inferImageTypeFromPath(src),
17
+ orientation: "up"
18
+ })).catch((error) => {
19
+ const failure = callWxAsyncFailure(options, `getImageInfo:fail ${error instanceof Error ? error.message : String(error)}`);
20
+ return Promise.reject(failure);
21
+ });
22
+ }
23
+ function getVideoInfoBridge(options) {
24
+ const src = typeof options?.src === "string" ? options.src.trim() : "";
25
+ if (!src) {
26
+ const failure = callWxAsyncFailure(options, "getVideoInfo:fail invalid src");
27
+ return Promise.reject(failure);
28
+ }
29
+ const preset = readPresetVideoInfo(src);
30
+ const resolveResult = async () => {
31
+ if (preset) return preset;
32
+ return readVideoInfoFromSource(src);
33
+ };
34
+ return resolveResult().then((result) => {
35
+ const duration = normalizeVideoInfoNumber(result.duration);
36
+ const width = normalizeVideoInfoNumber(result.width);
37
+ const height = normalizeVideoInfoNumber(result.height);
38
+ const bitrate = normalizeVideoInfoNumber(result.bitrate);
39
+ const fps = normalizeVideoInfoNumber(result.fps);
40
+ return callWxAsyncSuccess(options, {
41
+ errMsg: "getVideoInfo:ok",
42
+ orientation: "up",
43
+ type: inferVideoTypeFromPath(src),
44
+ duration,
45
+ size: normalizeVideoInfoNumber(result.size),
46
+ width,
47
+ height,
48
+ bitrate,
49
+ fps
50
+ });
51
+ }).catch((error) => {
52
+ const failure = callWxAsyncFailure(options, `getVideoInfo:fail ${error instanceof Error ? error.message : String(error)}`);
53
+ return Promise.reject(failure);
54
+ });
55
+ }
56
+
57
+ //#endregion
58
+ export { getImageInfoBridge, getVideoInfoBridge };
59
+ //# sourceMappingURL=info.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/info.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from '../async'\nimport {\n inferImageTypeFromPath,\n inferVideoTypeFromPath,\n normalizeVideoInfoNumber,\n readImageInfoFromSource,\n readPresetVideoInfo,\n readVideoInfoFromSource,\n} from '../mediaInfo'\n\nexport function getImageInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callWxAsyncFailure(options, 'getImageInfo:fail invalid src')\n return Promise.reject(failure)\n }\n return readImageInfoFromSource(src)\n .then(({ width, height }) => callWxAsyncSuccess(options, {\n errMsg: 'getImageInfo:ok',\n width,\n height,\n path: src,\n type: inferImageTypeFromPath(src),\n orientation: 'up',\n }))\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `getImageInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n\nexport function getVideoInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callWxAsyncFailure(options, 'getVideoInfo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetVideoInfo(src)\n const resolveResult = async () => {\n if (preset) {\n return preset\n }\n return readVideoInfoFromSource(src)\n }\n return resolveResult()\n .then((result) => {\n const duration = normalizeVideoInfoNumber(result.duration)\n const width = normalizeVideoInfoNumber(result.width)\n const height = normalizeVideoInfoNumber(result.height)\n const bitrate = normalizeVideoInfoNumber((result as Record<string, unknown>).bitrate)\n const fps = normalizeVideoInfoNumber((result as Record<string, unknown>).fps)\n return callWxAsyncSuccess(options, {\n errMsg: 'getVideoInfo:ok',\n orientation: 'up',\n type: inferVideoTypeFromPath(src),\n duration,\n size: normalizeVideoInfoNumber((result as Record<string, unknown>).size),\n width,\n height,\n bitrate,\n fps,\n })\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `getVideoInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n"],"mappings":";;;;AAaA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,mBAAmB,SAAS,gCAAgC;AAC5E,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,QAAO,wBAAwB,IAAI,CAChC,MAAM,EAAE,OAAO,aAAa,mBAAmB,SAAS;EACvD,QAAQ;EACR;EACA;EACA,MAAM;EACN,MAAM,uBAAuB,IAAI;EACjC,aAAa;EACd,CAAC,CAAC,CACF,OAAO,UAAU;EAEhB,MAAM,UAAU,mBAAmB,SAAS,qBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACK;AAC3E,SAAO,QAAQ,OAAO,QAAQ;GAC9B;;AAGN,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,mBAAmB,SAAS,gCAAgC;AAC5E,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,SAAS,oBAAoB,IAAI;CACvC,MAAM,gBAAgB,YAAY;AAChC,MAAI,OACF,QAAO;AAET,SAAO,wBAAwB,IAAI;;AAErC,QAAO,eAAe,CACnB,MAAM,WAAW;EAChB,MAAM,WAAW,yBAAyB,OAAO,SAAS;EAC1D,MAAM,QAAQ,yBAAyB,OAAO,MAAM;EACpD,MAAM,SAAS,yBAAyB,OAAO,OAAO;EACtD,MAAM,UAAU,yBAA0B,OAAmC,QAAQ;EACrF,MAAM,MAAM,yBAA0B,OAAmC,IAAI;AAC7E,SAAO,mBAAmB,SAAS;GACjC,QAAQ;GACR,aAAa;GACb,MAAM,uBAAuB,IAAI;GACjC;GACA,MAAM,yBAA0B,OAAmC,KAAK;GACxE;GACA;GACA;GACA;GACD,CAAC;GACF,CACD,OAAO,UAAU;EAEhB,MAAM,UAAU,mBAAmB,SAAS,qBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACK;AAC3E,SAAO,QAAQ,OAAO,QAAQ;GAC9B"}
@@ -0,0 +1,82 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "../async.mjs";
2
+ import { normalizeChooseImageCount, normalizeChooseImageFile, normalizeChooseMediaCount, normalizeChooseMediaFile, normalizeChooseMediaTypes, pickChooseImageFiles, pickChooseMediaFiles } from "../mediaPicker.mjs";
3
+ import { normalizeChooseFileExtensions, normalizeChooseMessageFile, normalizeChooseMessageFileCount, normalizeChooseMessageFileType, pickChooseFileFiles, pickChooseMessageFiles } from "../filePicker.mjs";
4
+ import { normalizeChooseVideoFile, pickChooseVideoFile } from "../mediaProcess.mjs";
5
+
6
+ //#region src/runtime/polyfill/mediaApi/picker.ts
7
+ async function chooseImageBridge(options) {
8
+ const count = normalizeChooseImageCount(options?.count);
9
+ try {
10
+ const tempFiles = (await pickChooseImageFiles(count)).map((file) => normalizeChooseImageFile(file));
11
+ return callWxAsyncSuccess(options, {
12
+ errMsg: "chooseImage:ok",
13
+ tempFilePaths: tempFiles.map((item) => item.path),
14
+ tempFiles
15
+ });
16
+ } catch (error) {
17
+ const failure = callWxAsyncFailure(options, `chooseImage:fail ${error instanceof Error ? error.message : String(error)}`);
18
+ return Promise.reject(failure);
19
+ }
20
+ }
21
+ async function chooseMediaBridge(options) {
22
+ const count = normalizeChooseMediaCount(options?.count);
23
+ const types = normalizeChooseMediaTypes(options?.mediaType);
24
+ try {
25
+ const tempFiles = (await pickChooseMediaFiles(count, types)).map((file) => normalizeChooseMediaFile(file));
26
+ const defaultType = types.has("video") && !types.has("image") ? "video" : "image";
27
+ return callWxAsyncSuccess(options, {
28
+ errMsg: "chooseMedia:ok",
29
+ type: tempFiles[0]?.fileType ?? defaultType,
30
+ tempFiles
31
+ });
32
+ } catch (error) {
33
+ const failure = callWxAsyncFailure(options, `chooseMedia:fail ${error instanceof Error ? error.message : String(error)}`);
34
+ return Promise.reject(failure);
35
+ }
36
+ }
37
+ async function chooseVideoBridge(options) {
38
+ try {
39
+ const file = await pickChooseVideoFile();
40
+ if (!file) throw new TypeError("no file selected");
41
+ const normalized = normalizeChooseVideoFile(file);
42
+ if (!normalized) throw new TypeError("selected file is not a video");
43
+ return callWxAsyncSuccess(options, {
44
+ errMsg: "chooseVideo:ok",
45
+ ...normalized
46
+ });
47
+ } catch (error) {
48
+ const failure = callWxAsyncFailure(options, `chooseVideo:fail ${error instanceof Error ? error.message : String(error)}`);
49
+ return Promise.reject(failure);
50
+ }
51
+ }
52
+ async function chooseMessageFileBridge(options) {
53
+ const count = normalizeChooseMessageFileCount(options?.count);
54
+ const type = normalizeChooseMessageFileType(options?.type);
55
+ try {
56
+ return callWxAsyncSuccess(options, {
57
+ errMsg: "chooseMessageFile:ok",
58
+ tempFiles: (await pickChooseMessageFiles(count, type)).map((file) => normalizeChooseMessageFile(file))
59
+ });
60
+ } catch (error) {
61
+ const failure = callWxAsyncFailure(options, `chooseMessageFile:fail ${error instanceof Error ? error.message : String(error)}`);
62
+ return Promise.reject(failure);
63
+ }
64
+ }
65
+ async function chooseFileBridge(options) {
66
+ const count = normalizeChooseMessageFileCount(options?.count);
67
+ const type = normalizeChooseMessageFileType(options?.type);
68
+ const extensions = normalizeChooseFileExtensions(options?.extension);
69
+ try {
70
+ return callWxAsyncSuccess(options, {
71
+ errMsg: "chooseFile:ok",
72
+ tempFiles: (await pickChooseFileFiles(count, type, extensions)).map((file) => normalizeChooseMessageFile(file))
73
+ });
74
+ } catch (error) {
75
+ const failure = callWxAsyncFailure(options, `chooseFile:fail ${error instanceof Error ? error.message : String(error)}`);
76
+ return Promise.reject(failure);
77
+ }
78
+ }
79
+
80
+ //#endregion
81
+ export { chooseFileBridge, chooseImageBridge, chooseMediaBridge, chooseMessageFileBridge, chooseVideoBridge };
82
+ //# sourceMappingURL=picker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"picker.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/picker.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from '../async'\nimport {\n normalizeChooseFileExtensions,\n normalizeChooseMessageFile,\n normalizeChooseMessageFileCount,\n normalizeChooseMessageFileType,\n pickChooseFileFiles,\n pickChooseMessageFiles,\n} from '../filePicker'\nimport {\n normalizeChooseImageCount,\n normalizeChooseImageFile,\n normalizeChooseMediaCount,\n normalizeChooseMediaFile,\n normalizeChooseMediaTypes,\n pickChooseImageFiles,\n pickChooseMediaFiles,\n} from '../mediaPicker'\nimport {\n normalizeChooseVideoFile,\n pickChooseVideoFile,\n} from '../mediaProcess'\n\nexport async function chooseImageBridge(options?: any) {\n const count = normalizeChooseImageCount(options?.count)\n try {\n const files = await pickChooseImageFiles(count)\n const tempFiles = files.map(file => normalizeChooseImageFile(file))\n const tempFilePaths = tempFiles.map(item => item.path)\n return callWxAsyncSuccess(options, {\n errMsg: 'chooseImage:ok',\n tempFilePaths,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `chooseImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMediaBridge(options?: any) {\n const count = normalizeChooseMediaCount(options?.count)\n const types = normalizeChooseMediaTypes(options?.mediaType)\n try {\n const files = await pickChooseMediaFiles(count, types)\n const tempFiles = files.map(file => normalizeChooseMediaFile(file))\n const defaultType = types.has('video') && !types.has('image') ? 'video' : 'image'\n return callWxAsyncSuccess(options, {\n errMsg: 'chooseMedia:ok',\n type: tempFiles[0]?.fileType ?? defaultType,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `chooseMedia:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseVideoBridge(options?: any) {\n try {\n const file = await pickChooseVideoFile()\n if (!file) {\n throw new TypeError('no file selected')\n }\n const normalized = normalizeChooseVideoFile(file)\n if (!normalized) {\n throw new TypeError('selected file is not a video')\n }\n return callWxAsyncSuccess(options, {\n errMsg: 'chooseVideo:ok',\n ...normalized,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `chooseVideo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMessageFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n try {\n const files = await pickChooseMessageFiles(count, type)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callWxAsyncSuccess(options, {\n errMsg: 'chooseMessageFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `chooseMessageFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n const extensions = normalizeChooseFileExtensions(options?.extension)\n try {\n const files = await pickChooseFileFiles(count, type, extensions)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callWxAsyncSuccess(options, {\n errMsg: 'chooseFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `chooseFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;;AA0BA,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,MAAM;AACvD,KAAI;EAEF,MAAM,aADQ,MAAM,qBAAqB,MAAM,EACvB,KAAI,SAAQ,yBAAyB,KAAK,CAAC;AAEnE,SAAO,mBAAmB,SAAS;GACjC,QAAQ;GACR,eAHoB,UAAU,KAAI,SAAQ,KAAK,KAAK;GAIpD;GACD,CAAC;UAEG,OAAO;EAEZ,MAAM,UAAU,mBAAmB,SAAS,oBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACI;AAC1E,SAAO,QAAQ,OAAO,QAAQ;;;AAIlC,eAAsB,kBAAkB,SAAe;CACrD,MAAM,QAAQ,0BAA0B,SAAS,MAAM;CACvD,MAAM,QAAQ,0BAA0B,SAAS,UAAU;AAC3D,KAAI;EAEF,MAAM,aADQ,MAAM,qBAAqB,OAAO,MAAM,EAC9B,KAAI,SAAQ,yBAAyB,KAAK,CAAC;EACnE,MAAM,cAAc,MAAM,IAAI,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG,UAAU;AAC1E,SAAO,mBAAmB,SAAS;GACjC,QAAQ;GACR,MAAM,UAAU,IAAI,Y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pE,CAAC;UAEG,OAAO;EAEZ,MAAM,UAAU,mBAAmB,SAAS,mBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACG;AACzE,SAAO,QAAQ,OAAO,QAAQ"}
@@ -0,0 +1,39 @@
1
+ import { callWxAsyncFailure, callWxAsyncSuccess } from "../async.mjs";
2
+ import { normalizePreviewMediaSources, openTargetInNewWindow, readOpenVideoEditorPreset } from "../mediaActions.mjs";
3
+
4
+ //#region src/runtime/polyfill/mediaApi/preview.ts
5
+ function previewImageBridge(options) {
6
+ const urls = Array.isArray(options?.urls) ? options.urls.map((url) => String(url).trim()).filter(Boolean) : [];
7
+ if (!urls.length) {
8
+ const failure = callWxAsyncFailure(options, "previewImage:fail invalid urls");
9
+ return Promise.reject(failure);
10
+ }
11
+ const current = typeof options?.current === "string" && options.current.trim() ? options.current.trim() : urls[0];
12
+ openTargetInNewWindow(urls.includes(current) ? current : urls[0]);
13
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "previewImage:ok" }));
14
+ }
15
+ function previewMediaBridge(options) {
16
+ const sources = normalizePreviewMediaSources(options?.sources);
17
+ if (!sources.length) {
18
+ const failure = callWxAsyncFailure(options, "previewMedia:fail invalid sources");
19
+ return Promise.reject(failure);
20
+ }
21
+ openTargetInNewWindow(sources[typeof options?.current === "number" && Number.isFinite(options.current) ? Math.max(0, Math.floor(options.current)) : 0]?.url ?? sources[0].url);
22
+ return Promise.resolve(callWxAsyncSuccess(options, { errMsg: "previewMedia:ok" }));
23
+ }
24
+ function openVideoEditorBridge(options) {
25
+ const src = typeof options?.src === "string" ? options.src.trim() : "";
26
+ if (!src) {
27
+ const failure = callWxAsyncFailure(options, "openVideoEditor:fail invalid src");
28
+ return Promise.reject(failure);
29
+ }
30
+ const tempFilePath = readOpenVideoEditorPreset(src) || src;
31
+ return Promise.resolve(callWxAsyncSuccess(options, {
32
+ errMsg: "openVideoEditor:ok",
33
+ tempFilePath
34
+ }));
35
+ }
36
+
37
+ //#endregion
38
+ export { openVideoEditorBridge, previewImageBridge, previewMediaBridge };
39
+ //# sourceMappingURL=preview.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/preview.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from '../async'\nimport {\n normalizePreviewMediaSources,\n openTargetInNewWindow,\n readOpenVideoEditorPreset,\n} from '../mediaActions'\n\nexport function previewImageBridge(options?: any) {\n const urls = Array.isArray(options?.urls)\n ? options.urls.map((url: unknown) => String(url).trim()).filter(Boolean)\n : []\n if (!urls.length) {\n const failure = callWxAsyncFailure(options, 'previewImage:fail invalid urls')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'string' && options.current.trim()\n ? options.current.trim()\n : urls[0]\n const target = urls.includes(current) ? current : urls[0]\n openTargetInNewWindow(target)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'previewImage:ok' }))\n}\n\nexport function previewMediaBridge(options?: any) {\n const sources = normalizePreviewMediaSources(options?.sources)\n if (!sources.length) {\n const failure = callWxAsyncFailure(options, 'previewMedia:fail invalid sources')\n return Promise.reject(failure)\n }\n const current = typeof options?.current === 'number' && Number.isFinite(options.current)\n ? Math.max(0, Math.floor(options.current))\n : 0\n const target = sources[current]?.url ?? sources[0].url\n openTargetInNewWindow(target)\n return Promise.resolve(callWxAsyncSuccess(options, { errMsg: 'previewMedia:ok' }))\n}\n\nexport function openVideoEditorBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callWxAsyncFailure(options, 'openVideoEditor:fail invalid src')\n return Promise.reject(failure)\n }\n const tempFilePath = readOpenVideoEditorPreset(src) || src\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'openVideoEditor:ok',\n tempFilePath,\n }))\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,OAAO,MAAM,QAAQ,S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} from "../async.mjs";
2
+ import { readPresetCompressVideo } from "../mediaInfo.mjs";
3
+ import { compressImageByCanvas, normalizeCompressImageQuality } from "../mediaProcess.mjs";
4
+
5
+ //#region src/runtime/polyfill/mediaApi/process.ts
6
+ async function compressImageBridge(options) {
7
+ const src = typeof options?.src === "string" ? options.src.trim() : "";
8
+ if (!src) {
9
+ const failure = callWxAsyncFailure(options, "compressImage:fail invalid src");
10
+ return Promise.reject(failure);
11
+ }
12
+ const quality = normalizeCompressImageQuality(options?.quality);
13
+ try {
14
+ return callWxAsyncSuccess(options, {
15
+ errMsg: "compressImage:ok",
16
+ tempFilePath: await compressImageByCanvas(src, quality)
17
+ });
18
+ } catch (error) {
19
+ const failure = callWxAsyncFailure(options, `compressImage:fail ${error instanceof Error ? error.message : String(error)}`);
20
+ return Promise.reject(failure);
21
+ }
22
+ }
23
+ function compressVideoBridge(options) {
24
+ const src = typeof options?.src === "string" ? options.src.trim() : "";
25
+ if (!src) {
26
+ const failure = callWxAsyncFailure(options, "compressVideo:fail invalid src");
27
+ return Promise.reject(failure);
28
+ }
29
+ const result = readPresetCompressVideo(src) ?? {
30
+ tempFilePath: src,
31
+ size: 0,
32
+ duration: 0,
33
+ width: 0,
34
+ height: 0,
35
+ bitrate: 0,
36
+ fps: 0
37
+ };
38
+ return Promise.resolve(callWxAsyncSuccess(options, {
39
+ errMsg: "compressVideo:ok",
40
+ ...result
41
+ }));
42
+ }
43
+
44
+ //#endregion
45
+ export { compressImageBridge, compressVideoBridge };
46
+ //# sourceMappingURL=process.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/process.ts"],"sourcesContent":["import {\n callWxAsyncFailure,\n callWxAsyncSuccess,\n} from '../async'\nimport { readPresetCompressVideo } from '../mediaInfo'\nimport {\n compressImageByCanvas,\n normalizeCompressImageQuality,\n} from '../mediaProcess'\n\nexport async function compressImageBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callWxAsyncFailure(options, 'compressImage:fail invalid src')\n return Promise.reject(failure)\n }\n const quality = normalizeCompressImageQuality(options?.quality)\n try {\n const tempFilePath = await compressImageByCanvas(src, quality)\n return callWxAsyncSuccess(options, {\n errMsg: 'compressImage:ok',\n tempFilePath,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callWxAsyncFailure(options, `compressImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport function compressVideoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callWxAsyncFailure(options, 'compressVideo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetCompressVideo(src)\n const result = preset ?? {\n tempFilePath: src,\n size: 0,\n duration: 0,\n width: 0,\n height: 0,\n bitrate: 0,\n fps: 0,\n }\n return Promise.resolve(callWxAsyncSuccess(options, {\n errMsg: 'compressVideo:ok',\n ...result,\n }))\n}\n"],"mappings":";;;;;AAUA,eAAsB,oBAAoB,SAAe;CACvD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,mBAAmB,SAAS,iCAAiC;AAC7E,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,UAAU,8BAA8B,SAAS,QAAQ;AAC/D,KAAI;AAEF,SAAO,mBAAmB,SAAS;GACjC,QAAQ;GACR,cAHmB,MAAM,sBAAsB,KAAK,QAAQ;GAI7D,CAAC;UAEG,OAAO;EAEZ,MAAM,UAAU,mBAAmB,SAAS,sBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACM;AAC5E,SAAO,QAAQ,OAAO,QAAQ;;;AAIlC,SAAgB,oBAAoB,SAAe;CACjD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,mBAAmB,SAAS,iCAAiC;AAC7E,SAAO,QAAQ,OAAO,QAAQ;;CAGhC,MAAM,SADS,wBAAwB,IAAI,IAClB;EACvB,cAAc;EACd,MAAM;EACN,UAAU;EACV,OAAO;EACP,QAAQ;EACR,SAAS;EACT,KAAK;EACN;AACD,QAAO,QAAQ,QAAQ,mBAAmB,SAAS;EACjD,QAAQ;EACR,GAAG;EACJ,CAAC,CAAC"}
@@ -0,0 +1,136 @@
1
+ import { WEAPP_VITE_WEB_COMPRESS_VIDEO_KEY, WEAPP_VITE_WEB_VIDEO_INFO_KEY } from "@weapp-core/constants";
2
+
3
+ //#region src/runtime/polyfill/mediaInfo.ts
4
+ function inferImageTypeFromPath(path) {
5
+ const lower = path.toLowerCase();
6
+ if (lower.includes(".png")) return "png";
7
+ if (lower.includes(".jpg") || lower.includes(".jpeg")) return "jpg";
8
+ if (lower.includes(".gif")) return "gif";
9
+ if (lower.includes(".webp")) return "webp";
10
+ if (lower.includes(".bmp")) return "bmp";
11
+ if (lower.includes(".svg")) return "svg";
12
+ if (lower.includes(".avif")) return "avif";
13
+ return "unknown";
14
+ }
15
+ function inferVideoTypeFromPath(path) {
16
+ const lower = path.toLowerCase();
17
+ if (lower.includes(".mp4")) return "mp4";
18
+ if (lower.includes(".mov")) return "mov";
19
+ if (lower.includes(".m4v")) return "m4v";
20
+ if (lower.includes(".webm")) return "webm";
21
+ if (lower.includes(".avi")) return "avi";
22
+ if (lower.includes(".mkv")) return "mkv";
23
+ return "unknown";
24
+ }
25
+ function normalizeVideoInfoNumber(value) {
26
+ if (typeof value !== "number" || Number.isNaN(value) || value < 0) return 0;
27
+ return value;
28
+ }
29
+ function normalizeVideoInfoPreset(value, src) {
30
+ if (!value || typeof value !== "object") return null;
31
+ const info = value;
32
+ return {
33
+ size: normalizeVideoInfoNumber(info.size),
34
+ duration: normalizeVideoInfoNumber(info.duration),
35
+ width: normalizeVideoInfoNumber(info.width),
36
+ height: normalizeVideoInfoNumber(info.height),
37
+ fps: normalizeVideoInfoNumber(info.fps),
38
+ bitrate: normalizeVideoInfoNumber(info.bitrate),
39
+ type: typeof info.type === "string" ? info.type : inferVideoTypeFromPath(src),
40
+ orientation: "up"
41
+ };
42
+ }
43
+ function readPresetVideoInfo(src) {
44
+ const preset = globalThis[WEAPP_VITE_WEB_VIDEO_INFO_KEY];
45
+ if (typeof preset === "function") return normalizeVideoInfoPreset(preset(src), src);
46
+ if (preset && typeof preset === "object") {
47
+ const sourcePreset = preset[src];
48
+ if (sourcePreset && typeof sourcePreset === "object") return normalizeVideoInfoPreset(sourcePreset, src);
49
+ return normalizeVideoInfoPreset(preset, src);
50
+ }
51
+ return null;
52
+ }
53
+ function normalizeCompressVideoResult(value, src) {
54
+ if (!value || typeof value !== "object") return null;
55
+ const info = value;
56
+ return {
57
+ tempFilePath: typeof info.tempFilePath === "string" && info.tempFilePath.trim() ? info.tempFilePath.trim() : src,
58
+ size: normalizeVideoInfoNumber(info.size),
59
+ duration: normalizeVideoInfoNumber(info.duration),
60
+ width: normalizeVideoInfoNumber(info.width),
61
+ height: normalizeVideoInfoNumber(info.height),
62
+ bitrate: normalizeVideoInfoNumber(info.bitrate),
63
+ fps: normalizeVideoInfoNumber(info.fps)
64
+ };
65
+ }
66
+ function readPresetCompressVideo(src) {
67
+ const preset = globalThis[WEAPP_VITE_WEB_COMPRESS_VIDEO_KEY];
68
+ if (typeof preset === "function") return normalizeCompressVideoResult(preset(src), src);
69
+ if (preset && typeof preset === "object") {
70
+ const sourcePreset = preset[src];
71
+ if (sourcePreset && typeof sourcePreset === "object") return normalizeCompressVideoResult(sourcePreset, src);
72
+ return normalizeCompressVideoResult(preset, src);
73
+ }
74
+ if (typeof preset === "string" && preset.trim()) return {
75
+ tempFilePath: preset.trim(),
76
+ size: 0,
77
+ duration: 0,
78
+ width: 0,
79
+ height: 0,
80
+ bitrate: 0,
81
+ fps: 0
82
+ };
83
+ return null;
84
+ }
85
+ async function readImageInfoFromSource(src) {
86
+ const ImageCtor = globalThis.Image;
87
+ if (typeof ImageCtor !== "function") throw new TypeError("Image is unavailable");
88
+ return new Promise((resolve, reject) => {
89
+ const image = new ImageCtor();
90
+ image.onload = () => {
91
+ const width = Number(image.naturalWidth ?? image.width ?? 0);
92
+ const height = Number(image.naturalHeight ?? image.height ?? 0);
93
+ resolve({
94
+ width: Number.isFinite(width) ? width : 0,
95
+ height: Number.isFinite(height) ? height : 0
96
+ });
97
+ };
98
+ image.onerror = () => {
99
+ reject(/* @__PURE__ */ new Error("image load error"));
100
+ };
101
+ image.src = src;
102
+ });
103
+ }
104
+ async function readVideoInfoFromSource(src) {
105
+ if (typeof document === "undefined" || typeof document.createElement !== "function") throw new TypeError("video element is unavailable");
106
+ const video = document.createElement("video");
107
+ if (!video || typeof video.addEventListener !== "function") throw new Error("video element is unavailable");
108
+ return new Promise((resolve, reject) => {
109
+ const cleanup = () => {
110
+ if (typeof video.removeEventListener === "function") {
111
+ video.removeEventListener("loadedmetadata", onLoadedMetadata);
112
+ video.removeEventListener("error", onError);
113
+ }
114
+ };
115
+ const onLoadedMetadata = () => {
116
+ cleanup();
117
+ resolve({
118
+ duration: normalizeVideoInfoNumber(video.duration),
119
+ width: normalizeVideoInfoNumber(video.videoWidth),
120
+ height: normalizeVideoInfoNumber(video.videoHeight)
121
+ });
122
+ };
123
+ const onError = () => {
124
+ cleanup();
125
+ reject(/* @__PURE__ */ new Error("video load error"));
126
+ };
127
+ video.addEventListener("loadedmetadata", onLoadedMetadata, { once: true });
128
+ video.addEventListener("error", onError, { once: true });
129
+ video.src = src;
130
+ video.load?.();
131
+ });
132
+ }
133
+
134
+ //#endregion
135
+ export { inferImageTypeFromPath, inferVideoTypeFromPath, normalizeVideoInfoNumber, readImageInfoFromSource, readPresetCompressVideo, readPresetVideoInfo, readVideoInfoFromSource };
136
+ //# sourceMappingURL=mediaInfo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaInfo.mjs","names":[],"sources":["../../../src/runtime/polyfill/mediaInfo.ts"],"sourcesContent":["import {\n WEAPP_VITE_WEB_COMPRESS_VIDEO_KEY,\n WEAPP_VITE_WEB_VIDEO_INFO_KEY,\n} from '@weapp-core/constants'\n\nexport function inferImageTypeFromPath(path: string) {\n const lower = path.toLowerCase()\n if (lower.includes('.png')) {\n return 'png'\n }\n if (lower.includes('.jpg') || lower.includes('.jpeg')) {\n return 'jpg'\n }\n if (lower.includes('.gif')) {\n return 'gif'\n }\n if (lower.includes('.webp')) {\n return 'webp'\n }\n if (lower.includes('.bmp')) {\n return 'bmp'\n }\n if (lower.includes('.svg')) {\n return 'svg'\n }\n if (lower.includes('.avif')) {\n return 'avif'\n }\n return 'unknown'\n}\n\nexport function inferVideoTypeFromPath(path: string) {\n const lower = path.toLowerCase()\n if (lower.includes('.mp4')) {\n return 'mp4'\n }\n if (lower.includes('.mov')) {\n return 'mov'\n }\n if (lower.includes('.m4v')) {\n return 'm4v'\n }\n if (lower.includes('.webm')) {\n return 'webm'\n }\n if (lower.includes('.avi')) {\n return 'avi'\n }\n if (lower.includes('.mkv')) {\n return 'mkv'\n }\n return 'unknown'\n}\n\nexport function normalizeVideoInfoNumber(value: unknown) {\n if (typeof value !== 'number' || Number.isNaN(value) || value < 0) {\n return 0\n }\n return value\n}\n\nfunction normalizeVideoInfoPreset(value: unknown, src: string) {\n if (!value || typeof value !== 'object') {\n return null\n }\n const info = value as Record<string, unknown>\n return {\n size: normalizeVideoInfoNumber(info.size),\n duration: normalizeVideoInfoNumber(info.duration),\n width: normalizeVideoInfoNumber(info.width),\n height: normalizeVideoInfoNumber(info.height),\n fps: normalizeVideoInfoNumber(info.fps),\n bitrate: normalizeVideoInfoNumber(info.bitrate),\n type: typeof info.type === 'string' ? info.type : inferVideoTypeFromPath(src),\n orientation: 'up' as const,\n }\n}\n\nexport function readPresetVideoInfo(src: string) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_VIDEO_INFO_KEY]\n if (typeof preset === 'function') {\n return normalizeVideoInfoPreset((preset as (value: string) => unknown)(src), src)\n }\n if (preset && typeof preset === 'object') {\n const sourcePreset = (preset as Record<string, unknown>)[src]\n if (sourcePreset && typeof sourcePreset === 'object') {\n return normalizeVideoInfoPreset(sourcePreset, src)\n }\n return normalizeVideoInfoPreset(preset, src)\n }\n return null\n}\n\nfunction normalizeCompressVideoResult(value: unknown, src: string) {\n if (!value || typeof value !== 'object') {\n return null\n }\n const info = value as Record<string, unknown>\n const tempFilePath = typeof info.tempFilePath === 'string' && info.tempFilePath.trim()\n ? info.tempFilePath.trim()\n : src\n return {\n tempFilePath,\n size: normalizeVideoInfoNumber(info.size),\n duration: normalizeVideoInfoNumber(info.duration),\n width: normalizeVideoInfoNumber(info.width),\n height: normalizeVideoInfoNumber(info.height),\n bitrate: normalizeVideoInfoNumber(info.bitrate),\n fps: normalizeVideoInfoNumber(info.fps),\n }\n}\n\nexport function readPresetCompressVideo(src: string) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_COMPRESS_VIDEO_KEY]\n if (typeof preset === 'function') {\n return normalizeCompressVideoResult((preset as (value: string) => unknown)(src), src)\n }\n if (preset && typeof preset === 'object') {\n const sourcePreset = (preset as Record<string, unknown>)[src]\n if (sourcePreset && typeof sourcePreset === 'object') {\n return normalizeCompressVideoResult(sourcePreset, src)\n }\n return normalizeCompressVideoResult(preset, src)\n }\n if (typeof preset === 'string' && preset.trim()) {\n return {\n tempFilePath: preset.trim(),\n size: 0,\n duration: 0,\n width: 0,\n height: 0,\n bitrate: 0,\n fps: 0,\n }\n }\n return null\n}\n\nexport async function readImageInfoFromSource(src: string) {\n const ImageCtor = (globalThis as { Image?: typeof Image }).Image\n if (typeof ImageCtor !== 'function') {\n throw new TypeError('Image is unavailable')\n }\n return new Promise<{ width: number, height: number }>((resolve, reject) => {\n const image = new ImageCtor()\n image.onload = () => {\n const width = Number((image as { naturalWidth?: number }).naturalWidth ?? image.width ?? 0)\n const height = Number((image as { naturalHeight?: number }).naturalHeight ?? image.height ?? 0)\n resolve({\n width: Number.isFinite(width) ? width : 0,\n height: Number.isFinite(height) ? height : 0,\n })\n }\n image.onerror = () => {\n reject(new Error('image load error'))\n }\n image.src = src\n })\n}\n\nexport async function readVideoInfoFromSource(src: string) {\n if (typeof document === 'undefined' || typeof document.createElement !== 'function') {\n throw new TypeError('video element is unavailable')\n }\n const video = document.createElement('video') as HTMLVideoElement\n if (!video || typeof video.addEventListener !== 'function') {\n throw new Error('video element is unavailable')\n }\n return new Promise<{ duration: number, width: number, height: number }>((resolve, reject) => {\n const cleanup = () => {\n if (typeof video.removeEventListener === 'function') {\n // eslint-disable-next-line ts/no-use-before-define\n video.removeEventListener('loadedmetadata', onLoadedMetadata)\n // eslint-disable-next-line ts/no-use-before-define\n video.removeEventListener('error', onError)\n }\n }\n const onLoadedMetadata = () => {\n cleanup()\n resolve({\n duration: normalizeVideoInfoNumber(video.duration),\n width: normalizeVideoInfoNumber((video as { videoWidth?: number }).videoWidth),\n height: normalizeVideoInfoNumber((video as { videoHeight?: number }).videoHeight),\n })\n }\n const onError = () => {\n cleanup()\n reject(new Error('video load error'))\n }\n video.addEventListener('loadedmetadata', onLoadedMetadata, { once: true })\n video.addEventListener('error', onError, { once: true })\n video.src = src\n video.load?.()\n })\n}\n"],"mappings":";;;AAKA,SAAgB,uBAAuB,MAAc;CACnD,MAAM,QAAQ,KAAK,aAAa;AAChC,KAAI,MAAM,SAAS,OAAO,CACxB,QAAO;AAET,KAAI,MAAM,SAAS,OAAO,IAAI,MAAM,SAAS,QAAQ,CACnD,QAAO;AAET,KAAI,MAAM,SAAS,OAAO,CACxB,QAAO;AAET,KAAI,MAAM,SAAS,QAAQ,CACzB,QAAO;AAET,KAAI,MAAM,SAAS,OAAO,CACxB,QAAO;AAET,KAAI,MAAM,SAAS,OAAO,CACxB,QAAO;AAET,KAAI,MAAM,SAAS,QAAQ,CACzB,QAAO;AAET,QAAO;;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