peachsim 0.1.679 → 0.1.681

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 (84) hide show
  1. package/cli/commands/daemon-mac-app.ts +11 -2
  2. package/cli/commands/daemon.ts +2 -3
  3. package/cli/commands/swift.ts +40 -19
  4. package/cli/outbound-endpoints.ts +8 -0
  5. package/dist-lib/agent-daemon-client.cjs +1 -1
  6. package/dist-lib/agent-events.cjs +1 -1
  7. package/dist-lib/agent-identity.cjs +1 -1
  8. package/dist-lib/agent-sessions.cjs +1 -1
  9. package/dist-lib/attached-projects.cjs +1 -1
  10. package/dist-lib/auth/shared-session.cjs +1 -1
  11. package/dist-lib/backend-origin.cjs +1 -1
  12. package/dist-lib/beta.cjs +1 -1
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +1 -1
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/capture-contract.cjs +1 -1
  20. package/dist-lib/capture-contract.mjs +1 -1
  21. package/dist-lib/cli-constants.cjs +1 -1
  22. package/dist-lib/cloud-contract.cjs +1 -1
  23. package/dist-lib/cloud-contract.mjs +1 -1
  24. package/dist-lib/cloud-test-args.cjs +1 -1
  25. package/dist-lib/cloud-test-args.mjs +1 -1
  26. package/dist-lib/cloud.cjs +1 -1
  27. package/dist-lib/cloud.mjs +1 -1
  28. package/dist-lib/config.cjs +1 -1
  29. package/dist-lib/detox/index.cjs +1 -1
  30. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  31. package/dist-lib/home-paths.cjs +1 -1
  32. package/dist-lib/host/bridge-host.cjs +2548 -2327
  33. package/dist-lib/host/fetch-proxy-handler.cjs +5 -13
  34. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -6
  35. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -6
  36. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  37. package/dist-lib/host/websocket-proxy.cjs +1 -1
  38. package/dist-lib/index.cjs +1 -1
  39. package/dist-lib/jump-to-source-babel.cjs +1 -1
  40. package/dist-lib/jump-to-source-native.cjs +1 -1
  41. package/dist-lib/kotlin-host.cjs +1 -1
  42. package/dist-lib/menu.cjs +1 -1
  43. package/dist-lib/menu.mjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  46. package/dist-lib/metro-production-bundle.cjs +1 -1
  47. package/dist-lib/metro-production-bundle.mjs +1 -1
  48. package/dist-lib/metro.cjs +1 -1
  49. package/dist-lib/native-app-identity.cjs +1 -1
  50. package/dist-lib/native-app-identity.mjs +1 -1
  51. package/dist-lib/native-firebase-metadata.cjs +1 -1
  52. package/dist-lib/native-firebase-metadata.mjs +1 -1
  53. package/dist-lib/plist.cjs +1 -1
  54. package/dist-lib/plist.mjs +1 -1
  55. package/dist-lib/profiles.cjs +1 -1
  56. package/dist-lib/public-brand.cjs +1 -1
  57. package/dist-lib/react-native-host-modules.cjs +1 -1
  58. package/dist-lib/react-native-host-modules.mjs +1 -1
  59. package/dist-lib/render-mode.cjs +1 -1
  60. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  61. package/dist-lib/sdk.cjs +1 -1
  62. package/dist-lib/sdk.mjs +1 -1
  63. package/dist-lib/skills.cjs +2296 -2053
  64. package/dist-lib/swift-compile.cjs +78 -12
  65. package/dist-lib/swift-compile.mjs +76 -12
  66. package/dist-lib/swift-package.cjs +1 -1
  67. package/dist-lib/swift-package.mjs +1 -1
  68. package/dist-lib/swift-submit.cjs +1 -1
  69. package/dist-lib/swift-submit.mjs +1 -1
  70. package/dist-lib/swift-toolchain.cjs +115 -0
  71. package/dist-lib/swift.cjs +1 -1
  72. package/dist-lib/vite-swift.cjs +470 -149
  73. package/dist-lib/vite.cjs +1 -1
  74. package/package.json +7 -1
  75. package/skills/contrast/SKILL.md +1 -1
  76. package/src/expo-swift-host.ts +9 -13
  77. package/src/host/fetch-proxy-handler.ts +11 -10
  78. package/src/host/fetch-proxy-overrides.ts +9 -10
  79. package/src/swift-compile.ts +76 -10
  80. package/src/swift-distribution-contract.ts +138 -0
  81. package/src/swift-distribution.lock.json +20 -0
  82. package/src/swift-distribution.ts +108 -0
  83. package/src/swift-host.ts +8 -30
  84. package/src/swift-toolchain.ts +102 -0
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -38,7 +38,9 @@ __export(swift_compile_exports, {
38
38
  compileTargets: () => compileTargets,
39
39
  emitSwiftPackageManifest: () => emitSwiftPackageManifest,
40
40
  swiftArtifactHash: () => swiftArtifactHash,
41
+ swiftDistributionAt: () => swiftDistributionAt,
41
42
  swiftIcuAsset: () => swiftIcuAsset,
43
+ swiftModuleDigest: () => swiftModuleDigest,
42
44
  swiftModuleInputFiles: () => swiftModuleInputFiles,
43
45
  swiftSourceAsIOS: () => swiftSourceAsIOS,
44
46
  withNativeSourceGlue: () => withNativeSourceGlue,
@@ -52,6 +54,40 @@ var import_node_os = __toESM(require("node:os"), 1);
52
54
  var import_node_path2 = __toESM(require("node:path"), 1);
53
55
  var import_node_util2 = require("node:util");
54
56
 
57
+ // src/is-record.ts
58
+ function isRecord(value) {
59
+ return typeof value === "object" && value !== null && !Array.isArray(value);
60
+ }
61
+
62
+ // src/swift-distribution-contract.ts
63
+ var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
64
+ var SWIFT_DISTRIBUTION_HOSTS = [
65
+ "darwin-arm64",
66
+ "linux-x64",
67
+ "linux-arm64"
68
+ ];
69
+ var isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
70
+ function parseSwiftDistributionManifest(value) {
71
+ if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
72
+ throw new Error(`invalid Swift distribution ${SWIFT_DISTRIBUTION_MANIFEST}`);
73
+ }
74
+ const host2 = SWIFT_DISTRIBUTION_HOSTS.find((candidate) => candidate === value.host);
75
+ if (!host2) throw new Error(`Swift distribution names an unknown host ${value.host}`);
76
+ return {
77
+ id: value.id,
78
+ release: value.release,
79
+ wasmSdkChecksum: value.wasmSdkChecksum,
80
+ modules: value.modules,
81
+ objects: value.objects,
82
+ link: value.link,
83
+ files: Object.fromEntries(
84
+ Object.entries(value.files).map(([file, sha]) => [file, String(sha)])
85
+ ),
86
+ host: host2,
87
+ plugins: value.plugins
88
+ };
89
+ }
90
+
55
91
  // src/swift-icu.ts
56
92
  var import_node_child_process = require("node:child_process");
57
93
  var import_node_crypto = require("node:crypto");
@@ -216,7 +252,13 @@ var WASM_TRIPLE = "wasm32-unknown-wasip1";
216
252
  var cores = import_node_os.default.availableParallelism();
217
253
  var BUILD_ENV = { ...process.env, BINARYEN_CORES: String(Math.min(4, cores)) };
218
254
  var BUILD_JOBS = String(Math.max(1, Math.floor(cores / 2)));
255
+ function swiftDistributionAt(root) {
256
+ const file = import_node_path2.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
257
+ if (!(0, import_node_fs2.existsSync)(file)) return null;
258
+ return parseSwiftDistributionManifest(JSON.parse((0, import_node_fs2.readFileSync)(file, "utf8")));
259
+ }
219
260
  function swiftModuleInputFiles(root) {
261
+ if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
220
262
  const files = [
221
263
  "Package.swift",
222
264
  "scripts/contrast-app-Package.swift",
@@ -233,6 +275,9 @@ function swiftModuleInputFiles(root) {
233
275
  return files.sort();
234
276
  }
235
277
  async function ensureMacroPlugins(moduleRoot, toolchainBin) {
278
+ const distribution = swiftDistributionAt(moduleRoot);
279
+ if (distribution)
280
+ return distribution.plugins.map((plugin) => import_node_path2.default.join(moduleRoot, plugin));
236
281
  const dir = import_node_path2.default.join(moduleRoot, ".build/host/RnxPreviewMacros");
237
282
  const ext = process.platform === "darwin" ? "dylib" : "so";
238
283
  const plugins = [
@@ -262,7 +307,7 @@ function clearLinkedModuleDigests(root) {
262
307
  if (root === void 0) linkedModuleDigests.clear();
263
308
  else linkedModuleDigests.delete(root);
264
309
  }
265
- function linkedModuleDigest(root) {
310
+ function swiftModuleDigest(root) {
266
311
  const files = swiftModuleInputFiles(root);
267
312
  const stampHash = (0, import_node_crypto2.createHash)("sha256");
268
313
  for (const file of files) {
@@ -334,7 +379,7 @@ function swiftArtifactHash(input, release, moduleRoot) {
334
379
  ${release}
335
380
  `);
336
381
  if (input.oneModule) hash.update("one-module\n");
337
- hash.update(linkedModuleDigest(moduleRoot));
382
+ hash.update(swiftModuleDigest(moduleRoot));
338
383
  for (const file of Object.keys(input.files).sort()) {
339
384
  hash.update((0, import_node_crypto2.createHash)("sha256").update(file).digest());
340
385
  hash.update((0, import_node_crypto2.createHash)("sha256").update(input.files[file]).digest());
@@ -368,23 +413,30 @@ ${release}
368
413
  return hash.digest("hex");
369
414
  }
370
415
  function emitSwiftPackageManifest(args) {
371
- const { targets, siblings, moduleRoot, oneModule } = args;
416
+ const { targets, siblings, moduleRoot, oneModule, distribution } = args;
372
417
  const executable = targets.find((target) => target.executable);
373
418
  if (!executable) throw new Error("swift-compile: no executable target to emit");
374
419
  const stanza = (target) => {
375
420
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
376
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${OBJC_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}])]`;
421
+ const imports = distribution ? `, "-I", ${JSON.stringify(import_node_path2.default.join(moduleRoot, "modules"))}` : "";
422
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${OBJC_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
377
423
  const deps = [
378
- '.product(name: "SwiftUI", package: "sootsim-swift")',
379
- ...oneModule ? [ONE_PRODUCT] : [],
424
+ ...distribution ? [] : [
425
+ '.product(name: "SwiftUI", package: "sootsim-swift")',
426
+ ...oneModule ? [ONE_PRODUCT] : []
427
+ ],
380
428
  ...(siblings.get(target.name) ?? []).map((sibling) => `"${sibling}"`)
381
429
  ].join(", ");
430
+ const library = distribution ? [
431
+ ...distribution.objects.map((object) => import_node_path2.default.join(moduleRoot, object)),
432
+ ...distribution.link
433
+ ].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
382
434
  const kind = target.executable ? ".executableTarget" : ".target";
383
435
  const link = target.executable ? `,
384
436
  linkerSettings: [
385
437
  .unsafeFlags([
386
438
  "-Xclang-linker", "-mexec-model=reactor",
387
- "-Xlinker", "--export-if-defined=__main_argc_argv",
439
+ "-Xlinker", "--export-if-defined=__main_argc_argv"${library},
388
440
  ]),
389
441
  .unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
390
442
  ]` : "";
@@ -405,7 +457,7 @@ function emitSwiftPackageManifest(args) {
405
457
  "let package = Package(",
406
458
  ' name: "app",',
407
459
  ` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
408
- ` dependencies: [.package(path: "${moduleRoot}")],`,
460
+ ` dependencies: [${distribution ? "" : `.package(path: "${moduleRoot}")`}],`,
409
461
  " targets: [",
410
462
  ...targets.map(stanza),
411
463
  " ]",
@@ -574,7 +626,17 @@ function swiftCodeScan(source) {
574
626
  }
575
627
  var compiledSource = (file, contents) => file.endsWith(".swift") ? swiftSourceAsIOS(contents) : contents;
576
628
  function writeSwiftProject(layout, input, moduleRoot) {
577
- const targets = compileTargets(input);
629
+ const distribution = swiftDistributionAt(moduleRoot);
630
+ const targets = distribution && compileTargets(input).length === 0 ? [
631
+ {
632
+ name: "App",
633
+ path: import_node_path2.default.relative(layout.root, layout.sources),
634
+ executable: true,
635
+ languageMode: 5,
636
+ mainActorIsolation: false,
637
+ resources: false
638
+ }
639
+ ] : compileTargets(input);
578
640
  const files = /* @__PURE__ */ new Map();
579
641
  const moduleFiles = `
580
642
  // sootsim-swift files ${(0, import_node_crypto2.createHash)("sha256").update(swiftModuleInputFiles(moduleRoot).join("\n")).digest("hex").slice(0, 16)}
@@ -601,9 +663,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
601
663
  }
602
664
  files.set(import_node_path2.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
603
665
  } else {
666
+ const base = layout.multi ? layout.root : layout.sources;
604
667
  for (const [file, contents] of Object.entries(input.files)) {
605
668
  if (file === "Package.swift") continue;
606
- files.set(import_node_path2.default.join(layout.root, file), compiledSource(file, contents));
669
+ files.set(import_node_path2.default.join(base, file), compiledSource(file, contents));
607
670
  }
608
671
  for (const target of targets) {
609
672
  if (!target.resources) continue;
@@ -625,7 +688,8 @@ function writeSwiftProject(layout, input, moduleRoot) {
625
688
  targets,
626
689
  siblings: swiftSiblingDependencies(input.files, targets),
627
690
  moduleRoot,
628
- oneModule: input.oneModule
691
+ oneModule: input.oneModule,
692
+ distribution: distribution ?? void 0
629
693
  }) + moduleFiles
630
694
  );
631
695
  }
@@ -742,7 +806,9 @@ function compileSwiftProjectUnit(input, options) {
742
806
  compileTargets,
743
807
  emitSwiftPackageManifest,
744
808
  swiftArtifactHash,
809
+ swiftDistributionAt,
745
810
  swiftIcuAsset,
811
+ swiftModuleDigest,
746
812
  swiftModuleInputFiles,
747
813
  swiftSourceAsIOS,
748
814
  withNativeSourceGlue,
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import { execFile as execFile2 } from "node:child_process";
@@ -17,6 +17,40 @@ import os from "node:os";
17
17
  import path2 from "node:path";
18
18
  import { promisify as promisify2 } from "node:util";
19
19
 
20
+ // src/is-record.ts
21
+ function isRecord(value) {
22
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23
+ }
24
+
25
+ // src/swift-distribution-contract.ts
26
+ var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
27
+ var SWIFT_DISTRIBUTION_HOSTS = [
28
+ "darwin-arm64",
29
+ "linux-x64",
30
+ "linux-arm64"
31
+ ];
32
+ var isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
33
+ function parseSwiftDistributionManifest(value) {
34
+ if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
35
+ throw new Error(`invalid Swift distribution ${SWIFT_DISTRIBUTION_MANIFEST}`);
36
+ }
37
+ const host2 = SWIFT_DISTRIBUTION_HOSTS.find((candidate) => candidate === value.host);
38
+ if (!host2) throw new Error(`Swift distribution names an unknown host ${value.host}`);
39
+ return {
40
+ id: value.id,
41
+ release: value.release,
42
+ wasmSdkChecksum: value.wasmSdkChecksum,
43
+ modules: value.modules,
44
+ objects: value.objects,
45
+ link: value.link,
46
+ files: Object.fromEntries(
47
+ Object.entries(value.files).map(([file, sha]) => [file, String(sha)])
48
+ ),
49
+ host: host2,
50
+ plugins: value.plugins
51
+ };
52
+ }
53
+
20
54
  // src/swift-icu.ts
21
55
  import { execFile } from "node:child_process";
22
56
  import { createHash } from "node:crypto";
@@ -181,7 +215,13 @@ var WASM_TRIPLE = "wasm32-unknown-wasip1";
181
215
  var cores = os.availableParallelism();
182
216
  var BUILD_ENV = { ...process.env, BINARYEN_CORES: String(Math.min(4, cores)) };
183
217
  var BUILD_JOBS = String(Math.max(1, Math.floor(cores / 2)));
218
+ function swiftDistributionAt(root) {
219
+ const file = path2.join(root, SWIFT_DISTRIBUTION_MANIFEST);
220
+ if (!existsSync(file)) return null;
221
+ return parseSwiftDistributionManifest(JSON.parse(readFileSync2(file, "utf8")));
222
+ }
184
223
  function swiftModuleInputFiles(root) {
224
+ if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
185
225
  const files = [
186
226
  "Package.swift",
187
227
  "scripts/contrast-app-Package.swift",
@@ -198,6 +238,9 @@ function swiftModuleInputFiles(root) {
198
238
  return files.sort();
199
239
  }
200
240
  async function ensureMacroPlugins(moduleRoot, toolchainBin) {
241
+ const distribution = swiftDistributionAt(moduleRoot);
242
+ if (distribution)
243
+ return distribution.plugins.map((plugin) => path2.join(moduleRoot, plugin));
201
244
  const dir = path2.join(moduleRoot, ".build/host/RnxPreviewMacros");
202
245
  const ext = process.platform === "darwin" ? "dylib" : "so";
203
246
  const plugins = [
@@ -227,7 +270,7 @@ function clearLinkedModuleDigests(root) {
227
270
  if (root === void 0) linkedModuleDigests.clear();
228
271
  else linkedModuleDigests.delete(root);
229
272
  }
230
- function linkedModuleDigest(root) {
273
+ function swiftModuleDigest(root) {
231
274
  const files = swiftModuleInputFiles(root);
232
275
  const stampHash = createHash2("sha256");
233
276
  for (const file of files) {
@@ -299,7 +342,7 @@ function swiftArtifactHash(input, release, moduleRoot) {
299
342
  ${release}
300
343
  `);
301
344
  if (input.oneModule) hash.update("one-module\n");
302
- hash.update(linkedModuleDigest(moduleRoot));
345
+ hash.update(swiftModuleDigest(moduleRoot));
303
346
  for (const file of Object.keys(input.files).sort()) {
304
347
  hash.update(createHash2("sha256").update(file).digest());
305
348
  hash.update(createHash2("sha256").update(input.files[file]).digest());
@@ -333,23 +376,30 @@ ${release}
333
376
  return hash.digest("hex");
334
377
  }
335
378
  function emitSwiftPackageManifest(args) {
336
- const { targets, siblings, moduleRoot, oneModule } = args;
379
+ const { targets, siblings, moduleRoot, oneModule, distribution } = args;
337
380
  const executable = targets.find((target) => target.executable);
338
381
  if (!executable) throw new Error("swift-compile: no executable target to emit");
339
382
  const stanza = (target) => {
340
383
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
341
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${OBJC_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}])]`;
384
+ const imports = distribution ? `, "-I", ${JSON.stringify(path2.join(moduleRoot, "modules"))}` : "";
385
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${OBJC_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
342
386
  const deps = [
343
- '.product(name: "SwiftUI", package: "sootsim-swift")',
344
- ...oneModule ? [ONE_PRODUCT] : [],
387
+ ...distribution ? [] : [
388
+ '.product(name: "SwiftUI", package: "sootsim-swift")',
389
+ ...oneModule ? [ONE_PRODUCT] : []
390
+ ],
345
391
  ...(siblings.get(target.name) ?? []).map((sibling) => `"${sibling}"`)
346
392
  ].join(", ");
393
+ const library = distribution ? [
394
+ ...distribution.objects.map((object) => path2.join(moduleRoot, object)),
395
+ ...distribution.link
396
+ ].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
347
397
  const kind = target.executable ? ".executableTarget" : ".target";
348
398
  const link = target.executable ? `,
349
399
  linkerSettings: [
350
400
  .unsafeFlags([
351
401
  "-Xclang-linker", "-mexec-model=reactor",
352
- "-Xlinker", "--export-if-defined=__main_argc_argv",
402
+ "-Xlinker", "--export-if-defined=__main_argc_argv"${library},
353
403
  ]),
354
404
  .unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
355
405
  ]` : "";
@@ -370,7 +420,7 @@ function emitSwiftPackageManifest(args) {
370
420
  "let package = Package(",
371
421
  ' name: "app",',
372
422
  ` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
373
- ` dependencies: [.package(path: "${moduleRoot}")],`,
423
+ ` dependencies: [${distribution ? "" : `.package(path: "${moduleRoot}")`}],`,
374
424
  " targets: [",
375
425
  ...targets.map(stanza),
376
426
  " ]",
@@ -539,7 +589,17 @@ function swiftCodeScan(source) {
539
589
  }
540
590
  var compiledSource = (file, contents) => file.endsWith(".swift") ? swiftSourceAsIOS(contents) : contents;
541
591
  function writeSwiftProject(layout, input, moduleRoot) {
542
- const targets = compileTargets(input);
592
+ const distribution = swiftDistributionAt(moduleRoot);
593
+ const targets = distribution && compileTargets(input).length === 0 ? [
594
+ {
595
+ name: "App",
596
+ path: path2.relative(layout.root, layout.sources),
597
+ executable: true,
598
+ languageMode: 5,
599
+ mainActorIsolation: false,
600
+ resources: false
601
+ }
602
+ ] : compileTargets(input);
543
603
  const files = /* @__PURE__ */ new Map();
544
604
  const moduleFiles = `
545
605
  // sootsim-swift files ${createHash2("sha256").update(swiftModuleInputFiles(moduleRoot).join("\n")).digest("hex").slice(0, 16)}
@@ -566,9 +626,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
566
626
  }
567
627
  files.set(path2.join(layout.root, "Package.swift"), manifest + moduleFiles);
568
628
  } else {
629
+ const base = layout.multi ? layout.root : layout.sources;
569
630
  for (const [file, contents] of Object.entries(input.files)) {
570
631
  if (file === "Package.swift") continue;
571
- files.set(path2.join(layout.root, file), compiledSource(file, contents));
632
+ files.set(path2.join(base, file), compiledSource(file, contents));
572
633
  }
573
634
  for (const target of targets) {
574
635
  if (!target.resources) continue;
@@ -590,7 +651,8 @@ function writeSwiftProject(layout, input, moduleRoot) {
590
651
  targets,
591
652
  siblings: swiftSiblingDependencies(input.files, targets),
592
653
  moduleRoot,
593
- oneModule: input.oneModule
654
+ oneModule: input.oneModule,
655
+ distribution: distribution ?? void 0
594
656
  }) + moduleFiles
595
657
  );
596
658
  }
@@ -706,7 +768,9 @@ export {
706
768
  compileTargets,
707
769
  emitSwiftPackageManifest,
708
770
  swiftArtifactHash,
771
+ swiftDistributionAt,
709
772
  swiftIcuAsset,
773
+ swiftModuleDigest,
710
774
  swiftModuleInputFiles,
711
775
  swiftSourceAsIOS,
712
776
  withNativeSourceGlue,
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-package.ts
4
4
  function isSwiftManifestFile(file) {
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-submit.ts
4
4
  var SWIFT_COMPILE_PATH = "/api/swift-compile";
@@ -0,0 +1,115 @@
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
+ "use strict";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/swift-toolchain.ts
33
+ var swift_toolchain_exports = {};
34
+ __export(swift_toolchain_exports, {
35
+ swiftInstallSteps: () => swiftInstallSteps,
36
+ swiftToolchain: () => swiftToolchain,
37
+ swiftToolchainBin: () => swiftToolchainBin
38
+ });
39
+ module.exports = __toCommonJS(swift_toolchain_exports);
40
+ var import_node_child_process = require("node:child_process");
41
+ var import_node_fs = __toESM(require("node:fs"), 1);
42
+ var import_node_os = __toESM(require("node:os"), 1);
43
+ var import_node_path = __toESM(require("node:path"), 1);
44
+ function swiftToolchainBin(release) {
45
+ if (process.platform === "darwin") {
46
+ const dirs = [import_node_os.default.homedir(), "/"].map(
47
+ (base) => import_node_path.default.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
48
+ );
49
+ return dirs.find((dir) => import_node_fs.default.existsSync(import_node_path.default.join(dir, "swift"))) ?? dirs[0];
50
+ }
51
+ if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
52
+ return import_node_path.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
53
+ }
54
+ const image = import_node_path.default.join("/opt/swift", release, "usr/bin");
55
+ if (import_node_fs.default.existsSync(import_node_path.default.join(image, "swift"))) return image;
56
+ return (process.env.PATH ?? "").split(import_node_path.default.delimiter).find((dir) => dir && import_node_fs.default.existsSync(import_node_path.default.join(dir, "swift"))) ?? image;
57
+ }
58
+ var verified = /* @__PURE__ */ new Map();
59
+ function swiftToolchain(release, wasmSdkChecksum) {
60
+ const cached = verified.get(release);
61
+ if (cached) return cached;
62
+ const bin = swiftToolchainBin(release);
63
+ const swift = import_node_path.default.join(bin, "swift");
64
+ const version = import_node_fs.default.existsSync(swift) ? (0, import_node_child_process.execFileSync)(swift, ["--version"], {
65
+ encoding: "utf8",
66
+ stdio: ["ignore", "pipe", "pipe"]
67
+ }) : "";
68
+ if (!version.includes(`(${release})`)) {
69
+ const found = version ? `found ${version.split("\n")[0]?.trim()} at ${swift}` : process.platform === "darwin" ? `found no ${release}.xctoolchain in ~/Library/Developer/Toolchains or /Library/Developer/Toolchains` : "found no swift on PATH";
70
+ throw new Error(
71
+ `peach compiles Swift with the swift.org toolchain ${release} and its wasm SDK; ${found}.
72
+ ${swiftInstallSteps(release, wasmSdkChecksum)}`
73
+ );
74
+ }
75
+ const sdks = (0, import_node_child_process.execFileSync)(swift, ["sdk", "list"], {
76
+ encoding: "utf8",
77
+ stdio: ["ignore", "pipe", "pipe"]
78
+ });
79
+ if (!sdks.split("\n").some((line) => line.trim() === `${release}_wasm`)) {
80
+ throw new Error(
81
+ `peach compiles Swift with the ${release}_wasm SDK, which ${swift} does not have.
82
+ ${swiftInstallSteps(release, wasmSdkChecksum)}`
83
+ );
84
+ }
85
+ verified.set(release, bin);
86
+ return bin;
87
+ }
88
+ function swiftInstallSteps(release, wasmSdkChecksum) {
89
+ const version = release.replace(/^swift-/, "").toLowerCase();
90
+ const downloads = `https://download.swift.org/swift-${version}`;
91
+ const sdk = `swift sdk install ${downloads}/wasm-sdk/${release}/${release}_wasm.artifactbundle.tar.gz --checksum ${wasmSdkChecksum}`;
92
+ if (process.platform === "darwin") {
93
+ const swift = `~/Library/Developer/Toolchains/${release}.xctoolchain/usr/bin/swift`;
94
+ return [
95
+ "install it:",
96
+ ` curl -fsSLO ${downloads}/xcode/${release}/${release}-osx.pkg`,
97
+ ` installer -pkg ${release}-osx.pkg -target CurrentUserHomeDirectory`,
98
+ ` ${swift} ${sdk.replace(/^swift /, "")}`
99
+ ].join("\n");
100
+ }
101
+ const platform = `debian12${process.arch === "arm64" ? "-aarch64" : ""}`;
102
+ const name = `${release}-${platform}`;
103
+ return [
104
+ "install it (Debian 12 shown; other distributions: https://www.swift.org/install/linux/):",
105
+ ` curl -fsSL ${downloads}/${platform}/${release}/${name}.tar.gz | tar -xz -C /opt`,
106
+ ` export PATH=/opt/${name}/usr/bin:$PATH`,
107
+ ` ${sdk}`
108
+ ].join("\n");
109
+ }
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ swiftInstallSteps,
113
+ swiftToolchain,
114
+ swiftToolchainBin
115
+ });
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.679 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.681 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;