canvas-editor-engine 2.3.17 → 2.3.19
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/components/canvas.component.js +102 -0
- package/dist/components/excretions.component.js +258 -0
- package/dist/components/loading.component.js +71 -0
- package/dist/components/pipette.component.js +120 -0
- package/dist/components/slot.component.js +45 -0
- package/dist/config.js +95 -0
- package/dist/filters/collection/vague.js +168 -0
- package/dist/filters/index.js +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +75 -0
- package/dist/services/component.service.js +40 -0
- package/dist/services/crop.service.js +60 -0
- package/dist/services/download.service.js +16 -0
- package/dist/services/draw-accumulator.service.d.ts +25 -0
- package/dist/services/draw-accumulator.service.js +222 -0
- package/dist/services/draw-layers.service.d.ts +17 -0
- package/dist/services/draw-layers.service.js +72 -0
- package/dist/services/draw-leayers.service.js +72 -0
- package/dist/services/draw.service.d.ts +1 -21
- package/dist/services/draw.service.js +259 -0
- package/dist/services/event.service.js +45 -0
- package/dist/services/logger.service.js +57 -0
- package/dist/services/projects.service.js +103 -0
- package/dist/services/pull-project.service.js +40 -0
- package/dist/services/serize.service.js +23 -0
- package/dist/services/store.service.js +14 -0
- package/dist/services/through-history.service.js +51 -0
- package/dist/services/tool-layers.service.js +13 -0
- package/dist/services/tool.service.js +59 -0
- package/dist/store/draw-layers.state.js +85 -0
- package/dist/store/history.state.js +77 -0
- package/dist/store/image.state.js +80 -0
- package/dist/store/store.js +41 -0
- package/dist/store/storeRepository.js +6 -0
- package/dist/types/canvas.js +2 -0
- package/dist/types/cursor.js +2 -0
- package/dist/types/draw-layers.js +3 -0
- package/dist/types/draw-service.js +2 -0
- package/dist/types/excretion.js +4 -0
- package/dist/types/general.js +5 -0
- package/dist/types/history.js +1 -0
- package/dist/types/image.js +9 -0
- package/dist/types/log.js +4 -0
- package/dist/types/pipette.js +1 -0
- package/dist/types/project.js +14 -0
- package/dist/types/temp-canvas.js +2 -0
- package/dist/utils/convert.js +27 -0
- package/dist/utils/filter.js +153 -0
- package/dist/utils/generation.js +7 -0
- package/dist/utils/guid4.js +122 -0
- package/dist/utils/project-file-serializer.js +77 -0
- package/dist/utils/reflect.js +30 -0
- package/dist/utils/temp-canvas.js +19 -0
- package/dist/web-component.d.ts +4 -3
- package/dist/web-component.js +179 -0
- package/package.json +1 -1
@@ -0,0 +1,179 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { reflect } from "./utils/reflect";
|
17
|
+
reflect();
|
18
|
+
import CanvasComponent from "./components/canvas.component";
|
19
|
+
import ExcretionsComponent from "./components/excretions.component";
|
20
|
+
import LoadingComponent from "./components/loading.component";
|
21
|
+
import PipetteComponent from "./components/pipette.component";
|
22
|
+
import SlotComponent from "./components/slot.component";
|
23
|
+
import EventService from "./services/event.service";
|
24
|
+
import LoggerService from "./services/logger.service";
|
25
|
+
import ToolLayerService from "./services/tool-layers.service";
|
26
|
+
import ToolService from "./services/tool.service";
|
27
|
+
import CropService from "./services/crop.service";
|
28
|
+
import AppStore from "./store/store";
|
29
|
+
import ThroughHistoryService from "./services/through-history.service";
|
30
|
+
import AppStoreRepository from "./store/storeRepository";
|
31
|
+
import ProjectsService from "./services/projects.service";
|
32
|
+
import PullProjectService from "./services/pull-project.service";
|
33
|
+
import DrawService from "./services/draw.service";
|
34
|
+
import DownloadService from "./services/download.service";
|
35
|
+
import ResizeService from "./services/serize.service";
|
36
|
+
import DrawLayersService from "./services/draw-layers.service";
|
37
|
+
import DrawAccumulatorService from "./services/draw-accumulator.service";
|
38
|
+
var WebComponentWrapper = /** @class */ (function () {
|
39
|
+
function WebComponentWrapper() {
|
40
|
+
var base = document.createElement('div');
|
41
|
+
base.className = 'wc-editor';
|
42
|
+
base.style.position = 'relative';
|
43
|
+
base.style.display = 'flex';
|
44
|
+
base.style.overflow = 'hidden';
|
45
|
+
var stylesWrap = document.createElement('div');
|
46
|
+
stylesWrap.className = 'styles-wrap';
|
47
|
+
var editorWrap = document.createElement('div');
|
48
|
+
editorWrap.className = 'editor-wrap';
|
49
|
+
editorWrap.style.position = 'relative';
|
50
|
+
editorWrap.style.display = 'flex';
|
51
|
+
editorWrap.style.overflow = 'hidden';
|
52
|
+
var toolsWrap = document.createElement('div');
|
53
|
+
toolsWrap.className = 'tools-wrap';
|
54
|
+
toolsWrap.style.position = 'relative';
|
55
|
+
toolsWrap.style.display = 'flex';
|
56
|
+
base.appendChild(stylesWrap);
|
57
|
+
base.appendChild(editorWrap);
|
58
|
+
base.appendChild(toolsWrap);
|
59
|
+
this.baseElement = base;
|
60
|
+
this.stylesWrapElement = stylesWrap;
|
61
|
+
this.editorWrapElement = editorWrap;
|
62
|
+
this.toolsWrapElement = toolsWrap;
|
63
|
+
this._baseStyle();
|
64
|
+
}
|
65
|
+
Object.defineProperty(WebComponentWrapper.prototype, "base", {
|
66
|
+
get: function () {
|
67
|
+
return this._methods(this.baseElement);
|
68
|
+
},
|
69
|
+
enumerable: false,
|
70
|
+
configurable: true
|
71
|
+
});
|
72
|
+
;
|
73
|
+
Object.defineProperty(WebComponentWrapper.prototype, "editorWrap", {
|
74
|
+
get: function () {
|
75
|
+
return this._methods(this.editorWrapElement);
|
76
|
+
},
|
77
|
+
enumerable: false,
|
78
|
+
configurable: true
|
79
|
+
});
|
80
|
+
;
|
81
|
+
Object.defineProperty(WebComponentWrapper.prototype, "stylesWrap", {
|
82
|
+
get: function () {
|
83
|
+
return this._methods(this.stylesWrapElement);
|
84
|
+
},
|
85
|
+
enumerable: false,
|
86
|
+
configurable: true
|
87
|
+
});
|
88
|
+
;
|
89
|
+
Object.defineProperty(WebComponentWrapper.prototype, "toolsWrap", {
|
90
|
+
get: function () {
|
91
|
+
return this._methods(this.toolsWrapElement);
|
92
|
+
},
|
93
|
+
enumerable: false,
|
94
|
+
configurable: true
|
95
|
+
});
|
96
|
+
;
|
97
|
+
WebComponentWrapper.prototype._methods = function (elementWrapper) {
|
98
|
+
var _this = this;
|
99
|
+
return {
|
100
|
+
add: function (component, style) { return _this._add(elementWrapper, component, style); },
|
101
|
+
};
|
102
|
+
};
|
103
|
+
WebComponentWrapper.prototype._add = function (elementWrapper, component, style) {
|
104
|
+
var componentElement = elementWrapper.appendChild(component);
|
105
|
+
if (!!style) {
|
106
|
+
this.stylesWrapElement.appendChild(style);
|
107
|
+
}
|
108
|
+
return componentElement;
|
109
|
+
};
|
110
|
+
WebComponentWrapper.prototype._baseStyle = function () {
|
111
|
+
var style = document.createElement('style');
|
112
|
+
style.innerHTML = "\n * {\n user-select: none;\n }\n ";
|
113
|
+
this.stylesWrapElement.appendChild(style);
|
114
|
+
};
|
115
|
+
return WebComponentWrapper;
|
116
|
+
}());
|
117
|
+
export { WebComponentWrapper };
|
118
|
+
var WebComponent = /** @class */ (function (_super) {
|
119
|
+
__extends(WebComponent, _super);
|
120
|
+
function WebComponent() {
|
121
|
+
var _this = _super.call(this) || this;
|
122
|
+
var shadowRoot = _this.attachShadow({ mode: "open" });
|
123
|
+
_this.webComponentWrapper = new WebComponentWrapper();
|
124
|
+
shadowRoot.appendChild(_this.webComponentWrapper.baseElement);
|
125
|
+
return _this;
|
126
|
+
}
|
127
|
+
WebComponent.prototype.init = function (appConfig) {
|
128
|
+
this.appConfig = appConfig;
|
129
|
+
this.projectsService = new ProjectsService();
|
130
|
+
this.loggerService = new LoggerService();
|
131
|
+
this.toolLayerService = new ToolLayerService(this.appConfig);
|
132
|
+
this.eventService = new EventService();
|
133
|
+
this.canvasComponent = new CanvasComponent(this.appConfig, this.loggerService, this.toolLayerService);
|
134
|
+
this.toolService = new ToolService(this.canvasComponent);
|
135
|
+
this.appStoreRepository = new AppStoreRepository();
|
136
|
+
this.throughHistoryService = new ThroughHistoryService(this.appConfig, this.appStoreRepository);
|
137
|
+
this.resizeService = new ResizeService(this.appConfig, this.throughHistoryService);
|
138
|
+
this.appStore = new AppStore(this.throughHistoryService, this.appStoreRepository);
|
139
|
+
this.pullProjectService = new PullProjectService(this.throughHistoryService, this.appStoreRepository);
|
140
|
+
this.drawService = new DrawService(this.appConfig, this.appStoreRepository, this.eventService);
|
141
|
+
this.drawLayersService = new DrawLayersService(this.appStoreRepository);
|
142
|
+
this.drawAccumulatorService = new DrawAccumulatorService(this.appConfig, this.appStoreRepository, this.eventService, this.drawLayersService);
|
143
|
+
this.downloadService = new DownloadService(this.canvasComponent);
|
144
|
+
var _a = this.canvasComponent.getComponent(), canvasTemplate = _a.canvasTemplate, canvasStyle = _a.canvasStyle;
|
145
|
+
this.canvasElement = this.webComponentWrapper.editorWrap.add(canvasTemplate, canvasStyle);
|
146
|
+
var pipetteComponent = new PipetteComponent(this.toolService, this.loggerService, this.canvasComponent);
|
147
|
+
var _b = pipetteComponent.getComponent(), pipetteTemplate = _b.pipetteTemplate, pipetteStyle = _b.pipetteStyle;
|
148
|
+
this.webComponentWrapper.editorWrap.add(pipetteTemplate, pipetteStyle);
|
149
|
+
var slotComponent = new SlotComponent(this.loggerService);
|
150
|
+
var _c = slotComponent.getComponent('tools'), slotTemplate = _c.slotTemplate, slotStyle = _c.slotStyle;
|
151
|
+
this.webComponentWrapper.toolsWrap.add(slotTemplate, slotStyle);
|
152
|
+
this.excretionsComponent = new ExcretionsComponent(this.toolService, this.loggerService, this.toolLayerService, this.canvasComponent);
|
153
|
+
this.cropService = new CropService(this.appConfig, this.appStoreRepository, this.excretionsComponent);
|
154
|
+
var _d = this.excretionsComponent.getComponent(), excretionsTemplate = _d.excretionsTemplate, excretionsStyle = _d.excretionsStyle;
|
155
|
+
this.webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
|
156
|
+
var loadingComponent = new LoadingComponent(this.loggerService, this.eventService);
|
157
|
+
var _e = loadingComponent.getComponent(), loadingTemplate = _e.loadingTemplate, loadingStyle = _e.loadingStyle;
|
158
|
+
this.webComponentWrapper.editorWrap.add(loadingTemplate, loadingStyle);
|
159
|
+
this.canvasComponent.simulateSubscriptions();
|
160
|
+
this.eventService.applyEvents(this.webComponentWrapper.baseElement);
|
161
|
+
return this.initial();
|
162
|
+
};
|
163
|
+
WebComponent.prototype.initial = function () {
|
164
|
+
this.appConfig.bindCanvas(this.canvasElement);
|
165
|
+
return {
|
166
|
+
editorElement: this.canvasElement,
|
167
|
+
canvasSelector: this.canvasComponent.getCanvasSelector(),
|
168
|
+
};
|
169
|
+
};
|
170
|
+
WebComponent.prototype.restoreJSONProjects = function (layerId, jsonProjects) {
|
171
|
+
var projectProcessor = this.projectsService.on('File');
|
172
|
+
var serializer = projectProcessor.getSerializerInstance(jsonProjects);
|
173
|
+
var projects = serializer.getProjects();
|
174
|
+
this.drawAccumulatorService.add(layerId, 'project', projects[0], projects[0].state.current.size);
|
175
|
+
this.throughHistoryService.recovery(projects[0]);
|
176
|
+
};
|
177
|
+
return WebComponent;
|
178
|
+
}(HTMLElement));
|
179
|
+
export default WebComponent;
|