@manifest-configuration-language/browser 0.3.23 → 0.3.24

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/mcl.wasm CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/mcl.wasm
3
- size: 97176173 bytes
4
- sha256: a72c3a90d2ef8199ae2d365a2038ff67344a114b74ac34b42f7d6ac9b6285cab
3
+ size: 97264725 bytes
4
+ sha256: 42920c29ca0da31afa4528ac787712f337151589e630aa06659e896e6d5dfb3c
package/dist/project.d.ts CHANGED
@@ -45,7 +45,7 @@ export interface RequestOptions {
45
45
  }
46
46
  export interface ProjectOperationOptions extends RequestOptions {
47
47
  entrypoint?: string;
48
- parameters?: Record<string, string>;
48
+ parameters?: Record<string, unknown>;
49
49
  }
50
50
  export interface PositionOptions {
51
51
  line: number;
@@ -8,12 +8,7 @@ export type Request = {
8
8
  oldPath?: ProjectPath;
9
9
  newPath?: ProjectPath;
10
10
  entrypoint?: ProjectPath2;
11
- /**
12
- * Runtime evaluation parameters. Only check, evaluate, and render operations accept parameters.
13
- */
14
- parameters?: {
15
- [k: string]: string;
16
- };
11
+ parameters?: RequestParameters;
17
12
  /**
18
13
  * UTF-8 entrypoint source, limited by the runtime.
19
14
  */
@@ -43,6 +38,12 @@ export interface CompletionPosition {
43
38
  line: number;
44
39
  character: number;
45
40
  }
41
+ /**
42
+ * Typed JSON runtime parameter values. Only check, evaluate, and render operations accept parameters.
43
+ */
44
+ export interface RequestParameters {
45
+ [k: string]: unknown;
46
+ }
46
47
  export interface Response {
47
48
  requestId: number;
48
49
  revision?: number;
package/dist/runtime.js CHANGED
@@ -1,6 +1,27 @@
1
1
  import PQueue from "p-queue";
2
2
  import * as Comlink from "comlink";
3
3
  import { createProjectSnapshot, computeProjectDelta, isValidProjectPath, operationPriorities, latestOnlyOperations, requestPriorities, maxSourceBytes, } from "./project.js";
4
+ function isJSONValue(value, ancestors = new Set()) {
5
+ if (value === null || typeof value === "string" || typeof value === "boolean")
6
+ return true;
7
+ if (typeof value === "number")
8
+ return Number.isFinite(value);
9
+ if (typeof value !== "object" || ancestors.has(value))
10
+ return false;
11
+ if (!Array.isArray(value)) {
12
+ const prototype = Object.getPrototypeOf(value);
13
+ if (prototype !== Object.prototype && prototype !== null)
14
+ return false;
15
+ if (Object.getOwnPropertySymbols(value).length > 0)
16
+ return false;
17
+ }
18
+ ancestors.add(value);
19
+ const valid = Array.isArray(value)
20
+ ? value.every((item) => isJSONValue(item, ancestors))
21
+ : Object.values(value).every((item) => isJSONValue(item, ancestors));
22
+ ancestors.delete(value);
23
+ return valid;
24
+ }
4
25
  // ---------------------------------------------------------------------------
5
26
  // Error class
6
27
  // ---------------------------------------------------------------------------
@@ -405,11 +426,11 @@ export function createMclRuntime(options = {}) {
405
426
  }
406
427
  const parameters = requestOptions.parameters;
407
428
  if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
408
- throw new TypeError("parameters must be an object with string values");
429
+ throw new TypeError("parameters must be an object with JSON values");
409
430
  }
410
431
  for (const value of Object.values(parameters)) {
411
- if (typeof value !== "string") {
412
- throw new TypeError("parameters must be an object with string values");
432
+ if (!isJSONValue(value)) {
433
+ throw new TypeError("parameters must be an object with JSON values");
413
434
  }
414
435
  }
415
436
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifest-configuration-language/browser",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "Run MCL projects in a browser Web Worker using the Go WebAssembly runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {