stim 1.9.0 → 1.10.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.
Files changed (83) hide show
  1. package/dist/{android-_y4Ohi5z.mjs → android-787HhP5w.mjs} +119 -29
  2. package/dist/{android-BPGizezh.mjs → android-DBkeHwpm.mjs} +168 -95
  3. package/dist/{android-DEgo4oCo.mjs → android-DPov-fv2.mjs} +2 -2
  4. package/dist/{android-cas-eiExNLf7.mjs → android-cas-CITmIeWY.mjs} +9 -8
  5. package/dist/android-cas-compiler.mjs +1 -1
  6. package/dist/{app-install-Uf3a83Tv.mjs → app-install-CrJ6t_bv.mjs} +2 -2
  7. package/dist/budget-BP4jZZL4.mjs +620 -0
  8. package/dist/build-progress-BXx-ZBe4.mjs +512 -0
  9. package/dist/{cache-manifest-Dg7OnMrp.mjs → cache-manifest-Pubfp8wV.mjs} +1 -1
  10. package/dist/cache-manifest.mjs +1 -1
  11. package/dist/cli.mjs +16 -16
  12. package/dist/collector-run.d.mts +5 -1
  13. package/dist/collector-run.mjs +7 -7
  14. package/dist/{command-output-gByVmIjy.mjs → command-output-D5z2_bcF.mjs} +1 -1
  15. package/dist/{config-Cp9lM3wX.mjs → config-BEq0Qw_a.mjs} +14 -131
  16. package/dist/{dependency-state-Bq5DcLGn.mjs → dependency-state-r9UesA9a.mjs} +2 -2
  17. package/dist/{deps-Cip5vUm1.mjs → deps-DP4eWqea.mjs} +3 -3
  18. package/dist/{detached-entry-KEu0_AXL.mjs → detached-entry-DJHoca49.mjs} +1 -1
  19. package/dist/{dev-client-HyqISM0h.mjs → dev-client-92U593KT.mjs} +137 -250
  20. package/dist/{device-D4U-xLty.mjs → device-DhTZe7L4.mjs} +7 -7
  21. package/dist/{build-lock-DPXPLgTc.mjs → device-lease-CbEaIk7b.mjs} +370 -12
  22. package/dist/{device-pool-CnTAz8X1.mjs → device-pool-Di8Q-9Ro.mjs} +4 -4
  23. package/dist/{device-remote-AQ5rQPqr.mjs → device-remote-Dy1jGj3U.mjs} +547 -468
  24. package/dist/{doctor-B_Ei3bZu.mjs → doctor-B-inAJmt.mjs} +58 -22
  25. package/dist/{error-diagnostics-Vfz83GCF.mjs → error-diagnostics-xxWKNO3-.mjs} +11 -12
  26. package/dist/{exec-jIAlgilk.mjs → exec-DK8KaVHK.mjs} +3 -2
  27. package/dist/{gc-Ckw8RQHi.mjs → gc-ChPFZMRC.mjs} +500 -1114
  28. package/dist/{guide-BiAbhs1J.mjs → guide-DwmaD_Wa.mjs} +882 -528
  29. package/dist/guide-status-CWvti2Lg.mjs +125 -0
  30. package/dist/idle-DpRLp5lj.mjs +157 -0
  31. package/dist/in-use-CjUluqIX.mjs +245 -0
  32. package/dist/{ios-BL2NFckr.mjs → ios-B2Fpqvlb.mjs} +25 -59
  33. package/dist/{ios-BzUJWk1K.mjs → ios-Dd-hYJBh.mjs} +130 -89
  34. package/dist/{ios-device-DPsSm0v_.mjs → ios-device-BiOsSVzd.mjs} +1 -1
  35. package/dist/{ios-device-D972i9wf.mjs → ios-device-CtRdEVjx.mjs} +3 -3
  36. package/dist/{launch-verify-Q_OtW1Rf.mjs → launch-verify-CQS_Kg-C.mjs} +5 -5
  37. package/dist/{logs-CI9NQSK7.mjs → logs-MARIy6m9.mjs} +9 -9
  38. package/dist/{metro-DrLHaMn2.mjs → metro-BWLOJ_Wr.mjs} +116 -10
  39. package/dist/{named-ports-CmLQSIRj.mjs → named-ports-DiTfSz6p.mjs} +4 -4
  40. package/dist/{ndjson-9uFNRwfe.mjs → ndjson-CDY9IkVC.mjs} +3 -56
  41. package/dist/{ndjson-DvHSsNU9.d.mts → ndjson-Du3j0AQ9.d.mts} +1 -0
  42. package/dist/{ownership-D15Op8vN.mjs → ownership-D2xbLVoz.mjs} +2 -3
  43. package/dist/ownership-DZjdx8Gq.mjs +1180 -0
  44. package/dist/{ports-BNKoWVWZ.mjs → ports-CLSSFOuz.mjs} +3 -3
  45. package/dist/{project-DS112DYB.mjs → project-BXZzOABt.mjs} +2 -2
  46. package/dist/{reload-ZNJUo1pl.mjs → reload-DoETJ3rl.mjs} +9 -10
  47. package/dist/{server-bare-DWkkcIxV.mjs → server-bare-DVbb7kXH.mjs} +1 -1
  48. package/dist/{server-expo-B_lctBR3.mjs → server-expo-BvOCeakp.mjs} +4 -4
  49. package/dist/server-expo-DBVTdult.mjs +2 -0
  50. package/dist/{settings-D030k0t4.mjs → settings-DOugPlPz.mjs} +16 -428
  51. package/dist/{settings-BKNh5rl4.mjs → settings-EWYNwe72.mjs} +16 -14
  52. package/dist/settings.schema.json +75 -0
  53. package/dist/{simslim-B_LsGLuJ.mjs → simslim-Ca3487H6.mjs} +182 -5
  54. package/dist/{slot-launch-DU9A-gYw.mjs → slot-launch-C5cg0fmk.mjs} +4 -4
  55. package/dist/{spawn-claims-Dn3C_N6w.mjs → spawn-claims-CUleC2cM.mjs} +1 -1
  56. package/dist/{start-DYkkKF0s.mjs → start-F9gv5dcC.mjs} +147 -98
  57. package/dist/start-VoFsPSes.mjs +2 -0
  58. package/dist/{state-NcJzMEBF.mjs → state-WGdIbi_d.mjs} +2 -2
  59. package/dist/{stats-DG9e66Rz.mjs → stats-BAgJaLA4.mjs} +1 -1
  60. package/dist/{stats-B63-JVAY.mjs → stats-DBYJ5bxL.mjs} +4 -4
  61. package/dist/{status-S6ehL4Ui.mjs → status-DLCD-o3s.mjs} +63 -231
  62. package/dist/status-Dr4fRkym.mjs +216 -0
  63. package/dist/{guide-status-BAMVU0ZA.mjs → stim-installations-CINXy_su.mjs} +3 -124
  64. package/dist/{stop-BO28HGqF.mjs → stop-Dj4pfmyv.mjs} +22 -18
  65. package/dist/{stop-T1R-cZRz.mjs → stop-ZvOeTmKb.mjs} +2 -2
  66. package/dist/supervisor-run.d.mts +11 -2
  67. package/dist/supervisor-run.mjs +185 -17
  68. package/dist/{workspace-process-lock-DWaiRD0e.mjs → workspace-process-lock-BXA96myD.mjs} +2 -2
  69. package/dist/workspaces-BTUyFfkv.mjs +1003 -0
  70. package/dist/{worktree-DKhSF0UX.mjs → worktree-4aZg2NnI.mjs} +1 -1
  71. package/dist/{worktree-LGB-UwgG.mjs → worktree-BMS7GeqB.mjs} +40 -122
  72. package/dist/{worktree-R_cUlE7s.mjs → worktree-BlizKDpZ.mjs} +143 -18
  73. package/dist/{xcode-BZqyxh3e.mjs → xcode-B2tBkf0m.mjs} +9 -158
  74. package/package.json +6 -5
  75. package/dist/build-progress-CVqkfPC6.mjs +0 -188
  76. package/dist/device-lease-Crs-HkJY.mjs +0 -366
  77. package/dist/logs-query-Cqma3WIu.mjs +0 -298
  78. package/dist/ownership-DCQPuWEc.mjs +0 -489
  79. package/dist/public-http-probe-CyMDrQ3c.mjs +0 -61
  80. package/dist/server-expo-CeILEu86.mjs +0 -2
  81. package/dist/sim-pool-KaIsp2Ft.mjs +0 -723
  82. package/dist/spawn-entry-nCE6m770.mjs +0 -14
  83. package/dist/workspace-state-DF2gCFhx.mjs +0 -169
