@alchemy.run/sigil 0.0.0-alpha.4 → 0.0.0-alpha.6
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 +21 -9
- package/THIRD_PARTY_NOTICES.md +39 -1
- package/dist/Text-BobFKi74.d.ts +452 -0
- package/dist/ansi.d.ts +122 -131
- package/dist/ansi.js +86 -6
- 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-BMzMwV7Q.d.ts +22 -0
- package/dist/color-policy-SVj1pYTA.js +560 -0
- package/dist/color-profile-DHhQHY55.js +36 -0
- package/dist/color-profile-u0Nhe9Nv.d.ts +97 -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-Bh4yGP6w.d.ts +186 -0
- package/dist/detect-BuTXtY6e.js +373 -0
- 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-DZ88EXJv.d.ts +21 -0
- package/dist/index.d.ts +143 -498
- package/dist/index.js +1026 -2244
- package/dist/osc-CCH7xDoS.js +71 -0
- package/dist/osc-Cn0fw77g.d.ts +23 -0
- package/dist/paint-C19minOS.d.ts +81 -0
- package/dist/query-vaIeGOkH.d.ts +152 -0
- package/dist/router.d.ts +392 -0
- package/dist/router.js +709 -0
- package/dist/sample-Cqw1bjUL.js +445 -0
- package/dist/screen-BOSLQ8fF.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-aZr9O8h3.js +665 -0
- package/dist/sgr-BhwaWAJB.js +246 -0
- package/dist/store-CgrG9K4y.d.ts +72 -0
- package/dist/string-width-CijQwpIk.js +69 -0
- package/dist/strip-BvU4toXG.js +6 -0
- package/dist/terminal.d.ts +118 -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-BzqAJi0n.js +1337 -0
- package/package.json +41 -9
- package/src/ansi/chalk.ts +5 -3
- package/src/ansi/escapes.ts +14 -0
- package/src/ansi/graphemes.ts +8 -0
- package/src/ansi/hyperlink.ts +44 -0
- package/src/ansi/index.ts +3 -1
- package/src/ansi/osc.ts +77 -0
- package/src/ansi/tokenize.ts +3 -4
- package/src/capabilities/color-policy.ts +34 -0
- package/src/capabilities/detect.ts +594 -0
- package/src/capabilities/index.ts +37 -0
- package/src/capabilities/query.ts +657 -0
- package/src/capabilities/store.ts +379 -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/AnsiText.tsx +42 -0
- package/src/components/App.tsx +98 -10
- package/src/components/BackgroundContext.ts +2 -3
- package/src/components/Box.tsx +0 -8
- package/src/components/CursorContext.ts +1 -1
- package/src/components/Hyperlink.tsx +56 -0
- package/src/components/TerminalOscContext.ts +25 -0
- package/src/components/Text.tsx +22 -45
- package/src/components/Transform.tsx +1 -1
- package/src/dom.ts +11 -2
- package/src/global.d.ts +3 -0
- package/src/hooks/use-capabilities.ts +73 -0
- package/src/hooks/use-cursor.ts +2 -2
- package/src/hooks/use-terminal-osc.ts +59 -0
- package/src/index.ts +45 -1
- package/src/ink.tsx +213 -153
- package/src/{render-node-to-output.ts → paint-tree.ts} +75 -48
- package/src/reconciler.ts +24 -3
- package/src/render-background.ts +36 -15
- package/src/render-border.ts +94 -61
- package/src/render-frame.ts +83 -0
- package/src/render-to-string.ts +21 -6
- package/src/render.ts +15 -6
- 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/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/squash-text-nodes.ts +2 -5
- package/src/structured-text.ts +325 -0
- package/src/styles.ts +19 -14
- package/src/terminal/index.ts +2 -0
- package/src/terminal/inline-presenter.ts +120 -0
- package/src/terminal/input.ts +86 -0
- package/src/terminal/render-scheduler.ts +37 -0
- package/src/terminal/screen-presenter.ts +188 -0
- package/src/terminal/session.ts +407 -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 +349 -0
- package/src/testing/vitest.ts +157 -0
- package/src/transform-adapter.ts +14 -0
- package/src/wrap-text.ts +4 -0
- package/dist/sgr-CMfEpjSk.d.ts +0 -91
- package/dist/truncate-Cr6xVFMa.js +0 -2330
- package/src/ansi/supports-color.ts +0 -207
- package/src/colorize.ts +0 -60
- package/src/log-update.ts +0 -370
- package/src/output.ts +0 -308
- package/src/renderer.ts +0 -73
package/src/components/Text.tsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
2
|
import { useContext, type ReactNode } from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { colorize } from "#/colorize.ts";
|
|
4
|
+
import type { Paint } from "#/color/paint.ts";
|
|
6
5
|
import { accessibilityContext } from "#/components/AccessibilityContext.ts";
|
|
7
|
-
import {
|
|
6
|
+
import { cellAttributes } from "#/screen/cell.ts";
|
|
7
|
+
import { parseSemanticColor } from "#/semantic-text-style.ts";
|
|
8
8
|
import { type Styles } from "#/styles.ts";
|
|
9
|
-
import { type LiteralUnion } from "#/types.ts";
|
|
10
9
|
|
|
11
10
|
export type Props = {
|
|
12
11
|
/**
|
|
@@ -22,12 +21,12 @@ export type Props = {
|
|
|
22
21
|
/**
|
|
23
22
|
Change text color. Ink uses Chalk under the hood, so all its functionality is supported.
|
|
24
23
|
*/
|
|
25
|
-
readonly color?:
|
|
24
|
+
readonly color?: Paint;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
Same as `color`, but for the background.
|
|
29
28
|
*/
|
|
30
|
-
readonly backgroundColor?:
|
|
29
|
+
readonly backgroundColor?: Paint;
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
Dim the color (make it less bright).
|
|
@@ -60,7 +59,7 @@ export type Props = {
|
|
|
60
59
|
readonly inverse?: boolean;
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
|
-
This property tells Ink to wrap or truncate text if its width is larger than the container. If `wrap` is passed (the default), Ink will wrap text and split it into multiple lines. If `hard` is passed, Ink will fill each line to the full column width, breaking words as necessary. If `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.
|
|
62
|
+
This property tells Ink to wrap or truncate text if its width is larger than the container. If `wrap` is passed (the default), Ink will wrap text and split it into multiple lines. If `hard` is passed, Ink will fill each line to the full column width, breaking words as necessary. If `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off. If `none` is passed, the text is neither wrapped nor truncated — it overflows the container (and the screen's nominal width), which is intended for log lines committed to scrollback (e.g. inside `<Static>`), not for live regions.
|
|
64
63
|
*/
|
|
65
64
|
readonly wrap?: Styles["textWrap"];
|
|
66
65
|
|
|
@@ -85,49 +84,27 @@ export function Text({
|
|
|
85
84
|
"aria-hidden": ariaHidden = false,
|
|
86
85
|
}: Props) {
|
|
87
86
|
const { isScreenReaderEnabled } = useContext(accessibilityContext);
|
|
88
|
-
const inheritedBackgroundColor = useContext(backgroundContext);
|
|
89
87
|
const childrenOrAriaLabel = isScreenReaderEnabled && ariaLabel ? ariaLabel : children;
|
|
90
88
|
|
|
91
89
|
if (childrenOrAriaLabel === undefined || childrenOrAriaLabel === null) {
|
|
92
90
|
return null;
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (bold) {
|
|
111
|
-
text = chalk.bold(text);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (italic) {
|
|
115
|
-
text = chalk.italic(text);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (underline) {
|
|
119
|
-
text = chalk.underline(text);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (strikethrough) {
|
|
123
|
-
text = chalk.strikethrough(text);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (inverse) {
|
|
127
|
-
text = chalk.inverse(text);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return text;
|
|
93
|
+
const foreground = typeof color === "object" ? color : parseSemanticColor(color);
|
|
94
|
+
const background =
|
|
95
|
+
typeof backgroundColor === "object" ? backgroundColor : parseSemanticColor(backgroundColor);
|
|
96
|
+
const semanticStyle = {
|
|
97
|
+
...(foreground ? { foreground } : {}),
|
|
98
|
+
...(background ? { background } : {}),
|
|
99
|
+
...(color === "" ? { resetForeground: true } : {}),
|
|
100
|
+
...(backgroundColor === "" ? { resetBackground: true } : {}),
|
|
101
|
+
...(underline ? { underline: "single" as const } : {}),
|
|
102
|
+
attributes:
|
|
103
|
+
(dimColor ? cellAttributes.faint : 0) +
|
|
104
|
+
(bold ? cellAttributes.bold : 0) +
|
|
105
|
+
(italic ? cellAttributes.italic : 0) +
|
|
106
|
+
(strikethrough ? cellAttributes.strikethrough : 0) +
|
|
107
|
+
(inverse ? cellAttributes.inverse : 0),
|
|
131
108
|
};
|
|
132
109
|
|
|
133
110
|
if (isScreenReaderEnabled && ariaHidden) {
|
|
@@ -137,7 +114,7 @@ export function Text({
|
|
|
137
114
|
return (
|
|
138
115
|
<ink-text
|
|
139
116
|
style={{ flexGrow: 0, flexShrink: 1, flexDirection: "row", textWrap: wrap }}
|
|
140
|
-
|
|
117
|
+
internal_textStyle={semanticStyle}
|
|
141
118
|
>
|
|
142
119
|
{childrenOrAriaLabel}
|
|
143
120
|
</ink-text>
|
|
@@ -10,7 +10,7 @@ export type Props = {
|
|
|
10
10
|
readonly accessibilityLabel?: string;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
|
|
13
|
+
Compatibility function that transforms the ANSI serialization of this subtree.
|
|
14
14
|
*/
|
|
15
15
|
readonly transform: (children: string, index: number) => string;
|
|
16
16
|
|
package/src/dom.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { measureText } from "#/measure-text.ts";
|
|
2
|
-
import {
|
|
2
|
+
import type { SemanticTextStyle } from "#/semantic-text-style.ts";
|
|
3
3
|
import { squashTextNodes } from "#/squash-text-nodes.ts";
|
|
4
4
|
import { type Styles } from "#/styles.ts";
|
|
5
|
+
import { type AnsiTransformer } from "#/transform-adapter.ts";
|
|
5
6
|
import { wrapText } from "#/wrap-text.ts";
|
|
6
7
|
import { Yoga, type Node as YogaNode } from "#/yoga/index.ts";
|
|
7
8
|
|
|
@@ -24,7 +25,9 @@ export type DOMElement = {
|
|
|
24
25
|
nodeName: ElementNames;
|
|
25
26
|
attributes: Record<string, DOMNodeAttribute>;
|
|
26
27
|
childNodes: DOMNode[];
|
|
27
|
-
|
|
28
|
+
internal_ansi?: boolean;
|
|
29
|
+
internal_transform?: AnsiTransformer;
|
|
30
|
+
internal_textStyle?: SemanticTextStyle;
|
|
28
31
|
|
|
29
32
|
internal_accessibility?: {
|
|
30
33
|
role?:
|
|
@@ -240,6 +243,12 @@ const measureTextNode = function (node: DOMNode, width: number): { width: number
|
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
const textWrap = node.style?.textWrap ?? "wrap";
|
|
246
|
+
|
|
247
|
+
// `none` keeps the intrinsic dimensions and overflows the container.
|
|
248
|
+
if (textWrap === "none") {
|
|
249
|
+
return dimensions;
|
|
250
|
+
}
|
|
251
|
+
|
|
243
252
|
const wrappedText = wrapText(text, width, textWrap);
|
|
244
253
|
|
|
245
254
|
return measureText(wrappedText);
|
package/src/global.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, type Key, type Ref } from "react";
|
|
2
2
|
|
|
3
3
|
import { type DOMElement } from "#/dom.ts";
|
|
4
|
+
import type { SemanticTextStyle } from "#/semantic-text-style.ts";
|
|
4
5
|
import { type Styles } from "#/styles.ts";
|
|
5
6
|
|
|
6
7
|
declare module "react" {
|
|
@@ -29,7 +30,9 @@ declare namespace Ink {
|
|
|
29
30
|
style?: Styles;
|
|
30
31
|
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
|
+
internal_ansi?: boolean;
|
|
32
34
|
internal_transform?: (children: string, index: number) => string;
|
|
35
|
+
internal_textStyle?: SemanticTextStyle;
|
|
33
36
|
internal_accessibility?: DOMElement["internal_accessibility"];
|
|
34
37
|
};
|
|
35
38
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useEffect, useEffectEvent, useSyncExternalStore } from "react";
|
|
2
|
+
|
|
3
|
+
import { type Capabilities } from "#/capabilities/detect.ts";
|
|
4
|
+
import { getCapabilities } from "#/capabilities/store.ts";
|
|
5
|
+
import { useStdinContext } from "#/hooks/use-stdin.ts";
|
|
6
|
+
import { useStdout } from "#/hooks/use-stdout.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Returns everything knowable about the terminal: size, identity, platform,
|
|
10
|
+
color depth, theme, and feature support.
|
|
11
|
+
|
|
12
|
+
A thin wrapper over the framework-free capabilities store (`getCapabilities`):
|
|
13
|
+
environment-derived facts are available immediately; facts only the terminal
|
|
14
|
+
itself can answer fill in after a lazy one-time query, and re-mounting
|
|
15
|
+
consumers refreshes the dynamic facts (theme colors, pixel geometry).
|
|
16
|
+
Re-renders on terminal resize and whenever query answers arrive.
|
|
17
|
+
*/
|
|
18
|
+
export const useCapabilities = (): Capabilities => {
|
|
19
|
+
const { stdout } = useStdout();
|
|
20
|
+
const { stdin } = useStdinContext();
|
|
21
|
+
const store = getCapabilities(stdin, stdout);
|
|
22
|
+
|
|
23
|
+
const capabilities = useSyncExternalStore(store.subscribe, () => store.current);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
void store.query();
|
|
27
|
+
}, [store]);
|
|
28
|
+
|
|
29
|
+
return capabilities;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
Calls `onChange` whenever the terminal changes: resizes (including in-band
|
|
34
|
+
pixel geometry), color scheme switches, window focus, and query answers
|
|
35
|
+
arriving. The React wrapper over `capabilities.subscribe()` for side effects —
|
|
36
|
+
for rendering, use `useCapabilities` instead.
|
|
37
|
+
|
|
38
|
+
The callback always sees the latest render's closure and changing it does not
|
|
39
|
+
resubscribe. Both the new and previous snapshot are passed, so handlers can
|
|
40
|
+
react to the specific change:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
useCapabilitiesChange((next, previous) => {
|
|
44
|
+
if (next.theme.appearance !== previous.theme.appearance) {
|
|
45
|
+
// re-theme
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
*/
|
|
50
|
+
export const useCapabilitiesChange = (
|
|
51
|
+
onChange: (capabilities: Capabilities, previous: Capabilities) => void,
|
|
52
|
+
): void => {
|
|
53
|
+
const { stdout } = useStdout();
|
|
54
|
+
const { stdin } = useStdinContext();
|
|
55
|
+
const store = getCapabilities(stdin, stdout);
|
|
56
|
+
|
|
57
|
+
const handleChange = useEffectEvent(onChange);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
let previous = store.current;
|
|
61
|
+
const unsubscribe = store.subscribe((next) => {
|
|
62
|
+
const before = previous;
|
|
63
|
+
previous = next;
|
|
64
|
+
handleChange(next, before);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Make sure the terminal has been asked — push report modes only turn
|
|
68
|
+
// on once the query has revealed support for them.
|
|
69
|
+
void store.query();
|
|
70
|
+
|
|
71
|
+
return unsubscribe;
|
|
72
|
+
}, [store]);
|
|
73
|
+
};
|
package/src/hooks/use-cursor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext, useRef, useCallback, useInsertionEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import { CursorContext } from "#/components/CursorContext.ts";
|
|
4
|
-
import { type CursorPosition } from "#/
|
|
4
|
+
import { type CursorPosition } from "#/cursor-position.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
A React hook that returns methods to control the terminal cursor position.
|
|
@@ -18,7 +18,7 @@ export const useCursor = () => {
|
|
|
18
18
|
positionRef.current = position;
|
|
19
19
|
}, []);
|
|
20
20
|
|
|
21
|
-
// Propagate cursor position to
|
|
21
|
+
// Propagate cursor position to the terminal presenter only during commit.
|
|
22
22
|
// useInsertionEffect runs before resetAfterCommit (which triggers onRender),
|
|
23
23
|
// and does NOT run for abandoned concurrent renders (e.g. suspended components).
|
|
24
24
|
// This prevents cursor state from leaking across render boundaries.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import type { ClipboardSelection, TerminalProgressState } from "#/ansi/osc.ts";
|
|
4
|
+
import { TerminalOscContext } from "#/components/TerminalOscContext.ts";
|
|
5
|
+
|
|
6
|
+
export type ProgressOptions = {
|
|
7
|
+
readonly state: TerminalProgressState;
|
|
8
|
+
readonly value?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const useProgress = ({ state, value }: ProgressOptions): void => {
|
|
12
|
+
const terminal = useContext(TerminalOscContext);
|
|
13
|
+
const owner = useRef<symbol>(undefined);
|
|
14
|
+
owner.current ??= Symbol("terminal-progress");
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
terminal.publishProgress(owner.current!, state, value);
|
|
18
|
+
}, [state, terminal, value]);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return () => {
|
|
22
|
+
terminal.publishProgress(owner.current!, "inactive");
|
|
23
|
+
};
|
|
24
|
+
}, [terminal]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const useClipboard = (): ((text: string, selection?: ClipboardSelection) => void) => {
|
|
28
|
+
const terminal = useContext(TerminalOscContext);
|
|
29
|
+
return useCallback((text, selection) => terminal.copyToClipboard(text, selection), [terminal]);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const useTitle = (title?: string): void => {
|
|
33
|
+
const terminal = useContext(TerminalOscContext);
|
|
34
|
+
const owner = useRef<symbol>(undefined);
|
|
35
|
+
owner.current ??= Symbol("terminal-title");
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
terminal.publishTitle(owner.current!, title);
|
|
38
|
+
}, [terminal, title]);
|
|
39
|
+
useEffect(() => () => terminal.publishTitle(owner.current!, undefined), [terminal]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const useWorkingDirectory = (directory: URL | string): void => {
|
|
43
|
+
const terminal = useContext(TerminalOscContext);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
terminal.setWorkingDirectory(directory);
|
|
46
|
+
}, [directory, terminal]);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const useNotification = (): ((title: string) => void) => {
|
|
50
|
+
const terminal = useContext(TerminalOscContext);
|
|
51
|
+
return useCallback((title) => terminal.notify(title), [terminal]);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const usePointerShape = (shape: string): void => {
|
|
55
|
+
const terminal = useContext(TerminalOscContext);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
terminal.setPointerShape(shape);
|
|
58
|
+
}, [shape, terminal]);
|
|
59
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type { Props as BoxProps } from "#/components/Box.tsx";
|
|
|
7
7
|
export { Box } from "#/components/Box.tsx";
|
|
8
8
|
export type { Props as TextProps } from "#/components/Text.tsx";
|
|
9
9
|
export { Text } from "#/components/Text.tsx";
|
|
10
|
+
export type { Props as AnsiTextProps } from "#/components/AnsiText.tsx";
|
|
11
|
+
export { AnsiText } from "#/components/AnsiText.tsx";
|
|
10
12
|
export type { Props as AppProps } from "#/components/AppContext.ts";
|
|
11
13
|
export type { PublicProps as StdinProps } from "#/components/StdinContext.ts";
|
|
12
14
|
export type { Props as StdoutProps } from "#/components/StdoutContext.ts";
|
|
@@ -15,9 +17,42 @@ export type { Props as StaticProps } from "#/components/Static.tsx";
|
|
|
15
17
|
export { Static } from "#/components/Static.tsx";
|
|
16
18
|
export type { Props as TransformProps } from "#/components/Transform.tsx";
|
|
17
19
|
export { Transform } from "#/components/Transform.tsx";
|
|
20
|
+
export type { Props as HyperlinkProps } from "#/components/Hyperlink.tsx";
|
|
21
|
+
export { Hyperlink } from "#/components/Hyperlink.tsx";
|
|
18
22
|
export type { Props as NewlineProps } from "#/components/Newline.tsx";
|
|
19
23
|
export { Newline } from "#/components/Newline.tsx";
|
|
20
24
|
export { Spacer } from "#/components/Spacer.tsx";
|
|
25
|
+
// Keep the Ink-compatible root surface fixed. New terminal-core APIs live on
|
|
26
|
+
// their focused subpaths rather than leaking through this entry point.
|
|
27
|
+
export type {
|
|
28
|
+
Capabilities,
|
|
29
|
+
ColorInfo,
|
|
30
|
+
ColorSupport,
|
|
31
|
+
ColorSupportLevel,
|
|
32
|
+
Multiplexer,
|
|
33
|
+
PixelGeometry,
|
|
34
|
+
RgbColor,
|
|
35
|
+
TerminalAppearance,
|
|
36
|
+
TerminalIdentity,
|
|
37
|
+
} from "#/capabilities/detect.ts";
|
|
38
|
+
export {
|
|
39
|
+
createSupportsColor,
|
|
40
|
+
detectCapabilities,
|
|
41
|
+
detectColorLevel,
|
|
42
|
+
detectHyperlinkSupport,
|
|
43
|
+
detectTerminal,
|
|
44
|
+
detectUnicodeSupport,
|
|
45
|
+
} from "#/capabilities/detect.ts";
|
|
46
|
+
export type { PixelSize, TerminalQueryOptions, TerminalQueryResult } from "#/capabilities/query.ts";
|
|
47
|
+
export {
|
|
48
|
+
applyTerminalQuery,
|
|
49
|
+
getTerminalQuery,
|
|
50
|
+
queryTerminal,
|
|
51
|
+
refreshTerminalQuery,
|
|
52
|
+
} from "#/capabilities/query.ts";
|
|
53
|
+
export type { CapabilitiesStore } from "#/capabilities/store.ts";
|
|
54
|
+
export { capabilities, getCapabilities } from "#/capabilities/store.ts";
|
|
55
|
+
export { useCapabilities, useCapabilitiesChange } from "#/hooks/use-capabilities.ts";
|
|
21
56
|
export type { Key } from "#/hooks/use-input.ts";
|
|
22
57
|
export { useInput } from "#/hooks/use-input.ts";
|
|
23
58
|
export { usePaste } from "#/hooks/use-paste.ts";
|
|
@@ -32,11 +67,20 @@ export { useIsScreenReaderEnabled } from "#/hooks/use-is-screen-reader-enabled.t
|
|
|
32
67
|
export { useCursor } from "#/hooks/use-cursor.ts";
|
|
33
68
|
export type { AnimationResult } from "#/hooks/use-animation.ts";
|
|
34
69
|
export { useAnimation } from "#/hooks/use-animation.ts";
|
|
70
|
+
export type { ProgressOptions } from "#/hooks/use-terminal-osc.ts";
|
|
71
|
+
export {
|
|
72
|
+
useClipboard,
|
|
73
|
+
useNotification,
|
|
74
|
+
usePointerShape,
|
|
75
|
+
useProgress,
|
|
76
|
+
useTitle,
|
|
77
|
+
useWorkingDirectory,
|
|
78
|
+
} from "#/hooks/use-terminal-osc.ts";
|
|
35
79
|
export type { WindowSize } from "#/hooks/use-window-size.ts";
|
|
36
80
|
export { useWindowSize } from "#/hooks/use-window-size.ts";
|
|
37
81
|
export type { BoxMetrics, UseBoxMetricsResult } from "#/hooks/use-box-metrics.ts";
|
|
38
82
|
export { useBoxMetrics } from "#/hooks/use-box-metrics.ts";
|
|
39
|
-
export type { CursorPosition } from "#/
|
|
83
|
+
export type { CursorPosition } from "#/cursor-position.ts";
|
|
40
84
|
export { measureElement } from "#/measure-element.ts";
|
|
41
85
|
export type { ElementMetrics } from "#/measure-element.ts";
|
|
42
86
|
export type { DOMElement } from "#/dom.ts";
|