@social-mail/social-mail-web-server 1.7.697 → 1.7.699
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.
- package/dist/server/services/puppeteer/PuppeteerService.d.ts +13 -1
- package/dist/server/services/puppeteer/PuppeteerService.d.ts.map +1 -1
- package/dist/server/services/puppeteer/PuppeteerService.js +143 -2
- package/dist/server/services/puppeteer/PuppeteerService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wwwroot/routes/social-mail/site/preview/get.d.ts +2 -2
- package/dist/wwwroot/routes/social-mail/site/preview/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/preview/get.js +13 -105
- package/dist/wwwroot/routes/social-mail/site/preview/get.js.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/templates/list/get.d.ts +1 -0
- package/dist/wwwroot/routes/social-mail/site/templates/list/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/templates/list/get.js +9 -3
- package/dist/wwwroot/routes/social-mail/site/templates/list/get.js.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.d.ts +2 -2
- package/dist/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.js +14 -105
- package/dist/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.js.map +1 -1
- package/package.json +3 -3
- package/src/server/services/puppeteer/PuppeteerService.ts +89 -1
- package/src/wwwroot/routes/social-mail/site/preview/get.tsx +12 -44
- package/src/wwwroot/routes/social-mail/site/templates/list/get.tsx +9 -3
- package/src/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.tsx +8 -38
|
@@ -11,43 +11,27 @@ import HttpProxyService from "../../../../../server/services/http/HttpProxyServi
|
|
|
11
11
|
import SiteDiskContentCache from "../../../../../server/services/files/SiteDiskContentCache.js";
|
|
12
12
|
import LockFile from "../../../../../server/storage/LockFile.js";
|
|
13
13
|
import { Route } from "@entity-access/server-pages/dist/core/Route.js";
|
|
14
|
+
import PuppeteerService from "../../../../../server/services/puppeteer/PuppeteerService.js";
|
|
14
15
|
|
|
15
16
|
let port = globalEnv.puppeteer.port as any;
|
|
16
17
|
if (/^\d+$/i.test(port)) {
|
|
17
18
|
port = Number(port);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const dispatcher = new Agent({
|
|
21
|
-
connect: (options, callback) => {
|
|
22
|
-
try {
|
|
23
|
-
const s= connect({
|
|
24
|
-
port,
|
|
25
|
-
host: globalEnv.puppeteer.host
|
|
26
|
-
}, () => callback(null, s));
|
|
27
|
-
s.on("error", (e) => {
|
|
28
|
-
console.error(e);
|
|
29
|
-
callback(e, null);
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
callback(error, null);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
21
|
export default class extends Page {
|
|
38
22
|
|
|
39
23
|
@Inject
|
|
40
24
|
wcs: WebSiteContentService;
|
|
41
25
|
|
|
42
|
-
@Inject
|
|
43
|
-
siteCache: SiteDiskContentCache;
|
|
44
|
-
|
|
45
26
|
@Query("mobile")
|
|
46
27
|
mobile;
|
|
47
28
|
|
|
48
29
|
@Query("cache-key")
|
|
49
30
|
cacheKey;
|
|
50
31
|
|
|
32
|
+
@Inject
|
|
33
|
+
puppeteerService: PuppeteerService;
|
|
34
|
+
|
|
51
35
|
async run() {
|
|
52
36
|
|
|
53
37
|
const snapshot = await this.wcs.getCurrentSnapshotFolder(this.request.hostName);
|
|
@@ -73,31 +57,15 @@ export default class extends Page {
|
|
|
73
57
|
deviceScaleFactor = 2;
|
|
74
58
|
}
|
|
75
59
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const file = await this.siteCache.htmlCache.getOrCreateAsync(key, async (lf) => {
|
|
79
|
-
|
|
80
|
-
using _ = await LockFile.lock("puppeteer-preview-generator");
|
|
81
|
-
|
|
82
|
-
const query = new URLSearchParams({
|
|
83
|
-
url: `https://${this.request.hostName}`,
|
|
84
|
-
width,
|
|
85
|
-
height,
|
|
86
|
-
deviceScaleFactor,
|
|
87
|
-
output: "webp"
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const r = await fetch(`http://localhost/screen-shot?${query.toString()}`, {
|
|
91
|
-
dispatcher
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
if(r.status !== 200) {
|
|
95
|
-
throw new Error(await r.text());
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const buffer = Buffer.from( await r.arrayBuffer());
|
|
60
|
+
const packageHash = await this.wcs.getPackagesHash();
|
|
99
61
|
|
|
100
|
-
|
|
62
|
+
const file = await this.puppeteerService.generate({
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
deviceScaleFactor,
|
|
66
|
+
packageHash,
|
|
67
|
+
url: `https://${this.request.hostName}`,
|
|
68
|
+
output: "webp"
|
|
101
69
|
});
|
|
102
70
|
|
|
103
71
|
const [ fileName = "preview.webp" ] = this.childPath as any[];
|
|
@@ -23,6 +23,9 @@ export default class extends Page {
|
|
|
23
23
|
@Query("search")
|
|
24
24
|
search: string;
|
|
25
25
|
|
|
26
|
+
@Query.caseInsensitiveAsBoolean
|
|
27
|
+
withoutCdn: string;
|
|
28
|
+
|
|
26
29
|
async run() {
|
|
27
30
|
|
|
28
31
|
if (!/^(www\.)?esocialmail.com$/i.test(this.request.hostName)) {
|
|
@@ -68,17 +71,20 @@ export default class extends Page {
|
|
|
68
71
|
.include((x) => [x.folder, x.hosts, x.webSiteTags.forEach((t) => t.tag)])
|
|
69
72
|
.toArray();
|
|
70
73
|
|
|
74
|
+
const cdn = this.withoutCdn
|
|
75
|
+
? this.request.hostName
|
|
76
|
+
: globalEnv.cdn ?? this.request.hostName;
|
|
77
|
+
|
|
71
78
|
const items = list.map((x) => {
|
|
72
79
|
const { host } = x.hosts[0];
|
|
73
|
-
const cdn = globalEnv.cdn ?? this.request.hostName;
|
|
74
80
|
const { currentVersionID } = x;
|
|
75
81
|
return {
|
|
76
82
|
id: x.folderID,
|
|
77
83
|
tags: x.webSiteTags?.map((t) => t.tag.name) ?? [],
|
|
78
84
|
name: x.folder.name,
|
|
79
85
|
host,
|
|
80
|
-
preview: `https://${cdn}/social-mail/site/templates/preview/${host}/desktop/
|
|
81
|
-
previewMobile: `https://${cdn}/social-mail/site/templates/preview/${host}/mobile/
|
|
86
|
+
preview: `https://${cdn}/social-mail/site/templates/preview/${host}/desktop/c4-${currentVersionID}/desktop-preview-1.webp`,
|
|
87
|
+
previewMobile: `https://${cdn}/social-mail/site/templates/preview/${host}/mobile/c4-${currentVersionID}/desktop-preview-1.webp`,
|
|
82
88
|
url: `https://${host}`
|
|
83
89
|
};
|
|
84
90
|
});
|
package/src/wwwroot/routes/social-mail/site/templates/preview/[host]/[type]/[cacheKey]/get.tsx
CHANGED
|
@@ -14,43 +14,27 @@ import CacheService from "../../../../../../../../../server/services/cache/Cache
|
|
|
14
14
|
import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
|
|
15
15
|
import TempFileService from "../../../../../../../../../server/storage/TempFileService.js";
|
|
16
16
|
import { Retry } from "../../../../../../../../../common/Retry.js";
|
|
17
|
+
import PuppeteerService from "../../../../../../../../../server/services/puppeteer/PuppeteerService.js";
|
|
17
18
|
|
|
18
19
|
let port = globalEnv.puppeteer.port as any;
|
|
19
20
|
if (/^\d+$/i.test(port)) {
|
|
20
21
|
port = Number(port);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const dispatcher = new Agent({
|
|
24
|
-
connect: (options, callback) => {
|
|
25
|
-
try {
|
|
26
|
-
const s= connect({
|
|
27
|
-
port,
|
|
28
|
-
host: globalEnv.puppeteer.host
|
|
29
|
-
}, () => callback(null, s));
|
|
30
|
-
s.on("error", (e) => {
|
|
31
|
-
console.error(e);
|
|
32
|
-
callback(e, null);
|
|
33
|
-
});
|
|
34
|
-
} catch (error) {
|
|
35
|
-
callback(error, null);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
24
|
export default class extends Page {
|
|
41
25
|
|
|
42
26
|
@Inject
|
|
43
27
|
wcs: WebSiteContentService;
|
|
44
28
|
|
|
45
|
-
@Inject
|
|
46
|
-
siteCache: SiteDiskContentCache;
|
|
47
|
-
|
|
48
29
|
@Inject
|
|
49
30
|
cacheService: CacheService;
|
|
50
31
|
|
|
51
32
|
@Inject
|
|
52
33
|
tfs: TempFileService;
|
|
53
34
|
|
|
35
|
+
@Inject
|
|
36
|
+
puppeteerService: PuppeteerService;
|
|
37
|
+
|
|
54
38
|
@Route("type")
|
|
55
39
|
type;
|
|
56
40
|
|
|
@@ -97,31 +81,17 @@ export default class extends Page {
|
|
|
97
81
|
ttl: TimeSpan.fromDays(30),
|
|
98
82
|
factory: (c) => Retry.retry(async () => {
|
|
99
83
|
|
|
100
|
-
|
|
84
|
+
const url = `https://${this.host}`;
|
|
101
85
|
|
|
102
|
-
|
|
103
|
-
url: `https://${this.host}`,
|
|
86
|
+
return await this.puppeteerService.generate({
|
|
104
87
|
width,
|
|
105
88
|
height,
|
|
106
89
|
deviceScaleFactor,
|
|
90
|
+
packageHash,
|
|
91
|
+
url,
|
|
107
92
|
output: "webp"
|
|
108
93
|
});
|
|
109
94
|
|
|
110
|
-
const r = await fetch(`http://localhost/screen-shot?${query.toString()}`, {
|
|
111
|
-
dispatcher
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (r.status >= 399) {
|
|
115
|
-
throw new Error(await r.text());
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const buffer = Buffer.from( await r.arrayBuffer());
|
|
119
|
-
|
|
120
|
-
const lf = await this.tfs.createTempFile(".webp", "preview.webp", "image/webp");
|
|
121
|
-
|
|
122
|
-
await lf.writeAll(buffer);
|
|
123
|
-
|
|
124
|
-
return lf;
|
|
125
95
|
})
|
|
126
96
|
});
|
|
127
97
|
|