diff --git a/packages/excalidraw/data/image.ts b/packages/excalidraw/data/image.ts index 070889fdf..5796f42fc 100644 --- a/packages/excalidraw/data/image.ts +++ b/packages/excalidraw/data/image.ts @@ -1,5 +1,5 @@ import tEXt from "png-chunk-text"; -import { encode as encodeITXt, decode as decodeITXt } from "png-chunk-itxt"; +import { encodeSync, decodeSync} from "png-chunk-itxt"; import encodePng from "png-chunks-encode"; import decodePng from "png-chunks-extract"; @@ -28,7 +28,7 @@ export const getMetadataChunk = async ( if (iTXtChunk) { try { - const decoded = decodeITXt(iTXtChunk.data); + const decoded = decodeSync(iTXtChunk.data); console.log("Decoded iTXt chunk:", decoded); return { keyword: decoded.keyword, @@ -67,7 +67,7 @@ export const encodePngMetadata = async ({ !(chunk.name === "tEXt" && tEXt.decode(chunk.data).keyword === MIME_TYPES.excalidraw) && !(chunk.name === "iTXt" && - decodeITXt(chunk.data).keyword === MIME_TYPES.excalidraw) + decodeSync(chunk.data).keyword === MIME_TYPES.excalidraw) ); const encodedData = JSON.stringify( @@ -80,7 +80,7 @@ export const encodePngMetadata = async ({ let metadataChunk; try { if (useITXt) { - metadataChunk = encodeITXt( + metadataChunk = encodeSync( MIME_TYPES.excalidraw, encodedData, { diff --git a/packages/excalidraw/global.d.ts b/packages/excalidraw/global.d.ts index 8688d354b..efbaa9292 100644 --- a/packages/excalidraw/global.d.ts +++ b/packages/excalidraw/global.d.ts @@ -43,12 +43,12 @@ declare module "png-chunk-text" { function decode(data: Uint8Array): { keyword: string; text: string }; } declare module "png-chunk-itxt" { - function encode( + function encodeSync( keyword: string, text: string, options?: { compressed?: boolean; compressedMethod: number; language?: string; translated?: string }, ): { name: "iTXt"; data: Uint8Array }; - function decode(data: Uint8Array): { + function decodeSync (data: Uint8Array): { keyword: string; text: string; compressed?: boolean; @@ -56,7 +56,7 @@ declare module "png-chunk-itxt" { language?: string; translated?: string; }; - export { encode, decode }; + export { encodeSync, decodeSync }; } declare module "png-chunks-encode" { function encode(chunks: (TEXtChunk | ITXtChunk)[]): Uint8Array;