@electrojs/config 1.0.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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/index.d.mts +164 -0
- package/dist/index.mjs +1 -0
- package/package.json +48 -0
- package/tsconfig/base.json +12 -0
- package/tsconfig/library.json +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anton Ryuben
|
|
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,119 @@
|
|
|
1
|
+
# @electrojs/config
|
|
2
|
+
|
|
3
|
+
Typed configuration contracts for Electro applications.
|
|
4
|
+
|
|
5
|
+
Electro supports a monorepo-style application layout with:
|
|
6
|
+
|
|
7
|
+
- one root `electro.config.ts`
|
|
8
|
+
- one `runtime/` package with `runtime.config.ts`
|
|
9
|
+
- one package per renderer view with `view.config.ts`
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add -D @electrojs/config vite typescript
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { defineElectroConfig, defineRuntimeConfig, defineViewConfig } from "@electrojs/config";
|
|
21
|
+
|
|
22
|
+
import type { AppConfig, RuntimeConfig, ViewConfig } from "@electrojs/config";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## `electro.config.ts`
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { defineElectroConfig } from "@electrojs/config";
|
|
29
|
+
|
|
30
|
+
export default defineElectroConfig({
|
|
31
|
+
runtime: "runtime",
|
|
32
|
+
views: ["@views/main", "@views/settings"],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`AppConfig`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
interface AppConfig {
|
|
40
|
+
readonly runtime: string;
|
|
41
|
+
readonly views: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- `runtime` is the package specifier for the runtime package
|
|
46
|
+
- `views` is the explicit list of renderer view package specifiers
|
|
47
|
+
|
|
48
|
+
Electro no longer documents single-repo auto-discovery as a supported setup.
|
|
49
|
+
|
|
50
|
+
## `runtime.config.ts`
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { defineRuntimeConfig } from "@electrojs/config";
|
|
54
|
+
|
|
55
|
+
export default defineRuntimeConfig({
|
|
56
|
+
entry: "./src/main.ts",
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`RuntimeConfig` extends Vite user config and adds:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
interface RuntimeConfig extends ViteUserConfig {
|
|
64
|
+
readonly entry: string;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `entry` points at the Electron main-process entry file inside the runtime package
|
|
69
|
+
|
|
70
|
+
## `view.config.ts`
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { defineViewConfig } from "@electrojs/config";
|
|
74
|
+
import react from "@vitejs/plugin-react";
|
|
75
|
+
|
|
76
|
+
export default defineViewConfig({
|
|
77
|
+
viewId: "main",
|
|
78
|
+
entry: "./index.html",
|
|
79
|
+
plugins: [react()],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`ViewConfig` extends Vite user config and adds:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
interface ViewConfig extends ViteUserConfig {
|
|
87
|
+
readonly viewId: string;
|
|
88
|
+
readonly entry?: string;
|
|
89
|
+
readonly preload?: string;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `viewId` is the bundled renderer id used by runtime `@View({ source: "view:<id>" })`
|
|
94
|
+
- `entry` defaults to `./index.html`
|
|
95
|
+
- `preload` is optional because Electro usually generates preload entrypoints automatically
|
|
96
|
+
|
|
97
|
+
## Layout
|
|
98
|
+
|
|
99
|
+
```txt
|
|
100
|
+
my-app/
|
|
101
|
+
├── electro.config.ts
|
|
102
|
+
├── pnpm-workspace.yaml
|
|
103
|
+
├── package.json
|
|
104
|
+
├── runtime/
|
|
105
|
+
│ ├── runtime.config.ts
|
|
106
|
+
│ └── src/main.ts
|
|
107
|
+
└── views/
|
|
108
|
+
├── main/
|
|
109
|
+
│ ├── view.config.ts
|
|
110
|
+
│ ├── index.html
|
|
111
|
+
│ └── src/main.tsx
|
|
112
|
+
└── settings/
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Related Packages
|
|
116
|
+
|
|
117
|
+
- `@electrojs/cli` runs `dev`, `generate`, `build`, and `preview`
|
|
118
|
+
- `@electrojs/runtime` powers the Electron runtime
|
|
119
|
+
- `@electrojs/renderer` powers the renderer bridge and signals APIs
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { UserConfig } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/app-config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Application-level configuration.
|
|
6
|
+
*
|
|
7
|
+
* Exported from `electro.config.ts` at the project root.
|
|
8
|
+
* Consumed by the Electro CLI for build, dev, preview, and code generation.
|
|
9
|
+
*/
|
|
10
|
+
interface AppConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Workspace package name of the runtime package.
|
|
13
|
+
*
|
|
14
|
+
* @example "runtime"
|
|
15
|
+
*/
|
|
16
|
+
readonly runtime: string;
|
|
17
|
+
/**
|
|
18
|
+
* Workspace package names of view packages.
|
|
19
|
+
*
|
|
20
|
+
* @example ["@views/main", "@views/settings"]
|
|
21
|
+
*/
|
|
22
|
+
readonly views: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/runtime-config.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Runtime build configuration.
|
|
28
|
+
*
|
|
29
|
+
* Exported from `runtime.config.ts` inside the runtime package.
|
|
30
|
+
* Extends Vite's `UserConfig` (minus fields Electro manages) with
|
|
31
|
+
* the Electron main-process–specific `entry` field.
|
|
32
|
+
*
|
|
33
|
+
* Users have full access to: `resolve`, `plugins`, `define`,
|
|
34
|
+
* `esbuild`, `ssr`, `css`, `assetsInclude`, `worker`, etc.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // runtime/runtime.config.ts
|
|
39
|
+
* import { defineRuntimeConfig } from "@electrojs/config";
|
|
40
|
+
* import { resolve } from "node:path";
|
|
41
|
+
*
|
|
42
|
+
* export default defineRuntimeConfig({
|
|
43
|
+
* entry: "./src/main.ts",
|
|
44
|
+
* resolve: {
|
|
45
|
+
* alias: { "@": resolve(import.meta.dirname, "./") },
|
|
46
|
+
* },
|
|
47
|
+
* ssr: {
|
|
48
|
+
* noExternal: ["better-sqlite3"],
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
interface RuntimeConfig extends UserConfig {
|
|
54
|
+
/**
|
|
55
|
+
* Entry point for the Electron main process.
|
|
56
|
+
* Relative to the runtime package root.
|
|
57
|
+
*
|
|
58
|
+
* @example "./src/main.ts"
|
|
59
|
+
*/
|
|
60
|
+
readonly entry: string;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/view-config.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* View build configuration.
|
|
66
|
+
*
|
|
67
|
+
* Exported from `view.config.ts` inside each view package.
|
|
68
|
+
* Extends Vite's `UserConfig` (minus fields Electro manages) with
|
|
69
|
+
* view-specific fields.
|
|
70
|
+
*
|
|
71
|
+
* Users have full access to: `resolve`, `plugins`, `define`,
|
|
72
|
+
* `esbuild`, `css`, `assetsInclude`, `optimizeDeps`, `worker`, etc.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // renderer/views/main/view.config.ts
|
|
77
|
+
* import { defineViewConfig } from "@electrojs/config";
|
|
78
|
+
* import { resolve } from "node:path";
|
|
79
|
+
* import react from "@vitejs/plugin-react";
|
|
80
|
+
*
|
|
81
|
+
* export default defineViewConfig({
|
|
82
|
+
* viewId: "main",
|
|
83
|
+
* entry: "./index.html",
|
|
84
|
+
* plugins: [react()],
|
|
85
|
+
* resolve: {
|
|
86
|
+
* alias: { "@": resolve(import.meta.dirname, "../../") },
|
|
87
|
+
* },
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
interface ViewConfig extends UserConfig {
|
|
92
|
+
/**
|
|
93
|
+
* The unique identifier of this view.
|
|
94
|
+
* Must match the `id` of the corresponding runtime `@View` class
|
|
95
|
+
* (derived from `resource: "view:<id>"`).
|
|
96
|
+
*
|
|
97
|
+
* @example "main"
|
|
98
|
+
*/
|
|
99
|
+
readonly viewId: string;
|
|
100
|
+
/**
|
|
101
|
+
* Path to the HTML entry file for this view.
|
|
102
|
+
* Relative to the view config file location.
|
|
103
|
+
*
|
|
104
|
+
* @example "./index.html"
|
|
105
|
+
*/
|
|
106
|
+
readonly entry: string;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/define-config.d.ts
|
|
110
|
+
/**
|
|
111
|
+
* Defines an application-level configuration with full type safety.
|
|
112
|
+
*
|
|
113
|
+
* Use in `electro.config.ts` at the project root.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* // electro.config.ts
|
|
118
|
+
* import { defineElectroConfig } from "@electrojs/config";
|
|
119
|
+
*
|
|
120
|
+
* export default defineElectroConfig({
|
|
121
|
+
* runtime: "runtime",
|
|
122
|
+
* views: ["@views/main"],
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
declare function defineElectroConfig(config: AppConfig): AppConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Defines a runtime build configuration with full type safety.
|
|
129
|
+
*
|
|
130
|
+
* Use in `runtime.config.ts` inside the runtime package.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* // runtime/runtime.config.ts
|
|
135
|
+
* import { defineRuntimeConfig } from "@electrojs/config";
|
|
136
|
+
*
|
|
137
|
+
* export default defineRuntimeConfig({
|
|
138
|
+
* entry: "./src/main.ts",
|
|
139
|
+
* ssr: { noExternal: ["better-sqlite3"] },
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function defineRuntimeConfig(config: RuntimeConfig): RuntimeConfig;
|
|
144
|
+
/**
|
|
145
|
+
* Defines a view build configuration with full type safety.
|
|
146
|
+
*
|
|
147
|
+
* Use in `view.config.ts` inside each view package.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* // renderer/views/main/view.config.ts
|
|
152
|
+
* import { defineViewConfig } from "@electrojs/config";
|
|
153
|
+
* import react from "@vitejs/plugin-react";
|
|
154
|
+
*
|
|
155
|
+
* export default defineViewConfig({
|
|
156
|
+
* viewId: "main",
|
|
157
|
+
* entry: "./index.html",
|
|
158
|
+
* plugins: [react()],
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function defineViewConfig(config: ViewConfig): ViewConfig;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { type AppConfig, type RuntimeConfig, type ViewConfig, defineElectroConfig, defineRuntimeConfig, defineViewConfig };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e}function t(e){return e}function n(e){return e}export{e as defineElectroConfig,t as defineRuntimeConfig,n as defineViewConfig};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@electrojs/config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared configuration presets for Electro",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"config",
|
|
7
|
+
"electro",
|
|
8
|
+
"tsconfig",
|
|
9
|
+
"typescript"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/MyraxByte/electrojs.git",
|
|
15
|
+
"directory": "packages/config"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"tsconfig/*.json",
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"import": "./dist/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./tsconfig/base.json": "./tsconfig/base.json",
|
|
32
|
+
"./tsconfig/library.json": "./tsconfig/library.json"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"publint": "^0.3.18",
|
|
39
|
+
"tsdown": "^0.21.4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"typescript": ">=6.0.2",
|
|
43
|
+
"vite": ">=8"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsdown"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noImplicitOverride": true,
|
|
5
|
+
"noUncheckedIndexedAccess": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"emitDecoratorMetadata": true,
|
|
9
|
+
"experimentalDecorators": true
|
|
10
|
+
},
|
|
11
|
+
"exclude": ["node_modules", "dist"]
|
|
12
|
+
}
|