@wevu/api 0.2.8 → 0.2.10
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/dist/index.d.mts +6 -6
- package/dist/index.mjs +24 -12
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -8306,11 +8306,11 @@ declare function createWeapi<TAdapter extends WeapiAdapter = WeapiCrossPlatformR
|
|
|
8306
8306
|
declare const WEAPI_TYPE_SOURCES: {
|
|
8307
8307
|
readonly default: {
|
|
8308
8308
|
readonly package: "miniprogram-api-typings";
|
|
8309
|
-
readonly version: "5.2.
|
|
8309
|
+
readonly version: "5.2.1";
|
|
8310
8310
|
};
|
|
8311
8311
|
readonly wechat: {
|
|
8312
8312
|
readonly package: "miniprogram-api-typings";
|
|
8313
|
-
readonly version: "5.2.
|
|
8313
|
+
readonly version: "5.2.1";
|
|
8314
8314
|
};
|
|
8315
8315
|
readonly alipay: {
|
|
8316
8316
|
readonly package: "@mini-types/alipay";
|
|
@@ -8322,7 +8322,7 @@ declare const WEAPI_TYPE_SOURCES: {
|
|
|
8322
8322
|
};
|
|
8323
8323
|
readonly wx: {
|
|
8324
8324
|
readonly package: "miniprogram-api-typings";
|
|
8325
|
-
readonly version: "5.2.
|
|
8325
|
+
readonly version: "5.2.1";
|
|
8326
8326
|
};
|
|
8327
8327
|
readonly my: {
|
|
8328
8328
|
readonly package: "@mini-types/alipay";
|
|
@@ -8336,11 +8336,11 @@ declare const WEAPI_TYPE_SOURCES: {
|
|
|
8336
8336
|
declare const WEAPI_PLATFORM_TYPE_SOURCES: {
|
|
8337
8337
|
readonly default: {
|
|
8338
8338
|
readonly package: "miniprogram-api-typings";
|
|
8339
|
-
readonly version: "5.2.
|
|
8339
|
+
readonly version: "5.2.1";
|
|
8340
8340
|
};
|
|
8341
8341
|
readonly wechat: {
|
|
8342
8342
|
readonly package: "miniprogram-api-typings";
|
|
8343
|
-
readonly version: "5.2.
|
|
8343
|
+
readonly version: "5.2.1";
|
|
8344
8344
|
};
|
|
8345
8345
|
readonly alipay: {
|
|
8346
8346
|
readonly package: "@mini-types/alipay";
|
|
@@ -8354,7 +8354,7 @@ declare const WEAPI_PLATFORM_TYPE_SOURCES: {
|
|
|
8354
8354
|
declare const WEAPI_RUNTIME_TYPE_SOURCES: {
|
|
8355
8355
|
readonly wx: {
|
|
8356
8356
|
readonly package: "miniprogram-api-typings";
|
|
8357
|
-
readonly version: "5.2.
|
|
8357
|
+
readonly version: "5.2.1";
|
|
8358
8358
|
};
|
|
8359
8359
|
readonly my: {
|
|
8360
8360
|
readonly package: "@mini-types/alipay";
|
package/dist/index.mjs
CHANGED
|
@@ -98,7 +98,7 @@ function detectGlobalAdapter() {
|
|
|
98
98
|
}
|
|
99
99
|
return {};
|
|
100
100
|
}
|
|
101
|
-
const WEAPI_NON_PROMISIFIED_METHOD_NAME_SET = new Set([
|
|
101
|
+
const WEAPI_NON_PROMISIFIED_METHOD_NAME_SET = /* @__PURE__ */ new Set([
|
|
102
102
|
"arrayBufferToBase64",
|
|
103
103
|
"base64ToArrayBuffer",
|
|
104
104
|
"canIUse",
|
|
@@ -776,11 +776,11 @@ const WEAPI_TT_METHODS = [...WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL
|
|
|
776
776
|
const WEAPI_TYPE_SOURCES = {
|
|
777
777
|
default: {
|
|
778
778
|
package: "miniprogram-api-typings",
|
|
779
|
-
version: "5.2.
|
|
779
|
+
version: "5.2.1"
|
|
780
780
|
},
|
|
781
781
|
wechat: {
|
|
782
782
|
package: "miniprogram-api-typings",
|
|
783
|
-
version: "5.2.
|
|
783
|
+
version: "5.2.1"
|
|
784
784
|
},
|
|
785
785
|
alipay: {
|
|
786
786
|
package: "@mini-types/alipay",
|
|
@@ -792,7 +792,7 @@ const WEAPI_TYPE_SOURCES = {
|
|
|
792
792
|
},
|
|
793
793
|
wx: {
|
|
794
794
|
package: "miniprogram-api-typings",
|
|
795
|
-
version: "5.2.
|
|
795
|
+
version: "5.2.1"
|
|
796
796
|
},
|
|
797
797
|
my: {
|
|
798
798
|
package: "@mini-types/alipay",
|
|
@@ -2210,13 +2210,13 @@ function resolveMethodMappingWithMeta(platform, methodName, options = {}) {
|
|
|
2210
2210
|
}
|
|
2211
2211
|
//#endregion
|
|
2212
2212
|
//#region src/core/networkRequestPolicy/types.ts
|
|
2213
|
-
const NETWORK_METHODS = new Set([
|
|
2213
|
+
const NETWORK_METHODS = /* @__PURE__ */ new Set([
|
|
2214
2214
|
"request",
|
|
2215
2215
|
"uploadFile",
|
|
2216
2216
|
"downloadFile",
|
|
2217
2217
|
"connectSocket"
|
|
2218
2218
|
]);
|
|
2219
|
-
const HTTP_METHODS = new Set([
|
|
2219
|
+
const HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
2220
2220
|
"request",
|
|
2221
2221
|
"uploadFile",
|
|
2222
2222
|
"downloadFile"
|
|
@@ -2467,7 +2467,7 @@ function createNetworkRequestPolicy(getPlatform, options = void 0) {
|
|
|
2467
2467
|
}
|
|
2468
2468
|
//#endregion
|
|
2469
2469
|
//#region src/core/createWeapi.ts
|
|
2470
|
-
const INTERNAL_KEYS = new Set([
|
|
2470
|
+
const INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
2471
2471
|
"setAdapter",
|
|
2472
2472
|
"getAdapter",
|
|
2473
2473
|
"platform",
|
|
@@ -2476,6 +2476,7 @@ const INTERNAL_KEYS = new Set([
|
|
|
2476
2476
|
"supports"
|
|
2477
2477
|
]);
|
|
2478
2478
|
const PLATFORM_ALIASES = { kuaishou: "ks" };
|
|
2479
|
+
const WECHAT_FILE_SYSTEM_MANAGER_METHODS = /* @__PURE__ */ new Set(["saveFile", "removeSavedFile"]);
|
|
2479
2480
|
function normalizePlatformName(value) {
|
|
2480
2481
|
const normalized = normalizeMiniProgramPlatform(value);
|
|
2481
2482
|
if (!normalized) return;
|
|
@@ -2514,12 +2515,23 @@ function createWeapi(options = {}) {
|
|
|
2514
2515
|
if (!platformName) resolveAdapter();
|
|
2515
2516
|
return platformName;
|
|
2516
2517
|
};
|
|
2518
|
+
const resolveRuntimeMethod = (runtimeAdapter, platform, methodName) => {
|
|
2519
|
+
if (!runtimeAdapter) return;
|
|
2520
|
+
if (platform === "wx" && WECHAT_FILE_SYSTEM_MANAGER_METHODS.has(methodName)) {
|
|
2521
|
+
const getFileSystemManager = runtimeAdapter.getFileSystemManager;
|
|
2522
|
+
if (typeof getFileSystemManager !== "function") return;
|
|
2523
|
+
const fileSystemManager = getFileSystemManager.call(runtimeAdapter);
|
|
2524
|
+
const fileSystemMethod = fileSystemManager?.[methodName];
|
|
2525
|
+
return typeof fileSystemMethod === "function" ? fileSystemMethod.bind(fileSystemManager) : void 0;
|
|
2526
|
+
}
|
|
2527
|
+
return runtimeAdapter[methodName];
|
|
2528
|
+
};
|
|
2517
2529
|
const resolveTarget = (methodName) => {
|
|
2518
2530
|
const runtimeAdapter = resolveAdapter();
|
|
2519
2531
|
const platform = getPlatform();
|
|
2520
2532
|
const mappingInfo = resolveMethodMappingWithMeta(platform, methodName, { allowFallback });
|
|
2521
2533
|
const target = mappingInfo?.target ?? methodName;
|
|
2522
|
-
const supported = typeof (runtimeAdapter
|
|
2534
|
+
const supported = typeof resolveRuntimeMethod(runtimeAdapter, platform, target) === "function";
|
|
2523
2535
|
const supportLevel = !supported ? "unsupported" : mappingInfo?.source === "fallback" ? "fallback" : mappingInfo?.source === "explicit" ? "mapped" : "native";
|
|
2524
2536
|
return {
|
|
2525
2537
|
method: methodName,
|
|
@@ -2554,7 +2566,7 @@ function createWeapi(options = {}) {
|
|
|
2554
2566
|
return (...args) => callMissingApi(prop, getPlatform(), args);
|
|
2555
2567
|
}
|
|
2556
2568
|
const platform = getPlatform();
|
|
2557
|
-
const value = currentAdapter
|
|
2569
|
+
const value = resolveRuntimeMethod(currentAdapter, platform, (typeof prop === "string" ? resolveMethodMappingWithMeta(platform, prop, { allowFallback }) : void 0)?.target ?? prop);
|
|
2558
2570
|
if (typeof value !== "function") {
|
|
2559
2571
|
if (value === void 0 && typeof prop === "string") {
|
|
2560
2572
|
const missing = (...args) => callMissingApi(prop, getPlatform(), args);
|
|
@@ -2566,10 +2578,10 @@ function createWeapi(options = {}) {
|
|
|
2566
2578
|
}
|
|
2567
2579
|
const wrapped = (...args) => {
|
|
2568
2580
|
const runtimeAdapter = resolveAdapter();
|
|
2569
|
-
const
|
|
2581
|
+
const platform = getPlatform();
|
|
2582
|
+
const mappingInfo = resolveMethodMappingWithMeta(platform, prop, { allowFallback });
|
|
2570
2583
|
const mappingRule = mappingInfo?.rule;
|
|
2571
|
-
const
|
|
2572
|
-
const runtimeMethod = runtimeAdapter ? runtimeAdapter[methodName] : void 0;
|
|
2584
|
+
const runtimeMethod = resolveRuntimeMethod(runtimeAdapter, platform, mappingInfo?.target ?? prop);
|
|
2573
2585
|
let runtimeArgs = args;
|
|
2574
2586
|
try {
|
|
2575
2587
|
runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.10",
|
|
5
5
|
"description": "tsdown bundler template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@douyin-microapp/typings": "^1.3.1",
|
|
36
36
|
"@mini-types/alipay": "^3.0.14",
|
|
37
|
-
"miniprogram-api-typings": "^5.2.
|
|
37
|
+
"miniprogram-api-typings": "^5.2.1",
|
|
38
38
|
"@weapp-core/shared": "3.0.4"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|