@pronto-tools-and-more/pronto 12.28.0 → 12.30.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -11
- package/src/parts/App/App.js +13 -0
- package/src/parts/Config/Config.js +3 -0
- package/src/parts/CreateServer/CreateServer.js +1 -0
- package/src/parts/GetBasePath/GetBasePath.js +8 -0
- package/src/parts/GetCommonJsSnippet/GetCommonJsSnippet.js +13 -0
- package/src/parts/GetNewCommonJsContent/GetNewCommonJsContent.js +110 -0
- package/src/parts/GetVarName/GetVarName.js +10 -0
- package/src/parts/HandleCommonJs/HandleCommonJs.js +21 -0
- package/src/parts/HandleMainJs/HandleMainJs.js +2 -8
- package/src/parts/HandleViewsReactComponents/HandleViewsReactComponents.js +3 -4
- package/src/parts/PushCodeTo/PushCodeTo.js +1 -1
- package/src/parts/ReplaceNeedle/ReplaceNeedle.js +10 -0
- package/src/parts/Version/Version.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.30.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "src/main.js",
|
6
6
|
"type": "module",
|
@@ -17,16 +17,16 @@
|
|
17
17
|
"@lvce-editor/ipc": "^13.7.0",
|
18
18
|
"@lvce-editor/json-rpc": "^5.4.0",
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
20
|
-
"@pronto-tools-and-more/file-watcher": "12.
|
21
|
-
"@pronto-tools-and-more/files": "12.
|
22
|
-
"@pronto-tools-and-more/network-process": "12.
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "12.
|
24
|
-
"@pronto-tools-and-more/components-renderer": "12.
|
25
|
-
"@pronto-tools-and-more/components": "12.
|
26
|
-
"@pronto-tools-and-more/schema-process": "12.
|
27
|
-
"@pronto-tools-and-more/diff-process": "12.
|
28
|
-
"@pronto-tools-and-more/type-checker": "12.
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "12.
|
20
|
+
"@pronto-tools-and-more/file-watcher": "12.30.0",
|
21
|
+
"@pronto-tools-and-more/files": "12.30.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "12.30.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "12.30.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "12.30.0",
|
25
|
+
"@pronto-tools-and-more/components": "12.30.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "12.30.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "12.30.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "12.30.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "12.30.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
package/src/parts/App/App.js
CHANGED
@@ -2,6 +2,7 @@ import express from "express";
|
|
2
2
|
import { join } from "node:path";
|
3
3
|
import * as FilesPath from "../FilesPath/FilesPath.js";
|
4
4
|
import * as HandleApi from "../HandleApi/HandleApi.js";
|
5
|
+
import * as HandleCommonJs from "../HandleCommonJs/HandleCommonJs.js";
|
5
6
|
import * as HandleConfigLoader from "../HandleConfigLoader/HandleConfigLoader.js";
|
6
7
|
import * as HandleCss from "../HandleCss/HandleCss.js";
|
7
8
|
import * as HandleCustomServer from "../HandleCustomServer/HandleCustomServer.js";
|
@@ -31,6 +32,7 @@ export const create = ({
|
|
31
32
|
injectCustomJs,
|
32
33
|
shimConfigLoader,
|
33
34
|
apiUrl,
|
35
|
+
supportNormalHtmlElements,
|
34
36
|
}) => {
|
35
37
|
const app = express();
|
36
38
|
const storeFrontPath = join(root, "src", "default", "storefront");
|
@@ -68,6 +70,17 @@ export const create = ({
|
|
68
70
|
mode,
|
69
71
|
})
|
70
72
|
);
|
73
|
+
if (supportNormalHtmlElements) {
|
74
|
+
app.get(
|
75
|
+
"/modules/common.js",
|
76
|
+
HandleCommonJs.handleCommonJs({
|
77
|
+
storeFrontPath,
|
78
|
+
filesPath: FilesPath.filesPath,
|
79
|
+
mode,
|
80
|
+
})
|
81
|
+
);
|
82
|
+
}
|
83
|
+
|
71
84
|
app.get(
|
72
85
|
"/assets/views.json",
|
73
86
|
HandleViews.handleViews({
|
@@ -118,5 +118,8 @@ export const injectCustomJs = config.injectCustomJs || false;
|
|
118
118
|
|
119
119
|
export const shimConfigLoader = config.shimConfigLoader || false;
|
120
120
|
|
121
|
+
export const supportNormalHtmlElements =
|
122
|
+
config.supportNormalHtmlElements || false;
|
123
|
+
|
121
124
|
export const apiUrl =
|
122
125
|
process.env.API_URL || "https://catalog.purplemanager.com/graphql";
|
@@ -30,6 +30,7 @@ export const createServer = async (root, errorColor) => {
|
|
30
30
|
shimConfigLoader: Config.shimConfigLoader,
|
31
31
|
releaseAppId: Config.releaseAppId,
|
32
32
|
apiUrl: Config.apiUrl,
|
33
|
+
supportNormalHtmlElements: Config.supportNormalHtmlElements,
|
33
34
|
});
|
34
35
|
const server = http.createServer(app);
|
35
36
|
const webSocketServer = new ws.WebSocketServer({
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { join } from "path";
|
2
|
+
import * as FilesPath from "../FilesPath/FilesPath.js";
|
3
|
+
import { readFile } from "fs/promises";
|
4
|
+
|
5
|
+
export const getCommonJsSnippet = async () => {
|
6
|
+
const snippetPath = join(
|
7
|
+
FilesPath.filesPath,
|
8
|
+
"assets",
|
9
|
+
"hack-normal-html-elements.js"
|
10
|
+
);
|
11
|
+
const snippetContent = await readFile(snippetPath, "utf8");
|
12
|
+
return snippetContent;
|
13
|
+
};
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import * as ReplaceNeedle from "../ReplaceNeedle/ReplaceNeedle.js";
|
2
|
+
import * as GetVarName from "../GetVarName/GetVarName.js";
|
3
|
+
|
4
|
+
// monkeypatch common.js to support normal html elements
|
5
|
+
export const getNewCommonJsContent = ({ content, normalHtmlSnippet }) => {
|
6
|
+
const needle0 = '"use strict"';
|
7
|
+
const needle1 = `tag:"div"`;
|
8
|
+
const needle2 = `tag: "div"`;
|
9
|
+
const needle3 = "ngOnInit(){";
|
10
|
+
const needle4 = "ngOnInit() {";
|
11
|
+
const needle5 = "onConfigChanges(){";
|
12
|
+
const needle6 = "onConfigChanges() {";
|
13
|
+
const needle7 = "=this";
|
14
|
+
const needle8 = "= this";
|
15
|
+
const needle9 = "changeDetectorRef.markForCheck()";
|
16
|
+
|
17
|
+
let newContent = content;
|
18
|
+
|
19
|
+
const indexStrict = newContent.indexOf(needle0);
|
20
|
+
|
21
|
+
if (indexStrict === -1) {
|
22
|
+
throw new Error("needle not found");
|
23
|
+
}
|
24
|
+
|
25
|
+
const occurrence0 = '"use strict"';
|
26
|
+
const replacement0 = normalHtmlSnippet;
|
27
|
+
newContent = ReplaceNeedle.replaceNeedle(
|
28
|
+
newContent,
|
29
|
+
indexStrict,
|
30
|
+
occurrence0,
|
31
|
+
replacement0
|
32
|
+
);
|
33
|
+
|
34
|
+
const needles = [needle1, needle2];
|
35
|
+
let index = -1;
|
36
|
+
for (const needle of needles) {
|
37
|
+
index = newContent.indexOf(needle);
|
38
|
+
if (index !== -1) {
|
39
|
+
index += needle.length;
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
if (index === -1) {
|
44
|
+
throw new Error("no needle found (1)");
|
45
|
+
}
|
46
|
+
|
47
|
+
let initIndex = newContent.indexOf(needle3, index);
|
48
|
+
if (initIndex === -1) {
|
49
|
+
initIndex = newContent.indexOf(needle4, index);
|
50
|
+
}
|
51
|
+
if (initIndex === -1) {
|
52
|
+
throw new Error("no needle found (2)");
|
53
|
+
}
|
54
|
+
let this1Index = newContent.indexOf(needle7, initIndex);
|
55
|
+
if (this1Index === -1) {
|
56
|
+
this1Index = newContent.indexOf(needle8, initIndex);
|
57
|
+
}
|
58
|
+
|
59
|
+
if (this1Index === -1) {
|
60
|
+
throw new Error("no needle found (3)");
|
61
|
+
}
|
62
|
+
|
63
|
+
const occurence1 = "this";
|
64
|
+
const replacement1 = `this;globalThis.HACK__NORMAL_HTML_ELEMENTS_CHECK(this);`;
|
65
|
+
|
66
|
+
newContent = ReplaceNeedle.replaceNeedle(
|
67
|
+
newContent,
|
68
|
+
this1Index,
|
69
|
+
occurence1,
|
70
|
+
replacement1
|
71
|
+
);
|
72
|
+
let configIndex = newContent.indexOf(needle5, this1Index);
|
73
|
+
if (configIndex === -1) {
|
74
|
+
configIndex = newContent.indexOf(needle6, this1Index);
|
75
|
+
}
|
76
|
+
if (configIndex === -1) {
|
77
|
+
throw new Error("no needle found (4)");
|
78
|
+
}
|
79
|
+
let this2Index = newContent.indexOf(needle7, configIndex);
|
80
|
+
if (this2Index === -1) {
|
81
|
+
this2Index = newContent.indexOf(needle8, configIndex);
|
82
|
+
}
|
83
|
+
if (this2Index === -1) {
|
84
|
+
throw new Error("no needle found (5)");
|
85
|
+
}
|
86
|
+
const varName = GetVarName.getVarName(newContent, configIndex);
|
87
|
+
const occurrence2 = "this";
|
88
|
+
const replacement2 = `this;globalThis.HACK__NORMAL_HTML_ELEMENTS_CHECK_2(this);`;
|
89
|
+
|
90
|
+
newContent = ReplaceNeedle.replaceNeedle(
|
91
|
+
newContent,
|
92
|
+
this2Index,
|
93
|
+
occurrence2,
|
94
|
+
replacement2
|
95
|
+
);
|
96
|
+
|
97
|
+
const checkIndex = newContent.indexOf(needle9, configIndex);
|
98
|
+
if (checkIndex === -1) {
|
99
|
+
throw new Error("no needle found (7)");
|
100
|
+
}
|
101
|
+
const occurrence3 = "changeDetectorRef.markForCheck()";
|
102
|
+
const replacement3 = `changeDetectorRef.markForCheck();globalThis.HACK__NORMAL_HTML_ELEMENTS_RENDER_2(${varName});`;
|
103
|
+
newContent = ReplaceNeedle.replaceNeedle(
|
104
|
+
newContent,
|
105
|
+
checkIndex,
|
106
|
+
occurrence3,
|
107
|
+
replacement3
|
108
|
+
);
|
109
|
+
return newContent;
|
110
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
const RE_THIS = /(\S+)(\s*)=(\s*)(this)/;
|
2
|
+
|
3
|
+
export const getVarName = (content, startIndex) => {
|
4
|
+
const match = content.slice(startIndex).match(RE_THIS);
|
5
|
+
if (!match) {
|
6
|
+
throw new Error("match not found (6)");
|
7
|
+
}
|
8
|
+
const varName = match[1];
|
9
|
+
return varName;
|
10
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
2
|
+
import { join } from "node:path";
|
3
|
+
import * as GetBasePath from "../GetBasePath/GetBasePath.js";
|
4
|
+
import * as GetCommonJsSnippet from "../GetCommonJsSnippet/GetCommonJsSnippet.js";
|
5
|
+
import * as GetNewCommonJsContent from "../GetNewCommonJsContent/GetNewCommonJsContent.js";
|
6
|
+
|
7
|
+
export const handleCommonJs =
|
8
|
+
({ storeFrontPath, filesPath, mode }) =>
|
9
|
+
async (req, res) => {
|
10
|
+
const basePath = GetBasePath.getBasePath(mode, storeFrontPath, filesPath);
|
11
|
+
// TODO use etag
|
12
|
+
const commonPath = join(basePath, "modules", "common.js");
|
13
|
+
const content = await readFile(commonPath, "utf8");
|
14
|
+
const normalHtmlSnippet = await GetCommonJsSnippet.getCommonJsSnippet();
|
15
|
+
const newContent = GetNewCommonJsContent.getNewCommonJsContent({
|
16
|
+
content,
|
17
|
+
normalHtmlSnippet,
|
18
|
+
});
|
19
|
+
res.setHeader("content-type", "application/javascript");
|
20
|
+
res.end(newContent);
|
21
|
+
};
|
@@ -1,15 +1,9 @@
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
2
2
|
import { join } from "node:path";
|
3
3
|
import * as GetNewMainJsContent from "../GetNewMainJsContent/GetNewMainJsContent.js";
|
4
|
+
import * as GetBasePath from "../GetBasePath/GetBasePath.js";
|
4
5
|
import * as GetPdfViewerSnippet from "../GetPdfViewerSnippet/GetPdfViewerSnippet.js";
|
5
6
|
|
6
|
-
const getBasePath = (mode, storeFrontPath, filesPath) => {
|
7
|
-
if (mode === "slim") {
|
8
|
-
return join(filesPath, "framework", "src", "default", "storefront");
|
9
|
-
}
|
10
|
-
return storeFrontPath;
|
11
|
-
};
|
12
|
-
|
13
7
|
export const handleMainJs =
|
14
8
|
({
|
15
9
|
storeFrontPath,
|
@@ -22,7 +16,7 @@ export const handleMainJs =
|
|
22
16
|
mode,
|
23
17
|
}) =>
|
24
18
|
async (req, res) => {
|
25
|
-
const basePath = getBasePath(mode, storeFrontPath, filesPath);
|
19
|
+
const basePath = GetBasePath.getBasePath(mode, storeFrontPath, filesPath);
|
26
20
|
// TODO use etag
|
27
21
|
const mainPath = join(basePath, "modules", "main.js");
|
28
22
|
const content = await readFile(mainPath, "utf8");
|
@@ -32,13 +32,12 @@ export const handleViewsReactComponents = async (
|
|
32
32
|
tsconfigPath,
|
33
33
|
isBuild
|
34
34
|
);
|
35
|
-
const result = await renderer.invoke(
|
36
|
-
"RenderViews.renderViews",
|
35
|
+
const result = await renderer.invoke("RenderViews.renderViews", {
|
37
36
|
componentsPath,
|
38
37
|
tsconfigPath,
|
39
38
|
pathPrefix,
|
40
|
-
isBuild
|
41
|
-
);
|
39
|
+
isBuild,
|
40
|
+
});
|
42
41
|
renderer.dispose();
|
43
42
|
|
44
43
|
const splitResult = await HandleViewsSplit.handleViewsSplit(storeFrontPath);
|
@@ -9,7 +9,7 @@ import * as GetZipUploadMessage from "../GetZipUploadMessage/GetZipUploadMessage
|
|
9
9
|
import * as NetworkProcess from "../NetworkProcess/NetworkProcess.js";
|
10
10
|
import * as UploadZip from "../UploadZip/UploadZip.js";
|
11
11
|
|
12
|
-
const maxRetries =
|
12
|
+
const maxRetries = 50;
|
13
13
|
const waitBetweenRetries = 60_000;
|
14
14
|
|
15
15
|
export const pushCodeTo = async ({ preview, appId }) => {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export const replaceNeedle = (content, startIndex, needle, replacement) => {
|
2
|
+
const index = content.indexOf(needle, startIndex);
|
3
|
+
if (index === -1) {
|
4
|
+
throw new Error(`needle replacement: needle not found ${needle}`);
|
5
|
+
}
|
6
|
+
const pre = content.slice(0, index);
|
7
|
+
const post = content.slice(index);
|
8
|
+
const newContent = pre + replacement + post.slice(needle.length);
|
9
|
+
return newContent;
|
10
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '12.
|
1
|
+
export const version = '12.30.0'
|