@qvac/tts-ggml 0.11.1 → 0.12.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
@@ -54,8 +54,9 @@ validated on Apple/Metal.
54
54
  iOS, picked up when staged next to the model (see
55
55
  [Core ML sidecars on Apple](#core-ml-sidecars-on-apple)).
56
56
  - **Dynamic backend loading on Android** — per-arch CPU + Vulkan +
57
- OpenCL `.so` files ship under `prebuilds/<bare-target>/qvac__tts-ggml/`
58
- and are picked up at runtime via the new `backendsDir` option (see
57
+ OpenCL `.so` files ship under
58
+ `prebuilds/<bare-target>/qvac__tts-ggml-android-arm64/` and the addon picks
59
+ them up at runtime from next to its native module (see
59
60
  [Backends & GPU acceleration](#backends--gpu-acceleration)).
60
61
  - **Cancellation** via `model.cancel()` — stops T3 decode on the next
61
62
  token; in-flight S3Gen chunk runs to completion.
@@ -150,11 +151,10 @@ package selected at install time through `os`/`cpu` filtered
150
151
 
151
152
  Do not depend on desktop platform packages directly. Supported installers are
152
153
  npm 7+, pnpm, bun, and Yarn Berry. Yarn v1 and `--omit=optional` installs skip
153
- the platform package and fail at require time with an error naming the missing
154
- package; a locally built `prebuilds/` directory in the package root always
155
- takes precedence. Use `require('@qvac/tts-ggml').resolveBackendsDir()` to
156
- locate the directory holding the host's prebuilt binaries and dynamically
157
- loaded ggml backends. Unsupported targets must
154
+ the platform package and fail at require time, and at `bare-pack` time, naming
155
+ the missing package. Each platform package is an ordinary Bare addon whose
156
+ `prebuilds/<host>/` holds the native module and, next to it, the dynamically
157
+ loaded ggml backends the module finds on its own. Unsupported targets must
158
158
  [build from source](#build-from-source); installation does not automatically
159
159
  compile a local addon.
160
160
 
@@ -805,13 +805,13 @@ registration and the addon falls back to Vulkan or CPU.
805
805
 
806
806
  Android prebuilds enable `GGML_BACKEND_DL=ON` and ship per-arch
807
807
  backend `.so` files under
808
- `prebuilds/<bare-target>/qvac__tts-ggml/`.
808
+ `prebuilds/android-arm64/qvac__tts-ggml-android-arm64/` of
809
+ `@qvac/tts-ggml-android-arm64`; `bare-link` puts them next to the module in
810
+ the app, where the addon looks when `backendsDir` is unset.
809
811
 
810
812
  The engine `dlopen()`s the highest-tier CPU variant the device's
811
813
  HWCAPs support and one of the GPU `.so` files based on the policy
812
- table above. Hosts must pass `backendsDir: path.join(__dirname,
813
- 'prebuilds')` (or rely on the default fallback the package ships)
814
- so the runtime knows where to look. `openclCacheDir` is also
814
+ table above. `openclCacheDir` is
815
815
  Android-specific; setting it to a writable path lets the OpenCL
816
816
  backend persist its compiled program cache across launches.
817
817
  `vulkanCacheDir` is the Vulkan analogue (Supertonic + `useGPU: true`):
@@ -1228,7 +1228,7 @@ instance. Runtime stats add `promptTokens`, `generatedTokens`, `replyTokens`,
1228
1228
  | `promptText` | string | — | CosyVoice3-only: verbatim transcript of `referenceAudio` — set for zero-shot cloning, omit for cross-lingual; without a reference it overrides the baked voice's transcript |
1229
1229
  | `mecabDictDir` | string | — | Chatterbox MTL Japanese (`ja`): compiled MeCab/IPAdic dictionary directory |
1230
1230
  | `cangjieTsvPath` | string | — | Chatterbox MTL Chinese (`zh`): `Cangjie5_TC` TSV path |
1231
- | `backendsDir` | string | `resolveBackendsDir()` | Root dir the addon scans for dynamically-loaded ggml backend `.so` files. Defaults to the package's own `prebuilds/` when present, otherwise the installed platform package. Required on Android when backends ship elsewhere (e.g. inside the APK); ignored on platforms that statically link the backend |
1231
+ | `backendsDir` | string | the module's own | Directory the addon scans, as given, for dynamically-loaded ggml backend `.so` / `.dll` files. Unset scans the directory the native module was loaded from (`prebuilds/<host>/qvac__tts-ggml-<suffix>/` in a platform package, the app's native library directory after `bare-link`); ignored on platforms that statically link the backend |
1232
1232
  | `openclCacheDir` | string | unset | Android-only: directory where the OpenCL backend persists its compiled program-binary cache. Setting it across runs avoids re-JITing the kernels on every fresh process |
1233
1233
  | `vulkanCacheDir` | string | unset | Supertonic + `useGPU: true` only: writable directory where the Vulkan backend persists its compiled pipeline cache (`GGML_VK_PIPELINE_CACHE_DIR`). Moves the one-time first-dispatch pipeline-compile cost (seconds on Mali) off the first `run()` — paid once per install instead of once per process — and enables a load-time pre-warm. Fully opt-in: unset -> no cross-process cache, no pre-warm, behaviour unchanged |
1234
1234
  | `config.language` | string | `"en"` | Chatterbox MTL accepts `es/fr/de/pt/it/zh/ja/ko/...`; turbo & Supertonic are English; MOSS takes it as a prompt hint (`en`, `zh`, ...) |
@@ -1571,8 +1571,14 @@ npm install
1571
1571
  npx bare-make generate # configures + fetches the tts-cpp port
1572
1572
  npx bare-make build
1573
1573
  npx bare-make install # copies the .bare into prebuilds/<triple>/
1574
+ npm run link:platform # stages node_modules/@qvac/tts-ggml-<host>
1574
1575
  ```
1575
1576
 
1577
+ `require('#host-addon')` only ever loads a platform package, so a source
1578
+ build becomes loadable once `npm run link:platform` (run by
1579
+ `npm run build:native`) wraps `prebuilds/<host>/` as that host's
1580
+ `@qvac/tts-ggml-<host>` package in `node_modules/`.
1581
+
1576
1582
  The vcpkg port is hosted in
1577
1583
  [`tetherto/qvac-registry-vcpkg`][registry] and pulls
1578
1584
  [`qvac-tts.cpp`][qvac-tts-cpp] at a pinned REF. See
@@ -1,31 +1,15 @@
1
- const { hostPlatformPackage, PREBUILT_HOSTS } = require('./lib/backends.js')
1
+ 'use strict'
2
2
 
3
- const META_PACKAGE = '@qvac/tts-ggml'
4
- const UNKNOWN_HOST = 'unknown'
3
+ // "#host-addon" target for hosts with no platform package. Hosts that have one
4
+ // map straight to it with no fallback, so a missing install fails bare-pack (and
5
+ // fails at run time naming the package) instead of producing a bundle that only
6
+ // throws once launched.
7
+ const host = require.addon ? require.addon.host : 'unknown'
5
8
 
6
- throw new Error(buildMessage(currentHost()))
7
-
8
- function currentHost() {
9
- return require.addon ? require.addon.host : null
10
- }
11
-
12
- function buildMessage(host) {
13
- if (!host || !PREBUILT_HOSTS.includes(host)) {
14
- return (
15
- META_PACKAGE +
16
- ' has no prebuilt binaries for host ' +
17
- (host || UNKNOWN_HOST) +
18
- '. Prebuilt hosts: ' +
19
- PREBUILT_HOSTS.join(', ') +
20
- '. Build from source with bare-make.'
21
- )
22
- }
23
- return (
24
- META_PACKAGE +
25
- ' found no native prebuild for ' +
9
+ throw new Error(
10
+ '@qvac/tts-ggml has no prebuilt binaries for host ' +
26
11
  host +
27
- ': the platform package ' +
28
- hostPlatformPackage(host) +
29
- ' is not installed. It ships as an os/cpu filtered optional dependency, which Yarn v1 and installs using --omit=optional drop. Reinstall with npm 7+, pnpm, bun, or Yarn Berry, or build from source with bare-make.'
30
- )
31
- }
12
+ '. Platform packages exist for linux-x64, linux-arm64, darwin-arm64, ' +
13
+ 'darwin-x64, win32-x64, android-arm64 and ios (ios-arm64, ' +
14
+ 'ios-arm64-simulator, ios-x64-simulator). Build from source with bare-make.'
15
+ )
package/binding.js CHANGED
@@ -1,52 +1 @@
1
- module.exports = loadAddon()
2
-
3
- // `require.addon()` reads the prebuild shipped inside this package. Since the
4
- // per-platform split (0.9.0) there is none, so the real binding almost always
5
- // comes from the `#host-addon` platform package. Runtimes have been seen to
6
- // answer `require.addon()` with this package's own JavaScript entry instead of
7
- // failing, which used to be returned verbatim: callers then got a module with
8
- // no `createInstance`, and the first symptom was an unrelated TypeError deep in
9
- // a model load. Anything that is not the native binding is treated as a miss.
10
- function loadAddon() {
11
- let cause = null
12
-
13
- try {
14
- const addon = require.addon()
15
- if (isNativeBinding(addon)) return addon
16
- cause = new Error(
17
- '@qvac/tts-ggml: require.addon() answered with a module that is not the native binding ' +
18
- '(no createInstance function), so the prebuild in this package was treated as absent.'
19
- )
20
- } catch (err) {
21
- cause = err
22
- }
23
-
24
- return loadPlatformPackageAddon(cause)
25
- }
26
-
27
- function loadPlatformPackageAddon(cause) {
28
- let addon
29
-
30
- try {
31
- addon = require('#host-addon')
32
- } catch (err) {
33
- if (err.cause === undefined) err.cause = cause
34
- throw err
35
- }
36
-
37
- if (!isNativeBinding(addon)) {
38
- const err = new Error(
39
- '@qvac/tts-ggml resolved #host-addon to a module that is not the native binding: ' +
40
- 'it has no createInstance function. Check that the platform package for this host ' +
41
- 'is installed and is not shadowed by another module of the same name.'
42
- )
43
- err.cause = cause
44
- throw err
45
- }
46
-
47
- return addon
48
- }
49
-
50
- function isNativeBinding(addon) {
51
- return addon !== null && typeof addon === 'object' && typeof addon.createInstance === 'function'
52
- }
1
+ module.exports = require('#host-addon')
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type QvacResponse } from "@qvac/infer-base";
2
2
  import * as errorModule from "./lib/error";
3
- import { resolveBackendsDir as resolveBackendsDirImpl } from "./lib/backends";
4
3
  import { assessFit as assessFitImpl, type Audio8FitRequest, type MossFitRequest, type MossSoundEffectFitRequest, type ChatterboxFitRequest, type CosyvoiceFitRequest, type ParlerFitRequest, type SupertonicFitRequest, type TtsFitEngine, type TtsFitRequest, type TtsFitResult, type TtsFitStatus } from "./lib/fit";
5
4
  import { type SentenceDelimiterPreset } from "./lib/textStreamAccumulator";
6
5
  declare const ENGINE_CHATTERBOX = "chatterbox";
@@ -607,7 +606,11 @@ interface TTSGgmlOptions extends ParlerDescriptionFields, Audio8VoiceFields, TTS
607
606
  * streaming (batch synthesis only).
608
607
  */
609
608
  denoiser?: LavaSRDenoiserOptions;
610
- /** Directory the addon scans for dynamically loaded ggml backends. */
609
+ /**
610
+ * Directory the addon scans for dynamically loaded ggml backends, as given.
611
+ * Unset scans the addon's own: the one its platform package or the app
612
+ * installed next to the native module.
613
+ */
611
614
  backendsDir?: string;
612
615
  /** Directory where ggml-opencl persists its compiled program binary. */
613
616
  openclCacheDir?: string;
@@ -1211,7 +1214,6 @@ declare namespace TTSGgml {
1211
1214
  type MossFitRequest = NamespaceMossFit;
1212
1215
  type MossSoundEffectFitRequest = NamespaceMossSoundEffectFit;
1213
1216
  type CosyvoiceFitRequest = NamespaceCosyvoiceFit;
1214
- const resolveBackendsDir: typeof resolveBackendsDirImpl;
1215
1217
  const assessFit: typeof assessFitImpl;
1216
1218
  }
1217
1219
  export = TTSGgml;
package/index.js CHANGED
@@ -46,7 +46,6 @@ const infer_base_1 = require("@qvac/infer-base");
46
46
  const tts_1 = require("./tts");
47
47
  const errorModule = __importStar(require("./lib/error"));
48
48
  const pocketConfig_1 = require("./lib/pocketConfig");
49
- const backends_1 = require("./lib/backends");
50
49
  const fit_1 = require("./lib/fit");
51
50
  const textChunker_1 = require("./lib/textChunker");
52
51
  const textStreamAccumulator_1 = require("./lib/textStreamAccumulator");
@@ -1293,7 +1292,7 @@ class TTSGgml {
1293
1292
  this._assignSynthesisOptions(options);
1294
1293
  this._enhancerGgufPath = resolveEnhancerGgufPath(normalizedFiles, options.enhancer);
1295
1294
  this._denoiserGgufPath = resolveDenoiserGgufPath(normalizedFiles, options.denoiser);
1296
- this._backendsDir = firstNonEmpty(options.backendsDir, this._config.backendsDir, (0, backends_1.resolveBackendsDir)());
1295
+ this._backendsDir = firstNonEmpty(options.backendsDir, this._config.backendsDir);
1297
1296
  this._openclCacheDir = firstNonEmpty(options.openclCacheDir, this._config.openclCacheDir);
1298
1297
  this._vulkanCacheDir = firstNonEmpty(options.vulkanCacheDir, this._config.vulkanCacheDir);
1299
1298
  assertGpuIntentConsistent(this._config.useGPU, this._nGpuLayers);
@@ -3311,7 +3310,6 @@ class TTSGgml {
3311
3310
  (function (TTSGgml) {
3312
3311
  TTSGgml.QvacErrorAddonTTSGgml = errorModule.QvacErrorAddonTTSGgml;
3313
3312
  TTSGgml.ERR_CODES = errorModule.ERR_CODES;
3314
- TTSGgml.resolveBackendsDir = backends_1.resolveBackendsDir;
3315
3313
  TTSGgml.assessFit = fit_1.assessFit;
3316
3314
  })(TTSGgml || (TTSGgml = {}));
3317
3315
  module.exports.QvacErrorAddonTTSGgml =
package/lib/fit.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assessFit = assessFit;
4
- const backends_1 = require("./backends");
5
4
  /**
6
5
  * Projects one voice against the memory free right now, reading GGUF metadata
7
6
  * and never weight data. The registry's weightless copy of each file answers
@@ -18,12 +17,7 @@ const backends_1 = require("./backends");
18
17
  * throws.
19
18
  */
20
19
  function assessFit(request) {
21
- // eslint-disable-next-line @typescript-eslint/no-require-imports -- native binding is resolved lazily from package prebuilds.
20
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- the native binding loads on first use.
22
21
  const binding = require('../binding.js');
23
- return binding.assessFit({
24
- ...request,
25
- backendsDir: typeof request.backendsDir === 'string' && request.backendsDir.length > 0
26
- ? request.backendsDir
27
- : (0, backends_1.resolveBackendsDir)()
28
- });
22
+ return binding.assessFit(request);
29
23
  }
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@qvac/tts-ggml",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "Text to Speech (TTS) addon for qvac (ggml backend, wrapping the chatterbox + supertonic + parler + cosyvoice3 + audio8 + moss + moss-sfx + moss-speech + Pocket engines from tts-cpp)",
5
- "addon": true,
6
5
  "qvac": {
7
6
  "ggml-speech": "2026-10-07#1"
8
7
  },
@@ -12,52 +11,32 @@
12
11
  "imports": {
13
12
  "#host-addon": {
14
13
  "linux": {
15
- "x64": [
16
- "@qvac/tts-ggml-linux-x64",
17
- "./addon-unavailable.js"
18
- ],
19
- "arm64": [
20
- "@qvac/tts-ggml-linux-arm64",
21
- "./addon-unavailable.js"
22
- ],
14
+ "x64": "@qvac/tts-ggml-linux-x64",
15
+ "arm64": "@qvac/tts-ggml-linux-arm64",
23
16
  "default": "./addon-unavailable.js"
24
17
  },
25
18
  "darwin": {
26
- "arm64": [
27
- "@qvac/tts-ggml-darwin-arm64",
28
- "./addon-unavailable.js"
29
- ],
30
- "x64": [
31
- "@qvac/tts-ggml-darwin-x64",
32
- "./addon-unavailable.js"
33
- ],
19
+ "arm64": "@qvac/tts-ggml-darwin-arm64",
20
+ "x64": "@qvac/tts-ggml-darwin-x64",
34
21
  "default": "./addon-unavailable.js"
35
22
  },
36
23
  "win32": {
37
- "x64": [
38
- "@qvac/tts-ggml-win32-x64",
39
- "./addon-unavailable.js"
40
- ],
24
+ "x64": "@qvac/tts-ggml-win32-x64",
41
25
  "default": "./addon-unavailable.js"
42
26
  },
43
27
  "android": {
44
- "arm64": [
45
- "@qvac/tts-ggml-android-arm64",
46
- "./addon-unavailable.js"
47
- ],
28
+ "arm64": "@qvac/tts-ggml-android-arm64",
48
29
  "default": "./addon-unavailable.js"
49
30
  },
50
- "ios": [
51
- "@qvac/tts-ggml-ios",
52
- "./addon-unavailable.js"
53
- ],
31
+ "ios": "@qvac/tts-ggml-ios",
54
32
  "default": "./addon-unavailable.js"
55
33
  }
56
34
  },
57
35
  "scripts": {
58
36
  "build": "npm run build:ts && npm run build:native",
59
- "build:native": "bare-make generate -D BUILD_FUZZING=OFF && bare-make build && bare-make install",
60
- "build:native:cuda": "bare-make generate -D ENABLE_CUDA=ON -D BUILD_FUZZING=OFF && bare-make build && bare-make install",
37
+ "build:native": "bare-make generate -D BUILD_FUZZING=OFF && bare-make build && bare-make install && npm run link:platform",
38
+ "build:native:cuda": "bare-make generate -D ENABLE_CUDA=ON -D BUILD_FUZZING=OFF && bare-make build && bare-make install && npm run link:platform",
39
+ "link:platform": "node ../../scripts/ci/slice-platform-packages.mjs --link-local --workdir .",
61
40
  "build:cuda": "npm run build:ts && npm run build:native:cuda",
62
41
  "build:ts": "tsc -p tsconfig.build.json",
63
42
  "build:pack": "npm run build:ts && mkdir -p dist && npm pack --pack-destination dist",
@@ -86,10 +65,10 @@
86
65
  "example:moss-sfx": "bare examples/moss-sound-effect.js \"Heavy rain falling on a tin roof with distant thunder.\" 5",
87
66
  "example:moss-speech": "bare examples/moss-speech.js test/reference-audio/jfk.wav",
88
67
  "lint": "npm run lint:js && npm run lint:ts && npm run test:types",
89
- "lint:js": "prettier --check \"test/**/*.js\" \"scripts/run-cpp-fuzz.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"scripts/__tests__/run-cpp-fuzz.test.js\" \"binding.js\" \"addon-unavailable.js\" && lunte \"test/**/*.js\" \"scripts/run-cpp-fuzz.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"scripts/__tests__/run-cpp-fuzz.test.js\" \"binding.js\" \"addon-unavailable.js\"",
68
+ "lint:js": "prettier --check \"test/**/*.js\" \"scripts/run-cpp-fuzz.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/run-cpp-fuzz.test.js\" \"binding.js\" \"addon-unavailable.js\" && lunte \"test/**/*.js\" \"scripts/run-cpp-fuzz.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/run-cpp-fuzz.test.js\" \"binding.js\" \"addon-unavailable.js\"",
90
69
  "lint:ts": "eslint \"src/**/*.ts\" --max-warnings=0",
91
70
  "lint:ts:fix": "eslint \"src/**/*.ts\" --fix",
92
- "format": "prettier --write \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"binding.js\" \"addon-unavailable.js\"",
71
+ "format": "prettier --write \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"binding.js\" \"addon-unavailable.js\"",
93
72
  "test:unit": "npm run build:ts && brittle-bare test/unit/**/*.test.js && npm run test:node",
94
73
  "test:node": "node --test scripts/__tests__/*.test.js",
95
74
  "test": "npm run test:types && npm run test:unit && npm run test:integration",
@@ -232,12 +211,24 @@
232
211
  "bare-stream": "^2.7.0",
233
212
  "bare-url": "^2.4.3"
234
213
  },
235
- "types": "index.d.ts",
236
214
  "optionalDependencies": {
237
- "@qvac/tts-ggml-linux-x64": "0.11.1",
238
- "@qvac/tts-ggml-linux-arm64": "0.11.1",
239
- "@qvac/tts-ggml-darwin-arm64": "0.11.1",
240
- "@qvac/tts-ggml-darwin-x64": "0.11.1",
241
- "@qvac/tts-ggml-win32-x64": "0.11.1"
215
+ "@qvac/tts-ggml-linux-x64": "0.12.0",
216
+ "@qvac/tts-ggml-linux-arm64": "0.12.0",
217
+ "@qvac/tts-ggml-darwin-arm64": "0.12.0",
218
+ "@qvac/tts-ggml-darwin-x64": "0.12.0",
219
+ "@qvac/tts-ggml-win32-x64": "0.12.0"
220
+ },
221
+ "types": "index.d.ts",
222
+ "peerDependencies": {
223
+ "@qvac/tts-ggml-android-arm64": "0.12.0",
224
+ "@qvac/tts-ggml-ios": "0.12.0"
225
+ },
226
+ "peerDependenciesMeta": {
227
+ "@qvac/tts-ggml-android-arm64": {
228
+ "optional": true
229
+ },
230
+ "@qvac/tts-ggml-ios": {
231
+ "optional": true
232
+ }
242
233
  }
243
234
  }
package/lib/backends.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare const PREBUILT_HOSTS: string[];
2
- export interface BackendsDirSources {
3
- localPrebuildsDir: string;
4
- host: string | null;
5
- directoryExists: (dir: string) => boolean;
6
- resolveManifest: (specifier: string) => string | null;
7
- }
8
- export declare function hostPlatformPackage(host: string): string;
9
- export declare function resolveBackendsDirFrom(sources: BackendsDirSources): string;
10
- export declare function resolveBackendsDir(): string;
package/lib/backends.js DELETED
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PREBUILT_HOSTS = void 0;
4
- exports.hostPlatformPackage = hostPlatformPackage;
5
- exports.resolveBackendsDirFrom = resolveBackendsDirFrom;
6
- exports.resolveBackendsDir = resolveBackendsDir;
7
- /* eslint-disable @typescript-eslint/no-require-imports -- Bare modules expose CommonJS export shapes. */
8
- const fs = require("bare-fs");
9
- const path = require("bare-path");
10
- /* eslint-enable @typescript-eslint/no-require-imports */
11
- const PACKAGE_ROOT = path.join(__dirname, "..");
12
- const PREBUILDS_DIR_NAME = "prebuilds";
13
- const PLATFORM_ADDON_DIR_NAME = "addon";
14
- const PLATFORM_PACKAGE_PREFIX = "@qvac/tts-ggml-";
15
- const PLATFORM_MANIFEST_SUBPATH = "/package";
16
- const IOS_PLATFORM = "ios";
17
- const HOST_SEPARATOR = "-";
18
- exports.PREBUILT_HOSTS = [
19
- "linux-x64",
20
- "linux-arm64",
21
- "darwin-arm64",
22
- "darwin-x64",
23
- "win32-x64",
24
- "android-arm64",
25
- "ios-arm64",
26
- "ios-arm64-simulator",
27
- "ios-x64-simulator",
28
- ];
29
- function hostPlatformPackage(host) {
30
- const platform = host.split(HOST_SEPARATOR)[0];
31
- const suffix = platform === IOS_PLATFORM ? IOS_PLATFORM : host;
32
- return PLATFORM_PACKAGE_PREFIX + suffix;
33
- }
34
- function resolveBackendsDirFrom(sources) {
35
- if (sources.directoryExists(sources.localPrebuildsDir)) {
36
- return sources.localPrebuildsDir;
37
- }
38
- return platformPackagePrebuildsDir(sources) ?? sources.localPrebuildsDir;
39
- }
40
- function platformPackagePrebuildsDir(sources) {
41
- if (!sources.host) {
42
- return null;
43
- }
44
- const manifestPath = sources.resolveManifest(hostPlatformPackage(sources.host) + PLATFORM_MANIFEST_SUBPATH);
45
- if (!manifestPath) {
46
- return null;
47
- }
48
- return path.join(path.dirname(manifestPath), PLATFORM_ADDON_DIR_NAME, PREBUILDS_DIR_NAME);
49
- }
50
- function resolveBackendsDir() {
51
- return resolveBackendsDirFrom({
52
- localPrebuildsDir: path.join(PACKAGE_ROOT, PREBUILDS_DIR_NAME),
53
- host: currentHost(),
54
- directoryExists: safeDirectoryExists,
55
- resolveManifest: safeResolveManifest,
56
- });
57
- }
58
- function currentHost() {
59
- return require.addon ? require.addon.host : null;
60
- }
61
- function safeDirectoryExists(dir) {
62
- try {
63
- return fs.existsSync(dir);
64
- }
65
- catch {
66
- return false;
67
- }
68
- }
69
- function safeResolveManifest(specifier) {
70
- try {
71
- return require.resolve(specifier);
72
- }
73
- catch {
74
- return null;
75
- }
76
- }