assistsx-js 0.1.41 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +32 -0
  2. package/dist/index.cjs +7957 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.mts +4231 -0
  5. package/dist/index.d.ts +4231 -30
  6. package/dist/index.global.js +46 -0
  7. package/dist/index.global.js.map +1 -0
  8. package/dist/index.js +7879 -30
  9. package/dist/index.js.map +1 -0
  10. package/package.json +11 -5
  11. package/src/{AssistsXAsync.ts → assistsx-async.ts} +8 -8
  12. package/src/{AssistsX.ts → assistsx.ts} +8 -8
  13. package/src/barutils/bar-utils.ts +3 -3
  14. package/src/filesystem/fileio/file-io.ts +2 -2
  15. package/src/filesystem/fileutils/file-utils.ts +2 -2
  16. package/src/filesystem/path.ts +2 -2
  17. package/src/floatingwindow/float.ts +4 -4
  18. package/src/gallery/gallery.ts +2 -2
  19. package/src/global.d.ts +6 -1
  20. package/src/imageutils/image-utils.ts +2 -2
  21. package/src/ime/ime.ts +2 -2
  22. package/src/index.ts +21 -20
  23. package/src/log/log-call-method.ts +28 -0
  24. package/src/log/log.ts +445 -0
  25. package/src/mlkit/mlkit.ts +3 -3
  26. package/src/network/http.ts +2 -2
  27. package/src/{NodeAsync.ts → node-async.ts} +5 -5
  28. package/src/{Node.ts → node.ts} +5 -5
  29. package/src/{StepAsync.ts → step-async.ts} +8 -8
  30. package/src/{Step.ts → step.ts} +7 -7
  31. package/dist/AccessibilityEventFilter.d.ts +0 -105
  32. package/dist/AccessibilityEventFilter.js +0 -89
  33. package/dist/AppInfo.d.ts +0 -45
  34. package/dist/AppInfo.js +0 -38
  35. package/dist/AssistsX.d.ts +0 -484
  36. package/dist/AssistsX.js +0 -828
  37. package/dist/AssistsXAsync.d.ts +0 -532
  38. package/dist/AssistsXAsync.js +0 -874
  39. package/dist/Bounds.d.ts +0 -48
  40. package/dist/Bounds.js +0 -68
  41. package/dist/CallMethod.d.ts +0 -69
  42. package/dist/CallMethod.js +0 -71
  43. package/dist/CallResponse.d.ts +0 -10
  44. package/dist/CallResponse.js +0 -28
  45. package/dist/DeviceInfo.d.ts +0 -69
  46. package/dist/DeviceInfo.js +0 -50
  47. package/dist/Node.d.ts +0 -334
  48. package/dist/Node.js +0 -369
  49. package/dist/NodeAsync.d.ts +0 -213
  50. package/dist/NodeAsync.js +0 -313
  51. package/dist/NodeClassValue.d.ts +0 -15
  52. package/dist/NodeClassValue.js +0 -15
  53. package/dist/Step.d.ts +0 -355
  54. package/dist/Step.js +0 -689
  55. package/dist/StepAsync.d.ts +0 -162
  56. package/dist/StepAsync.js +0 -264
  57. package/dist/StepError.d.ts +0 -35
  58. package/dist/StepError.js +0 -26
  59. package/dist/StepStateStore.d.ts +0 -14
  60. package/dist/StepStateStore.js +0 -37
  61. package/dist/Utils.d.ts +0 -3
  62. package/dist/Utils.js +0 -20
  63. package/dist/WindowFlags.d.ts +0 -75
  64. package/dist/WindowFlags.js +0 -97
  65. package/dist/barutils/BarUtilsCallMethod.d.ts +0 -24
  66. package/dist/barutils/BarUtilsCallMethod.js +0 -26
  67. package/dist/barutils/bar-utils.d.ts +0 -41
  68. package/dist/barutils/bar-utils.js +0 -205
  69. package/dist/filesystem/fileio/file-io.d.ts +0 -101
  70. package/dist/filesystem/fileio/file-io.js +0 -235
  71. package/dist/filesystem/fileutils/file-utils.d.ts +0 -242
  72. package/dist/filesystem/fileutils/file-utils.js +0 -493
  73. package/dist/filesystem/path.d.ts +0 -252
  74. package/dist/filesystem/path.js +0 -589
  75. package/dist/floatingwindow/FloatCallMethod.d.ts +0 -19
  76. package/dist/floatingwindow/FloatCallMethod.js +0 -18
  77. package/dist/floatingwindow/float.d.ts +0 -29
  78. package/dist/floatingwindow/float.js +0 -149
  79. package/dist/gallery/gallery.d.ts +0 -60
  80. package/dist/gallery/gallery.js +0 -142
  81. package/dist/imageutils/image-utils.d.ts +0 -442
  82. package/dist/imageutils/image-utils.js +0 -543
  83. package/dist/ime/ime.d.ts +0 -80
  84. package/dist/ime/ime.js +0 -141
  85. package/dist/mlkit/MlkitCallMethod.d.ts +0 -27
  86. package/dist/mlkit/MlkitCallMethod.js +0 -26
  87. package/dist/mlkit/mlkit.d.ts +0 -86
  88. package/dist/mlkit/mlkit.js +0 -169
  89. package/dist/network/http.d.ts +0 -127
  90. package/dist/network/http.js +0 -202
  91. /package/src/{AccessibilityEventFilter.ts → accessibility-event-filter.ts} +0 -0
  92. /package/src/{AppInfo.ts → app-info.ts} +0 -0
  93. /package/src/barutils/{BarUtilsCallMethod.ts → bar-utils-call-method.ts} +0 -0
  94. /package/src/{Bounds.ts → bounds.ts} +0 -0
  95. /package/src/{CallMethod.ts → call-method.ts} +0 -0
  96. /package/src/{CallResponse.ts → call-response.ts} +0 -0
  97. /package/src/{DeviceInfo.ts → device-info.ts} +0 -0
  98. /package/src/floatingwindow/{FloatCallMethod.ts → float-call-method.ts} +0 -0
  99. /package/src/mlkit/{MlkitCallMethod.ts → mlkit-call-method.ts} +0 -0
  100. /package/src/{NodeClassValue.ts → node-class-value.ts} +0 -0
  101. /package/src/{StepError.ts → step-error.ts} +0 -0
  102. /package/src/{StepStateStore.ts → step-state-store.ts} +0 -0
  103. /package/src/{Utils.ts → utils.ts} +0 -0
  104. /package/src/{WindowFlags.ts → window-flags.ts} +0 -0
