behavior-contracts 0.10.1 → 0.11.1

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 (97) hide show
  1. package/README.md +246 -350
  2. package/cli-contract.yaml +49 -51
  3. package/dist/authoring.d.ts +80 -420
  4. package/dist/authoring.d.ts.map +1 -1
  5. package/dist/authoring.js +53 -1157
  6. package/dist/authoring.js.map +1 -1
  7. package/dist/behavior.d.ts +31 -15
  8. package/dist/behavior.d.ts.map +1 -1
  9. package/dist/behavior.js +55 -0
  10. package/dist/behavior.js.map +1 -1
  11. package/dist/builder.d.ts +4 -4
  12. package/dist/builder.d.ts.map +1 -1
  13. package/dist/builder.js +18 -16
  14. package/dist/builder.js.map +1 -1
  15. package/dist/cli.js +5 -5
  16. package/dist/cli.js.map +1 -1
  17. package/dist/commands/codegen.d.ts.map +1 -1
  18. package/dist/commands/codegen.js +12 -56
  19. package/dist/commands/codegen.js.map +1 -1
  20. package/dist/commands/ts-compile.d.ts +23 -0
  21. package/dist/commands/ts-compile.d.ts.map +1 -0
  22. package/dist/commands/ts-compile.js +693 -0
  23. package/dist/commands/ts-compile.js.map +1 -0
  24. package/dist/commands/ts-extract.d.ts +55 -7
  25. package/dist/commands/ts-extract.d.ts.map +1 -1
  26. package/dist/commands/ts-extract.js +177 -64
  27. package/dist/commands/ts-extract.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.js +4 -4
  32. package/dist/generated/program.js.map +1 -1
  33. package/dist/generator/core.d.ts +11 -1
  34. package/dist/generator/core.d.ts.map +1 -1
  35. package/dist/generator/core.js +5 -4
  36. package/dist/generator/core.js.map +1 -1
  37. package/dist/generator/emit-php.d.ts +0 -17
  38. package/dist/generator/emit-php.d.ts.map +1 -1
  39. package/dist/generator/emit-php.js +25 -1
  40. package/dist/generator/emit-php.js.map +1 -1
  41. package/dist/generator/emit-python.d.ts +0 -7
  42. package/dist/generator/emit-python.d.ts.map +1 -1
  43. package/dist/generator/emit-python.js +34 -1
  44. package/dist/generator/emit-python.js.map +1 -1
  45. package/dist/generator/emit-straightline-typed-typescript.js +1 -1
  46. package/dist/generator/emit-straightline-typed-typescript.js.map +1 -1
  47. package/dist/generator/emit-typed-native-go.d.ts +1 -1
  48. package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
  49. package/dist/generator/emit-typed-native-go.js +122 -112
  50. package/dist/generator/emit-typed-native-go.js.map +1 -1
  51. package/dist/generator/emit-typed-native-rust.d.ts +3 -2
  52. package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
  53. package/dist/generator/emit-typed-native-rust.js +61 -125
  54. package/dist/generator/emit-typed-native-rust.js.map +1 -1
  55. package/dist/generator/emit-typescript-native.js +1 -1
  56. package/dist/generator/emit-typescript-native.js.map +1 -1
  57. package/dist/generator/emit-typescript.js +1 -1
  58. package/dist/generator/emit-typescript.js.map +1 -1
  59. package/dist/generator/typed.d.ts +5 -1
  60. package/dist/generator/typed.d.ts.map +1 -1
  61. package/dist/generator/typed.js +40 -9
  62. package/dist/generator/typed.js.map +1 -1
  63. package/dist/guard.d.ts +11 -0
  64. package/dist/guard.d.ts.map +1 -1
  65. package/dist/guard.js +35 -8
  66. package/dist/guard.js.map +1 -1
  67. package/dist/index.d.ts +20 -57
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +25 -101
  70. package/dist/index.js.map +1 -1
  71. package/dist/lowering.d.ts +251 -0
  72. package/dist/lowering.d.ts.map +1 -0
  73. package/dist/lowering.js +682 -0
  74. package/dist/lowering.js.map +1 -0
  75. package/dist/provenance.js +4 -4
  76. package/dist/provenance.js.map +1 -1
  77. package/dist/runtime.d.ts +52 -0
  78. package/dist/runtime.d.ts.map +1 -0
  79. package/dist/runtime.js +77 -0
  80. package/dist/runtime.js.map +1 -0
  81. package/dist/spec-versions.d.ts +25 -0
  82. package/dist/spec-versions.d.ts.map +1 -0
  83. package/dist/spec-versions.js +26 -0
  84. package/dist/spec-versions.js.map +1 -0
  85. package/dist/type-gate.d.ts +12 -0
  86. package/dist/type-gate.d.ts.map +1 -1
  87. package/dist/type-gate.js +79 -3
  88. package/dist/type-gate.js.map +1 -1
  89. package/package.json +5 -1
  90. package/dist/bind.d.ts +0 -88
  91. package/dist/bind.d.ts.map +0 -1
  92. package/dist/bind.js +0 -155
  93. package/dist/bind.js.map +0 -1
  94. package/dist/lower.d.ts +0 -35
  95. package/dist/lower.d.ts.map +0 -1
  96. package/dist/lower.js +0 -118
  97. package/dist/lower.js.map +0 -1
package/cli-contract.yaml CHANGED
@@ -6,17 +6,18 @@ info:
6
6
  version: 0.1.0
7
7
  description: >-
8
8
  bc — the build-time codegen CLI over behavior-contracts' public API.
9
- The consumer authors behaviors in TS only (@behavior / defineLeaf /
10
- behaviorComponents) and never touches the IR. `bc generate --from
11
- <behaviors.ts> --behavior <ClassName>` uses the TypeScript compiler to
12
- type-extract each method's `$: In<T>` input-port types and to transpile +
13
- load the module (decorators supported), then runs ts→ir→native end to end
14
- in-process (compileBehaviors → generateModule), emitting a runtime-free
15
- native module (data baked as literals). The IR exists only inside the CLI;
16
- nothing reads it at runtime. `typescript` is a build-time-only optional peer
17
- dependency used solely on this `--from <.ts>` path; the runtime entry stays
18
- dependency-free. `--in <ir-doc.json>` (a pre-serialized ComponentGraphIRDoc)
19
- remains as an internal/test input alongside --from.
9
+ The consumer authors behaviors in native TS only (`@behavior` / `@leaf`
10
+ static methods with plain TS bodies) and never touches the IR. `bc generate
11
+ --from <behaviors.ts> --behavior <ClassName>` uses the TypeScript compiler to
12
+ read each method's SOURCE — type-extracting parameter/return types and
13
+ lowering the body AST (`+`/`?:`/`.map`/`?.` etc.) to the component-graph IR
14
+ (no module execution), then runs source→ir→native end to end in-process,
15
+ emitting a runtime-free native module (data baked as literals). The IR exists
16
+ only inside the CLI; nothing reads it at runtime. `typescript` is a
17
+ build-time-only optional peer dependency used solely on this `--from <.ts>`
18
+ path; the runtime entry stays dependency-free. `--in <ir-doc.json>` (a
19
+ pre-serialized ComponentGraphIRDoc) remains as an internal/test input
20
+ alongside --from.
20
21
  license:
21
22
  name: MIT
22
23
  contact:
@@ -27,11 +28,11 @@ artifact_slots:
27
28
  behaviors-module:
28
29
  direction: read
29
30
  description: >-
30
- The consumer's behavior module exporting an @behavior / SemanticBehavior
31
- class — the TS-authoring codegen input (`--from`). A `.ts` SOURCE is the
32
- primary form (the TS compiler type-extracts `$: In<T>` input ports +
33
- transpiles decorators); a compiled `.js`/`.mjs` is also accepted (no input
34
- types). BC runs ts→ir→native.
31
+ The consumer's TS SOURCE module exporting an `@behavior` class with
32
+ `@behavior` / `@leaf` static methods — the TS-authoring codegen input
33
+ (`--from`). The TS compiler type-extracts each method's parameter/return
34
+ types and lowers its body AST to IR (no module execution). BC runs
35
+ source→ir→native.
35
36
  ir-doc:
36
37
  direction: read
37
38
  description: >-
@@ -64,18 +65,18 @@ command_sets:
64
65
  generate:
65
66
  summary: Emit a native module from a TS behavior module (--from) or a serialized IR doc (--in).
66
67
  description: >-
67
- TS-authoring flow (--from): imports the consumer's compiled behavior
68
- module and reads its --behavior export (an @behavior / SemanticBehavior
69
- class), then runs ts→ir→native in-process (compileBehaviors →
70
- generateModule) for the --lang emitter. The IR is CLI-internal and
71
- never touches the consumer surface. Internal/test flow (--in): reads
72
- the ComponentGraphIRDoc, adopts it via loadCompiledIR, and runs the
73
- same generateModule. Exactly one of --from / --in is required (--from
74
- also requires --behavior). Writes the module source to --out if given,
75
- else to stdout. Rejects an unregistered --lang.
68
+ TS-authoring flow (--from): reads the consumer's TS SOURCE module and
69
+ its --behavior export (an `@behavior` class), then runs source→ir→native
70
+ in-process (the AST reader lowers each method to IR → generateModule)
71
+ for the --lang emitter. The IR is CLI-internal and never touches the
72
+ consumer surface. Internal/test flow (--in): reads the
73
+ ComponentGraphIRDoc, adopts it via loadCompiledIR, and runs the same
74
+ generateModule. Exactly one of --from / --in is required (--from also
75
+ requires --behavior). Writes the module source to --out if given, else
76
+ to stdout. Rejects an unregistered --lang.
76
77
  usage:
77
- - bc generate --lang rust-typed-native --from behaviors.js --behavior UserRepo --out gen.rs
78
- - bc generate --lang go-typed-native --from behaviors.mjs --behavior UserRepo --out gen.go
78
+ - bc generate --lang rust-typed-native --from behaviors.ts --behavior UserRepo --out gen.rs
79
+ - bc generate --lang go-typed-native --from behaviors.ts --behavior UserRepo --out gen.go
79
80
  - bc generate --lang typescript-typed --in ir-doc.json --runtime-import ./runtime.js
80
81
 
81
82
  options:
@@ -91,18 +92,15 @@ command_sets:
91
92
  - name: from
92
93
  required: false
93
94
  description: >-
94
- TS-authoring input. A `.ts` SOURCE is the primary form: the
95
- TypeScript compiler type-extracts each method's `$: In<T>`
96
- input-port types (so an input-typed behavior emits native) and
97
- transpiles + loads the module with decorators (Node type-stripping
98
- rejects @behavior). A compiled `.js`/`.mjs` is also accepted (no
99
- input-port types → native emit limited to no-dynamic-input shapes).
100
- BC reads the --behavior export and runs compileBehaviors →
101
- generateModule. The module's `behavior-contracts` import must
102
- resolve to the same installed package as bc (shared
103
- @behavior/defineLeaf registry). A `.ts` requires the optional peer
104
- dependency `typescript`. Mutually exclusive with --in.
105
- value_name: behaviors.(ts|js|mjs)
95
+ TS-authoring input: the consumer's `.ts` SOURCE. The TypeScript
96
+ compiler type-extracts each method's parameter/return types and
97
+ lowers its body AST (`+`/`?:`/`.map`/`?.` etc.) to IR — the source
98
+ is read, not executed. BC compiles the --behavior export's methods
99
+ and runs the emitter. The module's `behavior-contracts` import must
100
+ resolve to the same installed package as bc (so `@behavior`/`@leaf`
101
+ markers are identified by declaration file). Requires the optional
102
+ peer dependency `typescript`. Mutually exclusive with --in.
103
+ value_name: behaviors.ts
106
104
  schema:
107
105
  type: string
108
106
  file:
@@ -113,9 +111,9 @@ command_sets:
113
111
  - name: behavior
114
112
  required: false
115
113
  description: >-
116
- (with --from) The name of the exported @behavior / SemanticBehavior
117
- class to compile (one class = its public methods each a root
118
- Behavior). Required whenever --from is given.
114
+ (with --from) The name of the exported `@behavior` class to compile
115
+ (one class = its public static methods, each a root Behavior).
116
+ Required whenever --from is given.
119
117
  value_name: ClassName
120
118
  schema:
121
119
  type: string
@@ -249,7 +247,7 @@ command_sets:
249
247
  byte-compares it against the committed --out file. Exits non-zero on
250
248
  drift. This is the build's codegen drift gate.
251
249
  usage:
252
- - bc check --lang rust-typed-native --from behaviors.js --behavior UserRepo --out gen.rs
250
+ - bc check --lang rust-typed-native --from behaviors.ts --behavior UserRepo --out gen.rs
253
251
  - bc check --lang rust-typed-native --in ir-doc.json --out gen.rs
254
252
 
255
253
  options:
@@ -263,12 +261,12 @@ command_sets:
263
261
  - name: from
264
262
  required: false
265
263
  description: >-
266
- TS-authoring input (same as generate --from): a `.ts` SOURCE (TS
267
- compiler type-extracts `$: In<T>` + transpiles decorators; needs the
268
- optional peer `typescript`) or a compiled `.js`/`.mjs`. Regenerated
269
- + byte-compared against --out. Requires --behavior. Mutually
270
- exclusive with --in.
271
- value_name: behaviors.(ts|js|mjs)
264
+ TS-authoring input (same as generate --from): the consumer's `.ts`
265
+ SOURCE, read by the TS compiler (type-extract + AST-lower, not
266
+ executed; needs the optional peer `typescript`). Regenerated +
267
+ byte-compared against --out. Requires --behavior. Mutually exclusive
268
+ with --in.
269
+ value_name: behaviors.ts
272
270
  schema:
273
271
  type: string
274
272
  file:
@@ -279,8 +277,8 @@ command_sets:
279
277
  - name: behavior
280
278
  required: false
281
279
  description: >-
282
- (with --from) The name of the exported @behavior / SemanticBehavior
283
- class to compile. Required whenever --from is given.
280
+ (with --from) The name of the exported `@behavior` class to
281
+ compile. Required whenever --from is given.
284
282
  value_name: ClassName
285
283
  schema:
286
284
  type: string