@jordond/kit 0.0.0-stage → 0.1.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/bin/kit +39 -0
- package/dist/_verb-espppzez.js +115 -0
- package/dist/android-g73naxgg.js +31 -0
- package/dist/build-88hxf0kc.js +42 -0
- package/dist/check-7mndz8g8.js +54 -0
- package/dist/check-ngc4kzmj.js +33 -0
- package/dist/cleanup-hrcvxmh2.js +18 -0
- package/dist/cli/builtins.d.ts +13 -0
- package/dist/cli/command.d.ts +86 -0
- package/dist/cli/discover.d.ts +10 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/plugin.d.ts +7 -0
- package/dist/cli/usage.d.ts +3 -0
- package/dist/cli-07t28k94.js +30 -0
- package/dist/cli-12dww95e.js +195 -0
- package/dist/cli-5d61x8vg.js +675 -0
- package/dist/cli-5wasc5mr.js +76 -0
- package/dist/cli-6dxp4v3m.js +73 -0
- package/dist/cli-7wvrehng.js +23 -0
- package/dist/cli-bam7dqfd.js +33 -0
- package/dist/cli-fqfan92n.js +135 -0
- package/dist/cli-fqxtcj42.js +75 -0
- package/dist/cli-h974q2wr.js +2019 -0
- package/dist/cli-m53122z6.js +221 -0
- package/dist/cli-qhs8ww91.js +51 -0
- package/dist/cli-qq1ktr8q.js +234 -0
- package/dist/cli-rds33bnp.js +101 -0
- package/dist/cli-re3ntm60.js +48 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +35 -0
- package/dist/cloudflare-n5c46k6x.js +43 -0
- package/dist/command-gazq4bmt.js +19 -0
- package/dist/commands/_verb.d.ts +15 -0
- package/dist/commands/build.d.ts +11 -0
- package/dist/commands/check.d.ts +8 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/db/create.d.ts +7 -0
- package/dist/commands/db/exec.d.ts +16 -0
- package/dist/commands/db/list.d.ts +11 -0
- package/dist/commands/db/migrate.d.ts +11 -0
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deps.d.ts +72 -0
- package/dist/commands/dev.d.ts +8 -0
- package/dist/commands/doctor.d.ts +56 -0
- package/dist/commands/env/check.d.ts +7 -0
- package/dist/commands/env/init.d.ts +2 -0
- package/dist/commands/env/push.d.ts +12 -0
- package/dist/commands/env/sync.d.ts +2 -0
- package/dist/commands/format.d.ts +11 -0
- package/dist/commands/gradle.d.ts +2 -0
- package/dist/commands/init.d.ts +53 -0
- package/dist/commands/lint.d.ts +12 -0
- package/dist/commands/release/android.d.ts +13 -0
- package/dist/commands/release/ios.d.ts +13 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/typecheck.d.ts +2 -0
- package/dist/commands/wrangler.d.ts +4 -0
- package/dist/commands/xcode.d.ts +8 -0
- package/dist/config/load.d.ts +6 -0
- package/dist/config/schema.d.ts +135 -0
- package/dist/config-ey5yrrfn.js +22 -0
- package/dist/create-7s8h3dja.js +38 -0
- package/dist/deploy-8mg1zhpb.js +102 -0
- package/dist/deps-97dq4mg8.js +334 -0
- package/dist/dev-yc9xmntj.js +62 -0
- package/dist/doctor-0wzmfyyh.js +324 -0
- package/dist/errors-1fjbr7ee.js +10 -0
- package/dist/exec-1k3sqwxz.js +53 -0
- package/dist/format-mnqfak22.js +39 -0
- package/dist/git-52v5rk51.js +80 -0
- package/dist/gradle-gtkf3geq.js +39 -0
- package/dist/index-cx34x4np.js +874 -0
- package/dist/index-erv82p4z.js +1528 -0
- package/dist/index-jqfz6hfy.js +2659 -0
- package/dist/index-mm4ht8yh.js +9 -0
- package/dist/index-s3ehw02w.js +1610 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +50 -0
- package/dist/init-0402av4m.js +78 -0
- package/dist/init-dk5sym9w.js +76 -0
- package/dist/init-qr7y55ea.js +185 -0
- package/dist/ios-msg4bk15.js +31 -0
- package/dist/lib/cleanup.d.ts +21 -0
- package/dist/lib/cloudflare.d.ts +96 -0
- package/dist/lib/env/init.d.ts +22 -0
- package/dist/lib/env/load.d.ts +12 -0
- package/dist/lib/env/push.d.ts +54 -0
- package/dist/lib/env/render.d.ts +49 -0
- package/dist/lib/env/schema.d.ts +49 -0
- package/dist/lib/errors.d.ts +14 -0
- package/dist/lib/git.d.ts +36 -0
- package/dist/lib/log.d.ts +11 -0
- package/dist/lib/pm.d.ts +8 -0
- package/dist/lib/proc.d.ts +73 -0
- package/dist/lib/prompt.d.ts +32 -0
- package/dist/lib/secrets.d.ts +32 -0
- package/dist/lib/steps.d.ts +38 -0
- package/dist/lib/targets.d.ts +46 -0
- package/dist/lib/toml.d.ts +15 -0
- package/dist/lint-280dpn4y.js +39 -0
- package/dist/list-jdc3dqk0.js +34 -0
- package/dist/load-5qzs1c6b.js +137 -0
- package/dist/log-hhspqwjw.js +11 -0
- package/dist/main-ywtsjxev.js +2052 -0
- package/dist/migrate-emk758k1.js +35 -0
- package/dist/picocolors-0dxagz5d.js +6 -0
- package/dist/pm-5q5vz6w3.js +14 -0
- package/dist/proc-jv4bcyyx.js +33 -0
- package/dist/prompt-v510j04z.js +93 -0
- package/dist/push-4z70h3d8.js +117 -0
- package/dist/push-xzqw218t.js +117 -0
- package/dist/render-488tjnsq.js +22 -0
- package/dist/sync-wc4jpmkj.js +53 -0
- package/dist/targets-hbwxv97d.js +22 -0
- package/dist/test-198w46m4.js +26 -0
- package/dist/toml-zbhtxjh1.js +1062 -0
- package/dist/typecheck-e86e6yg1.js +24 -0
- package/dist/wrangler-0ctx1p3w.js +66 -0
- package/dist/xcode-g44qh2rc.js +60 -0
- package/fastlane/Fastfile +413 -0
- package/fastlane/Gemfile +21 -0
- package/fastlane/Gemfile.lock +275 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar +0 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module +64 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom +12 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar +0 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module +64 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom +12 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom +15 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom +15 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha512 +1 -0
- package/package.json +58 -4
- package/templates/lefthook.yml +6 -0
- package/templates/mise.toml +6 -0
- package/README.md +0 -3
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
stringWidth
|
|
4
|
+
} from "./cli-qq1ktr8q.js";
|
|
5
|
+
import"./cli-re3ntm60.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/cli-truncate/index.js
|
|
8
|
+
import { stripVTControlCharacters } from "util";
|
|
9
|
+
|
|
10
|
+
// node_modules/slice-ansi/node_modules/ansi-styles/index.js
|
|
11
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
12
|
+
var ANSI_UNDERLINE_OFFSET = 20;
|
|
13
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
14
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
15
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
16
|
+
var wrapUnderlineAnsi = (code) => `\x1B[58;5;${code < 90 ? code - 30 : code - 90 + 8}m`;
|
|
17
|
+
var blackBright = [90, 39];
|
|
18
|
+
var bgBlackBright = [100, 49];
|
|
19
|
+
var styles = {
|
|
20
|
+
modifier: {
|
|
21
|
+
reset: [0, 0],
|
|
22
|
+
bold: [1, 22],
|
|
23
|
+
dim: [2, 22],
|
|
24
|
+
italic: [3, 23],
|
|
25
|
+
underline: [4, 24],
|
|
26
|
+
underlineDouble: ["4:2", 24],
|
|
27
|
+
underlineCurly: ["4:3", 24],
|
|
28
|
+
underlineDotted: ["4:4", 24],
|
|
29
|
+
underlineDashed: ["4:5", 24],
|
|
30
|
+
overline: [53, 55],
|
|
31
|
+
inverse: [7, 27],
|
|
32
|
+
hidden: [8, 28],
|
|
33
|
+
strikethrough: [9, 29]
|
|
34
|
+
},
|
|
35
|
+
color: {
|
|
36
|
+
black: [30, 39],
|
|
37
|
+
red: [31, 39],
|
|
38
|
+
green: [32, 39],
|
|
39
|
+
yellow: [33, 39],
|
|
40
|
+
blue: [34, 39],
|
|
41
|
+
magenta: [35, 39],
|
|
42
|
+
cyan: [36, 39],
|
|
43
|
+
white: [37, 39],
|
|
44
|
+
blackBright,
|
|
45
|
+
gray: blackBright,
|
|
46
|
+
grey: blackBright,
|
|
47
|
+
redBright: [91, 39],
|
|
48
|
+
greenBright: [92, 39],
|
|
49
|
+
yellowBright: [93, 39],
|
|
50
|
+
blueBright: [94, 39],
|
|
51
|
+
magentaBright: [95, 39],
|
|
52
|
+
cyanBright: [96, 39],
|
|
53
|
+
whiteBright: [97, 39]
|
|
54
|
+
},
|
|
55
|
+
bgColor: {
|
|
56
|
+
bgBlack: [40, 49],
|
|
57
|
+
bgRed: [41, 49],
|
|
58
|
+
bgGreen: [42, 49],
|
|
59
|
+
bgYellow: [43, 49],
|
|
60
|
+
bgBlue: [44, 49],
|
|
61
|
+
bgMagenta: [45, 49],
|
|
62
|
+
bgCyan: [46, 49],
|
|
63
|
+
bgWhite: [47, 49],
|
|
64
|
+
bgBlackBright,
|
|
65
|
+
bgGray: bgBlackBright,
|
|
66
|
+
bgGrey: bgBlackBright,
|
|
67
|
+
bgRedBright: [101, 49],
|
|
68
|
+
bgGreenBright: [102, 49],
|
|
69
|
+
bgYellowBright: [103, 49],
|
|
70
|
+
bgBlueBright: [104, 49],
|
|
71
|
+
bgMagentaBright: [105, 49],
|
|
72
|
+
bgCyanBright: [106, 49],
|
|
73
|
+
bgWhiteBright: [107, 49]
|
|
74
|
+
},
|
|
75
|
+
underlineColor: {
|
|
76
|
+
underlineBlack: ["58;5;0", 59],
|
|
77
|
+
underlineRed: ["58;5;1", 59],
|
|
78
|
+
underlineGreen: ["58;5;2", 59],
|
|
79
|
+
underlineYellow: ["58;5;3", 59],
|
|
80
|
+
underlineBlue: ["58;5;4", 59],
|
|
81
|
+
underlineMagenta: ["58;5;5", 59],
|
|
82
|
+
underlineCyan: ["58;5;6", 59],
|
|
83
|
+
underlineWhite: ["58;5;7", 59],
|
|
84
|
+
underlineBlackBright: ["58;5;8", 59],
|
|
85
|
+
underlineGray: ["58;5;8", 59],
|
|
86
|
+
underlineGrey: ["58;5;8", 59],
|
|
87
|
+
underlineRedBright: ["58;5;9", 59],
|
|
88
|
+
underlineGreenBright: ["58;5;10", 59],
|
|
89
|
+
underlineYellowBright: ["58;5;11", 59],
|
|
90
|
+
underlineBlueBright: ["58;5;12", 59],
|
|
91
|
+
underlineMagentaBright: ["58;5;13", 59],
|
|
92
|
+
underlineCyanBright: ["58;5;14", 59],
|
|
93
|
+
underlineWhiteBright: ["58;5;15", 59]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
97
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
98
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
99
|
+
var underlineColorNames = Object.keys(styles.underlineColor);
|
|
100
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
101
|
+
function assembleStyles() {
|
|
102
|
+
const codes = new Map;
|
|
103
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
104
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
105
|
+
styles[styleName] = {
|
|
106
|
+
open: `\x1B[${style[0]}m`,
|
|
107
|
+
close: `\x1B[${style[1]}m`
|
|
108
|
+
};
|
|
109
|
+
group[styleName] = styles[styleName];
|
|
110
|
+
codes.set(Number(String(style[0]).split(/[:;]/v, 1)[0]), style[1]);
|
|
111
|
+
}
|
|
112
|
+
Object.defineProperty(styles, groupName, {
|
|
113
|
+
value: group,
|
|
114
|
+
enumerable: false
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
Object.defineProperty(styles, "codes", {
|
|
118
|
+
value: codes,
|
|
119
|
+
enumerable: false
|
|
120
|
+
});
|
|
121
|
+
styles.color.close = "\x1B[39m";
|
|
122
|
+
styles.bgColor.close = "\x1B[49m";
|
|
123
|
+
styles.underlineColor.close = "\x1B[59m";
|
|
124
|
+
styles.color.ansi = wrapAnsi16();
|
|
125
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
126
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
127
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
128
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
129
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
130
|
+
styles.underlineColor.ansi = wrapUnderlineAnsi;
|
|
131
|
+
styles.underlineColor.ansi256 = wrapAnsi256(ANSI_UNDERLINE_OFFSET);
|
|
132
|
+
styles.underlineColor.ansi16m = wrapAnsi16m(ANSI_UNDERLINE_OFFSET);
|
|
133
|
+
Object.defineProperties(styles, {
|
|
134
|
+
rgbToAnsi256: {
|
|
135
|
+
value(red, green, blue) {
|
|
136
|
+
if (red === green && green === blue) {
|
|
137
|
+
if (red < 8) {
|
|
138
|
+
return 16;
|
|
139
|
+
}
|
|
140
|
+
if (red > 248) {
|
|
141
|
+
return 231;
|
|
142
|
+
}
|
|
143
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
144
|
+
}
|
|
145
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
146
|
+
},
|
|
147
|
+
enumerable: false
|
|
148
|
+
},
|
|
149
|
+
hexToRgb: {
|
|
150
|
+
value(hex) {
|
|
151
|
+
const matches = /[\da-f]{6}|[\da-f]{3}/iv.exec(hex.toString(16));
|
|
152
|
+
if (!matches) {
|
|
153
|
+
return [0, 0, 0];
|
|
154
|
+
}
|
|
155
|
+
let [colorString] = matches;
|
|
156
|
+
if (colorString.length === 3) {
|
|
157
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
158
|
+
}
|
|
159
|
+
const integer = Number.parseInt(colorString, 16);
|
|
160
|
+
return [
|
|
161
|
+
integer >> 16 & 255,
|
|
162
|
+
integer >> 8 & 255,
|
|
163
|
+
integer & 255
|
|
164
|
+
];
|
|
165
|
+
},
|
|
166
|
+
enumerable: false
|
|
167
|
+
},
|
|
168
|
+
hexToAnsi256: {
|
|
169
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
170
|
+
enumerable: false
|
|
171
|
+
},
|
|
172
|
+
ansi256ToAnsi: {
|
|
173
|
+
value(code) {
|
|
174
|
+
if (code < 8) {
|
|
175
|
+
return 30 + code;
|
|
176
|
+
}
|
|
177
|
+
if (code < 16) {
|
|
178
|
+
return 90 + (code - 8);
|
|
179
|
+
}
|
|
180
|
+
let red;
|
|
181
|
+
let green;
|
|
182
|
+
let blue;
|
|
183
|
+
if (code >= 232) {
|
|
184
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
185
|
+
green = red;
|
|
186
|
+
blue = red;
|
|
187
|
+
} else {
|
|
188
|
+
code -= 16;
|
|
189
|
+
const remainder = code % 36;
|
|
190
|
+
red = Math.floor(code / 36) / 5;
|
|
191
|
+
green = Math.floor(remainder / 6) / 5;
|
|
192
|
+
blue = remainder % 6 / 5;
|
|
193
|
+
}
|
|
194
|
+
const value = Math.max(red, green, blue) * 2;
|
|
195
|
+
if (value === 0) {
|
|
196
|
+
return 30;
|
|
197
|
+
}
|
|
198
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
199
|
+
if (value === 2) {
|
|
200
|
+
result += 60;
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
},
|
|
204
|
+
enumerable: false
|
|
205
|
+
},
|
|
206
|
+
rgbToAnsi: {
|
|
207
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
208
|
+
enumerable: false
|
|
209
|
+
},
|
|
210
|
+
hexToAnsi: {
|
|
211
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
212
|
+
enumerable: false
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return styles;
|
|
216
|
+
}
|
|
217
|
+
var ansiStyles = assembleStyles();
|
|
218
|
+
var ansi_styles_default = ansiStyles;
|
|
219
|
+
|
|
220
|
+
// node_modules/slice-ansi/tokenize-ansi.js
|
|
221
|
+
var ESCAPE_CODE_POINT = 27;
|
|
222
|
+
var C1_DCS_CODE_POINT = 144;
|
|
223
|
+
var C1_SOS_CODE_POINT = 152;
|
|
224
|
+
var C1_CSI_CODE_POINT = 155;
|
|
225
|
+
var C1_ST_CODE_POINT = 156;
|
|
226
|
+
var C1_OSC_CODE_POINT = 157;
|
|
227
|
+
var C1_PM_CODE_POINT = 158;
|
|
228
|
+
var C1_APC_CODE_POINT = 159;
|
|
229
|
+
var CONTROL_STRING_STARTS = new Set([
|
|
230
|
+
C1_DCS_CODE_POINT,
|
|
231
|
+
C1_SOS_CODE_POINT,
|
|
232
|
+
C1_OSC_CODE_POINT,
|
|
233
|
+
C1_PM_CODE_POINT,
|
|
234
|
+
C1_APC_CODE_POINT
|
|
235
|
+
]);
|
|
236
|
+
var ESCAPES = new Set([
|
|
237
|
+
ESCAPE_CODE_POINT,
|
|
238
|
+
C1_CSI_CODE_POINT,
|
|
239
|
+
C1_ST_CODE_POINT,
|
|
240
|
+
...CONTROL_STRING_STARTS
|
|
241
|
+
]);
|
|
242
|
+
var ESCAPE = "\x1B";
|
|
243
|
+
var ANSI_BELL = "\x07";
|
|
244
|
+
var ANSI_CSI = "[";
|
|
245
|
+
var ANSI_OSC = "]";
|
|
246
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
247
|
+
var ANSI_OSC_TERMINATOR = "\\";
|
|
248
|
+
var ANSI_STRING_TERMINATOR = `${ESCAPE}${ANSI_OSC_TERMINATOR}`;
|
|
249
|
+
var C1_OSC = "\x9D";
|
|
250
|
+
var C1_STRING_TERMINATOR = "\x9C";
|
|
251
|
+
var ANSI_HYPERLINK_ESC_PREFIX = `${ESCAPE}${ANSI_OSC}8;`;
|
|
252
|
+
var ANSI_HYPERLINK_C1_PREFIX = `${C1_OSC}8;`;
|
|
253
|
+
var CODE_POINT_CSI_PARAMETER_START = "0".codePointAt(0);
|
|
254
|
+
var CODE_POINT_CSI_PARAMETER_END = "?".codePointAt(0);
|
|
255
|
+
var CODE_POINT_CSI_INTERMEDIATE_START = " ".codePointAt(0);
|
|
256
|
+
var CODE_POINT_CSI_INTERMEDIATE_END = "/".codePointAt(0);
|
|
257
|
+
var CODE_POINT_CSI_FINAL_START = "@".codePointAt(0);
|
|
258
|
+
var CODE_POINT_CSI_FINAL_END = "~".codePointAt(0);
|
|
259
|
+
var SGR_RESET_CODE = 0;
|
|
260
|
+
var SGR_EXTENDED_COLOR_END_CODES = new Map([
|
|
261
|
+
[38, 39],
|
|
262
|
+
[48, 49],
|
|
263
|
+
[58, 59]
|
|
264
|
+
]);
|
|
265
|
+
var SGR_COLOR_LENGTHS = new Map([
|
|
266
|
+
[5, 3],
|
|
267
|
+
[2, 5]
|
|
268
|
+
]);
|
|
269
|
+
var GRAPHEME_SEGMENTER = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
270
|
+
var endCodeNumbers = new Set;
|
|
271
|
+
for (const [, end] of ansi_styles_default.codes) {
|
|
272
|
+
endCodeNumbers.add(end);
|
|
273
|
+
}
|
|
274
|
+
function isCsiParameterCharacter(codePoint) {
|
|
275
|
+
return codePoint >= CODE_POINT_CSI_PARAMETER_START && codePoint <= CODE_POINT_CSI_PARAMETER_END;
|
|
276
|
+
}
|
|
277
|
+
function isCsiIntermediateCharacter(codePoint) {
|
|
278
|
+
return codePoint >= CODE_POINT_CSI_INTERMEDIATE_START && codePoint <= CODE_POINT_CSI_INTERMEDIATE_END;
|
|
279
|
+
}
|
|
280
|
+
function isCsiFinalCharacter(codePoint) {
|
|
281
|
+
return codePoint >= CODE_POINT_CSI_FINAL_START && codePoint <= CODE_POINT_CSI_FINAL_END;
|
|
282
|
+
}
|
|
283
|
+
function createControlParseResult(code, endIndex) {
|
|
284
|
+
return {
|
|
285
|
+
token: {
|
|
286
|
+
type: "control",
|
|
287
|
+
code
|
|
288
|
+
},
|
|
289
|
+
endIndex
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function getSgrPrefix(code) {
|
|
293
|
+
return code.startsWith("\x9B") ? "\x9B" : `${ESCAPE}${ANSI_CSI}`;
|
|
294
|
+
}
|
|
295
|
+
function createSgrCode(prefix, values) {
|
|
296
|
+
return `${prefix}${values.join(";")}${ANSI_SGR_TERMINATOR}`;
|
|
297
|
+
}
|
|
298
|
+
function getSgrFragments(code) {
|
|
299
|
+
const fragments = [];
|
|
300
|
+
const sgrPrefix = getSgrPrefix(code);
|
|
301
|
+
const rawCodes = code.slice(sgrPrefix.length, -1).split(";");
|
|
302
|
+
let index = 0;
|
|
303
|
+
while (index < rawCodes.length) {
|
|
304
|
+
const codeNumber = Number.parseInt(rawCodes[index] || "0", 10);
|
|
305
|
+
if (Number.isNaN(codeNumber)) {
|
|
306
|
+
index++;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (codeNumber === SGR_RESET_CODE) {
|
|
310
|
+
fragments.push({ type: "reset" });
|
|
311
|
+
index++;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (endCodeNumbers.has(codeNumber)) {
|
|
315
|
+
fragments.push({
|
|
316
|
+
type: "end",
|
|
317
|
+
endCode: ansi_styles_default.color.ansi(codeNumber)
|
|
318
|
+
});
|
|
319
|
+
index++;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const extendedColorEndCode = SGR_EXTENDED_COLOR_END_CODES.get(codeNumber);
|
|
323
|
+
let fragmentLength = 1;
|
|
324
|
+
if (extendedColorEndCode !== undefined && !rawCodes[index].includes(":")) {
|
|
325
|
+
const colorType = Number.parseInt(rawCodes[index + 1], 10);
|
|
326
|
+
const colorLength = SGR_COLOR_LENGTHS.get(colorType);
|
|
327
|
+
if (colorLength !== undefined && index + colorLength <= rawCodes.length) {
|
|
328
|
+
fragmentLength = colorLength;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const endCode = extendedColorEndCode ?? ansi_styles_default.codes.get(codeNumber);
|
|
332
|
+
fragments.push({
|
|
333
|
+
type: "start",
|
|
334
|
+
code: createSgrCode(sgrPrefix, rawCodes.slice(index, index + fragmentLength)),
|
|
335
|
+
endCode: endCode === undefined ? ansi_styles_default.reset.open : ansi_styles_default.color.ansi(endCode)
|
|
336
|
+
});
|
|
337
|
+
index += fragmentLength;
|
|
338
|
+
}
|
|
339
|
+
if (fragments.length === 0) {
|
|
340
|
+
fragments.push({ type: "reset" });
|
|
341
|
+
}
|
|
342
|
+
return fragments;
|
|
343
|
+
}
|
|
344
|
+
function parseCsiCode(string, index) {
|
|
345
|
+
const escapeCodePoint = string.codePointAt(index);
|
|
346
|
+
let sequenceStartIndex;
|
|
347
|
+
if (escapeCodePoint === ESCAPE_CODE_POINT) {
|
|
348
|
+
if (string[index + 1] !== ANSI_CSI) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
sequenceStartIndex = index + 2;
|
|
352
|
+
} else if (escapeCodePoint === C1_CSI_CODE_POINT) {
|
|
353
|
+
sequenceStartIndex = index + 1;
|
|
354
|
+
} else {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
for (let sequenceIndex = sequenceStartIndex;sequenceIndex < string.length; sequenceIndex++) {
|
|
358
|
+
const codePoint = string.codePointAt(sequenceIndex);
|
|
359
|
+
if (isCsiFinalCharacter(codePoint)) {
|
|
360
|
+
const code = string.slice(index, sequenceIndex + 1);
|
|
361
|
+
if (string[sequenceIndex] !== ANSI_SGR_TERMINATOR || !/^[\d:;]*$/v.test(string.slice(sequenceStartIndex, sequenceIndex))) {
|
|
362
|
+
return createControlParseResult(code, sequenceIndex + 1);
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
token: {
|
|
366
|
+
type: "sgr",
|
|
367
|
+
code,
|
|
368
|
+
fragments: getSgrFragments(code)
|
|
369
|
+
},
|
|
370
|
+
endIndex: sequenceIndex + 1
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
if (isCsiParameterCharacter(codePoint) || isCsiIntermediateCharacter(codePoint)) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
const endIndex = sequenceIndex;
|
|
377
|
+
return createControlParseResult(string.slice(index, endIndex), endIndex);
|
|
378
|
+
}
|
|
379
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
380
|
+
}
|
|
381
|
+
function createControlStringParseResult(string, index, endIndex, terminator) {
|
|
382
|
+
const code = string.slice(index, endIndex);
|
|
383
|
+
const hyperlinkPrefix = code.startsWith(ANSI_HYPERLINK_ESC_PREFIX) ? ANSI_HYPERLINK_ESC_PREFIX : ANSI_HYPERLINK_C1_PREFIX;
|
|
384
|
+
if (!code.startsWith(hyperlinkPrefix)) {
|
|
385
|
+
return createControlParseResult(code, endIndex);
|
|
386
|
+
}
|
|
387
|
+
const uriStart = code.indexOf(";", hyperlinkPrefix.length);
|
|
388
|
+
const contentEnd = code.length - terminator.length;
|
|
389
|
+
if (uriStart === -1 || uriStart >= contentEnd) {
|
|
390
|
+
return createControlParseResult(code, endIndex);
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
token: {
|
|
394
|
+
type: "hyperlink",
|
|
395
|
+
code,
|
|
396
|
+
action: uriStart + 1 === contentEnd ? "close" : "open",
|
|
397
|
+
closePrefix: `${hyperlinkPrefix};`,
|
|
398
|
+
terminator
|
|
399
|
+
},
|
|
400
|
+
endIndex
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function parseControlStringCode(string, index) {
|
|
404
|
+
const codePoint = string.codePointAt(index);
|
|
405
|
+
const command = codePoint === ESCAPE_CODE_POINT ? string.codePointAt(index + 1) + 64 : codePoint;
|
|
406
|
+
const sequenceStartIndex = index + (codePoint === ESCAPE_CODE_POINT ? 2 : 1);
|
|
407
|
+
if (command === C1_ST_CODE_POINT) {
|
|
408
|
+
return createControlParseResult(string.slice(index, sequenceStartIndex), sequenceStartIndex);
|
|
409
|
+
}
|
|
410
|
+
if (!CONTROL_STRING_STARTS.has(command)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
for (let sequenceIndex = sequenceStartIndex;sequenceIndex < string.length; sequenceIndex++) {
|
|
414
|
+
if (command === C1_OSC_CODE_POINT && string[sequenceIndex] === ANSI_BELL) {
|
|
415
|
+
return createControlStringParseResult(string, index, sequenceIndex + 1, ANSI_BELL);
|
|
416
|
+
}
|
|
417
|
+
if (string[sequenceIndex] === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) {
|
|
418
|
+
return createControlStringParseResult(string, index, sequenceIndex + 2, ANSI_STRING_TERMINATOR);
|
|
419
|
+
}
|
|
420
|
+
if (string[sequenceIndex] === C1_STRING_TERMINATOR) {
|
|
421
|
+
return createControlStringParseResult(string, index, sequenceIndex + 1, C1_STRING_TERMINATOR);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
425
|
+
}
|
|
426
|
+
function parseAnsiCode(string, index) {
|
|
427
|
+
return parseControlStringCode(string, index) || parseCsiCode(string, index);
|
|
428
|
+
}
|
|
429
|
+
function appendAnsiTokens(string, index, tokens) {
|
|
430
|
+
while (index < string.length) {
|
|
431
|
+
const nextCodePoint = string.codePointAt(index);
|
|
432
|
+
if (!ESCAPES.has(nextCodePoint)) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
const escapeCode = parseAnsiCode(string, index);
|
|
436
|
+
if (!escapeCode) {
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
tokens.push(escapeCode.token);
|
|
440
|
+
index = escapeCode.endIndex;
|
|
441
|
+
}
|
|
442
|
+
return index;
|
|
443
|
+
}
|
|
444
|
+
function parseCharacterTokenWithRawSegmentation(index, graphemeSegments) {
|
|
445
|
+
const segment = graphemeSegments.containing(index);
|
|
446
|
+
if (!segment || segment.index !== index) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
return {
|
|
450
|
+
token: {
|
|
451
|
+
type: "character",
|
|
452
|
+
value: segment.segment,
|
|
453
|
+
visibleWidth: stringWidth(segment.segment)
|
|
454
|
+
},
|
|
455
|
+
endIndex: index + segment.segment.length
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Infinity } = {}) {
|
|
459
|
+
const tokens = [];
|
|
460
|
+
let visibleString = "";
|
|
461
|
+
let index = 0;
|
|
462
|
+
while (index < string.length) {
|
|
463
|
+
const codePoint = string.codePointAt(index);
|
|
464
|
+
if (ESCAPES.has(codePoint)) {
|
|
465
|
+
const code = parseAnsiCode(string, index);
|
|
466
|
+
if (code) {
|
|
467
|
+
tokens.push(code.token);
|
|
468
|
+
index = code.endIndex;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const value = String.fromCodePoint(codePoint);
|
|
473
|
+
visibleString += value;
|
|
474
|
+
tokens.push({ type: "text", value, visibleEnd: visibleString.length });
|
|
475
|
+
index += value.length;
|
|
476
|
+
}
|
|
477
|
+
const graphemes = [];
|
|
478
|
+
let tokenIndex = 0;
|
|
479
|
+
let visibleCount = 0;
|
|
480
|
+
for (const { segment, index: segmentIndex } of GRAPHEME_SEGMENTER.segment(visibleString)) {
|
|
481
|
+
while (tokens[tokenIndex].type !== "text") {
|
|
482
|
+
graphemes.push(tokens[tokenIndex]);
|
|
483
|
+
tokenIndex++;
|
|
484
|
+
}
|
|
485
|
+
if (segmentIndex > 0 && visibleCount >= endCharacter) {
|
|
486
|
+
return graphemes;
|
|
487
|
+
}
|
|
488
|
+
const startIndex = tokenIndex;
|
|
489
|
+
const visibleEnd = segmentIndex + segment.length;
|
|
490
|
+
do {
|
|
491
|
+
tokenIndex++;
|
|
492
|
+
} while (tokens[tokenIndex - 1].visibleEnd !== visibleEnd);
|
|
493
|
+
const visibleWidth = stringWidth(segment);
|
|
494
|
+
graphemes.push({
|
|
495
|
+
type: "character",
|
|
496
|
+
value: segment,
|
|
497
|
+
visibleWidth,
|
|
498
|
+
parts: tokens.slice(startIndex, tokenIndex)
|
|
499
|
+
});
|
|
500
|
+
visibleCount += visibleWidth;
|
|
501
|
+
}
|
|
502
|
+
while (tokenIndex < tokens.length) {
|
|
503
|
+
graphemes.push(tokens[tokenIndex]);
|
|
504
|
+
tokenIndex++;
|
|
505
|
+
}
|
|
506
|
+
return graphemes;
|
|
507
|
+
}
|
|
508
|
+
function areValuesInSameGrapheme(leftValue, rightValue) {
|
|
509
|
+
const segment = GRAPHEME_SEGMENTER.segment(leftValue + rightValue).containing(leftValue.length);
|
|
510
|
+
return segment.index < leftValue.length;
|
|
511
|
+
}
|
|
512
|
+
function tokenizeAnsi(string, { endCharacter = Infinity } = {}) {
|
|
513
|
+
const tokens = [];
|
|
514
|
+
const graphemeSegments = GRAPHEME_SEGMENTER.segment(string);
|
|
515
|
+
let index = 0;
|
|
516
|
+
let visibleCount = 0;
|
|
517
|
+
let previousCharacter;
|
|
518
|
+
while (index < string.length) {
|
|
519
|
+
index = appendAnsiTokens(string, index, tokens);
|
|
520
|
+
if (index === string.length) {
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
const characterToken = parseCharacterTokenWithRawSegmentation(index, graphemeSegments);
|
|
524
|
+
if (!characterToken || previousCharacter && index > previousCharacter.endIndex && areValuesInSameGrapheme(previousCharacter.token.value, characterToken.token.value)) {
|
|
525
|
+
return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
526
|
+
}
|
|
527
|
+
if (previousCharacter && visibleCount >= endCharacter) {
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
tokens.push(characterToken.token);
|
|
531
|
+
index = characterToken.endIndex;
|
|
532
|
+
visibleCount += characterToken.token.visibleWidth;
|
|
533
|
+
previousCharacter = characterToken;
|
|
534
|
+
}
|
|
535
|
+
return tokens;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// node_modules/slice-ansi/index.js
|
|
539
|
+
class SliceOutput {
|
|
540
|
+
#phase = "before";
|
|
541
|
+
#styles = new Map;
|
|
542
|
+
#hyperlink;
|
|
543
|
+
#checkpoint;
|
|
544
|
+
#output = [];
|
|
545
|
+
#writeText(value) {
|
|
546
|
+
if (this.#phase === "before") {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
this.#output.push(value);
|
|
550
|
+
this.#checkpoint = undefined;
|
|
551
|
+
if (this.#hyperlink?.phase === "pending") {
|
|
552
|
+
this.#hyperlink = { phase: "visible", token: this.#hyperlink.token };
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
#writeSgr(token, isPastEnd) {
|
|
556
|
+
const hasStart = token.fragments.some((fragment) => fragment.type === "start");
|
|
557
|
+
if (isPastEnd) {
|
|
558
|
+
const hasClosingEffect = token.fragments.some(({ type, endCode }) => type === "reset" && this.#styles.size > 0 || type === "end" && this.#styles.has(endCode));
|
|
559
|
+
if (hasStart || !hasClosingEffect) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (hasStart && !this.#checkpoint && this.#phase === "emitting") {
|
|
564
|
+
this.#checkpoint = { outputLength: this.#output.length, styles: new Map(this.#styles), hyperlink: this.#hyperlink };
|
|
565
|
+
}
|
|
566
|
+
this.#applySgrFragments(token.fragments);
|
|
567
|
+
if (this.#phase === "emitting") {
|
|
568
|
+
this.#output.push(token.code);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
#applySgrFragments(fragments) {
|
|
572
|
+
for (const fragment of fragments) {
|
|
573
|
+
switch (fragment.type) {
|
|
574
|
+
case "reset": {
|
|
575
|
+
this.#styles.clear();
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
case "end": {
|
|
579
|
+
this.#styles.delete(fragment.endCode);
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
case "start": {
|
|
583
|
+
this.#styles.delete(fragment.endCode);
|
|
584
|
+
this.#styles.set(fragment.endCode, fragment.code);
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
default: {
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
#openHyperlink(token) {
|
|
594
|
+
if (this.#phase === "before") {
|
|
595
|
+
this.#hyperlink = { phase: "inherited", token };
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
this.#hyperlink = { phase: "pending", token, outputIndex: this.#output.length };
|
|
599
|
+
this.#output.push(token.code);
|
|
600
|
+
}
|
|
601
|
+
#settleHyperlink() {
|
|
602
|
+
const hyperlink = this.#hyperlink;
|
|
603
|
+
if (!hyperlink) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (hyperlink.phase === "visible") {
|
|
607
|
+
this.#output.push(`${hyperlink.token.closePrefix}${hyperlink.token.terminator}`);
|
|
608
|
+
} else if (hyperlink.phase === "pending") {
|
|
609
|
+
this.#output[hyperlink.outputIndex] = "";
|
|
610
|
+
}
|
|
611
|
+
this.#hyperlink = undefined;
|
|
612
|
+
}
|
|
613
|
+
#writeHyperlink(token, isPastEnd) {
|
|
614
|
+
if (isPastEnd && (token.action !== "close" || !this.#hyperlink)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (token.action === "open") {
|
|
618
|
+
this.#settleHyperlink();
|
|
619
|
+
this.#openHyperlink(token);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (this.#hyperlink?.phase === "pending") {
|
|
623
|
+
this.#settleHyperlink();
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
this.#hyperlink = undefined;
|
|
627
|
+
if (this.#phase === "emitting") {
|
|
628
|
+
this.#output.push(token.code);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
begin() {
|
|
632
|
+
if (this.#phase === "emitting") {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
this.#phase = "emitting";
|
|
636
|
+
this.#output.push(...this.#styles.values());
|
|
637
|
+
if (this.#hyperlink) {
|
|
638
|
+
this.#openHyperlink(this.#hyperlink.token);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
write(token, isPastEnd = false) {
|
|
642
|
+
switch (token.type) {
|
|
643
|
+
case "sgr": {
|
|
644
|
+
this.#writeSgr(token, isPastEnd);
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
case "hyperlink": {
|
|
648
|
+
this.#writeHyperlink(token, isPastEnd);
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
case "control": {
|
|
652
|
+
if (!isPastEnd && this.#phase === "emitting") {
|
|
653
|
+
this.#output.push(token.code);
|
|
654
|
+
}
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
case "text": {
|
|
658
|
+
this.#writeText(token.value);
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
case "character": {
|
|
662
|
+
if (token.parts) {
|
|
663
|
+
for (const part of token.parts) {
|
|
664
|
+
this.write(part);
|
|
665
|
+
}
|
|
666
|
+
} else {
|
|
667
|
+
this.#writeText(token.value);
|
|
668
|
+
}
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
default: {
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
discardPending() {
|
|
677
|
+
if (this.#hyperlink?.phase !== "visible") {
|
|
678
|
+
this.#settleHyperlink();
|
|
679
|
+
}
|
|
680
|
+
if (!this.#checkpoint) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
this.#output.length = this.#checkpoint.outputLength;
|
|
684
|
+
this.#styles = this.#checkpoint.styles;
|
|
685
|
+
this.#hyperlink = this.#checkpoint.hyperlink;
|
|
686
|
+
this.#checkpoint = undefined;
|
|
687
|
+
}
|
|
688
|
+
finish() {
|
|
689
|
+
if (this.#phase === "before") {
|
|
690
|
+
return "";
|
|
691
|
+
}
|
|
692
|
+
this.#settleHyperlink();
|
|
693
|
+
this.#output.push(...[...this.#styles.keys()].toReversed());
|
|
694
|
+
return this.#output.join("");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function sliceAnsi(string, start, end) {
|
|
698
|
+
if (end <= start || string.length === 0) {
|
|
699
|
+
return "";
|
|
700
|
+
}
|
|
701
|
+
const output = new SliceOutput;
|
|
702
|
+
let position = 0;
|
|
703
|
+
for (const token of tokenizeAnsi(string, { endCharacter: end })) {
|
|
704
|
+
const isPastEnd = end !== undefined && position >= end;
|
|
705
|
+
if (token.type === "character") {
|
|
706
|
+
if (isPastEnd || end !== undefined && position + token.visibleWidth > end) {
|
|
707
|
+
output.discardPending();
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
if (position >= start) {
|
|
711
|
+
output.begin();
|
|
712
|
+
}
|
|
713
|
+
output.write(token);
|
|
714
|
+
position += token.visibleWidth;
|
|
715
|
+
} else {
|
|
716
|
+
output.write(token, isPastEnd);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return output.finish();
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// node_modules/cli-truncate/index.js
|
|
723
|
+
var validPositions = new Set(["start", "middle", "end"]);
|
|
724
|
+
function getVisibleColumns(text) {
|
|
725
|
+
const visibleColumns = [];
|
|
726
|
+
for (const { segment } of new Intl.Segmenter().segment(stripVTControlCharacters(text))) {
|
|
727
|
+
const width = stringWidth(segment);
|
|
728
|
+
for (let column = 0;column < width; column++) {
|
|
729
|
+
visibleColumns.push(column === 0 ? segment : "");
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return visibleColumns;
|
|
733
|
+
}
|
|
734
|
+
function getIndexOfNearestSpace(visibleColumns, wantedIndex, shouldSearchRight) {
|
|
735
|
+
if (visibleColumns[wantedIndex] === " ") {
|
|
736
|
+
return wantedIndex;
|
|
737
|
+
}
|
|
738
|
+
const direction = shouldSearchRight ? 1 : -1;
|
|
739
|
+
for (let index = 0;index <= 3; index++) {
|
|
740
|
+
const finalIndex = wantedIndex + index * direction;
|
|
741
|
+
if (visibleColumns[finalIndex] === " ") {
|
|
742
|
+
return finalIndex;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return wantedIndex;
|
|
746
|
+
}
|
|
747
|
+
function getIndexAfterSpaces(visibleColumns, index) {
|
|
748
|
+
while (visibleColumns[index] === " ") {
|
|
749
|
+
index++;
|
|
750
|
+
}
|
|
751
|
+
return index;
|
|
752
|
+
}
|
|
753
|
+
function validateInput(text, columns, position, truncationCharacter) {
|
|
754
|
+
if (typeof text !== "string") {
|
|
755
|
+
throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
|
|
756
|
+
}
|
|
757
|
+
if (typeof columns !== "number") {
|
|
758
|
+
throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
|
|
759
|
+
}
|
|
760
|
+
if (!Number.isFinite(columns)) {
|
|
761
|
+
throw new TypeError(`Expected \`columns\` to be a finite number, got ${columns}`);
|
|
762
|
+
}
|
|
763
|
+
if (!validPositions.has(position)) {
|
|
764
|
+
throw new TypeError(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
|
765
|
+
}
|
|
766
|
+
if (typeof truncationCharacter !== "string") {
|
|
767
|
+
throw new TypeError(`Expected \`options.truncationCharacter\` to be a string, got ${typeof truncationCharacter}`);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function cliTruncate(text, columns, options = {}) {
|
|
771
|
+
const {
|
|
772
|
+
position = "end",
|
|
773
|
+
space = false,
|
|
774
|
+
preferTruncationOnSpace = false
|
|
775
|
+
} = options;
|
|
776
|
+
let { truncationCharacter = "\u2026" } = options;
|
|
777
|
+
validateInput(text, columns, position, truncationCharacter);
|
|
778
|
+
if (columns < 1) {
|
|
779
|
+
return "";
|
|
780
|
+
}
|
|
781
|
+
const length = stringWidth(text);
|
|
782
|
+
if (length <= columns) {
|
|
783
|
+
return text;
|
|
784
|
+
}
|
|
785
|
+
if (columns === 1) {
|
|
786
|
+
return truncationCharacter;
|
|
787
|
+
}
|
|
788
|
+
const visibleColumns = preferTruncationOnSpace ? getVisibleColumns(text) : undefined;
|
|
789
|
+
const ANSI = {
|
|
790
|
+
ESC: 27,
|
|
791
|
+
LEFT_BRACKET: 91,
|
|
792
|
+
LETTER_M: 109
|
|
793
|
+
};
|
|
794
|
+
const isSgrParameter = (code) => code >= 48 && code <= 57 || code === 59;
|
|
795
|
+
function leadingSgrSpanEndIndex(string) {
|
|
796
|
+
let index = 0;
|
|
797
|
+
while (index + 2 < string.length && string.codePointAt(index) === ANSI.ESC && string.codePointAt(index + 1) === ANSI.LEFT_BRACKET) {
|
|
798
|
+
let j = index + 2;
|
|
799
|
+
while (j < string.length && isSgrParameter(string.codePointAt(j))) {
|
|
800
|
+
j++;
|
|
801
|
+
}
|
|
802
|
+
if (j < string.length && string.codePointAt(j) === ANSI.LETTER_M) {
|
|
803
|
+
index = j + 1;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
return index;
|
|
809
|
+
}
|
|
810
|
+
function trailingSgrSpanStartIndex(string) {
|
|
811
|
+
let start = string.length;
|
|
812
|
+
while (start > 1 && string.codePointAt(start - 1) === ANSI.LETTER_M) {
|
|
813
|
+
let j = start - 2;
|
|
814
|
+
while (j >= 0 && isSgrParameter(string.codePointAt(j))) {
|
|
815
|
+
j--;
|
|
816
|
+
}
|
|
817
|
+
if (j >= 1 && string.codePointAt(j - 1) === ANSI.ESC && string.codePointAt(j) === ANSI.LEFT_BRACKET) {
|
|
818
|
+
start = j - 1;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
return start;
|
|
824
|
+
}
|
|
825
|
+
function appendWithInheritedStyleFromEnd(visible, suffix) {
|
|
826
|
+
const start = trailingSgrSpanStartIndex(visible);
|
|
827
|
+
return start === visible.length ? visible + suffix : visible.slice(0, start) + suffix + visible.slice(start);
|
|
828
|
+
}
|
|
829
|
+
function prependWithInheritedStyleFromStart(prefix, visible) {
|
|
830
|
+
const end = leadingSgrSpanEndIndex(visible);
|
|
831
|
+
return end === 0 ? prefix + visible : visible.slice(0, end) + prefix + visible.slice(end);
|
|
832
|
+
}
|
|
833
|
+
if (position === "start") {
|
|
834
|
+
if (preferTruncationOnSpace) {
|
|
835
|
+
const nearestSpace = getIndexOfNearestSpace(visibleColumns, length - columns + stringWidth(truncationCharacter), true);
|
|
836
|
+
const right2 = sliceAnsi(text, getIndexAfterSpaces(visibleColumns, nearestSpace), length);
|
|
837
|
+
return prependWithInheritedStyleFromStart(truncationCharacter, right2);
|
|
838
|
+
}
|
|
839
|
+
if (space) {
|
|
840
|
+
truncationCharacter += " ";
|
|
841
|
+
}
|
|
842
|
+
const right = sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
|
|
843
|
+
return prependWithInheritedStyleFromStart(truncationCharacter, right);
|
|
844
|
+
}
|
|
845
|
+
if (position === "middle") {
|
|
846
|
+
if (space) {
|
|
847
|
+
truncationCharacter = ` ${truncationCharacter} `;
|
|
848
|
+
if (stringWidth(truncationCharacter) >= columns) {
|
|
849
|
+
truncationCharacter = truncationCharacter.trim();
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
const truncationWidth = stringWidth(truncationCharacter);
|
|
853
|
+
const half = Math.min(Math.floor(columns / 2), Math.max(0, columns - truncationWidth));
|
|
854
|
+
if (preferTruncationOnSpace) {
|
|
855
|
+
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(visibleColumns, half);
|
|
856
|
+
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(visibleColumns, length - (columns - half) + truncationWidth, true);
|
|
857
|
+
return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, getIndexAfterSpaces(visibleColumns, spaceNearSecondBreakPoint), length);
|
|
858
|
+
}
|
|
859
|
+
return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + truncationWidth, length);
|
|
860
|
+
}
|
|
861
|
+
if (preferTruncationOnSpace) {
|
|
862
|
+
const nearestSpace = getIndexOfNearestSpace(visibleColumns, columns - stringWidth(truncationCharacter));
|
|
863
|
+
const left2 = sliceAnsi(text, 0, nearestSpace);
|
|
864
|
+
return appendWithInheritedStyleFromEnd(left2, truncationCharacter);
|
|
865
|
+
}
|
|
866
|
+
if (space) {
|
|
867
|
+
truncationCharacter = ` ${truncationCharacter}`;
|
|
868
|
+
}
|
|
869
|
+
const left = sliceAnsi(text, 0, columns - stringWidth(truncationCharacter));
|
|
870
|
+
return appendWithInheritedStyleFromEnd(left, truncationCharacter);
|
|
871
|
+
}
|
|
872
|
+
export {
|
|
873
|
+
cliTruncate as default
|
|
874
|
+
};
|