@weapp-vite/web 1.3.16 → 1.3.18
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 +2 -2
- package/dist/compiler/wxml/attributes.mjs +6 -6
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/renderer.mjs +6 -6
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +6 -5
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -1
- package/dist/plugin/files.mjs.map +1 -1
- package/dist/runtime/component/constants.mjs +7 -2
- package/dist/runtime/component/constants.mjs.map +1 -1
- package/dist/runtime/component/dom.mjs +9 -3
- package/dist/runtime/component/dom.mjs.map +1 -1
- package/dist/runtime/component/events.mjs +5 -4
- package/dist/runtime/component/events.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/dom.mjs +10 -65
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/index.mjs +7 -6
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/polyfill/async.mjs +3 -3
- package/dist/runtime/polyfill/async.mjs.map +1 -1
- package/dist/runtime/polyfill/authApi.mjs +16 -16
- package/dist/runtime/polyfill/authApi.mjs.map +1 -1
- package/dist/runtime/polyfill/background.mjs +4 -4
- package/dist/runtime/polyfill/background.mjs.map +1 -1
- package/dist/runtime/polyfill/capability.mjs +6 -3
- package/dist/runtime/polyfill/capability.mjs.map +1 -1
- package/dist/runtime/polyfill/cloud.mjs +3 -3
- package/dist/runtime/polyfill/cloud.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceApi.mjs +5 -5
- package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +2 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/fileSystemManager.mjs +7 -7
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
- package/dist/runtime/polyfill/index.mjs +21 -10
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interactionApi.mjs +8 -8
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
- package/dist/runtime/polyfill/locationApi.mjs +21 -21
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/file.mjs +12 -12
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/info.mjs +7 -7
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/picker.mjs +11 -11
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/preview.mjs +7 -7
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/process.mjs +6 -6
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +13 -13
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +5 -4
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/network/requestBridge.mjs +7 -7
- package/dist/runtime/polyfill/network/requestBridge.mjs.map +1 -1
- package/dist/runtime/polyfill/platformApi.mjs +2 -2
- package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +2 -2
- package/dist/runtime/polyfill/runtimeCapabilityApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeDataApi.d.mts +7 -7
- package/dist/runtime/polyfill/runtimeDataApi.mjs +5 -5
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeOps.mjs +10 -10
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
- package/dist/runtime/polyfill/storageAsync.mjs +12 -12
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
- package/dist/runtime/polyfill/systemApi.mjs +3 -3
- package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/types/base.d.mts +5 -5
- package/dist/runtime/polyfill/types/common.d.mts +22 -22
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +27 -27
- package/dist/runtime/polyfill/types/mediaAuth.d.mts +30 -30
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +13 -13
- package/dist/runtime/polyfill/types/systemAuth.d.mts +11 -11
- package/dist/runtime/polyfill/uiFeedback.mjs +4 -4
- package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +2 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/shared/wxml.mjs +29 -10
- package/dist/shared/wxml.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -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
|
|
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 = typeof globalThis !== 'undefined' ? (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 const fallback = globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY]\n if (fallback && typeof fallback === 'object') {\n return fallback as Record<string, unknown>\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\nif (globalTarget) {\n const miniProgramBridge = (globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY] as Record<string, unknown> | undefined) ?? {}\n Object.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 createRewardedVideoAd,\n createInterstitialAd,\n getExtConfigSync,\n getExtConfig,\n getUpdateManager,\n getLogManager,\n reportAnalytics,\n canIUse,\n cloud: cloudBridge,\n })\n const miniProgramEnv = (miniProgramBridge.env as Record<string, unknown> | undefined) ?? {}\n if (typeof miniProgramEnv.USER_DATA_PATH !== 'string' || !miniProgramEnv.USER_DATA_PATH.trim()) {\n miniProgramEnv.USER_DATA_PATH = WEB_USER_DATA_PATH\n }\n miniProgramBridge.env = miniProgramEnv\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n globalTarget[runtimeGlobalKey] = miniProgramBridge\n }\n if (typeof globalTarget.getApp !== 'function') {\n globalTarget.getApp = getAppInstance\n }\n if (typeof globalTarget.getCurrentPages !== 'function') {\n globalTarget.getCurrentPages = getCurrentPagesInternal\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyEA,MAAM,2BAA2B,iCAAiC;AAClE,MAAM,kCAAkC,uCAAuC;AAC/E,MAAM,eAAe,OAAO,eAAe,cAAe,aAAyC,EAAE;AAErG,SAAS,2BAA2B;AAClC,MAAK,MAAM,oBAAoB,0BAA0B;EACvD,MAAM,YAAY,aAAa;AAC/B,MAAI,aAAa,OAAO,cAAc,SACpC,QAAO;;CAGX,MAAM,WA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EACA;EACA,OAAO;EACR,CAAC;CACF,MAAM,iBAAkB,kBAAkB,OAA+C,EAAE;AAC3F,KAAI,OAAO,eAAe,mBAAmB,YAAY,CAAC,eAAe,eAAe,MAAM,CAC5F,gBAAe,iBAAiB;AAElC,mBAAkB,MAAM;AACxB,MAAK,MAAM,oBAAoB,yBAC7B,cAAa,oBAAoB;AAEnC,KAAI,OAAO,aAAa,WAAW,WACjC,cAAa,SAAS;AAExB,KAAI,OAAO,aAAa,oBAAoB,WAC1C,cAAa,kBAAkB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
2
2
|
import { getGlobalDialogHandlers } from "./ui.mjs";
|
|
3
3
|
import { readClipboardData, resolveScanCodeResult, writeClipboardData } from "./interaction.mjs";
|
|
4
4
|
|
|
@@ -8,16 +8,16 @@ function openCustomerServiceChatBridge(options) {
|
|
|
8
8
|
if (url && typeof window !== "undefined" && typeof window.open === "function") try {
|
|
9
9
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
10
10
|
} catch {}
|
|
11
|
-
return Promise.resolve(
|
|
11
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "openCustomerServiceChat:ok" }));
|
|
12
12
|
}
|
|
13
13
|
function scanCodeBridge(options) {
|
|
14
14
|
const { prompt } = getGlobalDialogHandlers();
|
|
15
15
|
const resultText = resolveScanCodeResult(prompt);
|
|
16
16
|
if (resultText == null) {
|
|
17
|
-
const failure =
|
|
17
|
+
const failure = callMiniProgramAsyncFailure(options, "scanCode:fail cancel");
|
|
18
18
|
return Promise.reject(failure);
|
|
19
19
|
}
|
|
20
|
-
const result =
|
|
20
|
+
const result = callMiniProgramAsyncSuccess(options, {
|
|
21
21
|
errMsg: "scanCode:ok",
|
|
22
22
|
result: resultText,
|
|
23
23
|
scanType: "QR_CODE",
|
|
@@ -32,19 +32,19 @@ async function setClipboardDataBridge(options) {
|
|
|
32
32
|
try {
|
|
33
33
|
await writeClipboardData(data);
|
|
34
34
|
} catch (error) {
|
|
35
|
-
const failure =
|
|
35
|
+
const failure = callMiniProgramAsyncFailure(options, `setClipboardData:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
36
36
|
return Promise.reject(failure);
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return callMiniProgramAsyncSuccess(options, { errMsg: "setClipboardData:ok" });
|
|
39
39
|
}
|
|
40
40
|
async function getClipboardDataBridge(options) {
|
|
41
41
|
try {
|
|
42
|
-
return
|
|
42
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
43
43
|
errMsg: "getClipboardData:ok",
|
|
44
44
|
data: await readClipboardData()
|
|
45
45
|
});
|
|
46
46
|
} catch (error) {
|
|
47
|
-
const failure =
|
|
47
|
+
const failure = callMiniProgramAsyncFailure(options, `getClipboardData:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
48
48
|
return Promise.reject(failure);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/interactionApi.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"interactionApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/interactionApi.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n readClipboardData,\n resolveScanCodeResult,\n writeClipboardData,\n} from './interaction'\nimport { getGlobalDialogHandlers } from './ui'\n\nexport function openCustomerServiceChatBridge(options?: any) {\n const url = options?.url?.trim() ?? ''\n if (url && typeof window !== 'undefined' && typeof window.open === 'function') {\n try {\n window.open(url, '_blank', 'noopener,noreferrer')\n }\n catch {\n // ignore browser popup restrictions\n }\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'openCustomerServiceChat:ok' }))\n}\n\nexport function scanCodeBridge(options?: any) {\n const { prompt } = getGlobalDialogHandlers()\n const resultText = resolveScanCodeResult(prompt)\n if (resultText == null) {\n const failure = callMiniProgramAsyncFailure(options, 'scanCode:fail cancel')\n return Promise.reject(failure)\n }\n const result = callMiniProgramAsyncSuccess(options, {\n errMsg: 'scanCode:ok',\n result: resultText,\n scanType: 'QR_CODE',\n charSet: 'utf-8',\n path: resultText,\n rawData: resultText,\n })\n return Promise.resolve(result)\n}\n\nexport async function setClipboardDataBridge(options?: any) {\n const data = String(options?.data ?? '')\n try {\n await writeClipboardData(data)\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `setClipboardData:fail ${message}`)\n return Promise.reject(failure)\n }\n return callMiniProgramAsyncSuccess(options, { errMsg: 'setClipboardData:ok' })\n}\n\nexport async function getClipboardDataBridge(options?: any) {\n try {\n const data = await readClipboardData()\n return callMiniProgramAsyncSuccess(options, { errMsg: 'getClipboardData:ok', data })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getClipboardData:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;AAWA,SAAgB,8BAA8B,SAAe;CAC3D,MAAM,MAAM,SAAS,KAAK,MAAM,IAAI;AACpC,KAAI,OAAO,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,WACjE,KAAI;AACF,SAAO,KAAK,KAAK,UAAU,sBAAsB;SAE7C;AAIR,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,8BAA8B,CAAC,CAAC;;AAGxG,SAAgB,eAAe,SAAe;CAC5C,MAAM,EAAE,WAAW,yBAAyB;CAC5C,MAAM,aAAa,sBAAsB,OAAO;AAChD,KAAI,cAAc,MAAM;EACtB,MAAM,UAAU,4BAA4B,SAAS,uBAAuB;AAC5E,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,SAAS,4BAA4B,SAAS;EAClD,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,SAAS;EACT,MAAM;EACN,SAAS;EACV,CAAC;AACF,QAAO,QAAQ,QAAQ,OAAO;;AAGhC,eAAsB,uBAAuB,SAAe;CAC1D,MAAM,OAAO,OAAO,SAAS,QAAQ,GAAG;AACxC,KAAI;AACF,QAAM,mBAAmB,KAAK;UAEzB,OAAO;EAEZ,MAAM,UAAU,4BAA4B,SAAS,yBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACkB;AACxF,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,QAAO,4BAA4B,SAAS,EAAE,QAAQ,uBAAuB,CAAC;;AAGhF,eAAsB,uBAAuB,SAAe;AAC1D,KAAI;AAEF,SAAO,4BAA4B,SAAS;GAAE,QAAQ;GAAuB,MADhE,MAAM,mBAAmB;GAC6C,CAAC;UAE/E,OAAO;EAEZ,MAAM,UAAU,4BAA4B,SAAS,yBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACkB;AACxF,SAAO,QAAQ,OAAO,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
2
2
|
import { normalizeFuzzyCoordinate, normalizeGeoNumber, parseChooseAddressPromptInput, parseChooseLocationPromptInput, readCurrentLocation, readPresetChooseAddress, readPresetChooseLocation, readPresetFuzzyLocation } from "./location.mjs";
|
|
3
3
|
import { openTargetInNewWindow } from "./mediaActions.mjs";
|
|
4
4
|
import { getGlobalDialogHandlers } from "./ui.mjs";
|
|
@@ -7,17 +7,17 @@ import { getGlobalDialogHandlers } from "./ui.mjs";
|
|
|
7
7
|
function makePhoneCallBridge(options) {
|
|
8
8
|
const phoneNumber = typeof options?.phoneNumber === "string" ? options.phoneNumber.trim() : "";
|
|
9
9
|
if (!phoneNumber) {
|
|
10
|
-
const failure =
|
|
10
|
+
const failure = callMiniProgramAsyncFailure(options, "makePhoneCall:fail invalid phoneNumber");
|
|
11
11
|
return Promise.reject(failure);
|
|
12
12
|
}
|
|
13
13
|
if (typeof window !== "undefined" && typeof window.open === "function") try {
|
|
14
14
|
window.open(`tel:${encodeURIComponent(phoneNumber)}`, "_self");
|
|
15
15
|
} catch {}
|
|
16
|
-
return Promise.resolve(
|
|
16
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "makePhoneCall:ok" }));
|
|
17
17
|
}
|
|
18
18
|
function chooseAddressBridge(options) {
|
|
19
19
|
const preset = readPresetChooseAddress();
|
|
20
|
-
if (preset) return Promise.resolve(
|
|
20
|
+
if (preset) return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
21
21
|
errMsg: "chooseAddress:ok",
|
|
22
22
|
...preset
|
|
23
23
|
}));
|
|
@@ -25,25 +25,25 @@ function chooseAddressBridge(options) {
|
|
|
25
25
|
if (typeof prompt === "function") {
|
|
26
26
|
const input = prompt("请输入地址(格式:省,市,区,详细地址,姓名,电话)", "");
|
|
27
27
|
if (input == null) {
|
|
28
|
-
const failure =
|
|
28
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseAddress:fail cancel");
|
|
29
29
|
return Promise.reject(failure);
|
|
30
30
|
}
|
|
31
31
|
const parsed = parseChooseAddressPromptInput(input);
|
|
32
32
|
if (!parsed) {
|
|
33
|
-
const failure =
|
|
33
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseAddress:fail invalid input");
|
|
34
34
|
return Promise.reject(failure);
|
|
35
35
|
}
|
|
36
|
-
return Promise.resolve(
|
|
36
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
37
37
|
errMsg: "chooseAddress:ok",
|
|
38
38
|
...parsed
|
|
39
39
|
}));
|
|
40
40
|
}
|
|
41
|
-
const failure =
|
|
41
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseAddress:fail address picker is unavailable");
|
|
42
42
|
return Promise.reject(failure);
|
|
43
43
|
}
|
|
44
44
|
function chooseLocationBridge(options) {
|
|
45
45
|
const preset = readPresetChooseLocation();
|
|
46
|
-
if (preset) return Promise.resolve(
|
|
46
|
+
if (preset) return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
47
47
|
errMsg: "chooseLocation:ok",
|
|
48
48
|
...preset
|
|
49
49
|
}));
|
|
@@ -51,15 +51,15 @@ function chooseLocationBridge(options) {
|
|
|
51
51
|
if (typeof prompt === "function") {
|
|
52
52
|
const input = prompt("请输入坐标(格式:latitude,longitude)", "");
|
|
53
53
|
if (input == null) {
|
|
54
|
-
const failure =
|
|
54
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseLocation:fail cancel");
|
|
55
55
|
return Promise.reject(failure);
|
|
56
56
|
}
|
|
57
57
|
const parsed = parseChooseLocationPromptInput(input);
|
|
58
58
|
if (!parsed) {
|
|
59
|
-
const failure =
|
|
59
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseLocation:fail invalid latitude/longitude");
|
|
60
60
|
return Promise.reject(failure);
|
|
61
61
|
}
|
|
62
|
-
return Promise.resolve(
|
|
62
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
63
63
|
errMsg: "chooseLocation:ok",
|
|
64
64
|
name: "",
|
|
65
65
|
address: "",
|
|
@@ -67,50 +67,50 @@ function chooseLocationBridge(options) {
|
|
|
67
67
|
longitude: parsed.longitude
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
-
const failure =
|
|
70
|
+
const failure = callMiniProgramAsyncFailure(options, "chooseLocation:fail location picker is unavailable");
|
|
71
71
|
return Promise.reject(failure);
|
|
72
72
|
}
|
|
73
73
|
function openLocationBridge(options) {
|
|
74
74
|
const latitude = options?.latitude;
|
|
75
75
|
const longitude = options?.longitude;
|
|
76
76
|
if (typeof latitude !== "number" || Number.isNaN(latitude) || typeof longitude !== "number" || Number.isNaN(longitude)) {
|
|
77
|
-
const failure =
|
|
77
|
+
const failure = callMiniProgramAsyncFailure(options, "openLocation:fail invalid latitude/longitude");
|
|
78
78
|
return Promise.reject(failure);
|
|
79
79
|
}
|
|
80
80
|
const query = `${latitude},${longitude}`;
|
|
81
81
|
openTargetInNewWindow(`https://maps.google.com/?q=${encodeURIComponent(query)}`);
|
|
82
|
-
return Promise.resolve(
|
|
82
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "openLocation:ok" }));
|
|
83
83
|
}
|
|
84
84
|
function getLocationBridge(options) {
|
|
85
85
|
try {
|
|
86
|
-
return readCurrentLocation(options).then((location) =>
|
|
86
|
+
return readCurrentLocation(options).then((location) => callMiniProgramAsyncSuccess(options, {
|
|
87
87
|
errMsg: "getLocation:ok",
|
|
88
88
|
...location
|
|
89
89
|
})).catch((error) => {
|
|
90
|
-
const failure =
|
|
90
|
+
const failure = callMiniProgramAsyncFailure(options, `getLocation:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
91
91
|
return Promise.reject(failure);
|
|
92
92
|
});
|
|
93
93
|
} catch (error) {
|
|
94
|
-
const failure =
|
|
94
|
+
const failure = callMiniProgramAsyncFailure(options, `getLocation:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
95
95
|
return Promise.reject(failure);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
async function getFuzzyLocationBridge(options) {
|
|
99
99
|
const preset = readPresetFuzzyLocation();
|
|
100
|
-
if (preset) return
|
|
100
|
+
if (preset) return callMiniProgramAsyncSuccess(options, {
|
|
101
101
|
errMsg: "getFuzzyLocation:ok",
|
|
102
102
|
...preset
|
|
103
103
|
});
|
|
104
104
|
try {
|
|
105
105
|
const location = await getLocationBridge();
|
|
106
|
-
return
|
|
106
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
107
107
|
errMsg: "getFuzzyLocation:ok",
|
|
108
108
|
latitude: normalizeFuzzyCoordinate(location.latitude),
|
|
109
109
|
longitude: normalizeFuzzyCoordinate(location.longitude),
|
|
110
110
|
accuracy: Math.max(1e3, normalizeGeoNumber(location.accuracy, 1e3))
|
|
111
111
|
});
|
|
112
112
|
} catch (error) {
|
|
113
|
-
const failure =
|
|
113
|
+
const failure = callMiniProgramAsyncFailure(options, `getFuzzyLocation:fail ${typeof error?.errMsg === "string" ? error.errMsg : error instanceof Error ? error.message : String(error)}`);
|
|
114
114
|
return Promise.reject(failure);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locationApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/locationApi.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"locationApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/locationApi.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n normalizeFuzzyCoordinate,\n normalizeGeoNumber,\n parseChooseAddressPromptInput,\n parseChooseLocationPromptInput,\n readCurrentLocation,\n readPresetChooseAddress,\n readPresetChooseLocation,\n readPresetFuzzyLocation,\n} from './location'\nimport { openTargetInNewWindow } from './mediaActions'\nimport { getGlobalDialogHandlers } from './ui'\n\nexport function makePhoneCallBridge(options?: any) {\n const phoneNumber = typeof options?.phoneNumber === 'string' ? options.phoneNumber.trim() : ''\n if (!phoneNumber) {\n const failure = callMiniProgramAsyncFailure(options, 'makePhoneCall:fail invalid phoneNumber')\n return Promise.reject(failure)\n }\n if (typeof window !== 'undefined' && typeof window.open === 'function') {\n try {\n window.open(`tel:${encodeURIComponent(phoneNumber)}`, '_self')\n }\n catch {\n // ignore browser restrictions and keep API-level success semantics\n }\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'makePhoneCall:ok' }))\n}\n\nexport function chooseAddressBridge(options?: any) {\n const preset = readPresetChooseAddress()\n if (preset) {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseAddress:ok',\n ...preset,\n }))\n }\n const { prompt } = getGlobalDialogHandlers()\n if (typeof prompt === 'function') {\n const input = prompt('请输入地址(格式:省,市,区,详细地址,姓名,电话)', '')\n if (input == null) {\n const failure = callMiniProgramAsyncFailure(options, 'chooseAddress:fail cancel')\n return Promise.reject(failure)\n }\n const parsed = parseChooseAddressPromptInput(input)\n if (!parsed) {\n const failure = callMiniProgramAsyncFailure(options, 'chooseAddress:fail invalid input')\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseAddress:ok',\n ...parsed,\n }))\n }\n const failure = callMiniProgramAsyncFailure(options, 'chooseAddress:fail address picker is unavailable')\n return Promise.reject(failure)\n}\n\nexport function chooseLocationBridge(options?: any) {\n const preset = readPresetChooseLocation()\n if (preset) {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseLocation:ok',\n ...preset,\n }))\n }\n const { prompt } = getGlobalDialogHandlers()\n if (typeof prompt === 'function') {\n const input = prompt('请输入坐标(格式:latitude,longitude)', '')\n if (input == null) {\n const failure = callMiniProgramAsyncFailure(options, 'chooseLocation:fail cancel')\n return Promise.reject(failure)\n }\n const parsed = parseChooseLocationPromptInput(input)\n if (!parsed) {\n const failure = callMiniProgramAsyncFailure(options, 'chooseLocation:fail invalid latitude/longitude')\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseLocation:ok',\n name: '',\n address: '',\n latitude: parsed.latitude,\n longitude: parsed.longitude,\n }))\n }\n const failure = callMiniProgramAsyncFailure(options, 'chooseLocation:fail location picker is unavailable')\n return Promise.reject(failure)\n}\n\nexport function openLocationBridge(options?: any) {\n const latitude = options?.latitude\n const longitude = options?.longitude\n if (typeof latitude !== 'number' || Number.isNaN(latitude) || typeof longitude !== 'number' || Number.isNaN(longitude)) {\n const failure = callMiniProgramAsyncFailure(options, 'openLocation:fail invalid latitude/longitude')\n return Promise.reject(failure)\n }\n const query = `${latitude},${longitude}`\n const target = `https://maps.google.com/?q=${encodeURIComponent(query)}`\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'openLocation:ok' }))\n}\n\nexport function getLocationBridge(options?: any) {\n try {\n return readCurrentLocation(options)\n .then(location => callMiniProgramAsyncSuccess(options, {\n errMsg: 'getLocation:ok',\n ...location,\n }))\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getLocation:fail ${message}`)\n return Promise.reject(failure)\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getLocation:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function getFuzzyLocationBridge(options?: any) {\n const preset = readPresetFuzzyLocation()\n if (preset) {\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getFuzzyLocation:ok',\n ...preset,\n })\n }\n try {\n const location = await getLocationBridge()\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getFuzzyLocation:ok',\n latitude: normalizeFuzzyCoordinate(location.latitude),\n longitude: normalizeFuzzyCoordinate(location.longitude),\n accuracy: Math.max(1000, normalizeGeoNumber(location.accuracy, 1000)),\n })\n }\n catch (error) {\n const message = typeof (error as { errMsg?: unknown })?.errMsg === 'string'\n ? (error as { errMsg: string }).errMsg\n : error instanceof Error\n ? error.message\n : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getFuzzyLocation:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,oBAAoB,SAAe;CACjD,MAAM,cAAc,OAAO,SAAS,gBAAgB,WAAW,QAAQ,YAAY,MAAM,GAAG;AAC5F,KAAI,CAAC,aAAa;EAChB,MAAM,UAAU,4BAA4B,SAAS,yCAAyC;AAC9F,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,KAAI,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,WAC1D,KAAI;AACF,SAAO,KAAK,OAAO,mBAAmB,YAAY,IAAI,QAAQ;SAE1D;AAIR,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ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UAAU;GACvD,UAAU,KAAK,IAAI,KAAM,mBAAmB,SAAS,UAAU,IAAK,CAAC;GACtE,CAAC;UAEG,OAAO;EAMZ,MAAM,UAAU,4BAA4B,SAAS,yBALrC,OAAQ,OAAgC,WAAW,WAC9D,MAA6B,SAC9B,iBAAiB,QACf,MAAM,UACN,OAAO,MAAM,GACqE;AACxF,SAAO,QAAQ,OAAO,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "../async.mjs";
|
|
2
2
|
import { openTargetInNewWindow, triggerDownload } from "../mediaActions.mjs";
|
|
3
3
|
import { normalizeFilePath, resolveOpenDocumentUrl, resolveSaveFilePath, saveMemoryFile } from "../files.mjs";
|
|
4
4
|
|
|
@@ -6,30 +6,30 @@ import { normalizeFilePath, resolveOpenDocumentUrl, resolveSaveFilePath, saveMem
|
|
|
6
6
|
function saveImageToPhotosAlbumBridge(options) {
|
|
7
7
|
const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
|
|
8
8
|
if (!filePath) {
|
|
9
|
-
const failure =
|
|
9
|
+
const failure = callMiniProgramAsyncFailure(options, "saveImageToPhotosAlbum:fail invalid filePath");
|
|
10
10
|
return Promise.reject(failure);
|
|
11
11
|
}
|
|
12
12
|
triggerDownload(filePath);
|
|
13
|
-
return Promise.resolve(
|
|
13
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "saveImageToPhotosAlbum:ok" }));
|
|
14
14
|
}
|
|
15
15
|
function saveVideoToPhotosAlbumBridge(options) {
|
|
16
16
|
const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
|
|
17
17
|
if (!filePath) {
|
|
18
|
-
const failure =
|
|
18
|
+
const failure = callMiniProgramAsyncFailure(options, "saveVideoToPhotosAlbum:fail invalid filePath");
|
|
19
19
|
return Promise.reject(failure);
|
|
20
20
|
}
|
|
21
21
|
triggerDownload(filePath);
|
|
22
|
-
return Promise.resolve(
|
|
22
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "saveVideoToPhotosAlbum:ok" }));
|
|
23
23
|
}
|
|
24
24
|
function saveFileBridge(options) {
|
|
25
25
|
const tempFilePath = typeof options?.tempFilePath === "string" ? options.tempFilePath.trim() : "";
|
|
26
26
|
if (!tempFilePath) {
|
|
27
|
-
const failure =
|
|
27
|
+
const failure = callMiniProgramAsyncFailure(options, "saveFile:fail invalid tempFilePath");
|
|
28
28
|
return Promise.reject(failure);
|
|
29
29
|
}
|
|
30
30
|
const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath);
|
|
31
31
|
saveMemoryFile(tempFilePath, savedFilePath);
|
|
32
|
-
return Promise.resolve(
|
|
32
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
33
33
|
errMsg: "saveFile:ok",
|
|
34
34
|
savedFilePath
|
|
35
35
|
}));
|
|
@@ -37,25 +37,25 @@ function saveFileBridge(options) {
|
|
|
37
37
|
function saveFileToDiskBridge(options) {
|
|
38
38
|
const filePath = typeof options?.filePath === "string" ? options.filePath.trim() : "";
|
|
39
39
|
if (!filePath) {
|
|
40
|
-
const failure =
|
|
40
|
+
const failure = callMiniProgramAsyncFailure(options, "saveFileToDisk:fail invalid filePath");
|
|
41
41
|
return Promise.reject(failure);
|
|
42
42
|
}
|
|
43
43
|
triggerDownload(filePath, typeof options?.fileName === "string" ? options.fileName.trim() : "");
|
|
44
|
-
return Promise.resolve(
|
|
44
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "saveFileToDisk:ok" }));
|
|
45
45
|
}
|
|
46
46
|
function openDocumentBridge(options) {
|
|
47
47
|
const filePath = normalizeFilePath(options?.filePath);
|
|
48
48
|
if (!filePath) {
|
|
49
|
-
const failure =
|
|
49
|
+
const failure = callMiniProgramAsyncFailure(options, "openDocument:fail invalid filePath");
|
|
50
50
|
return Promise.reject(failure);
|
|
51
51
|
}
|
|
52
52
|
const target = resolveOpenDocumentUrl(filePath);
|
|
53
53
|
if (!target) {
|
|
54
|
-
const failure =
|
|
54
|
+
const failure = callMiniProgramAsyncFailure(options, "openDocument:fail document url is unavailable");
|
|
55
55
|
return Promise.reject(failure);
|
|
56
56
|
}
|
|
57
57
|
openTargetInNewWindow(target);
|
|
58
|
-
return Promise.resolve(
|
|
58
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "openDocument:ok" }));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/file.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"file.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/file.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeFilePath,\n resolveOpenDocumentUrl,\n resolveSaveFilePath,\n saveMemoryFile,\n} from '../files'\nimport {\n openTargetInNewWindow,\n triggerDownload,\n} from '../mediaActions'\n\nexport function saveImageToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveImageToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveImageToPhotosAlbum:ok' }))\n}\n\nexport function saveVideoToPhotosAlbumBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveVideoToPhotosAlbum:fail invalid filePath')\n return Promise.reject(failure)\n }\n triggerDownload(filePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveVideoToPhotosAlbum:ok' }))\n}\n\nexport function saveFileBridge(options?: any) {\n const tempFilePath = typeof options?.tempFilePath === 'string' ? options.tempFilePath.trim() : ''\n if (!tempFilePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFile:fail invalid tempFilePath')\n return Promise.reject(failure)\n }\n const savedFilePath = resolveSaveFilePath(tempFilePath, options?.filePath)\n saveMemoryFile(tempFilePath, savedFilePath)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'saveFile:ok',\n savedFilePath,\n }))\n}\n\nexport function saveFileToDiskBridge(options?: any) {\n const filePath = typeof options?.filePath === 'string' ? options.filePath.trim() : ''\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'saveFileToDisk:fail invalid filePath')\n return Promise.reject(failure)\n }\n const fileName = typeof options?.fileName === 'string' ? options.fileName.trim() : ''\n triggerDownload(filePath, fileName)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'saveFileToDisk:ok' }))\n}\n\nexport function openDocumentBridge(options?: any) {\n const filePath = normalizeFilePath(options?.filePath)\n if (!filePath) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail invalid filePath')\n return Promise.reject(failure)\n }\n const target = resolveOpenDocumentUrl(filePath)\n if (!target) {\n const failure = callMiniProgramAsyncFailure(options, 'openDocument:fail document url is unavailable')\n return Promise.reject(failure)\n }\n openTargetInNewWindow(target)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'openDocument:ok' }))\n}\n"],"mappings":";;;;;AAeA,SAAgB,6BAA6B,SAAe;CAC1D,MAAM,WAAW,OAAO,SAAS,aAAa,WAAW,QAAQ,SAAS,MAAM,GAAG;AACnF,KAAI,CAAC,UAAU;EACb,MAAM,UAAU,4BAA4B,SAAS,+CAA+C;AACpG,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,iBAAgB,SAAS;AACzB,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,6BAA6B,CAAC,CAAC;;AAGvG,SAAgB,6BAA6B,SAAe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G,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,uBAAsB,OAAO;AAC7B,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "../async.mjs";
|
|
2
2
|
import { inferImageTypeFromPath, inferVideoTypeFromPath, normalizeVideoInfoNumber, readImageInfoFromSource, readPresetVideoInfo, readVideoInfoFromSource } from "../mediaInfo.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/polyfill/mediaApi/info.ts
|
|
5
5
|
function getImageInfoBridge(options) {
|
|
6
6
|
const src = typeof options?.src === "string" ? options.src.trim() : "";
|
|
7
7
|
if (!src) {
|
|
8
|
-
const failure =
|
|
8
|
+
const failure = callMiniProgramAsyncFailure(options, "getImageInfo:fail invalid src");
|
|
9
9
|
return Promise.reject(failure);
|
|
10
10
|
}
|
|
11
|
-
return readImageInfoFromSource(src).then(({ width, height }) =>
|
|
11
|
+
return readImageInfoFromSource(src).then(({ width, height }) => callMiniProgramAsyncSuccess(options, {
|
|
12
12
|
errMsg: "getImageInfo:ok",
|
|
13
13
|
width,
|
|
14
14
|
height,
|
|
@@ -16,14 +16,14 @@ function getImageInfoBridge(options) {
|
|
|
16
16
|
type: inferImageTypeFromPath(src),
|
|
17
17
|
orientation: "up"
|
|
18
18
|
})).catch((error) => {
|
|
19
|
-
const failure =
|
|
19
|
+
const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
20
20
|
return Promise.reject(failure);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
function getVideoInfoBridge(options) {
|
|
24
24
|
const src = typeof options?.src === "string" ? options.src.trim() : "";
|
|
25
25
|
if (!src) {
|
|
26
|
-
const failure =
|
|
26
|
+
const failure = callMiniProgramAsyncFailure(options, "getVideoInfo:fail invalid src");
|
|
27
27
|
return Promise.reject(failure);
|
|
28
28
|
}
|
|
29
29
|
const preset = readPresetVideoInfo(src);
|
|
@@ -37,7 +37,7 @@ function getVideoInfoBridge(options) {
|
|
|
37
37
|
const height = normalizeVideoInfoNumber(result.height);
|
|
38
38
|
const bitrate = normalizeVideoInfoNumber(result.bitrate);
|
|
39
39
|
const fps = normalizeVideoInfoNumber(result.fps);
|
|
40
|
-
return
|
|
40
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
41
41
|
errMsg: "getVideoInfo:ok",
|
|
42
42
|
orientation: "up",
|
|
43
43
|
type: inferVideoTypeFromPath(src),
|
|
@@ -49,7 +49,7 @@ function getVideoInfoBridge(options) {
|
|
|
49
49
|
fps
|
|
50
50
|
});
|
|
51
51
|
}).catch((error) => {
|
|
52
|
-
const failure =
|
|
52
|
+
const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
53
53
|
return Promise.reject(failure);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/info.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"info.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/info.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n inferImageTypeFromPath,\n inferVideoTypeFromPath,\n normalizeVideoInfoNumber,\n readImageInfoFromSource,\n readPresetVideoInfo,\n readVideoInfoFromSource,\n} from '../mediaInfo'\n\nexport function getImageInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getImageInfo:fail invalid src')\n return Promise.reject(failure)\n }\n return readImageInfoFromSource(src)\n .then(({ width, height }) => callMiniProgramAsyncSuccess(options, {\n errMsg: 'getImageInfo:ok',\n width,\n height,\n path: src,\n type: inferImageTypeFromPath(src),\n orientation: 'up',\n }))\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getImageInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n\nexport function getVideoInfoBridge(options?: any) {\n const src = typeof options?.src === 'string' ? options.src.trim() : ''\n if (!src) {\n const failure = callMiniProgramAsyncFailure(options, 'getVideoInfo:fail invalid src')\n return Promise.reject(failure)\n }\n const preset = readPresetVideoInfo(src)\n const resolveResult = async () => {\n if (preset) {\n return preset\n }\n return readVideoInfoFromSource(src)\n }\n return resolveResult()\n .then((result) => {\n const duration = normalizeVideoInfoNumber(result.duration)\n const width = normalizeVideoInfoNumber(result.width)\n const height = normalizeVideoInfoNumber(result.height)\n const bitrate = normalizeVideoInfoNumber((result as Record<string, unknown>).bitrate)\n const fps = normalizeVideoInfoNumber((result as Record<string, unknown>).fps)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'getVideoInfo:ok',\n orientation: 'up',\n type: inferVideoTypeFromPath(src),\n duration,\n size: normalizeVideoInfoNumber((result as Record<string, unknown>).size),\n width,\n height,\n bitrate,\n fps,\n })\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `getVideoInfo:fail ${message}`)\n return Promise.reject(failure)\n })\n}\n"],"mappings":";;;;AAaA,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;AACrF,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,QAAO,wBAAwB,IAAI,CAChC,MAAM,EAAE,OAAO,aAAa,4BAA4B,SAAS;EAChE,QAAQ;EACR;EACA;EACA,MAAM;EACN,MAAM,uBAAuB,IAAI;EACjC,aAAa;EACd,CAAC,CAAC,CACF,OAAO,UAAU;EAEhB,MAAM,UAAU,4BAA4B,SAAS,qBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACc;AACpF,SAAO,QAAQ,OAAO,QAAQ;GAC9B;;AAGN,SAAgB,mBAAmB,SAAe;CAChD,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,QAAQ,IAAI,MAAM,GAAG;AACpE,KAAI,CAAC,KAAK;EACR,MAAM,UAAU,4BAA4B,SAAS,gCAAgC;AACrF,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,SAAS,oBAAoB,IAAI;CACvC,MAAM,gBAAgB,YAAY;AAChC,MAAI,OACF,QAAO;AAET,SAAO,wBAAwB,IAAI;;AAErC,QAAO,eAAe,CACnB,MAAM,WAAW;EAChB,MAAM,WAAW,yBAAyB,OAAO,SAAS;EAC1D,MAAM,QAAQ,yBAAyB,OAAO,MAAM;EACpD,MAAM,SAAS,yBAAyB,OAAO,OAAO;EACtD,MAAM,UAAU,yBAA0B,OAAmC,QAAQ;EACrF,MAAM,MAAM,yBAA0B,OAAmC,IAAI;AAC7E,SAAO,4BAA4B,SAAS;GAC1C,QAAQ;GACR,aAAa;GACb,MAAM,uBAAuB,IAAI;GACjC;GACA,MAAM,yBAA0B,OAAmC,KAAK;GACxE;GACA;GACA;GACA;GACD,CAAC;GACF,CACD,OAAO,UAAU;EAEhB,MAAM,UAAU,4BAA4B,SAAS,qBADrC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACc;AACpF,SAAO,QAAQ,OAAO,QAAQ;GAC9B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "../async.mjs";
|
|
2
2
|
import { normalizeChooseImageCount, normalizeChooseImageFile, normalizeChooseMediaCount, normalizeChooseMediaFile, normalizeChooseMediaTypes, pickChooseImageFiles, pickChooseMediaFiles } from "../mediaPicker.mjs";
|
|
3
3
|
import { normalizeChooseFileExtensions, normalizeChooseMessageFile, normalizeChooseMessageFileCount, normalizeChooseMessageFileType, pickChooseFileFiles, pickChooseMessageFiles } from "../filePicker.mjs";
|
|
4
4
|
import { normalizeChooseVideoFile, pickChooseVideoFile } from "../mediaProcess.mjs";
|
|
@@ -8,13 +8,13 @@ async function chooseImageBridge(options) {
|
|
|
8
8
|
const count = normalizeChooseImageCount(options?.count);
|
|
9
9
|
try {
|
|
10
10
|
const tempFiles = (await pickChooseImageFiles(count)).map((file) => normalizeChooseImageFile(file));
|
|
11
|
-
return
|
|
11
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
12
12
|
errMsg: "chooseImage:ok",
|
|
13
13
|
tempFilePaths: tempFiles.map((item) => item.path),
|
|
14
14
|
tempFiles
|
|
15
15
|
});
|
|
16
16
|
} catch (error) {
|
|
17
|
-
const failure =
|
|
17
|
+
const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
18
18
|
return Promise.reject(failure);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -24,13 +24,13 @@ async function chooseMediaBridge(options) {
|
|
|
24
24
|
try {
|
|
25
25
|
const tempFiles = (await pickChooseMediaFiles(count, types)).map((file) => normalizeChooseMediaFile(file));
|
|
26
26
|
const defaultType = types.has("video") && !types.has("image") ? "video" : "image";
|
|
27
|
-
return
|
|
27
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
28
28
|
errMsg: "chooseMedia:ok",
|
|
29
29
|
type: tempFiles[0]?.fileType ?? defaultType,
|
|
30
30
|
tempFiles
|
|
31
31
|
});
|
|
32
32
|
} catch (error) {
|
|
33
|
-
const failure =
|
|
33
|
+
const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
34
34
|
return Promise.reject(failure);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -40,12 +40,12 @@ async function chooseVideoBridge(options) {
|
|
|
40
40
|
if (!file) throw new TypeError("no file selected");
|
|
41
41
|
const normalized = normalizeChooseVideoFile(file);
|
|
42
42
|
if (!normalized) throw new TypeError("selected file is not a video");
|
|
43
|
-
return
|
|
43
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
44
44
|
errMsg: "chooseVideo:ok",
|
|
45
45
|
...normalized
|
|
46
46
|
});
|
|
47
47
|
} catch (error) {
|
|
48
|
-
const failure =
|
|
48
|
+
const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
49
49
|
return Promise.reject(failure);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -53,12 +53,12 @@ async function chooseMessageFileBridge(options) {
|
|
|
53
53
|
const count = normalizeChooseMessageFileCount(options?.count);
|
|
54
54
|
const type = normalizeChooseMessageFileType(options?.type);
|
|
55
55
|
try {
|
|
56
|
-
return
|
|
56
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
57
57
|
errMsg: "chooseMessageFile:ok",
|
|
58
58
|
tempFiles: (await pickChooseMessageFiles(count, type)).map((file) => normalizeChooseMessageFile(file))
|
|
59
59
|
});
|
|
60
60
|
} catch (error) {
|
|
61
|
-
const failure =
|
|
61
|
+
const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
62
62
|
return Promise.reject(failure);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -67,12 +67,12 @@ async function chooseFileBridge(options) {
|
|
|
67
67
|
const type = normalizeChooseMessageFileType(options?.type);
|
|
68
68
|
const extensions = normalizeChooseFileExtensions(options?.extension);
|
|
69
69
|
try {
|
|
70
|
-
return
|
|
70
|
+
return callMiniProgramAsyncSuccess(options, {
|
|
71
71
|
errMsg: "chooseFile:ok",
|
|
72
72
|
tempFiles: (await pickChooseFileFiles(count, type, extensions)).map((file) => normalizeChooseMessageFile(file))
|
|
73
73
|
});
|
|
74
74
|
} catch (error) {
|
|
75
|
-
const failure =
|
|
75
|
+
const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${error instanceof Error ? error.message : String(error)}`);
|
|
76
76
|
return Promise.reject(failure);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/picker.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"picker.mjs","names":[],"sources":["../../../../src/runtime/polyfill/mediaApi/picker.ts"],"sourcesContent":["import {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from '../async'\nimport {\n normalizeChooseFileExtensions,\n normalizeChooseMessageFile,\n normalizeChooseMessageFileCount,\n normalizeChooseMessageFileType,\n pickChooseFileFiles,\n pickChooseMessageFiles,\n} from '../filePicker'\nimport {\n normalizeChooseImageCount,\n normalizeChooseImageFile,\n normalizeChooseMediaCount,\n normalizeChooseMediaFile,\n normalizeChooseMediaTypes,\n pickChooseImageFiles,\n pickChooseMediaFiles,\n} from '../mediaPicker'\nimport {\n normalizeChooseVideoFile,\n pickChooseVideoFile,\n} from '../mediaProcess'\n\nexport async function chooseImageBridge(options?: any) {\n const count = normalizeChooseImageCount(options?.count)\n try {\n const files = await pickChooseImageFiles(count)\n const tempFiles = files.map(file => normalizeChooseImageFile(file))\n const tempFilePaths = tempFiles.map(item => item.path)\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseImage:ok',\n tempFilePaths,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseImage:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMediaBridge(options?: any) {\n const count = normalizeChooseMediaCount(options?.count)\n const types = normalizeChooseMediaTypes(options?.mediaType)\n try {\n const files = await pickChooseMediaFiles(count, types)\n const tempFiles = files.map(file => normalizeChooseMediaFile(file))\n const defaultType = types.has('video') && !types.has('image') ? 'video' : 'image'\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMedia:ok',\n type: tempFiles[0]?.fileType ?? defaultType,\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMedia:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseVideoBridge(options?: any) {\n try {\n const file = await pickChooseVideoFile()\n if (!file) {\n throw new TypeError('no file selected')\n }\n const normalized = normalizeChooseVideoFile(file)\n if (!normalized) {\n throw new TypeError('selected file is not a video')\n }\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseVideo:ok',\n ...normalized,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseVideo:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseMessageFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n try {\n const files = await pickChooseMessageFiles(count, type)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseMessageFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseMessageFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n\nexport async function chooseFileBridge(options?: any) {\n const count = normalizeChooseMessageFileCount(options?.count)\n const type = normalizeChooseMessageFileType(options?.type)\n const extensions = normalizeChooseFileExtensions(options?.extension)\n try {\n const files = await pickChooseFileFiles(count, type, extensions)\n const tempFiles = files.map(file => normalizeChooseMessageFile(file))\n return callMiniProgramAsyncSuccess(options, {\n errMsg: 'chooseFile:ok',\n tempFiles,\n })\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n const failure = callMiniProgramAsyncFailure(options, `chooseFile:fail ${message}`)\n return Promise.reject(failure)\n }\n}\n"],"mappings":";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