@qvac/sdk 0.22.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 (284) hide show
  1. package/NOTICE +194 -97
  2. package/README.md +29 -470
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  5. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
  6. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  7. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  8. package/dist/examples/assess-model-fit.d.ts +7 -9
  9. package/dist/examples/assess-model-fit.js +22 -43
  10. package/dist/examples/calc-tokens.d.ts +2 -0
  11. package/dist/examples/calc-tokens.js +21 -0
  12. package/dist/examples/classification/classify-image.js +11 -5
  13. package/dist/examples/completion-stop-reason.d.ts +3 -3
  14. package/dist/examples/completion-stop-reason.js +4 -4
  15. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  16. package/dist/examples/diffusion-flux3-klein.js +102 -0
  17. package/dist/examples/diffusion-img2vid-ltx.js +7 -14
  18. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  19. package/dist/examples/diffusion-moss-image.js +126 -0
  20. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  21. package/dist/examples/diffusion-qwen-image-21.js +115 -0
  22. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  23. package/dist/examples/embed-multimodal.d.ts +2 -0
  24. package/dist/examples/embed-multimodal.js +80 -0
  25. package/dist/examples/embed-p2p.js +2 -2
  26. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  27. package/dist/examples/image/megaloc.d.ts +2 -0
  28. package/dist/examples/image/megaloc.js +37 -0
  29. package/dist/examples/llamacpp-multimodal.js +21 -1
  30. package/dist/examples/mcp-websearch.js +1 -1
  31. package/dist/examples/plugins.js +1 -1
  32. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  33. package/dist/examples/rag/rag-turbovec.js +2 -2
  34. package/dist/examples/rerank.d.ts +2 -0
  35. package/dist/examples/rerank.js +33 -0
  36. package/dist/examples/sessions.d.ts +17 -0
  37. package/dist/examples/sessions.js +63 -0
  38. package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
  39. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
  40. package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
  41. package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
  42. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  43. package/dist/scripts/contract/build-contract.d.ts +2 -1
  44. package/dist/scripts/contract/build-contract.js +13 -1
  45. package/dist/scripts/contract/constants-registry.d.ts +19 -0
  46. package/dist/scripts/contract/constants-registry.js +9 -2
  47. package/dist/scripts/contract/method-shapes.d.ts +5 -0
  48. package/dist/scripts/contract/method-shapes.js +5 -0
  49. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  50. package/dist/scripts/enforce-inference-versions.js +28 -18
  51. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  52. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  53. package/dist/src/client/api/assess-model-fit.js +19 -32
  54. package/dist/src/client/api/audio-edit.d.ts +5 -3
  55. package/dist/src/client/api/audio-edit.js +7 -5
  56. package/dist/src/client/api/audio-gen-result.js +136 -47
  57. package/dist/src/client/api/audio-gen.d.ts +40 -3
  58. package/dist/src/client/api/audio-gen.js +42 -5
  59. package/dist/src/client/api/audio-understand.d.ts +2 -2
  60. package/dist/src/client/api/audio-understand.js +4 -4
  61. package/dist/src/client/api/batch-completion.js +4 -3
  62. package/dist/src/client/api/bci-transcribe.js +3 -3
  63. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  64. package/dist/src/client/api/calc-tokens.js +44 -0
  65. package/dist/src/client/api/cancel.d.ts +2 -2
  66. package/dist/src/client/api/cancel.js +3 -3
  67. package/dist/src/client/api/classify.d.ts +12 -5
  68. package/dist/src/client/api/classify.js +18 -6
  69. package/dist/src/client/api/client-request-id.d.ts +0 -15
  70. package/dist/src/client/api/client-request-id.js +15 -12
  71. package/dist/src/client/api/completion-stream.d.ts +9 -1
  72. package/dist/src/client/api/completion-stream.js +14 -3
  73. package/dist/src/client/api/decide.d.ts +1 -1
  74. package/dist/src/client/api/decide.js +3 -3
  75. package/dist/src/client/api/delete-cache.d.ts +9 -2
  76. package/dist/src/client/api/delete-cache.js +14 -4
  77. package/dist/src/client/api/diffusion.d.ts +38 -5
  78. package/dist/src/client/api/diffusion.js +42 -7
  79. package/dist/src/client/api/download-asset.js +3 -3
  80. package/dist/src/client/api/embed.d.ts +82 -29
  81. package/dist/src/client/api/embed.js +66 -21
  82. package/dist/src/client/api/finetune.js +3 -3
  83. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  84. package/dist/src/client/api/get-model-info.d.ts +2 -2
  85. package/dist/src/client/api/get-model-info.js +3 -3
  86. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  87. package/dist/src/client/api/get-system-resources.js +3 -3
  88. package/dist/src/client/api/heartbeat.d.ts +3 -2
  89. package/dist/src/client/api/heartbeat.js +4 -3
  90. package/dist/src/client/api/index.d.ts +8 -6
  91. package/dist/src/client/api/index.js +6 -4
  92. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  93. package/dist/src/client/api/invoke-plugin.js +18 -3
  94. package/dist/src/client/api/load-model.js +9 -6
  95. package/dist/src/client/api/logging-stream.d.ts +11 -2
  96. package/dist/src/client/api/logging-stream.js +12 -3
  97. package/dist/src/client/api/ocr.d.ts +5 -3
  98. package/dist/src/client/api/ocr.js +45 -22
  99. package/dist/src/client/api/rag.d.ts +1 -1
  100. package/dist/src/client/api/rag.js +3 -3
  101. package/dist/src/client/api/registry.d.ts +19 -8
  102. package/dist/src/client/api/registry.js +43 -17
  103. package/dist/src/client/api/rerank.d.ts +22 -0
  104. package/dist/src/client/api/rerank.js +39 -0
  105. package/dist/src/client/api/resume.d.ts +2 -1
  106. package/dist/src/client/api/resume.js +3 -3
  107. package/dist/src/client/api/rpc-server.d.ts +4 -4
  108. package/dist/src/client/api/rpc-server.js +12 -12
  109. package/dist/src/client/api/state.d.ts +2 -2
  110. package/dist/src/client/api/state.js +3 -3
  111. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  112. package/dist/src/client/api/subscribe-logs.js +4 -3
  113. package/dist/src/client/api/suspend.d.ts +4 -2
  114. package/dist/src/client/api/suspend.js +5 -4
  115. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  116. package/dist/src/client/api/text-to-speech.js +86 -32
  117. package/dist/src/client/api/transcribe.d.ts +7 -3
  118. package/dist/src/client/api/transcribe.js +9 -3
  119. package/dist/src/client/api/translate.js +2 -2
  120. package/dist/src/client/api/unload-model.d.ts +19 -7
  121. package/dist/src/client/api/unload-model.js +31 -13
  122. package/dist/src/client/api/upscale.d.ts +6 -3
  123. package/dist/src/client/api/upscale.js +10 -5
  124. package/dist/src/client/api/vector-index.d.ts +51 -17
  125. package/dist/src/client/api/vector-index.js +101 -49
  126. package/dist/src/client/api/video-request.d.ts +5 -5
  127. package/dist/src/client/api/video.d.ts +3 -2
  128. package/dist/src/client/api/video.js +6 -5
  129. package/dist/src/client/api/vla.d.ts +9 -5
  130. package/dist/src/client/api/vla.js +17 -8
  131. package/dist/src/client/api/world-result.js +2 -2
  132. package/dist/src/client/api/world.d.ts +6 -6
  133. package/dist/src/client/api/world.js +6 -6
  134. package/dist/src/client/init-hooks.d.ts +6 -4
  135. package/dist/src/client/init-hooks.js +12 -15
  136. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  137. package/dist/src/client/logging-stream-registry.js +36 -14
  138. package/dist/src/client/plugins-factory.d.ts +1 -1
  139. package/dist/src/client/plugins-factory.js +1 -1
  140. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  141. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  142. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  143. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  144. package/dist/src/client/rpc/expo-rpc-client.js +192 -138
  145. package/dist/src/client/rpc/node-rpc-client.js +324 -426
  146. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  147. package/dist/src/client/rpc/pear-runtime.js +12 -0
  148. package/dist/src/client/rpc/rpc-client.d.ts +6 -4
  149. package/dist/src/client/rpc/rpc-client.js +168 -31
  150. package/dist/src/client/rpc/rpc-error.js +24 -2
  151. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  152. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  153. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  154. package/dist/src/client/rpc/worker-failure.js +61 -0
  155. package/dist/src/client/session-registry.d.ts +75 -0
  156. package/dist/src/client/session-registry.js +149 -0
  157. package/dist/src/client/session.d.ts +125 -0
  158. package/dist/src/client/session.js +148 -0
  159. package/dist/src/commands/bundle/addons.d.ts +14 -0
  160. package/dist/src/commands/bundle/addons.js +65 -0
  161. package/dist/src/commands/bundle/constants.js +2 -0
  162. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  163. package/dist/src/commands/bundle/entry-gen.js +18 -51
  164. package/dist/src/commands/bundle/index.d.ts +60 -14
  165. package/dist/src/commands/bundle/index.js +350 -126
  166. package/dist/src/commands/bundle/link.d.ts +58 -0
  167. package/dist/src/commands/bundle/link.js +135 -0
  168. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  169. package/dist/src/commands/bundle/node-support.js +23 -0
  170. package/dist/src/commands/bundle/plugins.js +1 -1
  171. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  172. package/dist/src/commands/bundle/read-bundle.js +27 -0
  173. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  174. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  175. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  176. package/dist/src/commands/bundle/scratch.js +178 -0
  177. package/dist/src/commands/bundle/targets.d.ts +14 -0
  178. package/dist/src/commands/bundle/targets.js +37 -0
  179. package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
  180. package/dist/src/commands/host-prebuilds/index.js +13 -11
  181. package/dist/src/commands/index.d.ts +13 -12
  182. package/dist/src/commands/index.js +7 -7
  183. package/dist/src/commands/verify/abi.d.ts +21 -15
  184. package/dist/src/commands/verify/abi.js +12 -80
  185. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  186. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  187. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  188. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  189. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  190. package/dist/src/commands/verify/bundle-source.js +27 -23
  191. package/dist/src/commands/verify/engines-advice.d.ts +6 -12
  192. package/dist/src/commands/verify/engines-advice.js +9 -56
  193. package/dist/src/commands/verify/index.d.ts +34 -33
  194. package/dist/src/commands/verify/index.js +96 -204
  195. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  196. package/dist/src/commands/verify/node-modules-source.js +1 -1
  197. package/dist/src/commands/verify/prebuilds.d.ts +4 -6
  198. package/dist/src/commands/verify/prebuilds.js +3 -4
  199. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  200. package/dist/src/commands/verify/resource-collectors.js +3 -52
  201. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  202. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  203. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  204. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  205. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  206. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  207. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  208. package/dist/src/expo/plugins/withBareKit.js +204 -0
  209. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  210. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  211. package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
  212. package/dist/src/expo/plugins/withMobileBundle.js +38 -59
  213. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  214. package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
  215. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  216. package/dist/src/index.d.ts +6 -5
  217. package/dist/src/index.js +10 -14
  218. package/dist/src/logging/addon.d.ts +1 -1
  219. package/dist/src/logging/base-logger.js +1 -1
  220. package/dist/src/logging/utils.js +11 -3
  221. package/dist/src/plugin-ids.d.ts +3 -1
  222. package/dist/src/plugin-ids.js +4 -0
  223. package/dist/src/schemas/public.d.ts +1 -1
  224. package/dist/src/schemas/public.js +1 -1
  225. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  226. package/dist/src/schemas/sdk-errors-client.js +30 -36
  227. package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
  228. package/dist/src/schemas/sdk-errors-server.js +65 -2
  229. package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
  230. package/dist/src/server/rpc/rpc-utils.js +41 -0
  231. package/dist/src/utils/aggregate-events.d.ts +1 -1
  232. package/dist/src/utils/aggregate-events.js +2 -2
  233. package/dist/src/utils/errors-client.d.ts +37 -29
  234. package/dist/src/utils/errors-client.js +50 -41
  235. package/dist/src/utils/errors-server.d.ts +65 -1
  236. package/dist/src/utils/errors-server.js +122 -1
  237. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  238. package/dist/src/utils/mcp-adapter.js +1 -1
  239. package/dist/src/utils/tool-helpers.js +1 -1
  240. package/dist/src/utils/withTimeout.js +34 -17
  241. package/dist/src/worker/handle-request.js +26 -21
  242. package/dist/src/worker/handler-utils.d.ts +2 -6
  243. package/dist/src/worker/handler-utils.js +2 -20
  244. package/dist/src/worker/index.d.ts +2 -4
  245. package/dist/src/worker/index.js +24 -34
  246. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  247. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  248. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  249. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  250. package/dist/src/worker/shim.d.ts +4 -0
  251. package/dist/src/worker/shim.js +7 -0
  252. package/dist/src/worker/start.d.ts +9 -0
  253. package/dist/src/worker/start.js +16 -0
  254. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  255. package/dist/src/worker/unbundled-shim.js +4 -0
  256. package/docs/system-resources-support-matrix.md +27 -19
  257. package/package.json +91 -74
  258. package/src/electron-forge/index.cjs +65 -91
  259. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  260. package/dist/examples/model-fit-ui/server.js +0 -221
  261. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  262. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  263. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  264. package/dist/src/client/rpc/init-timeout.js +0 -25
  265. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  266. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  267. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  268. package/dist/src/commands/bundle/bare-pack.js +0 -77
  269. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  270. package/dist/src/commands/bundle/manifest.js +0 -192
  271. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  272. package/dist/src/expo/plugins/link-addons.js +0 -65
  273. package/dist/src/pear/pre.d.ts +0 -21
  274. package/dist/src/pear/pre.js +0 -448
  275. package/dist/src/server/env.d.ts +0 -22
  276. package/dist/src/server/env.js +0 -59
  277. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  278. package/dist/src/server/utils/qvac-paths.js +0 -5
  279. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  280. package/dist/src/server/utils/worker-lock.js +0 -67
  281. package/dist/src/worker/create-server.d.ts +0 -8
  282. package/dist/src/worker/create-server.js +0 -51
  283. package/dist/src/worker/lifecycle.d.ts +0 -23
  284. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,201 +1,153 @@
