diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..43f8682 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +tools +biome.json +jest.config.js +test +config +__mocks__ +.github diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b36e17..8c4a509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 3.2.0 (2024-08-04) + +- Fix issues around starting multiple downloads at the same time. +- No longer need to use `await` before a download call when multiple downloads are started at the same time. + # 3.1.1 (2024-07-31) - Added more debug logging diff --git a/README.md b/README.md index dfde400..2370f69 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,6 @@ import { ElectronDownloadManager } from 'electron-dl-manager'; const manager = new ElectronDownloadManager(); // Start a download -// You *must* call manager.download() with await or -// you may get unexpected behavior const id = await manager.download({ window: browserWindowInstance, url: 'https://example.com/file.zip', @@ -188,8 +186,6 @@ interface DownloadManagerConstructorParams { Starts a file download. Returns the `id` of the download. -**You must call `download()` with `await` or you may get unexpected behavior.** - ```typescript download(params: DownloadParams): Promise ``` diff --git a/package-lock.json b/package-lock.json index 57eea8c..f801b41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "electron-dl-manager", - "version": "3.1.0", + "version": "3.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "electron-dl-manager", - "version": "3.1.0", + "version": "3.1.1", "license": "MIT", "dependencies": { "ext-name": "^5.0.0", diff --git a/package.json b/package.json index 9a7e84f..e80f41f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron-dl-manager", - "version": "3.1.1", + "version": "3.2.0", "description": "A library for implementing file downloads in Electron with 'save as' dialog and id support.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/src/ElectronDownloadManager.ts b/src/ElectronDownloadManager.ts index 212ea63..d019327 100644 --- a/src/ElectronDownloadManager.ts +++ b/src/ElectronDownloadManager.ts @@ -9,12 +9,34 @@ import type { } from "./types"; import { truncateUrl } from "./utils"; +/** + * This is used to solve an issue where multiple downloads are started at the same time. + * For example, Promise.all([download1, download2, ...]) will start both downloads at the same + * time. This is problematic because the will-download event is not guaranteed to fire in the + * order that the downloads were started. + * + * So we use this to make sure that will-download fires in the order that the downloads were + * started by executing the downloads in a sequential fashion. + * + * For more information see: + * https://github.com/theogravity/electron-dl-manager/issues/11 + */ +class DownloadQueue { + private promise = Promise.resolve() as unknown as Promise; + + add(task: () => Promise): Promise { + this.promise = this.promise.then(() => task()); + return this.promise; + } +} + /** * Enables handling downloads in Electron. */ export class ElectronDownloadManager implements IElectronDownloadManager { protected downloadData: Record; protected logger: DebugLoggerFn; + private downloadQueue = new DownloadQueue(); constructor(params: DownloadManagerConstructorParams = {}) { this.downloadData = {}; @@ -88,30 +110,33 @@ export class ElectronDownloadManager implements IElectronDownloadManager { * Returns the id of the download. */ async download(params: DownloadConfig): Promise { - return new Promise((resolve, reject) => { - try { - if (params.saveAsFilename && params.saveDialogOptions) { - return reject(Error("You cannot define both saveAsFilename and saveDialogOptions to start a download")); - } - - const downloadInitiator = new DownloadInitiator({ - debugLogger: this.logger, - onCleanup: (data) => { - this.cleanup(data); - }, - onDownloadInit: (data) => { - this.downloadData[data.id] = data; - resolve(data.id); - }, - }); - - this.log(`[${downloadInitiator.getDownloadId()}] Registering download for url: ${truncateUrl(params.url)}`); - params.window.webContents.session.once("will-download", downloadInitiator.generateOnWillDownload(params)); - params.window.webContents.downloadURL(params.url, params.downloadURLOptions); - } catch (e) { - reject(e); - } - }); + return this.downloadQueue.add( + () => + new Promise((resolve, reject) => { + try { + if (params.saveAsFilename && params.saveDialogOptions) { + return reject(Error("You cannot define both saveAsFilename and saveDialogOptions to start a download")); + } + + const downloadInitiator = new DownloadInitiator({ + debugLogger: this.logger, + onCleanup: (data) => { + this.cleanup(data); + }, + onDownloadInit: (data) => { + this.downloadData[data.id] = data; + resolve(data.id); + }, + }); + + this.log(`[${downloadInitiator.getDownloadId()}] Registering download for url: ${truncateUrl(params.url)}`); + params.window.webContents.session.once("will-download", downloadInitiator.generateOnWillDownload(params)); + params.window.webContents.downloadURL(params.url, params.downloadURLOptions); + } catch (e) { + reject(e); + } + }), + ); } protected cleanup(data: DownloadData) { @@ -161,3 +186,16 @@ export class ElectronDownloadManager implements IElectronDownloadManager { dbg.detach(); } } + +function waitTicks(n: number): Promise { + return new Promise((resolve) => { + function tick(count: number) { + if (count <= 0) { + resolve(); + } else { + process.nextTick(() => tick(count - 1)); + } + } + tick(n); + }); +} diff --git a/test-app/.editorconfig b/test-app/.editorconfig deleted file mode 100644 index cf640d5..0000000 --- a/test-app/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true \ No newline at end of file diff --git a/test-app/.eslintignore b/test-app/.eslintignore deleted file mode 100644 index a6f34fe..0000000 --- a/test-app/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -dist -out -.gitignore diff --git a/test-app/.eslintrc.js b/test-app/.eslintrc.js deleted file mode 100644 index 510e905..0000000 --- a/test-app/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - extends: [ - 'eslint:recommended', - '@electron-toolkit/eslint-config-ts/recommended', - '@electron-toolkit/eslint-config-prettier' - ] -} diff --git a/test-app/.gitignore b/test-app/.gitignore deleted file mode 100644 index 42bd71b..0000000 --- a/test-app/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -dist -out -.DS_Store -*.log* diff --git a/test-app/.prettierignore b/test-app/.prettierignore deleted file mode 100644 index 9c6b791..0000000 --- a/test-app/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -out -dist -pnpm-lock.yaml -LICENSE.md -tsconfig.json -tsconfig.*.json diff --git a/test-app/.prettierrc.yaml b/test-app/.prettierrc.yaml deleted file mode 100644 index 35893b3..0000000 --- a/test-app/.prettierrc.yaml +++ /dev/null @@ -1,4 +0,0 @@ -singleQuote: true -semi: false -printWidth: 100 -trailingComma: none diff --git a/test-app/.vscode/extensions.json b/test-app/.vscode/extensions.json deleted file mode 100644 index 940260d..0000000 --- a/test-app/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["dbaeumer.vscode-eslint"] -} diff --git a/test-app/.vscode/launch.json b/test-app/.vscode/launch.json deleted file mode 100644 index 0b6b9a6..0000000 --- a/test-app/.vscode/launch.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Debug Main Process", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite", - "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd" - }, - "runtimeArgs": ["--sourcemap"], - "env": { - "REMOTE_DEBUGGING_PORT": "9222" - } - }, - { - "name": "Debug Renderer Process", - "port": 9222, - "request": "attach", - "type": "chrome", - "webRoot": "${workspaceFolder}/src/renderer", - "timeout": 60000, - "presentation": { - "hidden": true - } - } - ], - "compounds": [ - { - "name": "Debug All", - "configurations": ["Debug Main Process", "Debug Renderer Process"], - "presentation": { - "order": 1 - } - } - ] -} diff --git a/test-app/.vscode/settings.json b/test-app/.vscode/settings.json deleted file mode 100644 index 4c05394..0000000 --- a/test-app/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - } -} diff --git a/test-app/README.md b/test-app/README.md deleted file mode 100644 index 22bb96b..0000000 --- a/test-app/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# test-app - -A minimal Electron application with TypeScript - -## Recommended IDE Setup - -- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - -## Project Setup - -### Install - -```bash -$ yarn -``` - -### Development - -```bash -$ yarn dev -``` - -### Build - -```bash -# For windows -$ yarn build:win - -# For macOS -$ yarn build:mac - -# For Linux -$ yarn build:linux -``` diff --git a/test-app/build/entitlements.mac.plist b/test-app/build/entitlements.mac.plist deleted file mode 100644 index 38c887b..0000000 --- a/test-app/build/entitlements.mac.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - com.apple.security.cs.allow-jit - - com.apple.security.cs.allow-unsigned-executable-memory - - com.apple.security.cs.allow-dyld-environment-variables - - - diff --git a/test-app/build/icon.icns b/test-app/build/icon.icns deleted file mode 100644 index 28644aa..0000000 Binary files a/test-app/build/icon.icns and /dev/null differ diff --git a/test-app/build/icon.ico b/test-app/build/icon.ico deleted file mode 100644 index 72c391e..0000000 Binary files a/test-app/build/icon.ico and /dev/null differ diff --git a/test-app/build/icon.png b/test-app/build/icon.png deleted file mode 100644 index cf9e8b2..0000000 Binary files a/test-app/build/icon.png and /dev/null differ diff --git a/test-app/electron-builder.yml b/test-app/electron-builder.yml deleted file mode 100644 index ffe9c68..0000000 --- a/test-app/electron-builder.yml +++ /dev/null @@ -1,43 +0,0 @@ -appId: com.electron.app -productName: test-app -directories: - buildResources: build -files: - - '!**/.vscode/*' - - '!src/*' - - '!electron.vite.config.{js,ts,mjs,cjs}' - - '!{.eslintignore,.eslintrc.js,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}' - - '!{.env,.env.*,.npmrc,pnpm-lock.yaml}' - - '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}' -asarUnpack: - - resources/** -win: - executableName: test-app -nsis: - artifactName: ${name}-${version}-setup.${ext} - shortcutName: ${productName} - uninstallDisplayName: ${productName} - createDesktopShortcut: always -mac: - entitlementsInherit: build/entitlements.mac.plist - extendInfo: - - NSCameraUsageDescription: Application requests access to the device's camera. - - NSMicrophoneUsageDescription: Application requests access to the device's microphone. - - NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder. - - NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. - notarize: false -dmg: - artifactName: ${name}-${version}.${ext} -linux: - target: - - AppImage - - snap - - deb - maintainer: electronjs.org - category: Utility -appImage: - artifactName: ${name}-${version}.${ext} -npmRebuild: false -publish: - provider: generic - url: https://example.com/auto-updates diff --git a/test-app/electron.vite.config.ts b/test-app/electron.vite.config.ts deleted file mode 100644 index 3acc2e8..0000000 --- a/test-app/electron.vite.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig, externalizeDepsPlugin } from 'electron-vite' - -export default defineConfig({ - main: { - plugins: [externalizeDepsPlugin()] - }, - preload: { - plugins: [externalizeDepsPlugin()] - }, - renderer: {} -}) diff --git a/test-app/package.json b/test-app/package.json deleted file mode 100644 index 2e5e21a..0000000 --- a/test-app/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "test-app", - "version": "1.0.0", - "description": "A minimal Electron application with TypeScript", - "main": "./out/main/index.js", - "author": "example.com", - "homepage": "https://electron-vite.org", - "scripts": { - "format": "prettier --write .", - "lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", - "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", - "typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false", - "typecheck": "npm run typecheck:node && npm run typecheck:web", - "start": "electron-vite preview", - "dev": "electron-vite dev", - "build": "npm run typecheck && electron-vite build", - "postinstall": "electron-builder install-app-deps", - "build:unpack": "npm run build && electron-builder --dir", - "build:win": "npm run build && electron-builder --win", - "build:mac": "npm run build && electron-builder --mac", - "build:linux": "npm run build && electron-builder --linux" - }, - "dependencies": { - "@electron-toolkit/preload": "^3.0.0", - "@electron-toolkit/utils": "^3.0.0", - "electron-dl-manager": "^2.4.1" - }, - "devDependencies": { - "@electron-toolkit/eslint-config-prettier": "^2.0.0", - "@electron-toolkit/eslint-config-ts": "^1.0.1", - "@electron-toolkit/tsconfig": "^1.0.1", - "@types/node": "^18.19.9", - "electron": "^28.2.0", - "electron-builder": "^24.9.1", - "electron-vite": "^2.0.0", - "eslint": "^8.56.0", - "prettier": "^3.2.4", - "typescript": "^5.3.3", - "vite": "^5.0.12" - } -} diff --git a/test-app/resources/icon.png b/test-app/resources/icon.png deleted file mode 100644 index cf9e8b2..0000000 Binary files a/test-app/resources/icon.png and /dev/null differ diff --git a/test-app/src/main/index.ts b/test-app/src/main/index.ts deleted file mode 100644 index 2e2f90a..0000000 --- a/test-app/src/main/index.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { app, shell, BrowserWindow, ipcMain } from 'electron' -import { join } from 'path' -import { electronApp, optimizer, is } from '@electron-toolkit/utils' -import icon from '../../resources/icon.png?asset' -import { ElectronDownloadManager } from '../../../src' - -function createWindow(): void { - // Create the browser window. - const mainWindow = new BrowserWindow({ - width: 900, - height: 670, - show: false, - autoHideMenuBar: true, - ...(process.platform === 'linux' ? { icon } : {}), - webPreferences: { - preload: join(__dirname, '../preload/index.js'), - sandbox: false - } - }) - - mainWindow.on('ready-to-show', () => { - mainWindow.show() - }) - - mainWindow.webContents.setWindowOpenHandler((details) => { - shell.openExternal(details.url) - return { action: 'deny' } - }) - - // HMR for renderer base on electron-vite cli. - // Load the remote URL for development or the local html file for production. - if (is.dev && process.env['ELECTRON_RENDERER_URL']) { - mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) - } else { - mainWindow.loadFile(join(__dirname, '../renderer/index.html')) - } - - const manager = new ElectronDownloadManager({ - debugLogger: (message): void => { - console.log(message) - } - }) - - manager - .download({ - window: mainWindow, - url: 'https://testfile.org/file-1GB', - callbacks: {} - }) - .then((downloadId) => { - manager.pauseDownload(downloadId) - }) -} - -// This method will be called when Electron has finished -// initialization and is ready to create browser windows. -// Some APIs can only be used after this event occurs. -app.whenReady().then(() => { - // Set app user model id for windows - electronApp.setAppUserModelId('com.electron') - - // Default open or close DevTools by F12 in development - // and ignore CommandOrControl + R in production. - // see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils - app.on('browser-window-created', (_, window) => { - optimizer.watchWindowShortcuts(window) - }) - - // IPC test - ipcMain.on('ping', () => console.log('pong')) - - createWindow() - - app.on('activate', function () { - // On macOS it's common to re-create a window in the app when the - // dock icon is clicked and there are no other windows open. - if (BrowserWindow.getAllWindows().length === 0) createWindow() - }) -}) - -// Quit when all windows are closed, except on macOS. There, it's common -// for applications and their menu bar to stay active until the user quits -// explicitly with Cmd + Q. -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit() - } -}) - -// In this file you can include the rest of your app"s specific main process -// code. You can also put them in separate files and require them here. diff --git a/test-app/src/preload/index.d.ts b/test-app/src/preload/index.d.ts deleted file mode 100644 index a153669..0000000 --- a/test-app/src/preload/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ElectronAPI } from '@electron-toolkit/preload' - -declare global { - interface Window { - electron: ElectronAPI - api: unknown - } -} diff --git a/test-app/src/preload/index.ts b/test-app/src/preload/index.ts deleted file mode 100644 index 2d18524..0000000 --- a/test-app/src/preload/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { contextBridge } from 'electron' -import { electronAPI } from '@electron-toolkit/preload' - -// Custom APIs for renderer -const api = {} - -// Use `contextBridge` APIs to expose Electron APIs to -// renderer only if context isolation is enabled, otherwise -// just add to the DOM global. -if (process.contextIsolated) { - try { - contextBridge.exposeInMainWorld('electron', electronAPI) - contextBridge.exposeInMainWorld('api', api) - } catch (error) { - console.error(error) - } -} else { - // @ts-ignore (define in dts) - window.electron = electronAPI - // @ts-ignore (define in dts) - window.api = api -} diff --git a/test-app/src/renderer/assets/base.css b/test-app/src/renderer/assets/base.css deleted file mode 100644 index 5ed6406..0000000 --- a/test-app/src/renderer/assets/base.css +++ /dev/null @@ -1,67 +0,0 @@ -:root { - --ev-c-white: #ffffff; - --ev-c-white-soft: #f8f8f8; - --ev-c-white-mute: #f2f2f2; - - --ev-c-black: #1b1b1f; - --ev-c-black-soft: #222222; - --ev-c-black-mute: #282828; - - --ev-c-gray-1: #515c67; - --ev-c-gray-2: #414853; - --ev-c-gray-3: #32363f; - - --ev-c-text-1: rgba(255, 255, 245, 0.86); - --ev-c-text-2: rgba(235, 235, 245, 0.6); - --ev-c-text-3: rgba(235, 235, 245, 0.38); - - --ev-button-alt-border: transparent; - --ev-button-alt-text: var(--ev-c-text-1); - --ev-button-alt-bg: var(--ev-c-gray-3); - --ev-button-alt-hover-border: transparent; - --ev-button-alt-hover-text: var(--ev-c-text-1); - --ev-button-alt-hover-bg: var(--ev-c-gray-2); -} - -:root { - --color-background: var(--ev-c-black); - --color-background-soft: var(--ev-c-black-soft); - --color-background-mute: var(--ev-c-black-mute); - - --color-text: var(--ev-c-text-1); -} - -*, -*::before, -*::after { - box-sizing: border-box; - margin: 0; - font-weight: normal; -} - -ul { - list-style: none; -} - -body { - min-height: 100vh; - color: var(--color-text); - background: var(--color-background); - line-height: 1.6; - font-family: - Inter, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - Roboto, - Oxygen, - Ubuntu, - Cantarell, - 'Fira Sans', - 'Droid Sans', - 'Helvetica Neue', - sans-serif; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} diff --git a/test-app/src/renderer/assets/electron.svg b/test-app/src/renderer/assets/electron.svg deleted file mode 100644 index 45ef09c..0000000 --- a/test-app/src/renderer/assets/electron.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/test-app/src/renderer/assets/main.css b/test-app/src/renderer/assets/main.css deleted file mode 100644 index 463bc6b..0000000 --- a/test-app/src/renderer/assets/main.css +++ /dev/null @@ -1,163 +0,0 @@ -@import './base.css'; - -body { - display: flex; - align-items: center; - justify-content: center; - overflow: hidden; - background-image: url('./wavy-lines.svg'); - background-size: cover; - user-select: none; -} - -code { - font-weight: 600; - padding: 3px 5px; - border-radius: 2px; - background-color: var(--color-background-mute); - font-family: - ui-monospace, - SFMono-Regular, - SF Mono, - Menlo, - Consolas, - Liberation Mono, - monospace; - font-size: 85%; -} - -#app { - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - margin-bottom: 80px; -} - -.logo { - margin-bottom: 20px; - -webkit-user-drag: none; - height: 128px; - width: 128px; - will-change: filter; - transition: filter 300ms; -} - -.logo:hover { - filter: drop-shadow(0 0 1.2em #6988e6aa); -} - -.creator { - font-size: 14px; - line-height: 16px; - color: var(--ev-c-text-2); - font-weight: 600; - margin-bottom: 10px; -} - -.text { - font-size: 28px; - color: var(--ev-c-text-1); - font-weight: 700; - line-height: 32px; - text-align: center; - margin: 0 10px; - padding: 16px 0; -} - -.tip { - font-size: 16px; - line-height: 24px; - color: var(--ev-c-text-2); - font-weight: 600; -} - -.ts { - background: -webkit-linear-gradient(315deg, #3178c6 45%, #f0dc4e); - background-clip: text; - -webkit-background-clip: text; - -webkit-text-fill-color: transparent; - font-weight: 700; -} - -.actions { - display: flex; - padding-top: 32px; - margin: -6px; - flex-wrap: wrap; - justify-content: flex-start; -} - -.action { - flex-shrink: 0; - padding: 6px; -} - -.action a { - cursor: pointer; - text-decoration: none; - display: inline-block; - border: 1px solid transparent; - text-align: center; - font-weight: 600; - white-space: nowrap; - border-radius: 20px; - padding: 0 20px; - line-height: 38px; - font-size: 14px; - border-color: var(--ev-button-alt-border); - color: var(--ev-button-alt-text); - background-color: var(--ev-button-alt-bg); -} - -.action a:hover { - border-color: var(--ev-button-alt-hover-border); - color: var(--ev-button-alt-hover-text); - background-color: var(--ev-button-alt-hover-bg); -} - -.versions { - position: absolute; - bottom: 30px; - margin: 0 auto; - padding: 15px 0; - font-family: 'Menlo', 'Lucida Console', monospace; - display: inline-flex; - overflow: hidden; - align-items: center; - border-radius: 22px; - background-color: #202127; - backdrop-filter: blur(24px); -} - -.versions li { - display: block; - float: left; - border-right: 1px solid var(--ev-c-gray-1); - padding: 0 20px; - font-size: 14px; - line-height: 14px; - opacity: 0.8; - &:last-child { - border: none; - } -} - -@media (max-width: 720px) { - .text { - font-size: 20px; - } -} - -@media (max-width: 620px) { - .versions { - display: none; - } -} - -@media (max-width: 350px) { - .tip, - .actions { - display: none; - } -} diff --git a/test-app/src/renderer/assets/wavy-lines.svg b/test-app/src/renderer/assets/wavy-lines.svg deleted file mode 100644 index d08c611..0000000 --- a/test-app/src/renderer/assets/wavy-lines.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test-app/src/renderer/index.html b/test-app/src/renderer/index.html deleted file mode 100644 index 43a9e80..0000000 --- a/test-app/src/renderer/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Electron - - - - - - - -
- -
Powered by electron-vite
-
- Build an Electron app with - TypeScript -
-

