@ic-reactor/vite-plugin 0.6.0 → 0.7.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
@@ -87,56 +87,23 @@ function MyComponent() {
87
87
  }
88
88
  ```
89
89
 
90
- ### Reactor Mode (raw vs display)
90
+ ### Reactor Mode (per canister)
91
91
 
92
- By default, generated hooks use `DisplayReactor` (backward compatible). You can switch the default globally, and override specific canisters that need raw Candid shapes.
92
+ By default, generated hooks use `DisplayReactor` (backward compatible). Set `mode` on a canister to choose the generated reactor class (`Reactor`, `DisplayReactor`, `CandidReactor`, `CandidDisplayReactor`, or `MetadataDisplayReactor`).
93
93
 
94
94
  ```ts
95
95
  icReactor({
96
96
  canisters: [
97
97
  { name: "backend", didFile: "./backend/backend.did" },
98
- { name: "workflow_engine", didFile: "./workflow/workflow_engine.did" },
99
- ],
100
- reactor: {
101
- defaultMode: "display",
102
- canisters: {
103
- workflow_engine: "raw",
98
+ {
99
+ name: "workflow_engine",
100
+ mode: "Reactor",
101
+ didFile: "./workflow/workflow_engine.did",
104
102
  },
105
- },
103
+ ],
106
104
  })
