stim 1.14.0 → 1.15.0
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/README.md +2 -0
- package/dist/{activity-CYVDcrt3.mjs → activity-B2-kb7k0.mjs} +281 -41
- package/dist/{android-XpvCrV7q.mjs → android-CYmq0jNi.mjs} +2 -2
- package/dist/{android-LbPFRWVL.mjs → android-Cu_L4RpL.mjs} +502 -407
- package/dist/{android-d6rGq1pA.mjs → android-Db2eEMaf.mjs} +152 -65
- package/dist/android-cas-PnKfAdB2.mjs +167 -0
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/{app-install-BpgSgkJj.mjs → app-install-CAAplXAt.mjs} +95 -161
- package/dist/{budget-CGDkhvv_.mjs → budget-CMiqghig.mjs} +1038 -73
- package/dist/{build-plan-Dcr-3ie0.mjs → build-plan-aeGMFX7e.mjs} +193 -653
- package/dist/build-progress-C2Jv1AtA.mjs +872 -0
- package/dist/build-slots-Df1ApSuH.mjs +127 -0
- package/dist/{cache-manifest-C68QQ0ua.mjs → cache-manifest-DnUHBJaU.mjs} +2 -2
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{chrome-BPCiC3ZX.mjs → chrome-BrcVWQyD.mjs} +1 -1
- package/dist/cli-0cX5s4NM.mjs +45 -0
- package/dist/cli.mjs +6 -42
- package/dist/client-C2IS36Qf.mjs +1333 -0
- package/dist/collector-run.mjs +8 -7
- package/dist/{command-output-DVcpw6eE.mjs → command-output-CliHHn7a.mjs} +1 -1
- package/dist/{config-lvc7d3C2.mjs → config-D0DbpZtM.mjs} +28 -29
- package/dist/{created-devices-CllH_8eb.mjs → created-devices-BwVb3liH.mjs} +2 -2
- package/dist/{dependency-state-DsT7aKeo.mjs → dependency-state-BmsjKZ2H.mjs} +2 -2
- package/dist/{deps-D9IcKqXS.mjs → deps-BFlKbOIp.mjs} +3 -3
- package/dist/{detached-entry-DJHoca49.mjs → detached-entry-CiTEgMR1.mjs} +1 -1
- package/dist/dev-client-CjzLoNs0.mjs +80 -0
- package/dist/{device-CjuuAJjQ.mjs → device-BZ1IyS5A.mjs} +7 -7
- package/dist/device-capacity-DMuKC7nx.mjs +136 -0
- package/dist/device-host-worker.d.mts +1 -0
- package/dist/device-host-worker.mjs +769 -0
- package/dist/device-ios-DMQBUPus.mjs +381 -0
- package/dist/{device-lease-5c3WrVRm.mjs → device-lease-W5Pi1q38.mjs} +43 -36
- package/dist/{device-pool-BiyDyPP-.mjs → device-pool-B2r38YjS.mjs} +4 -4
- package/dist/{device-remote-D87zEzaq.mjs → device-remote-9ulPsdhY.mjs} +68 -162
- package/dist/{doctor-x9pnU9fq.mjs → doctor-BcE5xsBn.mjs} +191 -99
- package/dist/{error-diagnostics-C5HzcwCW.mjs → error-diagnostics-Cb0P1WLS.mjs} +12 -11
- package/dist/{exec-DK8KaVHK.mjs → exec-CaErVv7t.mjs} +5 -1
- package/dist/{gc-ko6mUAYD.mjs → gc-BuL1Genr.mjs} +429 -101
- package/dist/{android-cas-iZK3DOCr.mjs → gradle-CmdOBq1d.mjs} +8 -294
- package/dist/{guide-6R0VNFqI.mjs → guide-cCSGRFd3.mjs} +1959 -222
- package/dist/{guide-status-BZrFPIA_.mjs → guide-status-CIoWK6mG.mjs} +3 -3
- package/dist/hosted-macos-DwowNU7W.mjs +447 -0
- package/dist/idle-shutdown-B5LPaNyY.mjs +122 -0
- package/dist/in-use-CndPMilN.mjs +110 -0
- package/dist/{ios-BwDPrnYQ.mjs → ios-3CtCRhwr.mjs} +201 -10
- package/dist/{ios-P1f5nm2n.mjs → ios-Chob8ny7.mjs} +512 -263
- package/dist/{ios-device-DGglU3E_.mjs → ios-device-DERmMmk-.mjs} +12 -7
- package/dist/{ios-device-BiOsSVzd.mjs → ios-device-Ee7sDXfp.mjs} +1 -1
- package/dist/{launch-verify-Deg4tB3Z.mjs → launch-verify-CLlofxRt.mjs} +4 -4
- package/dist/{logs-Civ4gbBH.mjs → logs-h9h6MUvE.mjs} +95 -13
- package/dist/machine-usage-D_YYMzfR.mjs +283 -0
- package/dist/machines-CYtOCqcj.mjs +259 -0
- package/dist/macos-BwtbUtTN.mjs +468 -0
- package/dist/macos-run.d.mts +5 -0
- package/dist/macos-run.mjs +2 -0
- package/dist/{merge-state-ytFQCeh4.mjs → merge-state-BnxLNQiM.mjs} +22 -12
- package/dist/{metro-CcEo8Fl8.mjs → metro-Di8EN2Tb.mjs} +20 -120
- package/dist/{named-ports-Blg8IxOh.mjs → named-ports-Dj_XBNaL.mjs} +6 -59
- package/dist/native-run-DFDoIRbY.mjs +147 -0
- package/dist/{native-runtime-DjBHRg5m.mjs → native-runtime-i6OkVg-w.mjs} +9 -5
- package/dist/offload-worker.d.mts +121 -0
- package/dist/offload-worker.mjs +601 -0
- package/dist/{ownership-DyYDF5ww.mjs → ownership-BkYxUtuj.mjs} +3 -2
- package/dist/{page-BHUzTDFt.mjs → page-QF_Ke10s.mjs} +7 -2
- package/dist/{ports-BguS83ex.mjs → ports-DddwttKM.mjs} +3 -3
- package/dist/prebuild-BvxDlD6C.mjs +213 -0
- package/dist/process-identity-BmRm1qV0.mjs +12 -0
- package/dist/{project-CWlvEaeN.mjs → project-CV3tDFHl.mjs} +9 -18
- package/dist/pull-request-pxnDCQzn.mjs +322 -0
- package/dist/pull-requests.d.mts +120 -0
- package/dist/pull-requests.mjs +2 -0
- package/dist/recordings-GEXp4iBT.mjs +37 -0
- package/dist/{reload-BiniwsSZ.mjs → reload-ChPiwvot.mjs} +70 -22
- package/dist/{remote-cache-CcR6o6lI.mjs → remote-cache-CO2elm_b.mjs} +4 -4
- package/dist/run-B-xqRrsg.mjs +119 -0
- package/dist/{server-bare-DGfgyJ5J.mjs → server-bare-X7PUgizL.mjs} +33 -15
- package/dist/{server-expo-BVuwQ65v.mjs → server-expo-DhtX6bom.mjs} +6 -10
- package/dist/server-expo-KJeD109I.mjs +2 -0
- package/dist/{settings-D61iNOsB.mjs → settings-CduVcoxj.mjs} +77 -26
- package/dist/{settings-B-fsC-Om.mjs → settings-DbL6uhH8.mjs} +16 -10
- package/dist/settings.schema.json +357 -2
- package/dist/{simslim-DrDN4WuV.mjs → simslim-Ciluxlq4.mjs} +8 -132
- package/dist/{slot-launch-D5t8EiMf.mjs → slot-launch-BY0BrOLh.mjs} +6 -6
- package/dist/{spawn-claims-Drw_o-Fb.mjs → spawn-claims-D0XfSe8u.mjs} +1 -1
- package/dist/spawn-entry-DncpJvWL.mjs +16 -0
- package/dist/stage-CzaiwFsI.mjs +143 -0
- package/dist/start-CPO4wRg7.mjs +2 -0
- package/dist/{start-s4RXp1wy.mjs → start-CUD9nasA.mjs} +108 -61
- package/dist/state-B4PQFXMW.d.mts +12 -0
- package/dist/state-BxCgeTQu.mjs +41 -0
- package/dist/{state-DHqvsbqC.mjs → state-CaeaHbDA.mjs} +7 -4
- package/dist/{state-Dk9RVXI7.mjs → state-DFm77wRn.mjs} +67 -5
- package/dist/stats-DBLLFmKd.mjs +66 -0
- package/dist/{status-BsPAnfOI.mjs → status-DYXxNOT0.mjs} +423 -268
- package/dist/{status-BgAuxESg.mjs → status-l84Gbvp2.mjs} +116 -20
- package/dist/stdout-reader-C8yjre1x.mjs +23 -0
- package/dist/stim-desktop-Cnz8CPnl.mjs +63 -0
- package/dist/stim-footprint.swift +32 -0
- package/dist/{stim-installations-CINXy_su.mjs → stim-installations-QMEI32v1.mjs} +1 -1
- package/dist/{stop-BzreOWJp.mjs → stop-Bad61z_2.mjs} +38 -12
- package/dist/stop-Bvf1MflS.mjs +48 -0
- package/dist/{stop-BWIF_6BK.mjs → stop-CceYh1yG.mjs} +2 -2
- package/dist/stop-cause-CZ_Mr-v9.mjs +665 -0
- package/dist/supervisor-run.d.mts +43 -11
- package/dist/supervisor-run.mjs +227 -19
- package/dist/support-CDQbDkL5.mjs +315 -0
- package/dist/support-WLOzVKUv.mjs +176 -0
- package/dist/teardown-BYuQafiA.mjs +718 -0
- package/dist/{xcode-Cp5KvK9x.mjs → toolchain-DmeYjXD9.mjs} +363 -13
- package/dist/warm-progress-DVHLN4uC.mjs +463 -0
- package/dist/{idle-DXtx3RbX.mjs → watchman-Bx0wceoF.mjs} +55 -8
- package/dist/{web-BsQs1WlO.mjs → web-k6w8-HnE.mjs} +37 -20
- package/dist/web-run.mjs +309 -12
- package/dist/workspace-process-lock-BL7Q0HCO.mjs +57 -0
- package/dist/workspace-state-CL2V2Ons.mjs +371 -0
- package/dist/worktree-BT_uULFx.mjs +2 -0
- package/dist/{worktree-BVrHsYZG.mjs → worktree-C0c5Udwa.mjs} +55 -54
- package/dist/{worktree-UrQWXSeb.mjs → worktree-qXKzADSC.mjs} +154 -252
- package/package.json +10 -5
- package/shim/bundle-response.cjs +28 -12
- package/dist/build-progress-DxKpwnaS.mjs +0 -247
- package/dist/in-use-DlqBDKqY.mjs +0 -249
- package/dist/server-expo-DIHDhvGg.mjs +0 -2
- package/dist/start-Cetfvy8l.mjs +0 -2
- package/dist/stats-CFpFGlJV.mjs +0 -62
- package/dist/stats-CX1Z8Tca.mjs +0 -368
- package/dist/stim-desktop-CXt8-Z3J.mjs +0 -40
- package/dist/stop-cause-hjGBOZTG.mjs +0 -1231
- package/dist/worktree-CHWWvm5v.mjs +0 -2
- package/dist/{metro-store-DzeWkfqW.mjs → metro-store-CDDZHtPl.mjs} +1 -1
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { D as makeTemporaryDirectory, O as removeTemporaryEntry, c as gitCommonDirOnDisk } from "./worktree-
|
|
5
|
-
import { c as ownedDeviceLabel
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { i as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
1
|
+
import { t as getExecutor } from "./exec-CaErVv7t.mjs";
|
|
2
|
+
import { D as withConfigLock$1, H as projectDeviceSlots, _ as loadConfig$1, a as clearDevice, b as releaseAndroidConsolePort, i as clearAndroidBootPending, k as acquireAvdClaim, t as allConsolePortsAndSerials, w as setDevice, z as deviceSlotPlatforms } from "./config-D0DbpZtM.mjs";
|
|
3
|
+
import { m as sharedBuildCache } from "./workspace-state-CL2V2Ons.mjs";
|
|
4
|
+
import { D as makeTemporaryDirectory, O as removeTemporaryEntry, c as gitCommonDirOnDisk } from "./worktree-C0c5Udwa.mjs";
|
|
5
|
+
import { c as ownedDeviceLabel } from "./project-CV3tDFHl.mjs";
|
|
6
|
+
import { r as waitForChild, t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
|
|
7
|
+
import { i as formatDuration, l as phaseLine, m as shortHash, u as plural } from "./command-output-CliHHn7a.mjs";
|
|
8
|
+
import { C as diffFingerprintSources, I as storedSources, w as entryDir, y as artifactIn } from "./device-lease-W5Pi1q38.mjs";
|
|
9
|
+
import { A as listAvds, B as ownedAvdSystemImage, E as getAvdNameForSerial, F as ownedAvdDeviceProfile, J as resolveOwnedAvdSerial, L as ownedAvdMatchesConfiguration, O as listAdbDevices, P as nextConsolePort, R as ownedAvdName, W as pickDefaultSystemImage, b as createOwnedAvd, dt as parkedMaxSetting, f as assertOwnedAvdStopped, ft as readParked, g as avdPoolConfiguration, j as listInstalledSystemImages, lt as isLegacyDeletionClaim, n as OWNED_AVD_CONFIG_DEFAULTS, ot as adoptParked, t as DEFAULT_AVD_DEVICE_PROFILE, tt as waitForBoot, v as bootAndroidEmulator, y as configureNewOwnedAvd } from "./android-Db2eEMaf.mjs";
|
|
10
|
+
import { o as pidExists } from "./metro-Di8EN2Tb.mjs";
|
|
11
|
+
import { l as androidDataPartitionSizeGbSetting, o as androidAvdConfigSetting } from "./settings-CduVcoxj.mjs";
|
|
12
|
+
import { i as teardownOwnedAvd, s as teardownParkedAvd } from "./teardown-BYuQafiA.mjs";
|
|
13
|
+
import { j as readHostMemoryPressure, u as listAllIosSims } from "./ios-3CtCRhwr.mjs";
|
|
14
|
+
import { o as estimateBuild, p as readStats } from "./build-progress-C2Jv1AtA.mjs";
|
|
15
|
+
import { t as clearDeviceIdleShutdown } from "./idle-shutdown-B5LPaNyY.mjs";
|
|
16
|
+
import { i as liveOwnedDeviceCount } from "./device-capacity-DMuKC7nx.mjs";
|
|
17
|
+
import { b as tailLines, u as HEARTBEAT_INTERVAL_MS, y as startBuildHeartbeat } from "./toolchain-DmeYjXD9.mjs";
|
|
18
|
+
import { t as cleanLine } from "./server-expo-DhtX6bom.mjs";
|
|
19
|
+
import { i as staleNativeDirRefusal } from "./prebuild-BvxDlD6C.mjs";
|
|
20
|
+
import { i as ensureOwnedIosDevice, r as ensureIosBooted } from "./device-ios-DMQBUPus.mjs";
|
|
21
|
+
import { a as easAuthNote } from "./remote-cache-CO2elm_b.mjs";
|
|
22
|
+
import { t as reconcileSimSlim } from "./simslim-Ciluxlq4.mjs";
|
|
23
|
+
import { randomUUID } from "node:crypto";
|
|
24
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
23
25
|
import { basename, dirname, join, relative } from "node:path";
|
|
26
|
+
import { LAST_BUILD_KEYS, loadConfig, readWorkspaceState } from "@stim-cli/core/state";
|
|
24
27
|
import { claimRemoveCommand, clearClaimChild, markClaimChildPending, processGroupAlive, releaseClaim, setClaimChild } from "@stim-cli/core/ownership-claim";
|
|
25
28
|
import { captureProcessIdentity } from "@stim-cli/core/process-identity";
|
|
26
|
-
import { randomUUID } from "node:crypto";
|
|
27
29
|
import chalk from "chalk";
|
|
28
30
|
import { isDeepStrictEqual } from "node:util";
|
|
29
31
|
import * as expoFingerprint from "@expo/fingerprint";
|
|
@@ -91,370 +93,6 @@ async function warmMetro({ port, platform, isExpo, appId, bundleUrl }) {
|
|
|
91
93
|
} catch {}
|
|
92
94
|
}
|
|
93
95
|
//#endregion
|
|
94
|
-
//#region src/engine/device-ios.ts
|
|
95
|
-
function startIosBoot(udid, configure, label, out, simulatorApp) {
|
|
96
|
-
const done = (async () => {
|
|
97
|
-
await bootIosSim(udid, {
|
|
98
|
-
label,
|
|
99
|
-
out,
|
|
100
|
-
simulatorApp
|
|
101
|
-
});
|
|
102
|
-
await configure();
|
|
103
|
-
})();
|
|
104
|
-
done.catch(() => {});
|
|
105
|
-
return {
|
|
106
|
-
udid,
|
|
107
|
-
done
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
var IosDeviceMismatchError = class extends Error {
|
|
111
|
-
remedy = "Run `stim worktree remove` (or `stim gc --delete`) to reap the current sim, then `stim ios` again to create the requested one, or pass `--slot <name>` to create it beside the current one.";
|
|
112
|
-
};
|
|
113
|
-
async function ensureOwnedIosDevice({ record, projectPath, slot, settingsRoot, label, settings, flags, note, out, reconcileIosSimulator }) {
|
|
114
|
-
const memoryAdvice = hostMemoryPressureAdvice(readHostMemoryPressure());
|
|
115
|
-
if (memoryAdvice) out(chalk.yellow(phaseLine("memory", memoryAdvice)));
|
|
116
|
-
const simslimProfile = iosSimSlimProfileSetting(settings, settingsRoot);
|
|
117
|
-
if (record?.deviceUdid) {
|
|
118
|
-
if (record.owned) {
|
|
119
|
-
const resolved = resolveOwnedIosSim(record.deviceUdid);
|
|
120
|
-
if (resolved.notOwned) note(chalk.yellow(`Note: recorded sim is now named "${resolved.notOwned}", not Stim-owned -- creating a fresh owned sim instead of booting it.`));
|
|
121
|
-
else if (resolved.missing) {} else {
|
|
122
|
-
const sim = resolved.sim;
|
|
123
|
-
const wantedType = flags.deviceType || settings?.ios?.deviceType;
|
|
124
|
-
const deviceTypes = listIosDeviceTypes();
|
|
125
|
-
const mismatch = deviceTypeMismatch(sim.deviceTypeIdentifier, wantedType, deviceTypes);
|
|
126
|
-
if (mismatch) throw new IosDeviceMismatchError(`${mismatch}. Stim will not silently boot a different model.`);
|
|
127
|
-
const versionMismatch = flags.runtimeFlag ? runtimeMismatch(sim.runtime, flags.runtimeFlag, listIosRuntimes()) : null;
|
|
128
|
-
if (versionMismatch) throw new IosDeviceMismatchError(`${versionMismatch}. Stim will not silently boot a different iOS version.`);
|
|
129
|
-
const model = {
|
|
130
|
-
model: deviceTypes.find((d) => d.identifier === sim.deviceTypeIdentifier)?.name ?? null,
|
|
131
|
-
runtime: parseRuntimeVersion(sim.runtime)
|
|
132
|
-
};
|
|
133
|
-
const name = await withIosDeviceNameLock(() => renameToOwnedName(sim, label, model, projectPath));
|
|
134
|
-
const updated = {
|
|
135
|
-
deviceUdid: sim.udid,
|
|
136
|
-
owned: true,
|
|
137
|
-
deviceName: name,
|
|
138
|
-
...record.simslimManaged ? { simslimManaged: true } : {},
|
|
139
|
-
...record.adopted ? { adopted: true } : {},
|
|
140
|
-
...record.adoptionPending ? { adoptionPending: true } : {},
|
|
141
|
-
...record.parkedCacheKey ? { parkedCacheKey: record.parkedCacheKey } : {}
|
|
142
|
-
};
|
|
143
|
-
const configure = async () => {
|
|
144
|
-
if (record.adoptionPending) resetAdoptedSim(sim.udid, out);
|
|
145
|
-
return configureOwnedIosSim({
|
|
146
|
-
record: updated,
|
|
147
|
-
projectPath,
|
|
148
|
-
slot,
|
|
149
|
-
profile: simslimProfile,
|
|
150
|
-
out,
|
|
151
|
-
reconcileIosSimulator
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
const facts = {
|
|
155
|
-
deviceType: model.model,
|
|
156
|
-
runtime: model.runtime
|
|
157
|
-
};
|
|
158
|
-
if (sim.state !== "Booted") {
|
|
159
|
-
out(chalk.dim(phaseLine("device", `booting ${name} (${sim.udid})`)));
|
|
160
|
-
return {
|
|
161
|
-
...updated,
|
|
162
|
-
booting: startIosBoot(sim.udid, configure, name, out, flags.simulatorApp),
|
|
163
|
-
...facts
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
...await configure(),
|
|
168
|
-
...facts
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
const sim = listAllIosSims().find((s) => s.udid === record.deviceUdid);
|
|
173
|
-
if (sim) {
|
|
174
|
-
if (sim.state !== "Booted") {
|
|
175
|
-
note(chalk.yellow(`Note: assigned sim ${sim.name} (${sim.udid}) is shut down and is not owned by Stim, so it will not be booted automatically.`));
|
|
176
|
-
note(chalk.dim("Boot it yourself, or run `stim gc --delete` to clear the assignment so Stim can create an owned sim."));
|
|
177
|
-
}
|
|
178
|
-
return record;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
withConfigLock$1(() => {
|
|
182
|
-
const current = deviceSlotPlatforms(loadConfig$1()?.projects?.[projectPath], slot)?.ios;
|
|
183
|
-
if (!current) return;
|
|
184
|
-
if (current.deviceUdid !== record.deviceUdid || current.owned !== record.owned) throw new Error("The simulator assignment changed during recovery. Run `stim ios` again.");
|
|
185
|
-
clearDevice(projectPath, "ios", slot);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
const choice = resolveIosCreation({
|
|
189
|
-
deviceType: flags.deviceType || settings.ios?.deviceType,
|
|
190
|
-
runtime: flags.runtime || settings.ios?.runtime
|
|
191
|
-
});
|
|
192
|
-
const adopted = parkedMaxSetting("ios").max > 0 ? await withIosDeviceNameLock(() => takeParkedIosSim({
|
|
193
|
-
projectPath,
|
|
194
|
-
slot,
|
|
195
|
-
label,
|
|
196
|
-
choice,
|
|
197
|
-
out
|
|
198
|
-
})) : null;
|
|
199
|
-
if (adopted) {
|
|
200
|
-
out(chalk.dim(phaseLine("device", `booting ${adopted.deviceName} (${adopted.deviceUdid})`)));
|
|
201
|
-
const booting = startIosBoot(adopted.deviceUdid, async () => {
|
|
202
|
-
resetAdoptedSim(adopted.deviceUdid, out);
|
|
203
|
-
await configureOwnedIosSim({
|
|
204
|
-
record: adopted,
|
|
205
|
-
projectPath,
|
|
206
|
-
slot,
|
|
207
|
-
profile: simslimProfile,
|
|
208
|
-
out,
|
|
209
|
-
reconcileIosSimulator
|
|
210
|
-
});
|
|
211
|
-
}, adopted.deviceName, out, flags.simulatorApp);
|
|
212
|
-
return {
|
|
213
|
-
...adopted,
|
|
214
|
-
booting,
|
|
215
|
-
deviceType: choice.deviceType,
|
|
216
|
-
runtime: choice.runtime
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
const created = await withIosDeviceNameLock(() => {
|
|
220
|
-
const suffix = ownedIosNameSuffix(label, {
|
|
221
|
-
model: choice.deviceType,
|
|
222
|
-
runtime: choice.runtime
|
|
223
|
-
}, projectPath);
|
|
224
|
-
const result = createOwnedIosSim(label, { suffix }, choice);
|
|
225
|
-
setDevice(projectPath, "ios", {
|
|
226
|
-
deviceUdid: result.udid,
|
|
227
|
-
owned: true,
|
|
228
|
-
deviceName: result.name
|
|
229
|
-
}, slot);
|
|
230
|
-
return result;
|
|
231
|
-
});
|
|
232
|
-
const newRecord = {
|
|
233
|
-
deviceUdid: created.udid,
|
|
234
|
-
owned: true,
|
|
235
|
-
deviceName: created.name
|
|
236
|
-
};
|
|
237
|
-
const booting = startIosBoot(created.udid, () => configureOwnedIosSim({
|
|
238
|
-
record: newRecord,
|
|
239
|
-
projectPath,
|
|
240
|
-
slot,
|
|
241
|
-
profile: simslimProfile,
|
|
242
|
-
out,
|
|
243
|
-
reconcileIosSimulator
|
|
244
|
-
}), created.name, out, flags.simulatorApp);
|
|
245
|
-
return {
|
|
246
|
-
...newRecord,
|
|
247
|
-
created: true,
|
|
248
|
-
booting,
|
|
249
|
-
deviceType: created.deviceType,
|
|
250
|
-
runtime: created.runtime
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function withIosDeviceNameLock(fn) {
|
|
254
|
-
return withWorkspaceProcessLock(getConfigDir(), "ios-device-names", async () => fn(), { external: true });
|
|
255
|
-
}
|
|
256
|
-
function ownedIosNameSuffix(label, model, projectPath, udid) {
|
|
257
|
-
const names = new Set(listAllIosSims({ includeUnavailable: true }).filter((sim) => sim.udid !== udid).map((sim) => sim.name));
|
|
258
|
-
for (const project of Object.values(loadConfig$1()?.projects ?? {})) for (const { platforms } of projectDeviceSlots(project)) {
|
|
259
|
-
const record = platforms.ios;
|
|
260
|
-
if (record?.deviceUdid !== udid && record?.deviceName) names.add(record.deviceName);
|
|
261
|
-
}
|
|
262
|
-
for (const parked of readParked("ios")) if (parked.udid !== udid) names.add(parked.name);
|
|
263
|
-
let suffix = "";
|
|
264
|
-
for (let attempt = 0; names.has(ownedSimName(label, model, suffix)); attempt++) suffix = ` ${workspaceId(projectPath)}${attempt ? `-${attempt}` : ""}`;
|
|
265
|
-
return suffix;
|
|
266
|
-
}
|
|
267
|
-
function renameToOwnedName(sim, label, model, projectPath) {
|
|
268
|
-
const wanted = ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, sim.udid));
|
|
269
|
-
if (sim.name === wanted) return wanted;
|
|
270
|
-
try {
|
|
271
|
-
renameIosSim(sim.udid, wanted);
|
|
272
|
-
return wanted;
|
|
273
|
-
} catch {
|
|
274
|
-
return sim.name;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
function resetAdoptedSim(udid, out) {
|
|
278
|
-
out(chalk.dim(phaseLine("device", `resetting privacy grants and the keychain on ${udid}`)));
|
|
279
|
-
resetIosPrivacy(udid);
|
|
280
|
-
resetIosKeychain(udid);
|
|
281
|
-
}
|
|
282
|
-
function takeParkedIosSim({ projectPath, slot, label, choice, out }) {
|
|
283
|
-
const candidates = selectParked(readParked("ios"), {
|
|
284
|
-
deviceTypeIdentifier: choice.deviceTypeId,
|
|
285
|
-
runtimeIdentifier: choice.runtimeId
|
|
286
|
-
});
|
|
287
|
-
if (candidates.length === 0) return null;
|
|
288
|
-
const listed = new Map(listAllIosSims({ includeUnavailable: true }).map((sim) => [sim.udid, sim]));
|
|
289
|
-
for (const parked of candidates) {
|
|
290
|
-
const sim = listed.get(parked.udid);
|
|
291
|
-
if (!sim || !sim.available) {
|
|
292
|
-
const result = sim ? teardownParkedIosSim(parked.udid, { label: parked.name }) : null;
|
|
293
|
-
if (sim ? result?.status === "torn-down" : dropParked("ios", parked.udid)) out(chalk.dim(phaseLine("device", `deleted parked ${parked.name} (${parked.udid}): ${sim ? "unavailable" : "gone"}`)));
|
|
294
|
-
else if (result?.status === "failed") out(chalk.yellow(phaseLine("device", `could not delete unavailable parked ${parked.name} (${parked.udid}): ${result.reason}`)));
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
if (!sim.name.startsWith("stim-")) {
|
|
298
|
-
out(chalk.yellow(phaseLine("device", `kept parked record for ${parked.udid}: simulator is now named ${JSON.stringify(sim.name)} and is not Stim-owned`)));
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
const model = {
|
|
302
|
-
model: choice.deviceType,
|
|
303
|
-
runtime: choice.runtime
|
|
304
|
-
};
|
|
305
|
-
const name = ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, parked.udid));
|
|
306
|
-
const device = {
|
|
307
|
-
deviceUdid: parked.udid,
|
|
308
|
-
owned: true,
|
|
309
|
-
deviceName: name,
|
|
310
|
-
adopted: true,
|
|
311
|
-
adoptionPending: true,
|
|
312
|
-
...parked.simslimManaged ? { simslimManaged: true } : {},
|
|
313
|
-
...parked.cacheKey ? { parkedCacheKey: parked.cacheKey } : {}
|
|
314
|
-
};
|
|
315
|
-
if (!adoptParked({
|
|
316
|
-
platform: "ios",
|
|
317
|
-
projectPath,
|
|
318
|
-
slot,
|
|
319
|
-
udid: parked.udid,
|
|
320
|
-
device
|
|
321
|
-
})) continue;
|
|
322
|
-
try {
|
|
323
|
-
renameIosSim(parked.udid, name);
|
|
324
|
-
} catch {}
|
|
325
|
-
return device;
|
|
326
|
-
}
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
function clearIosAdoptionPending(projectPath, slot = "default") {
|
|
330
|
-
withConfigLock$1(() => {
|
|
331
|
-
const cfg = loadConfig$1();
|
|
332
|
-
const ios = deviceSlotPlatforms(cfg?.projects?.[projectPath], slot)?.ios;
|
|
333
|
-
if (!cfg || !ios?.adoptionPending) return;
|
|
334
|
-
delete ios.adopted;
|
|
335
|
-
delete ios.adoptionPending;
|
|
336
|
-
delete ios.parkedCacheKey;
|
|
337
|
-
saveConfig(cfg);
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
async function configureOwnedIosSim({ record, projectPath, slot, profile, out, reconcileIosSimulator }) {
|
|
341
|
-
if (profile) out(chalk.dim(phaseLine("device", `applying the SimSlim profile to ${record.deviceUdid}`)));
|
|
342
|
-
else if (record.simslimManaged) out(chalk.dim(phaseLine("device", `restoring stock simulator services on ${record.deviceUdid}`)));
|
|
343
|
-
const previouslyManaged = Boolean(record.simslimManaged);
|
|
344
|
-
if (profile && !record.simslimManaged) {
|
|
345
|
-
const pending = {
|
|
346
|
-
...record,
|
|
347
|
-
simslimManaged: true
|
|
348
|
-
};
|
|
349
|
-
setDevice(projectPath, "ios", pending, slot);
|
|
350
|
-
record = pending;
|
|
351
|
-
}
|
|
352
|
-
const result = await reconcileIosSimulator({
|
|
353
|
-
udid: record.deviceUdid,
|
|
354
|
-
profile,
|
|
355
|
-
previouslyManaged,
|
|
356
|
-
out
|
|
357
|
-
});
|
|
358
|
-
const updated = { ...record };
|
|
359
|
-
if (result.managed) updated.simslimManaged = true;
|
|
360
|
-
else delete updated.simslimManaged;
|
|
361
|
-
setDevice(projectPath, "ios", updated, slot);
|
|
362
|
-
return updated;
|
|
363
|
-
}
|
|
364
|
-
async function ensureIosBooted({ device, simulatorApp, timeoutMs, pollMs, out }) {
|
|
365
|
-
const udid = device?.deviceUdid;
|
|
366
|
-
if (!udid) return {
|
|
367
|
-
failed: true,
|
|
368
|
-
reason: "No iOS simulator is recorded for this project."
|
|
369
|
-
};
|
|
370
|
-
const ready = () => {
|
|
371
|
-
try {
|
|
372
|
-
getExecutor().runFile("xcrun", [
|
|
373
|
-
"simctl",
|
|
374
|
-
"spawn",
|
|
375
|
-
udid,
|
|
376
|
-
"launchctl",
|
|
377
|
-
"list"
|
|
378
|
-
], { timeoutMs: 3e4 });
|
|
379
|
-
return {
|
|
380
|
-
ok: true,
|
|
381
|
-
udid
|
|
382
|
-
};
|
|
383
|
-
} catch (error) {
|
|
384
|
-
return {
|
|
385
|
-
failed: true,
|
|
386
|
-
reason: `Simulator ${udid} failed its process-spawn readiness check: ${error?.message || error}. ${iosSimulatorFailureAdvice()}`
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const booting = device?.booting;
|
|
391
|
-
if (booting?.udid === udid) {
|
|
392
|
-
try {
|
|
393
|
-
await booting.done;
|
|
394
|
-
} catch (e) {
|
|
395
|
-
return {
|
|
396
|
-
failed: true,
|
|
397
|
-
reason: `Could not boot simulator ${udid}: ${e?.message || e}`
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
return ready();
|
|
401
|
-
}
|
|
402
|
-
let resolved;
|
|
403
|
-
try {
|
|
404
|
-
resolved = resolveOwnedIosSim(udid);
|
|
405
|
-
} catch (e) {
|
|
406
|
-
return {
|
|
407
|
-
failed: true,
|
|
408
|
-
reason: `Could not list simulators: ${e?.message || e}`
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
if (resolved.missing) return {
|
|
412
|
-
failed: true,
|
|
413
|
-
reason: `Simulator ${udid} no longer exists. Run \`stim ios\` again to create a fresh owned sim.`
|
|
414
|
-
};
|
|
415
|
-
if (resolved.notOwned) return {
|
|
416
|
-
failed: true,
|
|
417
|
-
reason: `Simulator ${udid} is now named "${resolved.notOwned}" and is not Stim-owned; refusing to boot it.`
|
|
418
|
-
};
|
|
419
|
-
const sim = resolved.sim;
|
|
420
|
-
if (sim.state === "Booted") {
|
|
421
|
-
const result = ready();
|
|
422
|
-
if (result.ok && simulatorApp !== void 0) configuredIosSimulatorViewer(simulatorApp).open(udid);
|
|
423
|
-
return result;
|
|
424
|
-
}
|
|
425
|
-
out(chalk.dim(phaseLine("device", `booting ${sim.name} (${udid})`)));
|
|
426
|
-
const bootDeadline = Date.now() + timeoutMs;
|
|
427
|
-
try {
|
|
428
|
-
await bootIosSim(udid, {
|
|
429
|
-
timeoutMs,
|
|
430
|
-
label: sim.name,
|
|
431
|
-
out,
|
|
432
|
-
simulatorApp
|
|
433
|
-
});
|
|
434
|
-
} catch (e) {
|
|
435
|
-
return {
|
|
436
|
-
failed: true,
|
|
437
|
-
reason: `Could not boot simulator ${udid}: ${e?.message || e}`
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
const deadline = Math.max(bootDeadline, Date.now() + 2 * pollMs);
|
|
441
|
-
while (Date.now() < deadline) {
|
|
442
|
-
await sleep(pollMs);
|
|
443
|
-
let state = null;
|
|
444
|
-
try {
|
|
445
|
-
state = listAllIosSims({ timeoutMs: 3e4 }).find((s) => s.udid === udid)?.state ?? null;
|
|
446
|
-
} catch {}
|
|
447
|
-
if (state === "Booted") return ready();
|
|
448
|
-
}
|
|
449
|
-
return {
|
|
450
|
-
failed: true,
|
|
451
|
-
reason: `Simulator ${udid} did not reach the Booted state within ${Math.round(timeoutMs / 1e3)}s.`
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function sleep(ms) {
|
|
455
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
456
|
-
}
|
|
457
|
-
//#endregion
|
|
458
96
|
//#region src/engine/android-avd-setup.ts
|
|
459
97
|
var AvdBootError = class extends Error {
|
|
460
98
|
remedy;
|
|
@@ -863,7 +501,8 @@ async function bootOwnedAvdOnFreshPort({ avdName, metadata, projectPath, slot, d
|
|
|
863
501
|
const { bootPending: _booted, ...booted } = claim;
|
|
864
502
|
return {
|
|
865
503
|
...booted,
|
|
866
|
-
serial
|
|
504
|
+
serial,
|
|
505
|
+
setup: true
|
|
867
506
|
};
|
|
868
507
|
} catch (error) {
|
|
869
508
|
releaseAndroidConsolePort(projectPath, claim.consolePort, slot);
|
|
@@ -990,7 +629,15 @@ async function ensureAndroidBooted({ device, projectPath, slot, timeoutMs, out,
|
|
|
990
629
|
}
|
|
991
630
|
//#endregion
|
|
992
631
|
//#region src/engine/device.ts
|
|
632
|
+
/**
|
|
633
|
+
* Whether `ensureOwnedDevice` created, adopted or started booting the device, rather than finding it booted.
|
|
634
|
+
* Undefined for a remote device, which those functions do not describe.
|
|
635
|
+
*/
|
|
636
|
+
function didSetUpDevice(device, remote) {
|
|
637
|
+
return remote ? void 0 : Boolean(device.setup || device.booting);
|
|
638
|
+
}
|
|
993
639
|
async function ensureOwnedDevice({ platform, project, projectPath, slot, settingsRoot = projectPath, label = ownedDeviceLabel(projectPath), settings, flags = {}, note = () => {}, out = () => {}, logFile = null, alive = pidExists, configureAvd = configureNewOwnedAvd, teardownAvd = teardownOwnedAvd, reconcileIosSimulator = reconcileSimSlim }) {
|
|
640
|
+
clearDeviceIdleShutdown(projectPath, platform, slot);
|
|
994
641
|
if (slot && slot !== "default") label = `${label}-${slot}`;
|
|
995
642
|
const record = deviceSlotPlatforms(project, slot)?.[platform] ?? null;
|
|
996
643
|
if (platform === "ios") return ensureOwnedIosDevice({
|
|
@@ -1045,210 +692,6 @@ async function ensureBooted({ platform, device, simulatorApp, timeoutMs, pollMs
|
|
|
1045
692
|
};
|
|
1046
693
|
}
|
|
1047
694
|
//#endregion
|
|
1048
|
-
//#region src/engine/prebuild.ts
|
|
1049
|
-
const PREBUILD_ERROR = "STIM_PREBUILD_FAILED";
|
|
1050
|
-
const LAST_LINES$1 = 20;
|
|
1051
|
-
function nativeDirName(platform) {
|
|
1052
|
-
return platform === "android" ? "android" : "ios";
|
|
1053
|
-
}
|
|
1054
|
-
function nativeDir(root, platform) {
|
|
1055
|
-
return join(root, nativeDirName(platform));
|
|
1056
|
-
}
|
|
1057
|
-
function nativeDirInFingerprint(sources, platform) {
|
|
1058
|
-
const dir = nativeDirName(platform);
|
|
1059
|
-
return sources.some((source) => source.type === "dir" && source.filePath === dir && source.hash != null);
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* @expo/fingerprint leaves a native directory out of the hash when git ignores it (CNG), so the cache
|
|
1063
|
-
* key only covers that directory when this workspace's recorded prebuild ran on the same fingerprint.
|
|
1064
|
-
*/
|
|
1065
|
-
function prebuildAction({ isExpo, nativeDirExists, nativeDirFingerprinted, nativeDirTracked, generatedFrom, fingerprint }) {
|
|
1066
|
-
if (!isExpo) return "none";
|
|
1067
|
-
if (!nativeDirExists) return "generate";
|
|
1068
|
-
if (nativeDirFingerprinted || generatedFrom === fingerprint) return "none";
|
|
1069
|
-
return nativeDirTracked ? "refuse" : "regenerate";
|
|
1070
|
-
}
|
|
1071
|
-
function prebuildRecord(state) {
|
|
1072
|
-
const record = state?.prebuild;
|
|
1073
|
-
return record && typeof record === "object" ? record : {};
|
|
1074
|
-
}
|
|
1075
|
-
function gitTracksNativeDir(root, platform) {
|
|
1076
|
-
try {
|
|
1077
|
-
return getExecutor().runFile("git", [
|
|
1078
|
-
"-C",
|
|
1079
|
-
root,
|
|
1080
|
-
"ls-files",
|
|
1081
|
-
"--",
|
|
1082
|
-
nativeDirName(platform)
|
|
1083
|
-
], { env: {
|
|
1084
|
-
LC_ALL: "C",
|
|
1085
|
-
LANGUAGE: "C"
|
|
1086
|
-
} }).trim() !== "";
|
|
1087
|
-
} catch (error) {
|
|
1088
|
-
if (error?.code === "ENOENT") return false;
|
|
1089
|
-
return !/not a git repository \(or any (of the parent directories|parent up to mount point)/.test(String(error?.message));
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
function planPrebuild(root, platform, { isExpo, fingerprint, sources }) {
|
|
1093
|
-
const nativeDirExists = existsSync(nativeDir(root, platform));
|
|
1094
|
-
const fingerprinted = nativeDirInFingerprint(sources, platform);
|
|
1095
|
-
const generatedFrom = prebuildRecord(readWorkspaceState$1(root))[platform];
|
|
1096
|
-
return prebuildAction({
|
|
1097
|
-
isExpo,
|
|
1098
|
-
nativeDirExists,
|
|
1099
|
-
nativeDirFingerprinted: fingerprinted,
|
|
1100
|
-
nativeDirTracked: nativeDirExists && !fingerprinted && gitTracksNativeDir(root, platform),
|
|
1101
|
-
generatedFrom: typeof generatedFrom === "string" ? generatedFrom : null,
|
|
1102
|
-
fingerprint
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
function recordPrebuild(root, platform, fingerprint) {
|
|
1106
|
-
updateWorkspaceState(root, (state) => ({
|
|
1107
|
-
...state,
|
|
1108
|
-
prebuild: {
|
|
1109
|
-
...prebuildRecord(state),
|
|
1110
|
-
[platform]: fingerprint
|
|
1111
|
-
}
|
|
1112
|
-
}));
|
|
1113
|
-
}
|
|
1114
|
-
function staleNativeDirRefusal(platform) {
|
|
1115
|
-
const dir = nativeDirName(platform);
|
|
1116
|
-
return {
|
|
1117
|
-
code: PREBUILD_ERROR,
|
|
1118
|
-
message: `The fingerprint leaves ${dir}/ out of the cache key, and Stim cannot show that ${dir}/ was generated from the current app config. Git tracks files in it, or could not say whether it does, so Stim will not regenerate it with \`expo prebuild --clean\`.`,
|
|
1119
|
-
remedy: `Stop excluding ${dir}/ from the fingerprint (check .fingerprintignore) so the cache key covers its files, or add ${dir}/ to .gitignore and untrack it so Stim regenerates it from the app config.`
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
function prebuildRefusal({ isExpo, platform, nativeDirExists }) {
|
|
1123
|
-
if (nativeDirExists || isExpo) return null;
|
|
1124
|
-
const dir = nativeDirName(platform);
|
|
1125
|
-
return {
|
|
1126
|
-
code: PREBUILD_ERROR,
|
|
1127
|
-
message: `This project has no ${dir}/ directory and is not an Expo (CNG) project, so Stim cannot generate one.`,
|
|
1128
|
-
remedy: `Check out or generate the native project (\`npx @react-native-community/cli init\` produced one originally), or add \`expo\` to the project so \`expo prebuild\` can create ${dir}/.`
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
function prebuildFailure(logWriter, result) {
|
|
1132
|
-
logWriter?.write?.({
|
|
1133
|
-
src: "build",
|
|
1134
|
-
level: "error",
|
|
1135
|
-
msg: result.reason || "Expo prebuild failed.",
|
|
1136
|
-
event: "prebuild_failed"
|
|
1137
|
-
});
|
|
1138
|
-
return result;
|
|
1139
|
-
}
|
|
1140
|
-
async function runPrebuild(root, platform, logWriter, { spawnFn = null, now = Date.now, isExpo = null, clean = false } = {}) {
|
|
1141
|
-
const dirExists = existsSync(nativeDir(root, platform));
|
|
1142
|
-
const refusal = prebuildRefusal({
|
|
1143
|
-
isExpo: isExpo === null ? detectIsExpo(root) : isExpo,
|
|
1144
|
-
platform,
|
|
1145
|
-
nativeDirExists: dirExists
|
|
1146
|
-
});
|
|
1147
|
-
if (refusal) return prebuildFailure(logWriter, {
|
|
1148
|
-
failed: true,
|
|
1149
|
-
code: refusal.code,
|
|
1150
|
-
reason: refusal.message,
|
|
1151
|
-
remedy: refusal.remedy,
|
|
1152
|
-
error: refusal,
|
|
1153
|
-
lastLines: []
|
|
1154
|
-
});
|
|
1155
|
-
const bin = expoBinPath(root);
|
|
1156
|
-
if (!bin) {
|
|
1157
|
-
const binRefusal = expoBinRefusal(root, "prebuild");
|
|
1158
|
-
return prebuildFailure(logWriter, {
|
|
1159
|
-
failed: true,
|
|
1160
|
-
code: PREBUILD_ERROR,
|
|
1161
|
-
reason: binRefusal.message,
|
|
1162
|
-
remedy: binRefusal.remedy,
|
|
1163
|
-
lastLines: []
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
const spawn = spawnFn || ((cmd, args, opts) => getExecutor().spawn(cmd, args, opts));
|
|
1167
|
-
const startedAt = now();
|
|
1168
|
-
const tail = [];
|
|
1169
|
-
const push = (line) => {
|
|
1170
|
-
const msg = stripAnsi(String(line)).trimEnd();
|
|
1171
|
-
if (!msg.trim()) return;
|
|
1172
|
-
tail.push(msg);
|
|
1173
|
-
if (tail.length > LAST_LINES$1) tail.shift();
|
|
1174
|
-
logWriter?.write?.({
|
|
1175
|
-
src: "build",
|
|
1176
|
-
level: "debug",
|
|
1177
|
-
msg,
|
|
1178
|
-
raw: true,
|
|
1179
|
-
event: "prebuild"
|
|
1180
|
-
});
|
|
1181
|
-
};
|
|
1182
|
-
let child;
|
|
1183
|
-
try {
|
|
1184
|
-
child = spawnDeclared(() => spawn(bin, [
|
|
1185
|
-
"prebuild",
|
|
1186
|
-
"-p",
|
|
1187
|
-
platform,
|
|
1188
|
-
"--no-install",
|
|
1189
|
-
...clean ? ["--clean"] : []
|
|
1190
|
-
], {
|
|
1191
|
-
cwd: root,
|
|
1192
|
-
stdio: [
|
|
1193
|
-
"ignore",
|
|
1194
|
-
"pipe",
|
|
1195
|
-
"pipe"
|
|
1196
|
-
],
|
|
1197
|
-
env: {
|
|
1198
|
-
...process.env,
|
|
1199
|
-
FORCE_COLOR: "0",
|
|
1200
|
-
CI: "1"
|
|
1201
|
-
}
|
|
1202
|
-
}));
|
|
1203
|
-
} catch (err) {
|
|
1204
|
-
return prebuildFailure(logWriter, {
|
|
1205
|
-
failed: true,
|
|
1206
|
-
code: PREBUILD_ERROR,
|
|
1207
|
-
reason: `Could not run \`expo prebuild\`: ${err?.message || err}`,
|
|
1208
|
-
lastLines: []
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
const outReader = createLineReader(push);
|
|
1212
|
-
const errReader = createLineReader(push);
|
|
1213
|
-
child.stdout?.setEncoding?.("utf-8");
|
|
1214
|
-
child.stderr?.setEncoding?.("utf-8");
|
|
1215
|
-
child.stdout?.on("data", (chunk) => outReader.push(chunk));
|
|
1216
|
-
child.stderr?.on("data", (chunk) => errReader.push(chunk));
|
|
1217
|
-
const result = await waitForChild(child);
|
|
1218
|
-
outReader.flush();
|
|
1219
|
-
errReader.flush();
|
|
1220
|
-
const durationMs = now() - startedAt;
|
|
1221
|
-
if (result.error) return prebuildFailure(logWriter, {
|
|
1222
|
-
failed: true,
|
|
1223
|
-
code: PREBUILD_ERROR,
|
|
1224
|
-
reason: `Could not run \`expo prebuild\`: ${result.error?.message || result.error}`,
|
|
1225
|
-
lastLines: tail.slice(),
|
|
1226
|
-
durationMs
|
|
1227
|
-
});
|
|
1228
|
-
if (result.code !== 0) {
|
|
1229
|
-
const how = result.signal ? `signal ${result.signal}` : `exit code ${result.code}`;
|
|
1230
|
-
return prebuildFailure(logWriter, {
|
|
1231
|
-
failed: true,
|
|
1232
|
-
code: PREBUILD_ERROR,
|
|
1233
|
-
reason: `\`expo prebuild -p ${platform}\` failed (${how}).`,
|
|
1234
|
-
lastLines: tail.slice(),
|
|
1235
|
-
durationMs
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
if (!existsSync(nativeDir(root, platform))) return prebuildFailure(logWriter, {
|
|
1239
|
-
failed: true,
|
|
1240
|
-
code: PREBUILD_ERROR,
|
|
1241
|
-
reason: `\`expo prebuild -p ${platform}\` succeeded but did not create ${nativeDirName(platform)}/.`,
|
|
1242
|
-
lastLines: tail.slice(),
|
|
1243
|
-
durationMs
|
|
1244
|
-
});
|
|
1245
|
-
return {
|
|
1246
|
-
ok: true,
|
|
1247
|
-
durationMs,
|
|
1248
|
-
nativeDir: nativeDir(root, platform)
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
//#endregion
|
|
1252
695
|
//#region src/engine/js-swap.ts
|
|
1253
696
|
const JS_BUNDLE_NAME = "main.jsbundle";
|
|
1254
697
|
const LAST_LINES = 5;
|
|
@@ -1290,7 +733,8 @@ function detectEntryFile(root) {
|
|
|
1290
733
|
}
|
|
1291
734
|
return pickEntryFile(entries);
|
|
1292
735
|
}
|
|
1293
|
-
function bundleCommand({ isExpo, entryFile, bundleOutput, assetsDest }) {
|
|
736
|
+
function bundleCommand({ isExpo, entryFile, bundleOutput, assetsDest, assetCatalogDest = null }) {
|
|
737
|
+
const catalogArgs = assetCatalogDest ? ["--asset-catalog-dest", assetCatalogDest] : [];
|
|
1294
738
|
if (isExpo) return {
|
|
1295
739
|
file: "npx",
|
|
1296
740
|
args: [
|
|
@@ -1303,7 +747,8 @@ function bundleCommand({ isExpo, entryFile, bundleOutput, assetsDest }) {
|
|
|
1303
747
|
"--bundle-output",
|
|
1304
748
|
bundleOutput,
|
|
1305
749
|
"--assets-dest",
|
|
1306
|
-
assetsDest
|
|
750
|
+
assetsDest,
|
|
751
|
+
...catalogArgs
|
|
1307
752
|
]
|
|
1308
753
|
};
|
|
1309
754
|
return {
|
|
@@ -1320,10 +765,117 @@ function bundleCommand({ isExpo, entryFile, bundleOutput, assetsDest }) {
|
|
|
1320
765
|
"--bundle-output",
|
|
1321
766
|
bundleOutput,
|
|
1322
767
|
"--assets-dest",
|
|
1323
|
-
assetsDest
|
|
768
|
+
assetsDest,
|
|
769
|
+
...catalogArgs
|
|
1324
770
|
]
|
|
1325
771
|
};
|
|
1326
772
|
}
|
|
773
|
+
const ASSET_CATALOG_BUNDLE = "RNAssets.bundle";
|
|
774
|
+
/**
|
|
775
|
+
* Where React Native 0.88+ keeps the app's packager images. With the `RCTUseAssetCatalog` Info.plist
|
|
776
|
+
* key, `react-native-xcode.sh` compiles them with actool into RNAssets.bundle and the native image
|
|
777
|
+
* loader reads only that catalog, so a swap has to rebuild it. Null means loose files under assets/.
|
|
778
|
+
*/
|
|
779
|
+
function assetCatalogTarget(infoPlist) {
|
|
780
|
+
if (!infoPlist || typeof infoPlist !== "object") return null;
|
|
781
|
+
const plist = infoPlist;
|
|
782
|
+
const flag = plist.RCTUseAssetCatalog;
|
|
783
|
+
if (!(flag === true || flag === 1 || typeof flag === "string" && [
|
|
784
|
+
"true",
|
|
785
|
+
"yes",
|
|
786
|
+
"1"
|
|
787
|
+
].includes(flag.toLowerCase()))) return null;
|
|
788
|
+
const families = Array.isArray(plist.UIDeviceFamily) ? plist.UIDeviceFamily : [1];
|
|
789
|
+
const targetDevices = [...families.includes(1) ? ["iphone"] : [], ...families.includes(2) ? ["ipad"] : []];
|
|
790
|
+
return {
|
|
791
|
+
platform: typeof plist.DTPlatformName === "string" ? plist.DTPlatformName : "iphoneos",
|
|
792
|
+
minimumDeploymentTarget: typeof plist.MinimumOSVersion === "string" ? plist.MinimumOSVersion : "15.1",
|
|
793
|
+
targetDevices: targetDevices.length ? targetDevices : ["iphone"]
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function readPlistKey(e, plist, key, format) {
|
|
797
|
+
try {
|
|
798
|
+
return e.runFile("plutil", [
|
|
799
|
+
"-extract",
|
|
800
|
+
key,
|
|
801
|
+
format,
|
|
802
|
+
"-o",
|
|
803
|
+
"-",
|
|
804
|
+
plist
|
|
805
|
+
]);
|
|
806
|
+
} catch (err) {
|
|
807
|
+
if (/No value at that key path/.test(describe(err))) return null;
|
|
808
|
+
throw err;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function readAssetCatalogTarget(e, plist) {
|
|
812
|
+
const flag = readPlistKey(e, plist, "RCTUseAssetCatalog", "raw");
|
|
813
|
+
if (flag === null) return null;
|
|
814
|
+
const families = readPlistKey(e, plist, "UIDeviceFamily", "json");
|
|
815
|
+
return assetCatalogTarget({
|
|
816
|
+
RCTUseAssetCatalog: flag,
|
|
817
|
+
DTPlatformName: readPlistKey(e, plist, "DTPlatformName", "raw"),
|
|
818
|
+
MinimumOSVersion: readPlistKey(e, plist, "MinimumOSVersion", "raw"),
|
|
819
|
+
UIDeviceFamily: families === null ? void 0 : JSON.parse(families)
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function actoolArgs({ catalog, out, target }) {
|
|
823
|
+
return [
|
|
824
|
+
"actool",
|
|
825
|
+
catalog,
|
|
826
|
+
"--compile",
|
|
827
|
+
out,
|
|
828
|
+
"--output-format",
|
|
829
|
+
"human-readable-text",
|
|
830
|
+
"--errors",
|
|
831
|
+
"--warnings",
|
|
832
|
+
"--notices",
|
|
833
|
+
"--platform",
|
|
834
|
+
target.platform,
|
|
835
|
+
"--minimum-deployment-target",
|
|
836
|
+
target.minimumDeploymentTarget,
|
|
837
|
+
...target.targetDevices.flatMap((device) => ["--target-device", device])
|
|
838
|
+
];
|
|
839
|
+
}
|
|
840
|
+
const ASSET_CATALOG_BUNDLE_INFO_PLIST = `<?xml version="1.0" encoding="UTF-8"?>
|
|
841
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
842
|
+
<plist version="1.0">
|
|
843
|
+
<dict>
|
|
844
|
+
<key>CFBundleIdentifier</key>
|
|
845
|
+
<string>org.reactjs.RNAssets</string>
|
|
846
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
847
|
+
<string>6.0</string>
|
|
848
|
+
<key>CFBundleName</key>
|
|
849
|
+
<string>RNAssets</string>
|
|
850
|
+
<key>CFBundlePackageType</key>
|
|
851
|
+
<string>BNDL</string>
|
|
852
|
+
</dict>
|
|
853
|
+
</plist>
|
|
854
|
+
`;
|
|
855
|
+
const UPDATES_MANIFEST_NAME = "app.manifest";
|
|
856
|
+
/**
|
|
857
|
+
* expo-updates launches the update with the newest `commitTime` among those built for the binary's
|
|
858
|
+
* runtime version, and the embedded one is only a row in that race. A swapped copy keeps the id and
|
|
859
|
+
* `commitTime` the cached build wrote, so an update downloaded after that build would launch instead
|
|
860
|
+
* of the injected bundle. A full build writes a fresh id and `commitTime`; this does the same.
|
|
861
|
+
*/
|
|
862
|
+
function refreshUpdatesManifest(text, { id, commitTime }) {
|
|
863
|
+
const manifest = JSON.parse(text);
|
|
864
|
+
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) throw new Error(`${UPDATES_MANIFEST_NAME} is not a JSON object`);
|
|
865
|
+
return JSON.stringify({
|
|
866
|
+
...manifest,
|
|
867
|
+
id,
|
|
868
|
+
commitTime
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
function refreshUpdatesManifestFile(path, commitTime) {
|
|
872
|
+
writeFileSync(path, refreshUpdatesManifest(readFileSync(path, "utf-8"), {
|
|
873
|
+
id: randomUUID(),
|
|
874
|
+
commitTime
|
|
875
|
+
}));
|
|
876
|
+
}
|
|
877
|
+
const IOS_UPDATES_MANIFESTS = [join("EXUpdates.bundle", UPDATES_MANIFEST_NAME), UPDATES_MANIFEST_NAME];
|
|
878
|
+
const IOS_FRAMEWORK_UPDATES_MANIFEST = join("Frameworks", "EXUpdates.framework", "EXUpdates.bundle", UPDATES_MANIFEST_NAME);
|
|
1327
879
|
function hermescPath(root, { exists = existsSync } = {}) {
|
|
1328
880
|
const candidates = [
|
|
1329
881
|
join(root, "node_modules", "hermes-compiler", "hermesc", "osx-bin", "hermesc"),
|
|
@@ -1383,19 +935,34 @@ async function swapJsBundle({ root, isExpo, cachedAppPath, logWriter = null, exe
|
|
|
1383
935
|
} catch (err) {
|
|
1384
936
|
return fail("copy", `could not copy ${cachedAppPath} aside: ${describe(err)}`);
|
|
1385
937
|
}
|
|
938
|
+
let catalogTarget;
|
|
939
|
+
const infoPlistPath = join(appCopy, "Info.plist");
|
|
940
|
+
try {
|
|
941
|
+
catalogTarget = readAssetCatalogTarget(e, infoPlistPath);
|
|
942
|
+
} catch (err) {
|
|
943
|
+
return fail("catalog", `could not read ${infoPlistPath}: ${describe(err)}`);
|
|
944
|
+
}
|
|
1386
945
|
const bundleOutput = join(tmp, JS_BUNDLE_NAME);
|
|
1387
946
|
const assetsDest = join(tmp, "assets");
|
|
947
|
+
const catalogStaging = catalogTarget ? join(tmp, "rn-assets") : null;
|
|
948
|
+
const catalogDir = catalogStaging ? join(catalogStaging, "RNAssets.xcassets") : null;
|
|
1388
949
|
const command = bundleCommand({
|
|
1389
950
|
isExpo,
|
|
1390
951
|
entryFile: isExpo ? "index.js" : detectEntryFile(root),
|
|
1391
952
|
bundleOutput,
|
|
1392
|
-
assetsDest
|
|
953
|
+
assetsDest,
|
|
954
|
+
assetCatalogDest: catalogStaging
|
|
1393
955
|
});
|
|
1394
956
|
try {
|
|
1395
957
|
mkdirSync(assetsDest, { recursive: true });
|
|
1396
958
|
} catch (err) {
|
|
1397
959
|
return fail("bundle", `could not create ${assetsDest}: ${describe(err)}`);
|
|
1398
960
|
}
|
|
961
|
+
if (catalogDir) try {
|
|
962
|
+
mkdirSync(catalogDir, { recursive: true });
|
|
963
|
+
} catch (err) {
|
|
964
|
+
return fail("bundle", `could not create ${catalogDir}: ${describe(err)}`);
|
|
965
|
+
}
|
|
1399
966
|
logWriter?.write?.({
|
|
1400
967
|
src: "build",
|
|
1401
968
|
level: "info",
|
|
@@ -1490,6 +1057,34 @@ async function swapJsBundle({ root, isExpo, cachedAppPath, logWriter = null, exe
|
|
|
1490
1057
|
} catch (err) {
|
|
1491
1058
|
return fail("replace", `could not replace the JS bundle inside ${appCopy}: ${describe(err)}`);
|
|
1492
1059
|
}
|
|
1060
|
+
if (catalogTarget && catalogDir) {
|
|
1061
|
+
const catalogBundle = join(appCopy, ASSET_CATALOG_BUNDLE);
|
|
1062
|
+
try {
|
|
1063
|
+
rmSync(catalogBundle, {
|
|
1064
|
+
recursive: true,
|
|
1065
|
+
force: true
|
|
1066
|
+
});
|
|
1067
|
+
if (readdirSync(catalogDir).some((name) => name.endsWith(".imageset"))) {
|
|
1068
|
+
mkdirSync(catalogBundle);
|
|
1069
|
+
const output = e.runFile("xcrun", actoolArgs({
|
|
1070
|
+
catalog: catalogDir,
|
|
1071
|
+
out: catalogBundle,
|
|
1072
|
+
target: catalogTarget
|
|
1073
|
+
}));
|
|
1074
|
+
if (!exists(join(catalogBundle, "Assets.car"))) return fail("actool", `actool wrote no Assets.car into ${catalogBundle}`, tailLines(output.split("\n"), LAST_LINES));
|
|
1075
|
+
writeFileSync(join(catalogBundle, "Info.plist"), ASSET_CATALOG_BUNDLE_INFO_PLIST);
|
|
1076
|
+
}
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
const stdout = String(err?.stdout ?? "");
|
|
1079
|
+
return fail("actool", `could not compile the image asset catalog into ${catalogBundle}: ${describe(err)}`, tailLines(stdout.split("\n"), LAST_LINES));
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (exists(join(appCopy, IOS_FRAMEWORK_UPDATES_MANIFEST))) return fail("updates", `the expo-updates manifest sits inside a nested framework (${IOS_FRAMEWORK_UPDATES_MANIFEST}), where a swap cannot refresh it without re-signing that framework`);
|
|
1083
|
+
for (const manifest of IOS_UPDATES_MANIFESTS.map((name) => join(appCopy, name)).filter(exists)) try {
|
|
1084
|
+
refreshUpdatesManifestFile(manifest, now());
|
|
1085
|
+
} catch (err) {
|
|
1086
|
+
return fail("updates", `could not refresh the expo-updates manifest ${manifest}: ${describe(err)}`);
|
|
1087
|
+
}
|
|
1493
1088
|
try {
|
|
1494
1089
|
e.runFile("codesign", [
|
|
1495
1090
|
"--force",
|
|
@@ -1520,61 +1115,6 @@ function describe(err) {
|
|
|
1520
1115
|
return String(err?.message || err);
|
|
1521
1116
|
}
|
|
1522
1117
|
//#endregion
|
|
1523
|
-
//#region src/commands/dev-client.ts
|
|
1524
|
-
function devClientScheme(root, appPath = null, { exec = null } = {}) {
|
|
1525
|
-
if (!hasDevClient(root)) return void 0;
|
|
1526
|
-
const fromBundle = pickDevClientScheme(readBundleSchemes(appPath, { exec }));
|
|
1527
|
-
if (fromBundle) return fromBundle;
|
|
1528
|
-
const app = readJsonObject(join(root, "app.json"));
|
|
1529
|
-
const expo = app?.expo;
|
|
1530
|
-
const raw = (isJsonObject(expo) ? expo.scheme : void 0) ?? app?.scheme ?? null;
|
|
1531
|
-
const scheme = Array.isArray(raw) ? raw.find((s) => typeof s === "string" && s.trim() !== "") : raw;
|
|
1532
|
-
if (typeof scheme !== "string" || scheme.trim() === "") return void 0;
|
|
1533
|
-
return scheme.trim();
|
|
1534
|
-
}
|
|
1535
|
-
function schemesFromInfoPlist(plist) {
|
|
1536
|
-
const types = plist?.CFBundleURLTypes;
|
|
1537
|
-
if (!Array.isArray(types)) return [];
|
|
1538
|
-
const out = [];
|
|
1539
|
-
for (const type of types) {
|
|
1540
|
-
const schemes = type?.CFBundleURLSchemes;
|
|
1541
|
-
if (Array.isArray(schemes)) out.push(...schemes.filter((s) => typeof s === "string" && s.trim() !== ""));
|
|
1542
|
-
}
|
|
1543
|
-
return out;
|
|
1544
|
-
}
|
|
1545
|
-
function readBundleSchemes(appPath, { exec = null } = {}) {
|
|
1546
|
-
if (typeof appPath !== "string" || appPath.trim() === "") return [];
|
|
1547
|
-
const e = exec || getExecutor();
|
|
1548
|
-
let out;
|
|
1549
|
-
try {
|
|
1550
|
-
out = e.runFile("plutil", [
|
|
1551
|
-
"-convert",
|
|
1552
|
-
"json",
|
|
1553
|
-
"-o",
|
|
1554
|
-
"-",
|
|
1555
|
-
join(appPath, "Info.plist")
|
|
1556
|
-
]);
|
|
1557
|
-
} catch {
|
|
1558
|
-
return [];
|
|
1559
|
-
}
|
|
1560
|
-
try {
|
|
1561
|
-
return schemesFromInfoPlist(JSON.parse(String(out)));
|
|
1562
|
-
} catch {
|
|
1563
|
-
return [];
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
const THIRD_PARTY_SCHEME = /^(?:fb\d+|com\.googleusercontent\.apps\.|msauth\.|msauthv2|twitterkit-|db-[a-z0-9]+$|spotify|snapchat|com\.facebook)/i;
|
|
1567
|
-
function pickDevClientScheme(schemes) {
|
|
1568
|
-
const all = (Array.isArray(schemes) ? schemes : []).filter((s) => typeof s === "string" && s.trim() !== "").map((s) => s.trim()).filter((s) => !/^(?:https?|mailto|tel|sms|itms(?:-apps)?)$/i.test(s));
|
|
1569
|
-
const expo = all.filter((s) => s.startsWith("exp+"));
|
|
1570
|
-
return (expo.length ? expo : all.filter((s) => !THIRD_PARTY_SCHEME.test(s))).toSorted((a, b) => b.length - a.length)[0] ?? null;
|
|
1571
|
-
}
|
|
1572
|
-
function hasDevClient(root) {
|
|
1573
|
-
const pkg = readJsonObject(join(root, "package.json"));
|
|
1574
|
-
if ([pkg?.dependencies, pkg?.devDependencies].some((deps) => isJsonObject(deps) && "expo-dev-client" in deps)) return true;
|
|
1575
|
-
return isPackageResolvable(root, "expo-dev-client");
|
|
1576
|
-
}
|
|
1577
|
-
//#endregion
|
|
1578
1118
|
//#region src/cache/miss-reason.ts
|
|
1579
1119
|
const MISS_CHANGE_CAP = 20;
|
|
1580
1120
|
function recordedBuilds(state, platform) {
|
|
@@ -1927,7 +1467,7 @@ async function planCachedBuild(lookup, deps) {
|
|
|
1927
1467
|
function planPayload({ platform, slot, projectKey }, found) {
|
|
1928
1468
|
const { refusal, missReason, ...rest } = found;
|
|
1929
1469
|
const outcome = refusal ? null : found.cacheHit ? "hit" : "cold";
|
|
1930
|
-
const estimate = outcome ? estimateBuild(readStats().record?.history?.[projectKey], platform, outcome
|
|
1470
|
+
const estimate = outcome ? estimateBuild(readStats().record?.history?.[projectKey], platform, outcome) : {
|
|
1931
1471
|
expectedMs: null,
|
|
1932
1472
|
basis: 0
|
|
1933
1473
|
};
|
|
@@ -1984,4 +1524,4 @@ function planFlagRefusal(flag) {
|
|
|
1984
1524
|
};
|
|
1985
1525
|
}
|
|
1986
1526
|
//#endregion
|
|
1987
|
-
export {
|
|
1527
|
+
export { AvdRecoveryError as _, refusePlan as a, skippedMissReason as c, refreshUpdatesManifestFile as d, swapJsBundle as f, AvdBootError as g, ensureOwnedDevice as h, printPlan as i, UPDATES_MANIFEST_NAME as l, ensureBooted as m, planFlagRefusal as n, explainBuildMiss as o, didSetUpDevice as p, planPayload as r, fingerprintErrorMissReason as s, planCachedBuild as t, detectEntryFile as u, warmMetro as v };
|