mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
refactor: misc. changes
This commit is contained in:
parent
00edf0e60f
commit
04ae33e2b9
21 changed files with 67 additions and 51 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"editor.formatOnSave": true,
|
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
"@types/diff": "^5.2.1",
|
"@types/diff": "^5.2.1",
|
||||||
"@types/html-minifier-terser": "^7.0.2",
|
"@types/html-minifier-terser": "^7.0.2",
|
||||||
"@types/lodash": "~4.17.7",
|
"@types/lodash": "~4.17.7",
|
||||||
"@types/node": "^18.19.42",
|
"@types/node": "^18.19.43",
|
||||||
"@types/react": "~18.2.79",
|
"@types/react": "~18.2.79",
|
||||||
"@types/react-dom": "~18.2.25",
|
"@types/react-dom": "~18.2.25",
|
||||||
"@types/yazl": "^2.4.5",
|
"@types/yazl": "^2.4.5",
|
||||||
|
|
|
@ -168,6 +168,7 @@ export default tseslint.config(
|
||||||
ignores: ["src/**"],
|
ignores: ["src/**"],
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
||||||
|
"unicorn/prefer-node-protocol": "error",
|
||||||
"simple-import-sort/imports": ["error", {
|
"simple-import-sort/imports": ["error", {
|
||||||
groups: [
|
groups: [
|
||||||
["^((node:)?(assert(/strict)?|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns(/promises)?|domain|events|fs(/promises)?|http|http2|https|module|net|os|path(/(posix|win32))?|perf_hooks|process|punycode|querystring|readline(/promises)?|repl|stream(/(consumers|promises|web))?|string_decoder|timers(/promises)?|tls|trace_events|tty|url|util(/types)?|v8|vm|wasi|worker_threads|zlib)|node:test(/reporters)?)$"],
|
["^((node:)?(assert(/strict)?|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns(/promises)?|domain|events|fs(/promises)?|http|http2|https|module|net|os|path(/(posix|win32))?|perf_hooks|process|punycode|querystring|readline(/promises)?|repl|stream(/(consumers|promises|web))?|string_decoder|timers(/promises)?|tls|trace_events|tty|url|util(/types)?|v8|vm|wasi|worker_threads|zlib)|node:test(/reporters)?)$"],
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@stylistic/eslint-plugin": "^2.6.1",
|
"@stylistic/eslint-plugin": "^2.6.1",
|
||||||
"@types/node": "^20.14.13",
|
"@types/node": "^20.14.14",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@typescript-eslint/typescript-estree": "^8.0.0",
|
"@typescript-eslint/typescript-estree": "^8.0.0",
|
||||||
"eslint": "^9.8.0",
|
"eslint": "^9.8.0",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { join } from "path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import type { CR } from "./types.mts";
|
import type { CR } from "./types.mts";
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "node:fs";
|
||||||
import { join } from "path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import puppeteer from "puppeteer-core";
|
import puppeteer from "puppeteer-core";
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { writeFile } from "fs/promises";
|
import { writeFile } from "node:fs/promises";
|
||||||
|
|
||||||
import type { CR } from "../types.mts";
|
import type { CR } from "../types.mts";
|
||||||
import { capitalize, codeBlock, formatChannel, formatEnumEntryList, formatKeyList, formatWarnList } from "./utils.mjs";
|
import { capitalize, codeBlock, formatChannel, formatEnumEntryList, formatKeyList, formatWarnList } from "./utils.mjs";
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { join } from "path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import type { Page } from "puppeteer-core";
|
import type { Page } from "puppeteer-core";
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFile } from "fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { basename } from "path";
|
import { basename } from "node:path";
|
||||||
|
|
||||||
import type { Page } from "puppeteer-core";
|
import type { Page } from "puppeteer-core";
|
||||||
import { satisfies, subset, valid, validRange } from "semver";
|
import { satisfies, subset, valid, validRange } from "semver";
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFile } from "fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { basename } from "path";
|
import { basename } from "node:path";
|
||||||
|
|
||||||
import { AST_NODE_TYPES, parse, type TSESTree } from "@typescript-eslint/typescript-estree";
|
import { AST_NODE_TYPES, parse, type TSESTree } from "@typescript-eslint/typescript-estree";
|
||||||
import type { Page } from "puppeteer-core";
|
import type { Page } from "puppeteer-core";
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"types": "./index.d.ts",
|
"types": "./index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "~4.17.7",
|
"@types/lodash": "~4.17.7",
|
||||||
"@types/node": "^18.19.42",
|
"@types/node": "^18.19.43",
|
||||||
"@types/react": "~18.2.79",
|
"@types/react": "~18.2.79",
|
||||||
"@types/react-dom": "~18.2.25",
|
"@types/react-dom": "~18.2.25",
|
||||||
"@vencord/discord-types": "workspace:^",
|
"@vencord/discord-types": "workspace:^",
|
||||||
|
|
|
@ -83,8 +83,8 @@ importers:
|
||||||
specifier: ~4.17.7
|
specifier: ~4.17.7
|
||||||
version: 4.17.7
|
version: 4.17.7
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^18.19.42
|
specifier: ^18.19.43
|
||||||
version: 18.19.42
|
version: 18.19.43
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ~18.2.79
|
specifier: ~18.2.79
|
||||||
version: 18.2.79
|
version: 18.2.79
|
||||||
|
@ -198,8 +198,8 @@ importers:
|
||||||
specifier: ^2.6.1
|
specifier: ^2.6.1
|
||||||
version: 2.6.1(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4)
|
version: 2.6.1(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4)
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20.14.13
|
specifier: ^20.14.14
|
||||||
version: 20.14.13
|
version: 20.14.14
|
||||||
'@types/semver':
|
'@types/semver':
|
||||||
specifier: ^7.5.8
|
specifier: ^7.5.8
|
||||||
version: 7.5.8
|
version: 7.5.8
|
||||||
|
@ -249,8 +249,8 @@ importers:
|
||||||
specifier: ~4.17.7
|
specifier: ~4.17.7
|
||||||
version: 4.17.7
|
version: 4.17.7
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^18.19.42
|
specifier: ^18.19.43
|
||||||
version: 18.19.42
|
version: 18.19.43
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ~18.2.79
|
specifier: ~18.2.79
|
||||||
version: 18.2.79
|
version: 18.2.79
|
||||||
|
@ -839,11 +839,11 @@ packages:
|
||||||
'@types/lodash@4.17.7':
|
'@types/lodash@4.17.7':
|
||||||
resolution: {integrity: sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==}
|
resolution: {integrity: sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==}
|
||||||
|
|
||||||
'@types/node@18.19.42':
|
'@types/node@18.19.43':
|
||||||
resolution: {integrity: sha512-d2ZFc/3lnK2YCYhos8iaNIYu9Vfhr92nHiyJHRltXWjXUBjEE+A4I58Tdbnw4VhggSW+2j5y5gTrLs4biNnubg==}
|
resolution: {integrity: sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==}
|
||||||
|
|
||||||
'@types/node@20.14.13':
|
'@types/node@20.14.14':
|
||||||
resolution: {integrity: sha512-+bHoGiZb8UiQ0+WEtmph2IWQCjIqg8MDZMAV+ppRRhUZnquF5mQkP/9vpSwJClEiSM/C7fZZExPzfU0vJTyp8w==}
|
resolution: {integrity: sha512-d64f00982fS9YoOgJkAMolK7MN8Iq3TDdVjchbYHdEmjth/DHowx82GnoA+tVUAN+7vxfYUgAzi+JXbKNd2SDQ==}
|
||||||
|
|
||||||
'@types/normalize-package-data@2.4.1':
|
'@types/normalize-package-data@2.4.1':
|
||||||
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
|
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
|
||||||
|
@ -3005,7 +3005,7 @@ snapshots:
|
||||||
'@types/fs-extra@11.0.4':
|
'@types/fs-extra@11.0.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/jsonfile': 6.1.4
|
'@types/jsonfile': 6.1.4
|
||||||
'@types/node': 20.14.13
|
'@types/node': 20.14.14
|
||||||
|
|
||||||
'@types/har-format@1.2.13': {}
|
'@types/har-format@1.2.13': {}
|
||||||
|
|
||||||
|
@ -3017,15 +3017,15 @@ snapshots:
|
||||||
|
|
||||||
'@types/jsonfile@6.1.4':
|
'@types/jsonfile@6.1.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.14.13
|
'@types/node': 20.14.14
|
||||||
|
|
||||||
'@types/lodash@4.17.7': {}
|
'@types/lodash@4.17.7': {}
|
||||||
|
|
||||||
'@types/node@18.19.42':
|
'@types/node@18.19.43':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 5.26.5
|
undici-types: 5.26.5
|
||||||
|
|
||||||
'@types/node@20.14.13':
|
'@types/node@20.14.14':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 5.26.5
|
undici-types: 5.26.5
|
||||||
|
|
||||||
|
@ -3051,12 +3051,12 @@ snapshots:
|
||||||
|
|
||||||
'@types/yauzl@2.10.0':
|
'@types/yauzl@2.10.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.14.13
|
'@types/node': 20.14.14
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@types/yazl@2.4.5':
|
'@types/yazl@2.4.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.14.13
|
'@types/node': 20.14.14
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4))(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4)':
|
'@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4))(eslint@9.8.0(patch_hash=wy5a2dwvtxac2ygzwebqqjurgi))(typescript@5.5.4)':
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4622,7 +4622,7 @@ snapshots:
|
||||||
|
|
||||||
standalone-electron-types@1.0.0(patch_hash=cvychuhjtbzvtowhc2efrgpqjq):
|
standalone-electron-types@1.0.0(patch_hash=cvychuhjtbzvtowhc2efrgpqjq):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 18.19.42
|
'@types/node': 18.19.43
|
||||||
|
|
||||||
static-extend@0.1.2:
|
static-extend@0.1.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -62,7 +62,7 @@ async function ensureBinary() {
|
||||||
|
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
headers.append("User-Agent", "Vencord (https://github.com/Vendicated/Vencord)");
|
headers.append("User-Agent", "Vencord (https://github.com/Vendicated/Vencord)");
|
||||||
if (etag != null)
|
if (etag !== null)
|
||||||
headers.append("If-None-Match", etag);
|
headers.append("If-None-Match", etag);
|
||||||
|
|
||||||
const res = await fetch(BASE_URL + filename, {
|
const res = await fetch(BASE_URL + filename, {
|
||||||
|
|
|
@ -69,9 +69,8 @@ export function addGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallback)
|
||||||
* @param patch The patch to be removed
|
* @param patch The patch to be removed
|
||||||
* @returns Whether the patch was successfully removed from the context menu(s)
|
* @returns Whether the patch was successfully removed from the context menu(s)
|
||||||
*/
|
*/
|
||||||
export function removeContextMenuPatch<T extends string[] | string>(navId: T, patch: NavContextMenuPatchCallback): T extends string ? boolean : boolean[] {
|
export function removeContextMenuPatch<T extends [string, ...string[]] | string>(navId: T, patch: NavContextMenuPatchCallback): T extends string ? boolean : boolean[] {
|
||||||
// https://github.com/microsoft/TypeScript/issues/33700
|
const navIds: [string, ...string[]] = Array.isArray(navId) ? navId : [navId];
|
||||||
const navIds: string[] = Array.isArray(navId) ? navId : [navId];
|
|
||||||
|
|
||||||
const results = navIds.map(id => navPatches.get(id)?.delete(patch) ?? false);
|
const results = navIds.map(id => navPatches.get(id)?.delete(patch) ?? false);
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,8 @@ export function _modifyAccessories(
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Values<T extends Iterable<unknown>> = T extends Iterable<infer U> ? U : never;
|
function filterIterable<T, S extends T>(iterable: Iterable<T>, predicate: (value: T) => value is S): Iterable<S>;
|
||||||
|
function filterIterable<T>(iterable: Iterable<T>, predicate: (value: T) => unknown): Iterable<T>;
|
||||||
function filterIterable<T extends Iterable<unknown>, S extends Values<T>>(iterable: T, predicate: (value: Values<T>) => value is S): T & Iterable<S>;
|
|
||||||
function filterIterable<T extends Iterable<unknown>>(iterable: T, predicate: (value: Values<T>) => unknown): T;
|
|
||||||
function* filterIterable<T>(iterable: Iterable<T>, predicate: (value: T) => unknown) {
|
function* filterIterable<T>(iterable: Iterable<T>, predicate: (value: T) => unknown) {
|
||||||
for (const value of iterable)
|
for (const value of iterable)
|
||||||
if (predicate(value))
|
if (predicate(value))
|
||||||
|
|
|
@ -143,7 +143,7 @@ export const compileStyle = (style: Style) => {
|
||||||
export const classNameToSelector = (name: string, prefix = "") =>
|
export const classNameToSelector = (name: string, prefix = "") =>
|
||||||
name.replaceAll(/ *([^ ]+) */g, `.${prefix}$1`);
|
name.replaceAll(/ *([^ ]+) */g, `.${prefix}$1`);
|
||||||
|
|
||||||
type ClassNameFactoryArg = string | string[] | Record<string, unknown> | false | null | undefined | 0 | "";
|
type ClassNameFactoryArg = string | string[] | Record<string, unknown> | false | null | undefined | 0n | 0 | "";
|
||||||
/**
|
/**
|
||||||
* @param prefix The prefix to add to each class, defaults to `""`
|
* @param prefix The prefix to add to each class, defaults to `""`
|
||||||
* @returns A classname generator function
|
* @returns A classname generator function
|
||||||
|
@ -156,14 +156,15 @@ type ClassNameFactoryArg = string | string[] | Record<string, unknown> | false |
|
||||||
export const classNameFactory = (prefix = "") => (...args: ClassNameFactoryArg[]) => {
|
export const classNameFactory = (prefix = "") => (...args: ClassNameFactoryArg[]) => {
|
||||||
const classNames = new Set<string>();
|
const classNames = new Set<string>();
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
if (arg && typeof arg === "string")
|
if (typeof arg === "string") {
|
||||||
classNames.add(arg);
|
if (arg) classNames.add(arg);
|
||||||
else if (Array.isArray(arg))
|
} else if (Array.isArray(arg)) {
|
||||||
arg.forEach(name => { classNames.add(name); });
|
for (const name of arg)
|
||||||
else if (arg && typeof arg === "object")
|
classNames.add(name);
|
||||||
Object.entries(arg).forEach(([name, value]) => {
|
} else if (typeof arg === "object" && arg !== null) {
|
||||||
if (value) classNames.add(name);
|
for (const name in arg)
|
||||||
});
|
if (arg[name]) classNames.add(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Array.from(classNames, name => prefix + name).join(" ");
|
return Array.from(classNames, name => prefix + name).join(" ");
|
||||||
};
|
};
|
||||||
|
|
16
src/globals.d.ts
vendored
16
src/globals.d.ts
vendored
|
@ -75,6 +75,15 @@ declare global {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/method-signature-style */
|
/* eslint-disable @typescript-eslint/method-signature-style */
|
||||||
|
// https://github.com/microsoft/TypeScript/issues/33700
|
||||||
|
// https://github.com/microsoft/TypeScript/issues/17002
|
||||||
|
interface ArrayConstructor {
|
||||||
|
// If 'any' or a generic type parameter that cannot be determined to satisfy
|
||||||
|
// the constraint is assigned to 'T', the default overload will be used.
|
||||||
|
isArray<T>(arg: 0 extends 1 & T ? never : T): arg is unknown extends typeof arg
|
||||||
|
? Extract<unknown[], typeof arg>
|
||||||
|
: ToArray<typeof arg>;
|
||||||
|
}
|
||||||
// https://github.com/microsoft/TypeScript/issues/29841
|
// https://github.com/microsoft/TypeScript/issues/29841
|
||||||
interface Array<T> {
|
interface Array<T> {
|
||||||
map<U>(callbackfn: (value: T, index: TupleKeys<this>, array: this) => U, thisArg?: any): MappedTuple<this, U>;
|
map<U>(callbackfn: (value: T, index: TupleKeys<this>, array: this) => U, thisArg?: any): MappedTuple<this, U>;
|
||||||
|
@ -85,6 +94,13 @@ declare global {
|
||||||
/* eslint-enable @typescript-eslint/method-signature-style */
|
/* eslint-enable @typescript-eslint/method-signature-style */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ToArray<T>
|
||||||
|
= T extends readonly unknown[]
|
||||||
|
? T
|
||||||
|
: T extends (ArrayLike<infer U> | Iterable<infer U>) & object
|
||||||
|
? Extract<U[], T>
|
||||||
|
: never;
|
||||||
|
|
||||||
// Workaround for https://github.com/microsoft/TypeScript/issues/59260
|
// Workaround for https://github.com/microsoft/TypeScript/issues/59260
|
||||||
type MappedTuple<T extends readonly unknown[], U>
|
type MappedTuple<T extends readonly unknown[], U>
|
||||||
// Detect non-homomorphic instantiation
|
// Detect non-homomorphic instantiation
|
||||||
|
|
|
@ -708,7 +708,7 @@ export default definePlugin({
|
||||||
addFakeNotice(type: FakeNoticeType, node: ReactNode, fake: boolean) {
|
addFakeNotice(type: FakeNoticeType, node: ReactNode, fake: boolean) {
|
||||||
if (!fake) return node;
|
if (!fake) return node;
|
||||||
|
|
||||||
const nodeArray: ReactNode[] = Array.isArray(node) ? node : [node];
|
const nodeArray = Array.isArray(node) ? node : [node];
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FakeNoticeType.Sticker: {
|
case FakeNoticeType.Sticker: {
|
||||||
|
|
|
@ -76,7 +76,7 @@ export default definePlugin({
|
||||||
const s = str(k);
|
const s = str(k);
|
||||||
|
|
||||||
return prev + (
|
return prev + (
|
||||||
s != null
|
s !== null
|
||||||
? (prev !== ""
|
? (prev !== ""
|
||||||
? (showMillis ? k === "milliseconds" : k === "seconds")
|
? (showMillis ? k === "milliseconds" : k === "seconds")
|
||||||
? " and "
|
? " and "
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { isObject } from "@utils";
|
||||||
import type { LiteralUnion } from "type-fest";
|
import type { LiteralUnion } from "type-fest";
|
||||||
|
|
||||||
// Resolves a possibly nested prop in the form of "some.nested.prop" to type of T.some.nested.prop
|
// Resolves a possibly nested prop in the form of "some.nested.prop" to type of T.some.nested.prop
|
||||||
|
@ -67,7 +68,7 @@ export class SettingsStore<T extends object> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
if (isObject(v))
|
||||||
return self.makeProxy(v, root, `${path}${path && "."}${key}`);
|
return self.makeProxy(v, root, `${path}${path && "."}${key}`);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ClipboardUtils, Toasts } from "@webpack/common";
|
import { ClipboardUtils, Toasts } from "@webpack/common";
|
||||||
|
import type { IsAny } from "type-fest";
|
||||||
|
|
||||||
import { DevsById } from "./constants";
|
import { DevsById } from "./constants";
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ export function copyWithToast(text: string, toastMessage?: string) {
|
||||||
/**
|
/**
|
||||||
* Check if obj is a true object: of type "object" and not null or array
|
* Check if obj is a true object: of type "object" and not null or array
|
||||||
*/
|
*/
|
||||||
export function isObject(obj: unknown): obj is object {
|
export function isObject<T>(obj: T): obj is IsAny<T> extends true ? any : unknown extends T ? Extract<object, T> : Exclude<T & object, readonly unknown[]> {
|
||||||
return typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
return typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue