@lovable.dev/lovsem-compiler 0.0.0 → 0.1.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 +25 -1
- package/dist/index.d.ts +130 -0
- package/dist/index.js +71 -0
- package/package.json +35 -4
- package/wasm/lovsem_wasm.d.ts +56 -0
- package/wasm/lovsem_wasm.js +287 -0
- package/wasm/lovsem_wasm_bg.wasm +0 -0
- package/wasm/lovsem_wasm_bg.wasm.d.ts +12 -0
package/README.md
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# @lovable.dev/lovsem-compiler
|
|
2
|
+
|
|
3
|
+
Compiles a query against a stitched semantic model to SQL, in the browser or on
|
|
4
|
+
a server. The compiler is `crates/lovsem-wasm` built as WebAssembly; the
|
|
5
|
+
model comes from `@lovable.dev/lovsem`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { SemanticCompiler, init } from "@lovable.dev/lovsem-compiler";
|
|
9
|
+
|
|
10
|
+
await init(); // in a Vite app; on a server, initSync(bytes of wasm/lovsem_wasm_bg.wasm)
|
|
11
|
+
const compiler = new SemanticCompiler(repo.buildSemanticModel("sales").document);
|
|
12
|
+
const sql = compiler.sql({ group_by: ["metric_time__month"], metrics: ["revenue"] }, "bigquery");
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| Export | What it does |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `init(module?)` | Loads the module; without an argument it fetches the copy the bundler emitted, which in `vite dev` needs the package kept out of `optimizeDeps` (the `semantics()` plugin does this) |
|
|
18
|
+
| `initSync(bytes)` | Loads it from bytes already read |
|
|
19
|
+
| `SemanticCompiler` | Compiles a model once; `sql(query, dialect)` returns SQL for `ansi` or `bigquery` |
|
|
20
|
+
| `SemanticsCompileError` | Thrown with every problem found, in `problems` |
|
|
21
|
+
| `SemanticQuery` and its parts | Generated from `crates/ossie-compiler` by ts-rs |
|
|
22
|
+
|
|
23
|
+
`wasm/` is committed build output. After changing a crate the compiler uses,
|
|
24
|
+
rebuild it with `./build-wasm.sh`, which needs `wasm-pack`, the
|
|
25
|
+
`wasm32-unknown-unknown` target and binaryen's `wasm-opt` on `PATH`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { InitInput } from "../wasm/lovsem_wasm.js";
|
|
2
|
+
import { OssieDocument } from "@lovable.dev/lovsem";
|
|
3
|
+
//#region src/generated/Direction.d.ts
|
|
4
|
+
type Direction = "asc" | "desc";
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/generated/FilterOperator.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Comparison used by a [`FilterSpec`].
|
|
9
|
+
*
|
|
10
|
+
* Deserialized from the query JSON, so an unrecognized spelling fails there
|
|
11
|
+
* rather than silently degrading to equality. Symbol aliases are accepted for
|
|
12
|
+
* the operators that have a conventional one.
|
|
13
|
+
*/
|
|
14
|
+
type FilterOperator = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "is_null" | "is_not_null" | "eq_field";
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/generated/serde_json/JsonValue.d.ts
|
|
17
|
+
type JsonValue = number | string | boolean | Array<JsonValue> | { [key in string]: JsonValue; } | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/generated/FilterSpec.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* Predicate on a field (`dataset.field`).
|
|
22
|
+
*/
|
|
23
|
+
type FilterSpec = {
|
|
24
|
+
/**
|
|
25
|
+
* `dataset.field`
|
|
26
|
+
*/
|
|
27
|
+
field: string;
|
|
28
|
+
/**
|
|
29
|
+
* Omitted means [`FilterOperator::In`] when `value` is a JSON array and
|
|
30
|
+
* [`FilterOperator::Eq`] otherwise.
|
|
31
|
+
*/
|
|
32
|
+
operator?: FilterOperator | null;
|
|
33
|
+
/**
|
|
34
|
+
* Omitted is `null`, which is what the null-checking operators expect.
|
|
35
|
+
*/
|
|
36
|
+
value?: JsonValue;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/generated/NullOrder.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* Engines disagree on where nulls sort by default, and Substrait makes the
|
|
42
|
+
* choice part of the sort direction, so it is stated rather than assumed.
|
|
43
|
+
*/
|
|
44
|
+
type NullOrder = "first" | "last";
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/generated/OrderBy.d.ts
|
|
47
|
+
/**
|
|
48
|
+
* One ordering term.
|
|
49
|
+
*/
|
|
50
|
+
type OrderBy = {
|
|
51
|
+
/**
|
|
52
|
+
* Something the query selects: a grouped `dataset.field` (or its bare
|
|
53
|
+
* field name) or a metric name. Not an arbitrary expression — you order
|
|
54
|
+
* by what you asked for.
|
|
55
|
+
*/
|
|
56
|
+
ref: string;
|
|
57
|
+
direction?: Direction;
|
|
58
|
+
/**
|
|
59
|
+
* Where nulls sort. Omitted means they sort as greater than non-nulls:
|
|
60
|
+
* last when ascending, first when descending.
|
|
61
|
+
*/
|
|
62
|
+
nulls?: NullOrder | null;
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/generated/SemanticQuery.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* Query body: `GROUP BY` fields, metrics, filters. Model identity is provided separately to [`crate::resolver::bind_query`].
|
|
68
|
+
*/
|
|
69
|
+
type SemanticQuery = {
|
|
70
|
+
/**
|
|
71
|
+
* Field references (`dataset.field`) for `GROUP BY`.
|
|
72
|
+
*/
|
|
73
|
+
group_by?: Array<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Metric names defined on the semantic model.
|
|
76
|
+
*/
|
|
77
|
+
metrics?: Array<string>;
|
|
78
|
+
filters?: Array<FilterSpec>;
|
|
79
|
+
/**
|
|
80
|
+
* When no field references appear in `group_by` or filters, selects the scan target for metrics-only queries.
|
|
81
|
+
*/
|
|
82
|
+
dataset?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Ordering, applied to what the query selects.
|
|
85
|
+
*/
|
|
86
|
+
order_by?: Array<OrderBy>;
|
|
87
|
+
/**
|
|
88
|
+
* Maximum rows to return. Omitted means all of them.
|
|
89
|
+
*/
|
|
90
|
+
limit?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Rows to skip before the first returned row.
|
|
93
|
+
*/
|
|
94
|
+
offset?: number;
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/index.d.ts
|
|
98
|
+
type Dialect = "ansi" | "bigquery";
|
|
99
|
+
/** Every problem the compiler found with a document or a query. */
|
|
100
|
+
declare class SemanticsCompileError extends Error {
|
|
101
|
+
readonly problems: string[];
|
|
102
|
+
constructor(problems: string[]);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Load the compiler before the first {@link SemanticCompiler}.
|
|
106
|
+
*
|
|
107
|
+
* In a browser bundled by Vite, call it without arguments: the module ships
|
|
108
|
+
* in this package and is fetched from where the bundler put it. Elsewhere pass
|
|
109
|
+
* its bytes, its URL or a compiled `WebAssembly.Module`.
|
|
110
|
+
*/
|
|
111
|
+
declare function init(module?: InitInput | Promise<InitInput>): Promise<void>;
|
|
112
|
+
/** {@link init} from bytes already in hand, as a server reading `wasm/lovsem_wasm_bg.wasm` has. */
|
|
113
|
+
declare function initSync(module: BufferSource | WebAssembly.Module): void;
|
|
114
|
+
/**
|
|
115
|
+
* A stitched semantic model compiled once, to compile many queries against.
|
|
116
|
+
*
|
|
117
|
+
* Its memory is released when it is garbage collected; `free()`, or a `using`
|
|
118
|
+
* declaration, releases it sooner.
|
|
119
|
+
*/
|
|
120
|
+
declare class SemanticCompiler {
|
|
121
|
+
#private;
|
|
122
|
+
/** `document` is a stitched model, as `SemanticRepo.buildSemanticModel` returns it. */
|
|
123
|
+
constructor(document: OssieDocument);
|
|
124
|
+
/** The SQL that answers `query`. */
|
|
125
|
+
sql(query: SemanticQuery, dialect?: Dialect): string;
|
|
126
|
+
free(): void;
|
|
127
|
+
[Symbol.dispose](): void;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Dialect, type Direction, type FilterOperator, type FilterSpec, type JsonValue, type NullOrder, type OrderBy, SemanticCompiler, type SemanticQuery, SemanticsCompileError, init, initSync };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import initWasm, { Compiler, initSync as initSync$1 } from "../wasm/lovsem_wasm.js";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
/** Every problem the compiler found with a document or a query. */
|
|
4
|
+
var SemanticsCompileError = class extends Error {
|
|
5
|
+
problems;
|
|
6
|
+
constructor(problems) {
|
|
7
|
+
super(problems.join("\n"));
|
|
8
|
+
this.name = "SemanticsCompileError";
|
|
9
|
+
this.problems = problems;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
let loaded = false;
|
|
13
|
+
/**
|
|
14
|
+
* Load the compiler before the first {@link SemanticCompiler}.
|
|
15
|
+
*
|
|
16
|
+
* In a browser bundled by Vite, call it without arguments: the module ships
|
|
17
|
+
* in this package and is fetched from where the bundler put it. Elsewhere pass
|
|
18
|
+
* its bytes, its URL or a compiled `WebAssembly.Module`.
|
|
19
|
+
*/
|
|
20
|
+
async function init(module) {
|
|
21
|
+
await initWasm(module === void 0 ? void 0 : { module_or_path: module });
|
|
22
|
+
loaded = true;
|
|
23
|
+
}
|
|
24
|
+
/** {@link init} from bytes already in hand, as a server reading `wasm/lovsem_wasm_bg.wasm` has. */
|
|
25
|
+
function initSync(module) {
|
|
26
|
+
initSync$1({ module });
|
|
27
|
+
loaded = true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A stitched semantic model compiled once, to compile many queries against.
|
|
31
|
+
*
|
|
32
|
+
* Its memory is released when it is garbage collected; `free()`, or a `using`
|
|
33
|
+
* declaration, releases it sooner.
|
|
34
|
+
*/
|
|
35
|
+
var SemanticCompiler = class {
|
|
36
|
+
#compiler;
|
|
37
|
+
/** `document` is a stitched model, as `SemanticRepo.buildSemanticModel` returns it. */
|
|
38
|
+
constructor(document) {
|
|
39
|
+
if (!loaded) throw new Error("call init() or initSync() before compiling");
|
|
40
|
+
this.#compiler = unpack(() => new Compiler(JSON.stringify(document)));
|
|
41
|
+
}
|
|
42
|
+
/** The SQL that answers `query`. */
|
|
43
|
+
sql(query, dialect = "ansi") {
|
|
44
|
+
return unpack(() => this.#compiler.sql(JSON.stringify(query), dialect));
|
|
45
|
+
}
|
|
46
|
+
free() {
|
|
47
|
+
this.#compiler.free();
|
|
48
|
+
}
|
|
49
|
+
[Symbol.dispose]() {
|
|
50
|
+
this.free();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/** The compiler throws its problems as a JSON array in the error's message. */
|
|
54
|
+
function unpack(run) {
|
|
55
|
+
try {
|
|
56
|
+
return run();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const problems = error instanceof Error ? problemsOf(error.message) : void 0;
|
|
59
|
+
throw problems ? new SemanticsCompileError(problems) : error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function problemsOf(message) {
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(message);
|
|
65
|
+
return Array.isArray(parsed) && parsed.every((p) => typeof p === "string") ? parsed : void 0;
|
|
66
|
+
} catch {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { SemanticCompiler, SemanticsCompileError, init, initSync };
|
package/package.json
CHANGED
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/lovsem-compiler",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Compile queries against a Lovable project's semantic layer to SQL, in the browser or on a server, with the Rust compiler built as WebAssembly.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
5
7
|
"license": "Apache-2.0",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
10
|
"url": "git+https://github.com/lovablelabs/lovable.git",
|
|
9
11
|
"directory": "data/lovsem/packages/lovsem-compiler"
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./wasm/*": "./wasm/*"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"wasm"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@lovable.dev/lovsem": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "22.13.13",
|
|
29
|
+
"tsdown": "^0.22.5",
|
|
30
|
+
"typescript": "7.0.2",
|
|
31
|
+
"vite": "8.2.1",
|
|
32
|
+
"vitest": "^4.1.5"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsdown",
|
|
36
|
+
"build:wasm": "./build-wasm.sh",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
39
|
+
"check:package": "tmp=$(mktemp -d) && pnpm pack --out \"$tmp/pkg.tgz\" && tar -xzf \"$tmp/pkg.tgz\" -C \"$tmp\" && publint \"$tmp/package\" --strict && attw \"$tmp/pkg.tgz\""
|
|
40
|
+
},
|
|
41
|
+
"types": "./dist/index.d.ts"
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A semantic model compiled once, for compiling many queries against.
|
|
6
|
+
*/
|
|
7
|
+
export class Compiler {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Compile `document`, a stitched Ossie document as JSON.
|
|
12
|
+
*/
|
|
13
|
+
constructor(document: string);
|
|
14
|
+
/**
|
|
15
|
+
* The SQL for `query`, a `SemanticQuery` as JSON, in `dialect`
|
|
16
|
+
* (`ansi` or `bigquery`).
|
|
17
|
+
*/
|
|
18
|
+
sql(query: string, dialect: string): string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
22
|
+
|
|
23
|
+
export interface InitOutput {
|
|
24
|
+
readonly memory: WebAssembly.Memory;
|
|
25
|
+
readonly __wbg_compiler_free: (a: number, b: number) => void;
|
|
26
|
+
readonly compiler_new: (a: number, b: number) => [number, number, number];
|
|
27
|
+
readonly compiler_sql: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
28
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
29
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
30
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
31
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
32
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
33
|
+
readonly __wbindgen_start: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
40
|
+
* a precompiled `WebAssembly.Module`.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
43
|
+
*
|
|
44
|
+
* @returns {InitOutput}
|
|
45
|
+
*/
|
|
46
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
50
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
51
|
+
*
|
|
52
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
53
|
+
*
|
|
54
|
+
* @returns {Promise<InitOutput>}
|
|
55
|
+
*/
|
|
56
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/* @ts-self-types="./lovsem_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A semantic model compiled once, for compiling many queries against.
|
|
5
|
+
*/
|
|
6
|
+
export class Compiler {
|
|
7
|
+
__destroy_into_raw() {
|
|
8
|
+
const ptr = this.__wbg_ptr;
|
|
9
|
+
this.__wbg_ptr = 0;
|
|
10
|
+
CompilerFinalization.unregister(this);
|
|
11
|
+
return ptr;
|
|
12
|
+
}
|
|
13
|
+
free() {
|
|
14
|
+
const ptr = this.__destroy_into_raw();
|
|
15
|
+
wasm.__wbg_compiler_free(ptr, 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compile `document`, a stitched Ossie document as JSON.
|
|
19
|
+
* @param {string} document
|
|
20
|
+
*/
|
|
21
|
+
constructor(document) {
|
|
22
|
+
const ptr0 = passStringToWasm0(document, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
23
|
+
const len0 = WASM_VECTOR_LEN;
|
|
24
|
+
const ret = wasm.compiler_new(ptr0, len0);
|
|
25
|
+
if (ret[2]) {
|
|
26
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
27
|
+
}
|
|
28
|
+
this.__wbg_ptr = ret[0];
|
|
29
|
+
CompilerFinalization.register(this, this.__wbg_ptr, this);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The SQL for `query`, a `SemanticQuery` as JSON, in `dialect`
|
|
34
|
+
* (`ansi` or `bigquery`).
|
|
35
|
+
* @param {string} query
|
|
36
|
+
* @param {string} dialect
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
sql(query, dialect) {
|
|
40
|
+
let deferred4_0;
|
|
41
|
+
let deferred4_1;
|
|
42
|
+
try {
|
|
43
|
+
let ptr0, len0, ptr1, len1;
|
|
44
|
+
try {
|
|
45
|
+
ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
46
|
+
len0 = WASM_VECTOR_LEN;
|
|
47
|
+
ptr1 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
|
+
len1 = WASM_VECTOR_LEN;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
51
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
const ret = wasm.compiler_sql(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
55
|
+
var ptr3 = ret[0];
|
|
56
|
+
var len3 = ret[1];
|
|
57
|
+
if (ret[3]) {
|
|
58
|
+
ptr3 = 0; len3 = 0;
|
|
59
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
60
|
+
}
|
|
61
|
+
deferred4_0 = ptr3;
|
|
62
|
+
deferred4_1 = len3;
|
|
63
|
+
return getStringFromWasm0(ptr3, len3);
|
|
64
|
+
} finally {
|
|
65
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (Symbol.dispose) Compiler.prototype[Symbol.dispose] = Compiler.prototype.free;
|
|
70
|
+
function __wbg_get_imports() {
|
|
71
|
+
const import0 = {
|
|
72
|
+
__proto__: null,
|
|
73
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
74
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
75
|
+
return ret;
|
|
76
|
+
},
|
|
77
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
78
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
79
|
+
},
|
|
80
|
+
__wbindgen_init_externref_table: function() {
|
|
81
|
+
const table = wasm.__wbindgen_externrefs;
|
|
82
|
+
table.set(0, undefined);
|
|
83
|
+
table.set(1024, undefined);
|
|
84
|
+
table.set(1025, null);
|
|
85
|
+
table.set(1026, true);
|
|
86
|
+
table.set(1027, false);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
__proto__: null,
|
|
91
|
+
"./lovsem_wasm_bg.js": import0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const CompilerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
96
|
+
? { register: () => {}, unregister: () => {} }
|
|
97
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compiler_free(ptr, 1));
|
|
98
|
+
|
|
99
|
+
function getStringFromWasm0(ptr, len) {
|
|
100
|
+
ptr = ptr >>> 0;
|
|
101
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let cachedUint8ArrayMemory0 = null;
|
|
105
|
+
function getUint8ArrayMemory0() {
|
|
106
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
107
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
108
|
+
}
|
|
109
|
+
return cachedUint8ArrayMemory0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
113
|
+
if (realloc === undefined) {
|
|
114
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
115
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
116
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
117
|
+
WASM_VECTOR_LEN = buf.length;
|
|
118
|
+
return ptr;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let len = arg.length;
|
|
122
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
123
|
+
|
|
124
|
+
const mem = getUint8ArrayMemory0();
|
|
125
|
+
|
|
126
|
+
let offset = 0;
|
|
127
|
+
|
|
128
|
+
for (; offset < len; offset++) {
|
|
129
|
+
const code = arg.charCodeAt(offset);
|
|
130
|
+
if (code > 0x7F) break;
|
|
131
|
+
mem[ptr + offset] = code;
|
|
132
|
+
}
|
|
133
|
+
if (offset !== len) {
|
|
134
|
+
if (offset !== 0) {
|
|
135
|
+
arg = arg.slice(offset);
|
|
136
|
+
}
|
|
137
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
138
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
139
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
140
|
+
|
|
141
|
+
offset += ret.written;
|
|
142
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
WASM_VECTOR_LEN = offset;
|
|
146
|
+
return ptr;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function takeFromExternrefTable0(idx) {
|
|
150
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
151
|
+
wasm.__externref_table_dealloc(idx);
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
156
|
+
cachedTextDecoder.decode();
|
|
157
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
158
|
+
let numBytesDecoded = 0;
|
|
159
|
+
function decodeText(bytes) {
|
|
160
|
+
numBytesDecoded += bytes.length;
|
|
161
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
162
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
163
|
+
cachedTextDecoder.decode();
|
|
164
|
+
numBytesDecoded = bytes.length;
|
|
165
|
+
}
|
|
166
|
+
return cachedTextDecoder.decode(bytes);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const cachedTextEncoder = new TextEncoder();
|
|
170
|
+
|
|
171
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
172
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
173
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
174
|
+
view.set(buf);
|
|
175
|
+
return {
|
|
176
|
+
read: arg.length,
|
|
177
|
+
written: buf.length
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let WASM_VECTOR_LEN = 0;
|
|
183
|
+
|
|
184
|
+
let wasmModule, wasmInstance, wasm;
|
|
185
|
+
function __wbg_finalize_init(instance, module) {
|
|
186
|
+
wasmInstance = instance;
|
|
187
|
+
wasm = instance.exports;
|
|
188
|
+
wasmModule = module;
|
|
189
|
+
cachedUint8ArrayMemory0 = null;
|
|
190
|
+
wasm.__wbindgen_start();
|
|
191
|
+
return wasm;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function __wbg_load(module, imports) {
|
|
195
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
196
|
+
if (!module.ok) {
|
|
197
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
201
|
+
try {
|
|
202
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
203
|
+
} catch (e) {
|
|
204
|
+
const validResponse = expectedResponseType(module.type);
|
|
205
|
+
|
|
206
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
207
|
+
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);
|
|
208
|
+
|
|
209
|
+
} else { throw e; }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const bytes = await module.arrayBuffer();
|
|
214
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
215
|
+
} else {
|
|
216
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
217
|
+
|
|
218
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
219
|
+
return { instance, module };
|
|
220
|
+
} else {
|
|
221
|
+
return instance;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function expectedResponseType(type) {
|
|
226
|
+
switch (type) {
|
|
227
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function initSync(module) {
|
|
234
|
+
if (wasm !== undefined) return wasm;
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
if (module !== undefined) {
|
|
238
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
239
|
+
({module} = module)
|
|
240
|
+
} else {
|
|
241
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const imports = __wbg_get_imports();
|
|
246
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
247
|
+
module = new WebAssembly.Module(module);
|
|
248
|
+
}
|
|
249
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
250
|
+
return __wbg_finalize_init(instance, module);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let __wbg_init_promise;
|
|
254
|
+
async function __wbg_init(module_or_path) {
|
|
255
|
+
if (wasm !== undefined) return wasm;
|
|
256
|
+
if (__wbg_init_promise === undefined) {
|
|
257
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
258
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
259
|
+
}
|
|
260
|
+
return __wbg_init_promise;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function __wbg_init_once(module_or_path) {
|
|
264
|
+
|
|
265
|
+
if (module_or_path !== undefined) {
|
|
266
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
267
|
+
({module_or_path} = module_or_path)
|
|
268
|
+
} else {
|
|
269
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (module_or_path === undefined) {
|
|
274
|
+
module_or_path = new URL('lovsem_wasm_bg.wasm', import.meta.url);
|
|
275
|
+
}
|
|
276
|
+
const imports = __wbg_get_imports();
|
|
277
|
+
|
|
278
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
279
|
+
module_or_path = fetch(module_or_path);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
283
|
+
|
|
284
|
+
return __wbg_finalize_init(instance, module);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_compiler_free: (a: number, b: number) => void;
|
|
5
|
+
export const compiler_new: (a: number, b: number) => [number, number, number];
|
|
6
|
+
export const compiler_sql: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
7
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
8
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
9
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
12
|
+
export const __wbindgen_start: () => void;
|