jlens-wasm 0.28.0 → 0.29.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 +55 -2
- 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-42b64bd3dd101627}/inline0.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-42b64bd3dd101627}/inline1.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-42b64bd3dd101627}/inline2.js +0 -0
- /package/snippets/{jlens-wasm-fdf4592b28db92a8 → jlens-wasm-42b64bd3dd101627}/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,18 @@ 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
|
type?: JsonType[];
|
|
305
310
|
examples?: unknown[];
|
|
306
311
|
}
|
|
307
312
|
|
|
308
|
-
|
|
313
|
+
/** `value`: a value of the `enum` or `const` of the left-hand side of `=`, `!=` or `in`. */
|
|
314
|
+
export type CompletionKind = "field" | "variable" | "function" | "keyword" | "operator" | "value";
|
|
309
315
|
|
|
310
316
|
export interface CompletionItem {
|
|
311
317
|
label: string;
|
|
@@ -319,10 +325,29 @@ export interface CompletionItem {
|
|
|
319
325
|
}
|
|
320
326
|
|
|
321
327
|
export interface Completions {
|
|
322
|
-
/** The range the chosen item replaces (the word under the cursor). */
|
|
328
|
+
/** The range the chosen item replaces (the word under the cursor, or the whole string literal). */
|
|
323
329
|
range: Span;
|
|
324
330
|
/** Best first. */
|
|
325
331
|
items: CompletionItem[];
|
|
332
|
+
/**
|
|
333
|
+
* Present where a value of an open domain (`x-jlens-domain`) completes the expression: the
|
|
334
|
+
* application fetches the domain's values and offers them beside `items`.
|
|
335
|
+
*/
|
|
336
|
+
valueRequest?: ValueRequest;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** A request for the values of an open domain, at the right of `=`, `!=` or `in`. */
|
|
340
|
+
export interface ValueRequest {
|
|
341
|
+
/** The domain's identifier, as the schema declares it. */
|
|
342
|
+
domain: string;
|
|
343
|
+
/** The left-hand side's path in the schema, such as `items[].type`; absent for a variable. */
|
|
344
|
+
path?: string;
|
|
345
|
+
/** What is typed so far: the word, or a string literal's text up to the cursor (as written). */
|
|
346
|
+
prefix: string;
|
|
347
|
+
/** The range a value replaces: the same as `Completions.range`. */
|
|
348
|
+
range: Span;
|
|
349
|
+
/** The quote to write a string value with (pass it to `valueLiteral`). */
|
|
350
|
+
quote: '"' | "'";
|
|
326
351
|
}
|
|
327
352
|
|
|
328
353
|
export interface Hover {
|
|
@@ -494,6 +519,32 @@ samples: unknown[],
|
|
|
494
519
|
overrides?: Record<string, SchemaOverride>,
|
|
495
520
|
): JsonSchema;
|
|
496
521
|
|
|
522
|
+
/** An override path the samples lack (see `missingOverridePaths`). */
|
|
523
|
+
export interface MissingOverridePath {
|
|
524
|
+
/** The path, as the overrides wrote it. */
|
|
525
|
+
path: string;
|
|
526
|
+
/** An existing path it most likely meant, such as `items[].type` for `items.type`. */
|
|
527
|
+
suggestion?: string;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* The paths of `overrides` that the samples lack, in path order: the fields `inferSchema`
|
|
532
|
+
* declares for them. A field may be declared on purpose, but a misspelt path does the same, so
|
|
533
|
+
* show them as warnings. Throws as `inferSchema` does for invalid samples or overrides; malformed
|
|
534
|
+
* paths are left out.
|
|
535
|
+
*/
|
|
536
|
+
export function missingOverridePaths(
|
|
537
|
+
samples: unknown[],
|
|
538
|
+
overrides: Record<string, SchemaOverride>,
|
|
539
|
+
): MissingOverridePath[];
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* `value` as a JSONata literal, to insert in place of a `ValueRequest`'s range: a string in
|
|
543
|
+
* `quote` when it can be, other values as JSON. Throws a `TypeError` for another quote, or a value
|
|
544
|
+
* without a JSON form (`undefined`, a function).
|
|
545
|
+
*/
|
|
546
|
+
export function valueLiteral(value: unknown, quote?: '"' | "'"): string;
|
|
547
|
+
|
|
497
548
|
|
|
498
549
|
|
|
499
550
|
/**
|
|
@@ -537,8 +588,10 @@ export interface InitOutput {
|
|
|
537
588
|
readonly languageservice_hover: (a: number, b: number, c: number, d: number) => any;
|
|
538
589
|
readonly languageservice_new: (a: number, b: number, c: number) => [number, number, number];
|
|
539
590
|
readonly languageservice_signatureHelp: (a: number, b: number, c: number, d: number) => any;
|
|
591
|
+
readonly missingOverridePaths: (a: any, b: any) => [number, number, number];
|
|
540
592
|
readonly parseRecover: (a: number, b: number) => any;
|
|
541
593
|
readonly unionReads: (a: any) => [number, number, number];
|
|
594
|
+
readonly valueLiteral: (a: any, b: number, c: number) => [number, number, number, number];
|
|
542
595
|
readonly version: () => [number, number];
|
|
543
596
|
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
597
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|