markdown-exit-s3-image 1.0.0 → 1.0.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/dist/index.mjs +4 -5
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { promises } from "node:fs";
|
|
2
|
+
import { thumbHashToDataURL } from "thumbhash";
|
|
2
3
|
|
|
3
4
|
//#region src/cache.ts
|
|
4
5
|
var ImageCache = class {
|
|
@@ -39,7 +40,7 @@ var ImageCache = class {
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
get(key) {
|
|
42
|
-
const decodedKey =
|
|
43
|
+
const decodedKey = decodeURI(key);
|
|
43
44
|
if (this.cache[decodedKey]) {
|
|
44
45
|
this.stats.cacheHits++;
|
|
45
46
|
return this.cache[decodedKey];
|
|
@@ -48,7 +49,7 @@ var ImageCache = class {
|
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
set(key, value) {
|
|
51
|
-
const decodedKey =
|
|
52
|
+
const decodedKey = decodeURI(key);
|
|
52
53
|
if (JSON.stringify(this.cache[decodedKey]) !== JSON.stringify(value)) {
|
|
53
54
|
this.cache[decodedKey] = value;
|
|
54
55
|
this.isDirty = true;
|
|
@@ -150,9 +151,7 @@ async function getBitifulThumbhash(imageUrl) {
|
|
|
150
151
|
const response = await fetch(`${baseUrl}?fmt=thumbhash`);
|
|
151
152
|
if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
152
153
|
const base64String = await response.text();
|
|
153
|
-
|
|
154
|
-
const { thumbHashToDataURL } = await import("thumbhash");
|
|
155
|
-
return thumbHashToDataURL(thumbhashBytes);
|
|
154
|
+
return thumbHashToDataURL(new Uint8Array(Buffer.from(base64String.trim(), "base64")));
|
|
156
155
|
} catch (error) {
|
|
157
156
|
console.warn(`[Bitiful] Thumbhash error for ${imageUrl}:`, error instanceof Error ? error.message : String(error));
|
|
158
157
|
return null;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-exit-s3-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"author": "
|
|
5
|
-
"version": "1.0.
|
|
4
|
+
"author": "GnixAij",
|
|
5
|
+
"version": "1.0.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -40,5 +40,8 @@
|
|
|
40
40
|
"@types/node": "^24.10.1",
|
|
41
41
|
"tsdown": "^0.16.6",
|
|
42
42
|
"typescript": "^5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"thumbhash": "^0.1.1"
|
|
43
46
|
}
|
|
44
47
|
}
|