peachsim 0.1.2252 → 0.1.2255

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 (120) hide show
  1. package/cli/commands/compat.ts +1 -1
  2. package/cli/commands/control.ts +1 -1
  3. package/cli/commands/package.ts +1 -1
  4. package/cli/commands/runtime.ts +1 -1
  5. package/cli/commands/upgrade.ts +2 -5
  6. package/cli/commands/version.ts +1 -1
  7. package/cli/native-input.ts +1 -1
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/bundle-channel.cjs +2927 -2218
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +16 -1
  30. package/dist-lib/config.mjs +14 -1
  31. package/dist-lib/detox/index.cjs +2 -2
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/expo-swift-bundle.cjs +3110 -2402
  34. package/dist-lib/expo-swift-metadata.cjs +1 -1
  35. package/dist-lib/expo-swift-metadata.mjs +1 -1
  36. package/dist-lib/home-paths.cjs +1 -1
  37. package/dist-lib/host/bridge-host.cjs +2995 -2275
  38. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  39. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  41. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  42. package/dist-lib/host/websocket-proxy.cjs +1 -1
  43. package/dist-lib/index.cjs +2785 -2643
  44. package/dist-lib/jump-to-source-babel.cjs +1 -1
  45. package/dist-lib/jump-to-source-native.cjs +1 -1
  46. package/dist-lib/kotlin-host.cjs +3 -2
  47. package/dist-lib/menu.cjs +1 -1
  48. package/dist-lib/menu.mjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  51. package/dist-lib/metro-production-bundle.cjs +1 -1
  52. package/dist-lib/metro-production-bundle.mjs +1 -1
  53. package/dist-lib/metro.cjs +126 -42
  54. package/dist-lib/native-app-identity-project.cjs +2 -2
  55. package/dist-lib/native-app-identity-project.mjs +2 -3
  56. package/dist-lib/native-app-identity.cjs +1 -1
  57. package/dist-lib/native-app-identity.mjs +1 -1
  58. package/dist-lib/native-firebase-metadata.cjs +1 -1
  59. package/dist-lib/native-firebase-metadata.mjs +1 -1
  60. package/dist-lib/pdfium-raster.cjs +1 -1
  61. package/dist-lib/pdfium-raster.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +24 -24
  67. package/dist-lib/public-origins-lib.json +126 -114
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/reap-browser.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +3454 -2736
  75. package/dist-lib/swift-compile.cjs +97 -31
  76. package/dist-lib/swift-compile.mjs +100 -31
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +1 -1
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +2203 -1517
  84. package/dist-lib/vite.cjs +4804 -3498
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  88. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
  89. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
  90. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +33 -1
  91. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  92. package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +11 -0
  93. package/kotlin/sdk.tar.gz +0 -0
  94. package/package.json +1 -1
  95. package/runtime-companion.json +1 -1
  96. package/sdk/ios/wasm/include/__typedef_time_t.h +5 -0
  97. package/sdk/ios/wasm/include/ifaddrs.h +75 -0
  98. package/sdk/ios/wasm/include/machine/_types.h +1 -1
  99. package/sdk/ios/wasm/include/pthread.h +4 -0
  100. package/sdk/ios/wasm/include/unistd.h +2 -0
  101. package/{cli → src}/app-config.ts +5 -5
  102. package/src/bundle-channel.mjs +1 -1
  103. package/src/config.ts +29 -0
  104. package/src/core-data-entity-classes.ts +2 -2
  105. package/src/core-data-model.ts +681 -0
  106. package/src/expo-swift-host.ts +1 -1
  107. package/src/kotlin-host.ts +2 -1
  108. package/src/metro-plugin.ts +1 -3
  109. package/src/nitro-adapter.lock.json +236 -236
  110. package/src/nitro-bundle.ts +1 -1
  111. package/src/nitro-superset.lock.json +4 -4
  112. package/src/plist-bytes.ts +113 -0
  113. package/src/runtime-delivery.ts +3 -2
  114. package/src/swift-compile.ts +8 -1
  115. package/src/swift-distribution.lock.json +11 -11
  116. package/src/swift-guest-image-ledger.ts +2 -1
  117. package/src/swift-host.ts +18 -3
  118. package/src/turbo-bundle.ts +1 -1
  119. package/src/turbo-runtime.lock.json +20 -20
  120. package/src/vite-plugin-one.ts +68 -0
