sweety-html-transcripts 0.2.0 → 0.2.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.
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAiC;AACjC,kDAA0B;AAiB1B;;GAEG;AACH,MAAa,yBAAyB;IAAtC;QAEU,QAAG,GAAG,yBAAyB,CAAC,GAAG,CAAC;IAsF9C,CAAC;IA7EC;;;OAGG;IACH,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAO,GAAG,EAAE,EAAE,aAAa,GAAG,KAAK,EAAE,UAAkD,EAAE;QACvG,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAEvF,uBAAuB;QACvB,kDAAO,OAAO,IAAE,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,KAAK,CACX,6KAA6K,CAC9K,CAAC;QACJ,CAA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AE,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/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "sweety-html-transcripts",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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/**/*.js",
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.2",
49
- "@types/react": "^19.2.13",
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.54.0",
52
- "@typescript-eslint/parser": "^8.54.0",
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.1+sha512.48dae233635a645768a3028d19545cacc1688639eeb1f3734e42d6d6b971afbf22aa1ac9af52a173d9c3a20c15857cfa400f19994d79a2f626fcc73fccda9bbc"
99
+ "packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc"
90
100
  }