@hokkiai/discord-emoji-selector 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+
6
+ // src/render.tsx
7
+ import tw from "@twemoji/api";
8
+ function render(txt) {
9
+ let twemojiparsed = tw.parse(txt).replaceAll("<img", '<img style="object-fit: cover;" loading="lazy"');
10
+ if (txt.startsWith("<:") || txt.startsWith("<a:")) {
11
+ const id = txt.split(":")[2].split(">")[0];
12
+ const isAnimated = txt.startsWith("<a:");
13
+ const url = `https://cdn.discordapp.com/emojis/${id}.${isAnimated ? "gif" : "webp"}`;
14
+ twemojiparsed = `<img style="object-fit: cover;" src="${url}" loading="lazy" />`;
15
+ }
16
+ return twemojiparsed;
17
+ }
18
+
19
+ // src/hooks.tsx
20
+ import { useEffect, useState } from "react";
21
+ function useSkin({ pickerId }) {
22
+ const [skin, setSkin] = useState(0);
23
+ useEffect(() => {
24
+ let raf;
25
+ const loop = () => {
26
+ const newSkin = window["emojipicker-" + pickerId]?.skin;
27
+ setSkin(newSkin || 0);
28
+ raf = requestAnimationFrame(loop);
29
+ };
30
+ raf = requestAnimationFrame(loop);
31
+ return () => {
32
+ cancelAnimationFrame(raf);
33
+ };
34
+ }, [pickerId]);
35
+ return skin;
36
+ }
37
+ function useSearchValue({ pickerId }) {
38
+ const [searchValue, setSearchValue] = useState("");
39
+ useEffect(() => {
40
+ let raf;
41
+ const loop = () => {
42
+ const newSearchValue = window["emojipicker-" + pickerId]?.searchValue || "";
43
+ setSearchValue(newSearchValue);
44
+ raf = requestAnimationFrame(loop);
45
+ };
46
+ raf = requestAnimationFrame(loop);
47
+ return () => {
48
+ cancelAnimationFrame(raf);
49
+ };
50
+ }, [pickerId]);
51
+ return searchValue;
52
+ }
53
+
54
+ export {
55
+ __commonJS,
56
+ render,
57
+ useSkin,
58
+ useSearchValue
59
+ };