mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
renamed itxt function names
This commit is contained in:
parent
770f44019a
commit
6ee38ad826
2 changed files with 7 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
import tEXt from "png-chunk-text";
|
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 encodePng from "png-chunks-encode";
|
||||||
import decodePng from "png-chunks-extract";
|
import decodePng from "png-chunks-extract";
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export const getMetadataChunk = async (
|
||||||
|
|
||||||
if (iTXtChunk) {
|
if (iTXtChunk) {
|
||||||
try {
|
try {
|
||||||
const decoded = decodeITXt(iTXtChunk.data);
|
const decoded = decodeSync(iTXtChunk.data);
|
||||||
console.log("Decoded iTXt chunk:", decoded);
|
console.log("Decoded iTXt chunk:", decoded);
|
||||||
return {
|
return {
|
||||||
keyword: decoded.keyword,
|
keyword: decoded.keyword,
|
||||||
|
@ -67,7 +67,7 @@ export const encodePngMetadata = async ({
|
||||||
!(chunk.name === "tEXt" &&
|
!(chunk.name === "tEXt" &&
|
||||||
tEXt.decode(chunk.data).keyword === MIME_TYPES.excalidraw) &&
|
tEXt.decode(chunk.data).keyword === MIME_TYPES.excalidraw) &&
|
||||||
!(chunk.name === "iTXt" &&
|
!(chunk.name === "iTXt" &&
|
||||||
decodeITXt(chunk.data).keyword === MIME_TYPES.excalidraw)
|
decodeSync(chunk.data).keyword === MIME_TYPES.excalidraw)
|
||||||
);
|
);
|
||||||
|
|
||||||
const encodedData = JSON.stringify(
|
const encodedData = JSON.stringify(
|
||||||
|
@ -80,7 +80,7 @@ export const encodePngMetadata = async ({
|
||||||
let metadataChunk;
|
let metadataChunk;
|
||||||
try {
|
try {
|
||||||
if (useITXt) {
|
if (useITXt) {
|
||||||
metadataChunk = encodeITXt(
|
metadataChunk = encodeSync(
|
||||||
MIME_TYPES.excalidraw,
|
MIME_TYPES.excalidraw,
|
||||||
encodedData,
|
encodedData,
|
||||||
{
|
{
|
||||||
|
|
6
packages/excalidraw/global.d.ts
vendored
6
packages/excalidraw/global.d.ts
vendored
|
@ -43,12 +43,12 @@ declare module "png-chunk-text" {
|
||||||
function decode(data: Uint8Array): { keyword: string; text: string };
|
function decode(data: Uint8Array): { keyword: string; text: string };
|
||||||
}
|
}
|
||||||
declare module "png-chunk-itxt" {
|
declare module "png-chunk-itxt" {
|
||||||
function encode(
|
function encodeSync(
|
||||||
keyword: string,
|
keyword: string,
|
||||||
text: string,
|
text: string,
|
||||||
options?: { compressed?: boolean; compressedMethod: number; language?: string; translated?: string },
|
options?: { compressed?: boolean; compressedMethod: number; language?: string; translated?: string },
|
||||||
): { name: "iTXt"; data: Uint8Array };
|
): { name: "iTXt"; data: Uint8Array };
|
||||||
function decode(data: Uint8Array): {
|
function decodeSync (data: Uint8Array): {
|
||||||
keyword: string;
|
keyword: string;
|
||||||
text: string;
|
text: string;
|
||||||
compressed?: boolean;
|
compressed?: boolean;
|
||||||
|
@ -56,7 +56,7 @@ declare module "png-chunk-itxt" {
|
||||||
language?: string;
|
language?: string;
|
||||||
translated?: string;
|
translated?: string;
|
||||||
};
|
};
|
||||||
export { encode, decode };
|
export { encodeSync, decodeSync };
|
||||||
}
|
}
|
||||||
declare module "png-chunks-encode" {
|
declare module "png-chunks-encode" {
|
||||||
function encode(chunks: (TEXtChunk | ITXtChunk)[]): Uint8Array;
|
function encode(chunks: (TEXtChunk | ITXtChunk)[]): Uint8Array;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue