jlens-wasm 0.28.0 → 0.30.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.
- package/README.md +1 -0
- package/jlens.d.ts +76 -3
- package/jlens.global.js +61 -16
- package/jlens.js +59 -14
- package/jlens_bg.wasm +0 -0
- package/jlens_bg.wasm.d.ts +2 -0
- package/package.json +1 -1
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-4e9c08ba97667291}/inline0.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-4e9c08ba97667291}/inline1.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-4e9c08ba97667291}/inline2.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-4e9c08ba97667291}/inline3.js +0 -0
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ expr.evaluate({ items: [{ type: "a", price: 2.5, qty: 4 }] }, { kind: "a" }); //
|
|
|
35
35
|
| `expr.ast()` | The processed syntax tree |
|
|
36
36
|
| `parseRecover(source)` | Partial syntax tree and every diagnostic, without throwing |
|
|
37
37
|
| `inferSchema(samples, overrides?)` | A JSON Schema (2020-12) inferred from sample documents |
|
|
38
|
+
| `missingOverridePaths(samples, overrides)` | The override paths the samples lack, with the path each most likely meant |
|
|
38
39
|
| `new LanguageService(schema?, variables?)` | `complete`, `diagnostics`, `hover` and `signatureHelp` for an editor |
|
|
39
40
|
| `functions()` | The built-in function catalog |
|
|
40
41
|
| `version()` | The jlens version |
|
package/jlens.d.ts
CHANGED
|
@@ -300,12 +300,19 @@ export interface SchemaOverride {
|
|
|
300
300
|
/** Hide from completion. */
|
|
301
301
|
hidden?: boolean;
|
|
302
302
|
enum?: unknown[];
|
|
303
|
+
/**
|
|
304
|
+
* An open domain: an identifier the application fetches the values of (in JSON Schema,
|
|
305
|
+
* `x-jlens-domain`). Completion returns a `valueRequest` for it.
|
|
306
|
+
*/
|
|
307
|
+
domain?: string;
|
|
303
308
|
format?: string;
|
|
304
|
-
|
|
309
|
+
/** Replaces the inferred types: one name, or a list for a union, as in JSON Schema. */
|
|
310
|
+
type?: JsonType | JsonType[];
|
|
305
311
|
examples?: unknown[];
|
|
306
312
|
}
|
|
307
313
|
|
|
308
|
-
|
|
314
|
+
/** `value`: a value of the `enum` or `const` of the left-hand side of `=`, `!=` or `in`. */
|
|
315
|
+
export type CompletionKind = "field" | "variable" | "function" | "keyword" | "operator" | "value";
|
|
309
316
|
|
|
310
317
|
export interface CompletionItem {
|
|
311
318
|
label: string;
|
|
@@ -319,10 +326,48 @@ export interface CompletionItem {
|
|
|
319
326
|
}
|
|
320
327
|
|
|
321
328
|
export interface Completions {
|
|
322
|
-
/** The range the chosen item replaces (the word under the cursor). */
|
|
329
|
+
/** The range the chosen item replaces (the word under the cursor, or the whole string literal). */
|
|
323
330
|
range: Span;
|
|
324
331
|
/** Best first. */
|
|
325
332
|
items: CompletionItem[];
|
|
333
|
+
/**
|
|
334
|
+
* Present where a value of an open domain (`x-jlens-domain`) completes the expression: the
|
|
335
|
+
* application fetches the domain's values and offers them beside `items`.
|
|
336
|
+
*/
|
|
337
|
+
valueRequest?: ValueRequest;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** A request for the values of an open domain, at the right of `=`, `!=` or `in`. */
|
|
341
|
+
export interface ValueRequest {
|
|
342
|
+
/** The domain's identifier, as the schema declares it. */
|
|
343
|
+
domain: string;
|
|
344
|
+
/** The left-hand side's path in the schema, such as `items[].type`; absent for a variable. */
|
|
345
|
+
path?: string;
|
|
346
|
+
/** What is typed so far: the word, or a string literal's text up to the cursor (as written). */
|
|
347
|
+
prefix: string;
|
|
348
|
+
/** The range a value replaces: the same as `Completions.range`. */
|
|
349
|
+
range: Span;
|
|
350
|
+
/** The quote to write a string value with (pass it to `valueLiteral`). */
|
|
351
|
+
quote: '"' | "'";
|
|
352
|
+
/**
|
|
353
|
+
* The fields fixed to literals beside the value, in the order written: the comparisons joined
|
|
354
|
+
* to this one by `and` within the same predicate (or, outside any, the whole expression). A
|
|
355
|
+
* domain whose values depend on another value reads it here, such as the group of
|
|
356
|
+
* `categories[group = 'X' and subgroup = '|']`.
|
|
357
|
+
*/
|
|
358
|
+
conditions: ValueCondition[];
|
|
359
|
+
/** Whether the value is an element of the array on the right of `in`: several may be inserted. */
|
|
360
|
+
inArray: boolean;
|
|
361
|
+
/** The literals already in that array, not to offer again; empty outside an array. */
|
|
362
|
+
listed: unknown[];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** A field compared with literals beside a requested value, by `=` or `in`. */
|
|
366
|
+
export interface ValueCondition {
|
|
367
|
+
/** The field's path in the schema, as `ValueRequest.path` writes it. */
|
|
368
|
+
path: string;
|
|
369
|
+
/** The literal it is compared with, or those of the array it is in. */
|
|
370
|
+
values: unknown[];
|
|
326
371
|
}
|
|
327
372
|
|
|
328
373
|
export interface Hover {
|
|
@@ -494,6 +539,32 @@ samples: unknown[],
|
|
|
494
539
|
overrides?: Record<string, SchemaOverride>,
|
|
495
540
|
): JsonSchema;
|
|
496
541
|
|
|
542
|
+
/** An override path the samples lack (see `missingOverridePaths`). */
|
|
543
|
+
export interface MissingOverridePath {
|
|
544
|
+
/** The path, as the overrides wrote it. */
|
|
545
|
+
path: string;
|
|
546
|
+
/** An existing path it most likely meant, such as `items[].type` for `items.type`. */
|
|
547
|
+
suggestion?: string;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* The paths of `overrides` that the samples lack, in path order: the fields `inferSchema`
|
|
552
|
+
* declares for them. A field may be declared on purpose, but a misspelt path does the same, so
|
|
553
|
+
* show them as warnings. Throws as `inferSchema` does for invalid samples or overrides; malformed
|
|
554
|
+
* paths are left out.
|
|
555
|
+
*/
|
|
556
|
+
export function missingOverridePaths(
|
|
557
|
+
samples: unknown[],
|
|
558
|
+
overrides: Record<string, SchemaOverride>,
|
|
559
|
+
): MissingOverridePath[];
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* `value` as a JSONata literal, to insert in place of a `ValueRequest`'s range: a string in
|
|
563
|
+
* `quote` when it can be, other values as JSON. Throws a `TypeError` for another quote, or a value
|
|
564
|
+
* without a JSON form (`undefined`, a function).
|
|
565
|
+
*/
|
|
566
|
+
export function valueLiteral(value: unknown, quote?: '"' | "'"): string;
|
|
567
|
+
|
|
497
568
|
|
|
498
569
|
|
|
499
570
|
/**
|
|
@@ -537,8 +608,10 @@ export interface InitOutput {
|
|
|
537
608
|
readonly languageservice_hover: (a: number, b: number, c: number, d: number) => any;
|
|
538
609
|
readonly languageservice_new: (a: number, b: number, c: number) => [number, number, number];
|
|
539
610
|
readonly languageservice_signatureHelp: (a: number, b: number, c: number, d: number) => any;
|
|
611
|
+
readonly missingOverridePaths: (a: any, b: any) => [number, number, number];
|
|
540
612
|
readonly parseRecover: (a: number, b: number) => any;
|
|
541
613
|
readonly unionReads: (a: any) => [number, number, number];
|
|
614
|
+
readonly valueLiteral: (a: any, b: number, c: number) => [number, number, number, number];
|
|
542
615
|
readonly version: () => [number, number];
|
|
543
616
|
readonly wasm_bindgen_b2e20306cf4cf84c___convert__closures_____invoke___js_sys_a01820d46f63e2f4___Array__core_37ee0ce0c4cd57d5___result__Result_wasm_bindgen_b2e20306cf4cf84c___JsValue__wasm_bindgen_b2e20306cf4cf84c___JsValue___false_: (a: number, b: number, c: any) => [number, number, number];
|
|
544
617
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|