@sanity-labs/groq-wasm 1.2.1 → 1.2.3
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/dist/index.browser.d.ts +8 -287
- package/dist/index.browser.js +15 -33
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.js +13 -29
- package/dist/index.js.map +1 -1
- package/dist/index.lazy.d.ts +16 -22
- package/dist/index.lazy.js +40 -55
- package/dist/index.lazy.js.map +1 -1
- package/dist/public-CItQFkIH.js +713 -0
- package/dist/public-CItQFkIH.js.map +1 -0
- package/dist/validate-BKAMowYw.d.ts +304 -0
- package/package.json +12 -7
- package/dist/chunk-PIYLCZE4.js +0 -561
- package/dist/chunk-PIYLCZE4.js.map +0 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,290 +1,11 @@
|
|
|
1
|
-
import { Finding } from '@sanity-labs/lint-core';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* @sanity-labs/groq-wasm — Browser entry.
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Fetches the WASM bytes at import time and initializes the module via
|
|
5
|
+
* top-level await + `initSync`. After this module finishes loading,
|
|
6
|
+
* `lint()`, `format()`, and `validate()` are usable synchronously. Bundlers that
|
|
7
|
+
* understand `new URL('...', import.meta.url)` (Vite, Rollup, Webpack 5,
|
|
8
|
+
* esbuild) emit the WASM file as an asset and rewrite the URL.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Rust: High, Medium, Low → TS: error, warning, info
|
|
12
|
-
*/
|
|
13
|
-
type WasmSeverity = 'high' | 'medium' | 'low';
|
|
14
|
-
/**
|
|
15
|
-
* Map WASM severity to our standard severity
|
|
16
|
-
*/
|
|
17
|
-
declare function mapSeverity(wasmSeverity: WasmSeverity): 'error' | 'warning' | 'info';
|
|
18
|
-
/**
|
|
19
|
-
* A finding from the Rust linter (JSON format from WASM)
|
|
20
|
-
*/
|
|
21
|
-
interface WasmFinding {
|
|
22
|
-
/** Rule ID (snake_case from Rust) */
|
|
23
|
-
ruleId: string;
|
|
24
|
-
/** Human-readable message */
|
|
25
|
-
message: string;
|
|
26
|
-
/** Severity level */
|
|
27
|
-
severity: WasmSeverity;
|
|
28
|
-
/** Start offset into the UTF-8 encoding of the query (0-based) */
|
|
29
|
-
start: number;
|
|
30
|
-
/** End offset into the UTF-8 encoding of the query (0-based, exclusive) */
|
|
31
|
-
end: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Configuration for linting
|
|
35
|
-
*/
|
|
36
|
-
interface WasmLintConfig {
|
|
37
|
-
/** Rules to enable/disable (rule_id → enabled) */
|
|
38
|
-
rules?: Record<string, boolean>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Configuration for formatting
|
|
42
|
-
*/
|
|
43
|
-
interface WasmFormatConfig {
|
|
44
|
-
/** Maximum line width (default: 80) */
|
|
45
|
-
width?: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* One `$name` reference in a query, from {@link extractParams}.
|
|
49
|
-
*
|
|
50
|
-
* `start` and `end` are indices into the JavaScript query string (UTF-16 code
|
|
51
|
-
* units), not UTF-8 byte offsets. `start` is inclusive and `end` is exclusive,
|
|
52
|
-
* so `query.slice(start, end)` is `"$name"`. Lines and columns are 1-based,
|
|
53
|
-
* and columns count UTF-16 code units, matching `SourceLocation` on lint
|
|
54
|
-
* findings.
|
|
55
|
-
*/
|
|
56
|
-
interface ParamReference {
|
|
57
|
-
/** Inclusive start index of the `$`, 0-based UTF-16 code units. */
|
|
58
|
-
start: number;
|
|
59
|
-
/** Exclusive end index, 0-based UTF-16 code units. */
|
|
60
|
-
end: number;
|
|
61
|
-
/** 1-based line number of `start`. */
|
|
62
|
-
line: number;
|
|
63
|
-
/** 1-based column of `start`, counted in UTF-16 code units. */
|
|
64
|
-
column: number;
|
|
65
|
-
/** 1-based line number of `end`. */
|
|
66
|
-
endLine: number;
|
|
67
|
-
/** 1-based column of `end`, counted in UTF-16 code units. */
|
|
68
|
-
endColumn: number;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* A query parameter referenced by a GROQ query, from {@link extractParams}.
|
|
72
|
-
*/
|
|
73
|
-
interface QueryParam {
|
|
74
|
-
/** Parameter name without the `$`, e.g. `"type"` for `$type`. */
|
|
75
|
-
name: string;
|
|
76
|
-
/** Every reference to this parameter, in source order. Never empty. */
|
|
77
|
-
references: ParamReference[];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Error from WASM operations
|
|
81
|
-
*/
|
|
82
|
-
declare class WasmError extends Error {
|
|
83
|
-
readonly code: 'PARSE_ERROR' | 'WASM_ERROR' | 'NOT_INITIALIZED';
|
|
84
|
-
constructor(message: string, code: 'PARSE_ERROR' | 'WASM_ERROR' | 'NOT_INITIALIZED');
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Rule ID mapping from Rust (snake_case) to TS (kebab-case)
|
|
88
|
-
*/
|
|
89
|
-
declare const RULE_ID_MAP: Record<string, string>;
|
|
90
|
-
/**
|
|
91
|
-
* Convert Rust rule ID to TS convention
|
|
92
|
-
*/
|
|
93
|
-
declare function mapRuleId(rustRuleId: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* A GROQ syntax error from `validate`.
|
|
96
|
-
*
|
|
97
|
-
* `start` and `end` are indices into the JavaScript query string (UTF-16 code
|
|
98
|
-
* units), not UTF-8 byte offsets. `start` is inclusive and `end` is exclusive,
|
|
99
|
-
* so `query.slice(start, end)` is the reported span. groq-parser reports UTF-8
|
|
100
|
-
* byte offsets; `validate` converts them. A zero-width span (`start === end`)
|
|
101
|
-
* is a caret on a token boundary.
|
|
102
|
-
*
|
|
103
|
-
* `line` / `column` locate `start`, and `endLine` / `endColumn` locate `end`.
|
|
104
|
-
* Lines and columns are 1-based. Columns count UTF-16 code units, matching
|
|
105
|
-
* `SourceLocation` on lint findings.
|
|
106
|
-
*/
|
|
107
|
-
interface ValidateError {
|
|
108
|
-
/** Parser message, without a serialized position suffix. */
|
|
109
|
-
message: string;
|
|
110
|
-
/** Inclusive start index, 0-based UTF-16 code units. */
|
|
111
|
-
start: number;
|
|
112
|
-
/** Exclusive end index, 0-based UTF-16 code units. */
|
|
113
|
-
end: number;
|
|
114
|
-
/** 1-based line number of `start`. */
|
|
115
|
-
line: number;
|
|
116
|
-
/** 1-based column of `start`, counted in UTF-16 code units. */
|
|
117
|
-
column: number;
|
|
118
|
-
/** 1-based line number of `end`. */
|
|
119
|
-
endLine: number;
|
|
120
|
-
/** 1-based column of `end`, counted in UTF-16 code units. */
|
|
121
|
-
endColumn: number;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Result of {@link validate}.
|
|
125
|
-
*
|
|
126
|
-
* Syntax errors are values, not thrown exceptions. `lint` and `format` still
|
|
127
|
-
* throw {@link WasmError} when a query does not parse.
|
|
128
|
-
*/
|
|
129
|
-
type ValidateResult = {
|
|
130
|
-
ok: true;
|
|
131
|
-
} | {
|
|
132
|
-
ok: false;
|
|
133
|
-
error: ValidateError;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* GROQ query parameter extraction via WASM.
|
|
138
|
-
*
|
|
139
|
-
* Wraps groq-parser's `ParseResult::referenced_params`. The parser reports
|
|
140
|
-
* UTF-8 byte offsets; this module converts them to UTF-16 code unit indices.
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* List the query parameters (`$name`) a GROQ query references.
|
|
145
|
-
*
|
|
146
|
-
* Returns one entry per distinct name, in order of first reference. Each entry
|
|
147
|
-
* lists every reference to that name in source order. Names do not include
|
|
148
|
-
* the `$`, so they match the keys of the params object passed to a client.
|
|
149
|
-
*
|
|
150
|
-
* Parameters bound by a custom function (`fn ns::f($p) = ...`) are local to
|
|
151
|
-
* that function's body and are not reported from inside it. `$name` text
|
|
152
|
-
* inside string literals and comments is not a reference.
|
|
153
|
-
*
|
|
154
|
-
* Reference `start` / `end` are 0-based UTF-16 code unit indices into
|
|
155
|
-
* `query` (`end` is exclusive), so `query.slice(start, end)` is `"$name"`.
|
|
156
|
-
*
|
|
157
|
-
* An empty or whitespace-only query returns `[]`, like `lint('')`.
|
|
158
|
-
*
|
|
159
|
-
* @param query - The GROQ query string
|
|
160
|
-
* @returns Referenced parameters, in order of first reference
|
|
161
|
-
* @throws {WasmError} With code `PARSE_ERROR` if the query does not parse
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* import {extractParams} from '@sanity-labs/groq-wasm'
|
|
166
|
-
*
|
|
167
|
-
* extractParams('*[_type == $type][0...$limit]').map((param) => param.name)
|
|
168
|
-
* // ['type', 'limit']
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
declare function extractParams(query: string): QueryParam[];
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* GROQ Linting via WASM
|
|
175
|
-
*
|
|
176
|
-
* Wraps the Rust groq-lint library compiled to WASM.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Lint a GROQ query using the WASM-based linter.
|
|
181
|
-
*
|
|
182
|
-
* Finding spans are source locations in JavaScript string coordinates.
|
|
183
|
-
* The Rust linter reports UTF-8 byte offsets; `line`, `column`, and `offset`
|
|
184
|
-
* below are converted from those bytes. `column` counts UTF-16 code units.
|
|
185
|
-
*
|
|
186
|
-
* @param query - The GROQ query string to lint
|
|
187
|
-
* @param config - Optional configuration
|
|
188
|
-
* @returns Array of findings
|
|
189
|
-
* @throws {WasmError} If query parsing fails
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* import {lint} from '@sanity-labs/groq-wasm'
|
|
194
|
-
*
|
|
195
|
-
* const findings = lint('*[_type == "post"]{ author-> }')
|
|
196
|
-
* // [{ ruleId: 'join-in-filter', message: '...', severity: 'error' }]
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
declare function lint(query: string, config?: WasmLintConfig): Finding[];
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* GROQ Formatting via WASM
|
|
203
|
-
*
|
|
204
|
-
* Wraps the Rust groq-format library compiled to WASM.
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Default line width for formatting
|
|
209
|
-
* Matches Rust groq-format DEFAULT_WIDTH
|
|
210
|
-
*/
|
|
211
|
-
declare const DEFAULT_WIDTH = 80;
|
|
212
|
-
/**
|
|
213
|
-
* Format a GROQ query using the WASM-based formatter
|
|
214
|
-
*
|
|
215
|
-
* @param query - The GROQ query string to format
|
|
216
|
-
* @param config - Optional configuration (width defaults to 80)
|
|
217
|
-
* @returns Formatted query string
|
|
218
|
-
* @throws {WasmError} If query parsing fails
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* import {format} from '@sanity-labs/groq-wasm'
|
|
223
|
-
*
|
|
224
|
-
* const formatted = format('*[_type=="post"]{title,body}')
|
|
225
|
-
* // '*[_type == "post"]{ title, body }'
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function format(query: string, config?: WasmFormatConfig): string;
|
|
229
|
-
/**
|
|
230
|
-
* Check if a query can be parsed (without full formatting)
|
|
231
|
-
*
|
|
232
|
-
* @param query - The GROQ query to validate
|
|
233
|
-
* @returns true if the query is valid GROQ syntax
|
|
234
|
-
*/
|
|
235
|
-
declare function isValidSyntax(query: string): boolean;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* GROQ syntax validation via WASM.
|
|
239
|
-
*
|
|
240
|
-
* Wraps groq-parser's structured parse errors. The parser reports UTF-8 byte
|
|
241
|
-
* offsets; this module converts them to UTF-16 code unit indices.
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Parse a GROQ query.
|
|
246
|
-
*
|
|
247
|
-
* Returns `{ok: true}` when the query parses. Syntax errors are returned as
|
|
248
|
-
* `{ok: false, error}` and are not thrown. `lint` and `format` still throw
|
|
249
|
-
* {@link WasmError} on invalid syntax; this function does not change that.
|
|
250
|
-
*
|
|
251
|
-
* `error.start` and `error.end` are 0-based UTF-16 code unit indices into
|
|
252
|
-
* `query` (`end` is exclusive), which is what JavaScript strings and editors
|
|
253
|
-
* such as Vision use. groq-parser's `ParseError` positions are UTF-8 byte
|
|
254
|
-
* offsets (`Position.start` / `Position.end` in groq-parser-rs). An empty or
|
|
255
|
-
* whitespace-only query is a syntax error (`"no query"`) at offset 0, unlike
|
|
256
|
-
* `lint('')` and `format('')`, which treat it as nothing to do.
|
|
257
|
-
*
|
|
258
|
-
* `line` / `column` locate `start`, and `endLine` / `endColumn` locate `end`.
|
|
259
|
-
* They are 1-based. Columns count UTF-16 code units, matching `SourceLocation`
|
|
260
|
-
* on lint findings.
|
|
261
|
-
*
|
|
262
|
-
* Parameter references (`$name`) are accepted. This is a syntax check and does
|
|
263
|
-
* not require the parameters to be declared.
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```typescript
|
|
267
|
-
* import {validate} from '@sanity-labs/groq-wasm'
|
|
268
|
-
*
|
|
269
|
-
* validate('*[_type == "post"]')
|
|
270
|
-
* // {ok: true}
|
|
271
|
-
*
|
|
272
|
-
* validate('*["é" == ]')
|
|
273
|
-
* // {
|
|
274
|
-
* // ok: false,
|
|
275
|
-
* // error: {
|
|
276
|
-
* // message: 'unexpected token "]", expected expression',
|
|
277
|
-
* // start: 9,
|
|
278
|
-
* // end: 10,
|
|
279
|
-
* // line: 1,
|
|
280
|
-
* // column: 10,
|
|
281
|
-
* // endLine: 1,
|
|
282
|
-
* // endColumn: 11,
|
|
283
|
-
* // },
|
|
284
|
-
* // }
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
declare function validate(query: string): ValidateResult;
|
|
288
|
-
|
|
289
|
-
export { DEFAULT_WIDTH, RULE_ID_MAP, WasmError, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
|
290
|
-
export type { ParamReference, QueryParam, ValidateError, ValidateResult, WasmFinding, WasmFormatConfig, WasmLintConfig, WasmSeverity };
|
|
10
|
+
import { _ as mapRuleId, a as lint, c as QueryParam, d as ValidateResult, f as WasmError, g as WasmSeverity, h as WasmLintConfig, i as isValidSyntax, l as RULE_ID_MAP, m as WasmFormatConfig, n as DEFAULT_WIDTH, o as extractParams, p as WasmFinding, r as format, s as ParamReference, t as validate, u as ValidateError, v as mapSeverity } from "./validate-BKAMowYw.js";
|
|
11
|
+
export { DEFAULT_WIDTH, type ParamReference, type QueryParam, RULE_ID_MAP, type ValidateError, type ValidateResult, WasmError, type WasmFinding, type WasmFormatConfig, type WasmLintConfig, type WasmSeverity, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
package/dist/index.browser.js
CHANGED
|
@@ -1,36 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_WIDTH,
|
|
3
|
-
RULE_ID_MAP,
|
|
4
|
-
WasmError,
|
|
5
|
-
extractParams,
|
|
6
|
-
format,
|
|
7
|
-
initWasm,
|
|
8
|
-
isValidSyntax,
|
|
9
|
-
lint,
|
|
10
|
-
mapRuleId,
|
|
11
|
-
mapSeverity,
|
|
12
|
-
validate
|
|
13
|
-
} from "./chunk-PIYLCZE4.js";
|
|
14
|
-
|
|
1
|
+
import { a as lint, d as mapRuleId, f as mapSeverity, i as isValidSyntax, l as RULE_ID_MAP, n as DEFAULT_WIDTH, o as extractParams, r as format, s as initWasm, t as validate, u as WasmError } from "./public-CItQFkIH.js";
|
|
15
2
|
// src/index.browser.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @sanity-labs/groq-wasm — Browser entry.
|
|
5
|
+
*
|
|
6
|
+
* Fetches the WASM bytes at import time and initializes the module via
|
|
7
|
+
* top-level await + `initSync`. After this module finishes loading,
|
|
8
|
+
* `lint()`, `format()`, and `validate()` are usable synchronously. Bundlers that
|
|
9
|
+
* understand `new URL('...', import.meta.url)` (Vite, Rollup, Webpack 5,
|
|
10
|
+
* esbuild) emit the WASM file as an asset and rewrite the URL.
|
|
11
|
+
*/
|
|
12
|
+
const wasmUrl = new URL("../wasm/groq_wasm_bg.wasm", import.meta.url);
|
|
13
|
+
const response = await fetch(wasmUrl);
|
|
14
|
+
if (!response.ok) throw new Error(`Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`);
|
|
23
15
|
initWasm(await response.arrayBuffer());
|
|
24
|
-
export {
|
|
25
|
-
|
|
26
|
-
RULE_ID_MAP,
|
|
27
|
-
WasmError,
|
|
28
|
-
extractParams,
|
|
29
|
-
format,
|
|
30
|
-
isValidSyntax,
|
|
31
|
-
lint,
|
|
32
|
-
mapRuleId,
|
|
33
|
-
mapSeverity,
|
|
34
|
-
validate
|
|
35
|
-
};
|
|
16
|
+
export { DEFAULT_WIDTH, RULE_ID_MAP, WasmError, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
|
17
|
+
|
|
36
18
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Browser entry.\n *\n * Fetches the WASM bytes at import time and initializes the module via\n * top-level await + `initSync`. After this module finishes loading,\n * `lint()`, `format()`, and `validate()` are usable synchronously. Bundlers that\n * understand `new URL('...', import.meta.url)` (Vite, Rollup, Webpack 5,\n * esbuild) emit the WASM file as an asset and rewrite the URL.\n */\n\nimport { initWasm } from './wasm-loader.js'\n\nconst wasmUrl = new URL('../wasm/groq_wasm_bg.wasm', import.meta.url)\nconst response = await fetch(wasmUrl)\nif (!response.ok) {\n throw new Error(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`\n )\n}\ninitWasm(await response.arrayBuffer())\n\nexport * from './public.js'\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.browser.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Browser entry.\n *\n * Fetches the WASM bytes at import time and initializes the module via\n * top-level await + `initSync`. After this module finishes loading,\n * `lint()`, `format()`, and `validate()` are usable synchronously. Bundlers that\n * understand `new URL('...', import.meta.url)` (Vite, Rollup, Webpack 5,\n * esbuild) emit the WASM file as an asset and rewrite the URL.\n */\n\nimport { initWasm } from './wasm-loader.js'\n\nconst wasmUrl = new URL('../wasm/groq_wasm_bg.wasm', import.meta.url)\nconst response = await fetch(wasmUrl)\nif (!response.ok) {\n throw new Error(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`\n )\n}\ninitWasm(await response.arrayBuffer())\n\nexport * from './public.js'\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,UAAU,IAAI,IAAI,6BAA6B,YAAY,GAAG;AACpE,MAAM,WAAW,MAAM,MAAM,OAAO;AACpC,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MACR,yCAAyC,QAAQ,KAAK,IAAI,SAAS,OAAO,GAAG,SAAS,YACxF;AAEF,SAAS,MAAM,SAAS,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @sanity-labs/groq-wasm — Node entry.
|
|
3
|
+
*
|
|
4
|
+
* Loads the WASM module synchronously at import time using `fs.readFileSync`
|
|
5
|
+
* + `initSync`. After importing this package, `lint()`, `format()`, and
|
|
6
|
+
* `validate()` are usable immediately — no async bootstrap.
|
|
7
|
+
*/
|
|
8
|
+
import { _ as mapRuleId, a as lint, c as QueryParam, d as ValidateResult, f as WasmError, g as WasmSeverity, h as WasmLintConfig, i as isValidSyntax, l as RULE_ID_MAP, m as WasmFormatConfig, n as DEFAULT_WIDTH, o as extractParams, p as WasmFinding, r as format, s as ParamReference, t as validate, u as ValidateError, v as mapSeverity } from "./validate-BKAMowYw.js";
|
|
9
|
+
export { DEFAULT_WIDTH, type ParamReference, type QueryParam, RULE_ID_MAP, type ValidateError, type ValidateResult, WasmError, type WasmFinding, type WasmFormatConfig, type WasmLintConfig, type WasmSeverity, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
WasmError,
|
|
5
|
-
extractParams,
|
|
6
|
-
format,
|
|
7
|
-
initWasm,
|
|
8
|
-
isValidSyntax,
|
|
9
|
-
lint,
|
|
10
|
-
mapRuleId,
|
|
11
|
-
mapSeverity,
|
|
12
|
-
validate
|
|
13
|
-
} from "./chunk-PIYLCZE4.js";
|
|
14
|
-
|
|
1
|
+
import { a as lint, d as mapRuleId, f as mapSeverity, i as isValidSyntax, l as RULE_ID_MAP, n as DEFAULT_WIDTH, o as extractParams, r as format, s as initWasm, t as validate, u as WasmError } from "./public-CItQFkIH.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
15
4
|
// src/index.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @sanity-labs/groq-wasm — Node entry.
|
|
7
|
+
*
|
|
8
|
+
* Loads the WASM module synchronously at import time using `fs.readFileSync`
|
|
9
|
+
* + `initSync`. After importing this package, `lint()`, `format()`, and
|
|
10
|
+
* `validate()` are usable immediately — no async bootstrap.
|
|
11
|
+
*/
|
|
12
|
+
const wasmPath = fileURLToPath(new URL("../wasm/groq_wasm_bg.wasm", import.meta.url));
|
|
19
13
|
initWasm(readFileSync(wasmPath));
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
RULE_ID_MAP,
|
|
23
|
-
WasmError,
|
|
24
|
-
extractParams,
|
|
25
|
-
format,
|
|
26
|
-
isValidSyntax,
|
|
27
|
-
lint,
|
|
28
|
-
mapRuleId,
|
|
29
|
-
mapSeverity,
|
|
30
|
-
validate
|
|
31
|
-
};
|
|
14
|
+
export { DEFAULT_WIDTH, RULE_ID_MAP, WasmError, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
|
15
|
+
|
|
32
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Node entry.\n *\n * Loads the WASM module synchronously at import time using `fs.readFileSync`\n * + `initSync`. After importing this package, `lint()`, `format()`, and\n * `validate()` are usable immediately — no async bootstrap.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\n\nimport { initWasm } from './wasm-loader.js'\n\nconst wasmPath = fileURLToPath(new URL('../wasm/groq_wasm_bg.wasm', import.meta.url))\ninitWasm(readFileSync(wasmPath))\n\nexport * from './public.js'\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Node entry.\n *\n * Loads the WASM module synchronously at import time using `fs.readFileSync`\n * + `initSync`. After importing this package, `lint()`, `format()`, and\n * `validate()` are usable immediately — no async bootstrap.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\n\nimport { initWasm } from './wasm-loader.js'\n\nconst wasmPath = fileURLToPath(new URL('../wasm/groq_wasm_bg.wasm', import.meta.url))\ninitWasm(readFileSync(wasmPath))\n\nexport * from './public.js'\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,WAAW,cAAc,IAAI,IAAI,6BAA6B,YAAY,GAAG,CAAC;AACpF,SAAS,aAAa,QAAQ,CAAC"}
|
package/dist/index.lazy.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @sanity-labs/groq-wasm — Lazy entry (`@sanity-labs/groq-wasm/lazy`).
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the public API plus `load()` and `initWasm()`. Evaluating this
|
|
5
|
+
* module does not fetch or compile the WebAssembly module and does not use
|
|
6
|
+
* top-level await. Call `load()` (or `initWasm()` with your own bytes) before
|
|
7
|
+
* `lint()`, `format()`, `validate()`, or `extractParams()`.
|
|
8
|
+
*
|
|
9
|
+
* Bundlers that understand `new URL('...', import.meta.url)` rewrite the URL
|
|
10
|
+
* inside `load()` and emit the `.wasm` file as an asset.
|
|
11
|
+
*/
|
|
12
|
+
import { _ as mapRuleId, a as lint, c as QueryParam, d as ValidateResult, f as WasmError, g as WasmSeverity, h as WasmLintConfig, i as isValidSyntax, l as RULE_ID_MAP, m as WasmFormatConfig, n as DEFAULT_WIDTH, o as extractParams, p as WasmFinding, r as format, s as ParamReference, t as validate, u as ValidateError, v as mapSeverity } from "./validate-BKAMowYw.js";
|
|
4
13
|
/**
|
|
5
14
|
* WASM module runtime.
|
|
6
15
|
*
|
|
@@ -27,21 +36,8 @@ type WasmInitSource = ArrayBuffer | Uint8Array | WebAssembly.Module | Response;
|
|
|
27
36
|
* instantiated, or when the module is not initialized yet and `source` is a
|
|
28
37
|
* `Response` that is not ok.
|
|
29
38
|
*/
|
|
30
|
-
declare function initWasm(source:
|
|
31
|
-
declare function initWasm(source:
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @sanity-labs/groq-wasm — Lazy entry (`@sanity-labs/groq-wasm/lazy`).
|
|
35
|
-
*
|
|
36
|
-
* Re-exports the public API plus `load()` and `initWasm()`. Evaluating this
|
|
37
|
-
* module does not fetch or compile the WebAssembly module and does not use
|
|
38
|
-
* top-level await. Call `load()` (or `initWasm()` with your own bytes) before
|
|
39
|
-
* `lint()`, `format()`, `validate()`, or `extractParams()`.
|
|
40
|
-
*
|
|
41
|
-
* Bundlers that understand `new URL('...', import.meta.url)` rewrite the URL
|
|
42
|
-
* inside `load()` and emit the `.wasm` file as an asset.
|
|
43
|
-
*/
|
|
44
|
-
|
|
39
|
+
export declare function initWasm(source: Response): Promise<void>;
|
|
40
|
+
export declare function initWasm(source: ArrayBuffer | Uint8Array | WebAssembly.Module): void;
|
|
45
41
|
/**
|
|
46
42
|
* Fetch the packaged WebAssembly module and initialize it.
|
|
47
43
|
*
|
|
@@ -52,7 +48,5 @@ declare function initWasm(source: Response): Promise<void>;
|
|
|
52
48
|
* @throws {WasmError} With code `WASM_ERROR` when the file cannot be fetched
|
|
53
49
|
* or instantiated.
|
|
54
50
|
*/
|
|
55
|
-
declare function load(): Promise<void>;
|
|
56
|
-
|
|
57
|
-
export { initWasm, load };
|
|
58
|
-
export type { WasmInitSource };
|
|
51
|
+
export declare function load(): Promise<void>;
|
|
52
|
+
export { DEFAULT_WIDTH, type ParamReference, type QueryParam, RULE_ID_MAP, type ValidateError, type ValidateResult, WasmError, type WasmFinding, type WasmFormatConfig, type WasmInitSource, type WasmLintConfig, type WasmSeverity, extractParams, format, isValidSyntax, lint, mapRuleId, mapSeverity, validate };
|
package/dist/index.lazy.js
CHANGED
|
@@ -1,61 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_WIDTH,
|
|
3
|
-
RULE_ID_MAP,
|
|
4
|
-
WasmError,
|
|
5
|
-
extractParams,
|
|
6
|
-
format,
|
|
7
|
-
initWasm,
|
|
8
|
-
isValidSyntax,
|
|
9
|
-
isWasmInitialized,
|
|
10
|
-
lint,
|
|
11
|
-
mapRuleId,
|
|
12
|
-
mapSeverity,
|
|
13
|
-
validate
|
|
14
|
-
} from "./chunk-PIYLCZE4.js";
|
|
15
|
-
|
|
1
|
+
import { a as lint, c as isWasmInitialized, d as mapRuleId, f as mapSeverity, i as isValidSyntax, l as RULE_ID_MAP, n as DEFAULT_WIDTH, o as extractParams, r as format, s as initWasm, t as validate, u as WasmError } from "./public-CItQFkIH.js";
|
|
16
2
|
// src/index.lazy.ts
|
|
17
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @sanity-labs/groq-wasm — Lazy entry (`@sanity-labs/groq-wasm/lazy`).
|
|
5
|
+
*
|
|
6
|
+
* Re-exports the public API plus `load()` and `initWasm()`. Evaluating this
|
|
7
|
+
* module does not fetch or compile the WebAssembly module and does not use
|
|
8
|
+
* top-level await. Call `load()` (or `initWasm()` with your own bytes) before
|
|
9
|
+
* `lint()`, `format()`, `validate()`, or `extractParams()`.
|
|
10
|
+
*
|
|
11
|
+
* Bundlers that understand `new URL('...', import.meta.url)` rewrite the URL
|
|
12
|
+
* inside `load()` and emit the `.wasm` file as an asset.
|
|
13
|
+
*/
|
|
14
|
+
let pendingLoad;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the packaged WebAssembly module and initialize it.
|
|
17
|
+
*
|
|
18
|
+
* Resolves immediately when the module is already initialized. Concurrent
|
|
19
|
+
* calls share one in-flight request. A rejection leaves the module
|
|
20
|
+
* uninitialized so a later call can retry.
|
|
21
|
+
*
|
|
22
|
+
* @throws {WasmError} With code `WASM_ERROR` when the file cannot be fetched
|
|
23
|
+
* or instantiated.
|
|
24
|
+
*/
|
|
18
25
|
function load() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return pendingLoad;
|
|
26
|
+
if (isWasmInitialized()) return Promise.resolve();
|
|
27
|
+
if (!pendingLoad) pendingLoad = fetchAndInit().finally(() => {
|
|
28
|
+
pendingLoad = void 0;
|
|
29
|
+
});
|
|
30
|
+
return pendingLoad;
|
|
26
31
|
}
|
|
27
32
|
async function fetchAndInit() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
throw new WasmError(
|
|
41
|
-
`Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`,
|
|
42
|
-
"WASM_ERROR"
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
await initWasm(response);
|
|
33
|
+
const wasmUrl = new URL("../wasm/groq_wasm_bg.wasm", import.meta.url);
|
|
34
|
+
let response;
|
|
35
|
+
try {
|
|
36
|
+
response = await fetch(wasmUrl);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
+
throw new WasmError(`Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${message}`, "WASM_ERROR");
|
|
40
|
+
}
|
|
41
|
+
if (!response.ok) throw new WasmError(`Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`, "WASM_ERROR");
|
|
42
|
+
await initWasm(response);
|
|
46
43
|
}
|
|
47
|
-
export {
|
|
48
|
-
|
|
49
|
-
RULE_ID_MAP,
|
|
50
|
-
WasmError,
|
|
51
|
-
extractParams,
|
|
52
|
-
format,
|
|
53
|
-
initWasm,
|
|
54
|
-
isValidSyntax,
|
|
55
|
-
lint,
|
|
56
|
-
load,
|
|
57
|
-
mapRuleId,
|
|
58
|
-
mapSeverity,
|
|
59
|
-
validate
|
|
60
|
-
};
|
|
44
|
+
export { DEFAULT_WIDTH, RULE_ID_MAP, WasmError, extractParams, format, initWasm, isValidSyntax, lint, load, mapRuleId, mapSeverity, validate };
|
|
45
|
+
|
|
61
46
|
//# sourceMappingURL=index.lazy.js.map
|
package/dist/index.lazy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.lazy.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Lazy entry (`@sanity-labs/groq-wasm/lazy`).\n *\n * Re-exports the public API plus `load()` and `initWasm()`. Evaluating this\n * module does not fetch or compile the WebAssembly module and does not use\n * top-level await. Call `load()` (or `initWasm()` with your own bytes) before\n * `lint()`, `format()`, `validate()`, or `extractParams()`.\n *\n * Bundlers that understand `new URL('...', import.meta.url)` rewrite the URL\n * inside `load()` and emit the `.wasm` file as an asset.\n */\n\nimport { WasmError } from './types.js'\nimport { initWasm, isWasmInitialized, type WasmInitSource } from './wasm-loader.js'\n\nexport { initWasm, type WasmInitSource }\nexport * from './public.js'\n\nlet pendingLoad: Promise<void> | undefined\n\n/**\n * Fetch the packaged WebAssembly module and initialize it.\n *\n * Resolves immediately when the module is already initialized. Concurrent\n * calls share one in-flight request. A rejection leaves the module\n * uninitialized so a later call can retry.\n *\n * @throws {WasmError} With code `WASM_ERROR` when the file cannot be fetched\n * or instantiated.\n */\nexport function load(): Promise<void> {\n if (isWasmInitialized()) return Promise.resolve()\n if (!pendingLoad) {\n pendingLoad = fetchAndInit().finally(() => {\n pendingLoad = undefined\n })\n }\n return pendingLoad\n}\n\nasync function fetchAndInit(): Promise<void> {\n const wasmUrl = new URL('../wasm/groq_wasm_bg.wasm', import.meta.url)\n let response: Response\n try {\n response = await fetch(wasmUrl)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new WasmError(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${message}`,\n 'WASM_ERROR'\n )\n }\n\n if (!response.ok) {\n throw new WasmError(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`,\n 'WASM_ERROR'\n )\n }\n\n await initWasm(response)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.lazy.js","names":[],"sources":["../src/index.lazy.ts"],"sourcesContent":["/**\n * @sanity-labs/groq-wasm — Lazy entry (`@sanity-labs/groq-wasm/lazy`).\n *\n * Re-exports the public API plus `load()` and `initWasm()`. Evaluating this\n * module does not fetch or compile the WebAssembly module and does not use\n * top-level await. Call `load()` (or `initWasm()` with your own bytes) before\n * `lint()`, `format()`, `validate()`, or `extractParams()`.\n *\n * Bundlers that understand `new URL('...', import.meta.url)` rewrite the URL\n * inside `load()` and emit the `.wasm` file as an asset.\n */\n\nimport { WasmError } from './types.js'\nimport { initWasm, isWasmInitialized, type WasmInitSource } from './wasm-loader.js'\n\nexport { initWasm, type WasmInitSource }\nexport * from './public.js'\n\nlet pendingLoad: Promise<void> | undefined\n\n/**\n * Fetch the packaged WebAssembly module and initialize it.\n *\n * Resolves immediately when the module is already initialized. Concurrent\n * calls share one in-flight request. A rejection leaves the module\n * uninitialized so a later call can retry.\n *\n * @throws {WasmError} With code `WASM_ERROR` when the file cannot be fetched\n * or instantiated.\n */\nexport function load(): Promise<void> {\n if (isWasmInitialized()) {\n return Promise.resolve()\n }\n if (!pendingLoad) {\n pendingLoad = fetchAndInit().finally(() => {\n pendingLoad = undefined\n })\n }\n return pendingLoad\n}\n\nasync function fetchAndInit(): Promise<void> {\n const wasmUrl = new URL('../wasm/groq_wasm_bg.wasm', import.meta.url)\n let response: Response\n try {\n response = await fetch(wasmUrl)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new WasmError(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${message}`,\n 'WASM_ERROR'\n )\n }\n\n if (!response.ok) {\n throw new WasmError(\n `Failed to fetch GROQ WASM module from ${wasmUrl.href}: ${response.status} ${response.statusText}`,\n 'WASM_ERROR'\n )\n }\n\n await initWasm(response)\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAI;;;;;;;;;;;AAYJ,SAAgB,OAAsB;CACpC,IAAI,kBAAkB,GACpB,OAAO,QAAQ,QAAQ;CAEzB,IAAI,CAAC,aACH,cAAc,aAAa,CAAC,CAAC,cAAc;EACzC,cAAc,KAAA;CAChB,CAAC;CAEH,OAAO;AACT;AAEA,eAAe,eAA8B;CAC3C,MAAM,UAAU,IAAI,IAAI,6BAA6B,YAAY,GAAG;CACpE,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,MAAM,OAAO;CAChC,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,MAAM,IAAI,UACR,yCAAyC,QAAQ,KAAK,IAAI,WAC1D,YACF;CACF;CAEA,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,UACR,yCAAyC,QAAQ,KAAK,IAAI,SAAS,OAAO,GAAG,SAAS,cACtF,YACF;CAGF,MAAM,SAAS,QAAQ;AACzB"}
|