jlens-wasm 0.12.0 → 0.13.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/jlens.d.ts CHANGED
@@ -9,14 +9,24 @@ export type Bindings = Record<string, unknown>;
9
9
 
10
10
  /**
11
11
  * A JavaScript function called from an expression. Arguments and the result are converted
12
- * through JSON: `undefined` stands for undefined, and a function argument arrives as
13
- * `undefined`. `this` is `undefined`; use a signature with `-` to receive the context value.
12
+ * through JSON: `undefined` stands for undefined, and a function argument arrives as a
13
+ * `Callable`. `this` is `undefined`; use a signature with `-` to receive the context value.
14
14
  * Without a signature, `length` tells higher-order functions how many arguments to pass. An
15
15
  * exception it throws is rethrown by the evaluation, with the `position` and `token` of the call
16
16
  * when it has none. Returning a promise fails with `U1002`.
17
17
  */
18
18
  export type HostFunction = (...args: any[]) => unknown;
19
19
 
20
+ /**
21
+ * A JSONata function passed to a `HostFunction`, such as the lambda in `$retry(function() {...},
22
+ * 3)`. Calling it applies the function, synchronously, with the context value `null`: arguments
23
+ * and the result are converted through JSON, and a JavaScript function among the arguments
24
+ * becomes `undefined`. Its errors are thrown as a `JlensError` with their codes, or as the
25
+ * exception a host function threw. `length` is 0 and `arity` is the number of parameters, as in
26
+ * jsonata-js. Valid until the host function returns: calling it later throws `U1005`.
27
+ */
28
+ export type Callable = ((...args: any[]) => unknown) & { readonly arity: number };
29
+
20
30
  /** Evaluation guardrails, and the clock and seed that make an evaluation reproducible. */
