@manifesto-ai/compiler 1.9.1 → 3.0.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 CHANGED
@@ -110,16 +110,28 @@ npx tsx --loader @manifesto-ai/compiler/node-loader main.ts
110
110
  ### Plugin Options
111
111
 
112
112
  ```typescript
113
+ import { createCompilerCodegen } from "@manifesto-ai/codegen";
114
+
113
115
  melPlugin({
114
116
  include: /\.mel$/, // File filter (default: /\.mel$/)
115
- codegen: { // Optional: auto-generate types
116
- outDir: "src/generated", // Output directory
117
- plugins: [/* custom */], // Defaults to TS + Zod plugins
118
- },
117
+ codegen: createCompilerCodegen(),
119
118
  });
120
119
  ```
121
120
 
122
- The `codegen` option requires `@manifesto-ai/codegen` as a peer dependency. When enabled, TypeScript types and Zod schemas are generated automatically at build time.
121
+ `codegen` is an explicit emitter hook. `@manifesto-ai/compiler` does not import `@manifesto-ai/codegen` for you; install it only if you want build-time artifact generation and inject the emitter yourself.
122
+
123
+ `createCompilerCodegen()` can be called with no options. In that default mode it uses the canonical domain plugin and writes `<source>.mel.ts` next to the compiled `.mel` file. You can still customize the pipeline:
124
+
125
+ ```typescript
126
+ import { createCompilerCodegen, createDomainPlugin } from "@manifesto-ai/codegen";
127
+
128
+ melPlugin({
129
+ codegen: createCompilerCodegen({
130
+ outDir: "src/generated",
131
+ plugins: [createDomainPlugin({ interfaceName: "CounterDomain" })],
132
+ }),
133
+ });
134
+ ```
123
135
 
124
136
  ### Subpath Exports
125
137
 
