@manifest-configuration-language/browser 0.1.4 → 0.1.6
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 +1 -1
- package/dist/mcl.wasm +2 -2
- package/package.json +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +26 -4
- package/src/limits.js +2 -0
- package/src/protocol.d.ts +5 -4
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Project files can be UTF-8 strings or `Uint8Array` values. UTF-8 files remain in
|
|
|
29
29
|
|
|
30
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.
|
|
31
31
|
|
|
32
|
-
MCL decodes the request into a root-relative `io/fs` filesystem for project files, module imports, schemas, resource
|
|
32
|
+
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.
|
|
33
33
|
|
|
34
34
|
The wire format is described in [`protocol.schema.json`](https://github.com/manifest-configuration-language/mcl/blob/main/cmd/mcl-wasm/protocol.schema.json). Go protocol models are generated with `go generate ./cmd/mcl-wasm`, and the browser package declarations are generated with `npm run generate:protocol`. The browser API declarations reuse the generated operation, diagnostic, and result types. MCL decodes each request into a root-relative `io/fs` project filesystem. Kustomize project overlays and locked Git archives use kyaml's in-memory filesystem, and Helm source loading accepts an `io/fs` filesystem. The Go `wasm_exec.js` runtime supplies its standard browser fallbacks for process, path, and stdout APIs; the Browser SDK does not provide a Node-style project filesystem or require Node polyfills in Vite.
|
|
35
35
|
|
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: 96170429 bytes
|
|
4
|
+
sha256: d08ad3914d8a2862e52db7dbc3ec43c38c1143dea99dda6c87383c7d59212c7d
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export declare const maxSourceBytes: number;
|
|
|
24
24
|
export declare const maxProjectFiles: number;
|
|
25
25
|
export declare const maxProjectFileBytes: number;
|
|
26
26
|
export declare const maxProjectBytes: number;
|
|
27
|
+
export declare const maxProjectPathLength: number;
|
|
28
|
+
export declare const maxProjectPathDepth: number;
|
|
29
|
+
export declare function isValidProjectPath(path: unknown): path is string;
|
|
27
30
|
|
|
28
31
|
/** Root-relative project files passed to MCL's per-request filesystem. Uint8Array values are copied before transfer so callers can reuse them. */
|
|
29
32
|
export type ProjectFile = string | Uint8Array;
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
maxProjectBytes,
|
|
3
|
+
maxProjectFileBytes,
|
|
4
|
+
maxProjectFiles,
|
|
5
|
+
maxProjectPathDepth,
|
|
6
|
+
maxProjectPathLength,
|
|
7
|
+
maxSourceBytes,
|
|
8
|
+
} from "./limits.js";
|
|
2
9
|
|
|
3
|
-
export { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxSourceBytes };
|
|
10
|
+
export { maxProjectBytes, maxProjectFileBytes, maxProjectFiles, maxProjectPathDepth, maxProjectPathLength, maxSourceBytes };
|
|
11
|
+
|
|
12
|
+
export function isValidProjectPath(value) {
|
|
13
|
+
if (typeof value !== "string" || value.length === 0 || value.startsWith("/") ||
|
|
14
|
+
/^[a-z]:/i.test(value) || value.includes("\\") || value.includes("\0")) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
let pathLength = 0;
|
|
18
|
+
let pathDepth = 1;
|
|
19
|
+
for (const character of value) {
|
|
20
|
+
if (++pathLength > maxProjectPathLength) return false;
|
|
21
|
+
if (character === "/" && ++pathDepth > maxProjectPathDepth) return false;
|
|
22
|
+
}
|
|
23
|
+
return value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
24
|
+
}
|
|
4
25
|
|
|
5
26
|
const defaultInitializationTimeoutMs = 30_000;
|
|
6
27
|
const defaultOperationTimeoutMs = 10_000;
|
|
@@ -113,7 +134,8 @@ export function createMclRuntime(options = {}) {
|
|
|
113
134
|
try {
|
|
114
135
|
if (timeoutMs <= 0) throw timeoutError;
|
|
115
136
|
timer = setTimeout(() => {
|
|
116
|
-
(stopCurrent
|
|
137
|
+
if (stopCurrent) stopCurrent(timeoutError);
|
|
138
|
+
else stopInitialization?.(timeoutError);
|
|
117
139
|
}, timeoutMs);
|
|
118
140
|
await waitUntilReady(requestOptions.signal);
|
|
119
141
|
if (requestOptions.signal?.aborted) throw new DOMException("The operation was aborted", "AbortError");
|
|
@@ -258,7 +280,7 @@ export function createMclRuntime(options = {}) {
|
|
|
258
280
|
}
|
|
259
281
|
|
|
260
282
|
function isSafeRelativePath(filePath) {
|
|
261
|
-
return
|
|
283
|
+
return isValidProjectPath(filePath);
|
|
262
284
|
}
|
|
263
285
|
|
|
264
286
|
function prepareFilesForTransfer(source, files, entrypoint) {
|
package/src/limits.js
CHANGED
package/src/protocol.d.ts
CHANGED
|
@@ -6,10 +6,7 @@ export type Request = {
|
|
|
6
6
|
revision?: number;
|
|
7
7
|
operation: "parse" | "lint" | "format" | "check" | "evaluate" | "render" | "completion" | "definition" | "hover";
|
|
8
8
|
position?: CompletionPosition;
|
|
9
|
-
|
|
10
|
-
* Project-relative MCL source path. Defaults to main.mcl.
|
|
11
|
-
*/
|
|
12
|
-
entrypoint?: string;
|
|
9
|
+
entrypoint?: ProjectPath;
|
|
13
10
|
/**
|
|
14
11
|
* UTF-8 entrypoint source, limited by the runtime.
|
|
15
12
|
*/
|
|
@@ -21,6 +18,10 @@ export type Request = {
|
|
|
21
18
|
[k: string]: FileInput;
|
|
22
19
|
};
|
|
23
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Project-relative MCL source path. Defaults to main.mcl.
|
|
23
|
+
*/
|
|
24
|
+
export type ProjectPath = string;
|
|
24
25
|
/**
|
|
25
26
|
* Binary files omit content and are supplied in the optional second run argument under the same path.
|
|
26
27
|
*/
|