@doubao-apps/taro-runtime 0.0.25 → 0.0.26

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.
@@ -3,7 +3,10 @@ type TaroStartCompassOption = Parameters<typeof Taro.startCompass>[0];
3
3
  type TaroStartCompassResult = Awaited<ReturnType<typeof Taro.startCompass>>;
4
4
  type TaroStopCompassOption = Parameters<typeof Taro.stopCompass>[0];
5
5
  type TaroStopCompassResult = Awaited<ReturnType<typeof Taro.stopCompass>>;
6
+ type CompassChangeCallback = Parameters<typeof Taro.onCompassChange>[0];
6
7
  export declare function startCompass(option?: TaroStartCompassOption): Promise<TaroStartCompassResult>;
7
8
  export declare function stopCompass(option?: TaroStopCompassOption): Promise<TaroStopCompassResult>;
9
+ export declare function onCompassChange(callback: CompassChangeCallback): void;
10
+ export declare function offCompassChange(callback?: CompassChangeCallback): void;
8
11
  export {};
9
12
  //# sourceMappingURL=compass.d.ts.map
@@ -1,9 +1,37 @@
1
1
  import * as appFrameworkApi from '@byted-doubao-apps/framework/api';
2
2
  import { runCallbackApi } from '../utils.js';
3
+ const compassChangeCallbacks = new Map();
3
4
  export async function startCompass(option) {
4
5
  return runCallbackApi('startCompass', option, () => appFrameworkApi.startCompass({}));
5
6
  }
6
7
  export async function stopCompass(option) {
7
8
  return runCallbackApi('stopCompass', option, () => appFrameworkApi.stopCompass({}));
8
9
  }
10
+ export function onCompassChange(callback) {
11
+ if (typeof callback !== 'function' || compassChangeCallbacks.has(callback)) {
12
+ return;
13
+ }
14
+ const unregister = appFrameworkApi.onCompassChange((event) => {
15
+ callback({
16
+ direction: event.direction
17
+ });
18
+ });
19
+ compassChangeCallbacks.set(callback, unregister);
20
+ }
21
+ export function offCompassChange(callback) {
22
+ if (typeof callback === 'function') {
23
+ const unregister = compassChangeCallbacks.get(callback);
24
+ if (!unregister) {
25
+ return;
26
+ }
27
+ unregister();
28
+ compassChangeCallbacks.delete(callback);
29
+ return;
30
+ }
31
+ if (callback !== undefined) {
32
+ return;
33
+ }
34
+ compassChangeCallbacks.forEach((unregister) => unregister());
35
+ compassChangeCallbacks.clear();
36
+ }
9
37
  //# sourceMappingURL=compass.js.map
@@ -11,7 +11,6 @@ export * from './contact.js';
11
11
  export * from './crypto.js';
12
12
  export * from './device-motion.js';
13
13
  export * from './gyroscope.js';
14
- export * from './hce.js';
15
14
  export * from './keyboard.js';
16
15
  export * from './network.js';
17
16
  export * from './scan.js';
@@ -11,7 +11,6 @@ export * from './contact.js';
11
11
  export * from './crypto.js';
12
12
  export * from './device-motion.js';
13
13
  export * from './gyroscope.js';
14
- export * from './hce.js';
15
14
  export * from './keyboard.js';
16
15
  export * from './network.js';
17
16
  export * from './scan.js';
@@ -5,8 +5,11 @@ type TaroSetScreenBrightnessOption = Parameters<typeof Taro.setScreenBrightness>
5
5
  type TaroSetScreenBrightnessResult = Awaited<ReturnType<typeof Taro.setScreenBrightness>>;
6
6
  type TaroSetKeepScreenOnOption = Parameters<typeof Taro.setKeepScreenOn>[0];
7
7
  type TaroSetKeepScreenOnResult = Awaited<ReturnType<typeof Taro.setKeepScreenOn>>;
8
+ type UserCaptureScreenCallback = (result: TaroGeneral.CallbackResult) => void;
8
9
  export declare function setVisualEffectOnCapture(option: TaroSetVisualEffectOnCaptureOption): Promise<TaroSetVisualEffectOnCaptureResult>;
