@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.
@@ -0,0 +1,5 @@
1
+ import{$ as n}from"./chunk-3KVBHKIL.js";function s(o){let r=o.location;if(!r)return`[${o.code}] ${o.message}`;let{line:e,column:t}=r.start;return`[${o.code}] ${o.message} (${e}:${t})`}function c(o,r){let e=n(o,{mode:"domain"});if(e.errors.length>0){let i=e.errors.map(s).join(`
2
+ `);throw new Error(`MEL compilation failed for ${r}
3
+ ${i}`)}if(!e.schema)throw new Error(`MEL compilation produced no schema for ${r}`);return`export default ${JSON.stringify(e.schema,null,2)};
4
+ `}export{s as a,c as b};
5
+ //# sourceMappingURL=chunk-F7ORNXSB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mel-module.ts"],"sourcesContent":["/**\n * MEL Module Helpers\n *\n * Utilities for turning MEL source into JavaScript module code.\n */\n\nimport type { Diagnostic } from \"./diagnostics/types.js\";\nimport { compileMelDomain } from \"./api/index.js\";\n\nexport function formatDiagnostic(diagnostic: Diagnostic): string {\n const location = diagnostic.location;\n\n if (!location) {\n return `[${diagnostic.code}] ${diagnostic.message}`;\n }\n\n const { line, column } = location.start;\n return `[${diagnostic.code}] ${diagnostic.message} (${line}:${column})`;\n}\n\n/**\n * Compile MEL source and emit ESM source that exports the compiled schema.\n *\n * @param melSource - MEL domain source text\n * @param sourceId - Human-readable source identifier for diagnostics\n */\nexport function compileMelToModuleCode(melSource: string, sourceId: string): string {\n const result = compileMelDomain(melSource, { 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 const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n}\n\n"],"mappings":";;;;;AASO,SAAS,iBAAiB,YAAgC;AAC/D,QAAM,WAAW,WAAW;AAE5B,MAAI,CAAC,UAAU;AACb,WAAO,IAAI,WAAW,IAAI,KAAK,WAAW,OAAO;AAAA,EACnD;AAEA,QAAM,EAAE,MAAM,OAAO,IAAI,SAAS;AAClC,SAAO,IAAI,WAAW,IAAI,KAAK,WAAW,OAAO,KAAK,IAAI,IAAI,MAAM;AACtE;AAQO,SAAS,uBAAuB,WAAmB,UAA0B;AAClF,QAAM,SAAS,iBAAiB,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7D,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,UAAU,OAAO,OAAO,IAAI,gBAAgB,EAAE,KAAK,IAAI;AAC7D,UAAM,IAAI,MAAM,8BAA8B,QAAQ;AAAA,EAAK,OAAO,EAAE;AAAA,EACtE;AAEA,MAAI,CAAC,OAAO,QAAQ;AAClB,UAAM,IAAI,MAAM,0CAA0C,QAAQ,EAAE;AAAA,EACtE;AAEA,QAAM,mBAAmB,KAAK,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9D,SAAO,kBAAkB,gBAAgB;AAAA;AAC3C;","names":[]}
1
+ {"version":3,"sources":["../src/mel-module.ts"],"sourcesContent":["/**\n * MEL Module Helpers\n *\n * Utilities for turning MEL source into JavaScript module code.\n */\n\nimport type { Diagnostic } from \"./diagnostics/types.js\";\nimport { compileMelDomain } from \"./api/index.js\";\n\nexport function formatDiagnostic(diagnostic: Diagnostic): string {\n const location = diagnostic.location;\n\n if (!location) {\n return `[${diagnostic.code}] ${diagnostic.message}`;\n }\n\n const { line, column } = location.start;\n return `[${diagnostic.code}] ${diagnostic.message} (${line}:${column})`;\n}\n\n/**\n * Compile MEL source and emit ESM source that exports the compiled schema.\n *\n * @param melSource - MEL domain source text\n * @param sourceId - Human-readable source identifier for diagnostics\n */\nexport function compileMelToModuleCode(melSource: string, sourceId: string): string {\n const result = compileMelDomain(melSource, { 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 const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n}\n\n"],"mappings":"wCASO,SAASA,EAAiBC,EAAgC,CAC/D,IAAMC,EAAWD,EAAW,SAE5B,GAAI,CAACC,EACH,MAAO,IAAID,EAAW,IAAI,KAAKA,EAAW,OAAO,GAGnD,GAAM,CAAE,KAAAE,EAAM,OAAAC,CAAO,EAAIF,EAAS,MAClC,MAAO,IAAID,EAAW,IAAI,KAAKA,EAAW,OAAO,KAAKE,CAAI,IAAIC,CAAM,GACtE,CAQO,SAASC,EAAuBC,EAAmBC,EAA0B,CAClF,IAAMC,EAASC,EAAiBH,EAAW,CAAE,KAAM,QAAS,CAAC,EAE7D,GAAIE,EAAO,OAAO,OAAS,EAAG,CAC5B,IAAME,EAAUF,EAAO,OAAO,IAAIR,CAAgB,EAAE,KAAK;AAAA,CAAI,EAC7D,MAAM,IAAI,MAAM,8BAA8BO,CAAQ;AAAA,EAAKG,CAAO,EAAE,CACtE,CAEA,GAAI,CAACF,EAAO,OACV,MAAM,IAAI,MAAM,0CAA0CD,CAAQ,EAAE,EAItE,MAAO,kBADkB,KAAK,UAAUC,EAAO,OAAQ,KAAM,CAAC,CACrB;AAAA,CAC3C","names":["formatDiagnostic","diagnostic","location","line","column","compileMelToModuleCode","melSource","sourceId","result","compileMelDomain","details"]}
@@ -0,0 +1,5 @@
1
+ import{a as d}from"./chunk-F7ORNXSB.js";import{$ as f}from"./chunk-3KVBHKIL.js";import{createHash as u}from"crypto";import*as i from"path";import{createUnplugin as p}from"unplugin";var h=new Set(["transform","build","both"]);function l(e){return e.split("?",1)[0]}function y(e,t){return e.lastIndex=0,e.test(t)}function b(e){let t=l(e).replace(/\\/g,"/");if(!t)return"domain.mel";if(!i.isAbsolute(e))return t.replace(/^\.\//,"");let n=i.relative(process.cwd(),e);return!n||n.startsWith("..")||i.isAbsolute(n)?M(t):n.split(i.sep).join("/")}function M(e){let t=i.posix.basename(e)||"domain.mel",n=i.posix.extname(t),o=t.slice(0,t.length-n.length)||"domain",r=u("sha256").update(e).digest("hex").slice(0,12);return`external/${x(o)}--${r}${n}`}function x(e){return e.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"domain"}function w(e){if(!e)return null;if(typeof e=="function")return{emit:e,timing:"transform"};if(typeof e=="object"&&typeof e.emit=="function"){let t=e.timing??"transform";if(!h.has(t))throw new TypeError(`manifesto:mel codegen timing must be one of "transform", "build", or "both" (received ${JSON.stringify(t)})`);return{emit:e.emit,timing:t}}throw new TypeError("manifesto:mel codegen must be a function or an object with a callable emit field")}var I=p((e={})=>{let t=e.include??/\.mel$/,n=new Map,o=w(e.codegen);return{name:"manifesto:mel",enforce:"pre",transformInclude(r){return y(t,l(r))},async transform(r,s){let m=l(s),a=f(r,{mode:"domain"});if(a.errors.length>0){let g=a.errors.map(d).join(`
2
+ `);throw new Error(`MEL compilation failed for ${m}
3
+ ${g}`)}if(!a.schema)throw new Error(`MEL compilation produced no schema for ${m}`);let c=b(m);return o&&((o.timing==="transform"||o.timing==="both")&&await o.emit({schema:a.schema,sourceId:c}),(o.timing==="build"||o.timing==="both")&&n.set(c,a.schema)),`export default ${JSON.stringify(a.schema,null,2)};
4
+ `},async buildEnd(){if(!(!o||n.size===0))for(let[r,s]of n)await o.emit({schema:s,sourceId:r})}}});export{I as a};
5
+ //# sourceMappingURL=chunk-PHMJ5ODH.js.map
@@ -1 +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 MelCodegenTiming = \"transform\" | \"build\" | \"both\";\n\nexport type MelCodegenOptions = {\n readonly emit: MelCodegenEmitter;\n readonly timing?: MelCodegenTiming;\n};\n\nexport type MelPluginOptions = {\n readonly include?: RegExp;\n readonly codegen?: MelCodegenEmitter | MelCodegenOptions | false;\n};\n\nconst VALID_CODEGEN_TIMINGS = new Set<MelCodegenTiming>([\"transform\", \"build\", \"both\"]);\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 resolveCodegenOptions(\n codegen: MelPluginOptions[\"codegen\"]\n): MelCodegenOptions | null {\n if (!codegen) {\n return null;\n }\n\n if (typeof codegen === \"function\") {\n return { emit: codegen, timing: \"transform\" };\n }\n\n if (typeof codegen === \"object\" && typeof codegen.emit === \"function\") {\n const timing = codegen.timing ?? \"transform\";\n if (!VALID_CODEGEN_TIMINGS.has(timing)) {\n throw new TypeError(\n `manifesto:mel codegen timing must be one of \"transform\", \"build\", or \"both\" (received ${JSON.stringify(timing)})`\n );\n }\n\n return {\n emit: codegen.emit,\n timing,\n };\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 codegen = resolveCodegenOptions(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 async 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 const artifactSourceId = normalizeArtifactSourceId(sourceId);\n\n if (codegen) {\n if (codegen.timing === \"transform\" || codegen.timing === \"both\") {\n await codegen.emit({ schema: result.schema, sourceId: artifactSourceId });\n }\n\n if (codegen.timing === \"build\" || codegen.timing === \"both\") {\n compiledSchemas.set(artifactSourceId, result.schema);\n }\n }\n\n const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n },\n\n async buildEnd() {\n if (!codegen || compiledSchemas.size === 0) {\n return;\n }\n\n for (const [sourceId, schema] of compiledSchemas) {\n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0BAA0B,QAAQ;AAE3D,UAAI,SAAS;AACX,YAAI,QAAQ,WAAW,eAAe,QAAQ,WAAW,QAAQ;AAC/D,gBAAM,QAAQ,KAAK,EAAE,QAAQ,OAAO,QAAQ,UAAU,iBAAiB,CAAC;AAAA,QAC1E;AAEA,YAAI,QAAQ,WAAW,WAAW,QAAQ,WAAW,QAAQ;AAC3D,0BAAgB,IAAI,kBAAkB,OAAO,MAAM;AAAA,QACrD;AAAA,MACF;AAEA,YAAM,mBAAmB,KAAK,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9D,aAAO,kBAAkB,gBAAgB;AAAA;AAAA,IAC3C;AAAA,IAEA,MAAM,WAAW;AACf,UAAI,CAAC,WAAW,gBAAgB,SAAS,GAAG;AAC1C;AAAA,MACF;AAEA,iBAAW,CAAC,UAAU,MAAM,KAAK,iBAAiB;AAChD,cAAM,QAAQ,KAAK,EAAE,QAAQ,SAAS,CAAC;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["relative"]}
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 MelCodegenTiming = \"transform\" | \"build\" | \"both\";\n\nexport type MelCodegenOptions = {\n readonly emit: MelCodegenEmitter;\n readonly timing?: MelCodegenTiming;\n};\n\nexport type MelPluginOptions = {\n readonly include?: RegExp;\n readonly codegen?: MelCodegenEmitter | MelCodegenOptions | false;\n};\n\nconst VALID_CODEGEN_TIMINGS = new Set<MelCodegenTiming>([\"transform\", \"build\", \"both\"]);\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 resolveCodegenOptions(\n codegen: MelPluginOptions[\"codegen\"]\n): MelCodegenOptions | null {\n if (!codegen) {\n return null;\n }\n\n if (typeof codegen === \"function\") {\n return { emit: codegen, timing: \"transform\" };\n }\n\n if (typeof codegen === \"object\" && typeof codegen.emit === \"function\") {\n const timing = codegen.timing ?? \"transform\";\n if (!VALID_CODEGEN_TIMINGS.has(timing)) {\n throw new TypeError(\n `manifesto:mel codegen timing must be one of \"transform\", \"build\", or \"both\" (received ${JSON.stringify(timing)})`\n );\n }\n\n return {\n emit: codegen.emit,\n timing,\n };\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 codegen = resolveCodegenOptions(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 async 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 const artifactSourceId = normalizeArtifactSourceId(sourceId);\n\n if (codegen) {\n if (codegen.timing === \"transform\" || codegen.timing === \"both\") {\n await codegen.emit({ schema: result.schema, sourceId: artifactSourceId });\n }\n\n if (codegen.timing === \"build\" || codegen.timing === \"both\") {\n compiledSchemas.set(artifactSourceId, result.schema);\n }\n }\n\n const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n },\n\n async buildEnd() {\n if (!codegen || compiledSchemas.size === 0) {\n return;\n }\n\n for (const [sourceId, schema] of compiledSchemas) {\n await codegen.emit({ schema, sourceId });\n }\n },\n };\n});\n"],"mappings":"gFAMA,OAAS,cAAAA,MAAkB,SAC3B,UAAYC,MAAc,OAC1B,OAAS,kBAAAC,MAAsB,WA0B/B,IAAMC,EAAwB,IAAI,IAAsB,CAAC,YAAa,QAAS,MAAM,CAAC,EAEtF,SAASC,EAAYC,EAAoB,CACvC,OAAOA,EAAG,MAAM,IAAK,CAAC,EAAE,CAAC,CAC3B,CAEA,SAASC,EAAUC,EAAeC,EAAwB,CACxD,OAAAD,EAAM,UAAY,EACXA,EAAM,KAAKC,CAAK,CACzB,CAEA,SAASC,EAA0BC,EAA0B,CAC3D,IA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4B,CAAC,IAAM,CAC5E,IAAMC,EAAUD,EAAQ,SAAW,SAC7BE,EAAkB,IAAI,IACtBN,EAAUD,EAAsBK,EAAQ,OAAO,EAErD,MAAO,CACL,KAAM,gBACN,QAAS,MAET,iBAAiBpB,EAAY,CAC3B,OAAOC,EAAUoB,EAAStB,EAAYC,CAAE,CAAC,CAC3C,EAEA,MAAM,UAAUuB,EAAgBvB,EAAY,CAC1C,IAAMK,EAAWN,EAAYC,CAAE,EACzBwB,EAASC,EAAiBF,EAAQ,CAAE,KAAM,QAAS,CAAC,EAE1D,GAAIC,EAAO,OAAO,OAAS,EAAG,CAC5B,IAAME,EAAUF,EAAO,OAAO,IAAIG,CAAgB,EAAE,KAAK;AAAA,CAAI,EAC7D,MAAM,IAAI,MAAM,8BAA8BtB,CAAQ;AAAA,EAAKqB,CAAO,EAAE,CACtE,CAEA,GAAI,CAACF,EAAO,OACV,MAAM,IAAI,MAAM,0CAA0CnB,CAAQ,EAAE,EAGtE,IAAMuB,EAAmBxB,EAA0BC,CAAQ,EAE3D,OAAIW,KACEA,EAAQ,SAAW,aAAeA,EAAQ,SAAW,SACvD,MAAMA,EAAQ,KAAK,CAAE,OAAQQ,EAAO,OAAQ,SAAUI,CAAiB,CAAC,GAGtEZ,EAAQ,SAAW,SAAWA,EAAQ,SAAW,SACnDM,EAAgB,IAAIM,EAAkBJ,EAAO,MAAM,GAKhD,kBADkB,KAAK,UAAUA,EAAO,OAAQ,KAAM,CAAC,CACrB;AAAA,CAC3C,EAEA,MAAM,UAAW,CACf,GAAI,GAACR,GAAWM,EAAgB,OAAS,GAIzC,OAAW,CAACjB,EAAUwB,CAAM,IAAKP,EAC/B,MAAMN,EAAQ,KAAK,CAAE,OAAAa,EAAQ,SAAAxB,CAAS,CAAC,CAE3C,CACF,CACF,CAAC","names":["createHash","nodePath","createUnplugin","VALID_CODEGEN_TIMINGS","normalizeId","id","testRegex","regex","value","normalizeArtifactSourceId","sourceId","normalized","relative","createExternalArtifactSourceId","basename","extension","stem","hash","createHash","sanitizePathSegment","resolveCodegenOptions","codegen","timing","unpluginMel","createUnplugin","options","include","compiledSchemas","source","result","compileMelDomain","details","formatDiagnostic","artifactSourceId","schema"]}
package/dist/esbuild.js CHANGED
@@ -1,14 +1,2 @@
1
- import {
2
- unpluginMel
3
- } from "./chunk-INVHMPXW.js";
4
- import "./chunk-LI5HNMZV.js";
5
- import "./chunk-7TT6Y5ZC.js";
6
-
7
- // src/esbuild.ts
8
- var melPlugin = unpluginMel.esbuild;
9
- var esbuild_default = melPlugin;
10
- export {
11
- esbuild_default as default,
12
- melPlugin
13
- };
1
+ import{a as e}from"./chunk-PHMJ5ODH.js";import"./chunk-F7ORNXSB.js";import"./chunk-3KVBHKIL.js";var t=e.esbuild,n=t;export{n as default,t as melPlugin};
14
2
  //# sourceMappingURL=esbuild.js.map
