peachsim 0.1.2773 → 0.1.2775

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 (148) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +318 -199
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-3SGU25AX.mjs → acorn-CTIC3GCU.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-KMMFDGYA.mjs → chunk-2YTHEKWJ.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-2HWUPAOD.mjs → chunk-3WU4YTJR.mjs} +205 -166
  29. package/dist-lib/esm-chunks/{chunk-ORGP6SSO.mjs → chunk-4B46TF64.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-QMI7ECNF.mjs → chunk-C5EU2DRL.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-DFVWY2BW.mjs → chunk-CFNSLWMQ.mjs} +4 -4
  32. package/dist-lib/esm-chunks/{chunk-HN7CHPZK.mjs → chunk-E6ULRDAP.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-IQF674WE.mjs → chunk-ESP2U4IX.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-5DQRSOJ5.mjs → chunk-ESWEEZZP.mjs} +2 -2
  35. package/dist-lib/esm-chunks/{chunk-4FVDW5QX.mjs → chunk-FBN2C43P.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-NH3CEIBN.mjs → chunk-FVUN2533.mjs} +3 -3
  37. package/dist-lib/esm-chunks/{chunk-IM2IAOAZ.mjs → chunk-GKKZLYBA.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-SZ7TVJHH.mjs → chunk-H5TBKFDB.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-GSZLZNZM.mjs → chunk-ITTQHQD5.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-XXLSXSUK.mjs → chunk-JERE5CAK.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-WBPJJXMA.mjs → chunk-MJSKVK7E.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-Q2EEH42W.mjs → chunk-NV5NLKKN.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-G5TS3L6A.mjs → chunk-RGOPQX37.mjs} +6 -6
  44. package/dist-lib/esm-chunks/{chunk-KEVJJ3QT.mjs → chunk-S47B7YHJ.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-FRPS6V6P.mjs → chunk-SK4FQLNJ.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-YZRKIUVZ.mjs → chunk-TE3WHBF3.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-ANTOZ3UC.mjs → chunk-W42DUKWD.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-DYKZYFHH.mjs → chunk-WB5OWF4G.mjs} +5 -5
  49. package/dist-lib/esm-chunks/{chunk-KZ2NH7C4.mjs → chunk-XMBGLLON.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-MRQ72NMR.mjs → chunk-YRKGWASL.mjs} +6 -6
  51. package/dist-lib/esm-chunks/{metro-layout-parser-5MEY33AK.mjs → metro-layout-parser-2RQ3WC37.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-3FLCNBQT.mjs → swift-package-prebuilt-L5SWVH6U.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-PPJ4LUOW.mjs → swift-sdk-app-module-5SWDBTBY.mjs} +107 -25
  54. package/dist-lib/esm-chunks/{swift-sdk-image-L5MERITP.mjs → swift-sdk-image-OOSMI47A.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-IILRYXVN.mjs → swift-sdk-image-producer-DL4VEBXN.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +318 -199
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +4327 -4209
  61. package/dist-lib/host/fetch-proxy-handler.cjs +343 -340
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +86 -86
  87. package/dist-lib/public-origins-lib.json +96 -96
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +2912 -2794
  95. package/dist-lib/swift-compile.cjs +314 -195
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/src/ios/duo-vertical-bar-geometry.d.ts +0 -15
  123. package/dist-types/packages/peach-engine/src/ios/flex-interaction.d.ts +0 -1
  124. package/dist-types/packages/peach-engine/src/react-native/AppState.d.ts +0 -1
  125. package/dist-types/packages/peach-engine/src/react-native/Keyboard.d.ts +0 -1
  126. package/dist-types/packages/peach-kit/src/ring-mode-state.d.ts +0 -1
  127. package/dist-types/packages/peach-kit/src/transitions/screen-transition-math.d.ts +0 -31
  128. package/package.json +1 -1
  129. package/src/assetCatalogContract.ts +0 -6
  130. package/src/expo-pod-prebuilt.ts +0 -63
  131. package/src/native-package-slice.ts +0 -2
  132. package/src/podfile-cocoapods.ts +0 -5
  133. package/src/runtime-assets.ts +0 -9
  134. package/src/sfSymbolMetricsContract.ts +51 -23
  135. package/src/swift-compile.ts +9 -6
  136. package/src/swift-distribution-mirror.ts +16 -5
  137. package/src/swift-guest-compile.ts +18 -7
  138. package/src/swift-guest-link.ts +0 -9
  139. package/src/swift-guest-projection-storage.ts +15 -2
  140. package/src/swift-guest-projection.ts +1 -46
  141. package/src/swift-guest-runtime-plan.ts +4 -80
  142. package/src/swift-header-compiler.ts +24 -9
  143. package/src/swift-sdk-app-module.ts +113 -10
  144. package/src/swift-wasm-prune.ts +0 -5
  145. package/src/swiftRuntimeProductContract.ts +1 -0
  146. package/src/swiftSdkLinkContract.ts +10 -0
  147. package/src/wasm-narrow-boundary.ts +0 -13
  148. package/src/wasm-lazy-split-tool.ts +0 -210
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2773 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2775 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -19579,7 +19579,7 @@ var init_react_native_core_digest = __esm({
19579
19579
 
19580
19580
  // src/swift-compiler-digest.ts
19581
19581
  function swiftArchiveCompilerDigestValue() {
19582
- return true ? "a3915d1d96c1d8c99b9affeff6c30dcd0a65ebdb46659725acdf5053072c6580" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19582
+ return true ? "dafa6520c0bcd0e852437835ad9626e824b1e758db5c163a7de2f7fc70ac67ee" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19583
19583
  }
19584
19584
  var import_node_crypto16, import_node_fs32, import_node_path31, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
19585
19585
  var init_swift_compiler_digest = __esm({
@@ -19725,13 +19725,13 @@ var init_swift_standin_digest = __esm({
19725
19725
  ];
19726
19726
  RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
19727
19727
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
19728
- STANDIN_SOURCE_DIGEST = true ? "46bd6373b813f44d3e812af83162f521ce032cba6bade9039bbb107120481dc5" : standinSourceDigest();
19728
+ STANDIN_SOURCE_DIGEST = true ? "c2d1c024e059538977fdd0666278d52ec2116aafae79fe0e8b1cda82a5981f3b" : standinSourceDigest();
19729
19729
  }
19730
19730
  });
19731
19731
 
19732
19732
  // src/expo-native-compiler-digest.ts
19733
19733
  function expoNativeCompilerDigestValue() {
19734
- return true ? "3aa55ede1762cf973bf737061cac6fe8e51ef2f66b9df8370329a6746d2d044a" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19734
+ return true ? "c9950c3dbdb6ca5891145f8c4133c9b62e89b35f62d9343e8d7ef410cda838f5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19735
19735
  }
19736
19736
  var import_node_crypto18;
19737
19737
  var init_expo_native_compiler_digest = __esm({
@@ -23891,6 +23891,128 @@ var init_swift_design_time = __esm({
23891
23891
  }
23892
23892
  });
23893
23893
 
23894
+ // src/swiftRuntimeProductContract.ts
23895
+ var v, SWIFT_FRAMEWORK_PRODUCT_FILE, swiftFrameworkProductSchema, SWIFT_SDK_PRODUCT_FILE, SWIFT_SDK_PRODUCT_DIRECTORY, swiftSdkProductSchema, swiftSdkProductsSchema;
23896
+ var init_swiftRuntimeProductContract = __esm({
23897
+ "src/swiftRuntimeProductContract.ts"() {
23898
+ "use strict";
23899
+ v = __toESM(require("peachsim/vendor/valibot"), 1);
23900
+ init_swiftTargetContract();
23901
+ SWIFT_FRAMEWORK_PRODUCT_FILE = "lib/framework-product.json";
23902
+ swiftFrameworkProductSchema = v.object({
23903
+ version: v.literal(1),
23904
+ packageName: v.string(),
23905
+ manifestSha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
23906
+ product: v.object({
23907
+ name: v.string(),
23908
+ linkage: v.picklist(["static", "dynamic", "automatic"]),
23909
+ targets: v.array(v.string())
23910
+ }),
23911
+ // framework names are distinct from SDK library linkNames. they identify
23912
+ // the packaged owner, not an observed native image dependency.
23913
+ frameworkAliases: v.array(
23914
+ v.object({
23915
+ kind: v.literal("framework"),
23916
+ name: v.string(),
23917
+ targets: v.array(v.string()),
23918
+ moduleMap: v.string(),
23919
+ moduleMapSha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
23920
+ wasmSdkId: v.string(),
23921
+ wasmSdkChecksum: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
23922
+ })
23923
+ ),
23924
+ targets: v.array(
23925
+ v.object({
23926
+ name: v.string(),
23927
+ path: v.string(),
23928
+ kind: v.picklist(["regular", "system"]),
23929
+ dependencies: v.array(v.string())
23930
+ })
23931
+ ),
23932
+ objects: v.array(v.object({ path: v.string(), target: v.string() })),
23933
+ autolink: v.array(v.string())
23934
+ });
23935
+ SWIFT_SDK_PRODUCT_FILE = "runtime-products.json";
23936
+ SWIFT_SDK_PRODUCT_DIRECTORY = "swift.xctoolchain/usr/lib/swift_static/wasi";
23937
+ swiftSdkProductSchema = v.pipe(
23938
+ v.object({
23939
+ id: v.string(),
23940
+ installName: v.string(),
23941
+ target: v.literal(SWIFT_WASM_TRIPLE),
23942
+ linkNames: v.array(v.string()),
23943
+ // absent records declare no framework namespace, even when a library name matches.
23944
+ frameworkAliases: v.optional(
23945
+ v.array(
23946
+ v.object({
23947
+ name: v.string(),
23948
+ moduleMap: v.string(),
23949
+ moduleMapSha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
23950
+ })
23951
+ ),
23952
+ []
23953
+ ),
23954
+ buildDependencies: v.array(v.string()),
23955
+ linkOwnership: v.picklist(["image", "containing-image"]),
23956
+ linkDependencies: v.nullable(v.array(v.string())),
23957
+ autolink: v.array(v.string()),
23958
+ sources: v.array(
23959
+ v.object({
23960
+ path: v.string(),
23961
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
23962
+ })
23963
+ ),
23964
+ artifacts: v.array(
23965
+ v.variant("kind", [
23966
+ v.object({
23967
+ kind: v.literal("archive"),
23968
+ path: v.string(),
23969
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
23970
+ members: v.array(
23971
+ v.object({
23972
+ name: v.string(),
23973
+ ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
23974
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
23975
+ sources: v.array(v.string())
23976
+ })
23977
+ )
23978
+ }),
23979
+ v.object({
23980
+ kind: v.literal("object"),
23981
+ path: v.string(),
23982
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
23983
+ sources: v.array(v.string()),
23984
+ input: v.optional(
23985
+ v.object({
23986
+ product: v.string(),
23987
+ artifact: v.object({
23988
+ path: v.string(),
23989
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
23990
+ }),
23991
+ member: v.optional(
23992
+ v.object({
23993
+ name: v.string(),
23994
+ ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
23995
+ sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/))
23996
+ })
23997
+ )
23998
+ })
23999
+ )
24000
+ })
24001
+ ])
24002
+ )
24003
+ }),
24004
+ v.check(
24005
+ (product) => product.linkOwnership === "image" || product.linkDependencies === null,
24006
+ "containing-image products cannot declare an image scope"
24007
+ )
24008
+ );
24009
+ swiftSdkProductsSchema = v.object({
24010
+ version: v.literal(1),
24011
+ products: v.array(swiftSdkProductSchema)
24012
+ });
24013
+ }
24014
+ });
24015
+
23894
24016
  // src/swift-distribution-mirror.ts
23895
24017
  function syncSwiftDistributionMirror(root, source, manifest) {
23896
24018
  const mirror = import_node_path40.default.join(root, SWIFT_DISTRIBUTION_MIRROR);
@@ -23953,10 +24075,12 @@ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId
23953
24075
  const options2 = ["--swift-sdks-path", mirror];
23954
24076
  const interrupted = (0, import_node_fs42.existsSync)(syncingMarker);
23955
24077
  const previous = interrupted ? null : readSdkRecord(recordFile);
23956
- if (previous && previous.sourceView === sourceView && previous.sourceSdkId === sourceSdkId && (0, import_node_fs42.existsSync)(bundleInfo) && (0, import_node_fs42.existsSync)(import_node_path40.default.join(destTriple, "swift-sdk.json"))) {
24078
+ const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId);
24079
+ const catalog = import_node_path40.default.join(destTriple, SDK_PRODUCT_CATALOG);
24080
+ const sourceCatalog = import_node_path40.default.join(sourceTriple, SDK_PRODUCT_CATALOG);
24081
+ if (previous && previous.sourceView === sourceView && previous.sourceSdkId === sourceSdkId && (0, import_node_fs42.existsSync)(bundleInfo) && (0, import_node_fs42.existsSync)(import_node_path40.default.join(destTriple, "swift-sdk.json")) && (!(0, import_node_fs42.lstatSync)(sourceCatalog, { throwIfNoEntry: false })?.isSymbolicLink() || (0, import_node_fs42.lstatSync)(catalog, { throwIfNoEntry: false })?.isSymbolicLink())) {
23957
24082
  return { id: SWIFT_SDK_MIRROR_ID, options: options2, toolsetChanged: false };
23958
24083
  }
23959
- const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId);
23960
24084
  if (!previous) {
23961
24085
  if (!interrupted) (0, import_node_fs42.rmSync)(mirror, { recursive: true, force: true });
23962
24086
  (0, import_node_fs42.rmSync)(import_node_path40.default.join(root, ".build"), { recursive: true, force: true });
@@ -23996,7 +24120,7 @@ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId
23996
24120
  (0, import_node_fs42.rmSync)(import_node_path40.default.join(root, ".build"), { recursive: true, force: true });
23997
24121
  } else {
23998
24122
  const compileTouched = touched.filter(
23999
- (file) => !file.endsWith(".a") && !file.endsWith(".o") && !file.startsWith("rust/") && file !== "runtime-products.json"
24123
+ (file) => !file.endsWith(".a") && !file.endsWith(".o") && !file.startsWith("rust/") && file !== SWIFT_SDK_PRODUCT_FILE && file !== SDK_PRODUCT_CATALOG
24000
24124
  );
24001
24125
  const headersChanged = compileTouched.some(
24002
24126
  (file) => !file.endsWith(".swiftmodule") && !file.endsWith(".swiftdoc") && !file.endsWith(".swiftsourceinfo") && !file.endsWith(".abi.json")
@@ -24065,8 +24189,8 @@ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, re
24065
24189
  const dest = import_node_path40.default.join(destDir, entry.name);
24066
24190
  const destLstat = (0, import_node_fs42.lstatSync)(dest, { throwIfNoEntry: false });
24067
24191
  if (entry.isSymbolicLink()) {
24068
- const target = (0, import_node_fs42.readlinkSync)(src);
24069
- if (target.startsWith(distributionPrefix)) {
24192
+ const target = import_node_path40.default.resolve(sourceDir, (0, import_node_fs42.readlinkSync)(src));
24193
+ if (target.startsWith(distributionPrefix) || rel === SDK_PRODUCT_CATALOG) {
24070
24194
  if (destLstat?.isSymbolicLink() && (0, import_node_fs42.readlinkSync)(dest) === target) continue;
24071
24195
  if (destLstat) (0, import_node_fs42.rmSync)(dest, { recursive: true, force: true });
24072
24196
  (0, import_node_fs42.symlinkSync)(target, dest);
@@ -24188,7 +24312,7 @@ function invalidateBuildDependents(root, spellings, read, headersChanged) {
24188
24312
  if (headersChanged)
24189
24313
  (0, import_node_fs42.rmSync)(import_node_path40.default.join(scratch2, "ModuleCache"), { recursive: true, force: true });
24190
24314
  }
24191
- var import_node_crypto24, import_node_fs42, import_node_path40, SWIFT_DISTRIBUTION_MIRROR, SWIFT_SDK_MIRROR, SWIFT_SDK_MIRROR_ID, SWIFT_SDK_MIRROR_RECORD, SWIFT_SDK_MIRROR_SYNCING, SWIFT_SDK_MIRROR_BUNDLE, SWIFT_DISTRIBUTION_MIRROR_SYNCING;
24315
+ var import_node_crypto24, import_node_fs42, import_node_path40, SWIFT_DISTRIBUTION_MIRROR, SWIFT_SDK_MIRROR, SWIFT_SDK_MIRROR_ID, SWIFT_SDK_MIRROR_RECORD, SWIFT_SDK_MIRROR_SYNCING, SWIFT_SDK_MIRROR_BUNDLE, SWIFT_DISTRIBUTION_MIRROR_SYNCING, SDK_PRODUCT_CATALOG;
24192
24316
  var init_swift_distribution_mirror = __esm({
24193
24317
  "src/swift-distribution-mirror.ts"() {
24194
24318
  "use strict";
@@ -24200,6 +24324,7 @@ var init_swift_distribution_mirror = __esm({
24200
24324
  init_swift_distribution_contract();
24201
24325
  init_swift_shared_sdk();
24202
24326
  init_swiftContract();
24327
+ init_swiftRuntimeProductContract();
24203
24328
  init_swiftTargetContract();
24204
24329
  SWIFT_DISTRIBUTION_MIRROR = ".peach-distribution";
24205
24330
  SWIFT_SDK_MIRROR = ".peach-sdk";
@@ -24208,6 +24333,7 @@ var init_swift_distribution_mirror = __esm({
24208
24333
  SWIFT_SDK_MIRROR_SYNCING = ".peach-sdk-syncing";
24209
24334
  SWIFT_SDK_MIRROR_BUNDLE = "peach-wasm.artifactbundle";
24210
24335
  SWIFT_DISTRIBUTION_MIRROR_SYNCING = ".peach-distribution-syncing";
24336
+ SDK_PRODUCT_CATALOG = `${SWIFT_SDK_PRODUCT_DIRECTORY}/${SWIFT_SDK_PRODUCT_FILE}`;
24211
24337
  }
24212
24338
  });
24213
24339
 
@@ -24334,8 +24460,8 @@ function guestSourceImages(input, swift) {
24334
24460
  membership = sourceImageMembership(graph);
24335
24461
  }
24336
24462
  if (promoted.length) {
24337
- const names = v.parse(
24338
- v.array(v.string()),
24463
+ const names = v2.parse(
24464
+ v2.array(v2.string()),
24339
24465
  JSON.parse(
24340
24466
  (0, import_node_child_process21.execFileSync)(
24341
24467
  swift,
@@ -24526,13 +24652,13 @@ function planGuestSourceLink(graph, images, callers, artifacts, symbols) {
24526
24652
  symbols
24527
24653
  };
24528
24654
  }
24529
- var import_node_child_process21, import_node_path41, v, NATIVE_ARCHIVE_OBJECTS_DIR;
24655
+ var import_node_child_process21, import_node_path41, v2, NATIVE_ARCHIVE_OBJECTS_DIR;
24530
24656
  var init_swift_guest_source_plan = __esm({
24531
24657
  "src/swift-guest-source-plan.ts"() {
24532
24658
  "use strict";
24533
24659
  import_node_child_process21 = require("node:child_process");
24534
24660
  import_node_path41 = __toESM(require("node:path"), 1);
24535
- v = __toESM(require("peachsim/vendor/valibot"), 1);
24661
+ v2 = __toESM(require("peachsim/vendor/valibot"), 1);
24536
24662
  init_swift_package();
24537
24663
  init_swift_toolchain();
24538
24664
  NATIVE_ARCHIVE_OBJECTS_DIR = ".peach-native-libraries";
@@ -24719,7 +24845,7 @@ var init_guest_engine_services = __esm({
24719
24845
  });
24720
24846
 
24721
24847
  // src/swift-guest-linked-spans.ts
24722
- function number(bytes, start) {
24848
+ function number2(bytes, start) {
24723
24849
  let value = 0;
24724
24850
  let shift = 0;
24725
24851
  let pos = start;
@@ -24732,7 +24858,7 @@ function number(bytes, start) {
24732
24858
  }
24733
24859
  }
24734
24860
  function signedAddress(bytes, start) {
24735
- const [value, end] = number(bytes, start);
24861
+ const [value, end] = number2(bytes, start);
24736
24862
  const bits = (end - start) * 7;
24737
24863
  const signed = bits < 32 && bytes[end - 1] & 64 ? value - 2 ** bits : value;
24738
24864
  return [signed >>> 0, end];
@@ -24740,7 +24866,7 @@ function signedAddress(bytes, start) {
24740
24866
  function startupDataInitializers(body) {
24741
24867
  let pos = 0;
24742
24868
  const read = () => {
24743
- const [value, next] = number(body, pos);
24869
+ const [value, next] = number2(body, pos);
24744
24870
  pos = next;
24745
24871
  return value;
24746
24872
  };
@@ -24819,7 +24945,7 @@ function layout(bytes, readData = true, requireExports = true) {
24819
24945
  let offset = 8;
24820
24946
  while (offset < bytes.length) {
24821
24947
  const id = bytes[offset++];
24822
- const [size2, start2] = number(bytes, offset);
24948
+ const [size2, start2] = number2(bytes, offset);
24823
24949
  if (start2 + size2 > bytes.length) throw new Error("invalid wasm section");
24824
24950
  if (id) sections.set(id, [start2, start2 + size2]);
24825
24951
  offset = start2 + size2;
@@ -24828,7 +24954,7 @@ function layout(bytes, readData = true, requireExports = true) {
24828
24954
  if (!exports2) throw new Error("guest wasm does not export memory and table");
24829
24955
  let exportPosition = exports2[0];
24830
24956
  const readExport2 = () => {
24831
- const [value, next] = number(bytes, exportPosition);
24957
+ const [value, next] = number2(bytes, exportPosition);
24832
24958
  exportPosition = next;
24833
24959
  return value;
24834
24960
  };
@@ -24849,7 +24975,7 @@ function layout(bytes, readData = true, requireExports = true) {
24849
24975
  if (section2) {
24850
24976
  let pos = section2[0];
24851
24977
  const read = () => {
24852
- const [value, next] = number(bytes, pos);
24978
+ const [value, next] = number2(bytes, pos);
24853
24979
  pos = next;
24854
24980
  return value;
24855
24981
  };
@@ -24892,7 +25018,7 @@ function layout(bytes, readData = true, requireExports = true) {
24892
25018
  if (memory) {
24893
25019
  let pos = memory[0];
24894
25020
  const read = () => {
24895
- const [value, next] = number(bytes, pos);
25021
+ const [value, next] = number2(bytes, pos);
24896
25022
  pos = next;
24897
25023
  return value;
24898
25024
  };
@@ -24906,7 +25032,7 @@ function layout(bytes, readData = true, requireExports = true) {
24906
25032
  }
24907
25033
  if (memoryPages === void 0) throw new Error("guest wasm has no memory");
24908
25034
  const start = sections.get(8);
24909
- const startFunction = start ? number(bytes, start[0])[0] : void 0;
25035
+ const startFunction = start ? number2(bytes, start[0])[0] : void 0;
24910
25036
  let startup;
24911
25037
  const functionsByCodeOffset = /* @__PURE__ */ new Map();
24912
25038
  const code = sections.get(10);
@@ -24962,7 +25088,7 @@ function layout(bytes, readData = true, requireExports = true) {
24962
25088
  return b0;
24963
25089
  }
24964
25090
  }
24965
- const [value, next] = number(bytes, pos);
25091
+ const [value, next] = number2(bytes, pos);
24966
25092
  pos = next;
24967
25093
  return value;
24968
25094
  };
@@ -24999,7 +25125,7 @@ function layout(bytes, readData = true, requireExports = true) {
24999
25125
  if (dataSection && readData) {
25000
25126
  let pos = dataSection[0];
25001
25127
  const read = () => {
25002
- const [value, next] = number(bytes, pos);
25128
+ const [value, next] = number2(bytes, pos);
25003
25129
  pos = next;
25004
25130
  return value;
25005
25131
  };
@@ -25343,7 +25469,7 @@ function takeGuestStartupData(wasm, address, length) {
25343
25469
  while (offset < wasm.length) {
25344
25470
  const header = offset;
25345
25471
  const id = wasm[offset++];
25346
- const [size3, start2] = number(wasm, offset);
25472
+ const [size3, start2] = number2(wasm, offset);
25347
25473
  if (id) sections.set(id, [header, start2, start2 + size3]);
25348
25474
  offset = start2 + size3;
25349
25475
  }
@@ -25351,13 +25477,13 @@ function takeGuestStartupData(wasm, address, length) {
25351
25477
  const code = sections.get(10);
25352
25478
  const data = sections.get(11);
25353
25479
  if (!start || !code || !data) throw new Error("guest wasm has no startup data");
25354
- const [startFunction] = number(wasm, start[1]);
25480
+ const [startFunction] = number2(wasm, start[1]);
25355
25481
  let functionImports = 0;
25356
25482
  const imports2 = sections.get(2);
25357
25483
  if (imports2) {
25358
25484
  let pos2 = imports2[1];
25359
25485
  const read = () => {
25360
- const [value, next2] = number(wasm, pos2);
25486
+ const [value, next2] = number2(wasm, pos2);
25361
25487
  pos2 = next2;
25362
25488
  return value;
25363
25489
  };
@@ -25389,29 +25515,29 @@ function takeGuestStartupData(wasm, address, length) {
25389
25515
  }
25390
25516
  let pos = code[1];
25391
25517
  let body;
25392
- let [count, next] = number(wasm, pos);
25518
+ let [count, next] = number2(wasm, pos);
25393
25519
  pos = next;
25394
25520
  for (let index = 0; index < count; index++) {
25395
- const [size3, bodyStart] = number(wasm, pos);
25521
+ const [size3, bodyStart] = number2(wasm, pos);
25396
25522
  if (functionImports + index === startFunction) body = [bodyStart, bodyStart + size3];
25397
25523
  pos = bodyStart + size3;
25398
25524
  }
25399
25525
  if (!body) throw new Error("guest wasm start function has no body");
25400
25526
  const segments = [];
25401
25527
  pos = data[1];
25402
- [count, pos] = number(wasm, pos);
25528
+ [count, pos] = number2(wasm, pos);
25403
25529
  for (let index = 0; index < count; index++) {
25404
25530
  const header = pos;
25405
- const [flags, afterFlags] = number(wasm, pos);
25531
+ const [flags, afterFlags] = number2(wasm, pos);
25406
25532
  pos = afterFlags;
25407
25533
  let active;
25408
25534
  if (flags !== 1) {
25409
- if (flags === 2) pos = number(wasm, pos)[1];
25535
+ if (flags === 2) pos = number2(wasm, pos)[1];
25410
25536
  [active, pos] = signedAddress(wasm, pos + 1);
25411
25537
  pos++;
25412
25538
  }
25413
25539
  const sizeAt = pos;
25414
- const [size3, payload2] = number(wasm, pos);
25540
+ const [size3, payload2] = number2(wasm, pos);
25415
25541
  if (active !== void 0 && active < address + length && active + size3 > address)
25416
25542
  throw new Error("guest startup data range overlaps an active segment");
25417
25543
  segments.push({ header, sizeAt, payload: payload2, length: size3 });
@@ -26879,127 +27005,6 @@ var init_swift_wasm_archive = __esm({
26879
27005
  }
26880
27006
  });
26881
27007
 
26882
- // src/swiftRuntimeProductContract.ts
26883
- var v2, SWIFT_FRAMEWORK_PRODUCT_FILE, swiftFrameworkProductSchema, SWIFT_SDK_PRODUCT_FILE, swiftSdkProductSchema, swiftSdkProductsSchema;
26884
- var init_swiftRuntimeProductContract = __esm({
26885
- "src/swiftRuntimeProductContract.ts"() {
26886
- "use strict";
26887
- v2 = __toESM(require("peachsim/vendor/valibot"), 1);
26888
- init_swiftTargetContract();
26889
- SWIFT_FRAMEWORK_PRODUCT_FILE = "lib/framework-product.json";
26890
- swiftFrameworkProductSchema = v2.object({
26891
- version: v2.literal(1),
26892
- packageName: v2.string(),
26893
- manifestSha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/)),
26894
- product: v2.object({
26895
- name: v2.string(),
26896
- linkage: v2.picklist(["static", "dynamic", "automatic"]),
26897
- targets: v2.array(v2.string())
26898
- }),
26899
- // framework names are distinct from SDK library linkNames. they identify
26900
- // the packaged owner, not an observed native image dependency.
26901
- frameworkAliases: v2.array(
26902
- v2.object({
26903
- kind: v2.literal("framework"),
26904
- name: v2.string(),
26905
- targets: v2.array(v2.string()),
26906
- moduleMap: v2.string(),
26907
- moduleMapSha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/)),
26908
- wasmSdkId: v2.string(),
26909
- wasmSdkChecksum: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/))
26910
- })
26911
- ),
26912
- targets: v2.array(
26913
- v2.object({
26914
- name: v2.string(),
26915
- path: v2.string(),
26916
- kind: v2.picklist(["regular", "system"]),
26917
- dependencies: v2.array(v2.string())
26918
- })
26919
- ),
26920
- objects: v2.array(v2.object({ path: v2.string(), target: v2.string() })),
26921
- autolink: v2.array(v2.string())
26922
- });
26923
- SWIFT_SDK_PRODUCT_FILE = "runtime-products.json";
26924
- swiftSdkProductSchema = v2.pipe(
26925
- v2.object({
26926
- id: v2.string(),
26927
- installName: v2.string(),
26928
- target: v2.literal(SWIFT_WASM_TRIPLE),
26929
- linkNames: v2.array(v2.string()),
26930
- // absent records declare no framework namespace, even when a library name matches.
26931
- frameworkAliases: v2.optional(
26932
- v2.array(
26933
- v2.object({
26934
- name: v2.string(),
26935
- moduleMap: v2.string(),
26936
- moduleMapSha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/))
26937
- })
26938
- ),
26939
- []
26940
- ),
26941
- buildDependencies: v2.array(v2.string()),
26942
- linkOwnership: v2.picklist(["image", "containing-image"]),
26943
- linkDependencies: v2.nullable(v2.array(v2.string())),
26944
- autolink: v2.array(v2.string()),
26945
- sources: v2.array(
26946
- v2.object({
26947
- path: v2.string(),
26948
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/))
26949
- })
26950
- ),
26951
- artifacts: v2.array(
26952
- v2.variant("kind", [
26953
- v2.object({
26954
- kind: v2.literal("archive"),
26955
- path: v2.string(),
26956
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/)),
26957
- members: v2.array(
26958
- v2.object({
26959
- name: v2.string(),
26960
- ordinal: v2.pipe(v2.number(), v2.integer(), v2.minValue(1)),
26961
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/)),
26962
- sources: v2.array(v2.string())
26963
- })
26964
- )
26965
- }),
26966
- v2.object({
26967
- kind: v2.literal("object"),
26968
- path: v2.string(),
26969
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/)),
26970
- sources: v2.array(v2.string()),
26971
- input: v2.optional(
26972
- v2.object({
26973
- product: v2.string(),
26974
- artifact: v2.object({
26975
- path: v2.string(),
26976
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/))
26977
- }),
26978
- member: v2.optional(
26979
- v2.object({
26980
- name: v2.string(),
26981
- ordinal: v2.pipe(v2.number(), v2.integer(), v2.minValue(1)),
26982
- sha256: v2.pipe(v2.string(), v2.regex(/^[a-f0-9]{64}$/))
26983
- })
26984
- )
26985
- })
26986
- )
26987
- })
26988
- ])
26989
- )
26990
- }),
26991
- v2.check(
26992
- (product) => product.linkOwnership === "image" || product.linkDependencies === null,
26993
- "containing-image products cannot declare an image scope"
26994
- )
26995
- );
26996
- swiftSdkProductsSchema = v2.object({
26997
- version: v2.literal(1),
26998
- products: v2.array(swiftSdkProductSchema)
26999
- });
27000
- }
27001
- });
27002
-
27003
27008
  // src/swift-wasm-prune.ts
27004
27009
  function sha256Hex2(bytes) {
27005
27010
  if (typeof Bun !== "undefined")
@@ -32137,6 +32142,7 @@ function finalizeGuestProjectionStorage(options2) {
32137
32142
  const result = Buffer.from(options2.optimized);
32138
32143
  const locations = /* @__PURE__ */ new Map();
32139
32144
  const counts = /* @__PURE__ */ new Map();
32145
+ const countAddresses = [];
32140
32146
  const uuids = /* @__PURE__ */ new Map();
32141
32147
  const markers = new Map(
32142
32148
  options2.reserved.countMarkers.map((marker, index) => [marker, index])
@@ -32169,6 +32175,7 @@ function finalizeGuestProjectionStorage(options2) {
32169
32175
  if (counts.has(count))
32170
32176
  throw new Error("duplicate guest projection count marker");
32171
32177
  counts.set(count, offset);
32178
+ countAddresses[count] = segment2.address + offset - segment2.offset;
32172
32179
  }
32173
32180
  if (offset > end - 8 || result[offset + 3] !== 254 || result[offset + 7] !== 253)
32174
32181
  continue;
@@ -32206,7 +32213,16 @@ function finalizeGuestProjectionStorage(options2) {
32206
32213
  result.writeUInt32LE(region?.initialProtection ?? 0, offset + 8);
32207
32214
  result.writeUInt32LE(region?.maximumProtection ?? 0, offset + 12);
32208
32215
  }
32209
- return { wasm: result, images };
32216
+ return {
32217
+ wasm: result,
32218
+ images,
32219
+ countAddresses,
32220
+ appImages: options2.sdkSpans ? planGuestProjectionRegions(
32221
+ options2.reserved.images,
32222
+ options2.reserved.capacities,
32223
+ spans
32224
+ ) : images
32225
+ };
32210
32226
  }
32211
32227
  var UUID_MARKER_PREFIX, UUID_BYTES;
32212
32228
  var init_swift_guest_projection_storage = __esm({
@@ -32261,9 +32277,9 @@ function sdkArtifactBytes(root, artifact) {
32261
32277
  const linked = (0, import_node_fs48.readFileSync)(file);
32262
32278
  const hash = (bytes) => (0, import_node_crypto31.createHash)("sha256").update(bytes).digest("hex");
32263
32279
  if (hash(linked) === artifact.sha256) return { source: linked, linked };
32264
- if (artifact.kind !== "archive" || artifact.path !== `${SDK_CATALOG_DIRECTORY}/libFoundation.a`)
32280
+ if (artifact.kind !== "archive" || artifact.path !== `${SWIFT_SDK_PRODUCT_DIRECTORY}/libFoundation.a`)
32265
32281
  throw new Error(`SDK product artifact changed ${file}`);
32266
- const catalog = import_node_path46.default.join(root, SDK_CATALOG_DIRECTORY, SWIFT_SDK_PRODUCT_FILE);
32282
+ const catalog = import_node_path46.default.join(root, SWIFT_SDK_PRODUCT_DIRECTORY, SWIFT_SDK_PRODUCT_FILE);
32267
32283
  const sourceDirectory = import_node_path46.default.dirname((0, import_node_fs48.realpathSync)(catalog));
32268
32284
  const source = (0, import_node_fs48.readFileSync)(import_node_path46.default.join(sourceDirectory, "libFoundation.a"));
32269
32285
  if (hash(source) !== artifact.sha256)
@@ -32298,13 +32314,7 @@ function readGuestRuntimeCatalogs(sdkRoot, distributionRoot) {
32298
32314
  );
32299
32315
  const sdk2 = v5.parse(
32300
32316
  swiftSdkProductsSchema,
32301
- read(
32302
- import_node_path46.default.join(
32303
- sdkRoot,
32304
- "swift.xctoolchain/usr/lib/swift_static/wasi",
32305
- SWIFT_SDK_PRODUCT_FILE
32306
- )
32307
- )
32317
+ read(import_node_path46.default.join(sdkRoot, SWIFT_SDK_PRODUCT_DIRECTORY, SWIFT_SDK_PRODUCT_FILE))
32308
32318
  );
32309
32319
  const distribution = v5.parse(
32310
32320
  swiftSdkProductsSchema,
@@ -32778,7 +32788,7 @@ function guestAliasedSdkArchiveArtifacts(options2) {
32778
32788
  }
32779
32789
  return result;
32780
32790
  }
32781
- var import_node_crypto31, import_node_fs48, import_node_path46, v5, SDK_CATALOG_DIRECTORY, SDK_CONTAINING_IMAGE;
32791
+ var import_node_crypto31, import_node_fs48, import_node_path46, v5, SDK_CONTAINING_IMAGE;
32782
32792
  var init_swift_guest_runtime_plan = __esm({
32783
32793
  "src/swift-guest-runtime-plan.ts"() {
32784
32794
  "use strict";
@@ -32791,7 +32801,6 @@ var init_swift_guest_runtime_plan = __esm({
32791
32801
  init_swift_shared_sdk();
32792
32802
  init_swift_wasm_prune();
32793
32803
  init_swiftRuntimeProductContract();
32794
- SDK_CATALOG_DIRECTORY = "swift.xctoolchain/usr/lib/swift_static/wasi";
32795
32804
  SDK_CONTAINING_IMAGE = "wasi/containing-image";
32796
32805
  }
32797
32806
  });
@@ -41439,7 +41448,7 @@ async function linkSwiftAppModule(options2) {
41439
41448
  { maxBuffer: 64 << 20, ...options2.project }
41440
41449
  );
41441
41450
  const module2 = import_node_path59.default.join(work, "app.module.wasm");
41442
- const { bytes, linkage } = resolveSdkReferences(
41451
+ const { bytes, linkage, staticEnd, globalValues } = resolveSdkReferences(
41443
41452
  (0, import_node_fs61.readFileSync)(
41444
41453
  options2.project ? projectOutputFile(work, linked, options2.project) : linked
41445
41454
  ),
@@ -41472,6 +41481,8 @@ async function linkSwiftAppModule(options2) {
41472
41481
  ).update(bytes).digest("hex"));
41473
41482
  return {
41474
41483
  linkage,
41484
+ staticEnd,
41485
+ globalValues,
41475
41486
  async lower() {
41476
41487
  const receipt = loweringCache && `${loweringCache.file}.key`;
41477
41488
  if (loweringCache && receipt && (0, import_node_fs61.existsSync)(receipt) && (0, import_node_fs61.existsSync)(loweringCache.file) && (0, import_node_fs61.readFileSync)(receipt, "utf8") === loweringKey) {
@@ -41952,6 +41963,7 @@ function resolveSdkReferences(source, sdk2, forwarders) {
41952
41963
  const er = wasmReader(bytes, exportSection.start);
41953
41964
  const exportCount = er.u();
41954
41965
  const originalExportsStart = er.at;
41966
+ let staticEnd = 0;
41955
41967
  for (let i = 0; i < exportCount; i++) {
41956
41968
  const name3 = er.name();
41957
41969
  const kind = er.byte();
@@ -41964,8 +41976,10 @@ function resolveSdkReferences(source, sdk2, forwarders) {
41964
41976
  const op = raw2.byte();
41965
41977
  const value = op === 35 ? BigInt(raw2.u()) : raw2.s();
41966
41978
  raw2.skip(1);
41967
- if (j === index && value > BigInt(SWIFT_SDK_MEMORY_BASE))
41979
+ if (j !== index) continue;
41980
+ if (value <= 0n || value > BigInt(SWIFT_SDK_MEMORY_BASE))
41968
41981
  throw new Error("Swift app exceeds its reserved static memory range");
41982
+ staticEnd = Number(value);
41969
41983
  }
41970
41984
  }
41971
41985
  const exportParts = [
@@ -42002,7 +42016,12 @@ function resolveSdkReferences(source, sdk2, forwarders) {
42002
42016
  parts.push(bytes.subarray(s.offset, s.end));
42003
42017
  }
42004
42018
  }
42005
- return { bytes: Buffer.concat(parts), linkage };
42019
+ return {
42020
+ bytes: Buffer.concat(parts),
42021
+ linkage,
42022
+ staticEnd,
42023
+ globalValues: [...new Set(got.values())]
42024
+ };
42006
42025
  }
42007
42026
  function expandSdkRelocations(bytes, section2, patches) {
42008
42027
  patches.sort((a, b) => a.at - b.at);
@@ -42049,25 +42068,94 @@ function bindSwiftAppModule(linkage, sdk2) {
42049
42068
  throw new Error(`SDK image has no compatible function ${name3}`);
42050
42069
  return slot;
42051
42070
  });
42052
- const values = BigInt64Array.from(linkage.values, ({ kind, name: name3, addend }) => {
42071
+ const projection = linkage.replayProjection?.sdk === sdk2.key ? void 0 : linkage.replayProjection;
42072
+ const optional3 = projection && new Set(projection.lookupValues);
42073
+ const values = linkage.values.map(({ kind, name: name3, addend }, index) => {
42053
42074
  const value = kind === "function" ? functions[name3] : kind === "address" ? data[name3] : tls[name3];
42075
+ if (value === void 0 && optional3?.has(index)) return 0n;
42054
42076
  if (value === void 0 || kind === "tls" && tls.errno === void 0)
42055
42077
  throw new Error(`SDK image has no ${kind} symbol ${name3}`);
42056
42078
  return BigInt(value + addend - (kind === "tls" ? tls.errno : 0));
42057
42079
  });
42080
+ const fixups = projection ? appendReplayProjectionFixups(linkage.data, values, projection, sdk2) : linkage.data;
42058
42081
  const words2 = Uint32Array.from([
42059
42082
  values.length,
42060
42083
  slots.length,
42061
- linkage.data.length,
42084
+ fixups.length,
42062
42085
  linkage.tls.length
42063
42086
  ]);
42064
42087
  return Buffer.concat([
42065
- ...[words2, values, slots, Uint32Array.from(linkage.tls)].map(
42088
+ ...[words2, BigInt64Array.from(values), slots, Uint32Array.from(linkage.tls)].map(
42066
42089
  (part) => new Uint8Array(part.buffer)
42067
42090
  ),
42068
- encodeNativeSdkFixups(linkage.data)
42091
+ encodeNativeSdkFixups(fixups)
42069
42092
  ]);
42070
42093
  }
42094
+ function appendReplayProjectionFixups(data, values, projection, sdk2) {
42095
+ const { countAddresses, images, staticEnd } = projection;
42096
+ if (!Number.isSafeInteger(staticEnd) || staticEnd < SWIFT_SDK_APP_MEMORY_BASE || staticEnd >= SWIFT_SDK_MEMORY_BASE || countAddresses.length !== images.length || new Set(countAddresses).size !== images.length)
42097
+ throw new Error("invalid retained app projection storage");
42098
+ const objects = new Map(projection.objects);
42099
+ const products = new Map(projection.products);
42100
+ const sdkSpans = swiftSdkProjectionSpans(
42101
+ sdk2,
42102
+ (object8, product) => objects.get(object8) ?? products.get(product)
42103
+ );
42104
+ const regions = planGuestProjectionRegions(
42105
+ images,
42106
+ images.map(() => ({
42107
+ regions: Number.MAX_SAFE_INTEGER,
42108
+ memoryProtection: { initial: 3, maximum: 3 },
42109
+ tableProtection: { initial: 5, maximum: 5 }
42110
+ })),
42111
+ [
42112
+ ...images.flatMap(
42113
+ ({ regions: regions2 }, image) => regions2.map(({ space, address, length }) => ({ image, space, address, length }))
42114
+ ),
42115
+ ...sdkSpans
42116
+ ]
42117
+ );
42118
+ const fixups = [...data];
42119
+ const literals = /* @__PURE__ */ new Map();
42120
+ const add = (address, width, value) => {
42121
+ let index = literals.get(value);
42122
+ if (index === void 0) {
42123
+ index = values.length;
42124
+ literals.set(value, index);
42125
+ values.push(value);
42126
+ }
42127
+ fixups.push(address, width, index);
42128
+ };
42129
+ const name3 = Math.ceil(staticEnd / 8) * 8;
42130
+ let next = name3 + 8;
42131
+ if (next > SWIFT_SDK_MEMORY_BASE)
42132
+ throw new Error("rebound SDK projection exceeds the app static memory reservation");
42133
+ add(name3, 8, Buffer.from("__WASM\0\0").readBigInt64LE());
42134
+ for (const [image, { regions: ranges }] of regions.entries()) {
42135
+ const count = countAddresses[image];
42136
+ if (!Number.isSafeInteger(count) || count < SWIFT_SDK_APP_MEMORY_BASE || count + 16 > staticEnd || count % 8 !== 0)
42137
+ throw new Error("retained app projection record is out of range");
42138
+ add(count, 4, BigInt(ranges.length));
42139
+ add(count + 8, 8, BigInt(next));
42140
+ for (const range3 of ranges) {
42141
+ if (next + 40 > SWIFT_SDK_MEMORY_BASE)
42142
+ throw new Error(
42143
+ "rebound SDK projection exceeds the app static memory reservation"
42144
+ );
42145
+ add(next, 8, BigInt(name3));
42146
+ add(
42147
+ next + 8,
42148
+ 8,
42149
+ BigInt(range3.address) << 32n | BigInt(range3.space === "function-table")
42150
+ );
42151
+ add(next + 16, 8, BigInt(range3.initialProtection) << 32n | BigInt(range3.length));
42152
+ add(next + 24, 8, BigInt(range3.maximumProtection));
42153
+ add(next + 32, 8, 0n);
42154
+ next += 40;
42155
+ }
42156
+ }
42157
+ return fixups;
42158
+ }
42071
42159
  function writeSwiftSdkAppLink(file, link) {
42072
42160
  const bytes = (0, import_node_zlib4.gzipSync)(JSON.stringify(link), { level: 1 });
42073
42161
  (0, import_node_fs61.writeFileSync)(file, bytes);
@@ -42361,8 +42449,10 @@ function selectSwiftSdkData(sdk2, usage, linkage, projection) {
42361
42449
  const { functions, data } = sdk2.sdkInterface;
42362
42450
  for (const { name: name3 } of linkage.functions) boundSlots.add(functions[name3]);
42363
42451
  for (const { kind, name: name3 } of linkage.values) {
42364
- if (kind === "function") boundSlots.add(functions[name3]);
42365
- else if (kind === "address") visit3(data[name3]);
42452
+ const address2 = kind === "function" ? functions[name3] : data[name3];
42453
+ if (address2 === void 0) continue;
42454
+ if (kind === "function") boundSlots.add(address2);
42455
+ else if (kind === "address") visit3(address2);
42366
42456
  }
42367
42457
  }
42368
42458
  const slots = block2("functionSlots");
@@ -42673,6 +42763,7 @@ var init_swift_sdk_app_module = __esm({
42673
42763
  init_swift_distribution_mirror();
42674
42764
  init_swift_guest_dyld_functions();
42675
42765
  init_swift_guest_linked_spans();
42766
+ init_swift_guest_projection_storage();
42676
42767
  init_swift_project_user();
42677
42768
  init_swift_sdk_image();
42678
42769
  init_swift_sdk_image_map();
@@ -43146,7 +43237,6 @@ async function compileGuestLink(options2) {
43146
43237
  linkSwiftAppModule: linkSwiftAppModule2,
43147
43238
  readSwiftSdkUsage: readSwiftSdkUsage2,
43148
43239
  swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
43149
- swiftSdkProjectionDigest: swiftSdkProjectionDigest2,
43150
43240
  swiftSdkProjectionSpans: swiftSdkProjectionSpans2,
43151
43241
  writeSwiftSdkAppLink: writeSwiftSdkAppLink2
43152
43242
  } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
@@ -43300,17 +43390,29 @@ async function compileGuestLink(options2) {
43300
43390
  if (project2) return binding;
43301
43391
  const replayDirectory = import_node_path60.default.join(options2.buildDirectory, ".peach-sdk-module");
43302
43392
  (0, import_node_fs62.mkdirSync)(replayDirectory, { recursive: true });
43393
+ const directValues = new Set(link.globalValues);
43394
+ for (const values2 of [data, linkage.tls])
43395
+ for (let index = 2; index < values2.length; index += 3)
43396
+ directValues.add(values2[index]);
43303
43397
  const appLink = writeSwiftSdkAppLink2(
43304
43398
  import_node_path60.default.join(replayDirectory, "app-link.json.gz"),
43305
43399
  {
43306
- linkage,
43400
+ linkage: {
43401
+ ...linkage,
43402
+ replayProjection: {
43403
+ sdk: sdk2.key,
43404
+ staticEnd: link.staticEnd,
43405
+ countAddresses: finalized.countAddresses,
43406
+ images: finalized.appImages,
43407
+ objects: [...sdkObjectImages],
43408
+ products: [...sdkProductImages],
43409
+ lookupValues: [...new Set(bindingRows.values())].filter(
43410
+ (index) => !directValues.has(index)
43411
+ )
43412
+ }
43413
+ },
43307
43414
  usage,
43308
- scopedLookups: true,
43309
- sdkProjection: {
43310
- objects: [...sdkObjectImages],
43311
- products: [...sdkProductImages],
43312
- layoutSha256: swiftSdkProjectionDigest2(sdkSpans)
43313
- }
43415
+ scopedLookups: true
43314
43416
  }
43315
43417
  );
43316
43418
  return { ...binding, appLink };
@@ -43351,19 +43453,32 @@ function compilerCheckpoint(root, recipe2, args, header) {
43351
43453
  };
43352
43454
  const outputMap = value("-output-file-map");
43353
43455
  const module2 = value("-emit-module-path");
43354
- if (!outputMap || !module2 || !args.includes("-whole-module-optimization")) return;
43456
+ const wholeModule = args.lastIndexOf("-whole-module-optimization") > args.lastIndexOf("-no-whole-module-optimization");
43457
+ const batch = args.includes("-enable-batch-mode") && !args.includes("-incremental");
43458
+ if (!outputMap || !module2 || !wholeModule && !batch) return;
43355
43459
  const mapText = (0, import_node_fs63.readFileSync)(outputMap, "utf8");
43356
43460
  const map2 = JSON.parse(mapText);
43357
- if (!isRecord(map2) || !isRecord(map2[""]) || typeof map2[""].dependencies !== "string")
43358
- return;
43359
- const objects = [];
43360
- for (const [source, outputs2] of Object.entries(map2)) {
43461
+ if (!isRecord(map2)) return;
43462
+ const outputs = [module2, header];
43463
+ if (wholeModule) {
43464
+ if (!isRecord(map2[""]) || typeof map2[""].dependencies !== "string") return;
43465
+ outputs.push(map2[""].dependencies);
43466
+ }
43467
+ let objects = 0;
43468
+ for (const [source, fileOutputs] of Object.entries(map2)) {
43361
43469
  if (!source) continue;
43362
- if (!isRecord(outputs2) || typeof outputs2.object !== "string") return;
43363
- objects.push(outputs2.object);
43364
- }
43365
- if (!objects.length) return;
43366
- const outputs = [module2, header, map2[""].dependencies, ...objects];
43470
+ if (!isRecord(fileOutputs) || typeof fileOutputs.object !== "string") return;
43471
+ objects++;
43472
+ const object8 = fileOutputs.object;
43473
+ outputs.push(object8);
43474
+ if (!wholeModule) {
43475
+ const dependencies = fileOutputs.dependencies;
43476
+ if (typeof dependencies === "string") outputs.push(dependencies);
43477
+ else if (object8.endsWith(".o")) outputs.push(`${object8.slice(0, -2)}.d`);
43478
+ else return;
43479
+ }
43480
+ }
43481
+ if (objects === 0) return;
43367
43482
  const digest2 = (0, import_node_crypto41.createHash)("sha256").update(recipe2).update(JSON.stringify(args)).update(mapText);
43368
43483
  for (const flag of args) {
43369
43484
  if (!flag.startsWith("@")) continue;
@@ -49891,7 +50006,9 @@ ${compatShape}` : "";
49891
50006
  }
49892
50007
  const jobs = swiftCompilerJobs();
49893
50008
  const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
49894
- const perFile = input.unoptimized || incrementalPreview;
50009
+ const batchGuest = guestGraph !== void 0 && !options2.project && !input.unoptimized;
50010
+ const batch = incrementalPreview || batchGuest;
50011
+ const perFile = input.unoptimized || batch;
49895
50012
  const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
49896
50013
  const buildArgs = [
49897
50014
  "build",
@@ -49916,9 +50033,11 @@ ${compatShape}` : "";
49916
50033
  "-Xswiftc",
49917
50034
  "-j",
49918
50035
  "-Xswiftc",
49919
- String(jobs)
50036
+ String(batchGuest ? Math.min(8, jobs) : jobs)
49920
50037
  ] : [],
49921
- ...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
50038
+ // optimized batches can move specialized definitions between objects.
50039
+ ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
50040
+ ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
49922
50041
  // the mirror finds a changed sdk header's readers in their
49923
50042
  // dependency files, which omit system headers by default
49924
50043
  ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
@@ -49932,7 +50051,7 @@ ${compatShape}` : "";
49932
50051
  "-g0",
49933
50052
  "-Xcxx",
49934
50053
  "-g0",
49935
- ...incrementalPreview ? [] : [
50054
+ ...batch ? [] : [
49936
50055
  "-Xswiftc",
49937
50056
  "-num-threads",
49938
50057
  "-Xswiftc",
@@ -50576,7 +50695,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
50576
50695
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
50577
50696
  MULTI_MANIFEST_VERSION = 76;
50578
50697
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
50579
- compilerSourceDigest = true ? "a6326513da78eebd8cea52e4d27f4b4891f880aa2d7de55db6773c2aed5900be" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
50698
+ compilerSourceDigest = true ? "1803ba36803a88ceeca92ee7b13baa39dde72fbb72df14659f0414084afaf5d7" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
50580
50699
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
50581
50700
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
50582
50701
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -105962,7 +106081,7 @@ var init_nitro_superset = __esm({
105962
106081
  init_nitroContract();
105963
106082
  init_swift_standin_digest();
105964
106083
  NITRO_SUPERSET_ENTRY_NAME = "superset";
105965
- NITRO_COMPILER_DIGEST = true ? "e999d0832c1898ff3a78c55053c6d301b602f5ee78e24312deedc93b4b4451d0" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
106084
+ NITRO_COMPILER_DIGEST = true ? "474b8b30de1650e72f19b75c50a0db7090ddaffdf79752b283fb389946014fa7" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
105966
106085
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
105967
106086
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
105968
106087
  published2 = /* @__PURE__ */ new Map();