@@ -717,7 +717,7 @@ export async function init(options?: {
717717
718718 // --- Tape export/import helpers ---
719719 /** Parse a stream's buffer, export packed tape, free the temp doc slot. */
720- function streamExportTape ( streamId : number ) : ArrayBuffer | null {
720+ function streamExportTape ( streamId : number , formatCode = 0 ) : ArrayBuffer | null {
721721 const status = engine . stream_get_status ( streamId ) ;
722722 if ( status !== 1 /* complete */ && status !== 3 /* end_early */ ) return null ;
723723 const bufPtr = engine . stream_get_buffer_ptr ( streamId ) >>> 0 ;
@@ -730,7 +730,9 @@ export async function init(options?: {
730730 new Uint8Array ( engine . memory . buffer , bufPtr , bufLen ) ,
731731 ) ;
732732 new Uint8Array ( engine . memory . buffer , padPtr + bufLen , 64 ) . fill ( 0x20 ) ;
733- const docId = engine . doc_parse ( padPtr , bufLen ) ;
733+ const docId = formatCode === 2
734+ ? engine . doc_parse_fmt ( padPtr , bufLen , 2 )
735+ : engine . doc_parse ( padPtr , bufLen ) ;
734736 engine . dealloc ( padPtr , bufLen + 64 ) ;
735737 if ( docId < 0 ) return null ;
736738 // Export tape → JS ArrayBuffer, then free slot
@@ -1759,7 +1761,7 @@ export async function init(options?: {
17591761 } ,
17601762
17611763 getTapeBuffer ( ) : ArrayBuffer | null {
1762- return destroyed ? null : streamExportTape ( streamId ) ;
1764+ return destroyed ? null : streamExportTape ( streamId , FORMAT_CODE ) ;
17631765 } ,
17641766
17651767 destroy ( ) : void {
@@ -2340,7 +2342,7 @@ export async function init(options?: {
23402342 } ,
23412343
23422344 getTapeBuffer ( ) : ArrayBuffer | null {
2343- return destroyed ? null : streamExportTape ( streamId ) ;
2345+ return destroyed ? null : streamExportTape ( streamId , FORMAT_CODE ) ;
23442346 } ,
23452347
23462348 destroy ( ) : void {
0 commit comments