@@ -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 {\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":[]}
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":"gGAYO,IAAMA,EAAYC,EAAY,QAC9BC,EAAQF","names":["melPlugin","unpluginMel","esbuild_default"]}
@@ -65,6 +65,7 @@ export interface FieldSpec {
65
65
  */
66
66
  export interface StateSpec {
67
67
  fields: Record<string, FieldSpec>;
68
+ fieldTypes?: Record<string, TypeDefinition>;
68
69
  }
69
70
  /**
70
71
  * Computed field specification
@@ -91,13 +92,19 @@ export interface ComputedSpec {
91
92
  export interface ActionSpec {
92
93
  flow: CoreFlowNode;
93
94
  input?: FieldSpec;
95
+ inputType?: TypeDefinition;
96
+ params?: readonly string[];
94
97
  available?: CoreExprNode;
98
+ dispatchable?: CoreExprNode;
95
99
  description?: string;
96
100
  }
97
101
  export interface CompilerActionSpec {
98
102
  flow: CompilerFlowNode;
99
103
  input?: FieldSpec;
104
+ inputType?: TypeDefinition;
105
+ params?: readonly string[];
100
106
  available?: CompilerExprNode;
107
+ dispatchable?: CompilerExprNode;
101
108
  description?: string;
102
109
  }
103
110
  /**
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { renderTypeExpr, renderTypeField, renderValue, renderExprNode, renderPat
13
13
  export * from "./lowering/index.js";
14
14
  export * from "./evaluation/index.js";
15
15
  export * from "./api/index.js";
16
+ export * from "./schema-graph.js";
16
17
  export type { DomainSchema as DomainModule } from "./generator/ir.js";
17
18
  import type { ParseResult } from "./parser/index.js";
18
19
  import { type DomainSchema } from "./generator/index.js";