@guanmingchiu/sqlparser-ts 0.61.0 → 0.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/index.cjs +21 -36
- package/dist/index.d.cts +4 -8
- package/dist/index.d.mts +4 -8
- package/dist/index.mjs +21 -35
- package/package.json +2 -3
- package/wasm/README.md +17 -1
- package/wasm/package.json +6 -2
- package/wasm/sqlparser_rs_wasm.d.ts +44 -0
- package/wasm/sqlparser_rs_wasm.js +108 -21
- package/wasm/sqlparser_rs_wasm_bg.wasm +0 -0
- package/wasm/sqlparser_rs_wasm_web.js +0 -628
- package/wasm/sqlparser_rs_wasm_web_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -25,7 +25,10 @@ npm install @guanmingchiu/sqlparser-ts
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { parse, format, validate } from '@guanmingchiu/sqlparser-ts';
|
|
28
|
+
import { init, parse, format, validate } from '@guanmingchiu/sqlparser-ts';
|
|
29
|
+
|
|
30
|
+
// Initialize WASM module (must be called once before using any parser functions)
|
|
31
|
+
await init();
|
|
29
32
|
|
|
30
33
|
// Parse SQL into AST
|
|
31
34
|
const ast = parse('SELECT * FROM users');
|
|
@@ -41,6 +44,19 @@ const sql = format('select * from users');
|
|
|
41
44
|
validate('SELECT * FROM users'); // ok
|
|
42
45
|
```
|
|
43
46
|
|
|
47
|
+
### Vite Configuration
|
|
48
|
+
|
|
49
|
+
WASM packages must be excluded from Vite's dev server [dependency pre-bundling](https://github.com/vitejs/vite/discussions/9256). This only affects the dev server. Production builds use Rollup instead of esbuild and handle WASM files correctly.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// vite.config.ts
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
optimizeDeps: {
|
|
55
|
+
exclude: ['@guanmingchiu/sqlparser-ts'],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
44
60
|
### Working with AST
|
|
45
61
|
|
|
46
62
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -204,55 +204,41 @@ var WasmInitError = class WasmInitError extends Error {
|
|
|
204
204
|
//#region src/wasm.ts
|
|
205
205
|
let wasmModule = null;
|
|
206
206
|
let initPromise = null;
|
|
207
|
-
let initStarted = false;
|
|
208
207
|
const isBrowser = typeof window !== "undefined" && typeof process === "undefined";
|
|
209
|
-
function startInit() {
|
|
210
|
-
if (initStarted) return;
|
|
211
|
-
initStarted = true;
|
|
212
|
-
initPromise = initWasm().catch(() => {});
|
|
213
|
-
}
|
|
214
|
-
startInit();
|
|
215
208
|
/** Get initialized WASM module or throw */
|
|
216
209
|
function getWasmModule() {
|
|
217
210
|
if (wasmModule) return wasmModule;
|
|
218
|
-
throw new WasmInitError("WASM module not yet initialized.
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Wait for WASM module to be ready
|
|
222
|
-
*/
|
|
223
|
-
async function ready() {
|
|
224
|
-
startInit();
|
|
225
|
-
await initPromise;
|
|
211
|
+
throw new WasmInitError("WASM module not yet initialized. Call `await init()` before using the parser.");
|
|
226
212
|
}
|
|
227
213
|
/**
|
|
228
|
-
* Initialize the WASM module
|
|
229
|
-
*
|
|
214
|
+
* Initialize the WASM module. Must be called before using any parser functions.
|
|
215
|
+
* Safe to call multiple times, subsequent calls are no-ops.
|
|
230
216
|
*/
|
|
231
|
-
async function
|
|
217
|
+
async function init() {
|
|
232
218
|
if (wasmModule) return;
|
|
233
|
-
if (
|
|
219
|
+
if (!initPromise) initPromise = (async () => {
|
|
234
220
|
try {
|
|
235
|
-
const wasmJsUrl = new URL("../wasm/sqlparser_rs_wasm_web.js", require("url").pathToFileURL(__filename).href);
|
|
236
|
-
const wasmBinaryUrl = new URL("../wasm/sqlparser_rs_wasm_web_bg.wasm", require("url").pathToFileURL(__filename).href);
|
|
237
221
|
const wasm = await import(
|
|
238
222
|
/* @vite-ignore */
|
|
239
|
-
|
|
223
|
+
"../wasm/sqlparser_rs_wasm.js"
|
|
240
224
|
);
|
|
241
|
-
if (
|
|
225
|
+
if (isBrowser) {
|
|
226
|
+
const wasmUrl = new URL("../wasm/sqlparser_rs_wasm_bg.wasm", require("url").pathToFileURL(__filename).href);
|
|
227
|
+
await wasm.default({ module_or_path: wasmUrl });
|
|
228
|
+
} else {
|
|
229
|
+
const { readFile } = await import(
|
|
230
|
+
/* @vite-ignore */
|
|
231
|
+
"node:fs/promises"
|
|
232
|
+
);
|
|
233
|
+
const bytes = await readFile(new URL("../wasm/sqlparser_rs_wasm_bg.wasm", require("url").pathToFileURL(__filename).href));
|
|
234
|
+
await wasm.default({ module_or_path: bytes });
|
|
235
|
+
}
|
|
242
236
|
wasmModule = wasm;
|
|
243
237
|
} catch (error) {
|
|
244
|
-
throw new WasmInitError(`Failed to load WASM module
|
|
238
|
+
throw new WasmInitError(`Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`);
|
|
245
239
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
try {
|
|
249
|
-
wasmModule = await import(
|
|
250
|
-
/* @vite-ignore */
|
|
251
|
-
new URL("../wasm/sqlparser_rs_wasm.js", require("url").pathToFileURL(__filename).href).href
|
|
252
|
-
);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
throw new WasmInitError(`Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`);
|
|
255
|
-
}
|
|
240
|
+
})();
|
|
241
|
+
await initPromise;
|
|
256
242
|
}
|
|
257
243
|
|
|
258
244
|
//#endregion
|
|
@@ -397,7 +383,6 @@ exports.SnowflakeDialect = SnowflakeDialect;
|
|
|
397
383
|
exports.WasmInitError = WasmInitError;
|
|
398
384
|
exports.dialectFromString = dialectFromString;
|
|
399
385
|
exports.format = format;
|
|
400
|
-
exports.
|
|
386
|
+
exports.init = init;
|
|
401
387
|
exports.parse = parse;
|
|
402
|
-
exports.ready = ready;
|
|
403
388
|
exports.validate = validate;
|
package/dist/index.d.cts
CHANGED
|
@@ -1204,14 +1204,10 @@ type CommentObject = 'Column' | 'Table';
|
|
|
1204
1204
|
//#endregion
|
|
1205
1205
|
//#region src/wasm.d.ts
|
|
1206
1206
|
/**
|
|
1207
|
-
*
|
|
1207
|
+
* Initialize the WASM module. Must be called before using any parser functions.
|
|
1208
|
+
* Safe to call multiple times, subsequent calls are no-ops.
|
|
1208
1209
|
*/
|
|
1209
|
-
declare function
|
|
1210
|
-
/**
|
|
1211
|
-
* Initialize the WASM module explicitly.
|
|
1212
|
-
* Usually not needed - the module auto-initializes on first use.
|
|
1213
|
-
*/
|
|
1214
|
-
declare function initWasm(): Promise<void>;
|
|
1210
|
+
declare function init(): Promise<void>;
|
|
1215
1211
|
//#endregion
|
|
1216
1212
|
//#region src/parser.d.ts
|
|
1217
1213
|
/** Dialect can be specified as a Dialect instance or a string name */
|
|
@@ -1306,4 +1302,4 @@ declare class WasmInitError extends Error {
|
|
|
1306
1302
|
constructor(message: string);
|
|
1307
1303
|
}
|
|
1308
1304
|
//#endregion
|
|
1309
|
-
export { Action, AlterColumnOperation, AlterTableOperation, AnsiDialect, Assignment, BigQueryDialect, BinaryOperator, ClickHouseDialect, CloseCursor, ColumnDef, ColumnOption, ColumnOptionDef, CommentObject, CopyLegacyOption, CopyOption, CopySource, CopyTarget, Cte, DataType, DatabricksDialect, DateTimeField, DescribeAlias, type Dialect, type DialectInput, type DialectName, DiscardObject, Distinct, DoUpdate, DropStatement, DuckDbDialect, ErrorLocation, ExceptSelectItem, ExcludeSelectItem, Expr, Fetch, FetchDirection, FileFormat, ForeignKeyOption, FunctionArg, FunctionArgExpr, FunctionExpr, GeneratedAs, GeneratedExpressionMode, GenericDialect, GrantObjects, GroupByExpr, HiveDialect, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident, IdentWithAlias, IndexType, IntervalExpr, Join, JoinConstraint, JoinOperator, LateralView, LockClause, LockType, MergeClause, MsSqlDialect, MySqlDialect, NamedWindowDefinition, NonBlock, ObjectName, ObjectType, Offset, OffsetRows, OnCommit, OnInsert, OracleDialect, OrderByExpr, Parser, ParserError, type ParserOptions, PostgreSqlDialect, Privileges, Query, RedshiftDialect, ReferentialAction, RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, SQLiteDialect, SUPPORTED_DIALECTS, SchemaName, Select, SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, ShowCreateObject, ShowStatementFilter, SnowflakeDialect, SqlOption, SqliteOnConflict, Statement, TableAlias, TableConstraint, TableFactor, TableWithJoins, Top, TransactionAccessMode, TransactionIsolationLevel, TransactionMode, TrimWhereField, UnaryOperator, Value, Values, WasmInitError, WildcardAdditionalOptions, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowSpec, With, dialectFromString, format,
|
|
1305
|
+
export { Action, AlterColumnOperation, AlterTableOperation, AnsiDialect, Assignment, BigQueryDialect, BinaryOperator, ClickHouseDialect, CloseCursor, ColumnDef, ColumnOption, ColumnOptionDef, CommentObject, CopyLegacyOption, CopyOption, CopySource, CopyTarget, Cte, DataType, DatabricksDialect, DateTimeField, DescribeAlias, type Dialect, type DialectInput, type DialectName, DiscardObject, Distinct, DoUpdate, DropStatement, DuckDbDialect, ErrorLocation, ExceptSelectItem, ExcludeSelectItem, Expr, Fetch, FetchDirection, FileFormat, ForeignKeyOption, FunctionArg, FunctionArgExpr, FunctionExpr, GeneratedAs, GeneratedExpressionMode, GenericDialect, GrantObjects, GroupByExpr, HiveDialect, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident, IdentWithAlias, IndexType, IntervalExpr, Join, JoinConstraint, JoinOperator, LateralView, LockClause, LockType, MergeClause, MsSqlDialect, MySqlDialect, NamedWindowDefinition, NonBlock, ObjectName, ObjectType, Offset, OffsetRows, OnCommit, OnInsert, OracleDialect, OrderByExpr, Parser, ParserError, type ParserOptions, PostgreSqlDialect, Privileges, Query, RedshiftDialect, ReferentialAction, RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, SQLiteDialect, SUPPORTED_DIALECTS, SchemaName, Select, SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, ShowCreateObject, ShowStatementFilter, SnowflakeDialect, SqlOption, SqliteOnConflict, Statement, TableAlias, TableConstraint, TableFactor, TableWithJoins, Top, TransactionAccessMode, TransactionIsolationLevel, TransactionMode, TrimWhereField, UnaryOperator, Value, Values, WasmInitError, WildcardAdditionalOptions, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowSpec, With, dialectFromString, format, init, parse, validate };
|
package/dist/index.d.mts
CHANGED
|
@@ -1204,14 +1204,10 @@ type CommentObject = 'Column' | 'Table';
|
|
|
1204
1204
|
//#endregion
|
|
1205
1205
|
//#region src/wasm.d.ts
|
|
1206
1206
|
/**
|
|
1207
|
-
*
|
|
1207
|
+
* Initialize the WASM module. Must be called before using any parser functions.
|
|
1208
|
+
* Safe to call multiple times, subsequent calls are no-ops.
|
|
1208
1209
|
*/
|
|
1209
|
-
declare function
|
|
1210
|
-
/**
|
|
1211
|
-
* Initialize the WASM module explicitly.
|
|
1212
|
-
* Usually not needed - the module auto-initializes on first use.
|
|
1213
|
-
*/
|
|
1214
|
-
declare function initWasm(): Promise<void>;
|
|
1210
|
+
declare function init(): Promise<void>;
|
|
1215
1211
|
//#endregion
|
|
1216
1212
|
//#region src/parser.d.ts
|
|
1217
1213
|
/** Dialect can be specified as a Dialect instance or a string name */
|
|
@@ -1306,4 +1302,4 @@ declare class WasmInitError extends Error {
|
|
|
1306
1302
|
constructor(message: string);
|
|
1307
1303
|
}
|
|
1308
1304
|
//#endregion
|
|
1309
|
-
export { Action, AlterColumnOperation, AlterTableOperation, AnsiDialect, Assignment, BigQueryDialect, BinaryOperator, ClickHouseDialect, CloseCursor, ColumnDef, ColumnOption, ColumnOptionDef, CommentObject, CopyLegacyOption, CopyOption, CopySource, CopyTarget, Cte, DataType, DatabricksDialect, DateTimeField, DescribeAlias, type Dialect, type DialectInput, type DialectName, DiscardObject, Distinct, DoUpdate, DropStatement, DuckDbDialect, ErrorLocation, ExceptSelectItem, ExcludeSelectItem, Expr, Fetch, FetchDirection, FileFormat, ForeignKeyOption, FunctionArg, FunctionArgExpr, FunctionExpr, GeneratedAs, GeneratedExpressionMode, GenericDialect, GrantObjects, GroupByExpr, HiveDialect, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident, IdentWithAlias, IndexType, IntervalExpr, Join, JoinConstraint, JoinOperator, LateralView, LockClause, LockType, MergeClause, MsSqlDialect, MySqlDialect, NamedWindowDefinition, NonBlock, ObjectName, ObjectType, Offset, OffsetRows, OnCommit, OnInsert, OracleDialect, OrderByExpr, Parser, ParserError, type ParserOptions, PostgreSqlDialect, Privileges, Query, RedshiftDialect, ReferentialAction, RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, SQLiteDialect, SUPPORTED_DIALECTS, SchemaName, Select, SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, ShowCreateObject, ShowStatementFilter, SnowflakeDialect, SqlOption, SqliteOnConflict, Statement, TableAlias, TableConstraint, TableFactor, TableWithJoins, Top, TransactionAccessMode, TransactionIsolationLevel, TransactionMode, TrimWhereField, UnaryOperator, Value, Values, WasmInitError, WildcardAdditionalOptions, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowSpec, With, dialectFromString, format,
|
|
1305
|
+
export { Action, AlterColumnOperation, AlterTableOperation, AnsiDialect, Assignment, BigQueryDialect, BinaryOperator, ClickHouseDialect, CloseCursor, ColumnDef, ColumnOption, ColumnOptionDef, CommentObject, CopyLegacyOption, CopyOption, CopySource, CopyTarget, Cte, DataType, DatabricksDialect, DateTimeField, DescribeAlias, type Dialect, type DialectInput, type DialectName, DiscardObject, Distinct, DoUpdate, DropStatement, DuckDbDialect, ErrorLocation, ExceptSelectItem, ExcludeSelectItem, Expr, Fetch, FetchDirection, FileFormat, ForeignKeyOption, FunctionArg, FunctionArgExpr, FunctionExpr, GeneratedAs, GeneratedExpressionMode, GenericDialect, GrantObjects, GroupByExpr, HiveDialect, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident, IdentWithAlias, IndexType, IntervalExpr, Join, JoinConstraint, JoinOperator, LateralView, LockClause, LockType, MergeClause, MsSqlDialect, MySqlDialect, NamedWindowDefinition, NonBlock, ObjectName, ObjectType, Offset, OffsetRows, OnCommit, OnInsert, OracleDialect, OrderByExpr, Parser, ParserError, type ParserOptions, PostgreSqlDialect, Privileges, Query, RedshiftDialect, ReferentialAction, RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, SQLiteDialect, SUPPORTED_DIALECTS, SchemaName, Select, SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, ShowCreateObject, ShowStatementFilter, SnowflakeDialect, SqlOption, SqliteOnConflict, Statement, TableAlias, TableConstraint, TableFactor, TableWithJoins, Top, TransactionAccessMode, TransactionIsolationLevel, TransactionMode, TrimWhereField, UnaryOperator, Value, Values, WasmInitError, WildcardAdditionalOptions, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowSpec, With, dialectFromString, format, init, parse, validate };
|
package/dist/index.mjs
CHANGED
|
@@ -203,55 +203,41 @@ var WasmInitError = class WasmInitError extends Error {
|
|
|
203
203
|
//#region src/wasm.ts
|
|
204
204
|
let wasmModule = null;
|
|
205
205
|
let initPromise = null;
|
|
206
|
-
let initStarted = false;
|
|
207
206
|
const isBrowser = typeof window !== "undefined" && typeof process === "undefined";
|
|
208
|
-
function startInit() {
|
|
209
|
-
if (initStarted) return;
|
|
210
|
-
initStarted = true;
|
|
211
|
-
initPromise = initWasm().catch(() => {});
|
|
212
|
-
}
|
|
213
|
-
startInit();
|
|
214
207
|
/** Get initialized WASM module or throw */
|
|
215
208
|
function getWasmModule() {
|
|
216
209
|
if (wasmModule) return wasmModule;
|
|
217
|
-
throw new WasmInitError("WASM module not yet initialized.
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Wait for WASM module to be ready
|
|
221
|
-
*/
|
|
222
|
-
async function ready() {
|
|
223
|
-
startInit();
|
|
224
|
-
await initPromise;
|
|
210
|
+
throw new WasmInitError("WASM module not yet initialized. Call `await init()` before using the parser.");
|
|
225
211
|
}
|
|
226
212
|
/**
|
|
227
|
-
* Initialize the WASM module
|
|
228
|
-
*
|
|
213
|
+
* Initialize the WASM module. Must be called before using any parser functions.
|
|
214
|
+
* Safe to call multiple times, subsequent calls are no-ops.
|
|
229
215
|
*/
|
|
230
|
-
async function
|
|
216
|
+
async function init() {
|
|
231
217
|
if (wasmModule) return;
|
|
232
|
-
if (
|
|
218
|
+
if (!initPromise) initPromise = (async () => {
|
|
233
219
|
try {
|
|
234
|
-
const wasmJsUrl = new URL("../wasm/sqlparser_rs_wasm_web.js", import.meta.url);
|
|
235
|
-
const wasmBinaryUrl = new URL("../wasm/sqlparser_rs_wasm_web_bg.wasm", import.meta.url);
|
|
236
220
|
const wasm = await import(
|
|
237
221
|
/* @vite-ignore */
|
|
238
|
-
|
|
222
|
+
"../wasm/sqlparser_rs_wasm.js"
|
|
239
223
|
);
|
|
240
|
-
if (
|
|
224
|
+
if (isBrowser) {
|
|
225
|
+
const wasmUrl = new URL("../wasm/sqlparser_rs_wasm_bg.wasm", import.meta.url);
|
|
226
|
+
await wasm.default({ module_or_path: wasmUrl });
|
|
227
|
+
} else {
|
|
228
|
+
const { readFile } = await import(
|
|
229
|
+
/* @vite-ignore */
|
|
230
|
+
"node:fs/promises"
|
|
231
|
+
);
|
|
232
|
+
const bytes = await readFile(new URL("../wasm/sqlparser_rs_wasm_bg.wasm", import.meta.url));
|
|
233
|
+
await wasm.default({ module_or_path: bytes });
|
|
234
|
+
}
|
|
241
235
|
wasmModule = wasm;
|
|
242
236
|
} catch (error) {
|
|
243
|
-
throw new WasmInitError(`Failed to load WASM module
|
|
237
|
+
throw new WasmInitError(`Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`);
|
|
244
238
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
try {
|
|
248
|
-
wasmModule = await import(
|
|
249
|
-
/* @vite-ignore */
|
|
250
|
-
new URL("../wasm/sqlparser_rs_wasm.js", import.meta.url).href
|
|
251
|
-
);
|
|
252
|
-
} catch (error) {
|
|
253
|
-
throw new WasmInitError(`Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`);
|
|
254
|
-
}
|
|
239
|
+
})();
|
|
240
|
+
await initPromise;
|
|
255
241
|
}
|
|
256
242
|
|
|
257
243
|
//#endregion
|
|
@@ -376,4 +362,4 @@ function format(sql, dialect = "generic") {
|
|
|
376
362
|
}
|
|
377
363
|
|
|
378
364
|
//#endregion
|
|
379
|
-
export { AnsiDialect, BigQueryDialect, ClickHouseDialect, DatabricksDialect, DuckDbDialect, GenericDialect, HiveDialect, MsSqlDialect, MySqlDialect, OracleDialect, Parser, ParserError, PostgreSqlDialect, RedshiftDialect, SQLiteDialect, SUPPORTED_DIALECTS, SnowflakeDialect, WasmInitError, dialectFromString, format,
|
|
365
|
+
export { AnsiDialect, BigQueryDialect, ClickHouseDialect, DatabricksDialect, DuckDbDialect, GenericDialect, HiveDialect, MsSqlDialect, MySqlDialect, OracleDialect, Parser, ParserError, PostgreSqlDialect, RedshiftDialect, SQLiteDialect, SUPPORTED_DIALECTS, SnowflakeDialect, WasmInitError, dialectFromString, format, init, parse, validate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanmingchiu/sqlparser-ts",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A SQL parser for JavaScript and TypeScript, powered by datafusion-sqlparser-rs via WASM",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "npm run build:wasm && npm run build:ts",
|
|
23
|
-
"build:wasm": "cd .. && wasm-pack build --target
|
|
24
|
-
"build:wasm:web": "cd .. && wasm-pack build --target web --out-dir ts/wasm-web",
|
|
23
|
+
"build:wasm": "cd .. && wasm-pack build --target web --out-dir ts/wasm && rm -f ts/wasm/.gitignore",
|
|
25
24
|
"build:ts": "tsdown",
|
|
26
25
|
"test": "vitest run",
|
|
27
26
|
"test:watch": "vitest",
|
package/wasm/README.md
CHANGED
|
@@ -25,7 +25,10 @@ npm install @guanmingchiu/sqlparser-ts
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { parse, format, validate } from '@guanmingchiu/sqlparser-ts';
|
|
28
|
+
import { init, parse, format, validate } from '@guanmingchiu/sqlparser-ts';
|
|
29
|
+
|
|
30
|
+
// Initialize WASM module (must be called once before using any parser functions)
|
|
31
|
+
await init();
|
|
29
32
|
|
|
30
33
|
// Parse SQL into AST
|
|
31
34
|
const ast = parse('SELECT * FROM users');
|
|
@@ -41,6 +44,19 @@ const sql = format('select * from users');
|
|
|
41
44
|
validate('SELECT * FROM users'); // ok
|
|
42
45
|
```
|
|
43
46
|
|
|
47
|
+
### Vite Configuration
|
|
48
|
+
|
|
49
|
+
WASM packages must be excluded from Vite's dev server [dependency pre-bundling](https://github.com/vitejs/vite/discussions/9256). This only affects the dev server. Production builds use Rollup instead of esbuild and handle WASM files correctly.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// vite.config.ts
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
optimizeDeps: {
|
|
55
|
+
exclude: ['@guanmingchiu/sqlparser-ts'],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
44
60
|
### Working with AST
|
|
45
61
|
|
|
46
62
|
```typescript
|
package/wasm/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqlparser-rs-wasm",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "WebAssembly bindings for sqlparser SQL parser",
|
|
4
|
-
"version": "0.61.
|
|
5
|
+
"version": "0.61.1",
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
@@ -13,5 +14,8 @@
|
|
|
13
14
|
"sqlparser_rs_wasm.d.ts"
|
|
14
15
|
],
|
|
15
16
|
"main": "sqlparser_rs_wasm.js",
|
|
16
|
-
"types": "sqlparser_rs_wasm.d.ts"
|
|
17
|
+
"types": "sqlparser_rs_wasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
]
|
|
17
21
|
}
|
|
@@ -37,3 +37,47 @@ export function parse_sql_with_options(dialect: string, sql: string, options: an
|
|
|
37
37
|
* Validate SQL syntax without returning the full AST
|
|
38
38
|
*/
|
|
39
39
|
export function validate_sql(dialect: string, sql: string): boolean;
|
|
40
|
+
|
|
41
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
42
|
+
|
|
43
|
+
export interface InitOutput {
|
|
44
|
+
readonly memory: WebAssembly.Memory;
|
|
45
|
+
readonly format_sql: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
46
|
+
readonly get_supported_dialects: () => any;
|
|
47
|
+
readonly init: () => void;
|
|
48
|
+
readonly parse_sql: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
49
|
+
readonly parse_sql_to_json_string: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
50
|
+
readonly parse_sql_to_string: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
51
|
+
readonly parse_sql_with_options: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
52
|
+
readonly validate_sql: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
53
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
54
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
55
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
56
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
57
|
+
readonly __externref_table_alloc: () => number;
|
|
58
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
59
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
60
|
+
readonly __wbindgen_start: () => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
67
|
+
* a precompiled `WebAssembly.Module`.
|
|
68
|
+
*
|
|
69
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
70
|
+
*
|
|
71
|
+
* @returns {InitOutput}
|
|
72
|
+
*/
|
|
73
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
77
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
78
|
+
*
|
|
79
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
80
|
+
*
|
|
81
|
+
* @returns {Promise<InitOutput>}
|
|
82
|
+
*/
|
|
83
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string} sql
|
|
7
7
|
* @returns {string}
|
|
8
8
|
*/
|
|
9
|
-
function format_sql(dialect, sql) {
|
|
9
|
+
export function format_sql(dialect, sql) {
|
|
10
10
|
let deferred4_0;
|
|
11
11
|
let deferred4_1;
|
|
12
12
|
try {
|
|
@@ -28,22 +28,19 @@ function format_sql(dialect, sql) {
|
|
|
28
28
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
exports.format_sql = format_sql;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* Get a list of all supported dialect names
|
|
35
34
|
* @returns {any}
|
|
36
35
|
*/
|
|
37
|
-
function get_supported_dialects() {
|
|
36
|
+
export function get_supported_dialects() {
|
|
38
37
|
const ret = wasm.get_supported_dialects();
|
|
39
38
|
return ret;
|
|
40
39
|
}
|
|
41
|
-
exports.get_supported_dialects = get_supported_dialects;
|
|
42
40
|
|
|
43
|
-
function init() {
|
|
41
|
+
export function init() {
|
|
44
42
|
wasm.init();
|
|
45
43
|
}
|
|
46
|
-
exports.init = init;
|
|
47
44
|
|
|
48
45
|
/**
|
|
49
46
|
* Parse SQL and return the AST as a JSON value
|
|
@@ -51,7 +48,7 @@ exports.init = init;
|
|
|
51
48
|
* @param {string} sql
|
|
52
49
|
* @returns {any}
|
|
53
50
|
*/
|
|
54
|
-
function parse_sql(dialect, sql) {
|
|
51
|
+
export function parse_sql(dialect, sql) {
|
|
55
52
|
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
53
|
const len0 = WASM_VECTOR_LEN;
|
|
57
54
|
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -62,7 +59,6 @@ function parse_sql(dialect, sql) {
|
|
|
62
59
|
}
|
|
63
60
|
return takeFromExternrefTable0(ret[0]);
|
|
64
61
|
}
|
|
65
|
-
exports.parse_sql = parse_sql;
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
64
|
* Parse SQL and return the AST as a JSON string
|
|
@@ -70,7 +66,7 @@ exports.parse_sql = parse_sql;
|
|
|
70
66
|
* @param {string} sql
|
|
71
67
|
* @returns {string}
|
|
72
68
|
*/
|
|
73
|
-
function parse_sql_to_json_string(dialect, sql) {
|
|
69
|
+
export function parse_sql_to_json_string(dialect, sql) {
|
|
74
70
|
let deferred4_0;
|
|
75
71
|
let deferred4_1;
|
|
76
72
|
try {
|
|
@@ -92,7 +88,6 @@ function parse_sql_to_json_string(dialect, sql) {
|
|
|
92
88
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
|
-
exports.parse_sql_to_json_string = parse_sql_to_json_string;
|
|
96
91
|
|
|
97
92
|
/**
|
|
98
93
|
* Parse SQL and return a string representation of the AST
|
|
@@ -100,7 +95,7 @@ exports.parse_sql_to_json_string = parse_sql_to_json_string;
|
|
|
100
95
|
* @param {string} sql
|
|
101
96
|
* @returns {string}
|
|
102
97
|
*/
|
|
103
|
-
function parse_sql_to_string(dialect, sql) {
|
|
98
|
+
export function parse_sql_to_string(dialect, sql) {
|
|
104
99
|
let deferred4_0;
|
|
105
100
|
let deferred4_1;
|
|
106
101
|
try {
|
|
@@ -122,7 +117,6 @@ function parse_sql_to_string(dialect, sql) {
|
|
|
122
117
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
123
118
|
}
|
|
124
119
|
}
|
|
125
|
-
exports.parse_sql_to_string = parse_sql_to_string;
|
|
126
120
|
|
|
127
121
|
/**
|
|
128
122
|
* Parse SQL with options and return the AST as a JSON value
|
|
@@ -131,7 +125,7 @@ exports.parse_sql_to_string = parse_sql_to_string;
|
|
|
131
125
|
* @param {any} options
|
|
132
126
|
* @returns {any}
|
|
133
127
|
*/
|
|
134
|
-
function parse_sql_with_options(dialect, sql, options) {
|
|
128
|
+
export function parse_sql_with_options(dialect, sql, options) {
|
|
135
129
|
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
130
|
const len0 = WASM_VECTOR_LEN;
|
|
137
131
|
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -142,7 +136,6 @@ function parse_sql_with_options(dialect, sql, options) {
|
|
|
142
136
|
}
|
|
143
137
|
return takeFromExternrefTable0(ret[0]);
|
|
144
138
|
}
|
|
145
|
-
exports.parse_sql_with_options = parse_sql_with_options;
|
|
146
139
|
|
|
147
140
|
/**
|
|
148
141
|
* Validate SQL syntax without returning the full AST
|
|
@@ -150,7 +143,7 @@ exports.parse_sql_with_options = parse_sql_with_options;
|
|
|
150
143
|
* @param {string} sql
|
|
151
144
|
* @returns {boolean}
|
|
152
145
|
*/
|
|
153
|
-
function validate_sql(dialect, sql) {
|
|
146
|
+
export function validate_sql(dialect, sql) {
|
|
154
147
|
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
155
148
|
const len0 = WASM_VECTOR_LEN;
|
|
156
149
|
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -161,7 +154,6 @@ function validate_sql(dialect, sql) {
|
|
|
161
154
|
}
|
|
162
155
|
return ret[0] !== 0;
|
|
163
156
|
}
|
|
164
|
-
exports.validate_sql = validate_sql;
|
|
165
157
|
|
|
166
158
|
function __wbg_get_imports() {
|
|
167
159
|
const import0 = {
|
|
@@ -515,7 +507,15 @@ function takeFromExternrefTable0(idx) {
|
|
|
515
507
|
|
|
516
508
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
517
509
|
cachedTextDecoder.decode();
|
|
510
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
511
|
+
let numBytesDecoded = 0;
|
|
518
512
|
function decodeText(ptr, len) {
|
|
513
|
+
numBytesDecoded += len;
|
|
514
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
515
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
516
|
+
cachedTextDecoder.decode();
|
|
517
|
+
numBytesDecoded = len;
|
|
518
|
+
}
|
|
519
519
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
520
520
|
}
|
|
521
521
|
|
|
@@ -534,8 +534,95 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
534
534
|
|
|
535
535
|
let WASM_VECTOR_LEN = 0;
|
|
536
536
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
537
|
+
let wasmModule, wasm;
|
|
538
|
+
function __wbg_finalize_init(instance, module) {
|
|
539
|
+
wasm = instance.exports;
|
|
540
|
+
wasmModule = module;
|
|
541
|
+
cachedDataViewMemory0 = null;
|
|
542
|
+
cachedUint8ArrayMemory0 = null;
|
|
543
|
+
wasm.__wbindgen_start();
|
|
544
|
+
return wasm;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async function __wbg_load(module, imports) {
|
|
548
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
549
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
550
|
+
try {
|
|
551
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
552
|
+
} catch (e) {
|
|
553
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
554
|
+
|
|
555
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
556
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
557
|
+
|
|
558
|
+
} else { throw e; }
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const bytes = await module.arrayBuffer();
|
|
563
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
564
|
+
} else {
|
|
565
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
566
|
+
|
|
567
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
568
|
+
return { instance, module };
|
|
569
|
+
} else {
|
|
570
|
+
return instance;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function expectedResponseType(type) {
|
|
575
|
+
switch (type) {
|
|
576
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
577
|
+
}
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function initSync(module) {
|
|
583
|
+
if (wasm !== undefined) return wasm;
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
if (module !== undefined) {
|
|
587
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
588
|
+
({module} = module)
|
|
589
|
+
} else {
|
|
590
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const imports = __wbg_get_imports();
|
|
595
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
596
|
+
module = new WebAssembly.Module(module);
|
|
597
|
+
}
|
|
598
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
599
|
+
return __wbg_finalize_init(instance, module);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function __wbg_init(module_or_path) {
|
|
603
|
+
if (wasm !== undefined) return wasm;
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
if (module_or_path !== undefined) {
|
|
607
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
608
|
+
({module_or_path} = module_or_path)
|
|
609
|
+
} else {
|
|
610
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (module_or_path === undefined) {
|
|
615
|
+
module_or_path = new URL('sqlparser_rs_wasm_bg.wasm', import.meta.url);
|
|
616
|
+
}
|
|
617
|
+
const imports = __wbg_get_imports();
|
|
618
|
+
|
|
619
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
620
|
+
module_or_path = fetch(module_or_path);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
624
|
+
|
|
625
|
+
return __wbg_finalize_init(instance, module);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./sqlparser_rs_wasm.d.ts" */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Format SQL by parsing and regenerating it (round-trip)
|
|
5
|
-
* @param {string} dialect
|
|
6
|
-
* @param {string} sql
|
|
7
|
-
* @returns {string}
|
|
8
|
-
*/
|
|
9
|
-
export function format_sql(dialect, sql) {
|
|
10
|
-
let deferred4_0;
|
|
11
|
-
let deferred4_1;
|
|
12
|
-
try {
|
|
13
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
14
|
-
const len0 = WASM_VECTOR_LEN;
|
|
15
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
16
|
-
const len1 = WASM_VECTOR_LEN;
|
|
17
|
-
const ret = wasm.format_sql(ptr0, len0, ptr1, len1);
|
|
18
|
-
var ptr3 = ret[0];
|
|
19
|
-
var len3 = ret[1];
|
|
20
|
-
if (ret[3]) {
|
|
21
|
-
ptr3 = 0; len3 = 0;
|
|
22
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
23
|
-
}
|
|
24
|
-
deferred4_0 = ptr3;
|
|
25
|
-
deferred4_1 = len3;
|
|
26
|
-
return getStringFromWasm0(ptr3, len3);
|
|
27
|
-
} finally {
|
|
28
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get a list of all supported dialect names
|
|
34
|
-
* @returns {any}
|
|
35
|
-
*/
|
|
36
|
-
export function get_supported_dialects() {
|
|
37
|
-
const ret = wasm.get_supported_dialects();
|
|
38
|
-
return ret;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function init() {
|
|
42
|
-
wasm.init();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Parse SQL and return the AST as a JSON value
|
|
47
|
-
* @param {string} dialect
|
|
48
|
-
* @param {string} sql
|
|
49
|
-
* @returns {any}
|
|
50
|
-
*/
|
|
51
|
-
export function parse_sql(dialect, sql) {
|
|
52
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
53
|
-
const len0 = WASM_VECTOR_LEN;
|
|
54
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
55
|
-
const len1 = WASM_VECTOR_LEN;
|
|
56
|
-
const ret = wasm.parse_sql(ptr0, len0, ptr1, len1);
|
|
57
|
-
if (ret[2]) {
|
|
58
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
59
|
-
}
|
|
60
|
-
return takeFromExternrefTable0(ret[0]);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Parse SQL and return the AST as a JSON string
|
|
65
|
-
* @param {string} dialect
|
|
66
|
-
* @param {string} sql
|
|
67
|
-
* @returns {string}
|
|
68
|
-
*/
|
|
69
|
-
export function parse_sql_to_json_string(dialect, sql) {
|
|
70
|
-
let deferred4_0;
|
|
71
|
-
let deferred4_1;
|
|
72
|
-
try {
|
|
73
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
74
|
-
const len0 = WASM_VECTOR_LEN;
|
|
75
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
-
const len1 = WASM_VECTOR_LEN;
|
|
77
|
-
const ret = wasm.parse_sql_to_json_string(ptr0, len0, ptr1, len1);
|
|
78
|
-
var ptr3 = ret[0];
|
|
79
|
-
var len3 = ret[1];
|
|
80
|
-
if (ret[3]) {
|
|
81
|
-
ptr3 = 0; len3 = 0;
|
|
82
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
83
|
-
}
|
|
84
|
-
deferred4_0 = ptr3;
|
|
85
|
-
deferred4_1 = len3;
|
|
86
|
-
return getStringFromWasm0(ptr3, len3);
|
|
87
|
-
} finally {
|
|
88
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Parse SQL and return a string representation of the AST
|
|
94
|
-
* @param {string} dialect
|
|
95
|
-
* @param {string} sql
|
|
96
|
-
* @returns {string}
|
|
97
|
-
*/
|
|
98
|
-
export function parse_sql_to_string(dialect, sql) {
|
|
99
|
-
let deferred4_0;
|
|
100
|
-
let deferred4_1;
|
|
101
|
-
try {
|
|
102
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
-
const len0 = WASM_VECTOR_LEN;
|
|
104
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
-
const len1 = WASM_VECTOR_LEN;
|
|
106
|
-
const ret = wasm.parse_sql_to_string(ptr0, len0, ptr1, len1);
|
|
107
|
-
var ptr3 = ret[0];
|
|
108
|
-
var len3 = ret[1];
|
|
109
|
-
if (ret[3]) {
|
|
110
|
-
ptr3 = 0; len3 = 0;
|
|
111
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
112
|
-
}
|
|
113
|
-
deferred4_0 = ptr3;
|
|
114
|
-
deferred4_1 = len3;
|
|
115
|
-
return getStringFromWasm0(ptr3, len3);
|
|
116
|
-
} finally {
|
|
117
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Parse SQL with options and return the AST as a JSON value
|
|
123
|
-
* @param {string} dialect
|
|
124
|
-
* @param {string} sql
|
|
125
|
-
* @param {any} options
|
|
126
|
-
* @returns {any}
|
|
127
|
-
*/
|
|
128
|
-
export function parse_sql_with_options(dialect, sql, options) {
|
|
129
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
-
const len0 = WASM_VECTOR_LEN;
|
|
131
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
-
const len1 = WASM_VECTOR_LEN;
|
|
133
|
-
const ret = wasm.parse_sql_with_options(ptr0, len0, ptr1, len1, options);
|
|
134
|
-
if (ret[2]) {
|
|
135
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
136
|
-
}
|
|
137
|
-
return takeFromExternrefTable0(ret[0]);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Validate SQL syntax without returning the full AST
|
|
142
|
-
* @param {string} dialect
|
|
143
|
-
* @param {string} sql
|
|
144
|
-
* @returns {boolean}
|
|
145
|
-
*/
|
|
146
|
-
export function validate_sql(dialect, sql) {
|
|
147
|
-
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
-
const len0 = WASM_VECTOR_LEN;
|
|
149
|
-
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
-
const len1 = WASM_VECTOR_LEN;
|
|
151
|
-
const ret = wasm.validate_sql(ptr0, len0, ptr1, len1);
|
|
152
|
-
if (ret[2]) {
|
|
153
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
154
|
-
}
|
|
155
|
-
return ret[0] !== 0;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function __wbg_get_imports() {
|
|
159
|
-
const import0 = {
|
|
160
|
-
__proto__: null,
|
|
161
|
-
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
162
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
163
|
-
return ret;
|
|
164
|
-
},
|
|
165
|
-
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
166
|
-
const ret = Number(arg0);
|
|
167
|
-
return ret;
|
|
168
|
-
},
|
|
169
|
-
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
170
|
-
const ret = String(arg1);
|
|
171
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
172
|
-
const len1 = WASM_VECTOR_LEN;
|
|
173
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
174
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
175
|
-
},
|
|
176
|
-
__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
|
|
177
|
-
const v = arg1;
|
|
178
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
179
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
180
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
181
|
-
},
|
|
182
|
-
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
183
|
-
const v = arg0;
|
|
184
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
185
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
186
|
-
},
|
|
187
|
-
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
188
|
-
const ret = debugString(arg1);
|
|
189
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
-
const len1 = WASM_VECTOR_LEN;
|
|
191
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
192
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
193
|
-
},
|
|
194
|
-
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
195
|
-
const ret = arg0 in arg1;
|
|
196
|
-
return ret;
|
|
197
|
-
},
|
|
198
|
-
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
199
|
-
const ret = typeof(arg0) === 'bigint';
|
|
200
|
-
return ret;
|
|
201
|
-
},
|
|
202
|
-
__wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
|
|
203
|
-
const ret = arg0 === null;
|
|
204
|
-
return ret;
|
|
205
|
-
},
|
|
206
|
-
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
207
|
-
const val = arg0;
|
|
208
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
209
|
-
return ret;
|
|
210
|
-
},
|
|
211
|
-
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
212
|
-
const ret = arg0 === undefined;
|
|
213
|
-
return ret;
|
|
214
|
-
},
|
|
215
|
-
__wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
|
|
216
|
-
const ret = arg0 === arg1;
|
|
217
|
-
return ret;
|
|
218
|
-
},
|
|
219
|
-
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
220
|
-
const ret = arg0 == arg1;
|
|
221
|
-
return ret;
|
|
222
|
-
},
|
|
223
|
-
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
224
|
-
const obj = arg1;
|
|
225
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
226
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
227
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
228
|
-
},
|
|
229
|
-
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
230
|
-
const obj = arg1;
|
|
231
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
232
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
233
|
-
var len1 = WASM_VECTOR_LEN;
|
|
234
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
235
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
236
|
-
},
|
|
237
|
-
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
238
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
239
|
-
},
|
|
240
|
-
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
241
|
-
let deferred0_0;
|
|
242
|
-
let deferred0_1;
|
|
243
|
-
try {
|
|
244
|
-
deferred0_0 = arg0;
|
|
245
|
-
deferred0_1 = arg1;
|
|
246
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
247
|
-
} finally {
|
|
248
|
-
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
__wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
|
|
252
|
-
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
253
|
-
return ret;
|
|
254
|
-
}, arguments); },
|
|
255
|
-
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
256
|
-
const ret = arg0[arg1];
|
|
257
|
-
return ret;
|
|
258
|
-
},
|
|
259
|
-
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
260
|
-
let result;
|
|
261
|
-
try {
|
|
262
|
-
result = arg0 instanceof ArrayBuffer;
|
|
263
|
-
} catch (_) {
|
|
264
|
-
result = false;
|
|
265
|
-
}
|
|
266
|
-
const ret = result;
|
|
267
|
-
return ret;
|
|
268
|
-
},
|
|
269
|
-
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
270
|
-
let result;
|
|
271
|
-
try {
|
|
272
|
-
result = arg0 instanceof Uint8Array;
|
|
273
|
-
} catch (_) {
|
|
274
|
-
result = false;
|
|
275
|
-
}
|
|
276
|
-
const ret = result;
|
|
277
|
-
return ret;
|
|
278
|
-
},
|
|
279
|
-
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
280
|
-
const ret = Number.isSafeInteger(arg0);
|
|
281
|
-
return ret;
|
|
282
|
-
},
|
|
283
|
-
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
284
|
-
const ret = arg0.length;
|
|
285
|
-
return ret;
|
|
286
|
-
},
|
|
287
|
-
__wbg_new_361308b2356cecd0: function() {
|
|
288
|
-
const ret = new Object();
|
|
289
|
-
return ret;
|
|
290
|
-
},
|
|
291
|
-
__wbg_new_3eb36ae241fe6f44: function() {
|
|
292
|
-
const ret = new Array();
|
|
293
|
-
return ret;
|
|
294
|
-
},
|
|
295
|
-
__wbg_new_8a6f238a6ece86ea: function() {
|
|
296
|
-
const ret = new Error();
|
|
297
|
-
return ret;
|
|
298
|
-
},
|
|
299
|
-
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
300
|
-
const ret = new Uint8Array(arg0);
|
|
301
|
-
return ret;
|
|
302
|
-
},
|
|
303
|
-
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
304
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
305
|
-
},
|
|
306
|
-
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
307
|
-
arg0[arg1] = arg2;
|
|
308
|
-
},
|
|
309
|
-
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
310
|
-
arg0[arg1 >>> 0] = arg2;
|
|
311
|
-
},
|
|
312
|
-
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
313
|
-
const ret = arg1.stack;
|
|
314
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
315
|
-
const len1 = WASM_VECTOR_LEN;
|
|
316
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
317
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
318
|
-
},
|
|
319
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
320
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
321
|
-
const ret = arg0;
|
|
322
|
-
return ret;
|
|
323
|
-
},
|
|
324
|
-
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
325
|
-
// Cast intrinsic for `I64 -> Externref`.
|
|
326
|
-
const ret = arg0;
|
|
327
|
-
return ret;
|
|
328
|
-
},
|
|
329
|
-
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
330
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
331
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
332
|
-
return ret;
|
|
333
|
-
},
|
|
334
|
-
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
335
|
-
// Cast intrinsic for `U64 -> Externref`.
|
|
336
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
337
|
-
return ret;
|
|
338
|
-
},
|
|
339
|
-
__wbindgen_init_externref_table: function() {
|
|
340
|
-
const table = wasm.__wbindgen_externrefs;
|
|
341
|
-
const offset = table.grow(4);
|
|
342
|
-
table.set(0, undefined);
|
|
343
|
-
table.set(offset + 0, undefined);
|
|
344
|
-
table.set(offset + 1, null);
|
|
345
|
-
table.set(offset + 2, true);
|
|
346
|
-
table.set(offset + 3, false);
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
return {
|
|
350
|
-
__proto__: null,
|
|
351
|
-
"./sqlparser_rs_wasm_bg.js": import0,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function addToExternrefTable0(obj) {
|
|
356
|
-
const idx = wasm.__externref_table_alloc();
|
|
357
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
358
|
-
return idx;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function debugString(val) {
|
|
362
|
-
// primitive types
|
|
363
|
-
const type = typeof val;
|
|
364
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
365
|
-
return `${val}`;
|
|
366
|
-
}
|
|
367
|
-
if (type == 'string') {
|
|
368
|
-
return `"${val}"`;
|
|
369
|
-
}
|
|
370
|
-
if (type == 'symbol') {
|
|
371
|
-
const description = val.description;
|
|
372
|
-
if (description == null) {
|
|
373
|
-
return 'Symbol';
|
|
374
|
-
} else {
|
|
375
|
-
return `Symbol(${description})`;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (type == 'function') {
|
|
379
|
-
const name = val.name;
|
|
380
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
381
|
-
return `Function(${name})`;
|
|
382
|
-
} else {
|
|
383
|
-
return 'Function';
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
// objects
|
|
387
|
-
if (Array.isArray(val)) {
|
|
388
|
-
const length = val.length;
|
|
389
|
-
let debug = '[';
|
|
390
|
-
if (length > 0) {
|
|
391
|
-
debug += debugString(val[0]);
|
|
392
|
-
}
|
|
393
|
-
for(let i = 1; i < length; i++) {
|
|
394
|
-
debug += ', ' + debugString(val[i]);
|
|
395
|
-
}
|
|
396
|
-
debug += ']';
|
|
397
|
-
return debug;
|
|
398
|
-
}
|
|
399
|
-
// Test for built-in
|
|
400
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
401
|
-
let className;
|
|
402
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
403
|
-
className = builtInMatches[1];
|
|
404
|
-
} else {
|
|
405
|
-
// Failed to match the standard '[object ClassName]'
|
|
406
|
-
return toString.call(val);
|
|
407
|
-
}
|
|
408
|
-
if (className == 'Object') {
|
|
409
|
-
// we're a user defined class or Object
|
|
410
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
411
|
-
// easier than looping through ownProperties of `val`.
|
|
412
|
-
try {
|
|
413
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
414
|
-
} catch (_) {
|
|
415
|
-
return 'Object';
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
// errors
|
|
419
|
-
if (val instanceof Error) {
|
|
420
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
421
|
-
}
|
|
422
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
423
|
-
return className;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
427
|
-
ptr = ptr >>> 0;
|
|
428
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
let cachedDataViewMemory0 = null;
|
|
432
|
-
function getDataViewMemory0() {
|
|
433
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
434
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
435
|
-
}
|
|
436
|
-
return cachedDataViewMemory0;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
function getStringFromWasm0(ptr, len) {
|
|
440
|
-
ptr = ptr >>> 0;
|
|
441
|
-
return decodeText(ptr, len);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
let cachedUint8ArrayMemory0 = null;
|
|
445
|
-
function getUint8ArrayMemory0() {
|
|
446
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
447
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
448
|
-
}
|
|
449
|
-
return cachedUint8ArrayMemory0;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function handleError(f, args) {
|
|
453
|
-
try {
|
|
454
|
-
return f.apply(this, args);
|
|
455
|
-
} catch (e) {
|
|
456
|
-
const idx = addToExternrefTable0(e);
|
|
457
|
-
wasm.__wbindgen_exn_store(idx);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function isLikeNone(x) {
|
|
462
|
-
return x === undefined || x === null;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
466
|
-
if (realloc === undefined) {
|
|
467
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
468
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
469
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
470
|
-
WASM_VECTOR_LEN = buf.length;
|
|
471
|
-
return ptr;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
let len = arg.length;
|
|
475
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
476
|
-
|
|
477
|
-
const mem = getUint8ArrayMemory0();
|
|
478
|
-
|
|
479
|
-
let offset = 0;
|
|
480
|
-
|
|
481
|
-
for (; offset < len; offset++) {
|
|
482
|
-
const code = arg.charCodeAt(offset);
|
|
483
|
-
if (code > 0x7F) break;
|
|
484
|
-
mem[ptr + offset] = code;
|
|
485
|
-
}
|
|
486
|
-
if (offset !== len) {
|
|
487
|
-
if (offset !== 0) {
|
|
488
|
-
arg = arg.slice(offset);
|
|
489
|
-
}
|
|
490
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
491
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
492
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
493
|
-
|
|
494
|
-
offset += ret.written;
|
|
495
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
WASM_VECTOR_LEN = offset;
|
|
499
|
-
return ptr;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function takeFromExternrefTable0(idx) {
|
|
503
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
504
|
-
wasm.__externref_table_dealloc(idx);
|
|
505
|
-
return value;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
509
|
-
cachedTextDecoder.decode();
|
|
510
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
511
|
-
let numBytesDecoded = 0;
|
|
512
|
-
function decodeText(ptr, len) {
|
|
513
|
-
numBytesDecoded += len;
|
|
514
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
515
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
516
|
-
cachedTextDecoder.decode();
|
|
517
|
-
numBytesDecoded = len;
|
|
518
|
-
}
|
|
519
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const cachedTextEncoder = new TextEncoder();
|
|
523
|
-
|
|
524
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
525
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
526
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
527
|
-
view.set(buf);
|
|
528
|
-
return {
|
|
529
|
-
read: arg.length,
|
|
530
|
-
written: buf.length
|
|
531
|
-
};
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
let WASM_VECTOR_LEN = 0;
|
|
536
|
-
|
|
537
|
-
let wasmModule, wasm;
|
|
538
|
-
function __wbg_finalize_init(instance, module) {
|
|
539
|
-
wasm = instance.exports;
|
|
540
|
-
wasmModule = module;
|
|
541
|
-
cachedDataViewMemory0 = null;
|
|
542
|
-
cachedUint8ArrayMemory0 = null;
|
|
543
|
-
wasm.__wbindgen_start();
|
|
544
|
-
return wasm;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
async function __wbg_load(module, imports) {
|
|
548
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
549
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
550
|
-
try {
|
|
551
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
552
|
-
} catch (e) {
|
|
553
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
554
|
-
|
|
555
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
556
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
557
|
-
|
|
558
|
-
} else { throw e; }
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const bytes = await module.arrayBuffer();
|
|
563
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
564
|
-
} else {
|
|
565
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
566
|
-
|
|
567
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
568
|
-
return { instance, module };
|
|
569
|
-
} else {
|
|
570
|
-
return instance;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function expectedResponseType(type) {
|
|
575
|
-
switch (type) {
|
|
576
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
577
|
-
}
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
function initSync(module) {
|
|
583
|
-
if (wasm !== undefined) return wasm;
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
if (module !== undefined) {
|
|
587
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
588
|
-
({module} = module)
|
|
589
|
-
} else {
|
|
590
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
const imports = __wbg_get_imports();
|
|
595
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
596
|
-
module = new WebAssembly.Module(module);
|
|
597
|
-
}
|
|
598
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
599
|
-
return __wbg_finalize_init(instance, module);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
async function __wbg_init(module_or_path) {
|
|
603
|
-
if (wasm !== undefined) return wasm;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (module_or_path !== undefined) {
|
|
607
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
608
|
-
({module_or_path} = module_or_path)
|
|
609
|
-
} else {
|
|
610
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if (module_or_path === undefined) {
|
|
615
|
-
module_or_path = new URL('sqlparser_rs_wasm_bg.wasm', import.meta.url);
|
|
616
|
-
}
|
|
617
|
-
const imports = __wbg_get_imports();
|
|
618
|
-
|
|
619
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
620
|
-
module_or_path = fetch(module_or_path);
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
624
|
-
|
|
625
|
-
return __wbg_finalize_init(instance, module);
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
export { initSync, __wbg_init as default };
|
|
Binary file
|