Skip to content

Commit 2c799be

Browse files
committed
feat: upgrade to latest electron
1 parent bf69b0f commit 2c799be

File tree

6 files changed

+2173
-1204
lines changed

6 files changed

+2173
-1204
lines changed

.vscode/settings.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Enable the ESlint flat config support
3+
"eslint.experimental.useFlatConfig": true,
4+
5+
// Disable the default formatter, use eslint instead
6+
"prettier.enable": false,
7+
"editor.formatOnSave": false,
8+
9+
// Auto fix
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll": "explicit",
12+
"source.organizeImports": "never"
13+
},
14+
15+
// Silent the stylistic rules in you IDE, but still auto fix them
16+
"eslint.rules.customizations": [
17+
{ "rule": "style/*", "severity": "off" },
18+
{ "rule": "*-indent", "severity": "off" },
19+
{ "rule": "*-spacing", "severity": "off" },
20+
{ "rule": "*-spaces", "severity": "off" },
21+
{ "rule": "*-order", "severity": "off" },
22+
{ "rule": "*-dangle", "severity": "off" },
23+
{ "rule": "*-newline", "severity": "off" },
24+
{ "rule": "*quotes", "severity": "off" },
25+
{ "rule": "*semi", "severity": "off" }
26+
],
27+
28+
// Enable eslint for all supported languages
29+
"eslint.validate": [
30+
"javascript",
31+
"javascriptreact",
32+
"typescript",
33+
"typescriptreact",
34+
"vue",
35+
"html",
36+
"markdown",
37+
"json",
38+
"jsonc",
39+
"yaml"
40+
]
41+
}

broz.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
22
'use strict'
3-
const { execFileSync } = require('child_process')
4-
const path = require('path')
3+
const process = require('node:process')
4+
const { execFileSync } = require('node:child_process')
5+
const path = require('node:path')
56

67
const args = [path.resolve(__dirname, 'index.js'), ...Array.from(process.argv).slice(2)]
78
execFileSync(String(require('electron')), args, { stdio: 'inherit' })

eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @ts-check
2+
const antfu = require('@antfu/eslint-config').default
3+
4+
module.exports = antfu()

index.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @ts-check
2+
const process = require('node:process')
23
const { app, BrowserWindow } = require('electron')
34
const createState = require('electron-window-state')
45
const yargs = require('yargs')
@@ -27,12 +28,12 @@ yargs
2728
})
2829
.option('height', {
2930
type: 'number',
30-
default: false,
31+
default: undefined,
3132
desc: 'set initial window height',
3233
})
3334
.option('width', {
3435
type: 'number',
35-
default: false,
36+
default: undefined,
3637
desc: 'set initial window width',
3738
}),
3839
async (args) => {
@@ -76,6 +77,14 @@ function createMainWindow(args) {
7677
})
7778

7879
state.manage(main)
80+
const debouncedSaveWindowState = debounce(
81+
event => state.saveState(event.sender),
82+
500,
83+
)
84+
85+
main.on('resize', debouncedSaveWindowState)
86+
main.on('move', debouncedSaveWindowState)
87+
7988
configureWindow(main, args)
8089

8190
return main
@@ -155,3 +164,13 @@ document.head.appendChild(rootStyle)
155164

156165
return win
157166
}
167+
168+
function debounce(fn, delay) {
169+
let timeoutID = null
170+
return function (...args) {
171+
clearTimeout(timeoutID)
172+
timeoutID = setTimeout(() => {
173+
fn(...args)
174+
}, delay)
175+
}
176+
}

package.json

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "broz",
33
"version": "0.3.3",
4-
"packageManager": "pnpm@7.3.0",
4+
"packageManager": "pnpm@8.9.0",
55
"description": "A simple, frameless browser for screenshots",
66
"author": "antfu <[email protected]>",
77
"license": "MIT",
@@ -22,18 +22,15 @@
2222
"release": "bumpp --commit --tag --push && npm publish"
2323
},
2424
"dependencies": {
25-
"electron": "^12.0.6",
25+
"electron": "^26.3.0",
2626
"electron-window-state": "^5.0.3",
27-
"yargs": "^17.5.1"
27+
"yargs": "^17.7.2"
2828
},
2929
"devDependencies": {
30-
"@antfu/eslint-config": "^0.25.1",
31-
"@types/yargs": "^17.0.10",
32-
"bumpp": "^8.2.1",
33-
"eslint": "^8.18.0",
34-
"typescript": "^4.7.4"
35-
},
36-
"eslintConfig": {
37-
"extends": "@antfu"
30+
"@antfu/eslint-config": "^1.0.0-beta.24",
31+
"@types/yargs": "^17.0.28",
32+
"bumpp": "^9.2.0",
33+
"eslint": "^8.51.0",
34+
"typescript": "^5.2.2"
3835
}
3936
}

0 commit comments

Comments
 (0)