Merge remote-tracking branch 'upstream/dev' into dev
Some checks are pending
Sync to Codeberg / Sync Codeberg and Github (push) Waiting to run
Test / Test (push) Waiting to run

This commit is contained in:
thororen1234 2025-02-25 20:19:22 +00:00
commit e224a1cde3
3 changed files with 26 additions and 16 deletions

View file

@ -88,10 +88,8 @@ export default definePlugin({
find: ".description,delay:", find: ".description,delay:",
replacement: [ replacement: [
{ {
// alt: "", aria-hidden: false, src: originalSrc match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/,
match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/, replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})`
// ...badge.props, ..., src: badge.image ?? ...
replace: "...$1.props,$& $1.image??"
}, },
{ {
match: /(?<="aria-label":(\i)\.description,.{0,200})children:/, match: /(?<="aria-label":(\i)\.description,.{0,200})children:/,

View file

@ -153,13 +153,7 @@ function makeShortcuts() {
openModal: { getter: () => ModalAPI.openModal }, openModal: { getter: () => ModalAPI.openModal },
openModalLazy: { getter: () => ModalAPI.openModalLazy }, openModalLazy: { getter: () => ModalAPI.openModalLazy },
Stores: { Stores: Webpack.fluxStores
getter: () => Object.fromEntries(
Common.Flux.Store.getAll()
.map(store => [store.getName(), store] as const)
.filter(([name]) => name.length > 1)
)
}
}; };
} }

View file

@ -20,6 +20,7 @@ import { makeLazy, proxyLazy } from "@utils/lazy";
import { LazyComponent } from "@utils/lazyReact"; import { LazyComponent } from "@utils/lazyReact";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { canonicalizeMatch } from "@utils/patches"; import { canonicalizeMatch } from "@utils/patches";
import { FluxStore } from "@webpack/types";
import { traceFunction } from "../debug/Tracer"; import { traceFunction } from "../debug/Tracer";
import { Flux } from "./common"; import { Flux } from "./common";
@ -37,6 +38,8 @@ export const onceReady = new Promise<void>(r => _resolveReady = r);
export let wreq: WebpackRequire; export let wreq: WebpackRequire;
export let cache: WebpackRequire["c"]; export let cache: WebpackRequire["c"];
export const fluxStores: Record<string, FluxStore> = {};
export type FilterFn = (mod: any) => boolean; export type FilterFn = (mod: any) => boolean;
export type PropsFilter = Array<string>; export type PropsFilter = Array<string>;
@ -430,9 +433,24 @@ export function findByCodeLazy(...code: CodeFilter) {
* Find a store by its displayName * Find a store by its displayName
*/ */
export function findStore(name: StoreNameFilter) { export function findStore(name: StoreNameFilter) {
const res = Flux.Store.getAll let res = fluxStores[name] as any;
? Flux.Store.getAll().find(filters.byStoreName(name)) if (res == null) {
: find(filters.byStoreName(name), { isIndirect: true }); for (const store of Flux.Store.getAll?.() ?? []) {
const storeName = store.getName();
if (storeName === name) {
res = store;
}
if (fluxStores[storeName] == null) {
fluxStores[storeName] = store;
}
}
if (res == null) {
res = find(filters.byStoreName(name), { isIndirect: true });
}
}
if (!res) if (!res)
handleModuleNotFound("findStore", name); handleModuleNotFound("findStore", name);