@termdraw/app 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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/cli.js +63437 -0
- package/dist/highlights-eq9cgrbb.scm +604 -0
- package/dist/highlights-ghv9g403.scm +205 -0
- package/dist/highlights-hk7bwhj4.scm +284 -0
- package/dist/highlights-r812a2qc.scm +150 -0
- package/dist/highlights-x6tmsnaa.scm +115 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/injections-73j83es3.scm +27 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +80 -0
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/package.json +77 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/99ddf573531c4dbe53f743ecbc1595af5eb1d32f/queries/markdown_inline/highlights.scm
|
|
2
|
+
; From MDeiml/tree-sitter-markdown
|
|
3
|
+
(code_span) @markup.raw @nospell
|
|
4
|
+
|
|
5
|
+
(emphasis) @markup.italic
|
|
6
|
+
|
|
7
|
+
(strong_emphasis) @markup.strong
|
|
8
|
+
|
|
9
|
+
(strikethrough) @markup.strikethrough
|
|
10
|
+
|
|
11
|
+
(shortcut_link
|
|
12
|
+
(link_text) @nospell)
|
|
13
|
+
|
|
14
|
+
[
|
|
15
|
+
(backslash_escape)
|
|
16
|
+
(hard_line_break)
|
|
17
|
+
] @string.escape
|
|
18
|
+
|
|
19
|
+
; Conceal codeblock and text style markers
|
|
20
|
+
([
|
|
21
|
+
(code_span_delimiter)
|
|
22
|
+
(emphasis_delimiter)
|
|
23
|
+
] @conceal
|
|
24
|
+
(#set! conceal ""))
|
|
25
|
+
|
|
26
|
+
; Inline links - style all parts
|
|
27
|
+
(inline_link
|
|
28
|
+
["[" "(" ")"] @markup.link)
|
|
29
|
+
|
|
30
|
+
(inline_link
|
|
31
|
+
"]" @markup.link.bracket.close)
|
|
32
|
+
|
|
33
|
+
; Conceal opening bracket
|
|
34
|
+
((inline_link
|
|
35
|
+
"[" @conceal)
|
|
36
|
+
(#set! conceal ""))
|
|
37
|
+
|
|
38
|
+
; Conceal closing bracket with space replacement
|
|
39
|
+
((inline_link
|
|
40
|
+
"]" @conceal)
|
|
41
|
+
(#set! conceal " "))
|
|
42
|
+
|
|
43
|
+
; Conceal image links
|
|
44
|
+
(image
|
|
45
|
+
[
|
|
46
|
+
"!"
|
|
47
|
+
"["
|
|
48
|
+
"]"
|
|
49
|
+
"("
|
|
50
|
+
(link_destination)
|
|
51
|
+
")"
|
|
52
|
+
] @markup.link
|
|
53
|
+
(#set! conceal ""))
|
|
54
|
+
|
|
55
|
+
; Conceal full reference links
|
|
56
|
+
(full_reference_link
|
|
57
|
+
[
|
|
58
|
+
"["
|
|
59
|
+
"]"
|
|
60
|
+
(link_label)
|
|
61
|
+
] @markup.link
|
|
62
|
+
(#set! conceal ""))
|
|
63
|
+
|
|
64
|
+
; Conceal collapsed reference links
|
|
65
|
+
(collapsed_reference_link
|
|
66
|
+
[
|
|
67
|
+
"["
|
|
68
|
+
"]"
|
|
69
|
+
] @markup.link
|
|
70
|
+
(#set! conceal ""))
|
|
71
|
+
|
|
72
|
+
; Conceal shortcut links
|
|
73
|
+
(shortcut_link
|
|
74
|
+
[
|
|
75
|
+
"["
|
|
76
|
+
"]"
|
|
77
|
+
] @markup.link
|
|
78
|
+
(#set! conceal ""))
|
|
79
|
+
|
|
80
|
+
[
|
|
81
|
+
(link_destination)
|
|
82
|
+
(uri_autolink)
|
|
83
|
+
] @markup.link.url @nospell
|
|
84
|
+
|
|
85
|
+
[
|
|
86
|
+
(link_label)
|
|
87
|
+
(link_text)
|
|
88
|
+
(link_title)
|
|
89
|
+
(image_description)
|
|
90
|
+
] @markup.link.label
|
|
91
|
+
|
|
92
|
+
; Replace common HTML entities.
|
|
93
|
+
((entity_reference) @character.special
|
|
94
|
+
(#eq? @character.special " ")
|
|
95
|
+
(#set! conceal ""))
|
|
96
|
+
|
|
97
|
+
((entity_reference) @character.special
|
|
98
|
+
(#eq? @character.special "<")
|
|
99
|
+
(#set! conceal "<"))
|
|
100
|
+
|
|
101
|
+
((entity_reference) @character.special
|
|
102
|
+
(#eq? @character.special ">")
|
|
103
|
+
(#set! conceal ">"))
|
|
104
|
+
|
|
105
|
+
((entity_reference) @character.special
|
|
106
|
+
(#eq? @character.special "&")
|
|
107
|
+
(#set! conceal "&"))
|
|
108
|
+
|
|
109
|
+
((entity_reference) @character.special
|
|
110
|
+
(#eq? @character.special """)
|
|
111
|
+
(#set! conceal "\""))
|
|
112
|
+
|
|
113
|
+
((entity_reference) @character.special
|
|
114
|
+
(#any-of? @character.special " " " ")
|
|
115
|
+
(#set! conceal " "))
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseArgs, runTermDrawAppCli } from "./main.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/markdown/injections.scm
|
|
2
|
+
(fenced_code_block
|
|
3
|
+
(info_string
|
|
4
|
+
(language) @_lang)
|
|
5
|
+
(code_fence_content) @injection.content
|
|
6
|
+
(#set-lang-from-info-string! @_lang))
|
|
7
|
+
|
|
8
|
+
((html_block) @injection.content
|
|
9
|
+
(#set! injection.language "html")
|
|
10
|
+
(#set! injection.combined)
|
|
11
|
+
(#set! injection.include-children))
|
|
12
|
+
|
|
13
|
+
((minus_metadata) @injection.content
|
|
14
|
+
(#set! injection.language "yaml")
|
|
15
|
+
(#offset! @injection.content 1 0 -1 0)
|
|
16
|
+
(#set! injection.include-children))
|
|
17
|
+
|
|
18
|
+
((plus_metadata) @injection.content
|
|
19
|
+
(#set! injection.language "toml")
|
|
20
|
+
(#offset! @injection.content 1 0 -1 0)
|
|
21
|
+
(#set! injection.include-children))
|
|
22
|
+
|
|
23
|
+
([
|
|
24
|
+
(inline)
|
|
25
|
+
(pipe_table_cell)
|
|
26
|
+
] @injection.content
|
|
27
|
+
(#set! injection.language "markdown_inline"))
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CliOptions {
|
|
2
|
+
outputPath?: string;
|
|
3
|
+
fenced: boolean;
|
|
4
|
+
help: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseArgs(argv: string[]): CliOptions;
|
|
7
|
+
export declare function runTermDrawAppCli(argv?: string[]): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAsCpD;AAMD,wBAAsB,iBAAiB,CAAC,IAAI,WAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD/E"}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createCliRenderer } from "@opentui/core";
|
|
3
|
+
import { createRoot } from "@opentui/react";
|
|
4
|
+
import { buildHelpText, formatSavedOutput, TermDrawApp } from "@termdraw/opentui";
|
|
5
|
+
export function parseArgs(argv) {
|
|
6
|
+
const options = {
|
|
7
|
+
fenced: false,
|
|
8
|
+
help: false,
|
|
9
|
+
};
|
|
10
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
11
|
+
const arg = argv[i];
|
|
12
|
+
if (arg === "-h" || arg === "--help") {
|
|
13
|
+
options.help = true;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (arg === "--fenced") {
|
|
17
|
+
options.fenced = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (arg === "--plain") {
|
|
21
|
+
options.fenced = false;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (arg === "-o" || arg === "--output") {
|
|
25
|
+
const outputPath = argv[i + 1];
|
|
26
|
+
if (!outputPath) {
|
|
27
|
+
throw new Error(`Missing value for ${arg}`);
|
|
28
|
+
}
|
|
29
|
+
options.outputPath = outputPath;
|
|
30
|
+
i += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
34
|
+
}
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
function withTrailingNewline(text) {
|
|
38
|
+
return text.endsWith("\n") ? text : `${text}\n`;
|
|
39
|
+
}
|
|
40
|
+
export async function runTermDrawAppCli(argv = Bun.argv.slice(2)) {
|
|
41
|
+
const options = parseArgs(argv);
|
|
42
|
+
if (options.help) {
|
|
43
|
+
process.stdout.write(buildHelpText("termdraw"));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const renderer = await createCliRenderer({
|
|
47
|
+
exitOnCtrlC: false,
|
|
48
|
+
useMouse: true,
|
|
49
|
+
enableMouseMovement: true,
|
|
50
|
+
autoFocus: true,
|
|
51
|
+
screenMode: "alternate-screen",
|
|
52
|
+
});
|
|
53
|
+
const root = createRoot(renderer);
|
|
54
|
+
let finished = false;
|
|
55
|
+
const finish = async (art) => {
|
|
56
|
+
if (finished)
|
|
57
|
+
return;
|
|
58
|
+
finished = true;
|
|
59
|
+
renderer.destroy();
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
61
|
+
if (art === null) {
|
|
62
|
+
process.stderr.write("Drawing cancelled.\n");
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
const output = withTrailingNewline(formatSavedOutput(art, options.fenced));
|
|
66
|
+
if (options.outputPath) {
|
|
67
|
+
await Bun.write(options.outputPath, output);
|
|
68
|
+
process.stderr.write(`Saved drawing to ${options.outputPath}\n`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
process.stdout.write(output);
|
|
72
|
+
}
|
|
73
|
+
process.exit(0);
|
|
74
|
+
};
|
|
75
|
+
root.render(_jsx(TermDrawApp, { width: "100%", height: "100%", autoFocus: true, cancelOnCtrlC: true, onSave: (art) => {
|
|
76
|
+
void finish(art);
|
|
77
|
+
}, onCancel: () => {
|
|
78
|
+
void finish(null);
|
|
79
|
+
} }));
|
|
80
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@termdraw/app",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Standalone termDRAW terminal drawing app.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ascii-art",
|
|
7
|
+
"diagram",
|
|
8
|
+
"drawing",
|
|
9
|
+
"terminal",
|
|
10
|
+
"tui"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/benvinegar/termdraw/tree/main/packages/app#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/benvinegar/termdraw/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Ben Vinegar",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/benvinegar/termdraw.git"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"termdraw": "./dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"start": "bun run src/cli.tsx",
|
|
46
|
+
"dev": "bun --watch run src/cli.tsx",
|
|
47
|
+
"clean": "rm -rf dist",
|
|
48
|
+
"build": "bun run clean && bun run build:lib && bun run build:cli",
|
|
49
|
+
"build:lib": "tsc -p tsconfig.build.json",
|
|
50
|
+
"build:cli": "bun build src/cli.tsx --outdir dist --target=bun && chmod +x dist/cli.js",
|
|
51
|
+
"check": "bun run format:check && bun run lint && bun run typecheck",
|
|
52
|
+
"pack:check": "bun run build && npm pack --dry-run --ignore-scripts",
|
|
53
|
+
"prepack": "bun run build",
|
|
54
|
+
"prepublishOnly": "bun run lint && bun run typecheck",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"format": "oxfmt .",
|
|
57
|
+
"format:check": "oxfmt --check .",
|
|
58
|
+
"lint": "oxlint .",
|
|
59
|
+
"lint:fix": "oxlint --fix ."
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@opentui/core": "^0.1.97",
|
|
63
|
+
"@opentui/react": "^0.1.97",
|
|
64
|
+
"@termdraw/opentui": "0.3.0",
|
|
65
|
+
"react": "^19.2.5"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/bun": "latest",
|
|
69
|
+
"@types/react": "^19.2.14",
|
|
70
|
+
"oxfmt": "^0.44.0",
|
|
71
|
+
"oxlint": "^1.59.0",
|
|
72
|
+
"typescript": "^5.9.3"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"bun": ">=1.3.0"
|
|
76
|
+
}
|
|
77
|
+
}
|