behavior-contracts 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +430 -115
- package/cli-contract.yaml +49 -51
- package/dist/authoring.d.ts +61 -424
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +53 -1157
- package/dist/authoring.js.map +1 -1
- package/dist/behavior.d.ts +7 -15
- package/dist/behavior.d.ts.map +1 -1
- package/dist/behavior.js.map +1 -1
- package/dist/builder.d.ts +4 -4
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +9 -11
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +5 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +12 -56
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/ts-compile.d.ts +23 -0
- package/dist/commands/ts-compile.d.ts.map +1 -0
- package/dist/commands/ts-compile.js +724 -0
- package/dist/commands/ts-compile.js.map +1 -0
- package/dist/commands/ts-extract.d.ts +67 -1
- package/dist/commands/ts-extract.d.ts.map +1 -1
- package/dist/commands/ts-extract.js +162 -31
- package/dist/commands/ts-extract.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.js +4 -4
- package/dist/generated/program.js.map +1 -1
- package/dist/generator/core.d.ts +11 -1
- package/dist/generator/core.d.ts.map +1 -1
- package/dist/generator/core.js +5 -4
- package/dist/generator/core.js.map +1 -1
- package/dist/generator/emit-php.d.ts +0 -17
- package/dist/generator/emit-php.d.ts.map +1 -1
- package/dist/generator/emit-php.js +25 -1
- package/dist/generator/emit-php.js.map +1 -1
- package/dist/generator/emit-python.d.ts +0 -7
- package/dist/generator/emit-python.d.ts.map +1 -1
- package/dist/generator/emit-python.js +34 -1
- package/dist/generator/emit-python.js.map +1 -1
- package/dist/generator/emit-straightline-typed-typescript.js +1 -1
- package/dist/generator/emit-straightline-typed-typescript.js.map +1 -1
- package/dist/generator/emit-typed-native-go.d.ts +1 -1
- package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-go.js +110 -107
- package/dist/generator/emit-typed-native-go.js.map +1 -1
- package/dist/generator/emit-typed-native-rust.d.ts +3 -2
- package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-rust.js +62 -126
- package/dist/generator/emit-typed-native-rust.js.map +1 -1
- package/dist/generator/emit-typescript-native.js +1 -1
- package/dist/generator/emit-typescript-native.js.map +1 -1
- package/dist/generator/emit-typescript.js +1 -1
- package/dist/generator/emit-typescript.js.map +1 -1
- package/dist/generator/typed.d.ts +5 -1
- package/dist/generator/typed.d.ts.map +1 -1
- package/dist/generator/typed.js +40 -9
- package/dist/generator/typed.js.map +1 -1
- package/dist/guard.d.ts +4 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +26 -8
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +19 -55
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -87
- package/dist/index.js.map +1 -1
- package/dist/lowering.d.ts +251 -0
- package/dist/lowering.d.ts.map +1 -0
- package/dist/lowering.js +652 -0
- package/dist/lowering.js.map +1 -0
- package/dist/provenance.js +4 -4
- package/dist/provenance.js.map +1 -1
- package/dist/runtime.d.ts +52 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +77 -0
- package/dist/runtime.js.map +1 -0
- package/dist/spec-versions.d.ts +25 -0
- package/dist/spec-versions.d.ts.map +1 -0
- package/dist/spec-versions.js +26 -0
- package/dist/spec-versions.js.map +1 -0
- package/dist/type-gate.d.ts +12 -0
- package/dist/type-gate.d.ts.map +1 -1
- package/dist/type-gate.js +79 -3
- package/dist/type-gate.js.map +1 -1
- package/package.json +5 -1
- package/dist/bind.d.ts +0 -64
- package/dist/bind.d.ts.map +0 -1
- package/dist/bind.js +0 -131
- package/dist/bind.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 (
|
|
10
|
-
|
|
11
|
-
<behaviors.ts> --behavior <ClassName>` uses the TypeScript compiler to
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
native module (data baked as literals). The IR exists
|
|
16
|
-
nothing reads it at runtime. `typescript` is a
|
|
17
|
-
dependency used solely on this `--from <.ts>`
|
|
18
|
-
dependency-free. `--in <ir-doc.json>` (a
|
|
19
|
-
remains as an internal/test input
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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):
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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.
|
|
78
|
-
- bc generate --lang go-typed-native --from behaviors.
|
|
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
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
117
|
-
|
|
118
|
-
|
|
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.
|
|
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):
|
|
267
|
-
compiler type-
|
|
268
|
-
optional peer `typescript`)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
value_name: behaviors.
|
|
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
|
|
283
|
-
|
|
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
|