@@ -2,13 +2,13 @@ let wasm;
2
2
3
3
let WASM_VECTOR_LEN = 0 ;
4
4
5
- let cachedUint8Memory0 = null ;
5
+ let cachedUint8ArrayMemory0 = null ;
6
6
7
- function getUint8Memory0 ( ) {
8
- if ( cachedUint8Memory0 === null || cachedUint8Memory0 . byteLength === 0 ) {
9
- cachedUint8Memory0 = new Uint8Array ( wasm . memory . buffer ) ;
7
+ function getUint8ArrayMemory0 ( ) {
8
+ if ( cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0 . byteLength === 0 ) {
9
+ cachedUint8ArrayMemory0 = new Uint8Array ( wasm . memory . buffer ) ;
10
10
}
11
- return cachedUint8Memory0 ;
11
+ return cachedUint8ArrayMemory0 ;
12
12
}
13
13
14
14
const cachedTextEncoder = ( typeof TextEncoder !== 'undefined' ? new TextEncoder ( 'utf-8' ) : { encode : ( ) => { throw Error ( 'TextEncoder not available' ) } } ) ;
@@ -31,15 +31,15 @@ function passStringToWasm0(arg, malloc, realloc) {
31
31
if ( realloc === undefined ) {
32
32
const buf = cachedTextEncoder . encode ( arg ) ;
33
33
const ptr = malloc ( buf . length , 1 ) >>> 0 ;
34
- getUint8Memory0 ( ) . subarray ( ptr , ptr + buf . length ) . set ( buf ) ;
34
+ getUint8ArrayMemory0 ( ) . subarray ( ptr , ptr + buf . length ) . set ( buf ) ;
35
35
WASM_VECTOR_LEN = buf . length ;
36
36
return ptr ;
37
37
}
38
38
39
39
let len = arg . length ;
40
40
let ptr = malloc ( len , 1 ) >>> 0 ;
41
41
42
- const mem = getUint8Memory0 ( ) ;
42
+ const mem = getUint8ArrayMemory0 ( ) ;
43
43
44
44
let offset = 0 ;
45
45
@@ -54,23 +54,24 @@ function passStringToWasm0(arg, malloc, realloc) {
54
54
arg = arg . slice ( offset ) ;
55
55
}
56
56
ptr = realloc ( ptr , len , len = offset + arg . length * 3 , 1 ) >>> 0 ;
57
- const view = getUint8Memory0 ( ) . subarray ( ptr + offset , ptr + len ) ;
57
+ const view = getUint8ArrayMemory0 ( ) . subarray ( ptr + offset , ptr + len ) ;
58
58
const ret = encodeString ( arg , view ) ;
59
59
60
60
offset += ret . written ;
61
+ ptr = realloc ( ptr , len , offset , 1 ) >>> 0 ;
61
62
}
62
63
63
64
WASM_VECTOR_LEN = offset ;
64
65
return ptr ;
65
66
}
66
67
67
- let cachedInt32Memory0 = null ;
68
+ let cachedDataViewMemory0 = null ;
68
69
69
- function getInt32Memory0 ( ) {
70
- if ( cachedInt32Memory0 === null || cachedInt32Memory0 . byteLength === 0 ) {
71
- cachedInt32Memory0 = new Int32Array ( wasm . memory . buffer ) ;
70
+ function getDataViewMemory0 ( ) {
71
+ if ( cachedDataViewMemory0 === null || cachedDataViewMemory0 . buffer . detached === true || ( cachedDataViewMemory0 . buffer . detached === undefined && cachedDataViewMemory0 . buffer !== wasm . memory . buffer ) ) {
72
+ cachedDataViewMemory0 = new DataView ( wasm . memory . buffer ) ;
72
73
}
73
- return cachedInt32Memory0 ;
74
+ return cachedDataViewMemory0 ;
74
75
}
75
76
76
77
const cachedTextDecoder = ( typeof TextDecoder !== 'undefined' ? new TextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) : { decode : ( ) => { throw Error ( 'TextDecoder not available' ) } } ) ;
@@ -79,7 +80,7 @@ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
79
80
80
81
function getStringFromWasm0 ( ptr , len ) {
81
82
ptr = ptr >>> 0 ;
82
- return cachedTextDecoder . decode ( getUint8Memory0 ( ) . subarray ( ptr , ptr + len ) ) ;
83
+ return cachedTextDecoder . decode ( getUint8ArrayMemory0 ( ) . subarray ( ptr , ptr + len ) ) ;
83
84
}
84
85
/**
85
86
* @param {string } sql
@@ -93,8 +94,8 @@ export function parse_sql(sql) {
93
94
const ptr0 = passStringToWasm0 ( sql , wasm . __wbindgen_malloc , wasm . __wbindgen_realloc ) ;
94
95
const len0 = WASM_VECTOR_LEN ;
95
96
wasm . parse_sql ( retptr , ptr0 , len0 ) ;
96
- var r0 = getInt32Memory0 ( ) [ retptr / 4 + 0 ] ;
97
- var r1 = getInt32Memory0 ( ) [ retptr / 4 + 1 ] ;
97
+ var r0 = getDataViewMemory0 ( ) . getInt32 ( retptr + 4 * 0 , true ) ;
98
+ var r1 = getDataViewMemory0 ( ) . getInt32 ( retptr + 4 * 1 , true ) ;
98
99
deferred2_0 = r0 ;
99
100
deferred2_1 = r1 ;
100
101
return getStringFromWasm0 ( r0 , r1 ) ;
@@ -142,15 +143,16 @@ function __wbg_get_imports() {
142
143
return imports ;
143
144
}
144
145
145
- function __wbg_init_memory ( imports , maybe_memory ) {
146
+ function __wbg_init_memory ( imports , memory ) {
146
147
147
148
}
148
149
149
150
function __wbg_finalize_init ( instance , module ) {
150
151
wasm = instance . exports ;
151
152
__wbg_init . __wbindgen_wasm_module = module ;
152
- cachedInt32Memory0 = null ;
153
- cachedUint8Memory0 = null ;
153
+ cachedDataViewMemory0 = null ;
154
+ cachedUint8ArrayMemory0 = null ;
155
+
154
156
155
157
156
158
return wasm ;
@@ -159,6 +161,12 @@ function __wbg_finalize_init(instance, module) {
159
161
function initSync ( module ) {
160
162
if ( wasm !== undefined ) return wasm ;
161
163
164
+
165
+ if ( typeof module !== 'undefined' && Object . getPrototypeOf ( module ) === Object . prototype )
166
+ ( { module} = module )
167
+ else
168
+ console . warn ( 'using deprecated parameters for `initSync()`; pass a single object instead' )
169
+
162
170
const imports = __wbg_get_imports ( ) ;
163
171
164
172
__wbg_init_memory ( imports ) ;
@@ -172,24 +180,30 @@ function initSync(module) {
172
180
return __wbg_finalize_init ( instance , module ) ;
173
181
}
174
182
175
- async function __wbg_init ( input ) {
183
+ async function __wbg_init ( module_or_path ) {
176
184
if ( wasm !== undefined ) return wasm ;
177
185
178
- if ( typeof input === 'undefined' ) {
179
- input = new URL ( 'postgresql_cst_parser_wasm_bg.wasm' , import . meta. url ) ;
186
+
187
+ if ( typeof module_or_path !== 'undefined' && Object . getPrototypeOf ( module_or_path ) === Object . prototype )
188
+ ( { module_or_path} = module_or_path )
189
+ else
190
+ console . warn ( 'using deprecated parameters for the initialization function; pass a single object instead' )
191
+
192
+ if ( typeof module_or_path === 'undefined' ) {
193
+ module_or_path = new URL ( 'postgresql_cst_parser_wasm_bg.wasm' , import . meta. url ) ;
180
194
}
181
195
const imports = __wbg_get_imports ( ) ;
182
196
183
- if ( typeof input === 'string' || ( typeof Request === 'function' && input instanceof Request ) || ( typeof URL === 'function' && input instanceof URL ) ) {
184
- input = fetch ( input ) ;
197
+ if ( typeof module_or_path === 'string' || ( typeof Request === 'function' && module_or_path instanceof Request ) || ( typeof URL === 'function' && module_or_path instanceof URL ) ) {
198
+ module_or_path = fetch ( module_or_path ) ;
185
199
}
186
200
187
201
__wbg_init_memory ( imports ) ;
188
202
189
- const { instance, module } = await __wbg_load ( await input , imports ) ;
203
+ const { instance, module } = await __wbg_load ( await module_or_path , imports ) ;
190
204
191
205
return __wbg_finalize_init ( instance , module ) ;
192
206
}
193
207
194
- export { initSync }
208
+ export { initSync } ;
195
209
export default __wbg_init ;
0 commit comments