peachsim 0.1.1728 → 0.1.1738
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.
- package/cli/commands/control.ts +1 -0
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/package.ts +11 -1
- package/cli/commands/shell-url.ts +4 -0
- package/cli/scene-video.ts +24 -7
- package/detox/index.ts +9 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +3592 -1918
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +13 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1329 -1022
- package/dist-lib/expo-swift-metadata.cjs +2 -2
- package/dist-lib/expo-swift-metadata.mjs +2 -2
- package/dist-lib/home-paths.cjs +7 -2
- package/dist-lib/host/bridge-host.cjs +3773 -2149
- package/dist-lib/host/fetch-proxy-handler.cjs +16 -5
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +97 -68
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +209 -32
- package/dist-lib/menu.cjs +7 -1
- package/dist-lib/menu.mjs +7 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +93 -65
- package/dist-lib/native-app-identity-project.cjs +37 -31
- package/dist-lib/native-app-identity-project.mjs +37 -31
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +79 -53
- package/dist-lib/react-native-host-modules.cjs +5 -2
- package/dist-lib/react-native-host-modules.mjs +5 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +4486 -2789
- package/dist-lib/swift-compile.cjs +53 -60
- package/dist-lib/swift-compile.mjs +52 -60
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +17 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1056 -870
- package/dist-lib/vite.cjs +20 -8
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +4 -1
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +13 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +636 -37
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +5 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/native-hashes.json +3 -3
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +0 -1
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/appPackageContract.ts +2 -0
- package/src/bundle-channel.mjs +20 -2
- package/src/cli-runtime.ts +9 -5
- package/src/expo-discovery-cache.ts +7 -3
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-native-workspace.ts +135 -40
- package/src/expo-swift-host.ts +93 -20
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +9 -2
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +6 -1
- package/src/host/bridge-host.ts +5 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/kotlin-host.ts +204 -30
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +7 -0
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +251 -251
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +84 -74
- package/src/nitro-compile.ts +10 -5
- package/src/nitro-dependencies.ts +43 -28
- package/src/nitro-source.ts +60 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +64 -21
- package/src/react-native-bridge-modules.ts +2 -0
- package/src/react-native-host-modules.ts +4 -1
- package/src/settingsContract.ts +11 -0
- package/src/storageSnapshotContract.ts +29 -81
- package/src/swift-compile.ts +49 -50
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode.ts +9 -1
- package/src/swift-distribution.lock.json +15 -12
- package/src/swift-host.ts +3 -0
- package/src/swift-standin-emit.ts +6 -1
- package/src/swift-standins.ts +172 -10
- package/src/swift-submit.ts +5 -1
- package/src/swift-toolchain.ts +16 -16
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +4 -3
package/src/nitro-adapter.ts
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
// the private
|
|
2
|
-
// compile: the
|
|
3
|
-
//
|
|
4
|
-
// this build carries, then checked against the
|
|
5
|
-
// module root compiles with
|
|
6
|
-
// never reaches this machine.
|
|
1
|
+
// the private adapter archives an installed peach links into a native module
|
|
2
|
+
// compile: the Nitro adapter, and the TurboModule runtime, each built against
|
|
3
|
+
// the app's own original headers, downloaded from PEACH_SWIFT_ENDPOINT,
|
|
4
|
+
// verified against the lock this build carries, then checked against the
|
|
5
|
+
// compiler, SDK and framework the module root compiles with
|
|
6
|
+
// (docs/swift-distribution.md). the adapter source never reaches this machine.
|
|
7
7
|
import fs from 'node:fs'
|
|
8
8
|
import path from 'node:path'
|
|
9
9
|
import { installVerifiedTarball } from '@contrast/runtime-delivery'
|
|
10
10
|
import { rnxHomeDir } from './home-paths'
|
|
11
|
-
import
|
|
11
|
+
import nitroLockJson from './nitro-adapter.lock.json' with { type: 'json' }
|
|
12
12
|
import {
|
|
13
|
+
ADAPTER_FAMILIES,
|
|
14
|
+
ADAPTER_MANIFEST,
|
|
15
|
+
adapterArchiveKey,
|
|
16
|
+
adapterPin,
|
|
13
17
|
headerDigests,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type NitroAdapterPin,
|
|
18
|
+
parseAdapterLock,
|
|
19
|
+
verifyInstalledAdapter,
|
|
20
|
+
type AdapterFamily,
|
|
21
|
+
type AdapterLock,
|
|
22
|
+
type AdapterManifest,
|
|
23
|
+
type AdapterPin,
|
|
24
|
+
type NitroAdapterRoots,
|
|
22
25
|
} from './nitroAdapterContract'
|
|
23
26
|
import { NITRO_GUEST_PLATFORM } from './nitroContract'
|
|
24
27
|
import { swiftDistributionAt, swiftModuleSdk, WASM_TRIPLE } from './swift-compile'
|
|
25
28
|
import { SWIFT_ENDPOINT_ENV } from './swift-distribution'
|
|
26
|
-
import
|
|
29
|
+
import turboLockJson from './turbo-runtime.lock.json' with { type: 'json' }
|
|
27
30
|
|
|
28
|
-
/** the verified
|
|
29
|
-
export const
|
|
31
|
+
/** the verified archives this build ships, the only locks normal compiles use. */
|
|
32
|
+
export const committedAdapterLocks: Record<AdapterFamily, AdapterLock> = {
|
|
33
|
+
nitro: parseAdapterLock('nitro', nitroLockJson),
|
|
34
|
+
turbo: parseAdapterLock('turbo', turboLockJson),
|
|
35
|
+
}
|
|
30
36
|
|
|
31
|
-
export interface
|
|
32
|
-
manifest:
|
|
37
|
+
export interface AdapterArchive {
|
|
38
|
+
manifest: AdapterManifest
|
|
33
39
|
/** the static archive, base64, as SwiftCompileInput.libraries carries it. */
|
|
34
40
|
base64: string
|
|
35
41
|
}
|
|
@@ -44,11 +50,12 @@ const installedVersion = (root: string) =>
|
|
|
44
50
|
* fixes; the consumer cannot recompute it and the framework distribution id
|
|
45
51
|
* does not independently bind it. */
|
|
46
52
|
function selectPin(
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
family: AdapterFamily,
|
|
54
|
+
lock: AdapterLock,
|
|
55
|
+
roots: NitroAdapterRoots,
|
|
49
56
|
moduleRoot: string,
|
|
50
|
-
):
|
|
51
|
-
const {
|
|
57
|
+
): AdapterPin {
|
|
58
|
+
const { label } = ADAPTER_FAMILIES[family]
|
|
52
59
|
const distribution = swiftDistributionAt(moduleRoot)
|
|
53
60
|
if (!distribution) throw new Error(`${moduleRoot} holds no Swift distribution`)
|
|
54
61
|
const sdk = swiftModuleSdk(moduleRoot)
|
|
@@ -62,49 +69,48 @@ function selectPin(
|
|
|
62
69
|
].filter((name) => name !== false)
|
|
63
70
|
if (mismatched.length > 0)
|
|
64
71
|
throw new Error(
|
|
65
|
-
|
|
72
|
+
`${label} archives do not match this toolchain: ${mismatched.join(', ')}`,
|
|
66
73
|
)
|
|
67
|
-
const pin =
|
|
68
|
-
lock,
|
|
69
|
-
headerDigests({ nitroModules: nitro.root, reactNative: reactNative.root }),
|
|
70
|
-
)
|
|
74
|
+
const pin = adapterPin(lock, headerDigests(family, roots))
|
|
71
75
|
if (!pin)
|
|
72
76
|
throw new Error(
|
|
73
|
-
`this peach has no
|
|
77
|
+
`this peach has no ${label} for react-native ${installedVersion(roots.reactNative)}${roots.nitroModules ? ` with react-native-nitro-modules ${installedVersion(roots.nitroModules)}` : ''}`,
|
|
74
78
|
)
|
|
75
79
|
return pin
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
/** the verified
|
|
79
|
-
* download, whose tarball and unpacked bytes the lock pins. */
|
|
80
|
-
export async function
|
|
81
|
-
|
|
82
|
+
/** the verified archive for an app's original headers: identity first, then
|
|
83
|
+
* the download, whose tarball and unpacked bytes the lock pins. */
|
|
84
|
+
export async function resolveAdapterArchive(
|
|
85
|
+
family: AdapterFamily,
|
|
86
|
+
roots: NitroAdapterRoots,
|
|
82
87
|
moduleRoot: string,
|
|
83
|
-
lock:
|
|
88
|
+
lock: AdapterLock,
|
|
84
89
|
signal?: AbortSignal,
|
|
85
|
-
): Promise<
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
): Promise<AdapterArchive> {
|
|
91
|
+
const { label, key } = ADAPTER_FAMILIES[family]
|
|
92
|
+
const pin = selectPin(family, lock, roots, moduleRoot)
|
|
93
|
+
const dir = path.join(rnxHomeDir(), 'swift', `${key}-${pin.archive.sha256}`)
|
|
94
|
+
if (!fs.existsSync(path.join(dir, ADAPTER_MANIFEST))) {
|
|
95
|
+
const endpoint = process.env[SWIFT_ENDPOINT_ENV]?.trim().replace(/\/+$/, '')
|
|
96
|
+
if (!endpoint)
|
|
97
|
+
throw new Error(
|
|
98
|
+
`native module compilation needs ${SWIFT_ENDPOINT_ENV} for its ${label}`,
|
|
99
|
+
)
|
|
100
|
+
process.stderr.write(`peach: downloading ${label} ${pin.archive.sha256}…\n`)
|
|
95
101
|
await installVerifiedTarball({
|
|
96
102
|
signal,
|
|
97
|
-
url: `${endpoint}/${
|
|
103
|
+
url: `${endpoint}/${adapterArchiveKey(family, pin)}`,
|
|
98
104
|
digest: { algorithm: 'sha256', encoding: 'hex', value: pin.archive.sha256 },
|
|
99
105
|
destDir: dir,
|
|
100
|
-
installedMarker:
|
|
101
|
-
label:
|
|
106
|
+
installedMarker: ADAPTER_MANIFEST,
|
|
107
|
+
label: `${label} archive`,
|
|
102
108
|
verify: (installed) => {
|
|
103
|
-
|
|
109
|
+
verifyInstalledAdapter(family, installed, pin)
|
|
104
110
|
},
|
|
105
111
|
})
|
|
106
112
|
}
|
|
107
|
-
const manifest =
|
|
113
|
+
const manifest = verifyInstalledAdapter(family, dir, pin)
|
|
108
114
|
return {
|
|
109
115
|
manifest,
|
|
110
116
|
base64: fs.readFileSync(path.join(dir, manifest.archive.path)).toString('base64'),
|
package/src/nitro-bundle.ts
CHANGED
|
@@ -20,9 +20,11 @@ import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
|
20
20
|
|
|
21
21
|
export const NITRO_ROUTE = '/__peach/nitro'
|
|
22
22
|
|
|
23
|
+
export type CompiledModuleAsset = { path: string; bytes: Buffer; contentType: string }
|
|
24
|
+
|
|
23
25
|
export interface NitroBundle {
|
|
24
26
|
metadata: NitroCompiledModule
|
|
25
|
-
assets:
|
|
27
|
+
assets: CompiledModuleAsset[]
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
|
|
@@ -93,14 +95,9 @@ export async function compileNitroApp(
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
): Promise<NitroBundle | null> {
|
|
100
|
-
const compiled = await compileNitroApp(appRoot, '', moduleRoot)
|
|
101
|
-
if (!compiled) return null
|
|
102
|
-
const { artifact, metadata } = compiled
|
|
103
|
-
const assets: NitroBundle['assets'] = [
|
|
98
|
+
/** a compiled module's served files: its wasm and, unless shared, its ICU. */
|
|
99
|
+
export function compiledModuleAssets(artifact: SwiftArtifact): CompiledModuleAsset[] {
|
|
100
|
+
const assets: CompiledModuleAsset[] = [
|
|
104
101
|
{
|
|
105
102
|
path: `__peach/swift/${artifact.hash}.wasm`,
|
|
106
103
|
bytes: artifact.bytes,
|
|
@@ -113,78 +110,91 @@ export async function buildNitroBundle(
|
|
|
113
110
|
bytes: artifact.icu.gzip,
|
|
114
111
|
contentType: 'application/gzip',
|
|
115
112
|
})
|
|
116
|
-
return
|
|
113
|
+
return assets
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
export async function buildNitroBundle(
|
|
117
|
+
appRoot: string,
|
|
118
|
+
moduleRoot?: string,
|
|
119
|
+
): Promise<NitroBundle | null> {
|
|
120
|
+
const compiled = await compileNitroApp(appRoot, '', moduleRoot)
|
|
121
|
+
if (!compiled) return null
|
|
122
|
+
return { metadata: compiled.metadata, assets: compiledModuleAssets(compiled.artifact) }
|
|
123
|
+
}
|
|
123
124
|
|
|
124
|
-
// the dev server's build of an app's installed
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
res.
|
|
149
|
-
res.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
125
|
+
// the dev server's build of one kind of an app's installed native modules.
|
|
126
|
+
// one build per app root and dev server; concurrent boots share it. the
|
|
127
|
+
// compiler reuses an unchanged artifact, so a reload pays only the source
|
|
128
|
+
// check. its wasm and ICU are served from the same host by the Swift artifact
|
|
129
|
+
// route.
|
|
130
|
+
export function compiledModuleRequestHandler<Metadata>(
|
|
131
|
+
label: string,
|
|
132
|
+
compile: (appRoot: string, origin: string) => Promise<{ metadata: Metadata } | null>,
|
|
133
|
+
): (req: IncomingMessage, res: ServerResponse) => Promise<void> {
|
|
134
|
+
const compiling = new Map<string, Promise<Metadata | null>>()
|
|
135
|
+
const openPreparations = new NativePreparationReceipts<Metadata | null>()
|
|
136
|
+
return async (req, res) => {
|
|
137
|
+
const url = new URL(req.url ?? '/', 'http://localhost')
|
|
138
|
+
const remote = req.socket.remoteAddress?.replace(/^::ffff:/, '')
|
|
139
|
+
const origin = req.headers.origin
|
|
140
|
+
if (
|
|
141
|
+
!remote ||
|
|
142
|
+
!isLoopbackHost(remote) ||
|
|
143
|
+
(origin && !isLoopbackHost(new URL(origin).hostname))
|
|
144
|
+
) {
|
|
145
|
+
res.writeHead(403)
|
|
146
|
+
res.end(`${label} compilation requires a loopback client`)
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
res.setHeader('Access-Control-Allow-Origin', origin ?? '*')
|
|
150
|
+
res.setHeader('Vary', 'Origin')
|
|
151
|
+
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin')
|
|
152
|
+
const root = url.searchParams.get('root')
|
|
153
|
+
const host = req.headers.host
|
|
154
|
+
if (req.method !== 'GET' || !root || !path.isAbsolute(root) || !host) {
|
|
155
|
+
res.writeHead(400)
|
|
156
|
+
res.end(`${label} compilation needs GET with an absolute app root`)
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const key = `${host}\0${fs.realpathSync(root)}`
|
|
161
|
+
const prepared = openPreparations.take(
|
|
162
|
+
key,
|
|
163
|
+
url.searchParams.get(NATIVE_PREPARED_QUERY_PARAM),
|
|
164
|
+
)
|
|
165
|
+
if (prepared) {
|
|
166
|
+
res.writeHead(200, {
|
|
167
|
+
'Content-Type': 'application/json',
|
|
168
|
+
'Cache-Control': 'no-store',
|
|
169
|
+
})
|
|
170
|
+
res.end(JSON.stringify(prepared.value))
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
let pending = compiling.get(key)
|
|
174
|
+
if (!pending) {
|
|
175
|
+
pending = compile(fs.realpathSync(root), `http://${host}`)
|
|
176
|
+
.then((compiled) => compiled?.metadata ?? null)
|
|
177
|
+
.finally(() => compiling.delete(key))
|
|
178
|
+
compiling.set(key, pending)
|
|
179
|
+
}
|
|
180
|
+
const metadata = await pending
|
|
181
|
+
if (res.destroyed) return
|
|
182
|
+
openPreparations.store(
|
|
183
|
+
key,
|
|
184
|
+
url.searchParams.get(NATIVE_PREPARE_QUERY_PARAM),
|
|
185
|
+
metadata,
|
|
186
|
+
)
|
|
159
187
|
res.writeHead(200, {
|
|
160
188
|
'Content-Type': 'application/json',
|
|
161
189
|
'Cache-Control': 'no-store',
|
|
162
190
|
})
|
|
163
|
-
res.end(JSON.stringify(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
pending = compileNitroApp(fs.realpathSync(root), `http://${host}`)
|
|
169
|
-
.then((compiled) => compiled?.metadata ?? null)
|
|
170
|
-
.finally(() => compiling.delete(key))
|
|
171
|
-
compiling.set(key, pending)
|
|
191
|
+
res.end(JSON.stringify(metadata))
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (res.destroyed) return
|
|
194
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' })
|
|
195
|
+
res.end(error instanceof Error ? error.message : String(error))
|
|
172
196
|
}
|
|
173
|
-
const metadata = await pending
|
|
174
|
-
if (res.destroyed) return
|
|
175
|
-
openPreparations.store(
|
|
176
|
-
key,
|
|
177
|
-
url.searchParams.get(NATIVE_PREPARE_QUERY_PARAM),
|
|
178
|
-
metadata,
|
|
179
|
-
)
|
|
180
|
-
res.writeHead(200, {
|
|
181
|
-
'Content-Type': 'application/json',
|
|
182
|
-
'Cache-Control': 'no-store',
|
|
183
|
-
})
|
|
184
|
-
res.end(JSON.stringify(metadata))
|
|
185
|
-
} catch (error) {
|
|
186
|
-
if (res.destroyed) return
|
|
187
|
-
res.writeHead(500, { 'Content-Type': 'text/plain' })
|
|
188
|
-
res.end(error instanceof Error ? error.message : String(error))
|
|
189
197
|
}
|
|
190
198
|
}
|
|
199
|
+
|
|
200
|
+
export const handleNitroRequest = compiledModuleRequestHandler('Nitro', compileNitroApp)
|
package/src/nitro-compile.ts
CHANGED
|
@@ -4,9 +4,9 @@ import os from 'node:os'
|
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { readIosAppTarget } from './native-app-identity-project'
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
7
|
+
committedAdapterLocks,
|
|
8
|
+
resolveAdapterArchive,
|
|
9
|
+
type AdapterArchive,
|
|
10
10
|
} from './nitro-adapter'
|
|
11
11
|
import {
|
|
12
12
|
collectNitroSources,
|
|
@@ -58,7 +58,7 @@ function bundledNamespaceDefines(
|
|
|
58
58
|
// linking and reuse.
|
|
59
59
|
export function collectNitroCompileInput(
|
|
60
60
|
collection: NitroSourceCollection,
|
|
61
|
-
adapter:
|
|
61
|
+
adapter: AdapterArchive,
|
|
62
62
|
dependencies: SwiftCompileInput | null,
|
|
63
63
|
iosDeploymentTarget: string,
|
|
64
64
|
): SwiftCompileInput {
|
|
@@ -183,7 +183,12 @@ export async function compileNitroModule(
|
|
|
183
183
|
)
|
|
184
184
|
const input = collectNitroCompileInput(
|
|
185
185
|
collection,
|
|
186
|
-
await
|
|
186
|
+
await resolveAdapterArchive(
|
|
187
|
+
'nitro',
|
|
188
|
+
{ nitroModules: collection.nitro.root, reactNative: collection.reactNative.root },
|
|
189
|
+
options.moduleRoot,
|
|
190
|
+
committedAdapterLocks.nitro,
|
|
191
|
+
),
|
|
187
192
|
dependencies,
|
|
188
193
|
iosDeploymentTarget,
|
|
189
194
|
)
|
|
@@ -59,31 +59,43 @@ export interface NitroDependencyHeader {
|
|
|
59
59
|
derivation?: { upstreamCommit: string; originalSha256: string }
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// the archives React Native's podspecs pin, shared until a release moves one
|
|
63
|
+
const RN_SHARED_DEPENDENCIES: NitroDependency[] = [
|
|
64
|
+
{
|
|
65
|
+
name: 'RCT-Folly',
|
|
66
|
+
url: 'https://github.com/facebook/folly/archive/v2024.11.18.00.tar.gz',
|
|
67
|
+
sha256: 'b2c6879ba8ba625218d1ab9eefcc1611a9003d05bc2cb1a38f3bae21892e5167',
|
|
68
|
+
prefix: 'folly-2024.11.18.00',
|
|
69
|
+
headers: { from: 'folly', to: 'folly' },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'boost',
|
|
73
|
+
url: 'https://github.com/react-native-community/boost-for-react-native/archive/v1.84.0.tar.gz',
|
|
74
|
+
sha256: '954a04e9468dee21259937b83a2b21c3985cc96f91ee0152a34a7f0f752093e8',
|
|
75
|
+
prefix: 'boost-for-react-native-1.84.0',
|
|
76
|
+
headers: { from: 'boost', to: 'boost' },
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
// the podspec's prepare_command renames src to double-conversion.
|
|
80
|
+
name: 'DoubleConversion',
|
|
81
|
+
url: 'https://github.com/google/double-conversion/archive/v1.1.6.tar.gz',
|
|
82
|
+
sha256: '6b850acd8e88515764472c52973277744a945f9a769a93968efc42efef64d67a',
|
|
83
|
+
prefix: 'double-conversion-1.1.6',
|
|
84
|
+
headers: { from: 'src', to: 'double-conversion' },
|
|
85
|
+
backport: { file: 'src/utils.h', ...DOUBLE_CONVERSION_WASM32_BACKPORT },
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'fast_float',
|
|
89
|
+
url: 'https://github.com/fastfloat/fast_float/archive/v8.0.0.tar.gz',
|
|
90
|
+
sha256: 'f312f2dc34c61e665f4b132c0307d6f70ad9420185fa831911bc24408acf625d',
|
|
91
|
+
prefix: 'fast_float-8.0.0',
|
|
92
|
+
headers: { from: 'include/fast_float', to: 'fast_float' },
|
|
93
|
+
},
|
|
94
|
+
]
|
|
95
|
+
|
|
62
96
|
const RN_DEPENDENCIES: Record<string, NitroDependency[]> = {
|
|
63
97
|
'0.83.1': [
|
|
64
|
-
|
|
65
|
-
name: 'RCT-Folly',
|
|
66
|
-
url: 'https://github.com/facebook/folly/archive/v2024.11.18.00.tar.gz',
|
|
67
|
-
sha256: 'b2c6879ba8ba625218d1ab9eefcc1611a9003d05bc2cb1a38f3bae21892e5167',
|
|
68
|
-
prefix: 'folly-2024.11.18.00',
|
|
69
|
-
headers: { from: 'folly', to: 'folly' },
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'boost',
|
|
73
|
-
url: 'https://github.com/react-native-community/boost-for-react-native/archive/v1.84.0.tar.gz',
|
|
74
|
-
sha256: '954a04e9468dee21259937b83a2b21c3985cc96f91ee0152a34a7f0f752093e8',
|
|
75
|
-
prefix: 'boost-for-react-native-1.84.0',
|
|
76
|
-
headers: { from: 'boost', to: 'boost' },
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
// the podspec's prepare_command renames src to double-conversion.
|
|
80
|
-
name: 'DoubleConversion',
|
|
81
|
-
url: 'https://github.com/google/double-conversion/archive/v1.1.6.tar.gz',
|
|
82
|
-
sha256: '6b850acd8e88515764472c52973277744a945f9a769a93968efc42efef64d67a',
|
|
83
|
-
prefix: 'double-conversion-1.1.6',
|
|
84
|
-
headers: { from: 'src', to: 'double-conversion' },
|
|
85
|
-
backport: { file: 'src/utils.h', ...DOUBLE_CONVERSION_WASM32_BACKPORT },
|
|
86
|
-
},
|
|
98
|
+
...RN_SHARED_DEPENDENCIES,
|
|
87
99
|
{
|
|
88
100
|
name: 'fmt',
|
|
89
101
|
url: 'https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz',
|
|
@@ -91,12 +103,15 @@ const RN_DEPENDENCIES: Record<string, NitroDependency[]> = {
|
|
|
91
103
|
prefix: 'fmt-11.0.2',
|
|
92
104
|
headers: { from: 'include/fmt', to: 'fmt' },
|
|
93
105
|
},
|
|
106
|
+
],
|
|
107
|
+
'0.88.0': [
|
|
108
|
+
...RN_SHARED_DEPENDENCIES,
|
|
94
109
|
{
|
|
95
|
-
name: '
|
|
96
|
-
url: 'https://github.com/
|
|
97
|
-
sha256: '
|
|
98
|
-
prefix: '
|
|
99
|
-
headers: { from: 'include/
|
|
110
|
+
name: 'fmt',
|
|
111
|
+
url: 'https://github.com/fmtlib/fmt/archive/12.1.0.tar.gz',
|
|
112
|
+
sha256: 'ea7de4299689e12b6dddd392f9896f08fb0777ac7168897a244a6d6085043fea',
|
|
113
|
+
prefix: 'fmt-12.1.0',
|
|
114
|
+
headers: { from: 'include/fmt', to: 'fmt' },
|
|
100
115
|
},
|
|
101
116
|
],
|
|
102
117
|
}
|
package/src/nitro-source.ts
CHANGED
|
@@ -30,6 +30,22 @@ export type NitroSourceOptions = { packageRoots: string[]; answers?: NitroAnswer
|
|
|
30
30
|
|
|
31
31
|
const run = promisify(execFile)
|
|
32
32
|
|
|
33
|
+
// an autolinker that exits 0 with unparseable stdout names what it printed,
|
|
34
|
+
// so a truncated or empty pipe read is distinguishable from a bad command.
|
|
35
|
+
function autolinkerJson(
|
|
36
|
+
command: string,
|
|
37
|
+
output: { stdout: string; stderr: string },
|
|
38
|
+
): unknown {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(output.stdout)
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`${command} exited 0 with ${output.stdout.length} bytes of stdout that is not JSON (${cause instanceof Error ? cause.message : cause}); stderr: ${output.stderr.trim().slice(0, 500) || '(empty)'}; stdout: ${output.stdout.slice(0, 200) || '(empty)'}`,
|
|
44
|
+
{ cause },
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
type NitroPackage = { name: string; version: string; root: string }
|
|
34
50
|
|
|
35
51
|
/** source fragments for the common Swift host; its caller owns the executable,
|
|
@@ -240,7 +256,7 @@ async function cliAdvertises(
|
|
|
240
256
|
args: string[],
|
|
241
257
|
token: string,
|
|
242
258
|
): Promise<boolean> {
|
|
243
|
-
const { stdout } = await run(
|
|
259
|
+
const { stdout } = await run('node', [cli, ...args], {
|
|
244
260
|
timeout: 30_000,
|
|
245
261
|
maxBuffer: 1 * 1024 * 1024,
|
|
246
262
|
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: '1' },
|
|
@@ -271,18 +287,18 @@ async function autolinkingConfig(
|
|
|
271
287
|
// through to their own `react-native config`, the command their Podfile's
|
|
272
288
|
// use_native_modules! runs.
|
|
273
289
|
if (await cliAdvertises(cli, ['--help'], 'react-native-config')) {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
{
|
|
290
|
+
const args = [
|
|
291
|
+
cli,
|
|
292
|
+
'react-native-config',
|
|
293
|
+
'--json',
|
|
294
|
+
'--platform',
|
|
295
|
+
'ios',
|
|
296
|
+
'--project-root',
|
|
297
|
+
appRoot,
|
|
298
|
+
]
|
|
299
|
+
return autolinkerJson(
|
|
300
|
+
'expo-modules-autolinking react-native-config',
|
|
301
|
+
await run('node', args, {
|
|
286
302
|
timeout: 30_000,
|
|
287
303
|
maxBuffer: 8 * 1024 * 1024,
|
|
288
304
|
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: '1' },
|
|
@@ -290,9 +306,8 @@ async function autolinkingConfig(
|
|
|
290
306
|
// process cwd and ignores --project-root. the corpus bridge starts
|
|
291
307
|
// outside the app, where that walk finds no package.json.
|
|
292
308
|
cwd: appRoot,
|
|
293
|
-
},
|
|
309
|
+
}),
|
|
294
310
|
)
|
|
295
|
-
return JSON.parse(stdout)
|
|
296
311
|
}
|
|
297
312
|
}
|
|
298
313
|
// the app's own `react-native config`, the command its Podfile runs, so any
|
|
@@ -310,13 +325,15 @@ async function autolinkingConfig(
|
|
|
310
325
|
const configArgs = (await cliAdvertises(cliPath, ['config', '--help'], '--platform'))
|
|
311
326
|
? ['config', '--platform', 'ios']
|
|
312
327
|
: ['config']
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
328
|
+
return autolinkerJson(
|
|
329
|
+
`react-native ${configArgs.join(' ')}`,
|
|
330
|
+
await run('node', [cliPath, ...configArgs], {
|
|
331
|
+
cwd: appRoot,
|
|
332
|
+
timeout: 30_000,
|
|
333
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
334
|
+
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: '1', NO_COLOR: '1' },
|
|
335
|
+
}),
|
|
336
|
+
)
|
|
320
337
|
}
|
|
321
338
|
|
|
322
339
|
/** the packages react native's iOS autolinking links into the app that ship a
|
|
@@ -326,26 +343,43 @@ async function autolinkingConfig(
|
|
|
326
343
|
* app's Podfile asks expo-modules-autolinking, any other app the React Native
|
|
327
344
|
* CLI. */
|
|
328
345
|
export async function discoverNitroProviders(appRoot: string): Promise<string[]> {
|
|
346
|
+
return (await iosAutolinkedDependencies(appRoot))
|
|
347
|
+
.map(({ root }) => root)
|
|
348
|
+
.filter(hasNitroIosInitializer)
|
|
349
|
+
.sort()
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** every dependency React Native iOS autolinking links into the app, with the
|
|
353
|
+
* podspec CocoaPods installs it from, as the app's own autolinker answers. */
|
|
354
|
+
export async function iosAutolinkedDependencies(
|
|
355
|
+
appRoot: string,
|
|
356
|
+
): Promise<{ name: string; root: string; podspecPath: string | null }[]> {
|
|
329
357
|
appRoot = fs.realpathSync(appRoot)
|
|
330
358
|
const appRequire = createRequire(path.join(appRoot, 'package.json'))
|
|
331
359
|
const config = await autolinkingConfig(appRoot, appRequire)
|
|
332
360
|
const dependencies = object(config) ? config.dependencies : undefined
|
|
333
361
|
if (!object(dependencies))
|
|
334
362
|
throw new Error(`${appRoot}: React Native autolinking config has no dependencies`)
|
|
335
|
-
const
|
|
363
|
+
const linked: { name: string; root: string; podspecPath: string | null }[] = []
|
|
336
364
|
for (const [name, dependency] of Object.entries(dependencies)) {
|
|
337
365
|
if (!object(dependency) || !object(dependency.platforms))
|
|
338
366
|
throw new Error(
|
|
339
367
|
`${appRoot}: React Native autolinking dependency ${name} is malformed`,
|
|
340
368
|
)
|
|
341
|
-
|
|
369
|
+
const ios = dependency.platforms.ios
|
|
370
|
+
if (ios == null) continue
|
|
342
371
|
if (typeof dependency.root !== 'string')
|
|
343
372
|
throw new Error(
|
|
344
373
|
`${appRoot}: React Native autolinking dependency ${name} has no root`,
|
|
345
374
|
)
|
|
346
|
-
|
|
375
|
+
linked.push({
|
|
376
|
+
name,
|
|
377
|
+
root: dependency.root,
|
|
378
|
+
podspecPath:
|
|
379
|
+
object(ios) && typeof ios.podspecPath === 'string' ? ios.podspecPath : null,
|
|
380
|
+
})
|
|
347
381
|
}
|
|
348
|
-
return
|
|
382
|
+
return linked.sort((a, b) => a.root.localeCompare(b.root))
|
|
349
383
|
}
|
|
350
384
|
|
|
351
385
|
function dependencyRootsFor(
|