behavior-contracts 0.9.2 → 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.
Files changed (88) hide show
  1. package/cli-contract.yaml +116 -24
  2. package/dist/authoring.d.ts +18 -1
  3. package/dist/authoring.d.ts.map +1 -1
  4. package/dist/authoring.js +11 -0
  5. package/dist/authoring.js.map +1 -1
  6. package/dist/behavior.d.ts +23 -0
  7. package/dist/behavior.d.ts.map +1 -1
  8. package/dist/behavior.js +18 -10
  9. package/dist/behavior.js.map +1 -1
  10. package/dist/bind.d.ts +1 -1
  11. package/dist/bind.d.ts.map +1 -1
  12. package/dist/builder.d.ts.map +1 -1
  13. package/dist/builder.js +21 -6
  14. package/dist/builder.js.map +1 -1
  15. package/dist/cli.js +65 -40
  16. package/dist/cli.js.map +1 -1
  17. package/dist/commands/codegen.d.ts +18 -12
  18. package/dist/commands/codegen.d.ts.map +1 -1
  19. package/dist/commands/codegen.js +111 -27
  20. package/dist/commands/codegen.js.map +1 -1
  21. package/dist/commands/ts-extract.d.ts +26 -0
  22. package/dist/commands/ts-extract.d.ts.map +1 -0
  23. package/dist/commands/ts-extract.js +265 -0
  24. package/dist/commands/ts-extract.js.map +1 -0
  25. package/dist/generated/commands.d.ts.map +1 -1
  26. package/dist/generated/commands.js +8 -0
  27. package/dist/generated/commands.js.map +1 -1
  28. package/dist/generated/contract.d.ts.map +1 -1
  29. package/dist/generated/contract.js +2 -2
  30. package/dist/generated/contract.js.map +1 -1
  31. package/dist/generated/program.d.ts +4 -0
  32. package/dist/generated/program.d.ts.map +1 -1
  33. package/dist/generated/program.js +7 -3
  34. package/dist/generated/program.js.map +1 -1
  35. package/dist/generated/types.d.ts +6 -2
  36. package/dist/generated/types.d.ts.map +1 -1
  37. package/dist/generator/emit-shared-go.d.ts.map +1 -1
  38. package/dist/generator/emit-shared-go.js +40 -19
  39. package/dist/generator/emit-shared-go.js.map +1 -1
  40. package/dist/generator/emit-shared-rust.d.ts.map +1 -1
  41. package/dist/generator/emit-shared-rust.js +50 -30
  42. package/dist/generator/emit-shared-rust.js.map +1 -1
  43. package/dist/generator/emit-shared-typescript.d.ts.map +1 -1
  44. package/dist/generator/emit-shared-typescript.js +26 -4
  45. package/dist/generator/emit-shared-typescript.js.map +1 -1
  46. package/dist/generator/emit-typed-native-go.d.ts +5 -7
  47. package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
  48. package/dist/generator/emit-typed-native-go.js +292 -420
  49. package/dist/generator/emit-typed-native-go.js.map +1 -1
  50. package/dist/generator/emit-typed-native-rust.d.ts +6 -8
  51. package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
  52. package/dist/generator/emit-typed-native-rust.js +275 -382
  53. package/dist/generator/emit-typed-native-rust.js.map +1 -1
  54. package/dist/generator/native-expr.d.ts +7 -0
  55. package/dist/generator/native-expr.d.ts.map +1 -1
  56. package/dist/generator/native-expr.js +11 -0
  57. package/dist/generator/native-expr.js.map +1 -1
  58. package/dist/generator/straightline.d.ts +5 -0
  59. package/dist/generator/straightline.d.ts.map +1 -1
  60. package/dist/generator/straightline.js +1 -0
  61. package/dist/generator/straightline.js.map +1 -1
  62. package/dist/generator/typed.d.ts +17 -11
  63. package/dist/generator/typed.d.ts.map +1 -1
  64. package/dist/generator/typed.js +19 -12
  65. package/dist/generator/typed.js.map +1 -1
  66. package/dist/guard.d.ts +23 -0
  67. package/dist/guard.d.ts.map +1 -1
  68. package/dist/guard.js +52 -0
  69. package/dist/guard.js.map +1 -1
  70. package/dist/index.d.ts +3 -32
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +10 -5
  73. package/dist/index.js.map +1 -1
  74. package/dist/ir-handle.d.ts +30 -0
  75. package/dist/ir-handle.d.ts.map +1 -0
  76. package/dist/ir-handle.js +2 -0
  77. package/dist/ir-handle.js.map +1 -0
  78. package/dist/plan.d.ts +7 -0
  79. package/dist/plan.d.ts.map +1 -1
  80. package/dist/plan.js +7 -2
  81. package/dist/plan.js.map +1 -1
  82. package/dist/primitives.d.ts +4 -3
  83. package/dist/primitives.d.ts.map +1 -1
  84. package/dist/primitives.js +8 -7
  85. package/dist/primitives.js.map +1 -1
  86. package/dist/provenance.d.ts +1 -1
  87. package/dist/provenance.d.ts.map +1 -1
  88. package/package.json +9 -1
