@weapp-vite/web 1.3.37 → 1.4.1
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.
- package/README.md +144 -5
- package/dist/_virtual/_rolldown/runtime.mjs +19 -1
- package/dist/compiler/wxml/attributes.mjs +1 -1
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +6 -3
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/compiler/wxml/interpolation.mjs +1 -2
- package/dist/compiler/wxml/interpolation.mjs.map +1 -1
- package/dist/compiler/wxml/navigation.mjs +5 -7
- package/dist/compiler/wxml/navigation.mjs.map +1 -1
- package/dist/compiler/wxml/parser.mjs +5 -5
- package/dist/compiler/wxml/parser.mjs.map +1 -1
- package/dist/compiler/wxml/renderer.mjs +16 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +8 -2
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
- package/dist/compiler/wxml/types.d.mts +12 -0
- package/dist/compiler/wxs.mjs +5 -5
- package/dist/compiler/wxs.mjs.map +1 -1
- package/dist/css/wxss.d.mts +1 -0
- package/dist/css/wxss.mjs +110 -9
- package/dist/css/wxss.mjs.map +1 -1
- package/dist/index.d.mts +24 -6
- package/dist/index.mjs +21 -4
- package/dist/plugin/assets.d.mts +7 -0
- package/dist/plugin/assets.mjs +122 -0
- package/dist/plugin/assets.mjs.map +1 -0
- package/dist/plugin/constants.mjs +10 -1
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/dependencyScan.mjs +41 -0
- package/dist/plugin/dependencyScan.mjs.map +1 -0
- package/dist/plugin/entry.mjs +55 -6
- package/dist/plugin/entry.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -1
- package/dist/plugin/files.mjs.map +1 -1
- package/dist/plugin/index.d.mts +37 -3
- package/dist/plugin/index.mjs +244 -73
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/layout.mjs +24 -0
- package/dist/plugin/layout.mjs.map +1 -0
- package/dist/plugin/path.mjs +6 -2
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +45 -33
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +211 -92
- package/dist/plugin/scan.mjs.map +1 -1
- package/dist/plugin/scanSfc.mjs +65 -0
- package/dist/plugin/scanSfc.mjs.map +1 -0
- package/dist/plugin/state.mjs +3 -2
- package/dist/plugin/state.mjs.map +1 -1
- package/dist/plugin/styleModule.mjs +52 -0
- package/dist/plugin/styleModule.mjs.map +1 -0
- package/dist/plugin/types.d.mts +37 -1
- package/dist/plugin/vueSfc.mjs +150 -0
- package/dist/plugin/vueSfc.mjs.map +1 -0
- package/dist/runtime/appShell/container.mjs +25 -0
- package/dist/runtime/appShell/container.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/index.mjs +192 -0
- package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/style.mjs +127 -0
- package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
- package/dist/runtime/button/helpers.mjs +1 -58
- package/dist/runtime/button/helpers.mjs.map +1 -1
- package/dist/runtime/button/index.d.mts +4 -5
- package/dist/runtime/button/index.mjs +6 -28
- package/dist/runtime/button/index.mjs.map +1 -1
- package/dist/runtime/button/style.mjs +53 -28
- package/dist/runtime/button/style.mjs.map +1 -1
- package/dist/runtime/component/behavior.mjs +26 -2
- package/dist/runtime/component/behavior.mjs.map +1 -1
- package/dist/runtime/component/element.mjs +107 -31
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/observers.mjs +36 -0
- package/dist/runtime/component/observers.mjs.map +1 -0
- package/dist/runtime/component/publicInstance.mjs +48 -0
- package/dist/runtime/component/publicInstance.mjs.map +1 -0
- package/dist/runtime/component/relations.mjs +36 -0
- package/dist/runtime/component/relations.mjs.map +1 -0
- package/dist/runtime/component/slots.mjs +24 -0
- package/dist/runtime/component/slots.mjs.map +1 -0
- package/dist/runtime/component/state.mjs +13 -3
- package/dist/runtime/component/state.mjs.map +1 -1
- package/dist/runtime/component/types.d.mts +29 -4
- package/dist/runtime/component/virtualHost.mjs +83 -0
- package/dist/runtime/component/virtualHost.mjs.map +1 -0
- package/dist/runtime/host/index.d.mts +13 -0
- package/dist/runtime/host/index.mjs +47 -0
- package/dist/runtime/host/index.mjs.map +1 -0
- package/dist/runtime/host/types.d.mts +28 -0
- package/dist/runtime/hostGlobals.d.mts +9 -0
- package/dist/runtime/hostGlobals.mjs +39 -0
- package/dist/runtime/hostGlobals.mjs.map +1 -0
- package/dist/runtime/index.d.mts +21 -3
- package/dist/runtime/index.mjs +26 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +3 -3
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/expression.mjs +9 -9
- package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/index.mjs +6 -6
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
- package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
- package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
- package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
- package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/form.d.mts +7 -0
- package/dist/runtime/nativeComponents/form.mjs +50 -0
- package/dist/runtime/nativeComponents/form.mjs.map +1 -0
- package/dist/runtime/nativeComponents/formControl.mjs +61 -0
- package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
- package/dist/runtime/nativeComponents/helpers.mjs +25 -0
- package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
- package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
- package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/image.d.mts +8 -0
- package/dist/runtime/nativeComponents/image.mjs +121 -0
- package/dist/runtime/nativeComponents/image.mjs.map +1 -0
- package/dist/runtime/nativeComponents/index.d.mts +11 -0
- package/dist/runtime/nativeComponents/index.mjs +83 -0
- package/dist/runtime/nativeComponents/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/input.d.mts +8 -0
- package/dist/runtime/nativeComponents/input.mjs +131 -0
- package/dist/runtime/nativeComponents/input.mjs.map +1 -0
- package/dist/runtime/nativeComponents/label.mjs +36 -0
- package/dist/runtime/nativeComponents/label.mjs.map +1 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
- package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/navigator.mjs +200 -0
- package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
- package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
- package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/primitives.mjs +16 -0
- package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
- package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
- package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/radio.mjs +147 -0
- package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
- package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
- package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
- package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/style.mjs +41 -0
- package/dist/runtime/nativeComponents/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/switch.d.mts +7 -0
- package/dist/runtime/nativeComponents/switch.mjs +132 -0
- package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
- package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
- package/dist/runtime/nativeComponents/textarea.mjs +144 -0
- package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/index.mjs +124 -0
- package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/style.mjs +14 -0
- package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
- package/dist/runtime/navigationBar/index.mjs +1 -3
- package/dist/runtime/navigationBar/index.mjs.map +1 -1
- package/dist/runtime/pageLayout.d.mts +9 -0
- package/dist/runtime/pageLayout.mjs +16 -0
- package/dist/runtime/pageLayout.mjs.map +1 -0
- package/dist/runtime/polyfill/animation.mjs +120 -0
- package/dist/runtime/polyfill/animation.mjs.map +1 -0
- package/dist/runtime/polyfill/appState.mjs +1 -1
- package/dist/runtime/polyfill/appState.mjs.map +1 -1
- package/dist/runtime/polyfill/async.d.mts +7 -0
- package/dist/runtime/polyfill/async.mjs.map +1 -1
- package/dist/runtime/polyfill/canvasContext.mjs +41 -0
- package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
- package/dist/runtime/polyfill/device.mjs +1 -1
- package/dist/runtime/polyfill/device.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceApi.mjs +6 -3
- package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/eventBus.mjs +56 -0
- package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
- package/dist/runtime/polyfill/files.mjs +10 -10
- package/dist/runtime/polyfill/files.mjs.map +1 -1
- package/dist/runtime/polyfill/font.mjs +33 -0
- package/dist/runtime/polyfill/font.mjs.map +1 -0
- package/dist/runtime/polyfill/index.d.mts +2 -2
- package/dist/runtime/polyfill/index.mjs +49 -45
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interaction.mjs +7 -6
- package/dist/runtime/polyfill/interaction.mjs.map +1 -1
- package/dist/runtime/polyfill/interactionApi.mjs +9 -5
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
- package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
- package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
- package/dist/runtime/polyfill/locale.mjs +14 -0
- package/dist/runtime/polyfill/locale.mjs.map +1 -0
- package/dist/runtime/polyfill/locationApi.mjs +11 -6
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaActions.mjs +2 -2
- package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/file.mjs +3 -2
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/picker.mjs +16 -8
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +39 -4
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/network/request.mjs +2 -2
- package/dist/runtime/polyfill/network/request.mjs.map +1 -1
- package/dist/runtime/polyfill/platformApi.mjs +3 -2
- package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
- package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
- package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
- package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
- package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
- package/dist/runtime/polyfill/storage.mjs +5 -2
- package/dist/runtime/polyfill/storage.mjs.map +1 -1
- package/dist/runtime/polyfill/storageAsync.mjs +4 -2
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +31 -4
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/systemApi.mjs +2 -1
- package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
- package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
- package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
- package/dist/runtime/polyfill/ui.mjs +2 -6
- package/dist/runtime/polyfill/ui.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
- package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/runtime/polyfill/videoContext.mjs +4 -0
- package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
- package/dist/runtime/polyfill/vkSession.mjs +4 -14
- package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
- package/dist/runtime/polyfill.d.mts +2 -2
- package/dist/runtime/renderContext.mjs +1 -1
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/rpx.mjs +17 -8
- package/dist/runtime/rpx.mjs.map +1 -1
- package/dist/runtime/seo/index.d.mts +31 -0
- package/dist/runtime/seo/index.mjs +94 -0
- package/dist/runtime/seo/index.mjs.map +1 -0
- package/dist/runtime/viewport/index.d.mts +12 -0
- package/dist/runtime/viewport/index.mjs +44 -0
- package/dist/runtime/viewport/index.mjs.map +1 -0
- package/dist/runtime/viewport/style.mjs +62 -0
- package/dist/runtime/viewport/style.mjs.map +1 -0
- package/dist/runtime/viewport/types.d.mts +14 -0
- package/dist/runtime/wevu.d.mts +20 -0
- package/dist/runtime/wevu.mjs +73 -0
- package/dist/runtime/wevu.mjs.map +1 -0
- package/dist/shared/nativeComponents.mjs +401 -0
- package/dist/shared/nativeComponents.mjs.map +1 -0
- package/dist/shared/tabBar.d.mts +19 -0
- package/dist/shared/tabBar.mjs +37 -0
- package/dist/shared/tabBar.mjs.map +1 -0
- package/dist/shared/wxml.mjs +3 -20
- package/dist/shared/wxml.mjs.map +1 -1
- package/package.json +14 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appState.mjs","names":[],"sources":["../../../src/runtime/polyfill/appState.ts"],"sourcesContent":["import type { AppLaunchOptions } from './routeRuntime/options'\n\nexport function resolveCurrentPages<T>(navigationHistory: Array<{ instance?: T }>) {\n return navigationHistory\n .map(entry => entry.instance)\n .filter((instance): instance is T => Boolean(instance))\n}\n\nexport function cloneLaunchOptions(options: AppLaunchOptions): AppLaunchOptions {\n return {\n path: options.path,\n scene: options.scene,\n query: { ...options.query },\n referrerInfo: { ...options.referrerInfo },\n }\n}\n\nexport function resolveFallbackLaunchOptions(\n navigationHistory: Array<{ id: string, query: Record<string, string> }>,\n): AppLaunchOptions {\n const entry = navigationHistory[navigationHistory.length - 1]
|
|
1
|
+
{"version":3,"file":"appState.mjs","names":[],"sources":["../../../src/runtime/polyfill/appState.ts"],"sourcesContent":["import type { AppLaunchOptions } from './routeRuntime/options'\n\nexport function resolveCurrentPages<T>(navigationHistory: Array<{ instance?: T }>) {\n return navigationHistory\n .map(entry => entry.instance)\n .filter((instance): instance is T => Boolean(instance))\n}\n\nexport function cloneLaunchOptions(options: AppLaunchOptions): AppLaunchOptions {\n return {\n path: options.path,\n scene: options.scene,\n query: { ...options.query },\n referrerInfo: { ...options.referrerInfo },\n }\n}\n\nexport function resolveFallbackLaunchOptions(\n navigationHistory: Array<{ id: string, query: Record<string, string> }>,\n): AppLaunchOptions {\n const entry = navigationHistory[navigationHistory.length - 1]\n if (!entry) {\n return {\n path: '',\n scene: 0,\n query: {},\n referrerInfo: {},\n }\n }\n return {\n path: entry.id,\n scene: 0,\n query: { ...entry.query },\n referrerInfo: {},\n }\n}\n"],"mappings":";AAEA,SAAgB,oBAAuB,mBAA4C;CACjF,OAAO,kBACJ,KAAI,UAAS,MAAM,QAAQ,CAAC,CAC5B,QAAQ,aAA4B,QAAQ,QAAQ,CAAC;AAC1D;AAEA,SAAgB,mBAAmB,SAA6C;CAC9E,OAAO;EACL,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,EAAE,GAAG,QAAQ,MAAM;EAC1B,cAAc,EAAE,GAAG,QAAQ,aAAa;CAC1C;AACF;AAEA,SAAgB,6BACd,mBACkB;CAClB,MAAM,QAAQ,kBAAkB,kBAAkB,SAAS;CAC3D,IAAI,CAAC,OACH,OAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO,CAAC;EACR,cAAc,CAAC;CACjB;CAEF,OAAO;EACL,MAAM,MAAM;EACZ,OAAO;EACP,OAAO,EAAE,GAAG,MAAM,MAAM;EACxB,cAAc,CAAC;CACjB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.mjs","names":[],"sources":["../../../src/runtime/polyfill/async.ts"],"sourcesContent":["interface MiniProgramBaseResultLike {\n errMsg: string\n}\n\
|
|
1
|
+
{"version":3,"file":"async.mjs","names":[],"sources":["../../../src/runtime/polyfill/async.ts"],"sourcesContent":["export interface MiniProgramBaseResultLike {\n errMsg: string\n}\n\nexport interface MiniProgramAsyncOptionsLike<SuccessResult extends MiniProgramBaseResultLike> {\n success?: (result: SuccessResult) => void\n fail?: (result: MiniProgramBaseResultLike) => void\n complete?: (result: SuccessResult | MiniProgramBaseResultLike) => void\n}\n\nexport function callMiniProgramAsyncSuccess<SuccessResult extends MiniProgramBaseResultLike>(\n options: MiniProgramAsyncOptionsLike<SuccessResult> | undefined,\n result: SuccessResult,\n) {\n options?.success?.(result)\n options?.complete?.(result)\n return result\n}\n\nexport function callMiniProgramAsyncFailure<SuccessResult extends MiniProgramBaseResultLike>(\n options: MiniProgramAsyncOptionsLike<SuccessResult> | undefined,\n errMsg: string,\n) {\n const result: MiniProgramBaseResultLike = { errMsg }\n options?.fail?.(result)\n options?.complete?.(result)\n return result\n}\n\nexport const callWxAsyncSuccess = callMiniProgramAsyncSuccess\nexport const callWxAsyncFailure = callMiniProgramAsyncFailure\n\nexport function normalizeDuration(duration: number | undefined, fallback: number) {\n if (typeof duration !== 'number' || Number.isNaN(duration)) {\n return fallback\n }\n return Math.max(0, duration)\n}\n\nexport function scheduleMicrotask(task: () => void) {\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(task)\n return\n }\n Promise.resolve()\n .then(task)\n .catch((error) => {\n setTimeout(() => {\n throw error\n }, 0)\n })\n}\n"],"mappings":";AAUA,SAAgB,4BACd,SACA,QACA;CACA,SAAS,UAAU,MAAM;CACzB,SAAS,WAAW,MAAM;CAC1B,OAAO;AACT;AAEA,SAAgB,4BACd,SACA,QACA;CACA,MAAM,SAAoC,EAAE,OAAO;CACnD,SAAS,OAAO,MAAM;CACtB,SAAS,WAAW,MAAM;CAC1B,OAAO;AACT;AAKA,SAAgB,kBAAkB,UAA8B,UAAkB;CAChF,IAAI,OAAO,aAAa,YAAY,OAAO,MAAM,QAAQ,GACvD,OAAO;CAET,OAAO,KAAK,IAAI,GAAG,QAAQ;AAC7B;AAEA,SAAgB,kBAAkB,MAAkB;CAClD,IAAI,OAAO,mBAAmB,YAAY;EACxC,eAAe,IAAI;EACnB;CACF;CACA,QAAQ,QAAQ,CAAC,CACd,KAAK,IAAI,CAAC,CACV,OAAO,UAAU;EAChB,iBAAiB;GACf,MAAM;EACR,GAAG,CAAC;CACN,CAAC;AACL"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveNativeMediaElement } from "../nativeComponents/mediaRegistry.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/runtime/polyfill/canvasContext.ts
|
|
2
4
|
function normalizeCanvasNumber(value) {
|
|
3
5
|
if (typeof value !== "number" || Number.isNaN(value)) return 0;
|
|
@@ -8,6 +10,8 @@ function resolveCanvasById(canvasId) {
|
|
|
8
10
|
const runtimeDocument = document;
|
|
9
11
|
const normalized = canvasId.trim();
|
|
10
12
|
if (!normalized) return;
|
|
13
|
+
const registered = resolveNativeMediaElement("canvas", normalized);
|
|
14
|
+
if (registered) return registered;
|
|
11
15
|
const canvasList = runtimeDocument.querySelectorAll?.("canvas") ?? runtimeDocument.body?.querySelectorAll?.("canvas") ?? [];
|
|
12
16
|
for (const candidate of Array.from(canvasList)) {
|
|
13
17
|
const canvas = candidate;
|
|
@@ -52,6 +56,11 @@ function createCanvasCommandQueue(canvasId) {
|
|
|
52
56
|
ctx.lineWidth = normalizeCanvasNumber(width);
|
|
53
57
|
});
|
|
54
58
|
},
|
|
59
|
+
setLineCap(lineCap) {
|
|
60
|
+
pushCommand((ctx) => {
|
|
61
|
+
ctx.lineCap = lineCap;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
55
64
|
setFontSize(size) {
|
|
56
65
|
pushCommand((ctx) => {
|
|
57
66
|
ctx.font = `${Math.max(1, normalizeCanvasNumber(size))}px sans-serif`;
|
|
@@ -103,6 +112,38 @@ function createCanvasCommandQueue(canvasId) {
|
|
|
103
112
|
stroke() {
|
|
104
113
|
pushCommand((ctx) => ctx.stroke());
|
|
105
114
|
},
|
|
115
|
+
fill() {
|
|
116
|
+
pushCommand((ctx) => ctx.fill());
|
|
117
|
+
},
|
|
118
|
+
rect(x, y, width, height) {
|
|
119
|
+
pushCommand((ctx) => {
|
|
120
|
+
ctx.rect(normalizeCanvasNumber(x), normalizeCanvasNumber(y), normalizeCanvasNumber(width), normalizeCanvasNumber(height));
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
arc(x, y, radius, startAngle, endAngle, counterClockwise = false) {
|
|
124
|
+
pushCommand((ctx) => {
|
|
125
|
+
ctx.arc(normalizeCanvasNumber(x), normalizeCanvasNumber(y), Math.max(0, normalizeCanvasNumber(radius)), normalizeCanvasNumber(startAngle), normalizeCanvasNumber(endAngle), Boolean(counterClockwise));
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
save() {
|
|
129
|
+
pushCommand((ctx) => ctx.save());
|
|
130
|
+
},
|
|
131
|
+
restore() {
|
|
132
|
+
pushCommand((ctx) => ctx.restore());
|
|
133
|
+
},
|
|
134
|
+
translate(x, y) {
|
|
135
|
+
pushCommand((ctx) => {
|
|
136
|
+
ctx.translate(normalizeCanvasNumber(x), normalizeCanvasNumber(y));
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
rotate(angle) {
|
|
140
|
+
pushCommand((ctx) => ctx.rotate(normalizeCanvasNumber(angle)));
|
|
141
|
+
},
|
|
142
|
+
scale(scaleWidth, scaleHeight) {
|
|
143
|
+
pushCommand((ctx) => {
|
|
144
|
+
ctx.scale(normalizeCanvasNumber(scaleWidth), normalizeCanvasNumber(scaleHeight));
|
|
145
|
+
});
|
|
146
|
+
},
|
|
106
147
|
draw
|
|
107
148
|
};
|
|
108
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvasContext.mjs","names":[],"sources":["../../../src/runtime/polyfill/canvasContext.ts"],"sourcesContent":["import type { CanvasContext } from './types/platformRuntime'\n\nfunction normalizeCanvasNumber(value: unknown) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return 0\n }\n return value\n}\n\nfunction resolveCanvasById(canvasId: string) {\n if (typeof document === 'undefined') {\n return undefined\n }\n const runtimeDocument = document as Document & {\n querySelectorAll?: (selector: string) => ArrayLike<Element>\n body?: {\n querySelectorAll?: (selector: string) => ArrayLike<Element>\n }\n }\n const normalized = canvasId.trim()\n if (!normalized) {\n return undefined\n }\n const canvasList = runtimeDocument.querySelectorAll?.('canvas')\n ?? runtimeDocument.body?.querySelectorAll?.('canvas')\n ?? []\n for (const candidate of Array.from(canvasList)) {\n const canvas = candidate as HTMLCanvasElement\n if (!canvas) {\n continue\n }\n if ((canvas as { id?: string }).id === normalized) {\n return canvas\n }\n if (typeof canvas.getAttribute === 'function' && canvas.getAttribute('canvas-id') === normalized) {\n return canvas\n }\n }\n return undefined\n}\n\nfunction createCanvasCommandQueue(canvasId: string) {\n const commands: Array<(ctx: CanvasRenderingContext2D) => void> = []\n\n const pushCommand = (command: (ctx: CanvasRenderingContext2D) => void) => {\n commands.push(command)\n }\n\n const draw: CanvasContext['draw'] = (reserveOrCallback?: boolean | (() => void), callback?: () => void) => {\n const reserve = typeof reserveOrCallback === 'boolean' ? reserveOrCallback : false\n const done = typeof reserveOrCallback === 'function' ? reserveOrCallback : callback\n const canvas = resolveCanvasById(canvasId)\n const context = canvas?.getContext?.('2d') as CanvasRenderingContext2D | null | undefined\n if (!context) {\n commands.length = 0\n done?.()\n return\n }\n if (!reserve) {\n context.clearRect(0, 0, normalizeCanvasNumber(canvas?.width), normalizeCanvasNumber(canvas?.height))\n }\n for (const command of commands) {\n command(context)\n }\n commands.length = 0\n done?.()\n }\n\n const api: CanvasContext = {\n setFillStyle(color: string) {\n pushCommand((ctx) => {\n ctx.fillStyle = color\n })\n },\n setStrokeStyle(color: string) {\n pushCommand((ctx) => {\n ctx.strokeStyle = color\n })\n },\n setLineWidth(width: number) {\n pushCommand((ctx) => {\n ctx.lineWidth = normalizeCanvasNumber(width)\n })\n },\n setFontSize(size: number) {\n pushCommand((ctx) => {\n const normalized = Math.max(1, normalizeCanvasNumber(size))\n ctx.font = `${normalized}px sans-serif`\n })\n },\n fillRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.fillRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n strokeRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.strokeRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n clearRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.clearRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n fillText(text: string, x: number, y: number, maxWidth?: number) {\n pushCommand((ctx) => {\n const normalizedText = String(text ?? '')\n const normalizedX = normalizeCanvasNumber(x)\n const normalizedY = normalizeCanvasNumber(y)\n if (typeof maxWidth === 'number' && Number.isFinite(maxWidth)) {\n ctx.fillText(normalizedText, normalizedX, normalizedY, normalizeCanvasNumber(maxWidth))\n return\n }\n ctx.fillText(normalizedText, normalizedX, normalizedY)\n })\n },\n beginPath() {\n pushCommand(ctx => ctx.beginPath())\n },\n closePath() {\n pushCommand(ctx => ctx.closePath())\n },\n moveTo(x: number, y: number) {\n pushCommand((ctx) => {\n ctx.moveTo(normalizeCanvasNumber(x), normalizeCanvasNumber(y))\n })\n },\n lineTo(x: number, y: number) {\n pushCommand((ctx) => {\n ctx.lineTo(normalizeCanvasNumber(x), normalizeCanvasNumber(y))\n })\n },\n stroke() {\n pushCommand(ctx => ctx.stroke())\n },\n draw,\n }\n return api\n}\n\nexport function createCanvasContextBridge(canvasId: string) {\n return createCanvasCommandQueue(String(canvasId ?? ''))\n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GAAW;GAC3B,aAAa,QAAQ;IACnB,IAAI,OAAO,sBAAsB,CAAC,GAAG,sBAAsB,CAAC,CAAC;GAC/D,CAAC;EACH;EACA,OAAO,GAAW,GAAW;GAC3B,aAAa,QAAQ;IACnB,IAAI,OAAO,sBAAsB,CAAC,GAAG,sBAAsB,CAAC,CAAC;GAC/D,CAAC;EACH;EACA,SAAS;GACP,aAAY,QAAO,IAAI,OAAO,CAAC;EACjC;EACA;CAEO;AACX;AAEA,SAAgB,0BAA0B,UAAkB;CAC1D,OAAO,yBAAyB,OAAO,YAAY,EAAE,CAAC;AACxD"}
|
|
1
|
+
{"version":3,"file":"canvasContext.mjs","names":[],"sources":["../../../src/runtime/polyfill/canvasContext.ts"],"sourcesContent":["import type { CanvasContext } from './types/platformRuntime'\nimport { resolveNativeMediaElement } from '../nativeComponents/mediaRegistry'\n\nfunction normalizeCanvasNumber(value: unknown) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return 0\n }\n return value\n}\n\nfunction resolveCanvasById(canvasId: string) {\n if (typeof document === 'undefined') {\n return undefined\n }\n const runtimeDocument = document as Document & {\n querySelectorAll?: (selector: string) => ArrayLike<Element>\n body?: {\n querySelectorAll?: (selector: string) => ArrayLike<Element>\n }\n }\n const normalized = canvasId.trim()\n if (!normalized) {\n return undefined\n }\n const registered = resolveNativeMediaElement<HTMLCanvasElement>('canvas', normalized)\n if (registered) {\n return registered\n }\n const canvasList = runtimeDocument.querySelectorAll?.('canvas')\n ?? runtimeDocument.body?.querySelectorAll?.('canvas')\n ?? []\n for (const candidate of Array.from(canvasList)) {\n const canvas = candidate as HTMLCanvasElement\n if (!canvas) {\n continue\n }\n if ((canvas as { id?: string }).id === normalized) {\n return canvas\n }\n if (typeof canvas.getAttribute === 'function' && canvas.getAttribute('canvas-id') === normalized) {\n return canvas\n }\n }\n return undefined\n}\n\nfunction createCanvasCommandQueue(canvasId: string) {\n const commands: Array<(ctx: CanvasRenderingContext2D) => void> = []\n\n const pushCommand = (command: (ctx: CanvasRenderingContext2D) => void) => {\n commands.push(command)\n }\n\n const draw: CanvasContext['draw'] = (reserveOrCallback?: boolean | (() => void), callback?: () => void) => {\n const reserve = typeof reserveOrCallback === 'boolean' ? reserveOrCallback : false\n const done = typeof reserveOrCallback === 'function' ? reserveOrCallback : callback\n const canvas = resolveCanvasById(canvasId)\n const context = canvas?.getContext?.('2d') as CanvasRenderingContext2D | null | undefined\n if (!context) {\n commands.length = 0\n done?.()\n return\n }\n if (!reserve) {\n context.clearRect(0, 0, normalizeCanvasNumber(canvas?.width), normalizeCanvasNumber(canvas?.height))\n }\n for (const command of commands) {\n command(context)\n }\n commands.length = 0\n done?.()\n }\n\n const api: CanvasContext = {\n setFillStyle(color: string) {\n pushCommand((ctx) => {\n ctx.fillStyle = color\n })\n },\n setStrokeStyle(color: string) {\n pushCommand((ctx) => {\n ctx.strokeStyle = color\n })\n },\n setLineWidth(width: number) {\n pushCommand((ctx) => {\n ctx.lineWidth = normalizeCanvasNumber(width)\n })\n },\n setLineCap(lineCap: CanvasLineCap) {\n pushCommand((ctx) => {\n ctx.lineCap = lineCap\n })\n },\n setFontSize(size: number) {\n pushCommand((ctx) => {\n const normalized = Math.max(1, normalizeCanvasNumber(size))\n ctx.font = `${normalized}px sans-serif`\n })\n },\n fillRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.fillRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n strokeRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.strokeRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n clearRect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.clearRect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n fillText(text: string, x: number, y: number, maxWidth?: number) {\n pushCommand((ctx) => {\n const normalizedText = String(text ?? '')\n const normalizedX = normalizeCanvasNumber(x)\n const normalizedY = normalizeCanvasNumber(y)\n if (typeof maxWidth === 'number' && Number.isFinite(maxWidth)) {\n ctx.fillText(normalizedText, normalizedX, normalizedY, normalizeCanvasNumber(maxWidth))\n return\n }\n ctx.fillText(normalizedText, normalizedX, normalizedY)\n })\n },\n beginPath() {\n pushCommand(ctx => ctx.beginPath())\n },\n closePath() {\n pushCommand(ctx => ctx.closePath())\n },\n moveTo(x: number, y: number) {\n pushCommand((ctx) => {\n ctx.moveTo(normalizeCanvasNumber(x), normalizeCanvasNumber(y))\n })\n },\n lineTo(x: number, y: number) {\n pushCommand((ctx) => {\n ctx.lineTo(normalizeCanvasNumber(x), normalizeCanvasNumber(y))\n })\n },\n stroke() {\n pushCommand(ctx => ctx.stroke())\n },\n fill() {\n pushCommand(ctx => ctx.fill())\n },\n rect(x: number, y: number, width: number, height: number) {\n pushCommand((ctx) => {\n ctx.rect(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n normalizeCanvasNumber(width),\n normalizeCanvasNumber(height),\n )\n })\n },\n arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterClockwise = false) {\n pushCommand((ctx) => {\n ctx.arc(\n normalizeCanvasNumber(x),\n normalizeCanvasNumber(y),\n Math.max(0, normalizeCanvasNumber(radius)),\n normalizeCanvasNumber(startAngle),\n normalizeCanvasNumber(endAngle),\n Boolean(counterClockwise),\n )\n })\n },\n save() {\n pushCommand(ctx => ctx.save())\n },\n restore() {\n pushCommand(ctx => ctx.restore())\n },\n translate(x: number, y: number) {\n pushCommand((ctx) => {\n ctx.translate(normalizeCanvasNumber(x), normalizeCanvasNumber(y))\n })\n },\n rotate(angle: number) {\n pushCommand(ctx => ctx.rotate(normalizeCanvasNumber(angle)))\n },\n scale(scaleWidth: number, scaleHeight: number) {\n pushCommand((ctx) => {\n ctx.scale(normalizeCanvasNumber(scaleWidth), normalizeCanvasNumber(scaleHeight))\n })\n },\n draw,\n }\n return api\n}\n\nexport function createCanvasContextBridge(canvasId: string) {\n return createCanvasCommandQueue(String(canvasId ?? ''))\n}\n"],"mappings":";;;AAGA,SAAS,sBAAsB,OAAgB;CAC7C,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,KAAK,GACjD,OAAO;CAET,OAAO;AACT;AAEA,SAAS,kBAAkB,UAAkB;CAC3C,IAAI,OAAO,aAAa,aACtB;CAEF,MAAM,kBAAkB;CAMxB,MAAM,aAAa,SAAS,KAAK;CACjC,IAAI,CAAC,YACH;CAEF,MAAM,aAAa,0BAA6C,UAAU,UAAU;CACpF,IAAI,YACF,OAAO;CAET,MAAM,aAAa,gBAAgB,mBAAmB,QAAQ,KACzD,gBAAgB,MAAM,mBAAmB,QAAQ,KACjD,CAAC;CACN,KAAK,MAAM,aAAa,MAAM,KAAK,UAAU,GAAG;EAC9C,MAAM,SAAS;EACf,IAAI,CAAC,QACH;EAEF,IAAK,OAA2B,OAAO,YACrC,OAAO;EAET,IAAI,OAAO,OAAO,iBAAiB,cAAc,OAAO,aAAa,WAAW,MAAM,YACpF,OAAO;CAEX;AAEF;AAEA,SAAS,yBAAyB,UAAkB;CAClD,MAAM,WAA2D,CAAC;CAElE,MAAM,eAAe,YAAqD;EACxE,SAAS,KAAK,OAAO;CACvB;CAEA,MAAM,QAA+B,mBAA4C,aAA0B;EACzG,MAAM,UAAU,OAAO,sBAAsB,YAAY,oBAAoB;EAC7E,MAAM,OAAO,OAAO,sBAAsB,aAAa,oBAAoB;EAC3E,MAAM,SAAS,kBAAkB,QAAQ;EACzC,MAAM,UAAU,QAAQ,aAAa,IAAI;EACzC,IAAI,CAAC,SAAS;GACZ,SAAS,SAAS;GAClB,OAAO;GACP;EACF;EACA,IAAI,CAAC,SACH,QAAQ,UAAU,GAAG,GAAG,sBAAsB,QAAQ,KAAK,GAAG,sBAAsB,QAAQ,MAAM,CAAC;EAErG,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C,CAAC;GAClE,CAAC;EACH;EACA,OAAO,OAAe;GACpB,aAAY,QAAO,IAAI,OAAO,sBAAsB,KAAK,CAAC,CAAC;EAC7D;EACA,MAAM,YAAoB,aAAqB;GAC7C,aAAa,QAAQ;IACnB,IAAI,MAAM,sBAAsB,UAAU,GAAG,sBAAsB,WAAW,CAAC;GACjF,CAAC;EACH;EACA;CAEO;AACX;AAEA,SAAgB,0BAA0B,UAAkB;CAC1D,OAAO,yBAAyB,OAAO,YAAY,EAAE,CAAC;AACxD"}
|
|
@@ -19,7 +19,7 @@ let cachedBatteryInfo = {
|
|
|
19
19
|
isCharging: false
|
|
20
20
|
};
|
|
21
21
|
async function readRuntimeBatteryInfoInternal() {
|
|
22
|
-
const runtimeNavigator =
|
|
22
|
+
const runtimeNavigator = globalThis.navigator;
|
|
23
23
|
if (runtimeNavigator && typeof runtimeNavigator.getBattery === "function") {
|
|
24
24
|
const battery = await runtimeNavigator.getBattery();
|
|
25
25
|
const nextInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.mjs","names":[],"sources":["../../../src/runtime/polyfill/device.ts"],"sourcesContent":["type VibrateType = 'heavy' | 'medium' | 'light' | undefined\n\ninterface BatterySnapshot {\n level: number\n isCharging: boolean\n}\n\nfunction resolveVibrateDuration(type: VibrateType) {\n if (type === 'heavy') {\n return 30\n }\n if (type === 'medium') {\n return 20\n }\n return 15\n}\n\nexport function vibrateDevice(type: VibrateType) {\n const runtimeNavigator = (typeof navigator !== 'undefined' ? navigator : undefined) as (Navigator & {\n vibrate?: (pattern: number | number[]) => boolean\n }) | undefined\n if (!runtimeNavigator || typeof runtimeNavigator.vibrate !== 'function') {\n throw new Error('vibrate is unavailable')\n }\n runtimeNavigator.vibrate(resolveVibrateDuration(type))\n}\n\nfunction normalizeBatteryLevel(level: unknown) {\n if (typeof level !== 'number' || Number.isNaN(level)) {\n return 100\n }\n const value = Math.round(level * 100)\n return Math.min(100, Math.max(0, value))\n}\n\nlet cachedBatteryInfo: BatterySnapshot = {\n level: 100,\n isCharging: false,\n}\n\nasync function readRuntimeBatteryInfoInternal() {\n const runtimeNavigator =
|
|
1
|
+
{"version":3,"file":"device.mjs","names":[],"sources":["../../../src/runtime/polyfill/device.ts"],"sourcesContent":["type VibrateType = 'heavy' | 'medium' | 'light' | undefined\n\ninterface BatterySnapshot {\n level: number\n isCharging: boolean\n}\n\nfunction resolveVibrateDuration(type: VibrateType) {\n if (type === 'heavy') {\n return 30\n }\n if (type === 'medium') {\n return 20\n }\n return 15\n}\n\nexport function vibrateDevice(type: VibrateType) {\n const runtimeNavigator = (typeof navigator !== 'undefined' ? navigator : undefined) as (Navigator & {\n vibrate?: (pattern: number | number[]) => boolean\n }) | undefined\n if (!runtimeNavigator || typeof runtimeNavigator.vibrate !== 'function') {\n throw new Error('vibrate is unavailable')\n }\n runtimeNavigator.vibrate(resolveVibrateDuration(type))\n}\n\nfunction normalizeBatteryLevel(level: unknown) {\n if (typeof level !== 'number' || Number.isNaN(level)) {\n return 100\n }\n const value = Math.round(level * 100)\n return Math.min(100, Math.max(0, value))\n}\n\nlet cachedBatteryInfo: BatterySnapshot = {\n level: 100,\n isCharging: false,\n}\n\nasync function readRuntimeBatteryInfoInternal() {\n const runtimeNavigator = globalThis.navigator as (Navigator & {\n getBattery?: () => Promise<{ charging?: boolean, level?: number }>\n }) | undefined\n if (runtimeNavigator && typeof runtimeNavigator.getBattery === 'function') {\n const battery = await runtimeNavigator.getBattery()\n const nextInfo: BatterySnapshot = {\n level: normalizeBatteryLevel(battery?.level),\n isCharging: Boolean(battery?.charging),\n }\n cachedBatteryInfo = nextInfo\n return nextInfo\n }\n return cachedBatteryInfo\n}\n\nexport function readBatteryInfoSyncSnapshot() {\n void readRuntimeBatteryInfoInternal().catch(() => {})\n return {\n ...cachedBatteryInfo,\n }\n}\n\nexport function readBatteryInfoSnapshot() {\n return readRuntimeBatteryInfoInternal()\n}\n"],"mappings":";AAOA,SAAS,uBAAuB,MAAmB;CACjD,IAAI,SAAS,SACX,OAAO;CAET,IAAI,SAAS,UACX,OAAO;CAET,OAAO;AACT;AAEA,SAAgB,cAAc,MAAmB;CAC/C,MAAM,mBAAoB,OAAO,cAAc,cAAc,YAAY;CAGzE,IAAI,CAAC,oBAAoB,OAAO,iBAAiB,YAAY,YAC3D,MAAM,IAAI,MAAM,wBAAwB;CAE1C,iBAAiB,QAAQ,uBAAuB,IAAI,CAAC;AACvD;AAEA,SAAS,sBAAsB,OAAgB;CAC7C,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,KAAK,GACjD,OAAO;CAET,MAAM,QAAQ,KAAK,MAAM,QAAQ,GAAG;CACpC,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;AACzC;AAEA,IAAI,oBAAqC;CACvC,OAAO;CACP,YAAY;AACd;AAEA,eAAe,iCAAiC;CAC9C,MAAM,mBAAmB,WAAW;CAGpC,IAAI,oBAAoB,OAAO,iBAAiB,eAAe,YAAY;EACzE,MAAM,UAAU,MAAM,iBAAiB,WAAW;EAClD,MAAM,WAA4B;GAChC,OAAO,sBAAsB,SAAS,KAAK;GAC3C,YAAY,QAAQ,SAAS,QAAQ;EACvC;EACA,oBAAoB;EACpB,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAgB,8BAA8B;CAC5C,AAAK,+BAA+B,CAAC,CAAC,YAAY,CAAC,CAAC;CACpD,OAAO,EACL,GAAG,kBACL;AACF;AAEA,SAAgB,0BAA0B;CACxC,OAAO,+BAA+B;AACxC"}
|
|
@@ -7,7 +7,8 @@ function vibrateShortBridge(options) {
|
|
|
7
7
|
vibrateDevice(options?.type);
|
|
8
8
|
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "vibrateShort:ok" }));
|
|
9
9
|
} catch (error) {
|
|
10
|
-
const
|
|
10
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
11
|
+
const failure = callMiniProgramAsyncFailure(options, `vibrateShort:fail ${message}`);
|
|
11
12
|
return Promise.reject(failure);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -16,12 +17,14 @@ function getBatteryInfoSyncBridge() {
|
|
|
16
17
|
}
|
|
17
18
|
async function getBatteryInfoBridge(options) {
|
|
18
19
|
try {
|
|
20
|
+
const batteryInfo = await readBatteryInfoSnapshot();
|
|
19
21
|
return callMiniProgramAsyncSuccess(options, {
|
|
20
22
|
errMsg: "getBatteryInfo:ok",
|
|
21
|
-
...
|
|
23
|
+
...batteryInfo
|
|
22
24
|
});
|
|
23
25
|
} catch (error) {
|
|
24
|
-
const
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
const failure = callMiniProgramAsyncFailure(options, `getBatteryInfo:fail ${message}`);
|
|
25
28
|
return Promise.reject(failure);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/deviceApi.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n readBatteryInfoSnapshot,\n readBatteryInfoSyncSnapshot,\n vibrateDevice,\n} from './device'\n\nexport function vibrateShortBridge(options?: any) {\n try {\n vibrateDevice(options?.type)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'vibrateShort:ok' }))\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `vibrateShort:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport function getBatteryInfoSyncBridge() {\n return readBatteryInfoSyncSnapshot()\n}\n\nexport async function getBatteryInfoBridge(options?: any) {\n try {\n const batteryInfo = await readBatteryInfoSnapshot()\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getBatteryInfo:ok',\n ...batteryInfo,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getBatteryInfo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,SAAe;CAChD,IAAI;EACF,cAAc,SAAS,IAAI;EAC3B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;CAC5F,SACO,OAAO;
|
|
1
|
+
{"version":3,"file":"deviceApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/deviceApi.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n readBatteryInfoSnapshot,\n readBatteryInfoSyncSnapshot,\n vibrateDevice,\n} from './device'\n\nexport function vibrateShortBridge(options?: any) {\n try {\n vibrateDevice(options?.type)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'vibrateShort:ok' }))\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `vibrateShort:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport function getBatteryInfoSyncBridge() {\n return readBatteryInfoSyncSnapshot()\n}\n\nexport async function getBatteryInfoBridge(options?: any) {\n try {\n const batteryInfo = await readBatteryInfoSnapshot()\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getBatteryInfo:ok',\n ...batteryInfo,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getBatteryInfo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,SAAe;CAChD,IAAI;EACF,cAAc,SAAS,IAAI;EAC3B,OAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC,CAAC;CAC5F,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,UAAU,4BAA4B,SAAS,qBAAqB,SAAS;EACnF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF;AAEA,SAAgB,2BAA2B;CACzC,OAAO,4BAA4B;AACrC;AAEA,eAAsB,qBAAqB,SAAe;CACxD,IAAI;EACF,MAAM,cAAc,MAAM,wBAAwB;EAClD,OAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,GAAG;EACL,CAAC;CACH,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,UAAU,4BAA4B,SAAS,uBAAuB,SAAS;EACrF,OAAO,QAAQ,OAAO,OAAO;CAC/B;AACF"}
|
|
@@ -4,7 +4,7 @@ import { getBatteryInfoBridge, getBatteryInfoSyncBridge, vibrateShortBridge } fr
|
|
|
4
4
|
import { getFuzzyLocationBridge, getLocationBridge } from "./locationApi.mjs";
|
|
5
5
|
import { getNetworkTypeBridge } from "./menuApi.mjs";
|
|
6
6
|
import { offNetworkStatusChangeBridge, offWindowResizeBridge, onNetworkStatusChangeBridge, onWindowResizeBridge } from "./runtimeCapabilityApi.mjs";
|
|
7
|
-
import { resolveDeviceOrientation } from "./system.mjs";
|
|
7
|
+
import { resolveDeviceOrientation, rpx2px as rpx2px$1 } from "./system.mjs";
|
|
8
8
|
import { getAccountInfoSyncBridge, getAppBaseInfoBridge, getDeviceInfoBridge, getMenuButtonBoundingClientRectBridge, getSystemInfoBridge, getSystemInfoSyncBridge, getWindowInfoBridge } from "./systemApi.mjs";
|
|
9
9
|
|
|
10
10
|
//#region src/runtime/polyfill/deviceAuthSystemApi.ts
|
|
@@ -35,6 +35,8 @@ var deviceAuthSystemApi_exports = /* @__PURE__ */ __exportAll({
|
|
|
35
35
|
onWindowResize: () => onWindowResize,
|
|
36
36
|
openAppAuthorizeSetting: () => openAppAuthorizeSetting,
|
|
37
37
|
openSetting: () => openSetting,
|
|
38
|
+
rpx2px: () => rpx2px,
|
|
39
|
+
upx2px: () => upx2px,
|
|
38
40
|
vibrateShort: () => vibrateShort
|
|
39
41
|
});
|
|
40
42
|
const WEB_SUPPORTED_AUTH_SCOPES = /* @__PURE__ */ new Set([
|
|
@@ -99,6 +101,10 @@ function offNetworkStatusChange(callback) {
|
|
|
99
101
|
function getWindowInfo() {
|
|
100
102
|
return getWindowInfoBridge();
|
|
101
103
|
}
|
|
104
|
+
function rpx2px(value) {
|
|
105
|
+
return rpx2px$1(value);
|
|
106
|
+
}
|
|
107
|
+
const upx2px = rpx2px;
|
|
102
108
|
function onWindowResize(callback) {
|
|
103
109
|
return onWindowResizeBridge(callback, getWindowInfo);
|
|
104
110
|
}
|
|
@@ -140,5 +146,5 @@ function getMenuButtonBoundingClientRect() {
|
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
//#endregion
|
|
143
|
-
export { 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 };
|
|
149
|
+
export { 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, rpx2px, upx2px, vibrateShort };
|
|
144
150
|
//# sourceMappingURL=deviceAuthSystemApi.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceAuthSystemApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/deviceAuthSystemApi.ts"],"sourcesContent":["import type {\n AccountInfoSync,\n AppAuthorizeSetting,\n AppAuthorizeStatus,\n AppBaseInfo,\n AuthorizeOptions,\n BatteryInfo,\n CheckSessionOptions,\n DeviceInfo,\n GetBatteryInfoSuccessResult,\n GetFuzzyLocationOptions,\n GetLocationOptions,\n GetNetworkTypeOptions,\n GetSettingOptions,\n GetSystemInfoOptions,\n GetUserInfoOptions,\n GetUserProfileOptions,\n LoginOptions,\n MenuButtonBoundingClientRect,\n MiniProgramAsyncOptions,\n NetworkStatusChangeCallback,\n OpenAppAuthorizeSettingOptions,\n OpenSettingOptions,\n SystemInfo,\n SystemSetting,\n VibrateShortOptions,\n WindowInfo,\n WindowResizeCallback,\n} from './types'\nimport {\n authorizeBridge,\n checkSessionBridge,\n getAppAuthorizeSettingBridge,\n getSettingBridge,\n getSystemSettingBridge,\n getUserInfoBridge,\n getUserProfileBridge,\n loginBridge,\n openAppAuthorizeSettingBridge,\n openSettingBridge,\n} from './authApi'\nimport {\n getBatteryInfoBridge,\n getBatteryInfoSyncBridge,\n vibrateShortBridge,\n} from './deviceApi'\nimport {\n getFuzzyLocationBridge,\n getLocationBridge,\n} from './locationApi'\nimport { getNetworkTypeBridge } from './menuApi'\nimport {\n offNetworkStatusChangeBridge,\n offWindowResizeBridge,\n onNetworkStatusChangeBridge,\n onWindowResizeBridge,\n} from './runtimeCapabilityApi'\nimport { resolveDeviceOrientation } from './system'\nimport {\n getAccountInfoSyncBridge,\n getAppBaseInfoBridge,\n getDeviceInfoBridge,\n getMenuButtonBoundingClientRectBridge,\n getSystemInfoBridge,\n getSystemInfoSyncBridge,\n getWindowInfoBridge,\n} from './systemApi'\n\nconst WEB_SUPPORTED_AUTH_SCOPES = new Set([\n 'scope.userInfo',\n 'scope.userLocation',\n 'scope.userLocationBackground',\n 'scope.address',\n 'scope.invoiceTitle',\n 'scope.invoice',\n 'scope.werun',\n 'scope.record',\n 'scope.writePhotosAlbum',\n 'scope.camera',\n])\nconst APP_AUTHORIZE_SCOPE_MAP: Partial<Record<keyof AppAuthorizeSetting, string>> = {\n albumAuthorized: 'scope.writePhotosAlbum',\n cameraAuthorized: 'scope.camera',\n locationAuthorized: 'scope.userLocation',\n microphoneAuthorized: 'scope.record',\n}\nconst webAuthorizeState = new Map<string, AppAuthorizeStatus>()\nfor (const scope of WEB_SUPPORTED_AUTH_SCOPES) {\n webAuthorizeState.set(scope, 'not determined')\n}\n\nexport function vibrateShort(options?: VibrateShortOptions) {\n return vibrateShortBridge(options)\n}\n\nexport function getBatteryInfoSync(): BatteryInfo {\n return getBatteryInfoSyncBridge()\n}\n\nexport async function getBatteryInfo(options?: MiniProgramAsyncOptions<GetBatteryInfoSuccessResult>) {\n return getBatteryInfoBridge(options)\n}\n\nexport function getLocation(options?: GetLocationOptions) {\n return getLocationBridge(options)\n}\n\nexport async function getFuzzyLocation(options?: GetFuzzyLocationOptions) {\n return getFuzzyLocationBridge(options)\n}\n\nexport function getSetting(options?: GetSettingOptions) {\n return getSettingBridge(options, webAuthorizeState)\n}\n\nexport function authorize(options?: AuthorizeOptions) {\n return authorizeBridge(options, webAuthorizeState, WEB_SUPPORTED_AUTH_SCOPES)\n}\n\nexport function openSetting(options?: OpenSettingOptions) {\n return openSettingBridge(options, webAuthorizeState, WEB_SUPPORTED_AUTH_SCOPES)\n}\n\nexport function getAppAuthorizeSetting(): AppAuthorizeSetting {\n return getAppAuthorizeSettingBridge(webAuthorizeState) as AppAuthorizeSetting\n}\n\nexport function openAppAuthorizeSetting(options?: OpenAppAuthorizeSettingOptions) {\n return openAppAuthorizeSettingBridge(\n options,\n webAuthorizeState,\n APP_AUTHORIZE_SCOPE_MAP as Record<string, string>,\n getAppAuthorizeSetting,\n )\n}\n\nexport function getNetworkType(options?: GetNetworkTypeOptions) {\n return getNetworkTypeBridge(options)\n}\n\nexport function onNetworkStatusChange(callback: NetworkStatusChangeCallback) {\n return onNetworkStatusChangeBridge(callback)\n}\n\nexport function offNetworkStatusChange(callback?: NetworkStatusChangeCallback) {\n return offNetworkStatusChangeBridge(callback)\n}\n\nexport function getWindowInfo(): WindowInfo {\n return getWindowInfoBridge()\n}\n\nexport function onWindowResize(callback: WindowResizeCallback) {\n return onWindowResizeBridge(callback, getWindowInfo)\n}\n\nexport function offWindowResize(callback?: WindowResizeCallback) {\n return offWindowResizeBridge(callback)\n}\n\nexport function getSystemInfoSync(): SystemInfo {\n return getSystemInfoSyncBridge()\n}\n\nexport function getSystemInfo(options?: GetSystemInfoOptions) {\n return getSystemInfoBridge(options)\n}\n\nexport function getDeviceInfo(): DeviceInfo {\n return getDeviceInfoBridge() as DeviceInfo\n}\n\nexport function getSystemSetting(): SystemSetting {\n return getSystemSettingBridge(webAuthorizeState, resolveDeviceOrientation)\n}\n\nexport function login(options?: LoginOptions) {\n return loginBridge(options)\n}\n\nexport function checkSession(options?: CheckSessionOptions) {\n return checkSessionBridge(options)\n}\n\nexport function getUserInfo(options?: GetUserInfoOptions) {\n return getUserInfoBridge(options, webAuthorizeState)\n}\n\nexport function getUserProfile(options?: GetUserProfileOptions) {\n return getUserProfileBridge(options, webAuthorizeState)\n}\n\nexport function getAccountInfoSync(): AccountInfoSync {\n return getAccountInfoSyncBridge() as AccountInfoSync\n}\n\nexport function getAppBaseInfo(): AppBaseInfo {\n return getAppBaseInfoBridge() as AppBaseInfo\n}\n\nexport function getMenuButtonBoundingClientRect(): MenuButtonBoundingClientRect {\n return getMenuButtonBoundingClientRectBridge() as MenuButtonBoundingClientRect\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"deviceAuthSystemApi.mjs","names":["rpx2pxBridge"],"sources":["../../../src/runtime/polyfill/deviceAuthSystemApi.ts"],"sourcesContent":["import type {\n AccountInfoSync,\n AppAuthorizeSetting,\n AppAuthorizeStatus,\n AppBaseInfo,\n AuthorizeOptions,\n BatteryInfo,\n CheckSessionOptions,\n DeviceInfo,\n GetBatteryInfoSuccessResult,\n GetFuzzyLocationOptions,\n GetLocationOptions,\n GetNetworkTypeOptions,\n GetSettingOptions,\n GetSystemInfoOptions,\n GetUserInfoOptions,\n GetUserProfileOptions,\n LoginOptions,\n MenuButtonBoundingClientRect,\n MiniProgramAsyncOptions,\n NetworkStatusChangeCallback,\n OpenAppAuthorizeSettingOptions,\n OpenSettingOptions,\n SystemInfo,\n SystemSetting,\n VibrateShortOptions,\n WindowInfo,\n WindowResizeCallback,\n} from './types'\nimport {\n authorizeBridge,\n checkSessionBridge,\n getAppAuthorizeSettingBridge,\n getSettingBridge,\n getSystemSettingBridge,\n getUserInfoBridge,\n getUserProfileBridge,\n loginBridge,\n openAppAuthorizeSettingBridge,\n openSettingBridge,\n} from './authApi'\nimport {\n getBatteryInfoBridge,\n getBatteryInfoSyncBridge,\n vibrateShortBridge,\n} from './deviceApi'\nimport {\n getFuzzyLocationBridge,\n getLocationBridge,\n} from './locationApi'\nimport { getNetworkTypeBridge } from './menuApi'\nimport {\n offNetworkStatusChangeBridge,\n offWindowResizeBridge,\n onNetworkStatusChangeBridge,\n onWindowResizeBridge,\n} from './runtimeCapabilityApi'\nimport { resolveDeviceOrientation, rpx2px as rpx2pxBridge } from './system'\nimport {\n getAccountInfoSyncBridge,\n getAppBaseInfoBridge,\n getDeviceInfoBridge,\n getMenuButtonBoundingClientRectBridge,\n getSystemInfoBridge,\n getSystemInfoSyncBridge,\n getWindowInfoBridge,\n} from './systemApi'\n\nconst WEB_SUPPORTED_AUTH_SCOPES = new Set([\n 'scope.userInfo',\n 'scope.userLocation',\n 'scope.userLocationBackground',\n 'scope.address',\n 'scope.invoiceTitle',\n 'scope.invoice',\n 'scope.werun',\n 'scope.record',\n 'scope.writePhotosAlbum',\n 'scope.camera',\n])\nconst APP_AUTHORIZE_SCOPE_MAP: Partial<Record<keyof AppAuthorizeSetting, string>> = {\n albumAuthorized: 'scope.writePhotosAlbum',\n cameraAuthorized: 'scope.camera',\n locationAuthorized: 'scope.userLocation',\n microphoneAuthorized: 'scope.record',\n}\nconst webAuthorizeState = new Map<string, AppAuthorizeStatus>()\nfor (const scope of WEB_SUPPORTED_AUTH_SCOPES) {\n webAuthorizeState.set(scope, 'not determined')\n}\n\nexport function vibrateShort(options?: VibrateShortOptions) {\n return vibrateShortBridge(options)\n}\n\nexport function getBatteryInfoSync(): BatteryInfo {\n return getBatteryInfoSyncBridge()\n}\n\nexport async function getBatteryInfo(options?: MiniProgramAsyncOptions<GetBatteryInfoSuccessResult>) {\n return getBatteryInfoBridge(options)\n}\n\nexport function getLocation(options?: GetLocationOptions) {\n return getLocationBridge(options)\n}\n\nexport async function getFuzzyLocation(options?: GetFuzzyLocationOptions) {\n return getFuzzyLocationBridge(options)\n}\n\nexport function getSetting(options?: GetSettingOptions) {\n return getSettingBridge(options, webAuthorizeState)\n}\n\nexport function authorize(options?: AuthorizeOptions) {\n return authorizeBridge(options, webAuthorizeState, WEB_SUPPORTED_AUTH_SCOPES)\n}\n\nexport function openSetting(options?: OpenSettingOptions) {\n return openSettingBridge(options, webAuthorizeState, WEB_SUPPORTED_AUTH_SCOPES)\n}\n\nexport function getAppAuthorizeSetting(): AppAuthorizeSetting {\n return getAppAuthorizeSettingBridge(webAuthorizeState) as AppAuthorizeSetting\n}\n\nexport function openAppAuthorizeSetting(options?: OpenAppAuthorizeSettingOptions) {\n return openAppAuthorizeSettingBridge(\n options,\n webAuthorizeState,\n APP_AUTHORIZE_SCOPE_MAP as Record<string, string>,\n getAppAuthorizeSetting,\n )\n}\n\nexport function getNetworkType(options?: GetNetworkTypeOptions) {\n return getNetworkTypeBridge(options)\n}\n\nexport function onNetworkStatusChange(callback: NetworkStatusChangeCallback) {\n return onNetworkStatusChangeBridge(callback)\n}\n\nexport function offNetworkStatusChange(callback?: NetworkStatusChangeCallback) {\n return offNetworkStatusChangeBridge(callback)\n}\n\nexport function getWindowInfo(): WindowInfo {\n return getWindowInfoBridge()\n}\n\nexport function rpx2px(value: number) {\n return rpx2pxBridge(value)\n}\n\nexport const upx2px = rpx2px\n\nexport function onWindowResize(callback: WindowResizeCallback) {\n return onWindowResizeBridge(callback, getWindowInfo)\n}\n\nexport function offWindowResize(callback?: WindowResizeCallback) {\n return offWindowResizeBridge(callback)\n}\n\nexport function getSystemInfoSync(): SystemInfo {\n return getSystemInfoSyncBridge()\n}\n\nexport function getSystemInfo(options?: GetSystemInfoOptions) {\n return getSystemInfoBridge(options)\n}\n\nexport function getDeviceInfo(): DeviceInfo {\n return getDeviceInfoBridge() as DeviceInfo\n}\n\nexport function getSystemSetting(): SystemSetting {\n return getSystemSettingBridge(webAuthorizeState, resolveDeviceOrientation)\n}\n\nexport function login(options?: LoginOptions) {\n return loginBridge(options)\n}\n\nexport function checkSession(options?: CheckSessionOptions) {\n return checkSessionBridge(options)\n}\n\nexport function getUserInfo(options?: GetUserInfoOptions) {\n return getUserInfoBridge(options, webAuthorizeState)\n}\n\nexport function getUserProfile(options?: GetUserProfileOptions) {\n return getUserProfileBridge(options, webAuthorizeState)\n}\n\nexport function getAccountInfoSync(): AccountInfoSync {\n return getAccountInfoSyncBridge() as AccountInfoSync\n}\n\nexport function getAppBaseInfo(): AppBaseInfo {\n return getAppBaseInfoBridge() as AppBaseInfo\n}\n\nexport function getMenuButtonBoundingClientRect(): MenuButtonBoundingClientRect {\n return getMenuButtonBoundingClientRectBridge() as MenuButtonBoundingClientRect\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,0BAA8E;CAClF,iBAAiB;CACjB,kBAAkB;CAClB,oBAAoB;CACpB,sBAAsB;AACxB;AACA,MAAM,oCAAoB,IAAI,IAAgC;AAC9D,KAAK,MAAM,SAAS,2BAClB,kBAAkB,IAAI,OAAO,gBAAgB;AAG/C,SAAgB,aAAa,SAA+B;CAC1D,OAAO,mBAAmB,OAAO;AACnC;AAEA,SAAgB,qBAAkC;CAChD,OAAO,yBAAyB;AAClC;AAEA,eAAsB,eA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AY,OAAO;AAC5B;AAEA,SAAgB,aAAa,SAA+B;CAC1D,OAAO,mBAAmB,OAAO;AACnC;AAEA,SAAgB,YAAY,SAA8B;CACxD,OAAO,kBAAkB,SAAS,iBAAiB;AACrD;AAEA,SAAgB,eAAe,SAAiC;CAC9D,OAAO,qBAAqB,SAAS,iBAAiB;AACxD;AAEA,SAAgB,qBAAsC;CACpD,OAAO,yBAAyB;AAClC;AAEA,SAAgB,iBAA8B;CAC5C,OAAO,qBAAqB;AAC9B;AAEA,SAAgB,kCAAgE;CAC9E,OAAO,sCAAsC;AAC/C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/polyfill/eventBus.ts
|
|
4
|
+
var eventBus_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
$emit: () => $emit,
|
|
6
|
+
$off: () => $off,
|
|
7
|
+
$on: () => $on,
|
|
8
|
+
$once: () => $once
|
|
9
|
+
});
|
|
10
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
11
|
+
function $on(eventName, handler) {
|
|
12
|
+
if (typeof eventName !== "string" || typeof handler !== "function") return;
|
|
13
|
+
const eventListeners = listeners.get(eventName) ?? /* @__PURE__ */ new Set();
|
|
14
|
+
eventListeners.add({
|
|
15
|
+
handler,
|
|
16
|
+
original: handler
|
|
17
|
+
});
|
|
18
|
+
listeners.set(eventName, eventListeners);
|
|
19
|
+
}
|
|
20
|
+
function $off(eventName, handler) {
|
|
21
|
+
if (eventName === void 0) {
|
|
22
|
+
listeners.clear();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (typeof eventName !== "string") return;
|
|
26
|
+
if (typeof handler !== "function") {
|
|
27
|
+
listeners.delete(eventName);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const eventListeners = listeners.get(eventName);
|
|
31
|
+
if (!eventListeners) return;
|
|
32
|
+
for (const record of eventListeners) if (record.original === handler || record.handler === handler) eventListeners.delete(record);
|
|
33
|
+
if (eventListeners.size === 0) listeners.delete(eventName);
|
|
34
|
+
}
|
|
35
|
+
function $once(eventName, handler) {
|
|
36
|
+
if (typeof eventName !== "string" || typeof handler !== "function") return;
|
|
37
|
+
const onceHandler = (...args) => {
|
|
38
|
+
$off(eventName, handler);
|
|
39
|
+
handler(...args);
|
|
40
|
+
};
|
|
41
|
+
const eventListeners = listeners.get(eventName) ?? /* @__PURE__ */ new Set();
|
|
42
|
+
eventListeners.add({
|
|
43
|
+
handler: onceHandler,
|
|
44
|
+
original: handler
|
|
45
|
+
});
|
|
46
|
+
listeners.set(eventName, eventListeners);
|
|
47
|
+
}
|
|
48
|
+
function $emit(eventName, ...args) {
|
|
49
|
+
const eventListeners = listeners.get(eventName);
|
|
50
|
+
if (!eventListeners) return;
|
|
51
|
+
for (const { handler } of [...eventListeners]) handler(...args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { $emit, $off, $on, $once, eventBus_exports };
|
|
56
|
+
//# sourceMappingURL=eventBus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventBus.mjs","names":[],"sources":["../../../src/runtime/polyfill/eventBus.ts"],"sourcesContent":["export type UniEventHandler = (...args: any[]) => void\n\ninterface EventListenerRecord {\n handler: UniEventHandler\n original: UniEventHandler\n}\n\nconst listeners = new Map<string, Set<EventListenerRecord>>()\n\nexport function $on(eventName: string, handler: UniEventHandler): void {\n if (typeof eventName !== 'string' || typeof handler !== 'function') {\n return\n }\n const eventListeners = listeners.get(eventName) ?? new Set<EventListenerRecord>()\n eventListeners.add({ handler, original: handler })\n listeners.set(eventName, eventListeners)\n}\n\nexport function $off(eventName?: string, handler?: UniEventHandler): void {\n if (eventName === undefined) {\n listeners.clear()\n return\n }\n if (typeof eventName !== 'string') {\n return\n }\n if (typeof handler !== 'function') {\n listeners.delete(eventName)\n return\n }\n const eventListeners = listeners.get(eventName)\n if (!eventListeners) {\n return\n }\n for (const record of eventListeners) {\n if (record.original === handler || record.handler === handler) {\n eventListeners.delete(record)\n }\n }\n if (eventListeners.size === 0) {\n listeners.delete(eventName)\n }\n}\n\nexport function $once(eventName: string, handler: UniEventHandler): void {\n if (typeof eventName !== 'string' || typeof handler !== 'function') {\n return\n }\n const onceHandler: UniEventHandler = (...args) => {\n $off(eventName, handler)\n handler(...args)\n }\n const eventListeners = listeners.get(eventName) ?? new Set<EventListenerRecord>()\n eventListeners.add({ handler: onceHandler, original: handler })\n listeners.set(eventName, eventListeners)\n}\n\nexport function $emit(eventName: string, ...args: any[]): void {\n const eventListeners = listeners.get(eventName)\n if (!eventListeners) {\n return\n }\n for (const { handler } of [...eventListeners]) {\n handler(...args)\n }\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,4BAAY,IAAI,IAAsC;AAE5D,SAAgB,IAAI,WAAmB,SAAgC;CACrE,IAAI,OAAO,cAAc,YAAY,OAAO,YAAY,YACtD;CAEF,MAAM,iBAAiB,UAAU,IAAI,SAAS,qBAAK,IAAI,IAAyB;CAChF,eAAe,IAAI;EAAE;EAAS,UAAU;CAAQ,CAAC;CACjD,UAAU,IAAI,WAAW,cAAc;AACzC;AAEA,SAAgB,KAAK,WAAoB,SAAiC;CACxE,IAAI,cAAc,QAAW;EAC3B,UAAU,MAAM;EAChB;CACF;CACA,IAAI,OAAO,cAAc,UACvB;CAEF,IAAI,OAAO,YAAY,YAAY;EACjC,UAAU,OAAO,SAAS;EAC1B;CACF;CACA,MAAM,iBAAiB,UAAU,IAAI,SAAS;CAC9C,IAAI,CAAC,gBACH;CAEF,KAAK,MAAM,UAAU,gBACnB,IAAI,OAAO,aAAa,WAAW,OAAO,YAAY,SACpD,eAAe,OAAO,MAAM;CAGhC,IAAI,eAAe,SAAS,GAC1B,UAAU,OAAO,SAAS;AAE9B;AAEA,SAAgB,MAAM,WAAmB,SAAgC;CACvE,IAAI,OAAO,cAAc,YAAY,OAAO,YAAY,YACtD;CAEF,MAAM,eAAgC,GAAG,SAAS;EAChD,KAAK,WAAW,OAAO;EACvB,QAAQ,GAAG,IAAI;CACjB;CACA,MAAM,iBAAiB,UAAU,IAAI,SAAS,qBAAK,IAAI,IAAyB;CAChF,eAAe,IAAI;EAAE,SAAS;EAAa,UAAU;CAAQ,CAAC;CAC9D,UAAU,IAAI,WAAW,cAAc;AACzC;AAEA,SAAgB,MAAM,WAAmB,GAAG,MAAmB;CAC7D,MAAM,iBAAiB,UAAU,IAAI,SAAS;CAC9C,IAAI,CAAC,gBACH;CAEF,KAAK,MAAM,EAAE,aAAa,CAAC,GAAG,cAAc,GAC1C,QAAQ,GAAG,IAAI;AAEnB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { normalizeFilePath, readFileSyncInternal, writeFileSyncInternal } from "./files.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/polyfill/fileSystemManager.ts
|
|
4
|
+
function stringifyFileSystemError(error) {
|
|
5
|
+
return error instanceof Error ? error.message : String(error);
|
|
6
|
+
}
|
|
4
7
|
function createFileSystemManagerBridge(callMiniProgramAsyncSuccess, callMiniProgramAsyncFailure) {
|
|
5
8
|
return {
|
|
6
9
|
writeFile(options) {
|
|
@@ -13,7 +16,7 @@ function createFileSystemManagerBridge(callMiniProgramAsyncSuccess, callMiniProg
|
|
|
13
16
|
writeFileSyncInternal(filePath, options?.data ?? "");
|
|
14
17
|
callMiniProgramAsyncSuccess(options, { errMsg: "writeFile:ok" });
|
|
15
18
|
} catch (error) {
|
|
16
|
-
callMiniProgramAsyncFailure(options, `writeFile:fail ${
|
|
19
|
+
callMiniProgramAsyncFailure(options, `writeFile:fail ${stringifyFileSystemError(error)}`);
|
|
17
20
|
}
|
|
18
21
|
},
|
|
19
22
|
readFile(options) {
|
|
@@ -28,7 +31,7 @@ function createFileSystemManagerBridge(callMiniProgramAsyncSuccess, callMiniProg
|
|
|
28
31
|
data: readFileSyncInternal(filePath, options?.encoding)
|
|
29
32
|
});
|
|
30
33
|
} catch (error) {
|
|
31
|
-
callMiniProgramAsyncFailure(options, `readFile:fail ${
|
|
34
|
+
callMiniProgramAsyncFailure(options, `readFile:fail ${stringifyFileSystemError(error)}`);
|
|
32
35
|
}
|
|
33
36
|
},
|
|
34
37
|
writeFileSync(filePath, data, _encoding) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemManager.mjs","names":[],"sources":["../../../src/runtime/polyfill/fileSystemManager.ts"],"sourcesContent":["import {\n normalizeFilePath,\n readFileSyncInternal,\n writeFileSyncInternal,\n} from './files'\n\ntype AsyncSuccess = (options: unknown, result: { errMsg: string, [key: string]: unknown }) => unknown\ntype AsyncFailure = (options: unknown, errMsg: string) => unknown\n\ninterface FileWriteOptionsLike {\n filePath?: string\n data?: unknown\n}\n\ninterface FileReadOptionsLike {\n filePath?: string\n encoding?: string\n}\n\nexport function createFileSystemManagerBridge(\n callMiniProgramAsyncSuccess: AsyncSuccess,\n callMiniProgramAsyncFailure: AsyncFailure,\n) {\n return {\n writeFile(options?: FileWriteOptionsLike) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n callMiniProgramAsyncFailure(options, 'writeFile:fail invalid filePath')\n return\n }\n try {\n writeFileSyncInternal(filePath, (options?.data ?? '') as string | ArrayBuffer | ArrayBufferView)\n callMiniProgramAsyncSuccess(options, { errMsg: 'writeFile:ok' })\n }\n catch (error) {\n const message =
|
|
1
|
+
{"version":3,"file":"fileSystemManager.mjs","names":[],"sources":["../../../src/runtime/polyfill/fileSystemManager.ts"],"sourcesContent":["import {\n normalizeFilePath,\n readFileSyncInternal,\n writeFileSyncInternal,\n} from './files'\n\ntype AsyncSuccess = (options: unknown, result: { errMsg: string, [key: string]: unknown }) => unknown\ntype AsyncFailure = (options: unknown, errMsg: string) => unknown\n\ninterface FileWriteOptionsLike {\n filePath?: string\n data?: unknown\n}\n\ninterface FileReadOptionsLike {\n filePath?: string\n encoding?: string\n}\n\nfunction stringifyFileSystemError(error: unknown) {\n return error instanceof Error ? error.message : String(error)\n}\n\nexport function createFileSystemManagerBridge(\n callMiniProgramAsyncSuccess: AsyncSuccess,\n callMiniProgramAsyncFailure: AsyncFailure,\n) {\n return {\n writeFile(options?: FileWriteOptionsLike) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n callMiniProgramAsyncFailure(options, 'writeFile:fail invalid filePath')\n return\n }\n try {\n writeFileSyncInternal(filePath, (options?.data ?? '') as string | ArrayBuffer | ArrayBufferView)\n callMiniProgramAsyncSuccess(options, { errMsg: 'writeFile:ok' })\n }\n catch (error) {\n const message = stringifyFileSystemError(error)\n callMiniProgramAsyncFailure(options, `writeFile:fail ${message}`)\n }\n },\n readFile(options?: FileReadOptionsLike) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n callMiniProgramAsyncFailure(options, 'readFile:fail invalid filePath')\n return\n }\n try {\n const data = readFileSyncInternal(filePath, options?.encoding)\n callMiniProgramAsyncSuccess(options, { errMsg: 'readFile:ok', data })\n }\n catch (error) {\n const message = stringifyFileSystemError(error)\n callMiniProgramAsyncFailure(options, `readFile:fail ${message}`)\n }\n },\n writeFileSync(filePath: string, data: string | ArrayBuffer | ArrayBufferView, _encoding?: string) {\n writeFileSyncInternal(filePath, data)\n },\n readFileSync(filePath: string, encoding?: string) {\n return readFileSyncInternal(filePath, encoding)\n },\n }\n}\n"],"mappings":";;;AAmBA,SAAS,yBAAyB,OAAgB;CAChD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAgB,8BACd,6BACA,6BACA;CACA,OAAO;EACL,UAAU,SAAgC;GACxC,MAAM,WAAW,kBAAkB,SAAS,QAAQ;GACpD,IAAI,CAAC,UAAU;IACb,4BAA4B,SAAS,iCAAiC;IACtE;GACF;GACA,IAAI;IACF,sBAAsB,UAAW,SAAS,QAAQ,EAA6C;IAC/F,4BAA4B,SAAS,EAAE,QAAQ,eAAe,CAAC;GACjE,SACO,OAAO;IAEZ,4BAA4B,SAAS,kBADrB,yBAAyB,KACoB,GAAG;GAClE;EACF;EACA,SAAS,SAA+B;GACtC,MAAM,WAAW,kBAAkB,SAAS,QAAQ;GACpD,IAAI,CAAC,UAAU;IACb,4BAA4B,SAAS,gCAAgC;IACrE;GACF;GACA,IAAI;IAEF,4BAA4B,SAAS;KAAE,QAAQ;KAAe,MADjD,qBAAqB,UAAU,SAAS,QACY;IAAE,CAAC;GACtE,SACO,OAAO;IAEZ,4BAA4B,SAAS,iBADrB,yBAAyB,KACmB,GAAG;GACjE;EACF;EACA,cAAc,UAAkB,MAA8C,WAAoB;GAChG,sBAAsB,UAAU,IAAI;EACtC;EACA,aAAa,UAAkB,UAAmB;GAChD,OAAO,qBAAqB,UAAU,QAAQ;EAChD;CACF;AACF"}
|
|
@@ -19,7 +19,7 @@ function toArrayBuffer(data) {
|
|
|
19
19
|
}
|
|
20
20
|
function decodeArrayBufferToText(buffer, encoding) {
|
|
21
21
|
if (typeof TextDecoder === "function") try {
|
|
22
|
-
return new TextDecoder(encoding
|
|
22
|
+
return new TextDecoder(encoding).decode(new Uint8Array(buffer));
|
|
23
23
|
} catch {
|
|
24
24
|
return new TextDecoder().decode(new Uint8Array(buffer));
|
|
25
25
|
}
|
|
@@ -46,20 +46,20 @@ function readFileSyncInternal(filePath, encoding) {
|
|
|
46
46
|
const record = memoryFileStorage.get(normalizedPath);
|
|
47
47
|
if (!record) throw new TypeError(`readFileSync:fail no such file ${normalizedPath}`);
|
|
48
48
|
const normalizedEncoding = normalizeFileEncoding(encoding);
|
|
49
|
-
if (record.kind === "text") return record.text
|
|
50
|
-
const bytes =
|
|
49
|
+
if (record.kind === "text") return record.text;
|
|
50
|
+
const bytes = cloneArrayBuffer(record.bytes);
|
|
51
51
|
if (normalizedEncoding) return decodeArrayBufferToText(bytes, normalizedEncoding);
|
|
52
52
|
return bytes;
|
|
53
53
|
}
|
|
54
54
|
function resolveUploadFileName(filePath) {
|
|
55
|
-
const segments =
|
|
55
|
+
const segments = filePath.split(/[?#]/)[0].split("/");
|
|
56
56
|
return segments[segments.length - 1] || "file";
|
|
57
57
|
}
|
|
58
58
|
async function resolveUploadFileBlob(filePath, runtimeFetch) {
|
|
59
59
|
const record = memoryFileStorage.get(filePath);
|
|
60
60
|
if (record) {
|
|
61
|
-
if (record.kind === "text") return new Blob([record.text
|
|
62
|
-
return new Blob([record.bytes
|
|
61
|
+
if (record.kind === "text") return new Blob([record.text], { type: "text/plain;charset=utf-8" });
|
|
62
|
+
return new Blob([record.bytes]);
|
|
63
63
|
}
|
|
64
64
|
if (/^(?:https?:|blob:|data:)/i.test(filePath) && runtimeFetch) try {
|
|
65
65
|
return await (await runtimeFetch(filePath, { method: "GET" })).blob();
|
|
@@ -69,11 +69,11 @@ async function resolveUploadFileBlob(filePath, runtimeFetch) {
|
|
|
69
69
|
function cloneMemoryFileRecord(record) {
|
|
70
70
|
if (record.kind === "text") return {
|
|
71
71
|
kind: "text",
|
|
72
|
-
text: record.text
|
|
72
|
+
text: record.text
|
|
73
73
|
};
|
|
74
74
|
return {
|
|
75
75
|
kind: "binary",
|
|
76
|
-
bytes:
|
|
76
|
+
bytes: cloneArrayBuffer(record.bytes)
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
function resolveSaveFilePath(tempFilePath, customPath) {
|
|
@@ -97,11 +97,11 @@ function resolveOpenDocumentUrl(filePath) {
|
|
|
97
97
|
const runtimeUrl = globalThis.URL;
|
|
98
98
|
if (record) {
|
|
99
99
|
if (record.kind === "text") {
|
|
100
|
-
const text = record.text
|
|
100
|
+
const text = record.text;
|
|
101
101
|
if (typeof Blob === "function" && runtimeUrl?.createObjectURL) return runtimeUrl.createObjectURL(new Blob([text], { type: "text/plain;charset=utf-8" }));
|
|
102
102
|
return `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`;
|
|
103
103
|
}
|
|
104
|
-
const bytes = record.bytes
|
|
104
|
+
const bytes = record.bytes;
|
|
105
105
|
if (typeof Blob === "function" && runtimeUrl?.createObjectURL) return runtimeUrl.createObjectURL(new Blob([bytes]));
|
|
106
106
|
return "";
|
|
107
107
|
}
|
|
@@ -1 +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\
|
|
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\ntype MemoryFileRecord = {\n kind: 'text'\n text: string\n} | {\n kind: 'binary'\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).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 = cloneArrayBuffer(record.bytes)\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])\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: cloneArrayBuffer(record.bytes),\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\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;AAUlC,MAAM,oCAAoB,IAAI,IAA8B;AAE5D,SAAgB,kBAAkB,UAAmB;CACnD,IAAI,OAAO,aAAa,UACtB,OAAO;CAET,OAAO,SAAS,KAAK;AACvB;AAEA,SAAS,sBAAsB,UAAmB;CAChD,IAAI,OAAO,aAAa,UACtB,OAAO;CAET,OAAO,SAAS,KAAK,CAAC,CAAC,YAAY;AACrC;AAEA,SAAS,iBAAiB,QAAqB;CAC7C,OAAO,OAAO,MAAM,CAAC;AACvB;AAEA,SAAS,cAAc,MAAqC;CAC1D,IAAI,gBAAgB,aAClB,OAAO,iBAAiB,IAAI;CAE9B,MAAM,OAAO;CACb,OAAO,I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GACpB,IAAI,OAAO,SAAS,cAAc,YAAY,iBAC5C,OAAO,WAAW,gBAAgB,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC,CAAC;GAE1F,OAAO,iCAAiC,mBAAmB,IAAI;EACjE;EACA,MAAM,QAAQ,OAAO;EACrB,IAAI,OAAO,SAAS,cAAc,YAAY,iBAC5C,OAAO,WAAW,gBAAgB,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;EAErD,OAAO;CACT;CAEA,IAAI,4BAA4B,KAAK,QAAQ,GAC3C,OAAO;CAET,IAAI;EACF,MAAM,kBAAmB,OAAO,aAAa,cAAc,WAAW;EACtE,IAAI,iBAAiB,MACnB,OAAO,IAAI,IAAI,UAAU,gBAAgB,IAAI,CAAC,CAAC,SAAS;CAE5D,QACM,CAEN;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/polyfill/font.ts
|
|
4
|
+
function installFallbackFontFace(options) {
|
|
5
|
+
if (typeof document === "undefined") throw new Error("document is unavailable");
|
|
6
|
+
const style = document.createElement("style");
|
|
7
|
+
style.dataset.weappFontFamily = options.family;
|
|
8
|
+
style.textContent = `@font-face{font-family:${JSON.stringify(options.family)};src:${options.source};}`;
|
|
9
|
+
document.head.append(style);
|
|
10
|
+
}
|
|
11
|
+
async function loadFontFace(options) {
|
|
12
|
+
const family = options?.family?.trim();
|
|
13
|
+
const source = options?.source?.trim();
|
|
14
|
+
if (!family || !source) return callMiniProgramAsyncFailure(options, "loadFontFace:fail invalid options");
|
|
15
|
+
try {
|
|
16
|
+
if (typeof FontFace === "function" && typeof document !== "undefined" && document.fonts && typeof document.fonts.add === "function") {
|
|
17
|
+
const fontFace = new FontFace(family, source, options.descriptors);
|
|
18
|
+
document.fonts.add(await fontFace.load());
|
|
19
|
+
} else installFallbackFontFace({
|
|
20
|
+
...options,
|
|
21
|
+
family,
|
|
22
|
+
source
|
|
23
|
+
});
|
|
24
|
+
return callMiniProgramAsyncSuccess(options, { errMsg: "loadFontFace:ok" });
|
|
25
|
+
} catch (error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
return callMiniProgramAsyncFailure(options, `loadFontFace:fail ${message}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { loadFontFace };
|
|
33
|
+
//# sourceMappingURL=font.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.mjs","names":[],"sources":["../../../src/runtime/polyfill/font.ts"],"sourcesContent":["import type { LoadFontFaceOptions } from './types'\nimport { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from './async'\n\nfunction installFallbackFontFace(options: LoadFontFaceOptions) {\n if (typeof document === 'undefined') {\n throw new Error('document is unavailable')\n }\n const style = document.createElement('style')\n style.dataset.weappFontFamily = options.family\n style.textContent = `@font-face{font-family:${JSON.stringify(options.family)};src:${options.source};}`\n document.head.append(style)\n}\n\nexport async function loadFontFace(options: LoadFontFaceOptions) {\n const family = options?.family?.trim()\n const source = options?.source?.trim()\n if (!family || !source) {\n return callMiniProgramAsyncFailure(options, 'loadFontFace:fail invalid options')\n }\n\n try {\n if (\n typeof FontFace === 'function'\n && typeof document !== 'undefined'\n && document.fonts\n && typeof document.fonts.add === 'function'\n ) {\n const fontFace = new FontFace(family, source, options.descriptors)\n document.fonts.add(await fontFace.load())\n }\n else {\n installFallbackFontFace({ ...options, family, source })\n }\n return callMiniProgramAsyncSuccess(options, { errMsg: 'loadFontFace:ok' })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return callMiniProgramAsyncFailure(options, `loadFontFace:fail ${message}`)\n }\n}\n"],"mappings":";;;AAGA,SAAS,wBAAwB,SAA8B;CAC7D,IAAI,OAAO,aAAa,aACtB,MAAM,IAAI,MAAM,yBAAyB;CAE3C,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,QAAQ,kBAAkB,QAAQ;CACxC,MAAM,cAAc,0BAA0B,KAAK,UAAU,QAAQ,MAAM,EAAE,OAAO,QAAQ,OAAO;CACnG,SAAS,KAAK,OAAO,KAAK;AAC5B;AAEA,eAAsB,aAAa,SAA8B;CAC/D,MAAM,SAAS,SAAS,QAAQ,KAAK;CACrC,MAAM,SAAS,SAAS,QAAQ,KAAK;CACrC,IAAI,CAAC,UAAU,CAAC,QACd,OAAO,4BAA4B,SAAS,mCAAmC;CAGjF,IAAI;EACF,IACE,OAAO,aAAa,cACjB,OAAO,aAAa,eACpB,SAAS,SACT,OAAO,SAAS,MAAM,QAAQ,YACjC;GACA,MAAM,WAAW,IAAI,SAAS,QAAQ,QAAQ,QAAQ,WAAW;GACjE,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC;EAC1C,OAEE,wBAAwB;GAAE,GAAG;GAAS;GAAQ;EAAO,CAAC;EAExD,OAAO,4BAA4B,SAAS,EAAE,QAAQ,kBAAkB,CAAC;CAC3E,SACO,OAAO;EACZ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,OAAO,4BAA4B,SAAS,qBAAqB,SAAS;CAC5E;AACF"}
|
|
@@ -3,7 +3,7 @@ import { AdBaseOptions, GetExtConfigOptions, InterstitialAd, RewardedVideoAd } f
|
|
|
3
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
4
|
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
|
|
5
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";
|
|
6
|
+
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./uiMediaApi.mjs";
|
|
7
7
|
//#region src/runtime/polyfill/index.d.ts
|
|
8
8
|
declare function setNavigationBarTitle(options: {
|
|
9
9
|
title: string;
|
|
@@ -35,5 +35,5 @@ declare function getUpdateManager(): UpdateManager;
|
|
|
35
35
|
declare function getLogManager(options?: LogManagerOptions): LogManager;
|
|
36
36
|
declare function reportAnalytics(eventName: string, data?: Record<string, unknown>): void;
|
|
37
37
|
//#endregion
|
|
38
|
-
export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
|
|
38
|
+
export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
|
|
39
39
|
//# sourceMappingURL=index.d.mts.map
|