giggles 0.3.11 → 0.3.13
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/dist/{chunk-WJRBHS5J.js → chunk-JTJH45JR.js} +3 -6
- package/dist/chunk-N2MMNJV3.js +52 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/markdown/index.js +1 -1
- package/dist/terminal/index.d.ts +4 -2
- package/dist/terminal/index.js +7 -28
- package/dist/ui/index.d.ts +7 -12
- package/dist/ui/index.js +11 -9
- package/package.json +1 -1
- package/dist/chunk-7PDVDYFB.js +0 -23
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
} from "./chunk-EVD6YPS3.js";
|
|
4
4
|
|
|
5
5
|
// src/ui/CodeBlock.tsx
|
|
6
|
-
import Prism from "prismjs";
|
|
7
6
|
import { Box, Text } from "ink";
|
|
7
|
+
import Prism from "prismjs";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
var defaultTokenColors = {
|
|
10
10
|
keyword: "#C678DD",
|
|
@@ -22,15 +22,12 @@ var defaultTokenColors = {
|
|
|
22
22
|
inserted: "#98C379",
|
|
23
23
|
deleted: "#E06C75"
|
|
24
24
|
};
|
|
25
|
-
function CodeBlock({ children, language,
|
|
25
|
+
function CodeBlock({ children, language, tokenColors, ...boxProps }) {
|
|
26
26
|
const theme = useTheme();
|
|
27
27
|
const colors = { ...defaultTokenColors, ...tokenColors };
|
|
28
28
|
const grammar = language ? Prism.languages[language] : void 0;
|
|
29
29
|
const content = grammar ? renderTokens(Prism.tokenize(children, grammar), colors) : /* @__PURE__ */ jsx(Text, { children });
|
|
30
|
-
|
|
31
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: content }) });
|
|
32
|
-
}
|
|
33
|
-
return /* @__PURE__ */ jsx(Box, { paddingX: 1, borderStyle: "single", borderColor: theme.borderColor, children: /* @__PURE__ */ jsx(Text, { children: content }) });
|
|
30
|
+
return /* @__PURE__ */ jsx(Box, { paddingX: 1, borderStyle: "round", borderColor: theme.borderColor, ...boxProps, children: /* @__PURE__ */ jsx(Text, { children: content }) });
|
|
34
31
|
}
|
|
35
32
|
function renderTokens(tokens, colors) {
|
|
36
33
|
return tokens.map((token, idx) => {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/terminal/hooks/useTerminalSize.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
function useTerminalSize() {
|
|
4
|
+
const [size, setSize] = useState({
|
|
5
|
+
rows: process.stdout.rows,
|
|
6
|
+
columns: process.stdout.columns
|
|
7
|
+
});
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const handleResize = () => {
|
|
10
|
+
setSize({
|
|
11
|
+
rows: process.stdout.rows,
|
|
12
|
+
columns: process.stdout.columns
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
process.stdout.on("resize", handleResize);
|
|
16
|
+
return () => {
|
|
17
|
+
process.stdout.off("resize", handleResize);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return size;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/terminal/components/AlternateScreen.tsx
|
|
24
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
25
|
+
import { Box } from "ink";
|
|
26
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
27
|
+
var _a;
|
|
28
|
+
var isTTY = typeof process !== "undefined" && ((_a = process.stdout) == null ? void 0 : _a.write);
|
|
29
|
+
function FullScreenBox({ children }) {
|
|
30
|
+
const { rows, columns } = useTerminalSize();
|
|
31
|
+
return /* @__PURE__ */ jsx(Box, { height: rows, width: columns, children });
|
|
32
|
+
}
|
|
33
|
+
function AlternateScreen({ children, fullScreen = true }) {
|
|
34
|
+
const [ready, setReady] = useState2(!isTTY);
|
|
35
|
+
useEffect2(() => {
|
|
36
|
+
if (!isTTY) return;
|
|
37
|
+
process.stdout.write("\x1B[?1049h");
|
|
38
|
+
process.stdout.write("\x1B[2J");
|
|
39
|
+
process.stdout.write("\x1B[H");
|
|
40
|
+
setReady(true);
|
|
41
|
+
return () => {
|
|
42
|
+
process.stdout.write("\x1B[?1049l");
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
if (!ready) return null;
|
|
46
|
+
return fullScreen ? /* @__PURE__ */ jsx(FullScreenBox, { children }) : /* @__PURE__ */ jsx(Fragment, { children });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
useTerminalSize,
|
|
51
|
+
AlternateScreen
|
|
52
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -30,9 +30,10 @@ declare function useTheme(): GigglesTheme;
|
|
|
30
30
|
|
|
31
31
|
type GigglesProviderProps = {
|
|
32
32
|
theme?: Partial<GigglesTheme>;
|
|
33
|
+
fullScreen?: boolean;
|
|
33
34
|
children: React__default.ReactNode;
|
|
34
35
|
};
|
|
35
|
-
declare function GigglesProvider({ theme, children }: GigglesProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare function GigglesProvider({ theme, fullScreen, children }: GigglesProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
37
|
|
|
37
38
|
declare function useKeybindings(focus: FocusHandle, bindings: Keybindings, options?: KeybindingOptions): void;
|
|
38
39
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AlternateScreen
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N2MMNJV3.js";
|
|
4
4
|
import {
|
|
5
5
|
FocusGroup,
|
|
6
6
|
FocusNodeContext,
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
|
|
23
23
|
// src/core/GigglesProvider.tsx
|
|
24
24
|
import { jsx } from "react/jsx-runtime";
|
|
25
|
-
function GigglesProvider({ theme, children }) {
|
|
26
|
-
return /* @__PURE__ */ jsx(AlternateScreen, { children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(FocusProvider, { children: /* @__PURE__ */ jsx(InputProvider, { children: /* @__PURE__ */ jsx(InputRouter, { children }) }) }) }) });
|
|
25
|
+
function GigglesProvider({ theme, fullScreen, children }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(AlternateScreen, { fullScreen, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(FocusProvider, { children: /* @__PURE__ */ jsx(InputProvider, { children: /* @__PURE__ */ jsx(InputRouter, { children }) }) }) }) });
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// src/core/router/Router.tsx
|
package/dist/markdown/index.js
CHANGED
package/dist/terminal/index.d.ts
CHANGED
|
@@ -10,9 +10,11 @@ declare function useTerminalSize(): TerminalSize;
|
|
|
10
10
|
|
|
11
11
|
declare function useTerminalFocus(callback: (focused: boolean) => void): void;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
type AlternateScreenProps = {
|
|
14
14
|
children: ReactNode;
|
|
15
|
-
|
|
15
|
+
fullScreen?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare function AlternateScreen({ children, fullScreen }: AlternateScreenProps): react_jsx_runtime.JSX.Element | null;
|
|
16
18
|
|
|
17
19
|
declare function useShellOut(): {
|
|
18
20
|
run: (command: string) => Promise<{
|
package/dist/terminal/index.js
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AlternateScreen
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// src/terminal/hooks/useTerminalSize.ts
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
function useTerminalSize() {
|
|
8
|
-
const [size, setSize] = useState({
|
|
9
|
-
rows: process.stdout.rows,
|
|
10
|
-
columns: process.stdout.columns
|
|
11
|
-
});
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const handleResize = () => {
|
|
14
|
-
setSize({
|
|
15
|
-
rows: process.stdout.rows,
|
|
16
|
-
columns: process.stdout.columns
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
process.stdout.on("resize", handleResize);
|
|
20
|
-
return () => {
|
|
21
|
-
process.stdout.off("resize", handleResize);
|
|
22
|
-
};
|
|
23
|
-
}, []);
|
|
24
|
-
return size;
|
|
25
|
-
}
|
|
2
|
+
AlternateScreen,
|
|
3
|
+
useTerminalSize
|
|
4
|
+
} from "../chunk-N2MMNJV3.js";
|
|
26
5
|
|
|
27
6
|
// src/terminal/hooks/useTerminalFocus.ts
|
|
28
|
-
import { useEffect
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
29
8
|
function useTerminalFocus(callback) {
|
|
30
9
|
const callbackRef = useRef(callback);
|
|
31
10
|
callbackRef.current = callback;
|
|
32
|
-
|
|
11
|
+
useEffect(() => {
|
|
33
12
|
const handler = (data) => {
|
|
34
13
|
const str = data.toString();
|
|
35
14
|
if (str.includes("\x1B[I")) callbackRef.current(true);
|
|
@@ -49,10 +28,10 @@ function useTerminalFocus(callback) {
|
|
|
49
28
|
|
|
50
29
|
// src/terminal/hooks/useShellout.ts
|
|
51
30
|
import { execa } from "execa";
|
|
52
|
-
import { useCallback, useState
|
|
31
|
+
import { useCallback, useState } from "react";
|
|
53
32
|
import { useStdin } from "ink";
|
|
54
33
|
function useShellOut() {
|
|
55
|
-
const [, setRedrawCount] =
|
|
34
|
+
const [, setRedrawCount] = useState(0);
|
|
56
35
|
const { setRawMode } = useStdin();
|
|
57
36
|
const run = useCallback(
|
|
58
37
|
async (command) => {
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { R as RegisteredKeybinding } from '../types-Dmw9TKt4.js';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import 'ink';
|
|
4
|
+
import { BoxProps } from 'ink';
|
|
5
5
|
|
|
6
6
|
type CommandPaletteRenderProps = {
|
|
7
7
|
query: string;
|
|
@@ -162,14 +162,12 @@ type ViewportProps = {
|
|
|
162
162
|
};
|
|
163
163
|
declare const Viewport: React__default.ForwardRefExoticComponent<ViewportProps & React__default.RefAttributes<ViewportRef>>;
|
|
164
164
|
|
|
165
|
-
type
|
|
166
|
-
type ModalProps = {
|
|
165
|
+
type ModalProps = Omit<BoxProps, 'children'> & {
|
|
167
166
|
children: React__default.ReactNode;
|
|
168
167
|
onClose: () => void;
|
|
169
168
|
title?: string;
|
|
170
|
-
borderStyle?: BorderStyle;
|
|
171
169
|
};
|
|
172
|
-
declare function Modal({ children, onClose, title,
|
|
170
|
+
declare function Modal({ children, onClose, title, ...boxProps }: ModalProps): react_jsx_runtime.JSX.Element;
|
|
173
171
|
|
|
174
172
|
type BadgeVariant = 'round' | 'arrow' | 'plain';
|
|
175
173
|
type BadgeProps = {
|
|
@@ -180,14 +178,12 @@ type BadgeProps = {
|
|
|
180
178
|
};
|
|
181
179
|
declare function Badge({ children, color, background, variant }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
182
180
|
|
|
183
|
-
type PanelProps = {
|
|
181
|
+
type PanelProps = Omit<BoxProps, 'children'> & {
|
|
184
182
|
children: React__default.ReactNode;
|
|
185
183
|
title?: string;
|
|
186
|
-
width?: number;
|
|
187
|
-
borderColor?: string;
|
|
188
184
|
footer?: React__default.ReactNode;
|
|
189
185
|
};
|
|
190
|
-
declare function Panel({ children, title, width, borderColor, footer }: PanelProps): react_jsx_runtime.JSX.Element;
|
|
186
|
+
declare function Panel({ children, title, width, borderColor, footer, ...boxProps }: PanelProps): react_jsx_runtime.JSX.Element;
|
|
191
187
|
|
|
192
188
|
type TokenColors = {
|
|
193
189
|
keyword: string;
|
|
@@ -205,13 +201,12 @@ type TokenColors = {
|
|
|
205
201
|
inserted: string;
|
|
206
202
|
deleted: string;
|
|
207
203
|
};
|
|
208
|
-
type CodeBlockProps = {
|
|
204
|
+
type CodeBlockProps = Omit<BoxProps, 'children'> & {
|
|
209
205
|
children: string;
|
|
210
206
|
language?: string;
|
|
211
|
-
showBorder?: boolean;
|
|
212
207
|
tokenColors?: Partial<TokenColors>;
|
|
213
208
|
};
|
|
214
|
-
declare function CodeBlock({ children, language,
|
|
209
|
+
declare function CodeBlock({ children, language, tokenColors, ...boxProps }: CodeBlockProps): react_jsx_runtime.JSX.Element;
|
|
215
210
|
|
|
216
211
|
type SpinnerDef = {
|
|
217
212
|
frames: string[];
|
package/dist/ui/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../chunk-CKA5JJ4B.js";
|
|
8
8
|
import {
|
|
9
9
|
CodeBlock
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-JTJH45JR.js";
|
|
11
11
|
import {
|
|
12
12
|
useTheme
|
|
13
13
|
} from "../chunk-EVD6YPS3.js";
|
|
@@ -821,7 +821,7 @@ var Viewport = forwardRef(function Viewport2({ children, height, keybindings: en
|
|
|
821
821
|
// src/ui/Modal.tsx
|
|
822
822
|
import { Box as Box8, Text as Text8 } from "ink";
|
|
823
823
|
import { jsx as jsx9, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
824
|
-
function ModalInner({ children, onClose, title,
|
|
824
|
+
function ModalInner({ children, onClose, title, ...boxProps }) {
|
|
825
825
|
const focus = useFocus();
|
|
826
826
|
const theme = useTheme();
|
|
827
827
|
useKeybindings(focus, {
|
|
@@ -832,9 +832,10 @@ function ModalInner({ children, onClose, title, borderStyle = "round" }) {
|
|
|
832
832
|
{
|
|
833
833
|
flexDirection: "column",
|
|
834
834
|
alignSelf: "flex-start",
|
|
835
|
-
borderStyle,
|
|
835
|
+
borderStyle: "round",
|
|
836
836
|
borderColor: theme.borderColor,
|
|
837
837
|
paddingX: 1,
|
|
838
|
+
...boxProps,
|
|
838
839
|
children: [
|
|
839
840
|
title != null && /* @__PURE__ */ jsx9(Text8, { bold: true, children: title }),
|
|
840
841
|
children
|
|
@@ -842,8 +843,8 @@ function ModalInner({ children, onClose, title, borderStyle = "round" }) {
|
|
|
842
843
|
}
|
|
843
844
|
);
|
|
844
845
|
}
|
|
845
|
-
function Modal({ children, onClose, title,
|
|
846
|
-
return /* @__PURE__ */ jsx9(FocusTrap, { children: /* @__PURE__ */ jsx9(ModalInner, { onClose, title,
|
|
846
|
+
function Modal({ children, onClose, title, ...boxProps }) {
|
|
847
|
+
return /* @__PURE__ */ jsx9(FocusTrap, { children: /* @__PURE__ */ jsx9(ModalInner, { onClose, title, ...boxProps, children }) });
|
|
847
848
|
}
|
|
848
849
|
|
|
849
850
|
// src/ui/Badge.tsx
|
|
@@ -871,11 +872,11 @@ function Badge({ children, color, background, variant = "round" }) {
|
|
|
871
872
|
import { useState as useState7 } from "react";
|
|
872
873
|
import { Box as Box9, Text as Text10, measureElement as measureElement2 } from "ink";
|
|
873
874
|
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
874
|
-
function Panel({ children, title, width, borderColor, footer }) {
|
|
875
|
+
function Panel({ children, title, width, borderColor, footer, ...boxProps }) {
|
|
875
876
|
const theme = useTheme();
|
|
876
877
|
const color = borderColor ?? theme.borderColor;
|
|
877
|
-
const [measuredWidth, setMeasuredWidth] = useState7(width
|
|
878
|
-
const effectiveWidth = width
|
|
878
|
+
const [measuredWidth, setMeasuredWidth] = useState7(typeof width === "number" ? width : 0);
|
|
879
|
+
const effectiveWidth = typeof width === "number" ? width : measuredWidth;
|
|
879
880
|
const renderTopBorder = () => {
|
|
880
881
|
if (effectiveWidth === 0) return null;
|
|
881
882
|
if (title == null) {
|
|
@@ -908,9 +909,10 @@ function Panel({ children, title, width, borderColor, footer }) {
|
|
|
908
909
|
ref: (node) => {
|
|
909
910
|
if (node) {
|
|
910
911
|
const { width: w } = measureElement2(node);
|
|
911
|
-
if (w !== measuredWidth) setMeasuredWidth(w);
|
|
912
|
+
if (w > 0 && w !== measuredWidth) setMeasuredWidth(w);
|
|
912
913
|
}
|
|
913
914
|
},
|
|
915
|
+
...boxProps,
|
|
914
916
|
children: [
|
|
915
917
|
renderTopBorder(),
|
|
916
918
|
/* @__PURE__ */ jsx11(Box9, { flexDirection: "column", flexGrow: 1, borderStyle: "round", borderTop: false, borderColor: color, paddingX: 1, children: footer ? /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
package/package.json
CHANGED
package/dist/chunk-7PDVDYFB.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/terminal/components/AlternateScreen.tsx
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
var _a;
|
|
5
|
-
var isTTY = typeof process !== "undefined" && ((_a = process.stdout) == null ? void 0 : _a.write);
|
|
6
|
-
function AlternateScreen({ children }) {
|
|
7
|
-
const [ready, setReady] = useState(!isTTY);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (!isTTY) return;
|
|
10
|
-
process.stdout.write("\x1B[?1049h");
|
|
11
|
-
process.stdout.write("\x1B[2J");
|
|
12
|
-
process.stdout.write("\x1B[H");
|
|
13
|
-
setReady(true);
|
|
14
|
-
return () => {
|
|
15
|
-
process.stdout.write("\x1B[?1049l");
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
18
|
-
return ready ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
AlternateScreen
|
|
23
|
-
};
|