import { TNSTextDecoderBase } from './canvas-plugin.common' ; declare var com ; export class TNSTextDecoder extends TNSTextDecoderBase { constructor ( encoding = 'utf-8' ) { super ( new com . github . triniwiz . canvas . TextDecoder ( encoding ) ) ; } get encoding ( ) : string { return this . native . getEncoding ( ) ; } decode ( buffer ? , options ? ) { if ( buffer instanceof ArrayBuffer || buffer instanceof Uint8Array || buffer instanceof Int8Array || buffer instanceof Uint16Array || buffer instanceof Int16Array || buffer instanceof Uint32Array || buffer instanceof Int32Array || buffer instanceof Float32Array ) { if ( buffer instanceof Uint8Array || buffer instanceof Int8Array ) { const nativeBuffer = java . nio . ByteBuffer . wrap ( Array . from ( buffer ) ) ; return this . native . decode ( nativeBuffer . array ( ) ) ; } else if ( buffer instanceof Uint16Array || buffer instanceof Int16Array ) { const nativeBuffer = java . nio . ShortBuffer . wrap ( Array . from ( buffer ) ) ; return this . native . decode ( nativeBuffer . array ( ) ) ; } else if ( buffer instanceof Int32Array ) { const nativeBuffer = java . nio . IntBuffer . wrap ( Array . from ( buffer ) ) ; return this . native . decode ( nativeBuffer . array ( ) ) ; } const array = new Uint8Array ( buffer ) ; const nativeBuffer = java . nio . ByteBuffer . wrap ( Array . from ( array ) ) ; return this . native . decode ( nativeBuffer . array ( ) ) ; } else { return '' ; } } }