@cueloop/client 0.1.0-alpha.48 → 0.1.0-alpha.49
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/package.json +5 -5
- package/src/kitty-image.test.ts +20 -0
- package/src/kitty-image.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cueloop/client",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.49",
|
|
4
4
|
"description": "The cueloop review UI: projection renderer, keyboard grammar, review rail",
|
|
5
5
|
"homepage": "https://github.com/mmurakaru/cueloop#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cueloop/daemon": "0.1.0-alpha.
|
|
30
|
-
"@cueloop/extension-api": "0.1.0-alpha.
|
|
31
|
-
"@cueloop/integration-obsidian": "0.1.0-alpha.
|
|
32
|
-
"@cueloop/schema": "0.1.0-alpha.
|
|
29
|
+
"@cueloop/daemon": "0.1.0-alpha.49",
|
|
30
|
+
"@cueloop/extension-api": "0.1.0-alpha.49",
|
|
31
|
+
"@cueloop/integration-obsidian": "0.1.0-alpha.49",
|
|
32
|
+
"@cueloop/schema": "0.1.0-alpha.49",
|
|
33
33
|
"@opentui/core": "^0.5.2",
|
|
34
34
|
"@opentui/keymap": "0.5.2",
|
|
35
35
|
"@opentui/react": "^0.5.2",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { placeKittyImage, transmitKittyImage } from "./kitty-image";
|
|
3
|
+
|
|
4
|
+
const REGION = { column: 2, row: 3, columns: 40, rows: 12 };
|
|
5
|
+
|
|
6
|
+
describe("kitty image stacking", () => {
|
|
7
|
+
test("places the prototype below cells with painted backgrounds", () => {
|
|
8
|
+
// Arrange
|
|
9
|
+
const writes: string[] = [];
|
|
10
|
+
|
|
11
|
+
// Act
|
|
12
|
+
transmitKittyImage((chunk) => writes.push(chunk), new Uint8Array([1]), REGION, 811);
|
|
13
|
+
placeKittyImage((chunk) => writes.push(chunk), REGION, 811);
|
|
14
|
+
|
|
15
|
+
// Assert
|
|
16
|
+
expect(writes).toHaveLength(2);
|
|
17
|
+
expect(writes[0]).toContain("z=-1073741825");
|
|
18
|
+
expect(writes[1]).toContain("z=-1073741825");
|
|
19
|
+
});
|
|
20
|
+
});
|
package/src/kitty-image.ts
CHANGED
|
@@ -19,6 +19,9 @@ export type OrderedWrite = (chunk: string) => void;
|
|
|
19
19
|
|
|
20
20
|
const ESCAPE_STRING_TERMINATOR = "\x1b\\";
|
|
21
21
|
const CHUNK_BYTES = 4096;
|
|
22
|
+
// The protocol reserves values below INT32_MIN/2 for images that must sit
|
|
23
|
+
// beneath cells with painted backgrounds, such as the marker popover.
|
|
24
|
+
const IMAGE_Z_INDEX = -1_073_741_825;
|
|
22
25
|
|
|
23
26
|
/** Save the cursor, run the placement at the region's corner, restore it. */
|
|
24
27
|
function atRegion(region: CellRegion, body: string): string {
|
|
@@ -43,9 +46,7 @@ export function transmitKittyImage(
|
|
|
43
46
|
): void {
|
|
44
47
|
if (region.columns < 1 || region.rows < 1) return;
|
|
45
48
|
const base64 = Buffer.from(png).toString("base64");
|
|
46
|
-
|
|
47
|
-
// compose card (ordinary cells) still paint over it
|
|
48
|
-
const controlKeys = `a=T,f=100,i=${imageId},q=2,C=1,z=-1,c=${region.columns},r=${region.rows}`;
|
|
49
|
+
const controlKeys = `a=T,f=100,i=${imageId},q=2,C=1,z=${IMAGE_Z_INDEX},c=${region.columns},r=${region.rows}`;
|
|
49
50
|
let sequence = "";
|
|
50
51
|
for (let offset = 0; offset < base64.length; offset += CHUNK_BYTES) {
|
|
51
52
|
const chunk = base64.slice(offset, offset + CHUNK_BYTES);
|
|
@@ -62,7 +63,7 @@ export function transmitKittyImage(
|
|
|
62
63
|
export function placeKittyImage(write: OrderedWrite, region: CellRegion, imageId: number): void {
|
|
63
64
|
if (region.columns < 1 || region.rows < 1) return;
|
|
64
65
|
const command = graphicsCommand(
|
|
65
|
-
`a=p,i=${imageId},q=2,C=1,z
|
|
66
|
+
`a=p,i=${imageId},q=2,C=1,z=${IMAGE_Z_INDEX},c=${region.columns},r=${region.rows}`,
|
|
66
67
|
"",
|
|
67
68
|
);
|
|
68
69
|
write(atRegion(region, command));
|