55import { IImageAddonOptions , IOscHandler , IResetHandler , ITerminalExt } from './Types' ;
66import { ImageRenderer } from './ImageRenderer' ;
77import { ImageStorage , CELL_SIZE_DEFAULT } from './ImageStorage' ;
8- import Base64Decoder , { type DecodeStatus } from 'xterm-wasm-parts/lib/base64/Base64Decoder.wasm' ;
8+ import Base64Decoder from 'xterm-wasm-parts/lib/base64/Base64Decoder.wasm' ;
99import { HeaderParser , IHeaderFields , HeaderState } from './IIPHeaderParser' ;
1010import { imageType , UNSUPPORTED_TYPE } from './IIPMetrics' ;
1111
12- // limit hold memory in base64 decoder (encoded bytes)
13- const KEEP_DATA = 4194304 ;
14- const INITIAL_DATA = 1048576 ;
15-
16- // Local mirror of const enum (esbuild can't inline const enums from external packages)
17- const DECODER_OK : DecodeStatus . OK = 0 ;
12+ // Local const enum mirror - esbuild can't inline const enums from external packages
13+ const enum DecoderConst {
14+ // Limit held memory in base64 decoder (encoded bytes).
15+ KEEP_DATA = 4194304 ,
16+ // Initial buffer allocation for the decoder.
17+ INITIAL_DATA = 1048576 ,
18+ // Local mirror of const enum (esbuild can't inline const enums from external packages)
19+ OK = 0
20+ }
1821
1922// default IIP header values
2023const DEFAULT_HEADER : IHeaderFields = {
@@ -41,8 +44,8 @@ export class IIPHandler implements IOscHandler, IResetHandler {
4144 private readonly _coreTerminal : ITerminalExt
4245 ) {
4346 const maxEncodedBytes = Math . ceil ( this . _opts . iipSizeLimit * 4 / 3 ) ;
44- const initialBytes = Math . min ( INITIAL_DATA , maxEncodedBytes ) ;
45- this . _dec = new Base64Decoder ( KEEP_DATA , maxEncodedBytes , initialBytes ) ;
47+ const initialBytes = Math . min ( DecoderConst . INITIAL_DATA , maxEncodedBytes ) ;
48+ this . _dec = new Base64Decoder ( DecoderConst . KEEP_DATA , maxEncodedBytes , initialBytes ) ;
4649 }
4750
4851 public reset ( ) : void { }
@@ -58,7 +61,7 @@ export class IIPHandler implements IOscHandler, IResetHandler {
5861 if ( this . _aborted ) return ;
5962
6063 if ( this . _hp . state === HeaderState . END ) {
61- if ( this . _dec . put ( data . subarray ( start , end ) ) !== DECODER_OK ) {
64+ if ( ( this . _dec . put ( data . subarray ( start , end ) ) as number ) !== DecoderConst . OK ) {
6265 this . _dec . release ( ) ;
6366 this . _aborted = true ;
6467 }
@@ -75,7 +78,7 @@ export class IIPHandler implements IOscHandler, IResetHandler {
7578 return ;
7679 }
7780 this . _dec . init ( ) ;
78- if ( this . _dec . put ( data . subarray ( dataPos , end ) ) !== DECODER_OK ) {
81+ if ( ( this . _dec . put ( data . subarray ( dataPos , end ) ) as number ) !== DecoderConst . OK ) {
7982 this . _dec . release ( ) ;
8083 this . _aborted = true ;
8184 }
0 commit comments