@manifesto-ai/compiler 3.8.0 → 5.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 +2 -2
- package/dist/analyzer/expr-type-surface.d.ts +1 -0
- package/dist/analyzer/validator.d.ts +7 -4
- package/dist/api/compile-fragment-edit-result.d.ts +12 -0
- package/dist/api/compile-fragment-in-context.d.ts +3 -0
- package/dist/api/compile-fragment-json-validation.d.ts +13 -0
- package/dist/api/compile-fragment-options-validation.d.ts +15 -0
- package/dist/api/compile-fragment-reference-collector.d.ts +3 -0
- package/dist/api/compile-fragment-reference-types.d.ts +40 -0
- package/dist/api/compile-fragment-reference-utils.d.ts +5 -0
- package/dist/api/compile-fragment-source-utils.d.ts +36 -0
- package/dist/api/compile-fragment-types.d.ts +109 -0
- package/dist/api/compile-fragment-validation.d.ts +52 -0
- package/dist/api/compile-mel-patch-collector.d.ts +5 -6
- package/dist/api/compile-mel.d.ts +4 -4
- package/dist/api/index.d.ts +4 -2
- package/dist/{chunk-MB43CHXV.js → chunk-A356Y7I6.js} +1 -1
- package/dist/{chunk-M3P5RIDR.js → chunk-HOS3TLHW.js} +1 -1
- package/dist/chunk-JYNK3VUK.js +23 -0
- package/dist/esbuild.js +1 -1
- package/dist/evaluation/context.d.ts +32 -6
- package/dist/generator/ir.d.ts +25 -3
- package/dist/generator/lowering.d.ts +7 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +18 -18
- package/dist/lowering/context.d.ts +7 -9
- package/dist/lowering/errors.d.ts +2 -2
- package/dist/lowering/lower-runtime-patch.d.ts +1 -1
- package/dist/node-loader.js +1 -1
- package/dist/parser/ast.d.ts +21 -2
- package/dist/parser/parser.d.ts +3 -0
- package/dist/rollup.js +1 -1
- package/dist/rspack.js +1 -1
- package/dist/source-map.d.ts +1 -0
- package/dist/unplugin.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-PEO2YZ2Y.js +0 -12
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ MEL source -> Compiler -> DomainSchema -> Core
|
|
|
21
21
|
| Parse MEL | Tokenize and parse MEL into an AST |
|
|
22
22
|
| Validate | Scope, typing, and semantic checks aligned to the current compiler contract |
|
|
23
23
|
| Generate IR | Produce DomainSchema for Core |
|
|
24
|
-
| Lower
|
|
24
|
+
| Lower runtime/context expressions | Lower ADR-027 `$runtime.*` and `$context.*` references into Core expressions |
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
@@ -216,7 +216,7 @@ type CompileOptions = {
|
|
|
216
216
|
| [MEL Syntax](../../docs/mel/SYNTAX.md) | Grammar and syntax |
|
|
217
217
|
| [MEL Examples](../../docs/mel/EXAMPLES.md) | Example library |
|
|
218
218
|
| [MEL Error Guide](../../docs/mel/ERROR-GUIDE.md) | Error codes and fixes |
|
|
219
|
-
| [Compiler Spec](docs/SPEC-v1.
|
|
219
|
+
| [Compiler Spec](docs/SPEC-v1.2.0.md) | Current full compiler and MEL spec |
|
|
220
220
|
| [Compiler FDR](docs/FDR-v0.5.0.md) | Design rationale |
|
|
221
221
|
| [Compiler Compliance Suite](docs/compiler-SPEC-compilance-test-suite.md) | CCTS structure, rule modes, and execution guide |
|
|
222
222
|
|
|
@@ -6,6 +6,7 @@ export type TypeEnv = Map<string, TypeExprNode>;
|
|
|
6
6
|
export type ComparableSurfaceClass = "primitive" | "nonprimitive" | "unknown";
|
|
7
7
|
export interface DomainTypeSymbols {
|
|
8
8
|
stateTypes: Map<string, TypeExprNode>;
|
|
9
|
+
contextTypes: Map<string, TypeExprNode>;
|
|
9
10
|
computedDecls: Map<string, ComputedNode>;
|
|
10
11
|
typeDefs: Map<string, TypeDeclNode>;
|
|
11
12
|
computedTypeCache: Map<string, TypeExprNode | null>;
|
|
@@ -31,6 +31,7 @@ export declare class SemanticValidator {
|
|
|
31
31
|
* v0.3.3: Validate state field - check for anonymous object types (W012)
|
|
32
32
|
*/
|
|
33
33
|
private validateStateField;
|
|
34
|
+
private validateContext;
|
|
34
35
|
private validateStateInitializer;
|
|
35
36
|
/**
|
|
36
37
|
* v0.3.3: Check if a type expression contains anonymous object types
|
|
@@ -39,13 +40,13 @@ export declare class SemanticValidator {
|
|
|
39
40
|
private checkAnonymousObjectType;
|
|
40
41
|
private validateAction;
|
|
41
42
|
/**
|
|
42
|
-
* v0.3.3: Validate available expression is pure (E005)
|
|
43
|
-
* No
|
|
43
|
+
* v0.3.3: Validate available expression is pure (E005).
|
|
44
|
+
* No dollar namespace reads or action parameters.
|
|
44
45
|
*/
|
|
45
46
|
private validateAvailableExpr;
|
|
46
47
|
/**
|
|
47
|
-
* v0.9.0: Validate dispatchable expression is pure (E047)
|
|
48
|
-
* Allows state/computed/action params, but forbids direct
|
|
48
|
+
* v0.9.0: Validate dispatchable expression is pure (E047).
|
|
49
|
+
* Allows state/computed/action params, but forbids direct dollar namespace reads.
|
|
49
50
|
*/
|
|
50
51
|
private validateDispatchableExpr;
|
|
51
52
|
private validateGuardedStmt;
|
|
@@ -58,6 +59,8 @@ export declare class SemanticValidator {
|
|
|
58
59
|
private validateStop;
|
|
59
60
|
private validateCondition;
|
|
60
61
|
private validateExpr;
|
|
62
|
+
private validateDollarIdent;
|
|
63
|
+
private validateContextPath;
|
|
61
64
|
private validateFunctionCall;
|
|
62
65
|
private validatePrimitiveEquality;
|
|
63
66
|
private inferType;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
3
|
+
import type { MelEditResult, MelTextEdit } from "./compile-fragment-types.js";
|
|
4
|
+
export type MaterializedEdit = {
|
|
5
|
+
readonly edits: readonly MelTextEdit[];
|
|
6
|
+
readonly changedTargets: readonly LocalTargetKey[];
|
|
7
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
8
|
+
};
|
|
9
|
+
export declare function validateThenEdit(diagnostics: readonly Diagnostic[], makeEdit: () => MaterializedEdit): MaterializedEdit;
|
|
10
|
+
export declare function preMaterializationFailure(baseSource: string, diagnostics: readonly Diagnostic[]): MelEditResult;
|
|
11
|
+
export declare function materializationSuccess(edits: readonly MelTextEdit[], changedTargets: readonly LocalTargetKey[]): MaterializedEdit;
|
|
12
|
+
export declare function materializationFailure(...diagnostics: Diagnostic[]): MaterializedEdit;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CompileFragmentInContextOptions, MelEditOp, MelEditResult } from "./compile-fragment-types.js";
|
|
2
|
+
export type { CompileFragmentInContextOptions, MelEditAddActionOp, MelEditAddAvailableOp, MelEditAddComputedOp, MelEditAddDispatchableOp, MelEditAddStateFieldOp, MelEditAddTypeOp, MelEditOp, MelEditRemoveDeclarationOp, MelEditRenameDeclarationOp, MelEditReplaceActionBodyOp, MelEditReplaceAvailableOp, MelEditReplaceComputedExprOp, MelEditReplaceDispatchableOp, MelEditReplaceStateDefaultOp, MelEditReplaceTypeFieldOp, MelEditResult, MelParamSource, MelTextEdit, SchemaDiff, SchemaModifiedTarget, } from "./compile-fragment-types.js";
|
|
3
|
+
export declare function compileFragmentInContext(baseSource: string, op: MelEditOp, options?: CompileFragmentInContextOptions): MelEditResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonLiteral } from "../annotations.js";
|
|
2
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
3
|
+
type JsonLiteralSnapshot = {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
readonly value: JsonLiteral;
|
|
6
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
7
|
+
} | {
|
|
8
|
+
readonly ok: false;
|
|
9
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
10
|
+
};
|
|
11
|
+
export declare function validateJsonLiteralFragment(value: unknown, label: string): Diagnostic[];
|
|
12
|
+
export declare function snapshotJsonLiteralFragment(value: unknown, label: string): JsonLiteralSnapshot;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
2
|
+
export type CompileFragmentOptionsSnapshot = {
|
|
3
|
+
readonly baseModuleSourceHash: string | null;
|
|
4
|
+
readonly includeModule: boolean;
|
|
5
|
+
readonly includeSchemaDiff: boolean;
|
|
6
|
+
};
|
|
7
|
+
type OptionsSnapshotRead = {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
readonly value: CompileFragmentOptionsSnapshot;
|
|
10
|
+
} | {
|
|
11
|
+
readonly ok: false;
|
|
12
|
+
readonly diagnostic: Diagnostic;
|
|
13
|
+
};
|
|
14
|
+
export declare function snapshotCompileFragmentOptions(options: unknown): OptionsSnapshotRead;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProgramNode } from "../parser/index.js";
|
|
2
|
+
import type { OffsetRange, ReferenceSpan, TargetInfo } from "./compile-fragment-reference-types.js";
|
|
3
|
+
export declare function collectTargetReferences(source: string, program: ProgramNode, target: TargetInfo, ignoreRange?: OffsetRange): ReferenceSpan[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import type { ProgramNode } from "../parser/index.js";
|
|
3
|
+
import type { MelTextEdit } from "./compile-fragment-types.js";
|
|
4
|
+
export type DeclarationEditPlan = {
|
|
5
|
+
readonly ok: true;
|
|
6
|
+
readonly edits: readonly MelTextEdit[];
|
|
7
|
+
readonly changedTargets: readonly LocalTargetKey[];
|
|
8
|
+
} | {
|
|
9
|
+
readonly ok: false;
|
|
10
|
+
readonly code: DeclarationEditFailureCode;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly location: ProgramNode["location"];
|
|
13
|
+
};
|
|
14
|
+
export type DeclarationEditFailureCode = "E_REMOVE_BLOCKED_BY_REFERENCES" | "E_UNSAFE_RENAME_AMBIGUOUS" | "E_TARGET_NOT_FOUND" | "E_FRAGMENT_SCOPE_VIOLATION";
|
|
15
|
+
export type TargetInfo = {
|
|
16
|
+
readonly kind: "type";
|
|
17
|
+
readonly name: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "state_field";
|
|
20
|
+
readonly name: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "computed";
|
|
23
|
+
readonly name: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "action";
|
|
26
|
+
readonly name: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "type_field";
|
|
29
|
+
readonly typeName: string;
|
|
30
|
+
readonly fieldName: string;
|
|
31
|
+
};
|
|
32
|
+
export type ReferenceSpan = {
|
|
33
|
+
readonly range: OffsetRange;
|
|
34
|
+
readonly location: ProgramNode["location"];
|
|
35
|
+
readonly rewrite: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type OffsetRange = {
|
|
38
|
+
readonly start: number;
|
|
39
|
+
readonly end: number;
|
|
40
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import type { ProgramNode } from "../parser/index.js";
|
|
3
|
+
import type { DeclarationEditPlan } from "./compile-fragment-reference-types.js";
|
|
4
|
+
export declare function planRemoveDeclaration(source: string, program: ProgramNode, target: LocalTargetKey): DeclarationEditPlan;
|
|
5
|
+
export declare function planRenameDeclaration(source: string, program: ProgramNode, target: LocalTargetKey, newName: string): DeclarationEditPlan;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { JsonLiteral, LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import type { DomainSchema } from "../generator/ir.js";
|
|
3
|
+
import { type Token } from "../lexer/index.js";
|
|
4
|
+
import type { ActionNode, ComputedNode, ProgramNode, StateFieldNode, TypeDeclNode, TypeFieldNode } from "../parser/index.js";
|
|
5
|
+
import { type SourcePoint } from "../source-map.js";
|
|
6
|
+
import type { MelEditAddActionOp, MelTextEdit, SchemaDiff } from "./compile-fragment-types.js";
|
|
7
|
+
export declare function findAction(program: ProgramNode, name: string): ActionNode | null;
|
|
8
|
+
export declare function findComputed(program: ProgramNode, name: string): ComputedNode | null;
|
|
9
|
+
export declare function findStateField(program: ProgramNode, name: string): StateFieldNode | null;
|
|
10
|
+
export declare function findTypeDecl(program: ProgramNode, name: string): TypeDeclNode | null;
|
|
11
|
+
export declare function findTypeField(program: ProgramNode, typeName: string, fieldName: string): TypeFieldNode | null;
|
|
12
|
+
export declare function parseTypeFieldTarget(target: `type_field:${string}.${string}`): {
|
|
13
|
+
typeName: string;
|
|
14
|
+
fieldName: string;
|
|
15
|
+
} | null;
|
|
16
|
+
export declare function targetLocation(program: ProgramNode, target: LocalTargetKey): ProgramNode["location"];
|
|
17
|
+
export declare function findActionBodyBraces(source: string, action: ActionNode): {
|
|
18
|
+
open: Token;
|
|
19
|
+
close: Token;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare function findActionToken(source: string, action: ActionNode, kind: Token["kind"]): Token | null;
|
|
22
|
+
export declare function insertBeforeClosingLine(source: string, closeOffset: number, text: string): MelTextEdit;
|
|
23
|
+
export declare function textEdit(source: string, start: number, end: number, replacement: string): MelTextEdit;
|
|
24
|
+
export declare function applyTextEdits(source: string, edits: readonly MelTextEdit[]): string;
|
|
25
|
+
export declare function requiredOffset(point: SourcePoint): number;
|
|
26
|
+
export declare function lineIndentAt(source: string, offset: number): string;
|
|
27
|
+
export declare function indentLines(source: string, indent: string): string;
|
|
28
|
+
export declare function renderAction(op: MelEditAddActionOp): string;
|
|
29
|
+
export declare function renderBodyReplacement(body: string, bodyIndent: string, actionIndent: string): string;
|
|
30
|
+
export declare function renderJsonLiteral(value: JsonLiteral): string;
|
|
31
|
+
export declare function diffSchemas(before: DomainSchema, after: DomainSchema): SchemaDiff;
|
|
32
|
+
export declare function sortTargets(targets: readonly LocalTargetKey[]): LocalTargetKey[];
|
|
33
|
+
export declare function isEditObject(value: unknown): value is {
|
|
34
|
+
readonly kind: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function describeUnknown(value: unknown): string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { DomainModule, JsonLiteral, LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import type { SourceSpan } from "../source-map.js";
|
|
3
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
4
|
+
export interface CompileFragmentInContextOptions {
|
|
5
|
+
readonly baseModule?: DomainModule;
|
|
6
|
+
readonly includeModule?: boolean;
|
|
7
|
+
readonly includeSchemaDiff?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MelEditResult {
|
|
10
|
+
readonly ok: boolean;
|
|
11
|
+
readonly newSource: string;
|
|
12
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
13
|
+
readonly module?: DomainModule;
|
|
14
|
+
readonly changedTargets: readonly LocalTargetKey[];
|
|
15
|
+
readonly edits: readonly MelTextEdit[];
|
|
16
|
+
readonly schemaDiff?: SchemaDiff;
|
|
17
|
+
}
|
|
18
|
+
export interface MelTextEdit {
|
|
19
|
+
readonly range: SourceSpan;
|
|
20
|
+
readonly replacement: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SchemaDiff {
|
|
23
|
+
readonly addedTargets: readonly LocalTargetKey[];
|
|
24
|
+
readonly removedTargets: readonly LocalTargetKey[];
|
|
25
|
+
readonly modifiedTargets: readonly SchemaModifiedTarget[];
|
|
26
|
+
}
|
|
27
|
+
export interface SchemaModifiedTarget {
|
|
28
|
+
readonly target: LocalTargetKey;
|
|
29
|
+
readonly beforeHash: string;
|
|
30
|
+
readonly afterHash: string;
|
|
31
|
+
readonly before?: unknown;
|
|
32
|
+
readonly after?: unknown;
|
|
33
|
+
}
|
|
34
|
+
export type MelParamSource = {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
};
|
|
38
|
+
export type MelEditOp = MelEditAddTypeOp | MelEditAddStateFieldOp | MelEditAddComputedOp | MelEditAddActionOp | MelEditAddAvailableOp | MelEditAddDispatchableOp | MelEditReplaceActionBodyOp | MelEditReplaceComputedExprOp | MelEditReplaceAvailableOp | MelEditReplaceDispatchableOp | MelEditReplaceStateDefaultOp | MelEditReplaceTypeFieldOp | MelEditRemoveDeclarationOp | MelEditRenameDeclarationOp;
|
|
39
|
+
export type MelEditAddTypeOp = {
|
|
40
|
+
readonly kind: "addType";
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly expr: string;
|
|
43
|
+
};
|
|
44
|
+
export type MelEditAddStateFieldOp = {
|
|
45
|
+
readonly kind: "addStateField";
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly type: string;
|
|
48
|
+
readonly defaultValue: JsonLiteral;
|
|
49
|
+
};
|
|
50
|
+
export type MelEditAddComputedOp = {
|
|
51
|
+
readonly kind: "addComputed";
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly expr: string;
|
|
54
|
+
};
|
|
55
|
+
export type MelEditAddActionOp = {
|
|
56
|
+
readonly kind: "addAction";
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly params: readonly MelParamSource[];
|
|
59
|
+
readonly body: string;
|
|
60
|
+
};
|
|
61
|
+
export type MelEditAddAvailableOp = {
|
|
62
|
+
readonly kind: "addAvailable";
|
|
63
|
+
readonly target: `action:${string}`;
|
|
64
|
+
readonly expr: string;
|
|
65
|
+
};
|
|
66
|
+
export type MelEditAddDispatchableOp = {
|
|
67
|
+
readonly kind: "addDispatchable";
|
|
68
|
+
readonly target: `action:${string}`;
|
|
69
|
+
readonly expr: string;
|
|
70
|
+
};
|
|
71
|
+
export type MelEditReplaceActionBodyOp = {
|
|
72
|
+
readonly kind: "replaceActionBody";
|
|
73
|
+
readonly target: `action:${string}`;
|
|
74
|
+
readonly body: string;
|
|
75
|
+
};
|
|
76
|
+
export type MelEditReplaceComputedExprOp = {
|
|
77
|
+
readonly kind: "replaceComputedExpr";
|
|
78
|
+
readonly target: `computed:${string}`;
|
|
79
|
+
readonly expr: string;
|
|
80
|
+
};
|
|
81
|
+
export type MelEditReplaceAvailableOp = {
|
|
82
|
+
readonly kind: "replaceAvailable";
|
|
83
|
+
readonly target: `action:${string}`;
|
|
84
|
+
readonly expr: string | null;
|
|
85
|
+
};
|
|
86
|
+
export type MelEditReplaceDispatchableOp = {
|
|
87
|
+
readonly kind: "replaceDispatchable";
|
|
88
|
+
readonly target: `action:${string}`;
|
|
89
|
+
readonly expr: string | null;
|
|
90
|
+
};
|
|
91
|
+
export type MelEditReplaceStateDefaultOp = {
|
|
92
|
+
readonly kind: "replaceStateDefault";
|
|
93
|
+
readonly target: `state_field:${string}`;
|
|
94
|
+
readonly value: JsonLiteral;
|
|
95
|
+
};
|
|
96
|
+
export type MelEditReplaceTypeFieldOp = {
|
|
97
|
+
readonly kind: "replaceTypeField";
|
|
98
|
+
readonly target: `type_field:${string}.${string}`;
|
|
99
|
+
readonly type: string;
|
|
100
|
+
};
|
|
101
|
+
export type MelEditRemoveDeclarationOp = {
|
|
102
|
+
readonly kind: "removeDeclaration";
|
|
103
|
+
readonly target: LocalTargetKey;
|
|
104
|
+
};
|
|
105
|
+
export type MelEditRenameDeclarationOp = {
|
|
106
|
+
readonly kind: "renameDeclaration";
|
|
107
|
+
readonly target: LocalTargetKey;
|
|
108
|
+
readonly newName: string;
|
|
109
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { DomainModule, LocalTargetKey } from "../annotations.js";
|
|
2
|
+
import { type Diagnostic } from "../diagnostics/types.js";
|
|
3
|
+
import { type ProgramNode } from "../parser/index.js";
|
|
4
|
+
import type { MelParamSource } from "./compile-fragment-types.js";
|
|
5
|
+
export declare const EMPTY_LOCATION: {
|
|
6
|
+
start: {
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
offset: number;
|
|
10
|
+
};
|
|
11
|
+
end: {
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
offset: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function editError(code: string, message: string, location?: ProgramNode["location"]): Diagnostic;
|
|
18
|
+
export declare function diagnosticsOf(result: {
|
|
19
|
+
warnings: readonly Diagnostic[];
|
|
20
|
+
errors: readonly Diagnostic[];
|
|
21
|
+
}): Diagnostic[];
|
|
22
|
+
export declare function parseProgram(source: string): {
|
|
23
|
+
program: ProgramNode | null;
|
|
24
|
+
diagnostics: Diagnostic[];
|
|
25
|
+
};
|
|
26
|
+
export declare function validateExpressionFragment(expr: unknown): Diagnostic[];
|
|
27
|
+
export declare function validateTypeFragment(typeSource: unknown): Diagnostic[];
|
|
28
|
+
export declare function validateStateFieldFragment(typeSource: unknown, defaultSource: string): Diagnostic[];
|
|
29
|
+
export declare function validateActionBodyFragment(body: unknown): Diagnostic[];
|
|
30
|
+
export declare function validateIdentifierFragment(value: unknown, label: string): Diagnostic[];
|
|
31
|
+
export declare function validateParamsFragment(params: unknown): Diagnostic[];
|
|
32
|
+
type ParamsFragmentSnapshot = {
|
|
33
|
+
readonly ok: true;
|
|
34
|
+
readonly value: readonly MelParamSource[];
|
|
35
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
36
|
+
} | {
|
|
37
|
+
readonly ok: false;
|
|
38
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
39
|
+
};
|
|
40
|
+
export declare function snapshotParamsFragment(params: unknown): ParamsFragmentSnapshot;
|
|
41
|
+
type EditOperationKindRead = {
|
|
42
|
+
readonly ok: true;
|
|
43
|
+
readonly value: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly ok: false;
|
|
46
|
+
readonly diagnostic: Diagnostic;
|
|
47
|
+
};
|
|
48
|
+
export declare function readEditOperationKind(value: unknown): EditOperationKindRead;
|
|
49
|
+
export declare function validateTarget(baseModule: DomainModule, target: unknown, allowedKinds: readonly string[]): Diagnostic | null;
|
|
50
|
+
export declare function targetNotFound(target: LocalTargetKey): Diagnostic;
|
|
51
|
+
export declare function targetKind(target: string): string | null;
|
|
52
|
+
export {};
|
|
@@ -4,11 +4,9 @@ import type { MelIRPatchPath } from "../lowering/lower-runtime-patch.js";
|
|
|
4
4
|
import type { GuardedStmtNode, InnerStmtNode, PatchStmtNode } from "../parser/ast.js";
|
|
5
5
|
import { toMelExpr } from "./compile-mel-patch-expr.js";
|
|
6
6
|
export interface PatchCollectContext {
|
|
7
|
-
actionName: string;
|
|
8
|
-
onceCounter: number;
|
|
9
|
-
onceIntentCounter: number;
|
|
10
|
-
whenCounter: number;
|
|
7
|
+
readonly actionName: string;
|
|
11
8
|
}
|
|
9
|
+
type AllowedSysPrefix = "input" | "runtime" | "context";
|
|
12
10
|
export type ConditionedPatchStatement = {
|
|
13
11
|
patch: PatchStmtNode;
|
|
14
12
|
condition?: MelExprNode;
|
|
@@ -19,11 +17,11 @@ export interface PatchCollectorDeps {
|
|
|
19
17
|
}
|
|
20
18
|
export declare class PatchStatementCollector {
|
|
21
19
|
private readonly deps;
|
|
22
|
-
private readonly conditionComposer;
|
|
23
20
|
private readonly exprValidator;
|
|
24
|
-
constructor(deps: PatchCollectorDeps);
|
|
21
|
+
constructor(deps: PatchCollectorDeps, allowSysPrefixes?: readonly AllowedSysPrefix[]);
|
|
25
22
|
collect(stmts: GuardedStmtNode[] | InnerStmtNode[], errors: Diagnostic[], context: PatchCollectContext, parentCondition: MelExprNode | undefined): ConditionedPatchStatement[];
|
|
26
23
|
private collectPatchStatements;
|
|
24
|
+
private pushUnsupportedControlError;
|
|
27
25
|
}
|
|
28
26
|
export declare function compilePatchStmtToMelRuntime(patchStatement: ConditionedPatchStatement): {
|
|
29
27
|
op: "set" | "unset" | "merge";
|
|
@@ -31,3 +29,4 @@ export declare function compilePatchStmtToMelRuntime(patchStatement: Conditioned
|
|
|
31
29
|
value?: MelExprNode;
|
|
32
30
|
condition?: MelExprNode;
|
|
33
31
|
};
|
|
32
|
+
export {};
|
|
@@ -81,11 +81,11 @@ export interface CompileMelPatchOptions {
|
|
|
81
81
|
*/
|
|
82
82
|
actionName: string;
|
|
83
83
|
/**
|
|
84
|
-
* Allowed
|
|
85
|
-
* Default: ["
|
|
84
|
+
* Allowed dollar namespace prefixes.
|
|
85
|
+
* Default: ["input", "runtime", "context"].
|
|
86
86
|
*/
|
|
87
87
|
allowSysPaths?: {
|
|
88
|
-
prefixes: ("
|
|
88
|
+
prefixes: ("input" | "runtime" | "context")[];
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* Function table version.
|
|
@@ -140,7 +140,7 @@ export declare function compileMelModule(melText: string, options?: CompileMelMo
|
|
|
140
140
|
* by evaluateRuntimePatches() to get concrete values.
|
|
141
141
|
*
|
|
142
142
|
* Constraints:
|
|
143
|
-
* -
|
|
143
|
+
* - ADR-027: `$system.*` and `$meta.*` are retired in current v5 MEL.
|
|
144
144
|
*
|
|
145
145
|
* @param melText - MEL patch source text
|
|
146
146
|
* @param options - Compilation options
|
package/dist/api/index.d.ts
CHANGED
|
@@ -5,5 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see SPEC v0.4.0 §19
|
|
7
7
|
*/
|
|
8
|
-
export type { Annotation, AnnotationIndex, CompileTrace, CompileMelDomainOptions, CompileMelDomainResult, CompileMelModuleOptions, CompileMelModuleResult,
|
|
9
|
-
export {
|
|
8
|
+
export type { Annotation, AnnotationIndex, CompileTrace, CompileMelDomainOptions, CompileMelDomainResult, CompileMelModuleOptions, CompileMelModuleResult, DomainModule, JsonLiteral, LocalTargetKey, SourceMapEmissionContext, SourceMapEntry, SourceMapIndex, SourceMapPath, SourcePoint, SourceSpan, } from "./compile-mel.js";
|
|
9
|
+
export type { CompileFragmentInContextOptions, MelEditAddActionOp, MelEditAddAvailableOp, MelEditAddComputedOp, MelEditAddDispatchableOp, MelEditAddStateFieldOp, MelEditAddTypeOp, MelEditOp, MelEditRemoveDeclarationOp, MelEditRenameDeclarationOp, MelEditReplaceActionBodyOp, MelEditReplaceAvailableOp, MelEditReplaceComputedExprOp, MelEditReplaceDispatchableOp, MelEditReplaceStateDefaultOp, MelEditReplaceTypeFieldOp, MelEditResult, MelParamSource, MelTextEdit, SchemaDiff, SchemaModifiedTarget, } from "./compile-fragment-in-context.js";
|
|
10
|
+
export { compileMelDomain, compileMelModule } from "./compile-mel.js";
|
|
11
|
+
export { compileFragmentInContext } from "./compile-fragment-in-context.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as f,b as g}from"./chunk-
|
|
1
|
+
import{a as f,b as g}from"./chunk-HOS3TLHW.js";import{aa as d}from"./chunk-JYNK3VUK.js";import{createHash as p}from"crypto";import*as i from"path";import{createUnplugin as h}from"unplugin";var M=new Set(["transform","build","both"]);function l(e){return e.split("?",1)[0]}function b(e,t){return e.lastIndex=0,e.test(t)}function y(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)?w(t):n.split(i.sep).join("/")}function w(e){let t=i.posix.basename(e)||"domain.mel",n=i.posix.extname(t),o=t.slice(0,t.length-n.length)||"domain",r=p("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 E(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(!M.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 O=h((e={})=>{let t=e.include??/\.mel$/,n=new Map,o=E(e.codegen);return{name:"manifesto:mel",enforce:"pre",transformInclude(r){return b(t,l(r))},async transform(r,s){let m=l(s),a=d(r,{mode:"domain"});if(a.errors.length>0){let u=a.errors.map(f).join(`
|
|
2
2
|
`);throw new Error(`MEL compilation failed for ${m}
|
|
3
3
|
${u}`)}if(!a.schema)throw new Error(`MEL compilation produced no schema for ${m}`);let c=y(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)),g(a.schema)},async buildEnd(){if(!(!o||n.size===0))for(let[r,s]of n)await o.emit({schema:s,sourceId:r})}}});export{O as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aa as t}from"./chunk-JYNK3VUK.js";function i(o){let e=o.location;if(!e)return`[${o.code}] ${o.message}`;let{line:r,column:n}=e.start;return`[${o.code}] ${o.message} (${r}:${n})`}function s(o){return`export default ${JSON.stringify(o,null,2)};
|
|
2
2
|
`}function a(o,e){let r=t(o,{mode:"domain"});if(r.errors.length>0){let n=r.errors.map(i).join(`
|
|
3
3
|
`);throw new Error(`MEL compilation failed for ${e}
|
|
4
4
|
${n}`)}if(!r.schema)throw new Error(`MEL compilation produced no schema for ${e}`);return s(r.schema)}export{i as a,s as b,a as c};
|