@tooee/view 0.2.3 → 0.3.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/README.md +15 -15
- package/dist/components/subviews/{CodeSubview.d.ts → code-subview.d.ts} +2 -2
- package/dist/components/subviews/code-subview.d.ts.map +1 -0
- package/dist/components/subviews/{CodeSubview.js → code-subview.js} +8 -8
- package/dist/components/subviews/code-subview.js.map +1 -0
- package/dist/components/subviews/custom-subview.d.ts +9 -0
- package/dist/components/subviews/custom-subview.d.ts.map +1 -0
- package/dist/components/subviews/{CustomSubview.js → custom-subview.js} +7 -7
- package/dist/components/subviews/custom-subview.js.map +1 -0
- package/dist/components/subviews/index.d.ts +4 -4
- package/dist/components/subviews/index.d.ts.map +1 -1
- package/dist/components/subviews/index.js +4 -4
- package/dist/components/subviews/index.js.map +1 -1
- package/dist/components/subviews/markdown-subview.d.ts +11 -0
- package/dist/components/subviews/markdown-subview.d.ts.map +1 -0
- package/dist/components/subviews/{MarkdownSubview.js → markdown-subview.js} +28 -26
- package/dist/components/subviews/markdown-subview.js.map +1 -0
- package/dist/components/subviews/table-subview.d.ts +8 -0
- package/dist/components/subviews/table-subview.d.ts.map +1 -0
- package/dist/components/subviews/{TableSubview.js → table-subview.js} +40 -22
- package/dist/components/subviews/table-subview.js.map +1 -0
- package/dist/components/subviews/types.d.ts.map +1 -1
- package/dist/components/{ViewScreen.d.ts → view-screen.d.ts} +3 -3
- package/dist/components/view-screen.d.ts.map +1 -0
- package/dist/components/{ViewScreen.js → view-screen.js} +11 -11
- package/dist/components/view-screen.js.map +1 -0
- package/dist/content-loader-store.d.ts +11 -7
- package/dist/content-loader-store.d.ts.map +1 -1
- package/dist/content-loader-store.js +70 -50
- package/dist/content-loader-store.js.map +1 -1
- package/dist/default-provider.d.ts +4 -4
- package/dist/default-provider.d.ts.map +1 -1
- package/dist/default-provider.js +48 -39
- package/dist/default-provider.js.map +1 -1
- package/dist/directory-provider.d.ts +2 -2
- package/dist/directory-provider.d.ts.map +1 -1
- package/dist/directory-provider.js +13 -10
- package/dist/directory-provider.js.map +1 -1
- package/dist/directory-view.d.ts +8 -0
- package/dist/directory-view.d.ts.map +1 -0
- package/dist/{DirectoryView.js → directory-view.js} +18 -12
- package/dist/directory-view.js.map +1 -0
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/{useContentCommands.d.ts → use-content-commands.d.ts} +2 -2
- package/dist/hooks/use-content-commands.d.ts.map +1 -0
- package/dist/hooks/{useContentCommands.js → use-content-commands.js} +6 -4
- package/dist/hooks/use-content-commands.js.map +1 -0
- package/dist/hooks/{useContentLoader.d.ts → use-content-loader.d.ts} +4 -4
- package/dist/hooks/use-content-loader.d.ts.map +1 -0
- package/dist/hooks/use-content-loader.js +81 -0
- package/dist/hooks/use-content-loader.js.map +1 -0
- package/dist/hooks/{useViewCommandContext.d.ts → use-view-command-context.d.ts} +3 -3
- package/dist/hooks/use-view-command-context.d.ts.map +1 -0
- package/dist/hooks/{useViewCommandContext.js → use-view-command-context.js} +15 -13
- package/dist/hooks/use-view-command-context.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/launch.d.ts +2 -2
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +6 -6
- package/dist/launch.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +46 -24
- package/dist/types.js.map +1 -1
- package/dist/view.d.ts +18 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/{View.js → view.js} +20 -14
- package/dist/view.js.map +1 -0
- package/package.json +10 -10
- package/src/components/subviews/{CodeSubview.tsx → code-subview.tsx} +25 -19
- package/src/components/subviews/{CustomSubview.tsx → custom-subview.tsx} +23 -21
- package/src/components/subviews/index.ts +5 -5
- package/src/components/subviews/{MarkdownSubview.tsx → markdown-subview.tsx} +55 -52
- package/src/components/subviews/table-subview.tsx +95 -0
- package/src/components/subviews/types.ts +14 -14
- package/src/components/{ViewScreen.tsx → view-screen.tsx} +33 -32
- package/src/content-loader-store.ts +131 -99
- package/src/default-provider.ts +84 -64
- package/src/directory-provider.ts +32 -24
- package/src/directory-view.tsx +79 -0
- package/src/hooks/index.ts +7 -4
- package/src/hooks/{useContentCommands.ts → use-content-commands.ts} +19 -14
- package/src/hooks/use-content-loader.ts +92 -0
- package/src/hooks/{useViewCommandContext.ts → use-view-command-context.ts} +40 -38
- package/src/index.ts +14 -14
- package/src/launch.tsx +20 -18
- package/src/types.ts +107 -78
- package/src/view.tsx +114 -0
- package/dist/DirectoryView.d.ts +0 -7
- package/dist/DirectoryView.d.ts.map +0 -1
- package/dist/DirectoryView.js.map +0 -1
- package/dist/View.d.ts +0 -16
- package/dist/View.d.ts.map +0 -1
- package/dist/View.js.map +0 -1
- package/dist/components/ViewScreen.d.ts.map +0 -1
- package/dist/components/ViewScreen.js.map +0 -1
- package/dist/components/subviews/CodeSubview.d.ts.map +0 -1
- package/dist/components/subviews/CodeSubview.js.map +0 -1
- package/dist/components/subviews/CustomSubview.d.ts +0 -9
- package/dist/components/subviews/CustomSubview.d.ts.map +0 -1
- package/dist/components/subviews/CustomSubview.js.map +0 -1
- package/dist/components/subviews/MarkdownSubview.d.ts +0 -10
- package/dist/components/subviews/MarkdownSubview.d.ts.map +0 -1
- package/dist/components/subviews/MarkdownSubview.js.map +0 -1
- package/dist/components/subviews/TableSubview.d.ts +0 -8
- package/dist/components/subviews/TableSubview.d.ts.map +0 -1
- package/dist/components/subviews/TableSubview.js.map +0 -1
- package/dist/hooks/useContentCommands.d.ts.map +0 -1
- package/dist/hooks/useContentCommands.js.map +0 -1
- package/dist/hooks/useContentLoader.d.ts.map +0 -1
- package/dist/hooks/useContentLoader.js +0 -55
- package/dist/hooks/useContentLoader.js.map +0 -1
- package/dist/hooks/useViewCommandContext.d.ts.map +0 -1
- package/dist/hooks/useViewCommandContext.js.map +0 -1
- package/src/DirectoryView.tsx +0 -68
- package/src/View.tsx +0 -94
- package/src/components/subviews/TableSubview.tsx +0 -65
- package/src/hooks/useContentLoader.ts +0 -72
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { createStore } from "@xstate/store";
|
|
2
|
-
export function isAsyncIterable(value) {
|
|
3
|
-
return value
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export const isAsyncIterable = function isAsyncIterable(value) {
|
|
3
|
+
return (value !== null &&
|
|
4
|
+
value !== undefined &&
|
|
5
|
+
typeof value === "object" &&
|
|
6
|
+
Symbol.asyncIterator in value);
|
|
7
|
+
};
|
|
8
|
+
export const createEmptyContent = function createEmptyContent(format, title) {
|
|
6
9
|
switch (format) {
|
|
7
|
-
case "markdown":
|
|
10
|
+
case "markdown": {
|
|
8
11
|
return { format, markdown: "", title };
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
}
|
|
13
|
+
case "code": {
|
|
14
|
+
return { code: "", format, title };
|
|
15
|
+
}
|
|
16
|
+
case "text": {
|
|
12
17
|
return { format, text: "", title };
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
}
|
|
19
|
+
case "table": {
|
|
20
|
+
return { columns: [], format, rows: [], title };
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
return { data: undefined, format, title };
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
|
-
}
|
|
19
|
-
function ensureContentFormat(current, format, title) {
|
|
26
|
+
};
|
|
27
|
+
const ensureContentFormat = function ensureContentFormat(current, format, title) {
|
|
20
28
|
if (!current || current.format !== format) {
|
|
29
|
+
// Deferred(lint-sweep): add schema-based validation for custom and streamed content formats.
|
|
30
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- format-dependent content is trusted at this provider boundary
|
|
21
31
|
return createEmptyContent(format, title);
|
|
22
32
|
}
|
|
33
|
+
// Deferred(lint-sweep): add schema-based validation for custom and streamed content formats.
|
|
34
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the provider contract supplies the matching format
|
|
23
35
|
return current;
|
|
24
|
-
}
|
|
25
|
-
export function applyContentChunk(current, chunk, title) {
|
|
36
|
+
};
|
|
37
|
+
export const applyContentChunk = function applyContentChunk(current, chunk, title) {
|
|
26
38
|
switch (chunk.type) {
|
|
27
|
-
case "replace":
|
|
39
|
+
case "replace": {
|
|
28
40
|
return chunk.content;
|
|
29
|
-
|
|
41
|
+
}
|
|
42
|
+
case "append": {
|
|
30
43
|
if (chunk.format === "markdown") {
|
|
31
44
|
const target = ensureContentFormat(current, "markdown", title);
|
|
32
45
|
return { ...target, markdown: target.markdown + chunk.data };
|
|
@@ -43,45 +56,37 @@ export function applyContentChunk(current, chunk, title) {
|
|
|
43
56
|
const target = ensureContentFormat(current, "text", title);
|
|
44
57
|
return { ...target, text: target.text + chunk.data };
|
|
45
58
|
}
|
|
46
|
-
|
|
59
|
+
}
|
|
60
|
+
case "patch": {
|
|
47
61
|
return chunk.apply(current);
|
|
48
|
-
|
|
62
|
+
}
|
|
63
|
+
case "marks": {
|
|
49
64
|
return current ?? createEmptyContent("markdown", title);
|
|
65
|
+
}
|
|
66
|
+
default: {
|
|
67
|
+
return current ?? createEmptyContent("markdown", title);
|
|
68
|
+
}
|
|
50
69
|
}
|
|
51
|
-
}
|
|
52
|
-
export function normalizeError(error) {
|
|
70
|
+
};
|
|
71
|
+
export const normalizeError = function normalizeError(error) {
|
|
53
72
|
return error instanceof Error ? error.message : String(error);
|
|
54
|
-
}
|
|
55
|
-
export function createContentLoaderStore() {
|
|
73
|
+
};
|
|
74
|
+
export const createContentLoaderStore = function createContentLoaderStore() {
|
|
56
75
|
return createStore({
|
|
57
76
|
context: {
|
|
58
|
-
status: "idle",
|
|
59
|
-
requestId: 0,
|
|
60
|
-
loadSeq: 0,
|
|
61
77
|
content: null,
|
|
62
78
|
error: null,
|
|
79
|
+
loadSeq: 0,
|
|
63
80
|
providerMarks: [],
|
|
81
|
+
requestId: 0,
|
|
82
|
+
status: "idle",
|
|
64
83
|
title: undefined,
|
|
65
84
|
},
|
|
66
85
|
on: {
|
|
67
|
-
loadStarted: (ctx, event) => ({
|
|
68
|
-
...ctx,
|
|
69
|
-
status: "loading",
|
|
70
|
-
requestId: ctx.requestId + 1,
|
|
71
|
-
error: null,
|
|
72
|
-
providerMarks: event.marks,
|
|
73
|
-
title: event.title,
|
|
74
|
-
}),
|
|
75
|
-
streamStarted: (ctx, event) => event.requestId !== ctx.requestId
|
|
76
|
-
? ctx
|
|
77
|
-
: {
|
|
78
|
-
...ctx,
|
|
79
|
-
status: "streaming",
|
|
80
|
-
content: createEmptyContent(event.format, ctx.title),
|
|
81
|
-
},
|
|
82
86
|
chunkReceived: (ctx, event) => {
|
|
83
|
-
if (event.requestId !== ctx.requestId)
|
|
87
|
+
if (event.requestId !== ctx.requestId) {
|
|
84
88
|
return ctx;
|
|
89
|
+
}
|
|
85
90
|
if (event.chunk.type === "marks") {
|
|
86
91
|
const markSet = event.chunk.set;
|
|
87
92
|
const providerMarks = [
|
|
@@ -92,16 +97,31 @@ export function createContentLoaderStore() {
|
|
|
92
97
|
}
|
|
93
98
|
return { ...ctx, content: applyContentChunk(ctx.content, event.chunk, ctx.title) };
|
|
94
99
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
loadCancelled: (ctx, event) => event.requestId === ctx.requestId ? { ...ctx, requestId: ctx.requestId + 1 } : ctx,
|
|
101
|
+
loadFailed: (ctx, event) => event.requestId === ctx.requestId ? { ...ctx, error: event.error, status: "error" } : ctx,
|
|
102
|
+
loadStarted: (ctx, event) => ({
|
|
103
|
+
...ctx,
|
|
104
|
+
error: null,
|
|
105
|
+
providerMarks: event.marks,
|
|
106
|
+
requestId: ctx.requestId + 1,
|
|
107
|
+
status: "loading",
|
|
108
|
+
title: event.title,
|
|
109
|
+
}),
|
|
110
|
+
loaded: (ctx, event) => event.requestId === ctx.requestId
|
|
111
|
+
? { ...ctx, content: event.content, status: "ready" }
|
|
112
|
+
: ctx,
|
|
101
113
|
reloadRequested: (ctx) => ({ ...ctx, loadSeq: ctx.loadSeq + 1 }),
|
|
114
|
+
streamEnded: (ctx, event) => event.requestId === ctx.requestId ? { ...ctx, status: "ready" } : ctx,
|
|
115
|
+
streamStarted: (ctx, event) => event.requestId === ctx.requestId
|
|
116
|
+
? {
|
|
117
|
+
...ctx,
|
|
118
|
+
content: createEmptyContent(event.format, ctx.title),
|
|
119
|
+
status: "streaming",
|
|
120
|
+
}
|
|
121
|
+
: ctx,
|
|
102
122
|
},
|
|
103
123
|
});
|
|
104
|
-
}
|
|
124
|
+
};
|
|
105
125
|
export const selectContent = (ctx) => ctx.content;
|
|
106
126
|
export const selectStatus = (ctx) => ctx.status;
|
|
107
127
|
export const selectStreaming = (ctx) => ctx.status === "streaming";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-loader-store.js","sourceRoot":"","sources":["../src/content-loader-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"content-loader-store.js","sourceRoot":"","sources":["../src/content-loader-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA+B5C,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,eAAe,CACrD,KAAc;IAEd,OAAO,CACL,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,SAAS;QACnB,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,aAAa,IAAI,KAAK,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,kBAAkB,CAC3D,MAAc,EACd,KAAc;IAEd,QAAQ,MAAM,EAAE,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,CAAC,CAAC;oBACE,GAAG,GAAG;oBACN,OAAO,EAAE,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC;oBACpD,MAAM,EAAE,WAAW;iBACpB;gBACH,CAAC,CAAC,GAAG;SACV;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;AACxE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC;AACzF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC"}
|
|
@@ -2,8 +2,8 @@ import type { ContentFormat, ContentProvider } from "./types.js";
|
|
|
2
2
|
export interface CreateProviderOptions {
|
|
3
3
|
renderer?: ContentFormat;
|
|
4
4
|
}
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
8
|
-
export declare
|
|
5
|
+
export declare const createFileProvider: (filePath: string, options?: CreateProviderOptions) => ContentProvider;
|
|
6
|
+
export declare const createStdinProvider: (options?: CreateProviderOptions) => ContentProvider;
|
|
7
|
+
export declare const createTableFileProvider: (filePath: string) => ContentProvider;
|
|
8
|
+
export declare const createTableStdinProvider: () => ContentProvider;
|
|
9
9
|
//# sourceMappingURL=default-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAmFD,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,UAAS,qBAA0B,KAClC,eAYF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,UAAS,qBAA0B,KAClC,eAQF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,KACf,eAEF,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAwC,eAE5E,CAAC"}
|
package/dist/default-provider.js
CHANGED
|
@@ -1,62 +1,71 @@
|
|
|
1
1
|
import { parseAuto } from "@tooee/renderers";
|
|
2
|
-
function detectFormat(filePath) {
|
|
2
|
+
const detectFormat = function detectFormat(filePath) {
|
|
3
3
|
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
4
|
-
if (
|
|
4
|
+
if (ext === undefined || ext === "") {
|
|
5
5
|
return { format: "text" };
|
|
6
|
+
}
|
|
6
7
|
const tableExts = new Set(["csv", "tsv"]);
|
|
7
|
-
if (tableExts.has(ext))
|
|
8
|
+
if (tableExts.has(ext)) {
|
|
8
9
|
return { format: "table" };
|
|
10
|
+
}
|
|
9
11
|
const markdownExts = new Set(["md", "mdx", "markdown"]);
|
|
10
|
-
if (markdownExts.has(ext))
|
|
12
|
+
if (markdownExts.has(ext)) {
|
|
11
13
|
return { format: "markdown" };
|
|
14
|
+
}
|
|
12
15
|
const codeExts = {
|
|
13
|
-
ts: "typescript",
|
|
14
|
-
tsx: "typescript",
|
|
15
|
-
js: "javascript",
|
|
16
|
-
jsx: "javascript",
|
|
17
|
-
py: "python",
|
|
18
|
-
rs: "rust",
|
|
19
|
-
go: "go",
|
|
20
|
-
rb: "ruby",
|
|
21
|
-
sh: "bash",
|
|
22
16
|
bash: "bash",
|
|
23
|
-
zsh: "zsh",
|
|
24
|
-
json: "json",
|
|
25
|
-
yaml: "yaml",
|
|
26
|
-
yml: "yaml",
|
|
27
|
-
toml: "toml",
|
|
28
|
-
css: "css",
|
|
29
|
-
html: "html",
|
|
30
|
-
sql: "sql",
|
|
31
17
|
c: "c",
|
|
32
18
|
cpp: "cpp",
|
|
19
|
+
css: "css",
|
|
20
|
+
go: "go",
|
|
33
21
|
h: "c",
|
|
34
22
|
hpp: "cpp",
|
|
23
|
+
html: "html",
|
|
35
24
|
java: "java",
|
|
25
|
+
js: "javascript",
|
|
26
|
+
json: "json",
|
|
27
|
+
jsx: "javascript",
|
|
36
28
|
kt: "kotlin",
|
|
29
|
+
py: "python",
|
|
30
|
+
rb: "ruby",
|
|
31
|
+
rs: "rust",
|
|
32
|
+
sh: "bash",
|
|
33
|
+
sql: "sql",
|
|
37
34
|
swift: "swift",
|
|
35
|
+
toml: "toml",
|
|
36
|
+
ts: "typescript",
|
|
37
|
+
tsx: "typescript",
|
|
38
|
+
yaml: "yaml",
|
|
39
|
+
yml: "yaml",
|
|
40
|
+
zsh: "zsh",
|
|
38
41
|
};
|
|
39
42
|
const language = codeExts[ext];
|
|
40
|
-
if (language)
|
|
43
|
+
if (typeof language === "string") {
|
|
41
44
|
return { format: "code", language };
|
|
45
|
+
}
|
|
42
46
|
return { format: "text" };
|
|
43
|
-
}
|
|
44
|
-
function contentFromText(text, format, title, language) {
|
|
47
|
+
};
|
|
48
|
+
const contentFromText = function contentFromText(text, format, title, language) {
|
|
45
49
|
switch (format) {
|
|
46
|
-
case "markdown":
|
|
50
|
+
case "markdown": {
|
|
47
51
|
return { format: "markdown", markdown: text, title };
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
}
|
|
53
|
+
case "code": {
|
|
54
|
+
return { code: text, format: "code", language, title };
|
|
55
|
+
}
|
|
50
56
|
case "table": {
|
|
51
57
|
const parsed = parseAuto(text);
|
|
52
|
-
return { format: "table",
|
|
58
|
+
return { columns: parsed.columns, format: "table", rows: parsed.rows, title };
|
|
53
59
|
}
|
|
54
|
-
case "text":
|
|
55
|
-
default:
|
|
60
|
+
case "text": {
|
|
56
61
|
return { format: "text", text, title };
|
|
62
|
+
}
|
|
63
|
+
default: {
|
|
64
|
+
return { format: "text", text, title };
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
|
-
}
|
|
59
|
-
export function createFileProvider(filePath, options = {}) {
|
|
67
|
+
};
|
|
68
|
+
export const createFileProvider = function createFileProvider(filePath, options = {}) {
|
|
60
69
|
return {
|
|
61
70
|
async load() {
|
|
62
71
|
const detected = detectFormat(filePath);
|
|
@@ -67,8 +76,8 @@ export function createFileProvider(filePath, options = {}) {
|
|
|
67
76
|
return contentFromText(text, format, title, detected.language);
|
|
68
77
|
},
|
|
69
78
|
};
|
|
70
|
-
}
|
|
71
|
-
export function createStdinProvider(options = {}) {
|
|
79
|
+
};
|
|
80
|
+
export const createStdinProvider = function createStdinProvider(options = {}) {
|
|
72
81
|
return {
|
|
73
82
|
async load() {
|
|
74
83
|
const text = await new Response(Bun.stdin.stream()).text();
|
|
@@ -76,11 +85,11 @@ export function createStdinProvider(options = {}) {
|
|
|
76
85
|
return contentFromText(text, format, "stdin");
|
|
77
86
|
},
|
|
78
87
|
};
|
|
79
|
-
}
|
|
80
|
-
export function createTableFileProvider(filePath) {
|
|
88
|
+
};
|
|
89
|
+
export const createTableFileProvider = function createTableFileProvider(filePath) {
|
|
81
90
|
return createFileProvider(filePath, { renderer: "table" });
|
|
82
|
-
}
|
|
83
|
-
export function createTableStdinProvider() {
|
|
91
|
+
};
|
|
92
|
+
export const createTableStdinProvider = function createTableStdinProvider() {
|
|
84
93
|
return createStdinProvider({ renderer: "table" });
|
|
85
|
-
}
|
|
94
|
+
};
|
|
86
95
|
//# sourceMappingURL=default-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO7C,MAAM,YAAY,GAAG,SAAS,YAAY,CAAC,QAAgB;IAIzD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC;IACrD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1C,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IACxD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,MAAM,QAAQ,GAA2B;QACvC,IAAI,EAAE,MAAM;QACZ,CAAC,EAAE,GAAG;QACN,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,EAAE,EAAE,IAAI;QACR,CAAC,EAAE,GAAG;QACN,GAAG,EAAE,KA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C;YAC9C,OAAO,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,uBAAuB,CACrE,QAAgB;IAEhB,OAAO,kBAAkB,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,wBAAwB;IACvE,OAAO,mBAAmB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
|
@@ -3,6 +3,6 @@ export interface DirectoryEntry {
|
|
|
3
3
|
name: string;
|
|
4
4
|
path: string;
|
|
5
5
|
}
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
6
|
+
export declare const listDirectoryFiles: (dirPath: string) => DirectoryEntry[];
|
|
7
|
+
export declare const createDirectoryFileProvider: (filePath: string) => ContentProvider;
|
|
8
8
|
//# sourceMappingURL=directory-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-provider.d.ts","sourceRoot":"","sources":["../src/directory-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"directory-provider.d.ts","sourceRoot":"","sources":["../src/directory-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmClD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,kBAAkB,GAA+B,SAAS,MAAM,KAAG,cAAc,EA0B7F,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,KACf,eAEF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readdirSync, statSync } from "fs";
|
|
2
|
-
import
|
|
1
|
+
import { readdirSync, statSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { createFileProvider } from "./default-provider.js";
|
|
4
4
|
const SUPPORTED_EXTENSIONS = new Set([
|
|
5
5
|
"md",
|
|
@@ -32,30 +32,33 @@ const SUPPORTED_EXTENSIONS = new Set([
|
|
|
32
32
|
"swift",
|
|
33
33
|
"sql",
|
|
34
34
|
]);
|
|
35
|
-
export function listDirectoryFiles(dirPath) {
|
|
35
|
+
export const listDirectoryFiles = function listDirectoryFiles(dirPath) {
|
|
36
36
|
const entries = readdirSync(dirPath);
|
|
37
37
|
const files = [];
|
|
38
38
|
for (const entry of entries) {
|
|
39
|
-
if (entry.startsWith("."))
|
|
39
|
+
if (entry.startsWith(".")) {
|
|
40
40
|
continue;
|
|
41
|
-
|
|
41
|
+
}
|
|
42
|
+
const fullPath = path.join(dirPath, entry);
|
|
42
43
|
try {
|
|
43
44
|
const stat = statSync(fullPath);
|
|
44
|
-
if (!stat.isFile())
|
|
45
|
+
if (!stat.isFile()) {
|
|
45
46
|
continue;
|
|
47
|
+
}
|
|
46
48
|
}
|
|
47
49
|
catch {
|
|
48
50
|
continue;
|
|
49
51
|
}
|
|
50
52
|
const ext = entry.split(".").pop()?.toLowerCase();
|
|
51
|
-
if (
|
|
53
|
+
if (ext === undefined || ext === "" || !SUPPORTED_EXTENSIONS.has(ext)) {
|
|
52
54
|
continue;
|
|
55
|
+
}
|
|
53
56
|
files.push({ name: entry, path: fullPath });
|
|
54
57
|
}
|
|
55
58
|
files.sort((a, b) => a.name.localeCompare(b.name));
|
|
56
59
|
return files;
|
|
57
|
-
}
|
|
58
|
-
export function createDirectoryFileProvider(filePath) {
|
|
60
|
+
};
|
|
61
|
+
export const createDirectoryFileProvider = function createDirectoryFileProvider(filePath) {
|
|
59
62
|
return createFileProvider(filePath);
|
|
60
|
-
}
|
|
63
|
+
};
|
|
61
64
|
//# sourceMappingURL=directory-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-provider.js","sourceRoot":"","sources":["../src/directory-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"directory-provider.js","sourceRoot":"","sources":["../src/directory-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,IAAI;IACJ,KAAK;IACL,UAAU;IACV,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,KAAK;IACL,GAAG;IACH,KAAK;IACL,MAAM;IACN,IAAI;IACJ,OAAO;IACP,KAAK;CACN,CAAC,CAAC;AAOH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,kBAAkB,CAAC,OAAe;IAC3E,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,KAAK,GAAqB,EAAE,CAAC;IAEnC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBACnB,SAAS;YACX,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC;QAClD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACtE,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,2BAA2B,CAC7E,QAAgB;IAEhB,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionDefinition } from "@tooee/commands";
|
|
2
|
+
interface DirectoryViewProps {
|
|
3
|
+
dirPath: string;
|
|
4
|
+
actions?: ActionDefinition[];
|
|
5
|
+
}
|
|
6
|
+
export declare const DirectoryView: ({ dirPath, actions, }: DirectoryViewProps) => React.ReactNode;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=directory-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-view.d.ts","sourceRoot":"","sources":["../src/directory-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA2BxD,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,GAA0B,uBAGjD,kBAAkB,KAAG,KAAK,CAAC,SAyC7B,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useState, useMemo } from "react";
|
|
3
3
|
import { useCommand } from "@tooee/commands";
|
|
4
|
-
import { View } from "./
|
|
4
|
+
import { View } from "./view.js";
|
|
5
5
|
import { listDirectoryFiles } from "./directory-provider.js";
|
|
6
6
|
import { createFileProvider } from "./default-provider.js";
|
|
7
|
-
function createDirectoryFileProvider(entry, index, total) {
|
|
7
|
+
const createDirectoryFileProvider = function createDirectoryFileProvider(entry, index, total) {
|
|
8
8
|
const inner = createFileProvider(entry.path);
|
|
9
9
|
return {
|
|
10
10
|
async load() {
|
|
11
11
|
const result = inner.load();
|
|
12
|
+
// Deferred(lint-sweep): add schema-based validation for custom and streamed content formats.
|
|
13
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- file providers return external content at this boundary
|
|
12
14
|
const content = result instanceof Promise ? await result : result;
|
|
13
15
|
return {
|
|
14
16
|
...content,
|
|
@@ -16,30 +18,34 @@ function createDirectoryFileProvider(entry, index, total) {
|
|
|
16
18
|
};
|
|
17
19
|
},
|
|
18
20
|
};
|
|
19
|
-
}
|
|
20
|
-
export function DirectoryView({ dirPath, actions }) {
|
|
21
|
+
};
|
|
22
|
+
export const DirectoryView = function DirectoryView({ dirPath, actions, }) {
|
|
21
23
|
const files = useMemo(() => listDirectoryFiles(dirPath), [dirPath]);
|
|
22
24
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
23
25
|
const contentProvider = useMemo(() => files.length > 0
|
|
24
26
|
? createDirectoryFileProvider(files[currentIndex], currentIndex, files.length)
|
|
25
27
|
: null, [files, currentIndex]);
|
|
26
28
|
useCommand({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
handler: () => {
|
|
30
|
+
setCurrentIndex((i) => Math.min(i + 1, files.length - 1));
|
|
31
|
+
},
|
|
29
32
|
hotkey: "l",
|
|
33
|
+
id: "dir.next-file",
|
|
30
34
|
modes: ["cursor"],
|
|
31
|
-
|
|
35
|
+
title: "Next file",
|
|
32
36
|
});
|
|
33
37
|
useCommand({
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
handler: () => {
|
|
39
|
+
setCurrentIndex((i) => Math.max(i - 1, 0));
|
|
40
|
+
},
|
|
36
41
|
hotkey: "h",
|
|
42
|
+
id: "dir.prev-file",
|
|
37
43
|
modes: ["cursor"],
|
|
38
|
-
|
|
44
|
+
title: "Previous file",
|
|
39
45
|
});
|
|
40
46
|
if (files.length === 0 || !contentProvider) {
|
|
41
47
|
return (_jsx("box", { children: _jsx("text", { content: "No viewable files in directory" }) }));
|
|
42
48
|
}
|
|
43
49
|
return _jsx(View, { contentProvider: contentProvider, actions: actions });
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=directory-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-view.js","sourceRoot":"","sources":["../src/directory-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,2BAA2B,GAAG,SAAS,2BAA2B,CACtE,KAAqB,EACrB,KAAa,EACb,KAAa;IAEb,MAAM,KAAK,GAAG,kBA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E,CAAC,QAAQ,CAAC;QACjB,KAAK,EAAE,WAAW;KACnB,CAAC,CAAC;IAEH,UAAU,CAAC;QACT,OAAO,EAAE,GAAG,EAAE;YACZ,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,EAAE,GAAG;QACX,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,CAAC,QAAQ,CAAC;QACjB,KAAK,EAAE,eAAe;KACvB,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3C,OAAO,CACL,wBACE,eAAM,OAAO,EAAC,gCAAgC,GAAG,GAC7C,CACP,CAAC;IACJ,CAAC;IAED,OAAO,KAAC,IAAI,IAAC,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAI,CAAC;AACtE,CAAC,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useContentLoader } from "./
|
|
2
|
-
export { useContentCommands } from "./
|
|
3
|
-
export { createViewCommandContext, useProvideViewCommandContext } from "./
|
|
4
|
-
export type { CreateViewCommandContextOptions, ProvideViewCommandContextOptions, ViewCommandContext, } from "./
|
|
1
|
+
export { useContentLoader } from "./use-content-loader.js";
|
|
2
|
+
export { useContentCommands } from "./use-content-commands.js";
|
|
3
|
+
export { createViewCommandContext, useProvideViewCommandContext, } from "./use-view-command-context.js";
|
|
4
|
+
export type { CreateViewCommandContextOptions, ProvideViewCommandContextOptions, ViewCommandContext, } from "./use-view-command-context.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,+BAA+B,EAC/B,gCAAgC,EAChC,kBAAkB,GACnB,MAAM,+BAA+B,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useContentLoader } from "./
|
|
2
|
-
export { useContentCommands } from "./
|
|
3
|
-
export { createViewCommandContext, useProvideViewCommandContext } from "./
|
|
1
|
+
export { useContentLoader } from "./use-content-loader.js";
|
|
2
|
+
export { useContentCommands } from "./use-content-commands.js";
|
|
3
|
+
export { createViewCommandContext, useProvideViewCommandContext, } from "./use-view-command-context.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC"}
|
|
@@ -8,8 +8,8 @@ interface UseContentCommandsParams {
|
|
|
8
8
|
* whole document and toggling the line-number gutter. Theme, quit, actions and
|
|
9
9
|
* every row-level command belong to the document controller and its screen.
|
|
10
10
|
*/
|
|
11
|
-
export declare
|
|
11
|
+
export declare const useContentCommands: ({ content, textContent, }: UseContentCommandsParams) => {
|
|
12
12
|
showLineNumbers: boolean;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=use-content-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-content-commands.d.ts","sourceRoot":"","sources":["../../src/hooks/use-content-commands.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,UAAU,wBAAwB;IAChC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAA+B,2BAG3D,wBAAwB;;CAe1B,CAAC"}
|
|
@@ -6,16 +6,18 @@ import { useConfig } from "@tooee/config";
|
|
|
6
6
|
* whole document and toggling the line-number gutter. Theme, quit, actions and
|
|
7
7
|
* every row-level command belong to the document controller and its screen.
|
|
8
8
|
*/
|
|
9
|
-
export function useContentCommands({ content, textContent }) {
|
|
9
|
+
export const useContentCommands = function useContentCommands({ content, textContent, }) {
|
|
10
10
|
const config = useConfig();
|
|
11
11
|
const [showLineNumbers, setShowLineNumbers] = useState(config.view?.gutter ?? true);
|
|
12
12
|
useCopyCommand({
|
|
13
13
|
getText: () => (content ? textContent : undefined),
|
|
14
14
|
});
|
|
15
15
|
useToggleLineNumbersCommand({
|
|
16
|
+
onToggle: () => {
|
|
17
|
+
setShowLineNumbers((v) => !v);
|
|
18
|
+
},
|
|
16
19
|
showLineNumbers,
|
|
17
|
-
onToggle: () => setShowLineNumbers((v) => !v),
|
|
18
20
|
});
|
|
19
21
|
return { showLineNumbers };
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=use-content-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-content-commands.js","sourceRoot":"","sources":["../../src/hooks/use-content-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAQ1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,kBAAkB,CAAC,EAC5D,OAAO,EACP,WAAW,GACc;IACzB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;IAEpF,cAAc,CAAC;QACb,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;KACnD,CAAC,CAAC;IACH,2BAA2B,CAAC;QAC1B,QAAQ,EAAE,GAAG,EAAE;YACb,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7B,CAAC,CAAC"}
|