early animation PoC

This commit is contained in:
Jörg Breitbart
2026-08-28 16:42:43 +02:00
parent d3e32b344d
commit f1ae0ab30b
8 changed files with 781 additions and 60 deletions
+10 -1
View File
@@ -15,6 +15,7 @@ import { SixelHandler } from './SixelHandler';
import { SixelImageStorage } from './SixelImageStorage';
import { IIPImageStorage } from './IIPImageStorage';
import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types';
import { AnimationManager } from 'AnimationManager';
/**
@@ -69,6 +70,7 @@ const DEFAULT_OPTIONS: IImageAddonOptions = {
showPlaceholder: true,
iipSupport: true,
iipSizeLimit: 33554432,
iipAnimation: true, // alpha
kittySupport: true,
kittySizeLimit: 33554432
};
@@ -104,6 +106,7 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
private _disposables: IDisposable[] = [];
private _terminal: ITerminalExt | undefined;
private _handlers: Map<String, IResetHandler> = new Map();
private _aniManager: AnimationManager | undefined;
private readonly _onImageAdded = new Emitter<void>();
public readonly onImageAdded: IEvent<void> = this._onImageAdded.event;
@@ -144,6 +147,11 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
terminal.options.windowOptions = windowOps;
}
if (this._opts.iipAnimation && typeof ImageDecoder === 'function') {
this._aniManager = new AnimationManager(this._storage, this._renderer, terminal);
this._disposeLater(terminal.onRender(range => this._aniManager!.viewportUpdated(range)));
}
this._disposeLater(
this._renderer,
this._storage,
@@ -187,7 +195,7 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
// iTerm IIP handler
if (this._opts.iipSupport) {
const iipStorage = new IIPImageStorage(this._storage!);
const iipHandler = new IIPHandler(this._opts, this._renderer!, iipStorage, terminal);
const iipHandler = new IIPHandler(this._opts, this._renderer!, iipStorage, terminal, this._aniManager);
this._handlers.set('iip', iipHandler);
this._disposeLater(
terminal._core._inputHandler._parser.registerOscHandler(1337, iipHandler)
@@ -218,6 +226,7 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
for (const handler of this._handlers.values()) {
handler.reset();
}
this._aniManager?.reset();
return false;
}