@hughescr/stryker-bun-runner 1.3.3 → 1.3.5

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 CHANGED
@@ -153,7 +153,7 @@ Stryker core's own [`maxTestRunnerReuse`](https://stryker-mutator.io/docs/stryke
153
153
  This plugin is designed to tolerate that recycling cleanly:
154
154
 
155
155
  - `dispose()` cleans up its preload script, coverage file, sanitized bunfig, and registry temp file, and aborts any run still in flight (see [Orphan prevention](#orphan-prevention)).
156
- - A fresh `BunTestRunner` instance that never ran its own `dryRun` (as happens after a recycle) still resolves `killedBy` names correctly: it lazily loads the shared, file-backed dry-run test registry written by whichever instance *did* run `dryRun`, exactly as it already does for any other multi-worker Stryker run.
156
+ - A fresh `BunTestRunner` instance that never ran its own `dryRun` (as happens after a recycle) still resolves `killedBy` names correctly: it lazily loads the shared, file-backed dry-run test registry written by whichever instance *did* run `dryRun`, exactly as it already does for any other multi-worker Stryker run. The registry lives in the OS temp directory, not the project directory, keyed to this Stryker run so it can't collide with another run's registry or a different project's — a recycled instance is still a child of the same Stryker main process, so it derives the same key and finds the same file.
157
157
 
158
158
  ```javascript
159
159
  // stryker.conf.mjs
@@ -242,13 +242,36 @@ of them in a clean run's logs is worth investigating before trusting the score.
242
242
  retrying the run (with less concurrent load, or fewer parallel Stryker workers) is
243
243
  the first thing to try.
244
244
 
245
+ Before this check runs, the bun test child process (during `dryRun` only) holds
246
+ itself open past its own natural exit and waits for the runner to prove — via an
247
+ inspector-protocol round-trip over the same ordered connection the test events
248
+ arrive on — that it has actually received and processed everything the child
249
+ sent, before letting the child close its coverage socket and exit. This closes
250
+ the specific race that used to cause this gate to fire under CPU-contended CI
251
+ runners: previously, nothing synchronized "the runner has drained the inspector
252
+ stream" with "the child process is allowed to exit," so a consumer that couldn't
253
+ keep up with the event stream under contention would lose whatever hadn't been
254
+ processed by the time the child exited. The handshake is bounded on both sides
255
+ (the child gives up and proceeds after a few seconds if it hears nothing back,
256
+ and the runner's own round-trip is bounded independently and more tightly) — if
257
+ either bound is hit, today's original behavior (including this gate) applies
258
+ exactly as before, so the handshake can only reduce how often this gate fires,
259
+ never mask a real truncation from it.
260
+
245
261
  The gate's thresholds — `EXECUTION_SHORTFALL_ABS_FLOOR`, `EXECUTION_SHORTFALL_RATIO_THRESHOLD`,
246
- `ORPHANED_KEY_ABS_FLOOR`, and the drain wait `INSPECTOR_DRAIN_TIMEOUT_MS` it depends on —
247
- are fixed module-level constants in `src/bun-test-runner.ts`. There is currently no config
248
- option to override them; if these defaults produce false positives in your environment
249
- (e.g. a CI runner with very different contention characteristics than the ones this gate
250
- was tuned against), a config knob is a possible follow-up — please open an issue rather
251
- than patching the constants locally.
262
+ `ORPHANED_KEY_ABS_FLOOR`, the drain wait `INSPECTOR_DRAIN_TIMEOUT_MS`, and the drain-handshake
263
+ bounds (`DRAIN_ACK_ROUND_TRIP_TIMEOUT_MS` in `src/bun-test-runner.ts`, and the matching preload-side
264
+ ceiling in `src/templates/coverage-preload.ts`) — are fixed module-level constants. There is
265
+ currently no config option to override them; if these defaults produce false positives in your
266
+ environment (e.g. a CI runner with very different contention characteristics than the ones this
267
+ gate was tuned against), a config knob is a possible follow-up — please open an issue rather than
268
+ patching the constants locally.
269
+
270
+ This handshake only covers the `dryRun` path (where coverage collection and the
271
+ completeness gate apply) — individual mutant runs are not held open the same way,
272
+ since they run small, `--test-name-pattern`-filtered subsets where the same
273
+ backlog-under-contention risk is negligible and the completeness gate does not
274
+ apply to them.
252
275
 
253
276
  ### Coverage-bleed warning (dry run only)
254
277
 
@@ -277,6 +300,13 @@ of them in a clean run's logs is worth investigating before trusting the score.
277
300
 
278
301
  - **Sequential execution required** - Tests run with `--concurrency=1` to ensure accurate coverage tracking. This is slower than parallel execution but necessary for correct test-to-mutant correlation.
279
302
 
303
+ - **Inspector-stream drain handshake covers `dryRun` only** — the hold-open-until-drained
304
+ handshake described under "Dry-run completeness gate" above only runs for the dry run
305
+ (where a `SyncServer` and coverage collection are set up). Individual mutant runs are not
306
+ held open the same way: they run small, filtered test subsets where the backlog-under-CPU-
307
+ contention risk that motivated the handshake is negligible, and the completeness gate does
308
+ not apply to mutant runs in the first place.
309
+
280
310
  **Upgrade note: duplicate-name test suffixes**
281
311
 
282
312
  The runner reconciles how it assigns the `' [N]'` disambiguating suffix to
package/dist/index.d.ts CHANGED
@@ -47,9 +47,47 @@ export declare class BunTestRunner implements TestRunner {
47
47
  constructor(logger: Logger, options: StrykerOptions);
48
48
  /**
49
49
  * Single source of truth for the registry file name.
50
- * Using getters that read process.cwd() at call time ensures the path
51
- * resolves to Stryker's sandbox directory — which is set by the time these
52
- * are invoked — rather than the orchestrator's cwd at module-load time.
50
+ *
51
+ * Lives in the OS temp directory, not cwd: under Stryker's --inPlace mode
52
+ * cwd IS the user's real project root, and writing there would both
53
+ * pollute the user's project and never get cleaned up (dispose()
54
+ * deliberately never unlinks the registry itself — see its doc comment).
55
+ * The temp directory is OS-managed instead.
56
+ *
57
+ * Keyed by sha256(cwd + ':' + ppid): every worker process Stryker spawns
58
+ * for one run is a direct child of that run's single Stryker main
59
+ * process, so all of them share BOTH process.cwd() (the sandbox
60
+ * directory) AND process.ppid (the main process's pid) — and therefore
61
+ * independently derive this SAME path with no coordination required. A
62
+ * worker recycled mid-run is still a child of the same main process, so
63
+ * it re-derives the same path too (README documents recycled instances
64
+ * lazily loading the registry). This is the entire sharing contract:
65
+ * writer (buildAndPersistTestRegistry) and reader (loadRegistryFile) both
66
+ * go through this one getter rather than reimplementing the formula, so
67
+ * they can never disagree by construction.
68
+ *
69
+ * process.ppid is what makes this safe for this repo's own dogfooding:
70
+ * this plugin's own unit/integration tests run INSIDE a Stryker sandbox as
71
+ * the system under test, as children of the sandbox WORKER process, not
72
+ * of the Stryker main process — so those inner test processes hash a
73
+ * different ppid and land on a different file, and can never clobber the
74
+ * outer run's registry. A worker-unique key (e.g. the STRYKER_MUTATOR_WORKER
75
+ * env var Stryker injects per forked worker) was considered and rejected
76
+ * for the same reason it would break the cross-worker sharing above: it
77
+ * uniquely identifies each worker, not the run.
78
+ *
79
+ * process.cwd() is read directly (not resolved via fs.realpathSync):
80
+ * Stryker's child-process-proxy-worker computes every worker's chdir
81
+ * target via a pure path.resolve() of an identical IPC string, so all
82
+ * workers of a run already get a byte-identical process.cwd() with no
83
+ * symlink divergence to guard against — realpath would only add a
84
+ * syscall (and a new ENOENT failure mode if the sandbox dir is mid-
85
+ * teardown) for no benefit.
86
+ *
87
+ * Using a getter that reads process.cwd()/process.ppid at call time
88
+ * (rather than caching at construction) ensures the path resolves against
89
+ * Stryker's sandbox directory — which is set by the time these are
90
+ * invoked — rather than the orchestrator's cwd at module-load time.
53
91
  */
54
92
  private get registryPath();
55
93
  private get registryTmpPath();
package/dist/index.js CHANGED
@@ -2320,6 +2320,8 @@ var require_receiver = __commonJS((exports, module) => {
2320
2320
  this._binaryType = options.binaryType || BINARY_TYPES[0];
2321
2321
  this._extensions = options.extensions || {};
2322
2322
  this._isServer = !!options.isServer;
2323
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
2324
+ this._maxFragments = options.maxFragments | 0;
2323
2325
  this._maxPayload = options.maxPayload | 0;
2324
2326
  this._skipUTF8Validation = !!options.skipUTF8Validation;
2325
2327
  this[kWebSocket] = undefined;
@@ -2342,6 +2344,10 @@ var require_receiver = __commonJS((exports, module) => {
2342
2344
  _write(chunk, encoding, cb) {
2343
2345
  if (this._opcode === 8 && this._state == GET_INFO)
2344
2346
  return cb();
2347
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
2348
+ cb(this.createError(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
2349
+ return;
2350
+ }
2345
2351
  this._bufferedBytes += chunk.length;
2346
2352
  this._buffers.push(chunk);
2347
2353
  this.startLoop(cb);
@@ -2545,6 +2551,11 @@ var require_receiver = __commonJS((exports, module) => {
2545
2551
  return;
2546
2552
  }
2547
2553
  if (data.length) {
2554
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
2555
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
2556
+ cb(error);
2557
+ return;
2558
+ }
2548
2559
  this._messageLength = this._totalPayloadLength;
2549
2560
  this._fragments.push(data);
2550
2561
  }
@@ -2562,6 +2573,11 @@ var require_receiver = __commonJS((exports, module) => {
2562
2573
  cb(error);
2563
2574
  return;
2564
2575
  }
2576
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
2577
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
2578
+ cb(error);
2579
+ return;
2580
+ }
2565
2581
  this._fragments.push(buf);
2566
2582
  }
2567
2583
  this.dataMessage(cb);
@@ -2677,6 +2693,9 @@ var require_receiver = __commonJS((exports, module) => {
2677
2693
  var require_sender = __commonJS((exports, module) => {
2678
2694
  var { Duplex } = __require("stream");
2679
2695
  var { randomFillSync } = __require("crypto");
2696
+ var {
2697
+ types: { isUint8Array }
2698
+ } = __require("util");
2680
2699
  var PerMessageDeflate = require_permessage_deflate();
2681
2700
  var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants2();
2682
2701
  var { isBlob, isValidStatusCode } = require_validation();
@@ -2796,8 +2815,10 @@ var require_sender = __commonJS((exports, module) => {
2796
2815
  buf.writeUInt16BE(code, 0);
2797
2816
  if (typeof data === "string") {
2798
2817
  buf.write(data, 2);
2799
- } else {
2818
+ } else if (isUint8Array(data)) {
2800
2819
  buf.set(data, 2);
2820
+ } else {
2821
+ throw new TypeError("Second argument must be a string or a Uint8Array");
2801
2822
  }
2802
2823
  }
2803
2824
  const options = {
@@ -3464,6 +3485,8 @@ var require_websocket = __commonJS((exports, module) => {
3464
3485
  binaryType: this.binaryType,
3465
3486
  extensions: this._extensions,
3466
3487
  isServer: this._isServer,
3488
+ maxBufferedChunks: options.maxBufferedChunks,
3489
+ maxFragments: options.maxFragments,
3467
3490
  maxPayload: options.maxPayload,
3468
3491
  skipUTF8Validation: options.skipUTF8Validation
3469
3492
  });
@@ -3706,6 +3729,8 @@ var require_websocket = __commonJS((exports, module) => {
3706
3729
  autoPong: true,
3707
3730
  closeTimeout: CLOSE_TIMEOUT,
3708
3731
  protocolVersion: protocolVersions[1],
3732
+ maxBufferedChunks: 1024 * 1024,
3733
+ maxFragments: 128 * 1024,
3709
3734
  maxPayload: 100 * 1024 * 1024,
3710
3735
  skipUTF8Validation: false,
3711
3736
  perMessageDeflate: true,
@@ -3944,6 +3969,8 @@ var require_websocket = __commonJS((exports, module) => {
3944
3969
  websocket.setSocket(socket, head, {
3945
3970
  allowSynchronousEvents: opts.allowSynchronousEvents,
3946
3971
  generateMask: opts.generateMask,
3972
+ maxBufferedChunks: opts.maxBufferedChunks,
3973
+ maxFragments: opts.maxFragments,
3947
3974
  maxPayload: opts.maxPayload,
3948
3975
  skipUTF8Validation: opts.skipUTF8Validation
3949
3976
  });
@@ -4279,6 +4306,8 @@ var require_websocket_server = __commonJS((exports, module) => {
4279
4306
  options = {
4280
4307
  allowSynchronousEvents: true,
4281
4308
  autoPong: true,
4309
+ maxBufferedChunks: 1024 * 1024,
4310
+ maxFragments: 128 * 1024,
4282
4311
  maxPayload: 100 * 1024 * 1024,
4283
4312
  skipUTF8Validation: false,
4284
4313
  perMessageDeflate: false,
@@ -4505,6 +4534,8 @@ var require_websocket_server = __commonJS((exports, module) => {
4505
4534
  socket.removeListener("error", socketOnError);
4506
4535
  ws.setSocket(socket, head, {
4507
4536
  allowSynchronousEvents: this.options.allowSynchronousEvents,
4537
+ maxBufferedChunks: this.options.maxBufferedChunks,
4538
+ maxFragments: this.options.maxFragments,
4508
4539
  maxPayload: this.options.maxPayload,
4509
4540
  skipUTF8Validation: this.options.skipUTF8Validation
4510
4541
  });
@@ -4604,6 +4635,7 @@ var Scope;
4604
4635
  Scope2["Singleton"] = "singleton";
4605
4636
  })(Scope || (Scope = {}));
4606
4637
  // src/bun-test-runner.ts
4638
+ import { createHash } from "node:crypto";
4607
4639
  import * as fsPromises2 from "node:fs/promises";
4608
4640
  import { tmpdir } from "node:os";
4609
4641
  import path4 from "node:path";
@@ -5176,6 +5208,7 @@ var Builder = class {
5176
5208
  var import_picomatch = __toESM(require_picomatch2(), 1);
5177
5209
  var isReadonlyArray = Array.isArray;
5178
5210
  var BACKSLASHES = /\\/g;
5211
+ var DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
5179
5212
  var isWin = process.platform === "win32";
5180
5213
  var ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
5181
5214
  function getPartialMatcher(patterns, options = {}) {
@@ -5250,6 +5283,9 @@ function buildRelative(cwd, root) {
5250
5283
  return p[p.length - 1] === "/" && result !== "" ? `${result}/` : result || ".";
5251
5284
  };
5252
5285
  }
5286
+ function ensureNonDriveRelativePath(path) {
5287
+ return path.replace(DRIVE_RELATIVE_PATH, (match) => `${match}/`);
5288
+ }
5253
5289
  var splitPatternOptions = { parts: true };
5254
5290
  function splitPattern(path) {
5255
5291
  var _result$parts;
@@ -5297,7 +5333,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
5297
5333
  }
5298
5334
  const potentialRoot = posix.join(cwd, parentDir.slice(i * 3));
5299
5335
  if (potentialRoot[0] !== "." && props.root.length > potentialRoot.length) {
5300
- props.root = potentialRoot;
5336
+ props.root = ensureNonDriveRelativePath(potentialRoot);
5301
5337
  props.depthOffset = -n + i;
5302
5338
  }
5303
5339
  }
@@ -5318,7 +5354,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
5318
5354
  }
5319
5355
  props.depthOffset = newCommonPath.length;
5320
5356
  props.commonPath = newCommonPath;
5321
- props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
5357
+ props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
5322
5358
  }
5323
5359
  return result;
5324
5360
  }
@@ -5418,18 +5454,17 @@ function formatPaths(paths, mapper) {
5418
5454
  }
5419
5455
  var defaultOptions = {
5420
5456
  caseSensitiveMatch: true,
5421
- cwd: process.cwd(),
5422
5457
  debug: !!process.env.TINYGLOBBY_DEBUG,
5423
5458
  expandDirectories: true,
5424
5459
  followSymbolicLinks: true,
5425
5460
  onlyFiles: true
5426
5461
  };
5427
5462
  function getOptions(options) {
5428
- const opts = {
5429
- ...defaultOptions,
5430
- ...options
5431
- };
5432
- opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve2(opts.cwd)).replace(BACKSLASHES, "/");
5463
+ const opts = Object.assign({}, options);
5464
+ for (const key in defaultOptions)
5465
+ if (opts[key] === undefined)
5466
+ Object.assign(opts, { [key]: defaultOptions[key] });
5467
+ opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve2(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
5433
5468
  opts.ignore = ensureStringArray(opts.ignore);
5434
5469
  opts.fs && (opts.fs = {
5435
5470
  readdir: opts.fs.readdir || readdir,
@@ -5505,7 +5540,6 @@ async function cleanupPreloadScript(preloadPath) {
5505
5540
  await unlink(preloadPath);
5506
5541
  } catch {}
5507
5542
  }
5508
-
5509
5543
  // src/coverage/collector.ts
5510
5544
  import { readFile as readFile2, unlink as unlink2 } from "node:fs/promises";
5511
5545
  function arrayToCoverageData(mutantIds) {
@@ -5590,7 +5624,6 @@ async function cleanupCoverageFile(coverageFile) {
5590
5624
  await unlink2(coverageFile);
5591
5625
  } catch {}
5592
5626
  }
5593
-
5594
5627
  // src/utils/duplicate-suffix.ts
5595
5628
  function buildDiscoveryOrderIndex(discoveryOrderedIds) {
5596
5629
  const index = new Map;
@@ -5916,7 +5949,6 @@ function mapLegacyCounterKeys(rawCoverage, executionOrder, testHierarchy, logger
5916
5949
  perTest: remappedPerTest
5917
5950
  });
5918
5951
  }
5919
-
5920
5952
  // node_modules/ws/wrapper.mjs
5921
5953
  var import_stream = __toESM(require_stream(), 1);
5922
5954
  var import_extension = __toESM(require_extension(), 1);
@@ -6625,6 +6657,13 @@ async function getAvailablePort() {
6625
6657
  }
6626
6658
  // src/utils/sync-server.ts
6627
6659
  import { createServer as createServer2 } from "node:http";
6660
+ function rawDataToString(data) {
6661
+ if (Array.isArray(data)) {
6662
+ return Buffer.concat(data).toString("utf8");
6663
+ }
6664
+ return Buffer.isBuffer(data) ? data.toString("utf8") : Buffer.from(data).toString("utf8");
6665
+ }
6666
+
6628
6667
  class SyncServer {
6629
6668
  httpServer = null;
6630
6669
  wss = null;
@@ -6634,6 +6673,8 @@ class SyncServer {
6634
6673
  createHttpServer;
6635
6674
  WebSocketServerClass;
6636
6675
  webSocketOpenState;
6676
+ drainHandler = null;
6677
+ drainInFlight = null;
6637
6678
  constructor(options) {
6638
6679
  this.port = options.port;
6639
6680
  this.createHttpServer = options.createHttpServer ?? createServer2;
@@ -6666,7 +6707,11 @@ class SyncServer {
6666
6707
  ws.on("close", () => {
6667
6708
  this.clients.delete(ws);
6668
6709
  });
6669
- ws.on("message", () => {});
6710
+ ws.on("message", (data) => {
6711
+ if (rawDataToString(data) === "drain-request") {
6712
+ this.handleDrainRequest(ws);
6713
+ }
6714
+ });
6670
6715
  });
6671
6716
  this.httpServer.on("error", reject);
6672
6717
  this.httpServer.listen(this.port, () => {
@@ -6687,8 +6732,32 @@ class SyncServer {
6687
6732
  } catch {}
6688
6733
  }
6689
6734
  }
6735
+ setDrainHandler(handler) {
6736
+ this.drainHandler = handler;
6737
+ }
6738
+ handleDrainRequest(ws) {
6739
+ if (!this.drainHandler) {
6740
+ return;
6741
+ }
6742
+ this.drainInFlight ??= this.drainHandler();
6743
+ const inFlight = this.drainInFlight;
6744
+ (async () => {
6745
+ try {
6746
+ await inFlight;
6747
+ } catch {
6748
+ return;
6749
+ }
6750
+ try {
6751
+ if (ws.readyState === this.webSocketOpenState) {
6752
+ ws.send("drained");
6753
+ }
6754
+ } catch {}
6755
+ })();
6756
+ }
6690
6757
  async close() {
6691
6758
  this.readyLatched = false;
6759
+ this.drainHandler = null;
6760
+ this.drainInFlight = null;
6692
6761
  for (const client of this.clients) {
6693
6762
  try {
6694
6763
  client.close();
@@ -6718,189 +6787,6 @@ class SyncServer {
6718
6787
  import { readFile as readFile4, unlink as unlink3, writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
6719
6788
  import path2 from "node:path";
6720
6789
 
6721
- // node_modules/smol-toml/dist/error.js
6722
- /*!
6723
- * Copyright (c) Squirrel Chat et al., All rights reserved.
6724
- * SPDX-License-Identifier: BSD-3-Clause
6725
- *
6726
- * Redistribution and use in source and binary forms, with or without
6727
- * modification, are permitted provided that the following conditions are met:
6728
- *
6729
- * 1. Redistributions of source code must retain the above copyright notice, this
6730
- * list of conditions and the following disclaimer.
6731
- * 2. Redistributions in binary form must reproduce the above copyright notice,
6732
- * this list of conditions and the following disclaimer in the
6733
- * documentation and/or other materials provided with the distribution.
6734
- * 3. Neither the name of the copyright holder nor the names of its contributors
6735
- * may be used to endorse or promote products derived from this software without
6736
- * specific prior written permission.
6737
- *
6738
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
6739
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6740
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6741
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
6742
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6743
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
6744
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6745
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6746
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6747
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6748
- */
6749
- function getLineColFromPtr(string, ptr) {
6750
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
6751
- return [lines.length, lines.pop().length + 1];
6752
- }
6753
- function makeCodeBlock(string, line, column) {
6754
- let lines = string.split(/\r\n|\n|\r/g);
6755
- let codeblock = "";
6756
- let numberLen = (Math.log10(line + 1) | 0) + 1;
6757
- for (let i = line - 1;i <= line + 1; i++) {
6758
- let l = lines[i - 1];
6759
- if (!l)
6760
- continue;
6761
- codeblock += i.toString().padEnd(numberLen, " ");
6762
- codeblock += ": ";
6763
- codeblock += l;
6764
- codeblock += `
6765
- `;
6766
- if (i === line) {
6767
- codeblock += " ".repeat(numberLen + column + 2);
6768
- codeblock += `^
6769
- `;
6770
- }
6771
- }
6772
- return codeblock;
6773
- }
6774
-
6775
- class TomlError extends Error {
6776
- line;
6777
- column;
6778
- codeblock;
6779
- constructor(message, options) {
6780
- const [line, column] = getLineColFromPtr(options.toml, options.ptr);
6781
- const codeblock = makeCodeBlock(options.toml, line, column);
6782
- super(`Invalid TOML document: ${message}
6783
-
6784
- ${codeblock}`, options);
6785
- this.line = line;
6786
- this.column = column;
6787
- this.codeblock = codeblock;
6788
- }
6789
- }
6790
-
6791
- // node_modules/smol-toml/dist/util.js
6792
- /*!
6793
- * Copyright (c) Squirrel Chat et al., All rights reserved.
6794
- * SPDX-License-Identifier: BSD-3-Clause
6795
- *
6796
- * Redistribution and use in source and binary forms, with or without
6797
- * modification, are permitted provided that the following conditions are met:
6798
- *
6799
- * 1. Redistributions of source code must retain the above copyright notice, this
6800
- * list of conditions and the following disclaimer.
6801
- * 2. Redistributions in binary form must reproduce the above copyright notice,
6802
- * this list of conditions and the following disclaimer in the
6803
- * documentation and/or other materials provided with the distribution.
6804
- * 3. Neither the name of the copyright holder nor the names of its contributors
6805
- * may be used to endorse or promote products derived from this software without
6806
- * specific prior written permission.
6807
- *
6808
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
6809
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6810
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6811
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
6812
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6813
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
6814
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6815
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6816
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6817
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6818
- */
6819
- function isEscaped(str, ptr) {
6820
- let i = 0;
6821
- while (str[ptr - ++i] === "\\")
6822
- ;
6823
- return --i && i % 2;
6824
- }
6825
- function indexOfNewline(str, start = 0, end = str.length) {
6826
- let idx = str.indexOf(`
6827
- `, start);
6828
- if (str[idx - 1] === "\r")
6829
- idx--;
6830
- return idx <= end ? idx : -1;
6831
- }
6832
- function skipComment(str, ptr) {
6833
- for (let i = ptr;i < str.length; i++) {
6834
- let c = str[i];
6835
- if (c === `
6836
- `)
6837
- return i;
6838
- if (c === "\r" && str[i + 1] === `
6839
- `)
6840
- return i + 1;
6841
- if (c < " " && c !== "\t" || c === "") {
6842
- throw new TomlError("control characters are not allowed in comments", {
6843
- toml: str,
6844
- ptr
6845
- });
6846
- }
6847
- }
6848
- return str.length;
6849
- }
6850
- function skipVoid(str, ptr, banNewLines, banComments) {
6851
- let c;
6852
- while (true) {
6853
- while ((c = str[ptr]) === " " || c === "\t" || !banNewLines && (c === `
6854
- ` || c === "\r" && str[ptr + 1] === `
6855
- `))
6856
- ptr++;
6857
- if (banComments || c !== "#")
6858
- break;
6859
- ptr = skipComment(str, ptr);
6860
- }
6861
- return ptr;
6862
- }
6863
- function skipUntil(str, ptr, sep2, end, banNewLines = false) {
6864
- if (!end) {
6865
- ptr = indexOfNewline(str, ptr);
6866
- return ptr < 0 ? str.length : ptr;
6867
- }
6868
- for (let i = ptr;i < str.length; i++) {
6869
- let c = str[i];
6870
- if (c === "#") {
6871
- i = indexOfNewline(str, i);
6872
- } else if (c === sep2) {
6873
- return i + 1;
6874
- } else if (c === end || banNewLines && (c === `
6875
- ` || c === "\r" && str[i + 1] === `
6876
- `)) {
6877
- return i;
6878
- }
6879
- }
6880
- throw new TomlError("cannot find end of structure", {
6881
- toml: str,
6882
- ptr
6883
- });
6884
- }
6885
- function getStringEnd(str, seek) {
6886
- let first = str[seek];
6887
- let target2 = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
6888
- seek += target2.length - 1;
6889
- do
6890
- seek = str.indexOf(target2, ++seek);
6891
- while (seek > -1 && first !== "'" && isEscaped(str, seek));
6892
- if (seek > -1) {
6893
- seek += target2.length;
6894
- if (target2.length > 1) {
6895
- if (str[seek] === first)
6896
- seek++;
6897
- if (str[seek] === first)
6898
- seek++;
6899
- }
6900
- }
6901
- return seek;
6902
- }
6903
-
6904
6790
  // node_modules/smol-toml/dist/date.js
6905
6791
  /*!
6906
6792
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -7021,6 +6907,76 @@ class TomlDate extends Date {
7021
6907
  }
7022
6908
  }
7023
6909
 
6910
+ // node_modules/smol-toml/dist/error.js
6911
+ /*!
6912
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
6913
+ * SPDX-License-Identifier: BSD-3-Clause
6914
+ *
6915
+ * Redistribution and use in source and binary forms, with or without
6916
+ * modification, are permitted provided that the following conditions are met:
6917
+ *
6918
+ * 1. Redistributions of source code must retain the above copyright notice, this
6919
+ * list of conditions and the following disclaimer.
6920
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
6921
+ * this list of conditions and the following disclaimer in the
6922
+ * documentation and/or other materials provided with the distribution.
6923
+ * 3. Neither the name of the copyright holder nor the names of its contributors
6924
+ * may be used to endorse or promote products derived from this software without
6925
+ * specific prior written permission.
6926
+ *
6927
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
6928
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6929
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6930
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
6931
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6932
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
6933
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6934
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6935
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6936
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6937
+ */
6938
+ function getLineColFromPtr(string, ptr) {
6939
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
6940
+ return [lines.length, lines.pop().length + 1];
6941
+ }
6942
+ function makeCodeBlock(string, line, column) {
6943
+ let lines = string.split(/\r\n|\n|\r/g);
6944
+ let codeblock = "";
6945
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
6946
+ for (let i = line - 1;i <= line + 1; i++) {
6947
+ let l = lines[i - 1];
6948
+ if (!l)
6949
+ continue;
6950
+ codeblock += i.toString().padEnd(numberLen, " ");
6951
+ codeblock += ": ";
6952
+ codeblock += l;
6953
+ codeblock += `
6954
+ `;
6955
+ if (i === line) {
6956
+ codeblock += " ".repeat(numberLen + column + 2);
6957
+ codeblock += `^
6958
+ `;
6959
+ }
6960
+ }
6961
+ return codeblock;
6962
+ }
6963
+
6964
+ class TomlError extends Error {
6965
+ line;
6966
+ column;
6967
+ codeblock;
6968
+ constructor(message, options) {
6969
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
6970
+ const codeblock = makeCodeBlock(options.toml, line, column);
6971
+ super(`Invalid TOML document: ${message}
6972
+
6973
+ ${codeblock}`, options);
6974
+ this.line = line;
6975
+ this.column = column;
6976
+ this.codeblock = codeblock;
6977
+ }
6978
+ }
6979
+
7024
6980
  // node_modules/smol-toml/dist/primitive.js
7025
6981
  /*!
7026
6982
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -7052,95 +7008,103 @@ class TomlDate extends Date {
7052
7008
  var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
7053
7009
  var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
7054
7010
  var LEADING_ZERO = /^[+-]?0[0-9_]/;
7055
- var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
7056
- var ESC_MAP = {
7057
- b: "\b",
7058
- t: "\t",
7059
- n: `
7060
- `,
7061
- f: "\f",
7062
- r: "\r",
7063
- e: "\x1B",
7064
- '"': '"',
7065
- "\\": "\\"
7066
- };
7067
- function parseString(str, ptr = 0, endPtr = str.length) {
7068
- let isLiteral = str[ptr] === "'";
7069
- let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
7011
+ function parseString(str, ptr) {
7012
+ let c = str[ptr++];
7013
+ let first = c;
7014
+ let isLiteral = c === "'";
7015
+ let isMultiline = c === str[ptr] && c === str[ptr + 1];
7070
7016
  if (isMultiline) {
7071
- endPtr -= 2;
7072
- if (str[ptr += 2] === "\r")
7073
- ptr++;
7074
- if (str[ptr] === `
7017
+ if (str[ptr += 2] === `
7075
7018
  `)
7076
7019
  ptr++;
7020
+ else if (str[ptr] === "\r" && str[ptr + 1] === `
7021
+ `)
7022
+ ptr += 2;
7077
7023
  }
7078
- let tmp = 0;
7079
- let isEscape;
7080
7024
  let parsed = "";
7081
7025
  let sliceStart = ptr;
7082
- while (ptr < endPtr - 1) {
7083
- let c = str[ptr++];
7084
- if (c === `
7085
- ` || c === "\r" && str[ptr] === `
7086
- `) {
7087
- if (!isMultiline) {
7088
- throw new TomlError("newlines are not allowed in strings", {
7089
- toml: str,
7090
- ptr: ptr - 1
7091
- });
7092
- }
7026
+ let state = 0;
7027
+ for (let i = ptr;i < str.length; i++) {
7028
+ c = str[i];
7029
+ if (isMultiline && (c === `
7030
+ ` || c === "\r" && str[i + 1] === `
7031
+ `)) {
7032
+ state = state && 3;
7093
7033
  } else if (c < " " && c !== "\t" || c === "") {
7094
7034
  throw new TomlError("control characters are not allowed in strings", {
7095
7035
  toml: str,
7096
- ptr: ptr - 1
7036
+ ptr: i
7097
7037
  });
7098
- }
7099
- if (isEscape) {
7100
- isEscape = false;
7038
+ } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
7039
+ if (isMultiline) {
7040
+ if (str[i + 3] === first)
7041
+ i++;
7042
+ if (str[i + 3] === first)
7043
+ i++;
7044
+ }
7045
+ return [
7046
+ state ? parsed : parsed + str.slice(sliceStart, i),
7047
+ i + (isMultiline ? 3 : 1)
7048
+ ];
7049
+ } else if (!state) {
7050
+ if (!isLiteral && c === "\\") {
7051
+ parsed += str.slice(sliceStart, sliceStart = i);
7052
+ state = 1;
7053
+ }
7054
+ } else if (state === 1) {
7101
7055
  if (c === "x" || c === "u" || c === "U") {
7102
- let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
7103
- if (!ESCAPE_REGEX.test(code)) {
7104
- throw new TomlError("invalid unicode escape", {
7105
- toml: str,
7106
- ptr: tmp
7107
- });
7108
- }
7109
- try {
7110
- parsed += String.fromCodePoint(parseInt(code, 16));
7111
- } catch {
7112
- throw new TomlError("invalid unicode escape", {
7113
- toml: str,
7114
- ptr: tmp
7115
- });
7116
- }
7117
- } else if (isMultiline && (c === `
7118
- ` || c === " " || c === "\t" || c === "\r")) {
7119
- ptr = skipVoid(str, ptr - 1, true);
7120
- if (str[ptr] !== `
7121
- ` && str[ptr] !== "\r") {
7122
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
7123
- toml: str,
7124
- ptr: tmp
7125
- });
7126
- }
7127
- ptr = skipVoid(str, ptr);
7128
- } else if (c in ESC_MAP) {
7129
- parsed += ESC_MAP[c];
7056
+ let value = 0;
7057
+ let len = c === "x" ? 2 : c === "u" ? 4 : 8;
7058
+ for (let j = 0;j < len; j++, i++) {
7059
+ let hex = str.charCodeAt(i + 1);
7060
+ let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
7061
+ if (digit < 0)
7062
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
7063
+ value = value << 4 | digit;
7064
+ }
7065
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
7066
+ throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
7067
+ }
7068
+ parsed += String.fromCodePoint(value);
7069
+ sliceStart = i + 1;
7070
+ state = 0;
7071
+ } else if (c === " " || c === "\t") {
7072
+ state = 2;
7130
7073
  } else {
7131
- throw new TomlError("unrecognized escape sequence", {
7074
+ if (c === "b")
7075
+ parsed += "\b";
7076
+ else if (c === "t")
7077
+ parsed += "\t";
7078
+ else if (c === "n")
7079
+ parsed += `
7080
+ `;
7081
+ else if (c === "f")
7082
+ parsed += "\f";
7083
+ else if (c === "r")
7084
+ parsed += "\r";
7085
+ else if (c === "e")
7086
+ parsed += "\x1B";
7087
+ else if (c === '"')
7088
+ parsed += '"';
7089
+ else if (c === "\\")
7090
+ parsed += "\\";
7091
+ else
7092
+ throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
7093
+ sliceStart = i + 1;
7094
+ state = 0;
7095
+ }
7096
+ } else if (c !== " " && c !== "\t") {
7097
+ if (state === 2) {
7098
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
7132
7099
  toml: str,
7133
- ptr: tmp
7100
+ ptr: sliceStart
7134
7101
  });
7135
7102
  }
7136
- sliceStart = ptr;
7137
- } else if (!isLiteral && c === "\\") {
7138
- tmp = ptr - 1;
7139
- isEscape = true;
7140
- parsed += str.slice(sliceStart, tmp);
7103
+ state = !isLiteral && c === "\\" ? 1 : 0;
7104
+ sliceStart = i;
7141
7105
  }
