@libtmux/workspace-cli 0.1.0-alpha.11 → 0.1.0-alpha.13
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 +86 -18
- package/THIRD-PARTY-NOTICES.md +6 -6
- package/assets/logo.png +0 -0
- package/assets/logo.svg +2 -0
- package/dist/{app-w7cbtf0n.js → app-hhtza52q.js} +17 -8
- package/dist/{completions-2a9fqwq3.js → completions-n0m971c2.js} +1 -1
- package/dist/{extensions-8v6mfszj.js → extensions-zx6s05v3.js} +15 -8
- package/dist/{index-0j386v40.js → index-vh2kh7ms.js} +113 -112
- package/dist/{main-c8atq2pj.js → main-04s13z6x.js} +1 -1
- package/dist/{main-bfnr2nkj.js → main-fv0q4s30.js} +9 -9
- package/dist/{main-gh3pafqb.js → main-gky86mgf.js} +2 -2
- package/dist/main-p4mbtvt8.js +5 -0
- package/dist/main-wxsb2mch.js +33 -0
- package/dist/main.js +2 -2
- package/dist/{progress-n08zapg2.js → progress-bf8sfdrg.js} +130 -157
- package/dist/{reference-ebfxh6yp.js → reference-3kbd1xpz.js} +2 -2
- package/dist/{tmux-wa2zn8z1.js → tmux-2bj9awev.js} +25 -13
- package/package.json +8 -8
- package/dist/main-1de529jm.js +0 -37
|
@@ -2044,7 +2044,7 @@ var program = new Command;
|
|
|
2044
2044
|
// package.json
|
|
2045
2045
|
var package_default = {
|
|
2046
2046
|
name: "@libtmux/workspace-cli",
|
|
2047
|
-
version: "0.1.0-alpha.
|
|
2047
|
+
version: "0.1.0-alpha.13",
|
|
2048
2048
|
description: "A tmuxp-compatible workspace manager for Node and Bun.",
|
|
2049
2049
|
license: "MIT",
|
|
2050
2050
|
repository: {
|
|
@@ -2056,6 +2056,7 @@ var package_default = {
|
|
|
2056
2056
|
"tmux-workspace": "./dist/main.js"
|
|
2057
2057
|
},
|
|
2058
2058
|
files: [
|
|
2059
|
+
"assets",
|
|
2059
2060
|
"dist",
|
|
2060
2061
|
"docs",
|
|
2061
2062
|
"THIRD-PARTY-NOTICES.md"
|
|
@@ -2075,16 +2076,15 @@ var package_default = {
|
|
|
2075
2076
|
"test:package": "bun run build && bun scripts/check-install.ts --package-only",
|
|
2076
2077
|
"test:install": "bun run build && bun scripts/check-install.ts"
|
|
2077
2078
|
},
|
|
2079
|
+
dependencies: {
|
|
2080
|
+
libtmux: "0.1.0-alpha.13"
|
|
2081
|
+
},
|
|
2078
2082
|
devDependencies: {
|
|
2079
2083
|
"cli-truncate": "6.1.1",
|
|
2080
2084
|
commander: "15.0.0",
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
yaml: "2.9.0"
|
|
2085
|
-
},
|
|
2086
|
-
peerDependencies: {
|
|
2087
|
-
libtmux: "0.1.0-alpha.11"
|
|
2085
|
+
oxfmt: "0.73.0",
|
|
2086
|
+
"string-width": "8.3.0",
|
|
2087
|
+
yaml: "2.9.1"
|
|
2088
2088
|
},
|
|
2089
2089
|
engines: {
|
|
2090
2090
|
bun: ">=1.3.14",
|
|
@@ -2204,7 +2204,7 @@ var grammar_default = [
|
|
|
2204
2204
|
nargs: 0,
|
|
2205
2205
|
choices: null,
|
|
2206
2206
|
const: 88,
|
|
2207
|
-
help: "legacy 88-color mode; rejected because tmux
|
|
2207
|
+
help: "legacy 88-color mode; rejected because tmux does not implement it.",
|
|
2208
2208
|
flags: ["-8"]
|
|
2209
2209
|
},
|
|
2210
2210
|
{
|
|
@@ -230,7 +230,7 @@ async function readDocument(path) {
|
|
|
230
230
|
const extension = extname(path).toLowerCase();
|
|
231
231
|
if (!extensions.includes(extension))
|
|
232
232
|
throw new Error(`Unsupported workspace extension: ${extension}`);
|
|
233
|
-
const value = extension === ".json" ? JSON.parse(source) : (await import("./index-
|
|
233
|
+
const value = extension === ".json" ? JSON.parse(source) : (await import("./index-vh2kh7ms.js")).parse(source, { merge: true, maxAliasCount: 100 });
|
|
234
234
|
jsonData(value);
|
|
235
235
|
return mapping(value);
|
|
236
236
|
}
|
|
@@ -240,7 +240,7 @@ async function saveDocument(document, path, format, force, signal) {
|
|
|
240
240
|
if (!["json", "yaml"].includes(format))
|
|
241
241
|
throw new Error(`Unsupported workspace format: ${format}`);
|
|
242
242
|
const contents = format === "json" ? JSON.stringify(document, null, 2) + `
|
|
243
|
-
` : stringifyYaml(document, await import("./index-
|
|
243
|
+
` : stringifyYaml(document, await import("./index-vh2kh7ms.js"));
|
|
244
244
|
signal?.throwIfAborted();
|
|
245
245
|
const temporary = join(dirname(path), `.${basename(path)}.${randomUUID()}.tmp`);
|
|
246
246
|
try {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
processRun
|
|
3
|
+
} from "./main-04s13z6x.js";
|
|
4
|
+
import {
|
|
5
|
+
CliError
|
|
6
|
+
} from "./main-gky86mgf.js";
|
|
7
|
+
|
|
8
|
+
// src/supported.ts
|
|
9
|
+
import { assertSupportedTmux, TmuxCommandError } from "libtmux";
|
|
10
|
+
function noDaemon(error) {
|
|
11
|
+
return error instanceof TmuxCommandError && error.exitCode === 1 && error.stderr.length === 1 && /^(?:no server running on .+|error connecting to .+ \((?:No such file or directory|Connection refused)\))$/u.test(error.stderr[0]);
|
|
12
|
+
}
|
|
13
|
+
async function requireSupportedTmux(server, context) {
|
|
14
|
+
const { signal } = context;
|
|
15
|
+
try {
|
|
16
|
+
await server.cmd("list-sessions", [], signal ? { signal } : {});
|
|
17
|
+
return;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (!noDaemon(error))
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
const probe = await processRun([server.tmuxBin, "-V"], {
|
|
23
|
+
cwd: context.cwd,
|
|
24
|
+
env: context.env,
|
|
25
|
+
...signal ? { signal } : {}
|
|
26
|
+
});
|
|
27
|
+
const words = probe.stdout.trim().split(/\s+/u);
|
|
28
|
+
if (probe.code !== 0 || words.length !== 2)
|
|
29
|
+
throw new CliError("tmux_failed", `cannot establish the version of ${server.tmuxBin}`, 1);
|
|
30
|
+
assertSupportedTmux(words[1]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { requireSupportedTmux };
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
__require
|
|
4
|
-
} from "./main-
|
|
4
|
+
} from "./main-p4mbtvt8.js";
|
|
5
5
|
|
|
6
6
|
// src/main.ts
|
|
7
7
|
if (process.env.NO_COLOR)
|
|
@@ -21,7 +21,7 @@ for (const stream of [process.stdout, process.stderr])
|
|
|
21
21
|
} else
|
|
22
22
|
throw error;
|
|
23
23
|
});
|
|
24
|
-
var { run } = await import("./app-
|
|
24
|
+
var { run } = await import("./app-hhtza52q.js");
|
|
25
25
|
var exitCode = await run(process.argv.slice(2), {
|
|
26
26
|
cwd: process.cwd(),
|
|
27
27
|
env: process.env,
|
|
@@ -4,22 +4,8 @@ import {
|
|
|
4
4
|
scalarText,
|
|
5
5
|
styled,
|
|
6
6
|
write
|
|
7
|
-
} from "./main-
|
|
8
|
-
import
|
|
9
|
-
__commonJS,
|
|
10
|
-
__toESM
|
|
11
|
-
} from "./main-1de529jm.js";
|
|
12
|
-
|
|
13
|
-
// ../../node_modules/.bun/ansi-regex@5.0.1/node_modules/ansi-regex/index.js
|
|
14
|
-
var require_ansi_regex = __commonJS(function(exports, module) {
|
|
15
|
-
module.exports = ({ onlyFirst = false } = {}) => {
|
|
16
|
-
const pattern = [
|
|
17
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
18
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
19
|
-
].join("|");
|
|
20
|
-
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
21
|
-
};
|
|
22
|
-
});
|
|
7
|
+
} from "./main-gky86mgf.js";
|
|
8
|
+
import"./main-p4mbtvt8.js";
|
|
23
9
|
|
|
24
10
|
// ../../node_modules/.bun/ansi-styles@6.2.3/node_modules/ansi-styles/index.js
|
|
25
11
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -198,7 +184,7 @@ function assembleStyles() {
|
|
|
198
184
|
var ansiStyles = assembleStyles();
|
|
199
185
|
var ansi_styles_default = ansiStyles;
|
|
200
186
|
|
|
201
|
-
// ../../node_modules/.bun/get-east-asian-width@1.
|
|
187
|
+
// ../../node_modules/.bun/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup-data.js
|
|
202
188
|
var ambiguousMinimalCodePoint = 161;
|
|
203
189
|
var ambiguousMaximumCodePoint = 1114109;
|
|
204
190
|
var ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
@@ -207,9 +193,9 @@ var fullwidthMaximumCodePoint = 65510;
|
|
|
207
193
|
var fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
208
194
|
var wideMinimalCodePoint = 4352;
|
|
209
195
|
var wideMaximumCodePoint = 262141;
|
|
210
|
-
var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208,
|
|
196
|
+
var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101594, 101631, 101664, 101760, 101874, 101888, 102801, 102816, 102866, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110888, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110952, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127406, 127406, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128729, 128732, 128735, 128747, 128748, 128756, 128764, 128986, 128986, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129734, 129736, 129736, 129740, 129757, 129759, 129771, 129775, 129786, 131072, 196605, 196608, 262141];
|
|
211
197
|
|
|
212
|
-
// ../../node_modules/.bun/get-east-asian-width@1.
|
|
198
|
+
// ../../node_modules/.bun/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/utilities.js
|
|
213
199
|
var isInRange = (ranges, codePoint) => {
|
|
214
200
|
let low = 0;
|
|
215
201
|
let high = Math.floor(ranges.length / 2) - 1;
|
|
@@ -227,7 +213,7 @@ var isInRange = (ranges, codePoint) => {
|
|
|
227
213
|
return false;
|
|
228
214
|
};
|
|
229
215
|
|
|
230
|
-
// ../../node_modules/.bun/get-east-asian-width@1.
|
|
216
|
+
// ../../node_modules/.bun/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup.js
|
|
231
217
|
var commonCjkCodePoint = 19968;
|
|
232
218
|
var [wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
|
|
233
219
|
function findWideFastPathRange(ranges) {
|
|
@@ -252,7 +238,7 @@ var isAmbiguous = (codePoint) => {
|
|
|
252
238
|
}
|
|
253
239
|
return isInRange(ambiguousRanges, codePoint);
|
|
254
240
|
};
|
|
255
|
-
var
|
|
241
|
+
var isFullwidth = (codePoint) => {
|
|
256
242
|
if (codePoint < fullwidthMinimalCodePoint || codePoint > fullwidthMaximumCodePoint) {
|
|
257
243
|
return false;
|
|
258
244
|
}
|
|
@@ -268,7 +254,7 @@ var isWide = (codePoint) => {
|
|
|
268
254
|
return isInRange(wideRanges, codePoint);
|
|
269
255
|
};
|
|
270
256
|
|
|
271
|
-
// ../../node_modules/.bun/get-east-asian-width@1.
|
|
257
|
+
// ../../node_modules/.bun/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/index.js
|
|
272
258
|
function validate(codePoint) {
|
|
273
259
|
if (!Number.isSafeInteger(codePoint)) {
|
|
274
260
|
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
@@ -276,7 +262,7 @@ function validate(codePoint) {
|
|
|
276
262
|
}
|
|
277
263
|
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
278
264
|
validate(codePoint);
|
|
279
|
-
if (
|
|
265
|
+
if (isFullwidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
280
266
|
return 2;
|
|
281
267
|
}
|
|
282
268
|
return 1;
|
|
@@ -287,10 +273,10 @@ function isFullwidthCodePoint(codePoint) {
|
|
|
287
273
|
if (!Number.isInteger(codePoint)) {
|
|
288
274
|
return false;
|
|
289
275
|
}
|
|
290
|
-
return
|
|
276
|
+
return isFullwidth(codePoint) || isWide(codePoint);
|
|
291
277
|
}
|
|
292
278
|
|
|
293
|
-
// ../../node_modules/.bun/slice-ansi@9.0.
|
|
279
|
+
// ../../node_modules/.bun/slice-ansi@9.0.1/node_modules/slice-ansi/tokenize-ansi.js
|
|
294
280
|
var ESCAPE_CODE_POINT = 27;
|
|
295
281
|
var C1_DCS_CODE_POINT = 144;
|
|
296
282
|
var C1_SOS_CODE_POINT = 152;
|
|
@@ -895,7 +881,7 @@ function tokenizeAnsi(string, { endCharacter = Number.POSITIVE_INFINITY } = {})
|
|
|
895
881
|
return tokens;
|
|
896
882
|
}
|
|
897
883
|
|
|
898
|
-
// ../../node_modules/.bun/slice-ansi@9.0.
|
|
884
|
+
// ../../node_modules/.bun/slice-ansi@9.0.1/node_modules/slice-ansi/index.js
|
|
899
885
|
function applySgrFragments(activeStyles, fragments) {
|
|
900
886
|
for (const fragment of fragments) {
|
|
901
887
|
switch (fragment.type) {
|
|
@@ -946,82 +932,88 @@ function shouldIncludeSgrAfterEnd(token, activeStyles) {
|
|
|
946
932
|
function hasSgrStartFragment(token) {
|
|
947
933
|
return token.fragments.some((fragment) => fragment.type === "start");
|
|
948
934
|
}
|
|
949
|
-
function discardPendingHyperlink(
|
|
950
|
-
if (
|
|
951
|
-
const openCodeLength =
|
|
952
|
-
|
|
953
|
-
if (
|
|
954
|
-
|
|
935
|
+
function discardPendingHyperlink(state) {
|
|
936
|
+
if (state.activeHyperlink && !state.activeHyperlinkHasVisibleText && state.activeHyperlinkOutputIndex !== undefined) {
|
|
937
|
+
const openCodeLength = state.activeHyperlink.code.length;
|
|
938
|
+
state.returnValue = state.returnValue.slice(0, state.activeHyperlinkOutputIndex) + state.returnValue.slice(state.activeHyperlinkOutputIndex + openCodeLength);
|
|
939
|
+
if (state.pendingSgrOutputIndex !== undefined && state.pendingSgrOutputIndex > state.activeHyperlinkOutputIndex) {
|
|
940
|
+
state.pendingSgrOutputIndex -= openCodeLength;
|
|
955
941
|
}
|
|
956
942
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
943
|
+
state.activeHyperlink = undefined;
|
|
944
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
945
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
946
|
+
}
|
|
947
|
+
function settleActiveHyperlink(state) {
|
|
948
|
+
if (state.activeHyperlinkHasVisibleText) {
|
|
949
|
+
state.returnValue += closeHyperlink(state.activeHyperlink);
|
|
950
|
+
} else {
|
|
951
|
+
discardPendingHyperlink(state);
|
|
952
|
+
}
|
|
960
953
|
}
|
|
961
|
-
function applySgrToken(
|
|
962
|
-
if (
|
|
963
|
-
return
|
|
954
|
+
function applySgrToken(state) {
|
|
955
|
+
if (state.isPastEnd && !shouldIncludeSgrAfterEnd(state.token, state.activeStyles)) {
|
|
956
|
+
return;
|
|
964
957
|
}
|
|
965
|
-
if (
|
|
966
|
-
|
|
967
|
-
|
|
958
|
+
if (state.include && hasSgrStartFragment(state.token) && state.pendingSgrOutputIndex === undefined) {
|
|
959
|
+
state.pendingSgrOutputIndex = state.returnValue.length;
|
|
960
|
+
state.pendingSgrActiveStyles = new Map(state.activeStyles);
|
|
968
961
|
}
|
|
969
|
-
|
|
970
|
-
if (
|
|
971
|
-
|
|
962
|
+
state.activeStyles = applySgrFragments(state.activeStyles, state.token.fragments);
|
|
963
|
+
if (state.include) {
|
|
964
|
+
state.returnValue += state.token.code;
|
|
972
965
|
}
|
|
973
|
-
return parameters;
|
|
974
966
|
}
|
|
975
|
-
function applyHyperlinkToken(
|
|
976
|
-
if (
|
|
977
|
-
return
|
|
978
|
-
}
|
|
979
|
-
if (
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
967
|
+
function applyHyperlinkToken(state) {
|
|
968
|
+
if (state.isPastEnd && (state.token.action !== "close" || !state.activeHyperlink)) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
if (state.token.action === "open") {
|
|
972
|
+
if (state.activeHyperlink) {
|
|
973
|
+
settleActiveHyperlink(state);
|
|
974
|
+
}
|
|
975
|
+
state.activeHyperlink = state.token;
|
|
976
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
977
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
978
|
+
if (state.include) {
|
|
979
|
+
state.activeHyperlinkOutputIndex = state.returnValue.length;
|
|
980
|
+
}
|
|
981
|
+
} else if (state.token.action === "close") {
|
|
982
|
+
if (state.include && state.activeHyperlink && !state.activeHyperlinkHasVisibleText) {
|
|
983
|
+
discardPendingHyperlink(state);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
state.activeHyperlink = undefined;
|
|
987
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
988
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
989
|
+
}
|
|
990
|
+
if (state.include) {
|
|
991
|
+
state.returnValue += state.token.code;
|
|
992
|
+
}
|
|
999
993
|
}
|
|
1000
|
-
function applyControlToken(
|
|
1001
|
-
if (!
|
|
1002
|
-
|
|
994
|
+
function applyControlToken(state) {
|
|
995
|
+
if (!state.isPastEnd && state.include) {
|
|
996
|
+
state.returnValue += state.token.code;
|
|
1003
997
|
}
|
|
1004
|
-
return parameters;
|
|
1005
998
|
}
|
|
1006
|
-
function applyCharacterToken(
|
|
1007
|
-
if (!
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1012
|
-
|
|
999
|
+
function applyCharacterToken(state) {
|
|
1000
|
+
if (!state.include && state.position >= state.start && !state.token.isGraphemeContinuation) {
|
|
1001
|
+
state.include = true;
|
|
1002
|
+
state.returnValue = [...state.activeStyles.values()].join("");
|
|
1003
|
+
if (state.activeHyperlink) {
|
|
1004
|
+
state.activeHyperlinkOutputIndex = state.returnValue.length;
|
|
1005
|
+
state.returnValue += state.activeHyperlink.code;
|
|
1013
1006
|
}
|
|
1014
1007
|
}
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
if (
|
|
1020
|
-
|
|
1008
|
+
if (state.include) {
|
|
1009
|
+
state.returnValue += state.token.value;
|
|
1010
|
+
state.pendingSgrOutputIndex = undefined;
|
|
1011
|
+
state.pendingSgrActiveStyles = undefined;
|
|
1012
|
+
if (state.activeHyperlink) {
|
|
1013
|
+
state.activeHyperlinkHasVisibleText = true;
|
|
1021
1014
|
}
|
|
1022
1015
|
}
|
|
1023
|
-
|
|
1024
|
-
return parameters;
|
|
1016
|
+
state.position += state.token.visibleWidth;
|
|
1025
1017
|
}
|
|
1026
1018
|
var tokenHandlers = {
|
|
1027
1019
|
sgr: applySgrToken,
|
|
@@ -1029,12 +1021,8 @@ var tokenHandlers = {
|
|
|
1029
1021
|
control: applyControlToken,
|
|
1030
1022
|
character: applyCharacterToken
|
|
1031
1023
|
};
|
|
1032
|
-
function applyToken(
|
|
1033
|
-
|
|
1034
|
-
if (!tokenHandler) {
|
|
1035
|
-
return parameters;
|
|
1036
|
-
}
|
|
1037
|
-
return tokenHandler(parameters);
|
|
1024
|
+
function applyToken(state) {
|
|
1025
|
+
tokenHandlers[state.token.type]?.(state);
|
|
1038
1026
|
}
|
|
1039
1027
|
function createHasContinuationAheadMap(tokens) {
|
|
1040
1028
|
const hasContinuationAhead = Array.from({ length: tokens.length }, () => false);
|
|
@@ -1060,74 +1048,62 @@ function isPastEndBoundary(token, position, end) {
|
|
|
1060
1048
|
function sliceAnsi(string, start, end) {
|
|
1061
1049
|
const tokens = tokenizeAnsi(string, { endCharacter: end });
|
|
1062
1050
|
const hasContinuationAhead = createHasContinuationAheadMap(tokens);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1051
|
+
const state = {
|
|
1052
|
+
start,
|
|
1053
|
+
token: undefined,
|
|
1054
|
+
isPastEnd: false,
|
|
1055
|
+
activeStyles: new Map,
|
|
1056
|
+
activeHyperlink: undefined,
|
|
1057
|
+
activeHyperlinkHasVisibleText: false,
|
|
1058
|
+
activeHyperlinkOutputIndex: undefined,
|
|
1059
|
+
pendingSgrOutputIndex: undefined,
|
|
1060
|
+
pendingSgrActiveStyles: undefined,
|
|
1061
|
+
position: 0,
|
|
1062
|
+
returnValue: "",
|
|
1063
|
+
include: false
|
|
1064
|
+
};
|
|
1072
1065
|
for (const [tokenIndex, token] of tokens.entries()) {
|
|
1073
|
-
let isPastEnd = isPastEndBoundary(token, position, end);
|
|
1066
|
+
let isPastEnd = isPastEndBoundary(token, state.position, end);
|
|
1074
1067
|
if (isPastEnd && token.type !== "character" && hasContinuationAhead[tokenIndex]) {
|
|
1075
1068
|
isPastEnd = false;
|
|
1076
1069
|
}
|
|
1077
1070
|
if (isPastEnd && token.type === "character" && !token.isGraphemeContinuation) {
|
|
1078
|
-
if (activeHyperlink && !activeHyperlinkHasVisibleText) {
|
|
1079
|
-
|
|
1080
|
-
activeHyperlink,
|
|
1081
|
-
activeHyperlinkHasVisibleText,
|
|
1082
|
-
activeHyperlinkOutputIndex,
|
|
1083
|
-
pendingSgrOutputIndex,
|
|
1084
|
-
returnValue
|
|
1085
|
-
};
|
|
1086
|
-
discardPendingHyperlink(hyperlinkState);
|
|
1087
|
-
({
|
|
1088
|
-
activeHyperlink,
|
|
1089
|
-
activeHyperlinkHasVisibleText,
|
|
1090
|
-
activeHyperlinkOutputIndex,
|
|
1091
|
-
pendingSgrOutputIndex,
|
|
1092
|
-
returnValue
|
|
1093
|
-
} = hyperlinkState);
|
|
1071
|
+
if (state.activeHyperlink && !state.activeHyperlinkHasVisibleText) {
|
|
1072
|
+
discardPendingHyperlink(state);
|
|
1094
1073
|
}
|
|
1095
|
-
if (pendingSgrOutputIndex !== undefined) {
|
|
1096
|
-
returnValue = returnValue.slice(0, pendingSgrOutputIndex);
|
|
1097
|
-
activeStyles = pendingSgrActiveStyles;
|
|
1098
|
-
pendingSgrOutputIndex = undefined;
|
|
1099
|
-
pendingSgrActiveStyles = undefined;
|
|
1074
|
+
if (state.pendingSgrOutputIndex !== undefined) {
|
|
1075
|
+
state.returnValue = state.returnValue.slice(0, state.pendingSgrOutputIndex);
|
|
1076
|
+
state.activeStyles = state.pendingSgrActiveStyles;
|
|
1077
|
+
state.pendingSgrOutputIndex = undefined;
|
|
1078
|
+
state.pendingSgrActiveStyles = undefined;
|
|
1100
1079
|
}
|
|
1101
1080
|
break;
|
|
1102
1081
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
activeHyperlink,
|
|
1109
|
-
activeHyperlinkHasVisibleText,
|
|
1110
|
-
activeHyperlinkOutputIndex,
|
|
1111
|
-
pendingSgrOutputIndex,
|
|
1112
|
-
pendingSgrActiveStyles,
|
|
1113
|
-
position,
|
|
1114
|
-
returnValue,
|
|
1115
|
-
include
|
|
1116
|
-
}));
|
|
1117
|
-
}
|
|
1118
|
-
if (!include) {
|
|
1082
|
+
state.token = token;
|
|
1083
|
+
state.isPastEnd = isPastEnd;
|
|
1084
|
+
applyToken(state);
|
|
1085
|
+
}
|
|
1086
|
+
if (!state.include) {
|
|
1119
1087
|
return "";
|
|
1120
1088
|
}
|
|
1121
|
-
if (activeHyperlink) {
|
|
1122
|
-
|
|
1089
|
+
if (state.activeHyperlink) {
|
|
1090
|
+
settleActiveHyperlink(state);
|
|
1123
1091
|
}
|
|
1124
|
-
returnValue += undoAnsiCodes(activeStyles);
|
|
1125
|
-
return returnValue;
|
|
1092
|
+
state.returnValue += undoAnsiCodes(state.activeStyles);
|
|
1093
|
+
return state.returnValue;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// ../../node_modules/.bun/ansi-regex@6.4.0/node_modules/ansi-regex/index.js
|
|
1097
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1098
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1099
|
+
const osc = `(?:(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C\\u009D]*${ST})`;
|
|
1100
|
+
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
1101
|
+
const pattern = `${osc}|${csi}`;
|
|
1102
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
1126
1103
|
}
|
|
1127
1104
|
|
|
1128
1105
|
// ../../node_modules/.bun/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
|
|
1129
|
-
var
|
|
1130
|
-
var regex = import_ansi_regex.default();
|
|
1106
|
+
var regex = ansiRegex();
|
|
1131
1107
|
function stripAnsi(string) {
|
|
1132
1108
|
if (typeof string !== "string") {
|
|
1133
1109
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
@@ -1138,10 +1114,9 @@ function stripAnsi(string) {
|
|
|
1138
1114
|
return string.replace(regex, "");
|
|
1139
1115
|
}
|
|
1140
1116
|
|
|
1141
|
-
// ../../node_modules/.bun/string-width@8.
|
|
1117
|
+
// ../../node_modules/.bun/string-width@8.3.0/node_modules/string-width/index.js
|
|
1142
1118
|
var segmenter = new Intl.Segmenter;
|
|
1143
|
-
var
|
|
1144
|
-
var leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v;
|
|
1119
|
+
var visibleCharacterRegex = /[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v;
|
|
1145
1120
|
var spacingMarkRegex = /\p{Spacing_Mark}/v;
|
|
1146
1121
|
var rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
1147
1122
|
var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
|
|
@@ -1160,10 +1135,8 @@ function isDoubleWidthNonRgiEmojiSequence(segment) {
|
|
|
1160
1135
|
return false;
|
|
1161
1136
|
}
|
|
1162
1137
|
function baseVisible(segment) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
function isZeroWidthCluster(segment) {
|
|
1166
|
-
return zeroWidthClusterRegex.test(segment);
|
|
1138
|
+
const index = segment.search(visibleCharacterRegex);
|
|
1139
|
+
return index === -1 ? undefined : segment.slice(index);
|
|
1167
1140
|
}
|
|
1168
1141
|
function isHangulLeadingJamo(codePoint) {
|
|
1169
1142
|
return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
|
|
@@ -1180,7 +1153,7 @@ function isHangulJamo(codePoint) {
|
|
|
1180
1153
|
function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
|
|
1181
1154
|
const codePoints = [];
|
|
1182
1155
|
for (const character of visibleSegment) {
|
|
1183
|
-
if (
|
|
1156
|
+
if (!visibleCharacterRegex.test(character)) {
|
|
1184
1157
|
continue;
|
|
1185
1158
|
}
|
|
1186
1159
|
codePoints.push(character.codePointAt(0));
|
|
@@ -1244,14 +1217,14 @@ function stringWidth(input, options = {}) {
|
|
|
1244
1217
|
let width = 0;
|
|
1245
1218
|
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
1246
1219
|
for (const { segment } of segmenter.segment(string)) {
|
|
1247
|
-
|
|
1220
|
+
const visibleSegment = baseVisible(segment);
|
|
1221
|
+
if (visibleSegment === undefined) {
|
|
1248
1222
|
continue;
|
|
1249
1223
|
}
|
|
1250
1224
|
if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
|
|
1251
1225
|
width += 2;
|
|
1252
1226
|
continue;
|
|
1253
1227
|
}
|
|
1254
|
-
const visibleSegment = baseVisible(segment);
|
|
1255
1228
|
const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
|
|
1256
1229
|
if (hangulWidth !== undefined) {
|
|
1257
1230
|
width += hangulWidth;
|