@atomicservice/ascf-base 1.0.11

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 ADDED
@@ -0,0 +1 @@
1
+ # ASCF base
@@ -0,0 +1,330 @@
1
+ import * as log4js from 'log4js';
2
+ import * as child_process from 'child_process';
3
+ import { ChildProcessWithoutNullStreams } from 'child_process';
4
+ import * as http from 'http';
5
+
6
+ declare const ASCF_LOG_FILE: string;
7
+ declare function setLoggerConfig(val: any): void;
8
+ declare function configureLogger(config: any): void;
9
+ declare function setLogLevelGetter(getLogLevel: () => string): void;
10
+ declare function getLogLevelGetter(): () => string;
11
+ declare class Logger {
12
+ categories: string;
13
+ logger: log4js.Logger;
14
+ fileLogger: log4js.Logger | undefined;
15
+ constructor(categories: string);
16
+ doLog(level: any, message: any, args: any, isExit?: boolean): void;
17
+ info(message: any, ...args: any[]): void;
18
+ warn(message: any, ...args: any[]): void;
19
+ debug(message: any, ...args: any[]): void;
20
+ error(message: any, ...args: any[]): void;
21
+ fatal(message: any, ...args: any[]): void;
22
+ }
23
+ declare function getLogger(categories: any): Logger;
24
+
25
+ declare const qsHostPkg = "com.enjoy.now.hmos";
26
+ declare const LEGACY_PKG_NAME = "com.huawei.intelligent/com.huawei.ascf.main.AscfActivity";
27
+ declare const LEGACY_DEVICE = "legacy";
28
+ declare const HOS_DEVICE = "hos";
29
+ declare const DEBUG_TYPE_VIEW = "view";
30
+ declare const DEBUG_TYPE_SERVICE = "service";
31
+
32
+ type BuildModeType = 'debug' | 'release';
33
+ type BuildTargetType = 'atomicservice' | 'crossAtomicService';
34
+ type BuildDeviceType = 'hos' | 'legacy';
35
+ type BuilderOptions = {
36
+ projectRoot?: string;
37
+ deviceId?: string;
38
+ buildMode?: BuildModeType;
39
+ targets?: BuildTargetType;
40
+ deviceType?: BuildDeviceType;
41
+ };
42
+ type DebuggerOptions = {
43
+ open?: '' | 'default' | 'chrome' | 'edge';
44
+ targets?: BuildTargetType;
45
+ deviceType?: BuildDeviceType;
46
+ deviceId?: string;
47
+ bundleName?: string;
48
+ };
49
+ interface IInstallSpkShared {
50
+ logger: any;
51
+ projectRoot: any;
52
+ deviceId: any;
53
+ getSpkInfo: any;
54
+ buildMode: any;
55
+ startServer: any;
56
+ tryAdbPortReversing: any;
57
+ startHostPkgUrl: any;
58
+ rportRmCmd: any;
59
+ legacyPkg?: string;
60
+ }
61
+
62
+ declare function getDebugees(localPort: string | number): Promise<never[]>;
63
+ declare abstract class DebuggerProcess {
64
+ options: DebuggerOptions;
65
+ lastDebugServer: any;
66
+ protected constructor(options: DebuggerOptions);
67
+ handle(subCmd: any): void;
68
+ abstract status(): any;
69
+ abstract start(): any;
70
+ abstract stop(): any;
71
+ abstract startView(): any;
72
+ abstract startService(): any;
73
+ abstract stopView(): any;
74
+ abstract stopService(): any;
75
+ abstract checkAndGetBundleName(): Promise<string | boolean | undefined>;
76
+ openBrowser(type: any, localPort: any, fallback?: string): Promise<void>;
77
+ startDebugServer(url: any): Promise<void>;
78
+ stopDebugServer(): void;
79
+ }
80
+
81
+ declare class AscfDebugger extends DebuggerProcess {
82
+ constructor(options: DebuggerOptions);
83
+ isLegacy(): boolean;
84
+ getPortManager(): {
85
+ webLocalPort: number;
86
+ v8LocalPort: number;
87
+ fportWeb(deviceId: any, bundleName: any): Promise<void>;
88
+ fportV8(deviceId: any): Promise<void>;
89
+ fportRmV8(deviceId: any): Promise<void>;
90
+ fportRmWeb(deviceId: any): Promise<void>;
91
+ fportRm(deviceId: any, localPort: any): Promise<void>;
92
+ status(deviceId: any): Promise<any[]>;
93
+ };
94
+ status(): Promise<void>;
95
+ start(): Promise<void>;
96
+ stop(): Promise<void>;
97
+ startView(): Promise<void>;
98
+ startService(): Promise<void>;
99
+ stopView(): Promise<void>;
100
+ stopService(): Promise<void>;
101
+ checkAndGetBundleName(): Promise<string | false>;
102
+ }
103
+
104
+ declare abstract class BuildProcess {
105
+ cpList: ChildProcessWithoutNullStreams[];
106
+ terminal: null;
107
+ stopping: boolean;
108
+ options: BuilderOptions;
109
+ protected constructor(options: BuilderOptions);
110
+ handle(subCmd: any): void;
111
+ installDeps(): Promise<void>;
112
+ prepareAssemble(projectRoot: string, args?: string[]): Promise<void>;
113
+ abstract start(): void;
114
+ abstract assembleHap(): void;
115
+ abstract assembleApp(): void;
116
+ abstract installHap(): void;
117
+ abstract assembleAndInstallHap(): void;
118
+ abstract uninstall(): void;
119
+ add(cp: any): void;
120
+ del(cp: any): void;
121
+ stop(): void;
122
+ dispose(): void;
123
+ init(): void;
124
+ runCmdAsync(cmd: any, args?: string[], options?: any): Promise<any>;
125
+ clean(): Promise<void>;
126
+ }
127
+
128
+ declare class AscfBuilder extends BuildProcess {
129
+ constructor(options: BuilderOptions);
130
+ runHdcCmdAsync(args?: string[], options?: any): Promise<any>;
131
+ start(): Promise<void>;
132
+ assembleHap(): Promise<void>;
133
+ assembleApp(): Promise<void>;
134
+ usingTmpDir(deviceId: any, cb: any): Promise<void>;
135
+ installHap(): Promise<void>;
136
+ assembleAndInstallHap(): Promise<void>;
137
+ uninstall(): Promise<void>;
138
+ }
139
+
140
+ declare function getDevEcoToolsDir(): string;
141
+ declare function getPath(...args: any[]): string;
142
+ declare function getNodePath(): string;
143
+ declare function getNpmPath(): string;
144
+ declare function getOhpmPath(): string;
145
+ declare function getHvigorwPath(): string;
146
+ declare function getDevEcoSdkHome(): string;
147
+ declare function getHdcPath(): string;
148
+
149
+ declare class AsyncResult<T> {
150
+ err?: Error;
151
+ data?: T;
152
+ }
153
+ declare function $async<T>(promise: Promise<T>): Promise<AsyncResult<T>>;
154
+
155
+ declare function maskLast4(input: string): string;
156
+
157
+ declare function getSpkInfo(projectRoot: any, buildMode: any): {
158
+ bundleName: string;
159
+ spkName: string;
160
+ };
161
+ declare function getBundleInfo(projectRoot: string, isQs?: boolean): {
162
+ bundleName: string;
163
+ versionCode: string;
164
+ };
165
+ declare function getProjectConfig(projectRoot: string): any;
166
+
167
+ declare function isPortReachable(port: any, { host, timeout }?: {
168
+ host?: string | undefined;
169
+ timeout?: number | undefined;
170
+ }): Promise<boolean>;
171
+ declare function findAvailablePort(): Promise<number>;
172
+
173
+ declare function hasHvigor(projectRoot: any): boolean;
174
+ declare function clearAscfDepDirCache(projectRoot: any): void;
175
+ declare function fixHvigorPath(fixPath: any): any;
176
+ declare function getAscfDepDir(projectRoot: any): Promise<string | undefined>;
177
+ declare function ascfRun(projectRoot: any, options?: any, onCp?: any): Promise<void>;
178
+ declare function ascfCompile(projectRoot: any, options?: any, onCp?: any): Promise<void>;
179
+ declare function ascfConvert(input: any, projectRoot: any, options?: any): Promise<void>;
180
+ declare function ascfGenCert(projectRoot: any, options: any): Promise<void>;
181
+ declare function ascfGenP12(projectRoot: any, options: any): Promise<void>;
182
+ declare function startDebugServerCmd(projectRoot: any, opts: any): Promise<unknown>;
183
+ declare function stopDebugServer(): void;
184
+ declare function getDebugServerInfo(localPort: string | number, path: string): Promise<any>;
185
+ declare function getAscfDebuggerPidFile(pid: any): string | undefined;
186
+ declare const BUILD_MODE_DEBUG = "debug";
187
+ declare const BUILD_MODE_RELEASE = "release";
188
+ declare function normalizeBuildMode(buildMode?: boolean | string): string;
189
+ declare const optArgIf: (key: string, value?: any, def?: any) => any[];
190
+
191
+ declare function parseJsonSafe<T>(jsonStr: any, def: T): T;
192
+ declare function parseJsonFile<T>(filepath: any, def: T): T;
193
+ declare function mergeJson(oldJson: any, newJson: any): any;
194
+
195
+ /**
196
+ * 获取ADB工具的路径。
197
+ * 根据不同的操作系统平台(Windows, macOS, Linux),返回对应的ADB可执行文件路径。
198
+ *
199
+ * @returns {Promise<string>} 返回ADB工具的路径字符串。
200
+ */
201
+ declare function getAdbPath(): Promise<string>;
202
+ declare function runAdbCmdAsync(args?: string[], options?: any): Promise<any>;
203
+ declare const listTargets: () => Promise<any>;
204
+ declare const getDeviceName: (deviceId: string) => Promise<string>;
205
+ declare const tryAdbPortReversing: (deviceId: any, localPort: any, times?: number) => Promise<number | undefined>;
206
+ declare const startHostPkg: (deviceId: string, bundleName: string) => Promise<string>;
207
+ declare const startHostPkgUrl: (deviceId: string, bundleName: string, reqUrl: string, legacyPkg: string) => Promise<string>;
208
+ declare const fportListCmd: (deviceId: string) => Promise<string>;
209
+ declare const fportRmCmd: (deviceId: string, localnode: string) => Promise<string>;
210
+ declare const fportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
211
+ declare const rportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
212
+ declare const rportRmCmd: (deviceId: string, devicenode: string) => Promise<string>;
213
+ declare const getDevicesCmd: () => Promise<string>;
214
+ declare const getLegacyDeviceName: (deviceId: any) => Promise<string>;
215
+ declare const getLegacyProcess: (deviceId: any, bundleName: any) => Promise<string>;
216
+ /**
217
+ * 查找包安装信息
218
+ *
219
+ * @param deviceId 设备id
220
+ * @param bundleName 包名
221
+ */
222
+ declare function getLegacyPackInfo(deviceId: any, bundleName: any): Promise<string>;
223
+ declare function getPid(deviceId: string, bundleName: string): Promise<string>;
224
+
225
+ declare function installAscfTools(): Promise<string>;
226
+
227
+ /**
228
+ * 启动热加载服务的异步函数。
229
+ *
230
+ * @param {number} port - 热加载服务尝试使用的端口号。
231
+ * @param {string} staticFolder - 提供静态文件的文件夹路径。
232
+ * @returns {Promise<Server>} 返回一个Promise,当服务器成功创建时解析为服务器对象。
233
+ */
234
+ declare function startServer(port: number, staticFolder: string): Promise<{
235
+ server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
236
+ port: any;
237
+ close: () => void;
238
+ hasReq(url: string): boolean | "";
239
+ }>;
240
+
241
+ declare const BUILD_TARGET_AS = "atomicservice";
242
+ declare const BUILD_TARGET_QS = "crossAtomicService";
243
+ declare function hdcShared({ logger, getDevEcoSdkHome, getPath, getHdcPath }: {
244
+ logger: any;
245
+ getDevEcoSdkHome: any;
246
+ getPath: any;
247
+ getHdcPath: any;
248
+ }): {
249
+ runCmd: (cmd: any, args?: string[], cb?: any, options?: any, onCp?: any) => child_process.ChildProcessWithoutNullStreams;
250
+ runCmdAsync: (cmd: any, args?: string[], options?: any, onCp?: any) => Promise<any>;
251
+ runExecAsync: (cmd: any, args?: string[], options?: any) => Promise<any>;
252
+ runHdcCmd: (args?: string[], cb?: any, options?: any) => child_process.ChildProcessWithoutNullStreams;
253
+ runHdcCmdAsync: (args?: string[], options?: any) => Promise<any>;
254
+ getDeviceName: (deviceId: string) => Promise<string>;
255
+ };
256
+ type deviceType = typeof LEGACY_DEVICE | typeof HOS_DEVICE;
257
+ declare class DeviceInfo {
258
+ name?: string;
259
+ sn?: string;
260
+ type?: deviceType;
261
+ constructor(type?: deviceType);
262
+ }
263
+ declare class DeviceManagerInner {
264
+ adapter: any;
265
+ cache: Map<string, DeviceInfo>;
266
+ cur: DeviceInfo | null;
267
+ isInit: boolean;
268
+ devices: DeviceInfo[];
269
+ constructor(adapter: any);
270
+ getDevices(force?: boolean, isAll?: boolean): Promise<DeviceInfo[]>;
271
+ getDevicesInner(deviceType?: string): Promise<DeviceInfo[]>;
272
+ getHosDevices(): Promise<DeviceInfo[]>;
273
+ getLegacyDevices(): Promise<DeviceInfo[]>;
274
+ getCurrent(): DeviceInfo | null;
275
+ setCurrent(sn: any): void;
276
+ checkAndGetCurrent(): Promise<DeviceInfo | null>;
277
+ getDeviceId(): Promise<string | undefined>;
278
+ getDeviceType(deviceId?: string): Promise<BuildDeviceType | undefined>;
279
+ }
280
+ declare function hdcDeviceShared(opts: any): {
281
+ DeviceInfo: typeof DeviceInfo;
282
+ DeviceManager: {
283
+ new (): {};
284
+ instance: DeviceManagerInner;
285
+ getInstance(): DeviceManagerInner;
286
+ };
287
+ };
288
+
289
+ declare function execSafe(cmd: any, opt?: {}): string | undefined;
290
+
291
+ declare function openInBrowser(url: any, browserName?: string): void;
292
+
293
+ declare class BuildProcessFactory {
294
+ static create(options: BuilderOptions): Promise<BuildProcess>;
295
+ }
296
+ declare class DebuggerProcessFactory {
297
+ static create(options: BuilderOptions): Promise<DebuggerProcess>;
298
+ }
299
+
300
+ declare function devicesLegacyShared({ logger, runAdbCmdAsync }: {
301
+ logger: any;
302
+ runAdbCmdAsync: any;
303
+ }): {
304
+ listTargets: () => Promise<any>;
305
+ getDeviceName: (deviceId: string) => Promise<string>;
306
+ tryAdbPortReversing: (deviceId: any, localPort: any, times?: number) => Promise<number | undefined>;
307
+ startHostPkg: (deviceId: string, bundleName: string) => Promise<string>;
308
+ startHostPkgUrl: (deviceId: string, bundleName: string, reqUrl: string, legacyPkg: string) => Promise<string>;
309
+ fportListCmd: (deviceId: string) => Promise<string>;
310
+ fportRmCmd: (deviceId: string, localnode: string) => Promise<string>;
311
+ fportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
312
+ rportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
313
+ rportRmCmd: (deviceId: string, devicenode: string) => Promise<string>;
314
+ getDevicesCmd: () => Promise<string>;
315
+ getLegacyDeviceName: (deviceId: any) => Promise<string>;
316
+ getLegacyProcess: (deviceId: any, bundleName: any) => Promise<string>;
317
+ };
318
+
319
+ declare const ERROR_MSG: string;
320
+ declare function portManagerShared({ logger, fportListCmd, fportRmCmd, isPortReachable, fportCmd }: any): {
321
+ fportList: (deviceId: string, forceRm?: boolean, rmLocalPort?: string) => Promise<any[]>;
322
+ fport: (deviceId: string, localnode: string, remotenode: string) => Promise<void>;
323
+ fportRm: (deviceId: string, localPort: string) => Promise<any[]>;
324
+ };
325
+
326
+ declare function tryHdcPortReversing(deviceId: any, localPort: any, times?: number): Promise<number | undefined>;
327
+
328
+ declare function installSpkShared({ logger, projectRoot, deviceId, getSpkInfo, buildMode, startServer, tryAdbPortReversing, startHostPkgUrl, rportRmCmd, legacyPkg }: IInstallSpkShared): Promise<void>;
329
+
330
+ export { $async, ASCF_LOG_FILE, AscfBuilder, AscfDebugger, AsyncResult, BUILD_MODE_DEBUG, BUILD_MODE_RELEASE, BUILD_TARGET_AS, BUILD_TARGET_QS, BuildProcessFactory, DEBUG_TYPE_SERVICE, DEBUG_TYPE_VIEW, DebuggerProcessFactory, ERROR_MSG, HOS_DEVICE, LEGACY_DEVICE, LEGACY_PKG_NAME, ascfCompile, ascfConvert, ascfGenCert, ascfGenP12, ascfRun, clearAscfDepDirCache, configureLogger, type deviceType, devicesLegacyShared, execSafe, findAvailablePort, fixHvigorPath, fportCmd, fportListCmd, fportRmCmd, getAdbPath, getAscfDebuggerPidFile, getAscfDepDir, getBundleInfo, getDebugServerInfo, getDebugees, getDevEcoSdkHome, getDevEcoToolsDir, getDeviceName, getDevicesCmd, getHdcPath, getHvigorwPath, getLegacyDeviceName, getLegacyPackInfo, getLegacyProcess, getLogLevelGetter, getLogger, getNodePath, getNpmPath, getOhpmPath, getPath, getPid, getProjectConfig, getSpkInfo, hasHvigor, hdcDeviceShared, hdcShared, installAscfTools, installSpkShared, isPortReachable, listTargets, maskLast4, mergeJson, normalizeBuildMode, openInBrowser, optArgIf, parseJsonFile, parseJsonSafe, portManagerShared, qsHostPkg, rportCmd, rportRmCmd, runAdbCmdAsync, setLogLevelGetter, setLoggerConfig, startDebugServerCmd, startHostPkg, startHostPkgUrl, startServer, stopDebugServer, tryAdbPortReversing, tryHdcPortReversing };
@@ -0,0 +1,330 @@
1
+ import * as log4js from 'log4js';
2
+ import * as child_process from 'child_process';
3
+ import { ChildProcessWithoutNullStreams } from 'child_process';
4
+ import * as http from 'http';
5
+
6
+ declare const ASCF_LOG_FILE: string;
7
+ declare function setLoggerConfig(val: any): void;
8
+ declare function configureLogger(config: any): void;
9
+ declare function setLogLevelGetter(getLogLevel: () => string): void;
10
+ declare function getLogLevelGetter(): () => string;
11
+ declare class Logger {
12
+ categories: string;
13
+ logger: log4js.Logger;
14
+ fileLogger: log4js.Logger | undefined;
15
+ constructor(categories: string);
16
+ doLog(level: any, message: any, args: any, isExit?: boolean): void;
17
+ info(message: any, ...args: any[]): void;
18
+ warn(message: any, ...args: any[]): void;
19
+ debug(message: any, ...args: any[]): void;
20
+ error(message: any, ...args: any[]): void;
21
+ fatal(message: any, ...args: any[]): void;
22
+ }
23
+ declare function getLogger(categories: any): Logger;
24
+
25
+ declare const qsHostPkg = "com.enjoy.now.hmos";
26
+ declare const LEGACY_PKG_NAME = "com.huawei.intelligent/com.huawei.ascf.main.AscfActivity";
27
+ declare const LEGACY_DEVICE = "legacy";
28
+ declare const HOS_DEVICE = "hos";
29
+ declare const DEBUG_TYPE_VIEW = "view";
30
+ declare const DEBUG_TYPE_SERVICE = "service";
31
+
32
+ type BuildModeType = 'debug' | 'release';
33
+ type BuildTargetType = 'atomicservice' | 'crossAtomicService';
34
+ type BuildDeviceType = 'hos' | 'legacy';
35
+ type BuilderOptions = {
36
+ projectRoot?: string;
37
+ deviceId?: string;
38
+ buildMode?: BuildModeType;
39
+ targets?: BuildTargetType;
40
+ deviceType?: BuildDeviceType;
41
+ };
42
+ type DebuggerOptions = {
43
+ open?: '' | 'default' | 'chrome' | 'edge';
44
+ targets?: BuildTargetType;
45
+ deviceType?: BuildDeviceType;
46
+ deviceId?: string;
47
+ bundleName?: string;
48
+ };
49
+ interface IInstallSpkShared {
50
+ logger: any;
51
+ projectRoot: any;
52
+ deviceId: any;
53
+ getSpkInfo: any;
54
+ buildMode: any;
55
+ startServer: any;
56
+ tryAdbPortReversing: any;
57
+ startHostPkgUrl: any;
58
+ rportRmCmd: any;
59
+ legacyPkg?: string;
60
+ }
61
+
62
+ declare function getDebugees(localPort: string | number): Promise<never[]>;
63
+ declare abstract class DebuggerProcess {
64
+ options: DebuggerOptions;
65
+ lastDebugServer: any;
66
+ protected constructor(options: DebuggerOptions);
67
+ handle(subCmd: any): void;
68
+ abstract status(): any;
69
+ abstract start(): any;
70
+ abstract stop(): any;
71
+ abstract startView(): any;
72
+ abstract startService(): any;
73
+ abstract stopView(): any;
74
+ abstract stopService(): any;
75
+ abstract checkAndGetBundleName(): Promise<string | boolean | undefined>;
76
+ openBrowser(type: any, localPort: any, fallback?: string): Promise<void>;
77
+ startDebugServer(url: any): Promise<void>;
78
+ stopDebugServer(): void;
79
+ }
80
+
81
+ declare class AscfDebugger extends DebuggerProcess {
82
+ constructor(options: DebuggerOptions);
83
+ isLegacy(): boolean;
84
+ getPortManager(): {
85
+ webLocalPort: number;
86
+ v8LocalPort: number;
87
+ fportWeb(deviceId: any, bundleName: any): Promise<void>;
88
+ fportV8(deviceId: any): Promise<void>;
89
+ fportRmV8(deviceId: any): Promise<void>;
90
+ fportRmWeb(deviceId: any): Promise<void>;
91
+ fportRm(deviceId: any, localPort: any): Promise<void>;
92
+ status(deviceId: any): Promise<any[]>;
93
+ };
94
+ status(): Promise<void>;
95
+ start(): Promise<void>;
96
+ stop(): Promise<void>;
97
+ startView(): Promise<void>;
98
+ startService(): Promise<void>;
99
+ stopView(): Promise<void>;
100
+ stopService(): Promise<void>;
101
+ checkAndGetBundleName(): Promise<string | false>;
102
+ }
103
+
104
+ declare abstract class BuildProcess {
105
+ cpList: ChildProcessWithoutNullStreams[];
106
+ terminal: null;
107
+ stopping: boolean;
108
+ options: BuilderOptions;
109
+ protected constructor(options: BuilderOptions);
110
+ handle(subCmd: any): void;
111
+ installDeps(): Promise<void>;
112
+ prepareAssemble(projectRoot: string, args?: string[]): Promise<void>;
113
+ abstract start(): void;
114
+ abstract assembleHap(): void;
115
+ abstract assembleApp(): void;
116
+ abstract installHap(): void;
117
+ abstract assembleAndInstallHap(): void;
118
+ abstract uninstall(): void;
119
+ add(cp: any): void;
120
+ del(cp: any): void;
121
+ stop(): void;
122
+ dispose(): void;
123
+ init(): void;
124
+ runCmdAsync(cmd: any, args?: string[], options?: any): Promise<any>;
125
+ clean(): Promise<void>;
126
+ }
127
+
128
+ declare class AscfBuilder extends BuildProcess {
129
+ constructor(options: BuilderOptions);
130
+ runHdcCmdAsync(args?: string[], options?: any): Promise<any>;
131
+ start(): Promise<void>;
132
+ assembleHap(): Promise<void>;
133
+ assembleApp(): Promise<void>;
134
+ usingTmpDir(deviceId: any, cb: any): Promise<void>;
135
+ installHap(): Promise<void>;
136
+ assembleAndInstallHap(): Promise<void>;
137
+ uninstall(): Promise<void>;
138
+ }
139
+
140
+ declare function getDevEcoToolsDir(): string;
141
+ declare function getPath(...args: any[]): string;
142
+ declare function getNodePath(): string;
143
+ declare function getNpmPath(): string;
144
+ declare function getOhpmPath(): string;
145
+ declare function getHvigorwPath(): string;
146
+ declare function getDevEcoSdkHome(): string;
147
+ declare function getHdcPath(): string;
148
+
149
+ declare class AsyncResult<T> {
150
+ err?: Error;
151
+ data?: T;
152
+ }
153
+ declare function $async<T>(promise: Promise<T>): Promise<AsyncResult<T>>;
154
+
155
+ declare function maskLast4(input: string): string;
156
+
157
+ declare function getSpkInfo(projectRoot: any, buildMode: any): {
158
+ bundleName: string;
159
+ spkName: string;
160
+ };
161
+ declare function getBundleInfo(projectRoot: string, isQs?: boolean): {
162
+ bundleName: string;
163
+ versionCode: string;
164
+ };
165
+ declare function getProjectConfig(projectRoot: string): any;
166
+
167
+ declare function isPortReachable(port: any, { host, timeout }?: {
168
+ host?: string | undefined;
169
+ timeout?: number | undefined;
170
+ }): Promise<boolean>;
171
+ declare function findAvailablePort(): Promise<number>;
172
+
173
+ declare function hasHvigor(projectRoot: any): boolean;
174
+ declare function clearAscfDepDirCache(projectRoot: any): void;
175
+ declare function fixHvigorPath(fixPath: any): any;
176
+ declare function getAscfDepDir(projectRoot: any): Promise<string | undefined>;
177
+ declare function ascfRun(projectRoot: any, options?: any, onCp?: any): Promise<void>;
178
+ declare function ascfCompile(projectRoot: any, options?: any, onCp?: any): Promise<void>;
179
+ declare function ascfConvert(input: any, projectRoot: any, options?: any): Promise<void>;
180
+ declare function ascfGenCert(projectRoot: any, options: any): Promise<void>;
181
+ declare function ascfGenP12(projectRoot: any, options: any): Promise<void>;
182
+ declare function startDebugServerCmd(projectRoot: any, opts: any): Promise<unknown>;
183
+ declare function stopDebugServer(): void;
184
+ declare function getDebugServerInfo(localPort: string | number, path: string): Promise<any>;
185
+ declare function getAscfDebuggerPidFile(pid: any): string | undefined;
186
+ declare const BUILD_MODE_DEBUG = "debug";
187
+ declare const BUILD_MODE_RELEASE = "release";
188
+ declare function normalizeBuildMode(buildMode?: boolean | string): string;
189
+ declare const optArgIf: (key: string, value?: any, def?: any) => any[];
190
+
191
+ declare function parseJsonSafe<T>(jsonStr: any, def: T): T;
192
+ declare function parseJsonFile<T>(filepath: any, def: T): T;
193
+ declare function mergeJson(oldJson: any, newJson: any): any;
194
+
195
+ /**
196
+ * 获取ADB工具的路径。
197
+ * 根据不同的操作系统平台(Windows, macOS, Linux),返回对应的ADB可执行文件路径。
198
+ *
199
+ * @returns {Promise<string>} 返回ADB工具的路径字符串。
200
+ */
201
+ declare function getAdbPath(): Promise<string>;
202
+ declare function runAdbCmdAsync(args?: string[], options?: any): Promise<any>;
203
+ declare const listTargets: () => Promise<any>;
204
+ declare const getDeviceName: (deviceId: string) => Promise<string>;
205
+ declare const tryAdbPortReversing: (deviceId: any, localPort: any, times?: number) => Promise<number | undefined>;
206
+ declare const startHostPkg: (deviceId: string, bundleName: string) => Promise<string>;
207
+ declare const startHostPkgUrl: (deviceId: string, bundleName: string, reqUrl: string, legacyPkg: string) => Promise<string>;
208
+ declare const fportListCmd: (deviceId: string) => Promise<string>;
209
+ declare const fportRmCmd: (deviceId: string, localnode: string) => Promise<string>;
210
+ declare const fportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
211
+ declare const rportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
212
+ declare const rportRmCmd: (deviceId: string, devicenode: string) => Promise<string>;
213
+ declare const getDevicesCmd: () => Promise<string>;
214
+ declare const getLegacyDeviceName: (deviceId: any) => Promise<string>;
215
+ declare const getLegacyProcess: (deviceId: any, bundleName: any) => Promise<string>;
216
+ /**
217
+ * 查找包安装信息
218
+ *
219
+ * @param deviceId 设备id
220
+ * @param bundleName 包名
221
+ */
222
+ declare function getLegacyPackInfo(deviceId: any, bundleName: any): Promise<string>;
223
+ declare function getPid(deviceId: string, bundleName: string): Promise<string>;
224
+
225
+ declare function installAscfTools(): Promise<string>;
226
+
227
+ /**
228
+ * 启动热加载服务的异步函数。
229
+ *
230
+ * @param {number} port - 热加载服务尝试使用的端口号。
231
+ * @param {string} staticFolder - 提供静态文件的文件夹路径。
232
+ * @returns {Promise<Server>} 返回一个Promise,当服务器成功创建时解析为服务器对象。
233
+ */
234
+ declare function startServer(port: number, staticFolder: string): Promise<{
235
+ server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
236
+ port: any;
237
+ close: () => void;
238
+ hasReq(url: string): boolean | "";
239
+ }>;
240
+
241
+ declare const BUILD_TARGET_AS = "atomicservice";
242
+ declare const BUILD_TARGET_QS = "crossAtomicService";
243
+ declare function hdcShared({ logger, getDevEcoSdkHome, getPath, getHdcPath }: {
244
+ logger: any;
245
+ getDevEcoSdkHome: any;
246
+ getPath: any;
247
+ getHdcPath: any;
248
+ }): {
249
+ runCmd: (cmd: any, args?: string[], cb?: any, options?: any, onCp?: any) => child_process.ChildProcessWithoutNullStreams;
250
+ runCmdAsync: (cmd: any, args?: string[], options?: any, onCp?: any) => Promise<any>;
251
+ runExecAsync: (cmd: any, args?: string[], options?: any) => Promise<any>;
252
+ runHdcCmd: (args?: string[], cb?: any, options?: any) => child_process.ChildProcessWithoutNullStreams;
253
+ runHdcCmdAsync: (args?: string[], options?: any) => Promise<any>;
254
+ getDeviceName: (deviceId: string) => Promise<string>;
255
+ };
256
+ type deviceType = typeof LEGACY_DEVICE | typeof HOS_DEVICE;
257
+ declare class DeviceInfo {
258
+ name?: string;
259
+ sn?: string;
260
+ type?: deviceType;
261
+ constructor(type?: deviceType);
262
+ }
263
+ declare class DeviceManagerInner {
264
+ adapter: any;
265
+ cache: Map<string, DeviceInfo>;
266
+ cur: DeviceInfo | null;
267
+ isInit: boolean;
268
+ devices: DeviceInfo[];
269
+ constructor(adapter: any);
270
+ getDevices(force?: boolean, isAll?: boolean): Promise<DeviceInfo[]>;
271
+ getDevicesInner(deviceType?: string): Promise<DeviceInfo[]>;
272
+ getHosDevices(): Promise<DeviceInfo[]>;
273
+ getLegacyDevices(): Promise<DeviceInfo[]>;
274
+ getCurrent(): DeviceInfo | null;
275
+ setCurrent(sn: any): void;
276
+ checkAndGetCurrent(): Promise<DeviceInfo | null>;
277
+ getDeviceId(): Promise<string | undefined>;
278
+ getDeviceType(deviceId?: string): Promise<BuildDeviceType | undefined>;
279
+ }
280
+ declare function hdcDeviceShared(opts: any): {
281
+ DeviceInfo: typeof DeviceInfo;
282
+ DeviceManager: {
283
+ new (): {};
284
+ instance: DeviceManagerInner;
285
+ getInstance(): DeviceManagerInner;
286
+ };
287
+ };
288
+
289
+ declare function execSafe(cmd: any, opt?: {}): string | undefined;
290
+
291
+ declare function openInBrowser(url: any, browserName?: string): void;
292
+
293
+ declare class BuildProcessFactory {
294
+ static create(options: BuilderOptions): Promise<BuildProcess>;
295
+ }
296
+ declare class DebuggerProcessFactory {
297
+ static create(options: BuilderOptions): Promise<DebuggerProcess>;
298
+ }
299
+
300
+ declare function devicesLegacyShared({ logger, runAdbCmdAsync }: {
301
+ logger: any;
302
+ runAdbCmdAsync: any;
303
+ }): {
304
+ listTargets: () => Promise<any>;
305
+ getDeviceName: (deviceId: string) => Promise<string>;
306
+ tryAdbPortReversing: (deviceId: any, localPort: any, times?: number) => Promise<number | undefined>;
307
+ startHostPkg: (deviceId: string, bundleName: string) => Promise<string>;
308
+ startHostPkgUrl: (deviceId: string, bundleName: string, reqUrl: string, legacyPkg: string) => Promise<string>;
309
+ fportListCmd: (deviceId: string) => Promise<string>;
310
+ fportRmCmd: (deviceId: string, localnode: string) => Promise<string>;
311
+ fportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
312
+ rportCmd: (deviceId: string, localnode: string, remotenode: string) => Promise<string>;
313
+ rportRmCmd: (deviceId: string, devicenode: string) => Promise<string>;
314
+ getDevicesCmd: () => Promise<string>;
315
+ getLegacyDeviceName: (deviceId: any) => Promise<string>;
316
+ getLegacyProcess: (deviceId: any, bundleName: any) => Promise<string>;
317
+ };
318
+
319
+ declare const ERROR_MSG: string;
320
+ declare function portManagerShared({ logger, fportListCmd, fportRmCmd, isPortReachable, fportCmd }: any): {
321
+ fportList: (deviceId: string, forceRm?: boolean, rmLocalPort?: string) => Promise<any[]>;
322
+ fport: (deviceId: string, localnode: string, remotenode: string) => Promise<void>;
323
+ fportRm: (deviceId: string, localPort: string) => Promise<any[]>;
324
+ };
325
+
326
+ declare function tryHdcPortReversing(deviceId: any, localPort: any, times?: number): Promise<number | undefined>;
327
+
328
+ declare function installSpkShared({ logger, projectRoot, deviceId, getSpkInfo, buildMode, startServer, tryAdbPortReversing, startHostPkgUrl, rportRmCmd, legacyPkg }: IInstallSpkShared): Promise<void>;
329
+
330
+ export { $async, ASCF_LOG_FILE, AscfBuilder, AscfDebugger, AsyncResult, BUILD_MODE_DEBUG, BUILD_MODE_RELEASE, BUILD_TARGET_AS, BUILD_TARGET_QS, BuildProcessFactory, DEBUG_TYPE_SERVICE, DEBUG_TYPE_VIEW, DebuggerProcessFactory, ERROR_MSG, HOS_DEVICE, LEGACY_DEVICE, LEGACY_PKG_NAME, ascfCompile, ascfConvert, ascfGenCert, ascfGenP12, ascfRun, clearAscfDepDirCache, configureLogger, type deviceType, devicesLegacyShared, execSafe, findAvailablePort, fixHvigorPath, fportCmd, fportListCmd, fportRmCmd, getAdbPath, getAscfDebuggerPidFile, getAscfDepDir, getBundleInfo, getDebugServerInfo, getDebugees, getDevEcoSdkHome, getDevEcoToolsDir, getDeviceName, getDevicesCmd, getHdcPath, getHvigorwPath, getLegacyDeviceName, getLegacyPackInfo, getLegacyProcess, getLogLevelGetter, getLogger, getNodePath, getNpmPath, getOhpmPath, getPath, getPid, getProjectConfig, getSpkInfo, hasHvigor, hdcDeviceShared, hdcShared, installAscfTools, installSpkShared, isPortReachable, listTargets, maskLast4, mergeJson, normalizeBuildMode, openInBrowser, optArgIf, parseJsonFile, parseJsonSafe, portManagerShared, qsHostPkg, rportCmd, rportRmCmd, runAdbCmdAsync, setLogLevelGetter, setLoggerConfig, startDebugServerCmd, startHostPkg, startHostPkgUrl, startServer, stopDebugServer, tryAdbPortReversing, tryHdcPortReversing };