Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add types

Manav Rathic918a796af85
diff --git a/desktop/src/types/clip-bpe-js.ts b/desktop/src/main/types/clip-bpe-js.d.ts
similarity index 69%
rename from desktop/src/types/clip-bpe-js.ts
rename to desktop/src/main/types/clip-bpe-js.d.ts
index 269ebf28fc..575b5fe127 100644
--- a/desktop/src/types/clip-bpe-js.ts
+++ b/desktop/src/main/types/clip-bpe-js.d.ts
@@ -1,9 +1,8 @@
/**
- * @file Types for "clip-bpe-js"
+ * Types for [clip-bpe-js](https://github.com/josephrocca/clip-bpe-js).
*
* Non exhaustive, only the function we need.
*/
-
declare module "clip-bpe-js" {
class Tokenizer {
encodeForCLIP(text: string): number[];
diff --git a/web/packages/new/photos/services/exif-update.ts b/web/packages/new/photos/services/exif-update.ts
index 09f8fd1a84..c08d404d5c 100644
--- a/web/packages/new/photos/services/exif-update.ts
+++ b/web/packages/new/photos/services/exif-update.ts
@@ -14,10 +14,8 @@ export const updateFileCreationDateInEXIF = async (
"data:image/jpeg;base64" +
imageDataURL.slice(imageDataURL.indexOf(","));
const exifObj = piexif.load(imageDataURL);
- if (!exifObj["Exif"]) {
- exifObj["Exif"] = {};
- }
- exifObj["Exif"][piexif.ExifIFD.DateTimeOriginal] =
+ if (!exifObj.Exif) exifObj.Exif = {};
+ exifObj.Exif[piexif.ExifIFD.DateTimeOriginal] =
convertToExifDateFormat(updatedDate);
log.debug(() => [
"updateFileCreationDateInEXIF",
diff --git a/web/packages/new/photos/types/piexifjs.d.ts b/web/packages/new/photos/types/piexifjs.d.ts
new file mode 100644
index 0000000000..211ee9754e
--- /dev/null
+++ b/web/packages/new/photos/types/piexifjs.d.ts
@@ -0,0 +1,42 @@
+/**
+ * Types for [piexifjs](https://github.com/hMatoba/piexifjs).
+ *
+ * Non exhaustive, only the function we need.
+ */
+declare module "piexifjs" {
+ interface ExifObj {
+ Exif?: Record<number, unknown>;
+ }
+
+ interface Piexifjs {
+ /**
+ * Get exif data as object.
+ *
+ * @param jpegData a string that starts with "data:image/jpeg;base64,"
+ * (a data URL), "\xff\xd8", or "Exif".
+ */
+ load: (jpegData: string) => ExifObj;
+ /**
+ * Get exif as string to insert into JPEG.
+ *
+ * @param exifObj An object obtained using {@link load}.
+ */
+ dump: (exifObj: ExifObj) => string;
+ /**
+ * Insert exif into JPEG.
+ *
+ * If {@link jpegData} is a data URL, returns the modified JPEG as a
+ * data URL. Else if {@link jpegData} is binary as string, returns JPEG
+ * as binary as string.
+ */
+ insert: (exifStr: string, jpegData: string) => string;
+ /**
+ * Keys for the tags in {@link ExifObj}.
+ */
+ ExifIFD: {
+ DateTimeOriginal: number;
+ };
+ }
+ const piexifjs: Piexifjs;
+ export default piexifjs;
+}