@alchemy.run/sigil 0.0.0-alpha.3 → 0.0.0-alpha.5
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 +23 -13
- package/THIRD_PARTY_NOTICES.md +70 -23
- package/dist/Text-D5HUf3Fj.d.ts +452 -0
- package/dist/ansi.d.ts +137 -143
- package/dist/ansi.js +87 -2
- 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/{devtools-BhYGjb7h.js → devtools-DbthxoD1.js} +22 -23
- 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-Bmc2tRPk.d.ts +21 -0
- package/dist/index.d.ts +235 -754
- package/dist/index.js +1362 -3001
- 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-BOh__-65.js +324 -0
- package/dist/screen-BReKIheE.d.ts +40 -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-BJmzX2NJ.js +664 -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-C2sciZOo.js +1335 -0
- package/package.json +43 -17
- package/src/ansi/chalk.ts +12 -53
- package/src/ansi/cursor.ts +2 -4
- package/src/ansi/east-asian-width.ts +44 -0
- package/src/ansi/escapes.ts +18 -26
- package/src/ansi/graphemes.ts +8 -0
- package/src/ansi/hyperlink.ts +44 -0
- package/src/ansi/index.ts +14 -14
- package/src/ansi/osc.ts +77 -0
- package/src/ansi/sgr.ts +2 -5
- package/src/ansi/slice.ts +1 -1
- package/src/ansi/string-width.ts +91 -206
- package/src/ansi/strip.ts +13 -33
- package/src/ansi/tokenize.ts +96 -169
- package/src/ansi/truncate.ts +5 -3
- package/src/ansi/wrap.ts +13 -14
- package/src/ansi-tokenizer.ts +1 -1
- 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 +109 -22
- package/src/components/BackgroundContext.ts +2 -3
- package/src/components/Box.tsx +43 -60
- package/src/components/CursorContext.ts +1 -1
- package/src/components/ErrorBoundary.tsx +1 -1
- package/src/components/ErrorOverview.tsx +8 -7
- package/src/components/Hyperlink.tsx +56 -0
- package/src/components/Spacer.tsx +1 -1
- package/src/components/Static.tsx +1 -1
- package/src/components/StderrContext.ts +0 -2
- package/src/components/StdinContext.ts +0 -1
- package/src/components/StdoutContext.ts +1 -3
- package/src/components/TerminalOscContext.ts +25 -0
- package/src/components/Text.tsx +23 -46
- package/src/components/Transform.tsx +2 -2
- package/src/cursor-position.ts +1 -1
- package/src/devtools.ts +84 -24
- package/src/dom.ts +11 -8
- package/src/env.ts +12 -0
- package/src/get-max-width.ts +1 -1
- package/src/global.d.ts +6 -4
- package/src/{boxes.ts → glyphs.ts} +17 -18
- package/src/hooks/use-animation.ts +1 -1
- package/src/hooks/use-app.ts +1 -1
- package/src/hooks/use-box-metrics.ts +1 -1
- package/src/hooks/use-capabilities.ts +73 -0
- package/src/hooks/use-cursor.ts +3 -3
- package/src/hooks/use-focus-manager.ts +1 -1
- package/src/hooks/use-focus.ts +5 -6
- package/src/hooks/use-input.ts +4 -4
- package/src/hooks/use-is-screen-reader-enabled.ts +1 -1
- package/src/hooks/use-paste.ts +2 -2
- package/src/hooks/use-stderr.ts +1 -1
- package/src/hooks/use-stdin.ts +1 -1
- package/src/hooks/use-stdout.ts +1 -1
- package/src/hooks/use-terminal-osc.ts +59 -0
- package/src/hooks/use-window-size.ts +2 -2
- package/src/index.ts +88 -44
- package/src/ink.tsx +620 -745
- package/src/input-parser.ts +1 -1
- package/src/instances.ts +1 -1
- package/src/kitty-keyboard.ts +128 -0
- package/src/measure-element.ts +1 -1
- package/src/measure-text.ts +2 -2
- package/src/{render-node-to-output.ts → paint-tree.ts} +78 -53
- package/src/parse-keypress.ts +4 -5
- package/src/parse-stack-line.ts +0 -1
- package/src/patch-console.ts +44 -0
- package/src/reconciler.ts +36 -62
- package/src/render-background.ts +37 -16
- package/src/render-border.ts +97 -64
- package/src/render-frame.ts +83 -0
- package/src/render-to-string.ts +24 -9
- package/src/render.ts +24 -16
- 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 +1 -1
- package/src/screen/ansi.ts +184 -0
- package/src/screen/canvas.ts +137 -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 +272 -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 +4 -5
- package/src/squash-text-nodes.ts +4 -7
- package/src/stream.ts +2 -4
- package/src/structured-text.ts +321 -0
- package/src/styles.ts +16 -17
- 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-size.ts +9 -8
- 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/types.ts +1 -6
- package/src/utils.ts +2 -2
- package/src/wrap-text.ts +4 -4
- package/src/yoga/config.ts +2 -2
- package/src/yoga/core/absoluteLayout.ts +15 -15
- package/src/yoga/core/baseline.ts +3 -3
- package/src/yoga/core/cache.ts +4 -4
- package/src/yoga/core/calculateLayout.ts +33 -27
- package/src/yoga/core/config.ts +1 -1
- package/src/yoga/core/flexLine.ts +3 -3
- package/src/yoga/core/helpers.ts +3 -3
- package/src/yoga/core/layoutResults.ts +4 -4
- package/src/yoga/core/node.ts +16 -16
- package/src/yoga/core/pixelGrid.ts +4 -4
- package/src/yoga/core/style.ts +11 -11
- package/src/yoga/core/types.ts +2 -2
- package/src/yoga/index.ts +6 -6
- package/src/yoga/node.ts +8 -8
- package/dist/sgr-CMfEpjSk.d.ts +0 -91
- package/dist/truncate-CBiyyZzw.js +0 -2156
- package/src/ansi/supports-color.ts +0 -213
- package/src/ansi/widest-line.ts +0 -12
- package/src/auto-bind.ts +0 -41
- package/src/colorize.ts +0 -60
- package/src/devtools-window-polyfill.ts +0 -73
- package/src/indent-string.ts +0 -16
- package/src/is-in-ci.ts +0 -7
- package/src/log-update.ts +0 -370
- package/src/output.ts +0 -308
- package/src/renderer.ts +0 -73
- package/src/write-synchronized.ts +0 -9
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
// Derived from `cli-boxes` (MIT, Sindre Sorhus).
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
Style of the box border.
|
|
5
|
-
*/
|
|
6
|
-
export type BoxStyle = {
|
|
7
|
-
readonly topLeft: string;
|
|
8
|
-
readonly top: string;
|
|
9
|
-
readonly topRight: string;
|
|
10
|
-
readonly right: string;
|
|
11
|
-
readonly bottomRight: string;
|
|
12
|
-
readonly bottom: string;
|
|
13
|
-
readonly bottomLeft: string;
|
|
14
|
-
readonly left: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const boxes = {
|
|
2
|
+
export const BOXES = {
|
|
18
3
|
single: {
|
|
19
4
|
topLeft: "┌",
|
|
20
5
|
top: "─",
|
|
@@ -95,6 +80,20 @@ export const boxes = {
|
|
|
95
80
|
bottomLeft: "↗",
|
|
96
81
|
left: "→",
|
|
97
82
|
},
|
|
98
|
-
} as const
|
|
83
|
+
} as const;
|
|
99
84
|
|
|
100
|
-
export type
|
|
85
|
+
export type BoxStyle = keyof typeof BOXES;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
The set of glyphs making up a box border, for custom `borderStyle` objects.
|
|
89
|
+
*/
|
|
90
|
+
export type BoxGlyphs = {
|
|
91
|
+
readonly topLeft: string;
|
|
92
|
+
readonly top: string;
|
|
93
|
+
readonly topRight: string;
|
|
94
|
+
readonly right: string;
|
|
95
|
+
readonly bottomRight: string;
|
|
96
|
+
readonly bottom: string;
|
|
97
|
+
readonly bottomLeft: string;
|
|
98
|
+
readonly left: string;
|
|
99
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, useLayoutEffect, useRef, useCallback, useContext } from "react";
|
|
2
2
|
|
|
3
|
-
import { animationContext as AnimationContext } from "
|
|
3
|
+
import { animationContext as AnimationContext } from "#/components/AnimationContext.ts";
|
|
4
4
|
|
|
5
5
|
const defaultAnimationInterval = 100;
|
|
6
6
|
const maximumTimerInterval = 2_147_483_647;
|
package/src/hooks/use-app.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RefObject, useState, useEffect, useCallback, useMemo } from "react";
|
|
2
2
|
|
|
3
|
-
import { type DOMElement, addLayoutListener } from "
|
|
3
|
+
import { type DOMElement, addLayoutListener } from "#/dom.ts";
|
|
4
4
|
|
|
5
5
|
// Yoga's `right`/`bottom` are omitted: always `0` for flow layout and unintuitive for absolute positioning.
|
|
6
6
|
/**
|
|
@@ -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
|
-
import { CursorContext } from "
|
|
4
|
-
import { type CursorPosition } from "
|
|
3
|
+
import { CursorContext } from "#/components/CursorContext.ts";
|
|
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.
|
package/src/hooks/use-focus.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useEffect, useContext,
|
|
1
|
+
import { useEffect, useContext, useId } from "react";
|
|
2
2
|
|
|
3
|
-
import { FocusContext } from "
|
|
4
|
-
import { useStdin } from "
|
|
3
|
+
import { FocusContext } from "#/components/FocusContext.ts";
|
|
4
|
+
import { useStdin } from "#/hooks/use-stdin.ts";
|
|
5
5
|
|
|
6
6
|
type Input = {
|
|
7
7
|
/**
|
|
@@ -44,9 +44,8 @@ export const useFocus = ({
|
|
|
44
44
|
const { isRawModeSupported, setRawMode } = useStdin();
|
|
45
45
|
const { activeId, add, remove, activate, deactivate, focus } = useContext(FocusContext);
|
|
46
46
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}, [customId]);
|
|
47
|
+
const autoId = useId();
|
|
48
|
+
const id = customId ?? autoId;
|
|
50
49
|
|
|
51
50
|
useEffect(() => {
|
|
52
51
|
add(id, { autoFocus });
|
package/src/hooks/use-input.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useEffect, useEffectEvent } from "react";
|
|
2
2
|
|
|
3
|
-
import { ESC } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { ESC } from "#/ansi/escapes.ts";
|
|
4
|
+
import { useStdinContext } from "#/hooks/use-stdin.ts";
|
|
5
|
+
import { parseKeypress, nonAlphanumericKeys } from "#/parse-keypress.ts";
|
|
6
|
+
import { reconciler } from "#/reconciler.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
Handy information about a key that was pressed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
|
|
3
|
-
import { accessibilityContext } from "
|
|
3
|
+
import { accessibilityContext } from "#/components/AccessibilityContext.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
A React hook that returns whether a screen reader is enabled.
|
package/src/hooks/use-paste.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useEffectEvent } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useStdinContext } from "#/hooks/use-stdin.ts";
|
|
4
|
+
import { reconciler } from "#/reconciler.ts";
|
|
5
5
|
|
|
6
6
|
type Options = {
|
|
7
7
|
/**
|
package/src/hooks/use-stderr.ts
CHANGED
package/src/hooks/use-stdin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
|
|
3
|
-
import { StdinContext, type PublicProps, type Props } from "
|
|
3
|
+
import { StdinContext, type PublicProps, type Props } from "#/components/StdinContext.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
A React hook that returns the stdin stream and stdin-related utilities.
|
package/src/hooks/use-stdout.ts
CHANGED
|
@@ -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
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useStdout } from "#/hooks/use-stdout.ts";
|
|
4
|
+
import { getWindowSize } from "#/utils.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
Dimensions of the terminal window.
|
package/src/index.ts
CHANGED
|
@@ -1,44 +1,88 @@
|
|
|
1
|
-
export type { RenderOptions, Instance } from "
|
|
2
|
-
export type { CapturedOutputSource } from "
|
|
3
|
-
export { render } from "
|
|
4
|
-
export type { RenderToStringOptions } from "
|
|
5
|
-
export { renderToString } from "
|
|
6
|
-
export type { Props as BoxProps } from "
|
|
7
|
-
export { Box } from "
|
|
8
|
-
export type { Props as TextProps } from "
|
|
9
|
-
export { Text } from "
|
|
10
|
-
export type { Props as
|
|
11
|
-
export
|
|
12
|
-
export type { Props as
|
|
13
|
-
export type {
|
|
14
|
-
export type { Props as
|
|
15
|
-
export {
|
|
16
|
-
export type { Props as
|
|
17
|
-
export {
|
|
18
|
-
export type { Props as
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
export type { RenderOptions, Instance } from "#/render.ts";
|
|
2
|
+
export type { CapturedOutputSource } from "#/ink.tsx";
|
|
3
|
+
export { render } from "#/render.ts";
|
|
4
|
+
export type { RenderToStringOptions } from "#/render-to-string.ts";
|
|
5
|
+
export { renderToString } from "#/render-to-string.ts";
|
|
6
|
+
export type { Props as BoxProps } from "#/components/Box.tsx";
|
|
7
|
+
export { Box } from "#/components/Box.tsx";
|
|
8
|
+
export type { Props as TextProps } from "#/components/Text.tsx";
|
|
9
|
+
export { Text } from "#/components/Text.tsx";
|
|
10
|
+
export type { Props as AnsiTextProps } from "#/components/AnsiText.tsx";
|
|
11
|
+
export { AnsiText } from "#/components/AnsiText.tsx";
|
|
12
|
+
export type { Props as AppProps } from "#/components/AppContext.ts";
|
|
13
|
+
export type { PublicProps as StdinProps } from "#/components/StdinContext.ts";
|
|
14
|
+
export type { Props as StdoutProps } from "#/components/StdoutContext.ts";
|
|
15
|
+
export type { Props as StderrProps } from "#/components/StderrContext.ts";
|
|
16
|
+
export type { Props as StaticProps } from "#/components/Static.tsx";
|
|
17
|
+
export { Static } from "#/components/Static.tsx";
|
|
18
|
+
export type { Props as TransformProps } from "#/components/Transform.tsx";
|
|
19
|
+
export { Transform } from "#/components/Transform.tsx";
|
|
20
|
+
export type { Props as HyperlinkProps } from "#/components/Hyperlink.tsx";
|
|
21
|
+
export { Hyperlink } from "#/components/Hyperlink.tsx";
|
|
22
|
+
export type { Props as NewlineProps } from "#/components/Newline.tsx";
|
|
23
|
+
export { Newline } from "#/components/Newline.tsx";
|
|
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";
|
|
56
|
+
export type { Key } from "#/hooks/use-input.ts";
|
|
57
|
+
export { useInput } from "#/hooks/use-input.ts";
|
|
58
|
+
export { usePaste } from "#/hooks/use-paste.ts";
|
|
59
|
+
export type { SuspendTerminal, TerminalSuspension } from "#/components/AppContext.ts";
|
|
60
|
+
export { useApp } from "#/hooks/use-app.ts";
|
|
61
|
+
export { useStdin } from "#/hooks/use-stdin.ts";
|
|
62
|
+
export { useStdout } from "#/hooks/use-stdout.ts";
|
|
63
|
+
export { useStderr } from "#/hooks/use-stderr.ts";
|
|
64
|
+
export { useFocus } from "#/hooks/use-focus.ts";
|
|
65
|
+
export { useFocusManager } from "#/hooks/use-focus-manager.ts";
|
|
66
|
+
export { useIsScreenReaderEnabled } from "#/hooks/use-is-screen-reader-enabled.ts";
|
|
67
|
+
export { useCursor } from "#/hooks/use-cursor.ts";
|
|
68
|
+
export type { AnimationResult } from "#/hooks/use-animation.ts";
|
|
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";
|
|
79
|
+
export type { WindowSize } from "#/hooks/use-window-size.ts";
|
|
80
|
+
export { useWindowSize } from "#/hooks/use-window-size.ts";
|
|
81
|
+
export type { BoxMetrics, UseBoxMetricsResult } from "#/hooks/use-box-metrics.ts";
|
|
82
|
+
export { useBoxMetrics } from "#/hooks/use-box-metrics.ts";
|
|
83
|
+
export type { CursorPosition } from "#/cursor-position.ts";
|
|
84
|
+
export { measureElement } from "#/measure-element.ts";
|
|
85
|
+
export type { ElementMetrics } from "#/measure-element.ts";
|
|
86
|
+
export type { DOMElement } from "#/dom.ts";
|
|
87
|
+
export { kittyFlags, kittyModifiers } from "#/kitty-keyboard.ts";
|
|
88
|
+
export type { KittyKeyboardOptions, KittyFlagName } from "#/kitty-keyboard.ts";
|