@tooee/renderers 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/dist/code-blocks.d.ts +6 -6
- package/dist/code-blocks.d.ts.map +1 -1
- package/dist/code-blocks.js +52 -42
- package/dist/code-blocks.js.map +1 -1
- package/dist/{CodeView.d.ts → code-view.d.ts} +3 -3
- package/dist/code-view.d.ts.map +1 -0
- package/dist/{CodeView.js → code-view.js} +5 -5
- package/dist/code-view.js.map +1 -0
- package/dist/{CommandPalette.d.ts → command-palette.d.ts} +2 -2
- package/dist/command-palette.d.ts.map +1 -0
- package/dist/{CommandPalette.js → command-palette.js} +27 -24
- package/dist/command-palette.js.map +1 -0
- package/dist/{ContextMenu.d.ts → context-menu.d.ts} +2 -2
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/{ContextMenu.js → context-menu.js} +24 -14
- package/dist/context-menu.js.map +1 -0
- package/dist/{DecorationLayer.d.ts → decoration-layer.d.ts} +2 -2
- package/dist/decoration-layer.d.ts.map +1 -0
- package/dist/decoration-layer.js +2 -0
- package/dist/decoration-layer.js.map +1 -0
- package/dist/{DocumentBindings.d.ts → document-bindings.d.ts} +4 -4
- package/dist/document-bindings.d.ts.map +1 -0
- package/dist/document-bindings.js +2 -0
- package/dist/document-bindings.js.map +1 -0
- package/dist/index.d.ts +16 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/markdown-blocks.d.ts +9 -13
- package/dist/markdown-blocks.d.ts.map +1 -1
- package/dist/markdown-blocks.js +98 -79
- package/dist/markdown-blocks.js.map +1 -1
- package/dist/{MarkdownView.d.ts → markdown-view.d.ts} +20 -6
- package/dist/markdown-view.d.ts.map +1 -0
- package/dist/markdown-view.js +455 -0
- package/dist/markdown-view.js.map +1 -0
- package/dist/mermaid.d.ts +5 -5
- package/dist/mermaid.d.ts.map +1 -1
- package/dist/mermaid.js +33 -25
- package/dist/mermaid.js.map +1 -1
- package/dist/parsers.d.ts +5 -5
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +64 -44
- package/dist/parsers.js.map +1 -1
- package/dist/{RowDocumentRenderable.d.ts → row-document-renderable.d.ts} +15 -11
- package/dist/row-document-renderable.d.ts.map +1 -0
- package/dist/{RowDocumentRenderable.js → row-document-renderable.js} +110 -62
- package/dist/row-document-renderable.js.map +1 -0
- package/dist/row-document.d.ts +1 -1
- package/dist/row-document.d.ts.map +1 -1
- package/dist/row-document.js +1 -1
- package/dist/row-document.js.map +1 -1
- package/dist/source.d.ts +6 -6
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +35 -26
- package/dist/source.js.map +1 -1
- package/dist/table-types.d.ts.map +1 -1
- package/dist/{Table.d.ts → table.d.ts} +6 -6
- package/dist/table.d.ts.map +1 -0
- package/dist/{Table.js → table.js} +65 -35
- package/dist/table.js.map +1 -0
- package/dist/text-table.d.ts.map +1 -1
- package/dist/text-table.js.map +1 -1
- package/dist/use-gutter-palette.d.ts +3 -0
- package/dist/use-gutter-palette.d.ts.map +1 -0
- package/dist/{useGutterPalette.js → use-gutter-palette.js} +4 -4
- package/dist/use-gutter-palette.js.map +1 -0
- package/package.json +5 -5
- package/src/code-blocks.tsx +122 -106
- package/src/{CodeView.tsx → code-view.tsx} +19 -14
- package/src/command-palette.tsx +163 -0
- package/src/context-menu.tsx +157 -0
- package/src/decoration-layer.ts +11 -0
- package/src/document-bindings.ts +16 -0
- package/src/index.ts +24 -23
- package/src/markdown-blocks.ts +178 -138
- package/src/markdown-view.tsx +853 -0
- package/src/mermaid.ts +94 -71
- package/src/parsers.ts +141 -103
- package/src/row-document-renderable.ts +672 -0
- package/src/row-document.ts +4 -4
- package/src/source.ts +92 -72
- package/src/table-types.ts +4 -4
- package/src/table.tsx +346 -0
- package/src/text-table.ts +4 -4
- package/src/use-gutter-palette.ts +15 -0
- package/dist/CodeView.d.ts.map +0 -1
- package/dist/CodeView.js.map +0 -1
- package/dist/CommandPalette.d.ts.map +0 -1
- package/dist/CommandPalette.js.map +0 -1
- package/dist/ContextMenu.d.ts.map +0 -1
- package/dist/ContextMenu.js.map +0 -1
- package/dist/DecorationLayer.d.ts.map +0 -1
- package/dist/DecorationLayer.js +0 -2
- package/dist/DecorationLayer.js.map +0 -1
- package/dist/DocumentBindings.d.ts.map +0 -1
- package/dist/DocumentBindings.js +0 -2
- package/dist/DocumentBindings.js.map +0 -1
- package/dist/MarkdownView.d.ts.map +0 -1
- package/dist/MarkdownView.js +0 -275
- package/dist/MarkdownView.js.map +0 -1
- package/dist/RowDocumentRenderable.d.ts.map +0 -1
- package/dist/RowDocumentRenderable.js.map +0 -1
- package/dist/Table.d.ts.map +0 -1
- package/dist/Table.js.map +0 -1
- package/dist/useGutterPalette.d.ts +0 -3
- package/dist/useGutterPalette.d.ts.map +0 -1
- package/dist/useGutterPalette.js.map +0 -1
- package/src/CommandPalette.tsx +0 -147
- package/src/ContextMenu.tsx +0 -132
- package/src/DecorationLayer.ts +0 -11
- package/src/DocumentBindings.ts +0 -16
- package/src/MarkdownView.tsx +0 -541
- package/src/RowDocumentRenderable.ts +0 -593
- package/src/Table.tsx +0 -300
- package/src/useGutterPalette.ts +0 -15
package/dist/mermaid.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { renderMermaidASCII } from "beautiful-mermaid";
|
|
2
2
|
import { parseColor, StyledText } from "@opentui/core";
|
|
3
|
-
|
|
3
|
+
// oxlint-disable-next-line no-control-regex -- ANSI SGR sequences start with the ESC control character
|
|
4
|
+
const SGR_SEQUENCE = /\u001B\[(?<params>[0-9;]*)m/gu;
|
|
4
5
|
/**
|
|
5
6
|
* Marked may include extra info-string content after the language. Treat only
|
|
6
7
|
* the first word as the fence language, matching common Markdown behavior.
|
|
7
8
|
*/
|
|
8
|
-
export function isMermaidFence(lang) {
|
|
9
|
-
return (lang ?? "").trim().split(/\s+/)[0]?.toLowerCase() === "mermaid";
|
|
10
|
-
}
|
|
11
|
-
function appendStyledChunk(chunks, text, fg) {
|
|
12
|
-
if (text.length === 0)
|
|
9
|
+
export const isMermaidFence = function isMermaidFence(lang) {
|
|
10
|
+
return (lang ?? "").trim().split(/\s+/u)[0]?.toLowerCase() === "mermaid";
|
|
11
|
+
};
|
|
12
|
+
const appendStyledChunk = function appendStyledChunk(chunks, text, fg) {
|
|
13
|
+
if (text.length === 0) {
|
|
13
14
|
return;
|
|
15
|
+
}
|
|
14
16
|
chunks.push({
|
|
15
17
|
__isChunk: true,
|
|
16
18
|
text,
|
|
17
|
-
...(fg ? { fg: parseColor(fg) } : {}),
|
|
19
|
+
...(fg !== undefined && fg !== "" ? { fg: parseColor(fg) } : {}),
|
|
18
20
|
});
|
|
19
|
-
}
|
|
20
|
-
function sgrParams(rawParams) {
|
|
21
|
-
if (rawParams === "")
|
|
21
|
+
};
|
|
22
|
+
const sgrParams = function sgrParams(rawParams) {
|
|
23
|
+
if (rawParams === "") {
|
|
22
24
|
return [0];
|
|
25
|
+
}
|
|
23
26
|
return rawParams.split(";").map((param) => (param === "" ? 0 : Number(param)));
|
|
24
|
-
}
|
|
25
|
-
function updateAnsiForeground(params, currentFg) {
|
|
27
|
+
};
|
|
28
|
+
const updateAnsiForeground = function updateAnsiForeground(params, currentFg) {
|
|
26
29
|
let fg = currentFg;
|
|
27
|
-
for (let i = 0; i < params.length; i
|
|
30
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
28
31
|
const param = params[i];
|
|
29
32
|
if (param === 0 || param === 39) {
|
|
30
33
|
fg = undefined;
|
|
@@ -34,7 +37,12 @@ function updateAnsiForeground(params, currentFg) {
|
|
|
34
37
|
const r = params[i + 2];
|
|
35
38
|
const g = params[i + 3];
|
|
36
39
|
const b = params[i + 4];
|
|
37
|
-
if (r
|
|
40
|
+
if (r !== null &&
|
|
41
|
+
r !== undefined &&
|
|
42
|
+
g !== null &&
|
|
43
|
+
g !== undefined &&
|
|
44
|
+
b !== null &&
|
|
45
|
+
b !== undefined) {
|
|
38
46
|
fg = `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b
|
|
39
47
|
.toString(16)
|
|
40
48
|
.padStart(2, "0")}`;
|
|
@@ -43,9 +51,9 @@ function updateAnsiForeground(params, currentFg) {
|
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
return fg;
|
|
46
|
-
}
|
|
54
|
+
};
|
|
47
55
|
/** Convert beautiful-mermaid truecolor ANSI output into OpenTUI StyledText. */
|
|
48
|
-
export function ansiToStyledText(input) {
|
|
56
|
+
export const ansiToStyledText = function ansiToStyledText(input) {
|
|
49
57
|
const chunks = [];
|
|
50
58
|
let plainText = "";
|
|
51
59
|
let cursor = 0;
|
|
@@ -55,22 +63,22 @@ export function ansiToStyledText(input) {
|
|
|
55
63
|
const literal = input.slice(cursor, index);
|
|
56
64
|
appendStyledChunk(chunks, literal, currentFg);
|
|
57
65
|
plainText += literal;
|
|
58
|
-
currentFg = updateAnsiForeground(sgrParams(match
|
|
66
|
+
currentFg = updateAnsiForeground(sgrParams(match.groups?.params ?? ""), currentFg);
|
|
59
67
|
cursor = index + match[0].length;
|
|
60
68
|
}
|
|
61
69
|
const tail = input.slice(cursor);
|
|
62
70
|
appendStyledChunk(chunks, tail, currentFg);
|
|
63
71
|
plainText += tail;
|
|
64
|
-
return {
|
|
65
|
-
}
|
|
72
|
+
return { content: new StyledText(chunks), text: plainText };
|
|
73
|
+
};
|
|
66
74
|
/**
|
|
67
75
|
* Render Mermaid source for terminal display. This wrapper keeps third-party
|
|
68
76
|
* parser/layout failures out of React render paths so MarkdownView can fall
|
|
69
77
|
* back to the original source block.
|
|
70
78
|
*/
|
|
71
|
-
export function renderMermaidForTerminal(source, options = {}) {
|
|
79
|
+
export const renderMermaidForTerminal = function renderMermaidForTerminal(source, options = {}) {
|
|
72
80
|
if (source.trim().length === 0) {
|
|
73
|
-
return {
|
|
81
|
+
return { message: "Mermaid block is empty", ok: false, reason: "empty" };
|
|
74
82
|
}
|
|
75
83
|
try {
|
|
76
84
|
const mode = options.mode ?? "plain";
|
|
@@ -80,16 +88,16 @@ export function renderMermaidForTerminal(source, options = {}) {
|
|
|
80
88
|
}).trimEnd();
|
|
81
89
|
const { text, content } = ansiToStyledText(rendered);
|
|
82
90
|
if (text.trim().length === 0) {
|
|
83
|
-
return {
|
|
91
|
+
return { message: "Mermaid renderer returned no output", ok: false, reason: "empty" };
|
|
84
92
|
}
|
|
85
|
-
return { ok: true, text
|
|
93
|
+
return { content, ok: true, text };
|
|
86
94
|
}
|
|
87
95
|
catch (error) {
|
|
88
96
|
return {
|
|
97
|
+
message: error instanceof Error ? error.message : String(error),
|
|
89
98
|
ok: false,
|
|
90
99
|
reason: "render-error",
|
|
91
|
-
message: error instanceof Error ? error.message : String(error),
|
|
92
100
|
};
|
|
93
101
|
}
|
|
94
|
-
}
|
|
102
|
+
};
|
|
95
103
|
//# sourceMappingURL=mermaid.js.map
|
package/dist/mermaid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../src/mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../src/mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAyBvD,uGAAuG;AACvG,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,cAAc,CAAC,IAAa;IACjE,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC;AAC3E,CAAC,CAA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AAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,OAAO,EAAE,qCAAqC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QACxF,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC/D,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,cAAc;SACvB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
package/dist/parsers.d.ts
CHANGED
|
@@ -4,19 +4,19 @@ export interface ParsedTable {
|
|
|
4
4
|
rows: TableRow[];
|
|
5
5
|
format: Format;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const parseCSV: (input: string) => {
|
|
8
8
|
columns: ColumnDef[];
|
|
9
9
|
rows: TableRow[];
|
|
10
10
|
};
|
|
11
|
-
export declare
|
|
11
|
+
export declare const parseTSV: (input: string) => {
|
|
12
12
|
columns: ColumnDef[];
|
|
13
13
|
rows: TableRow[];
|
|
14
14
|
};
|
|
15
|
-
export declare
|
|
15
|
+
export declare const parseJSON: (input: string) => {
|
|
16
16
|
columns: ColumnDef[];
|
|
17
17
|
rows: TableRow[];
|
|
18
18
|
};
|
|
19
19
|
export type Format = "csv" | "tsv" | "json" | "unknown";
|
|
20
|
-
export declare
|
|
21
|
-
export declare
|
|
20
|
+
export declare const detectFormat: (input: string) => Format;
|
|
21
|
+
export declare const parseAuto: (input: string) => ParsedTable;
|
|
22
22
|
//# sourceMappingURL=parsers.d.ts.map
|
package/dist/parsers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ,GAAqB,OAAO,MAAM,KAAG;IACxD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAYlB,CAAC;AA2CF,eAAO,MAAM,QAAQ,GAAqB,OAAO,MAAM,KAAG;IACxD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAelB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAsB,OAAO,MAAM,KAAG;IAC1D,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAgBlB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAExD,eAAO,MAAM,YAAY,GAAyB,OAAO,MAAM,KAAG,MAoBjE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAsB,OAAO,MAAM,KAAG,WA4B3D,CAAC"}
|
package/dist/parsers.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
export function parseCSV(input) {
|
|
1
|
+
export const parseCSV = function parseCSV(input) {
|
|
2
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
2
3
|
const lines = splitLines(input);
|
|
3
|
-
if (lines.length === 0)
|
|
4
|
+
if (lines.length === 0) {
|
|
4
5
|
return { columns: [], rows: [] };
|
|
6
|
+
}
|
|
7
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
5
8
|
const columns = createColumnDefs(parseCSVLine(lines[0]));
|
|
9
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
6
10
|
const rows = buildRows(columns, lines.slice(1).map(parseCSVLine));
|
|
7
11
|
return { columns, rows };
|
|
8
|
-
}
|
|
9
|
-
function parseCSVLine(line) {
|
|
12
|
+
};
|
|
13
|
+
const parseCSVLine = function parseCSVLine(line) {
|
|
10
14
|
const fields = [];
|
|
11
15
|
let i = 0;
|
|
12
16
|
while (i < line.length) {
|
|
13
17
|
if (line[i] === '"') {
|
|
14
18
|
// Quoted field
|
|
15
|
-
i
|
|
19
|
+
i += 1;
|
|
16
20
|
let field = "";
|
|
17
21
|
while (i < line.length) {
|
|
18
22
|
if (line[i] === '"') {
|
|
@@ -21,18 +25,20 @@ function parseCSVLine(line) {
|
|
|
21
25
|
i += 2;
|
|
22
26
|
}
|
|
23
27
|
else {
|
|
24
|
-
i
|
|
28
|
+
i += 1;
|
|
25
29
|
break;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
33
|
field += line[i];
|
|
30
|
-
i
|
|
34
|
+
i += 1;
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
fields.push(field);
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
// Skip the comma after a quoted field.
|
|
39
|
+
if (i < line.length && line[i] === ",") {
|
|
40
|
+
i += 1;
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
else {
|
|
38
44
|
const nextComma = line.indexOf(",", i);
|
|
@@ -47,21 +53,26 @@ function parseCSVLine(line) {
|
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
return fields;
|
|
50
|
-
}
|
|
51
|
-
export function parseTSV(input) {
|
|
56
|
+
};
|
|
57
|
+
export const parseTSV = function parseTSV(input) {
|
|
58
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
52
59
|
const lines = splitLines(input);
|
|
53
|
-
if (lines.length === 0)
|
|
60
|
+
if (lines.length === 0) {
|
|
54
61
|
return { columns: [], rows: [] };
|
|
62
|
+
}
|
|
63
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
55
64
|
const columns = createColumnDefs(lines[0].split("\t"));
|
|
65
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): parser helpers are kept below the public entry points
|
|
56
66
|
const rows = buildRows(columns, lines.slice(1).map((line) => line.split("\t")));
|
|
57
67
|
return { columns, rows };
|
|
58
|
-
}
|
|
59
|
-
export function parseJSON(input) {
|
|
68
|
+
};
|
|
69
|
+
export const parseJSON = function parseJSON(input) {
|
|
60
70
|
const data = JSON.parse(input);
|
|
61
|
-
if (!Array.isArray(data) || data.length === 0)
|
|
71
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
62
72
|
return { columns: [], rows: [] };
|
|
63
|
-
|
|
64
|
-
const
|
|
73
|
+
}
|
|
74
|
+
const keys = [...new Set(data.flatMap((item) => Object.keys(item)))];
|
|
75
|
+
const columns = keys.map((key) => ({ header: key, key }));
|
|
65
76
|
const rows = data.map((item) => {
|
|
66
77
|
const row = {};
|
|
67
78
|
for (const column of columns) {
|
|
@@ -70,53 +81,62 @@ export function parseJSON(input) {
|
|
|
70
81
|
return row;
|
|
71
82
|
});
|
|
72
83
|
return { columns, rows };
|
|
73
|
-
}
|
|
74
|
-
export function detectFormat(input) {
|
|
84
|
+
};
|
|
85
|
+
export const detectFormat = function detectFormat(input) {
|
|
75
86
|
const trimmed = input.trimStart();
|
|
76
87
|
if (trimmed.startsWith("[")) {
|
|
77
88
|
try {
|
|
78
89
|
const parsed = JSON.parse(trimmed);
|
|
79
|
-
if (Array.isArray(parsed))
|
|
90
|
+
if (Array.isArray(parsed)) {
|
|
80
91
|
return "json";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Not valid JSON — fall through to the delimiter sniffing below.
|
|
81
96
|
}
|
|
82
|
-
catch { }
|
|
83
97
|
}
|
|
84
98
|
const firstLine = input.split("\n")[0] ?? "";
|
|
85
|
-
if (firstLine.includes("\t"))
|
|
99
|
+
if (firstLine.includes("\t")) {
|
|
86
100
|
return "tsv";
|
|
87
|
-
|
|
101
|
+
}
|
|
102
|
+
if (firstLine.includes(",")) {
|
|
88
103
|
return "csv";
|
|
104
|
+
}
|
|
89
105
|
return "unknown";
|
|
90
|
-
}
|
|
91
|
-
export function parseAuto(input) {
|
|
106
|
+
};
|
|
107
|
+
export const parseAuto = function parseAuto(input) {
|
|
92
108
|
const format = detectFormat(input);
|
|
93
109
|
let columns;
|
|
94
110
|
let rows;
|
|
95
111
|
switch (format) {
|
|
96
|
-
case "csv":
|
|
97
|
-
;
|
|
112
|
+
case "csv": {
|
|
98
113
|
({ columns, rows } = parseCSV(input));
|
|
99
114
|
break;
|
|
100
|
-
|
|
101
|
-
|
|
115
|
+
}
|
|
116
|
+
case "tsv": {
|
|
102
117
|
({ columns, rows } = parseTSV(input));
|
|
103
118
|
break;
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
}
|
|
120
|
+
case "json": {
|
|
106
121
|
({ columns, rows } = parseJSON(input));
|
|
107
122
|
break;
|
|
108
|
-
|
|
123
|
+
}
|
|
124
|
+
case "unknown": {
|
|
109
125
|
// Fall back to CSV
|
|
110
|
-
;
|
|
111
126
|
({ columns, rows } = parseCSV(input));
|
|
112
127
|
break;
|
|
128
|
+
}
|
|
129
|
+
default: {
|
|
130
|
+
({ columns, rows } = parseCSV(input));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
113
133
|
}
|
|
114
|
-
return { columns,
|
|
115
|
-
}
|
|
116
|
-
function splitLines(input) {
|
|
134
|
+
return { columns, format, rows };
|
|
135
|
+
};
|
|
136
|
+
const splitLines = function splitLines(input) {
|
|
117
137
|
return input.split("\n").filter((line) => line.trim().length > 0);
|
|
118
|
-
}
|
|
119
|
-
function createColumnDefs(rawHeaders) {
|
|
138
|
+
};
|
|
139
|
+
const createColumnDefs = function createColumnDefs(rawHeaders) {
|
|
120
140
|
const seen = new Map();
|
|
121
141
|
return rawHeaders.map((header, index) => {
|
|
122
142
|
const trimmed = header.trim();
|
|
@@ -126,18 +146,18 @@ function createColumnDefs(rawHeaders) {
|
|
|
126
146
|
seen.set(base, count + 1);
|
|
127
147
|
const key = count === 0 ? base : `${base}_${count + 1}`;
|
|
128
148
|
return {
|
|
129
|
-
key,
|
|
130
149
|
header: trimmed || undefined,
|
|
150
|
+
key,
|
|
131
151
|
};
|
|
132
152
|
});
|
|
133
|
-
}
|
|
134
|
-
function buildRows(columns, rawRows) {
|
|
153
|
+
};
|
|
154
|
+
const buildRows = function buildRows(columns, rawRows) {
|
|
135
155
|
return rawRows.map((row) => {
|
|
136
156
|
const record = {};
|
|
137
|
-
columns.
|
|
157
|
+
for (const [index, column] of columns.entries()) {
|
|
138
158
|
record[column.key] = row[index] ?? "";
|
|
139
|
-
}
|
|
159
|
+
}
|
|
140
160
|
return record;
|
|
141
161
|
});
|
|
142
|
-
}
|
|
162
|
+
};
|
|
143
163
|
//# sourceMappingURL=parsers.js.map
|
package/dist/parsers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAQA,MAAM,
|
|
1
|
+
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,QAAQ,CAAC,KAAa;IAIrD,+HAA+H;IAC/H,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,KAA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K,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACxD,OAAO;YACL,MAAM,EAAE,OAAO,IAAI,SAAS;YAC5B,GAAG;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,SAAS,SAAS,CAAC,OAAoB,EAAE,OAAmB;IAC5E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { OptimizedBuffer } from "@opentui/core";
|
|
3
|
-
import type { DecorationLayer } from "./
|
|
1
|
+
import { ScrollBoxRenderable } from "@opentui/core";
|
|
2
|
+
import type { RenderContext, ScrollBoxOptions, OptimizedBuffer } from "@opentui/core";
|
|
3
|
+
import type { DecorationLayer } from "./decoration-layer.js";
|
|
4
4
|
export declare const DEFAULT_SIGN_COLUMN_WIDTH = 3;
|
|
5
5
|
export interface RowDocumentPalette {
|
|
6
6
|
gutterFg?: string;
|
|
@@ -17,21 +17,21 @@ export interface RowDocumentOptions extends ScrollBoxOptions {
|
|
|
17
17
|
palette?: RowDocumentPalette;
|
|
18
18
|
decorations?: readonly DecorationLayer[];
|
|
19
19
|
}
|
|
20
|
-
export declare
|
|
20
|
+
export declare const computeRowDocumentGutterWidth: (opts: {
|
|
21
21
|
showLineNumbers: boolean;
|
|
22
22
|
rowCount: number;
|
|
23
23
|
lineNumberStart?: number;
|
|
24
24
|
signColumnWidth?: number;
|
|
25
25
|
gutterPaddingRight?: number;
|
|
26
|
-
})
|
|
26
|
+
}) => number;
|
|
27
27
|
export declare class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
28
|
-
private _mode;
|
|
28
|
+
private readonly _mode;
|
|
29
29
|
private _showGutter;
|
|
30
30
|
private _showLineNumbers;
|
|
31
|
-
private _lineNumberStart;
|
|
32
|
-
private _signColumnWidth;
|
|
33
|
-
private _gutterPaddingRight;
|
|
34
|
-
private _rowChildOffset;
|
|
31
|
+
private readonly _lineNumberStart;
|
|
32
|
+
private readonly _signColumnWidth;
|
|
33
|
+
private readonly _gutterPaddingRight;
|
|
34
|
+
private readonly _rowChildOffset;
|
|
35
35
|
private _palette;
|
|
36
36
|
private _layers;
|
|
37
37
|
private _layerGutterBgs;
|
|
@@ -45,9 +45,13 @@ export declare class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
45
45
|
private _contentVirtualEnd;
|
|
46
46
|
private _lastGeometryHash;
|
|
47
47
|
constructor(ctx: RenderContext, options: RowDocumentOptions);
|
|
48
|
+
get decorations(): readonly DecorationLayer[];
|
|
48
49
|
set decorations(layers: readonly DecorationLayer[] | undefined);
|
|
50
|
+
get palette(): Required<RowDocumentPalette>;
|
|
49
51
|
set palette(palette: RowDocumentPalette | undefined);
|
|
52
|
+
get showGutter(): boolean;
|
|
50
53
|
set showGutter(value: boolean);
|
|
54
|
+
get showLineNumbers(): boolean;
|
|
51
55
|
set showLineNumbers(value: boolean);
|
|
52
56
|
get rowCount(): number;
|
|
53
57
|
get virtualRowCount(): number;
|
|
@@ -88,4 +92,4 @@ export declare class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
88
92
|
private _paintDecorations;
|
|
89
93
|
private _paintGutter;
|
|
90
94
|
}
|
|
91
|
-
//# sourceMappingURL=
|
|
95
|
+
//# sourceMappingURL=row-document-renderable.d.ts.map
|
|
@@ -0,0 +1 @@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