@sanity-labs/groq-wasm 1.2.2 → 1.2.4

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.
@@ -1,571 +0,0 @@
1
- // src/types.ts
2
- function mapSeverity(wasmSeverity) {
3
- switch (wasmSeverity) {
4
- case "high":
5
- return "error";
6
- case "medium":
7
- return "warning";
8
- case "low":
9
- return "info";
10
- }
11
- }
12
- var WasmError = class extends Error {
13
- constructor(message, code) {
14
- super(message);
15
- this.code = code;
16
- this.name = "WasmError";
17
- }
18
- code;
19
- };
20
- var RULE_ID_MAP = {
21
- join_in_filter: "join-in-filter",
22
- join_to_get_id: "join-to-get-id",
23
- computed_value_in_filter: "computed-value-in-filter",
24
- match_on_id: "match-on-id",
25
- order_on_expr: "order-on-expr",
26
- deep_pagination: "deep-pagination",
27
- large_pages: "large-pages",
28
- non_literal_comparison: "non-literal-comparison",
29
- count_in_correlated_subquery: "count-in-correlated-subquery",
30
- very_large_query: "very-large-query",
31
- extremely_large_query: "extremely-large-query",
32
- many_joins: "many-joins",
33
- unlimited_query: "unlimited-query"
34
- };
35
- function mapRuleId(rustRuleId) {
36
- return RULE_ID_MAP[rustRuleId] ?? rustRuleId.replaceAll("_", "-");
37
- }
38
-
39
- // wasm/groq_wasm.js
40
- function extractParams(query) {
41
- let deferred3_0;
42
- let deferred3_1;
43
- try {
44
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
45
- const len0 = WASM_VECTOR_LEN;
46
- const ret = wasm.extractParams(ptr0, len0);
47
- var ptr2 = ret[0];
48
- var len2 = ret[1];
49
- if (ret[3]) {
50
- ptr2 = 0;
51
- len2 = 0;
52
- throw takeFromExternrefTable0(ret[2]);
53
- }
54
- deferred3_0 = ptr2;
55
- deferred3_1 = len2;
56
- return getStringFromWasm0(ptr2, len2);
57
- } finally {
58
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
59
- }
60
- }
61
- function format(query, width) {
62
- let deferred4_0;
63
- let deferred4_1;
64
- try {
65
- const val2 = +(isLikeNone(width) ? Number.MAX_SAFE_INTEGER : width >>> 0);
66
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
67
- const len0 = WASM_VECTOR_LEN;
68
- const ret = wasm.format(ptr0, len0, val2);
69
- var ptr3 = ret[0];
70
- var len3 = ret[1];
71
- if (ret[3]) {
72
- ptr3 = 0;
73
- len3 = 0;
74
- throw takeFromExternrefTable0(ret[2]);
75
- }
76
- deferred4_0 = ptr3;
77
- deferred4_1 = len3;
78
- return getStringFromWasm0(ptr3, len3);
79
- } finally {
80
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
81
- }
82
- }
83
- function lint(query) {
84
- let deferred3_0;
85
- let deferred3_1;
86
- try {
87
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
88
- const len0 = WASM_VECTOR_LEN;
89
- const ret = wasm.lint(ptr0, len0);
90
- var ptr2 = ret[0];
91
- var len2 = ret[1];
92
- if (ret[3]) {
93
- ptr2 = 0;
94
- len2 = 0;
95
- throw takeFromExternrefTable0(ret[2]);
96
- }
97
- deferred3_0 = ptr2;
98
- deferred3_1 = len2;
99
- return getStringFromWasm0(ptr2, len2);
100
- } finally {
101
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
102
- }
103
- }
104
- function validate(query) {
105
- let deferred2_0;
106
- let deferred2_1;
107
- try {
108
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
- const len0 = WASM_VECTOR_LEN;
110
- const ret = wasm.validate(ptr0, len0);
111
- deferred2_0 = ret[0];
112
- deferred2_1 = ret[1];
113
- return getStringFromWasm0(ret[0], ret[1]);
114
- } finally {
115
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
116
- }
117
- }
118
- function __wbg_get_imports() {
119
- const import0 = {
120
- __proto__: null,
121
- __wbg_error_757e9472f8410341: function(arg0, arg1) {
122
- let deferred0_0;
123
- let deferred0_1;
124
- try {
125
- deferred0_0 = arg0;
126
- deferred0_1 = arg1;
127
- console.error(getStringFromWasm0(arg0, arg1));
128
- } finally {
129
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
130
- }
131
- },
132
- __wbg_new_bb74001155cb8ca8: function() {
133
- const ret = new Error();
134
- return ret;
135
- },
136
- __wbg_stack_575c4e0918581b9c: function(arg0, arg1) {
137
- const ret = arg1.stack;
138
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
- const len1 = WASM_VECTOR_LEN;
140
- getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
141
- getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
142
- },
143
- __wbindgen_generic_0000000000000001: function(arg0, arg1) {
144
- const ret = getStringFromWasm0(arg0, arg1);
145
- return ret;
146
- },
147
- __wbindgen_init_externref_table: function() {
148
- const table = wasm.__wbindgen_externrefs;
149
- table.set(0, void 0);
150
- table.set(1024, void 0);
151
- table.set(1025, null);
152
- table.set(1026, true);
153
- table.set(1027, false);
154
- }
155
- };
156
- return {
157
- __proto__: null,
158
- "./groq_wasm_bg.js": import0
159
- };
160
- }
161
- var cachedDataViewMemory0 = null;
162
- function getDataViewMemory0() {
163
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
164
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
165
- }
166
- return cachedDataViewMemory0;
167
- }
168
- function getStringFromWasm0(ptr, len) {
169
- ptr = ptr >>> 0;
170
- return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
171
- }
172
- var cachedUint8ArrayMemory0 = null;
173
- function getUint8ArrayMemory0() {
174
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
175
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
176
- }
177
- return cachedUint8ArrayMemory0;
178
- }
179
- function isLikeNone(x) {
180
- return x === void 0 || x === null;
181
- }
182
- function passStringToWasm0(arg, malloc, realloc) {
183
- if (realloc === void 0) {
184
- const buf = cachedTextEncoder.encode(arg);
185
- const ptr2 = malloc(buf.length, 1) >>> 0;
186
- getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
187
- WASM_VECTOR_LEN = buf.length;
188
- return ptr2;
189
- }
190
- let len = arg.length;
191
- let ptr = malloc(len, 1) >>> 0;
192
- const mem = getUint8ArrayMemory0();
193
- let offset = 0;
194
- for (; offset < len; offset++) {
195
- const code = arg.charCodeAt(offset);
196
- if (code > 127) break;
197
- mem[ptr + offset] = code;
198
- }
199
- if (offset !== len) {
200
- if (offset !== 0) {
201
- arg = arg.slice(offset);
202
- }
203
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
204
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
205
- const ret = cachedTextEncoder.encodeInto(arg, view);
206
- offset += ret.written;
207
- ptr = realloc(ptr, len, offset, 1) >>> 0;
208
- }
209
- WASM_VECTOR_LEN = offset;
210
- return ptr;
211
- }
212
- function takeFromExternrefTable0(idx) {
213
- const value = wasm.__wbindgen_externrefs.get(idx);
214
- wasm.__externref_table_dealloc(idx);
215
- return value;
216
- }
217
- var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
218
- cachedTextDecoder.decode();
219
- var MAX_SAFARI_DECODE_BYTES = 2146435072;
220
- var numBytesDecoded = 0;
221
- function decodeText(bytes) {
222
- numBytesDecoded += bytes.length;
223
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
224
- cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
225
- cachedTextDecoder.decode();
226
- numBytesDecoded = bytes.length;
227
- }
228
- return cachedTextDecoder.decode(bytes);
229
- }
230
- var cachedTextEncoder = new TextEncoder();
231
- if (!("encodeInto" in cachedTextEncoder)) {
232
- cachedTextEncoder.encodeInto = function(arg, view) {
233
- const buf = cachedTextEncoder.encode(arg);
234
- view.set(buf);
235
- return {
236
- read: arg.length,
237
- written: buf.length
238
- };
239
- };
240
- }
241
- var WASM_VECTOR_LEN = 0;
242
- var wasmModule;
243
- var wasmInstance;
244
- var wasm;
245
- function __wbg_finalize_init(instance, module) {
246
- wasmInstance = instance;
247
- wasm = instance.exports;
248
- wasmModule = module;
249
- cachedDataViewMemory0 = null;
250
- cachedUint8ArrayMemory0 = null;
251
- wasm.__wbindgen_start();
252
- return wasm;
253
- }
254
- function initSync(module) {
255
- if (wasm !== void 0) return wasm;
256
- if (module !== void 0) {
257
- if (Object.getPrototypeOf(module) === Object.prototype) {
258
- ({ module } = module);
259
- } else {
260
- console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
261
- }
262
- }
263
- const imports = __wbg_get_imports();
264
- if (!(module instanceof WebAssembly.Module)) {
265
- module = new WebAssembly.Module(module);
266
- }
267
- const instance = new WebAssembly.Instance(module, imports);
268
- return __wbg_finalize_init(instance, module);
269
- }
270
-
271
- // src/wasm-loader.ts
272
- var NOT_INITIALIZED_MESSAGE = "GROQ WASM module is not initialized. Call load() or initWasm() before using this API.";
273
- var initialized = false;
274
- function isWasmInitialized() {
275
- return initialized;
276
- }
277
- function initWasm(source) {
278
- if (isResponse(source)) {
279
- return initFromResponse(source);
280
- }
281
- initFromCompiled(source);
282
- }
283
- function callLint(query) {
284
- assertInitialized();
285
- return lint(query);
286
- }
287
- function callExtractParams(query) {
288
- assertInitialized();
289
- return extractParams(query);
290
- }
291
- function callFormat(query, width) {
292
- assertInitialized();
293
- return format(query, width ?? null);
294
- }
295
- function callValidate(query) {
296
- assertInitialized();
297
- return validate(query);
298
- }
299
- function assertInitialized() {
300
- if (!initialized) {
301
- throw new WasmError(NOT_INITIALIZED_MESSAGE, "NOT_INITIALIZED");
302
- }
303
- }
304
- function isResponse(source) {
305
- return "arrayBuffer" in source && typeof source.arrayBuffer === "function";
306
- }
307
- function initFromCompiled(source) {
308
- if (initialized) {
309
- return;
310
- }
311
- try {
312
- initSync({ module: source });
313
- } catch (error) {
314
- throw new WasmError(
315
- `Failed to initialize WASM: ${error instanceof Error ? error.message : String(error)}`,
316
- "WASM_ERROR"
317
- );
318
- }
319
- initialized = true;
320
- }
321
- async function initFromResponse(response) {
322
- if (initialized) {
323
- return;
324
- }
325
- if (!response.ok) {
326
- const from = response.url ? ` from ${response.url}` : "";
327
- throw new WasmError(
328
- `Failed to read GROQ WASM module${from}: ${response.status} ${response.statusText}`,
329
- "WASM_ERROR"
330
- );
331
- }
332
- initFromCompiled(await response.arrayBuffer());
333
- }
334
-
335
- // src/offsets.ts
336
- function createUtf8OffsetMapper(text) {
337
- let index = 0;
338
- let bytes = 0;
339
- let line = 1;
340
- let column = 1;
341
- return (byteOffset) => {
342
- if (byteOffset < bytes) {
343
- index = 0;
344
- bytes = 0;
345
- line = 1;
346
- column = 1;
347
- }
348
- while (index < text.length && bytes < byteOffset) {
349
- const codePoint = text.codePointAt(index) ?? 0;
350
- const byteWidth = utf8ByteLength(codePoint);
351
- if (bytes + byteWidth > byteOffset) {
352
- break;
353
- }
354
- const utf16Width = codePoint > 65535 ? 2 : 1;
355
- bytes += byteWidth;
356
- index += utf16Width;
357
- if (codePoint === 10) {
358
- line += 1;
359
- column = 1;
360
- } else {
361
- column += utf16Width;
362
- }
363
- }
364
- return { index, line, column };
365
- };
366
- }
367
- function utf8ByteLength(codePoint) {
368
- if (codePoint <= 127) {
369
- return 1;
370
- }
371
- if (codePoint <= 2047) {
372
- return 2;
373
- }
374
- if (codePoint <= 65535) {
375
- return 3;
376
- }
377
- return 4;
378
- }
379
-
380
- // src/params.ts
381
- function extractParams2(query) {
382
- if (!query.trim()) {
383
- return [];
384
- }
385
- let resultJson;
386
- try {
387
- resultJson = callExtractParams(query);
388
- } catch (error) {
389
- if (error instanceof WasmError) {
390
- throw error;
391
- }
392
- const message = error instanceof Error ? error.message : String(error);
393
- if (message.includes("parse") || message.includes("Parse")) {
394
- throw new WasmError(`Failed to parse query: ${message}`, "PARSE_ERROR");
395
- }
396
- throw new WasmError(`Extract params failed: ${message}`, "WASM_ERROR");
397
- }
398
- const wasmReferences = JSON.parse(resultJson);
399
- const toPosition = createUtf8OffsetMapper(query);
400
- const params = /* @__PURE__ */ new Map();
401
- for (const reference of wasmReferences) {
402
- const start = toPosition(reference.start);
403
- const end = toPosition(reference.end);
404
- let param = params.get(reference.name);
405
- if (!param) {
406
- param = { name: reference.name, references: [] };
407
- params.set(reference.name, param);
408
- }
409
- param.references.push({
410
- start: start.index,
411
- end: end.index,
412
- line: start.line,
413
- column: start.column,
414
- endLine: end.line,
415
- endColumn: end.column
416
- });
417
- }
418
- return [...params.values()];
419
- }
420
-
421
- // src/lint.ts
422
- function lint2(query, config) {
423
- if (!query.trim()) {
424
- return [];
425
- }
426
- try {
427
- const resultJson = callLint(query);
428
- const wasmFindings = JSON.parse(resultJson);
429
- let findings = wasmFindings;
430
- if (config?.rules) {
431
- const rules = config.rules;
432
- findings = findings.filter((f) => {
433
- const enabled = rules[f.ruleId];
434
- return enabled !== false;
435
- });
436
- }
437
- return findings.map((wf) => convertFinding(wf, query));
438
- } catch (error) {
439
- if (error instanceof WasmError) {
440
- throw error;
441
- }
442
- const message = error instanceof Error ? error.message : String(error);
443
- if (message.includes("parse") || message.includes("Parse")) {
444
- throw new WasmError(`Failed to parse query: ${message}`, "PARSE_ERROR");
445
- }
446
- throw new WasmError(`Lint failed: ${message}`, "WASM_ERROR");
447
- }
448
- }
449
- function convertFinding(wf, query) {
450
- return {
451
- ruleId: mapRuleId(wf.ruleId),
452
- message: wf.message,
453
- severity: mapSeverity(wf.severity),
454
- span: byteSpanToSourceSpan(wf.start, wf.end, query)
455
- };
456
- }
457
- function byteSpanToSourceSpan(startByte, endByte, query) {
458
- const toPosition = createUtf8OffsetMapper(query);
459
- const start = toPosition(startByte);
460
- const end = toPosition(endByte);
461
- return {
462
- start: { line: start.line, column: start.column, offset: start.index },
463
- end: { line: end.line, column: end.column, offset: end.index }
464
- };
465
- }
466
-
467
- // src/format.ts
468
- var DEFAULT_WIDTH = 80;
469
- function format2(query, config) {
470
- const width = config?.width ?? DEFAULT_WIDTH;
471
- if (!query.trim()) {
472
- return query;
473
- }
474
- try {
475
- return callFormat(query, width);
476
- } catch (error) {
477
- if (error instanceof WasmError) {
478
- throw error;
479
- }
480
- const message = error instanceof Error ? error.message : String(error);
481
- if (message.includes("parse") || message.includes("Parse")) {
482
- throw new WasmError(`Failed to parse query: ${message}`, "PARSE_ERROR");
483
- }
484
- throw new WasmError(`Format failed: ${message}`, "WASM_ERROR");
485
- }
486
- }
487
- function isValidSyntax(query) {
488
- try {
489
- format2(query);
490
- return true;
491
- } catch (error) {
492
- if (error instanceof WasmError && error.code === "PARSE_ERROR") {
493
- return false;
494
- }
495
- throw error;
496
- }
497
- }
498
-
499
- // src/validate.ts
500
- function validate2(query) {
501
- let parsed;
502
- try {
503
- parsed = JSON.parse(callValidate(query));
504
- } catch (error) {
505
- if (error instanceof WasmError) {
506
- throw error;
507
- }
508
- const message = error instanceof Error ? error.message : String(error);
509
- throw new WasmError(`Validate failed: ${message}`, "WASM_ERROR");
510
- }
511
- const payload = readValidatePayload(parsed);
512
- switch (payload.ok) {
513
- case true:
514
- return { ok: true };
515
- case false:
516
- return { ok: false, error: toValidateError(query, payload) };
517
- default: {
518
- const unexpected = payload;
519
- throw new WasmError(`Unexpected validate result: ${JSON.stringify(unexpected)}`, "WASM_ERROR");
520
- }
521
- }
522
- }
523
- function readValidatePayload(value) {
524
- if (!isRecord(value)) {
525
- throw new WasmError("Validate returned an invalid payload", "WASM_ERROR");
526
- }
527
- const ok = value["ok"];
528
- if (ok === true) {
529
- return { ok: true };
530
- }
531
- const message = value["message"];
532
- const start = value["start"];
533
- const end = value["end"];
534
- if (ok === false && typeof message === "string" && typeof start === "number" && typeof end === "number") {
535
- return { ok: false, message, start, end };
536
- }
537
- throw new WasmError("Validate returned an invalid payload", "WASM_ERROR");
538
- }
539
- function toValidateError(query, failure) {
540
- const toPosition = createUtf8OffsetMapper(query);
541
- const start = toPosition(Math.max(0, failure.start));
542
- const end = toPosition(Math.max(failure.start, failure.end));
543
- return {
544
- message: failure.message,
545
- start: start.index,
546
- end: end.index,
547
- line: start.line,
548
- column: start.column,
549
- endLine: end.line,
550
- endColumn: end.column
551
- };
552
- }
553
- function isRecord(value) {
554
- return typeof value === "object" && value !== null;
555
- }
556
-
557
- export {
558
- mapSeverity,
559
- WasmError,
560
- RULE_ID_MAP,
561
- mapRuleId,
562
- isWasmInitialized,
563
- initWasm,
564
- extractParams2 as extractParams,
565
- lint2 as lint,
566
- DEFAULT_WIDTH,
567
- format2 as format,
568
- isValidSyntax,
569
- validate2 as validate
570
- };
571
- //# sourceMappingURL=chunk-ZSHLLLLH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts","../wasm/groq_wasm.js","../src/wasm-loader.ts","../src/offsets.ts","../src/params.ts","../src/lint.ts","../src/format.ts","../src/validate.ts"],"sourcesContent":["/**\n * Types for @sanity-labs/groq-wasm\n *\n * These types match the Rust API from groq-lint and groq-format,\n * converted to TypeScript conventions (snake_case → camelCase).\n */\n\n/**\n * Severity levels matching Rust groq-lint\n * Rust: High, Medium, Low → TS: error, warning, info\n */\nexport type WasmSeverity = 'high' | 'medium' | 'low'\n\n/**\n * Map WASM severity to our standard severity\n */\nexport function mapSeverity(wasmSeverity: WasmSeverity): 'error' | 'warning' | 'info' {\n switch (wasmSeverity) {\n case 'high':\n return 'error'\n case 'medium':\n return 'warning'\n case 'low':\n return 'info'\n }\n}\n\n/**\n * A finding from the Rust linter (JSON format from WASM)\n */\nexport interface WasmFinding {\n /** Rule ID (snake_case from Rust) */\n ruleId: string\n /** Human-readable message */\n message: string\n /** Severity level */\n severity: WasmSeverity\n /** Start offset into the UTF-8 encoding of the query (0-based) */\n start: number\n /** End offset into the UTF-8 encoding of the query (0-based, exclusive) */\n end: number\n}\n\n/**\n * Configuration for linting\n */\nexport interface WasmLintConfig {\n /** Rules to enable/disable (rule_id → enabled) */\n rules?: Record<string, boolean>\n}\n\n/**\n * Configuration for formatting\n */\nexport interface WasmFormatConfig {\n /** Maximum line width (default: 80) */\n width?: number\n}\n\n/**\n * A parameter reference from the Rust parser (JSON format from WASM)\n */\nexport interface WasmParamReference {\n /** Parameter name without the `$` */\n name: string\n /** Start byte offset of the `$` (0-based, UTF-8) */\n start: number\n /** End byte offset, exclusive (0-based, UTF-8) */\n end: number\n}\n\n/**\n * One `$name` reference in a query, from {@link extractParams}.\n *\n * `start` and `end` are indices into the JavaScript query string (UTF-16 code\n * units), not UTF-8 byte offsets. `start` is inclusive and `end` is exclusive,\n * so `query.slice(start, end)` is `\"$name\"`. Lines and columns are 1-based,\n * and columns count UTF-16 code units, matching `SourceLocation` on lint\n * findings.\n */\nexport interface ParamReference {\n /** Inclusive start index of the `$`, 0-based UTF-16 code units. */\n start: number\n /** Exclusive end index, 0-based UTF-16 code units. */\n end: number\n /** 1-based line number of `start`. */\n line: number\n /** 1-based column of `start`, counted in UTF-16 code units. */\n column: number\n /** 1-based line number of `end`. */\n endLine: number\n /** 1-based column of `end`, counted in UTF-16 code units. */\n endColumn: number\n}\n\n/**\n * A query parameter referenced by a GROQ query, from {@link extractParams}.\n */\nexport interface QueryParam {\n /** Parameter name without the `$`, e.g. `\"type\"` for `$type`. */\n name: string\n /** Every reference to this parameter, in source order. Never empty. */\n references: Array<ParamReference>\n}\n\n/**\n * Error from WASM operations\n */\nexport class WasmError extends Error {\n constructor(\n message: string,\n public readonly code: 'PARSE_ERROR' | 'WASM_ERROR' | 'NOT_INITIALIZED'\n ) {\n super(message)\n this.name = 'WasmError'\n }\n}\n\n/**\n * Rule ID mapping from Rust (snake_case) to TS (kebab-case)\n */\n// oxlint-disable-next-line quality/no-known-value-widening -- documented public contract; looked up by arbitrary Rust rule IDs\nexport const RULE_ID_MAP: Record<string, string> = {\n join_in_filter: 'join-in-filter',\n join_to_get_id: 'join-to-get-id',\n computed_value_in_filter: 'computed-value-in-filter',\n match_on_id: 'match-on-id',\n order_on_expr: 'order-on-expr',\n deep_pagination: 'deep-pagination',\n large_pages: 'large-pages',\n non_literal_comparison: 'non-literal-comparison',\n count_in_correlated_subquery: 'count-in-correlated-subquery',\n very_large_query: 'very-large-query',\n extremely_large_query: 'extremely-large-query',\n many_joins: 'many-joins',\n unlimited_query: 'unlimited-query',\n}\n\n/**\n * Convert Rust rule ID to TS convention\n */\nexport function mapRuleId(rustRuleId: string): string {\n return RULE_ID_MAP[rustRuleId] ?? rustRuleId.replaceAll('_', '-')\n}\n\n/**\n * A GROQ syntax error from `validate`.\n *\n * `start` and `end` are indices into the JavaScript query string (UTF-16 code\n * units), not UTF-8 byte offsets. `start` is inclusive and `end` is exclusive,\n * so `query.slice(start, end)` is the reported span. groq-parser reports UTF-8\n * byte offsets; `validate` converts them. A zero-width span (`start === end`)\n * is a caret on a token boundary.\n *\n * `line` / `column` locate `start`, and `endLine` / `endColumn` locate `end`.\n * Lines and columns are 1-based. Columns count UTF-16 code units, matching\n * `SourceLocation` on lint findings.\n */\nexport interface ValidateError {\n /** Parser message, without a serialized position suffix. */\n message: string\n /** Inclusive start index, 0-based UTF-16 code units. */\n start: number\n /** Exclusive end index, 0-based UTF-16 code units. */\n end: number\n /** 1-based line number of `start`. */\n line: number\n /** 1-based column of `start`, counted in UTF-16 code units. */\n column: number\n /** 1-based line number of `end`. */\n endLine: number\n /** 1-based column of `end`, counted in UTF-16 code units. */\n endColumn: number\n}\n\n/**\n * Result of {@link validate}.\n *\n * Syntax errors are values, not thrown exceptions. `lint` and `format` still\n * throw {@link WasmError} when a query does not parse.\n */\nexport type ValidateResult = { ok: true } | { ok: false; error: ValidateError }\n","/* @ts-self-types=\"./groq_wasm.d.ts\" */\n\n/**\n * List every query parameter a GROQ query references, as JSON.\n *\n * Returns one entry per reference, ordered by `start`. Byte offsets are\n * UTF-8 offsets into `query`; the JavaScript wrapper converts them to UTF-16\n * code unit indices. Parameters bound by a custom function (`fn ns::f($p)`)\n * are omitted inside that function's body.\n * @param {string} query\n * @returns {string}\n */\nexport function extractParams(query) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.extractParams(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Format a GROQ query.\n *\n * # Arguments\n * * `query` - The GROQ query string to format\n * * `width` - Maximum line width (default: 80)\n *\n * # Returns\n * The formatted query string\n * @param {string} query\n * @param {number | null} [width]\n * @returns {string}\n */\nexport function format(query, width) {\n let deferred4_0;\n let deferred4_1;\n try {\n const val2 = +(isLikeNone(width) ? Number.MAX_SAFE_INTEGER : (width) >>> 0);\n const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.format(ptr0, len0, val2);\n var ptr3 = ret[0];\n var len3 = ret[1];\n if (ret[3]) {\n ptr3 = 0; len3 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred4_0 = ptr3;\n deferred4_1 = len3;\n return getStringFromWasm0(ptr3, len3);\n } finally {\n wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);\n }\n}\n\nexport function init() {\n wasm.init();\n}\n\n/**\n * Lint a GROQ query and return findings as JSON.\n *\n * # Arguments\n * * `query` - The GROQ query string to lint\n *\n * # Returns\n * A JSON string containing an array of findings\n * @param {string} query\n * @returns {string}\n */\nexport function lint(query) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.lint(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Parse a GROQ query and return a JSON validation result.\n *\n * Byte offsets in the JSON are UTF-8 offsets into `query`. The JavaScript\n * wrapper converts them to UTF-16 code unit indices.\n *\n * Success is `{\"ok\":true}`. A syntax error is\n * `{\"ok\":false,\"message\":\"...\",\"start\":N,\"end\":M}` where `start` is inclusive,\n * `end` is exclusive, and the two are equal when the parser reports a caret\n * rather than a token span.\n * @param {string} query\n * @returns {string}\n */\nexport function validate(query) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.validate(ptr0, len0);\n deferred2_0 = ret[0];\n deferred2_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n}\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_error_757e9472f8410341: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_new_bb74001155cb8ca8: function() {\n const ret = new Error();\n return ret;\n },\n __wbg_stack_575c4e0918581b9c: function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);\n getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);\n },\n __wbindgen_generic_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n table.set(0, undefined);\n table.set(1024, undefined);\n table.set(1025, null);\n table.set(1026, true);\n table.set(1027, false);\n },\n };\n return {\n __proto__: null,\n \"./groq_wasm_bg.js\": import0,\n };\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(bytes) {\n numBytesDecoded += bytes.length;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });\n cachedTextDecoder.decode();\n numBytesDecoded = bytes.length;\n }\n return cachedTextDecoder.decode(bytes);\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasmInstance, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasmInstance = instance;\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (!module.ok) {\n throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);\n }\n\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n 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);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nlet __wbg_init_promise;\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n if (__wbg_init_promise === undefined) {\n __wbg_init_promise = __wbg_init_once(module_or_path);\n __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });\n }\n return __wbg_init_promise;\n}\n\nasync function __wbg_init_once(module_or_path) {\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('groq_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","/**\n * WASM module runtime.\n *\n * Exposes the WASM-backed lint/format/validate calls and init helpers.\n * Byte loading is platform-specific:\n * - `index.ts` reads the file and calls `initWasm` synchronously (Node).\n * - `index.browser.ts` fetches it with top-level await (browser).\n * - `index.lazy.ts` does neither until `load()` or `initWasm()`.\n */\n\nimport {\n extractParams as wasmExtractParams,\n format as wasmFormat,\n initSync,\n lint as wasmLint,\n validate as wasmValidate,\n} from '../wasm/groq_wasm.js'\n\nimport { WasmError } from './types.js'\n\n/**\n * Bytes, a compiled module, or a fetch `Response` accepted by {@link initWasm}.\n * A `Response` initializes asynchronously. The other forms are synchronous.\n */\nexport type WasmInitSource = ArrayBuffer | Uint8Array | WebAssembly.Module | Response\n\nconst NOT_INITIALIZED_MESSAGE =\n 'GROQ WASM module is not initialized. Call load() or initWasm() before using this API.'\n\nlet initialized = false\n\nexport function isWasmInitialized(): boolean {\n return initialized\n}\n\n/**\n * Initialize the GROQ WebAssembly module.\n *\n * `ArrayBuffer`, `Uint8Array`, and `WebAssembly.Module` initialize\n * synchronously and this function returns `void`. A `Response` is consumed\n * asynchronously and this function returns a promise. `await initWasm(source)`\n * is valid for every accepted source. A second successful call does nothing.\n *\n * @throws {WasmError} With code `WASM_ERROR` when the bytes cannot be\n * instantiated, or when the module is not initialized yet and `source` is a\n * `Response` that is not ok.\n */\nexport function initWasm(source: Response): Promise<void>\nexport function initWasm(source: ArrayBuffer | Uint8Array | WebAssembly.Module): void\nexport function initWasm(source: WasmInitSource): void | Promise<void> {\n if (isResponse(source)) {\n return initFromResponse(source)\n }\n initFromCompiled(source)\n}\n\nexport function callLint(query: string): string {\n assertInitialized()\n return wasmLint(query)\n}\n\nexport function callExtractParams(query: string): string {\n assertInitialized()\n return wasmExtractParams(query)\n}\n\nexport function callFormat(query: string, width?: number): string {\n assertInitialized()\n return wasmFormat(query, width ?? null)\n}\n\nexport function callValidate(query: string): string {\n assertInitialized()\n return wasmValidate(query)\n}\n\nfunction assertInitialized(): void {\n if (!initialized) {\n throw new WasmError(NOT_INITIALIZED_MESSAGE, 'NOT_INITIALIZED')\n }\n}\n\nfunction isResponse(source: WasmInitSource): source is Response {\n return 'arrayBuffer' in source && typeof source.arrayBuffer === 'function'\n}\n\nfunction initFromCompiled(source: ArrayBuffer | Uint8Array | WebAssembly.Module): void {\n if (initialized) {\n return\n }\n\n try {\n initSync({ module: source })\n } catch (error) {\n throw new WasmError(\n `Failed to initialize WASM: ${error instanceof Error ? error.message : String(error)}`,\n 'WASM_ERROR'\n )\n }\n\n initialized = true\n}\n\nasync function initFromResponse(response: Response): Promise<void> {\n if (initialized) {\n return\n }\n\n if (!response.ok) {\n const from = response.url ? ` from ${response.url}` : ''\n throw new WasmError(\n `Failed to read GROQ WASM module${from}: ${response.status} ${response.statusText}`,\n 'WASM_ERROR'\n )\n }\n\n initFromCompiled(await response.arrayBuffer())\n}\n","/**\n * Conversion from groq-parser's UTF-8 byte offsets to JavaScript string\n * coordinates.\n *\n * wasm-bindgen passes the query to Rust with `TextEncoder`, so parser spans\n * are byte offsets into the query's UTF-8 encoding. JavaScript strings are\n * UTF-16, so those offsets stop matching string indices once the query\n * contains non-ASCII text.\n */\n\n/** A position in a JavaScript string. */\nexport interface TextPosition {\n /** 0-based UTF-16 code unit index. */\n index: number\n /** 1-based line. Advances on `\\n`. */\n line: number\n /** 1-based column, counted in UTF-16 code units. */\n column: number\n}\n\n/**\n * Create a function that maps UTF-8 byte offsets in `text` to\n * {@link TextPosition}s.\n *\n * The mapper resumes from the previous result, so calling it with ascending\n * offsets walks `text` once. A smaller offset restarts from the beginning.\n * An offset inside a code point resolves to the start of that code point, and\n * an offset past the end resolves to the end of `text`.\n */\nexport function createUtf8OffsetMapper(text: string): (byteOffset: number) => TextPosition {\n let index = 0\n let bytes = 0\n let line = 1\n let column = 1\n\n return (byteOffset) => {\n if (byteOffset < bytes) {\n index = 0\n bytes = 0\n line = 1\n column = 1\n }\n\n while (index < text.length && bytes < byteOffset) {\n const codePoint = text.codePointAt(index) ?? 0\n const byteWidth = utf8ByteLength(codePoint)\n if (bytes + byteWidth > byteOffset) {\n break\n }\n\n const utf16Width = codePoint > 0xff_ff ? 2 : 1\n bytes += byteWidth\n index += utf16Width\n\n if (codePoint === 0x0a) {\n line += 1\n column = 1\n } else {\n column += utf16Width\n }\n }\n\n return { index, line, column }\n }\n}\n\n/**\n * UTF-8 byte length of one code point, matching `TextEncoder`.\n *\n * Unpaired surrogates fall in the 3-byte range. `TextEncoder` replaces each\n * of them with U+FFFD, which is also 3 bytes.\n */\nfunction utf8ByteLength(codePoint: number): number {\n if (codePoint <= 0x7f) {\n return 1\n }\n if (codePoint <= 0x7_ff) {\n return 2\n }\n if (codePoint <= 0xff_ff) {\n return 3\n }\n return 4\n}\n","/**\n * GROQ query parameter extraction via WASM.\n *\n * Wraps groq-parser's `ParseResult::referenced_params`. The parser reports\n * UTF-8 byte offsets; this module converts them to UTF-16 code unit indices.\n */\n\nimport { createUtf8OffsetMapper } from './offsets.js'\nimport { WasmError, type QueryParam, type WasmParamReference } from './types.js'\nimport { callExtractParams } from './wasm-loader.js'\n\n/**\n * List the query parameters (`$name`) a GROQ query references.\n *\n * Returns one entry per distinct name, in order of first reference. Each entry\n * lists every reference to that name in source order. Names do not include\n * the `$`, so they match the keys of the params object passed to a client.\n *\n * Parameters bound by a custom function (`fn ns::f($p) = ...`) are local to\n * that function's body and are not reported from inside it. `$name` text\n * inside string literals and comments is not a reference.\n *\n * Reference `start` / `end` are 0-based UTF-16 code unit indices into\n * `query` (`end` is exclusive), so `query.slice(start, end)` is `\"$name\"`.\n *\n * An empty or whitespace-only query returns `[]`, like `lint('')`.\n *\n * @param query - The GROQ query string\n * @returns Referenced parameters, in order of first reference\n * @throws {WasmError} With code `PARSE_ERROR` if the query does not parse\n *\n * @example\n * ```typescript\n * import {extractParams} from '@sanity-labs/groq-wasm'\n *\n * extractParams('*[_type == $type][0...$limit]').map((param) => param.name)\n * // ['type', 'limit']\n * ```\n */\nexport function extractParams(query: string): Array<QueryParam> {\n if (!query.trim()) {\n return []\n }\n\n let resultJson: string\n try {\n resultJson = callExtractParams(query)\n } catch (error) {\n if (error instanceof WasmError) {\n throw error\n }\n\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('parse') || message.includes('Parse')) {\n throw new WasmError(`Failed to parse query: ${message}`, 'PARSE_ERROR')\n }\n\n throw new WasmError(`Extract params failed: ${message}`, 'WASM_ERROR')\n }\n\n const wasmReferences: Array<WasmParamReference> = JSON.parse(resultJson)\n const toPosition = createUtf8OffsetMapper(query)\n const params = new Map<string, QueryParam>()\n\n for (const reference of wasmReferences) {\n const start = toPosition(reference.start)\n const end = toPosition(reference.end)\n\n let param = params.get(reference.name)\n if (!param) {\n param = { name: reference.name, references: [] }\n params.set(reference.name, param)\n }\n\n param.references.push({\n start: start.index,\n end: end.index,\n line: start.line,\n column: start.column,\n endLine: end.line,\n endColumn: end.column,\n })\n }\n\n return [...params.values()]\n}\n","/**\n * GROQ Linting via WASM\n *\n * Wraps the Rust groq-lint library compiled to WASM.\n */\n\nimport type { Finding, SourceSpan } from '@sanity-labs/lint-core'\n\nimport { createUtf8OffsetMapper } from './offsets.js'\nimport {\n mapRuleId,\n mapSeverity,\n WasmError,\n type WasmFinding,\n type WasmLintConfig,\n} from './types.js'\nimport { callLint } from './wasm-loader.js'\n\n/**\n * Lint a GROQ query using the WASM-based linter.\n *\n * Finding spans are source locations in JavaScript string coordinates.\n * The Rust linter reports UTF-8 byte offsets; `line`, `column`, and `offset`\n * below are converted from those bytes. `column` counts UTF-16 code units.\n *\n * @param query - The GROQ query string to lint\n * @param config - Optional configuration\n * @returns Array of findings\n * @throws {WasmError} If query parsing fails\n *\n * @example\n * ```typescript\n * import {lint} from '@sanity-labs/groq-wasm'\n *\n * const findings = lint('*[_type == \"post\"]{ author-> }')\n * // [{ ruleId: 'join-in-filter', message: '...', severity: 'error' }]\n * ```\n */\nexport function lint(query: string, config?: WasmLintConfig): Array<Finding> {\n if (!query.trim()) {\n return []\n }\n\n try {\n // Call WASM function - returns JSON string\n const resultJson = callLint(query)\n const wasmFindings: Array<WasmFinding> = JSON.parse(resultJson)\n\n // Filter by config if provided\n let findings = wasmFindings\n if (config?.rules) {\n const rules = config.rules\n findings = findings.filter((f) => {\n const enabled = rules[f.ruleId]\n return enabled !== false\n })\n }\n\n // Convert to our Finding type\n return findings.map((wf) => convertFinding(wf, query))\n } catch (error) {\n if (error instanceof WasmError) {\n throw error\n }\n\n // Parse errors from WASM come as thrown strings/errors\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('parse') || message.includes('Parse')) {\n throw new WasmError(`Failed to parse query: ${message}`, 'PARSE_ERROR')\n }\n\n throw new WasmError(`Lint failed: ${message}`, 'WASM_ERROR')\n }\n}\n\n/**\n * Convert WASM finding to our Finding type\n */\nfunction convertFinding(wf: WasmFinding, query: string): Finding {\n return {\n ruleId: mapRuleId(wf.ruleId),\n message: wf.message,\n severity: mapSeverity(wf.severity),\n span: byteSpanToSourceSpan(wf.start, wf.end, query),\n }\n}\n\n/**\n * Convert UTF-8 byte offsets to a line/column source span.\n *\n * `column` is a 1-based count of UTF-16 code units and `offset` is the\n * matching JavaScript string index. See {@link createUtf8OffsetMapper}.\n */\nfunction byteSpanToSourceSpan(startByte: number, endByte: number, query: string): SourceSpan {\n const toPosition = createUtf8OffsetMapper(query)\n const start = toPosition(startByte)\n const end = toPosition(endByte)\n return {\n start: { line: start.line, column: start.column, offset: start.index },\n end: { line: end.line, column: end.column, offset: end.index },\n }\n}\n","/**\n * GROQ Formatting via WASM\n *\n * Wraps the Rust groq-format library compiled to WASM.\n */\n\nimport { WasmError, type WasmFormatConfig } from './types.js'\nimport { callFormat } from './wasm-loader.js'\n\n/**\n * Default line width for formatting\n * Matches Rust groq-format DEFAULT_WIDTH\n */\nexport const DEFAULT_WIDTH = 80\n\n/**\n * Format a GROQ query using the WASM-based formatter\n *\n * @param query - The GROQ query string to format\n * @param config - Optional configuration (width defaults to 80)\n * @returns Formatted query string\n * @throws {WasmError} If query parsing fails\n *\n * @example\n * ```typescript\n * import {format} from '@sanity-labs/groq-wasm'\n *\n * const formatted = format('*[_type==\"post\"]{title,body}')\n * // '*[_type == \"post\"]{ title, body }'\n * ```\n */\nexport function format(query: string, config?: WasmFormatConfig): string {\n const width = config?.width ?? DEFAULT_WIDTH\n\n if (!query.trim()) {\n return query\n }\n\n try {\n return callFormat(query, width)\n } catch (error) {\n if (error instanceof WasmError) {\n throw error\n }\n\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('parse') || message.includes('Parse')) {\n throw new WasmError(`Failed to parse query: ${message}`, 'PARSE_ERROR')\n }\n\n throw new WasmError(`Format failed: ${message}`, 'WASM_ERROR')\n }\n}\n\n/**\n * Check if a query can be parsed (without full formatting)\n *\n * @param query - The GROQ query to validate\n * @returns true if the query is valid GROQ syntax\n */\nexport function isValidSyntax(query: string): boolean {\n try {\n format(query)\n return true\n } catch (error) {\n if (error instanceof WasmError && error.code === 'PARSE_ERROR') {\n return false\n }\n throw error\n }\n}\n","/**\n * GROQ syntax validation via WASM.\n *\n * Wraps groq-parser's structured parse errors. The parser reports UTF-8 byte\n * offsets; this module converts them to UTF-16 code unit indices.\n */\n\nimport { createUtf8OffsetMapper } from './offsets.js'\nimport { WasmError, type ValidateError, type ValidateResult } from './types.js'\nimport { callValidate } from './wasm-loader.js'\n\n/**\n * Parse a GROQ query.\n *\n * Returns `{ok: true}` when the query parses. Syntax errors are returned as\n * `{ok: false, error}` and are not thrown. `lint` and `format` still throw\n * {@link WasmError} on invalid syntax; this function does not change that.\n *\n * `error.start` and `error.end` are 0-based UTF-16 code unit indices into\n * `query` (`end` is exclusive), which is what JavaScript strings and editors\n * such as Vision use. groq-parser's `ParseError` positions are UTF-8 byte\n * offsets (`Position.start` / `Position.end` in groq-parser-rs). An empty or\n * whitespace-only query is a syntax error (`\"no query\"`) at offset 0, unlike\n * `lint('')` and `format('')`, which treat it as nothing to do.\n *\n * `line` / `column` locate `start`, and `endLine` / `endColumn` locate `end`.\n * They are 1-based. Columns count UTF-16 code units, matching `SourceLocation`\n * on lint findings.\n *\n * Parameter references (`$name`) are accepted. This is a syntax check and does\n * not require the parameters to be declared.\n *\n * @example\n * ```typescript\n * import {validate} from '@sanity-labs/groq-wasm'\n *\n * validate('*[_type == \"post\"]')\n * // {ok: true}\n *\n * validate('*[\"é\" == ]')\n * // {\n * // ok: false,\n * // error: {\n * // message: 'unexpected token \"]\", expected expression',\n * // start: 9,\n * // end: 10,\n * // line: 1,\n * // column: 10,\n * // endLine: 1,\n * // endColumn: 11,\n * // },\n * // }\n * ```\n */\nexport function validate(query: string): ValidateResult {\n let parsed: unknown\n try {\n parsed = JSON.parse(callValidate(query))\n } catch (error) {\n if (error instanceof WasmError) {\n throw error\n }\n\n const message = error instanceof Error ? error.message : String(error)\n throw new WasmError(`Validate failed: ${message}`, 'WASM_ERROR')\n }\n\n const payload = readValidatePayload(parsed)\n switch (payload.ok) {\n case true:\n return { ok: true }\n case false:\n return { ok: false, error: toValidateError(query, payload) }\n default: {\n const unexpected: never = payload\n throw new WasmError(`Unexpected validate result: ${JSON.stringify(unexpected)}`, 'WASM_ERROR')\n }\n }\n}\n\ninterface WasmValidateFailure {\n ok: false\n message: string\n start: number\n end: number\n}\n\ntype WasmValidatePayload = { ok: true } | WasmValidateFailure\n\nfunction readValidatePayload(value: unknown): WasmValidatePayload {\n if (!isRecord(value)) {\n throw new WasmError('Validate returned an invalid payload', 'WASM_ERROR')\n }\n\n const ok = value['ok']\n if (ok === true) {\n return { ok: true }\n }\n\n const message = value['message']\n const start = value['start']\n const end = value['end']\n if (\n ok === false &&\n typeof message === 'string' &&\n typeof start === 'number' &&\n typeof end === 'number'\n ) {\n return { ok: false, message, start, end }\n }\n\n throw new WasmError('Validate returned an invalid payload', 'WASM_ERROR')\n}\n\nfunction toValidateError(query: string, failure: WasmValidateFailure): ValidateError {\n const toPosition = createUtf8OffsetMapper(query)\n const start = toPosition(Math.max(0, failure.start))\n const end = toPosition(Math.max(failure.start, failure.end))\n return {\n message: failure.message,\n start: start.index,\n end: end.index,\n line: start.line,\n column: start.column,\n endLine: end.line,\n endColumn: end.column,\n }\n}\n\n// oxlint-disable-next-line quality/no-unsafe-dictionary-type -- narrows unparsed WASM JSON before its fields are checked\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null\n}\n"],"mappings":";AAgBO,SAAS,YAAY,cAA0D;AACpF,UAAQ,cAAc;AAAA,IACpB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAmFO,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC,YACE,SACgB,MAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AAAA,EAJkB;AAKpB;AAMO,IAAM,cAAsC;AAAA,EACjD,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,0BAA0B;AAAA,EAC1B,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,YAAY;AAAA,EACZ,iBAAiB;AACnB;AAKO,SAAS,UAAU,YAA4B;AACpD,SAAO,YAAY,UAAU,KAAK,WAAW,WAAW,KAAK,GAAG;AAClE;;;ACnIO,SAAS,cAAc,OAAO;AACjC,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KA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