1
1
  import { promises as fsp } from 'node:fs';
2
+ import { createRequire } from 'node:module';
2
3
  import path from 'node:path';
3
- import semver from 'semver';
4
- import { BARE_KIT_BARE_VERSIONS, REACT_NATIVE_BARE_KIT_RUNTIMES } from './bare-kit-runtimes.js';
4
+ import { BARE_KIT_BARE_VERSIONS, BARE_KIT_KOTLIN_BARE_KITS, BARE_KIT_KOTLIN_WITHOUT_BARE_KIT, BARE_KIT_SWIFT_BARE_KITS, BARE_KIT_SWIFT_WITHOUT_BARE_KIT, BARE_KIT_WITHOUT_BARE } from '../../commands/verify/bare-kit-runtimes.js';
5
5
  import { findInAncestorNodeModules } from '../../expo/plugins/find-in-ancestor-node-modules.js';
6
6
  export const REACT_NATIVE_BARE_KIT = 'react-native-bare-kit';
7
7
  export const NETWORK_TIMEOUT_MS = 5000;
8
8
  const RAW_GITHUB_BASE = 'https://raw.githubusercontent.com/holepunchto';
9
- /**
10
- * The iOS framework ships inside the npm package, and its bundle version is
11
- * the bare-kit release it was built from, so it identifies the embedded
12
- * runtime without a network request.
13
- */
14
- const BARE_KIT_INFO_PLIST = path.join('ios', 'BareKit.xcframework', 'ios-arm64', 'BareKit.framework', 'Info.plist');
9
+ /** The bare-stow file that pins the Bare Kit bindings phone apps link. */
10
+ const BARE_KIT_TARGET = path.join('lib', 'target', 'bare-kit.js');
11
+ export const BARE_KIT_PLATFORMS = ['android', 'ios'];
12
+ const BINDINGS = {
13
+ android: {
14
+ name: 'bare-kit-kotlin',
15
+ bareKits: BARE_KIT_KOTLIN_BARE_KITS,
16
+ withoutBareKit: BARE_KIT_KOTLIN_WITHOUT_BARE_KIT,
17
+ pin: /['"]com\.github\.holepunchto\.bare-kit-kotlin:bare-kit-kotlin['"]\s*:\s*['"]v?(\d+\.\d+\.\d+[^'"\s]*)['"]/
18
+ },
19
+ ios: {
20
+ name: 'bare-kit-swift',
21
+ bareKits: BARE_KIT_SWIFT_BARE_KITS,
22
+ withoutBareKit: BARE_KIT_SWIFT_WITHOUT_BARE_KIT,
23
+ pin: /['"]https:\/\/github\.com\/holepunchto\/bare-kit-swift(?:\.git)?['"]\s*,\s*from\s*:\s*['"]v?(\d+\.\d+\.\d+[^'"\s]*)['"]/
24
+ }
25
+ };
15
26
  export function isReactNativeBareKitInstalled(projectRoot) {
16
27
  return findInAncestorNodeModules(projectRoot, REACT_NATIVE_BARE_KIT) !== null;
17
28
  }
29
+ export function bareKitPlatformOf(host) {
30
+ if (host.startsWith('android-'))
31
+ return 'android';
32
+ if (host.startsWith('ios-'))
33
+ return 'ios';
34
+ return null;
35
+ }
18
36
  export async function fetchText(url) {
19
37
  const response = await fetch(url, { signal: AbortSignal.timeout(NETWORK_TIMEOUT_MS) });
20
38
  if (!response.ok)
21
39
  throw new Error(`GET ${url} returned HTTP ${response.status}`);
22
40
  return response.text();
23
41
  }
24
- export function parseBareKitReleaseVersion(cmakeLists) {
25
- const match = /holepunchto\/bare-kit\/releases\/download\/v(\d+\.\d+\.\d+[^/"\s]*)\//.exec(cmakeLists);
26
- return match?.[1] ?? null;
27
- }
28
42
  export function parseBareVersion(cmakeLists) {
29
43
  const match = /fetch_package\(\s*"github:holepunchto\/bare@(\d+\.\d+\.\d+[^"\s]*)"/.exec(cmakeLists);
30
44
  return match?.[1] ?? null;
31
45
  }
32
- export function parseInfoPlistVersion(plist) {
33
- const match = /<key>CFBundleShortVersionString<\/key>\s*<string>(\d+\.\d+\.\d+[^<]*)<\/string>/.exec(plist);
46
+ export function parseBareKitVersion(cmakeLists) {
47
+ const match = /fetch_package\(\s*"github:holepunchto\/bare-kit@(\d+\.\d+\.\d+[^"\s]*)"/.exec(cmakeLists);
34
48
  return match?.[1] ?? null;
35
49
  }
36
- export async function fetchBareKitVersionFromGitHub(reactNativeBareKitVersion, fetch = fetchText) {
37
- const cmakeLists = await fetch(`${RAW_GITHUB_BASE}/${REACT_NATIVE_BARE_KIT}/v${reactNativeBareKitVersion}/CMakeLists.txt`);
38
- return parseBareKitReleaseVersion(cmakeLists);
50
+ /** The binding version bare-stow pins for each platform, or null where none is found. */
51
+ export function parseBareKitPins(source) {
52
+ return {
53
+ android: BINDINGS.android.pin.exec(source)?.[1] ?? null,
54
+ ios: BINDINGS.ios.pin.exec(source)?.[1] ?? null
55
+ };
56
+ }
57
+ export async function fetchBindingBareKitFromGitHub(binding, version, fetch = fetchText) {
58
+ const cmakeLists = await fetch(`${RAW_GITHUB_BASE}/${binding}/v${version}/CMakeLists.txt`);
59
+ return parseBareKitVersion(cmakeLists);
39
60
  }
40
61
  export async function fetchBareVersionFromGitHub(bareKitVersion, fetch = fetchText) {
41
62
  const cmakeLists = await fetch(`${RAW_GITHUB_BASE}/bare-kit/v${bareKitVersion}/CMakeLists.txt`);
42
63
  return parseBareVersion(cmakeLists);
43
64
  }
44
- export function bareVersionForBareKit(bareKitVersion) {
45
- return BARE_KIT_BARE_VERSIONS[bareKitVersion] ?? null;
65
+ /** The bare-stow of the project's `@qvac/sdk`, which bundles its app, else this SDK's. */
66
+ function resolveBareStowDir(projectRoot) {
67
+ const projectSdk = projectRoot === undefined ? null : findInAncestorNodeModules(projectRoot, '@qvac/sdk');
68
+ const from = projectSdk ? path.join(projectSdk, 'package.json') : import.meta.url;
69
+ return path.dirname(createRequire(from).resolve('bare-stow/package'));
46
70
  }
47
- function newestKey(record) {
48
- const versions = Object.keys(record).filter((version) => semver.valid(version) !== null);
49
- return versions.length === 0 ? null : versions.sort(semver.rcompare)[0];
71
+ function unresolved(reason, triedPaths) {
72
+ return { resolved: false, error: { reason, triedPaths } };
50
73
  }
51
- /**
52
- * The table generator has already probed every release up to the newest
53
- * entry, so only newer releases can have data on GitHub that the table lacks.
54
- */
55
- function isNewerThanTable(version, record) {
56
- const newest = newestKey(record);
57
- return newest === null || semver.valid(version) === null || semver.gt(version, newest);
58
- }
59
- /**
60
- * The oldest react-native-bare-kit release newer than `currentVersion` whose
61
- * embedded Bare satisfies every range, or null if the table has none.
62
- */
63
- export function findReactNativeBareKitUpgrade(currentVersion, ranges) {
64
- const candidates = Object.entries(REACT_NATIVE_BARE_KIT_RUNTIMES)
65
- .filter(([version]) => semver.valid(version) !== null && semver.prerelease(version) === null)
66
- .sort(([a], [b]) => semver.compare(a, b));
67
- for (const [version, runtime] of candidates) {
68
- if (semver.valid(currentVersion) !== null && !semver.gt(version, currentVersion))
69
- continue;
70
- if (ranges.every((range) => semver.satisfies(runtime.bare, range))) {
71
- return { version, bareKit: runtime.bareKit, bare: runtime.bare };
72
- }
73
- }
74
- return null;
75
- }
76
- async function readJsonVersion(packageJsonPath) {
77
- try {
78
- const parsed = JSON.parse(await fsp.readFile(packageJsonPath, 'utf8'));
79
- return typeof parsed.version === 'string' ? parsed.version : null;
80
- }
81
- catch {
82
- return null;
83
- }
84
- }
85
- async function readInfoPlistVersion(packageDir) {
86
- try {
87
- return parseInfoPlistVersion(await fsp.readFile(path.join(packageDir, BARE_KIT_INFO_PLIST), 'utf8'));
88
- }
89
- catch {
90
- return null;
91
- }
92
- }
93
- function resolved(version, reactNativeBareKitVersion, bareKitVersion, via) {
74
+ function resolved(platform, bare, version, bareKit, viaGitHub) {
75
+ const binding = BINDINGS[platform].name;
94
76
  return {
95
77
  resolved: true,
96
78
  runtime: {
97
- version,
98
- source: 'react-native-bare-kit',
99
- packageVersion: reactNativeBareKitVersion,
100
- detail: `react-native-bare-kit@${reactNativeBareKitVersion} embeds bare-kit ${bareKitVersion}` +
101
- (via === 'github' ? ', looked up on GitHub' : '')
79
+ version: bare,
80
+ source: binding,
81
+ packageVersion: version,
82
+ detail: `bare-stow pins ${binding} ${version}, built from bare-kit ${bareKit}` +
83
+ (viaGitHub ? ', looked up on GitHub' : '')
102
84
  }
103
85
  };
104
86
  }
105
87
  /**
106
- * Bare version the app runs on mobile: the one compiled into the bare-kit
107
- * binaries that react-native-bare-kit ships, not any `bare-runtime` package
108
- * in node_modules.
88
+ * Bare version a phone platform runs: the one in the bare-kit that the Bare
89
+ * Kit binding pinned by the SDK's bare-stow is built from. Android links
90
+ * bare-kit-kotlin at an exact version. bare-stow names a minimum
91
+ * bare-kit-swift, which the link step writes into the app as an exact version.
109
92
  *
110
- * Checks the built-in table, then the installed iOS framework's Info.plist,
111
- * and only then GitHub.
93
+ * Checks the built-in tables, and only then GitHub.
112
94
  */
113
- export async function resolveMobileBareRuntime(options) {
114
- const { projectRoot, network = true, onProgress, fetchText: fetch = fetchText } = options;
115
- const packageDir = findInAncestorNodeModules(projectRoot, REACT_NATIVE_BARE_KIT);
116
- if (packageDir === null) {
117
- return {
118
- resolved: false,
119
- error: {
120
- reason: `${REACT_NATIVE_BARE_KIT} is not installed, so the mobile Bare version is unknown`,
121
- triedPaths: [path.join(projectRoot, 'node_modules', REACT_NATIVE_BARE_KIT)]
122
- }
123
- };
95
+ export async function resolveBareKitRuntime(options) {
96
+ const { platform, network = true, onProgress, fetchText: fetch = fetchText } = options;
97
+ const binding = BINDINGS[platform];
98
+ let bareStowDir;
99
+ try {
100
+ bareStowDir = options.bareStowDir ?? resolveBareStowDir(options.projectRoot);
124
101
  }
125
- const packageJsonPath = path.join(packageDir, 'package.json');
126
- const version = await readJsonVersion(packageJsonPath);
102
+ catch (error) {
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ return unresolved(`bare-stow could not be resolved from the SDK, so the ${platform} Bare version is unknown: ${message}`, []);
105
+ }
106
+ const targetPath = path.join(bareStowDir, BARE_KIT_TARGET);
107
+ let source;
108
+ try {
109
+ source = await fsp.readFile(targetPath, 'utf8');
110
+ }
111
+ catch {
112
+ return unresolved(`Could not read ${targetPath}, so the ${platform} Bare version is unknown`, [
113
+ targetPath
114
+ ]);
115
+ }
116
+ const version = parseBareKitPins(source)[platform];
127
117
  if (version === null) {
128
- return {
129
- resolved: false,
130
- error: {
131
- reason: `Could not read the version of ${REACT_NATIVE_BARE_KIT}`,
132
- triedPaths: [packageJsonPath]
133
- }
134
- };
118
+ return unresolved(`${targetPath} pins no ${binding.name} version, so the ${platform} Bare version is unknown`, [targetPath]);
135
119
  }
136
- const known = REACT_NATIVE_BARE_KIT_RUNTIMES[version];
137
- if (known !== undefined)
138
- return resolved(known.bare, version, known.bareKit, 'table');
139
- let bareKitVersion = await readInfoPlistVersion(packageDir);
140
- if (bareKitVersion !== null) {
141
- const bare = bareVersionForBareKit(bareKitVersion);
142
- if (bare !== null)
143
- return resolved(bare, version, bareKitVersion, 'info-plist');
120
+ const tableBareKit = binding.bareKits[version] ?? null;
121
+ const tableBare = tableBareKit === null ? null : (BARE_KIT_BARE_VERSIONS[tableBareKit] ?? null);
122
+ if (tableBareKit !== null && tableBare !== null) {
123
+ return resolved(platform, tableBare, version, tableBareKit, false);
144
124
  }
145
- const canLookUp = bareKitVersion === null
146
- ? isNewerThanTable(version, REACT_NATIVE_BARE_KIT_RUNTIMES)
147
- : isNewerThanTable(bareKitVersion, BARE_KIT_BARE_VERSIONS);
148
- if (!canLookUp) {
149
- return {
150
- resolved: false,
151
- error: {
152
- reason: `The Bare version of ${REACT_NATIVE_BARE_KIT}@${version} could not be determined: ` +
153
- (bareKitVersion === null
154
- ? 'the release does not record its bare-kit version and its iOS framework Info.plist could not be read'
155
- : `bare-kit ${bareKitVersion} does not name its Bare version in CMakeLists.txt`),
156
- triedPaths: [packageJsonPath, path.join(packageDir, BARE_KIT_INFO_PLIST)]
157
- }
158
- };
125
+ const checkedWithoutVersion = tableBareKit === null
126
+ ? binding.withoutBareKit.includes(version)
127
+ : BARE_KIT_WITHOUT_BARE.includes(tableBareKit);
128
+ if (checkedWithoutVersion) {
129
+ return unresolved(`The Bare version of ${binding.name}@${version} could not be determined: ` +
130
+ (tableBareKit === null
131
+ ? 'its CMakeLists.txt names no bare-kit version'
132
+ : `bare-kit ${tableBareKit} does not name its Bare version in CMakeLists.txt`), [targetPath]);
159
133
  }
160
134
  if (!network) {
161
- return {
162
- resolved: false,
163
- error: {
164
- reason: `${REACT_NATIVE_BARE_KIT}@${version} is not in the built-in runtime table ` +
165
- 'and network lookups are disabled',
166
- triedPaths: [packageJsonPath]
167
- }
168
- };
135
+ return unresolved(`${tableBareKit === null ? `${binding.name}@${version}` : `bare-kit ${tableBareKit}`} ` +
136
+ 'is not in the built-in runtime table and network lookups are disabled', [targetPath]);
169
137
  }
170
- onProgress?.(`Looking up the Bare version embedded in ${REACT_NATIVE_BARE_KIT}@${version} on ` +
171
- `raw.githubusercontent.com (not in the built-in table, timeout ${NETWORK_TIMEOUT_MS / 1000}s per request)...`);
138
+ onProgress?.(`Looking up the Bare version of ${binding.name}@${version} on raw.githubusercontent.com ` +
139
+ `(not in the built-in table, timeout ${NETWORK_TIMEOUT_MS / 1000}s per request)...`);
172
140
  try {
173
- if (bareKitVersion === null) {
174
- bareKitVersion = await fetchBareKitVersionFromGitHub(version, fetch);
175
- }
176
- const bare = bareKitVersion === null
141
+ const bareKit = tableBareKit ?? (await fetchBindingBareKitFromGitHub(binding.name, version, fetch));
142
+ const bare = bareKit === null
177
143
  ? null
178
- : (bareVersionForBareKit(bareKitVersion) ??
179
- (await fetchBareVersionFromGitHub(bareKitVersion, fetch)));
180
- if (bareKitVersion !== null && bare !== null) {
181
- return resolved(bare, version, bareKitVersion, 'github');
182
- }
183
- return {
184
- resolved: false,
185
- error: {
186
- reason: `Could not find the bare-kit or Bare version in the CMakeLists.txt of ${REACT_NATIVE_BARE_KIT}@${version}`,
187
- triedPaths: [packageJsonPath]
188
- }
189
- };
144
+ : (BARE_KIT_BARE_VERSIONS[bareKit] ?? (await fetchBareVersionFromGitHub(bareKit, fetch)));
145
+ if (bareKit !== null && bare !== null)
146
+ return resolved(platform, bare, version, bareKit, true);
147
+ return unresolved(`Could not find the bare-kit or Bare version in the CMakeLists.txt of ${binding.name}@${version}`, [targetPath]);
190
148
  }
191
149
  catch (error) {
192
150
  const message = error instanceof Error ? error.message : String(error);
193
- return {
194
- resolved: false,
195
- error: {
196
- reason: `Could not look up the Bare version of ${REACT_NATIVE_BARE_KIT}@${version}: ${message}`,
197
- triedPaths: [packageJsonPath]
198
- }
199
- };
151
+ return unresolved(`Could not look up the Bare version of ${binding.name}@${version}: ${message}`, [targetPath]);
200
152
  }
201
153
  }
@@ -1,12 +1,13 @@
1
- export interface BareKitRuntime {
2
- bareKit: string;
3
- bare: string;
4
- }
5
- /**
6
- * react-native-bare-kit releases whose CMakeLists.txt names the bare-kit
7
- * prebuilds it ships. Older releases carry no such reference.
8
- */
9
- export declare const REACT_NATIVE_BARE_KIT_RUNTIMES: Record<string, BareKitRuntime>;
1
+ /** bare-kit release each bare-kit-kotlin release is built from. */
2
+ export declare const BARE_KIT_KOTLIN_BARE_KITS: Record<string, string>;
3
+ /** bare-kit-kotlin releases whose CMakeLists.txt names no bare-kit version. */
4
+ export declare const BARE_KIT_KOTLIN_WITHOUT_BARE_KIT: string[];
5
+ /** bare-kit release each bare-kit-swift release is built from. */
6
+ export declare const BARE_KIT_SWIFT_BARE_KITS: Record<string, string>;
7
+ /** bare-kit-swift releases whose CMakeLists.txt names no bare-kit version. */
8
+ export declare const BARE_KIT_SWIFT_WITHOUT_BARE_KIT: string[];
10
9
  /** Bare version each bare-kit release is built against. */
11
10
  export declare const BARE_KIT_BARE_VERSIONS: Record<string, string>;
11
+ /** bare-kit releases whose CMakeLists.txt names no Bare version. */
12
+ export declare const BARE_KIT_WITHOUT_BARE: string[];
12
13
  //# sourceMappingURL=bare-kit-runtimes.d.ts.map
@@ -1,25 +1,21 @@
1
1
  // Generated by scripts/generate-bare-kit-runtimes.ts. Do not edit by hand.
2
- /**
3
- * react-native-bare-kit releases whose CMakeLists.txt names the bare-kit
4
- * prebuilds it ships. Older releases carry no such reference.
5
- */
6
- export const REACT_NATIVE_BARE_KIT_RUNTIMES = {
7
- '0.13.3': { bareKit: '2.0.2', bare: '1.28.1' },
8
- '0.14.0': { bareKit: '2.1.0', bare: '1.28.1' },
9
- '0.14.1': { bareKit: '2.1.1', bare: '1.28.1' },
10
- '0.14.2': { bareKit: '2.1.2', bare: '1.28.6' },
11
- '0.14.3': { bareKit: '2.1.3', bare: '1.28.6' },
12
- '0.14.4': { bareKit: '2.2.0', bare: '1.29.3' },
13
- '0.14.5': { bareKit: '2.2.1', bare: '1.29.4' },
14
- '0.15.0': { bareKit: '2.3.0', bare: '1.29.4' },
15
- '0.15.1': { bareKit: '2.5.0', bare: '1.33.1' },
16
- '0.15.2': { bareKit: '2.5.0', bare: '1.33.1' },
17
- '0.15.3': { bareKit: '2.5.1', bare: '1.33.2' },
18
- '0.15.4': { bareKit: '2.5.3', bare: '1.33.3' },
19
- '0.15.5': { bareKit: '2.5.4', bare: '1.33.4' },
20
- '0.15.6': { bareKit: '2.5.4', bare: '1.33.4' },
21
- '0.16.0': { bareKit: '2.5.4', bare: '1.33.4' }
2
+ /** bare-kit release each bare-kit-kotlin release is built from. */
3
+ export const BARE_KIT_KOTLIN_BARE_KITS = {
4
+ '0.1.2': '3.0.1',
5
+ '0.2.0': '3.0.1',
6
+ '0.2.1': '3.0.1',
7
+ '0.2.2': '3.0.1'
22
8
  };
9
+ /** bare-kit-kotlin releases whose CMakeLists.txt names no bare-kit version. */
10
+ export const BARE_KIT_KOTLIN_WITHOUT_BARE_KIT = [];
11
+ /** bare-kit release each bare-kit-swift release is built from. */
12
+ export const BARE_KIT_SWIFT_BARE_KITS = {
13
+ '2.0.0': '3.0.1',
14
+ '2.1.0': '3.0.1',
15
+ '2.2.0': '3.0.1'
16
+ };
17
+ /** bare-kit-swift releases whose CMakeLists.txt names no bare-kit version. */
18
+ export const BARE_KIT_SWIFT_WITHOUT_BARE_KIT = [];
23
19
  /** Bare version each bare-kit release is built against. */
24
20
  export const BARE_KIT_BARE_VERSIONS = {
25
21
  '1.0.0': '1.12.2',
@@ -105,5 +101,9 @@ export const BARE_KIT_BARE_VERSIONS = {
105
101
  '2.5.2': '1.33.3',
106
102
  '2.5.3': '1.33.3',
107
103
  '2.5.4': '1.33.4',
108
- '2.5.5': '1.33.4'
104
+ '2.5.5': '1.33.4',
105
+ '3.0.0': '1.36.1',
106
+ '3.0.1': '1.36.2'
109
107
  };
108
+ /** bare-kit releases whose CMakeLists.txt names no Bare version. */
109
+ export const BARE_KIT_WITHOUT_BARE = [];
@@ -1,4 +1,4 @@
1
- import { type CollectDiagnostics, type NativeAddon } from './addon-source.js';
1
+ import { type CollectDiagnostics, type NativeAddon } from '../../commands/verify/addon-source.js';
2
2
  export declare class InvalidBundleSourceError extends Error {
3
3
  bundlePath: string;
4
4
  constructor(bundlePath: string, cause: unknown);
@@ -1,10 +1,17 @@
1
- import { promises as fsp } from 'node:fs';
2
1
  import path from 'node:path';
3
- import { DEFAULT_HOSTS } from '../bundle/constants.js';
4
- import { buildNestedPathIndex, extractBarePackHeader, extractPackedString } from '../bundle/manifest.js';
5
- import { createLimiter, deduplicateAddons, FS_CONCURRENCY, readAddonPackageJson } from './addon-source.js';
2
+ import { DEFAULT_HOSTS } from '../../commands/bundle/constants.js';
3
+ import { buildNestedPathIndex } from '../../commands/bundle/addons.js';
4
+ import { bundleRoot, readBundle } from '../../commands/bundle/read-bundle.js';
5
+ import { createLimiter, deduplicateAddons, FS_CONCURRENCY, readAddonPackageJson } from '../../commands/verify/addon-source.js';
6
6
  /** bare-pack resolves a linked native addon to this prefix instead of a module path. */
7
7
  const LINKED_PREFIX = 'linked:';
8
+ /**
9
+ * Condition naming the addon a `require.addon()` specifier loads. An offloading
10
+ * target such as bare-stow's `bare-sidecar` points it at the binary beside the
11
+ * bundle (`/../index.bundle.d/...`), or at `deferred:` when the package keeps no
12
+ * binary of its own, as split addons do.
13
+ */
14
+ const ADDON_KEY = 'addon';
8
15
  /** Reserved resolution key naming the package.json that owns a module. */
9
16
  const PACKAGE_KEY = '#package';
10
17
  /** Export conditions that name a platform. */
@@ -19,43 +26,34 @@ export class InvalidBundleSourceError extends Error {
19
26
  const reason = cause instanceof Error ? cause.message : String(cause);
20
27
  super(`Bundle at ${bundlePath} could not be parsed as a bare-pack bundle.\n\n` +
21
28
  ` Reason: ${reason}\n\n` +
22
- ' Make sure the path points to a worker.bundle.js generated by bundleSdk.');
29
+ ' Make sure the path points to a bundle generated by bundleSdk.');
23
30
  this.name = 'InvalidBundleSourceError';
24
31
  this.bundlePath = bundlePath;
25
32
  }
26
33
  }
27
34
  export async function collectAddonsFromBundle(options) {
28
35
  const { bundlePath, projectRoot, hosts, diagnostics } = options;
29
- let bundleText;
30
- try {
31
- bundleText = await fsp.readFile(bundlePath, 'utf8');
32
- }
33
- catch (error) {
34
- throw new InvalidBundleSourceError(bundlePath, error);
35
- }
36
- let resolutions;
37
- let main;
38
- let imports;
36
+ let bundle;
39
37
  try {
40
- const packed = extractPackedString(bundleText);
41
- const header = extractBarePackHeader(packed);
42
- resolutions = header.resolutions ?? {};
43
- main = header.main;
44
- imports = header.imports ?? {};
38
+ bundle = await readBundle(bundlePath);
45
39
  }
46
40
  catch (error) {
47
41
  throw new InvalidBundleSourceError(bundlePath, error);
48
42
  }
43
+ const resolutions = bundle.resolutions;
44
+ const main = bundle.main ?? undefined;
45
+ const imports = bundle.imports;
49
46
  if (diagnostics !== undefined && Object.keys(resolutions).length === 0) {
50
47
  diagnostics.emptyResolutions = true;
51
48
  }
52
- const pathsByPackage = buildNestedPathIndex(resolutions, projectRoot);
49
+ const root = bundleRoot(main, projectRoot);
50
+ const pathsByPackage = buildNestedPathIndex(resolutions, root);
53
51
  const analysed = analyseLinkedHosts({
54
52
  resolutions,
55
53
  main,
56
54
  imports,
57
55
  hosts: hosts ?? [],
58
- projectRoot,
56
+ projectRoot: root,
59
57
  pathsByPackage
60
58
  });
61
59
  const limit = createLimiter(FS_CONCURRENCY);
@@ -99,7 +97,7 @@ function analyseLinkedHosts(options) {
99
97
  /**
100
98
  * Which of `hosts` link each package's addon, keyed by the owning package.json.
101
99
  * A host counts only when the bundle both reaches a module of that package on
102
- * its platform *and* resolves a `linked:` addon there.
100
+ * its platform *and* resolves an addon there, `linked:` or through `addon`.
103
101
  *
104
102
  * Both halves are needed because bare-pack emits two graph shapes: for a single
105
103
  * host it resolves conditions eagerly, dropping the binding module of a package
@@ -159,6 +157,12 @@ function linkedOwnersOn(resolutions, main, platform, projectRoot) {
159
157
  for (const [specifier, target] of Object.entries(edges)) {
160
158
  if (specifier === PACKAGE_KEY)
161
159
  continue;
160
+ const addon = asRecord(target)?.[ADDON_KEY];
161
+ if (addon !== undefined) {
162
+ if (targetsOn(addon, platform).length > 0)
163
+ linksAddon = true;
164
+ continue;
165
+ }
162
166
  for (const resolved of targetsOn(target, platform)) {
163
167
  if (resolved.startsWith(LINKED_PREFIX))
164
168
  linksAddon = true;
@@ -1,7 +1,7 @@
1
- import { type PackageManagerName } from '../host-prebuilds/package-manager.js';
2
- import { type BareRuntime } from './abi.js';
3
- import type { PackageRecord } from './addon-source.js';
4
- import { type ProgressFn } from './bare-kit-runtime.js';
1
+ import { type PackageManagerName } from '../../commands/host-prebuilds/package-manager.js';
2
+ import { type BareRuntime } from '../../commands/verify/abi.js';
3
+ import type { PackageRecord } from '../../commands/verify/addon-source.js';
4
+ import { type ProgressFn } from '../../commands/verify/bare-kit-runtime.js';
5
5
  export interface EnginesFailure {
6
6
  name: string;
7
7
  version?: string;
@@ -25,18 +25,12 @@ export interface EnginesOverride {
25
25
  lookupSkipped?: boolean;
26
26
  lookupError?: string;
27
27
  }
28
- export interface EnginesUpgrade {
29
- packageName: string;
30
- from: string;
31
- to: string;
32
- bare: string;
33
- }
28
+ /** How to fix the packages that fail one phone platform's runtime. */
34
29
  export interface EnginesAdvice {
35
30
  hosts: string[];
36
31
  runtime: BareRuntime;
32
+ /** Lowest Bare that satisfies every failing engines.bare. */
37
33
  requiredBare: string;
38
- upgrade: EnginesUpgrade | null;
39
- upgradeHint: string;
40
34
  overrides: EnginesOverride[];
41
35
  packageManager: PackageManagerName | null;
42
36
  }
@@ -1,8 +1,7 @@
1
1
  import semver from 'semver';
2
- import { detectPackageManager } from '../host-prebuilds/package-manager.js';
3
- import { formatRuntimeSource } from './abi.js';
4
- import { findReactNativeBareKitUpgrade, NETWORK_TIMEOUT_MS, REACT_NATIVE_BARE_KIT } from './bare-kit-runtime.js';
5
- import { REACT_NATIVE_BARE_KIT_RUNTIMES } from './bare-kit-runtimes.js';
2
+ import { detectPackageManager } from '../../commands/host-prebuilds/package-manager.js';
3
+ import { formatRuntimeSource } from '../../commands/verify/abi.js';
4
+ import { NETWORK_TIMEOUT_MS } from '../../commands/verify/bare-kit-runtime.js';
6
5
  const REGISTRY_URL = 'https://registry.npmjs.org';
7
6
  /** The registry's abbreviated metadata lists `engines` per version at a fraction of the full size. */
8
7
  const ABBREVIATED_METADATA_TYPE = 'application/vnd.npm.install-v1+json';
@@ -122,48 +121,6 @@ function requiredBareVersion(ranges) {
122
121
  }
123
122
  return required ?? 'unknown';
124
123
  }
125
- function newestTableEntry() {
126
- const versions = Object.keys(REACT_NATIVE_BARE_KIT_RUNTIMES).sort(semver.rcompare);
127
- const newest = versions[0];
128
- return newest === undefined
129
- ? null
130
- : { version: newest, ...REACT_NATIVE_BARE_KIT_RUNTIMES[newest] };
131
- }
132
- function buildUpgrade(runtime, ranges, requiredBare) {
133
- if (runtime.source === 'react-native-bare-kit' && runtime.packageVersion !== undefined) {
134
- const target = findReactNativeBareKitUpgrade(runtime.packageVersion, ranges);
135
- if (target !== null) {
136
- return {
137
- upgrade: {
138
- packageName: REACT_NATIVE_BARE_KIT,
139
- from: runtime.packageVersion,
140
- to: target.version,
141
- bare: target.bare
142
- },
143
- upgradeHint: `Upgrade ${REACT_NATIVE_BARE_KIT} to ${target.version} or newer ` +
144
- `(embeds bare-kit ${target.bareKit}, Bare ${target.bare}).`
145
- };
146
- }
147
- const newest = newestTableEntry();
148
- return {
149
- upgrade: null,
150
- upgradeHint: `No ${REACT_NATIVE_BARE_KIT} release in the built-in table embeds Bare ${requiredBare} or newer` +
151
- (newest === null
152
- ? '.'
153
- : `; the newest known, ${newest.version}, embeds Bare ${newest.bare}. Check for a newer release.`)
154
- };
155
- }
156
- if (runtime.source === 'bare-runtime' || runtime.source === 'bare') {
157
- return {
158
- upgrade: null,
159
- upgradeHint: `Upgrade ${runtime.source} to ${requiredBare} or newer.`
160
- };
161
- }
162
- return {
163
- upgrade: null,
164
- upgradeHint: `The runtime version comes from ${runtime.source}; raise it to ${requiredBare} or newer if the target runtime allows it.`
165
- };
166
- }
167
124
  export async function buildEnginesAdvice(options) {
168
125
  const { projectRoot, hosts, runtime, failures, packages, network = true, onProgress, fetchPackageMetadata: fetchOne = fetchPackageMetadata } = options;
169
126
  const grouped = groupFailures(failures);
@@ -215,7 +172,6 @@ export async function buildEnginesAdvice(options) {
215
172
  hosts,
216
173
  runtime,
217
174
  requiredBare,
218
- ...buildUpgrade(runtime, allRanges, requiredBare),
219
175
  overrides,
220
176
  packageManager
221
177
  };
@@ -230,13 +186,12 @@ export function formatEnginesAdvice(advice) {
230
186
  const lines = [
231
187
  ` Fix for ${advice.hosts.join(', ')}:`,
232
188
  ` Runtime: Bare ${advice.runtime.version} (from ${formatRuntimeSource(advice.runtime)})`,
233
- ...advice.overrides.map((override) => ` Requires: ${override.name}@${override.installedVersions.join(', ') || 'unknown'} needs Bare ${override.enginesBare.join(' and ')}`),
234
- ` Option 1: ${advice.upgradeHint}`
189
+ ...advice.overrides.map((override) => ` Requires: ${override.name}@${override.installedVersions.join(', ') || 'unknown'} needs Bare ${override.enginesBare.join(' and ')}`)
235
190
  ];
236
191
  for (const override of advice.overrides) {
237
192
  const installed = override.installedVersions.join(', ') || 'unknown';
238
193
  if (override.lookupSkipped === true) {
239
- lines.push(` Option 2 (${override.name}): pin an older release; run again with network lookups ` +
194
+ lines.push(` Override (${override.name}): pin an older release; run again with network lookups ` +
240
195
  'enabled (without --offline) to find one that runs on this Bare.');
241
196
  continue;
242
197
  }
@@ -244,16 +199,14 @@ export function formatEnginesAdvice(advice) {
244
199
  const acceptedBy = override.parents.length === 0
245
200
  ? ` on the ${installed} release line`
246
201
  : ` that ${override.parents.map((p) => `${p.name} (${p.range})`).join(', ')} accept${override.parents.length === 1 ? 's' : ''}`;
247
- lines.push(` Option 2 (${override.name}): no release that runs on Bare ${advice.runtime.version}${acceptedBy} was found` +
248
- (override.lookupError === undefined
249
- ? '; upgrade the runtime.'
250
- : ` (${override.lookupError}).`));
202
+ lines.push(` Override (${override.name}): no release that runs on Bare ${advice.runtime.version}${acceptedBy} was found` +
203
+ (override.lookupError === undefined ? '.' : ` (${override.lookupError}).`));
251
204
  continue;
252
205
  }
253
206
  const field = advice.packageManager === null
254
207
  ? '"overrides" (npm/bun), "pnpm.overrides" or "resolutions" (yarn)'
255
208
  : MANIFEST_FIELD[advice.packageManager];
256
- lines.push(` Option 2 (${override.name}): pin ${installed} -> ${override.version} with ${field} in your app's package.json:`);
209
+ lines.push(` Override (${override.name}): pin ${installed} -> ${override.version} with ${field} in your app's package.json:`);
257
210
  for (const line of (override.snippet ?? '').split('\n'))
258
211
  lines.push(` ${line}`);
259
212
  const rejected = override.parents.filter((parent) => !parent.satisfied);
@@ -266,6 +219,6 @@ export function formatEnginesAdvice(advice) {
266
219
  lines.push(' bun applies overrides to every copy in the tree.');
267
220
  }
268
221
  }
269
- lines.push('');
222
+ lines.push(` Or: use an @qvac/sdk release whose bare-stow pins a Bare Kit with Bare ${advice.requiredBare} or newer.`, '');
270
223
  return lines;
271
224
  }