peachsim 0.1.726 → 0.1.728

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 (73) hide show
  1. package/cli/outbound-endpoints.ts +7 -0
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/agent-identity.cjs +1 -1
  5. package/dist-lib/agent-sessions.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cli-constants.cjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/home-paths.cjs +1 -1
  29. package/dist-lib/host/bridge-host.cjs +178 -4
  30. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  32. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  33. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  34. package/dist-lib/host/websocket-proxy.cjs +1 -1
  35. package/dist-lib/index.cjs +1 -1
  36. package/dist-lib/jump-to-source-babel.cjs +1 -1
  37. package/dist-lib/jump-to-source-native.cjs +1 -1
  38. package/dist-lib/kotlin-host.cjs +1 -1
  39. package/dist-lib/menu.cjs +1 -1
  40. package/dist-lib/menu.mjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  43. package/dist-lib/metro-production-bundle.cjs +1 -1
  44. package/dist-lib/metro-production-bundle.mjs +1 -1
  45. package/dist-lib/metro.cjs +1 -1
  46. package/dist-lib/native-app-identity.cjs +1 -1
  47. package/dist-lib/native-app-identity.mjs +1 -1
  48. package/dist-lib/native-firebase-metadata.cjs +1 -1
  49. package/dist-lib/native-firebase-metadata.mjs +1 -1
  50. package/dist-lib/plist.cjs +1 -1
  51. package/dist-lib/plist.mjs +1 -1
  52. package/dist-lib/profiles.cjs +1 -1
  53. package/dist-lib/public-brand.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.cjs +1 -1
  55. package/dist-lib/react-native-host-modules.mjs +1 -1
  56. package/dist-lib/render-mode.cjs +1 -1
  57. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  58. package/dist-lib/sdk.cjs +1 -1
  59. package/dist-lib/sdk.mjs +1 -1
  60. package/dist-lib/skills.cjs +181 -5
  61. package/dist-lib/swift-compile.cjs +179 -3
  62. package/dist-lib/swift-compile.mjs +178 -3
  63. package/dist-lib/swift-package.cjs +1 -1
  64. package/dist-lib/swift-package.mjs +1 -1
  65. package/dist-lib/swift-submit.cjs +2 -2
  66. package/dist-lib/swift-submit.mjs +2 -2
  67. package/dist-lib/swift-toolchain.cjs +1 -1
  68. package/dist-lib/swift.cjs +1 -1
  69. package/dist-lib/vite-swift.cjs +178 -4
  70. package/dist-lib/vite.cjs +1 -1
  71. package/package.json +1 -1
  72. package/src/swift-compile.ts +214 -2
  73. package/src/swift-submit.ts +2 -1
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (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;
@@ -51,7 +51,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
51
51
  var MAX_SWIFT_COMPILE_IMAGES = 128;
52
52
  var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
53
53
  var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
54
- var SWIFT_HOST_ABI = 20;
54
+ var SWIFT_HOST_ABI = 21;
55
55
  var POLL_INTERVAL_MS = 1500;
56
56
  function swiftNativeEntry(native, file) {
57
57
  return {
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/swift-submit.ts
4
4
  var SWIFT_COMPILE_PATH = "/api/swift-compile";
@@ -12,7 +12,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
12
12
  var MAX_SWIFT_COMPILE_IMAGES = 128;
13
13
  var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
14
14
  var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
15
- var SWIFT_HOST_ABI = 20;
15
+ var SWIFT_HOST_ABI = 21;
16
16
  var POLL_INTERVAL_MS = 1500;
17
17
  function swiftNativeEntry(native, file) {
18
18
  return {
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (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;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (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.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (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;
@@ -484,7 +484,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
484
484
  var MULTI_MANIFEST_VERSION = 10;
485
485
  function swiftArtifactHash(input, release, moduleRoot) {
486
486
  const hash = (0, import_node_crypto2.createHash)("sha256");
487
- hash.update(`swift-compile/v13
487
+ hash.update(`swift-compile/v14
488
488
  ${release}
489
489
  `);
490
490
  if (input.oneModule) hash.update("one-module\n");
@@ -789,6 +789,180 @@ function liftExtensionOverrides(source) {
789
789
  out = out.slice(0, at) + insert + out.slice(at + remove);
790
790
  return out;
791
791
  }
792
+ function lowerAnyObjectDoubleValue(source) {
793
+ const masked = swiftCodeMask(source);
794
+ const names = /* @__PURE__ */ new Set();
795
+ const binding = /(?:\blet\b|\bvar\b)\s+([A-Za-z_]\w*)\s*=[^\n;{}]*?\bas[?!]?\s*AnyObject\??(?=\s*(?:[,;{]|\belse\b|$))/gm;
796
+ const declared = /(?:\blet\b|\bvar\b)\s+([A-Za-z_]\w*)\s*:\s*AnyObject\b/g;
797
+ const parameter = /[(,]\s*(?:[A-Za-z_]\w*\s+)?([A-Za-z_]\w*)\s*:\s*AnyObject\??(?=\s*[,)=])/g;
798
+ for (const pattern of [binding, declared, parameter]) {
799
+ pattern.lastIndex = 0;
800
+ for (let found = pattern.exec(masked); found; found = pattern.exec(masked))
801
+ names.add(found[1]);
802
+ }
803
+ const edits = [];
804
+ const member = /\.\s*doubleValue\b/g;
805
+ let hit;
806
+ while ((hit = member.exec(masked)) !== null) {
807
+ const memberEnd = hit.index + hit[0].length;
808
+ let j = hit.index - 1;
809
+ while (j >= 0 && /\s/.test(masked[j])) j--;
810
+ if (masked[j] === "?" || masked[j] === "!") {
811
+ j--;
812
+ while (j >= 0 && /\s/.test(masked[j])) j--;
813
+ }
814
+ if (masked[j] === ")") {
815
+ const close = j;
816
+ let depth = 0;
817
+ let open = -1;
818
+ for (let k = close; k >= 0; k--) {
819
+ if (masked[k] === ")") depth++;
820
+ else if (masked[k] === "(" && --depth === 0) {
821
+ open = k;
822
+ break;
823
+ }
824
+ }
825
+ if (open === -1) continue;
826
+ const inner = masked.slice(open + 1, close);
827
+ const cast = /^(?:\s*(?:try\b|await\b))*\s*([\s\S]*?)\bas[?!]?\s*AnyObject\??\s*$/.exec(inner);
828
+ if (!cast) continue;
829
+ const expression = source.slice(open + 1, open + 1 + cast[1].length).replace(/\s+$/, "");
830
+ const hoisted = /^\s*((?:try\b\s*|await\s*)+)([\s\S]*)$/.exec(expression);
831
+ edits.push([
832
+ open,
833
+ memberEnd - open,
834
+ `${hoisted ? hoisted[1] : ""}_objcNumber(${hoisted ? hoisted[2] : expression})`
835
+ ]);
836
+ continue;
837
+ }
838
+ const head = masked.slice(0, j + 1);
839
+ const selfed = /(?:^|[^\w$])self\s*\.\s*([A-Za-z_]\w*)$/.exec(head);
840
+ if (selfed) {
841
+ if (!names.has(selfed[1])) continue;
842
+ const receiver = selfed[0].replace(/^[^\w$]+/, "");
843
+ edits.push([
844
+ j + 1 - receiver.length,
845
+ memberEnd - (j + 1 - receiver.length),
846
+ `_objcNumber(${receiver})`
847
+ ]);
848
+ continue;
849
+ }
850
+ const named = /([A-Za-z_]\w*)$/.exec(head);
851
+ if (!named || !names.has(named[1])) continue;
852
+ const nameStart = j + 1 - named[1].length;
853
+ let before = nameStart - 1;
854
+ while (before >= 0 && /\s/.test(masked[before])) before--;
855
+ if (masked[before] === ".") continue;
856
+ edits.push([nameStart, memberEnd - nameStart, `_objcNumber(${named[1]})`]);
857
+ }
858
+ let out = source;
859
+ for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
860
+ out = out.slice(0, at) + insert + out.slice(at + remove);
861
+ return out;
862
+ }
863
+ function swiftCodeMask(source) {
864
+ const chars = source.split("");
865
+ const blank = (from, to) => {
866
+ for (let i = Math.max(0, from); i < Math.min(to, chars.length); i++)
867
+ if (chars[i] !== "\n") chars[i] = " ";
868
+ };
869
+ const hashesAt = (at) => {
870
+ let end = at;
871
+ while (source[end] === "#") end++;
872
+ return end - at;
873
+ };
874
+ const scanString = (quote, hashes) => {
875
+ const multiline = source.startsWith('"""', quote);
876
+ let i = quote + (multiline ? 3 : 1);
877
+ const keep = [];
878
+ const quoteEnd = (at) => {
879
+ const mark = multiline ? '"""' : '"';
880
+ return source.startsWith(mark, at) && source.startsWith("#".repeat(hashes), at + mark.length);
881
+ };
882
+ while (i < chars.length) {
883
+ if (source[i] === "\\" && source.startsWith("#".repeat(hashes), i + 1) && source[i + 1 + hashes] === "(") {
884
+ const codeStart = i + 2 + hashes;
885
+ const codeEnd = scanCode(codeStart, true);
886
+ keep.push([codeStart, codeEnd]);
887
+ i = codeEnd + 1;
888
+ continue;
889
+ }
890
+ if (quoteEnd(i)) {
891
+ const close = i + (multiline ? 3 : 1) + hashes;
892
+ let cursor = quote - hashes;
893
+ for (const [from, to] of [...keep, [close, close]])
894
+ if (from > cursor) {
895
+ blank(cursor, from);
896
+ cursor = to;
897
+ } else cursor = Math.max(cursor, to);
898
+ return close;
899
+ }
900
+ i++;
901
+ }
902
+ blank(quote - hashes, chars.length);
903
+ return chars.length;
904
+ };
905
+ const scanCode = (i, nested) => {
906
+ let parens = 0;
907
+ while (i < chars.length) {
908
+ const char = source[i];
909
+ if (char === "/" && source[i + 1] === "/") {
910
+ const end = source.indexOf("\n", i);
911
+ blank(i, end === -1 ? chars.length : end);
912
+ i = end === -1 ? chars.length : end;
913
+ continue;
914
+ }
915
+ if (char === "/" && source[i + 1] === "*") {
916
+ let j = i + 2;
917
+ let depth = 1;
918
+ while (j < chars.length && depth > 0) {
919
+ if (source.startsWith("/*", j)) {
920
+ depth++;
921
+ j += 2;
922
+ } else if (source.startsWith("*/", j)) {
923
+ depth--;
924
+ j += 2;
925
+ } else j++;
926
+ }
927
+ blank(i, j);
928
+ i = j;
929
+ continue;
930
+ }
931
+ if (char === "#") {
932
+ const hashes = hashesAt(i);
933
+ const at = i + hashes;
934
+ if (source[at] === '"') {
935
+ i = scanString(at, hashes);
936
+ continue;
937
+ }
938
+ if (hashes > 0 && source[at] === "/") {
939
+ const mark = "#".repeat(hashes);
940
+ let j = at + 1;
941
+ while (j < chars.length && !(source[j] === "/" && source.startsWith(mark, j + 1)))
942
+ j++;
943
+ blank(i, Math.min(chars.length, j + 1 + hashes));
944
+ i = Math.min(chars.length, j + 1 + hashes);
945
+ continue;
946
+ }
947
+ i++;
948
+ continue;
949
+ }
950
+ if (char === '"') {
951
+ i = scanString(i, 0);
952
+ continue;
953
+ }
954
+ if (char === "(") parens++;
955
+ else if (char === ")") {
956
+ if (nested && parens === 0) return i;
957
+ parens--;
958
+ }
959
+ i++;
960
+ }
961
+ return i;
962
+ };
963
+ scanCode(0, false);
964
+ return chars.join("");
965
+ }
792
966
  function swiftSourceAsIOS(original) {
793
967
  const source = liftExtensionOverrides(original);
794
968
  const { lineStarts, tokens } = swiftCodeScan(source);
@@ -863,7 +1037,7 @@ function swiftSourceAsIOS(original) {
863
1037
  out += conditioned.slice(copied, at) + replacement;
864
1038
  copied = at + match[0].length;
865
1039
  }
866
- return out + conditioned.slice(copied);
1040
+ return lowerAnyObjectDoubleValue(out + conditioned.slice(copied));
867
1041
  }
868
1042
  function swiftCodeScan(source) {
869
1043
  const starts = /* @__PURE__ */ new Set();
@@ -1924,7 +2098,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
1924
2098
  var MAX_SWIFT_COMPILE_IMAGES = 128;
1925
2099
  var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
1926
2100
  var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
1927
- var SWIFT_HOST_ABI = 20;
2101
+ var SWIFT_HOST_ABI = 21;
1928
2102
  var POLL_INTERVAL_MS = 1500;
1929
2103
  function swiftNativeEntry(native, file) {
1930
2104
  return {
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.726 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.728 | (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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.726",
3
+ "version": "0.1.728",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -323,6 +323,7 @@ export function swiftArtifactHash(
323
323
  moduleRoot: string,
324
324
  ): string {
325
325
  const hash = createHash('sha256')
326
+ // v14: AnyObject doubleValue lowers to the typed _objcNumber getter
326
327
  // v13: implicit target resources synthesize Bundle.module
327
328
  // v12: overrides in an extension of a same-file class lift into the class
328
329
  // v10: Foundation-only sources see Dispatch queues
@@ -332,7 +333,7 @@ export function swiftArtifactHash(
332
333
  // v6: app and scene delegate classes compile final
333
334
  // (v5: a target declaring resources gets SwiftPM's Bundle.module accessor;
334
335
  // v4: sources compile through swiftSourceAsIOS)
335
- hash.update(`swift-compile/v13\n${release}\n`)
336
+ hash.update(`swift-compile/v14\n${release}\n`)
336
337
  if (input.oneModule) hash.update('one-module\n')
337
338
  hash.update(swiftModuleDigest(moduleRoot))
338
339
  for (const file of Object.keys(input.files).sort()) {
@@ -761,6 +762,217 @@ function liftExtensionOverrides(source: string): string {
761
762
  return out
762
763
  }
763
764
 
765
+ // wasm Swift has no ObjC runtime, so a member read on AnyObject never
766
+ // resolves: `value of type 'AnyObject' has no member 'doubleValue'`. native
767
+ // code that bridges dictionary values through AnyObject to reach NSNumber's
768
+ // getter lowers here to the typed getter PeachObjC already dispatches
769
+ // (_objcNumber): `name.doubleValue` where name binds `as?`/`as!`/`as`
770
+ // AnyObject or declares `: AnyObject` (a `self.` prefix is the same
771
+ // variable), and `(expression as? AnyObject)?.doubleValue`, become
772
+ // `_objcNumber(name)` and `_objcNumber(expression)`. both read Double?, as
773
+ // natively, so `guard let` and `??` around them keep their meaning. a `try`
774
+ // or `await` on a cast expression hoists in front of the call. a concrete
775
+ // receiver (NSNumber, JSON, a dotted member), a multi-line `let`
776
+ // initializer, and anything in a string, comment or regex stay as written.
777
+ export function lowerAnyObjectDoubleValue(source: string): string {
778
+ const masked = swiftCodeMask(source)
779
+ const names = new Set<string>()
780
+ const binding =
781
+ /(?:\blet\b|\bvar\b)\s+([A-Za-z_]\w*)\s*=[^\n;{}]*?\bas[?!]?\s*AnyObject\??(?=\s*(?:[,;{]|\belse\b|$))/gm
782
+ const declared = /(?:\blet\b|\bvar\b)\s+([A-Za-z_]\w*)\s*:\s*AnyObject\b/g
783
+ const parameter =
784
+ /[(,]\s*(?:[A-Za-z_]\w*\s+)?([A-Za-z_]\w*)\s*:\s*AnyObject\??(?=\s*[,)=])/g
785
+ for (const pattern of [binding, declared, parameter]) {
786
+ pattern.lastIndex = 0
787
+ for (let found = pattern.exec(masked); found; found = pattern.exec(masked))
788
+ names.add(found[1]!)
789
+ }
790
+ const edits: [number, number, string][] = []
791
+ const member = /\.\s*doubleValue\b/g
792
+ let hit: RegExpExecArray | null
793
+ while ((hit = member.exec(masked)) !== null) {
794
+ const memberEnd = hit.index + hit[0].length
795
+ let j = hit.index - 1
796
+ while (j >= 0 && /\s/.test(masked[j]!)) j--
797
+ // `?.` and `!` unwrap an optional AnyObject to the same getter input
798
+ if (masked[j] === '?' || masked[j] === '!') {
799
+ j--
800
+ while (j >= 0 && /\s/.test(masked[j]!)) j--
801
+ }
802
+ if (masked[j] === ')') {
803
+ const close = j
804
+ let depth = 0
805
+ let open = -1
806
+ for (let k = close; k >= 0; k--) {
807
+ if (masked[k] === ')') depth++
808
+ else if (masked[k] === '(' && --depth === 0) {
809
+ open = k
810
+ break
811
+ }
812
+ }
813
+ if (open === -1) continue
814
+ const inner = masked.slice(open + 1, close)
815
+ const cast =
816
+ /^(?:\s*(?:try\b|await\b))*\s*([\s\S]*?)\bas[?!]?\s*AnyObject\??\s*$/.exec(inner)
817
+ if (!cast) continue
818
+ const expression = source
819
+ .slice(open + 1, open + 1 + cast[1]!.length)
820
+ .replace(/\s+$/, '')
821
+ const hoisted = /^\s*((?:try\b\s*|await\s*)+)([\s\S]*)$/.exec(expression)
822
+ edits.push([
823
+ open,
824
+ memberEnd - open,
825
+ `${hoisted ? hoisted[1] : ''}_objcNumber(${hoisted ? hoisted[2] : expression})`,
826
+ ])
827
+ continue
828
+ }
829
+ const head = masked.slice(0, j + 1)
830
+ // `self.name` names the same variable a tracked `name` declares
831
+ const selfed = /(?:^|[^\w$])self\s*\.\s*([A-Za-z_]\w*)$/.exec(head)
832
+ if (selfed) {
833
+ if (!names.has(selfed[1]!)) continue
834
+ const receiver = selfed[0].replace(/^[^\w$]+/, '')
835
+ edits.push([
836
+ j + 1 - receiver.length,
837
+ memberEnd - (j + 1 - receiver.length),
838
+ `_objcNumber(${receiver})`,
839
+ ])
840
+ continue
841
+ }
842
+ const named = /([A-Za-z_]\w*)$/.exec(head)
843
+ if (!named || !names.has(named[1]!)) continue
844
+ const nameStart = j + 1 - named[1]!.length
845
+ let before = nameStart - 1
846
+ while (before >= 0 && /\s/.test(masked[before]!)) before--
847
+ // a dotted member receiver (`a.b.doubleValue`) has an unknown type
848
+ if (masked[before] === '.') continue
849
+ edits.push([nameStart, memberEnd - nameStart, `_objcNumber(${named[1]})`])
850
+ }
851
+ let out = source
852
+ for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
853
+ out = out.slice(0, at) + insert + out.slice(at + remove)
854
+ return out
855
+ }
856
+
857
+ // the index-preserving view lowerAnyObjectDoubleValue matches on: every
858
+ // char outside code (comments, strings, regex literals) reads as a space,
859
+ // so an identifier that survives is code. newlines stay, keeping every
860
+ // offset valid in both views.
861
+ function swiftCodeMask(source: string): string {
862
+ const chars = source.split('')
863
+ const blank = (from: number, to: number): void => {
864
+ for (let i = Math.max(0, from); i < Math.min(to, chars.length); i++)
865
+ if (chars[i] !== '\n') chars[i] = ' '
866
+ }
867
+ const hashesAt = (at: number): number => {
868
+ let end = at
869
+ while (source[end] === '#') end++
870
+ return end - at
871
+ }
872
+ const scanString = (quote: number, hashes: number): number => {
873
+ const multiline = source.startsWith('"""', quote)
874
+ let i = quote + (multiline ? 3 : 1)
875
+ const keep: [number, number][] = []
876
+ const quoteEnd = (at: number): boolean => {
877
+ const mark = multiline ? '"""' : '"'
878
+ return (
879
+ source.startsWith(mark, at) &&
880
+ source.startsWith('#'.repeat(hashes), at + mark.length)
881
+ )
882
+ }
883
+ while (i < chars.length) {
884
+ if (
885
+ source[i] === '\\' &&
886
+ source.startsWith('#'.repeat(hashes), i + 1) &&
887
+ source[i + 1 + hashes] === '('
888
+ ) {
889
+ const codeStart = i + 2 + hashes
890
+ const codeEnd = scanCode(codeStart, true)
891
+ keep.push([codeStart, codeEnd])
892
+ i = codeEnd + 1
893
+ continue
894
+ }
895
+ if (quoteEnd(i)) {
896
+ const close = i + (multiline ? 3 : 1) + hashes
897
+ let cursor = quote - hashes
898
+ for (const [from, to] of [...keep, [close, close] as [number, number]])
899
+ if (from > cursor) {
900
+ blank(cursor, from)
901
+ cursor = to
902
+ } else cursor = Math.max(cursor, to)
903
+ return close
904
+ }
905
+ i++
906
+ }
907
+ blank(quote - hashes, chars.length)
908
+ return chars.length
909
+ }
910
+ // an interpolation's `)` ends the scan only when no paren is open inside
911
+ const scanCode = (i: number, nested: boolean): number => {
912
+ let parens = 0
913
+ while (i < chars.length) {
914
+ const char = source[i]!
915
+ if (char === '/' && source[i + 1] === '/') {
916
+ const end = source.indexOf('\n', i)
917
+ blank(i, end === -1 ? chars.length : end)
918
+ i = end === -1 ? chars.length : end
919
+ continue
920
+ }
921
+ if (char === '/' && source[i + 1] === '*') {
922
+ let j = i + 2
923
+ let depth = 1
924
+ while (j < chars.length && depth > 0) {
925
+ if (source.startsWith('/*', j)) {
926
+ depth++
927
+ j += 2
928
+ } else if (source.startsWith('*/', j)) {
929
+ depth--
930
+ j += 2
931
+ } else j++
932
+ }
933
+ blank(i, j)
934
+ i = j
935
+ continue
936
+ }
937
+ if (char === '#') {
938
+ const hashes = hashesAt(i)
939
+ const at = i + hashes
940
+ if (source[at] === '"') {
941
+ i = scanString(at, hashes)
942
+ continue
943
+ }
944
+ if (hashes > 0 && source[at] === '/') {
945
+ const mark = '#'.repeat(hashes)
946
+ let j = at + 1
947
+ while (
948
+ j < chars.length &&
949
+ !(source[j] === '/' && source.startsWith(mark, j + 1))
950
+ )
951
+ j++
952
+ blank(i, Math.min(chars.length, j + 1 + hashes))
953
+ i = Math.min(chars.length, j + 1 + hashes)
954
+ continue
955
+ }
956
+ i++
957
+ continue
958
+ }
959
+ if (char === '"') {
960
+ i = scanString(i, 0)
961
+ continue
962
+ }
963
+ if (char === '(') parens++
964
+ else if (char === ')') {
965
+ if (nested && parens === 0) return i
966
+ parens--
967
+ }
968
+ i++
969
+ }
970
+ return i
971
+ }
972
+ scanCode(0, false)
973
+ return chars.join('')
974
+ }
975
+
764
976
  export function swiftSourceAsIOS(original: string): string {
765
977
  const source = liftExtensionOverrides(original)
766
978
  const { lineStarts, tokens } = swiftCodeScan(source)
@@ -843,7 +1055,7 @@ export function swiftSourceAsIOS(original: string): string {
843
1055
  out += conditioned.slice(copied, at) + replacement
844
1056
  copied = at + match[0].length
845
1057
  }
846
- return out + conditioned.slice(copied)
1058
+ return lowerAnyObjectDoubleValue(out + conditioned.slice(copied))
847
1059
  }
848
1060
 
849
1061
  // the offsets of the lines that begin in code, and of every `@`, `#`,
@@ -67,8 +67,9 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
67
67
  * answered cancel carry the browser's resource timing for URLSessionTaskMetrics.
68
68
  * 19: synchronous UIImage/ImageIO bitmap decode, frame sources and context drawing.
69
69
  * 20: peach_codec provides synchronous streaming Brotli and zlib decoders.
70
+ * 21: the system environment supplies UIKitCore's semantic color components.
70
71
  */
71
- export const SWIFT_HOST_ABI = 20
72
+ export const SWIFT_HOST_ABI = 21
72
73
 
73
74
  export interface SwiftImageUpload {
74
75
  /** the raster file picked for the asset (has the extension). */