@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +499 -313
- package/THIRD_PARTY_NOTICES.md +98 -23
- package/dist/Text-DV9CuzAT.d.ts +452 -0
- package/dist/ansi.d.ts +217 -0
- package/dist/ansi.js +87 -0
- package/dist/capabilities.d.ts +5 -0
- package/dist/capabilities.js +3 -0
- package/dist/cell-_ZVhbfl0.js +44 -0
- package/dist/color-CkbalRqK.js +2 -0
- package/dist/color-policy-BAC9-TZX.js +592 -0
- package/dist/color-policy-CCxuHIdD.d.ts +22 -0
- package/dist/color-profile-CyeHnG1T.d.ts +97 -0
- package/dist/color-profile-DHhQHY55.js +36 -0
- package/dist/color.d.ts +21 -0
- package/dist/color.js +3 -0
- package/dist/cursor-position-D2LAkRG0.d.ts +7 -0
- package/dist/detect-B3dL4Q11.js +374 -0
- package/dist/detect-Db6GbKOm.d.ts +195 -0
- package/dist/{devtools-QpCMm9JH.mjs → devtools-DbthxoD1.js} +23 -24
- package/dist/env-YVw64yZS.js +9 -0
- package/dist/escapes-CB_6CWOE.d.ts +72 -0
- package/dist/geometry-BxXOzJgo.d.ts +11 -0
- package/dist/index-D48vQhhe.d.ts +21 -0
- package/dist/index-DDVME65c.d.ts +919 -0
- package/dist/index.d.ts +1310 -0
- package/dist/index.js +3211 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +227 -0
- package/dist/jsx-runtime-XtwIVFsg.js +255 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/osc-BFKKSqpg.js +71 -0
- package/dist/osc-Cn0fw77g.d.ts +23 -0
- package/dist/paint-Cx-zC_sX.d.ts +81 -0
- package/dist/query-BNc2B8GD.d.ts +152 -0
- package/dist/react-CTZ_8dwh.js +1197 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +49 -0
- package/dist/router.d.ts +392 -0
- package/dist/router.js +711 -0
- package/dist/sample-Cqw1bjUL.js +445 -0
- package/dist/screen-CgC2WlVM.d.ts +49 -0
- package/dist/screen-CiPytswf.js +342 -0
- package/dist/screen.d.ts +5 -0
- package/dist/screen.js +5 -0
- package/dist/semantic-text-style-DIMzC7xt.js +91 -0
- package/dist/serialize-BTkAZgw1.js +79 -0
- package/dist/session-DDQ5V300.js +723 -0
- package/dist/sgr-BhwaWAJB.js +246 -0
- package/dist/store-C1P5fOUi.d.ts +72 -0
- package/dist/string-width-CijQwpIk.js +69 -0
- package/dist/strip-BvU4toXG.js +6 -0
- package/dist/terminal.d.ts +121 -0
- package/dist/terminal.js +2 -0
- package/dist/tokenize-AjqbvtiT.js +1242 -0
- package/dist/tokenize-Dx1y_l5H.d.ts +57 -0
- package/dist/truncate-D31fhU6i.js +562 -0
- package/dist/use-focus-B5npZrJU.js +18736 -0
- package/dist/yoga-5jKhYCJC.js +3465 -0
- package/dist/yoga.d.ts +2 -0
- package/dist/yoga.js +2 -0
- package/package.json +89 -29
- package/src/ansi/chalk.ts +138 -0
- package/src/ansi/cursor.ts +46 -0
- package/src/ansi/east-asian-width.ts +259 -0
- package/src/ansi/escapes.ts +120 -0
- package/src/ansi/graphemes.ts +8 -0
- package/src/ansi/hyperlink.ts +44 -0
- package/src/ansi/index.ts +27 -0
- package/src/ansi/osc.ts +77 -0
- package/src/ansi/sgr.ts +234 -0
- package/src/ansi/slice.ts +43 -0
- package/src/ansi/string-width.ts +121 -0
- package/src/ansi/strip.ts +13 -0
- package/src/ansi/tokenize.ts +380 -0
- package/src/ansi/truncate.ts +196 -0
- package/src/ansi/wrap.ts +765 -0
- package/src/ansi-tokenizer.ts +510 -0
- package/src/capabilities/color-policy.ts +34 -0
- package/src/capabilities/detect.ts +608 -0
- package/src/capabilities/index.ts +37 -0
- package/src/capabilities/query.ts +679 -0
- package/src/capabilities/store.ts +394 -0
- package/src/code-excerpt.ts +39 -0
- package/src/color/index.ts +3 -0
- package/src/color/paint.ts +169 -0
- package/src/color/palette.ts +48 -0
- package/src/color/sample.ts +323 -0
- package/src/color.ts +1 -0
- package/src/components/AccessibilityContext.ts +5 -0
- package/src/components/AnimationContext.ts +24 -0
- package/src/components/AnsiText.tsx +42 -0
- package/src/components/App.tsx +878 -0
- package/src/components/AppContext.ts +111 -0
- package/src/components/BackgroundContext.ts +7 -0
- package/src/components/Box.tsx +100 -0
- package/src/components/CursorContext.ts +19 -0
- package/src/components/ErrorBoundary.tsx +39 -0
- package/src/components/ErrorOverview.tsx +135 -0
- package/src/components/FocusContext.ts +30 -0
- package/src/components/Hyperlink.tsx +56 -0
- package/src/components/Newline.tsx +16 -0
- package/src/components/Spacer.tsx +11 -0
- package/src/components/Static.tsx +60 -0
- package/src/components/StderrContext.ts +24 -0
- package/src/components/StdinContext.ts +48 -0
- package/src/components/StdoutContext.ts +26 -0
- package/src/components/TerminalOscContext.ts +25 -0
- package/src/components/Text.tsx +122 -0
- package/src/components/Transform.tsx +38 -0
- package/src/components/VirtualList.tsx +128 -0
- package/src/cursor-position.ts +103 -0
- package/src/devtools.ts +103 -0
- package/src/dom.ts +301 -0
- package/src/env.ts +12 -0
- package/src/get-max-width.ts +11 -0
- package/src/global.d.ts +38 -0
- package/src/glyphs.ts +99 -0
- package/src/hooks/use-animation.ts +142 -0
- package/src/hooks/use-app.ts +8 -0
- package/src/hooks/use-box-metrics.ts +134 -0
- package/src/hooks/use-capabilities.ts +73 -0
- package/src/hooks/use-cursor.ts +33 -0
- package/src/hooks/use-focus-manager.ts +62 -0
- package/src/hooks/use-focus.ts +82 -0
- package/src/hooks/use-input.ts +267 -0
- package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
- package/src/hooks/use-paste.ts +78 -0
- package/src/hooks/use-stderr.ts +8 -0
- package/src/hooks/use-stdin.ts +10 -0
- package/src/hooks/use-stdout.ts +8 -0
- package/src/hooks/use-terminal-osc.ts +59 -0
- package/src/hooks/use-virtual-scroll.ts +84 -0
- package/src/hooks/use-window-size.ts +37 -0
- package/src/index.ts +96 -0
- package/src/ink.tsx +1452 -0
- package/src/input-parser.ts +303 -0
- package/src/instances.ts +9 -0
- package/src/jsx-dev-runtime.ts +3 -0
- package/src/jsx-runtime.ts +6 -0
- package/src/kitty-keyboard.ts +185 -0
- package/src/measure-element.ts +62 -0
- package/src/measure-text.ts +31 -0
- package/src/paint-tree.ts +220 -0
- package/src/parse-keypress.ts +515 -0
- package/src/parse-stack-line.ts +138 -0
- package/src/patch-console.ts +106 -0
- package/src/quick-lru.ts +85 -0
- package/src/react.ts +53 -0
- package/src/reconciler.ts +476 -0
- package/src/render-background.ts +59 -0
- package/src/render-border.ts +167 -0
- package/src/render-frame.ts +83 -0
- package/src/render-to-string.ts +146 -0
- package/src/render.ts +284 -0
- package/src/router/components.tsx +343 -0
- package/src/router/context.ts +41 -0
- package/src/router/history.ts +194 -0
- package/src/router/hooks.tsx +391 -0
- package/src/router/index.ts +34 -0
- package/src/router/matcher.ts +571 -0
- package/src/sanitize-ansi.ts +33 -0
- package/src/screen/ansi.ts +184 -0
- package/src/screen/canvas.ts +160 -0
- package/src/screen/cell.ts +138 -0
- package/src/screen/color-profile.ts +47 -0
- package/src/screen/geometry.ts +9 -0
- package/src/screen/index.ts +6 -0
- package/src/screen/screen.ts +305 -0
- package/src/screen/serialize.ts +129 -0
- package/src/screen.ts +1 -0
- package/src/semantic-text-style.ts +118 -0
- package/src/signal-exit.ts +106 -0
- package/src/squash-text-nodes.ts +37 -0
- package/src/stream.ts +28 -0
- package/src/structured-text.ts +325 -0
- package/src/styles.ts +753 -0
- package/src/terminal/index.ts +2 -0
- package/src/terminal/inline-presenter.ts +120 -0
- package/src/terminal/input.ts +92 -0
- package/src/terminal/render-scheduler.ts +37 -0
- package/src/terminal/screen-presenter.ts +242 -0
- package/src/terminal/session.ts +408 -0
- package/src/terminal-size.ts +58 -0
- package/src/terminal.ts +1 -0
- package/src/testing/browser.ts +588 -0
- package/src/testing/emulators.ts +205 -0
- package/src/testing/explorer-app/index.html +12 -0
- package/src/testing/explorer-app/main.ts +381 -0
- package/src/testing/explorer-app/style.css +194 -0
- package/src/testing/explorer-app/tsconfig.json +15 -0
- package/src/testing/explorer-app/vite-env.d.ts +1 -0
- package/src/testing/index.ts +26 -0
- package/src/testing/keys.ts +56 -0
- package/src/testing/live.ts +85 -0
- package/src/testing/matchers.ts +70 -0
- package/src/testing/public.ts +94 -0
- package/src/testing/terminal.ts +361 -0
- package/src/testing/vitest.ts +157 -0
- package/src/throttle.ts +73 -0
- package/src/transform-adapter.ts +14 -0
- package/src/types.ts +10 -0
- package/src/virtual-scroll.ts +133 -0
- package/src/wrap-text.ts +54 -0
- package/src/yoga/config.ts +57 -0
- package/src/yoga/core/absoluteLayout.ts +626 -0
- package/src/yoga/core/baseline.ts +66 -0
- package/src/yoga/core/cache.ts +136 -0
- package/src/yoga/core/calculateLayout.ts +2926 -0
- package/src/yoga/core/config.ts +104 -0
- package/src/yoga/core/flexLine.ts +177 -0
- package/src/yoga/core/helpers.ts +293 -0
- package/src/yoga/core/layoutResults.ts +167 -0
- package/src/yoga/core/node.ts +611 -0
- package/src/yoga/core/numeric.ts +44 -0
- package/src/yoga/core/pixelGrid.ts +151 -0
- package/src/yoga/core/style.ts +887 -0
- package/src/yoga/core/types.ts +224 -0
- package/src/yoga/generated/YGEnums.ts +263 -0
- package/src/yoga/index.ts +19 -0
- package/src/yoga/node.ts +1140 -0
- package/dist/index.d.mts +0 -2379
- package/dist/index.mjs +0 -10072
package/dist/ansi.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { i as ColorSupportLevel, n as ColorInfo } from "./detect-Db6GbKOm.js";
|
|
2
|
+
import { A as exitAlternativeScreen, C as enableBracketedPaste, D as eraseLines, E as eraseLine, F as popKittyKeyboard, I as pushKittyKeyboard, L as resetCursorColor, M as link, N as pasteEnd, O as eraseScreen, P as pasteStart, S as disableBracketedPaste, T as eraseEndLine, _ as cursorNextLine, a as CursorShape, b as cursorTo, c as OSC, d as bsu, f as clearTerminal, g as cursorLeft, h as cursorHide, i as CSI, j as kittyQuery, k as esu, l as ST, m as cursorDown, n as C1_CSI, o as DEL, p as cursorColor, r as C1_ST, s as ESC, t as BEL, u as ansiEscapes, v as cursorShape, w as enterAlternativeScreen, x as cursorUp, y as cursorShow } from "./escapes-CB_6CWOE.js";
|
|
3
|
+
import { a as queryClipboard, c as setTerminalProgress, d as tmuxPassthrough, i as notify, l as setWindowTitle, n as TerminalProgressState, o as setClipboard, r as clearClipboard, s as setPointerShape, t as ClipboardSelection, u as setWorkingDirectory } from "./osc-Cn0fw77g.js";
|
|
4
|
+
import { _ as tokenize, a as StyledChar, c as diffAnsiCodes, d as getLinkStartCode, f as isIntensityCode, g as styledCharsToString, h as styledCharsFromTokens, i as ControlToken, l as endCodesSet, m as reduceAnsiCodesIncremental, n as AnsiToken, o as Token, p as reduceAnsiCodes, r as CharToken, s as ansiCodesToString, t as AnsiCode, u as getEndCode, v as undoAnsiCodes } from "./tokenize-Dx1y_l5H.js";
|
|
5
|
+
//#region src/ansi/sgr.d.ts
|
|
6
|
+
type StylePair = {
|
|
7
|
+
readonly open: string;
|
|
8
|
+
readonly close: string;
|
|
9
|
+
};
|
|
10
|
+
declare const modifierCodes: {
|
|
11
|
+
readonly reset: readonly [0, 0];
|
|
12
|
+
readonly bold: readonly [1, 22];
|
|
13
|
+
readonly dim: readonly [2, 22];
|
|
14
|
+
readonly italic: readonly [3, 23];
|
|
15
|
+
readonly underline: readonly [4, 24];
|
|
16
|
+
readonly overline: readonly [53, 55];
|
|
17
|
+
readonly inverse: readonly [7, 27];
|
|
18
|
+
readonly hidden: readonly [8, 28];
|
|
19
|
+
readonly strikethrough: readonly [9, 29];
|
|
20
|
+
};
|
|
21
|
+
declare const colorCodes: {
|
|
22
|
+
readonly black: readonly [30, 39];
|
|
23
|
+
readonly red: readonly [31, 39];
|
|
24
|
+
readonly green: readonly [32, 39];
|
|
25
|
+
readonly yellow: readonly [33, 39];
|
|
26
|
+
readonly blue: readonly [34, 39];
|
|
27
|
+
readonly magenta: readonly [35, 39];
|
|
28
|
+
readonly cyan: readonly [36, 39];
|
|
29
|
+
readonly white: readonly [37, 39];
|
|
30
|
+
readonly blackBright: readonly [90, 39];
|
|
31
|
+
readonly gray: readonly [90, 39];
|
|
32
|
+
readonly grey: readonly [90, 39];
|
|
33
|
+
readonly redBright: readonly [91, 39];
|
|
34
|
+
readonly greenBright: readonly [92, 39];
|
|
35
|
+
readonly yellowBright: readonly [93, 39];
|
|
36
|
+
readonly blueBright: readonly [94, 39];
|
|
37
|
+
readonly magentaBright: readonly [95, 39];
|
|
38
|
+
readonly cyanBright: readonly [96, 39];
|
|
39
|
+
readonly whiteBright: readonly [97, 39];
|
|
40
|
+
};
|
|
41
|
+
declare const bgColorCodes: {
|
|
42
|
+
readonly bgBlack: readonly [40, 49];
|
|
43
|
+
readonly bgRed: readonly [41, 49];
|
|
44
|
+
readonly bgGreen: readonly [42, 49];
|
|
45
|
+
readonly bgYellow: readonly [43, 49];
|
|
46
|
+
readonly bgBlue: readonly [44, 49];
|
|
47
|
+
readonly bgMagenta: readonly [45, 49];
|
|
48
|
+
readonly bgCyan: readonly [46, 49];
|
|
49
|
+
readonly bgWhite: readonly [47, 49];
|
|
50
|
+
readonly bgBlackBright: readonly [100, 49];
|
|
51
|
+
readonly bgGray: readonly [100, 49];
|
|
52
|
+
readonly bgGrey: readonly [100, 49];
|
|
53
|
+
readonly bgRedBright: readonly [101, 49];
|
|
54
|
+
readonly bgGreenBright: readonly [102, 49];
|
|
55
|
+
readonly bgYellowBright: readonly [103, 49];
|
|
56
|
+
readonly bgBlueBright: readonly [104, 49];
|
|
57
|
+
readonly bgMagentaBright: readonly [105, 49];
|
|
58
|
+
readonly bgCyanBright: readonly [106, 49];
|
|
59
|
+
readonly bgWhiteBright: readonly [107, 49];
|
|
60
|
+
};
|
|
61
|
+
type ModifierName = keyof typeof modifierCodes;
|
|
62
|
+
type ForegroundColorName = keyof typeof colorCodes;
|
|
63
|
+
type BackgroundColorName = keyof typeof bgColorCodes;
|
|
64
|
+
type StyleName = ModifierName | ForegroundColorName | BackgroundColorName;
|
|
65
|
+
declare const modifierNames: ModifierName[];
|
|
66
|
+
declare const foregroundColorNames: ForegroundColorName[];
|
|
67
|
+
declare const backgroundColorNames: BackgroundColorName[];
|
|
68
|
+
/**
|
|
69
|
+
Named SGR styles as `{open, close}` escape sequence pairs.
|
|
70
|
+
*/
|
|
71
|
+
declare const styles: Record<StyleName, StylePair>;
|
|
72
|
+
/**
|
|
73
|
+
Raw SGR code numbers: open code → close code.
|
|
74
|
+
*/
|
|
75
|
+
declare const codes: ReadonlyMap<number, number>;
|
|
76
|
+
declare const foreground: {
|
|
77
|
+
close: string;
|
|
78
|
+
ansi: (code: number) => string;
|
|
79
|
+
ansi256: (code: number) => string;
|
|
80
|
+
ansi16m: (red: number, green: number, blue: number) => string;
|
|
81
|
+
};
|
|
82
|
+
declare const background: {
|
|
83
|
+
close: string;
|
|
84
|
+
ansi: (code: number) => string;
|
|
85
|
+
ansi256: (code: number) => string;
|
|
86
|
+
ansi16m: (red: number, green: number, blue: number) => string;
|
|
87
|
+
};
|
|
88
|
+
declare const rgbToAnsi256: (red: number, green: number, blue: number) => number;
|
|
89
|
+
declare const hexToRgb: (hex: string) => [number, number, number];
|
|
90
|
+
declare const hexToAnsi256: (hex: string) => number;
|
|
91
|
+
declare const ansi256ToAnsi: (code: number) => number;
|
|
92
|
+
declare const rgbToAnsi: (red: number, green: number, blue: number) => number;
|
|
93
|
+
declare const hexToAnsi: (hex: string) => number;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/ansi/chalk.d.ts
|
|
96
|
+
type StyleFunction = (text: string) => string;
|
|
97
|
+
type NamedStyles = Record<ModifierName | ForegroundColorName | BackgroundColorName, StyleFunction>;
|
|
98
|
+
type Chalk = NamedStyles & {
|
|
99
|
+
level: ColorSupportLevel;
|
|
100
|
+
hex: (color: string) => StyleFunction;
|
|
101
|
+
bgHex: (color: string) => StyleFunction;
|
|
102
|
+
rgb: (red: number, green: number, blue: number) => StyleFunction;
|
|
103
|
+
bgRgb: (red: number, green: number, blue: number) => StyleFunction;
|
|
104
|
+
ansi256: (code: number) => StyleFunction;
|
|
105
|
+
bgAnsi256: (code: number) => StyleFunction;
|
|
106
|
+
};
|
|
107
|
+
declare const chalk: Chalk;
|
|
108
|
+
declare const supportsColor: ColorInfo;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/ansi/hyperlink.d.ts
|
|
111
|
+
type HyperlinkOptions = {
|
|
112
|
+
/**
|
|
113
|
+
When the terminal does not support OSC 8 hyperlinks, append the URL in
|
|
114
|
+
parentheses after the text so it stays reachable. Set to `false` to
|
|
115
|
+
return the text alone.
|
|
116
|
+
|
|
117
|
+
@default true
|
|
118
|
+
*/
|
|
119
|
+
fallback?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
The stream the text will be written to, for support detection.
|
|
122
|
+
|
|
123
|
+
@default process.stdout
|
|
124
|
+
*/
|
|
125
|
+
stream?: {
|
|
126
|
+
isTTY?: boolean;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
Wraps text in a clickable OSC 8 hyperlink when the terminal supports it,
|
|
131
|
+
falling back to `text (url)`.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { hyperlink } from "@alchemy.run/sigil/ansi";
|
|
135
|
+
|
|
136
|
+
console.log(hyperlink("Documentation", "https://example.com"));
|
|
137
|
+
```
|
|
138
|
+
*/
|
|
139
|
+
declare const hyperlink: (text: string, url: string, { fallback, stream }?: HyperlinkOptions) => string;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/ansi/cursor.d.ts
|
|
142
|
+
type CursorStream = {
|
|
143
|
+
isTTY?: boolean;
|
|
144
|
+
write: (data: string) => unknown;
|
|
145
|
+
};
|
|
146
|
+
declare const cliCursor: {
|
|
147
|
+
show(writableStream?: CursorStream): void;
|
|
148
|
+
hide(writableStream?: CursorStream): void;
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/ansi/string-width.d.ts
|
|
152
|
+
declare const stringWidth: (input: string) => number;
|
|
153
|
+
declare const widestLine: (text: string) => number;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/ansi/east-asian-width.d.ts
|
|
156
|
+
type EastAsianWidthType = "ambiguous" | "fullwidth" | "halfwidth" | "narrow" | "neutral" | "wide";
|
|
157
|
+
declare const ambiguousMinimalCodePoint = 161;
|
|
158
|
+
declare const ambiguousMaximumCodePoint = 1114109;
|
|
159
|
+
declare const ambiguousRanges: readonly number[];
|
|
160
|
+
declare const fullwidthMinimalCodePoint = 12288;
|
|
161
|
+
declare const fullwidthMaximumCodePoint = 65510;
|
|
162
|
+
declare const fullwidthRanges: readonly number[];
|
|
163
|
+
declare const halfwidthMinimalCodePoint = 8361;
|
|
164
|
+
declare const halfwidthMaximumCodePoint = 65518;
|
|
165
|
+
declare const halfwidthRanges: readonly number[];
|
|
166
|
+
declare const narrowMinimalCodePoint = 32;
|
|
167
|
+
declare const narrowMaximumCodePoint = 10630;
|
|
168
|
+
declare const narrowRanges: readonly number[];
|
|
169
|
+
declare const wideMinimalCodePoint = 4352;
|
|
170
|
+
declare const wideMaximumCodePoint = 262141;
|
|
171
|
+
declare const wideRanges: readonly number[];
|
|
172
|
+
declare const isAmbiguous: (codePoint: number) => boolean;
|
|
173
|
+
declare const isFullWidth: (codePoint: number) => boolean;
|
|
174
|
+
declare const isWide: (codePoint: number) => boolean;
|
|
175
|
+
declare function getCategory(codePoint: number): EastAsianWidthType;
|
|
176
|
+
declare function eastAsianWidthType(codePoint: number): EastAsianWidthType;
|
|
177
|
+
declare function eastAsianWidth(codePoint: number, { ambiguousAsWide }?: {
|
|
178
|
+
ambiguousAsWide?: boolean;
|
|
179
|
+
}): 1 | 2;
|
|
180
|
+
/**
|
|
181
|
+
Grapheme-cluster width test shared by the tokenizer (slice/clip path): the
|
|
182
|
+
base code point's East Asian Width, plus emoji presentation rules.
|
|
183
|
+
*/
|
|
184
|
+
declare function isFullwidthGrapheme(grapheme: string, baseCodePoint: number): boolean;
|
|
185
|
+
/**
|
|
186
|
+
Wide code points not covered by string-width's CJKT script regex or emoji
|
|
187
|
+
regex — the fallback bucket of its block parser. A disjoint decomposition of
|
|
188
|
+
the `wide` table above, kept alongside it so the width data lives in one
|
|
189
|
+
module.
|
|
190
|
+
*/
|
|
191
|
+
declare const isWideNotCJKTNotEmoji: (x: number) => boolean;
|
|
192
|
+
declare function isFullwidthCodePoint(codePoint: number): boolean;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/ansi/strip.d.ts
|
|
195
|
+
declare const stripAnsi: (input: string) => string;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/ansi/slice.d.ts
|
|
198
|
+
declare function sliceAnsi(string: string, start: number, end?: number): string;
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/ansi/truncate.d.ts
|
|
201
|
+
type TruncateOptions = {
|
|
202
|
+
readonly position?: "start" | "middle" | "end";
|
|
203
|
+
readonly space?: boolean;
|
|
204
|
+
readonly preferTruncationOnSpace?: boolean;
|
|
205
|
+
readonly truncationCharacter?: string;
|
|
206
|
+
};
|
|
207
|
+
declare function cliTruncate(text: string, columns: number, options?: TruncateOptions): string;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/ansi/wrap.d.ts
|
|
210
|
+
type WrapOptions = {
|
|
211
|
+
readonly trim?: boolean;
|
|
212
|
+
readonly hard?: boolean;
|
|
213
|
+
readonly wordWrap?: boolean;
|
|
214
|
+
};
|
|
215
|
+
declare function wrapAnsi(string: string, columns: number, options?: WrapOptions): string;
|
|
216
|
+
//#endregion
|
|
217
|
+
export { AnsiCode, AnsiToken, BEL, BackgroundColorName, C1_CSI, C1_ST, CSI, CharToken, ClipboardSelection, ControlToken, CursorShape, DEL, ESC, EastAsianWidthType, ForegroundColorName, ModifierName, OSC, ST, StyleName, StylePair, StyledChar, TerminalProgressState, Token, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, background, backgroundColorNames, bsu, chalk, clearClipboard, clearTerminal, cliCursor, codes, cursorColor, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShape, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, hyperlink, isAmbiguous, isFullWidth, isFullwidthCodePoint, isFullwidthGrapheme, isIntensityCode, isWide, isWideNotCJKTNotEmoji, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, notify, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, queryClipboard, reduceAnsiCodes, reduceAnsiCodesIncremental, resetCursorColor, rgbToAnsi, rgbToAnsi256, setClipboard, setPointerShape, setTerminalProgress, setWindowTitle, setWorkingDirectory, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tmuxPassthrough, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
|
package/dist/ansi.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { A as cursorShape, B as eraseScreen, C as bsu, D as cursorHide, E as cursorDown, F as enableBracketedPaste, G as pasteEnd, H as exitAlternativeScreen, I as enterAlternativeScreen, J as pushKittyKeyboard, K as pasteStart, L as eraseEndLine, M as cursorTo, N as cursorUp, O as cursorLeft, P as disableBracketedPaste, R as eraseLine, S as ansiEscapes, T as cursorColor, U as kittyQuery, V as esu, W as link, Y as resetCursorColor, _ as CSI, a as foreground, b as OSC, c as hexToAnsi256, d as rgbToAnsi, f as rgbToAnsi256, g as C1_ST, h as C1_CSI, i as codes, j as cursorShow, k as cursorNextLine, l as hexToRgb, m as BEL, n as background, o as foregroundColorNames, p as styles, q as popKittyKeyboard, r as backgroundColorNames, s as hexToAnsi, t as ansi256ToAnsi, u as modifierNames, v as DEL, w as clearTerminal, x as ST, y as ESC, z as eraseLines } from "./sgr-BhwaWAJB.js";
|
|
2
|
+
import { A as isFullwidthCodePoint, C as fullwidthRanges, D as halfwidthRanges, E as halfwidthMinimalCodePoint, F as narrowMinimalCodePoint, I as narrowRanges, L as wideMaximumCodePoint, M as isWide, N as isWideNotCJKTNotEmoji, O as isAmbiguous, P as narrowMaximumCodePoint, R as wideMinimalCodePoint, S as fullwidthMinimalCodePoint, T as halfwidthMaximumCodePoint, _ as ambiguousMinimalCodePoint, a as getLinkStartCode, b as eastAsianWidthType, c as reduceAnsiCodesIncremental, d as tokenize, f as undoAnsiCodes, g as ambiguousMaximumCodePoint, i as getEndCode, j as isFullwidthGrapheme, k as isFullWidth, l as styledCharsFromTokens, n as diffAnsiCodes, o as isIntensityCode, r as endCodesSet, s as reduceAnsiCodes, t as ansiCodesToString, u as styledCharsToString, v as ambiguousRanges, w as getCategory, x as fullwidthMaximumCodePoint, y as eastAsianWidth, z as wideRanges } from "./tokenize-AjqbvtiT.js";
|
|
3
|
+
import { n as widestLine, t as stringWidth } from "./string-width-CijQwpIk.js";
|
|
4
|
+
import { n as sliceAnsi, r as wrapAnsi, t as cliTruncate } from "./truncate-D31fhU6i.js";
|
|
5
|
+
import { i as detectHyperlinkSupport, t as createSupportsColor } from "./detect-B3dL4Q11.js";
|
|
6
|
+
import { a as setPointerShape, c as setWorkingDirectory, i as setClipboard, l as tmuxPassthrough, n as notify, o as setTerminalProgress, r as queryClipboard, s as setWindowTitle, t as clearClipboard, u as cliCursor } from "./osc-BFKKSqpg.js";
|
|
7
|
+
import { t as stripAnsi } from "./strip-BvU4toXG.js";
|
|
8
|
+
import { isatty } from "node:tty";
|
|
9
|
+
//#region src/ansi/chalk.ts
|
|
10
|
+
const stdoutColor = createSupportsColor({ isTTY: isatty(1) });
|
|
11
|
+
const levelMapping = [
|
|
12
|
+
"ansi",
|
|
13
|
+
"ansi",
|
|
14
|
+
"ansi256",
|
|
15
|
+
"ansi16m"
|
|
16
|
+
];
|
|
17
|
+
const state = { level: stdoutColor ? stdoutColor.level : 0 };
|
|
18
|
+
const applyStyle = (open, close, text) => {
|
|
19
|
+
if (state.level <= 0 || !text) return text;
|
|
20
|
+
let string = text;
|
|
21
|
+
if (string.includes("\x1B")) string = string.replaceAll(close, close + open);
|
|
22
|
+
if (string.includes("\n")) string = string.replaceAll(/\r?\n/g, `${close}$&${open}`);
|
|
23
|
+
return open + string + close;
|
|
24
|
+
};
|
|
25
|
+
const styleFunction = (open, close) => {
|
|
26
|
+
return (text) => applyStyle(open, close, text);
|
|
27
|
+
};
|
|
28
|
+
const foregroundOpen = (model, args) => {
|
|
29
|
+
return colorOpen(model, args, foreground, rgbToAnsi256, rgbToAnsi);
|
|
30
|
+
};
|
|
31
|
+
const backgroundOpen = (model, args) => {
|
|
32
|
+
return colorOpen(model, args, background, rgbToAnsi256, rgbToAnsi);
|
|
33
|
+
};
|
|
34
|
+
const colorOpen = (model, args, space, toAnsi256, toAnsi) => {
|
|
35
|
+
const rgb = typeof args[0] === "string" ? hexToRgb(args[0]) : args;
|
|
36
|
+
if (model === "ansi16m") return space.ansi16m(...rgb);
|
|
37
|
+
if (model === "ansi256") return space.ansi256(toAnsi256(...rgb));
|
|
38
|
+
return space.ansi(toAnsi(...rgb));
|
|
39
|
+
};
|
|
40
|
+
const named = {};
|
|
41
|
+
for (const name of [
|
|
42
|
+
...modifierNames,
|
|
43
|
+
...foregroundColorNames,
|
|
44
|
+
...backgroundColorNames
|
|
45
|
+
]) named[name] = styleFunction(styles[name].open, styles[name].close);
|
|
46
|
+
const chalk = {
|
|
47
|
+
...named,
|
|
48
|
+
get level() {
|
|
49
|
+
return state.level;
|
|
50
|
+
},
|
|
51
|
+
set level(level) {
|
|
52
|
+
state.level = level;
|
|
53
|
+
},
|
|
54
|
+
hex: (color) => styleFunction(foregroundOpen(levelMapping[state.level], [color]), foreground.close),
|
|
55
|
+
bgHex: (color) => styleFunction(backgroundOpen(levelMapping[state.level], [color]), background.close),
|
|
56
|
+
rgb: (red, green, blue) => styleFunction(foregroundOpen(levelMapping[state.level], [
|
|
57
|
+
red,
|
|
58
|
+
green,
|
|
59
|
+
blue
|
|
60
|
+
]), foreground.close),
|
|
61
|
+
bgRgb: (red, green, blue) => styleFunction(backgroundOpen(levelMapping[state.level], [
|
|
62
|
+
red,
|
|
63
|
+
green,
|
|
64
|
+
blue
|
|
65
|
+
]), background.close),
|
|
66
|
+
ansi256: (code) => styleFunction(foreground.ansi256(code), foreground.close),
|
|
67
|
+
bgAnsi256: (code) => styleFunction(background.ansi256(code), background.close)
|
|
68
|
+
};
|
|
69
|
+
const supportsColor = stdoutColor;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/ansi/hyperlink.ts
|
|
72
|
+
/**
|
|
73
|
+
Wraps text in a clickable OSC 8 hyperlink when the terminal supports it,
|
|
74
|
+
falling back to `text (url)`.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { hyperlink } from "@alchemy.run/sigil/ansi";
|
|
78
|
+
|
|
79
|
+
console.log(hyperlink("Documentation", "https://example.com"));
|
|
80
|
+
```
|
|
81
|
+
*/
|
|
82
|
+
const hyperlink = (text, url, { fallback = true, stream = process.stdout } = {}) => {
|
|
83
|
+
if (detectHyperlinkSupport(stream)) return link(text, url);
|
|
84
|
+
return fallback ? `${text} (${url})` : text;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { BEL, C1_CSI, C1_ST, CSI, DEL, ESC, OSC, ST, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, background, backgroundColorNames, bsu, chalk, clearClipboard, clearTerminal, cliCursor, codes, cursorColor, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShape, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, hyperlink, isAmbiguous, isFullWidth, isFullwidthCodePoint, isFullwidthGrapheme, isIntensityCode, isWide, isWideNotCJKTNotEmoji, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, notify, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, queryClipboard, reduceAnsiCodes, reduceAnsiCodesIncremental, resetCursorColor, rgbToAnsi, rgbToAnsi256, setClipboard, setPointerShape, setTerminalProgress, setWindowTitle, setWorkingDirectory, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tmuxPassthrough, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as Multiplexer, c as TerminalAppearance, d as detectCapabilities, f as detectColorLevel, h as detectUnicodeSupport, i as ColorSupportLevel, l as TerminalIdentity, m as detectTerminal, n as ColorInfo, o as PixelGeometry, p as detectHyperlinkSupport, r as ColorSupport, s as RgbColor, t as Capabilities, u as createSupportsColor } from "./detect-Db6GbKOm.js";
|
|
2
|
+
import { a as getTerminalQuery, i as applyTerminalQuery, n as TerminalQueryOptions, o as queryTerminal, r as TerminalQueryResult, s as refreshTerminalQuery, t as PixelSize } from "./query-BNc2B8GD.js";
|
|
3
|
+
import { n as capabilities, r as getCapabilities, t as CapabilitiesStore } from "./store-C1P5fOUi.js";
|
|
4
|
+
import { i as resolveColorProfile, n as ColorState, r as colorState, t as ColorPolicy } from "./color-policy-CCxuHIdD.js";
|
|
5
|
+
export { type Capabilities, type CapabilitiesStore, type ColorInfo, type ColorPolicy, type ColorState, type ColorSupport, type ColorSupportLevel, type Multiplexer, type PixelGeometry, type PixelSize, type RgbColor, type TerminalAppearance, type TerminalIdentity, type TerminalQueryOptions, type TerminalQueryResult, applyTerminalQuery, capabilities, colorState, createSupportsColor, detectCapabilities, detectColorLevel, detectHyperlinkSupport, detectTerminal, detectUnicodeSupport, getCapabilities, getTerminalQuery, queryTerminal, refreshTerminalQuery, resolveColorProfile };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as detectTerminal, i as detectHyperlinkSupport, n as detectCapabilities, o as detectUnicodeSupport, r as detectColorLevel, t as createSupportsColor } from "./detect-B3dL4Q11.js";
|
|
2
|
+
import { f as queryTerminal, i as getCapabilities, l as getTerminalQuery, n as resolveColorProfile, p as refreshTerminalQuery, r as capabilities, s as applyTerminalQuery, t as colorState } from "./color-policy-BAC9-TZX.js";
|
|
3
|
+
export { applyTerminalQuery, capabilities, colorState, createSupportsColor, detectCapabilities, detectColorLevel, detectHyperlinkSupport, detectTerminal, detectUnicodeSupport, getCapabilities, getTerminalQuery, queryTerminal, refreshTerminalQuery, resolveColorProfile };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/screen/cell.ts
|
|
2
|
+
/**
|
|
3
|
+
Bit flags for terminal text attributes. Multiple attributes may be combined.
|
|
4
|
+
*/
|
|
5
|
+
const cellAttributes = {
|
|
6
|
+
none: 0,
|
|
7
|
+
bold: 1,
|
|
8
|
+
faint: 2,
|
|
9
|
+
italic: 4,
|
|
10
|
+
blink: 8,
|
|
11
|
+
rapidBlink: 16,
|
|
12
|
+
inverse: 32,
|
|
13
|
+
hidden: 64,
|
|
14
|
+
strikethrough: 128
|
|
15
|
+
};
|
|
16
|
+
const emptyCellStyle = {
|
|
17
|
+
underline: "none",
|
|
18
|
+
attributes: cellAttributes.none
|
|
19
|
+
};
|
|
20
|
+
const emptyCell = {
|
|
21
|
+
grapheme: " ",
|
|
22
|
+
width: 1,
|
|
23
|
+
style: emptyCellStyle
|
|
24
|
+
};
|
|
25
|
+
const createCell = (grapheme, width, style = emptyCellStyle, hyperlink, reset) => {
|
|
26
|
+
if (grapheme.length === 0) throw new Error("A cell must contain one grapheme cluster");
|
|
27
|
+
if (!Number.isInteger(width) || width < 1) throw new Error("A cell width must be a positive integer");
|
|
28
|
+
return {
|
|
29
|
+
grapheme,
|
|
30
|
+
width,
|
|
31
|
+
style,
|
|
32
|
+
...hyperlink ? { hyperlink } : {},
|
|
33
|
+
...reset ? { reset } : {}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const cellsEqual = (left, right) => {
|
|
37
|
+
if (left === right) return true;
|
|
38
|
+
if (!left || !right || left.grapheme !== right.grapheme || left.width !== right.width) return false;
|
|
39
|
+
const leftStyle = left.style;
|
|
40
|
+
const rightStyle = right.style;
|
|
41
|
+
return leftStyle.attributes === rightStyle.attributes && leftStyle.underline === rightStyle.underline && JSON.stringify(leftStyle.foreground) === JSON.stringify(rightStyle.foreground) && JSON.stringify(leftStyle.background) === JSON.stringify(rightStyle.background) && JSON.stringify(leftStyle.underlineColor) === JSON.stringify(rightStyle.underlineColor) && JSON.stringify(left.hyperlink) === JSON.stringify(right.hyperlink);
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { emptyCellStyle as a, emptyCell as i, cellsEqual as n, createCell as r, cellAttributes as t };
|