@weapp-core/api 0.3.0 → 0.3.2
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 +1 -1
- package/dist/{index-BcqIvCCn.d.mts → index-Bt6fzcnM.d.mts} +2 -10
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +37 -7
- package/dist/vitest.d.mts +10 -11
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -388,7 +388,7 @@ resetApiMock(localWpi)
|
|
|
388
388
|
## 行为说明
|
|
389
389
|
|
|
390
390
|
- **只在不传回调时返回 Promise**
|
|
391
|
-
-
|
|
391
|
+
- 同步直接返回 API(包括无 `Sync` 后缀的宿主同步 API)、`*Sync` API 与事件 API(`onXxx/offXxx`)直接透传
|
|
392
392
|
- 可通过 `api.resolveTarget('showModal')` 查看当前平台目标方法与可用性
|
|
393
393
|
- 可通过 `api.supports('showModal')` 快速判断当前平台是否支持调用
|
|
394
394
|
- 缺失 API 时:
|
|
@@ -176,15 +176,7 @@ type WeapiMiniProgramCrossPlatformRawAdapter = MergeAdapters<MergeAdapters<Weapi
|
|
|
176
176
|
type WeapiCrossPlatformRawAdapter = WeapiMiniProgramCrossPlatformRawAdapter;
|
|
177
177
|
//#endregion
|
|
178
178
|
//#region src/core/nonPromisifiedMethods.d.ts
|
|
179
|
-
|
|
180
|
-
* @description `wpi` 中需要保留原始同步返回值的方法名单。
|
|
181
|
-
*
|
|
182
|
-
* 这些方法虽然不一定带有 `Sync` 后缀,但本质上属于以下几类:
|
|
183
|
-
* - 宿主能力探测与同步工具方法
|
|
184
|
-
* - 各类上下文 / manager / socket / observer 工厂
|
|
185
|
-
* - 同步返回句柄的调度与分析方法
|
|
186
|
-
*/
|
|
187
|
-
declare const WEAPI_NON_PROMISIFIED_METHOD_NAMES: readonly ["arrayBufferToBase64", "base64ToArrayBuffer", "canIUse", "cancelIdleCallback", "createAnimation", "createAudioContext", "createCameraContext", "createCanvasContext", "createEditorContext", "createInnerAudioContext", "createIntersectionObserver", "createInterstitialAd", "createLivePlayerContext", "createLivePusherContext", "createMapContext", "createMediaAudioPlayer", "createMediaContainer", "createMediaRecorder", "createOffscreenCanvas", "createRewardedVideoAd", "createSelectorQuery", "createTCPSocket", "createUDPSocket", "createVKSession", "createVideoContext", "createWebAudioContext", "createWorker", "getBackgroundAudioManager", "getFileSystemManager", "getLogManager", "getMenuButtonBoundingClientRect", "getNFCAdapter", "getOpenDataContext", "getPerformance", "getRealtimeLogManager", "getRecorderManager", "getUpdateManager", "getUserCryptoManager", "getXrFrameSystem", "nextTick", "reportAnalytics", "requestIdleCallback"];
|
|
179
|
+
declare const WEAPI_NON_PROMISIFIED_METHOD_NAMES: readonly ["arrayBufferToBase64", "base64ToArrayBuffer", "cancelIdleCallback", "canIUse", "checkIsPictureInPictureActive", "createAnimation", "createAudioContext", "createBufferURL", "createCacheManager", "createCameraContext", "createCanvasContext", "createGlobalPayment", "createInferenceSession", "createInnerAudioContext", "createIntersectionObserver", "createInterstitialAd", "createLivePlayerContext", "createLivePusherContext", "createMapContext", "createMediaAudioPlayer", "createMediaContainer", "createMediaRecorder", "createOffscreenCanvas", "createRewardedVideoAd", "createSelectorQuery", "createTCPSocket", "createUDPSocket", "createVideoContext", "createVideoDecoder", "createVKSession", "createWebAudioContext", "createWorker", "getApiCategory", "getAppAuthorizeSetting", "getAppBaseInfo", "getBackgroundAudioManager", "getDeviceInfo", "getFileSystemManager", "getLogManager", "getMenuButtonBoundingClientRect", "getNFCAdapter", "getPerformance", "getPluginUpdateManager", "getRealtimeLogManager", "getRecorderManager", "getSystemSetting", "getUpdateManager", "getUserCryptoManager", "getWindowInfo", "getXrFrameSystem", "isVKSupport", "nextTick", "postMessageToReferrerMiniProgram", "postMessageToReferrerPage", "reportAnalytics", "reportEvent", "reportMonitor", "reportPerformance", "requestAppleSubscribeSign", "requestIdleCallback", "revokeBufferURL", "createEditorContext", "getOpenDataContext"];
|
|
188
180
|
type WeapiNonPromisifiedMethodName = typeof WEAPI_NON_PROMISIFIED_METHOD_NAMES[number];
|
|
189
181
|
//#endregion
|
|
190
182
|
//#region src/core/promisify/index.d.ts
|
|
@@ -1105,7 +1097,7 @@ interface WeapiCrossPlatformMethodDocsChooseVideoToOpenDocumentChooseVideoToGetL
|
|
|
1105
1097
|
*
|
|
1106
1098
|
* 示例:
|
|
1107
1099
|
* ```ts
|
|
1108
|
-
* const info =
|
|
1100
|
+
* const info = wpi.getWindowInfo()
|
|
1109
1101
|
*
|
|
1110
1102
|
* console.log(info.windowWidth, info.windowHeight)
|
|
1111
1103
|
* ```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as WeapiMiniProgramLogManager, A as WeapiMiniProgramAlipayAdapter, B as WeapiError, C as CreateWeapiOptions, Ct as WeapiTtMiniProgramRawAdapterSource, D as WeapiInstance, E as WeapiDouyinAdapter, F as WeapiNetworkOverflowPolicy, G as WeapiDouyinRawAdapter, H as WeapiPromisify, I as WeapiResolvedTarget, J as WeapiMiniProgramBluetoothError, K as WeapiMiniProgramCrossPlatformRawAdapter, L as WeapiSupportLevel, M as WeapiMiniProgramDouyinAdapter, N as WeapiMiniProgramWxAdapter, O as WeapiMethodSupportQueryOptions, P as WeapiNetworkOptions, Q as WeapiMiniProgramGeneralCallbackResult, R as WeapiWxAdapter, S as createWeapi, St as WeapiMiniProgramRuntimeRawAdapterSourceRegistry, T as WeapiCrossPlatformAdapter, U as WeapiAlipayRawAdapter, V as WeapiPromise, W as WeapiCrossPlatformRawAdapter, X as WeapiMiniProgramConnectSocketOption, Y as WeapiMiniProgramClipboardDataResult, Z as WeapiMiniProgramDouyinRawAdapter, _ as WeapiWechatMethodName, _t as WeapiDouyinMiniProgramRawAdapterSource, a as normalizeMiniProgramPlatform, at as WeapiMiniProgramRequestTask, b as WEAPI_RUNTIME_TYPE_SOURCES, bt as WeapiMiniProgramRawAdapterSourceName, c as WeapiDouyinMethodName, ct as WeapiMiniProgramSystemInfo, d as WeapiMiniProgramMethodName, dt as WeapiMiniProgramWechatRawAdapter, et as WeapiMiniProgramRawAdapter, f as WeapiMiniProgramWechatMethodName, ft as WeapiMiniProgramWxRawAdapter, g as WeapiTypeSourceName, gt as WeapiDefaultMiniProgramRawAdapterSource, h as WeapiRuntimeTypeSourceName, ht as WeapiAlipayMiniProgramRawAdapterSource, i as MiniProgramApiPlatformDescriptor, it as WeapiMiniProgramRequestSuccessResult, j as WeapiMiniProgramCrossPlatformAdapter, k as WeapiMiniProgramAdapter, l as WeapiMiniProgramAlipayMethodName, lt as WeapiMiniProgramUpdateManager, m as WeapiPlatformTypeSourceName, mt as WeapiWxRawAdapter, n as wpi, nt as WeapiMiniProgramRequestMethod, o as resolveMiniProgramPlatform, ot as WeapiMiniProgramSelectorQuery, p as WeapiMiniProgramWxMethodName, pt as WeapiWechatRawAdapter, q as WeapiMiniProgramAlipayRawAdapter, r as MINI_PROGRAM_API_PLATFORM_DESCRIPTORS, rt as WeapiMiniProgramRequestOption, s as WeapiAlipayMethodName, st as WeapiMiniProgramSocketTask, t as api, tt as WeapiMiniProgramRequestFailResult, u as WeapiMiniProgramDouyinMethodName, ut as WeapiMiniProgramVideoContext, v as WeapiWxMethodName, vt as WeapiMiniProgramPlatformRawAdapterSourceName, w as WeapiAlipayAdapter, wt as WeapiWechatMiniProgramRawAdapterSource, x as WEAPI_TYPE_SOURCES, xt as WeapiMiniProgramRuntimeRawAdapterSourceName, y as WEAPI_PLATFORM_TYPE_SOURCES, yt as WeapiMiniProgramPlatformRawAdapterSourceRegistry, z as WeapiAdapter } from "./index-
|
|
1
|
+
import { $ as WeapiMiniProgramLogManager, A as WeapiMiniProgramAlipayAdapter, B as WeapiError, C as CreateWeapiOptions, Ct as WeapiTtMiniProgramRawAdapterSource, D as WeapiInstance, E as WeapiDouyinAdapter, F as WeapiNetworkOverflowPolicy, G as WeapiDouyinRawAdapter, H as WeapiPromisify, I as WeapiResolvedTarget, J as WeapiMiniProgramBluetoothError, K as WeapiMiniProgramCrossPlatformRawAdapter, L as WeapiSupportLevel, M as WeapiMiniProgramDouyinAdapter, N as WeapiMiniProgramWxAdapter, O as WeapiMethodSupportQueryOptions, P as WeapiNetworkOptions, Q as WeapiMiniProgramGeneralCallbackResult, R as WeapiWxAdapter, S as createWeapi, St as WeapiMiniProgramRuntimeRawAdapterSourceRegistry, T as WeapiCrossPlatformAdapter, U as WeapiAlipayRawAdapter, V as WeapiPromise, W as WeapiCrossPlatformRawAdapter, X as WeapiMiniProgramConnectSocketOption, Y as WeapiMiniProgramClipboardDataResult, Z as WeapiMiniProgramDouyinRawAdapter, _ as WeapiWechatMethodName, _t as WeapiDouyinMiniProgramRawAdapterSource, a as normalizeMiniProgramPlatform, at as WeapiMiniProgramRequestTask, b as WEAPI_RUNTIME_TYPE_SOURCES, bt as WeapiMiniProgramRawAdapterSourceName, c as WeapiDouyinMethodName, ct as WeapiMiniProgramSystemInfo, d as WeapiMiniProgramMethodName, dt as WeapiMiniProgramWechatRawAdapter, et as WeapiMiniProgramRawAdapter, f as WeapiMiniProgramWechatMethodName, ft as WeapiMiniProgramWxRawAdapter, g as WeapiTypeSourceName, gt as WeapiDefaultMiniProgramRawAdapterSource, h as WeapiRuntimeTypeSourceName, ht as WeapiAlipayMiniProgramRawAdapterSource, i as MiniProgramApiPlatformDescriptor, it as WeapiMiniProgramRequestSuccessResult, j as WeapiMiniProgramCrossPlatformAdapter, k as WeapiMiniProgramAdapter, l as WeapiMiniProgramAlipayMethodName, lt as WeapiMiniProgramUpdateManager, m as WeapiPlatformTypeSourceName, mt as WeapiWxRawAdapter, n as wpi, nt as WeapiMiniProgramRequestMethod, o as resolveMiniProgramPlatform, ot as WeapiMiniProgramSelectorQuery, p as WeapiMiniProgramWxMethodName, pt as WeapiWechatRawAdapter, q as WeapiMiniProgramAlipayRawAdapter, r as MINI_PROGRAM_API_PLATFORM_DESCRIPTORS, rt as WeapiMiniProgramRequestOption, s as WeapiAlipayMethodName, st as WeapiMiniProgramSocketTask, t as api, tt as WeapiMiniProgramRequestFailResult, u as WeapiMiniProgramDouyinMethodName, ut as WeapiMiniProgramVideoContext, v as WeapiWxMethodName, vt as WeapiMiniProgramPlatformRawAdapterSourceName, w as WeapiAlipayAdapter, wt as WeapiWechatMiniProgramRawAdapterSource, x as WEAPI_TYPE_SOURCES, xt as WeapiMiniProgramRuntimeRawAdapterSourceName, y as WEAPI_PLATFORM_TYPE_SOURCES, yt as WeapiMiniProgramPlatformRawAdapterSourceRegistry, z as WeapiAdapter } from "./index-Bt6fzcnM.mjs";
|
|
2
2
|
export { type CreateWeapiOptions as CreateApiOptions, type CreateWeapiOptions, MINI_PROGRAM_API_PLATFORM_DESCRIPTORS, type WeapiInstance as MiniProgramApiInstance, type WeapiInstance, type MiniProgramApiPlatformDescriptor, WEAPI_PLATFORM_TYPE_SOURCES, WEAPI_RUNTIME_TYPE_SOURCES, WEAPI_TYPE_SOURCES, type WeapiAdapter, type WeapiAlipayAdapter, type WeapiAlipayMethodName, type WeapiAlipayMiniProgramRawAdapterSource, type WeapiAlipayRawAdapter, type WeapiCrossPlatformAdapter, type WeapiCrossPlatformRawAdapter, type WeapiDefaultMiniProgramRawAdapterSource, type WeapiDouyinAdapter, type WeapiDouyinMethodName, type WeapiDouyinMiniProgramRawAdapterSource, type WeapiDouyinRawAdapter, type WeapiError, type WeapiMethodSupportQueryOptions, type WeapiMiniProgramAdapter, type WeapiMiniProgramAlipayAdapter, type WeapiMiniProgramAlipayMethodName, type WeapiMiniProgramAlipayRawAdapter, type WeapiMiniProgramBluetoothError, type WeapiMiniProgramClipboardDataResult, type WeapiMiniProgramConnectSocketOption, type WeapiMiniProgramCrossPlatformAdapter, type WeapiMiniProgramCrossPlatformRawAdapter, type WeapiMiniProgramDouyinAdapter, type WeapiMiniProgramDouyinMethodName, type WeapiMiniProgramDouyinRawAdapter, type WeapiMiniProgramGeneralCallbackResult, type WeapiMiniProgramLogManager, type WeapiMiniProgramMethodName, type WeapiMiniProgramPlatformRawAdapterSourceName, type WeapiMiniProgramPlatformRawAdapterSourceRegistry, type WeapiMiniProgramRawAdapter, type WeapiMiniProgramRawAdapterSourceName, type WeapiMiniProgramRequestFailResult, type WeapiMiniProgramRequestMethod, type WeapiMiniProgramRequestOption, type WeapiMiniProgramRequestSuccessResult, type WeapiMiniProgramRequestTask, type WeapiMiniProgramRuntimeRawAdapterSourceName, type WeapiMiniProgramRuntimeRawAdapterSourceRegistry, type WeapiMiniProgramSelectorQuery, type WeapiMiniProgramSocketTask, type WeapiMiniProgramSystemInfo, type WeapiMiniProgramUpdateManager, type WeapiMiniProgramVideoContext, type WeapiMiniProgramWechatMethodName, type WeapiMiniProgramWechatRawAdapter, type WeapiMiniProgramWxAdapter, type WeapiMiniProgramWxMethodName, type WeapiMiniProgramWxRawAdapter, type WeapiNetworkOptions, type WeapiNetworkOverflowPolicy, type WeapiPlatformTypeSourceName, type WeapiPromise, type WeapiPromisify, type WeapiResolvedTarget, type WeapiRuntimeTypeSourceName, type WeapiSupportLevel, type WeapiTtMiniProgramRawAdapterSource, type WeapiTypeSourceName, type WeapiWechatMethodName, type WeapiWechatMiniProgramRawAdapterSource, type WeapiWechatRawAdapter, type WeapiWxAdapter, type WeapiWxMethodName, type WeapiWxRawAdapter, api, createWeapi as createApi, createWeapi, normalizeMiniProgramPlatform, resolveMiniProgramPlatform, wpi };
|
package/dist/index.mjs
CHANGED
|
@@ -232,16 +232,26 @@ function detectGlobalAdapter() {
|
|
|
232
232
|
}
|
|
233
233
|
return {};
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/core/apiCatalog/wxDirectReturnMethods.ts
|
|
237
|
+
/**
|
|
238
|
+
* @description 微信无回调直接返回 API 名单(由 typings 自动提取,请勿手工修改)
|
|
239
|
+
* @generated by scripts/sync-api-catalog.mjs
|
|
240
|
+
*/
|
|
241
|
+
const WEAPI_WX_DIRECT_RETURN_METHODS = [
|
|
236
242
|
"arrayBufferToBase64",
|
|
237
243
|
"base64ToArrayBuffer",
|
|
238
|
-
"canIUse",
|
|
239
244
|
"cancelIdleCallback",
|
|
245
|
+
"canIUse",
|
|
246
|
+
"checkIsPictureInPictureActive",
|
|
240
247
|
"createAnimation",
|
|
241
248
|
"createAudioContext",
|
|
249
|
+
"createBufferURL",
|
|
250
|
+
"createCacheManager",
|
|
242
251
|
"createCameraContext",
|
|
243
252
|
"createCanvasContext",
|
|
244
|
-
"
|
|
253
|
+
"createGlobalPayment",
|
|
254
|
+
"createInferenceSession",
|
|
245
255
|
"createInnerAudioContext",
|
|
246
256
|
"createIntersectionObserver",
|
|
247
257
|
"createInterstitialAd",
|
|
@@ -256,26 +266,46 @@ const WEAPI_NON_PROMISIFIED_METHOD_NAME_SET = /* @__PURE__ */ new Set([
|
|
|
256
266
|
"createSelectorQuery",
|
|
257
267
|
"createTCPSocket",
|
|
258
268
|
"createUDPSocket",
|
|
259
|
-
"createVKSession",
|
|
260
269
|
"createVideoContext",
|
|
270
|
+
"createVideoDecoder",
|
|
271
|
+
"createVKSession",
|
|
261
272
|
"createWebAudioContext",
|
|
262
273
|
"createWorker",
|
|
274
|
+
"getApiCategory",
|
|
275
|
+
"getAppAuthorizeSetting",
|
|
276
|
+
"getAppBaseInfo",
|
|
263
277
|
"getBackgroundAudioManager",
|
|
278
|
+
"getDeviceInfo",
|
|
264
279
|
"getFileSystemManager",
|
|
265
280
|
"getLogManager",
|
|
266
281
|
"getMenuButtonBoundingClientRect",
|
|
267
282
|
"getNFCAdapter",
|
|
268
|
-
"getOpenDataContext",
|
|
269
283
|
"getPerformance",
|
|
284
|
+
"getPluginUpdateManager",
|
|
270
285
|
"getRealtimeLogManager",
|
|
271
286
|
"getRecorderManager",
|
|
287
|
+
"getSystemSetting",
|
|
272
288
|
"getUpdateManager",
|
|
273
289
|
"getUserCryptoManager",
|
|
290
|
+
"getWindowInfo",
|
|
274
291
|
"getXrFrameSystem",
|
|
292
|
+
"isVKSupport",
|
|
275
293
|
"nextTick",
|
|
294
|
+
"postMessageToReferrerMiniProgram",
|
|
295
|
+
"postMessageToReferrerPage",
|
|
276
296
|
"reportAnalytics",
|
|
277
|
-
"
|
|
278
|
-
|
|
297
|
+
"reportEvent",
|
|
298
|
+
"reportMonitor",
|
|
299
|
+
"reportPerformance",
|
|
300
|
+
"requestAppleSubscribeSign",
|
|
301
|
+
"requestIdleCallback",
|
|
302
|
+
"revokeBufferURL"
|
|
303
|
+
];
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/core/nonPromisifiedMethods.ts
|
|
306
|
+
const WEAPI_LEGACY_NON_PROMISIFIED_METHOD_NAMES = ["createEditorContext", "getOpenDataContext"];
|
|
307
|
+
const WEAPI_NON_PROMISIFIED_METHOD_NAMES = [...WEAPI_WX_DIRECT_RETURN_METHODS, ...WEAPI_LEGACY_NON_PROMISIFIED_METHOD_NAMES];
|
|
308
|
+
const WEAPI_NON_PROMISIFIED_METHOD_NAME_SET = new Set(WEAPI_NON_PROMISIFIED_METHOD_NAMES);
|
|
279
309
|
/**
|
|
280
310
|
* @description 判断方法是否应保留原始同步返回值,而不是包装为 Promise。
|
|
281
311
|
*/
|
package/dist/vitest.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as WeapiInstance, K as WeapiMiniProgramCrossPlatformRawAdapter, W as WeapiCrossPlatformRawAdapter, z as WeapiAdapter } from "./index-
|
|
1
|
+
import { D as WeapiInstance, K as WeapiMiniProgramCrossPlatformRawAdapter, W as WeapiCrossPlatformRawAdapter, z as WeapiAdapter } from "./index-Bt6fzcnM.mjs";
|
|
2
2
|
import { Mock } from "vitest";
|
|
3
3
|
//#region src/vitest/index.d.ts
|
|
4
4
|
type Procedure = (...args: any[]) => any;
|
|
@@ -23,34 +23,33 @@ type RawMethod<TAdapter extends WeapiAdapter, TKey extends PropertyKey, TFallbac
|
|
|
23
23
|
/**
|
|
24
24
|
* @description 与 API 实例方法签名对齐的 Vitest mock 对象。
|
|
25
25
|
*/
|
|
26
|
-
type ApiMock<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter> = { [TKey in keyof WeapiInstance<TAdapter>]: WeapiInstance<TAdapter>[TKey] extends Procedure ? ApiMockFunction<WeapiInstance<TAdapter>[TKey], RawMethod<TAdapter, TKey, WeapiInstance<TAdapter>[TKey]>> : WeapiInstance<TAdapter>[TKey]; };
|
|
26
|
+
export type ApiMock<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter> = { [TKey in keyof WeapiInstance<TAdapter>]: WeapiInstance<TAdapter>[TKey] extends Procedure ? ApiMockFunction<WeapiInstance<TAdapter>[TKey], RawMethod<TAdapter, TKey, WeapiInstance<TAdapter>[TKey]>> : WeapiInstance<TAdapter>[TKey]; };
|
|
27
27
|
/**
|
|
28
28
|
* @description 创建 API mock 时预设的属性或方法实现。
|
|
29
29
|
*/
|
|
30
|
-
type ApiMockOverrides<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter> = Partial<WeapiInstance<TAdapter>>;
|
|
30
|
+
export type ApiMockOverrides<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter> = Partial<WeapiInstance<TAdapter>>;
|
|
31
31
|
/**
|
|
32
32
|
* @description 创建与 API 类型对齐、按访问惰性生成方法的 Vitest mock。
|
|
33
33
|
*/
|
|
34
|
-
declare function createApiMock<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter>(overrides?: ApiMockOverrides<NoInfer<TAdapter>>): ApiMock<TAdapter>;
|
|
34
|
+
export declare function createApiMock<TAdapter extends WeapiAdapter = WeapiCrossPlatformRawAdapter>(overrides?: ApiMockOverrides<NoInfer<TAdapter>>): ApiMock<TAdapter>;
|
|
35
35
|
/**
|
|
36
36
|
* @description 默认 API Vitest mock 单例。
|
|
37
37
|
*/
|
|
38
|
-
declare const apiMock: ApiMock<WeapiMiniProgramCrossPlatformRawAdapter>;
|
|
38
|
+
export declare const apiMock: ApiMock<WeapiMiniProgramCrossPlatformRawAdapter>;
|
|
39
39
|
/**
|
|
40
40
|
* @description 默认 API Vitest mock 单例的兼容名称。
|
|
41
41
|
*/
|
|
42
|
-
declare const wpiMock: ApiMock<WeapiMiniProgramCrossPlatformRawAdapter>;
|
|
42
|
+
export declare const wpiMock: ApiMock<WeapiMiniProgramCrossPlatformRawAdapter>;
|
|
43
43
|
/**
|
|
44
44
|
* @description 创建 API Vitest mock 的兼容名称。
|
|
45
45
|
*/
|
|
46
|
-
declare const createWpiMock: typeof createApiMock;
|
|
46
|
+
export declare const createWpiMock: typeof createApiMock;
|
|
47
47
|
/**
|
|
48
48
|
* @description 重置指定 API mock 自身已创建的方法,不影响其他 Vitest mocks。
|
|
49
49
|
*/
|
|
50
|
-
declare function resetApiMock(mock?: ApiMock<any>): void;
|
|
50
|
+
export declare function resetApiMock(mock?: ApiMock<any>): void;
|
|
51
51
|
/**
|
|
52
52
|
* @description 在 Vitest setup 文件中注册需要替换 API 实例的模块入口。
|
|
53
53
|
*/
|
|
54
|
-
declare function setupApiMock(moduleIds: readonly string[]): void;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { ApiMock, ApiMockOverrides, apiMock, createApiMock, createWpiMock, resetApiMock, setupApiMock, wpiMock };
|
|
54
|
+
export declare function setupApiMock(moduleIds: readonly string[]): void;
|
|
55
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "Framework-agnostic cross-platform mini-program API proxy",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
"url": "https://github.com/weapp-vite/weapp-vite/issues"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
|
+
"weapp-vite",
|
|
19
|
+
"weapp",
|
|
20
|
+
"wechat",
|
|
18
21
|
"mini-program",
|
|
19
22
|
"miniprogram",
|
|
20
23
|
"cross-platform",
|
|
21
24
|
"api",
|
|
22
|
-
"adapter"
|
|
23
|
-
"weapp"
|
|
25
|
+
"adapter"
|
|
24
26
|
],
|
|
25
27
|
"sideEffects": [
|
|
26
28
|
"./dist/vitest/setup.mjs"
|
|
@@ -69,6 +71,9 @@
|
|
|
69
71
|
"dist",
|
|
70
72
|
"types"
|
|
71
73
|
],
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
76
|
+
},
|
|
72
77
|
"peerDependencies": {
|
|
73
78
|
"vitest": ">=4.0.0"
|
|
74
79
|
},
|
|
@@ -89,7 +94,8 @@
|
|
|
89
94
|
}
|
|
90
95
|
},
|
|
91
96
|
"publishConfig": {
|
|
92
|
-
"access": "public"
|
|
97
|
+
"access": "public",
|
|
98
|
+
"registry": "https://registry.npmjs.org"
|
|
93
99
|
},
|
|
94
100
|
"scripts": {
|
|
95
101
|
"dev": "tsdown -w",
|