@qvac/sdk 0.23.0 → 0.24.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.
Files changed (239) hide show
  1. package/NOTICE +115 -58
  2. package/README.md +10 -13
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
  5. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  6. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  7. package/dist/examples/assess-model-fit.d.ts +7 -9
  8. package/dist/examples/assess-model-fit.js +22 -43
  9. package/dist/examples/calc-tokens.d.ts +2 -0
  10. package/dist/examples/calc-tokens.js +21 -0
  11. package/dist/examples/classification/classify-image.js +11 -5
  12. package/dist/examples/completion-stop-reason.d.ts +3 -3
  13. package/dist/examples/completion-stop-reason.js +4 -4
  14. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  15. package/dist/examples/diffusion-flux3-klein.js +102 -0
  16. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  17. package/dist/examples/diffusion-moss-image.js +126 -0
  18. package/dist/examples/diffusion-qwen-image-21.js +15 -4
  19. package/dist/examples/embed-multimodal.d.ts +2 -0
  20. package/dist/examples/embed-multimodal.js +80 -0
  21. package/dist/examples/embed-p2p.js +2 -2
  22. package/dist/examples/image/megaloc.d.ts +2 -0
  23. package/dist/examples/image/megaloc.js +37 -0
  24. package/dist/examples/llamacpp-multimodal.js +18 -0
  25. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  26. package/dist/examples/rag/rag-turbovec.js +2 -2
  27. package/dist/examples/sessions.d.ts +17 -0
  28. package/dist/examples/sessions.js +63 -0
  29. package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
  30. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  31. package/dist/scripts/contract/build-contract.d.ts +2 -1
  32. package/dist/scripts/contract/build-contract.js +13 -1
  33. package/dist/scripts/contract/constants-registry.d.ts +17 -0
  34. package/dist/scripts/contract/constants-registry.js +8 -2
  35. package/dist/scripts/contract/method-shapes.d.ts +4 -0
  36. package/dist/scripts/contract/method-shapes.js +4 -0
  37. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  38. package/dist/scripts/enforce-inference-versions.js +28 -18
  39. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  40. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  41. package/dist/src/client/api/assess-model-fit.js +18 -31
  42. package/dist/src/client/api/audio-edit.d.ts +5 -3
  43. package/dist/src/client/api/audio-edit.js +5 -3
  44. package/dist/src/client/api/audio-gen-result.js +134 -45
  45. package/dist/src/client/api/audio-gen.d.ts +40 -3
  46. package/dist/src/client/api/audio-gen.js +40 -3
  47. package/dist/src/client/api/audio-understand.d.ts +2 -2
  48. package/dist/src/client/api/audio-understand.js +2 -2
  49. package/dist/src/client/api/batch-completion.js +2 -1
  50. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  51. package/dist/src/client/api/calc-tokens.js +44 -0
  52. package/dist/src/client/api/cancel.d.ts +2 -2
  53. package/dist/src/client/api/cancel.js +2 -2
  54. package/dist/src/client/api/classify.d.ts +12 -5
  55. package/dist/src/client/api/classify.js +17 -5
  56. package/dist/src/client/api/client-request-id.d.ts +0 -15
  57. package/dist/src/client/api/client-request-id.js +15 -12
  58. package/dist/src/client/api/completion-stream.d.ts +8 -1
  59. package/dist/src/client/api/completion-stream.js +10 -1
  60. package/dist/src/client/api/delete-cache.d.ts +9 -2
  61. package/dist/src/client/api/delete-cache.js +13 -3
  62. package/dist/src/client/api/diffusion.d.ts +20 -4
  63. package/dist/src/client/api/diffusion.js +23 -5
  64. package/dist/src/client/api/embed.d.ts +82 -29
  65. package/dist/src/client/api/embed.js +64 -19
  66. package/dist/src/client/api/get-model-info.d.ts +2 -2
  67. package/dist/src/client/api/get-model-info.js +2 -2
  68. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  69. package/dist/src/client/api/get-system-resources.js +2 -2
  70. package/dist/src/client/api/heartbeat.d.ts +3 -2
  71. package/dist/src/client/api/heartbeat.js +3 -2
  72. package/dist/src/client/api/index.d.ts +4 -3
  73. package/dist/src/client/api/index.js +2 -1
  74. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  75. package/dist/src/client/api/invoke-plugin.js +17 -2
  76. package/dist/src/client/api/load-model.js +5 -2
  77. package/dist/src/client/api/ocr.d.ts +5 -3
  78. package/dist/src/client/api/ocr.js +44 -21
  79. package/dist/src/client/api/rag.d.ts +1 -1
  80. package/dist/src/client/api/rag.js +1 -1
  81. package/dist/src/client/api/registry.d.ts +17 -7
  82. package/dist/src/client/api/registry.js +37 -12
  83. package/dist/src/client/api/resume.d.ts +2 -1
  84. package/dist/src/client/api/resume.js +2 -2
  85. package/dist/src/client/api/rpc-server.d.ts +4 -4
  86. package/dist/src/client/api/rpc-server.js +10 -10
  87. package/dist/src/client/api/state.d.ts +2 -2
  88. package/dist/src/client/api/state.js +2 -2
  89. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  90. package/dist/src/client/api/subscribe-logs.js +2 -2
  91. package/dist/src/client/api/suspend.d.ts +4 -2
  92. package/dist/src/client/api/suspend.js +4 -3
  93. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  94. package/dist/src/client/api/text-to-speech.js +83 -29
  95. package/dist/src/client/api/transcribe.d.ts +6 -2
  96. package/dist/src/client/api/transcribe.js +7 -1
  97. package/dist/src/client/api/unload-model.d.ts +19 -7
  98. package/dist/src/client/api/unload-model.js +29 -11
  99. package/dist/src/client/api/upscale.d.ts +6 -3
  100. package/dist/src/client/api/upscale.js +9 -4
  101. package/dist/src/client/api/vector-index.d.ts +50 -16
  102. package/dist/src/client/api/vector-index.js +100 -48
  103. package/dist/src/client/api/video-request.d.ts +5 -5
  104. package/dist/src/client/api/video.d.ts +3 -2
  105. package/dist/src/client/api/video.js +3 -2
  106. package/dist/src/client/api/vla.d.ts +9 -5
  107. package/dist/src/client/api/vla.js +17 -8
  108. package/dist/src/client/api/world.d.ts +5 -5
  109. package/dist/src/client/api/world.js +4 -4
  110. package/dist/src/client/init-hooks.d.ts +6 -4
  111. package/dist/src/client/init-hooks.js +12 -15
  112. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  113. package/dist/src/client/logging-stream-registry.js +31 -12
  114. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  115. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  116. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  117. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  118. package/dist/src/client/rpc/expo-rpc-client.js +189 -135
  119. package/dist/src/client/rpc/node-rpc-client.js +322 -413
  120. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  121. package/dist/src/client/rpc/pear-runtime.js +12 -0
  122. package/dist/src/client/rpc/rpc-client.d.ts +5 -4
  123. package/dist/src/client/rpc/rpc-client.js +126 -23
  124. package/dist/src/client/rpc/rpc-error.js +21 -2
  125. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  126. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  127. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  128. package/dist/src/client/rpc/worker-failure.js +61 -0
  129. package/dist/src/client/session-registry.d.ts +75 -0
  130. package/dist/src/client/session-registry.js +149 -0
  131. package/dist/src/client/session.d.ts +125 -0
  132. package/dist/src/client/session.js +148 -0
  133. package/dist/src/commands/bundle/addons.d.ts +14 -0
  134. package/dist/src/commands/bundle/addons.js +65 -0
  135. package/dist/src/commands/bundle/constants.js +1 -0
  136. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  137. package/dist/src/commands/bundle/entry-gen.js +17 -50
  138. package/dist/src/commands/bundle/index.d.ts +59 -13
  139. package/dist/src/commands/bundle/index.js +345 -121
  140. package/dist/src/commands/bundle/link.d.ts +58 -0
  141. package/dist/src/commands/bundle/link.js +135 -0
  142. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  143. package/dist/src/commands/bundle/node-support.js +23 -0
  144. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  145. package/dist/src/commands/bundle/read-bundle.js +27 -0
  146. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  147. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  148. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  149. package/dist/src/commands/bundle/scratch.js +178 -0
  150. package/dist/src/commands/bundle/targets.d.ts +14 -0
  151. package/dist/src/commands/bundle/targets.js +37 -0
  152. package/dist/src/commands/host-prebuilds/index.d.ts +5 -4
  153. package/dist/src/commands/host-prebuilds/index.js +9 -7
  154. package/dist/src/commands/index.d.ts +4 -3
  155. package/dist/src/commands/verify/abi.d.ts +20 -14
  156. package/dist/src/commands/verify/abi.js +11 -79
  157. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  158. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  159. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  160. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  161. package/dist/src/commands/verify/bundle-source.js +25 -21
  162. package/dist/src/commands/verify/engines-advice.d.ts +2 -8
  163. package/dist/src/commands/verify/engines-advice.js +7 -54
  164. package/dist/src/commands/verify/index.d.ts +30 -29
  165. package/dist/src/commands/verify/index.js +92 -200
  166. package/dist/src/commands/verify/prebuilds.d.ts +3 -5
  167. package/dist/src/commands/verify/prebuilds.js +1 -2
  168. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  169. package/dist/src/commands/verify/resource-collectors.js +1 -50
  170. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  171. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  172. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  173. package/dist/src/expo/plugins/withBareKit.js +204 -0
  174. package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
  175. package/dist/src/expo/plugins/withMobileBundle.js +36 -57
  176. package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
  177. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  178. package/dist/src/index.d.ts +6 -5
  179. package/dist/src/index.js +10 -14
  180. package/dist/src/logging/utils.js +10 -2
  181. package/dist/src/plugin-ids.d.ts +2 -1
  182. package/dist/src/plugin-ids.js +2 -0
  183. package/dist/src/schemas/public.d.ts +1 -1
  184. package/dist/src/schemas/public.js +1 -1
  185. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  186. package/dist/src/schemas/sdk-errors-client.js +30 -36
  187. package/dist/src/schemas/sdk-errors-server.d.ts +11 -1
  188. package/dist/src/schemas/sdk-errors-server.js +60 -2
  189. package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
  190. package/dist/src/server/rpc/rpc-utils.js +39 -5
  191. package/dist/src/utils/errors-client.d.ts +37 -29
  192. package/dist/src/utils/errors-client.js +50 -41
  193. package/dist/src/utils/errors-server.d.ts +59 -1
  194. package/dist/src/utils/errors-server.js +110 -1
  195. package/dist/src/utils/withTimeout.js +34 -17
  196. package/dist/src/worker/handle-request.js +25 -22
  197. package/dist/src/worker/handler-utils.d.ts +2 -6
  198. package/dist/src/worker/handler-utils.js +2 -20
  199. package/dist/src/worker/index.d.ts +2 -4
  200. package/dist/src/worker/index.js +23 -35
  201. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  202. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  203. package/dist/src/worker/shim.d.ts +4 -0
  204. package/dist/src/worker/shim.js +7 -0
  205. package/dist/src/worker/start.d.ts +9 -0
  206. package/dist/src/worker/start.js +16 -0
  207. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  208. package/dist/src/worker/unbundled-shim.js +4 -0
  209. package/docs/system-resources-support-matrix.md +27 -19
  210. package/package.json +62 -51
  211. package/src/electron-forge/index.cjs +65 -91
  212. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  213. package/dist/examples/model-fit-ui/server.js +0 -221
  214. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  215. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  216. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  217. package/dist/src/client/rpc/init-timeout.js +0 -25
  218. package/dist/src/client/rpc/ipc-socket-path.d.ts +0 -11
  219. package/dist/src/client/rpc/ipc-socket-path.js +0 -30
  220. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  221. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  222. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  223. package/dist/src/commands/bundle/bare-pack.js +0 -77
  224. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  225. package/dist/src/commands/bundle/manifest.js +0 -192
  226. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  227. package/dist/src/expo/plugins/link-addons.js +0 -65
  228. package/dist/src/pear/pre.d.ts +0 -21
  229. package/dist/src/pear/pre.js +0 -450
  230. package/dist/src/server/env.d.ts +0 -22
  231. package/dist/src/server/env.js +0 -59
  232. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  233. package/dist/src/server/utils/qvac-paths.js +0 -5
  234. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  235. package/dist/src/server/utils/worker-lock.js +0 -67
  236. package/dist/src/worker/create-server.d.ts +0 -8
  237. package/dist/src/worker/create-server.js +0 -51
  238. package/dist/src/worker/lifecycle.d.ts +0 -23
  239. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,34 +1,43 @@
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 { fileURLToPath, pathToFileURL } from 'node:url';
5
+ import stow from 'bare-stow';
4
6
  import { DEFAULT_HOSTS, DEFAULT_SDK_NAME } from '../../commands/bundle/constants.js';