package/dist/cli.js CHANGED
@@ -8,8 +8,11 @@
8
8
  // codegen core lives in ./commands/codegen.ts (a thin wrapper over the public
9
9
  // API — no emit logic reimplemented).
10
10
  //
11
- // bc generate --lang <emitter> --in <ir-doc.json> [--out <file>] [--shared-types-out <file>] [--runtime-import <spec>]
12
- // bc check --lang <emitter> --in <ir-doc.json> [--out <file>] [--shared-types-out <file>] [--runtime-import <spec>]
11
+ // bc generate --lang <emitter> (--from <behaviors.(js|mjs|ts)> --behavior <ClassName> | --in <ir-doc.json>) [--out <file>] [--shared-types-out <file>] [--runtime-import <spec>]
12
+ // bc check --lang <emitter> (--from <behaviors.(js|mjs|ts)> --behavior <ClassName> | --in <ir-doc.json>) [--out <file>] [--shared-types-out <file>] [--runtime-import <spec>]
13
+ //
14
+ // TS-authoring flow (--from): imports the consumer's compiled behavior module + runs ts→ir→native in-process
15
+ // (compileBehaviors → generateModule). Internal/test flow (--in): a pre-serialized IR doc. Exactly one input.
13
16
  //
14
17
  // generate → emit the covered native module (to --out, or stdout if omitted) and/or the BC-owned shared
15
18
  // wire types module (to --shared-types-out; go/rust cross-package/cross-crate only).
@@ -20,54 +23,74 @@
20
23
  import { readFileSync, writeFileSync } from "node:fs";
21
24
  import { createRequire } from "node:module";
22
25
  import { createProgram } from "./generated/program.js";
23
- import { generateFromDoc, generateSharedTypesFromDoc, readDoc } from "./commands/codegen.js";
26
+ import { generateFromDoc, generateFromModule, generateSharedTypesFromDoc, generateSharedTypesFromModule, readDoc, } from "./commands/codegen.js";
24
27
  const require = createRequire(import.meta.url);
25
28
  const pkg = require("../package.json");
