sweety-html-transcripts 0.2.0 → 0.2.3
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.
|
@@ -14,8 +14,6 @@ export type ResolveImageCallback = (attachment: APIAttachment, message: APIMessa
|
|
|
14
14
|
* Builder to build a image saving callback.
|
|
15
15
|
*/
|
|
16
16
|
export declare class TranscriptImageDownloader {
|
|
17
|
-
private static log;
|
|
18
|
-
private log;
|
|
19
17
|
private maxFileSize?;
|
|
20
18
|
private compression?;
|
|
21
19
|
/**
|
|
@@ -32,20 +32,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.TranscriptImageDownloader = void 0;
|
|
40
37
|
const undici_1 = require("undici");
|
|
41
|
-
const debug_1 = __importDefault(require("debug"));
|
|
42
38
|
/**
|
|
43
39
|
* Builder to build a image saving callback.
|
|
44
40
|
*/
|
|
45
41
|
class TranscriptImageDownloader {
|
|
46
|
-
constructor() {
|
|
47
|
-
this.log = TranscriptImageDownloader.log;
|
|
48
|
-
}
|
|
49
42
|
/**
|
|
50
43
|
* Sets the maximum file size for *each* individual image.
|
|
51
44
|
* @param size The maximum file size in kilobytes
|
|
@@ -83,7 +76,6 @@ class TranscriptImageDownloader {
|
|
|
83
76
|
if (this.maxFileSize && attachment.size > this.maxFileSize * 1024)
|
|
84
77
|
return undefined;
|
|
85
78
|
// fetch the image
|
|
86
|
-
this.log(`Fetching attachment ${attachment.id}: ${attachment.url}`);
|
|
87
79
|
const response = await (0, undici_1.request)(attachment.url).catch((err) => {
|
|
88
80
|
console.error(`[sweety-html-transcripts] Failed to download image for transcript: `, err);
|
|
89
81
|
return null;
|
|
@@ -92,11 +84,9 @@ class TranscriptImageDownloader {
|
|
|
92
84
|
return undefined;
|
|
93
85
|
const mimetype = response.headers['content-type'];
|
|
94
86
|
const buffer = await response.body.arrayBuffer().then((res) => Buffer.from(res));
|
|
95
|
-
this.log(`Finished fetching ${attachment.id} (${buffer.length} bytes)`);
|
|
96
87
|
// if the compression options are set, compress the image
|
|
97
88
|
if (this.compression) {
|
|
98
89
|
const sharp = await Promise.resolve().then(() => __importStar(require('sharp')));
|
|
99
|
-
this.log(`Compressing ${attachment.id} with 'sharp'`);
|
|
100
90
|
const sharpbuf = await sharp
|
|
101
91
|
.default(buffer)
|
|
102
92
|
.webp({
|
|
@@ -106,7 +96,6 @@ class TranscriptImageDownloader {
|
|
|
106
96
|
...this.compression.options,
|
|
107
97
|
})
|
|
108
98
|
.toBuffer({ resolveWithObject: true });
|
|
109
|
-
this.log(`Finished compressing ${attachment.id} (${sharpbuf.info.size} bytes)`);
|
|
110
99
|
return `data:image/${sharpbuf.info.format};base64,${sharpbuf.data.toString('base64')}`;
|
|
111
100
|
}
|
|
112
101
|
// return the base64 string
|
|
@@ -115,5 +104,4 @@ class TranscriptImageDownloader {
|
|
|
115
104
|
}
|
|
116
105
|
}
|
|
117
106
|
exports.TranscriptImageDownloader = TranscriptImageDownloader;
|
|
118
|
-
TranscriptImageDownloader.log = (0, debug_1.default)('sweety-html-transcripts:TranscriptImageDownloader');
|
|
119
107
|
//# sourceMappingURL=images.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/downloader/images.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/downloader/images.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAiC;AAiBjC;;GAEG;AACH,MAAa,yBAAyB;IAQpC;;;OAGG;IACH,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,WAAW,GAAG,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ClD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAEjF,yDAAyD;YACzD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,MAAM,KAAK,GAAG,wDAAa,OAAO,GAAC,CAAC;gBAEpC,MAAM,QAAQ,GAAG,MAAM,KAAK;qBACzB,OAAO,CAAC,MAAM,CAAC;qBACf,IAAI,CAAC;oBACJ,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO;oBACjC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa;oBACrC,MAAM,EAAE,CAAC;oBACT,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO;iBAC5B,CAAC;qBACD,QAAQ,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;gBAEzC,OAAO,cAAc,QAAQ,CAAC,IAAI,CAAC,MAAM,WAAW,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzF,CAAC;YAED,2BAA2B;YAC3B,OAAO,QAAQ,QAAQ,WAAW,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC;CACF;AAjFD,8DAiFC"}
|
package/dist/utils/profiles.js
CHANGED
|
@@ -11,6 +11,9 @@ async function buildProfiles(context) {
|
|
|
11
11
|
const profiles = {};
|
|
12
12
|
// loop through messages
|
|
13
13
|
for (const message of messages) {
|
|
14
|
+
// for some reason, some messages don't have an author but have a user_id
|
|
15
|
+
if (typeof message.author === 'undefined' && 'user_id' in message && message.user_id)
|
|
16
|
+
message.author = (await adapter.resolveUser(message.user_id));
|
|
14
17
|
// add all users
|
|
15
18
|
const author = message.author;
|
|
16
19
|
if (!profiles[author.id]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/utils/profiles.ts"],"names":[],"mappings":";;AA2BA,
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/utils/profiles.ts"],"names":[],"mappings":";;AA2BA,sCAwCC;AAlED,+CAAkD;AAGlD,uCAAyC;AACzC,iCAAmC;AACnC,mCAAgD;AAChD,mCAAqC;AAoB9B,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEtC,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAE7C,wBAAwB;IACxB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,yEAAyE;QACzE,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,SAAS,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO;YAClF,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAE,CAAC;QAEjE,gBAAgB;QAChB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YACzB,cAAc;YACd,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,QAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACvF,CAAC;QAED,wBAAwB;QACxB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;YACjC,sFAAsF;YACtF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CA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AAa,CAAC,KAAK,EAAE;gBAC3F,IAAI,EAAE,EAAE;gBACR,SAAS,EAAE,KAAK;aACjB,CAAC;KACa,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sweety-html-transcripts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A sweety formatted html transcript generator for discord bots.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"homepage": "https://github.com/Ganyu-Studios/sweety-html-transcripts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"homepage": "https://github.com/Ganyu-Studios/sweety-html-transcripts",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "tsc -p tsconfig.json",
|
|
10
11
|
"prepack": "npm run build",
|
|
12
|
+
"prepare": "npm run build",
|
|
11
13
|
"lint": "prettier --write --cache . && eslint --cache --fix .",
|
|
12
14
|
"typecheck": "tsc -p tsconfig.eslint.json",
|
|
13
15
|
"vite": "vite",
|
|
@@ -15,6 +17,18 @@
|
|
|
15
17
|
"test:djs": "tsx ./tests/djs-generate.ts",
|
|
16
18
|
"update-components": "pnpm update @penwin/*@latest"
|
|
17
19
|
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./adapters/*": {
|
|
27
|
+
"import": "./dist/adapters/*.js",
|
|
28
|
+
"require": "./dist/adapters/*.js",
|
|
29
|
+
"types": "./dist/adapters/*.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
18
32
|
"repository": {
|
|
19
33
|
"type": "git",
|
|
20
34
|
"url": "git+https://github.com/Ganyu-Studios/sweety-html-transcripts.git"
|
|
@@ -36,25 +50,21 @@
|
|
|
36
50
|
}
|
|
37
51
|
],
|
|
38
52
|
"files": [
|
|
39
|
-
"dist
|
|
40
|
-
"dist/**/*.d.ts",
|
|
41
|
-
"dist/**/*.js.map"
|
|
53
|
+
"dist/**"
|
|
42
54
|
],
|
|
43
55
|
"devDependencies": {
|
|
44
56
|
"@eslint/eslintrc": "^3.3.3",
|
|
45
57
|
"@eslint/js": "^10.0.1",
|
|
46
58
|
"@penwin/discord-components-core": "^4.3.8",
|
|
47
59
|
"@types/debug": "^4.1.12",
|
|
48
|
-
"@types/node": "^25.2.
|
|
49
|
-
"@types/react": "^19.2.
|
|
60
|
+
"@types/node": "^25.2.3",
|
|
61
|
+
"@types/react": "^19.2.14",
|
|
50
62
|
"@types/react-dom": "^19.2.3",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
52
|
-
"@typescript-eslint/parser": "^8.
|
|
53
|
-
"debug": "^4.4.3",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
64
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
54
65
|
"dotenv": "^17.2.4",
|
|
55
66
|
"eslint": "^10.0.0",
|
|
56
67
|
"globals": "^17.3.0",
|
|
57
|
-
"husky": "^9.1.7",
|
|
58
68
|
"prettier": "^3.8.1",
|
|
59
69
|
"sharp": "^0.34.5",
|
|
60
70
|
"tsx": "^4.21.0",
|
|
@@ -86,5 +96,5 @@
|
|
|
86
96
|
"sharp"
|
|
87
97
|
]
|
|
88
98
|
},
|
|
89
|
-
"packageManager": "pnpm@10.29.
|
|
99
|
+
"packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc"
|
|
90
100
|
}
|