jsmdcui 0.7.0 → 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.
@@ -26,6 +26,28 @@ test("Bun-rendered Markdown image links reserve rows and retain Kitty data", asy
26
26
  expect(Bun.stripANSI(result.rendered)).toContain("📷 pixel");
27
27
  });
28
28
 
29
+ test("Kitty compat converts compressed images to standard PNG payloads", async () => {
30
+ const dir = await mkdtemp(join(tmpdir(), "jsmdcui-kitty-compat-"));
31
+ const markdownPath = join(dir, "app.md");
32
+ const jpeg = Buffer.from(await new Bun.Image(ONE_PIXEL_PNG).jpeg().toBuffer());
33
+ await writeFile(join(dir, "pixel.jpg"), jpeg);
34
+ const ansi = Bun.markdown.ansi("![pixel](pixel.jpg)", {
35
+ hyperlinks: true,
36
+ columns: 40,
37
+ });
38
+
39
+ const result = await prepareKittyImages(ansi, markdownPath, 40, {
40
+ kittyMode: "compat",
41
+ });
42
+
43
+ expect(result.images).toHaveLength(1);
44
+ expect(result.images[0].mime).toBe("image/png");
45
+ expect(result.images[0].data.subarray(0, 8).equals(Buffer.from([
46
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
47
+ ]))).toBe(true);
48
+ expect(result.images[0].data.equals(jpeg)).toBe(false);
49
+ });
50
+
29
51
  test("remote Kitty images require allowUrl and use the configured HTTP byte fetcher", async () => {
30
52
  const imageUrl = "https://example.test/assets/pixel.png";
31
53
  const ansi = Bun.markdown.ansi(`![pixel](${imageUrl})`, {
@@ -0,0 +1,8 @@
1
+ import { expect, test } from "bun:test";
2
+ import { controllingTerminalInputPath } from "../src/platform/terminal.js";
3
+
4
+ test("redirected stdin uses the platform controlling-terminal input device", () => {
5
+ expect(controllingTerminalInputPath("win32")).toBe("CONIN$");
6
+ expect(controllingTerminalInputPath("linux")).toBe("/dev/tty");
7
+ expect(controllingTerminalInputPath("darwin")).toBe("/dev/tty");
8
+ });
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env jsmdcui
2
+
3
+ ```textarea
4
+ hello
5
+ ```
6
+
7
+ - [show text](javascript:alert($('textarea').val()))
8
+ - [show hello](javascript:alert('hello'))
package/tests/wui.test.js CHANGED
@@ -2,7 +2,7 @@ import { expect, test } from "bun:test";
2
2
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
- import { readMarkdownInput } from "../runmd.mjs";
5
+ import { readMarkdownInput, writeRuntimeFiles } from "../runmd.mjs";
6
6
 
7
7
  test("WUI writes the bundled testapp.md when it is missing", async () => {
8
8
  const dir = await mkdtemp(join(tmpdir(), "jsmdcui-wui-"));
@@ -28,3 +28,18 @@ test("WUI preserves an existing testapp.md", async () => {
28
28
  await rm(dir, { recursive: true, force: true });
29
29
  }
30
30
  });
31
+
32
+ test("generated WUI server falls back to a system port when 3000 is occupied", async () => {
33
+ const dir = await mkdtemp(join(tmpdir(), "jsmdcui-wui-port-"));
34
+ const mdpath = join(dir, "app.md");
35
+ try {
36
+ await writeRuntimeFiles(mdpath);
37
+ const source = await readFile(`${mdpath}-server.js`, "utf8");
38
+ expect(source).toContain('error?.code === "EADDRINUSE"');
39
+ expect(source).toContain('serverOptions.port !== 3000 || !addressInUse');
40
+ expect(source).toContain('Bun.serve({ ...serverOptions, port: 0 })');
41
+ expect(source).toContain('localhost:${server.port}');
42
+ } finally {
43
+ await rm(dir, { recursive: true, force: true });
44
+ }
45
+ });