peachsim 0.1.1815 → 0.1.1817

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 (97) hide show
  1. package/cli/commands/package.ts +82 -31
  2. package/cli/outbound-endpoints.ts +1 -1
  3. package/cli/packaged-app-launcher.ts +6 -1
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.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/bundle-channel.cjs +4418 -5235
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +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/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +12 -3
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +3932 -4526
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +3289 -4175
  34. package/dist-lib/host/fetch-proxy-handler.cjs +12 -3
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +13 -24
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +13 -24
  50. package/dist-lib/native-app-identity-project.cjs +2 -22
  51. package/dist-lib/native-app-identity-project.mjs +2 -22
  52. package/dist-lib/native-app-identity.cjs +1 -1
  53. package/dist-lib/native-app-identity.mjs +1 -1
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +24 -24
  63. package/dist-lib/public-origins-lib.json +74 -66
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +1 -1
  69. package/dist-lib/sdk.mjs +1 -1
  70. package/dist-lib/skills.cjs +3793 -4671
  71. package/dist-lib/swift-compile.cjs +216 -242
  72. package/dist-lib/swift-compile.mjs +216 -242
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +251 -236
  80. package/dist-lib/vite.cjs +12 -3
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/package.json +1 -1
  84. package/src/answeredNativePackages.ts +41 -0
  85. package/src/cli-runtime.ts +2 -9
  86. package/src/expo-discovery-cache.ts +2 -0
  87. package/src/expo-kotlin-host.ts +11 -9
  88. package/src/expo-swift-host.ts +10 -6
  89. package/src/nitro-bundle.ts +8 -6
  90. package/src/nitro-compiler-digest.ts +2 -4
  91. package/src/nitro-superset.lock.json +19 -251
  92. package/src/nitro-superset.ts +59 -63
  93. package/src/react-native-bridge-modules.ts +2 -4
  94. package/src/swift-compile.ts +258 -254
  95. package/src/swift-objc-standin.ts +10 -6
  96. package/src/swift-standins.ts +36 -12
  97. package/src/turbo-source.ts +2 -3
@@ -1,18 +1,23 @@
1
1
  // the shared Nitro executable (plans/peach/native-prebuild-registry.md). every
2
2
  // compiled Nitro provider links one Swift, Foundation and UIKit closure that is
3
3
  // most of an executable's bytes, so building each app's own copy ships the same
4
- // closure per app. one executable of every provider in the lock is published
5
- // under a content address on the prebuilt registry, and an app whose providers are byte-identical to the ones
6
- // it was built from points its metadata at that address: the browser downloads
7
- // it once for every app, port and deployment. an app with a provider outside
8
- // the lock, a different provider build, or a HybridObject or view its config
9
- // answers compiles its own executable.
4
+ // closure per app. one executable of every provider in the capsule is published
5
+ // on the prebuilt registry under a key of its committed inputs and the compiler
6
+ // sources, and an app whose providers are byte-identical to the ones it was
7
+ // built from points its metadata at that key: the browser downloads it once for
8
+ // every app, port and deployment. an app with a provider outside the lock, a
9
+ // different provider build, or a HybridObject or view its config answers
10
+ // compiles its own executable.
10
11
  import { createHash } from 'node:crypto'
11
12
  import { readdirSync, readFileSync } from 'node:fs'
12
13
  import { createRequire } from 'node:module'
13
14
  import { dirname, join } from 'node:path'
14
15
  import { isRecord } from './is-record'
15
- import { NATIVE_PREBUILT_ORIGIN, nativeEntryPrefix } from './native-prebuilt'
16
+ import {
17
+ NATIVE_PREBUILT_ORIGIN,
18
+ nativeEntryKey,
19
+ nativeEntryPrefix,
20
+ } from './native-prebuilt'
16
21
  import { committedAdapterLocks } from './nitro-adapter'
17
22
  import { nitroCompilerSourceDigest } from './nitro-compiler-digest'
18
23
  import supersetLockJson from './nitro-superset.lock.json' with { type: 'json' }
@@ -49,10 +54,10 @@ const packageVersion = (root: string): string =>
49
54
 