107
105
  ```
108
106
 
109
- Generated canister folders now contain:
110
-
111
- - `index.generated.ts` (overwritten on regenerate)
112
- - `index.ts` (created once if missing, never overwritten)
113
-
114
- The generated implementation exports both factories so apps can opt in explicitly without editing generated files:
115
-
116
- ```ts
117
- // display-default canister (generated)
118
- export function createBackendRawReactor() {
119
- /* ... */
120
- }
121
- export function createBackendDisplayReactor() {
122
- /* ... */
123
- }
124
- export const backendReactor = createBackendDisplayReactor()
125
- export const BackendReactorMode = "display" as const
126
- ```
127
-
128
- ```ts
129
- // raw-default canister (generated)
130
- export function createWorkflowEngineRawReactor() {
131
- /* ... */
132
- }
133
- export function createWorkflowEngineDisplayReactor() {
134
- /* ... */
135
- }
136
- export const workflowEngineReactor = createWorkflowEngineRawReactor()
137
- export const WorkflowEngineReactorMode = "raw" as const
138
- ```
139
-
140
107
  ## Configuration
141
108
 
142
109
  ### Plugin Options
@@ -147,24 +114,17 @@ export const WorkflowEngineReactorMode = "raw" as const
147
114
  | `outDir` | `string` | Base output directory for generated files. | `"src/declarations"` |
148
115
  | `clientManagerPath` | `string` | Path to client manager import. | `"../../clients"` |
149
116
  | `injectEnvironment` | `boolean` | Inject `ic_env` cookie for local development. | `true` |
150
- | `reactor` | `ReactorConfig` | Default/per-canister raw vs display reactor mode. | display default |
151
117
 
152
118
  ### Canister Config
153
119
 
154
- | Option | Type | Description | Required |
155
- | :------------------ | :------- | :---------------------------------------------- | :------- |
156
- | `name` | `string` | Name of the canister (used for variable names). | Yes |
157
- | `didFile` | `string` | Path to the `.did` file. | Yes |
158
- | `outDir` | `string` | Override output directory for this canister. | No |
159
- | `clientManagerPath` | `string` | Override client manager path. | No |
160
- | `canisterId` | `string` | Optional fixed canister ID. | No |
161
-
162
- ### ReactorConfig
163
-
164
- | Option | Type | Description | Required |
165
- | :------------ | :----------------------------------- | :--------------------------------------- | :------- |
166
- | `defaultMode` | `"raw" \| "display"` | Global default mode for generated hooks. | No |
167
- | `canisters` | `Record<string, "raw" \| "display">` | Per-canister overrides keyed by name. | No |
120
+ | Option | Type | Description | Required |
121
+ | :------------------ | :------------------------------------------------------------------------------------------------------- | :---------------------------------------------- | :------- |
122
+ | `name` | `string` | Name of the canister (used for variable names). | Yes |
123
+ | `didFile` | `string` | Path to the `.did` file. | Yes |
124
+ | `outDir` | `string` | Override output directory for this canister. | No |
125
+ | `clientManagerPath` | `string` | Override client manager path. | No |
126
+ | `mode` | `"Reactor" \| "DisplayReactor" \| "CandidReactor" \| "CandidDisplayReactor" \| "MetadataDisplayReactor"` | Reactor class for generated hooks. | No |
127
+ | `canisterId` | `string` | Optional fixed canister ID. | No |
168
128
 
169
129
  ## Local Development (Environment Injection)
170
130
 
package/dist/index.cjs CHANGED
@@ -83,16 +83,12 @@ function icReactor(options) {
83
83
  canisters,
84
84
  outDir = "src/declarations",
85
85
  clientManagerPath = "../../clients",
86
- injectEnvironment = true,
87
- reactor
86
+ injectEnvironment = true
88
87
  } = options;
89
88
  const globalConfig = {
90
89
  outDir,
91
90
  clientManagerPath
92
91
  };
93
- if (reactor != null) {
94
- globalConfig.reactor = reactor;
95
- }
96
92
  const plugin = {
97
93
  name: "ic-reactor-plugin",
98
94
  enforce: "pre",
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { CanisterConfig, ReactorGenerationConfig } from '@ic-reactor/codegen';
1
+ import { CanisterConfig } from '@ic-reactor/codegen';
2
2
 
3
3
  /**
4
4
  * @ic-reactor/vite-plugin
@@ -30,11 +30,6 @@ interface IcReactorPluginOptions {
30
30
  * Default: true
31
31
  */
32
32
  injectEnvironment?: boolean;
33
- /**
34
- * Reactor generation behavior.
35
- * Controls whether generated default hooks use raw (Reactor) or display (DisplayReactor).
36
- */
37
- reactor?: ReactorGenerationConfig;
38
33
  }
39
34
  declare function icReactor(options: IcReactorPluginOptions): any;
40
35
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CanisterConfig, ReactorGenerationConfig } from '@ic-reactor/codegen';
1
+ import { CanisterConfig } from '@ic-reactor/codegen';
2
2
 
3
3
  /**
4
4
  * @ic-reactor/vite-plugin
@@ -30,11 +30,6 @@ interface IcReactorPluginOptions {
30
30
  * Default: true
31
31
  */
32
32
  injectEnvironment?: boolean;
33
- /**
34
- * Reactor generation behavior.
35
- * Controls whether generated default hooks use raw (Reactor) or display (DisplayReactor).
36
- */
37
- reactor?: ReactorGenerationConfig;
38
33
  }
39
34
  declare function icReactor(options: IcReactorPluginOptions): any;
40
35
 
package/dist/index.js CHANGED
@@ -51,16 +51,12 @@ function icReactor(options) {
51
51
  canisters,
52
52
  outDir = "src/declarations",
53
53
  clientManagerPath = "../../clients",
54
- injectEnvironment = true,
55
- reactor
54
+ injectEnvironment = true
56
55
  } = options;
57
56
  const globalConfig = {
58
57
  outDir,
59
58
  clientManagerPath
60
59
  };
61
- if (reactor != null) {
62
- globalConfig.reactor = reactor;
63
- }
64
60
  const plugin = {
65
61
  name: "ic-reactor-plugin",
66
62
  enforce: "pre",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/vite-plugin",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Vite plugin for zero-config IC reactor generation from Candid files",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/B3Pay/ic-reactor/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@ic-reactor/codegen": "0.6.0"
40
+ "@ic-reactor/codegen": "0.7.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
package/src/index.test.ts CHANGED
@@ -157,31 +157,28 @@ describe("icReactor", () => {
157
157
  consoleErrorSpy.mockRestore()
158
158
  })
159
159
 
160
- it("should pass reactor mode config to codegen", async () => {
160
+ it("should pass canister mode through to codegen via canister config", async () => {
161
161
  const plugin = icReactor({
162
- ...mockOptions,
163
- reactor: {
164
- defaultMode: "display",
165
- canisters: {
166
- test_canister: "raw",
162
+ canisters: [
163
+ {
164
+ ...mockOptions.canisters[0],
165
+ mode: "Reactor",
167
166
  },
168
- },
167
+ ],
168
+ outDir: mockOptions.outDir,
169
169
  })
170
170
 
171
171
  await (plugin.buildStart as any)()
172
172
 
173
173
  expect(runCanisterPipeline).toHaveBeenCalledWith({
174
- canisterConfig: mockOptions.canisters[0],
174
+ canisterConfig: {
175
+ ...mockOptions.canisters[0],
176
+ mode: "Reactor",
177
+ },
175
178
  projectRoot: expect.any(String),
176
179
  globalConfig: {
177
180
  outDir: "src/declarations",
178
181
  clientManagerPath: "../../clients",
179
- reactor: {
180
- defaultMode: "display",
181
- canisters: {
182
- test_canister: "raw",
183
- },
184
- },
185
182
  },
186
183
  })
187
184
  })
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  runCanisterPipeline,
14
14
  type CanisterConfig,
15
15
  type CodegenConfig,
16
- type ReactorGenerationConfig,
17
16
  } from "@ic-reactor/codegen"
18
17
  import { getIcEnvironmentInfo, buildIcEnvCookie } from "./env.js"
19
18
 
@@ -38,11 +37,6 @@ export interface IcReactorPluginOptions {
38
37
  * Default: true
39
38
  */
40
39
  injectEnvironment?: boolean
41
- /**
42
- * Reactor generation behavior.
43
- * Controls whether generated default hooks use raw (Reactor) or display (DisplayReactor).
44
- */
45
- reactor?: ReactorGenerationConfig
46
40
  }
47
41
 
48
42
  export function icReactor(options: IcReactorPluginOptions): any {
@@ -51,20 +45,13 @@ export function icReactor(options: IcReactorPluginOptions): any {
51
45
  outDir = "src/declarations",
52
46
  clientManagerPath = "../../clients",
53
47
  injectEnvironment = true,
54
- reactor,
55
48
  } = options
56
49
 
57
50
  // Construct a partial CodegenConfig to pass to the pipeline
58
- const globalConfig: Pick<
59
- CodegenConfig,
60
- "outDir" | "clientManagerPath" | "reactor"
61
- > = {
51
+ const globalConfig: Pick<CodegenConfig, "outDir" | "clientManagerPath"> = {
62
52
  outDir,
63
53
  clientManagerPath,
64
54
  }
65
- if (reactor != null) {
66
- globalConfig.reactor = reactor
67
- }
68
55
 
69
56
  const plugin: Plugin = {
70
57
  name: "ic-reactor-plugin",