@libstermynal/transcript-v2 3.3.2
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.
- package/LICENSE +201 -0
- package/README.md +134 -0
- package/dist/downloader/images.d.ts +36 -0
- package/dist/downloader/images.js +114 -0
- package/dist/downloader/images.js.map +1 -0
- package/dist/generator/index.d.ts +18 -0
- package/dist/generator/index.js +71 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/renderers/attachment.d.ts +21 -0
- package/dist/generator/renderers/attachment.js +67 -0
- package/dist/generator/renderers/attachment.js.map +1 -0
- package/dist/generator/renderers/components/Button.d.ts +9 -0
- package/dist/generator/renderers/components/Button.js +9 -0
- package/dist/generator/renderers/components/Button.js.map +1 -0
- package/dist/generator/renderers/components/Container.d.ts +5 -0
- package/dist/generator/renderers/components/Container.js +19 -0
- package/dist/generator/renderers/components/Container.js.map +1 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.d.ts +6 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.js +199 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.js.map +1 -0
- package/dist/generator/renderers/components/DiscordImage.d.ts +6 -0
- package/dist/generator/renderers/components/DiscordImage.js +21 -0
- package/dist/generator/renderers/components/DiscordImage.js.map +1 -0
- package/dist/generator/renderers/components/Media Gallery.d.ts +5 -0
- package/dist/generator/renderers/components/Media Gallery.js +32 -0
- package/dist/generator/renderers/components/Media Gallery.js.map +1 -0
- package/dist/generator/renderers/components/Select Menu.d.ts +7 -0
- package/dist/generator/renderers/components/Select Menu.js +31 -0
- package/dist/generator/renderers/components/Select Menu.js.map +1 -0
- package/dist/generator/renderers/components/Spacing.d.ts +6 -0
- package/dist/generator/renderers/components/Spacing.js +14 -0
- package/dist/generator/renderers/components/Spacing.js.map +1 -0
- package/dist/generator/renderers/components/Thumbnail.d.ts +4 -0
- package/dist/generator/renderers/components/Thumbnail.js +13 -0
- package/dist/generator/renderers/components/Thumbnail.js.map +1 -0
- package/dist/generator/renderers/components/TranscriptHeader.d.ts +8 -0
- package/dist/generator/renderers/components/TranscriptHeader.js +13 -0
- package/dist/generator/renderers/components/TranscriptHeader.js.map +1 -0
- package/dist/generator/renderers/components/section/Section.d.ts +9 -0
- package/dist/generator/renderers/components/section/Section.js +19 -0
- package/dist/generator/renderers/components/section/Section.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionAccessory.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js +16 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionContent.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionContent.js +12 -0
- package/dist/generator/renderers/components/section/SectionContent.js.map +1 -0
- package/dist/generator/renderers/components/styles.d.ts +21 -0
- package/dist/generator/renderers/components/styles.js +147 -0
- package/dist/generator/renderers/components/styles.js.map +1 -0
- package/dist/generator/renderers/components/utils.d.ts +36 -0
- package/dist/generator/renderers/components/utils.js +98 -0
- package/dist/generator/renderers/components/utils.js.map +1 -0
- package/dist/generator/renderers/components.d.ts +11 -0
- package/dist/generator/renderers/components.js +65 -0
- package/dist/generator/renderers/components.js.map +1 -0
- package/dist/generator/renderers/content.d.ts +31 -0
- package/dist/generator/renderers/content.js +163 -0
- package/dist/generator/renderers/content.js.map +1 -0
- package/dist/generator/renderers/embed.d.ts +11 -0
- package/dist/generator/renderers/embed.js +44 -0
- package/dist/generator/renderers/embed.js.map +1 -0
- package/dist/generator/renderers/message.d.ts +6 -0
- package/dist/generator/renderers/message.js +59 -0
- package/dist/generator/renderers/message.js.map +1 -0
- package/dist/generator/renderers/reply.d.ts +6 -0
- package/dist/generator/renderers/reply.js +53 -0
- package/dist/generator/renderers/reply.js.map +1 -0
- package/dist/generator/renderers/systemMessage.d.ts +13 -0
- package/dist/generator/renderers/systemMessage.js +115 -0
- package/dist/generator/renderers/systemMessage.js.map +1 -0
- package/dist/generator/transcript.d.ts +9 -0
- package/dist/generator/transcript.js +76 -0
- package/dist/generator/transcript.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/dist/static/client.d.ts +3 -0
- package/dist/static/client.js +31 -0
- package/dist/static/client.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buildProfiles.d.ts +11 -0
- package/dist/utils/buildProfiles.js +42 -0
- package/dist/utils/buildProfiles.js.map +1 -0
- package/dist/utils/embeds.d.ts +2 -0
- package/dist/utils/embeds.js +17 -0
- package/dist/utils/embeds.js.map +1 -0
- package/dist/utils/extend.d.ts +8 -0
- package/dist/utils/extend.js +8 -0
- package/dist/utils/extend.js.map +1 -0
- package/dist/utils/utils.d.ts +15 -0
- package/dist/utils/utils.js +50 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: create some sort of build system to compile this file
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ggSansFont = exports.revealSpoiler = exports.scrollToMessage = void 0;
|
|
5
|
+
/*
|
|
6
|
+
// whenever user clicks on element with data-goto attribute, scroll to that message
|
|
7
|
+
document.addEventListener('click', (e) => {
|
|
8
|
+
const target = e.target;
|
|
9
|
+
if(!target) return;
|
|
10
|
+
|
|
11
|
+
const goto = target?.getAttribute('data-goto');
|
|
12
|
+
|
|
13
|
+
if (goto) {
|
|
14
|
+
const message = document.getElementById(`m-\${goto}`);
|
|
15
|
+
if (message) {
|
|
16
|
+
message.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
17
|
+
message.style.backgroundColor = 'rgba(148, 156, 247, 0.1)';
|
|
18
|
+
message.style.transition = 'background-color 0.5s ease';
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
message.style.backgroundColor = 'transparent';
|
|
21
|
+
}, 1000);
|
|
22
|
+
} else {
|
|
23
|
+
console.warn(`Message \${goto} not found.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
*/
|
|
28
|
+
exports.scrollToMessage = 'document.addEventListener("click",t=>{let e=t.target;if(!e)return;let o=e?.getAttribute("data-goto");if(o){let r=document.getElementById(`m-${o}`);r?(r.scrollIntoView({behavior:"smooth",block:"center"}),r.style.backgroundColor="rgba(148, 156, 247, 0.1)",r.style.transition="background-color 0.5s ease",setTimeout(()=>{r.style.backgroundColor="transparent"},1e3)):console.warn("Message ${goto} not found.")}});';
|
|
29
|
+
exports.revealSpoiler = 'const s=document.querySelectorAll(".discord-spoiler");s.forEach(s=>s.addEventListener("click",()=>{if(s.classList.contains("discord-spoiler")){s.classList.remove("discord-spoiler");s.classList.add("discord-spoiler--revealed");}}));';
|
|
30
|
+
exports.ggSansFont = '@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-normal-400.woff2);font-family:"gg sans";font-weight:400;font-style:normal}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-normal-500.woff2);font-family:"gg sans";font-weight:500;font-style:normal}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-normal-600.woff2);font-family:"gg sans";font-weight:600;font-style:normal}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-normal-700.woff2);font-family:"gg sans";font-weight:700;font-style:normal}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-normal-800.woff2);font-family:"gg sans";font-weight:800;font-style:normal}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-italic-400.woff2);font-family:"gg sans";font-weight:400;font-style:italic}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-italic-500.woff2);font-family:"gg sans";font-weight:500;font-style:italic}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-italic-600.woff2);font-family:"gg sans";font-weight:600;font-style:italic}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-italic-700.woff2);font-family:"gg sans";font-weight:700;font-style:italic}@font-face{src:url(https://cdn.jsdelivr.net/gh/Tyrrrz/DiscordFonts@master/ggsans-italic-800.woff2);font-family:"gg sans";font-weight:800;font-style:italic}';
|
|
31
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/static/client.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D;;;;;;;;;;;;;;;;;;;;;;EAsBE;AACW,QAAA,eAAe,GAC1B,2ZAA2Z,CAAC;AAEjZ,QAAA,aAAa,GACxB,yOAAyO,CAAC;AAE/N,QAAA,UAAU,GACrB,ghDAAghD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AttachmentBuilder, Message } from 'discord.js';
|
|
2
|
+
import type { RenderMessageContext } from './generator';
|
|
3
|
+
export declare enum AttachmentTypes {
|
|
4
|
+
Audio = 0,
|
|
5
|
+
Video = 1,
|
|
6
|
+
Image = 2,
|
|
7
|
+
File = 3
|
|
8
|
+
}
|
|
9
|
+
export declare enum ExportReturnType {
|
|
10
|
+
Buffer = "buffer",
|
|
11
|
+
String = "string",
|
|
12
|
+
Attachment = "attachment"
|
|
13
|
+
}
|
|
14
|
+
export type ObjectType<T extends ExportReturnType> = T extends ExportReturnType.Buffer ? Buffer : T extends ExportReturnType.String ? string : AttachmentBuilder;
|
|
15
|
+
export type GenerateFromMessagesOptions<T extends ExportReturnType> = Partial<{
|
|
16
|
+
/**
|
|
17
|
+
* The type of object to return
|
|
18
|
+
* @default ExportReturnType.ATTACHMENT
|
|
19
|
+
*/
|
|
20
|
+
returnType: T;
|
|
21
|
+
/**
|
|
22
|
+
* Downloads images and encodes them as base64 data urls
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
saveImages: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Callbacks for resolving channels, users, and roles
|
|
28
|
+
*/
|
|
29
|
+
callbacks: Partial<RenderMessageContext['callbacks']>;
|
|
30
|
+
/**
|
|
31
|
+
* The name of the file to return if returnType is ExportReturnType.ATTACHMENT
|
|
32
|
+
* @default 'transcript-{channel-id}.html'
|
|
33
|
+
*/
|
|
34
|
+
filename: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to include the "Powered by discord-html-transcripts" footer
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
poweredBy: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The message right before "Powered by" text. Remember to put the {s}
|
|
42
|
+
* @default 'Exported {number} message{s}.'
|
|
43
|
+
*/
|
|
44
|
+
footerText: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether to show the guild icon or a custom icon as the favicon
|
|
47
|
+
* 'guild' - use the guild icon
|
|
48
|
+
* or pass in a url to use a custom icon
|
|
49
|
+
* @default "guild"
|
|
50
|
+
*/
|
|
51
|
+
favicon: 'guild' | string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to hydrate the html server-side
|
|
54
|
+
* @default false - the returned html will be hydrated client-side
|
|
55
|
+
*/
|
|
56
|
+
hydrate: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
export type CreateTranscriptOptions<T extends ExportReturnType> = Partial<GenerateFromMessagesOptions<T> & {
|
|
59
|
+
/**
|
|
60
|
+
* The max amount of messages to fetch. Use `-1` to recursively fetch.
|
|
61
|
+
*/
|
|
62
|
+
limit: number;
|
|
63
|
+
/**
|
|
64
|
+
* Filter messages of the channel
|
|
65
|
+
* @default (() => true)
|
|
66
|
+
*/
|
|
67
|
+
filter: (message: Message<boolean>) => boolean;
|
|
68
|
+
}>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExportReturnType = exports.AttachmentTypes = void 0;
|
|
4
|
+
var AttachmentTypes;
|
|
5
|
+
(function (AttachmentTypes) {
|
|
6
|
+
AttachmentTypes[AttachmentTypes["Audio"] = 0] = "Audio";
|
|
7
|
+
AttachmentTypes[AttachmentTypes["Video"] = 1] = "Video";
|
|
8
|
+
AttachmentTypes[AttachmentTypes["Image"] = 2] = "Image";
|
|
9
|
+
AttachmentTypes[AttachmentTypes["File"] = 3] = "File";
|
|
10
|
+
})(AttachmentTypes || (exports.AttachmentTypes = AttachmentTypes = {}));
|
|
11
|
+
var ExportReturnType;
|
|
12
|
+
(function (ExportReturnType) {
|
|
13
|
+
ExportReturnType["Buffer"] = "buffer";
|
|
14
|
+
ExportReturnType["String"] = "string";
|
|
15
|
+
ExportReturnType["Attachment"] = "attachment";
|
|
16
|
+
})(ExportReturnType || (exports.ExportReturnType = ExportReturnType = {}));
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,uDAAK,CAAA;IACL,uDAAK,CAAA;IACL,uDAAK,CAAA;IACL,qDAAI,CAAA;AACN,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;AAC3B,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Message } from 'discord.js';
|
|
2
|
+
export type Profile = {
|
|
3
|
+
author: string;
|
|
4
|
+
avatar?: string;
|
|
5
|
+
roleColor?: string;
|
|
6
|
+
roleIcon?: string;
|
|
7
|
+
roleName?: string;
|
|
8
|
+
bot?: boolean;
|
|
9
|
+
verified?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function buildProfiles(messages: Message[]): Promise<Record<string, Profile>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildProfiles = buildProfiles;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
async function buildProfiles(messages) {
|
|
6
|
+
const profiles = {};
|
|
7
|
+
// loop through messages
|
|
8
|
+
for (const message of messages) {
|
|
9
|
+
// add all users
|
|
10
|
+
const author = message.author;
|
|
11
|
+
if (!profiles[author.id]) {
|
|
12
|
+
// add profile
|
|
13
|
+
profiles[author.id] = buildProfile(message.member, author);
|
|
14
|
+
}
|
|
15
|
+
// add interaction users
|
|
16
|
+
if (message.interaction) {
|
|
17
|
+
const user = message.interaction.user;
|
|
18
|
+
if (!profiles[user.id]) {
|
|
19
|
+
profiles[user.id] = buildProfile(null, user);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// threads
|
|
23
|
+
if (message.thread && message.thread.lastMessage) {
|
|
24
|
+
profiles[message.thread.lastMessage.author.id] = buildProfile(message.thread.lastMessage.member, message.thread.lastMessage.author);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// return as a JSON
|
|
28
|
+
return profiles;
|
|
29
|
+
}
|
|
30
|
+
function buildProfile(member, author) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
+
return {
|
|
33
|
+
author: (_b = (_a = member === null || member === void 0 ? void 0 : member.nickname) !== null && _a !== void 0 ? _a : author.displayName) !== null && _b !== void 0 ? _b : author.username,
|
|
34
|
+
avatar: (_c = member === null || member === void 0 ? void 0 : member.displayAvatarURL({ size: 64 })) !== null && _c !== void 0 ? _c : author.displayAvatarURL({ size: 64 }),
|
|
35
|
+
roleColor: member === null || member === void 0 ? void 0 : member.displayHexColor,
|
|
36
|
+
roleIcon: (_e = (_d = member === null || member === void 0 ? void 0 : member.roles.icon) === null || _d === void 0 ? void 0 : _d.iconURL()) !== null && _e !== void 0 ? _e : undefined,
|
|
37
|
+
roleName: (_g = (_f = member === null || member === void 0 ? void 0 : member.roles.hoist) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : undefined,
|
|
38
|
+
bot: author.bot,
|
|
39
|
+
verified: (_h = author.flags) === null || _h === void 0 ? void 0 : _h.has(discord_js_1.UserFlags.VerifiedBot),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=buildProfiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildProfiles.js","sourceRoot":"","sources":["../../src/utils/buildProfiles.ts"],"names":[],"mappings":";;AAaA,sCA+BC;AA5CD,2CAAkF;AAa3E,KAAK,UAAU,aAAa,CAAC,QAAmB;IACrD,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAE7C,wBAAwB;IACxB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,gBAAgB;QAChB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YACzB,cAAc;YACd,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7D,CAAC;QAED,wBAAwB;QACxB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;YACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateInlineIndex = calculateInlineIndex;
|
|
4
|
+
function calculateInlineIndex(fields, currentFieldIndex) {
|
|
5
|
+
const startIndex = currentFieldIndex - 1;
|
|
6
|
+
for (let i = startIndex; i >= 0; i--) {
|
|
7
|
+
const field = fields[i];
|
|
8
|
+
if (!field)
|
|
9
|
+
continue;
|
|
10
|
+
if (field.inline === false) {
|
|
11
|
+
const amount = startIndex - i;
|
|
12
|
+
return (amount % 3) + 1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return (currentFieldIndex % 3) + 1;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=embeds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeds.js","sourceRoot":"","sources":["../../src/utils/embeds.ts"],"names":[],"mappings":";;AAEA,oDAcC;AAdD,SAAgB,oBAAoB,CAAC,MAAuB,EAAE,iBAAyB;IACrF,MAAM,UAAU,GAAG,iBAAiB,GAAG,CAAC,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK;YAAE,SAAS;QAErB,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,UAAU,GAAG,CAAC,CAAC;YAC9B,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ASTNode, ParserRule } from 'simple-markdown';
|
|
3
|
+
import type { State } from './types';
|
|
4
|
+
type AdditionalRule = Partial<ParserRule> & {
|
|
5
|
+
react: (node: ASTNode, output: (node: ASTNode, state?: unknown) => string, state: State) => ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const extend: (additionalRules: AdditionalRule, defaultRule: ParserRule) => AdditionalRule;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extend = void 0;
|
|
4
|
+
const extend = (additionalRules, defaultRule) => {
|
|
5
|
+
return Object.assign({}, defaultRule, additionalRules);
|
|
6
|
+
};
|
|
7
|
+
exports.extend = extend;
|
|
8
|
+
//# sourceMappingURL=extend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../src/utils/extend.ts"],"names":[],"mappings":";;;AAQO,MAAM,MAAM,GAAG,CAAC,eAA+B,EAAE,WAAuB,EAAkB,EAAE;IACjG,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,MAAM,UAEjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { APIMessageComponentEmoji, Emoji } from 'discord.js';
|
|
2
|
+
export declare function isDefined<T>(value: T | undefined | null): value is T;
|
|
3
|
+
/**
|
|
4
|
+
* Returns a tuple of [bytes (i.e. 1024), bytesUnit (i.e. KB)]
|
|
5
|
+
* @param bytes
|
|
6
|
+
* @param decimals
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatBytes(bytes: number, decimals?: number): [number, string];
|
|
10
|
+
export declare function parseDiscordEmoji(emoji: Emoji | APIMessageComponentEmoji): string;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a stream to a string
|
|
13
|
+
* @param stream - The stream to convert
|
|
14
|
+
*/
|
|
15
|
+
export declare function streamToString(stream: NodeJS.ReadableStream): Promise<string>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isDefined = isDefined;
|
|
7
|
+
exports.formatBytes = formatBytes;
|
|
8
|
+
exports.parseDiscordEmoji = parseDiscordEmoji;
|
|
9
|
+
exports.streamToString = streamToString;
|
|
10
|
+
const twemoji_1 = __importDefault(require("twemoji"));
|
|
11
|
+
function isDefined(value) {
|
|
12
|
+
return value !== undefined && value !== null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns a tuple of [bytes (i.e. 1024), bytesUnit (i.e. KB)]
|
|
16
|
+
* @param bytes
|
|
17
|
+
* @param decimals
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
function formatBytes(bytes, decimals = 2) {
|
|
21
|
+
if (bytes === 0)
|
|
22
|
+
return [0, 'Bytes'];
|
|
23
|
+
const k = 1024;
|
|
24
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
25
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
26
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
27
|
+
return [parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), sizes[i]];
|
|
28
|
+
}
|
|
29
|
+
function parseDiscordEmoji(emoji) {
|
|
30
|
+
if (emoji.id) {
|
|
31
|
+
return `https://cdn.discordapp.com/emojis/${emoji.id}.${emoji.animated ? 'gif' : 'png'}`;
|
|
32
|
+
}
|
|
33
|
+
const codepoints = twemoji_1.default.convert
|
|
34
|
+
.toCodePoint(emoji.name.indexOf(String.fromCharCode(0x200d)) < 0 ? emoji.name.replace(/\uFE0F/g, '') : emoji.name)
|
|
35
|
+
.toLowerCase();
|
|
36
|
+
return `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${codepoints}.svg`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts a stream to a string
|
|
40
|
+
* @param stream - The stream to convert
|
|
41
|
+
*/
|
|
42
|
+
function streamToString(stream) {
|
|
43
|
+
const chunks = [];
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
46
|
+
stream.on('error', reject);
|
|
47
|
+
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;;;AAGA,8BAEC;AAQD,kCAUC;AAED,8CAYC;AAMD,wCAQC;AAlDD,sDAA8B;AAE9B,SAAgB,SAAS,CAAI,KAA2B;IACtD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,QAAQ,GAAG,CAAC;IACrD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAErC,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,EAAE,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAExE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,C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CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@libstermynal/transcript-v2",
|
|
3
|
+
"version": "3.3.2",
|
|
4
|
+
"description": "(Forked for fixes) A nicely formatted html transcript generator for discord.js.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"homepage": "https://github.com/ddust1n/discord-html-transcripts",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ddust1n/discord-html-transcripts.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"discord.js",
|
|
14
|
+
"discord.js-transcripts",
|
|
15
|
+
"discord.js-html-transcripts",
|
|
16
|
+
"html-transcripts",
|
|
17
|
+
"discord-html-transcripts",
|
|
18
|
+
"discord-transcripts"
|
|
19
|
+
],
|
|
20
|
+
"author": "Derock <derock@derock.dev>",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*.js",
|
|
24
|
+
"dist/**/*.d.ts",
|
|
25
|
+
"dist/**/*.js.map"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
29
|
+
"@eslint/js": "^9.39.2",
|
|
30
|
+
"@types/debug": "^4.1.12",
|
|
31
|
+
"@types/node": "^24.10.4",
|
|
32
|
+
"@types/react": "^19.2.7",
|
|
33
|
+
"@types/react-dom": "^19.2.3",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.50.0",
|
|
36
|
+
"discord.js": "^14.25.1",
|
|
37
|
+
"dotenv": "^17.2.3",
|
|
38
|
+
"eslint": "^9.39.2",
|
|
39
|
+
"globals": "^16.5.0",
|
|
40
|
+
"husky": "^9.1.7",
|
|
41
|
+
"prettier": "^3.7.4",
|
|
42
|
+
"pretty-quick": "^4.2.2",
|
|
43
|
+
"sharp": "^0.34.5",
|
|
44
|
+
"ts-node": "^10.9.2",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@lit-labs/ssr": "^3.3.1",
|
|
49
|
+
"@skyra/discord-components-core": "^4.0.2",
|
|
50
|
+
"debug": "^4.4.3",
|
|
51
|
+
"discord-markdown-parser": "~1.3.1",
|
|
52
|
+
"highlight.js": "^11.11.1",
|
|
53
|
+
"react": "19.1.1",
|
|
54
|
+
"react-dom": "19.1.1",
|
|
55
|
+
"simple-markdown": "^0.7.3",
|
|
56
|
+
"twemoji": "^14.0.2",
|
|
57
|
+
"undici": "^7.16.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"discord.js": "^14.0.0 || ^15.0.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
64
|
+
"build": "tsc -p tsconfig.json",
|
|
65
|
+
"test:typescript": "ts-node --project tsconfig.test.json ./tests/generate.ts",
|
|
66
|
+
"test:send-components-v2": "ts-node ./tests/components-v2-send.ts",
|
|
67
|
+
"lint": "prettier --write --cache . && eslint --cache --fix .",
|
|
68
|
+
"typecheck": "tsc -p tsconfig.eslint.json"
|
|
69
|
+
}
|
|
70
|
+
}
|