@@ -7,3 +7,116 @@ export function parsePlistBytes(source: Uint8Array): unknown {
7
7
  ? binaryPlist.parseBuffer<unknown>(bytes)[0]
8
8
  : parsePlistSource(bytes.toString('utf8'))
9
9
  }
10
+
11
+ // what the binary writer takes; an undefined dictionary member is left out
12
+ export type BinaryPlistValue =
13
+ | string
14
+ | number
15
+ | boolean
16
+ | Buffer
17
+ | readonly BinaryPlistValue[]
18
+ | BinaryPlistDictionary
19
+ export type BinaryPlistDictionary = { [key: string]: BinaryPlistValue | undefined }
20
+
21
+ const isList = (value: BinaryPlistValue): value is readonly BinaryPlistValue[] =>
22
+ Array.isArray(value)
23
+
24
+ const isUid = (value: BinaryPlistValue): value is { CF$UID: number } =>
25
+ typeof value === 'object' &&
26
+ !isList(value) &&
27
+ !Buffer.isBuffer(value) &&
28
+ Object.keys(value).length === 1 &&
29
+ typeof value['CF$UID'] === 'number'
30
+
31
+ // writes Apple's bplist00, where a { CF$UID } dictionary is an archive uid as in the xml form
32
+ export function buildBinaryPlist(top: BinaryPlistValue): Buffer {
33
+ type Node = { value: BinaryPlistValue; refs: number[] }
34
+ const nodes: Node[] = []
35
+ const visit = (value: BinaryPlistValue): number => {
36
+ const node: Node = { value, refs: [] }
37
+ const index = nodes.push(node) - 1
38
+ if (isList(value)) node.refs = value.map(visit)
39
+ else if (typeof value === 'object' && !Buffer.isBuffer(value) && !isUid(value)) {
40
+ const keys = Object.keys(value).filter((key) => value[key] !== undefined)
41
+ node.refs = [...keys.map(visit), ...keys.map((key) => visit(value[key]!))]
42
+ }
43
+ return index
44
+ }
45
+ visit(top)
46
+ const width = (count: number) => (count < 0x100 ? 1 : count < 0x10000 ? 2 : 4)
47
+ const unsigned = (value: number, size: number) => {
48
+ const bytes = Buffer.alloc(size)
49
+ bytes.writeUIntBE(value, 0, size)
50
+ return bytes
51
+ }
52
+ const integer = (value: number) => {
53
+ if (value < 0 || value >= 0x100000000) {
54
+ const bytes = Buffer.alloc(9)
55
+ bytes[0] = 0x13
56
+ bytes.writeBigInt64BE(BigInt(value), 1)
57
+ return bytes
58
+ }
59
+ const size = width(value)
60
+ return Buffer.concat([Buffer.from([0x10 | Math.log2(size)]), unsigned(value, size)])
61
+ }
62
+ const marker = (high: number, count: number) =>
63
+ count < 15
64
+ ? Buffer.from([high | count])
65
+ : Buffer.concat([Buffer.from([high | 15]), integer(count)])
66
+ const refSize = width(nodes.length)
67
+ const chunks: Buffer[] = [Buffer.from('bplist00')]
68
+ const offsets: number[] = []
69
+ let offset = 8
70
+ for (const { value, refs } of nodes) {
71
+ let bytes: Buffer
72
+ if (typeof value === 'string') {
73
+ bytes =
74
+ Buffer.byteLength(value) === value.length
75
+ ? Buffer.concat([marker(0x50, value.length), Buffer.from(value, 'ascii')])
76
+ : Buffer.concat([
77
+ marker(0x60, value.length),
78
+ Buffer.from(value, 'utf16le').swap16(),
79
+ ])
80
+ } else if (typeof value === 'number') {
81
+ if (Number.isInteger(value)) bytes = integer(value)
82
+ else {
83
+ bytes = Buffer.alloc(9)
84
+ bytes[0] = 0x23
85
+ bytes.writeDoubleBE(value, 1)
86
+ }
87
+ } else if (typeof value === 'boolean') bytes = Buffer.from([value ? 0x09 : 0x08])
88
+ else if (Buffer.isBuffer(value))
89
+ bytes = Buffer.concat([marker(0x40, value.length), value])
90
+ else if (isUid(value)) {
91
+ const size = width(value['CF$UID'])
92
+ bytes = Buffer.concat([
93
+ Buffer.from([0x80 | (size - 1)]),
94
+ unsigned(value['CF$UID'], size),
95
+ ])
96
+ } else {
97
+ const table = Buffer.concat(refs.map((ref) => unsigned(ref, refSize)))
98
+ bytes = Buffer.concat([
99
+ marker(
100
+ isList(value) ? 0xa0 : 0xd0,
101
+ isList(value) ? refs.length : refs.length / 2,
102
+ ),
103
+ table,
104
+ ])
105
+ }
106
+ offsets.push(offset)
107
+ chunks.push(bytes)
108
+ offset += bytes.length
109
+ }
110
+ const offsetSize = width(offset)
111
+ const trailer = Buffer.alloc(32)
112
+ trailer[6] = offsetSize
113
+ trailer[7] = refSize
114
+ trailer.writeBigUInt64BE(BigInt(nodes.length), 8)
115
+ trailer.writeBigUInt64BE(0n, 16)
116
+ trailer.writeBigUInt64BE(BigInt(offset), 24)
117
+ return Buffer.concat([
118
+ ...chunks,
119
+ ...offsets.map((at) => unsigned(at, offsetSize)),
120
+ trailer,
121
+ ])
122
+ }
@@ -11,7 +11,6 @@
11
11
  // out as a bare require.
