@pronto-tools-and-more/pronto 9.0.0 → 9.2.0
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/package.json +10 -10
- package/src/parts/Build/Build.js +1 -0
- package/src/parts/CreateServer/CreateServer.js +3 -1
- package/src/parts/DiffNode/DiffNode.js +34 -0
- package/src/parts/DiffViews/DiffViews.js +58 -1
- package/src/parts/GetViewsResponse/GetViewsResponse.js +6 -0
- package/src/parts/HandleFileChange/HandleFileChange.js +23 -1
- package/src/parts/HandleViews/HandleViews.js +1 -0
- package/src/parts/HandleViewsReactComponents/HandleViewsReactComponents.js +1 -0
- package/src/parts/SendComponentsUpdates/SendComponentsUpdates.js +35 -0
- package/src/parts/SendViewsUpdate/SendViewsUpdate.js +14 -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": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"@lvce-editor/ipc": "^11.1.0",
|
|
18
18
|
"@lvce-editor/json-rpc": "^5.0.0",
|
|
19
19
|
"@lvce-editor/verror": "^1.4.0",
|
|
20
|
-
"@pronto-tools-and-more/file-watcher": "9.
|
|
21
|
-
"@pronto-tools-and-more/files": "9.
|
|
22
|
-
"@pronto-tools-and-more/network-process": "9.
|
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "9.
|
|
24
|
-
"@pronto-tools-and-more/components-renderer": "9.
|
|
25
|
-
"@pronto-tools-and-more/components": "9.
|
|
26
|
-
"@pronto-tools-and-more/schema-process": "9.
|
|
27
|
-
"@pronto-tools-and-more/diff-process": "9.
|
|
28
|
-
"@pronto-tools-and-more/type-checker": "9.
|
|
20
|
+
"@pronto-tools-and-more/file-watcher": "9.2.0",
|
|
21
|
+
"@pronto-tools-and-more/files": "9.2.0",
|
|
22
|
+
"@pronto-tools-and-more/network-process": "9.2.0",
|
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "9.2.0",
|
|
24
|
+
"@pronto-tools-and-more/components-renderer": "9.2.0",
|
|
25
|
+
"@pronto-tools-and-more/components": "9.2.0",
|
|
26
|
+
"@pronto-tools-and-more/schema-process": "9.2.0",
|
|
27
|
+
"@pronto-tools-and-more/diff-process": "9.2.0",
|
|
28
|
+
"@pronto-tools-and-more/type-checker": "9.2.0",
|
|
29
29
|
"execa": "^9.5.1",
|
|
30
30
|
"express": "^4.21.1"
|
|
31
31
|
},
|
package/src/parts/Build/Build.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const diffNode = (changes, oldChild, newChild, diffArray, path) => {
|
|
2
|
+
const oldKeys = Object.keys(oldChild);
|
|
3
|
+
const newKeys = Object.keys(newChild);
|
|
4
|
+
if (oldKeys.length !== newKeys.length) {
|
|
5
|
+
changes.push([
|
|
6
|
+
{
|
|
7
|
+
type: "full-update",
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (oldKeys.length !== newKeys.length) {
|
|
13
|
+
changes.push([
|
|
14
|
+
{
|
|
15
|
+
type: "full-update",
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const oldKey of oldKeys) {
|
|
21
|
+
if (Array.isArray(oldChild[oldKey]) && Array.isArray(newChild[oldKey])) {
|
|
22
|
+
changes.push(
|
|
23
|
+
diffArray(changes, oldChild[oldKey], newChild[oldKey], path)
|
|
24
|
+
);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (oldChild[oldKey] !== newChild[oldKey]) {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const oldEntries = Object.entries(oldChild);
|
|
31
|
+
const newEntries = Object.entries(newChild);
|
|
32
|
+
for (const [key, value] of Object.entries(oldChild)) {
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -1,4 +1,61 @@
|
|
|
1
|
-
const
|
|
1
|
+
const diffNode = (oldChild, newChild) => {
|
|
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
|
+
};
|
|
2
59
|
|
|
3
60
|
export const diffViews = (oldViews, newViews) => {
|
|
4
61
|
// TODO walk all nodes
|
|
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import * as HandleViewsReactComponents from "../HandleViewsReactComponents/HandleViewsReactComponents.js";
|
|
4
4
|
import * as HandleViewsSplit from "../HandleViewsSplit/HandleViewsSplit.js";
|
|
5
|
+
import * as ViewsState from "../ViewsState/ViewsState.js";
|
|
5
6
|
|
|
6
7
|
export const getViewsResponse = async ({
|
|
7
8
|
storeFrontPath,
|
|
@@ -9,6 +10,7 @@ export const getViewsResponse = async ({
|
|
|
9
10
|
reactComponents,
|
|
10
11
|
pathPrefix,
|
|
11
12
|
isBuild,
|
|
13
|
+
hotReload,
|
|
12
14
|
}) => {
|
|
13
15
|
if (reactComponents) {
|
|
14
16
|
const content = await HandleViewsReactComponents.handleViewsReactComponents(
|
|
@@ -16,6 +18,10 @@ export const getViewsResponse = async ({
|
|
|
16
18
|
pathPrefix,
|
|
17
19
|
isBuild
|
|
18
20
|
);
|
|
21
|
+
if (hotReload) {
|
|
22
|
+
// TODO optimize this code for react components, don't parse and stringify so often
|
|
23
|
+
ViewsState.set(JSON.parse(content));
|
|
24
|
+
}
|
|
19
25
|
return content;
|
|
20
26
|
}
|
|
21
27
|
if (splitViews) {
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import * as SendComponentsUpdates from "../SendComponentsUpdates/SendComponentsUpdates.js";
|
|
3
4
|
import * as SendFullUpdates from "../SendFullUpdates/SendFullUpdates.js";
|
|
4
5
|
import * as SendSassUpdates from "../SendSassUpdates/SendSassUpdates.js";
|
|
5
6
|
import * as SendUpdates from "../SendUpdates/SendUpdates.js";
|
|
7
|
+
import * as SendViewsUpdate from "../SendViewsUpdate/SendViewsUpdate.js";
|
|
6
8
|
|
|
7
|
-
export const handleFileChange = async (
|
|
9
|
+
export const handleFileChange = async (
|
|
10
|
+
clients,
|
|
11
|
+
event,
|
|
12
|
+
root,
|
|
13
|
+
errorColor,
|
|
14
|
+
pathPrefix,
|
|
15
|
+
hotReload
|
|
16
|
+
) => {
|
|
8
17
|
const absolutePath = join(root, event.filename);
|
|
9
18
|
if (event.filename === "default/readmode/custom.css") {
|
|
10
19
|
const css = await readFile(absolutePath, "utf8");
|
|
@@ -26,6 +35,19 @@ export const handleFileChange = async (clients, event, root, errorColor) => {
|
|
|
26
35
|
undefined,
|
|
27
36
|
errorColor
|
|
28
37
|
);
|
|
38
|
+
} else if (event.filename.startsWith("components/src/parts")) {
|
|
39
|
+
const storeFrontPath = join(root, "default", "storefront");
|
|
40
|
+
SendComponentsUpdates.sendComponentsUpdates(
|
|
41
|
+
clients,
|
|
42
|
+
storeFrontPath,
|
|
43
|
+
pathPrefix,
|
|
44
|
+
hotReload
|
|
45
|
+
);
|
|
46
|
+
} else if (
|
|
47
|
+
event.filename.endsWith(".json") &&
|
|
48
|
+
event.filename.includes("views")
|
|
49
|
+
) {
|
|
50
|
+
SendViewsUpdate.sendViewsUpdate(clients);
|
|
29
51
|
} else {
|
|
30
52
|
SendFullUpdates.sendFullUpdates(clients);
|
|
31
53
|
}
|
|
@@ -52,6 +52,7 @@ export const handleViewsReactComponents = async (
|
|
|
52
52
|
const splitResult = await HandleViewsSplit.handleViewsSplit(storeFrontPath);
|
|
53
53
|
const splitResultParsed = JSON.parse(splitResult);
|
|
54
54
|
const merged = [...splitResultParsed, ...result];
|
|
55
|
+
|
|
55
56
|
return JSON.stringify(merged, null, 2);
|
|
56
57
|
} catch (error) {
|
|
57
58
|
console.log(error);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as SendUpdates from "../SendUpdates/SendUpdates.js";
|
|
2
|
+
import * as HandleViewsReactComponents from "../HandleViewsReactComponents/HandleViewsReactComponents.js";
|
|
3
|
+
import * as ViewsState from "../ViewsState/ViewsState.js";
|
|
4
|
+
import * as DiffViews from "../DiffViews/DiffViews.js";
|
|
5
|
+
|
|
6
|
+
export const sendComponentsUpdates = async (
|
|
7
|
+
clients,
|
|
8
|
+
storefrontPath,
|
|
9
|
+
pathPrefix,
|
|
10
|
+
hotReload
|
|
11
|
+
) => {
|
|
12
|
+
if (!hotReload) {
|
|
13
|
+
SendUpdates.sendUpdates(clients, {
|
|
14
|
+
jsonrpc: "2.0",
|
|
15
|
+
method: "reload",
|
|
16
|
+
params: [],
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const isBuilt = false;
|
|
21
|
+
const old = ViewsState.get();
|
|
22
|
+
const res = await HandleViewsReactComponents.handleViewsReactComponents(
|
|
23
|
+
storefrontPath,
|
|
24
|
+
pathPrefix,
|
|
25
|
+
isBuilt
|
|
26
|
+
);
|
|
27
|
+
const latest = ViewsState.get();
|
|
28
|
+
if (old !== latest) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const newViews = JSON.parse(res);
|
|
32
|
+
ViewsState.set(JSON.parse(res));
|
|
33
|
+
const changes = DiffViews.diffViews(old, newViews);
|
|
34
|
+
console.log({ changes });
|
|
35
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as SendUpdates from "../SendUpdates/SendUpdates.js";
|
|
2
|
+
|
|
3
|
+
export const sendViewsUpdate = (clients) => {
|
|
4
|
+
SendUpdates.sendUpdates(clients, {
|
|
5
|
+
jsonrpc: "2.0",
|
|
6
|
+
method: "reload",
|
|
7
|
+
params: [],
|
|
8
|
+
});
|
|
9
|
+
// SendUpdates.sendUpdates(clients, {
|
|
10
|
+
// jsonrpc: "2.0",
|
|
11
|
+
// method: "updateViews",
|
|
12
|
+
// params: [],
|
|
13
|
+
// });
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '9.
|
|
1
|
+
export const version = '9.2.0'
|