@pronto-tools-and-more/pronto 10.57.0 → 11.1.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/DiffProcess/DiffProcess.js +31 -0
- package/src/parts/DiffProcessPath/DiffProcessPath.js +13 -0
- package/src/parts/DiffViews/DiffViews.js +4 -88
- package/src/parts/GetRendererIpc/GetRendererIpc.js +31 -0
- package/src/parts/HandleFileChange/HandleFileChange.js +4 -0
- package/src/parts/HandleViewsReactComponents/HandleViewsReactComponents.js +8 -19
- package/src/parts/MatchesMemoryRef/MatchesMemoryRef.js +18 -0
- package/src/parts/PidKey/PidKey.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": "
|
3
|
+
"version": "11.1.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": "
|
21
|
-
"@pronto-tools-and-more/files": "
|
22
|
-
"@pronto-tools-and-more/network-process": "
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "
|
24
|
-
"@pronto-tools-and-more/components-renderer": "
|
25
|
-
"@pronto-tools-and-more/components": "
|
26
|
-
"@pronto-tools-and-more/schema-process": "
|
27
|
-
"@pronto-tools-and-more/diff-process": "
|
28
|
-
"@pronto-tools-and-more/type-checker": "
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "
|
20
|
+
"@pronto-tools-and-more/file-watcher": "11.1.0",
|
21
|
+
"@pronto-tools-and-more/files": "11.1.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "11.1.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "11.1.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "11.1.0",
|
25
|
+
"@pronto-tools-and-more/components": "11.1.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "11.1.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "11.1.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "11.1.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "11.1.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
@@ -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,31 @@
|
|
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
|
+
// TODO when in watch mode, create a queue of renderers.
|
10
|
+
// swc takes ~500ms to load
|
11
|
+
// while the current request is being processed, launch a new renderer process and load swc
|
12
|
+
// when the actual next request comes, reuse that process, saving ~700ms setup time
|
13
|
+
|
14
|
+
const ipc = await IpcParent.create({
|
15
|
+
path: ComponentsRendererPath.componentsRendererPath,
|
16
|
+
method: IpcParentType.NodeForkedProcess, // TODO worker could be faster
|
17
|
+
execArgv: [],
|
18
|
+
stdio: "inherit",
|
19
|
+
});
|
20
|
+
HandleIpc.handleIpc(ipc);
|
21
|
+
await JsonRpc.invoke(ipc, "RenderViews.loadSwc", tsconfigPath);
|
22
|
+
return {
|
23
|
+
invoke(method, ...params) {
|
24
|
+
return JsonRpc.invoke(ipc, method, ...params);
|
25
|
+
},
|
26
|
+
dispose() {
|
27
|
+
UnhandleIpc.unhandleIpc(ipc);
|
28
|
+
ipc.dispose();
|
29
|
+
},
|
30
|
+
};
|
31
|
+
};
|
@@ -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 GetRendererIpc from "../GetRendererIpc/GetRendererIpc.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,22 @@ 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
|
-
execArgv: [],
|
39
|
-
stdio: "inherit",
|
40
|
-
});
|
41
|
-
HandleIpc.handleIpc(ipc);
|
42
|
-
const result = await JsonRpc.invoke(
|
43
|
-
ipc,
|
30
|
+
|
31
|
+
const renderer = await GetRendererIpc.getRendererIpc(tsconfigPath);
|
32
|
+
const result = await renderer.invoke(
|
44
33
|
"RenderViews.renderViews",
|
45
34
|
componentsPath,
|
46
35
|
tsconfigPath,
|
47
36
|
pathPrefix,
|
48
37
|
isBuild
|
49
38
|
);
|
50
|
-
|
51
|
-
|
39
|
+
renderer.dispose();
|
40
|
+
|
52
41
|
const splitResult = await HandleViewsSplit.handleViewsSplit(storeFrontPath);
|
53
42
|
const splitResultParsed = JSON.parse(splitResult);
|
54
43
|
const merged = [...splitResultParsed, ...result];
|
55
|
-
|
56
|
-
return
|
44
|
+
const resultString = JSON.stringify(merged, null, 2);
|
45
|
+
return resultString;
|
57
46
|
} catch (error) {
|
58
47
|
console.log(error);
|
59
48
|
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";
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '
|
1
|
+
export const version = '11.1.0'
|