Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wpilibutility: update to electron 28 #679

Closed
wants to merge 7 commits into from
Closed
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
7 changes: 3 additions & 4 deletions vscode-wpilib/src/riolog/shared/sharedscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,9 @@ window.addEventListener('resize', () => {
checkResize();
});

// tslint:disable-next-line:no-any
function handleFileSelect(evt: any) {
// tslint:disable-next-line:no-unsafe-any
const files: FileList = evt.target.files; // filelist
function handleFileSelect(evt: Event) {
// tslint:disable-next-line:no-non-null-assertion
const files = (evt.target as HTMLInputElement).files!;
const firstFile = files[0];
const reader = new FileReader();
reader.onload = (loaded: Event) => {
Expand Down
3 changes: 1 addition & 2 deletions vscode-wpilib/src/shared/vendorexamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ interface IJsonExample {
extravendordeps?: string[];
}

// tslint:disable-next-line:no-any
function isJsonExample(arg: any): arg is IJsonExample {
function isJsonExample(arg: unknown): arg is IJsonExample {
const jsonDep = arg as IJsonExample;

return jsonDep.name !== undefined && jsonDep.description !== undefined
Expand Down
3 changes: 1 addition & 2 deletions vscode-wpilib/src/shared/vendorlibrariesbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export interface IJsonDependency {
fileName: string;
}

// tslint:disable-next-line:no-any
export function isJsonDependency(arg: any): arg is IJsonDependency {
export function isJsonDependency(arg: unknown): arg is IJsonDependency {
const jsonDep = arg as IJsonDependency;

return jsonDep.jsonUrl !== undefined && jsonDep.name !== undefined
Expand Down
5 changes: 5 additions & 0 deletions wpilib-utility-standalone/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.eslintrc.js
out
release
build
dist
12 changes: 12 additions & 0 deletions wpilib-utility-standalone/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
rules: {
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-case-declarations": "off"
}
};
4,025 changes: 2,584 additions & 1,441 deletions wpilib-utility-standalone/package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions wpilib-utility-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"compile": "tsc -p ./",
"clean": "rmdir-cli out",
"lint": "tslint -c tslint.json -p tsconfig.json",
"lint": "eslint .",
"start": "npm run compile && electron ./out/main.js",
"watch": "tsc -watch -p ./",
"packageWindows": "electron-packager . wpilibutility --platform=win32 --overwrite --out ./build",
Expand All @@ -15,26 +15,27 @@
},
"main": "out/main.js",
"repository": "https://github.com/wpilibsuite/vscode-wpilib",
"keywords": [

],
"keywords": [],
"author": "WPILib Suite",
"license": "BSD-3-Clause",
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mkdirp": "^1.0.2",
"@types/ncp": "^2.0.5",
"@types/node": "^10.2.0",
"@types/node": "^20.10.5",
"@types/node-fetch": "^2.6.4",
"@types/temp": "^0.8.34",
"@types/triple-beam": "^1.3.1",
"electron": "11.5.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"electron": "^28.1.0",
"electron-packager": "^17.1.2",
"eslint": "^8.56.0",
"rmdir-cli": "^2.0.6",
"tslint": "^6.1.3",
"typescript": "^3.9.10"
"typescript": "^5.3.3"
},
"dependencies": {
"@electron/remote": "^2.1.1",
"glob": "^7.2.3",
"java-properties": "^1.0.2",
"jsonc-parser": "^2.3.1",
Expand All @@ -46,4 +47,4 @@
"winston": "3.3.3",
"wpilib-riolog": "^0.2.0"
}
}
}
12 changes: 3 additions & 9 deletions wpilib-utility-standalone/src/generatorscript.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as electron from 'electron';
import { app, dialog, getCurrentWindow } from '@electron/remote';
import * as fs from 'fs';
import * as path from 'path';
import { generateCopyCpp, generateCopyJava } from './shared/generator';

const remote = electron.remote;
const dialog = remote.dialog;
const app = remote.app;
const shell = electron.shell;
const basepath = app.getAppPath();

Expand Down Expand Up @@ -56,11 +54,7 @@ window.addEventListener('load', async () => {
];

for (const languageDetails of languages) {
let language;
let templatesEventHandler;
let examplesEventHandler;

[language, templatesEventHandler, examplesEventHandler] = languageDetails;
const [language, templatesEventHandler, examplesEventHandler] = languageDetails;

const languageLowerCase = language.toLocaleLowerCase();

Expand Down Expand Up @@ -186,7 +180,7 @@ function displayItems(toDisplay: IDisplayJSON[], rootFolder: string, java: boole

document.addEventListener('keydown', (e) => {
if (e.key === '{') {
remote.getCurrentWindow().webContents.toggleDevTools();
getCurrentWindow().webContents.toggleDevTools();
} else if (e.key === '}') {
location.reload();
}
Expand Down
10 changes: 2 additions & 8 deletions wpilib-utility-standalone/src/locale.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// tslint:disable:no-any

console.warn('[Locale] Not implemented!');

function isString(value: any): value is string {
return toString.call(value) === '[object String]';
}

export function localize(_domain: string, message: string | string[], ..._args: any[]) {
if (isString(message)) {
export function localize(_domain: string, message: string | string[], ..._args: unknown[]) {
if (typeof message === "string") {
return message;
} else if (message.length === 2) {
return message[1];
Expand Down
24 changes: 8 additions & 16 deletions wpilib-utility-standalone/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import { MESSAGE } from 'triple-beam';
import * as winston from 'winston';

export interface ILogger {
// tslint:disable-next-line:no-any
error(message: string, ...meta: any[]): void;
// tslint:disable-next-line:no-any
warn(message: string, ...meta: any[]): void;
// tslint:disable-next-line:no-any
info(message: string, ...meta: any[]): void;
// tslint:disable-next-line:no-any
log(message: string, ...meta: any[]): void;
error(message: string, ...meta: unknown[]): void;
warn(message: string, ...meta: unknown[]): void;
info(message: string, ...meta: unknown[]): void;
log(message: string, ...meta: unknown[]): void;
}

const myFormat = winston.format.printf((info) => {
Expand Down Expand Up @@ -54,20 +50,16 @@ export function setLoggerDirectory(dirname: string) {
}

class LoggerImpl implements ILogger {
// tslint:disable-next-line:no-any
public error(message: string, ...meta: any[]): void {
public error(message: string, ...meta: unknown[]): void {
winstonLogger.log('error', message, meta);
}
// tslint:disable-next-line:no-any
public warn(message: string, ...meta: any[]): void {
public warn(message: string, ...meta: unknown[]): void {
winstonLogger.log('warn', message, meta);
}
// tslint:disable-next-line:no-any
public info(message: string, ...meta: any[]): void {
public info(message: string, ...meta: unknown[]): void {
winstonLogger.log('info', message, meta);
}
// tslint:disable-next-line:no-any
public log(message: string, ...meta: any[]): void {
public log(message: string, ...meta: unknown[]): void {
winstonLogger.log('verbose', message, meta);
}
}
Expand Down
5 changes: 4 additions & 1 deletion wpilib-utility-standalone/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { app, BrowserWindow } from 'electron';
// import * as path from 'path';
// import * as url from 'url';
import { initialize, enable } from '@electron/remote/main';
initialize();

let mainWindow: Electron.BrowserWindow | undefined;

Expand All @@ -11,11 +13,12 @@ async function createWindow() {
height: 250,
title: 'WPILib Utility',
webPreferences: {
enableRemoteModule: true,
contextIsolation: false,
nodeIntegration: true,
},
width: 350,
});
enable(mainWindow.webContents);

await mainWindow.loadFile('index.html');

Expand Down
12 changes: 5 additions & 7 deletions wpilib-utility-standalone/src/mainscript.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

import * as electron from 'electron';
const remote = electron.remote;
import { getCurrentWindow } from '@electron/remote';

document.addEventListener('keydown', (e) => {
if (e.key === '{') {
remote.getCurrentWindow().webContents.openDevTools();
getCurrentWindow().webContents.openDevTools();
} else if (e.key === '}') {
location.reload();
}
Expand All @@ -20,7 +18,7 @@ window.addEventListener('load', () => {
const rioLogButton = document.createElement('button');
rioLogButton.appendChild(document.createTextNode('Start RioLog'));
rioLogButton.addEventListener('click', async () => {
const bWindow = remote.getCurrentWindow();
const bWindow = getCurrentWindow();

bWindow.setSize(800, 600);
bWindow.setTitle('RioLog');
Expand All @@ -36,7 +34,7 @@ window.addEventListener('load', () => {
const generatorButton = document.createElement('button');
generatorButton.appendChild(document.createTextNode('Start New Project Generator'));
generatorButton.addEventListener('click', async () => {
const bWindow = remote.getCurrentWindow();
const bWindow = getCurrentWindow();

bWindow.setSize(800, 600);
bWindow.setTitle('New Project Generator');
Expand All @@ -50,7 +48,7 @@ window.addEventListener('load', () => {
const vendorDepsButton = document.createElement('button');
vendorDepsButton.appendChild(document.createTextNode('Start Vendor Deps Manager'));
vendorDepsButton.addEventListener('click', async () => {
const bWindow = remote.getCurrentWindow();
const bWindow = getCurrentWindow();

bWindow.setSize(800, 600);
bWindow.setTitle('Vendor Deps Manager');
Expand Down
10 changes: 3 additions & 7 deletions wpilib-utility-standalone/src/projectcreator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as electron from 'electron';
import { app, dialog, getCurrentWindow } from '@electron/remote';
import * as path from 'path';
import { Examples } from './shared/examples';
import { ExampleTemplateAPI } from './shared/exampletemplateapi';
Expand All @@ -13,16 +13,15 @@ import { promptForProjectOpen } from './utilities';
import { validateProject, validateTeamNumber } from './validators';
import * as vscode from './vscodeshim';

const dialog = electron.remote.dialog;
const bWindow = electron.remote.getCurrentWindow();
const bWindow = getCurrentWindow();

let exampleTemplateApi: ExampleTemplateAPI;

export async function projectSelectButtonClick(): Promise<void> {
(document.activeElement as HTMLElement).blur();
const paths = await dialog.showOpenDialog(bWindow, {
buttonLabel: 'Select Folder',
defaultPath: electron.remote.app.getPath('documents'),
defaultPath: app.getPath('documents'),
message: 'Select a folder to put the project in',
properties: [
'openDirectory',
Expand Down Expand Up @@ -129,9 +128,6 @@ async function handleProjectGenerate(template: boolean, language: string, base:
await promptForProjectOpen(vscode.Uri.file(toFolder));
}

const remote = electron.remote;
// const dialog = remote.dialog;
const app = remote.app;
// const shell = electron.shell;
const basepath = app.getAppPath();

Expand Down
4 changes: 1 addition & 3 deletions wpilib-utility-standalone/src/riolog/electronimpl.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';
import * as electron from 'electron';
import { dialog } from '@electron/remote';
import { EventEmitter } from 'events';
import { IErrorMessage, IIPCReceiveMessage, IIPCSendMessage, IPrintMessage, IRioConsole, IRioConsoleProvider,
IWindowProvider, IWindowView, RioConsole } from 'wpilib-riolog';
import { writeFileAsync } from '../utilities';

const dialog = electron.remote.dialog;

export class RioLogWindowView extends EventEmitter implements IWindowView {
private fromMain: (data: IIPCSendMessage) => Promise<void>;

Expand Down
6 changes: 2 additions & 4 deletions wpilib-utility-standalone/src/riolog/script/implscript.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';

import * as electron from 'electron';
import { getCurrentWindow } from '@electron/remote';
import { IIPCReceiveMessage, RioLogWindow } from 'wpilib-riolog';
import { LiveRioConsoleProvider, RioLogWebviewProvider, RioLogWindowView } from '../electronimpl';
import { checkResizeImpl, handleMessage } from '../shared/sharedscript';

const remote = electron.remote;

export function checkResize() {
checkResizeImpl(document.documentElement);
}
Expand All @@ -25,7 +23,7 @@ export function sendMessage(message: IIPCReceiveMessage) {

document.addEventListener('keydown', (e) => {
if (e.key === '{') {
remote.getCurrentWindow().webContents.toggleDevTools();
getCurrentWindow().webContents.toggleDevTools();
} else if (e.key === '}') {
location.reload();
}
Expand Down
3 changes: 1 addition & 2 deletions wpilib-utility-standalone/src/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import * as electron from 'electron';
import { dialog } from '@electron/remote';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
import * as ncp from 'ncp';
Expand All @@ -9,8 +10,6 @@ import * as temp from 'temp';
import * as util from 'util';
import * as vscode from './vscodeshim';

const dialog = electron.remote.dialog;

export function getIsWindows(): boolean {
const nodePlatform: NodeJS.Platform = process.platform;
return nodePlatform === 'win32';
Expand Down
7 changes: 3 additions & 4 deletions wpilib-utility-standalone/src/vendordeps.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

import * as electron from 'electron';
import { app, dialog, getCurrentWindow } from '@electron/remote';
import * as path from 'path';
import { logger } from './logger';
import { UtilitiesAPI } from './shared/utilitiesapi';
import { IJsonDependency, VendorLibrariesBase } from './shared/vendorlibrariesbase';
import { deleteFileAsync, existsAsync, readdirAsync } from './utilities';

const dialog = electron.remote.dialog;
const bWindow = electron.remote.getCurrentWindow();
const bWindow = getCurrentWindow();

class VendorLibraries extends VendorLibrariesBase {
public constructor() {
Expand Down Expand Up @@ -143,7 +142,7 @@ const vendorLibs = new VendorLibraries();
export async function selectProjectButton(): Promise<void> {
const paths = await dialog.showOpenDialog(bWindow, {
buttonLabel: 'Select Project (build.gradle)',
defaultPath: electron.remote.app.getPath('documents'),
defaultPath: app.getPath('documents'),
filters: [
{ name: 'Build Files', extensions: ['gradle'] },
],
Expand Down
Loading