@tooee/view 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/subviews/code-subview.d.ts +2 -1
- package/dist/components/subviews/code-subview.d.ts.map +1 -1
- package/dist/components/subviews/code-subview.js +2 -15
- package/dist/components/subviews/code-subview.js.map +1 -1
- package/dist/components/subviews/custom-subview.d.ts +2 -1
- package/dist/components/subviews/custom-subview.d.ts.map +1 -1
- package/dist/components/subviews/custom-subview.js +3 -13
- package/dist/components/subviews/custom-subview.js.map +1 -1
- package/dist/components/subviews/diff-subview.d.ts +2 -1
- package/dist/components/subviews/diff-subview.d.ts.map +1 -1
- package/dist/components/subviews/diff-subview.js +23 -33
- package/dist/components/subviews/diff-subview.js.map +1 -1
- package/dist/components/subviews/image-subview.d.ts +2 -1
- package/dist/components/subviews/image-subview.d.ts.map +1 -1
- package/dist/components/subviews/image-subview.js +4 -9
- package/dist/components/subviews/image-subview.js.map +1 -1
- package/dist/components/subviews/markdown-subview.d.ts +2 -1
- package/dist/components/subviews/markdown-subview.d.ts.map +1 -1
- package/dist/components/subviews/markdown-subview.js +8 -15
- package/dist/components/subviews/markdown-subview.js.map +1 -1
- package/dist/components/subviews/table-subview.d.ts +2 -1
- package/dist/components/subviews/table-subview.d.ts.map +1 -1
- package/dist/components/subviews/table-subview.js +9 -48
- package/dist/components/subviews/table-subview.js.map +1 -1
- package/dist/components/view-state.d.ts +2 -1
- package/dist/components/view-state.d.ts.map +1 -1
- package/dist/components/view-state.js.map +1 -1
- package/dist/content-loader-store.d.ts +3 -2
- package/dist/content-loader-store.d.ts.map +1 -1
- package/dist/content-loader-store.js +5 -4
- package/dist/content-loader-store.js.map +1 -1
- package/dist/default-provider.d.ts.map +1 -1
- package/dist/default-provider.js +29 -29
- package/dist/default-provider.js.map +1 -1
- package/dist/directory-view.d.ts +2 -1
- package/dist/directory-view.d.ts.map +1 -1
- package/dist/directory-view.js +2 -1
- package/dist/directory-view.js.map +1 -1
- package/dist/hooks/use-content-commands.d.ts +5 -3
- package/dist/hooks/use-content-commands.d.ts.map +1 -1
- package/dist/hooks/use-content-commands.js.map +1 -1
- package/dist/hooks/use-content-document.d.ts +28 -0
- package/dist/hooks/use-content-document.d.ts.map +1 -0
- package/dist/hooks/use-content-document.js +21 -0
- package/dist/hooks/use-content-document.js.map +1 -0
- package/dist/hooks/use-content-loader.d.ts +10 -6
- package/dist/hooks/use-content-loader.d.ts.map +1 -1
- package/dist/hooks/use-content-loader.js +1 -1
- package/dist/hooks/use-content-loader.js.map +1 -1
- package/dist/hooks/use-view-command-context.d.ts +4 -2
- package/dist/hooks/use-view-command-context.d.ts.map +1 -1
- package/dist/hooks/use-view-command-context.js +6 -1
- package/dist/hooks/use-view-command-context.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +2 -2
- package/dist/launch.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -33
- package/dist/types.js.map +1 -1
- package/dist/view.d.ts +2 -1
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js.map +1 -1
- package/package.json +12 -11
- package/src/components/subviews/code-subview.tsx +8 -20
- package/src/components/subviews/custom-subview.tsx +9 -19
- package/src/components/subviews/diff-subview.tsx +35 -43
- package/src/components/subviews/image-subview.tsx +12 -11
- package/src/components/subviews/markdown-subview.tsx +16 -22
- package/src/components/subviews/table-subview.tsx +16 -56
- package/src/components/view-state.tsx +2 -1
- package/src/content-loader-store.ts +8 -5
- package/src/default-provider.ts +34 -32
- package/src/directory-view.tsx +4 -2
- package/src/hooks/use-content-commands.ts +6 -1
- package/src/hooks/use-content-document.ts +54 -0
- package/src/hooks/use-content-loader.ts +17 -3
- package/src/hooks/use-view-command-context.ts +16 -4
- package/src/index.ts +2 -0
- package/src/launch.tsx +11 -8
- package/src/types.ts +4 -35
- package/src/view.tsx +2 -1
- package/dist/hooks/index.d.ts +0 -5
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -4
- package/dist/hooks/index.js.map +0 -1
- package/src/hooks/index.ts +0 -11
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CodeContent, TextContent } from "../../types.js";
|
|
2
2
|
import type { SubviewProps } from "./types.js";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
interface CodeSubviewProps extends SubviewProps {
|
|
4
5
|
content: CodeContent | TextContent;
|
|
5
6
|
}
|
|
6
|
-
export declare const CodeSubview: ({ content, decorations, actions, ...screen }: CodeSubviewProps) =>
|
|
7
|
+
export declare const CodeSubview: ({ content, decorations, actions, ...screen }: CodeSubviewProps) => ReactNode;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=code-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/code-subview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/code-subview.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;CACpC;AAED,eAAO,MAAM,WAAW,iDAKrB,gBAAgB,KAAG,SA4BrB,CAAC"}
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { CodeView, sourceLines, sourceLineAdapter } from "@tooee/renderers";
|
|
4
|
-
import {
|
|
5
|
-
import { useContentCommands } from "../../hooks/use-content-commands.js";
|
|
4
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
6
5
|
import { ViewScreen } from "../view-screen.js";
|
|
7
6
|
export const CodeSubview = function CodeSubview({ content, decorations, actions, ...screen }) {
|
|
8
7
|
const textContent = content.format === "code" ? content.code : content.text;
|
|
9
8
|
// One navigation row per physical source line; row index is the source line.
|
|
10
9
|
const lineRows = useMemo(() => sourceLines(textContent), [textContent]);
|
|
11
|
-
const { showLineNumbers } =
|
|
12
|
-
const document = useDocumentController({
|
|
13
|
-
adapter: sourceLineAdapter,
|
|
14
|
-
// The controller projects the screen's actions onto menu entries at open time.
|
|
15
|
-
contextMenu: actions,
|
|
16
|
-
decorations,
|
|
17
|
-
multiSelect: true,
|
|
18
|
-
rows: lineRows,
|
|
19
|
-
});
|
|
20
|
-
const statusItems = useMemo(() => [
|
|
21
|
-
{ label: "Format:", value: content.format },
|
|
22
|
-
{ label: "Lines:", value: String(lineRows.length) },
|
|
23
|
-
], [content.format, lineRows.length]);
|
|
10
|
+
const { document, showLineNumbers, statusItems } = useContentDocument(lineRows, sourceLineAdapter, { actions, content, decorations, textContent }, { multiSelect: true });
|
|
24
11
|
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(CodeView, { content: textContent, language: content.format === "code" ? content.language : undefined, showLineNumbers: showLineNumbers, document: document }) }));
|
|
25
12
|
};
|
|
26
13
|
//# sourceMappingURL=code-subview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/code-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"code-subview.js","sourceRoot":"","sources":["../../../src/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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CustomContent, ContentRenderer } from "../../types.js";
|
|
2
2
|
import type { SubviewProps } from "./types.js";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
interface CustomSubviewProps extends SubviewProps {
|
|
4
5
|
content: CustomContent;
|
|
5
6
|
renderers?: Record<string, ContentRenderer>;
|
|
6
7
|
}
|
|
7
|
-
export declare const CustomSubview: ({ content, decorations, actions, renderers, ...screen }: CustomSubviewProps) =>
|
|
8
|
+
export declare const CustomSubview: ({ content, decorations, actions, renderers, ...screen }: CustomSubviewProps) => ReactNode;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=custom-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/custom-subview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/custom-subview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,kBAAmB,SAAQ,YAAY;IAC/C,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,aAAa,4DAMvB,kBAAkB,KAAG,SA8BvB,CAAC"}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { CodeView, sourceLines, sourceLineAdapter } from "@tooee/renderers";
|
|
4
|
-
import { useDocumentController } from "@tooee/shell";
|
|
5
4
|
import { getTextContent } from "../../types.js";
|
|
6
|
-
import {
|
|
5
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
7
6
|
import { ViewScreen } from "../view-screen.js";
|
|
8
7
|
export const CustomSubview = function CustomSubview({ content, decorations, actions, renderers, ...screen }) {
|
|
9
8
|
const textContent = useMemo(() => getTextContent(content), [content]);
|
|
10
9
|
// Fallback rows are source lines; row index is the source line.
|
|
11
10
|
const lineRows = useMemo(() => sourceLines(textContent), [textContent]);
|
|
12
|
-
|
|
11
|
+
const { document, statusItems } = useContentDocument(lineRows, sourceLineAdapter, { actions, content, decorations, textContent },
|
|
13
12
|
// Custom content has no action rows of its own, so no context menu is bound.
|
|
14
|
-
|
|
15
|
-
adapter: sourceLineAdapter,
|
|
16
|
-
decorations,
|
|
17
|
-
multiSelect: true,
|
|
18
|
-
rows: lineRows,
|
|
19
|
-
});
|
|
20
|
-
const statusItems = useMemo(() => [
|
|
21
|
-
{ label: "Format:", value: content.format },
|
|
22
|
-
{ label: "Lines:", value: String(lineRows.length) },
|
|
23
|
-
], [content.format, lineRows.length]);
|
|
13
|
+
{ contextMenu: false, multiSelect: true });
|
|
24
14
|
const customRenderer = renderers?.[content.format];
|
|
25
15
|
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: customRenderer ? (customRenderer({ content, document })) : (_jsx(CodeView, { content: textContent, showLineNumbers: false, document: document })) }));
|
|
26
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/custom-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"custom-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/custom-subview.tsx"],"names":[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C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC/E,GACU,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DiffContent } from "../../types.js";
|
|
2
2
|
import type { SubviewProps } from "./types.js";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
interface DiffSubviewProps extends SubviewProps {
|
|
4
5
|
content: DiffContent;
|
|
5
6
|
}
|
|
@@ -10,6 +11,6 @@ interface DiffSubviewProps extends SubviewProps {
|
|
|
10
11
|
* scrolling, the cursor, decorations and mouse routing. The cursor row maps 1:1
|
|
11
12
|
* onto Hunk's `{ fileId, hunkIndex }` selection, so `j`/`k` step hunk by hunk.
|
|
12
13
|
*/
|
|
13
|
-
export declare const DiffSubview: ({ content, decorations, actions, ...screen }: DiffSubviewProps) =>
|
|
14
|
+
export declare const DiffSubview: ({ content, decorations, actions, ...screen }: DiffSubviewProps) => ReactNode;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=diff-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/diff-subview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/diff-subview.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,OAAO,EAAE,WAAW,CAAC;CACtB;AAcD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,iDAKrB,gBAAgB,KAAG,SAiLrB,CAAC"}
|
|
@@ -4,8 +4,7 @@ import { DiffView, buildDiffModel, diffRowAdapter } from "@tooee/diff";
|
|
|
4
4
|
import { useCommand } from "@tooee/commands";
|
|
5
5
|
import { useConfig } from "@tooee/config";
|
|
6
6
|
import { useOverlay } from "@tooee/overlays";
|
|
7
|
-
import {
|
|
8
|
-
import { useContentCommands } from "../../hooks/use-content-commands.js";
|
|
7
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
9
8
|
import { ViewScreen } from "../view-screen.js";
|
|
10
9
|
import { DiffFilePickerOverlay } from "../diff-file-picker.js";
|
|
11
10
|
/** Columns panned per h/l press when a hunk is wider than the viewport. */
|
|
@@ -32,15 +31,30 @@ export const DiffSubview = function DiffSubview({ content, decorations, actions,
|
|
|
32
31
|
const [layout, setLayout] = useState(content.layout ?? config.view?.diffLayout ?? "stack");
|
|
33
32
|
const [wrapLines, setWrapLines] = useState(config.view?.wrap ?? false);
|
|
34
33
|
const [horizontalOffset, setHorizontalOffset] = useState(0);
|
|
35
|
-
const { showLineNumbers } =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const { document, showLineNumbers, statusItems } = useContentDocument(model.rows, DIFF_ROW_ADAPTER, { actions, content, decorations, textContent }, {
|
|
35
|
+
buildStatusItems: (currentDocument) => {
|
|
36
|
+
const activeRow = currentDocument.activeIndex === null
|
|
37
|
+
? undefined
|
|
38
|
+
: model.rows[currentDocument.activeIndex];
|
|
39
|
+
return [
|
|
40
|
+
{ label: "Format:", value: content.format },
|
|
41
|
+
{ label: "Files:", value: String(model.files.length) },
|
|
42
|
+
{ label: "Changes:", value: `+${model.stats.additions} -${model.stats.deletions}` },
|
|
43
|
+
{ label: "Layout:", value: layout },
|
|
44
|
+
...(activeRow
|
|
45
|
+
? [
|
|
46
|
+
{
|
|
47
|
+
label: "At:",
|
|
48
|
+
value: activeRow.hunkIndex >= 0
|
|
49
|
+
? `${activeRow.parent.path ?? activeRow.fileId}:${activeRow.hunkIndex + 1}`
|
|
50
|
+
: (activeRow.parent.path ?? activeRow.fileId),
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
: []),
|
|
54
|
+
];
|
|
55
|
+
},
|
|
41
56
|
multiSelect: true,
|
|
42
57
|
preserveCursorByKey: true,
|
|
43
|
-
rows: model.rows,
|
|
44
58
|
});
|
|
45
59
|
const { activeIndex } = document;
|
|
46
60
|
// `setCursor` rather than `selectRow`: the latter stands down while a modal
|
|
@@ -137,30 +151,6 @@ export const DiffSubview = function DiffSubview({ content, decorations, actions,
|
|
|
137
151
|
modes: ["cursor", "select"],
|
|
138
152
|
title: "Go to file",
|
|
139
153
|
});
|
|
140
|
-
const activeRow = activeIndex === null ? undefined : model.rows[activeIndex];
|
|
141
|
-
const statusItems = useMemo(() => [
|
|
142
|
-
{ label: "Format:", value: content.format },
|
|
143
|
-
{ label: "Files:", value: String(model.files.length) },
|
|
144
|
-
{ label: "Changes:", value: `+${model.stats.additions} -${model.stats.deletions}` },
|
|
145
|
-
{ label: "Layout:", value: layout },
|
|
146
|
-
...(activeRow
|
|
147
|
-
? [
|
|
148
|
-
{
|
|
149
|
-
label: "At:",
|
|
150
|
-
value: activeRow.hunkIndex >= 0
|
|
151
|
-
? `${activeRow.parent.path ?? activeRow.fileId}:${activeRow.hunkIndex + 1}`
|
|
152
|
-
: (activeRow.parent.path ?? activeRow.fileId),
|
|
153
|
-
},
|
|
154
|
-
]
|
|
155
|
-
: []),
|
|
156
|
-
], [
|
|
157
|
-
activeRow,
|
|
158
|
-
content.format,
|
|
159
|
-
layout,
|
|
160
|
-
model.files.length,
|
|
161
|
-
model.stats.additions,
|
|
162
|
-
model.stats.deletions,
|
|
163
|
-
]);
|
|
164
154
|
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(DiffView, { rows: model.rows, document: document, activeIndex: activeIndex, showLineNumbers: showLineNumbers, layout: layout, wrapLines: wrapLines, horizontalOffset: horizontalOffset }) }));
|
|
165
155
|
};
|
|
166
156
|
//# sourceMappingURL=diff-subview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/diff-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"diff-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/diff-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAQ/D,2EAA2E;AAC3E,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,gBAAgB,GAAgC,cAAc,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW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ubviewProps } from "./types.js";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
interface ImageSubviewProps extends SubviewProps {
|
|
4
5
|
content: ImageContent;
|
|
5
6
|
}
|
|
6
|
-
export declare const ImageSubview: ({ content, decorations, actions, ...screen }: ImageSubviewProps) =>
|
|
7
|
+
export declare const ImageSubview: ({ content, decorations, actions, ...screen }: ImageSubviewProps) => ReactNode;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=image-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/image-subview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/image-subview.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,iBAAkB,SAAQ,YAAY;IAC9C,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,iDAKtB,iBAAiB,KAAG,SA4CtB,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { sourceLineAdapter, sourceLines } from "@tooee/renderers";
|
|
4
|
-
import { useDocumentController } from "@tooee/shell";
|
|
5
4
|
import { getTextContent } from "../../types.js";
|
|
6
|
-
import {
|
|
5
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
7
6
|
import { ViewScreen } from "../view-screen.js";
|
|
8
7
|
export const ImageSubview = function ImageSubview({ content, decorations, actions, ...screen }) {
|
|
9
8
|
const textContent = getTextContent(content);
|
|
@@ -12,15 +11,11 @@ export const ImageSubview = function ImageSubview({ content, decorations, action
|
|
|
12
11
|
useEffect(() => {
|
|
13
12
|
setError(false);
|
|
14
13
|
}, [content.src]);
|
|
15
|
-
|
|
16
|
-
const document = useDocumentController({
|
|
17
|
-
adapter: sourceLineAdapter,
|
|
18
|
-
contextMenu: actions,
|
|
19
|
-
decorations,
|
|
14
|
+
const { document, statusItems } = useContentDocument(rows, sourceLineAdapter, { actions, content, decorations, textContent }, {
|
|
20
15
|
multiSelect: false,
|
|
21
|
-
|
|
16
|
+
statusItems: [{ label: "Format:", value: content.format }],
|
|
22
17
|
});
|
|
23
|
-
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems:
|
|
18
|
+
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsxs("box", { style: { flexDirection: "column", flexGrow: 1 }, children: [error && _jsx("text", { content: `Image failed to load: ${textContent}` }), _jsx("image", { source: content.src, fit: content.fit ?? "fit", protocol: content.protocol ?? "auto", onError: () => {
|
|
24
19
|
setError(true);
|
|
25
20
|
}, onLoad: () => {
|
|
26
21
|
setError(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/image-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"image-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/image-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,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O,CAAC,GAAG,IAAI,KAAK,EACzB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,MAAM,EACpC,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACjB,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;wBACX,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAClB,CAAC,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GACtB,IACE,GACK,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { CodeBlockRenderer } from "@tooee/renderers";
|
|
2
2
|
import type { MarkdownContent, MarkdownLinkActivateHandler } from "../../types.js";
|
|
3
3
|
import type { SubviewProps } from "./types.js";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
4
5
|
interface MarkdownSubviewProps extends SubviewProps {
|
|
5
6
|
content: MarkdownContent;
|
|
6
7
|
codeBlockRenderers?: Record<string, CodeBlockRenderer>;
|
|
7
8
|
onLinkActivate?: MarkdownLinkActivateHandler;
|
|
8
9
|
}
|
|
9
|
-
export declare const MarkdownSubview: ({ content, codeBlockRenderers, onLinkActivate, decorations, actions, ...screen }: MarkdownSubviewProps) =>
|
|
10
|
+
export declare const MarkdownSubview: ({ content, codeBlockRenderers, onLinkActivate, decorations, actions, ...screen }: MarkdownSubviewProps) => ReactNode;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=markdown-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/markdown-subview.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/markdown-subview.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAGnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,oBAAqB,SAAQ,YAAY;IACjD,OAAO,EAAE,eAAe,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,2BAA2B,CAAC;CAC9C;AAeD,eAAO,MAAM,eAAe,qFAOzB,oBAAoB,KAAG,SA0EzB,CAAC"}
|
|
@@ -2,8 +2,7 @@ import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useRef } from "react";
|
|
3
3
|
import { MarkdownView, flattenMarkdown, getFlatBlockText } from "@tooee/renderers";
|
|
4
4
|
import { useBuildCommandContext, useCommand } from "@tooee/commands";
|
|
5
|
-
import {
|
|
6
|
-
import { useContentCommands } from "../../hooks/use-content-commands.js";
|
|
5
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
7
6
|
import { ViewScreen } from "../view-screen.js";
|
|
8
7
|
/** Columns moved per h/l press when scrolling a wide block horizontally. */
|
|
9
8
|
const BLOCK_HSCROLL_STEP = 4;
|
|
@@ -20,19 +19,17 @@ export const MarkdownSubview = function MarkdownSubview({ content, codeBlockRend
|
|
|
20
19
|
const textContent = content.markdown;
|
|
21
20
|
const lineCount = useMemo(() => textContent.split("\n").length, [textContent]);
|
|
22
21
|
const blocks = useMemo(() => flattenMarkdown(content.markdown), [content.markdown]);
|
|
23
|
-
const { showLineNumbers } =
|
|
22
|
+
const { document, showLineNumbers, statusItems } = useContentDocument(blocks, MARKDOWN_BLOCK_ADAPTER, { actions, content, decorations, textContent }, {
|
|
23
|
+
multiSelect: true,
|
|
24
|
+
statusItems: [
|
|
25
|
+
{ label: "Format:", value: content.format },
|
|
26
|
+
{ label: "Lines:", value: String(lineCount) },
|
|
27
|
+
],
|
|
28
|
+
});
|
|
24
29
|
const buildCommandContext = useBuildCommandContext();
|
|
25
30
|
const handleLinkActivate = onLinkActivate
|
|
26
31
|
? (href) => onLinkActivate(href, buildCommandContext())
|
|
27
32
|
: undefined;
|
|
28
|
-
const document = useDocumentController({
|
|
29
|
-
adapter: MARKDOWN_BLOCK_ADAPTER,
|
|
30
|
-
// The controller projects the screen's actions onto menu entries at open time.
|
|
31
|
-
contextMenu: actions,
|
|
32
|
-
decorations,
|
|
33
|
-
multiSelect: true,
|
|
34
|
-
rows: blocks,
|
|
35
|
-
});
|
|
36
33
|
const hScrollableBlocksRef = useRef(new Map());
|
|
37
34
|
const cursorScrollable = () => document.activeIndex === null
|
|
38
35
|
? undefined
|
|
@@ -63,10 +60,6 @@ export const MarkdownSubview = function MarkdownSubview({ content, codeBlockRend
|
|
|
63
60
|
title: "Scroll block right",
|
|
64
61
|
when: () => cursorScrollable() !== undefined,
|
|
65
62
|
});
|
|
66
|
-
const statusItems = useMemo(() => [
|
|
67
|
-
{ label: "Format:", value: content.format },
|
|
68
|
-
{ label: "Lines:", value: String(lineCount) },
|
|
69
|
-
], [content.format, lineCount]);
|
|
70
63
|
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(MarkdownView, { content: content.markdown, blocks: blocks, showLineNumbers: showLineNumbers, document: document, hScrollableBlocksRef: hScrollableBlocksRef, codeBlockRenderers: codeBlockRenderers, onLinkActivate: handleLinkActivate, imageBasePath: content.imageBasePath }) }));
|
|
71
64
|
};
|
|
72
65
|
//# sourceMappingURL=markdown-subview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/markdown-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EA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BAAgB,EAAE,KAAK,SAAS;KAC7C,CAAC,CAAC;IACH,UAAU,CAAC;QACT,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;YAClC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,OAAO,IAAI,kBAAkB,CAAC;YACvC,CAAC;QACH,CAAC;QACD,MAAM,EAAE,GAAG;QACX,EAAE,EAAE,oBAAoB;QACxB,KAAK,EAAE,CAAC,QAAQ,CAAC;QACjB,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,KAAK,SAAS;KAC7C,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,QAAQ,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,KACpB,MAAM,YAEV,KAAC,YAAY,IACX,OAAO,EAAE,OAAO,CAAC,QAAQ,EACzB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAC1C,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,OAAO,CAAC,aAAa,GACpC,GACS,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { TableContent } from "../../types.js";
|
|
2
2
|
import type { SubviewProps } from "./types.js";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
interface TableSubviewProps extends SubviewProps {
|
|
4
5
|
content: TableContent;
|
|
5
6
|
}
|
|
6
|
-
export declare const TableSubview: ({ content, decorations, actions, ...screen }: TableSubviewProps) =>
|
|
7
|
+
export declare const TableSubview: ({ content, decorations, actions, ...screen }: TableSubviewProps) => ReactNode;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=table-subview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/table-subview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-subview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/table-subview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,iBAAkB,SAAQ,YAAY;IAC9C,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,iDAKtB,iBAAiB,KAAG,SAmCtB,CAAC"}
|
|
@@ -1,62 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { Table } from "@tooee/renderers";
|
|
4
|
-
import { useDocumentController } from "@tooee/shell";
|
|
3
|
+
import { Table, formatTableCell } from "@tooee/renderers";
|
|
5
4
|
import { getTextContent } from "../../types.js";
|
|
6
|
-
import {
|
|
5
|
+
import { useContentDocument } from "../../hooks/use-content-document.js";
|
|
7
6
|
import { ViewScreen } from "../view-screen.js";
|
|
8
|
-
const stringifyRowCell = function stringifyRowCell(value) {
|
|
9
|
-
if (value === null || value === undefined) {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
if (typeof value === "string") {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
16
|
-
return String(value);
|
|
17
|
-
}
|
|
18
|
-
if (typeof value === "string") {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
if (typeof value === "number" ||
|
|
22
|
-
typeof value === "bigint" ||
|
|
23
|
-
typeof value === "boolean" ||
|
|
24
|
-
typeof value === "symbol") {
|
|
25
|
-
return value.toString();
|
|
26
|
-
}
|
|
27
|
-
if (value === null || value === undefined) {
|
|
28
|
-
return String(value);
|
|
29
|
-
}
|
|
30
|
-
if (typeof value === "function") {
|
|
31
|
-
return Function.prototype.toString.call(value);
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
return JSON.stringify(value);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return Array.isArray(value) ? value.join(",") : Object.prototype.toString.call(value);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
7
|
export const TableSubview = function TableSubview({ content, decorations, actions, ...screen }) {
|
|
41
8
|
const textContent = useMemo(() => getTextContent(content), [content]);
|
|
42
|
-
const { showLineNumbers } = useContentCommands({ content, textContent });
|
|
43
9
|
const { columns, rows } = content;
|
|
44
10
|
const adapter = useMemo(() => ({
|
|
45
|
-
getText: (row) => columns.map((column) =>
|
|
11
|
+
getText: (row) => columns.map((column) => formatTableCell(row[column.key])).join("\t"),
|
|
46
12
|
}), [columns]);
|
|
47
|
-
const document =
|
|
48
|
-
adapter,
|
|
49
|
-
// The controller projects the screen's actions onto menu entries at open time.
|
|
50
|
-
contextMenu: actions,
|
|
51
|
-
decorations,
|
|
13
|
+
const { document, showLineNumbers, statusItems } = useContentDocument(rows, adapter, { actions, content, decorations, textContent }, {
|
|
52
14
|
multiSelect: true,
|
|
53
|
-
|
|
15
|
+
statusItems: [
|
|
16
|
+
{ label: "Format:", value: content.format },
|
|
17
|
+
{ label: "Rows:", value: String(rows.length) },
|
|
18
|
+
{ label: "Cols:", value: String(columns.length) },
|
|
19
|
+
],
|
|
54
20
|
});
|
|
55
|
-
const statusItems = useMemo(() => [
|
|
56
|
-
{ label: "Format:", value: content.format },
|
|
57
|
-
{ label: "Rows:", value: String(rows.length) },
|
|
58
|
-
{ label: "Cols:", value: String(columns.length) },
|
|
59
|
-
], [content.format, rows.length, columns.length]);
|
|
60
21
|
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(Table, { columns: columns, rows: rows, showLineNumbers: showLineNumbers, document: document }) }));
|
|
61
22
|
};
|
|
62
23
|
//# sourceMappingURL=table-subview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/table-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"table-subview.js","sourceRoot":"","sources":["../../../src/components/subviews/table-subview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ/C,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,YAAY,CAAC,EAChD,OAAO,EACP,WAAW,EACX,OAAO,EACP,GAAG,MAAM,EACS;IAClB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,OAAO,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,CAAC,GAAa,EAAE,EAAE,CACzB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KACvE,CAAC,EACF,CAAC,OAAO,CAAC,CACV,CAAC;IACF,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,kBAAkB,CACnE,IAAI,EACJ,OAAO,EACP,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,EAC9C;QACE,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE;YACX,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;YAC3C,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YAC9C,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;SAClD;KACF,CACF,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,QAAQ,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,KACpB,MAAM,YAEV,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAI,GAClF,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
interface ViewStateProps {
|
|
2
3
|
message: string;
|
|
3
4
|
color?: string;
|
|
4
5
|
}
|
|
5
6
|
/** A non-document view state that preserves the viewer's normal quit command. */
|
|
6
|
-
export declare const ViewState: ({ message, color }: ViewStateProps) =>
|
|
7
|
+
export declare const ViewState: ({ message, color }: ViewStateProps) => ReactNode;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=view-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-state.d.ts","sourceRoot":"","sources":["../../src/components/view-state.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view-state.d.ts","sourceRoot":"","sources":["../../src/components/view-state.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iFAAiF;AACjF,eAAO,MAAM,SAAS,uBAA0C,cAAc,KAAG,SAQhF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-state.js","sourceRoot":"","sources":["../../src/components/view-state.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"view-state.js","sourceRoot":"","sources":["../../src/components/view-state.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ9C,iFAAiF;AACjF,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAkB;IAC5E,cAAc,EAAE,CAAC;IAEjB,OAAO,CACL,cAAK,KAAK,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,YACrC,eAAM,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAI,GACjC,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MarkSet } from "@tooee/marks";
|
|
2
2
|
import type { AnyContent, ContentChunk } from "./types.js";
|
|
3
|
+
type ContentProviderResult = AnyContent | Promise<AnyContent> | AsyncIterable<ContentChunk>;
|
|
3
4
|
export type ContentLoaderStatus = "idle" | "loading" | "streaming" | "ready" | "error";
|
|
4
5
|
export interface ContentLoaderContext {
|
|
5
6
|
status: ContentLoaderStatus;
|
|
@@ -42,10 +43,10 @@ interface ContentLoaderEventPayloads {
|
|
|
42
43
|
export type ContentLoaderEvents = {
|
|
43
44
|
[Event in keyof ContentLoaderEventPayloads]: ContentLoaderEventPayloads[Event];
|
|
44
45
|
};
|
|
45
|
-
export declare const isAsyncIterable: (value:
|
|
46
|
+
export declare const isAsyncIterable: (value: ContentProviderResult) => value is AsyncIterable<ContentChunk>;
|
|
46
47
|
export declare const createEmptyContent: (format: string, title?: string) => AnyContent;
|
|
47
48
|
export declare const applyContentChunk: (current: AnyContent | null, chunk: ContentChunk, title?: string) => AnyContent;
|
|
48
|
-
export declare const normalizeError: (
|
|
49
|
+
export declare const normalizeError: (cause: unknown) => string;
|
|
49
50
|
export declare const createContentLoaderStore: () => import("@xstate/store").Store<ContentLoaderContext, ContentLoaderEvents, never>;
|
|
50
51
|
export declare const selectContent: (ctx: ContentLoaderContext) => AnyContent | null;
|
|
51
52
|
export declare const selectStatus: (ctx: ContentLoaderContext) => ContentLoaderStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-loader-store.d.ts","sourceRoot":"","sources":["../src/content-loader-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAW,YAAY,EAAiB,MAAM,YAAY,CAAC;AAEnF,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,UAAU,0BAA0B;IAClC,WAAW,EAAE;QAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAAC,KAAK,CAA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,cAAc,UAAkC,OAAO,KAAG,MAEtE,CAAC;AAEF,eAAO,MAAM,wBAAwB,uFAuDpC,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,oBAAoB,sBAAgB,CAAC;AACxE,eAAO,MAAM,YAAY,QAAS,oBAAoB,wBAAe,CAAC;AACtE,eAAO,MAAM,eAAe,QAAS,oBAAoB,YAA+B,CAAC;AACzF,eAAO,MAAM,WAAW,QAAS,oBAAoB,kBAAc,CAAC;AACpE,eAAO,MAAM,mBAAmB,QAAS,oBAAoB,cAAsB,CAAC;AACpF,eAAO,MAAM,aAAa,QAAS,oBAAoB,WAAgB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { createStore } from "@xstate/store";
|
|
|
2
2
|
export const isAsyncIterable = function isAsyncIterable(value) {
|
|
3
3
|
return (value !== null &&
|
|
4
4
|
value !== undefined &&
|
|
5
|
+
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- provider result boundary distinguishes the documented async-iterable source from content and promises
|
|
5
6
|
typeof value === "object" &&
|
|
6
7
|
Symbol.asyncIterator in value);
|
|
7
8
|
};
|
|
@@ -26,11 +27,11 @@ export const createEmptyContent = function createEmptyContent(format, title) {
|
|
|
26
27
|
};
|
|
27
28
|
const ensureContentFormat = function ensureContentFormat(current, format, title) {
|
|
28
29
|
if (!current || current.format !== format) {
|
|
29
|
-
//
|
|
30
|
+
// SAFETY: createEmptyContent returns the built-in content variant selected by the same format.
|
|
30
31
|
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- format-dependent content is trusted at this provider boundary
|
|
31
32
|
return createEmptyContent(format, title);
|
|
32
33
|
}
|
|
33
|
-
//
|
|
34
|
+
// SAFETY: The equality guard narrows current to the built-in content variant selected by format.
|
|
34
35
|
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the provider contract supplies the matching format
|
|
35
36
|
return current;
|
|
36
37
|
};
|
|
@@ -68,8 +69,8 @@ export const applyContentChunk = function applyContentChunk(current, chunk, titl
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
|
-
export const normalizeError = function normalizeError(
|
|
72
|
-
return
|
|
72
|
+
export const normalizeError = function normalizeError(cause) {
|
|
73
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
73
74
|
};
|
|
74
75
|
export const createContentLoaderStore = function createContentLoaderStore() {
|
|
75
76
|
return createStore({
|