From 4f85fbfd0737db43e4d73e63a72cb57e25e63be4 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 25 Jul 2022 22:08:39 -0400 Subject: [PATCH 01/79] Added preserveFocus to show --- src/views/gView.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/gView.ts b/src/views/gView.ts index 5868166..4c118f8 100644 --- a/src/views/gView.ts +++ b/src/views/gView.ts @@ -78,10 +78,10 @@ export abstract class GView> implements TreeDa return this._tree?.visible ?? false; } - protected async show() { + protected async show(options?: { preserveFocus?: boolean }) { if (!this.visible) { try { - void (await commands.executeCommand(`${this.id}.focus`)); + void (await commands.executeCommand(`${this.id}.focus`, options)); } catch (err) { Logger.error(err, 'Error focusing view'); } From ac251160747a91c1e66d1b5062798816488d199e Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 25 Jul 2022 22:09:54 -0400 Subject: [PATCH 02/79] Working test side view for calculators --- package.json | 7 +++ src/control.ts | 17 +++++-- src/webviews/calcWebviewView.ts | 52 +++++++++++++++++++ src/webviews/gWebviewView.ts | 88 +++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 src/webviews/calcWebviewView.ts create mode 100644 src/webviews/gWebviewView.ts diff --git a/package.json b/package.json index 679e83f..719c238 100644 --- a/package.json +++ b/package.json @@ -343,14 +343,21 @@ "views": { "gcode": [ { + "type": "tree", "id": "gcode.views.navTree", "name": "Tree", "contextualTitle": "G-Code" }, { + "type": "tree", "id": "gcode.views.stats", "name": "Stats", "contextualTitle": "G-Code" + }, + { + "type": "webview", + "id": "gcode.webviews.calc", + "name": "Milling / Turning Calculator" } ] }, diff --git a/src/control.ts b/src/control.ts index b9caa90..b01b4dd 100644 --- a/src/control.ts +++ b/src/control.ts @@ -21,6 +21,7 @@ import { MachineTypeControl } from './util/machineType'; import { GCodeHoverControl } from './hovers/gcodeHoverControl'; import { defaults } from './util/configuration/defaults'; import { registerCommands } from './util/commands'; +import { CalcWebviewView } from './webviews/calcWebviewView'; const cfgUnits = 'general.units'; const cfgAutoRef = { @@ -47,6 +48,7 @@ export class Control { // Webviews private static _codesWebview: CodesWebview | undefined; + private static _calcWebviewView: CalcWebviewView | undefined; private static async _checkVersion() { const prevVer = this._stateController.getVersion(); @@ -156,7 +158,7 @@ export class Control { // Set Up Webviews context.subscriptions.push((this._codesWebview = new CodesWebview())); - + context.subscriptions.push((this._calcWebviewView = new CalcWebviewView())); Logger.log('Done Initializing.'); } @@ -165,6 +167,7 @@ export class Control { // Dispose Views this._codesWebview?.dispose(); + this._calcWebviewView?.dispose(); this._statsView?.dispose(); this._statsView?.dispose(); @@ -196,10 +199,6 @@ export class Control { return this._version; } - static get machineType() { - return this._machineTypeControl; - } - static get navTree() { if (this._navTree === undefined) { this._context.subscriptions.push((this._navTree = new NavTreeView())); @@ -227,4 +226,12 @@ export class Control { static get stateController() { return this._stateController; } + + static get machineTypeController() { + return this._machineTypeControl; + } + + static get hoverController() { + return this._hoverController; + } } diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calcWebviewView.ts new file mode 100644 index 0000000..2b0e76f --- /dev/null +++ b/src/webviews/calcWebviewView.ts @@ -0,0 +1,52 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +import { Uri, Webview } from 'vscode'; +import { Control } from '../control'; +import { GWebviewView } from './gWebviewView'; + +const CalcWebviewInfo = { + ViewId: 'gcode.webviews.calc', + Title: 'Milling / Turning Calculators', +}; + +export class CalcWebviewView extends GWebviewView { + constructor() { + super(CalcWebviewInfo.ViewId, CalcWebviewInfo.Title); + } + + async getHtml(webview: Webview): Promise { + // CSS styles + const stylesReset = webview.asWebviewUri( + Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css'), + ); + + const stylesMain = webview.asWebviewUri( + Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), + ); + + const nonce = this.getNonce(); + + return Promise.resolve(` + + + + + + + + + + + + Calc + + Calculators + `); + } +} diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts new file mode 100644 index 0000000..0c6fc34 --- /dev/null +++ b/src/webviews/gWebviewView.ts @@ -0,0 +1,88 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +import { + CancellationToken, + commands, + Disposable, + Uri, + Webview, + WebviewOptions, + WebviewView, + WebviewViewProvider, + WebviewViewResolveContext, + window, +} from 'vscode'; +import { Control } from '../control'; +import { Logger } from '../util/logger'; + +export abstract class GWebviewView implements WebviewViewProvider, Disposable { + protected readonly _disposables: Disposable[] = []; + private _view: WebviewView | undefined; + private _title: string; + + constructor(public readonly id: string, public readonly title: string) { + this._title = title; + + this._disposables.push(window.registerWebviewViewProvider(id, this)); + } + + dispose() { + Disposable.from(...this._disposables).dispose(); + } + + get visible() { + return this._view?.visible ?? false; + } + + async show(options?: { preserveFocus?: boolean }) { + try { + void (await commands.executeCommand(`${this.id}.focus`), options); + } catch (err) { + Logger.error(err); + } + } + + async resolveWebviewView( + webviewView: WebviewView, + _context: WebviewViewResolveContext, + _token: CancellationToken, + ): Promise { + this._view = webviewView; + + webviewView.webview.options = this.getWebviewOptions(); + webviewView.title = this.title; + + webviewView.webview.html = await this.getHtml(this._view.webview); + } + + protected async refresh(): Promise { + if (this._view) { + this._view.webview.html = await this.getHtml(this._view.webview); + } + } + + protected abstract getHtml(webview: Webview): Promise; + + protected getNonce(): string { + let text = ''; + + const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + for (let i = 0; i < 32; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; + } + + protected getWebviewOptions(): WebviewOptions { + return { + enableScripts: true, + // enableCommandUris: true, + localResourceRoots: [Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews')], + }; + } +} From 44039d667af6d278a0d6d233724bad56541ee58d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 00:24:23 -0400 Subject: [PATCH 03/79] Added @vscode/webview-ui-toolkit to deps --- package-lock.json | 171 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 3 +- 2 files changed, 163 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c9439e..9f1ee43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "0.7.5", "license": "MIT", "dependencies": { - "@appliedengdesign/gcode-reference": "^0.0.7" + "@appliedengdesign/gcode-reference": "^0.0.7", + "@vscode/webview-ui-toolkit": "^1.0.0" }, "devDependencies": { "@types/chai": "^4.3.3", @@ -292,6 +293,42 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@microsoft/fast-element": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@microsoft/fast-element/-/fast-element-1.10.3.tgz", + "integrity": "sha512-ns/EEo5WSXNwRBe29O7sSA4SSqlapyHESXBT+JAcrR/3i0fLYQFMO/PdzfEMhsXmoUkZny6ewVbM4CttZa94Kg==" + }, + "node_modules/@microsoft/fast-foundation": { + "version": "2.46.10", + "resolved": "https://registry.npmjs.org/@microsoft/fast-foundation/-/fast-foundation-2.46.10.tgz", + "integrity": "sha512-lu1jN/dRkdOqkrDudEMZAmWhBy0XFkGr8oU8Z8vjUwhU1Ag3gxKbmfU0Yf4V44tMDkId3nJh8bXvh1d+U6MvQA==", + "dependencies": { + "@microsoft/fast-element": "^1.10.3", + "@microsoft/fast-web-utilities": "^5.4.1", + "tabbable": "^5.2.0", + "tslib": "^1.13.0" + } + }, + "node_modules/@microsoft/fast-react-wrapper": { + "version": "0.1.48", + "resolved": "https://registry.npmjs.org/@microsoft/fast-react-wrapper/-/fast-react-wrapper-0.1.48.tgz", + "integrity": "sha512-9NvEjru9Kn5ZKjomAMX6v+eF0DR+eDkxKDwDfi+Wb73kTbrNzcnmlwd4diN15ygH97kldgj2+lpvI4CKLQQWLg==", + "dependencies": { + "@microsoft/fast-element": "^1.9.0", + "@microsoft/fast-foundation": "^2.41.1" + }, + "peerDependencies": { + "react": ">=16.9.0" + } + }, + "node_modules/@microsoft/fast-web-utilities": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@microsoft/fast-web-utilities/-/fast-web-utilities-5.4.1.tgz", + "integrity": "sha512-ReWYncndjV3c8D8iq9tp7NcFNc1vbVHvcBFPME2nNFKNbS1XCesYZGlIlf3ot5EmuOXPlrzUHOWzQ2vFpIkqDg==", + "dependencies": { + "exenv-es6": "^1.1.1" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -640,6 +677,19 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "node_modules/@vscode/webview-ui-toolkit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@vscode/webview-ui-toolkit/-/webview-ui-toolkit-1.0.0.tgz", + "integrity": "sha512-/qaHYZXqvIKkao54b7bLzyNH8BC+X4rBmTUx1MvcIiCjqRMxml0BCpqJhnDpfrCb0IOxXRO8cAy1eB5ayzQfBA==", + "dependencies": { + "@microsoft/fast-element": "^1.6.2", + "@microsoft/fast-foundation": "^2.38.0", + "@microsoft/fast-react-wrapper": "^0.1.18" + }, + "peerDependencies": { + "react": ">=16.9.0" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -2029,6 +2079,11 @@ "node": ">=0.8.x" } }, + "node_modules/exenv-es6": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exenv-es6/-/exenv-es6-1.1.1.tgz", + "integrity": "sha512-vlVu3N8d6yEMpMsEm+7sUBAI81aqYYuEvfK0jNqmdb/OPXzzH7QWDDnVjMvDSY47JdHEqx/dfC/q8WkfoTmpGQ==" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2976,8 +3031,7 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -3116,6 +3170,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "peer": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/loupe": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", @@ -3703,6 +3769,18 @@ "safe-buffer": "^5.1.0" } }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -4218,6 +4296,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tabbable": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-5.3.3.tgz", + "integrity": "sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA==" + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -4398,8 +4481,7 @@ "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -5139,6 +5221,39 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@microsoft/fast-element": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@microsoft/fast-element/-/fast-element-1.10.3.tgz", + "integrity": "sha512-ns/EEo5WSXNwRBe29O7sSA4SSqlapyHESXBT+JAcrR/3i0fLYQFMO/PdzfEMhsXmoUkZny6ewVbM4CttZa94Kg==" + }, + "@microsoft/fast-foundation": { + "version": "2.46.10", + "resolved": "https://registry.npmjs.org/@microsoft/fast-foundation/-/fast-foundation-2.46.10.tgz", + "integrity": "sha512-lu1jN/dRkdOqkrDudEMZAmWhBy0XFkGr8oU8Z8vjUwhU1Ag3gxKbmfU0Yf4V44tMDkId3nJh8bXvh1d+U6MvQA==", + "requires": { + "@microsoft/fast-element": "^1.10.3", + "@microsoft/fast-web-utilities": "^5.4.1", + "tabbable": "^5.2.0", + "tslib": "^1.13.0" + } + }, + "@microsoft/fast-react-wrapper": { + "version": "0.1.48", + "resolved": "https://registry.npmjs.org/@microsoft/fast-react-wrapper/-/fast-react-wrapper-0.1.48.tgz", + "integrity": "sha512-9NvEjru9Kn5ZKjomAMX6v+eF0DR+eDkxKDwDfi+Wb73kTbrNzcnmlwd4diN15ygH97kldgj2+lpvI4CKLQQWLg==", + "requires": { + "@microsoft/fast-element": "^1.9.0", + "@microsoft/fast-foundation": "^2.41.1" + } + }, + "@microsoft/fast-web-utilities": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@microsoft/fast-web-utilities/-/fast-web-utilities-5.4.1.tgz", + "integrity": "sha512-ReWYncndjV3c8D8iq9tp7NcFNc1vbVHvcBFPME2nNFKNbS1XCesYZGlIlf3ot5EmuOXPlrzUHOWzQ2vFpIkqDg==", + "requires": { + "exenv-es6": "^1.1.1" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -5386,6 +5501,16 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "@vscode/webview-ui-toolkit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@vscode/webview-ui-toolkit/-/webview-ui-toolkit-1.0.0.tgz", + "integrity": "sha512-/qaHYZXqvIKkao54b7bLzyNH8BC+X4rBmTUx1MvcIiCjqRMxml0BCpqJhnDpfrCb0IOxXRO8cAy1eB5ayzQfBA==", + "requires": { + "@microsoft/fast-element": "^1.6.2", + "@microsoft/fast-foundation": "^2.38.0", + "@microsoft/fast-react-wrapper": "^0.1.18" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", @@ -6478,6 +6603,11 @@ "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", "dev": true }, + "exenv-es6": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exenv-es6/-/exenv-es6-1.1.1.tgz", + "integrity": "sha512-vlVu3N8d6yEMpMsEm+7sUBAI81aqYYuEvfK0jNqmdb/OPXzzH7QWDDnVjMvDSY47JdHEqx/dfC/q8WkfoTmpGQ==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -7170,8 +7300,7 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { "version": "4.1.0", @@ -7284,6 +7413,15 @@ "is-unicode-supported": "^0.1.0" } }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "peer": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "loupe": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", @@ -7714,6 +7852,15 @@ "safe-buffer": "^5.1.0" } }, + "react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0" + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -8079,6 +8226,11 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tabbable": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-5.3.3.tgz", + "integrity": "sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA==" + }, "tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -8193,8 +8345,7 @@ "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "tsutils": { "version": "3.21.0", @@ -8575,4 +8726,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 719c238..8189d23 100644 --- a/package.json +++ b/package.json @@ -563,6 +563,7 @@ "webpack-cli": "^4.10.0" }, "dependencies": { - "@appliedengdesign/gcode-reference": "^0.0.7" + "@appliedengdesign/gcode-reference": "^0.0.7", + "@vscode/webview-ui-toolkit": "^1.0.0" } } \ No newline at end of file From 97a3b5d03ec2ce090de0647d58dad9aa5f36df62 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 00:24:50 -0400 Subject: [PATCH 04/79] Fixed typo in machineTypeController --- src/hovers/gcodeHoverProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hovers/gcodeHoverProvider.ts b/src/hovers/gcodeHoverProvider.ts index 2ac6e7a..4d406e0 100644 --- a/src/hovers/gcodeHoverProvider.ts +++ b/src/hovers/gcodeHoverProvider.ts @@ -29,7 +29,7 @@ export class GCodeHoverProvider implements HoverProvider { } private lookup(text: string): MarkdownString | undefined { - const ref = Control.machineType?.gReference; + const ref = Control.machineTypeController?.gReference; const code = ref?.get(text); From 97daa137eeaf99e9b22637def7515ea38f3d8cc8 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 00:25:14 -0400 Subject: [PATCH 05/79] Testing tabs & ui kit --- src/webviews/calcWebviewView.ts | 36 ++++++++++++++++++++++++++++++--- src/webviews/gWebviewView.ts | 3 +-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calcWebviewView.ts index 2b0e76f..00862db 100644 --- a/src/webviews/calcWebviewView.ts +++ b/src/webviews/calcWebviewView.ts @@ -4,7 +4,8 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { Uri, Webview } from 'vscode'; +import { TextDecoder } from 'util'; +import { Uri, Webview, workspace } from 'vscode'; import { Control } from '../control'; import { GWebviewView } from './gWebviewView'; @@ -28,25 +29,54 @@ export class CalcWebviewView extends GWebviewView { Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), ); + // vscode-webview-ui-toolkit + const toolkitUri = webview.asWebviewUri( + Uri.joinPath( + Control.context.extensionUri, + 'node_modules', + '@vscode', + 'webview-ui-toolkit', + 'dist', + 'toolkit.js', + ), + ); + const nonce = this.getNonce(); + // const body = new TextDecoder('utf8').decode(await workspace.fs.readFile()) + return Promise.resolve(` + + Calc - Calculators + + + MILLING + TURNING + + + + Calculate> + +
+
+ +
+ `); } } diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 0c6fc34..36dc8ab 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -81,8 +81,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected getWebviewOptions(): WebviewOptions { return { enableScripts: true, - // enableCommandUris: true, - localResourceRoots: [Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews')], + localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], }; } } From 0575e020496082534c5bc63c0abfa45de0c4032b Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 13:16:22 -0400 Subject: [PATCH 06/79] updated vscodeignore --- .vscodeignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.vscodeignore b/.vscodeignore index b2f7b32..d702229 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -8,6 +8,7 @@ .prettierignore .prettierrc .vscode-test/** +.vscode-test-web/** .vscode/** **/*.map CODE_OF_CONDUCT.md @@ -18,9 +19,12 @@ images/**/[^logo]* out/test/** package-lock.json samplenc/** +scripts/** src/** test/** out/** +node_modules/** tsconfig** tsconfig.tsbuildinfo -webpack.config.js \ No newline at end of file +webpack.config*.js +.DS_Store \ No newline at end of file From b460cf7c4be59fbb5f8cb53b0973cebfadc72780 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 13:21:43 -0400 Subject: [PATCH 07/79] Changed to eslint-webpack-plugin --- webpack.config.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 5caa8d5..9f53a11 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,7 @@ 'use strict'; -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); +const ESLintPlugin = require('eslint-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const path = require('path'); @@ -14,12 +14,11 @@ const path = require('path'); function getExtensionConfig(mode, env) { const plugins = []; + plugins.push( - new ForkTsCheckerWebpackPlugin({ - async: false, - // eslint: { enabled: true, files: 'src/**/*.ts', options: { cache: true } }, - formatter: 'basic', - }), + new ESLintPlugin({ + extensions: ['ts'] + }) ); if (env.analyzeBundle) { From 002c3acee816eaf36bc6b6b1326f5f18683089e4 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 13:37:14 -0400 Subject: [PATCH 08/79] Added webview controller --- src/control.ts | 11 ++- src/util/configuration/defaults.ts | 12 ++-- src/util/constants.ts | 2 + src/webviews/{ => calc}/calcWebviewView.ts | 22 ++++-- src/webviews/gWebviewView.ts | 3 + src/webviews/webviewController.ts | 80 ++++++++++++++++++++++ 6 files changed, 111 insertions(+), 19 deletions(-) rename src/webviews/{ => calc}/calcWebviewView.ts (86%) create mode 100644 src/webviews/webviewController.ts diff --git a/src/control.ts b/src/control.ts index b01b4dd..d514146 100644 --- a/src/control.ts +++ b/src/control.ts @@ -16,12 +16,11 @@ import { constants, Contexts, GCommands, PIcon, VSBuiltInCommands } from './util import { Version } from './util/version'; import { Messages } from './util/messages'; import { StateControl } from './util/stateControl'; -import { CodesWebview } from './webviews/codesWebview'; import { MachineTypeControl } from './util/machineType'; import { GCodeHoverControl } from './hovers/gcodeHoverControl'; import { defaults } from './util/configuration/defaults'; import { registerCommands } from './util/commands'; -import { CalcWebviewView } from './webviews/calcWebviewView'; +import { WebviewController } from './webviews/webviewController'; const cfgUnits = 'general.units'; const cfgAutoRef = { @@ -41,6 +40,7 @@ export class Control { private static _unitsController: GCodeUnitsController | undefined; private static _stateController: StateControl; private static _hoverController: GCodeHoverControl; + private static _webviewController: WebviewController | undefined; // Views private static _statsView: StatsView | undefined; @@ -157,8 +157,7 @@ export class Control { ); // Set Up Webviews - context.subscriptions.push((this._codesWebview = new CodesWebview())); - context.subscriptions.push((this._calcWebviewView = new CalcWebviewView())); + context.subscriptions.push((this._webviewController = new WebviewController())); Logger.log('Done Initializing.'); } @@ -166,10 +165,8 @@ export class Control { Logger.log('Terminating Extension...'); // Dispose Views - this._codesWebview?.dispose(); - this._calcWebviewView?.dispose(); - this._statsView?.dispose(); this._statsView?.dispose(); + this._navTree?.dispose(); // Dispose Controllers this._hoverController.dispose(); diff --git a/src/util/configuration/defaults.ts b/src/util/configuration/defaults.ts index 9db981f..d10dd41 100644 --- a/src/util/configuration/defaults.ts +++ b/src/util/configuration/defaults.ts @@ -47,10 +47,10 @@ export interface GCodeConfiguration { stats: { autoRefresh: boolean; }; + }; - webviews: { - enabled: boolean; - }; + webviews: { + enabled: boolean; }; } @@ -88,8 +88,8 @@ export const defaults: GCodeConfiguration = { stats: { autoRefresh: false, }, - webviews: { - enabled: true, - }, + }, + webviews: { + enabled: true, }, }; diff --git a/src/util/constants.ts b/src/util/constants.ts index 4b9c39c..31926f0 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -74,6 +74,7 @@ export enum Contexts { MachineType = 'gcode:general:machineType', ViewsNavTreeEnabled = 'gcode:views:navTree:enabled', ViewsStatsEnabled = 'gcode:views:stats:enabled', + WebviewsEnabled = 'gcode:webviews:enabled', } export enum GCommands { @@ -93,4 +94,5 @@ export const enum ViewCommands { export const enum WebViewCommands { ShowCodesWebview = 'gcode.webviews.codes.show', + ShowCalcWebview = 'gcode.webviews.calc.show', } diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts similarity index 86% rename from src/webviews/calcWebviewView.ts rename to src/webviews/calc/calcWebviewView.ts index 00862db..81e1b84 100644 --- a/src/webviews/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -4,10 +4,10 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { TextDecoder } from 'util'; -import { Uri, Webview, workspace } from 'vscode'; -import { Control } from '../control'; -import { GWebviewView } from './gWebviewView'; +import { commands, Disposable, Uri, Webview } from 'vscode'; +import { Control } from '../../control'; +import { WebViewCommands } from '../../util/constants'; +import { GWebviewView } from '../gWebviewView'; const CalcWebviewInfo = { ViewId: 'gcode.webviews.calc', @@ -19,6 +19,18 @@ export class CalcWebviewView extends GWebviewView { super(CalcWebviewInfo.ViewId, CalcWebviewInfo.Title); } + registerCommands(): Disposable[] { + return [ + commands.registerCommand( + WebViewCommands.ShowCalcWebview, + () => { + void this.show(); + }, + this, + ), + ]; + } + async getHtml(webview: Webview): Promise { // CSS styles const stylesReset = webview.asWebviewUri( @@ -43,8 +55,6 @@ export class CalcWebviewView extends GWebviewView { const nonce = this.getNonce(); - // const body = new TextDecoder('utf8').decode(await workspace.fs.readFile()) - return Promise.resolve(` diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 36dc8ab..7937a72 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -28,6 +28,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { this._title = title; this._disposables.push(window.registerWebviewViewProvider(id, this)); + this._disposables.push(...this.registerCommands()); } dispose() { @@ -67,6 +68,8 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected abstract getHtml(webview: Webview): Promise; + protected abstract registerCommands(): Disposable[]; + protected getNonce(): string { let text = ''; diff --git a/src/webviews/webviewController.ts b/src/webviews/webviewController.ts new file mode 100644 index 0000000..c818407 --- /dev/null +++ b/src/webviews/webviewController.ts @@ -0,0 +1,80 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +import { ConfigurationChangeEvent, Disposable } from 'vscode'; +import { Control } from '../control'; +import { configuration } from '../util/configuration/config'; +import { defaults } from '../util/configuration/defaults'; +import { Contexts } from '../util/constants'; +import { Logger } from '../util/logger'; +import { CalcWebviewView } from './calc/calcWebviewView'; + +export interface Webviews { + calcWebviewView?: CalcWebviewView | undefined; +} + +const wv = { + enabled: 'webviews.enabled', +}; + +export class WebviewController implements Disposable { + private _enabled: boolean; + private readonly _disposables: Disposable[] = []; + + // webviews + private _webviews: Webviews = { + calcWebviewView: undefined, + }; + + constructor() { + this._enabled = configuration.getParam(wv.enabled) ?? defaults.webviews.enabled; + + this._disposables.push(configuration.onDidChange(this.onConfigurationChanged, this)); + + if (this._enabled) { + Logger.log('Loading Webviews...'); + + void Control.setContext(Contexts.WebviewsEnabled, true); + + this._disposables.push(...this.buildWebviews()); + } else { + void Control.setContext(Contexts.WebviewsEnabled, false); + } + } + + dispose() { + Disposable.from(...this._disposables); + } + + private onConfigurationChanged(e: ConfigurationChangeEvent) { + if (configuration.changed(e, wv.enabled)) { + if (this._enabled) { + Logger.log('Webviews disabled...'); + void Control.setContext(Contexts.WebviewsEnabled, false); + // Disable webviews & dispose + Object.keys(this._webviews).forEach(key => { + this._webviews[key as keyof Webviews]?.dispose(); + this._webviews[key as keyof Webviews] = undefined; + }); + } else { + // Enable + Logger.log('Webviews enabled...'); + void Control.setContext(Contexts.WebviewsEnabled, true); + this._disposables.push(...this.buildWebviews()); + } + } + + this._enabled = configuration.getParam(wv.enabled) ?? defaults.webviews.enabled; + } + + private buildWebviews(): Disposable[] { + // Build webviews + return [ + // Calc Webview + (this._webviews.calcWebviewView = new CalcWebviewView()), + ]; + } +} From a2393120747a51fb138170a82cf283c39c04334d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 13:38:01 -0400 Subject: [PATCH 09/79] Added copy-webpack-plugin --- package-lock.json | 476 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 61 +++++- 2 files changed, 513 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9f1ee43..c007726 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,10 +21,12 @@ "@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", + "copy-webpack-plugin": "^11.0.0", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", + "eslint-webpack-plugin": "^3.2.0", "fork-ts-checker-webpack-plugin": "^7.2.13", "glob": "^8.0.3", "mocha": "^10.0.0", @@ -951,6 +953,45 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv-formats/node_modules/ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, "node_modules/ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -1380,6 +1421,126 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "node_modules/copy-webpack-plugin": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz", + "integrity": "sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==", + "dev": true, + "dependencies": { + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.1", + "globby": "^13.1.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0", + "serialize-javascript": "^6.0.0" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/copy-webpack-plugin/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/copy-webpack-plugin/node_modules/globby": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz", + "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==", + "dev": true, + "dependencies": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.11", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/copy-webpack-plugin/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/copy-webpack-plugin/node_modules/schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/copy-webpack-plugin/node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -1947,6 +2108,97 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/eslint-webpack-plugin": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-3.2.0.tgz", + "integrity": "sha512-avrKcGncpPbPSUHX6B3stNGzkKFto3eL+DKM4+VyMrVnhPc3vRczVlCq3uhuFOdRvDHTVXuzwk1ZKUrqDQHQ9w==", + "dev": true, + "dependencies": { + "@types/eslint": "^7.29.0 || ^8.4.1", + "jest-worker": "^28.0.2", + "micromatch": "^4.0.5", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0", + "webpack": "^5.0.0" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/jest-worker": { + "version": "28.1.3", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-28.1.3.tgz", + "integrity": "sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==", + "dev": true, + "dependencies": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/eslint-webpack-plugin/node_modules/schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, "node_modules/eslint/node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -3237,13 +3489,13 @@ } }, "node_modules/micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" @@ -3678,9 +3930,9 @@ } }, "node_modules/picomatch": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", - "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, "engines": { "node": ">=8.6" @@ -3847,6 +4099,15 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -5739,6 +6000,35 @@ "uri-js": "^4.2.2" } }, + "ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "requires": { + "ajv": "^8.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + } + } + }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -6065,6 +6355,89 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "copy-webpack-plugin": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz", + "integrity": "sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==", + "dev": true, + "requires": { + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.1", + "globby": "^13.1.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0", + "serialize-javascript": "^6.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, + "globby": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz", + "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==", + "dev": true, + "requires": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.11", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + } + }, + "slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true + } + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -6540,6 +6913,71 @@ "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, + "eslint-webpack-plugin": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-3.2.0.tgz", + "integrity": "sha512-avrKcGncpPbPSUHX6B3stNGzkKFto3eL+DKM4+VyMrVnhPc3vRczVlCq3uhuFOdRvDHTVXuzwk1ZKUrqDQHQ9w==", + "dev": true, + "requires": { + "@types/eslint": "^7.29.0 || ^8.4.1", + "jest-worker": "^28.0.2", + "micromatch": "^4.0.5", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "jest-worker": { + "version": "28.1.3", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-28.1.3.tgz", + "integrity": "sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==", + "dev": true, + "requires": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + } + } + } + }, "espree": { "version": "9.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", @@ -7468,13 +7906,13 @@ "dev": true }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" } }, "mime": { @@ -7799,9 +8237,9 @@ "dev": true }, "picomatch": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", - "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, "prelude-ls": { @@ -7914,6 +8352,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", diff --git a/package.json b/package.json index 8189d23..f9499de 100644 --- a/package.json +++ b/package.json @@ -326,7 +326,7 @@ "gcode.webviews.enabled": { "type": "boolean", "default": true, - "markdownDescription": "Enable or Disable WebViews", + "markdownDescription": "Enable or Disable Webviews", "scope": "window" } } @@ -357,7 +357,10 @@ { "type": "webview", "id": "gcode.webviews.calc", - "name": "Milling / Turning Calculator" + "name": "Milling / Turning Calculator", + "contextualTitle": "G-Code", + "visibility": "collapsed", + "when": "gcode:webviews:enabled" } ] }, @@ -423,6 +426,10 @@ { "command": "gcode.views.stats.refresh", "when": "editorLangId == gcode" + }, + { + "command": "gcode.webviews.calc.show", + "when": "editorLangId == gcode" } ], "editor/context": [ @@ -446,6 +453,38 @@ "command": "gcode.removeComment", "group": "gcode" }, + { + "when": "editorLangId == gcode && gcode:webviews:enabled", + "command": "gcode.webviews.calc.show", + "group": "gcode" + }, + { + "when": "editorLangId == gcode", + "command": "gcode.showSettings", + "group": "gcode" + } + ], + "editor/title/context": [ + { + "when": "editorLangId == gcode", + "command": "gcode.views.navTree.refresh", + "group": "gcode" + }, + { + "when": "editorLangId == gcode", + "command": "gcode.views.stats.refresh", + "group": "gcode" + }, + { + "when": "editorLangId == gcode", + "command": "gcode.addLineNumbers", + "group": "gcode" + }, + { + "when": "editorLangId == gcode", + "command": "gcode.removeLineNumbers", + "group": "gcode" + }, { "when": "editorLangId == gcode", "command": "gcode.showSettings", @@ -500,11 +539,6 @@ "title": "G-Code: Remove Comment", "category": "G-Code" }, - { - "command": "gcode.webviews.codes.show", - "title": "G-Code: Show Code Reference", - "category": "G-Code" - }, { "command": "gcode.addLineNumbers", "title": "G-Code: Add Line Numbers", @@ -514,6 +548,16 @@ "command": "gcode.removeLineNumbers", "title": "G-Code: Remove Line Numbers", "category": "G-Code" + }, + { + "command": "gcode.webviews.codes.show", + "title": "G-Code: Show Code Reference", + "category": "G-Code" + }, + { + "command": "gcode.webviews.calc.show", + "title": "G-Code: Show Calculator", + "category": "G-Code" } ] }, @@ -545,11 +589,12 @@ "@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", + "copy-webpack-plugin": "^11.0.0", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", - "fork-ts-checker-webpack-plugin": "^7.2.13", + "eslint-webpack-plugin": "^3.2.0", "glob": "^8.0.3", "mocha": "^10.0.0", "prettier": "^2.7.1", From e3ad38cd5c555ab73604d7fe2e4175afff7f7a46 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 14:08:13 -0400 Subject: [PATCH 10/79] Refactored configuration into categories --- package.json | 372 +++++++++++++++++++++++++++------------------------ 1 file changed, 196 insertions(+), 176 deletions(-) diff --git a/package.json b/package.json index f9499de..f8b76ea 100644 --- a/package.json +++ b/package.json @@ -152,185 +152,205 @@ "path": "./snippets/general-snippets.json" } ], - "configuration": { - "type": "object", - "title": "G-Code", - "properties": { - "gcode.general.machineType": { - "type": "string", - "default": "Mill", - "enum": [ - "Mill", - "Lathe", - "3D Printer", - "Swiss", - "Laser", - "EDM" - ], - "enumDescriptions": [ - "Configure G-Code Extension for CNC Mill", - "Configure G-Code Extension for CNC Lathe", - "Configure G-Code Extension for 3D Printers", - "Configure G-Code Extension for Swiss-style Lathes", - "Configure G-Code Extension for Laser Machine Tools", - "Configure G-Code Extension for EDM" - ], - "markdownDescription": "Configure G-Code Extension for a Specific Machine Type", - "scope": "window" - }, - "gcode.general.hovers.enabled": { - "type": "boolean", - "default": true, - "markdownDescription": "Enable G-Code Hovers", - "scope": "window" - }, - "gcode.general.statusBars.enabled": { - "type": "boolean", - "default": true, - "markdownDescription": "Enable G-Code Statusbars", - "scope": "window" - }, - "gcode.general.statusBars.alignment": { - "type": "string", - "default": "Left", - "enum": [ - "Left", - "Right" - ], - "enumDescriptions": [ - "Aligns to the left", - "Aligns to the right" - ], - "markdownDescription": "Specifies status bars alignment", - "scope": "window" - }, - "gcode.general.units": { - "type": "string", - "default": "Auto", - "enum": [ - "Auto", - "Inch", - "Metric" - ], - "markdownDescription": "Configure Units for G-Code Files. Choose Auto to have G-Code parse for ```G20/G21```" - }, - "gcode.general.outputLevel": { - "type": "string", - "default": "verbose", - "enum": [ - "silent", - "errors", - "warnings", - "verbose", - "debug" - ], - "enumDescriptions": [ - "No Output", - "Outputs only Errors", - "Outputs all errors, warnings and messages", - "Outputs Everything for Debugging Purposes" - ], - "markdownDescription": "Specifies how much output will be sent to the G-Code Output Channel.", - "scope": "window" - }, - "gcode.lineNumberer.addSpaceAfter": { - "type": "boolean", - "default": true, - "markdownDescription": "Add Space After Line Number", - "scope": "window" - }, - "gcode.lineNumberer.defaultIncrement": { - "type": "number", - "default": 10, - "markdownDescription": "Default Line Numberer Increment", - "scope": "window" - }, - "gcode.lineNumberer.defaultStart": { - "type": "number", - "default": 10, - "markdownDescription": "Default Line Numberer Start", - "scope": "window" - }, - "gcode.lineNumbere.enableQuickPick": { - "type": "boolean", - "default": true, - "markdownDescription": "Enable or Disable Input for Line Numberer (Will use above defaults).", - "scope": "window" - }, - "gcode.lineNumberer.frequency": { - "type": "string", - "default": "Every Line", - "enum": [ - "Every Line", - "At Tool Changes" - ], - "enumDescriptions": [ - "Line Number at Every Line", - "Line Number only at Tool Changes" - ], - "markdownDescription": "Specify Frequency of Line Numbering" - }, - "gcode.lineNumberer.ignoreBlank": { - "type": "boolean", - "default": true, - "markdownDescription": "Ignore Blank Lines when Numbering", - "scope": "window" - }, - "gcode.lineNumberer.ignoreComments": { - "type": "boolean", - "default": true, - "markdownDescription": "Ignore Comments when Numbering", - "scope": "window" - }, - "gcode.lineNumberer.ignoreExtra": { - "type": "array", - "items": { - "type": "string" + "configuration": [ + { + "title": "General", + "order": 0, + "properties": { + "gcode.general.machineType": { + "type": "string", + "default": "Mill", + "enum": [ + "Mill", + "Lathe", + "3D Printer", + "Swiss", + "Laser", + "EDM" + ], + "enumDescriptions": [ + "Configure G-Code Extension for CNC Mill", + "Configure G-Code Extension for CNC Lathe", + "Configure G-Code Extension for 3D Printers", + "Configure G-Code Extension for Swiss-style Lathes", + "Configure G-Code Extension for Laser Machine Tools", + "Configure G-Code Extension for EDM" + ], + "markdownDescription": "Configure G-Code Extension for a Specific Machine Type", + "scope": "window" }, - "default": [ - "%" - ], - "markdownDescription": "Additional characters to ignore (Beginning of Line)", - "scope": "window" - }, - "gcode.lineNumberer.ignoreProgramNumbers": { - "type": "boolean", - "default": true, - "markdownDescription": "Ignore program numbers, e.g. `O12345`", - "scope": "window" - }, - "gcode.lineNumberer.matchLineNumber": { - "type": "boolean", - "default": false, - "markdownDescription": "When numbering, match N number to file's line number.", - "scope": "window" - }, - "gcode.views.maxAutoRefresh": { - "type": "integer", - "default": "10000", - "markdownDescription": "Maximum Number of Lines in Editor to allow Auto Refresh", - "scope": "window" - }, - "gcode.views.navTree.autoRefresh": { - "type": "boolean", - "default": true, - "markdownDescription": "Enable G-Code Tree Auto Refresh", - "scope": "window" - }, - "gcode.views.stats.autoRefresh": { - "type": "boolean", - "default": false, - "markdownDescription": "Enable G-Code Stats Auto Refresh", - "scope": "window" - }, - "gcode.webviews.enabled": { - "type": "boolean", - "default": true, - "markdownDescription": "Enable or Disable Webviews", - "scope": "window" + "gcode.general.hovers.enabled": { + "type": "boolean", + "default": true, + "markdownDescription": "Enable G-Code Hovers", + "scope": "window" + }, + "gcode.general.statusBars.enabled": { + "type": "boolean", + "default": true, + "markdownDescription": "Enable G-Code Statusbars", + "scope": "window" + }, + "gcode.general.statusBars.alignment": { + "type": "string", + "default": "Left", + "enum": [ + "Left", + "Right" + ], + "enumDescriptions": [ + "Aligns to the left", + "Aligns to the right" + ], + "markdownDescription": "Specifies status bars alignment", + "scope": "window" + }, + "gcode.general.units": { + "type": "string", + "default": "Auto", + "enum": [ + "Auto", + "Inch", + "Metric" + ], + "markdownDescription": "Configure Units for G-Code Files. Choose Auto to have G-Code parse for ```G20/G21```" + }, + "gcode.general.outputLevel": { + "type": "string", + "default": "verbose", + "enum": [ + "silent", + "errors", + "warnings", + "verbose", + "debug" + ], + "enumDescriptions": [ + "No Output", + "Outputs only Errors", + "Outputs all errors, warnings and messages", + "Outputs Everything for Debugging Purposes" + ], + "markdownDescription": "Specifies how much output will be sent to the G-Code Output Channel.", + "scope": "window" + } + } + }, + { + "title": "Line Numberer", + "order": 10, + "properties": { + "gcode.lineNumberer.addSpaceAfter": { + "type": "boolean", + "default": true, + "markdownDescription": "Add Space After Line Number", + "scope": "window" + }, + "gcode.lineNumberer.defaultIncrement": { + "type": "number", + "default": 10, + "markdownDescription": "Default Line Numberer Increment", + "scope": "window" + }, + "gcode.lineNumberer.defaultStart": { + "type": "number", + "default": 10, + "markdownDescription": "Default Line Numberer Start", + "scope": "window" + }, + "gcode.lineNumbere.enableQuickPick": { + "type": "boolean", + "default": true, + "markdownDescription": "Enable or Disable Input for Line Numberer (Will use above defaults).", + "scope": "window" + }, + "gcode.lineNumberer.frequency": { + "type": "string", + "default": "Every Line", + "enum": [ + "Every Line", + "At Tool Changes" + ], + "enumDescriptions": [ + "Line Number at Every Line", + "Line Number only at Tool Changes" + ], + "markdownDescription": "Specify Frequency of Line Numbering" + }, + "gcode.lineNumberer.ignoreBlank": { + "type": "boolean", + "default": true, + "markdownDescription": "Ignore Blank Lines when Numbering", + "scope": "window" + }, + "gcode.lineNumberer.ignoreComments": { + "type": "boolean", + "default": true, + "markdownDescription": "Ignore Comments when Numbering", + "scope": "window" + }, + "gcode.lineNumberer.ignoreExtra": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "%" + ], + "markdownDescription": "Additional characters to ignore (Beginning of Line)", + "scope": "window" + }, + "gcode.lineNumberer.ignoreProgramNumbers": { + "type": "boolean", + "default": true, + "markdownDescription": "Ignore program numbers, e.g. `O12345`", + "scope": "window" + }, + "gcode.lineNumberer.matchLineNumber": { + "type": "boolean", + "default": false, + "markdownDescription": "When numbering, match N number to file's line number.", + "scope": "window" + } + } + }, + { + "title": "Views", + "order": 20, + "properties": { + "gcode.views.maxAutoRefresh": { + "type": "integer", + "default": "10000", + "markdownDescription": "Maximum Number of Lines in Editor to allow Auto Refresh", + "scope": "window" + }, + "gcode.views.navTree.autoRefresh": { + "type": "boolean", + "default": true, + "markdownDescription": "Enable G-Code Tree Auto Refresh", + "scope": "window" + }, + "gcode.views.stats.autoRefresh": { + "type": "boolean", + "default": false, + "markdownDescription": "Enable G-Code Stats Auto Refresh", + "scope": "window" + } + } + }, + { + "title": "Webviews", + "order": 30, + "properties": { + "gcode.webviews.enabled": { + "type": "boolean", + "default": true, + "markdownDescription": "Enable or Disable Webviews", + "scope": "window" + } } } - }, + ], "viewsContainers": { "activitybar": [ { From 9648b543fe762c332a84e4f34506a227f3a58c78 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 19:17:19 -0400 Subject: [PATCH 11/79] Working framework for calc sidebar view --- package.json | 8 +-- src/control.ts | 9 ++-- src/webviews/calc/calcWebviewView.ts | 43 +++++++++++---- src/webviews/codesWebview.ts | 54 ------------------- src/webviews/gWebview.ts | 4 +- src/webviews/gWebviewView.ts | 34 +++++++++++- src/webviews/webviewController.ts | 80 ---------------------------- 7 files changed, 75 insertions(+), 157 deletions(-) delete mode 100644 src/webviews/codesWebview.ts delete mode 100644 src/webviews/webviewController.ts diff --git a/package.json b/package.json index f8b76ea..c013d2d 100644 --- a/package.json +++ b/package.json @@ -342,10 +342,10 @@ "title": "Webviews", "order": 30, "properties": { - "gcode.webviews.enabled": { + "gcode.webviews.calc.enabled": { "type": "boolean", "default": true, - "markdownDescription": "Enable or Disable Webviews", + "markdownDescription": "Enable Milling / Turning Calculator", "scope": "window" } } @@ -380,7 +380,7 @@ "name": "Milling / Turning Calculator", "contextualTitle": "G-Code", "visibility": "collapsed", - "when": "gcode:webviews:enabled" + "when": "gcode:webviews:calc:enabled" } ] }, @@ -474,7 +474,7 @@ "group": "gcode" }, { - "when": "editorLangId == gcode && gcode:webviews:enabled", + "when": "editorLangId == gcode && gcode:webviews:calc:enabled", "command": "gcode.webviews.calc.show", "group": "gcode" }, diff --git a/src/control.ts b/src/control.ts index d514146..f9afc28 100644 --- a/src/control.ts +++ b/src/control.ts @@ -20,7 +20,7 @@ import { MachineTypeControl } from './util/machineType'; import { GCodeHoverControl } from './hovers/gcodeHoverControl'; import { defaults } from './util/configuration/defaults'; import { registerCommands } from './util/commands'; -import { WebviewController } from './webviews/webviewController'; +import { CalcWebviewView } from './webviews/calc/calcWebviewView'; const cfgUnits = 'general.units'; const cfgAutoRef = { @@ -40,14 +40,12 @@ export class Control { private static _unitsController: GCodeUnitsController | undefined; private static _stateController: StateControl; private static _hoverController: GCodeHoverControl; - private static _webviewController: WebviewController | undefined; // Views private static _statsView: StatsView | undefined; private static _navTree: NavTreeView | undefined; // Webviews - private static _codesWebview: CodesWebview | undefined; private static _calcWebviewView: CalcWebviewView | undefined; private static async _checkVersion() { @@ -156,8 +154,9 @@ export class Control { GCommands.ShowSupportGCode, ); - // Set Up Webviews - context.subscriptions.push((this._webviewController = new WebviewController())); + // Webviews + context.subscriptions.push((this._calcWebviewView = new CalcWebviewView())); + Logger.log('Done Initializing.'); } diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 81e1b84..c06998d 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -4,25 +4,48 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { commands, Disposable, Uri, Webview } from 'vscode'; +import { commands, ConfigurationChangeEvent, Disposable, Uri, Webview } from 'vscode'; import { Control } from '../../control'; -import { WebViewCommands } from '../../util/constants'; +import { configuration } from '../../util/configuration/config'; +import { defaults } from '../../util/configuration/defaults'; +import { Contexts, WebviewCommands, Webviews, WebviewTitles } from '../../util/constants'; import { GWebviewView } from '../gWebviewView'; -const CalcWebviewInfo = { - ViewId: 'gcode.webviews.calc', - Title: 'Milling / Turning Calculators', -}; - export class CalcWebviewView extends GWebviewView { constructor() { - super(CalcWebviewInfo.ViewId, CalcWebviewInfo.Title); + super(Webviews.CalcWebviewView, WebviewTitles.CalcWebviewView); + + if ((this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled)) { + void Control.setContext(Contexts.CalcWebviewViewEnabled, true); + } + + this._disposables.push(configuration.onDidChange(this.onConfigurationChanged, this)); + } + + dispose() { + super.dispose(); + } + + private onConfigurationChanged(e: ConfigurationChangeEvent) { + if (configuration.changed(e, `${this.id.slice(6)}.enabled`)) { + if (this._enabled) { + // Disable + void Control.setContext(Contexts.CalcWebviewViewEnabled, false); + } else { + // Enable + void Control.setContext(Contexts.CalcWebviewViewEnabled, true); + } + + // void this.refresh(); + + this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled; + } } - registerCommands(): Disposable[] { + protected registerCommands(): Disposable[] { return [ commands.registerCommand( - WebViewCommands.ShowCalcWebview, + WebviewCommands.ShowCalcWebview, () => { void this.show(); }, diff --git a/src/webviews/codesWebview.ts b/src/webviews/codesWebview.ts deleted file mode 100644 index d83b5be..0000000 --- a/src/webviews/codesWebview.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* eslint-disable max-len */ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ -/* --------------------------------------------------------------------------------------------- - * Copyright (c) Applied Eng & Design All rights reserved. - * Licensed under the MIT License. See License.md in the project root for license information. - * -------------------------------------------------------------------------------------------- */ - -'use strict'; - -import { Uri, Webview } from 'vscode'; -import { Control } from '../control'; -import { WebViewCommands } from '../util/constants'; -import { GWebview } from './gWebview'; - -const GCodesWebviewInfo = { - ViewId: 'gcode.webviews.codes', - Title: 'G/M Code Reference', -}; - -export class CodesWebview extends GWebview { - constructor() { - super(GCodesWebviewInfo.ViewId, GCodesWebviewInfo.Title, WebViewCommands.ShowCodesWebview); - } - - getHtml(webview: Webview): Promise { - // CSS styles - const stylesReset = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css'), - ); - - const stylesMain = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), - ); - - const nonce = this.getNonce(); - - return Promise.resolve(` - - - - - - - - - - - - G/M Codes - - Test - `); - } -} diff --git a/src/webviews/gWebview.ts b/src/webviews/gWebview.ts index a2861c7..84757d4 100644 --- a/src/webviews/gWebview.ts +++ b/src/webviews/gWebview.ts @@ -19,7 +19,7 @@ import { window, } from 'vscode'; import { configuration } from '../util/configuration/config'; -import { constants, WebViewCommands } from '../util/constants'; +import { constants, WebviewCommands } from '../util/constants'; import { Control } from '../control'; export abstract class GWebview implements Disposable { @@ -31,7 +31,7 @@ export abstract class GWebview implements Disposable { constructor( public readonly id: string, public readonly title: string, - showCommand: WebViewCommands, + showCommand: WebviewCommands, private readonly _column?: ViewColumn, ) { this._disposable = Disposable.from( diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 7937a72..bb04ef4 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -21,10 +21,11 @@ import { Logger } from '../util/logger'; export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected readonly _disposables: Disposable[] = []; + protected _enabled: boolean | undefined; private _view: WebviewView | undefined; private _title: string; - constructor(public readonly id: string, public readonly title: string) { + constructor(public readonly id: string, title: string) { this._title = title; this._disposables.push(window.registerWebviewViewProvider(id, this)); @@ -35,10 +36,39 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { Disposable.from(...this._disposables).dispose(); } + isEnabled(): boolean { + return this._enabled ?? false; + } + + disable() { + this._enabled = false; + } + get visible() { return this._view?.visible ?? false; } + get title(): string { + return this._view?.title ?? this._title; + } + + set title(title: string) { + this._title = title; + if (this._view) { + this._view.title = title; + } + } + + get description(): string | undefined { + return this._view?.description; + } + + set description(desc: string | undefined) { + if (this._view) { + this._view.description = desc; + } + } + async show(options?: { preserveFocus?: boolean }) { try { void (await commands.executeCommand(`${this.id}.focus`), options); @@ -57,7 +87,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { webviewView.webview.options = this.getWebviewOptions(); webviewView.title = this.title; - webviewView.webview.html = await this.getHtml(this._view.webview); + await this.refresh(); } protected async refresh(): Promise { diff --git a/src/webviews/webviewController.ts b/src/webviews/webviewController.ts deleted file mode 100644 index c818407..0000000 --- a/src/webviews/webviewController.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* --------------------------------------------------------------------------------------------- - * Copyright (c) Applied Eng & Design All rights reserved. - * Licensed under the MIT License. See License.md in the project root for license information. - * -------------------------------------------------------------------------------------------- */ -'use strict'; - -import { ConfigurationChangeEvent, Disposable } from 'vscode'; -import { Control } from '../control'; -import { configuration } from '../util/configuration/config'; -import { defaults } from '../util/configuration/defaults'; -import { Contexts } from '../util/constants'; -import { Logger } from '../util/logger'; -import { CalcWebviewView } from './calc/calcWebviewView'; - -export interface Webviews { - calcWebviewView?: CalcWebviewView | undefined; -} - -const wv = { - enabled: 'webviews.enabled', -}; - -export class WebviewController implements Disposable { - private _enabled: boolean; - private readonly _disposables: Disposable[] = []; - - // webviews - private _webviews: Webviews = { - calcWebviewView: undefined, - }; - - constructor() { - this._enabled = configuration.getParam(wv.enabled) ?? defaults.webviews.enabled; - - this._disposables.push(configuration.onDidChange(this.onConfigurationChanged, this)); - - if (this._enabled) { - Logger.log('Loading Webviews...'); - - void Control.setContext(Contexts.WebviewsEnabled, true); - - this._disposables.push(...this.buildWebviews()); - } else { - void Control.setContext(Contexts.WebviewsEnabled, false); - } - } - - dispose() { - Disposable.from(...this._disposables); - } - - private onConfigurationChanged(e: ConfigurationChangeEvent) { - if (configuration.changed(e, wv.enabled)) { - if (this._enabled) { - Logger.log('Webviews disabled...'); - void Control.setContext(Contexts.WebviewsEnabled, false); - // Disable webviews & dispose - Object.keys(this._webviews).forEach(key => { - this._webviews[key as keyof Webviews]?.dispose(); - this._webviews[key as keyof Webviews] = undefined; - }); - } else { - // Enable - Logger.log('Webviews enabled...'); - void Control.setContext(Contexts.WebviewsEnabled, true); - this._disposables.push(...this.buildWebviews()); - } - } - - this._enabled = configuration.getParam(wv.enabled) ?? defaults.webviews.enabled; - } - - private buildWebviews(): Disposable[] { - // Build webviews - return [ - // Calc Webview - (this._webviews.calcWebviewView = new CalcWebviewView()), - ]; - } -} From d1e55008d4a31d5e84762142121ff3781dada10c Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 19:39:54 -0400 Subject: [PATCH 12/79] Added webview constants --- src/util/configuration/defaults.ts | 8 ++++++-- src/util/constants.ts | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/util/configuration/defaults.ts b/src/util/configuration/defaults.ts index d10dd41..0ed9eb4 100644 --- a/src/util/configuration/defaults.ts +++ b/src/util/configuration/defaults.ts @@ -50,7 +50,9 @@ export interface GCodeConfiguration { }; webviews: { - enabled: boolean; + calc: { + enabled: boolean; + }; }; } @@ -90,6 +92,8 @@ export const defaults: GCodeConfiguration = { }, }, webviews: { - enabled: true, + calc: { + enabled: true, + }, }, }; diff --git a/src/util/constants.ts b/src/util/constants.ts index 31926f0..26241a6 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -74,7 +74,7 @@ export enum Contexts { MachineType = 'gcode:general:machineType', ViewsNavTreeEnabled = 'gcode:views:navTree:enabled', ViewsStatsEnabled = 'gcode:views:stats:enabled', - WebviewsEnabled = 'gcode:webviews:enabled', + CalcWebviewViewEnabled = 'gcode:webviews:calc:enabled', } export enum GCommands { @@ -86,13 +86,21 @@ export enum GCommands { RemoveLineNumbers = 'gcode.removeLineNumbers', } -export const enum ViewCommands { +export enum Webviews { + CalcWebviewView = 'gcode.webviews.calc', +} + +export enum WebviewTitles { + CalcWebviewView = 'Milling / Turning Calculators', +} + +export enum ViewCommands { RefreshStats = 'gcode.views.stats.refresh', RefreshTree = 'gcode.views.navTree.refresh', TreeSelect = 'gcode.views.navTree.select', } -export const enum WebViewCommands { +export enum WebviewCommands { ShowCodesWebview = 'gcode.webviews.codes.show', ShowCalcWebview = 'gcode.webviews.calc.show', } From 8b34dffba35cec86d2cd83d490e44f9ffe022329 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 23:46:51 -0400 Subject: [PATCH 13/79] Changed scripts. Added css-loader,sass-loader,sass,mini-css-extract-plugin dev deps --- .vscode/launch.json | 12 +- package-lock.json | 1021 ++++++++++++++++++++++--------------------- package.json | 15 +- webpack.config.js | 110 ++++- 4 files changed, 642 insertions(+), 516 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0db84af..a6d3134 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,7 +26,7 @@ "group": "Launch Extension", "order": 1 }, - "preLaunchTask": "npm: webpack", + "preLaunchTask": "npm: build", "skipFiles": [ "/**", "**/node_modules/**", @@ -55,7 +55,7 @@ "group": "Launch Extension", "order": 2 }, - "preLaunchTask": "npm: webpack", + "preLaunchTask": "npm: build", "skipFiles": [ "/**", "**/node_modules/**", @@ -82,10 +82,11 @@ "group": "Launch Extension", "order": 3 }, - "preLaunchTask": "npm: webpack", + "preLaunchTask": "npm: build", "skipFiles": [ "/**", - "**/node_modules/**" + "**/node_modules/**", + "**/resources/app/out/vs/**" ], "smartStep": true, "sourceMaps": true, @@ -127,7 +128,8 @@ ], "skipFiles": [ "/**", - "**/node_modules/**" + "**/node_modules/**", + "**/resources/app/out/vs/**" ], "presentation": { "hidden": false, diff --git a/package-lock.json b/package-lock.json index c007726..c748d50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,15 +22,18 @@ "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", "copy-webpack-plugin": "^11.0.0", + "css-loader": "^6.7.1", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-webpack-plugin": "^3.2.0", - "fork-ts-checker-webpack-plugin": "^7.2.13", "glob": "^8.0.3", + "mini-css-extract-plugin": "^2.6.1", "mocha": "^10.0.0", "prettier": "^2.7.1", + "sass": "^1.54.0", + "sass-loader": "^13.0.2", "shx": "^0.3.4", "ts-loader": "^9.4.1", "ts-node": "^10.9.1", @@ -53,103 +56,6 @@ "url": "https://github.com/sponsors/appliedengdesign" } }, - "node_modules/@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz", - "integrity": "sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -477,12 +383,6 @@ "integrity": "sha512-Sq1itGUKUX1ap7GgZlrzdBydjbsJL/NSQt/4wkAxUJ7/OS5c2WkoN6WSpWc2Yc5wtKMZOUA0VCs/j2XJadN3HA==", "dev": true }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, "node_modules/@types/vscode": { "version": "1.71.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", @@ -1547,22 +1447,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "node_modules/cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", - "dev": true, - "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -1583,6 +1467,44 @@ "node": ">= 8" } }, + "node_modules/css-loader": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz", + "integrity": "sha512-yB5CNFa14MbPJcomwNh3wLThtkZgcNyI2bNMRt8iE5Z8Vwl7f8vQXFAzn2HDOJvtDq2NTZBUGMSUNNyrv3/+cw==", + "dev": true, + "dependencies": { + "icss-utils": "^5.1.0", + "postcss": "^8.4.7", + "postcss-modules-extract-imports": "^3.0.0", + "postcss-modules-local-by-default": "^4.0.0", + "postcss-modules-scope": "^3.0.0", + "postcss-modules-values": "^4.0.0", + "postcss-value-parser": "^4.2.0", + "semver": "^7.3.5" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -1618,15 +1540,6 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "node_modules/deepmerge": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", - "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -1724,15 +1637,6 @@ "node": ">=4" } }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, "node_modules/es-abstract": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", @@ -1799,15 +1703,6 @@ "node": ">=6" } }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/eslint": { "version": "8.23.1", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.1.tgz", @@ -2456,60 +2351,6 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, - "node_modules/fork-ts-checker-webpack-plugin": { - "version": "7.2.13", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-7.2.13.tgz", - "integrity": "sha512-fR3WRkOb4bQdWB/y7ssDUlVdrclvwtyCUIHCfivAoYxq9dF7XfrDKbMdZIfwJ7hxIAqkYSGeU7lLJE6xrxIBdg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "chalk": "^4.1.2", - "chokidar": "^3.5.3", - "cosmiconfig": "^7.0.1", - "deepmerge": "^4.2.2", - "fs-extra": "^10.0.0", - "memfs": "^3.4.1", - "minimatch": "^3.0.4", - "node-abort-controller": "^3.0.1", - "schema-utils": "^3.1.1", - "semver": "^7.3.5", - "tapable": "^2.2.1" - }, - "engines": { - "node": ">=12.13.0", - "yarn": ">=1.0.0" - }, - "peerDependencies": { - "typescript": ">3.6.0", - "vue-template-compiler": "*", - "webpack": "^5.11.0" - }, - "peerDependenciesMeta": { - "vue-template-compiler": { - "optional": true - } - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fs-monkey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz", - "integrity": "sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==", - "dev": true - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2844,6 +2685,18 @@ "node": ">= 6" } }, + "node_modules/icss-utils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", + "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "dev": true, + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, "node_modules/ignore": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", @@ -2853,6 +2706,12 @@ "node": ">= 4" } }, + "node_modules/immutable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.1.0.tgz", + "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", + "dev": true + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -2997,12 +2856,6 @@ "node": ">= 0.10" } }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, "node_modules/is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -3283,7 +3136,8 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "peer": true }, "node_modules/js-yaml": { "version": "4.1.0", @@ -3327,18 +3181,6 @@ "json5": "lib/cli.js" } }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -3348,6 +3190,15 @@ "node": ">=0.10.0" } }, + "node_modules/klona": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.5.tgz", + "integrity": "sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -3361,12 +3212,6 @@ "node": ">= 0.8.0" } }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, "node_modules/listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", @@ -3461,18 +3306,6 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, - "node_modules/memfs": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.4.1.tgz", - "integrity": "sha512-1c9VPVvW5P7I85c35zAdEr1TD5+F11IToIHIlrVIcflfnzPkJa0ZoYEoEdYDP8KgPFoSZ/opDrUsAoZWym3mtw==", - "dev": true, - "dependencies": { - "fs-monkey": "1.0.3" - }, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -3534,6 +3367,78 @@ "node": ">= 0.6" } }, + "node_modules/mini-css-extract-plugin": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.6.1.tgz", + "integrity": "sha512-wd+SD57/K6DiV7jIR34P+s3uckTRuQvx0tKPcvjFlrEylk6P4mQ2KSWk1hblj1Kxaqok7LogKOieygXqBczNlg==", + "dev": true, + "dependencies": { + "schema-utils": "^4.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, + "node_modules/mini-css-extract-plugin/node_modules/ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/mini-css-extract-plugin/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/mini-css-extract-plugin/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/mini-css-extract-plugin/node_modules/schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3703,12 +3608,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node_modules/node-abort-controller": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz", - "integrity": "sha512-/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw==", - "dev": true - }, "node_modules/node-releases": { "version": "1.1.71", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", @@ -3860,24 +3759,6 @@ "node": ">=6" } }, - "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3929,6 +3810,12 @@ "node": "*" } }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -3941,6 +3828,120 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/postcss": { + "version": "8.4.14", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", + "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + } + ], + "dependencies": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-modules-extract-imports": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", + "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", + "dev": true, + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-modules-local-by-default": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz", + "integrity": "sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==", + "dev": true, + "dependencies": { + "icss-utils": "^5.0.0", + "postcss-selector-parser": "^6.0.2", + "postcss-value-parser": "^4.1.0" + }, + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-modules-scope": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz", + "integrity": "sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.4" + }, + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-modules-values": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz", + "integrity": "sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==", + "dev": true, + "dependencies": { + "icss-utils": "^5.0.0" + }, + "engines": { + "node": "^10 || ^12 || >= 14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -4243,6 +4244,61 @@ } ] }, + "node_modules/sass": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.54.0.tgz", + "integrity": "sha512-C4zp79GCXZfK0yoHZg+GxF818/aclhp9F48XBu/+bm9vXEVAYov9iU3FBVRMq3Hx3OA4jfKL+p2K9180mEh0xQ==", + "dev": true, + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/sass-loader": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-13.0.2.tgz", + "integrity": "sha512-BbiqbVmbfJaWVeOOAu2o7DhYWtcNmTfvroVgFXa6k2hHheMxNAeDHLNoDy/Q5aoaVlz0LH+MbMktKwm9vN/j8Q==", + "dev": true, + "dependencies": { + "klona": "^2.0.4", + "neo-async": "^2.6.2" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "fibers": ">= 3.1.0", + "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", + "sass": "^1.3.0", + "sass-embedded": "*", + "webpack": "^5.0.0" + }, + "peerDependenciesMeta": { + "fibers": { + "optional": true + }, + "node-sass": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + } + } + }, "node_modules/schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -4423,6 +4479,15 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -4820,15 +4885,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/unzipper": { "version": "0.10.11", "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.11.tgz", @@ -5191,15 +5247,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -5294,84 +5341,6 @@ "resolved": "https://registry.npmjs.org/@appliedengdesign/gcode-reference/-/gcode-reference-0.0.7.tgz", "integrity": "sha512-U6/wKf4xMU901BIEg/MDXOG+Zz30KDoUYS8cynSfekyBP0FwfGllw5WrHlRUOQLZ1Jesu+zeNYPK7KVkUDyCTw==" }, - "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.16.7" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/highlight": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz", - "integrity": "sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -5649,12 +5618,6 @@ "integrity": "sha512-Sq1itGUKUX1ap7GgZlrzdBydjbsJL/NSQt/4wkAxUJ7/OS5c2WkoN6WSpWc2Yc5wtKMZOUA0VCs/j2XJadN3HA==", "dev": true }, - "@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, "@types/vscode": { "version": "1.71.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", @@ -6444,19 +6407,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", - "dev": true, - "requires": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - } - }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -6474,6 +6424,28 @@ "which": "^2.0.1" } }, + "css-loader": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz", + "integrity": "sha512-yB5CNFa14MbPJcomwNh3wLThtkZgcNyI2bNMRt8iE5Z8Vwl7f8vQXFAzn2HDOJvtDq2NTZBUGMSUNNyrv3/+cw==", + "dev": true, + "requires": { + "icss-utils": "^5.1.0", + "postcss": "^8.4.7", + "postcss-modules-extract-imports": "^3.0.0", + "postcss-modules-local-by-default": "^4.0.0", + "postcss-modules-scope": "^3.0.0", + "postcss-modules-values": "^4.0.0", + "postcss-value-parser": "^4.2.0", + "semver": "^7.3.5" + } + }, + "cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true + }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -6498,12 +6470,6 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "deepmerge": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", - "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", - "dev": true - }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -6580,15 +6546,6 @@ "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", "dev": true }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, "es-abstract": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", @@ -6640,12 +6597,6 @@ "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, "eslint": { "version": "8.23.1", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.1.tgz", @@ -7148,43 +7099,6 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, - "fork-ts-checker-webpack-plugin": { - "version": "7.2.13", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-7.2.13.tgz", - "integrity": "sha512-fR3WRkOb4bQdWB/y7ssDUlVdrclvwtyCUIHCfivAoYxq9dF7XfrDKbMdZIfwJ7hxIAqkYSGeU7lLJE6xrxIBdg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "chalk": "^4.1.2", - "chokidar": "^3.5.3", - "cosmiconfig": "^7.0.1", - "deepmerge": "^4.2.2", - "fs-extra": "^10.0.0", - "memfs": "^3.4.1", - "minimatch": "^3.0.4", - "node-abort-controller": "^3.0.1", - "schema-utils": "^3.1.1", - "semver": "^7.3.5", - "tapable": "^2.2.1" - } - }, - "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs-monkey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz", - "integrity": "sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==", - "dev": true - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -7429,12 +7343,25 @@ "debug": "4" } }, + "icss-utils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", + "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", + "dev": true, + "requires": {} + }, "ignore": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true }, + "immutable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.1.0.tgz", + "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", + "dev": true + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -7542,12 +7469,6 @@ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", "dev": true }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, "is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -7738,7 +7659,8 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "peer": true }, "js-yaml": { "version": "4.1.0", @@ -7776,22 +7698,18 @@ "minimist": "^1.2.0" } }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, + "klona": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.5.tgz", + "integrity": "sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==", + "dev": true + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -7802,12 +7720,6 @@ "type-check": "~0.4.0" } }, - "lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, "listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", @@ -7884,15 +7796,6 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, - "memfs": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.4.1.tgz", - "integrity": "sha512-1c9VPVvW5P7I85c35zAdEr1TD5+F11IToIHIlrVIcflfnzPkJa0ZoYEoEdYDP8KgPFoSZ/opDrUsAoZWym3mtw==", - "dev": true, - "requires": { - "fs-monkey": "1.0.3" - } - }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -7936,6 +7839,56 @@ "mime-db": "1.47.0" } }, + "mini-css-extract-plugin": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.6.1.tgz", + "integrity": "sha512-wd+SD57/K6DiV7jIR34P+s3uckTRuQvx0tKPcvjFlrEylk6P4mQ2KSWk1hblj1Kxaqok7LogKOieygXqBczNlg==", + "dev": true, + "requires": { + "schema-utils": "^4.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + } + } + } + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -8073,12 +8026,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node-abort-controller": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz", - "integrity": "sha512-/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw==", - "dev": true - }, "node-releases": { "version": "1.1.71", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", @@ -8188,18 +8135,6 @@ "callsites": "^3.0.0" } }, - "parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - } - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -8236,12 +8171,89 @@ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, + "postcss": { + "version": "8.4.14", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", + "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "dev": true, + "requires": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "dependencies": { + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true + } + } + }, + "postcss-modules-extract-imports": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", + "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", + "dev": true, + "requires": {} + }, + "postcss-modules-local-by-default": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz", + "integrity": "sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==", + "dev": true, + "requires": { + "icss-utils": "^5.0.0", + "postcss-selector-parser": "^6.0.2", + "postcss-value-parser": "^4.1.0" + } + }, + "postcss-modules-scope": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz", + "integrity": "sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.4" + } + }, + "postcss-modules-values": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz", + "integrity": "sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==", + "dev": true, + "requires": { + "icss-utils": "^5.0.0" + } + }, + "postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + }, + "postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -8438,6 +8450,27 @@ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, + "sass": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.54.0.tgz", + "integrity": "sha512-C4zp79GCXZfK0yoHZg+GxF818/aclhp9F48XBu/+bm9vXEVAYov9iU3FBVRMq3Hx3OA4jfKL+p2K9180mEh0xQ==", + "dev": true, + "requires": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + } + }, + "sass-loader": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-13.0.2.tgz", + "integrity": "sha512-BbiqbVmbfJaWVeOOAu2o7DhYWtcNmTfvroVgFXa6k2hHheMxNAeDHLNoDy/Q5aoaVlz0LH+MbMktKwm9vN/j8Q==", + "dev": true, + "requires": { + "klona": "^2.0.4", + "neo-async": "^2.6.2" + } + }, "schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -8568,6 +8601,12 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true + }, "source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -8839,12 +8878,6 @@ "which-boxed-primitive": "^1.0.2" } }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, "unzipper": { "version": "0.10.11", "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.11.tgz", @@ -9104,12 +9137,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true - }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index c013d2d..d258230 100644 --- a/package.json +++ b/package.json @@ -583,13 +583,15 @@ }, "scripts": { "analyze:bundle": "webpack --env analyzeBundle", - "build": "webpack -mode development", - "bundle": "webpack --mode production", + "build": "webpack --mode development", + "build:extension": "webpack --mode development --config-name extension", + "build:webviews": "webpack --mode development --config-name webviews", + "bundle": "npm run clean && webpack --mode production --devtool hidden-source-map", "clean": "shx rm -rf out/* && rm -rf dist/*", "compile": "tsc -p ./", "lint": "eslint --ext .ts src/**/*.ts --cache", - "watch": "tsc -watch -p ./", "pack": "vsce package", + "package": "npm run clean && webpack --mode production --devtool hidden-source-map", "pretest": "npm run compile", "pretty": "prettier --config .prettierrc --loglevel warn .", "pub": "vsce publish", @@ -597,8 +599,7 @@ "test": "node ./out/test/runTests.js", "test:unit": "SET TS_NODE_PROJECT=./tsconfig.tests.json && mocha -r ts-node/register test/unit/*.test.ts", "vscode:prepublish": "npm run bundle", - "webpack": "webpack --mode development", - "webpack-dev": "webpack --mode development --watch" + "watch": "webpack --watch -mode deveopment" }, "devDependencies": { "@types/chai": "^4.3.3", @@ -610,14 +611,18 @@ "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", "copy-webpack-plugin": "^11.0.0", + "css-loader": "^6.7.1", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-webpack-plugin": "^3.2.0", "glob": "^8.0.3", + "mini-css-extract-plugin": "^2.6.1", "mocha": "^10.0.0", "prettier": "^2.7.1", + "sass": "^1.54.0", + "sass-loader": "^13.0.2", "shx": "^0.3.4", "ts-loader": "^9.4.1", "ts-node": "^10.9.1", diff --git a/webpack.config.js b/webpack.config.js index 9f53a11..ec1f182 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,11 +7,27 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const path = require('path'); // @ts-check /** @typedef {import('webpack').Configuration} */ +module.exports = function (env, argv) { + const mode = argv.mode || 'none'; + + env = { + analyzeBundle: false, + analyzeDeps: false, + ...env, + }; + + return [ + getExtensionConfig(mode, env), + getWebviewsConfig(mode, env), + ]; +}; + function getExtensionConfig(mode, env) { const plugins = []; @@ -36,7 +52,6 @@ function getExtensionConfig(mode, env) { filename: 'extension.js', libraryTarget: 'commonjs2', devtoolFallbackModuleFilenameTemplate: '../[resource-path]', - clean: true, }, devtool: 'source-map', @@ -48,6 +63,7 @@ function getExtensionConfig(mode, env) { resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], + mainFields: ['browser', 'module', 'main'], }, module: { @@ -67,6 +83,10 @@ function getExtensionConfig(mode, env) { plugins: plugins, + infrastructureLogging: { + level: 'log', + }, + stats: { preset: 'error-warnings', assets: true, @@ -81,14 +101,86 @@ function getExtensionConfig(mode, env) { return config; } -module.exports = function (env, argv) { - const mode = argv.mode || 'none'; +function getWebviewsConfig(mode, env) { + const basePath = path.join(__dirname, 'src', 'webviews', 'apps'); + const plugins = []; - env = { - analyzeBundle: false, - analyzeDeps: false, - ...env, + plugins.push( + new ESLintPlugin({ + extensions: ['ts'] + }) + ); + + plugins.push( + new MiniCssExtractPlugin({ + filename: '[name].css', + }) + ); + + const config = { + name: 'webviews', + mode: mode, + target: 'web', + devtool: 'source-map', + context: basePath, + + entry: { + 'calc/calc': './calc/calc.ts' + }, + + output: { + filename: '[name].js', + path: path.join(__dirname, 'dist', 'webviews'), + publicPath: '#{root}/dist/webviews/[name]', + }, + + module: { + rules: [ + { + test: /\.scss$/, + use: [ + { + loader: MiniCssExtractPlugin.loader, + }, + { + loader: 'css-loader', + options: { + sourceMap: true, + url: false, + }, + }, + { + loader: 'sass-loader', + options: { + sourceMap: true, + } + } + ], + exclude: /node_modules/, + }, + ], + }, + + resolve: { + extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], + }, + + plugins: plugins, + + infrastructureLogging: { + level: 'log', + }, + + stats: { + preset: 'error-warnings', + assets: true, + colors: true, + env: true, + errorsCount: true, + warningsCount: true, + timings: true, + }, }; - return getExtensionConfig(mode, env); -}; + return config; +} \ No newline at end of file From 41fa5a7131c856fd38368e006c9385390ae04965 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 23:48:32 -0400 Subject: [PATCH 14/79] Moved css into src/webviews/apps/shared. Calc.ts placeholder --- src/webviews/apps/calc/calc.scss | 2 ++ src/webviews/apps/calc/calc.ts | 5 ++++ .../webviews/apps/shared/reset.scss | 0 .../webviews/apps/shared/vscode.scss | 0 src/webviews/calc/calcWebviewView.ts | 23 ++++++++++--------- 5 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 src/webviews/apps/calc/calc.scss create mode 100644 src/webviews/apps/calc/calc.ts rename resources/webviews/css/reset.css => src/webviews/apps/shared/reset.scss (100%) rename resources/webviews/css/vscode.css => src/webviews/apps/shared/vscode.scss (100%) diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss new file mode 100644 index 0000000..70b1802 --- /dev/null +++ b/src/webviews/apps/calc/calc.scss @@ -0,0 +1,2 @@ +@import '../shared/reset'; +@import '../shared/vscode'; diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts new file mode 100644 index 0000000..cabdd4d --- /dev/null +++ b/src/webviews/apps/calc/calc.ts @@ -0,0 +1,5 @@ +import './calc.scss'; + +export class CalcApp {} + +new CalcApp(); diff --git a/resources/webviews/css/reset.css b/src/webviews/apps/shared/reset.scss similarity index 100% rename from resources/webviews/css/reset.css rename to src/webviews/apps/shared/reset.scss diff --git a/resources/webviews/css/vscode.css b/src/webviews/apps/shared/vscode.scss similarity index 100% rename from resources/webviews/css/vscode.css rename to src/webviews/apps/shared/vscode.scss diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index c06998d..d2ef9fc 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -56,12 +56,8 @@ export class CalcWebviewView extends GWebviewView { async getHtml(webview: Webview): Promise { // CSS styles - const stylesReset = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css'), - ); - const stylesMain = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), + Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews', 'calc', 'calc.css'), ); // vscode-webview-ui-toolkit @@ -76,6 +72,10 @@ export class CalcWebviewView extends GWebviewView { ), ); + const calcJsUri = webview.asWebviewUri( + Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews', 'calc', 'calc.js'), + ); + const nonce = this.getNonce(); return Promise.resolve(` @@ -90,20 +90,21 @@ export class CalcWebviewView extends GWebviewView { + - - Calc + ${this.title} - MILLING - TURNING + Cutting Speed + Feed Rate - - Calculate> + + + Calculate RPM
From 26a0d6b21e157dc7859648e535f47d9f161cca6a Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 23:50:09 -0400 Subject: [PATCH 15/79] Changed name of calculator --- package.json | 4 ++-- src/util/constants.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d258230..fcfc13d 100644 --- a/package.json +++ b/package.json @@ -345,7 +345,7 @@ "gcode.webviews.calc.enabled": { "type": "boolean", "default": true, - "markdownDescription": "Enable Milling / Turning Calculator", + "markdownDescription": "Enable Machining Calculator", "scope": "window" } } @@ -377,7 +377,7 @@ { "type": "webview", "id": "gcode.webviews.calc", - "name": "Milling / Turning Calculator", + "name": "Machining Calculator", "contextualTitle": "G-Code", "visibility": "collapsed", "when": "gcode:webviews:calc:enabled" diff --git a/src/util/constants.ts b/src/util/constants.ts index 26241a6..2554467 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -91,7 +91,7 @@ export enum Webviews { } export enum WebviewTitles { - CalcWebviewView = 'Milling / Turning Calculators', + CalcWebviewView = 'Machining Calculators', } export enum ViewCommands { From 15391af00da4ccfdb3069e57beddf111dec70d0d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 25 Jul 2022 22:09:54 -0400 Subject: [PATCH 16/79] Working test side view for calculators --- package.json | 5 +--- src/control.ts | 2 ++ src/webviews/calcWebviewView.ts | 52 +++++++++++++++++++++++++++++++++ src/webviews/gWebviewView.ts | 40 +++---------------------- 4 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 src/webviews/calcWebviewView.ts diff --git a/package.json b/package.json index fcfc13d..a973ac2 100644 --- a/package.json +++ b/package.json @@ -377,10 +377,7 @@ { "type": "webview", "id": "gcode.webviews.calc", - "name": "Machining Calculator", - "contextualTitle": "G-Code", - "visibility": "collapsed", - "when": "gcode:webviews:calc:enabled" + "name": "Milling / Turning Calculator" } ] }, diff --git a/src/control.ts b/src/control.ts index f9afc28..5af770d 100644 --- a/src/control.ts +++ b/src/control.ts @@ -164,6 +164,8 @@ export class Control { Logger.log('Terminating Extension...'); // Dispose Views + this._calcWebviewView?.dispose(); + this._statsView?.dispose(); this._statsView?.dispose(); this._navTree?.dispose(); diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calcWebviewView.ts new file mode 100644 index 0000000..2b0e76f --- /dev/null +++ b/src/webviews/calcWebviewView.ts @@ -0,0 +1,52 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +import { Uri, Webview } from 'vscode'; +import { Control } from '../control'; +import { GWebviewView } from './gWebviewView'; + +const CalcWebviewInfo = { + ViewId: 'gcode.webviews.calc', + Title: 'Milling / Turning Calculators', +}; + +export class CalcWebviewView extends GWebviewView { + constructor() { + super(CalcWebviewInfo.ViewId, CalcWebviewInfo.Title); + } + + async getHtml(webview: Webview): Promise { + // CSS styles + const stylesReset = webview.asWebviewUri( + Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css'), + ); + + const stylesMain = webview.asWebviewUri( + Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), + ); + + const nonce = this.getNonce(); + + return Promise.resolve(` + + + + + + + + + + + + Calc + + Calculators + `); + } +} diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index bb04ef4..0c6fc34 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -21,54 +21,23 @@ import { Logger } from '../util/logger'; export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected readonly _disposables: Disposable[] = []; - protected _enabled: boolean | undefined; private _view: WebviewView | undefined; private _title: string; - constructor(public readonly id: string, title: string) { + constructor(public readonly id: string, public readonly title: string) { this._title = title; this._disposables.push(window.registerWebviewViewProvider(id, this)); - this._disposables.push(...this.registerCommands()); } dispose() { Disposable.from(...this._disposables).dispose(); } - isEnabled(): boolean { - return this._enabled ?? false; - } - - disable() { - this._enabled = false; - } - get visible() { return this._view?.visible ?? false; } - get title(): string { - return this._view?.title ?? this._title; - } - - set title(title: string) { - this._title = title; - if (this._view) { - this._view.title = title; - } - } - - get description(): string | undefined { - return this._view?.description; - } - - set description(desc: string | undefined) { - if (this._view) { - this._view.description = desc; - } - } - async show(options?: { preserveFocus?: boolean }) { try { void (await commands.executeCommand(`${this.id}.focus`), options); @@ -87,7 +56,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { webviewView.webview.options = this.getWebviewOptions(); webviewView.title = this.title; - await this.refresh(); + webviewView.webview.html = await this.getHtml(this._view.webview); } protected async refresh(): Promise { @@ -98,8 +67,6 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected abstract getHtml(webview: Webview): Promise; - protected abstract registerCommands(): Disposable[]; - protected getNonce(): string { let text = ''; @@ -114,7 +81,8 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected getWebviewOptions(): WebviewOptions { return { enableScripts: true, - localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], + // enableCommandUris: true, + localResourceRoots: [Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews')], }; } } From df9cf079800c094bd24d825e3160f8f2a1cc78df Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 00:25:14 -0400 Subject: [PATCH 17/79] Testing tabs & ui kit --- src/webviews/calcWebviewView.ts | 36 ++++++++++++++++++++++++++++++--- src/webviews/gWebviewView.ts | 3 +-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calcWebviewView.ts index 2b0e76f..00862db 100644 --- a/src/webviews/calcWebviewView.ts +++ b/src/webviews/calcWebviewView.ts @@ -4,7 +4,8 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { Uri, Webview } from 'vscode'; +import { TextDecoder } from 'util'; +import { Uri, Webview, workspace } from 'vscode'; import { Control } from '../control'; import { GWebviewView } from './gWebviewView'; @@ -28,25 +29,54 @@ export class CalcWebviewView extends GWebviewView { Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), ); + // vscode-webview-ui-toolkit + const toolkitUri = webview.asWebviewUri( + Uri.joinPath( + Control.context.extensionUri, + 'node_modules', + '@vscode', + 'webview-ui-toolkit', + 'dist', + 'toolkit.js', + ), + ); + const nonce = this.getNonce(); + // const body = new TextDecoder('utf8').decode(await workspace.fs.readFile()) + return Promise.resolve(` + + Calc - Calculators + + + MILLING + TURNING + + + + Calculate> + +
+
+ +
+ `); } } diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 0c6fc34..36dc8ab 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -81,8 +81,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected getWebviewOptions(): WebviewOptions { return { enableScripts: true, - // enableCommandUris: true, - localResourceRoots: [Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews')], + localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], }; } } From d928db3fa7d5d3556ae7781dcda23e61ff13e24d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 19:17:19 -0400 Subject: [PATCH 18/79] Working framework for calc sidebar view --- package.json | 7 +++++-- src/webviews/gWebviewView.ts | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a973ac2..d258230 100644 --- a/package.json +++ b/package.json @@ -345,7 +345,7 @@ "gcode.webviews.calc.enabled": { "type": "boolean", "default": true, - "markdownDescription": "Enable Machining Calculator", + "markdownDescription": "Enable Milling / Turning Calculator", "scope": "window" } } @@ -377,7 +377,10 @@ { "type": "webview", "id": "gcode.webviews.calc", - "name": "Milling / Turning Calculator" + "name": "Milling / Turning Calculator", + "contextualTitle": "G-Code", + "visibility": "collapsed", + "when": "gcode:webviews:calc:enabled" } ] }, diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 36dc8ab..a55a2b6 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -21,10 +21,11 @@ import { Logger } from '../util/logger'; export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected readonly _disposables: Disposable[] = []; + protected _enabled: boolean | undefined; private _view: WebviewView | undefined; private _title: string; - constructor(public readonly id: string, public readonly title: string) { + constructor(public readonly id: string, title: string) { this._title = title; this._disposables.push(window.registerWebviewViewProvider(id, this)); @@ -34,10 +35,39 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { Disposable.from(...this._disposables).dispose(); } + isEnabled(): boolean { + return this._enabled ?? false; + } + + disable() { + this._enabled = false; + } + get visible() { return this._view?.visible ?? false; } + get title(): string { + return this._view?.title ?? this._title; + } + + set title(title: string) { + this._title = title; + if (this._view) { + this._view.title = title; + } + } + + get description(): string | undefined { + return this._view?.description; + } + + set description(desc: string | undefined) { + if (this._view) { + this._view.description = desc; + } + } + async show(options?: { preserveFocus?: boolean }) { try { void (await commands.executeCommand(`${this.id}.focus`), options); @@ -56,7 +86,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { webviewView.webview.options = this.getWebviewOptions(); webviewView.title = this.title; - webviewView.webview.html = await this.getHtml(this._view.webview); + await this.refresh(); } protected async refresh(): Promise { From 2a257b8242e8c0b165cc83b6b9abcbc52c49c289 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 19:39:54 -0400 Subject: [PATCH 19/79] Added webview constants --- src/util/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/constants.ts b/src/util/constants.ts index 2554467..26241a6 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -91,7 +91,7 @@ export enum Webviews { } export enum WebviewTitles { - CalcWebviewView = 'Machining Calculators', + CalcWebviewView = 'Milling / Turning Calculators', } export enum ViewCommands { From 39e5aa8875f7148caf1fb39bbf2018fa23480cc8 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 26 Jul 2022 23:50:09 -0400 Subject: [PATCH 20/79] Changed name of calculator --- package.json | 4 ++-- src/util/constants.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d258230..fcfc13d 100644 --- a/package.json +++ b/package.json @@ -345,7 +345,7 @@ "gcode.webviews.calc.enabled": { "type": "boolean", "default": true, - "markdownDescription": "Enable Milling / Turning Calculator", + "markdownDescription": "Enable Machining Calculator", "scope": "window" } } @@ -377,7 +377,7 @@ { "type": "webview", "id": "gcode.webviews.calc", - "name": "Milling / Turning Calculator", + "name": "Machining Calculator", "contextualTitle": "G-Code", "visibility": "collapsed", "when": "gcode:webviews:calc:enabled" diff --git a/src/util/constants.ts b/src/util/constants.ts index 26241a6..2554467 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -91,7 +91,7 @@ export enum Webviews { } export enum WebviewTitles { - CalcWebviewView = 'Milling / Turning Calculators', + CalcWebviewView = 'Machining Calculators', } export enum ViewCommands { From 32c20e23ab254b95da0a814ae559b5cc28d90cd7 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 28 Jul 2022 17:11:38 -0400 Subject: [PATCH 21/79] Updated launch and tasks Added extensions config --- .vscode/extensions.json | 7 +++++++ .vscode/launch.json | 7 +++---- .vscode/settings.json | 6 +++--- .vscode/tasks.json | 39 ++++++++++++--------------------------- 4 files changed, 25 insertions(+), 34 deletions(-) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3544d6d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "amodio.tsl-problem-matcher", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index a6d3134..90ee5bb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,4 +1,3 @@ -// A launch configuration that launches the extension inside a new window { "version": "0.2.0", "configurations": [ @@ -34,7 +33,7 @@ ], "smartStep": true, "sourceMaps": true, - "trace": true, + "trace": true }, { "name": "Run G-Code (Sandbox)", @@ -104,9 +103,9 @@ "outFiles": [ "${workspaceFolder}/dist/**/*.js" ], - "preLaunchTask": "npm: webpack", + "preLaunchTask": "npm: build", "presentation": { - "hidden": false, + "hidden": true, "group": "Web Extension", "order": 1 } diff --git a/.vscode/settings.json b/.vscode/settings.json index 8fb0f2b..3b7675b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,11 @@ { "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files + "out": false }, "search.exclude": { - "out": true // set this to false to include "out" folder in search results + "out": true, + "dist": true }, - // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 577788d..b46001f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,39 +1,24 @@ { "version": "2.0.0", + "presentation": { + "echo": false, + "reveal": "always", + "focus": false, + "panel": "dedicated", + "showReuseMessage": false, + "clear": false + }, "tasks": [ { "type": "npm", - "script": "watch", - "problemMatcher": "$tsc-watch", - "isBackground": true, - "presentation": { - "echo": true, - "reveal": "never", - "focus": false, - "panel": "shared", - "showReuseMessage": true, - "clear": false - }, + "script": "build", + "problemMatcher": [ + "$ts-webpack", + ], "group": { "kind": "build", "isDefault": true } - }, - { - "type": "npm", - "script": "webpack", - "problemMatcher": "$tsc-watch", - "label": "npm: webpack", - "detail": "webpack --mode development", - "isBackground": true, - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared", - "showReuseMessage": true, - "clear": false - } } ] } \ No newline at end of file From ab454a53ad5f77a044c545625e5d92390d8a2937 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 01:44:47 -0400 Subject: [PATCH 22/79] Working webview bundling --- webpack.config.js | 115 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 17 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index ec1f182..f393023 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,13 +5,18 @@ 'use strict'; +// @ts-check +/** @typedef {import('webpack').Configuration} */ + const ESLintPlugin = require('eslint-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); const path = require('path'); +const fs = require('fs'); + + -// @ts-check -/** @typedef {import('webpack').Configuration} */ module.exports = function (env, argv) { const mode = argv.mode || 'none'; @@ -93,6 +98,7 @@ function getExtensionConfig(mode, env) { colors: true, env: true, errorsCount: true, + errorDetails: true, warningsCount: true, timings: true, }, @@ -102,20 +108,19 @@ function getExtensionConfig(mode, env) { } function getWebviewsConfig(mode, env) { - const basePath = path.join(__dirname, 'src', 'webviews', 'apps'); + const basePath = path.resolve(__dirname, 'src', 'webviews', 'apps'); + const outPath = path.resolve(__dirname, 'dist', 'webviews'); const plugins = []; + const entries = getWebviewEntries(basePath); + plugins.push( new ESLintPlugin({ extensions: ['ts'] }) ); - plugins.push( - new MiniCssExtractPlugin({ - filename: '[name].css', - }) - ); + plugins.push(...getWebviewPlugins(outPath, basePath, entries)); const config = { name: 'webviews', @@ -124,23 +129,37 @@ function getWebviewsConfig(mode, env) { devtool: 'source-map', context: basePath, - entry: { - 'calc/calc': './calc/calc.ts' - }, + entry: entries, output: { - filename: '[name].js', - path: path.join(__dirname, 'dist', 'webviews'), - publicPath: '#{root}/dist/webviews/[name]', + path: path.resolve(__dirname, 'dist', 'webviews'), + filename: `[name]/[name][ext]`, + publicPath: '{root}/dist/webviews/', + clean: true, }, + plugins: plugins, + module: { rules: [ { - test: /\.scss$/, + exclude: /\.d.ts$/i, + test: /.tsx?$/, + use: [ + { + loader: 'ts-loader', + }, + ], + exclude: /node_modules/, + }, + { + test: /\.s[ca]ss$/i, use: [ { loader: MiniCssExtractPlugin.loader, + options: { + //esModule: false, + } }, { loader: 'css-loader', @@ -158,6 +177,10 @@ function getWebviewsConfig(mode, env) { ], exclude: /node_modules/, }, + { + test: /\.(woff|woff2|eot|ttf|otf)$/, + type: 'asset/resource', + }, ], }, @@ -165,8 +188,6 @@ function getWebviewsConfig(mode, env) { extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], }, - plugins: plugins, - infrastructureLogging: { level: 'log', }, @@ -177,10 +198,70 @@ function getWebviewsConfig(mode, env) { colors: true, env: true, errorsCount: true, + errorDetails: true, warningsCount: true, timings: true, }, }; return config; +} + +function getWebviewEntries(_path) { + // Get Entries from apps path + const entries = fs.readdirSync(_path, { withFileTypes: true }) + .filter(dirent => dirent.isDirectory()) + .filter(dirent => dirent.name !== 'shared') + .map(dirent => dirent.name) + .reduce((result, item, index, array) => { + // App TS File + result[item] = { import: [`./${item}/${item}.ts`, `./${item}/${item}.scss` ], filename: `${item}/${item}.js` }; + + // App SCSS File + //result[`${item}.scss`] = { import: `./${item}/${item}.scss`, filename: `${item}/${item}.css` }; + + return result; + }, {}); + + return entries; +} + +function getWebviewPlugins(_outPath, _basePath, entries) { + const webviewPlugins = []; + + Object.keys(entries).forEach(entry => { + if (entry !== undefined && (/\.s[ca]ss$/).test(entry)) { + const name = entry.split('.').shift(); + if (name) { + webviewPlugins.push( + new MiniCssExtractPlugin({ + filename: path.join(name, `${name}.css`), + chunkFilename: '[id].css', + }) + ); + } + + return; + } + webviewPlugins.push( + new HtmlWebpackPlugin({ + template: path.resolve(_basePath, entry, `${entry}.html`), + inject: 'head', + filename: path.resolve(_outPath, `${entry}`, `${entry}.html`), + }), + ); + + webviewPlugins.push( + new MiniCssExtractPlugin({ + filename: `${entry}/${entry}.css`, + + }) + ); + + return; + }); + + //console.log(webviewPlugins); + //process.exit(1); + return webviewPlugins; } \ No newline at end of file From 53ec7726926c7d360a11d9a47ecea3cedd77b7e4 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 01:45:57 -0400 Subject: [PATCH 23/79] Initial html framework --- src/webviews/apps/calc/calc.html | 17 +++++++++++++++++ src/webviews/apps/shared/partials/head.html | 8 ++++++++ src/webviews/apps/shared/partials/tail.html | 1 + 3 files changed, 26 insertions(+) create mode 100644 src/webviews/apps/calc/calc.html create mode 100644 src/webviews/apps/shared/partials/head.html create mode 100644 src/webviews/apps/shared/partials/tail.html diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html new file mode 100644 index 0000000..7e5d345 --- /dev/null +++ b/src/webviews/apps/calc/calc.html @@ -0,0 +1,17 @@ +<%= require('html-loader?{"esModule":false}!../shared/partials/head.html') %> + + + Cutting Speed + Feed Rate + + + + + Calculate RPM + +
+
+ +
+ +<%= require('html-loader?{"esModule":false}!../shared/partials/tail.html') %> \ No newline at end of file diff --git a/src/webviews/apps/shared/partials/head.html b/src/webviews/apps/shared/partials/head.html new file mode 100644 index 0000000..363df83 --- /dev/null +++ b/src/webviews/apps/shared/partials/head.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/webviews/apps/shared/partials/tail.html b/src/webviews/apps/shared/partials/tail.html new file mode 100644 index 0000000..62d09b8 --- /dev/null +++ b/src/webviews/apps/shared/partials/tail.html @@ -0,0 +1 @@ + \ No newline at end of file From 30157cc81ede834d1dd64b152f45b7f80351eaea Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 01:46:37 -0400 Subject: [PATCH 24/79] Moved getNonce functon to helpers --- src/webviews/calc/calcWebviewView.ts | 3 ++- src/webviews/gWebviewView.ts | 12 ++---------- src/webviews/helpers.ts | 11 +++++++++++ 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 src/webviews/helpers.ts diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index d2ef9fc..fb87189 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -10,6 +10,7 @@ import { configuration } from '../../util/configuration/config'; import { defaults } from '../../util/configuration/defaults'; import { Contexts, WebviewCommands, Webviews, WebviewTitles } from '../../util/constants'; import { GWebviewView } from '../gWebviewView'; +import { getNonce } from '../helpers'; export class CalcWebviewView extends GWebviewView { constructor() { @@ -76,7 +77,7 @@ export class CalcWebviewView extends GWebviewView { Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews', 'calc', 'calc.js'), ); - const nonce = this.getNonce(); + const nonce = getNonce(); return Promise.resolve(` diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index a55a2b6..e1de998 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -97,20 +97,12 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected abstract getHtml(webview: Webview): Promise; - protected getNonce(): string { - let text = ''; - - const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - for (let i = 0; i < 32; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); - } - return text; - } + protected abstract registerCommands(): Disposable[]; protected getWebviewOptions(): WebviewOptions { return { enableScripts: true, + enableCommandUris: true, localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], }; } diff --git a/src/webviews/helpers.ts b/src/webviews/helpers.ts new file mode 100644 index 0000000..2313d4a --- /dev/null +++ b/src/webviews/helpers.ts @@ -0,0 +1,11 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +import crypto from 'crypto'; + +export function getNonce(): string { + return crypto.randomBytes(16).toString('base64'); +} From f16773b9df9f625c3d7a734323a60989956e91dd Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 01:47:07 -0400 Subject: [PATCH 25/79] testing empty class added --- src/webviews/apps/calc/calc.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index cabdd4d..b6ccff8 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -1,5 +1,9 @@ -import './calc.scss'; +export class CalcApp { + private btn: string; -export class CalcApp {} + constructor() { + this.btn = 'test'; + } +} new CalcApp(); From 85dc97a5ae77c1c83b4e80126297340d2238d816 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 23:22:47 -0400 Subject: [PATCH 26/79] Added csp-html-webpack-plugin --- package-lock.json | 464 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 465 insertions(+) diff --git a/package-lock.json b/package-lock.json index c748d50..5660daf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", "copy-webpack-plugin": "^11.0.0", + "csp-html-webpack-plugin": "^5.1.0", "css-loader": "^6.7.1", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", @@ -1224,6 +1225,189 @@ "node": "*" } }, + "node_modules/cheerio": { + "version": "1.0.0-rc.12", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", + "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", + "dev": true, + "dependencies": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "htmlparser2": "^8.0.1", + "parse5": "^7.0.0", + "parse5-htmlparser2-tree-adapter": "^7.0.0" + }, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/cheerio-select/node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/cheerio-select/node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/cheerio-select/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/cheerio-select/node_modules/domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/cheerio-select/node_modules/entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/cheerio/node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/cheerio/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/cheerio/node_modules/domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/cheerio/node_modules/entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/cheerio/node_modules/htmlparser2": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.1.tgz", + "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "entities": "^4.3.0" + } + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1467,6 +1651,20 @@ "node": ">= 8" } }, + "node_modules/csp-html-webpack-plugin": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/csp-html-webpack-plugin/-/csp-html-webpack-plugin-5.1.0.tgz", + "integrity": "sha512-6l/s6hACE+UA01PLReNKZfgLZWM98f7ewWmE79maDWIbEXiPcIWQGB3LQR/Zw+hPBj4XPZZ5zNrrO+aygqaLaQ==", + "dev": true, + "dependencies": { + "cheerio": "^1.0.0-rc.5", + "lodash": "^4.17.20" + }, + "peerDependencies": { + "html-webpack-plugin": "^4 || ^5", + "webpack": "^4 || ^5" + } + }, "node_modules/css-loader": { "version": "6.7.1", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz", @@ -3759,6 +3957,74 @@ "node": ">=6" } }, + "node_modules/parse5": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.0.0.tgz", + "integrity": "sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==", + "dev": true, + "dependencies": { + "entities": "^4.3.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", + "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", + "dev": true, + "dependencies": { + "domhandler": "^5.0.2", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/parse5/node_modules/entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/pascal-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -6241,6 +6507,138 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, + "cheerio": { + "version": "1.0.0-rc.12", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", + "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", + "dev": true, + "requires": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "htmlparser2": "^8.0.1", + "parse5": "^7.0.0", + "parse5-htmlparser2-tree-adapter": "^7.0.0" + }, + "dependencies": { + "dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0" + } + }, + "domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "requires": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + } + }, + "entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true + }, + "htmlparser2": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.1.tgz", + "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "entities": "^4.3.0" + } + } + } + }, + "cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "dependencies": { + "css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + } + }, + "dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0" + } + }, + "domutils": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz", + "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==", + "dev": true, + "requires": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.1" + } + }, + "entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true + } + } + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -6424,6 +6822,16 @@ "which": "^2.0.1" } }, + "csp-html-webpack-plugin": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/csp-html-webpack-plugin/-/csp-html-webpack-plugin-5.1.0.tgz", + "integrity": "sha512-6l/s6hACE+UA01PLReNKZfgLZWM98f7ewWmE79maDWIbEXiPcIWQGB3LQR/Zw+hPBj4XPZZ5zNrrO+aygqaLaQ==", + "dev": true, + "requires": { + "cheerio": "^1.0.0-rc.5", + "lodash": "^4.17.20" + } + }, "css-loader": { "version": "6.7.1", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.7.1.tgz", @@ -8135,6 +8543,62 @@ "callsites": "^3.0.0" } }, + "parse5": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.0.0.tgz", + "integrity": "sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==", + "dev": true, + "requires": { + "entities": "^4.3.0" + }, + "dependencies": { + "entities": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz", + "integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==", + "dev": true + } + } + }, + "parse5-htmlparser2-tree-adapter": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", + "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", + "dev": true, + "requires": { + "domhandler": "^5.0.2", + "parse5": "^7.0.0" + }, + "dependencies": { + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0" + } + } + } + }, + "pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "requires": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", diff --git a/package.json b/package.json index fcfc13d..f0f1c7c 100644 --- a/package.json +++ b/package.json @@ -611,6 +611,7 @@ "@typescript-eslint/parser": "^5.38.0", "chai": "^4.3.6", "copy-webpack-plugin": "^11.0.0", + "csp-html-webpack-plugin": "^5.1.0", "css-loader": "^6.7.1", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", From 2d27cc7e7307a1b52a32d92a628d97381fcbdd0c Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 29 Jul 2022 23:35:10 -0400 Subject: [PATCH 27/79] Added config for csp-html-webpack-plugin --- webpack.config.js | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index f393023..cfe7f80 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,6 +12,7 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CspHtmlPlugin = require('csp-html-webpack-plugin'); const path = require('path'); const fs = require('fs'); @@ -50,6 +51,8 @@ function getExtensionConfig(mode, env) { name: 'extension', mode: mode, target: 'node', + devtool: 'source-map', + entry: './src/extension.ts', output: { @@ -59,8 +62,6 @@ function getExtensionConfig(mode, env) { devtoolFallbackModuleFilenameTemplate: '../[resource-path]', }, - devtool: 'source-map', - externals: { vscode: 'commonjs vscode', '@appliedengdesign/gcode-reference': '@appliedengdesign/gcode-reference', @@ -122,6 +123,8 @@ function getWebviewsConfig(mode, env) { plugins.push(...getWebviewPlugins(outPath, basePath, entries)); + plugins.push(getCspHtml(mode, env)); + const config = { name: 'webviews', mode: mode, @@ -135,7 +138,6 @@ function getWebviewsConfig(mode, env) { path: path.resolve(__dirname, 'dist', 'webviews'), filename: `[name]/[name][ext]`, publicPath: '{root}/dist/webviews/', - clean: true, }, plugins: plugins, @@ -148,6 +150,10 @@ function getWebviewsConfig(mode, env) { use: [ { loader: 'ts-loader', + options: { + configFile: path.resolve(basePath, 'tsconfig.json'), + transpileOnly: true, + } }, ], exclude: /node_modules/, @@ -217,9 +223,6 @@ function getWebviewEntries(_path) { // App TS File result[item] = { import: [`./${item}/${item}.ts`, `./${item}/${item}.scss` ], filename: `${item}/${item}.js` }; - // App SCSS File - //result[`${item}.scss`] = { import: `./${item}/${item}.scss`, filename: `${item}/${item}.css` }; - return result; }, {}); @@ -248,6 +251,7 @@ function getWebviewPlugins(_outPath, _basePath, entries) { template: path.resolve(_basePath, entry, `${entry}.html`), inject: 'head', filename: path.resolve(_outPath, `${entry}`, `${entry}.html`), + scriptLoading: 'module', }), ); @@ -264,4 +268,33 @@ function getWebviewPlugins(_outPath, _basePath, entries) { //console.log(webviewPlugins); //process.exit(1); return webviewPlugins; +} + +function getCspHtml(mode, env) { + const cspPlugin = new CspHtmlPlugin( + { + 'default-src': "'none'", + 'img-src': [ '{cspSource}', 'https:', 'data:' ], + 'script-src': [ '{cspSource}', "'nonce-{cspNonce}'" ], + 'style-src': [ '{cspSource}', "'nonce-{cspNonce}'", "'unsafe-inline'" ], + 'font-src': [ '{cspSource}' ], + }, + { + enabled: true, + hashingMethod: 'sha256', + hashEnabled: { + 'script-src': true, + 'style-src:': true, + }, + nonceEnabled: { + 'script-src': true, + 'style-src': true, + }, + }, + ); + + // Override nonce creation + cspPlugin.createNonce = () => '{cspNonce}'; + + return cspPlugin; } \ No newline at end of file From 174f64755f799aff3fd602e4c3ca4adaea839d26 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Sat, 30 Jul 2022 00:00:23 -0400 Subject: [PATCH 28/79] Added webview apps to ignore --- src/webviews/apps/.eslintrc.json | 11 +++++++++++ src/webviews/apps/tsconfig.json | 18 ++++++++++++++++++ tsconfig.json | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/webviews/apps/.eslintrc.json create mode 100644 src/webviews/apps/tsconfig.json diff --git a/src/webviews/apps/.eslintrc.json b/src/webviews/apps/.eslintrc.json new file mode 100644 index 0000000..0de801f --- /dev/null +++ b/src/webviews/apps/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "extends": [ + "../../../.eslintrc.json" + ], + "env": { + "browser": true + }, + "parserOptions": { + "project": "src/webviews/apps/tsconfig.json" + } +} \ No newline at end of file diff --git a/src/webviews/apps/tsconfig.json b/src/webviews/apps/tsconfig.json new file mode 100644 index 0000000..39f7eb2 --- /dev/null +++ b/src/webviews/apps/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "lib": [ + "dom", + "dom.iterable", + "ES2021" + ], + "outDir": "../../" + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules", + "test" + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index fbed3ed..a83d598 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,6 +29,7 @@ ], "exclude": [ "node_modules", - "samplenc" + "samplenc", + "src/webviews/apps/**/*" ] } \ No newline at end of file From 2a97c944f38df7714ea83a84b7c3e89708c5a0f2 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Sat, 30 Jul 2022 00:01:23 -0400 Subject: [PATCH 29/79] Added html loading from webpack-emitted file --- src/webviews/apps/calc/calc.html | 24 +++---- src/webviews/apps/calc/calc.ts | 34 ++++++++- src/webviews/apps/shared/partials/head.html | 6 +- src/webviews/calc/calcWebviewView.ts | 80 ++++++++++----------- 4 files changed, 84 insertions(+), 60 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 7e5d345..39068cf 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -1,17 +1,17 @@ <%= require('html-loader?{"esModule":false}!../shared/partials/head.html') %> - - Cutting Speed - Feed Rate + + Cutting Speed + Feed Rate - - - - Calculate RPM - -
-
- -
+ +
+
+
+ Calculate RPM + +
+ +
<%= require('html-loader?{"esModule":false}!../shared/partials/tail.html') %> \ No newline at end of file diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index b6ccff8..4557cb0 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -1,8 +1,36 @@ -export class CalcApp { - private btn: string; +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +interface RPMCalc { + btn: HTMLElement; + sfm: HTMLInputElement; + toolDia: HTMLInputElement; + results: HTMLInputElement; +} +export class CalcApp { + private _rpmCalc: RPMCalc; constructor() { - this.btn = 'test'; + this._rpmCalc = { + btn: document.getElementById('rpm-calc')!, + sfm: document.getElementById('sfm') as HTMLInputElement, + toolDia: document.getElementById('tool-dia') as HTMLInputElement, + results: document.getElementById('rpm-results') as HTMLInputElement, + }; + + this._rpmCalc.btn.addEventListener('click', this.calcRPM); + } + + private calcRPM(): void { + const sfm = Number(this._rpmCalc.sfm.value); + const toolDia = Number(this._rpmCalc.toolDia.value); + + const results = Math.round((sfm * 12) / Math.PI / toolDia); + + this._rpmCalc.results.value = results.toString(); } } diff --git a/src/webviews/apps/shared/partials/head.html b/src/webviews/apps/shared/partials/head.html index 363df83..b9a4981 100644 --- a/src/webviews/apps/shared/partials/head.html +++ b/src/webviews/apps/shared/partials/head.html @@ -4,5 +4,9 @@ + + {toolkit} + + {title} - \ No newline at end of file + diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index fb87189..3a5b5eb 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -4,7 +4,8 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { commands, ConfigurationChangeEvent, Disposable, Uri, Webview } from 'vscode'; +import { TextDecoder } from 'util'; +import { commands, ConfigurationChangeEvent, Disposable, Uri, Webview, workspace } from 'vscode'; import { Control } from '../../control'; import { configuration } from '../../util/configuration/config'; import { defaults } from '../../util/configuration/defaults'; @@ -13,9 +14,13 @@ import { GWebviewView } from '../gWebviewView'; import { getNonce } from '../helpers'; export class CalcWebviewView extends GWebviewView { + private _shortId: string; + constructor() { super(Webviews.CalcWebviewView, WebviewTitles.CalcWebviewView); + this._shortId = this.id.split('.').pop() ?? ''; + if ((this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled)) { void Control.setContext(Contexts.CalcWebviewViewEnabled, true); } @@ -56,10 +61,14 @@ export class CalcWebviewView extends GWebviewView { } async getHtml(webview: Webview): Promise { - // CSS styles - const stylesMain = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews', 'calc', 'calc.css'), - ); + const webRootUri = Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews'); + const uri = Uri.joinPath(webRootUri, this._shortId, `${this._shortId}.html`); + const content = new TextDecoder('utf8').decode(await workspace.fs.readFile(uri)); + + const cspSource = webview.cspSource; + const cspNonce = getNonce(); + + const root = webview.asWebviewUri(Control.context.extensionUri).toString(); // vscode-webview-ui-toolkit const toolkitUri = webview.asWebviewUri( @@ -73,45 +82,28 @@ export class CalcWebviewView extends GWebviewView { ), ); - const calcJsUri = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews', 'calc', 'calc.js'), - ); + const html = content.replace(/{(cspNonce|cspSource|root|title|toolkit)}/g, (_substring, token) => { + switch (token) { + case 'cspNonce': + return cspNonce.toString(); + + case 'cspSource': + return cspSource.toString(); + + case 'root': + return root; + + case 'title': + return `${this.title}`; + + case 'toolkit': + return ``; + + default: + return ''; + } + }); - const nonce = getNonce(); - - return Promise.resolve(` - - - - - - - - - - - - - - ${this.title} - - - - Cutting Speed - Feed Rate - - - - - Calculate RPM - -
-
- -
- - `); + return Promise.resolve(html); } } From 119bcf9d36a6adecfe1db2b94f4ccc22dcf4e5a1 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Sat, 30 Jul 2022 00:36:10 -0400 Subject: [PATCH 30/79] Refactored to match gWebviewView --- src/webviews/gWebview.ts | 112 +++++++++------------------------------ 1 file changed, 26 insertions(+), 86 deletions(-) diff --git a/src/webviews/gWebview.ts b/src/webviews/gWebview.ts index 84757d4..d196b84 100644 --- a/src/webviews/gWebview.ts +++ b/src/webviews/gWebview.ts @@ -7,8 +7,6 @@ 'use strict'; import { - commands, - ConfigurationChangeEvent, Disposable, Uri, ViewColumn, @@ -18,39 +16,28 @@ import { WebviewPanelOnDidChangeViewStateEvent, window, } from 'vscode'; -import { configuration } from '../util/configuration/config'; import { constants, WebviewCommands } from '../util/constants'; import { Control } from '../control'; export abstract class GWebview implements Disposable { - protected _disposable: Disposable; + protected _disposables: Disposable[] = []; private _panel: WebviewPanel | undefined; private _dPanel: Disposable | undefined; - private _enabled: boolean; + private _title: string; constructor( public readonly id: string, - public readonly title: string, + title: string, showCommand: WebviewCommands, private readonly _column?: ViewColumn, ) { - this._disposable = Disposable.from( - configuration.onDidChange(this.onConfigurationChanged, this), - commands.registerCommand(showCommand, this.onShowCommand, this), - ); - - this._enabled = configuration.getParam('webviews.enabled'); - } - - private onConfigurationChanged(e: ConfigurationChangeEvent) { - if (e.affectsConfiguration('webviews.enabled')) { - this._enabled = configuration.getParam('webviews.enabled'); - } + this._title = title; + this._disposables.push(...this.registerCommands()); } dispose() { - this._disposable && this._disposable.dispose(); - this._dPanel && this._dPanel.dispose(); + Disposable.from(...this._disposables).dispose(); + this._dPanel?.dispose(); } hide() { @@ -61,17 +48,14 @@ export abstract class GWebview implements Disposable { return this._panel?.visible ?? false; } - setTitle(title: string) { - if (this._panel == null) { - return; - } - - this._panel.title = title; + get title(): string { + return this._panel?.title ?? this._title; } - protected onShowCommand() { - if (this._enabled) { - void this.show(this._column); + setTitle(title: string) { + this._title = title; + if (this._panel) { + this._panel.title = title; } } @@ -86,11 +70,15 @@ export abstract class GWebview implements Disposable { } } + protected onShowCommand(): void { + void this.show(); + } + async show(column: ViewColumn = ViewColumn.Beside): Promise { - if (this._panel == null) { + if (!this._panel) { this._panel = window.createWebviewPanel( this.id, - this.title, + this._title, { viewColumn: column, preserveFocus: false }, this.getWebviewOptions(), ); @@ -114,68 +102,20 @@ export abstract class GWebview implements Disposable { } } - protected abstract getHtml(webview: Webview): Promise; - - private _getHtmlForWebview(webview: Webview, ...opts: string[]) { - // CSS styles - const stylesReset = webview - .asWebviewUri(Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css')) - .with({ scheme: 'vscode-resource' }); - - const stylesMain = webview - .asWebviewUri(Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css')) - .with({ scheme: 'vscode-resource' }); - - const nonce = this.getNonce(); - - const scriptUri = webview - .asWebviewUri(Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'js', `${opts[0]}.js`)) - .with({ scheme: 'vscode-resource' }); - - return ` - - - - - - - ${this.title} - - - - - - - - - - - -
- - - - - - `; - } - - protected getNonce(): string { - let text = ''; - - const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - for (let i = 0; i < 32; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); + async refresh(): Promise { + if (this._panel) { + this._panel.webview.html = await this.getHtml(this._panel.webview); } - return text; } + protected abstract getHtml(webview: Webview): Promise; + protected abstract registerCommands(): Disposable[]; + private getWebviewOptions(): WebviewOptions { return { enableScripts: true, enableCommandUris: true, - localResourceRoots: [Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews')], + localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], }; } } From bba75a8fcab301c355562a713637a6a2ac34af36 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 1 Aug 2022 17:27:20 -0400 Subject: [PATCH 31/79] Added logger --- src/webviews/calc/calcWebviewView.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 3a5b5eb..7631a6a 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -10,6 +10,7 @@ import { Control } from '../../control'; import { configuration } from '../../util/configuration/config'; import { defaults } from '../../util/configuration/defaults'; import { Contexts, WebviewCommands, Webviews, WebviewTitles } from '../../util/constants'; +import { Logger } from '../../util/logger'; import { GWebviewView } from '../gWebviewView'; import { getNonce } from '../helpers'; @@ -22,6 +23,7 @@ export class CalcWebviewView extends GWebviewView { this._shortId = this.id.split('.').pop() ?? ''; if ((this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled)) { + Logger.log('Loading Calculator...'); void Control.setContext(Contexts.CalcWebviewViewEnabled, true); } @@ -37,8 +39,10 @@ export class CalcWebviewView extends GWebviewView { if (this._enabled) { // Disable void Control.setContext(Contexts.CalcWebviewViewEnabled, false); + Logger.log('Disabling Calculator...'); } else { // Enable + Logger.log('Loading Calculator...'); void Control.setContext(Contexts.CalcWebviewViewEnabled, true); } From ec68e8804e15201f679d7ad6282569fe2ddcf383 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 1 Aug 2022 17:31:52 -0400 Subject: [PATCH 32/79] Added csp-nonce meta property to head template for vscode-webview-ui-toolkit --- src/webviews/apps/shared/partials/head.html | 2 ++ webpack.config.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webviews/apps/shared/partials/head.html b/src/webviews/apps/shared/partials/head.html index b9a4981..19c271b 100644 --- a/src/webviews/apps/shared/partials/head.html +++ b/src/webviews/apps/shared/partials/head.html @@ -5,6 +5,8 @@ + + {toolkit} {title} diff --git a/webpack.config.js b/webpack.config.js index cfe7f80..ddf4f11 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -152,7 +152,7 @@ function getWebviewsConfig(mode, env) { loader: 'ts-loader', options: { configFile: path.resolve(basePath, 'tsconfig.json'), - transpileOnly: true, + //transpileOnly: true, } }, ], @@ -276,7 +276,7 @@ function getCspHtml(mode, env) { 'default-src': "'none'", 'img-src': [ '{cspSource}', 'https:', 'data:' ], 'script-src': [ '{cspSource}', "'nonce-{cspNonce}'" ], - 'style-src': [ '{cspSource}', "'nonce-{cspNonce}'", "'unsafe-inline'" ], + 'style-src': [ '{cspSource}', "'nonce-{cspNonce}'" ], 'font-src': [ '{cspSource}' ], }, { From c1e25db625141532bea445525e2b4debaab98681 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 1 Aug 2022 17:33:46 -0400 Subject: [PATCH 33/79] Fixed finding input box within shadowRoot --- src/webviews/apps/calc/calc.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 4557cb0..c46ad92 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -13,15 +13,16 @@ interface RPMCalc { export class CalcApp { private _rpmCalc: RPMCalc; + constructor() { this._rpmCalc = { btn: document.getElementById('rpm-calc')!, - sfm: document.getElementById('sfm') as HTMLInputElement, - toolDia: document.getElementById('tool-dia') as HTMLInputElement, - results: document.getElementById('rpm-results') as HTMLInputElement, + sfm: document.getElementById('sfm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + toolDia: document.getElementById('tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('rpm-results')?.shadowRoot?.getElementById('control') as HTMLInputElement, }; - this._rpmCalc.btn.addEventListener('click', this.calcRPM); + this._rpmCalc.btn.addEventListener('click', this.calcRPM.bind(this), false); } private calcRPM(): void { From 9b27032dced23b03fb43354114d8ff91bbb29437 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 01:46:31 -0400 Subject: [PATCH 34/79] Added run-only launches --- .vscode/launch.json | 89 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 20 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 90ee5bb..80c15e1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,7 +2,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Run G-Code (Sandbox) - Samples", + "name": "Run G-Code (Sandbox)", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", @@ -22,10 +22,9 @@ ], "presentation": { "hidden": false, - "group": "Launch Extension", + "group": "1_run", "order": 1 }, - "preLaunchTask": "npm: build", "skipFiles": [ "/**", "**/node_modules/**", @@ -36,14 +35,48 @@ "trace": true }, { - "name": "Run G-Code (Sandbox)", + "name": "Run G-Code (Full)", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--trace-depreciation", + "--trace-warnings", + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/samplenc/sample-colors.nc", + "${workspaceFolder}/samplenc/sample-profile.nc", + "${workspaceFolder}/samplenc/sample-circular-pocket.nc" + ], + "outFiles": [ + "${workspaceFolder}/dist/**/*.js" + ], + "presentation": { + "hidden": false, + "group": "1_run", + "order": 2 + }, + "skipFiles": [ + "/**", + "**/node_modules/**", + "**/resources/app/out/vs/**" + ], + "smartStep": true, + "sourceMaps": true, + "trace": true + }, + { + "name": "Build & Run G-Code (Sandbox)", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", "args": [ "--disable-extensions", + "--trace-warnings", "--trace-depreciation", - "--extensionDevelopmentPath=${workspaceFolder}" + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/samplenc/sample-colors.nc", + "${workspaceFolder}/samplenc/sample-profile.nc", + "${workspaceFolder}/samplenc/sample-circular-pocket.nc" ], "cwd": "${workspaceFolder}", "outFiles": [ @@ -51,8 +84,8 @@ ], "presentation": { "hidden": false, - "group": "Launch Extension", - "order": 2 + "group": "2_build_launch", + "order": 1 }, "preLaunchTask": "npm: build", "skipFiles": [ @@ -65,21 +98,25 @@ "trace": true }, { - "name": "Run G-Code (Full)", + "name": "Build & Run G-Code (Full)", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", "args": [ "--trace-depreciation", - "--extensionDevelopmentPath=${workspaceFolder}" + "--trace-warnings", + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/samplenc/sample-colors.nc", + "${workspaceFolder}/samplenc/sample-profile.nc", + "${workspaceFolder}/samplenc/sample-circular-pocket.nc" ], "outFiles": [ "${workspaceFolder}/dist/**/*.js" ], "presentation": { "hidden": false, - "group": "Launch Extension", - "order": 3 + "group": "2_build_launch", + "order": 2 }, "preLaunchTask": "npm: build", "skipFiles": [ @@ -92,23 +129,35 @@ "trace": true }, { - "name": "Run G-Code As Web Extension", + "name": "Build & Run G-Code (Full/Production)", "type": "extensionHost", - "debugWebWorkerHost": true, "request": "launch", + "runtimeExecutable": "${execPath}", "args": [ + "--trace-depreciation", + "--trace-warnings", "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionDevelopmentKind=web" + "${workspaceFolder}/samplenc/sample-colors.nc", + "${workspaceFolder}/samplenc/sample-profile.nc", + "${workspaceFolder}/samplenc/sample-circular-pocket.nc" ], "outFiles": [ "${workspaceFolder}/dist/**/*.js" ], - "preLaunchTask": "npm: build", "presentation": { - "hidden": true, - "group": "Web Extension", - "order": 1 - } + "hidden": false, + "group": "2_build_launch", + "order": 3 + }, + "preLaunchTask": "npm: bundle", + "skipFiles": [ + "/**", + "**/node_modules/**", + "**/resources/app/out/vs/**" + ], + "smartStep": true, + "sourceMaps": true, + "trace": true }, { "name": "G-Code Mocha Unit Tests", @@ -132,7 +181,7 @@ ], "presentation": { "hidden": false, - "group": "Testing", + "group": "3_test", "order": 1 }, "env": { From 9a44fb4e339e72e595123f76b8bd85b1ff11b486 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 01:48:41 -0400 Subject: [PATCH 35/79] Moved scss into subfolder. Added base.scss --- src/webviews/apps/shared/scss/base.scss | 14 ++++++++++++++ src/webviews/apps/shared/{ => scss}/reset.scss | 0 src/webviews/apps/shared/{ => scss}/vscode.scss | 0 3 files changed, 14 insertions(+) create mode 100644 src/webviews/apps/shared/scss/base.scss rename src/webviews/apps/shared/{ => scss}/reset.scss (100%) rename src/webviews/apps/shared/{ => scss}/vscode.scss (100%) diff --git a/src/webviews/apps/shared/scss/base.scss b/src/webviews/apps/shared/scss/base.scss new file mode 100644 index 0000000..86bb761 --- /dev/null +++ b/src/webviews/apps/shared/scss/base.scss @@ -0,0 +1,14 @@ +html { + height: 100%; + font-size: 62.5%; +} + +body { + height: 100%; + line-height: 1.4; + font-size: 100% !important; +} + +a { + border: 0; +} \ No newline at end of file diff --git a/src/webviews/apps/shared/reset.scss b/src/webviews/apps/shared/scss/reset.scss similarity index 100% rename from src/webviews/apps/shared/reset.scss rename to src/webviews/apps/shared/scss/reset.scss diff --git a/src/webviews/apps/shared/vscode.scss b/src/webviews/apps/shared/scss/vscode.scss similarity index 100% rename from src/webviews/apps/shared/vscode.scss rename to src/webviews/apps/shared/scss/vscode.scss From 553d847904e382bddd4c680ce9ae992d4aa9eb6d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 01:50:32 -0400 Subject: [PATCH 36/79] Added better typing. Finished 4 types of calculators --- src/webviews/apps/calc/calc.ts | 214 ++++++++++++++++++++++++++++++--- 1 file changed, 197 insertions(+), 17 deletions(-) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index c46ad92..a23a048 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -4,34 +4,214 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -interface RPMCalc { - btn: HTMLElement; - sfm: HTMLInputElement; - toolDia: HTMLInputElement; - results: HTMLInputElement; +interface ICalcDom { + rpm?: { + btn: HTMLElement; + sfm: HTMLInputElement; + toolDia: HTMLInputElement; + results: HTMLSpanElement; + }; + + sfm?: { + btn: HTMLElement; + rpm: HTMLInputElement; + toolDia: HTMLInputElement; + results: HTMLSpanElement; + }; + + feedrate?: { + btn: HTMLElement; + rpm: HTMLInputElement; + numFlutes: HTMLInputElement; + chipLoad: HTMLInputElement; + results: HTMLSpanElement; + }; + + chipLoad?: { + btn: HTMLElement; + ipm: HTMLInputElement; + rpm: HTMLInputElement; + numFlutes: HTMLInputElement; + results: HTMLSpanElement; + }; } +type TCalcDom = ICalcDom[keyof ICalcDom]; + +type Units = 'imperial' | 'metric'; + export class CalcApp { - private _rpmCalc: RPMCalc; + private _calcDom: ICalcDom = {}; + private _units: Units = 'imperial'; constructor() { - this._rpmCalc = { - btn: document.getElementById('rpm-calc')!, - sfm: document.getElementById('sfm')?.shadowRoot?.getElementById('control') as HTMLInputElement, - toolDia: document.getElementById('tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, - results: document.getElementById('rpm-results')?.shadowRoot?.getElementById('control') as HTMLInputElement, + this.populateDOM(); + + this.registerBtns(); + } + + private populateDOM(): void { + // Populate RPM Calculator + this._calcDom.rpm = { + btn: document.getElementById('rpm-calc-btn') as HTMLElement, + sfm: document.getElementById('rpm-sfm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + toolDia: document.getElementById('rpm-tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('rpm-results') as HTMLSpanElement, + }; + + // Populate SFM Calculator + this._calcDom.sfm = { + btn: document.getElementById('sfm-calc-btn') as HTMLElement, + rpm: document.getElementById('sfm-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + toolDia: document.getElementById('sfm-tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('sfm-results') as HTMLSpanElement, }; - this._rpmCalc.btn.addEventListener('click', this.calcRPM.bind(this), false); + // Populate Feedrate Calculator + this._calcDom.feedrate = { + btn: document.getElementById('fr-calc-btn') as HTMLElement, + rpm: document.getElementById('fr-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + numFlutes: document + .getElementById('fr-num-flutes') + ?.shadowRoot?.getElementById('control') as HTMLInputElement, + chipLoad: document + .getElementById('fr-chip-load') + ?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('fr-results') as HTMLSpanElement, + }; + + this._calcDom.chipLoad = { + btn: document.getElementById('cl-calc-btn') as HTMLElement, + ipm: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + rpm: document.getElementById('cl-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + numFlutes: document + .getElementById('cl-num-flutes') + ?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('cl-results') as HTMLSpanElement, + }; + } + + private registerBtns(): void { + Object.keys(this._calcDom).forEach(key => { + this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this.processEvent.bind(this), false); + }); + } + + private processEvent(e: MouseEvent): void { + const target = e.target as HTMLButtonElement; + let result: number | undefined; + + if (target) { + switch (target.id) { + case 'rpm-calc-btn': { + if (this._calcDom.rpm) { + const sfm = Math.abs(Number(this._calcDom.rpm.sfm.value)); + const toolDia = Math.abs(Number(this._calcDom.rpm.toolDia.value)); + + this._calcDom.rpm.sfm.value = sfm ? sfm.toString() : ''; + this._calcDom.rpm.toolDia.value = toolDia ? sfm.toString() : ''; + + result = this.calcRPM(sfm, toolDia, this._units); + + this.displayResults(result, this._calcDom.rpm); + } + break; + } + + case 'sfm-calc-btn': { + if (this._calcDom.sfm) { + const rpm = Math.abs(Number(this._calcDom.sfm.rpm.value)); + const toolDia = Math.abs(Number(this._calcDom.sfm.toolDia.value)); + + this._calcDom.sfm.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.sfm.toolDia.value = toolDia ? toolDia.toString() : ''; + + result = this.calcSFM(rpm, toolDia, this._units); + + this.displayResults(result, this._calcDom.sfm); + } + break; + } + + case 'fr-calc-btn': { + if (this._calcDom.feedrate) { + const rpm = Math.abs(Number(this._calcDom.feedrate.rpm.value)); + const numFlutes = Math.abs(Number(this._calcDom.feedrate.numFlutes.value)); + const chipLoad = Math.abs(Number(this._calcDom.feedrate.chipLoad.value)); + + this._calcDom.feedrate.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.feedrate.numFlutes.value = numFlutes ? numFlutes.toString() : ''; + this._calcDom.feedrate.chipLoad.value = chipLoad ? chipLoad.toString() : ''; + + result = this.calcFeedRate(rpm, numFlutes, chipLoad); + + this.displayResults(result, this._calcDom.feedrate); + } + break; + } + + case 'cl-calc-btn': { + if (this._calcDom.chipLoad) { + const ipm = Math.abs(Number(this._calcDom.chipLoad.ipm.value)); + const rpm = Math.abs(Number(this._calcDom.chipLoad.rpm.value)); + const numFlutes = Math.abs(Number(this._calcDom.chipLoad.numFlutes.value)); + + this._calcDom.chipLoad.ipm.value = ipm ? ipm.toString() : ''; + this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : ''; + + result = this.calcChipLoad(ipm, rpm, numFlutes); + + this.displayResults(result, this._calcDom.chipLoad); + } + break; + } + } + } + } + + private displayResults(result: number | undefined, target: TCalcDom): void { + if (result && result !== Number.POSITIVE_INFINITY) { + // Precision is 2 decimals or 5 for Chip Load + const precision = target === this._calcDom.chipLoad ? 5 : 2; + + if (target) { + target.results.classList.remove('error'); + target.results.innerHTML = result.toFixed(precision); + } + } else { + // Answer is NaN or Infinity + if (target) { + target.results.classList.add('error'); + target.results.innerHTML = 'Err'; + } + } } - private calcRPM(): void { - const sfm = Number(this._rpmCalc.sfm.value); - const toolDia = Number(this._rpmCalc.toolDia.value); + private calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { + if (units === 'imperial') { + return (sfm * 12) / (Math.PI * toolDia); + } else { + return (sfm * 1000) / (Math.PI * toolDia); + } + } - const results = Math.round((sfm * 12) / Math.PI / toolDia); + private calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { + if (units === 'imperial') { + // Calculate SFM for Imperial + return (Math.PI * toolDia * rpm) / 12; + } else { + // Calculate SFM for Metric + return (Math.PI * toolDia * rpm) / 1000; + } + } + + private calcFeedRate(rpm: number, numFlutes: number, feedPerTooth: number): number | undefined { + return rpm * feedPerTooth * numFlutes; + } - this._rpmCalc.results.value = results.toString(); + private calcChipLoad(feedRate: number, rpm: number, numFlutes: number): number | undefined { + return feedRate / rpm / numFlutes; } } From d07bb15ba7c7007ed83ed6866414e0879b06ad7d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 01:51:21 -0400 Subject: [PATCH 37/79] Added framework and styling for calculators --- src/webviews/apps/calc/calc.html | 62 +++++++++++++++++++++++++------- src/webviews/apps/calc/calc.scss | 59 ++++++++++++++++++++++++++++-- 2 files changed, 107 insertions(+), 14 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 39068cf..e3a3fb1 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -1,17 +1,55 @@ <%= require('html-loader?{"esModule":false}!../shared/partials/head.html') %> - - Cutting Speed - Feed Rate + - -
-
-
- Calculate RPM - -
- -
+
+ + + SPEEDS + FEEDS + + +
+

RPM

+ + SFM + Tool Diameter + + Calculate +
+
+

SFM

+ + RPM + Tool Diameter + + Calculate +
+
+ +
+

Feedrate

+ + RPM + # of Flutes + Load / Tooth + + Calculate +
+
+

Chip Load

+ + IPM + RPM + # of Flutes + + Calculate +
+
+
+ +
+ + <%= require('html-loader?{"esModule":false}!../shared/partials/tail.html') %> \ No newline at end of file diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index 70b1802..34d0fd1 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -1,2 +1,57 @@ -@import '../shared/reset'; -@import '../shared/vscode'; +@import '../shared/scss/reset'; +@import '../shared/scss/vscode'; +@import '../shared/scss/base'; + +.container { + display: flex; + font-size: 1.1em; + grid-template-rows: auto min-content; + min-height: 100%; +} + +section { + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + + padding: 1em; +} + +h3 { + border: none; + font-weight: 600; + margin-top: 0; + white-space: nowrap; +} + +vscode-text-field, +vscode-button { + margin: 0.5rem 0; +} + +vscode-text-field.results { + font-style: italic; +} + +label.results { + font-style: italic; + margin-top: 1rem; + margin-bottom: 2px; +} + +span.results { + border: 1px solid var(--vscode-inputValidation-infoBorder); + background: transparent; + width: 90px; + height: 20px; + padding: 5px; +} + +section.calculator > vscode-button { + margin-top: 1rem; +} + +.error { + color: var(--vscode-errorForeground); +} \ No newline at end of file From a539bcada815ea6a175828a76840903d3a859f4b Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 16:32:41 -0400 Subject: [PATCH 38/79] Styling and flex model updated --- src/webviews/apps/calc/calc.html | 74 +++++++++++++++++++------------- src/webviews/apps/calc/calc.scss | 23 ++++++++-- 2 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index e3a3fb1..4e7b7c8 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -9,41 +9,55 @@ FEEDS -
-

RPM

- - SFM - Tool Diameter - - Calculate +
+
+

RPM

+ + SFM + Tool Diameter + + Calculate +
+
+

SFM

+ + RPM + Tool Diameter + + Calculate +
-
-

SFM

- - RPM - Tool Diameter - - Calculate +
+ + Clear Fields +
-
-

Feedrate

- - RPM - # of Flutes - Load / Tooth - - Calculate +
+
+

Feedrate

+ + RPM + # of Flutes + Load / Tooth + + Calculate +
+
+

Chip Load

+ + IPM + RPM + # of Flutes + + Calculate +
-
-

Chip Load

- - IPM - RPM - # of Flutes - - Calculate +
+ + Clear Fields +
diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index 34d0fd1..2edb746 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -4,20 +4,25 @@ .container { display: flex; - font-size: 1.1em; - grid-template-rows: auto min-content; min-height: 100%; + margin: 0; + padding: 0; } section { display: flex; flex-direction: column; - align-items: flex-start; - justify-content: flex-start; + justify-content: center; padding: 1em; } +section.row { + flex-direction: row; + flex: none; + padding: 0; +} + h3 { border: none; font-weight: 600; @@ -30,10 +35,20 @@ vscode-button { margin: 0.5rem 0; } +vscode-panel-view { + flex-wrap: wrap; + flex-direction: column; + padding: 0; +} + vscode-text-field.results { font-style: italic; } +span.clear-btn { + margin-top: 1rem; +} + label.results { font-style: italic; margin-top: 1rem; From 50636cbf6c05e3417ddf2a6af30d0031f796722b Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 16:33:19 -0400 Subject: [PATCH 39/79] Added clear fields functionality --- src/webviews/apps/calc/calc.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index a23a048..03e7963 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -95,6 +95,27 @@ export class CalcApp { Object.keys(this._calcDom).forEach(key => { this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this.processEvent.bind(this), false); }); + + const clearBtns = document.querySelectorAll('span.clear-btn > vscode-button'); + + if (clearBtns) { + clearBtns.forEach(btn => { + btn.addEventListener('click', this.clearFields.bind(this), false); + }); + } + } + + private clearFields(e: MouseEvent): void { + const target = e.target as HTMLButtonElement; + + if (target) { + const targetView = target.id.split('-')[1]; + + document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { + const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; + element.value = ''; + }); + } } private processEvent(e: MouseEvent): void { From ca73ade6eaed04aed58ef884c744899214875b8a Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 23:15:51 -0400 Subject: [PATCH 40/79] Add abstract class for webview apps --- src/webviews/apps/shared/gWebviewApp.ts | 31 ++++++++++++++++++++ src/webviews/apps/shared/webviewMsg.types.ts | 10 +++++++ 2 files changed, 41 insertions(+) create mode 100644 src/webviews/apps/shared/gWebviewApp.ts create mode 100644 src/webviews/apps/shared/webviewMsg.types.ts diff --git a/src/webviews/apps/shared/gWebviewApp.ts b/src/webviews/apps/shared/gWebviewApp.ts new file mode 100644 index 0000000..e4a8ade --- /dev/null +++ b/src/webviews/apps/shared/gWebviewApp.ts @@ -0,0 +1,31 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +interface VsCodeApi { + postMessage(msg: any): void; + setState(state: any): void; + getState(): any; +} + +declare function acquireVsCodeApi(): VsCodeApi; + +export abstract class GWebviewApp { + private readonly _api: VsCodeApi; + + constructor(protected readonly appName: string) { + this._api = acquireVsCodeApi(); + } + + private registerEvents(): void { + window.addEventListener('message', this.onMsgReceived.bind(this)); + } + + private postMessage(msg: any): void { + this._api.postMessage(msg); + } + + protected abstract onMsgReceived(e: MessageEvent): void; +} diff --git a/src/webviews/apps/shared/webviewMsg.types.ts b/src/webviews/apps/shared/webviewMsg.types.ts new file mode 100644 index 0000000..c8383ef --- /dev/null +++ b/src/webviews/apps/shared/webviewMsg.types.ts @@ -0,0 +1,10 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +export interface WebviewMsg { + type: string; + payload?: any; +} From 44bef952c6360255ce498c1157cffd28a1208204 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 3 Aug 2022 23:17:26 -0400 Subject: [PATCH 41/79] Move types to ext file; Add message event handler --- src/webviews/apps/calc/calc.html | 6 ++ src/webviews/apps/calc/calc.ts | 84 +++++++++++----------------- src/webviews/apps/calc/calc.types.ts | 41 ++++++++++++++ 3 files changed, 79 insertions(+), 52 deletions(-) create mode 100644 src/webviews/apps/calc/calc.types.ts diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 4e7b7c8..9d1afc4 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -32,6 +32,9 @@

SFM

Clear Fields
+
+ Units: +
@@ -59,6 +62,9 @@

Chip Load

Clear Fields
+
+ Units: +
diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 03e7963..0299c1a 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -4,49 +4,21 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -interface ICalcDom { - rpm?: { - btn: HTMLElement; - sfm: HTMLInputElement; - toolDia: HTMLInputElement; - results: HTMLSpanElement; - }; - - sfm?: { - btn: HTMLElement; - rpm: HTMLInputElement; - toolDia: HTMLInputElement; - results: HTMLSpanElement; - }; - - feedrate?: { - btn: HTMLElement; - rpm: HTMLInputElement; - numFlutes: HTMLInputElement; - chipLoad: HTMLInputElement; - results: HTMLSpanElement; - }; - - chipLoad?: { - btn: HTMLElement; - ipm: HTMLInputElement; - rpm: HTMLInputElement; - numFlutes: HTMLInputElement; - results: HTMLSpanElement; - }; -} - -type TCalcDom = ICalcDom[keyof ICalcDom]; - -type Units = 'imperial' | 'metric'; +import { GWebviewApp } from '../shared/gWebviewApp'; +import { WebviewMsg } from '../shared/webviewMsg.types'; +import { ICalcDom, TCalcDom, Units } from './calc.types'; -export class CalcApp { +export class CalcApp extends GWebviewApp { private _calcDom: ICalcDom = {}; - private _units: Units = 'imperial'; + private _units: Units = 'Inch'; constructor() { + super('CalcApp'); + + // Populate DOM this.populateDOM(); + // Register Button Events this.registerBtns(); } @@ -91,6 +63,14 @@ export class CalcApp { }; } + protected onMsgReceived(e: MessageEvent): void { + const message = e.data; + + if (message.type === 'changeUnits') { + this._units = message.payload as Units; + } + } + private registerBtns(): void { Object.keys(this._calcDom).forEach(key => { this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this.processEvent.bind(this), false); @@ -105,19 +85,6 @@ export class CalcApp { } } - private clearFields(e: MouseEvent): void { - const target = e.target as HTMLButtonElement; - - if (target) { - const targetView = target.id.split('-')[1]; - - document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { - const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; - element.value = ''; - }); - } - } - private processEvent(e: MouseEvent): void { const target = e.target as HTMLButtonElement; let result: number | undefined; @@ -191,6 +158,19 @@ export class CalcApp { } } + private clearFields(e: MouseEvent): void { + const target = e.target as HTMLButtonElement; + + if (target) { + const targetView = target.id.split('-')[1]; + + document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { + const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; + element.value = ''; + }); + } + } + private displayResults(result: number | undefined, target: TCalcDom): void { if (result && result !== Number.POSITIVE_INFINITY) { // Precision is 2 decimals or 5 for Chip Load @@ -210,7 +190,7 @@ export class CalcApp { } private calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { - if (units === 'imperial') { + if (units === 'Inch') { return (sfm * 12) / (Math.PI * toolDia); } else { return (sfm * 1000) / (Math.PI * toolDia); @@ -218,7 +198,7 @@ export class CalcApp { } private calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { - if (units === 'imperial') { + if (units === 'Inch') { // Calculate SFM for Imperial return (Math.PI * toolDia * rpm) / 12; } else { diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts new file mode 100644 index 0000000..300872a --- /dev/null +++ b/src/webviews/apps/calc/calc.types.ts @@ -0,0 +1,41 @@ +/* --------------------------------------------------------------------------------------------- + * Copyright (c) Applied Eng & Design All rights reserved. + * Licensed under the MIT License. See License.md in the project root for license information. + * -------------------------------------------------------------------------------------------- */ +'use strict'; + +export interface ICalcDom { + rpm?: { + btn: HTMLElement; + sfm: HTMLInputElement; + toolDia: HTMLInputElement; + results: HTMLSpanElement; + }; + + sfm?: { + btn: HTMLElement; + rpm: HTMLInputElement; + toolDia: HTMLInputElement; + results: HTMLSpanElement; + }; + + feedrate?: { + btn: HTMLElement; + rpm: HTMLInputElement; + numFlutes: HTMLInputElement; + chipLoad: HTMLInputElement; + results: HTMLSpanElement; + }; + + chipLoad?: { + btn: HTMLElement; + ipm: HTMLInputElement; + rpm: HTMLInputElement; + numFlutes: HTMLInputElement; + results: HTMLSpanElement; + }; +} + +export type TCalcDom = ICalcDom[keyof ICalcDom]; + +export type Units = 'Inch' | 'Metric'; From 8bdefa25a4592bbf77a722a99de11834a0c7f2bb Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 26 Aug 2022 17:03:53 -0400 Subject: [PATCH 42/79] Refactor units controller --- src/control.ts | 31 +++---------------------------- src/gcodeUnits.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/control.ts b/src/control.ts index 5af770d..d5b785e 100644 --- a/src/control.ts +++ b/src/control.ts @@ -5,7 +5,7 @@ 'use strict'; -import { commands, Disposable, ExtensionContext } from 'vscode'; +import { commands, ExtensionContext } from 'vscode'; import { Config, configuration } from './util/configuration/config'; import { Logger } from './util/logger'; import { StatusBarControl } from './util/statusBar'; @@ -18,11 +18,9 @@ import { Messages } from './util/messages'; import { StateControl } from './util/stateControl'; import { MachineTypeControl } from './util/machineType'; import { GCodeHoverControl } from './hovers/gcodeHoverControl'; -import { defaults } from './util/configuration/defaults'; import { registerCommands } from './util/commands'; import { CalcWebviewView } from './webviews/calc/calcWebviewView'; -const cfgUnits = 'general.units'; const cfgAutoRef = { navTree: 'views.navTree.autoRefresh', stats: 'views.stats.autoRefresh', @@ -31,7 +29,6 @@ const cfgAutoRef = { export class Control { private static _config: Config | undefined; private static _context: ExtensionContext; - private static _units: string | undefined; private static _version: Version; // Controllers @@ -106,30 +103,8 @@ export class Control { Logger.log('Loading Hover Controller...'); context.subscriptions.push((this._hoverController = new GCodeHoverControl())); - // Units - this._units = config.getParam(cfgUnits) ?? defaults.general.units; - Logger.log(`Units: ${this._units}`); - if (this._units === 'Auto') { - // Load Units Monitor - context.subscriptions.push((this._unitsController = new GCodeUnitsController())); - } else { - let disposable: Disposable; - // eslint-disable-next-line prefer-const - disposable = configuration.onDidChange(e => { - if (configuration.changed(e, cfgUnits)) { - this._units = configuration.getParam(cfgUnits); - if (this._units === 'Auto') { - disposable.dispose(); - Logger.log(`Units: ${this._units}`); - context.subscriptions.push((this._unitsController = new GCodeUnitsController())); - } else { - return; - } - } - }); - - this._statusBarControl.updateStatusBar(this._units, 'unitsBar'); - } + // Load Units Controller + context.subscriptions.push((this._unitsController = new GCodeUnitsController())); // Load Nav Tree Logger.log('Loading Nav Tree...'); diff --git a/src/gcodeUnits.ts b/src/gcodeUnits.ts index 6d4b85d..d4ba25c 100644 --- a/src/gcodeUnits.ts +++ b/src/gcodeUnits.ts @@ -55,7 +55,11 @@ export class GCodeUnitsController implements Disposable { if (configuration.changed(e, cfgUnits)) { if ((this._units = configuration.getParam(cfgUnits) ?? defaults.general.units) !== GCodeUnits.Auto) { Logger.log(`Units: ${this._units}`); + + // Set Auto False this._auto = false; + + // Update Statusbar with new Units this._statusbar.updateStatusBar( this._units, this.unitsStatusBar, @@ -64,8 +68,13 @@ export class GCodeUnitsController implements Disposable { GCommands.ShowGCodeSettings, ); } else { + // Units = Auto Logger.log(`Units: ${this._units}`); + + // Set Auto True this._auto = true; + + // Updates Statusbar with Auto Units this._statusbar.updateStatusBar( this._units, this.unitsStatusBar, From 4abece123e54323b43e825b12c92018498e1e958 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 26 Aug 2022 17:14:02 -0400 Subject: [PATCH 43/79] Fixed clearFields to clear results --- src/webviews/apps/calc/calc.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 0299c1a..b55130d 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -164,10 +164,16 @@ export class CalcApp extends GWebviewApp { if (target) { const targetView = target.id.split('-')[1]; + // Clear Input Fields document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; element.value = ''; }); + + // Clear Results Field + document.querySelectorAll(`#view-${targetView} span.results`).forEach(span => { + span.innerHTML = ''; + }); } } From 4654d2234d9311bf01ac9bffdd30f6d6243fedab Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 26 Aug 2022 18:32:11 -0400 Subject: [PATCH 44/79] Moved webviewMsg file --- src/webviews/{apps/shared => }/webviewMsg.types.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/webviews/{apps/shared => }/webviewMsg.types.ts (100%) diff --git a/src/webviews/apps/shared/webviewMsg.types.ts b/src/webviews/webviewMsg.types.ts similarity index 100% rename from src/webviews/apps/shared/webviewMsg.types.ts rename to src/webviews/webviewMsg.types.ts From 619f4a479afc7224c0cda2c575bf76593818c8f2 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:44:41 -0400 Subject: [PATCH 45/79] Added calcWebviewView getter; Renamed Units Controller --- src/control.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/control.ts b/src/control.ts index d5b785e..2ea44ee 100644 --- a/src/control.ts +++ b/src/control.ts @@ -32,9 +32,9 @@ export class Control { private static _version: Version; // Controllers - private static _machineTypeControl: MachineTypeControl | undefined; + private static _machineTypeControl: MachineTypeControl; private static _statusBarControl: StatusBarControl; - private static _unitsController: GCodeUnitsController | undefined; + private static _unitsController: GCodeUnitsController; private static _stateController: StateControl; private static _hoverController: GCodeHoverControl; @@ -192,7 +192,7 @@ export class Control { return this._statusBarControl; } - static get gcodeUnitsController() { + static get unitsController() { return this._unitsController; } @@ -207,4 +207,8 @@ export class Control { static get hoverController() { return this._hoverController; } + + static get calcWebviewView() { + return this._calcWebviewView; + } } From 6118dc963e693b81d839a1e6024adc11776e93fc Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:46:03 -0400 Subject: [PATCH 46/79] Added GCodeUnits enum --- src/util/constants.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/constants.ts b/src/util/constants.ts index 2554467..24008cf 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -77,6 +77,13 @@ export enum Contexts { CalcWebviewViewEnabled = 'gcode:webviews:calc:enabled', } +export enum GCodeUnits { + Auto = 'Auto', + Inch = 'Inch', + MM = 'Metric', + Default = 'Default (Inch)', +} + export enum GCommands { ShowGCodeSettings = 'gcode.showSettings', ShowSupportGCode = 'gcode.supportGCode', From 13be27021fbfd9ce7efbae142cf1d7c5ad8535d9 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:47:00 -0400 Subject: [PATCH 47/79] Changed location of GCodeUnits --- src/util/configuration/defaults.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/configuration/defaults.ts b/src/util/configuration/defaults.ts index 0ed9eb4..fef7eb7 100644 --- a/src/util/configuration/defaults.ts +++ b/src/util/configuration/defaults.ts @@ -6,8 +6,8 @@ 'use strict'; import { StatusBarAlignment } from 'vscode'; -import { GCodeUnits } from '../../gcodeUnits'; -import { LineNumbererOptions, LineNumberFrequency } from '../lineNumberer'; +import { GCodeUnits } from '../constants'; +import { LineNumberFrequency } from '../lineNumberer'; export enum TraceLevel { Silent = 'silent', From 51a4e423ada0c47710694a9e79aa1f78def4c49a Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:48:14 -0400 Subject: [PATCH 48/79] Fixed units HTML & SCSS --- src/webviews/apps/calc/calc.html | 4 ++-- src/webviews/apps/calc/calc.scss | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 9d1afc4..0f15174 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -33,7 +33,7 @@

SFM

- Units: + Units:
@@ -63,7 +63,7 @@

Chip Load

- Units: +
diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index 2edb746..f4e859b 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -49,6 +49,11 @@ span.clear-btn { margin-top: 1rem; } +span.units { + font-weight: 600; + font-size: 0.9em; +} + label.results { font-style: italic; margin-top: 1rem; From 3a395482c740de89d306aad9b0b2ef0d77d0c93d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:48:57 -0400 Subject: [PATCH 49/79] Changed Units type to enum --- src/webviews/apps/calc/calc.types.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index 300872a..8728786 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -38,4 +38,8 @@ export interface ICalcDom { export type TCalcDom = ICalcDom[keyof ICalcDom]; -export type Units = 'Inch' | 'Metric'; +export enum Units { + Inch = 'Inch', + MM = 'Metric', + Default = 'Default (Inch)', +} From 6d25a5a0cfeeeeaf514d9daf0457c53b45380635 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:49:42 -0400 Subject: [PATCH 50/79] Added webviewMsg.types to includes --- src/webviews/apps/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webviews/apps/tsconfig.json b/src/webviews/apps/tsconfig.json index 39f7eb2..81d0397 100644 --- a/src/webviews/apps/tsconfig.json +++ b/src/webviews/apps/tsconfig.json @@ -9,7 +9,8 @@ "outDir": "../../" }, "include": [ - "**/*.ts" + "**/*.ts", + "../webviewMsg.types.ts" ], "exclude": [ "node_modules", From 6c16eedc16ab818530d19b93ed0a09724f66f244 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 17:57:45 -0400 Subject: [PATCH 51/79] Refactored Units Controller; Added Units change event --- src/gcodeUnits.ts | 156 +++++++++++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 64 deletions(-) diff --git a/src/gcodeUnits.ts b/src/gcodeUnits.ts index d4ba25c..f4aa569 100644 --- a/src/gcodeUnits.ts +++ b/src/gcodeUnits.ts @@ -4,84 +4,92 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { ConfigurationChangeEvent, Disposable, TextDocumentChangeEvent, TextEditor, window, workspace } from 'vscode'; +import { + ConfigurationChangeEvent, + Disposable, + Event, + EventEmitter, + TextDocumentChangeEvent, + TextEditor, + window, + workspace, +} from 'vscode'; import { Control } from './control'; import { configuration } from './util/configuration/config'; import { defaults } from './util/configuration/defaults'; -import { GCommands } from './util/constants'; +import { GCodeUnits, GCommands } from './util/constants'; import { Logger } from './util/logger'; import { StatusBar, StatusBarControl } from './util/statusBar'; -export const enum GCodeUnits { - Inch = 'Inch', - MM = 'Metric', - Auto = 'Auto', - Default = 'Default (Inch)', -} +type Units = GCodeUnits.Inch | GCodeUnits.MM | GCodeUnits.Default; -const cfgUnits = 'general.units'; +export const cfgUnits = 'general.units'; export class GCodeUnitsController implements Disposable { - private readonly _disposable: Disposable | undefined; + private readonly _disposables: Disposable[] = []; + private readonly unitsStatusBar: StatusBar = 'unitsBar'; private _editor: TextEditor | undefined; private _statusbar: StatusBarControl; - private readonly unitsStatusBar: StatusBar = 'unitsBar'; - private _units: GCodeUnits; + private _units: Units; private _auto: boolean; + private _onDidChangeUnits: EventEmitter = new EventEmitter(); + get onDidChangeUnits(): Event { + return this._onDidChangeUnits.event; + } + constructor() { + Logger.log('Loading Units Controller...'); + this._statusbar = Control.statusBarController; - this._auto = (this._units = configuration.getParam(cfgUnits) ?? defaults.general.units) === GCodeUnits.Auto; + const units = configuration.getParam(cfgUnits) ?? defaults.general.units; + if (units === GCodeUnits.Auto) { + this._auto = true; + this._units = GCodeUnits.Default; + } else { + this._auto = false; + this._units = units; + } - this._statusbar.updateStatusBar( - this._units, - this.unitsStatusBar, - undefined, - undefined, - GCommands.ShowGCodeSettings, - ); + this.updateStatusBar(); - Control.context.subscriptions.push(configuration.onDidChange(this.onConfigurationChanged, this)); - Control.context.subscriptions.push(window.onDidChangeActiveTextEditor(() => this.onActiveEditorChanged())); - Control.context.subscriptions.push(workspace.onDidChangeTextDocument(e => this.onDocumentChanged(e), this)); + this._disposables.push( + configuration.onDidChange(this.onConfigurationChanged, this), + window.onDidChangeActiveTextEditor(() => this.onActiveEditorChanged()), + workspace.onDidChangeTextDocument(e => this.onDocumentChanged(e), this), + ); } dispose() { - this._disposable && this._disposable.dispose(); + Disposable.from(...this._disposables).dispose(); + } + + get units(): Units { + return this._units; } private onConfigurationChanged(e: ConfigurationChangeEvent) { if (configuration.changed(e, cfgUnits)) { - if ((this._units = configuration.getParam(cfgUnits) ?? defaults.general.units) !== GCodeUnits.Auto) { + const units = configuration.getParam(cfgUnits) ?? defaults.general.units; + if (units !== GCodeUnits.Auto) { + // Update Units + this._units = units; Logger.log(`Units: ${this._units}`); // Set Auto False this._auto = false; - // Update Statusbar with new Units - this._statusbar.updateStatusBar( - this._units, - this.unitsStatusBar, - undefined, - undefined, - GCommands.ShowGCodeSettings, - ); + this.updateStatusBar(); + + // Fire Units Change Event + this._onDidChangeUnits.fire(this._units); } else { // Units = Auto - Logger.log(`Units: ${this._units}`); + Logger.log('Units: Auto'); // Set Auto True this._auto = true; - - // Updates Statusbar with Auto Units - this._statusbar.updateStatusBar( - this._units, - this.unitsStatusBar, - undefined, - undefined, - GCommands.ShowGCodeSettings, - ); } } } @@ -92,16 +100,19 @@ export class GCodeUnitsController implements Disposable { const text = this._editor.document.getText(); // Parse doc for units - this._units = this.parseUnits(text); - - // Update Status Bar - this._statusbar.updateStatusBar( - this._units, - this.unitsStatusBar, - undefined, - undefined, - GCommands.ShowGCodeSettings, - ); + const newUnits = this.parseUnits(text); + + if (newUnits === this._units) { + return; + } else { + this._units = newUnits; + + // Update Statusbar + this.updateStatusBar(); + + // Fire Units Change Event + this._onDidChangeUnits.fire(this._units); + } } else { return; } @@ -112,24 +123,41 @@ export class GCodeUnitsController implements Disposable { if ((this._editor = window.activeTextEditor) && this._editor.document.uri.scheme === 'file') { if (this._auto) { const text = this._editor.document.getText(); + // Parse doc for units - this._units = this.parseUnits(text); - - // Update Status Bar - this._statusbar.updateStatusBar( - this._units, - this.unitsStatusBar, - undefined, - undefined, - GCommands.ShowGCodeSettings, - ); + const newUnits = this.parseUnits(text); + + if (newUnits === this._units) { + return; + } else { + this._units = newUnits; + + // Update Statusbar + this.updateStatusBar(); + + // Fire Units Change Event + this._onDidChangeUnits.fire(this._units); + } } else { return; } } } - private parseUnits(text: string): GCodeUnits { + private updateStatusBar(): void { + let tooltip = `${this._units}`; + let units = `${this.units}`; + if (this._auto && this._units !== GCodeUnits.Default) { + this._units === GCodeUnits.Inch + ? (tooltip = `${tooltip} (G20 Found)`) + : (tooltip = `${tooltip} (G21 Found)`); + + units = `${units} (Auto)`; + } + this._statusbar.updateStatusBar(units, this.unitsStatusBar, tooltip, undefined, GCommands.ShowGCodeSettings); + } + + private parseUnits(text: string): Units { const reUnits = /(G20)|(G21)/im; const units = reUnits.exec(text); From daf025ebff82aff48a40aafbd26fb6ee29572c17 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 18:17:36 -0400 Subject: [PATCH 52/79] Added message passing --- src/webviews/gWebviewView.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index e1de998..3763185 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -18,6 +18,7 @@ import { } from 'vscode'; import { Control } from '../control'; import { Logger } from '../util/logger'; +import { WebviewMsg } from './webviewMsg.types'; export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected readonly _disposables: Disposable[] = []; @@ -28,7 +29,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { constructor(public readonly id: string, title: string) { this._title = title; - this._disposables.push(window.registerWebviewViewProvider(id, this)); + this._disposables.push(window.registerWebviewViewProvider(id, this), ...(this.registerCommands?.() ?? [])); } dispose() { @@ -86,6 +87,8 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { webviewView.webview.options = this.getWebviewOptions(); webviewView.title = this.title; + this._disposables.push(this._view.webview.onDidReceiveMessage(this.onMessageReceived, this)); + await this.refresh(); } @@ -96,8 +99,8 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { } protected abstract getHtml(webview: Webview): Promise; - - protected abstract registerCommands(): Disposable[]; + protected registerCommands?(): Disposable[]; + protected handleMessage?(msg: WebviewMsg): void; protected getWebviewOptions(): WebviewOptions { return { @@ -106,4 +109,20 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { localResourceRoots: [Uri.joinPath(Control.context.extensionUri)], }; } + + protected onMessageReceived(msg: WebviewMsg): void { + if (msg) { + this.handleMessage?.(msg); + } else { + return; + } + } + + protected async postMessage(msg: WebviewMsg) { + if (this._view) { + return await this._view.webview.postMessage(msg); + } else { + return Promise.resolve(false); + } + } } From bcaea069ea51cf9f13f710bbf038e387718d1326 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 18:25:27 -0400 Subject: [PATCH 53/79] Added register events to constructor --- src/webviews/apps/shared/gWebviewApp.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webviews/apps/shared/gWebviewApp.ts b/src/webviews/apps/shared/gWebviewApp.ts index e4a8ade..0eac859 100644 --- a/src/webviews/apps/shared/gWebviewApp.ts +++ b/src/webviews/apps/shared/gWebviewApp.ts @@ -17,13 +17,14 @@ export abstract class GWebviewApp { constructor(protected readonly appName: string) { this._api = acquireVsCodeApi(); + this.registerEvents(); } private registerEvents(): void { window.addEventListener('message', this.onMsgReceived.bind(this)); } - private postMessage(msg: any): void { + protected postMessage(msg: any): void { this._api.postMessage(msg); } From e0f482fd647e628a4f2e2f8b81b35aee61aad156 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 18:26:39 -0400 Subject: [PATCH 54/79] Added units tracking & message passing --- src/webviews/calc/calcWebviewView.ts | 33 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 7631a6a..57870a8 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -13,6 +13,7 @@ import { Contexts, WebviewCommands, Webviews, WebviewTitles } from '../../util/c import { Logger } from '../../util/logger'; import { GWebviewView } from '../gWebviewView'; import { getNonce } from '../helpers'; +import { WebviewMsg } from '../webviewMsg.types'; export class CalcWebviewView extends GWebviewView { private _shortId: string; @@ -27,7 +28,10 @@ export class CalcWebviewView extends GWebviewView { void Control.setContext(Contexts.CalcWebviewViewEnabled, true); } - this._disposables.push(configuration.onDidChange(this.onConfigurationChanged, this)); + this._disposables.push( + configuration.onDidChange(this.onConfigurationChanged, this), + Control.unitsController.onDidChangeUnits(() => this.changeUnits()), + ); } dispose() { @@ -35,6 +39,7 @@ export class CalcWebviewView extends GWebviewView { } private onConfigurationChanged(e: ConfigurationChangeEvent) { + // Enable / Disable Calculator Webview if (configuration.changed(e, `${this.id.slice(6)}.enabled`)) { if (this._enabled) { // Disable @@ -46,13 +51,11 @@ export class CalcWebviewView extends GWebviewView { void Control.setContext(Contexts.CalcWebviewViewEnabled, true); } - // void this.refresh(); - this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled; } } - protected registerCommands(): Disposable[] { + protected override registerCommands(): Disposable[] { return [ commands.registerCommand( WebviewCommands.ShowCalcWebview, @@ -64,7 +67,21 @@ export class CalcWebviewView extends GWebviewView { ]; } - async getHtml(webview: Webview): Promise { + protected override async handleMessage(msg: WebviewMsg): Promise { + const type = msg.type; + + switch (type) { + case 'getUnits': + await this.postMessage({ type: 'changeUnits', payload: Control.unitsController.units }); + + break; + + default: + return; + } + } + + protected async getHtml(webview: Webview): Promise { const webRootUri = Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews'); const uri = Uri.joinPath(webRootUri, this._shortId, `${this._shortId}.html`); const content = new TextDecoder('utf8').decode(await workspace.fs.readFile(uri)); @@ -110,4 +127,10 @@ export class CalcWebviewView extends GWebviewView { return Promise.resolve(html); } + + private changeUnits() { + if (this._enabled) { + void this.postMessage({ type: 'changeUnits', payload: Control.unitsController?.units }); + } + } } From 75e02c97e9e92ca47cf4bed79f291cd54b385547 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 1 Sep 2022 18:28:33 -0400 Subject: [PATCH 55/79] Added units tracking --- src/webviews/apps/calc/calc.ts | 42 ++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index b55130d..81c6772 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -5,12 +5,13 @@ 'use strict'; import { GWebviewApp } from '../shared/gWebviewApp'; -import { WebviewMsg } from '../shared/webviewMsg.types'; +import { WebviewMsg } from '../../webviewMsg.types'; import { ICalcDom, TCalcDom, Units } from './calc.types'; export class CalcApp extends GWebviewApp { private _calcDom: ICalcDom = {}; - private _units: Units = 'Inch'; + private _clearBtns: NodeListOf | undefined; + private _units: Units = Units.Default; constructor() { super('CalcApp'); @@ -20,6 +21,9 @@ export class CalcApp extends GWebviewApp { // Register Button Events this.registerBtns(); + + // Get Current Units + this.getUnits(); } private populateDOM(): void { @@ -66,20 +70,40 @@ export class CalcApp extends GWebviewApp { protected onMsgReceived(e: MessageEvent): void { const message = e.data; - if (message.type === 'changeUnits') { - this._units = message.payload as Units; + switch (message.type) { + case 'changeUnits': + this._units = message.payload as Units; + this.updateUnits(); + this._clearBtns?.forEach(btn => { + btn.click(); + }); + + break; + + default: + return; } } + private getUnits(): void { + this.postMessage({ type: 'getUnits' }); + } + + private updateUnits(): void { + document.querySelectorAll('span.units').forEach(elem => { + elem.innerHTML = `Units: ${this._units}`; + }); + } + private registerBtns(): void { Object.keys(this._calcDom).forEach(key => { this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this.processEvent.bind(this), false); }); - const clearBtns = document.querySelectorAll('span.clear-btn > vscode-button'); + this._clearBtns = document.querySelectorAll('span.clear-btn > vscode-button'); - if (clearBtns) { - clearBtns.forEach(btn => { + if (this._clearBtns) { + this._clearBtns.forEach(btn => { btn.addEventListener('click', this.clearFields.bind(this), false); }); } @@ -196,7 +220,7 @@ export class CalcApp extends GWebviewApp { } private calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { - if (units === 'Inch') { + if (units === Units.Inch || units === Units.Default) { return (sfm * 12) / (Math.PI * toolDia); } else { return (sfm * 1000) / (Math.PI * toolDia); @@ -204,7 +228,7 @@ export class CalcApp extends GWebviewApp { } private calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { - if (units === 'Inch') { + if (units === Units.Inch || units === Units.Default) { // Calculate SFM for Imperial return (Math.PI * toolDia * rpm) / 12; } else { From 426a2bd4bfd15ca60c8ac9452f1cc0b541a7fc0d Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 26 Sep 2022 16:35:03 -0400 Subject: [PATCH 56/79] Added html-loader --- package-lock.json | 758 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- 2 files changed, 757 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5660daf..458a8e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-gcode-syntax", - "version": "0.7.5", + "version": "0.7.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-gcode-syntax", - "version": "0.7.5", + "version": "0.7.6", "license": "MIT", "dependencies": { "@appliedengdesign/gcode-reference": "^0.0.7", @@ -30,6 +30,7 @@ "eslint-plugin-prettier": "^4.2.1", "eslint-webpack-plugin": "^3.2.0", "glob": "^8.0.3", + "html-loader": "^4.2.0", "mini-css-extract-plugin": "^2.6.1", "mocha": "^10.0.0", "prettier": "^2.7.1", @@ -354,6 +355,13 @@ "@types/node": "*" } }, + "node_modules/@types/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==", + "dev": true, + "peer": true + }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -1054,6 +1062,12 @@ "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=", "dev": true }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1151,6 +1165,22 @@ "node": ">=6" } }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, + "node_modules/camel-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/caniuse-lite": { "version": "1.0.30001230", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz", @@ -1444,6 +1474,19 @@ "node": ">=6.0" } }, + "node_modules/clean-css": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz", + "integrity": "sha512-lCr8OHhiWCTw4v8POJovCoh4T7I9U11yVsPjMWWnnMmp9ZowCxyad1Pathle/9HjaDp+fdQKjO9fQydE6RHTZg==", + "dev": true, + "peer": true, + "dependencies": { + "source-map": "~0.6.0" + }, + "engines": { + "node": ">= 10.0" + } + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1691,6 +1734,35 @@ "webpack": "^5.0.0" } }, + "node_modules/css-select": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", + "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", + "dev": true, + "peer": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -1783,6 +1855,90 @@ "node": ">=6.0.0" } }, + "node_modules/dom-converter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", + "dev": true, + "peer": true, + "dependencies": { + "utila": "~0.4" + } + }, + "node_modules/dom-serializer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", + "dev": true, + "peer": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", + "dev": true, + "peer": true, + "dependencies": { + "domelementtype": "^2.2.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, + "peer": true, + "dependencies": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/dot-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -1823,6 +1979,16 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "peer": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", @@ -2856,6 +3022,156 @@ "he": "bin/he" } }, + "node_modules/html-loader": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-4.2.0.tgz", + "integrity": "sha512-OxCHD3yt+qwqng2vvcaPApCEvbx+nXWu+v69TYHx1FO8bffHn/JjHtE3TTQZmHjwvnJe4xxzuecetDVBrQR1Zg==", + "dev": true, + "dependencies": { + "html-minifier-terser": "^7.0.0", + "parse5": "^7.0.0" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, + "node_modules/html-loader/node_modules/clean-css": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.0.tgz", + "integrity": "sha512-2639sWGa43EMmG7fn8mdVuBSs6HuWaSor+ZPoFWzenBc6oN+td8YhTfghWXZ25G1NiiSvz8bOFBS7PdSbTiqEA==", + "dev": true, + "dependencies": { + "source-map": "~0.6.0" + }, + "engines": { + "node": ">= 10.0" + } + }, + "node_modules/html-loader/node_modules/commander": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz", + "integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==", + "dev": true, + "engines": { + "node": "^12.20.0 || >=14" + } + }, + "node_modules/html-loader/node_modules/entities": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz", + "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/html-loader/node_modules/html-minifier-terser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.0.0.tgz", + "integrity": "sha512-Adqk0b/pWKIQiGvEAuzPKpBKNHiwblr3QSGS7TTr6v+xXKV9AI2k4vWW+6Oytt6Z5SeBnfvYypKOnz8r75pz3Q==", + "dev": true, + "dependencies": { + "camel-case": "^4.1.2", + "clean-css": "5.2.0", + "commander": "^9.4.0", + "entities": "^4.3.1", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.14.2" + }, + "bin": { + "html-minifier-terser": "cli.js" + }, + "engines": { + "node": "^14.13.1 || >=16.0.0" + } + }, + "node_modules/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", + "dev": true, + "peer": true, + "dependencies": { + "camel-case": "^4.1.2", + "clean-css": "^5.2.2", + "commander": "^8.3.0", + "he": "^1.2.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.10.0" + }, + "bin": { + "html-minifier-terser": "cli.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/html-minifier-terser/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "peer": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/html-webpack-plugin": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw==", + "dev": true, + "peer": true, + "dependencies": { + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", + "lodash": "^4.17.21", + "pretty-error": "^4.0.0", + "tapable": "^2.0.0" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/html-webpack-plugin" + }, + "peerDependencies": { + "webpack": "^5.20.0" + } + }, + "node_modules/htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "peer": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "node_modules/http-proxy-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", @@ -3486,6 +3802,21 @@ "get-func-name": "^2.0.0" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/lower-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -3806,6 +4137,22 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/no-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/node-releases": { "version": "1.1.71", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", @@ -3821,6 +4168,18 @@ "node": ">=0.10.0" } }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, "node_modules/object-inspect": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", @@ -3945,6 +4304,22 @@ "node": ">=6" } }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/param-case/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -4244,6 +4619,17 @@ "node": ">=6.0.0" } }, + "node_modules/pretty-error": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", + "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", + "dev": true, + "peer": true, + "dependencies": { + "lodash": "^4.17.20", + "renderkid": "^3.0.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -4357,6 +4743,29 @@ "url": "https://github.com/sponsors/mysticatea" } }, + "node_modules/relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/renderkid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", + "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", + "dev": true, + "peer": true, + "dependencies": { + "css-select": "^4.1.3", + "dom-converter": "^0.2.0", + "htmlparser2": "^6.1.0", + "lodash": "^4.17.21", + "strip-ansi": "^6.0.1" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -5184,6 +5593,13 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/utila": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", + "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==", + "dev": true, + "peer": true + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -5854,6 +6270,13 @@ "@types/node": "*" } }, + "@types/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==", + "dev": true, + "peer": true + }, "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -6378,6 +6801,12 @@ "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=", "dev": true }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -6450,6 +6879,24 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "requires": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "caniuse-lite": { "version": "1.0.30001230", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz", @@ -6661,6 +7108,16 @@ "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", "dev": true }, + "clean-css": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz", + "integrity": "sha512-lCr8OHhiWCTw4v8POJovCoh4T7I9U11yVsPjMWWnnMmp9ZowCxyad1Pathle/9HjaDp+fdQKjO9fQydE6RHTZg==", + "dev": true, + "peer": true, + "requires": { + "source-map": "~0.6.0" + } + }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -6848,6 +7305,26 @@ "semver": "^7.3.5" } }, + "css-select": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", + "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", + "dev": true, + "peer": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + } + }, + "css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true + }, "cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -6911,6 +7388,74 @@ "esutils": "^2.0.2" } }, + "dom-converter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", + "dev": true, + "peer": true, + "requires": { + "utila": "~0.4" + } + }, + "dom-serializer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", + "dev": true, + "peer": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + } + }, + "domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true + }, + "domhandler": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", + "dev": true, + "peer": true, + "requires": { + "domelementtype": "^2.2.0" + } + }, + "domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, + "peer": true, + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + } + }, + "dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "requires": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -6948,6 +7493,13 @@ "tapable": "^2.2.0" } }, + "entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "peer": true + }, "envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", @@ -7730,6 +8282,106 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "html-loader": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-4.2.0.tgz", + "integrity": "sha512-OxCHD3yt+qwqng2vvcaPApCEvbx+nXWu+v69TYHx1FO8bffHn/JjHtE3TTQZmHjwvnJe4xxzuecetDVBrQR1Zg==", + "dev": true, + "requires": { + "html-minifier-terser": "^7.0.0", + "parse5": "^7.0.0" + }, + "dependencies": { + "clean-css": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.0.tgz", + "integrity": "sha512-2639sWGa43EMmG7fn8mdVuBSs6HuWaSor+ZPoFWzenBc6oN+td8YhTfghWXZ25G1NiiSvz8bOFBS7PdSbTiqEA==", + "dev": true, + "requires": { + "source-map": "~0.6.0" + } + }, + "commander": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz", + "integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==", + "dev": true + }, + "entities": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz", + "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "dev": true + }, + "html-minifier-terser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.0.0.tgz", + "integrity": "sha512-Adqk0b/pWKIQiGvEAuzPKpBKNHiwblr3QSGS7TTr6v+xXKV9AI2k4vWW+6Oytt6Z5SeBnfvYypKOnz8r75pz3Q==", + "dev": true, + "requires": { + "camel-case": "^4.1.2", + "clean-css": "5.2.0", + "commander": "^9.4.0", + "entities": "^4.3.1", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.14.2" + } + } + } + }, + "html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", + "dev": true, + "peer": true, + "requires": { + "camel-case": "^4.1.2", + "clean-css": "^5.2.2", + "commander": "^8.3.0", + "he": "^1.2.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.10.0" + }, + "dependencies": { + "commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "peer": true + } + } + }, + "html-webpack-plugin": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw==", + "dev": true, + "peer": true, + "requires": { + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", + "lodash": "^4.17.21", + "pretty-error": "^4.0.0", + "tapable": "^2.0.0" + } + }, + "htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "peer": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "http-proxy-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", @@ -8189,6 +8841,23 @@ "get-func-name": "^2.0.0" } }, + "lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "requires": { + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -8434,6 +9103,24 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "requires": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "node-releases": { "version": "1.1.71", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", @@ -8446,6 +9133,15 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, + "nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "requires": { + "boolbase": "^1.0.0" + } + }, "object-inspect": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", @@ -8534,6 +9230,24 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "requires": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + } + } + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -8739,6 +9453,17 @@ "fast-diff": "^1.1.2" } }, + "pretty-error": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", + "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", + "dev": true, + "peer": true, + "requires": { + "lodash": "^4.17.20", + "renderkid": "^3.0.0" + } + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -8822,6 +9547,26 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, + "relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "dev": true + }, + "renderkid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", + "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", + "dev": true, + "peer": true, + "requires": { + "css-select": "^4.1.3", + "dom-converter": "^0.2.0", + "htmlparser2": "^6.1.0", + "lodash": "^4.17.21", + "strip-ansi": "^6.0.1" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -9375,6 +10120,13 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utila": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", + "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==", + "dev": true, + "peer": true + }, "v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -9661,4 +10413,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index f0f1c7c..0779025 100644 --- a/package.json +++ b/package.json @@ -619,6 +619,7 @@ "eslint-plugin-prettier": "^4.2.1", "eslint-webpack-plugin": "^3.2.0", "glob": "^8.0.3", + "html-loader": "^4.2.0", "mini-css-extract-plugin": "^2.6.1", "mocha": "^10.0.0", "prettier": "^2.7.1", @@ -637,4 +638,4 @@ "@appliedengdesign/gcode-reference": "^0.0.7", "@vscode/webview-ui-toolkit": "^1.0.0" } -} \ No newline at end of file +} From 4a1967b15bd46c87f38eaf47f68591999b3c0ab9 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 26 Sep 2022 16:35:37 -0400 Subject: [PATCH 57/79] Removed old calcWebviewView file --- src/webviews/calcWebviewView.ts | 82 --------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 src/webviews/calcWebviewView.ts diff --git a/src/webviews/calcWebviewView.ts b/src/webviews/calcWebviewView.ts deleted file mode 100644 index 00862db..0000000 --- a/src/webviews/calcWebviewView.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* --------------------------------------------------------------------------------------------- - * Copyright (c) Applied Eng & Design All rights reserved. - * Licensed under the MIT License. See License.md in the project root for license information. - * -------------------------------------------------------------------------------------------- */ -'use strict'; - -import { TextDecoder } from 'util'; -import { Uri, Webview, workspace } from 'vscode'; -import { Control } from '../control'; -import { GWebviewView } from './gWebviewView'; - -const CalcWebviewInfo = { - ViewId: 'gcode.webviews.calc', - Title: 'Milling / Turning Calculators', -}; - -export class CalcWebviewView extends GWebviewView { - constructor() { - super(CalcWebviewInfo.ViewId, CalcWebviewInfo.Title); - } - - async getHtml(webview: Webview): Promise { - // CSS styles - const stylesReset = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'reset.css'), - ); - - const stylesMain = webview.asWebviewUri( - Uri.joinPath(Control.context.extensionUri, 'resources', 'webviews', 'css', 'vscode.css'), - ); - - // vscode-webview-ui-toolkit - const toolkitUri = webview.asWebviewUri( - Uri.joinPath( - Control.context.extensionUri, - 'node_modules', - '@vscode', - 'webview-ui-toolkit', - 'dist', - 'toolkit.js', - ), - ); - - const nonce = this.getNonce(); - - // const body = new TextDecoder('utf8').decode(await workspace.fs.readFile()) - - return Promise.resolve(` - - - - - - - - - - - - - - Calc - - - - MILLING - TURNING - - - - Calculate> - -
-
- -
- - `); - } -} From 66b522391ef9ce0b9415722024827bb550e826be Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 26 Sep 2022 16:36:22 -0400 Subject: [PATCH 58/79] Fixed missing LineNumbererOptions from rebase --- src/util/configuration/defaults.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/configuration/defaults.ts b/src/util/configuration/defaults.ts index fef7eb7..268bda6 100644 --- a/src/util/configuration/defaults.ts +++ b/src/util/configuration/defaults.ts @@ -7,7 +7,7 @@ import { StatusBarAlignment } from 'vscode'; import { GCodeUnits } from '../constants'; -import { LineNumberFrequency } from '../lineNumberer'; +import { LineNumbererOptions, LineNumberFrequency } from '../lineNumberer'; export enum TraceLevel { Silent = 'silent', From 50b21bcbd32429167b60fff009321b5bf15aabb9 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 26 Sep 2022 16:38:24 -0400 Subject: [PATCH 59/79] Fixed a few typos --- src/webviews/calc/calcWebviewView.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 57870a8..b8f4da4 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -29,8 +29,8 @@ export class CalcWebviewView extends GWebviewView { } this._disposables.push( - configuration.onDidChange(this.onConfigurationChanged, this), - Control.unitsController.onDidChangeUnits(() => this.changeUnits()), + configuration.onDidChange(this._onConfigurationChanged, this), + Control.unitsController.onDidChangeUnits(() => this._changeUnits()), ); } @@ -38,7 +38,7 @@ export class CalcWebviewView extends GWebviewView { super.dispose(); } - private onConfigurationChanged(e: ConfigurationChangeEvent) { + private _onConfigurationChanged(e: ConfigurationChangeEvent) { // Enable / Disable Calculator Webview if (configuration.changed(e, `${this.id.slice(6)}.enabled`)) { if (this._enabled) { @@ -128,9 +128,9 @@ export class CalcWebviewView extends GWebviewView { return Promise.resolve(html); } - private changeUnits() { + private _changeUnits() { if (this._enabled) { - void this.postMessage({ type: 'changeUnits', payload: Control.unitsController?.units }); + void this.postMessage({ type: 'changeUnits', payload: Control.unitsController.units }); } } } From 950431719dc848ef55a2fc7f000d9fe2a47d424e Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Mon, 26 Sep 2022 17:08:33 -0400 Subject: [PATCH 60/79] Renamed MachineTypeControl -> MachineTypeController --- src/control.ts | 10 +++++----- src/util/{machineType.ts => machineTypeController.ts} | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/util/{machineType.ts => machineTypeController.ts} (98%) diff --git a/src/control.ts b/src/control.ts index 2ea44ee..d19dc8b 100644 --- a/src/control.ts +++ b/src/control.ts @@ -16,7 +16,7 @@ import { constants, Contexts, GCommands, PIcon, VSBuiltInCommands } from './util import { Version } from './util/version'; import { Messages } from './util/messages'; import { StateControl } from './util/stateControl'; -import { MachineTypeControl } from './util/machineType'; +import { MachineTypeController } from './util/machineTypeController'; import { GCodeHoverControl } from './hovers/gcodeHoverControl'; import { registerCommands } from './util/commands'; import { CalcWebviewView } from './webviews/calc/calcWebviewView'; @@ -32,7 +32,7 @@ export class Control { private static _version: Version; // Controllers - private static _machineTypeControl: MachineTypeControl; + private static _machineTypeController: MachineTypeController; private static _statusBarControl: StatusBarControl; private static _unitsController: GCodeUnitsController; private static _stateController: StateControl; @@ -97,7 +97,7 @@ export class Control { // Load Machine Type Logger.log('Loading Machine Type Controller...'); - context.subscriptions.push((this._machineTypeControl = new MachineTypeControl())); + context.subscriptions.push((this._machineTypeController = new MachineTypeController())); // Load Hover Controller Logger.log('Loading Hover Controller...'); @@ -147,7 +147,7 @@ export class Control { // Dispose Controllers this._hoverController.dispose(); this._unitsController?.dispose(); - this._machineTypeControl?.dispose(); + this._machineTypeController?.dispose(); this._statusBarControl?.dispose(); } @@ -201,7 +201,7 @@ export class Control { } static get machineTypeController() { - return this._machineTypeControl; + return this._machineTypeController; } static get hoverController() { diff --git a/src/util/machineType.ts b/src/util/machineTypeController.ts similarity index 98% rename from src/util/machineType.ts rename to src/util/machineTypeController.ts index 5153f67..40c137b 100644 --- a/src/util/machineType.ts +++ b/src/util/machineTypeController.ts @@ -12,7 +12,7 @@ import { StatusBar, StatusBarControl } from './statusBar'; import { Control } from '../control'; import { GCommands } from './constants'; -export class MachineTypeControl implements Disposable { +export class MachineTypeController implements Disposable { private readonly _dispoable: Disposable | undefined; private _machineType: MachineTypes | undefined; private _statusbar: StatusBarControl; From 2321ee60ef9762f8d07cf54c1297c6f5accaf652 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:30:37 -0400 Subject: [PATCH 61/79] Added bootstrap & subscription to MachineType change --- src/webviews/calc/calcWebviewView.ts | 36 +++++++++++++++++++++++++--- src/webviews/gWebviewView.ts | 1 + 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index b8f4da4..9c4d1e4 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -31,10 +31,12 @@ export class CalcWebviewView extends GWebviewView { this._disposables.push( configuration.onDidChange(this._onConfigurationChanged, this), Control.unitsController.onDidChangeUnits(() => this._changeUnits()), + Control.machineTypeController.onDidChangeMachineType(() => this._changeMachineType()), ); } dispose() { + Disposable.from(...this._disposables); super.dispose(); } @@ -76,11 +78,26 @@ export class CalcWebviewView extends GWebviewView { break; + case 'getMachineType': + await this.postMessage({ + type: 'changeMachineType', + payload: Control.machineTypeController.machineType, + }); + + break; + default: return; } } + protected override bootstrap(): WebviewMsg { + return { + type: 'bootstrap', + payload: { units: Control.unitsController.units, machineType: Control.machineTypeController.machineType }, + }; + } + protected async getHtml(webview: Webview): Promise { const webRootUri = Uri.joinPath(Control.context.extensionUri, 'dist', 'webviews'); const uri = Uri.joinPath(webRootUri, this._shortId, `${this._shortId}.html`); @@ -91,6 +108,8 @@ export class CalcWebviewView extends GWebviewView { const root = webview.asWebviewUri(Control.context.extensionUri).toString(); + const bootstrap = this.bootstrap(); + // vscode-webview-ui-toolkit const toolkitUri = webview.asWebviewUri( Uri.joinPath( @@ -103,7 +122,7 @@ export class CalcWebviewView extends GWebviewView { ), ); - const html = content.replace(/{(cspNonce|cspSource|root|title|toolkit)}/g, (_substring, token) => { + const html = content.replace(/{(bootstrap|cspNonce|cspSource|root|title|toolkit)}/g, (_substring, token) => { switch (token) { case 'cspNonce': return cspNonce.toString(); @@ -120,6 +139,11 @@ export class CalcWebviewView extends GWebviewView { case 'toolkit': return ``; + case 'bootstrap': + return ``; + default: return ''; } @@ -128,9 +152,15 @@ export class CalcWebviewView extends GWebviewView { return Promise.resolve(html); } - private _changeUnits() { + private async _changeUnits() { + if (this._enabled) { + await this.postMessage({ type: 'changeUnits', payload: Control.unitsController.units }); + } + } + + private async _changeMachineType() { if (this._enabled) { - void this.postMessage({ type: 'changeUnits', payload: Control.unitsController.units }); + await this.postMessage({ type: 'changeMachineType', payload: Control.machineTypeController.machineType }); } } } diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index 3763185..f6ee52e 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -101,6 +101,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected abstract getHtml(webview: Webview): Promise; protected registerCommands?(): Disposable[]; protected handleMessage?(msg: WebviewMsg): void; + protected bootstrap?(): WebviewMsg; protected getWebviewOptions(): WebviewOptions { return { From cf859d519062f4192bb0194f419921b3ebd2b977 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:31:29 -0400 Subject: [PATCH 62/79] Added subscribable MachineTypeChange --- src/util/machineTypeController.ts | 33 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/util/machineTypeController.ts b/src/util/machineTypeController.ts index 40c137b..b059ff3 100644 --- a/src/util/machineTypeController.ts +++ b/src/util/machineTypeController.ts @@ -4,48 +4,49 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { ConfigurationChangeEvent, Disposable, Event, EventEmitter, workspace } from 'vscode'; -import { GReference, MachineTypes } from '@appliedengdesign/gcode-reference'; +import { ConfigurationChangeEvent, Disposable, Event, EventEmitter } from 'vscode'; +import { GReference, MachineType, MachineTypes } from '@appliedengdesign/gcode-reference'; import { configuration } from './configuration/config'; import { Logger } from './logger'; import { StatusBar, StatusBarControl } from './statusBar'; import { Control } from '../control'; import { GCommands } from './constants'; +import { defaults } from './configuration/defaults'; export class MachineTypeController implements Disposable { - private readonly _dispoable: Disposable | undefined; + private readonly _dispoables: Disposable[] = []; private _machineType: MachineTypes | undefined; private _statusbar: StatusBarControl; private readonly mtypeStatusBar: StatusBar = 'machineTypeBar'; private _gReference: GReference; - private _onDidChange = new EventEmitter(); - get onDidChange(): Event { - return this._onDidChange.event; + private _onDidChangeMachineType: EventEmitter = new EventEmitter(); + get onDidChangeMachineType(): Event { + return this._onDidChangeMachineType.event; } constructor() { this._statusbar = Control.statusBarController; this._gReference = new GReference(); - this.update(); + this._update(); - this._dispoable = Disposable.from(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this)); + this._dispoables.push(configuration.onDidChange(this._onConfigurationChanged, this)); } dispose() { - this._dispoable && this._dispoable.dispose(); + Disposable.from(...this._dispoables).dispose(); } - private onConfigurationChanged(e: ConfigurationChangeEvent) { + private _onConfigurationChanged(e: ConfigurationChangeEvent) { if (configuration.changed(e, 'general.machineType')) { - this.update(); + this._update(); } else { return; } } - private update() { - const cfgMachineType = configuration.getParam('general.machineType'); + private _update() { + const cfgMachineType = configuration.getParam('general.machineType') ?? defaults.general.machineType; Logger.log(`Machine Type: ${cfgMachineType}`); switch (cfgMachineType) { case 'Mill': @@ -76,6 +77,7 @@ export class MachineTypeController implements Disposable { return; } + // Update Status Bar this._statusbar.updateStatusBar( cfgMachineType, this.mtypeStatusBar, @@ -84,10 +86,15 @@ export class MachineTypeController implements Disposable { GCommands.ShowGCodeSettings, ); + // Update GReference this._gReference.setType(this._machineType); } get gReference() { return this._gReference; } + + get machineType() { + return this._machineType; + } } From 4f4c2892c433b0ab16c0e4ab17e28e4a7f362842 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:32:16 -0400 Subject: [PATCH 63/79] Added bootstrapping of Units & MachineType --- src/webviews/apps/calc/calc.html | 2 +- src/webviews/apps/calc/calc.ts | 62 +++++++++++++------------ src/webviews/apps/calc/calc.types.ts | 7 +++ src/webviews/apps/shared/gWebviewApp.ts | 22 ++++++++- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 0f15174..4d90a2c 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -69,7 +69,7 @@

Chip Load

- + {bootstrap} <%= require('html-loader?{"esModule":false}!../shared/partials/tail.html') %> \ No newline at end of file diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 81c6772..0cde259 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -6,27 +6,33 @@ import { GWebviewApp } from '../shared/gWebviewApp'; import { WebviewMsg } from '../../webviewMsg.types'; -import { ICalcDom, TCalcDom, Units } from './calc.types'; +import { calcBootstrap, ICalcDom, TCalcDom, Units } from './calc.types'; +import { MachineTypes } from '@appliedengdesign/gcode-reference/dist/types'; export class CalcApp extends GWebviewApp { private _calcDom: ICalcDom = {}; private _clearBtns: NodeListOf | undefined; + private _machineType: MachineTypes = MachineTypes.Mill; private _units: Units = Units.Default; constructor() { super('CalcApp'); // Populate DOM - this.populateDOM(); + this._populateDOM(); // Register Button Events - this.registerBtns(); + this._registerBtns(); - // Get Current Units - this.getUnits(); + // Load Units & MachineType from Bootstrap + if (this.bootstrap) { + this._machineType = (this.bootstrap.payload as calcBootstrap).machineType; + this._units = (this.bootstrap.payload as calcBootstrap).units; + this._updateUnits(); + } } - private populateDOM(): void { + private _populateDOM(): void { // Populate RPM Calculator this._calcDom.rpm = { btn: document.getElementById('rpm-calc-btn') as HTMLElement, @@ -73,7 +79,7 @@ export class CalcApp extends GWebviewApp { switch (message.type) { case 'changeUnits': this._units = message.payload as Units; - this.updateUnits(); + this._updateUnits(); this._clearBtns?.forEach(btn => { btn.click(); }); @@ -85,31 +91,27 @@ export class CalcApp extends GWebviewApp { } } - private getUnits(): void { - this.postMessage({ type: 'getUnits' }); - } - - private updateUnits(): void { + private _updateUnits(): void { document.querySelectorAll('span.units').forEach(elem => { elem.innerHTML = `Units: ${this._units}`; }); } - private registerBtns(): void { + private _registerBtns(): void { Object.keys(this._calcDom).forEach(key => { - this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this.processEvent.bind(this), false); + this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this._processEvent.bind(this), false); }); this._clearBtns = document.querySelectorAll('span.clear-btn > vscode-button'); if (this._clearBtns) { this._clearBtns.forEach(btn => { - btn.addEventListener('click', this.clearFields.bind(this), false); + btn.addEventListener('click', this._clearFields.bind(this), false); }); } } - private processEvent(e: MouseEvent): void { + private _processEvent(e: MouseEvent): void { const target = e.target as HTMLButtonElement; let result: number | undefined; @@ -123,9 +125,9 @@ export class CalcApp extends GWebviewApp { this._calcDom.rpm.sfm.value = sfm ? sfm.toString() : ''; this._calcDom.rpm.toolDia.value = toolDia ? sfm.toString() : ''; - result = this.calcRPM(sfm, toolDia, this._units); + result = this._calcRPM(sfm, toolDia, this._units); - this.displayResults(result, this._calcDom.rpm); + this._displayResults(result, this._calcDom.rpm); } break; } @@ -138,9 +140,9 @@ export class CalcApp extends GWebviewApp { this._calcDom.sfm.rpm.value = rpm ? rpm.toString() : ''; this._calcDom.sfm.toolDia.value = toolDia ? toolDia.toString() : ''; - result = this.calcSFM(rpm, toolDia, this._units); + result = this._calcSFM(rpm, toolDia, this._units); - this.displayResults(result, this._calcDom.sfm); + this._displayResults(result, this._calcDom.sfm); } break; } @@ -155,9 +157,9 @@ export class CalcApp extends GWebviewApp { this._calcDom.feedrate.numFlutes.value = numFlutes ? numFlutes.toString() : ''; this._calcDom.feedrate.chipLoad.value = chipLoad ? chipLoad.toString() : ''; - result = this.calcFeedRate(rpm, numFlutes, chipLoad); + result = this._calcFeedRate(rpm, numFlutes, chipLoad); - this.displayResults(result, this._calcDom.feedrate); + this._displayResults(result, this._calcDom.feedrate); } break; } @@ -172,9 +174,9 @@ export class CalcApp extends GWebviewApp { this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : ''; this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : ''; - result = this.calcChipLoad(ipm, rpm, numFlutes); + result = this._calcChipLoad(ipm, rpm, numFlutes); - this.displayResults(result, this._calcDom.chipLoad); + this._displayResults(result, this._calcDom.chipLoad); } break; } @@ -182,7 +184,7 @@ export class CalcApp extends GWebviewApp { } } - private clearFields(e: MouseEvent): void { + private _clearFields(e: MouseEvent): void { const target = e.target as HTMLButtonElement; if (target) { @@ -201,7 +203,7 @@ export class CalcApp extends GWebviewApp { } } - private displayResults(result: number | undefined, target: TCalcDom): void { + private _displayResults(result: number | undefined, target: TCalcDom): void { if (result && result !== Number.POSITIVE_INFINITY) { // Precision is 2 decimals or 5 for Chip Load const precision = target === this._calcDom.chipLoad ? 5 : 2; @@ -219,7 +221,7 @@ export class CalcApp extends GWebviewApp { } } - private calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { + private _calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { if (units === Units.Inch || units === Units.Default) { return (sfm * 12) / (Math.PI * toolDia); } else { @@ -227,7 +229,7 @@ export class CalcApp extends GWebviewApp { } } - private calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { + private _calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { if (units === Units.Inch || units === Units.Default) { // Calculate SFM for Imperial return (Math.PI * toolDia * rpm) / 12; @@ -237,11 +239,11 @@ export class CalcApp extends GWebviewApp { } } - private calcFeedRate(rpm: number, numFlutes: number, feedPerTooth: number): number | undefined { + private _calcFeedRate(rpm: number, numFlutes: number, feedPerTooth: number): number | undefined { return rpm * feedPerTooth * numFlutes; } - private calcChipLoad(feedRate: number, rpm: number, numFlutes: number): number | undefined { + private _calcChipLoad(feedRate: number, rpm: number, numFlutes: number): number | undefined { return feedRate / rpm / numFlutes; } } diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index 8728786..ffba622 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -4,6 +4,8 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; +import { MachineTypes } from '@appliedengdesign/gcode-reference/dist/types'; + export interface ICalcDom { rpm?: { btn: HTMLElement; @@ -38,6 +40,11 @@ export interface ICalcDom { export type TCalcDom = ICalcDom[keyof ICalcDom]; +export interface calcBootstrap { + machineType: MachineTypes; + units: Units; +} + export enum Units { Inch = 'Inch', MM = 'Metric', diff --git a/src/webviews/apps/shared/gWebviewApp.ts b/src/webviews/apps/shared/gWebviewApp.ts index 0eac859..3a557c5 100644 --- a/src/webviews/apps/shared/gWebviewApp.ts +++ b/src/webviews/apps/shared/gWebviewApp.ts @@ -4,6 +4,10 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; +import { WebviewMsg } from '../../webviewMsg.types'; + +declare let __BOOTSTRAP__: WebviewMsg; + interface VsCodeApi { postMessage(msg: any): void; setState(state: any): void; @@ -14,13 +18,19 @@ declare function acquireVsCodeApi(): VsCodeApi; export abstract class GWebviewApp { private readonly _api: VsCodeApi; + protected bootstrap: WebviewMsg | undefined; constructor(protected readonly appName: string) { + // Get Bootstrap if any + if (typeof __BOOTSTRAP__ !== 'undefined') { + this.bootstrap = __BOOTSTRAP__; + } + this._api = acquireVsCodeApi(); - this.registerEvents(); + this._registerEvents(); } - private registerEvents(): void { + private _registerEvents(): void { window.addEventListener('message', this.onMsgReceived.bind(this)); } @@ -28,5 +38,13 @@ export abstract class GWebviewApp { this._api.postMessage(msg); } + protected getState(): any { + return this._api.getState(); + } + + protected setState(state: any): void { + this._api.setState(state); + } + protected abstract onMsgReceived(e: MessageEvent): void; } From 91dfdfb070ab018a63fc96a6d7d90ec89d2a206f Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:45:29 -0400 Subject: [PATCH 64/79] Renamed UnitsController and moved to Utils --- src/control.ts | 6 +++--- src/{gcodeUnits.ts => util/unitsController.ts} | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) rename src/{gcodeUnits.ts => util/unitsController.ts} (93%) diff --git a/src/control.ts b/src/control.ts index d19dc8b..ea8d125 100644 --- a/src/control.ts +++ b/src/control.ts @@ -10,7 +10,7 @@ import { Config, configuration } from './util/configuration/config'; import { Logger } from './util/logger'; import { StatusBarControl } from './util/statusBar'; import { NavTreeView } from './views/navTreeView'; -import { GCodeUnitsController } from './gcodeUnits'; +import { UnitsController } from './util/unitsController'; import { StatsView } from './views/statsView'; import { constants, Contexts, GCommands, PIcon, VSBuiltInCommands } from './util/constants'; import { Version } from './util/version'; @@ -34,7 +34,7 @@ export class Control { // Controllers private static _machineTypeController: MachineTypeController; private static _statusBarControl: StatusBarControl; - private static _unitsController: GCodeUnitsController; + private static _unitsController: UnitsController; private static _stateController: StateControl; private static _hoverController: GCodeHoverControl; @@ -104,7 +104,7 @@ export class Control { context.subscriptions.push((this._hoverController = new GCodeHoverControl())); // Load Units Controller - context.subscriptions.push((this._unitsController = new GCodeUnitsController())); + context.subscriptions.push((this._unitsController = new UnitsController())); // Load Nav Tree Logger.log('Loading Nav Tree...'); diff --git a/src/gcodeUnits.ts b/src/util/unitsController.ts similarity index 93% rename from src/gcodeUnits.ts rename to src/util/unitsController.ts index f4aa569..dc49369 100644 --- a/src/gcodeUnits.ts +++ b/src/util/unitsController.ts @@ -14,18 +14,18 @@ import { window, workspace, } from 'vscode'; -import { Control } from './control'; -import { configuration } from './util/configuration/config'; -import { defaults } from './util/configuration/defaults'; -import { GCodeUnits, GCommands } from './util/constants'; -import { Logger } from './util/logger'; -import { StatusBar, StatusBarControl } from './util/statusBar'; +import { Control } from '../control'; +import { configuration } from './configuration/config'; +import { defaults } from './configuration/defaults'; +import { GCodeUnits, GCommands } from './constants'; +import { Logger } from './logger'; +import { StatusBar, StatusBarControl } from './statusBar'; type Units = GCodeUnits.Inch | GCodeUnits.MM | GCodeUnits.Default; export const cfgUnits = 'general.units'; -export class GCodeUnitsController implements Disposable { +export class UnitsController implements Disposable { private readonly _disposables: Disposable[] = []; private readonly unitsStatusBar: StatusBar = 'unitsBar'; private _editor: TextEditor | undefined; From fc126cd02982d2bd3c8e3aaa93d1aee751f25173 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:46:12 -0400 Subject: [PATCH 65/79] Typo for MachineType type --- src/util/machineTypeController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/machineTypeController.ts b/src/util/machineTypeController.ts index b059ff3..413cd15 100644 --- a/src/util/machineTypeController.ts +++ b/src/util/machineTypeController.ts @@ -15,7 +15,7 @@ import { defaults } from './configuration/defaults'; export class MachineTypeController implements Disposable { private readonly _dispoables: Disposable[] = []; - private _machineType: MachineTypes | undefined; + private _machineType: MachineType | undefined; private _statusbar: StatusBarControl; private readonly mtypeStatusBar: StatusBar = 'machineTypeBar'; private _gReference: GReference; From 9a8c131602cf4b36a0dbcf26036e5e6e85d1a5e3 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 15:51:02 -0400 Subject: [PATCH 66/79] Hardcoded MachineTypes to avoid loading additional module --- src/webviews/apps/calc/calc.ts | 5 ++--- src/webviews/apps/calc/calc.types.ts | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 0cde259..dfafaeb 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -6,13 +6,12 @@ import { GWebviewApp } from '../shared/gWebviewApp'; import { WebviewMsg } from '../../webviewMsg.types'; -import { calcBootstrap, ICalcDom, TCalcDom, Units } from './calc.types'; -import { MachineTypes } from '@appliedengdesign/gcode-reference/dist/types'; +import { calcBootstrap, ICalcDom, MachineType, MachineTypes, TCalcDom, Units } from './calc.types'; export class CalcApp extends GWebviewApp { private _calcDom: ICalcDom = {}; private _clearBtns: NodeListOf | undefined; - private _machineType: MachineTypes = MachineTypes.Mill; + private _machineType: MachineType = MachineTypes.Mill; private _units: Units = Units.Default; constructor() { diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index ffba622..d2ddc87 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -4,8 +4,6 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; -import { MachineTypes } from '@appliedengdesign/gcode-reference/dist/types'; - export interface ICalcDom { rpm?: { btn: HTMLElement; @@ -40,13 +38,24 @@ export interface ICalcDom { export type TCalcDom = ICalcDom[keyof ICalcDom]; -export interface calcBootstrap { - machineType: MachineTypes; - units: Units; +export enum MachineTypes { + EDM = 'edm', + Mill = 'mill', + Lathe = 'lathe', + Laser = 'laser', + Printer = 'printer', + Swiss = 'swiss', } +export type MachineType = MachineTypes; + export enum Units { Inch = 'Inch', MM = 'Metric', Default = 'Default (Inch)', } + +export interface calcBootstrap { + machineType: MachineTypes; + units: Units; +} From 267ab0ecdbb15b2e03fab2c3e19adc8d4c7ec6f9 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 16:30:20 -0400 Subject: [PATCH 67/79] Added MRR calculator --- src/webviews/apps/calc/calc.html | 13 +++++++++- src/webviews/apps/calc/calc.scss | 4 +++ src/webviews/apps/calc/calc.ts | 38 +++++++++++++++++++++++++--- src/webviews/apps/calc/calc.types.ts | 10 +++++++- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 4d90a2c..0b2107c 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -7,6 +7,7 @@ SPEEDS FEEDS + MRR
@@ -66,8 +67,18 @@

Chip Load

+ +
+
+ Ap - Axial Depth of Cut + Ae - Radial Depth of Cut + Feedrate + + Calculate +
+
+
- {bootstrap} diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index f4e859b..b8c27a2 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -68,6 +68,10 @@ span.results { padding: 5px; } +#mrr-results { + width: 130px; +} + section.calculator > vscode-button { margin-top: 1rem; } diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index dfafaeb..a2db828 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -61,15 +61,25 @@ export class CalcApp extends GWebviewApp { results: document.getElementById('fr-results') as HTMLSpanElement, }; + // Populate Chipload Calculator this._calcDom.chipLoad = { btn: document.getElementById('cl-calc-btn') as HTMLElement, - ipm: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + feedRate: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement, rpm: document.getElementById('cl-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, numFlutes: document .getElementById('cl-num-flutes') ?.shadowRoot?.getElementById('control') as HTMLInputElement, results: document.getElementById('cl-results') as HTMLSpanElement, }; + + // Populate MRR Calculator + this._calcDom.mrr = { + btn: document.getElementById('mrr-calc-btn') as HTMLElement, + axialDepth: document.getElementById('mrr-ap')?.shadowRoot?.getElementById('control') as HTMLInputElement, + radialDepth: document.getElementById('mrr-ae')?.shadowRoot?.getElementById('control') as HTMLInputElement, + feedRate: document.getElementById('mrr-fr')?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('mrr-results') as HTMLSpanElement, + }; } protected onMsgReceived(e: MessageEvent): void { @@ -165,20 +175,36 @@ export class CalcApp extends GWebviewApp { case 'cl-calc-btn': { if (this._calcDom.chipLoad) { - const ipm = Math.abs(Number(this._calcDom.chipLoad.ipm.value)); + const feedRate = Math.abs(Number(this._calcDom.chipLoad.feedRate.value)); const rpm = Math.abs(Number(this._calcDom.chipLoad.rpm.value)); const numFlutes = Math.abs(Number(this._calcDom.chipLoad.numFlutes.value)); - this._calcDom.chipLoad.ipm.value = ipm ? ipm.toString() : ''; + this._calcDom.chipLoad.feedRate.value = feedRate ? feedRate.toString() : ''; this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : ''; this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : ''; - result = this._calcChipLoad(ipm, rpm, numFlutes); + result = this._calcChipLoad(feedRate, rpm, numFlutes); this._displayResults(result, this._calcDom.chipLoad); } break; } + + case 'mrr-calc-btn': { + if (this._calcDom.mrr) { + const axialDepth = Math.abs(Number(this._calcDom.mrr.axialDepth.value)); + const radialDepth = Math.abs(Number(this._calcDom.mrr.radialDepth.value)); + const feedRate = Math.abs(Number(this._calcDom.mrr.feedRate.value)); + + this._calcDom.mrr.axialDepth.value = axialDepth ? axialDepth.toString() : ''; + this._calcDom.mrr.radialDepth.value = radialDepth ? radialDepth.toString() : ''; + this._calcDom.mrr.feedRate.value = feedRate ? feedRate.toString() : ''; + + result = this._calcMRR(axialDepth, radialDepth, feedRate); + + this._displayResults(result, this._calcDom.mrr); + } + } } } } @@ -245,6 +271,10 @@ export class CalcApp extends GWebviewApp { private _calcChipLoad(feedRate: number, rpm: number, numFlutes: number): number | undefined { return feedRate / rpm / numFlutes; } + + private _calcMRR(axialDepth: number, radialDepth: number, feedRate: number): number | undefined { + return feedRate * radialDepth * axialDepth; + } } new CalcApp(); diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index d2ddc87..f43ae86 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -29,11 +29,19 @@ export interface ICalcDom { chipLoad?: { btn: HTMLElement; - ipm: HTMLInputElement; + feedRate: HTMLInputElement; rpm: HTMLInputElement; numFlutes: HTMLInputElement; results: HTMLSpanElement; }; + + mrr?: { + btn: HTMLElement; + axialDepth: HTMLInputElement; + radialDepth: HTMLInputElement; + feedRate: HTMLInputElement; + results: HTMLSpanElement; + }; } export type TCalcDom = ICalcDom[keyof ICalcDom]; From 2a0ef462406fcf14cc0cc2e5e8ca249552af0f1c Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 17:14:11 -0400 Subject: [PATCH 68/79] Modified variable & field labels to be unit independent --- src/webviews/apps/calc/calc.html | 26 ++++--- src/webviews/apps/calc/calc.ts | 106 ++++++++++++++++++++------- src/webviews/apps/calc/calc.types.ts | 4 +- 3 files changed, 99 insertions(+), 37 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 0b2107c..092292e 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -14,18 +14,18 @@

RPM

- SFM + Cutting Speed Tool Diameter Calculate
-
-

SFM

+
+

Cutting Speed

- RPM - Tool Diameter - - Calculate + RPM + Tool Diameter + + Calculate
@@ -44,14 +44,14 @@

Feedrate

RPM # of Flutes - Load / Tooth + Feed / Tooth Calculate

Chip Load

- IPM + Feedrate RPM # of Flutes @@ -77,6 +77,14 @@

Chip Load

Calculate
+
+ + Clear Fields + +
+
+ Units: +
diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index a2db828..0a34dcf 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -35,17 +35,19 @@ export class CalcApp extends GWebviewApp { // Populate RPM Calculator this._calcDom.rpm = { btn: document.getElementById('rpm-calc-btn') as HTMLElement, - sfm: document.getElementById('rpm-sfm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + speed: document.getElementById('rpm-speed')?.shadowRoot?.getElementById('control') as HTMLInputElement, toolDia: document.getElementById('rpm-tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, results: document.getElementById('rpm-results') as HTMLSpanElement, }; // Populate SFM Calculator - this._calcDom.sfm = { - btn: document.getElementById('sfm-calc-btn') as HTMLElement, - rpm: document.getElementById('sfm-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, - toolDia: document.getElementById('sfm-tool-dia')?.shadowRoot?.getElementById('control') as HTMLInputElement, - results: document.getElementById('sfm-results') as HTMLSpanElement, + this._calcDom.speed = { + btn: document.getElementById('speed-calc-btn') as HTMLElement, + rpm: document.getElementById('speed-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + toolDia: document + .getElementById('speed-tool-dia') + ?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('speed-results') as HTMLSpanElement, }; // Populate Feedrate Calculator @@ -64,7 +66,7 @@ export class CalcApp extends GWebviewApp { // Populate Chipload Calculator this._calcDom.chipLoad = { btn: document.getElementById('cl-calc-btn') as HTMLElement, - feedRate: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement, + feedRate: document.getElementById('cl-feedrate')?.shadowRoot?.getElementById('control') as HTMLInputElement, rpm: document.getElementById('cl-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement, numFlutes: document .getElementById('cl-num-flutes') @@ -128,30 +130,30 @@ export class CalcApp extends GWebviewApp { switch (target.id) { case 'rpm-calc-btn': { if (this._calcDom.rpm) { - const sfm = Math.abs(Number(this._calcDom.rpm.sfm.value)); + const sfm = Math.abs(Number(this._calcDom.rpm.speed.value)); const toolDia = Math.abs(Number(this._calcDom.rpm.toolDia.value)); - this._calcDom.rpm.sfm.value = sfm ? sfm.toString() : ''; + this._calcDom.rpm.speed.value = sfm ? sfm.toString() : ''; this._calcDom.rpm.toolDia.value = toolDia ? sfm.toString() : ''; - result = this._calcRPM(sfm, toolDia, this._units); + result = this._calcRPM(sfm, toolDia); this._displayResults(result, this._calcDom.rpm); } break; } - case 'sfm-calc-btn': { - if (this._calcDom.sfm) { - const rpm = Math.abs(Number(this._calcDom.sfm.rpm.value)); - const toolDia = Math.abs(Number(this._calcDom.sfm.toolDia.value)); + case 'speed-calc-btn': { + if (this._calcDom.speed) { + const rpm = Math.abs(Number(this._calcDom.speed.rpm.value)); + const toolDia = Math.abs(Number(this._calcDom.speed.toolDia.value)); - this._calcDom.sfm.rpm.value = rpm ? rpm.toString() : ''; - this._calcDom.sfm.toolDia.value = toolDia ? toolDia.toString() : ''; + this._calcDom.speed.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.speed.toolDia.value = toolDia ? toolDia.toString() : ''; - result = this._calcSFM(rpm, toolDia, this._units); + result = this._calcSFM(rpm, toolDia); - this._displayResults(result, this._calcDom.sfm); + this._displayResults(result, this._calcDom.speed); } break; } @@ -204,6 +206,7 @@ export class CalcApp extends GWebviewApp { this._displayResults(result, this._calcDom.mrr); } + break; } } } @@ -230,12 +233,63 @@ export class CalcApp extends GWebviewApp { private _displayResults(result: number | undefined, target: TCalcDom): void { if (result && result !== Number.POSITIVE_INFINITY) { - // Precision is 2 decimals or 5 for Chip Load - const precision = target === this._calcDom.chipLoad ? 5 : 2; - if (target) { target.results.classList.remove('error'); - target.results.innerHTML = result.toFixed(precision); + + // Precision is 2 decimals or 4 for Chip Load + const precision = target === this._calcDom.chipLoad ? 4 : 2; + let units = ''; + + // Assign units + switch (target) { + case this._calcDom.rpm: + { + units = '[RPM]'; + } + break; + + case this._calcDom.speed: + { + if (this._units === Units.Inch || this._units === Units.Default) { + units = '[SFM]'; + } else { + units = '[m/min]'; + } + } + break; + + case this._calcDom.feedrate: + { + if (this._units === Units.Inch || this._units === Units.Default) { + units = '[in/min]'; + } else { + units = '[mm/min]'; + } + } + break; + + case this._calcDom.chipLoad: + { + if (this._units === Units.Inch || this._units === Units.Default) { + units = '[in]'; + } else { + units = '[mm]'; + } + } + break; + + case this._calcDom.mrr: + { + if (this._units === Units.Inch || this._units === Units.Default) { + units = '[in3/min]'; + } else { + result /= 100; + units = '[cm3/min]'; + } + } + break; + } + target.results.innerHTML = `${result.toFixed(precision)} ${units}`; } } else { // Answer is NaN or Infinity @@ -246,16 +300,16 @@ export class CalcApp extends GWebviewApp { } } - private _calcRPM(sfm: number, toolDia: number, units: Units): number | undefined { - if (units === Units.Inch || units === Units.Default) { + private _calcRPM(sfm: number, toolDia: number): number | undefined { + if (this._units === Units.Inch || this._units === Units.Default) { return (sfm * 12) / (Math.PI * toolDia); } else { return (sfm * 1000) / (Math.PI * toolDia); } } - private _calcSFM(rpm: number, toolDia: number, units: Units): number | undefined { - if (units === Units.Inch || units === Units.Default) { + private _calcSFM(rpm: number, toolDia: number): number | undefined { + if (this._units === Units.Inch || this._units === Units.Default) { // Calculate SFM for Imperial return (Math.PI * toolDia * rpm) / 12; } else { diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index f43ae86..c03efcb 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -7,12 +7,12 @@ export interface ICalcDom { rpm?: { btn: HTMLElement; - sfm: HTMLInputElement; + speed: HTMLInputElement; toolDia: HTMLInputElement; results: HTMLSpanElement; }; - sfm?: { + speed?: { btn: HTMLElement; rpm: HTMLInputElement; toolDia: HTMLInputElement; From fd6923279d77eb14ccc65acd49695f7416f3ce90 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 17:18:28 -0400 Subject: [PATCH 69/79] Removed handleMessage --- src/webviews/calc/calcWebviewView.ts | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 9c4d1e4..0ebae2b 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -69,28 +69,6 @@ export class CalcWebviewView extends GWebviewView { ]; } - protected override async handleMessage(msg: WebviewMsg): Promise { - const type = msg.type; - - switch (type) { - case 'getUnits': - await this.postMessage({ type: 'changeUnits', payload: Control.unitsController.units }); - - break; - - case 'getMachineType': - await this.postMessage({ - type: 'changeMachineType', - payload: Control.machineTypeController.machineType, - }); - - break; - - default: - return; - } - } - protected override bootstrap(): WebviewMsg { return { type: 'bootstrap', From 99ca27d86c6251201f6bee064d63374521935e61 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 19:13:34 -0400 Subject: [PATCH 70/79] Use MachineType from gcode-reference --- src/util/configuration/defaults.ts | 5 +++-- src/util/machineTypeController.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/configuration/defaults.ts b/src/util/configuration/defaults.ts index 268bda6..7b326a4 100644 --- a/src/util/configuration/defaults.ts +++ b/src/util/configuration/defaults.ts @@ -8,6 +8,7 @@ import { StatusBarAlignment } from 'vscode'; import { GCodeUnits } from '../constants'; import { LineNumbererOptions, LineNumberFrequency } from '../lineNumberer'; +import { MachineType, MachineTypes } from '@appliedengdesign/gcode-reference'; export enum TraceLevel { Silent = 'silent', @@ -19,7 +20,7 @@ export enum TraceLevel { export interface GCodeConfiguration { general: { - machineType: 'Mill' | 'Lathe' | '3D Printer'; + machineType: MachineType; hovers: { enabled: boolean; @@ -58,7 +59,7 @@ export interface GCodeConfiguration { export const defaults: GCodeConfiguration = { general: { - machineType: 'Mill', + machineType: MachineTypes.Mill, hovers: { enabled: true, }, diff --git a/src/util/machineTypeController.ts b/src/util/machineTypeController.ts index 413cd15..92c0c41 100644 --- a/src/util/machineTypeController.ts +++ b/src/util/machineTypeController.ts @@ -15,7 +15,7 @@ import { defaults } from './configuration/defaults'; export class MachineTypeController implements Disposable { private readonly _dispoables: Disposable[] = []; - private _machineType: MachineType | undefined; + private _machineType: MachineType = defaults.general.machineType; private _statusbar: StatusBarControl; private readonly mtypeStatusBar: StatusBar = 'machineTypeBar'; private _gReference: GReference; From 9753649f4dc938f26e27be628db03791a267a086 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 23:42:39 -0400 Subject: [PATCH 71/79] Added MRR title --- src/webviews/apps/calc/calc.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 092292e..0fce779 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -69,7 +69,9 @@

Chip Load

-
+
+

Metal Removal Rate

+ Ap - Axial Depth of Cut Ae - Radial Depth of Cut Feedrate From f3d9c7dc6a253546aa372f9a8a32a232427d3402 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Tue, 27 Sep 2022 23:43:33 -0400 Subject: [PATCH 72/79] Fixed event not firing on machineType change --- src/util/machineTypeController.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/machineTypeController.ts b/src/util/machineTypeController.ts index 92c0c41..892244e 100644 --- a/src/util/machineTypeController.ts +++ b/src/util/machineTypeController.ts @@ -88,6 +88,9 @@ export class MachineTypeController implements Disposable { // Update GReference this._gReference.setType(this._machineType); + + // Fire Event + this._onDidChangeMachineType.fire(this._machineType); } get gReference() { From 11916d776f18006a4c5d0b3645bd1eac8eaf0c54 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 28 Sep 2022 13:10:56 -0400 Subject: [PATCH 73/79] Fixed typo in MRR feedrate input --- src/webviews/apps/calc/calc.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 0fce779..b3e164d 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -74,7 +74,7 @@

Metal Removal Rate

Ap - Axial Depth of Cut Ae - Radial Depth of Cut - Feedrate + Feedrate Calculate
From 6b67c89fd115a715a63aa77b0f5c1560c7740deb Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 28 Sep 2022 16:05:20 -0400 Subject: [PATCH 74/79] Added MachineType response & Surface Finish calc --- src/webviews/apps/calc/calc.html | 19 +- src/webviews/apps/calc/calc.scss | 16 +- src/webviews/apps/calc/calc.ts | 372 ++++++++++++++++++++------- src/webviews/apps/calc/calc.types.ts | 7 + src/webviews/calc/calcWebviewView.ts | 45 +++- 5 files changed, 353 insertions(+), 106 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index b3e164d..4db58e4 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -70,14 +70,23 @@

Chip Load

-

Metal Removal Rate

+

Metal Removal

- Ap - Axial Depth of Cut - Ae - Radial Depth of Cut - Feedrate - + Ap - Axial Depth of Cut + Ae - Radial Depth of Cut + Feedrate + Calculate
+
+

Surface Finish

+ + Corner Radius + Feedrate + + + Calculate +
diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index b8c27a2..c99c405 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -12,14 +12,14 @@ section { display: flex; flex-direction: column; - justify-content: center; - + justify-content: start; padding: 1em; } section.row { flex-direction: row; flex: none; + justify-content: center; padding: 0; } @@ -68,14 +68,18 @@ span.results { padding: 5px; } -#mrr-results { - width: 130px; -} - section.calculator > vscode-button { margin-top: 1rem; } .error { color: var(--vscode-errorForeground); +} + +.hidden { + visibility: hidden; +} + +#finish .label { + padding-bottom: 3.5px; } \ No newline at end of file diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 0a34dcf..912f4de 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -28,6 +28,7 @@ export class CalcApp extends GWebviewApp { this._machineType = (this.bootstrap.payload as calcBootstrap).machineType; this._units = (this.bootstrap.payload as calcBootstrap).units; this._updateUnits(); + this._updateMachineType(); } } @@ -82,6 +83,16 @@ export class CalcApp extends GWebviewApp { feedRate: document.getElementById('mrr-fr')?.shadowRoot?.getElementById('control') as HTMLInputElement, results: document.getElementById('mrr-results') as HTMLSpanElement, }; + + // Populate Finish Calculator + this._calcDom.finish = { + btn: document.getElementById('finish-btn') as HTMLElement, + radius: document.getElementById('finish-radius')?.shadowRoot?.getElementById('control') as HTMLInputElement, + feedRate: document + .getElementById('finish-feedrate') + ?.shadowRoot?.getElementById('control') as HTMLInputElement, + results: document.getElementById('finish-results') as HTMLSpanElement, + }; } protected onMsgReceived(e: MessageEvent): void { @@ -89,12 +100,20 @@ export class CalcApp extends GWebviewApp { switch (message.type) { case 'changeUnits': - this._units = message.payload as Units; - this._updateUnits(); - this._clearBtns?.forEach(btn => { - btn.click(); - }); + { + this._units = message.payload as Units; + this._updateUnits(); + this._clearBtns?.forEach(btn => { + btn.click(); + }); + } + break; + case 'changeMachineType': + { + this._machineType = message.payload as MachineType; + this._updateMachineType(); + } break; default: @@ -108,6 +127,121 @@ export class CalcApp extends GWebviewApp { }); } + private _updateMachineType(): void { + // Clear Fields + this._clearFields(); + + switch (this._machineType) { + case MachineTypes.Mill: + { + // Hide Surface Finish Calculator + const finishSection = document.getElementById('finish')?.parentElement as HTMLElement; + if (finishSection) { + finishSection.style.display = 'none'; + } + + const mrrTab = document.getElementById('tab-3') as HTMLElement; + if (mrrTab) { + mrrTab.innerHTML = 'MRR'; + } + + // Show Feeds Tab + const tab = document.getElementById('tab-2') as HTMLElement; + const tabView = document.getElementById('view-2') as HTMLElement; + if (tab && tabView) { + tab.style.display = ''; + tabView.style.display = ''; + } + + // Update Diameter -> Tool Dia + const rpmDiaField = document.getElementById('rpm-tool-dia') as HTMLElement; + if (rpmDiaField) { + rpmDiaField.setAttribute('placeholder', 'Enter Tool Dia'); + rpmDiaField.innerHTML = 'Diameter'; + } + + const speedDiaField = document.getElementById('speed-tool-dia') as HTMLElement; + if (speedDiaField) { + speedDiaField.setAttribute('placeholder', 'Enter Tool Dia'); + speedDiaField.innerHTML = 'Diameter'; + } + + // Update MRR Calculator + const mrrDepth = document.getElementById('mrr-ap') as HTMLElement; + if (mrrDepth) { + mrrDepth.setAttribute('placeholder', 'Axial Depth of Cut'); + mrrDepth.innerHTML = 'Ap - Axial Depth of Cut'; + } + + const mrrSpeed = document.getElementById('mrr-ae') as HTMLElement; + if (mrrSpeed) { + mrrSpeed.setAttribute('placeholder', 'Radial Depth of Cut'); + mrrSpeed.innerHTML = 'Ae - Radial Depth of Cut'; + } + } + break; + + case MachineTypes.Lathe: + case MachineTypes.Swiss: + { + // Focus Speeds Tab + const speedsTab = document.getElementById('tab-1') as HTMLElement; + if (speedsTab) { + speedsTab.click(); + } + + // Hide Feeds Tab + const tab = document.getElementById('tab-2') as HTMLElement; + const tabView = document.getElementById('view-2') as HTMLElement; + if (tab && tabView) { + tab.style.display = 'none'; + tabView.style.display = 'none'; + } + + // Update Tool Dia -> Diameter + const rpmDiaField = document.getElementById('rpm-tool-dia') as HTMLElement; + if (rpmDiaField) { + rpmDiaField.setAttribute('placeholder', 'Enter Dia'); + rpmDiaField.innerHTML = 'Diameter'; + } + + const speedDiaField = document.getElementById('speed-tool-dia') as HTMLElement; + if (speedDiaField) { + speedDiaField.setAttribute('placeholder', 'Enter Dia'); + speedDiaField.innerHTML = 'Diameter'; + } + + // Update MRR Calculator + const mrrDepth = document.getElementById('mrr-ap') as HTMLElement; + if (mrrDepth) { + mrrDepth.setAttribute('placeholder', 'Depth of Cut'); + mrrDepth.innerHTML = 'Depth of Cut'; + } + + const mrrSpeed = document.getElementById('mrr-ae') as HTMLElement; + if (mrrSpeed) { + mrrSpeed.setAttribute('placeholder', 'Enter Cutting Speed'); + mrrSpeed.innerHTML = 'Cutting Speed'; + } + + // Show Surface Finish Calculator + const finishSection = document.getElementById('finish')?.parentElement as HTMLElement; + if (finishSection) { + finishSection.style.display = ''; + } + + const mrrTab = document.getElementById('tab-3') as HTMLElement; + if (mrrTab) { + mrrTab.innerHTML = 'MRR / SF'; + } + } + break; + + default: + return; + } + } + private _registerBtns(): void { Object.keys(this._calcDom).forEach(key => { this._calcDom[key as keyof ICalcDom]?.btn.addEventListener('click', this._processEvent.bind(this), false); @@ -128,104 +262,137 @@ export class CalcApp extends GWebviewApp { if (target) { switch (target.id) { - case 'rpm-calc-btn': { - if (this._calcDom.rpm) { - const sfm = Math.abs(Number(this._calcDom.rpm.speed.value)); - const toolDia = Math.abs(Number(this._calcDom.rpm.toolDia.value)); + case 'rpm-calc-btn': + { + if (this._calcDom.rpm) { + const sfm = Math.abs(Number(this._calcDom.rpm.speed.value)); + const toolDia = Math.abs(Number(this._calcDom.rpm.toolDia.value)); - this._calcDom.rpm.speed.value = sfm ? sfm.toString() : ''; - this._calcDom.rpm.toolDia.value = toolDia ? sfm.toString() : ''; + this._calcDom.rpm.speed.value = sfm ? sfm.toString() : ''; + this._calcDom.rpm.toolDia.value = toolDia ? sfm.toString() : ''; - result = this._calcRPM(sfm, toolDia); + result = this._calcRPM(sfm, toolDia); - this._displayResults(result, this._calcDom.rpm); + this._displayResults(result, this._calcDom.rpm); + } } break; - } - case 'speed-calc-btn': { - if (this._calcDom.speed) { - const rpm = Math.abs(Number(this._calcDom.speed.rpm.value)); - const toolDia = Math.abs(Number(this._calcDom.speed.toolDia.value)); + case 'speed-calc-btn': + { + if (this._calcDom.speed) { + const rpm = Math.abs(Number(this._calcDom.speed.rpm.value)); + const toolDia = Math.abs(Number(this._calcDom.speed.toolDia.value)); - this._calcDom.speed.rpm.value = rpm ? rpm.toString() : ''; - this._calcDom.speed.toolDia.value = toolDia ? toolDia.toString() : ''; + this._calcDom.speed.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.speed.toolDia.value = toolDia ? toolDia.toString() : ''; - result = this._calcSFM(rpm, toolDia); + result = this._calcSFM(rpm, toolDia); - this._displayResults(result, this._calcDom.speed); + this._displayResults(result, this._calcDom.speed); + } } break; - } - case 'fr-calc-btn': { - if (this._calcDom.feedrate) { - const rpm = Math.abs(Number(this._calcDom.feedrate.rpm.value)); - const numFlutes = Math.abs(Number(this._calcDom.feedrate.numFlutes.value)); - const chipLoad = Math.abs(Number(this._calcDom.feedrate.chipLoad.value)); + case 'fr-calc-btn': + { + if (this._calcDom.feedrate) { + const rpm = Math.abs(Number(this._calcDom.feedrate.rpm.value)); + const numFlutes = Math.abs(Number(this._calcDom.feedrate.numFlutes.value)); + const chipLoad = Math.abs(Number(this._calcDom.feedrate.chipLoad.value)); - this._calcDom.feedrate.rpm.value = rpm ? rpm.toString() : ''; - this._calcDom.feedrate.numFlutes.value = numFlutes ? numFlutes.toString() : ''; - this._calcDom.feedrate.chipLoad.value = chipLoad ? chipLoad.toString() : ''; + this._calcDom.feedrate.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.feedrate.numFlutes.value = numFlutes ? numFlutes.toString() : ''; + this._calcDom.feedrate.chipLoad.value = chipLoad ? chipLoad.toString() : ''; - result = this._calcFeedRate(rpm, numFlutes, chipLoad); + result = this._calcFeedRate(rpm, numFlutes, chipLoad); - this._displayResults(result, this._calcDom.feedrate); + this._displayResults(result, this._calcDom.feedrate); + } } break; - } - case 'cl-calc-btn': { - if (this._calcDom.chipLoad) { - const feedRate = Math.abs(Number(this._calcDom.chipLoad.feedRate.value)); - const rpm = Math.abs(Number(this._calcDom.chipLoad.rpm.value)); - const numFlutes = Math.abs(Number(this._calcDom.chipLoad.numFlutes.value)); + case 'cl-calc-btn': + { + if (this._calcDom.chipLoad) { + const feedRate = Math.abs(Number(this._calcDom.chipLoad.feedRate.value)); + const rpm = Math.abs(Number(this._calcDom.chipLoad.rpm.value)); + const numFlutes = Math.abs(Number(this._calcDom.chipLoad.numFlutes.value)); - this._calcDom.chipLoad.feedRate.value = feedRate ? feedRate.toString() : ''; - this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : ''; - this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : ''; + this._calcDom.chipLoad.feedRate.value = feedRate ? feedRate.toString() : ''; + this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : ''; + this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : ''; - result = this._calcChipLoad(feedRate, rpm, numFlutes); + result = this._calcChipLoad(feedRate, rpm, numFlutes); - this._displayResults(result, this._calcDom.chipLoad); + this._displayResults(result, this._calcDom.chipLoad); + } } break; - } - case 'mrr-calc-btn': { - if (this._calcDom.mrr) { - const axialDepth = Math.abs(Number(this._calcDom.mrr.axialDepth.value)); - const radialDepth = Math.abs(Number(this._calcDom.mrr.radialDepth.value)); - const feedRate = Math.abs(Number(this._calcDom.mrr.feedRate.value)); + case 'mrr-calc-btn': + { + if (this._calcDom.mrr) { + const axialDepth = Math.abs(Number(this._calcDom.mrr.axialDepth.value)); + const radialDepth = Math.abs(Number(this._calcDom.mrr.radialDepth.value)); + const feedRate = Math.abs(Number(this._calcDom.mrr.feedRate.value)); - this._calcDom.mrr.axialDepth.value = axialDepth ? axialDepth.toString() : ''; - this._calcDom.mrr.radialDepth.value = radialDepth ? radialDepth.toString() : ''; - this._calcDom.mrr.feedRate.value = feedRate ? feedRate.toString() : ''; + this._calcDom.mrr.axialDepth.value = axialDepth ? axialDepth.toString() : ''; + this._calcDom.mrr.radialDepth.value = radialDepth ? radialDepth.toString() : ''; + this._calcDom.mrr.feedRate.value = feedRate ? feedRate.toString() : ''; - result = this._calcMRR(axialDepth, radialDepth, feedRate); + result = this._calcMRR(axialDepth, radialDepth, feedRate); - this._displayResults(result, this._calcDom.mrr); + this._displayResults(result, this._calcDom.mrr); + } + } + break; + + case 'finish-btn': + { + if (this._calcDom.finish) { + const radius = Math.abs(Number(this._calcDom.finish.radius.value)); + const feedRate = Math.abs(Number(this._calcDom.finish.feedRate.value)); + + this._calcDom.finish.radius.value = radius ? radius.toString() : ''; + this._calcDom.finish.feedRate.value = feedRate ? feedRate.toString() : ''; + + result = this._calcSurfaceFinish(radius, feedRate); + + this._displayResults(result, this._calcDom.finish); + } } break; - } } } } - private _clearFields(e: MouseEvent): void { - const target = e.target as HTMLButtonElement; + private _clearFields(e?: MouseEvent): void { + if (e) { + const target = e.target as HTMLButtonElement; - if (target) { - const targetView = target.id.split('-')[1]; + if (target) { + const targetView = target.id.split('-')[1]; - // Clear Input Fields - document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { + // Clear Input Fields + document.querySelectorAll(`#view-${targetView} vscode-text-field`).forEach(input => { + const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; + element.value = ''; + }); + + // Clear Results Field + document.querySelectorAll(`#view-${targetView} span.results`).forEach(span => { + span.innerHTML = ''; + }); + } + } else { + // Clear All Fields + document.querySelectorAll('vscode-text-field').forEach(input => { const element = input.shadowRoot?.getElementById('control') as HTMLInputElement; element.value = ''; }); - // Clear Results Field - document.querySelectorAll(`#view-${targetView} span.results`).forEach(span => { + document.querySelectorAll('span.results').forEach(span => { span.innerHTML = ''; }); } @@ -236,8 +403,8 @@ export class CalcApp extends GWebviewApp { if (target) { target.results.classList.remove('error'); - // Precision is 2 decimals or 4 for Chip Load - const precision = target === this._calcDom.chipLoad ? 4 : 2; + // Set Precision to 2 for > 1 or 4 or < 1 + const precision = target !== this._calcDom.mrr && result < 1 ? 4 : 2; let units = ''; // Assign units @@ -250,41 +417,50 @@ export class CalcApp extends GWebviewApp { case this._calcDom.speed: { - if (this._units === Units.Inch || this._units === Units.Default) { - units = '[SFM]'; - } else { + if (this._units === Units.MM) { units = '[m/min]'; + } else { + units = '[SFM]'; } } break; case this._calcDom.feedrate: { - if (this._units === Units.Inch || this._units === Units.Default) { - units = '[in/min]'; - } else { + if (this._units === Units.MM) { units = '[mm/min]'; + } else { + units = '[in/min]'; } } break; case this._calcDom.chipLoad: { - if (this._units === Units.Inch || this._units === Units.Default) { - units = '[in]'; - } else { + if (this._units === Units.MM) { units = '[mm]'; + } else { + units = '[in]'; } } break; case this._calcDom.mrr: { - if (this._units === Units.Inch || this._units === Units.Default) { - units = '[in3/min]'; - } else { - result /= 100; + if (this._units === Units.MM) { units = '[cm3/min]'; + } else { + units = '[mm3/min]'; + } + } + break; + + case this._calcDom.finish: + { + if (this._units === Units.MM) { + units = '[μ]'; + } else { + units = '[μ in]'; } } break; @@ -301,20 +477,20 @@ export class CalcApp extends GWebviewApp { } private _calcRPM(sfm: number, toolDia: number): number | undefined { - if (this._units === Units.Inch || this._units === Units.Default) { - return (sfm * 12) / (Math.PI * toolDia); + const rpm = sfm / (Math.PI * toolDia); + if (this._units === Units.MM) { + return rpm * 1000; } else { - return (sfm * 1000) / (Math.PI * toolDia); + return rpm * 12; } } private _calcSFM(rpm: number, toolDia: number): number | undefined { - if (this._units === Units.Inch || this._units === Units.Default) { - // Calculate SFM for Imperial - return (Math.PI * toolDia * rpm) / 12; + const sfm = Math.PI * toolDia * rpm; + if (this._units === Units.MM) { + return sfm / 1000; } else { - // Calculate SFM for Metric - return (Math.PI * toolDia * rpm) / 1000; + return sfm / 12; } } @@ -327,7 +503,27 @@ export class CalcApp extends GWebviewApp { } private _calcMRR(axialDepth: number, radialDepth: number, feedRate: number): number | undefined { - return feedRate * radialDepth * axialDepth; + const mrr = feedRate * radialDepth * axialDepth; + + if (this._machineType === MachineTypes.Lathe || this._machineType === MachineTypes.Swiss) { + if (this._units === Units.MM) { + return mrr; + } else { + return mrr * 12; + } + } else { + return mrr; + } + } + + private _calcSurfaceFinish(radius: number, feedRate: number): number | undefined { + const finish = Math.pow(feedRate, 2) / radius; + + if (this._units === Units.MM) { + return finish * 46; + } else { + return finish * 31675; + } } } diff --git a/src/webviews/apps/calc/calc.types.ts b/src/webviews/apps/calc/calc.types.ts index c03efcb..39e19f9 100644 --- a/src/webviews/apps/calc/calc.types.ts +++ b/src/webviews/apps/calc/calc.types.ts @@ -42,6 +42,13 @@ export interface ICalcDom { feedRate: HTMLInputElement; results: HTMLSpanElement; }; + + finish?: { + btn: HTMLElement; + radius: HTMLInputElement; + feedRate: HTMLInputElement; + results: HTMLSpanElement; + }; } export type TCalcDom = ICalcDom[keyof ICalcDom]; diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 0ebae2b..6f57dc0 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -4,6 +4,7 @@ * -------------------------------------------------------------------------------------------- */ 'use strict'; +import { MachineType, MachineTypes } from '@appliedengdesign/gcode-reference'; import { TextDecoder } from 'util'; import { commands, ConfigurationChangeEvent, Disposable, Uri, Webview, workspace } from 'vscode'; import { Control } from '../../control'; @@ -17,21 +18,36 @@ import { WebviewMsg } from '../webviewMsg.types'; export class CalcWebviewView extends GWebviewView { private _shortId: string; + private _machineType: MachineType; constructor() { - super(Webviews.CalcWebviewView, WebviewTitles.CalcWebviewView); + const title = `${WebviewTitles.CalcWebviewView} (${ + Control.machineTypeController.machineType.toString() ?? '' + })`; + + super(Webviews.CalcWebviewView, title); this._shortId = this.id.split('.').pop() ?? ''; + this._machineType = Control.machineTypeController.machineType; if ((this._enabled = configuration.getParam(`${this.id.slice(6)}.enabled`) ?? defaults.webviews.calc.enabled)) { Logger.log('Loading Calculator...'); - void Control.setContext(Contexts.CalcWebviewViewEnabled, true); + + if ( + this._machineType === MachineTypes.Mill || + this._machineType === MachineTypes.Lathe || + this._machineType === MachineTypes.Swiss + ) { + void Control.setContext(Contexts.CalcWebviewViewEnabled, true); + } else { + void Control.setContext(Contexts.CalcWebviewViewEnabled, false); + } } this._disposables.push( configuration.onDidChange(this._onConfigurationChanged, this), - Control.unitsController.onDidChangeUnits(() => this._changeUnits()), - Control.machineTypeController.onDidChangeMachineType(() => this._changeMachineType()), + Control.unitsController.onDidChangeUnits(this._changeUnits, this), + Control.machineTypeController.onDidChangeMachineType(this._changeMachineType, this), ); } @@ -136,9 +152,24 @@ export class CalcWebviewView extends GWebviewView { } } - private async _changeMachineType() { - if (this._enabled) { - await this.postMessage({ type: 'changeMachineType', payload: Control.machineTypeController.machineType }); + private async _changeMachineType(e: MachineType) { + this._machineType = e; + + if ( + this._machineType === MachineTypes.Mill || + this._machineType === MachineTypes.Lathe || + this._machineType === MachineTypes.Swiss + ) { + if (this._enabled) { + void Control.setContext(Contexts.CalcWebviewViewEnabled, true); + this.title = `${WebviewTitles.CalcWebviewView} (${this._machineType.toString()})`; + await this.postMessage({ + type: 'changeMachineType', + payload: Control.machineTypeController.machineType, + }); + } + } else { + void Control.setContext(Contexts.CalcWebviewViewEnabled, false); } } } From 9d0698ccbe6361f364e474838f2f8f0ccefafec8 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 28 Sep 2022 16:18:04 -0400 Subject: [PATCH 75/79] Added onView:gcode.views.calc --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0779025..755d0a8 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "activationEvents": [ "onLanguage:gcode", "onView:gcode.gcodeTree", - "onView:gcode.gcodeStats" + "onView:gcode.gcodeStats", + "onView:gcode.webviews.calc" ], "capabilities": { "virtualWorkspaces": true @@ -638,4 +639,4 @@ "@appliedengdesign/gcode-reference": "^0.0.7", "@vscode/webview-ui-toolkit": "^1.0.0" } -} +} \ No newline at end of file From 05778dc3ad426876fce68fcc97e82db442eac6c0 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Wed, 28 Sep 2022 20:29:43 -0400 Subject: [PATCH 76/79] Fixed layout issues --- src/webviews/apps/calc/calc.html | 4 ++-- src/webviews/apps/calc/calc.scss | 1 + src/webviews/apps/calc/calc.ts | 24 +++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/webviews/apps/calc/calc.html b/src/webviews/apps/calc/calc.html index 4db58e4..f3bbeed 100644 --- a/src/webviews/apps/calc/calc.html +++ b/src/webviews/apps/calc/calc.html @@ -72,8 +72,8 @@

Chip Load

Metal Removal

- Ap - Axial Depth of Cut - Ae - Radial Depth of Cut + Ap - Axial DoC + Ae - Radial DoC Feedrate Calculate diff --git a/src/webviews/apps/calc/calc.scss b/src/webviews/apps/calc/calc.scss index c99c405..0ddec8e 100644 --- a/src/webviews/apps/calc/calc.scss +++ b/src/webviews/apps/calc/calc.scss @@ -4,6 +4,7 @@ .container { display: flex; + justify-content: center; min-height: 100%; margin: 0; padding: 0; diff --git a/src/webviews/apps/calc/calc.ts b/src/webviews/apps/calc/calc.ts index 912f4de..166c389 100644 --- a/src/webviews/apps/calc/calc.ts +++ b/src/webviews/apps/calc/calc.ts @@ -134,10 +134,16 @@ export class CalcApp extends GWebviewApp { switch (this._machineType) { case MachineTypes.Mill: { + // Focus Speeds Tab + const speedsTab = document.getElementById('tab-1') as HTMLElement; + if (speedsTab) { + speedsTab.click(); + } + // Hide Surface Finish Calculator - const finishSection = document.getElementById('finish')?.parentElement as HTMLElement; + const finishSection = document.getElementById('finish') as HTMLElement; if (finishSection) { - finishSection.style.display = 'none'; + finishSection.style.visibility = 'hidden'; } const mrrTab = document.getElementById('tab-3') as HTMLElement; @@ -169,14 +175,14 @@ export class CalcApp extends GWebviewApp { // Update MRR Calculator const mrrDepth = document.getElementById('mrr-ap') as HTMLElement; if (mrrDepth) { - mrrDepth.setAttribute('placeholder', 'Axial Depth of Cut'); - mrrDepth.innerHTML = 'Ap - Axial Depth of Cut'; + mrrDepth.setAttribute('placeholder', 'Axial DoC'); + mrrDepth.innerHTML = 'Ap - Axial DoC'; } const mrrSpeed = document.getElementById('mrr-ae') as HTMLElement; if (mrrSpeed) { - mrrSpeed.setAttribute('placeholder', 'Radial Depth of Cut'); - mrrSpeed.innerHTML = 'Ae - Radial Depth of Cut'; + mrrSpeed.setAttribute('placeholder', 'Radial DoC'); + mrrSpeed.innerHTML = 'Ae - Radial DoC'; } } break; @@ -220,14 +226,14 @@ export class CalcApp extends GWebviewApp { const mrrSpeed = document.getElementById('mrr-ae') as HTMLElement; if (mrrSpeed) { - mrrSpeed.setAttribute('placeholder', 'Enter Cutting Speed'); + mrrSpeed.setAttribute('placeholder', `Enter ${this._units === Units.MM ? 'SMM' : 'SFM'}`); mrrSpeed.innerHTML = 'Cutting Speed'; } // Show Surface Finish Calculator - const finishSection = document.getElementById('finish')?.parentElement as HTMLElement; + const finishSection = document.getElementById('finish') as HTMLElement; if (finishSection) { - finishSection.style.display = ''; + finishSection.style.visibility = ''; } const mrrTab = document.getElementById('tab-3') as HTMLElement; From 7e1e583ce14411c75274e204b34d91e207e4d4e0 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Thu, 29 Sep 2022 13:23:40 -0400 Subject: [PATCH 77/79] Added screenshot of calculator --- images/calculator-screenshot.png | Bin 0 -> 14445 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 images/calculator-screenshot.png diff --git a/images/calculator-screenshot.png b/images/calculator-screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..0aded90380a898ab023d9f3fd0f78a9c17834594 GIT binary patch literal 14445 zcmeIZWl&_%vL@P%Hqf|x1C6^obR&(sH16*1P)$SQ?(XjH*0{SD?obr&R*!S;%#Atm z=EXhnX6F5RKX&ZgJ66hZy%kNB}6_{O%ffyKfsuOm;3(VLv1wDiy`d$GlGMprt^mnD1HC9J`UNJn0)xa z10^N)UDZPmypHUldYj37VGpF%iTl3sTZ&HV>$K?_y{3~WdVk~^&KjelGWWtQ&VXFS zMFY*M%{-HJ(;}Ch7H2x0bh`l=kVda;qOn%w9C4kn{#VEZa^yN+171k(K4S;9<6ph= zbHL>Jc!sA86&XVO$o;iI{^4szs`KRii+iBAZgX8Xc)fG4MEq9JF`Z-KjFpg?fsW?MEnTLHgMFr&0t))tC$O? zU^sKPXFwxr$~LvzD!WVfB!_orfCpFx5Pg^oq0rM25XYHywEhEBdfdT~o$-ZZJcpp@ zTIjiRcL6PumUhM1vos%hT&fL+aF6*l*1E$7d>J}lxX7Lx#8ybwHv7`f-m>8H?Wgj_ zMq_UI$Id8;o6blcb>3a{hG&RO9Q(V2vKiz+gGsVIb|E`w znMs@X2B&n>)cL06SBV|;V>Em1i}{D;$Nu#@p{CW%@xWltGgMJYk0TCEDoO~+3(FC= zn_ss1jE}tE)IO>vkQ2nzx*C{MZ%{Df1O@I-d4f675ELva8k8e!YFMo;YeFN6kLJ z6i_5TCPM>+HttXDq5`}m0u>wjE&w{Og!6v8*`^~TFK*pxT4_#|w1(@ygdv!%`=+a` z)YjUCR;ZrcsIETO{*KlBom({2&UgnqbHII1Yp7XIvBH(B3O!GRbL zBUcSEZXP(;FVGd=I9)je(v_jVzN@tKt`fLqQB|MPr|bE^?{Qy+#n%qCJ1&W;o$t4T zqIGa+A%`pq(p=A-T#F#Yx;`r-T+QihQG%aTg+;H+`bfyAy@~1juA#NIB|Za16qcZS znMN-jhS12Pl%A#Mlsu%Y)KTekq4%N=6l2uR6?XqW_WUJFx zrhBJ0uCsIo$|!Vy7xVo@A08xa|IsRW*mNo!d{H;(RmMdsU@Q1bM5bO{jps-QXdB`t zc9Ii+X&MjC3Hj2;VcEab8<+e2Wga_^r`=W@-fUT9q6J=fzRSH=t zzi=0qEk~G(NP8Yo0U!IjR~E?KT^qN^RPRbvzSbQ=n4}LSu=ulC)NF~B+(uZFPVSK& zQWvPqr3?Kj&mW>5^#mbsv9}GK-xOgQt4DC|yH`}CCQB!~%t!+s#gJ%&1!&$T=n8$Q z6zk&S>W(>uXs$)>4_*!?A6=rB7(2dNB&Vn-QwX$qbu=+4&BxJFmMufgu;e~8Q)*m( zBkh~6!-TwP*DD7SD)YM_d2NF}EpZW}+OGtNK;SaKCl&%4br{xf3~CZK#NB26PfIw)`)R44(&lPW6G6>J zlXc2IcPBG^GY=nv-BgXQwVi7!Zt6d!QJ#X2Lmb!H5|~;D-UeLSFGaiIQMPdx(rYD( z;g-8252u+GJ2ek}yds0QkGhkiW@|7Z{uY07afNeWEi!aU@%PoYSj zzZKUyB#tLK(Ep{f=1D>57w)S*SPR-psTbvNA?ANU$c11mVY!W2E z9iI?r6%_fBnl6M1P6VOz4Xtfm*NmYAe4&y&_{hJ`-40id>7|ZWv|B=thQq8K6g3h1 z`_QSjTcSGe)Wp#wcsdK<|N(X zcp;uJ=&IS7#TLZAU-=UJF?^o2QM@?D2Md`zE=SPB(OZ?!JWu}cyP4;NCyj0{5hR#8 zPeq25Z_t+mx)&U_*En?byr z*MFZm>+Oi(jZb7NH0yr|7gl|c9FT?FaB8%QQHRg`1aQ^JAG4L3+*Ry$sN}5%Oe`cW z!>^m`!0(a}@gVAC9un;m$;!Z^a7u)*y{~uK6xo8|{kdt`)a8Piv@fTPSE^j2>m(8K zV2(jMRCd$v5g$bV?1{g&RVScUeIeUQb6=dc^3@_a#p1D{PIds7DBLv(>~g=Xan_9n@4a&ze8uNmVnyczf5T&N7Hrl023* zAyj&1E-kK^5~p9x>|`EtO?bu=h`KfbJqq!DEfei^Eb0^_XbM`l=8j&!J(9bq(xp^U>ZNalJA*^}PP z;kaCo_?DoFt!qG6Br)tM!XMm^k8^{aKB;eMe;b$hUCmyH8~K>5`nW$`u$%q%APWe) zerL1sM>H$-@8+B-=*jn}!%I(tHZCaI@PZ@{E>0L`{rn}>^K8lPx42jFMUGlw)CI{- zYx8A;YAL!aF){1cf_tBhMz_FwEar9+{dNRT)Jy2+PJzJApNAdpxW|HGDqy$nHq16z zfv$Mmx2NfyMC%w&o`-c2NI6HWpC~(csz8i(6WmkWtFKb0zkdAr(bl2`kA&F_6CK&# za4ASqj6(x2L`*EqUs9~#-xcVpAcrUifG57S6bLm1Iggw+E^^L+YRLOaJqQ4MqRwEX&#~a{yB@4He}%5+(Y^tUgE((UN_?q;~5MVE^wnEX{D=~7`JNpZ{DnQ!sKEqQz|=B zY-yigmNx5HAlU%!lt{wcR<_a;FY~NmriJiynEEyEEW%X3i!Kcud-&xMs+H2cSgm{w zV;jWMW~~l=|JwDpBq=@aBDISNnx`G3#3R@_mbVSF(z|)A5g3xxN9{ke>xw`?gMbrK zJpHr=XA`4v+vjd58lUhvp3QNh*tMz6!KJxzylwRPB9V`jiJbTm3CX3Z^17npc|^fj zQ&Q1vBP*H+VPlS%&wu9^{2zS?Ayxt9_6y8|%5m!>^ps(+pX zp)H1=LXaPGH~u$iATwZ>3kw_B?HH})mXA5k0Snmei91TSG}5RYDbaPOws!v&LFgKi^jzFN$3e8>g>pt4Paik!H!{n5OE4XzE2=CXJ}5x63i)5d#1a zpID6=l4R!sucJ4+pwtLWc{RJM?kp4h7Inq(qs37LB3F}L-Ug)wZW!ycR+5=8X7FUk zUF?S{@zl(;)#z(#IBLMFjr%kiRpEG9I%{=K-QaS_N1eQvcUy71)AxxXRz7f2riXhjiU=WhogH8EDh4SWn6qwoO8%UG=5-JM3 z{tKDeCfZBxuc{p(X&=SZu+ze34@!JS7KaY|+<1C8vm_qX2iL;k$%#|rx`#ucZ>-VmeHezEaW_Tiln;H|QSl^+53zB{5?K!dS+f=@vC4oXX? z<}QQf{T#^I|3p8F3om|!L`uBH8R?L2Z-Y{G%hbZKQ_`s@!v_I>cZHWynZUyKu}GT% z)^E>jkLF|tUV<%0z{rVJOSwx*Qx^@~Wz*?UVl^-(G>XL+#zo_kuGCJ7xtk zj^D#RUyr`3ZM1oV5Byn+oQs+tRj4)kBmnm+yhaO}(Tl=I4!qbn0b zn`^jhnnpaGC z@s5OlP|(JK{!9Mzu%INtZ@s(Rgqln`p>pK@1h{0w#CAi?_gN5TdE*07B_c!?LMOU? zP;ujnjAjmt$V>BKg(DT?3dU?U)f-acM)&@B9F?P&#eFaE5>$uZ7Pp&^3j6DTaVUp< z9nVX1bG{frSe;eU$9i(wE3Q&anuxVl%F2c8&t@!iRn5iE8+6yauYaCdC&DAhj(ZNa z{vHn6WxxMsf31+wysFObj0oLbeTbCuBt^&mgr557adZ}3vlG6kTKVL~a?7l4xbQlVVy$qN?`6ZSa6Hr6 z(s`m(Q5Urhe<$-MNb@Go*ahj7PS|XRqCaDlSO~%%PF6gBS!b>lO|C7NOav#cW`HFeYp;^?}Qz2PtJ4d%dhdv+&JiNBW5%=eTx8I?opJR zkQSDB-Qjp(p4x`Ppor1FRRa*@4!+7mprm!HwQeT3Y#^x4;=}_$VKbt^%2!SrZM8_- zZr-rTnd9M%qyVBv6KNWvSMW#g)a?1KKfV%&er%k?N*Tqm&n0Byd*6F2kju{<)DCsgJ0tPFd#WL!qQkTt2Ir*?eoO+Vh2Cz)i} z^6_^-M)}|K*8fak5oStvZrk3nZLzq0x-1~(z5WB&q}f3yFQ{Md*f9U!<1b@X9kt*# zy65v}s)V?*{ue#5*BApxGvTXq1Rq>OURTNI&Nsus$NiE{0F>K9GUGQ-Ia(?XtX!LT zPQwe0=SkETve(=790I08eR?P!$ml?k1fUkH$~p;!mC@SWZh=M^KK#h@#9s3b0YFZ(>DjdGqd> z7EX{T;ztd9m$Qk!nNhuof3`-6s0#Ds)$eHR%@i(wyjX#;+Q^0#^D4 zl*RHZn<{hai+~{9>eAb4!h;G_WMn=DE4s!6BU{lXYuHXZ`T{HMFThBysj?kV z$ChvUW^XF4(;7m-L8iI~mE2sdBBzI`J@qUbRCoB)QdkClZubvXyDZ<&a&-)mpF`0@ zC|idS5Ry`C>Eh!|;uFwLG5W7YhZNOSBa7;li&zRLLKbLx*uDKL$_r!F5mW$Qq_$dQ zd@-hx%%17{|L*puyw*;F?NyvI`$-vGR^^KczL;V!oWE6)!HX=RY3gH8rkyG~cm&>=tiaLUdK`}V z-2^4u@^A7glCu>OvccJ0pH1$``QW1}) zF%ecz+$eoZi_3y=I|PdoOBV*7R12Y81{fc~tfGOm_n)5wCJeblHM&F9e(RHXSdS>F)mJXo%J_NPq{CZPtaxaXw)|rUv#WAOH}5!P1c0G{C{Y0`9w>)8HfW z$0!K2U@|E^Thk}>!IWGm8MXS!|4YT(IR&%>#o%${9Src=I_MDN=5%9Jt3WY$&f*;p{I z`BO-~MT>Gm)i$|7XfiRr_JMCnT>UK$`C{pgy0XJci(?r)j2Y9v--s+0krw0=RfQIjb{Y23 zk>M-;;k*7(kW&>&K&!8>cMaK*($-E#L1xN=JaDKU0>0D+{yWJj54l|6y;t>1e8}35 zWk6|M#E7Tou>7J@emnBSMDR>y{)}vfpI}{k+RWMpFs}BKU{w4C_-;fvI1Hhm-q9!K z9v=WHl=jJh?2QZTnZgpotfr+qF0Z--8lPSm-upevu7F1ELHa@|yz=(aHk+0;m))xP zIO7A&gzfGi^I>M9=il8|V$NH5K8LZVT^}vbbkDBsL4KRQZ|$+*OopF9eZCPB7BZLQ z%yXPSQF!?2MIMDb+3HkWQ=axQf9kp}a8G>u`7@c*kcWWVE(7J33c;A2Y6SEC)1+@n ze1hlIVSVW2_~Zi>Y&AdLWCm}(Xn?gxCSYZ9IU;9&<`rFl z7t`VIs@)N*Ux+iVz%ai1U%u?cHr*jdCSxceL|y=9@nla43T5&OPHtud_1w&BjdSu^K!<|&nvVv=Snx)+r<^sBWh0EP|leODv`AGr_HRV)X zb*SUP5zIPphlQ=jh%#)TYA$&9!qs$4?vR1jKb2ZdxAI zv!}MGMF~859EG<|)8xq$uQe{xz+6?AgfCVT%yORFU9um{Bth9jA>RS5c@(^iL!FHd1jE}OWu}FQQ z(glwZQRL-jYL$>KHOtic+yOcGY!%TgByVqg5ozc9ve5X=LTjAMHRj2BYqDG6H)F{Y zp%YVIuVU(|sMDQ^Y(knSn@lkDZ~tZHqRJm-Y;R4SU7vKB@iD1k3lq!XmCAZIY`&Gr zP%WQY#c_*RDg!A4yy%DzG}eI$6fqbG(3i?OqmQWOX)J9NSxb5@V~$@4^-8-)-Cc8( zAdx+K2Mh@C?dH>O%bh`_Q4`;O%;Nu?vSFiY^}=dz7ZM3t3Ma~RtILNbHJ#{*ATsBd zuP&%aP5a}B8x7-y9^jHsze0F~JUQA^LNWPldnXj_9?=_NU95dQn0dPmUUa@IBhBiI zt#V9Z?HiwawX(koHjmD+t{{rO^Gb^@E+;+!xdan|hBlK49s2Ls^v|wIbCXweFo%CF z@yj>)!bvH4^+s;Ff=P}lqF+Bk995(FEg4Q1R>syyUofE@#ifat%y)eflI?;C-w^y` zBmY^9GyV^l7eQZi$i`YWCf0}kFYO7+ers+qF=+q)J1YE7c=%rkoWG%J@zh*hOXy~l z2n;>mO5G8zx*>G`0CQJECnZ+Cjh{@@T}*~ohB$J!ok;p5|6VIVQ}|1VWLkKYy~DG~ zViFCl;I=ZOOoh`aFzsUEyo?A`Nz@- zYtdo|`_t|dP&b|@ItUW5)$)%ke6O*NClqUnaQ>7uCnr7%*_W2f(bp(!e1`sWnEgbx z&98=%aWtQ65SeJ|Kigk~({Pd_mvwW?d6&b<>>_}idTrXWXSSD*P|Z{LCkXCg@}z@h zpv9953K*+h@OLS+;q#%HD>wk|^OW$dcrW};gA@r7KgMyWbs6o|Ub9fuiJX4qghVNT zzsPVi071o7504gh?VLe7cy@*4A2`vI1Mhtwm@)X#4wH?)%hPMUfCW)(>o2)`mx2?} zo^lpSpFNb78r@MT~Fg5IZ1;|Q%pI1$~c6;vZ*=U1fa6_vYQ%9glyR~=|j zroj7$wF_vrTJNMdtT&bWzK5?d-~91(h)dhw!Mm8Z7PqRw>jnoF-`FI})Y)6f_Z1a6 zN%qLI$)@*8Su-MMUfy@YJy$I`P0loBBHDH+MZHus_DcB0PLhAtor4$NZx=+i1Qj^_I& zlc_lN>zHKh?a}Z{9&&bWF|J8&?p=pvxN(8%m$^zpTl8dNjmvxevWpiW2IvK~;N8dT z^(@_o8|K)Be0V+}nrkBLisvic^lB%o>c3nUdT=+EhVgu_@CnCkQtSA@kxv2g-u1W% zEw5@jNjJ+WFCR-|A&MmAmJjxd53I$H{}n~SbDt}(d@v%&zYEo-ypJFxh@`0*e-Yc5 z(duAsysDw;trH}BpHtr1=M|Tp-mk}n6hG}xVGfQ=JKorfW;t8MPZ2t%SXt){Je5x| z9_cAz2Ol|9Njc|EX89AX=pAt(gYc>+Y7bzerqTkWGBKuC{rJjvqeZ zZ_qpbm2JNBP84LQ54gvyvm?#mb^Z|yhdTus7J@*B+J@Mb>gjkIal4&wL>}B1?rmo> zB&%?vaF3~Uh|&>UiLF;EXgSY#Y}Y5PcedjXQIE8g>&0bo{>U0-V?MBo5g6GoT?g0S zlQvC+>Xll#_L)zx0|le#3mY(XuulTc;(0a%(SHWne!<67iOSc!-v!0𝔯eer6Vc z7{O!%SfQX<@mD;TcAr3C1-+tj!Q#Hd>Mj>|qGakrJWam1(Ba8Ay1&ozlm&#;3N949 zlr=8*&$j+_(x2nl>seo#Bg(;xOiyL`g8e;saeDNg~Wei(d7gEKv(WuWx8u%%gd`g>$xLdLDG?lg@&L%Oa@ z=6xy@ZMRa?xnP%pn#nkJ56C|7=xer&oejC}ta8Wo#(qqb~`LvTz+e3{wSqWEoqT+MQ)6>bGJGw_3o@cdRFtMfpdpLNWcq?rupOZPP##L z`i+!o;<;Z+Dxw;;#OVD1KaQns->{i&MW4g!jXYeOqPu)SV$ayux zm5@$3a&*6HXSgKE5rjuXDDhBig4R~pzi)ze*QrgBbgMQg-7Z(g#;>z2-qHA_!l&t+ z(C&LQOB&>%do)c`s{f(M{x3l&5v}^YFN6&9f1=xNq#RM!#;2NibmZ{!z423KL`)_j z@+z0OQ^tpNa1=756`fZ{;O*hZYjr*qJVb(7S;9;gFxj{yXDj0B2ut9aCcf0SVZ~7W zIZgC(cAkB4O-?%eHcrz{M zy(wX&UojMQ(HrW1kgMK|b(P~>_3^R8>+^=^o#vU;_a6j&3PjVatiqU<<_do~P0=Ke zr140+7kD?UI5MX-18i2mqE;V&!k|W*fQ>M=xKD<$nw~8S=+*gfhScSljGAdoZIFgv z%k)Mye=a^fp;BW;dBvYL?b3u5K7MDt8s%dUYo zGwqo=si8tUWhKj~4WXhkjOWcouHGoY8e4bHjn2(2U%03RAH>3o9&0|G9hjYY1Z5~2 zgtgC3A8`+OaJ4_OsfbE@nt2w(7zFXJDmm}r32Z#x{h?1UHPV-rr#Bj?S;uJz4}%*Jc&7Ng?g2Y zQ)JkyagV9Q6jSKr|4dLp*srg%?%;gXwx4RU*jz;3Luiopn z#RR%r4;)F(f&U32XMGhzcb_hSD@oPCcN^)lH@9!jU~%u9#hh_O71~rdSBDf=69}?A z(468uxx=q}O)p$jKDU3aPx~!9EkncPaNhhCm)A>nK<$rYyaV@NI|N^z82#Tcc}Zv$ z)H$By(3R&c*3%z(hBO>oB9qq3qEj$& z{00G{6LgGczLYf`^ad5+lYqrpZS8^ttK@WRE;W(^c^WIsN&5G$0w+=5De!fRIkTbf zB(V0kQu)JT$769r0L#~L*y`gWjIU_xxDFHqKAFR*=pH+1NIfT=^<@}$Ly(5gtq;~4 zmW@fss4`*NTDRkoPtvj$J=nVkEB@C6IB2Fdp#=)C>Sbj##5Qz`1@-j|i-8r2bq}hEPxfYqO@v?dcc9)& z`lt@B=24{BWhq?sX=3n}@|;v&yx89~x+M<+wo1b}xaMz@o;e7V6+@g2()b)CUUD$P z9H-|X+c3EtO|i204V6{LEsj4a z$3^)@@KLSOa_YkjiJtNbXWqqo{#Ip$1T~W_rL#f0m{eb&Kh9~i_Ia(3@de=*=XK|P z0m`yJyF|I(vCco2w@j1Rvrnye7&moqoETjGjLbAng7@^bMnTLxR%dQ$grg(S0-saQ zId7IqSWg4-_L3Ce(~JRZP$3B6Zzgjmn_#c#g$R#$0!!z(*rj;c0i}PL-M9vQYsEVW z0J^Y1y1e|rxSRe+)zx^x7!w7V@1M~9p)P`mXVG8hqUv(Jx&cgZ+?$y79g@3ZK{y%ziTdP@b=4%2MMJjA3hZnVa zRxe`?!qCt z=UeG#z&p9dLL%9Uh|RXH@5KtdW3GPA7utR##m5U_rR~XxKw56D79XOZk%D%!8ZjI@ z_qVN@82a?mN+@#86?GyjVNEGs_VwN!M^5e>Ng}Oa6ItI&vCGY+4vS( zWlPWrO(xTL)8%tl0+#HOQW*9WM6%~wgeGEjx4_SM+u;7 z!=}+nvdo~1?xIgo9}wi8>mUH3_z2BP6}jwef@L-tvB+e?G!2S*12k$m-D`VLoTzwX z&9b}J=s(pl1M%nXOc_BwR?w7iVISYW_4ixE%n96_y0fmNajQ-Sc9Ec&z^san!dp5U zEBlU0J1k_??c)X^6f&@!RKo!rc+Zi;SXA{Q3^=5D#EE}Z|9C_=qp=zuz)V@0eZTIGS?s6`eCy;3?lF|Q_9mcYR z1#QIs7TUAr^7O6dgO=`FJk7#9RL4H^2;)#W_pu4O&Zvu;ek0#=*(9J`tazwrwWz(! z+LpdosJA7W-KVt?d$J>!30bAX@Jrn2fWAre@AGf@QTKxhRK?Kzjabe5FlHMEfsr=W zJ~;`G`4qd3=8Ea-9^+#5oab$Fe5F%g_w3RGedVQ`s2$Av?*?LaJD%|l)>!loSIE4n z_sDXF(q2u%Cv#&%{3V%i9U64uy;azVxp(eMT%o|XZl@sWzgXo7%kPfDU-{q!y4ZEt zkw6&C>hWWH5C~P+BuV_GoHPaMJT^e%sZDA$N9oPmuXp7WMK zj{Njl%nAR`jVy75_^4Wmg9xY<9_8h1_{Ho}|@(jY0EPh%CVi9RgqL!yom z%@8E*wU1_$yJX^NA2tIWwcxV7Uw*Hrt?x*{d*C zzVTh3X_GxyBPZaki%9<}S5a{pHoMguds1h)a?L=G^q2Ir&KCHTP3!t6uy-}=6ERLv z7~R;96RcXOAvHQ}{>o~~{*B6Ycc>OB<`N2O@^U&~?4;-D`VV8(_=SCcHGHYwH~d|> z_RU^G<8`$eX5&eJ$07VfWU&1ne?JzUml!9=(_U5Gzq@6eThATx}r7cydy4qaL2GW zH7x#iTFMp|zH@HVpG1u(jn$18!r`&Xwbi8^ez9OazG*-bJsxo>xq~g?7?Dh^OI{h} zS51U!8v~HJZL2E67#r7*$kvb2DsQt*q7{GBNKH~HQPW4oNfP=8e<~9h)vzjo{HLI{ zc_O*@%k?y+TAe&2iLOc^$o}uW4DKinGU~yG?w?3)mv+Lj+Tk=Np;&ys2r;J5Vgz{E zvVD)Z=Y75l_B%%!%s6igI+=zXd3h}aa^|KrjU?jYrX{KFs7crb`L9FnBOd5s>H<;R z;6KKD-_@_|Q~_Z0jt&UaEE3MPI{WRSQv%au|KmUSFt4AQGH<`E>wS-MWMfJ**4Yf4 zGaQoa|5o5XyAkNxZ6V>kYe$r{buD{T8v%dnjVd85`TM^54I%L!hg^6;*5+@Uci20} zjnkqT=R}Hn19-`nhSF?Mf1VOiY|txfFjG+~$#+M^B~VXX$!6aNSq+1}Lv)JpR Date: Thu, 10 Nov 2022 16:22:10 -0500 Subject: [PATCH 78/79] Added dispose/visability event handlers --- src/webviews/calc/calcWebviewView.ts | 5 ----- src/webviews/gWebviewView.ts | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/webviews/calc/calcWebviewView.ts b/src/webviews/calc/calcWebviewView.ts index 6f57dc0..331cd5c 100644 --- a/src/webviews/calc/calcWebviewView.ts +++ b/src/webviews/calc/calcWebviewView.ts @@ -51,11 +51,6 @@ export class CalcWebviewView extends GWebviewView { ); } - dispose() { - Disposable.from(...this._disposables); - super.dispose(); - } - private _onConfigurationChanged(e: ConfigurationChangeEvent) { // Enable / Disable Calculator Webview if (configuration.changed(e, `${this.id.slice(6)}.enabled`)) { diff --git a/src/webviews/gWebviewView.ts b/src/webviews/gWebviewView.ts index f6ee52e..3dd99df 100644 --- a/src/webviews/gWebviewView.ts +++ b/src/webviews/gWebviewView.ts @@ -24,6 +24,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { protected readonly _disposables: Disposable[] = []; protected _enabled: boolean | undefined; private _view: WebviewView | undefined; + private _disposableView: Disposable | undefined; private _title: string; constructor(public readonly id: string, title: string) { @@ -34,6 +35,7 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { dispose() { Disposable.from(...this._disposables).dispose(); + this._disposableView?.dispose(); } isEnabled(): boolean { @@ -87,7 +89,11 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { webviewView.webview.options = this.getWebviewOptions(); webviewView.title = this.title; - this._disposables.push(this._view.webview.onDidReceiveMessage(this.onMessageReceived, this)); + this._disposableView = Disposable.from( + this._view.onDidDispose(this.onViewDisposed, this), + this._view.onDidChangeVisibility(this.onViewVisabilityChanged, this), + this._view.webview.onDidReceiveMessage(this.onMessageReceived, this), + ); await this.refresh(); } @@ -126,4 +132,18 @@ export abstract class GWebviewView implements WebviewViewProvider, Disposable { return Promise.resolve(false); } } + + private onViewDisposed() { + this._disposableView?.dispose(); + this._disposableView = undefined; + this._view = undefined; + } + + private async onViewVisabilityChanged() { + const visable = this.visible; + + if (visable) { + await this.refresh(); + } + } } From 71bff5fabd45a430883f9f95415e3b55872f4176 Mon Sep 17 00:00:00 2001 From: Mike Centola Date: Fri, 11 Nov 2022 16:46:26 -0500 Subject: [PATCH 79/79] Refresh npm to fix package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index b9d299d..16e559e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10428,4 +10428,4 @@ "dev": true } } -} \ No newline at end of file +}