1+ const { readFile} = require ( 'fs' ) . promises ;
2+ const { join} = require ( 'path' ) ;
3+
4+ let wasm ;
5+
6+ let cachegetUint8Memory0 = null ;
7+
8+ function getUint8Memory0 ( ) {
9+ if ( cachegetUint8Memory0 === null || cachegetUint8Memory0 . buffer !== wasm . memory . buffer ) {
10+ cachegetUint8Memory0 = new Uint8Array ( wasm . memory . buffer ) ;
11+ }
12+ return cachegetUint8Memory0 ;
13+ }
14+
15+ let WASM_VECTOR_LEN = 0 ;
16+
17+ function passArray8ToWasm0 ( arg , malloc ) {
18+ const ptr = malloc ( arg . length * 1 ) ;
19+ getUint8Memory0 ( ) . set ( arg , ptr / 1 ) ;
20+ WASM_VECTOR_LEN = arg . length ;
21+ return ptr ;
22+ }
23+
24+ let cachegetInt32Memory0 = null ;
25+
26+ function getInt32Memory0 ( ) {
27+ if ( cachegetInt32Memory0 === null || cachegetInt32Memory0 . buffer !== wasm . memory . buffer ) {
28+ cachegetInt32Memory0 = new Int32Array ( wasm . memory . buffer ) ;
29+ }
30+ return cachegetInt32Memory0 ;
31+ }
32+
33+ let cachegetUint32Memory0 = null ;
34+
35+ function getUint32Memory0 ( ) {
36+ if ( cachegetUint32Memory0 === null || cachegetUint32Memory0 . buffer !== wasm . memory . buffer ) {
37+ cachegetUint32Memory0 = new Uint32Array ( wasm . memory . buffer ) ;
38+ }
39+ return cachegetUint32Memory0 ;
40+ }
41+
42+ function getArrayU32FromWasm0 ( ptr , len ) {
43+ return getUint32Memory0 ( ) . subarray ( ptr / 4 , ptr / 4 + len ) ;
44+ }
45+
46+ function getArrayU8FromWasm0 ( ptr , len ) {
47+ return getUint8Memory0 ( ) . subarray ( ptr / 1 , ptr / 1 + len ) ;
48+ }
49+
50+ module . exports = {
51+ /**
52+ * @param {number } ptr
53+ * @param {Uint8Array } buffer
54+ * @returns {number }
55+ */
56+ async decode ( ptr , buffer ) {
57+ if ( ! wasm ) {
58+ const module = new WebAssembly . Module ( await readFile ( join ( __dirname , './tiff.wasm' ) ) ) ;
59+ const instance = new WebAssembly . Instance ( module ) ;
60+ wasm = instance . exports ;
61+ }
62+
63+ const ptr0 = passArray8ToWasm0 ( buffer , wasm . __wbindgen_malloc ) ;
64+ return wasm . decode ( ptr , ptr0 , WASM_VECTOR_LEN ) ;
65+ } ,
66+ /**
67+ * @param {number } id
68+ * @returns {Uint32Array }
69+ */
70+ meta ( id ) {
71+ try {
72+ const retptr = wasm . __wbindgen_export_1 . value - 16 ;
73+ wasm . __wbindgen_export_1 . value = retptr ;
74+ wasm . meta ( retptr , id ) ;
75+ const r0 = getInt32Memory0 ( ) [ retptr / 4 ] ;
76+ const r1 = getInt32Memory0 ( ) [ retptr / 4 + 1 ] ;
77+ const v0 = getArrayU32FromWasm0 ( r0 , r1 ) . slice ( ) ;
78+ wasm . __wbindgen_free ( r0 , r1 * 4 ) ;
79+ return v0 ;
80+ } finally {
81+ wasm . __wbindgen_export_1 . value += 16 ;
82+ }
83+ } ,
84+ /**
85+ * @param {number } id
86+ * @returns {Uint8Array }
87+ */
88+ buffer ( id ) {
89+ try {
90+ const retptr = wasm . __wbindgen_export_1 . value - 16 ;
91+ wasm . __wbindgen_export_1 . value = retptr ;
92+ wasm . buffer ( retptr , id ) ;
93+ const r0 = getInt32Memory0 ( ) [ retptr / 4 ] ;
94+ const r1 = getInt32Memory0 ( ) [ retptr / 4 + 1 ] ;
95+ const v0 = getArrayU8FromWasm0 ( r0 , r1 ) . slice ( ) ;
96+ wasm . __wbindgen_free ( r0 , r1 * 1 ) ;
97+ return v0 ;
98+ } finally {
99+ wasm . __wbindgen_export_1 . value += 16 ;
100+ }
101+ } ,
102+ /**
103+ * @param {number } id
104+ */
105+ free ( id ) {
106+ wasm . free ( id ) ;
107+ }
108+ }
0 commit comments