@oniroproject/core 0.7.0 → 0.9.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.
- package/README.md +18 -6
- package/dist/index.cjs +899 -444
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +301 -18
- package/dist/index.d.ts +301 -18
- package/dist/index.js +874 -445
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
1
|
+
import { ChildProcess, SpawnOptions, ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
|
|
3
3
|
interface Logger {
|
|
4
4
|
debug(message: string): void;
|
|
@@ -28,7 +28,7 @@ declare const noopProgress: ProgressReporter;
|
|
|
28
28
|
* Keys read from the ConfigProvider by core. Frontends (CLI, VS Code extension)
|
|
29
29
|
* implement the provider however they like (env vars, settings.json, etc.).
|
|
30
30
|
*/
|
|
31
|
-
type ConfigKey = 'sdkRootDir' | 'cmdToolsPath' | 'emulatorDir' | 'hapPath' | 'cmdToolsUrlLinux' | 'cmdToolsUrlWindows' | 'cmdToolsUrlMac' | 'emulatorUrl' | 'sdkUrlBase' | 'applicationCertPath';
|
|
31
|
+
type ConfigKey = 'sdkRootDir' | 'cmdToolsPath' | 'hdcPath' | 'emulatorDir' | 'hapPath' | 'cmdToolsUrlLinux' | 'cmdToolsUrlWindows' | 'cmdToolsUrlMac' | 'emulatorUrl' | 'tmpDir' | 'sdkUrlBase' | 'applicationCertPath';
|
|
32
32
|
interface ConfigProvider {
|
|
33
33
|
/**
|
|
34
34
|
* Get the configured value for `key`, or `fallback` if unset/empty.
|
|
@@ -96,6 +96,15 @@ declare class ChecksumMismatchError extends OniroError {
|
|
|
96
96
|
readonly actual: string;
|
|
97
97
|
constructor(expected: string, actual: string);
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* A download/extract ran out of room on the filesystem holding its scratch
|
|
101
|
+
* directory. The message is built by the caller (see `sdk/tmp.ts`) so it can name
|
|
102
|
+
* the directory, whether it is RAM-backed, and how to point elsewhere.
|
|
103
|
+
*/
|
|
104
|
+
declare class InsufficientSpaceError extends OniroError {
|
|
105
|
+
readonly dir: string;
|
|
106
|
+
constructor(message: string, dir: string, cause?: unknown);
|
|
107
|
+
}
|
|
99
108
|
declare class CancelledError extends OniroError {
|
|
100
109
|
constructor(message?: string);
|
|
101
110
|
}
|
|
@@ -173,6 +182,26 @@ declare function getSdkRootDir(config: ConfigProvider): string;
|
|
|
173
182
|
declare function getOhosBaseSdkHome(config: ConfigProvider): string;
|
|
174
183
|
declare function getCmdToolsPath(config: ConfigProvider): string;
|
|
175
184
|
declare function getEmulatorDir(config: ConfigProvider): string;
|
|
185
|
+
/**
|
|
186
|
+
* Expand a Windows 8.3 short path (`C:\Users\FRANCE~1\...`) to its long form.
|
|
187
|
+
*
|
|
188
|
+
* Short names reach us whenever a caller passes `%TEMP%` or a path built in a
|
|
189
|
+
* `cmd` context, and hvigor cannot resolve a module directory underneath one:
|
|
190
|
+
* it aborts with `00303149 Configuration Error / Path not found` naming a
|
|
191
|
+
* `srcPath` that plainly exists. Node and the Win32 API resolve short names
|
|
192
|
+
* fine, so the mismatch only surfaces once hvigor is running.
|
|
193
|
+
*
|
|
194
|
+
* No-op off Windows, where short names do not exist and resolving would only
|
|
195
|
+
* dereference symlinks the caller chose deliberately. On Windows it does also
|
|
196
|
+
* canonicalise case and follow junctions — the same path the OS resolves to
|
|
197
|
+
* anyway.
|
|
198
|
+
*
|
|
199
|
+
* Returns `p` unchanged when it does not exist, so a caller's "not found"
|
|
200
|
+
* error still quotes the path the user actually typed.
|
|
201
|
+
*
|
|
202
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
203
|
+
*/
|
|
204
|
+
declare function toLongPath(p: string, platform?: NodeJS.Platform): string;
|
|
176
205
|
/**
|
|
177
206
|
* Resolve a binary inside the command-line tools `bin/` directory by name
|
|
178
207
|
* (e.g. `'ohpm'`, `'hvigorw'`, `'codelinter'`). On Windows tries common
|
|
@@ -182,7 +211,10 @@ declare function getCmdToolsBin(config: ConfigProvider, name?: string): string;
|
|
|
182
211
|
/** Resolve the OHPM binary path inside the command-line tools install. */
|
|
183
212
|
declare function getOhpmPath(config: ConfigProvider): string;
|
|
184
213
|
/**
|
|
185
|
-
* Resolve the hdc binary
|
|
214
|
+
* Resolve the hdc binary. An explicit `hdcPath` override (config key / `ONIRO_HDC`
|
|
215
|
+
* env var) wins — point it at a wrapper/proxy hdc when the device is not directly
|
|
216
|
+
* attached here (e.g. a remote device behind an SSH-tunnel `hdc` wrapper). When
|
|
217
|
+
* unset, fall back to the hdc bundled in the SDK toolchains tree.
|
|
186
218
|
*/
|
|
187
219
|
declare function getHdcPath(config: ConfigProvider): string;
|
|
188
220
|
/**
|
|
@@ -192,8 +224,13 @@ declare function getHdcPath(config: ConfigProvider): string;
|
|
|
192
224
|
* ship a project-local `hvigorw` whose `hvigor/` install is absent, so the
|
|
193
225
|
* wrapper crashes on startup; in that case we fall back to the hvigorw bundled
|
|
194
226
|
* with the command-line tools, which is always installed.
|
|
227
|
+
*
|
|
228
|
+
* DevEco projects ship both wrappers side by side: an extensionless POSIX shell
|
|
229
|
+
* script and a `.bat` for Windows. The candidate order is therefore
|
|
230
|
+
* platform-dependent — picking the shell script on Windows would hand `spawn` a
|
|
231
|
+
* file the OS cannot execute.
|
|
195
232
|
*/
|
|
196
|
-
declare function getHvigorwPath(config: ConfigProvider, projectDir: string): string;
|
|
233
|
+
declare function getHvigorwPath(config: ConfigProvider, projectDir: string, platform?: NodeJS.Platform): string;
|
|
197
234
|
|
|
198
235
|
/**
|
|
199
236
|
* Detect the SDK API a project targets by reading `build-profile.json5`.
|
|
@@ -202,6 +239,82 @@ declare function getHvigorwPath(config: ConfigProvider, projectDir: string): str
|
|
|
202
239
|
*/
|
|
203
240
|
declare function detectProjectSdkVersion(projectRoot: string, logger?: Logger): number | undefined;
|
|
204
241
|
|
|
242
|
+
/** Name of the scratch folder created next to an install target. */
|
|
243
|
+
declare const INSTALL_TMP_DIRNAME = ".oniro-tmp";
|
|
244
|
+
/** Advice appended to out-of-space failures in the scratch directory. */
|
|
245
|
+
declare const TMP_DIR_HINT: string;
|
|
246
|
+
/**
|
|
247
|
+
* Resolve the directory that download/extract scratch space is created in.
|
|
248
|
+
*
|
|
249
|
+
* Precedence: explicit override (CLI `--tmp-dir`) → `tmpDir` config key
|
|
250
|
+
* (`ONIRO_TMP_DIR`) → `<installRoot>/.oniro-tmp` → the system temp dir.
|
|
251
|
+
*
|
|
252
|
+
* The default sits next to the install target so that the unpacked tree is renamed
|
|
253
|
+
* into place rather than copied across a device boundary, and so the system temp dir
|
|
254
|
+
* — a RAM-backed `tmpfs` on most Linux systems, and far smaller than a multi-GB
|
|
255
|
+
* archive — is never in the picture.
|
|
256
|
+
*/
|
|
257
|
+
declare function resolveTmpRoot(config: ConfigProvider, override?: string, installRoot?: string): string;
|
|
258
|
+
/** Create a private scratch directory under `root`, creating `root` if needed. */
|
|
259
|
+
declare function createTempWorkDir(root: string, prefix: string): string;
|
|
260
|
+
/**
|
|
261
|
+
* Remove a scratch directory once an install is done, taking the `.oniro-tmp` root
|
|
262
|
+
* with it when that leaves it empty. A root the caller named explicitly is left alone,
|
|
263
|
+
* as are roots another install is still using (the rmdir simply fails).
|
|
264
|
+
*/
|
|
265
|
+
declare function removeTempWorkDir(dir: string, root?: string): void;
|
|
266
|
+
interface InstallTempDirOptions {
|
|
267
|
+
config: ConfigProvider;
|
|
268
|
+
/** Explicit scratch directory (CLI `--tmp-dir`). */
|
|
269
|
+
override?: string;
|
|
270
|
+
/** Directory the install lands in; the default scratch root is created inside it. */
|
|
271
|
+
installRoot: string;
|
|
272
|
+
prefix: string;
|
|
273
|
+
logger?: Logger;
|
|
274
|
+
}
|
|
275
|
+
interface InstallTempDir {
|
|
276
|
+
/** The private per-run scratch directory. Remove it when the install finishes. */
|
|
277
|
+
dir: string;
|
|
278
|
+
/** The configurable root it was created under, for out-of-space messages. */
|
|
279
|
+
root: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Create the scratch directory for an install, defaulting to `<installRoot>/.oniro-tmp`.
|
|
283
|
+
*
|
|
284
|
+
* When that default is unusable — a read-only or root-owned install parent, say — the
|
|
285
|
+
* system temp dir is used instead. A directory the caller asked for explicitly is never
|
|
286
|
+
* swapped out silently, and a full filesystem is reported rather than papered over.
|
|
287
|
+
*/
|
|
288
|
+
declare function createInstallTempDir(opts: InstallTempDirOptions): InstallTempDir;
|
|
289
|
+
/**
|
|
290
|
+
* Bytes available to an unprivileged user on the filesystem holding `dir`.
|
|
291
|
+
* Returns null when the platform cannot report it.
|
|
292
|
+
*/
|
|
293
|
+
declare function getFreeSpaceBytes(dir: string): number | null;
|
|
294
|
+
/**
|
|
295
|
+
* Whether `dir` lives on a RAM-backed filesystem (`tmpfs`/`ramfs`), i.e. one whose
|
|
296
|
+
* capacity comes out of memory rather than disk.
|
|
297
|
+
*/
|
|
298
|
+
declare function isRamBackedPath(dir: string): boolean;
|
|
299
|
+
declare function formatBytes(bytes: number): string;
|
|
300
|
+
/** Recognise an out-of-disk-space failure from fs/stream errors and their wrappers. */
|
|
301
|
+
declare function isOutOfSpaceError(err: unknown): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Fail before writing a byte when the filesystem holding `dir` cannot take
|
|
304
|
+
* `requiredBytes`. A no-op when free space cannot be determined.
|
|
305
|
+
*/
|
|
306
|
+
declare function ensureFreeSpace(dir: string, requiredBytes: number, what: string): void;
|
|
307
|
+
/**
|
|
308
|
+
* Convert an out-of-space failure into an {@link InsufficientSpaceError}; any other
|
|
309
|
+
* error is returned unchanged, so callers can `throw toSpaceError(err, ...)`.
|
|
310
|
+
*
|
|
311
|
+
* `tmpRoot` is the scratch directory the operation was using. Failures under it are
|
|
312
|
+
* reported against it (not the per-run subdirectory the user cannot configure) and get
|
|
313
|
+
* the `--tmp-dir` remedy; failures elsewhere — an install target that is full — name
|
|
314
|
+
* their own directory and skip the remedy, which would not help.
|
|
315
|
+
*/
|
|
316
|
+
declare function toSpaceError(err: unknown, tmpRoot: string, what: string): unknown;
|
|
317
|
+
|
|
205
318
|
interface DownloadOptions {
|
|
206
319
|
url: string;
|
|
207
320
|
dest: string;
|
|
@@ -211,10 +324,21 @@ interface DownloadOptions {
|
|
|
211
324
|
start?: number;
|
|
212
325
|
/** Overall progress range to consume (0..100). Default 100. */
|
|
213
326
|
range?: number;
|
|
327
|
+
/** What the download is for, used in out-of-space messages. */
|
|
328
|
+
what?: string;
|
|
329
|
+
/**
|
|
330
|
+
* Configurable scratch root that `dest` lives under, if any. Out-of-space messages
|
|
331
|
+
* name it instead of the per-run subdirectory, since that is what the user can change.
|
|
332
|
+
*/
|
|
333
|
+
tmpRoot?: string;
|
|
214
334
|
}
|
|
215
335
|
/**
|
|
216
336
|
* Stream a remote file to disk with optional progress reporting and cancellation.
|
|
217
337
|
* Follows redirects via the `follow-redirects` library.
|
|
338
|
+
*
|
|
339
|
+
* Fails fast with an `InsufficientSpaceError` when the destination filesystem cannot
|
|
340
|
+
* hold the advertised `content-length` — the common case being a system temp dir on a
|
|
341
|
+
* RAM-backed tmpfs that is far smaller than the SDK/tools archives.
|
|
218
342
|
*/
|
|
219
343
|
declare function downloadFile(opts: DownloadOptions): Promise<void>;
|
|
220
344
|
/**
|
|
@@ -273,6 +397,11 @@ interface InstallSdkOptions {
|
|
|
273
397
|
progress?: ProgressReporter;
|
|
274
398
|
abortSignal?: AbortSignal;
|
|
275
399
|
logger?: Logger;
|
|
400
|
+
/**
|
|
401
|
+
* Scratch directory for the download/extract temporaries. Overrides the `tmpDir`
|
|
402
|
+
* config key and the default location next to the install target.
|
|
403
|
+
*/
|
|
404
|
+
tmpDir?: string;
|
|
276
405
|
}
|
|
277
406
|
/**
|
|
278
407
|
* Download and install an OpenHarmony SDK release into `<sdkRootDir>/<osFolder>/<api>`.
|
|
@@ -310,6 +439,11 @@ interface InstallCmdToolsOptions {
|
|
|
310
439
|
logger?: Logger;
|
|
311
440
|
/** Skip download and install from a local zip the caller already has. */
|
|
312
441
|
localZipPath?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Scratch directory for the download/extract temporaries. Overrides the `tmpDir`
|
|
444
|
+
* config key and the default location next to the install target.
|
|
445
|
+
*/
|
|
446
|
+
tmpDir?: string;
|
|
313
447
|
}
|
|
314
448
|
/**
|
|
315
449
|
* Install the OpenHarmony command-line tools into `<cmdToolsPath>`.
|
|
@@ -437,6 +571,11 @@ interface InstallEmulatorOptions {
|
|
|
437
571
|
progress?: ProgressReporter;
|
|
438
572
|
abortSignal?: AbortSignal;
|
|
439
573
|
logger?: Logger;
|
|
574
|
+
/**
|
|
575
|
+
* Scratch directory for the downloaded ZIP. Overrides the `tmpDir` config key and
|
|
576
|
+
* the default location next to the install target.
|
|
577
|
+
*/
|
|
578
|
+
tmpDir?: string;
|
|
440
579
|
}
|
|
441
580
|
/**
|
|
442
581
|
* Download and extract the Oniro emulator into the configured `emulatorDir`.
|
|
@@ -491,6 +630,63 @@ interface StartEmulatorOptions {
|
|
|
491
630
|
declare function startEmulator(opts: StartEmulatorOptions): Promise<void>;
|
|
492
631
|
declare function stopEmulator(logger?: Logger): Promise<void>;
|
|
493
632
|
|
|
633
|
+
/**
|
|
634
|
+
* True when `command` must be routed through `cmd.exe` to run at all —
|
|
635
|
+
* i.e. we are on Windows and the target is a batch wrapper.
|
|
636
|
+
*
|
|
637
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
638
|
+
*/
|
|
639
|
+
declare function needsCmdWrapper(command: string, platform?: NodeJS.Platform): boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Escape one argument for a `cmd.exe` command line: quote it, double the
|
|
642
|
+
* backslashes that would otherwise escape the closing quote, then caret-escape
|
|
643
|
+
* every metacharacter.
|
|
644
|
+
*
|
|
645
|
+
* `doubleEscapeMetaChars` adds the second caret layer needed by `%*`-forwarding
|
|
646
|
+
* shims — see {@link CMD_SHIM_RE}.
|
|
647
|
+
*/
|
|
648
|
+
declare function escapeCmdArgument(arg: string, doubleEscapeMetaChars?: boolean): string;
|
|
649
|
+
/**
|
|
650
|
+
* Escape the executable path. It is caret-escaped but deliberately NOT quoted:
|
|
651
|
+
* `cmd.exe /s /c "..."` strips the outer quotes of the whole line, and a quoted
|
|
652
|
+
* first token confuses that parse. Caret-escaping the spaces is what makes
|
|
653
|
+
* `C:\Program Files\...` work.
|
|
654
|
+
*/
|
|
655
|
+
declare function escapeCmdCommand(command: string): string;
|
|
656
|
+
interface CmdWrapper {
|
|
657
|
+
command: string;
|
|
658
|
+
args: string[];
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Build the `cmd.exe /d /s /c "<command> <args...>"` invocation for a batch
|
|
662
|
+
* wrapper. Pure (no I/O, no spawning) so the escaping is unit-testable on every
|
|
663
|
+
* platform.
|
|
664
|
+
*
|
|
665
|
+
* `/d` skips AutoRun registry commands, `/s` keeps the outer quotes intact,
|
|
666
|
+
* `/c` runs the command and exits.
|
|
667
|
+
*
|
|
668
|
+
* @throws OniroError if the command or any argument contains a character that
|
|
669
|
+
* cannot survive `cmd.exe` unambiguously (see {@link UNSAFE_CMD_CHARS_RE}).
|
|
670
|
+
*/
|
|
671
|
+
declare function buildCmdWrapper(command: string, args: readonly string[]): CmdWrapper;
|
|
672
|
+
/**
|
|
673
|
+
* `child_process.spawn`, but able to run Windows batch wrappers.
|
|
674
|
+
*
|
|
675
|
+
* Identical to `spawn` everywhere else — on POSIX, and on Windows for real
|
|
676
|
+
* executables, the command and args are passed straight through with
|
|
677
|
+
* `shell: false`.
|
|
678
|
+
*/
|
|
679
|
+
declare function spawnCompat(command: string, args: readonly string[], options?: SpawnOptions): ChildProcess;
|
|
680
|
+
/**
|
|
681
|
+
* Kill a child and everything it started.
|
|
682
|
+
*
|
|
683
|
+
* On Windows a signal only reaches the process we spawned — killing the
|
|
684
|
+
* `cmd.exe` wrapper leaves the Node/hvigor process it launched running, so an
|
|
685
|
+
* aborted or timed-out build would keep holding the project's output files.
|
|
686
|
+
* `taskkill /T /F` tears down the whole tree instead.
|
|
687
|
+
*/
|
|
688
|
+
declare function killProcessTree(child: ChildProcess): void;
|
|
689
|
+
|
|
494
690
|
/** Result of a spawned command. `code` is the process exit code (-1 if it was killed). */
|
|
495
691
|
interface HdcExecResult {
|
|
496
692
|
code: number;
|
|
@@ -521,6 +717,12 @@ interface RunProcessOptions {
|
|
|
521
717
|
* because args are passed as an array and never interpolated into a shell
|
|
522
718
|
* string, command construction is injection-safe by construction.
|
|
523
719
|
*
|
|
720
|
+
* The one exception is a Windows batch wrapper (`.bat`/`.cmd`, how the
|
|
721
|
+
* OpenHarmony command-line tools ship there), which the OS cannot execute
|
|
722
|
+
* directly: those go through `cmd.exe` with every argument individually
|
|
723
|
+
* escaped — see {@link spawnCompat}. The array-in, no-word-splitting contract
|
|
724
|
+
* is preserved.
|
|
725
|
+
*
|
|
524
726
|
* Resolves with `{ code, stdout, stderr }` for ANY exit code (callers opt into
|
|
525
727
|
* throw-on-non-zero via {@link ensureOk}). Rejects only on spawn failure
|
|
526
728
|
* (e.g. missing binary), timeout, or abort.
|
|
@@ -554,6 +756,33 @@ declare function shell(opts: HdcShellOptions): Promise<HdcExecResult>;
|
|
|
554
756
|
* return the result unchanged. Lets callers opt into throw-semantics.
|
|
555
757
|
*/
|
|
556
758
|
declare function ensureOk(result: HdcExecResult, command: string): HdcExecResult;
|
|
759
|
+
/**
|
|
760
|
+
* Parse the exit-code marker appended by {@link shellChecked}. Pure/testable.
|
|
761
|
+
* Returns the remote exit code plus stdout with every marker occurrence
|
|
762
|
+
* stripped, or `null` when no marker is present (the command was killed/timed
|
|
763
|
+
* out, or the device shell never reached the trailing `echo`).
|
|
764
|
+
*/
|
|
765
|
+
declare function parseRemoteExit(stdout: string): {
|
|
766
|
+
code: number;
|
|
767
|
+
stdout: string;
|
|
768
|
+
} | null;
|
|
769
|
+
/**
|
|
770
|
+
* Like {@link shell}, but recovers the REMOTE command's exit status.
|
|
771
|
+
*
|
|
772
|
+
* `hdc shell "<cmd>"` reports hdc's OWN exit code (≈ always 0) regardless of
|
|
773
|
+
* whether `<cmd>` succeeded on the device — so on-device failures (`uinput`
|
|
774
|
+
* rejecting its args, a `bm install` error, a missing binary) otherwise look
|
|
775
|
+
* like success. We append an exit-code marker, parse it back out, and report
|
|
776
|
+
* it as `code`, with the marker stripped from stdout. Pair with
|
|
777
|
+
* {@link ensureRemoteOk} to throw on a non-zero remote exit.
|
|
778
|
+
*/
|
|
779
|
+
declare function shellChecked(opts: HdcShellOptions): Promise<HdcExecResult>;
|
|
780
|
+
/**
|
|
781
|
+
* Throw a typed {@link CommandFailedError} on a non-zero result, preferring
|
|
782
|
+
* stderr but falling back to stdout for the detail — device tools like
|
|
783
|
+
* `uinput`/`uitest` print their errors to stdout, not stderr.
|
|
784
|
+
*/
|
|
785
|
+
declare function ensureRemoteOk(result: HdcExecResult, command: string): HdcExecResult;
|
|
557
786
|
|
|
558
787
|
interface DeviceInfo {
|
|
559
788
|
/** Connect key — a USB serial or a `host:port` for a TCP target. */
|
|
@@ -827,10 +1056,35 @@ interface SendRawTouchOptions {
|
|
|
827
1056
|
* interleaving `-i <ms>` intervals from the event time deltas. Pure.
|
|
828
1057
|
*/
|
|
829
1058
|
declare function buildRawTouchCommand(events: RawTouchEvent[]): string;
|
|
1059
|
+
/** Expand a waypoint path (+ optional holds) into raw down/move/up events for
|
|
1060
|
+
* the `uinput` escape hatch ({@link sendRawTouch} / {@link buildRawTouchCommand}). */
|
|
1061
|
+
declare function waypointsToRawEvents(waypoints: Waypoint[], holdStartMs?: number, holdEndMs?: number): RawTouchEvent[];
|
|
1062
|
+
interface GestureUitestOptions {
|
|
1063
|
+
/** A leading press-hold; when > 0 the stroke uses `drag` (press-and-hold,
|
|
1064
|
+
* then move) instead of `swipe`. uitest has no arbitrary hold duration. */
|
|
1065
|
+
holdStartMs?: number;
|
|
1066
|
+
}
|
|
830
1067
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
1068
|
+
* Build a single continuous `uitest uiInput` stroke for a waypoint path. Pure.
|
|
1069
|
+
*
|
|
1070
|
+
* uitest has no polyline or stationary-hold primitive, so the path is collapsed
|
|
1071
|
+
* to first→last (gesture-nav strokes are straight lines) with the velocity
|
|
1072
|
+
* derived from the total elapsed time and clamped to uitest's range. A
|
|
1073
|
+
* requested `holdStartMs` maps to `drag` (which presses-and-holds before
|
|
1074
|
+
* moving — uitest's nearest equivalent to a leading hold); otherwise `swipe`.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function buildGestureUitestCommand(waypoints: Waypoint[], opts?: GestureUitestOptions): string;
|
|
1077
|
+
/**
|
|
1078
|
+
* Drive a swipe-style gesture via a single continuous `uitest uiInput` stroke —
|
|
1079
|
+
* the MMI-injection path that `inputMonitor`-based services (gesture-nav,
|
|
1080
|
+
* systemui overlays) actually observe. Preferred over raw `uinput`, whose
|
|
1081
|
+
* kernel virtual-device events do not reach `inputMonitor` on some native-boot
|
|
1082
|
+
* devices (and whose multi-op form some on-device `uinput` builds reject).
|
|
1083
|
+
*
|
|
1084
|
+
* uitest has no polyline or stationary-hold primitive: a multi-waypoint path is
|
|
1085
|
+
* collapsed to first→last, `holdStartMs` maps to `drag` (press-hold-then-move),
|
|
1086
|
+
* and `holdEndMs` has no equivalent (ignored). For true press-time control use
|
|
1087
|
+
* {@link sendRawTouch} (raw `uinput`) — accepting the device caveats above.
|
|
834
1088
|
*/
|
|
835
1089
|
declare function sendGesture(opts: SendGestureOptions): Promise<void>;
|
|
836
1090
|
/**
|
|
@@ -840,6 +1094,12 @@ declare function sendGesture(opts: SendGestureOptions): Promise<void>;
|
|
|
840
1094
|
* WARNING: uinput's gesture form `uinput -T -g x1 y1 x2 y2 [press] [total]`
|
|
841
1095
|
* silently no-ops if `press < 500ms` or `total - press < 500ms` ("press time is
|
|
842
1096
|
* out of range" — it runs nothing). Keep press and post-press windows ≥ 500ms.
|
|
1097
|
+
*
|
|
1098
|
+
* DEVICE CAVEAT: on some native-boot devices these kernel-`uinput` events never
|
|
1099
|
+
* reach MMI `inputMonitor` services (gesture-nav, systemui), and some on-device
|
|
1100
|
+
* `uinput` builds reject the multi-op `-d/-m/-u` form with "wrong number of
|
|
1101
|
+
* parameters". Prefer {@link sendGesture} (uitest) for those; this path now
|
|
1102
|
+
* surfaces such failures instead of silently succeeding.
|
|
843
1103
|
*/
|
|
844
1104
|
declare function sendRawTouch(opts: SendRawTouchOptions): Promise<void>;
|
|
845
1105
|
|
|
@@ -935,11 +1195,19 @@ interface InstallAppResult {
|
|
|
935
1195
|
declare function installApp(opts: InstallAppOptions): Promise<InstallAppResult>;
|
|
936
1196
|
interface LaunchAppOptions {
|
|
937
1197
|
config: ConfigProvider;
|
|
938
|
-
|
|
939
|
-
|
|
1198
|
+
/** Project mode: resolve bundle + main ability from the project. Required unless `bundleName` is given. */
|
|
1199
|
+
projectDir?: string;
|
|
1200
|
+
/**
|
|
1201
|
+
* Bundle mode: launch an already-installed app directly by bundle name (no
|
|
1202
|
+
* project needed). When set, `projectDir` is ignored. If `abilityName` is
|
|
1203
|
+
* omitted, the main ability is resolved from the device via `bm dump -n`.
|
|
1204
|
+
*/
|
|
1205
|
+
bundleName?: string;
|
|
1206
|
+
/** Override the module name if it isn't the default `entry` (project mode). */
|
|
940
1207
|
moduleName?: string;
|
|
941
|
-
/** Explicit ability to launch; defaults to the module's mainElement / first visible ability. */
|
|
1208
|
+
/** Explicit ability to launch; defaults to the module's mainElement / first visible ability (project mode) or the installed bundle's main ability (bundle mode). */
|
|
942
1209
|
abilityName?: string;
|
|
1210
|
+
deviceSerial?: string;
|
|
943
1211
|
logger?: Logger;
|
|
944
1212
|
}
|
|
945
1213
|
/**
|
|
@@ -949,6 +1217,14 @@ interface LaunchAppOptions {
|
|
|
949
1217
|
* failed launch, or null when it looks like a success.
|
|
950
1218
|
*/
|
|
951
1219
|
declare function detectAaStartFailure(output: string): string | null;
|
|
1220
|
+
/**
|
|
1221
|
+
* Parse the main ability of an installed bundle from `bm dump -n <bundle>`
|
|
1222
|
+
* output. Pure/testable. The output is a bundle-name prefix line followed by a
|
|
1223
|
+
* JSON blob; we take the entry module's `mainElementName` (fallback
|
|
1224
|
+
* `mainAbility`), or the first module that declares one. Returns null when the
|
|
1225
|
+
* bundle isn't installed or the output is unparseable.
|
|
1226
|
+
*/
|
|
1227
|
+
declare function parseMainAbilityFromBmDump(stdout: string): string | null;
|
|
952
1228
|
declare function launchApp(opts: LaunchAppOptions): Promise<void>;
|
|
953
1229
|
interface RunningProcess {
|
|
954
1230
|
pid: string;
|
|
@@ -973,10 +1249,16 @@ interface BundleOptions {
|
|
|
973
1249
|
logger?: Logger;
|
|
974
1250
|
}
|
|
975
1251
|
/**
|
|
976
|
-
* Non-throwing companion to {@link listRunningProcesses}: resolve
|
|
977
|
-
* process for a bundle
|
|
978
|
-
*
|
|
979
|
-
*
|
|
1252
|
+
* Non-throwing companion to {@link listRunningProcesses}: resolve a running
|
|
1253
|
+
* process for a bundle, or `null` when it isn't running. Suitable for "is X
|
|
1254
|
+
* running?" checks (e.g. the pre/post-install pid comparison in applyChanges).
|
|
1255
|
+
*
|
|
1256
|
+
* `pidof` matches the bundle's main (UIAbility) process. When that isn't found,
|
|
1257
|
+
* we fall back to `track-jpid` to also catch **extension-ability** processes,
|
|
1258
|
+
* which run under a separate process name `"<bundle>:<ext>"` (e.g. a
|
|
1259
|
+
* ServiceExtension, FormExtension, UIExtension or input method). Without this,
|
|
1260
|
+
* "verify the running process took the change" silently reported nothing for an
|
|
1261
|
+
* app whose only live process is an extension.
|
|
980
1262
|
*/
|
|
981
1263
|
declare function findRunningProcess(opts: BundleOptions): Promise<RunningProcess | null>;
|
|
982
1264
|
/** Uninstall an app by bundle name (`hdc uninstall <bundle>`). */
|
|
@@ -1144,9 +1426,10 @@ interface DiscoverHapsOptions {
|
|
|
1144
1426
|
}
|
|
1145
1427
|
/**
|
|
1146
1428
|
* Walk a project's build outputs and group `*-signed.hap` / `*-unsigned.hap`
|
|
1147
|
-
* by module
|
|
1148
|
-
* the proven MCP `findHaps`, extended with
|
|
1149
|
-
* projects can install the right HAP.
|
|
1429
|
+
* by build module name (parsed from the HAP filename). Skips `node_modules` /
|
|
1430
|
+
* `oh_modules` / `.git`. Ported from the proven MCP `findHaps`, extended with
|
|
1431
|
+
* per-module grouping so multi-module projects can install the right HAP.
|
|
1432
|
+
* Empty object when nothing is built.
|
|
1150
1433
|
*/
|
|
1151
1434
|
declare function discoverHaps(opts: DiscoverHapsOptions): Promise<Record<string, ModuleHaps>>;
|
|
1152
1435
|
|
|
@@ -1476,4 +1759,4 @@ declare function applyChanges(opts: ApplyChangesOptions): Promise<ApplyChangesRe
|
|
|
1476
1759
|
|
|
1477
1760
|
declare const VERSION: string;
|
|
1478
1761
|
|
|
1479
|
-
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildGestureCommands, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createMaterial, createScaffold, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureOhModules, ensureOk, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, writeJson5File, writeJsonFile };
|
|
1762
|
+
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CmdWrapper, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GestureUitestOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, INSTALL_TMP_DIRNAME, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type InstallTempDir, type InstallTempDirOptions, InsufficientSpaceError, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, TMP_DIR_HINT, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildCmdWrapper, buildGestureCommands, buildGestureUitestCommand, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createInstallTempDir, createMaterial, createScaffold, createTempWorkDir, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureFreeSpace, ensureOhModules, ensureOk, ensureRemoteOk, escapeCmdArgument, escapeCmdCommand, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, formatBytes, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getFreeSpaceBytes, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isOutOfSpaceError, isRamBackedPath, isValidBundleName, isValidProjectName, killProcessTree, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, needsCmdWrapper, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, parseMainAbilityFromBmDump, parseRemoteExit, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, removeTempWorkDir, resolveTmpRoot, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, shellChecked, spawnCompat, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, toLongPath, toSpaceError, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, waypointsToRawEvents, writeJson5File, writeJsonFile };
|