@manifest-configuration-language/browser 0.3.26 → 0.3.28
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.d.ts +1 -1
- package/dist/mcl.wasm +2 -2
- package/dist/project.d.ts +4 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +28 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createMclRuntime, MclRuntimeError, } from "./runtime.js";
|
|
2
2
|
export type { MclOperation, MclResult, MclRuntime, MclProject, RuntimeStatus, RuntimeStatusEvent, RuntimeOperationOutcome, RuntimeOperationEvent, RuntimeOptions, } from "./runtime.js";
|
|
3
3
|
export { isValidProjectPath, isValidProjectFileSet, } from "./project.js";
|
|
4
|
-
export type { ProjectFile, ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions, } from "./project.js";
|
|
4
|
+
export type { ProjectFile, ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectParametersOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions, } from "./project.js";
|
|
5
5
|
export { maxSourceBytes, maxSourceMapBytes, maxRenameNameLength, maxProjectFiles, maxProjectFileBytes, maxProjectBytes, maxProjectPathLength, maxProjectPathDepth, } from "./limits.js";
|
|
6
6
|
export type { CheckResult, CompletionItem, CompletionPosition, CompletionResult, DefinitionLocation, DefinitionResult, EvaluateResult, FormatResult, HoverInfo, HoverResult, LintCodeAction, LintDiagnostic, ParseResult, ReferenceLocation, ReferencesResult, RelatedLocation, RenderResult, RenameEdit, RenameFileImportsResult, RenameResult, SourceMap, SourceMapEntry, SourceMapOrigin, SourceRange, } from "./protocol.js";
|
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:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 104721233 bytes
|
|
4
|
+
sha256: aeb536c104bb37ed92472901fadb6c842ed01f207115575edea64d787166d1dc
|
package/dist/project.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes } from "./limits.js";
|
|
2
|
-
import type { Request as WasmRequest } from "./protocol.js";
|
|
2
|
+
import type { Request as WasmRequest, RequestParameters } from "./protocol.js";
|
|
3
3
|
export type MclOperation = WasmRequest["operation"];
|
|
4
4
|
export { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes, };
|
|
5
5
|
/** Root-relative project files passed to MCL's in-memory session filesystem.
|
|
@@ -45,7 +45,9 @@ export interface RequestOptions {
|
|
|
45
45
|
}
|
|
46
46
|
export interface ProjectOperationOptions extends RequestOptions {
|
|
47
47
|
entrypoint?: string;
|
|
48
|
-
|
|
48
|
+
}
|
|
49
|
+
export interface ProjectParametersOptions extends ProjectOperationOptions {
|
|
50
|
+
parameters?: RequestParameters;
|
|
49
51
|
}
|
|
50
52
|
export interface PositionOptions {
|
|
51
53
|
line: number;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions } from "./project.js";
|
|
1
|
+
import type { ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectParametersOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions } from "./project.js";
|
|
2
2
|
import type { CheckResult, CompletionResult as ProtocolCompletionResult, DefinitionResult as ProtocolDefinitionResult, EvaluateResult, FormatResult, HoverResult as ProtocolHoverResult, LintDiagnostic as ProtocolLintDiagnostic, ParseResult, ReferencesResult as ProtocolReferencesResult, RenderResult, RenameResult as ProtocolRenameResult, RenameFileImportsResult as ProtocolRenameFileImportsResult, Request as WasmRequest, Error as ProtocolError } from "./protocol.js";
|
|
3
3
|
export type MclOperation = WasmRequest["operation"];
|
|
4
4
|
export type MclResult = ({
|
|
@@ -56,7 +56,7 @@ export interface MclProject {
|
|
|
56
56
|
set?: ProjectFiles;
|
|
57
57
|
delete?: string[];
|
|
58
58
|
}): MclProject;
|
|
59
|
-
run<O extends MclOperation>(operation: O, ...options: O extends "completion" ? [options: ProjectCompletionOptions] : O extends "definition" | "hover" | "references" ? [options: ProjectNavigationOptions] : O extends "rename" ? [options: ProjectRenameOptions] : O extends "renameFileImports" ? [options: ProjectFileRenameOptions] : [options?: ProjectOperationOptions]): Promise<Extract<MclResult, {
|
|
59
|
+
run<O extends MclOperation>(operation: O, ...options: O extends "completion" ? [options: ProjectCompletionOptions] : O extends "definition" | "hover" | "references" ? [options: ProjectNavigationOptions] : O extends "rename" ? [options: ProjectRenameOptions] : O extends "check" | "evaluate" | "render" ? [options?: ProjectParametersOptions] : O extends "renameFileImports" ? [options: ProjectFileRenameOptions] : [options?: ProjectOperationOptions]): Promise<Extract<MclResult, {
|
|
60
60
|
operation: O;
|
|
61
61
|
}>>;
|
|
62
62
|
}
|
package/dist/runtime.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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
|
-
|
|
4
|
+
const maxParameterBytes = 1_048_576;
|
|
5
|
+
const maxParameterDepth = 64;
|
|
6
|
+
function isJSONValue(value, ancestors = new Set(), depth = 0) {
|
|
5
7
|
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
6
8
|
return true;
|
|
7
9
|
if (typeof value === "number")
|
|
8
10
|
return Number.isFinite(value);
|
|
9
|
-
if (typeof value !== "object" || ancestors.has(value))
|
|
11
|
+
if (typeof value !== "object" || ancestors.has(value) || depth >= maxParameterDepth)
|
|
10
12
|
return false;
|
|
11
13
|
if (!Array.isArray(value)) {
|
|
12
14
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -16,9 +18,19 @@ function isJSONValue(value, ancestors = new Set()) {
|
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
20
|
ancestors.add(value);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
let valid;
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
valid = true;
|
|
24
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
25
|
+
if (!Object.hasOwn(value, index) || !isJSONValue(value[index], ancestors, depth + 1)) {
|
|
26
|
+
valid = false;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
valid = Object.values(value).every((item) => isJSONValue(item, ancestors, depth + 1));
|
|
33
|
+
}
|
|
22
34
|
ancestors.delete(value);
|
|
23
35
|
return valid;
|
|
24
36
|
}
|
|
@@ -241,7 +253,6 @@ export function createMclRuntime(options = {}) {
|
|
|
241
253
|
else if (data?.type === "fatal") {
|
|
242
254
|
const error = new Error(typeof data.message === "string" ? data.message : "MCL WebAssembly exited unexpectedly");
|
|
243
255
|
if (initialized) {
|
|
244
|
-
emitStatus("error");
|
|
245
256
|
terminateWorker(error);
|
|
246
257
|
}
|
|
247
258
|
else
|
|
@@ -255,7 +266,6 @@ export function createMclRuntime(options = {}) {
|
|
|
255
266
|
return;
|
|
256
267
|
const error = new Error(event.message || "MCL worker failed");
|
|
257
268
|
if (initialized) {
|
|
258
|
-
emitStatus("error");
|
|
259
269
|
terminateWorker(error);
|
|
260
270
|
}
|
|
261
271
|
else
|
|
@@ -268,7 +278,6 @@ export function createMclRuntime(options = {}) {
|
|
|
268
278
|
return;
|
|
269
279
|
const error = new Error("MCL worker sent a malformed message");
|
|
270
280
|
if (initialized) {
|
|
271
|
-
emitStatus("error");
|
|
272
281
|
terminateWorker(error);
|
|
273
282
|
}
|
|
274
283
|
else
|
|
@@ -288,8 +297,6 @@ export function createMclRuntime(options = {}) {
|
|
|
288
297
|
function fail(error) {
|
|
289
298
|
if (rawWorker !== currentRawWorker)
|
|
290
299
|
return;
|
|
291
|
-
if (!initialized)
|
|
292
|
-
reportStatus("error");
|
|
293
300
|
clearTimeout(timer);
|
|
294
301
|
if (stopInitialization === fail)
|
|
295
302
|
stopInitialization = undefined;
|
|
@@ -317,6 +324,8 @@ export function createMclRuntime(options = {}) {
|
|
|
317
324
|
}
|
|
318
325
|
function terminateWorker(error) {
|
|
319
326
|
const currentWorker = rawWorker;
|
|
327
|
+
if (!currentWorker)
|
|
328
|
+
return;
|
|
320
329
|
const currentApi = workerApi;
|
|
321
330
|
const currentStop = stopCurrent;
|
|
322
331
|
const cleanup = cleanupWorkerListeners;
|
|
@@ -327,6 +336,8 @@ export function createMclRuntime(options = {}) {
|
|
|
327
336
|
workerProjectId = undefined;
|
|
328
337
|
workerSnapshot = undefined;
|
|
329
338
|
stopCurrent = undefined;
|
|
339
|
+
if (!disposed && error.name !== "AbortError")
|
|
340
|
+
emitStatus("error");
|
|
330
341
|
cleanup?.();
|
|
331
342
|
currentWorker?.terminate();
|
|
332
343
|
currentApi?.[Comlink.releaseProxy]();
|
|
@@ -427,13 +438,15 @@ export function createMclRuntime(options = {}) {
|
|
|
427
438
|
throw new TypeError("parameters are only valid for check, evaluate, and render operations");
|
|
428
439
|
}
|
|
429
440
|
const parameters = requestOptions.parameters;
|
|
430
|
-
if (parameters === null ||
|
|
441
|
+
if (parameters === null ||
|
|
442
|
+
typeof parameters !== "object" ||
|
|
443
|
+
Array.isArray(parameters) ||
|
|
444
|
+
!isJSONValue(parameters)) {
|
|
431
445
|
throw new TypeError("parameters must be an object with JSON values");
|
|
432
446
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
447
|
+
const serializedParameters = JSON.stringify(parameters);
|
|
448
|
+
if (new TextEncoder().encode(serializedParameters).byteLength > maxParameterBytes) {
|
|
449
|
+
throw new RangeError(`parameters exceed the ${maxParameterBytes}-byte limit`);
|
|
437
450
|
}
|
|
438
451
|
}
|
|
439
452
|
// Validate renameFileImports paths eagerly so we never spin up a Worker.
|
package/package.json
CHANGED