Please try pressing F12 to open the devTool

-
- -
- Send IPC -
-
- -
    -
  • -
  • -
  • -
-
- - - - diff --git a/test-app/src/renderer/src/renderer.ts b/test-app/src/renderer/src/renderer.ts deleted file mode 100644 index 228d848..0000000 --- a/test-app/src/renderer/src/renderer.ts +++ /dev/null @@ -1,26 +0,0 @@ -function init(): void { - window.addEventListener('DOMContentLoaded', () => { - doAThing() - }) -} - -function doAThing(): void { - const versions = window.electron.process.versions - replaceText('.electron-version', `Electron v${versions.electron}`) - replaceText('.chrome-version', `Chromium v${versions.chrome}`) - replaceText('.node-version', `Node v${versions.node}`) - - const ipcHandlerBtn = document.getElementById('ipcHandler') - ipcHandlerBtn?.addEventListener('click', () => { - window.electron.ipcRenderer.send('ping') - }) -} - -function replaceText(selector: string, text: string): void { - const element = document.querySelector(selector) - if (element) { - element.innerText = text - } -} - -init() diff --git a/test-app/tsconfig.json b/test-app/tsconfig.json deleted file mode 100644 index 31bac6e..0000000 --- a/test-app/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "files": [], - "references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.web.json" }] -} diff --git a/test-app/tsconfig.node.json b/test-app/tsconfig.node.json deleted file mode 100644 index bf49dc7..0000000 --- a/test-app/tsconfig.node.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "@electron-toolkit/tsconfig/tsconfig.node.json", - "include": ["electron.vite.config.*", "src/main/**/*", "src/preload/**/*", "../src/**/*"], - "compilerOptions": { - "composite": true, - "types": ["electron-vite/node"] - } -} diff --git a/test-app/tsconfig.web.json b/test-app/tsconfig.web.json deleted file mode 100644 index 9f8ebb6..0000000 --- a/test-app/tsconfig.web.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@electron-toolkit/tsconfig/tsconfig.web.json", - "include": ["src/renderer/**/*.ts", "src/preload/*.d.ts"], - "compilerOptions": { - "composite": true - } -}