@tsplc/typegen 0.5.14 → 0.5.15

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 CHANGED
@@ -1,7 +1,33 @@
1
1
  # @tsplc/typegen
2
2
 
3
- Part of [tsPLC](https://github.com/rip-technologies/tsplc).
3
+ Generates TypeScript from Structured Text declarations and EtherNet/IP EDS files: the PLC contract that `@tsplc/opcua` reads, and the hardware I/O types that check a project's `io`. Part of [tsPLC](https://github.com/rip-technologies/tsplc); in a tsPLC project, `tsplc typegen` runs it.
4
4
 
5
- Generates TypeScript contracts for host clients from Structured Text declarations, and parses EtherNet/IP EDS files into typed hardware IO channels. In a tsPLC project, `tsplc typegen` writes `generated/hardware.ts`, whose `HardwareIoMapping` type checks every `io` key and channel in `tsplc.config.ts`.
5
+ ## Install
6
6
 
7
- See the [documentation](https://github.com/rip-technologies/tsplc/tree/master/docs). MIT licensed.
7
+ ```sh
8
+ bun add -d @tsplc/typegen
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Without a tsPLC project, generate a contract from declaration directories:
14
+
15
+ ```sh
16
+ bunx tsplc-typegen --types src/types --globals src/globals --out generated/plc.ts
17
+ bunx tsplc-typegen --types src/types --globals src/globals --out generated/plc.ts --check
18
+ ```
19
+
20
+ Or from code:
21
+
22
+ ```ts
23
+ import { generateTypes } from "@tsplc/typegen";
24
+
25
+ const source = await generateTypes({ types: "src/types", globals: ["src/globals"], publication: null, declarations: true });
26
+ await Bun.write("generated/plc.ts", source);
27
+ ```
28
+
29
+ ## Documentation
30
+
31
+ [Type generation](https://github.com/rip-technologies/tsplc/blob/master/docs/03-guides/type-generation.md).
32
+
33
+ MIT licensed.