From 99766de53d18ad902c24be7b6a6e6ca03c9372ca Mon Sep 17 00:00:00 2001 From: iCrawl Date: Thu, 16 Jul 2020 18:25:05 +0200 Subject: [PATCH] refactor: rewrite for error handling, logging and disposing --- package-lock.json | 45 +- package.json | 6 +- src/client/RPCClient.ts | 113 +-- src/data/languages.json | 1757 +++++++++++------------------------- src/extension.ts | 66 +- src/structures/Activity.ts | 13 +- src/structures/Logger.ts | 12 +- tsconfig.json | 31 +- 8 files changed, 655 insertions(+), 1388 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8593878..d27653b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "discord-vscode", - "version": "3.16.0", + "version": "4.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -912,9 +912,9 @@ "dev": true }, "cacache": { - "version": "15.0.4", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.0.4.tgz", - "integrity": "sha512-YlnKQqTbD/6iyoJvEY3KJftjrdBYroCbxxYXzhOzsFLWlp6KX4BOlEf4mTx0cMUfVaTS3ENL2QtDWeRYoGLkkw==", + "version": "15.0.5", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.0.5.tgz", + "integrity": "sha512-lloiL22n7sOjEEXdL8NAjTgv9a1u43xICE9/203qonkZUCj5X1UEWIdf2/Y0d6QcCtMzbKQyhrcDbdvlZTs/+A==", "dev": true, "requires": { "@npmcli/move-file": "^1.0.1", @@ -922,7 +922,7 @@ "fs-minipass": "^2.0.0", "glob": "^7.1.4", "infer-owner": "^1.0.4", - "lru-cache": "^5.1.1", + "lru-cache": "^6.0.0", "minipass": "^3.1.1", "minipass-collect": "^1.0.2", "minipass-flush": "^1.0.5", @@ -936,6 +936,15 @@ "unique-filename": "^1.1.1" }, "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -1461,7 +1470,7 @@ } }, "discord-rpc": { - "version": "github:discordjs/RPC#df0a9e00b17b86c728e7b43bc2bae2641560a887", + "version": "github:discordjs/RPC#69915999307d337688b92f6011ea4961a7f8313e", "from": "github:discordjs/RPC", "requires": { "node-fetch": "2.6.0", @@ -2864,9 +2873,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, "lru-cache": { @@ -4286,15 +4295,15 @@ } }, "terser-webpack-plugin": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-3.0.6.tgz", - "integrity": "sha512-z3HLOOPUHkCNGkeEHqqiMAIy1pjpHwS1o+i6Zn0Ws3EAvHJj46737efNNEvJ0Vx9BdDQM83d56qySDJOSORA0A==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-3.0.7.tgz", + "integrity": "sha512-5JqibUOctE6Ou4T00IVGYTQJBOhu24jz0PpqYeitQJJ3hlZY2ZKSwzzuqjmBH8MzbdWMgIefpmHwTkvwm6Q4CQ==", "dev": true, "requires": { - "cacache": "^15.0.4", + "cacache": "^15.0.5", "find-cache-dir": "^3.3.1", - "jest-worker": "^26.0.0", - "p-limit": "^3.0.1", + "jest-worker": "^26.1.0", + "p-limit": "^3.0.2", "schema-utils": "^2.6.6", "serialize-javascript": "^4.0.0", "source-map": "^0.6.1", @@ -4303,9 +4312,9 @@ }, "dependencies": { "p-limit": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.1.tgz", - "integrity": "sha512-mw/p92EyOzl2MhauKodw54Rx5ZK4624rNfgNaBguFZkHzyUG9WsDzFF5/yQVEJinbJDdP4jEfMN+uBquiGnaLg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz", + "integrity": "sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==", "dev": true, "requires": { "p-try": "^2.0.0" diff --git a/package.json b/package.json index 2d256cb..1ac2789 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "discord-vscode", "displayName": "Discord Presence", - "version": "3.16.0", + "version": "4.0.0", "description": "Update your discord status with the newly added rich presence.", "private": true, "author": { @@ -181,7 +181,7 @@ }, "dependencies": { "bufferutil": "^4.0.1", - "discord-rpc": "discordjs/RPC", + "discord-rpc": "github:discordjs/RPC", "utf-8-validate": "^5.0.2", "vsls": "^1.0.2426" }, @@ -199,7 +199,7 @@ "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.4", "prettier": "^2.0.5", - "terser-webpack-plugin": "^3.0.6", + "terser-webpack-plugin": "^3.0.7", "ts-loader": "^8.0.1", "typescript": "^3.9.6", "webpack": "^4.43.0", diff --git a/src/client/RPCClient.ts b/src/client/RPCClient.ts index 9b5e6bf..28209b8 100644 --- a/src/client/RPCClient.ts +++ b/src/client/RPCClient.ts @@ -8,81 +8,87 @@ import { API } from '../git'; let activityTimer: NodeJS.Timer | undefined; export default class RPCClient implements Disposable { - public statusBarIcon: StatusBarItem; - public config = workspace.getConfiguration('discord'); public git?: API; - private _rpc: any; + private rpc: any; - private readonly _activity = new Activity(this); + private readonly activity = new Activity(this); - private readonly _clientId: string; - - public constructor(clientId: string, statusBarIcon: StatusBarItem) { - this._clientId = clientId; - this.statusBarIcon = statusBarIcon; - } + public constructor(private readonly clientId: string, public statusBarIcon: StatusBarItem) {} public get client() { - return this._rpc; + return this.rpc; } public async setActivity(workspaceElapsedTime = false) { - if (!this._rpc) return; - const activity = await this._activity.generate(workspaceElapsedTime); + if (!this.rpc) return; + const activity = await this.activity.generate(workspaceElapsedTime); if (!activity) return; Logger.log('Sending activity to Discord.'); - this._rpc.setActivity(activity); + this.rpc.setActivity(activity); } - public async allowSpectate() { - if (!this._rpc) return; + public allowSpectate() { + if (!this.rpc) return; Logger.log('Allowed spectating.'); Logger.log('Sending spectate activity to Discord.'); - await this._activity.allowSpectate(); + void this.activity.allowSpectate(); } - public async disableSpectate() { - if (!this._rpc) return; + public disableSpectate() { + if (!this.rpc) return; Logger.log('Disabled spectating.'); - await this._activity.disableSpectate(); + void this.activity.disableSpectate(); } - public async allowJoinRequests() { - if (!this._rpc) return; + public allowJoinRequests() { + if (!this.rpc) return; Logger.log('Allowed join requests.'); Logger.log('Sending join activity to Discord.'); - await this._activity.allowJoinRequests(); + void this.activity.allowJoinRequests(); } - public async disableJoinRequests() { - if (!this._rpc) return; + public disableJoinRequests() { + if (!this.rpc) return; Logger.log('Disabled join requests.'); - await this._activity.disableJoinRequests(); + void this.activity.disableJoinRequests(); } public async login() { - if (this._rpc) return; - this._rpc = new Client({ transport: 'ipc' }); - Logger.log('Logging into RPC.'); - this._rpc.once('ready', async () => { + if (this.rpc) { + this.dispose(); + } + this.rpc = new Client({ transport: 'ipc' }); + + Logger.log('Logging into RPC...'); + + this.rpc.transport.once('close', () => { + if (!this.config.get('enabled')) return; + void this.dispose(); + this.statusBarIcon.text = '$(plug) Reconnect to Discord'; + this.statusBarIcon.command = 'discord.reconnect'; + this.statusBarIcon.tooltip = ''; + }); + + this.rpc.once('ready', async () => { Logger.log('Successfully connected to Discord.'); + this.statusBarIcon.text = '$(globe) Connected to Discord'; this.statusBarIcon.tooltip = 'Connected to Discord'; setTimeout(() => (this.statusBarIcon.text = '$(globe)'), 5000); if (activityTimer) clearInterval(activityTimer); - await this.setActivity(this.config.get('workspaceElapsedTime')); + void this.setActivity(this.config.get('workspaceElapsedTime')); activityTimer = setInterval(() => { this.config = workspace.getConfiguration('discord'); void this.setActivity(this.config.get('workspaceElapsedTime')); - }, 10000); + }, 1000); - this._rpc.subscribe('ACTIVITY_SPECTATE', async ({ secret }: { secret: string }) => { + this.rpc.subscribe('ACTIVITY_SPECTATE', async ({ secret }: { secret: string }) => { const liveshare = await vsls.getApi(); if (!liveshare) return; try { @@ -104,7 +110,7 @@ export default class RPCClient implements Disposable { // Same here, this is a real nasty race condition that happens inside the discord-rpc module currently // To circumvent this we need to timeout sending the subscribe events to the discord client setTimeout(() => { - this._rpc.subscribe( + this.rpc.subscribe( 'ACTIVITY_JOIN_REQUEST', async ({ user }: { user: { username: string; discriminator: string } }) => { const val = await window.showInformationMessage( @@ -112,13 +118,13 @@ export default class RPCClient implements Disposable { { title: 'Accept' }, { title: 'Decline' }, ); - if (val && val.title === 'Accept') await this._rpc.sendJoinInvite(user); - else await this._rpc.closeJoinRequest(user); + if (val && val.title === 'Accept') await this.rpc.sendJoinInvite(user); + else await this.rpc.closeJoinRequest(user); }, ); }, 1000); setTimeout(() => { - this._rpc.subscribe('ACTIVITY_JOIN', async ({ secret }: { secret: string }) => { + this.rpc.subscribe('ACTIVITY_JOIN', async ({ secret }: { secret: string }) => { const liveshare = await vsls.getApi(); if (!liveshare) return; try { @@ -137,33 +143,28 @@ export default class RPCClient implements Disposable { const liveshare = await vsls.getApi(); if (!liveshare) return; + liveshare.onDidChangeSession(({ session }) => { - if (session.id) return this._activity.changePartyId(session.id); - return this._activity.changePartyId(); + if (session.id) return this.activity.changePartyId(session.id); + return this.activity.changePartyId(); }); liveshare.onDidChangePeers(({ added, removed }) => { - if (added.length) return this._activity.increasePartySize(added.length); - else if (removed.length) return this._activity.decreasePartySize(removed.length); + if (added.length) return this.activity.increasePartySize(added.length); + else if (removed.length) return this.activity.decreasePartySize(removed.length); }); }); - this._rpc.transport.once('close', async () => { - if (!this.config.get('enabled')) return; - await this.dispose(); - this.statusBarIcon.text = '$(plug) Reconnect to Discord'; - this.statusBarIcon.command = 'discord.reconnect'; - this.statusBarIcon.tooltip = ''; - }); - - await this._rpc.login({ clientId: this._clientId }); + try { + await this.rpc.login({ clientId: this.clientId }); + } catch (error) { + throw error; + } } - public async dispose() { - this._activity.dispose(); - try { - if (this._rpc) await this._rpc.destroy(); - } catch {} - this._rpc = null; + public dispose() { + this.activity.dispose(); + if (this.rpc) this.rpc.destroy(); + this.rpc = null; this.statusBarIcon.tooltip = ''; if (activityTimer) clearInterval(activityTimer); diff --git a/src/data/languages.json b/src/data/languages.json index 73322ef..d749782 100644 --- a/src/data/languages.json +++ b/src/data/languages.json @@ -1,1246 +1,515 @@ { - "knownLanguages": [ - "as", - "angular", - "android", - "asp", - "assembly", - "arduino", - "gruntfile", - "ahk", - "applescript", - "appveyor", - "autoit", - "babel", - "bower", - "brainfuck", - "gemfile", - "c", - "circleci", - "cargo", - "cpp", - "codeclimate", - "npm", - "nodemon", - "csharp", - "cshtml", - "clojure", - "cmake", - "coffee", - "livescript", - "crystal", - "css", - "less", - "stylus", - "scss", - "cuda", - "flowconfig", - "prisma", - "prettier", - "heroku", - "editorconfig", - "ponylang", - "jsmap", - "d", - "dart", - "denizen", - "dm", - "manifest", - "delphi", - "docker", - "ejs", - "elm", - "erlang", - "elixir", - "eslint", - "env", - "fsharp", - "git", - "go", - "godot", - "gradle", - "graphql", - "groovy", - "gulp", - "harbour", - "handlebars", - "haskell", - "html", - "hjson", - "http", - "haxe", - "ini", - "pug", - "jar", - "jest", - "java", - "julia", - "jupyter", - "js", - "jsx", - "json", - "kotlin", - "lisp", - "log", - "lua", - "makefile", - "markdown", - "markdownx", - "marko", - "nim", - "nix", - "objc", - "ocaml", - "pascal", - "pawn", - "perl", - "php", - "powershell", - "purescript", - "python", - "postcss", - "processing", - "r", - "reasonml", - "ruby", - "rust", - "scala", - "shell", - "sql", - "sqf", - "svg", - "svelte", - "swift", - "tex", - "toml", - "ts", - "tsx", - "twig", - "text", - "travis", - "typescript-def", - "v", - "vb", - "vba", - "vbhtml", - "vbproj", - "vcxproj", - "vscodeignore", - "vue", - "xml", - "yaml", - "yarn", - "bat", - "wasm", - "webpack", - "v", - "vala", - "zig" - ], - "knownExtentions": { - ".swf": { - "image": "as" - }, - ".as": { - "image": "as" - }, - ".jsfl": { - "image": "as" - }, - ".swc": { - "image": "as" - }, - "/(\\.)?angular(-cli)?\\.json/i": { - "image": "angular" - }, - "/angular.(component|guard|service|pipe|filter|directive|resolver).(ts|js)/i": { - "image": "angular" - }, - "androidmanifest.xml": { - "image": "android" - }, - ".asp": { - "image": "asp" - }, - ".asax": { - "image": "asp" - }, - ".ascx": { - "image": "asp" - }, - ".ashx": { - "image": "asp" - }, - ".asmx": { - "image": "asp" - }, - ".aspx": { - "image": "asp" - }, - ".axd": { - "image": "asp" - }, - "/\\.(l?a|[ls]?o|out|s|a51|asm|axf|elf|prx|puff|z80)$/i": { - "image": "assembly" - }, - ".agc": { - "image": "assembly" - }, - ".ko": { - "image": "assembly" - }, - ".lst": { - "image": "assembly" - }, - "/\\.((c([+px]{2}?)?-?)?objdump|bsdiff|bin|dat|pak|pdb)$/i": { - "image": "assembly" - }, - ".d-objdump": { - "image": "assembly" - }, - "/gruntfile\\.(js|coffee)/i": { - "image": "gruntfile" - }, - "/\\.gcode|\\.gco/i": { - "image": "assembly" - }, - "/\\.rpy[bc]$/i": { - "image": "assembly" - }, - "/\\.py[co]$/i": { - "image": "assembly" - }, - ".swp": { - "image": "assembly" - }, - ".DS_Store": { - "image": "assembly" - }, - ".ahk": { - "image": "ahk" - }, - ".ahkl": { - "image": "ahk" - }, - ".applescript": { - "image": "applescript" - }, - ".au3": { - "image": "autoit" - }, - "/^(\\.bowerrc|bower\\.json|Bowerfile)$/i": { - "image": "bower" - }, - "/\\.bf?$/i": { - "image": "brainfuck" - }, - "/^Gemfile(\\.lock)?$/i": { - "image": "gemfile" - }, - ".c": { - "image": "c" - }, - "/\\.c[+px]{2}$|\\.cc$/i": { - "image": "cpp" - }, - "/\\.h[+px]{2}$/i": { - "image": "cpp" - }, - "/\\.[it]pp$/i": { - "image": "cpp" - }, - "/\\.(tcc|inl)$/i": { - "image": "cpp" - }, - ".cats": { - "image": "cpp" - }, - "/(cargo.toml|cargo.lock)/i": { - "image": "cargo" - }, - "circle.yml": { - "image": "circleci" - }, - "/\\.codeclimate\\.(yml|json)/i": { - "image": "codeclimate" - }, - ".idc": { - "image": "cpp" - }, - ".w": { - "image": "cpp" - }, - "/webpack(\\.dev|\\.development|\\.prod|\\.production)?\\.config\\.js/i": { - "image": "webpack" - }, - ".nc": { - "image": "cpp" - }, - ".npmrc": { - "image": "npm" - }, - ".upc": { - "image": "cpp" - }, - ".xpm": { - "image": "cpp" - }, - ".cs": { - "image": "csharp" - }, - ".csx": { - "image": "csharp" - }, - ".cshtml": { - "image": "cshtml" - }, - ".clj": { - "image": "clojure" - }, - ".cl2": { - "image": "clojure" - }, - ".cljc": { - "image": "clojure" - }, - ".cljx": { - "image": "clojure" - }, - ".hic": { - "image": "clojure" - }, - "/\\.cljs(cm)?$/i": { - "image": "clojure" - }, - ".cmake": { - "image": "cmake" - }, - "/^CMakeLists\\.txt$/": { - "image": "cmake" - }, - ".coffee": { - "image": "coffee" - }, - ".cjsx": { - "image": "coffee" - }, - ".coffee.ecr": { - "image": "coffee" - }, - ".coffee.erb": { - "image": "coffee" - }, - ".litcoffee": { - "image": "coffee" - }, - ".ls": { - "image": "livescript" - }, - ".iced": { - "image": "coffee" - }, - "/\\.e?cr$/i": { - "image": "crystal" - }, - ".css.map": { - "image": "cssmap" - }, - ".css": { - "image": "css" - }, - ".cu": { - "image": "cuda" - }, - ".less": { - "image": "less" - }, - "/\\.(styl|stylus)$/i": { - "image": "stylus" - }, - ".scss": { - "image": "scss" - }, - ".sass": { - "image": "scss" - }, - "/\\.di?$/i": { - "image": "d" - }, - ".dart": { - "image": "dart" - }, - ".dm": { - "image": "dm" - }, - ".dme": { - "image": "dm" - }, - ".dmm": { - "image": "dm" - }, - "/\\.(h|geo|topo)$/i": { - "image": "manifest" - }, - ".cson": { - "image": "manifest" - }, - "/(\\.firebaserc|firebase\\.json)/i": { - "image": "firebase" - }, - ".json5": { - "image": "manifest" - }, - ".http": { - "image": "http" - }, - ".ndjson": { - "image": "manifest" - }, - "nodemon.json": { - "image": "nodemon" - }, - ".fea": { - "image": "manifest" - }, - ".flowconfig": { - "image": "flowconfig" - }, - ".json.eex": { - "image": "manifest" - }, - "prisma.yml": { - "image": "prisma" - }, - ".prettierignore": { - "image": "prettier" - }, - "/\\.prettier((rc)|(\\.(toml|yml|yaml|json|js))?$){2}/i": { - "image": "prettier" - }, - "prettier.config.js": { - "image": "prettier" - }, - ".proto": { - "image": "manifest" - }, - "/^procfile/i": { - "image": "heroku" - }, - ".pytb": { - "image": "manifest" - }, - ".pydeps": { - "image": "manifest" - }, - "/\\.pot?$/i": { - "image": "manifest" - }, - ".pcss": { - "image": "postcss" - }, - ".pde": { - "image": "processing" - }, - ".ejson": { - "image": "manifest" - }, - ".editorconfig": { - "image": "editorconfig" - }, - ".edn": { - "image": "manifest" - }, - ".eam.fs": { - "image": "manifest" - }, - ".qml": { - "image": "manifest" - }, - ".qbs": { - "image": "manifest" - }, - ".ston": { - "image": "manifest" - }, - ".ttl": { - "image": "manifest" - }, - ".travis.yml": { - "image": "travis" - }, - ".rest": { - "image": "http" - }, - ".rviz": { - "image": "manifest" - }, - ".syntax": { - "image": "manifest" - }, - ".webmanifest": { - "image": "manifest" - }, - "/^pkginfo$/": { - "image": "manifest" - }, - "/^mime\\.types$/i": { - "image": "manifest" - }, - "/^METADATA\\.pb$/": { - "image": "manifest" - }, - "/[\\/\\\\](?:magic[\\/\\\\]Magdir|file[\\/\\\\]magic)[\\/\\\\][-.\\w]+$/i": { - "image": "manifest" - }, - "/(\\\\|\\/)dev[-\\w]+\\1(?:[^\\\\\\/]+\\1)*(?!DESC|NOTES)(?:[A-Z][-A-Z]*)(?:\\.in)?$/": { - "image": "manifest" - }, - "lib/icons/.icondb.js": { - "image": "manifest" - }, - "/\\.git[\\/\\\\](.*[\\/\\\\])?(HEAD|ORIG_HEAD|packed-refs|logs[\\/\\\\](.+[\\/\\\\])?[^\\/\\\\]+)$/": { - "image": "manifest" - }, - "/gatsby-(browser|node|ssr|config)\\.js/i": { - "image": "gatsbyjs" - }, - ".dfm": { - "image": "delphi" - }, - ".dpr": { - "image": "delphi" - }, - "/^(Dockerfile|docker-compose)|\\.docker(file|ignore)$/i": { - "image": "docker" - }, - "/^docker-sync\\.yml$/i": { - "image": "docker" - }, - ".ejs": { - "image": "ejs" - }, - ".elm": { - "image": "elm" - }, - ".erl": { - "image": "erlang" - }, - ".beam": { - "image": "erlang" - }, - ".hrl": { - "image": "erlang" - }, - ".xrl": { - "image": "erlang" - }, - ".yrl": { - "image": "erlang" - }, - ".app.src": { - "image": "erlang" - }, - "/(\\.)?appveyor\\.yml/i": { - "image": "appveyor" - }, - "/^Emakefile$/": { - "image": "erlang" - }, - "/^rebar(\\.config)?\\.lock$/i": { - "image": "erlang" - }, - ".ex": { - "image": "elixir" - }, - "/\\.(exs|eex)$/i": { - "image": "elixir" - }, - "/^mix\\.(exs?|lock)$/i": { - "image": "elixir" - }, - ".fs": { - "image": "fsharp" - }, - ".fsi": { - "image": "fsharp" - }, - ".fsscript": { - "image": "fsharp" - }, - ".fsx": { - "image": "fsharp" - }, - "/^\\.git|^\\.keep$|\\.mailmap$/i": { - "image": "git" - }, - ".go": { - "image": "go" - }, - ".gd": { - "image": "godot" - }, - ".gradle": { - "image": "gradle" - }, - "gradlew": { - "image": "gradle" - }, - ".gql": { - "image": "graphql" - }, - ".graphql": { - "image": "graphql" - }, - "gulpfile.js": { - "image": "gulp" - }, - "/\\.(hbs|handlebars|(mu)?stache)$/i": { - "image": "handlebars" - }, - ".hs": { - "image": "haskell" - }, - ".hsc": { - "image": "haskell" - }, - ".c2hs": { - "image": "haskell" - }, - ".lhs": { - "image": "haskell" - }, - ".hjson": { - "image": "hjson" - }, - "/\\.x?html?$/i": { - "image": "html" - }, - ".hx": { - "image": "haxe" - }, - ".hxml": { - "image": "haxe" - }, - ".prg": { - "image": "harbour" - }, - ".hbp": { - "image": "harbour" - }, - ".hbc": { - "image": "harbour" - }, - ".rc": { - "image": "harbour" - }, - ".fmg": { - "image": "harbour" - }, - ".nix": { - "image": "nix" - }, - ".re": { - "image": "reasonml" - }, - ".marko": { - "image": "marko" - }, - ".pony": { - "image": "ponylang" - }, - ".groovy": { - "image": "groovy" - }, - ".gvy": { - "image": "groovy" - }, - ".gy": { - "image": "groovy" - }, - ".gsh": { - "image": "groovy" - }, - ".dsc": { - "image": "denizen" - }, - ".jade": { - "image": "pug" - }, - ".pug": { - "image": "pug" - }, - ".jar": { - "image": "jar" - }, - ".java": { - "image": "java" - }, - "/\\.(jil|jl)/i": { - "image": "julia" - }, - ".ipynb": { - "image": "jupyter" - }, - "babel.config.js": { - "image": "babel" - }, - "jest.config.js": { - "image": "jest" - }, - ".js.map": { - "image": "jsmap" - }, - ".js": { - "image": "js" - }, - ".es6": { - "image": "js" - }, - ".es": { - "image": "js" - }, - ".env": { - "image": "env" - }, - ".mjs": { - "image": "js" - }, - ".jsx": { - "image": "jsx" - }, - ".json": { - "image": "json" - }, - ".jsonc": { - "image": "json" - }, - ".kt": { - "image": "kotlin" - }, - ".ktm": { - "image": "kotlin" - }, - ".kts": { - "image": "kotlin" - }, - ".lsp": { - "image": "lisp" - }, - ".lisp": { - "image": "lisp" - }, - ".l": { - "image": "lisp" - }, - ".nl": { - "image": "lisp" - }, - ".ny": { - "image": "lisp" - }, - ".podsl": { - "image": "lisp" - }, - ".sexp": { - "image": "lisp" - }, - ".log": { - "image": "log" - }, - ".lua": { - "image": "lua" - }, - ".pd_lua": { - "image": "lua" - }, - ".rbxs": { - "image": "lua" - }, - ".wlua": { - "image": "lua" - }, - "/^Makefile/": { - "image": "makefile" - }, - "/^mk\\.config$/": { - "image": "makefile" - }, - "/\\.(mk|mak|make)$/i": { - "image": "makefile" - }, - "/^BSDmakefile$/i": { - "image": "makefile" - }, - "/^GNUmakefile$/i": { - "image": "makefile" - }, - "/^makefile\\.sco$/i": { - "image": "makefile" - }, - "/^Kbuild$/": { - "image": "makefile" - }, - "/^makefile$/": { - "image": "makefile" - }, - "/^mkfile$/i": { - "image": "makefile" - }, - "/^\\.?qmake$/i": { - "image": "makefile" - }, - "/\\.(md|mdown|markdown|mkd|mkdown|mdwn|mkdn|rmd|ron|pmd)$/i": { - "image": "markdown" - }, - ".mdx": { - "image": "markdownx" - }, - ".nim": { - "image": "nim" - }, - ".nims": { - "image": "nim" - }, - ".nimble": { - "image": "nim" - }, - "/\\.mm?$/i": { - "image": "objc" - }, - ".pch": { - "image": "objc" - }, - ".x": { - "image": "objc" - }, - ".ml": { - "image": "ocaml" - }, - ".mli": { - "image": "ocaml" - }, - ".eliom": { - "image": "ocaml" - }, - ".eliomi": { - "image": "ocaml" - }, - "/\\.(eslintrc|eslintignore)/i": { - "image": "eslint" - }, - ".ml4": { - "image": "ocaml" - }, - ".mll": { - "image": "ocaml" - }, - ".mly": { - "image": "ocaml" - }, - "/\\.pas(cal)?$/i": { - "image": "pascal" - }, - ".lpr": { - "image": "pascal" - }, - "/\\.p(er)?l$/i": { - "image": "perl" - }, - ".al": { - "image": "perl" - }, - ".ph": { - "image": "perl" - }, - ".plx": { - "image": "perl" - }, - ".pm": { - "image": "perl" - }, - "/\\.(psgi|xs)$/i": { - "image": "perl" - }, - ".pl6": { - "image": "perl" - }, - "/\\.[tp]6$|\\.6pl$/i": { - "image": "perl" - }, - "/\\.(pm6|p6m)$/i": { - "image": "perl" - }, - ".6pm": { - "image": "perl" - }, - ".nqp": { - "image": "perl" - }, - ".p6l": { - "image": "perl" - }, - ".pod6": { - "image": "perl" - }, - "/^Rexfile$/": { - "image": "perl" - }, - "/\\.php([st\\d]|_cs)?$/i": { - "image": "php" - }, - "/^Phakefile/": { - "image": "php" - }, - ".ps1": { - "image": "powershell" - }, - ".psd1": { - "image": "powershell" - }, - ".psm1": { - "image": "powershell" - }, - ".ps1xml": { - "image": "powershell" - }, - ".purs": { - "image": "purescript" - }, - ".p": { - "image": "pawn" - }, - ".inc": { - "image": "pawn" - }, - ".sma": { - "image": "pawn" - }, - ".ino": { - "image": "arduino" - }, - ".pwn": { - "image": "pawn" - }, - ".sp": { - "image": "pawn" - }, - ".py": { - "image": "python" - }, - ".ipy": { - "image": "python" - }, - ".isolate": { - "image": "python" - }, - ".pep": { - "image": "python" - }, - ".gyp": { - "image": "python" - }, - ".gypi": { - "image": "python" - }, - ".pyde": { - "image": "python" - }, - ".pyp": { - "image": "python" - }, - ".pyt": { - "image": "python" - }, - ".py3": { - "image": "python" - }, - ".pyi": { - "image": "python" - }, - ".pyw": { - "image": "python" - }, - ".tac": { - "image": "python" - }, - ".wsgi": { - "image": "python" - }, - ".xpy": { - "image": "python" - }, - ".rpy": { - "image": "python" - }, - "/\\.?(pypirc|pythonrc|python-venv)$/i": { - "image": "python" - }, - "/^(SConstruct|SConscript)$/": { - "image": "python" - }, - "/^(Snakefile|WATCHLISTS)$/": { - "image": "python" - }, - "/^wscript$/": { - "image": "python" - }, - "/\\.(r|Rprofile|rsx|rd)$/i": { - "image": "r" - }, - "/\\.(rb|ru|ruby|erb|gemspec|god|mspec|pluginspec|podspec|rabl|rake|opal)$/i": { - "image": "ruby" - }, - "/^\\.?(irbrc|gemrc|pryrc|ruby-(gemset|version))$/i": { - "image": "ruby" - }, - "/^(Appraisals|(Rake|[bB]uild|Cap|Danger|Deliver|Fast|Guard|Jar|Maven|Pod|Puppet|Snap)file(\\.lock)?)$/": { - "image": "ruby" - }, - "/\\.(jbuilder|rbuild|rb[wx]|builder)$/i": { - "image": "ruby" - }, - "/^rails$/": { - "image": "ruby" - }, - ".watchr": { - "image": "ruby" - }, - ".rs": { - "image": "rust" - }, - "/\\.(sc|scala)$/i": { - "image": "scala" - }, - "/\\.(sh|rc|bats|bash|tool|install|command)$/i": { - "image": "shell" - }, - "/^(\\.?bash(rc|[-_]?(profile|login|logout|history|prompt))|_osc|config|install-sh|PKGBUILD)$/i": { - "image": "shell" - }, - "/\\.(ksh|mksh|pdksh)$/i": { - "image": "shell" - }, - ".sh-session": { - "image": "shell" - }, - "/\\.zsh(-theme|_history)?$|^\\.?(antigen|zpreztorc|zlogin|zlogout|zprofile|zshenv|zshrc)$/i": { - "image": "shell" - }, - "/\\.fish$|^\\.fishrc$/i": { - "image": "shell" - }, - "/^\\.?(login|profile)$/": { - "image": "shell" - }, - ".inputrc": { - "image": "shell" - }, - ".tmux": { - "image": "shell" - }, - "/^(configure|config\\.(guess|rpath|status|sub)|depcomp|libtool|compile)$/": { - "image": "shell" - }, - "/^\\/(private\\/)?etc\\/([^\\/]+\\/)*(profile$|nanorc$|rc\\.|csh\\.)/i": { - "image": "shell" - }, - "/^\\.?cshrc$/i": { - "image": "shell" - }, - ".profile": { - "image": "shell" - }, - ".tcsh": { - "image": "shell" - }, - ".csh": { - "image": "shell" - }, - "/\\.(my)?sql$/i": { - "image": "sql" - }, - ".ddl": { - "image": "sql" - }, - ".udf": { - "image": "sql" - }, - ".hql": { - "image": "sql" - }, - ".viw": { - "image": "sql" - }, - ".prc": { - "image": "sql" - }, - ".cql": { - "image": "sql" - }, - ".db2": { - "image": "sql" - }, - ".sqf": { - "image": "sqf" - }, - ".svg": { - "image": "svg" - }, - ".svelte": { - "image": "svelte" - }, - ".swift": { - "image": "swift" - }, - ".tex": { - "image": "tex" - }, - ".ltx": { - "image": "tex" - }, - ".aux": { - "image": "tex" - }, - ".sty": { - "image": "tex" - }, - ".dtx": { - "image": "tex" - }, - ".cls": { - "image": "tex" - }, - ".ins": { - "image": "tex" - }, - ".lbx": { - "image": "tex" - }, - ".mkiv": { - "image": "tex" - }, - ".mkvi": { - "image": "tex" - }, - ".mkii": { - "image": "tex" - }, - ".texi": { - "image": "tex" - }, - "heroku.yml": { - "image": "heroku" - }, - "/^hyphen(ex)?\\.(cs|den|det|fr|sv|us)$/": { - "image": "tex" - }, - ".toml": { - "image": "toml" - }, - "/.*\\.d\\.ts/i": { - "image": "typescript-def" - }, - ".ts": { - "image": "ts" - }, - ".tsx": { - "image": "tsx" - }, - ".twig": { - "image": "twig" - }, - "/\\.te?xt$/i": { - "image": "text" - }, - ".rtf": { - "image": "text" - }, - "/\\.i?nfo$/i": { - "image": "text" - }, - ".msg": { - "image": "text" - }, - "/\\.(utxt|utf8)$/i": { - "image": "text" - }, - ".vb": { - "image": "vb" - }, - ".vbs": { - "image": "vb" - }, - ".vba": { - "image": "vba" - }, - ".vbhtml": { - "image": "vb" - }, - ".vbproj": { - "image": "vb" - }, - ".vcxproj": { - "image": "vcxproj" - }, - ".vscodeignore": { - "image": "vscodeignore" - }, - ".vue": { - "image": "vue" - }, - ".xml": { - "image": "xml" - }, - "/\\.ya?ml$/i": { - "image": "yaml" - }, - "/^yarn(\\.lock)?$/i": { - "image": "yarn" - }, - ".yarnrc": { - "image": "yarn" - }, - "/\\.babelrc/i": { - "image": "babel" - }, - ".bat": { - "image": "bat" - }, - ".batch": { - "image": "bat" - }, - ".cmd": { - "image": "bat" - }, - "/\\.(exe|com|msi)$/i": { - "image": "bat" - }, - ".reg": { - "image": "bat" - }, - ".wat": { - "image": "wasm" - }, - ".wast": { - "image": "wasm" - }, - ".wasm": { - "image": "wasm" - }, - ".v": { - "image": "v" - }, - ".vh": { - "image": "v" - }, - ".vala": { - "image": "vala" - }, - ".vapi": { - "image": "vala" - }, - ".zig": { - "image": "zig" - } - } + "knownLanguages": [ + "ahk", + "android", + "angular", + "applescript", + "appveyor", + "arduino", + "as", + "asp", + "assembly", + "autoit", + "babel", + "bat", + "bower", + "brainfuck", + "c", + "cargo", + "circleci", + "clojure", + "cmake", + "codeclimate", + "coffee", + "cpp", + "crystal", + "csharp", + "cshtml", + "css", + "cuda", + "d", + "dart", + "delphi", + "denizen", + "dm", + "docker", + "editorconfig", + "ejs", + "elixir", + "elm", + "env", + "erlang", + "eslint", + "flowconfig", + "fsharp", + "gemfile", + "git", + "go", + "godot", + "gradle", + "graphql", + "groovy", + "gruntfile", + "gulp", + "handlebars", + "harbour", + "haskell", + "haxe", + "heroku", + "hjson", + "html", + "http", + "ini", + "jar", + "java", + "jest", + "js", + "jsmap", + "json", + "jsx", + "julia", + "jupyter", + "kotlin", + "less", + "lisp", + "livescript", + "log", + "lua", + "makefile", + "manifest", + "markdown", + "markdownx", + "marko", + "nim", + "nix", + "nodemon", + "npm", + "objc", + "ocaml", + "pascal", + "pawn", + "perl", + "php", + "ponylang", + "postcss", + "powershell", + "prettier", + "prisma", + "processing", + "pug", + "purescript", + "python", + "r", + "reasonml", + "ruby", + "rust", + "scala", + "scss", + "shell", + "sqf", + "sql", + "stylus", + "svelte", + "svg", + "swift", + "tex", + "text", + "toml", + "travis", + "ts", + "tsx", + "twig", + "typescript-def", + "v", + "v", + "vala", + "vb", + "vba", + "vbhtml", + "vbproj", + "vcxproj", + "vscodeignore", + "vue", + "wasm", + "webpack", + "xml", + "yaml", + "yarn", + "zig" + ], + "knownExtentions": { + ".ahk": { "image": "ahk" }, + ".ahkl": { "image": "ahk" }, + "androidmanifest.xml": { "image": "android" }, + "/^angular[^.]*\\.js$/i": { "image": "angular" }, + ".applescript": { "image": "applescript" }, + "/(\\.)?appveyor\\.yml/i": { "image": "appveyor" }, + ".ino": { "image": "arduino" }, + ".swf": { "image": "as" }, + ".as": { "image": "as" }, + ".jsfl": { "image": "as" }, + ".swc": { "image": "as" }, + ".asp": { "image": "asp" }, + ".asax": { "image": "asp" }, + ".ascx": { "image": "asp" }, + ".ashx": { "image": "asp" }, + ".asmx": { "image": "asp" }, + ".aspx": { "image": "asp" }, + ".axd": { "image": "asp" }, + "/\\.(l?a|[ls]?o|out|s|a51|asm|axf|elf|prx|puff|z80)$/i": { "image": "assembly" }, + ".agc": { "image": "assembly" }, + ".ko": { "image": "assembly" }, + ".lst": { "image": "assembly" }, + "/\\.((c([+px]{2}?)?-?)?objdump|bsdiff|bin|dat|pak|pdb)$/i": { "image": "assembly" }, + ".d-objdump": { "image": "assembly" }, + "/\\.gcode|\\.gco/i": { "image": "assembly" }, + "/\\.rpy[bc]$/i": { "image": "assembly" }, + "/\\.py[co]$/i": { "image": "assembly" }, + ".swp": { "image": "assembly" }, + ".DS_Store": { "image": "assembly" }, + ".au3": { "image": "autoit" }, + "babel.config.js": { "image": "babel" }, + "/\\.babelrc/i": { "image": "babel" }, + ".bat": { "image": "bat" }, + ".batch": { "image": "bat" }, + ".cmd": { "image": "bat" }, + "/\\.(exe|com|msi)$/i": { "image": "bat" }, + ".reg": { "image": "bat" }, + "/^(\\.bowerrc|bower\\.json|Bowerfile)$/i": { "image": "bower" }, + "/\\.bf?$/i": { "image": "brainfuck" }, + "/\\.c$/i": { "image": "c" }, + "/(cargo.toml|cargo.lock)/i": { "image": "cargo" }, + "circle.yml": { "image": "circleci" }, + ".clj": { "image": "clojure" }, + ".cl2": { "image": "clojure" }, + ".cljc": { "image": "clojure" }, + ".cljx": { "image": "clojure" }, + ".hic": { "image": "clojure" }, + "/\\.cljs(cm)?$/i": { "image": "clojure" }, + ".cmake": { "image": "cmake" }, + "/^CMakeLists\\.txt$/": { "image": "cmake" }, + "/\\.codeclimate\\.(yml|json)/i": { "image": "codeclimate" }, + ".coffee": { "image": "coffee" }, + ".cjsx": { "image": "coffee" }, + ".coffee.ecr": { "image": "coffee" }, + ".coffee.erb": { "image": "coffee" }, + ".litcoffee": { "image": "coffee" }, + ".iced": { "image": "coffee" }, + "/\\.c[+px]{2}$|\\.cc$/i": { "image": "cpp" }, + "/\\.h[+px]{2}$/i": { "image": "cpp" }, + "/\\.[it]pp$/i": { "image": "cpp" }, + "/\\.(tcc|inl)$/i": { "image": "cpp" }, + ".cats": { "image": "cpp" }, + ".idc": { "image": "cpp" }, + ".w": { "image": "cpp" }, + ".nc": { "image": "cpp" }, + ".upc": { "image": "cpp" }, + ".xpm": { "image": "cpp" }, + "/\\.e?cr$/i": { "image": "crystal" }, + ".cs": { "image": "csharp" }, + ".csx": { "image": "csharp" }, + ".cshtml": { "image": "cshtml" }, + ".css": { "image": "css" }, + ".css.map": { "image": "cssmap" }, + ".cu": { "image": "cuda" }, + "/\\.di?$/i": { "image": "d" }, + ".dart": { "image": "dart" }, + ".dfm": { "image": "delphi" }, + ".dpr": { "image": "delphi" }, + ".dsc": { "image": "denizen" }, + ".dm": { "image": "dm" }, + ".dme": { "image": "dm" }, + ".dmm": { "image": "dm" }, + "/^(Dockerfile|docker-compose)|\\.docker(file|ignore)$/i": { "image": "docker" }, + "/^docker-sync\\.yml$/i": { "image": "docker" }, + ".editorconfig": { "image": "editorconfig" }, + ".ejs": { "image": "ejs" }, + ".ex": { "image": "elixir" }, + "/\\.(exs|eex)$/i": { "image": "elixir" }, + "/^mix\\.(exs?|lock)$/i": { "image": "elixir" }, + ".elm": { "image": "elm" }, + ".env": { "image": "env" }, + ".erl": { "image": "erlang" }, + ".beam": { "image": "erlang" }, + ".hrl": { "image": "erlang" }, + ".xrl": { "image": "erlang" }, + ".yrl": { "image": "erlang" }, + ".app.src": { "image": "erlang" }, + "/^Emakefile$/": { "image": "erlang" }, + "/^rebar(\\.config)?\\.lock$/i": { "image": "erlang" }, + "/\\.(eslintrc|eslintignore)/i": { "image": "eslint" }, + "/(\\.firebaserc|firebase\\.json)/i": { "image": "firebase" }, + ".flowconfig": { "image": "flowconfig" }, + ".fs": { "image": "fsharp" }, + ".fsi": { "image": "fsharp" }, + ".fsscript": { "image": "fsharp" }, + ".fsx": { "image": "fsharp" }, + "/gatsby-(browser|node|ssr|config)\\.js/i": { "image": "gatsbyjs" }, + "/^Gemfile(\\.lock)?$/i": { "image": "gemfile" }, + "/^\\.git|^\\.keep$|\\.mailmap$/i": { "image": "git" }, + ".go": { "image": "go" }, + ".gd": { "image": "godot" }, + ".gradle": { "image": "gradle" }, + "gradlew": { "image": "gradle" }, + ".gql": { "image": "graphql" }, + ".graphql": { "image": "graphql" }, + ".groovy": { "image": "groovy" }, + ".gvy": { "image": "groovy" }, + ".gy": { "image": "groovy" }, + ".gsh": { "image": "groovy" }, + "/gruntfile\\.(js|coffee)/i": { "image": "gruntfile" }, + "gulpfile.js": { "image": "gulp" }, + "/\\.(hbs|handlebars|(mu)?stache)$/i": { "image": "handlebars" }, + ".prg": { "image": "harbour" }, + ".hbp": { "image": "harbour" }, + ".hbc": { "image": "harbour" }, + ".rc": { "image": "harbour" }, + ".fmg": { "image": "harbour" }, + ".hs": { "image": "haskell" }, + ".hsc": { "image": "haskell" }, + ".c2hs": { "image": "haskell" }, + ".lhs": { "image": "haskell" }, + ".hx": { "image": "haxe" }, + ".hxml": { "image": "haxe" }, + "/^procfile/i": { "image": "heroku" }, + "heroku.yml": { "image": "heroku" }, + ".hjson": { "image": "hjson" }, + "/\\.x?html?$/i": { "image": "html" }, + ".http": { "image": "http" }, + ".rest": { "image": "http" }, + ".jar": { "image": "jar" }, + ".java": { "image": "java" }, + "jest.config.js": { "image": "jest" }, + ".js": { "image": "js" }, + ".es6": { "image": "js" }, + ".es": { "image": "js" }, + ".mjs": { "image": "js" }, + ".js.map": { "image": "jsmap" }, + ".json": { "image": "json" }, + ".jsonc": { "image": "json" }, + ".jsx": { "image": "jsx" }, + "/\\.(jil|jl)/i": { "image": "julia" }, + ".ipynb": { "image": "jupyter" }, + ".kt": { "image": "kotlin" }, + ".ktm": { "image": "kotlin" }, + ".kts": { "image": "kotlin" }, + ".less": { "image": "less" }, + ".lsp": { "image": "lisp" }, + ".lisp": { "image": "lisp" }, + ".l": { "image": "lisp" }, + ".nl": { "image": "lisp" }, + ".ny": { "image": "lisp" }, + ".podsl": { "image": "lisp" }, + ".sexp": { "image": "lisp" }, + ".ls": { "image": "livescript" }, + ".log": { "image": "log" }, + ".lua": { "image": "lua" }, + ".pd_lua": { "image": "lua" }, + ".rbxs": { "image": "lua" }, + ".wlua": { "image": "lua" }, + "/^Makefile/": { "image": "makefile" }, + "/^mk\\.config$/": { "image": "makefile" }, + "/\\.(mk|mak|make)$/i": { "image": "makefile" }, + "/^BSDmakefile$/i": { "image": "makefile" }, + "/^GNUmakefile$/i": { "image": "makefile" }, + "/^makefile\\.sco$/i": { "image": "makefile" }, + "/^Kbuild$/": { "image": "makefile" }, + "/^makefile$/": { "image": "makefile" }, + "/^mkfile$/i": { "image": "makefile" }, + "/^\\.?qmake$/i": { "image": "makefile" }, + "/\\.(h|geo|topo)$/i": { "image": "manifest" }, + ".cson": { "image": "manifest" }, + ".json5": { "image": "manifest" }, + ".ndjson": { "image": "manifest" }, + ".fea": { "image": "manifest" }, + ".json.eex": { "image": "manifest" }, + ".proto": { "image": "manifest" }, + ".pytb": { "image": "manifest" }, + ".pydeps": { "image": "manifest" }, + "/\\.pot?$/i": { "image": "manifest" }, + ".ejson": { "image": "manifest" }, + ".edn": { "image": "manifest" }, + ".eam.fs": { "image": "manifest" }, + ".qml": { "image": "manifest" }, + ".qbs": { "image": "manifest" }, + ".ston": { "image": "manifest" }, + ".ttl": { "image": "manifest" }, + ".rviz": { "image": "manifest" }, + ".syntax": { "image": "manifest" }, + ".webmanifest": { "image": "manifest" }, + "/^pkginfo$/": { "image": "manifest" }, + "/^mime\\.types$/i": { "image": "manifest" }, + "/^METADATA\\.pb$/": { "image": "manifest" }, + "/[\\/\\\\](?:magic[\\/\\\\]Magdir|file[\\/\\\\]magic)[\\/\\\\][-.\\w]+$/i": { "image": "manifest" }, + "/(\\\\|\\/)dev[-\\w]+\\1(?:[^\\\\\\/]+\\1)*(?!DESC|NOTES)(?:[A-Z][-A-Z]*)(?:\\.in)?$/": { "image": "manifest" }, + "lib/icons/.icondb.js": { "image": "manifest" }, + "/\\.git[\\/\\\\](.*[\\/\\\\])?(HEAD|ORIG_HEAD|packed-refs|logs[\\/\\\\](.+[\\/\\\\])?[^\\/\\\\]+)$/": { + "image": "manifest" + }, + "/\\.(md|mdown|markdown|mkd|mkdown|mdwn|mkdn|rmd|ron|pmd)$/i": { "image": "markdown" }, + ".mdx": { "image": "markdownx" }, + ".marko": { "image": "marko" }, + ".nim": { "image": "nim" }, + ".nims": { "image": "nim" }, + ".nimble": { "image": "nim" }, + ".nix": { "image": "nix" }, + "nodemon.json": { "image": "nodemon" }, + ".npmrc": { "image": "npm" }, + "/\\.mm?$/i": { "image": "objc" }, + ".pch": { "image": "objc" }, + ".x": { "image": "objc" }, + ".ml": { "image": "ocaml" }, + ".mli": { "image": "ocaml" }, + ".eliom": { "image": "ocaml" }, + ".eliomi": { "image": "ocaml" }, + ".ml4": { "image": "ocaml" }, + ".mll": { "image": "ocaml" }, + ".mly": { "image": "ocaml" }, + "/\\.pas(cal)?$/i": { "image": "pascal" }, + ".lpr": { "image": "pascal" }, + ".p": { "image": "pawn" }, + ".inc": { "image": "pawn" }, + ".sma": { "image": "pawn" }, + ".pwn": { "image": "pawn" }, + ".sp": { "image": "pawn" }, + "/\\.p(er)?l$/i": { "image": "perl" }, + ".al": { "image": "perl" }, + ".ph": { "image": "perl" }, + ".plx": { "image": "perl" }, + ".pm": { "image": "perl" }, + "/\\.(psgi|xs)$/i": { "image": "perl" }, + ".pl6": { "image": "perl" }, + "/\\.[tp]6$|\\.6pl$/i": { "image": "perl" }, + "/\\.(pm6|p6m)$/i": { "image": "perl" }, + ".6pm": { "image": "perl" }, + ".nqp": { "image": "perl" }, + ".p6l": { "image": "perl" }, + ".pod6": { "image": "perl" }, + "/^Rexfile$/": { "image": "perl" }, + "/\\.php([st\\d]|_cs)?$/i": { "image": "php" }, + "/^Phakefile/": { "image": "php" }, + ".pony": { "image": "ponylang" }, + ".pcss": { "image": "postcss" }, + ".ps1": { "image": "powershell" }, + ".psd1": { "image": "powershell" }, + ".psm1": { "image": "powershell" }, + ".ps1xml": { "image": "powershell" }, + ".prettierignore": { "image": "prettier" }, + "/\\.prettier((rc)|(\\.(toml|yml|yaml|json|js))?$){2}/i": { "image": "prettier" }, + "prettier.config.js": { "image": "prettier" }, + "prisma.yml": { "image": "prisma" }, + ".pde": { "image": "processing" }, + ".jade": { "image": "pug" }, + ".pug": { "image": "pug" }, + ".purs": { "image": "purescript" }, + ".py": { "image": "python" }, + ".ipy": { "image": "python" }, + ".isolate": { "image": "python" }, + ".pep": { "image": "python" }, + ".gyp": { "image": "python" }, + ".gypi": { "image": "python" }, + ".pyde": { "image": "python" }, + ".pyp": { "image": "python" }, + ".pyt": { "image": "python" }, + ".py3": { "image": "python" }, + ".pyi": { "image": "python" }, + ".pyw": { "image": "python" }, + ".tac": { "image": "python" }, + ".wsgi": { "image": "python" }, + ".xpy": { "image": "python" }, + ".rpy": { "image": "python" }, + "/\\.?(pypirc|pythonrc|python-venv)$/i": { "image": "python" }, + "/^(SConstruct|SConscript)$/": { "image": "python" }, + "/^(Snakefile|WATCHLISTS)$/": { "image": "python" }, + "/^wscript$/": { "image": "python" }, + "/\\.(r|Rprofile|rsx|rd)$/i": { "image": "r" }, + ".re": { "image": "reasonml" }, + "/\\.(rb|ru|ruby|erb|gemspec|god|mspec|pluginspec|podspec|rabl|rake|opal)$/i": { "image": "ruby" }, + "/^\\.?(irbrc|gemrc|pryrc|ruby-(gemset|version))$/i": { "image": "ruby" }, + "/^(Appraisals|(Rake|[bB]uild|Cap|Danger|Deliver|Fast|Guard|Jar|Maven|Pod|Puppet|Snap)file(\\.lock)?)$/": { + "image": "ruby" + }, + "/\\.(jbuilder|rbuild|rb[wx]|builder)$/i": { "image": "ruby" }, + "/^rails$/": { "image": "ruby" }, + ".watchr": { "image": "ruby" }, + ".rs": { "image": "rust" }, + "/\\.(sc|scala)$/i": { "image": "scala" }, + ".scss": { "image": "scss" }, + ".sass": { "image": "scss" }, + "/\\.(sh|rc|bats|bash|tool|install|command)$/i": { "image": "shell" }, + "/^(\\.?bash(rc|[-_]?(profile|login|logout|history|prompt))|_osc|config|install-sh|PKGBUILD)$/i": { + "image": "shell" + }, + "/\\.(ksh|mksh|pdksh)$/i": { "image": "shell" }, + ".sh-session": { "image": "shell" }, + "/\\.zsh(-theme|_history)?$|^\\.?(antigen|zpreztorc|zlogin|zlogout|zprofile|zshenv|zshrc)$/i": { "image": "shell" }, + "/\\.fish$|^\\.fishrc$/i": { "image": "shell" }, + "/^\\.?(login|profile)$/": { "image": "shell" }, + ".inputrc": { "image": "shell" }, + ".tmux": { "image": "shell" }, + "/^(configure|config\\.(guess|rpath|status|sub)|depcomp|libtool|compile)$/": { "image": "shell" }, + "/^\\/(private\\/)?etc\\/([^\\/]+\\/)*(profile$|nanorc$|rc\\.|csh\\.)/i": { "image": "shell" }, + "/^\\.?cshrc$/i": { "image": "shell" }, + ".profile": { "image": "shell" }, + ".tcsh": { "image": "shell" }, + ".csh": { "image": "shell" }, + ".sqf": { "image": "sqf" }, + "/\\.(my)?sql$/i": { "image": "sql" }, + ".ddl": { "image": "sql" }, + ".udf": { "image": "sql" }, + ".hql": { "image": "sql" }, + ".viw": { "image": "sql" }, + ".prc": { "image": "sql" }, + ".cql": { "image": "sql" }, + ".db2": { "image": "sql" }, + "/\\.(styl|stylus)$/i": { "image": "stylus" }, + ".svelte": { "image": "svelte" }, + ".svg": { "image": "svg" }, + ".swift": { "image": "swift" }, + ".tex": { "image": "tex" }, + ".ltx": { "image": "tex" }, + ".aux": { "image": "tex" }, + ".sty": { "image": "tex" }, + ".dtx": { "image": "tex" }, + ".cls": { "image": "tex" }, + ".ins": { "image": "tex" }, + ".lbx": { "image": "tex" }, + ".mkiv": { "image": "tex" }, + ".mkvi": { "image": "tex" }, + ".mkii": { "image": "tex" }, + ".texi": { "image": "tex" }, + "/^hyphen(ex)?\\.(cs|den|det|fr|sv|us)$/": { "image": "tex" }, + "/\\.te?xt$/i": { "image": "text" }, + ".rtf": { "image": "text" }, + "/\\.i?nfo$/i": { "image": "text" }, + ".msg": { "image": "text" }, + "/\\.(utxt|utf8)$/i": { "image": "text" }, + ".toml": { "image": "toml" }, + ".travis.yml": { "image": "travis" }, + ".ts": { "image": "ts" }, + ".tsx": { "image": "tsx" }, + ".twig": { "image": "twig" }, + "/.*\\.d\\.ts/i": { "image": "typescript-def" }, + ".v": { "image": "v" }, + ".vh": { "image": "v" }, + ".vala": { "image": "vala" }, + ".vapi": { "image": "vala" }, + ".vb": { "image": "vb" }, + ".vbs": { "image": "vb" }, + ".vbhtml": { "image": "vb" }, + ".vbproj": { "image": "vb" }, + ".vba": { "image": "vba" }, + ".vcxproj": { "image": "vcxproj" }, + ".vscodeignore": { "image": "vscodeignore" }, + ".vue": { "image": "vue" }, + ".wat": { "image": "wasm" }, + ".wast": { "image": "wasm" }, + ".wasm": { "image": "wasm" }, + "/webpack(\\.dev|\\.development|\\.prod|\\.production)?\\.config\\.js/i": { "image": "webpack" }, + ".xml": { "image": "xml" }, + "/\\.ya?ml$/i": { "image": "yaml" }, + "/^yarn(\\.lock)?$/i": { "image": "yarn" }, + ".yarnrc": { "image": "yarn" }, + ".zig": { "image": "zig" } + } } diff --git a/src/extension.ts b/src/extension.ts index ea5644e..2e6d013 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -31,27 +31,25 @@ export async function activate(context: ExtensionContext) { } } - const enabler = commands.registerCommand('discord.enable', async () => { - await rpc.dispose(); + const enabler = commands.registerCommand('discord.enable', () => { + rpc.dispose(); void config.update('enabled', true); rpc.config = workspace.getConfiguration('discord'); rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...'; rpc.statusBarIcon.show(); - await rpc.login(); + void rpc.login(); void window.showInformationMessage('Enabled Discord Rich Presence for this workspace.'); }); - - const disabler = commands.registerCommand('discord.disable', async () => { + const disabler = commands.registerCommand('discord.disable', () => { void config.update('enabled', false); rpc.config = workspace.getConfiguration('discord'); - await rpc.dispose(); + rpc.dispose(); rpc.statusBarIcon.hide(); void window.showInformationMessage('Disabled Discord Rich Presence for this workspace.'); }); - - const reconnecter = commands.registerCommand('discord.reconnect', async () => { + const reconnecter = commands.registerCommand('discord.reconnect', () => { if (loginTimeout) clearTimeout(loginTimeout); - await rpc.dispose(); + rpc.dispose(); loginTimeout = setTimeout(() => { void rpc.login(); if (!config.get('silent')) void window.showInformationMessage('Reconnecting to Discord RPC...'); @@ -59,28 +57,15 @@ export async function activate(context: ExtensionContext) { rpc.statusBarIcon.command = 'discord.reconnect'; }, 1000); }); - - const disconnect = commands.registerCommand('discord.disconnect', async () => { - await rpc.dispose(); + const disconnect = commands.registerCommand('discord.disconnect', () => { + rpc.dispose(); rpc.statusBarIcon.text = '$(pulse) Reconnect to Discord'; rpc.statusBarIcon.command = 'discord.reconnect'; }); - - const allowSpectate = commands.registerCommand('discord.allowSpectate', async () => { - await rpc.allowSpectate(); - }); - - const disableSpectate = commands.registerCommand('discord.disableSpectate', async () => { - await rpc.disableSpectate(); - }); - - const allowJoinRequests = commands.registerCommand('discord.allowJoinRequests', async () => { - await rpc.allowJoinRequests(); - }); - - const disableJoinRequests = commands.registerCommand('discord.disableJoinRequests', async () => { - await rpc.disableJoinRequests(); - }); + const allowSpectate = commands.registerCommand('discord.allowSpectate', () => rpc.allowSpectate()); + const disableSpectate = commands.registerCommand('discord.disableSpectate', () => rpc.disableSpectate()); + const allowJoinRequests = commands.registerCommand('discord.allowJoinRequests', () => rpc.allowJoinRequests()); + const disableJoinRequests = commands.registerCommand('discord.disableJoinRequests', () => rpc.disableJoinRequests()); context.subscriptions.push( enabler, @@ -93,22 +78,13 @@ export async function activate(context: ExtensionContext) { disableJoinRequests, ); - setTimeout(() => { - const gitExtension = extensions.getExtension('vscode.git'); - if (gitExtension) { - if (gitExtension.isActive) { - rpc.git = gitExtension.exports.getAPI(1); - } - } - }, 5000); - if (!isWorkspaceExcluded && config.get('enabled')) { statusBarIcon.show(); try { await rpc.login(); } catch (error) { Logger.log(`Encountered following error after trying to login:\n${error as string}`); - await rpc.dispose(); + rpc.dispose(); if (!config.get('silent')) { if (error?.message?.includes('ENOENT')) void window.showErrorMessage('No Discord Client detected!'); else void window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error as string}`); @@ -117,10 +93,20 @@ export async function activate(context: ExtensionContext) { rpc.statusBarIcon.command = 'discord.reconnect'; } } + + const gitExtension = extensions.getExtension('vscode.git'); + if (gitExtension) { + if (gitExtension.isActive) { + rpc.git = gitExtension.exports.getAPI(1); + } else { + const extension = await gitExtension.activate(); + rpc.git = extension.getAPI(1); + } + } } -export async function deactivate() { - await rpc.dispose(); +export function deactivate() { + rpc.dispose(); } process.on('unhandledRejection', (err) => Logger.log(err as string)); diff --git a/src/structures/Activity.ts b/src/structures/Activity.ts index 0f5f45d..21179ca 100644 --- a/src/structures/Activity.ts +++ b/src/structures/Activity.ts @@ -2,7 +2,7 @@ import { basename, parse, sep } from 'path'; import { debug, Disposable, env, window, workspace } from 'vscode'; import * as vsls from 'vsls'; import RPCClient from '../client/RPCClient'; -const lang = require('../data/languages.json'); // eslint-disable-line +import lang from '../data/languages.json'; const knownExtentions: { [key: string]: { image: string } } = lang.knownExtentions; const knownLanguages: string[] = lang.knownLanguages; @@ -39,10 +39,9 @@ interface FileDetail { export default class Activity implements Disposable { private _state: State | null = null; - private _lastKnownFile = ''; + private lastKnownFile = ''; - // eslint-disable-next-line no-useless-constructor - public constructor(public client: RPCClient) {} + public constructor(private readonly client: RPCClient) {} public get state() { return this._state; @@ -52,7 +51,7 @@ export default class Activity implements Disposable { let largeImageKey: any = 'vscode-big'; if (window.activeTextEditor) { if (window.activeTextEditor.document.languageId === 'Log') return this._state; - if (this._state && window.activeTextEditor.document.fileName === this._lastKnownFile) { + if (this._state && window.activeTextEditor.document.fileName === this.lastKnownFile) { return (this._state = { ...this._state, details: await this._generateDetails( @@ -74,7 +73,7 @@ export default class Activity implements Disposable { ), }); } - this._lastKnownFile = window.activeTextEditor.document.fileName; + this.lastKnownFile = window.activeTextEditor.document.fileName; const filename = basename(window.activeTextEditor.document.fileName); largeImageKey = // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition @@ -238,7 +237,7 @@ export default class Activity implements Disposable { public dispose() { this._state = null; - this._lastKnownFile = ''; + this.lastKnownFile = ''; } private async _generateDetails(debugging: string, editing: string, idling: string, largeImageKey: any) { diff --git a/src/structures/Logger.ts b/src/structures/Logger.ts index a682bf3..bbe244e 100644 --- a/src/structures/Logger.ts +++ b/src/structures/Logger.ts @@ -2,14 +2,12 @@ import { OutputChannel, window } from 'vscode'; // eslint-disable-next-line export default class Logger { - private static _output?: OutputChannel; - - private static _setup() { - this._output = this._output ?? window.createOutputChannel('Discord Presence'); - } + private static output?: OutputChannel; public static log(message: string) { - if (!this._output) this._setup(); - this._output?.appendLine(message); + if (!this.output) { + this.output = window.createOutputChannel('Discord Presence'); + } + this.output.appendLine(message); } } diff --git a/tsconfig.json b/tsconfig.json index e5b92d8..8792116 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,25 @@ { "compilerOptions": { "strict": true, - "module": "commonjs", - "target": "es2017", - "lib": [ - "esnext", - "esnext.array", - "esnext.asynciterable", - "esnext.intl", - "esnext.symbol" - ], - "rootDir": "src", - "outDir": "dist", + "moduleResolution": "node", "declaration": false, - "sourceMap": true, "removeComments": false, - "experimentalDecorators": true + "alwaysStrict": true, + "pretty": true, + "target": "es2017", + "module": "commonjs", + "lib": [ + "esnext" + ], + "outDir": "dist", + "sourceRoot": "./", + "sourceMap": true, + "inlineSources": true, + "incremental": true, + "noEmitHelpers": true, + "importHelpers": true, + "skipLibCheck": true, + "esModuleInterop": true, + "resolveJsonModule": true } }