9
10
  export declare function setScreenBrightness(option: TaroSetScreenBrightnessOption): Promise<TaroSetScreenBrightnessResult>;
10
11
  export declare function setKeepScreenOn(option: TaroSetKeepScreenOnOption): Promise<TaroSetKeepScreenOnResult>;
12
+ export declare function onUserCaptureScreen(callback: UserCaptureScreenCallback): void;
13
+ export declare function offUserCaptureScreen(callback?: UserCaptureScreenCallback): void;
11
14
  export {};
12
15
  //# sourceMappingURL=screen.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import * as appFrameworkApi from '@byted-doubao-apps/framework/api';
2
- import { runCallbackApi } from '../utils.js';
2
+ import { buildOkCallbackResult, runCallbackApi } from '../utils.js';
3
+ const userCaptureScreenCallbacks = new Map();
3
4
  export async function setVisualEffectOnCapture(option) {
4
5
  return runCallbackApi('setVisualEffectOnCapture', option, () => appFrameworkApi.setVisualEffectOnCapture({
5
6
  visualEffect: option.visualEffect
@@ -15,4 +16,29 @@ export async function setKeepScreenOn(option) {
15
16
  keepScreenOn: option.keepScreenOn
16
17
  }));
17
18
  }
19
+ export function onUserCaptureScreen(callback) {
20
+ if (typeof callback !== 'function' || userCaptureScreenCallbacks.has(callback)) {
21
+ return;
22
+ }
23
+ const unregister = appFrameworkApi.onUserCaptureScreen(() => {
24
+ callback(buildOkCallbackResult('onUserCaptureScreen'));
25
+ });
26
+ userCaptureScreenCallbacks.set(callback, unregister);
27
+ }
28
+ export function offUserCaptureScreen(callback) {
29
+ if (typeof callback === 'function') {
30
+ const unregister = userCaptureScreenCallbacks.get(callback);
31
+ if (!unregister) {
32
+ return;
33
+ }
34
+ unregister();
35
+ userCaptureScreenCallbacks.delete(callback);
36
+ return;
37
+ }
38
+ if (callback !== undefined) {
39
+ return;
40
+ }
41
+ userCaptureScreenCallbacks.forEach((unregister) => unregister());
42
+ userCaptureScreenCallbacks.clear();
43
+ }
18
44
  //# sourceMappingURL=screen.js.map
@@ -1,4 +1,3 @@
1
1
  export * from './beacon.js';
2
- export * from './hce.js';
3
2
  export * from './wifi.js';
4
3
  //# sourceMappingURL=wireless.d.ts.map
@@ -1,4 +1,3 @@
1
1
  export * from './beacon.js';
2
- export * from './hce.js';
3
2
  export * from './wifi.js';
4
3
  //# sourceMappingURL=wireless.js.map
@@ -1,11 +1,13 @@
1
1
  export { getEnv, ENV_TYPE } from './base/index.js';
2
2
  export * from './device/index.js';
3
3
  export * from './device/index.js';
4
+ export * from './media/index.js';
4
5
  export { request } from './request/index.js';
5
6
  export { exitMiniProgram, navigateBack, navigateTo, getCurrentPages, reLaunch, redirectTo } from './router/index.js';
6
7
  export { setStorage, setStorageSync, getStorage, getStorageSync, removeStorage, removeStorageSync, clearStorage, clearStorageSync, getStorageInfo, getStorageInfoSync } from './storage/index.js';
7
8
  export * from './system/index.js';
8
9
  export { getLocation } from './location/index.js';
10
+ export { disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal } from './interaction/index.js';
9
11
  export { showToast } from './show-toast/index.js';
10
12
  export { createMapContext } from './map/index.js';
11
13
  export { createSelectorQuery } from './create-selector-query/index.js';
package/dist/api/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  export { getEnv, ENV_TYPE } from './base/index.js';
2
2
  export * from './device/index.js';
3
3
  export * from './device/index.js';
4
+ export * from './media/index.js';
4
5
  export { request } from './request/index.js';
5
6
  export { exitMiniProgram, navigateBack, navigateTo, getCurrentPages, reLaunch, redirectTo } from './router/index.js';
6
7
  export { setStorage, setStorageSync, getStorage, getStorageSync, removeStorage, removeStorageSync, clearStorage, clearStorageSync, getStorageInfo, getStorageInfoSync } from './storage/index.js';
7
8
  export * from './system/index.js';
8
9
  export { getLocation } from './location/index.js';
10
+ export { disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal } from './interaction/index.js';
9
11
  export { showToast } from './show-toast/index.js';
10
12
  export { createMapContext } from './map/index.js';
11
13
  export { createSelectorQuery } from './create-selector-query/index.js';
@@ -0,0 +1,24 @@
1
+ import type Taro from '@tarojs/taro';
2
+ type TaroShowModalOption = NonNullable<Parameters<typeof Taro.showModal>[0]>;
3
+ type TaroShowModalResult = Awaited<ReturnType<typeof Taro.showModal>>;
4
+ type TaroShowLoadingOption = Parameters<typeof Taro.showLoading>[0];
5
+ type TaroShowLoadingResult = Awaited<ReturnType<typeof Taro.showLoading>>;
6
+ type TaroHideToastOption = Parameters<typeof Taro.hideToast>[0];
7
+ type TaroHideToastResult = ReturnType<typeof Taro.hideToast>;
8
+ type TaroHideLoadingOption = Parameters<typeof Taro.hideLoading>[0];
9
+ type TaroHideLoadingResult = ReturnType<typeof Taro.hideLoading>;
10
+ type TaroShowActionSheetOption = Parameters<typeof Taro.showActionSheet>[0];
11
+ type TaroShowActionSheetResult = Awaited<ReturnType<typeof Taro.showActionSheet>>;
12
+ type TaroEnableAlertBeforeUnloadOption = Parameters<typeof Taro.enableAlertBeforeUnload>[0];
13
+ type TaroEnableAlertBeforeUnloadResult = ReturnType<typeof Taro.enableAlertBeforeUnload>;
14
+ type TaroDisableAlertBeforeUnloadOption = Parameters<typeof Taro.disableAlertBeforeUnload>[0];
15
+ type TaroDisableAlertBeforeUnloadResult = ReturnType<typeof Taro.disableAlertBeforeUnload>;
16
+ export declare function showModal(option?: TaroShowModalOption): Promise<TaroShowModalResult>;
17
+ export declare function showLoading(option?: TaroShowLoadingOption): Promise<TaroShowLoadingResult>;
18
+ export declare function hideToast(option?: TaroHideToastOption): TaroHideToastResult;
19
+ export declare function hideLoading(option?: TaroHideLoadingOption): TaroHideLoadingResult;
20
+ export declare function showActionSheet(option: TaroShowActionSheetOption): Promise<TaroShowActionSheetResult>;
21
+ export declare function enableAlertBeforeUnload(option: TaroEnableAlertBeforeUnloadOption): TaroEnableAlertBeforeUnloadResult;
22
+ export declare function disableAlertBeforeUnload(option?: TaroDisableAlertBeforeUnloadOption): TaroDisableAlertBeforeUnloadResult;
23
+ export {};
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { disableAlertBeforeUnload as appDisableAlertBeforeUnload, enableAlertBeforeUnload as appEnableAlertBeforeUnload, hideLoading as appHideLoading, hideToast as appHideToast, showActionSheet as appShowActionSheet, showLoading as appShowLoading, showModal as appShowModal } from '@byted-doubao-apps/framework/api';
2
+ import { buildOkCallbackResult, runCallbackApi, runTaroApi } from '../utils.js';
3
+ function runVoidCallbackApi(apiName, callbacks, run) {
4
+ const task = runCallbackApi(apiName, callbacks, run);
5
+ void task.catch(() => undefined);
6
+ return task;
7
+ }
8
+ function buildShowModalParams(option) {
9
+ const params = {
10
+ content: typeof option?.content === 'string' ? option.content : ''
11
+ };
12
+ if (typeof option?.title === 'string') {
13
+ params.title = option.title;
14
+ }
15
+ if (typeof option?.showCancel === 'boolean') {
16
+ params.showCancel = option.showCancel;
17
+ }
18
+ if (typeof option?.cancelText === 'string') {
19
+ params.cancelText = option.cancelText;
20
+ }
21
+ if (typeof option?.confirmText === 'string') {
22
+ params.confirmText = option.confirmText;
23
+ }
24
+ return params;
25
+ }
26
+ function buildShowModalResult(result) {
27
+ return {
28
+ confirm: result.action === 'confirm',
29
+ cancel: result.action === 'cancel',
30
+ ...buildOkCallbackResult('showModal')
31
+ };
32
+ }
33
+ function buildShowActionSheetParams(option) {
34
+ const params = {
35
+ itemList: Array.isArray(option.itemList) ? option.itemList.filter((item) => typeof item === 'string') : []
36
+ };
37
+ if (typeof option.itemColor === 'string') {
38
+ params.itemColor = option.itemColor;
39
+ }
40
+ return params;
41
+ }
42
+ function buildShowActionSheetResult(result) {
43
+ return {
44
+ tapIndex: typeof result.tapIndex === 'number' ? result.tapIndex : 0,
45
+ ...buildOkCallbackResult('showActionSheet')
46
+ };
47
+ }
48
+ function buildEnableAlertBeforeUnloadParams(option) {
49
+ return {
50
+ message: typeof option.message === 'string' ? option.message : ''
51
+ };
52
+ }
53
+ export async function showModal(option) {
54
+ return runTaroApi('showModal', option, async () => buildShowModalResult(await appShowModal(buildShowModalParams(option))));
55
+ }
56
+ export async function showLoading(option) {
57
+ return runCallbackApi('showLoading', option, () => appShowLoading({}));
58
+ }
59
+ export function hideToast(option) {
60
+ return runVoidCallbackApi('hideToast', option, () => appHideToast(option));
61
+ }
62
+ export function hideLoading(option) {
63
+ return runVoidCallbackApi('hideLoading', option, () => appHideLoading(option));
64
+ }
65
+ export async function showActionSheet(option) {
66
+ return runTaroApi('showActionSheet', option, async () => buildShowActionSheetResult(await appShowActionSheet(buildShowActionSheetParams(option))));
67
+ }
68
+ export function enableAlertBeforeUnload(option) {
69
+ return runVoidCallbackApi('enableAlertBeforeUnload', option, () => appEnableAlertBeforeUnload(buildEnableAlertBeforeUnloadParams(option)));
70
+ }
71
+ export function disableAlertBeforeUnload(option) {
72
+ return runVoidCallbackApi('disableAlertBeforeUnload', option, () => appDisableAlertBeforeUnload({}));
73
+ }
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ import type Taro from '@tarojs/taro';
2
+ type TaroSaveImageToPhotosAlbumOption = Parameters<typeof Taro.saveImageToPhotosAlbum>[0];
3
+ type TaroSaveImageToPhotosAlbumResult = Awaited<ReturnType<typeof Taro.saveImageToPhotosAlbum>>;
4
+ type TaroPreviewImageOption = Parameters<typeof Taro.previewImage>[0];
5
+ type TaroPreviewImageResult = Awaited<ReturnType<typeof Taro.previewImage>>;
6
+ type TaroGetImageInfoOption = Parameters<typeof Taro.getImageInfo>[0];
7
+ type TaroGetImageInfoResult = Awaited<ReturnType<typeof Taro.getImageInfo>>;
8
+ type TaroChooseImageOption = Parameters<typeof Taro.chooseImage>[0];
9
+ type TaroChooseImageResult = Awaited<ReturnType<typeof Taro.chooseImage>>;
10
+ type TaroCompressImageOption = Parameters<typeof Taro.compressImage>[0];
11
+ type TaroCompressImageResult = Awaited<ReturnType<typeof Taro.compressImage>>;
12
+ export declare function saveImageToPhotosAlbum(option: TaroSaveImageToPhotosAlbumOption): Promise<TaroSaveImageToPhotosAlbumResult>;
13
+ export declare function previewImage(option: TaroPreviewImageOption): Promise<TaroPreviewImageResult>;
14
+ export declare function getImageInfo(option: TaroGetImageInfoOption): Promise<TaroGetImageInfoResult>;
15
+ export declare function chooseImage(option?: TaroChooseImageOption): Promise<TaroChooseImageResult>;
16
+ export declare function compressImage(option: TaroCompressImageOption): Promise<TaroCompressImageResult>;
17
+ export {};
18
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1,62 @@
1
+ import * as appFrameworkApi from '@byted-doubao-apps/framework/api';
2
+ import { buildOkCallbackResult, runCallbackApi, runTaroApi } from '../utils.js';
3
+ function buildGetImageInfoResult(result, src) {
4
+ return {
5
+ height: result.height ?? 0,
6
+ orientation: result.orientation ?? 'up',
7
+ path: result.path ?? src,
8
+ type: result.type ?? '',
9
+ width: result.width ?? 0,
10
+ ...buildOkCallbackResult('getImageInfo')
11
+ };
12
+ }
13
+ function buildChooseImageResult(result) {
14
+ const tempFiles = result.tempFiles ?? result.tempFilePaths.map((path) => ({ path, size: 0 }));
15
+ const tempFilePaths = result.tempFilePaths ?? tempFiles.map((file) => file.path);
16
+ return {
17
+ tempFilePaths,
18
+ tempFiles,
19
+ ...buildOkCallbackResult('chooseImage')
20
+ };
21
+ }
22
+ function buildCompressImageResult(result) {
23
+ return {
24
+ tempFilePath: result.tempFilePath ?? '',
25
+ ...buildOkCallbackResult('compressImage')
26
+ };
27
+ }
28
+ export async function saveImageToPhotosAlbum(option) {
29
+ return runCallbackApi('saveImageToPhotosAlbum', option, () => appFrameworkApi.saveImageToPhotosAlbum({
30
+ filePath: option.filePath
31
+ }));
32
+ }
33
+ export async function previewImage(option) {
34
+ return runCallbackApi('previewImage', option, () => appFrameworkApi.previewImage({
35
+ urls: option.urls,
36
+ current: option.current,
37
+ showmenu: option.showmenu,
38
+ referrerPolicy: option.referrerPolicy
39
+ }));
40
+ }
41
+ export async function getImageInfo(option) {
42
+ return runTaroApi('getImageInfo', option, async () => buildGetImageInfoResult(await appFrameworkApi.getImageInfo({
43
+ src: option.src
44
+ }), option.src));
45
+ }
46
+ export async function chooseImage(option = {}) {
47
+ return runTaroApi('chooseImage', option, async () => buildChooseImageResult(await appFrameworkApi.chooseImage({
48
+ count: option.count,
49
+ sizeType: option.sizeType,
50
+ sourceType: option.sourceType,
51
+ imageId: option.imageId
52
+ })));
53
+ }
54
+ export async function compressImage(option) {
55
+ return runTaroApi('compressImage', option, async () => buildCompressImageResult(await appFrameworkApi.compressImage({
56
+ src: option.src,
57
+ quality: option.quality,
58
+ compressedWidth: option.compressedWidth,
59
+ compressedHeight: option.compressedHeight
60
+ })));
61
+ }
62
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1,2 @@
1
+ export * from './image.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './image.js';
2
+ //# sourceMappingURL=index.js.map
@@ -9,16 +9,21 @@ type TaroGetScreenBrightnessOption = Parameters<typeof taroGetScreenBrightness>[
9
9
  type TaroGetScreenBrightnessResult = Awaited<ReturnType<typeof taroGetScreenBrightness>>;
10
10
  type TaroSetClipboardDataOption = Parameters<typeof Taro.setClipboardData>[0];
11
11
  type TaroSetClipboardDataResult = Awaited<ReturnType<typeof Taro.setClipboardData>>;
12
+ type TaroMenuButtonBoundingClientRect = ReturnType<typeof Taro.getMenuButtonBoundingClientRect>;
12
13
  type KeyboardHeightChangeCallback = Parameters<typeof Taro.onKeyboardHeightChange>[0];
14
+ type NetworkStatusChangeCallback = Parameters<typeof Taro.onNetworkStatusChange>[0];
13
15
  export declare function getSystemSetting(): Taro.getSystemSetting.Result;
14
16
  export declare function getAppAuthorizeSetting(): Taro.getAppAuthorizeSetting.Result;
15
17
  export declare function getDeviceInfo(): Taro.getDeviceInfo.Result;
16
18
  export declare function getAppBaseInfo(): Taro.getAppBaseInfo.Result;
17
19
  export declare function getWindowInfo(): Taro.getWindowInfo.Result;
20
+ export declare function getMenuButtonBoundingClientRect(): TaroMenuButtonBoundingClientRect;
18
21
  export declare function makePhoneCall(option: TaroMakePhoneCallOption): Promise<TaroMakePhoneCallResult>;
19
22
  export declare function getNetworkType(option?: TaroGetNetworkTypeOption): Promise<TaroGetNetworkTypeResult>;
20
23
  export declare function getScreenBrightness(option?: TaroGetScreenBrightnessOption): Promise<TaroGetScreenBrightnessResult>;
21
24
  export declare function setClipboardData(option: TaroSetClipboardDataOption): Promise<TaroSetClipboardDataResult>;
22
25
  export declare function onKeyboardHeightChange(callback: KeyboardHeightChangeCallback): void;
26
+ export declare function onNetworkStatusChange(callback: NetworkStatusChangeCallback): void;
27
+ export declare function offNetworkStatusChange(callback?: NetworkStatusChangeCallback): void;
23
28
  export {};
24
29
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
- import { getAppBaseInfoSync, getWindowInfoSync, makePhoneCall as appMakePhoneCall, getNetworkType as appGetNetworkType, getScreenBrightness as appGetScreenBrightness, setClipboardData as appSetClipboardData, onKeyboardHeightChange as appOnKeyboardHeightChange } from '@byted-doubao-apps/framework/api';
1
+ import { getAppBaseInfoSync, getMenuButtonBoundingClientRect as appGetMenuButtonBoundingClientRect, getSystemSetting as appGetSystemSetting, getWindowInfoSync, makePhoneCall as appMakePhoneCall, getNetworkType as appGetNetworkType, onNetworkStatusChange as appOnNetworkStatusChange, getScreenBrightness as appGetScreenBrightness, setClipboardData as appSetClipboardData, onKeyboardHeightChange as appOnKeyboardHeightChange } from '@byted-doubao-apps/framework/api';
2
2
  import { buildFailCallbackResult, emitFailure, runCallbackApi, runTaroApi } from '../utils.js';
3
+ const networkStatusChangeCallbacks = new Map();
3
4
  function buildVibrateShortParams(option) {
4
5
  if (option?.type === 'heavy' || option?.type === 'medium' || option?.type === 'light') {
5
6
  return { type: option.type };
@@ -7,7 +8,21 @@ function buildVibrateShortParams(option) {
7
8
  return { type: 'medium' };
8
9
  }
9
10
  export function getSystemSetting() {
10
- return {};
11
+ const result = appGetSystemSetting();
12
+ const systemSetting = {};
13
+ if (typeof result.bluetoothEnabled === 'boolean') {
14
+ systemSetting.bluetoothEnabled = result.bluetoothEnabled;
15
+ }
16
+ if (typeof result.locationEnabled === 'boolean') {
17
+ systemSetting.locationEnabled = result.locationEnabled;
18
+ }
19
+ if (typeof result.wifiEnabled === 'boolean') {
20
+ systemSetting.wifiEnabled = result.wifiEnabled;
21
+ }
22
+ if (result.deviceOrientation === 'portrait' || result.deviceOrientation === 'landscape') {
23
+ systemSetting.deviceOrientation = result.deviceOrientation;
24
+ }
25
+ return systemSetting;
11
26
  }
12
27
  export function getAppAuthorizeSetting() {
13
28
  return {
@@ -41,6 +56,9 @@ export function getAppBaseInfo() {
41
56
  export function getWindowInfo() {
42
57
  return getWindowInfoSync();
43
58
  }
59
+ export function getMenuButtonBoundingClientRect() {
60
+ return appGetMenuButtonBoundingClientRect();
61
+ }
44
62
  export async function makePhoneCall(option) {
45
63
  const { phoneNumber } = option;
46
64
  if (typeof phoneNumber !== 'string' || phoneNumber.length === 0) {
@@ -102,4 +120,33 @@ export function onKeyboardHeightChange(callback) {
102
120
  });
103
121
  });
104
122
  }
123
+ export function onNetworkStatusChange(callback) {
124
+ if (typeof callback !== 'function' || networkStatusChangeCallbacks.has(callback)) {
125
+ return;
126
+ }
127
+ const unregister = appOnNetworkStatusChange((event) => {
128
+ callback({
129
+ isConnected: event.isConnected,
130
+ networkType: event.networkType,
131
+ errMsg: 'onNetworkStatusChange:ok'
132
+ });
133
+ });
134
+ networkStatusChangeCallbacks.set(callback, unregister);
135
+ }
136
+ export function offNetworkStatusChange(callback) {
137
+ if (typeof callback === 'function') {
138
+ const unregister = networkStatusChangeCallbacks.get(callback);
139
+ if (!unregister) {
140
+ return;
141
+ }
142
+ unregister();
143
+ networkStatusChangeCallbacks.delete(callback);
144
+ return;
145
+ }
146
+ if (callback !== undefined) {
147
+ return;
148
+ }
149
+ networkStatusChangeCallbacks.forEach((unregister) => unregister());
150
+ networkStatusChangeCallbacks.clear();
151
+ }
105
152
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -37,7 +37,7 @@
37
37
  "access": "public",
38
38
  "registry": "https://registry.npmjs.org/"
39
39
  },
40
- "version": "0.0.25",
40
+ "version": "0.0.26",
41
41
  "scripts": {
42
42
  "dev": "npm run build -- -w",
43
43
  "build": "rimraf dist bundle && tsc -p tsconfig.build.json",
@@ -1,11 +0,0 @@
1
- import type Taro from '@tarojs/taro';
2
- type TaroStartHCEOption = Taro.startHCE.Option;
3
- type TaroStopHCEOption = Taro.stopHCE.Option;
4
- type TaroSendHCEMessageOption = Taro.sendHCEMessage.Option;
5
- type TaroGetHCEStateOption = Taro.getHCEState.Option;
6
- export declare function startHCE(option: TaroStartHCEOption): Promise<TaroGeneral.CallbackResult>;
7
- export declare function stopHCE(option?: TaroStopHCEOption): Promise<TaroGeneral.CallbackResult>;
8
- export declare function sendHCEMessage(option: TaroSendHCEMessageOption): Promise<TaroGeneral.CallbackResult>;
9
- export declare function getHCEState(option?: TaroGetHCEStateOption): Promise<TaroGeneral.CallbackResult>;
10
- export {};
11
- //# sourceMappingURL=hce.d.ts.map
@@ -1,19 +0,0 @@
1
- import * as appFrameworkApi from '@byted-doubao-apps/framework/api';
2
- import { runCallbackApi } from '../utils.js';
3
- export async function startHCE(option) {
4
- return runCallbackApi('startHCE', option, () => appFrameworkApi.startHCE({
5
- aidList: option.aid_list
6
- }));
7
- }
8
- export async function stopHCE(option) {
9
- return runCallbackApi('stopHCE', option, () => appFrameworkApi.stopHCE({}));
10
- }
11
- export async function sendHCEMessage(option) {
12
- return runCallbackApi('sendHCEMessage', option, () => appFrameworkApi.sendHCEMessage({
13
- data: option.data
14
- }));
15
- }
16
- export async function getHCEState(option) {
17
- return runCallbackApi('getHCEState', option, () => appFrameworkApi.getHCEState({}));
18
- }
19
- //# sourceMappingURL=hce.js.map