@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,1610 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ansi_styles_default,
|
|
4
|
+
wrapAnsi
|
|
5
|
+
} from "./cli-5d61x8vg.js";
|
|
6
|
+
import {
|
|
7
|
+
isFullwidth,
|
|
8
|
+
isWide,
|
|
9
|
+
stringWidth,
|
|
10
|
+
stripAnsi
|
|
11
|
+
} from "./cli-qq1ktr8q.js";
|
|
12
|
+
import {
|
|
13
|
+
__export
|
|
14
|
+
} from "./cli-re3ntm60.js";
|
|
15
|
+
|
|
16
|
+
// node_modules/log-update/index.js
|
|
17
|
+
import process6 from "process";
|
|
18
|
+
|
|
19
|
+
// node_modules/ansi-escapes/base.js
|
|
20
|
+
var exports_base = {};
|
|
21
|
+
__export(exports_base, {
|
|
22
|
+
synchronizedOutput: () => synchronizedOutput,
|
|
23
|
+
setCwd: () => setCwd,
|
|
24
|
+
scrollUp: () => scrollUp,
|
|
25
|
+
scrollDown: () => scrollDown,
|
|
26
|
+
link: () => link,
|
|
27
|
+
image: () => image,
|
|
28
|
+
iTerm: () => iTerm,
|
|
29
|
+
exitAlternativeScreen: () => exitAlternativeScreen,
|
|
30
|
+
eraseUp: () => eraseUp,
|
|
31
|
+
eraseStartLine: () => eraseStartLine,
|
|
32
|
+
eraseScreen: () => eraseScreen,
|
|
33
|
+
eraseLines: () => eraseLines,
|
|
34
|
+
eraseLine: () => eraseLine,
|
|
35
|
+
eraseEndLine: () => eraseEndLine,
|
|
36
|
+
eraseDown: () => eraseDown,
|
|
37
|
+
enterAlternativeScreen: () => enterAlternativeScreen,
|
|
38
|
+
endSynchronizedOutput: () => endSynchronizedOutput,
|
|
39
|
+
cursorUp: () => cursorUp,
|
|
40
|
+
cursorTo: () => cursorTo,
|
|
41
|
+
cursorShow: () => cursorShow,
|
|
42
|
+
cursorSavePosition: () => cursorSavePosition,
|
|
43
|
+
cursorRestorePosition: () => cursorRestorePosition,
|
|
44
|
+
cursorPrevLine: () => cursorPrevLine,
|
|
45
|
+
cursorNextLine: () => cursorNextLine,
|
|
46
|
+
cursorMove: () => cursorMove,
|
|
47
|
+
cursorLeft: () => cursorLeft,
|
|
48
|
+
cursorHide: () => cursorHide,
|
|
49
|
+
cursorGetPosition: () => cursorGetPosition,
|
|
50
|
+
cursorForward: () => cursorForward,
|
|
51
|
+
cursorDown: () => cursorDown,
|
|
52
|
+
cursorBackward: () => cursorBackward,
|
|
53
|
+
clearViewport: () => clearViewport,
|
|
54
|
+
clearTerminal: () => clearTerminal,
|
|
55
|
+
clearScreen: () => clearScreen,
|
|
56
|
+
beginSynchronizedOutput: () => beginSynchronizedOutput,
|
|
57
|
+
beep: () => beep,
|
|
58
|
+
ConEmu: () => ConEmu
|
|
59
|
+
});
|
|
60
|
+
import process2 from "process";
|
|
61
|
+
import os from "os";
|
|
62
|
+
|
|
63
|
+
// node_modules/environment/index.js
|
|
64
|
+
var isBrowser = globalThis.window?.document !== undefined;
|
|
65
|
+
var isNode = globalThis.process?.versions?.node !== undefined;
|
|
66
|
+
var isBun = globalThis.process?.versions?.bun !== undefined;
|
|
67
|
+
var isDeno = globalThis.Deno?.version?.deno !== undefined;
|
|
68
|
+
var isElectron = globalThis.process?.versions?.electron !== undefined;
|
|
69
|
+
var isJsDom = globalThis.navigator?.userAgent?.includes("jsdom") === true;
|
|
70
|
+
var isWebWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
71
|
+
var isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
72
|
+
var isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
|
|
73
|
+
var isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
|
|
74
|
+
var platform = globalThis.navigator?.userAgentData?.platform;
|
|
75
|
+
var isMacOs = platform === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
|
|
76
|
+
var isWindows = platform === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
|
|
77
|
+
var isLinux = platform === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
|
|
78
|
+
var isIos = platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
|
|
79
|
+
var isAndroid = platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
|
|
80
|
+
|
|
81
|
+
// node_modules/ansi-escapes/base.js
|
|
82
|
+
var ESC = "\x1B[";
|
|
83
|
+
var OSC = "\x1B]";
|
|
84
|
+
var BEL = "\x07";
|
|
85
|
+
var SEP = ";";
|
|
86
|
+
var isTerminalApp = !isBrowser && process2.env.TERM_PROGRAM === "Apple_Terminal";
|
|
87
|
+
var isWindows2 = !isBrowser && process2.platform === "win32";
|
|
88
|
+
var isTmux = !isBrowser && (process2.env.TERM?.startsWith("screen") || process2.env.TERM?.startsWith("tmux") || process2.env.TMUX !== undefined);
|
|
89
|
+
var cwdFunction = isBrowser ? () => {
|
|
90
|
+
throw new Error("`process.cwd()` only works in Node.js, not the browser.");
|
|
91
|
+
} : process2.cwd;
|
|
92
|
+
var wrapOsc = (sequence) => {
|
|
93
|
+
if (isTmux) {
|
|
94
|
+
return "\x1BPtmux;" + sequence.replaceAll("\x1B", "\x1B\x1B") + "\x1B\\";
|
|
95
|
+
}
|
|
96
|
+
return sequence;
|
|
97
|
+
};
|
|
98
|
+
var cursorTo = (x, y) => {
|
|
99
|
+
if (typeof x !== "number") {
|
|
100
|
+
throw new TypeError("The `x` argument is required");
|
|
101
|
+
}
|
|
102
|
+
if (typeof y !== "number") {
|
|
103
|
+
return ESC + (x + 1) + "G";
|
|
104
|
+
}
|
|
105
|
+
return ESC + (y + 1) + SEP + (x + 1) + "H";
|
|
106
|
+
};
|
|
107
|
+
var cursorMove = (x, y) => {
|
|
108
|
+
if (typeof x !== "number") {
|
|
109
|
+
throw new TypeError("The `x` argument is required");
|
|
110
|
+
}
|
|
111
|
+
let returnValue = "";
|
|
112
|
+
if (x < 0) {
|
|
113
|
+
returnValue += ESC + -x + "D";
|
|
114
|
+
} else if (x > 0) {
|
|
115
|
+
returnValue += ESC + x + "C";
|
|
116
|
+
}
|
|
117
|
+
if (y < 0) {
|
|
118
|
+
returnValue += ESC + -y + "A";
|
|
119
|
+
} else if (y > 0) {
|
|
120
|
+
returnValue += ESC + y + "B";
|
|
121
|
+
}
|
|
122
|
+
return returnValue;
|
|
123
|
+
};
|
|
124
|
+
var cursorUp = (count = 1) => ESC + count + "A";
|
|
125
|
+
var cursorDown = (count = 1) => ESC + count + "B";
|
|
126
|
+
var cursorForward = (count = 1) => ESC + count + "C";
|
|
127
|
+
var cursorBackward = (count = 1) => ESC + count + "D";
|
|
128
|
+
var cursorLeft = ESC + "G";
|
|
129
|
+
var cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
|
|
130
|
+
var cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
|
|
131
|
+
var cursorGetPosition = ESC + "6n";
|
|
132
|
+
var cursorNextLine = ESC + "E";
|
|
133
|
+
var cursorPrevLine = ESC + "F";
|
|
134
|
+
var cursorHide = ESC + "?25l";
|
|
135
|
+
var cursorShow = ESC + "?25h";
|
|
136
|
+
var eraseLines = (count) => {
|
|
137
|
+
let clear = "";
|
|
138
|
+
for (let i = 0;i < count; i++) {
|
|
139
|
+
clear += eraseLine + (i < count - 1 ? cursorUp() : "");
|
|
140
|
+
}
|
|
141
|
+
if (count) {
|
|
142
|
+
clear += cursorLeft;
|
|
143
|
+
}
|
|
144
|
+
return clear;
|
|
145
|
+
};
|
|
146
|
+
var eraseEndLine = ESC + "K";
|
|
147
|
+
var eraseStartLine = ESC + "1K";
|
|
148
|
+
var eraseLine = ESC + "2K";
|
|
149
|
+
var eraseDown = ESC + "J";
|
|
150
|
+
var eraseUp = ESC + "1J";
|
|
151
|
+
var eraseScreen = ESC + "2J";
|
|
152
|
+
var scrollUp = ESC + "S";
|
|
153
|
+
var scrollDown = ESC + "T";
|
|
154
|
+
var clearScreen = "\x1Bc";
|
|
155
|
+
var clearViewport = `${eraseScreen}${ESC}H`;
|
|
156
|
+
var isOldWindows = () => {
|
|
157
|
+
if (isBrowser || !isWindows2) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const parts = os.release().split(".");
|
|
161
|
+
const major = Number(parts[0]);
|
|
162
|
+
const build = Number(parts[2] ?? 0);
|
|
163
|
+
if (major < 10) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
if (major === 10 && build < 10586) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
};
|
|
171
|
+
var clearTerminal = isOldWindows() ? `${eraseScreen}${ESC}0f` : `${eraseScreen}${ESC}3J${ESC}H`;
|
|
172
|
+
var enterAlternativeScreen = ESC + "?1049h";
|
|
173
|
+
var exitAlternativeScreen = ESC + "?1049l";
|
|
174
|
+
var beginSynchronizedOutput = ESC + "?2026h";
|
|
175
|
+
var endSynchronizedOutput = ESC + "?2026l";
|
|
176
|
+
var synchronizedOutput = (text) => beginSynchronizedOutput + text + endSynchronizedOutput;
|
|
177
|
+
var beep = BEL;
|
|
178
|
+
var link = (text, url) => {
|
|
179
|
+
const openLink = wrapOsc(`${OSC}8${SEP}${SEP}${url}${BEL}`);
|
|
180
|
+
const closeLink = wrapOsc(`${OSC}8${SEP}${SEP}${BEL}`);
|
|
181
|
+
return openLink + text + closeLink;
|
|
182
|
+
};
|
|
183
|
+
var image = (data, options = {}) => {
|
|
184
|
+
let returnValue = `${OSC}1337;File=inline=1`;
|
|
185
|
+
if (options.width) {
|
|
186
|
+
returnValue += `;width=${options.width}`;
|
|
187
|
+
}
|
|
188
|
+
if (options.height) {
|
|
189
|
+
returnValue += `;height=${options.height}`;
|
|
190
|
+
}
|
|
191
|
+
if (options.preserveAspectRatio === false) {
|
|
192
|
+
returnValue += ";preserveAspectRatio=0";
|
|
193
|
+
}
|
|
194
|
+
const imageBuffer = Buffer.from(data);
|
|
195
|
+
return wrapOsc(returnValue + `;size=${imageBuffer.byteLength}` + ":" + imageBuffer.toString("base64") + BEL);
|
|
196
|
+
};
|
|
197
|
+
var iTerm = {
|
|
198
|
+
setCwd: (cwd = cwdFunction()) => wrapOsc(`${OSC}50;CurrentDir=${cwd}${BEL}`),
|
|
199
|
+
annotation(message, options = {}) {
|
|
200
|
+
let returnValue = `${OSC}1337;`;
|
|
201
|
+
const hasX = options.x !== undefined;
|
|
202
|
+
const hasY = options.y !== undefined;
|
|
203
|
+
if ((hasX || hasY) && !(hasX && hasY && options.length !== undefined)) {
|
|
204
|
+
throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
|
|
205
|
+
}
|
|
206
|
+
message = message.replaceAll("|", "");
|
|
207
|
+
returnValue += options.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
|
|
208
|
+
if (options.length > 0) {
|
|
209
|
+
returnValue += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join("|");
|
|
210
|
+
} else {
|
|
211
|
+
returnValue += message;
|
|
212
|
+
}
|
|
213
|
+
return wrapOsc(returnValue + BEL);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var ConEmu = {
|
|
217
|
+
setCwd: (cwd = cwdFunction()) => wrapOsc(`${OSC}9;9;${cwd}${BEL}`)
|
|
218
|
+
};
|
|
219
|
+
var setCwd = (cwd = cwdFunction()) => iTerm.setCwd(cwd) + ConEmu.setCwd(cwd);
|
|
220
|
+
// node_modules/cli-cursor/index.js
|
|
221
|
+
import process5 from "process";
|
|
222
|
+
|
|
223
|
+
// node_modules/restore-cursor/index.js
|
|
224
|
+
import process4 from "process";
|
|
225
|
+
|
|
226
|
+
// node_modules/mimic-function/index.js
|
|
227
|
+
var copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
228
|
+
if (property === "length" || property === "prototype") {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (property === "arguments" || property === "caller") {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
235
|
+
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
236
|
+
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
Object.defineProperty(to, property, fromDescriptor);
|
|
240
|
+
};
|
|
241
|
+
var canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
242
|
+
return toDescriptor === undefined || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
243
|
+
};
|
|
244
|
+
var changePrototype = (to, from) => {
|
|
245
|
+
const fromPrototype = Object.getPrototypeOf(from);
|
|
246
|
+
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
Object.setPrototypeOf(to, fromPrototype);
|
|
250
|
+
};
|
|
251
|
+
var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
|
|
252
|
+
${fromBody}`;
|
|
253
|
+
var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
|
|
254
|
+
var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
|
|
255
|
+
var changeToString = (to, from, name) => {
|
|
256
|
+
const withName = name === "" ? "" : `with ${name.trim()}() `;
|
|
257
|
+
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
258
|
+
Object.defineProperty(newToString, "name", toStringName);
|
|
259
|
+
const { writable, enumerable, configurable } = toStringDescriptor;
|
|
260
|
+
Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
|
|
261
|
+
};
|
|
262
|
+
function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
|
|
263
|
+
const { name } = to;
|
|
264
|
+
for (const property of Reflect.ownKeys(from)) {
|
|
265
|
+
copyProperty(to, from, property, ignoreNonConfigurable);
|
|
266
|
+
}
|
|
267
|
+
changePrototype(to, from);
|
|
268
|
+
changeToString(to, from, name);
|
|
269
|
+
return to;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// node_modules/onetime/index.js
|
|
273
|
+
var calledFunctions = new WeakMap;
|
|
274
|
+
var onetime = (function_, options = {}) => {
|
|
275
|
+
if (typeof function_ !== "function") {
|
|
276
|
+
throw new TypeError("Expected a function");
|
|
277
|
+
}
|
|
278
|
+
let returnValue;
|
|
279
|
+
let callCount = 0;
|
|
280
|
+
const functionName = function_.displayName || function_.name || "<anonymous>";
|
|
281
|
+
const onetime2 = function(...arguments_) {
|
|
282
|
+
calledFunctions.set(onetime2, ++callCount);
|
|
283
|
+
if (callCount === 1) {
|
|
284
|
+
returnValue = function_.apply(this, arguments_);
|
|
285
|
+
function_ = undefined;
|
|
286
|
+
} else if (options.throw === true) {
|
|
287
|
+
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
288
|
+
}
|
|
289
|
+
return returnValue;
|
|
290
|
+
};
|
|
291
|
+
mimicFunction(onetime2, function_);
|
|
292
|
+
calledFunctions.set(onetime2, callCount);
|
|
293
|
+
return onetime2;
|
|
294
|
+
};
|
|
295
|
+
onetime.callCount = (function_) => {
|
|
296
|
+
if (!calledFunctions.has(function_)) {
|
|
297
|
+
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
298
|
+
}
|
|
299
|
+
return calledFunctions.get(function_);
|
|
300
|
+
};
|
|
301
|
+
var onetime_default = onetime;
|
|
302
|
+
|
|
303
|
+
// node_modules/signal-exit/dist/mjs/signals.js
|
|
304
|
+
var signals = [];
|
|
305
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
306
|
+
if (process.platform !== "win32") {
|
|
307
|
+
signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
308
|
+
}
|
|
309
|
+
if (process.platform === "linux") {
|
|
310
|
+
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// node_modules/signal-exit/dist/mjs/index.js
|
|
314
|
+
var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
315
|
+
var kExitEmitter = Symbol.for("signal-exit emitter");
|
|
316
|
+
var global = globalThis;
|
|
317
|
+
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
318
|
+
|
|
319
|
+
class Emitter {
|
|
320
|
+
emitted = {
|
|
321
|
+
afterExit: false,
|
|
322
|
+
exit: false
|
|
323
|
+
};
|
|
324
|
+
listeners = {
|
|
325
|
+
afterExit: [],
|
|
326
|
+
exit: []
|
|
327
|
+
};
|
|
328
|
+
count = 0;
|
|
329
|
+
id = Math.random();
|
|
330
|
+
constructor() {
|
|
331
|
+
if (global[kExitEmitter]) {
|
|
332
|
+
return global[kExitEmitter];
|
|
333
|
+
}
|
|
334
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
335
|
+
value: this,
|
|
336
|
+
writable: false,
|
|
337
|
+
enumerable: false,
|
|
338
|
+
configurable: false
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
on(ev, fn) {
|
|
342
|
+
this.listeners[ev].push(fn);
|
|
343
|
+
}
|
|
344
|
+
removeListener(ev, fn) {
|
|
345
|
+
const list = this.listeners[ev];
|
|
346
|
+
const i = list.indexOf(fn);
|
|
347
|
+
if (i === -1) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (i === 0 && list.length === 1) {
|
|
351
|
+
list.length = 0;
|
|
352
|
+
} else {
|
|
353
|
+
list.splice(i, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
emit(ev, code, signal) {
|
|
357
|
+
if (this.emitted[ev]) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
this.emitted[ev] = true;
|
|
361
|
+
let ret = false;
|
|
362
|
+
for (const fn of this.listeners[ev]) {
|
|
363
|
+
ret = fn(code, signal) === true || ret;
|
|
364
|
+
}
|
|
365
|
+
if (ev === "exit") {
|
|
366
|
+
ret = this.emit("afterExit", code, signal) || ret;
|
|
367
|
+
}
|
|
368
|
+
return ret;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
class SignalExitBase {
|
|
373
|
+
}
|
|
374
|
+
var signalExitWrap = (handler) => {
|
|
375
|
+
return {
|
|
376
|
+
onExit(cb, opts) {
|
|
377
|
+
return handler.onExit(cb, opts);
|
|
378
|
+
},
|
|
379
|
+
load() {
|
|
380
|
+
return handler.load();
|
|
381
|
+
},
|
|
382
|
+
unload() {
|
|
383
|
+
return handler.unload();
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
class SignalExitFallback extends SignalExitBase {
|
|
389
|
+
onExit() {
|
|
390
|
+
return () => {};
|
|
391
|
+
}
|
|
392
|
+
load() {}
|
|
393
|
+
unload() {}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
class SignalExit extends SignalExitBase {
|
|
397
|
+
#hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
398
|
+
#emitter = new Emitter;
|
|
399
|
+
#process;
|
|
400
|
+
#originalProcessEmit;
|
|
401
|
+
#originalProcessReallyExit;
|
|
402
|
+
#sigListeners = {};
|
|
403
|
+
#loaded = false;
|
|
404
|
+
constructor(process3) {
|
|
405
|
+
super();
|
|
406
|
+
this.#process = process3;
|
|
407
|
+
this.#sigListeners = {};
|
|
408
|
+
for (const sig of signals) {
|
|
409
|
+
this.#sigListeners[sig] = () => {
|
|
410
|
+
const listeners = this.#process.listeners(sig);
|
|
411
|
+
let { count } = this.#emitter;
|
|
412
|
+
const p = process3;
|
|
413
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
414
|
+
count += p.__signal_exit_emitter__.count;
|
|
415
|
+
}
|
|
416
|
+
if (listeners.length === count) {
|
|
417
|
+
this.unload();
|
|
418
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
419
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
420
|
+
if (!ret)
|
|
421
|
+
process3.kill(process3.pid, s);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
this.#originalProcessReallyExit = process3.reallyExit;
|
|
426
|
+
this.#originalProcessEmit = process3.emit;
|
|
427
|
+
}
|
|
428
|
+
onExit(cb, opts) {
|
|
429
|
+
if (!processOk(this.#process)) {
|
|
430
|
+
return () => {};
|
|
431
|
+
}
|
|
432
|
+
if (this.#loaded === false) {
|
|
433
|
+
this.load();
|
|
434
|
+
}
|
|
435
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
436
|
+
this.#emitter.on(ev, cb);
|
|
437
|
+
return () => {
|
|
438
|
+
this.#emitter.removeListener(ev, cb);
|
|
439
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
440
|
+
this.unload();
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
load() {
|
|
445
|
+
if (this.#loaded) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this.#loaded = true;
|
|
449
|
+
this.#emitter.count += 1;
|
|
450
|
+
for (const sig of signals) {
|
|
451
|
+
try {
|
|
452
|
+
const fn = this.#sigListeners[sig];
|
|
453
|
+
if (fn)
|
|
454
|
+
this.#process.on(sig, fn);
|
|
455
|
+
} catch (_) {}
|
|
456
|
+
}
|
|
457
|
+
this.#process.emit = (ev, ...a) => {
|
|
458
|
+
return this.#processEmit(ev, ...a);
|
|
459
|
+
};
|
|
460
|
+
this.#process.reallyExit = (code) => {
|
|
461
|
+
return this.#processReallyExit(code);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
unload() {
|
|
465
|
+
if (!this.#loaded) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
this.#loaded = false;
|
|
469
|
+
signals.forEach((sig) => {
|
|
470
|
+
const listener = this.#sigListeners[sig];
|
|
471
|
+
if (!listener) {
|
|
472
|
+
throw new Error("Listener not defined for signal: " + sig);
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
this.#process.removeListener(sig, listener);
|
|
476
|
+
} catch (_) {}
|
|
477
|
+
});
|
|
478
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
479
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
480
|
+
this.#emitter.count -= 1;
|
|
481
|
+
}
|
|
482
|
+
#processReallyExit(code) {
|
|
483
|
+
if (!processOk(this.#process)) {
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
486
|
+
this.#process.exitCode = code || 0;
|
|
487
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
488
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
489
|
+
}
|
|
490
|
+
#processEmit(ev, ...args) {
|
|
491
|
+
const og = this.#originalProcessEmit;
|
|
492
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
493
|
+
if (typeof args[0] === "number") {
|
|
494
|
+
this.#process.exitCode = args[0];
|
|
495
|
+
}
|
|
496
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
497
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
498
|
+
return ret;
|
|
499
|
+
} else {
|
|
500
|
+
return og.call(this.#process, ev, ...args);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
var process3 = globalThis.process;
|
|
505
|
+
var {
|
|
506
|
+
onExit,
|
|
507
|
+
load,
|
|
508
|
+
unload
|
|
509
|
+
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
510
|
+
|
|
511
|
+
// node_modules/restore-cursor/index.js
|
|
512
|
+
var terminal = process4.stderr.isTTY ? process4.stderr : process4.stdout.isTTY ? process4.stdout : undefined;
|
|
513
|
+
var restoreCursor = terminal ? onetime_default(() => {
|
|
514
|
+
onExit(() => {
|
|
515
|
+
terminal.write("\x1B[?25h");
|
|
516
|
+
}, { alwaysLast: true });
|
|
517
|
+
}) : () => {};
|
|
518
|
+
var restore_cursor_default = restoreCursor;
|
|
519
|
+
|
|
520
|
+
// node_modules/cli-cursor/index.js
|
|
521
|
+
var isHidden = false;
|
|
522
|
+
var cliCursor = {};
|
|
523
|
+
cliCursor.show = (writableStream = process5.stderr) => {
|
|
524
|
+
if (!writableStream.isTTY) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
isHidden = false;
|
|
528
|
+
writableStream.write("\x1B[?25h");
|
|
529
|
+
};
|
|
530
|
+
cliCursor.hide = (writableStream = process5.stderr) => {
|
|
531
|
+
if (!writableStream.isTTY) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
restore_cursor_default();
|
|
535
|
+
isHidden = true;
|
|
536
|
+
writableStream.write("\x1B[?25l");
|
|
537
|
+
};
|
|
538
|
+
cliCursor.toggle = (force, writableStream) => {
|
|
539
|
+
if (force !== undefined) {
|
|
540
|
+
isHidden = force;
|
|
541
|
+
}
|
|
542
|
+
if (isHidden) {
|
|
543
|
+
cliCursor.show(writableStream);
|
|
544
|
+
} else {
|
|
545
|
+
cliCursor.hide(writableStream);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
var cli_cursor_default = cliCursor;
|
|
549
|
+
|
|
550
|
+
// node_modules/is-fullwidth-code-point/index.js
|
|
551
|
+
function isFullwidthCodePoint(codePoint) {
|
|
552
|
+
if (!Number.isInteger(codePoint)) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
return isFullwidth(codePoint) || isWide(codePoint);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// node_modules/log-update/node_modules/slice-ansi/tokenize-ansi.js
|
|
559
|
+
var ESCAPE_CODE_POINT = 27;
|
|
560
|
+
var C1_DCS_CODE_POINT = 144;
|
|
561
|
+
var C1_SOS_CODE_POINT = 152;
|
|
562
|
+
var C1_CSI_CODE_POINT = 155;
|
|
563
|
+
var C1_ST_CODE_POINT = 156;
|
|
564
|
+
var C1_OSC_CODE_POINT = 157;
|
|
565
|
+
var C1_PM_CODE_POINT = 158;
|
|
566
|
+
var C1_APC_CODE_POINT = 159;
|
|
567
|
+
var ESCAPES = new Set([
|
|
568
|
+
ESCAPE_CODE_POINT,
|
|
569
|
+
C1_DCS_CODE_POINT,
|
|
570
|
+
C1_SOS_CODE_POINT,
|
|
571
|
+
C1_CSI_CODE_POINT,
|
|
572
|
+
C1_ST_CODE_POINT,
|
|
573
|
+
C1_OSC_CODE_POINT,
|
|
574
|
+
C1_PM_CODE_POINT,
|
|
575
|
+
C1_APC_CODE_POINT
|
|
576
|
+
]);
|
|
577
|
+
var ESCAPE = "\x1B";
|
|
578
|
+
var ANSI_BELL = "\x07";
|
|
579
|
+
var ANSI_CSI = "[";
|
|
580
|
+
var ANSI_OSC = "]";
|
|
581
|
+
var ANSI_DCS = "P";
|
|
582
|
+
var ANSI_SOS = "X";
|
|
583
|
+
var ANSI_PM = "^";
|
|
584
|
+
var ANSI_APC = "_";
|
|
585
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
586
|
+
var ANSI_OSC_TERMINATOR = "\\";
|
|
587
|
+
var ANSI_STRING_TERMINATOR = `${ESCAPE}${ANSI_OSC_TERMINATOR}`;
|
|
588
|
+
var C1_OSC = "\x9D";
|
|
589
|
+
var C1_STRING_TERMINATOR = "\x9C";
|
|
590
|
+
var ANSI_HYPERLINK_ESC_PREFIX = `${ESCAPE}${ANSI_OSC}8;`;
|
|
591
|
+
var ANSI_HYPERLINK_C1_PREFIX = `${C1_OSC}8;`;
|
|
592
|
+
var ANSI_HYPERLINK_ESC_CLOSE = `${ANSI_HYPERLINK_ESC_PREFIX};`;
|
|
593
|
+
var ANSI_HYPERLINK_C1_CLOSE = `${ANSI_HYPERLINK_C1_PREFIX};`;
|
|
594
|
+
var CODE_POINT_0 = "0".codePointAt(0);
|
|
595
|
+
var CODE_POINT_9 = "9".codePointAt(0);
|
|
596
|
+
var CODE_POINT_SEMICOLON = ";".codePointAt(0);
|
|
597
|
+
var CODE_POINT_COLON = ":".codePointAt(0);
|
|
598
|
+
var CODE_POINT_CSI_PARAMETER_START = "0".codePointAt(0);
|
|
599
|
+
var CODE_POINT_CSI_PARAMETER_END = "?".codePointAt(0);
|
|
600
|
+
var CODE_POINT_CSI_INTERMEDIATE_START = " ".codePointAt(0);
|
|
601
|
+
var CODE_POINT_CSI_INTERMEDIATE_END = "/".codePointAt(0);
|
|
602
|
+
var CODE_POINT_CSI_FINAL_START = "@".codePointAt(0);
|
|
603
|
+
var CODE_POINT_CSI_FINAL_END = "~".codePointAt(0);
|
|
604
|
+
var REGIONAL_INDICATOR_SYMBOL_LETTER_A = 127462;
|
|
605
|
+
var REGIONAL_INDICATOR_SYMBOL_LETTER_Z = 127487;
|
|
606
|
+
var SGR_RESET_CODE = 0;
|
|
607
|
+
var SGR_EXTENDED_FOREGROUND_CODE = 38;
|
|
608
|
+
var SGR_DEFAULT_FOREGROUND_CODE = 39;
|
|
609
|
+
var SGR_EXTENDED_BACKGROUND_CODE = 48;
|
|
610
|
+
var SGR_DEFAULT_BACKGROUND_CODE = 49;
|
|
611
|
+
var SGR_COLOR_TYPE_ANSI_256 = 5;
|
|
612
|
+
var SGR_COLOR_TYPE_TRUECOLOR = 2;
|
|
613
|
+
var SGR_ANSI_256_FRAGMENT_LENGTH = 3;
|
|
614
|
+
var SGR_TRUECOLOR_FRAGMENT_LENGTH = 5;
|
|
615
|
+
var SGR_ANSI_256_LAST_PARAMETER_OFFSET = 2;
|
|
616
|
+
var SGR_TRUECOLOR_LAST_PARAMETER_OFFSET = 4;
|
|
617
|
+
var VARIATION_SELECTOR_16_CODE_POINT = 65039;
|
|
618
|
+
var COMBINING_ENCLOSING_KEYCAP_CODE_POINT = 8419;
|
|
619
|
+
var EMOJI_PRESENTATION_GRAPHEME_REGEX = /\p{Emoji_Presentation}/v;
|
|
620
|
+
var GRAPHEME_SEGMENTER = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
621
|
+
var endCodeNumbers = new Set;
|
|
622
|
+
for (const [, end] of ansi_styles_default.codes) {
|
|
623
|
+
endCodeNumbers.add(end);
|
|
624
|
+
}
|
|
625
|
+
function isSgrParameterCharacter(codePoint) {
|
|
626
|
+
return codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9 || codePoint === CODE_POINT_SEMICOLON || codePoint === CODE_POINT_COLON;
|
|
627
|
+
}
|
|
628
|
+
function isCsiParameterCharacter(codePoint) {
|
|
629
|
+
return codePoint >= CODE_POINT_CSI_PARAMETER_START && codePoint <= CODE_POINT_CSI_PARAMETER_END;
|
|
630
|
+
}
|
|
631
|
+
function isCsiIntermediateCharacter(codePoint) {
|
|
632
|
+
return codePoint >= CODE_POINT_CSI_INTERMEDIATE_START && codePoint <= CODE_POINT_CSI_INTERMEDIATE_END;
|
|
633
|
+
}
|
|
634
|
+
function isCsiFinalCharacter(codePoint) {
|
|
635
|
+
return codePoint >= CODE_POINT_CSI_FINAL_START && codePoint <= CODE_POINT_CSI_FINAL_END;
|
|
636
|
+
}
|
|
637
|
+
function isRegionalIndicatorCodePoint(codePoint) {
|
|
638
|
+
return codePoint >= REGIONAL_INDICATOR_SYMBOL_LETTER_A && codePoint <= REGIONAL_INDICATOR_SYMBOL_LETTER_Z;
|
|
639
|
+
}
|
|
640
|
+
function createControlParseResult(code, endIndex) {
|
|
641
|
+
return {
|
|
642
|
+
token: {
|
|
643
|
+
type: "control",
|
|
644
|
+
code
|
|
645
|
+
},
|
|
646
|
+
endIndex
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function isEmojiStyleGrapheme(grapheme) {
|
|
650
|
+
if (EMOJI_PRESENTATION_GRAPHEME_REGEX.test(grapheme)) {
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
for (const character of grapheme) {
|
|
654
|
+
const codePoint = character.codePointAt(0);
|
|
655
|
+
if (codePoint === VARIATION_SELECTOR_16_CODE_POINT || codePoint === COMBINING_ENCLOSING_KEYCAP_CODE_POINT) {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
661
|
+
function getGraphemeWidth(grapheme) {
|
|
662
|
+
let regionalIndicatorCount = 0;
|
|
663
|
+
for (const character of grapheme) {
|
|
664
|
+
const codePoint = character.codePointAt(0);
|
|
665
|
+
if (isFullwidthCodePoint(codePoint)) {
|
|
666
|
+
return 2;
|
|
667
|
+
}
|
|
668
|
+
if (isRegionalIndicatorCodePoint(codePoint)) {
|
|
669
|
+
regionalIndicatorCount++;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
if (regionalIndicatorCount >= 1) {
|
|
673
|
+
return 2;
|
|
674
|
+
}
|
|
675
|
+
if (isEmojiStyleGrapheme(grapheme)) {
|
|
676
|
+
return 2;
|
|
677
|
+
}
|
|
678
|
+
return 1;
|
|
679
|
+
}
|
|
680
|
+
function getSgrPrefix(code) {
|
|
681
|
+
if (code.startsWith("\x9B")) {
|
|
682
|
+
return "\x9B";
|
|
683
|
+
}
|
|
684
|
+
return `${ESCAPE}${ANSI_CSI}`;
|
|
685
|
+
}
|
|
686
|
+
function createSgrCode(prefix, values) {
|
|
687
|
+
return `${prefix}${values.join(";")}${ANSI_SGR_TERMINATOR}`;
|
|
688
|
+
}
|
|
689
|
+
function getSgrFragments(code) {
|
|
690
|
+
const fragments = [];
|
|
691
|
+
const sgrPrefix = getSgrPrefix(code);
|
|
692
|
+
let parameterString;
|
|
693
|
+
if (code.startsWith(`${ESCAPE}${ANSI_CSI}`)) {
|
|
694
|
+
parameterString = code.slice(2, -1);
|
|
695
|
+
} else if (code.startsWith("\x9B")) {
|
|
696
|
+
parameterString = code.slice(1, -1);
|
|
697
|
+
} else {
|
|
698
|
+
return fragments;
|
|
699
|
+
}
|
|
700
|
+
const rawCodes = parameterString.length === 0 ? [String(SGR_RESET_CODE)] : parameterString.split(";");
|
|
701
|
+
let index = 0;
|
|
702
|
+
while (index < rawCodes.length) {
|
|
703
|
+
const codeNumber = Number.parseInt(rawCodes[index], 10);
|
|
704
|
+
if (Number.isNaN(codeNumber)) {
|
|
705
|
+
index++;
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (codeNumber === SGR_RESET_CODE) {
|
|
709
|
+
fragments.push({ type: "reset" });
|
|
710
|
+
index++;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (codeNumber === SGR_EXTENDED_FOREGROUND_CODE || codeNumber === SGR_EXTENDED_BACKGROUND_CODE) {
|
|
714
|
+
const colorType = Number.parseInt(rawCodes[index + 1], 10);
|
|
715
|
+
if (colorType === SGR_COLOR_TYPE_ANSI_256 && index + SGR_ANSI_256_LAST_PARAMETER_OFFSET < rawCodes.length) {
|
|
716
|
+
const openCode3 = createSgrCode(sgrPrefix, rawCodes.slice(index, index + SGR_ANSI_256_FRAGMENT_LENGTH));
|
|
717
|
+
fragments.push({
|
|
718
|
+
type: "start",
|
|
719
|
+
code: openCode3,
|
|
720
|
+
endCode: ansi_styles_default.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
721
|
+
});
|
|
722
|
+
index += SGR_ANSI_256_FRAGMENT_LENGTH;
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
if (colorType === SGR_COLOR_TYPE_TRUECOLOR && index + SGR_TRUECOLOR_LAST_PARAMETER_OFFSET < rawCodes.length) {
|
|
726
|
+
const openCode3 = createSgrCode(sgrPrefix, rawCodes.slice(index, index + SGR_TRUECOLOR_FRAGMENT_LENGTH));
|
|
727
|
+
fragments.push({
|
|
728
|
+
type: "start",
|
|
729
|
+
code: openCode3,
|
|
730
|
+
endCode: ansi_styles_default.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
731
|
+
});
|
|
732
|
+
index += SGR_TRUECOLOR_FRAGMENT_LENGTH;
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
const openCode2 = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
736
|
+
fragments.push({
|
|
737
|
+
type: "start",
|
|
738
|
+
code: openCode2,
|
|
739
|
+
endCode: ansi_styles_default.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
740
|
+
});
|
|
741
|
+
index++;
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (endCodeNumbers.has(codeNumber)) {
|
|
745
|
+
fragments.push({
|
|
746
|
+
type: "end",
|
|
747
|
+
endCode: ansi_styles_default.color.ansi(codeNumber)
|
|
748
|
+
});
|
|
749
|
+
index++;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
const mappedEndCode = ansi_styles_default.codes.get(codeNumber);
|
|
753
|
+
if (mappedEndCode !== undefined) {
|
|
754
|
+
const openCode2 = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
755
|
+
fragments.push({
|
|
756
|
+
type: "start",
|
|
757
|
+
code: openCode2,
|
|
758
|
+
endCode: ansi_styles_default.color.ansi(mappedEndCode)
|
|
759
|
+
});
|
|
760
|
+
index++;
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
const openCode = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
764
|
+
fragments.push({
|
|
765
|
+
type: "start",
|
|
766
|
+
code: openCode,
|
|
767
|
+
endCode: ansi_styles_default.reset.open
|
|
768
|
+
});
|
|
769
|
+
index++;
|
|
770
|
+
}
|
|
771
|
+
if (fragments.length === 0) {
|
|
772
|
+
fragments.push({ type: "reset" });
|
|
773
|
+
}
|
|
774
|
+
return fragments;
|
|
775
|
+
}
|
|
776
|
+
function parseCsiCode(string, index) {
|
|
777
|
+
const escapeCodePoint = string.codePointAt(index);
|
|
778
|
+
let sequenceStartIndex;
|
|
779
|
+
if (escapeCodePoint === ESCAPE_CODE_POINT) {
|
|
780
|
+
if (string[index + 1] !== ANSI_CSI) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
sequenceStartIndex = index + 2;
|
|
784
|
+
} else if (escapeCodePoint === C1_CSI_CODE_POINT) {
|
|
785
|
+
sequenceStartIndex = index + 1;
|
|
786
|
+
} else {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
let hasCanonicalSgrParameters = true;
|
|
790
|
+
for (let sequenceIndex = sequenceStartIndex;sequenceIndex < string.length; sequenceIndex++) {
|
|
791
|
+
const codePoint = string.codePointAt(sequenceIndex);
|
|
792
|
+
if (isCsiFinalCharacter(codePoint)) {
|
|
793
|
+
const code = string.slice(index, sequenceIndex + 1);
|
|
794
|
+
if (string[sequenceIndex] !== ANSI_SGR_TERMINATOR || !hasCanonicalSgrParameters) {
|
|
795
|
+
return createControlParseResult(code, sequenceIndex + 1);
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
token: {
|
|
799
|
+
type: "sgr",
|
|
800
|
+
code,
|
|
801
|
+
fragments: getSgrFragments(code)
|
|
802
|
+
},
|
|
803
|
+
endIndex: sequenceIndex + 1
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (isCsiParameterCharacter(codePoint)) {
|
|
807
|
+
if (!isSgrParameterCharacter(codePoint)) {
|
|
808
|
+
hasCanonicalSgrParameters = false;
|
|
809
|
+
}
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
if (isCsiIntermediateCharacter(codePoint)) {
|
|
813
|
+
hasCanonicalSgrParameters = false;
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
const endIndex = sequenceIndex;
|
|
817
|
+
return createControlParseResult(string.slice(index, endIndex), endIndex);
|
|
818
|
+
}
|
|
819
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
820
|
+
}
|
|
821
|
+
function parseHyperlinkCode(string, index) {
|
|
822
|
+
let hyperlinkPrefix;
|
|
823
|
+
let hyperlinkClose;
|
|
824
|
+
const codePoint = string.codePointAt(index);
|
|
825
|
+
if (codePoint === ESCAPE_CODE_POINT && string.startsWith(ANSI_HYPERLINK_ESC_PREFIX, index)) {
|
|
826
|
+
hyperlinkPrefix = ANSI_HYPERLINK_ESC_PREFIX;
|
|
827
|
+
hyperlinkClose = ANSI_HYPERLINK_ESC_CLOSE;
|
|
828
|
+
} else if (codePoint === C1_OSC_CODE_POINT && string.startsWith(ANSI_HYPERLINK_C1_PREFIX, index)) {
|
|
829
|
+
hyperlinkPrefix = ANSI_HYPERLINK_C1_PREFIX;
|
|
830
|
+
hyperlinkClose = ANSI_HYPERLINK_C1_CLOSE;
|
|
831
|
+
} else {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
const uriStart = string.indexOf(";", index + hyperlinkPrefix.length);
|
|
835
|
+
if (uriStart === -1) {
|
|
836
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
837
|
+
}
|
|
838
|
+
for (let sequenceIndex = uriStart + 1;sequenceIndex < string.length; sequenceIndex++) {
|
|
839
|
+
const character = string[sequenceIndex];
|
|
840
|
+
if (character === ANSI_BELL) {
|
|
841
|
+
const code = string.slice(index, sequenceIndex + 1);
|
|
842
|
+
const action = sequenceIndex === uriStart + 1 ? "close" : "open";
|
|
843
|
+
return {
|
|
844
|
+
token: {
|
|
845
|
+
type: "hyperlink",
|
|
846
|
+
code,
|
|
847
|
+
action,
|
|
848
|
+
closePrefix: hyperlinkClose,
|
|
849
|
+
terminator: ANSI_BELL
|
|
850
|
+
},
|
|
851
|
+
endIndex: sequenceIndex + 1
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
if (character === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) {
|
|
855
|
+
const code = string.slice(index, sequenceIndex + 2);
|
|
856
|
+
const action = sequenceIndex === uriStart + 1 ? "close" : "open";
|
|
857
|
+
return {
|
|
858
|
+
token: {
|
|
859
|
+
type: "hyperlink",
|
|
860
|
+
code,
|
|
861
|
+
action,
|
|
862
|
+
closePrefix: hyperlinkClose,
|
|
863
|
+
terminator: ANSI_STRING_TERMINATOR
|
|
864
|
+
},
|
|
865
|
+
endIndex: sequenceIndex + 2
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
if (character === C1_STRING_TERMINATOR) {
|
|
869
|
+
const code = string.slice(index, sequenceIndex + 1);
|
|
870
|
+
const action = sequenceIndex === uriStart + 1 ? "close" : "open";
|
|
871
|
+
return {
|
|
872
|
+
token: {
|
|
873
|
+
type: "hyperlink",
|
|
874
|
+
code,
|
|
875
|
+
action,
|
|
876
|
+
closePrefix: hyperlinkClose,
|
|
877
|
+
terminator: C1_STRING_TERMINATOR
|
|
878
|
+
},
|
|
879
|
+
endIndex: sequenceIndex + 1
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
884
|
+
}
|
|
885
|
+
function parseControlStringCode(string, index) {
|
|
886
|
+
const codePoint = string.codePointAt(index);
|
|
887
|
+
let sequenceStartIndex;
|
|
888
|
+
let supportsBellTerminator = false;
|
|
889
|
+
switch (codePoint) {
|
|
890
|
+
case ESCAPE_CODE_POINT: {
|
|
891
|
+
const command = string[index + 1];
|
|
892
|
+
switch (command) {
|
|
893
|
+
case ANSI_OSC: {
|
|
894
|
+
sequenceStartIndex = index + 2;
|
|
895
|
+
supportsBellTerminator = true;
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
case ANSI_DCS:
|
|
899
|
+
case ANSI_SOS:
|
|
900
|
+
case ANSI_PM:
|
|
901
|
+
case ANSI_APC: {
|
|
902
|
+
sequenceStartIndex = index + 2;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
case ANSI_OSC_TERMINATOR: {
|
|
906
|
+
return createControlParseResult(ANSI_STRING_TERMINATOR, index + 2);
|
|
907
|
+
}
|
|
908
|
+
default: {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
case C1_OSC_CODE_POINT: {
|
|
915
|
+
sequenceStartIndex = index + 1;
|
|
916
|
+
supportsBellTerminator = true;
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
case C1_DCS_CODE_POINT:
|
|
920
|
+
case C1_SOS_CODE_POINT:
|
|
921
|
+
case C1_PM_CODE_POINT:
|
|
922
|
+
case C1_APC_CODE_POINT: {
|
|
923
|
+
sequenceStartIndex = index + 1;
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
case C1_ST_CODE_POINT: {
|
|
927
|
+
return createControlParseResult(C1_STRING_TERMINATOR, index + 1);
|
|
928
|
+
}
|
|
929
|
+
default: {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
for (let sequenceIndex = sequenceStartIndex;sequenceIndex < string.length; sequenceIndex++) {
|
|
934
|
+
if (supportsBellTerminator && string[sequenceIndex] === ANSI_BELL) {
|
|
935
|
+
return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
|
|
936
|
+
}
|
|
937
|
+
if (string[sequenceIndex] === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) {
|
|
938
|
+
return createControlParseResult(string.slice(index, sequenceIndex + 2), sequenceIndex + 2);
|
|
939
|
+
}
|
|
940
|
+
if (string[sequenceIndex] === C1_STRING_TERMINATOR) {
|
|
941
|
+
return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
945
|
+
}
|
|
946
|
+
function parseAnsiCode(string, index) {
|
|
947
|
+
const codePoint = string.codePointAt(index);
|
|
948
|
+
if (codePoint === ESCAPE_CODE_POINT || codePoint === C1_OSC_CODE_POINT) {
|
|
949
|
+
const hyperlinkCode = parseHyperlinkCode(string, index);
|
|
950
|
+
if (hyperlinkCode) {
|
|
951
|
+
return hyperlinkCode;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
const controlStringCode = parseControlStringCode(string, index);
|
|
955
|
+
if (controlStringCode) {
|
|
956
|
+
return controlStringCode;
|
|
957
|
+
}
|
|
958
|
+
return parseCsiCode(string, index);
|
|
959
|
+
}
|
|
960
|
+
function appendTrailingAnsiTokens(string, index, tokens) {
|
|
961
|
+
while (index < string.length) {
|
|
962
|
+
const nextCodePoint = string.codePointAt(index);
|
|
963
|
+
if (!ESCAPES.has(nextCodePoint)) {
|
|
964
|
+
break;
|
|
965
|
+
}
|
|
966
|
+
const escapeCode = parseAnsiCode(string, index);
|
|
967
|
+
if (!escapeCode) {
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
tokens.push(escapeCode.token);
|
|
971
|
+
index = escapeCode.endIndex;
|
|
972
|
+
}
|
|
973
|
+
return index;
|
|
974
|
+
}
|
|
975
|
+
function parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments) {
|
|
976
|
+
const segment = graphemeSegments.containing(index);
|
|
977
|
+
if (!segment || segment.index !== index) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
token: {
|
|
982
|
+
type: "character",
|
|
983
|
+
value: segment.segment,
|
|
984
|
+
visibleWidth: getGraphemeWidth(segment.segment),
|
|
985
|
+
isGraphemeContinuation: false
|
|
986
|
+
},
|
|
987
|
+
endIndex: index + segment.segment.length
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function collectVisibleCharacters(string) {
|
|
991
|
+
const visibleCharacters = [];
|
|
992
|
+
let index = 0;
|
|
993
|
+
while (index < string.length) {
|
|
994
|
+
const codePoint = string.codePointAt(index);
|
|
995
|
+
if (ESCAPES.has(codePoint)) {
|
|
996
|
+
const code = parseAnsiCode(string, index);
|
|
997
|
+
if (code) {
|
|
998
|
+
index = code.endIndex;
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
const value = String.fromCodePoint(codePoint);
|
|
1003
|
+
visibleCharacters.push({
|
|
1004
|
+
value,
|
|
1005
|
+
visibleWidth: 1,
|
|
1006
|
+
isGraphemeContinuation: false
|
|
1007
|
+
});
|
|
1008
|
+
index += value.length;
|
|
1009
|
+
}
|
|
1010
|
+
return visibleCharacters;
|
|
1011
|
+
}
|
|
1012
|
+
function applyGraphemeMetadata(visibleCharacters) {
|
|
1013
|
+
if (visibleCharacters.length === 0) {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
const visibleString = visibleCharacters.map(({ value }) => value).join("");
|
|
1017
|
+
const scalarOffsets = [];
|
|
1018
|
+
let scalarOffset = 0;
|
|
1019
|
+
for (const visibleCharacter of visibleCharacters) {
|
|
1020
|
+
scalarOffsets.push(scalarOffset);
|
|
1021
|
+
scalarOffset += visibleCharacter.value.length;
|
|
1022
|
+
}
|
|
1023
|
+
let scalarIndex = 0;
|
|
1024
|
+
for (const segment of GRAPHEME_SEGMENTER.segment(visibleString)) {
|
|
1025
|
+
while (scalarIndex < visibleCharacters.length && scalarOffsets[scalarIndex] < segment.index) {
|
|
1026
|
+
scalarIndex++;
|
|
1027
|
+
}
|
|
1028
|
+
let graphemeIndex = scalarIndex;
|
|
1029
|
+
let isFirstInGrapheme = true;
|
|
1030
|
+
while (graphemeIndex < visibleCharacters.length && scalarOffsets[graphemeIndex] < segment.index + segment.segment.length) {
|
|
1031
|
+
visibleCharacters[graphemeIndex].visibleWidth = isFirstInGrapheme ? getGraphemeWidth(segment.segment) : 0;
|
|
1032
|
+
visibleCharacters[graphemeIndex].isGraphemeContinuation = !isFirstInGrapheme;
|
|
1033
|
+
isFirstInGrapheme = false;
|
|
1034
|
+
graphemeIndex++;
|
|
1035
|
+
}
|
|
1036
|
+
scalarIndex = graphemeIndex;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
|
|
1040
|
+
const tokens = [];
|
|
1041
|
+
const visibleCharacters = collectVisibleCharacters(string);
|
|
1042
|
+
applyGraphemeMetadata(visibleCharacters);
|
|
1043
|
+
let index = 0;
|
|
1044
|
+
let visibleCharacterIndex = 0;
|
|
1045
|
+
let visibleCount = 0;
|
|
1046
|
+
while (index < string.length) {
|
|
1047
|
+
const codePoint = string.codePointAt(index);
|
|
1048
|
+
if (ESCAPES.has(codePoint)) {
|
|
1049
|
+
const code = parseAnsiCode(string, index);
|
|
1050
|
+
if (code) {
|
|
1051
|
+
tokens.push(code.token);
|
|
1052
|
+
index = code.endIndex;
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
const value = String.fromCodePoint(codePoint);
|
|
1057
|
+
const visibleCharacter = visibleCharacters[visibleCharacterIndex];
|
|
1058
|
+
let visibleWidth = isFullwidthCodePoint(codePoint) ? 2 : value.length;
|
|
1059
|
+
if (visibleCharacter) {
|
|
1060
|
+
visibleWidth = visibleCharacter.visibleWidth;
|
|
1061
|
+
}
|
|
1062
|
+
const token = {
|
|
1063
|
+
type: "character",
|
|
1064
|
+
value,
|
|
1065
|
+
visibleWidth,
|
|
1066
|
+
isGraphemeContinuation: visibleCharacter ? visibleCharacter.isGraphemeContinuation : false
|
|
1067
|
+
};
|
|
1068
|
+
tokens.push(token);
|
|
1069
|
+
index += value.length;
|
|
1070
|
+
visibleCharacterIndex++;
|
|
1071
|
+
visibleCount += token.visibleWidth;
|
|
1072
|
+
if (visibleCount >= endCharacter) {
|
|
1073
|
+
const nextVisibleCharacter = visibleCharacters[visibleCharacterIndex];
|
|
1074
|
+
if (!nextVisibleCharacter || !nextVisibleCharacter.isGraphemeContinuation) {
|
|
1075
|
+
index = appendTrailingAnsiTokens(string, index, tokens);
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return tokens;
|
|
1081
|
+
}
|
|
1082
|
+
function areValuesInSameGrapheme(leftValue, rightValue) {
|
|
1083
|
+
const pair = `${leftValue}${rightValue}`;
|
|
1084
|
+
const splitIndex = leftValue.length;
|
|
1085
|
+
for (const segment of GRAPHEME_SEGMENTER.segment(pair)) {
|
|
1086
|
+
if (segment.index === splitIndex) {
|
|
1087
|
+
return false;
|
|
1088
|
+
}
|
|
1089
|
+
if (segment.index > splitIndex) {
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
function hasAnsiSplitContinuationAhead(string, startIndex, previousVisibleValue, graphemeSegments) {
|
|
1096
|
+
if (!previousVisibleValue) {
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
let index = startIndex;
|
|
1100
|
+
let hasAnsiCode = false;
|
|
1101
|
+
while (index < string.length) {
|
|
1102
|
+
const codePoint = string.codePointAt(index);
|
|
1103
|
+
if (ESCAPES.has(codePoint)) {
|
|
1104
|
+
const code = parseAnsiCode(string, index);
|
|
1105
|
+
if (code) {
|
|
1106
|
+
hasAnsiCode = true;
|
|
1107
|
+
index = code.endIndex;
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
if (!hasAnsiCode) {
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
const characterToken = parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments);
|
|
1115
|
+
if (!characterToken) {
|
|
1116
|
+
return true;
|
|
1117
|
+
}
|
|
1118
|
+
return areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value);
|
|
1119
|
+
}
|
|
1120
|
+
return false;
|
|
1121
|
+
}
|
|
1122
|
+
function tokenizeAnsi(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
|
|
1123
|
+
const tokens = [];
|
|
1124
|
+
const graphemeSegments = GRAPHEME_SEGMENTER.segment(string);
|
|
1125
|
+
let index = 0;
|
|
1126
|
+
let visibleCount = 0;
|
|
1127
|
+
let previousVisibleValue;
|
|
1128
|
+
let hasAnsiSinceLastVisible = false;
|
|
1129
|
+
while (index < string.length) {
|
|
1130
|
+
const codePoint = string.codePointAt(index);
|
|
1131
|
+
if (ESCAPES.has(codePoint)) {
|
|
1132
|
+
const code = parseAnsiCode(string, index);
|
|
1133
|
+
if (code) {
|
|
1134
|
+
tokens.push(code.token);
|
|
1135
|
+
index = code.endIndex;
|
|
1136
|
+
hasAnsiSinceLastVisible = true;
|
|
1137
|
+
continue;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
const characterToken = parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments);
|
|
1141
|
+
if (!characterToken) {
|
|
1142
|
+
return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
1143
|
+
}
|
|
1144
|
+
if (hasAnsiSinceLastVisible && previousVisibleValue && areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value)) {
|
|
1145
|
+
return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
1146
|
+
}
|
|
1147
|
+
tokens.push(characterToken.token);
|
|
1148
|
+
index = characterToken.endIndex;
|
|
1149
|
+
visibleCount += characterToken.token.visibleWidth;
|
|
1150
|
+
hasAnsiSinceLastVisible = false;
|
|
1151
|
+
previousVisibleValue = characterToken.token.value;
|
|
1152
|
+
if (visibleCount >= endCharacter) {
|
|
1153
|
+
if (hasAnsiSplitContinuationAhead(string, index, previousVisibleValue, graphemeSegments)) {
|
|
1154
|
+
return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
1155
|
+
}
|
|
1156
|
+
index = appendTrailingAnsiTokens(string, index, tokens);
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return tokens;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// node_modules/log-update/node_modules/slice-ansi/index.js
|
|
1164
|
+
function applySgrFragments(activeStyles, fragments) {
|
|
1165
|
+
for (const fragment of fragments) {
|
|
1166
|
+
switch (fragment.type) {
|
|
1167
|
+
case "reset": {
|
|
1168
|
+
activeStyles.clear();
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
case "end": {
|
|
1172
|
+
activeStyles.delete(fragment.endCode);
|
|
1173
|
+
break;
|
|
1174
|
+
}
|
|
1175
|
+
case "start": {
|
|
1176
|
+
activeStyles.delete(fragment.endCode);
|
|
1177
|
+
activeStyles.set(fragment.endCode, fragment.code);
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
default: {
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return activeStyles;
|
|
1186
|
+
}
|
|
1187
|
+
function undoAnsiCodes(activeStyles) {
|
|
1188
|
+
return [...activeStyles.keys()].toReversed().join("");
|
|
1189
|
+
}
|
|
1190
|
+
function closeHyperlink(hyperlinkToken) {
|
|
1191
|
+
return `${hyperlinkToken.closePrefix}${hyperlinkToken.terminator}`;
|
|
1192
|
+
}
|
|
1193
|
+
function shouldIncludeSgrAfterEnd(token, activeStyles) {
|
|
1194
|
+
let hasStartFragment = false;
|
|
1195
|
+
let hasClosingEffect = false;
|
|
1196
|
+
for (const fragment of token.fragments) {
|
|
1197
|
+
if (fragment.type === "start") {
|
|
1198
|
+
hasStartFragment = true;
|
|
1199
|
+
continue;
|
|
1200
|
+
}
|
|
1201
|
+
if (fragment.type === "reset" && activeStyles.size > 0) {
|
|
1202
|
+
hasClosingEffect = true;
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
if (fragment.type === "end" && activeStyles.has(fragment.endCode)) {
|
|
1206
|
+
hasClosingEffect = true;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return hasClosingEffect && !hasStartFragment;
|
|
1210
|
+
}
|
|
1211
|
+
function hasSgrStartFragment(token) {
|
|
1212
|
+
return token.fragments.some((fragment) => fragment.type === "start");
|
|
1213
|
+
}
|
|
1214
|
+
function discardPendingHyperlink(state) {
|
|
1215
|
+
if (state.activeHyperlink && !state.activeHyperlinkHasVisibleText && state.activeHyperlinkOutputIndex !== undefined) {
|
|
1216
|
+
const openCodeLength = state.activeHyperlink.code.length;
|
|
1217
|
+
state.returnValue = state.returnValue.slice(0, state.activeHyperlinkOutputIndex) + state.returnValue.slice(state.activeHyperlinkOutputIndex + openCodeLength);
|
|
1218
|
+
if (state.pendingSgrOutputIndex !== undefined && state.pendingSgrOutputIndex > state.activeHyperlinkOutputIndex) {
|
|
1219
|
+
state.pendingSgrOutputIndex -= openCodeLength;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
state.activeHyperlink = undefined;
|
|
1223
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
1224
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
1225
|
+
}
|
|
1226
|
+
function settleActiveHyperlink(state) {
|
|
1227
|
+
if (state.activeHyperlinkHasVisibleText) {
|
|
1228
|
+
state.returnValue += closeHyperlink(state.activeHyperlink);
|
|
1229
|
+
} else {
|
|
1230
|
+
discardPendingHyperlink(state);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
function applySgrToken(state) {
|
|
1234
|
+
if (state.isPastEnd && !shouldIncludeSgrAfterEnd(state.token, state.activeStyles)) {
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (state.include && hasSgrStartFragment(state.token) && state.pendingSgrOutputIndex === undefined) {
|
|
1238
|
+
state.pendingSgrOutputIndex = state.returnValue.length;
|
|
1239
|
+
state.pendingSgrActiveStyles = new Map(state.activeStyles);
|
|
1240
|
+
}
|
|
1241
|
+
state.activeStyles = applySgrFragments(state.activeStyles, state.token.fragments);
|
|
1242
|
+
if (state.include) {
|
|
1243
|
+
state.returnValue += state.token.code;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function applyHyperlinkToken(state) {
|
|
1247
|
+
if (state.isPastEnd && (state.token.action !== "close" || !state.activeHyperlink)) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
if (state.token.action === "open") {
|
|
1251
|
+
if (state.activeHyperlink) {
|
|
1252
|
+
settleActiveHyperlink(state);
|
|
1253
|
+
}
|
|
1254
|
+
state.activeHyperlink = state.token;
|
|
1255
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
1256
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
1257
|
+
if (state.include) {
|
|
1258
|
+
state.activeHyperlinkOutputIndex = state.returnValue.length;
|
|
1259
|
+
}
|
|
1260
|
+
} else if (state.token.action === "close") {
|
|
1261
|
+
if (state.include && state.activeHyperlink && !state.activeHyperlinkHasVisibleText) {
|
|
1262
|
+
discardPendingHyperlink(state);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
state.activeHyperlink = undefined;
|
|
1266
|
+
state.activeHyperlinkHasVisibleText = false;
|
|
1267
|
+
state.activeHyperlinkOutputIndex = undefined;
|
|
1268
|
+
}
|
|
1269
|
+
if (state.include) {
|
|
1270
|
+
state.returnValue += state.token.code;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
function applyControlToken(state) {
|
|
1274
|
+
if (!state.isPastEnd && state.include) {
|
|
1275
|
+
state.returnValue += state.token.code;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function applyCharacterToken(state) {
|
|
1279
|
+
if (!state.include && state.position >= state.start && !state.token.isGraphemeContinuation) {
|
|
1280
|
+
state.include = true;
|
|
1281
|
+
state.returnValue = [...state.activeStyles.values()].join("");
|
|
1282
|
+
if (state.activeHyperlink) {
|
|
1283
|
+
state.activeHyperlinkOutputIndex = state.returnValue.length;
|
|
1284
|
+
state.returnValue += state.activeHyperlink.code;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
if (state.include) {
|
|
1288
|
+
state.returnValue += state.token.value;
|
|
1289
|
+
state.pendingSgrOutputIndex = undefined;
|
|
1290
|
+
state.pendingSgrActiveStyles = undefined;
|
|
1291
|
+
if (state.activeHyperlink) {
|
|
1292
|
+
state.activeHyperlinkHasVisibleText = true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
state.position += state.token.visibleWidth;
|
|
1296
|
+
}
|
|
1297
|
+
var tokenHandlers = {
|
|
1298
|
+
sgr: applySgrToken,
|
|
1299
|
+
hyperlink: applyHyperlinkToken,
|
|
1300
|
+
control: applyControlToken,
|
|
1301
|
+
character: applyCharacterToken
|
|
1302
|
+
};
|
|
1303
|
+
function applyToken(state) {
|
|
1304
|
+
tokenHandlers[state.token.type]?.(state);
|
|
1305
|
+
}
|
|
1306
|
+
function createHasContinuationAheadMap(tokens) {
|
|
1307
|
+
const hasContinuationAhead = Array.from({ length: tokens.length }, () => false);
|
|
1308
|
+
let nextCharacterIsContinuation = false;
|
|
1309
|
+
for (let tokenIndex = tokens.length - 1;tokenIndex >= 0; tokenIndex--) {
|
|
1310
|
+
const token = tokens[tokenIndex];
|
|
1311
|
+
hasContinuationAhead[tokenIndex] = nextCharacterIsContinuation;
|
|
1312
|
+
if (token.type === "character") {
|
|
1313
|
+
nextCharacterIsContinuation = Boolean(token.isGraphemeContinuation);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return hasContinuationAhead;
|
|
1317
|
+
}
|
|
1318
|
+
function isPastEndBoundary(token, position, end) {
|
|
1319
|
+
if (end === undefined) {
|
|
1320
|
+
return false;
|
|
1321
|
+
}
|
|
1322
|
+
if (position >= end) {
|
|
1323
|
+
return true;
|
|
1324
|
+
}
|
|
1325
|
+
return token.type === "character" && !token.isGraphemeContinuation && position + token.visibleWidth > end;
|
|
1326
|
+
}
|
|
1327
|
+
function sliceAnsi(string, start, end) {
|
|
1328
|
+
const tokens = tokenizeAnsi(string, { endCharacter: end });
|
|
1329
|
+
const hasContinuationAhead = createHasContinuationAheadMap(tokens);
|
|
1330
|
+
const state = {
|
|
1331
|
+
start,
|
|
1332
|
+
token: undefined,
|
|
1333
|
+
isPastEnd: false,
|
|
1334
|
+
activeStyles: new Map,
|
|
1335
|
+
activeHyperlink: undefined,
|
|
1336
|
+
activeHyperlinkHasVisibleText: false,
|
|
1337
|
+
activeHyperlinkOutputIndex: undefined,
|
|
1338
|
+
pendingSgrOutputIndex: undefined,
|
|
1339
|
+
pendingSgrActiveStyles: undefined,
|
|
1340
|
+
position: 0,
|
|
1341
|
+
returnValue: "",
|
|
1342
|
+
include: false
|
|
1343
|
+
};
|
|
1344
|
+
for (const [tokenIndex, token] of tokens.entries()) {
|
|
1345
|
+
let isPastEnd = isPastEndBoundary(token, state.position, end);
|
|
1346
|
+
if (isPastEnd && token.type !== "character" && hasContinuationAhead[tokenIndex]) {
|
|
1347
|
+
isPastEnd = false;
|
|
1348
|
+
}
|
|
1349
|
+
if (isPastEnd && token.type === "character" && !token.isGraphemeContinuation) {
|
|
1350
|
+
if (state.activeHyperlink && !state.activeHyperlinkHasVisibleText) {
|
|
1351
|
+
discardPendingHyperlink(state);
|
|
1352
|
+
}
|
|
1353
|
+
if (state.pendingSgrOutputIndex !== undefined) {
|
|
1354
|
+
state.returnValue = state.returnValue.slice(0, state.pendingSgrOutputIndex);
|
|
1355
|
+
state.activeStyles = state.pendingSgrActiveStyles;
|
|
1356
|
+
state.pendingSgrOutputIndex = undefined;
|
|
1357
|
+
state.pendingSgrActiveStyles = undefined;
|
|
1358
|
+
}
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
state.token = token;
|
|
1362
|
+
state.isPastEnd = isPastEnd;
|
|
1363
|
+
applyToken(state);
|
|
1364
|
+
}
|
|
1365
|
+
if (!state.include) {
|
|
1366
|
+
return "";
|
|
1367
|
+
}
|
|
1368
|
+
if (state.activeHyperlink) {
|
|
1369
|
+
settleActiveHyperlink(state);
|
|
1370
|
+
}
|
|
1371
|
+
state.returnValue += undoAnsiCodes(state.activeStyles);
|
|
1372
|
+
return state.returnValue;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// node_modules/log-update/index.js
|
|
1376
|
+
var getWidth = (stream, defaultWidth) => stream.columns ?? defaultWidth ?? 80;
|
|
1377
|
+
var SYNCHRONIZED_OUTPUT_ENABLE = "\x1B[?2026h";
|
|
1378
|
+
var SYNCHRONIZED_OUTPUT_DISABLE = "\x1B[?2026l";
|
|
1379
|
+
var countLines = (text) => text.split(`
|
|
1380
|
+
`).length;
|
|
1381
|
+
var getFrameHeight = (text) => {
|
|
1382
|
+
const unstyledText = stripAnsi(text);
|
|
1383
|
+
return unstyledText === "" ? 0 : unstyledText.split(`
|
|
1384
|
+
`).length;
|
|
1385
|
+
};
|
|
1386
|
+
var fitToTerminalHeight = (stream, wrappedText, defaultHeight) => {
|
|
1387
|
+
const terminalHeight = stream.rows ?? defaultHeight ?? 24;
|
|
1388
|
+
if (terminalHeight === 0) {
|
|
1389
|
+
return { text: "", wasClipped: wrappedText !== "" };
|
|
1390
|
+
}
|
|
1391
|
+
const unstyled = stripAnsi(wrappedText);
|
|
1392
|
+
const lines = unstyled.split(`
|
|
1393
|
+
`);
|
|
1394
|
+
const toRemove = Math.max(0, lines.length - terminalHeight);
|
|
1395
|
+
if (toRemove === 0) {
|
|
1396
|
+
return { text: wrappedText, wasClipped: false };
|
|
1397
|
+
}
|
|
1398
|
+
let cut = 0;
|
|
1399
|
+
for (let index = 0;index < toRemove; index++) {
|
|
1400
|
+
cut += stringWidth(lines[index]) + 1;
|
|
1401
|
+
}
|
|
1402
|
+
let clippedText = sliceAnsi(wrappedText, cut);
|
|
1403
|
+
let clippedLineCount = getFrameHeight(clippedText);
|
|
1404
|
+
while (clippedLineCount > terminalHeight) {
|
|
1405
|
+
cut++;
|
|
1406
|
+
clippedText = sliceAnsi(wrappedText, cut);
|
|
1407
|
+
clippedLineCount = getFrameHeight(clippedText);
|
|
1408
|
+
}
|
|
1409
|
+
while (cut > 0) {
|
|
1410
|
+
const previousClippedText = sliceAnsi(wrappedText, cut - 1);
|
|
1411
|
+
if (getFrameHeight(previousClippedText) > terminalHeight) {
|
|
1412
|
+
break;
|
|
1413
|
+
}
|
|
1414
|
+
cut--;
|
|
1415
|
+
clippedText = previousClippedText;
|
|
1416
|
+
}
|
|
1417
|
+
return { text: clippedText, wasClipped: cut > 0 };
|
|
1418
|
+
};
|
|
1419
|
+
var diffFrames = (previousLines, nextLines) => {
|
|
1420
|
+
let start = 0;
|
|
1421
|
+
for (;start < previousLines.length && start < nextLines.length; start++) {
|
|
1422
|
+
if (previousLines[start] !== nextLines[start]) {
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
let endPrevious = previousLines.length - 1;
|
|
1427
|
+
let endNext = nextLines.length - 1;
|
|
1428
|
+
while (endPrevious >= start && endNext >= start && previousLines[endPrevious] === nextLines[endNext]) {
|
|
1429
|
+
endPrevious--;
|
|
1430
|
+
endNext--;
|
|
1431
|
+
}
|
|
1432
|
+
return { start, endPrevious, endNext };
|
|
1433
|
+
};
|
|
1434
|
+
var buildPatch = ({
|
|
1435
|
+
prevCount,
|
|
1436
|
+
start,
|
|
1437
|
+
endPrevious,
|
|
1438
|
+
endNext,
|
|
1439
|
+
nextLines,
|
|
1440
|
+
nextWrappedEndsWithNewline
|
|
1441
|
+
}) => {
|
|
1442
|
+
let sequence = "";
|
|
1443
|
+
const cursorLine = prevCount - 1;
|
|
1444
|
+
const cursorLineDelta = start - cursorLine;
|
|
1445
|
+
if (cursorLineDelta > 0) {
|
|
1446
|
+
sequence += exports_base.cursorDown(cursorLineDelta);
|
|
1447
|
+
}
|
|
1448
|
+
if (cursorLineDelta < 0) {
|
|
1449
|
+
sequence += exports_base.cursorUp(-cursorLineDelta);
|
|
1450
|
+
}
|
|
1451
|
+
sequence += exports_base.cursorLeft;
|
|
1452
|
+
const linesToClear = Math.max(0, endPrevious - start + 1);
|
|
1453
|
+
for (let index = 0;index < linesToClear; index++) {
|
|
1454
|
+
sequence += exports_base.eraseLine;
|
|
1455
|
+
if (index < linesToClear - 1) {
|
|
1456
|
+
sequence += exports_base.cursorDown();
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
if (linesToClear > 1) {
|
|
1460
|
+
sequence += exports_base.cursorUp(linesToClear - 1);
|
|
1461
|
+
}
|
|
1462
|
+
sequence += exports_base.cursorLeft;
|
|
1463
|
+
const wroteSlice = nextLines.slice(start, endNext + 1);
|
|
1464
|
+
let writtenLineBreakCount = 0;
|
|
1465
|
+
if (wroteSlice.length > 0) {
|
|
1466
|
+
const chunk = wroteSlice.join(`
|
|
1467
|
+
`);
|
|
1468
|
+
const shouldWriteTrailingNewline = nextWrappedEndsWithNewline && endNext < nextLines.length - 1 && !chunk.endsWith(`
|
|
1469
|
+
`);
|
|
1470
|
+
sequence += chunk;
|
|
1471
|
+
writtenLineBreakCount = countLines(chunk) - 1;
|
|
1472
|
+
sequence += exports_base.eraseEndLine;
|
|
1473
|
+
if (shouldWriteTrailingNewline) {
|
|
1474
|
+
sequence += `
|
|
1475
|
+
`;
|
|
1476
|
+
writtenLineBreakCount++;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
const currentLine = start + writtenLineBreakCount;
|
|
1480
|
+
const finalLine = nextLines.length - 1;
|
|
1481
|
+
const lineDelta = finalLine - currentLine;
|
|
1482
|
+
if (lineDelta > 0) {
|
|
1483
|
+
sequence += exports_base.cursorDown(lineDelta);
|
|
1484
|
+
}
|
|
1485
|
+
if (lineDelta < 0) {
|
|
1486
|
+
sequence += exports_base.cursorUp(-lineDelta);
|
|
1487
|
+
}
|
|
1488
|
+
return sequence;
|
|
1489
|
+
};
|
|
1490
|
+
function createLogUpdate(stream, { showCursor = false, defaultWidth, defaultHeight } = {}) {
|
|
1491
|
+
let previousLineCount = 0;
|
|
1492
|
+
let previousWidth = getWidth(stream, defaultWidth);
|
|
1493
|
+
let previousOutput = "";
|
|
1494
|
+
const useSynchronizedOutput = stream.isTTY === true;
|
|
1495
|
+
const write = (output) => {
|
|
1496
|
+
if (output === "") {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
if (useSynchronizedOutput) {
|
|
1500
|
+
stream.write(SYNCHRONIZED_OUTPUT_ENABLE + output + SYNCHRONIZED_OUTPUT_DISABLE);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
stream.write(output);
|
|
1504
|
+
};
|
|
1505
|
+
const computeFrame = (text, width, clipToHeight = true) => {
|
|
1506
|
+
const textString = String(text);
|
|
1507
|
+
const raw = textString.endsWith(`
|
|
1508
|
+
`) ? textString : `${textString}
|
|
1509
|
+
`;
|
|
1510
|
+
const wrapped = wrapAnsi(raw, width, { trim: false, hard: true, wordWrap: false });
|
|
1511
|
+
const { text: frameText, wasClipped } = clipToHeight ? fitToTerminalHeight(stream, wrapped, defaultHeight) : { text: wrapped, wasClipped: false };
|
|
1512
|
+
const lines = frameText === "" ? [] : frameText.split(`
|
|
1513
|
+
`);
|
|
1514
|
+
return { wrapped: frameText, lines, wasClipped };
|
|
1515
|
+
};
|
|
1516
|
+
const reset = () => {
|
|
1517
|
+
previousOutput = "";
|
|
1518
|
+
previousWidth = getWidth(stream, defaultWidth);
|
|
1519
|
+
previousLineCount = 0;
|
|
1520
|
+
};
|
|
1521
|
+
const render = (...arguments_) => {
|
|
1522
|
+
if (!showCursor) {
|
|
1523
|
+
cli_cursor_default.hide();
|
|
1524
|
+
}
|
|
1525
|
+
const width = getWidth(stream, defaultWidth);
|
|
1526
|
+
const { wrapped, lines, wasClipped } = computeFrame(arguments_.join(" "), width);
|
|
1527
|
+
if (lines.length === 0) {
|
|
1528
|
+
if (previousLineCount > 0) {
|
|
1529
|
+
write(exports_base.eraseLines(previousLineCount));
|
|
1530
|
+
}
|
|
1531
|
+
previousOutput = wrapped;
|
|
1532
|
+
previousWidth = width;
|
|
1533
|
+
previousLineCount = 0;
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
if (wrapped === previousOutput && previousWidth === width) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
if (previousLineCount === 0) {
|
|
1540
|
+
write(wrapped);
|
|
1541
|
+
previousOutput = wrapped;
|
|
1542
|
+
previousWidth = width;
|
|
1543
|
+
previousLineCount = lines.length;
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (previousWidth !== width || wasClipped) {
|
|
1547
|
+
write(exports_base.eraseLines(previousLineCount) + wrapped);
|
|
1548
|
+
previousOutput = wrapped;
|
|
1549
|
+
previousWidth = width;
|
|
1550
|
+
previousLineCount = lines.length;
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
const previousLines = previousOutput === "" ? [] : previousOutput.split(`
|
|
1554
|
+
`);
|
|
1555
|
+
let { start, endPrevious, endNext } = diffFrames(previousLines, lines);
|
|
1556
|
+
if (previousLines.length !== lines.length) {
|
|
1557
|
+
endPrevious = previousLines.length - 1;
|
|
1558
|
+
endNext = lines.length - 1;
|
|
1559
|
+
}
|
|
1560
|
+
if (start === lines.length && previousLineCount === lines.length) {
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
if (start === 0) {
|
|
1564
|
+
write(exports_base.eraseLines(previousLineCount) + wrapped);
|
|
1565
|
+
previousOutput = wrapped;
|
|
1566
|
+
previousWidth = width;
|
|
1567
|
+
previousLineCount = lines.length;
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
const patch = buildPatch({
|
|
1571
|
+
prevCount: previousLineCount,
|
|
1572
|
+
start,
|
|
1573
|
+
endPrevious,
|
|
1574
|
+
endNext,
|
|
1575
|
+
nextLines: lines,
|
|
1576
|
+
nextWrappedEndsWithNewline: wrapped.endsWith(`
|
|
1577
|
+
`)
|
|
1578
|
+
});
|
|
1579
|
+
write(patch);
|
|
1580
|
+
previousOutput = wrapped;
|
|
1581
|
+
previousWidth = width;
|
|
1582
|
+
previousLineCount = lines.length;
|
|
1583
|
+
};
|
|
1584
|
+
render.clear = () => {
|
|
1585
|
+
write(exports_base.eraseLines(previousLineCount));
|
|
1586
|
+
reset();
|
|
1587
|
+
};
|
|
1588
|
+
render.done = () => {
|
|
1589
|
+
reset();
|
|
1590
|
+
if (!showCursor) {
|
|
1591
|
+
cli_cursor_default.show();
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
render.persist = (...arguments_) => {
|
|
1595
|
+
const erasePrevious = previousLineCount > 0 ? exports_base.eraseLines(previousLineCount) : "";
|
|
1596
|
+
const width = getWidth(stream, defaultWidth);
|
|
1597
|
+
const { wrapped: wrappedText } = computeFrame(arguments_.join(" "), width, false);
|
|
1598
|
+
write(erasePrevious + wrappedText);
|
|
1599
|
+
reset();
|
|
1600
|
+
};
|
|
1601
|
+
return render;
|
|
1602
|
+
}
|
|
1603
|
+
var logUpdate = createLogUpdate(process6.stdout);
|
|
1604
|
+
var log_update_default = logUpdate;
|
|
1605
|
+
var logUpdateStderr = createLogUpdate(process6.stderr);
|
|
1606
|
+
export {
|
|
1607
|
+
logUpdateStderr,
|
|
1608
|
+
log_update_default as default,
|
|
1609
|
+
createLogUpdate
|
|
1610
|
+
};
|