50
55
  /**
51
56
  * what one executable of these providers depends on, apart from the sources
52
- * that compile it (the lock records their digest, scripts/ops/nitro-superset.ts
53
- * checks it when publishing): the toolchain and runtime identities, the build
54
- * configuration, the iOS deployment target its project compiles for, and each
55
- * provider's version and source tree, Nitro Modules' included.
57
+ * that compile it, which NITRO_COMPILER_DIGEST adds to the key: the toolchain
58
+ * and runtime identities, the build configuration, the iOS deployment target
59
+ * its project compiles for, and each provider's version and source tree, Nitro
60
+ * Modules' included.
56
61
  */
57
62
  export function nitroSupersetInputs(options: {
58
63
  appRoot: string
@@ -77,64 +82,56 @@ export function nitroSupersetInputs(options: {
77
82
  return inputs
78
83
  }
79
84
 
80
- export function nitroCompilerDigest(): string {
81
- return nitroCompilerSourceDigest(import.meta.dirname, STANDIN_SOURCE_DIGEST)
82
- }
85
+ // build-cli replaces this in every bundle with the digest of the sources it
86
+ // bundles; source runs read the files once at load, like STANDIN_SOURCE_DIGEST.
87
+ declare const __NITRO_COMPILER_DIGEST__: string | undefined
88
+ export const NITRO_COMPILER_DIGEST =
89
+ typeof __NITRO_COMPILER_DIGEST__ === 'string'
90
+ ? __NITRO_COMPILER_DIGEST__
91
+ : nitroCompilerSourceDigest(import.meta.dirname, STANDIN_SOURCE_DIGEST)
83
92
 
84
- export interface NitroSupersetEntry {
85
- key: string
86
- inputs: Record<string, string>
87
- /** every provider the executable registers; urls are absolute. */
88
- metadata: NitroCompiledModule
89
- }
90
-
91
- /** the Release executable at the top level, where the lander reads its
92
- * compiler digest, and the Debug build of the same providers beside it. */
93
- export interface NitroSupersetLock extends NitroSupersetEntry {
94
- debug: NitroSupersetEntry
95
- }
93
+ /** each configuration's compiler-independent inputs, as `nitro-superset.ts inputs` wrote them. */
94
+ export type NitroSupersetLock = Record<NitroBuildConfiguration, Record<string, string>>
96
95
 
97
- function parseEntry(value: unknown): NitroSupersetEntry | null {
98
- if (!isRecord(value) || !isRecord(value.inputs)) return null
99
- const metadata = readNitroMetadata(value.metadata)
100
- if (!metadata || typeof value.key !== 'string') return null
101
- const inputs = Object.fromEntries(
102
- Object.entries(value.inputs).filter(
103
- (entry): entry is [string, string] => typeof entry[1] === 'string',
104
- ),
105
- )
106
- return { key: value.key, inputs, metadata }
96
+ function readInputs(value: unknown): Record<string, string> | null {
97
+ if (!isRecord(value)) return null
98
+ const inputs: Record<string, string> = {}
99
+ for (const [name, entry] of Object.entries(value)) {
100
+ if (typeof entry !== 'string') return null
101
+ inputs[name] = entry
102
+ }
103
+ return inputs
107
104
  }
108
105
 
109
106
  function parseLock(value: unknown): NitroSupersetLock | null {
110
- const release = parseEntry(value)
111
- const debug = isRecord(value) ? parseEntry(value.debug) : null
112
- return release && debug ? { ...release, debug } : null
107
+ if (!isRecord(value)) return null
108
+ const release = readInputs(value.Release)
109
+ const debug = readInputs(value.Debug)
110
+ return release && debug ? { Release: release, Debug: debug } : null
113
111
  }
114
112
 
115
113
  export const nitroSupersetLock = parseLock(supersetLockJson)
116
114
 
117
- /** the lock entry an executable of a configuration is addressed by. */
118
- export const nitroSupersetEntry = (
119
- lock: NitroSupersetLock,
120
- configuration: NitroBuildConfiguration,
121
- ): NitroSupersetEntry => (configuration === 'Debug' ? lock.debug : lock)
115
+ /** the registry key of an executable: its inputs and the compiler that builds it. */
116
+ export const nitroSupersetKey = (inputs: Record<string, string>): string =>
117
+ nativeEntryKey({ ...inputs, compiler: NITRO_COMPILER_DIGEST })
122
118
 
123
119
  /** the registry prefix and file urls of an executable built for a key. */
124
120
  export function nitroSupersetUrl(key: string, file: string): string {
125
121
  return `${NATIVE_PREBUILT_ORIGIN}/${nativeEntryPrefix('nitro', NITRO_SUPERSET_ENTRY_NAME, key)}/${file}`
126
122
  }
127
123
 
128
- // a lock names an address before the publish workflow has filled it, so each
129
- // address is asked for once per process
130
- const published = new Map<string, Promise<boolean>>()
131
- const isPublished = (url: string) => {
124
+ // the publish workflow fills a key after main moves its compiler, so each key's
125
+ // metadata is asked for once per process and a miss compiles the app's own.
126
+ const published = new Map<string, Promise<NitroCompiledModule | null>>()
127
+ const publishedMetadata = (url: string) => {
132
128
  let pending = published.get(url)
133
129
  if (!pending) {
134
- pending = fetch(url, { method: 'HEAD' }).then(
135
- (response) => response.ok,
136
- () => false,
137
- )
130
+ pending = fetch(url)
131
+ .then(async (response) =>
132
+ response.ok ? readNitroMetadata(await response.json()) : null,
133
+ )
134
+ .catch(() => null)
138
135
  published.set(url, pending)
139
136
  }
140
137
  return pending
@@ -143,8 +140,8 @@ const isPublished = (url: string) => {
143
140
  /**
144
141
  * the shared executable's metadata for an app's providers, or null when the app
145
142
  * needs its own: its inputs differ from the lock's anywhere, it holds a
146
- * provider the lock lacks, or its config answers a name or view the executable
147
- * would register.
143
+ * provider the lock lacks, its config answers a name or view the executable
144
+ * would register, or this compiler's executable is not published yet.
148
145
  */
149
146
  export async function sharedNitroModule(options: {
150
147
  appRoot: string
@@ -153,17 +150,16 @@ export async function sharedNitroModule(options: {
153
150
  providers: readonly { name: string; root: string }[]
154
151
  answers: { hybridObjects: ReadonlySet<string>; views: ReadonlySet<string> }
155
152
  }): Promise<NitroCompiledModule | null> {
156
- const lock =
157
- nitroSupersetLock && nitroSupersetEntry(nitroSupersetLock, options.configuration)
158
- if (!lock || options.answers.hybridObjects.size > 0 || options.answers.views.size > 0)
153
+ const locked = nitroSupersetLock?.[options.configuration]
154
+ if (!locked || options.answers.hybridObjects.size > 0 || options.answers.views.size > 0)
159
155
  return null
160
156
  const inputs = nitroSupersetInputs(options)
161
157
  for (const [name, value] of Object.entries(inputs))
162
- if (lock.inputs[name] !== value) return null
158
+ if (locked[name] !== value) return null
159
+ const metadata = await publishedMetadata(
160
+ nitroSupersetUrl(nitroSupersetKey(locked), 'metadata.json'),
161
+ )
162
+ if (!metadata) return null
163
163
  const own = new Set(options.providers.map(({ name }) => name))
164
- if (!(await isPublished(lock.metadata.url))) return null
165
- return {
166
- ...lock.metadata,
167
- packages: lock.metadata.packages.filter(({ name }) => own.has(name)),
168
- }
164
+ return { ...metadata, packages: metadata.packages.filter(({ name }) => own.has(name)) }
169
165
  }
@@ -6,9 +6,7 @@
6
6
  import fs from 'node:fs'
7
7
  import { createRequire } from 'node:module'
8
8
  import path from 'node:path'
9
- import { PEACH_ANSWERED_NATIVE_PACKAGE_NAMES } from '../../peach-compat/src/generated/supported-native-packages'
10
-
11
- const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
9
+ import { peachAnsweredNativePackages } from './answeredNativePackages'
12
10
  import { swiftCodeMask, swiftSourceClosure } from './swift-compile'
13
11
  import { xcodeNativeFlags, xcodeObjCInputs } from './swift-objc-compile'
14
12
  import { SWIFT_NATIVE_INPUT_ROOT, SWIFT_NATIVE_SDK_INCLUDE } from './swiftContract'
@@ -617,7 +615,7 @@ function collectInstalledSwiftBridgeUnits(
617
615
  const namespacesSeen = new Set(units.map((unit) => unit.namespace))
618
616
  for (const packageName of Object.keys(dependencies).sort()) {
619
617
  signal?.throwIfAborted()
620
- if (answeredPackages.has(packageName)) continue
618
+ if (peachAnsweredNativePackages().has(packageName)) continue
621
619
  let pkgRoot: string | null = null
622
620
  try {
623
621
  pkgRoot = fs.realpathSync(