5
7
  import { CONFIG_CANDIDATES, resolveConfigForProject } from '../../client/config-loader/resolve-config.node.js';
6
8
  import { createCommandLogger } from '../../commands/command-logger.js';
7
- import { BareImportsMapNotFoundError, HostPrebuildsMissingError } from '../../utils/errors-client.js';
9
+ import { BareImportsMapNotFoundError, BundleFailedError, BundleVerificationFailedError, HostPrebuildsMissingError } from '../../utils/errors-client.js';
8
10
  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';
11
+ import { generateWorkerEntry } from '../../commands/bundle/entry-gen.js';
12
+ import { createSdkImportResolver, sdkImportsMap } from '../../commands/bundle/resolve-sdk-import.js';
13
+ import { AUDIO_DECODER_ADDON, listBundledAddonModules, listBundledAddons } from '../../commands/bundle/addons.js';
14
+ import { assertReactNativeBareKitSupported, stageAddons } from '../../commands/bundle/link.js';
15
+ import { assertNodeCanBundle } from '../../commands/bundle/node-support.js';
16
+ import { readBundle } from '../../commands/bundle/read-bundle.js';
17
+ import { discardScratch, discardStaged, removeStaleScratch, replaceAll, scratchFolderFor } from '../../commands/bundle/scratch.js';
18
+ import { HARNESS_FILE, TARGETS } from '../../commands/bundle/targets.js';
19
+ import { findMissingPlatformPackages, installMissingHostPrebuilds, resolveAddons } from '../../commands/host-prebuilds/index.js';
20
+ import { findInAncestorNodeModules } from '../../expo/plugins/find-in-ancestor-node-modules.js';
21
+ import { isMobileHost } from '../../commands/verify/prebuilds.js';
22
+ import { DESKTOP_RUNTIMES, formatVerifyBundleResult, hasErrors, verifyBundle } from '../../commands/verify/index.js';
15
23
  import { formatRuntimeSource } from '../../commands/verify/abi.js';
