@weapp-vite/web 1.3.36 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +13 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +6 -1
- 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 +29 -6
- package/dist/index.mjs +197 -4
- package/dist/index.mjs.map +1 -0
- 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 +56 -7
- 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 +245 -74
- 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 +4 -1
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +48 -36
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +206 -94
- 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 +46 -1
- package/dist/plugin/vueSfc.mjs +149 -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 +35 -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/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 +32 -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 +3 -2
- 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 +7 -4
- 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 +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/menuApi.mjs +38 -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 +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/system.mjs +30 -3
- package/dist/runtime/polyfill/system.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 +13 -5
|
@@ -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,eAAe,SAAgE;CACnG,OAAO,qBAAqB,OAAO;AACrC;AAEA,SAAgB,YAAY,SAA8B;CACxD,OAAO,kBAAkB,OAAO;AAClC;AAEA,eAAsB,iBAAiB,SAAmC;CACxE,OAAO,uBAAuB,OAAO;AACvC;AAEA,SAAgB,WAAW,SAA6B;CACtD,OAAO,iBAAiB,SAAS,iBAAiB;AACpD;AAEA,SAAgB,UAAU,SAA4B;CACpD,OAAO,gBAAgB,SAAS,mBAAmB,yBAAyB;AAC9E;AAEA,SAAgB,YAAY,SAA8B;CACxD,OAAO,kBAAkB,SAAS,mBAAmB,yBAAyB;AAChF;AAEA,SAAgB,yBAA8C;CAC5D,OAAO,6BAA6B,iBAAiB;AACvD;AAEA,SAAgB,wBAAwB,SAA0C;CAChF,OAAO,8BACL,SACA,mBACA,yBACA,sBACF;AACF;AAEA,SAAgB,eAAe,SAAiC;CAC9D,OAAO,qBAAqB,OAAO;AACrC;AAEA,SAAgB,sBAAsB,UAAuC;CAC3E,OAAO,4BAA4B,QAAQ;AAC7C;AAEA,SAAgB,uBAAuB,UAAwC;CAC7E,OAAO,6BAA6B,QAAQ;AAC9C;AAEA,SAAgB,gBAA4B;CAC1C,OAAO,oBAAoB;AAC7B;AAEA,SAAgB,OAAO,OAAe;CACpC,OAAOA,SAAa,KAAK;AAC3B;AAEA,MAAa,SAAS;AAEtB,SAAgB,eAAe,UAAgC;CAC7D,OAAO,qBAAqB,UAAU,aAAa;AACrD;AAEA,SAAgB,gBAAgB,UAAiC;CAC/D,OAAO,sBAAsB,QAAQ;AACvC;AAEA,SAAgB,oBAAgC;CAC9C,OAAO,wBAAwB;AACjC;AAEA,SAAgB,cAAc,SAAgC;CAC5D,OAAO,oBAAoB,OAAO;AACpC;AAEA,SAAgB,gBAA4B;CAC1C,OAAO,oBAAoB;AAC7B;AAEA,SAAgB,mBAAkC;CAChD,OAAO,uBAAuB,mBAAmB,wBAAwB;AAC3E;AAEA,SAAgB,MAAM,SAAwB;CAC5C,OAAO,YAAY,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,IAAI,WAAW,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/E;AAEA,SAAS,wBAAwB,QAAqB,UAAkB;CACtE,IAAI,OAAO,gBAAgB,YACzB,IAAI;EACF,OAAO,IAAI,YAAY,QAAQ,CAAC,CAAC,OAAO,IAAI,WAAW,MAAM,CAAC;CAChE,QACM;EACJ,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,WAAW,MAAM,CAAC;CACxD;CAEF,OAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,CAAC,CACtC,KAAI,SAAQ,OAAO,aAAa,IAAI,CAAC,CAAC,CACtC,KAAK,EAAE;AACZ;AAEA,SAAgB,sBACd,UACA,MACA;CACA,MAAM,iBAAiB,kBAAkB,QAAQ;CACjD,IAAI,CAAC,gBACH,MAAM,IAAI,UAAU,qCAAqC;CAE3D,IAAI,OAAO,SAAS,UAAU;EAC5B,kBAAkB,IAAI,gBAAgB;GACpC,MAAM;GACN,MAAM;EACR,CAAC;EACD;CACF;CACA,kBAAkB,IAAI,gBAAgB;EACpC,MAAM;EACN,OAAO,cAAc,IAAI;CAC3B,CAAC;AACH;AAEA,SAAgB,qBAAqB,UAAkB,UAAmB;CACxE,MAAM,iBAAiB,kBAAkB,QAAQ;CACjD,IAAI,CAAC,gBACH,MAAM,IAAI,UAAU,oCAAoC;CAE1D,MAAM,SAAS,kBAAkB,IAAI,cAAc;CACnD,IAAI,CAAC,QACH,MAAM,IAAI,UAAU,kCAAkC,gBAAgB;CAExE,MAAM,qBAAqB,sBAAsB,QAAQ;CACzD,IAAI,OAAO,SAAS,QAClB,OAAO,OAAO;CAEhB,MAAM,QAAQ,iBAAiB,OAAO,KAAK;CAC3C,IAAI,oBACF,OAAO,wBAAwB,OAAO,kBAAkB;CAE1D,OAAO;AACT;AAEA,SAAgB,sBAAsB,UAAkB;CAEtD,MAAM,WADa,SAAS,MAAM,MAAM,CAAC,CAAC,EACf,CAAC,MAAM,GAAG;CACrC,OAAO,SAAS,SAAS,SAAS,MAAM;AAC1C;AAEA,eAAsB,sBACpB,UACA,cACA;CACA,MAAM,SAAS,kBAAkB,IAAI,QAAQ;CAC7C,IAAI,QAAQ;EACV,IAAI,OAAO,SAAS,QAClB,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC;EAErE,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC;CAChC;CACA,IAAI,4BAA4B,KAAK,QAAQ,KAAK,cAChD,IAAI;EAEF,OAAO,OAAM,MADU,aAAa,UAAU,EAAE,QAAQ,MAAM,CAAC,EAC1C,CAAC,KAAK;CAC7B,QACM,CAEN;CAEF,OAAO,IAAI,KAAK,CAAC,QAAQ,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAClE;AAEA,SAAS,sBAAsB,QAA4C;CACzE,IAAI,OAAO,SAAS,QAClB,OAAO;EACL,MAAM;EACN,MAAM,OAAO;CACf;CAEF,OAAO;EACL,MAAM;EACN,OAAO,iBAAiB,OAAO,KAAK;CACtC;AACF;AAEA,SAAgB,oBAAoB,cAAsB,YAAqB;CAC7E,MAAM,aAAa,OAAO,eAAe,WAAW,WAAW,KAAK,IAAI;CACxE,IAAI,YACF,OAAO;CAET,OAAO,GAAG,mBAAmB,GAAG,sBAAsB,YAAY;AACpE;AAEA,SAAgB,eAAe,cAAsB,eAAuB;CAC1E,MAAM,eAAe,kBAAkB,IAAI,YAAY;CACvD,IAAI,cAAc;EAChB,kBAAkB,IAAI,eAAe,sBAAsB,YAAY,CAAC;EACxE;CACF;CACA,kBAAkB,IAAI,eAAe;EACnC,MAAM;EACN,MAAM;CACR,CAAC;AACH;AAEA,SAAgB,uBAAuB,UAAkB;CACvD,MAAM,SAAS,kBAAkB,IAAI,QAAQ;CAC7C,MAAM,aAAc,WAIjB;CAEH,IAAI,QAAQ;EACV,IAAI,OAAO,SAAS,QAAQ;GAC1B,MAAM,OAAO,OAAO;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,32 @@
|
|
|
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
|
+
return callMiniProgramAsyncFailure(options, `loadFontFace:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { loadFontFace };
|
|
32
|
+
//# 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;EAEZ,OAAO,4BAA4B,SAAS,qBAD5B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACK;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
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { emitRuntimeWarning } from "../warning.mjs";
|
|
2
2
|
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
3
|
+
import { getAppInstance, getCurrentPagesInternal, getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
|
|
4
|
+
import { WEB_USER_DATA_PATH } from "./files.mjs";
|
|
5
|
+
import { clearStorage, clearStorageSync, createCanvasContext, createIntersectionObserver, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, runtimeDataApi_exports, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtimeDataApi.mjs";
|
|
6
|
+
import { createAnimation } from "./animation.mjs";
|
|
3
7
|
import { setBackgroundColorBridge, setBackgroundTextStyleBridge } from "./background.mjs";
|
|
4
8
|
import { createCloudBridge } from "./cloud.mjs";
|
|
5
|
-
import { WEB_USER_DATA_PATH } from "./files.mjs";
|
|
6
9
|
import { canIUseBridge } from "./runtimeCapabilityApi.mjs";
|
|
7
|
-
import { authorize, checkSession, deviceAuthSystemApi_exports, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./deviceAuthSystemApi.mjs";
|
|
10
|
+
import { authorize, checkSession, deviceAuthSystemApi_exports, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, rpx2px, upx2px, vibrateShort } from "./deviceAuthSystemApi.mjs";
|
|
11
|
+
import { $emit, $off, $on, $once, eventBus_exports } from "./eventBus.mjs";
|
|
12
|
+
import { loadFontFace } from "./font.mjs";
|
|
13
|
+
import { getLocale } from "./locale.mjs";
|
|
8
14
|
import { createNavigationBarRuntimeBridge } from "./navigationBarRuntime.mjs";
|
|
9
15
|
import { createInterstitialAdBridge, createRewardedVideoAdBridge, getExtConfigBridge, getExtConfigSyncBridge, getLogManagerBridge, getUpdateManagerBridge, reportAnalyticsBridge } from "./platformApi.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, runtimeDataApi_exports, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtimeDataApi.mjs";
|
|
12
|
-
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, uiMediaApi_exports, updateShareMenu } from "./uiMediaApi.mjs";
|
|
16
|
+
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, uiMediaApi_exports, updateShareMenu } from "./uiMediaApi.mjs";
|
|
13
17
|
import { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from "@weapp-core/shared";
|
|
14
18
|
|
|
15
19
|
//#region src/runtime/polyfill/index.ts
|
|
16
20
|
const MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys();
|
|
17
21
|
const DEFAULT_MINI_PROGRAM_GLOBAL_KEY = getDefaultMiniProgramRuntimeGlobalKey();
|
|
18
|
-
const globalTarget =
|
|
22
|
+
const globalTarget = globalThis;
|
|
19
23
|
function resolveMiniProgramBridge() {
|
|
20
24
|
for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {
|
|
21
25
|
const candidate = globalTarget[runtimeGlobalKey];
|
|
22
26
|
if (candidate && typeof candidate === "object") return candidate;
|
|
23
27
|
}
|
|
24
|
-
const fallback = globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY];
|
|
25
|
-
if (fallback && typeof fallback === "object") return fallback;
|
|
26
28
|
}
|
|
27
29
|
const navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(() => getCurrentPagesInternal(), emitRuntimeWarning);
|
|
28
30
|
function setNavigationBarTitle(options) {
|
|
@@ -68,43 +70,45 @@ function getLogManager(options) {
|
|
|
68
70
|
function reportAnalytics(eventName, data) {
|
|
69
71
|
reportAnalyticsBridge(eventName, data);
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
73
|
+
const miniProgramBridge = globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY] ?? {};
|
|
74
|
+
Object.assign(miniProgramBridge, {
|
|
75
|
+
navigateTo,
|
|
76
|
+
navigateBack,
|
|
77
|
+
redirectTo,
|
|
78
|
+
switchTab,
|
|
79
|
+
reLaunch,
|
|
80
|
+
getLaunchOptionsSync,
|
|
81
|
+
getEnterOptionsSync,
|
|
82
|
+
...runtimeDataApi_exports,
|
|
83
|
+
setNavigationBarTitle,
|
|
84
|
+
setNavigationBarColor,
|
|
85
|
+
setBackgroundColor,
|
|
86
|
+
setBackgroundTextStyle,
|
|
87
|
+
showNavigationBarLoading,
|
|
88
|
+
hideNavigationBarLoading,
|
|
89
|
+
...uiMediaApi_exports,
|
|
90
|
+
...deviceAuthSystemApi_exports,
|
|
91
|
+
...eventBus_exports,
|
|
92
|
+
loadFontFace,
|
|
93
|
+
getLocale,
|
|
94
|
+
createAnimation,
|
|
95
|
+
createRewardedVideoAd,
|
|
96
|
+
createInterstitialAd,
|
|
97
|
+
getExtConfigSync,
|
|
98
|
+
getExtConfig,
|
|
99
|
+
getUpdateManager,
|
|
100
|
+
getLogManager,
|
|
101
|
+
reportAnalytics,
|
|
102
|
+
canIUse,
|
|
103
|
+
cloud: cloudBridge
|
|
104
|
+
});
|
|
105
|
+
const miniProgramEnv = miniProgramBridge.env ?? {};
|
|
106
|
+
if (typeof miniProgramEnv.USER_DATA_PATH !== "string" || !miniProgramEnv.USER_DATA_PATH.trim()) miniProgramEnv.USER_DATA_PATH = WEB_USER_DATA_PATH;
|
|
107
|
+
miniProgramBridge.env = miniProgramEnv;
|
|
108
|
+
for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) globalTarget[runtimeGlobalKey] = miniProgramBridge;
|
|
109
|
+
if (typeof globalTarget.getApp !== "function") globalTarget.getApp = getAppInstance;
|
|
110
|
+
if (typeof globalTarget.getCurrentPages !== "function") globalTarget.getCurrentPages = getCurrentPagesInternal;
|
|
107
111
|
|
|
108
112
|
//#endregion
|
|
109
|
-
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 };
|
|
113
|
+
export { $emit, $off, $on, $once, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createIntersectionObserver, 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, rpx2px, 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, upx2px, vibrateShort };
|
|
110
114
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["runtimeDataApi","uiMediaApi","deviceAuthSystemApi"],"sources":["../../../src/runtime/polyfill/index.ts"],"sourcesContent":["import type {\n AdBaseOptions,\n CloudBridge,\n GetExtConfigOptions,\n InterstitialAd,\n LogManager,\n LogManagerOptions,\n MiniProgramAsyncOptions,\n MiniProgramBaseResult,\n RewardedVideoAd,\n SetBackgroundColorOptions,\n SetBackgroundTextStyleOptions,\n UpdateManager,\n} from './types'\nimport { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from '@weapp-core/shared'\nimport { emitRuntimeWarning } from '../warning'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n setBackgroundColorBridge,\n setBackgroundTextStyleBridge,\n} from './background'\nimport { createCloudBridge } from './cloud'\nimport * as deviceAuthSystemApi from './deviceAuthSystemApi'\nimport { WEB_USER_DATA_PATH } from './files'\nimport { createNavigationBarRuntimeBridge } from './navigationBarRuntime'\nimport {\n createInterstitialAdBridge,\n createRewardedVideoAdBridge,\n getExtConfigBridge,\n getExtConfigSyncBridge,\n getLogManagerBridge,\n getUpdateManagerBridge,\n reportAnalyticsBridge,\n} from './platformApi'\nimport {\n getAppInstance,\n getCurrentPagesInternal,\n getEnterOptionsSync,\n getLaunchOptionsSync,\n navigateBack,\n navigateTo,\n redirectTo,\n reLaunch,\n switchTab,\n} from './routeRuntime'\nimport {\n canIUseBridge,\n} from './runtimeCapabilityApi'\nimport * as runtimeDataApi from './runtimeDataApi'\nimport * as uiMediaApi from './uiMediaApi'\n\nexport * from './deviceAuthSystemApi'\n\nexport {\n getEnterOptionsSync,\n getLaunchOptionsSync,\n initializePageRoutes,\n navigateBack,\n navigateTo,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n switchTab,\n} from './routeRuntime'\n\nexport * from './runtimeDataApi'\nexport * from './uiMediaApi'\n\nconst MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys()\nconst DEFAULT_MINI_PROGRAM_GLOBAL_KEY = getDefaultMiniProgramRuntimeGlobalKey()\nconst globalTarget =
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["runtimeDataApi","uiMediaApi","deviceAuthSystemApi","eventBusApi"],"sources":["../../../src/runtime/polyfill/index.ts"],"sourcesContent":["import type {\n AdBaseOptions,\n CloudBridge,\n GetExtConfigOptions,\n InterstitialAd,\n LogManager,\n LogManagerOptions,\n MiniProgramAsyncOptions,\n MiniProgramBaseResult,\n RewardedVideoAd,\n SetBackgroundColorOptions,\n SetBackgroundTextStyleOptions,\n UpdateManager,\n} from './types'\nimport { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from '@weapp-core/shared'\nimport { emitRuntimeWarning } from '../warning'\nimport { createAnimation } from './animation'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n setBackgroundColorBridge,\n setBackgroundTextStyleBridge,\n} from './background'\nimport { createCloudBridge } from './cloud'\nimport * as deviceAuthSystemApi from './deviceAuthSystemApi'\nimport * as eventBusApi from './eventBus'\nimport { WEB_USER_DATA_PATH } from './files'\nimport { loadFontFace } from './font'\nimport { getLocale } from './locale'\nimport { createNavigationBarRuntimeBridge } from './navigationBarRuntime'\nimport {\n createInterstitialAdBridge,\n createRewardedVideoAdBridge,\n getExtConfigBridge,\n getExtConfigSyncBridge,\n getLogManagerBridge,\n getUpdateManagerBridge,\n reportAnalyticsBridge,\n} from './platformApi'\nimport {\n getAppInstance,\n getCurrentPagesInternal,\n getEnterOptionsSync,\n getLaunchOptionsSync,\n navigateBack,\n navigateTo,\n redirectTo,\n reLaunch,\n switchTab,\n} from './routeRuntime'\nimport {\n canIUseBridge,\n} from './runtimeCapabilityApi'\nimport * as runtimeDataApi from './runtimeDataApi'\nimport * as uiMediaApi from './uiMediaApi'\n\nexport { createAnimation } from './animation'\nexport * from './deviceAuthSystemApi'\nexport * from './eventBus'\nexport { loadFontFace } from './font'\nexport { getLocale } from './locale'\n\nexport {\n getEnterOptionsSync,\n getLaunchOptionsSync,\n initializePageRoutes,\n navigateBack,\n navigateTo,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n switchTab,\n} from './routeRuntime'\n\nexport * from './runtimeDataApi'\nexport * from './uiMediaApi'\n\nconst MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys()\nconst DEFAULT_MINI_PROGRAM_GLOBAL_KEY = getDefaultMiniProgramRuntimeGlobalKey()\nconst globalTarget = globalThis as Record<string, unknown>\n\nfunction resolveMiniProgramBridge() {\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n const candidate = globalTarget[runtimeGlobalKey]\n if (candidate && typeof candidate === 'object') {\n return candidate as Record<string, unknown>\n }\n }\n return undefined\n}\n\nconst navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(\n () => getCurrentPagesInternal() as Array<HTMLElement & { renderRoot?: ShadowRoot | HTMLElement }>,\n emitRuntimeWarning,\n)\n\nexport function setNavigationBarTitle(options: { title: string }) {\n return navigationBarRuntimeBridge.setNavigationBarTitle(options)\n}\n\nexport function setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n}) {\n return navigationBarRuntimeBridge.setNavigationBarColor(options)\n}\n\nexport function showNavigationBarLoading() {\n return navigationBarRuntimeBridge.showNavigationBarLoading()\n}\n\nexport function hideNavigationBarLoading() {\n return navigationBarRuntimeBridge.hideNavigationBarLoading()\n}\n\nexport function setBackgroundColor(options?: SetBackgroundColorOptions) {\n return setBackgroundColorBridge(options)\n}\n\nexport function setBackgroundTextStyle(options?: SetBackgroundTextStyleOptions) {\n return setBackgroundTextStyleBridge(options)\n}\n\nexport function canIUse(schema: string) {\n return canIUseBridge(resolveMiniProgramBridge(), schema)\n}\n\nconst cloudBridge: CloudBridge = createCloudBridge(\n (options, result) => callMiniProgramAsyncSuccess(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n result as MiniProgramBaseResult,\n ),\n (options, errMsg) => callMiniProgramAsyncFailure(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n errMsg,\n ),\n) as CloudBridge\n\nexport function createRewardedVideoAd(options?: AdBaseOptions): RewardedVideoAd {\n return createRewardedVideoAdBridge(options)\n}\n\nexport function createInterstitialAd(options?: AdBaseOptions): InterstitialAd {\n return createInterstitialAdBridge(options)\n}\n\nexport function getExtConfigSync() {\n return getExtConfigSyncBridge()\n}\n\nexport function getExtConfig(options?: GetExtConfigOptions) {\n return getExtConfigBridge(options)\n}\n\nexport function getUpdateManager(): UpdateManager {\n return getUpdateManagerBridge()\n}\n\nexport function getLogManager(options?: LogManagerOptions): LogManager {\n return getLogManagerBridge(options)\n}\n\nexport function reportAnalytics(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsBridge(eventName, data)\n}\n\nconst miniProgramBridge = (globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY] as Record<string, unknown> | undefined) ?? {}\nObject.assign(miniProgramBridge, {\n navigateTo,\n navigateBack,\n redirectTo,\n switchTab,\n reLaunch,\n getLaunchOptionsSync,\n getEnterOptionsSync,\n ...runtimeDataApi,\n setNavigationBarTitle,\n setNavigationBarColor,\n setBackgroundColor,\n setBackgroundTextStyle,\n showNavigationBarLoading,\n hideNavigationBarLoading,\n ...uiMediaApi,\n ...deviceAuthSystemApi,\n ...eventBusApi,\n loadFontFace,\n getLocale,\n createAnimation,\n createRewardedVideoAd,\n createInterstitialAd,\n getExtConfigSync,\n getExtConfig,\n getUpdateManager,\n getLogManager,\n reportAnalytics,\n canIUse,\n cloud: cloudBridge,\n})\nconst miniProgramEnv = (miniProgramBridge.env as Record<string, unknown> | undefined) ?? {}\nif (typeof miniProgramEnv.USER_DATA_PATH !== 'string' || !miniProgramEnv.USER_DATA_PATH.trim()) {\n miniProgramEnv.USER_DATA_PATH = WEB_USER_DATA_PATH\n}\nminiProgramBridge.env = miniProgramEnv\nfor (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n globalTarget[runtimeGlobalKey] = miniProgramBridge\n}\nif (typeof globalTarget.getApp !== 'function') {\n globalTarget.getApp = getAppInstance\n}\nif (typeof globalTarget.getCurrentPages !== 'function') {\n globalTarget.getCurrentPages = getCurrentPagesInternal\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiFA,MAAM,2BAA2B,gCAAgC;AACjE,MAAM,kCAAkC,sCAAsC;AAC9E,MAAM,eAAe;AAErB,SAAS,2BAA2B;CAClC,KAAK,MAAM,oBAAoB,0BAA0B;EACvD,MAAM,YAAY,aAAa;EAC/B,IAAI,aAAa,OAAO,cAAc,UACpC,OAAO;CAEX;AAEF;AAEA,MAAM,6BAA6B,uCAC3B,wBAAwB,GAC9B,kBACF;AAEA,SAAgB,sBAAsB,SAA4B;CAChE,OAAO,2BAA2B,sBAAsB,OAAO;AACjE;AAEA,SAAgB,sBAAsB,SAInC;CACD,OAAO,2BAA2B,sBAAsB,OAAO;AACjE;AAEA,SAAgB,2BAA2B;CACzC,OAAO,2BAA2B,yBAAyB;AAC7D;AAEA,SAAgB,2BAA2B;CACzC,OAAO,2BAA2B,yBAAyB;AAC7D;AAEA,SAAgB,mBAAmB,SAAqC;CACtE,OAAO,yBAAyB,OAAO;AACzC;AAEA,SAAgB,uBAAuB,SAAyC;CAC9E,OAAO,6BAA6B,OAAO;AAC7C;AAEA,SAAgB,QAAQ,QAAgB;CACtC,OAAO,cAAc,yBAAyB,GAAG,MAAM;AACzD;AAEA,MAAM,cAA2B,mBAC9B,SAAS,WAAW,4BACnB,SACA,MACF,IACC,SAAS,WAAW,4BACnB,SACA,MACF,CACF;AAEA,SAAgB,sBAAsB,SAA0C;CAC9E,OAAO,4BAA4B,OAAO;AAC5C;AAEA,SAAgB,qBAAqB,SAAyC;CAC5E,OAAO,2BAA2B,OAAO;AAC3C;AAEA,SAAgB,mBAAmB;CACjC,OAAO,uBAAuB;AAChC;AAEA,SAAgB,aAAa,SAA+B;CAC1D,OAAO,mBAAmB,OAAO;AACnC;AAEA,SAAgB,mBAAkC;CAChD,OAAO,uBAAuB;AAChC;AAEA,SAAgB,cAAc,SAAyC;CACrE,OAAO,oBAAoB,OAAO;AACpC;AAEA,SAAgB,gBAAgB,WAAmB,MAAgC;CACjF,sBAAsB,WAAW,IAAI;AACvC;AAEA,MAAM,oBAAqB,aAAa,oCAA4E,CAAC;AACrH,OAAO,OAAO,mBAAmB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAGA;CACH;CACA;CACA;CACA;CACA;CACA;CACA,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,OAAO;AACT,CAAC;AACD,MAAM,iBAAkB,kBAAkB,OAA+C,CAAC;AAC1F,IAAI,OAAO,eAAe,mBAAmB,YAAY,CAAC,eAAe,eAAe,KAAK,GAC3F,eAAe,iBAAiB;AAElC,kBAAkB,MAAM;AACxB,KAAK,MAAM,oBAAoB,0BAC7B,aAAa,oBAAoB;AAEnC,IAAI,OAAO,aAAa,WAAW,YACjC,aAAa,SAAS;AAExB,IAAI,OAAO,aAAa,oBAAoB,YAC1C,aAAa,kBAAkB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getRuntimeClipboard } from "../host/index.mjs";
|
|
1
2
|
import { WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY } from "@weapp-core/constants";
|
|
2
3
|
|
|
3
4
|
//#region src/runtime/polyfill/interaction.ts
|
|
@@ -9,9 +10,9 @@ function resolveScanCodeResult(prompt) {
|
|
|
9
10
|
return String(rawResult?.result ?? "");
|
|
10
11
|
}
|
|
11
12
|
async function writeClipboardData(data) {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
await
|
|
13
|
+
const clipboard = getRuntimeClipboard();
|
|
14
|
+
if (clipboard && typeof clipboard.writeText === "function") {
|
|
15
|
+
await clipboard.writeText(data);
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
if (typeof document === "undefined" || !document.body) throw new Error("Clipboard API is unavailable in current environment.");
|
|
@@ -28,9 +29,9 @@ async function writeClipboardData(data) {
|
|
|
28
29
|
if (!copied) throw new Error("document.execCommand(\"copy\") returned false.");
|
|
29
30
|
}
|
|
30
31
|
async function readClipboardData() {
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
return
|
|
32
|
+
const clipboard = getRuntimeClipboard();
|
|
33
|
+
if (!clipboard || typeof clipboard.readText !== "function") throw new Error("Clipboard API is unavailable in current environment.");
|
|
34
|
+
return clipboard.readText();
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.mjs","names":["runtimeGlobal"],"sources":["../../../src/runtime/polyfill/interaction.ts"],"sourcesContent":["import { WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY } from '@weapp-core/constants'\n\nexport function resolveScanCodeResult(prompt?: (message: string, defaultValue: string) => unknown) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n let rawResult: unknown = runtimeGlobal[WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY]\n if (rawResult == null && typeof prompt === 'function') {\n rawResult = prompt('请输入二维码/条码内容', '')\n }\n if (rawResult == null) {\n return null\n }\n if (typeof rawResult === 'string') {\n return rawResult\n }\n return String((rawResult as { result?: unknown })?.result ?? '')\n}\n\nexport async function writeClipboardData(data: string) {\n const
|
|
1
|
+
{"version":3,"file":"interaction.mjs","names":["runtimeGlobal"],"sources":["../../../src/runtime/polyfill/interaction.ts"],"sourcesContent":["import { WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY } from '@weapp-core/constants'\nimport { getRuntimeClipboard } from '../host'\n\nexport function resolveScanCodeResult(prompt?: (message: string, defaultValue: string) => unknown) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n let rawResult: unknown = runtimeGlobal[WEAPP_VITE_WEB_SCAN_CODE_RESULT_KEY]\n if (rawResult == null && typeof prompt === 'function') {\n rawResult = prompt('请输入二维码/条码内容', '')\n }\n if (rawResult == null) {\n return null\n }\n if (typeof rawResult === 'string') {\n return rawResult\n }\n return String((rawResult as { result?: unknown })?.result ?? '')\n}\n\nexport async function writeClipboardData(data: string) {\n const clipboard = getRuntimeClipboard()\n if (clipboard && typeof clipboard.writeText === 'function') {\n await clipboard.writeText(data)\n return\n }\n\n if (typeof document === 'undefined' || !document.body) {\n throw new Error('Clipboard API is unavailable in current environment.')\n }\n\n const execCommand = (document as Document & { execCommand?: (command: string) => boolean }).execCommand\n if (typeof execCommand !== 'function') {\n throw new TypeError('Clipboard API is unavailable in current environment.')\n }\n\n const textarea = document.createElement('textarea') as HTMLTextAreaElement\n textarea.value = data\n textarea.setAttribute('readonly', 'true')\n textarea.setAttribute('style', 'position: fixed; top: -9999px; left: -9999px; opacity: 0;')\n document.body.append(textarea)\n textarea.select?.()\n const copied = execCommand.call(document, 'copy')\n if (textarea.parentNode) {\n textarea.parentNode.removeChild(textarea)\n }\n if (!copied) {\n throw new Error('document.execCommand(\"copy\") returned false.')\n }\n}\n\nexport async function readClipboardData() {\n const clipboard = getRuntimeClipboard()\n if (!clipboard || typeof clipboard.readText !== 'function') {\n throw new Error('Clipboard API is unavailable in current environment.')\n }\n return clipboard.readText()\n}\n"],"mappings":";;;;AAGA,SAAgB,sBAAsB,QAA6D;CAEjG,IAAI,YAAqBA,WAAc;CACvC,IAAI,aAAa,QAAQ,OAAO,WAAW,YACzC,YAAY,OAAO,eAAe,EAAE;CAEtC,IAAI,aAAa,MACf,OAAO;CAET,IAAI,OAAO,cAAc,UACvB,OAAO;CAET,OAAO,OAAQ,WAAoC,UAAU,EAAE;AACjE;AAEA,eAAsB,mBAAmB,MAAc;CACrD,MAAM,YAAY,oBAAoB;CACtC,IAAI,aAAa,OAAO,UAAU,cAAc,YAAY;EAC1D,MAAM,UAAU,UAAU,IAAI;EAC9B;CACF;CAEA,IAAI,OAAO,aAAa,eAAe,CAAC,SAAS,MAC/C,MAAM,IAAI,MAAM,sDAAsD;CAGxE,MAAM,cAAe,SAAuE;CAC5F,IAAI,OAAO,gBAAgB,YACzB,MAAM,IAAI,UAAU,sDAAsD;CAG5E,MAAM,WAAW,SAAS,cAAc,UAAU;CAClD,SAAS,QAAQ;CACjB,SAAS,aAAa,YAAY,MAAM;CACxC,SAAS,aAAa,SAAS,2DAA2D;CAC1F,SAAS,KAAK,OAAO,QAAQ;CAC7B,SAAS,SAAS;CAClB,MAAM,SAAS,YAAY,KAAK,UAAU,MAAM;CAChD,IAAI,SAAS,YACX,SAAS,WAAW,YAAY,QAAQ;CAE1C,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,gDAA8C;AAElE;AAEA,eAAsB,oBAAoB;CACxC,MAAM,YAAY,oBAAoB;CACtC,IAAI,CAAC,aAAa,OAAO,UAAU,aAAa,YAC9C,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO,UAAU,SAAS;AAC5B"}
|