electron-types 0.0.1
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 +22 -0
- package/README.md +78 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Electron contributors
|
|
4
|
+
Copyright (c) 2024 electron-types contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# electron-types
|
|
2
|
+
|
|
3
|
+
TypeScript type definitions extracted from the [electron](https://www.electronjs.org/) package.
|
|
4
|
+
|
|
5
|
+
## Why?
|
|
6
|
+
|
|
7
|
+
The official `electron` package is ~200MB because it includes the Electron binary. If you only need TypeScript types (e.g., for type-checking code that will run in an Electron context), this package provides just the type definitions (~1MB).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Since this package only provides TypeScript types, install it as a dev dependency:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -D electron-types
|
|
15
|
+
# or
|
|
16
|
+
yarn add -D electron-types
|
|
17
|
+
# or
|
|
18
|
+
pnpm add -D electron-types
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
The types are available via the `Electron` namespace:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// Types are available via the Electron namespace
|
|
27
|
+
const win: Electron.BrowserWindow = /* ... */;
|
|
28
|
+
const app: Electron.App = /* ... */;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For projects that need to reference the types in a `.d.ts` file:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
/// <reference types="electron-types" />
|
|
35
|
+
|
|
36
|
+
declare const myWindow: Electron.BrowserWindow;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Version Matching
|
|
40
|
+
|
|
41
|
+
This package's version matches the electron version it was extracted from. For example, `electron-types@39.2.7` contains types from `electron@39.2.7`.
|
|
42
|
+
|
|
43
|
+
## How It Works
|
|
44
|
+
|
|
45
|
+
This package is automatically updated via CI:
|
|
46
|
+
|
|
47
|
+
1. A scheduled GitHub Action checks for new electron releases every 6 hours
|
|
48
|
+
2. When a new version is detected, it downloads the electron package
|
|
49
|
+
3. Extracts the `electron.d.ts` type definitions
|
|
50
|
+
4. Publishes to npm using [Trusted Publisher](https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions) (OIDC) with provenance attestation
|
|
51
|
+
|
|
52
|
+
## Development
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Install dependencies
|
|
56
|
+
yarn install
|
|
57
|
+
|
|
58
|
+
# Extract types from latest electron
|
|
59
|
+
yarn extract
|
|
60
|
+
|
|
61
|
+
# Extract types from a specific version
|
|
62
|
+
yarn extract 39.2.7
|
|
63
|
+
|
|
64
|
+
# Build package for a specific version (extract + update version)
|
|
65
|
+
yarn build 39.2.7
|
|
66
|
+
|
|
67
|
+
# Test that types work correctly
|
|
68
|
+
yarn test
|
|
69
|
+
|
|
70
|
+
# Check if a new version needs to be published
|
|
71
|
+
yarn check-versions
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT - Same as Electron
|
|
77
|
+
|
|
78
|
+
The type definitions are extracted from the Electron project, which is licensed under the MIT license.
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "electron-types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "TypeScript type definitions extracted from the electron package",
|
|
6
|
+
"types": "./dist/electron.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"extract": "tsx scripts/extract-types.ts",
|
|
12
|
+
"build": "tsx scripts/build.ts",
|
|
13
|
+
"test": "vitest --typecheck.only --run",
|
|
14
|
+
"test:watch": "vitest --typecheck.only",
|
|
15
|
+
"check-versions": "tsx scripts/check-versions.ts"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"electron",
|
|
19
|
+
"types",
|
|
20
|
+
"typescript",
|
|
21
|
+
"definitions"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/biw/electron-types.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/biw/electron-types/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/biw/electron-types#readme",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@types/node": "^22.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"expect-type": "^1.3.0",
|
|
37
|
+
"tsx": "^4.0.0",
|
|
38
|
+
"typescript": "^5.0.0",
|
|
39
|
+
"vitest": "^4.0.16"
|
|
40
|
+
},
|
|
41
|
+
"packageManager": "yarn@4.12.0",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|