canvas-editor-engine 1.1.46 → 1.1.47
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.
|
@@ -11,33 +11,36 @@ class ProjectFileSerializer {
|
|
|
11
11
|
;
|
|
12
12
|
load() {
|
|
13
13
|
const rowProjects = JSON.parse(this.file);
|
|
14
|
-
const imageDataProcessor = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const imageDataProcessor = (temp) => {
|
|
15
|
+
let data;
|
|
16
|
+
let size;
|
|
17
|
+
if (temp?.current) {
|
|
18
|
+
data = Object.values(temp?.current.imageData.data);
|
|
19
|
+
size = temp?.current.size;
|
|
20
|
+
}
|
|
21
|
+
else if (temp?.state) {
|
|
22
|
+
data = Object.values(temp?.state.tempImageData.data);
|
|
23
|
+
size = temp?.state.size;
|
|
24
|
+
}
|
|
25
|
+
const tempImageData = new ImageData(size.width, size.height);
|
|
20
26
|
data.forEach((colorAtom, index) => {
|
|
21
27
|
tempImageData.data[index] = colorAtom;
|
|
22
28
|
});
|
|
23
29
|
return tempImageData;
|
|
24
30
|
};
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// });
|
|
39
|
-
// return projects;
|
|
40
|
-
return [{}];
|
|
31
|
+
const projects = rowProjects.map((project) => {
|
|
32
|
+
project.state.current.imageData = imageDataProcessor({ current: project.state.current });
|
|
33
|
+
project.state.history = project.state.history.map((historyLine) => {
|
|
34
|
+
historyLine.stateValue.tempImageData = imageDataProcessor({ state: historyLine.stateValue });
|
|
35
|
+
return historyLine;
|
|
36
|
+
});
|
|
37
|
+
project.state.cache = project.state.cache.map((historyLine) => {
|
|
38
|
+
historyLine.stateValue.tempImageData = imageDataProcessor({ state: historyLine.stateValue });
|
|
39
|
+
return historyLine;
|
|
40
|
+
});
|
|
41
|
+
return project;
|
|
42
|
+
});
|
|
43
|
+
return projects;
|
|
41
44
|
}
|
|
42
45
|
saveProjects(projects) {
|
|
43
46
|
this.file.save(JSON.stringify(projects));
|