26
- /** Validate the always-required --lang/--in and return them, else exit 2 (usage). Shared by the covered-module
27
- * and shared-types generation paths so the usage contract lives in ONE place. */
28
- function requireLangIn(opts) {
29
+ function requireLangInput(opts) {
29
30
  if (!opts.lang) {
30
31
  process.stderr.write("bc: --lang <emitter> is required\n");
31
32
  process.exit(2);
32
33
  }
33
- if (!opts.in) {
34
- process.stderr.write("bc: --in <ir-doc.json> is required\n");
34
+ const hasFrom = opts.from !== undefined;
35
+ const hasIn = opts.in !== undefined;
36
+ if (hasFrom && hasIn) {
37
+ process.stderr.write("bc: --from and --in are mutually exclusive\n");
38
+ process.exit(2);
39
+ }
40
+ if (!hasFrom && !hasIn) {
41
+ process.stderr.write("bc: an input is required — --from <behaviors.(js|mjs|ts)> --behavior <ClassName> (TS authoring), or --in <ir-doc.json>\n");
35
42
  process.exit(2);
36
43
  }
37
- return { lang: opts.lang, in: opts.in };
44
+ if (hasFrom && opts.behavior === undefined) {
45
+ process.stderr.write("bc: --from requires --behavior <ClassName>\n");
46
+ process.exit(2);
47
+ }
48
+ const input = hasFrom
49
+ ? { kind: "from", from: opts.from, behavior: opts.behavior }
50
+ : { kind: "in", in: opts.in };
51
+ return { lang: opts.lang, input };
52
+ }
53
+ /** Build the emitter's leaf-transport option from the CLI flags, or undefined when none is present (native
54
+ * emitters then apply their in-package default symbols: rust leaf_<comp> / go Leaf_<comp>). Each
55
+ * `--leaf-transport <leaf>=<symbol>` maps a covered leaf to the symbol the runner calls directly. A malformed
56
+ * mapping (no `=`) throws — surfaced as a loud generation error by the callers. */
57
+ function buildLeafTransport(opts) {
58
+ const ltList = opts.leafTransport === undefined ? undefined : Array.isArray(opts.leafTransport) ? opts.leafTransport : [opts.leafTransport];
59
+ if (ltList === undefined && opts.leafTransportImport === undefined)
60
+ return undefined;
61
+ return {
62
+ symbols: Object.fromEntries((ltList ?? []).map((m) => {
63
+ const eq = m.indexOf("=");
64
+ if (eq <= 0 || eq === m.length - 1)
65
+ throw new Error(`--leaf-transport expects <leaf>=<symbol>, got '${m}'`);
66
+ return [m.slice(0, eq), m.slice(eq + 1)];
67
+ })),
68
+ ...(opts.leafTransportImport !== undefined ? { import: opts.leafTransportImport } : {}),
69
+ };
38
70
  }
39
- /** Validate required options + generate the covered module. Exits on any failure (2=usage, 1=generation). */
40
- function generateOrExit(opts) {
41
- const { lang, in: inPath } = requireLangIn(opts);
71
+ /** Validate options + generate the covered module from the resolved input mode (--from: ts→ir→native;
72
+ * --in: IR doc → native). Exits on any failure (2=usage, 1=generation). */
73
+ async function generateOrExit(opts) {
74
+ const { lang, input } = requireLangInput(opts);
42
75
  try {
43
- // Build the leaf-transport option only when a leaf-transport flag is present; absent → undefined so the
44
- // native emitters apply their in-package default symbols (rust leaf_<comp> / go Leaf_<comp>). Each
45
- // `--leaf-transport <leaf>=<symbol>` maps a covered leaf to the symbol the runner calls directly.
46
- const ltList = opts.leafTransport === undefined ? undefined : Array.isArray(opts.leafTransport) ? opts.leafTransport : [opts.leafTransport];
47
- const leafTransport = ltList !== undefined || opts.leafTransportImport !== undefined
48
- ? {
49
- symbols: Object.fromEntries((ltList ?? []).map((m) => {
50
- const eq = m.indexOf("=");
51
- if (eq <= 0 || eq === m.length - 1)
52
- throw new Error(`--leaf-transport expects <leaf>=<symbol>, got '${m}'`);
53
- return [m.slice(0, eq), m.slice(eq + 1)];
54
- })),
55
- ...(opts.leafTransportImport !== undefined ? { import: opts.leafTransportImport } : {}),
56
- }
57
- : undefined;
58
- return generateFromDoc(readDoc(inPath), lang, opts.runtimeImport, leafTransport, opts.sharedTypesImport);
76
+ const leafTransport = buildLeafTransport(opts);
77
+ return input.kind === "from"
78
+ ? await generateFromModule(input.from, input.behavior, lang, opts.runtimeImport, leafTransport, opts.sharedTypesImport)
79
+ : generateFromDoc(readDoc(input.in), lang, opts.runtimeImport, leafTransport, opts.sharedTypesImport);
59
80
  }
60
81
  catch (e) {
61
82
  process.stderr.write(`bc: ${e instanceof Error ? e.message : String(e)}\n`);
62
83
  process.exit(1);
63
84
  }
64
85
  }
65
- /** Validate required options + generate the BC-owned shared wire types module. Exits on any failure
66
- * (2=usage, 1=generation). Same shape as generateOrExit but dispatches to the shared-types path. */
67
- function generateSharedTypesOrExit(opts) {
68
- const { lang, in: inPath } = requireLangIn(opts);
86
+ /** Validate options + generate the BC-owned shared wire types module from the resolved input mode. Same
87
+ * shape as generateOrExit but dispatches to the shared-types seam. */
88
+ async function generateSharedTypesOrExit(opts) {
89
+ const { lang, input } = requireLangInput(opts);
69
90
  try {
70
- return generateSharedTypesFromDoc(readDoc(inPath), lang, opts.sharedTypesImport);
91
+ return input.kind === "from"
92
+ ? await generateSharedTypesFromModule(input.from, input.behavior, lang, opts.sharedTypesImport)
93
+ : generateSharedTypesFromDoc(readDoc(input.in), lang, opts.sharedTypesImport);
71
94
  }
72
95
  catch (e) {
73
96
  process.stderr.write(`bc: ${e instanceof Error ? e.message : String(e)}\n`);
@@ -92,9 +115,11 @@ function driftCheckOrExit(outPath, fresh, regenHint) {
92
115
  }
93
116
  process.stdout.write(`bc: up to date — ${outPath}\n`);
94
117
  }
95
- /** The invocation prefix common to a generate/check hint (`bc generate --lang <l> --in <i>`). */
118
+ /** The invocation prefix common to a generate/check hint, echoing the input mode the drift was checked with
119
+ * (`bc generate --lang <l> --from <m> --behavior <c>` or `--in <i>`). */
96
120
  function regenPrefix(opts) {
97
- return `bc generate --lang ${opts.lang} --in ${opts.in}`;
121
+ const input = opts.from !== undefined ? `--from ${opts.from} --behavior ${opts.behavior}` : `--in ${opts.in}`;
122
+ return `bc generate --lang ${opts.lang} ${input}`;
98
123
  }
99
124
  const handlers = {
100
125
  // ── generate ─────────────────────────────────────────────────────────────
@@ -102,11 +127,11 @@ const handlers = {
102
127
  // A standalone --shared-types-out never dumps the covered module to stdout.
103
128
  generate: async (opts) => {
104
129
  if (opts.sharedTypesOut)
105
- writeFileSync(opts.sharedTypesOut, generateSharedTypesOrExit(opts));
130
+ writeFileSync(opts.sharedTypesOut, await generateSharedTypesOrExit(opts));
106
131
  if (opts.out)
107
- writeFileSync(opts.out, generateOrExit(opts));
132
+ writeFileSync(opts.out, await generateOrExit(opts));
108
133
  else if (!opts.sharedTypesOut)
109
- process.stdout.write(generateOrExit(opts));
134
+ process.stdout.write(await generateOrExit(opts));
110
135
  },
111
136
  // ── check ────────────────────────────────────────────────────────────────
112
137
  // Drift-check --out (covered) and/or --shared-types-out (shared) — at least one is required; both may be
@@ -117,12 +142,12 @@ const handlers = {
117
142
  process.exit(2);
118
143
  }
119
144
  if (opts.out) {
120
- driftCheckOrExit(opts.out, generateOrExit(opts), `${regenPrefix(opts)} --out ${opts.out}`);
145
+ driftCheckOrExit(opts.out, await generateOrExit(opts), `${regenPrefix(opts)} --out ${opts.out}`);
121
146
  }
122
147
  if (opts.sharedTypesOut) {
123
148
  const hint = `${regenPrefix(opts)} --shared-types-out ${opts.sharedTypesOut}` +
124
149
  (opts.sharedTypesImport ? ` --shared-types-import ${opts.sharedTypesImport}` : "");
125
- driftCheckOrExit(opts.sharedTypesOut, generateSharedTypesOrExit(opts), hint);
150
+ driftCheckOrExit(opts.sharedTypesOut, await generateSharedTypesOrExit(opts), hint);
126
151
  }
127
152
  },
128
153
  };
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,sCAAsC;AACtC,EAAE;AACF,yHAAyH;AACzH,yHAAyH;AACzH,EAAE;AACF,0GAA0G;AAC1G,kGAAkG;AAClG,6GAA6G;AAC7G,EAAE;AACF,gGAAgG;AAChG,8DAA8D;AAC9D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,0BAA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C,cAAc,EAAE,CAAC;YACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;YACpG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACnG,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,IAAI,GACR,GAAG,WAAW,CAAC,IAAI,CAAC,uBAAuB,IAAI,CAAC,cAAc,EAAE;gBAChE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,0BAA0B,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACrF,gBAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,yBAAyB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;CACF,CAAC;AAEF,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC"}
@@ -1,17 +1,23 @@
1
- import { type ComponentGraphIRDoc, type GenerateOptions } from "../index.js";
2
- /** A serialized IR doc → the native module source (same path as the in-process API).
3
- * `leafTransport` (native emitters only) + `sharedTypesImport` (go cross-package: BC-generated shared wire
4
- * types package) are forwarded verbatim to the emitter options of the same name; other emitters ignore
5
- * them. Omitted → the emitter's default transport symbols / in-package wire types. */
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
- /** A serialized IR doc → the BC-OWNED shared wire types module (the same one the covered module imports when
8
- * generated with --shared-types-import). NO emit logic is reimplemented: this validates the emitter then
9
- * dispatches to the EXISTING rustSharedWireTypesModule / goSharedWireTypesPackage over the SAME loadCompiledIR
10
- * the covered path uses. Only go-typed-native / rust-typed-native own a shared module — any other --lang is a
11
- * loud error. For go the package name is SSoT-derived from `sharedTypesImport` (goSharedTypesPackageName, the
12
- * SAME normalization resolveGoWire uses to selector-qualify the hoisted types), so --shared-types-import is
13
- * required; rust's shared module content needs no import. */
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":"AAYA,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAUrB;;;sFAGsF;AACtF,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,CAaR;AAKD;;;;;;6DAM6D;AAC7D,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CAsBR;AAED,+DAA+D;AAC/D,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAY3D"}
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"}
@@ -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 { loadCompiledIR, generateModule, registeredLanguages, } from "../index.js";
14
- // The BC-owned shared wire types emitters are package-INTERNAL (not part of the consumer-facing public API in
15
- // ../index.ts): the CLI is the only supported entry to emit them (bc generate --shared-types-out), so they are
16
- // imported from the internal generator barrel, not re-exported to consumers.
17
- import { rustSharedWireTypesModule, goSharedWireTypesPackage, goSharedTypesPackageName, } from "../generator/index.js";
18
- /** A serialized IR doc → the native module source (same path as the in-process API).
19
- * `leafTransport` (native emitters only) + `sharedTypesImport` (go cross-package: BC-generated shared wire
20
- * types package) are forwarded verbatim to the emitter options of the same name; other emitters ignore
21
- * them. Omitted → the emitter's default transport symbols / in-package wire types. */
22
- export function generateFromDoc(doc, language, runtimeImport, leafTransport, sharedTypesImport) {
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
- const compiled = loadCompiledIR(doc); // adopt the unbranded doc (recomputes + mints the provenance token)
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
- const module = generateModule(compiled, options);
35
- return module.code;
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
- /** A serialized IR doc → the BC-OWNED shared wire types module (the same one the covered module imports when
40
- * generated with --shared-types-import). NO emit logic is reimplemented: this validates the emitter then
41
- * dispatches to the EXISTING rustSharedWireTypesModule / goSharedWireTypesPackage over the SAME loadCompiledIR
42
- * the covered path uses. Only go-typed-native / rust-typed-native own a shared module — any other --lang is a
43
- * loud error. For go the package name is SSoT-derived from `sharedTypesImport` (goSharedTypesPackageName, the
44
- * SAME normalization resolveGoWire uses to selector-qualify the hoisted types), so --shared-types-import is
45
- * required; rust's shared module content needs no import. */
46
- export function generateSharedTypesFromDoc(doc, language, sharedTypesImport) {
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(compiled);
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), compiled);
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,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,GAGpB,MAAM,aAAa,CAAC;AACrB,8GAA8G;AAC9G,+GAA+G;AAC/G,6EAA6E;AAC7E,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B;;;sFAGsF;AACtF,MAAM,UAAU,eAAe,CA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AC,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"}