@manifest-configuration-language/browser 0.3.22 → 0.3.23

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 CHANGED
@@ -12,7 +12,7 @@ try {
12
12
  "main.mcl": source,
13
13
  "values.json": JSON.stringify(values),
14
14
  });
15
- const result = await project.render({ entrypoint: "main.mcl" });
15
+ const result = await project.run("render", { entrypoint: "main.mcl" });
16
16
  console.log(result.yaml);
17
17
  } finally {
18
18
  runtime.dispose();
@@ -25,13 +25,13 @@ Call `runtime.warmUp()` to load the WebAssembly runtime before the first project
25
25
 
26
26
  Project files can be UTF-8 strings or `Uint8Array` values. UTF-8 files remain inline in project updates. The Browser SDK copies each changed `Uint8Array` and transfers its buffer to the Worker; the Worker sends only `{ "encoding": "binary" }` metadata in the update JSON and passes a path-to-`Uint8Array` map to the Go/WASM project session. The Go runtime copies those bytes into its bounded project filesystem. The SDK-owned and caller-owned arrays remain reusable after each update.
27
27
 
28
- An open project is a Worker-backed session. Call `project.update(files)` with the complete next snapshot when project files change, then use the returned project handle for subsequent operations. The SDK validates changed files, sends only changed, added, and removed files to the Worker, and applies those deltas to a bounded in-memory Go/WASM filesystem. Each operation sends its entrypoint source and session ID; the project filesystem is not resent or rebuilt. If a canceled or timed-out operation terminates the Worker, the next operation restores the complete snapshot before running. Existing `runtime.parse`, `runtime.render`, and other source-based methods continue to use per-request files.
28
+ An open project is a Worker-backed immutable snapshot. Call `project.patch({ set, delete })` with only changed and removed files, then use the returned project handle for subsequent operations. `project.run(operation, options)` accepts any protocol operation and returns its operation-specific result. The SDK validates changed files, sends only changed, added, and removed files to the Worker, and applies those deltas to a bounded in-memory Go/WASM filesystem. Each operation sends its entrypoint source and session ID; the project filesystem is not resent or rebuilt. If a canceled or timed-out operation terminates the Worker, the next operation restores the complete snapshot before running.
29
29
 
30
- `runtime.render` returns a `sourceMap` alongside the YAML. Each entry identifies a YAML document, a JSON Pointer within that document, and whether the output range covers a key or value. Source ranges use zero-based UTF-16 line and character positions with an exclusive end, matching LSP and CodeMirror positions; the engine converts its internal UTF-8 byte offsets before returning them. Source paths are project-relative. The source map is limited by `maxSourceMapBytes`; `sourceMap.complete` is false when the map was truncated or an MCL source range could not be resolved.
30
+ `project.run("render")` returns a `sourceMap` alongside the YAML. Each entry identifies a YAML document, a JSON Pointer within that document, and whether the output range covers a key or value. Source ranges use zero-based UTF-16 line and character positions with an exclusive end, matching LSP and CodeMirror positions; the engine converts its internal UTF-8 byte offsets before returning them. Source paths are project-relative. The source map is limited by `maxSourceMapBytes`; `sourceMap.complete` is false when the map was truncated or an MCL source range could not be resolved.
31
31
 
32
- `project.complete({ entrypoint, position })` returns the MCL language-service candidates for a zero-based UTF-16 position. Completion uses the same local project files as parsing and rendering, including schemas and Helm values schemas. It does not access a Kubernetes API server or any other network service.
32
+ `project.run("completion", { entrypoint, position })` returns the MCL language-service candidates for a zero-based UTF-16 position. Completion uses the same local project files as parsing and rendering, including schemas and Helm values schemas. It does not access a Kubernetes API server or any other network service.
33
33
 
34
- `project.definition({ entrypoint, position })` returns a project-relative declaration path and zero-based UTF-16 range for local and imported MCL declarations. `project.hover({ entrypoint, position })` returns declaration syntax, including explicit type annotations and function or rule signatures. `project.references({ entrypoint, position })` returns the declaration and references found in the supplied MCL project. `project.renameFileImports({ oldPath, newPath, entrypoint })` returns import-path edits needed when an MCL file moves. These operations use only project files already supplied to the browser runtime.
34
+ `project.run("definition", { entrypoint, position })` returns a project-relative declaration path and zero-based UTF-16 range for local and imported MCL declarations. `project.run("hover", { entrypoint, position })` returns declaration syntax, including explicit type annotations and function or rule signatures. `project.run("references", { entrypoint, position })` returns the declaration and references found in the supplied MCL project. `project.run("renameFileImports", { oldPath, newPath, entrypoint })` returns import-path edits needed when an MCL file moves. These operations use only project files already supplied to the browser runtime.
35
35
 
36
36
  The package exports the completion, definition, hover, references, rename, file-import rename, and source map result types, `maxSourceBytes`, `maxSourceMapBytes`, `maxRenameNameLength`, `maxProjectFiles`, `maxProjectFileBytes`, and `maxProjectBytes` so browser interfaces can consume the runtime's public types and limits. `isValidProjectFileSet(paths)` checks path validity, duplicate paths, and file/directory conflicts before a UI creates or renames project files. `rename()` returns edits for local symbols and exported declarations, including qualified value and type references in the supplied MCL project. It returns no edits when a rename would be ambiguous or collide with an existing exported declaration. `renameFileImports()` returns an error if any project MCL file has a syntax error because its import references cannot be determined safely.
37
37
 
@@ -0,0 +1,6 @@
1
+ export { createMclRuntime, MclRuntimeError, } from "./runtime.js";
2
+ export type { MclOperation, MclResult, MclRuntime, MclProject, RuntimeStatus, RuntimeStatusEvent, RuntimeOperationOutcome, RuntimeOperationEvent, RuntimeOptions, } from "./runtime.js";
3
+ export { isValidProjectPath, isValidProjectFileSet, } from "./project.js";
4
+ export type { ProjectFile, ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions, } from "./project.js";
5
+ export { maxSourceBytes, maxSourceMapBytes, maxRenameNameLength, maxProjectFiles, maxProjectFileBytes, maxProjectBytes, maxProjectPathLength, maxProjectPathDepth, } from "./limits.js";
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/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Public API for @manifest-configuration-language/browser
2
+ export { createMclRuntime, MclRuntimeError, } from "./runtime.js";
3
+ export { isValidProjectPath, isValidProjectFileSet, } from "./project.js";
4
+ export { maxSourceBytes, maxSourceMapBytes, maxRenameNameLength, maxProjectFiles, maxProjectFileBytes, maxProjectBytes, maxProjectPathLength, maxProjectPathDepth, } from "./limits.js";
@@ -0,0 +1,10 @@
1
+ export declare const maxSourceBytes = 65536;
2
+ export declare const maxProjectFiles = 4096;
3
+ export declare const maxProjectFileBytes = 16777216;
4
+ export declare const maxProjectBytes = 67108864;
5
+ export declare const maxOutputBytes = 1048576;
6
+ export declare const maxSourceMapBytes = 1048576;
7
+ export declare const maxRenameNameLength = 256;
8
+ export declare const evaluationTimeoutMillis = 4000;
9
+ export declare const maxProjectPathLength = 512;
10
+ export declare const maxProjectPathDepth = 64;
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: 96964277 bytes
4
- sha256: 8c86389ea0079e7915a5121d0629406bfc21cc265a7c1634a65f5087f7930965
3
+ size: 97176173 bytes
4
+ sha256: a72c3a90d2ef8199ae2d365a2038ff67344a114b74ac34b42f7d6ac9b6285cab
@@ -0,0 +1,66 @@
1
+ import { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes } from "./limits.js";
2
+ import type { Request as WasmRequest } from "./protocol.js";
3
+ export type MclOperation = WasmRequest["operation"];
4
+ export { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes, };
5
+ /** Root-relative project files passed to MCL's in-memory session filesystem.
6
+ * Uint8Array values are copied before transfer so callers can reuse them. */
7
+ export type ProjectFile = string | Uint8Array;
8
+ export type ProjectFiles = Readonly<Record<string, ProjectFile>>;
9
+ export declare function isValidProjectPath(value: unknown): value is string;
10
+ export declare function isValidProjectFileSet(paths: readonly string[]): boolean;
11
+ export interface ProjectSnapshot {
12
+ readonly files: Readonly<Record<string, ProjectFile>>;
13
+ readonly sizes: Readonly<Record<string, number>>;
14
+ readonly defaultEntrypoint: string | undefined;
15
+ }
16
+ export declare function createProjectSnapshot(files: ProjectFiles, previous?: ProjectSnapshot): ProjectSnapshot;
17
+ export interface FileDelta {
18
+ encoding: "utf8" | "binary";
19
+ content?: string;
20
+ }
21
+ export interface ProjectDelta {
22
+ reset: boolean;
23
+ files: Record<string, FileDelta>;
24
+ deleted: string[];
25
+ }
26
+ /**
27
+ * Compute the minimal delta between `previous` and `next` snapshots.
28
+ * Returns `null` if there is nothing to send (no changes).
29
+ */
30
+ export declare function computeProjectDelta(next: ProjectSnapshot, previous: ProjectSnapshot | undefined, reset: boolean): {
31
+ delta: ProjectDelta;
32
+ binaryFiles: Record<string, Uint8Array>;
33
+ transferables: ArrayBuffer[];
34
+ } | null;
35
+ export declare const operationPriorities: Record<string, number>;
36
+ export declare const latestOnlyOperations: Set<string>;
37
+ export declare const requestPriorities: {
38
+ readonly interactive: 40;
39
+ readonly background: 0;
40
+ };
41
+ export interface RequestOptions {
42
+ signal?: AbortSignal;
43
+ timeoutMs?: number;
44
+ priority?: "interactive" | "background";
45
+ }
46
+ export interface ProjectOperationOptions extends RequestOptions {
47
+ entrypoint?: string;
48
+ parameters?: Record<string, string>;
49
+ }
50
+ export interface PositionOptions {
51
+ line: number;
52
+ character: number;
53
+ }
54
+ export interface ProjectCompletionOptions extends ProjectOperationOptions {
55
+ position: PositionOptions;
56
+ }
57
+ export interface ProjectNavigationOptions extends ProjectOperationOptions {
58
+ position: PositionOptions;
59
+ }
60
+ export interface ProjectRenameOptions extends ProjectNavigationOptions {
61
+ newName: string;
62
+ }
63
+ export interface ProjectFileRenameOptions extends ProjectOperationOptions {
64
+ oldPath: string;
65
+ newPath: string;
66
+ }
@@ -0,0 +1,170 @@
1
+ import { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes, } from "./limits.js";
2
+ export { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes, };
3
+ // ---------------------------------------------------------------------------
4
+ // Path validation helpers (exported for callers such as website)
5
+ // ---------------------------------------------------------------------------
6
+ export function isValidProjectPath(value) {
7
+ if (typeof value !== "string" ||
8
+ value.length === 0 ||
9
+ value.startsWith("/") ||
10
+ /^[a-z]:/i.test(value) ||
11
+ value.includes("\\") ||
12
+ value.includes("\0")) {
13
+ return false;
14
+ }
15
+ let pathLength = 0;
16
+ let pathDepth = 1;
17
+ for (const character of value) {
18
+ if (++pathLength > maxProjectPathLength)
19
+ return false;
20
+ if (character === "/" && ++pathDepth > maxProjectPathDepth)
21
+ return false;
22
+ }
23
+ return value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
24
+ }
25
+ export function isValidProjectFileSet(paths) {
26
+ if (!Array.isArray(paths))
27
+ return false;
28
+ const files = new Set();
29
+ const directories = new Set();
30
+ for (const filePath of paths) {
31
+ if (!isValidProjectPath(filePath) || files.has(filePath) || directories.has(filePath))
32
+ return false;
33
+ let separator = filePath.indexOf("/");
34
+ while (separator !== -1) {
35
+ const directory = filePath.slice(0, separator);
36
+ if (files.has(directory))
37
+ return false;
38
+ directories.add(directory);
39
+ separator = filePath.indexOf("/", separator + 1);
40
+ }
41
+ files.add(filePath);
42
+ }
43
+ return true;
44
+ }
45
+ function sameContent(left, right) {
46
+ if (left === right)
47
+ return true;
48
+ if (typeof left !== typeof right)
49
+ return false;
50
+ if (typeof left === "string")
51
+ return left === right;
52
+ const l = left;
53
+ const r = right;
54
+ if (l.byteLength !== r.byteLength)
55
+ return false;
56
+ for (let index = 0; index < l.byteLength; index++) {
57
+ if (l[index] !== r[index])
58
+ return false;
59
+ }
60
+ return true;
61
+ }
62
+ export function createProjectSnapshot(files, previous) {
63
+ const entries = Object.entries(files);
64
+ if (entries.length === 0)
65
+ throw new TypeError("Project must contain at least one MCL source file");
66
+ if (entries.length > maxProjectFiles)
67
+ throw new RangeError(`Project has more than ${maxProjectFiles} files`);
68
+ if (!isValidProjectFileSet(entries.map(([filePath]) => filePath)))
69
+ throw new TypeError("Project file paths must be valid and cannot conflict with a file or directory path");
70
+ let totalBytes = 0;
71
+ const projectFiles = Object.create(null);
72
+ const fileSizes = Object.create(null);
73
+ for (const [filePath, input] of entries) {
74
+ if (typeof input !== "string" && !(input instanceof Uint8Array))
75
+ throw new TypeError(`Project file ${filePath} must be a string or Uint8Array`);
76
+ const previousContent = previous?.files[filePath];
77
+ const unchanged = previousContent !== undefined && sameContent(previousContent, input);
78
+ const content = unchanged
79
+ ? previousContent
80
+ : typeof input === "string"
81
+ ? input
82
+ : new Uint8Array(input);
83
+ const fileBytes = unchanged
84
+ ? previous.sizes[filePath]
85
+ : typeof content === "string"
86
+ ? new TextEncoder().encode(content).byteLength
87
+ : content.byteLength;
88
+ if (!unchanged && fileBytes > maxProjectFileBytes)
89
+ throw new RangeError(`Project file ${filePath} exceeds the ${maxProjectFileBytes}-byte limit`);
90
+ totalBytes += fileBytes;
91
+ if (totalBytes > maxProjectBytes)
92
+ throw new RangeError(`Project files exceed the ${maxProjectBytes}-byte limit`);
93
+ projectFiles[filePath] = content;
94
+ fileSizes[filePath] = fileBytes;
95
+ }
96
+ const sourcePaths = Object.keys(projectFiles)
97
+ .filter((filePath) => filePath.endsWith(".mcl"))
98
+ .sort();
99
+ if (sourcePaths.length === 0)
100
+ throw new TypeError("Project must contain at least one MCL source file");
101
+ const defaultEntrypoint = Object.hasOwn(projectFiles, "main.mcl")
102
+ ? "main.mcl"
103
+ : sourcePaths.length === 1
104
+ ? sourcePaths[0]
105
+ : undefined;
106
+ return Object.freeze({
107
+ files: Object.freeze(projectFiles),
108
+ sizes: Object.freeze(fileSizes),
109
+ defaultEntrypoint,
110
+ });
111
+ }
112
+ /**
113
+ * Compute the minimal delta between `previous` and `next` snapshots.
114
+ * Returns `null` if there is nothing to send (no changes).
115
+ */
116
+ export function computeProjectDelta(next, previous, reset) {
117
+ const previousFiles = reset || !previous ? Object.create(null) : previous.files;
118
+ const updates = Object.create(null);
119
+ const binaryFiles = Object.create(null);
120
+ const transferables = [];
121
+ const deleted = [];
122
+ for (const [filePath, content] of Object.entries(next.files)) {
123
+ if (!reset &&
124
+ previous &&
125
+ Object.hasOwn(previousFiles, filePath) &&
126
+ sameContent(previousFiles[filePath], content))
127
+ continue;
128
+ if (typeof content === "string") {
129
+ updates[filePath] = { encoding: "utf8", content };
130
+ }
131
+ else {
132
+ const copy = new Uint8Array(content);
133
+ updates[filePath] = { encoding: "binary" };
134
+ binaryFiles[filePath] = copy;
135
+ transferables.push(copy.buffer);
136
+ }
137
+ }
138
+ if (!reset && previous) {
139
+ for (const filePath of Object.keys(previous.files)) {
140
+ if (!Object.hasOwn(next.files, filePath))
141
+ deleted.push(filePath);
142
+ }
143
+ }
144
+ if (!reset && Object.keys(updates).length === 0 && deleted.length === 0)
145
+ return null;
146
+ return {
147
+ delta: { reset, files: updates, deleted },
148
+ binaryFiles,
149
+ transferables,
150
+ };
151
+ }
152
+ // ---------------------------------------------------------------------------
153
+ // Operation metadata
154
+ // ---------------------------------------------------------------------------
155
+ export const operationPriorities = {
156
+ render: 30,
157
+ evaluate: 30,
158
+ check: 30,
159
+ parse: 20,
160
+ format: 20,
161
+ rename: 20,
162
+ renameFileImports: 20,
163
+ references: 20,
164
+ definition: 20,
165
+ completion: 20,
166
+ hover: 20,
167
+ lint: 10,
168
+ };
169
+ export const latestOnlyOperations = new Set(["completion", "hover", "lint"]);
170
+ export const requestPriorities = { interactive: 40, background: 0 };
@@ -0,0 +1,185 @@
1
+ export type MCLWebAssemblyRequestAndResponseProtocol = Request | Response;
2
+ export type Request = {
3
+ requestId?: number;
4
+ revision?: number;
5
+ operation: "parse" | "lint" | "format" | "check" | "evaluate" | "render" | "completion" | "definition" | "hover" | "references" | "rename" | "renameFileImports";
6
+ position?: CompletionPosition;
7
+ newName?: string;
8
+ oldPath?: ProjectPath;
9
+ newPath?: ProjectPath;
10
+ entrypoint?: ProjectPath2;
11
+ /**
12
+ * Runtime evaluation parameters. Only check, evaluate, and render operations accept parameters.
13
+ */
14
+ parameters?: {
15
+ [k: string]: string;
16
+ };
17
+ /**
18
+ * UTF-8 entrypoint source, limited by the runtime.
19
+ */
20
+ source: string;
21
+ /**
22
+ * Project files are limited by the runtime; this count excludes the entrypoint.
23
+ */
24
+ files?: {
25
+ [k: string]: FileInput;
26
+ };
27
+ };
28
+ export type ProjectPath = ProjectPath1;
29
+ export type ProjectPath1 = string;
30
+ /**
31
+ * Project-relative MCL source path. Defaults to main.mcl.
32
+ */
33
+ export type ProjectPath2 = string;
34
+ /**
35
+ * Binary files omit content and are supplied in the optional second run argument under the same path.
36
+ */
37
+ export type FileInput = {
38
+ encoding: "utf8" | "binary";
39
+ content?: string;
40
+ };
41
+ export type LintResult = LintDiagnostic[];
42
+ export interface CompletionPosition {
43
+ line: number;
44
+ character: number;
45
+ }
46
+ export interface Response {
47
+ requestId: number;
48
+ revision?: number;
49
+ ok: boolean;
50
+ result?: ParseResult | LintResult | FormatResult | CheckResult | EvaluateResult | RenderResult | CompletionResult | DefinitionResult | HoverResult | ReferencesResult | RenameResult | RenameFileImportsResult;
51
+ error?: Error;
52
+ }
53
+ export interface ParseResult {
54
+ declarations: number;
55
+ }
56
+ export interface LintDiagnostic {
57
+ code: string;
58
+ message: string;
59
+ severity: string;
60
+ path: string;
61
+ line: number;
62
+ column: number;
63
+ endLine: number;
64
+ endColumn: number;
65
+ actions?: LintCodeAction[];
66
+ }
67
+ export interface LintCodeAction {
68
+ kind: "removeUnreachableDefinition";
69
+ /**
70
+ * @minItems 1
71
+ */
72
+ edits: [RenameEdit, ...RenameEdit[]];
73
+ }
74
+ export interface RenameEdit {
75
+ path: ProjectPath;
76
+ range: SourceRange;
77
+ newText: string;
78
+ }
79
+ export interface SourceRange {
80
+ start: CompletionPosition;
81
+ end: CompletionPosition;
82
+ }
83
+ export interface FormatResult {
84
+ source: string;
85
+ }
86
+ export interface CheckResult {
87
+ valid: true;
88
+ artifacts: number;
89
+ }
90
+ export interface EvaluateResult {
91
+ artifacts: number;
92
+ renderedBytes: number;
93
+ }
94
+ export interface RenderResult {
95
+ yaml: string;
96
+ artifacts: number;
97
+ sourceMap: SourceMap;
98
+ }
99
+ /**
100
+ * Source map entries are limited by maxSourceMapBytes. Ranges use zero-based UTF-16 line and character positions with an exclusive end.
101
+ */
102
+ export interface SourceMap {
103
+ complete: boolean;
104
+ entries: SourceMapEntry[];
105
+ }
106
+ export interface SourceMapEntry {
107
+ document: number;
108
+ /**
109
+ * JSON Pointer into the rendered YAML document.
110
+ */
111
+ path: string;
112
+ kind: "key" | "value";
113
+ output: SourceRange;
114
+ sources: SourceMapOrigin[];
115
+ }
116
+ export interface SourceMapOrigin {
117
+ path: ProjectPath;
118
+ range: SourceRange;
119
+ kind: "mcl" | "mcl-overlay-base" | "mcl-overlay-patch";
120
+ multiplicity: "unique" | "repeated" | "ambiguous";
121
+ occurrences: number;
122
+ }
123
+ export interface CompletionResult {
124
+ isIncomplete: boolean;
125
+ items: CompletionItem[];
126
+ }
127
+ export interface CompletionItem {
128
+ label: string;
129
+ kind: number;
130
+ insertText?: string;
131
+ detail?: string;
132
+ documentation?: string;
133
+ }
134
+ export interface DefinitionResult {
135
+ location: DefinitionLocation | null;
136
+ }
137
+ export interface DefinitionLocation {
138
+ path: string;
139
+ range: SourceRange;
140
+ }
141
+ export interface HoverResult {
142
+ hover: HoverInfo | null;
143
+ }
144
+ export interface HoverInfo {
145
+ contents: string;
146
+ range: SourceRange;
147
+ standardLibrary?: StandardLibraryFunction;
148
+ }
149
+ export interface StandardLibraryFunction {
150
+ module: string;
151
+ name: string;
152
+ }
153
+ export interface ReferencesResult {
154
+ references: ReferenceLocation[];
155
+ }
156
+ export interface ReferenceLocation {
157
+ path: ProjectPath;
158
+ range: SourceRange;
159
+ }
160
+ export interface RenameResult {
161
+ edits: RenameEdit[];
162
+ }
163
+ export interface RenameFileImportsResult {
164
+ oldPath: ProjectPath;
165
+ newPath: ProjectPath;
166
+ edits: RenameEdit[];
167
+ }
168
+ export interface Error {
169
+ code: string;
170
+ message: string;
171
+ path?: string;
172
+ line?: number;
173
+ column?: number;
174
+ endLine?: number;
175
+ endColumn?: number;
176
+ related?: RelatedLocation[];
177
+ }
178
+ export interface RelatedLocation {
179
+ path: string;
180
+ message: string;
181
+ line: number;
182
+ column: number;
183
+ endLine: number;
184
+ endColumn: number;
185
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from cmd/mcl-wasm/protocol.schema.json. Do not edit. */
2
+ export {};
@@ -0,0 +1,81 @@
1
+ import type { ProjectFiles, RequestOptions, ProjectOperationOptions, ProjectCompletionOptions, ProjectNavigationOptions, ProjectRenameOptions, ProjectFileRenameOptions } from "./project.js";
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
+ export type MclOperation = WasmRequest["operation"];
4
+ export type MclResult = ({
5
+ operation: "parse";
6
+ } & ParseResult) | {
7
+ operation: "lint";
8
+ diagnostics: ProtocolLintDiagnostic[];
9
+ } | ({
10
+ operation: "completion";
11
+ } & ProtocolCompletionResult) | ({
12
+ operation: "definition";
13
+ } & ProtocolDefinitionResult) | ({
14
+ operation: "hover";
15
+ } & ProtocolHoverResult) | ({
16
+ operation: "references";
17
+ } & ProtocolReferencesResult) | ({
18
+ operation: "rename";
19
+ } & ProtocolRenameResult) | ({
20
+ operation: "renameFileImports";
21
+ } & ProtocolRenameFileImportsResult) | ({
22
+ operation: "format";
23
+ } & FormatResult) | ({
24
+ operation: "check";
25
+ } & CheckResult) | ({
26
+ operation: "evaluate";
27
+ } & EvaluateResult) | ({
28
+ operation: "render";
29
+ } & RenderResult);
30
+ export type RuntimeStatus = "fetching" | "compiling" | "initializing" | "ready" | "error";
31
+ export type RuntimeStatusEvent = {
32
+ status: RuntimeStatus;
33
+ workerGeneration: number;
34
+ initializationDurationMs?: number;
35
+ };
36
+ export type RuntimeOperationOutcome = "success" | "error" | "aborted";
37
+ export type RuntimeOperationEvent = {
38
+ operation: MclOperation;
39
+ durationMs: number;
40
+ queueWaitMs: number;
41
+ executionDurationMs: number;
42
+ wasmDurationMs?: number;
43
+ workerGeneration?: number;
44
+ outcome: RuntimeOperationOutcome;
45
+ };
46
+ export interface RuntimeOptions {
47
+ initializationTimeoutMs?: number;
48
+ operationTimeoutMs?: number;
49
+ onStatus?: (event: RuntimeStatusEvent) => void;
50
+ onOperation?: (event: RuntimeOperationEvent) => void;
51
+ workerFactory?: () => Worker;
52
+ }
53
+ export interface MclProject {
54
+ /** Returns a new immutable snapshot handle. Only changed files are sent on the next operation. */
55
+ patch(changes: {
56
+ set?: ProjectFiles;
57
+ delete?: string[];
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, {
60
+ operation: O;
61
+ }>>;
62
+ }
63
+ export interface MclRuntime {
64
+ openProject(files: ProjectFiles): MclProject;
65
+ warmUp(options?: RequestOptions): Promise<void>;
66
+ dispose(): void;
67
+ }
68
+ export declare class MclRuntimeError extends Error {
69
+ readonly code: string;
70
+ readonly path?: string;
71
+ readonly line?: number;
72
+ readonly column?: number;
73
+ readonly endLine?: number;
74
+ readonly endColumn?: number;
75
+ readonly related?: ProtocolError["related"];
76
+ constructor(error: Partial<ProtocolError> & {
77
+ code: string;
78
+ message: string;
79
+ });
80
+ }
81
+ export declare function createMclRuntime(options?: RuntimeOptions): MclRuntime;