diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 2d5d60ecf..c0e00110c 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -130,6 +130,52 @@ export default definePlugin({ replace: "" } }, + // Zustand section + { + find: "[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'", + replacement: [ + { + match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use `import { create } from 'zustand'`\."\),/, + replace: "" + }, + { + match: /&&console\.warn\("\[DEPRECATED\] Passing a vanilla store will be unsupported in a future version\. Instead use `import { useStore } from 'zustand'`\."\)/, + replace: "" + }, + { + match: /console\.warn\("\[DEPRECATED\] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`\. They can be imported from 'zustand\/traditional'\. https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1937"\),/, + replace: "" + } + ] + }, + { + find: "[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] `getStorage`, `serialize` and `deserialize` options are deprecated\. Use `storage` option instead\."\),/, + replace: "" + } + }, + { + find: "[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use import { createStore } from 'zustand\/vanilla'\."\),/, + replace: "" + } + }, + { + find: "[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] `context` will be removed in a future version\. Instead use `import { createStore, useStore } from 'zustand'`\. See: https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1180\."\);/, + replace: "" + } + }, + { + find: "[DEPRECATED] Default export is deprecated. Instead use `import { shallow } from 'zustand/shallow'`.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use `import { shallow } from 'zustand\/shallow'`\."\),/, + replace: "" + } + }, // Patches discords generic logger function { find: "Σ:", @@ -147,5 +193,5 @@ export default definePlugin({ replace: "$self.NoopLogger()" } } - ], + ] }); diff --git a/src/plugins/decor/lib/stores/AuthorizationStore.tsx b/src/plugins/decor/lib/stores/AuthorizationStore.tsx index ba71da99e..7f3468fd0 100644 --- a/src/plugins/decor/lib/stores/AuthorizationStore.tsx +++ b/src/plugins/decor/lib/stores/AuthorizationStore.tsx @@ -93,7 +93,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate( } as AuthorizationState), { name: "decor-auth", - getStorage: () => indexedDBStorage, + storage: indexedDBStorage, partialize: state => ({ tokens: state.tokens }), onRehydrateStorage: () => state => state?.init() } diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index bc3c1ed90..a79e3f31e 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -28,7 +28,7 @@ import { getIntlMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { classes } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { findByPropsLazy } from "@webpack"; import { ChannelStore, FluxDispatcher, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -43,7 +43,6 @@ interface MLMessage extends Message { } const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage"); -const getMessage = findByCodeLazy('replace(/^\\n+|\\n+$/g,"")'); function addDeleteStyle() { if (Settings.plugins.MessageLogger.deleteStyle === "text") { @@ -312,35 +311,33 @@ export default definePlugin({ ); }, - Messages: { - // DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}") - // TODO: find a better way to generate intl messages - DELETED_MESSAGE_COUNT: () => ({ - ast: [[ - 6, - "count", - { - "=0": ["No deleted messages"], - one: [ - [ - 1, - "count" - ], - " deleted message" + // DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}") + // TODO: Find a better way to generate intl messages + DELETED_MESSAGE_COUNT: () => ({ + ast: [[ + 6, + "count", + { + "=0": ["No deleted messages"], + one: [ + [ + 1, + "count" ], - other: [ - [ - 1, - "count" - ], - " deleted messages" - ] - }, - 0, - "cardinal" - ]] - }) - }, + " deleted message" + ], + other: [ + [ + 1, + "count" + ], + " deleted messages" + ] + }, + 0, + "cardinal" + ]] + }), patches: [ { @@ -531,7 +528,7 @@ export default definePlugin({ }, { match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/, - replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.Messages.DELETED_MESSAGE_COUNT:', + replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.DELETED_MESSAGE_COUNT:', }, ], predicate: () => Settings.plugins.MessageLogger.collapseDeleted diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 1a1700e40..65ce6136f 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -28,8 +28,8 @@ import { Message } from "discord-types/general"; const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); interface MessageDeleteProps { - // i18n message i18n.t["+FcYMz"] if deleted, with args - collapsedReason: () => any + // Internal intl message for BLOCKED_MESSAGE_COUNT + collapsedReason: () => any; } export default definePlugin({ diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 3f44d106d..72f8a4275 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -163,9 +163,13 @@ waitFor(["open", "saveAccountChanges"], m => SettingsRouter = m); export const PermissionsBits: t.PermissionsBits = findLazy(m => typeof m.ADMINISTRATOR === "bigint"); -export const zustandCreate = findByCodeLazy("will be removed in v4"); +export const { zustandCreate } = mapMangledModuleLazy(["useSyncExternalStoreWithSelector:", "Object.assign"], { + zustandCreate: m => typeof m === "function" +}); -export const zustandPersist = findByCodeLazy("[zustand persist middleware]"); +export const { zustandPersist } = mapMangledModuleLazy(".onRehydrateStorage)?", { + zustandPersist: m => typeof m === "function" +}); export const MessageActions = findByPropsLazy("editMessage", "sendMessage"); export const MessageCache = findByPropsLazy("clearCache", "_channelMessages"); @@ -181,7 +185,7 @@ export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLa toggleExpressionPicker: filters.byCode(/getState\(\)\.activeView===\i\?\i\(\):\i\(/), setExpressionPickerView: filters.byCode(/setState\({activeView:\i,lastActiveView:/), setSearchQuery: filters.byCode("searchQuery:"), - useExpressionPickerStore: filters.byCode("Object.is") + useExpressionPickerStore: filters.byCode(".getInitialState") }); export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT_WINDOW_OPEN"', {