21
31
  export interface EvaluateOptions {
22
32
  /** Maximum duration of one evaluation, in milliseconds (error `D1012`). */
@@ -478,6 +488,7 @@ export interface InitOutput {
478
488
  readonly languageservice_signatureHelp: (a: number, b: number, c: number, d: number) => any;
479
489
  readonly parseRecover: (a: number, b: number) => any;
480
490
  readonly version: () => [number, number];
491
+ readonly wasm_bindgen_e9b0c291ff1d8c5f___convert__closures_____invoke___js_sys_f23edf6acf2820d5___Array__core_608f92abc48d28da___result__Result_wasm_bindgen_e9b0c291ff1d8c5f___JsValue__wasm_bindgen_e9b0c291ff1d8c5f___JsValue___false_: (a: number, b: number, c: any) => [number, number, number];
481
492
  readonly __wbindgen_malloc: (a: number, b: number) => number;
482
493
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
483
494
  readonly __wbindgen_exn_store: (a: number) => void;
package/jlens.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* @ts-self-types="./jlens.d.ts" */
2
- import { jlensLevel } from './snippets/jlens-wasm-57db79c815b1e6d9/inline0.js';
2
+ import { jlensCallable } from './snippets/jlens-wasm-8f70bef341ac4aed/inline0.js';
3
+ import { jlensLevel } from './snippets/jlens-wasm-8f70bef341ac4aed/inline1.js';
3
4
 
4
5
 
5
6
  /**
@@ -370,6 +371,10 @@ function __wbg_get_imports() {
370
371
  const ret = arg0 === undefined;
371
372
  return ret;
372
373
  },
374
+ __wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
375
+ const ret = arg0 === arg1;
376
+ return ret;
377
+ },
373
378
  __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
374
379
  const obj = arg1;
375
380
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -381,10 +386,17 @@ function __wbg_get_imports() {
381
386
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
382
387
  throw new Error(getStringFromWasm0(arg0, arg1));
383
388
  },
389
+ __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
390
+ arg0._wbg_cb_unref();
391
+ },
384
392
  __wbg_apply_a910804df6e1e433: function() { return handleError(function (arg0, arg1, arg2) {
385
393
  const ret = arg0.apply(arg1, arg2);
386
394
  return ret;
387
395
  }, arguments); },
396
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
397
+ const ret = arg0.call(arg1, arg2);
398
+ return ret;
399
+ }, arguments); },
388
400
  __wbg_entries_fb6397112b1de25f: function(arg0) {
389
401
  const ret = Object.entries(arg0);
390
402
  return ret;
@@ -419,7 +431,11 @@ function __wbg_get_imports() {
419
431
  const ret = Array.isArray(arg0);
420
432
  return ret;
421
433
  },
422
- __wbg_jlensLevel_1c5c4649e804b1e8: function() { return handleError(function (arg0, arg1, arg2) {
434
+ __wbg_jlensCallable_06b1183d73f75f40: function(arg0, arg1) {
435
+ const ret = jlensCallable(arg0, arg1 >>> 0);
436
+ return ret;
437
+ },
438
+ __wbg_jlensLevel_541f3ed0b0472e8b: function() { return handleError(function (arg0, arg1, arg2) {
423
439
  const ret = jlensLevel(arg0, arg1 >>> 0, arg2 >>> 0);
424
440
  return ret;
425
441
  }, arguments); },
@@ -478,6 +494,9 @@ function __wbg_get_imports() {
478
494
  const ret = Reflect.set(arg0, arg1, arg2);
479
495
  return ret;
480
496
  }, arguments); },
497
+ __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
498
+ arg0[arg1 >>> 0] = arg2;
499
+ },
481
500
  __wbg_set_name_2c630595dc90a7aa: function(arg0, arg1, arg2) {
482
501
  arg0.name = getStringFromWasm0(arg1, arg2);
483
502
  },
@@ -501,12 +520,20 @@ function __wbg_get_imports() {
501
520
  const ret = JSON.stringify(arg0);
502
521
  return ret;
503
522
  }, arguments); },
504
- __wbindgen_generic_0000000000000001: function(arg0) {
523
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
524
+ var state0 = {a: arg0, b: arg1};
525
+ var cb0 = (arg0) => wasm_bindgen_e9b0c291ff1d8c5f___convert__closures_____invoke___js_sys_f23edf6acf2820d5___Array__core_608f92abc48d28da___result__Result_wasm_bindgen_e9b0c291ff1d8c5f___JsValue__wasm_bindgen_e9b0c291ff1d8c5f___JsValue___false_(state0.a, state0.b, arg0);
526
+ cb0._wbg_cb_unref = () => state0.a = 0;
527
+ // Cast intrinsic for `Closure(Closure { owned: false, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 10, ret: Result(Externref), inner_ret: Some(Result(Externref)) }, mutable: false }) -> Externref`.
528
+ const ret = cb0;
529
+ return ret;
530
+ },
531
+ __wbindgen_generic_0000000000000002: function(arg0) {
505
532
  // Cast intrinsic for `F64 -> Externref`.
506
533
  const ret = arg0;
507
534
  return ret;
508
535
  },
509
- __wbindgen_generic_0000000000000002: function(arg0, arg1) {
536
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
510
537
  // Cast intrinsic for `Ref(String) -> Externref`.
511
538
  const ret = getStringFromWasm0(arg0, arg1);
512
539
  return ret;
@@ -527,6 +554,14 @@ function __wbg_get_imports() {
527
554
  };
528
555
  }
529
556
 
557
+ function wasm_bindgen_e9b0c291ff1d8c5f___convert__closures_____invoke___js_sys_f23edf6acf2820d5___Array__core_608f92abc48d28da___result__Result_wasm_bindgen_e9b0c291ff1d8c5f___JsValue__wasm_bindgen_e9b0c291ff1d8c5f___JsValue___false_(arg0, arg1, arg2) {
558
+ const ret = wasm.wasm_bindgen_e9b0c291ff1d8c5f___convert__closures_____invoke___js_sys_f23edf6acf2820d5___Array__core_608f92abc48d28da___result__Result_wasm_bindgen_e9b0c291ff1d8c5f___JsValue__wasm_bindgen_e9b0c291ff1d8c5f___JsValue___false_(arg0, arg1, arg2);
559
+ if (ret[2]) {
560
+ throw takeFromExternrefTable0(ret[1]);
561
+ }
562
+ return takeFromExternrefTable0(ret[0]);
563
+ }
564
+
530
565
  const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
531
566
  ? { register: () => {}, unregister: () => {} }
532
567
  : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr, 1));
package/jlens_bg.wasm CHANGED
Binary file
@@ -23,6 +23,7 @@ export const languageservice_new: (a: number, b: number, c: number) => [number,
23
23
  export const languageservice_signatureHelp: (a: number, b: number, c: number, d: number) => any;
24
24
  export const parseRecover: (a: number, b: number) => any;
25
25
  export const version: () => [number, number];
26
+ export const wasm_bindgen_e9b0c291ff1d8c5f___convert__closures_____invoke___js_sys_f23edf6acf2820d5___Array__core_608f92abc48d28da___result__Result_wasm_bindgen_e9b0c291ff1d8c5f___JsValue__wasm_bindgen_e9b0c291ff1d8c5f___JsValue___false_: (a: number, b: number, c: any) => [number, number, number];
26
27
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
28
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
29
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jlens-wasm",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "JSONata in WebAssembly, with evaluation audits and schema-driven autocomplete",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,13 @@
1
+
2
+ // Wraps `inner`, which takes the arguments as an array, in a function with an `arity` property,
3
+ // as jsonata-js does. Returns the function, and a function that ends it: from then on, it throws
4
+ // the error given.
5
+ export function jlensCallable(inner, arity) {
6
+ let expired;
7
+ const callable = (...args) => {
8
+ if (expired) throw expired;
9
+ return inner(args);
10
+ };
11
+ callable.arity = arity;
12
+ return [callable, (error) => { expired = error; }];
13
+ }