@oniroproject/core 0.13.0 → 0.14.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 CHANGED
@@ -172,11 +172,14 @@ The injection-safe primitives every device operation builds on (`spawn` with `sh
172
172
  | `listDevices` | `(config, opts?) => Promise<DeviceInfo[]>` | Parse `hdc list targets -v`. |
173
173
  | `selectDevice` | `(config, serial?, opts?) => Promise<string>` | Resolve the target: explicit serial → `ONIRO_DEVICE_SERIAL`/`DEVICE_SERIAL` env → the single connected device (throws on ambiguity). |
174
174
  | `parseDeviceList` | `(stdout) => DeviceInfo[]` | Pure parser (unit-testable). |
175
- | `paramGet` / `paramSet` | `(config, key[, value], opts?) => Promise<…>` | Read/write system properties via `param get`/`set`. |
175
+ | `resolveDeviceSerial` / `hdcTargetArgsFor` | `(explicit?) => string \| undefined` / `(args, explicit?) => string[]` | The serial (explicit → `ONIRO_DEVICE_SERIAL` → none) and the `-t` prefix `hdcExec` uses; hdc server commands only take an explicit one. |
176
+ | `hdcClientFailure` | `(output) => string \| null` | The `[Fail]…` line hdc printed while exiting 0; `hdcExec` reports it as exit code 1. |
177
+ | `paramGet` / `paramSet` | `(config, key[, value], opts?) => Promise<…>` | Read/write system properties via `param get`/`set`. `paramGet` throws for an unset property. |
178
+ | `paramGetMany` | `(config, keys, opts?) => Promise<Record<string, string \| undefined>>` | Read several properties in one round trip. |
176
179
 
177
180
  ### hdc — files
178
181
 
179
- `sendFile(SendFileOptions)` / `recvFile(RecvFileOptions)` — push/pull a file via `hdc file send`/`recv`.
182
+ `sendFile(SendFileOptions)` / `recvFile(RecvFileOptions)` — push/pull a file via `hdc file send`/`recv`. Local paths are normalised for hdc (`normaliseLocalPath`); a device path a Windows shell rewrote is rejected (`assertDevicePath`). `sendFile` with `bundle` writes into that app's sandbox (`appSandboxDir`) and chowns the file to the app.
180
183
 
181
184
  ### hdc — lifecycle & waiting
182
185
 
@@ -191,7 +194,9 @@ The injection-safe primitives every device operation builds on (`spawn` with `sh
191
194
 
192
195
  | Export | Signature | Description |
193
196
  | --- | --- | --- |
194
- | `installApp` | `(InstallAppOptions) => Promise<InstallAppResult>` | Install the signed `.hap` (resolves the path from `hapPath` / config / default). |
197
+ | `installApp` | `(InstallAppOptions) => Promise<InstallAppResult>` | Install a `.hap` (`hapPath` / config / the signed entry HAP / the newest built one, unsigned as a last resort). Throws when the bundle manager rejects it, with the reason and the signing to do when it refuses an unsigned HAP (`unsignedHapRejection`). |
198
+ | `detectInstallFailure` / `ensureInstallOk` | — | Spot a bundle-manager rejection in `hdc install` output, which exits 0 either way. |
199
+ | `isBundleInstalled` | `(BundleOptions) => Promise<boolean>` | `bm dump -n` check. |
195
200
  | `launchApp` | `(LaunchAppOptions) => Promise<void>` | `aa start` the entry ability (or an explicit `abilityName`). |
196
201
  | `uninstallApp` / `forceStop` | `(BundleOptions) => Promise<void>` | Uninstall / force-stop by bundle name. |
197
202
  | `findRunningProcess` | `(BundleOptions) => Promise<RunningProcess \| null>` | Non-throwing `pidof` check. |
@@ -231,6 +236,7 @@ The injection-safe primitives every device operation builds on (`spawn` with `sh
231
236
  | `waitForLog` | `(WaitForLogOptions) => Promise<HilogEntry>` | First entry matching a regex; auto-respawns the stream so it survives a reboot. |
232
237
  | `watchLog` | `(WatchLogOptions) => Promise<HilogEntry[]>` | Collect matches for a duration (deduped by default). |
233
238
  | `dumpLog` | `(DumpLogOptions) => Promise<HilogEntry[]>` | One-shot `hilog -x` filtered by domain/bundle/grep, capped to the last N lines. |
239
+ | `captureLog` | `(CaptureLogOptions) => Promise<CaptureLogResult>` | Stream hilog into a file until a deadline or abort, writing each line as it arrives and reconnecting after a reboot, so the small ring buffer cannot drop lines. |
234
240
  | `streamHilog` | `(StreamHilogOptions) => ChildProcessWithoutNullStreams` | Raw long-lived hilog stream (caller owns the process). |
235
241
  | `setHilogLevel` | `(SetHilogLevelOptions) => Promise<void>` | Set the buffer level. |
236
242
  | `parseHilogLine` / `dedupEntries` | — | Pure helpers; `HilogEntry` / `HilogLevel` types. |
@@ -239,12 +245,13 @@ The injection-safe primitives every device operation builds on (`spawn` with `sh
239
245
 
240
246
  | Export | Signature | Description |
241
247
  | --- | --- | --- |
242
- | `buildHap` | `(BuildHapOptions) => Promise<BuildHapResult>` | High-level orchestration: ensure deps → `hvigorw` → discover built HAPs. The call most consumers want. |
248
+ | `buildHap` | `(BuildHapOptions) => Promise<BuildHapResult>` | High-level orchestration: ensure deps → `hvigorw` → discover built HAPs. The call most consumers want. Throws `SdkNotInstalledError` (with the `version` to install) up front when an OpenHarmony project's SDK is missing; `diagnoseBuildFailure` adds a hint for system-API errors. |
243
249
  | `runHvigorw` | `(RunHvigorwOptions) => Promise<RunHvigorwResult>` | Raw single `hvigorw` spawn. Parallel by default; `parallel: false` adds `--no-parallel`. |
244
250
  | `buildHvigorwArgs` | `(opts) => string[]` | Pure argv builder (unit-testable). |
245
- | `discoverHaps` | `(DiscoverHapsOptions) => Promise<Record<string, ModuleHaps>>` | Group `*-signed`/`*-unsigned` HAPs by module. |
251
+ | `discoverHaps` | `(DiscoverHapsOptions) => Promise<Record<string, ModuleHaps>>` | Group `*-signed`/`*-unsigned` HAPs by module, newest first. |
252
+ | `pickHap` | `(haps, module?) => PickedHap \| null` | The HAP to install: a signed one, else unsigned (`signed: false`). |
246
253
  | `runOhpm` / `ensureOhModules` | — | Run `ohpm`; install `--all` only when `oh_modules/` is missing. |
247
- | `runCodelinter` / `parseCodelinterFindings` | — | Run the codelinter → `CodelinterResult { code, findings, raw }`. |
254
+ | `runCodelinter` / `parseCodelinterReport` / `parseCodelinterFindings` | — | Run the codelinter → `CodelinterResult { code, findings, summary, notices, incomplete, raw }`; the parsers read its per-file table and `-Defects:` totals. |
248
255
 
249
256
  ### Project scaffolding & inspection
250
257
 
@@ -261,13 +268,13 @@ The injection-safe primitives every device operation builds on (`spawn` with `sh
261
268
 
262
269
  ### Device info
263
270
 
264
- `getDeviceInfo(GetDeviceInfoOptions) => Promise<DeviceFullInfo>` collates device properties + display resolution. `dumpScreen` / `dumpWindow` / `dumpRenderService` wrap the corresponding `hidumper` services.
271
+ `getDeviceInfo(GetDeviceInfoOptions) => Promise<DeviceFullInfo>` collates device properties (model, `osFamily` HarmonyOS / OpenHarmony, `osDistVersion`, API level, `abi`, `deviceType`, …) in one round trip, plus the display resolution. `dumpScreen` / `dumpWindow` / `dumpRenderService` wrap the corresponding `hidumper` services.
265
272
 
266
273
  ### Install orchestration
267
274
 
268
275
  | Export | Signature | Description |
269
276
  | --- | --- | --- |
270
- | `applyChanges` | `(ApplyChangesOptions) => Promise<ApplyChangesResult>` | Install a HAP **and verify the process took it** — handles sign-info mismatch, asset-cache invalidation (reboot), and persistent-bundle restart. |
277
+ | `applyChanges` | `(ApplyChangesOptions) => Promise<ApplyChangesResult>` | Install a HAP **and verify it took**: throws on a bundle-manager rejection or when `bm dump` does not list the bundle afterwards; handles sign-info mismatch, asset-cache invalidation (reboot), and persistent-bundle restart. |
271
278
  | `decideInstallMethod` / `decideReboot` | — | The pure (tested) decision functions behind `applyChanges`. |
272
279
  | `diffHapAssets` / `diffEntryNames` | — | Diff two HAP archives' file manifests (drives the cache-invalidation reboot). |
273
280
 
@@ -308,7 +315,7 @@ DevEco Studio. Parts of this subtree are adapted from the MIT-licensed
308
315
 
309
316
  - **Configuration.** Pass a `ConfigProvider`. `staticConfig({...})` is the quick path; a frontend can read settings, env vars, etc. Unset keys fall back to `defaultPaths`.
310
317
  - **Logging & progress are opt-in.** Omit `logger`/`progress` for silence, or pass `consoleLogger` / your own. Nothing is written to `console` by default.
311
- - **Device targeting.** Pass `deviceSerial` to address a specific target; omit it to use the default connected device. `selectDevice` additionally honors `ONIRO_DEVICE_SERIAL` / `DEVICE_SERIAL`.
318
+ - **Device targeting.** Pass `deviceSerial` to address a specific target. Without it, every device operation addresses `ONIRO_DEVICE_SERIAL` / `DEVICE_SERIAL` when set, else hdc's single connected device. hdc's `[Fail]` lines (exit code 0 from hdc) surface as failures.
312
319
  - **Timeouts & cancellation.** Device ops take `timeoutMs` (sane per-op defaults) and `abortSignal`; aborting rejects with `CancelledError`.
313
320
  - **Error model.** Exec primitives (`runProcess`/`hdcExec`/`shell`) resolve for any exit code — call `ensureOk` to throw `CommandFailedError`. Everything else throws a typed `OniroError` subclass.
314
321
  - **No surprises in returns.** Functions return plain JSON-safe data; screenshots/bursts return raw `Buffer`s. No image decoding, no `sharp`-style dependency.