16
24
  import { formatEnginesAdvice } from '../../commands/verify/engines-advice.js';
17
- const require = createRequire(import.meta.url);
25
+ import { BUNDLE_RECORD_FILE, BUNDLED_SDK_VERSION_FIELD, BUNDLED_TARGET_FIELD } from '../../client/rpc/bundle-stamp.js';
18
26
  function resolveSdkPath(projectRoot, explicitSdkPath) {
19
27
  if (explicitSdkPath) {
20
28
  return path.isAbsolute(explicitSdkPath)
21
29
  ? explicitSdkPath
22
30
  : path.join(projectRoot, explicitSdkPath);
23
31
  }
32
+ return (findInAncestorNodeModules(projectRoot, DEFAULT_SDK_NAME) ??
33
+ path.join(projectRoot, 'node_modules', DEFAULT_SDK_NAME));
34
+ }
35
+ function realpath(dir) {
24
36
  try {
25
- const pkgJsonPath = require.resolve('@qvac/sdk/package.json', {
26
- paths: [projectRoot]
27
- });
28
- return path.dirname(pkgJsonPath);
37
+ return fs.realpathSync(dir);
29
38
  }
30
39
  catch {
31
- return path.join(projectRoot, 'node_modules', '@qvac', 'sdk');
40
+ return dir;
32
41
  }
33
42
  }
34
43
  async function resolveSdkName(sdkPath) {
@@ -53,7 +62,6 @@ function resolveImportsMapPath(sdkPath, sdkName) {
53
62
  }
54
63
  throw new BareImportsMapNotFoundError(sdkName, importsMapPath);
55
64
  }
56
- const ENGINES_ISSUE_CODES = new Set(['abi-mismatch', 'engines-mismatch']);
57
65
  const AUDIO_PLUGINS = new Set([
58
66
  'whispercpp-transcription',
59
67
  'bci-whispercpp-transcription',
@@ -67,50 +75,204 @@ function audioPluginsIn(pluginSpecifiers, sdkName) {
67
75
  return builtin !== null && AUDIO_PLUGINS.has(builtin.suffix);
68
76
  });
69
77
  }
