bivium 0.9.0 → 0.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.
- package/README.md +10 -6
- package/cli.js +51 -2192
- package/compute.js +4 -3
- package/config.js +3 -2
- package/docs/api.md +1 -0
- package/docs/ci.md +21 -0
- package/docs/cli.md +28 -2
- package/docs/config.md +50 -0
- package/docs/how-it-works.md +99 -0
- package/docs/tuning.md +24 -1
- package/errors.js +2 -1
- package/index.d.ts +6 -0
- package/package.json +1 -1
- package/shared-118ck8qt.js +40 -0
- package/{shared-07rt4zr7.js → shared-70w84x4c.js} +2007 -1350
- package/shared-84c9vs8a.js +475 -0
- package/shared-a5kfg3qy.js +68 -0
- package/shared-a8ebfhzf.js +319 -0
- package/shared-byhfswm9.js +1047 -0
- package/shared-graedbt1.js +12 -0
- package/shared-ke52sg37.js +149 -0
- package/shared-m8z858pr.js +26 -0
- package/shared-my87dhfd.js +164 -0
- package/{shared-550cvwt2.js → shared-px5a17nj.js} +1 -1
- package/shared-qe34axez.js +19 -0
- package/shared-rzbfbyqq.js +549 -0
- package/shared-v5gfq9zy.js +13 -0
- package/shared-wahjx628.js +66 -0
- package/shared-x17wzptz.js +4 -0
- package/shared-y7y281x3.js +103 -0
- package/shared-yfvpkeff.js +30 -0
- package/shared-211m8fjt.js +0 -69
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
showCursor2,
|
|
3
|
+
cursorHidden2
|
|
4
|
+
} from "./shared-a8ebfhzf.js";
|
|
5
|
+
|
|
6
|
+
// src/live.ts
|
|
7
|
+
var EXIT_INTERRUPTED = 130;
|
|
8
|
+
var EXIT_TERMINATED = 143;
|
|
9
|
+
var ERASE_ECHO = "\r\x1B[2K";
|
|
10
|
+
var exitCodeOf = (signal) => signal === "SIGINT" ? EXIT_INTERRUPTED : EXIT_TERMINATED;
|
|
11
|
+
function handleInterrupt(options) {
|
|
12
|
+
const { process: target } = options;
|
|
13
|
+
const controller = new AbortController;
|
|
14
|
+
const exits = options.exit ?? true;
|
|
15
|
+
const secondExits = options.secondExit ?? true;
|
|
16
|
+
const echo = options.echo ?? (options.terminal ? "erase" : "keep");
|
|
17
|
+
const state = { restored: false, stoppedBy: undefined, forced: undefined };
|
|
18
|
+
let markStopped = () => {};
|
|
19
|
+
const stopped = new Promise((resolve) => {
|
|
20
|
+
markStopped = resolve;
|
|
21
|
+
});
|
|
22
|
+
const restore = () => {
|
|
23
|
+
if (state.restored)
|
|
24
|
+
return;
|
|
25
|
+
state.restored = true;
|
|
26
|
+
const input = options.input;
|
|
27
|
+
if (input?.isTTY === true && input.isRaw !== false) {
|
|
28
|
+
input.setRawMode?.(false);
|
|
29
|
+
}
|
|
30
|
+
if (options.terminal && cursorHidden2())
|
|
31
|
+
options.write(showCursor2());
|
|
32
|
+
};
|
|
33
|
+
const quit = (code) => {
|
|
34
|
+
restore();
|
|
35
|
+
target.exit(code);
|
|
36
|
+
};
|
|
37
|
+
const stop = (signal, echoed) => {
|
|
38
|
+
if (echoed) {
|
|
39
|
+
if (echo === "erase")
|
|
40
|
+
options.write(ERASE_ECHO);
|
|
41
|
+
else if (echo === "newline")
|
|
42
|
+
options.write(`
|
|
43
|
+
`);
|
|
44
|
+
}
|
|
45
|
+
if (!secondExits && state.forced !== undefined)
|
|
46
|
+
return;
|
|
47
|
+
if (state.stoppedBy !== undefined) {
|
|
48
|
+
state.forced = signal;
|
|
49
|
+
options.onQuit?.();
|
|
50
|
+
if (secondExits) {
|
|
51
|
+
quit(exitCodeOf(signal));
|
|
52
|
+
} else {
|
|
53
|
+
restore();
|
|
54
|
+
markStopped(state.stoppedBy);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
state.stoppedBy = signal;
|
|
59
|
+
controller.abort();
|
|
60
|
+
const end = () => {
|
|
61
|
+
restore();
|
|
62
|
+
markStopped(signal);
|
|
63
|
+
if (exits && (secondExits || state.forced === undefined)) {
|
|
64
|
+
target.exit(exitCodeOf(signal));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
Promise.resolve().then(() => options.onStop?.(signal)).then(end, end);
|
|
68
|
+
};
|
|
69
|
+
const onInt = () => stop("SIGINT", true);
|
|
70
|
+
const onTerm = () => stop("SIGTERM", false);
|
|
71
|
+
const dispose = () => {
|
|
72
|
+
target.off("SIGINT", onInt);
|
|
73
|
+
target.off("SIGTERM", onTerm);
|
|
74
|
+
target.off("exit", restore);
|
|
75
|
+
};
|
|
76
|
+
target.on("SIGINT", onInt);
|
|
77
|
+
target.on("SIGTERM", onTerm);
|
|
78
|
+
target.on("exit", restore);
|
|
79
|
+
return {
|
|
80
|
+
signal: controller.signal,
|
|
81
|
+
get stoppedBy() {
|
|
82
|
+
return state.stoppedBy;
|
|
83
|
+
},
|
|
84
|
+
get forced() {
|
|
85
|
+
return state.forced;
|
|
86
|
+
},
|
|
87
|
+
stopped,
|
|
88
|
+
interrupt: () => stop("SIGINT", false),
|
|
89
|
+
settle: () => new Promise((resolve) => {
|
|
90
|
+
setImmediate(() => {
|
|
91
|
+
if (state.stoppedBy === undefined)
|
|
92
|
+
dispose();
|
|
93
|
+
resolve(state.stoppedBy);
|
|
94
|
+
});
|
|
95
|
+
}),
|
|
96
|
+
dispose
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
EXIT_INTERRUPTED,
|
|
101
|
+
exitCodeOf,
|
|
102
|
+
handleInterrupt
|
|
103
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
textWidth2,
|
|
3
|
+
MEASURE2
|
|
4
|
+
} from "./shared-a8ebfhzf.js";
|
|
5
|
+
|
|
6
|
+
// src/human.ts
|
|
7
|
+
function duration(ms) {
|
|
8
|
+
if (ms < 999.5)
|
|
9
|
+
return `${Math.round(ms)} ms`;
|
|
10
|
+
const s = ms / 1000;
|
|
11
|
+
return `${s < 999.5 ? s.toPrecision(3) : Math.round(s)} s`;
|
|
12
|
+
}
|
|
13
|
+
function wrapped(text, first, hang) {
|
|
14
|
+
const lines = [];
|
|
15
|
+
let line = first;
|
|
16
|
+
let empty = true;
|
|
17
|
+
for (const word of text.split(" ")) {
|
|
18
|
+
if (!empty && textWidth2(line) + 1 + textWidth2(word) > MEASURE2) {
|
|
19
|
+
lines.push(line);
|
|
20
|
+
line = hang + word;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
line += empty ? word : ` ${word}`;
|
|
24
|
+
empty = false;
|
|
25
|
+
}
|
|
26
|
+
lines.push(line);
|
|
27
|
+
return lines;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { duration, wrapped };
|
package/shared-211m8fjt.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var KINDS = {
|
|
3
|
-
BV_MISSING_ARGUMENT: "usage",
|
|
4
|
-
BV_UNKNOWN_COMMAND: "usage",
|
|
5
|
-
BV_UNKNOWN_OPTION: "usage",
|
|
6
|
-
BV_BAD_OPTION_VALUE: "usage",
|
|
7
|
-
BV_UNEXPECTED_ARGUMENT: "usage",
|
|
8
|
-
BV_UNKNOWN_SUITE: "usage",
|
|
9
|
-
BV_UNKNOWN_TEST: "usage",
|
|
10
|
-
BV_UNKNOWN_FILE: "usage",
|
|
11
|
-
BV_NO_RUN_COMMAND: "usage",
|
|
12
|
-
BV_NO_GITHUB_OUTPUT: "usage",
|
|
13
|
-
BV_CONFIG_NOT_FOUND: "config",
|
|
14
|
-
BV_CONFIG_UNREADABLE: "config",
|
|
15
|
-
BV_CONFIG_INVALID: "config",
|
|
16
|
-
BV_GIT_NO_BASE: "git",
|
|
17
|
-
BV_GIT_NO_MERGE_BASE: "git",
|
|
18
|
-
BV_GIT_FAILED: "git",
|
|
19
|
-
BV_INTERNAL: "other"
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class BiviumError2 extends Error {
|
|
23
|
-
code;
|
|
24
|
-
kind;
|
|
25
|
-
constructor(code, message, options) {
|
|
26
|
-
super(message, options);
|
|
27
|
-
this.code = code;
|
|
28
|
-
this.kind = KINDS[code];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function distance(a, b) {
|
|
32
|
-
const width = b.length + 1;
|
|
33
|
-
const cells = new Uint32Array((a.length + 1) * width);
|
|
34
|
-
const d = (i, j) => cells[i * width + j] ?? 0;
|
|
35
|
-
for (let i = 0;i <= a.length; i++)
|
|
36
|
-
cells[i * width] = i;
|
|
37
|
-
for (let j = 0;j <= b.length; j++)
|
|
38
|
-
cells[j] = j;
|
|
39
|
-
for (let i = 1;i <= a.length; i++) {
|
|
40
|
-
for (let j = 1;j <= b.length; j++) {
|
|
41
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
42
|
-
let best = Math.min(d(i - 1, j) + 1, d(i, j - 1) + 1, d(i - 1, j - 1) + cost);
|
|
43
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
44
|
-
best = Math.min(best, d(i - 2, j - 2) + 1);
|
|
45
|
-
}
|
|
46
|
-
cells[i * width + j] = best;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return d(a.length, b.length);
|
|
50
|
-
}
|
|
51
|
-
function closest(input, candidates) {
|
|
52
|
-
const most = Math.max(1, Math.floor(input.length / 3));
|
|
53
|
-
let best;
|
|
54
|
-
let bestDistance = most + 1;
|
|
55
|
-
for (const candidate of candidates) {
|
|
56
|
-
const d = distance(input, candidate);
|
|
57
|
-
if (d < bestDistance) {
|
|
58
|
-
best = candidate;
|
|
59
|
-
bestDistance = d;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return best;
|
|
63
|
-
}
|
|
64
|
-
function didYouMean2(input, candidates) {
|
|
65
|
-
const match = closest(input, candidates);
|
|
66
|
-
return match === undefined ? "" : ` (did you mean ${match}?)`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { BiviumError2, didYouMean2 };
|