@qvac/sdk 0.21.1 ā 0.23.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/NOTICE +131 -62
- package/README.md +31 -326
- package/dist/examples/abot-world.js +1 -1
- package/dist/examples/advisory-model-fit.d.ts +0 -58
- package/dist/examples/advisory-model-fit.js +23 -150
- package/dist/examples/asr/moss-transcribe-filesystem.d.ts +2 -0
- package/dist/examples/asr/moss-transcribe-filesystem.js +84 -0
- package/dist/examples/asr/moss-transcribe-fit.d.ts +2 -0
- package/dist/examples/asr/moss-transcribe-fit.js +40 -0
- package/dist/examples/asr/nemotron-diarization-filesystem.d.ts +2 -0
- package/dist/examples/asr/nemotron-diarization-filesystem.js +64 -0
- package/dist/examples/asr/parakeet-ctc-filesystem.js +2 -2
- package/dist/examples/asr/parakeet-indic-conformer-filesystem.js +2 -2
- package/dist/examples/asr/parakeet-microphone-record.js +1 -1
- package/dist/examples/asr/parakeet-microphone-stream.js +1 -1
- package/dist/examples/asr/parakeet-nemotron-filesystem.js +3 -3
- package/dist/examples/asr/parakeet-sortformer-streaming.js +2 -2
- package/dist/examples/asr/parakeet-sortformer.js +1 -1
- package/dist/examples/asr/parakeet-tdt-filesystem-chunked.js +2 -2
- package/dist/examples/asr/parakeet-tdt-filesystem.js +2 -2
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +76 -0
- package/dist/examples/asr/parakeet-unified-coreml.js +2 -2
- package/dist/examples/asr/parakeet-unified-filesystem.js +2 -2
- package/dist/examples/asr/whispercpp-filesystem-streaming.js +1 -1
- package/dist/examples/asr/whispercpp-filesystem.js +1 -1
- package/dist/examples/asr/whispercpp-microphone-record.js +1 -1
- package/dist/examples/asr/whispercpp-prompt.js +1 -1
- package/dist/examples/assess-model-fit.js +3 -6
- package/dist/examples/audiogen/edit-music.js +2 -2
- package/dist/examples/audiogen/generate-cover.js +2 -2
- package/dist/examples/audiogen/generate-music-minimax.js +1 -1
- package/dist/examples/audiogen/generate-music.js +1 -1
- package/dist/examples/audiogen/understand-music.js +2 -2
- package/dist/examples/batch-completion.d.ts +1 -1
- package/dist/examples/batch-completion.js +1 -1
- package/dist/examples/bci/bci-filesystem-streaming.js +2 -2
- package/dist/examples/bci/bci-filesystem.js +2 -2
- package/dist/examples/concurrent-completion-collision.js +1 -1
- package/dist/examples/config-reload.js +1 -1
- package/dist/examples/decisions.d.ts +2 -0
- package/dist/examples/decisions.js +38 -0
- package/dist/examples/diffusion-esrgan-upscale.js +1 -1
- package/dist/examples/diffusion-flux2-klein-img2img.js +1 -1
- package/dist/examples/diffusion-img2img.js +1 -1
- package/dist/examples/diffusion-img2vid-ltx.js +8 -15
- package/dist/examples/diffusion-img2vid-minimax-h3.d.ts +2 -0
- package/dist/examples/diffusion-img2vid-minimax-h3.js +72 -0
- package/dist/examples/diffusion-img2vid.js +1 -1
- package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
- package/dist/examples/diffusion-qwen-image-21.js +104 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
- package/dist/examples/finetune/llamacpp-finetune.js +9 -4
- package/dist/examples/llamacpp-filesystem.js +1 -1
- package/dist/examples/llamacpp-multi-gpu.js +2 -2
- package/dist/examples/llamacpp-multimodal.js +3 -1
- package/dist/examples/llamacpp-structured-output.js +1 -1
- package/dist/examples/mcp-websearch.d.ts +2 -2
- package/dist/examples/mcp-websearch.js +4 -4
- package/dist/examples/model-fit-ui/server.d.ts +1 -1
- package/dist/examples/model-fit-ui/server.js +1 -1
- package/dist/examples/multi-job-completion.d.ts +1 -1
- package/dist/examples/multi-job-completion.js +1 -1
- package/dist/examples/ocr-fasttext.js +1 -1
- package/dist/examples/plugins.js +1 -1
- package/dist/examples/rerank.d.ts +2 -0
- package/dist/examples/rerank.js +33 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +5 -5
- package/dist/examples/tools/llamacpp-tools-auto-dialect.js +5 -4
- package/dist/examples/tools/llamacpp-tools-gemma4.js +4 -4
- package/dist/examples/tools/llamacpp-tools-qwen35.js +5 -4
- package/dist/examples/tts/llm-to-tts-streaming.d.ts +2 -2
- package/dist/examples/tts/llm-to-tts-streaming.js +2 -2
- package/dist/examples/tts/moss-sound-effect-controls.d.ts +2 -0
- package/dist/examples/tts/moss-sound-effect-controls.js +88 -0
- package/dist/examples/tts/moss-sound-effect.d.ts +2 -0
- package/dist/examples/tts/moss-sound-effect.js +86 -0
- package/dist/examples/tts/moss-speech-audio.d.ts +2 -0
- package/dist/examples/tts/moss-speech-audio.js +159 -0
- package/dist/examples/tts/moss-speech.d.ts +2 -0
- package/dist/examples/tts/moss-speech.js +70 -0
- package/dist/examples/vla-groot.js +2 -2
- package/dist/examples/vla-pi05.js +2 -2
- package/dist/examples/vla-smolvla.js +2 -2
- package/dist/examples/voice-assistant/voice-assistant.js +1 -1
- package/dist/scripts/contract/build-contract.d.ts +3 -1
- package/dist/scripts/contract/build-contract.js +40 -2
- package/dist/scripts/contract/build-model-type-maps.d.ts +6 -1
- package/dist/scripts/contract/build-model-type-maps.js +3 -2
- package/dist/scripts/contract/constants-registry.d.ts +6 -0
- package/dist/scripts/contract/constants-registry.js +4 -1
- package/dist/scripts/contract/method-shapes.d.ts +2 -0
- package/dist/scripts/contract/method-shapes.js +2 -0
- package/dist/scripts/export-contract.js +20 -7
- package/dist/scripts/run-unit-tests.js +10 -5
- package/dist/src/client/api/assess-model-fit.d.ts +5 -5
- package/dist/src/client/api/assess-model-fit.js +6 -7
- package/dist/src/client/api/audio-edit.d.ts +14 -2
- package/dist/src/client/api/audio-edit.js +16 -4
- package/dist/src/client/api/audio-gen-result.js +2 -2
- package/dist/src/client/api/audio-gen.d.ts +10 -2
- package/dist/src/client/api/audio-gen.js +12 -4
- package/dist/src/client/api/audio-understand.d.ts +1 -1
- package/dist/src/client/api/audio-understand.js +3 -3
- package/dist/src/client/api/batch-completion.js +3 -3
- package/dist/src/client/api/bci-transcribe.js +3 -3
- package/dist/src/client/api/cancel.js +1 -1
- package/dist/src/client/api/classify.js +1 -1
- package/dist/src/client/api/completion-stream.d.ts +2 -1
- package/dist/src/client/api/completion-stream.js +6 -4
- package/dist/src/client/api/decide.d.ts +31 -0
- package/dist/src/client/api/decide.js +29 -0
- package/dist/src/client/api/delete-cache.js +1 -1
- package/dist/src/client/api/diffusion.d.ts +18 -1
- package/dist/src/client/api/diffusion.js +19 -2
- package/dist/src/client/api/download-asset.js +3 -3
- package/dist/src/client/api/embed.js +2 -2
- package/dist/src/client/api/finetune.js +3 -3
- package/dist/src/client/api/get-loaded-model-info.js +1 -1
- package/dist/src/client/api/get-model-info.js +1 -1
- package/dist/src/client/api/get-system-resources.js +1 -1
- package/dist/src/client/api/heartbeat.js +1 -1
- package/dist/src/client/api/index.d.ts +5 -3
- package/dist/src/client/api/index.js +5 -3
- package/dist/src/client/api/invoke-plugin.js +1 -1
- package/dist/src/client/api/load-model.d.ts +1 -0
- package/dist/src/client/api/load-model.js +4 -4
- package/dist/src/client/api/logging-stream.d.ts +11 -2
- package/dist/src/client/api/logging-stream.js +12 -3
- package/dist/src/client/api/ocr.js +1 -1
- package/dist/src/client/api/rag.js +2 -2
- package/dist/src/client/api/registry.d.ts +2 -1
- package/dist/src/client/api/registry.js +6 -5
- package/dist/src/client/api/rerank.d.ts +22 -0
- package/dist/src/client/api/rerank.js +39 -0
- package/dist/src/client/api/resume.js +1 -1
- package/dist/src/client/api/rpc-server.js +2 -2
- package/dist/src/client/api/state.js +1 -1
- package/dist/src/client/api/subscribe-logs.js +3 -2
- package/dist/src/client/api/suspend.js +1 -1
- package/dist/src/client/api/text-to-speech.d.ts +1 -0
- package/dist/src/client/api/text-to-speech.js +18 -25
- package/dist/src/client/api/transcribe.d.ts +1 -1
- package/dist/src/client/api/transcribe.js +7 -4
- package/dist/src/client/api/translate.js +2 -2
- package/dist/src/client/api/unload-model.js +2 -2
- package/dist/src/client/api/upscale.js +1 -1
- package/dist/src/client/api/vector-index.d.ts +1 -1
- package/dist/src/client/api/vector-index.js +1 -1
- package/dist/src/client/api/video-request.d.ts +5 -5
- package/dist/src/client/api/video.d.ts +23 -3
- package/dist/src/client/api/video.js +26 -6
- package/dist/src/client/api/world-result.js +2 -2
- package/dist/src/client/api/world.d.ts +1 -1
- package/dist/src/client/api/world.js +2 -2
- package/dist/src/client/logging-stream-registry.js +9 -6
- package/dist/src/client/plugins-factory.d.ts +1 -1
- package/dist/src/client/plugins-factory.js +1 -1
- package/dist/src/client/rpc/expo-rpc-client.js +3 -3
- package/dist/src/client/rpc/ipc-socket-path.d.ts +11 -0
- package/dist/src/client/rpc/ipc-socket-path.js +30 -0
- package/dist/src/client/rpc/node-rpc-client.js +14 -25
- package/dist/src/client/rpc/rpc-client.d.ts +3 -2
- package/dist/src/client/rpc/rpc-client.js +46 -12
- package/dist/src/client/rpc/rpc-error.js +4 -1
- package/dist/src/commands/bundle/bare-pack.d.ts +8 -0
- package/dist/src/commands/bundle/bare-pack.js +28 -5
- package/dist/src/commands/bundle/constants.js +3 -0
- package/dist/src/commands/bundle/entry-gen.js +1 -1
- package/dist/src/commands/bundle/index.d.ts +8 -7
- package/dist/src/commands/bundle/index.js +135 -52
- package/dist/src/commands/bundle/manifest.d.ts +2 -0
- package/dist/src/commands/bundle/manifest.js +3 -2
- package/dist/src/commands/bundle/plugins.js +1 -1
- package/dist/src/commands/host-prebuilds/index.d.ts +18 -10
- package/dist/src/commands/host-prebuilds/index.js +39 -20
- package/dist/src/commands/index.d.ts +13 -13
- package/dist/src/commands/index.js +8 -8
- package/dist/src/commands/verify/abi.d.ts +1 -1
- package/dist/src/commands/verify/abi.js +1 -1
- package/dist/src/commands/verify/addon-source.d.ts +12 -0
- package/dist/src/commands/verify/addon-source.js +36 -3
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +1 -1
- package/dist/src/commands/verify/bare-kit-runtime.js +1 -1
- package/dist/src/commands/verify/bare-kit-runtimes.js +2 -1
- package/dist/src/commands/verify/bundle-source.d.ts +1 -1
- package/dist/src/commands/verify/bundle-source.js +3 -3
- package/dist/src/commands/verify/engines-advice.d.ts +4 -4
- package/dist/src/commands/verify/engines-advice.js +4 -4
- package/dist/src/commands/verify/index.d.ts +5 -5
- package/dist/src/commands/verify/index.js +7 -7
- package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/src/commands/verify/node-modules-source.js +11 -2
- package/dist/src/{expo/plugins/patches/qvac-platform-addons.d.ts ā commands/verify/platform-addons.d.ts} +6 -10
- package/dist/src/{expo/plugins/patches/qvac-platform-addons.js ā commands/verify/platform-addons.js} +2 -45
- package/dist/src/commands/verify/prebuilds.d.ts +8 -11
- package/dist/src/commands/verify/prebuilds.js +44 -35
- package/dist/src/commands/verify/resource-collectors.js +2 -2
- package/dist/src/expo/plugins/link-addons.d.ts +18 -0
- package/dist/src/expo/plugins/link-addons.js +65 -0
- package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
- package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
- package/dist/src/expo/plugins/withMobileBundle.d.ts +13 -23
- package/dist/src/expo/plugins/withMobileBundle.js +27 -117
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +3 -3
- package/dist/src/logging/addon.d.ts +1 -1
- package/dist/src/pear/pre.js +4 -0
- package/dist/src/plugin-ids.d.ts +4 -1
- package/dist/src/plugin-ids.js +6 -0
- package/dist/src/schemas/public.d.ts +2 -1
- package/dist/src/schemas/public.js +2 -1
- package/dist/src/schemas/sdk-errors-client.d.ts +3 -0
- package/dist/src/schemas/sdk-errors-client.js +16 -0
- package/dist/src/schemas/sdk-errors-server.d.ts +2 -0
- package/dist/src/schemas/sdk-errors-server.js +11 -1
- package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
- package/dist/src/server/rpc/rpc-utils.js +7 -0
- package/dist/src/server/utils/qvac-paths.js +1 -1
- package/dist/src/server/utils/worker-lock.js +1 -1
- package/dist/src/utils/aggregate-events.d.ts +1 -1
- package/dist/src/utils/aggregate-events.js +2 -2
- package/dist/src/utils/errors-client.d.ts +10 -0
- package/dist/src/utils/errors-client.js +18 -0
- package/dist/src/utils/errors-server.d.ts +6 -0
- package/dist/src/utils/errors-server.js +12 -0
- package/dist/src/utils/mcp-adapter.d.ts +1 -1
- package/dist/src/utils/mcp-adapter.js +13 -9
- package/dist/src/utils/tool-helpers.d.ts +1 -1
- package/dist/src/utils/tool-helpers.js +21 -53
- package/dist/src/worker/create-server.d.ts +1 -0
- package/dist/src/worker/create-server.js +5 -0
- package/dist/src/worker/handle-request.js +4 -2
- package/dist/src/worker/handler-utils.js +1 -1
- package/dist/src/worker/index.js +7 -1
- package/dist/src/worker/lifecycle.js +10 -2
- package/dist/src/worker/plugins/llamacpp-decision.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-decision.js +1 -0
- package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
- package/dist/src/worker/plugins/moss-transcribe.d.ts +2 -0
- package/dist/src/worker/plugins/moss-transcribe.js +1 -0
- package/package.json +63 -53
- package/src/electron-forge/index.cjs +12 -71
- package/dist/scripts/link-workspace-inference.d.ts +0 -2
- package/dist/scripts/link-workspace-inference.js +0 -31
- package/src/expo/plugins/patches/android-link.mjs +0 -67
- package/src/expo/plugins/patches/ios-link.mjs +0 -67
- package/src/expo/plugins/patches/qvac-platform-addons.ts +0 -124
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { requestSchema, responseSchema, PROFILING_TRAILER_KEY, nowMs, shouldProfile, shouldIncludeServerBreakdown, shouldIncludeResourceGauges, generateId as createProfileId, createProfilingMeta, createProfilingDisabledMeta, injectProfilingMetaIntoObject, extractProfilingMeta, stripProfilingMeta, recordFailure } from '@qvac/inference/surface';
|
|
1
|
+
import { requestSchema, responseSchema, PROFILING_TRAILER_KEY, nowMs, shouldProfile, shouldIncludeServerBreakdown, shouldIncludeResourceGauges, generateId as createProfileId, createProfilingMeta, createProfilingDisabledMeta, injectProfilingMetaIntoObject, extractProfilingMeta, stripProfilingMeta, recordFailure, untilAborted } from '@qvac/inference/surface';
|
|
2
2
|
import { reconstructError } from './rpc-error.js';
|
|
3
3
|
import { withTimeout, withTimeoutStream, OperationTimeoutError } from '../../utils/withTimeout.js';
|
|
4
4
|
import { getClientLogger, summarizeRequest } from '../../logging/index.js';
|
|
@@ -157,6 +157,20 @@ async function* iterateWithLifeSignal(source) {
|
|
|
157
157
|
void source.return?.(undefined).catch(() => { });
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
// Destroying the response stream makes the worker abort the engine stream.
|
|
161
|
+
// Registered before `untilAborted`, so the destroyed stream's late rejection is
|
|
162
|
+
// dropped there instead of reaching `iterateWithLifeSignal` as a worker crash.
|
|
163
|
+
function destroyOnAbort(responseStream, signal) {
|
|
164
|
+
if (!signal)
|
|
165
|
+
return () => { };
|
|
166
|
+
const onAbort = () => responseStream.destroy();
|
|
167
|
+
if (signal.aborted) {
|
|
168
|
+
onAbort();
|
|
169
|
+
return () => { };
|
|
170
|
+
}
|
|
171
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
172
|
+
return () => signal.removeEventListener('abort', onAbort);
|
|
173
|
+
}
|
|
160
174
|
function checkAndThrowError(response) {
|
|
161
175
|
if (response.type === 'error') {
|
|
162
176
|
// Use the typed-error reconstructor map in `rpc-error.ts` so the
|
|
@@ -277,8 +291,13 @@ async function sendProfiled(request, rpc, options) {
|
|
|
277
291
|
throw error;
|
|
278
292
|
}
|
|
279
293
|
}
|
|
294
|
+
/** `options.signal` ends the stream; only `endsOnAbort` handlers stop on the worker. */
|
|
280
295
|
export async function* stream(request, options = {}, rpc) {
|
|
296
|
+
if (options.signal?.aborted)
|
|
297
|
+
return;
|
|
281
298
|
const ctx = await prepareRPCContext(request.type, options?.profiling, rpc);
|
|
299
|
+
if (options.signal?.aborted)
|
|
300
|
+
return;
|
|
282
301
|
if (!ctx.profilingEnabled) {
|
|
283
302
|
yield* streamBase(request, ctx.rpc, options, ctx.signalDisable);
|
|
284
303
|
return;
|
|
@@ -294,6 +313,7 @@ async function* streamBase(request, rpc, options = {}, signalDisable = false) {
|
|
|
294
313
|
: parsedRequest;
|
|
295
314
|
req.send(JSON.stringify(payloadObj), 'utf-8');
|
|
296
315
|
const responseStream = req.createResponseStream({ encoding: 'utf-8' });
|
|
316
|
+
const stopDestroyOnAbort = destroyOnAbort(responseStream, options.signal);
|
|
297
317
|
let buffer = '';
|
|
298
318
|
async function* processStream() {
|
|
299
319
|
for await (const chunk of responseStream) {
|
|
@@ -301,19 +321,27 @@ async function* streamBase(request, rpc, options = {}, signalDisable = false) {
|
|
|
301
321
|
}
|
|
302
322
|
}
|
|
303
323
|
const streamWithTimeout = withTimeoutStream(processStream(), options?.timeout);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
324
|
+
try {
|
|
325
|
+
for await (const chunk of iterateWithLifeSignal(untilAborted(streamWithTimeout, options.signal))) {
|
|
326
|
+
buffer += chunk.toString();
|
|
327
|
+
// Process complete lines (newline-delimited JSON)
|
|
328
|
+
const lines = buffer.split('\n');
|
|
329
|
+
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
330
|
+
for (const line of lines) {
|
|
331
|
+
// Aborted mid-chunk.
|
|
332
|
+
if (options.signal?.aborted)
|
|
333
|
+
return;
|
|
334
|
+
if (line.trim()) {
|
|
335
|
+
const response = responseSchema.parse(JSON.parse(line));
|
|
336
|
+
checkAndThrowError(response);
|
|
337
|
+
yield response;
|
|
338
|
+
}
|
|
314
339
|
}
|
|
315
340
|
}
|
|
316
341
|
}
|
|
342
|
+
finally {
|
|
343
|
+
stopDestroyOnAbort();
|
|
344
|
+
}
|
|
317
345
|
}
|
|
318
346
|
async function* streamProfiled(request, rpc, options = {}) {
|
|
319
347
|
const requestType = request.type;
|
|
@@ -322,6 +350,7 @@ async function* streamProfiled(request, rpc, options = {}) {
|
|
|
322
350
|
const includeResources = shouldIncludeResourceGauges(options?.profiling);
|
|
323
351
|
const timings = createClientStreamTimings(profileId, requestType);
|
|
324
352
|
let profilingMeta = undefined;
|
|
353
|
+
let stopDestroyOnAbort = () => { };
|
|
325
354
|
try {
|
|
326
355
|
const zodStart = nowMs();
|
|
327
356
|
const parsedRequest = parseRequest(request);
|
|
@@ -336,6 +365,7 @@ async function* streamProfiled(request, rpc, options = {}) {
|
|
|
336
365
|
timings.sendStart = nowMs();
|
|
337
366
|
req.send(payload, 'utf-8');
|
|
338
367
|
const responseStream = req.createResponseStream({ encoding: 'utf-8' });
|
|
368
|
+
stopDestroyOnAbort = destroyOnAbort(responseStream, options.signal);
|
|
339
369
|
let buffer = '';
|
|
340
370
|
async function* processStream() {
|
|
341
371
|
for await (const chunk of responseStream) {
|
|
@@ -343,7 +373,7 @@ async function* streamProfiled(request, rpc, options = {}) {
|
|
|
343
373
|
}
|
|
344
374
|
}
|
|
345
375
|
const streamWithTimeout = withTimeoutStream(processStream(), options?.timeout);
|
|
346
|
-
for await (const chunk of iterateWithLifeSignal(streamWithTimeout)) {
|
|
376
|
+
for await (const chunk of iterateWithLifeSignal(untilAborted(streamWithTimeout, options.signal))) {
|
|
347
377
|
const chunkTime = nowMs();
|
|
348
378
|
if (timings.firstChunkAt === undefined) {
|
|
349
379
|
timings.firstChunkAt = chunkTime;
|
|
@@ -353,6 +383,9 @@ async function* streamProfiled(request, rpc, options = {}) {
|
|
|
353
383
|
const lines = buffer.split('\n');
|
|
354
384
|
buffer = lines.pop() || '';
|
|
355
385
|
for (const line of lines) {
|
|
386
|
+
// Aborted mid-chunk.
|
|
387
|
+
if (options.signal?.aborted)
|
|
388
|
+
return;
|
|
356
389
|
if (line.trim()) {
|
|
357
390
|
const rawParsed = JSON.parse(line);
|
|
358
391
|
const chunkMeta = extractProfilingMeta(rawParsed);
|
|
@@ -383,6 +416,7 @@ async function* streamProfiled(request, rpc, options = {}) {
|
|
|
383
416
|
throw error;
|
|
384
417
|
}
|
|
385
418
|
finally {
|
|
419
|
+
stopDestroyOnAbort();
|
|
386
420
|
if (timings.chunkCount > 0) {
|
|
387
421
|
timings.requestEnd = nowMs();
|
|
388
422
|
recordClientStreamEvents(timings, profilingMeta);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RpcServerOperationError, InferenceCancelledError, ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, TranslationFailedError } from '../../utils/errors-server.js';
|
|
1
|
+
import { RpcServerOperationError, InferenceCancelledError, ContextOverflowError, ModelRegistryModelNotFoundError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, TranslationFailedError } from '../../utils/errors-server.js';
|
|
2
2
|
export class RPCError extends Error {
|
|
3
3
|
timestamp;
|
|
4
4
|
remoteStack;
|
|
@@ -108,6 +108,9 @@ const RECONSTRUCTORS = {
|
|
|
108
108
|
REQUEST_ID_CONFLICT: (response) => {
|
|
109
109
|
return new RequestIdConflictError(readStringField(response.typedFields, 'requestId', ''), response.cause);
|
|
110
110
|
},
|
|
111
|
+
QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND: (response) => {
|
|
112
|
+
return new ModelRegistryModelNotFoundError(readStringField(response.typedFields, 'registrySource', ''), readStringField(response.typedFields, 'registryPath', ''), response.cause);
|
|
113
|
+
},
|
|
111
114
|
REQUEST_NOT_FOUND: (response) => {
|
|
112
115
|
return new RequestNotFoundError(readStringField(response.typedFields, 'requestId', ''), response.cause);
|
|
113
116
|
},
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '../../logging/types.js';
|
|
2
|
+
export declare const BARE_PACK_NODE_ENGINES = "^22.21.0 || >=24.9.0";
|
|
3
|
+
export declare function isBarePackNodeSupported(version: string): boolean;
|
|
4
|
+
interface NodeVersions {
|
|
5
|
+
node: string;
|
|
6
|
+
bun?: string | undefined;
|
|
7
|
+
}
|
|
2
8
|
interface RunBarePackOptions {
|
|
3
9
|
entryPath: string;
|
|
4
10
|
outputPath: string;
|
|
@@ -7,6 +13,8 @@ interface RunBarePackOptions {
|
|
|
7
13
|
deferModules: string[];
|
|
8
14
|
quiet: boolean;
|
|
9
15
|
logger: Logger;
|
|
16
|
+
/** The runtime running bare-pack; defaults to this process. Tests inject an older Node. */
|
|
17
|
+
nodeVersions?: NodeVersions | undefined;
|
|
10
18
|
}
|
|
11
19
|
export declare function runBarePack(options: RunBarePackOptions): Promise<void>;
|
|
12
20
|
export {};
|
|
@@ -2,9 +2,29 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import { platform, execPath } from 'node:process';
|
|
6
|
-
import
|
|
5
|
+
import { platform, execPath, versions } from 'node:process';
|
|
6
|
+
import semver from 'semver';
|
|
7
|
+
import { BarePackNotInstalledError, BarePackNodeUnsupportedError, BarePackError } from '../../utils/errors-client.js';
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
9
|
+
// bare-module-lexer (loaded by bare-pack through bare-module-traverse) calls
|
|
10
|
+
// js_is_sharedarraybuffer from its native addon, which Node outside this range
|
|
11
|
+
// lacks; the bare-pack child process crashes instead of throwing. Same range as
|
|
12
|
+
// engines.node in @qvac/cli.
|
|
13
|
+
export const BARE_PACK_NODE_ENGINES = '^22.21.0 || >=24.9.0';
|
|
14
|
+
export function isBarePackNodeSupported(version) {
|
|
15
|
+
return semver.satisfies(version, BARE_PACK_NODE_ENGINES, { includePrerelease: true });
|
|
16
|
+
}
|
|
17
|
+
// On Node, bare-pack is spawned with this process's execPath, so checking
|
|
18
|
+
// process.versions.node checks the Node that will load the lexer. Under Bun,
|
|
19
|
+
// process.versions.node is Bun's emulated value and, except on Windows, bare-pack
|
|
20
|
+
// runs through its shebang in the `node` from PATH, which cannot be checked here.
|
|
21
|
+
function assertNodeCanRunBarePack(nodeVersions) {
|
|
22
|
+
if (nodeVersions.bun !== undefined)
|
|
23
|
+
return;
|
|
24
|
+
if (isBarePackNodeSupported(nodeVersions.node))
|
|
25
|
+
return;
|
|
26
|
+
throw new BarePackNodeUnsupportedError(nodeVersions.node, BARE_PACK_NODE_ENGINES);
|
|
27
|
+
}
|
|
8
28
|
function resolveBarePackBin() {
|
|
9
29
|
try {
|
|
10
30
|
const barePackPkgPath = require.resolve('bare-pack/package');
|
|
@@ -17,10 +37,12 @@ function resolveBarePackBin() {
|
|
|
17
37
|
}
|
|
18
38
|
export async function runBarePack(options) {
|
|
19
39
|
const { entryPath, outputPath, hosts, importsMapPath, deferModules, quiet, logger } = options;
|
|
40
|
+
const nodeVersions = options.nodeVersions ?? versions;
|
|
20
41
|
const barePackBin = resolveBarePackBin();
|
|
21
42
|
if (!barePackBin || !fs.existsSync(barePackBin)) {
|
|
22
43
|
throw new BarePackNotInstalledError();
|
|
23
44
|
}
|
|
45
|
+
assertNodeCanRunBarePack(nodeVersions);
|
|
24
46
|
return new Promise((resolve, reject) => {
|
|
25
47
|
const hostArgs = hosts.flatMap((h) => ['--host', h]);
|
|
26
48
|
const deferArgs = deferModules.flatMap((m) => ['--defer', m]);
|
|
@@ -34,9 +56,10 @@ export async function runBarePack(options) {
|
|
|
34
56
|
outputPath,
|
|
35
57
|
entryPath
|
|
36
58
|
];
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
59
|
+
// Windows cannot exec a .js file directly, so it always goes through execPath.
|
|
60
|
+
const viaShebang = nodeVersions.bun !== undefined && platform !== 'win32';
|
|
61
|
+
const command = viaShebang ? barePackBin : execPath;
|
|
62
|
+
const spawnArgs = viaShebang ? args : [barePackBin, ...args];
|
|
40
63
|
logger.debug(`\nš¦ Running: ${command} ${spawnArgs.join(' ')}`);
|
|
41
64
|
const proc = spawn(command, spawnArgs, {
|
|
42
65
|
stdio: quiet ? 'ignore' : 'inherit'
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export const BUILTIN_PLUGINS = {
|
|
2
2
|
'llamacpp-completion': { exportName: 'llmPlugin' },
|
|
3
3
|
'llamacpp-embedding': { exportName: 'embeddingsPlugin' },
|
|
4
|
+
'llamacpp-decision': { exportName: 'decisionPlugin' },
|
|
5
|
+
'llamacpp-rerank': { exportName: 'rerankPlugin' },
|
|
4
6
|
'whispercpp-transcription': { exportName: 'whisperPlugin' },
|
|
5
7
|
'bci-whispercpp-transcription': { exportName: 'bciPlugin' },
|
|
6
8
|
'parakeet-transcription': { exportName: 'parakeetPlugin' },
|
|
9
|
+
'moss-transcribe': { exportName: 'mossTranscribePlugin' },
|
|
7
10
|
'nmtcpp-translation': { exportName: 'nmtPlugin' },
|
|
8
11
|
'tts-ggml': { exportName: 'ttsPlugin' },
|
|
9
12
|
'ggml-ocr': { exportName: 'ocrPlugin' },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseBuiltinSpecifier } from '
|
|
1
|
+
import { parseBuiltinSpecifier } from '../../commands/bundle/plugins.js';
|
|
2
2
|
export function generateWorkerEntry(pluginSpecifiers, sdkName, resolveImport = (specifier) => specifier, rpcServerProvider) {
|
|
3
3
|
const imports = [];
|
|
4
4
|
const registrations = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HostPrebuildPackage } from '
|
|
1
|
+
import { type HostPrebuildPackage } from '../../commands/host-prebuilds/index.js';
|
|
2
2
|
export interface BundleSdkOptions {
|
|
3
3
|
projectRoot?: string | undefined;
|
|
4
4
|
configPath?: string | undefined;
|
|
@@ -8,12 +8,13 @@ export interface BundleSdkOptions {
|
|
|
8
8
|
quiet?: boolean | undefined;
|
|
9
9
|
verbose?: boolean | undefined;
|
|
10
10
|
/**
|
|
11
|
-
* Install the addon platform packages the
|
|
12
|
-
* with the project's package manager
|
|
13
|
-
*
|
|
14
|
-
* package.json or node_modules
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Install the addon platform packages that the split addons the bundle
|
|
12
|
+
* reaches need for its mobile hosts, with the project's package manager
|
|
13
|
+
* (see `ensureHostPrebuilds`), before bundling. Off by default: without it,
|
|
14
|
+
* bundling never changes package.json or node_modules, and a mobile host
|
|
15
|
+
* whose platform package is missing fails with `HostPrebuildsMissingError`,
|
|
16
|
+
* naming the exact pins. A refused install
|
|
17
|
+
* throws `HostPrebuildsInstallRefusedError` before anything is written.
|
|
17
18
|
*/
|
|
18
19
|
installMissingPrebuilds?: boolean | undefined;
|
|
19
20
|
/**
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import fs, { promises as fsp } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
|
-
import { DEFAULT_HOSTS, DEFAULT_SDK_NAME } from '
|
|
4
|
+
import { DEFAULT_HOSTS, DEFAULT_SDK_NAME } from '../../commands/bundle/constants.js';
|
|
5
5
|
import { CONFIG_CANDIDATES, resolveConfigForProject } from '../../client/config-loader/resolve-config.node.js';
|
|
6
|
-
import { createCommandLogger } from '
|
|
7
|
-
import { BareImportsMapNotFoundError,
|
|
8
|
-
import { resolvePluginSpecifiers, parseBuiltinSpecifier } from '
|
|
9
|
-
import { generateWorkerEntries } from '
|
|
10
|
-
import { runBarePack } from '
|
|
11
|
-
import { generateAddonsManifest } from '
|
|
12
|
-
import { createSdkImportResolver } from '
|
|
13
|
-
import { installMissingHostPrebuilds } from '
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { formatEnginesAdvice } from '../verify/engines-advice.js';
|
|
6
|
+
import { createCommandLogger } from '../../commands/command-logger.js';
|
|
7
|
+
import { BareImportsMapNotFoundError, HostPrebuildsMissingError } from '../../utils/errors-client.js';
|
|
8
|
+
import { resolvePluginSpecifiers, parseBuiltinSpecifier } from '../../commands/bundle/plugins.js';
|
|
9
|
+
import { generateWorkerEntries } from '../../commands/bundle/entry-gen.js';
|
|
10
|
+
import { runBarePack } from '../../commands/bundle/bare-pack.js';
|
|
11
|
+
import { AUDIO_DECODER_ADDON, extractBarePackHeader, extractPackedString, generateAddonsManifest } from '../../commands/bundle/manifest.js';
|
|
12
|
+
import { createSdkImportResolver } from '../../commands/bundle/resolve-sdk-import.js';
|
|
13
|
+
import { findMissingHostPrebuilds, installMissingHostPrebuilds, resolveAddons } from '../../commands/host-prebuilds/index.js';
|
|
14
|
+
import { verifyBundle } from '../../commands/verify/index.js';
|
|
15
|
+
import { formatRuntimeSource } from '../../commands/verify/abi.js';
|
|
16
|
+
import { formatEnginesAdvice } from '../../commands/verify/engines-advice.js';
|
|
18
17
|
const require = createRequire(import.meta.url);
|
|
19
18
|
function resolveSdkPath(projectRoot, explicitSdkPath) {
|
|
20
19
|
if (explicitSdkPath) {
|
|
@@ -55,6 +54,19 @@ function resolveImportsMapPath(sdkPath, sdkName) {
|
|
|
55
54
|
throw new BareImportsMapNotFoundError(sdkName, importsMapPath);
|
|
56
55
|
}
|
|
57
56
|
const ENGINES_ISSUE_CODES = new Set(['abi-mismatch', 'engines-mismatch']);
|
|
57
|
+
const AUDIO_PLUGINS = new Set([
|
|
58
|
+
'whispercpp-transcription',
|
|
59
|
+
'bci-whispercpp-transcription',
|
|
60
|
+
'parakeet-transcription',
|
|
61
|
+
'moss-transcribe',
|
|
62
|
+
'audiogen-ggml'
|
|
63
|
+
]);
|
|
64
|
+
function audioPluginsIn(pluginSpecifiers, sdkName) {
|
|
65
|
+
return pluginSpecifiers.filter((specifier) => {
|
|
66
|
+
const builtin = parseBuiltinSpecifier(specifier, sdkName);
|
|
67
|
+
return builtin !== null && AUDIO_PLUGINS.has(builtin.suffix);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
58
70
|
async function checkBundleEngines(options) {
|
|
59
71
|
const { projectRoot, bundlePath, hosts, configPath, network, logger } = options;
|
|
60
72
|
logger.info('\nš Checking engines.bare against the Bare runtime of each host...');
|
|
@@ -124,7 +136,17 @@ export async function bundleSdk(options = {}) {
|
|
|
124
136
|
logger.info(` ${label}: ${spec}`);
|
|
125
137
|
}
|
|
126
138
|
const hosts = options.hosts && options.hosts.length > 0 ? options.hosts : DEFAULT_HOSTS;
|
|
127
|
-
const
|
|
139
|
+
const explicitDefer = options.defer ?? [];
|
|
140
|
+
const includeAudioDecoder = config.includeAudioDecoder !== false && !explicitDefer.includes(AUDIO_DECODER_ADDON);
|
|
141
|
+
const deferModules = includeAudioDecoder
|
|
142
|
+
? explicitDefer
|
|
143
|
+
: [...new Set([...explicitDefer, AUDIO_DECODER_ADDON])];
|
|
144
|
+
if (!includeAudioDecoder) {
|
|
145
|
+
const affected = audioPluginsIn(pluginSpecifiers, sdkName);
|
|
146
|
+
if (affected.length > 0) {
|
|
147
|
+
logger.warn(`${AUDIO_DECODER_ADDON} is not bundled: ${affected.join(', ')} cannot decode compressed audio files; compressed audiogen output formats also require FFmpeg.`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
128
150
|
await fsp.mkdir(outputDir, { recursive: true });
|
|
129
151
|
logger.info('\nš Generating worker entry...');
|
|
130
152
|
const resolveSdkImport = createSdkImportResolver(sdkPath, sdkName);
|
|
@@ -137,46 +159,44 @@ export async function bundleSdk(options = {}) {
|
|
|
137
159
|
if (deferModules.length > 0) {
|
|
138
160
|
logger.debug(` Deferred: ${deferModules.join(', ')}`);
|
|
139
161
|
}
|
|
162
|
+
// Missing mobile platform packages are installed, or reported, before bundling.
|
|
140
163
|
let installedPrebuilds = [];
|
|
141
|
-
|
|
164
|
+
const barePackOptions = {
|
|
165
|
+
entryPath: bundleEntryPath,
|
|
166
|
+
hosts,
|
|
167
|
+
importsMapPath,
|
|
168
|
+
quiet: options.quiet === true,
|
|
169
|
+
logger
|
|
170
|
+
};
|
|
171
|
+
const addonsMissingPlatformPackages = () => reachedAddonsMissingPlatformPackages({
|
|
172
|
+
addons: async () => (await resolveAddons(projectRoot, undefined, logger)).filter((addon) => !deferModules.includes(addon.name)),
|
|
173
|
+
hosts,
|
|
174
|
+
scan: (extraDefer, outputPath) => runBarePack({
|
|
175
|
+
...barePackOptions,
|
|
176
|
+
outputPath,
|
|
177
|
+
deferModules: [...deferModules, ...extraDefer],
|
|
178
|
+
quiet: true
|
|
179
|
+
}),
|
|
180
|
+
scanPath: path.join(outputDir, 'worker.scan.bundle.js'),
|
|
181
|
+
logger
|
|
182
|
+
});
|
|
142
183
|
try {
|
|
143
184
|
await fsp.writeFile(bundleEntryPath, bundleEntry, 'utf8');
|
|
144
|
-
const
|
|
145
|
-
entryPath: bundleEntryPath,
|
|
146
|
-
outputPath: bundlePath,
|
|
147
|
-
hosts,
|
|
148
|
-
importsMapPath,
|
|
149
|
-
deferModules,
|
|
150
|
-
quiet: options.quiet === true,
|
|
151
|
-
logger
|
|
152
|
-
};
|
|
153
|
-
await runBarePack(barePackOptions);
|
|
185
|
+
const addons = await addonsMissingPlatformPackages();
|
|
154
186
|
if (options.installMissingPrebuilds === true) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
installedPrebuilds = installed;
|
|
164
|
-
// Where a platform package was missing, bare-pack resolved the addon's
|
|
165
|
-
// `#host-addon` import to its fallback module; bundle again to pick up
|
|
166
|
-
// the installed package.
|
|
167
|
-
if (installed.length > 0) {
|
|
168
|
-
logger.info('\nšØ Bundling again with the installed platform packages...');
|
|
169
|
-
await runBarePack(barePackOptions);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
if (!(error instanceof HostPrebuildsInstallRefusedError))
|
|
174
|
-
throw error;
|
|
175
|
-
// A refusal happens before anything is installed, so the bundle
|
|
176
|
-
// already written is final and only its manifest is left to write.
|
|
177
|
-
installRefused = error;
|
|
178
|
-
}
|
|
187
|
+
const { installed } = await installMissingHostPrebuilds({
|
|
188
|
+
projectRoot,
|
|
189
|
+
hosts,
|
|
190
|
+
addons,
|
|
191
|
+
quiet: options.quiet === true,
|
|
192
|
+
logger
|
|
193
|
+
});
|
|
194
|
+
installedPrebuilds = installed;
|
|
179
195
|
}
|
|
196
|
+
else {
|
|
197
|
+
await throwIfPlatformPackagesMissing(addons, hosts);
|
|
198
|
+
}
|
|
199
|
+
await runBarePack({ ...barePackOptions, outputPath: bundlePath, deferModules });
|
|
180
200
|
}
|
|
181
201
|
finally {
|
|
182
202
|
await fsp.rm(bundleEntryPath, { force: true });
|
|
@@ -189,7 +209,8 @@ export async function bundleSdk(options = {}) {
|
|
|
189
209
|
bundlePath,
|
|
190
210
|
outputDir,
|
|
191
211
|
projectRoot,
|
|
192
|
-
logger
|
|
212
|
+
logger,
|
|
213
|
+
includeAudioDecoder
|
|
193
214
|
});
|
|
194
215
|
if (options.checkEngines !== false) {
|
|
195
216
|
await checkBundleEngines({
|
|
@@ -201,8 +222,6 @@ export async function bundleSdk(options = {}) {
|
|
|
201
222
|
logger
|
|
202
223
|
});
|
|
203
224
|
}
|
|
204
|
-
if (installRefused !== undefined)
|
|
205
|
-
throw installRefused;
|
|
206
225
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
207
226
|
logger.info(`\nš Done in ${elapsed}s!\n`);
|
|
208
227
|
logger.info('Generated files:');
|
|
@@ -222,3 +241,67 @@ export async function bundleSdk(options = {}) {
|
|
|
222
241
|
installedPrebuilds
|
|
223
242
|
};
|
|
224
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* The installed split addons that the bundle reaches and that are missing a
|
|
246
|
+
* mobile platform package. Every installed addon is a candidate (`@qvac/sdk`
|
|
247
|
+
* depends on all of them), so a first bare-pack pass defers each missing
|
|
248
|
+
* platform package: bare-pack then records the reached ones as
|
|
249
|
+
* `deferred:<package>` and never visits the rest. Empty when nothing is
|
|
250
|
+
* missing, or when that pass fails, which leaves the real bundle to report
|
|
251
|
+
* the failure.
|
|
252
|
+
*/
|
|
253
|
+
async function reachedAddonsMissingPlatformPackages(options) {
|
|
254
|
+
const { hosts, scan, scanPath, logger } = options;
|
|
255
|
+
const addons = await options.addons();
|
|
256
|
+
const missing = await findMissingHostPrebuilds(addons, hosts);
|
|
257
|
+
if (missing.length === 0)
|
|
258
|
+
return [];
|
|
259
|
+
logger.debug(`\nš Checking which of ${missing.length} missing platform packages the bundle reaches...`);
|
|
260
|
+
try {
|
|
261
|
+
await scan(missing.map((pkg) => pkg.name), scanPath);
|
|
262
|
+
const reached = deferredSpecifiers(await fsp.readFile(scanPath, 'utf8'));
|
|
263
|
+
const owners = new Set(missing.filter((pkg) => reached.has(pkg.name)).map((pkg) => pkg.addon));
|
|
264
|
+
return addons.filter((addon) => owners.has(addon.name));
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
logger.debug(` Scan failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
await fsp.rm(scanPath, { force: true });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const DEFERRED_PROTOCOL = 'deferred:';
|
|
275
|
+
/** Every specifier a bare-pack bundle leaves as `deferred:<specifier>`. */
|
|
276
|
+
function deferredSpecifiers(bundleText) {
|
|
277
|
+
const { resolutions = {} } = extractBarePackHeader(extractPackedString(bundleText));
|
|
278
|
+
const found = new Set();
|
|
279
|
+
const visit = (value) => {
|
|
280
|
+
if (typeof value === 'string') {
|
|
281
|
+
if (value.startsWith(DEFERRED_PROTOCOL))
|
|
282
|
+
found.add(value.slice(DEFERRED_PROTOCOL.length));
|
|
283
|
+
}
|
|
284
|
+
else if (value !== null && typeof value === 'object') {
|
|
285
|
+
for (const nested of Object.values(value))
|
|
286
|
+
visit(nested);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
visit(resolutions);
|
|
290
|
+
return found;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Throws `HostPrebuildsMissingError` when split addons are missing mobile
|
|
294
|
+
* platform packages, naming the exact pins.
|
|
295
|
+
*/
|
|
296
|
+
async function throwIfPlatformPackagesMissing(addons, hosts) {
|
|
297
|
+
let missing;
|
|
298
|
+
try {
|
|
299
|
+
missing = await findMissingHostPrebuilds(addons, hosts);
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (missing.length === 0)
|
|
305
|
+
return;
|
|
306
|
+
throw new HostPrebuildsMissingError(Object.fromEntries(missing.map((pkg) => [pkg.name, pkg.version])));
|
|
307
|
+
}
|
|
@@ -10,7 +10,9 @@ interface GenerateAddonsManifestOptions {
|
|
|
10
10
|
outputDir: string;
|
|
11
11
|
projectRoot: string;
|
|
12
12
|
logger: Logger;
|
|
13
|
+
includeAudioDecoder?: boolean;
|
|
13
14
|
}
|
|
15
|
+
export declare const AUDIO_DECODER_ADDON = "bare-ffmpeg";
|
|
14
16
|
interface GenerateAddonsManifestResult {
|
|
15
17
|
manifestPath: string;
|
|
16
18
|
addons: string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs, { promises as fsp } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
export const AUDIO_DECODER_ADDON = 'bare-ffmpeg';
|
|
3
4
|
export function extractPackedString(bundleJsText) {
|
|
4
5
|
const idx = bundleJsText.indexOf('module.exports');
|
|
5
6
|
if (idx === -1) {
|
|
@@ -150,7 +151,7 @@ export function buildNestedPathIndex(resolutions, projectRoot) {
|
|
|
150
151
|
return index;
|
|
151
152
|
}
|
|
152
153
|
export async function generateAddonsManifest(options) {
|
|
153
|
-
const { bundlePath, outputDir, projectRoot, logger } = options;
|
|
154
|
+
const { bundlePath, outputDir, projectRoot, logger, includeAudioDecoder = true } = options;
|
|
154
155
|
logger.info('\nš¦ Generating addons manifest...');
|
|
155
156
|
const bundleJsText = await fsp.readFile(bundlePath, 'utf8');
|
|
156
157
|
const packed = extractPackedString(bundleJsText);
|
|
@@ -171,7 +172,7 @@ export async function generateAddonsManifest(options) {
|
|
|
171
172
|
logger.warn(` Could not read ${candidate}: ${err.message}`);
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
|
-
if (pkgJson?.addon === true) {
|
|
175
|
+
if (pkgJson?.addon === true && (includeAudioDecoder || pkgName !== AUDIO_DECODER_ADDON)) {
|
|
175
176
|
addons.push(pkgName);
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BUILTIN_PLUGINS, BUILTIN_SUFFIXES } from '
|
|
1
|
+
import { BUILTIN_PLUGINS, BUILTIN_SUFFIXES } from '../../commands/bundle/constants.js';
|
|
2
2
|
import { InvalidPluginSpecifierError } from '../../utils/errors-client.js';
|
|
3
3
|
export function buildBuiltinSpecifier(sdkName, suffix) {
|
|
4
4
|
return `${sdkName}/${suffix}/plugin`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../../logging/types.js';
|
|
2
|
-
import { type NativeAddon } from '
|
|
3
|
-
import { type PackageManagerName } from '
|
|
4
|
-
export type { PackageManagerName } from '
|
|
2
|
+
import { type NativeAddon } from '../../commands/verify/addon-source.js';
|
|
3
|
+
import { type PackageManagerName } from '../../commands/host-prebuilds/package-manager.js';
|
|
4
|
+
export type { PackageManagerName } from '../../commands/host-prebuilds/package-manager.js';
|
|
5
5
|
export interface EnsureHostPrebuildsOptions {
|
|
6
6
|
/** The package whose package.json receives the pins; its package manager installs them. */
|
|
7
7
|
projectRoot: string;
|
|
@@ -9,7 +9,8 @@ export interface EnsureHostPrebuildsOptions {
|
|
|
9
9
|
hosts: string[];
|
|
10
10
|
/**
|
|
11
11
|
* Addon package names to cover. Defaults to every addon installed for the
|
|
12
|
-
* project: in its own node_modules or in that
|
|
12
|
+
* project, split addon metas included: in its own node_modules or in that
|
|
13
|
+
* of a workspace root listing it.
|
|
13
14
|
*/
|
|
14
15
|
addons?: string[] | undefined;
|
|
15
16
|
/** Install with this package manager instead of detecting the project's own. */
|
|
@@ -38,15 +39,15 @@ export interface EnsureHostPrebuildsResult {
|
|
|
38
39
|
* hosts and that the project does not have yet.
|
|
39
40
|
*
|
|
40
41
|
* A split addon names one platform package per host in the `#host-addon` map
|
|
41
|
-
* of its package.json (`<addon>-ios` covers every iOS host)
|
|
42
|
-
*
|
|
43
|
-
* build host never reports a
|
|
42
|
+
* of its package.json (`<addon>-ios` covers every iOS host) and loads its
|
|
43
|
+
* native code from that package alone. Desktop platform packages install as
|
|
44
|
+
* os/cpu-filtered optionalDependencies, but a build host never reports a
|
|
45
|
+
* mobile os, so mobile ones have to be declared.
|
|
44
46
|
* This declares the missing ones in package.json, pinned to each addon's
|
|
45
47
|
* exact version, using the project's own package manager.
|
|
46
48
|
*
|
|
47
|
-
* A host whose
|
|
48
|
-
*
|
|
49
|
-
* the addon's version. Throws `HostPrebuildsInstallRefusedError` when no
|
|
49
|
+
* A host whose platform package is already installed at the addon's version
|
|
50
|
+
* is skipped. Throws `HostPrebuildsInstallRefusedError` when no
|
|
50
51
|
* supported package manager (npm 7+, pnpm, bun, Yarn Berry) is found, and
|
|
51
52
|
* `HostPrebuildsInstallFailedError` when the install does not produce the
|
|
52
53
|
* packages.
|
|
@@ -68,4 +69,11 @@ export declare function installMissingHostPrebuilds(options: InstallMissingHostP
|
|
|
68
69
|
* the same platform package, since only one version of it can be installed.
|
|
69
70
|
*/
|
|
70
71
|
export declare function findMissingHostPrebuilds(addons: NativeAddon[], hosts: string[]): Promise<HostPrebuildPackage[]>;
|
|
72
|
+
/**
|
|
73
|
+
* The installed addons named in `names`, or every installed addon when
|
|
74
|
+
* `names` is omitted, split addon metas included. For each name the copy in
|
|
75
|
+
* the nearest modules directory wins, as it does for Node's resolver. Without
|
|
76
|
+
* `names`, the packages nested in each package's own node_modules count too.
|
|
77
|
+
*/
|
|
78
|
+
export declare function resolveAddons(projectRoot: string, names: string[] | undefined, logger: Logger): Promise<NativeAddon[]>;
|
|
71
79
|
//# sourceMappingURL=index.d.ts.map
|