@@ -0,0 +1,101 @@
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
+ function normalizeId(id) {
13
+ return id.split("?", 1)[0];
14
+ }
15
+ function testRegex(regex, value) {
16
+ regex.lastIndex = 0;
17
+ return regex.test(value);
18
+ }
19
+ function normalizeArtifactSourceId(sourceId) {
20
+ const normalized = normalizeId(sourceId).replace(/\\/g, "/");
21
+ if (!normalized) {
22
+ return "domain.mel";
23
+ }
24
+ if (!nodePath.isAbsolute(sourceId)) {
25
+ return normalized.replace(/^\.\//, "");
26
+ }
27
+ const relative2 = nodePath.relative(process.cwd(), sourceId);
28
+ if (!relative2 || relative2.startsWith("..") || nodePath.isAbsolute(relative2)) {
29
+ return createExternalArtifactSourceId(normalized);
30
+ }
31
+ return relative2.split(nodePath.sep).join("/");
32
+ }
33
+ function createExternalArtifactSourceId(sourceId) {
34
+ const basename = nodePath.posix.basename(sourceId) || "domain.mel";
35
+ const extension = nodePath.posix.extname(basename);
36
+ const stem = basename.slice(0, basename.length - extension.length) || "domain";
37
+ const hash = createHash("sha256").update(sourceId).digest("hex").slice(0, 12);
38
+ const safeStem = sanitizePathSegment(stem);
39
+ return `external/${safeStem}--${hash}${extension}`;
40
+ }
41
+ function sanitizePathSegment(value) {
42
+ const normalized = value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
43
+ return normalized || "domain";
44
+ }
45
+ function resolveCodegenEmitter(codegen) {
46
+ if (!codegen) {
47
+ return null;
48
+ }
49
+ if (typeof codegen === "function") {
50
+ return codegen;
51
+ }
52
+ if (typeof codegen === "object" && typeof codegen.emit === "function") {
53
+ return codegen.emit;
54
+ }
55
+ throw new TypeError(
56
+ "manifesto:mel codegen must be a function or an object with a callable emit field"
57
+ );
58
+ }
59
+ var unpluginMel = createUnplugin((options = {}) => {
60
+ const include = options.include ?? /\.mel$/;
61
+ const compiledSchemas = /* @__PURE__ */ new Map();
62
+ const codegenEmitter = resolveCodegenEmitter(options.codegen);
63
+ return {
64
+ name: "manifesto:mel",
65
+ enforce: "pre",
66
+ transformInclude(id) {
67
+ return testRegex(include, normalizeId(id));
68
+ },
69
+ transform(source, id) {
70
+ const sourceId = normalizeId(id);
71
+ const result = compileMelDomain(source, { mode: "domain" });
72
+ if (result.errors.length > 0) {
73
+ const details = result.errors.map(formatDiagnostic).join("\n");
74
+ throw new Error(`MEL compilation failed for ${sourceId}
75
+ ${details}`);
76
+ }
77
+ if (!result.schema) {
78
+ throw new Error(`MEL compilation produced no schema for ${sourceId}`);
79
+ }
80
+ if (codegenEmitter) {
81
+ compiledSchemas.set(normalizeArtifactSourceId(sourceId), result.schema);
82
+ }
83
+ const serializedSchema = JSON.stringify(result.schema, null, 2);
84
+ return `export default ${serializedSchema};
85
+ `;
86
+ },
87
+ async buildEnd() {
88
+ if (!codegenEmitter || compiledSchemas.size === 0) {
89
+ return;
90
+ }
91
+ for (const [sourceId, schema] of compiledSchemas) {
92
+ await codegenEmitter({ schema, sourceId });
93
+ }
94
+ }
95
+ };
96
+ });
97
+
98
+ export {
99
+ unpluginMel
100
+ };
101
+ //# sourceMappingURL=chunk-VAFXIS7J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/unplugin.ts"],"sourcesContent":["/**\n * Unified MEL plugin via unplugin.\n *\n * Single implementation that targets Vite, Webpack, Rollup, esbuild, and Rspack.\n */\n\nimport { createHash } from \"node:crypto\";\nimport * as nodePath from \"node:path\";\nimport { createUnplugin } from \"unplugin\";\nimport type { DomainSchema } from \"@manifesto-ai/core\";\nimport { compileMelDomain } from \"./api/index.js\";\nimport { formatDiagnostic } from \"./mel-module.js\";\n\nexport type MelCodegenArtifact = {\n readonly schema: DomainSchema;\n readonly sourceId: string;\n};\n\nexport type MelCodegenEmitter = (\n artifact: MelCodegenArtifact\n) => unknown | Promise<unknown>;\n\nexport type MelCodegenOptions = {\n readonly emit: MelCodegenEmitter;\n};\n\nexport type MelPluginOptions = {\n readonly include?: RegExp;\n readonly codegen?: MelCodegenEmitter | MelCodegenOptions | false;\n};\n\nfunction normalizeId(id: string): string {\n return id.split(\"?\", 1)[0];\n}\n\nfunction testRegex(regex: RegExp, value: string): boolean {\n regex.lastIndex = 0;\n return regex.test(value);\n}\n\nfunction normalizeArtifactSourceId(sourceId: string): string {\n const normalized = normalizeId(sourceId).replace(/\\\\/g, \"/\");\n if (!normalized) {\n return \"domain.mel\";\n }\n\n if (!nodePath.isAbsolute(sourceId)) {\n return normalized.replace(/^\\.\\//, \"\");\n }\n\n const relative = nodePath.relative(process.cwd(), sourceId);\n if (!relative || relative.startsWith(\"..\") || nodePath.isAbsolute(relative)) {\n return createExternalArtifactSourceId(normalized);\n }\n\n return relative.split(nodePath.sep).join(\"/\");\n}\n\nfunction createExternalArtifactSourceId(sourceId: string): string {\n const basename = nodePath.posix.basename(sourceId) || \"domain.mel\";\n const extension = nodePath.posix.extname(basename);\n const stem = basename.slice(0, basename.length - extension.length) || \"domain\";\n const hash = createHash(\"sha256\").update(sourceId).digest(\"hex\").slice(0, 12);\n const safeStem = sanitizePathSegment(stem);\n return `external/${safeStem}--${hash}${extension}`;\n}\n\nfunction sanitizePathSegment(value: string): string {\n const normalized = value.replace(/[^a-zA-Z0-9._-]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n return normalized || \"domain\";\n}\n\nfunction resolveCodegenEmitter(\n codegen: MelPluginOptions[\"codegen\"]\n): MelCodegenEmitter | null {\n if (!codegen) {\n return null;\n }\n\n if (typeof codegen === \"function\") {\n return codegen;\n }\n\n if (typeof codegen === \"object\" && typeof codegen.emit === \"function\") {\n return codegen.emit;\n }\n\n throw new TypeError(\n \"manifesto:mel codegen must be a function or an object with a callable emit field\"\n );\n}\n\nexport const unpluginMel = createUnplugin((options: MelPluginOptions = {}) => {\n const include = options.include ?? /\\.mel$/;\n const compiledSchemas = new Map<string, DomainSchema>();\n const codegenEmitter = resolveCodegenEmitter(options.codegen);\n\n return {\n name: \"manifesto:mel\",\n enforce: \"pre\" as const,\n\n transformInclude(id: string) {\n return testRegex(include, normalizeId(id));\n },\n\n transform(source: string, id: string) {\n const sourceId = normalizeId(id);\n const result = compileMelDomain(source, { mode: \"domain\" });\n\n if (result.errors.length > 0) {\n const details = result.errors.map(formatDiagnostic).join(\"\\n\");\n throw new Error(`MEL compilation failed for ${sourceId}\\n${details}`);\n }\n\n if (!result.schema) {\n throw new Error(`MEL compilation produced no schema for ${sourceId}`);\n }\n\n if (codegenEmitter) {\n compiledSchemas.set(normalizeArtifactSourceId(sourceId), result.schema);\n }\n\n const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n },\n\n async buildEnd() {\n if (!codegenEmitter || compiledSchemas.size === 0) {\n return;\n }\n\n for (const [sourceId, schema] of compiledSchemas) {\n await codegenEmitter({ schema, sourceId });\n }\n },\n };\n});\n"],"mappings":";;;;;;;;AAMA,SAAS,kBAAkB;AAC3B,YAAY,cAAc;AAC1B,SAAS,sBAAsB;AAuB/B,SAAS,YAAY,IAAoB;AACvC,SAAO,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC;AAC3B;AAEA,SAAS,UAAU,OAAe,OAAwB;AACxD,QAAM,YAAY;AAClB,SAAO,MAAM,KAAK,KAAK;AACzB;AAEA,SAAS,0BAA0B,UAA0B;AAC3D,QAAM,aAAa,YAAY,QAAQ,EAAE,QAAQ,OAAO,GAAG;AAC3D,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAEA,MAAI,CAAU,oBAAW,QAAQ,GAAG;AAClC,WAAO,WAAW,QAAQ,SAAS,EAAE;AAAA,EACvC;AAEA,QAAMA,YAAoB,kBAAS,QAAQ,IAAI,GAAG,QAAQ;AAC1D,MAAI,CAACA,aAAYA,UAAS,WAAW,IAAI,KAAc,oBAAWA,SAAQ,GAAG;AAC3E,WAAO,+BAA+B,UAAU;AAAA,EAClD;AAEA,SAAOA,UAAS,MAAe,YAAG,EAAE,KAAK,GAAG;AAC9C;AAEA,SAAS,+BAA+B,UAA0B;AAChE,QAAM,WAAoB,eAAM,SAAS,QAAQ,KAAK;AACtD,QAAM,YAAqB,eAAM,QAAQ,QAAQ;AACjD,QAAM,OAAO,SAAS,MAAM,GAAG,SAA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AA0C,QAAQ,EAAE;AAAA,MACtE;AAEA,UAAI,gBAAgB;AAClB,wBAAgB,IAAI,0BAA0B,QAAQ,GAAG,OAAO,MAAM;AAAA,MACxE;AAEA,YAAM,mBAAmB,KAAK,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9D,aAAO,kBAAkB,gBAAgB;AAAA;AAAA,IAC3C;AAAA,IAEA,MAAM,WAAW;AACf,UAAI,CAAC,kBAAkB,gBAAgB,SAAS,GAAG;AACjD;AAAA,MACF;AAEA,iBAAW,CAAC,UAAU,MAAM,KAAK,iBAAiB;AAChD,cAAM,eAAe,EAAE,QAAQ,SAAS,CAAC;AAAA,MAC3C;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["relative"]}
package/dist/esbuild.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * esbuild plugin for MEL files.
3
3
  */
4
- export type { MelPluginOptions, MelCodegenOptions } from "./unplugin.js";
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
5
  export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => import("unplugin").EsbuildPlugin;
6
6
  export default melPlugin;
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-WZRGVNJK.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
4
  import "./chunk-LI5HNMZV.js";
5
5
  import "./chunk-7TT6Y5ZC.js";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * esbuild plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.esbuild;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * esbuild plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.esbuild;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Rollup plugin for MEL files.
3
3
  */
4
- export type { MelPluginOptions, MelCodegenOptions } from "./unplugin.js";
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
5
  export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => import("unplugin").RollupPlugin<any> | import("unplugin").RollupPlugin<any>[];
6
6
  export default melPlugin;
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-WZRGVNJK.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
4
  import "./chunk-LI5HNMZV.js";
5
5
  import "./chunk-7TT6Y5ZC.js";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rollup.ts"],"sourcesContent":["/**\n * Rollup plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.rollup;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/rollup.ts"],"sourcesContent":["/**\n * Rollup plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.rollup;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,iBAAQ;","names":[]}
package/dist/rspack.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Rspack plugin for MEL files.
3
3
  */
4
- export type { MelPluginOptions, MelCodegenOptions } from "./unplugin.js";
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
5
  export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => RspackPluginInstance;
6
6
  export default melPlugin;
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-WZRGVNJK.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
4
  import "./chunk-LI5HNMZV.js";
5
5
  import "./chunk-7TT6Y5ZC.js";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rspack.ts"],"sourcesContent":["/**\n * Rspack plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.rspack;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/rspack.ts"],"sourcesContent":["/**\n * Rspack plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.rspack;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,iBAAQ;","names":[]}
@@ -3,12 +3,17 @@
3
3
  *
4
4
  * Single implementation that targets Vite, Webpack, Rollup, esbuild, and Rspack.
5
5
  */
6
+ import type { DomainSchema } from "@manifesto-ai/core";
7
+ export type MelCodegenArtifact = {
8
+ readonly schema: DomainSchema;
9
+ readonly sourceId: string;
10
+ };
11
+ export type MelCodegenEmitter = (artifact: MelCodegenArtifact) => unknown | Promise<unknown>;
6
12
  export type MelCodegenOptions = {
7
- readonly outDir: string;
8
- readonly plugins?: readonly import("@manifesto-ai/codegen").CodegenPlugin[];
13
+ readonly emit: MelCodegenEmitter;
9
14
  };
10
15
  export type MelPluginOptions = {
11
16
  readonly include?: RegExp;
12
- readonly codegen?: MelCodegenOptions | false;
17
+ readonly codegen?: MelCodegenEmitter | MelCodegenOptions | false;
13
18
  };
14
19
  export declare const unpluginMel: import("unplugin").UnpluginInstance<MelPluginOptions, boolean>;
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Vite plugin for MEL files.
3
3
  */
4
- export type { MelPluginOptions, MelCodegenOptions } from "./unplugin.js";
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
5
  export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
6
6
  export default melPlugin;
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-WZRGVNJK.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
4
  import "./chunk-LI5HNMZV.js";
5
5
  import "./chunk-7TT6Y5ZC.js";
6
6
 
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/**\n * Vite plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.vite;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,eAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["/**\n * Vite plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.vite;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,eAAQ;","names":[]}
package/dist/webpack.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Webpack plugin for MEL files.
3
3
  */
4
- export type { MelPluginOptions, MelCodegenOptions } from "./unplugin.js";
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
5
  export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => import("unplugin").WebpackPluginInstance;
6
6
  export default melPlugin;
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-WZRGVNJK.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
4
  import "./chunk-LI5HNMZV.js";
5
5
  import "./chunk-7TT6Y5ZC.js";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["/**\n * Webpack plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.webpack;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["/**\n * Webpack plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.webpack;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifesto-ai/compiler",
3
- "version": "1.9.1",
3
+ "version": "3.0.0",
4
4
  "description": "Manifesto Compiler - MEL (Manifesto Expression Language) to DomainSchema compiler",
5
5
  "author": "eggplantiny <eggplantiny@gmail.com>",
6
6
  "license": "MIT",
@@ -61,7 +61,6 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@anthropic-ai/sdk": "^0.26.0",
64
- "@manifesto-ai/codegen": "^0.1.5",
65
64
  "@manifesto-ai/core": "^2.0.0",
66
65
  "openai": "^4.0.0",
67
66
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
@@ -71,9 +70,6 @@
71
70
  "@anthropic-ai/sdk": {
72
71
  "optional": true
73
72
  },
74
- "@manifesto-ai/codegen": {
75
- "optional": true
76
- },
77
73
  "openai": {
78
74
  "optional": true
79
75
  },
@@ -101,7 +97,6 @@
101
97
  "vitest": "^4.1.2",
102
98
  "webpack": "^5.105.4",
103
99
  "zod": "^4.3.6",
104
- "@manifesto-ai/codegen": "0.1.5",
105
100
  "@manifesto-ai/core": "2.8.0"
106
101
  },
107
102
  "files": [
@@ -1,74 +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 { createUnplugin } from "unplugin";
10
- function normalizeId(id) {
11
- return id.split("?", 1)[0];
12
- }
13
- function testRegex(regex, value) {
14
- regex.lastIndex = 0;
15
- return regex.test(value);
16
- }
17
- var unpluginMel = createUnplugin((options = {}) => {
18
- const include = options.include ?? /\.mel$/;
19
- const compiledSchemas = /* @__PURE__ */ new Map();
20
- return {
21
- name: "manifesto:mel",
22
- enforce: "pre",
23
- transformInclude(id) {
24
- return testRegex(include, normalizeId(id));
25
- },
26
- transform(source, id) {
27
- const sourceId = normalizeId(id);
28
- const result = compileMelDomain(source, { mode: "domain" });
29
- if (result.errors.length > 0) {
30
- const details = result.errors.map(formatDiagnostic).join("\n");
31
- throw new Error(`MEL compilation failed for ${sourceId}
32
- ${details}`);
33
- }
34
- if (!result.schema) {
35
- throw new Error(`MEL compilation produced no schema for ${sourceId}`);
36
- }
37
- if (options.codegen) {
38
- compiledSchemas.set(sourceId, result.schema);
39
- }
40
- const serializedSchema = JSON.stringify(result.schema, null, 2);
41
- return `export default ${serializedSchema};
42
- `;
43
- },
44
- async buildEnd() {
45
- if (!options.codegen || compiledSchemas.size === 0) return;
46
- let codegen;
47
- try {
48
- codegen = await import("@manifesto-ai/codegen");
49
- } catch {
50
- console.warn(
51
- "[manifesto:mel] codegen option is enabled but @manifesto-ai/codegen is not installed. Skipping."
52
- );
53
- return;
54
- }
55
- const plugins = options.codegen.plugins ?? [
56
- codegen.createTsPlugin(),
57
- codegen.createZodPlugin()
58
- ];
59
- for (const [sourceId, schema] of compiledSchemas) {
60
- await codegen.generate({
61
- schema,
62
- outDir: options.codegen.outDir,
63
- plugins,
64
- sourceId
65
- });
66
- }
67
- }
68
- };
69
- });
70
-
71
- export {
72
- unpluginMel
73
- };
74
- //# sourceMappingURL=chunk-WZRGVNJK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/unplugin.ts"],"sourcesContent":["/**\n * Unified MEL plugin via unplugin.\n *\n * Single implementation that targets Vite, Webpack, Rollup, esbuild, and Rspack.\n */\n\nimport { createUnplugin } from \"unplugin\";\nimport type { DomainSchema } from \"@manifesto-ai/core\";\nimport { compileMelDomain } from \"./api/index.js\";\nimport { formatDiagnostic } from \"./mel-module.js\";\n\nexport type MelCodegenOptions = {\n readonly outDir: string;\n readonly plugins?: readonly import(\"@manifesto-ai/codegen\").CodegenPlugin[];\n};\n\nexport type MelPluginOptions = {\n readonly include?: RegExp;\n readonly codegen?: MelCodegenOptions | false;\n};\n\nfunction normalizeId(id: string): string {\n return id.split(\"?\", 1)[0];\n}\n\nfunction testRegex(regex: RegExp, value: string): boolean {\n regex.lastIndex = 0;\n return regex.test(value);\n}\n\nexport const unpluginMel = createUnplugin((options: MelPluginOptions = {}) => {\n const include = options.include ?? /\\.mel$/;\n const compiledSchemas = new Map<string, DomainSchema>();\n\n return {\n name: \"manifesto:mel\",\n enforce: \"pre\" as const,\n\n transformInclude(id: string) {\n return testRegex(include, normalizeId(id));\n },\n\n transform(source: string, id: string) {\n const sourceId = normalizeId(id);\n const result = compileMelDomain(source, { mode: \"domain\" });\n\n if (result.errors.length > 0) {\n const details = result.errors.map(formatDiagnostic).join(\"\\n\");\n throw new Error(`MEL compilation failed for ${sourceId}\\n${details}`);\n }\n\n if (!result.schema) {\n throw new Error(`MEL compilation produced no schema for ${sourceId}`);\n }\n\n if (options.codegen) {\n compiledSchemas.set(sourceId, result.schema);\n }\n\n const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n },\n\n async buildEnd() {\n if (!options.codegen || compiledSchemas.size === 0) return;\n\n let codegen: typeof import(\"@manifesto-ai/codegen\");\n try {\n codegen = await import(\"@manifesto-ai/codegen\");\n } catch {\n console.warn(\n \"[manifesto:mel] codegen option is enabled but @manifesto-ai/codegen is not installed. Skipping.\"\n );\n return;\n }\n\n const plugins = options.codegen.plugins ?? [\n codegen.createTsPlugin(),\n codegen.createZodPlugin(),\n ];\n\n for (const [sourceId, schema] of compiledSchemas) {\n await codegen.generate({\n schema,\n outDir: options.codegen.outDir,\n plugins,\n sourceId,\n });\n }\n },\n };\n});\n"],"mappings":";;;;;;;;AAMA,SAAS,sBAAsB;AAe/B,SAAS,YAAY,IAAoB;AACvC,SAAO,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC;AAC3B;AAEA,SAAS,UAAU,OAAe,OAAwB;AACxD,QAAM,YAAY;AAClB,SAAO,MAAM,KAAK,KAAK;AACzB;AAEO,I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