Use sharding, decode with streaming

This commit is contained in:
Anthony Kim
2026-02-01 12:37:09 -08:00
parent bae314f67c
commit e4710d3286
3 changed files with 440 additions and 274 deletions
File diff suppressed because it is too large Load Diff
@@ -93,13 +93,19 @@ export interface IKittyCommand {
/**
* Pending chunked transmission state.
* Stores metadata from the first chunk while accumulating payload data.
* Stores metadata from the first chunk while accumulating decoded payload data.
*/
export interface IPendingTransmission {
/** The parsed command from the first chunk (contains action, format, dimensions, etc.) */
cmd: IKittyCommand;
/** Accumulated base64 payload data */
data: string;
/** Accumulated decoded payload chunks */
chunks: Uint8Array[];
/** Total size of accumulated chunks */
totalSize: number;
/** Leftover base64 bytes (0-3) that weren't aligned in previous chunk */
leftover: Uint32Array;
/** Number of valid bytes in leftover */
leftoverLength: number;
}
/**
@@ -107,7 +113,8 @@ export interface IPendingTransmission {
*/
export interface IKittyImageData {
id: number;
data: string;
/** Decoded image bytes (already decoded from base64) */
data: Uint8Array;
width: number;
height: number;
format: 24 | 32 | 100;
+3 -2
View File
@@ -77,6 +77,7 @@ const TESTDATA_IIP: [string, [number, number]][] = [
// Kitty graphics test images
const KITTY_BLACK_1X1_BASE64 = readFileSync('./addons/addon-image/fixture/kitty/black-1x1.png').toString('base64');
const KITTY_BLACK_1X1_BYTES = Array.from(readFileSync('./addons/addon-image/fixture/kitty/black-1x1.png'));
const KITTY_RGB_3X1_BASE64 = readFileSync('./addons/addon-image/fixture/kitty/rgb-3x1.png').toString('base64');
let ctx: ITestContext;
@@ -386,8 +387,8 @@ test.describe('ImageAddon', () => {
await ctx.proxy.write(`\x1b_Ga=t,f=100,i=99;${part2}\x1b\\`);
await timeout(100);
const storedData = await ctx.page.evaluate(`window.imageAddon._handlers.get('kitty').images.get(99).data`);
strictEqual(storedData, KITTY_BLACK_1X1_BASE64);
const storedData = await ctx.page.evaluate(`Array.from(window.imageAddon._handlers.get('kitty').images.get(99).data)`);
deepStrictEqual(storedData, KITTY_BLACK_1X1_BYTES);
});
test('delete command (a=d) removes specific image by id', async () => {