12
12
 
13
13
  import { createRuntimeDelivery, type RuntimeProduct } from '@contrast/runtime-delivery'
14
- import { ensureCliCompanion } from './cli-runtime'
15
14
  import {
16
15
  cacheDir,
17
16
  configFilePath,
@@ -38,7 +37,9 @@ export const RNX_RUNTIME_PRODUCT: RuntimeProduct = {
38
37
  // engine-tenant/ beneath it. index.html is what the daemon and the
39
38
  // vite/metro plugins serve, so its absence means the tarball is not one.
40
39
  installedMarker: 'index.html',
41
- verifyInstall: ensureCliCompanion,
40
+ // loaded on use: its companion identity is generated by the CLI build, and
41
+ // source-tree hosts such as the recorder import this module without one
42
+ verifyInstall: async (dir) => (await import('./cli-runtime')).ensureCliCompanion(dir),
42
43
  // canvaskit's ganesh backend is a runtime pack because a browser with WebGPU
43
44
  // never runs it, but linux and CI browsers usually have no GPU and always do
44
45
  afterInstall: async (dir) => {
@@ -1047,7 +1047,7 @@ function swiftCondition(
1047
1047
  if (name === 'canImport')
1048
1048
  return argument !== 'FoundationNetworking' && available?.has(argument!)
1049
1049
  if (name === 'targetEnvironment') return argument === 'simulator'
1050
- if (name === 'arch') return argument === 'wasm64'
1050
+ if (name === 'arch') return argument === 'wasm64' || argument === 'arm64'
1051
1051
  return undefined
1052
1052
  }
1053
1053
  const both = (): boolean | undefined => {
@@ -1757,6 +1757,8 @@ const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0"
1757
1757
  "-Xlinker", "--global-base=8372224",
1758
1758
  "-Xlinker", "-lsetjmp",
1759
1759
  "-Xlinker", "--export-table",
1760
+ "-Xlinker", "--export-if-defined=__cpp_exception",
1761
+ "-Xlinker", "--export-if-defined=__objc_wasm_terminate",
1760
1762
  "-Xlinker", "--growable-table",
1761
1763
  "-Xlinker", "--wrap=swift_udata_open",
1762
1764
  "-Xlinker", "--wrap=swift_udata_openChoice",
@@ -2614,6 +2616,10 @@ export function syncSwiftTree(base: string, files: Map<string, string | Buffer>)
2614
2616
  // objective-c syntax is compiled unchanged by the native importer.
2615
2617
  const DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/
2616
2618
  const OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g
2619
+ // the guest is the arm64 iOS simulator at 64-bit pointers: the compiler reports wasm64, so a
2620
+ // package that lists only the architectures its iOS build runs on would reach its
2621
+ // `#error("Unknown architecture")`
2622
+ const ARCH_ARM64 = /\barch\(\s*arm64\s*\)/g
2617
2623
  // iOS has no FoundationNetworking module; Peach's is imported implicitly
2618
2624
  // and gated packages must take their Apple branch
2619
2625
  const NOT_ON_IOS = /\b(?:os\(\s*WASI\s*\)|canImport\(\s*FoundationNetworking\s*\))/g
@@ -3379,6 +3385,7 @@ function swiftConditionsAsIOS(
3379
3385
  if (!lineStarts.has(start) || !DIRECTIVE.test(line)) return line
3380
3386
  const platform = line
3381
3387
  .replace(OS_IOS, (match) => 'true'.padEnd(match.length))
3388
+ .replace(ARCH_ARM64, (match) => 'true'.padEnd(match.length))
3382
3389
  .replace(NOT_ON_IOS, (match) => 'false'.padEnd(match.length))
3383
3390
  // SwiftPM is the backend for Xcode targets, whose original conditions
3384
3391
  // do not include its automatically injected SWIFT_PACKAGE definition.
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "7eb5f6473249e4be",
2
+ "id": "fab4e40b5d51a4ba",
3
3
  "release": "swift-6.4.0-RELEASE-custom-fb42d2535739dfd2",
4
- "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-11784d37",
5
- "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-11784d37.artifactbundle.tar.gz",
6
- "wasmSdkChecksum": "2f79c08f5df1a4c36803d1555e874d37d30c39f6f5f6c03c515812a5b71d2bbf",
7
- "source": "b033ae3fac6f9f1611d574a458b54741e896cd40",
4
+ "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-4dcccce1",
5
+ "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-4dcccce1.artifactbundle.tar.gz",
6
+ "wasmSdkChecksum": "a1139bae6549a600a3fbc3c8d6032f5a6b4c3392a64f5d1ece867a6ac11ce92b",
7
+ "source": "eb5014e2cbd517b63594b28184e7c67a060e2ea1",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -245,16 +245,16 @@
245
245
  },
246
246
  "hosts": {
247
247
  "darwin-arm64": {
248
- "sha256": "281e3145afea5c5d9e4d08c660f45a91fc072f118aa0a78458e74394f45e4330",
249
- "size": 106751604
248
+ "sha256": "be97d84d3b601245b49be90a91fde03ed4055b0402ae800a4a4f2ad6e78cec8e",
249
+ "size": 106980477
250
250
  },
251
251
  "linux-x64": {
252
- "sha256": "d81c05a287ed825b0a9ffbb3de04e1205910208d22d6e5723e4419c113f206f5",
253
- "size": 109470691
252
+ "sha256": "a095dc9030a4c72a4e3c2d6fa9c835801e7cfba7423afc6548d69131bfe916ee",
253
+ "size": 109699290
254
254
  },
255
255
  "linux-arm64": {
256
- "sha256": "c160405784418e52304a5ee2f58f30dd0cfc5921f29d51d0105e2fc1edddf418",
257
- "size": 108958717
256
+ "sha256": "0690fd9cdfc637b0353b27ed449c9d40885370edd269d023935102bfcab9dc6c",
257
+ "size": 109192596
258
258
  }
259
259
  }
260
260
  }
@@ -595,7 +595,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
595
595
  const objects = units.map(({ image, object, aliases, functionImports }) => {
596
596
  const shared = bindingsByImage.get(image)!
597
597
  const own = startup.get(object.path)
598
- const bindings = own ? new Map([...shared, ...own]) : shared
598
+ let bindings = own ? new Map([...shared, ...own]) : shared
599
599
  for (const [name, type] of functionImports) {
600
600
  const alias = bindings.get(name)
601
601
  const provider = alias === undefined ? undefined : definitionsByAlias.get(alias)
@@ -618,6 +618,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
618
618
  }
619
619
  resultWrappers.set(key, wrapper)
620
620
  }
621
+ if (bindings === shared) bindings = new Map(shared)
621
622
  bindings.set(name, wrapper.symbol)
622
623
  }
623
624
  return {
package/src/swift-host.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  } from '../../sootsim-swift/src/bundleAssets'
16
16
  import { compileStringCatalog } from '../../sootsim-swift/src/stringCatalog'
17
17
  import { coreDataSources } from './core-data-entity-classes'
18
+ import { compileCoreDataModel, coreDataModelDirectories } from './core-data-model'
18
19
  import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
19
20
  import { type NativeAppIdentity } from './native-app-identity'
20
21
  import { readNativeAppIdentityFromXcodeTarget } from './native-app-identity-project'
@@ -2065,6 +2066,8 @@ export function buildSwiftResourceTable(
2065
2066
  let bytes: Buffer
2066
2067
  let ext = path.posix.extname(file).toLowerCase()
2067
2068
  let uploadName = path.posix.basename(file)
2069
+ // an svg keeps its point size when it travels as a 3x png
2070
+ let variantScale = scale
2068
2071
  if (ext === '.pdf') {
2069
2072
  const pdfBytes = readPackageFile(project.packagePath, disk, limits.imageBytes)
2070
2073
  const pdfHash = createHash('sha256').update(pdfBytes).digest('hex')
@@ -2086,6 +2089,7 @@ export function buildSwiftResourceTable(
2086
2089
  : null
2087
2090
  if (svg) {
2088
2091
  bytes = svg.bytes
2092
+ variantScale = 3
2089
2093
  ext = '.png'
2090
2094
  uploadName = `${path.posix.basename(file, path.posix.extname(file))}.png`
2091
2095
  }
@@ -2099,7 +2103,7 @@ export function buildSwiftResourceTable(
2099
2103
  const variants = (bundle[name] ??= [])
2100
2104
  variants.push({
2101
2105
  uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`,
2102
- scale,
2106
+ scale: variantScale,
2103
2107
  ...(renderingMode ? { renderingMode } : {}),
2104
2108
  })
2105
2109
  table[bundlePath] = bundle
@@ -2275,6 +2279,17 @@ export function buildSwiftBundleFiles(
2275
2279
  groups.set(product.path, group)
2276
2280
  }
2277
2281
  for (const [bundlePath, members] of groups) {
2282
+ const prefix = bundlePath === '.' ? '' : `${bundlePath}/`
2283
+ // a package bundle's target files are its resources; the app's sit under Resources
2284
+ const models = [...members]
2285
+ .filter(([key]) => bundlePath !== '.' || key.split('/').includes('Resources'))
2286
+ .map(([, disk]) => disk)
2287
+ for (const model of coreDataModelDirectories(models)) {
2288
+ for (const disk of models.filter((file) => file.startsWith(`${model}${path.sep}`)))
2289
+ watched.push(path.relative(packagePath, disk).split(path.sep).join('/'))
2290
+ for (const [name, bytes] of Object.entries(compileCoreDataModel(model)))
2291
+ addFile(`${prefix}${name}`, bytes)
2292
+ }
2278
2293
  for (const { base, file } of enumerateBundleResources(
2279
2294
  [...members.keys()],
2280
2295
  bundlePath.endsWith('.bundle'),
@@ -2282,12 +2297,12 @@ export function buildSwiftBundleFiles(
2282
2297
  const disk = members.get(file)!
2283
2298
  watched.push(path.relative(packagePath, disk).split(path.sep).join('/'))
2284
2299
  const bytes = readPackageFile(packagePath, disk, limits.resourceBytes)
2285
- addFile(bundlePath === '.' ? base : `${bundlePath}/${base}`, bytes)
2300
+ addFile(`${prefix}${base}`, bytes)
2286
2301
  if (base.endsWith('.xcstrings')) {
2287
2302
  for (const [name, table] of Object.entries(
2288
2303
  compileStringCatalog(bytes.toString('utf8'), base.slice(0, -10)),
2289
2304
  )) {
2290
- addFile(bundlePath === '.' ? name : `${bundlePath}/${name}`, Buffer.from(table))
2305
+ addFile(`${prefix}${name}`, Buffer.from(table))
2291
2306
  }
2292
2307
  }
2293
2308
  }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module'
2
2
  import path from 'node:path'
3
- import { loadRNXAppConfig } from '../cli/app-config'
4
3
  import { resolveAppProject } from '../cli/app-project'
4
+ import { loadRNXAppConfig } from './app-config'
5
5
  import { prebuiltExpoNative } from './expo-native-prebuilt'
6
6
  import { prepareNativeAppRoot } from './expo-native-workspace'
7
7
  import { installedNativeLibraries } from './installed-native-libraries'
@@ -8,11 +8,11 @@
8
8
  },
9
9
  "compiler": "swift-6.4.0-RELEASE-custom-fb42d2535739dfd2",
10
10
  "sdk": {
11
- "id": "swift-6.4.0-RELEASE_wasm-peach-11784d37",
12
- "checksum": "2f79c08f5df1a4c36803d1555e874d37d30c39f6f5f6c03c515812a5b71d2bbf"
11
+ "id": "swift-6.4.0-RELEASE_wasm-peach-4dcccce1",
12
+ "checksum": "a1139bae6549a600a3fbc3c8d6032f5a6b4c3392a64f5d1ece867a6ac11ce92b"
13
13
  },
14
14
  "framework": {
15
- "distribution": "7eb5f6473249e4be",
15
+ "distribution": "fab4e40b5d51a4ba",
16
16
  "wireAbi": "38eed69f6b7391584112981b7892914e7033d7e0c17c2e8d4a4448030618bd2b"
17
17
  },
18
18
  "archives": [
@@ -20,71 +20,71 @@
20
20
  "headers": {
21
21
  "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
22
  },
23
- "sha256": "ec1db15c0c1cdafcfbb0d6e46b70218479e7987e46db0fecbb12e3227fb557f0",
24
- "size": 26171
23
+ "sha256": "db2fc1e28dab37c75aebd1e806c75f96c8a4b09dd3da246499280d93c6ac22f3",
24
+ "size": 26175
25
25
  },
26
26
  {
27
27
  "headers": {
28
28
  "reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
29
29
  },
30
- "sha256": "27eba9bd34fbdc8c80ebfc192b31b3ee89d027d2ae9816b7ada54e3de42c3d8b",
31
- "size": 26913
30
+ "sha256": "cb39ce60008d8b1ee55b85d3765739cd6f2dd8c3088cae9954935405c32b29c0",
31
+ "size": 26911
32
32
  },
33
33
  {
34
34
  "headers": {
35
35
  "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
36
36
  },
37
- "sha256": "78831ce6c2e1fe1d164998aead5bbfc1283c31250426f6ee06311ba56551f802",
38
- "size": 26167
37
+ "sha256": "c9015a121ee6cde5589ba8b3cd8d77a2534b6fe74360bd195231eed3eca7f3de",
38
+ "size": 26169
39
39
  },
40
40
  {
41
41
  "headers": {
42
42
  "reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
43
43
  },
44
- "sha256": "9e64875f841d719b3f2b81fc2bd459e4c293f812a60c07d8b811991d443ec97d",
44
+ "sha256": "a409ff8ac07dd2de079f5c772d00b27989d5af2ce0e43417caf8699675e110af",
45
45
  "size": 25954
46
46
  },
47
47
  {
48
48
  "headers": {
49
49
  "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
50
50
  },
51
- "sha256": "68b2b211a2f5c2ed00497fce5e0f433ce76afa96de2cc6ba934343e6e0de06f6",
52
- "size": 26168
51
+ "sha256": "5beab3affe783a710850741e48ddf10311d211614286511034f4e17c0d12f2ca",
52
+ "size": 26175
53
53
  },
54
54
  {
55
55
  "headers": {
56
56
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
57
57
  },
58
- "sha256": "ee90b76a0d9ccbf7056451855820bfef97f39c9b45730155a1bfa160dba85b07",
58
+ "sha256": "f66d579210c50e888d7b56076de1aaf01b3abbb10dbd11dd2f28697fa1973d6d",
59
59
  "size": 26910
60
60
  },
61
61
  {
62
62
  "headers": {
63
63
  "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
64
64
  },
65
- "sha256": "97881f12d2e6168645984291a920961f1667a61bd9c448e546a40456a4cfe9b3",
66
- "size": 26911
65
+ "sha256": "69708a94c93655eebbe88a36c40b00b52ade6914bcea747f68aa42c8caf27b9e",
66
+ "size": 26912
67
67
  },
68
68
  {
69
69
  "headers": {
70
70
  "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
71
71
  },
72
- "sha256": "e97b334fd4105e356bb3958214b52b953928828f31f35c9d273b150736530be1",
73
- "size": 26045
72
+ "sha256": "67be94e46cb799d81221f71ec63b819752429e3dc9b1afd1fda0ec206deb9ee4",
73
+ "size": 26044
74
74
  },
75
75
  {
76
76
  "headers": {
77
77
  "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
78
78
  },
79
- "sha256": "3be1e1c6f5dda70945a1afb2cea67fc1093704c71e20f4eb3d344371fdfea755",
79
+ "sha256": "87f021b0d37edc7569c56548b53ec00aadc03e4d892afbf07589af032a3ebc15",
80
80
  "size": 26911
81
81
  },
82
82
  {
83
83
  "headers": {
84
84
  "reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
85
85
  },
86
- "sha256": "76d5af4649ecf90a32a2c25739747e08deefeebe0054a030c6bc718d872c4625",
87
- "size": 25918
86
+ "sha256": "6e1fff6565c1359e63ff7d8f27557c073bd13497d39bc9c33c801ceabf791ce5",
87
+ "size": 25917
88
88
  }
89
89
  ]
90
90
  }
@@ -18,8 +18,11 @@ import {
18
18
  PACKAGE_VERSIONS_HEADER,
19
19
  } from '@peach/globals/package-versions'
20
20
  import { WebSocket, WebSocketServer } from 'ws'
21
+ import { resolveAppProject } from '../cli/app-project'
22
+ import { loadRNXAppConfig } from './app-config'
21
23
  import { DEFAULT_SOOTSIM_BRIDGE_PORT } from './bridge-constants'
22
24
  import { getCliRuntime } from './cli-runtime'
25
+ import { matchConfigModule, PEACH_WORKSPACE_MODULE_MARKER } from './config'
23
26
  import {
24
27
  launchRnxDesktop,
25
28
  resolveRnxDesktopAppName,
@@ -48,6 +51,7 @@ import { ensureRuntimePackFor } from './runtime-packs'
48
51
  import { SWIFT_HMR_PATH, SWIFT_PACKAGE_PATH } from './swift-submit'
49
52
  import { privateSwiftDistributionRoot } from './swift-toolchain'
50
53
  import { swiftViteLifetime } from './swift-vite-lifetime'
54
+ import type { PeachConfig } from './config'
51
55
  import type { OneWidgetPackage } from './oneWidgetContract'
52
56
  import type { PeachPluginOptions } from './vite'
53
57
  import type { IncomingMessage, ServerResponse } from 'node:http'
@@ -91,8 +95,72 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
91
95
 
92
96
  api: {
93
97
  vxrnNative({ root, dev }: { root: string; dev: boolean }): Plugin {
98
+ let modules: PeachConfig['modules']
94
99
  return {
95
100
  name: 'peach:package-versions',
101
+ async buildStart() {
102
+ if (options.enabled === false || dev) return
103
+ modules = (await loadRNXAppConfig(resolveAppProject(root)))?.modules
104
+ },
105
+ transform(code, id) {
106
+ if (!modules || id.includes('/node_modules/')) return
107
+ const match = matchConfigModule(id.split('?')[0], modules)
108
+ if (!match) return
109
+ // production rolldown reads a module's exports by direct binding, so
110
+ // the tag lists each export name with the local it reads
111
+ const exported: string[] = []
112
+ for (const node of this.parse(code, {
113
+ lang: id.split('?')[0].endsWith('x') ? 'tsx' : 'ts',
114
+ }).body) {
115
+ if (node.type === 'ExportDefaultDeclaration') {
116
+ const declaration = node.declaration
117
+ if (!('id' in declaration) || declaration.id?.type !== 'Identifier')
118
+ throw new Error(
119
+ `${id}: a configured module needs a named default export`,
120
+ )
121
+ exported.push(`default:()=>${declaration.id.name}`)
122
+ } else if (
123
+ node.type === 'ExportNamedDeclaration' &&
124
+ node.exportKind !== 'type'
125
+ ) {
126
+ if (node.source)
127
+ throw new Error(
128
+ `${id}: a configured module cannot re-export from another module`,
129
+ )
130
+ for (const specifier of node.specifiers) {
131
+ const { exported: name, local } = specifier
132
+ if (specifier.exportKind === 'type') continue
133
+ if (local.type !== 'Identifier')
134
+ throw new Error(`${id}: a configured module needs plain exports`)
135
+ exported.push(
136
+ `${JSON.stringify('name' in name ? name.name : name.value)}:()=>${local.name}`,
137
+ )
138
+ }
139
+ const declaration = node.declaration
140
+ if (declaration?.type === 'VariableDeclaration') {
141
+ for (const declarator of declaration.declarations) {
142
+ if (declarator.id.type !== 'Identifier')
143
+ throw new Error(
144
+ `${id}: a configured module needs plain exported variables`,
145
+ )
146
+ exported.push(`${declarator.id.name}:()=>${declarator.id.name}`)
147
+ }
148
+ } else if (
149
+ (declaration?.type === 'FunctionDeclaration' ||
150
+ declaration?.type === 'ClassDeclaration' ||
151
+ declaration?.type === 'TSEnumDeclaration') &&
152
+ declaration.id?.type === 'Identifier'
153
+ ) {
154
+ exported.push(`${declaration.id.name}:()=>${declaration.id.name}`)
155
+ }
156
+ } else if (node.type === 'ExportAllDeclaration') {
157
+ throw new Error(
158
+ `${id}: a configured module cannot re-export from another module`,
159
+ )
160
+ }
161
+ }
162
+ return `${code}\nglobalThis.${PEACH_WORKSPACE_MODULE_MARKER}=[${JSON.stringify(match.pattern)},{${exported.join(',')}}];`
163
+ },
96
164
  async generateBundle(_options, bundle) {
97
165
  if (options.enabled === false || dev) return
98
166
  const versions = readInstalledNativePackageVersions(root)