7142
7106
  }
7143
- return parsed + str.slice(sliceStart, endPtr - 1);
7107
+ throw new TomlError("unfinished string", { toml: str, ptr });
7144
7108
  }
7145
7109
  function parseValue(value, toml, ptr, integersAsBigInt) {
7146
7110
  if (value === "true")
@@ -7193,6 +7157,95 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
7193
7157
  return date;
7194
7158
  }
7195
7159
 
7160
+ // node_modules/smol-toml/dist/util.js
7161
+ /*!
7162
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
7163
+ * SPDX-License-Identifier: BSD-3-Clause
7164
+ *
7165
+ * Redistribution and use in source and binary forms, with or without
7166
+ * modification, are permitted provided that the following conditions are met:
7167
+ *
7168
+ * 1. Redistributions of source code must retain the above copyright notice, this
7169
+ * list of conditions and the following disclaimer.
7170
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
7171
+ * this list of conditions and the following disclaimer in the
7172
+ * documentation and/or other materials provided with the distribution.
7173
+ * 3. Neither the name of the copyright holder nor the names of its contributors
7174
+ * may be used to endorse or promote products derived from this software without
7175
+ * specific prior written permission.
7176
+ *
7177
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
7178
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
7179
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7180
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
7181
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7182
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
7183
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7184
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
7185
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7186
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7187
+ */
7188
+ function indexOfNewline(str, start = 0, end = str.length) {
7189
+ let idx = str.indexOf(`
7190
+ `, start);
7191
+ if (str[idx - 1] === "\r")
7192
+ idx--;
7193
+ return idx <= end ? idx : -1;
7194
+ }
7195
+ function skipComment(str, ptr) {
7196
+ for (let i = ptr;i < str.length; i++) {
7197
+ let c = str[i];
7198
+ if (c === `
7199
+ `)
7200
+ return i;
7201
+ if (c === "\r" && str[i + 1] === `
7202
+ `)
7203
+ return i + 1;
7204
+ if (c < " " && c !== "\t" || c === "") {
7205
+ throw new TomlError("control characters are not allowed in comments", {
7206
+ toml: str,
7207
+ ptr
7208
+ });
7209
+ }
7210
+ }
7211
+ return str.length;
7212
+ }
7213
+ function skipVoid(str, ptr, banNewLines, banComments) {
7214
+ let c;
7215
+ while (true) {
7216
+ while ((c = str[ptr]) === " " || c === "\t" || !banNewLines && (c === `
7217
+ ` || c === "\r" && str[ptr + 1] === `
7218
+ `))
7219
+ ptr++;
7220
+ if (banComments || c !== "#")
7221
+ break;
7222
+ ptr = skipComment(str, ptr);
7223
+ }
7224
+ return ptr;
7225
+ }
7226
+ function skipUntil(str, ptr, sep2, end, banNewLines = false) {
7227
+ if (!end) {
7228
+ ptr = indexOfNewline(str, ptr);
7229
+ return ptr < 0 ? str.length : ptr;
7230
+ }
7231
+ for (let i = ptr;i < str.length; i++) {
7232
+ let c = str[i];
7233
+ if (c === "#") {
7234
+ i = indexOfNewline(str, i);
7235
+ } else if (c === sep2) {
7236
+ return i + 1;
7237
+ } else if (c === end || banNewLines && (c === `
7238
+ ` || c === "\r" && str[i + 1] === `
7239
+ `)) {
7240
+ return i;
7241
+ }
7242
+ }
7243
+ throw new TomlError("cannot find end of structure", {
7244
+ toml: str,
7245
+ ptr
7246
+ });
7247
+ }
7248
+
7196
7249
  // node_modules/smol-toml/dist/extract.js
