@pronto-tools-and-more/pronto 11.0.0 → 11.2.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 +6 -1
- package/src/parts/DiffProcess/DiffProcess.js +31 -0
- package/src/parts/DiffProcessPath/DiffProcessPath.js +13 -0
- package/src/parts/DiffViews/DiffViews.js +4 -88
- package/src/parts/GetOrCreateRendererIpc/GetOrCreateRendererIpc.js +21 -0
- package/src/parts/GetRendererIpc/GetRendererIpc.js +26 -0
- package/src/parts/HandleConfigLoader/HandleConfigLoader.js +7 -0
- package/src/parts/HandleFileChange/HandleFileChange.js +4 -0
- package/src/parts/HandleViewsReactComponents/HandleViewsReactComponents.js +11 -19
- package/src/parts/MatchesMemoryRef/MatchesMemoryRef.js +18 -0
- package/src/parts/PidKey/PidKey.js +1 -0
- package/src/parts/UpdateIndexHtml/UpdateIndexHtml.js +1 -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": "11.
|
3
|
+
"version": "11.2.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "src/main.js",
|
6
6
|
"type": "module",
|
@@ -17,16 +17,16 @@
|
|
17
17
|
"@lvce-editor/ipc": "^11.7.0",
|
18
18
|
"@lvce-editor/json-rpc": "^5.3.0",
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
20
|
-
"@pronto-tools-and-more/file-watcher": "11.
|
21
|
-
"@pronto-tools-and-more/files": "11.
|
22
|
-
"@pronto-tools-and-more/network-process": "11.
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "11.
|
24
|
-
"@pronto-tools-and-more/components-renderer": "11.
|
25
|
-
"@pronto-tools-and-more/components": "11.
|
26
|
-
"@pronto-tools-and-more/schema-process": "11.
|
27
|
-
"@pronto-tools-and-more/diff-process": "11.
|
28
|
-
"@pronto-tools-and-more/type-checker": "11.
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "11.
|
20
|
+
"@pronto-tools-and-more/file-watcher": "11.2.0",
|
21
|
+
"@pronto-tools-and-more/files": "11.2.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "11.2.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "11.2.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "11.2.0",
|
25
|
+
"@pronto-tools-and-more/components": "11.2.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "11.2.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "11.2.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "11.2.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "11.2.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
package/src/parts/App/App.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import express from "express";
|
2
2
|
import { join } from "node:path";
|
3
3
|
import * as FilesPath from "../FilesPath/FilesPath.js";
|
4
|
+
import * as HandleConfigLoader from "../HandleConfigLoader/HandleConfigLoader.js";
|
4
5
|
import * as HandleCss from "../HandleCss/HandleCss.js";
|
6
|
+
import * as HandleCustomServer from "../HandleCustomServer/HandleCustomServer.js";
|
5
7
|
import * as HandleFeaturesJson from "../HandleFeaturesJson/HandleFeaturesJson.js";
|
6
8
|
import * as HandleIndex from "../HandleIndex/HandleIndex.js";
|
7
9
|
import * as HandleMainJs from "../HandleMainJs/HandleMainJs.js";
|
8
10
|
import * as HandleViews from "../HandleViews/HandleViews.js";
|
9
|
-
import * as HandleCustomServer from "../HandleCustomServer/HandleCustomServer.js";
|
10
11
|
import * as ProxyPath from "../ProxyPath/ProxyPath.js";
|
11
12
|
|
12
13
|
export const create = ({
|
@@ -42,6 +43,10 @@ export const create = ({
|
|
42
43
|
filesPath: FilesPath.filesPath,
|
43
44
|
})
|
44
45
|
);
|
46
|
+
app.get(
|
47
|
+
"/assets/scripts/configLoader.js",
|
48
|
+
HandleConfigLoader.handleConfigLoader
|
49
|
+
);
|
45
50
|
app.get(
|
46
51
|
"/modules/main.js",
|
47
52
|
HandleMainJs.handleMainJs({
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import * as DiffProcessPath from "../DiffProcessPath/DiffProcessPath.js";
|
2
|
+
import * as HandleIpc from "../HandleIpc/HandleIpc.js";
|
3
|
+
import * as IpcParent from "../IpcParent/IpcParent.js";
|
4
|
+
import * as IpcParentType from "../IpcParentType/IpcParentType.js";
|
5
|
+
import * as JsonRpc from "../JsonRpc/JsonRpc.js";
|
6
|
+
|
7
|
+
let ipcPromise;
|
8
|
+
|
9
|
+
const create = async () => {
|
10
|
+
const ipc = await IpcParent.create({
|
11
|
+
path: DiffProcessPath.diffProcessRendererPath,
|
12
|
+
method: IpcParentType.NodeForkedProcess, // TODO worker could be faster
|
13
|
+
execArgv: [],
|
14
|
+
stdio: "inherit",
|
15
|
+
});
|
16
|
+
HandleIpc.handleIpc(ipc);
|
17
|
+
return ipc;
|
18
|
+
};
|
19
|
+
|
20
|
+
const getOrCreate = () => {
|
21
|
+
if (!ipcPromise) {
|
22
|
+
ipcPromise = create();
|
23
|
+
}
|
24
|
+
return ipcPromise;
|
25
|
+
};
|
26
|
+
|
27
|
+
export const invoke = async (method, ...params) => {
|
28
|
+
const ipc = await getOrCreate();
|
29
|
+
const result = await JsonRpc.invoke(ipc, method, ...params);
|
30
|
+
return result;
|
31
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import * as Path from "node:path";
|
2
|
+
import * as ResolveBin from "../ResolveBin/ResolveBin.js";
|
3
|
+
import * as Root from "../Root/Root.js";
|
4
|
+
|
5
|
+
export const diffProcessRendererPath =
|
6
|
+
ResolveBin.resolveBin("@pronto-tools-and-more/diff-process") ||
|
7
|
+
Path.join(
|
8
|
+
Root.root,
|
9
|
+
"packages",
|
10
|
+
"pronto-diff-process",
|
11
|
+
"src",
|
12
|
+
"diffProcessMain.js"
|
13
|
+
);
|
@@ -1,90 +1,6 @@
|
|
1
|
-
|
2
|
-
const oldKeys = Object.keys(oldChild);
|
3
|
-
const newKeys = Object.keys(newChild);
|
4
|
-
if (oldKeys.length !== newKeys.length) {
|
5
|
-
return [
|
6
|
-
{
|
7
|
-
type: "full-update",
|
8
|
-
},
|
9
|
-
];
|
10
|
-
}
|
11
|
-
if (oldKeys.length !== newKeys.length) {
|
12
|
-
return [
|
13
|
-
{
|
14
|
-
type: "full-update",
|
15
|
-
},
|
16
|
-
];
|
17
|
-
}
|
18
|
-
for (const oldKey of oldKeys) {
|
19
|
-
if (oldChild[oldKey] !== newChild[oldKey]) {
|
20
|
-
}
|
21
|
-
}
|
22
|
-
const oldEntries = Object.entries(oldChild);
|
23
|
-
const newEntries = Object.entries(newChild);
|
24
|
-
for (const [key, value] of Object.entries(oldChild)) {
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
const diffInternal = (oldChildren, newChildren) => {
|
29
|
-
if (oldChildren.length !== newChildren.length) {
|
30
|
-
return [
|
31
|
-
{
|
32
|
-
type: "full-update",
|
33
|
-
},
|
34
|
-
];
|
35
|
-
}
|
36
|
-
const length = oldChildren.length;
|
37
|
-
for (let i = 0; i < oldChildren.length; i++) {
|
38
|
-
const oldChild = oldChildren[i];
|
39
|
-
const newChild = newChildren[i];
|
40
|
-
const oldKeys = Object.keys(oldChild);
|
41
|
-
const newKeys = Object.keys(newChild);
|
42
|
-
if (oldKeys.length !== newKeys.length) {
|
43
|
-
return [
|
44
|
-
{
|
45
|
-
type: "full-update",
|
46
|
-
},
|
47
|
-
];
|
48
|
-
}
|
49
|
-
for (const oldKey of oldKeys) {
|
50
|
-
if (oldChild[oldKey] !== newChild[oldKey]) {
|
51
|
-
}
|
52
|
-
}
|
53
|
-
const oldEntries = Object.entries(oldChild);
|
54
|
-
const newEntries = Object.entries(newChild);
|
55
|
-
for (const [key, value] of Object.entries(oldChild)) {
|
56
|
-
}
|
57
|
-
}
|
58
|
-
};
|
59
|
-
|
60
|
-
export const diffViews = (oldViews, newViews) => {
|
61
|
-
// TODO walk all nodes
|
62
|
-
// return one of four changes
|
63
|
-
// 1. full update
|
64
|
-
// 2. classname update
|
65
|
-
// 3. text update
|
66
|
-
// 4. node update
|
67
|
-
|
68
|
-
if (!oldViews) {
|
69
|
-
return [
|
70
|
-
{
|
71
|
-
type: "full-update",
|
72
|
-
},
|
73
|
-
];
|
74
|
-
}
|
75
|
-
if (oldViews.length !== newViews.length) {
|
76
|
-
return [
|
77
|
-
{
|
78
|
-
type: "full-update",
|
79
|
-
},
|
80
|
-
];
|
81
|
-
}
|
82
|
-
const length = oldViews.length;
|
1
|
+
import * as DiffProcess from "../DiffProcess/DiffProcess.js";
|
83
2
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
88
|
-
for (const item of oldViews) console.log({ oldViews, newViews });
|
89
|
-
return [];
|
3
|
+
export const diffViews = async (oldViews, newViews) => {
|
4
|
+
const result = await DiffProcess.invoke("Diff.diff", oldViews, newViews);
|
5
|
+
return result;
|
90
6
|
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import * as GetRendererIpc from "../GetRendererIpc/GetRendererIpc.js";
|
2
|
+
|
3
|
+
const state = {
|
4
|
+
/**
|
5
|
+
* @type {Promise[]}
|
6
|
+
*/
|
7
|
+
preloadedIpcs: [],
|
8
|
+
};
|
9
|
+
|
10
|
+
export const getOrCreateRendererIpc = async (tsconfigPath, isBuild) => {
|
11
|
+
const cachedIpc = state.preloadedIpcs.pop();
|
12
|
+
if (cachedIpc) {
|
13
|
+
state.preloadedIpcs.push(GetRendererIpc.getRendererIpc(tsconfigPath));
|
14
|
+
return cachedIpc;
|
15
|
+
}
|
16
|
+
const oursPromise = GetRendererIpc.getRendererIpc(tsconfigPath);
|
17
|
+
if (!isBuild) {
|
18
|
+
state.preloadedIpcs.push(GetRendererIpc.getRendererIpc(tsconfigPath));
|
19
|
+
}
|
20
|
+
return oursPromise;
|
21
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import * as ComponentsRendererPath from "../ComponentsRendererPath/ComponentsRendererPath.js";
|
2
|
+
import * as HandleIpc from "../HandleIpc/HandleIpc.js";
|
3
|
+
import * as IpcParent from "../IpcParent/IpcParent.js";
|
4
|
+
import * as IpcParentType from "../IpcParentType/IpcParentType.js";
|
5
|
+
import * as JsonRpc from "../JsonRpc/JsonRpc.js";
|
6
|
+
import * as UnhandleIpc from "../UnhandleIpc/UnhandleIpc.js";
|
7
|
+
|
8
|
+
export const getRendererIpc = async (tsconfigPath) => {
|
9
|
+
const ipc = await IpcParent.create({
|
10
|
+
path: ComponentsRendererPath.componentsRendererPath,
|
11
|
+
method: IpcParentType.NodeForkedProcess, // TODO worker could be faster
|
12
|
+
execArgv: [],
|
13
|
+
stdio: "inherit",
|
14
|
+
});
|
15
|
+
HandleIpc.handleIpc(ipc);
|
16
|
+
await JsonRpc.invoke(ipc, "RenderViews.loadSwc", tsconfigPath);
|
17
|
+
return {
|
18
|
+
invoke(method, ...params) {
|
19
|
+
return JsonRpc.invoke(ipc, method, ...params);
|
20
|
+
},
|
21
|
+
dispose() {
|
22
|
+
UnhandleIpc.unhandleIpc(ipc);
|
23
|
+
ipc.dispose();
|
24
|
+
},
|
25
|
+
};
|
26
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
2
2
|
import { join } from "node:path";
|
3
|
+
import * as MatchesMemoryRef from "../MatchesMemoryRef/MatchesMemoryRef.js";
|
3
4
|
import * as SendComponentsUpdates from "../SendComponentsUpdates/SendComponentsUpdates.js";
|
4
5
|
import * as SendFullUpdates from "../SendFullUpdates/SendFullUpdates.js";
|
5
6
|
import * as SendSassUpdates from "../SendSassUpdates/SendSassUpdates.js";
|
@@ -15,6 +16,9 @@ export const handleFileChange = async (
|
|
15
16
|
hotReload
|
16
17
|
) => {
|
17
18
|
const absolutePath = join(root, event.filename);
|
19
|
+
if (MatchesMemoryRef.matchesMemoryRef(absolutePath)) {
|
20
|
+
return;
|
21
|
+
}
|
18
22
|
if (event.filename === "default/readmode/custom.css") {
|
19
23
|
const css = await readFile(absolutePath, "utf8");
|
20
24
|
const changes = [
|
@@ -1,12 +1,7 @@
|
|
1
1
|
import { existsSync } from "node:fs";
|
2
2
|
import { join } from "node:path";
|
3
|
-
import * as
|
4
|
-
import * as HandleIpc from "../HandleIpc/HandleIpc.js";
|
3
|
+
import * as GetOrCreateRendererIpc from "../GetOrCreateRendererIpc/GetOrCreateRendererIpc.js";
|
5
4
|
import * as HandleViewsSplit from "../HandleViewsSplit/HandleViewsSplit.js";
|
6
|
-
import * as IpcParent from "../IpcParent/IpcParent.js";
|
7
|
-
import * as IpcParentType from "../IpcParentType/IpcParentType.js";
|
8
|
-
import * as JsonRpc from "../JsonRpc/JsonRpc.js";
|
9
|
-
import * as UnhandleIpc from "../UnhandleIpc/UnhandleIpc.js";
|
10
5
|
|
11
6
|
export const handleViewsReactComponents = async (
|
12
7
|
storeFrontPath,
|
@@ -32,28 +27,25 @@ export const handleViewsReactComponents = async (
|
|
32
27
|
if (!existsSync(componentsPath)) {
|
33
28
|
throw new Error(`components path not found: ${componentsPath}`);
|
34
29
|
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
HandleIpc.handleIpc(ipc);
|
42
|
-
const result = await JsonRpc.invoke(
|
43
|
-
ipc,
|
30
|
+
|
31
|
+
const renderer = await GetOrCreateRendererIpc.getOrCreateRendererIpc(
|
32
|
+
tsconfigPath,
|
33
|
+
isBuild
|
34
|
+
);
|
35
|
+
const result = await renderer.invoke(
|
44
36
|
"RenderViews.renderViews",
|
45
37
|
componentsPath,
|
46
38
|
tsconfigPath,
|
47
39
|
pathPrefix,
|
48
40
|
isBuild
|
49
41
|
);
|
50
|
-
|
51
|
-
|
42
|
+
renderer.dispose();
|
43
|
+
|
52
44
|
const splitResult = await HandleViewsSplit.handleViewsSplit(storeFrontPath);
|
53
45
|
const splitResultParsed = JSON.parse(splitResult);
|
54
46
|
const merged = [...splitResultParsed, ...result];
|
55
|
-
|
56
|
-
return
|
47
|
+
const resultString = JSON.stringify(merged, null, 2);
|
48
|
+
return resultString;
|
57
49
|
} catch (error) {
|
58
50
|
console.log(error);
|
59
51
|
console.error(`[pronto] views json error: ${error}`);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { readFileSync } from "node:fs";
|
2
|
+
|
3
|
+
const memoryRef = Object.create(null);
|
4
|
+
|
5
|
+
export const matchesMemoryRef = (absolutePath) => {
|
6
|
+
try {
|
7
|
+
const oldContent = memoryRef[absolutePath];
|
8
|
+
const content = readFileSync(absolutePath, "utf8");
|
9
|
+
if (content === oldContent) {
|
10
|
+
return true;
|
11
|
+
}
|
12
|
+
memoryRef[absolutePath] = content;
|
13
|
+
return false;
|
14
|
+
} catch (error) {
|
15
|
+
// ignore
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export const pidKey = "data-prid";
|
@@ -23,6 +23,7 @@ const replacementSnippetBody = (appId, baseUrl, contentUrl, platform) =>
|
|
23
23
|
const occurrenceSnippetHead = "</head>";
|
24
24
|
const replacementSnippetHead = `
|
25
25
|
<link rel="stylesheet" href="/theme.css" />
|
26
|
+
<link rel="stylesheet" href="/assets/custom.css" />
|
26
27
|
</head>`;
|
27
28
|
|
28
29
|
export const updateIndexHtml = (
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '11.
|
1
|
+
export const version = '11.2.0'
|