@manifest-configuration-language/browser 0.3.9 → 0.3.11
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 +2 -2
- package/dist/mcl.wasm +2 -2
- package/package.json +1 -1
- package/src/index.d.ts +26 -0
- package/src/index.js +35 -0
- package/src/protocol.d.ts +23 -9
- package/src/worker.js +2 -0
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ An open project is a Worker-backed session. Call `project.update(files)` with th
|
|
|
31
31
|
|
|
32
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.
|
|
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. These operations use only project files already supplied to the browser runtime.
|
|
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.
|
|
35
35
|
|
|
36
|
-
The package exports the completion, definition, hover, references, 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.
|
|
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
|
|
|
38
38
|
MCL decodes the request into a root-relative `io/fs` filesystem for project files, module imports, schemas, and dependency locks. Kubernetes resource scope checks use built-in metadata and CRDs in the project; unknown resource kinds can still be rendered. 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.
|
|
39
39
|
|
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: 96833091 bytes
|
|
4
|
+
sha256: 521315bfa09d7e8930b44dc1e030c44eb1c0587437b8222f656f65c33a44a2ee
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
RenderResult,
|
|
19
19
|
RenameEdit as ProtocolRenameEdit,
|
|
20
20
|
RenameResult as ProtocolRenameResult,
|
|
21
|
+
RenameFileImportsResult as ProtocolRenameFileImportsResult,
|
|
21
22
|
Request as WasmRequest,
|
|
22
23
|
SourceRange as ProtocolSourceRange,
|
|
23
24
|
SourceMap as ProtocolSourceMap,
|
|
@@ -54,6 +55,7 @@ export type HoverResult = ProtocolHoverResult;
|
|
|
54
55
|
export type HoverInfo = ProtocolHoverInfo;
|
|
55
56
|
export type RenameEdit = ProtocolRenameEdit;
|
|
56
57
|
export type RenameResult = ProtocolRenameResult;
|
|
58
|
+
export type RenameFileImportsResult = ProtocolRenameFileImportsResult;
|
|
57
59
|
export type ReferenceLocation = ProtocolReferenceLocation;
|
|
58
60
|
export type ReferencesResult = ProtocolReferencesResult;
|
|
59
61
|
export type SourceRange = ProtocolSourceRange;
|
|
@@ -69,6 +71,7 @@ export type MclResult =
|
|
|
69
71
|
| ({ operation: "hover" } & ProtocolHoverResult)
|
|
70
72
|
| ({ operation: "references" } & ProtocolReferencesResult)
|
|
71
73
|
| ({ operation: "rename" } & ProtocolRenameResult)
|
|
74
|
+
| ({ operation: "renameFileImports" } & ProtocolRenameFileImportsResult)
|
|
72
75
|
| ({ operation: "format" } & FormatResult)
|
|
73
76
|
| ({ operation: "check" } & CheckResult)
|
|
74
77
|
| ({ operation: "evaluate" } & EvaluateResult)
|
|
@@ -158,6 +161,15 @@ export interface MclRuntime {
|
|
|
158
161
|
files: ProjectFiles | undefined,
|
|
159
162
|
options: RenameRequestOptions,
|
|
160
163
|
): Promise<MclResult & { operation: "rename" }>;
|
|
164
|
+
renameFileImports(
|
|
165
|
+
source: string,
|
|
166
|
+
options: FileRenameRequestOptions,
|
|
167
|
+
): Promise<MclResult & { operation: "renameFileImports" }>;
|
|
168
|
+
renameFileImports(
|
|
169
|
+
source: string,
|
|
170
|
+
files: ProjectFiles | undefined,
|
|
171
|
+
options: FileRenameRequestOptions,
|
|
172
|
+
): Promise<MclResult & { operation: "renameFileImports" }>;
|
|
161
173
|
dispose(): void;
|
|
162
174
|
}
|
|
163
175
|
|
|
@@ -171,6 +183,9 @@ export interface MclProject {
|
|
|
171
183
|
hover(options: ProjectNavigationOptions): Promise<MclResult & { operation: "hover" }>;
|
|
172
184
|
references(options: ProjectNavigationOptions): Promise<MclResult & { operation: "references" }>;
|
|
173
185
|
rename(options: ProjectRenameOptions): Promise<MclResult & { operation: "rename" }>;
|
|
186
|
+
renameFileImports(
|
|
187
|
+
options: ProjectFileRenameOptions,
|
|
188
|
+
): Promise<MclResult & { operation: "renameFileImports" }>;
|
|
174
189
|
format(options?: ProjectOperationOptions): Promise<MclResult & { operation: "format" }>;
|
|
175
190
|
check(options?: ProjectOperationOptions): Promise<MclResult & { operation: "check" }>;
|
|
176
191
|
evaluate(options?: ProjectOperationOptions): Promise<MclResult & { operation: "evaluate" }>;
|
|
@@ -200,6 +215,11 @@ export interface ProjectRenameOptions extends ProjectNavigationOptions {
|
|
|
200
215
|
newName: string;
|
|
201
216
|
}
|
|
202
217
|
|
|
218
|
+
export interface ProjectFileRenameOptions extends ProjectOperationOptions {
|
|
219
|
+
oldPath: string;
|
|
220
|
+
newPath: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
203
223
|
export interface PositionRequestOptions extends RequestOptions {
|
|
204
224
|
entrypoint?: string;
|
|
205
225
|
position: CompletionPosition;
|
|
@@ -209,6 +229,12 @@ export interface RenameRequestOptions extends PositionRequestOptions {
|
|
|
209
229
|
newName: string;
|
|
210
230
|
}
|
|
211
231
|
|
|
232
|
+
export interface FileRenameRequestOptions extends RequestOptions {
|
|
233
|
+
entrypoint?: string;
|
|
234
|
+
oldPath: string;
|
|
235
|
+
newPath: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
212
238
|
export declare class MclRuntimeError extends Error {
|
|
213
239
|
readonly code: string;
|
|
214
240
|
readonly path?: string;
|
package/src/index.js
CHANGED
|
@@ -69,6 +69,7 @@ const operationPriorities = {
|
|
|
69
69
|
parse: 20,
|
|
70
70
|
format: 20,
|
|
71
71
|
rename: 20,
|
|
72
|
+
renameFileImports: 20,
|
|
72
73
|
references: 20,
|
|
73
74
|
definition: 20,
|
|
74
75
|
completion: 20,
|
|
@@ -415,6 +416,19 @@ export function createMclRuntime(options = {}) {
|
|
|
415
416
|
position,
|
|
416
417
|
project,
|
|
417
418
|
) {
|
|
419
|
+
if (operation === "renameFileImports") {
|
|
420
|
+
const { oldPath, newPath } = requestOptions;
|
|
421
|
+
if (
|
|
422
|
+
!isValidProjectPath(oldPath) ||
|
|
423
|
+
!oldPath.endsWith(".mcl") ||
|
|
424
|
+
!isValidProjectPath(newPath) ||
|
|
425
|
+
!newPath.endsWith(".mcl")
|
|
426
|
+
) {
|
|
427
|
+
throw new TypeError("oldPath and newPath must be valid project-relative MCL paths");
|
|
428
|
+
}
|
|
429
|
+
if (oldPath === newPath)
|
|
430
|
+
throw new TypeError("oldPath and newPath must be distinct");
|
|
431
|
+
}
|
|
418
432
|
const signal = requestOptions.signal;
|
|
419
433
|
if (signal?.aborted) throw new DOMException("The operation was aborted", "AbortError");
|
|
420
434
|
const startedAt = performance.now();
|
|
@@ -509,6 +523,8 @@ export function createMclRuntime(options = {}) {
|
|
|
509
523
|
entrypoint,
|
|
510
524
|
position,
|
|
511
525
|
newName: requestOptions.newName,
|
|
526
|
+
oldPath: requestOptions.oldPath,
|
|
527
|
+
newPath: requestOptions.newPath,
|
|
512
528
|
};
|
|
513
529
|
if (project) message.projectId = project.id;
|
|
514
530
|
else message.files = preparedFiles.files;
|
|
@@ -674,6 +690,8 @@ export function createMclRuntime(options = {}) {
|
|
|
674
690
|
hover: (requestOptions) => runProjectOperation("hover", requestOptions),
|
|
675
691
|
references: (requestOptions) => runProjectOperation("references", requestOptions),
|
|
676
692
|
rename: (requestOptions) => runProjectOperation("rename", requestOptions),
|
|
693
|
+
renameFileImports: (requestOptions) =>
|
|
694
|
+
runProjectOperation("renameFileImports", requestOptions),
|
|
677
695
|
format: (requestOptions) => runProjectOperation("format", requestOptions),
|
|
678
696
|
check: (requestOptions) => runProjectOperation("check", requestOptions),
|
|
679
697
|
evaluate: (requestOptions) => runProjectOperation("evaluate", requestOptions),
|
|
@@ -740,6 +758,21 @@ export function createMclRuntime(options = {}) {
|
|
|
740
758
|
);
|
|
741
759
|
}
|
|
742
760
|
|
|
761
|
+
function runSourceFileRename(source, filesOrOptions, requestOptions) {
|
|
762
|
+
const files = requestOptions === undefined ? undefined : filesOrOptions;
|
|
763
|
+
const options = requestOptions ?? filesOrOptions;
|
|
764
|
+
if (!options?.oldPath || !options?.newPath)
|
|
765
|
+
throw new TypeError("oldPath and newPath are required");
|
|
766
|
+
return execute(
|
|
767
|
+
"renameFileImports",
|
|
768
|
+
source,
|
|
769
|
+
files,
|
|
770
|
+
options,
|
|
771
|
+
options.entrypoint ?? "main.mcl",
|
|
772
|
+
undefined,
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
|
|
743
776
|
return {
|
|
744
777
|
openProject,
|
|
745
778
|
warmUp,
|
|
@@ -757,6 +790,8 @@ export function createMclRuntime(options = {}) {
|
|
|
757
790
|
runSourceNavigation("references", source, filesOrOptions, requestOptions),
|
|
758
791
|
rename: (source, filesOrOptions, requestOptions) =>
|
|
759
792
|
runSourceNavigation("rename", source, filesOrOptions, requestOptions),
|
|
793
|
+
renameFileImports: (source, filesOrOptions, requestOptions) =>
|
|
794
|
+
runSourceFileRename(source, filesOrOptions, requestOptions),
|
|
760
795
|
dispose() {
|
|
761
796
|
if (disposed) return;
|
|
762
797
|
disposed = true;
|
package/src/protocol.d.ts
CHANGED
|
@@ -15,10 +15,13 @@ export type Request = {
|
|
|
15
15
|
| "definition"
|
|
16
16
|
| "hover"
|
|
17
17
|
| "references"
|
|
18
|
-
| "rename"
|
|
18
|
+
| "rename"
|
|
19
|
+
| "renameFileImports";
|
|
19
20
|
position?: CompletionPosition;
|
|
20
21
|
newName?: string;
|
|
21
|
-
|
|
22
|
+
oldPath?: ProjectPath;
|
|
23
|
+
newPath?: ProjectPath;
|
|
24
|
+
entrypoint?: ProjectPath2;
|
|
22
25
|
/**
|
|
23
26
|
* UTF-8 entrypoint source, limited by the runtime.
|
|
24
27
|
*/
|
|
@@ -30,10 +33,12 @@ export type Request = {
|
|
|
30
33
|
[k: string]: FileInput;
|
|
31
34
|
};
|
|
32
35
|
};
|
|
36
|
+
export type ProjectPath = ProjectPath1;
|
|
37
|
+
export type ProjectPath1 = string;
|
|
33
38
|
/**
|
|
34
39
|
* Project-relative MCL source path. Defaults to main.mcl.
|
|
35
40
|
*/
|
|
36
|
-
export type
|
|
41
|
+
export type ProjectPath2 = string;
|
|
37
42
|
/**
|
|
38
43
|
* Binary files omit content and are supplied in the optional second run argument under the same path.
|
|
39
44
|
*/
|
|
@@ -42,8 +47,6 @@ export type FileInput = {
|
|
|
42
47
|
content?: string;
|
|
43
48
|
};
|
|
44
49
|
export type LintResult = LintDiagnostic[];
|
|
45
|
-
export type ProjectPath1 = ProjectPath2;
|
|
46
|
-
export type ProjectPath2 = string;
|
|
47
50
|
|
|
48
51
|
export interface CompletionPosition {
|
|
49
52
|
line: number;
|
|
@@ -64,7 +67,8 @@ export interface Response {
|
|
|
64
67
|
| DefinitionResult
|
|
65
68
|
| HoverResult
|
|
66
69
|
| ReferencesResult
|
|
67
|
-
| RenameResult
|
|
70
|
+
| RenameResult
|
|
71
|
+
| RenameFileImportsResult;
|
|
68
72
|
error?: Error;
|
|
69
73
|
}
|
|
70
74
|
export interface ParseResult {
|
|
@@ -118,7 +122,7 @@ export interface SourceRange {
|
|
|
118
122
|
end: CompletionPosition;
|
|
119
123
|
}
|
|
120
124
|
export interface SourceMapOrigin {
|
|
121
|
-
path:
|
|
125
|
+
path: ProjectPath;
|
|
122
126
|
range: SourceRange;
|
|
123
127
|
kind: "mcl" | "mcl-overlay-base" | "mcl-overlay-patch";
|
|
124
128
|
multiplicity: "unique" | "repeated" | "ambiguous";
|
|
@@ -148,22 +152,32 @@ export interface HoverResult {
|
|
|
148
152
|
export interface HoverInfo {
|
|
149
153
|
contents: string;
|
|
150
154
|
range: SourceRange;
|
|
155
|
+
standardLibrary?: StandardLibraryFunction;
|
|
156
|
+
}
|
|
157
|
+
export interface StandardLibraryFunction {
|
|
158
|
+
module: string;
|
|
159
|
+
name: string;
|
|
151
160
|
}
|
|
152
161
|
export interface ReferencesResult {
|
|
153
162
|
references: ReferenceLocation[];
|
|
154
163
|
}
|
|
155
164
|
export interface ReferenceLocation {
|
|
156
|
-
path:
|
|
165
|
+
path: ProjectPath;
|
|
157
166
|
range: SourceRange;
|
|
158
167
|
}
|
|
159
168
|
export interface RenameResult {
|
|
160
169
|
edits: RenameEdit[];
|
|
161
170
|
}
|
|
162
171
|
export interface RenameEdit {
|
|
163
|
-
path:
|
|
172
|
+
path: ProjectPath;
|
|
164
173
|
range: SourceRange;
|
|
165
174
|
newText: string;
|
|
166
175
|
}
|
|
176
|
+
export interface RenameFileImportsResult {
|
|
177
|
+
oldPath: ProjectPath;
|
|
178
|
+
newPath: ProjectPath;
|
|
179
|
+
edits: RenameEdit[];
|
|
180
|
+
}
|
|
167
181
|
export interface Error {
|
|
168
182
|
code: string;
|
|
169
183
|
message: string;
|
package/src/worker.js
CHANGED
|
@@ -168,6 +168,8 @@ self.addEventListener("message", async (event) => {
|
|
|
168
168
|
operation: message.operation,
|
|
169
169
|
entrypoint: message.entrypoint,
|
|
170
170
|
newName: message.newName,
|
|
171
|
+
oldPath: message.oldPath,
|
|
172
|
+
newPath: message.newPath,
|
|
171
173
|
position: message.position,
|
|
172
174
|
source: message.source,
|
|
173
175
|
files: encodedFiles.files,
|