7197
7250
  /*!
7198
7251
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -7253,25 +7306,24 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
7253
7306
  }
7254
7307
  return [value, endPtr2];
7255
7308
  }
7256
- let endPtr;
7257
7309
  if (c === '"' || c === "'") {
7258
- endPtr = getStringEnd(str, ptr);
7259
- let parsed = parseString(str, ptr, endPtr);
7310
+ let [parsed, endPtr2] = parseString(str, ptr);
7260
7311
  if (end) {
7261
- endPtr = skipVoid(str, endPtr);
7262
- if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== `
7263
- ` && str[endPtr] !== "\r") {
7312
+ endPtr2 = skipVoid(str, endPtr2);
7313
+ if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== `
7314
+ ` && str[endPtr2] !== "\r") {
7264
7315
  throw new TomlError("unexpected character encountered", {
7265
7316
  toml: str,
7266
- ptr: endPtr
7317
+ ptr: endPtr2
7267
7318
  });
7268
7319
  }
7269
- endPtr += +(str[endPtr] === ",");
7320
+ if (str[endPtr2] === ",")
7321
+ endPtr2++;
7270
7322
  }
7271
- return [parsed, endPtr];
7323
+ return [parsed, endPtr2];
7272
7324
  }
7273
- endPtr = skipUntil(str, ptr, ",", end);
7274
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
7325
+ let endPtr = skipUntil(str, ptr, ",", end);
7326
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
7275
7327
  if (!slice[0]) {
7276
7328
  throw new TomlError("incomplete key-value declaration: no value specified", {
7277
7329
  toml: str,
@@ -7280,7 +7332,8 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
7280
7332
  }
7281
7333
  if (end && slice[1] > -1) {
7282
7334
  endPtr = skipVoid(str, ptr + slice[1]);
7283
- endPtr += +(str[endPtr] === ",");
7335
+ if (str[endPtr] === ",")
7336
+ endPtr++;
7284
7337
  }
7285
7338
  return [
7286
7339
  parseValue(slice[0], str, ptr, integersAsBigInt),
@@ -7337,13 +7390,7 @@ function parseKey(str, ptr, end = "=") {
7337
7390
  ptr
7338
7391
  });
7339
7392
  }
7340
- let eos = getStringEnd(str, ptr);
7341
- if (eos < 0) {
7342
- throw new TomlError("unfinished string encountered", {
7343
- toml: str,
7344
- ptr
7345
- });
7346
- }
7393
+ let [part, eos] = parseString(str, ptr);
7347
7394
  dot = str.indexOf(".", eos);
7348
7395
  let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
7349
7396
  let newLine = indexOfNewline(strEnd);
@@ -7368,7 +7415,7 @@ function parseKey(str, ptr, end = "=") {
7368
7415
  });
7369
7416
  }
7370
7417
  }
7371
- parsed.push(parseString(str, ptr, eos));
7418
+ parsed.push(part);
7372
7419
  } else {
7373
7420
  dot = str.indexOf(".", ptr);
7374
7421
  let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
@@ -7666,7 +7713,7 @@ function stringifyValue(val, type, depth, numberAsFloat) {
7666
7713
  return "inf";
7667
7714
  if (val === -Infinity)
7668
7715
  return "-inf";
7669
- if (numberAsFloat && Number.isInteger(val))
7716
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
7670
7717
  return val.toFixed(1);
7671
7718
  return val.toString();
7672
7719
  }
@@ -8020,6 +8067,15 @@ function sleep(ms) {
8020
8067
  setTimeout(resolve3, ms);
8021
8068
  });
8022
8069
  }
8070
+ function rejectAfterMs(ms, message) {
8071
+ let timer;
8072
+ const promise2 = new Promise((_resolve, reject) => {
8073
+ timer = setTimeout(() => {
8074
+ reject(new Error(message));
8075
+ }, ms);
8076
+ });
8077
+ return { promise: promise2, cancel: () => clearTimeout(timer) };
8078
+ }
8023
8079
  function buildTestNameIndex(tests, bunNames) {
8024
8080
  const testNameIndex = new Map;
8025
8081
  for (const [i, test] of tests.entries()) {
@@ -8037,6 +8093,7 @@ var EXECUTION_SHORTFALL_ABS_FLOOR = 10;
8037
8093
  var EXECUTION_SHORTFALL_RATIO_THRESHOLD = 0.05;
8038
8094
  var ORPHANED_KEY_ABS_FLOOR = 5;
8039
8095
  var INSPECTOR_DRAIN_TIMEOUT_MS = 1000;
8096
+ var DRAIN_ACK_ROUND_TRIP_TIMEOUT_MS = 4000;
8040
8097
 
8041
8098
  class BunTestRunner {
8042
8099
  logger;
@@ -8101,7 +8158,9 @@ class BunTestRunner {
8101
8158
  }
8102
8159
  }
8103
8160
  get registryPath() {
8104
- return path4.join(process.cwd(), ".stryker-bun-runner-registry.json");
8161
+ const key = `${process.cwd()}:${process.ppid}`;
8162
+ const hash = createHash("sha256").update(key).digest("hex").slice(0, 16);
8163
+ return path4.join(tmpdir(), "stryker-bun-runner", `registry-${hash}.json`);
8105
8164
  }
8106
8165
  get registryTmpPath() {
8107
8166
  return `${this.registryPath}.tmp`;
@@ -8419,6 +8478,17 @@ exit=%s timedOut=%s
8419
8478
  errorMessage: `Failed to connect to Bun inspector: ${errorMsg}`
8420
8479
  };
8421
8480
  }
8481
+ syncServer.setDrainHandler(async () => {
8482
+ const { promise: timeoutPromise, cancel: cancelTimeout } = rejectAfterMs(DRAIN_ACK_ROUND_TRIP_TIMEOUT_MS, "Inspector drain round-trip timed out");
8483
+ try {
8484
+ await Promise.race([
8485
+ inspector.send("TestReporter.enable", {}),
8486
+ timeoutPromise
8487
+ ]);
8488
+ } finally {
8489
+ cancelTimeout();
8490
+ }
8491
+ });
8422
8492
  syncServer.signalReady();
8423
8493
  this.logger.debug("Signaled preload script to proceed");
8424
8494
  const result = await testProcess;
@@ -8496,6 +8566,7 @@ exit=%s timedOut=%s
8496
8566
  baseNameIndex: [...this.baseNameIndex.entries()],
8497
8567
  testNameIndex: [...testNameIndex.entries()]
8498
8568
  });
8569
+ await fsPromises2.mkdir(path4.dirname(registryPath), { recursive: true });
8499
8570
  await fsPromises2.writeFile(tmpPath, registryData, "utf8");
8500
8571
  this.lastRegistryTmpPath = tmpPath;
8501
8572
  await fsPromises2.rename(tmpPath, registryPath);
@@ -79,6 +79,15 @@ const shouldCollectCoverage = shouldCollect(config);
79
79
  // ============================================================================
80
80
  let ws: WebSocket | null = null;
81
81
 
82
+ // Bound on how long the final afterAll (below) waits for the runner's drain
83
+ // acknowledgment before giving up and proceeding as if drained — see
84
+ // "Inspector-stream drain handshake" further down.
85
+ // Deliberately ABOVE the runner-side inspector round-trip timeout
86
+ // (DRAIN_ACK_ROUND_TRIP_TIMEOUT_MS in bun-test-runner.ts) so a stuck
87
+ // round-trip is governed by that shorter ceiling first; this is the outer
88
+ // backstop if the sync channel itself is unresponsive.
89
+ const DRAIN_ACK_TIMEOUT_MS = 5000;
90
+
82
91
  // Per-file test counters for per-test coverage tracking.
83
92
  //
84
93
  // Bun runs multiple test files sequentially inside the same worker process,
@@ -314,7 +323,7 @@ if(shouldCollectCoverage) {
314
323
  strykerGlobal.currentTestId = undefined;
315
324
  });
316
325
 
317
- afterAll(() => {
326
+ afterAll(async () => {
318
327
  // Final gap check, best-effort: catches bleed that has already recorded a
319
328
  // counter delta by the time afterAll runs, with no following beforeEach
320
329
  // left to catch it any other way. This preload's afterAll fires once per
@@ -339,9 +348,76 @@ if(shouldCollectCoverage) {
339
348
  }
340
349
  }
341
350
 
342
- ws?.close();
351
+ // Coverage must be finalized — gap check above, then the write itself —
352
+ // BEFORE the drain-ack wait below, not after. The wait yields this
353
+ // process's event loop for up to DRAIN_ACK_TIMEOUT_MS; if it ran first,
354
+ // any stray timer or promise continuation left behind by the last test
355
+ // could fire during that yield, touch mutantCoverage.static, and leak
356
+ // into the persisted snapshot — reintroducing exactly the class of risk
357
+ // the gap-window bleed check above exists to catch. Writing first means
358
+ // the snapshot is already on disk before that window even opens, so
359
+ // nothing that runs during the wait can affect what was persisted.
343
360
  writeCoverageData();
344
361
  // Clear the accumulator now that it has been written out.
345
362
  lateHits.length = 0;
363
+
364
+ // ====================================================================
365
+ // Inspector-stream drain handshake
366
+ // ====================================================================
367
+ // Block (bounded) on a drain acknowledgment from the runner BEFORE
368
+ // closing this socket / allowing this process to exit. Without this,
369
+ // nothing synchronizes "the runner has received and processed every
370
+ // inspector event" with "this child process is allowed to exit" — a
371
+ // contended CPU (e.g. a 2-core CI box) can leave the runner's
372
+ // InspectorClient with an unprocessed backlog at the moment this
373
+ // process exits, silently truncating the inspector stream that dry
374
+ // run's completeness gate depends on.
375
+ //
376
+ // This IS a single bounded `await`, and an `await` genuinely yields
377
+ // this process's event loop for up to DRAIN_ACK_TIMEOUT_MS — it is not
378
+ // a no-op with respect to timer/microtask starvation, and does not
379
+ // pretend to be. What makes it safe here is ordering, not avoidance:
380
+ // writeCoverageData() above already ran and the coverage snapshot is
381
+ // already on disk by the time this wait starts, so anything that
382
+ // executes during the wait cannot alter what was persisted. This must
383
+ // stay the LAST coverage-adjacent step before ws.close() — no
384
+ // coverage-relevant work should be added after it starts. Separately,
385
+ // it does NOT drain THIS process's own microtask/timer queue on
386
+ // purpose (that risk is documented in the LIMITATION comment above); it
387
+ // only waits on a message sent FROM the parent runner process.
388
+ if(ws && ws.readyState === WebSocket.OPEN) {
389
+ try {
390
+ await new Promise<void>((resolve) => {
391
+ const wsForDrain = ws!;
392
+ const timeout = setTimeout(() => {
393
+ console.warn('[Stryker] Timeout waiting for drain acknowledgment');
394
+ resolve();
395
+ }, DRAIN_ACK_TIMEOUT_MS);
396
+
397
+ wsForDrain.onmessage = (event) => {
398
+ if(event.data === 'drained') {
399
+ clearTimeout(timeout);
400
+ resolve();
401
+ }
402
+ };
403
+
404
+ wsForDrain.onerror = () => {
405
+ clearTimeout(timeout);
406
+ resolve();
407
+ };
408
+
409
+ try {
410
+ wsForDrain.send('drain-request');
411
+ } catch {
412
+ clearTimeout(timeout);
413
+ resolve();
414
+ }
415
+ });
416
+ } catch (error) {
417
+ console.warn('[Stryker] Error during drain handshake:', error);
418
+ }
419
+ }
420
+
421
+ ws?.close();
346
422
  });
347
423
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hughescr/stryker-bun-runner",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Stryker test runner plugin for Bun with perTest coverage support",
5
5
  "keywords": [
6
6
  "stryker",
@@ -43,24 +43,22 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@stryker-mutator/api": "9.6.1",
46
- "smol-toml": "1.6.1",
47
- "tinyglobby": "0.2.16",
48
- "ws": "8.20.0"
46
+ "smol-toml": "1.7.0",
47
+ "tinyglobby": "0.2.17",
48
+ "ws": "8.21.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@hughescr/eslint-config-default": "5.1.0",
51
+ "@hughescr/eslint-config-default": "6.0.1",
52
52
  "@stryker-mutator/core": "9.6.1",
53
53
  "@stryker-mutator/typescript-checker": "9.6.1",
54
- "@types/bun": "1.3.13",
55
- "@types/node": "25.6.0",
54
+ "@types/bun": "1.3.14",
55
+ "@types/node": "26.1.1",
56
56
  "@types/ws": "8.18.1",
57
57
  "dts-bundle-generator": "9.5.1",
58
- "eslint": "10.2.1",
58
+ "eslint": "10.7.0",
59
59
  "eslint-formatter-overview": "2.0.0",
60
60
  "eslint-formatter-unix": "9.0.1",
61
- "eslint-plugin-import-x": "4.16.2",
62
- "eslint-plugin-n": "17.24.0",
63
- "typescript": "6.0.3"
61
+ "typescript": "<7.0.0"
64
62
  },
65
63
  "peerDependencies": {
66
64
  "@stryker-mutator/core": "^9.0.0"