peachsim 0.1.2268 → 0.1.2270
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/map.ts +1 -1
- package/cli/commands/record.ts +4 -1
- package/cli/commands/screenshot.ts +10 -0
- package/cli/commands/upload.ts +4 -1
- package/detox/index.ts +8 -4
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- 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 +48 -32
- 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 +14 -7
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +33 -22
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +67 -40
- package/dist-lib/host/fetch-proxy-handler.cjs +13 -10
- 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 +15 -12
- 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 +9 -5
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -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 +13 -10
- package/dist-lib/native-app-identity-project.cjs +5 -1
- package/dist-lib/native-app-identity-project.mjs +5 -1
- 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/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +55 -54
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- 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 +76 -43
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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 +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +8 -6
- package/dist-lib/vite.cjs +13 -10
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/paint-boundary-types.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/preview/compress-node.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1 -0
- package/java-platform/licenses/android.txt +6 -3
- package/java-platform/licenses/openjdk.txt +11 -4
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/answeredNativePackages.ts +16 -1
- package/src/desktop-host-delivery.ts +22 -6
- package/src/expo-pod-prebuilt.ts +29 -3
- package/src/guest-bundle.ts +1 -0
- package/src/kotlin-host.ts +8 -4
- package/src/native-package-slice-build.ts +171 -95
- package/src/package-tree-digest.ts +33 -10
- package/src/swift-submit.ts +2 -1
- package/src/turbo-compile.ts +5 -1
|
@@ -19,7 +19,8 @@ Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
|
|
19
19
|
|
|
20
20
|
The overlay's java/time/format/DateTimeTextNames.java and the LocaleStore edit in
|
|
21
21
|
threeten-patches.ts port Android's java/time/format/DateTimeTextProvider.java and
|
|
22
|
-
sun/util/locale/provider/CalendarDataUtility.java
|
|
22
|
+
sun/util/locale/provider/CalendarDataUtility.java, which the overlay's
|
|
23
|
+
sun/util/locale/provider/CalendarDataUtility.java also ports; kotlin/java/text/DateFormatSymbols.kt
|
|
23
24
|
ports Android's java/text/DateFormatSymbols.java (ojluni, android17-release).
|
|
24
25
|
Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
|
25
26
|
Copyright (C) 2014 The Android Open Source Project
|
|
@@ -28,9 +29,9 @@ Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
|
|
28
29
|
The overlay's java/time/format ZoneTextPrinterParser.java, ZoneIdPrinterParser.java,
|
|
29
30
|
ZoneTextNames.java, PrefixTree.java and PrefixTreeCaseless.java port Android's
|
|
30
31
|
DateTimeFormatterBuilder zone printer-parsers and PrefixTree; kotlin/java/text/JavaZoneNames.kt
|
|
31
|
-
ports java/time/format/ZoneName.java
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
ports java/time/format/ZoneName.java. The overlay's java/util TimeZone.java, SimpleTimeZone.java,
|
|
33
|
+
Calendar.java and GregorianCalendar.java, and its sun/util/calendar files, port Android's copies
|
|
34
|
+
of those OpenJDK files (ojluni, android17-release).
|
|
34
35
|
Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
|
35
36
|
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
36
37
|
Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
|
@@ -43,6 +44,12 @@ members of JCP JSR-166 Expert Group and released to the public domain, as explai
|
|
|
43
44
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
44
45
|
Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
|
45
46
|
|
|
47
|
+
The overlay's java/nio/channels and sun/nio/ch files, with java/io FileInputStream.java and
|
|
48
|
+
FileOutputStream.java, port Android's ojluni sources of those names (android17-release).
|
|
49
|
+
Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
|
50
|
+
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
|
51
|
+
Copyright (C) 2014 The Android Open Source Project
|
|
52
|
+
|
|
46
53
|
This code is free software; you can redistribute it and/or modify it
|
|
47
54
|
under the terms of the GNU General Public License version 2 only, as
|
|
48
55
|
published by the Free Software Foundation. Oracle designates these
|
package/kotlin/sdk.tar.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/runtime-companion.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"abi":1,"sha256":"
|
|
1
|
+
{"abi":1,"sha256":"d02533327d5a71a81c4402948c16014a41f69aaec3e413f48e4dbf3b9a2be677","file":"node/cli-d02533327d5a71a81c4402948c16014a41f69aaec3e413f48e4dbf3b9a2be677.cjs"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
1
2
|
import { readFileSync } from 'node:fs'
|
|
2
3
|
import { join } from 'node:path'
|
|
3
4
|
import {
|
|
@@ -9,6 +10,18 @@ import {
|
|
|
9
10
|
// CLI built from newer source never skips compiling one its runtime lacks.
|
|
10
11
|
export const ANSWERED_NATIVE_PACKAGES_PATH = 'node/answered-native-packages.json'
|
|
11
12
|
|
|
13
|
+
const unansweredStore = new AsyncLocalStorage<ReadonlySet<string>>()
|
|
14
|
+
|
|
15
|
+
/** temporarily omits named packages from the answered set within the callback scope. */
|
|
16
|
+
export function withUnansweredNativePackages<T>(
|
|
17
|
+
packageNames: Iterable<string>,
|
|
18
|
+
fn: () => T,
|
|
19
|
+
): T {
|
|
20
|
+
const merged = new Set(unansweredStore.getStore())
|
|
21
|
+
for (const name of packageNames) merged.add(name)
|
|
22
|
+
return unansweredStore.run(merged, fn)
|
|
23
|
+
}
|
|
24
|
+
|
|
12
25
|
// the companion and the answered packages come from the runtime the host
|
|
13
26
|
// serves: inside the dev checkout that is the dev build `build:peachsim:cli`
|
|
14
27
|
// copied them beside, unless PEACH_HOME stages a runtime, as a release replay
|
|
@@ -35,5 +48,7 @@ export function peachAnsweredNativePackages(): ReadonlySet<string> {
|
|
|
35
48
|
const names = readPeachRuntimeJson(ANSWERED_NATIVE_PACKAGES_PATH)
|
|
36
49
|
if (!Array.isArray(names) || !names.every((name) => typeof name === 'string'))
|
|
37
50
|
throw new Error(`${ANSWERED_NATIVE_PACKAGES_PATH} must list package names`)
|
|
38
|
-
|
|
51
|
+
const overridden = unansweredStore.getStore()
|
|
52
|
+
if (!overridden || overridden.size === 0) return new Set(names)
|
|
53
|
+
return new Set(names.filter((name) => !overridden.has(name)))
|
|
39
54
|
}
|
|
@@ -75,14 +75,30 @@ function verifyHost(dir: string): void {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// a served page asks on every request, so each Info.plist's values are read once per version of the file
|
|
79
|
+
const bundleValues = new Map<
|
|
80
|
+
string,
|
|
81
|
+
{ stamp: string; values: Map<string, string | null> }
|
|
82
|
+
>()
|
|
83
|
+
|
|
78
84
|
function bundleValue(app: string, key: string): string | null {
|
|
85
|
+
const plist = path.join(app, 'Contents/Info.plist')
|
|
86
|
+
const stat = fs.statSync(plist, { throwIfNoEntry: false })
|
|
87
|
+
if (!stat) return null
|
|
88
|
+
const stamp = `${stat.ino}:${stat.size}:${stat.mtimeMs}`
|
|
89
|
+
let entry = bundleValues.get(plist)
|
|
90
|
+
if (entry?.stamp !== stamp) {
|
|
91
|
+
entry = { stamp, values: new Map() }
|
|
92
|
+
bundleValues.set(plist, entry)
|
|
93
|
+
}
|
|
94
|
+
if (entry.values.has(key)) return entry.values.get(key) ?? null
|
|
79
95
|
// runner-toolchain-platform: darwin
|
|
80
|
-
const read = spawnSync(
|
|
81
|
-
'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)
|
|
85
|
-
return
|
|
96
|
+
const read = spawnSync('plutil', ['-extract', key, 'raw', '-o', '-', plist], {
|
|
97
|
+
encoding: 'utf8',
|
|
98
|
+
})
|
|
99
|
+
const value = read.status === 0 ? read.stdout.trim() : null
|
|
100
|
+
entry.values.set(key, value)
|
|
101
|
+
return value
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
/** whether `app` is the native host, as opposed to the Electron app, which
|
package/src/expo-pod-prebuilt.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
nativeEntryPrefix,
|
|
31
31
|
nativePackageEntryName,
|
|
32
32
|
} from './native-prebuilt'
|
|
33
|
-
import {
|
|
33
|
+
import { nativePackageTreeDigest } from './package-tree-digest'
|
|
34
34
|
import { swiftNativePin } from './swift-native-pin'
|
|
35
35
|
|
|
36
36
|
export interface ExpoPodPackage {
|
|
@@ -72,7 +72,7 @@ export async function expoPodInputs(
|
|
|
72
72
|
answered: JSON.stringify([...peachAnsweredNativePackages()].sort()),
|
|
73
73
|
name: pod.name,
|
|
74
74
|
version: pod.version,
|
|
75
|
-
tree: await
|
|
75
|
+
tree: await nativePackageTreeDigest(pod.root),
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -151,7 +151,33 @@ export async function prebuiltExpoPods(
|
|
|
151
151
|
),
|
|
152
152
|
)
|
|
153
153
|
const bundled = await lookup(expoAppBundleEntryUrl(bundleKey, 'metadata.json'))
|
|
154
|
-
if (bundled)
|
|
154
|
+
if (bundled) {
|
|
155
|
+
const isCovered = (swiftModule: string) =>
|
|
156
|
+
bundled.namespaces.some(
|
|
157
|
+
(ns) => ns === swiftModule || ns.startsWith(`${swiftModule}.`),
|
|
158
|
+
)
|
|
159
|
+
const remaining = podEntries.filter(({ pod }) => !isCovered(pod.swiftModule))
|
|
160
|
+
if (remaining.length === 0) return bundled
|
|
161
|
+
const extraEntries = await Promise.all(
|
|
162
|
+
remaining.map(async ({ pod, podKey }) =>
|
|
163
|
+
lookup(expoPodEntryUrl(pod.name, podKey, 'metadata.json')),
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
const extraHits = extraEntries.filter((entry) => entry !== null)
|
|
167
|
+
if (extraHits.length === 0) return bundled
|
|
168
|
+
const merged = [bundled, ...extraHits]
|
|
169
|
+
const bridgeModules = [
|
|
170
|
+
...new Set(merged.flatMap((entry) => entry.bridgeModules ?? [])),
|
|
171
|
+
]
|
|
172
|
+
return {
|
|
173
|
+
namespaces: merged.flatMap((entry) => entry.namespaces),
|
|
174
|
+
...(merged.some((entry) => entry.bridgeModules !== undefined)
|
|
175
|
+
? { bridgeModules }
|
|
176
|
+
: {}),
|
|
177
|
+
modules: merged.flatMap((entry) => entry.modules),
|
|
178
|
+
failures: [],
|
|
179
|
+
}
|
|
180
|
+
}
|
|
155
181
|
}
|
|
156
182
|
const entries = await Promise.all(
|
|
157
183
|
podEntries.map(async ({ pod, podKey }) =>
|
package/src/guest-bundle.ts
CHANGED
package/src/kotlin-host.ts
CHANGED
|
@@ -142,9 +142,11 @@ function entrySource(ids: string[]): string {
|
|
|
142
142
|
'fun peachSetAndroidDeviceInfo(model: String, release: String, apiLevel: Int, locale: String, timeZone: String, settings: String, properties: String) {',
|
|
143
143
|
' Build.setDevice(model, release, apiLevel)',
|
|
144
144
|
' java.util.Locale.setDefault(java.util.Locale.forLanguageTag(locale))',
|
|
145
|
-
' java.util.TimeZone.setDevice(timeZone)',
|
|
146
145
|
' dev.peach.android.ProcessSettings.configure(settings)',
|
|
147
|
-
' android.
|
|
146
|
+
' // the engine reports the device zone apart; android keeps it in persist.sys.timezone',
|
|
147
|
+
' android.os.SystemProperties.configure(org.json.JSONObject(properties).put("persist.sys.timezone", timeZone).toString())',
|
|
148
|
+
" // a later call is the device's time zone change, which ActivityThread answers with setDefault(null)",
|
|
149
|
+
' if (dalvik.system.RuntimeHooks.getTimeZoneIdSupplier() == null) com.android.internal.os.RuntimeInit.commonInit() else java.util.TimeZone.setDefault(null)',
|
|
148
150
|
'}',
|
|
149
151
|
'',
|
|
150
152
|
'@OptIn(kotlin.js.ExperimentalJsExport::class, kotlinx.coroutines.DelicateCoroutinesApi::class)',
|
|
@@ -762,9 +764,11 @@ export async function expoKotlinArtifact(
|
|
|
762
764
|
'@JsExport fun peachSetAndroidDeviceInfo(model: String, release: String, apiLevel: Int, locale: String, timeZone: String, settings: String, properties: String) {',
|
|
763
765
|
' android.os.Build.setDevice(model, release, apiLevel)',
|
|
764
766
|
' java.util.Locale.setDefault(java.util.Locale.forLanguageTag(locale))',
|
|
765
|
-
' java.util.TimeZone.setDevice(timeZone)',
|
|
766
767
|
' dev.peach.android.ProcessSettings.configure(settings)',
|
|
767
|
-
' android.
|
|
768
|
+
' // the engine reports the device zone apart; android keeps it in persist.sys.timezone',
|
|
769
|
+
' android.os.SystemProperties.configure(org.json.JSONObject(properties).put("persist.sys.timezone", timeZone).toString())',
|
|
770
|
+
" // a later call is the device's time zone change, which ActivityThread answers with setDefault(null)",
|
|
771
|
+
' if (dalvik.system.RuntimeHooks.getTimeZoneIdSupplier() == null) com.android.internal.os.RuntimeInit.commonInit() else java.util.TimeZone.setDefault(null)',
|
|
768
772
|
' PeachExpoRuntime.configureProcessLocale(locale)',
|
|
769
773
|
'}',
|
|
770
774
|
'',
|
|
@@ -4,8 +4,13 @@ import fs from 'node:fs'
|
|
|
4
4
|
import { createRequire } from 'node:module'
|
|
5
5
|
import os from 'node:os'
|
|
6
6
|
import path from 'node:path'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
peachAnsweredNativePackages,
|
|
9
|
+
withUnansweredNativePackages,
|
|
10
|
+
} from './answeredNativePackages'
|
|
11
|
+
import { prepareNativeAppRoot } from './expo-native-workspace'
|
|
8
12
|
import { expoPodInputs, expoPodPackages } from './expo-pod-prebuilt'
|
|
13
|
+
import { cacheDir } from './home-paths'
|
|
9
14
|
import { isRecord } from './is-record'
|
|
10
15
|
import {
|
|
11
16
|
buildExpoSwiftPackageSlice,
|
|
@@ -20,14 +25,16 @@ import { nativeEntryKey } from './native-prebuilt'
|
|
|
20
25
|
import { selectCompiledNitroProviders } from './nitro-bundle'
|
|
21
26
|
import { prepareNitroCompileInput } from './nitro-compile'
|
|
22
27
|
import { NITRO_VIEWS_TARGET } from './nitro-source'
|
|
23
|
-
import {
|
|
28
|
+
import { nativePackageTreeDigest } from './package-tree-digest'
|
|
24
29
|
import { reactNativeCoreFloor } from './react-native-core'
|
|
25
30
|
import { compilerSourceDigest, compileSwiftProjectUnit } from './swift-compile'
|
|
26
31
|
import { swiftDistributionRoot, swiftModuleToolchain } from './swift-distribution'
|
|
27
32
|
import { swiftNativePin } from './swift-native-pin'
|
|
28
33
|
import { swiftManifestTargets } from './swift-package'
|
|
34
|
+
import { withSwiftRootLock } from './swift-root-lock'
|
|
29
35
|
import { prepareTurboCompileInput } from './turbo-compile'
|
|
30
36
|
import { discoverTurboProviders, TURBO_CORE_TARGET } from './turbo-source'
|
|
37
|
+
import { installedXcodeWorkspace } from './xcode-project'
|
|
31
38
|
import type { NitroBuildConfiguration } from './nitroContract'
|
|
32
39
|
|
|
33
40
|
export interface DetectedNativePackage {
|
|
@@ -62,48 +69,61 @@ function resolveReactNativeRoot(appRoot: string): string {
|
|
|
62
69
|
export async function detectNativePackageKinds(
|
|
63
70
|
appRoot: string,
|
|
64
71
|
packageName?: string,
|
|
72
|
+
opts?: { includeAnswered?: readonly string[]; kind?: NativePackageSliceKind },
|
|
65
73
|
): Promise<DetectedNativePackage[]> {
|
|
74
|
+
if (opts?.includeAnswered && opts.includeAnswered.length > 0) {
|
|
75
|
+
const nextOpts = opts.kind ? { kind: opts.kind } : undefined
|
|
76
|
+
return withUnansweredNativePackages(opts.includeAnswered, () =>
|
|
77
|
+
detectNativePackageKinds(appRoot, packageName, nextOpts),
|
|
78
|
+
)
|
|
79
|
+
}
|
|
66
80
|
const realRoot = fs.realpathSync(appRoot)
|
|
67
81
|
const answered = peachAnsweredNativePackages()
|
|
68
82
|
const detected: DetectedNativePackage[] = []
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
if (!opts?.kind || opts.kind === 'expo-swift') {
|
|
85
|
+
for (const pod of await expoPodPackages(realRoot)) {
|
|
86
|
+
detected.push({
|
|
87
|
+
name: pod.name,
|
|
88
|
+
version: pod.version,
|
|
89
|
+
root: fs.realpathSync(pod.root),
|
|
90
|
+
kind: 'expo-swift',
|
|
91
|
+
})
|
|
92
|
+
}
|
|
77
93
|
}
|
|
78
94
|
|
|
79
95
|
const nitroNames = new Set<string>()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
if (!opts?.kind || opts.kind === 'nitro') {
|
|
97
|
+
const nitroSelection = await selectCompiledNitroProviders(realRoot)
|
|
98
|
+
for (const provider of nitroSelection?.providers ?? []) {
|
|
99
|
+
const root = fs.realpathSync(provider.root)
|
|
100
|
+
const meta = readPackageMeta(root)
|
|
101
|
+
const version = meta?.version ?? '0.0.0'
|
|
102
|
+
nitroNames.add(provider.name)
|
|
103
|
+
detected.push({
|
|
104
|
+
name: provider.name,
|
|
105
|
+
version,
|
|
106
|
+
root,
|
|
107
|
+
kind: 'nitro',
|
|
108
|
+
})
|
|
109
|
+
}
|
|
92
110
|
}
|
|
93
111
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
if (!opts?.kind || opts.kind === 'turbomodule') {
|
|
113
|
+
const seenTurbo = new Set<string>()
|
|
114
|
+
for (const provider of await discoverTurboProviders(realRoot)) {
|
|
115
|
+
const root = fs.realpathSync(provider.root)
|
|
116
|
+
const meta = readPackageMeta(root)
|
|
117
|
+
if (!meta || seenTurbo.has(meta.name)) continue
|
|
118
|
+
seenTurbo.add(meta.name)
|
|
119
|
+
if (answered.has(meta.name) || nitroNames.has(meta.name)) continue
|
|
120
|
+
detected.push({
|
|
121
|
+
name: meta.name,
|
|
122
|
+
version: meta.version,
|
|
123
|
+
root,
|
|
124
|
+
kind: 'turbomodule',
|
|
125
|
+
})
|
|
126
|
+
}
|
|
107
127
|
}
|
|
108
128
|
|
|
109
129
|
return detected
|
|
@@ -130,7 +150,7 @@ export async function turboPackageSliceInputs(opts: {
|
|
|
130
150
|
version: opts.packageVersion,
|
|
131
151
|
'react-native': opts.reactNativeVersion,
|
|
132
152
|
'core-mode': opts.coreMode,
|
|
133
|
-
tree: await
|
|
153
|
+
tree: await nativePackageTreeDigest(opts.packageRoot),
|
|
134
154
|
}
|
|
135
155
|
}
|
|
136
156
|
|
|
@@ -152,7 +172,7 @@ export async function nitroPackageSliceInputs(opts: {
|
|
|
152
172
|
'nitro-modules': opts.nitroVersion,
|
|
153
173
|
'react-native': opts.reactNativeVersion,
|
|
154
174
|
configuration: opts.configuration,
|
|
155
|
-
tree: await
|
|
175
|
+
tree: await nativePackageTreeDigest(opts.packageRoot),
|
|
156
176
|
}
|
|
157
177
|
}
|
|
158
178
|
|
|
@@ -168,7 +188,14 @@ export async function buildNativePackageSlice(opts: {
|
|
|
168
188
|
projectRoot?: string
|
|
169
189
|
iosTarget?: string
|
|
170
190
|
configuration?: NitroBuildConfiguration
|
|
191
|
+
includeAnswered?: boolean
|
|
171
192
|
}): Promise<LoadedNativePackageSlice | null> {
|
|
193
|
+
if (opts.includeAnswered) {
|
|
194
|
+
const { includeAnswered: _ignored, ...rest } = opts
|
|
195
|
+
return withUnansweredNativePackages([opts.packageName], () =>
|
|
196
|
+
buildNativePackageSlice(rest),
|
|
197
|
+
)
|
|
198
|
+
}
|
|
172
199
|
const appRoot = fs.realpathSync(opts.appRoot)
|
|
173
200
|
const projectRoot = opts.projectRoot ? fs.realpathSync(opts.projectRoot) : appRoot
|
|
174
201
|
const moduleRoot = opts.moduleRoot ?? (await swiftDistributionRoot())
|
|
@@ -190,17 +217,38 @@ export async function buildNativePackageSlice(opts: {
|
|
|
190
217
|
}
|
|
191
218
|
|
|
192
219
|
if (kind === 'turbomodule') {
|
|
193
|
-
|
|
194
|
-
|
|
220
|
+
let resolvedProjectRoot = projectRoot
|
|
221
|
+
let providers = (
|
|
222
|
+
await discoverTurboProviders(appRoot, resolvedProjectRoot, opts.iosTarget)
|
|
195
223
|
).filter((provider) => readPackageMeta(provider.root)?.name === opts.packageName)
|
|
196
224
|
if (providers.length === 0) return null
|
|
225
|
+
const hasExpoConfig = ['app.json', 'app.config.ts', 'app.config.js'].some((name) =>
|
|
226
|
+
fs.existsSync(path.join(appRoot, name)),
|
|
227
|
+
)
|
|
228
|
+
const hasSwiftSources = providers.some((provider) =>
|
|
229
|
+
fs
|
|
230
|
+
.readdirSync(provider.root, { recursive: true, encoding: 'utf8' })
|
|
231
|
+
.some((file) => file.endsWith('.swift')),
|
|
232
|
+
)
|
|
233
|
+
if (
|
|
234
|
+
!opts.projectRoot &&
|
|
235
|
+
!installedXcodeWorkspace(resolvedProjectRoot) &&
|
|
236
|
+
hasExpoConfig &&
|
|
237
|
+
hasSwiftSources
|
|
238
|
+
) {
|
|
239
|
+
resolvedProjectRoot = await prepareNativeAppRoot(appRoot, undefined, opts.iosTarget)
|
|
240
|
+
providers = (
|
|
241
|
+
await discoverTurboProviders(appRoot, resolvedProjectRoot, opts.iosTarget)
|
|
242
|
+
).filter((provider) => readPackageMeta(provider.root)?.name === opts.packageName)
|
|
243
|
+
if (providers.length === 0) return null
|
|
244
|
+
}
|
|
197
245
|
const reactNativeRoot = resolveReactNativeRoot(appRoot)
|
|
198
246
|
const { input, collection } = await prepareTurboCompileInput({
|
|
199
247
|
appRoot,
|
|
200
248
|
reactNativeRoot,
|
|
201
249
|
providers,
|
|
202
250
|
moduleRoot,
|
|
203
|
-
projectRoot,
|
|
251
|
+
projectRoot: resolvedProjectRoot,
|
|
204
252
|
...(opts.iosTarget ? { iosTarget: opts.iosTarget } : {}),
|
|
205
253
|
iosDeploymentTargetFallback: reactNativeCoreFloor(reactNativeRoot),
|
|
206
254
|
})
|
|
@@ -298,6 +346,7 @@ export async function buildNativePackageSlice(opts: {
|
|
|
298
346
|
if (!matchedRoot) return null
|
|
299
347
|
const configuration: NitroBuildConfiguration = opts.configuration ?? 'Release'
|
|
300
348
|
const reactNativeRoot = resolveReactNativeRoot(appRoot)
|
|
349
|
+
const iosDeploymentTargetFallback = reactNativeCoreFloor(reactNativeRoot)
|
|
301
350
|
const { input, collection, packagePath } = await prepareNitroCompileInput({
|
|
302
351
|
appRoot,
|
|
303
352
|
packageRoots: [matchedRoot],
|
|
@@ -306,9 +355,8 @@ export async function buildNativePackageSlice(opts: {
|
|
|
306
355
|
projectRoot,
|
|
307
356
|
...(opts.iosTarget ? { iosTarget: opts.iosTarget } : {}),
|
|
308
357
|
configuration,
|
|
309
|
-
iosDeploymentTargetFallback
|
|
358
|
+
iosDeploymentTargetFallback,
|
|
310
359
|
})
|
|
311
|
-
const workRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'peach-nitro-slice-'))
|
|
312
360
|
try {
|
|
313
361
|
const providerInfo = collection.providers[0]
|
|
314
362
|
if (!providerInfo) return null
|
|
@@ -324,63 +372,91 @@ export async function buildNativePackageSlice(opts: {
|
|
|
324
372
|
const cached = loadNativePackageSlice(providerInfo.name, key, { remote: false })
|
|
325
373
|
if (cached) return cached
|
|
326
374
|
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
buildRoot: compileRoot,
|
|
338
|
-
intermediates: true,
|
|
339
|
-
},
|
|
340
|
-
)
|
|
341
|
-
const packageSwift = input.files['Package.swift'] ?? ''
|
|
342
|
-
const coreTargets = new Set([
|
|
343
|
-
'NitroCore',
|
|
344
|
-
'JsiBridge',
|
|
345
|
-
'NitroModules',
|
|
346
|
-
NITRO_VIEWS_TARGET,
|
|
347
|
-
...Object.keys(input.libraries ?? {}),
|
|
348
|
-
])
|
|
349
|
-
const onlyTargets = new Set(
|
|
350
|
-
swiftManifestTargets(packageSwift)
|
|
351
|
-
.filter((target) => !target.executable && !coreTargets.has(target.name))
|
|
352
|
-
.map((target) => target.name),
|
|
353
|
-
)
|
|
354
|
-
const packed = packCompiledTargetsToSliceDir({
|
|
355
|
-
buildRoot: compileRoot,
|
|
356
|
-
packageSwift,
|
|
357
|
-
toolchainBin: toolchain.toolchainBin,
|
|
358
|
-
stagingDir,
|
|
359
|
-
onlyTargets,
|
|
375
|
+
// share compiled NitroCore/JsiBridge/NitroModules intermediates across slices
|
|
376
|
+
const nitroCoreKey = nativeEntryKey({
|
|
377
|
+
kind: 'nitro-slice-core',
|
|
378
|
+
compiler: compilerSourceDigest,
|
|
379
|
+
'swift-pin': JSON.stringify(swiftNativePin()),
|
|
380
|
+
'nitro-modules': collection.nitro.version,
|
|
381
|
+
'react-native': collection.reactNative.version,
|
|
382
|
+
iosDeploymentTargetFallback,
|
|
383
|
+
...(opts.iosTarget ? { iosTarget: opts.iosTarget } : {}),
|
|
384
|
+
configuration,
|
|
360
385
|
})
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
const compileRoot = path.join(cacheDir(), 'nitro-slice-build', nitroCoreKey)
|
|
387
|
+
return await withSwiftRootLock(`${compileRoot}.slice-lock`, async () => {
|
|
388
|
+
const lockedCached = loadNativePackageSlice(providerInfo.name, key, {
|
|
389
|
+
remote: false,
|
|
390
|
+
})
|
|
391
|
+
if (lockedCached) return lockedCached
|
|
392
|
+
|
|
393
|
+
fs.mkdirSync(compileRoot, { recursive: true })
|
|
394
|
+
const sourcesDir = path.join(compileRoot, 'Sources')
|
|
395
|
+
if (fs.existsSync(sourcesDir)) {
|
|
396
|
+
for (const entry of fs.readdirSync(sourcesDir)) {
|
|
397
|
+
if (entry.startsWith('NitroPackage_')) {
|
|
398
|
+
fs.rmSync(path.join(sourcesDir, entry), { recursive: true, force: true })
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const stagingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'peach-nitro-slice-'))
|
|
403
|
+
try {
|
|
404
|
+
const toolchain = swiftModuleToolchain(moduleRoot)
|
|
405
|
+
await compileSwiftProjectUnit(
|
|
406
|
+
{ ...input, optimize: false },
|
|
407
|
+
{
|
|
408
|
+
...toolchain,
|
|
409
|
+
moduleRoot,
|
|
410
|
+
buildRoot: compileRoot,
|
|
411
|
+
intermediates: true,
|
|
412
|
+
},
|
|
413
|
+
)
|
|
414
|
+
const packageSwift = input.files['Package.swift'] ?? ''
|
|
415
|
+
const coreTargets = new Set([
|
|
416
|
+
'NitroCore',
|
|
417
|
+
'JsiBridge',
|
|
418
|
+
'NitroModules',
|
|
419
|
+
NITRO_VIEWS_TARGET,
|
|
420
|
+
...Object.keys(input.libraries ?? {}),
|
|
421
|
+
])
|
|
422
|
+
const onlyTargets = new Set(
|
|
423
|
+
swiftManifestTargets(packageSwift)
|
|
424
|
+
.filter((target) => !target.executable && !coreTargets.has(target.name))
|
|
425
|
+
.map((target) => target.name),
|
|
426
|
+
)
|
|
427
|
+
const packed = packCompiledTargetsToSliceDir({
|
|
428
|
+
buildRoot: compileRoot,
|
|
429
|
+
packageSwift,
|
|
430
|
+
toolchainBin: toolchain.toolchainBin,
|
|
431
|
+
stagingDir,
|
|
432
|
+
onlyTargets,
|
|
433
|
+
})
|
|
434
|
+
const targetNames = packed.targets.map((target) => target.name)
|
|
435
|
+
const manifest: NativePackageSliceManifest = {
|
|
436
|
+
schema: 1,
|
|
437
|
+
kind: 'nitro',
|
|
438
|
+
packageName: providerInfo.name,
|
|
439
|
+
packageVersion: providerInfo.version,
|
|
440
|
+
key,
|
|
441
|
+
runtimePin: swiftNativePin(),
|
|
442
|
+
targets: packed.targets,
|
|
443
|
+
nitro: {
|
|
444
|
+
targetNames,
|
|
445
|
+
hybridObjects: providerInfo.hybridObjects,
|
|
446
|
+
registrations: collection.registrations,
|
|
447
|
+
},
|
|
448
|
+
}
|
|
449
|
+
return finalizeSliceEntry({
|
|
450
|
+
manifest,
|
|
451
|
+
inputs,
|
|
452
|
+
assetFiles: packed.files,
|
|
453
|
+
stagingDir,
|
|
454
|
+
})
|
|
455
|
+
} finally {
|
|
456
|
+
fs.rmSync(stagingDir, { recursive: true, force: true })
|
|
457
|
+
}
|
|
381
458
|
})
|
|
382
459
|
} finally {
|
|
383
460
|
fs.rmSync(packagePath, { recursive: true, force: true })
|
|
384
|
-
fs.rmSync(workRoot, { recursive: true, force: true })
|
|
385
461
|
}
|
|
386
462
|
}
|
|
@@ -5,25 +5,48 @@ import { join } from 'node:path'
|
|
|
5
5
|
|
|
6
6
|
const READ_AHEAD = 64
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
function hashPackageTree(
|
|
9
|
+
root: string,
|
|
10
|
+
options: {
|
|
11
|
+
compareNames: (left: string, right: string) => number
|
|
12
|
+
skipFile?: (name: string) => boolean
|
|
13
|
+
},
|
|
14
|
+
): Promise<string> {
|
|
10
15
|
const files: string[] = []
|
|
11
16
|
const walk = (directory: string, relative: string) => {
|
|
12
17
|
for (const entry of readdirSync(directory, { withFileTypes: true }).sort((a, b) =>
|
|
13
|
-
a.name
|
|
18
|
+
options.compareNames(a.name, b.name),
|
|
14
19
|
)) {
|
|
15
20
|
if (entry.name === 'node_modules') continue
|
|
16
21
|
const path = `${relative}${entry.name}`
|
|
17
22
|
if (entry.isDirectory()) walk(join(directory, entry.name), `${path}/`)
|
|
18
|
-
else if (entry.isFile()) files.push(path)
|
|
23
|
+
else if (entry.isFile() && !options.skipFile?.(entry.name)) files.push(path)
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
walk(root, '')
|
|
22
27
|
const hash = createHash('sha256')
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
return (async () => {
|
|
29
|
+
for (let start = 0; start < files.length; start += READ_AHEAD) {
|
|
30
|
+
const batch = files.slice(start, start + READ_AHEAD)
|
|
31
|
+
const bytes = await Promise.all(batch.map((file) => readFile(join(root, file))))
|
|
32
|
+
batch.forEach((file, index) => hash.update(`${file}\0`).update(bytes[index]!))
|
|
33
|
+
}
|
|
34
|
+
return hash.digest('hex')
|
|
35
|
+
})()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** an installed package's source tree digest, its nested node_modules excluded. */
|
|
39
|
+
export function packageTreeDigest(root: string): Promise<string> {
|
|
40
|
+
return hashPackageTree(root, {
|
|
41
|
+
compareNames: (left, right) => left.localeCompare(right),
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** native-build package digest excluding declaration and sourcemap outputs plugins may rewrite. */
|
|
46
|
+
export function nativePackageTreeDigest(root: string): Promise<string> {
|
|
47
|
+
return hashPackageTree(root, {
|
|
48
|
+
compareNames: (left, right) => (left < right ? -1 : left > right ? 1 : 0),
|
|
49
|
+
skipFile: (name) =>
|
|
50
|
+
name.endsWith('.d.ts') || name.endsWith('.d.ts.map') || name.endsWith('.js.map'),
|
|
51
|
+
})
|
|
29
52
|
}
|
package/src/swift-submit.ts
CHANGED
|
@@ -151,7 +151,8 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
|
|
|
151
151
|
// `peach.bitmap_release`; trees name them `peach-bitmap:<id>`.
|
|
152
152
|
// 72: a refresh may answer `{"$patch":[node]}`, nodes that replace the same
|
|
153
153
|
// ids in the last tree.
|
|
154
|
-
|
|
154
|
+
// 73: custom label styles retain a StyledLabel accessibility host.
|
|
155
|
+
export const SWIFT_HOST_ABI = 73
|
|
155
156
|
|
|
156
157
|
export interface SwiftImageUpload {
|
|
157
158
|
/** the raster file picked for the asset (has the extension). */
|