@xterm/addon-image 0.10.0-beta.167 → 0.10.0-beta.168
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/lib/addon-image.js +1 -1
- package/lib/addon-image.js.map +1 -1
- package/lib/addon-image.mjs +1 -1
- package/lib/addon-image.mjs.map +4 -4
- package/package.json +3 -3
- package/src/ImageAddon.ts +5 -0
- package/src/ImageStorage.ts +2 -0
- package/typings/addon-image.d.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/addon-image",
|
|
3
|
-
"version": "0.10.0-beta.
|
|
3
|
+
"version": "0.10.0-beta.168",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "The xterm.js authors",
|
|
6
6
|
"url": "https://xtermjs.org/"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"sixel": "^0.16.0",
|
|
28
28
|
"xterm-wasm-parts": "^0.3.0"
|
|
29
29
|
},
|
|
30
|
-
"commit": "
|
|
30
|
+
"commit": "a12061c899066bb49a535ac7afa46909e503e113",
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@xterm/xterm": "^6.1.0-beta.
|
|
32
|
+
"@xterm/xterm": "^6.1.0-beta.168"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/ImageAddon.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ITerminalAddon, IDisposable } from '@xterm/xterm';
|
|
7
7
|
import type { ImageAddon as IImageApi } from '@xterm/addon-image';
|
|
8
|
+
import { Emitter, type IEvent } from 'common/Event';
|
|
8
9
|
import { IIPHandler } from './IIPHandler';
|
|
9
10
|
import { ImageRenderer } from './ImageRenderer';
|
|
10
11
|
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
|
|
@@ -62,6 +63,8 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
|
|
|
62
63
|
private _disposables: IDisposable[] = [];
|
|
63
64
|
private _terminal: ITerminalExt | undefined;
|
|
64
65
|
private _handlers: Map<String, IResetHandler> = new Map();
|
|
66
|
+
private readonly _onImageAdded = new Emitter<void>();
|
|
67
|
+
public readonly onImageAdded: IEvent<void> = this._onImageAdded.event;
|
|
65
68
|
|
|
66
69
|
constructor(opts?: Partial<IImageAddonOptions>) {
|
|
67
70
|
this._opts = Object.assign({}, DEFAULT_OPTIONS, opts);
|
|
@@ -74,6 +77,7 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
|
|
|
74
77
|
}
|
|
75
78
|
this._disposables.length = 0;
|
|
76
79
|
this._handlers.clear();
|
|
80
|
+
this._onImageAdded.dispose();
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
private _disposeLater(...args: IDisposable[]): void {
|
|
@@ -88,6 +92,7 @@ export class ImageAddon implements ITerminalAddon, IImageApi {
|
|
|
88
92
|
// internal data structures
|
|
89
93
|
this._renderer = new ImageRenderer(terminal);
|
|
90
94
|
this._storage = new ImageStorage(terminal, this._renderer, this._opts);
|
|
95
|
+
this._storage.onImageAdded = () => this._onImageAdded.fire();
|
|
91
96
|
|
|
92
97
|
// enable size reports
|
|
93
98
|
if (this._opts.enableSizeReports) {
|
package/src/ImageStorage.ts
CHANGED
|
@@ -124,6 +124,7 @@ export class ImageStorage implements IDisposable {
|
|
|
124
124
|
private _pixelLimit: number = 2500000;
|
|
125
125
|
|
|
126
126
|
private _viewportMetrics: { cols: number, rows: number };
|
|
127
|
+
public onImageAdded: (() => void) | undefined;
|
|
127
128
|
public onImageDeleted: ((storageId: number) => void) | undefined;
|
|
128
129
|
|
|
129
130
|
constructor(
|
|
@@ -336,6 +337,7 @@ export class ImageStorage implements IDisposable {
|
|
|
336
337
|
|
|
337
338
|
// finally add the image
|
|
338
339
|
this._images.set(imageId, imgSpec);
|
|
340
|
+
this.onImageAdded?.();
|
|
339
341
|
return imageId;
|
|
340
342
|
}
|
|
341
343
|
|
package/typings/addon-image.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Terminal, ITerminalAddon } from '@xterm/xterm';
|
|
6
|
+
import { Terminal, ITerminalAddon, IEvent } from '@xterm/xterm';
|
|
7
7
|
|
|
8
8
|
declare module '@xterm/addon-image' {
|
|
9
9
|
export interface IImageAddonOptions {
|
|
@@ -116,6 +116,11 @@ declare module '@xterm/addon-image' {
|
|
|
116
116
|
*/
|
|
117
117
|
public showPlaceholder: boolean;
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Event fired whenever a new image is added to storage.
|
|
121
|
+
*/
|
|
122
|
+
public readonly onImageAdded: IEvent<void>;
|
|
123
|
+
|
|
119
124
|
/**
|
|
120
125
|
* Get original image canvas at buffer position.
|
|
121
126
|
*/
|