@social-mail/social-mail-web-server 1.5.72 → 1.5.73

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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.5.72",
3
+ "version": "1.5.73",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2,19 +2,23 @@ import { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
2
2
  import { dirname, join } from "path";
3
3
  import { fileURLToPath } from "url";
4
4
 
5
- const metaDir = dirname(import.meta.url);
6
- const folder = join(fileURLToPath(metaDir), "..", "..", "images");
5
+ const metaDir = fileURLToPath(dirname(import.meta.url));
7
6
 
8
- export const ImagesFolder = {
9
- folder,
10
- file: (name) =>
11
- join(folder, name)
12
- };
7
+ class PackageFolder {
8
+ constructor(public readonly folder: string) {
13
9
 
10
+ }
14
11
 
15
- const contentFolder = join(fileURLToPath(metaDir), "..", "..", "content");
16
- export const ContentFolder = {
17
- folder: contentFolder,
18
- file: (name) => join(contentFolder, name),
19
- localFile: (name: string) => new LocalFile(join(contentFolder, name), name.split("/").pop(), void 0, () => void 0)
20
- };
12
+ file(... names) {
13
+ return join(this.folder, ... names);
14
+ }
15
+
16
+ localFile(... names) {
17
+ const path= join(this.folder, ... names);
18
+ return new LocalFile(path, names.pop(), void 0, () => void 0);
19
+ }
20
+ }
21
+
22
+ export const ImagesFolder = new PackageFolder(join(metaDir, "..", "..", "images"));
23
+
24
+ export const contentFolder = new PackageFolder(join(metaDir, "..", "..", "content"));
@@ -9,8 +9,7 @@ import { spawnPromise } from "../../../common/spawnPromise.js";
9
9
  import { copyFile, readdir } from "fs/promises";
10
10
  import FFCommand from "../convert/FFCommand.js";
11
11
  import ensureDir from "../../../common/FileApi.js";
12
- import { existsSync } from "fs";
13
- import { ContentFolder } from "../../../common/ImagesFolder.js";
12
+ import { ImagesFolder } from "../../../common/ImagesFolder.js";
14
13
 
15
14
  const cachePath = `./data/img-cache/`;
16
15
 
@@ -81,12 +80,8 @@ export default class ImageConverterService {
81
80
  }
82
81
  }
83
82
 
84
- if (!existsSync(outputFile.path)) {
85
- // copy protected.pdf
86
- if (retry) {
87
- const src = ContentFolder.localFile("pdf/protected.pdf");
88
- return await this.getImage(src, pageNumber, false);
89
- }
83
+ if (!outputFile.exists) {
84
+ return ImagesFolder.localFile("png", "protected.png");
90
85
  }
91
86
  }
92
87
 
@@ -129,6 +124,9 @@ export default class ImageConverterService {
129
124
  }
130
125
 
131
126
  file = await this.getImage(file, args?.[2] ?? void 0);
127
+ if (!file.exists) {
128
+ file = ImagesFolder.localFile("png", "unavailable.png");
129
+ }
132
130
 
133
131
  const { default: fx } = await import("./formats/" + fileName + ".js");
134
132
  let r: sharp.Sharp = await fx(file, ... args);