From 2d2152262334fa8b19d5b496f408ef641d4ed63d Mon Sep 17 00:00:00 2001 From: xhayper Date: Sat, 29 Oct 2022 11:13:17 +0700 Subject: [PATCH] chore: more cleanup --- .vscode/launch.json | 28 +++++++++++++++------------- .vscode/settings.json | 12 ++++++++++-- .vscode/tasks.json | 17 +++-------------- package.json | 12 +++++------- src/controller.ts | 10 +++++++--- yarn.lock | 26 +++++++++++++------------- 6 files changed, 53 insertions(+), 52 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0beb4d79..c42edc04 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,17 +3,19 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { - "version": "0.2.0", - "configurations": [ - { - "name": "Run Extension", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceFolder}"], - "sourceMaps": true, - "outFiles": ["${workspaceFolder}/dist/**/*.js"], - "preLaunchTask": "npm: watch" - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/dist/**/*.js" + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 392aaabe..d647cbee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,15 @@ // Place your settings in this file to overwrite default and user settings. { "typescript.tsdk": "./node_modules/typescript/lib", - "task.allowAutomaticTasks": "on", + "typescript.tsc.autoDetect": "off", "eslint.enable": true, - "prettier.enable": true + "prettier.enable": true, + "files.exclude": { + "out": false, + "dist": false + }, + "search.exclude": { + "out": true, + "dist": true + } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8e4e115c..e1d88a0c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,28 +5,17 @@ "tasks": [ { "type": "npm", - "label": "npm: watch", "script": "watch", - "group": { - "kind": "build", - "isDefault": true - }, "problemMatcher": ["$tsup-watch", "$tsup-tsc-watch"], "isBackground": true, "presentation": { "reveal": "never", "group": "watchers" }, - "runOptions": { - "runOn": "folderOpen" + "group": { + "kind": "build", + "isDefault": true } - }, - { - "type": "npm", - "label": "npm: build", - "script": "build", - "group": "build", - "problemMatcher": ["$tsup", "$tsup-tsc"] } ] } diff --git a/package.json b/package.json index 6ea6ba9b..225bed5a 100644 --- a/package.json +++ b/package.json @@ -39,15 +39,15 @@ "onStartupFinished" ], "scripts": { - "vscode:prepublish": "yarn build", - "build": "tsup", + "vscode:prepublish": "yarn run package", + "package": "tsup", "watch": "tsup --watch", "lint": "eslint src" }, "devDependencies": { "@types/git-url-parse": "^9.0.1", "@types/node": "16.x", - "@types/vscode": "^1.57.0", + "@types/vscode": "1.57.0", "@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/parser": "^5.41.0", "@xhayper/discord-rpc": "^1.0.13", @@ -55,6 +55,7 @@ "eslint-config-prettier": "^8.5.0", "filesize": "^10.0.5", "git-url-parse": "^13.1.0", + "prettier": "^2.7.1", "source-map-support": "^0.5.21", "tsup": "^6.3.0", "typescript": "^4.8.4" @@ -728,8 +729,5 @@ } ] }, - "packageManager": "yarn@3.2.4", - "dependencies": { - "prettier": "^2.7.1" - } + "packageManager": "yarn@3.2.4" } diff --git a/src/controller.ts b/src/controller.ts index 5d05b6a9..1c716382 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -18,7 +18,11 @@ export class RPCController { private idleTimeout: NodeJS.Timer | undefined; private iconTimeout: NodeJS.Timer | undefined; - private activityThrottle = throttle(() => void this.sendActivity(), 2000, true); + private activityThrottle = throttle( + (isViewing?: boolean, isIdling?: boolean) => this.sendActivity(isViewing, isIdling), + 2000, + true + ); constructor(clientId: string, debug = false) { this.client = new Client({ clientId }); @@ -91,11 +95,11 @@ export class RPCController { const fileSwitch = window.onDidChangeActiveTextEditor(() => sendActivity(true)); const fileEdit = workspace.onDidChangeTextDocument((e) => { if (e.document !== dataClass.editor?.document) return; - this.activityThrottle.callable(); + void this.activityThrottle.callable(); }); const fileSelectionChanged = window.onDidChangeTextEditorSelection((e) => { if (e.textEditor !== dataClass.editor) return; - this.activityThrottle.callable(); + void this.activityThrottle.callable(); }); const debugStart = debug.onDidStartDebugSession(() => sendActivity()); const debugEnd = debug.onDidTerminateDebugSession(() => sendActivity()); diff --git a/yarn.lock b/yarn.lock index 496704df..47ddf9c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,13 +44,13 @@ __metadata: linkType: hard "@humanwhocodes/config-array@npm:^0.11.6": - version: 0.11.6 - resolution: "@humanwhocodes/config-array@npm:0.11.6" + version: 0.11.7 + resolution: "@humanwhocodes/config-array@npm:0.11.7" dependencies: "@humanwhocodes/object-schema": ^1.2.1 debug: ^4.1.1 - minimatch: ^3.0.4 - checksum: 2fb7288638968dfeec27f06aef52f043726edd126ac47f24b54256902fdb35b3bf9863d4a4caf0423dccca5dd1354ca5899f3ac047b56774641ca0c4cbedb104 + minimatch: ^3.0.5 + checksum: cf506dc45d9488af7fbf108ea6ac2151ba1a25e6d2b94b9b4fc36d2c1e4099b89ff560296dbfa13947e44604d4ca4a90d97a4fb167370bf8dd01a6ca2b6d83ac languageName: node linkType: hard @@ -150,10 +150,10 @@ __metadata: languageName: node linkType: hard -"@types/vscode@npm:^1.57.0": - version: 1.72.0 - resolution: "@types/vscode@npm:1.72.0" - checksum: 590ec21d01d737176f231fde1cafae31e9774891cc3c89cc7167167c0d88a91547c5a9f2103f4e778804f4f55724e9e1d2e3499448e8cea0d33786a1c728e4b6 +"@types/vscode@npm:1.57.0": + version: 1.57.0 + resolution: "@types/vscode@npm:1.57.0" + checksum: 1393f0c7302562638ddae31a305680935e50b17cfb922eff4f83aeb06e3cc6e196d92224e32781c9c78e5dc342cc9878da18d01066a76739b99fed4658bb2daf languageName: node linkType: hard @@ -695,9 +695,9 @@ __metadata: linkType: hard "discord-api-types@npm:^0.37.14": - version: 0.37.14 - resolution: "discord-api-types@npm:0.37.14" - checksum: 8f45f202e66acfd7b25624c8f4d225b363d9d8991d766959bcf246761548b99e21c12d9f7eafe00903913af66058595e5e56329dfb219eab8bb75a84f6413983 + version: 0.37.15 + resolution: "discord-api-types@npm:0.37.15" + checksum: c54d2feeb8074509bdda430fb8ec0f6ff315512e7327d47399e0e7a78bbd0a6f0f0dcfc4b5e39825eb6141a13f33efa942711af89c9a5936a721cfc1e1d69d19 languageName: node linkType: hard @@ -1810,7 +1810,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": +"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": version: 3.1.2 resolution: "minimatch@npm:3.1.2" dependencies: @@ -2705,7 +2705,7 @@ __metadata: dependencies: "@types/git-url-parse": ^9.0.1 "@types/node": 16.x - "@types/vscode": ^1.57.0 + "@types/vscode": 1.57.0 "@typescript-eslint/eslint-plugin": ^5.41.0 "@typescript-eslint/parser": ^5.41.0 "@xhayper/discord-rpc": ^1.0.13