@pi-archimedes/image-paste 0.3.2 → 0.4.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.
- package/package.json +1 -1
- package/src/clipboard.ts +8 -2
package/package.json
CHANGED
package/src/clipboard.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
3
5
|
|
|
4
6
|
import type { ClipboardImage } from "./types.js";
|
|
5
7
|
|
|
@@ -18,6 +20,11 @@ const SUPPORTED_IMAGE_MIME_TYPES = [
|
|
|
18
20
|
|
|
19
21
|
let cachedClipboardModule: ClipboardModule | null | undefined;
|
|
20
22
|
|
|
23
|
+
/** Reset the clipboard module cache — allows retry after install. */
|
|
24
|
+
export function resetClipboardModuleCache(): void {
|
|
25
|
+
cachedClipboardModule = undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
interface ClipboardModule {
|
|
22
29
|
hasImage: () => boolean;
|
|
23
30
|
getImageBinary: () => Promise<Array<number> | Uint8Array>;
|
|
@@ -389,8 +396,7 @@ export async function readClipboardImage(options?: {
|
|
|
389
396
|
throw new Error(getUnavailableReaderMessage(platform));
|
|
390
397
|
}
|
|
391
398
|
|
|
392
|
-
|
|
393
|
-
import { readFile } from "node:fs/promises";
|
|
399
|
+
// ── File-based image reading ────────────────────────────────────────────────
|
|
394
400
|
|
|
395
401
|
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp"]);
|
|
396
402
|
|