@ic-reactor/codegen 0.12.0 → 0.13.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 +14 -4
- package/dist/index.cjs +415 -699
- package/dist/index.d.cts +119 -28
- package/dist/index.d.ts +119 -28
- package/dist/index.js +404 -98
- package/package.json +9 -15
- package/src/generators/declarations.ts +164 -21
- package/src/generators/reactor.ts +20 -7
- package/src/index.ts +19 -5
- package/src/pipeline.ts +190 -18
- package/src/validate.ts +407 -0
- package/dist/chunk-VBCR5IVT.js +0 -609
- package/dist/renderer.cjs +0 -639
- package/dist/renderer.d.cts +0 -33
- package/dist/renderer.d.ts +0 -33
- package/dist/renderer.js +0 -14
- package/src/__snapshots__/bindgen.test.ts.snap +0 -18
- package/src/__snapshots__/reactor.test.ts.snap +0 -127
- package/src/bindgen.test.ts +0 -85
- package/src/metadata-rules.json +0 -144
- package/src/metadata.ts +0 -157
- package/src/naming.test.ts +0 -45
- package/src/parser.ts +0 -79
- package/src/pipeline.test.ts +0 -355
- package/src/reactor.test.ts +0 -84
- package/src/renderer.test.ts +0 -573
- package/src/renderer.ts +0 -515
package/README.md
CHANGED
|
@@ -45,7 +45,9 @@ Set `target` to control whether generated files include React hooks:
|
|
|
45
45
|
- `react` (default): generates the reactor plus bound `createActorHooks` exports
|
|
46
46
|
- `core`: generates only the typed reactor exports with no `@ic-reactor/react` dependency
|
|
47
47
|
|
|
48
|
-
Codegen now writes two files per canister: a managed `index.generated.ts` implementation that is regenerated on every run, and an `index.ts` entry wrapper. The wrapper is created once, then preserved unless it still matches the default generated wrapper or an older generated scaffold that can be migrated automatically.
|
|
48
|
+
Codegen now writes two files per canister: a managed `index.generated.ts` implementation that is regenerated on every run, and an `index.ts` entry wrapper. The wrapper is created once, then preserved unless it still matches the default generated wrapper or an older generated scaffold that can be migrated automatically. A scaffold that carries any export the old generator never wrote counts as user-owned and is left alone; one that is migrated is copied to `index.ts.bak` first.
|
|
49
|
+
|
|
50
|
+
Each canister needs its own `outDir`. Generating into a directory that already holds another canister's `index.generated.ts` fails rather than overwriting it, because every run replaces `declarations/` wholesale.
|
|
49
51
|
|
|
50
52
|
Set `generateReactor: false` if you only want the bindgen/declaration output and
|
|
51
53
|
need to skip `index.generated.ts` and `index.ts`.
|
|
@@ -54,7 +56,7 @@ need to skip `index.generated.ts` and `index.ts`.
|
|
|
54
56
|
|
|
55
57
|
You can also use individual generators if you need more granular control:
|
|
56
58
|
|
|
57
|
-
- **`generateDeclarations`**: Writes `declarations/<did-basename>.js` (factory), `.d.ts` (types), and a `.did` copy.
|
|
59
|
+
- **`generateDeclarations`**: Writes `declarations/<did-basename>.js` (factory), `.d.ts` (types), and a `.did` copy. Generation runs in a staging directory that replaces `declarations/` only once every file is written, so a `.did` that fails to parse leaves the previous declarations untouched. A `.did` that parses but declares no `service` is rejected — it would produce no `idlFactory` and no `_SERVICE`.
|
|
58
60
|
- **`generateReactorFile`**: Generates the managed `index.generated.ts` implementation using any `ReactorClassName` — `Reactor`, `DisplayReactor` (default), `CandidReactor`, `CandidDisplayReactor`, or `MetadataDisplayReactor`. With `target: "react"` it also emits the six `createActorHooks` exports (`use<Canister>Query`, `use<Canister>SuspenseQuery`, `use<Canister>InfiniteQuery`, `use<Canister>SuspenseInfiniteQuery`, `use<Canister>Mutation`, `use<Canister>Method`). No `createQuery` / `createMutation` objects are generated.
|
|
59
61
|
- **`generateReactorEntryFile`**: Generates the stable `index.ts` wrapper that re-exports from `index.generated.ts`.
|
|
60
62
|
- **`generateClientFile`**: Generates a `ClientManager` boilerplate file that
|
|
@@ -62,9 +64,17 @@ You can also use individual generators if you need more granular control:
|
|
|
62
64
|
|
|
63
65
|
## Utilities
|
|
64
66
|
|
|
65
|
-
- **`parseDIDFile` / `extractMethods`**: Parse a `.did` file and extract method signatures.
|
|
66
67
|
- **`toPascalCase` / `getReactorName` / `getServiceTypeName`**: Naming helpers.
|
|
67
|
-
- **`
|
|
68
|
+
- **`assertSafeCanisterConfig` and friends**: Validate a canister config before generating; the pipeline runs these itself.
|
|
69
|
+
|
|
70
|
+
`parseDIDFile` / `extractMethods` (and the `MethodInfo` / `MethodType` types)
|
|
71
|
+
have been removed. They regex-scraped the pretty-printed JS from
|
|
72
|
+
`didToJs`, which silently returned no methods for any service whose first
|
|
73
|
+
method took an inline record, dropped every method whose signature wrapped over
|
|
74
|
+
80 columns, and reported `composite_query` as a mutation. Read a `.did` with
|
|
75
|
+
[`parseDid()`](https://ic-reactor.b3pay.net/v3/packages/parser) from
|
|
76
|
+
`@ic-reactor/parser` instead — it returns `{ name, mode, args, returns }` per
|
|
77
|
+
method, straight from the Rust parser.
|
|
68
78
|
|
|
69
79
|
## License
|
|
70
80
|
|