@@ -1,298 +0,0 @@
1
- import { a as parseNdjsonLine, i as levelRank, o as readNdjsonGenerations } from "./ndjson-9uFNRwfe.mjs";
2
- import { closeSync, openSync, readSync, readdirSync, statSync } from "fs";
3
- import { join } from "path";
4
- import { rotatedLogPath } from "@stim-cli/core";
5
- import { StringDecoder } from "string_decoder";
6
- //#region src/diagnostics/logs-query.ts
7
- const SINCE_UNITS = {
8
- s: 1e3,
9
- m: 6e4,
10
- h: 36e5
11
- };
12
- const SINCE_FORMS = "30s, 5m, 2h";
13
- function parseSince(text) {
14
- if (typeof text !== "string") return { error: `Invalid --since value ${JSON.stringify(text)}. Use a count and a unit, e.g. ${SINCE_FORMS}.` };
15
- const m = /^(\d+)\s*([smh])$/i.exec(text.trim());
16
- if (!m) return { error: `Invalid --since value "${text}". Use a count and a unit, e.g. ${SINCE_FORMS}.` };
17
- const unit = (m[2] ?? "").toLowerCase();
18
- return { ms: parseInt(m[1] ?? "", 10) * SINCE_UNITS[unit] };
19
- }
20
- function compileGrep(pattern) {
21
- if (pattern instanceof RegExp) return { re: pattern };
22
- try {
23
- return { re: new RegExp(String(pattern)) };
24
- } catch (err) {
25
- return { error: `Invalid --grep pattern "${pattern}": ${err.message}` };
26
- }
27
- }
28
- const ERROR_SOURCES = [
29
- "metro",
30
- "client",
31
- "build"
32
- ];
33
- function markerWindow(records) {
34
- let launchTs = null;
35
- let bundleTs = null;
36
- for (const r of records) {
37
- if (r?.marker !== true) continue;
38
- const ts = tsOf(r);
39
- if (ts === null) continue;
40
- if (r.src === "metro") {
41
- if (bundleTs === null || ts > bundleTs) bundleTs = ts;
42
- } else if (launchTs === null || ts > launchTs) launchTs = ts;
43
- }
44
- return {
45
- launchTs,
46
- bundleTs
47
- };
48
- }
49
- function recordMatches(record, criteria = {}) {
50
- if (!record) return false;
51
- if (criteria.slot !== void 0 && (record.slot ?? "default") !== criteria.slot) return false;
52
- const { sources, minLevel, grep, sinceTs, errorsOnly, markerTs, bundleMarkerTs } = criteria;
53
- if (sources && sources.length > 0 && !sources.includes(record.src) && !(criteria.includeNativeCrashes && record.src === "device" && record.event === "native_crash")) return false;
54
- if (minLevel && levelRank(record.level) < levelRank(minLevel)) return false;
55
- if (errorsOnly) {
56
- if (record.level !== "error" && record.level !== "fatal") return false;
57
- if (typeof markerTs === "number") {
58
- const ts = tsOf(record);
59
- if (ts === null || ts <= markerTs) return false;
60
- }
61
- if (typeof bundleMarkerTs === "number" && record.src === "metro") {
62
- const ts = tsOf(record);
63
- if (ts === null || ts < bundleMarkerTs) return false;
64
- }
65
- }
66
- if (typeof sinceTs === "number") {
67
- const ts = tsOf(record);
68
- if (ts === null || ts < sinceTs) return false;
69
- }
70
- if (grep) {
71
- const re = grep instanceof RegExp ? grep : compileGrep(grep).re;
72
- if (!re || String(record.msg ?? "").search(re) === -1) return false;
73
- }
74
- return true;
75
- }
76
- function buildCriteria({ slot, sources, minLevel, since, grep, errorsOnly, markerTs, bundleMarkerTs, now } = {}) {
77
- const criteria = {
78
- ...slot === void 0 ? {} : { slot },
79
- errorsOnly: Boolean(errorsOnly),
80
- includeNativeCrashes: Boolean(errorsOnly && !sources?.length)
81
- };
82
- if (sources && sources.length > 0) criteria.sources = sources;
83
- else if (criteria.errorsOnly) criteria.sources = ERROR_SOURCES;
84
- if (minLevel) criteria.minLevel = minLevel;
85
- if (typeof markerTs === "number") criteria.markerTs = markerTs;
86
- if (typeof bundleMarkerTs === "number") criteria.bundleMarkerTs = bundleMarkerTs;
87
- if (since !== void 0 && since !== null && since !== "") {
88
- const parsed = parseSince(since);
89
- if (parsed.error) throw new Error(parsed.error);
90
- criteria.sinceTs = (typeof now === "number" ? now : Date.now()) - parsed.ms;
91
- }
92
- if (grep !== void 0 && grep !== null && grep !== "") {
93
- const compiled = compileGrep(grep);
94
- if (compiled.error) throw new Error(compiled.error);
95
- criteria.grep = compiled.re;
96
- }
97
- return criteria;
98
- }
99
- function logFiles(dir) {
100
- let entries;
101
- try {
102
- entries = readdirSync(dir, { withFileTypes: true });
103
- } catch {
104
- return [];
105
- }
106
- return entries.filter((e) => e.isFile() && e.name.endsWith(".ndjson")).map((e) => e.name).toSorted();
107
- }
108
- function fileSizes(dir) {
109
- const sizes = {};
110
- for (const name of logFiles(dir)) try {
111
- sizes[name] = statSync(join(dir, name)).size;
112
- } catch {}
113
- return sizes;
114
- }
115
- function readLogRecords(dir, include = () => true) {
116
- const all = [];
117
- for (const name of logFiles(dir).filter(include)) for (const record of readNdjsonGenerations(join(dir, name))) all.push(record);
118
- return sortByTs(all);
119
- }
120
- function isExpoErrorContext(record, event) {
121
- if (record.src !== "metro" || record.raw !== true || record.event !== event || typeof record.msg !== "string") return false;
122
- return /^Code: \S/.test(record.msg) || /^\s*>?\s*\d+\s*\|/.test(record.msg) || /^\s*\|\s*\^/.test(record.msg) || /^Call Stack$/.test(record.msg) || /^\s+.+\([^()]+:\d+:\d+\)\s*$/.test(record.msg) || /^\s+at\s+\S+:\d+:\d+\s*$/.test(record.msg);
123
- }
124
- function attachExpoErrorContext(all, matched) {
125
- return matched.map((record) => {
126
- if (record.src !== "metro" || record.raw !== true || record.level !== "error" && record.level !== "fatal" || typeof record.msg !== "string") return record;
127
- const index = all.findIndex((entry) => entry.ts === record.ts && entry.src === record.src && entry.msg === record.msg && entry.event === record.event);
128
- if (index === -1) return record;
129
- const context = [];
130
- for (let i = index + 1; i < all.length; i += 1) {
131
- const next = all[i];
132
- if (next.src !== "metro") continue;
133
- if (!isExpoErrorContext(next, record.event)) break;
134
- context.push(next.msg);
135
- }
136
- return context.length > 0 ? {
137
- ...record,
138
- msg: [record.msg, ...context].join("\n")
139
- } : record;
140
- });
141
- }
142
- function includeBareErrorContext(all, matched, launchTs, sinceTs) {
143
- if (!matched.some((record) => record.src === "client" && (record.level === "error" || record.level === "fatal"))) return matched;
144
- const renderedContext = [];
145
- for (const record of all) {
146
- if (record.src !== "client" || record.event !== "client_symbolication") continue;
147
- const ts = tsOf(record);
148
- if (launchTs !== null && (ts === null || ts <= launchTs)) continue;
149
- if (sinceTs !== void 0 && (ts === null || ts < sinceTs)) continue;
150
- renderedContext.push({
151
- ...record,
152
- msg: `Metro symbolication context (not correlated to a specific client error)\n${String(record.msg ?? "")}`,
153
- errorContext: true
154
- });
155
- }
156
- return sortByTs([...matched, ...renderedContext]);
157
- }
158
- function launchMarkersBySlot(records) {
159
- const markers = /* @__PURE__ */ new Map();
160
- for (const record of records) {
161
- if (record.marker !== true || record.src === "metro") continue;
162
- const ts = tsOf(record);
163
- const slot = record.slot ?? "default";
164
- if (ts !== null && ts > (markers.get(slot) ?? -Infinity)) markers.set(slot, ts);
165
- }
166
- return markers;
167
- }
168
- function queryLogs({ slot, dir, records, sources, minLevel, since, grep, tail, errorsOnly, errorContext, now } = {}) {
169
- const all = (records ?? readLogRecords(dir)).filter((record) => slot === void 0 || (record.slot ?? "default") === slot);
170
- if (all.length === 0) return [];
171
- const { launchTs, bundleTs } = errorsOnly ? markerWindow(all) : {
172
- launchTs: null,
173
- bundleTs: null
174
- };
175
- const criteria = buildCriteria({
176
- slot,
177
- sources,
178
- minLevel,
179
- since,
180
- grep,
181
- errorsOnly,
182
- now,
183
- markerTs: launchTs === null ? void 0 : launchTs,
184
- bundleMarkerTs: bundleTs === null ? void 0 : bundleTs
185
- });
186
- const slotMarkers = launchMarkersBySlot(all);
187
- let matched = all.filter((record) => recordMatches(record, {
188
- ...criteria,
189
- markerTs: record.src === "metro" || record.src === "client" ? criteria.markerTs : slotMarkers.get(record.slot ?? "default")
190
- }));
191
- if (typeof tail === "number" && tail >= 0 && matched.length > tail) matched = matched.slice(matched.length - tail);
192
- return errorContext ? includeBareErrorContext(all, attachExpoErrorContext(all, matched), launchTs, criteria.sinceTs) : matched;
193
- }
194
- function tailRead(prev, size) {
195
- const state = prev && typeof prev.offset === "number" ? prev : {
196
- offset: 0,
197
- partial: ""
198
- };
199
- if (size < state.offset) return {
200
- start: 0,
201
- prev: {
202
- offset: 0,
203
- partial: ""
204
- }
205
- };
206
- return {
207
- start: state.offset,
208
- prev: state
209
- };
210
- }
211
- function advanceTail(prev, chunk, size) {
212
- const lines = ((prev && typeof prev.partial === "string" ? prev.partial : "") + (chunk || "")).split("\n");
213
- const partial = lines.pop();
214
- const records = [];
215
- for (const line of lines) {
216
- const record = parseNdjsonLine(line);
217
- if (record) records.push(record);
218
- }
219
- return {
220
- state: {
221
- offset: size,
222
- partial
223
- },
224
- records
225
- };
226
- }
227
- function followLogs({ dir, onRecord, criteria = {}, intervalMs = 500, offsets = null }) {
228
- const state = /* @__PURE__ */ new Map();
229
- const decoders = /* @__PURE__ */ new Map();
230
- for (const [name, size] of Object.entries(offsets || fileSizes(dir))) {
231
- state.set(name, {
232
- offset: size,
233
- partial: ""
234
- });
235
- decoders.set(name, new StringDecoder("utf8"));
236
- }
237
- function emit(records) {
238
- for (const record of records) if (recordMatches(record, criteria)) onRecord(record);
239
- }
240
- function drainRotated(name, entry) {
241
- const path = rotatedLogPath(join(dir, name));
242
- let size;
243
- try {
244
- size = statSync(path).size;
245
- } catch {
246
- return;
247
- }
248
- const decoder = decoders.get(name) ?? new StringDecoder("utf8");
249
- emit(advanceTail(entry, readChunk(path, decoder, entry.offset, size) + decoder.end(), size).records);
250
- }
251
- function pollFile(name) {
252
- const path = join(dir, name);
253
- const size = statSync(path).size;
254
- const entry = state.get(name);
255
- if (entry && size < entry.offset) drainRotated(name, entry);
256
- const { start, prev } = tailRead(entry, size);
257
- if (prev !== entry) decoders.set(name, new StringDecoder("utf8"));
258
- if (!decoders.has(name)) decoders.set(name, new StringDecoder("utf8"));
259
- const next = advanceTail(prev, readChunk(path, decoders.get(name), start, size), size);
260
- state.set(name, next.state);
261
- emit(next.records);
262
- }
263
- function poll() {
264
- for (const name of logFiles(dir)) try {
265
- pollFile(name);
266
- } catch {}
267
- }
268
- const timer = setInterval(poll, intervalMs);
269
- return function stop() {
270
- clearInterval(timer);
271
- };
272
- }
273
- function readChunk(path, decoder, start, size) {
274
- if (size <= start) return "";
275
- const fd = openSync(path, "r");
276
- try {
277
- const buf = Buffer.allocUnsafe(size - start);
278
- const read = readSync(fd, buf, 0, size - start, start);
279
- return decoder.write(buf.subarray(0, read));
280
- } finally {
281
- closeSync(fd);
282
- }
283
- }
284
- function tsOf(record) {
285
- return typeof record?.ts === "number" && Number.isFinite(record.ts) ? record.ts : null;
286
- }
287
- function sortByTs(records) {
288
- return records.toSorted((a, b) => {
289
- const ta = tsOf(a);
290
- const tb = tsOf(b);
291
- if (ta === null && tb === null) return 0;
292
- if (ta === null) return 1;
293
- if (tb === null) return -1;
294
- return ta - tb;
295
- });
296
- }
297
- //#endregion
298
- export { fileSizes as a, parseSince as c, recordMatches as d, sortByTs as f, compileGrep as i, queryLogs as l, attachExpoErrorContext as n, followLogs as o, buildCriteria as r, logFiles as s, ERROR_SOURCES as t, readLogRecords as u };