canvas-editor-engine 2.3.22 → 2.3.24
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/dist/index.mjs +84 -10
- package/dist/services/draw-accumulator.service.d.ts +6 -2
- package/dist/services/draw-layers.service.d.ts +4 -2
- package/dist/types/draw-layers.d.ts +8 -0
- package/dist/web-component.d.ts +1 -1
- package/package.json +7 -5
- package/dist/components/canvas.component.js +0 -102
- package/dist/components/excretions.component.js +0 -258
- package/dist/components/loading.component.js +0 -71
- package/dist/components/pipette.component.js +0 -120
- package/dist/components/slot.component.js +0 -45
- package/dist/config.js +0 -95
- package/dist/filters/collection/vague.js +0 -168
- package/dist/filters/index.js +0 -2
- package/dist/index.js +0 -75
- package/dist/services/component.service.js +0 -40
- package/dist/services/crop.service.js +0 -60
- package/dist/services/download.service.js +0 -16
- package/dist/services/draw-accumulator.service.js +0 -222
- package/dist/services/draw-layers.service.js +0 -72
- package/dist/services/draw.service.js +0 -259
- package/dist/services/event.service.js +0 -45
- package/dist/services/logger.service.js +0 -57
- package/dist/services/projects.service.js +0 -103
- package/dist/services/pull-project.service.js +0 -40
- package/dist/services/serize.service.js +0 -23
- package/dist/services/store.service.js +0 -14
- package/dist/services/through-history.service.js +0 -51
- package/dist/services/tool-layers.service.js +0 -13
- package/dist/services/tool.service.js +0 -59
- package/dist/store/draw-layers.state.js +0 -85
- package/dist/store/history.state.js +0 -77
- package/dist/store/image.state.js +0 -80
- package/dist/store/store.js +0 -41
- package/dist/store/storeRepository.js +0 -6
- package/dist/types/canvas.js +0 -2
- package/dist/types/cursor.js +0 -2
- package/dist/types/draw-layers.js +0 -3
- package/dist/types/draw-service.js +0 -2
- package/dist/types/excretion.js +0 -4
- package/dist/types/general.js +0 -5
- package/dist/types/history.js +0 -1
- package/dist/types/image.js +0 -9
- package/dist/types/log.js +0 -4
- package/dist/types/pipette.js +0 -1
- package/dist/types/project.js +0 -14
- package/dist/types/temp-canvas.js +0 -2
- package/dist/utils/convert.js +0 -27
- package/dist/utils/filter.js +0 -153
- package/dist/utils/generation.js +0 -7
- package/dist/utils/guid4.js +0 -122
- package/dist/utils/project-file-serializer.js +0 -77
- package/dist/utils/reflect.js +0 -30
- package/dist/utils/temp-canvas.js +0 -19
- package/dist/web-component.js +0 -179
- /package/dist/services/{serize.service.d.ts → resize.service.d.ts} +0 -0
@@ -1,57 +0,0 @@
|
|
1
|
-
var LoggerService = /** @class */ (function () {
|
2
|
-
function LoggerService() {
|
3
|
-
this.log = {
|
4
|
-
components: [],
|
5
|
-
services: [],
|
6
|
-
planed: [],
|
7
|
-
};
|
8
|
-
}
|
9
|
-
Object.defineProperty(LoggerService.prototype, "components", {
|
10
|
-
get: function () {
|
11
|
-
return this.getMethods('components');
|
12
|
-
},
|
13
|
-
enumerable: false,
|
14
|
-
configurable: true
|
15
|
-
});
|
16
|
-
;
|
17
|
-
Object.defineProperty(LoggerService.prototype, "services", {
|
18
|
-
get: function () {
|
19
|
-
return this.getMethods('services');
|
20
|
-
},
|
21
|
-
enumerable: false,
|
22
|
-
configurable: true
|
23
|
-
});
|
24
|
-
;
|
25
|
-
Object.defineProperty(LoggerService.prototype, "planed", {
|
26
|
-
get: function () {
|
27
|
-
return this.getMethods('planed');
|
28
|
-
},
|
29
|
-
enumerable: false,
|
30
|
-
configurable: true
|
31
|
-
});
|
32
|
-
;
|
33
|
-
LoggerService.prototype.getMethods = function (fields) {
|
34
|
-
var proto = this;
|
35
|
-
return {
|
36
|
-
add: function (logItem) {
|
37
|
-
proto._add(fields, logItem);
|
38
|
-
},
|
39
|
-
get: function () {
|
40
|
-
var args = [];
|
41
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
42
|
-
args[_i] = arguments[_i];
|
43
|
-
}
|
44
|
-
proto._get.apply(proto, args);
|
45
|
-
},
|
46
|
-
};
|
47
|
-
};
|
48
|
-
LoggerService.prototype._add = function (field, // keyof typeof this.log
|
49
|
-
logItem) {
|
50
|
-
this.log[field].push(logItem);
|
51
|
-
};
|
52
|
-
LoggerService.prototype._get = function (field, name) {
|
53
|
-
return this.log[field].find(function (logItem) { return logItem.info.name === name; });
|
54
|
-
};
|
55
|
-
return LoggerService;
|
56
|
-
}());
|
57
|
-
export default LoggerService;
|
@@ -1,103 +0,0 @@
|
|
1
|
-
import { ProjectFileSerializer } from "../utils/project-file-serializer";
|
2
|
-
var LocalStorageProjectModule = /** @class */ (function () {
|
3
|
-
function LocalStorageProjectModule() {
|
4
|
-
this.projectsKey = 'cee-projects';
|
5
|
-
}
|
6
|
-
LocalStorageProjectModule.prototype.getProjectsFromLocalStorage = function () {
|
7
|
-
var projects = localStorage.getItem(this.projectsKey);
|
8
|
-
return projects ? JSON.parse(projects) : [];
|
9
|
-
};
|
10
|
-
LocalStorageProjectModule.prototype.getProjectFromLocalStorage = function (projectId) {
|
11
|
-
var projects = this.getProjectsFromLocalStorage();
|
12
|
-
return projects.find(function (project) { return project.id === projectId; });
|
13
|
-
};
|
14
|
-
LocalStorageProjectModule.prototype.saveProjectsToLocalStorage = function (projects) {
|
15
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
16
|
-
};
|
17
|
-
LocalStorageProjectModule.prototype.saveProjectToLocalStorage = function (project) {
|
18
|
-
var projects = this.getProjectsFromLocalStorage();
|
19
|
-
projects.push(project);
|
20
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
21
|
-
};
|
22
|
-
LocalStorageProjectModule.prototype.removeProjectFromLocalStorage = function (projectId) {
|
23
|
-
var projects = this.getProjectsFromLocalStorage();
|
24
|
-
var index = projects.findIndex(function (project) { return project.id === projectId; });
|
25
|
-
projects.splice(index, 1);
|
26
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
27
|
-
};
|
28
|
-
LocalStorageProjectModule.prototype.updateProjectInLocalStorage = function (project) {
|
29
|
-
var projects = this.getProjectsFromLocalStorage();
|
30
|
-
var index = projects.findIndex(function (p) { return p.id === project.id; });
|
31
|
-
projects[index] = project;
|
32
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
33
|
-
};
|
34
|
-
LocalStorageProjectModule.prototype.getProjects = function () {
|
35
|
-
return this.getProjectsFromLocalStorage();
|
36
|
-
};
|
37
|
-
LocalStorageProjectModule.prototype.getProject = function (projectId) {
|
38
|
-
return this.getProjectFromLocalStorage(projectId);
|
39
|
-
};
|
40
|
-
LocalStorageProjectModule.prototype.saveProjects = function (projects) {
|
41
|
-
this.saveProjectsToLocalStorage(projects);
|
42
|
-
};
|
43
|
-
LocalStorageProjectModule.prototype.saveProject = function (project) {
|
44
|
-
this.saveProjectToLocalStorage(project);
|
45
|
-
};
|
46
|
-
LocalStorageProjectModule.prototype.removeProject = function (projectId) {
|
47
|
-
this.removeProjectFromLocalStorage(projectId);
|
48
|
-
};
|
49
|
-
LocalStorageProjectModule.prototype.updateProject = function (project) {
|
50
|
-
this.updateProjectInLocalStorage(project);
|
51
|
-
};
|
52
|
-
return LocalStorageProjectModule;
|
53
|
-
}());
|
54
|
-
var ProjectFileProjectModule = /** @class */ (function () {
|
55
|
-
function ProjectFileProjectModule() {
|
56
|
-
}
|
57
|
-
ProjectFileProjectModule.prototype.setSerializer = function (serializer) {
|
58
|
-
this._serializer = serializer;
|
59
|
-
};
|
60
|
-
ProjectFileProjectModule.prototype.getProjects = function () {
|
61
|
-
return this._serializer.getProjects();
|
62
|
-
};
|
63
|
-
ProjectFileProjectModule.prototype.getProject = function (projectId) {
|
64
|
-
return this._serializer.getProject(projectId);
|
65
|
-
};
|
66
|
-
ProjectFileProjectModule.prototype.saveProject = function (project) {
|
67
|
-
return this._serializer.saveProject(project);
|
68
|
-
};
|
69
|
-
ProjectFileProjectModule.prototype.saveProjects = function (projects) {
|
70
|
-
return this._serializer.saveProjects(projects);
|
71
|
-
};
|
72
|
-
ProjectFileProjectModule.prototype.removeProject = function (projectId) {
|
73
|
-
return this._serializer.removeProject(projectId);
|
74
|
-
};
|
75
|
-
ProjectFileProjectModule.prototype.updateProject = function (project) {
|
76
|
-
return this._serializer.updateProject(project);
|
77
|
-
};
|
78
|
-
return ProjectFileProjectModule;
|
79
|
-
}());
|
80
|
-
var ProjectsService = /** @class */ (function () {
|
81
|
-
function ProjectsService() {
|
82
|
-
this._modules = [];
|
83
|
-
this._serializer = ProjectFileSerializer;
|
84
|
-
this._addModule('LocalStorage', new LocalStorageProjectModule());
|
85
|
-
this._addModule('File', new ProjectFileProjectModule());
|
86
|
-
}
|
87
|
-
ProjectsService.prototype.on = function (moduleName) {
|
88
|
-
var _this = this;
|
89
|
-
var module = this._modules.find(function (module) { return module.name === moduleName; });
|
90
|
-
if (!module) {
|
91
|
-
throw new Error("Module ".concat(moduleName, " not found"));
|
92
|
-
}
|
93
|
-
return {
|
94
|
-
getSerializerInstance: function (file) { return new _this._serializer(file); },
|
95
|
-
instance: module.instance,
|
96
|
-
};
|
97
|
-
};
|
98
|
-
ProjectsService.prototype._addModule = function (name, module) {
|
99
|
-
this._modules.push({ name: name, instance: module });
|
100
|
-
};
|
101
|
-
return ProjectsService;
|
102
|
-
}());
|
103
|
-
export default ProjectsService;
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { Project } from "../types/project";
|
2
|
-
import { Guid4 } from "../utils/guid4";
|
3
|
-
var PullProjectService = /** @class */ (function () {
|
4
|
-
function PullProjectService(throughHistoryService, appStoreRepository) {
|
5
|
-
this.throughHistoryService = throughHistoryService;
|
6
|
-
this.appStoreRepository = appStoreRepository;
|
7
|
-
this._project = new Project();
|
8
|
-
}
|
9
|
-
Object.defineProperty(PullProjectService.prototype, "project", {
|
10
|
-
get: function () {
|
11
|
-
return this._project;
|
12
|
-
},
|
13
|
-
enumerable: false,
|
14
|
-
configurable: true
|
15
|
-
});
|
16
|
-
PullProjectService.prototype.refreshProject = function () {
|
17
|
-
this._project = new Project();
|
18
|
-
};
|
19
|
-
PullProjectService.prototype.updateProject = function (project) {
|
20
|
-
var _this = this;
|
21
|
-
Object.keys(project).forEach(function (key) {
|
22
|
-
_this._project[key] = project[key];
|
23
|
-
});
|
24
|
-
};
|
25
|
-
PullProjectService.prototype.pull = function (name, description) {
|
26
|
-
var project = new Project();
|
27
|
-
var state = {
|
28
|
-
cache: this.throughHistoryService.cache,
|
29
|
-
history: this.appStoreRepository.store.historyState.historyLines,
|
30
|
-
current: this.appStoreRepository.store.imageState.getEntry(),
|
31
|
-
};
|
32
|
-
project.id = new Guid4().generate();
|
33
|
-
project.description = description || 'New Project';
|
34
|
-
project.name = name || 'New Project';
|
35
|
-
project.state = state;
|
36
|
-
this._project = project;
|
37
|
-
};
|
38
|
-
return PullProjectService;
|
39
|
-
}());
|
40
|
-
export default PullProjectService;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { Filter } from "../utils/filter";
|
2
|
-
var ResizeService = /** @class */ (function () {
|
3
|
-
function ResizeService(appConfig, throughHistoryService) {
|
4
|
-
this.appConfig = appConfig;
|
5
|
-
this.throughHistoryService = throughHistoryService;
|
6
|
-
}
|
7
|
-
ResizeService.prototype.resize = function (ctx, size) {
|
8
|
-
var currentRender = this.throughHistoryService.current();
|
9
|
-
var state = currentRender === null || currentRender === void 0 ? void 0 : currentRender.stateValue;
|
10
|
-
if (!state) {
|
11
|
-
return console.warn('No state');
|
12
|
-
}
|
13
|
-
;
|
14
|
-
this.appConfig.CANVAS_SIZE = size;
|
15
|
-
this.updateCanvas(ctx, state);
|
16
|
-
};
|
17
|
-
ResizeService.prototype.updateCanvas = function (ctx, stateValue) {
|
18
|
-
var filter = new Filter(this.appConfig, ctx);
|
19
|
-
filter.update(stateValue.tempImageData, stateValue.position);
|
20
|
-
};
|
21
|
-
return ResizeService;
|
22
|
-
}());
|
23
|
-
export default ResizeService;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
var StateService = /** @class */ (function () {
|
2
|
-
function StateService() {
|
3
|
-
}
|
4
|
-
return StateService;
|
5
|
-
}());
|
6
|
-
export { StateService };
|
7
|
-
;
|
8
|
-
var StoreService = /** @class */ (function () {
|
9
|
-
function StoreService() {
|
10
|
-
}
|
11
|
-
return StoreService;
|
12
|
-
}());
|
13
|
-
export { StoreService };
|
14
|
-
;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { Filter } from "../utils/filter";
|
2
|
-
var ThroughHistoryService = /** @class */ (function () {
|
3
|
-
function ThroughHistoryService(appConfig, appStoreRepository) {
|
4
|
-
this.appConfig = appConfig;
|
5
|
-
this.appStoreRepository = appStoreRepository;
|
6
|
-
this.cache = [];
|
7
|
-
}
|
8
|
-
ThroughHistoryService.prototype.current = function () {
|
9
|
-
var history = this.appStoreRepository.store.historyState.historyLines;
|
10
|
-
var lastIndex = history.length - 1;
|
11
|
-
return history[lastIndex];
|
12
|
-
};
|
13
|
-
ThroughHistoryService.prototype.prev = function () {
|
14
|
-
var history = this.appStoreRepository.store.historyState.historyLines;
|
15
|
-
var prevIndex = history.length - 2;
|
16
|
-
return history[prevIndex];
|
17
|
-
};
|
18
|
-
ThroughHistoryService.prototype.undo = function (ctx) {
|
19
|
-
var current = this.current();
|
20
|
-
var prev = this.prev();
|
21
|
-
if (!!(current === null || current === void 0 ? void 0 : current.stateValue)) {
|
22
|
-
this.cache.unshift(current);
|
23
|
-
this.appStoreRepository.store.historyState.reduce('UNDO');
|
24
|
-
if (prev === null || prev === void 0 ? void 0 : prev.stateValue) {
|
25
|
-
this.updateCanvas(ctx, prev.stateValue);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
};
|
29
|
-
;
|
30
|
-
ThroughHistoryService.prototype.redo = function (ctx) {
|
31
|
-
var firstInCache = this.cache.shift();
|
32
|
-
if (!!(firstInCache === null || firstInCache === void 0 ? void 0 : firstInCache.stateValue)) {
|
33
|
-
this.appStoreRepository.store.historyState.reduce('REDO', firstInCache);
|
34
|
-
this.updateCanvas(ctx, firstInCache.stateValue);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
;
|
38
|
-
ThroughHistoryService.prototype.clearCache = function () {
|
39
|
-
this.cache = [];
|
40
|
-
};
|
41
|
-
ThroughHistoryService.prototype.recovery = function (project) {
|
42
|
-
this.appStoreRepository.store.historyState.reduce('SET_HISTORY', { historyLines: project.state.history });
|
43
|
-
this.cache = project.state.cache;
|
44
|
-
};
|
45
|
-
ThroughHistoryService.prototype.updateCanvas = function (ctx, stateValue) {
|
46
|
-
var filter = new Filter(this.appConfig, ctx);
|
47
|
-
filter.update(stateValue.tempImageData, stateValue.position);
|
48
|
-
};
|
49
|
-
return ThroughHistoryService;
|
50
|
-
}());
|
51
|
-
export default ThroughHistoryService;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
var ToolLayerService = /** @class */ (function () {
|
2
|
-
function ToolLayerService(appConfig) {
|
3
|
-
this.appConfig = appConfig;
|
4
|
-
this.multiplier = 1000;
|
5
|
-
}
|
6
|
-
ToolLayerService.prototype.getLayerIndex = function (layerName) {
|
7
|
-
var layer = this.appConfig.LAYERS.find(function (layer) { return layer.name === layerName; });
|
8
|
-
var zIndex = this.multiplier * layer.index;
|
9
|
-
return zIndex;
|
10
|
-
};
|
11
|
-
return ToolLayerService;
|
12
|
-
}());
|
13
|
-
export default ToolLayerService;
|
@@ -1,59 +0,0 @@
|
|
1
|
-
var ToolService = /** @class */ (function () {
|
2
|
-
function ToolService(canvasComponent) {
|
3
|
-
this.canvasComponent = canvasComponent;
|
4
|
-
this.before = null;
|
5
|
-
this.active = null;
|
6
|
-
this.registry = [];
|
7
|
-
}
|
8
|
-
ToolService.prototype.add = function (tool) {
|
9
|
-
var hasRegisteredTool = this.registry.find(function (registeredTool) { return registeredTool.id === tool.id; });
|
10
|
-
if (hasRegisteredTool) {
|
11
|
-
console.warn('Tool has been previously registered!');
|
12
|
-
return false;
|
13
|
-
}
|
14
|
-
this.registry.push(tool);
|
15
|
-
return true;
|
16
|
-
};
|
17
|
-
ToolService.prototype.setActive = function (id) {
|
18
|
-
var _a, _b, _c;
|
19
|
-
if (((_a = this.active) === null || _a === void 0 ? void 0 : _a.id) === id)
|
20
|
-
return console.warn('Tool is already active');
|
21
|
-
if (!!((_b = this.active) === null || _b === void 0 ? void 0 : _b.offAction)) {
|
22
|
-
this.active.offAction();
|
23
|
-
}
|
24
|
-
var registeredTool = this.registry.find(function (registeredTool) { return registeredTool.id === id; });
|
25
|
-
if (!!registeredTool) {
|
26
|
-
this.active = registeredTool;
|
27
|
-
if (!!((_c = this.active) === null || _c === void 0 ? void 0 : _c.onAction)) {
|
28
|
-
this.active.onAction();
|
29
|
-
}
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
console.warn('Tool has not previously been registered with this identifier');
|
33
|
-
}
|
34
|
-
};
|
35
|
-
ToolService.prototype.offActive = function (id) {
|
36
|
-
if (!!id) {
|
37
|
-
if (this.active.id === id) {
|
38
|
-
this.off();
|
39
|
-
}
|
40
|
-
else {
|
41
|
-
return console.warn("ID active tool is not \"".concat(id, "\""));
|
42
|
-
}
|
43
|
-
}
|
44
|
-
else {
|
45
|
-
this.off();
|
46
|
-
}
|
47
|
-
};
|
48
|
-
ToolService.prototype.off = function () {
|
49
|
-
var _a;
|
50
|
-
if (!!((_a = this.active) === null || _a === void 0 ? void 0 : _a.offAction)) {
|
51
|
-
this.active.offAction();
|
52
|
-
}
|
53
|
-
this.before = this.active;
|
54
|
-
this.active = null;
|
55
|
-
this.canvasComponent.cursorStyle = 'default';
|
56
|
-
};
|
57
|
-
return ToolService;
|
58
|
-
}());
|
59
|
-
export default ToolService;
|
@@ -1,85 +0,0 @@
|
|
1
|
-
;
|
2
|
-
var DrawLayersState = /** @class */ (function () {
|
3
|
-
function DrawLayersState(appStoreRepository) {
|
4
|
-
this.appStoreRepository = appStoreRepository;
|
5
|
-
this.default = {
|
6
|
-
layers: [],
|
7
|
-
};
|
8
|
-
this._layers = this.default.layers;
|
9
|
-
this.reset();
|
10
|
-
}
|
11
|
-
Object.defineProperty(DrawLayersState.prototype, "layers", {
|
12
|
-
get: function () { return this._layers; },
|
13
|
-
enumerable: false,
|
14
|
-
configurable: true
|
15
|
-
});
|
16
|
-
;
|
17
|
-
DrawLayersState.prototype.reduce = function (name, payload) {
|
18
|
-
var reducer = new Reducer(this);
|
19
|
-
switch (name) {
|
20
|
-
case 'SET_LAYERS':
|
21
|
-
reducer.setLayers(payload);
|
22
|
-
break;
|
23
|
-
case 'UPDATE_LAYER':
|
24
|
-
reducer.updateLayer(payload);
|
25
|
-
break;
|
26
|
-
case 'ADD_LAYER':
|
27
|
-
reducer.addLayer(payload);
|
28
|
-
break;
|
29
|
-
}
|
30
|
-
};
|
31
|
-
DrawLayersState.prototype.emerge = function (completeIt) {
|
32
|
-
this._emergeCompleteIt = completeIt;
|
33
|
-
};
|
34
|
-
DrawLayersState.prototype.reset = function () {
|
35
|
-
this.reduce('SET_LAYERS', this.default);
|
36
|
-
};
|
37
|
-
return DrawLayersState;
|
38
|
-
}());
|
39
|
-
export { DrawLayersState };
|
40
|
-
var Reducer = /** @class */ (function () {
|
41
|
-
function Reducer(state) {
|
42
|
-
this.state = state;
|
43
|
-
}
|
44
|
-
;
|
45
|
-
Reducer.prototype.setLayers = function (payload) {
|
46
|
-
var isUpdate = false;
|
47
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.layers)) {
|
48
|
-
this.state._layers = payload.layers;
|
49
|
-
isUpdate = true;
|
50
|
-
}
|
51
|
-
if (isUpdate && !!this.state._emergeCompleteIt) {
|
52
|
-
this.state._emergeCompleteIt(this.state._layers);
|
53
|
-
}
|
54
|
-
};
|
55
|
-
Reducer.prototype.updateLayer = function (payload) {
|
56
|
-
var isUpdate = false;
|
57
|
-
if (!!payload) {
|
58
|
-
var targetLayerIndex = this.state._layers.findIndex(function (layer) { return layer.id === payload.id; });
|
59
|
-
if (targetLayerIndex != -1) {
|
60
|
-
this.state._layers[targetLayerIndex] = payload;
|
61
|
-
isUpdate = true;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
if (isUpdate && !!this.state._emergeCompleteIt) {
|
65
|
-
this.state._emergeCompleteIt(this.state._layers);
|
66
|
-
}
|
67
|
-
};
|
68
|
-
Reducer.prototype.addLayer = function (payload) {
|
69
|
-
var isUpdate = false;
|
70
|
-
if (!!payload) {
|
71
|
-
this.state._layers.unshift(payload);
|
72
|
-
isUpdate = true;
|
73
|
-
}
|
74
|
-
if (isUpdate && !!this.state._emergeCompleteIt) {
|
75
|
-
this.state._emergeCompleteIt(this.state._layers);
|
76
|
-
}
|
77
|
-
};
|
78
|
-
Reducer.prototype.popLayer = function () {
|
79
|
-
this.state._layers.pop();
|
80
|
-
if (!!this.state._emergeCompleteIt) {
|
81
|
-
this.state._emergeCompleteIt(this.state._layers);
|
82
|
-
}
|
83
|
-
};
|
84
|
-
return Reducer;
|
85
|
-
}());
|
@@ -1,77 +0,0 @@
|
|
1
|
-
;
|
2
|
-
var HistoryState = /** @class */ (function () {
|
3
|
-
function HistoryState(throughHistoryService) {
|
4
|
-
this.throughHistoryService = throughHistoryService;
|
5
|
-
this.default = {
|
6
|
-
historyLines: [],
|
7
|
-
};
|
8
|
-
this._historyLines = this.default.historyLines;
|
9
|
-
this.reset();
|
10
|
-
}
|
11
|
-
Object.defineProperty(HistoryState.prototype, "historyLines", {
|
12
|
-
get: function () { return this._historyLines; },
|
13
|
-
enumerable: false,
|
14
|
-
configurable: true
|
15
|
-
});
|
16
|
-
;
|
17
|
-
HistoryState.prototype.reduce = function (name, payload) {
|
18
|
-
var reducer = new Reducer(this);
|
19
|
-
switch (name) {
|
20
|
-
case 'SET_HISTORY':
|
21
|
-
reducer.setHistoryLines(payload);
|
22
|
-
this.throughHistoryService.clearCache();
|
23
|
-
break;
|
24
|
-
case 'UPDATE_HISTORY':
|
25
|
-
reducer.updateHistoryLines(payload);
|
26
|
-
this.throughHistoryService.clearCache();
|
27
|
-
break;
|
28
|
-
case 'REDO':
|
29
|
-
reducer.updateHistoryLines(payload);
|
30
|
-
break;
|
31
|
-
case 'UNDO':
|
32
|
-
reducer.popHistoryLines();
|
33
|
-
break;
|
34
|
-
}
|
35
|
-
};
|
36
|
-
HistoryState.prototype.emerge = function (completeIt) {
|
37
|
-
this._emergeCompleteIt = completeIt;
|
38
|
-
};
|
39
|
-
HistoryState.prototype.reset = function () {
|
40
|
-
this.reduce('SET_HISTORY', this.default);
|
41
|
-
};
|
42
|
-
return HistoryState;
|
43
|
-
}());
|
44
|
-
export { HistoryState };
|
45
|
-
var Reducer = /** @class */ (function () {
|
46
|
-
function Reducer(state) {
|
47
|
-
this.state = state;
|
48
|
-
}
|
49
|
-
;
|
50
|
-
Reducer.prototype.setHistoryLines = function (payload) {
|
51
|
-
var isUpdate = false;
|
52
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.historyLines)) {
|
53
|
-
this.state._historyLines = payload.historyLines;
|
54
|
-
isUpdate = true;
|
55
|
-
}
|
56
|
-
if (isUpdate && !!this.state._emergeCompleteIt) {
|
57
|
-
this.state._emergeCompleteIt(this.state._historyLines);
|
58
|
-
}
|
59
|
-
};
|
60
|
-
Reducer.prototype.updateHistoryLines = function (payload) {
|
61
|
-
var isUpdate = false;
|
62
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.view)) {
|
63
|
-
this.state._historyLines.push(payload);
|
64
|
-
isUpdate = true;
|
65
|
-
}
|
66
|
-
if (isUpdate && !!this.state._emergeCompleteIt) {
|
67
|
-
this.state._emergeCompleteIt(this.state._historyLines);
|
68
|
-
}
|
69
|
-
};
|
70
|
-
Reducer.prototype.popHistoryLines = function () {
|
71
|
-
this.state._historyLines.pop();
|
72
|
-
if (!!this.state._emergeCompleteIt) {
|
73
|
-
this.state._emergeCompleteIt(this.state._historyLines);
|
74
|
-
}
|
75
|
-
};
|
76
|
-
return Reducer;
|
77
|
-
}());
|
@@ -1,80 +0,0 @@
|
|
1
|
-
;
|
2
|
-
;
|
3
|
-
var ImageState = /** @class */ (function () {
|
4
|
-
function ImageState(appStoreRepository) {
|
5
|
-
this.appStoreRepository = appStoreRepository;
|
6
|
-
this.default = {
|
7
|
-
position: {
|
8
|
-
x: 0,
|
9
|
-
y: 0,
|
10
|
-
},
|
11
|
-
size: {
|
12
|
-
width: 0,
|
13
|
-
height: 0,
|
14
|
-
},
|
15
|
-
tempImageData: null,
|
16
|
-
};
|
17
|
-
this._position = this.default.position;
|
18
|
-
this._size = this.default.size;
|
19
|
-
this._tempImageData = this.default.tempImageData;
|
20
|
-
this.reset();
|
21
|
-
}
|
22
|
-
Object.defineProperty(ImageState.prototype, "position", {
|
23
|
-
get: function () { return this._position; },
|
24
|
-
enumerable: false,
|
25
|
-
configurable: true
|
26
|
-
});
|
27
|
-
;
|
28
|
-
Object.defineProperty(ImageState.prototype, "size", {
|
29
|
-
get: function () { return this._size; },
|
30
|
-
enumerable: false,
|
31
|
-
configurable: true
|
32
|
-
});
|
33
|
-
;
|
34
|
-
Object.defineProperty(ImageState.prototype, "tempImageData", {
|
35
|
-
get: function () { return this._tempImageData; },
|
36
|
-
enumerable: false,
|
37
|
-
configurable: true
|
38
|
-
});
|
39
|
-
;
|
40
|
-
ImageState.prototype.reduce = function (payload, title) {
|
41
|
-
var isUpdate = false;
|
42
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.position)) {
|
43
|
-
this._position = payload.position;
|
44
|
-
}
|
45
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.size)) {
|
46
|
-
this._size = payload.size;
|
47
|
-
}
|
48
|
-
if (!!(payload === null || payload === void 0 ? void 0 : payload.tempImageData)) {
|
49
|
-
this._tempImageData = payload.tempImageData;
|
50
|
-
isUpdate = true;
|
51
|
-
}
|
52
|
-
if (isUpdate) {
|
53
|
-
this.addToHistory("".concat(title || "reduce image"));
|
54
|
-
}
|
55
|
-
};
|
56
|
-
ImageState.prototype.reset = function () {
|
57
|
-
this.reduce(this.default, "reset to default");
|
58
|
-
};
|
59
|
-
ImageState.prototype.getEntry = function () {
|
60
|
-
return {
|
61
|
-
position: this._position,
|
62
|
-
size: this._size,
|
63
|
-
imageData: this._tempImageData,
|
64
|
-
};
|
65
|
-
};
|
66
|
-
ImageState.prototype.addToHistory = function (title) {
|
67
|
-
var stateValue = {
|
68
|
-
position: this._position,
|
69
|
-
size: this._size,
|
70
|
-
tempImageData: this._tempImageData,
|
71
|
-
};
|
72
|
-
this.appStoreRepository.store.historyState.reduce('UPDATE_HISTORY', {
|
73
|
-
view: title,
|
74
|
-
stateName: 'image',
|
75
|
-
stateValue: stateValue,
|
76
|
-
});
|
77
|
-
};
|
78
|
-
return ImageState;
|
79
|
-
}());
|
80
|
-
export { ImageState };
|
package/dist/store/store.js
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
import { DrawLayersState } from "./draw-layers.state";
|
2
|
-
import { HistoryState } from "./history.state";
|
3
|
-
import { ImageState } from "./image.state";
|
4
|
-
var Store = /** @class */ (function () {
|
5
|
-
function Store(imageState, historyState, drawLayersState) {
|
6
|
-
this.imageState = imageState;
|
7
|
-
this.historyState = historyState;
|
8
|
-
this.drawLayersState = drawLayersState;
|
9
|
-
}
|
10
|
-
;
|
11
|
-
Store.prototype.reset = function () {
|
12
|
-
this.imageState.reset();
|
13
|
-
this.historyState.reset();
|
14
|
-
this.drawLayersState.reset();
|
15
|
-
};
|
16
|
-
return Store;
|
17
|
-
}());
|
18
|
-
export { Store };
|
19
|
-
var AppStore = /** @class */ (function () {
|
20
|
-
function AppStore(throughHistoryService, appStoreRepository) {
|
21
|
-
this.throughHistoryService = throughHistoryService;
|
22
|
-
this.appStoreRepository = appStoreRepository;
|
23
|
-
this.appStoreRepository.store = new Store(new ImageState(this.appStoreRepository), new HistoryState(this.throughHistoryService), new DrawLayersState(this.appStoreRepository));
|
24
|
-
}
|
25
|
-
AppStore.prototype.subscribe = function (to, completeIt) {
|
26
|
-
if (to === 'history') {
|
27
|
-
this.appStoreRepository.store.historyState.emerge(completeIt);
|
28
|
-
}
|
29
|
-
else if (to === 'layers') {
|
30
|
-
this.appStoreRepository.store.drawLayersState.emerge(completeIt);
|
31
|
-
}
|
32
|
-
};
|
33
|
-
AppStore.prototype.getHistoryLines = function () {
|
34
|
-
return this.appStoreRepository.store.historyState.historyLines;
|
35
|
-
};
|
36
|
-
AppStore.prototype.getLayers = function () {
|
37
|
-
return this.appStoreRepository.store.drawLayersState.layers;
|
38
|
-
};
|
39
|
-
return AppStore;
|
40
|
-
}());
|
41
|
-
export default AppStore;
|
package/dist/types/canvas.js
DELETED
package/dist/types/cursor.js
DELETED
package/dist/types/excretion.js
DELETED