@social-mail/social-mail-web-server 1.16.519 → 1.16.521
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/.tsbuildinfo +1 -1
- package/dist/server/services/DBConfig.d.ts +10 -2
- package/dist/server/services/DBConfig.d.ts.map +1 -1
- package/dist/server/services/DBConfig.js +182 -29
- package/dist/server/services/DBConfig.js.map +1 -1
- package/dist/server/services/files/WebSiteContentService.d.ts +0 -1
- package/dist/server/services/files/WebSiteContentService.d.ts.map +1 -1
- package/dist/server/services/files/WebSiteContentService.js +1 -18
- package/dist/server/services/files/WebSiteContentService.js.map +1 -1
- package/dist/server/services/files/web-content/WebContentTranspileService.d.ts +1 -6
- package/dist/server/services/files/web-content/WebContentTranspileService.d.ts.map +1 -1
- package/dist/server/services/files/web-content/WebContentTranspileService.js +4 -19
- package/dist/server/services/files/web-content/WebContentTranspileService.js.map +1 -1
- package/dist/server/services/html/PreviewDraftService.d.ts +1 -10
- package/dist/server/services/html/PreviewDraftService.d.ts.map +1 -1
- package/dist/server/services/html/PreviewDraftService.js +4 -31
- package/dist/server/services/html/PreviewDraftService.js.map +1 -1
- package/dist/server/services/site/SitePreviewGenerator.d.ts +2 -2
- package/dist/server/services/site/SitePreviewGenerator.d.ts.map +1 -1
- package/dist/server/services/site/SitePreviewGenerator.js +4 -4
- package/dist/server/services/site/SitePreviewGenerator.js.map +1 -1
- package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.d.ts +2 -0
- package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.d.ts.map +1 -1
- package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.js +18 -0
- package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.js.map +1 -1
- package/dist/wwwroot/routes/social-mail/config/ui-packages/get.d.ts +2 -2
- package/dist/wwwroot/routes/social-mail/config/ui-packages/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/social-mail/config/ui-packages/get.js +4 -5
- package/dist/wwwroot/routes/social-mail/config/ui-packages/get.js.map +1 -1
- package/package.json +1 -1
- package/src/server/services/DBConfig.ts +70 -9
- package/src/server/services/files/WebSiteContentService.ts +1 -16
- package/src/server/services/files/web-content/WebContentTranspileService.ts +4 -27
- package/src/server/services/html/PreviewDraftService.ts +13 -92
- package/src/server/services/site/SitePreviewGenerator.ts +3 -3
- package/src/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.ts +18 -0
- package/src/wwwroot/routes/social-mail/config/ui-packages/get.tsx +3 -4
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import Inject, { RegisterScoped,
|
|
1
|
+
import Inject, { RegisterScoped, ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
|
|
2
2
|
import SiteDiskContentCache from "../SiteDiskContentCache.js";
|
|
3
3
|
import { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
|
|
4
4
|
import WebSiteContentService from "../WebSiteContentService.js";
|
|
5
5
|
import { JSDOM } from 'jsdom';
|
|
6
6
|
import { join, parse } from "path";
|
|
7
|
-
import DBConfig, {
|
|
7
|
+
import DBConfig, { WebComponentsPackageConfig } from "../../DBConfig.js";
|
|
8
8
|
import { descendentElementIterator } from "../../../../common/html/Html.js";
|
|
9
|
-
import { ICacheContainer, ObjectCache } from "../../../../common/cacheFor.js";
|
|
10
9
|
import { tokenizeRegex } from "../../../../protocols/core/tokenizer.js";
|
|
11
10
|
import { globalEnv } from "../../../../common/globalEnv.js";
|
|
12
11
|
import EncryptionService from "../../encryption/EncryptionService.js";
|
|
@@ -31,9 +30,7 @@ const updateAttribute = (root: string, name: string, element: Element) => {
|
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
@RegisterScoped
|
|
34
|
-
export default class WebContentTranspileService
|
|
35
|
-
extends ServiceObject
|
|
36
|
-
implements ICacheContainer<WebContentTranspileService> {
|
|
33
|
+
export default class WebContentTranspileService {
|
|
37
34
|
|
|
38
35
|
@Inject
|
|
39
36
|
siteCache: SiteDiskContentCache;
|
|
@@ -47,13 +44,8 @@ export default class WebContentTranspileService
|
|
|
47
44
|
@Inject
|
|
48
45
|
ss: SessionSecurity;
|
|
49
46
|
|
|
50
|
-
cache: ObjectCache<any>;
|
|
51
|
-
|
|
52
47
|
packages: { latest: string, version: string }[];
|
|
53
48
|
|
|
54
|
-
postInit() {
|
|
55
|
-
this.cache = this.siteCache.cache;
|
|
56
|
-
}
|
|
57
49
|
|
|
58
50
|
async transformCss(siteFolder: ISiteFolder, srcFile: LocalFile, currentPath: string): Promise<string> {
|
|
59
51
|
const css = await srcFile.readAsText();
|
|
@@ -62,7 +54,7 @@ export default class WebContentTranspileService
|
|
|
62
54
|
|
|
63
55
|
async transformHtml(siteFolder: ISiteFolder, srcFile: LocalFile, currentPath: string, addPreview?: boolean): Promise<string> {
|
|
64
56
|
|
|
65
|
-
await this.
|
|
57
|
+
this.packages = await this.dbConfig.getPackages();
|
|
66
58
|
|
|
67
59
|
const html = await srcFile.readAsText();
|
|
68
60
|
const browser = new JSDOM(html);
|
|
@@ -442,21 +434,6 @@ export default class WebContentTranspileService
|
|
|
442
434
|
node.remove();
|
|
443
435
|
}
|
|
444
436
|
|
|
445
|
-
async loadPackages() {
|
|
446
|
-
const config = this.dbConfig;
|
|
447
|
-
|
|
448
|
-
const packages = [
|
|
449
|
-
await config.get(UIPackageConfig),
|
|
450
|
-
await config.get(WebComponentsPackageConfig),
|
|
451
|
-
await config.get(FAFreePackageConfig)
|
|
452
|
-
];
|
|
453
|
-
|
|
454
|
-
this.packages = packages.map((x) => ({
|
|
455
|
-
latest: x.value.package + "@latest",
|
|
456
|
-
version: x.value.package + "@" + x.value.version
|
|
457
|
-
}));
|
|
458
|
-
}
|
|
459
|
-
|
|
460
437
|
private async rewriteCss(css: string, siteFolder: ISiteFolder, currentPath: string) {
|
|
461
438
|
for (const [_match, group] of tokenizeRegex(css, /url\(((\"[^\"]+\")|([^\)]+))\)/gmi)) {
|
|
462
439
|
if (group) {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import Inject, { RegisterScoped
|
|
1
|
+
import Inject, { RegisterScoped } from "@entity-access/entity-access/dist/di/di.js";
|
|
2
2
|
import { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
|
|
3
3
|
import { JSDOM } from 'jsdom';
|
|
4
4
|
import { join } from "path";
|
|
5
5
|
import WebSite from "../../model/entities/WebSite.js";
|
|
6
6
|
import { descendentElementIterator } from "../../../common/html/Html.js";
|
|
7
7
|
import WebSiteContentService from "../files/WebSiteContentService.js";
|
|
8
|
-
import
|
|
9
|
-
import SiteDiskContentCache from "../files/SiteDiskContentCache.js";
|
|
10
|
-
import DBConfig, { UIPackageConfig, WebComponentsPackageConfig, FAFreePackageConfig } from "../DBConfig.js";
|
|
8
|
+
import DBConfig from "../DBConfig.js";
|
|
11
9
|
import DynamicStyles from "../files/web-content/DynamicStyles.js";
|
|
12
10
|
|
|
13
11
|
@RegisterScoped
|
|
14
|
-
export default class PreviewDraftService
|
|
15
|
-
|
|
16
|
-
cache: ObjectCache<PreviewDraftService>;
|
|
12
|
+
export default class PreviewDraftService {
|
|
17
13
|
|
|
18
14
|
@Inject
|
|
19
15
|
dbConfig: DBConfig;
|
|
@@ -21,29 +17,6 @@ export default class PreviewDraftService extends ServiceObject implements ICache
|
|
|
21
17
|
@Inject
|
|
22
18
|
private websiteService: WebSiteContentService;
|
|
23
19
|
|
|
24
|
-
@Inject
|
|
25
|
-
private siteCache: SiteDiskContentCache;
|
|
26
|
-
|
|
27
|
-
postInit() {
|
|
28
|
-
this.cache = this.siteCache.cache;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@cacheFor()
|
|
32
|
-
async getPackages() {
|
|
33
|
-
const config = this.dbConfig;
|
|
34
|
-
|
|
35
|
-
const packages = [
|
|
36
|
-
await config.get(UIPackageConfig),
|
|
37
|
-
await config.get(WebComponentsPackageConfig),
|
|
38
|
-
await config.get(FAFreePackageConfig)
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
return packages.map((x) => ({
|
|
42
|
-
latest: x.value.package + "@latest",
|
|
43
|
-
version: x.value.package + "@" + x.value.version
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
20
|
async prepareSecureHtml(siteID, site: WebSite, localFile: LocalFile) {
|
|
48
21
|
|
|
49
22
|
const updateAttribute = (root: string, name: string, element: Element) => {
|
|
@@ -117,69 +90,17 @@ export default class PreviewDraftService extends ServiceObject implements ICache
|
|
|
117
90
|
return body;
|
|
118
91
|
}
|
|
119
92
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
const packageReplacements = await this.getPackages();
|
|
126
|
-
for (const { latest, version } of packageReplacements) {
|
|
127
|
-
value = value.replace(latest, version);
|
|
128
|
-
}
|
|
129
|
-
node.setAttribute(attributeName, value);
|
|
93
|
+
async rewriteLink(node: Element, attributeName: string) {
|
|
94
|
+
let value = node.getAttribute(attributeName);
|
|
95
|
+
if (!value) {
|
|
96
|
+
return;
|
|
130
97
|
}
|
|
98
|
+
const packageReplacements = await this.dbConfig.getPackages();
|
|
99
|
+
for (const { latest, version } of packageReplacements) {
|
|
100
|
+
value = value.replace(latest, version);
|
|
101
|
+
}
|
|
102
|
+
node.setAttribute(attributeName, value);
|
|
103
|
+
}
|
|
131
104
|
|
|
132
105
|
|
|
133
|
-
// async prepareHtml(site: WebSite, localFile: LocalFile) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// const updateAttribute = (root: string, name: string, element: Element) => {
|
|
137
|
-
// const value = element.getAttribute(name);
|
|
138
|
-
// if (!value) {
|
|
139
|
-
// return;
|
|
140
|
-
// }
|
|
141
|
-
// if (value.startsWith(".")) {
|
|
142
|
-
// const v = join(root, value);
|
|
143
|
-
// element.setAttribute(name, v.toString());
|
|
144
|
-
// }
|
|
145
|
-
// };
|
|
146
|
-
|
|
147
|
-
// const updateAddress = (root: string, element: Element) => {
|
|
148
|
-
// for(const e of descendentElementIterator(element)) {
|
|
149
|
-
// updateAttribute(root, "src", e);
|
|
150
|
-
// }
|
|
151
|
-
// };
|
|
152
|
-
|
|
153
|
-
// let body = await localFile.readAsText();
|
|
154
|
-
// const siteID = site.folderID;
|
|
155
|
-
// if(/\<inject\s/i.test(body)) {
|
|
156
|
-
// // perform inject...
|
|
157
|
-
// const { window: { document } } = new JSDOM(body);
|
|
158
|
-
// const parser = new document.defaultView.DOMParser();
|
|
159
|
-
// const b = document.createElement("base");
|
|
160
|
-
// b.href = `/api/site/draft/${siteID}/`;
|
|
161
|
-
// document.head.insertAdjacentElement("afterbegin", b);
|
|
162
|
-
// for(const e of Array.from(document.body.querySelectorAll("inject"))) {
|
|
163
|
-
// let src = e.getAttribute("src");
|
|
164
|
-
// if (src.startsWith("/")) {
|
|
165
|
-
// src = src.substring(1);
|
|
166
|
-
// }
|
|
167
|
-
// const includeFile = await this.websiteService.getFile(site.folderID, ... src.split("/"));
|
|
168
|
-
// // const includeFile = await this.tfs.downloadAppFile(include);
|
|
169
|
-
// const parsed = parser.parseFromString(await includeFile.readAsText(), "text/html");
|
|
170
|
-
// for(const pe of Array.from(parsed.body.children)) {
|
|
171
|
-
// pe.remove();
|
|
172
|
-
// updateAddress(b.href + src, pe);
|
|
173
|
-
// e.parentElement.insertBefore(pe, e);
|
|
174
|
-
// }
|
|
175
|
-
// e.remove();
|
|
176
|
-
// }
|
|
177
|
-
// body = `<!DOCTYPE HTML>${document.documentElement.outerHTML}`;
|
|
178
|
-
// } else {
|
|
179
|
-
// body = body.split(/\<\/head\>/i).join(`<base href="/api/site/draft/${siteID}/"/></head>`);
|
|
180
|
-
// }
|
|
181
|
-
|
|
182
|
-
// return body;
|
|
183
|
-
// }
|
|
184
|
-
|
|
185
106
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import Inject, { RegisterScoped } from "@entity-access/entity-access/dist/di/di.js";
|
|
2
|
-
import WebSiteContentService from "../files/WebSiteContentService.js";
|
|
3
2
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
4
3
|
import WebSite from "../../model/entities/WebSite.js";
|
|
4
|
+
import DBConfig from "../DBConfig.js";
|
|
5
5
|
|
|
6
6
|
@RegisterScoped
|
|
7
7
|
export default class SitePreviewGenerator {
|
|
8
8
|
|
|
9
9
|
@Inject
|
|
10
|
-
|
|
10
|
+
dbConfig: DBConfig;
|
|
11
11
|
|
|
12
12
|
async getPreviewUrls(site:WebSite, hostName?) {
|
|
13
13
|
|
|
14
14
|
const cdn = hostName || globalEnv.cdn;
|
|
15
15
|
const { host } = site.hosts[0];
|
|
16
16
|
const { currentVersionID } = site;
|
|
17
|
-
const v = await this.
|
|
17
|
+
const v = await this.dbConfig.getPackagesHash();
|
|
18
18
|
const gv = (40).toString(36);
|
|
19
19
|
const cv = `c${gv}-${v}-${currentVersionID.toString(36)}`;
|
|
20
20
|
return {
|
|
@@ -9,6 +9,7 @@ import SitePreviewGenerator from "../../../services/site/SitePreviewGenerator.js
|
|
|
9
9
|
import WebSiteContentService from "../../../services/files/WebSiteContentService.js";
|
|
10
10
|
import MessagingService from "../../../services/message-events/MessagingService.js";
|
|
11
11
|
import WebSite from "../../../model/entities/WebSite.js";
|
|
12
|
+
import DBConfig from "../../../services/DBConfig.js";
|
|
12
13
|
|
|
13
14
|
export default class GenerateTemplatePreviewWorkflow extends Workflow<string> {
|
|
14
15
|
|
|
@@ -19,6 +20,8 @@ export default class GenerateTemplatePreviewWorkflow extends Workflow<string> {
|
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
await this.invalidate();
|
|
24
|
+
|
|
22
25
|
let start = "0";
|
|
23
26
|
for(;;) {
|
|
24
27
|
start = await this.generate(start);
|
|
@@ -28,6 +31,21 @@ export default class GenerateTemplatePreviewWorkflow extends Workflow<string> {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
@UniqueActivity
|
|
35
|
+
async invalidate(
|
|
36
|
+
@Inject db?: SocialMailContext,
|
|
37
|
+
@Inject dbConfig?: DBConfig
|
|
38
|
+
) {
|
|
39
|
+
|
|
40
|
+
if(!(await dbConfig.packagesChanged())) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await db.websiteFolders.asQuery()
|
|
45
|
+
.update(() => (({ previewGenerated: false})));
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
@UniqueActivity
|
|
32
50
|
async generateFor(
|
|
33
51
|
@Inject db?: SocialMailContext,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import Inject from "@entity-access/entity-access/dist/di/di.js";
|
|
2
2
|
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
3
|
-
import
|
|
3
|
+
import DBConfig from "../../../../../server/services/DBConfig.js";
|
|
4
4
|
|
|
5
5
|
export default class extends Page {
|
|
6
6
|
|
|
7
7
|
@Inject
|
|
8
|
-
|
|
8
|
+
dbConfig: DBConfig;
|
|
9
9
|
|
|
10
10
|
async run() {
|
|
11
|
-
await this.
|
|
12
|
-
const packages = this.ws.packages;
|
|
11
|
+
const packages = await this.dbConfig.getPackages();
|
|
13
12
|
return this.json(packages);
|
|
14
13
|
}
|
|
15
14
|
|