@blockml/compiler 0.1.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/blocks/org/blockml/bml/compiler/runtime/Library.bml +121 -0
- package/blocks/org/blockml/bml/compiler/runtime/README.bml +60 -0
- package/blocks/org/blockml/bml/compiler/runtime/RuntimeType.bml +36 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileBomOptions.bml +46 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileInput.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileOptions.bml +44 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileRequest.bml +42 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileScope.bml +45 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompileScopeKind.bml +44 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/CompilerResult.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/RenderContext.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/RenderOutput.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/RenderOutputFile.bml +42 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/RenderSession.bml +49 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/RenderTarget.bml +44 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/ResolvedScope.bml +44 -0
- package/blocks/org/blockml/bml/compiler/runtime/api/ScopeConfigHints.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/BuildRenderSession.bml +49 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/ClearTargets.bml +41 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/CompileBmlToBom.bml +52 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/CompileBmlToOutput.bml +54 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/CompileBomToOutput.bml +60 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/CompileToOutput.bml +58 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/CreateRenderContext.bml +54 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/GetTarget.bml +48 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/RegisterTarget.bml +47 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/RegisteredTargetNames.bml +41 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/ResolveScope.bml +54 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/ScopeAccepts.bml +51 -0
- package/blocks/org/blockml/bml/compiler/runtime/capability/ValidateRegistryDocuments.bml +51 -0
- package/blocks/org/blockml/bml/compiler/runtime/config/RuntimeConstants.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/ArchitectureOverview.bml +49 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/CompileIO.bml +44 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/CompileScopeRules.bml +46 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/DesignDecisions.bml +47 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/Diagnostics.bml +47 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/ExternalTargetContract.bml +63 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/Introduction.bml +49 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/LayerSeparation.bml +48 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/PackageOwnership.bml +46 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/PublicApi.bml +52 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/RenderContextRules.bml +47 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/ScopeExclusions.bml +43 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/TargetRegistry.bml +48 -0
- package/blocks/org/blockml/bml/compiler/runtime/documentation/V1Scope.bml +50 -0
- package/dist/compile-bml-to-bom.d.ts +6 -0
- package/dist/compile-bml-to-bom.d.ts.map +1 -0
- package/dist/compile-bml-to-bom.js +51 -0
- package/dist/compile-bml-to-bom.js.map +1 -0
- package/dist/compile-to-output.d.ts +6 -0
- package/dist/compile-to-output.d.ts.map +1 -0
- package/dist/compile-to-output.js +198 -0
- package/dist/compile-to-output.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/render-context.d.ts +12 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/render-context.js +33 -0
- package/dist/render-context.js.map +1 -0
- package/dist/scope.d.ts +8 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +71 -0
- package/dist/scope.js.map +1 -0
- package/dist/target-registry.d.ts +6 -0
- package/dist/target-registry.d.ts.map +1 -0
- package/dist/target-registry.js +41 -0
- package/dist/target-registry.js.map +1 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { registerTarget, getTarget, clearTargets, registeredTargetNames } from "./target-registry.js";
|
|
2
|
+
export { resolveScope, scopeAccepts } from "./scope.js";
|
|
3
|
+
export { compileBmlToBom, validateRegistryDocuments } from "./compile-bml-to-bom.js";
|
|
4
|
+
export { compileToOutput, compileBomToOutput, compileBmlToOutput, } from "./compile-to-output.js";
|
|
5
|
+
export { createRenderContext, buildRenderSession } from "./render-context.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RenderContext, RenderSession } from "./types.js";
|
|
2
|
+
export declare function createRenderContext(session: RenderSession, blockFqn?: string, outputRelativePath?: string): RenderContext;
|
|
3
|
+
export declare function buildRenderSession(options: {
|
|
4
|
+
typeRegistry: RenderSession["typeRegistry"];
|
|
5
|
+
targetName: string;
|
|
6
|
+
outputBasePath?: string;
|
|
7
|
+
sourceFilePath?: string;
|
|
8
|
+
scopeKind: RenderSession["scopeKind"];
|
|
9
|
+
libraryPaths?: string[];
|
|
10
|
+
corpusRoots?: string[];
|
|
11
|
+
}): RenderSession;
|
|
12
|
+
//# sourceMappingURL=render-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAsB/D,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,QAAQ,SAAK,EACb,kBAAkB,SAAK,GACtB,aAAa,CAEf;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE;IACP,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,GACA,aAAa,CAef"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class RenderContextImpl {
|
|
2
|
+
session;
|
|
3
|
+
blockFqn;
|
|
4
|
+
outputRelativePath;
|
|
5
|
+
constructor(session, blockFqn, outputRelativePath) {
|
|
6
|
+
this.session = session;
|
|
7
|
+
this.blockFqn = blockFqn;
|
|
8
|
+
this.outputRelativePath = outputRelativePath;
|
|
9
|
+
}
|
|
10
|
+
child(overrides) {
|
|
11
|
+
return new RenderContextImpl(this.session, overrides.blockFqn ?? this.blockFqn, overrides.outputRelativePath ?? this.outputRelativePath);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createRenderContext(session, blockFqn = "", outputRelativePath = "") {
|
|
15
|
+
return new RenderContextImpl(session, blockFqn, outputRelativePath);
|
|
16
|
+
}
|
|
17
|
+
export function buildRenderSession(options) {
|
|
18
|
+
const session = {
|
|
19
|
+
typeRegistry: options.typeRegistry,
|
|
20
|
+
sourceFilePath: options.sourceFilePath ?? "<scope>",
|
|
21
|
+
outputBasePath: options.outputBasePath ?? ".",
|
|
22
|
+
targetName: options.targetName,
|
|
23
|
+
scopeKind: options.scopeKind,
|
|
24
|
+
};
|
|
25
|
+
if (options.libraryPaths !== undefined) {
|
|
26
|
+
session.libraryPaths = options.libraryPaths;
|
|
27
|
+
}
|
|
28
|
+
if (options.corpusRoots !== undefined) {
|
|
29
|
+
session.corpusRoots = options.corpusRoots;
|
|
30
|
+
}
|
|
31
|
+
return session;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=render-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-context.js","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB;IACZ,OAAO,CAAgB;IACvB,QAAQ,CAAS;IACjB,kBAAkB,CAAS;IAEpC,YAAY,OAAsB,EAAE,QAAgB,EAAE,kBAA0B;QAC9E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,SAA4D;QAChE,OAAO,IAAI,iBAAiB,CAC1B,IAAI,CAAC,OAAO,EACZ,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EACnC,SAAS,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CACxD,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB,CACjC,OAAsB,EACtB,QAAQ,GAAG,EAAE,EACb,kBAAkB,GAAG,EAAE;IAEvB,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAQC;IAED,MAAM,OAAO,GAAkB;QAC7B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,SAAS;QACnD,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,GAAG;QAC7C,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;IACF,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC9C,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Diagnostic } from "@blockml/bom";
|
|
2
|
+
import type { CompileScope, ResolvedScope, ScopeConfigHints } from "./types.js";
|
|
3
|
+
export declare function resolveScope(scope: CompileScope, hints?: ScopeConfigHints): {
|
|
4
|
+
resolved: ResolvedScope | null;
|
|
5
|
+
diagnostics: Diagnostic[];
|
|
6
|
+
};
|
|
7
|
+
export declare function scopeAccepts(resolvedKind: Exclude<ResolvedScope["kind"], never>, accepts: Array<ResolvedScope["kind"] | "auto">): boolean;
|
|
8
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,KAAK,GAAE,gBAAqB,GAC3B;IAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAA;CAAE,CAiE/D;AAED,wBAAgB,YAAY,CAC1B,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EACnD,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAC7C,OAAO,CAWT"}
|
package/dist/scope.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export function resolveScope(scope, hints = {}) {
|
|
2
|
+
const diagnostics = [];
|
|
3
|
+
if (scope.kind === "document") {
|
|
4
|
+
if (!scope.document) {
|
|
5
|
+
diagnostics.push({
|
|
6
|
+
severity: "error",
|
|
7
|
+
code: "BML_COMPILE_SCOPE_EMPTY",
|
|
8
|
+
message: "Document scope requires scope.document",
|
|
9
|
+
source: { file: hints.rootDir ?? "<config>", line: 1, column: 1 },
|
|
10
|
+
});
|
|
11
|
+
return { resolved: null, diagnostics };
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
resolved: { kind: "document", document: scope.document },
|
|
15
|
+
diagnostics,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (scope.kind === "library") {
|
|
19
|
+
const libraries = scope.libraries ?? hints.libraries ?? [];
|
|
20
|
+
if (libraries.length === 0) {
|
|
21
|
+
diagnostics.push({
|
|
22
|
+
severity: "error",
|
|
23
|
+
code: "BML_COMPILE_SCOPE_EMPTY",
|
|
24
|
+
message: "Library scope requires libraries[]",
|
|
25
|
+
source: { file: hints.rootDir ?? "<config>", line: 1, column: 1 },
|
|
26
|
+
});
|
|
27
|
+
return { resolved: null, diagnostics };
|
|
28
|
+
}
|
|
29
|
+
return { resolved: { kind: "library", libraries }, diagnostics };
|
|
30
|
+
}
|
|
31
|
+
if (scope.kind === "corpus") {
|
|
32
|
+
const roots = scope.roots ?? hints.roots ?? [];
|
|
33
|
+
if (roots.length === 0) {
|
|
34
|
+
diagnostics.push({
|
|
35
|
+
severity: "error",
|
|
36
|
+
code: "BML_COMPILE_SCOPE_EMPTY",
|
|
37
|
+
message: "Corpus scope requires roots[]",
|
|
38
|
+
source: { file: hints.rootDir ?? "<config>", line: 1, column: 1 },
|
|
39
|
+
});
|
|
40
|
+
return { resolved: null, diagnostics };
|
|
41
|
+
}
|
|
42
|
+
return { resolved: { kind: "corpus", roots }, diagnostics };
|
|
43
|
+
}
|
|
44
|
+
// auto
|
|
45
|
+
const libraries = scope.libraries ?? hints.libraries ?? [];
|
|
46
|
+
if (libraries.length > 0) {
|
|
47
|
+
return { resolved: { kind: "library", libraries }, diagnostics };
|
|
48
|
+
}
|
|
49
|
+
const roots = scope.roots ?? hints.roots ?? [];
|
|
50
|
+
if (roots.length > 0) {
|
|
51
|
+
return { resolved: { kind: "corpus", roots }, diagnostics };
|
|
52
|
+
}
|
|
53
|
+
diagnostics.push({
|
|
54
|
+
severity: "error",
|
|
55
|
+
code: "BML_COMPILE_SCOPE_EMPTY",
|
|
56
|
+
message: "Auto scope resolution found no libraries or roots",
|
|
57
|
+
source: { file: hints.rootDir ?? "<config>", line: 1, column: 1 },
|
|
58
|
+
});
|
|
59
|
+
return { resolved: null, diagnostics };
|
|
60
|
+
}
|
|
61
|
+
export function scopeAccepts(resolvedKind, accepts) {
|
|
62
|
+
if (accepts.includes(resolvedKind)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (accepts.includes("auto") &&
|
|
66
|
+
(resolvedKind === "library" || resolvedKind === "corpus")) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,YAAY,CAC1B,KAAmB,EACnB,QAA0B,EAAE;IAE5B,MAAM,WAAW,GAAiB,EAAE,CAAC;IAErC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,WAAW,CAAC,IAAI,CAAC;gBACf,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,yBAAyB;gBAC/B,OAAO,EAAE,wCAAwC;gBACjD,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;aAClE,CAAC,CAAC;YACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QACzC,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;YACxD,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,SAA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,SAAS,IAAI,EAAE,CAAC;IAC3D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,CAAC;IACnE,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC;IAC9D,CAAC;IAED,WAAW,CAAC,IAAI,CAAC;QACf,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,mDAAmD;QAC5D,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KAClE,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,YAAmD,EACnD,OAA8C;IAE9C,IAAI,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IACE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QACxB,CAAC,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,QAAQ,CAAC,EACzD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RenderTarget } from "./types.js";
|
|
2
|
+
export declare function registerTarget(target: RenderTarget): void;
|
|
3
|
+
export declare function getTarget(name: string): RenderTarget | undefined;
|
|
4
|
+
export declare function clearTargets(): void;
|
|
5
|
+
export declare function registeredTargetNames(): string[];
|
|
6
|
+
//# sourceMappingURL=target-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target-registry.d.ts","sourceRoot":"","sources":["../src/target-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,YAAY,CAAC;AAsCjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAGzD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEhE;AAED,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const targets = new Map();
|
|
2
|
+
const VALID_SCOPE_KINDS = new Set([
|
|
3
|
+
"document",
|
|
4
|
+
"library",
|
|
5
|
+
"corpus",
|
|
6
|
+
"auto",
|
|
7
|
+
]);
|
|
8
|
+
function assertValidTarget(target) {
|
|
9
|
+
if (!target.name || typeof target.name !== "string" || target.name.trim() === "") {
|
|
10
|
+
throw new Error("registerTarget: name must be a non-empty string");
|
|
11
|
+
}
|
|
12
|
+
if (!Array.isArray(target.accepts) || target.accepts.length === 0) {
|
|
13
|
+
throw new Error(`registerTarget: target "${target.name}" accepts must be a non-empty array`);
|
|
14
|
+
}
|
|
15
|
+
for (const kind of target.accepts) {
|
|
16
|
+
if (!VALID_SCOPE_KINDS.has(kind)) {
|
|
17
|
+
throw new Error(`registerTarget: target "${target.name}" has invalid accepts value: ${String(kind)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (typeof target.render !== "function") {
|
|
21
|
+
throw new Error(`registerTarget: target "${target.name}" render must be a function`);
|
|
22
|
+
}
|
|
23
|
+
if (target.validateRequest !== undefined &&
|
|
24
|
+
typeof target.validateRequest !== "function") {
|
|
25
|
+
throw new Error(`registerTarget: target "${target.name}" validateRequest must be a function when set`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function registerTarget(target) {
|
|
29
|
+
assertValidTarget(target);
|
|
30
|
+
targets.set(target.name, target);
|
|
31
|
+
}
|
|
32
|
+
export function getTarget(name) {
|
|
33
|
+
return targets.get(name);
|
|
34
|
+
}
|
|
35
|
+
export function clearTargets() {
|
|
36
|
+
targets.clear();
|
|
37
|
+
}
|
|
38
|
+
export function registeredTargetNames() {
|
|
39
|
+
return [...targets.keys()];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=target-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target-registry.js","sourceRoot":"","sources":["../src/target-registry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAmB;IAClD,UAAU;IACV,SAAS;IACT,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,MAAoB;IAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjF,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,qCAAqC,CAAC,CAAC;IAC/F,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,IAAI,gCAAgC,MAAM,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,6BAA6B,CAAC,CAAC;IACvF,CAAC;IACD,IACE,MAAM,CAAC,eAAe,KAAK,SAAS;QACpC,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAC5C,CAAC;QACD,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,IAAI,+CAA+C,CACtF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Diagnostic } from "@blockml/bom";
|
|
2
|
+
import type { TypeRegistry } from "@blockml/framework";
|
|
3
|
+
export type CompileScopeKind = "document" | "library" | "corpus" | "auto";
|
|
4
|
+
export interface CompileInput {
|
|
5
|
+
source: string;
|
|
6
|
+
filePath: string;
|
|
7
|
+
format?: "xml";
|
|
8
|
+
}
|
|
9
|
+
export interface CompileScope {
|
|
10
|
+
kind: CompileScopeKind;
|
|
11
|
+
document?: CompileInput;
|
|
12
|
+
libraries?: string[];
|
|
13
|
+
roots?: string[];
|
|
14
|
+
includeDependencies?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface CompileRequest {
|
|
17
|
+
scope: CompileScope;
|
|
18
|
+
targetOptions?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface CompileOptions {
|
|
21
|
+
typeRegistry?: TypeRegistry;
|
|
22
|
+
outputBasePath?: string;
|
|
23
|
+
rootDir?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Options for BOM-first Stage-3 (compileBomToOutput). typeRegistry is required. */
|
|
26
|
+
export interface CompileBomOptions {
|
|
27
|
+
typeRegistry: TypeRegistry;
|
|
28
|
+
outputBasePath?: string;
|
|
29
|
+
rootDir?: string;
|
|
30
|
+
targetOptions?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface CompilerResult<T> {
|
|
33
|
+
output: T | null;
|
|
34
|
+
diagnostics: Diagnostic[];
|
|
35
|
+
success: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface RenderOutputFile {
|
|
38
|
+
path: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RenderOutput {
|
|
42
|
+
files: RenderOutputFile[];
|
|
43
|
+
/** Files written at project root (e.g. catalog.xml). CLI-owned write path. */
|
|
44
|
+
rootFiles?: RenderOutputFile[];
|
|
45
|
+
/** Target-emitted diagnostics merged by CLI after compile. */
|
|
46
|
+
diagnostics?: Diagnostic[];
|
|
47
|
+
}
|
|
48
|
+
export interface RenderSession {
|
|
49
|
+
typeRegistry: TypeRegistry;
|
|
50
|
+
sourceFilePath: string;
|
|
51
|
+
outputBasePath: string;
|
|
52
|
+
targetName: string;
|
|
53
|
+
/** Resolved scope kind after auto resolution. */
|
|
54
|
+
scopeKind: Exclude<CompileScopeKind, "auto">;
|
|
55
|
+
/** Library.bml paths when scope is library. */
|
|
56
|
+
libraryPaths?: string[];
|
|
57
|
+
/** Corpus roots when scope is corpus. */
|
|
58
|
+
corpusRoots?: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface RenderContext {
|
|
61
|
+
session: RenderSession;
|
|
62
|
+
blockFqn: string;
|
|
63
|
+
outputRelativePath: string;
|
|
64
|
+
child(overrides: Partial<Omit<RenderContext, "session" | "child">>): RenderContext;
|
|
65
|
+
}
|
|
66
|
+
export interface RenderTarget {
|
|
67
|
+
name: string;
|
|
68
|
+
accepts: CompileScopeKind[];
|
|
69
|
+
validateRequest?(request: CompileRequest): Diagnostic[];
|
|
70
|
+
render(request: CompileRequest, ctx: RenderContext): RenderOutput;
|
|
71
|
+
}
|
|
72
|
+
export interface ScopeConfigHints {
|
|
73
|
+
libraries?: string[];
|
|
74
|
+
roots?: string[];
|
|
75
|
+
rootDir?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ResolvedScope {
|
|
78
|
+
kind: Exclude<CompileScopeKind, "auto">;
|
|
79
|
+
document?: CompileInput;
|
|
80
|
+
libraries?: string[];
|
|
81
|
+
roots?: string[];
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1E,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE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AAE,CAAC;IACxB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,aAAa,CAAC;CACpF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,eAAe,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,EAAE,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blockml/compiler",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "BlockML compiler — facade, target registry, render pipeline",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/pks5/blockml-toolchain.git",
|
|
9
|
+
"directory": "packages/compiler"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"blockml": {
|
|
17
|
+
"library": "./blocks/org/blockml/bml/compiler/runtime/Library.bml"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"blocks"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc --build",
|
|
31
|
+
"prepublishOnly": "npm run build",
|
|
32
|
+
"test": "vitest run packages/compiler/test"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@blockml/bom": "^0.1.0",
|
|
36
|
+
"@blockml/framework": "^0.1.0",
|
|
37
|
+
"@blockml/parser": "^0.1.0",
|
|
38
|
+
"@blockml/validator": "^0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
}
|
|
43
|
+
}
|