@electron-ipc-bridge/vite-plugin 0.0.4
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/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/constants.d.ts +5 -0
- package/dist/generate-ipc.d.ts +9 -0
- package/dist/generator/build-namespaces.d.ts +2 -0
- package/dist/generator/build-type-definitions.d.ts +2 -0
- package/dist/generator/generate-global-types.d.ts +1 -0
- package/dist/generator/generate-runtime-types.d.ts +2 -0
- package/dist/generator/generate-types.d.ts +2 -0
- package/dist/generator/get-return-type.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1158 -0
- package/dist/index.js.map +7 -0
- package/dist/normalize-path.d.ts +1 -0
- package/dist/parser/ast-utils.d.ts +3 -0
- package/dist/parser/collect-dependencies.d.ts +2 -0
- package/dist/parser/collect-external-type-references.d.ts +2 -0
- package/dist/parser/constants.d.ts +1 -0
- package/dist/parser/extract-metadata.d.ts +3 -0
- package/dist/parser/extract-type.d.ts +4 -0
- package/dist/parser/find-controllers.d.ts +9 -0
- package/dist/parser/find-nest-root-module.d.ts +6 -0
- package/dist/parser/get-decorator.d.ts +2 -0
- package/dist/parser/is-truncated-type-string.d.ts +2 -0
- package/dist/parser/parse-controller.d.ts +3 -0
- package/dist/parser/parse-method.d.ts +3 -0
- package/dist/parser/process-create-ipc-app-call.d.ts +4 -0
- package/dist/parser/resolve-controller.d.ts +3 -0
- package/dist/parser/resolve-controllers-from-array.d.ts +3 -0
- package/dist/parser/resolve-controllers-from-module-class.d.ts +3 -0
- package/dist/parser/resolve-controllers-from-module.d.ts +3 -0
- package/dist/parser/resolve-controllers-from-nest-root.d.ts +6 -0
- package/dist/parser/resolve-return-type.d.ts +3 -0
- package/dist/parser/types.d.ts +28 -0
- package/dist/plugin-state.d.ts +17 -0
- package/dist/plugin.d.ts +21 -0
- package/dist/preload/resolve-api-root.d.ts +4 -0
- package/dist/resolve-type-paths.d.ts +12 -0
- package/dist/strategies/nest.d.ts +7 -0
- package/dist/strategies/types.d.ts +12 -0
- package/dist/types.d.ts +24 -0
- package/dist/utils/dependency-collector.d.ts +6 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 metacurb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<h1 align="center">@electron-ipc-bridge/vite-plugin</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
A <a href="https://vitejs.dev/">Vite</a> plugin for <a href="https://metacurb.github.io/electron-ipc-bridge/">Electron IPC Bridge</a>. It parses your main entry, discovers controllers registered with <code>createIpcApp</code>, and generates global (e.g. <code>Window</code>) and/or runtime type modules so the renderer gets typed IPC (e.g. <code>window.ipc</code>).
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -D @electron-ipc-bridge/vite-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer: `vite` ^5 / ^6 / ^7, `typescript` ^5.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// vite.config.ts
|
|
19
|
+
import { electronIpcBridge } from "@electron-ipc-bridge/vite-plugin";
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
plugins: [electronIpcBridge()],
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
| Option | Description |
|
|
29
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
30
|
+
| `main` | Path to main process entry. Default: `"src/main/index.ts"` |
|
|
31
|
+
| `preload` | Path to preload entry. Default: `"src/preload/index.ts"` |
|
|
32
|
+
| `types.global` | Output path for generated global `Window` augmentation (`.d.ts`). Default: preload dir + `ipc.d.ts`. Set `false` to disable. |
|
|
33
|
+
| `types.runtime` | Output path for generated runtime types module. Default: auto (e.g. `src/renderer/src/ipc.types.ts`). Set `false` to disable. |
|
|
34
|
+
| `resolutionStrategy` | Optional strategy when `controllers` is a call and default resolution finds nothing. Set to `"nest"` for NestJS. See below. |
|
|
35
|
+
|
|
36
|
+
### Resolution behaviour
|
|
37
|
+
|
|
38
|
+
- **Array:** `createIpcApp({ controllers: [FooController, ...] })` — resolved from the array.
|
|
39
|
+
- **Call with module/class:** `createIpcApp({ controllers: getIpcControllers(SomeModule) })` — plugin follows call args to class refs and resolves from decorators with `controllers`/`providers` (e.g. Nest `@Module`). No strategy needed.
|
|
40
|
+
- **Call with no static refs (e.g. DI):** When the above yields no controllers, an optional `resolutionStrategy` runs. For Nest, set `resolutionStrategy: "nest"`.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { electronIpcBridge } from "@electron-ipc-bridge/vite-plugin";
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
plugins: [electronIpcBridge({ resolutionStrategy: "nest" })],
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Full defaults and semantics: [Plugin Options](https://metacurb.github.io/electron-ipc-bridge/reference/vite-plugin/plugin-options) · [Generation Behaviour](https://metacurb.github.io/electron-ipc-bridge/reference/vite-plugin/generation-behaviour).
|
|
51
|
+
|
|
52
|
+
## Documentation
|
|
53
|
+
|
|
54
|
+
[metacurb.github.io/electron-ipc-bridge](https://metacurb.github.io/electron-ipc-bridge/)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const DEFAULT_GLOBAL_TYPES_FILENAME = "ipc.d.ts";
|
|
2
|
+
export declare const DEFAULT_MAIN_ENTRY = "src/main/index.ts";
|
|
3
|
+
export declare const DEFAULT_PRELOAD_ENTRY = "src/preload/index.ts";
|
|
4
|
+
export declare const DEFAULT_RENDERER_RUNTIME_DIR = "src/renderer/src";
|
|
5
|
+
export declare const DEFAULT_RUNTIME_TYPES_FILENAME = "ipc.types.ts";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from "vite";
|
|
2
|
+
import { PluginState } from "./plugin-state.js";
|
|
3
|
+
import type { PluginTypesOptions, ResolutionStrategy } from "./types.js";
|
|
4
|
+
export declare function generateIpc(root: string, logger: Logger, state: PluginState, options: {
|
|
5
|
+
main: string;
|
|
6
|
+
preload: string;
|
|
7
|
+
types: PluginTypesOptions;
|
|
8
|
+
resolutionStrategy?: ResolutionStrategy;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateGlobalTypes: (namespace: string | undefined, ipcApiImportPath: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getReturnType: (decorator: string, originalReturnType: string) => string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { electronIpcBridge, type PluginOptions } from "./plugin.js";
|