@manifest-configuration-language/browser 0.1.3 → 0.1.4

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
@@ -1,6 +1,6 @@
1
1
  # @manifest-configuration-language/browser
2
2
 
3
- `@manifest-configuration-language/browser` runs MCL parse, lint, format, check, evaluate, and render operations in a dedicated Web Worker. Its `prepack` step uses the shared WASM build script, which builds with the active Go toolchain, applies the mise-pinned Binaryen `wasm-opt -Oz`, selects the smaller binary, and copies the matching Go `wasm_exec.js` so both runtime assets ship together. GitHub Release assets use this same output. Update the Go and Binaryen pins in the repository's `mise.toml` when upgrading either tool.
3
+ `@manifest-configuration-language/browser` runs MCL parse, lint, format, completion, definition, hover, check, evaluate, and render operations in a dedicated Web Worker. Its `prepack` step uses the shared WASM build script, which builds with the active Go toolchain, applies the mise-pinned Binaryen `wasm-opt -Oz`, selects the smaller binary, and copies the matching Go `wasm_exec.js` so both runtime assets ship together. GitHub Release assets use this same output. Update the Go and Binaryen pins in the repository's `mise.toml` when upgrading either tool.
4
4
 
5
5
  ```js
6
6
  import { createMclRuntime } from "@manifest-configuration-language/browser";
@@ -25,7 +25,9 @@ Project files can be UTF-8 strings or `Uint8Array` values. UTF-8 files remain in
25
25
 
26
26
  `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.
27
27
 
