aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts13
-rw-r--r--src/scraping/buxton/final/BuxtonImporter.ts6
-rw-r--r--src/server/DashUploadUtils.ts6
-rw-r--r--src/server/SharedMediaTypes.ts4
4 files changed, 17 insertions, 12 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 53671707e..072e8c612 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -357,6 +357,8 @@ export namespace Docs {
});
const parentProto = Doc.GetProto(parent);
const { _socket } = DocServer;
+ _socket.off(MessageStore.BuxtonDocumentResult.Message);
+ _socket.off(MessageStore.BuxtonImportComplete.Message);
Utils.AddServerHandler(_socket, MessageStore.BuxtonDocumentResult, ({ device, errors }) => {
if (!responded) {
responded = true;
@@ -688,15 +690,12 @@ export namespace Docs {
if (input === undefined || input === null || ![...primitives, "object"].includes(typeof input)) {
return undefined;
}
- let parsed = input;
- if (typeof input === "string") {
- parsed = JSONUtils.tryParse(input);
- }
+ input = JSON.parse(typeof input === "string" ? input : JSON.stringify(input));
let converted: Doc;
- if (typeof parsed === "object" && !(parsed instanceof Array)) {
- converted = convertObject(parsed, title, appendToTarget);
+ if (typeof input === "object" && !(input instanceof Array)) {
+ converted = convertObject(input, title, appendToTarget);
} else {
- (converted = new Doc).json = toField(parsed);
+ (converted = new Doc).json = toField(input);
}
title && (converted.title = title);
return converted;
diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts
index 098671942..47d6bbe83 100644
--- a/src/scraping/buxton/final/BuxtonImporter.ts
+++ b/src/scraping/buxton/final/BuxtonImporter.ts
@@ -43,8 +43,8 @@ export interface AnalysisResult {
type Transformer<T> = (raw: string) => { transformed?: T, error?: string };
export interface ImportResults {
- deviceCount: number,
- errorCount: number
+ deviceCount: number;
+ errorCount: number;
}
type ResultCallback = (result: AnalysisResult) => void;
@@ -300,7 +300,7 @@ async function writeImages(zip: any): Promise<ImageData[]> {
const { width, height, type } = await new Promise<Dimensions>(async resolve => {
const sizeStream = createImageSizeStream().on('size', (dimensions: Dimensions) => {
readStream.destroy();
- resolve(dimensions)
+ resolve(dimensions);
});
const readStream = await streamImage();
readStream.pipe(sizeStream);
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 9ccc860f1..913ddc1c3 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -272,7 +272,7 @@ export namespace DashUploadUtils {
});
};
- const { pngs, jpgs } = AcceptibleMedia;
+ const { pngs, jpgs, webps, tiffs } = AcceptibleMedia;
const pngOptions = {
compressionLevel: 9,
adaptiveFiltering: true,
@@ -316,6 +316,10 @@ export namespace DashUploadUtils {
initial = initial.png(pngOptions);
} else if (jpgs.includes(ext)) {
initial = initial.jpeg();
+ } else if (webps.includes(ext)) {
+ initial = initial.webp();
+ } else if (tiffs.includes(ext)) {
+ initial = initial.tiff();
} else {
initial = undefined;
}
diff --git a/src/server/SharedMediaTypes.ts b/src/server/SharedMediaTypes.ts
index 8d0f441f0..274b4f01e 100644
--- a/src/server/SharedMediaTypes.ts
+++ b/src/server/SharedMediaTypes.ts
@@ -2,7 +2,9 @@ export namespace AcceptibleMedia {
export const gifs = [".gif"];
export const pngs = [".png"];
export const jpgs = [".jpg", ".jpeg"];
- export const imageFormats = [...pngs, ...jpgs, ...gifs];
+ export const webps = [".webp"];
+ export const tiffs = [".tiff"];
+ export const imageFormats = [...pngs, ...jpgs, ...gifs, ...webps, ...tiffs];
export const videoFormats = [".mov", ".mp4"];
export const applicationFormats = [".pdf"];
} \ No newline at end of file