70
- async function checkBundleEngines(options) {
71
- const { projectRoot, bundlePath, hosts, configPath, network, logger } = options;
72
- logger.info('\nšŸ”Ž Checking engines.bare against the Bare runtime of each host...');
78
+ /**
79
+ * The bare-stow this command bundles and links with, whose Bare Kit pins are
80
+ * the phone runtimes, even when the project installs another SDK.
81
+ */
82
+ function bundlerBareStowDir() {
83
+ return path.dirname(createRequire(import.meta.url).resolve('bare-stow/package'));
84
+ }
85
+ async function verifyOutput(options) {
86
+ const { projectRoot, bundlePath, hosts, target, network, logger } = options;
87
+ logger.info('\nšŸ”Ž Verifying the bundle...');
73
88
  const result = await verifyBundle({
74
89
  projectRoot,
75
90
  addonsSource: bundlePath,
76
91
  hosts,
77
- ...(configPath !== undefined ? { configPath } : {}),
92
+ bareStowDir: bundlerBareStowDir(),
93
+ desktopRuntime: DESKTOP_RUNTIMES[target],
78
94
  ...(network !== undefined ? { network } : {}),
79
95
  onProgress: (message) => logger.info(` ${message}`)
80
96
  });
81
- const checkedHosts = [];
82
- for (const group of result.runtimes ?? []) {
83
- const label = group.hosts.join(', ');
84
- if (group.resolution.resolved) {
85
- checkedHosts.push(...group.hosts);
86
- logger.info(` ${label}: Bare ${group.resolution.runtime.version} (from ${formatRuntimeSource(group.resolution.runtime)})`);
87
- }
88
- else {
89
- logger.warn(`engines.bare not checked for ${label}: ${group.resolution.error.reason}`);
97
+ if (hasErrors(result)) {
98
+ throw new BundleVerificationFailedError(bundlePath, new Error(formatVerifyBundleResult(result)));
99
+ }
100
+ const checked = [];
101
+ for (const { hosts: platformHosts, resolution } of result.runtimes) {
102
+ const label = platformHosts.join(', ');
103
+ if (!resolution.resolved) {
104
+ logger.warn(`engines.bare not checked for ${label}: ${resolution.error.reason}`);
105
+ continue;
90
106
  }
107
+ logger.info(` ${label}: Bare ${resolution.runtime.version} (from ${formatRuntimeSource(resolution.runtime)})`);
108
+ checked.push(...platformHosts);
91
109
  }
92
- const mismatches = result.issues.filter((issue) => ENGINES_ISSUE_CODES.has(issue.code) && issue.level === 'error');
110
+ if (checked.length === 0)
111
+ return result;
112
+ const mismatches = result.issues.filter((issue) => issue.code === 'engines-mismatch');
93
113
  if (mismatches.length === 0) {
94
- if (checkedHosts.length > 0) {
95
- logger.info(` No engines.bare mismatches for ${checkedHosts.join(', ')}`);
96
- }
97
- return;
114
+ logger.info(` No engines.bare mismatches for ${checked.join(', ')}`);
115
+ return result;
98
116
  }
99
- const lines = ['The bundle contains packages that require a newer Bare runtime:'];
117
+ const lines = ['The bundle contains packages that declare a newer Bare runtime:'];
100
118
  for (const issue of mismatches)
101
119
  lines.push(` - ${issue.message}`);
102
120
  lines.push('');
103
- for (const advice of result.advice ?? [])
121
+ for (const advice of result.advice)
104
122
  lines.push(...formatEnginesAdvice(advice));
105
123
  logger.warn(lines.join('\n').trimEnd());
124
+ return result;
125
+ }
126
+ function defaultHosts(target) {
127
+ if (target === 'react-native')
128
+ return DEFAULT_HOSTS.filter(isMobileHost);
129
+ if (target === 'bare-kit')
130
+ return DEFAULT_HOSTS.filter((host) => host.startsWith('android-'));
131
+ return [`${process.platform}-${process.arch}`];
132
+ }
133
+ /** Writes bare-stow's harness package for the target to `outputDir`, and returns the bundle's path. */
134
+ async function stowBundle(options) {
135
+ const { projectRoot, entryPath, target, language, outputDir, hosts, imports, deferModules } = options;
136
+ const stowTarget = await TARGETS[target].load(projectRoot);
137
+ assertNodeCanBundle();
138
+ // With no base, bare-stow keys the bundle from the closest folder holding
139
+ // every module.
140
+ const stowOptions = {
141
+ imports,
142
+ defer: deferModules,
143
+ hosts,
144
+ language,
145
+ languageOptions: options.languageOptions
146
+ };
147
+ let bundlePath;
148
+ try {
149
+ for await (const artifact of stow(pathToFileURL(entryPath).href, stowTarget, pathToFileURL(outputDir).href, stowOptions)) {
150
+ if (artifact.base !== undefined)
151
+ bundlePath = fileURLToPath(artifact.url.href);
152
+ }
153
+ }
154
+ catch (error) {
155
+ throw new BundleFailedError(entryPath, describeMissingAddonBuild(error, hosts) ?? error);
156
+ }
157
+ if (bundlePath === undefined) {
158
+ throw new BundleFailedError(entryPath, new Error(`bare-stow wrote no bundle to ${outputDir}`));
159
+ }
160
+ if (language === 'javascript')
161
+ await assertHarnessDependenciesResolve(entryPath, outputDir);
162
+ return bundlePath;
163
+ }
164
+ const PACKAGE_IN_PATH = /\/node_modules\/((?:@[^/]+\/)?[^/]+)(?=\/)/g;
165
+ const MISSING_FOR_HOSTS = /for hosts? ((?:'[^']+'(?:, )?)+)/;
166
+ /**
167
+ * The addon package and hosts an `ADDON_NOT_FOUND` from the bundler names, in
168
+ * place of its list of candidate paths, or null for any other error. The error
169
+ * names the hosts only when some of `hosts` have a build.
170
+ */
171
+ export function describeMissingAddonBuild(error, hosts) {
172
+ const { code, referrer, message } = (error ?? {});
173
+ if (code !== 'ADDON_NOT_FOUND' || !referrer)
174
+ return null;
175
+ const owner = [...referrer.href.matchAll(PACKAGE_IN_PATH)].at(-1)?.[1];
176
+ if (owner === undefined)
177
+ return null;
178
+ const named = typeof message === 'string' ? MISSING_FOR_HOSTS.exec(message)?.[1] : undefined;
179
+ const missing = named === undefined ? hosts : [...named.matchAll(/'([^']+)'/g)].map((m) => m[1]);
180
+ return new Error(`${owner} has no native build for ${missing.join(', ')}. Bundle for the hosts it ships ` +
181
+ 'builds for, or leave it out of the bundle with `defer`.', { cause: error });
182
+ }
183
+ /**
184
+ * Packages every importer gets from the SDK's own dependencies. Their newer
185
+ * releases need a newer Bare than the Bare Kit this SDK links, and a project
186
+ * may install one through another package's range.
187
+ */
188
+ const SDK_PINNED_MODULES = ['bare-type'];
189
+ function pinSdkModules(imports, sdkPath, logger) {
190
+ const sdkRequire = createRequire(path.join(sdkPath, 'package.json'));
191
+ for (const name of SDK_PINNED_MODULES) {
192
+ try {
193
+ imports[name] = pathToFileURL(sdkRequire.resolve(name)).href;
194
+ }
195
+ catch {
196
+ logger.debug(` ${name} is not among the SDK's dependencies; bundling the project's`);
197
+ }
198
+ }
199
+ }
200
+ /** Files an older `@qvac/sdk` wrote into `qvac/`, which nothing reads now. */
201
+ const STALE_QVAC_FILES = ['worker.bundle.js', 'addons.manifest.json'];
202
+ /**
203
+ * Records the SDK version and the target in the harness package.json, for the
204
+ * client and `verifyBundle` to check. A Kotlin or Python harness has no
205
+ * package.json, so they go in a record file at its root.
206
+ */
207
+ async function stampBundle(harnessDir, sdkPath, target, language) {
208
+ const sdk = JSON.parse(await fsp.readFile(path.join(sdkPath, 'package.json'), 'utf8'));
209
+ const stampPath = path.join(harnessDir, language === 'javascript' ? 'package.json' : BUNDLE_RECORD_FILE);
210
+ const stamp = language === 'javascript'
211
+ ? JSON.parse(await fsp.readFile(stampPath, 'utf8'))
212
+ : {};
213
+ if (typeof sdk.version === 'string')
214
+ stamp[BUNDLED_SDK_VERSION_FIELD] = sdk.version;
215
+ stamp[BUNDLED_TARGET_FIELD] = target;
216
+ await fsp.writeFile(stampPath, `${JSON.stringify(stamp, null, 2)}\n`);
217
+ }
218
+ /**
219
+ * A `javascript` harness imports the dependencies bare-stow lists in its
220
+ * `package.json` by name, from the project that holds the package.
221
+ */
222
+ async function assertHarnessDependenciesResolve(entryPath, outputDir) {
223
+ const manifest = JSON.parse(await fsp.readFile(path.join(outputDir, 'package.json'), 'utf8'));
224
+ for (const name of Object.keys(manifest.dependencies ?? {})) {
225
+ if (findInAncestorNodeModules(outputDir, name) !== null)
226
+ continue;
227
+ throw new BundleFailedError(entryPath, new Error(`${HARNESS_FILE} imports '${name}', which the project cannot resolve`));
228
+ }
229
+ }
230
+ async function readFileIfExists(filePath) {
231
+ try {
232
+ return await fsp.readFile(filePath);
233
+ }
234
+ catch (error) {
235
+ if (error.code === 'ENOENT')
236
+ return null;
237
+ throw error;
238
+ }
239
+ }
240
+ /** Puts back `filePath`'s earlier content, or removes it when it had none. */
241
+ async function restoreFile(filePath, content) {
242
+ if (content === null)
243
+ await fsp.rm(filePath, { force: true });
244
+ else
245
+ await fsp.writeFile(filePath, content);
246
+ }
247
+ async function assertOutputDirEmpty(outputDir, entryPath) {
248
+ let entries;
249
+ try {
250
+ entries = await fsp.readdir(outputDir);
251
+ }
252
+ catch (error) {
253
+ if (error.code === 'ENOENT')
254
+ return;
255
+ throw new BundleFailedError(entryPath, error);
256
+ }
257
+ if (entries.length > 0) {
258
+ throw new BundleFailedError(entryPath, new Error(`outputDir ${outputDir} must be empty or not exist yet`));
259
+ }
106
260
  }
107
261
  export async function bundleSdk(options = {}) {
108
262
  const startTime = Date.now();
109
- const projectRoot = options.projectRoot ?? process.cwd();
110
- const outputDir = path.join(projectRoot, 'qvac');
111
- const entryPath = path.join(outputDir, 'worker.entry.mjs');
112
- const bundleEntryPath = path.join(outputDir, 'worker.bundle.entry.mjs');
113
- const bundlePath = path.join(outputDir, 'worker.bundle.js');
263
+ const projectRoot = path.resolve(options.projectRoot ?? process.cwd());
264
+ const qvacDir = path.join(projectRoot, 'qvac');
265
+ const outputDir = path.resolve(projectRoot, options.outputDir ?? path.join(qvacDir, 'worker'));
266
+ const entryPath = path.join(qvacDir, 'worker.entry.mjs');
267
+ if (options.outputDir !== undefined)
268
+ await assertOutputDirEmpty(outputDir, entryPath);
269
+ const entryFromOutput = path.relative(outputDir, entryPath);
270
+ if (!entryFromOutput.startsWith('..') && !path.isAbsolute(entryFromOutput)) {
271
+ throw new BundleFailedError(entryPath, new Error(`outputDir ${outputDir} must not contain the worker entry`));
272
+ }
273
+ const target = options.target ?? 'bare-sidecar';
274
+ const language = options.language ?? (target === 'bare-kit' ? 'kotlin' : 'javascript');
275
+ const languageOptions = options.languageOptions ?? {};
114
276
  const logger = createCommandLogger(options);
115
277
  logger.info('šŸ”§ QVAC SDK Worker Bundler\n');
116
278
  const { configPath, config } = await resolveConfigForProject(projectRoot, options.configPath);
@@ -124,18 +286,33 @@ export async function bundleSdk(options = {}) {
124
286
  CONFIG_CANDIDATES.map((c) => ` - ${c}`).join('\n') +
125
287
  '\n');
126
288
  }
127
- const sdkPath = resolveSdkPath(projectRoot, options.sdkPath);
289
+ const sdkPath = realpath(resolveSdkPath(projectRoot, options.sdkPath));
128
290
  const sdkName = await resolveSdkName(sdkPath);
129
291
  logger.info(`šŸ“¦ SDK: ${sdkName}`);
130
292
  logger.debug(` Path: ${sdkPath}`);
131
293
  const importsMapPath = resolveImportsMapPath(sdkPath, sdkName);
294
+ const imports = JSON.parse(await fsp.readFile(importsMapPath, 'utf8'));
295
+ // An SDK the project installs is imported by name. One outside the project is
296
+ // imported by its real path, and so is its bare-stow runtime, which the
297
+ // generated shim imports.
298
+ const installedSdk = findInAncestorNodeModules(projectRoot, sdkName);
299
+ const sdkByName = installedSdk !== null && realpath(installedSdk) === sdkPath;
300
+ const resolveImport = sdkByName ? undefined : createSdkImportResolver(sdkPath, sdkName);
301
+ if (!sdkByName) {
302
+ const sdkRequire = createRequire(path.join(sdkPath, 'package.json'));
303
+ Object.assign(imports, sdkImportsMap(sdkPath, sdkName));
304
+ for (const runtime of ['bare-stow-runtime', 'bare-stow-runtime/process']) {
305
+ imports[runtime] = pathToFileURL(sdkRequire.resolve(runtime)).href;
306
+ }
307
+ }
308
+ pinSdkModules(imports, sdkPath, logger);
132
309
  const pluginSpecifiers = resolvePluginSpecifiers(config, sdkName, logger);
133
310
  logger.info(`\nšŸ“¦ Plugins to include (${pluginSpecifiers.length}):`);
134
311
  for (const spec of pluginSpecifiers) {
135
312
  const label = parseBuiltinSpecifier(spec, sdkName) ? 'āœ“ built-in' : 'āŠ• custom';
136
313
  logger.info(` ${label}: ${spec}`);
137
314
  }
138
- const hosts = options.hosts && options.hosts.length > 0 ? options.hosts : DEFAULT_HOSTS;
315
+ const hosts = options.hosts && options.hosts.length > 0 ? options.hosts : defaultHosts(target);
139
316
  const explicitDefer = options.defer ?? [];
140
317
  const includeAudioDecoder = config.includeAudioDecoder !== false && !explicitDefer.includes(AUDIO_DECODER_ADDON);
141
318
  const deferModules = includeAudioDecoder
@@ -147,119 +324,170 @@ export async function bundleSdk(options = {}) {
147
324
  logger.warn(`${AUDIO_DECODER_ADDON} is not bundled: ${affected.join(', ')} cannot decode compressed audio files; compressed audiogen output formats also require FFmpeg.`);
148
325
  }
149
326
  }
150
- await fsp.mkdir(outputDir, { recursive: true });
151
- logger.info('\nšŸ“ Generating worker entry...');
152
- const resolveSdkImport = createSdkImportResolver(sdkPath, sdkName);
153
- const { runtimeEntry, bundleEntry } = generateWorkerEntries(pluginSpecifiers, sdkName, resolveSdkImport, config.rpcServerProvider);
154
- await fsp.writeFile(entryPath, runtimeEntry, 'utf8');
155
- logger.info(` Created: ${path.relative(projectRoot, entryPath)}`);
156
- logger.info(` Using: ${path.relative(projectRoot, importsMapPath)}`);
157
- logger.info('\nšŸ”Ø Bundling with bare-pack...');
158
- logger.debug(` Hosts: ${hosts.join(', ')}`);
159
- if (deferModules.length > 0) {
160
- logger.debug(` Deferred: ${deferModules.join(', ')}`);
161
- }
162
- // Missing mobile platform packages are installed, or reported, before bundling.
163
- let installedPrebuilds = [];
164
- const barePackOptions = {
165
- entryPath: bundleEntryPath,
327
+ if (target === 'react-native')
328
+ await assertReactNativeBareKitSupported(projectRoot, sdkPath);
329
+ await fsp.mkdir(qvacDir, { recursive: true });
330
+ const scanOutputDir = path.join(qvacDir, 'worker-scan');
331
+ await removeStaleScratch(outputDir);
332
+ await removeStaleScratch(scanOutputDir);
333
+ const stowOptions = {
334
+ projectRoot,
335
+ entryPath,
336
+ target,
337
+ language,
338
+ languageOptions,
339
+ outputDir,
166
340
  hosts,
167
- importsMapPath,
168
- quiet: options.quiet === true,
169
- logger
341
+ imports,
342
+ deferModules
170
343
  };
171
344
  const addonsMissingPlatformPackages = () => reachedAddonsMissingPlatformPackages({
172
345
  addons: async () => (await resolveAddons(projectRoot, undefined, logger)).filter((addon) => !deferModules.includes(addon.name)),
173
346
  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'),
347
+ scan: async (extraDefer) => {
348
+ const scanDir = await scratchFolderFor(scanOutputDir);
349
+ try {
350
+ const bundlePath = await stowBundle({
351
+ ...stowOptions,
352
+ outputDir: scanDir,
353
+ deferModules: [...deferModules, ...extraDefer]
354
+ });
355
+ return (await readBundle(bundlePath)).resolutions;
356
+ }
357
+ finally {
358
+ await discardScratch(scanDir);
359
+ }
360
+ },
181
361
  logger
182
362
  });
363
+ // The bundle and the app's native modules are built in scratch folders and
364
+ // replace the old ones together, so a failure leaves the working ones in place.
365
+ // bare-stow names the bundle's main after the entry's folder, so the entry is
366
+ // bundled from its own path and its previous content is restored on failure.
367
+ const previousEntry = await readFileIfExists(entryPath);
368
+ const scratch = await scratchFolderFor(outputDir);
369
+ const staged = [{ dir: outputDir, next: scratch }];
370
+ let installedPrebuilds = [];
371
+ let addons;
372
+ let addonModules;
373
+ let linked = [];
374
+ let verification = null;
375
+ let bundlePath;
376
+ let replaced = false;
183
377
  try {
184
- await fsp.writeFile(bundleEntryPath, bundleEntry, 'utf8');
185
- const addons = await addonsMissingPlatformPackages();
378
+ logger.info('\nšŸ“ Generating worker entry...');
379
+ await fsp.writeFile(entryPath, generateWorkerEntry(pluginSpecifiers, sdkName, config.rpcServerProvider, resolveImport), 'utf8');
380
+ logger.info(` Created: ${path.relative(projectRoot, entryPath)}`);
381
+ logger.info(`\nšŸ”Ø Bundling for ${target}...`);
382
+ logger.debug(` Hosts: ${hosts.join(', ')}`);
383
+ if (deferModules.length > 0) {
384
+ logger.debug(` Deferred: ${deferModules.join(', ')}`);
385
+ }
386
+ const missingPlatformAddons = await addonsMissingPlatformPackages();
186
387
  if (options.installMissingPrebuilds === true) {
388
+ // Desktop packages are never installed, so a missing one is reported
389
+ // before package.json changes.
390
+ await throwIfPlatformPackagesMissing(missingPlatformAddons, hosts.filter((host) => !isMobileHost(host)));
187
391
  const { installed } = await installMissingHostPrebuilds({
188
392
  projectRoot,
189
393
  hosts,
190
- addons,
394
+ addons: missingPlatformAddons,
191
395
  quiet: options.quiet === true,
192
396
  logger
193
397
  });
194
398
  installedPrebuilds = installed;
195
399
  }
196
400
  else {
197
- await throwIfPlatformPackagesMissing(addons, hosts);
401
+ await throwIfPlatformPackagesMissing(missingPlatformAddons, hosts);
198
402
  }
199
- await runBarePack({ ...barePackOptions, outputPath: bundlePath, deferModules });
403
+ const scratchBundlePath = await stowBundle({ ...stowOptions, outputDir: scratch });
404
+ await stampBundle(scratch, sdkPath, target, language);
405
+ bundlePath = path.join(outputDir, path.relative(scratch, scratchBundlePath));
406
+ const stats = await fsp.stat(scratchBundlePath);
407
+ const sizeKB = (stats.size / 1024).toFixed(1);
408
+ logger.info(`\nāœ… Bundle created: ${path.relative(projectRoot, bundlePath)}`);
409
+ logger.info(` Size: ${sizeKB} KB`);
410
+ const listOptions = { bundlePath: scratchBundlePath, projectRoot, logger, includeAudioDecoder };
411
+ addons = await listBundledAddons(listOptions);
412
+ addonModules = await listBundledAddonModules(listOptions);
413
+ logger.info(` Native addons (${addons.length}): ${addons.join(', ') || '(none)'}`);
414
+ if (options.verify !== false) {
415
+ verification = await verifyOutput({
416
+ projectRoot,
417
+ bundlePath: scratchBundlePath,
418
+ hosts,
419
+ target,
420
+ network: options.network,
421
+ logger
422
+ });
423
+ }
424
+ if (target === 'react-native' && options.link !== false) {
425
+ const linkHosts = Array.isArray(options.link) ? options.link : hosts;
426
+ logger.info('\nšŸ”— Writing Bare Kit and the native addons into the app...');
427
+ const nativeModules = await stageAddons({
428
+ projectRoot,
429
+ entryPath,
430
+ hosts: linkHosts,
431
+ imports,
432
+ defer: deferModules,
433
+ logger
434
+ });
435
+ staged.push(...nativeModules.staged);
436
+ linked = nativeModules.written;
437
+ logger.info(` Wrote ${linked.length} files`);
438
+ }
439
+ await replaceAll(staged);
440
+ replaced = true;
441
+ for (const stale of STALE_QVAC_FILES)
442
+ await fsp.rm(path.join(qvacDir, stale), { force: true });
200
443
  }
201
- finally {
202
- await fsp.rm(bundleEntryPath, { force: true });
444
+ catch (error) {
445
+ if (!replaced)
446
+ await restoreFile(entryPath, previousEntry);
447
+ throw error;
203
448
  }
204
- const stats = await fsp.stat(bundlePath);
205
- const sizeKB = (stats.size / 1024).toFixed(1);
206
- logger.info(`\nāœ… Bundle created: ${path.relative(projectRoot, bundlePath)}`);
207
- logger.info(` Size: ${sizeKB} KB`);
208
- const manifestResult = await generateAddonsManifest({
209
- bundlePath,
210
- outputDir,
211
- projectRoot,
212
- logger,
213
- includeAudioDecoder
214
- });
215
- if (options.checkEngines !== false) {
216
- await checkBundleEngines({
217
- projectRoot,
218
- bundlePath,
219
- hosts,
220
- configPath: configPath ?? undefined,
221
- network: options.network,
222
- logger
223
- });
449
+ finally {
450
+ await discardStaged(staged);
224
451
  }
225
452
  const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
226
453
  logger.info(`\nšŸŽ‰ Done in ${elapsed}s!\n`);
227
454
  logger.info('Generated files:');
228
- logger.info(' - qvac/worker.entry.mjs (standalone worker with RPC + lifecycle)');
229
- logger.info(' - qvac/worker.bundle.js (mobile bundle for Expo/React Native BareKit)');
230
- logger.info(' - qvac/addons.manifest.json\n');
231
- logger.info('Mobile: Expo plugin auto-configures worker.bundle.js');
232
- logger.info('Standalone: Import qvac/worker.entry.mjs for full worker with RPC\n');
455
+ logger.info(` - ${path.relative(projectRoot, entryPath)} (worker entry)`);
456
+ logger.info(` - ${path.relative(projectRoot, outputDir)} (starts the bundled worker)`);
457
+ logger.info(` - ${path.relative(projectRoot, bundlePath)}\n`);
233
458
  return {
459
+ target,
460
+ language,
461
+ hosts,
462
+ entryPath,
463
+ outputDir,
234
464
  bundlePath,
235
465
  plugins: pluginSpecifiers,
236
- addons: manifestResult.addons,
237
- entryPaths: {
238
- worker: entryPath
239
- },
240
- manifestPath: manifestResult.manifestPath,
241
- installedPrebuilds
466
+ addons,
467
+ addonModules,
468
+ installedPrebuilds,
469
+ linked,
470
+ verification
242
471
  };
243
472
  }
244
473
  /**
245
474
  * 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
475
+ * platform package for one of the hosts. Every installed addon is a candidate (`@qvac/sdk`
476
+ * depends on all of them), so a first bundling pass defers each missing
477
+ * platform package: the bundle then records the reached ones as
249
478
  * `deferred:<package>` and never visits the rest. Empty when nothing is
250
479
  * missing, or when that pass fails, which leaves the real bundle to report
251
480
  * the failure.
252
481
  */
253
482
  async function reachedAddonsMissingPlatformPackages(options) {
254
- const { hosts, scan, scanPath, logger } = options;
483
+ const { hosts, scan, logger } = options;
255
484
  const addons = await options.addons();
256
- const missing = await findMissingHostPrebuilds(addons, hosts);
485
+ const missing = await findMissingPlatformPackages(addons, hosts);
257
486
  if (missing.length === 0)
258
487
  return [];
259
488
  logger.debug(`\nšŸ”Ž Checking which of ${missing.length} missing platform packages the bundle reaches...`);
260
489
  try {
261
- await scan(missing.map((pkg) => pkg.name), scanPath);
262
- const reached = deferredSpecifiers(await fsp.readFile(scanPath, 'utf8'));
490
+ const reached = deferredSpecifiers(await scan(missing.map((pkg) => pkg.name)));
263
491
  const owners = new Set(missing.filter((pkg) => reached.has(pkg.name)).map((pkg) => pkg.addon));
264
492
  return addons.filter((addon) => owners.has(addon.name));
265
493
  }
@@ -267,14 +495,10 @@ async function reachedAddonsMissingPlatformPackages(options) {
267
495
  logger.debug(` Scan failed: ${error instanceof Error ? error.message : String(error)}`);
268
496
  return [];
269
497
  }
270
- finally {
271
- await fsp.rm(scanPath, { force: true });
272
- }
273
498
  }
274
499
  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));
500
+ /** Every specifier a bundle leaves as `deferred:<specifier>`. */
501
+ function deferredSpecifiers(resolutions) {
278
502
  const found = new Set();
279
503
  const visit = (value) => {
280
504
  if (typeof value === 'string') {
@@ -290,13 +514,13 @@ function deferredSpecifiers(bundleText) {
290
514
  return found;
291
515
  }
292
516
  /**
293
- * Throws `HostPrebuildsMissingError` when split addons are missing mobile
294
- * platform packages, naming the exact pins.
517
+ * Throws `HostPrebuildsMissingError` when split addons are missing platform
518
+ * packages for `hosts`, naming the exact pins.
295
519
  */
296
520
  async function throwIfPlatformPackagesMissing(addons, hosts) {
297
521
  let missing;
298
522
  try {
299
- missing = await findMissingHostPrebuilds(addons, hosts);
523
+ missing = await findMissingPlatformPackages(addons, hosts);
300
524
  }
301
525
  catch {
302
526
  return;
@@ -0,0 +1,58 @@
1
+ import stow from 'bare-stow';
2
+ import { type Staged } from '../../commands/bundle/scratch.js';
3
+ import type { Logger } from '../../logging/types.js';
4
+ /** The folder of the app's assets in a linked module, which an iOS app copies into its bundle. */
5
+ export declare const BARE_KIT_RESOURCES: string;
6
+ /** Checks the installed react-native-bare-kit against the SDK's peer range for it. */
7
+ export declare function assertReactNativeBareKitSupported(projectRoot: string, sdkPath: string): Promise<void>;
8
+ /**
9
+ * The module each phone platform's app builds Bare Kit and the native addons
10
+ * from, relative to the project root.
11
+ */
12
+ export declare const NATIVE_MODULES: {
13
+ readonly android: {
14
+ readonly prefix: "android-";
15
+ readonly dir: string;
16
+ readonly language: "kotlin";
17
+ readonly languageOptions: {
18
+ readonly package: "io.tether.qvac.sdk.addons";
19
+ };
20
+ };
21
+ readonly ios: {
22
+ readonly prefix: "ios-";
23
+ readonly dir: string;
24
+ readonly language: "swift";
25
+ readonly languageOptions: {};
26
+ };
27
+ };
28
+ /**
29
+ * Pins bare-kit-swift at the version bare-stow names. bare-stow writes it as a
30
+ * minimum, which Swift Package Manager resolves at the newest release, so the
31
+ * app would run a newer Bare than the one its addons were checked against.
32
+ */
33
+ export declare function pinBareKitSwift(manifest: string): string;
34
+ export interface StageAddonsOptions {
35
+ projectRoot: string;
36
+ /** The worker entry the bundle starts from. */
37
+ entryPath: string;
38
+ hosts: string[];
39
+ imports: stow.LinkOptions['imports'];
40
+ defer: string[];
41
+ logger: Logger;
42
+ }
43
+ /**
44
+ * Links each phone platform's native module for `hosts`, holding Bare Kit and
45
+ * the native addons the worker loads, into a scratch folder. Returns the files
46
+ * as they will be named in the app, and the staged folders for `replaceAll`;
47
+ * the caller discards them. A failed link discards its own.
48
+ */
49
+ export declare function stageAddons(options: StageAddonsOptions): Promise<{
50
+ written: string[];
51
+ staged: Staged[];
52
+ }>;
53
+ /**
54
+ * Addons that ship a library under the same name write it to the same path,
55
+ * and the copy linked last is the one the app loads.
56
+ */
57
+ export declare function warnOverwritten(written: string[], out: string, logger: Logger): void;
58
+ //# sourceMappingURL=link.d.ts.map