Upgraded dependencies (including using Electron 30) and using ES Modules

This commit is contained in:
Mohamed Mohamedin 2024-05-17 17:34:22 -04:00
parent d3206b8b17
commit 3f6b5d8fd6
4 changed files with 43 additions and 37 deletions

View File

@ -2,10 +2,15 @@
"name": "draw.io", "name": "draw.io",
"version": "24.4.0", "version": "24.4.0",
"description": "draw.io desktop", "description": "draw.io desktop",
"exports": "./src/main/electron.js",
"type": "module",
"main": "src/main/electron.js", "main": "src/main/electron.js",
"engines": {
"node": ">=20"
},
"scripts": { "scripts": {
"start": "electron .", "start": "electron .",
"sync": "node ./sync.js", "sync": "node ./sync.cjs",
"release-win": "electron-builder --config electron-builder-win.json --publish always", "release-win": "electron-builder --config electron-builder-win.json --publish always",
"release-win32": "electron-builder --config electron-builder-win32.json --publish always", "release-win32": "electron-builder --config electron-builder-win32.json --publish always",
"release-appx": "electron-builder --config electron-builder-appx.json --publish always", "release-appx": "electron-builder --config electron-builder-appx.json --publish always",
@ -29,22 +34,22 @@
}, },
"homepage": "https://github.com/jgraph/drawio", "homepage": "https://github.com/jgraph/drawio",
"dependencies": { "dependencies": {
"commander": "^11.1.0", "commander": "^12.0.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"crc": "^4.3.2", "crc": "^4.3.2",
"electron-context-menu": "^3.6.1", "electron-context-menu": "^4.0.0",
"electron-log": "^5.0.2", "electron-log": "^5.1.4",
"electron-progressbar": "^2.1.0", "electron-progressbar": "^2.2.1",
"electron-store": "^8.1.0", "electron-store": "^9.0.0",
"electron-updater": "^6.1.7", "electron-updater": "^6.1.8",
"pdf-lib": "^1.17.1" "pdf-lib": "^1.17.1"
}, },
"devDependencies": { "devDependencies": {
"@electron/fuses": "^1.7.0", "@electron/fuses": "^1.8.0",
"@electron/notarize": "^2.2.0", "@electron/notarize": "^2.3.2",
"dotenv": "^16.3.1", "dotenv": "^16.4.5",
"electron": "28.1.0", "electron": "30.0.6",
"electron-builder": "^24.9.1", "electron-builder": "^24.9.1",
"sumchecker": "^3.0.1" "sumchecker": "^3.0.1"
} }
} }

View File

@ -1,6 +1,4 @@
module.exports = { export function disableUpdate()
disableUpdate: function() {
{ return false;
return false;
}
} }

View File

@ -1,22 +1,23 @@
const fs = require('fs') import fs from 'fs';
const fsProm = require('fs/promises'); import { promises as fsProm } from 'fs';
const os = require('os'); import path from 'path';
const path = require('path') import url from 'url';
const url = require('url') import {Menu as menu, shell, dialog, session, screen,
const {Menu: menu, shell, dialog, session, screen, clipboard, nativeImage, ipcMain, app, BrowserWindow} from 'electron';
clipboard, nativeImage, ipcMain, app, BrowserWindow} = require('electron') import crc from 'crc';
const crc = require('crc'); import zlib from 'zlib';
const zlib = require('zlib'); import log from'electron-log';
const log = require('electron-log') import { program } from 'commander';
const program = require('commander') import elecUpPkg from 'electron-updater';
const {autoUpdater} = require("electron-updater") const {autoUpdater} = elecUpPkg;
const PDFDocument = require('pdf-lib').PDFDocument; import {PDFDocument} from 'pdf-lib';
const Store = require('electron-store'); import Store from 'electron-store';
const store = new Store(); const store = new Store();
const ProgressBar = require('electron-progressbar'); import ProgressBar from 'electron-progressbar';
const contextMenu = require('electron-context-menu'); import contextMenu from 'electron-context-menu';
const spawn = require('child_process').spawn; import {spawn} from 'child_process';
const disableUpdate = require('./disableUpdate').disableUpdate() || import {disableUpdate as disUpPkg} from './disableUpdate.js';
const disableUpdate = disUpPkg() ||
process.env.DRAWIO_DISABLE_UPDATE === 'true' || process.env.DRAWIO_DISABLE_UPDATE === 'true' ||
fs.existsSync('/.flatpak-info'); //This file indicates running in flatpak sandbox fs.existsSync('/.flatpak-info'); //This file indicates running in flatpak sandbox
autoUpdater.logger = log autoUpdater.logger = log
@ -24,6 +25,8 @@ autoUpdater.logger.transports.file.level = 'error'
autoUpdater.logger.transports.console.level = 'error' autoUpdater.logger.transports.console.level = 'error'
autoUpdater.autoDownload = false autoUpdater.autoDownload = false
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
//Command option to disable hardware acceleration //Command option to disable hardware acceleration
if (process.argv.indexOf('--disable-acceleration') !== -1) if (process.argv.indexOf('--disable-acceleration') !== -1)
{ {
@ -336,7 +339,7 @@ function isPluginsEnabled()
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', e => app.whenReady().then(() =>
{ {
// Enforce our CSP on all contents // Enforce our CSP on all contents
session.defaultSession.webRequest.onHeadersReceived((details, callback) => session.defaultSession.webRequest.onHeadersReceived((details, callback) =>

View File

@ -13,4 +13,4 @@ pj.version = ver
fs.writeFileSync(appjsonpath, JSON.stringify(pj, null, 2), 'utf8') fs.writeFileSync(appjsonpath, JSON.stringify(pj, null, 2), 'utf8')
//Enable/disable updates //Enable/disable updates
fs.writeFileSync(disableUpdatePath, 'module.exports = { disableUpdate: function() { return ' + (process.argv[2] == 'disableUpdate'? 'true' : 'false') + ';}}', 'utf8'); fs.writeFileSync(disableUpdatePath, 'export function disableUpdate() { return ' + (process.argv[2] == 'disableUpdate'? 'true' : 'false') + ';}', 'utf8');