@gdscript-analyzer/wasm 0.1.0

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.
@@ -0,0 +1,157 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A live, URI-keyed analysis session in the browser. Construct once with `new Analyzer()`, push
6
+ * documents with `openDocument`/`changeDocument`/`closeDocument` (+ `setProjectConfig`,
7
+ * `loadEngineApi`), then query. The Rust `AnalysisHost` (and its salsa cache) stays alive across
8
+ * edits. Single-threaded — wasm has one thread, so the held salsa state is never shared.
9
+ */
10
+ export class Analyzer {
11
+ free(): void;
12
+ [Symbol.dispose](): void;
13
+ /**
14
+ * Replace a document's text by `uri` (its `res://` path is unchanged).
15
+ */
16
+ changeDocument(uri: string, text: string): void;
17
+ /**
18
+ * Close (remove) a document by `uri`.
19
+ */
20
+ closeDocument(uri: string): void;
21
+ /**
22
+ * Code actions at a byte `offset` in `uri`, as a JSON array string.
23
+ */
24
+ codeActions(uri: string, offset: number): string;
25
+ /**
26
+ * Completions at a byte `offset` in `uri`, as a JSON array string.
27
+ */
28
+ completions(uri: string, offset: number): string;
29
+ /**
30
+ * Parse + type diagnostics for `uri`, as a JSON array string.
31
+ */
32
+ diagnostics(uri: string): string;
33
+ /**
34
+ * The document outline for `uri`, as a JSON array string.
35
+ */
36
+ documentSymbols(uri: string): string;
37
+ /**
38
+ * Every reference to the symbol at a byte `offset` in `uri`, as a JSON array string.
39
+ */
40
+ findReferences(uri: string, offset: number): string;
41
+ /**
42
+ * Foldable ranges for `uri`, as a JSON array string.
43
+ */
44
+ foldingRanges(uri: string): string;
45
+ /**
46
+ * Go-to-definition target(s) for the symbol at a byte `offset` in `uri`, as a JSON array string.
47
+ */
48
+ gotoDefinition(uri: string, offset: number): string;
49
+ /**
50
+ * Hover at a byte `offset` in `uri`; `undefined` when there is nothing typed there.
51
+ */
52
+ hover(uri: string, offset: number): string | undefined;
53
+ /**
54
+ * Inlay hints for `uri`, as a JSON array string.
55
+ */
56
+ inlayHints(uri: string): string;
57
+ /**
58
+ * Whether `uri` is currently open (distinguishes "not tracked" from a genuine empty result).
59
+ */
60
+ isOpen(uri: string): boolean;
61
+ /**
62
+ * Install a `fetch`ed `extension_api` blob (the engine model — not embedded on wasm). Returns
63
+ * `false` if the bytes fail to decode. Call once, before querying, so engine-class
64
+ * completion/hover work.
65
+ */
66
+ loadEngineApi(bytes: Uint8Array): boolean;
67
+ /**
68
+ * Create an empty analysis session.
69
+ */
70
+ constructor();
71
+ /**
72
+ * Open or replace a document by `uri`. Pass `resPath` (`res://…`) on first open to enable
73
+ * cross-file `preload` / `extends` / autoload resolution.
74
+ */
75
+ openDocument(uri: string, text: string, res_path?: string | null): void;
76
+ /**
77
+ * Rename the symbol at a byte `offset` in `uri` to `newName`. JSON object string:
78
+ * `{"ok": <SourceChange>}` | `{"error": <RenameError | reason>}`.
79
+ */
80
+ rename(uri: string, offset: number, new_name: string): string;
81
+ /**
82
+ * Set the project's `project.godot` text (enables `[autoload]` singleton resolution).
83
+ */
84
+ setProjectConfig(text: string): void;
85
+ /**
86
+ * Signature help at a byte `offset` in `uri`; `undefined` when not at a call site.
87
+ */
88
+ signatureHelp(uri: string, offset: number): string | undefined;
89
+ /**
90
+ * The pretty-printed syntax tree for `uri` (debugging); `undefined` for an unknown `uri`.
91
+ */
92
+ syntaxTree(uri: string): string | undefined;
93
+ /**
94
+ * Project-wide symbols matching `query`, as a JSON array string.
95
+ */
96
+ workspaceSymbols(query: string): string;
97
+ }
98
+
99
+ /**
100
+ * Install a panic hook that routes Rust panics to the browser console (dev aid).
101
+ */
102
+ export function start(): void;
103
+
104
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
105
+
106
+ export interface InitOutput {
107
+ readonly memory: WebAssembly.Memory;
108
+ readonly __wbg_analyzer_free: (a: number, b: number) => void;
109
+ readonly analyzer_changeDocument: (a: number, b: number, c: number, d: number, e: number) => void;
110
+ readonly analyzer_closeDocument: (a: number, b: number, c: number) => void;
111
+ readonly analyzer_codeActions: (a: number, b: number, c: number, d: number) => [number, number];
112
+ readonly analyzer_completions: (a: number, b: number, c: number, d: number) => [number, number];
113
+ readonly analyzer_diagnostics: (a: number, b: number, c: number) => [number, number];
114
+ readonly analyzer_documentSymbols: (a: number, b: number, c: number) => [number, number];
115
+ readonly analyzer_findReferences: (a: number, b: number, c: number, d: number) => [number, number];
116
+ readonly analyzer_foldingRanges: (a: number, b: number, c: number) => [number, number];
117
+ readonly analyzer_gotoDefinition: (a: number, b: number, c: number, d: number) => [number, number];
118
+ readonly analyzer_hover: (a: number, b: number, c: number, d: number) => [number, number];
119
+ readonly analyzer_inlayHints: (a: number, b: number, c: number) => [number, number];
120
+ readonly analyzer_isOpen: (a: number, b: number, c: number) => number;
121
+ readonly analyzer_loadEngineApi: (a: number, b: number, c: number) => number;
122
+ readonly analyzer_new: () => number;
123
+ readonly analyzer_openDocument: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
124
+ readonly analyzer_rename: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
125
+ readonly analyzer_setProjectConfig: (a: number, b: number, c: number) => void;
126
+ readonly analyzer_signatureHelp: (a: number, b: number, c: number, d: number) => [number, number];
127
+ readonly analyzer_syntaxTree: (a: number, b: number, c: number) => [number, number];
128
+ readonly analyzer_workspaceSymbols: (a: number, b: number, c: number) => [number, number];
129
+ readonly start: () => void;
130
+ readonly __wbindgen_free_command_export: (a: number, b: number, c: number) => void;
131
+ readonly __wbindgen_malloc_command_export: (a: number, b: number) => number;
132
+ readonly __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
133
+ readonly __wbindgen_externrefs: WebAssembly.Table;
134
+ readonly __wbindgen_start: () => void;
135
+ }
136
+
137
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
138
+
139
+ /**
140
+ * Instantiates the given `module`, which can either be bytes or
141
+ * a precompiled `WebAssembly.Module`.
142
+ *
143
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
144
+ *
145
+ * @returns {InitOutput}
146
+ */
147
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
148
+
149
+ /**
150
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
151
+ * for everything else, calls `WebAssembly.instantiate` directly.
152
+ *
153
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
154
+ *
155
+ * @returns {Promise<InitOutput>}
156
+ */
157
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,594 @@
1
+ /* @ts-self-types="./gdscript_wasm.d.ts" */
2
+
3
+ /**
4
+ * A live, URI-keyed analysis session in the browser. Construct once with `new Analyzer()`, push
5
+ * documents with `openDocument`/`changeDocument`/`closeDocument` (+ `setProjectConfig`,
6
+ * `loadEngineApi`), then query. The Rust `AnalysisHost` (and its salsa cache) stays alive across
7
+ * edits. Single-threaded — wasm has one thread, so the held salsa state is never shared.
8
+ */
9
+ export class Analyzer {
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ AnalyzerFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_analyzer_free(ptr, 0);
19
+ }
20
+ /**
21
+ * Replace a document's text by `uri` (its `res://` path is unchanged).
22
+ * @param {string} uri
23
+ * @param {string} text
24
+ */
25
+ changeDocument(uri, text) {
26
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
27
+ const len0 = WASM_VECTOR_LEN;
28
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
29
+ const len1 = WASM_VECTOR_LEN;
30
+ wasm.analyzer_changeDocument(this.__wbg_ptr, ptr0, len0, ptr1, len1);
31
+ }
32
+ /**
33
+ * Close (remove) a document by `uri`.
34
+ * @param {string} uri
35
+ */
36
+ closeDocument(uri) {
37
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ wasm.analyzer_closeDocument(this.__wbg_ptr, ptr0, len0);
40
+ }
41
+ /**
42
+ * Code actions at a byte `offset` in `uri`, as a JSON array string.
43
+ * @param {string} uri
44
+ * @param {number} offset
45
+ * @returns {string}
46
+ */
47
+ codeActions(uri, offset) {
48
+ let deferred2_0;
49
+ let deferred2_1;
50
+ try {
51
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
52
+ const len0 = WASM_VECTOR_LEN;
53
+ const ret = wasm.analyzer_codeActions(this.__wbg_ptr, ptr0, len0, offset);
54
+ deferred2_0 = ret[0];
55
+ deferred2_1 = ret[1];
56
+ return getStringFromWasm0(ret[0], ret[1]);
57
+ } finally {
58
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
59
+ }
60
+ }
61
+ /**
62
+ * Completions at a byte `offset` in `uri`, as a JSON array string.
63
+ * @param {string} uri
64
+ * @param {number} offset
65
+ * @returns {string}
66
+ */
67
+ completions(uri, offset) {
68
+ let deferred2_0;
69
+ let deferred2_1;
70
+ try {
71
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.analyzer_completions(this.__wbg_ptr, ptr0, len0, offset);
74
+ deferred2_0 = ret[0];
75
+ deferred2_1 = ret[1];
76
+ return getStringFromWasm0(ret[0], ret[1]);
77
+ } finally {
78
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
79
+ }
80
+ }
81
+ /**
82
+ * Parse + type diagnostics for `uri`, as a JSON array string.
83
+ * @param {string} uri
84
+ * @returns {string}
85
+ */
86
+ diagnostics(uri) {
87
+ let deferred2_0;
88
+ let deferred2_1;
89
+ try {
90
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ const ret = wasm.analyzer_diagnostics(this.__wbg_ptr, ptr0, len0);
93
+ deferred2_0 = ret[0];
94
+ deferred2_1 = ret[1];
95
+ return getStringFromWasm0(ret[0], ret[1]);
96
+ } finally {
97
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
98
+ }
99
+ }
100
+ /**
101
+ * The document outline for `uri`, as a JSON array string.
102
+ * @param {string} uri
103
+ * @returns {string}
104
+ */
105
+ documentSymbols(uri) {
106
+ let deferred2_0;
107
+ let deferred2_1;
108
+ try {
109
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.analyzer_documentSymbols(this.__wbg_ptr, ptr0, len0);
112
+ deferred2_0 = ret[0];
113
+ deferred2_1 = ret[1];
114
+ return getStringFromWasm0(ret[0], ret[1]);
115
+ } finally {
116
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
117
+ }
118
+ }
119
+ /**
120
+ * Every reference to the symbol at a byte `offset` in `uri`, as a JSON array string.
121
+ * @param {string} uri
122
+ * @param {number} offset
123
+ * @returns {string}
124
+ */
125
+ findReferences(uri, offset) {
126
+ let deferred2_0;
127
+ let deferred2_1;
128
+ try {
129
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
130
+ const len0 = WASM_VECTOR_LEN;
131
+ const ret = wasm.analyzer_findReferences(this.__wbg_ptr, ptr0, len0, offset);
132
+ deferred2_0 = ret[0];
133
+ deferred2_1 = ret[1];
134
+ return getStringFromWasm0(ret[0], ret[1]);
135
+ } finally {
136
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
137
+ }
138
+ }
139
+ /**
140
+ * Foldable ranges for `uri`, as a JSON array string.
141
+ * @param {string} uri
142
+ * @returns {string}
143
+ */
144
+ foldingRanges(uri) {
145
+ let deferred2_0;
146
+ let deferred2_1;
147
+ try {
148
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
149
+ const len0 = WASM_VECTOR_LEN;
150
+ const ret = wasm.analyzer_foldingRanges(this.__wbg_ptr, ptr0, len0);
151
+ deferred2_0 = ret[0];
152
+ deferred2_1 = ret[1];
153
+ return getStringFromWasm0(ret[0], ret[1]);
154
+ } finally {
155
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
156
+ }
157
+ }
158
+ /**
159
+ * Go-to-definition target(s) for the symbol at a byte `offset` in `uri`, as a JSON array string.
160
+ * @param {string} uri
161
+ * @param {number} offset
162
+ * @returns {string}
163
+ */
164
+ gotoDefinition(uri, offset) {
165
+ let deferred2_0;
166
+ let deferred2_1;
167
+ try {
168
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
169
+ const len0 = WASM_VECTOR_LEN;
170
+ const ret = wasm.analyzer_gotoDefinition(this.__wbg_ptr, ptr0, len0, offset);
171
+ deferred2_0 = ret[0];
172
+ deferred2_1 = ret[1];
173
+ return getStringFromWasm0(ret[0], ret[1]);
174
+ } finally {
175
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
176
+ }
177
+ }
178
+ /**
179
+ * Hover at a byte `offset` in `uri`; `undefined` when there is nothing typed there.
180
+ * @param {string} uri
181
+ * @param {number} offset
182
+ * @returns {string | undefined}
183
+ */
184
+ hover(uri, offset) {
185
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
186
+ const len0 = WASM_VECTOR_LEN;
187
+ const ret = wasm.analyzer_hover(this.__wbg_ptr, ptr0, len0, offset);
188
+ let v2;
189
+ if (ret[0] !== 0) {
190
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
191
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
192
+ }
193
+ return v2;
194
+ }
195
+ /**
196
+ * Inlay hints for `uri`, as a JSON array string.
197
+ * @param {string} uri
198
+ * @returns {string}
199
+ */
200
+ inlayHints(uri) {
201
+ let deferred2_0;
202
+ let deferred2_1;
203
+ try {
204
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
205
+ const len0 = WASM_VECTOR_LEN;
206
+ const ret = wasm.analyzer_inlayHints(this.__wbg_ptr, ptr0, len0);
207
+ deferred2_0 = ret[0];
208
+ deferred2_1 = ret[1];
209
+ return getStringFromWasm0(ret[0], ret[1]);
210
+ } finally {
211
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
212
+ }
213
+ }
214
+ /**
215
+ * Whether `uri` is currently open (distinguishes "not tracked" from a genuine empty result).
216
+ * @param {string} uri
217
+ * @returns {boolean}
218
+ */
219
+ isOpen(uri) {
220
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ const ret = wasm.analyzer_isOpen(this.__wbg_ptr, ptr0, len0);
223
+ return ret !== 0;
224
+ }
225
+ /**
226
+ * Install a `fetch`ed `extension_api` blob (the engine model — not embedded on wasm). Returns
227
+ * `false` if the bytes fail to decode. Call once, before querying, so engine-class
228
+ * completion/hover work.
229
+ * @param {Uint8Array} bytes
230
+ * @returns {boolean}
231
+ */
232
+ loadEngineApi(bytes) {
233
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc_command_export);
234
+ const len0 = WASM_VECTOR_LEN;
235
+ const ret = wasm.analyzer_loadEngineApi(this.__wbg_ptr, ptr0, len0);
236
+ return ret !== 0;
237
+ }
238
+ /**
239
+ * Create an empty analysis session.
240
+ */
241
+ constructor() {
242
+ const ret = wasm.analyzer_new();
243
+ this.__wbg_ptr = ret;
244
+ AnalyzerFinalization.register(this, this.__wbg_ptr, this);
245
+ return this;
246
+ }
247
+ /**
248
+ * Open or replace a document by `uri`. Pass `resPath` (`res://…`) on first open to enable
249
+ * cross-file `preload` / `extends` / autoload resolution.
250
+ * @param {string} uri
251
+ * @param {string} text
252
+ * @param {string | null} [res_path]
253
+ */
254
+ openDocument(uri, text, res_path) {
255
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
256
+ const len0 = WASM_VECTOR_LEN;
257
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
258
+ const len1 = WASM_VECTOR_LEN;
259
+ var ptr2 = isLikeNone(res_path) ? 0 : passStringToWasm0(res_path, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
260
+ var len2 = WASM_VECTOR_LEN;
261
+ wasm.analyzer_openDocument(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
262
+ }
263
+ /**
264
+ * Rename the symbol at a byte `offset` in `uri` to `newName`. JSON object string:
265
+ * `{"ok": <SourceChange>}` | `{"error": <RenameError | reason>}`.
266
+ * @param {string} uri
267
+ * @param {number} offset
268
+ * @param {string} new_name
269
+ * @returns {string}
270
+ */
271
+ rename(uri, offset, new_name) {
272
+ let deferred3_0;
273
+ let deferred3_1;
274
+ try {
275
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
276
+ const len0 = WASM_VECTOR_LEN;
277
+ const ptr1 = passStringToWasm0(new_name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
278
+ const len1 = WASM_VECTOR_LEN;
279
+ const ret = wasm.analyzer_rename(this.__wbg_ptr, ptr0, len0, offset, ptr1, len1);
280
+ deferred3_0 = ret[0];
281
+ deferred3_1 = ret[1];
282
+ return getStringFromWasm0(ret[0], ret[1]);
283
+ } finally {
284
+ wasm.__wbindgen_free_command_export(deferred3_0, deferred3_1, 1);
285
+ }
286
+ }
287
+ /**
288
+ * Set the project's `project.godot` text (enables `[autoload]` singleton resolution).
289
+ * @param {string} text
290
+ */
291
+ setProjectConfig(text) {
292
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
293
+ const len0 = WASM_VECTOR_LEN;
294
+ wasm.analyzer_setProjectConfig(this.__wbg_ptr, ptr0, len0);
295
+ }
296
+ /**
297
+ * Signature help at a byte `offset` in `uri`; `undefined` when not at a call site.
298
+ * @param {string} uri
299
+ * @param {number} offset
300
+ * @returns {string | undefined}
301
+ */
302
+ signatureHelp(uri, offset) {
303
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
304
+ const len0 = WASM_VECTOR_LEN;
305
+ const ret = wasm.analyzer_signatureHelp(this.__wbg_ptr, ptr0, len0, offset);
306
+ let v2;
307
+ if (ret[0] !== 0) {
308
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
309
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
310
+ }
311
+ return v2;
312
+ }
313
+ /**
314
+ * The pretty-printed syntax tree for `uri` (debugging); `undefined` for an unknown `uri`.
315
+ * @param {string} uri
316
+ * @returns {string | undefined}
317
+ */
318
+ syntaxTree(uri) {
319
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
320
+ const len0 = WASM_VECTOR_LEN;
321
+ const ret = wasm.analyzer_syntaxTree(this.__wbg_ptr, ptr0, len0);
322
+ let v2;
323
+ if (ret[0] !== 0) {
324
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
325
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
326
+ }
327
+ return v2;
328
+ }
329
+ /**
330
+ * Project-wide symbols matching `query`, as a JSON array string.
331
+ * @param {string} query
332
+ * @returns {string}
333
+ */
334
+ workspaceSymbols(query) {
335
+ let deferred2_0;
336
+ let deferred2_1;
337
+ try {
338
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ret = wasm.analyzer_workspaceSymbols(this.__wbg_ptr, ptr0, len0);
341
+ deferred2_0 = ret[0];
342
+ deferred2_1 = ret[1];
343
+ return getStringFromWasm0(ret[0], ret[1]);
344
+ } finally {
345
+ wasm.__wbindgen_free_command_export(deferred2_0, deferred2_1, 1);
346
+ }
347
+ }
348
+ }
349
+ if (Symbol.dispose) Analyzer.prototype[Symbol.dispose] = Analyzer.prototype.free;
350
+
351
+ /**
352
+ * Install a panic hook that routes Rust panics to the browser console (dev aid).
353
+ */
354
+ export function start() {
355
+ wasm.start();
356
+ }
357
+ function __wbg_get_imports() {
358
+ const import0 = {
359
+ __proto__: null,
360
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
361
+ throw new Error(getStringFromWasm0(arg0, arg1));
362
+ },
363
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
364
+ let deferred0_0;
365
+ let deferred0_1;
366
+ try {
367
+ deferred0_0 = arg0;
368
+ deferred0_1 = arg1;
369
+ console.error(getStringFromWasm0(arg0, arg1));
370
+ } finally {
371
+ wasm.__wbindgen_free_command_export(deferred0_0, deferred0_1, 1);
372
+ }
373
+ },
374
+ __wbg_new_227d7c05414eb861: function() {
375
+ const ret = new Error();
376
+ return ret;
377
+ },
378
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
379
+ const ret = arg1.stack;
380
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
381
+ const len1 = WASM_VECTOR_LEN;
382
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
383
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
384
+ },
385
+ __wbindgen_init_externref_table: function() {
386
+ const table = wasm.__wbindgen_externrefs;
387
+ const offset = table.grow(4);
388
+ table.set(0, undefined);
389
+ table.set(offset + 0, undefined);
390
+ table.set(offset + 1, null);
391
+ table.set(offset + 2, true);
392
+ table.set(offset + 3, false);
393
+ },
394
+ };
395
+ return {
396
+ __proto__: null,
397
+ "./gdscript_wasm_bg.js": import0,
398
+ };
399
+ }
400
+
401
+ const AnalyzerFinalization = (typeof FinalizationRegistry === 'undefined')
402
+ ? { register: () => {}, unregister: () => {} }
403
+ : new FinalizationRegistry(ptr => wasm.__wbg_analyzer_free(ptr, 1));
404
+
405
+ let cachedDataViewMemory0 = null;
406
+ function getDataViewMemory0() {
407
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
408
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
409
+ }
410
+ return cachedDataViewMemory0;
411
+ }
412
+
413
+ function getStringFromWasm0(ptr, len) {
414
+ return decodeText(ptr >>> 0, len);
415
+ }
416
+
417
+ let cachedUint8ArrayMemory0 = null;
418
+ function getUint8ArrayMemory0() {
419
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
420
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
421
+ }
422
+ return cachedUint8ArrayMemory0;
423
+ }
424
+
425
+ function isLikeNone(x) {
426
+ return x === undefined || x === null;
427
+ }
428
+
429
+ function passArray8ToWasm0(arg, malloc) {
430
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
431
+ getUint8ArrayMemory0().set(arg, ptr / 1);
432
+ WASM_VECTOR_LEN = arg.length;
433
+ return ptr;
434
+ }
435
+
436
+ function passStringToWasm0(arg, malloc, realloc) {
437
+ if (realloc === undefined) {
438
+ const buf = cachedTextEncoder.encode(arg);
439
+ const ptr = malloc(buf.length, 1) >>> 0;
440
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
441
+ WASM_VECTOR_LEN = buf.length;
442
+ return ptr;
443
+ }
444
+
445
+ let len = arg.length;
446
+ let ptr = malloc(len, 1) >>> 0;
447
+
448
+ const mem = getUint8ArrayMemory0();
449
+
450
+ let offset = 0;
451
+
452
+ for (; offset < len; offset++) {
453
+ const code = arg.charCodeAt(offset);
454
+ if (code > 0x7F) break;
455
+ mem[ptr + offset] = code;
456
+ }
457
+ if (offset !== len) {
458
+ if (offset !== 0) {
459
+ arg = arg.slice(offset);
460
+ }
461
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
462
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
463
+ const ret = cachedTextEncoder.encodeInto(arg, view);
464
+
465
+ offset += ret.written;
466
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
467
+ }
468
+
469
+ WASM_VECTOR_LEN = offset;
470
+ return ptr;
471
+ }
472
+
473
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
474
+ cachedTextDecoder.decode();
475
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
476
+ let numBytesDecoded = 0;
477
+ function decodeText(ptr, len) {
478
+ numBytesDecoded += len;
479
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
480
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
481
+ cachedTextDecoder.decode();
482
+ numBytesDecoded = len;
483
+ }
484
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
485
+ }
486
+
487
+ const cachedTextEncoder = new TextEncoder();
488
+
489
+ if (!('encodeInto' in cachedTextEncoder)) {
490
+ cachedTextEncoder.encodeInto = function (arg, view) {
491
+ const buf = cachedTextEncoder.encode(arg);
492
+ view.set(buf);
493
+ return {
494
+ read: arg.length,
495
+ written: buf.length
496
+ };
497
+ };
498
+ }
499
+
500
+ let WASM_VECTOR_LEN = 0;
501
+
502
+ let wasmModule, wasmInstance, wasm;
503
+ function __wbg_finalize_init(instance, module) {
504
+ wasmInstance = instance;
505
+ wasm = instance.exports;
506
+ wasmModule = module;
507
+ cachedDataViewMemory0 = null;
508
+ cachedUint8ArrayMemory0 = null;
509
+ wasm.__wbindgen_start();
510
+ return wasm;
511
+ }
512
+
513
+ async function __wbg_load(module, imports) {
514
+ if (typeof Response === 'function' && module instanceof Response) {
515
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
516
+ try {
517
+ return await WebAssembly.instantiateStreaming(module, imports);
518
+ } catch (e) {
519
+ const validResponse = module.ok && expectedResponseType(module.type);
520
+
521
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
522
+ 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);
523
+
524
+ } else { throw e; }
525
+ }
526
+ }
527
+
528
+ const bytes = await module.arrayBuffer();
529
+ return await WebAssembly.instantiate(bytes, imports);
530
+ } else {
531
+ const instance = await WebAssembly.instantiate(module, imports);
532
+
533
+ if (instance instanceof WebAssembly.Instance) {
534
+ return { instance, module };
535
+ } else {
536
+ return instance;
537
+ }
538
+ }
539
+
540
+ function expectedResponseType(type) {
541
+ switch (type) {
542
+ case 'basic': case 'cors': case 'default': return true;
543
+ }
544
+ return false;
545
+ }
546
+ }
547
+
548
+ function initSync(module) {
549
+ if (wasm !== undefined) return wasm;
550
+
551
+
552
+ if (module !== undefined) {
553
+ if (Object.getPrototypeOf(module) === Object.prototype) {
554
+ ({module} = module)
555
+ } else {
556
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
557
+ }
558
+ }
559
+
560
+ const imports = __wbg_get_imports();
561
+ if (!(module instanceof WebAssembly.Module)) {
562
+ module = new WebAssembly.Module(module);
563
+ }
564
+ const instance = new WebAssembly.Instance(module, imports);
565
+ return __wbg_finalize_init(instance, module);
566
+ }
567
+
568
+ async function __wbg_init(module_or_path) {
569
+ if (wasm !== undefined) return wasm;
570
+
571
+
572
+ if (module_or_path !== undefined) {
573
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
574
+ ({module_or_path} = module_or_path)
575
+ } else {
576
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
577
+ }
578
+ }
579
+
580
+ if (module_or_path === undefined) {
581
+ module_or_path = new URL('gdscript_wasm_bg.wasm', import.meta.url);
582
+ }
583
+ const imports = __wbg_get_imports();
584
+
585
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
586
+ module_or_path = fetch(module_or_path);
587
+ }
588
+
589
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
590
+
591
+ return __wbg_finalize_init(instance, module);
592
+ }
593
+
594
+ export { initSync, __wbg_init as default };
Binary file
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@gdscript-analyzer/wasm",
3
+ "type": "module",
4
+ "description": "wasm-bindgen browser binding (documented fallback to the napi-rs wasm target) for gdscript-analyzer.",
5
+ "version": "0.1.0",
6
+ "license": "MIT OR Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/yanivkalfa/gdscript-analyzer"
10
+ },
11
+ "files": [
12
+ "gdscript_wasm_bg.wasm",
13
+ "gdscript_wasm.js",
14
+ "gdscript_wasm.d.ts"
15
+ ],
16
+ "main": "gdscript_wasm.js",
17
+ "types": "gdscript_wasm.d.ts",
18
+ "sideEffects": [
19
+ "./snippets/*"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "provenance": true
24
+ }
25
+ }