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,102 @@
|
|
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 ComponentService from "../services/component.service";
|
17
|
+
var CanvasComponent = /** @class */ (function (_super) {
|
18
|
+
__extends(CanvasComponent, _super);
|
19
|
+
function CanvasComponent(appConfig, loggerService, toolLayerService) {
|
20
|
+
var _this = _super.call(this) || this;
|
21
|
+
_this.appConfig = appConfig;
|
22
|
+
_this.loggerService = loggerService;
|
23
|
+
_this.toolLayerService = toolLayerService;
|
24
|
+
_this.template = "\n <div id=\"event-listener\"></div>\n <canvas id=\"sc-canvas\"></canvas>\n ";
|
25
|
+
_this.css = "\n #event-listener {\n position: absolute;\n z-index: ".concat(_this.toolLayerService.getLayerIndex('normal'), ";\n }\n ");
|
26
|
+
_this.subscriptions = {
|
27
|
+
click: [],
|
28
|
+
mousemove: [],
|
29
|
+
mousedown: [],
|
30
|
+
mouseup: [],
|
31
|
+
};
|
32
|
+
_this._cursorStyle = {
|
33
|
+
before: null,
|
34
|
+
current: 'default',
|
35
|
+
};
|
36
|
+
_this.loggerService.components.add({
|
37
|
+
info: {
|
38
|
+
name: 'canvas',
|
39
|
+
description: 'canvas component',
|
40
|
+
},
|
41
|
+
prototype: _this,
|
42
|
+
});
|
43
|
+
return _this;
|
44
|
+
}
|
45
|
+
;
|
46
|
+
CanvasComponent.prototype.getComponent = function () {
|
47
|
+
var canvasTemplate = this.getTemplate(this.template);
|
48
|
+
var canvasStyle = this.getStyle(this.css);
|
49
|
+
canvasTemplate.style.display = 'flex';
|
50
|
+
this.canvas = canvasTemplate.getElementsByTagName('canvas')[0];
|
51
|
+
this.canvas.width = this.appConfig.CANVAS_SIZE.width;
|
52
|
+
this.canvas.height = this.appConfig.CANVAS_SIZE.height;
|
53
|
+
this.ctx = this.canvas.getContext("2d", { willReadFrequently: true });
|
54
|
+
this.eventListener = canvasTemplate.querySelector('#event-listener');
|
55
|
+
this.eventListener.style.width = this.appConfig.CANVAS_SIZE.width + 'px';
|
56
|
+
this.eventListener.style.height = this.appConfig.CANVAS_SIZE.height + 'px';
|
57
|
+
return { canvasTemplate: canvasTemplate, canvasStyle: canvasStyle };
|
58
|
+
};
|
59
|
+
CanvasComponent.prototype.getCanvasSelector = function () {
|
60
|
+
return '#sc-canvas';
|
61
|
+
};
|
62
|
+
Object.defineProperty(CanvasComponent.prototype, "cursorStyle", {
|
63
|
+
set: function (styleName) {
|
64
|
+
if (!!styleName) {
|
65
|
+
this._cursorStyle.before = this._cursorStyle.current;
|
66
|
+
this._cursorStyle.current = styleName;
|
67
|
+
this.eventListener.style.cursor = styleName;
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
this.eventListener.style.cursor = 'default';
|
71
|
+
}
|
72
|
+
},
|
73
|
+
enumerable: false,
|
74
|
+
configurable: true
|
75
|
+
});
|
76
|
+
CanvasComponent.prototype.getCursorPosition = function (event) {
|
77
|
+
var rect = this.canvas.getBoundingClientRect();
|
78
|
+
var x = (event.clientX - rect.left) / this.appConfig.ZOOM;
|
79
|
+
var y = (event.clientY - rect.top) / this.appConfig.ZOOM;
|
80
|
+
return { x: x, y: y };
|
81
|
+
};
|
82
|
+
CanvasComponent.prototype.subscribe = function (eventName, action) {
|
83
|
+
this.subscriptions[eventName].push(action);
|
84
|
+
};
|
85
|
+
CanvasComponent.prototype.simulateSubscriptions = function () {
|
86
|
+
var _this = this;
|
87
|
+
var eventNames = Object.keys(this.subscriptions);
|
88
|
+
eventNames.forEach(function (eventName) {
|
89
|
+
var actionsList = _this.subscriptions[eventName];
|
90
|
+
if (!!actionsList.length) {
|
91
|
+
_this.eventListener.addEventListener(eventName, function (event) {
|
92
|
+
var cursorPosition = _this.getCursorPosition(event);
|
93
|
+
actionsList.forEach(function (action) {
|
94
|
+
action(event, cursorPosition);
|
95
|
+
});
|
96
|
+
});
|
97
|
+
}
|
98
|
+
});
|
99
|
+
};
|
100
|
+
return CanvasComponent;
|
101
|
+
}(ComponentService));
|
102
|
+
export default CanvasComponent;
|
@@ -0,0 +1,258 @@
|
|
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 ComponentService from "../services/component.service";
|
19
|
+
var ExcretionsComponent = /** @class */ (function (_super) {
|
20
|
+
__extends(ExcretionsComponent, _super);
|
21
|
+
function ExcretionsComponent(toolService, loggerService, toolLayerService,
|
22
|
+
// private cropService: CropService,
|
23
|
+
canvasComponent) {
|
24
|
+
var _this = _super.call(this) || this;
|
25
|
+
_this.toolService = toolService;
|
26
|
+
_this.loggerService = loggerService;
|
27
|
+
_this.toolLayerService = toolLayerService;
|
28
|
+
_this.canvasComponent = canvasComponent;
|
29
|
+
_this.template = "";
|
30
|
+
_this.templateExcretion = "\n <button type=\"button\" class=\"crop-button\">\n <svg fill=\"#ffffff\" viewBox=\"0 0 1920 1920\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"#ffffff\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M426.667 0h106.666v1386.67H1920v106.66H426.667V0zM320 426.667H0v106.666h320V426.667zm320 0v106.666h746.67V1280h106.66V426.667H640zM1493.33 1600h-106.66v320h106.66v-320z\"></path> </g></svg>\n </button>\n ";
|
31
|
+
_this._excretionDefaultStyle = ['excretion'];
|
32
|
+
_this.css = "\n .excretion {\n display: flex;\n position: absolute;\n background-image: linear-gradient(90deg, silver 50%, transparent 50%), linear-gradient(90deg, silver 50%, transparent 50%), linear-gradient(0deg, silver 50%, transparent 50%), linear-gradient(0deg, silver 50%, transparent 50%);\n background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;\n background-size: 8px 1px, 8px 1px, 1px 8px, 1px 8px;\n background-position: left top, right bottom, left bottom, right top;\n animation: border-dance 1s infinite linear;\n z-index: ".concat(_this.toolLayerService.getLayerIndex('low'), ";\n }\n\n .excretion_crop {\n box-shadow: 0px 0px 0px calc(100vw + 100vh) #50505070;\n }\n\n .crop-button {\n display: none;\n justify-content: center;\n align-items: center;\n position: absolute;\n padding: 5px;\n right: -35px;\n top: 0;\n background: #232222;\n border: 1px solid #ffffff50;\n border-radius: 4px;\n width: 30px;\n height: 30px;\n cursor: pointer;\n z-index: ").concat(_this.toolLayerService.getLayerIndex('high'), ";\n }\n\n .crop-button--view {\n display: flex;\n }\n\n @keyframes border-dance {\n 0% {\n background-position: left top, right bottom, left bottom, right top;\n }\n 100% {\n background-position: left 8px top, right 8px bottom, left bottom 8px, right top 8px;\n }\n }\n ");
|
33
|
+
_this._excretions = [];
|
34
|
+
_this._excretionState = 'abandoned';
|
35
|
+
_this._excretionActivity = 'abandoned';
|
36
|
+
_this._excretionToolState = 'abandoned';
|
37
|
+
_this._tempCoords = [];
|
38
|
+
_this.excretionsCoords = [];
|
39
|
+
_this._additionStyle = 'default';
|
40
|
+
_this.tool = {
|
41
|
+
id: 1,
|
42
|
+
name: 'excretion',
|
43
|
+
onAction: function () { return _this.setToolState('taken'); },
|
44
|
+
offAction: function () { return _this.setToolState('abandoned'); },
|
45
|
+
support: function () {
|
46
|
+
_this.clearExcretionsCoords();
|
47
|
+
_this.additionStyle = 'default';
|
48
|
+
},
|
49
|
+
};
|
50
|
+
_this.toolService.add(_this.tool);
|
51
|
+
_this.loggerService.components.add({
|
52
|
+
info: {
|
53
|
+
name: 'excretion',
|
54
|
+
description: 'excretion component',
|
55
|
+
},
|
56
|
+
prototype: _this,
|
57
|
+
});
|
58
|
+
return _this;
|
59
|
+
}
|
60
|
+
Object.defineProperty(ExcretionsComponent.prototype, "additionStyle", {
|
61
|
+
get: function () {
|
62
|
+
return this._additionStyle;
|
63
|
+
},
|
64
|
+
set: function (value) {
|
65
|
+
this._additionStyle = value;
|
66
|
+
this.applyExcretionStyle();
|
67
|
+
},
|
68
|
+
enumerable: false,
|
69
|
+
configurable: true
|
70
|
+
});
|
71
|
+
ExcretionsComponent.prototype.applyExcretionStyle = function () {
|
72
|
+
switch (this._additionStyle) {
|
73
|
+
case 'crop':
|
74
|
+
this.determineCropStyle();
|
75
|
+
break;
|
76
|
+
case 'default':
|
77
|
+
this.determineDefaultStyle();
|
78
|
+
break;
|
79
|
+
default:
|
80
|
+
this.determineDefaultStyle();
|
81
|
+
break;
|
82
|
+
}
|
83
|
+
};
|
84
|
+
;
|
85
|
+
ExcretionsComponent.prototype.determineCropStyle = function () {
|
86
|
+
this._excretions.forEach(function (excretion) {
|
87
|
+
if (!!excretion === false)
|
88
|
+
return;
|
89
|
+
if (!excretion.classList.contains('excretion_crop')) {
|
90
|
+
excretion.classList.add("excretion_crop");
|
91
|
+
// this.cropService.viewCropButton();
|
92
|
+
}
|
93
|
+
});
|
94
|
+
};
|
95
|
+
ExcretionsComponent.prototype.determineDefaultStyle = function () {
|
96
|
+
var _this = this;
|
97
|
+
this._excretions.forEach(function (excretion) {
|
98
|
+
if (!!excretion === false)
|
99
|
+
return;
|
100
|
+
// @ts-ignore
|
101
|
+
excretion.classList = _this._excretionDefaultStyle;
|
102
|
+
});
|
103
|
+
};
|
104
|
+
ExcretionsComponent.prototype.getComponent = function () {
|
105
|
+
var wrapOptions = {
|
106
|
+
className: 'excretions-wrap',
|
107
|
+
};
|
108
|
+
var excretionsTemplate = this.getTemplate(this.template, wrapOptions);
|
109
|
+
var excretionsStyle = this.getStyle(this.css);
|
110
|
+
this.excretionWrap = excretionsTemplate;
|
111
|
+
this.emmit();
|
112
|
+
return { excretionsTemplate: excretionsTemplate, excretionsStyle: excretionsStyle };
|
113
|
+
};
|
114
|
+
Object.defineProperty(ExcretionsComponent.prototype, "excretionState", {
|
115
|
+
set: function (state) {
|
116
|
+
this._excretionState = state;
|
117
|
+
this.applyExcretionStyle();
|
118
|
+
switch (state) {
|
119
|
+
case 'abandoned':
|
120
|
+
this.canvasComponent.cursorStyle = 'default';
|
121
|
+
break;
|
122
|
+
case 'create':
|
123
|
+
this.canvasComponent.cursorStyle = 'crosshair';
|
124
|
+
break;
|
125
|
+
case 'add':
|
126
|
+
this.canvasComponent.cursorStyle = 'copy';
|
127
|
+
break;
|
128
|
+
case 'remove':
|
129
|
+
this.canvasComponent.cursorStyle = 'alias';
|
130
|
+
break;
|
131
|
+
default:
|
132
|
+
this.canvasComponent.cursorStyle = 'default';
|
133
|
+
break;
|
134
|
+
}
|
135
|
+
},
|
136
|
+
enumerable: false,
|
137
|
+
configurable: true
|
138
|
+
});
|
139
|
+
ExcretionsComponent.prototype.setToolState = function (toolState) {
|
140
|
+
this._excretionToolState = toolState;
|
141
|
+
switch (toolState) {
|
142
|
+
case 'abandoned':
|
143
|
+
this.excretionState = 'abandoned';
|
144
|
+
this._excretionActivity = 'abandoned';
|
145
|
+
break;
|
146
|
+
case 'taken':
|
147
|
+
this.excretionState = 'create';
|
148
|
+
break;
|
149
|
+
default:
|
150
|
+
this.excretionState = 'abandoned';
|
151
|
+
this._excretionActivity = 'abandoned';
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
};
|
155
|
+
ExcretionsComponent.prototype.clearExcretionsCoords = function () {
|
156
|
+
this._excretions.forEach(function (excretion) { return excretion.remove(); });
|
157
|
+
this._excretions = [];
|
158
|
+
this.excretionsCoords = [];
|
159
|
+
};
|
160
|
+
ExcretionsComponent.prototype.getTempCoords = function () {
|
161
|
+
var startCoords = this._tempCoords[0];
|
162
|
+
var endCoords = this._tempCoords[1];
|
163
|
+
var coords = Object.assign(startCoords, endCoords);
|
164
|
+
this._tempCoords = [];
|
165
|
+
return coords;
|
166
|
+
};
|
167
|
+
ExcretionsComponent.prototype.endExcretion = function () {
|
168
|
+
var coords = this.getTempCoords();
|
169
|
+
this.excretionsCoords.push(coords);
|
170
|
+
this._excretionActivity = 'end';
|
171
|
+
};
|
172
|
+
ExcretionsComponent.prototype.emmit = function () {
|
173
|
+
var _this = this;
|
174
|
+
this.canvasComponent.subscribe('mousedown', function (event, cursorPosition) {
|
175
|
+
var toolState = _this._excretionToolState;
|
176
|
+
if (toolState === 'abandoned')
|
177
|
+
return;
|
178
|
+
var state = _this._excretionState;
|
179
|
+
if (state === 'create') {
|
180
|
+
var wrapOptions = {
|
181
|
+
className: _this._excretionDefaultStyle[0],
|
182
|
+
};
|
183
|
+
var excretionTemplate = _this.getTemplate(_this.templateExcretion, wrapOptions);
|
184
|
+
_this.clearExcretionsCoords();
|
185
|
+
var tempStart = {
|
186
|
+
start: cursorPosition,
|
187
|
+
};
|
188
|
+
excretionTemplate.style.left = "".concat(tempStart.start.x, "px");
|
189
|
+
excretionTemplate.style.top = "".concat(tempStart.start.y, "px");
|
190
|
+
var excretionElement = _this.excretionWrap.appendChild(excretionTemplate);
|
191
|
+
_this._excretions.push(excretionElement);
|
192
|
+
_this._tempCoords.push(tempStart);
|
193
|
+
}
|
194
|
+
if (state === 'add') {
|
195
|
+
var tempStart = {
|
196
|
+
start: cursorPosition,
|
197
|
+
};
|
198
|
+
_this._tempCoords.push(tempStart);
|
199
|
+
}
|
200
|
+
_this.applyExcretionStyle();
|
201
|
+
_this._excretionActivity = 'active';
|
202
|
+
});
|
203
|
+
this.canvasComponent.subscribe('mousemove', function (event, cursorPosition) {
|
204
|
+
var toolState = _this._excretionToolState;
|
205
|
+
if (toolState === 'abandoned')
|
206
|
+
return;
|
207
|
+
var activity = _this._excretionActivity;
|
208
|
+
if (event.altKey && _this._excretionState !== 'abandoned') {
|
209
|
+
_this._excretionState = 'add';
|
210
|
+
}
|
211
|
+
if (activity === 'abandoned')
|
212
|
+
return;
|
213
|
+
if (activity === 'active') {
|
214
|
+
var excretionLastIndex = _this._excretions.length - 1;
|
215
|
+
var excretion = _this._excretions[excretionLastIndex];
|
216
|
+
var excretionX = +(excretion.style.left.split('px')[0]);
|
217
|
+
var excretionY = +(excretion.style.top.split('px')[0]);
|
218
|
+
var width = Math.abs(cursorPosition.x - excretionX);
|
219
|
+
var height = Math.abs(cursorPosition.y - excretionY);
|
220
|
+
excretion.style.width = width + 'px';
|
221
|
+
excretion.style.height = height + 'px';
|
222
|
+
var isRightBottom = cursorPosition.x > excretionX && cursorPosition.y > excretionY;
|
223
|
+
var isLeftBottom = cursorPosition.x < excretionX && cursorPosition.y > excretionY;
|
224
|
+
var isLeftTop = cursorPosition.x < excretionX && cursorPosition.y < excretionY;
|
225
|
+
var isRightTop = cursorPosition.x > excretionX && cursorPosition.y < excretionY;
|
226
|
+
if (isRightBottom) {
|
227
|
+
excretion.style.transform = "translateX(0px) translateY(0px)";
|
228
|
+
}
|
229
|
+
else if (isLeftBottom) {
|
230
|
+
excretion.style.transform = "translateX(-".concat(width, "px) translateY(0px)");
|
231
|
+
}
|
232
|
+
else if (isLeftTop) {
|
233
|
+
excretion.style.transform = "translateX(-".concat(width, "px) translateY(-").concat(height, "px)");
|
234
|
+
}
|
235
|
+
else if (isRightTop) {
|
236
|
+
excretion.style.transform = "translateX(0px) translateY(-".concat(height, "px)");
|
237
|
+
}
|
238
|
+
}
|
239
|
+
});
|
240
|
+
this.canvasComponent.subscribe('mouseup', function (event, cursorPosition) {
|
241
|
+
var toolState = _this._excretionToolState;
|
242
|
+
if (toolState === 'abandoned')
|
243
|
+
return;
|
244
|
+
var state = _this._excretionState;
|
245
|
+
if (state === 'abandoned')
|
246
|
+
return;
|
247
|
+
if (state === 'create' || state === 'add') {
|
248
|
+
var tempEnd = {
|
249
|
+
end: cursorPosition,
|
250
|
+
};
|
251
|
+
_this._tempCoords.push(tempEnd);
|
252
|
+
_this.endExcretion();
|
253
|
+
}
|
254
|
+
});
|
255
|
+
};
|
256
|
+
return ExcretionsComponent;
|
257
|
+
}(ComponentService));
|
258
|
+
export default ExcretionsComponent;
|
@@ -0,0 +1,71 @@
|
|
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 ComponentService from "../services/component.service";
|
19
|
+
var LoadingComponent = /** @class */ (function (_super) {
|
20
|
+
__extends(LoadingComponent, _super);
|
21
|
+
function LoadingComponent(loggerService, eventService) {
|
22
|
+
var _this = _super.call(this) || this;
|
23
|
+
_this.loggerService = loggerService;
|
24
|
+
_this.eventService = eventService;
|
25
|
+
_this.template = "\n <span class=\"loader\"></span>\n ";
|
26
|
+
_this.css = "\n .loading-wrapper {\n display: none; \n justify-content: center;\n align-items: center;\n position: absolute;\n width: 100%;\n height: 100%;\n background: #ffffff30;\n }\n\n .loader {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n position: relative;\n animation: rotate 1s linear infinite\n }\n .loader::before , .loader::after {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n inset: 0px;\n border-radius: 50%;\n border: 5px solid #FFF;\n animation: prixClipFix 2s linear infinite ;\n }\n .loader::after{\n inset: 8px;\n transform: rotate3d(90, 90, 0, 180deg );\n border-color: #FF3D00;\n }\n\n @keyframes rotate {\n 0% {transform: rotate(0deg)}\n 100% {transform: rotate(360deg)}\n }\n\n @keyframes prixClipFix {\n 0% {clip-path:polygon(50% 50%,0 0,0 0,0 0,0 0,0 0)}\n 50% {clip-path:polygon(50% 50%,0 0,100% 0,100% 0,100% 0,100% 0)}\n 75%, 100% {clip-path:polygon(50% 50%,0 0,100% 0,100% 100%,100% 100%,100% 100%)}\n }\n ";
|
27
|
+
_this.loggerService.components.add({
|
28
|
+
info: {
|
29
|
+
name: 'loading',
|
30
|
+
description: 'loading component',
|
31
|
+
},
|
32
|
+
prototype: _this,
|
33
|
+
});
|
34
|
+
return _this;
|
35
|
+
}
|
36
|
+
LoadingComponent.prototype.getComponent = function () {
|
37
|
+
var wrapOptions = {
|
38
|
+
className: 'loading-wrapper',
|
39
|
+
};
|
40
|
+
var loadingTemplate = this.getTemplate(this.template, wrapOptions);
|
41
|
+
var loadingStyle = this.getStyle(this.css);
|
42
|
+
this.loading = loadingTemplate;
|
43
|
+
this.subscribeLoadingStart();
|
44
|
+
this.subscribeLoadingEnd();
|
45
|
+
return { loadingTemplate: loadingTemplate, loadingStyle: loadingStyle };
|
46
|
+
};
|
47
|
+
LoadingComponent.prototype.hide = function () {
|
48
|
+
this.loading.style.display = 'none';
|
49
|
+
};
|
50
|
+
LoadingComponent.prototype.view = function () {
|
51
|
+
this.loading.style.display = 'flex';
|
52
|
+
};
|
53
|
+
LoadingComponent.prototype.subscribeLoadingStart = function () {
|
54
|
+
var _this = this;
|
55
|
+
var controlEvent = {
|
56
|
+
name: 'loading-start',
|
57
|
+
action: function () { return _this.view(); },
|
58
|
+
};
|
59
|
+
this.eventService.subcribe(controlEvent);
|
60
|
+
};
|
61
|
+
LoadingComponent.prototype.subscribeLoadingEnd = function () {
|
62
|
+
var _this = this;
|
63
|
+
var controlEvent = {
|
64
|
+
name: 'loading-end',
|
65
|
+
action: function () { return _this.hide(); },
|
66
|
+
};
|
67
|
+
this.eventService.subcribe(controlEvent);
|
68
|
+
};
|
69
|
+
return LoadingComponent;
|
70
|
+
}(ComponentService));
|
71
|
+
export default LoadingComponent;
|
@@ -0,0 +1,120 @@
|
|
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 { Convert } from "../utils/convert";
|
19
|
+
import ComponentService from "../services/component.service";
|
20
|
+
var PipetteComponent = /** @class */ (function (_super) {
|
21
|
+
__extends(PipetteComponent, _super);
|
22
|
+
function PipetteComponent(toolService, loggerService, canvasComponent) {
|
23
|
+
var _this = _super.call(this) || this;
|
24
|
+
_this.toolService = toolService;
|
25
|
+
_this.loggerService = loggerService;
|
26
|
+
_this.canvasComponent = canvasComponent;
|
27
|
+
_this.template = "\n <div class=\"pipette_border-out\">\n <div class=\"pipette_color\">\n <div class=\"pipette_border-in\">\n <svg width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"></g><g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></g><g id=\"SVGRepo_iconCarrier\"><path d=\"M17 12C17 14.7614 14.7614 17 12 17M17 12C17 9.23858 14.7614 7 12 7M17 12H19M12 17C9.23858 17 7 14.7614 7 12M12 17V19M7 12C7 9.23858 9.23858 7 12 7M7 12H5M12 7V5M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z\" stroke=\"#d9d9d9\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></g></svg>\n </div> \n </div>\n </div>\n ";
|
28
|
+
_this.css = "\n .pipette {\n position: absolute;\n display: none;\n justify-content: center;\n align-items: center;\n width: 48px;\n height: 48px;\n }\n\n .pipette_border-out {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 100px;\n border: solid 2px #d9d9d9;\n width: 44px;\n height: 44px;\n }\n\n .pipette_border-in {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 100px;\n border: solid 1px #d9d9d9;\n width: 32px;\n height: 32px;\n }\n\n .pipette_color {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n border-radius: 100px;\n border-color: blue;\n border-style: solid;\n border-width: 5px;\n }\n ";
|
29
|
+
_this._pipetteState = 'abandoned';
|
30
|
+
_this.tool = {
|
31
|
+
id: 0,
|
32
|
+
name: 'pipette',
|
33
|
+
onAction: function () { return _this.setState('taken'); },
|
34
|
+
offAction: function () { return _this.setState('abandoned'); },
|
35
|
+
};
|
36
|
+
_this.toolService.add(_this.tool);
|
37
|
+
_this.loggerService.components.add({
|
38
|
+
info: {
|
39
|
+
name: 'pipette',
|
40
|
+
description: 'pipette component',
|
41
|
+
},
|
42
|
+
prototype: _this,
|
43
|
+
});
|
44
|
+
return _this;
|
45
|
+
}
|
46
|
+
Object.defineProperty(PipetteComponent.prototype, "pipetteColor", {
|
47
|
+
get: function () {
|
48
|
+
return this._pipetteColor;
|
49
|
+
},
|
50
|
+
set: function (color) {
|
51
|
+
this._pipetteColor = color;
|
52
|
+
this._pipetteColorElement.style.borderColor = this._pipetteColor;
|
53
|
+
},
|
54
|
+
enumerable: false,
|
55
|
+
configurable: true
|
56
|
+
});
|
57
|
+
PipetteComponent.prototype.getComponent = function () {
|
58
|
+
var wrapOptions = {
|
59
|
+
className: 'pipette',
|
60
|
+
};
|
61
|
+
var pipetteTemplate = this.getTemplate(this.template, wrapOptions);
|
62
|
+
var pipetteStyle = this.getStyle(this.css);
|
63
|
+
this.pipette = pipetteTemplate;
|
64
|
+
this._pipetteColorElement = pipetteTemplate.querySelector('.pipette_color');
|
65
|
+
this.emmit();
|
66
|
+
return { pipetteTemplate: pipetteTemplate, pipetteStyle: pipetteStyle };
|
67
|
+
};
|
68
|
+
PipetteComponent.prototype.setState = function (state) {
|
69
|
+
this._pipetteState = state;
|
70
|
+
switch (state) {
|
71
|
+
case 'abandoned':
|
72
|
+
return this.hide();
|
73
|
+
case 'taken':
|
74
|
+
return this.show();
|
75
|
+
case 'selected-color':
|
76
|
+
return this.show();
|
77
|
+
default:
|
78
|
+
return this.hide();
|
79
|
+
}
|
80
|
+
};
|
81
|
+
PipetteComponent.prototype.emmit = function () {
|
82
|
+
var _this = this;
|
83
|
+
this.canvasComponent.subscribe('mousemove', function (event, cursorPosition) {
|
84
|
+
var state = _this._pipetteState;
|
85
|
+
if (state === 'taken' || state === 'selected-color') {
|
86
|
+
var x = cursorPosition.x, y = cursorPosition.y;
|
87
|
+
_this.pipette.style.left = "".concat(x + 10, "px");
|
88
|
+
_this.pipette.style.top = "".concat(y + 10, "px");
|
89
|
+
}
|
90
|
+
});
|
91
|
+
this.canvasComponent.subscribe('click', function (event, cursorPosition) {
|
92
|
+
var state = _this._pipetteState;
|
93
|
+
if (state === 'taken' || state === 'selected-color') {
|
94
|
+
if (state === 'taken') {
|
95
|
+
_this.setColorFromChoosenPixel(cursorPosition);
|
96
|
+
_this.setState('selected-color');
|
97
|
+
}
|
98
|
+
if (state === 'selected-color') {
|
99
|
+
_this.setColorFromChoosenPixel(cursorPosition);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
});
|
103
|
+
};
|
104
|
+
PipetteComponent.prototype.setColorFromChoosenPixel = function (cursorPosition) {
|
105
|
+
var x = cursorPosition.x, y = cursorPosition.y;
|
106
|
+
var pixel = this.canvasComponent.ctx.getImageData(x, y, 1, 1).data;
|
107
|
+
var hexPixel = Convert.rgbToHex(pixel[0], pixel[1], pixel[2]);
|
108
|
+
this.pipetteColor = hexPixel;
|
109
|
+
};
|
110
|
+
PipetteComponent.prototype.show = function () {
|
111
|
+
this.pipette.style.display = 'flex';
|
112
|
+
this.canvasComponent.cursorStyle = 'default';
|
113
|
+
};
|
114
|
+
PipetteComponent.prototype.hide = function () {
|
115
|
+
this.pipette.style.display = 'none';
|
116
|
+
this.canvasComponent.cursorStyle = 'default';
|
117
|
+
};
|
118
|
+
return PipetteComponent;
|
119
|
+
}(ComponentService));
|
120
|
+
export default PipetteComponent;
|
@@ -0,0 +1,45 @@
|
|
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 ComponentService from "../services/component.service";
|
17
|
+
var SlotComponent = /** @class */ (function (_super) {
|
18
|
+
__extends(SlotComponent, _super);
|
19
|
+
function SlotComponent(loggerService) {
|
20
|
+
var _this = _super.call(this) || this;
|
21
|
+
_this.loggerService = loggerService;
|
22
|
+
_this.template = "\n <slot class=\"slot\"></slot>\n ";
|
23
|
+
_this.css = "";
|
24
|
+
_this.loggerService.components.add({
|
25
|
+
info: {
|
26
|
+
name: 'slot',
|
27
|
+
description: 'slot component',
|
28
|
+
},
|
29
|
+
prototype: _this,
|
30
|
+
});
|
31
|
+
return _this;
|
32
|
+
}
|
33
|
+
SlotComponent.prototype.getComponent = function (slotName) {
|
34
|
+
var wrapOptions = {
|
35
|
+
className: 'slot-wrapper',
|
36
|
+
};
|
37
|
+
var slotTemplate = this.getTemplate(this.template, wrapOptions);
|
38
|
+
var slotStyle = this.getStyle(this.css);
|
39
|
+
this.slot = slotTemplate.querySelector('slot');
|
40
|
+
this.slot.name = slotName;
|
41
|
+
return { slotTemplate: slotTemplate, slotStyle: slotStyle };
|
42
|
+
};
|
43
|
+
return SlotComponent;
|
44
|
+
}(ComponentService));
|
45
|
+
export default SlotComponent;
|