28
- The package exports `CompletionPosition`, `CompletionItem`, `CompletionResult`, `maxSourceBytes`, `maxProjectFiles`, `maxProjectFileBytes`, and `maxProjectBytes` so browser interfaces can display or consume the runtime's public types and limits.
28
+ `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. Hover does not infer runtime value types, and both operations use only project files already supplied to the browser runtime.
29
+
30
+ The package exports the completion, definition, and hover result types, `maxSourceBytes`, `maxProjectFiles`, `maxProjectFileBytes`, and `maxProjectBytes` so browser interfaces can consume the runtime's public types and limits.
29
31
 
30
32
  MCL decodes the request into a root-relative `io/fs` filesystem for project files, module imports, schemas, resource catalogs, and dependency locks. The runtime limits are defined in the [protocol schema](https://github.com/manifest-configuration-language/mcl/blob/main/cmd/mcl-wasm/protocol.schema.json). The worker blocks `fetch` after loading the WASM runtime assets, so MCL project evaluation cannot make external network requests.
31
33
 
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: 96180751 bytes
4
- sha256: b895cd81bec50ee1d9da9613f4417ff6513a830dceb61788988f28a6e3e20d97
3
+ size: 96219418 bytes
4
+ sha256: c3cd77de141c61f1a424f86d6c539d2d87cd3af5b0a745420b0cdea2c9f8b96a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifest-configuration-language/browser",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Run MCL projects in a browser Web Worker using the Go WebAssembly runtime.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.d.ts CHANGED
@@ -3,14 +3,19 @@ import type {
3
3
  CompletionItem as ProtocolCompletionItem,
4
4
  CompletionPosition as ProtocolCompletionPosition,
5
5
  CompletionResult as ProtocolCompletionResult,
6
+ DefinitionLocation as ProtocolDefinitionLocation,
7
+ DefinitionResult as ProtocolDefinitionResult,
6
8
  Error as ProtocolError,
7
9
  EvaluateResult,
8
10
  FormatResult,
11
+ HoverInfo as ProtocolHoverInfo,
12
+ HoverResult as ProtocolHoverResult,
9
13
  LintDiagnostic as ProtocolLintDiagnostic,
10
14
  ParseResult,
11
15
  RelatedLocation as ProtocolRelatedLocation,
12
16
  RenderResult,
13
17
  Request as WasmRequest,
18
+ SourceRange as ProtocolSourceRange,
14
19
  } from "./protocol.js";
15
20
 
16
21
  export type MclOperation = WasmRequest["operation"];
@@ -30,11 +35,18 @@ export type LintDiagnostic = ProtocolLintDiagnostic;
30
35
  export type CompletionPosition = ProtocolCompletionPosition;
31
36
  export type CompletionItem = ProtocolCompletionItem;
32
37
  export type CompletionResult = ProtocolCompletionResult;
38
+ export type DefinitionResult = ProtocolDefinitionResult;
39
+ export type DefinitionLocation = ProtocolDefinitionLocation;
40
+ export type HoverResult = ProtocolHoverResult;
41
+ export type HoverInfo = ProtocolHoverInfo;
42
+ export type SourceRange = ProtocolSourceRange;
33
43
 
34
44
  export type MclResult =
35
45
  | ({ operation: "parse" } & ParseResult)
36
46
  | { operation: "lint"; diagnostics: ProtocolLintDiagnostic[] }
37
47
  | ({ operation: "completion" } & ProtocolCompletionResult)
48
+ | ({ operation: "definition" } & ProtocolDefinitionResult)
49
+ | ({ operation: "hover" } & ProtocolHoverResult)
38
50
  | ({ operation: "format" } & FormatResult)
39
51
  | ({ operation: "check" } & CheckResult)
40
52
  | ({ operation: "evaluate" } & EvaluateResult)
@@ -55,6 +67,10 @@ export interface MclRuntime {
55
67
  check(source: string, files?: ProjectFiles, options?: RequestOptions): Promise<MclResult & { operation: "check" }>;
56
68
  evaluate(source: string, files?: ProjectFiles, options?: RequestOptions): Promise<MclResult & { operation: "evaluate" }>;
57
69
  render(source: string, files?: ProjectFiles, options?: RequestOptions): Promise<MclResult & { operation: "render" }>;
70
+ definition(source: string, options: PositionRequestOptions): Promise<MclResult & { operation: "definition" }>;
71
+ definition(source: string, files: ProjectFiles | undefined, options: PositionRequestOptions): Promise<MclResult & { operation: "definition" }>;
72
+ hover(source: string, options: PositionRequestOptions): Promise<MclResult & { operation: "hover" }>;
73
+ hover(source: string, files: ProjectFiles | undefined, options: PositionRequestOptions): Promise<MclResult & { operation: "hover" }>;
58
74
  dispose(): void;
59
75
  }
60
76
 
@@ -62,6 +78,8 @@ export interface MclProject {
62
78
  parse(options?: ProjectOperationOptions): Promise<MclResult & { operation: "parse" }>;
63
79
  lint(options?: ProjectOperationOptions): Promise<MclResult & { operation: "lint" }>;
64
80
  complete(options: ProjectCompletionOptions): Promise<MclResult & { operation: "completion" }>;
81
+ definition(options: ProjectNavigationOptions): Promise<MclResult & { operation: "definition" }>;
82
+ hover(options: ProjectNavigationOptions): Promise<MclResult & { operation: "hover" }>;
65
83
  format(options?: ProjectOperationOptions): Promise<MclResult & { operation: "format" }>;
66
84
  check(options?: ProjectOperationOptions): Promise<MclResult & { operation: "check" }>;
67
85
  evaluate(options?: ProjectOperationOptions): Promise<MclResult & { operation: "evaluate" }>;
@@ -81,6 +99,15 @@ export interface ProjectCompletionOptions extends ProjectOperationOptions {
81
99
  position: CompletionPosition;
82
100
  }
83
101
 
102
+ export interface ProjectNavigationOptions extends ProjectOperationOptions {
103
+ position: CompletionPosition;
104
+ }
105
+
106
+ export interface PositionRequestOptions extends RequestOptions {
107
+ entrypoint?: string;
108
+ position: CompletionPosition;
109
+ }
110
+
84
111
  export declare class MclRuntimeError extends Error {
85
112
  readonly code: string;
86
113
  readonly path?: string;
package/src/index.js CHANGED
@@ -248,6 +248,8 @@ export function createMclRuntime(options = {}) {
248
248
  parse: (requestOptions) => runProjectOperation("parse", requestOptions),
249
249
  lint: (requestOptions) => runProjectOperation("lint", requestOptions),
250
250
  complete: (requestOptions) => runProjectOperation("completion", requestOptions),
251
+ definition: (requestOptions) => runProjectOperation("definition", requestOptions),
252
+ hover: (requestOptions) => runProjectOperation("hover", requestOptions),
251
253
  format: (requestOptions) => runProjectOperation("format", requestOptions),
252
254
  check: (requestOptions) => runProjectOperation("check", requestOptions),
253
255
  evaluate: (requestOptions) => runProjectOperation("evaluate", requestOptions),
@@ -289,6 +291,13 @@ export function createMclRuntime(options = {}) {
289
291
  return { files: transferredFiles, transferables };
290
292
  }
291
293
 
294
+ function runSourceNavigation(operation, source, filesOrOptions, requestOptions) {
295
+ const files = requestOptions === undefined ? undefined : filesOrOptions;
296
+ const options = requestOptions ?? filesOrOptions;
297
+ if (!options?.position) throw new TypeError("A source position is required");
298
+ return execute(operation, source, files, options, options.entrypoint ?? "main.mcl", options.position);
299
+ }
300
+
292
301
  return {
293
302
  openProject,
294
303
  warmUp,
@@ -298,6 +307,8 @@ export function createMclRuntime(options = {}) {
298
307
  check: (source, files, requestOptions) => execute("check", source, files, requestOptions),
299
308
  evaluate: (source, files, requestOptions) => execute("evaluate", source, files, requestOptions),
300
309
  render: (source, files, requestOptions) => execute("render", source, files, requestOptions),
310
+ definition: (source, filesOrOptions, requestOptions) => runSourceNavigation("definition", source, filesOrOptions, requestOptions),
311
+ hover: (source, filesOrOptions, requestOptions) => runSourceNavigation("hover", source, filesOrOptions, requestOptions),
301
312
  dispose() {
302
313
  if (disposed) return;
303
314
  disposed = true;
package/src/protocol.d.ts CHANGED
@@ -4,7 +4,7 @@ export type MCLWebAssemblyRequestAndResponseProtocol = Request | Response;
4
4
  export type Request = {
5
5
  requestId?: number;
6
6
  revision?: number;
7
- operation: "parse" | "lint" | "format" | "check" | "evaluate" | "render" | "completion";
7
+ operation: "parse" | "lint" | "format" | "check" | "evaluate" | "render" | "completion" | "definition" | "hover";
8
8
  position?: CompletionPosition;
9
9
  /**
10
10
  * Project-relative MCL source path. Defaults to main.mcl.
@@ -38,7 +38,16 @@ export interface Response {
38
38
  requestId: number;
39
39
  revision?: number;
40
40
  ok: boolean;
41
- result?: ParseResult | LintResult | FormatResult | CheckResult | EvaluateResult | RenderResult | CompletionResult;
41
+ result?:
42
+ | ParseResult
43
+ | LintResult
44
+ | FormatResult
45
+ | CheckResult
46
+ | EvaluateResult
47
+ | RenderResult
48
+ | CompletionResult
49
+ | DefinitionResult
50
+ | HoverResult;
42
51
  error?: Error;
43
52
  }
44
53
  export interface ParseResult {
@@ -78,6 +87,24 @@ export interface CompletionItem {
78
87
  kind: number;
79
88
  insertText?: string;
80
89
  }
90
+ export interface DefinitionResult {
91
+ location: DefinitionLocation | null;
92
+ }
93
+ export interface DefinitionLocation {
94
+ path: string;
95
+ range: SourceRange;
96
+ }
97
+ export interface SourceRange {
98
+ start: CompletionPosition;
99
+ end: CompletionPosition;
100
+ }
101
+ export interface HoverResult {
102
+ hover: HoverInfo | null;
103
+ }
104
+ export interface HoverInfo {
105
+ contents: string;
106
+ range: SourceRange;
107
+ }
81
108
  export interface Error {
82
109
  code: string;
83
110
  message: string;