jsmdcui 0.6.3 → 0.7.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/CHANGELOG.md +60 -0
- package/README.md +105 -16
- package/clean.sh +9 -0
- package/demo.resized.jpg +0 -0
- package/{image-processor.md → demos/image-processor.md} +1 -0
- package/{image-processor.zh-TW.md → demos/image-processor.zh-TW.md} +1 -0
- package/{select.md → demos/select.md} +2 -0
- package/demos/todo-zh.md +92 -0
- package/demos/todo.md +93 -0
- package/package.json +1 -1
- package/runmd.mjs +33 -14
- package/runtime/help/help.md +105 -16
- package/single-exe/packAssets.sh +1 -1
- package/src/cui/kitty-debug.mjs +25 -0
- package/src/cui/kitty-images.mjs +190 -0
- package/src/cui/rpc.mjs +163 -7
- package/src/cui/server.mjs +1 -1
- package/src/cui/task-checkbox.mjs +44 -0
- package/src/index.js +236 -39
- package/src/plugins/js-bridge.js +244 -17
- package/src/screen/screen.js +108 -1
- package/tests/cat-markdown.test.js +6 -5
- package/tests/demo.test.js +99 -9
- package/tests/heading-list-selector.test.js +346 -0
- package/tests/id-collision.test.js +3 -2
- package/tests/kitty-demo.md +184 -0
- package/tests/kitty-images.test.js +147 -0
- package/tests/task-checkbox.test.js +33 -0
- package/tests/wui-responsive-images.test.js +35 -0
- package/tui +4 -2
- package/wui +6 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
toggleTaskCheckboxBeforeColumn,
|
|
4
|
+
updateAnsiTaskCheckbox,
|
|
5
|
+
} from "../src/cui/task-checkbox.mjs";
|
|
6
|
+
|
|
7
|
+
test("task checkbox toggle reports its position and new checked state", () => {
|
|
8
|
+
expect(toggleTaskCheckboxBeforeColumn(" ☐ todo", 4)).toEqual({
|
|
9
|
+
line: " ☒ todo",
|
|
10
|
+
toggled: true,
|
|
11
|
+
checkboxAt: 2,
|
|
12
|
+
checked: true,
|
|
13
|
+
});
|
|
14
|
+
expect(toggleTaskCheckboxBeforeColumn(" ☒ todo", 4)).toEqual({
|
|
15
|
+
line: " ☐ todo",
|
|
16
|
+
toggled: true,
|
|
17
|
+
checkboxAt: 2,
|
|
18
|
+
checked: false,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("task checkbox toggle updates Bun Markdown ANSI color with the glyph", () => {
|
|
23
|
+
const unchecked = " \x1b[2m☐ \x1b[0mtodo";
|
|
24
|
+
const checked = " \x1b[32m☒ \x1b[0mtodo";
|
|
25
|
+
expect(updateAnsiTaskCheckbox(unchecked, 2, true)).toBe(checked);
|
|
26
|
+
expect(updateAnsiTaskCheckbox(checked, 2, false)).toBe(unchecked);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("ANSI checkbox lookup ignores OSC 8 hyperlink metadata", () => {
|
|
30
|
+
const prefix = "\x1b]8;;https://example.test\x1b\\link\x1b]8;;\x1b\\ ";
|
|
31
|
+
expect(updateAnsiTaskCheckbox(`${prefix}\x1b[2m☐ \x1b[0mtodo`, 5, true))
|
|
32
|
+
.toBe(`${prefix}\x1b[32m☒ \x1b[0mtodo`);
|
|
33
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { afterEach, expect, test } from "bun:test";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createWui } from "../runmd.mjs";
|
|
6
|
+
|
|
7
|
+
const temporaryDirectories = [];
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
for (const directory of temporaryDirectories.splice(0)) {
|
|
11
|
+
rmSync(directory, { recursive: true, force: true });
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("createWui constrains images to their content width", async () => {
|
|
16
|
+
const directory = mkdtempSync(join(tmpdir(), "jsmdcui-wui-image-"));
|
|
17
|
+
temporaryDirectories.push(directory);
|
|
18
|
+
const markdownPath = join(directory, "image.md");
|
|
19
|
+
const html = await createWui("", markdownPath);
|
|
20
|
+
|
|
21
|
+
expect(html).toContain("img {\n max-width: 100%;\n height: auto;\n}");
|
|
22
|
+
expect(html.match(/max-width: 100%/g)).toHaveLength(1);
|
|
23
|
+
expect(html.match(/image\.md\.front\.js/g)).toHaveLength(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("createWui injects the image rule into an existing document head", async () => {
|
|
27
|
+
const directory = mkdtempSync(join(tmpdir(), "jsmdcui-wui-document-"));
|
|
28
|
+
temporaryDirectories.push(directory);
|
|
29
|
+
const markdownPath = join(directory, "document.md");
|
|
30
|
+
const source = "<!doctype html><html><head><title>x</title></head><body><img src=\"wide.png\"></body></html>";
|
|
31
|
+
const html = await createWui(source, markdownPath);
|
|
32
|
+
|
|
33
|
+
expect(html.indexOf("max-width: 100%")).toBeLessThan(html.indexOf("</head>"));
|
|
34
|
+
expect(html.match(/document\.md\.front\.js/g)).toHaveLength(1);
|
|
35
|
+
});
|
package/tui
CHANGED
package/wui
CHANGED