@qvac/tts-ggml 0.9.0 → 0.9.2

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.
Files changed (3) hide show
  1. package/README.md +25 -7
  2. package/binding.js +37 -3
  3. package/package.json +8 -10
package/README.md CHANGED
@@ -119,8 +119,9 @@ npm install @qvac/tts-ggml
119
119
  Requires [Bare](https://github.com/holepunchto/bare) `>=1.19.0`.
120
120
 
121
121
  `@qvac/tts-ggml` is a meta package that ships the JavaScript wrapper only.
122
- The native prebuild for each host lives in a version-locked platform package
123
- selected at install time through `os`/`cpu` filtered `optionalDependencies`:
122
+ The native prebuild for each desktop host lives in a version-locked platform
123
+ package selected at install time through `os`/`cpu` filtered
124
+ `optionalDependencies`:
124
125
 
125
126
  | Host | Package |
126
127
  | --- | --- |
@@ -129,12 +130,10 @@ selected at install time through `os`/`cpu` filtered `optionalDependencies`:
129
130
  | darwin-arm64 | `@qvac/tts-ggml-darwin-arm64` |
130
131
  | darwin-x64 | `@qvac/tts-ggml-darwin-x64` |
131
132
  | win32-x64 | `@qvac/tts-ggml-win32-x64` |
132
- | android-arm64 | `@qvac/tts-ggml-android-arm64` |
133
- | ios (device + simulators) | `@qvac/tts-ggml-ios` |
134
133
 
135
- Do not depend on platform packages directly. Supported installers are npm 7+,
136
- pnpm, bun, and Yarn Berry. Yarn v1 and `--omit=optional` installs skip the
137
- platform package and fail at require time with an error naming the missing
134
+ Do not depend on desktop platform packages directly. Supported installers are
135
+ npm 7+, pnpm, bun, and Yarn Berry. Yarn v1 and `--omit=optional` installs skip
136
+ the platform package and fail at require time with an error naming the missing
138
137
  package; a locally built `prebuilds/` directory in the package root always
139
138
  takes precedence. Use `require('@qvac/tts-ggml').resolveBackendsDir()` to
140
139
  locate the directory holding the host's prebuilt binaries and dynamically
@@ -142,6 +141,25 @@ loaded ggml backends. Unsupported targets must
142
141
  [build from source](#build-from-source); installation does not automatically
143
142
  compile a local addon.
144
143
 
144
+ Mobile targets are cross-built, so no install host ever matches their `os`,
145
+ and `optionalDependencies` filtering can never select them. Mobile
146
+ applications must declare the target's platform package as a direct
147
+ dependency, pinned to the exact `@qvac/tts-ggml` version:
148
+
149
+ | Target | Package |
150
+ | --- | --- |
151
+ | android-arm64 | `@qvac/tts-ggml-android-arm64` |
152
+ | ios (device + simulators) | `@qvac/tts-ggml-ios` |
153
+
154
+ ```json
155
+ {
156
+ "dependencies": {
157
+ "@qvac/tts-ggml": "x.y.z",
158
+ "@qvac/tts-ggml-android-arm64": "x.y.z"
159
+ }
160
+ }
161
+ ```
162
+
145
163
  ## Model files
146
164
 
147
165
  Five engine families are wrapped (Chatterbox, Supertonic, Parler,
package/binding.js CHANGED
@@ -1,18 +1,52 @@
1
1
  module.exports = loadAddon()
2
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.
3
10
  function loadAddon() {
11
+ let cause = null
12
+
4
13
  try {
5
- return require.addon()
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
+ )
6
20
  } catch (err) {
7
- return loadPlatformPackageAddon(err)
21
+ cause = err
8
22
  }
23
+
24
+ return loadPlatformPackageAddon(cause)
9
25
  }
10
26
 
11
27
  function loadPlatformPackageAddon(cause) {
28
+ let addon
29
+
12
30
  try {
13
- return require('#host-addon')
31
+ addon = require('#host-addon')
14
32
  } catch (err) {
15
33
  if (err.cause === undefined) err.cause = cause
16
34
  throw err
17
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'
18
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/tts-ggml",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Text to Speech (TTS) addon for qvac (ggml backend, wrapping the chatterbox + supertonic + parler + cosyvoice3 + audio8 engines from tts-cpp)",
5
5
  "addon": true,
6
6
  "engines": {
@@ -79,10 +79,10 @@
79
79
  "example:parler-enhanced": "bare examples/parler-enhanced.js \"Hello from enhanced Parler.\"",
80
80
  "example:audio8": "bare examples/audio8-tts.js \"Audio eight speaks on-device.\"",
81
81
  "lint": "npm run lint:js && npm run lint:ts && npm run test:types",
82
- "lint:js": "prettier --check \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"binding.js\" \"addon-unavailable.js\" && lunte \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"binding.js\" \"addon-unavailable.js\"",
82
+ "lint:js": "prettier --check \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"binding.js\" \"addon-unavailable.js\" && lunte \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"binding.js\" \"addon-unavailable.js\"",
83
83
  "lint:ts": "eslint \"src/**/*.ts\" --max-warnings=0",
84
84
  "lint:ts:fix": "eslint \"src/**/*.ts\" --fix",
85
- "format": "prettier --write \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"binding.js\" \"addon-unavailable.js\"",
85
+ "format": "prettier --write \"test/**/*.js\" \"scripts/__tests__/package-contract.test.js\" \"scripts/__tests__/binding-loader.test.js\" \"binding.js\" \"addon-unavailable.js\"",
86
86
  "test:unit": "npm run build:ts && brittle-bare test/unit/**/*.test.js && npm run test:node",
87
87
  "test:node": "node --test scripts/__tests__/*.test.js",
88
88
  "test": "npm run test:types && npm run test:unit && npm run test:integration",
@@ -209,12 +209,10 @@
209
209
  },
210
210
  "types": "index.d.ts",
211
211
  "optionalDependencies": {
212
- "@qvac/tts-ggml-linux-x64": "0.9.0",
213
- "@qvac/tts-ggml-linux-arm64": "0.9.0",
214
- "@qvac/tts-ggml-darwin-arm64": "0.9.0",
215
- "@qvac/tts-ggml-darwin-x64": "0.9.0",
216
- "@qvac/tts-ggml-win32-x64": "0.9.0",
217
- "@qvac/tts-ggml-android-arm64": "0.9.0",
218
- "@qvac/tts-ggml-ios": "0.9.0"
212
+ "@qvac/tts-ggml-linux-x64": "0.9.2",
213
+ "@qvac/tts-ggml-linux-arm64": "0.9.2",
214
+ "@qvac/tts-ggml-darwin-arm64": "0.9.2",
215
+ "@qvac/tts-ggml-darwin-x64": "0.9.2",
216
+ "@qvac/tts-ggml-win32-x64": "0.9.2"
219
217
  }
220
218
  }