@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 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. The `declarations/` directory is wiped and recreated on every run.
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
- - **`generateCodecDeclarations`**: Renders a `@ic-reactor/cod` codec module from Candid (also available on the `./renderer` subpath).
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