@manifesto-ai/compiler 3.1.1 → 3.3.0
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/analyzer/validator.d.ts +5 -0
- package/dist/chunk-3KVBHKIL.js +13 -0
- package/dist/chunk-3KVBHKIL.js.map +1 -0
- package/dist/chunk-F7ORNXSB.js +5 -0
- package/dist/{chunk-LI5HNMZV.js.map → chunk-F7ORNXSB.js.map} +1 -1
- package/dist/chunk-PHMJ5ODH.js +5 -0
- package/dist/{chunk-INVHMPXW.js.map → chunk-PHMJ5ODH.js.map} +1 -1
- package/dist/esbuild.js +1 -13
- package/dist/esbuild.js.map +1 -1
- package/dist/generator/ir.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +21 -2425
- package/dist/index.js.map +1 -1
- package/dist/lexer/tokens.d.ts +1 -1
- package/dist/lowering/context.d.ts +4 -0
- package/dist/lowering/index.d.ts +1 -1
- package/dist/node-loader.js +1 -46
- package/dist/node-loader.js.map +1 -1
- package/dist/parser/ast.d.ts +2 -0
- package/dist/rollup.js +1 -13
- package/dist/rollup.js.map +1 -1
- package/dist/rspack.js +1 -13
- package/dist/rspack.js.map +1 -1
- package/dist/schema-graph.d.ts +19 -0
- package/dist/vite.js +1 -13
- package/dist/vite.js.map +1 -1
- package/dist/webpack.js +1 -13
- package/dist/webpack.js.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-7TT6Y5ZC.js +0 -7635
- package/dist/chunk-7TT6Y5ZC.js.map +0 -1
- package/dist/chunk-INVHMPXW.js +0 -117
- package/dist/chunk-LI5HNMZV.js +0 -33
package/dist/chunk-INVHMPXW.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatDiagnostic
|
|
3
|
-
} from "./chunk-LI5HNMZV.js";
|
|
4
|
-
import {
|
|
5
|
-
compileMelDomain
|
|
6
|
-
} from "./chunk-7TT6Y5ZC.js";
|
|
7
|
-
|
|
8
|
-
// src/unplugin.ts
|
|
9
|
-
import { createHash } from "crypto";
|
|
10
|
-
import * as nodePath from "path";
|
|
11
|
-
import { createUnplugin } from "unplugin";
|
|
12
|
-
var VALID_CODEGEN_TIMINGS = /* @__PURE__ */ new Set(["transform", "build", "both"]);
|
|
13
|
-
function normalizeId(id) {
|
|
14
|
-
return id.split("?", 1)[0];
|
|
15
|
-
}
|
|
16
|
-
function testRegex(regex, value) {
|
|
17
|
-
regex.lastIndex = 0;
|
|
18
|
-
return regex.test(value);
|
|
19
|
-
}
|
|
20
|
-
function normalizeArtifactSourceId(sourceId) {
|
|
21
|
-
const normalized = normalizeId(sourceId).replace(/\\/g, "/");
|
|
22
|
-
if (!normalized) {
|
|
23
|
-
return "domain.mel";
|
|
24
|
-
}
|
|
25
|
-
if (!nodePath.isAbsolute(sourceId)) {
|
|
26
|
-
return normalized.replace(/^\.\//, "");
|
|
27
|
-
}
|
|
28
|
-
const relative2 = nodePath.relative(process.cwd(), sourceId);
|
|
29
|
-
if (!relative2 || relative2.startsWith("..") || nodePath.isAbsolute(relative2)) {
|
|
30
|
-
return createExternalArtifactSourceId(normalized);
|
|
31
|
-
}
|
|
32
|
-
return relative2.split(nodePath.sep).join("/");
|
|
33
|
-
}
|
|
34
|
-
function createExternalArtifactSourceId(sourceId) {
|
|
35
|
-
const basename = nodePath.posix.basename(sourceId) || "domain.mel";
|
|
36
|
-
const extension = nodePath.posix.extname(basename);
|
|
37
|
-
const stem = basename.slice(0, basename.length - extension.length) || "domain";
|
|
38
|
-
const hash = createHash("sha256").update(sourceId).digest("hex").slice(0, 12);
|
|
39
|
-
const safeStem = sanitizePathSegment(stem);
|
|
40
|
-
return `external/${safeStem}--${hash}${extension}`;
|
|
41
|
-
}
|
|
42
|
-
function sanitizePathSegment(value) {
|
|
43
|
-
const normalized = value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
44
|
-
return normalized || "domain";
|
|
45
|
-
}
|
|
46
|
-
function resolveCodegenOptions(codegen) {
|
|
47
|
-
if (!codegen) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
if (typeof codegen === "function") {
|
|
51
|
-
return { emit: codegen, timing: "transform" };
|
|
52
|
-
}
|
|
53
|
-
if (typeof codegen === "object" && typeof codegen.emit === "function") {
|
|
54
|
-
const timing = codegen.timing ?? "transform";
|
|
55
|
-
if (!VALID_CODEGEN_TIMINGS.has(timing)) {
|
|
56
|
-
throw new TypeError(
|
|
57
|
-
`manifesto:mel codegen timing must be one of "transform", "build", or "both" (received ${JSON.stringify(timing)})`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
emit: codegen.emit,
|
|
62
|
-
timing
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
throw new TypeError(
|
|
66
|
-
"manifesto:mel codegen must be a function or an object with a callable emit field"
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
var unpluginMel = createUnplugin((options = {}) => {
|
|
70
|
-
const include = options.include ?? /\.mel$/;
|
|
71
|
-
const compiledSchemas = /* @__PURE__ */ new Map();
|
|
72
|
-
const codegen = resolveCodegenOptions(options.codegen);
|
|
73
|
-
return {
|
|
74
|
-
name: "manifesto:mel",
|
|
75
|
-
enforce: "pre",
|
|
76
|
-
transformInclude(id) {
|
|
77
|
-
return testRegex(include, normalizeId(id));
|
|
78
|
-
},
|
|
79
|
-
async transform(source, id) {
|
|
80
|
-
const sourceId = normalizeId(id);
|
|
81
|
-
const result = compileMelDomain(source, { mode: "domain" });
|
|
82
|
-
if (result.errors.length > 0) {
|
|
83
|
-
const details = result.errors.map(formatDiagnostic).join("\n");
|
|
84
|
-
throw new Error(`MEL compilation failed for ${sourceId}
|
|
85
|
-
${details}`);
|
|
86
|
-
}
|
|
87
|
-
if (!result.schema) {
|
|
88
|
-
throw new Error(`MEL compilation produced no schema for ${sourceId}`);
|
|
89
|
-
}
|
|
90
|
-
const artifactSourceId = normalizeArtifactSourceId(sourceId);
|
|
91
|
-
if (codegen) {
|
|
92
|
-
if (codegen.timing === "transform" || codegen.timing === "both") {
|
|
93
|
-
await codegen.emit({ schema: result.schema, sourceId: artifactSourceId });
|
|
94
|
-
}
|
|
95
|
-
if (codegen.timing === "build" || codegen.timing === "both") {
|
|
96
|
-
compiledSchemas.set(artifactSourceId, result.schema);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const serializedSchema = JSON.stringify(result.schema, null, 2);
|
|
100
|
-
return `export default ${serializedSchema};
|
|
101
|
-
`;
|
|
102
|
-
},
|
|
103
|
-
async buildEnd() {
|
|
104
|
-
if (!codegen || compiledSchemas.size === 0) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
for (const [sourceId, schema] of compiledSchemas) {
|
|
108
|
-
await codegen.emit({ schema, sourceId });
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
export {
|
|
115
|
-
unpluginMel
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=chunk-INVHMPXW.js.map
|
package/dist/chunk-LI5HNMZV.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
compileMelDomain
|
|
3
|
-
} from "./chunk-7TT6Y5ZC.js";
|
|
4
|
-
|
|
5
|
-
// src/mel-module.ts
|
|
6
|
-
function formatDiagnostic(diagnostic) {
|
|
7
|
-
const location = diagnostic.location;
|
|
8
|
-
if (!location) {
|
|
9
|
-
return `[${diagnostic.code}] ${diagnostic.message}`;
|
|
10
|
-
}
|
|
11
|
-
const { line, column } = location.start;
|
|
12
|
-
return `[${diagnostic.code}] ${diagnostic.message} (${line}:${column})`;
|
|
13
|
-
}
|
|
14
|
-
function compileMelToModuleCode(melSource, sourceId) {
|
|
15
|
-
const result = compileMelDomain(melSource, { mode: "domain" });
|
|
16
|
-
if (result.errors.length > 0) {
|
|
17
|
-
const details = result.errors.map(formatDiagnostic).join("\n");
|
|
18
|
-
throw new Error(`MEL compilation failed for ${sourceId}
|
|
19
|
-
${details}`);
|
|
20
|
-
}
|
|
21
|
-
if (!result.schema) {
|
|
22
|
-
throw new Error(`MEL compilation produced no schema for ${sourceId}`);
|
|
23
|
-
}
|
|
24
|
-
const serializedSchema = JSON.stringify(result.schema, null, 2);
|
|
25
|
-
return `export default ${serializedSchema};
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
formatDiagnostic,
|
|
31
|
-
compileMelToModuleCode
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=chunk-LI5HNMZV.js.map
|