Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"/.webpack",
"/coverage",
"/node_modules",
"/.yarn",
"/static"
"/.yarn"
]
}
12 changes: 11 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
module.exports = {
trailingComma: "all",
trailingComma: 'all',
singleQuote: true,
overrides: [
{
// The bundled templates are semicolon-free, unlike src/.
files: 'static/**/*.js',
options: {
semi: false,
trailingComma: 'none',
},
},
],
};
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
"main": "./.webpack/main",
"scripts": {
"contributors": "tsx ./tools/contributors.ts",
"format": "prettier src --check --experimental-cli",
"format:write": "prettier src --write --experimental-cli",
"format": "prettier src \"static/**/*.js\" --check --experimental-cli",
"format:write": "prettier src \"static/**/*.js\" --write --experimental-cli",
"lint:style": "stylelint \"./src/less/*.less\"",
"lint:js": "oxlint",
"lint:markdown": "markdownlint-cli2 \"*.md\"",
"lint:templates": "standard \"static/**/*.js\"",
"lint:links": "lint-roller-markdown-links \"*.md\"",
"lint:fix": "npm-run-all \"lint:!(fix|links) -- --fix\"",
"lint": "npm-run-all \"lint:!(fix)\"",
Expand Down Expand Up @@ -119,7 +118,6 @@
"postcss": "^8.5.23",
"postcss-less": "^6.0.0",
"resolve-url-loader": "^5.0.0",
"standard": "^17.1.0",
"style-loader": "^4.0.0",
"stylelint": "^15.10.1",
"stylelint-config-standard": "^34.0.0",
Expand All @@ -135,9 +133,6 @@
"npm run lint:js -- --fix",
"prettier --write --experimental-cli"
],
"./static/**/*.js": [
"npm run lint:templates -- --fix"
],
"./src/less/*.less": [
"npm run lint:style -- --fix",
"prettier --write --experimental-cli"
Expand Down
2 changes: 1 addition & 1 deletion static/electron-quick-start/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { app, BrowserWindow } = require('electron')
const path = require('node:path')

function createWindow () {
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
Expand Down
4 changes: 3 additions & 1 deletion static/show-me/autoupdater/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ app.whenReady().then(() => {
})

autoUpdater.on('update-available', () => {
console.log('The autoUpdater has found an update and is now downloading it!')
console.log(
'The autoUpdater has found an update and is now downloading it!'
)
})

autoUpdater.on('update-not-available', () => {
Expand Down
10 changes: 8 additions & 2 deletions static/show-me/cookies/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ app.whenReady().then(() => {

// Query all cookies associated with a specific url.
try {
const cookies = await session.defaultSession.cookies.get({ url: 'http://www.github.com' })
const cookies = await session.defaultSession.cookies.get({
url: 'http://www.github.com'
})
console.log(cookies)
} catch (error) {
console.error(error)
Expand All @@ -33,7 +35,11 @@ app.whenReady().then(() => {
// Set a cookie with the given cookie data;
// may overwrite equivalent cookies if they exist.
try {
const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
const cookie = {
url: 'http://www.github.com',
name: 'dummy_name',
value: 'dummy'
}
await session.defaultSession.cookies.set(cookie)
} catch (error) {
console.error(error)
Expand Down
16 changes: 9 additions & 7 deletions static/show-me/desktopcapturer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ app.whenReady().then(() => {

mainWindow.loadFile('index.html')
if (parseInt(process.versions.electron) >= 17) {
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
for (const source of sources) {
if (source.id.startsWith('screen')) {
mainWindow.webContents.send('SET_SOURCE', source.id)
return
desktopCapturer
.getSources({ types: ['window', 'screen'] })
.then(async (sources) => {
for (const source of sources) {
if (source.id.startsWith('screen')) {
mainWindow.webContents.send('SET_SOURCE', source.id)
return
}
}
}
})
})
}
})
30 changes: 16 additions & 14 deletions static/show-me/desktopcapturer/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ const { desktopCapturer, ipcRenderer } = require('electron/renderer')
// just grab video from a single window.
//

function startCapture () {
desktopCapturer.getSources({
types: ['window', 'screen']
}).then(async sources => {
for (let i = 0; i < sources.length; ++i) {
console.log(sources[i])
if (sources[i].id.startsWith('screen')) {
showStream(sources[i].id)
function startCapture() {
desktopCapturer
.getSources({
types: ['window', 'screen']
})
.then(async (sources) => {
for (let i = 0; i < sources.length; ++i) {
console.log(sources[i])
if (sources[i].id.startsWith('screen')) {
showStream(sources[i].id)
}
}
}
})
})
}

async function showStream (sourceId) {
async function showStream(sourceId) {
try {
const stream = await navigator.mediaDevices.getUserMedia({
audio: false,
Expand All @@ -39,13 +41,13 @@ async function showStream (sourceId) {
}
}

function handleStream (stream) {
function handleStream(stream) {
const video = document.querySelector('video')
video.srcObject = stream
video.onloadedmetadata = (e) => video.play()
video.onloadedmetadata = () => video.play()
}

function handleError (e) {
function handleError(e) {
console.log(e)
}

Expand Down
2 changes: 1 addition & 1 deletion static/show-me/menu/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ app.whenReady().then(() => {
submenu: [
{
label: 'I have a custom handler',
click () {
click() {
console.log('👋')
}
},
Expand Down
4 changes: 3 additions & 1 deletion static/show-me/nativeimage/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/show-me/notification/preload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function notifyMe () {
function notifyMe() {
const notification = new window.Notification('Hello World', {
body: 'How is your day?'
})
Expand Down
4 changes: 2 additions & 2 deletions static/show-me/powermonitor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ app.whenReady().then(() => {
})

powerMonitor.on('on-ac', () => {
console.log('We\'re on AC power')
console.log("We're on AC power")
})

powerMonitor.on('on-battery', () => {
console.log('We\'re on battery power')
console.log("We're on battery power")
})
})
12 changes: 7 additions & 5 deletions static/show-me/screen/preload.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const { ipcRenderer } = require('electron/renderer')

window.addEventListener('DOMContentLoaded', () => {
ipcRenderer
.invoke('get-displays')
.then((screens) => {
document.querySelector('pre').innerText = JSON.stringify(screens, undefined, 2)
})
ipcRenderer.invoke('get-displays').then((screens) => {
document.querySelector('pre').innerText = JSON.stringify(
screens,
undefined,
2
)
})
})
13 changes: 5 additions & 8 deletions static/show-me/shell/preload.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const { contextBridge, ipcRenderer } = require('electron/renderer')

contextBridge.exposeInMainWorld(
'electron',
{
openGitHub: () => ipcRenderer.send('open-github'),
openFolder: () => ipcRenderer.send('open-folder'),
beep: () => ipcRenderer.send('beep')
}
)
contextBridge.exposeInMainWorld('electron', {
openGitHub: () => ipcRenderer.send('open-github'),
openFolder: () => ipcRenderer.send('open-folder'),
beep: () => ipcRenderer.send('beep')
})
5 changes: 4 additions & 1 deletion static/show-me/systempreferences/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ app.whenReady().then(() => {

if (process.platform === 'darwin') {
// Let's get the recent places
const places = systemPreferences.getUserDefault('NSNavRecentPlaces', 'array')
const places = systemPreferences.getUserDefault(
'NSNavRecentPlaces',
'array'
)
console.log(places)
}

Expand Down
2 changes: 1 addition & 1 deletion static/show-me/touchbar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ app.whenReady().then(() => {
const spinReels = () => {
updateReels()

if ((Date.now() - startTime) >= spinLength) {
if (Date.now() - startTime >= spinLength) {
finishSpin()
} else {
// Slow down a bit on each spin
Expand Down
Loading
Loading