behavior-contracts 0.9.3 → 0.10.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/cli-contract.yaml +116 -24
- package/dist/authoring.d.ts +18 -1
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +11 -0
- package/dist/authoring.js.map +1 -1
- package/dist/behavior.d.ts +23 -0
- package/dist/behavior.d.ts.map +1 -1
- package/dist/behavior.js.map +1 -1
- package/dist/bind.d.ts +1 -1
- package/dist/bind.d.ts.map +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +21 -6
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +65 -40
- package/dist/cli.js.map +1 -1
- package/dist/commands/codegen.d.ts +18 -12
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +111 -27
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/ts-extract.d.ts +26 -0
- package/dist/commands/ts-extract.d.ts.map +1 -0
- package/dist/commands/ts-extract.js +265 -0
- package/dist/commands/ts-extract.js.map +1 -0
- package/dist/generated/commands.d.ts.map +1 -1
- package/dist/generated/commands.js +8 -0
- package/dist/generated/commands.js.map +1 -1
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +2 -2
- package/dist/generated/contract.js.map +1 -1
- package/dist/generated/program.d.ts +4 -0
- package/dist/generated/program.d.ts.map +1 -1
- package/dist/generated/program.js +7 -3
- package/dist/generated/program.js.map +1 -1
- package/dist/generated/types.d.ts +6 -2
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-go.d.ts +5 -7
- package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-go.js +244 -404
- package/dist/generator/emit-typed-native-go.js.map +1 -1
- package/dist/generator/emit-typed-native-rust.d.ts +6 -8
- package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-rust.js +234 -371
- package/dist/generator/emit-typed-native-rust.js.map +1 -1
- package/dist/guard.d.ts +23 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +52 -0
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +3 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/ir-handle.d.ts +30 -0
- package/dist/ir-handle.d.ts.map +1 -0
- package/dist/ir-handle.js +2 -0
- package/dist/ir-handle.js.map +1 -0
- package/dist/provenance.d.ts +1 -1
- package/dist/provenance.d.ts.map +1 -1
- package/package.json +9 -1
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
import type { ComponentGraphIRDoc } from "../ir-handle.js";
|
|
2
|
+
import { type GenerateOptions } from "../generator/index.js";
|
|
3
|
+
/** `--in` covered path: a serialized IR doc → the native module source (same emit as the in-process API).
|
|
4
|
+
* Adopts the unbranded doc via {@link loadCompiledIR} (recomputes + mints the provenance token), then hands
|
|
5
|
+
* the compiled IR to the shared {@link emitCovered} seam. */
|
|
6
6
|
export declare function generateFromDoc(doc: ComponentGraphIRDoc, language: string, runtimeImport?: string, leafTransport?: GenerateOptions["leafTransport"], sharedTypesImport?: string): string;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/**
|
|
8
|
+
* `--from` covered path (the TS-authoring codegen entry — ts→ir→native一気通貫). Compiles the consumer's
|
|
9
|
+
* `--behavior` class to IR via {@link compileFromModule}, then hands that IR to the SAME {@link emitCovered}
|
|
10
|
+
* seam `--in` uses (no emit reimplementation). The IR is produced and consumed entirely inside the CLI — it
|
|
11
|
+
* never crosses the consumer surface.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateFromModule(fromPath: string, behaviorName: string, language: string, runtimeImport?: string, leafTransport?: GenerateOptions["leafTransport"], sharedTypesImport?: string): Promise<string>;
|
|
14
|
+
/** `--in` shared-types path: a serialized IR doc → the BC-OWNED shared wire types module (the same one the
|
|
15
|
+
* covered module imports when generated with --shared-types-import). Adopts via {@link loadCompiledIR} (the
|
|
16
|
+
* SAME adopt path the covered module uses), then hands off to the shared {@link emitSharedTypes} seam. */
|
|
14
17
|
export declare function generateSharedTypesFromDoc(doc: ComponentGraphIRDoc, language: string, sharedTypesImport?: string): string;
|
|
18
|
+
/** `--from` shared-types path: compile the consumer's behavior module via the SAME {@link compileFromModule}
|
|
19
|
+
* seam, and emit the BC-owned shared wire types module over the SAME {@link emitSharedTypes} seam `--in` uses. */
|
|
20
|
+
export declare function generateSharedTypesFromModule(fromPath: string, behaviorName: string, language: string, sharedTypesImport?: string): Promise<string>;
|
|
15
21
|
/** Read + parse a serialized ComponentGraphIRDoc from disk. */
|
|
16
22
|
export declare function readDoc(inPath: string): ComponentGraphIRDoc;
|
|
17
23
|
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAoB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAkC/B;;6DAE6D;AAC7D,wBAAgB,eAAe,CAC7B,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,EAChD,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,EAChD,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB;AA+ED;;0GAE0G;AAC1G,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CAER;AAED;kHACkH;AAClH,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,+DAA+D;AAC/D,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAY3D"}
|
package/dist/commands/codegen.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
// ════════════════════════════════════════════════════════════════════════════
|
|
2
10
|
// codegen — the pure core behind `bc generate` / `bc check`.
|
|
3
11
|
//
|
|
@@ -10,20 +18,29 @@
|
|
|
10
18
|
// in-process; the cli.ts handlers add I/O + exit semantics around it.
|
|
11
19
|
// ════════════════════════════════════════════════════════════════════════════
|
|
12
20
|
import { readFileSync } from "node:fs";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
import { resolve } from "node:path";
|
|
22
|
+
import { pathToFileURL } from "node:url";
|
|
23
|
+
// The codegen/compile/IR-handle surface is INTERNAL (#176): the consumer authors TS and never touches the IR,
|
|
24
|
+
// so these come from the internal modules directly, NOT the public ../index.ts. `bc` is the only caller.
|
|
25
|
+
import { compileBehaviors } from "../authoring.js";
|
|
26
|
+
import { loadCompiledIR } from "../provenance.js";
|
|
27
|
+
import { generateModule, registeredLanguages, rustSharedWireTypesModule, goSharedWireTypesPackage, goSharedTypesPackageName, } from "../generator/index.js";
|
|
28
|
+
// The build-time TypeScript bridge for `--from <.ts>` (type-extraction + decorator-aware transpile). Its
|
|
29
|
+
// `typescript` dependency is dynamic-imported inside ts-extract, so it never reaches the runtime entry.
|
|
30
|
+
import { isTypeScriptSource, extractInputPorts, transpileAndLoad } from "./ts-extract.js";
|
|
31
|
+
/** Guard: reject an unregistered --lang once, at the boundary both emit seams share. */
|
|
32
|
+
function assertRegistered(language) {
|
|
23
33
|
if (!registeredLanguages().includes(language)) {
|
|
24
34
|
throw new Error(`--lang '${language}' is not a registered emitter (registered: ${registeredLanguages().join(", ")})`);
|
|
25
35
|
}
|
|
26
|
-
|
|
36
|
+
}
|
|
37
|
+
/** The covered-module emit over an ALREADY-compiled IR — the single seam both input modes converge on
|
|
38
|
+
* (`--in`: {@link loadCompiledIR}(doc); `--from`: {@link compileBehaviors}(class)). NO emit logic here:
|
|
39
|
+
* forwards to the EXISTING `generateModule` with the same options both modes use. `leafTransport` (native
|
|
40
|
+
* emitters only) + `sharedTypesImport` (go/rust cross-package: BC-generated shared wire types package) are
|
|
41
|
+
* forwarded verbatim; other emitters ignore them. */
|
|
42
|
+
function emitCovered(ir, language, runtimeImport, leafTransport, sharedTypesImport) {
|
|
43
|
+
assertRegistered(language);
|
|
27
44
|
const options = { language };
|
|
28
45
|
if (runtimeImport !== undefined)
|
|
29
46
|
options.runtimeImport = runtimeImport;
|
|
@@ -31,35 +48,102 @@ export function generateFromDoc(doc, language, runtimeImport, leafTransport, sha
|
|
|
31
48
|
options.leafTransport = leafTransport;
|
|
32
49
|
if (sharedTypesImport !== undefined)
|
|
33
50
|
options.sharedTypesImport = sharedTypesImport;
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
return generateModule(ir, options).code;
|
|
52
|
+
}
|
|
53
|
+
/** `--in` covered path: a serialized IR doc → the native module source (same emit as the in-process API).
|
|
54
|
+
* Adopts the unbranded doc via {@link loadCompiledIR} (recomputes + mints the provenance token), then hands
|
|
55
|
+
* the compiled IR to the shared {@link emitCovered} seam. */
|
|
56
|
+
export function generateFromDoc(doc, language, runtimeImport, leafTransport, sharedTypesImport) {
|
|
57
|
+
return emitCovered(loadCompiledIR(doc), language, runtimeImport, leafTransport, sharedTypesImport);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `--from` covered path (the TS-authoring codegen entry — ts→ir→native一気通貫). Compiles the consumer's
|
|
61
|
+
* `--behavior` class to IR via {@link compileFromModule}, then hands that IR to the SAME {@link emitCovered}
|
|
62
|
+
* seam `--in` uses (no emit reimplementation). The IR is produced and consumed entirely inside the CLI — it
|
|
63
|
+
* never crosses the consumer surface.
|
|
64
|
+
*/
|
|
65
|
+
export async function generateFromModule(fromPath, behaviorName, language, runtimeImport, leafTransport, sharedTypesImport) {
|
|
66
|
+
return emitCovered(await compileFromModule(fromPath, behaviorName), language, runtimeImport, leafTransport, sharedTypesImport);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The single `--from` ts→ir seam both the covered and shared-types module paths compile through. Branches on
|
|
70
|
+
* the input kind:
|
|
71
|
+
* - **`.ts` SOURCE** (the TS-authoring surface): the TS compiler extracts the `$: In<T>` input-port types
|
|
72
|
+
* ({@link extractInputPorts} — `In<T>` is erased at runtime, so native emit of an input-typed behavior
|
|
73
|
+
* needs this) AND transpiles + loads the module ({@link transpileAndLoad} — Node type-stripping rejects
|
|
74
|
+
* `@behavior` decorators). Then `compileBehaviors(cls, { inputPorts })`.
|
|
75
|
+
* - **compiled `.js`/`.mjs`**: direct `import()`. No TS type info is available, so no input-port types are
|
|
76
|
+
* supplied — native emit is limited to shapes with no dynamic `$` input port (interpreter targets and
|
|
77
|
+
* literal/leaf-fed reads still work).
|
|
78
|
+
*
|
|
79
|
+
* Either way the consumer module's `behavior-contracts` import MUST resolve to the SAME package instance as
|
|
80
|
+
* this CLI: ESM caches by resolved file URL, and `@behavior`/`defineLeaf` share a process-global compile
|
|
81
|
+
* frame (authoring.ts `currentFrame`), so a duplicate package instance would record leaf calls into a
|
|
82
|
+
* different frame and break compilation. In an installed layout both resolve to the one
|
|
83
|
+
* `node_modules/behavior-contracts`.
|
|
84
|
+
*/
|
|
85
|
+
async function compileFromModule(fromPath, behaviorName) {
|
|
86
|
+
if (isTypeScriptSource(fromPath)) {
|
|
87
|
+
const inputPorts = await extractInputPorts(fromPath, behaviorName);
|
|
88
|
+
const cls = pickBehaviorClass(await transpileAndLoad(fromPath), behaviorName, fromPath);
|
|
89
|
+
return compileBehaviors(cls, { inputPorts });
|
|
90
|
+
}
|
|
91
|
+
let mod;
|
|
92
|
+
const url = pathToFileURL(resolve(fromPath)).href;
|
|
93
|
+
try {
|
|
94
|
+
mod = (await import(__rewriteRelativeImportExtension(url)));
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
throw new Error(`cannot import --from '${fromPath}': ${e instanceof Error ? e.message : String(e)}`);
|
|
98
|
+
}
|
|
99
|
+
return compileBehaviors(pickBehaviorClass(mod, behaviorName, fromPath));
|
|
100
|
+
}
|
|
101
|
+
/** Pick + validate the `--behavior` export from a loaded module namespace (the SINGLE export-name check for
|
|
102
|
+
* both the `.ts` and compiled-module paths). */
|
|
103
|
+
function pickBehaviorClass(mod, behaviorName, fromPath) {
|
|
104
|
+
const cls = mod[behaviorName];
|
|
105
|
+
if (cls === undefined) {
|
|
106
|
+
const exports = Object.keys(mod).filter((k) => k !== "default");
|
|
107
|
+
throw new Error(`--behavior '${behaviorName}' is not an export of --from '${fromPath}' ` +
|
|
108
|
+
`(exports: ${exports.length ? exports.join(", ") : "<none>"})`);
|
|
109
|
+
}
|
|
110
|
+
if (typeof cls !== "function")
|
|
111
|
+
throw new Error(`--behavior '${behaviorName}' from '${fromPath}' is not a class`);
|
|
112
|
+
return cls;
|
|
36
113
|
}
|
|
37
114
|
/** The emitters that own a BC-generated shared wire types module (the cross-package / cross-crate layout). */
|
|
38
115
|
const SHARED_TYPES_LANGUAGES = ["go-typed-native", "rust-typed-native"];
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!registeredLanguages().includes(language)) {
|
|
48
|
-
throw new Error(`--lang '${language}' is not a registered emitter (registered: ${registeredLanguages().join(", ")})`);
|
|
49
|
-
}
|
|
116
|
+
/** The BC-OWNED shared wire types emit over an ALREADY-compiled IR — the single seam both input modes
|
|
117
|
+
* converge on. NO emit logic is reimplemented: validates the emitter then dispatches to the EXISTING
|
|
118
|
+
* rustSharedWireTypesModule / goSharedWireTypesPackage. Only go-typed-native / rust-typed-native own a shared
|
|
119
|
+
* module — any other --lang is a loud error. For go the package name is SSoT-derived from `sharedTypesImport`
|
|
120
|
+
* (goSharedTypesPackageName, the SAME normalization resolveGoWire uses to selector-qualify the hoisted
|
|
121
|
+
* types), so --shared-types-import is required; rust's shared module content needs no import. */
|
|
122
|
+
function emitSharedTypes(ir, language, sharedTypesImport) {
|
|
123
|
+
assertRegistered(language);
|
|
50
124
|
if (!SHARED_TYPES_LANGUAGES.includes(language)) {
|
|
51
125
|
throw new Error(`--shared-types-out is only supported for ${SHARED_TYPES_LANGUAGES.join(" / ")} (got --lang '${language}')`);
|
|
52
126
|
}
|
|
53
|
-
const compiled = loadCompiledIR(doc); // same adopt path the covered module uses (recompute + mint provenance)
|
|
54
127
|
if (language === "rust-typed-native")
|
|
55
|
-
return rustSharedWireTypesModule(
|
|
128
|
+
return rustSharedWireTypesModule();
|
|
56
129
|
// go: the shared package's Go identifier must be derived from --shared-types-import via the SAME
|
|
57
130
|
// normalization the covered module uses to reference it, so --shared-types-import is required.
|
|
58
131
|
if (sharedTypesImport === undefined) {
|
|
59
132
|
throw new Error("--shared-types-out for go-typed-native requires --shared-types-import (the shared package's Go import " +
|
|
60
133
|
"path — its last segment names the emitted package, matching what the covered module imports)");
|
|
61
134
|
}
|
|
62
|
-
return goSharedWireTypesPackage(goSharedTypesPackageName(sharedTypesImport)
|
|
135
|
+
return goSharedWireTypesPackage(goSharedTypesPackageName(sharedTypesImport));
|
|
136
|
+
}
|
|
137
|
+
/** `--in` shared-types path: a serialized IR doc → the BC-OWNED shared wire types module (the same one the
|
|
138
|
+
* covered module imports when generated with --shared-types-import). Adopts via {@link loadCompiledIR} (the
|
|
139
|
+
* SAME adopt path the covered module uses), then hands off to the shared {@link emitSharedTypes} seam. */
|
|
140
|
+
export function generateSharedTypesFromDoc(doc, language, sharedTypesImport) {
|
|
141
|
+
return emitSharedTypes(loadCompiledIR(doc), language, sharedTypesImport);
|
|
142
|
+
}
|
|
143
|
+
/** `--from` shared-types path: compile the consumer's behavior module via the SAME {@link compileFromModule}
|
|
144
|
+
* seam, and emit the BC-owned shared wire types module over the SAME {@link emitSharedTypes} seam `--in` uses. */
|
|
145
|
+
export async function generateSharedTypesFromModule(fromPath, behaviorName, language, sharedTypesImport) {
|
|
146
|
+
return emitSharedTypes(await compileFromModule(fromPath, behaviorName), language, sharedTypesImport);
|
|
63
147
|
}
|
|
64
148
|
/** Read + parse a serialized ComponentGraphIRDoc from disk. */
|
|
65
149
|
export function readDoc(inPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,oDAAoD;AACpD,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":";;;;;;;;AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,oDAAoD;AACpD,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,8GAA8G;AAC9G,yGAAyG;AACzG,OAAO,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,yGAAyG;AACzG,wGAAwG;AACxG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE1F,wFAAwF;AACxF,SAAS,gBAAgB,CAAC,QAAgB;IACxC,IAAI,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,8CAA8C,mBAAmB,EAAE,CAAC,IAAI,CAAC,IA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AE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACvG,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,GAAG,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAwB,CAAC;IAChD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,wBAAwB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PortSchema } from "../behavior.js";
|
|
2
|
+
/** Is this specifier a TypeScript SOURCE module (needs the TS compiler) vs a compiled `.js`/`.mjs`? */
|
|
3
|
+
export declare function isTypeScriptSource(fromPath: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Extract `Record<method, Record<port, PortSchema>>` from a consumer `.ts` behavior module for the class
|
|
6
|
+
* `behaviorName` — the `inputPorts` structure compileBehaviors consumes. Uses a ts.Program + checker so
|
|
7
|
+
* `In<T>` (imported from behavior-contracts) and named/imported member interfaces resolve. Each public
|
|
8
|
+
* method's first parameter (`$`) type → its members → {@link tsTypeToPortSchema}. A method with no `$` (or no
|
|
9
|
+
* members) contributes no entry. Fail-closed LOUD on any unmappable member type.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractInputPorts(fromPath: string, behaviorName: string): Promise<Record<string, Record<string, PortSchema>>>;
|
|
12
|
+
/**
|
|
13
|
+
* Transpile a consumer `.ts` behavior module to a sibling ESM file, import it, and return its namespace. The
|
|
14
|
+
* temp file is written NEXT TO the source so its `behavior-contracts` (and any relative) imports resolve
|
|
15
|
+
* identically to the source — the precondition for sharing the process-global @behavior/defineLeaf compile
|
|
16
|
+
* frame with the CLI.
|
|
17
|
+
*
|
|
18
|
+
* Emit: `experimentalDecorators: true` (LEGACY decorator emit). `@behavior` is a dual-mode marker (TC39
|
|
19
|
+
* standard AND legacy), and legacy emit keeps the class body clean (`class X {}` then
|
|
20
|
+
* `X = __decorate([behavior], X)`), whereas STANDARD downlevel emit injects helper code (`typeof Symbol ===
|
|
21
|
+
* "function" …`) INTO the class source — which compileBehaviors' native-control-syntax scanner (it reads
|
|
22
|
+
* `class.toString()`) would reject. Module: ESNext, so the output is ESM regardless of the consumer dir's
|
|
23
|
+
* package.json `type`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function transpileAndLoad(fromPath: string): Promise<Record<string, unknown>>;
|
|
26
|
+
//# sourceMappingURL=ts-extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-extract.d.ts","sourceRoot":"","sources":["../../src/commands/ts-extract.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsB/D,uGAAuG;AACvG,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAID;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAwCrD;AAwHD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8BzF"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
10
|
+
// ts-extract — the BUILD-TIME TypeScript bridge behind `bc generate --from <.ts>`.
|
|
11
|
+
//
|
|
12
|
+
// The consumer authors behaviors in TS SOURCE and never touches the IR (#176). For a `.ts` --from module the
|
|
13
|
+
// CLI uses the TypeScript compiler to do two build-time-only jobs, then hands the result to the SAME
|
|
14
|
+
// compileBehaviors → generateModule pipeline the rest of the CLI uses:
|
|
15
|
+
//
|
|
16
|
+
// 1. INPUT-PORT TYPE EXTRACTION (extractInputPorts): a ts.Program + type-checker resolves each public
|
|
17
|
+
// method's `$: In<T>` parameter type and maps its members to the `PortSchema` structure compileBehaviors'
|
|
18
|
+
// `inputPorts` option expects (Record<method, Record<port, PortSchema>>). `In<T>` types are erased at
|
|
19
|
+
// runtime, so this is THE type-extraction seam authoring.ts documents ("型抽出ツールの接続点"). BC never
|
|
20
|
+
// infers types (consumer-interface.md C3) — extraction reads the consumer's DECLARED TS type and
|
|
21
|
+
// fail-closes LOUD on anything it cannot map faithfully to a PortSchema (never a silent unknown/value).
|
|
22
|
+
// 2. TRANSPILE + LOAD (transpileAndLoad): Node's own type-stripping rejects `@behavior` DECORATOR syntax,
|
|
23
|
+
// so a `.ts` is transpiled with the TS compiler (legacy decorator emit — see below) to a sibling ESM
|
|
24
|
+
// module and imported. Its `behavior-contracts` import resolves through the consumer's node_modules to
|
|
25
|
+
// the SAME package instance as the CLI (shared @behavior/defineLeaf compile frame).
|
|
26
|
+
//
|
|
27
|
+
// `typescript` is a build-time-only OPTIONAL PEER dependency (see package.json). It is imported dynamically
|
|
28
|
+
// HERE and nowhere on the runtime entry (../index.ts), so the published runtime stays dependency-free.
|
|
29
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
30
|
+
import { readFileSync, writeFileSync, rmSync } from "node:fs";
|
|
31
|
+
import { pathToFileURL } from "node:url";
|
|
32
|
+
import { dirname, join } from "node:path";
|
|
33
|
+
import { randomUUID } from "node:crypto";
|
|
34
|
+
import { portSchemaFromPortable } from "../authoring.js";
|
|
35
|
+
/** Dynamic-import the OPTIONAL PEER `typescript`. Absent → a loud, actionable error (a `.ts` --from module
|
|
36
|
+
* needs the TS compiler; a consumer authoring TS already has it, or can pass a prebuilt `.js`/`.mjs`). */
|
|
37
|
+
async function loadTypeScript(fromPath) {
|
|
38
|
+
try {
|
|
39
|
+
return (await import("typescript")).default ?? (await import("typescript"));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new Error(`--from '${fromPath}' is a .ts module, which requires the 'typescript' peer dependency to type-extract ` +
|
|
43
|
+
`+ transpile it. Install typescript (it is a build-time-only optional peer), or pass a prebuilt .js/.mjs.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Is this specifier a TypeScript SOURCE module (needs the TS compiler) vs a compiled `.js`/`.mjs`? */
|
|
47
|
+
export function isTypeScriptSource(fromPath) {
|
|
48
|
+
return /\.(?:m|c)?ts$/i.test(fromPath) && !/\.d\.ts$/i.test(fromPath);
|
|
49
|
+
}
|
|
50
|
+
// ── (1) input-port type extraction ──────────────────────────────────────────────────────────────────────
|
|
51
|
+
/**
|
|
52
|
+
* Extract `Record<method, Record<port, PortSchema>>` from a consumer `.ts` behavior module for the class
|
|
53
|
+
* `behaviorName` — the `inputPorts` structure compileBehaviors consumes. Uses a ts.Program + checker so
|
|
54
|
+
* `In<T>` (imported from behavior-contracts) and named/imported member interfaces resolve. Each public
|
|
55
|
+
* method's first parameter (`$`) type → its members → {@link tsTypeToPortSchema}. A method with no `$` (or no
|
|
56
|
+
* members) contributes no entry. Fail-closed LOUD on any unmappable member type.
|
|
57
|
+
*/
|
|
58
|
+
export async function extractInputPorts(fromPath, behaviorName) {
|
|
59
|
+
const ts = await loadTypeScript(fromPath);
|
|
60
|
+
const program = ts.createProgram([fromPath], {
|
|
61
|
+
module: ts.ModuleKind.NodeNext,
|
|
62
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
63
|
+
target: ts.ScriptTarget.ES2022,
|
|
64
|
+
strict: true,
|
|
65
|
+
skipLibCheck: true,
|
|
66
|
+
allowImportingTsExtensions: true,
|
|
67
|
+
noEmit: true,
|
|
68
|
+
});
|
|
69
|
+
const checker = program.getTypeChecker();
|
|
70
|
+
const sf = program.getSourceFile(fromPath);
|
|
71
|
+
if (sf === undefined)
|
|
72
|
+
throw new Error(`--from '${fromPath}': the TypeScript compiler could not read the source file`);
|
|
73
|
+
const cls = findClass(ts, sf, behaviorName);
|
|
74
|
+
if (cls === undefined)
|
|
75
|
+
throw new Error(`--behavior '${behaviorName}' is not a class declared in --from '${fromPath}'`);
|
|
76
|
+
const out = {};
|
|
77
|
+
for (const member of cls.members) {
|
|
78
|
+
if (!ts.isMethodDeclaration(member))
|
|
79
|
+
continue;
|
|
80
|
+
if (member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword))
|
|
81
|
+
continue;
|
|
82
|
+
const name = member.name && ts.isIdentifier(member.name) ? member.name.text : undefined;
|
|
83
|
+
// mirror compileBehaviors' public-method rule: skip constructor / `_`-helper / `#`-private / computed names.
|
|
84
|
+
if (name === undefined || name.startsWith("_"))
|
|
85
|
+
continue;
|
|
86
|
+
const param = member.parameters[0]; // `$` (the Input Port bundle); a method may legitimately take none.
|
|
87
|
+
if (param === undefined)
|
|
88
|
+
continue;
|
|
89
|
+
const paramType = checker.getTypeAtLocation(param);
|
|
90
|
+
const ports = {};
|
|
91
|
+
for (const prop of paramType.getProperties()) {
|
|
92
|
+
const portName = prop.getName();
|
|
93
|
+
const memberType = checker.getTypeOfSymbolAtLocation(prop, param);
|
|
94
|
+
const where = `--behavior ${behaviorName} method '${name}' input port '$.${portName}'`;
|
|
95
|
+
ports[portName] = tsTypeToPortSchema(ts, checker, memberType, param, where);
|
|
96
|
+
}
|
|
97
|
+
if (Object.keys(ports).length > 0)
|
|
98
|
+
out[name] = ports;
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/** Depth-first search for a class declaration named `name`. */
|
|
103
|
+
function findClass(ts, root, name) {
|
|
104
|
+
let found;
|
|
105
|
+
const visit = (node) => {
|
|
106
|
+
if (found)
|
|
107
|
+
return;
|
|
108
|
+
if (ts.isClassDeclaration(node) && node.name?.text === name) {
|
|
109
|
+
found = node;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
ts.forEachChild(node, visit);
|
|
113
|
+
};
|
|
114
|
+
visit(root);
|
|
115
|
+
return found;
|
|
116
|
+
}
|
|
117
|
+
/** One input port's TS member type → PortSchema, reusing the authoring SSoT {@link portSchemaFromPortable}
|
|
118
|
+
* (PortableType → PortSchema). The optionality of the top-level port is carried by an `{opt:…}` wrapper (the
|
|
119
|
+
* SAME derivation catalogEntryFromLeaf uses): opt → required:false, else required:true. */
|
|
120
|
+
function tsTypeToPortSchema(ts, checker, type, at, where) {
|
|
121
|
+
const portable = tsTypeToPortable(ts, checker, type, at, where);
|
|
122
|
+
const required = !(typeof portable === "object" && portable !== null && "opt" in portable);
|
|
123
|
+
return portSchemaFromPortable(portable, required);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Faithful TS type → PortableType mapping (the closed vocabulary behavior.ts declares). Fail-closed LOUD on
|
|
127
|
+
* anything not representable as a PortableType (never a silent `unknown`/`value`), mirroring the strict-typing
|
|
128
|
+
* discipline:
|
|
129
|
+
* string → "string" · boolean → "bool" · null → "null" · `T | undefined`/optional → {opt: T} ·
|
|
130
|
+
* `T[]` → {arr: T} · object/interface → {obj: {k: …}} .
|
|
131
|
+
* `number` is REJECTED: TS `number` is ambiguous between the portable `int` (i64) and `float` (f64) and BC
|
|
132
|
+
* does not infer — there is no single faithful mapping (a wrong guess emits the wrong native scalar type).
|
|
133
|
+
*/
|
|
134
|
+
function tsTypeToPortable(ts, checker, type, at, where) {
|
|
135
|
+
const fail = (msg) => {
|
|
136
|
+
throw new Error(`${where}: ${msg} (TS type '${checker.typeToString(type)}' is not a faithful PortSchema)`);
|
|
137
|
+
};
|
|
138
|
+
const F = ts.TypeFlags;
|
|
139
|
+
// union: strip null/undefined (optionality); boolean is itself a true|false union.
|
|
140
|
+
if (type.isUnion()) {
|
|
141
|
+
const voidish = type.types.filter((t) => t.flags & (F.Undefined | F.Null | F.Void));
|
|
142
|
+
const rest = type.types.filter((t) => !(t.flags & (F.Undefined | F.Null | F.Void)));
|
|
143
|
+
if (rest.length === 0)
|
|
144
|
+
return "null"; // only null/undefined declared
|
|
145
|
+
if (rest.every((t) => t.flags & F.BooleanLike))
|
|
146
|
+
return voidish.length ? { opt: "bool" } : "bool";
|
|
147
|
+
if (rest.length === 1) {
|
|
148
|
+
const base = tsTypeToPortable(ts, checker, rest[0], at, where);
|
|
149
|
+
return voidish.length ? { opt: base } : base;
|
|
150
|
+
}
|
|
151
|
+
return fail("a union of multiple non-null types has no portable representation");
|
|
152
|
+
}
|
|
153
|
+
// branded numeric precision: the authoring `Int`/`Float` aliases are `number & { [uniqueSym]: "int"|"float" }`
|
|
154
|
+
// intersections. Detect the brand STRUCTURALLY (the "int"/"float" string-literal value the brand carries), so
|
|
155
|
+
// re-exports / aliases (`type MyId = Int`) still resolve — never by the alias display name.
|
|
156
|
+
if (type.isIntersection()) {
|
|
157
|
+
const brand = numericBrandOf(ts, checker, type, at);
|
|
158
|
+
if (brand)
|
|
159
|
+
return brand;
|
|
160
|
+
return fail("an intersection type has no portable representation (use the Int/Float authoring aliases for numbers)");
|
|
161
|
+
}
|
|
162
|
+
if (type.flags & F.StringLike)
|
|
163
|
+
return "string";
|
|
164
|
+
if (type.flags & F.BooleanLike)
|
|
165
|
+
return "bool";
|
|
166
|
+
if (type.flags & F.NumberLike)
|
|
167
|
+
return fail("TS 'number' is ambiguous between the portable 'int' (i64) and 'float' (f64); BC does not infer — " +
|
|
168
|
+
"declare the port with the Int or Float authoring alias (no auto int/float rule)");
|
|
169
|
+
if (type.flags & F.Null)
|
|
170
|
+
return "null";
|
|
171
|
+
if (type.flags & (F.Any | F.Unknown))
|
|
172
|
+
return fail("'any'/'unknown' has no portable type");
|
|
173
|
+
if (checker.isArrayType(type)) {
|
|
174
|
+
const elem = getArrayElementType(ts, checker, type) ?? fail("array element type is unresolvable");
|
|
175
|
+
return { arr: tsTypeToPortable(ts, checker, elem, at, where) };
|
|
176
|
+
}
|
|
177
|
+
if (type.flags & F.Object) {
|
|
178
|
+
const props = type.getProperties();
|
|
179
|
+
if (props.length === 0)
|
|
180
|
+
return fail("an empty/opaque object has no portable representation");
|
|
181
|
+
const obj = {};
|
|
182
|
+
for (const prop of props) {
|
|
183
|
+
const pType = checker.getTypeOfSymbolAtLocation(prop, at);
|
|
184
|
+
obj[prop.getName()] = tsTypeToPortable(ts, checker, pType, at, `${where}.${prop.getName()}`);
|
|
185
|
+
}
|
|
186
|
+
return { obj };
|
|
187
|
+
}
|
|
188
|
+
return fail("unrepresentable type");
|
|
189
|
+
}
|
|
190
|
+
/** The portable scalar an `Int`/`Float` brand carries, or undefined if `type` is not a numeric brand. A brand
|
|
191
|
+
* is `number & { [uniqueSym]: "int"|"float" }`: an intersection with a NumberLike constituent AND a property
|
|
192
|
+
* whose type is the string literal "int"/"float". Detection is structural (by that literal value, not the
|
|
193
|
+
* property key or alias name), so re-exports / aliases resolve. */
|
|
194
|
+
function numericBrandOf(ts, checker, type, at) {
|
|
195
|
+
if (!type.isIntersection())
|
|
196
|
+
return undefined;
|
|
197
|
+
if (!type.types.some((t) => t.flags & ts.TypeFlags.NumberLike))
|
|
198
|
+
return undefined;
|
|
199
|
+
for (const prop of type.getProperties()) {
|
|
200
|
+
const pt = checker.getTypeOfSymbolAtLocation(prop, at);
|
|
201
|
+
if (pt.flags & ts.TypeFlags.StringLiteral) {
|
|
202
|
+
const v = pt.value;
|
|
203
|
+
if (v === "int" || v === "float")
|
|
204
|
+
return v;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
/** The element type of an array type (`getElementTypeOfArrayType` when present, else the type argument). */
|
|
210
|
+
function getArrayElementType(ts, checker, type) {
|
|
211
|
+
const viaApi = checker
|
|
212
|
+
.getElementTypeOfArrayType?.(type);
|
|
213
|
+
if (viaApi)
|
|
214
|
+
return viaApi;
|
|
215
|
+
const args = checker.getTypeArguments(type);
|
|
216
|
+
return args[0];
|
|
217
|
+
}
|
|
218
|
+
// ── (2) transpile + load ─────────────────────────────────────────────────────────────────────────────────
|
|
219
|
+
/**
|
|
220
|
+
* Transpile a consumer `.ts` behavior module to a sibling ESM file, import it, and return its namespace. The
|
|
221
|
+
* temp file is written NEXT TO the source so its `behavior-contracts` (and any relative) imports resolve
|
|
222
|
+
* identically to the source — the precondition for sharing the process-global @behavior/defineLeaf compile
|
|
223
|
+
* frame with the CLI.
|
|
224
|
+
*
|
|
225
|
+
* Emit: `experimentalDecorators: true` (LEGACY decorator emit). `@behavior` is a dual-mode marker (TC39
|
|
226
|
+
* standard AND legacy), and legacy emit keeps the class body clean (`class X {}` then
|
|
227
|
+
* `X = __decorate([behavior], X)`), whereas STANDARD downlevel emit injects helper code (`typeof Symbol ===
|
|
228
|
+
* "function" …`) INTO the class source — which compileBehaviors' native-control-syntax scanner (it reads
|
|
229
|
+
* `class.toString()`) would reject. Module: ESNext, so the output is ESM regardless of the consumer dir's
|
|
230
|
+
* package.json `type`.
|
|
231
|
+
*/
|
|
232
|
+
export async function transpileAndLoad(fromPath) {
|
|
233
|
+
const ts = await loadTypeScript(fromPath);
|
|
234
|
+
const source = (() => {
|
|
235
|
+
try {
|
|
236
|
+
return readFileSync(fromPath, "utf8");
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
throw new Error(`cannot read --from '${fromPath}'`);
|
|
240
|
+
}
|
|
241
|
+
})();
|
|
242
|
+
const { outputText, diagnostics } = ts.transpileModule(source, {
|
|
243
|
+
fileName: fromPath,
|
|
244
|
+
compilerOptions: {
|
|
245
|
+
module: ts.ModuleKind.ESNext,
|
|
246
|
+
target: ts.ScriptTarget.ES2022,
|
|
247
|
+
experimentalDecorators: true,
|
|
248
|
+
emitDecoratorMetadata: false,
|
|
249
|
+
},
|
|
250
|
+
reportDiagnostics: true,
|
|
251
|
+
});
|
|
252
|
+
if (diagnostics && diagnostics.length > 0) {
|
|
253
|
+
const msg = diagnostics.map((d) => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("; ");
|
|
254
|
+
throw new Error(`--from '${fromPath}' failed to transpile: ${msg}`);
|
|
255
|
+
}
|
|
256
|
+
const tmp = join(dirname(fromPath), `.bcgen-${randomUUID()}.mjs`);
|
|
257
|
+
writeFileSync(tmp, outputText);
|
|
258
|
+
try {
|
|
259
|
+
return (await import(__rewriteRelativeImportExtension(pathToFileURL(tmp).href)));
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
rmSync(tmp, { force: true }); // ESM caches by URL — already loaded; the temp artifact is disposable.
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=ts-extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-extract.js","sourceRoot":"","sources":["../../src/commands/ts-extract.ts"],"names":[],"mappings":";;;;;;;;AAAA,+EAA+E;AAC/E,mFAAmF;AACnF,EAAE;AACF,6GAA6G;AAC7G,qGAAqG;AACrG,uEAAuE;AACvE,EAAE;AACF,wGAAwG;AACxG,+GAA+G;AAC/G,2GA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ACvG,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,YAAY,EAAE,eAAe,CAAC,GACtD,OAAO,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,YAAY,EAAE,eAAe,CAAC,GACtD,OAAO,CAAC,UAAU,CAAC,CA0BrB;AAED,wBAAsB,OAAO,CAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,YAAY,EAAE,YAAY,CAAC,GACnD,OAAO,CAAC,UAAU,CAAC,CA0BrB"}
|
|
@@ -7,6 +7,10 @@ export async function bcGenerate(executable, options) {
|
|
|
7
7
|
if (options) {
|
|
8
8
|
if (options.lang !== undefined)
|
|
9
9
|
cmdArgs.push("--lang", String(options.lang));
|
|
10
|
+
if (options.from !== undefined)
|
|
11
|
+
cmdArgs.push("--from", String(options.from));
|
|
12
|
+
if (options.behavior !== undefined)
|
|
13
|
+
cmdArgs.push("--behavior", String(options.behavior));
|
|
10
14
|
if (options.in !== undefined)
|
|
11
15
|
cmdArgs.push("--in", String(options.in));
|
|
12
16
|
if (options.out !== undefined)
|
|
@@ -40,6 +44,10 @@ export async function bcCheck(executable, options) {
|
|
|
40
44
|
if (options) {
|
|
41
45
|
if (options.lang !== undefined)
|
|
42
46
|
cmdArgs.push("--lang", String(options.lang));
|
|
47
|
+
if (options.from !== undefined)
|
|
48
|
+
cmdArgs.push("--from", String(options.from));
|
|
49
|
+
if (options.behavior !== undefined)
|
|
50
|
+
cmdArgs.push("--behavior", String(options.behavior));
|
|
43
51
|
if (options.in !== undefined)
|
|
44
52
|
cmdArgs.push("--in", String(options.in));
|
|
45
53
|
if (options.out !== undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAQ1C,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,OAAuD;IAEvD,MAAM,OAAO,GAAa,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;YAAE,OAAO,CAAC,IAA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ts","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,MAA2/gB,CAAC;AAExhhB,eAAO,MAAM,iBAAiB,EAAE,MAA64kB,CAAC"}
|