@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 CHANGED
@@ -77,7 +77,7 @@ The injection points every frontend implements, plus their defaults.
77
77
 
78
78
  | Export | Description |
79
79
  | --- | --- |
80
- | `interface ConfigProvider` / `type ConfigKey` | `get(key, fallback)`. Keys: `sdkRootDir`, `cmdToolsPath`, `emulatorDir`, `hapPath`, `cmdToolsUrlLinux/Windows/Mac`, `emulatorUrl`, `sdkUrlBase`, `applicationCertPath`. |
80
+ | `interface ConfigProvider` / `type ConfigKey` | `get(key, fallback)`. Keys: `sdkRootDir`, `cmdToolsPath`, `emulatorDir`, `hapPath`, `cmdToolsUrlLinux/Windows/Mac`, `emulatorUrl`, `tmpDir`, `sdkUrlBase`, `applicationCertPath`. |
81
81
  | `staticConfig(values?)` | An in-memory `ConfigProvider` (expands `${userHome}`). For tests and as a base for frontend impls. |
82
82
  | `defaultPaths` | The fallback values core uses when a key is unset. |
83
83
  | `interface Logger` / `noopLogger` / `consoleLogger` | 4-level logger (`debug`/`info`/`warn`/`error`). Defaults to no-op. |
@@ -88,13 +88,13 @@ The injection points every frontend implements, plus their defaults.
88
88
 
89
89
  **Errors** — all extend `OniroError` (which carries an optional `cause`):
90
90
 
91
- `OniroError` · `SdkNotInstalledError` · `CmdToolsNotInstalledError` · `UnsupportedPlatformError` · `ChecksumMismatchError` · `CancelledError` · `CommandFailedError` (carries `command`, `exitCode`, `stderr`).
91
+ `OniroError` · `SdkNotInstalledError` · `CmdToolsNotInstalledError` · `UnsupportedPlatformError` · `ChecksumMismatchError` · `CancelledError` · `CommandFailedError` (carries `command`, `exitCode`, `stderr`) · `InsufficientSpaceError` (carries `dir`).
92
92
 
93
93
  ### SDK management
94
94
 
95
95
  | Export | Signature | Description |
96
96
  | --- | --- | --- |
97
- | `downloadAndInstallSdk` | `(InstallSdkOptions) => Promise<void>` | Download + install an SDK release into `<sdkRootDir>/<os>/<api>`, reporting progress. |
97
+ | `downloadAndInstallSdk` | `(InstallSdkOptions) => Promise<void>` | Download + install an SDK release into `<sdkRootDir>/<os>/<api>`, reporting progress; `tmpDir` overrides the scratch directory (default: next to the install target). |
98
98
  | `getSupportedSdksForUi` | `(config) => SdkInfo[]` | Known SDKs annotated with `installed`, newest first. |
99
99
  | `getInstalledSdks` | `(config) => string[]` | Versions with at least one OS-folder install. |
100
100
  | `removeSdk` | `(config, api) => boolean` | Remove an installed SDK by API level across OS folders. |
@@ -105,13 +105,25 @@ The injection points every frontend implements, plus their defaults.
105
105
 
106
106
  **Path resolvers** (all take `config`): `getSdkRootDir`, `getOhosBaseSdkHome`, `getCmdToolsPath`, `getEmulatorDir`, `getHdcPath`, `getOhpmPath`, `getCmdToolsBin(config, name?)`, `getHvigorwPath(config, projectDir)` (prefers the project-local wrapper only when it is structurally complete, else the bundled one).
107
107
 
108
- **Download/archive primitives**: `downloadFile(DownloadOptions)`, `verifySha256(file, sha256File)`, `extractZipWithProgress(ExtractZipOptions)` (Zip-Slip-safe), `extractTarball(tar, dest, strip?)`.
108
+ **Download/archive primitives**: `downloadFile(DownloadOptions)` (rejects with `InsufficientSpaceError` when the advertised `content-length` does not fit on the destination filesystem), `verifySha256(file, sha256File)`, `extractZipWithProgress(ExtractZipOptions)` (Zip-Slip-safe), `extractTarball(tar, dest, strip?)`.
109
+
110
+ **Temporary space**: the installers download and extract in a scratch directory resolved as
111
+ `options.tmpDir` → `tmpDir` config key → `<installRoot>/.oniro-tmp`. The default sits next to the
112
+ install target so the finished tree is renamed into place instead of copied across a device
113
+ boundary, and so the system temp dir — a RAM-backed `tmpfs` on most Linux systems, too small for a
114
+ multi-GB archive — is never involved. `createInstallTempDir(opts)` (returns `{ dir, root }`, and
115
+ falls back to `os.tmpdir()` when the install parent is unwritable) and `removeTempWorkDir(dir, root?)`
116
+ are the pair the installers use; `resolveTmpRoot(config, override?, installRoot?)`,
117
+ `createTempWorkDir(root, prefix)`, `getFreeSpaceBytes(dir)`, `isRamBackedPath(dir)`,
118
+ `ensureFreeSpace(dir, bytes, what)`, `isOutOfSpaceError(err)`, `toSpaceError(err, tmpRoot, what)`
119
+ (turns an `ENOSPC` into an `InsufficientSpaceError` naming the directory and the remedy),
120
+ `formatBytes(n)`, `INSTALL_TMP_DIRNAME`, `TMP_DIR_HINT`.
109
121
 
110
122
  ### Command-line tools
111
123
 
112
124
  | Export | Signature | Description |
113
125
  | --- | --- | --- |
114
- | `installCmdTools` | `(InstallCmdToolsOptions) => Promise<void>` | Install the tools by download or from a local zip (`localZipPath`). |
126
+ | `installCmdTools` | `(InstallCmdToolsOptions) => Promise<void>` | Install the tools by download or from a local zip (`localZipPath`); `tmpDir` overrides the scratch directory (default: next to the install target). |
115
127
  | `getCmdToolsStatus` | `(config) => CmdToolsStatus` | `{ installed, status }` (version when present). |
116
128
  | `isCmdToolsInstalled` | `(config) => boolean` | — |
117
129
  | `removeCmdTools` | `(config) => void` | Delete the install. |
@@ -135,7 +147,7 @@ The injection points every frontend implements, plus their defaults.
135
147
 
136
148
  | Export | Signature | Description |
137
149
  | --- | --- | --- |
138
- | `installEmulator` | `(InstallEmulatorOptions) => Promise<void>` | Download + extract the QEMU emulator into `emulatorDir`. |
150
+ | `installEmulator` | `(InstallEmulatorOptions) => Promise<void>` | Download + extract the QEMU emulator into `emulatorDir`; `tmpDir` overrides the scratch directory (default: next to the install target). |
139
151
  | `isEmulatorInstalled` / `removeEmulator` | `(config) => boolean` / `void` | — |
140
152
  | `startEmulator` | `(StartEmulatorOptions) => Promise<void>` | Launch detached via `run.sh`/`run.bat`; optional `headless`, `logFile`, `connect`, and `waitForHdcSeconds`. |
141
153
  | `stopEmulator` | `(logger?) => Promise<void>` | Kill running emulator processes. |