From 2b64710b510e8760675f35e66fe2d596085b247b Mon Sep 17 00:00:00 2001 From: Zerthox Date: Mon, 4 Dec 2023 16:00:57 +0100 Subject: [PATCH] Move additional modules & components to dium --- packages/dium/src/components/icon.ts | 4 ++++ packages/dium/src/components/index.ts | 1 + packages/dium/src/components/input.ts | 5 +++++ packages/dium/src/modules/index.ts | 1 + packages/dium/src/modules/util.ts | 11 +++++++++++ src/BetterFolders/uploader.tsx | 8 ++------ src/BetterVolume/index.tsx | 12 +----------- src/CollapseEmbeds/hider.tsx | 8 +++----- src/CollapseEmbeds/package.json | 2 +- 9 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 packages/dium/src/components/icon.ts create mode 100644 packages/dium/src/modules/util.ts diff --git a/packages/dium/src/components/icon.ts b/packages/dium/src/components/icon.ts new file mode 100644 index 000000000..c5740383d --- /dev/null +++ b/packages/dium/src/components/icon.ts @@ -0,0 +1,4 @@ +import {Finder} from "../api"; + +// chevron small down icon +export const IconArrow = /* @__PURE__ */ Finder.bySource(["d:\"M5.29289 9"], {entries: true}); diff --git a/packages/dium/src/components/index.ts b/packages/dium/src/components/index.ts index 9762193e2..fd94f37bc 100644 --- a/packages/dium/src/components/index.ts +++ b/packages/dium/src/components/index.ts @@ -5,6 +5,7 @@ export * from "./embed"; export * from "./flex"; export * from "./form"; export * from "./guild"; +export * from "./icon"; export * from "./link"; export * from "./margins"; export * from "./menu"; diff --git a/packages/dium/src/components/input.ts b/packages/dium/src/components/input.ts index 794af176f..fe385ba39 100644 --- a/packages/dium/src/components/input.ts +++ b/packages/dium/src/components/input.ts @@ -1,3 +1,4 @@ +import {Finder} from "../api"; import {Common} from "./common"; export const enum TextInputSizes { @@ -48,3 +49,7 @@ interface InputComponents { } export const {TextInput, InputError} = Common as InputComponents; + +export const ImageInput: React.ComponentClass = /* @__PURE__ */ Finder.find( + (target) => typeof target.defaultProps?.multiple === "boolean" && typeof target.defaultProps?.maxFileSizeBytes === "number" +); diff --git a/packages/dium/src/modules/index.ts b/packages/dium/src/modules/index.ts index 48aba11ec..789abf6fd 100644 --- a/packages/dium/src/modules/index.ts +++ b/packages/dium/src/modules/index.ts @@ -11,5 +11,6 @@ export * from "./npm"; export * from "./popout-window"; export * from "./router"; export * from "./user"; +export * from "./util"; export type Untyped = T & Record; diff --git a/packages/dium/src/modules/util.ts b/packages/dium/src/modules/util.ts new file mode 100644 index 000000000..9227f2a6e --- /dev/null +++ b/packages/dium/src/modules/util.ts @@ -0,0 +1,11 @@ +import {Filters, Finder} from "../api"; + +export interface AudioConvert { + amplitudeToPerceptual(amplitude: number): number; + perceptualToAmplitude(perceptual: number): number; +} + +export const AudioConvert: AudioConvert = /* @__PURE__ */ Finder.demangle({ + amplitudeToPerceptual: Filters.bySource("Math.log10"), + perceptualToAmplitude: Filters.bySource("Math.pow(10") +}); diff --git a/src/BetterFolders/uploader.tsx b/src/BetterFolders/uploader.tsx index 916600fdc..47b5a1540 100644 --- a/src/BetterFolders/uploader.tsx +++ b/src/BetterFolders/uploader.tsx @@ -1,13 +1,9 @@ -import {Finder, React} from "dium"; +import {React} from "dium"; import {GuildsTreeFolder} from "@dium/modules"; -import {Flex, Button, FormSwitch, FormText, margins} from "@dium/components"; +import {Flex, Button, FormSwitch, FormText, ImageInput, margins} from "@dium/components"; import {FolderData} from "./settings"; import {BetterFolderIcon} from "./icon"; -const ImageInput: React.ComponentClass = Finder.find( - (target) => typeof target.defaultProps?.multiple === "boolean" && typeof target.defaultProps?.maxFileSizeBytes === "number" -); - export interface BetterFolderUploaderProps extends FolderData { folderNode: GuildsTreeFolder; onChange(data: FolderData): void; diff --git a/src/BetterVolume/index.tsx b/src/BetterVolume/index.tsx index 23b2c8479..553c41d51 100644 --- a/src/BetterVolume/index.tsx +++ b/src/BetterVolume/index.tsx @@ -1,21 +1,11 @@ import {createPlugin, Finder, Filters, Patcher, React} from "dium"; -import {Snowflake, MediaEngineStore, MediaEngineActions, MediaEngineContext} from "@dium/modules"; +import {Snowflake, MediaEngineStore, MediaEngineActions, MediaEngineContext, AudioConvert} from "@dium/modules"; import {MenuItem, FormSwitch} from "@dium/components"; import {Settings} from "./settings"; import {NumberInput} from "./input"; import {handleExperiment, hasExperiment, resetExperiment} from "./experiment"; import {css} from "./styles.module.scss"; -interface AudioConvert { - amplitudeToPerceptual(amplitude: number): number; - perceptualToAmplitude(perceptual: number): number; -} - -const AudioConvert: AudioConvert = Finder.demangle({ - amplitudeToPerceptual: Filters.bySource("Math.log10"), - perceptualToAmplitude: Filters.bySource("Math.pow(10") -}); - type UseUserVolumeItem = (userId: Snowflake, context: MediaEngineContext) => JSX.Element; export default createPlugin({ diff --git a/src/CollapseEmbeds/hider.tsx b/src/CollapseEmbeds/hider.tsx index 5194bd075..185820ff0 100644 --- a/src/CollapseEmbeds/hider.tsx +++ b/src/CollapseEmbeds/hider.tsx @@ -1,11 +1,9 @@ -import {Finder, React} from "dium"; +import {React} from "dium"; import {classNames} from "@dium/modules"; -import {Flex, Clickable, Text} from "@dium/components"; +import {Flex, Clickable, Text, IconArrow} from "@dium/components"; import {Settings} from "./settings"; import styles from "./styles.module.scss"; -const Arrow = Finder.bySource(["d:\"M5.293 9"], {entries: true}); - export const enum AccessoryType { Embed = "embed", Attachment = "attachment" @@ -37,7 +35,7 @@ export const Hider = ({placeholders, type, children}: HiderProps): JSX.Element = className={styles.hideButton} onClick={() => setShown(!shown)} > - + ); diff --git a/src/CollapseEmbeds/package.json b/src/CollapseEmbeds/package.json index 8c39e1516..da7fbe57e 100644 --- a/src/CollapseEmbeds/package.json +++ b/src/CollapseEmbeds/package.json @@ -1,7 +1,7 @@ { "name": "CollapseEmbeds", "author": "Zerthox", - "version": "1.0.4", + "version": "1.0.5", "description": "Adds a button to collapse embeds & attachments.", "dependencies": { "dium": "*"