stim 1.3.1 → 1.5.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 +16 -3
- package/dist/{android-hMj83VpN.mjs → android-DJWiTBkz.mjs} +65 -72
- package/dist/{android-cas-DXorPCi_.mjs → android-cas-CSS8gjR7.mjs} +15 -12
- package/dist/{android-CT-PkXUh.mjs → android-sobvO9ia.mjs} +197 -114
- package/dist/{app-install-DIp9riNx.mjs → app-install--PAocWvq.mjs} +2 -2
- package/dist/{build-slots-C4AouyNz.mjs → build-slots-CuPszJDu.mjs} +7 -8
- package/dist/{cache-manifest-CXR-Y8pH.mjs → cache-manifest-uoOKhgUD.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/cli.mjs +14 -13
- package/dist/collector-run.mjs +4 -4
- package/dist/{command-output-8wHMEde0.mjs → command-output-BuIb_ZOI.mjs} +1 -4
- package/dist/{config-CcefMY2Q.mjs → config-DMP7L7H6.mjs} +52 -52
- package/dist/dependency-state-CTL8A9p3.mjs +76 -0
- package/dist/{deps-0Yt0Inly.mjs → deps-BAGOnrc7.mjs} +1 -1
- package/dist/{dev-client-VfSZNLT4.mjs → dev-client-BoifdqkU.mjs} +12 -12
- package/dist/{device-Bbv45Z9Z.mjs → device-BUw4JBuH.mjs} +7 -7
- package/dist/{xcode-xnxyvJkD.mjs → device-DvKJ454A.mjs} +208 -967
- package/dist/{device-lease-CJwK7OZr.mjs → device-lease-r7yEQ1R8.mjs} +3 -3
- package/dist/{device-pool-CcBNTvM7.mjs → device-pool-DU4FQKp5.mjs} +4 -4
- package/dist/{device-remote-DAA0Zm6Z.mjs → device-remote-BTUqbl0i.mjs} +7 -6
- package/dist/{doctor-B4EITgQB.mjs → doctor-Di_B26uh.mjs} +396 -117
- package/dist/{error-diagnostics-DwhNBFDU.mjs → error-diagnostics-CTePWAzW.mjs} +7 -6
- package/dist/{gc-BRu62v4o.mjs → gc-C20dWw_8.mjs} +61 -27
- package/dist/{guide-D95E0u3i.mjs → guide-sAnoty2y.mjs} +151 -20
- package/dist/guide-status-BF6RsJJp.mjs +271 -0
- package/dist/{ios-DAju3TVy.mjs → ios-BdpkncL6.mjs} +2667 -2607
- package/dist/{ios-device-CWOM_S44.mjs → ios-device-DJOi9FR5.mjs} +1 -1
- package/dist/{logs-CAdwW6c2.mjs → logs-BfQdIhiF.mjs} +5 -5
- package/dist/metro-ato6ef3J.mjs +99 -0
- package/dist/named-ports-DH9SXd0f.mjs +137 -0
- package/dist/{ownership-8O073GIC.mjs → ownership-CD_XnpDu.mjs} +5 -5
- package/dist/{ownership-DXcol4oU.mjs → ownership-CVY9cqCr.mjs} +6 -6
- package/dist/ports-A6uTJSPj.mjs +39 -0
- package/dist/ports-BZprTJRa.mjs +90 -0
- package/dist/{project-fKmuIaMI.mjs → project-B_SDt4ip.mjs} +2 -2
- package/dist/{reclaim-CUmwucWG.mjs → reclaim-C_rB25f4.mjs} +20 -13
- package/dist/{reload-CWpXoOgN.mjs → reload-CYBJbJfI.mjs} +8 -8
- package/dist/rolldown-runtime-BsOwBuO_.mjs +30 -0
- package/dist/{server-bare-DEzPZLvf.mjs → server-bare-H3pAhbMs.mjs} +11 -35
- package/dist/server-expo-CSwUVYOa.mjs +2 -0
- package/dist/{server-expo-DizT4OMk.mjs → server-expo-Ds8_mfng.mjs} +6 -14
- package/dist/{settings-DEJf6_kJ.mjs → settings-kO2ZqIKy.mjs} +2 -2
- package/dist/{slot-launch-CZklomj6.mjs → slot-launch-BpHiHH6A.mjs} +4 -4
- package/dist/{start-B5G4NjiA.mjs → start-DiEfqEWk.mjs} +20 -22
- package/dist/state-CnWzvCWP.mjs +131 -0
- package/dist/{stats-CaaQr4yN.mjs → stats-DHrO0frH.mjs} +4 -4
- package/dist/{stats-BR-kwj0B.mjs → stats-Fo9ACIv7.mjs} +1 -1
- package/dist/{status-CI9clRSb.mjs → status-J5LAXpag.mjs} +15 -12
- package/dist/{stop-CjlgDk0a.mjs → stop-0jJNahwN.mjs} +15 -14
- package/dist/{stop-CQhffpmX.mjs → stop-CM1fejKW.mjs} +2 -2
- package/dist/supervisor-run.d.mts +7 -28
- package/dist/supervisor-run.mjs +20 -11
- package/dist/{teardown--gESs9ck.mjs → teardown-CAVcWeRD.mjs} +148 -109
- package/dist/{workspace-process-lock-IBj1Towr.mjs → workspace-process-lock-Bz19_R9R.mjs} +4 -4
- package/dist/workspace-state-WVwWw_hB.mjs +146 -0
- package/dist/{worktree-DtQGO9-s.mjs → worktree-CeUKDAQw.mjs} +38 -34
- package/dist/{worktree-Eq6TLH8N.mjs → worktree-DJnBbQZ9.mjs} +79 -22
- package/dist/xcode-BqDeRkpT.mjs +860 -0
- package/package.json +7 -7
- package/shim/expo-metro-config.cjs +11 -17
- package/dist/doctor-BueDfLYG.mjs +0 -530
- package/dist/metro-CORqXyTL.mjs +0 -184
- package/dist/ownership-claim-BtPtJVmq.mjs +0 -584
- package/dist/server-expo-44em5Pmg.mjs +0 -2
- package/dist/state-B3XA2wp2.mjs +0 -268
- package/shim/metro-cache-generation.cjs +0 -20
- package/shim/metro-cache-generation.d.cts +0 -5
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { t as getExecutor } from "./exec-CyylIdq9.mjs";
|
|
2
|
+
import { S as upsertProject, f as getProject, u as getConfigDir } from "./config-DMP7L7H6.mjs";
|
|
3
|
+
import { accessSync, constants, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { delimiter, join, resolve } from "node:path";
|
|
5
|
+
//#region src/stim-installations.ts
|
|
6
|
+
const VERSION_OUTPUT_LIMIT = 4096;
|
|
7
|
+
function parsedVersion(version) {
|
|
8
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
9
|
+
if (!match) return null;
|
|
10
|
+
const core = [
|
|
11
|
+
match[1],
|
|
12
|
+
match[2],
|
|
13
|
+
match[3]
|
|
14
|
+
];
|
|
15
|
+
if (core.some((part) => part.length > 1 && part.startsWith("0"))) return null;
|
|
16
|
+
const prereleaseParts = match[4]?.split(".");
|
|
17
|
+
if (prereleaseParts?.some((part) => !part || /^\d+$/.test(part) && part.length > 1 && part.startsWith("0"))) return null;
|
|
18
|
+
const prerelease = prereleaseParts?.map((part) => /^\d+$/.test(part) ? Number(part) : part);
|
|
19
|
+
return {
|
|
20
|
+
core: core.map(Number),
|
|
21
|
+
prerelease: prerelease ?? null
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function compareStimVersions(left, right) {
|
|
25
|
+
const a = parsedVersion(left);
|
|
26
|
+
const b = parsedVersion(right);
|
|
27
|
+
if (!a || !b) return null;
|
|
28
|
+
for (let index = 0; index < a.core.length; index += 1) {
|
|
29
|
+
const difference = (a.core[index] ?? 0) - (b.core[index] ?? 0);
|
|
30
|
+
if (difference !== 0) return difference;
|
|
31
|
+
}
|
|
32
|
+
if (!a.prerelease && !b.prerelease) return 0;
|
|
33
|
+
if (!a.prerelease) return 1;
|
|
34
|
+
if (!b.prerelease) return -1;
|
|
35
|
+
for (let index = 0; index < Math.max(a.prerelease.length, b.prerelease.length); index += 1) {
|
|
36
|
+
const x = a.prerelease[index];
|
|
37
|
+
const y = b.prerelease[index];
|
|
38
|
+
if (x === void 0) return -1;
|
|
39
|
+
if (y === void 0) return 1;
|
|
40
|
+
if (x === y) continue;
|
|
41
|
+
if (typeof x === "number" && typeof y === "number") return x - y;
|
|
42
|
+
if (typeof x === "number") return -1;
|
|
43
|
+
if (typeof y === "number") return 1;
|
|
44
|
+
return x < y ? -1 : 1;
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
function parseStimVersionOutput(output) {
|
|
49
|
+
const version = output?.split("\n")[0]?.trim() ?? "";
|
|
50
|
+
return parsedVersion(version) ? version.replace(/^v/, "") : null;
|
|
51
|
+
}
|
|
52
|
+
function executableNames(platform) {
|
|
53
|
+
return platform === "win32" ? [
|
|
54
|
+
"stim.cmd",
|
|
55
|
+
"stim.exe",
|
|
56
|
+
"stim"
|
|
57
|
+
] : ["stim"];
|
|
58
|
+
}
|
|
59
|
+
function stimExecutablePaths(pathValue, { platform = process.platform, cwd = process.cwd() } = {}) {
|
|
60
|
+
const found = [];
|
|
61
|
+
const seen = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const entry of pathValue.split(delimiter)) {
|
|
63
|
+
const directory = resolve(cwd, entry || ".");
|
|
64
|
+
for (const name of executableNames(platform)) {
|
|
65
|
+
const path = join(directory, name);
|
|
66
|
+
try {
|
|
67
|
+
accessSync(path, platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
68
|
+
if (!statSync(path).isFile()) continue;
|
|
69
|
+
const realPath = realpathSync(path);
|
|
70
|
+
if (seen.has(realPath)) continue;
|
|
71
|
+
seen.add(realPath);
|
|
72
|
+
found.push({
|
|
73
|
+
path,
|
|
74
|
+
realPath
|
|
75
|
+
});
|
|
76
|
+
} catch {}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return found;
|
|
80
|
+
}
|
|
81
|
+
function canonicalPath(path) {
|
|
82
|
+
if (!path) return null;
|
|
83
|
+
try {
|
|
84
|
+
return realpathSync(resolve(path));
|
|
85
|
+
} catch {
|
|
86
|
+
return resolve(path);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function analyzeStimVersions(runningVersion, runningPath, installations) {
|
|
90
|
+
const candidates = [runningVersion, ...installations.map((entry) => entry.version)];
|
|
91
|
+
const versions = [...new Set(candidates)].filter((version) => version !== null && compareStimVersions(version, version) !== null).toSorted((left, right) => -(compareStimVersions(left, right) ?? 0));
|
|
92
|
+
const highestVersion = versions[0] ?? null;
|
|
93
|
+
const resolved = installations[0] ?? null;
|
|
94
|
+
return {
|
|
95
|
+
runningVersion,
|
|
96
|
+
runningPath,
|
|
97
|
+
resolved,
|
|
98
|
+
installations,
|
|
99
|
+
versions,
|
|
100
|
+
highestVersion,
|
|
101
|
+
resolvedIsOlder: Boolean(resolved?.version && highestVersion && (compareStimVersions(resolved.version, highestVersion) ?? 0) < 0)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function probeStimVersion(path, timeoutMs) {
|
|
105
|
+
return new Promise((resolveProbe) => {
|
|
106
|
+
let settled = false;
|
|
107
|
+
let output = "";
|
|
108
|
+
const finish = (version) => {
|
|
109
|
+
if (settled) return;
|
|
110
|
+
settled = true;
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
resolveProbe(version);
|
|
113
|
+
};
|
|
114
|
+
let child;
|
|
115
|
+
try {
|
|
116
|
+
child = getExecutor().spawn(path, ["--version"], {
|
|
117
|
+
stdio: [
|
|
118
|
+
"ignore",
|
|
119
|
+
"pipe",
|
|
120
|
+
"ignore"
|
|
121
|
+
],
|
|
122
|
+
detached: process.platform !== "win32"
|
|
123
|
+
});
|
|
124
|
+
} catch {
|
|
125
|
+
resolveProbe(null);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const timer = setTimeout(() => {
|
|
129
|
+
try {
|
|
130
|
+
if (process.platform !== "win32" && child.pid) process.kill(-child.pid, "SIGKILL");
|
|
131
|
+
else child.kill("SIGKILL");
|
|
132
|
+
} catch {}
|
|
133
|
+
finish(null);
|
|
134
|
+
}, timeoutMs);
|
|
135
|
+
child.stdout?.on("data", (chunk) => {
|
|
136
|
+
if (output.length < VERSION_OUTPUT_LIMIT) output += String(chunk).slice(0, VERSION_OUTPUT_LIMIT - output.length);
|
|
137
|
+
});
|
|
138
|
+
child.on("error", () => finish(null));
|
|
139
|
+
child.on("close", (code) => finish(code === 0 ? parseStimVersionOutput(output) : null));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async function inspectStimVersions(runningVersion, { pathValue = process.env.PATH ?? "", runningPath = process.argv[1], probeTimeoutMs = 5e3 } = {}) {
|
|
143
|
+
const paths = stimExecutablePaths(pathValue);
|
|
144
|
+
const versions = await Promise.all(paths.map((entry) => probeStimVersion(entry.path, probeTimeoutMs)));
|
|
145
|
+
const installations = paths.map((entry, index) => ({
|
|
146
|
+
path: entry.path,
|
|
147
|
+
realPath: entry.realPath,
|
|
148
|
+
version: versions[index] ?? null
|
|
149
|
+
}));
|
|
150
|
+
return analyzeStimVersions(runningVersion, canonicalPath(runningPath), installations);
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/guide-status.ts
|
|
154
|
+
const DAY_MS = 864e5;
|
|
155
|
+
const DOCTOR_STALE_MS = 7 * DAY_MS;
|
|
156
|
+
const UPDATE_CHECK_INTERVAL_MS = DAY_MS;
|
|
157
|
+
const UPDATE_CHECK_TIMEOUT_MS = 2e3;
|
|
158
|
+
const LATEST_URL = "https://registry.npmjs.org/stim/latest";
|
|
159
|
+
const PLATFORMS = ["ios", "android"];
|
|
160
|
+
function recordDoctorRun(projectRoot, platform, version, now = /* @__PURE__ */ new Date()) {
|
|
161
|
+
const run = {
|
|
162
|
+
at: now.toISOString(),
|
|
163
|
+
version
|
|
164
|
+
};
|
|
165
|
+
try {
|
|
166
|
+
upsertProject(projectRoot, (existing) => {
|
|
167
|
+
const doctorRuns = { ...existing.doctorRuns };
|
|
168
|
+
for (const target of platform ? [platform] : PLATFORMS) doctorRuns[target] = run;
|
|
169
|
+
return { doctorRuns };
|
|
170
|
+
});
|
|
171
|
+
} catch {}
|
|
172
|
+
}
|
|
173
|
+
function doctorDueReason(record, running, now) {
|
|
174
|
+
const at = record ? Date.parse(record.at) : NaN;
|
|
175
|
+
if (!record || Number.isNaN(at)) return "never run";
|
|
176
|
+
if (record.version !== running) return `last run with stim ${record.version}`;
|
|
177
|
+
const age = now.getTime() - at;
|
|
178
|
+
if (age > DOCTOR_STALE_MS) return `last run ${Math.floor(age / DAY_MS)} days ago`;
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
function updateCacheFile() {
|
|
182
|
+
return join(getConfigDir(), "update-check.json");
|
|
183
|
+
}
|
|
184
|
+
function readUpdateCache() {
|
|
185
|
+
try {
|
|
186
|
+
const parsed = JSON.parse(readFileSync(updateCacheFile(), "utf-8"));
|
|
187
|
+
if (typeof parsed?.checkedAt !== "string") return null;
|
|
188
|
+
return {
|
|
189
|
+
checkedAt: parsed.checkedAt,
|
|
190
|
+
latest: typeof parsed.latest === "string" ? parsed.latest : null
|
|
191
|
+
};
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function writeUpdateCache(cache) {
|
|
197
|
+
const target = updateCacheFile();
|
|
198
|
+
const tmp = `${target}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
199
|
+
try {
|
|
200
|
+
mkdirSync(getConfigDir(), { recursive: true });
|
|
201
|
+
writeFileSync(tmp, `${JSON.stringify(cache)}\n`);
|
|
202
|
+
renameSync(tmp, target);
|
|
203
|
+
} catch {
|
|
204
|
+
try {
|
|
205
|
+
unlinkSync(tmp);
|
|
206
|
+
} catch {}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function fetchLatest(fetchImpl) {
|
|
210
|
+
const res = await fetchImpl(LATEST_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) });
|
|
211
|
+
if (!res.ok) return null;
|
|
212
|
+
const body = await res.json();
|
|
213
|
+
return typeof body.version === "string" ? body.version : null;
|
|
214
|
+
}
|
|
215
|
+
async function checkForUpdate(running, { now = /* @__PURE__ */ new Date(), fetch: fetchImpl = fetch } = {}) {
|
|
216
|
+
if (process.env.STIM_NO_UPDATE_CHECK) return null;
|
|
217
|
+
const cached = readUpdateCache();
|
|
218
|
+
const checkedAt = cached ? Date.parse(cached.checkedAt) : NaN;
|
|
219
|
+
let latest = cached?.latest ?? null;
|
|
220
|
+
if (Number.isNaN(checkedAt) || now.getTime() - checkedAt > UPDATE_CHECK_INTERVAL_MS) {
|
|
221
|
+
try {
|
|
222
|
+
latest = await fetchLatest(fetchImpl);
|
|
223
|
+
} catch {
|
|
224
|
+
latest = null;
|
|
225
|
+
}
|
|
226
|
+
writeUpdateCache({
|
|
227
|
+
checkedAt: now.toISOString(),
|
|
228
|
+
latest
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (!latest) return null;
|
|
232
|
+
const comparison = compareStimVersions(latest, running);
|
|
233
|
+
return comparison !== null && comparison > 0 ? latest : null;
|
|
234
|
+
}
|
|
235
|
+
function renderGuideStatus({ running, doctor, latest }) {
|
|
236
|
+
const lines = [];
|
|
237
|
+
if (doctor.length) {
|
|
238
|
+
const named = doctor.map((due) => `${due.platform} (${due.reason})`).join(" and ");
|
|
239
|
+
const command = doctor.length === 1 ? `stim doctor --platform ${doctor[0]?.platform}` : "stim doctor";
|
|
240
|
+
lines.push(` Doctor is due for ${named}.`, ` Run before native work: ${command}`);
|
|
241
|
+
}
|
|
242
|
+
if (latest) lines.push(` stim ${latest} is available (running ${running}): npm install -g stim@latest`);
|
|
243
|
+
if (!lines.length) return null;
|
|
244
|
+
return ["STATUS", ...lines].join("\n");
|
|
245
|
+
}
|
|
246
|
+
async function guideStatus({ projectRoot, running, now = /* @__PURE__ */ new Date(), fetch: fetchImpl = fetch }) {
|
|
247
|
+
const doctor = [];
|
|
248
|
+
if (projectRoot) {
|
|
249
|
+
let runs = null;
|
|
250
|
+
try {
|
|
251
|
+
runs = getProject(projectRoot)?.doctorRuns ?? {};
|
|
252
|
+
} catch {}
|
|
253
|
+
if (runs) for (const platform of PLATFORMS) {
|
|
254
|
+
const reason = doctorDueReason(runs[platform], running, now);
|
|
255
|
+
if (reason) doctor.push({
|
|
256
|
+
platform,
|
|
257
|
+
reason
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return renderGuideStatus({
|
|
262
|
+
running,
|
|
263
|
+
doctor,
|
|
264
|
+
latest: await checkForUpdate(running, {
|
|
265
|
+
now,
|
|
266
|
+
fetch: fetchImpl
|
|
267
|
+
})
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
export { inspectStimVersions as i, recordDoctorRun as n, compareStimVersions as r, guideStatus as t };
|