@@ -1,97 +0,0 @@
1
- /**
2
- * 窗口标志位常量类
3
- * 定义了各种窗口行为和属性的标志位
4
- */
5
- export class WindowFlags {
6
- /**
7
- * 获取标志位的十六进制表示
8
- * @param flag 标志位值
9
- * @returns 十六进制字符串
10
- */
11
- static toHex(flag) {
12
- return `0x${flag.toString(16).toUpperCase()}`;
13
- }
14
- /**
15
- * 检查是否包含指定标志位
16
- * @param flags 当前标志位组合
17
- * @param flag 要检查的标志位
18
- * @returns 是否包含该标志位
19
- */
20
- static hasFlag(flags, flag) {
21
- return (flags & flag) === flag;
22
- }
23
- /**
24
- * 添加标志位
25
- * @param flags 当前标志位组合
26
- * @param flag 要添加的标志位
27
- * @returns 新的标志位组合
28
- */
29
- static addFlag(flags, flag) {
30
- return flags | flag;
31
- }
32
- /**
33
- * 移除标志位
34
- * @param flags 当前标志位组合
35
- * @param flag 要移除的标志位
36
- * @returns 新的标志位组合
37
- */
38
- static removeFlag(flags, flag) {
39
- return flags & ~flag;
40
- }
41
- /**
42
- * 获取所有标志位的描述信息
43
- * @returns 标志位描述对象数组
44
- */
45
- static getAllFlags() {
46
- return [
47
- { name: 'FLAG_NOT_FOCUSABLE', value: this.FLAG_NOT_FOCUSABLE, hex: this.toHex(this.FLAG_NOT_FOCUSABLE), description: '不获取焦点' },
48
- { name: 'FLAG_NOT_TOUCHABLE', value: this.FLAG_NOT_TOUCHABLE, hex: this.toHex(this.FLAG_NOT_TOUCHABLE), description: '不响应触摸' },
49
- { name: 'FLAG_NOT_TOUCH_MODAL', value: this.FLAG_NOT_TOUCH_MODAL, hex: this.toHex(this.FLAG_NOT_TOUCH_MODAL), description: '不拦截触摸' },
50
- { name: 'FLAG_WATCH_OUTSIDE_TOUCH', value: this.FLAG_WATCH_OUTSIDE_TOUCH, hex: this.toHex(this.FLAG_WATCH_OUTSIDE_TOUCH), description: '监听窗外点击' },
51
- { name: 'FLAG_LAYOUT_NO_LIMITS', value: this.FLAG_LAYOUT_NO_LIMITS, hex: this.toHex(this.FLAG_LAYOUT_NO_LIMITS), description: '可绘制超出屏幕' },
52
- { name: 'FLAG_LAYOUT_IN_SCREEN', value: this.FLAG_LAYOUT_IN_SCREEN, hex: this.toHex(this.FLAG_LAYOUT_IN_SCREEN), description: '屏幕全区域布局' },
53
- { name: 'FLAG_FULLSCREEN', value: this.FLAG_FULLSCREEN, hex: this.toHex(this.FLAG_FULLSCREEN), description: '全屏显示' },
54
- { name: 'FLAG_DIM_BEHIND', value: this.FLAG_DIM_BEHIND, hex: this.toHex(this.FLAG_DIM_BEHIND), description: '背景变暗' },
55
- { name: 'FLAG_SECURE', value: this.FLAG_SECURE, hex: this.toHex(this.FLAG_SECURE), description: '防录屏防截图' },
56
- { name: 'FLAG_KEEP_SCREEN_ON', value: this.FLAG_KEEP_SCREEN_ON, hex: this.toHex(this.FLAG_KEEP_SCREEN_ON), description: '保持常亮' },
57
- { name: 'FLAG_SHOW_WHEN_LOCKED', value: this.FLAG_SHOW_WHEN_LOCKED, hex: this.toHex(this.FLAG_SHOW_WHEN_LOCKED), description: '锁屏时可见' },
58
- { name: 'FLAG_DISMISS_KEYGUARD', value: this.FLAG_DISMISS_KEYGUARD, hex: this.toHex(this.FLAG_DISMISS_KEYGUARD), description: '解锁屏幕' },
59
- { name: 'FLAG_TURN_SCREEN_ON', value: this.FLAG_TURN_SCREEN_ON, hex: this.toHex(this.FLAG_TURN_SCREEN_ON), description: '点亮屏幕' },
60
- { name: 'FLAG_ALLOW_LOCK_WHILE_SCREEN_ON', value: this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, hex: this.toHex(this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON), description: '自动锁屏(不常用)' },
61
- { name: 'FLAG_SHOW_WALLPAPER', value: this.FLAG_SHOW_WALLPAPER, hex: this.toHex(this.FLAG_SHOW_WALLPAPER), description: '显示墙纸' },
62
- { name: 'FLAG_HARDWARE_ACCELERATED', value: this.FLAG_HARDWARE_ACCELERATED, hex: this.toHex(this.FLAG_HARDWARE_ACCELERATED), description: '强制硬件加速' }
63
- ];
64
- }
65
- }
66
- /** 不获取焦点 */
67
- WindowFlags.FLAG_NOT_FOCUSABLE = 8; // 0x08
68
- /** 不响应触摸 */
69
- WindowFlags.FLAG_NOT_TOUCHABLE = 16; // 0x10
70
- /** 不拦截触摸 */
71
- WindowFlags.FLAG_NOT_TOUCH_MODAL = 32; // 0x20
72
- /** 监听窗外点击 */
73
- WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH = 4; // 0x04
74
- /** 可绘制超出屏幕 */
75
- WindowFlags.FLAG_LAYOUT_NO_LIMITS = 512; // 0x200
76
- /** 屏幕全区域布局 */
77
- WindowFlags.FLAG_LAYOUT_IN_SCREEN = 256; // 0x100
78
- /** 全屏显示 */
79
- WindowFlags.FLAG_FULLSCREEN = 1024; // 0x400
80
- /** 背景变暗 */
81
- WindowFlags.FLAG_DIM_BEHIND = 2; // 0x02
82
- /** 防录屏防截图 */
83
- WindowFlags.FLAG_SECURE = 8192; // 0x2000
84
- /** 保持常亮 */
85
- WindowFlags.FLAG_KEEP_SCREEN_ON = 128; // 0x80
86
- /** 锁屏时可见 */
87
- WindowFlags.FLAG_SHOW_WHEN_LOCKED = 524288; // 0x80000
88
- /** 解锁屏幕 */
89
- WindowFlags.FLAG_DISMISS_KEYGUARD = 4194304; // 0x400000
90
- /** 点亮屏幕 */
91
- WindowFlags.FLAG_TURN_SCREEN_ON = 2097152; // 0x200000
92
- /** 自动锁屏(不常用) */
93
- WindowFlags.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 128; // 0x80
94
- /** 显示墙纸 */
95
- WindowFlags.FLAG_SHOW_WALLPAPER = 1048576; // 0x100000
96
- /** 强制硬件加速 */
97
- WindowFlags.FLAG_HARDWARE_ACCELERATED = 16777216; // 0x1000000
@@ -1,24 +0,0 @@
1
- /**
2
- * Bar utils (status bar, nav bar, action bar) method constants.
3
- * Matches BarUtilsCallMethod in Kotlin.
4
- */
5
- export declare const BarUtilsCallMethod: {
6
- readonly getStatusBarHeight: "getStatusBarHeight";
7
- readonly setStatusBarVisibility: "setStatusBarVisibility";
8
- readonly isStatusBarVisible: "isStatusBarVisible";
9
- readonly setStatusBarLightMode: "setStatusBarLightMode";
10
- readonly isStatusBarLightMode: "isStatusBarLightMode";
11
- readonly setStatusBarColor: "setStatusBarColor";
12
- readonly transparentStatusBar: "transparentStatusBar";
13
- readonly getActionBarHeight: "getActionBarHeight";
14
- readonly getNavBarHeight: "getNavBarHeight";
15
- readonly setNavBarVisibility: "setNavBarVisibility";
16
- readonly isNavBarVisible: "isNavBarVisible";
17
- readonly setNavBarColor: "setNavBarColor";
18
- readonly getNavBarColor: "getNavBarColor";
19
- readonly isSupportNavBar: "isSupportNavBar";
20
- readonly setNavBarLightMode: "setNavBarLightMode";
21
- readonly isNavBarLightMode: "isNavBarLightMode";
22
- readonly transparentNavBar: "transparentNavBar";
23
- };
24
- export type BarUtilsCallMethodType = (typeof BarUtilsCallMethod)[keyof typeof BarUtilsCallMethod];
@@ -1,26 +0,0 @@
1
- /**
2
- * Bar utils (status bar, nav bar, action bar) method constants.
3
- * Matches BarUtilsCallMethod in Kotlin.
4
- */
5
- export const BarUtilsCallMethod = {
6
- // Status bar
7
- getStatusBarHeight: "getStatusBarHeight",
8
- setStatusBarVisibility: "setStatusBarVisibility",
9
- isStatusBarVisible: "isStatusBarVisible",
10
- setStatusBarLightMode: "setStatusBarLightMode",
11
- isStatusBarLightMode: "isStatusBarLightMode",
12
- setStatusBarColor: "setStatusBarColor",
13
- transparentStatusBar: "transparentStatusBar",
14
- // ActionBar
15
- getActionBarHeight: "getActionBarHeight",
16
- // Nav bar
17
- getNavBarHeight: "getNavBarHeight",
18
- setNavBarVisibility: "setNavBarVisibility",
19
- isNavBarVisible: "isNavBarVisible",
20
- setNavBarColor: "setNavBarColor",
21
- getNavBarColor: "getNavBarColor",
22
- isSupportNavBar: "isSupportNavBar",
23
- setNavBarLightMode: "setNavBarLightMode",
24
- isNavBarLightMode: "isNavBarLightMode",
25
- transparentNavBar: "transparentNavBar",
26
- };
@@ -1,41 +0,0 @@
1
- export declare class BarUtils {
2
- private asyncCall;
3
- private errorMessage;
4
- /** Get status bar height in px. */
5
- getStatusBarHeight(timeout?: number): Promise<number>;
6
- /** Set status bar visibility. */
7
- setStatusBarVisibility(isVisible?: boolean, timeout?: number): Promise<void>;
8
- /** Check if status bar is visible. */
9
- isStatusBarVisible(timeout?: number): Promise<boolean>;
10
- /** Set status bar light mode (light content on dark background). */
11
- setStatusBarLightMode(isLightMode?: boolean, timeout?: number): Promise<void>;
12
- /** Check if status bar is in light mode. */
13
- isStatusBarLightMode(timeout?: number): Promise<boolean>;
14
- /** Set status bar color. color: Android color int (e.g. 0xff0000). isDecor: whether to apply to decor. */
15
- setStatusBarColor(color: number, options?: {
16
- isDecor?: boolean;
17
- }, timeout?: number): Promise<void>;
18
- /** Make status bar transparent. */
19
- transparentStatusBar(timeout?: number): Promise<void>;
20
- /** Get action bar height in px. */
21
- getActionBarHeight(timeout?: number): Promise<number>;
22
- /** Get navigation bar height in px. */
23
- getNavBarHeight(timeout?: number): Promise<number>;
24
- /** Set navigation bar visibility. */
25
- setNavBarVisibility(isVisible?: boolean, timeout?: number): Promise<void>;
26
- /** Check if navigation bar is visible. */
27
- isNavBarVisible(timeout?: number): Promise<boolean>;
28
- /** Set navigation bar color. color: Android color int. */
29
- setNavBarColor(color: number, timeout?: number): Promise<void>;
30
- /** Get current navigation bar color. */
31
- getNavBarColor(timeout?: number): Promise<number>;
32
- /** Check if device supports navigation bar. */
33
- isSupportNavBar(timeout?: number): Promise<boolean>;
34
- /** Set navigation bar light mode. */
35
- setNavBarLightMode(isLightMode?: boolean, timeout?: number): Promise<void>;
36
- /** Check if navigation bar is in light mode. */
37
- isNavBarLightMode(timeout?: number): Promise<boolean>;
38
- /** Make navigation bar transparent. */
39
- transparentNavBar(timeout?: number): Promise<void>;
40
- }
41
- export declare const barUtils: BarUtils;
@@ -1,205 +0,0 @@
1
- /**
2
- * Bar utils (status bar, nav bar, action bar) for WebView.
3
- * Requires Activity context on native side. Matches BarUtilsJavascriptInterface.kt.
4
- */
5
- import { CallResponse } from "../CallResponse";
6
- import { decodeBase64UTF8, generateUUID } from "../Utils";
7
- import { BarUtilsCallMethod } from "./BarUtilsCallMethod";
8
- const callbacks = new Map();
9
- if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
10
- window.assistsxBarUtilsCallback = (data) => {
11
- let callbackId;
12
- try {
13
- const json = decodeBase64UTF8(data);
14
- const response = JSON.parse(json);
15
- callbackId = response.callbackId;
16
- if (callbackId) {
17
- const callback = callbacks.get(callbackId);
18
- if (callback) {
19
- callback(json);
20
- }
21
- }
22
- }
23
- catch (e) {
24
- console.error("BarUtils callback error:", e);
25
- }
26
- finally {
27
- if (callbackId) {
28
- callbacks.delete(callbackId);
29
- }
30
- }
31
- };
32
- }
33
- export class BarUtils {
34
- async asyncCall(method, args, timeout = 30) {
35
- const uuid = generateUUID();
36
- const params = {
37
- method,
38
- arguments: args !== null && args !== void 0 ? args : undefined,
39
- callbackId: uuid,
40
- };
41
- const promise = new Promise((resolve) => {
42
- callbacks.set(uuid, (data) => {
43
- resolve(data);
44
- });
45
- setTimeout(() => {
46
- callbacks.delete(uuid);
47
- resolve(JSON.stringify(new CallResponse(-1, { message: "Timeout" }, uuid)));
48
- }, timeout * 1000);
49
- });
50
- window.assistsxBarUtils.call(JSON.stringify(params));
51
- const promiseResult = await promise;
52
- if (typeof promiseResult === "string") {
53
- const responseData = JSON.parse(promiseResult);
54
- const data = responseData.code !== 0 && responseData.message != null
55
- ? { message: responseData.message }
56
- : responseData.data;
57
- return new CallResponse(responseData.code, data, responseData.callbackId);
58
- }
59
- throw new Error("BarUtils call failed");
60
- }
61
- errorMessage(res, fallback) {
62
- const d = res.getDataOrNull();
63
- if (d &&
64
- typeof d === "object" &&
65
- typeof d.message === "string") {
66
- return d.message;
67
- }
68
- if (typeof d === "string")
69
- return d;
70
- return fallback;
71
- }
72
- // --- Status bar ---
73
- /** Get status bar height in px. */
74
- async getStatusBarHeight(timeout) {
75
- const res = await this.asyncCall(BarUtilsCallMethod.getStatusBarHeight, undefined, timeout);
76
- if (!res.isSuccess()) {
77
- throw new Error(this.errorMessage(res, "getStatusBarHeight failed"));
78
- }
79
- return res.getData().height;
80
- }
81
- /** Set status bar visibility. */
82
- async setStatusBarVisibility(isVisible = true, timeout) {
83
- const res = await this.asyncCall(BarUtilsCallMethod.setStatusBarVisibility, { isVisible }, timeout);
84
- if (!res.isSuccess()) {
85
- throw new Error(this.errorMessage(res, "setStatusBarVisibility failed"));
86
- }
87
- }
88
- /** Check if status bar is visible. */
89
- async isStatusBarVisible(timeout) {
90
- const res = await this.asyncCall(BarUtilsCallMethod.isStatusBarVisible, undefined, timeout);
91
- if (!res.isSuccess()) {
92
- throw new Error(this.errorMessage(res, "isStatusBarVisible failed"));
93
- }
94
- return res.getData().visible;
95
- }
96
- /** Set status bar light mode (light content on dark background). */
97
- async setStatusBarLightMode(isLightMode = true, timeout) {
98
- const res = await this.asyncCall(BarUtilsCallMethod.setStatusBarLightMode, { isLightMode }, timeout);
99
- if (!res.isSuccess()) {
100
- throw new Error(this.errorMessage(res, "setStatusBarLightMode failed"));
101
- }
102
- }
103
- /** Check if status bar is in light mode. */
104
- async isStatusBarLightMode(timeout) {
105
- const res = await this.asyncCall(BarUtilsCallMethod.isStatusBarLightMode, undefined, timeout);
106
- if (!res.isSuccess()) {
107
- throw new Error(this.errorMessage(res, "isStatusBarLightMode failed"));
108
- }
109
- return res.getData().isLightMode;
110
- }
111
- /** Set status bar color. color: Android color int (e.g. 0xff0000). isDecor: whether to apply to decor. */
112
- async setStatusBarColor(color, options, timeout) {
113
- var _a;
114
- const res = await this.asyncCall(BarUtilsCallMethod.setStatusBarColor, { color, isDecor: (_a = options === null || options === void 0 ? void 0 : options.isDecor) !== null && _a !== void 0 ? _a : false }, timeout);
115
- if (!res.isSuccess()) {
116
- throw new Error(this.errorMessage(res, "setStatusBarColor failed"));
117
- }
118
- }
119
- /** Make status bar transparent. */
120
- async transparentStatusBar(timeout) {
121
- const res = await this.asyncCall(BarUtilsCallMethod.transparentStatusBar, undefined, timeout);
122
- if (!res.isSuccess()) {
123
- throw new Error(this.errorMessage(res, "transparentStatusBar failed"));
124
- }
125
- }
126
- // --- ActionBar ---
127
- /** Get action bar height in px. */
128
- async getActionBarHeight(timeout) {
129
- const res = await this.asyncCall(BarUtilsCallMethod.getActionBarHeight, undefined, timeout);
130
- if (!res.isSuccess()) {
131
- throw new Error(this.errorMessage(res, "getActionBarHeight failed"));
132
- }
133
- return res.getData().height;
134
- }
135
- // --- Nav bar ---
136
- /** Get navigation bar height in px. */
137
- async getNavBarHeight(timeout) {
138
- const res = await this.asyncCall(BarUtilsCallMethod.getNavBarHeight, undefined, timeout);
139
- if (!res.isSuccess()) {
140
- throw new Error(this.errorMessage(res, "getNavBarHeight failed"));
141
- }
142
- return res.getData().height;
143
- }
144
- /** Set navigation bar visibility. */
145
- async setNavBarVisibility(isVisible = true, timeout) {
146
- const res = await this.asyncCall(BarUtilsCallMethod.setNavBarVisibility, { isVisible }, timeout);
147
- if (!res.isSuccess()) {
148
- throw new Error(this.errorMessage(res, "setNavBarVisibility failed"));
149
- }
150
- }
151
- /** Check if navigation bar is visible. */
152
- async isNavBarVisible(timeout) {
153
- const res = await this.asyncCall(BarUtilsCallMethod.isNavBarVisible, undefined, timeout);
154
- if (!res.isSuccess()) {
155
- throw new Error(this.errorMessage(res, "isNavBarVisible failed"));
156
- }
157
- return res.getData().visible;
158
- }
159
- /** Set navigation bar color. color: Android color int. */
160
- async setNavBarColor(color, timeout) {
161
- const res = await this.asyncCall(BarUtilsCallMethod.setNavBarColor, { color }, timeout);
162
- if (!res.isSuccess()) {
163
- throw new Error(this.errorMessage(res, "setNavBarColor failed"));
164
- }
165
- }
166
- /** Get current navigation bar color. */
167
- async getNavBarColor(timeout) {
168
- const res = await this.asyncCall(BarUtilsCallMethod.getNavBarColor, undefined, timeout);
169
- if (!res.isSuccess()) {
170
- throw new Error(this.errorMessage(res, "getNavBarColor failed"));
171
- }
172
- return res.getData().color;
173
- }
174
- /** Check if device supports navigation bar. */
175
- async isSupportNavBar(timeout) {
176
- const res = await this.asyncCall(BarUtilsCallMethod.isSupportNavBar, undefined, timeout);
177
- if (!res.isSuccess()) {
178
- throw new Error(this.errorMessage(res, "isSupportNavBar failed"));
179
- }
180
- return res.getData().support;
181
- }
182
- /** Set navigation bar light mode. */
183
- async setNavBarLightMode(isLightMode = true, timeout) {
184
- const res = await this.asyncCall(BarUtilsCallMethod.setNavBarLightMode, { isLightMode }, timeout);
185
- if (!res.isSuccess()) {
186
- throw new Error(this.errorMessage(res, "setNavBarLightMode failed"));
187
- }
188
- }
189
- /** Check if navigation bar is in light mode. */
190
- async isNavBarLightMode(timeout) {
191
- const res = await this.asyncCall(BarUtilsCallMethod.isNavBarLightMode, undefined, timeout);
192
- if (!res.isSuccess()) {
193
- throw new Error(this.errorMessage(res, "isNavBarLightMode failed"));
194
- }
195
- return res.getData().isLightMode;
196
- }
197
- /** Make navigation bar transparent. */
198
- async transparentNavBar(timeout) {
199
- const res = await this.asyncCall(BarUtilsCallMethod.transparentNavBar, undefined, timeout);
200
- if (!res.isSuccess()) {
201
- throw new Error(this.errorMessage(res, "transparentNavBar failed"));
202
- }
203
- }
204
- }
205
- export const barUtils = new BarUtils();
@@ -1,101 +0,0 @@
1
- export declare class FileIO {
2
- /**
3
- * 执行异步调用
4
- * @param method 方法名
5
- * @param args 参数对象
6
- * @param timeout 超时时间(秒),默认30秒
7
- * @returns Promise<调用响应>
8
- */
9
- private asyncCall;
10
- /**
11
- * 从输入流写入文件
12
- * @param filePath 文件路径
13
- * @param inputStreamBase64 Base64 编码的输入流数据
14
- * @param append 是否追加,默认为 false
15
- * @param timeout 超时时间(秒),默认30秒
16
- * @returns Promise<是否成功>
17
- */
18
- writeFileFromIS(filePath: string, inputStreamBase64: string, append?: boolean, timeout?: number): Promise<boolean>;
19
- /**
20
- * 从字节数组写入文件(使用流)
21
- * @param filePath 文件路径
22
- * @param bytesBase64 Base64 编码的字节数组
23
- * @param append 是否追加,默认为 false
24
- * @param timeout 超时时间(秒),默认30秒
25
- * @returns Promise<是否成功>
26
- */
27
- writeFileFromBytesByStream(filePath: string, bytesBase64: string, append?: boolean, timeout?: number): Promise<boolean>;
28
- /**
29
- * 从字节数组写入文件(使用通道)
30
- * @param filePath 文件路径
31
- * @param bytesBase64 Base64 编码的字节数组
32
- * @param append 是否追加,默认为 false
33
- * @param timeout 超时时间(秒),默认30秒
34
- * @returns Promise<是否成功>
35
- */
36
- writeFileFromBytesByChannel(filePath: string, bytesBase64: string, append?: boolean, timeout?: number): Promise<boolean>;
37
- /**
38
- * 从字节数组写入文件(使用内存映射)
39
- * @param filePath 文件路径
40
- * @param bytesBase64 Base64 编码的字节数组
41
- * @param append 是否追加,默认为 false
42
- * @param timeout 超时时间(秒),默认30秒
43
- * @returns Promise<是否成功>
44
- */
45
- writeFileFromBytesByMap(filePath: string, bytesBase64: string, append?: boolean, timeout?: number): Promise<boolean>;
46
- /**
47
- * 从字符串写入文件
48
- * @param filePath 文件路径
49
- * @param content 文件内容
50
- * @param append 是否追加,默认为 false
51
- * @param threadSafe 是否线程安全写入,默认为 false
52
- * @param timeout 超时时间(秒),默认30秒
53
- * @returns Promise<是否成功>
54
- */
55
- writeFileFromString(filePath: string, content: string, append?: boolean, threadSafe?: boolean, timeout?: number): Promise<boolean>;
56
- /**
57
- * 读取文件为字符串列表
58
- * @param filePath 文件路径
59
- * @param charsetName 字符集名称,默认为 "UTF-8"
60
- * @param timeout 超时时间(秒),默认30秒
61
- * @returns Promise<字符串数组>
62
- */
63
- readFile2List(filePath: string, charsetName?: string, timeout?: number): Promise<string[]>;
64
- /**
65
- * 读取文件为字符串
66
- * @param filePath 文件路径
67
- * @param charsetName 字符集名称,默认为 "UTF-8"
68
- * @param timeout 超时时间(秒),默认30秒
69
- * @returns Promise<文件内容字符串>
70
- */
71
- readFile2String(filePath: string, charsetName?: string, timeout?: number): Promise<string>;
72
- /**
73
- * 读取文件为字节数组(使用流)
74
- * @param filePath 文件路径
75
- * @param timeout 超时时间(秒),默认30秒
76
- * @returns Promise<Base64 编码的字节数组>
77
- */
78
- readFile2BytesByStream(filePath: string, timeout?: number): Promise<string>;
79
- /**
80
- * 读取文件为字节数组(使用通道)
81
- * @param filePath 文件路径
82
- * @param timeout 超时时间(秒),默认30秒
83
- * @returns Promise<Base64 编码的字节数组>
84
- */
85
- readFile2BytesByChannel(filePath: string, timeout?: number): Promise<string>;
86
- /**
87
- * 读取文件为字节数组(使用内存映射)
88
- * @param filePath 文件路径
89
- * @param timeout 超时时间(秒),默认30秒
90
- * @returns Promise<Base64 编码的字节数组>
91
- */
92
- readFile2BytesByMap(filePath: string, timeout?: number): Promise<string>;
93
- /**
94
- * 设置缓冲区大小
95
- * @param bufferSize 缓冲区大小(字节)
96
- * @param timeout 超时时间(秒),默认30秒
97
- * @returns Promise<是否成功>
98
- */
99
- setBufferSize(bufferSize: number, timeout?: number): Promise<boolean>;
100
- }
101
- export declare const fileIO: FileIO;